GeSHi Source Viewer: wavesurfer.jsView Raw


  1. /*!
  2.  * wavesurfer.js 6.6.4 (2023-06-10)
  3.  * https://wavesurfer-js.org
  4.  * @license BSD-3-Clause
  5.  */
  6. (function webpackUniversalModuleDefinition(root, factory) {
  7. 	if(typeof exports === 'object' && typeof module === 'object')
  8. 		module.exports = factory();
  9. 	else if(typeof define === 'function' && define.amd)
  10. 		define("WaveSurfer", [], factory);
  11. 	else if(typeof exports === 'object')
  12. 		exports["WaveSurfer"] = factory();
  13. 	else
  14. 		root["WaveSurfer"] = factory();
  15. })(self, () => {
  16. return /******/ (() => { // webpackBootstrap
  17. /******/ 	var __webpack_modules__ = ({
  18.  
  19. /***/ "./src/drawer.canvasentry.js":
  20. /*!***********************************!*\
  21.   !*** ./src/drawer.canvasentry.js ***!
  22.   \***********************************/
  23. /***/ ((module, exports, __webpack_require__) => {
  24.  
  25. "use strict";
  26.  
  27.  
  28. Object.defineProperty(exports, "__esModule", ({
  29.   value: true
  30. }));
  31. exports["default"] = void 0;
  32. var _style = _interopRequireDefault(__webpack_require__(/*! ./util/style */ "./src/util/style.js"));
  33. var _getId = _interopRequireDefault(__webpack_require__(/*! ./util/get-id */ "./src/util/get-id.js"));
  34. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  35. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  36. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  38. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  39. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  40. function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  41. /**
  42.  * The `CanvasEntry` class represents an element consisting of a wave `canvas`
  43.  * and an (optional) progress wave `canvas`.
  44.  *
  45.  * The `MultiCanvas` renderer uses one or more `CanvasEntry` instances to
  46.  * render a waveform, depending on the zoom level.
  47.  */
  48. var CanvasEntry = /*#__PURE__*/function () {
  49.   function CanvasEntry() {
  50.     _classCallCheck(this, CanvasEntry);
  51.     /**
  52.      * The wave node
  53.      *
  54.      * @type {HTMLCanvasElement}
  55.      */
  56.     this.wave = null;
  57.     /**
  58.      * The wave canvas rendering context
  59.      *
  60.      * @type {CanvasRenderingContext2D}
  61.      */
  62.     this.waveCtx = null;
  63.     /**
  64.      * The (optional) progress wave node
  65.      *
  66.      * @type {HTMLCanvasElement}
  67.      */
  68.     this.progress = null;
  69.     /**
  70.      * The (optional) progress wave canvas rendering context
  71.      *
  72.      * @type {CanvasRenderingContext2D}
  73.      */
  74.     this.progressCtx = null;
  75.     /**
  76.      * Start of the area the canvas should render, between 0 and 1
  77.      *
  78.      * @type {number}
  79.      */
  80.     this.start = 0;
  81.     /**
  82.      * End of the area the canvas should render, between 0 and 1
  83.      *
  84.      * @type {number}
  85.      */
  86.     this.end = 1;
  87.     /**
  88.      * Unique identifier for this entry
  89.      *
  90.      * @type {string}
  91.      */
  92.     this.id = (0, _getId.default)(typeof this.constructor.name !== 'undefined' ? this.constructor.name.toLowerCase() + '_' : 'canvasentry_');
  93.     /**
  94.      * Canvas 2d context attributes
  95.      *
  96.      * @type {object}
  97.      */
  98.     this.canvasContextAttributes = {};
  99.   }
  100.  
  101.   /**
  102.    * Store the wave canvas element and create the 2D rendering context
  103.    *
  104.    * @param {HTMLCanvasElement} element The wave `canvas` element.
  105.    */
  106.   _createClass(CanvasEntry, [{
  107.     key: "initWave",
  108.     value: function initWave(element) {
  109.       this.wave = element;
  110.       this.waveCtx = this.wave.getContext('2d', this.canvasContextAttributes);
  111.     }
  112.  
  113.     /**
  114.      * Store the progress wave canvas element and create the 2D rendering
  115.      * context
  116.      *
  117.      * @param {HTMLCanvasElement} element The progress wave `canvas` element.
  118.      */
  119.   }, {
  120.     key: "initProgress",
  121.     value: function initProgress(element) {
  122.       this.progress = element;
  123.       this.progressCtx = this.progress.getContext('2d', this.canvasContextAttributes);
  124.     }
  125.  
  126.     /**
  127.      * Update the dimensions
  128.      *
  129.      * @param {number} elementWidth Width of the entry
  130.      * @param {number} totalWidth Total width of the multi canvas renderer
  131.      * @param {number} width The new width of the element
  132.      * @param {number} height The new height of the element
  133.      */
  134.   }, {
  135.     key: "updateDimensions",
  136.     value: function updateDimensions(elementWidth, totalWidth, width, height) {
  137.       // where the canvas starts and ends in the waveform, represented as a
  138.       // decimal between 0 and 1
  139.       this.start = this.wave.offsetLeft / totalWidth || 0;
  140.       this.end = this.start + elementWidth / totalWidth;
  141.  
  142.       // set wave canvas dimensions
  143.       this.wave.width = width;
  144.       this.wave.height = height;
  145.       var elementSize = {
  146.         width: elementWidth + 'px'
  147.       };
  148.       (0, _style.default)(this.wave, elementSize);
  149.       if (this.hasProgressCanvas) {
  150.         // set progress canvas dimensions
  151.         this.progress.width = width;
  152.         this.progress.height = height;
  153.         (0, _style.default)(this.progress, elementSize);
  154.       }
  155.     }
  156.  
  157.     /**
  158.      * Clear the wave and progress rendering contexts
  159.      */
  160.   }, {
  161.     key: "clearWave",
  162.     value: function clearWave() {
  163.       // wave
  164.       this.waveCtx.clearRect(0, 0, this.waveCtx.canvas.width, this.waveCtx.canvas.height);
  165.  
  166.       // progress
  167.       if (this.hasProgressCanvas) {
  168.         this.progressCtx.clearRect(0, 0, this.progressCtx.canvas.width, this.progressCtx.canvas.height);
  169.       }
  170.     }
  171.  
  172.     /**
  173.      * Set the fill styles for wave and progress
  174.      * @param {string|string[]} waveColor Fill color for the wave canvas,
  175.      * or an array of colors to apply as a gradient
  176.      * @param {?string|string[]} progressColor Fill color for the progress canvas,
  177.      * or an array of colors to apply as a gradient
  178.      */
  179.   }, {
  180.     key: "setFillStyles",
  181.     value: function setFillStyles(waveColor, progressColor) {
  182.       this.waveCtx.fillStyle = this.getFillStyle(this.waveCtx, waveColor);
  183.       if (this.hasProgressCanvas) {
  184.         this.progressCtx.fillStyle = this.getFillStyle(this.progressCtx, progressColor);
  185.       }
  186.     }
  187.  
  188.     /**
  189.      * Utility function to handle wave color arguments
  190.      *
  191.      * When the color argument type is a string or CanvasGradient instance,
  192.      * it will be returned as is. Otherwise, it will be treated as an array,
  193.      * and a new CanvasGradient will be returned
  194.      *
  195.      * @since 6.0.0
  196.      * @param {CanvasRenderingContext2D} ctx Rendering context of target canvas
  197.      * @param {string|string[]|CanvasGradient} color Either a single fill color
  198.      *     for the wave canvas, an existing CanvasGradient instance, or an array
  199.      *     of colors to apply as a gradient
  200.      * @returns {string|CanvasGradient} Returns a string fillstyle value, or a
  201.      *     canvas gradient
  202.      */
  203.   }, {
  204.     key: "getFillStyle",
  205.     value: function getFillStyle(ctx, color) {
  206.       if (typeof color == 'string' || color instanceof CanvasGradient) {
  207.         return color;
  208.       }
  209.       var waveGradient = ctx.createLinearGradient(0, 0, 0, ctx.canvas.height);
  210.       color.forEach(function (value, index) {
  211.         return waveGradient.addColorStop(index / color.length, value);
  212.       });
  213.       return waveGradient;
  214.     }
  215.  
  216.     /**
  217.      * Set the canvas transforms for wave and progress
  218.      *
  219.      * @param {boolean} vertical Whether to render vertically
  220.      */
  221.   }, {
  222.     key: "applyCanvasTransforms",
  223.     value: function applyCanvasTransforms(vertical) {
  224.       if (vertical) {
  225.         // Reflect the waveform across the line y = -x
  226.         this.waveCtx.setTransform(0, 1, 1, 0, 0, 0);
  227.         if (this.hasProgressCanvas) {
  228.           this.progressCtx.setTransform(0, 1, 1, 0, 0, 0);
  229.         }
  230.       }
  231.     }
  232.  
  233.     /**
  234.      * Draw a rectangle for wave and progress
  235.      *
  236.      * @param {number} x X start position
  237.      * @param {number} y Y start position
  238.      * @param {number} width Width of the rectangle
  239.      * @param {number} height Height of the rectangle
  240.      * @param {number} radius Radius of the rectangle
  241.      */
  242.   }, {
  243.     key: "fillRects",
  244.     value: function fillRects(x, y, width, height, radius) {
  245.       this.fillRectToContext(this.waveCtx, x, y, width, height, radius);
  246.       if (this.hasProgressCanvas) {
  247.         this.fillRectToContext(this.progressCtx, x, y, width, height, radius);
  248.       }
  249.     }
  250.  
  251.     /**
  252.      * Draw the actual rectangle on a `canvas` element
  253.      *
  254.      * @param {CanvasRenderingContext2D} ctx Rendering context of target canvas
  255.      * @param {number} x X start position
  256.      * @param {number} y Y start position
  257.      * @param {number} width Width of the rectangle
  258.      * @param {number} height Height of the rectangle
  259.      * @param {number} radius Radius of the rectangle
  260.      */
  261.   }, {
  262.     key: "fillRectToContext",
  263.     value: function fillRectToContext(ctx, x, y, width, height, radius) {
  264.       if (!ctx) {
  265.         return;
  266.       }
  267.       if (radius) {
  268.         this.drawRoundedRect(ctx, x, y, width, height, radius);
  269.       } else {
  270.         ctx.fillRect(x, y, width, height);
  271.       }
  272.     }
  273.  
  274.     /**
  275.      * Draw a rounded rectangle on Canvas
  276.      *
  277.      * @param {CanvasRenderingContext2D} ctx Canvas context
  278.      * @param {number} x X-position of the rectangle
  279.      * @param {number} y Y-position of the rectangle
  280.      * @param {number} width Width of the rectangle
  281.      * @param {number} height Height of the rectangle
  282.      * @param {number} radius Radius of the rectangle
  283.      *
  284.      * @return {void}
  285.      * @example drawRoundedRect(ctx, 50, 50, 5, 10, 3)
  286.      */
  287.   }, {
  288.     key: "drawRoundedRect",
  289.     value: function drawRoundedRect(ctx, x, y, width, height, radius) {
  290.       if (height === 0) {
  291.         return;
  292.       }
  293.       // peaks are float values from -1 to 1. Use absolute height values in
  294.       // order to correctly calculate rounded rectangle coordinates
  295.       if (height < 0) {
  296.         height *= -1;
  297.         y -= height;
  298.       }
  299.       ctx.beginPath();
  300.       ctx.moveTo(x + radius, y);
  301.       ctx.lineTo(x + width - radius, y);
  302.       ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
  303.       ctx.lineTo(x + width, y + height - radius);
  304.       ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  305.       ctx.lineTo(x + radius, y + height);
  306.       ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
  307.       ctx.lineTo(x, y + radius);
  308.       ctx.quadraticCurveTo(x, y, x + radius, y);
  309.       ctx.closePath();
  310.       ctx.fill();
  311.     }
  312.  
  313.     /**
  314.      * Render the actual wave and progress lines
  315.      *
  316.      * @param {number[]} peaks Array with peaks data
  317.      * @param {number} absmax Maximum peak value (absolute)
  318.      * @param {number} halfH Half the height of the waveform
  319.      * @param {number} offsetY Offset to the top
  320.      * @param {number} start The x-offset of the beginning of the area that
  321.      * should be rendered
  322.      * @param {number} end The x-offset of the end of the area that
  323.      * should be rendered
  324.      */
  325.   }, {
  326.     key: "drawLines",
  327.     value: function drawLines(peaks, absmax, halfH, offsetY, start, end) {
  328.       this.drawLineToContext(this.waveCtx, peaks, absmax, halfH, offsetY, start, end);
  329.       if (this.hasProgressCanvas) {
  330.         this.drawLineToContext(this.progressCtx, peaks, absmax, halfH, offsetY, start, end);
  331.       }
  332.     }
  333.  
  334.     /**
  335.      * Render the actual waveform line on a `canvas` element
  336.      *
  337.      * @param {CanvasRenderingContext2D} ctx Rendering context of target canvas
  338.      * @param {number[]} peaks Array with peaks data
  339.      * @param {number} absmax Maximum peak value (absolute)
  340.      * @param {number} halfH Half the height of the waveform
  341.      * @param {number} offsetY Offset to the top
  342.      * @param {number} start The x-offset of the beginning of the area that
  343.      * should be rendered
  344.      * @param {number} end The x-offset of the end of the area that
  345.      * should be rendered
  346.      */
  347.   }, {
  348.     key: "drawLineToContext",
  349.     value: function drawLineToContext(ctx, peaks, absmax, halfH, offsetY, start, end) {
  350.       if (!ctx) {
  351.         return;
  352.       }
  353.       var length = peaks.length / 2;
  354.       var first = Math.round(length * this.start);
  355.  
  356.       // use one more peak value to make sure we join peaks at ends -- unless,
  357.       // of course, this is the last canvas
  358.       var last = Math.round(length * this.end) + 1;
  359.       var canvasStart = first;
  360.       var canvasEnd = last;
  361.       var scale = this.wave.width / (canvasEnd - canvasStart - 1);
  362.  
  363.       // optimization
  364.       var halfOffset = halfH + offsetY;
  365.       var absmaxHalf = absmax / halfH;
  366.       ctx.beginPath();
  367.       ctx.moveTo((canvasStart - first) * scale, halfOffset);
  368.       ctx.lineTo((canvasStart - first) * scale, halfOffset - Math.round((peaks[2 * canvasStart] || 0) / absmaxHalf));
  369.       var i, peak, h;
  370.       for (i = canvasStart; i < canvasEnd; i++) {
  371.         peak = peaks[2 * i] || 0;
  372.         h = Math.round(peak / absmaxHalf);
  373.         ctx.lineTo((i - first) * scale + this.halfPixel, halfOffset - h);
  374.       }
  375.  
  376.       // draw the bottom edge going backwards, to make a single
  377.       // closed hull to fill
  378.       var j = canvasEnd - 1;
  379.       for (j; j >= canvasStart; j--) {
  380.         peak = peaks[2 * j + 1] || 0;
  381.         h = Math.round(peak / absmaxHalf);
  382.         ctx.lineTo((j - first) * scale + this.halfPixel, halfOffset - h);
  383.       }
  384.       ctx.lineTo((canvasStart - first) * scale, halfOffset - Math.round((peaks[2 * canvasStart + 1] || 0) / absmaxHalf));
  385.       ctx.closePath();
  386.       ctx.fill();
  387.     }
  388.  
  389.     /**
  390.      * Destroys this entry
  391.      */
  392.   }, {
  393.     key: "destroy",
  394.     value: function destroy() {
  395.       this.waveCtx = null;
  396.       this.wave = null;
  397.       this.progressCtx = null;
  398.       this.progress = null;
  399.     }
  400.  
  401.     /**
  402.      * Return image data of the wave `canvas` element
  403.      *
  404.      * When using a `type` of `'blob'`, this will return a `Promise` that
  405.      * resolves with a `Blob` instance.
  406.      *
  407.      * @param {string} format='image/png' An optional value of a format type.
  408.      * @param {number} quality=0.92 An optional value between 0 and 1.
  409.      * @param {string} type='dataURL' Either 'dataURL' or 'blob'.
  410.      * @return {string|Promise} When using the default `'dataURL'` `type` this
  411.      * returns a data URL. When using the `'blob'` `type` this returns a
  412.      * `Promise` that resolves with a `Blob` instance.
  413.      */
  414.   }, {
  415.     key: "getImage",
  416.     value: function getImage(format, quality, type) {
  417.       var _this = this;
  418.       if (type === 'blob') {
  419.         return new Promise(function (resolve) {
  420.           _this.wave.toBlob(resolve, format, quality);
  421.         });
  422.       } else if (type === 'dataURL') {
  423.         return this.wave.toDataURL(format, quality);
  424.       }
  425.     }
  426.   }]);
  427.   return CanvasEntry;
  428. }();
  429. exports["default"] = CanvasEntry;
  430. module.exports = exports.default;
  431.  
  432. /***/ }),
  433.  
  434. /***/ "./src/drawer.js":
  435. /*!***********************!*\
  436.   !*** ./src/drawer.js ***!
  437.   \***********************/
  438. /***/ ((module, exports, __webpack_require__) => {
  439.  
  440. "use strict";
  441.  
  442.  
  443. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  444. Object.defineProperty(exports, "__esModule", ({
  445.   value: true
  446. }));
  447. exports["default"] = void 0;
  448. var util = _interopRequireWildcard(__webpack_require__(/*! ./util */ "./src/util/index.js"));
  449. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  450. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  451. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  452. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  453. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  454. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  455. function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  456. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  457. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  458. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  459. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  460. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  461. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  462. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  463. /**
  464.  * Parent class for renderers
  465.  *
  466.  * @extends {Observer}
  467.  */
  468. var Drawer = /*#__PURE__*/function (_util$Observer) {
  469.   _inherits(Drawer, _util$Observer);
  470.   var _super = _createSuper(Drawer);
  471.   /**
  472.    * @param {HTMLElement} container The container node of the wavesurfer instance
  473.    * @param {WavesurferParams} params The wavesurfer initialisation options
  474.    */
  475.   function Drawer(container, params) {
  476.     var _this;
  477.     _classCallCheck(this, Drawer);
  478.     _this = _super.call(this);
  479.     _this.container = util.withOrientation(container, params.vertical);
  480.     /**
  481.      * @type {WavesurferParams}
  482.      */
  483.     _this.params = params;
  484.     /**
  485.      * The width of the renderer
  486.      * @type {number}
  487.      */
  488.     _this.width = 0;
  489.     /**
  490.      * The height of the renderer
  491.      * @type {number}
  492.      */
  493.     _this.height = params.height * _this.params.pixelRatio;
  494.     _this.lastPos = 0;
  495.     /**
  496.      * The `<wave>` element which is added to the container
  497.      * @type {HTMLElement}
  498.      */
  499.     _this.wrapper = null;
  500.     return _this;
  501.   }
  502.  
  503.   /**
  504.    * Alias of `util.style`
  505.    *
  506.    * @param {HTMLElement} el The element that the styles will be applied to
  507.    * @param {Object} styles The map of propName: attribute, both are used as-is
  508.    * @return {HTMLElement} el
  509.    */
  510.   _createClass(Drawer, [{
  511.     key: "style",
  512.     value: function style(el, styles) {
  513.       return util.style(el, styles);
  514.     }
  515.  
  516.     /**
  517.      * Create the wrapper `<wave>` element, style it and set up the events for
  518.      * interaction
  519.      */
  520.   }, {
  521.     key: "createWrapper",
  522.     value: function createWrapper() {
  523.       this.wrapper = util.withOrientation(this.container.appendChild(document.createElement('wave')), this.params.vertical);
  524.       this.style(this.wrapper, {
  525.         display: 'block',
  526.         position: 'relative',
  527.         userSelect: 'none',
  528.         webkitUserSelect: 'none',
  529.         height: this.params.height + 'px'
  530.       });
  531.       if (this.params.fillParent || this.params.scrollParent) {
  532.         this.style(this.wrapper, {
  533.           width: '100%',
  534.           cursor: this.params.hideCursor ? 'none' : 'auto',
  535.           overflowX: this.params.hideScrollbar ? 'hidden' : 'auto',
  536.           overflowY: 'hidden'
  537.         });
  538.       }
  539.       this.setupWrapperEvents();
  540.     }
  541.  
  542.     /**
  543.      * Handle click event
  544.      *
  545.      * @param {Event} e Click event
  546.      * @param {?boolean} noPrevent Set to true to not call `e.preventDefault()`
  547.      * @return {number} Playback position from 0 to 1
  548.      */
  549.   }, {
  550.     key: "handleEvent",
  551.     value: function handleEvent(e, noPrevent) {
  552.       !noPrevent && e.preventDefault();
  553.       var clientX = util.withOrientation(e.targetTouches ? e.targetTouches[0] : e, this.params.vertical).clientX;
  554.       var bbox = this.wrapper.getBoundingClientRect();
  555.       var nominalWidth = this.width;
  556.       var parentWidth = this.getWidth();
  557.       var progressPixels = this.getProgressPixels(bbox, clientX);
  558.       var progress;
  559.       if (!this.params.fillParent && nominalWidth < parentWidth) {
  560.         progress = progressPixels * (this.params.pixelRatio / nominalWidth) || 0;
  561.       } else {
  562.         progress = (progressPixels + this.wrapper.scrollLeft) / this.wrapper.scrollWidth || 0;
  563.       }
  564.       return util.clamp(progress, 0, 1);
  565.     }
  566.   }, {
  567.     key: "getProgressPixels",
  568.     value: function getProgressPixels(wrapperBbox, clientX) {
  569.       if (this.params.rtl) {
  570.         return wrapperBbox.right - clientX;
  571.       } else {
  572.         return clientX - wrapperBbox.left;
  573.       }
  574.     }
  575.   }, {
  576.     key: "setupWrapperEvents",
  577.     value: function setupWrapperEvents() {
  578.       var _this2 = this;
  579.       this.wrapper.addEventListener('click', function (e) {
  580.         var orientedEvent = util.withOrientation(e, _this2.params.vertical);
  581.         var scrollbarHeight = _this2.wrapper.offsetHeight - _this2.wrapper.clientHeight;
  582.         if (scrollbarHeight !== 0) {
  583.           // scrollbar is visible.  Check if click was on it
  584.           var bbox = _this2.wrapper.getBoundingClientRect();
  585.           if (orientedEvent.clientY >= bbox.bottom - scrollbarHeight) {
  586.             // ignore mousedown as it was on the scrollbar
  587.             return;
  588.           }
  589.         }
  590.         if (_this2.params.interact) {
  591.           _this2.fireEvent('click', e, _this2.handleEvent(e));
  592.         }
  593.       });
  594.       this.wrapper.addEventListener('dblclick', function (e) {
  595.         if (_this2.params.interact) {
  596.           _this2.fireEvent('dblclick', e, _this2.handleEvent(e));
  597.         }
  598.       });
  599.       this.wrapper.addEventListener('scroll', function (e) {
  600.         return _this2.fireEvent('scroll', e);
  601.       });
  602.     }
  603.  
  604.     /**
  605.      * Draw peaks on the canvas
  606.      *
  607.      * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
  608.      * for split channel rendering
  609.      * @param {number} length The width of the area that should be drawn
  610.      * @param {number} start The x-offset of the beginning of the area that
  611.      * should be rendered
  612.      * @param {number} end The x-offset of the end of the area that should be
  613.      * rendered
  614.      */
  615.   }, {
  616.     key: "drawPeaks",
  617.     value: function drawPeaks(peaks, length, start, end) {
  618.       if (!this.setWidth(length)) {
  619.         this.clearWave();
  620.       }
  621.       this.params.barWidth ? this.drawBars(peaks, 0, start, end) : this.drawWave(peaks, 0, start, end);
  622.     }
  623.  
  624.     /**
  625.      * Scroll to the beginning
  626.      */
  627.   }, {
  628.     key: "resetScroll",
  629.     value: function resetScroll() {
  630.       if (this.wrapper !== null) {
  631.         this.wrapper.scrollLeft = 0;
  632.       }
  633.     }
  634.  
  635.     /**
  636.      * Recenter the view-port at a certain percent of the waveform
  637.      *
  638.      * @param {number} percent Value from 0 to 1 on the waveform
  639.      */
  640.   }, {
  641.     key: "recenter",
  642.     value: function recenter(percent) {
  643.       var position = this.wrapper.scrollWidth * percent;
  644.       this.recenterOnPosition(position, true);
  645.     }
  646.  
  647.     /**
  648.      * Recenter the view-port on a position, either scroll there immediately or
  649.      * in steps of 5 pixels
  650.      *
  651.      * @param {number} position X-offset in pixels
  652.      * @param {boolean} immediate Set to true to immediately scroll somewhere
  653.      */
  654.   }, {
  655.     key: "recenterOnPosition",
  656.     value: function recenterOnPosition(position, immediate) {
  657.       var scrollLeft = this.wrapper.scrollLeft;
  658.       var half = ~~(this.wrapper.clientWidth / 2);
  659.       var maxScroll = this.wrapper.scrollWidth - this.wrapper.clientWidth;
  660.       var target = position - half;
  661.       var offset = target - scrollLeft;
  662.       if (maxScroll == 0) {
  663.         // no need to continue if scrollbar is not there
  664.         return;
  665.       }
  666.  
  667.       // if the cursor is currently visible...
  668.       if (!immediate && -half <= offset && offset < half) {
  669.         // set rate at which waveform is centered
  670.         var rate = this.params.autoCenterRate;
  671.  
  672.         // make rate depend on width of view and length of waveform
  673.         rate /= half;
  674.         rate *= maxScroll;
  675.         offset = Math.max(-rate, Math.min(rate, offset));
  676.         target = scrollLeft + offset;
  677.       }
  678.  
  679.       // limit target to valid range (0 to maxScroll)
  680.       target = Math.max(0, Math.min(maxScroll, target));
  681.       // no use attempting to scroll if we're not moving
  682.       if (target != scrollLeft) {
  683.         this.wrapper.scrollLeft = target;
  684.       }
  685.     }
  686.  
  687.     /**
  688.      * Get the current scroll position in pixels
  689.      *
  690.      * @return {number} Horizontal scroll position in pixels
  691.      */
  692.   }, {
  693.     key: "getScrollX",
  694.     value: function getScrollX() {
  695.       var x = 0;
  696.       if (this.wrapper) {
  697.         var pixelRatio = this.params.pixelRatio;
  698.         x = Math.round(this.wrapper.scrollLeft * pixelRatio);
  699.  
  700.         // In cases of elastic scroll (safari with mouse wheel) you can
  701.         // scroll beyond the limits of the container
  702.         // Calculate and floor the scrollable extent to make sure an out
  703.         // of bounds value is not returned
  704.         // Ticket #1312
  705.         if (this.params.scrollParent) {
  706.           var maxScroll = ~~(this.wrapper.scrollWidth * pixelRatio - this.getWidth());
  707.           x = Math.min(maxScroll, Math.max(0, x));
  708.         }
  709.       }
  710.       return x;
  711.     }
  712.  
  713.     /**
  714.      * Get the width of the container
  715.      *
  716.      * @return {number} The width of the container
  717.      */
  718.   }, {
  719.     key: "getWidth",
  720.     value: function getWidth() {
  721.       return Math.round(this.container.clientWidth * this.params.pixelRatio);
  722.     }
  723.  
  724.     /**
  725.      * Set the width of the container
  726.      *
  727.      * @param {number} width The new width of the container
  728.      * @return {boolean} Whether the width of the container was updated or not
  729.      */
  730.   }, {
  731.     key: "setWidth",
  732.     value: function setWidth(width) {
  733.       if (this.width == width) {
  734.         return false;
  735.       }
  736.       this.width = width;
  737.       if (this.params.fillParent || this.params.scrollParent) {
  738.         this.style(this.wrapper, {
  739.           width: ''
  740.         });
  741.       } else {
  742.         var newWidth = ~~(this.width / this.params.pixelRatio) + 'px';
  743.         this.style(this.wrapper, {
  744.           width: newWidth
  745.         });
  746.       }
  747.       this.updateSize();
  748.       return true;
  749.     }
  750.  
  751.     /**
  752.      * Set the height of the container
  753.      *
  754.      * @param {number} height The new height of the container.
  755.      * @return {boolean} Whether the height of the container was updated or not
  756.      */
  757.   }, {
  758.     key: "setHeight",
  759.     value: function setHeight(height) {
  760.       if (height == this.height) {
  761.         return false;
  762.       }
  763.       this.height = height;
  764.       this.style(this.wrapper, {
  765.         height: ~~(this.height / this.params.pixelRatio) + 'px'
  766.       });
  767.       this.updateSize();
  768.       return true;
  769.     }
  770.  
  771.     /**
  772.      * Called by wavesurfer when progress should be rendered
  773.      *
  774.      * @param {number} progress From 0 to 1
  775.      */
  776.   }, {
  777.     key: "progress",
  778.     value: function progress(_progress) {
  779.       var minPxDelta = 1 / this.params.pixelRatio;
  780.       var pos = Math.round(_progress * this.width) * minPxDelta;
  781.       if (pos < this.lastPos || pos - this.lastPos >= minPxDelta) {
  782.         this.lastPos = pos;
  783.         if (this.params.scrollParent && this.params.autoCenter) {
  784.           var newPos = ~~(this.wrapper.scrollWidth * _progress);
  785.           this.recenterOnPosition(newPos, this.params.autoCenterImmediately);
  786.         }
  787.         this.updateProgress(pos);
  788.       }
  789.     }
  790.  
  791.     /**
  792.      * This is called when wavesurfer is destroyed
  793.      */
  794.   }, {
  795.     key: "destroy",
  796.     value: function destroy() {
  797.       this.unAll();
  798.       if (this.wrapper) {
  799.         if (this.wrapper.parentNode == this.container.domElement) {
  800.           this.container.removeChild(this.wrapper.domElement);
  801.         }
  802.         this.wrapper = null;
  803.       }
  804.     }
  805.  
  806.     /* Renderer-specific methods */
  807.  
  808.     /**
  809.      * Called after cursor related params have changed.
  810.      *
  811.      * @abstract
  812.      */
  813.   }, {
  814.     key: "updateCursor",
  815.     value: function updateCursor() {}
  816.  
  817.     /**
  818.      * Called when the size of the container changes so the renderer can adjust
  819.      *
  820.      * @abstract
  821.      */
  822.   }, {
  823.     key: "updateSize",
  824.     value: function updateSize() {}
  825.  
  826.     /**
  827.      * Draw a waveform with bars
  828.      *
  829.      * @abstract
  830.      * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays for split channel
  831.      * rendering
  832.      * @param {number} channelIndex The index of the current channel. Normally
  833.      * should be 0
  834.      * @param {number} start The x-offset of the beginning of the area that
  835.      * should be rendered
  836.      * @param {number} end The x-offset of the end of the area that should be
  837.      * rendered
  838.      */
  839.   }, {
  840.     key: "drawBars",
  841.     value: function drawBars(peaks, channelIndex, start, end) {}
  842.  
  843.     /**
  844.      * Draw a waveform
  845.      *
  846.      * @abstract
  847.      * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays for split channel
  848.      * rendering
  849.      * @param {number} channelIndex The index of the current channel. Normally
  850.      * should be 0
  851.      * @param {number} start The x-offset of the beginning of the area that
  852.      * should be rendered
  853.      * @param {number} end The x-offset of the end of the area that should be
  854.      * rendered
  855.      */
  856.   }, {
  857.     key: "drawWave",
  858.     value: function drawWave(peaks, channelIndex, start, end) {}
  859.  
  860.     /**
  861.      * Clear the waveform
  862.      *
  863.      * @abstract
  864.      */
  865.   }, {
  866.     key: "clearWave",
  867.     value: function clearWave() {}
  868.  
  869.     /**
  870.      * Render the new progress
  871.      *
  872.      * @abstract
  873.      * @param {number} position X-Offset of progress position in pixels
  874.      */
  875.   }, {
  876.     key: "updateProgress",
  877.     value: function updateProgress(position) {}
  878.   }]);
  879.   return Drawer;
  880. }(util.Observer);
  881. exports["default"] = Drawer;
  882. module.exports = exports.default;
  883.  
  884. /***/ }),
  885.  
  886. /***/ "./src/drawer.multicanvas.js":
  887. /*!***********************************!*\
  888.   !*** ./src/drawer.multicanvas.js ***!
  889.   \***********************************/
  890. /***/ ((module, exports, __webpack_require__) => {
  891.  
  892. "use strict";
  893.  
  894.  
  895. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  896. Object.defineProperty(exports, "__esModule", ({
  897.   value: true
  898. }));
  899. exports["default"] = void 0;
  900. var _drawer = _interopRequireDefault(__webpack_require__(/*! ./drawer */ "./src/drawer.js"));
  901. var util = _interopRequireWildcard(__webpack_require__(/*! ./util */ "./src/util/index.js"));
  902. var _drawer2 = _interopRequireDefault(__webpack_require__(/*! ./drawer.canvasentry */ "./src/drawer.canvasentry.js"));
  903. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  904. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  905. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  906. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  907. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  908. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  909. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  910. function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  911. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  912. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  913. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  914. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  915. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  916. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  917. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  918. /**
  919.  * MultiCanvas renderer for wavesurfer. Is currently the default and sole
  920.  * builtin renderer.
  921.  *
  922.  * A `MultiCanvas` consists of one or more `CanvasEntry` instances, depending
  923.  * on the zoom level.
  924.  */
  925. var MultiCanvas = /*#__PURE__*/function (_Drawer) {
  926.   _inherits(MultiCanvas, _Drawer);
  927.   var _super = _createSuper(MultiCanvas);
  928.   /**
  929.    * @param {HTMLElement} container The container node of the wavesurfer instance
  930.    * @param {WavesurferParams} params The wavesurfer initialisation options
  931.    */
  932.   function MultiCanvas(container, params) {
  933.     var _this;
  934.     _classCallCheck(this, MultiCanvas);
  935.     _this = _super.call(this, container, params);
  936.  
  937.     /**
  938.      * @type {number}
  939.      */
  940.     _this.maxCanvasWidth = params.maxCanvasWidth;
  941.  
  942.     /**
  943.      * @type {number}
  944.      */
  945.     _this.maxCanvasElementWidth = Math.round(params.maxCanvasWidth / params.pixelRatio);
  946.  
  947.     /**
  948.      * Whether or not the progress wave is rendered. If the `waveColor`
  949.      * and `progressColor` are the same color it is not.
  950.      *
  951.      * @type {boolean}
  952.      */
  953.     _this.hasProgressCanvas = params.waveColor != params.progressColor;
  954.  
  955.     /**
  956.      * @type {number}
  957.      */
  958.     _this.halfPixel = 0.5 / params.pixelRatio;
  959.  
  960.     /**
  961.      * List of `CanvasEntry` instances.
  962.      *
  963.      * @type {Array}
  964.      */
  965.     _this.canvases = [];
  966.  
  967.     /**
  968.      * @type {HTMLElement}
  969.      */
  970.     _this.progressWave = null;
  971.  
  972.     /**
  973.      * Class used to generate entries.
  974.      *
  975.      * @type {function}
  976.      */
  977.     _this.EntryClass = _drawer2.default;
  978.  
  979.     /**
  980.      * Canvas 2d context attributes.
  981.      *
  982.      * @type {object}
  983.      */
  984.     _this.canvasContextAttributes = params.drawingContextAttributes;
  985.  
  986.     /**
  987.      * Overlap added between entries to prevent vertical white stripes
  988.      * between `canvas` elements.
  989.      *
  990.      * @type {number}
  991.      */
  992.     _this.overlap = 2 * Math.ceil(params.pixelRatio / 2);
  993.  
  994.     /**
  995.      * The radius of the wave bars. Makes bars rounded
  996.      *
  997.      * @type {number}
  998.      */
  999.     _this.barRadius = params.barRadius || 0;
  1000.  
  1001.     /**
  1002.      * Whether to render the waveform vertically. Defaults to false.
  1003.      *
  1004.      * @type {boolean}
  1005.      */
  1006.     _this.vertical = params.vertical;
  1007.     return _this;
  1008.   }
  1009.  
  1010.   /**
  1011.    * Initialize the drawer
  1012.    */
  1013.   _createClass(MultiCanvas, [{
  1014.     key: "init",
  1015.     value: function init() {
  1016.       this.createWrapper();
  1017.       this.createElements();
  1018.     }
  1019.  
  1020.     /**
  1021.      * Create the canvas elements and style them
  1022.      *
  1023.      */
  1024.   }, {
  1025.     key: "createElements",
  1026.     value: function createElements() {
  1027.       this.progressWave = util.withOrientation(this.wrapper.appendChild(document.createElement('wave')), this.params.vertical);
  1028.       this.style(this.progressWave, {
  1029.         position: 'absolute',
  1030.         zIndex: 3,
  1031.         left: 0,
  1032.         top: 0,
  1033.         bottom: 0,
  1034.         overflow: 'hidden',
  1035.         width: '0',
  1036.         display: 'none',
  1037.         boxSizing: 'border-box',
  1038.         borderRightStyle: 'solid',
  1039.         pointerEvents: 'none'
  1040.       });
  1041.       this.addCanvas();
  1042.       this.updateCursor();
  1043.     }
  1044.  
  1045.     /**
  1046.      * Update cursor style
  1047.      */
  1048.   }, {
  1049.     key: "updateCursor",
  1050.     value: function updateCursor() {
  1051.       this.style(this.progressWave, {
  1052.         borderRightWidth: this.params.cursorWidth + 'px',
  1053.         borderRightColor: this.params.cursorColor
  1054.       });
  1055.     }
  1056.  
  1057.     /**
  1058.      * Adjust to the updated size by adding or removing canvases
  1059.      */
  1060.   }, {
  1061.     key: "updateSize",
  1062.     value: function updateSize() {
  1063.       var _this2 = this;
  1064.       var totalWidth = Math.round(this.width / this.params.pixelRatio);
  1065.       var requiredCanvases = Math.ceil(totalWidth / (this.maxCanvasElementWidth + this.overlap));
  1066.  
  1067.       // add required canvases
  1068.       while (this.canvases.length < requiredCanvases) {
  1069.         this.addCanvas();
  1070.       }
  1071.  
  1072.       // remove older existing canvases, if any
  1073.       while (this.canvases.length > requiredCanvases) {
  1074.         this.removeCanvas();
  1075.       }
  1076.       var canvasWidth = this.maxCanvasWidth + this.overlap;
  1077.       var lastCanvas = this.canvases.length - 1;
  1078.       this.canvases.forEach(function (entry, i) {
  1079.         if (i == lastCanvas) {
  1080.           canvasWidth = _this2.width - _this2.maxCanvasWidth * lastCanvas;
  1081.         }
  1082.         _this2.updateDimensions(entry, canvasWidth, _this2.height);
  1083.         entry.clearWave();
  1084.       });
  1085.     }
  1086.  
  1087.     /**
  1088.      * Add a canvas to the canvas list
  1089.      *
  1090.      */
  1091.   }, {
  1092.     key: "addCanvas",
  1093.     value: function addCanvas() {
  1094.       var entry = new this.EntryClass();
  1095.       entry.canvasContextAttributes = this.canvasContextAttributes;
  1096.       entry.hasProgressCanvas = this.hasProgressCanvas;
  1097.       entry.halfPixel = this.halfPixel;
  1098.       var leftOffset = this.maxCanvasElementWidth * this.canvases.length;
  1099.  
  1100.       // wave
  1101.       var wave = util.withOrientation(this.wrapper.appendChild(document.createElement('canvas')), this.params.vertical);
  1102.       this.style(wave, {
  1103.         position: 'absolute',
  1104.         zIndex: 2,
  1105.         left: leftOffset + 'px',
  1106.         top: 0,
  1107.         bottom: 0,
  1108.         height: '100%',
  1109.         pointerEvents: 'none'
  1110.       });
  1111.       entry.initWave(wave);
  1112.  
  1113.       // progress
  1114.       if (this.hasProgressCanvas) {
  1115.         var progress = util.withOrientation(this.progressWave.appendChild(document.createElement('canvas')), this.params.vertical);
  1116.         this.style(progress, {
  1117.           position: 'absolute',
  1118.           left: leftOffset + 'px',
  1119.           top: 0,
  1120.           bottom: 0,
  1121.           height: '100%'
  1122.         });
  1123.         entry.initProgress(progress);
  1124.       }
  1125.       this.canvases.push(entry);
  1126.     }
  1127.  
  1128.     /**
  1129.      * Pop single canvas from the list
  1130.      *
  1131.      */
  1132.   }, {
  1133.     key: "removeCanvas",
  1134.     value: function removeCanvas() {
  1135.       var lastEntry = this.canvases[this.canvases.length - 1];
  1136.  
  1137.       // wave
  1138.       lastEntry.wave.parentElement.removeChild(lastEntry.wave.domElement);
  1139.  
  1140.       // progress
  1141.       if (this.hasProgressCanvas) {
  1142.         lastEntry.progress.parentElement.removeChild(lastEntry.progress.domElement);
  1143.       }
  1144.  
  1145.       // cleanup
  1146.       if (lastEntry) {
  1147.         lastEntry.destroy();
  1148.         lastEntry = null;
  1149.       }
  1150.       this.canvases.pop();
  1151.     }
  1152.  
  1153.     /**
  1154.      * Update the dimensions of a canvas element
  1155.      *
  1156.      * @param {CanvasEntry} entry Target entry
  1157.      * @param {number} width The new width of the element
  1158.      * @param {number} height The new height of the element
  1159.      */
  1160.   }, {
  1161.     key: "updateDimensions",
  1162.     value: function updateDimensions(entry, width, height) {
  1163.       var elementWidth = Math.round(width / this.params.pixelRatio);
  1164.       var totalWidth = Math.round(this.width / this.params.pixelRatio);
  1165.  
  1166.       // update canvas dimensions
  1167.       entry.updateDimensions(elementWidth, totalWidth, width, height);
  1168.  
  1169.       // style element
  1170.       this.style(this.progressWave, {
  1171.         display: 'block'
  1172.       });
  1173.     }
  1174.  
  1175.     /**
  1176.      * Clear the whole multi-canvas
  1177.      */
  1178.   }, {
  1179.     key: "clearWave",
  1180.     value: function clearWave() {
  1181.       var _this3 = this;
  1182.       util.frame(function () {
  1183.         _this3.canvases.forEach(function (entry) {
  1184.           return entry.clearWave();
  1185.         });
  1186.       })();
  1187.     }
  1188.  
  1189.     /**
  1190.      * Draw a waveform with bars
  1191.      *
  1192.      * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
  1193.      * for split channel rendering
  1194.      * @param {number} channelIndex The index of the current channel. Normally
  1195.      * should be 0. Must be an integer.
  1196.      * @param {number} start The x-offset of the beginning of the area that
  1197.      * should be rendered
  1198.      * @param {number} end The x-offset of the end of the area that should be
  1199.      * rendered
  1200.      * @returns {void}
  1201.      */
  1202.   }, {
  1203.     key: "drawBars",
  1204.     value: function drawBars(peaks, channelIndex, start, end) {
  1205.       var _this4 = this;
  1206.       return this.prepareDraw(peaks, channelIndex, start, end, function (_ref) {
  1207.         var absmax = _ref.absmax,
  1208.           hasMinVals = _ref.hasMinVals,
  1209.           height = _ref.height,
  1210.           offsetY = _ref.offsetY,
  1211.           halfH = _ref.halfH,
  1212.           peaks = _ref.peaks,
  1213.           ch = _ref.channelIndex;
  1214.         // if drawBars was called within ws.empty we don't pass a start and
  1215.         // don't want anything to happen
  1216.         if (start === undefined) {
  1217.           return;
  1218.         }
  1219.         // Skip every other value if there are negatives.
  1220.         var peakIndexScale = hasMinVals ? 2 : 1;
  1221.         var length = peaks.length / peakIndexScale;
  1222.         var bar = _this4.params.barWidth * _this4.params.pixelRatio;
  1223.         var gap = _this4.params.barGap === null ? Math.max(_this4.params.pixelRatio, ~~(bar / 2)) : Math.max(_this4.params.pixelRatio, _this4.params.barGap * _this4.params.pixelRatio);
  1224.         var step = bar + gap;
  1225.         var scale = length / _this4.width;
  1226.         var first = start;
  1227.         var last = end;
  1228.         var peakIndex = first;
  1229.         for (peakIndex; peakIndex < last; peakIndex += step) {
  1230.           // search for the highest peak in the range this bar falls into
  1231.           var peak = 0;
  1232.           var peakIndexRange = Math.floor(peakIndex * scale) * peakIndexScale; // start index
  1233.           var peakIndexEnd = Math.floor((peakIndex + step) * scale) * peakIndexScale;
  1234.           do {
  1235.             // do..while makes sure at least one peak is always evaluated
  1236.             var newPeak = Math.abs(peaks[peakIndexRange]); // for arrays starting with negative values
  1237.             if (newPeak > peak) {
  1238.               peak = newPeak; // higher
  1239.             }
  1240.  
  1241.             peakIndexRange += peakIndexScale; // skip every other value for negatives
  1242.           } while (peakIndexRange < peakIndexEnd);
  1243.  
  1244.           // calculate the height of this bar according to the highest peak found
  1245.           var h = Math.round(peak / absmax * halfH);
  1246.  
  1247.           // raise the bar height to the specified minimum height
  1248.           // Math.max is used to replace any value smaller than barMinHeight (not just 0) with barMinHeight
  1249.           if (_this4.params.barMinHeight) {
  1250.             h = Math.max(h, _this4.params.barMinHeight);
  1251.           }
  1252.           _this4.fillRect(peakIndex + _this4.halfPixel, halfH - h + offsetY, bar + _this4.halfPixel, h * 2, _this4.barRadius, ch);
  1253.         }
  1254.       });
  1255.     }
  1256.  
  1257.     /**
  1258.      * Draw a waveform
  1259.      *
  1260.      * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
  1261.      * for split channel rendering
  1262.      * @param {number} channelIndex The index of the current channel. Normally
  1263.      * should be 0
  1264.      * @param {number?} start The x-offset of the beginning of the area that
  1265.      * should be rendered (If this isn't set only a flat line is rendered)
  1266.      * @param {number?} end The x-offset of the end of the area that should be
  1267.      * rendered
  1268.      * @returns {void}
  1269.      */
  1270.   }, {
  1271.     key: "drawWave",
  1272.     value: function drawWave(peaks, channelIndex, start, end) {
  1273.       var _this5 = this;
  1274.       return this.prepareDraw(peaks, channelIndex, start, end, function (_ref2) {
  1275.         var absmax = _ref2.absmax,
  1276.           hasMinVals = _ref2.hasMinVals,
  1277.           height = _ref2.height,
  1278.           offsetY = _ref2.offsetY,
  1279.           halfH = _ref2.halfH,
  1280.           peaks = _ref2.peaks,
  1281.           channelIndex = _ref2.channelIndex;
  1282.         if (!hasMinVals) {
  1283.           var reflectedPeaks = [];
  1284.           var len = peaks.length;
  1285.           var i = 0;
  1286.           for (i; i < len; i++) {
  1287.             reflectedPeaks[2 * i] = peaks[i];
  1288.             reflectedPeaks[2 * i + 1] = -peaks[i];
  1289.           }
  1290.           peaks = reflectedPeaks;
  1291.         }
  1292.  
  1293.         // if drawWave was called within ws.empty we don't pass a start and
  1294.         // end and simply want a flat line
  1295.         if (start !== undefined) {
  1296.           _this5.drawLine(peaks, absmax, halfH, offsetY, start, end, channelIndex);
  1297.         }
  1298.  
  1299.         // always draw a median line
  1300.         _this5.fillRect(0, halfH + offsetY - _this5.halfPixel, _this5.width, _this5.halfPixel, _this5.barRadius, channelIndex);
  1301.       });
  1302.     }
  1303.  
  1304.     /**
  1305.      * Tell the canvas entries to render their portion of the waveform
  1306.      *
  1307.      * @param {number[]} peaks Peaks data
  1308.      * @param {number} absmax Maximum peak value (absolute)
  1309.      * @param {number} halfH Half the height of the waveform
  1310.      * @param {number} offsetY Offset to the top
  1311.      * @param {number} start The x-offset of the beginning of the area that
  1312.      * should be rendered
  1313.      * @param {number} end The x-offset of the end of the area that
  1314.      * should be rendered
  1315.      * @param {channelIndex} channelIndex The channel index of the line drawn
  1316.      */
  1317.   }, {
  1318.     key: "drawLine",
  1319.     value: function drawLine(peaks, absmax, halfH, offsetY, start, end, channelIndex) {
  1320.       var _this6 = this;
  1321.       var _ref3 = this.params.splitChannelsOptions.channelColors[channelIndex] || {},
  1322.         waveColor = _ref3.waveColor,
  1323.         progressColor = _ref3.progressColor;
  1324.       this.canvases.forEach(function (entry, i) {
  1325.         _this6.setFillStyles(entry, waveColor, progressColor);
  1326.         _this6.applyCanvasTransforms(entry, _this6.params.vertical);
  1327.         entry.drawLines(peaks, absmax, halfH, offsetY, start, end);
  1328.       });
  1329.     }
  1330.  
  1331.     /**
  1332.      * Draw a rectangle on the multi-canvas
  1333.      *
  1334.      * @param {number} x X-position of the rectangle
  1335.      * @param {number} y Y-position of the rectangle
  1336.      * @param {number} width Width of the rectangle
  1337.      * @param {number} height Height of the rectangle
  1338.      * @param {number} radius Radius of the rectangle
  1339.      * @param {channelIndex} channelIndex The channel index of the bar drawn
  1340.      */
  1341.   }, {
  1342.     key: "fillRect",
  1343.     value: function fillRect(x, y, width, height, radius, channelIndex) {
  1344.       var startCanvas = Math.floor(x / this.maxCanvasWidth);
  1345.       var endCanvas = Math.min(Math.ceil((x + width) / this.maxCanvasWidth) + 1, this.canvases.length);
  1346.       var i = startCanvas;
  1347.       for (i; i < endCanvas; i++) {
  1348.         var entry = this.canvases[i];
  1349.         var leftOffset = i * this.maxCanvasWidth;
  1350.         var intersection = {
  1351.           x1: Math.max(x, i * this.maxCanvasWidth),
  1352.           y1: y,
  1353.           x2: Math.min(x + width, i * this.maxCanvasWidth + entry.wave.width),
  1354.           y2: y + height
  1355.         };
  1356.         if (intersection.x1 < intersection.x2) {
  1357.           var _ref4 = this.params.splitChannelsOptions.channelColors[channelIndex] || {},
  1358.             waveColor = _ref4.waveColor,
  1359.             progressColor = _ref4.progressColor;
  1360.           this.setFillStyles(entry, waveColor, progressColor);
  1361.           this.applyCanvasTransforms(entry, this.params.vertical);
  1362.           entry.fillRects(intersection.x1 - leftOffset, intersection.y1, intersection.x2 - intersection.x1, intersection.y2 - intersection.y1, radius);
  1363.         }
  1364.       }
  1365.     }
  1366.  
  1367.     /**
  1368.      * Returns whether to hide the channel from being drawn based on params.
  1369.      *
  1370.      * @param {number} channelIndex The index of the current channel.
  1371.      * @returns {bool} True to hide the channel, false to draw.
  1372.      */
  1373.   }, {
  1374.     key: "hideChannel",
  1375.     value: function hideChannel(channelIndex) {
  1376.       return this.params.splitChannels && this.params.splitChannelsOptions.filterChannels.includes(channelIndex);
  1377.     }
  1378.  
  1379.     /**
  1380.      * Performs preparation tasks and calculations which are shared by `drawBars`
  1381.      * and `drawWave`
  1382.      *
  1383.      * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays for
  1384.      * split channel rendering
  1385.      * @param {number} channelIndex The index of the current channel. Normally
  1386.      * should be 0
  1387.      * @param {number?} start The x-offset of the beginning of the area that
  1388.      * should be rendered. If this isn't set only a flat line is rendered
  1389.      * @param {number?} end The x-offset of the end of the area that should be
  1390.      * rendered
  1391.      * @param {function} fn The render function to call, e.g. `drawWave`
  1392.      * @param {number} drawIndex The index of the current channel after filtering.
  1393.      * @param {number?} normalizedMax Maximum modulation value across channels for use with relativeNormalization. Ignored when undefined
  1394.      * @returns {void}
  1395.      */
  1396.   }, {
  1397.     key: "prepareDraw",
  1398.     value: function prepareDraw(peaks, channelIndex, start, end, fn, drawIndex, normalizedMax) {
  1399.       var _this7 = this;
  1400.       return util.frame(function () {
  1401.         // Split channels and call this function with the channelIndex set
  1402.         if (peaks[0] instanceof Array) {
  1403.           var channels = peaks;
  1404.           if (_this7.params.splitChannels) {
  1405.             var filteredChannels = channels.filter(function (c, i) {
  1406.               return !_this7.hideChannel(i);
  1407.             });
  1408.             if (!_this7.params.splitChannelsOptions.overlay) {
  1409.               _this7.setHeight(Math.max(filteredChannels.length, 1) * _this7.params.height * _this7.params.pixelRatio);
  1410.             }
  1411.             var overallAbsMax;
  1412.             if (_this7.params.splitChannelsOptions && _this7.params.splitChannelsOptions.relativeNormalization) {
  1413.               // calculate maximum peak across channels to use for normalization
  1414.               overallAbsMax = util.max(channels.map(function (channelPeaks) {
  1415.                 return util.absMax(channelPeaks);
  1416.               }));
  1417.             }
  1418.             return channels.forEach(function (channelPeaks, i) {
  1419.               return _this7.prepareDraw(channelPeaks, i, start, end, fn, filteredChannels.indexOf(channelPeaks), overallAbsMax);
  1420.             });
  1421.           }
  1422.           peaks = channels[0];
  1423.         }
  1424.  
  1425.         // Return and do not draw channel peaks if hidden.
  1426.         if (_this7.hideChannel(channelIndex)) {
  1427.           return;
  1428.         }
  1429.  
  1430.         // calculate maximum modulation value, either from the barHeight
  1431.         // parameter or if normalize=true from the largest value in the peak
  1432.         // set
  1433.         var absmax = 1 / _this7.params.barHeight;
  1434.         if (_this7.params.normalize) {
  1435.           absmax = normalizedMax === undefined ? util.absMax(peaks) : normalizedMax;
  1436.         }
  1437.  
  1438.         // Bar wave draws the bottom only as a reflection of the top,
  1439.         // so we don't need negative values
  1440.         var hasMinVals = [].some.call(peaks, function (val) {
  1441.           return val < 0;
  1442.         });
  1443.         var height = _this7.params.height * _this7.params.pixelRatio;
  1444.         var halfH = height / 2;
  1445.         var offsetY = height * drawIndex || 0;
  1446.  
  1447.         // Override offsetY if overlay is true
  1448.         if (_this7.params.splitChannelsOptions && _this7.params.splitChannelsOptions.overlay) {
  1449.           offsetY = 0;
  1450.         }
  1451.         return fn({
  1452.           absmax: absmax,
  1453.           hasMinVals: hasMinVals,
  1454.           height: height,
  1455.           offsetY: offsetY,
  1456.           halfH: halfH,
  1457.           peaks: peaks,
  1458.           channelIndex: channelIndex
  1459.         });
  1460.       })();
  1461.     }
  1462.  
  1463.     /**
  1464.      * Set the fill styles for a certain entry (wave and progress)
  1465.      *
  1466.      * @param {CanvasEntry} entry Target entry
  1467.      * @param {string} waveColor Wave color to draw this entry
  1468.      * @param {string} progressColor Progress color to draw this entry
  1469.      */
  1470.   }, {
  1471.     key: "setFillStyles",
  1472.     value: function setFillStyles(entry) {
  1473.       var waveColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.params.waveColor;
  1474.       var progressColor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.params.progressColor;
  1475.       entry.setFillStyles(waveColor, progressColor);
  1476.     }
  1477.  
  1478.     /**
  1479.      * Set the canvas transforms for a certain entry (wave and progress)
  1480.      *
  1481.      * @param {CanvasEntry} entry Target entry
  1482.      * @param {boolean} vertical Whether to render the waveform vertically
  1483.      */
  1484.   }, {
  1485.     key: "applyCanvasTransforms",
  1486.     value: function applyCanvasTransforms(entry) {
  1487.       var vertical = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1488.       entry.applyCanvasTransforms(vertical);
  1489.     }
  1490.  
  1491.     /**
  1492.      * Return image data of the multi-canvas
  1493.      *
  1494.      * When using a `type` of `'blob'`, this will return a `Promise`.
  1495.      *
  1496.      * @param {string} format='image/png' An optional value of a format type.
  1497.      * @param {number} quality=0.92 An optional value between 0 and 1.
  1498.      * @param {string} type='dataURL' Either 'dataURL' or 'blob'.
  1499.      * @return {string|string[]|Promise} When using the default `'dataURL'`
  1500.      * `type` this returns a single data URL or an array of data URLs,
  1501.      * one for each canvas. When using the `'blob'` `type` this returns a
  1502.      * `Promise` that resolves with an array of `Blob` instances, one for each
  1503.      * canvas.
  1504.      */
  1505.   }, {
  1506.     key: "getImage",
  1507.     value: function getImage(format, quality, type) {
  1508.       if (type === 'blob') {
  1509.         return Promise.all(this.canvases.map(function (entry) {
  1510.           return entry.getImage(format, quality, type);
  1511.         }));
  1512.       } else if (type === 'dataURL') {
  1513.         var images = this.canvases.map(function (entry) {
  1514.           return entry.getImage(format, quality, type);
  1515.         });
  1516.         return images.length > 1 ? images : images[0];
  1517.       }
  1518.     }
  1519.  
  1520.     /**
  1521.      * Render the new progress
  1522.      *
  1523.      * @param {number} position X-offset of progress position in pixels
  1524.      */
  1525.   }, {
  1526.     key: "updateProgress",
  1527.     value: function updateProgress(position) {
  1528.       this.style(this.progressWave, {
  1529.         width: position + 'px'
  1530.       });
  1531.     }
  1532.   }]);
  1533.   return MultiCanvas;
  1534. }(_drawer.default);
  1535. exports["default"] = MultiCanvas;
  1536. module.exports = exports.default;
  1537.  
  1538. /***/ }),
  1539.  
  1540. /***/ "./src/mediaelement-webaudio.js":
  1541. /*!**************************************!*\
  1542.   !*** ./src/mediaelement-webaudio.js ***!
  1543.   \**************************************/
  1544. /***/ ((module, exports, __webpack_require__) => {
  1545.  
  1546. "use strict";
  1547.  
  1548.  
  1549. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  1550. Object.defineProperty(exports, "__esModule", ({
  1551.   value: true
  1552. }));
  1553. exports["default"] = void 0;
  1554. var _mediaelement = _interopRequireDefault(__webpack_require__(/*! ./mediaelement */ "./src/mediaelement.js"));
  1555. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1556. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1557. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  1558. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  1559. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  1560. function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  1561. function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
  1562. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  1563. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  1564. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  1565. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1566. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  1567. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  1568. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1569. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  1570. /**
  1571.  * MediaElementWebAudio backend: load audio via an HTML5 audio tag, but playback with the WebAudio API.
  1572.  * The advantage here is that the html5 <audio> tag can perform range requests on the server and not
  1573.  * buffer the entire file in one request, and you still get the filtering and scripting functionality
  1574.  * of the webaudio API.
  1575.  * Note that in order to use range requests and prevent buffering, you must provide peak data.
  1576.  *
  1577.  * @since 3.2.0
  1578.  */
  1579. var MediaElementWebAudio = /*#__PURE__*/function (_MediaElement) {
  1580.   _inherits(MediaElementWebAudio, _MediaElement);
  1581.   var _super = _createSuper(MediaElementWebAudio);
  1582.   /**
  1583.    * Construct the backend
  1584.    *
  1585.    * @param {WavesurferParams} params Wavesurfer parameters
  1586.    */
  1587.   function MediaElementWebAudio(params) {
  1588.     var _this;
  1589.     _classCallCheck(this, MediaElementWebAudio);
  1590.     _this = _super.call(this, params);
  1591.     /** @private */
  1592.     _this.params = params;
  1593.     /** @private */
  1594.     _this.sourceMediaElement = null;
  1595.     return _this;
  1596.   }
  1597.  
  1598.   /**
  1599.    * Initialise the backend, called in `wavesurfer.createBackend()`
  1600.    */
  1601.   _createClass(MediaElementWebAudio, [{
  1602.     key: "init",
  1603.     value: function init() {
  1604.       this.setPlaybackRate(this.params.audioRate);
  1605.       this.createTimer();
  1606.       this.createVolumeNode();
  1607.       this.createScriptNode();
  1608.       this.createAnalyserNode();
  1609.     }
  1610.     /**
  1611.      * Private method called by both `load` (from url)
  1612.      * and `loadElt` (existing media element) methods.
  1613.      *
  1614.      * @param {HTMLMediaElement} media HTML5 Audio or Video element
  1615.      * @param {number[]|Number.<Array[]>} peaks Array of peak data
  1616.      * @param {string} preload HTML 5 preload attribute value
  1617.      * @private
  1618.      */
  1619.   }, {
  1620.     key: "_load",
  1621.     value: function _load(media, peaks, preload) {
  1622.       _get(_getPrototypeOf(MediaElementWebAudio.prototype), "_load", this).call(this, media, peaks, preload);
  1623.       this.createMediaElementSource(media);
  1624.     }
  1625.  
  1626.     /**
  1627.      * Create MediaElementSource node
  1628.      *
  1629.      * @since 3.2.0
  1630.      * @param {HTMLMediaElement} mediaElement HTML5 Audio to load
  1631.      */
  1632.   }, {
  1633.     key: "createMediaElementSource",
  1634.     value: function createMediaElementSource(mediaElement) {
  1635.       this.sourceMediaElement = this.ac.createMediaElementSource(mediaElement);
  1636.       this.sourceMediaElement.connect(this.analyser);
  1637.     }
  1638.   }, {
  1639.     key: "play",
  1640.     value: function play(start, end) {
  1641.       this.resumeAudioContext();
  1642.       return _get(_getPrototypeOf(MediaElementWebAudio.prototype), "play", this).call(this, start, end);
  1643.     }
  1644.  
  1645.     /**
  1646.      * This is called when wavesurfer is destroyed
  1647.      *
  1648.      */
  1649.   }, {
  1650.     key: "destroy",
  1651.     value: function destroy() {
  1652.       _get(_getPrototypeOf(MediaElementWebAudio.prototype), "destroy", this).call(this);
  1653.       this.destroyWebAudio();
  1654.     }
  1655.   }]);
  1656.   return MediaElementWebAudio;
  1657. }(_mediaelement.default);
  1658. exports["default"] = MediaElementWebAudio;
  1659. module.exports = exports.default;
  1660.  
  1661. /***/ }),
  1662.  
  1663. /***/ "./src/mediaelement.js":
  1664. /*!*****************************!*\
  1665.   !*** ./src/mediaelement.js ***!
  1666.   \*****************************/
  1667. /***/ ((module, exports, __webpack_require__) => {
  1668.  
  1669. "use strict";
  1670.  
  1671.  
  1672. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  1673. Object.defineProperty(exports, "__esModule", ({
  1674.   value: true
  1675. }));
  1676. exports["default"] = void 0;
  1677. var _webaudio = _interopRequireDefault(__webpack_require__(/*! ./webaudio */ "./src/webaudio.js"));
  1678. var util = _interopRequireWildcard(__webpack_require__(/*! ./util */ "./src/util/index.js"));
  1679. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  1680. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  1681. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1682. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1683. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  1684. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  1685. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  1686. function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  1687. function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
  1688. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  1689. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  1690. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  1691. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1692. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  1693. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  1694. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1695. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  1696. /**
  1697.  * MediaElement backend
  1698.  */
  1699. var MediaElement = /*#__PURE__*/function (_WebAudio) {
  1700.   _inherits(MediaElement, _WebAudio);
  1701.   var _super = _createSuper(MediaElement);
  1702.   /**
  1703.    * Construct the backend
  1704.    *
  1705.    * @param {WavesurferParams} params Wavesurfer parameters
  1706.    */
  1707.   function MediaElement(params) {
  1708.     var _this;
  1709.     _classCallCheck(this, MediaElement);
  1710.     _this = _super.call(this, params);
  1711.     /** @private */
  1712.     _this.params = params;
  1713.  
  1714.     /**
  1715.      * Initially a dummy media element to catch errors. Once `_load` is
  1716.      * called, this will contain the actual `HTMLMediaElement`.
  1717.      * @private
  1718.      */
  1719.     _this.media = {
  1720.       currentTime: 0,
  1721.       duration: 0,
  1722.       paused: true,
  1723.       playbackRate: 1,
  1724.       play: function play() {},
  1725.       pause: function pause() {},
  1726.       volume: 0
  1727.     };
  1728.  
  1729.     /** @private */
  1730.     _this.mediaType = params.mediaType.toLowerCase();
  1731.     /** @private */
  1732.     _this.elementPosition = params.elementPosition;
  1733.     /** @private */
  1734.     _this.peaks = null;
  1735.     /** @private */
  1736.     _this.playbackRate = 1;
  1737.     /** @private */
  1738.     _this.volume = 1;
  1739.     /** @private */
  1740.     _this.isMuted = false;
  1741.     /** @private */
  1742.     _this.buffer = null;
  1743.     /** @private */
  1744.     _this.onPlayEnd = null;
  1745.     /** @private */
  1746.     _this.mediaListeners = {};
  1747.     return _this;
  1748.   }
  1749.  
  1750.   /**
  1751.    * Initialise the backend, called in `wavesurfer.createBackend()`
  1752.    */
  1753.   _createClass(MediaElement, [{
  1754.     key: "init",
  1755.     value: function init() {
  1756.       this.setPlaybackRate(this.params.audioRate);
  1757.       this.createTimer();
  1758.     }
  1759.  
  1760.     /**
  1761.      * Attach event listeners to media element.
  1762.      */
  1763.   }, {
  1764.     key: "_setupMediaListeners",
  1765.     value: function _setupMediaListeners() {
  1766.       var _this2 = this;
  1767.       this.mediaListeners.error = function () {
  1768.         _this2.fireEvent('error', 'Error loading media element');
  1769.       };
  1770.       this.mediaListeners.waiting = function () {
  1771.         _this2.fireEvent('waiting');
  1772.       };
  1773.       this.mediaListeners.canplay = function () {
  1774.         _this2.fireEvent('canplay');
  1775.       };
  1776.       this.mediaListeners.ended = function () {
  1777.         _this2.fireEvent('finish');
  1778.       };
  1779.       // listen to and relay play, pause and seeked events to enable
  1780.       // playback control from the external media element
  1781.       this.mediaListeners.play = function () {
  1782.         _this2.fireEvent('play');
  1783.       };
  1784.       this.mediaListeners.pause = function () {
  1785.         _this2.fireEvent('pause');
  1786.       };
  1787.       this.mediaListeners.seeked = function (event) {
  1788.         _this2.fireEvent('seek');
  1789.       };
  1790.       this.mediaListeners.volumechange = function (event) {
  1791.         _this2.isMuted = _this2.media.muted;
  1792.         if (_this2.isMuted) {
  1793.           _this2.volume = 0;
  1794.         } else {
  1795.           _this2.volume = _this2.media.volume;
  1796.         }
  1797.         _this2.fireEvent('volume');
  1798.       };
  1799.  
  1800.       // reset event listeners
  1801.       Object.keys(this.mediaListeners).forEach(function (id) {
  1802.         _this2.media.removeEventListener(id, _this2.mediaListeners[id]);
  1803.         _this2.media.addEventListener(id, _this2.mediaListeners[id]);
  1804.       });
  1805.     }
  1806.  
  1807.     /**
  1808.      * Create a timer to provide a more precise `audioprocess` event.
  1809.      */
  1810.   }, {
  1811.     key: "createTimer",
  1812.     value: function createTimer() {
  1813.       var _this3 = this;
  1814.       var onAudioProcess = function onAudioProcess() {
  1815.         if (_this3.isPaused()) {
  1816.           return;
  1817.         }
  1818.         _this3.fireEvent('audioprocess', _this3.getCurrentTime());
  1819.  
  1820.         // Call again in the next frame
  1821.         util.frame(onAudioProcess)();
  1822.       };
  1823.       this.on('play', onAudioProcess);
  1824.  
  1825.       // Update the progress one more time to prevent it from being stuck in
  1826.       // case of lower framerates
  1827.       this.on('pause', function () {
  1828.         _this3.fireEvent('audioprocess', _this3.getCurrentTime());
  1829.       });
  1830.     }
  1831.  
  1832.     /**
  1833.      * Create media element with url as its source,
  1834.      * and append to container element.
  1835.      *
  1836.      * @param {string} url Path to media file
  1837.      * @param {HTMLElement} container HTML element
  1838.      * @param {number[]|Number.<Array[]>} peaks Array of peak data
  1839.      * @param {string} preload HTML 5 preload attribute value
  1840.      * @throws Will throw an error if the `url` argument is not a valid media
  1841.      * element.
  1842.      */
  1843.   }, {
  1844.     key: "load",
  1845.     value: function load(url, container, peaks, preload) {
  1846.       var media = document.createElement(this.mediaType);
  1847.       media.controls = this.params.mediaControls;
  1848.       media.autoplay = this.params.autoplay || false;
  1849.       media.preload = preload == null ? 'auto' : preload;
  1850.       media.src = url;
  1851.       media.style.width = '100%';
  1852.       var prevMedia = container.querySelector(this.mediaType);
  1853.       if (prevMedia) {
  1854.         container.removeChild(prevMedia);
  1855.       }
  1856.       container.appendChild(media);
  1857.       this._load(media, peaks, preload);
  1858.     }
  1859.  
  1860.     /**
  1861.      * Load existing media element.
  1862.      *
  1863.      * @param {HTMLMediaElement} elt HTML5 Audio or Video element
  1864.      * @param {number[]|Number.<Array[]>} peaks Array of peak data
  1865.      */
  1866.   }, {
  1867.     key: "loadElt",
  1868.     value: function loadElt(elt, peaks) {
  1869.       elt.controls = this.params.mediaControls;
  1870.       elt.autoplay = this.params.autoplay || false;
  1871.       this._load(elt, peaks, elt.preload);
  1872.     }
  1873.  
  1874.     /**
  1875.      * Method called by both `load` (from url)
  1876.      * and `loadElt` (existing media element) methods.
  1877.      *
  1878.      * @param {HTMLMediaElement} media HTML5 Audio or Video element
  1879.      * @param {number[]|Number.<Array[]>} peaks Array of peak data
  1880.      * @param {string} preload HTML 5 preload attribute value
  1881.      * @throws Will throw an error if the `media` argument is not a valid media
  1882.      * element.
  1883.      * @private
  1884.      */
  1885.   }, {
  1886.     key: "_load",
  1887.     value: function _load(media, peaks, preload) {
  1888.       // verify media element is valid
  1889.       if (!(media instanceof HTMLMediaElement) || typeof media.addEventListener === 'undefined') {
  1890.         throw new Error('media parameter is not a valid media element');
  1891.       }
  1892.  
  1893.       // load must be called manually on iOS, otherwise peaks won't draw
  1894.       // until a user interaction triggers load --> 'ready' event
  1895.       //
  1896.       // note that we avoid calling media.load here when given peaks and preload == 'none'
  1897.       // as this almost always triggers some browser fetch of the media.
  1898.       if (typeof media.load == 'function' && !(peaks && preload == 'none')) {
  1899.         // Resets the media element and restarts the media resource. Any
  1900.         // pending events are discarded. How much media data is fetched is
  1901.         // still affected by the preload attribute.
  1902.         media.load();
  1903.       }
  1904.       this.media = media;
  1905.       this._setupMediaListeners();
  1906.       this.peaks = peaks;
  1907.       this.onPlayEnd = null;
  1908.       this.buffer = null;
  1909.       this.isMuted = media.muted;
  1910.       this.setPlaybackRate(this.playbackRate);
  1911.       this.setVolume(this.volume);
  1912.     }
  1913.  
  1914.     /**
  1915.      * Used by `wavesurfer.isPlaying()` and `wavesurfer.playPause()`
  1916.      *
  1917.      * @return {boolean} Media paused or not
  1918.      */
  1919.   }, {
  1920.     key: "isPaused",
  1921.     value: function isPaused() {
  1922.       return !this.media || this.media.paused;
  1923.     }
  1924.  
  1925.     /**
  1926.      * Used by `wavesurfer.getDuration()`
  1927.      *
  1928.      * @return {number} Duration
  1929.      */
  1930.   }, {
  1931.     key: "getDuration",
  1932.     value: function getDuration() {
  1933.       if (this.explicitDuration) {
  1934.         return this.explicitDuration;
  1935.       }
  1936.       var duration = (this.buffer || this.media).duration;
  1937.       if (duration >= Infinity) {
  1938.         // streaming audio
  1939.         duration = this.media.seekable.end(0);
  1940.       }
  1941.       return duration;
  1942.     }
  1943.  
  1944.     /**
  1945.      * Returns the current time in seconds relative to the audio-clip's
  1946.      * duration.
  1947.      *
  1948.      * @return {number} Current time
  1949.      */
  1950.   }, {
  1951.     key: "getCurrentTime",
  1952.     value: function getCurrentTime() {
  1953.       return this.media && this.media.currentTime;
  1954.     }
  1955.  
  1956.     /**
  1957.      * Get the position from 0 to 1
  1958.      *
  1959.      * @return {number} Current position
  1960.      */
  1961.   }, {
  1962.     key: "getPlayedPercents",
  1963.     value: function getPlayedPercents() {
  1964.       return this.getCurrentTime() / this.getDuration() || 0;
  1965.     }
  1966.  
  1967.     /**
  1968.      * Get the audio source playback rate.
  1969.      *
  1970.      * @return {number} Playback rate
  1971.      */
  1972.   }, {
  1973.     key: "getPlaybackRate",
  1974.     value: function getPlaybackRate() {
  1975.       return this.playbackRate || this.media.playbackRate;
  1976.     }
  1977.  
  1978.     /**
  1979.      * Set the audio source playback rate.
  1980.      *
  1981.      * @param {number} value Playback rate
  1982.      */
  1983.   }, {
  1984.     key: "setPlaybackRate",
  1985.     value: function setPlaybackRate(value) {
  1986.       this.playbackRate = value || 1;
  1987.       this.media.playbackRate = this.playbackRate;
  1988.     }
  1989.  
  1990.     /**
  1991.      * Used by `wavesurfer.seekTo()`
  1992.      *
  1993.      * @param {number} start Position to start at in seconds
  1994.      */
  1995.   }, {
  1996.     key: "seekTo",
  1997.     value: function seekTo(start) {
  1998.       if (start != null && !isNaN(start)) {
  1999.         this.media.currentTime = start;
  2000.       }
  2001.       this.clearPlayEnd();
  2002.     }
  2003.  
  2004.     /**
  2005.      * Plays the loaded audio region.
  2006.      *
  2007.      * @param {number} start Start offset in seconds, relative to the beginning
  2008.      * of a clip.
  2009.      * @param {number} end When to stop, relative to the beginning of a clip.
  2010.      * @emits MediaElement#play
  2011.      * @return {Promise} Result
  2012.      */
  2013.   }, {
  2014.     key: "play",
  2015.     value: function play(start, end) {
  2016.       this.seekTo(start);
  2017.       var promise = this.media.play();
  2018.       end && this.setPlayEnd(end);
  2019.       return promise;
  2020.     }
  2021.  
  2022.     /**
  2023.      * Pauses the loaded audio.
  2024.      *
  2025.      * @emits MediaElement#pause
  2026.      * @return {Promise} Result
  2027.      */
  2028.   }, {
  2029.     key: "pause",
  2030.     value: function pause() {
  2031.       var promise;
  2032.       if (this.media) {
  2033.         promise = this.media.pause();
  2034.       }
  2035.       this.clearPlayEnd();
  2036.       return promise;
  2037.     }
  2038.  
  2039.     /**
  2040.      * Set the play end
  2041.      *
  2042.      * @param {number} end Where to end
  2043.      */
  2044.   }, {
  2045.     key: "setPlayEnd",
  2046.     value: function setPlayEnd(end) {
  2047.       var _this4 = this;
  2048.       this.clearPlayEnd();
  2049.       this._onPlayEnd = function (time) {
  2050.         if (time >= end) {
  2051.           _this4.pause();
  2052.           _this4.seekTo(end);
  2053.         }
  2054.       };
  2055.       this.on('audioprocess', this._onPlayEnd);
  2056.     }
  2057.  
  2058.     /** @private */
  2059.   }, {
  2060.     key: "clearPlayEnd",
  2061.     value: function clearPlayEnd() {
  2062.       if (this._onPlayEnd) {
  2063.         this.un('audioprocess', this._onPlayEnd);
  2064.         this._onPlayEnd = null;
  2065.       }
  2066.     }
  2067.  
  2068.     /**
  2069.      * Compute the max and min value of the waveform when broken into
  2070.      * <length> subranges.
  2071.      *
  2072.      * @param {number} length How many subranges to break the waveform into.
  2073.      * @param {number} first First sample in the required range.
  2074.      * @param {number} last Last sample in the required range.
  2075.      * @return {number[]|Number.<Array[]>} Array of 2*<length> peaks or array of
  2076.      * arrays of peaks consisting of (max, min) values for each subrange.
  2077.      */
  2078.   }, {
  2079.     key: "getPeaks",
  2080.     value: function getPeaks(length, first, last) {
  2081.       if (this.buffer) {
  2082.         return _get(_getPrototypeOf(MediaElement.prototype), "getPeaks", this).call(this, length, first, last);
  2083.       }
  2084.       return this.peaks || [];
  2085.     }
  2086.  
  2087.     /**
  2088.      * Set the sink id for the media player
  2089.      *
  2090.      * @param {string} deviceId String value representing audio device id.
  2091.      * @returns {Promise} A Promise that resolves to `undefined` when there
  2092.      * are no errors.
  2093.      */
  2094.   }, {
  2095.     key: "setSinkId",
  2096.     value: function setSinkId(deviceId) {
  2097.       if (deviceId) {
  2098.         if (!this.media.setSinkId) {
  2099.           return Promise.reject(new Error('setSinkId is not supported in your browser'));
  2100.         }
  2101.         return this.media.setSinkId(deviceId);
  2102.       }
  2103.       return Promise.reject(new Error('Invalid deviceId: ' + deviceId));
  2104.     }
  2105.  
  2106.     /**
  2107.      * Get the current volume
  2108.      *
  2109.      * @return {number} value A floating point value between 0 and 1.
  2110.      */
  2111.   }, {
  2112.     key: "getVolume",
  2113.     value: function getVolume() {
  2114.       return this.volume;
  2115.     }
  2116.  
  2117.     /**
  2118.      * Set the audio volume
  2119.      *
  2120.      * @param {number} value A floating point value between 0 and 1.
  2121.      */
  2122.   }, {
  2123.     key: "setVolume",
  2124.     value: function setVolume(value) {
  2125.       this.volume = value;
  2126.       // no need to change when it's already at that volume
  2127.       if (this.media.volume !== this.volume) {
  2128.         this.media.volume = this.volume;
  2129.       }
  2130.     }
  2131.  
  2132.     /**
  2133.      * Enable or disable muted audio
  2134.      *
  2135.      * @since 4.0.0
  2136.      * @param {boolean} muted Specify `true` to mute audio.
  2137.      */
  2138.   }, {
  2139.     key: "setMute",
  2140.     value: function setMute(muted) {
  2141.       // This causes a volume change to be emitted too through the
  2142.       // volumechange event listener.
  2143.       this.isMuted = this.media.muted = muted;
  2144.     }
  2145.  
  2146.     /**
  2147.      * This is called when wavesurfer is destroyed
  2148.      *
  2149.      */
  2150.   }, {
  2151.     key: "destroy",
  2152.     value: function destroy() {
  2153.       var _this5 = this;
  2154.       this.pause();
  2155.       this.unAll();
  2156.       this.destroyed = true;
  2157.  
  2158.       // cleanup media event listeners
  2159.       Object.keys(this.mediaListeners).forEach(function (id) {
  2160.         if (_this5.media) {
  2161.           _this5.media.removeEventListener(id, _this5.mediaListeners[id]);
  2162.         }
  2163.       });
  2164.       if (this.params.removeMediaElementOnDestroy && this.media && this.media.parentNode) {
  2165.         this.media.parentNode.removeChild(this.media);
  2166.       }
  2167.       this.media = null;
  2168.     }
  2169.   }]);
  2170.   return MediaElement;
  2171. }(_webaudio.default);
  2172. exports["default"] = MediaElement;
  2173. module.exports = exports.default;
  2174.  
  2175. /***/ }),
  2176.  
  2177. /***/ "./src/peakcache.js":
  2178. /*!**************************!*\
  2179.   !*** ./src/peakcache.js ***!
  2180.   \**************************/
  2181. /***/ ((module, exports) => {
  2182.  
  2183. "use strict";
  2184.  
  2185.  
  2186. Object.defineProperty(exports, "__esModule", ({
  2187.   value: true
  2188. }));
  2189. exports["default"] = void 0;
  2190. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  2191. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2192. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  2193. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2194. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  2195. function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  2196. /**
  2197.  * Caches the decoded peaks data to improve rendering speed for large audio
  2198.  *
  2199.  * Is used if the option parameter `partialRender` is set to `true`
  2200.  */
  2201. var PeakCache = /*#__PURE__*/function () {
  2202.   /**
  2203.    * Instantiate cache
  2204.    */
  2205.   function PeakCache() {
  2206.     _classCallCheck(this, PeakCache);
  2207.     this.clearPeakCache();
  2208.   }
  2209.  
  2210.   /**
  2211.    * Empty the cache
  2212.    */
  2213.   _createClass(PeakCache, [{
  2214.     key: "clearPeakCache",
  2215.     value: function clearPeakCache() {
  2216.       /**
  2217.        * Flat array with entries that are always in pairs to mark the
  2218.        * beginning and end of each subrange.  This is a convenience so we can
  2219.        * iterate over the pairs for easy set difference operations.
  2220.        * @private
  2221.        */
  2222.       this.peakCacheRanges = [];
  2223.       /**
  2224.        * Length of the entire cachable region, used for resetting the cache
  2225.        * when this changes (zoom events, for instance).
  2226.        * @private
  2227.        */
  2228.       this.peakCacheLength = -1;
  2229.     }
  2230.  
  2231.     /**
  2232.      * Add a range of peaks to the cache
  2233.      *
  2234.      * @param {number} length The length of the range
  2235.      * @param {number} start The x offset of the start of the range
  2236.      * @param {number} end The x offset of the end of the range
  2237.      * @return {Number.<Array[]>} Array with arrays of numbers
  2238.      */
  2239.   }, {
  2240.     key: "addRangeToPeakCache",
  2241.     value: function addRangeToPeakCache(length, start, end) {
  2242.       if (length != this.peakCacheLength) {
  2243.         this.clearPeakCache();
  2244.         this.peakCacheLength = length;
  2245.       }
  2246.  
  2247.       // Return ranges that weren't in the cache before the call.
  2248.       var uncachedRanges = [];
  2249.       var i = 0;
  2250.       // Skip ranges before the current start.
  2251.       while (i < this.peakCacheRanges.length && this.peakCacheRanges[i] < start) {
  2252.         i++;
  2253.       }
  2254.       // If |i| is even, |start| falls after an existing range.  Otherwise,
  2255.       // |start| falls between an existing range, and the uncached region
  2256.       // starts when we encounter the next node in |peakCacheRanges| or
  2257.       // |end|, whichever comes first.
  2258.       if (i % 2 == 0) {
  2259.         uncachedRanges.push(start);
  2260.       }
  2261.       while (i < this.peakCacheRanges.length && this.peakCacheRanges[i] <= end) {
  2262.         uncachedRanges.push(this.peakCacheRanges[i]);
  2263.         i++;
  2264.       }
  2265.       // If |i| is even, |end| is after all existing ranges.
  2266.       if (i % 2 == 0) {
  2267.         uncachedRanges.push(end);
  2268.       }
  2269.  
  2270.       // Filter out the 0-length ranges.
  2271.       uncachedRanges = uncachedRanges.filter(function (item, pos, arr) {
  2272.         if (pos == 0) {
  2273.           return item != arr[pos + 1];
  2274.         } else if (pos == arr.length - 1) {
  2275.           return item != arr[pos - 1];
  2276.         }
  2277.         return item != arr[pos - 1] && item != arr[pos + 1];
  2278.       });
  2279.  
  2280.       // Merge the two ranges together, uncachedRanges will either contain
  2281.       // wholly new points, or duplicates of points in peakCacheRanges.  If
  2282.       // duplicates are detected, remove both and extend the range.
  2283.       this.peakCacheRanges = this.peakCacheRanges.concat(uncachedRanges);
  2284.       this.peakCacheRanges = this.peakCacheRanges.sort(function (a, b) {
  2285.         return a - b;
  2286.       }).filter(function (item, pos, arr) {
  2287.         if (pos == 0) {
  2288.           return item != arr[pos + 1];
  2289.         } else if (pos == arr.length - 1) {
  2290.           return item != arr[pos - 1];
  2291.         }
  2292.         return item != arr[pos - 1] && item != arr[pos + 1];
  2293.       });
  2294.  
  2295.       // Push the uncached ranges into an array of arrays for ease of
  2296.       // iteration in the functions that call this.
  2297.       var uncachedRangePairs = [];
  2298.       for (i = 0; i < uncachedRanges.length; i += 2) {
  2299.         uncachedRangePairs.push([uncachedRanges[i], uncachedRanges[i + 1]]);
  2300.       }
  2301.       return uncachedRangePairs;
  2302.     }
  2303.  
  2304.     /**
  2305.      * For testing
  2306.      *
  2307.      * @return {Number.<Array[]>} Array with arrays of numbers
  2308.      */
  2309.   }, {
  2310.     key: "getCacheRanges",
  2311.     value: function getCacheRanges() {
  2312.       var peakCacheRangePairs = [];
  2313.       var i;
  2314.       for (i = 0; i < this.peakCacheRanges.length; i += 2) {
  2315.         peakCacheRangePairs.push([this.peakCacheRanges[i], this.peakCacheRanges[i + 1]]);
  2316.       }
  2317.       return peakCacheRangePairs;
  2318.     }
  2319.   }]);
  2320.   return PeakCache;
  2321. }();
  2322. exports["default"] = PeakCache;
  2323. module.exports = exports.default;
  2324.  
  2325. /***/ }),
  2326.  
  2327. /***/ "./src/util/absMax.js":
  2328. /*!****************************!*\
  2329.   !*** ./src/util/absMax.js ***!
  2330.   \****************************/
  2331. /***/ ((module, exports, __webpack_require__) => {
  2332.  
  2333. "use strict";
  2334.  
  2335.  
  2336. Object.defineProperty(exports, "__esModule", ({
  2337.   value: true
  2338. }));
  2339. exports["default"] = absMax;
  2340. var _max = _interopRequireDefault(__webpack_require__(/*! ./max */ "./src/util/max.js"));
  2341. var _min = _interopRequireDefault(__webpack_require__(/*! ./min */ "./src/util/min.js"));
  2342. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2343. /**
  2344.  * Get the largest absolute value in an array
  2345.  *
  2346.  * @param   {Array} values Array of numbers
  2347.  * @returns {Number} Largest number found
  2348.  * @example console.log(max([-3, 2, 1]), max([-3, 2, 4])); // logs 3 4
  2349.  * @since 4.3.0
  2350.  */
  2351. function absMax(values) {
  2352.   var max = (0, _max.default)(values);
  2353.   var min = (0, _min.default)(values);
  2354.   return -min > max ? -min : max;
  2355. }
  2356. module.exports = exports.default;
  2357.  
  2358. /***/ }),
  2359.  
  2360. /***/ "./src/util/clamp.js":
  2361. /*!***************************!*\
  2362.   !*** ./src/util/clamp.js ***!
  2363.   \***************************/
  2364. /***/ ((module, exports) => {
  2365.  
  2366. "use strict";
  2367.  
  2368.  
  2369. Object.defineProperty(exports, "__esModule", ({
  2370.   value: true
  2371. }));
  2372. exports["default"] = clamp;
  2373. /**
  2374.  * Returns a number limited to the given range.
  2375.  *
  2376.  * @param {number} val The number to be limited to a range
  2377.  * @param {number} min The lower boundary of the limit range
  2378.  * @param {number} max The upper boundary of the limit range
  2379.  * @returns {number} A number in the range [min, max]
  2380.  */
  2381. function clamp(val, min, max) {
  2382.   return Math.min(Math.max(min, val), max);
  2383. }
  2384. module.exports = exports.default;
  2385.  
  2386. /***/ }),
  2387.  
  2388. /***/ "./src/util/fetch.js":
  2389. /*!***************************!*\
  2390.   !*** ./src/util/fetch.js ***!
  2391.   \***************************/
  2392. /***/ ((module, exports, __webpack_require__) => {
  2393.  
  2394. "use strict";
  2395.  
  2396.  
  2397. Object.defineProperty(exports, "__esModule", ({
  2398.   value: true
  2399. }));
  2400. exports["default"] = fetchFile;
  2401. var _observer = _interopRequireDefault(__webpack_require__(/*! ./observer */ "./src/util/observer.js"));
  2402. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2403. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  2404. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2405. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  2406. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2407. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  2408. function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  2409. var ProgressHandler = /*#__PURE__*/function () {
  2410.   /**
  2411.    * Instantiate ProgressHandler
  2412.    *
  2413.    * @param {Observer} instance The `fetchFile` observer instance.
  2414.    * @param {Number} contentLength Content length.
  2415.    * @param {Response} response Response object.
  2416.    */
  2417.   function ProgressHandler(instance, contentLength, response) {
  2418.     _classCallCheck(this, ProgressHandler);
  2419.     this.instance = instance;
  2420.     this.instance._reader = response.body.getReader();
  2421.     this.total = parseInt(contentLength, 10);
  2422.     this.loaded = 0;
  2423.   }
  2424.  
  2425.   /**
  2426.    * A method that is called once, immediately after the `ReadableStream``
  2427.    * is constructed.
  2428.    *
  2429.    * @param {ReadableStreamDefaultController} controller Controller instance
  2430.    *     used to control the stream.
  2431.    */
  2432.   _createClass(ProgressHandler, [{
  2433.     key: "start",
  2434.     value: function start(controller) {
  2435.       var _this = this;
  2436.       var read = function read() {
  2437.         // instance._reader.read() returns a promise that resolves
  2438.         // when a value has been received
  2439.         _this.instance._reader.read().then(function (_ref) {
  2440.           var done = _ref.done,
  2441.             value = _ref.value;
  2442.           // result objects contain two properties:
  2443.           // done  - true if the stream has already given you all its data.
  2444.           // value - some data. Always undefined when done is true.
  2445.           if (done) {
  2446.             // ensure onProgress called when content-length=0
  2447.             if (_this.total === 0) {
  2448.               _this.instance.onProgress.call(_this.instance, {
  2449.                 loaded: _this.loaded,
  2450.                 total: _this.total,
  2451.                 lengthComputable: false
  2452.               });
  2453.             }
  2454.             // no more data needs to be consumed, close the stream
  2455.             controller.close();
  2456.             return;
  2457.           }
  2458.           _this.loaded += value.byteLength;
  2459.           _this.instance.onProgress.call(_this.instance, {
  2460.             loaded: _this.loaded,
  2461.             total: _this.total,
  2462.             lengthComputable: !(_this.total === 0)
  2463.           });
  2464.           // enqueue the next data chunk into our target stream
  2465.           controller.enqueue(value);
  2466.           read();
  2467.         }).catch(function (error) {
  2468.           controller.error(error);
  2469.         });
  2470.       };
  2471.       read();
  2472.     }
  2473.   }]);
  2474.   return ProgressHandler;
  2475. }();
  2476. /**
  2477.  * Load a file using `fetch`.
  2478.  *
  2479.  * @param {object} options Request options to use. See example below.
  2480.  * @returns {Observer} Observer instance
  2481.  * @example
  2482.  * // default options
  2483.  * let options = {
  2484.  *     url: undefined,
  2485.  *     method: 'GET',
  2486.  *     mode: 'cors',
  2487.  *     credentials: 'same-origin',
  2488.  *     cache: 'default',
  2489.  *     responseType: 'json',
  2490.  *     requestHeaders: [],
  2491.  *     redirect: 'follow',
  2492.  *     referrer: 'client'
  2493.  * };
  2494.  *
  2495.  * // override some options
  2496.  * options.url = '../media/demo.wav';
  2497.  
  2498.  * // available types: 'arraybuffer', 'blob', 'json' or 'text'
  2499.  * options.responseType = 'arraybuffer';
  2500.  *
  2501.  * // make fetch call
  2502.  * let request = util.fetchFile(options);
  2503.  *
  2504.  * // listen for events
  2505.  * request.on('progress', e => {
  2506.  *     console.log('progress', e);
  2507.  * });
  2508.  *
  2509.  * request.on('success', data => {
  2510.  *     console.log('success!', data);
  2511.  * });
  2512.  *
  2513.  * request.on('error', e => {
  2514.  *     console.warn('fetchFile error: ', e);
  2515.  * });
  2516.  */
  2517. function fetchFile(options) {
  2518.   if (!options) {
  2519.     throw new Error('fetch options missing');
  2520.   } else if (!options.url) {
  2521.     throw new Error('fetch url missing');
  2522.   }
  2523.   var instance = new _observer.default();
  2524.   var fetchHeaders = new Headers();
  2525.   var fetchRequest = new Request(options.url);
  2526.  
  2527.   // add ability to abort
  2528.   instance.controller = new AbortController();
  2529.  
  2530.   // check if headers have to be added
  2531.   if (options && options.requestHeaders) {
  2532.     // add custom request headers
  2533.     options.requestHeaders.forEach(function (header) {
  2534.       fetchHeaders.append(header.key, header.value);
  2535.     });
  2536.   }
  2537.  
  2538.   // parse fetch options
  2539.   var responseType = options.responseType || 'json';
  2540.   var fetchOptions = {
  2541.     method: options.method || 'GET',
  2542.     headers: fetchHeaders,
  2543.     mode: options.mode || 'cors',
  2544.     credentials: options.credentials || 'same-origin',
  2545.     cache: options.cache || 'default',
  2546.     redirect: options.redirect || 'follow',
  2547.     referrer: options.referrer || 'client',
  2548.     signal: instance.controller.signal
  2549.   };
  2550.   fetch(fetchRequest, fetchOptions).then(function (response) {
  2551.     // store response reference
  2552.     instance.response = response;
  2553.     var progressAvailable = true;
  2554.     if (!response.body) {
  2555.       // ReadableStream is not yet supported in this browser
  2556.       // see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream
  2557.       progressAvailable = false;
  2558.     }
  2559.  
  2560.     // Server must send CORS header "Access-Control-Expose-Headers: content-length"
  2561.     var contentLength = response.headers.get('content-length');
  2562.     if (contentLength === null) {
  2563.       // Content-Length server response header missing.
  2564.       // Don't evaluate download progress if we can't compare against a total size
  2565.       // see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Access-Control-Expose-Headers
  2566.       progressAvailable = false;
  2567.     }
  2568.     if (!progressAvailable) {
  2569.       // not able to check download progress so skip it
  2570.       return response;
  2571.     }
  2572.  
  2573.     // fire progress event when during load
  2574.     instance.onProgress = function (e) {
  2575.       instance.fireEvent('progress', e);
  2576.     };
  2577.     return new Response(new ReadableStream(new ProgressHandler(instance, contentLength, response)), fetchOptions);
  2578.   }).then(function (response) {
  2579.     var errMsg;
  2580.     if (response.ok) {
  2581.       switch (responseType) {
  2582.         case 'arraybuffer':
  2583.           return response.arrayBuffer();
  2584.         case 'json':
  2585.           return response.json();
  2586.         case 'blob':
  2587.           return response.blob();
  2588.         case 'text':
  2589.           return response.text();
  2590.         default:
  2591.           errMsg = 'Unknown responseType: ' + responseType;
  2592.           break;
  2593.       }
  2594.     }
  2595.     if (!errMsg) {
  2596.       errMsg = 'HTTP error status: ' + response.status;
  2597.     }
  2598.     throw new Error(errMsg);
  2599.   }).then(function (response) {
  2600.     instance.fireEvent('success', response);
  2601.   }).catch(function (error) {
  2602.     instance.fireEvent('error', error);
  2603.   });
  2604.  
  2605.   // return the fetch request
  2606.   instance.fetchRequest = fetchRequest;
  2607.   return instance;
  2608. }
  2609. module.exports = exports.default;
  2610.  
  2611. /***/ }),
  2612.  
  2613. /***/ "./src/util/frame.js":
  2614. /*!***************************!*\
  2615.   !*** ./src/util/frame.js ***!
  2616.   \***************************/
  2617. /***/ ((module, exports, __webpack_require__) => {
  2618.  
  2619. "use strict";
  2620.  
  2621.  
  2622. Object.defineProperty(exports, "__esModule", ({
  2623.   value: true
  2624. }));
  2625. exports["default"] = frame;
  2626. var _requestAnimationFrame = _interopRequireDefault(__webpack_require__(/*! ./request-animation-frame */ "./src/util/request-animation-frame.js"));
  2627. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2628. /**
  2629.  * Create a function which will be called at the next requestAnimationFrame
  2630.  * cycle
  2631.  *
  2632.  * @param {function} func The function to call
  2633.  *
  2634.  * @return {func} The function wrapped within a requestAnimationFrame
  2635.  */
  2636. function frame(func) {
  2637.   return function () {
  2638.     for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2639.       args[_key] = arguments[_key];
  2640.     }
  2641.     return (0, _requestAnimationFrame.default)(function () {
  2642.       return func.apply(void 0, args);
  2643.     });
  2644.   };
  2645. }
  2646. module.exports = exports.default;
  2647.  
  2648. /***/ }),
  2649.  
  2650. /***/ "./src/util/get-id.js":
  2651. /*!****************************!*\
  2652.   !*** ./src/util/get-id.js ***!
  2653.   \****************************/
  2654. /***/ ((module, exports) => {
  2655.  
  2656. "use strict";
  2657.  
  2658.  
  2659. Object.defineProperty(exports, "__esModule", ({
  2660.   value: true
  2661. }));
  2662. exports["default"] = getId;
  2663. /**
  2664.  * Get a random prefixed ID
  2665.  *
  2666.  * @param {String} prefix Prefix to use. Default is `'wavesurfer_'`.
  2667.  * @returns {String} Random prefixed ID
  2668.  * @example
  2669.  * console.log(getId()); // logs 'wavesurfer_b5pors4ru6g'
  2670.  *
  2671.  * let prefix = 'foo-';
  2672.  * console.log(getId(prefix)); // logs 'foo-b5pors4ru6g'
  2673.  */
  2674. function getId(prefix) {
  2675.   if (prefix === undefined) {
  2676.     prefix = 'wavesurfer_';
  2677.   }
  2678.   return prefix + Math.random().toString(32).substring(2);
  2679. }
  2680. module.exports = exports.default;
  2681.  
  2682. /***/ }),
  2683.  
  2684. /***/ "./src/util/index.js":
  2685. /*!***************************!*\
  2686.   !*** ./src/util/index.js ***!
  2687.   \***************************/
  2688. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2689.  
  2690. "use strict";
  2691.  
  2692.  
  2693. Object.defineProperty(exports, "__esModule", ({
  2694.   value: true
  2695. }));
  2696. Object.defineProperty(exports, "Observer", ({
  2697.   enumerable: true,
  2698.   get: function get() {
  2699.     return _observer.default;
  2700.   }
  2701. }));
  2702. Object.defineProperty(exports, "absMax", ({
  2703.   enumerable: true,
  2704.   get: function get() {
  2705.     return _absMax.default;
  2706.   }
  2707. }));
  2708. Object.defineProperty(exports, "clamp", ({
  2709.   enumerable: true,
  2710.   get: function get() {
  2711.     return _clamp.default;
  2712.   }
  2713. }));
  2714. Object.defineProperty(exports, "debounce", ({
  2715.   enumerable: true,
  2716.   get: function get() {
  2717.     return _debounce.default;
  2718.   }
  2719. }));
  2720. Object.defineProperty(exports, "fetchFile", ({
  2721.   enumerable: true,
  2722.   get: function get() {
  2723.     return _fetch.default;
  2724.   }
  2725. }));
  2726. Object.defineProperty(exports, "frame", ({
  2727.   enumerable: true,
  2728.   get: function get() {
  2729.     return _frame.default;
  2730.   }
  2731. }));
  2732. Object.defineProperty(exports, "getId", ({
  2733.   enumerable: true,
  2734.   get: function get() {
  2735.     return _getId.default;
  2736.   }
  2737. }));
  2738. Object.defineProperty(exports, "ignoreSilenceMode", ({
  2739.   enumerable: true,
  2740.   get: function get() {
  2741.     return _silenceMode.default;
  2742.   }
  2743. }));
  2744. Object.defineProperty(exports, "max", ({
  2745.   enumerable: true,
  2746.   get: function get() {
  2747.     return _max.default;
  2748.   }
  2749. }));
  2750. Object.defineProperty(exports, "min", ({
  2751.   enumerable: true,
  2752.   get: function get() {
  2753.     return _min.default;
  2754.   }
  2755. }));
  2756. Object.defineProperty(exports, "preventClick", ({
  2757.   enumerable: true,
  2758.   get: function get() {
  2759.     return _preventClick.default;
  2760.   }
  2761. }));
  2762. Object.defineProperty(exports, "requestAnimationFrame", ({
  2763.   enumerable: true,
  2764.   get: function get() {
  2765.     return _requestAnimationFrame.default;
  2766.   }
  2767. }));
  2768. Object.defineProperty(exports, "style", ({
  2769.   enumerable: true,
  2770.   get: function get() {
  2771.     return _style.default;
  2772.   }
  2773. }));
  2774. Object.defineProperty(exports, "withOrientation", ({
  2775.   enumerable: true,
  2776.   get: function get() {
  2777.     return _orientation.default;
  2778.   }
  2779. }));
  2780. var _getId = _interopRequireDefault(__webpack_require__(/*! ./get-id */ "./src/util/get-id.js"));
  2781. var _max = _interopRequireDefault(__webpack_require__(/*! ./max */ "./src/util/max.js"));
  2782. var _min = _interopRequireDefault(__webpack_require__(/*! ./min */ "./src/util/min.js"));
  2783. var _absMax = _interopRequireDefault(__webpack_require__(/*! ./absMax */ "./src/util/absMax.js"));
  2784. var _observer = _interopRequireDefault(__webpack_require__(/*! ./observer */ "./src/util/observer.js"));
  2785. var _style = _interopRequireDefault(__webpack_require__(/*! ./style */ "./src/util/style.js"));
  2786. var _requestAnimationFrame = _interopRequireDefault(__webpack_require__(/*! ./request-animation-frame */ "./src/util/request-animation-frame.js"));
  2787. var _frame = _interopRequireDefault(__webpack_require__(/*! ./frame */ "./src/util/frame.js"));
  2788. var _debounce = _interopRequireDefault(__webpack_require__(/*! debounce */ "./node_modules/debounce/index.js"));
  2789. var _preventClick = _interopRequireDefault(__webpack_require__(/*! ./prevent-click */ "./src/util/prevent-click.js"));
  2790. var _fetch = _interopRequireDefault(__webpack_require__(/*! ./fetch */ "./src/util/fetch.js"));
  2791. var _clamp = _interopRequireDefault(__webpack_require__(/*! ./clamp */ "./src/util/clamp.js"));
  2792. var _orientation = _interopRequireDefault(__webpack_require__(/*! ./orientation */ "./src/util/orientation.js"));
  2793. var _silenceMode = _interopRequireDefault(__webpack_require__(/*! ./silence-mode */ "./src/util/silence-mode.js"));
  2794. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2795.  
  2796. /***/ }),
  2797.  
  2798. /***/ "./src/util/max.js":
  2799. /*!*************************!*\
  2800.   !*** ./src/util/max.js ***!
  2801.   \*************************/
  2802. /***/ ((module, exports) => {
  2803.  
  2804. "use strict";
  2805.  
  2806.  
  2807. Object.defineProperty(exports, "__esModule", ({
  2808.   value: true
  2809. }));
  2810. exports["default"] = max;
  2811. /**
  2812.  * Get the largest value
  2813.  *
  2814.  * @param   {Array} values Array of numbers
  2815.  * @returns {Number} Largest number found
  2816.  * @example console.log(max([1, 2, 3])); // logs 3
  2817.  */
  2818. function max(values) {
  2819.   var largest = -Infinity;
  2820.   Object.keys(values).forEach(function (i) {
  2821.     if (values[i] > largest) {
  2822.       largest = values[i];
  2823.     }
  2824.   });
  2825.   return largest;
  2826. }
  2827. module.exports = exports.default;
  2828.  
  2829. /***/ }),
  2830.  
  2831. /***/ "./src/util/min.js":
  2832. /*!*************************!*\
  2833.   !*** ./src/util/min.js ***!
  2834.   \*************************/
  2835. /***/ ((module, exports) => {
  2836.  
  2837. "use strict";
  2838.  
  2839.  
  2840. Object.defineProperty(exports, "__esModule", ({
  2841.   value: true
  2842. }));
  2843. exports["default"] = min;
  2844. /**
  2845.  * Get the smallest value
  2846.  *
  2847.  * @param   {Array} values Array of numbers
  2848.  * @returns {Number} Smallest number found
  2849.  * @example console.log(min([1, 2, 3])); // logs 1
  2850.  */
  2851. function min(values) {
  2852.   var smallest = Number(Infinity);
  2853.   Object.keys(values).forEach(function (i) {
  2854.     if (values[i] < smallest) {
  2855.       smallest = values[i];
  2856.     }
  2857.   });
  2858.   return smallest;
  2859. }
  2860. module.exports = exports.default;
  2861.  
  2862. /***/ }),
  2863.  
  2864. /***/ "./src/util/observer.js":
  2865. /*!******************************!*\
  2866.   !*** ./src/util/observer.js ***!
  2867.   \******************************/
  2868. /***/ ((module, exports) => {
  2869.  
  2870. "use strict";
  2871.  
  2872.  
  2873. Object.defineProperty(exports, "__esModule", ({
  2874.   value: true
  2875. }));
  2876. exports["default"] = void 0;
  2877. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  2878. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2879. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  2880. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2881. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  2882. function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  2883. /**
  2884.  * @typedef {Object} ListenerDescriptor
  2885.  * @property {string} name The name of the event
  2886.  * @property {function} callback The callback
  2887.  * @property {function} un The function to call to remove the listener
  2888.  */
  2889. /**
  2890.  * Observer class
  2891.  */
  2892. var Observer = /*#__PURE__*/function () {
  2893.   /**
  2894.    * Instantiate Observer
  2895.    */
  2896.   function Observer() {
  2897.     _classCallCheck(this, Observer);
  2898.     /**
  2899.      * @private
  2900.      * @todo Initialise the handlers here already and remove the conditional
  2901.      * assignment in `on()`
  2902.      */
  2903.     this._disabledEventEmissions = [];
  2904.     this.handlers = null;
  2905.   }
  2906.   /**
  2907.    * Attach a handler function for an event.
  2908.    *
  2909.    * @param {string} event Name of the event to listen to
  2910.    * @param {function} fn The callback to trigger when the event is fired
  2911.    * @return {ListenerDescriptor} The event descriptor
  2912.    */
  2913.   _createClass(Observer, [{
  2914.     key: "on",
  2915.     value: function on(event, fn) {
  2916.       var _this = this;
  2917.       if (!this.handlers) {
  2918.         this.handlers = {};
  2919.       }
  2920.       var handlers = this.handlers[event];
  2921.       if (!handlers) {
  2922.         handlers = this.handlers[event] = [];
  2923.       }
  2924.       handlers.push(fn);
  2925.  
  2926.       // Return an event descriptor
  2927.       return {
  2928.         name: event,
  2929.         callback: fn,
  2930.         un: function un(e, fn) {
  2931.           return _this.un(e, fn);
  2932.         }
  2933.       };
  2934.     }
  2935.  
  2936.     /**
  2937.      * Remove an event handler.
  2938.      *
  2939.      * @param {string} event Name of the event the listener that should be
  2940.      * removed listens to
  2941.      * @param {function} fn The callback that should be removed
  2942.      */
  2943.   }, {
  2944.     key: "un",
  2945.     value: function un(event, fn) {
  2946.       if (!this.handlers) {
  2947.         return;
  2948.       }
  2949.       var handlers = this.handlers[event];
  2950.       var i;
  2951.       if (handlers) {
  2952.         if (fn) {
  2953.           for (i = handlers.length - 1; i >= 0; i--) {
  2954.             if (handlers[i] == fn) {
  2955.               handlers.splice(i, 1);
  2956.             }
  2957.           }
  2958.         } else {
  2959.           handlers.length = 0;
  2960.         }
  2961.       }
  2962.     }
  2963.  
  2964.     /**
  2965.      * Remove all event handlers.
  2966.      */
  2967.   }, {
  2968.     key: "unAll",
  2969.     value: function unAll() {
  2970.       this.handlers = null;
  2971.     }
  2972.  
  2973.     /**
  2974.      * Attach a handler to an event. The handler is executed at most once per
  2975.      * event type.
  2976.      *
  2977.      * @param {string} event The event to listen to
  2978.      * @param {function} handler The callback that is only to be called once
  2979.      * @return {ListenerDescriptor} The event descriptor
  2980.      */
  2981.   }, {
  2982.     key: "once",
  2983.     value: function once(event, handler) {
  2984.       var _this2 = this;
  2985.       var fn = function fn() {
  2986.         for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2987.           args[_key] = arguments[_key];
  2988.         }
  2989.         /*  eslint-disable no-invalid-this */
  2990.         handler.apply(_this2, args);
  2991.         /*  eslint-enable no-invalid-this */
  2992.         setTimeout(function () {
  2993.           _this2.un(event, fn);
  2994.         }, 0);
  2995.       };
  2996.       return this.on(event, fn);
  2997.     }
  2998.  
  2999.     /**
  3000.      * Disable firing a list of events by name. When specified, event handlers for any event type
  3001.      * passed in here will not be called.
  3002.      *
  3003.      * @since 4.0.0
  3004.      * @param {string[]} eventNames an array of event names to disable emissions for
  3005.      * @example
  3006.      * // disable seek and interaction events
  3007.      * wavesurfer.setDisabledEventEmissions(['seek', 'interaction']);
  3008.      */
  3009.   }, {
  3010.     key: "setDisabledEventEmissions",
  3011.     value: function setDisabledEventEmissions(eventNames) {
  3012.       this._disabledEventEmissions = eventNames;
  3013.     }
  3014.  
  3015.     /**
  3016.      * plugins borrow part of this class without calling the constructor,
  3017.      * so we have to be careful about _disabledEventEmissions
  3018.      */
  3019.   }, {
  3020.     key: "_isDisabledEventEmission",
  3021.     value: function _isDisabledEventEmission(event) {
  3022.       return this._disabledEventEmissions && this._disabledEventEmissions.includes(event);
  3023.     }
  3024.  
  3025.     /**
  3026.      * Manually fire an event
  3027.      *
  3028.      * @param {string} event The event to fire manually
  3029.      * @param {...any} args The arguments with which to call the listeners
  3030.      */
  3031.   }, {
  3032.     key: "fireEvent",
  3033.     value: function fireEvent(event) {
  3034.       for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  3035.         args[_key2 - 1] = arguments[_key2];
  3036.       }
  3037.       if (!this.handlers || this._isDisabledEventEmission(event)) {
  3038.         return;
  3039.       }
  3040.       var handlers = this.handlers[event];
  3041.       handlers && handlers.forEach(function (fn) {
  3042.         fn.apply(void 0, args);
  3043.       });
  3044.     }
  3045.   }]);
  3046.   return Observer;
  3047. }();
  3048. exports["default"] = Observer;
  3049. module.exports = exports.default;
  3050.  
  3051. /***/ }),
  3052.  
  3053. /***/ "./src/util/orientation.js":
  3054. /*!*********************************!*\
  3055.   !*** ./src/util/orientation.js ***!
  3056.   \*********************************/
  3057. /***/ ((module, exports) => {
  3058.  
  3059. "use strict";
  3060.  
  3061.  
  3062. Object.defineProperty(exports, "__esModule", ({
  3063.   value: true
  3064. }));
  3065. exports["default"] = withOrientation;
  3066. var verticalPropMap = {
  3067.   width: 'height',
  3068.   height: 'width',
  3069.   overflowX: 'overflowY',
  3070.   overflowY: 'overflowX',
  3071.   clientWidth: 'clientHeight',
  3072.   clientHeight: 'clientWidth',
  3073.   clientX: 'clientY',
  3074.   clientY: 'clientX',
  3075.   scrollWidth: 'scrollHeight',
  3076.   scrollLeft: 'scrollTop',
  3077.   offsetLeft: 'offsetTop',
  3078.   offsetTop: 'offsetLeft',
  3079.   offsetHeight: 'offsetWidth',
  3080.   offsetWidth: 'offsetHeight',
  3081.   left: 'top',
  3082.   right: 'bottom',
  3083.   top: 'left',
  3084.   bottom: 'right',
  3085.   borderRightStyle: 'borderBottomStyle',
  3086.   borderRightWidth: 'borderBottomWidth',
  3087.   borderRightColor: 'borderBottomColor'
  3088. };
  3089.  
  3090. /**
  3091.  * Convert a horizontally-oriented property name to a vertical one.
  3092.  *
  3093.  * @param {string} prop A property name
  3094.  * @param {bool} vertical Whether the element is oriented vertically
  3095.  * @returns {string} prop, converted appropriately
  3096.  */
  3097. function mapProp(prop, vertical) {
  3098.   if (Object.prototype.hasOwnProperty.call(verticalPropMap, prop)) {
  3099.     return vertical ? verticalPropMap[prop] : prop;
  3100.   } else {
  3101.     return prop;
  3102.   }
  3103. }
  3104. var isProxy = Symbol("isProxy");
  3105.  
  3106. /**
  3107.  * Returns an appropriately oriented object based on vertical.
  3108.  * If vertical is true, attribute getting and setting will be mapped through
  3109.  * verticalPropMap, so that e.g. getting the object's .width will give its
  3110.  * .height instead.
  3111.  * Certain methods of an oriented object will return oriented objects as well.
  3112.  * Oriented objects can't be added to the DOM directly since they are Proxy objects
  3113.  * and thus fail typechecks. Use domElement to get the actual element for this.
  3114.  *
  3115.  * @param {object} target The object to be wrapped and oriented
  3116.  * @param {bool} vertical Whether the element is oriented vertically
  3117.  * @returns {Proxy} An oriented object with attr translation via verticalAttrMap
  3118.  * @since 5.0.0
  3119.  */
  3120. function withOrientation(target, vertical) {
  3121.   if (target[isProxy]) {
  3122.     return target;
  3123.   } else {
  3124.     return new Proxy(target, {
  3125.       get: function get(obj, prop, receiver) {
  3126.         if (prop === isProxy) {
  3127.           return true;
  3128.         } else if (prop === 'domElement') {
  3129.           return obj;
  3130.         } else if (prop === 'style') {
  3131.           return withOrientation(obj.style, vertical);
  3132.         } else if (prop === 'canvas') {
  3133.           return withOrientation(obj.canvas, vertical);
  3134.         } else if (prop === 'getBoundingClientRect') {
  3135.           return function () {
  3136.             return withOrientation(obj.getBoundingClientRect.apply(obj, arguments), vertical);
  3137.           };
  3138.         } else if (prop === 'getContext') {
  3139.           return function () {
  3140.             return withOrientation(obj.getContext.apply(obj, arguments), vertical);
  3141.           };
  3142.         } else {
  3143.           var value = obj[mapProp(prop, vertical)];
  3144.           return typeof value == 'function' ? value.bind(obj) : value;
  3145.         }
  3146.       },
  3147.       set: function set(obj, prop, value) {
  3148.         obj[mapProp(prop, vertical)] = value;
  3149.         return true;
  3150.       }
  3151.     });
  3152.   }
  3153. }
  3154. module.exports = exports.default;
  3155.  
  3156. /***/ }),
  3157.  
  3158. /***/ "./src/util/prevent-click.js":
  3159. /*!***********************************!*\
  3160.   !*** ./src/util/prevent-click.js ***!
  3161.   \***********************************/
  3162. /***/ ((module, exports) => {
  3163.  
  3164. "use strict";
  3165.  
  3166.  
  3167. Object.defineProperty(exports, "__esModule", ({
  3168.   value: true
  3169. }));
  3170. exports["default"] = preventClick;
  3171. /**
  3172.  * Stops propagation of click event and removes event listener
  3173.  *
  3174.  * @private
  3175.  * @param {object} event The click event
  3176.  */
  3177. function preventClickHandler(event) {
  3178.   event.stopPropagation();
  3179.   document.body.removeEventListener('click', preventClickHandler, true);
  3180. }
  3181.  
  3182. /**
  3183.  * Starts listening for click event and prevent propagation
  3184.  *
  3185.  * @param {object} values Values
  3186.  */
  3187. function preventClick(values) {
  3188.   document.body.addEventListener('click', preventClickHandler, true);
  3189. }
  3190. module.exports = exports.default;
  3191.  
  3192. /***/ }),
  3193.  
  3194. /***/ "./src/util/request-animation-frame.js":
  3195. /*!*********************************************!*\
  3196.   !*** ./src/util/request-animation-frame.js ***!
  3197.   \*********************************************/
  3198. /***/ ((module, exports) => {
  3199.  
  3200. "use strict";
  3201.  
  3202.  
  3203. Object.defineProperty(exports, "__esModule", ({
  3204.   value: true
  3205. }));
  3206. exports["default"] = void 0;
  3207. /* eslint-disable valid-jsdoc */
  3208. /**
  3209.  * Returns the `requestAnimationFrame` function for the browser, or a shim with
  3210.  * `setTimeout` if the function is not found
  3211.  *
  3212.  * @return {function} Available `requestAnimationFrame` function for the browser
  3213.  */
  3214. var _default = (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {
  3215.   return setTimeout(callback, 1000 / 60);
  3216. }).bind(window);
  3217. exports["default"] = _default;
  3218. module.exports = exports.default;
  3219.  
  3220. /***/ }),
  3221.  
  3222. /***/ "./src/util/silence-mode.js":
  3223. /*!**********************************!*\
  3224.   !*** ./src/util/silence-mode.js ***!
  3225.   \**********************************/
  3226. /***/ ((module, exports) => {
  3227.  
  3228. "use strict";
  3229.  
  3230.  
  3231. Object.defineProperty(exports, "__esModule", ({
  3232.   value: true
  3233. }));
  3234. exports["default"] = ignoreSilenceMode;
  3235. /**
  3236.  * Ignores device silence mode when using the `WebAudio` backend.
  3237.  *
  3238.  * Many mobile devices contain a hardware button to mute the ringtone for incoming
  3239.  * calls and messages. Unfortunately, on some platforms like iOS, this also mutes
  3240.  * wavesurfer's audio when using the `WebAudio` backend. This function creates a
  3241.  * temporary `<audio>` element that makes sure the WebAudio backend keeps playing
  3242.  * when muting the device ringer.
  3243.  *
  3244.  * @since 5.2.0
  3245.  */
  3246. function ignoreSilenceMode() {
  3247.   // Set webaudio context with 1 second silent audio 44100 bit rate buffer to allow playing audio even if silent switch is on the device
  3248.   var silentAC = new AudioContext();
  3249.   var silentBS = silentAC.createBufferSource();
  3250.   silentBS.buffer = silentAC.createBuffer(1, 1, 44100);
  3251.   silentBS.connect(silentAC.destination);
  3252.   silentBS.start();
  3253.  
  3254.   // Set the src to a short bit of url encoded as a silent mp3
  3255.   // NOTE The silence MP3 must be high quality, when web audio sounds are played
  3256.   // in parallel the web audio sound is mixed to match the bitrate of the html sound
  3257.   // 0.01 seconds of silence VBR220-260 Joint Stereo 859B
  3258.   var audioData = "data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAACcQCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA//////////////////////////////////////////////////////////////////8AAABhTEFNRTMuMTAwA8MAAAAAAAAAABQgJAUHQQAB9AAAAnGMHkkIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//sQxAADgnABGiAAQBCqgCRMAAgEAH///////////////7+n/9FTuQsQH//////2NG0jWUGlio5gLQTOtIoeR2WX////X4s9Atb/JRVCbBUpeRUq//////////////////9RUi0f2jn/+xDECgPCjAEQAABN4AAANIAAAAQVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==";
  3259.  
  3260.   // disable iOS Airplay (setting the attribute in js doesn't work)
  3261.   var tmp = document.createElement("div");
  3262.   tmp.innerHTML = '<audio x-webkit-airplay="deny"></audio>';
  3263.   var audioSilentMode = tmp.children.item(0);
  3264.   audioSilentMode.src = audioData;
  3265.   audioSilentMode.preload = "auto";
  3266.   audioSilentMode.type = "audio/mpeg";
  3267.   audioSilentMode.disableRemotePlayback = true;
  3268.  
  3269.   // play
  3270.   audioSilentMode.play();
  3271.  
  3272.   // cleanup
  3273.   audioSilentMode.remove();
  3274.   tmp.remove();
  3275. }
  3276. module.exports = exports.default;
  3277.  
  3278. /***/ }),
  3279.  
  3280. /***/ "./src/util/style.js":
  3281. /*!***************************!*\
  3282.   !*** ./src/util/style.js ***!
  3283.   \***************************/
  3284. /***/ ((module, exports) => {
  3285.  
  3286. "use strict";
  3287.  
  3288.  
  3289. Object.defineProperty(exports, "__esModule", ({
  3290.   value: true
  3291. }));
  3292. exports["default"] = style;
  3293. /**
  3294.  * Apply a map of styles to an element
  3295.  *
  3296.  * @param {HTMLElement} el The element that the styles will be applied to
  3297.  * @param {Object} styles The map of propName: attribute, both are used as-is
  3298.  *
  3299.  * @return {HTMLElement} el
  3300.  */
  3301. function style(el, styles) {
  3302.   Object.keys(styles).forEach(function (prop) {
  3303.     if (el.style[prop] !== styles[prop]) {
  3304.       el.style[prop] = styles[prop];
  3305.     }
  3306.   });
  3307.   return el;
  3308. }
  3309. module.exports = exports.default;
  3310.  
  3311. /***/ }),
  3312.  
  3313. /***/ "./src/wavesurfer.js":
  3314. /*!***************************!*\
  3315.   !*** ./src/wavesurfer.js ***!
  3316.   \***************************/
  3317. /***/ ((module, exports, __webpack_require__) => {
  3318.  
  3319. "use strict";
  3320.  
  3321.  
  3322. Object.defineProperty(exports, "__esModule", ({
  3323.   value: true
  3324. }));
  3325. exports["default"] = void 0;
  3326. var util = _interopRequireWildcard(__webpack_require__(/*! ./util */ "./src/util/index.js"));
  3327. var _drawer = _interopRequireDefault(__webpack_require__(/*! ./drawer.multicanvas */ "./src/drawer.multicanvas.js"));
  3328. var _webaudio = _interopRequireDefault(__webpack_require__(/*! ./webaudio */ "./src/webaudio.js"));
  3329. var _mediaelement = _interopRequireDefault(__webpack_require__(/*! ./mediaelement */ "./src/mediaelement.js"));
  3330. var _peakcache = _interopRequireDefault(__webpack_require__(/*! ./peakcache */ "./src/peakcache.js"));
  3331. var _mediaelementWebaudio = _interopRequireDefault(__webpack_require__(/*! ./mediaelement-webaudio */ "./src/mediaelement-webaudio.js"));
  3332. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3333. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  3334. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  3335. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  3336. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3337. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3338. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  3339. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3340. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3341. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  3342. function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  3343. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  3344. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3345. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  3346. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  3347. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  3348. function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  3349. /*
  3350.  * This work is licensed under a BSD-3-Clause License.
  3351.  */
  3352. /** @external {HTMLElement} https://developer.mozilla.org/en/docs/Web/API/HTMLElement */
  3353. /** @external {OfflineAudioContext} https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext */
  3354. /** @external {File} https://developer.mozilla.org/en-US/docs/Web/API/File */
  3355. /** @external {Blob} https://developer.mozilla.org/en-US/docs/Web/API/Blob */
  3356. /** @external {CanvasRenderingContext2D} https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D */
  3357. /** @external {MediaStreamConstraints} https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraints */
  3358. /** @external {AudioNode} https://developer.mozilla.org/de/docs/Web/API/AudioNode */
  3359. /**
  3360.  * @typedef {Object} WavesurferParams
  3361.  * @property {AudioContext} audioContext=null Use your own previously
  3362.  * initialized AudioContext or leave blank.
  3363.  * @property {number} audioRate=1 Speed at which to play audio. Lower number is
  3364.  * slower.
  3365.  * @property {ScriptProcessorNode} audioScriptProcessor=null Use your own previously
  3366.  * initialized ScriptProcessorNode or leave blank.
  3367.  * @property {boolean} autoCenter=true If a scrollbar is present, center the
  3368.  * waveform on current progress
  3369.  * @property {number} autoCenterRate=5 If autoCenter is active, rate at which the
  3370.  * waveform is centered
  3371.  * @property {boolean} autoCenterImmediately=false If autoCenter is active, immediately
  3372.  * center waveform on current progress
  3373.  * @property {string} backend='WebAudio' `'WebAudio'|'MediaElement'|'MediaElementWebAudio'` In most cases
  3374.  * you don't have to set this manually. MediaElement is a fallback for unsupported browsers.
  3375.  * MediaElementWebAudio allows to use WebAudio API also with big audio files, loading audio like with
  3376.  * MediaElement backend (HTML5 audio tag). You have to use the same methods of MediaElement backend for loading and
  3377.  * playback, giving also peaks, so the audio data are not decoded. In this way you can use WebAudio features, like filters,
  3378.  * also with audio with big duration. For example:
  3379.  * ` wavesurfer.load(url | HTMLMediaElement, peaks, preload, duration);
  3380.  *   wavesurfer.play();
  3381.  *   wavesurfer.setFilter(customFilter);
  3382.  * `
  3383.  * @property {string} backgroundColor=null Change background color of the
  3384.  * waveform container.
  3385.  * @property {number} barHeight=1 The height of the wave bars.
  3386.  * @property {number} barRadius=0 The radius of the wave bars. Makes bars rounded
  3387.  * @property {number} barGap=null The optional spacing between bars of the wave,
  3388.  * if not provided will be calculated in legacy format.
  3389.  * @property {number} barWidth=null Draw the waveform using bars.
  3390.  * @property {number} barMinHeight=null If specified, draw at least a bar of this height,
  3391.  * eliminating waveform gaps
  3392.  * @property {boolean} closeAudioContext=false Close and nullify all audio
  3393.  * contexts when the destroy method is called.
  3394.  * @property {!string|HTMLElement} container CSS selector or HTML element where
  3395.  * the waveform should be drawn. This is the only required parameter.
  3396.  * @property {string} cursorColor='#333' The fill color of the cursor indicating
  3397.  * the playhead position.
  3398.  * @property {number} cursorWidth=1 Measured in pixels.
  3399.  * @property {object} drawingContextAttributes={desynchronized: false} Drawing context
  3400.  * attributes.
  3401.  * @property {number} duration=null Optional audio length so pre-rendered peaks
  3402.  * can be display immediately for example.
  3403.  * @property {boolean} fillParent=true Whether to fill the entire container or
  3404.  * draw only according to `minPxPerSec`.
  3405.  * @property {boolean} forceDecode=false Force decoding of audio using web audio
  3406.  * when zooming to get a more detailed waveform.
  3407.  * @property {number} height=128 The height of the waveform. Measured in
  3408.  * pixels.
  3409.  * @property {boolean} hideScrollbar=false Whether to hide the horizontal
  3410.  * scrollbar when one would normally be shown.
  3411.  * @property {boolean} hideCursor=false Whether to hide the mouse cursor
  3412.  * when one would normally be shown by default.
  3413.  * @property {boolean} ignoreSilenceMode=false If true, ignores device silence mode
  3414.  * when using the `WebAudio` backend.
  3415.  * @property {boolean} interact=true Whether the mouse interaction will be
  3416.  * enabled at initialization. You can switch this parameter at any time later
  3417.  * on.
  3418.  * @property {boolean} loopSelection=true (Use with regions plugin) Enable
  3419.  * looping of selected regions
  3420.  * @property {number} maxCanvasWidth=4000 Maximum width of a single canvas in
  3421.  * pixels, excluding a small overlap (2 * `pixelRatio`, rounded up to the next
  3422.  * even integer). If the waveform is longer than this value, additional canvases
  3423.  * will be used to render the waveform, which is useful for very large waveforms
  3424.  * that may be too wide for browsers to draw on a single canvas.
  3425.  * @property {boolean} mediaControls=false (Use with backend `MediaElement` or `MediaElementWebAudio`)
  3426.  * this enables the native controls for the media element
  3427.  * @property {string} mediaType='audio' (Use with backend `MediaElement` or `MediaElementWebAudio`)
  3428.  * `'audio'|'video'` ('video' only for `MediaElement`)
  3429.  * @property {number} minPxPerSec=20 Minimum number of pixels per second of
  3430.  * audio.
  3431.  * @property {boolean} normalize=false If true, normalize by the maximum peak
  3432.  * instead of 1.0.
  3433.  * @property {boolean} partialRender=false Use the PeakCache to improve
  3434.  * rendering speed of large waveforms
  3435.  * @property {number} pixelRatio=window.devicePixelRatio The pixel ratio used to
  3436.  * calculate display
  3437.  * @property {PluginDefinition[]} plugins=[] An array of plugin definitions to
  3438.  * register during instantiation, they will be directly initialised unless they
  3439.  * are added with the `deferInit` property set to true.
  3440.  * @property {string} progressColor='#555' The fill color of the part of the
  3441.  * waveform behind the cursor. When `progressColor` and `waveColor` are the same
  3442.  * the progress wave is not rendered at all.
  3443.  * @property {boolean} removeMediaElementOnDestroy=true Set to false to keep the
  3444.  * media element in the DOM when the player is destroyed. This is useful when
  3445.  * reusing an existing media element via the `loadMediaElement` method.
  3446.  * @property {Object} renderer=MultiCanvas Can be used to inject a custom
  3447.  * renderer.
  3448.  * @property {boolean|number} responsive=false If set to `true` resize the
  3449.  * waveform, when the window is resized. This is debounced with a `100ms`
  3450.  * timeout by default. If this parameter is a number it represents that timeout.
  3451.  * @property {boolean} rtl=false If set to `true`, renders waveform from
  3452.  * right-to-left.
  3453.  * @property {boolean} scrollParent=false Whether to scroll the container with a
  3454.  * lengthy waveform. Otherwise the waveform is shrunk to the container width
  3455.  * (see fillParent).
  3456.  * @property {number} skipLength=2 Number of seconds to skip with the
  3457.  * skipForward() and skipBackward() methods.
  3458.  * @property {boolean} splitChannels=false Render with separate waveforms for
  3459.  * the channels of the audio
  3460.  * @property {SplitChannelOptions} splitChannelsOptions={} Options for splitChannel rendering
  3461.  * @property {boolean} vertical=false Render the waveform vertically instead of horizontally.
  3462.  * @property {string} waveColor='#999' The fill color of the waveform after the
  3463.  * cursor.
  3464.  * @property {object} xhr={} XHR options. For example:
  3465.  * `let xhr = {
  3466.  *     cache: 'default',
  3467.  *     mode: 'cors',
  3468.  *     method: 'GET',
  3469.  *     credentials: 'same-origin',
  3470.  *     redirect: 'follow',
  3471.  *     referrer: 'client',
  3472.  *     requestHeaders: [
  3473.  *         {
  3474.  *             key: 'Authorization',
  3475.  *             value: 'my-token'
  3476.  *         }
  3477.  *     ]
  3478.  * };`
  3479.  */
  3480. /**
  3481.  * @typedef {Object} PluginDefinition
  3482.  * @desc The Object used to describe a plugin
  3483.  * @example wavesurfer.addPlugin(pluginDefinition);
  3484.  * @property {string} name The name of the plugin, the plugin instance will be
  3485.  * added as a property to the wavesurfer instance under this name
  3486.  * @property {?Object} staticProps The properties that should be added to the
  3487.  * wavesurfer instance as static properties
  3488.  * @property {?boolean} deferInit Don't initialise plugin
  3489.  * automatically
  3490.  * @property {Object} params={} The plugin parameters, they are the first parameter
  3491.  * passed to the plugin class constructor function
  3492.  * @property {PluginClass} instance The plugin instance factory, is called with
  3493.  * the dependency specified in extends. Returns the plugin class.
  3494.  */
  3495. /**
  3496.  * @typedef {Object} SplitChannelOptions
  3497.  * @desc parameters applied when splitChannels option is true
  3498.  * @property {boolean} overlay=false determines whether channels are rendered on top of each other or on separate tracks
  3499.  * @property {object} channelColors={} object describing color for each channel. Example:
  3500.  * {
  3501.  *     0: {
  3502.  *         progressColor: 'green',
  3503.  *         waveColor: 'pink'
  3504.  *     },
  3505.  *     1: {
  3506.  *         progressColor: 'orange',
  3507.  *         waveColor: 'purple'
  3508.  *     }
  3509.  * }
  3510.  * @property {number[]} filterChannels=[] indexes of channels to be hidden from rendering
  3511.  * @property {boolean} relativeNormalization=false determines whether
  3512.  * normalization is done per channel or maintains proportionality between
  3513.  * channels. Only applied when normalize and splitChannels are both true.
  3514.  * @property {boolean} splitDragSelection=false determines if drag selection in regions
  3515.  * plugin works separately on each channel or only one selection for all channels
  3516.  * @since 4.3.0
  3517.  */
  3518. /**
  3519.  * @interface PluginClass
  3520.  *
  3521.  * @desc This is the interface which is implemented by all plugin classes. Note
  3522.  * that this only turns into an observer after being passed through
  3523.  * `wavesurfer.addPlugin`.
  3524.  *
  3525.  * @extends {Observer}
  3526.  */
  3527. var PluginClass = /*#__PURE__*/function () {
  3528.   /**
  3529.    * Construct the plugin
  3530.    *
  3531.    * @param {Object} params={} The plugin params (specific to the plugin)
  3532.    * @param {Object} ws The wavesurfer instance
  3533.    */
  3534.   function PluginClass(params, ws) {
  3535.     _classCallCheck(this, PluginClass);
  3536.   }
  3537.   /**
  3538.    * Initialise the plugin
  3539.    *
  3540.    * Start doing something. This is called by
  3541.    * `wavesurfer.initPlugin(pluginName)`
  3542.    */
  3543.   _createClass(PluginClass, [{
  3544.     key: "create",
  3545.     value:
  3546.     /**
  3547.      * Plugin definition factory
  3548.      *
  3549.      * This function must be used to create a plugin definition which can be
  3550.      * used by wavesurfer to correctly instantiate the plugin.
  3551.      *
  3552.      * It returns a `PluginDefinition` object representing the plugin.
  3553.      *
  3554.      * @param {Object} params={} The plugin params (specific to the plugin)
  3555.      */
  3556.     function create(params) {}
  3557.   }, {
  3558.     key: "init",
  3559.     value: function init() {}
  3560.     /**
  3561.      * Destroy the plugin instance
  3562.      *
  3563.      * Stop doing something. This is called by
  3564.      * `wavesurfer.destroyPlugin(pluginName)`
  3565.      */
  3566.   }, {
  3567.     key: "destroy",
  3568.     value: function destroy() {}
  3569.   }]);
  3570.   return PluginClass;
  3571. }();
  3572. /**
  3573.  * WaveSurfer core library class
  3574.  *
  3575.  * @extends {Observer}
  3576.  * @example
  3577.  * const params = {
  3578.  *   container: '#waveform',
  3579.  *   waveColor: 'violet',
  3580.  *   progressColor: 'purple'
  3581.  * };
  3582.  *
  3583.  * // initialise like this
  3584.  * const wavesurfer = WaveSurfer.create(params);
  3585.  *
  3586.  * // or like this ...
  3587.  * const wavesurfer = new WaveSurfer(params);
  3588.  * wavesurfer.init();
  3589.  *
  3590.  * // load audio file
  3591.  * wavesurfer.load('example/media/demo.wav');
  3592.  */
  3593. var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
  3594.   _inherits(WaveSurfer, _util$Observer);
  3595.   var _super = _createSuper(WaveSurfer);
  3596.   /**
  3597.    * Initialise wavesurfer instance
  3598.    *
  3599.    * @param {WavesurferParams} params Instantiation options for wavesurfer
  3600.    * @example
  3601.    * const wavesurfer = new WaveSurfer(params);
  3602.    * @returns {this} Wavesurfer instance
  3603.    */
  3604.   function WaveSurfer(params) {
  3605.     var _this;
  3606.     _classCallCheck(this, WaveSurfer);
  3607.     _this = _super.call(this);
  3608.     /**
  3609.      * Extract relevant parameters (or defaults)
  3610.      * @private
  3611.      */
  3612.     /** @private */
  3613.     _defineProperty(_assertThisInitialized(_this), "defaultParams", {
  3614.       audioContext: null,
  3615.       audioScriptProcessor: null,
  3616.       audioRate: 1,
  3617.       autoCenter: true,
  3618.       autoCenterRate: 5,
  3619.       autoCenterImmediately: false,
  3620.       backend: 'WebAudio',
  3621.       backgroundColor: null,
  3622.       barHeight: 1,
  3623.       barRadius: 0,
  3624.       barGap: null,
  3625.       barMinHeight: null,
  3626.       container: null,
  3627.       cursorColor: '#333',
  3628.       cursorWidth: 1,
  3629.       dragSelection: true,
  3630.       drawingContextAttributes: {
  3631.         // Boolean that hints the user agent to reduce the latency
  3632.         // by desynchronizing the canvas paint cycle from the event
  3633.         // loop
  3634.         desynchronized: false
  3635.       },
  3636.       duration: null,
  3637.       fillParent: true,
  3638.       forceDecode: false,
  3639.       height: 128,
  3640.       hideScrollbar: false,
  3641.       hideCursor: false,
  3642.       ignoreSilenceMode: false,
  3643.       interact: true,
  3644.       loopSelection: true,
  3645.       maxCanvasWidth: 4000,
  3646.       mediaContainer: null,
  3647.       mediaControls: false,
  3648.       mediaType: 'audio',
  3649.       minPxPerSec: 20,
  3650.       normalize: false,
  3651.       partialRender: false,
  3652.       pixelRatio: window.devicePixelRatio || screen.deviceXDPI / screen.logicalXDPI,
  3653.       plugins: [],
  3654.       progressColor: '#555',
  3655.       removeMediaElementOnDestroy: true,
  3656.       renderer: _drawer.default,
  3657.       responsive: false,
  3658.       rtl: false,
  3659.       scrollParent: false,
  3660.       skipLength: 2,
  3661.       splitChannels: false,
  3662.       splitChannelsOptions: {
  3663.         overlay: false,
  3664.         channelColors: {},
  3665.         filterChannels: [],
  3666.         relativeNormalization: false,
  3667.         splitDragSelection: false
  3668.       },
  3669.       vertical: false,
  3670.       waveColor: '#999',
  3671.       xhr: {}
  3672.     });
  3673.     /** @private */
  3674.     _defineProperty(_assertThisInitialized(_this), "backends", {
  3675.       MediaElement: _mediaelement.default,
  3676.       WebAudio: _webaudio.default,
  3677.       MediaElementWebAudio: _mediaelementWebaudio.default
  3678.     });
  3679.     /**
  3680.      * Functions in the `util` property are available as a prototype property to
  3681.      * all instances
  3682.      *
  3683.      * @type {Object}
  3684.      * @example
  3685.      * const wavesurfer = WaveSurfer.create(params);
  3686.      * wavesurfer.util.style(myElement, { background: 'blue' });
  3687.      */
  3688.     _defineProperty(_assertThisInitialized(_this), "util", util);
  3689.     _this.params = Object.assign({}, _this.defaultParams, params);
  3690.     _this.params.splitChannelsOptions = Object.assign({}, _this.defaultParams.splitChannelsOptions, params.splitChannelsOptions);
  3691.     /** @private */
  3692.     _this.container = 'string' == typeof params.container ? document.querySelector(_this.params.container) : _this.params.container;
  3693.     if (!_this.container) {
  3694.       throw new Error('Container element not found');
  3695.     }
  3696.     if (_this.params.mediaContainer == null) {
  3697.       /** @private */
  3698.       _this.mediaContainer = _this.container;
  3699.     } else if (typeof _this.params.mediaContainer == 'string') {
  3700.       /** @private */
  3701.       _this.mediaContainer = document.querySelector(_this.params.mediaContainer);
  3702.     } else {
  3703.       /** @private */
  3704.       _this.mediaContainer = _this.params.mediaContainer;
  3705.     }
  3706.     if (!_this.mediaContainer) {
  3707.       throw new Error('Media Container element not found');
  3708.     }
  3709.     if (_this.params.maxCanvasWidth <= 1) {
  3710.       throw new Error('maxCanvasWidth must be greater than 1');
  3711.     } else if (_this.params.maxCanvasWidth % 2 == 1) {
  3712.       throw new Error('maxCanvasWidth must be an even number');
  3713.     }
  3714.     if (_this.params.rtl === true) {
  3715.       if (_this.params.vertical === true) {
  3716.         util.style(_this.container, {
  3717.           transform: 'rotateX(180deg)'
  3718.         });
  3719.       } else {
  3720.         util.style(_this.container, {
  3721.           transform: 'rotateY(180deg)'
  3722.         });
  3723.       }
  3724.     }
  3725.     if (_this.params.backgroundColor) {
  3726.       _this.setBackgroundColor(_this.params.backgroundColor);
  3727.     }
  3728.  
  3729.     /**
  3730.      * @private Used to save the current volume when muting so we can
  3731.      * restore once unmuted
  3732.      * @type {number}
  3733.      */
  3734.     _this.savedVolume = 0;
  3735.  
  3736.     /**
  3737.      * @private The current muted state
  3738.      * @type {boolean}
  3739.      */
  3740.     _this.isMuted = false;
  3741.  
  3742.     /**
  3743.      * @private Will hold a list of event descriptors that need to be
  3744.      * canceled on subsequent loads of audio
  3745.      * @type {Object[]}
  3746.      */
  3747.     _this.tmpEvents = [];
  3748.  
  3749.     /**
  3750.      * @private Holds any running audio downloads
  3751.      * @type {Observer}
  3752.      */
  3753.     _this.currentRequest = null;
  3754.     /** @private */
  3755.     _this.arraybuffer = null;
  3756.     /** @private */
  3757.     _this.drawer = null;
  3758.     /** @private */
  3759.     _this.backend = null;
  3760.     /** @private */
  3761.     _this.peakCache = null;
  3762.  
  3763.     // cache constructor objects
  3764.     if (typeof _this.params.renderer !== 'function') {
  3765.       throw new Error('Renderer parameter is invalid');
  3766.     }
  3767.     /**
  3768.      * @private The uninitialised Drawer class
  3769.      */
  3770.     _this.Drawer = _this.params.renderer;
  3771.     /**
  3772.      * @private The uninitialised Backend class
  3773.      */
  3774.     // Back compat
  3775.     if (_this.params.backend == 'AudioElement') {
  3776.       _this.params.backend = 'MediaElement';
  3777.     }
  3778.     if ((_this.params.backend == 'WebAudio' || _this.params.backend === 'MediaElementWebAudio') && !_webaudio.default.prototype.supportsWebAudio.call(null)) {
  3779.       _this.params.backend = 'MediaElement';
  3780.     }
  3781.     _this.Backend = _this.backends[_this.params.backend];
  3782.  
  3783.     /**
  3784.      * @private map of plugin names that are currently initialised
  3785.      */
  3786.     _this.initialisedPluginList = {};
  3787.     /** @private */
  3788.     _this.isDestroyed = false;
  3789.  
  3790.     /**
  3791.      * Get the current ready status.
  3792.      *
  3793.      * @example const isReady = wavesurfer.isReady;
  3794.      * @return {boolean}
  3795.      */
  3796.     _this.isReady = false;
  3797.  
  3798.     // responsive debounced event listener. If this.params.responsive is not
  3799.     // set, this is never called. Use 100ms or this.params.responsive as
  3800.     // timeout for the debounce function.
  3801.     var prevWidth = 0;
  3802.     _this._onResize = util.debounce(function () {
  3803.       if (_this.drawer.wrapper && prevWidth != _this.drawer.wrapper.clientWidth && !_this.params.scrollParent) {
  3804.         prevWidth = _this.drawer.wrapper.clientWidth;
  3805.         if (prevWidth) {
  3806.           // redraw only if waveform container is rendered and has a width
  3807.           _this.drawer.fireEvent('redraw');
  3808.         }
  3809.       }
  3810.     }, typeof _this.params.responsive === 'number' ? _this.params.responsive : 100);
  3811.     return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
  3812.   }
  3813.  
  3814.   /**
  3815.    * Initialise the wave
  3816.    *
  3817.    * @example
  3818.    * var wavesurfer = new WaveSurfer(params);
  3819.    * wavesurfer.init();
  3820.    * @return {this} The wavesurfer instance
  3821.    */
  3822.   _createClass(WaveSurfer, [{
  3823.     key: "init",
  3824.     value: function init() {
  3825.       this.registerPlugins(this.params.plugins);
  3826.       this.createDrawer();
  3827.       this.createBackend();
  3828.       this.createPeakCache();
  3829.       return this;
  3830.     }
  3831.  
  3832.     /**
  3833.      * Add and initialise array of plugins (if `plugin.deferInit` is falsey),
  3834.      * this function is called in the init function of wavesurfer
  3835.      *
  3836.      * @param {PluginDefinition[]} plugins An array of plugin definitions
  3837.      * @emits {WaveSurfer#plugins-registered} Called with the array of plugin definitions
  3838.      * @return {this} The wavesurfer instance
  3839.      */
  3840.   }, {
  3841.     key: "registerPlugins",
  3842.     value: function registerPlugins(plugins) {
  3843.       var _this2 = this;
  3844.       // first instantiate all the plugins
  3845.       plugins.forEach(function (plugin) {
  3846.         return _this2.addPlugin(plugin);
  3847.       });
  3848.  
  3849.       // now run the init functions
  3850.       plugins.forEach(function (plugin) {
  3851.         // call init function of the plugin if deferInit is falsey
  3852.         // in that case you would manually use initPlugins()
  3853.         if (!plugin.deferInit) {
  3854.           _this2.initPlugin(plugin.name);
  3855.         }
  3856.       });
  3857.       this.fireEvent('plugins-registered', plugins);
  3858.       return this;
  3859.     }
  3860.  
  3861.     /**
  3862.      * Get a map of plugin names that are currently initialised
  3863.      *
  3864.      * @example wavesurfer.getPlugins();
  3865.      * @return {Object} Object with plugin names
  3866.      */
  3867.   }, {
  3868.     key: "getActivePlugins",
  3869.     value: function getActivePlugins() {
  3870.       return this.initialisedPluginList;
  3871.     }
  3872.  
  3873.     /**
  3874.      * Add a plugin object to wavesurfer
  3875.      *
  3876.      * @param {PluginDefinition} plugin A plugin definition
  3877.      * @emits {WaveSurfer#plugin-added} Called with the name of the plugin that was added
  3878.      * @example wavesurfer.addPlugin(WaveSurfer.minimap());
  3879.      * @return {this} The wavesurfer instance
  3880.      */
  3881.   }, {
  3882.     key: "addPlugin",
  3883.     value: function addPlugin(plugin) {
  3884.       var _this3 = this;
  3885.       if (!plugin.name) {
  3886.         throw new Error('Plugin does not have a name!');
  3887.       }
  3888.       if (!plugin.instance) {
  3889.         throw new Error("Plugin ".concat(plugin.name, " does not have an instance property!"));
  3890.       }
  3891.  
  3892.       // staticProps properties are applied to wavesurfer instance
  3893.       if (plugin.staticProps) {
  3894.         Object.keys(plugin.staticProps).forEach(function (pluginStaticProp) {
  3895.           /**
  3896.            * Properties defined in a plugin definition's `staticProps` property are added as
  3897.            * staticProps properties of the WaveSurfer instance
  3898.            */
  3899.           _this3[pluginStaticProp] = plugin.staticProps[pluginStaticProp];
  3900.         });
  3901.       }
  3902.       var Instance = plugin.instance;
  3903.  
  3904.       // turn the plugin instance into an observer
  3905.       var observerPrototypeKeys = Object.getOwnPropertyNames(util.Observer.prototype);
  3906.       observerPrototypeKeys.forEach(function (key) {
  3907.         Instance.prototype[key] = util.Observer.prototype[key];
  3908.       });
  3909.  
  3910.       /**
  3911.        * Instantiated plugin classes are added as a property of the wavesurfer
  3912.        * instance
  3913.        * @type {Object}
  3914.        */
  3915.       this[plugin.name] = new Instance(plugin.params || {}, this);
  3916.       this.fireEvent('plugin-added', plugin.name);
  3917.       return this;
  3918.     }
  3919.  
  3920.     /**
  3921.      * Initialise a plugin
  3922.      *
  3923.      * @param {string} name A plugin name
  3924.      * @emits WaveSurfer#plugin-initialised
  3925.      * @example wavesurfer.initPlugin('minimap');
  3926.      * @return {this} The wavesurfer instance
  3927.      */
  3928.   }, {
  3929.     key: "initPlugin",
  3930.     value: function initPlugin(name) {
  3931.       if (!this[name]) {
  3932.         throw new Error("Plugin ".concat(name, " has not been added yet!"));
  3933.       }
  3934.       if (this.initialisedPluginList[name]) {
  3935.         // destroy any already initialised plugins
  3936.         this.destroyPlugin(name);
  3937.       }
  3938.       this[name].init();
  3939.       this.initialisedPluginList[name] = true;
  3940.       this.fireEvent('plugin-initialised', name);
  3941.       return this;
  3942.     }
  3943.  
  3944.     /**
  3945.      * Destroy a plugin
  3946.      *
  3947.      * @param {string} name A plugin name
  3948.      * @emits WaveSurfer#plugin-destroyed
  3949.      * @example wavesurfer.destroyPlugin('minimap');
  3950.      * @returns {this} The wavesurfer instance
  3951.      */
  3952.   }, {
  3953.     key: "destroyPlugin",
  3954.     value: function destroyPlugin(name) {
  3955.       if (!this[name]) {
  3956.         throw new Error("Plugin ".concat(name, " has not been added yet and cannot be destroyed!"));
  3957.       }
  3958.       if (!this.initialisedPluginList[name]) {
  3959.         throw new Error("Plugin ".concat(name, " is not active and cannot be destroyed!"));
  3960.       }
  3961.       if (typeof this[name].destroy !== 'function') {
  3962.         throw new Error("Plugin ".concat(name, " does not have a destroy function!"));
  3963.       }
  3964.       this[name].destroy();
  3965.       delete this.initialisedPluginList[name];
  3966.       this.fireEvent('plugin-destroyed', name);
  3967.       return this;
  3968.     }
  3969.  
  3970.     /**
  3971.      * Destroy all initialised plugins. Convenience function to use when
  3972.      * wavesurfer is removed
  3973.      *
  3974.      * @private
  3975.      */
  3976.   }, {
  3977.     key: "destroyAllPlugins",
  3978.     value: function destroyAllPlugins() {
  3979.       var _this4 = this;
  3980.       Object.keys(this.initialisedPluginList).forEach(function (name) {
  3981.         return _this4.destroyPlugin(name);
  3982.       });
  3983.     }
  3984.  
  3985.     /**
  3986.      * Create the drawer and draw the waveform
  3987.      *
  3988.      * @private
  3989.      * @emits WaveSurfer#drawer-created
  3990.      */
  3991.   }, {
  3992.     key: "createDrawer",
  3993.     value: function createDrawer() {
  3994.       var _this5 = this;
  3995.       this.drawer = new this.Drawer(this.container, this.params);
  3996.       this.drawer.init();
  3997.       this.fireEvent('drawer-created', this.drawer);
  3998.       if (this.params.responsive !== false) {
  3999.         window.addEventListener('resize', this._onResize, true);
  4000.         window.addEventListener('orientationchange', this._onResize, true);
  4001.       }
  4002.       this.drawer.on('redraw', function () {
  4003.         _this5.drawBuffer();
  4004.         _this5.drawer.progress(_this5.backend.getPlayedPercents());
  4005.       });
  4006.  
  4007.       // Click-to-seek
  4008.       this.drawer.on('click', function (e, progress) {
  4009.         setTimeout(function () {
  4010.           return _this5.seekTo(progress);
  4011.         }, 0);
  4012.       });
  4013.  
  4014.       // Relay the scroll event from the drawer
  4015.       this.drawer.on('scroll', function (e) {
  4016.         if (_this5.params.partialRender) {
  4017.           _this5.drawBuffer();
  4018.         }
  4019.         _this5.fireEvent('scroll', e);
  4020.       });
  4021.  
  4022.       // Relay the dblclick event from the drawer
  4023.       this.drawer.on('dblclick', function (e, progress) {
  4024.         _this5.fireEvent('dblclick', e, progress);
  4025.       });
  4026.     }
  4027.  
  4028.     /**
  4029.      * Create the backend
  4030.      *
  4031.      * @private
  4032.      * @emits WaveSurfer#backend-created
  4033.      */
  4034.   }, {
  4035.     key: "createBackend",
  4036.     value: function createBackend() {
  4037.       var _this6 = this;
  4038.       if (this.backend) {
  4039.         this.backend.destroy();
  4040.       }
  4041.       this.backend = new this.Backend(this.params);
  4042.       this.backend.init();
  4043.       this.fireEvent('backend-created', this.backend);
  4044.       this.backend.on('finish', function () {
  4045.         _this6.drawer.progress(_this6.backend.getPlayedPercents());
  4046.         _this6.fireEvent('finish');
  4047.       });
  4048.       this.backend.on('play', function () {
  4049.         return _this6.fireEvent('play');
  4050.       });
  4051.       this.backend.on('pause', function () {
  4052.         return _this6.fireEvent('pause');
  4053.       });
  4054.       this.backend.on('audioprocess', function (time) {
  4055.         _this6.drawer.progress(_this6.backend.getPlayedPercents());
  4056.         _this6.fireEvent('audioprocess', time);
  4057.       });
  4058.  
  4059.       // only needed for MediaElement and MediaElementWebAudio backend
  4060.       if (this.params.backend === 'MediaElement' || this.params.backend === 'MediaElementWebAudio') {
  4061.         this.backend.on('seek', function () {
  4062.           _this6.drawer.progress(_this6.backend.getPlayedPercents());
  4063.         });
  4064.         this.backend.on('volume', function () {
  4065.           var newVolume = _this6.getVolume();
  4066.           _this6.fireEvent('volume', newVolume);
  4067.           if (_this6.backend.isMuted !== _this6.isMuted) {
  4068.             _this6.isMuted = _this6.backend.isMuted;
  4069.             _this6.fireEvent('mute', _this6.isMuted);
  4070.           }
  4071.         });
  4072.       }
  4073.     }
  4074.  
  4075.     /**
  4076.      * Create the peak cache
  4077.      *
  4078.      * @private
  4079.      */
  4080.   }, {
  4081.     key: "createPeakCache",
  4082.     value: function createPeakCache() {
  4083.       if (this.params.partialRender) {
  4084.         this.peakCache = new _peakcache.default();
  4085.       }
  4086.     }
  4087.  
  4088.     /**
  4089.      * Get the duration of the audio clip
  4090.      *
  4091.      * @example const duration = wavesurfer.getDuration();
  4092.      * @return {number} Duration in seconds
  4093.      */
  4094.   }, {
  4095.     key: "getDuration",
  4096.     value: function getDuration() {
  4097.       return this.backend.getDuration();
  4098.     }
  4099.  
  4100.     /**
  4101.      * Get the current playback position
  4102.      *
  4103.      * @example const currentTime = wavesurfer.getCurrentTime();
  4104.      * @return {number} Playback position in seconds
  4105.      */
  4106.   }, {
  4107.     key: "getCurrentTime",
  4108.     value: function getCurrentTime() {
  4109.       return this.backend.getCurrentTime();
  4110.     }
  4111.  
  4112.     /**
  4113.      * Set the current play time in seconds.
  4114.      *
  4115.      * @param {number} seconds A positive number in seconds. E.g. 10 means 10
  4116.      * seconds, 60 means 1 minute
  4117.      */
  4118.   }, {
  4119.     key: "setCurrentTime",
  4120.     value: function setCurrentTime(seconds) {
  4121.       if (seconds >= this.getDuration()) {
  4122.         this.seekTo(1);
  4123.       } else {
  4124.         this.seekTo(seconds / this.getDuration());
  4125.       }
  4126.     }
  4127.  
  4128.     /**
  4129.      * Starts playback from the current position. Optional start and end
  4130.      * measured in seconds can be used to set the range of audio to play.
  4131.      *
  4132.      * @param {?number} start Position to start at
  4133.      * @param {?number} end Position to end at
  4134.      * @emits WaveSurfer#interaction
  4135.      * @return {Promise} Result of the backend play method
  4136.      * @example
  4137.      * // play from second 1 to 5
  4138.      * wavesurfer.play(1, 5);
  4139.      */
  4140.   }, {
  4141.     key: "play",
  4142.     value: function play(start, end) {
  4143.       var _this7 = this;
  4144.       if (this.params.ignoreSilenceMode) {
  4145.         // ignores device hardware silence mode
  4146.         util.ignoreSilenceMode();
  4147.       }
  4148.       this.fireEvent('interaction', function () {
  4149.         return _this7.play(start, end);
  4150.       });
  4151.       return this.backend.play(start, end);
  4152.     }
  4153.  
  4154.     /**
  4155.      * Set a point in seconds for playback to stop at.
  4156.      *
  4157.      * @param {number} position Position (in seconds) to stop at
  4158.      * @version 3.3.0
  4159.      */
  4160.   }, {
  4161.     key: "setPlayEnd",
  4162.     value: function setPlayEnd(position) {
  4163.       this.backend.setPlayEnd(position);
  4164.     }
  4165.  
  4166.     /**
  4167.      * Stops and pauses playback
  4168.      *
  4169.      * @example wavesurfer.pause();
  4170.      * @return {Promise} Result of the backend pause method
  4171.      */
  4172.   }, {
  4173.     key: "pause",
  4174.     value: function pause() {
  4175.       if (!this.backend.isPaused()) {
  4176.         return this.backend.pause();
  4177.       }
  4178.     }
  4179.  
  4180.     /**
  4181.      * Toggle playback
  4182.      *
  4183.      * @example wavesurfer.playPause();
  4184.      * @return {Promise} Result of the backend play or pause method
  4185.      */
  4186.   }, {
  4187.     key: "playPause",
  4188.     value: function playPause() {
  4189.       return this.backend.isPaused() ? this.play() : this.pause();
  4190.     }
  4191.  
  4192.     /**
  4193.      * Get the current playback state
  4194.      *
  4195.      * @example const isPlaying = wavesurfer.isPlaying();
  4196.      * @return {boolean} False if paused, true if playing
  4197.      */
  4198.   }, {
  4199.     key: "isPlaying",
  4200.     value: function isPlaying() {
  4201.       return !this.backend.isPaused();
  4202.     }
  4203.  
  4204.     /**
  4205.      * Skip backward
  4206.      *
  4207.      * @param {?number} seconds Amount to skip back, if not specified `skipLength`
  4208.      * is used
  4209.      * @example wavesurfer.skipBackward();
  4210.      */
  4211.   }, {
  4212.     key: "skipBackward",
  4213.     value: function skipBackward(seconds) {
  4214.       this.skip(-seconds || -this.params.skipLength);
  4215.     }
  4216.  
  4217.     /**
  4218.      * Skip forward
  4219.      *
  4220.      * @param {?number} seconds Amount to skip back, if not specified `skipLength`
  4221.      * is used
  4222.      * @example wavesurfer.skipForward();
  4223.      */
  4224.   }, {
  4225.     key: "skipForward",
  4226.     value: function skipForward(seconds) {
  4227.       this.skip(seconds || this.params.skipLength);
  4228.     }
  4229.  
  4230.     /**
  4231.      * Skip a number of seconds from the current position (use a negative value
  4232.      * to go backwards).
  4233.      *
  4234.      * @param {number} offset Amount to skip back or forwards
  4235.      * @example
  4236.      * // go back 2 seconds
  4237.      * wavesurfer.skip(-2);
  4238.      */
  4239.   }, {
  4240.     key: "skip",
  4241.     value: function skip(offset) {
  4242.       var duration = this.getDuration() || 1;
  4243.       var position = this.getCurrentTime() || 0;
  4244.       position = Math.max(0, Math.min(duration, position + (offset || 0)));
  4245.       this.seekAndCenter(position / duration);
  4246.     }
  4247.  
  4248.     /**
  4249.      * Seeks to a position and centers the view
  4250.      *
  4251.      * @param {number} progress Between 0 (=beginning) and 1 (=end)
  4252.      * @example
  4253.      * // seek and go to the middle of the audio
  4254.      * wavesurfer.seekTo(0.5);
  4255.      */
  4256.   }, {
  4257.     key: "seekAndCenter",
  4258.     value: function seekAndCenter(progress) {
  4259.       this.seekTo(progress);
  4260.       this.drawer.recenter(progress);
  4261.     }
  4262.  
  4263.     /**
  4264.      * Seeks to a position
  4265.      *
  4266.      * @param {number} progress Between 0 (=beginning) and 1 (=end)
  4267.      * @emits WaveSurfer#interaction
  4268.      * @emits WaveSurfer#seek
  4269.      * @example
  4270.      * // seek to the middle of the audio
  4271.      * wavesurfer.seekTo(0.5);
  4272.      */
  4273.   }, {
  4274.     key: "seekTo",
  4275.     value: function seekTo(progress) {
  4276.       var _this8 = this;
  4277.       // return an error if progress is not a number between 0 and 1
  4278.       if (typeof progress !== 'number' || !isFinite(progress) || progress < 0 || progress > 1) {
  4279.         throw new Error('Error calling wavesurfer.seekTo, parameter must be a number between 0 and 1!');
  4280.       }
  4281.       this.fireEvent('interaction', function () {
  4282.         return _this8.seekTo(progress);
  4283.       });
  4284.       var isWebAudioBackend = this.params.backend === 'WebAudio';
  4285.       var paused = this.backend.isPaused();
  4286.       if (isWebAudioBackend && !paused) {
  4287.         this.backend.pause();
  4288.       }
  4289.  
  4290.       // avoid small scrolls while paused seeking
  4291.       var oldScrollParent = this.params.scrollParent;
  4292.       this.params.scrollParent = false;
  4293.       this.backend.seekTo(progress * this.getDuration());
  4294.       this.drawer.progress(progress);
  4295.       if (isWebAudioBackend && !paused) {
  4296.         this.backend.play();
  4297.       }
  4298.       this.params.scrollParent = oldScrollParent;
  4299.       this.fireEvent('seek', progress);
  4300.     }
  4301.  
  4302.     /**
  4303.      * Stops and goes to the beginning.
  4304.      *
  4305.      * @example wavesurfer.stop();
  4306.      */
  4307.   }, {
  4308.     key: "stop",
  4309.     value: function stop() {
  4310.       this.pause();
  4311.       this.seekTo(0);
  4312.       this.drawer.progress(0);
  4313.     }
  4314.  
  4315.     /**
  4316.      * Sets the ID of the audio device to use for output and returns a Promise.
  4317.      *
  4318.      * @param {string} deviceId String value representing underlying output
  4319.      * device
  4320.      * @returns {Promise} `Promise` that resolves to `undefined` when there are
  4321.      * no errors detected.
  4322.      */
  4323.   }, {
  4324.     key: "setSinkId",
  4325.     value: function setSinkId(deviceId) {
  4326.       return this.backend.setSinkId(deviceId);
  4327.     }
  4328.  
  4329.     /**
  4330.      * Set the playback volume.
  4331.      *
  4332.      * @param {number} newVolume A value between 0 and 1, 0 being no
  4333.      * volume and 1 being full volume.
  4334.      * @emits WaveSurfer#volume
  4335.      */
  4336.   }, {
  4337.     key: "setVolume",
  4338.     value: function setVolume(newVolume) {
  4339.       if (this.isMuted === true) {
  4340.         this.savedVolume = newVolume;
  4341.         return;
  4342.       }
  4343.       this.backend.setVolume(newVolume);
  4344.       this.fireEvent('volume', newVolume);
  4345.     }
  4346.  
  4347.     /**
  4348.      * Get the playback volume.
  4349.      *
  4350.      * @return {number} A value between 0 and 1, 0 being no
  4351.      * volume and 1 being full volume.
  4352.      */
  4353.   }, {
  4354.     key: "getVolume",
  4355.     value: function getVolume() {
  4356.       return this.backend.getVolume();
  4357.     }
  4358.  
  4359.     /**
  4360.      * Set the playback rate.
  4361.      *
  4362.      * @param {number} rate A positive number. E.g. 0.5 means half the normal
  4363.      * speed, 2 means double speed and so on.
  4364.      * @example wavesurfer.setPlaybackRate(2);
  4365.      */
  4366.   }, {
  4367.     key: "setPlaybackRate",
  4368.     value: function setPlaybackRate(rate) {
  4369.       this.backend.setPlaybackRate(rate);
  4370.     }
  4371.  
  4372.     /**
  4373.      * Get the playback rate.
  4374.      *
  4375.      * @return {number} The current playback rate.
  4376.      */
  4377.   }, {
  4378.     key: "getPlaybackRate",
  4379.     value: function getPlaybackRate() {
  4380.       return this.backend.getPlaybackRate();
  4381.     }
  4382.  
  4383.     /**
  4384.      * Toggle the volume on and off. If not currently muted it will save the
  4385.      * current volume value and turn the volume off. If currently muted then it
  4386.      * will restore the volume to the saved value, and then rest the saved
  4387.      * value.
  4388.      *
  4389.      * @example wavesurfer.toggleMute();
  4390.      */
  4391.   }, {
  4392.     key: "toggleMute",
  4393.     value: function toggleMute() {
  4394.       this.setMute(!this.isMuted);
  4395.     }
  4396.  
  4397.     /**
  4398.      * Enable or disable muted audio
  4399.      *
  4400.      * @param {boolean} mute Specify `true` to mute audio.
  4401.      * @emits WaveSurfer#volume
  4402.      * @emits WaveSurfer#mute
  4403.      * @example
  4404.      * // unmute
  4405.      * wavesurfer.setMute(false);
  4406.      * console.log(wavesurfer.getMute()) // logs false
  4407.      */
  4408.   }, {
  4409.     key: "setMute",
  4410.     value: function setMute(mute) {
  4411.       // ignore all muting requests if the audio is already in that state
  4412.       if (mute === this.isMuted) {
  4413.         this.fireEvent('mute', this.isMuted);
  4414.         return;
  4415.       }
  4416.       if (this.backend.setMute) {
  4417.         // Backends such as the MediaElement backend have their own handling
  4418.         // of mute, let them handle it.
  4419.         this.backend.setMute(mute);
  4420.         this.isMuted = mute;
  4421.       } else {
  4422.         if (mute) {
  4423.           // If currently not muted then save current volume,
  4424.           // turn off the volume and update the mute properties
  4425.           this.savedVolume = this.backend.getVolume();
  4426.           this.backend.setVolume(0);
  4427.           this.isMuted = true;
  4428.           this.fireEvent('volume', 0);
  4429.         } else {
  4430.           // If currently muted then restore to the saved volume
  4431.           // and update the mute properties
  4432.           this.backend.setVolume(this.savedVolume);
  4433.           this.isMuted = false;
  4434.           this.fireEvent('volume', this.savedVolume);
  4435.         }
  4436.       }
  4437.       this.fireEvent('mute', this.isMuted);
  4438.     }
  4439.  
  4440.     /**
  4441.      * Get the current mute status.
  4442.      *
  4443.      * @example const isMuted = wavesurfer.getMute();
  4444.      * @return {boolean} Current mute status
  4445.      */
  4446.   }, {
  4447.     key: "getMute",
  4448.     value: function getMute() {
  4449.       return this.isMuted;
  4450.     }
  4451.  
  4452.     /**
  4453.      * Get the list of current set filters as an array.
  4454.      *
  4455.      * Filters must be set with setFilters method first
  4456.      *
  4457.      * @return {array} List of enabled filters
  4458.      */
  4459.   }, {
  4460.     key: "getFilters",
  4461.     value: function getFilters() {
  4462.       return this.backend.filters || [];
  4463.     }
  4464.  
  4465.     /**
  4466.      * Toggles `scrollParent` and redraws
  4467.      *
  4468.      * @example wavesurfer.toggleScroll();
  4469.      */
  4470.   }, {
  4471.     key: "toggleScroll",
  4472.     value: function toggleScroll() {
  4473.       this.params.scrollParent = !this.params.scrollParent;
  4474.       this.drawBuffer();
  4475.     }
  4476.  
  4477.     /**
  4478.      * Toggle mouse interaction
  4479.      *
  4480.      * @example wavesurfer.toggleInteraction();
  4481.      */
  4482.   }, {
  4483.     key: "toggleInteraction",
  4484.     value: function toggleInteraction() {
  4485.       this.params.interact = !this.params.interact;
  4486.     }
  4487.  
  4488.     /**
  4489.      * Get the fill color of the waveform after the cursor.
  4490.      *
  4491.      * @param {?number} channelIdx Optional index of the channel to get its wave color if splitChannels is true
  4492.      * @return {string|object} A CSS color string, or an array of CSS color strings.
  4493.      */
  4494.   }, {
  4495.     key: "getWaveColor",
  4496.     value: function getWaveColor() {
  4497.       var channelIdx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4498.       if (this.params.splitChannelsOptions.channelColors[channelIdx]) {
  4499.         return this.params.splitChannelsOptions.channelColors[channelIdx].waveColor;
  4500.       }
  4501.       return this.params.waveColor;
  4502.     }
  4503.  
  4504.     /**
  4505.      * Set the fill color of the waveform after the cursor.
  4506.      *
  4507.      * @param {string|object} color A CSS color string, or an array of CSS color strings.
  4508.      * @param {?number} channelIdx Optional index of the channel to set its wave color if splitChannels is true
  4509.      * @example wavesurfer.setWaveColor('#ddd');
  4510.      */
  4511.   }, {
  4512.     key: "setWaveColor",
  4513.     value: function setWaveColor(color) {
  4514.       var channelIdx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4515.       if (this.params.splitChannelsOptions.channelColors[channelIdx]) {
  4516.         this.params.splitChannelsOptions.channelColors[channelIdx].waveColor = color;
  4517.       } else {
  4518.         this.params.waveColor = color;
  4519.       }
  4520.       this.drawBuffer();
  4521.     }
  4522.  
  4523.     /**
  4524.      * Get the fill color of the waveform behind the cursor.
  4525.      *
  4526.      * @param {?number} channelIdx Optional index of the channel to get its progress color if splitChannels is true
  4527.      * @return {string|object} A CSS color string, or an array of CSS color strings.
  4528.      */
  4529.   }, {
  4530.     key: "getProgressColor",
  4531.     value: function getProgressColor() {
  4532.       var channelIdx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4533.       if (this.params.splitChannelsOptions.channelColors[channelIdx]) {
  4534.         return this.params.splitChannelsOptions.channelColors[channelIdx].progressColor;
  4535.       }
  4536.       return this.params.progressColor;
  4537.     }
  4538.  
  4539.     /**
  4540.      * Set the fill color of the waveform behind the cursor.
  4541.      *
  4542.      * @param {string|object} color A CSS color string, or an array of CSS color strings.
  4543.      * @param {?number} channelIdx Optional index of the channel to set its progress color if splitChannels is true
  4544.      * @example wavesurfer.setProgressColor('#400');
  4545.      */
  4546.   }, {
  4547.     key: "setProgressColor",
  4548.     value: function setProgressColor(color, channelIdx) {
  4549.       if (this.params.splitChannelsOptions.channelColors[channelIdx]) {
  4550.         this.params.splitChannelsOptions.channelColors[channelIdx].progressColor = color;
  4551.       } else {
  4552.         this.params.progressColor = color;
  4553.       }
  4554.       this.drawBuffer();
  4555.     }
  4556.  
  4557.     /**
  4558.      * Get the background color of the waveform container.
  4559.      *
  4560.      * @return {string} A CSS color string.
  4561.      */
  4562.   }, {
  4563.     key: "getBackgroundColor",
  4564.     value: function getBackgroundColor() {
  4565.       return this.params.backgroundColor;
  4566.     }
  4567.  
  4568.     /**
  4569.      * Set the background color of the waveform container.
  4570.      *
  4571.      * @param {string} color A CSS color string.
  4572.      * @example wavesurfer.setBackgroundColor('#FF00FF');
  4573.      */
  4574.   }, {
  4575.     key: "setBackgroundColor",
  4576.     value: function setBackgroundColor(color) {
  4577.       this.params.backgroundColor = color;
  4578.       util.style(this.container, {
  4579.         background: this.params.backgroundColor
  4580.       });
  4581.     }
  4582.  
  4583.     /**
  4584.      * Get the fill color of the cursor indicating the playhead
  4585.      * position.
  4586.      *
  4587.      * @return {string} A CSS color string.
  4588.      */
  4589.   }, {
  4590.     key: "getCursorColor",
  4591.     value: function getCursorColor() {
  4592.       return this.params.cursorColor;
  4593.     }
  4594.  
  4595.     /**
  4596.      * Set the fill color of the cursor indicating the playhead
  4597.      * position.
  4598.      *
  4599.      * @param {string} color A CSS color string.
  4600.      * @example wavesurfer.setCursorColor('#222');
  4601.      */
  4602.   }, {
  4603.     key: "setCursorColor",
  4604.     value: function setCursorColor(color) {
  4605.       this.params.cursorColor = color;
  4606.       this.drawer.updateCursor();
  4607.     }
  4608.  
  4609.     /**
  4610.      * Get the height of the waveform.
  4611.      *
  4612.      * @return {number} Height measured in pixels.
  4613.      */
  4614.   }, {
  4615.     key: "getHeight",
  4616.     value: function getHeight() {
  4617.       return this.params.height;
  4618.     }
  4619.  
  4620.     /**
  4621.      * Set the height of the waveform.
  4622.      *
  4623.      * @param {number} height Height measured in pixels.
  4624.      * @example wavesurfer.setHeight(200);
  4625.      */
  4626.   }, {
  4627.     key: "setHeight",
  4628.     value: function setHeight(height) {
  4629.       this.params.height = height;
  4630.       this.drawer.setHeight(height * this.params.pixelRatio);
  4631.       this.drawBuffer();
  4632.     }
  4633.  
  4634.     /**
  4635.      * Hide channels from being drawn on the waveform if splitting channels.
  4636.      *
  4637.      * For example, if we want to draw only the peaks for the right stereo channel:
  4638.      *
  4639.      * const wavesurfer = new WaveSurfer.create({...splitChannels: true});
  4640.      * wavesurfer.load('stereo_audio.mp3');
  4641.      *
  4642.      * wavesurfer.setFilteredChannel([0]); <-- hide left channel peaks.
  4643.      *
  4644.      * @param {array} channelIndices Channels to be filtered out from drawing.
  4645.      * @version 4.0.0
  4646.      */
  4647.   }, {
  4648.     key: "setFilteredChannels",
  4649.     value: function setFilteredChannels(channelIndices) {
  4650.       this.params.splitChannelsOptions.filterChannels = channelIndices;
  4651.       this.drawBuffer();
  4652.     }
  4653.  
  4654.     /**
  4655.      * Get the correct peaks for current wave view-port and render wave
  4656.      *
  4657.      * @private
  4658.      * @emits WaveSurfer#redraw
  4659.      */
  4660.   }, {
  4661.     key: "drawBuffer",
  4662.     value: function drawBuffer() {
  4663.       var nominalWidth = Math.round(this.getDuration() * this.params.minPxPerSec * this.params.pixelRatio);
  4664.       var parentWidth = this.drawer.getWidth();
  4665.       var width = nominalWidth;
  4666.       // always start at 0 after zooming for scrolling : issue redraw left part
  4667.       var start = 0;
  4668.       var end = Math.max(start + parentWidth, width);
  4669.       // Fill container
  4670.       if (this.params.fillParent && (!this.params.scrollParent || nominalWidth < parentWidth)) {
  4671.         width = parentWidth;
  4672.         start = 0;
  4673.         end = width;
  4674.       }
  4675.       var peaks;
  4676.       if (this.params.partialRender) {
  4677.         var newRanges = this.peakCache.addRangeToPeakCache(width, start, end);
  4678.         var i;
  4679.         for (i = 0; i < newRanges.length; i++) {
  4680.           peaks = this.backend.getPeaks(width, newRanges[i][0], newRanges[i][1]);
  4681.           this.drawer.drawPeaks(peaks, width, newRanges[i][0], newRanges[i][1]);
  4682.         }
  4683.       } else {
  4684.         peaks = this.backend.getPeaks(width, start, end);
  4685.         this.drawer.drawPeaks(peaks, width, start, end);
  4686.       }
  4687.       this.fireEvent('redraw', peaks, width);
  4688.     }
  4689.  
  4690.     /**
  4691.      * Horizontally zooms the waveform in and out. It also changes the parameter
  4692.      * `minPxPerSec` and enables the `scrollParent` option. Calling the function
  4693.      * with a falsey parameter will reset the zoom state.
  4694.      *
  4695.      * @param {?number} pxPerSec Number of horizontal pixels per second of
  4696.      * audio, if none is set the waveform returns to unzoomed state
  4697.      * @emits WaveSurfer#zoom
  4698.      * @example wavesurfer.zoom(20);
  4699.      */
  4700.   }, {
  4701.     key: "zoom",
  4702.     value: function zoom(pxPerSec) {
  4703.       if (!pxPerSec) {
  4704.         this.params.minPxPerSec = this.defaultParams.minPxPerSec;
  4705.         this.params.scrollParent = false;
  4706.       } else {
  4707.         this.params.minPxPerSec = pxPerSec;
  4708.         this.params.scrollParent = true;
  4709.       }
  4710.       this.drawBuffer();
  4711.       this.drawer.progress(this.backend.getPlayedPercents());
  4712.       this.drawer.recenter(this.getCurrentTime() / this.getDuration());
  4713.       this.fireEvent('zoom', pxPerSec);
  4714.     }
  4715.  
  4716.     /**
  4717.      * Decode buffer and load
  4718.      *
  4719.      * @private
  4720.      * @param {ArrayBuffer} arraybuffer Buffer to process
  4721.      */
  4722.   }, {
  4723.     key: "loadArrayBuffer",
  4724.     value: function loadArrayBuffer(arraybuffer) {
  4725.       var _this9 = this;
  4726.       this.decodeArrayBuffer(arraybuffer, function (data) {
  4727.         if (!_this9.isDestroyed) {
  4728.           _this9.loadDecodedBuffer(data);
  4729.         }
  4730.       });
  4731.     }
  4732.  
  4733.     /**
  4734.      * Directly load an externally decoded AudioBuffer
  4735.      *
  4736.      * @private
  4737.      * @param {AudioBuffer} buffer Buffer to process
  4738.      * @emits WaveSurfer#ready
  4739.      */
  4740.   }, {
  4741.     key: "loadDecodedBuffer",
  4742.     value: function loadDecodedBuffer(buffer) {
  4743.       this.backend.load(buffer);
  4744.       this.drawBuffer();
  4745.       this.isReady = true;
  4746.       this.fireEvent('ready');
  4747.     }
  4748.  
  4749.     /**
  4750.      * Loads audio data from a Blob or File object
  4751.      *
  4752.      * @param {Blob|File} blob Audio data
  4753.      * @example
  4754.      */
  4755.   }, {
  4756.     key: "loadBlob",
  4757.     value: function loadBlob(blob) {
  4758.       var _this10 = this;
  4759.       // Create file reader
  4760.       var reader = new FileReader();
  4761.       reader.addEventListener('progress', function (e) {
  4762.         return _this10.onProgress(e);
  4763.       });
  4764.       reader.addEventListener('load', function (e) {
  4765.         return _this10.loadArrayBuffer(e.target.result);
  4766.       });
  4767.       reader.addEventListener('error', function () {
  4768.         return _this10.fireEvent('error', 'Error reading file');
  4769.       });
  4770.       reader.readAsArrayBuffer(blob);
  4771.       this.empty();
  4772.     }
  4773.  
  4774.     /**
  4775.      * Loads audio and re-renders the waveform.
  4776.      *
  4777.      * @param {string|HTMLMediaElement} url The url of the audio file or the
  4778.      * audio element with the audio
  4779.      * @param {number[]|Number.<Array[]>} peaks Wavesurfer does not have to decode
  4780.      * the audio to render the waveform if this is specified
  4781.      * @param {?string} preload (Use with backend `MediaElement` and `MediaElementWebAudio`)
  4782.      * `'none'|'metadata'|'auto'` Preload attribute for the media element
  4783.      * @param {?number} duration The duration of the audio. This is used to
  4784.      * render the peaks data in the correct size for the audio duration (as
  4785.      * befits the current `minPxPerSec` and zoom value) without having to decode
  4786.      * the audio.
  4787.      * @returns {void}
  4788.      * @throws Will throw an error if the `url` argument is empty.
  4789.      * @example
  4790.      * // uses fetch or media element to load file (depending on backend)
  4791.      * wavesurfer.load('http://example.com/demo.wav');
  4792.      *
  4793.      * // setting preload attribute with media element backend and supplying
  4794.      * // peaks
  4795.      * wavesurfer.load(
  4796.      *   'http://example.com/demo.wav',
  4797.      *   [0.0218, 0.0183, 0.0165, 0.0198, 0.2137, 0.2888],
  4798.      *   true
  4799.      * );
  4800.      */
  4801.   }, {
  4802.     key: "load",
  4803.     value: function load(url, peaks, preload, duration) {
  4804.       if (!url) {
  4805.         throw new Error('url parameter cannot be empty');
  4806.       }
  4807.       this.empty();
  4808.       if (preload) {
  4809.         // check whether the preload attribute will be usable and if not log
  4810.         // a warning listing the reasons why not and nullify the variable
  4811.         var preloadIgnoreReasons = {
  4812.           "Preload is not 'auto', 'none' or 'metadata'": ['auto', 'metadata', 'none'].indexOf(preload) === -1,
  4813.           'Peaks are not provided': !peaks,
  4814.           "Backend is not of type 'MediaElement' or 'MediaElementWebAudio'": ['MediaElement', 'MediaElementWebAudio'].indexOf(this.params.backend) === -1,
  4815.           'Url is not of type string': typeof url !== 'string'
  4816.         };
  4817.         var activeReasons = Object.keys(preloadIgnoreReasons).filter(function (reason) {
  4818.           return preloadIgnoreReasons[reason];
  4819.         });
  4820.         if (activeReasons.length) {
  4821.           // eslint-disable-next-line no-console
  4822.           console.warn('Preload parameter of wavesurfer.load will be ignored because:\n\t- ' + activeReasons.join('\n\t- '));
  4823.           // stop invalid values from being used
  4824.           preload = null;
  4825.         }
  4826.       }
  4827.  
  4828.       // loadBuffer(url, peaks, duration) requires that url is a string
  4829.       // but users can pass in a HTMLMediaElement to WaveSurfer
  4830.       if (this.params.backend === 'WebAudio' && url instanceof HTMLMediaElement) {
  4831.         url = url.src;
  4832.       }
  4833.       switch (this.params.backend) {
  4834.         case 'WebAudio':
  4835.           return this.loadBuffer(url, peaks, duration);
  4836.         case 'MediaElement':
  4837.         case 'MediaElementWebAudio':
  4838.           return this.loadMediaElement(url, peaks, preload, duration);
  4839.       }
  4840.     }
  4841.  
  4842.     /**
  4843.      * Loads audio using Web Audio buffer backend.
  4844.      *
  4845.      * @private
  4846.      * @emits WaveSurfer#waveform-ready
  4847.      * @param {string} url URL of audio file
  4848.      * @param {number[]|Number.<Array[]>} peaks Peaks data
  4849.      * @param {?number} duration Optional duration of audio file
  4850.      * @returns {void}
  4851.      */
  4852.   }, {
  4853.     key: "loadBuffer",
  4854.     value: function loadBuffer(url, peaks, duration) {
  4855.       var _this11 = this;
  4856.       var load = function load(action) {
  4857.         if (action) {
  4858.           _this11.tmpEvents.push(_this11.once('ready', action));
  4859.         }
  4860.         return _this11.getArrayBuffer(url, function (data) {
  4861.           return _this11.loadArrayBuffer(data);
  4862.         });
  4863.       };
  4864.       if (peaks) {
  4865.         this.backend.setPeaks(peaks, duration);
  4866.         this.drawBuffer();
  4867.         this.fireEvent('waveform-ready');
  4868.         this.tmpEvents.push(this.once('interaction', load));
  4869.       } else {
  4870.         return load();
  4871.       }
  4872.     }
  4873.  
  4874.     /**
  4875.      * Either create a media element, or load an existing media element.
  4876.      *
  4877.      * @private
  4878.      * @emits WaveSurfer#waveform-ready
  4879.      * @param {string|HTMLMediaElement} urlOrElt Either a path to a media file, or an
  4880.      * existing HTML5 Audio/Video Element
  4881.      * @param {number[]|Number.<Array[]>} peaks Array of peaks. Required to bypass web audio
  4882.      * dependency
  4883.      * @param {?boolean} preload Set to true if the preload attribute of the
  4884.      * audio element should be enabled
  4885.      * @param {?number} duration Optional duration of audio file
  4886.      */
  4887.   }, {
  4888.     key: "loadMediaElement",
  4889.     value: function loadMediaElement(urlOrElt, peaks, preload, duration) {
  4890.       var _this12 = this;
  4891.       var url = urlOrElt;
  4892.       if (typeof urlOrElt === 'string') {
  4893.         this.backend.load(url, this.mediaContainer, peaks, preload);
  4894.       } else {
  4895.         var elt = urlOrElt;
  4896.         this.backend.loadElt(elt, peaks);
  4897.  
  4898.         // If peaks are not provided,
  4899.         // url = element.src so we can get peaks with web audio
  4900.         url = elt.src;
  4901.       }
  4902.       this.tmpEvents.push(this.backend.once('canplay', function () {
  4903.         // ignore when backend was already destroyed
  4904.         if (!_this12.backend.destroyed) {
  4905.           _this12.drawBuffer();
  4906.           _this12.isReady = true;
  4907.           _this12.fireEvent('ready');
  4908.         }
  4909.       }), this.backend.once('error', function (err) {
  4910.         return _this12.fireEvent('error', err);
  4911.       }));
  4912.  
  4913.       // If peaks are provided, render them and fire the `waveform-ready` event.
  4914.       if (peaks) {
  4915.         this.backend.setPeaks(peaks, duration);
  4916.         this.drawBuffer();
  4917.         this.fireEvent('waveform-ready');
  4918.       }
  4919.  
  4920.       // If no pre-decoded peaks are provided, or are provided with
  4921.       // forceDecode flag, attempt to download the audio file and decode it
  4922.       // with Web Audio.
  4923.       if ((!peaks || this.params.forceDecode) && this.backend.supportsWebAudio()) {
  4924.         this.getArrayBuffer(url, function (arraybuffer) {
  4925.           _this12.decodeArrayBuffer(arraybuffer, function (buffer) {
  4926.             _this12.backend.buffer = buffer;
  4927.             _this12.backend.setPeaks(null);
  4928.             _this12.drawBuffer();
  4929.             _this12.fireEvent('waveform-ready');
  4930.           });
  4931.         });
  4932.       }
  4933.     }
  4934.  
  4935.     /**
  4936.      * Decode an array buffer and pass data to a callback
  4937.      *
  4938.      * @private
  4939.      * @param {Object} arraybuffer The array buffer to decode
  4940.      * @param {function} callback The function to call on complete
  4941.      */
  4942.   }, {
  4943.     key: "decodeArrayBuffer",
  4944.     value: function decodeArrayBuffer(arraybuffer, callback) {
  4945.       var _this13 = this;
  4946.       if (!this.isDestroyed) {
  4947.         this.arraybuffer = arraybuffer;
  4948.         this.backend.decodeArrayBuffer(arraybuffer, function (data) {
  4949.           // Only use the decoded data if we haven't been destroyed or
  4950.           // another decode started in the meantime
  4951.           if (!_this13.isDestroyed && _this13.arraybuffer == arraybuffer) {
  4952.             callback(data);
  4953.             _this13.arraybuffer = null;
  4954.           }
  4955.         }, function () {
  4956.           return _this13.fireEvent('error', 'Error decoding audiobuffer');
  4957.         });
  4958.       }
  4959.     }
  4960.  
  4961.     /**
  4962.      * Load an array buffer using fetch and pass the result to a callback
  4963.      *
  4964.      * @param {string} url The URL of the file object
  4965.      * @param {function} callback The function to call on complete
  4966.      * @returns {util.fetchFile} fetch call
  4967.      * @private
  4968.      */
  4969.   }, {
  4970.     key: "getArrayBuffer",
  4971.     value: function getArrayBuffer(url, callback) {
  4972.       var _this14 = this;
  4973.       var options = Object.assign({
  4974.         url: url,
  4975.         responseType: 'arraybuffer'
  4976.       }, this.params.xhr);
  4977.       var request = util.fetchFile(options);
  4978.       this.currentRequest = request;
  4979.       this.tmpEvents.push(request.on('progress', function (e) {
  4980.         _this14.onProgress(e);
  4981.       }), request.on('success', function (data) {
  4982.         callback(data);
  4983.         _this14.currentRequest = null;
  4984.       }), request.on('error', function (e) {
  4985.         _this14.fireEvent('error', e);
  4986.         _this14.currentRequest = null;
  4987.       }));
  4988.       return request;
  4989.     }
  4990.  
  4991.     /**
  4992.      * Called while the audio file is loading
  4993.      *
  4994.      * @private
  4995.      * @param {Event} e Progress event
  4996.      * @emits WaveSurfer#loading
  4997.      */
  4998.   }, {
  4999.     key: "onProgress",
  5000.     value: function onProgress(e) {
  5001.       var percentComplete;
  5002.       if (e.lengthComputable) {
  5003.         percentComplete = e.loaded / e.total;
  5004.       } else {
  5005.         // Approximate progress with an asymptotic
  5006.         // function, and assume downloads in the 1-3 MB range.
  5007.         percentComplete = e.loaded / (e.loaded + 1000000);
  5008.       }
  5009.       this.fireEvent('loading', Math.round(percentComplete * 100), e.target);
  5010.     }
  5011.  
  5012.     /**
  5013.      * Exports PCM data into a JSON array and optionally opens in a new window
  5014.      * as valid JSON Blob instance.
  5015.      *
  5016.      * @param {number} length=1024 The scale in which to export the peaks
  5017.      * @param {number} accuracy=10000
  5018.      * @param {?boolean} noWindow Set to true to disable opening a new
  5019.      * window with the JSON
  5020.      * @param {number} start Start index
  5021.      * @param {number} end End index
  5022.      * @return {Promise} Promise that resolves with array of peaks
  5023.      */
  5024.   }, {
  5025.     key: "exportPCM",
  5026.     value: function exportPCM(length, accuracy, noWindow, start, end) {
  5027.       length = length || 1024;
  5028.       start = start || 0;
  5029.       accuracy = accuracy || 10000;
  5030.       noWindow = noWindow || false;
  5031.       var peaks = this.backend.getPeaks(length, start, end);
  5032.       var arr = [].map.call(peaks, function (val) {
  5033.         return Math.round(val * accuracy) / accuracy;
  5034.       });
  5035.       return new Promise(function (resolve, reject) {
  5036.         if (!noWindow) {
  5037.           var blobJSON = new Blob([JSON.stringify(arr)], {
  5038.             type: 'application/json;charset=utf-8'
  5039.           });
  5040.           var objURL = URL.createObjectURL(blobJSON);
  5041.           window.open(objURL);
  5042.           URL.revokeObjectURL(objURL);
  5043.         }
  5044.         resolve(arr);
  5045.       });
  5046.     }
  5047.  
  5048.     /**
  5049.      * Save waveform image as data URI.
  5050.      *
  5051.      * The default format is `image/png`. Other supported types are
  5052.      * `image/jpeg` and `image/webp`.
  5053.      *
  5054.      * @param {string} format='image/png' A string indicating the image format.
  5055.      * The default format type is `image/png`.
  5056.      * @param {number} quality=1 A number between 0 and 1 indicating the image
  5057.      * quality to use for image formats that use lossy compression such as
  5058.      * `image/jpeg` and `image/webp`.
  5059.      * @param {string} type Image data type to return. Either `dataURL` (default)
  5060.      * or `blob`.
  5061.      * @return {string|string[]|Promise} When using `dataURL` type this returns
  5062.      * a single data URL or an array of data URLs, one for each canvas. When using
  5063.      * `blob` type this returns a `Promise` resolving with an array of `Blob`
  5064.      * instances, one for each canvas.
  5065.      */
  5066.   }, {
  5067.     key: "exportImage",
  5068.     value: function exportImage(format, quality, type) {
  5069.       if (!format) {
  5070.         format = 'image/png';
  5071.       }
  5072.       if (!quality) {
  5073.         quality = 1;
  5074.       }
  5075.       if (!type) {
  5076.         type = 'dataURL';
  5077.       }
  5078.       return this.drawer.getImage(format, quality, type);
  5079.     }
  5080.  
  5081.     /**
  5082.      * Cancel any fetch request currently in progress
  5083.      */
  5084.   }, {
  5085.     key: "cancelAjax",
  5086.     value: function cancelAjax() {
  5087.       if (this.currentRequest && this.currentRequest.controller) {
  5088.         // If the current request has a ProgressHandler, then its ReadableStream might need to be cancelled too
  5089.         // See: Wavesurfer issue #2042
  5090.         // See Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1583815
  5091.         if (this.currentRequest._reader) {
  5092.           // Ignoring exceptions thrown by call to cancel()
  5093.           this.currentRequest._reader.cancel().catch(function (err) {});
  5094.         }
  5095.         this.currentRequest.controller.abort();
  5096.         this.currentRequest = null;
  5097.       }
  5098.     }
  5099.  
  5100.     /**
  5101.      * @private
  5102.      */
  5103.   }, {
  5104.     key: "clearTmpEvents",
  5105.     value: function clearTmpEvents() {
  5106.       this.tmpEvents.forEach(function (e) {
  5107.         return e.un();
  5108.       });
  5109.     }
  5110.  
  5111.     /**
  5112.      * Display empty waveform.
  5113.      */
  5114.   }, {
  5115.     key: "empty",
  5116.     value: function empty() {
  5117.       if (!this.backend.isPaused()) {
  5118.         this.stop();
  5119.         this.backend.disconnectSource();
  5120.       }
  5121.       this.isReady = false;
  5122.       this.cancelAjax();
  5123.       this.clearTmpEvents();
  5124.  
  5125.       // empty drawer
  5126.       this.drawer.progress(0);
  5127.       this.drawer.setWidth(0);
  5128.       this.drawer.drawPeaks({
  5129.         length: this.drawer.getWidth()
  5130.       }, 0);
  5131.     }
  5132.  
  5133.     /**
  5134.      * Remove events, elements and disconnect WebAudio nodes.
  5135.      *
  5136.      * @emits WaveSurfer#destroy
  5137.      */
  5138.   }, {
  5139.     key: "destroy",
  5140.     value: function destroy() {
  5141.       this.destroyAllPlugins();
  5142.       this.fireEvent('destroy');
  5143.       this.cancelAjax();
  5144.       this.clearTmpEvents();
  5145.       this.unAll();
  5146.       if (this.params.responsive !== false) {
  5147.         window.removeEventListener('resize', this._onResize, true);
  5148.         window.removeEventListener('orientationchange', this._onResize, true);
  5149.       }
  5150.       if (this.backend) {
  5151.         this.backend.destroy();
  5152.         // clears memory usage
  5153.         this.backend = null;
  5154.       }
  5155.       if (this.drawer) {
  5156.         this.drawer.destroy();
  5157.       }
  5158.       this.isDestroyed = true;
  5159.       this.isReady = false;
  5160.       this.arraybuffer = null;
  5161.     }
  5162.   }], [{
  5163.     key: "create",
  5164.     value:
  5165.     /**
  5166.      * Instantiate this class, call its `init` function and returns it
  5167.      *
  5168.      * @param {WavesurferParams} params The wavesurfer parameters
  5169.      * @return {Object} WaveSurfer instance
  5170.      * @example const wavesurfer = WaveSurfer.create(params);
  5171.      */
  5172.     function create(params) {
  5173.       var wavesurfer = new WaveSurfer(params);
  5174.       return wavesurfer.init();
  5175.     }
  5176.  
  5177.     /**
  5178.      * The library version number is available as a static property of the
  5179.      * WaveSurfer class
  5180.      *
  5181.      * @type {String}
  5182.      * @example
  5183.      * console.log('Using wavesurfer.js ' + WaveSurfer.VERSION);
  5184.      */
  5185.   }]);
  5186.   return WaveSurfer;
  5187. }(util.Observer);
  5188. exports["default"] = WaveSurfer;
  5189. _defineProperty(WaveSurfer, "VERSION", "6.6.4");
  5190. /**
  5191.  * Functions in the `util` property are available as a static property of the
  5192.  * WaveSurfer class
  5193.  *
  5194.  * @type {Object}
  5195.  * @example
  5196.  * WaveSurfer.util.style(myElement, { background: 'blue' });
  5197.  */
  5198. _defineProperty(WaveSurfer, "util", util);
  5199. module.exports = exports.default;
  5200.  
  5201. /***/ }),
  5202.  
  5203. /***/ "./src/webaudio.js":
  5204. /*!*************************!*\
  5205.   !*** ./src/webaudio.js ***!
  5206.   \*************************/
  5207. /***/ ((module, exports, __webpack_require__) => {
  5208.  
  5209. "use strict";
  5210.  
  5211.  
  5212. Object.defineProperty(exports, "__esModule", ({
  5213.   value: true
  5214. }));
  5215. exports["default"] = void 0;
  5216. var util = _interopRequireWildcard(__webpack_require__(/*! ./util */ "./src/util/index.js"));
  5217. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  5218. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  5219. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  5220. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5221. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  5222. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  5223. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
  5224. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  5225. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  5226. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
  5227. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  5228. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  5229. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  5230. function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  5231. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  5232. function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  5233. // using constants to prevent someone writing the string wrong
  5234. var PLAYING = 'playing';
  5235. var PAUSED = 'paused';
  5236. var FINISHED = 'finished';
  5237.  
  5238. /**
  5239.  * WebAudio backend
  5240.  *
  5241.  * @extends {util.Observer}
  5242.  */
  5243. var WebAudio = /*#__PURE__*/function (_util$Observer) {
  5244.   _inherits(WebAudio, _util$Observer);
  5245.   var _super = _createSuper(WebAudio);
  5246.   /**
  5247.    * Construct the backend
  5248.    *
  5249.    * @param {WavesurferParams} params Wavesurfer parameters
  5250.    */
  5251.   function WebAudio(params) {
  5252.     var _defineProperty2, _this$states;
  5253.     var _this;
  5254.     _classCallCheck(this, WebAudio);
  5255.     _this = _super.call(this);
  5256.     /** @private */
  5257.     /** audioContext: allows to process audio with WebAudio API */
  5258.     _defineProperty(_assertThisInitialized(_this), "audioContext", null);
  5259.     /** @private */
  5260.     _defineProperty(_assertThisInitialized(_this), "stateBehaviors", (_defineProperty2 = {}, _defineProperty(_defineProperty2, PLAYING, {
  5261.       init: function init() {
  5262.         this.addOnAudioProcess();
  5263.       },
  5264.       getPlayedPercents: function getPlayedPercents() {
  5265.         var duration = this.getDuration();
  5266.         return this.getCurrentTime() / duration || 0;
  5267.       },
  5268.       getCurrentTime: function getCurrentTime() {
  5269.         return this.startPosition + this.getPlayedTime();
  5270.       }
  5271.     }), _defineProperty(_defineProperty2, PAUSED, {
  5272.       init: function init() {},
  5273.       getPlayedPercents: function getPlayedPercents() {
  5274.         var duration = this.getDuration();
  5275.         return this.getCurrentTime() / duration || 0;
  5276.       },
  5277.       getCurrentTime: function getCurrentTime() {
  5278.         return this.startPosition;
  5279.       }
  5280.     }), _defineProperty(_defineProperty2, FINISHED, {
  5281.       init: function init() {
  5282.         this.fireEvent('finish');
  5283.       },
  5284.       getPlayedPercents: function getPlayedPercents() {
  5285.         return 1;
  5286.       },
  5287.       getCurrentTime: function getCurrentTime() {
  5288.         return this.getDuration();
  5289.       }
  5290.     }), _defineProperty2));
  5291.     _this.params = params;
  5292.     /** ac: Audio Context instance */
  5293.     _this.ac = params.audioContext || (_this.supportsWebAudio() ? _this.getAudioContext() : {});
  5294.     /**@private */
  5295.     _this.lastPlay = _this.ac.currentTime;
  5296.     /** @private */
  5297.     _this.startPosition = 0;
  5298.     /** @private */
  5299.     _this.scheduledPause = null;
  5300.     /** @private */
  5301.     _this.states = (_this$states = {}, _defineProperty(_this$states, PLAYING, Object.create(_this.stateBehaviors[PLAYING])), _defineProperty(_this$states, PAUSED, Object.create(_this.stateBehaviors[PAUSED])), _defineProperty(_this$states, FINISHED, Object.create(_this.stateBehaviors[FINISHED])), _this$states);
  5302.     /** @private */
  5303.     _this.buffer = null;
  5304.     /** @private */
  5305.     _this.filters = [];
  5306.     /** gainNode: allows to control audio volume */
  5307.     _this.gainNode = null;
  5308.     /** @private */
  5309.     _this.mergedPeaks = null;
  5310.     /** @private */
  5311.     _this.offlineAc = null;
  5312.     /** @private */
  5313.     _this.peaks = null;
  5314.     /** @private */
  5315.     _this.playbackRate = 1;
  5316.     /** analyser: provides audio analysis information */
  5317.     _this.analyser = null;
  5318.     /** scriptNode: allows processing audio */
  5319.     _this.scriptNode = null;
  5320.     /** @private */
  5321.     _this.source = null;
  5322.     /** @private */
  5323.     _this.splitPeaks = [];
  5324.     /** @private */
  5325.     _this.state = null;
  5326.     /** @private */
  5327.     _this.explicitDuration = params.duration;
  5328.     /** @private */
  5329.     _this.sinkStreamDestination = null;
  5330.     /** @private */
  5331.     _this.sinkAudioElement = null;
  5332.     /**
  5333.      * Boolean indicating if the backend was destroyed.
  5334.      */
  5335.     _this.destroyed = false;
  5336.     return _this;
  5337.   }
  5338.  
  5339.   /**
  5340.    * Initialise the backend, called in `wavesurfer.createBackend()`
  5341.    */
  5342.   _createClass(WebAudio, [{
  5343.     key: "supportsWebAudio",
  5344.     value:
  5345.     /**
  5346.      * Does the browser support this backend
  5347.      *
  5348.      * @return {boolean} Whether or not this browser supports this backend
  5349.      */
  5350.     function supportsWebAudio() {
  5351.       return !!(window.AudioContext || window.webkitAudioContext);
  5352.     }
  5353.  
  5354.     /**
  5355.      * Get the audio context used by this backend or create one
  5356.      *
  5357.      * @return {AudioContext} Existing audio context, or creates a new one
  5358.      */
  5359.   }, {
  5360.     key: "getAudioContext",
  5361.     value: function getAudioContext() {
  5362.       if (!window.WaveSurferAudioContext) {
  5363.         window.WaveSurferAudioContext = new (window.AudioContext || window.webkitAudioContext)();
  5364.       }
  5365.       return window.WaveSurferAudioContext;
  5366.     }
  5367.  
  5368.     /**
  5369.      * Get the offline audio context used by this backend or create one
  5370.      *
  5371.      * @param {number} sampleRate The sample rate to use
  5372.      * @return {OfflineAudioContext} Existing offline audio context, or creates
  5373.      * a new one
  5374.      */
  5375.   }, {
  5376.     key: "getOfflineAudioContext",
  5377.     value: function getOfflineAudioContext(sampleRate) {
  5378.       if (!window.WaveSurferOfflineAudioContext) {
  5379.         window.WaveSurferOfflineAudioContext = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 2, sampleRate);
  5380.       }
  5381.       return window.WaveSurferOfflineAudioContext;
  5382.     }
  5383.   }, {
  5384.     key: "init",
  5385.     value: function init() {
  5386.       this.createVolumeNode();
  5387.       this.createScriptNode();
  5388.       this.createAnalyserNode();
  5389.       this.setState(PAUSED);
  5390.       this.setPlaybackRate(this.params.audioRate);
  5391.       this.setLength(0);
  5392.     }
  5393.  
  5394.     /** @private */
  5395.   }, {
  5396.     key: "disconnectFilters",
  5397.     value: function disconnectFilters() {
  5398.       if (this.filters) {
  5399.         this.filters.forEach(function (filter) {
  5400.           filter && filter.disconnect();
  5401.         });
  5402.         this.filters = null;
  5403.         // Reconnect direct path
  5404.         this.analyser.connect(this.gainNode);
  5405.       }
  5406.     }
  5407.  
  5408.     /**
  5409.      * @private
  5410.      *
  5411.      * @param {string} state The new state
  5412.      */
  5413.   }, {
  5414.     key: "setState",
  5415.     value: function setState(state) {
  5416.       if (this.state !== this.states[state]) {
  5417.         this.state = this.states[state];
  5418.         this.state.init.call(this);
  5419.       }
  5420.     }
  5421.  
  5422.     /**
  5423.      * Unpacked `setFilters()`
  5424.      *
  5425.      * @param {...AudioNode} filters One or more filters to set
  5426.      */
  5427.   }, {
  5428.     key: "setFilter",
  5429.     value: function setFilter() {
  5430.       for (var _len = arguments.length, filters = new Array(_len), _key = 0; _key < _len; _key++) {
  5431.         filters[_key] = arguments[_key];
  5432.       }
  5433.       this.setFilters(filters);
  5434.     }
  5435.  
  5436.     /**
  5437.      * Insert custom Web Audio nodes into the graph
  5438.      *
  5439.      * @param {AudioNode[]} filters Packed filters array
  5440.      * @example
  5441.      * const lowpass = wavesurfer.backend.ac.createBiquadFilter();
  5442.      * wavesurfer.backend.setFilter(lowpass);
  5443.      */
  5444.   }, {
  5445.     key: "setFilters",
  5446.     value: function setFilters(filters) {
  5447.       // Remove existing filters
  5448.       this.disconnectFilters();
  5449.  
  5450.       // Insert filters if filter array not empty
  5451.       if (filters && filters.length) {
  5452.         this.filters = filters;
  5453.  
  5454.         // Disconnect direct path before inserting filters
  5455.         this.analyser.disconnect();
  5456.  
  5457.         // Connect each filter in turn
  5458.         filters.reduce(function (prev, curr) {
  5459.           prev.connect(curr);
  5460.           return curr;
  5461.         }, this.analyser).connect(this.gainNode);
  5462.       }
  5463.     }
  5464.     /** Create ScriptProcessorNode to process audio */
  5465.   }, {
  5466.     key: "createScriptNode",
  5467.     value: function createScriptNode() {
  5468.       if (this.params.audioScriptProcessor) {
  5469.         this.scriptNode = this.params.audioScriptProcessor;
  5470.         this.scriptNode.connect(this.ac.destination);
  5471.       }
  5472.     }
  5473.  
  5474.     /** @private */
  5475.   }, {
  5476.     key: "addOnAudioProcess",
  5477.     value: function addOnAudioProcess() {
  5478.       var _this2 = this;
  5479.       var loop = function loop() {
  5480.         var time = _this2.getCurrentTime();
  5481.         if (time >= _this2.getDuration() && _this2.state !== _this2.states[FINISHED]) {
  5482.           _this2.setState(FINISHED);
  5483.           _this2.fireEvent('pause');
  5484.         } else if (time >= _this2.scheduledPause && _this2.state !== _this2.states[PAUSED]) {
  5485.           _this2.pause();
  5486.         } else if (_this2.state === _this2.states[PLAYING]) {
  5487.           _this2.fireEvent('audioprocess', time);
  5488.           util.frame(loop)();
  5489.         }
  5490.       };
  5491.       loop();
  5492.     }
  5493.  
  5494.     /** Create analyser node to perform audio analysis */
  5495.   }, {
  5496.     key: "createAnalyserNode",
  5497.     value: function createAnalyserNode() {
  5498.       this.analyser = this.ac.createAnalyser();
  5499.       this.analyser.connect(this.gainNode);
  5500.     }
  5501.  
  5502.     /**
  5503.      * Create the gain node needed to control the playback volume.
  5504.      *
  5505.      */
  5506.   }, {
  5507.     key: "createVolumeNode",
  5508.     value: function createVolumeNode() {
  5509.       // Create gain node using the AudioContext
  5510.       if (this.ac.createGain) {
  5511.         this.gainNode = this.ac.createGain();
  5512.       } else {
  5513.         this.gainNode = this.ac.createGainNode();
  5514.       }
  5515.       // Add the gain node to the graph
  5516.       this.gainNode.connect(this.ac.destination);
  5517.     }
  5518.  
  5519.     /**
  5520.      * Set the sink id for the media player
  5521.      *
  5522.      * @param {string} deviceId String value representing audio device id.
  5523.      * @returns {Promise} A Promise that resolves to `undefined` when there
  5524.      * are no errors.
  5525.      */
  5526.   }, {
  5527.     key: "setSinkId",
  5528.     value: function setSinkId(deviceId) {
  5529.       if (deviceId) {
  5530.         /**
  5531.          * The webaudio API doesn't currently support setting the device
  5532.          * output. Here we create an HTMLAudioElement, connect the
  5533.          * webaudio stream to that element and setSinkId there.
  5534.          */
  5535.         if (!this.sinkAudioElement) {
  5536.           this.sinkAudioElement = new window.Audio();
  5537.           // autoplay is necessary since we're not invoking .play()
  5538.           this.sinkAudioElement.autoplay = true;
  5539.         }
  5540.         if (!this.sinkAudioElement.setSinkId) {
  5541.           return Promise.reject(new Error('setSinkId is not supported in your browser'));
  5542.         }
  5543.         if (!this.sinkStreamDestination) {
  5544.           this.sinkStreamDestination = this.ac.createMediaStreamDestination();
  5545.         }
  5546.         this.gainNode.disconnect();
  5547.         this.gainNode.connect(this.sinkStreamDestination);
  5548.         this.sinkAudioElement.srcObject = this.sinkStreamDestination.stream;
  5549.         return this.sinkAudioElement.setSinkId(deviceId);
  5550.       } else {
  5551.         return Promise.reject(new Error('Invalid deviceId: ' + deviceId));
  5552.       }
  5553.     }
  5554.  
  5555.     /**
  5556.      * Set the audio volume
  5557.      *
  5558.      * @param {number} value A floating point value between 0 and 1.
  5559.      */
  5560.   }, {
  5561.     key: "setVolume",
  5562.     value: function setVolume(value) {
  5563.       this.gainNode.gain.setValueAtTime(value, this.ac.currentTime);
  5564.     }
  5565.  
  5566.     /**
  5567.      * Get the current volume
  5568.      *
  5569.      * @return {number} value A floating point value between 0 and 1.
  5570.      */
  5571.   }, {
  5572.     key: "getVolume",
  5573.     value: function getVolume() {
  5574.       return this.gainNode.gain.value;
  5575.     }
  5576.  
  5577.     /**
  5578.      * Decode an array buffer and pass data to a callback
  5579.      *
  5580.      * @private
  5581.      * @param {ArrayBuffer} arraybuffer The array buffer to decode
  5582.      * @param {function} callback The function to call on complete.
  5583.      * @param {function} errback The function to call on error.
  5584.      */
  5585.   }, {
  5586.     key: "decodeArrayBuffer",
  5587.     value: function decodeArrayBuffer(arraybuffer, callback, errback) {
  5588.       if (!this.offlineAc) {
  5589.         this.offlineAc = this.getOfflineAudioContext(this.ac && this.ac.sampleRate ? this.ac.sampleRate : 44100);
  5590.       }
  5591.       if ('webkitAudioContext' in window) {
  5592.         // Safari: no support for Promise-based decodeAudioData enabled
  5593.         // Enable it in Safari using the Experimental Features > Modern WebAudio API option
  5594.         this.offlineAc.decodeAudioData(arraybuffer, function (data) {
  5595.           return callback(data);
  5596.         }, errback);
  5597.       } else {
  5598.         this.offlineAc.decodeAudioData(arraybuffer).then(function (data) {
  5599.           return callback(data);
  5600.         }).catch(function (err) {
  5601.           return errback(err);
  5602.         });
  5603.       }
  5604.     }
  5605.  
  5606.     /**
  5607.      * Set pre-decoded peaks
  5608.      *
  5609.      * @param {number[]|Number.<Array[]>} peaks Peaks data
  5610.      * @param {?number} duration Explicit duration
  5611.      */
  5612.   }, {
  5613.     key: "setPeaks",
  5614.     value: function setPeaks(peaks, duration) {
  5615.       if (duration != null) {
  5616.         this.explicitDuration = duration;
  5617.       }
  5618.       this.peaks = peaks;
  5619.     }
  5620.  
  5621.     /**
  5622.      * Set the rendered length (different from the length of the audio)
  5623.      *
  5624.      * @param {number} length The rendered length
  5625.      */
  5626.   }, {
  5627.     key: "setLength",
  5628.     value: function setLength(length) {
  5629.       // No resize, we can preserve the cached peaks.
  5630.       if (this.mergedPeaks && length == 2 * this.mergedPeaks.length - 1 + 2) {
  5631.         return;
  5632.       }
  5633.       this.splitPeaks = [];
  5634.       this.mergedPeaks = [];
  5635.       // Set the last element of the sparse array so the peak arrays are
  5636.       // appropriately sized for other calculations.
  5637.       var channels = this.buffer ? this.buffer.numberOfChannels : 1;
  5638.       var c;
  5639.       for (c = 0; c < channels; c++) {
  5640.         this.splitPeaks[c] = [];
  5641.         this.splitPeaks[c][2 * (length - 1)] = 0;
  5642.         this.splitPeaks[c][2 * (length - 1) + 1] = 0;
  5643.       }
  5644.       this.mergedPeaks[2 * (length - 1)] = 0;
  5645.       this.mergedPeaks[2 * (length - 1) + 1] = 0;
  5646.     }
  5647.  
  5648.     /**
  5649.      * Compute the max and min value of the waveform when broken into <length> subranges.
  5650.      *
  5651.      * @param {number} length How many subranges to break the waveform into.
  5652.      * @param {number} first First sample in the required range.
  5653.      * @param {number} last Last sample in the required range.
  5654.      * @return {number[]|Number.<Array[]>} Array of 2*<length> peaks or array of arrays of
  5655.      * peaks consisting of (max, min) values for each subrange.
  5656.      */
  5657.   }, {
  5658.     key: "getPeaks",
  5659.     value: function getPeaks(length, first, last) {
  5660.       if (this.peaks) {
  5661.         return this.peaks;
  5662.       }
  5663.       if (!this.buffer) {
  5664.         return [];
  5665.       }
  5666.       first = first || 0;
  5667.       last = last || length - 1;
  5668.       this.setLength(length);
  5669.       if (!this.buffer) {
  5670.         return this.params.splitChannels ? this.splitPeaks : this.mergedPeaks;
  5671.       }
  5672.  
  5673.       /**
  5674.        * The following snippet fixes a buffering data issue on the Safari
  5675.        * browser which returned undefined It creates the missing buffer based
  5676.        * on 1 channel, 4096 samples and the sampleRate from the current
  5677.        * webaudio context 4096 samples seemed to be the best fit for rendering
  5678.        * will review this code once a stable version of Safari TP is out
  5679.        */
  5680.       if (!this.buffer.length) {
  5681.         var newBuffer = this.createBuffer(1, 4096, this.sampleRate);
  5682.         this.buffer = newBuffer.buffer;
  5683.       }
  5684.       var sampleSize = this.buffer.length / length;
  5685.       var sampleStep = ~~(sampleSize / 10) || 1;
  5686.       var channels = this.buffer.numberOfChannels;
  5687.       var c;
  5688.       for (c = 0; c < channels; c++) {
  5689.         var peaks = this.splitPeaks[c];
  5690.         var chan = this.buffer.getChannelData(c);
  5691.         var i = void 0;
  5692.         for (i = first; i <= last; i++) {
  5693.           var start = ~~(i * sampleSize);
  5694.           var end = ~~(start + sampleSize);
  5695.           /**
  5696.            * Initialize the max and min to the first sample of this
  5697.            * subrange, so that even if the samples are entirely
  5698.            * on one side of zero, we still return the true max and
  5699.            * min values in the subrange.
  5700.            */
  5701.           var min = chan[start];
  5702.           var max = min;
  5703.           var j = void 0;
  5704.           for (j = start; j < end; j += sampleStep) {
  5705.             var value = chan[j];
  5706.             if (value > max) {
  5707.               max = value;
  5708.             }
  5709.             if (value < min) {
  5710.               min = value;
  5711.             }
  5712.           }
  5713.           peaks[2 * i] = max;
  5714.           peaks[2 * i + 1] = min;
  5715.           if (c == 0 || max > this.mergedPeaks[2 * i]) {
  5716.             this.mergedPeaks[2 * i] = max;
  5717.           }
  5718.           if (c == 0 || min < this.mergedPeaks[2 * i + 1]) {
  5719.             this.mergedPeaks[2 * i + 1] = min;
  5720.           }
  5721.         }
  5722.       }
  5723.       return this.params.splitChannels ? this.splitPeaks : this.mergedPeaks;
  5724.     }
  5725.  
  5726.     /**
  5727.      * Get the position from 0 to 1
  5728.      *
  5729.      * @return {number} Position
  5730.      */
  5731.   }, {
  5732.     key: "getPlayedPercents",
  5733.     value: function getPlayedPercents() {
  5734.       return this.state.getPlayedPercents.call(this);
  5735.     }
  5736.  
  5737.     /** @private */
  5738.   }, {
  5739.     key: "disconnectSource",
  5740.     value: function disconnectSource() {
  5741.       if (this.source) {
  5742.         this.source.disconnect();
  5743.       }
  5744.     }
  5745.     /**
  5746.      * Destroy all references with WebAudio, disconnecting audio nodes and closing Audio Context
  5747.      */
  5748.   }, {
  5749.     key: "destroyWebAudio",
  5750.     value: function destroyWebAudio() {
  5751.       this.disconnectFilters();
  5752.       this.disconnectSource();
  5753.       this.gainNode.disconnect();
  5754.       this.scriptNode && this.scriptNode.disconnect();
  5755.       this.analyser.disconnect();
  5756.  
  5757.       // close the audioContext if closeAudioContext option is set to true
  5758.       if (this.params.closeAudioContext) {
  5759.         // check if browser supports AudioContext.close()
  5760.         if (typeof this.ac.close === 'function' && this.ac.state != 'closed') {
  5761.           this.ac.close();
  5762.         }
  5763.         // clear the reference to the audiocontext
  5764.         this.ac = null;
  5765.         // clear the actual audiocontext, either passed as param or the
  5766.         // global singleton
  5767.         if (!this.params.audioContext) {
  5768.           window.WaveSurferAudioContext = null;
  5769.         } else {
  5770.           this.params.audioContext = null;
  5771.         }
  5772.         // clear the offlineAudioContext
  5773.         window.WaveSurferOfflineAudioContext = null;
  5774.       }
  5775.  
  5776.       // disconnect resources used by setSinkId
  5777.       if (this.sinkStreamDestination) {
  5778.         this.sinkAudioElement.pause();
  5779.         this.sinkAudioElement.srcObject = null;
  5780.         this.sinkStreamDestination.disconnect();
  5781.         this.sinkStreamDestination = null;
  5782.       }
  5783.     }
  5784.     /**
  5785.      * This is called when wavesurfer is destroyed
  5786.      */
  5787.   }, {
  5788.     key: "destroy",
  5789.     value: function destroy() {
  5790.       if (!this.isPaused()) {
  5791.         this.pause();
  5792.       }
  5793.       this.unAll();
  5794.       this.buffer = null;
  5795.       this.destroyed = true;
  5796.       this.destroyWebAudio();
  5797.     }
  5798.  
  5799.     /**
  5800.      * Loaded a decoded audio buffer
  5801.      *
  5802.      * @param {Object} buffer Decoded audio buffer to load
  5803.      */
  5804.   }, {
  5805.     key: "load",
  5806.     value: function load(buffer) {
  5807.       this.startPosition = 0;
  5808.       this.lastPlay = this.ac.currentTime;
  5809.       this.buffer = buffer;
  5810.       this.createSource();
  5811.     }
  5812.  
  5813.     /** @private */
  5814.   }, {
  5815.     key: "createSource",
  5816.     value: function createSource() {
  5817.       this.disconnectSource();
  5818.       this.source = this.ac.createBufferSource();
  5819.  
  5820.       // adjust for old browsers
  5821.       this.source.start = this.source.start || this.source.noteGrainOn;
  5822.       this.source.stop = this.source.stop || this.source.noteOff;
  5823.       this.setPlaybackRate(this.playbackRate);
  5824.       this.source.buffer = this.buffer;
  5825.       this.source.connect(this.analyser);
  5826.     }
  5827.  
  5828.     /**
  5829.      * @private
  5830.      *
  5831.      * some browsers require an explicit call to #resume before they will play back audio
  5832.      */
  5833.   }, {
  5834.     key: "resumeAudioContext",
  5835.     value: function resumeAudioContext() {
  5836.       if (this.ac.state == 'suspended') {
  5837.         this.ac.resume && this.ac.resume();
  5838.       }
  5839.     }
  5840.  
  5841.     /**
  5842.      * Used by `wavesurfer.isPlaying()` and `wavesurfer.playPause()`
  5843.      *
  5844.      * @return {boolean} Whether or not this backend is currently paused
  5845.      */
  5846.   }, {
  5847.     key: "isPaused",
  5848.     value: function isPaused() {
  5849.       return this.state !== this.states[PLAYING];
  5850.     }
  5851.  
  5852.     /**
  5853.      * Used by `wavesurfer.getDuration()`
  5854.      *
  5855.      * @return {number} Duration of loaded buffer
  5856.      */
  5857.   }, {
  5858.     key: "getDuration",
  5859.     value: function getDuration() {
  5860.       if (this.explicitDuration) {
  5861.         return this.explicitDuration;
  5862.       }
  5863.       if (!this.buffer) {
  5864.         return 0;
  5865.       }
  5866.       return this.buffer.duration;
  5867.     }
  5868.  
  5869.     /**
  5870.      * Used by `wavesurfer.seekTo()`
  5871.      *
  5872.      * @param {number} start Position to start at in seconds
  5873.      * @param {number} end Position to end at in seconds
  5874.      * @return {{start: number, end: number}} Object containing start and end
  5875.      * positions
  5876.      */
  5877.   }, {
  5878.     key: "seekTo",
  5879.     value: function seekTo(start, end) {
  5880.       if (!this.buffer) {
  5881.         return;
  5882.       }
  5883.       this.scheduledPause = null;
  5884.       if (start == null) {
  5885.         start = this.getCurrentTime();
  5886.         if (start >= this.getDuration()) {
  5887.           start = 0;
  5888.         }
  5889.       }
  5890.       if (end == null) {
  5891.         end = this.getDuration();
  5892.       }
  5893.       this.startPosition = start;
  5894.       this.lastPlay = this.ac.currentTime;
  5895.       if (this.state === this.states[FINISHED]) {
  5896.         this.setState(PAUSED);
  5897.       }
  5898.       return {
  5899.         start: start,
  5900.         end: end
  5901.       };
  5902.     }
  5903.  
  5904.     /**
  5905.      * Get the playback position in seconds
  5906.      *
  5907.      * @return {number} The playback position in seconds
  5908.      */
  5909.   }, {
  5910.     key: "getPlayedTime",
  5911.     value: function getPlayedTime() {
  5912.       return (this.ac.currentTime - this.lastPlay) * this.playbackRate;
  5913.     }
  5914.  
  5915.     /**
  5916.      * Plays the loaded audio region.
  5917.      *
  5918.      * @param {number} start Start offset in seconds, relative to the beginning
  5919.      * of a clip.
  5920.      * @param {number} end When to stop relative to the beginning of a clip.
  5921.      */
  5922.   }, {
  5923.     key: "play",
  5924.     value: function play(start, end) {
  5925.       if (!this.buffer) {
  5926.         return;
  5927.       }
  5928.  
  5929.       // need to re-create source on each playback
  5930.       this.createSource();
  5931.       var adjustedTime = this.seekTo(start, end);
  5932.       start = adjustedTime.start;
  5933.       end = adjustedTime.end;
  5934.       this.scheduledPause = end;
  5935.       this.source.start(0, start);
  5936.       this.resumeAudioContext();
  5937.       this.setState(PLAYING);
  5938.       this.fireEvent('play');
  5939.     }
  5940.  
  5941.     /**
  5942.      * Pauses the loaded audio.
  5943.      */
  5944.   }, {
  5945.     key: "pause",
  5946.     value: function pause() {
  5947.       this.scheduledPause = null;
  5948.       this.startPosition += this.getPlayedTime();
  5949.       try {
  5950.         this.source && this.source.stop(0);
  5951.       } catch (err) {
  5952.         // Calling stop can throw the following 2 errors:
  5953.         // - RangeError (The value specified for when is negative.)
  5954.         // - InvalidStateNode (The node has not been started by calling start().)
  5955.         // We can safely ignore both errors, because:
  5956.         // - The range is surely correct
  5957.         // - The node might not have been started yet, in which case we just want to carry on without causing any trouble.
  5958.       }
  5959.       this.setState(PAUSED);
  5960.       this.fireEvent('pause');
  5961.     }
  5962.  
  5963.     /**
  5964.      * Returns the current time in seconds relative to the audio-clip's
  5965.      * duration.
  5966.      *
  5967.      * @return {number} The current time in seconds
  5968.      */
  5969.   }, {
  5970.     key: "getCurrentTime",
  5971.     value: function getCurrentTime() {
  5972.       return this.state.getCurrentTime.call(this);
  5973.     }
  5974.  
  5975.     /**
  5976.      * Returns the current playback rate. (0=no playback, 1=normal playback)
  5977.      *
  5978.      * @return {number} The current playback rate
  5979.      */
  5980.   }, {
  5981.     key: "getPlaybackRate",
  5982.     value: function getPlaybackRate() {
  5983.       return this.playbackRate;
  5984.     }
  5985.  
  5986.     /**
  5987.      * Set the audio source playback rate.
  5988.      *
  5989.      * @param {number} value The playback rate to use
  5990.      */
  5991.   }, {
  5992.     key: "setPlaybackRate",
  5993.     value: function setPlaybackRate(value) {
  5994.       this.playbackRate = value || 1;
  5995.       this.source && this.source.playbackRate.setValueAtTime(this.playbackRate, this.ac.currentTime);
  5996.     }
  5997.  
  5998.     /**
  5999.      * Set a point in seconds for playback to stop at.
  6000.      *
  6001.      * @param {number} end Position to end at
  6002.      * @version 3.3.0
  6003.      */
  6004.   }, {
  6005.     key: "setPlayEnd",
  6006.     value: function setPlayEnd(end) {
  6007.       this.scheduledPause = end;
  6008.     }
  6009.   }]);
  6010.   return WebAudio;
  6011. }(util.Observer);
  6012. exports["default"] = WebAudio;
  6013. module.exports = exports.default;
  6014.  
  6015. /***/ }),
  6016.  
  6017. /***/ "./node_modules/debounce/index.js":
  6018. /*!****************************************!*\
  6019.   !*** ./node_modules/debounce/index.js ***!
  6020.   \****************************************/
  6021. /***/ ((module) => {
  6022.  
  6023. /**
  6024.  * Returns a function, that, as long as it continues to be invoked, will not
  6025.  * be triggered. The function will be called after it stops being called for
  6026.  * N milliseconds. If `immediate` is passed, trigger the function on the
  6027.  * leading edge, instead of the trailing. The function also has a property 'clear' 
  6028.  * that is a function which will clear the timer to prevent previously scheduled executions. 
  6029.  *
  6030.  * @source underscore.js
  6031.  * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
  6032.  * @param {Function} function to wrap
  6033.  * @param {Number} timeout in ms (`100`)
  6034.  * @param {Boolean} whether to execute at the beginning (`false`)
  6035.  * @api public
  6036.  */
  6037. function debounce(func, wait, immediate){
  6038.   var timeout, args, context, timestamp, result;
  6039.   if (null == wait) wait = 100;
  6040.  
  6041.   function later() {
  6042.     var last = Date.now() - timestamp;
  6043.  
  6044.     if (last < wait && last >= 0) {
  6045.       timeout = setTimeout(later, wait - last);
  6046.     } else {
  6047.       timeout = null;
  6048.       if (!immediate) {
  6049.         result = func.apply(context, args);
  6050.         context = args = null;
  6051.       }
  6052.     }
  6053.   };
  6054.  
  6055.   var debounced = function(){
  6056.     context = this;
  6057.     args = arguments;
  6058.     timestamp = Date.now();
  6059.     var callNow = immediate && !timeout;
  6060.     if (!timeout) timeout = setTimeout(later, wait);
  6061.     if (callNow) {
  6062.       result = func.apply(context, args);
  6063.       context = args = null;
  6064.     }
  6065.  
  6066.     return result;
  6067.   };
  6068.  
  6069.   debounced.clear = function() {
  6070.     if (timeout) {
  6071.       clearTimeout(timeout);
  6072.       timeout = null;
  6073.     }
  6074.   };
  6075.  
  6076.   debounced.flush = function() {
  6077.     if (timeout) {
  6078.       result = func.apply(context, args);
  6079.       context = args = null;
  6080.  
  6081.       clearTimeout(timeout);
  6082.       timeout = null;
  6083.     }
  6084.   };
  6085.  
  6086.   return debounced;
  6087. };
  6088.  
  6089. // Adds compatibility for ES modules
  6090. debounce.debounce = debounce;
  6091.  
  6092. module.exports = debounce;
  6093.  
  6094.  
  6095. /***/ })
  6096.  
  6097. /******/ 	});
  6098. /************************************************************************/
  6099. /******/ 	// The module cache
  6100. /******/ 	var __webpack_module_cache__ = {};
  6101. /******/ 	
  6102. /******/ 	// The require function
  6103. /******/ 	function __webpack_require__(moduleId) {
  6104. /******/ 		// Check if module is in cache
  6105. /******/ 		var cachedModule = __webpack_module_cache__[moduleId];
  6106. /******/ 		if (cachedModule !== undefined) {
  6107. /******/ 			return cachedModule.exports;
  6108. /******/ 		}
  6109. /******/ 		// Create a new module (and put it into the cache)
  6110. /******/ 		var module = __webpack_module_cache__[moduleId] = {
  6111. /******/ 			// no module.id needed
  6112. /******/ 			// no module.loaded needed
  6113. /******/ 			exports: {}
  6114. /******/ 		};
  6115. /******/ 	
  6116. /******/ 		// Execute the module function
  6117. /******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  6118. /******/ 	
  6119. /******/ 		// Return the exports of the module
  6120. /******/ 		return module.exports;
  6121. /******/ 	}
  6122. /******/ 	
  6123. /************************************************************************/
  6124. /******/ 	
  6125. /******/ 	// startup
  6126. /******/ 	// Load entry module and return exports
  6127. /******/ 	// This entry module is referenced by other modules so it can't be inlined
  6128. /******/ 	var __webpack_exports__ = __webpack_require__("./src/wavesurfer.js");
  6129. /******/ 	
  6130. /******/ 	return __webpack_exports__;
  6131. /******/ })()
  6132. ;
  6133. });
  6134. //# sourceMappingURL=wavesurfer.js.map