react-modern-audio-player 1.4.0-rc.2 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +294 -100
  2. package/dist/index.css +1 -1
  3. package/dist/index.es.js +1914 -7975
  4. package/dist/types/api/index.d.ts +6 -0
  5. package/dist/types/api/useAudioPlayer.d.ts +27 -0
  6. package/dist/types/api/useAudioPlayerElement.d.ts +6 -0
  7. package/dist/types/api/useAudioPlayerPlayback.d.ts +9 -0
  8. package/dist/types/api/useAudioPlayerTime.d.ts +6 -0
  9. package/dist/types/api/useAudioPlayerTrack.d.ts +11 -0
  10. package/dist/types/api/useAudioPlayerVolume.d.ts +7 -0
  11. package/dist/types/components/AudioPlayer/Audio/index.d.ts +2 -2
  12. package/dist/types/components/AudioPlayer/Audio/useAudio.d.ts +1 -1
  13. package/dist/types/components/AudioPlayer/Container/AudioPlayerContainer.d.ts +5 -0
  14. package/dist/types/components/AudioPlayer/Container/index.d.ts +1 -0
  15. package/dist/types/components/AudioPlayer/Context/AudioAttrsContext.d.ts +15 -0
  16. package/dist/types/components/AudioPlayer/Context/PlaybackContext.d.ts +10 -0
  17. package/dist/types/components/AudioPlayer/Context/ResourceContext.d.ts +7 -0
  18. package/dist/types/components/AudioPlayer/Context/StateContext/audio.d.ts +18 -8
  19. package/dist/types/components/AudioPlayer/Context/StateContext/element.d.ts +8 -13
  20. package/dist/types/components/AudioPlayer/Context/StateContext/index.d.ts +9 -8
  21. package/dist/types/components/AudioPlayer/Context/StateContext/placement.d.ts +9 -9
  22. package/dist/types/components/AudioPlayer/Context/TimeContext.d.ts +6 -0
  23. package/dist/types/components/AudioPlayer/Context/TrackContext.d.ts +7 -0
  24. package/dist/types/components/AudioPlayer/Context/UIContext.d.ts +11 -0
  25. package/dist/types/components/AudioPlayer/Context/dispatchContext.d.ts +11 -7
  26. package/dist/types/components/AudioPlayer/Context/index.d.ts +10 -3
  27. package/dist/types/components/AudioPlayer/Context/providerProps.d.ts +14 -0
  28. package/dist/types/components/AudioPlayer/Context/reducer.d.ts +2 -2
  29. package/dist/types/components/AudioPlayer/Interface/Controller/Button/NextBtn.d.ts +6 -0
  30. package/dist/types/components/AudioPlayer/Interface/Controller/Button/PlayBtn.d.ts +1 -1
  31. package/dist/types/components/AudioPlayer/Interface/Controller/Button/PrevBtn.d.ts +6 -0
  32. package/dist/types/components/AudioPlayer/Interface/Controller/Button/RepeatTypeBtn.d.ts +1 -1
  33. package/dist/types/components/AudioPlayer/Interface/Controller/Button/VolumeTriggerBtn.d.ts +1 -1
  34. package/dist/types/components/AudioPlayer/Interface/Controller/Button/index.d.ts +5 -5
  35. package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/SortablePlayList/Content/PlayListItem.d.ts +3 -3
  36. package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/SortablePlayList/Content/index.d.ts +2 -6
  37. package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/SortablePlayList/Content/usePlayList.d.ts +3 -4
  38. package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/SortablePlayList/PlayListIcon.d.ts +2 -0
  39. package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/SortablePlayList/index.d.ts +1 -1
  40. package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/index.d.ts +1 -1
  41. package/dist/types/components/AudioPlayer/Interface/Controller/Icon.d.ts +3 -3
  42. package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/BarProgress.d.ts +2 -4
  43. package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/WaveformProgress.d.ts +1 -1
  44. package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/index.d.ts +1 -1
  45. package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/useProgress.d.ts +1 -1
  46. package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/useProgressKeyDown.d.ts +2 -0
  47. package/dist/types/components/AudioPlayer/Interface/Controller/Input/index.d.ts +1 -1
  48. package/dist/types/components/AudioPlayer/Interface/Controller/Tooltip/Volume/Content.d.ts +2 -2
  49. package/dist/types/components/AudioPlayer/Interface/Controller/Tooltip/Volume/index.d.ts +1 -1
  50. package/dist/types/components/AudioPlayer/Interface/Controller/Tooltip/Volume/useVolume.d.ts +2 -2
  51. package/dist/types/components/AudioPlayer/Interface/Controller/Tooltip/index.d.ts +1 -1
  52. package/dist/types/components/AudioPlayer/Interface/Controller/index.d.ts +1 -1
  53. package/dist/types/components/AudioPlayer/Interface/CustomComponent/index.d.ts +2 -2
  54. package/dist/types/components/AudioPlayer/Interface/Information/Artwork.d.ts +1 -1
  55. package/dist/types/components/AudioPlayer/Interface/Information/TrackInfo.d.ts +1 -1
  56. package/dist/types/components/AudioPlayer/Interface/Information/TrackTime/Current.d.ts +2 -2
  57. package/dist/types/components/AudioPlayer/Interface/Information/TrackTime/Duration.d.ts +2 -2
  58. package/dist/types/components/AudioPlayer/Interface/Information/TrackTime/TrackTimeContainer.d.ts +6 -0
  59. package/dist/types/components/AudioPlayer/Interface/Information/TrackTime/Types.d.ts +1 -1
  60. package/dist/types/components/AudioPlayer/Interface/Information/TrackTime/index.d.ts +1 -1
  61. package/dist/types/components/AudioPlayer/Interface/Information/index.d.ts +1 -1
  62. package/dist/types/components/AudioPlayer/Interface/index.d.ts +1 -1
  63. package/dist/types/components/AudioPlayer/Player/index.d.ts +9 -14
  64. package/dist/types/components/AudioPlayer/Player/usePropsStateEffect.d.ts +1 -1
  65. package/dist/types/components/AudioPlayer/Provider/AudioPlayerStateProvider.d.ts +7 -0
  66. package/dist/types/components/AudioPlayer/Provider/index.d.ts +1 -0
  67. package/dist/types/components/AudioPlayer/index.d.ts +10 -11
  68. package/dist/types/components/Drawer/Drawer.d.ts +5 -6
  69. package/dist/types/components/Drawer/DrawerContent.d.ts +4 -3
  70. package/dist/types/components/Drawer/DrawerContext.d.ts +2 -1
  71. package/dist/types/components/Drawer/DrawerTrigger.d.ts +7 -2
  72. package/dist/types/components/Drawer/index.d.ts +2 -2
  73. package/dist/types/components/Dropdown/Dropdown.d.ts +6 -6
  74. package/dist/types/components/Dropdown/DropdownContent.d.ts +3 -3
  75. package/dist/types/components/Dropdown/DropdownContext.d.ts +2 -1
  76. package/dist/types/components/Dropdown/DropdownTrigger.d.ts +2 -2
  77. package/dist/types/components/Dropdown/index.d.ts +2 -2
  78. package/dist/types/components/Dropdown/useDropdown.d.ts +3 -3
  79. package/dist/types/components/Dropdown/useDropdownPlacementStyle.d.ts +3 -0
  80. package/dist/types/components/Grid/Grid.d.ts +12 -8
  81. package/dist/types/components/Grid/Item.d.ts +8 -5
  82. package/dist/types/components/Grid/index.d.ts +8 -1
  83. package/dist/types/components/SortableList/SortableList.d.ts +4 -4
  84. package/dist/types/components/SortableList/SortableListItem.d.ts +5 -5
  85. package/dist/types/components/SortableList/index.d.ts +5 -5
  86. package/dist/types/components/SortableList/useSortableListItem.d.ts +1 -1
  87. package/dist/types/components/icons/index.d.ts +16 -0
  88. package/dist/types/hooks/context/index.d.ts +7 -0
  89. package/dist/types/hooks/context/useAudioAttrsContext.d.ts +2 -0
  90. package/dist/types/hooks/{useNonNullableContext.d.ts → context/useNonNullableContext.d.ts} +1 -1
  91. package/dist/types/hooks/context/usePlaybackContext.d.ts +2 -0
  92. package/dist/types/hooks/context/useResourceContext.d.ts +2 -0
  93. package/dist/types/hooks/context/useTimeContext.d.ts +2 -0
  94. package/dist/types/hooks/context/useTrackContext.d.ts +2 -0
  95. package/dist/types/hooks/context/useUIContext.d.ts +1 -0
  96. package/dist/types/hooks/index.d.ts +5 -4
  97. package/dist/types/hooks/useClickOutside.d.ts +1 -1
  98. package/dist/types/hooks/useDidUpdateEffect.d.ts +16 -0
  99. package/dist/types/hooks/useRefsDispatch.d.ts +1 -1
  100. package/dist/types/hooks/useVariableColor.d.ts +2 -2
  101. package/dist/types/index.d.ts +7 -5
  102. package/dist/types/test/setup.d.ts +0 -0
  103. package/dist/types/{components → ui}/CssTransition.d.ts +1 -3
  104. package/dist/types/ui/StyledBtn.d.ts +1 -0
  105. package/dist/types/utils/clampVolume.d.ts +5 -0
  106. package/dist/types/utils/generateUnionNumType.d.ts +2 -2
  107. package/dist/types/utils/refs.d.ts +1 -0
  108. package/dist/types/utils/safeRatio.d.ts +5 -0
  109. package/dist/types/utils/ssr.d.ts +5 -0
  110. package/dist/wavesurfer-_j5aw4gZ.mjs +4471 -0
  111. package/package.json +32 -22
  112. package/dist/types/components/AudioPlayer/Interface/Controller/Button/PlayListTriggerBtn.d.ts +0 -5
  113. package/dist/types/components/AudioPlayer/Interface/Controller/Button/PrevNnextBtn.d.ts +0 -7
  114. package/dist/types/components/AudioPlayer/Interface/Controller/Button/StyledBtn.d.ts +0 -1
  115. package/dist/types/components/AudioPlayer/Interface/Information/TrackTime/Styles.d.ts +0 -6
  116. package/dist/types/components/Provider/AudioPlayerProvider.d.ts +0 -3
  117. package/dist/types/components/Provider/SpectrumProvider.d.ts +0 -7
  118. package/dist/types/components/Provider/index.d.ts +0 -2
  119. package/dist/types/styles/GlobalStyle.d.ts +0 -1
  120. package/dist/types/utils/resetAudioValues.d.ts +0 -2
@@ -0,0 +1,4471 @@
1
+ function oe(q, Z) {
2
+ for (var X = 0; X < Z.length; X++) {
3
+ const Q = Z[X];
4
+ if (typeof Q != "string" && !Array.isArray(Q)) {
5
+ for (const G in Q)
6
+ if (G !== "default" && !(G in q)) {
7
+ const K = Object.getOwnPropertyDescriptor(Q, G);
8
+ K && Object.defineProperty(q, G, K.get ? K : {
9
+ enumerable: !0,
10
+ get: () => Q[G]
11
+ });
12
+ }
13
+ }
14
+ }
15
+ return Object.freeze(Object.defineProperty(q, Symbol.toStringTag, { value: "Module" }));
16
+ }
17
+ function ue(q) {
18
+ return q && q.__esModule && Object.prototype.hasOwnProperty.call(q, "default") ? q.default : q;
19
+ }
20
+ var re = { exports: {} };
21
+ /*!
22
+ * wavesurfer.js 6.6.4 (2023-06-10)
23
+ * https://wavesurfer-js.org
24
+ * @license BSD-3-Clause
25
+ */
26
+ (function(q, Z) {
27
+ (function(Q, G) {
28
+ q.exports = G();
29
+ })(self, () => (
30
+ /******/
31
+ (() => {
32
+ var X = {
33
+ /***/
34
+ "./src/drawer.canvasentry.js": (
35
+ /*!***********************************!*\
36
+ !*** ./src/drawer.canvasentry.js ***!
37
+ \***********************************/
38
+ /***/
39
+ (j, h, C) => {
40
+ Object.defineProperty(h, "__esModule", {
41
+ value: !0
42
+ }), h.default = void 0;
43
+ var g = E(C(
44
+ /*! ./util/style */
45
+ "./src/util/style.js"
46
+ )), W = E(C(
47
+ /*! ./util/get-id */
48
+ "./src/util/get-id.js"
49
+ ));
50
+ function E(p) {
51
+ return p && p.__esModule ? p : { default: p };
52
+ }
53
+ function M(p) {
54
+ "@babel/helpers - typeof";
55
+ return M = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(c) {
56
+ return typeof c;
57
+ } : function(c) {
58
+ return c && typeof Symbol == "function" && c.constructor === Symbol && c !== Symbol.prototype ? "symbol" : typeof c;
59
+ }, M(p);
60
+ }
61
+ function x(p, c) {
62
+ if (!(p instanceof c))
63
+ throw new TypeError("Cannot call a class as a function");
64
+ }
65
+ function I(p, c) {
66
+ for (var v = 0; v < c.length; v++) {
67
+ var d = c[v];
68
+ d.enumerable = d.enumerable || !1, d.configurable = !0, "value" in d && (d.writable = !0), Object.defineProperty(p, O(d.key), d);
69
+ }
70
+ }
71
+ function b(p, c, v) {
72
+ return c && I(p.prototype, c), Object.defineProperty(p, "prototype", { writable: !1 }), p;
73
+ }
74
+ function O(p) {
75
+ var c = R(p, "string");
76
+ return M(c) === "symbol" ? c : String(c);
77
+ }
78
+ function R(p, c) {
79
+ if (M(p) !== "object" || p === null) return p;
80
+ var v = p[Symbol.toPrimitive];
81
+ if (v !== void 0) {
82
+ var d = v.call(p, c);
83
+ if (M(d) !== "object") return d;
84
+ throw new TypeError("@@toPrimitive must return a primitive value.");
85
+ }
86
+ return String(p);
87
+ }
88
+ var _ = /* @__PURE__ */ function() {
89
+ function p() {
90
+ x(this, p), this.wave = null, this.waveCtx = null, this.progress = null, this.progressCtx = null, this.start = 0, this.end = 1, this.id = (0, W.default)(typeof this.constructor.name < "u" ? this.constructor.name.toLowerCase() + "_" : "canvasentry_"), this.canvasContextAttributes = {};
91
+ }
92
+ return b(p, [{
93
+ key: "initWave",
94
+ value: function(v) {
95
+ this.wave = v, this.waveCtx = this.wave.getContext("2d", this.canvasContextAttributes);
96
+ }
97
+ /**
98
+ * Store the progress wave canvas element and create the 2D rendering
99
+ * context
100
+ *
101
+ * @param {HTMLCanvasElement} element The progress wave `canvas` element.
102
+ */
103
+ }, {
104
+ key: "initProgress",
105
+ value: function(v) {
106
+ this.progress = v, this.progressCtx = this.progress.getContext("2d", this.canvasContextAttributes);
107
+ }
108
+ /**
109
+ * Update the dimensions
110
+ *
111
+ * @param {number} elementWidth Width of the entry
112
+ * @param {number} totalWidth Total width of the multi canvas renderer
113
+ * @param {number} width The new width of the element
114
+ * @param {number} height The new height of the element
115
+ */
116
+ }, {
117
+ key: "updateDimensions",
118
+ value: function(v, d, P, w) {
119
+ this.start = this.wave.offsetLeft / d || 0, this.end = this.start + v / d, this.wave.width = P, this.wave.height = w;
120
+ var k = {
121
+ width: v + "px"
122
+ };
123
+ (0, g.default)(this.wave, k), this.hasProgressCanvas && (this.progress.width = P, this.progress.height = w, (0, g.default)(this.progress, k));
124
+ }
125
+ /**
126
+ * Clear the wave and progress rendering contexts
127
+ */
128
+ }, {
129
+ key: "clearWave",
130
+ value: function() {
131
+ this.waveCtx.clearRect(0, 0, this.waveCtx.canvas.width, this.waveCtx.canvas.height), this.hasProgressCanvas && this.progressCtx.clearRect(0, 0, this.progressCtx.canvas.width, this.progressCtx.canvas.height);
132
+ }
133
+ /**
134
+ * Set the fill styles for wave and progress
135
+ * @param {string|string[]} waveColor Fill color for the wave canvas,
136
+ * or an array of colors to apply as a gradient
137
+ * @param {?string|string[]} progressColor Fill color for the progress canvas,
138
+ * or an array of colors to apply as a gradient
139
+ */
140
+ }, {
141
+ key: "setFillStyles",
142
+ value: function(v, d) {
143
+ this.waveCtx.fillStyle = this.getFillStyle(this.waveCtx, v), this.hasProgressCanvas && (this.progressCtx.fillStyle = this.getFillStyle(this.progressCtx, d));
144
+ }
145
+ /**
146
+ * Utility function to handle wave color arguments
147
+ *
148
+ * When the color argument type is a string or CanvasGradient instance,
149
+ * it will be returned as is. Otherwise, it will be treated as an array,
150
+ * and a new CanvasGradient will be returned
151
+ *
152
+ * @since 6.0.0
153
+ * @param {CanvasRenderingContext2D} ctx Rendering context of target canvas
154
+ * @param {string|string[]|CanvasGradient} color Either a single fill color
155
+ * for the wave canvas, an existing CanvasGradient instance, or an array
156
+ * of colors to apply as a gradient
157
+ * @returns {string|CanvasGradient} Returns a string fillstyle value, or a
158
+ * canvas gradient
159
+ */
160
+ }, {
161
+ key: "getFillStyle",
162
+ value: function(v, d) {
163
+ if (typeof d == "string" || d instanceof CanvasGradient)
164
+ return d;
165
+ var P = v.createLinearGradient(0, 0, 0, v.canvas.height);
166
+ return d.forEach(function(w, k) {
167
+ return P.addColorStop(k / d.length, w);
168
+ }), P;
169
+ }
170
+ /**
171
+ * Set the canvas transforms for wave and progress
172
+ *
173
+ * @param {boolean} vertical Whether to render vertically
174
+ */
175
+ }, {
176
+ key: "applyCanvasTransforms",
177
+ value: function(v) {
178
+ v && (this.waveCtx.setTransform(0, 1, 1, 0, 0, 0), this.hasProgressCanvas && this.progressCtx.setTransform(0, 1, 1, 0, 0, 0));
179
+ }
180
+ /**
181
+ * Draw a rectangle for wave and progress
182
+ *
183
+ * @param {number} x X start position
184
+ * @param {number} y Y start position
185
+ * @param {number} width Width of the rectangle
186
+ * @param {number} height Height of the rectangle
187
+ * @param {number} radius Radius of the rectangle
188
+ */
189
+ }, {
190
+ key: "fillRects",
191
+ value: function(v, d, P, w, k) {
192
+ this.fillRectToContext(this.waveCtx, v, d, P, w, k), this.hasProgressCanvas && this.fillRectToContext(this.progressCtx, v, d, P, w, k);
193
+ }
194
+ /**
195
+ * Draw the actual rectangle on a `canvas` element
196
+ *
197
+ * @param {CanvasRenderingContext2D} ctx Rendering context of target canvas
198
+ * @param {number} x X start position
199
+ * @param {number} y Y start position
200
+ * @param {number} width Width of the rectangle
201
+ * @param {number} height Height of the rectangle
202
+ * @param {number} radius Radius of the rectangle
203
+ */
204
+ }, {
205
+ key: "fillRectToContext",
206
+ value: function(v, d, P, w, k, y) {
207
+ v && (y ? this.drawRoundedRect(v, d, P, w, k, y) : v.fillRect(d, P, w, k));
208
+ }
209
+ /**
210
+ * Draw a rounded rectangle on Canvas
211
+ *
212
+ * @param {CanvasRenderingContext2D} ctx Canvas context
213
+ * @param {number} x X-position of the rectangle
214
+ * @param {number} y Y-position of the rectangle
215
+ * @param {number} width Width of the rectangle
216
+ * @param {number} height Height of the rectangle
217
+ * @param {number} radius Radius of the rectangle
218
+ *
219
+ * @return {void}
220
+ * @example drawRoundedRect(ctx, 50, 50, 5, 10, 3)
221
+ */
222
+ }, {
223
+ key: "drawRoundedRect",
224
+ value: function(v, d, P, w, k, y) {
225
+ k !== 0 && (k < 0 && (k *= -1, P -= k), v.beginPath(), v.moveTo(d + y, P), v.lineTo(d + w - y, P), v.quadraticCurveTo(d + w, P, d + w, P + y), v.lineTo(d + w, P + k - y), v.quadraticCurveTo(d + w, P + k, d + w - y, P + k), v.lineTo(d + y, P + k), v.quadraticCurveTo(d, P + k, d, P + k - y), v.lineTo(d, P + y), v.quadraticCurveTo(d, P, d + y, P), v.closePath(), v.fill());
226
+ }
227
+ /**
228
+ * Render the actual wave and progress lines
229
+ *
230
+ * @param {number[]} peaks Array with peaks data
231
+ * @param {number} absmax Maximum peak value (absolute)
232
+ * @param {number} halfH Half the height of the waveform
233
+ * @param {number} offsetY Offset to the top
234
+ * @param {number} start The x-offset of the beginning of the area that
235
+ * should be rendered
236
+ * @param {number} end The x-offset of the end of the area that
237
+ * should be rendered
238
+ */
239
+ }, {
240
+ key: "drawLines",
241
+ value: function(v, d, P, w, k, y) {
242
+ this.drawLineToContext(this.waveCtx, v, d, P, w, k, y), this.hasProgressCanvas && this.drawLineToContext(this.progressCtx, v, d, P, w, k, y);
243
+ }
244
+ /**
245
+ * Render the actual waveform line on a `canvas` element
246
+ *
247
+ * @param {CanvasRenderingContext2D} ctx Rendering context of target canvas
248
+ * @param {number[]} peaks Array with peaks data
249
+ * @param {number} absmax Maximum peak value (absolute)
250
+ * @param {number} halfH Half the height of the waveform
251
+ * @param {number} offsetY Offset to the top
252
+ * @param {number} start The x-offset of the beginning of the area that
253
+ * should be rendered
254
+ * @param {number} end The x-offset of the end of the area that
255
+ * should be rendered
256
+ */
257
+ }, {
258
+ key: "drawLineToContext",
259
+ value: function(v, d, P, w, k, y, f) {
260
+ if (v) {
261
+ var m = d.length / 2, u = Math.round(m * this.start), n = Math.round(m * this.end) + 1, a = u, o = n, r = this.wave.width / (o - a - 1), t = w + k, s = P / w;
262
+ v.beginPath(), v.moveTo((a - u) * r, t), v.lineTo((a - u) * r, t - Math.round((d[2 * a] || 0) / s));
263
+ var i, e, l;
264
+ for (i = a; i < o; i++)
265
+ e = d[2 * i] || 0, l = Math.round(e / s), v.lineTo((i - u) * r + this.halfPixel, t - l);
266
+ var A = o - 1;
267
+ for (A; A >= a; A--)
268
+ e = d[2 * A + 1] || 0, l = Math.round(e / s), v.lineTo((A - u) * r + this.halfPixel, t - l);
269
+ v.lineTo((a - u) * r, t - Math.round((d[2 * a + 1] || 0) / s)), v.closePath(), v.fill();
270
+ }
271
+ }
272
+ /**
273
+ * Destroys this entry
274
+ */
275
+ }, {
276
+ key: "destroy",
277
+ value: function() {
278
+ this.waveCtx = null, this.wave = null, this.progressCtx = null, this.progress = null;
279
+ }
280
+ /**
281
+ * Return image data of the wave `canvas` element
282
+ *
283
+ * When using a `type` of `'blob'`, this will return a `Promise` that
284
+ * resolves with a `Blob` instance.
285
+ *
286
+ * @param {string} format='image/png' An optional value of a format type.
287
+ * @param {number} quality=0.92 An optional value between 0 and 1.
288
+ * @param {string} type='dataURL' Either 'dataURL' or 'blob'.
289
+ * @return {string|Promise} When using the default `'dataURL'` `type` this
290
+ * returns a data URL. When using the `'blob'` `type` this returns a
291
+ * `Promise` that resolves with a `Blob` instance.
292
+ */
293
+ }, {
294
+ key: "getImage",
295
+ value: function(v, d, P) {
296
+ var w = this;
297
+ if (P === "blob")
298
+ return new Promise(function(k) {
299
+ w.wave.toBlob(k, v, d);
300
+ });
301
+ if (P === "dataURL")
302
+ return this.wave.toDataURL(v, d);
303
+ }
304
+ }]), p;
305
+ }();
306
+ h.default = _, j.exports = h.default;
307
+ }
308
+ ),
309
+ /***/
310
+ "./src/drawer.js": (
311
+ /*!***********************!*\
312
+ !*** ./src/drawer.js ***!
313
+ \***********************/
314
+ /***/
315
+ (j, h, C) => {
316
+ function g(y) {
317
+ "@babel/helpers - typeof";
318
+ return g = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(f) {
319
+ return typeof f;
320
+ } : function(f) {
321
+ return f && typeof Symbol == "function" && f.constructor === Symbol && f !== Symbol.prototype ? "symbol" : typeof f;
322
+ }, g(y);
323
+ }
324
+ Object.defineProperty(h, "__esModule", {
325
+ value: !0
326
+ }), h.default = void 0;
327
+ var W = M(C(
328
+ /*! ./util */
329
+ "./src/util/index.js"
330
+ ));
331
+ function E(y) {
332
+ if (typeof WeakMap != "function") return null;
333
+ var f = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap();
334
+ return (E = function(n) {
335
+ return n ? m : f;
336
+ })(y);
337
+ }
338
+ function M(y, f) {
339
+ if (y && y.__esModule)
340
+ return y;
341
+ if (y === null || g(y) !== "object" && typeof y != "function")
342
+ return { default: y };
343
+ var m = E(f);
344
+ if (m && m.has(y))
345
+ return m.get(y);
346
+ var u = {}, n = Object.defineProperty && Object.getOwnPropertyDescriptor;
347
+ for (var a in y)
348
+ if (a !== "default" && Object.prototype.hasOwnProperty.call(y, a)) {
349
+ var o = n ? Object.getOwnPropertyDescriptor(y, a) : null;
350
+ o && (o.get || o.set) ? Object.defineProperty(u, a, o) : u[a] = y[a];
351
+ }
352
+ return u.default = y, m && m.set(y, u), u;
353
+ }
354
+ function x(y, f) {
355
+ if (!(y instanceof f))
356
+ throw new TypeError("Cannot call a class as a function");
357
+ }
358
+ function I(y, f) {
359
+ for (var m = 0; m < f.length; m++) {
360
+ var u = f[m];
361
+ u.enumerable = u.enumerable || !1, u.configurable = !0, "value" in u && (u.writable = !0), Object.defineProperty(y, O(u.key), u);
362
+ }
363
+ }
364
+ function b(y, f, m) {
365
+ return f && I(y.prototype, f), Object.defineProperty(y, "prototype", { writable: !1 }), y;
366
+ }
367
+ function O(y) {
368
+ var f = R(y, "string");
369
+ return g(f) === "symbol" ? f : String(f);
370
+ }
371
+ function R(y, f) {
372
+ if (g(y) !== "object" || y === null) return y;
373
+ var m = y[Symbol.toPrimitive];
374
+ if (m !== void 0) {
375
+ var u = m.call(y, f);
376
+ if (g(u) !== "object") return u;
377
+ throw new TypeError("@@toPrimitive must return a primitive value.");
378
+ }
379
+ return String(y);
380
+ }
381
+ function _(y, f) {
382
+ if (typeof f != "function" && f !== null)
383
+ throw new TypeError("Super expression must either be null or a function");
384
+ y.prototype = Object.create(f && f.prototype, { constructor: { value: y, writable: !0, configurable: !0 } }), Object.defineProperty(y, "prototype", { writable: !1 }), f && p(y, f);
385
+ }
386
+ function p(y, f) {
387
+ return p = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(u, n) {
388
+ return u.__proto__ = n, u;
389
+ }, p(y, f);
390
+ }
391
+ function c(y) {
392
+ var f = P();
393
+ return function() {
394
+ var u = w(y), n;
395
+ if (f) {
396
+ var a = w(this).constructor;
397
+ n = Reflect.construct(u, arguments, a);
398
+ } else
399
+ n = u.apply(this, arguments);
400
+ return v(this, n);
401
+ };
402
+ }
403
+ function v(y, f) {
404
+ if (f && (g(f) === "object" || typeof f == "function"))
405
+ return f;
406
+ if (f !== void 0)
407
+ throw new TypeError("Derived constructors may only return object or undefined");
408
+ return d(y);
409
+ }
410
+ function d(y) {
411
+ if (y === void 0)
412
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
413
+ return y;
414
+ }
415
+ function P() {
416
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
417
+ if (typeof Proxy == "function") return !0;
418
+ try {
419
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
420
+ })), !0;
421
+ } catch {
422
+ return !1;
423
+ }
424
+ }
425
+ function w(y) {
426
+ return w = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(m) {
427
+ return m.__proto__ || Object.getPrototypeOf(m);
428
+ }, w(y);
429
+ }
430
+ var k = /* @__PURE__ */ function(y) {
431
+ _(m, y);
432
+ var f = c(m);
433
+ function m(u, n) {
434
+ var a;
435
+ return x(this, m), a = f.call(this), a.container = W.withOrientation(u, n.vertical), a.params = n, a.width = 0, a.height = n.height * a.params.pixelRatio, a.lastPos = 0, a.wrapper = null, a;
436
+ }
437
+ return b(m, [{
438
+ key: "style",
439
+ value: function(n, a) {
440
+ return W.style(n, a);
441
+ }
442
+ /**
443
+ * Create the wrapper `<wave>` element, style it and set up the events for
444
+ * interaction
445
+ */
446
+ }, {
447
+ key: "createWrapper",
448
+ value: function() {
449
+ this.wrapper = W.withOrientation(this.container.appendChild(document.createElement("wave")), this.params.vertical), this.style(this.wrapper, {
450
+ display: "block",
451
+ position: "relative",
452
+ userSelect: "none",
453
+ webkitUserSelect: "none",
454
+ height: this.params.height + "px"
455
+ }), (this.params.fillParent || this.params.scrollParent) && this.style(this.wrapper, {
456
+ width: "100%",
457
+ cursor: this.params.hideCursor ? "none" : "auto",
458
+ overflowX: this.params.hideScrollbar ? "hidden" : "auto",
459
+ overflowY: "hidden"
460
+ }), this.setupWrapperEvents();
461
+ }
462
+ /**
463
+ * Handle click event
464
+ *
465
+ * @param {Event} e Click event
466
+ * @param {?boolean} noPrevent Set to true to not call `e.preventDefault()`
467
+ * @return {number} Playback position from 0 to 1
468
+ */
469
+ }, {
470
+ key: "handleEvent",
471
+ value: function(n, a) {
472
+ !a && n.preventDefault();
473
+ var o = W.withOrientation(n.targetTouches ? n.targetTouches[0] : n, this.params.vertical).clientX, r = this.wrapper.getBoundingClientRect(), t = this.width, s = this.getWidth(), i = this.getProgressPixels(r, o), e;
474
+ return !this.params.fillParent && t < s ? e = i * (this.params.pixelRatio / t) || 0 : e = (i + this.wrapper.scrollLeft) / this.wrapper.scrollWidth || 0, W.clamp(e, 0, 1);
475
+ }
476
+ }, {
477
+ key: "getProgressPixels",
478
+ value: function(n, a) {
479
+ return this.params.rtl ? n.right - a : a - n.left;
480
+ }
481
+ }, {
482
+ key: "setupWrapperEvents",
483
+ value: function() {
484
+ var n = this;
485
+ this.wrapper.addEventListener("click", function(a) {
486
+ var o = W.withOrientation(a, n.params.vertical), r = n.wrapper.offsetHeight - n.wrapper.clientHeight;
487
+ if (r !== 0) {
488
+ var t = n.wrapper.getBoundingClientRect();
489
+ if (o.clientY >= t.bottom - r)
490
+ return;
491
+ }
492
+ n.params.interact && n.fireEvent("click", a, n.handleEvent(a));
493
+ }), this.wrapper.addEventListener("dblclick", function(a) {
494
+ n.params.interact && n.fireEvent("dblclick", a, n.handleEvent(a));
495
+ }), this.wrapper.addEventListener("scroll", function(a) {
496
+ return n.fireEvent("scroll", a);
497
+ });
498
+ }
499
+ /**
500
+ * Draw peaks on the canvas
501
+ *
502
+ * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
503
+ * for split channel rendering
504
+ * @param {number} length The width of the area that should be drawn
505
+ * @param {number} start The x-offset of the beginning of the area that
506
+ * should be rendered
507
+ * @param {number} end The x-offset of the end of the area that should be
508
+ * rendered
509
+ */
510
+ }, {
511
+ key: "drawPeaks",
512
+ value: function(n, a, o, r) {
513
+ this.setWidth(a) || this.clearWave(), this.params.barWidth ? this.drawBars(n, 0, o, r) : this.drawWave(n, 0, o, r);
514
+ }
515
+ /**
516
+ * Scroll to the beginning
517
+ */
518
+ }, {
519
+ key: "resetScroll",
520
+ value: function() {
521
+ this.wrapper !== null && (this.wrapper.scrollLeft = 0);
522
+ }
523
+ /**
524
+ * Recenter the view-port at a certain percent of the waveform
525
+ *
526
+ * @param {number} percent Value from 0 to 1 on the waveform
527
+ */
528
+ }, {
529
+ key: "recenter",
530
+ value: function(n) {
531
+ var a = this.wrapper.scrollWidth * n;
532
+ this.recenterOnPosition(a, !0);
533
+ }
534
+ /**
535
+ * Recenter the view-port on a position, either scroll there immediately or
536
+ * in steps of 5 pixels
537
+ *
538
+ * @param {number} position X-offset in pixels
539
+ * @param {boolean} immediate Set to true to immediately scroll somewhere
540
+ */
541
+ }, {
542
+ key: "recenterOnPosition",
543
+ value: function(n, a) {
544
+ var o = this.wrapper.scrollLeft, r = ~~(this.wrapper.clientWidth / 2), t = this.wrapper.scrollWidth - this.wrapper.clientWidth, s = n - r, i = s - o;
545
+ if (t != 0) {
546
+ if (!a && -r <= i && i < r) {
547
+ var e = this.params.autoCenterRate;
548
+ e /= r, e *= t, i = Math.max(-e, Math.min(e, i)), s = o + i;
549
+ }
550
+ s = Math.max(0, Math.min(t, s)), s != o && (this.wrapper.scrollLeft = s);
551
+ }
552
+ }
553
+ /**
554
+ * Get the current scroll position in pixels
555
+ *
556
+ * @return {number} Horizontal scroll position in pixels
557
+ */
558
+ }, {
559
+ key: "getScrollX",
560
+ value: function() {
561
+ var n = 0;
562
+ if (this.wrapper) {
563
+ var a = this.params.pixelRatio;
564
+ if (n = Math.round(this.wrapper.scrollLeft * a), this.params.scrollParent) {
565
+ var o = ~~(this.wrapper.scrollWidth * a - this.getWidth());
566
+ n = Math.min(o, Math.max(0, n));
567
+ }
568
+ }
569
+ return n;
570
+ }
571
+ /**
572
+ * Get the width of the container
573
+ *
574
+ * @return {number} The width of the container
575
+ */
576
+ }, {
577
+ key: "getWidth",
578
+ value: function() {
579
+ return Math.round(this.container.clientWidth * this.params.pixelRatio);
580
+ }
581
+ /**
582
+ * Set the width of the container
583
+ *
584
+ * @param {number} width The new width of the container
585
+ * @return {boolean} Whether the width of the container was updated or not
586
+ */
587
+ }, {
588
+ key: "setWidth",
589
+ value: function(n) {
590
+ if (this.width == n)
591
+ return !1;
592
+ if (this.width = n, this.params.fillParent || this.params.scrollParent)
593
+ this.style(this.wrapper, {
594
+ width: ""
595
+ });
596
+ else {
597
+ var a = ~~(this.width / this.params.pixelRatio) + "px";
598
+ this.style(this.wrapper, {
599
+ width: a
600
+ });
601
+ }
602
+ return this.updateSize(), !0;
603
+ }
604
+ /**
605
+ * Set the height of the container
606
+ *
607
+ * @param {number} height The new height of the container.
608
+ * @return {boolean} Whether the height of the container was updated or not
609
+ */
610
+ }, {
611
+ key: "setHeight",
612
+ value: function(n) {
613
+ return n == this.height ? !1 : (this.height = n, this.style(this.wrapper, {
614
+ height: ~~(this.height / this.params.pixelRatio) + "px"
615
+ }), this.updateSize(), !0);
616
+ }
617
+ /**
618
+ * Called by wavesurfer when progress should be rendered
619
+ *
620
+ * @param {number} progress From 0 to 1
621
+ */
622
+ }, {
623
+ key: "progress",
624
+ value: function(n) {
625
+ var a = 1 / this.params.pixelRatio, o = Math.round(n * this.width) * a;
626
+ if (o < this.lastPos || o - this.lastPos >= a) {
627
+ if (this.lastPos = o, this.params.scrollParent && this.params.autoCenter) {
628
+ var r = ~~(this.wrapper.scrollWidth * n);
629
+ this.recenterOnPosition(r, this.params.autoCenterImmediately);
630
+ }
631
+ this.updateProgress(o);
632
+ }
633
+ }
634
+ /**
635
+ * This is called when wavesurfer is destroyed
636
+ */
637
+ }, {
638
+ key: "destroy",
639
+ value: function() {
640
+ this.unAll(), this.wrapper && (this.wrapper.parentNode == this.container.domElement && this.container.removeChild(this.wrapper.domElement), this.wrapper = null);
641
+ }
642
+ /* Renderer-specific methods */
643
+ /**
644
+ * Called after cursor related params have changed.
645
+ *
646
+ * @abstract
647
+ */
648
+ }, {
649
+ key: "updateCursor",
650
+ value: function() {
651
+ }
652
+ /**
653
+ * Called when the size of the container changes so the renderer can adjust
654
+ *
655
+ * @abstract
656
+ */
657
+ }, {
658
+ key: "updateSize",
659
+ value: function() {
660
+ }
661
+ /**
662
+ * Draw a waveform with bars
663
+ *
664
+ * @abstract
665
+ * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays for split channel
666
+ * rendering
667
+ * @param {number} channelIndex The index of the current channel. Normally
668
+ * should be 0
669
+ * @param {number} start The x-offset of the beginning of the area that
670
+ * should be rendered
671
+ * @param {number} end The x-offset of the end of the area that should be
672
+ * rendered
673
+ */
674
+ }, {
675
+ key: "drawBars",
676
+ value: function(n, a, o, r) {
677
+ }
678
+ /**
679
+ * Draw a waveform
680
+ *
681
+ * @abstract
682
+ * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays for split channel
683
+ * rendering
684
+ * @param {number} channelIndex The index of the current channel. Normally
685
+ * should be 0
686
+ * @param {number} start The x-offset of the beginning of the area that
687
+ * should be rendered
688
+ * @param {number} end The x-offset of the end of the area that should be
689
+ * rendered
690
+ */
691
+ }, {
692
+ key: "drawWave",
693
+ value: function(n, a, o, r) {
694
+ }
695
+ /**
696
+ * Clear the waveform
697
+ *
698
+ * @abstract
699
+ */
700
+ }, {
701
+ key: "clearWave",
702
+ value: function() {
703
+ }
704
+ /**
705
+ * Render the new progress
706
+ *
707
+ * @abstract
708
+ * @param {number} position X-Offset of progress position in pixels
709
+ */
710
+ }, {
711
+ key: "updateProgress",
712
+ value: function(n) {
713
+ }
714
+ }]), m;
715
+ }(W.Observer);
716
+ h.default = k, j.exports = h.default;
717
+ }
718
+ ),
719
+ /***/
720
+ "./src/drawer.multicanvas.js": (
721
+ /*!***********************************!*\
722
+ !*** ./src/drawer.multicanvas.js ***!
723
+ \***********************************/
724
+ /***/
725
+ (j, h, C) => {
726
+ function g(u) {
727
+ "@babel/helpers - typeof";
728
+ return g = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
729
+ return typeof n;
730
+ } : function(n) {
731
+ return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
732
+ }, g(u);
733
+ }
734
+ Object.defineProperty(h, "__esModule", {
735
+ value: !0
736
+ }), h.default = void 0;
737
+ var W = b(C(
738
+ /*! ./drawer */
739
+ "./src/drawer.js"
740
+ )), E = I(C(
741
+ /*! ./util */
742
+ "./src/util/index.js"
743
+ )), M = b(C(
744
+ /*! ./drawer.canvasentry */
745
+ "./src/drawer.canvasentry.js"
746
+ ));
747
+ function x(u) {
748
+ if (typeof WeakMap != "function") return null;
749
+ var n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap();
750
+ return (x = function(r) {
751
+ return r ? a : n;
752
+ })(u);
753
+ }
754
+ function I(u, n) {
755
+ if (u && u.__esModule)
756
+ return u;
757
+ if (u === null || g(u) !== "object" && typeof u != "function")
758
+ return { default: u };
759
+ var a = x(n);
760
+ if (a && a.has(u))
761
+ return a.get(u);
762
+ var o = {}, r = Object.defineProperty && Object.getOwnPropertyDescriptor;
763
+ for (var t in u)
764
+ if (t !== "default" && Object.prototype.hasOwnProperty.call(u, t)) {
765
+ var s = r ? Object.getOwnPropertyDescriptor(u, t) : null;
766
+ s && (s.get || s.set) ? Object.defineProperty(o, t, s) : o[t] = u[t];
767
+ }
768
+ return o.default = u, a && a.set(u, o), o;
769
+ }
770
+ function b(u) {
771
+ return u && u.__esModule ? u : { default: u };
772
+ }
773
+ function O(u, n) {
774
+ if (!(u instanceof n))
775
+ throw new TypeError("Cannot call a class as a function");
776
+ }
777
+ function R(u, n) {
778
+ for (var a = 0; a < n.length; a++) {
779
+ var o = n[a];
780
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(u, p(o.key), o);
781
+ }
782
+ }
783
+ function _(u, n, a) {
784
+ return n && R(u.prototype, n), Object.defineProperty(u, "prototype", { writable: !1 }), u;
785
+ }
786
+ function p(u) {
787
+ var n = c(u, "string");
788
+ return g(n) === "symbol" ? n : String(n);
789
+ }
790
+ function c(u, n) {
791
+ if (g(u) !== "object" || u === null) return u;
792
+ var a = u[Symbol.toPrimitive];
793
+ if (a !== void 0) {
794
+ var o = a.call(u, n);
795
+ if (g(o) !== "object") return o;
796
+ throw new TypeError("@@toPrimitive must return a primitive value.");
797
+ }
798
+ return String(u);
799
+ }
800
+ function v(u, n) {
801
+ if (typeof n != "function" && n !== null)
802
+ throw new TypeError("Super expression must either be null or a function");
803
+ u.prototype = Object.create(n && n.prototype, { constructor: { value: u, writable: !0, configurable: !0 } }), Object.defineProperty(u, "prototype", { writable: !1 }), n && d(u, n);
804
+ }
805
+ function d(u, n) {
806
+ return d = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, r) {
807
+ return o.__proto__ = r, o;
808
+ }, d(u, n);
809
+ }
810
+ function P(u) {
811
+ var n = y();
812
+ return function() {
813
+ var o = f(u), r;
814
+ if (n) {
815
+ var t = f(this).constructor;
816
+ r = Reflect.construct(o, arguments, t);
817
+ } else
818
+ r = o.apply(this, arguments);
819
+ return w(this, r);
820
+ };
821
+ }
822
+ function w(u, n) {
823
+ if (n && (g(n) === "object" || typeof n == "function"))
824
+ return n;
825
+ if (n !== void 0)
826
+ throw new TypeError("Derived constructors may only return object or undefined");
827
+ return k(u);
828
+ }
829
+ function k(u) {
830
+ if (u === void 0)
831
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
832
+ return u;
833
+ }
834
+ function y() {
835
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
836
+ if (typeof Proxy == "function") return !0;
837
+ try {
838
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
839
+ })), !0;
840
+ } catch {
841
+ return !1;
842
+ }
843
+ }
844
+ function f(u) {
845
+ return f = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(a) {
846
+ return a.__proto__ || Object.getPrototypeOf(a);
847
+ }, f(u);
848
+ }
849
+ var m = /* @__PURE__ */ function(u) {
850
+ v(a, u);
851
+ var n = P(a);
852
+ function a(o, r) {
853
+ var t;
854
+ return O(this, a), t = n.call(this, o, r), t.maxCanvasWidth = r.maxCanvasWidth, t.maxCanvasElementWidth = Math.round(r.maxCanvasWidth / r.pixelRatio), t.hasProgressCanvas = r.waveColor != r.progressColor, t.halfPixel = 0.5 / r.pixelRatio, t.canvases = [], t.progressWave = null, t.EntryClass = M.default, t.canvasContextAttributes = r.drawingContextAttributes, t.overlap = 2 * Math.ceil(r.pixelRatio / 2), t.barRadius = r.barRadius || 0, t.vertical = r.vertical, t;
855
+ }
856
+ return _(a, [{
857
+ key: "init",
858
+ value: function() {
859
+ this.createWrapper(), this.createElements();
860
+ }
861
+ /**
862
+ * Create the canvas elements and style them
863
+ *
864
+ */
865
+ }, {
866
+ key: "createElements",
867
+ value: function() {
868
+ this.progressWave = E.withOrientation(this.wrapper.appendChild(document.createElement("wave")), this.params.vertical), this.style(this.progressWave, {
869
+ position: "absolute",
870
+ zIndex: 3,
871
+ left: 0,
872
+ top: 0,
873
+ bottom: 0,
874
+ overflow: "hidden",
875
+ width: "0",
876
+ display: "none",
877
+ boxSizing: "border-box",
878
+ borderRightStyle: "solid",
879
+ pointerEvents: "none"
880
+ }), this.addCanvas(), this.updateCursor();
881
+ }
882
+ /**
883
+ * Update cursor style
884
+ */
885
+ }, {
886
+ key: "updateCursor",
887
+ value: function() {
888
+ this.style(this.progressWave, {
889
+ borderRightWidth: this.params.cursorWidth + "px",
890
+ borderRightColor: this.params.cursorColor
891
+ });
892
+ }
893
+ /**
894
+ * Adjust to the updated size by adding or removing canvases
895
+ */
896
+ }, {
897
+ key: "updateSize",
898
+ value: function() {
899
+ for (var r = this, t = Math.round(this.width / this.params.pixelRatio), s = Math.ceil(t / (this.maxCanvasElementWidth + this.overlap)); this.canvases.length < s; )
900
+ this.addCanvas();
901
+ for (; this.canvases.length > s; )
902
+ this.removeCanvas();
903
+ var i = this.maxCanvasWidth + this.overlap, e = this.canvases.length - 1;
904
+ this.canvases.forEach(function(l, A) {
905
+ A == e && (i = r.width - r.maxCanvasWidth * e), r.updateDimensions(l, i, r.height), l.clearWave();
906
+ });
907
+ }
908
+ /**
909
+ * Add a canvas to the canvas list
910
+ *
911
+ */
912
+ }, {
913
+ key: "addCanvas",
914
+ value: function() {
915
+ var r = new this.EntryClass();
916
+ r.canvasContextAttributes = this.canvasContextAttributes, r.hasProgressCanvas = this.hasProgressCanvas, r.halfPixel = this.halfPixel;
917
+ var t = this.maxCanvasElementWidth * this.canvases.length, s = E.withOrientation(this.wrapper.appendChild(document.createElement("canvas")), this.params.vertical);
918
+ if (this.style(s, {
919
+ position: "absolute",
920
+ zIndex: 2,
921
+ left: t + "px",
922
+ top: 0,
923
+ bottom: 0,
924
+ height: "100%",
925
+ pointerEvents: "none"
926
+ }), r.initWave(s), this.hasProgressCanvas) {
927
+ var i = E.withOrientation(this.progressWave.appendChild(document.createElement("canvas")), this.params.vertical);
928
+ this.style(i, {
929
+ position: "absolute",
930
+ left: t + "px",
931
+ top: 0,
932
+ bottom: 0,
933
+ height: "100%"
934
+ }), r.initProgress(i);
935
+ }
936
+ this.canvases.push(r);
937
+ }
938
+ /**
939
+ * Pop single canvas from the list
940
+ *
941
+ */
942
+ }, {
943
+ key: "removeCanvas",
944
+ value: function() {
945
+ var r = this.canvases[this.canvases.length - 1];
946
+ r.wave.parentElement.removeChild(r.wave.domElement), this.hasProgressCanvas && r.progress.parentElement.removeChild(r.progress.domElement), r && (r.destroy(), r = null), this.canvases.pop();
947
+ }
948
+ /**
949
+ * Update the dimensions of a canvas element
950
+ *
951
+ * @param {CanvasEntry} entry Target entry
952
+ * @param {number} width The new width of the element
953
+ * @param {number} height The new height of the element
954
+ */
955
+ }, {
956
+ key: "updateDimensions",
957
+ value: function(r, t, s) {
958
+ var i = Math.round(t / this.params.pixelRatio), e = Math.round(this.width / this.params.pixelRatio);
959
+ r.updateDimensions(i, e, t, s), this.style(this.progressWave, {
960
+ display: "block"
961
+ });
962
+ }
963
+ /**
964
+ * Clear the whole multi-canvas
965
+ */
966
+ }, {
967
+ key: "clearWave",
968
+ value: function() {
969
+ var r = this;
970
+ E.frame(function() {
971
+ r.canvases.forEach(function(t) {
972
+ return t.clearWave();
973
+ });
974
+ })();
975
+ }
976
+ /**
977
+ * Draw a waveform with bars
978
+ *
979
+ * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
980
+ * for split channel rendering
981
+ * @param {number} channelIndex The index of the current channel. Normally
982
+ * should be 0. Must be an integer.
983
+ * @param {number} start The x-offset of the beginning of the area that
984
+ * should be rendered
985
+ * @param {number} end The x-offset of the end of the area that should be
986
+ * rendered
987
+ * @returns {void}
988
+ */
989
+ }, {
990
+ key: "drawBars",
991
+ value: function(r, t, s, i) {
992
+ var e = this;
993
+ return this.prepareDraw(r, t, s, i, function(l) {
994
+ var A = l.absmax, T = l.hasMinVals;
995
+ l.height;
996
+ var S = l.offsetY, D = l.halfH, B = l.peaks, V = l.channelIndex;
997
+ if (s !== void 0) {
998
+ var N = T ? 2 : 1, H = B.length / N, L = e.params.barWidth * e.params.pixelRatio, U = e.params.barGap === null ? Math.max(e.params.pixelRatio, ~~(L / 2)) : Math.max(e.params.pixelRatio, e.params.barGap * e.params.pixelRatio), F = L + U, z = H / e.width, ie = s, ae = i, Y = ie;
999
+ for (Y; Y < ae; Y += F) {
1000
+ var $ = 0, ee = Math.floor(Y * z) * N, se = Math.floor((Y + F) * z) * N;
1001
+ do {
1002
+ var te = Math.abs(B[ee]);
1003
+ te > $ && ($ = te), ee += N;
1004
+ } while (ee < se);
1005
+ var J = Math.round($ / A * D);
1006
+ e.params.barMinHeight && (J = Math.max(J, e.params.barMinHeight)), e.fillRect(Y + e.halfPixel, D - J + S, L + e.halfPixel, J * 2, e.barRadius, V);
1007
+ }
1008
+ }
1009
+ });
1010
+ }
1011
+ /**
1012
+ * Draw a waveform
1013
+ *
1014
+ * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
1015
+ * for split channel rendering
1016
+ * @param {number} channelIndex The index of the current channel. Normally
1017
+ * should be 0
1018
+ * @param {number?} start The x-offset of the beginning of the area that
1019
+ * should be rendered (If this isn't set only a flat line is rendered)
1020
+ * @param {number?} end The x-offset of the end of the area that should be
1021
+ * rendered
1022
+ * @returns {void}
1023
+ */
1024
+ }, {
1025
+ key: "drawWave",
1026
+ value: function(r, t, s, i) {
1027
+ var e = this;
1028
+ return this.prepareDraw(r, t, s, i, function(l) {
1029
+ var A = l.absmax, T = l.hasMinVals;
1030
+ l.height;
1031
+ var S = l.offsetY, D = l.halfH, B = l.peaks, V = l.channelIndex;
1032
+ if (!T) {
1033
+ var N = [], H = B.length, L = 0;
1034
+ for (L; L < H; L++)
1035
+ N[2 * L] = B[L], N[2 * L + 1] = -B[L];
1036
+ B = N;
1037
+ }
1038
+ s !== void 0 && e.drawLine(B, A, D, S, s, i, V), e.fillRect(0, D + S - e.halfPixel, e.width, e.halfPixel, e.barRadius, V);
1039
+ });
1040
+ }
1041
+ /**
1042
+ * Tell the canvas entries to render their portion of the waveform
1043
+ *
1044
+ * @param {number[]} peaks Peaks data
1045
+ * @param {number} absmax Maximum peak value (absolute)
1046
+ * @param {number} halfH Half the height of the waveform
1047
+ * @param {number} offsetY Offset to the top
1048
+ * @param {number} start The x-offset of the beginning of the area that
1049
+ * should be rendered
1050
+ * @param {number} end The x-offset of the end of the area that
1051
+ * should be rendered
1052
+ * @param {channelIndex} channelIndex The channel index of the line drawn
1053
+ */
1054
+ }, {
1055
+ key: "drawLine",
1056
+ value: function(r, t, s, i, e, l, A) {
1057
+ var T = this, S = this.params.splitChannelsOptions.channelColors[A] || {}, D = S.waveColor, B = S.progressColor;
1058
+ this.canvases.forEach(function(V, N) {
1059
+ T.setFillStyles(V, D, B), T.applyCanvasTransforms(V, T.params.vertical), V.drawLines(r, t, s, i, e, l);
1060
+ });
1061
+ }
1062
+ /**
1063
+ * Draw a rectangle on the multi-canvas
1064
+ *
1065
+ * @param {number} x X-position of the rectangle
1066
+ * @param {number} y Y-position of the rectangle
1067
+ * @param {number} width Width of the rectangle
1068
+ * @param {number} height Height of the rectangle
1069
+ * @param {number} radius Radius of the rectangle
1070
+ * @param {channelIndex} channelIndex The channel index of the bar drawn
1071
+ */
1072
+ }, {
1073
+ key: "fillRect",
1074
+ value: function(r, t, s, i, e, l) {
1075
+ var A = Math.floor(r / this.maxCanvasWidth), T = Math.min(Math.ceil((r + s) / this.maxCanvasWidth) + 1, this.canvases.length), S = A;
1076
+ for (S; S < T; S++) {
1077
+ var D = this.canvases[S], B = S * this.maxCanvasWidth, V = {
1078
+ x1: Math.max(r, S * this.maxCanvasWidth),
1079
+ y1: t,
1080
+ x2: Math.min(r + s, S * this.maxCanvasWidth + D.wave.width),
1081
+ y2: t + i
1082
+ };
1083
+ if (V.x1 < V.x2) {
1084
+ var N = this.params.splitChannelsOptions.channelColors[l] || {}, H = N.waveColor, L = N.progressColor;
1085
+ this.setFillStyles(D, H, L), this.applyCanvasTransforms(D, this.params.vertical), D.fillRects(V.x1 - B, V.y1, V.x2 - V.x1, V.y2 - V.y1, e);
1086
+ }
1087
+ }
1088
+ }
1089
+ /**
1090
+ * Returns whether to hide the channel from being drawn based on params.
1091
+ *
1092
+ * @param {number} channelIndex The index of the current channel.
1093
+ * @returns {bool} True to hide the channel, false to draw.
1094
+ */
1095
+ }, {
1096
+ key: "hideChannel",
1097
+ value: function(r) {
1098
+ return this.params.splitChannels && this.params.splitChannelsOptions.filterChannels.includes(r);
1099
+ }
1100
+ /**
1101
+ * Performs preparation tasks and calculations which are shared by `drawBars`
1102
+ * and `drawWave`
1103
+ *
1104
+ * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays for
1105
+ * split channel rendering
1106
+ * @param {number} channelIndex The index of the current channel. Normally
1107
+ * should be 0
1108
+ * @param {number?} start The x-offset of the beginning of the area that
1109
+ * should be rendered. If this isn't set only a flat line is rendered
1110
+ * @param {number?} end The x-offset of the end of the area that should be
1111
+ * rendered
1112
+ * @param {function} fn The render function to call, e.g. `drawWave`
1113
+ * @param {number} drawIndex The index of the current channel after filtering.
1114
+ * @param {number?} normalizedMax Maximum modulation value across channels for use with relativeNormalization. Ignored when undefined
1115
+ * @returns {void}
1116
+ */
1117
+ }, {
1118
+ key: "prepareDraw",
1119
+ value: function(r, t, s, i, e, l, A) {
1120
+ var T = this;
1121
+ return E.frame(function() {
1122
+ if (r[0] instanceof Array) {
1123
+ var S = r;
1124
+ if (T.params.splitChannels) {
1125
+ var D = S.filter(function(F, z) {
1126
+ return !T.hideChannel(z);
1127
+ });
1128
+ T.params.splitChannelsOptions.overlay || T.setHeight(Math.max(D.length, 1) * T.params.height * T.params.pixelRatio);
1129
+ var B;
1130
+ return T.params.splitChannelsOptions && T.params.splitChannelsOptions.relativeNormalization && (B = E.max(S.map(function(F) {
1131
+ return E.absMax(F);
1132
+ }))), S.forEach(function(F, z) {
1133
+ return T.prepareDraw(F, z, s, i, e, D.indexOf(F), B);
1134
+ });
1135
+ }
1136
+ r = S[0];
1137
+ }
1138
+ if (!T.hideChannel(t)) {
1139
+ var V = 1 / T.params.barHeight;
1140
+ T.params.normalize && (V = A === void 0 ? E.absMax(r) : A);
1141
+ var N = [].some.call(r, function(F) {
1142
+ return F < 0;
1143
+ }), H = T.params.height * T.params.pixelRatio, L = H / 2, U = H * l || 0;
1144
+ return T.params.splitChannelsOptions && T.params.splitChannelsOptions.overlay && (U = 0), e({
1145
+ absmax: V,
1146
+ hasMinVals: N,
1147
+ height: H,
1148
+ offsetY: U,
1149
+ halfH: L,
1150
+ peaks: r,
1151
+ channelIndex: t
1152
+ });
1153
+ }
1154
+ })();
1155
+ }
1156
+ /**
1157
+ * Set the fill styles for a certain entry (wave and progress)
1158
+ *
1159
+ * @param {CanvasEntry} entry Target entry
1160
+ * @param {string} waveColor Wave color to draw this entry
1161
+ * @param {string} progressColor Progress color to draw this entry
1162
+ */
1163
+ }, {
1164
+ key: "setFillStyles",
1165
+ value: function(r) {
1166
+ var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.params.waveColor, s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : this.params.progressColor;
1167
+ r.setFillStyles(t, s);
1168
+ }
1169
+ /**
1170
+ * Set the canvas transforms for a certain entry (wave and progress)
1171
+ *
1172
+ * @param {CanvasEntry} entry Target entry
1173
+ * @param {boolean} vertical Whether to render the waveform vertically
1174
+ */
1175
+ }, {
1176
+ key: "applyCanvasTransforms",
1177
+ value: function(r) {
1178
+ var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
1179
+ r.applyCanvasTransforms(t);
1180
+ }
1181
+ /**
1182
+ * Return image data of the multi-canvas
1183
+ *
1184
+ * When using a `type` of `'blob'`, this will return a `Promise`.
1185
+ *
1186
+ * @param {string} format='image/png' An optional value of a format type.
1187
+ * @param {number} quality=0.92 An optional value between 0 and 1.
1188
+ * @param {string} type='dataURL' Either 'dataURL' or 'blob'.
1189
+ * @return {string|string[]|Promise} When using the default `'dataURL'`
1190
+ * `type` this returns a single data URL or an array of data URLs,
1191
+ * one for each canvas. When using the `'blob'` `type` this returns a
1192
+ * `Promise` that resolves with an array of `Blob` instances, one for each
1193
+ * canvas.
1194
+ */
1195
+ }, {
1196
+ key: "getImage",
1197
+ value: function(r, t, s) {
1198
+ if (s === "blob")
1199
+ return Promise.all(this.canvases.map(function(e) {
1200
+ return e.getImage(r, t, s);
1201
+ }));
1202
+ if (s === "dataURL") {
1203
+ var i = this.canvases.map(function(e) {
1204
+ return e.getImage(r, t, s);
1205
+ });
1206
+ return i.length > 1 ? i : i[0];
1207
+ }
1208
+ }
1209
+ /**
1210
+ * Render the new progress
1211
+ *
1212
+ * @param {number} position X-offset of progress position in pixels
1213
+ */
1214
+ }, {
1215
+ key: "updateProgress",
1216
+ value: function(r) {
1217
+ this.style(this.progressWave, {
1218
+ width: r + "px"
1219
+ });
1220
+ }
1221
+ }]), a;
1222
+ }(W.default);
1223
+ h.default = m, j.exports = h.default;
1224
+ }
1225
+ ),
1226
+ /***/
1227
+ "./src/mediaelement-webaudio.js": (
1228
+ /*!**************************************!*\
1229
+ !*** ./src/mediaelement-webaudio.js ***!
1230
+ \**************************************/
1231
+ /***/
1232
+ (j, h, C) => {
1233
+ function g(f) {
1234
+ "@babel/helpers - typeof";
1235
+ return g = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(m) {
1236
+ return typeof m;
1237
+ } : function(m) {
1238
+ return m && typeof Symbol == "function" && m.constructor === Symbol && m !== Symbol.prototype ? "symbol" : typeof m;
1239
+ }, g(f);
1240
+ }
1241
+ Object.defineProperty(h, "__esModule", {
1242
+ value: !0
1243
+ }), h.default = void 0;
1244
+ var W = E(C(
1245
+ /*! ./mediaelement */
1246
+ "./src/mediaelement.js"
1247
+ ));
1248
+ function E(f) {
1249
+ return f && f.__esModule ? f : { default: f };
1250
+ }
1251
+ function M(f, m) {
1252
+ if (!(f instanceof m))
1253
+ throw new TypeError("Cannot call a class as a function");
1254
+ }
1255
+ function x(f, m) {
1256
+ for (var u = 0; u < m.length; u++) {
1257
+ var n = m[u];
1258
+ n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(f, b(n.key), n);
1259
+ }
1260
+ }
1261
+ function I(f, m, u) {
1262
+ return m && x(f.prototype, m), Object.defineProperty(f, "prototype", { writable: !1 }), f;
1263
+ }
1264
+ function b(f) {
1265
+ var m = O(f, "string");
1266
+ return g(m) === "symbol" ? m : String(m);
1267
+ }
1268
+ function O(f, m) {
1269
+ if (g(f) !== "object" || f === null) return f;
1270
+ var u = f[Symbol.toPrimitive];
1271
+ if (u !== void 0) {
1272
+ var n = u.call(f, m);
1273
+ if (g(n) !== "object") return n;
1274
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1275
+ }
1276
+ return String(f);
1277
+ }
1278
+ function R() {
1279
+ return typeof Reflect < "u" && Reflect.get ? R = Reflect.get.bind() : R = function(m, u, n) {
1280
+ var a = _(m, u);
1281
+ if (a) {
1282
+ var o = Object.getOwnPropertyDescriptor(a, u);
1283
+ return o.get ? o.get.call(arguments.length < 3 ? m : n) : o.value;
1284
+ }
1285
+ }, R.apply(this, arguments);
1286
+ }
1287
+ function _(f, m) {
1288
+ for (; !Object.prototype.hasOwnProperty.call(f, m) && (f = k(f), f !== null); )
1289
+ ;
1290
+ return f;
1291
+ }
1292
+ function p(f, m) {
1293
+ if (typeof m != "function" && m !== null)
1294
+ throw new TypeError("Super expression must either be null or a function");
1295
+ f.prototype = Object.create(m && m.prototype, { constructor: { value: f, writable: !0, configurable: !0 } }), Object.defineProperty(f, "prototype", { writable: !1 }), m && c(f, m);
1296
+ }
1297
+ function c(f, m) {
1298
+ return c = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, a) {
1299
+ return n.__proto__ = a, n;
1300
+ }, c(f, m);
1301
+ }
1302
+ function v(f) {
1303
+ var m = w();
1304
+ return function() {
1305
+ var n = k(f), a;
1306
+ if (m) {
1307
+ var o = k(this).constructor;
1308
+ a = Reflect.construct(n, arguments, o);
1309
+ } else
1310
+ a = n.apply(this, arguments);
1311
+ return d(this, a);
1312
+ };
1313
+ }
1314
+ function d(f, m) {
1315
+ if (m && (g(m) === "object" || typeof m == "function"))
1316
+ return m;
1317
+ if (m !== void 0)
1318
+ throw new TypeError("Derived constructors may only return object or undefined");
1319
+ return P(f);
1320
+ }
1321
+ function P(f) {
1322
+ if (f === void 0)
1323
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1324
+ return f;
1325
+ }
1326
+ function w() {
1327
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
1328
+ if (typeof Proxy == "function") return !0;
1329
+ try {
1330
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
1331
+ })), !0;
1332
+ } catch {
1333
+ return !1;
1334
+ }
1335
+ }
1336
+ function k(f) {
1337
+ return k = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(u) {
1338
+ return u.__proto__ || Object.getPrototypeOf(u);
1339
+ }, k(f);
1340
+ }
1341
+ var y = /* @__PURE__ */ function(f) {
1342
+ p(u, f);
1343
+ var m = v(u);
1344
+ function u(n) {
1345
+ var a;
1346
+ return M(this, u), a = m.call(this, n), a.params = n, a.sourceMediaElement = null, a;
1347
+ }
1348
+ return I(u, [{
1349
+ key: "init",
1350
+ value: function() {
1351
+ this.setPlaybackRate(this.params.audioRate), this.createTimer(), this.createVolumeNode(), this.createScriptNode(), this.createAnalyserNode();
1352
+ }
1353
+ /**
1354
+ * Private method called by both `load` (from url)
1355
+ * and `loadElt` (existing media element) methods.
1356
+ *
1357
+ * @param {HTMLMediaElement} media HTML5 Audio or Video element
1358
+ * @param {number[]|Number.<Array[]>} peaks Array of peak data
1359
+ * @param {string} preload HTML 5 preload attribute value
1360
+ * @private
1361
+ */
1362
+ }, {
1363
+ key: "_load",
1364
+ value: function(a, o, r) {
1365
+ R(k(u.prototype), "_load", this).call(this, a, o, r), this.createMediaElementSource(a);
1366
+ }
1367
+ /**
1368
+ * Create MediaElementSource node
1369
+ *
1370
+ * @since 3.2.0
1371
+ * @param {HTMLMediaElement} mediaElement HTML5 Audio to load
1372
+ */
1373
+ }, {
1374
+ key: "createMediaElementSource",
1375
+ value: function(a) {
1376
+ this.sourceMediaElement = this.ac.createMediaElementSource(a), this.sourceMediaElement.connect(this.analyser);
1377
+ }
1378
+ }, {
1379
+ key: "play",
1380
+ value: function(a, o) {
1381
+ return this.resumeAudioContext(), R(k(u.prototype), "play", this).call(this, a, o);
1382
+ }
1383
+ /**
1384
+ * This is called when wavesurfer is destroyed
1385
+ *
1386
+ */
1387
+ }, {
1388
+ key: "destroy",
1389
+ value: function() {
1390
+ R(k(u.prototype), "destroy", this).call(this), this.destroyWebAudio();
1391
+ }
1392
+ }]), u;
1393
+ }(W.default);
1394
+ h.default = y, j.exports = h.default;
1395
+ }
1396
+ ),
1397
+ /***/
1398
+ "./src/mediaelement.js": (
1399
+ /*!*****************************!*\
1400
+ !*** ./src/mediaelement.js ***!
1401
+ \*****************************/
1402
+ /***/
1403
+ (j, h, C) => {
1404
+ function g(n) {
1405
+ "@babel/helpers - typeof";
1406
+ return g = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(a) {
1407
+ return typeof a;
1408
+ } : function(a) {
1409
+ return a && typeof Symbol == "function" && a.constructor === Symbol && a !== Symbol.prototype ? "symbol" : typeof a;
1410
+ }, g(n);
1411
+ }
1412
+ Object.defineProperty(h, "__esModule", {
1413
+ value: !0
1414
+ }), h.default = void 0;
1415
+ var W = I(C(
1416
+ /*! ./webaudio */
1417
+ "./src/webaudio.js"
1418
+ )), E = x(C(
1419
+ /*! ./util */
1420
+ "./src/util/index.js"
1421
+ ));
1422
+ function M(n) {
1423
+ if (typeof WeakMap != "function") return null;
1424
+ var a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap();
1425
+ return (M = function(t) {
1426
+ return t ? o : a;
1427
+ })(n);
1428
+ }
1429
+ function x(n, a) {
1430
+ if (n && n.__esModule)
1431
+ return n;
1432
+ if (n === null || g(n) !== "object" && typeof n != "function")
1433
+ return { default: n };
1434
+ var o = M(a);
1435
+ if (o && o.has(n))
1436
+ return o.get(n);
1437
+ var r = {}, t = Object.defineProperty && Object.getOwnPropertyDescriptor;
1438
+ for (var s in n)
1439
+ if (s !== "default" && Object.prototype.hasOwnProperty.call(n, s)) {
1440
+ var i = t ? Object.getOwnPropertyDescriptor(n, s) : null;
1441
+ i && (i.get || i.set) ? Object.defineProperty(r, s, i) : r[s] = n[s];
1442
+ }
1443
+ return r.default = n, o && o.set(n, r), r;
1444
+ }
1445
+ function I(n) {
1446
+ return n && n.__esModule ? n : { default: n };
1447
+ }
1448
+ function b(n, a) {
1449
+ if (!(n instanceof a))
1450
+ throw new TypeError("Cannot call a class as a function");
1451
+ }
1452
+ function O(n, a) {
1453
+ for (var o = 0; o < a.length; o++) {
1454
+ var r = a[o];
1455
+ r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(n, _(r.key), r);
1456
+ }
1457
+ }
1458
+ function R(n, a, o) {
1459
+ return a && O(n.prototype, a), Object.defineProperty(n, "prototype", { writable: !1 }), n;
1460
+ }
1461
+ function _(n) {
1462
+ var a = p(n, "string");
1463
+ return g(a) === "symbol" ? a : String(a);
1464
+ }
1465
+ function p(n, a) {
1466
+ if (g(n) !== "object" || n === null) return n;
1467
+ var o = n[Symbol.toPrimitive];
1468
+ if (o !== void 0) {
1469
+ var r = o.call(n, a);
1470
+ if (g(r) !== "object") return r;
1471
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1472
+ }
1473
+ return String(n);
1474
+ }
1475
+ function c() {
1476
+ return typeof Reflect < "u" && Reflect.get ? c = Reflect.get.bind() : c = function(a, o, r) {
1477
+ var t = v(a, o);
1478
+ if (t) {
1479
+ var s = Object.getOwnPropertyDescriptor(t, o);
1480
+ return s.get ? s.get.call(arguments.length < 3 ? a : r) : s.value;
1481
+ }
1482
+ }, c.apply(this, arguments);
1483
+ }
1484
+ function v(n, a) {
1485
+ for (; !Object.prototype.hasOwnProperty.call(n, a) && (n = m(n), n !== null); )
1486
+ ;
1487
+ return n;
1488
+ }
1489
+ function d(n, a) {
1490
+ if (typeof a != "function" && a !== null)
1491
+ throw new TypeError("Super expression must either be null or a function");
1492
+ n.prototype = Object.create(a && a.prototype, { constructor: { value: n, writable: !0, configurable: !0 } }), Object.defineProperty(n, "prototype", { writable: !1 }), a && P(n, a);
1493
+ }
1494
+ function P(n, a) {
1495
+ return P = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(r, t) {
1496
+ return r.__proto__ = t, r;
1497
+ }, P(n, a);
1498
+ }
1499
+ function w(n) {
1500
+ var a = f();
1501
+ return function() {
1502
+ var r = m(n), t;
1503
+ if (a) {
1504
+ var s = m(this).constructor;
1505
+ t = Reflect.construct(r, arguments, s);
1506
+ } else
1507
+ t = r.apply(this, arguments);
1508
+ return k(this, t);
1509
+ };
1510
+ }
1511
+ function k(n, a) {
1512
+ if (a && (g(a) === "object" || typeof a == "function"))
1513
+ return a;
1514
+ if (a !== void 0)
1515
+ throw new TypeError("Derived constructors may only return object or undefined");
1516
+ return y(n);
1517
+ }
1518
+ function y(n) {
1519
+ if (n === void 0)
1520
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1521
+ return n;
1522
+ }
1523
+ function f() {
1524
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
1525
+ if (typeof Proxy == "function") return !0;
1526
+ try {
1527
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
1528
+ })), !0;
1529
+ } catch {
1530
+ return !1;
1531
+ }
1532
+ }
1533
+ function m(n) {
1534
+ return m = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(o) {
1535
+ return o.__proto__ || Object.getPrototypeOf(o);
1536
+ }, m(n);
1537
+ }
1538
+ var u = /* @__PURE__ */ function(n) {
1539
+ d(o, n);
1540
+ var a = w(o);
1541
+ function o(r) {
1542
+ var t;
1543
+ return b(this, o), t = a.call(this, r), t.params = r, t.media = {
1544
+ currentTime: 0,
1545
+ duration: 0,
1546
+ paused: !0,
1547
+ playbackRate: 1,
1548
+ play: function() {
1549
+ },
1550
+ pause: function() {
1551
+ },
1552
+ volume: 0
1553
+ }, t.mediaType = r.mediaType.toLowerCase(), t.elementPosition = r.elementPosition, t.peaks = null, t.playbackRate = 1, t.volume = 1, t.isMuted = !1, t.buffer = null, t.onPlayEnd = null, t.mediaListeners = {}, t;
1554
+ }
1555
+ return R(o, [{
1556
+ key: "init",
1557
+ value: function() {
1558
+ this.setPlaybackRate(this.params.audioRate), this.createTimer();
1559
+ }
1560
+ /**
1561
+ * Attach event listeners to media element.
1562
+ */
1563
+ }, {
1564
+ key: "_setupMediaListeners",
1565
+ value: function() {
1566
+ var t = this;
1567
+ this.mediaListeners.error = function() {
1568
+ t.fireEvent("error", "Error loading media element");
1569
+ }, this.mediaListeners.waiting = function() {
1570
+ t.fireEvent("waiting");
1571
+ }, this.mediaListeners.canplay = function() {
1572
+ t.fireEvent("canplay");
1573
+ }, this.mediaListeners.ended = function() {
1574
+ t.fireEvent("finish");
1575
+ }, this.mediaListeners.play = function() {
1576
+ t.fireEvent("play");
1577
+ }, this.mediaListeners.pause = function() {
1578
+ t.fireEvent("pause");
1579
+ }, this.mediaListeners.seeked = function(s) {
1580
+ t.fireEvent("seek");
1581
+ }, this.mediaListeners.volumechange = function(s) {
1582
+ t.isMuted = t.media.muted, t.isMuted ? t.volume = 0 : t.volume = t.media.volume, t.fireEvent("volume");
1583
+ }, Object.keys(this.mediaListeners).forEach(function(s) {
1584
+ t.media.removeEventListener(s, t.mediaListeners[s]), t.media.addEventListener(s, t.mediaListeners[s]);
1585
+ });
1586
+ }
1587
+ /**
1588
+ * Create a timer to provide a more precise `audioprocess` event.
1589
+ */
1590
+ }, {
1591
+ key: "createTimer",
1592
+ value: function() {
1593
+ var t = this, s = function i() {
1594
+ t.isPaused() || (t.fireEvent("audioprocess", t.getCurrentTime()), E.frame(i)());
1595
+ };
1596
+ this.on("play", s), this.on("pause", function() {
1597
+ t.fireEvent("audioprocess", t.getCurrentTime());
1598
+ });
1599
+ }
1600
+ /**
1601
+ * Create media element with url as its source,
1602
+ * and append to container element.
1603
+ *
1604
+ * @param {string} url Path to media file
1605
+ * @param {HTMLElement} container HTML element
1606
+ * @param {number[]|Number.<Array[]>} peaks Array of peak data
1607
+ * @param {string} preload HTML 5 preload attribute value
1608
+ * @throws Will throw an error if the `url` argument is not a valid media
1609
+ * element.
1610
+ */
1611
+ }, {
1612
+ key: "load",
1613
+ value: function(t, s, i, e) {
1614
+ var l = document.createElement(this.mediaType);
1615
+ l.controls = this.params.mediaControls, l.autoplay = this.params.autoplay || !1, l.preload = e ?? "auto", l.src = t, l.style.width = "100%";
1616
+ var A = s.querySelector(this.mediaType);
1617
+ A && s.removeChild(A), s.appendChild(l), this._load(l, i, e);
1618
+ }
1619
+ /**
1620
+ * Load existing media element.
1621
+ *
1622
+ * @param {HTMLMediaElement} elt HTML5 Audio or Video element
1623
+ * @param {number[]|Number.<Array[]>} peaks Array of peak data
1624
+ */
1625
+ }, {
1626
+ key: "loadElt",
1627
+ value: function(t, s) {
1628
+ t.controls = this.params.mediaControls, t.autoplay = this.params.autoplay || !1, this._load(t, s, t.preload);
1629
+ }
1630
+ /**
1631
+ * Method called by both `load` (from url)
1632
+ * and `loadElt` (existing media element) methods.
1633
+ *
1634
+ * @param {HTMLMediaElement} media HTML5 Audio or Video element
1635
+ * @param {number[]|Number.<Array[]>} peaks Array of peak data
1636
+ * @param {string} preload HTML 5 preload attribute value
1637
+ * @throws Will throw an error if the `media` argument is not a valid media
1638
+ * element.
1639
+ * @private
1640
+ */
1641
+ }, {
1642
+ key: "_load",
1643
+ value: function(t, s, i) {
1644
+ if (!(t instanceof HTMLMediaElement) || typeof t.addEventListener > "u")
1645
+ throw new Error("media parameter is not a valid media element");
1646
+ typeof t.load == "function" && !(s && i == "none") && t.load(), this.media = t, this._setupMediaListeners(), this.peaks = s, this.onPlayEnd = null, this.buffer = null, this.isMuted = t.muted, this.setPlaybackRate(this.playbackRate), this.setVolume(this.volume);
1647
+ }
1648
+ /**
1649
+ * Used by `wavesurfer.isPlaying()` and `wavesurfer.playPause()`
1650
+ *
1651
+ * @return {boolean} Media paused or not
1652
+ */
1653
+ }, {
1654
+ key: "isPaused",
1655
+ value: function() {
1656
+ return !this.media || this.media.paused;
1657
+ }
1658
+ /**
1659
+ * Used by `wavesurfer.getDuration()`
1660
+ *
1661
+ * @return {number} Duration
1662
+ */
1663
+ }, {
1664
+ key: "getDuration",
1665
+ value: function() {
1666
+ if (this.explicitDuration)
1667
+ return this.explicitDuration;
1668
+ var t = (this.buffer || this.media).duration;
1669
+ return t >= 1 / 0 && (t = this.media.seekable.end(0)), t;
1670
+ }
1671
+ /**
1672
+ * Returns the current time in seconds relative to the audio-clip's
1673
+ * duration.
1674
+ *
1675
+ * @return {number} Current time
1676
+ */
1677
+ }, {
1678
+ key: "getCurrentTime",
1679
+ value: function() {
1680
+ return this.media && this.media.currentTime;
1681
+ }
1682
+ /**
1683
+ * Get the position from 0 to 1
1684
+ *
1685
+ * @return {number} Current position
1686
+ */
1687
+ }, {
1688
+ key: "getPlayedPercents",
1689
+ value: function() {
1690
+ return this.getCurrentTime() / this.getDuration() || 0;
1691
+ }
1692
+ /**
1693
+ * Get the audio source playback rate.
1694
+ *
1695
+ * @return {number} Playback rate
1696
+ */
1697
+ }, {
1698
+ key: "getPlaybackRate",
1699
+ value: function() {
1700
+ return this.playbackRate || this.media.playbackRate;
1701
+ }
1702
+ /**
1703
+ * Set the audio source playback rate.
1704
+ *
1705
+ * @param {number} value Playback rate
1706
+ */
1707
+ }, {
1708
+ key: "setPlaybackRate",
1709
+ value: function(t) {
1710
+ this.playbackRate = t || 1, this.media.playbackRate = this.playbackRate;
1711
+ }
1712
+ /**
1713
+ * Used by `wavesurfer.seekTo()`
1714
+ *
1715
+ * @param {number} start Position to start at in seconds
1716
+ */
1717
+ }, {
1718
+ key: "seekTo",
1719
+ value: function(t) {
1720
+ t != null && !isNaN(t) && (this.media.currentTime = t), this.clearPlayEnd();
1721
+ }
1722
+ /**
1723
+ * Plays the loaded audio region.
1724
+ *
1725
+ * @param {number} start Start offset in seconds, relative to the beginning
1726
+ * of a clip.
1727
+ * @param {number} end When to stop, relative to the beginning of a clip.
1728
+ * @emits MediaElement#play
1729
+ * @return {Promise} Result
1730
+ */
1731
+ }, {
1732
+ key: "play",
1733
+ value: function(t, s) {
1734
+ this.seekTo(t);
1735
+ var i = this.media.play();
1736
+ return s && this.setPlayEnd(s), i;
1737
+ }
1738
+ /**
1739
+ * Pauses the loaded audio.
1740
+ *
1741
+ * @emits MediaElement#pause
1742
+ * @return {Promise} Result
1743
+ */
1744
+ }, {
1745
+ key: "pause",
1746
+ value: function() {
1747
+ var t;
1748
+ return this.media && (t = this.media.pause()), this.clearPlayEnd(), t;
1749
+ }
1750
+ /**
1751
+ * Set the play end
1752
+ *
1753
+ * @param {number} end Where to end
1754
+ */
1755
+ }, {
1756
+ key: "setPlayEnd",
1757
+ value: function(t) {
1758
+ var s = this;
1759
+ this.clearPlayEnd(), this._onPlayEnd = function(i) {
1760
+ i >= t && (s.pause(), s.seekTo(t));
1761
+ }, this.on("audioprocess", this._onPlayEnd);
1762
+ }
1763
+ /** @private */
1764
+ }, {
1765
+ key: "clearPlayEnd",
1766
+ value: function() {
1767
+ this._onPlayEnd && (this.un("audioprocess", this._onPlayEnd), this._onPlayEnd = null);
1768
+ }
1769
+ /**
1770
+ * Compute the max and min value of the waveform when broken into
1771
+ * <length> subranges.
1772
+ *
1773
+ * @param {number} length How many subranges to break the waveform into.
1774
+ * @param {number} first First sample in the required range.
1775
+ * @param {number} last Last sample in the required range.
1776
+ * @return {number[]|Number.<Array[]>} Array of 2*<length> peaks or array of
1777
+ * arrays of peaks consisting of (max, min) values for each subrange.
1778
+ */
1779
+ }, {
1780
+ key: "getPeaks",
1781
+ value: function(t, s, i) {
1782
+ return this.buffer ? c(m(o.prototype), "getPeaks", this).call(this, t, s, i) : this.peaks || [];
1783
+ }
1784
+ /**
1785
+ * Set the sink id for the media player
1786
+ *
1787
+ * @param {string} deviceId String value representing audio device id.
1788
+ * @returns {Promise} A Promise that resolves to `undefined` when there
1789
+ * are no errors.
1790
+ */
1791
+ }, {
1792
+ key: "setSinkId",
1793
+ value: function(t) {
1794
+ return t ? this.media.setSinkId ? this.media.setSinkId(t) : Promise.reject(new Error("setSinkId is not supported in your browser")) : Promise.reject(new Error("Invalid deviceId: " + t));
1795
+ }
1796
+ /**
1797
+ * Get the current volume
1798
+ *
1799
+ * @return {number} value A floating point value between 0 and 1.
1800
+ */
1801
+ }, {
1802
+ key: "getVolume",
1803
+ value: function() {
1804
+ return this.volume;
1805
+ }
1806
+ /**
1807
+ * Set the audio volume
1808
+ *
1809
+ * @param {number} value A floating point value between 0 and 1.
1810
+ */
1811
+ }, {
1812
+ key: "setVolume",
1813
+ value: function(t) {
1814
+ this.volume = t, this.media.volume !== this.volume && (this.media.volume = this.volume);
1815
+ }
1816
+ /**
1817
+ * Enable or disable muted audio
1818
+ *
1819
+ * @since 4.0.0
1820
+ * @param {boolean} muted Specify `true` to mute audio.
1821
+ */
1822
+ }, {
1823
+ key: "setMute",
1824
+ value: function(t) {
1825
+ this.isMuted = this.media.muted = t;
1826
+ }
1827
+ /**
1828
+ * This is called when wavesurfer is destroyed
1829
+ *
1830
+ */
1831
+ }, {
1832
+ key: "destroy",
1833
+ value: function() {
1834
+ var t = this;
1835
+ this.pause(), this.unAll(), this.destroyed = !0, Object.keys(this.mediaListeners).forEach(function(s) {
1836
+ t.media && t.media.removeEventListener(s, t.mediaListeners[s]);
1837
+ }), this.params.removeMediaElementOnDestroy && this.media && this.media.parentNode && this.media.parentNode.removeChild(this.media), this.media = null;
1838
+ }
1839
+ }]), o;
1840
+ }(W.default);
1841
+ h.default = u, j.exports = h.default;
1842
+ }
1843
+ ),
1844
+ /***/
1845
+ "./src/peakcache.js": (
1846
+ /*!**************************!*\
1847
+ !*** ./src/peakcache.js ***!
1848
+ \**************************/
1849
+ /***/
1850
+ (j, h) => {
1851
+ Object.defineProperty(h, "__esModule", {
1852
+ value: !0
1853
+ }), h.default = void 0;
1854
+ function C(b) {
1855
+ "@babel/helpers - typeof";
1856
+ return C = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(O) {
1857
+ return typeof O;
1858
+ } : function(O) {
1859
+ return O && typeof Symbol == "function" && O.constructor === Symbol && O !== Symbol.prototype ? "symbol" : typeof O;
1860
+ }, C(b);
1861
+ }
1862
+ function g(b, O) {
1863
+ if (!(b instanceof O))
1864
+ throw new TypeError("Cannot call a class as a function");
1865
+ }
1866
+ function W(b, O) {
1867
+ for (var R = 0; R < O.length; R++) {
1868
+ var _ = O[R];
1869
+ _.enumerable = _.enumerable || !1, _.configurable = !0, "value" in _ && (_.writable = !0), Object.defineProperty(b, M(_.key), _);
1870
+ }
1871
+ }
1872
+ function E(b, O, R) {
1873
+ return O && W(b.prototype, O), Object.defineProperty(b, "prototype", { writable: !1 }), b;
1874
+ }
1875
+ function M(b) {
1876
+ var O = x(b, "string");
1877
+ return C(O) === "symbol" ? O : String(O);
1878
+ }
1879
+ function x(b, O) {
1880
+ if (C(b) !== "object" || b === null) return b;
1881
+ var R = b[Symbol.toPrimitive];
1882
+ if (R !== void 0) {
1883
+ var _ = R.call(b, O);
1884
+ if (C(_) !== "object") return _;
1885
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1886
+ }
1887
+ return String(b);
1888
+ }
1889
+ var I = /* @__PURE__ */ function() {
1890
+ function b() {
1891
+ g(this, b), this.clearPeakCache();
1892
+ }
1893
+ return E(b, [{
1894
+ key: "clearPeakCache",
1895
+ value: function() {
1896
+ this.peakCacheRanges = [], this.peakCacheLength = -1;
1897
+ }
1898
+ /**
1899
+ * Add a range of peaks to the cache
1900
+ *
1901
+ * @param {number} length The length of the range
1902
+ * @param {number} start The x offset of the start of the range
1903
+ * @param {number} end The x offset of the end of the range
1904
+ * @return {Number.<Array[]>} Array with arrays of numbers
1905
+ */
1906
+ }, {
1907
+ key: "addRangeToPeakCache",
1908
+ value: function(R, _, p) {
1909
+ R != this.peakCacheLength && (this.clearPeakCache(), this.peakCacheLength = R);
1910
+ for (var c = [], v = 0; v < this.peakCacheRanges.length && this.peakCacheRanges[v] < _; )
1911
+ v++;
1912
+ for (v % 2 == 0 && c.push(_); v < this.peakCacheRanges.length && this.peakCacheRanges[v] <= p; )
1913
+ c.push(this.peakCacheRanges[v]), v++;
1914
+ v % 2 == 0 && c.push(p), c = c.filter(function(P, w, k) {
1915
+ return w == 0 ? P != k[w + 1] : w == k.length - 1 ? P != k[w - 1] : P != k[w - 1] && P != k[w + 1];
1916
+ }), this.peakCacheRanges = this.peakCacheRanges.concat(c), this.peakCacheRanges = this.peakCacheRanges.sort(function(P, w) {
1917
+ return P - w;
1918
+ }).filter(function(P, w, k) {
1919
+ return w == 0 ? P != k[w + 1] : w == k.length - 1 ? P != k[w - 1] : P != k[w - 1] && P != k[w + 1];
1920
+ });
1921
+ var d = [];
1922
+ for (v = 0; v < c.length; v += 2)
1923
+ d.push([c[v], c[v + 1]]);
1924
+ return d;
1925
+ }
1926
+ /**
1927
+ * For testing
1928
+ *
1929
+ * @return {Number.<Array[]>} Array with arrays of numbers
1930
+ */
1931
+ }, {
1932
+ key: "getCacheRanges",
1933
+ value: function() {
1934
+ var R = [], _;
1935
+ for (_ = 0; _ < this.peakCacheRanges.length; _ += 2)
1936
+ R.push([this.peakCacheRanges[_], this.peakCacheRanges[_ + 1]]);
1937
+ return R;
1938
+ }
1939
+ }]), b;
1940
+ }();
1941
+ h.default = I, j.exports = h.default;
1942
+ }
1943
+ ),
1944
+ /***/
1945
+ "./src/util/absMax.js": (
1946
+ /*!****************************!*\
1947
+ !*** ./src/util/absMax.js ***!
1948
+ \****************************/
1949
+ /***/
1950
+ (j, h, C) => {
1951
+ Object.defineProperty(h, "__esModule", {
1952
+ value: !0
1953
+ }), h.default = M;
1954
+ var g = E(C(
1955
+ /*! ./max */
1956
+ "./src/util/max.js"
1957
+ )), W = E(C(
1958
+ /*! ./min */
1959
+ "./src/util/min.js"
1960
+ ));
1961
+ function E(x) {
1962
+ return x && x.__esModule ? x : { default: x };
1963
+ }
1964
+ function M(x) {
1965
+ var I = (0, g.default)(x), b = (0, W.default)(x);
1966
+ return -b > I ? -b : I;
1967
+ }
1968
+ j.exports = h.default;
1969
+ }
1970
+ ),
1971
+ /***/
1972
+ "./src/util/clamp.js": (
1973
+ /*!***************************!*\
1974
+ !*** ./src/util/clamp.js ***!
1975
+ \***************************/
1976
+ /***/
1977
+ (j, h) => {
1978
+ Object.defineProperty(h, "__esModule", {
1979
+ value: !0
1980
+ }), h.default = C;
1981
+ function C(g, W, E) {
1982
+ return Math.min(Math.max(W, g), E);
1983
+ }
1984
+ j.exports = h.default;
1985
+ }
1986
+ ),
1987
+ /***/
1988
+ "./src/util/fetch.js": (
1989
+ /*!***************************!*\
1990
+ !*** ./src/util/fetch.js ***!
1991
+ \***************************/
1992
+ /***/
1993
+ (j, h, C) => {
1994
+ Object.defineProperty(h, "__esModule", {
1995
+ value: !0
1996
+ }), h.default = _;
1997
+ var g = W(C(
1998
+ /*! ./observer */
1999
+ "./src/util/observer.js"
2000
+ ));
2001
+ function W(p) {
2002
+ return p && p.__esModule ? p : { default: p };
2003
+ }
2004
+ function E(p) {
2005
+ "@babel/helpers - typeof";
2006
+ return E = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(c) {
2007
+ return typeof c;
2008
+ } : function(c) {
2009
+ return c && typeof Symbol == "function" && c.constructor === Symbol && c !== Symbol.prototype ? "symbol" : typeof c;
2010
+ }, E(p);
2011
+ }
2012
+ function M(p, c) {
2013
+ if (!(p instanceof c))
2014
+ throw new TypeError("Cannot call a class as a function");
2015
+ }
2016
+ function x(p, c) {
2017
+ for (var v = 0; v < c.length; v++) {
2018
+ var d = c[v];
2019
+ d.enumerable = d.enumerable || !1, d.configurable = !0, "value" in d && (d.writable = !0), Object.defineProperty(p, b(d.key), d);
2020
+ }
2021
+ }
2022
+ function I(p, c, v) {
2023
+ return c && x(p.prototype, c), Object.defineProperty(p, "prototype", { writable: !1 }), p;
2024
+ }
2025
+ function b(p) {
2026
+ var c = O(p, "string");
2027
+ return E(c) === "symbol" ? c : String(c);
2028
+ }
2029
+ function O(p, c) {
2030
+ if (E(p) !== "object" || p === null) return p;
2031
+ var v = p[Symbol.toPrimitive];
2032
+ if (v !== void 0) {
2033
+ var d = v.call(p, c);
2034
+ if (E(d) !== "object") return d;
2035
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2036
+ }
2037
+ return String(p);
2038
+ }
2039
+ var R = /* @__PURE__ */ function() {
2040
+ function p(c, v, d) {
2041
+ M(this, p), this.instance = c, this.instance._reader = d.body.getReader(), this.total = parseInt(v, 10), this.loaded = 0;
2042
+ }
2043
+ return I(p, [{
2044
+ key: "start",
2045
+ value: function(v) {
2046
+ var d = this, P = function w() {
2047
+ d.instance._reader.read().then(function(k) {
2048
+ var y = k.done, f = k.value;
2049
+ if (y) {
2050
+ d.total === 0 && d.instance.onProgress.call(d.instance, {
2051
+ loaded: d.loaded,
2052
+ total: d.total,
2053
+ lengthComputable: !1
2054
+ }), v.close();
2055
+ return;
2056
+ }
2057
+ d.loaded += f.byteLength, d.instance.onProgress.call(d.instance, {
2058
+ loaded: d.loaded,
2059
+ total: d.total,
2060
+ lengthComputable: d.total !== 0
2061
+ }), v.enqueue(f), w();
2062
+ }).catch(function(k) {
2063
+ v.error(k);
2064
+ });
2065
+ };
2066
+ P();
2067
+ }
2068
+ }]), p;
2069
+ }();
2070
+ function _(p) {
2071
+ if (p) {
2072
+ if (!p.url)
2073
+ throw new Error("fetch url missing");
2074
+ } else throw new Error("fetch options missing");
2075
+ var c = new g.default(), v = new Headers(), d = new Request(p.url);
2076
+ c.controller = new AbortController(), p && p.requestHeaders && p.requestHeaders.forEach(function(k) {
2077
+ v.append(k.key, k.value);
2078
+ });
2079
+ var P = p.responseType || "json", w = {
2080
+ method: p.method || "GET",
2081
+ headers: v,
2082
+ mode: p.mode || "cors",
2083
+ credentials: p.credentials || "same-origin",
2084
+ cache: p.cache || "default",
2085
+ redirect: p.redirect || "follow",
2086
+ referrer: p.referrer || "client",
2087
+ signal: c.controller.signal
2088
+ };
2089
+ return fetch(d, w).then(function(k) {
2090
+ c.response = k;
2091
+ var y = !0;
2092
+ k.body || (y = !1);
2093
+ var f = k.headers.get("content-length");
2094
+ return f === null && (y = !1), y ? (c.onProgress = function(m) {
2095
+ c.fireEvent("progress", m);
2096
+ }, new Response(new ReadableStream(new R(c, f, k)), w)) : k;
2097
+ }).then(function(k) {
2098
+ var y;
2099
+ if (k.ok)
2100
+ switch (P) {
2101
+ case "arraybuffer":
2102
+ return k.arrayBuffer();
2103
+ case "json":
2104
+ return k.json();
2105
+ case "blob":
2106
+ return k.blob();
2107
+ case "text":
2108
+ return k.text();
2109
+ default:
2110
+ y = "Unknown responseType: " + P;
2111
+ break;
2112
+ }
2113
+ throw y || (y = "HTTP error status: " + k.status), new Error(y);
2114
+ }).then(function(k) {
2115
+ c.fireEvent("success", k);
2116
+ }).catch(function(k) {
2117
+ c.fireEvent("error", k);
2118
+ }), c.fetchRequest = d, c;
2119
+ }
2120
+ j.exports = h.default;
2121
+ }
2122
+ ),
2123
+ /***/
2124
+ "./src/util/frame.js": (
2125
+ /*!***************************!*\
2126
+ !*** ./src/util/frame.js ***!
2127
+ \***************************/
2128
+ /***/
2129
+ (j, h, C) => {
2130
+ Object.defineProperty(h, "__esModule", {
2131
+ value: !0
2132
+ }), h.default = E;
2133
+ var g = W(C(
2134
+ /*! ./request-animation-frame */
2135
+ "./src/util/request-animation-frame.js"
2136
+ ));
2137
+ function W(M) {
2138
+ return M && M.__esModule ? M : { default: M };
2139
+ }
2140
+ function E(M) {
2141
+ return function() {
2142
+ for (var x = arguments.length, I = new Array(x), b = 0; b < x; b++)
2143
+ I[b] = arguments[b];
2144
+ return (0, g.default)(function() {
2145
+ return M.apply(void 0, I);
2146
+ });
2147
+ };
2148
+ }
2149
+ j.exports = h.default;
2150
+ }
2151
+ ),
2152
+ /***/
2153
+ "./src/util/get-id.js": (
2154
+ /*!****************************!*\
2155
+ !*** ./src/util/get-id.js ***!
2156
+ \****************************/
2157
+ /***/
2158
+ (j, h) => {
2159
+ Object.defineProperty(h, "__esModule", {
2160
+ value: !0
2161
+ }), h.default = C;
2162
+ function C(g) {
2163
+ return g === void 0 && (g = "wavesurfer_"), g + Math.random().toString(32).substring(2);
2164
+ }
2165
+ j.exports = h.default;
2166
+ }
2167
+ ),
2168
+ /***/
2169
+ "./src/util/index.js": (
2170
+ /*!***************************!*\
2171
+ !*** ./src/util/index.js ***!
2172
+ \***************************/
2173
+ /***/
2174
+ (j, h, C) => {
2175
+ Object.defineProperty(h, "__esModule", {
2176
+ value: !0
2177
+ }), Object.defineProperty(h, "Observer", {
2178
+ enumerable: !0,
2179
+ get: function() {
2180
+ return x.default;
2181
+ }
2182
+ }), Object.defineProperty(h, "absMax", {
2183
+ enumerable: !0,
2184
+ get: function() {
2185
+ return M.default;
2186
+ }
2187
+ }), Object.defineProperty(h, "clamp", {
2188
+ enumerable: !0,
2189
+ get: function() {
2190
+ return c.default;
2191
+ }
2192
+ }), Object.defineProperty(h, "debounce", {
2193
+ enumerable: !0,
2194
+ get: function() {
2195
+ return R.default;
2196
+ }
2197
+ }), Object.defineProperty(h, "fetchFile", {
2198
+ enumerable: !0,
2199
+ get: function() {
2200
+ return p.default;
2201
+ }
2202
+ }), Object.defineProperty(h, "frame", {
2203
+ enumerable: !0,
2204
+ get: function() {
2205
+ return O.default;
2206
+ }
2207
+ }), Object.defineProperty(h, "getId", {
2208
+ enumerable: !0,
2209
+ get: function() {
2210
+ return g.default;
2211
+ }
2212
+ }), Object.defineProperty(h, "ignoreSilenceMode", {
2213
+ enumerable: !0,
2214
+ get: function() {
2215
+ return d.default;
2216
+ }
2217
+ }), Object.defineProperty(h, "max", {
2218
+ enumerable: !0,
2219
+ get: function() {
2220
+ return W.default;
2221
+ }
2222
+ }), Object.defineProperty(h, "min", {
2223
+ enumerable: !0,
2224
+ get: function() {
2225
+ return E.default;
2226
+ }
2227
+ }), Object.defineProperty(h, "preventClick", {
2228
+ enumerable: !0,
2229
+ get: function() {
2230
+ return _.default;
2231
+ }
2232
+ }), Object.defineProperty(h, "requestAnimationFrame", {
2233
+ enumerable: !0,
2234
+ get: function() {
2235
+ return b.default;
2236
+ }
2237
+ }), Object.defineProperty(h, "style", {
2238
+ enumerable: !0,
2239
+ get: function() {
2240
+ return I.default;
2241
+ }
2242
+ }), Object.defineProperty(h, "withOrientation", {
2243
+ enumerable: !0,
2244
+ get: function() {
2245
+ return v.default;
2246
+ }
2247
+ });
2248
+ var g = P(C(
2249
+ /*! ./get-id */
2250
+ "./src/util/get-id.js"
2251
+ )), W = P(C(
2252
+ /*! ./max */
2253
+ "./src/util/max.js"
2254
+ )), E = P(C(
2255
+ /*! ./min */
2256
+ "./src/util/min.js"
2257
+ )), M = P(C(
2258
+ /*! ./absMax */
2259
+ "./src/util/absMax.js"
2260
+ )), x = P(C(
2261
+ /*! ./observer */
2262
+ "./src/util/observer.js"
2263
+ )), I = P(C(
2264
+ /*! ./style */
2265
+ "./src/util/style.js"
2266
+ )), b = P(C(
2267
+ /*! ./request-animation-frame */
2268
+ "./src/util/request-animation-frame.js"
2269
+ )), O = P(C(
2270
+ /*! ./frame */
2271
+ "./src/util/frame.js"
2272
+ )), R = P(C(
2273
+ /*! debounce */
2274
+ "./node_modules/debounce/index.js"
2275
+ )), _ = P(C(
2276
+ /*! ./prevent-click */
2277
+ "./src/util/prevent-click.js"
2278
+ )), p = P(C(
2279
+ /*! ./fetch */
2280
+ "./src/util/fetch.js"
2281
+ )), c = P(C(
2282
+ /*! ./clamp */
2283
+ "./src/util/clamp.js"
2284
+ )), v = P(C(
2285
+ /*! ./orientation */
2286
+ "./src/util/orientation.js"
2287
+ )), d = P(C(
2288
+ /*! ./silence-mode */
2289
+ "./src/util/silence-mode.js"
2290
+ ));
2291
+ function P(w) {
2292
+ return w && w.__esModule ? w : { default: w };
2293
+ }
2294
+ }
2295
+ ),
2296
+ /***/
2297
+ "./src/util/max.js": (
2298
+ /*!*************************!*\
2299
+ !*** ./src/util/max.js ***!
2300
+ \*************************/
2301
+ /***/
2302
+ (j, h) => {
2303
+ Object.defineProperty(h, "__esModule", {
2304
+ value: !0
2305
+ }), h.default = C;
2306
+ function C(g) {
2307
+ var W = -1 / 0;
2308
+ return Object.keys(g).forEach(function(E) {
2309
+ g[E] > W && (W = g[E]);
2310
+ }), W;
2311
+ }
2312
+ j.exports = h.default;
2313
+ }
2314
+ ),
2315
+ /***/
2316
+ "./src/util/min.js": (
2317
+ /*!*************************!*\
2318
+ !*** ./src/util/min.js ***!
2319
+ \*************************/
2320
+ /***/
2321
+ (j, h) => {
2322
+ Object.defineProperty(h, "__esModule", {
2323
+ value: !0
2324
+ }), h.default = C;
2325
+ function C(g) {
2326
+ var W = 1 / 0;
2327
+ return Object.keys(g).forEach(function(E) {
2328
+ g[E] < W && (W = g[E]);
2329
+ }), W;
2330
+ }
2331
+ j.exports = h.default;
2332
+ }
2333
+ ),
2334
+ /***/
2335
+ "./src/util/observer.js": (
2336
+ /*!******************************!*\
2337
+ !*** ./src/util/observer.js ***!
2338
+ \******************************/
2339
+ /***/
2340
+ (j, h) => {
2341
+ Object.defineProperty(h, "__esModule", {
2342
+ value: !0
2343
+ }), h.default = void 0;
2344
+ function C(b) {
2345
+ "@babel/helpers - typeof";
2346
+ return C = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(O) {
2347
+ return typeof O;
2348
+ } : function(O) {
2349
+ return O && typeof Symbol == "function" && O.constructor === Symbol && O !== Symbol.prototype ? "symbol" : typeof O;
2350
+ }, C(b);
2351
+ }
2352
+ function g(b, O) {
2353
+ if (!(b instanceof O))
2354
+ throw new TypeError("Cannot call a class as a function");
2355
+ }
2356
+ function W(b, O) {
2357
+ for (var R = 0; R < O.length; R++) {
2358
+ var _ = O[R];
2359
+ _.enumerable = _.enumerable || !1, _.configurable = !0, "value" in _ && (_.writable = !0), Object.defineProperty(b, M(_.key), _);
2360
+ }
2361
+ }
2362
+ function E(b, O, R) {
2363
+ return O && W(b.prototype, O), Object.defineProperty(b, "prototype", { writable: !1 }), b;
2364
+ }
2365
+ function M(b) {
2366
+ var O = x(b, "string");
2367
+ return C(O) === "symbol" ? O : String(O);
2368
+ }
2369
+ function x(b, O) {
2370
+ if (C(b) !== "object" || b === null) return b;
2371
+ var R = b[Symbol.toPrimitive];
2372
+ if (R !== void 0) {
2373
+ var _ = R.call(b, O);
2374
+ if (C(_) !== "object") return _;
2375
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2376
+ }
2377
+ return String(b);
2378
+ }
2379
+ var I = /* @__PURE__ */ function() {
2380
+ function b() {
2381
+ g(this, b), this._disabledEventEmissions = [], this.handlers = null;
2382
+ }
2383
+ return E(b, [{
2384
+ key: "on",
2385
+ value: function(R, _) {
2386
+ var p = this;
2387
+ this.handlers || (this.handlers = {});
2388
+ var c = this.handlers[R];
2389
+ return c || (c = this.handlers[R] = []), c.push(_), {
2390
+ name: R,
2391
+ callback: _,
2392
+ un: function(d, P) {
2393
+ return p.un(d, P);
2394
+ }
2395
+ };
2396
+ }
2397
+ /**
2398
+ * Remove an event handler.
2399
+ *
2400
+ * @param {string} event Name of the event the listener that should be
2401
+ * removed listens to
2402
+ * @param {function} fn The callback that should be removed
2403
+ */
2404
+ }, {
2405
+ key: "un",
2406
+ value: function(R, _) {
2407
+ if (this.handlers) {
2408
+ var p = this.handlers[R], c;
2409
+ if (p)
2410
+ if (_)
2411
+ for (c = p.length - 1; c >= 0; c--)
2412
+ p[c] == _ && p.splice(c, 1);
2413
+ else
2414
+ p.length = 0;
2415
+ }
2416
+ }
2417
+ /**
2418
+ * Remove all event handlers.
2419
+ */
2420
+ }, {
2421
+ key: "unAll",
2422
+ value: function() {
2423
+ this.handlers = null;
2424
+ }
2425
+ /**
2426
+ * Attach a handler to an event. The handler is executed at most once per
2427
+ * event type.
2428
+ *
2429
+ * @param {string} event The event to listen to
2430
+ * @param {function} handler The callback that is only to be called once
2431
+ * @return {ListenerDescriptor} The event descriptor
2432
+ */
2433
+ }, {
2434
+ key: "once",
2435
+ value: function(R, _) {
2436
+ var p = this, c = function v() {
2437
+ for (var d = arguments.length, P = new Array(d), w = 0; w < d; w++)
2438
+ P[w] = arguments[w];
2439
+ _.apply(p, P), setTimeout(function() {
2440
+ p.un(R, v);
2441
+ }, 0);
2442
+ };
2443
+ return this.on(R, c);
2444
+ }
2445
+ /**
2446
+ * Disable firing a list of events by name. When specified, event handlers for any event type
2447
+ * passed in here will not be called.
2448
+ *
2449
+ * @since 4.0.0
2450
+ * @param {string[]} eventNames an array of event names to disable emissions for
2451
+ * @example
2452
+ * // disable seek and interaction events
2453
+ * wavesurfer.setDisabledEventEmissions(['seek', 'interaction']);
2454
+ */
2455
+ }, {
2456
+ key: "setDisabledEventEmissions",
2457
+ value: function(R) {
2458
+ this._disabledEventEmissions = R;
2459
+ }
2460
+ /**
2461
+ * plugins borrow part of this class without calling the constructor,
2462
+ * so we have to be careful about _disabledEventEmissions
2463
+ */
2464
+ }, {
2465
+ key: "_isDisabledEventEmission",
2466
+ value: function(R) {
2467
+ return this._disabledEventEmissions && this._disabledEventEmissions.includes(R);
2468
+ }
2469
+ /**
2470
+ * Manually fire an event
2471
+ *
2472
+ * @param {string} event The event to fire manually
2473
+ * @param {...any} args The arguments with which to call the listeners
2474
+ */
2475
+ }, {
2476
+ key: "fireEvent",
2477
+ value: function(R) {
2478
+ for (var _ = arguments.length, p = new Array(_ > 1 ? _ - 1 : 0), c = 1; c < _; c++)
2479
+ p[c - 1] = arguments[c];
2480
+ if (!(!this.handlers || this._isDisabledEventEmission(R))) {
2481
+ var v = this.handlers[R];
2482
+ v && v.forEach(function(d) {
2483
+ d.apply(void 0, p);
2484
+ });
2485
+ }
2486
+ }
2487
+ }]), b;
2488
+ }();
2489
+ h.default = I, j.exports = h.default;
2490
+ }
2491
+ ),
2492
+ /***/
2493
+ "./src/util/orientation.js": (
2494
+ /*!*********************************!*\
2495
+ !*** ./src/util/orientation.js ***!
2496
+ \*********************************/
2497
+ /***/
2498
+ (j, h) => {
2499
+ Object.defineProperty(h, "__esModule", {
2500
+ value: !0
2501
+ }), h.default = E;
2502
+ var C = {
2503
+ width: "height",
2504
+ height: "width",
2505
+ overflowX: "overflowY",
2506
+ overflowY: "overflowX",
2507
+ clientWidth: "clientHeight",
2508
+ clientHeight: "clientWidth",
2509
+ clientX: "clientY",
2510
+ clientY: "clientX",
2511
+ scrollWidth: "scrollHeight",
2512
+ scrollLeft: "scrollTop",
2513
+ offsetLeft: "offsetTop",
2514
+ offsetTop: "offsetLeft",
2515
+ offsetHeight: "offsetWidth",
2516
+ offsetWidth: "offsetHeight",
2517
+ left: "top",
2518
+ right: "bottom",
2519
+ top: "left",
2520
+ bottom: "right",
2521
+ borderRightStyle: "borderBottomStyle",
2522
+ borderRightWidth: "borderBottomWidth",
2523
+ borderRightColor: "borderBottomColor"
2524
+ };
2525
+ function g(M, x) {
2526
+ return Object.prototype.hasOwnProperty.call(C, M) && x ? C[M] : M;
2527
+ }
2528
+ var W = Symbol("isProxy");
2529
+ function E(M, x) {
2530
+ return M[W] ? M : new Proxy(M, {
2531
+ get: function(b, O, R) {
2532
+ if (O === W)
2533
+ return !0;
2534
+ if (O === "domElement")
2535
+ return b;
2536
+ if (O === "style")
2537
+ return E(b.style, x);
2538
+ if (O === "canvas")
2539
+ return E(b.canvas, x);
2540
+ if (O === "getBoundingClientRect")
2541
+ return function() {
2542
+ return E(b.getBoundingClientRect.apply(b, arguments), x);
2543
+ };
2544
+ if (O === "getContext")
2545
+ return function() {
2546
+ return E(b.getContext.apply(b, arguments), x);
2547
+ };
2548
+ var _ = b[g(O, x)];
2549
+ return typeof _ == "function" ? _.bind(b) : _;
2550
+ },
2551
+ set: function(b, O, R) {
2552
+ return b[g(O, x)] = R, !0;
2553
+ }
2554
+ });
2555
+ }
2556
+ j.exports = h.default;
2557
+ }
2558
+ ),
2559
+ /***/
2560
+ "./src/util/prevent-click.js": (
2561
+ /*!***********************************!*\
2562
+ !*** ./src/util/prevent-click.js ***!
2563
+ \***********************************/
2564
+ /***/
2565
+ (j, h) => {
2566
+ Object.defineProperty(h, "__esModule", {
2567
+ value: !0
2568
+ }), h.default = g;
2569
+ function C(W) {
2570
+ W.stopPropagation(), document.body.removeEventListener("click", C, !0);
2571
+ }
2572
+ function g(W) {
2573
+ document.body.addEventListener("click", C, !0);
2574
+ }
2575
+ j.exports = h.default;
2576
+ }
2577
+ ),
2578
+ /***/
2579
+ "./src/util/request-animation-frame.js": (
2580
+ /*!*********************************************!*\
2581
+ !*** ./src/util/request-animation-frame.js ***!
2582
+ \*********************************************/
2583
+ /***/
2584
+ (j, h) => {
2585
+ Object.defineProperty(h, "__esModule", {
2586
+ value: !0
2587
+ }), h.default = void 0;
2588
+ var C = (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(g, W) {
2589
+ return setTimeout(g, 1e3 / 60);
2590
+ }).bind(window);
2591
+ h.default = C, j.exports = h.default;
2592
+ }
2593
+ ),
2594
+ /***/
2595
+ "./src/util/silence-mode.js": (
2596
+ /*!**********************************!*\
2597
+ !*** ./src/util/silence-mode.js ***!
2598
+ \**********************************/
2599
+ /***/
2600
+ (j, h) => {
2601
+ Object.defineProperty(h, "__esModule", {
2602
+ value: !0
2603
+ }), h.default = C;
2604
+ function C() {
2605
+ var g = new AudioContext(), W = g.createBufferSource();
2606
+ W.buffer = g.createBuffer(1, 1, 44100), W.connect(g.destination), W.start();
2607
+ var E = "data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAACcQCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA//////////////////////////////////////////////////////////////////8AAABhTEFNRTMuMTAwA8MAAAAAAAAAABQgJAUHQQAB9AAAAnGMHkkIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//sQxAADgnABGiAAQBCqgCRMAAgEAH///////////////7+n/9FTuQsQH//////2NG0jWUGlio5gLQTOtIoeR2WX////X4s9Atb/JRVCbBUpeRUq//////////////////9RUi0f2jn/+xDECgPCjAEQAABN4AAANIAAAAQVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==", M = document.createElement("div");
2608
+ M.innerHTML = '<audio x-webkit-airplay="deny"></audio>';
2609
+ var x = M.children.item(0);
2610
+ x.src = E, x.preload = "auto", x.type = "audio/mpeg", x.disableRemotePlayback = !0, x.play(), x.remove(), M.remove();
2611
+ }
2612
+ j.exports = h.default;
2613
+ }
2614
+ ),
2615
+ /***/
2616
+ "./src/util/style.js": (
2617
+ /*!***************************!*\
2618
+ !*** ./src/util/style.js ***!
2619
+ \***************************/
2620
+ /***/
2621
+ (j, h) => {
2622
+ Object.defineProperty(h, "__esModule", {
2623
+ value: !0
2624
+ }), h.default = C;
2625
+ function C(g, W) {
2626
+ return Object.keys(W).forEach(function(E) {
2627
+ g.style[E] !== W[E] && (g.style[E] = W[E]);
2628
+ }), g;
2629
+ }
2630
+ j.exports = h.default;
2631
+ }
2632
+ ),
2633
+ /***/
2634
+ "./src/wavesurfer.js": (
2635
+ /*!***************************!*\
2636
+ !*** ./src/wavesurfer.js ***!
2637
+ \***************************/
2638
+ /***/
2639
+ (j, h, C) => {
2640
+ Object.defineProperty(h, "__esModule", {
2641
+ value: !0
2642
+ }), h.default = void 0;
2643
+ var g = R(C(
2644
+ /*! ./util */
2645
+ "./src/util/index.js"
2646
+ )), W = b(C(
2647
+ /*! ./drawer.multicanvas */
2648
+ "./src/drawer.multicanvas.js"
2649
+ )), E = b(C(
2650
+ /*! ./webaudio */
2651
+ "./src/webaudio.js"
2652
+ )), M = b(C(
2653
+ /*! ./mediaelement */
2654
+ "./src/mediaelement.js"
2655
+ )), x = b(C(
2656
+ /*! ./peakcache */
2657
+ "./src/peakcache.js"
2658
+ )), I = b(C(
2659
+ /*! ./mediaelement-webaudio */
2660
+ "./src/mediaelement-webaudio.js"
2661
+ ));
2662
+ function b(r) {
2663
+ return r && r.__esModule ? r : { default: r };
2664
+ }
2665
+ function O(r) {
2666
+ if (typeof WeakMap != "function") return null;
2667
+ var t = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap();
2668
+ return (O = function(e) {
2669
+ return e ? s : t;
2670
+ })(r);
2671
+ }
2672
+ function R(r, t) {
2673
+ if (r && r.__esModule)
2674
+ return r;
2675
+ if (r === null || y(r) !== "object" && typeof r != "function")
2676
+ return { default: r };
2677
+ var s = O(t);
2678
+ if (s && s.has(r))
2679
+ return s.get(r);
2680
+ var i = {}, e = Object.defineProperty && Object.getOwnPropertyDescriptor;
2681
+ for (var l in r)
2682
+ if (l !== "default" && Object.prototype.hasOwnProperty.call(r, l)) {
2683
+ var A = e ? Object.getOwnPropertyDescriptor(r, l) : null;
2684
+ A && (A.get || A.set) ? Object.defineProperty(i, l, A) : i[l] = r[l];
2685
+ }
2686
+ return i.default = r, s && s.set(r, i), i;
2687
+ }
2688
+ function _(r, t) {
2689
+ if (typeof t != "function" && t !== null)
2690
+ throw new TypeError("Super expression must either be null or a function");
2691
+ r.prototype = Object.create(t && t.prototype, { constructor: { value: r, writable: !0, configurable: !0 } }), Object.defineProperty(r, "prototype", { writable: !1 }), t && p(r, t);
2692
+ }
2693
+ function p(r, t) {
2694
+ return p = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(i, e) {
2695
+ return i.__proto__ = e, i;
2696
+ }, p(r, t);
2697
+ }
2698
+ function c(r) {
2699
+ var t = P();
2700
+ return function() {
2701
+ var i = w(r), e;
2702
+ if (t) {
2703
+ var l = w(this).constructor;
2704
+ e = Reflect.construct(i, arguments, l);
2705
+ } else
2706
+ e = i.apply(this, arguments);
2707
+ return v(this, e);
2708
+ };
2709
+ }
2710
+ function v(r, t) {
2711
+ if (t && (y(t) === "object" || typeof t == "function"))
2712
+ return t;
2713
+ if (t !== void 0)
2714
+ throw new TypeError("Derived constructors may only return object or undefined");
2715
+ return d(r);
2716
+ }
2717
+ function d(r) {
2718
+ if (r === void 0)
2719
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2720
+ return r;
2721
+ }
2722
+ function P() {
2723
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
2724
+ if (typeof Proxy == "function") return !0;
2725
+ try {
2726
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
2727
+ })), !0;
2728
+ } catch {
2729
+ return !1;
2730
+ }
2731
+ }
2732
+ function w(r) {
2733
+ return w = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(s) {
2734
+ return s.__proto__ || Object.getPrototypeOf(s);
2735
+ }, w(r);
2736
+ }
2737
+ function k(r, t, s) {
2738
+ return t = n(t), t in r ? Object.defineProperty(r, t, { value: s, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = s, r;
2739
+ }
2740
+ function y(r) {
2741
+ "@babel/helpers - typeof";
2742
+ return y = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
2743
+ return typeof t;
2744
+ } : function(t) {
2745
+ return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
2746
+ }, y(r);
2747
+ }
2748
+ function f(r, t) {
2749
+ if (!(r instanceof t))
2750
+ throw new TypeError("Cannot call a class as a function");
2751
+ }
2752
+ function m(r, t) {
2753
+ for (var s = 0; s < t.length; s++) {
2754
+ var i = t[s];
2755
+ i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(r, n(i.key), i);
2756
+ }
2757
+ }
2758
+ function u(r, t, s) {
2759
+ return t && m(r.prototype, t), s && m(r, s), Object.defineProperty(r, "prototype", { writable: !1 }), r;
2760
+ }
2761
+ function n(r) {
2762
+ var t = a(r, "string");
2763
+ return y(t) === "symbol" ? t : String(t);
2764
+ }
2765
+ function a(r, t) {
2766
+ if (y(r) !== "object" || r === null) return r;
2767
+ var s = r[Symbol.toPrimitive];
2768
+ if (s !== void 0) {
2769
+ var i = s.call(r, t);
2770
+ if (y(i) !== "object") return i;
2771
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2772
+ }
2773
+ return (t === "string" ? String : Number)(r);
2774
+ }
2775
+ var o = /* @__PURE__ */ function(r) {
2776
+ _(s, r);
2777
+ var t = c(s);
2778
+ function s(i) {
2779
+ var e;
2780
+ if (f(this, s), e = t.call(this), k(d(e), "defaultParams", {
2781
+ audioContext: null,
2782
+ audioScriptProcessor: null,
2783
+ audioRate: 1,
2784
+ autoCenter: !0,
2785
+ autoCenterRate: 5,
2786
+ autoCenterImmediately: !1,
2787
+ backend: "WebAudio",
2788
+ backgroundColor: null,
2789
+ barHeight: 1,
2790
+ barRadius: 0,
2791
+ barGap: null,
2792
+ barMinHeight: null,
2793
+ container: null,
2794
+ cursorColor: "#333",
2795
+ cursorWidth: 1,
2796
+ dragSelection: !0,
2797
+ drawingContextAttributes: {
2798
+ // Boolean that hints the user agent to reduce the latency
2799
+ // by desynchronizing the canvas paint cycle from the event
2800
+ // loop
2801
+ desynchronized: !1
2802
+ },
2803
+ duration: null,
2804
+ fillParent: !0,
2805
+ forceDecode: !1,
2806
+ height: 128,
2807
+ hideScrollbar: !1,
2808
+ hideCursor: !1,
2809
+ ignoreSilenceMode: !1,
2810
+ interact: !0,
2811
+ loopSelection: !0,
2812
+ maxCanvasWidth: 4e3,
2813
+ mediaContainer: null,
2814
+ mediaControls: !1,
2815
+ mediaType: "audio",
2816
+ minPxPerSec: 20,
2817
+ normalize: !1,
2818
+ partialRender: !1,
2819
+ pixelRatio: window.devicePixelRatio || screen.deviceXDPI / screen.logicalXDPI,
2820
+ plugins: [],
2821
+ progressColor: "#555",
2822
+ removeMediaElementOnDestroy: !0,
2823
+ renderer: W.default,
2824
+ responsive: !1,
2825
+ rtl: !1,
2826
+ scrollParent: !1,
2827
+ skipLength: 2,
2828
+ splitChannels: !1,
2829
+ splitChannelsOptions: {
2830
+ overlay: !1,
2831
+ channelColors: {},
2832
+ filterChannels: [],
2833
+ relativeNormalization: !1,
2834
+ splitDragSelection: !1
2835
+ },
2836
+ vertical: !1,
2837
+ waveColor: "#999",
2838
+ xhr: {}
2839
+ }), k(d(e), "backends", {
2840
+ MediaElement: M.default,
2841
+ WebAudio: E.default,
2842
+ MediaElementWebAudio: I.default
2843
+ }), k(d(e), "util", g), e.params = Object.assign({}, e.defaultParams, i), e.params.splitChannelsOptions = Object.assign({}, e.defaultParams.splitChannelsOptions, i.splitChannelsOptions), e.container = typeof i.container == "string" ? document.querySelector(e.params.container) : e.params.container, !e.container)
2844
+ throw new Error("Container element not found");
2845
+ if (e.params.mediaContainer == null ? e.mediaContainer = e.container : typeof e.params.mediaContainer == "string" ? e.mediaContainer = document.querySelector(e.params.mediaContainer) : e.mediaContainer = e.params.mediaContainer, !e.mediaContainer)
2846
+ throw new Error("Media Container element not found");
2847
+ if (e.params.maxCanvasWidth <= 1)
2848
+ throw new Error("maxCanvasWidth must be greater than 1");
2849
+ if (e.params.maxCanvasWidth % 2 == 1)
2850
+ throw new Error("maxCanvasWidth must be an even number");
2851
+ if (e.params.rtl === !0 && (e.params.vertical === !0 ? g.style(e.container, {
2852
+ transform: "rotateX(180deg)"
2853
+ }) : g.style(e.container, {
2854
+ transform: "rotateY(180deg)"
2855
+ })), e.params.backgroundColor && e.setBackgroundColor(e.params.backgroundColor), e.savedVolume = 0, e.isMuted = !1, e.tmpEvents = [], e.currentRequest = null, e.arraybuffer = null, e.drawer = null, e.backend = null, e.peakCache = null, typeof e.params.renderer != "function")
2856
+ throw new Error("Renderer parameter is invalid");
2857
+ e.Drawer = e.params.renderer, e.params.backend == "AudioElement" && (e.params.backend = "MediaElement"), (e.params.backend == "WebAudio" || e.params.backend === "MediaElementWebAudio") && !E.default.prototype.supportsWebAudio.call(null) && (e.params.backend = "MediaElement"), e.Backend = e.backends[e.params.backend], e.initialisedPluginList = {}, e.isDestroyed = !1, e.isReady = !1;
2858
+ var l = 0;
2859
+ return e._onResize = g.debounce(function() {
2860
+ e.drawer.wrapper && l != e.drawer.wrapper.clientWidth && !e.params.scrollParent && (l = e.drawer.wrapper.clientWidth, l && e.drawer.fireEvent("redraw"));
2861
+ }, typeof e.params.responsive == "number" ? e.params.responsive : 100), v(e, d(e));
2862
+ }
2863
+ return u(s, [{
2864
+ key: "init",
2865
+ value: function() {
2866
+ return this.registerPlugins(this.params.plugins), this.createDrawer(), this.createBackend(), this.createPeakCache(), this;
2867
+ }
2868
+ /**
2869
+ * Add and initialise array of plugins (if `plugin.deferInit` is falsey),
2870
+ * this function is called in the init function of wavesurfer
2871
+ *
2872
+ * @param {PluginDefinition[]} plugins An array of plugin definitions
2873
+ * @emits {WaveSurfer#plugins-registered} Called with the array of plugin definitions
2874
+ * @return {this} The wavesurfer instance
2875
+ */
2876
+ }, {
2877
+ key: "registerPlugins",
2878
+ value: function(e) {
2879
+ var l = this;
2880
+ return e.forEach(function(A) {
2881
+ return l.addPlugin(A);
2882
+ }), e.forEach(function(A) {
2883
+ A.deferInit || l.initPlugin(A.name);
2884
+ }), this.fireEvent("plugins-registered", e), this;
2885
+ }
2886
+ /**
2887
+ * Get a map of plugin names that are currently initialised
2888
+ *
2889
+ * @example wavesurfer.getPlugins();
2890
+ * @return {Object} Object with plugin names
2891
+ */
2892
+ }, {
2893
+ key: "getActivePlugins",
2894
+ value: function() {
2895
+ return this.initialisedPluginList;
2896
+ }
2897
+ /**
2898
+ * Add a plugin object to wavesurfer
2899
+ *
2900
+ * @param {PluginDefinition} plugin A plugin definition
2901
+ * @emits {WaveSurfer#plugin-added} Called with the name of the plugin that was added
2902
+ * @example wavesurfer.addPlugin(WaveSurfer.minimap());
2903
+ * @return {this} The wavesurfer instance
2904
+ */
2905
+ }, {
2906
+ key: "addPlugin",
2907
+ value: function(e) {
2908
+ var l = this;
2909
+ if (!e.name)
2910
+ throw new Error("Plugin does not have a name!");
2911
+ if (!e.instance)
2912
+ throw new Error("Plugin ".concat(e.name, " does not have an instance property!"));
2913
+ e.staticProps && Object.keys(e.staticProps).forEach(function(S) {
2914
+ l[S] = e.staticProps[S];
2915
+ });
2916
+ var A = e.instance, T = Object.getOwnPropertyNames(g.Observer.prototype);
2917
+ return T.forEach(function(S) {
2918
+ A.prototype[S] = g.Observer.prototype[S];
2919
+ }), this[e.name] = new A(e.params || {}, this), this.fireEvent("plugin-added", e.name), this;
2920
+ }
2921
+ /**
2922
+ * Initialise a plugin
2923
+ *
2924
+ * @param {string} name A plugin name
2925
+ * @emits WaveSurfer#plugin-initialised
2926
+ * @example wavesurfer.initPlugin('minimap');
2927
+ * @return {this} The wavesurfer instance
2928
+ */
2929
+ }, {
2930
+ key: "initPlugin",
2931
+ value: function(e) {
2932
+ if (!this[e])
2933
+ throw new Error("Plugin ".concat(e, " has not been added yet!"));
2934
+ return this.initialisedPluginList[e] && this.destroyPlugin(e), this[e].init(), this.initialisedPluginList[e] = !0, this.fireEvent("plugin-initialised", e), this;
2935
+ }
2936
+ /**
2937
+ * Destroy a plugin
2938
+ *
2939
+ * @param {string} name A plugin name
2940
+ * @emits WaveSurfer#plugin-destroyed
2941
+ * @example wavesurfer.destroyPlugin('minimap');
2942
+ * @returns {this} The wavesurfer instance
2943
+ */
2944
+ }, {
2945
+ key: "destroyPlugin",
2946
+ value: function(e) {
2947
+ if (!this[e])
2948
+ throw new Error("Plugin ".concat(e, " has not been added yet and cannot be destroyed!"));
2949
+ if (!this.initialisedPluginList[e])
2950
+ throw new Error("Plugin ".concat(e, " is not active and cannot be destroyed!"));
2951
+ if (typeof this[e].destroy != "function")
2952
+ throw new Error("Plugin ".concat(e, " does not have a destroy function!"));
2953
+ return this[e].destroy(), delete this.initialisedPluginList[e], this.fireEvent("plugin-destroyed", e), this;
2954
+ }
2955
+ /**
2956
+ * Destroy all initialised plugins. Convenience function to use when
2957
+ * wavesurfer is removed
2958
+ *
2959
+ * @private
2960
+ */
2961
+ }, {
2962
+ key: "destroyAllPlugins",
2963
+ value: function() {
2964
+ var e = this;
2965
+ Object.keys(this.initialisedPluginList).forEach(function(l) {
2966
+ return e.destroyPlugin(l);
2967
+ });
2968
+ }
2969
+ /**
2970
+ * Create the drawer and draw the waveform
2971
+ *
2972
+ * @private
2973
+ * @emits WaveSurfer#drawer-created
2974
+ */
2975
+ }, {
2976
+ key: "createDrawer",
2977
+ value: function() {
2978
+ var e = this;
2979
+ this.drawer = new this.Drawer(this.container, this.params), this.drawer.init(), this.fireEvent("drawer-created", this.drawer), this.params.responsive !== !1 && (window.addEventListener("resize", this._onResize, !0), window.addEventListener("orientationchange", this._onResize, !0)), this.drawer.on("redraw", function() {
2980
+ e.drawBuffer(), e.drawer.progress(e.backend.getPlayedPercents());
2981
+ }), this.drawer.on("click", function(l, A) {
2982
+ setTimeout(function() {
2983
+ return e.seekTo(A);
2984
+ }, 0);
2985
+ }), this.drawer.on("scroll", function(l) {
2986
+ e.params.partialRender && e.drawBuffer(), e.fireEvent("scroll", l);
2987
+ }), this.drawer.on("dblclick", function(l, A) {
2988
+ e.fireEvent("dblclick", l, A);
2989
+ });
2990
+ }
2991
+ /**
2992
+ * Create the backend
2993
+ *
2994
+ * @private
2995
+ * @emits WaveSurfer#backend-created
2996
+ */
2997
+ }, {
2998
+ key: "createBackend",
2999
+ value: function() {
3000
+ var e = this;
3001
+ this.backend && this.backend.destroy(), this.backend = new this.Backend(this.params), this.backend.init(), this.fireEvent("backend-created", this.backend), this.backend.on("finish", function() {
3002
+ e.drawer.progress(e.backend.getPlayedPercents()), e.fireEvent("finish");
3003
+ }), this.backend.on("play", function() {
3004
+ return e.fireEvent("play");
3005
+ }), this.backend.on("pause", function() {
3006
+ return e.fireEvent("pause");
3007
+ }), this.backend.on("audioprocess", function(l) {
3008
+ e.drawer.progress(e.backend.getPlayedPercents()), e.fireEvent("audioprocess", l);
3009
+ }), (this.params.backend === "MediaElement" || this.params.backend === "MediaElementWebAudio") && (this.backend.on("seek", function() {
3010
+ e.drawer.progress(e.backend.getPlayedPercents());
3011
+ }), this.backend.on("volume", function() {
3012
+ var l = e.getVolume();
3013
+ e.fireEvent("volume", l), e.backend.isMuted !== e.isMuted && (e.isMuted = e.backend.isMuted, e.fireEvent("mute", e.isMuted));
3014
+ }));
3015
+ }
3016
+ /**
3017
+ * Create the peak cache
3018
+ *
3019
+ * @private
3020
+ */
3021
+ }, {
3022
+ key: "createPeakCache",
3023
+ value: function() {
3024
+ this.params.partialRender && (this.peakCache = new x.default());
3025
+ }
3026
+ /**
3027
+ * Get the duration of the audio clip
3028
+ *
3029
+ * @example const duration = wavesurfer.getDuration();
3030
+ * @return {number} Duration in seconds
3031
+ */
3032
+ }, {
3033
+ key: "getDuration",
3034
+ value: function() {
3035
+ return this.backend.getDuration();
3036
+ }
3037
+ /**
3038
+ * Get the current playback position
3039
+ *
3040
+ * @example const currentTime = wavesurfer.getCurrentTime();
3041
+ * @return {number} Playback position in seconds
3042
+ */
3043
+ }, {
3044
+ key: "getCurrentTime",
3045
+ value: function() {
3046
+ return this.backend.getCurrentTime();
3047
+ }
3048
+ /**
3049
+ * Set the current play time in seconds.
3050
+ *
3051
+ * @param {number} seconds A positive number in seconds. E.g. 10 means 10
3052
+ * seconds, 60 means 1 minute
3053
+ */
3054
+ }, {
3055
+ key: "setCurrentTime",
3056
+ value: function(e) {
3057
+ e >= this.getDuration() ? this.seekTo(1) : this.seekTo(e / this.getDuration());
3058
+ }
3059
+ /**
3060
+ * Starts playback from the current position. Optional start and end
3061
+ * measured in seconds can be used to set the range of audio to play.
3062
+ *
3063
+ * @param {?number} start Position to start at
3064
+ * @param {?number} end Position to end at
3065
+ * @emits WaveSurfer#interaction
3066
+ * @return {Promise} Result of the backend play method
3067
+ * @example
3068
+ * // play from second 1 to 5
3069
+ * wavesurfer.play(1, 5);
3070
+ */
3071
+ }, {
3072
+ key: "play",
3073
+ value: function(e, l) {
3074
+ var A = this;
3075
+ return this.params.ignoreSilenceMode && g.ignoreSilenceMode(), this.fireEvent("interaction", function() {
3076
+ return A.play(e, l);
3077
+ }), this.backend.play(e, l);
3078
+ }
3079
+ /**
3080
+ * Set a point in seconds for playback to stop at.
3081
+ *
3082
+ * @param {number} position Position (in seconds) to stop at
3083
+ * @version 3.3.0
3084
+ */
3085
+ }, {
3086
+ key: "setPlayEnd",
3087
+ value: function(e) {
3088
+ this.backend.setPlayEnd(e);
3089
+ }
3090
+ /**
3091
+ * Stops and pauses playback
3092
+ *
3093
+ * @example wavesurfer.pause();
3094
+ * @return {Promise} Result of the backend pause method
3095
+ */
3096
+ }, {
3097
+ key: "pause",
3098
+ value: function() {
3099
+ if (!this.backend.isPaused())
3100
+ return this.backend.pause();
3101
+ }
3102
+ /**
3103
+ * Toggle playback
3104
+ *
3105
+ * @example wavesurfer.playPause();
3106
+ * @return {Promise} Result of the backend play or pause method
3107
+ */
3108
+ }, {
3109
+ key: "playPause",
3110
+ value: function() {
3111
+ return this.backend.isPaused() ? this.play() : this.pause();
3112
+ }
3113
+ /**
3114
+ * Get the current playback state
3115
+ *
3116
+ * @example const isPlaying = wavesurfer.isPlaying();
3117
+ * @return {boolean} False if paused, true if playing
3118
+ */
3119
+ }, {
3120
+ key: "isPlaying",
3121
+ value: function() {
3122
+ return !this.backend.isPaused();
3123
+ }
3124
+ /**
3125
+ * Skip backward
3126
+ *
3127
+ * @param {?number} seconds Amount to skip back, if not specified `skipLength`
3128
+ * is used
3129
+ * @example wavesurfer.skipBackward();
3130
+ */
3131
+ }, {
3132
+ key: "skipBackward",
3133
+ value: function(e) {
3134
+ this.skip(-e || -this.params.skipLength);
3135
+ }
3136
+ /**
3137
+ * Skip forward
3138
+ *
3139
+ * @param {?number} seconds Amount to skip back, if not specified `skipLength`
3140
+ * is used
3141
+ * @example wavesurfer.skipForward();
3142
+ */
3143
+ }, {
3144
+ key: "skipForward",
3145
+ value: function(e) {
3146
+ this.skip(e || this.params.skipLength);
3147
+ }
3148
+ /**
3149
+ * Skip a number of seconds from the current position (use a negative value
3150
+ * to go backwards).
3151
+ *
3152
+ * @param {number} offset Amount to skip back or forwards
3153
+ * @example
3154
+ * // go back 2 seconds
3155
+ * wavesurfer.skip(-2);
3156
+ */
3157
+ }, {
3158
+ key: "skip",
3159
+ value: function(e) {
3160
+ var l = this.getDuration() || 1, A = this.getCurrentTime() || 0;
3161
+ A = Math.max(0, Math.min(l, A + (e || 0))), this.seekAndCenter(A / l);
3162
+ }
3163
+ /**
3164
+ * Seeks to a position and centers the view
3165
+ *
3166
+ * @param {number} progress Between 0 (=beginning) and 1 (=end)
3167
+ * @example
3168
+ * // seek and go to the middle of the audio
3169
+ * wavesurfer.seekTo(0.5);
3170
+ */
3171
+ }, {
3172
+ key: "seekAndCenter",
3173
+ value: function(e) {
3174
+ this.seekTo(e), this.drawer.recenter(e);
3175
+ }
3176
+ /**
3177
+ * Seeks to a position
3178
+ *
3179
+ * @param {number} progress Between 0 (=beginning) and 1 (=end)
3180
+ * @emits WaveSurfer#interaction
3181
+ * @emits WaveSurfer#seek
3182
+ * @example
3183
+ * // seek to the middle of the audio
3184
+ * wavesurfer.seekTo(0.5);
3185
+ */
3186
+ }, {
3187
+ key: "seekTo",
3188
+ value: function(e) {
3189
+ var l = this;
3190
+ if (typeof e != "number" || !isFinite(e) || e < 0 || e > 1)
3191
+ throw new Error("Error calling wavesurfer.seekTo, parameter must be a number between 0 and 1!");
3192
+ this.fireEvent("interaction", function() {
3193
+ return l.seekTo(e);
3194
+ });
3195
+ var A = this.params.backend === "WebAudio", T = this.backend.isPaused();
3196
+ A && !T && this.backend.pause();
3197
+ var S = this.params.scrollParent;
3198
+ this.params.scrollParent = !1, this.backend.seekTo(e * this.getDuration()), this.drawer.progress(e), A && !T && this.backend.play(), this.params.scrollParent = S, this.fireEvent("seek", e);
3199
+ }
3200
+ /**
3201
+ * Stops and goes to the beginning.
3202
+ *
3203
+ * @example wavesurfer.stop();
3204
+ */
3205
+ }, {
3206
+ key: "stop",
3207
+ value: function() {
3208
+ this.pause(), this.seekTo(0), this.drawer.progress(0);
3209
+ }
3210
+ /**
3211
+ * Sets the ID of the audio device to use for output and returns a Promise.
3212
+ *
3213
+ * @param {string} deviceId String value representing underlying output
3214
+ * device
3215
+ * @returns {Promise} `Promise` that resolves to `undefined` when there are
3216
+ * no errors detected.
3217
+ */
3218
+ }, {
3219
+ key: "setSinkId",
3220
+ value: function(e) {
3221
+ return this.backend.setSinkId(e);
3222
+ }
3223
+ /**
3224
+ * Set the playback volume.
3225
+ *
3226
+ * @param {number} newVolume A value between 0 and 1, 0 being no
3227
+ * volume and 1 being full volume.
3228
+ * @emits WaveSurfer#volume
3229
+ */
3230
+ }, {
3231
+ key: "setVolume",
3232
+ value: function(e) {
3233
+ if (this.isMuted === !0) {
3234
+ this.savedVolume = e;
3235
+ return;
3236
+ }
3237
+ this.backend.setVolume(e), this.fireEvent("volume", e);
3238
+ }
3239
+ /**
3240
+ * Get the playback volume.
3241
+ *
3242
+ * @return {number} A value between 0 and 1, 0 being no
3243
+ * volume and 1 being full volume.
3244
+ */
3245
+ }, {
3246
+ key: "getVolume",
3247
+ value: function() {
3248
+ return this.backend.getVolume();
3249
+ }
3250
+ /**
3251
+ * Set the playback rate.
3252
+ *
3253
+ * @param {number} rate A positive number. E.g. 0.5 means half the normal
3254
+ * speed, 2 means double speed and so on.
3255
+ * @example wavesurfer.setPlaybackRate(2);
3256
+ */
3257
+ }, {
3258
+ key: "setPlaybackRate",
3259
+ value: function(e) {
3260
+ this.backend.setPlaybackRate(e);
3261
+ }
3262
+ /**
3263
+ * Get the playback rate.
3264
+ *
3265
+ * @return {number} The current playback rate.
3266
+ */
3267
+ }, {
3268
+ key: "getPlaybackRate",
3269
+ value: function() {
3270
+ return this.backend.getPlaybackRate();
3271
+ }
3272
+ /**
3273
+ * Toggle the volume on and off. If not currently muted it will save the
3274
+ * current volume value and turn the volume off. If currently muted then it
3275
+ * will restore the volume to the saved value, and then rest the saved
3276
+ * value.
3277
+ *
3278
+ * @example wavesurfer.toggleMute();
3279
+ */
3280
+ }, {
3281
+ key: "toggleMute",
3282
+ value: function() {
3283
+ this.setMute(!this.isMuted);
3284
+ }
3285
+ /**
3286
+ * Enable or disable muted audio
3287
+ *
3288
+ * @param {boolean} mute Specify `true` to mute audio.
3289
+ * @emits WaveSurfer#volume
3290
+ * @emits WaveSurfer#mute
3291
+ * @example
3292
+ * // unmute
3293
+ * wavesurfer.setMute(false);
3294
+ * console.log(wavesurfer.getMute()) // logs false
3295
+ */
3296
+ }, {
3297
+ key: "setMute",
3298
+ value: function(e) {
3299
+ if (e === this.isMuted) {
3300
+ this.fireEvent("mute", this.isMuted);
3301
+ return;
3302
+ }
3303
+ this.backend.setMute ? (this.backend.setMute(e), this.isMuted = e) : e ? (this.savedVolume = this.backend.getVolume(), this.backend.setVolume(0), this.isMuted = !0, this.fireEvent("volume", 0)) : (this.backend.setVolume(this.savedVolume), this.isMuted = !1, this.fireEvent("volume", this.savedVolume)), this.fireEvent("mute", this.isMuted);
3304
+ }
3305
+ /**
3306
+ * Get the current mute status.
3307
+ *
3308
+ * @example const isMuted = wavesurfer.getMute();
3309
+ * @return {boolean} Current mute status
3310
+ */
3311
+ }, {
3312
+ key: "getMute",
3313
+ value: function() {
3314
+ return this.isMuted;
3315
+ }
3316
+ /**
3317
+ * Get the list of current set filters as an array.
3318
+ *
3319
+ * Filters must be set with setFilters method first
3320
+ *
3321
+ * @return {array} List of enabled filters
3322
+ */
3323
+ }, {
3324
+ key: "getFilters",
3325
+ value: function() {
3326
+ return this.backend.filters || [];
3327
+ }
3328
+ /**
3329
+ * Toggles `scrollParent` and redraws
3330
+ *
3331
+ * @example wavesurfer.toggleScroll();
3332
+ */
3333
+ }, {
3334
+ key: "toggleScroll",
3335
+ value: function() {
3336
+ this.params.scrollParent = !this.params.scrollParent, this.drawBuffer();
3337
+ }
3338
+ /**
3339
+ * Toggle mouse interaction
3340
+ *
3341
+ * @example wavesurfer.toggleInteraction();
3342
+ */
3343
+ }, {
3344
+ key: "toggleInteraction",
3345
+ value: function() {
3346
+ this.params.interact = !this.params.interact;
3347
+ }
3348
+ /**
3349
+ * Get the fill color of the waveform after the cursor.
3350
+ *
3351
+ * @param {?number} channelIdx Optional index of the channel to get its wave color if splitChannels is true
3352
+ * @return {string|object} A CSS color string, or an array of CSS color strings.
3353
+ */
3354
+ }, {
3355
+ key: "getWaveColor",
3356
+ value: function() {
3357
+ var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
3358
+ return this.params.splitChannelsOptions.channelColors[e] ? this.params.splitChannelsOptions.channelColors[e].waveColor : this.params.waveColor;
3359
+ }
3360
+ /**
3361
+ * Set the fill color of the waveform after the cursor.
3362
+ *
3363
+ * @param {string|object} color A CSS color string, or an array of CSS color strings.
3364
+ * @param {?number} channelIdx Optional index of the channel to set its wave color if splitChannels is true
3365
+ * @example wavesurfer.setWaveColor('#ddd');
3366
+ */
3367
+ }, {
3368
+ key: "setWaveColor",
3369
+ value: function(e) {
3370
+ var l = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
3371
+ this.params.splitChannelsOptions.channelColors[l] ? this.params.splitChannelsOptions.channelColors[l].waveColor = e : this.params.waveColor = e, this.drawBuffer();
3372
+ }
3373
+ /**
3374
+ * Get the fill color of the waveform behind the cursor.
3375
+ *
3376
+ * @param {?number} channelIdx Optional index of the channel to get its progress color if splitChannels is true
3377
+ * @return {string|object} A CSS color string, or an array of CSS color strings.
3378
+ */
3379
+ }, {
3380
+ key: "getProgressColor",
3381
+ value: function() {
3382
+ var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
3383
+ return this.params.splitChannelsOptions.channelColors[e] ? this.params.splitChannelsOptions.channelColors[e].progressColor : this.params.progressColor;
3384
+ }
3385
+ /**
3386
+ * Set the fill color of the waveform behind the cursor.
3387
+ *
3388
+ * @param {string|object} color A CSS color string, or an array of CSS color strings.
3389
+ * @param {?number} channelIdx Optional index of the channel to set its progress color if splitChannels is true
3390
+ * @example wavesurfer.setProgressColor('#400');
3391
+ */
3392
+ }, {
3393
+ key: "setProgressColor",
3394
+ value: function(e, l) {
3395
+ this.params.splitChannelsOptions.channelColors[l] ? this.params.splitChannelsOptions.channelColors[l].progressColor = e : this.params.progressColor = e, this.drawBuffer();
3396
+ }
3397
+ /**
3398
+ * Get the background color of the waveform container.
3399
+ *
3400
+ * @return {string} A CSS color string.
3401
+ */
3402
+ }, {
3403
+ key: "getBackgroundColor",
3404
+ value: function() {
3405
+ return this.params.backgroundColor;
3406
+ }
3407
+ /**
3408
+ * Set the background color of the waveform container.
3409
+ *
3410
+ * @param {string} color A CSS color string.
3411
+ * @example wavesurfer.setBackgroundColor('#FF00FF');
3412
+ */
3413
+ }, {
3414
+ key: "setBackgroundColor",
3415
+ value: function(e) {
3416
+ this.params.backgroundColor = e, g.style(this.container, {
3417
+ background: this.params.backgroundColor
3418
+ });
3419
+ }
3420
+ /**
3421
+ * Get the fill color of the cursor indicating the playhead
3422
+ * position.
3423
+ *
3424
+ * @return {string} A CSS color string.
3425
+ */
3426
+ }, {
3427
+ key: "getCursorColor",
3428
+ value: function() {
3429
+ return this.params.cursorColor;
3430
+ }
3431
+ /**
3432
+ * Set the fill color of the cursor indicating the playhead
3433
+ * position.
3434
+ *
3435
+ * @param {string} color A CSS color string.
3436
+ * @example wavesurfer.setCursorColor('#222');
3437
+ */
3438
+ }, {
3439
+ key: "setCursorColor",
3440
+ value: function(e) {
3441
+ this.params.cursorColor = e, this.drawer.updateCursor();
3442
+ }
3443
+ /**
3444
+ * Get the height of the waveform.
3445
+ *
3446
+ * @return {number} Height measured in pixels.
3447
+ */
3448
+ }, {
3449
+ key: "getHeight",
3450
+ value: function() {
3451
+ return this.params.height;
3452
+ }
3453
+ /**
3454
+ * Set the height of the waveform.
3455
+ *
3456
+ * @param {number} height Height measured in pixels.
3457
+ * @example wavesurfer.setHeight(200);
3458
+ */
3459
+ }, {
3460
+ key: "setHeight",
3461
+ value: function(e) {
3462
+ this.params.height = e, this.drawer.setHeight(e * this.params.pixelRatio), this.drawBuffer();
3463
+ }
3464
+ /**
3465
+ * Hide channels from being drawn on the waveform if splitting channels.
3466
+ *
3467
+ * For example, if we want to draw only the peaks for the right stereo channel:
3468
+ *
3469
+ * const wavesurfer = new WaveSurfer.create({...splitChannels: true});
3470
+ * wavesurfer.load('stereo_audio.mp3');
3471
+ *
3472
+ * wavesurfer.setFilteredChannel([0]); <-- hide left channel peaks.
3473
+ *
3474
+ * @param {array} channelIndices Channels to be filtered out from drawing.
3475
+ * @version 4.0.0
3476
+ */
3477
+ }, {
3478
+ key: "setFilteredChannels",
3479
+ value: function(e) {
3480
+ this.params.splitChannelsOptions.filterChannels = e, this.drawBuffer();
3481
+ }
3482
+ /**
3483
+ * Get the correct peaks for current wave view-port and render wave
3484
+ *
3485
+ * @private
3486
+ * @emits WaveSurfer#redraw
3487
+ */
3488
+ }, {
3489
+ key: "drawBuffer",
3490
+ value: function() {
3491
+ var e = Math.round(this.getDuration() * this.params.minPxPerSec * this.params.pixelRatio), l = this.drawer.getWidth(), A = e, T = 0, S = Math.max(T + l, A);
3492
+ this.params.fillParent && (!this.params.scrollParent || e < l) && (A = l, T = 0, S = A);
3493
+ var D;
3494
+ if (this.params.partialRender) {
3495
+ var B = this.peakCache.addRangeToPeakCache(A, T, S), V;
3496
+ for (V = 0; V < B.length; V++)
3497
+ D = this.backend.getPeaks(A, B[V][0], B[V][1]), this.drawer.drawPeaks(D, A, B[V][0], B[V][1]);
3498
+ } else
3499
+ D = this.backend.getPeaks(A, T, S), this.drawer.drawPeaks(D, A, T, S);
3500
+ this.fireEvent("redraw", D, A);
3501
+ }
3502
+ /**
3503
+ * Horizontally zooms the waveform in and out. It also changes the parameter
3504
+ * `minPxPerSec` and enables the `scrollParent` option. Calling the function
3505
+ * with a falsey parameter will reset the zoom state.
3506
+ *
3507
+ * @param {?number} pxPerSec Number of horizontal pixels per second of
3508
+ * audio, if none is set the waveform returns to unzoomed state
3509
+ * @emits WaveSurfer#zoom
3510
+ * @example wavesurfer.zoom(20);
3511
+ */
3512
+ }, {
3513
+ key: "zoom",
3514
+ value: function(e) {
3515
+ e ? (this.params.minPxPerSec = e, this.params.scrollParent = !0) : (this.params.minPxPerSec = this.defaultParams.minPxPerSec, this.params.scrollParent = !1), this.drawBuffer(), this.drawer.progress(this.backend.getPlayedPercents()), this.drawer.recenter(this.getCurrentTime() / this.getDuration()), this.fireEvent("zoom", e);
3516
+ }
3517
+ /**
3518
+ * Decode buffer and load
3519
+ *
3520
+ * @private
3521
+ * @param {ArrayBuffer} arraybuffer Buffer to process
3522
+ */
3523
+ }, {
3524
+ key: "loadArrayBuffer",
3525
+ value: function(e) {
3526
+ var l = this;
3527
+ this.decodeArrayBuffer(e, function(A) {
3528
+ l.isDestroyed || l.loadDecodedBuffer(A);
3529
+ });
3530
+ }
3531
+ /**
3532
+ * Directly load an externally decoded AudioBuffer
3533
+ *
3534
+ * @private
3535
+ * @param {AudioBuffer} buffer Buffer to process
3536
+ * @emits WaveSurfer#ready
3537
+ */
3538
+ }, {
3539
+ key: "loadDecodedBuffer",
3540
+ value: function(e) {
3541
+ this.backend.load(e), this.drawBuffer(), this.isReady = !0, this.fireEvent("ready");
3542
+ }
3543
+ /**
3544
+ * Loads audio data from a Blob or File object
3545
+ *
3546
+ * @param {Blob|File} blob Audio data
3547
+ * @example
3548
+ */
3549
+ }, {
3550
+ key: "loadBlob",
3551
+ value: function(e) {
3552
+ var l = this, A = new FileReader();
3553
+ A.addEventListener("progress", function(T) {
3554
+ return l.onProgress(T);
3555
+ }), A.addEventListener("load", function(T) {
3556
+ return l.loadArrayBuffer(T.target.result);
3557
+ }), A.addEventListener("error", function() {
3558
+ return l.fireEvent("error", "Error reading file");
3559
+ }), A.readAsArrayBuffer(e), this.empty();
3560
+ }
3561
+ /**
3562
+ * Loads audio and re-renders the waveform.
3563
+ *
3564
+ * @param {string|HTMLMediaElement} url The url of the audio file or the
3565
+ * audio element with the audio
3566
+ * @param {number[]|Number.<Array[]>} peaks Wavesurfer does not have to decode
3567
+ * the audio to render the waveform if this is specified
3568
+ * @param {?string} preload (Use with backend `MediaElement` and `MediaElementWebAudio`)
3569
+ * `'none'|'metadata'|'auto'` Preload attribute for the media element
3570
+ * @param {?number} duration The duration of the audio. This is used to
3571
+ * render the peaks data in the correct size for the audio duration (as
3572
+ * befits the current `minPxPerSec` and zoom value) without having to decode
3573
+ * the audio.
3574
+ * @returns {void}
3575
+ * @throws Will throw an error if the `url` argument is empty.
3576
+ * @example
3577
+ * // uses fetch or media element to load file (depending on backend)
3578
+ * wavesurfer.load('http://example.com/demo.wav');
3579
+ *
3580
+ * // setting preload attribute with media element backend and supplying
3581
+ * // peaks
3582
+ * wavesurfer.load(
3583
+ * 'http://example.com/demo.wav',
3584
+ * [0.0218, 0.0183, 0.0165, 0.0198, 0.2137, 0.2888],
3585
+ * true
3586
+ * );
3587
+ */
3588
+ }, {
3589
+ key: "load",
3590
+ value: function(e, l, A, T) {
3591
+ if (!e)
3592
+ throw new Error("url parameter cannot be empty");
3593
+ if (this.empty(), A) {
3594
+ var S = {
3595
+ "Preload is not 'auto', 'none' or 'metadata'": ["auto", "metadata", "none"].indexOf(A) === -1,
3596
+ "Peaks are not provided": !l,
3597
+ "Backend is not of type 'MediaElement' or 'MediaElementWebAudio'": ["MediaElement", "MediaElementWebAudio"].indexOf(this.params.backend) === -1,
3598
+ "Url is not of type string": typeof e != "string"
3599
+ }, D = Object.keys(S).filter(function(B) {
3600
+ return S[B];
3601
+ });
3602
+ D.length && (console.warn(`Preload parameter of wavesurfer.load will be ignored because:
3603
+ - ` + D.join(`
3604
+ - `)), A = null);
3605
+ }
3606
+ switch (this.params.backend === "WebAudio" && e instanceof HTMLMediaElement && (e = e.src), this.params.backend) {
3607
+ case "WebAudio":
3608
+ return this.loadBuffer(e, l, T);
3609
+ case "MediaElement":
3610
+ case "MediaElementWebAudio":
3611
+ return this.loadMediaElement(e, l, A, T);
3612
+ }
3613
+ }
3614
+ /**
3615
+ * Loads audio using Web Audio buffer backend.
3616
+ *
3617
+ * @private
3618
+ * @emits WaveSurfer#waveform-ready
3619
+ * @param {string} url URL of audio file
3620
+ * @param {number[]|Number.<Array[]>} peaks Peaks data
3621
+ * @param {?number} duration Optional duration of audio file
3622
+ * @returns {void}
3623
+ */
3624
+ }, {
3625
+ key: "loadBuffer",
3626
+ value: function(e, l, A) {
3627
+ var T = this, S = function(B) {
3628
+ return B && T.tmpEvents.push(T.once("ready", B)), T.getArrayBuffer(e, function(V) {
3629
+ return T.loadArrayBuffer(V);
3630
+ });
3631
+ };
3632
+ if (l)
3633
+ this.backend.setPeaks(l, A), this.drawBuffer(), this.fireEvent("waveform-ready"), this.tmpEvents.push(this.once("interaction", S));
3634
+ else
3635
+ return S();
3636
+ }
3637
+ /**
3638
+ * Either create a media element, or load an existing media element.
3639
+ *
3640
+ * @private
3641
+ * @emits WaveSurfer#waveform-ready
3642
+ * @param {string|HTMLMediaElement} urlOrElt Either a path to a media file, or an
3643
+ * existing HTML5 Audio/Video Element
3644
+ * @param {number[]|Number.<Array[]>} peaks Array of peaks. Required to bypass web audio
3645
+ * dependency
3646
+ * @param {?boolean} preload Set to true if the preload attribute of the
3647
+ * audio element should be enabled
3648
+ * @param {?number} duration Optional duration of audio file
3649
+ */
3650
+ }, {
3651
+ key: "loadMediaElement",
3652
+ value: function(e, l, A, T) {
3653
+ var S = this, D = e;
3654
+ if (typeof e == "string")
3655
+ this.backend.load(D, this.mediaContainer, l, A);
3656
+ else {
3657
+ var B = e;
3658
+ this.backend.loadElt(B, l), D = B.src;
3659
+ }
3660
+ this.tmpEvents.push(this.backend.once("canplay", function() {
3661
+ S.backend.destroyed || (S.drawBuffer(), S.isReady = !0, S.fireEvent("ready"));
3662
+ }), this.backend.once("error", function(V) {
3663
+ return S.fireEvent("error", V);
3664
+ })), l && (this.backend.setPeaks(l, T), this.drawBuffer(), this.fireEvent("waveform-ready")), (!l || this.params.forceDecode) && this.backend.supportsWebAudio() && this.getArrayBuffer(D, function(V) {
3665
+ S.decodeArrayBuffer(V, function(N) {
3666
+ S.backend.buffer = N, S.backend.setPeaks(null), S.drawBuffer(), S.fireEvent("waveform-ready");
3667
+ });
3668
+ });
3669
+ }
3670
+ /**
3671
+ * Decode an array buffer and pass data to a callback
3672
+ *
3673
+ * @private
3674
+ * @param {Object} arraybuffer The array buffer to decode
3675
+ * @param {function} callback The function to call on complete
3676
+ */
3677
+ }, {
3678
+ key: "decodeArrayBuffer",
3679
+ value: function(e, l) {
3680
+ var A = this;
3681
+ this.isDestroyed || (this.arraybuffer = e, this.backend.decodeArrayBuffer(e, function(T) {
3682
+ !A.isDestroyed && A.arraybuffer == e && (l(T), A.arraybuffer = null);
3683
+ }, function() {
3684
+ return A.fireEvent("error", "Error decoding audiobuffer");
3685
+ }));
3686
+ }
3687
+ /**
3688
+ * Load an array buffer using fetch and pass the result to a callback
3689
+ *
3690
+ * @param {string} url The URL of the file object
3691
+ * @param {function} callback The function to call on complete
3692
+ * @returns {util.fetchFile} fetch call
3693
+ * @private
3694
+ */
3695
+ }, {
3696
+ key: "getArrayBuffer",
3697
+ value: function(e, l) {
3698
+ var A = this, T = Object.assign({
3699
+ url: e,
3700
+ responseType: "arraybuffer"
3701
+ }, this.params.xhr), S = g.fetchFile(T);
3702
+ return this.currentRequest = S, this.tmpEvents.push(S.on("progress", function(D) {
3703
+ A.onProgress(D);
3704
+ }), S.on("success", function(D) {
3705
+ l(D), A.currentRequest = null;
3706
+ }), S.on("error", function(D) {
3707
+ A.fireEvent("error", D), A.currentRequest = null;
3708
+ })), S;
3709
+ }
3710
+ /**
3711
+ * Called while the audio file is loading
3712
+ *
3713
+ * @private
3714
+ * @param {Event} e Progress event
3715
+ * @emits WaveSurfer#loading
3716
+ */
3717
+ }, {
3718
+ key: "onProgress",
3719
+ value: function(e) {
3720
+ var l;
3721
+ e.lengthComputable ? l = e.loaded / e.total : l = e.loaded / (e.loaded + 1e6), this.fireEvent("loading", Math.round(l * 100), e.target);
3722
+ }
3723
+ /**
3724
+ * Exports PCM data into a JSON array and optionally opens in a new window
3725
+ * as valid JSON Blob instance.
3726
+ *
3727
+ * @param {number} length=1024 The scale in which to export the peaks
3728
+ * @param {number} accuracy=10000
3729
+ * @param {?boolean} noWindow Set to true to disable opening a new
3730
+ * window with the JSON
3731
+ * @param {number} start Start index
3732
+ * @param {number} end End index
3733
+ * @return {Promise} Promise that resolves with array of peaks
3734
+ */
3735
+ }, {
3736
+ key: "exportPCM",
3737
+ value: function(e, l, A, T, S) {
3738
+ e = e || 1024, T = T || 0, l = l || 1e4, A = A || !1;
3739
+ var D = this.backend.getPeaks(e, T, S), B = [].map.call(D, function(V) {
3740
+ return Math.round(V * l) / l;
3741
+ });
3742
+ return new Promise(function(V, N) {
3743
+ if (!A) {
3744
+ var H = new Blob([JSON.stringify(B)], {
3745
+ type: "application/json;charset=utf-8"
3746
+ }), L = URL.createObjectURL(H);
3747
+ window.open(L), URL.revokeObjectURL(L);
3748
+ }
3749
+ V(B);
3750
+ });
3751
+ }
3752
+ /**
3753
+ * Save waveform image as data URI.
3754
+ *
3755
+ * The default format is `image/png`. Other supported types are
3756
+ * `image/jpeg` and `image/webp`.
3757
+ *
3758
+ * @param {string} format='image/png' A string indicating the image format.
3759
+ * The default format type is `image/png`.
3760
+ * @param {number} quality=1 A number between 0 and 1 indicating the image
3761
+ * quality to use for image formats that use lossy compression such as
3762
+ * `image/jpeg` and `image/webp`.
3763
+ * @param {string} type Image data type to return. Either `dataURL` (default)
3764
+ * or `blob`.
3765
+ * @return {string|string[]|Promise} When using `dataURL` type this returns
3766
+ * a single data URL or an array of data URLs, one for each canvas. When using
3767
+ * `blob` type this returns a `Promise` resolving with an array of `Blob`
3768
+ * instances, one for each canvas.
3769
+ */
3770
+ }, {
3771
+ key: "exportImage",
3772
+ value: function(e, l, A) {
3773
+ return e || (e = "image/png"), l || (l = 1), A || (A = "dataURL"), this.drawer.getImage(e, l, A);
3774
+ }
3775
+ /**
3776
+ * Cancel any fetch request currently in progress
3777
+ */
3778
+ }, {
3779
+ key: "cancelAjax",
3780
+ value: function() {
3781
+ this.currentRequest && this.currentRequest.controller && (this.currentRequest._reader && this.currentRequest._reader.cancel().catch(function(e) {
3782
+ }), this.currentRequest.controller.abort(), this.currentRequest = null);
3783
+ }
3784
+ /**
3785
+ * @private
3786
+ */
3787
+ }, {
3788
+ key: "clearTmpEvents",
3789
+ value: function() {
3790
+ this.tmpEvents.forEach(function(e) {
3791
+ return e.un();
3792
+ });
3793
+ }
3794
+ /**
3795
+ * Display empty waveform.
3796
+ */
3797
+ }, {
3798
+ key: "empty",
3799
+ value: function() {
3800
+ this.backend.isPaused() || (this.stop(), this.backend.disconnectSource()), this.isReady = !1, this.cancelAjax(), this.clearTmpEvents(), this.drawer.progress(0), this.drawer.setWidth(0), this.drawer.drawPeaks({
3801
+ length: this.drawer.getWidth()
3802
+ }, 0);
3803
+ }
3804
+ /**
3805
+ * Remove events, elements and disconnect WebAudio nodes.
3806
+ *
3807
+ * @emits WaveSurfer#destroy
3808
+ */
3809
+ }, {
3810
+ key: "destroy",
3811
+ value: function() {
3812
+ this.destroyAllPlugins(), this.fireEvent("destroy"), this.cancelAjax(), this.clearTmpEvents(), this.unAll(), this.params.responsive !== !1 && (window.removeEventListener("resize", this._onResize, !0), window.removeEventListener("orientationchange", this._onResize, !0)), this.backend && (this.backend.destroy(), this.backend = null), this.drawer && this.drawer.destroy(), this.isDestroyed = !0, this.isReady = !1, this.arraybuffer = null;
3813
+ }
3814
+ }], [{
3815
+ key: "create",
3816
+ value: (
3817
+ /**
3818
+ * Instantiate this class, call its `init` function and returns it
3819
+ *
3820
+ * @param {WavesurferParams} params The wavesurfer parameters
3821
+ * @return {Object} WaveSurfer instance
3822
+ * @example const wavesurfer = WaveSurfer.create(params);
3823
+ */
3824
+ function(e) {
3825
+ var l = new s(e);
3826
+ return l.init();
3827
+ }
3828
+ )
3829
+ /**
3830
+ * The library version number is available as a static property of the
3831
+ * WaveSurfer class
3832
+ *
3833
+ * @type {String}
3834
+ * @example
3835
+ * console.log('Using wavesurfer.js ' + WaveSurfer.VERSION);
3836
+ */
3837
+ }]), s;
3838
+ }(g.Observer);
3839
+ h.default = o, k(o, "VERSION", "6.6.4"), k(o, "util", g), j.exports = h.default;
3840
+ }
3841
+ ),
3842
+ /***/
3843
+ "./src/webaudio.js": (
3844
+ /*!*************************!*\
3845
+ !*** ./src/webaudio.js ***!
3846
+ \*************************/
3847
+ /***/
3848
+ (j, h, C) => {
3849
+ Object.defineProperty(h, "__esModule", {
3850
+ value: !0
3851
+ }), h.default = void 0;
3852
+ var g = E(C(
3853
+ /*! ./util */
3854
+ "./src/util/index.js"
3855
+ ));
3856
+ function W(n) {
3857
+ if (typeof WeakMap != "function") return null;
3858
+ var a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap();
3859
+ return (W = function(t) {
3860
+ return t ? o : a;
3861
+ })(n);
3862
+ }
3863
+ function E(n, a) {
3864
+ if (n && n.__esModule)
3865
+ return n;
3866
+ if (n === null || M(n) !== "object" && typeof n != "function")
3867
+ return { default: n };
3868
+ var o = W(a);
3869
+ if (o && o.has(n))
3870
+ return o.get(n);
3871
+ var r = {}, t = Object.defineProperty && Object.getOwnPropertyDescriptor;
3872
+ for (var s in n)
3873
+ if (s !== "default" && Object.prototype.hasOwnProperty.call(n, s)) {
3874
+ var i = t ? Object.getOwnPropertyDescriptor(n, s) : null;
3875
+ i && (i.get || i.set) ? Object.defineProperty(r, s, i) : r[s] = n[s];
3876
+ }
3877
+ return r.default = n, o && o.set(n, r), r;
3878
+ }
3879
+ function M(n) {
3880
+ "@babel/helpers - typeof";
3881
+ return M = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(a) {
3882
+ return typeof a;
3883
+ } : function(a) {
3884
+ return a && typeof Symbol == "function" && a.constructor === Symbol && a !== Symbol.prototype ? "symbol" : typeof a;
3885
+ }, M(n);
3886
+ }
3887
+ function x(n, a) {
3888
+ if (!(n instanceof a))
3889
+ throw new TypeError("Cannot call a class as a function");
3890
+ }
3891
+ function I(n, a) {
3892
+ for (var o = 0; o < a.length; o++) {
3893
+ var r = a[o];
3894
+ r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(n, w(r.key), r);
3895
+ }
3896
+ }
3897
+ function b(n, a, o) {
3898
+ return a && I(n.prototype, a), Object.defineProperty(n, "prototype", { writable: !1 }), n;
3899
+ }
3900
+ function O(n, a) {
3901
+ if (typeof a != "function" && a !== null)
3902
+ throw new TypeError("Super expression must either be null or a function");
3903
+ n.prototype = Object.create(a && a.prototype, { constructor: { value: n, writable: !0, configurable: !0 } }), Object.defineProperty(n, "prototype", { writable: !1 }), a && R(n, a);
3904
+ }
3905
+ function R(n, a) {
3906
+ return R = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(r, t) {
3907
+ return r.__proto__ = t, r;
3908
+ }, R(n, a);
3909
+ }
3910
+ function _(n) {
3911
+ var a = v();
3912
+ return function() {
3913
+ var r = d(n), t;
3914
+ if (a) {
3915
+ var s = d(this).constructor;
3916
+ t = Reflect.construct(r, arguments, s);
3917
+ } else
3918
+ t = r.apply(this, arguments);
3919
+ return p(this, t);
3920
+ };
3921
+ }
3922
+ function p(n, a) {
3923
+ if (a && (M(a) === "object" || typeof a == "function"))
3924
+ return a;
3925
+ if (a !== void 0)
3926
+ throw new TypeError("Derived constructors may only return object or undefined");
3927
+ return c(n);
3928
+ }
3929
+ function c(n) {
3930
+ if (n === void 0)
3931
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
3932
+ return n;
3933
+ }
3934
+ function v() {
3935
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
3936
+ if (typeof Proxy == "function") return !0;
3937
+ try {
3938
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
3939
+ })), !0;
3940
+ } catch {
3941
+ return !1;
3942
+ }
3943
+ }
3944
+ function d(n) {
3945
+ return d = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(o) {
3946
+ return o.__proto__ || Object.getPrototypeOf(o);
3947
+ }, d(n);
3948
+ }
3949
+ function P(n, a, o) {
3950
+ return a = w(a), a in n ? Object.defineProperty(n, a, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : n[a] = o, n;
3951
+ }
3952
+ function w(n) {
3953
+ var a = k(n, "string");
3954
+ return M(a) === "symbol" ? a : String(a);
3955
+ }
3956
+ function k(n, a) {
3957
+ if (M(n) !== "object" || n === null) return n;
3958
+ var o = n[Symbol.toPrimitive];
3959
+ if (o !== void 0) {
3960
+ var r = o.call(n, a);
3961
+ if (M(r) !== "object") return r;
3962
+ throw new TypeError("@@toPrimitive must return a primitive value.");
3963
+ }
3964
+ return (a === "string" ? String : Number)(n);
3965
+ }
3966
+ var y = "playing", f = "paused", m = "finished", u = /* @__PURE__ */ function(n) {
3967
+ O(o, n);
3968
+ var a = _(o);
3969
+ function o(r) {
3970
+ var t, s, i;
3971
+ return x(this, o), i = a.call(this), P(c(i), "audioContext", null), P(c(i), "stateBehaviors", (t = {}, P(t, y, {
3972
+ init: function() {
3973
+ this.addOnAudioProcess();
3974
+ },
3975
+ getPlayedPercents: function() {
3976
+ var l = this.getDuration();
3977
+ return this.getCurrentTime() / l || 0;
3978
+ },
3979
+ getCurrentTime: function() {
3980
+ return this.startPosition + this.getPlayedTime();
3981
+ }
3982
+ }), P(t, f, {
3983
+ init: function() {
3984
+ },
3985
+ getPlayedPercents: function() {
3986
+ var l = this.getDuration();
3987
+ return this.getCurrentTime() / l || 0;
3988
+ },
3989
+ getCurrentTime: function() {
3990
+ return this.startPosition;
3991
+ }
3992
+ }), P(t, m, {
3993
+ init: function() {
3994
+ this.fireEvent("finish");
3995
+ },
3996
+ getPlayedPercents: function() {
3997
+ return 1;
3998
+ },
3999
+ getCurrentTime: function() {
4000
+ return this.getDuration();
4001
+ }
4002
+ }), t)), i.params = r, i.ac = r.audioContext || (i.supportsWebAudio() ? i.getAudioContext() : {}), i.lastPlay = i.ac.currentTime, i.startPosition = 0, i.scheduledPause = null, i.states = (s = {}, P(s, y, Object.create(i.stateBehaviors[y])), P(s, f, Object.create(i.stateBehaviors[f])), P(s, m, Object.create(i.stateBehaviors[m])), s), i.buffer = null, i.filters = [], i.gainNode = null, i.mergedPeaks = null, i.offlineAc = null, i.peaks = null, i.playbackRate = 1, i.analyser = null, i.scriptNode = null, i.source = null, i.splitPeaks = [], i.state = null, i.explicitDuration = r.duration, i.sinkStreamDestination = null, i.sinkAudioElement = null, i.destroyed = !1, i;
4003
+ }
4004
+ return b(o, [{
4005
+ key: "supportsWebAudio",
4006
+ value: (
4007
+ /**
4008
+ * Does the browser support this backend
4009
+ *
4010
+ * @return {boolean} Whether or not this browser supports this backend
4011
+ */
4012
+ function() {
4013
+ return !!(window.AudioContext || window.webkitAudioContext);
4014
+ }
4015
+ )
4016
+ /**
4017
+ * Get the audio context used by this backend or create one
4018
+ *
4019
+ * @return {AudioContext} Existing audio context, or creates a new one
4020
+ */
4021
+ }, {
4022
+ key: "getAudioContext",
4023
+ value: function() {
4024
+ return window.WaveSurferAudioContext || (window.WaveSurferAudioContext = new (window.AudioContext || window.webkitAudioContext)()), window.WaveSurferAudioContext;
4025
+ }
4026
+ /**
4027
+ * Get the offline audio context used by this backend or create one
4028
+ *
4029
+ * @param {number} sampleRate The sample rate to use
4030
+ * @return {OfflineAudioContext} Existing offline audio context, or creates
4031
+ * a new one
4032
+ */
4033
+ }, {
4034
+ key: "getOfflineAudioContext",
4035
+ value: function(t) {
4036
+ return window.WaveSurferOfflineAudioContext || (window.WaveSurferOfflineAudioContext = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 2, t)), window.WaveSurferOfflineAudioContext;
4037
+ }
4038
+ }, {
4039
+ key: "init",
4040
+ value: function() {
4041
+ this.createVolumeNode(), this.createScriptNode(), this.createAnalyserNode(), this.setState(f), this.setPlaybackRate(this.params.audioRate), this.setLength(0);
4042
+ }
4043
+ /** @private */
4044
+ }, {
4045
+ key: "disconnectFilters",
4046
+ value: function() {
4047
+ this.filters && (this.filters.forEach(function(t) {
4048
+ t && t.disconnect();
4049
+ }), this.filters = null, this.analyser.connect(this.gainNode));
4050
+ }
4051
+ /**
4052
+ * @private
4053
+ *
4054
+ * @param {string} state The new state
4055
+ */
4056
+ }, {
4057
+ key: "setState",
4058
+ value: function(t) {
4059
+ this.state !== this.states[t] && (this.state = this.states[t], this.state.init.call(this));
4060
+ }
4061
+ /**
4062
+ * Unpacked `setFilters()`
4063
+ *
4064
+ * @param {...AudioNode} filters One or more filters to set
4065
+ */
4066
+ }, {
4067
+ key: "setFilter",
4068
+ value: function() {
4069
+ for (var t = arguments.length, s = new Array(t), i = 0; i < t; i++)
4070
+ s[i] = arguments[i];
4071
+ this.setFilters(s);
4072
+ }
4073
+ /**
4074
+ * Insert custom Web Audio nodes into the graph
4075
+ *
4076
+ * @param {AudioNode[]} filters Packed filters array
4077
+ * @example
4078
+ * const lowpass = wavesurfer.backend.ac.createBiquadFilter();
4079
+ * wavesurfer.backend.setFilter(lowpass);
4080
+ */
4081
+ }, {
4082
+ key: "setFilters",
4083
+ value: function(t) {
4084
+ this.disconnectFilters(), t && t.length && (this.filters = t, this.analyser.disconnect(), t.reduce(function(s, i) {
4085
+ return s.connect(i), i;
4086
+ }, this.analyser).connect(this.gainNode));
4087
+ }
4088
+ /** Create ScriptProcessorNode to process audio */
4089
+ }, {
4090
+ key: "createScriptNode",
4091
+ value: function() {
4092
+ this.params.audioScriptProcessor && (this.scriptNode = this.params.audioScriptProcessor, this.scriptNode.connect(this.ac.destination));
4093
+ }
4094
+ /** @private */
4095
+ }, {
4096
+ key: "addOnAudioProcess",
4097
+ value: function() {
4098
+ var t = this, s = function i() {
4099
+ var e = t.getCurrentTime();
4100
+ e >= t.getDuration() && t.state !== t.states[m] ? (t.setState(m), t.fireEvent("pause")) : e >= t.scheduledPause && t.state !== t.states[f] ? t.pause() : t.state === t.states[y] && (t.fireEvent("audioprocess", e), g.frame(i)());
4101
+ };
4102
+ s();
4103
+ }
4104
+ /** Create analyser node to perform audio analysis */
4105
+ }, {
4106
+ key: "createAnalyserNode",
4107
+ value: function() {
4108
+ this.analyser = this.ac.createAnalyser(), this.analyser.connect(this.gainNode);
4109
+ }
4110
+ /**
4111
+ * Create the gain node needed to control the playback volume.
4112
+ *
4113
+ */
4114
+ }, {
4115
+ key: "createVolumeNode",
4116
+ value: function() {
4117
+ this.ac.createGain ? this.gainNode = this.ac.createGain() : this.gainNode = this.ac.createGainNode(), this.gainNode.connect(this.ac.destination);
4118
+ }
4119
+ /**
4120
+ * Set the sink id for the media player
4121
+ *
4122
+ * @param {string} deviceId String value representing audio device id.
4123
+ * @returns {Promise} A Promise that resolves to `undefined` when there
4124
+ * are no errors.
4125
+ */
4126
+ }, {
4127
+ key: "setSinkId",
4128
+ value: function(t) {
4129
+ return t ? (this.sinkAudioElement || (this.sinkAudioElement = new window.Audio(), this.sinkAudioElement.autoplay = !0), this.sinkAudioElement.setSinkId ? (this.sinkStreamDestination || (this.sinkStreamDestination = this.ac.createMediaStreamDestination()), this.gainNode.disconnect(), this.gainNode.connect(this.sinkStreamDestination), this.sinkAudioElement.srcObject = this.sinkStreamDestination.stream, this.sinkAudioElement.setSinkId(t)) : Promise.reject(new Error("setSinkId is not supported in your browser"))) : Promise.reject(new Error("Invalid deviceId: " + t));
4130
+ }
4131
+ /**
4132
+ * Set the audio volume
4133
+ *
4134
+ * @param {number} value A floating point value between 0 and 1.
4135
+ */
4136
+ }, {
4137
+ key: "setVolume",
4138
+ value: function(t) {
4139
+ this.gainNode.gain.setValueAtTime(t, this.ac.currentTime);
4140
+ }
4141
+ /**
4142
+ * Get the current volume
4143
+ *
4144
+ * @return {number} value A floating point value between 0 and 1.
4145
+ */
4146
+ }, {
4147
+ key: "getVolume",
4148
+ value: function() {
4149
+ return this.gainNode.gain.value;
4150
+ }
4151
+ /**
4152
+ * Decode an array buffer and pass data to a callback
4153
+ *
4154
+ * @private
4155
+ * @param {ArrayBuffer} arraybuffer The array buffer to decode
4156
+ * @param {function} callback The function to call on complete.
4157
+ * @param {function} errback The function to call on error.
4158
+ */
4159
+ }, {
4160
+ key: "decodeArrayBuffer",
4161
+ value: function(t, s, i) {
4162
+ this.offlineAc || (this.offlineAc = this.getOfflineAudioContext(this.ac && this.ac.sampleRate ? this.ac.sampleRate : 44100)), "webkitAudioContext" in window ? this.offlineAc.decodeAudioData(t, function(e) {
4163
+ return s(e);
4164
+ }, i) : this.offlineAc.decodeAudioData(t).then(function(e) {
4165
+ return s(e);
4166
+ }).catch(function(e) {
4167
+ return i(e);
4168
+ });
4169
+ }
4170
+ /**
4171
+ * Set pre-decoded peaks
4172
+ *
4173
+ * @param {number[]|Number.<Array[]>} peaks Peaks data
4174
+ * @param {?number} duration Explicit duration
4175
+ */
4176
+ }, {
4177
+ key: "setPeaks",
4178
+ value: function(t, s) {
4179
+ s != null && (this.explicitDuration = s), this.peaks = t;
4180
+ }
4181
+ /**
4182
+ * Set the rendered length (different from the length of the audio)
4183
+ *
4184
+ * @param {number} length The rendered length
4185
+ */
4186
+ }, {
4187
+ key: "setLength",
4188
+ value: function(t) {
4189
+ if (!(this.mergedPeaks && t == 2 * this.mergedPeaks.length - 1 + 2)) {
4190
+ this.splitPeaks = [], this.mergedPeaks = [];
4191
+ var s = this.buffer ? this.buffer.numberOfChannels : 1, i;
4192
+ for (i = 0; i < s; i++)
4193
+ this.splitPeaks[i] = [], this.splitPeaks[i][2 * (t - 1)] = 0, this.splitPeaks[i][2 * (t - 1) + 1] = 0;
4194
+ this.mergedPeaks[2 * (t - 1)] = 0, this.mergedPeaks[2 * (t - 1) + 1] = 0;
4195
+ }
4196
+ }
4197
+ /**
4198
+ * Compute the max and min value of the waveform when broken into <length> subranges.
4199
+ *
4200
+ * @param {number} length How many subranges to break the waveform into.
4201
+ * @param {number} first First sample in the required range.
4202
+ * @param {number} last Last sample in the required range.
4203
+ * @return {number[]|Number.<Array[]>} Array of 2*<length> peaks or array of arrays of
4204
+ * peaks consisting of (max, min) values for each subrange.
4205
+ */
4206
+ }, {
4207
+ key: "getPeaks",
4208
+ value: function(t, s, i) {
4209
+ if (this.peaks)
4210
+ return this.peaks;
4211
+ if (!this.buffer)
4212
+ return [];
4213
+ if (s = s || 0, i = i || t - 1, this.setLength(t), !this.buffer)
4214
+ return this.params.splitChannels ? this.splitPeaks : this.mergedPeaks;
4215
+ if (!this.buffer.length) {
4216
+ var e = this.createBuffer(1, 4096, this.sampleRate);
4217
+ this.buffer = e.buffer;
4218
+ }
4219
+ var l = this.buffer.length / t, A = ~~(l / 10) || 1, T = this.buffer.numberOfChannels, S;
4220
+ for (S = 0; S < T; S++) {
4221
+ var D = this.splitPeaks[S], B = this.buffer.getChannelData(S), V = void 0;
4222
+ for (V = s; V <= i; V++) {
4223
+ var N = ~~(V * l), H = ~~(N + l), L = B[N], U = L, F = void 0;
4224
+ for (F = N; F < H; F += A) {
4225
+ var z = B[F];
4226
+ z > U && (U = z), z < L && (L = z);
4227
+ }
4228
+ D[2 * V] = U, D[2 * V + 1] = L, (S == 0 || U > this.mergedPeaks[2 * V]) && (this.mergedPeaks[2 * V] = U), (S == 0 || L < this.mergedPeaks[2 * V + 1]) && (this.mergedPeaks[2 * V + 1] = L);
4229
+ }
4230
+ }
4231
+ return this.params.splitChannels ? this.splitPeaks : this.mergedPeaks;
4232
+ }
4233
+ /**
4234
+ * Get the position from 0 to 1
4235
+ *
4236
+ * @return {number} Position
4237
+ */
4238
+ }, {
4239
+ key: "getPlayedPercents",
4240
+ value: function() {
4241
+ return this.state.getPlayedPercents.call(this);
4242
+ }
4243
+ /** @private */
4244
+ }, {
4245
+ key: "disconnectSource",
4246
+ value: function() {
4247
+ this.source && this.source.disconnect();
4248
+ }
4249
+ /**
4250
+ * Destroy all references with WebAudio, disconnecting audio nodes and closing Audio Context
4251
+ */
4252
+ }, {
4253
+ key: "destroyWebAudio",
4254
+ value: function() {
4255
+ this.disconnectFilters(), this.disconnectSource(), this.gainNode.disconnect(), this.scriptNode && this.scriptNode.disconnect(), this.analyser.disconnect(), this.params.closeAudioContext && (typeof this.ac.close == "function" && this.ac.state != "closed" && this.ac.close(), this.ac = null, this.params.audioContext ? this.params.audioContext = null : window.WaveSurferAudioContext = null, window.WaveSurferOfflineAudioContext = null), this.sinkStreamDestination && (this.sinkAudioElement.pause(), this.sinkAudioElement.srcObject = null, this.sinkStreamDestination.disconnect(), this.sinkStreamDestination = null);
4256
+ }
4257
+ /**
4258
+ * This is called when wavesurfer is destroyed
4259
+ */
4260
+ }, {
4261
+ key: "destroy",
4262
+ value: function() {
4263
+ this.isPaused() || this.pause(), this.unAll(), this.buffer = null, this.destroyed = !0, this.destroyWebAudio();
4264
+ }
4265
+ /**
4266
+ * Loaded a decoded audio buffer
4267
+ *
4268
+ * @param {Object} buffer Decoded audio buffer to load
4269
+ */
4270
+ }, {
4271
+ key: "load",
4272
+ value: function(t) {
4273
+ this.startPosition = 0, this.lastPlay = this.ac.currentTime, this.buffer = t, this.createSource();
4274
+ }
4275
+ /** @private */
4276
+ }, {
4277
+ key: "createSource",
4278
+ value: function() {
4279
+ this.disconnectSource(), this.source = this.ac.createBufferSource(), this.source.start = this.source.start || this.source.noteGrainOn, this.source.stop = this.source.stop || this.source.noteOff, this.setPlaybackRate(this.playbackRate), this.source.buffer = this.buffer, this.source.connect(this.analyser);
4280
+ }
4281
+ /**
4282
+ * @private
4283
+ *
4284
+ * some browsers require an explicit call to #resume before they will play back audio
4285
+ */
4286
+ }, {
4287
+ key: "resumeAudioContext",
4288
+ value: function() {
4289
+ this.ac.state == "suspended" && this.ac.resume && this.ac.resume();
4290
+ }
4291
+ /**
4292
+ * Used by `wavesurfer.isPlaying()` and `wavesurfer.playPause()`
4293
+ *
4294
+ * @return {boolean} Whether or not this backend is currently paused
4295
+ */
4296
+ }, {
4297
+ key: "isPaused",
4298
+ value: function() {
4299
+ return this.state !== this.states[y];
4300
+ }
4301
+ /**
4302
+ * Used by `wavesurfer.getDuration()`
4303
+ *
4304
+ * @return {number} Duration of loaded buffer
4305
+ */
4306
+ }, {
4307
+ key: "getDuration",
4308
+ value: function() {
4309
+ return this.explicitDuration ? this.explicitDuration : this.buffer ? this.buffer.duration : 0;
4310
+ }
4311
+ /**
4312
+ * Used by `wavesurfer.seekTo()`
4313
+ *
4314
+ * @param {number} start Position to start at in seconds
4315
+ * @param {number} end Position to end at in seconds
4316
+ * @return {{start: number, end: number}} Object containing start and end
4317
+ * positions
4318
+ */
4319
+ }, {
4320
+ key: "seekTo",
4321
+ value: function(t, s) {
4322
+ if (this.buffer)
4323
+ return this.scheduledPause = null, t == null && (t = this.getCurrentTime(), t >= this.getDuration() && (t = 0)), s == null && (s = this.getDuration()), this.startPosition = t, this.lastPlay = this.ac.currentTime, this.state === this.states[m] && this.setState(f), {
4324
+ start: t,
4325
+ end: s
4326
+ };
4327
+ }
4328
+ /**
4329
+ * Get the playback position in seconds
4330
+ *
4331
+ * @return {number} The playback position in seconds
4332
+ */
4333
+ }, {
4334
+ key: "getPlayedTime",
4335
+ value: function() {
4336
+ return (this.ac.currentTime - this.lastPlay) * this.playbackRate;
4337
+ }
4338
+ /**
4339
+ * Plays the loaded audio region.
4340
+ *
4341
+ * @param {number} start Start offset in seconds, relative to the beginning
4342
+ * of a clip.
4343
+ * @param {number} end When to stop relative to the beginning of a clip.
4344
+ */
4345
+ }, {
4346
+ key: "play",
4347
+ value: function(t, s) {
4348
+ if (this.buffer) {
4349
+ this.createSource();
4350
+ var i = this.seekTo(t, s);
4351
+ t = i.start, s = i.end, this.scheduledPause = s, this.source.start(0, t), this.resumeAudioContext(), this.setState(y), this.fireEvent("play");
4352
+ }
4353
+ }
4354
+ /**
4355
+ * Pauses the loaded audio.
4356
+ */
4357
+ }, {
4358
+ key: "pause",
4359
+ value: function() {
4360
+ this.scheduledPause = null, this.startPosition += this.getPlayedTime();
4361
+ try {
4362
+ this.source && this.source.stop(0);
4363
+ } catch {
4364
+ }
4365
+ this.setState(f), this.fireEvent("pause");
4366
+ }
4367
+ /**
4368
+ * Returns the current time in seconds relative to the audio-clip's
4369
+ * duration.
4370
+ *
4371
+ * @return {number} The current time in seconds
4372
+ */
4373
+ }, {
4374
+ key: "getCurrentTime",
4375
+ value: function() {
4376
+ return this.state.getCurrentTime.call(this);
4377
+ }
4378
+ /**
4379
+ * Returns the current playback rate. (0=no playback, 1=normal playback)
4380
+ *
4381
+ * @return {number} The current playback rate
4382
+ */
4383
+ }, {
4384
+ key: "getPlaybackRate",
4385
+ value: function() {
4386
+ return this.playbackRate;
4387
+ }
4388
+ /**
4389
+ * Set the audio source playback rate.
4390
+ *
4391
+ * @param {number} value The playback rate to use
4392
+ */
4393
+ }, {
4394
+ key: "setPlaybackRate",
4395
+ value: function(t) {
4396
+ this.playbackRate = t || 1, this.source && this.source.playbackRate.setValueAtTime(this.playbackRate, this.ac.currentTime);
4397
+ }
4398
+ /**
4399
+ * Set a point in seconds for playback to stop at.
4400
+ *
4401
+ * @param {number} end Position to end at
4402
+ * @version 3.3.0
4403
+ */
4404
+ }, {
4405
+ key: "setPlayEnd",
4406
+ value: function(t) {
4407
+ this.scheduledPause = t;
4408
+ }
4409
+ }]), o;
4410
+ }(g.Observer);
4411
+ h.default = u, j.exports = h.default;
4412
+ }
4413
+ ),
4414
+ /***/
4415
+ "./node_modules/debounce/index.js": (
4416
+ /*!****************************************!*\
4417
+ !*** ./node_modules/debounce/index.js ***!
4418
+ \****************************************/
4419
+ /***/
4420
+ (j) => {
4421
+ function h(C, g, W) {
4422
+ var E, M, x, I, b;
4423
+ g == null && (g = 100);
4424
+ function O() {
4425
+ var _ = Date.now() - I;
4426
+ _ < g && _ >= 0 ? E = setTimeout(O, g - _) : (E = null, W || (b = C.apply(x, M), x = M = null));
4427
+ }
4428
+ var R = function() {
4429
+ x = this, M = arguments, I = Date.now();
4430
+ var _ = W && !E;
4431
+ return E || (E = setTimeout(O, g)), _ && (b = C.apply(x, M), x = M = null), b;
4432
+ };
4433
+ return R.clear = function() {
4434
+ E && (clearTimeout(E), E = null);
4435
+ }, R.flush = function() {
4436
+ E && (b = C.apply(x, M), x = M = null, clearTimeout(E), E = null);
4437
+ }, R;
4438
+ }
4439
+ h.debounce = h, j.exports = h;
4440
+ }
4441
+ )
4442
+ /******/
4443
+ }, Q = {};
4444
+ function G(j) {
4445
+ var h = Q[j];
4446
+ if (h !== void 0)
4447
+ return h.exports;
4448
+ var C = Q[j] = {
4449
+ /******/
4450
+ // no module.id needed
4451
+ /******/
4452
+ // no module.loaded needed
4453
+ /******/
4454
+ exports: {}
4455
+ /******/
4456
+ };
4457
+ return X[j](C, C.exports, G), C.exports;
4458
+ }
4459
+ var K = G("./src/wavesurfer.js");
4460
+ return K;
4461
+ })()
4462
+ ));
4463
+ })(re);
4464
+ var ne = re.exports;
4465
+ const le = /* @__PURE__ */ ue(ne), fe = /* @__PURE__ */ oe({
4466
+ __proto__: null,
4467
+ default: le
4468
+ }, [ne]);
4469
+ export {
4470
+ fe as w
4471
+ };