lingo3d-react
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
1,094 lines • 200 kB
JavaScript
import { aX as se } from "./index-895cfa2f.mjs";
function oe(X, Z) {
for (var Q = 0; Q < Z.length; Q++) {
const U = Z[Q];
if (typeof U != "string" && !Array.isArray(U)) {
for (const z in U)
if (z !== "default" && !(z in X)) {
const K = Object.getOwnPropertyDescriptor(U, z);
K && Object.defineProperty(X, z, K.get ? K : {
enumerable: !0,
get: () => U[z]
});
}
}
}
return Object.freeze(Object.defineProperty(X, Symbol.toStringTag, { value: "Module" }));
}
var $ = {}, ue = {
get exports() {
return $;
},
set exports(X) {
$ = X;
}
};
/*!
* wavesurfer.js 6.6.2 (2023-03-26)
* https://wavesurfer-js.org
* @license BSD-3-Clause
*/
(function(X, Z) {
(function(U, z) {
X.exports = z();
})(self, () => (
/******/
(() => {
var Q = {
/***/
"./src/drawer.canvasentry.js": (
/*!***********************************!*\
!*** ./src/drawer.canvasentry.js ***!
\***********************************/
/***/
(D, h, O) => {
Object.defineProperty(h, "__esModule", {
value: !0
}), h.default = void 0;
var b = _(O(
/*! ./util/style */
"./src/util/style.js"
)), M = _(O(
/*! ./util/get-id */
"./src/util/get-id.js"
));
function _(p) {
return p && p.__esModule ? p : { default: p };
}
function T(p) {
return T = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(f) {
return typeof f;
} : function(f) {
return f && typeof Symbol == "function" && f.constructor === Symbol && f !== Symbol.prototype ? "symbol" : typeof f;
}, T(p);
}
function W(p, f) {
if (!(p instanceof f))
throw new TypeError("Cannot call a class as a function");
}
function B(p, f) {
for (var v = 0; v < f.length; v++) {
var d = f[v];
d.enumerable = d.enumerable || !1, d.configurable = !0, "value" in d && (d.writable = !0), Object.defineProperty(p, C(d.key), d);
}
}
function g(p, f, v) {
return f && B(p.prototype, f), v && B(p, v), Object.defineProperty(p, "prototype", { writable: !1 }), p;
}
function C(p) {
var f = E(p, "string");
return T(f) === "symbol" ? f : String(f);
}
function E(p, f) {
if (T(p) !== "object" || p === null)
return p;
var v = p[Symbol.toPrimitive];
if (v !== void 0) {
var d = v.call(p, f || "default");
if (T(d) !== "object")
return d;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (f === "string" ? String : Number)(p);
}
var R = /* @__PURE__ */ function() {
function p() {
W(this, p), this.wave = null, this.waveCtx = null, this.progress = null, this.progressCtx = null, this.start = 0, this.end = 1, this.id = (0, M.default)(typeof this.constructor.name < "u" ? this.constructor.name.toLowerCase() + "_" : "canvasentry_"), this.canvasContextAttributes = {};
}
return g(p, [{
key: "initWave",
value: function(v) {
this.wave = v, this.waveCtx = this.wave.getContext("2d", this.canvasContextAttributes);
}
/**
* Store the progress wave canvas element and create the 2D rendering
* context
*
* @param {HTMLCanvasElement} element The progress wave `canvas` element.
*/
}, {
key: "initProgress",
value: function(v) {
this.progress = v, this.progressCtx = this.progress.getContext("2d", this.canvasContextAttributes);
}
/**
* Update the dimensions
*
* @param {number} elementWidth Width of the entry
* @param {number} totalWidth Total width of the multi canvas renderer
* @param {number} width The new width of the element
* @param {number} height The new height of the element
*/
}, {
key: "updateDimensions",
value: function(v, d, A, w) {
this.start = this.wave.offsetLeft / d || 0, this.end = this.start + v / d, this.wave.width = A, this.wave.height = w;
var k = {
width: v + "px"
};
(0, b.default)(this.wave, k), this.hasProgressCanvas && (this.progress.width = A, this.progress.height = w, (0, b.default)(this.progress, k));
}
/**
* Clear the wave and progress rendering contexts
*/
}, {
key: "clearWave",
value: function() {
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);
}
/**
* Set the fill styles for wave and progress
* @param {string|string[]} waveColor Fill color for the wave canvas,
* or an array of colors to apply as a gradient
* @param {?string|string[]} progressColor Fill color for the progress canvas,
* or an array of colors to apply as a gradient
*/
}, {
key: "setFillStyles",
value: function(v, d) {
this.waveCtx.fillStyle = this.getFillStyle(this.waveCtx, v), this.hasProgressCanvas && (this.progressCtx.fillStyle = this.getFillStyle(this.progressCtx, d));
}
/**
* Utility function to handle wave color arguments
*
* When the color argument type is a string or CanvasGradient instance,
* it will be returned as is. Otherwise, it will be treated as an array,
* and a new CanvasGradient will be returned
*
* @since 6.0.0
* @param {CanvasRenderingContext2D} ctx Rendering context of target canvas
* @param {string|string[]|CanvasGradient} color Either a single fill color
* for the wave canvas, an existing CanvasGradient instance, or an array
* of colors to apply as a gradient
* @returns {string|CanvasGradient} Returns a string fillstyle value, or a
* canvas gradient
*/
}, {
key: "getFillStyle",
value: function(v, d) {
if (typeof d == "string" || d instanceof CanvasGradient)
return d;
var A = v.createLinearGradient(0, 0, 0, v.canvas.height);
return d.forEach(function(w, k) {
return A.addColorStop(k / d.length, w);
}), A;
}
/**
* Set the canvas transforms for wave and progress
*
* @param {boolean} vertical Whether to render vertically
*/
}, {
key: "applyCanvasTransforms",
value: function(v) {
v && (this.waveCtx.setTransform(0, 1, 1, 0, 0, 0), this.hasProgressCanvas && this.progressCtx.setTransform(0, 1, 1, 0, 0, 0));
}
/**
* Draw a rectangle for wave and progress
*
* @param {number} x X start position
* @param {number} y Y start position
* @param {number} width Width of the rectangle
* @param {number} height Height of the rectangle
* @param {number} radius Radius of the rectangle
*/
}, {
key: "fillRects",
value: function(v, d, A, w, k) {
this.fillRectToContext(this.waveCtx, v, d, A, w, k), this.hasProgressCanvas && this.fillRectToContext(this.progressCtx, v, d, A, w, k);
}
/**
* Draw the actual rectangle on a `canvas` element
*
* @param {CanvasRenderingContext2D} ctx Rendering context of target canvas
* @param {number} x X start position
* @param {number} y Y start position
* @param {number} width Width of the rectangle
* @param {number} height Height of the rectangle
* @param {number} radius Radius of the rectangle
*/
}, {
key: "fillRectToContext",
value: function(v, d, A, w, k, y) {
v && (y ? this.drawRoundedRect(v, d, A, w, k, y) : v.fillRect(d, A, w, k));
}
/**
* Draw a rounded rectangle on Canvas
*
* @param {CanvasRenderingContext2D} ctx Canvas context
* @param {number} x X-position of the rectangle
* @param {number} y Y-position of the rectangle
* @param {number} width Width of the rectangle
* @param {number} height Height of the rectangle
* @param {number} radius Radius of the rectangle
*
* @return {void}
* @example drawRoundedRect(ctx, 50, 50, 5, 10, 3)
*/
}, {
key: "drawRoundedRect",
value: function(v, d, A, w, k, y) {
k !== 0 && (k < 0 && (k *= -1, A -= k), v.beginPath(), v.moveTo(d + y, A), v.lineTo(d + w - y, A), v.quadraticCurveTo(d + w, A, d + w, A + y), v.lineTo(d + w, A + k - y), v.quadraticCurveTo(d + w, A + k, d + w - y, A + k), v.lineTo(d + y, A + k), v.quadraticCurveTo(d, A + k, d, A + k - y), v.lineTo(d, A + y), v.quadraticCurveTo(d, A, d + y, A), v.closePath(), v.fill());
}
/**
* Render the actual wave and progress lines
*
* @param {number[]} peaks Array with peaks data
* @param {number} absmax Maximum peak value (absolute)
* @param {number} halfH Half the height of the waveform
* @param {number} offsetY Offset to the top
* @param {number} start The x-offset of the beginning of the area that
* should be rendered
* @param {number} end The x-offset of the end of the area that
* should be rendered
*/
}, {
key: "drawLines",
value: function(v, d, A, w, k, y) {
this.drawLineToContext(this.waveCtx, v, d, A, w, k, y), this.hasProgressCanvas && this.drawLineToContext(this.progressCtx, v, d, A, w, k, y);
}
/**
* Render the actual waveform line on a `canvas` element
*
* @param {CanvasRenderingContext2D} ctx Rendering context of target canvas
* @param {number[]} peaks Array with peaks data
* @param {number} absmax Maximum peak value (absolute)
* @param {number} halfH Half the height of the waveform
* @param {number} offsetY Offset to the top
* @param {number} start The x-offset of the beginning of the area that
* should be rendered
* @param {number} end The x-offset of the end of the area that
* should be rendered
*/
}, {
key: "drawLineToContext",
value: function(v, d, A, w, k, y, c) {
if (v) {
var m = d.length / 2, u = Math.round(m * this.start), n = Math.round(m * this.end) + 1, i = u, o = n, r = this.wave.width / (o - i - 1), t = w + k, s = A / w;
v.beginPath(), v.moveTo((i - u) * r, t), v.lineTo((i - u) * r, t - Math.round((d[2 * i] || 0) / s));
var a, e, l;
for (a = i; a < o; a++)
e = d[2 * a] || 0, l = Math.round(e / s), v.lineTo((a - u) * r + this.halfPixel, t - l);
var P = o - 1;
for (P; P >= i; P--)
e = d[2 * P + 1] || 0, l = Math.round(e / s), v.lineTo((P - u) * r + this.halfPixel, t - l);
v.lineTo((i - u) * r, t - Math.round((d[2 * i + 1] || 0) / s)), v.closePath(), v.fill();
}
}
/**
* Destroys this entry
*/
}, {
key: "destroy",
value: function() {
this.waveCtx = null, this.wave = null, this.progressCtx = null, this.progress = null;
}
/**
* Return image data of the wave `canvas` element
*
* When using a `type` of `'blob'`, this will return a `Promise` that
* resolves with a `Blob` instance.
*
* @param {string} format='image/png' An optional value of a format type.
* @param {number} quality=0.92 An optional value between 0 and 1.
* @param {string} type='dataURL' Either 'dataURL' or 'blob'.
* @return {string|Promise} When using the default `'dataURL'` `type` this
* returns a data URL. When using the `'blob'` `type` this returns a
* `Promise` that resolves with a `Blob` instance.
*/
}, {
key: "getImage",
value: function(v, d, A) {
var w = this;
if (A === "blob")
return new Promise(function(k) {
w.wave.toBlob(k, v, d);
});
if (A === "dataURL")
return this.wave.toDataURL(v, d);
}
}]), p;
}();
h.default = R, D.exports = h.default;
}
),
/***/
"./src/drawer.js": (
/*!***********************!*\
!*** ./src/drawer.js ***!
\***********************/
/***/
(D, h, O) => {
function b(y) {
return b = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(c) {
return typeof c;
} : function(c) {
return c && typeof Symbol == "function" && c.constructor === Symbol && c !== Symbol.prototype ? "symbol" : typeof c;
}, b(y);
}
Object.defineProperty(h, "__esModule", {
value: !0
}), h.default = void 0;
var M = T(O(
/*! ./util */
"./src/util/index.js"
));
function _(y) {
if (typeof WeakMap != "function")
return null;
var c = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap();
return (_ = function(n) {
return n ? m : c;
})(y);
}
function T(y, c) {
if (!c && y && y.__esModule)
return y;
if (y === null || b(y) !== "object" && typeof y != "function")
return { default: y };
var m = _(c);
if (m && m.has(y))
return m.get(y);
var u = {}, n = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var i in y)
if (i !== "default" && Object.prototype.hasOwnProperty.call(y, i)) {
var o = n ? Object.getOwnPropertyDescriptor(y, i) : null;
o && (o.get || o.set) ? Object.defineProperty(u, i, o) : u[i] = y[i];
}
return u.default = y, m && m.set(y, u), u;
}
function W(y, c) {
if (!(y instanceof c))
throw new TypeError("Cannot call a class as a function");
}
function B(y, c) {
for (var m = 0; m < c.length; m++) {
var u = c[m];
u.enumerable = u.enumerable || !1, u.configurable = !0, "value" in u && (u.writable = !0), Object.defineProperty(y, C(u.key), u);
}
}
function g(y, c, m) {
return c && B(y.prototype, c), m && B(y, m), Object.defineProperty(y, "prototype", { writable: !1 }), y;
}
function C(y) {
var c = E(y, "string");
return b(c) === "symbol" ? c : String(c);
}
function E(y, c) {
if (b(y) !== "object" || y === null)
return y;
var m = y[Symbol.toPrimitive];
if (m !== void 0) {
var u = m.call(y, c || "default");
if (b(u) !== "object")
return u;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (c === "string" ? String : Number)(y);
}
function R(y, c) {
if (typeof c != "function" && c !== null)
throw new TypeError("Super expression must either be null or a function");
y.prototype = Object.create(c && c.prototype, { constructor: { value: y, writable: !0, configurable: !0 } }), Object.defineProperty(y, "prototype", { writable: !1 }), c && p(y, c);
}
function p(y, c) {
return p = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(u, n) {
return u.__proto__ = n, u;
}, p(y, c);
}
function f(y) {
var c = A();
return function() {
var u = w(y), n;
if (c) {
var i = w(this).constructor;
n = Reflect.construct(u, arguments, i);
} else
n = u.apply(this, arguments);
return v(this, n);
};
}
function v(y, c) {
if (c && (b(c) === "object" || typeof c == "function"))
return c;
if (c !== void 0)
throw new TypeError("Derived constructors may only return object or undefined");
return d(y);
}
function d(y) {
if (y === void 0)
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return y;
}
function A() {
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
return !1;
if (typeof Proxy == "function")
return !0;
try {
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
})), !0;
} catch {
return !1;
}
}
function w(y) {
return w = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(m) {
return m.__proto__ || Object.getPrototypeOf(m);
}, w(y);
}
var k = /* @__PURE__ */ function(y) {
R(m, y);
var c = f(m);
function m(u, n) {
var i;
return W(this, m), i = c.call(this), i.container = M.withOrientation(u, n.vertical), i.params = n, i.width = 0, i.height = n.height * i.params.pixelRatio, i.lastPos = 0, i.wrapper = null, i;
}
return g(m, [{
key: "style",
value: function(n, i) {
return M.style(n, i);
}
/**
* Create the wrapper `<wave>` element, style it and set up the events for
* interaction
*/
}, {
key: "createWrapper",
value: function() {
this.wrapper = M.withOrientation(this.container.appendChild(document.createElement("wave")), this.params.vertical), this.style(this.wrapper, {
display: "block",
position: "relative",
userSelect: "none",
webkitUserSelect: "none",
height: this.params.height + "px"
}), (this.params.fillParent || this.params.scrollParent) && this.style(this.wrapper, {
width: "100%",
cursor: this.params.hideCursor ? "none" : "auto",
overflowX: this.params.hideScrollbar ? "hidden" : "auto",
overflowY: "hidden"
}), this.setupWrapperEvents();
}
/**
* Handle click event
*
* @param {Event} e Click event
* @param {?boolean} noPrevent Set to true to not call `e.preventDefault()`
* @return {number} Playback position from 0 to 1
*/
}, {
key: "handleEvent",
value: function(n, i) {
!i && n.preventDefault();
var o = M.withOrientation(n.targetTouches ? n.targetTouches[0] : n, this.params.vertical).clientX, r = this.wrapper.getBoundingClientRect(), t = this.width, s = this.getWidth(), a = this.getProgressPixels(r, o), e;
return !this.params.fillParent && t < s ? e = a * (this.params.pixelRatio / t) || 0 : e = (a + this.wrapper.scrollLeft) / this.wrapper.scrollWidth || 0, M.clamp(e, 0, 1);
}
}, {
key: "getProgressPixels",
value: function(n, i) {
return this.params.rtl ? n.right - i : i - n.left;
}
}, {
key: "setupWrapperEvents",
value: function() {
var n = this;
this.wrapper.addEventListener("click", function(i) {
var o = M.withOrientation(i, n.params.vertical), r = n.wrapper.offsetHeight - n.wrapper.clientHeight;
if (r !== 0) {
var t = n.wrapper.getBoundingClientRect();
if (o.clientY >= t.bottom - r)
return;
}
n.params.interact && n.fireEvent("click", i, n.handleEvent(i));
}), this.wrapper.addEventListener("dblclick", function(i) {
n.params.interact && n.fireEvent("dblclick", i, n.handleEvent(i));
}), this.wrapper.addEventListener("scroll", function(i) {
return n.fireEvent("scroll", i);
});
}
/**
* Draw peaks on the canvas
*
* @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
* for split channel rendering
* @param {number} length The width of the area that should be drawn
* @param {number} start The x-offset of the beginning of the area that
* should be rendered
* @param {number} end The x-offset of the end of the area that should be
* rendered
*/
}, {
key: "drawPeaks",
value: function(n, i, o, r) {
this.setWidth(i) || this.clearWave(), this.params.barWidth ? this.drawBars(n, 0, o, r) : this.drawWave(n, 0, o, r);
}
/**
* Scroll to the beginning
*/
}, {
key: "resetScroll",
value: function() {
this.wrapper !== null && (this.wrapper.scrollLeft = 0);
}
/**
* Recenter the view-port at a certain percent of the waveform
*
* @param {number} percent Value from 0 to 1 on the waveform
*/
}, {
key: "recenter",
value: function(n) {
var i = this.wrapper.scrollWidth * n;
this.recenterOnPosition(i, !0);
}
/**
* Recenter the view-port on a position, either scroll there immediately or
* in steps of 5 pixels
*
* @param {number} position X-offset in pixels
* @param {boolean} immediate Set to true to immediately scroll somewhere
*/
}, {
key: "recenterOnPosition",
value: function(n, i) {
var o = this.wrapper.scrollLeft, r = ~~(this.wrapper.clientWidth / 2), t = this.wrapper.scrollWidth - this.wrapper.clientWidth, s = n - r, a = s - o;
if (t != 0) {
if (!i && -r <= a && a < r) {
var e = this.params.autoCenterRate;
e /= r, e *= t, a = Math.max(-e, Math.min(e, a)), s = o + a;
}
s = Math.max(0, Math.min(t, s)), s != o && (this.wrapper.scrollLeft = s);
}
}
/**
* Get the current scroll position in pixels
*
* @return {number} Horizontal scroll position in pixels
*/
}, {
key: "getScrollX",
value: function() {
var n = 0;
if (this.wrapper) {
var i = this.params.pixelRatio;
if (n = Math.round(this.wrapper.scrollLeft * i), this.params.scrollParent) {
var o = ~~(this.wrapper.scrollWidth * i - this.getWidth());
n = Math.min(o, Math.max(0, n));
}
}
return n;
}
/**
* Get the width of the container
*
* @return {number} The width of the container
*/
}, {
key: "getWidth",
value: function() {
return Math.round(this.container.clientWidth * this.params.pixelRatio);
}
/**
* Set the width of the container
*
* @param {number} width The new width of the container
* @return {boolean} Whether the width of the container was updated or not
*/
}, {
key: "setWidth",
value: function(n) {
if (this.width == n)
return !1;
if (this.width = n, this.params.fillParent || this.params.scrollParent)
this.style(this.wrapper, {
width: ""
});
else {
var i = ~~(this.width / this.params.pixelRatio) + "px";
this.style(this.wrapper, {
width: i
});
}
return this.updateSize(), !0;
}
/**
* Set the height of the container
*
* @param {number} height The new height of the container.
* @return {boolean} Whether the height of the container was updated or not
*/
}, {
key: "setHeight",
value: function(n) {
return n == this.height ? !1 : (this.height = n, this.style(this.wrapper, {
height: ~~(this.height / this.params.pixelRatio) + "px"
}), this.updateSize(), !0);
}
/**
* Called by wavesurfer when progress should be rendered
*
* @param {number} progress From 0 to 1
*/
}, {
key: "progress",
value: function(n) {
var i = 1 / this.params.pixelRatio, o = Math.round(n * this.width) * i;
if (o < this.lastPos || o - this.lastPos >= i) {
if (this.lastPos = o, this.params.scrollParent && this.params.autoCenter) {
var r = ~~(this.wrapper.scrollWidth * n);
this.recenterOnPosition(r, this.params.autoCenterImmediately);
}
this.updateProgress(o);
}
}
/**
* This is called when wavesurfer is destroyed
*/
}, {
key: "destroy",
value: function() {
this.unAll(), this.wrapper && (this.wrapper.parentNode == this.container.domElement && this.container.removeChild(this.wrapper.domElement), this.wrapper = null);
}
/* Renderer-specific methods */
/**
* Called after cursor related params have changed.
*
* @abstract
*/
}, {
key: "updateCursor",
value: function() {
}
/**
* Called when the size of the container changes so the renderer can adjust
*
* @abstract
*/
}, {
key: "updateSize",
value: function() {
}
/**
* Draw a waveform with bars
*
* @abstract
* @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays for split channel
* rendering
* @param {number} channelIndex The index of the current channel. Normally
* should be 0
* @param {number} start The x-offset of the beginning of the area that
* should be rendered
* @param {number} end The x-offset of the end of the area that should be
* rendered
*/
}, {
key: "drawBars",
value: function(n, i, o, r) {
}
/**
* Draw a waveform
*
* @abstract
* @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays for split channel
* rendering
* @param {number} channelIndex The index of the current channel. Normally
* should be 0
* @param {number} start The x-offset of the beginning of the area that
* should be rendered
* @param {number} end The x-offset of the end of the area that should be
* rendered
*/
}, {
key: "drawWave",
value: function(n, i, o, r) {
}
/**
* Clear the waveform
*
* @abstract
*/
}, {
key: "clearWave",
value: function() {
}
/**
* Render the new progress
*
* @abstract
* @param {number} position X-Offset of progress position in pixels
*/
}, {
key: "updateProgress",
value: function(n) {
}
}]), m;
}(M.Observer);
h.default = k, D.exports = h.default;
}
),
/***/
"./src/drawer.multicanvas.js": (
/*!***********************************!*\
!*** ./src/drawer.multicanvas.js ***!
\***********************************/
/***/
(D, h, O) => {
function b(u) {
return b = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
return typeof n;
} : function(n) {
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
}, b(u);
}
Object.defineProperty(h, "__esModule", {
value: !0
}), h.default = void 0;
var M = g(O(
/*! ./drawer */
"./src/drawer.js"
)), _ = B(O(
/*! ./util */
"./src/util/index.js"
)), T = g(O(
/*! ./drawer.canvasentry */
"./src/drawer.canvasentry.js"
));
function W(u) {
if (typeof WeakMap != "function")
return null;
var n = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap();
return (W = function(r) {
return r ? i : n;
})(u);
}
function B(u, n) {
if (!n && u && u.__esModule)
return u;
if (u === null || b(u) !== "object" && typeof u != "function")
return { default: u };
var i = W(n);
if (i && i.has(u))
return i.get(u);
var o = {}, r = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var t in u)
if (t !== "default" && Object.prototype.hasOwnProperty.call(u, t)) {
var s = r ? Object.getOwnPropertyDescriptor(u, t) : null;
s && (s.get || s.set) ? Object.defineProperty(o, t, s) : o[t] = u[t];
}
return o.default = u, i && i.set(u, o), o;
}
function g(u) {
return u && u.__esModule ? u : { default: u };
}
function C(u, n) {
if (!(u instanceof n))
throw new TypeError("Cannot call a class as a function");
}
function E(u, n) {
for (var i = 0; i < n.length; i++) {
var o = n[i];
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(u, p(o.key), o);
}
}
function R(u, n, i) {
return n && E(u.prototype, n), i && E(u, i), Object.defineProperty(u, "prototype", { writable: !1 }), u;
}
function p(u) {
var n = f(u, "string");
return b(n) === "symbol" ? n : String(n);
}
function f(u, n) {
if (b(u) !== "object" || u === null)
return u;
var i = u[Symbol.toPrimitive];
if (i !== void 0) {
var o = i.call(u, n || "default");
if (b(o) !== "object")
return o;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (n === "string" ? String : Number)(u);
}
function v(u, n) {
if (typeof n != "function" && n !== null)
throw new TypeError("Super expression must either be null or a function");
u.prototype = Object.create(n && n.prototype, { constructor: { value: u, writable: !0, configurable: !0 } }), Object.defineProperty(u, "prototype", { writable: !1 }), n && d(u, n);
}
function d(u, n) {
return d = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, r) {
return o.__proto__ = r, o;
}, d(u, n);
}
function A(u) {
var n = y();
return function() {
var o = c(u), r;
if (n) {
var t = c(this).constructor;
r = Reflect.construct(o, arguments, t);
} else
r = o.apply(this, arguments);
return w(this, r);
};
}
function w(u, n) {
if (n && (b(n) === "object" || typeof n == "function"))
return n;
if (n !== void 0)
throw new TypeError("Derived constructors may only return object or undefined");
return k(u);
}
function k(u) {
if (u === void 0)
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return u;
}
function y() {
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
return !1;
if (typeof Proxy == "function")
return !0;
try {
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
})), !0;
} catch {
return !1;
}
}
function c(u) {
return c = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(i) {
return i.__proto__ || Object.getPrototypeOf(i);
}, c(u);
}
var m = /* @__PURE__ */ function(u) {
v(i, u);
var n = A(i);
function i(o, r) {
var t;
return C(this, i), 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 = T.default, t.canvasContextAttributes = r.drawingContextAttributes, t.overlap = 2 * Math.ceil(r.pixelRatio / 2), t.barRadius = r.barRadius || 0, t.vertical = r.vertical, t;
}
return R(i, [{
key: "init",
value: function() {
this.createWrapper(), this.createElements();
}
/**
* Create the canvas elements and style them
*
*/
}, {
key: "createElements",
value: function() {
this.progressWave = _.withOrientation(this.wrapper.appendChild(document.createElement("wave")), this.params.vertical), this.style(this.progressWave, {
position: "absolute",
zIndex: 3,
left: 0,
top: 0,
bottom: 0,
overflow: "hidden",
width: "0",
display: "none",
boxSizing: "border-box",
borderRightStyle: "solid",
pointerEvents: "none"
}), this.addCanvas(), this.updateCursor();
}
/**
* Update cursor style
*/
}, {
key: "updateCursor",
value: function() {
this.style(this.progressWave, {
borderRightWidth: this.params.cursorWidth + "px",
borderRightColor: this.params.cursorColor
});
}
/**
* Adjust to the updated size by adding or removing canvases
*/
}, {
key: "updateSize",
value: function() {
for (var r = this, t = Math.round(this.width / this.params.pixelRatio), s = Math.ceil(t / (this.maxCanvasElementWidth + this.overlap)); this.canvases.length < s; )
this.addCanvas();
for (; this.canvases.length > s; )
this.removeCanvas();
var a = this.maxCanvasWidth + this.overlap, e = this.canvases.length - 1;
this.canvases.forEach(function(l, P) {
P == e && (a = r.width - r.maxCanvasWidth * e), r.updateDimensions(l, a, r.height), l.clearWave();
});
}
/**
* Add a canvas to the canvas list
*
*/
}, {
key: "addCanvas",
value: function() {
var r = new this.EntryClass();
r.canvasContextAttributes = this.canvasContextAttributes, r.hasProgressCanvas = this.hasProgressCanvas, r.halfPixel = this.halfPixel;
var t = this.maxCanvasElementWidth * this.canvases.length, s = _.withOrientation(this.wrapper.appendChild(document.createElement("canvas")), this.params.vertical);
if (this.style(s, {
position: "absolute",
zIndex: 2,
left: t + "px",
top: 0,
bottom: 0,
height: "100%",
pointerEvents: "none"
}), r.initWave(s), this.hasProgressCanvas) {
var a = _.withOrientation(this.progressWave.appendChild(document.createElement("canvas")), this.params.vertical);
this.style(a, {
position: "absolute",
left: t + "px",
top: 0,
bottom: 0,
height: "100%"
}), r.initProgress(a);
}
this.canvases.push(r);
}
/**
* Pop single canvas from the list
*
*/
}, {
key: "removeCanvas",
value: function() {
var r = this.canvases[this.canvases.length - 1];
r.wave.parentElement.removeChild(r.wave.domElement), this.hasProgressCanvas && r.progress.parentElement.removeChild(r.progress.domElement), r && (r.destroy(), r = null), this.canvases.pop();
}
/**
* Update the dimensions of a canvas element
*
* @param {CanvasEntry} entry Target entry
* @param {number} width The new width of the element
* @param {number} height The new height of the element
*/
}, {
key: "updateDimensions",
value: function(r, t, s) {
var a = Math.round(t / this.params.pixelRatio), e = Math.round(this.width / this.params.pixelRatio);
r.updateDimensions(a, e, t, s), this.style(this.progressWave, {
display: "block"
});
}
/**
* Clear the whole multi-canvas
*/
}, {
key: "clearWave",
value: function() {
var r = this;
_.frame(function() {
r.canvases.forEach(function(t) {
return t.clearWave();
});
})();
}
/**
* Draw a waveform with bars
*
* @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
* for split channel rendering
* @param {number} channelIndex The index of the current channel. Normally
* should be 0. Must be an integer.
* @param {number} start The x-offset of the beginning of the area that
* should be rendered
* @param {number} end The x-offset of the end of the area that should be
* rendered
* @returns {void}
*/
}, {
key: "drawBars",
value: function(r, t, s, a) {
var e = this;
return this.prepareDraw(r, t, s, a, function(l) {
var P = l.absmax, x = l.hasMinVals;
l.height;
var S = l.offsetY, j = l.halfH, L = l.peaks, V = l.channelIndex;
if (s !== void 0) {
var N = x ? 2 : 1, H = L.length / N, I = e.params.barWidth * e.params.pixelRatio, G = e.params.barGap === null ? Math.max(e.params.pixelRatio, ~~(I / 2)) : Math.max(e.params.pixelRatio, e.params.barGap * e.params.pixelRatio), F = I + G, q = H / e.width, ne = s, ie = a, Y = ne;
for (Y; Y < ie; Y += F) {
var ee = 0, te = Math.floor(Y * q) * N, ae = Math.floor((Y + F) * q) * N;
do {
var re = Math.abs(L[te]);
re > ee && (ee = re), te += N;
} while (te < ae);
var J = Math.round(ee / P * j);
e.params.barMinHeight && (J = Math.max(J, e.params.barMinHeight)), e.fillRect(Y + e.halfPixel, j - J + S, I + e.halfPixel, J * 2, e.barRadius, V);
}
}
});
}
/**
* Draw a waveform
*
* @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
* for split channel rendering
* @param {number} channelIndex The index of the current channel. Normally
* should be 0
* @param {number?} start The x-offset of the beginning of the area that
* should be rendered (If this isn't set only a flat line is rendered)
* @param {number?} end The x-offset of the end of the area that should be
* rendered
* @returns {void}
*/
}, {
key: "drawWave",
value: function(r, t, s, a) {
var e = this;
return this.prepareDraw(r, t, s, a, function(l) {
var P = l.absmax, x = l.hasMinVals;
l.height;
var S = l.offsetY, j = l.halfH, L = l.peaks, V = l.channelIndex;
if (!x) {
var N = [], H = L.length, I = 0;
for (I; I < H; I++)
N[2 * I] = L[I], N[2 * I + 1] = -L[I];
L = N;
}
s !== void 0 && e.drawLine(L, P, j, S, s, a, V), e.fillRect(0, j + S - e.halfPixel, e.width, e.halfPixel, e.barRadius, V);
});
}
/**
* Tell the canvas entries to render their portion of the waveform
*
* @param {number[]} peaks Peaks data
* @param {number} absmax Maximum peak value (absolute)
* @param {number} halfH Half the height of the waveform
* @param {number} offsetY Offset to the top
* @param {number} start The x-offset of the beginning of the area that
* should be rendered
* @param {number} end The x-offset of the end of the area that
* should be rendered
* @param {channelIndex} channelIndex The channel index of the line drawn
*/
}, {
key: "drawLine",
value: function(r, t, s, a, e, l, P) {
var x = this, S = this.params.splitChannelsOptions.channelColors[P] || {}, j = S.waveColor, L = S.progressColor;
this.canvases.forEach(function(V, N) {
x.setFillStyles(V, j, L), x.applyCanvasTransforms(V, x.params.vertical), V.drawLines(r, t, s, a, e, l);
});
}
/**
* Draw a rectangle on the multi-canvas
*
* @param {number} x X-position of the rectangle
* @param {number} y Y-position of the rectangle
* @param {number} width Width of the rectangle
* @param {number} height Height of the rectangle
* @param {number} radius Radius of the rectangle
* @param {channelIndex} channelIndex The channel index of the bar drawn
*/
}, {
key: "fillRect",
value: function(r, t, s, a, e, l) {
var P = Math.floor(r / this.maxCanvasWidth), x = Math.min(Math.ceil((r + s) / this.maxCanvasWidth) + 1, this.canvases.length), S = P;
for (S; S < x; S++) {
var j = this.canvases[S], L = S * this.maxCanvasWidth, V = {
x1: Math.max(r, S * this.maxCanvasWidth),
y1: t,
x2: Math.min(r + s, S * this.maxCanvasWidth + j.wave.w