soundcraft-ui-connection
Version:
Library for controlling the Soundcraft Ui series audio mixers
3,341 lines • 97.7 kB
JavaScript
//#region ../../node_modules/tslib/tslib.es6.mjs
var e = function(t, n) {
return e = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
}, e(t, n);
};
function t(t, n) {
if (typeof n != "function" && n !== null) throw TypeError("Class extends value " + String(n) + " is not a constructor or null");
e(t, n);
function r() {
this.constructor = t;
}
t.prototype = n === null ? Object.create(n) : (r.prototype = n.prototype, new r());
}
var n = function() {
return n = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}, n.apply(this, arguments);
};
function r(e, t, n, r) {
function i(e) {
return e instanceof n ? e : new n(function(t) {
t(e);
});
}
return new (n ||= Promise)(function(n, a) {
function o(e) {
try {
c(r.next(e));
} catch (e) {
a(e);
}
}
function s(e) {
try {
c(r.throw(e));
} catch (e) {
a(e);
}
}
function c(e) {
e.done ? n(e.value) : i(e.value).then(o, s);
}
c((r = r.apply(e, t || [])).next());
});
}
function i(e, t) {
var n = {
label: 0,
sent: function() {
if (a[0] & 1) throw a[1];
return a[1];
},
trys: [],
ops: []
}, r, i, a, o = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
return o.next = s(0), o.throw = s(1), o.return = s(2), typeof Symbol == "function" && (o[Symbol.iterator] = function() {
return this;
}), o;
function s(e) {
return function(t) {
return c([e, t]);
};
}
function c(s) {
if (r) throw TypeError("Generator is already executing.");
for (; o && (o = 0, s[0] && (n = 0)), n;) try {
if (r = 1, i && (a = s[0] & 2 ? i.return : s[0] ? i.throw || ((a = i.return) && a.call(i), 0) : i.next) && !(a = a.call(i, s[1])).done) return a;
switch (i = 0, a && (s = [s[0] & 2, a.value]), s[0]) {
case 0:
case 1:
a = s;
break;
case 4: return n.label++, {
value: s[1],
done: !1
};
case 5:
n.label++, i = s[1], s = [0];
continue;
case 7:
s = n.ops.pop(), n.trys.pop();
continue;
default:
if ((a = n.trys, !(a = a.length > 0 && a[a.length - 1])) && (s[0] === 6 || s[0] === 2)) {
n = 0;
continue;
}
if (s[0] === 3 && (!a || s[1] > a[0] && s[1] < a[3])) {
n.label = s[1];
break;
}
if (s[0] === 6 && n.label < a[1]) {
n.label = a[1], a = s;
break;
}
if (a && n.label < a[2]) {
n.label = a[2], n.ops.push(s);
break;
}
a[2] && n.ops.pop(), n.trys.pop();
continue;
}
s = t.call(e, n);
} catch (e) {
s = [6, e], i = 0;
} finally {
r = a = 0;
}
if (s[0] & 5) throw s[1];
return {
value: s[0] ? s[1] : void 0,
done: !0
};
}
}
function a(e) {
var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], r = 0;
if (n) return n.call(e);
if (e && typeof e.length == "number") return { next: function() {
return e && r >= e.length && (e = void 0), {
value: e && e[r++],
done: !e
};
} };
throw TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function o(e, t) {
var n = typeof Symbol == "function" && e[Symbol.iterator];
if (!n) return e;
var r = n.call(e), i, a = [], o;
try {
for (; (t === void 0 || t-- > 0) && !(i = r.next()).done;) a.push(i.value);
} catch (e) {
o = { error: e };
} finally {
try {
i && !i.done && (n = r.return) && n.call(r);
} finally {
if (o) throw o.error;
}
}
return a;
}
function s(e, t, n) {
if (n || arguments.length === 2) for (var r = 0, i = t.length, a; r < i; r++) (a || !(r in t)) && (a ||= Array.prototype.slice.call(t, 0, r), a[r] = t[r]);
return e.concat(a || Array.prototype.slice.call(t));
}
function c(e) {
return this instanceof c ? (this.v = e, this) : new c(e);
}
function l(e, t, n) {
if (!Symbol.asyncIterator) throw TypeError("Symbol.asyncIterator is not defined.");
var r = n.apply(e, t || []), i, a = [];
return i = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), s("next"), s("throw"), s("return", o), i[Symbol.asyncIterator] = function() {
return this;
}, i;
function o(e) {
return function(t) {
return Promise.resolve(t).then(e, f);
};
}
function s(e, t) {
r[e] && (i[e] = function(t) {
return new Promise(function(n, r) {
a.push([
e,
t,
n,
r
]) > 1 || l(e, t);
});
}, t && (i[e] = t(i[e])));
}
function l(e, t) {
try {
u(r[e](t));
} catch (e) {
p(a[0][3], e);
}
}
function u(e) {
e.value instanceof c ? Promise.resolve(e.value.v).then(d, f) : p(a[0][2], e);
}
function d(e) {
l("next", e);
}
function f(e) {
l("throw", e);
}
function p(e, t) {
e(t), a.shift(), a.length && l(a[0][0], a[0][1]);
}
}
function u(e) {
if (!Symbol.asyncIterator) throw TypeError("Symbol.asyncIterator is not defined.");
var t = e[Symbol.asyncIterator], n;
return t ? t.call(e) : (e = typeof a == "function" ? a(e) : e[Symbol.iterator](), n = {}, r("next"), r("throw"), r("return"), n[Symbol.asyncIterator] = function() {
return this;
}, n);
function r(t) {
n[t] = e[t] && function(n) {
return new Promise(function(r, a) {
n = e[t](n), i(r, a, n.done, n.value);
});
};
}
function i(e, t, n, r) {
Promise.resolve(r).then(function(t) {
e({
value: t,
done: n
});
}, t);
}
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/isFunction.js
function d(e) {
return typeof e == "function";
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js
function f(e) {
var t = e(function(e) {
Error.call(e), e.stack = (/* @__PURE__ */ Error()).stack;
});
return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js
var p = f(function(e) {
return function(t) {
e(this), this.message = t ? t.length + " errors occurred during unsubscription:\n" + t.map(function(e, t) {
return t + 1 + ") " + e.toString();
}).join("\n ") : "", this.name = "UnsubscriptionError", this.errors = t;
};
});
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/arrRemove.js
function m(e, t) {
if (e) {
var n = e.indexOf(t);
0 <= n && e.splice(n, 1);
}
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/Subscription.js
var h = function() {
function e(e) {
this.initialTeardown = e, this.closed = !1, this._parentage = null, this._finalizers = null;
}
return e.prototype.unsubscribe = function() {
var e, t, n, r, i;
if (!this.closed) {
this.closed = !0;
var c = this._parentage;
if (c) if (this._parentage = null, Array.isArray(c)) try {
for (var l = a(c), u = l.next(); !u.done; u = l.next()) u.value.remove(this);
} catch (t) {
e = { error: t };
} finally {
try {
u && !u.done && (t = l.return) && t.call(l);
} finally {
if (e) throw e.error;
}
}
else c.remove(this);
var f = this.initialTeardown;
if (d(f)) try {
f();
} catch (e) {
i = e instanceof p ? e.errors : [e];
}
var m = this._finalizers;
if (m) {
this._finalizers = null;
try {
for (var h = a(m), g = h.next(); !g.done; g = h.next()) {
var ee = g.value;
try {
te(ee);
} catch (e) {
i ??= [], e instanceof p ? i = s(s([], o(i)), o(e.errors)) : i.push(e);
}
}
} catch (e) {
n = { error: e };
} finally {
try {
g && !g.done && (r = h.return) && r.call(h);
} finally {
if (n) throw n.error;
}
}
}
if (i) throw new p(i);
}
}, e.prototype.add = function(t) {
if (t && t !== this) if (this.closed) te(t);
else {
if (t instanceof e) {
if (t.closed || t._hasParent(this)) return;
t._addParent(this);
}
(this._finalizers = this._finalizers ?? []).push(t);
}
}, e.prototype._hasParent = function(e) {
var t = this._parentage;
return t === e || Array.isArray(t) && t.includes(e);
}, e.prototype._addParent = function(e) {
var t = this._parentage;
this._parentage = Array.isArray(t) ? (t.push(e), t) : t ? [t, e] : e;
}, e.prototype._removeParent = function(e) {
var t = this._parentage;
t === e ? this._parentage = null : Array.isArray(t) && m(t, e);
}, e.prototype.remove = function(t) {
var n = this._finalizers;
n && m(n, t), t instanceof e && t._removeParent(this);
}, e.EMPTY = (function() {
var t = new e();
return t.closed = !0, t;
})(), e;
}(), g = h.EMPTY;
function ee(e) {
return e instanceof h || e && "closed" in e && d(e.remove) && d(e.add) && d(e.unsubscribe);
}
function te(e) {
d(e) ? e() : e.unsubscribe();
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/config.js
var _ = {
onUnhandledError: null,
onStoppedNotification: null,
Promise: void 0,
useDeprecatedSynchronousErrorHandling: !1,
useDeprecatedNextContext: !1
}, ne = {
setTimeout: function(e, t) {
var n = [...arguments].slice(2), r = ne.delegate;
return r?.setTimeout ? r.setTimeout.apply(r, s([e, t], o(n))) : setTimeout.apply(void 0, s([e, t], o(n)));
},
clearTimeout: function(e) {
return (ne.delegate?.clearTimeout || clearTimeout)(e);
},
delegate: void 0
};
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js
function re(e) {
ne.setTimeout(function() {
var t = _.onUnhandledError;
if (t) t(e);
else throw e;
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/noop.js
function v() {}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/NotificationFactories.js
var ie = (function() {
return se("C", void 0, void 0);
})();
function ae(e) {
return se("E", void 0, e);
}
function oe(e) {
return se("N", e, void 0);
}
function se(e, t, n) {
return {
kind: e,
value: t,
error: n
};
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/errorContext.js
var y = null;
function ce(e) {
if (_.useDeprecatedSynchronousErrorHandling) {
var t = !y;
if (t && (y = {
errorThrown: !1,
error: null
}), e(), t) {
var n = y, r = n.errorThrown, i = n.error;
if (y = null, r) throw i;
}
} else e();
}
function le(e) {
_.useDeprecatedSynchronousErrorHandling && y && (y.errorThrown = !0, y.error = e);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/Subscriber.js
var ue = function(e) {
t(n, e);
function n(t) {
var n = e.call(this) || this;
return n.isStopped = !1, t ? (n.destination = t, ee(t) && t.add(n)) : n.destination = _e, n;
}
return n.create = function(e, t, n) {
return new b(e, t, n);
}, n.prototype.next = function(e) {
this.isStopped ? ge(oe(e), this) : this._next(e);
}, n.prototype.error = function(e) {
this.isStopped ? ge(ae(e), this) : (this.isStopped = !0, this._error(e));
}, n.prototype.complete = function() {
this.isStopped ? ge(ie, this) : (this.isStopped = !0, this._complete());
}, n.prototype.unsubscribe = function() {
this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
}, n.prototype._next = function(e) {
this.destination.next(e);
}, n.prototype._error = function(e) {
try {
this.destination.error(e);
} finally {
this.unsubscribe();
}
}, n.prototype._complete = function() {
try {
this.destination.complete();
} finally {
this.unsubscribe();
}
}, n;
}(h), de = Function.prototype.bind;
function fe(e, t) {
return de.call(e, t);
}
var pe = function() {
function e(e) {
this.partialObserver = e;
}
return e.prototype.next = function(e) {
var t = this.partialObserver;
if (t.next) try {
t.next(e);
} catch (e) {
me(e);
}
}, e.prototype.error = function(e) {
var t = this.partialObserver;
if (t.error) try {
t.error(e);
} catch (e) {
me(e);
}
else me(e);
}, e.prototype.complete = function() {
var e = this.partialObserver;
if (e.complete) try {
e.complete();
} catch (e) {
me(e);
}
}, e;
}(), b = function(e) {
t(n, e);
function n(t, n, r) {
var i = e.call(this) || this, a;
if (d(t) || !t) a = {
next: t ?? void 0,
error: n ?? void 0,
complete: r ?? void 0
};
else {
var o;
i && _.useDeprecatedNextContext ? (o = Object.create(t), o.unsubscribe = function() {
return i.unsubscribe();
}, a = {
next: t.next && fe(t.next, o),
error: t.error && fe(t.error, o),
complete: t.complete && fe(t.complete, o)
}) : a = t;
}
return i.destination = new pe(a), i;
}
return n;
}(ue);
function me(e) {
_.useDeprecatedSynchronousErrorHandling ? le(e) : re(e);
}
function he(e) {
throw e;
}
function ge(e, t) {
var n = _.onStoppedNotification;
n && ne.setTimeout(function() {
return n(e, t);
});
}
var _e = {
closed: !0,
next: v,
error: he,
complete: v
}, ve = (function() {
return typeof Symbol == "function" && Symbol.observable || "@@observable";
})();
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/identity.js
function x(e) {
return e;
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/pipe.js
function ye() {
return be([...arguments]);
}
function be(e) {
return e.length === 0 ? x : e.length === 1 ? e[0] : function(t) {
return e.reduce(function(e, t) {
return t(e);
}, t);
};
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/Observable.js
var S = function() {
function e(e) {
e && (this._subscribe = e);
}
return e.prototype.lift = function(t) {
var n = new e();
return n.source = this, n.operator = t, n;
}, e.prototype.subscribe = function(e, t, n) {
var r = this, i = Ce(e) ? e : new b(e, t, n);
return ce(function() {
var e = r, t = e.operator, n = e.source;
i.add(t ? t.call(i, n) : n ? r._subscribe(i) : r._trySubscribe(i));
}), i;
}, e.prototype._trySubscribe = function(e) {
try {
return this._subscribe(e);
} catch (t) {
e.error(t);
}
}, e.prototype.forEach = function(e, t) {
var n = this;
return t = xe(t), new t(function(t, r) {
var i = new b({
next: function(t) {
try {
e(t);
} catch (e) {
r(e), i.unsubscribe();
}
},
error: r,
complete: t
});
n.subscribe(i);
});
}, e.prototype._subscribe = function(e) {
return this.source?.subscribe(e);
}, e.prototype[ve] = function() {
return this;
}, e.prototype.pipe = function() {
return be([...arguments])(this);
}, e.prototype.toPromise = function(e) {
var t = this;
return e = xe(e), new e(function(e, n) {
var r;
t.subscribe(function(e) {
return r = e;
}, function(e) {
return n(e);
}, function() {
return e(r);
});
});
}, e.create = function(t) {
return new e(t);
}, e;
}();
function xe(e) {
return e ?? _.Promise ?? Promise;
}
function Se(e) {
return e && d(e.next) && d(e.error) && d(e.complete);
}
function Ce(e) {
return e && e instanceof ue || Se(e) && ee(e);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/lift.js
function we(e) {
return d(e?.lift);
}
function C(e) {
return function(t) {
if (we(t)) return t.lift(function(t) {
try {
return e(t, this);
} catch (e) {
this.error(e);
}
});
throw TypeError("Unable to lift unknown Observable type");
};
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js
function w(e, t, n, r, i) {
return new Te(e, t, n, r, i);
}
var Te = function(e) {
t(n, e);
function n(t, n, r, i, a, o) {
var s = e.call(this, t) || this;
return s.onFinalize = a, s.shouldUnsubscribe = o, s._next = n ? function(e) {
try {
n(e);
} catch (e) {
t.error(e);
}
} : e.prototype._next, s._error = i ? function(e) {
try {
i(e);
} catch (e) {
t.error(e);
} finally {
this.unsubscribe();
}
} : e.prototype._error, s._complete = r ? function() {
try {
r();
} catch (e) {
t.error(e);
} finally {
this.unsubscribe();
}
} : e.prototype._complete, s;
}
return n.prototype.unsubscribe = function() {
var t;
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
var n = this.closed;
e.prototype.unsubscribe.call(this), !n && ((t = this.onFinalize) == null || t.call(this));
}
}, n;
}(ue), Ee = f(function(e) {
return function() {
e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
};
}), T = function(e) {
t(n, e);
function n() {
var t = e.call(this) || this;
return t.closed = !1, t.currentObservers = null, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
}
return n.prototype.lift = function(e) {
var t = new De(this, this);
return t.operator = e, t;
}, n.prototype._throwIfClosed = function() {
if (this.closed) throw new Ee();
}, n.prototype.next = function(e) {
var t = this;
ce(function() {
var n, r;
if (t._throwIfClosed(), !t.isStopped) {
t.currentObservers ||= Array.from(t.observers);
try {
for (var i = a(t.currentObservers), o = i.next(); !o.done; o = i.next()) o.value.next(e);
} catch (e) {
n = { error: e };
} finally {
try {
o && !o.done && (r = i.return) && r.call(i);
} finally {
if (n) throw n.error;
}
}
}
});
}, n.prototype.error = function(e) {
var t = this;
ce(function() {
if (t._throwIfClosed(), !t.isStopped) {
t.hasError = t.isStopped = !0, t.thrownError = e;
for (var n = t.observers; n.length;) n.shift().error(e);
}
});
}, n.prototype.complete = function() {
var e = this;
ce(function() {
if (e._throwIfClosed(), !e.isStopped) {
e.isStopped = !0;
for (var t = e.observers; t.length;) t.shift().complete();
}
});
}, n.prototype.unsubscribe = function() {
this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
}, Object.defineProperty(n.prototype, "observed", {
get: function() {
return this.observers?.length > 0;
},
enumerable: !1,
configurable: !0
}), n.prototype._trySubscribe = function(t) {
return this._throwIfClosed(), e.prototype._trySubscribe.call(this, t);
}, n.prototype._subscribe = function(e) {
return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
}, n.prototype._innerSubscribe = function(e) {
var t = this, n = this, r = n.hasError, i = n.isStopped, a = n.observers;
return r || i ? g : (this.currentObservers = null, a.push(e), new h(function() {
t.currentObservers = null, m(a, e);
}));
}, n.prototype._checkFinalizedStatuses = function(e) {
var t = this, n = t.hasError, r = t.thrownError, i = t.isStopped;
n ? e.error(r) : i && e.complete();
}, n.prototype.asObservable = function() {
var e = new S();
return e.source = this, e;
}, n.create = function(e, t) {
return new De(e, t);
}, n;
}(S), De = function(e) {
t(n, e);
function n(t, n) {
var r = e.call(this) || this;
return r.destination = t, r.source = n, r;
}
return n.prototype.next = function(e) {
var t, n;
(n = (t = this.destination)?.next) == null || n.call(t, e);
}, n.prototype.error = function(e) {
var t, n;
(n = (t = this.destination)?.error) == null || n.call(t, e);
}, n.prototype.complete = function() {
var e, t;
(t = (e = this.destination)?.complete) == null || t.call(e);
}, n.prototype._subscribe = function(e) {
return this.source?.subscribe(e) ?? g;
}, n;
}(T), Oe = {
now: function() {
return (Oe.delegate || Date).now();
},
delegate: void 0
}, E = function(e) {
t(n, e);
function n(t, n, r) {
t === void 0 && (t = Infinity), n === void 0 && (n = Infinity), r === void 0 && (r = Oe);
var i = e.call(this) || this;
return i._bufferSize = t, i._windowTime = n, i._timestampProvider = r, i._buffer = [], i._infiniteTimeWindow = !0, i._infiniteTimeWindow = n === Infinity, i._bufferSize = Math.max(1, t), i._windowTime = Math.max(1, n), i;
}
return n.prototype.next = function(t) {
var n = this, r = n.isStopped, i = n._buffer, a = n._infiniteTimeWindow, o = n._timestampProvider, s = n._windowTime;
r || (i.push(t), !a && i.push(o.now() + s)), this._trimBuffer(), e.prototype.next.call(this, t);
}, n.prototype._subscribe = function(e) {
this._throwIfClosed(), this._trimBuffer();
for (var t = this._innerSubscribe(e), n = this, r = n._infiniteTimeWindow, i = n._buffer.slice(), a = 0; a < i.length && !e.closed; a += r ? 1 : 2) e.next(i[a]);
return this._checkFinalizedStatuses(e), t;
}, n.prototype._trimBuffer = function() {
var e = this, t = e._bufferSize, n = e._timestampProvider, r = e._buffer, i = e._infiniteTimeWindow, a = (i ? 1 : 2) * t;
if (t < Infinity && a < r.length && r.splice(0, r.length - a), !i) {
for (var o = n.now(), s = 0, c = 1; c < r.length && r[c] <= o; c += 2) s = c;
s && r.splice(0, s + 1);
}
}, n;
}(T), ke = function(e) {
t(n, e);
function n(t, n) {
return e.call(this) || this;
}
return n.prototype.schedule = function(e, t) {
return t === void 0 && (t = 0), this;
}, n;
}(h), Ae = {
setInterval: function(e, t) {
var n = [...arguments].slice(2), r = Ae.delegate;
return r?.setInterval ? r.setInterval.apply(r, s([e, t], o(n))) : setInterval.apply(void 0, s([e, t], o(n)));
},
clearInterval: function(e) {
return (Ae.delegate?.clearInterval || clearInterval)(e);
},
delegate: void 0
}, je = function(e) {
t(n, e);
function n(t, n) {
var r = e.call(this, t, n) || this;
return r.scheduler = t, r.work = n, r.pending = !1, r;
}
return n.prototype.schedule = function(e, t) {
if (t === void 0 && (t = 0), this.closed) return this;
this.state = e;
var n = this.id, r = this.scheduler;
return n != null && (this.id = this.recycleAsyncId(r, n, t)), this.pending = !0, this.delay = t, this.id = this.id ?? this.requestAsyncId(r, this.id, t), this;
}, n.prototype.requestAsyncId = function(e, t, n) {
return n === void 0 && (n = 0), Ae.setInterval(e.flush.bind(e, this), n);
}, n.prototype.recycleAsyncId = function(e, t, n) {
if (n === void 0 && (n = 0), n != null && this.delay === n && this.pending === !1) return t;
t != null && Ae.clearInterval(t);
}, n.prototype.execute = function(e, t) {
if (this.closed) return /* @__PURE__ */ Error("executing a cancelled action");
this.pending = !1;
var n = this._execute(e, t);
if (n) return n;
this.pending === !1 && this.id != null && (this.id = this.recycleAsyncId(this.scheduler, this.id, null));
}, n.prototype._execute = function(e, t) {
var n = !1, r;
try {
this.work(e);
} catch (e) {
n = !0, r = e || /* @__PURE__ */ Error("Scheduled action threw falsy error");
}
if (n) return this.unsubscribe(), r;
}, n.prototype.unsubscribe = function() {
if (!this.closed) {
var t = this, n = t.id, r = t.scheduler, i = r.actions;
this.work = this.state = this.scheduler = null, this.pending = !1, m(i, this), n != null && (this.id = this.recycleAsyncId(r, n, null)), this.delay = null, e.prototype.unsubscribe.call(this);
}
}, n;
}(ke), Me = function() {
function e(t, n) {
n === void 0 && (n = e.now), this.schedulerActionCtor = t, this.now = n;
}
return e.prototype.schedule = function(e, t, n) {
return t === void 0 && (t = 0), new this.schedulerActionCtor(this, e).schedule(n, t);
}, e.now = Oe.now, e;
}(), Ne = new (function(e) {
t(n, e);
function n(t, n) {
n === void 0 && (n = Me.now);
var r = e.call(this, t, n) || this;
return r.actions = [], r._active = !1, r;
}
return n.prototype.flush = function(e) {
var t = this.actions;
if (this._active) {
t.push(e);
return;
}
var n;
this._active = !0;
do
if (n = e.execute(e.state, e.delay)) break;
while (e = t.shift());
if (this._active = !1, n) {
for (; e = t.shift();) e.unsubscribe();
throw n;
}
}, n;
}(Me))(je), Pe = Ne, Fe = new S(function(e) {
return e.complete();
});
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/isScheduler.js
function Ie(e) {
return e && d(e.schedule);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/args.js
function Le(e) {
return e[e.length - 1];
}
function Re(e) {
return d(Le(e)) ? e.pop() : void 0;
}
function ze(e) {
return Ie(Le(e)) ? e.pop() : void 0;
}
function Be(e, t) {
return typeof Le(e) == "number" ? e.pop() : t;
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js
var Ve = (function(e) {
return e && typeof e.length == "number" && typeof e != "function";
});
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/isPromise.js
function He(e) {
return d(e?.then);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js
function Ue(e) {
return d(e[ve]);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js
function We(e) {
return Symbol.asyncIterator && d(e?.[Symbol.asyncIterator]);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js
function Ge(e) {
return /* @__PURE__ */ TypeError("You provided " + (typeof e == "object" && e ? "an invalid object" : "'" + e + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/symbol/iterator.js
function Ke() {
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
}
var qe = Ke();
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/isIterable.js
function Je(e) {
return d(e?.[qe]);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js
function Ye(e) {
return l(this, arguments, function() {
var t, n, r, a;
return i(this, function(i) {
switch (i.label) {
case 0: t = e.getReader(), i.label = 1;
case 1: i.trys.push([
1,
,
9,
10
]), i.label = 2;
case 2: return [4, c(t.read())];
case 3: return n = i.sent(), r = n.value, a = n.done, a ? [4, c(void 0)] : [3, 5];
case 4: return [2, i.sent()];
case 5: return [4, c(r)];
case 6: return [4, i.sent()];
case 7: return i.sent(), [3, 2];
case 8: return [3, 10];
case 9: return t.releaseLock(), [7];
case 10: return [2];
}
});
});
}
function Xe(e) {
return d(e?.getReader);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js
function D(e) {
if (e instanceof S) return e;
if (e != null) {
if (Ue(e)) return Ze(e);
if (Ve(e)) return Qe(e);
if (He(e)) return $e(e);
if (We(e)) return tt(e);
if (Je(e)) return et(e);
if (Xe(e)) return nt(e);
}
throw Ge(e);
}
function Ze(e) {
return new S(function(t) {
var n = e[ve]();
if (d(n.subscribe)) return n.subscribe(t);
throw TypeError("Provided object does not correctly implement Symbol.observable");
});
}
function Qe(e) {
return new S(function(t) {
for (var n = 0; n < e.length && !t.closed; n++) t.next(e[n]);
t.complete();
});
}
function $e(e) {
return new S(function(t) {
e.then(function(e) {
t.closed || (t.next(e), t.complete());
}, function(e) {
return t.error(e);
}).then(null, re);
});
}
function et(e) {
return new S(function(t) {
var n, r;
try {
for (var i = a(e), o = i.next(); !o.done; o = i.next()) {
var s = o.value;
if (t.next(s), t.closed) return;
}
} catch (e) {
n = { error: e };
} finally {
try {
o && !o.done && (r = i.return) && r.call(i);
} finally {
if (n) throw n.error;
}
}
t.complete();
});
}
function tt(e) {
return new S(function(t) {
rt(e, t).catch(function(e) {
return t.error(e);
});
});
}
function nt(e) {
return tt(Ye(e));
}
function rt(e, t) {
var n, a, o, s;
return r(this, void 0, void 0, function() {
var r, c;
return i(this, function(i) {
switch (i.label) {
case 0: i.trys.push([
0,
5,
6,
11
]), n = u(e), i.label = 1;
case 1: return [4, n.next()];
case 2:
if (a = i.sent(), a.done) return [3, 4];
if (r = a.value, t.next(r), t.closed) return [2];
i.label = 3;
case 3: return [3, 1];
case 4: return [3, 11];
case 5: return c = i.sent(), o = { error: c }, [3, 11];
case 6: return i.trys.push([
6,
,
9,
10
]), a && !a.done && (s = n.return) ? [4, s.call(n)] : [3, 8];
case 7: i.sent(), i.label = 8;
case 8: return [3, 10];
case 9:
if (o) throw o.error;
return [7];
case 10: return [7];
case 11: return t.complete(), [2];
}
});
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js
function O(e, t, n, r, i) {
r === void 0 && (r = 0), i === void 0 && (i = !1);
var a = t.schedule(function() {
n(), i ? e.add(this.schedule(null, r)) : this.unsubscribe();
}, r);
if (e.add(a), !i) return a;
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/observeOn.js
function it(e, t) {
return t === void 0 && (t = 0), C(function(n, r) {
n.subscribe(w(r, function(n) {
return O(r, e, function() {
return r.next(n);
}, t);
}, function() {
return O(r, e, function() {
return r.complete();
}, t);
}, function(n) {
return O(r, e, function() {
return r.error(n);
}, t);
}));
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js
function at(e, t) {
return t === void 0 && (t = 0), C(function(n, r) {
r.add(e.schedule(function() {
return n.subscribe(r);
}, t));
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js
function ot(e, t) {
return D(e).pipe(at(t), it(t));
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js
function st(e, t) {
return D(e).pipe(at(t), it(t));
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js
function ct(e, t) {
return new S(function(n) {
var r = 0;
return t.schedule(function() {
r === e.length ? n.complete() : (n.next(e[r++]), n.closed || this.schedule());
});
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js
function lt(e, t) {
return new S(function(n) {
var r;
return O(n, t, function() {
r = e[qe](), O(n, t, function() {
var e, t, i;
try {
e = r.next(), t = e.value, i = e.done;
} catch (e) {
n.error(e);
return;
}
i ? n.complete() : n.next(t);
}, 0, !0);
}), function() {
return d(r?.return) && r.return();
};
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js
function ut(e, t) {
if (!e) throw Error("Iterable cannot be null");
return new S(function(n) {
O(n, t, function() {
var r = e[Symbol.asyncIterator]();
O(n, t, function() {
r.next().then(function(e) {
e.done ? n.complete() : n.next(e.value);
});
}, 0, !0);
});
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js
function dt(e, t) {
return ut(Ye(e), t);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js
function ft(e, t) {
if (e != null) {
if (Ue(e)) return ot(e, t);
if (Ve(e)) return ct(e, t);
if (He(e)) return st(e, t);
if (We(e)) return ut(e, t);
if (Je(e)) return lt(e, t);
if (Xe(e)) return dt(e, t);
}
throw Ge(e);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/from.js
function k(e, t) {
return t ? ft(e, t) : D(e);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/of.js
function pt() {
var e = [...arguments];
return k(e, ze(e));
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/EmptyError.js
var mt = f(function(e) {
return function() {
e(this), this.name = "EmptyError", this.message = "no elements in sequence";
};
});
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/firstValueFrom.js
function ht(e, t) {
var n = typeof t == "object";
return new Promise(function(r, i) {
var a = new b({
next: function(e) {
r(e), a.unsubscribe();
},
error: i,
complete: function() {
n ? r(t.defaultValue) : i(new mt());
}
});
e.subscribe(a);
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/isDate.js
function gt(e) {
return e instanceof Date && !isNaN(e);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/map.js
function A(e, t) {
return C(function(n, r) {
var i = 0;
n.subscribe(w(r, function(n) {
r.next(e.call(t, n, i++));
}));
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js
var _t = Array.isArray;
function vt(e, t) {
return _t(t) ? e.apply(void 0, s([], o(t))) : e(t);
}
function yt(e) {
return A(function(t) {
return vt(e, t);
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js
var bt = Array.isArray, xt = Object.getPrototypeOf, St = Object.prototype, Ct = Object.keys;
function wt(e) {
if (e.length === 1) {
var t = e[0];
if (bt(t)) return {
args: t,
keys: null
};
if (Tt(t)) {
var n = Ct(t);
return {
args: n.map(function(e) {
return t[e];
}),
keys: n
};
}
}
return {
args: e,
keys: null
};
}
function Tt(e) {
return e && typeof e == "object" && xt(e) === St;
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/createObject.js
function Et(e, t) {
return e.reduce(function(e, n, r) {
return e[n] = t[r], e;
}, {});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/combineLatest.js
function j() {
var e = [...arguments], t = ze(e), n = Re(e), r = wt(e), i = r.args, a = r.keys;
if (i.length === 0) return k([], t);
var o = new S(Dt(i, t, a ? function(e) {
return Et(a, e);
} : x));
return n ? o.pipe(yt(n)) : o;
}
function Dt(e, t, n) {
return n === void 0 && (n = x), function(r) {
Ot(t, function() {
for (var i = e.length, a = Array(i), o = i, s = i, c = function(i) {
Ot(t, function() {
var c = k(e[i], t), l = !1;
c.subscribe(w(r, function(e) {
a[i] = e, l || (l = !0, s--), s || r.next(n(a.slice()));
}, function() {
--o || r.complete();
}));
}, r);
}, l = 0; l < i; l++) c(l);
}, r);
};
}
function Ot(e, t, n) {
e ? O(n, e, t) : t();
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js
function kt(e, t, n, r, i, a, o, s) {
var c = [], l = 0, u = 0, d = !1, f = function() {
d && !c.length && !l && t.complete();
}, p = function(e) {
return l < r ? m(e) : c.push(e);
}, m = function(e) {
a && t.next(e), l++;
var s = !1;
D(n(e, u++)).subscribe(w(t, function(e) {
i?.(e), a ? p(e) : t.next(e);
}, function() {
s = !0;
}, void 0, function() {
if (s) try {
l--;
for (var e = function() {
var e = c.shift();
o ? O(t, o, function() {
return m(e);
}) : m(e);
}; c.length && l < r;) e();
f();
} catch (e) {
t.error(e);
}
}));
};
return e.subscribe(w(t, p, function() {
d = !0, f();
})), function() {
s?.();
};
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js
function At(e, t, n) {
return n === void 0 && (n = Infinity), d(t) ? At(function(n, r) {
return A(function(e, i) {
return t(n, e, r, i);
})(D(e(n, r)));
}, n) : (typeof t == "number" && (n = t), C(function(t, r) {
return kt(t, r, e, n);
}));
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js
function jt(e) {
return e === void 0 && (e = Infinity), At(x, e);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/concatAll.js
function Mt() {
return jt(1);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/concat.js
function Nt() {
var e = [...arguments];
return Mt()(k(e, ze(e)));
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/defer.js
function Pt(e) {
return new S(function(t) {
D(e()).subscribe(t);
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/connectable.js
var Ft = {
connector: function() {
return new T();
},
resetOnDisconnect: !0
};
function It(e, t) {
t === void 0 && (t = Ft);
var n = null, r = t.connector, i = t.resetOnDisconnect, a = i === void 0 || i, o = r(), s = new S(function(e) {
return o.subscribe(e);
});
return s.connect = function() {
return (!n || n.closed) && (n = Pt(function() {
return e;
}).subscribe(o), a && n.add(function() {
return o = r();
})), n;
}, s;
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/iif.js
function Lt(e, t, n) {
return Pt(function() {
return e() ? t : n;
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/timer.js
function Rt(e, t, n) {
e === void 0 && (e = 0), n === void 0 && (n = Pe);
var r = -1;
return t != null && (Ie(t) ? n = t : r = t), new S(function(t) {
var i = gt(e) ? +e - n.now() : e;
i < 0 && (i = 0);
var a = 0;
return n.schedule(function() {
t.closed || (t.next(a++), 0 <= r ? this.schedule(void 0, r) : t.complete());
}, i);
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/interval.js
function zt(e, t) {
return e === void 0 && (e = 0), t === void 0 && (t = Ne), e < 0 && (e = 0), Rt(e, e, t);
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/merge.js
function Bt() {
var e = [...arguments], t = ze(e), n = Be(e, Infinity), r = e;
return r.length ? r.length === 1 ? D(r[0]) : jt(n)(k(r, t)) : Fe;
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/util/argsOrArgArray.js
var Vt = Array.isArray;
function Ht(e) {
return e.length === 1 && Vt(e[0]) ? e[0] : e;
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/filter.js
function M(e, t) {
return C(function(n, r) {
var i = 0;
n.subscribe(w(r, function(n) {
return e.call(t, n, i++) && r.next(n);
}));
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/race.js
function Ut() {
var e = [...arguments];
return e = Ht(e), e.length === 1 ? D(e[0]) : new S(Wt(e));
}
function Wt(e) {
return function(t) {
for (var n = [], r = function(r) {
n.push(D(e[r]).subscribe(w(t, function(e) {
if (n) {
for (var i = 0; i < n.length; i++) i !== r && n[i].unsubscribe();
n = null;
}
t.next(e);
})));
}, i = 0; n && !t.closed && i < e.length; i++) r(i);
};
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js
function Gt(e, t, n, r, i) {
return function(a, o) {
var s = n, c = t, l = 0;
a.subscribe(w(o, function(t) {
var n = l++;
c = s ? e(c, t, n) : (s = !0, t), r && o.next(c);
}, i && (function() {
s && o.next(c), o.complete();
})));
};
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/debounceTime.js
function Kt(e, t) {
return t === void 0 && (t = Ne), C(function(n, r) {
var i = null, a = null, o = null, s = function() {
if (i) {
i.unsubscribe(), i = null;
var e = a;
a = null, r.next(e);
}
};
function c() {
var n = o + e, a = t.now();
if (a < n) {
i = this.schedule(void 0, n - a), r.add(i);
return;
}
s();
}
n.subscribe(w(r, function(n) {
a = n, o = t.now(), i || (i = t.schedule(c, e), r.add(i));
}, function() {
s(), r.complete();
}, void 0, function() {
a = i = null;
}));
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/take.js
function N(e) {
return e <= 0 ? function() {
return Fe;
} : C(function(t, n) {
var r = 0;
t.subscribe(w(n, function(t) {
++r <= e && (n.next(t), e <= r && n.complete());
}));
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/ignoreElements.js
function qt() {
return C(function(e, t) {
e.subscribe(w(t, v));
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/mapTo.js
function Jt(e) {
return A(function() {
return e;
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/delayWhen.js
function Yt(e, t) {
return t ? function(n) {
return Nt(t.pipe(N(1), qt()), n.pipe(Yt(e)));
} : At(function(t, n) {
return D(e(t, n)).pipe(N(1), Jt(t));
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/delay.js
function Xt(e, t) {
t === void 0 && (t = Ne);
var n = Rt(e, t);
return Yt(function() {
return n;
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js
function Zt(e, t) {
return t === void 0 && (t = x), e ??= Qt, C(function(n, r) {
var i, a = !0;
n.subscribe(w(r, function(n) {
var o = t(n);
(a || !e(i, o)) && (a = !1, i = o, r.next(n));
}));
});
}
function Qt(e, t) {
return e === t;
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/retry.js
function $t(e) {
e === void 0 && (e = Infinity);
var t = e && typeof e == "object" ? e : { count: e }, n = t.count, r = n === void 0 ? Infinity : n, i = t.delay, a = t.resetOnSuccess, o = a !== void 0 && a;
return r <= 0 ? x : C(function(e, t) {
var n = 0, a, s = function() {
var c = !1;
a = e.subscribe(w(t, function(e) {
o && (n = 0), t.next(e);
}, void 0, function(e) {
if (n++ < r) {
var o = function() {
a ? (a.unsubscribe(), a = null, s()) : c = !0;
};
if (i != null) {
var l = typeof i == "number" ? Rt(i) : D(i(e, n)), u = w(t, function() {
u.unsubscribe(), o();
}, function() {
t.complete();
});
l.subscribe(u);
} else o();
} else t.error(e);
})), c && (a.unsubscribe(), a = null, s());
};
s();
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/scan.js
function en(e, t) {
return C(Gt(e, t, arguments.length >= 2, !0));
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/share.js
function tn(e) {
e === void 0 && (e = {});
var t = e.connector, n = t === void 0 ? function() {
return new T();
} : t, r = e.resetOnError, i = r === void 0 || r, a = e.resetOnComplete, o = a === void 0 || a, s = e.resetOnRefCountZero, c = s === void 0 || s;
return function(e) {
var t, r, a, s = 0, l = !1, u = !1, d = function() {
r?.unsubscribe(), r = void 0;
}, f = function() {
d(), t = a = void 0, l = u = !1;
}, p = function() {
var e = t;
f(), e?.unsubscribe();
};
return C(function(e, m) {
s++, !u && !l && d();
var h = a ??= n();
m.add(function() {
s--, s === 0 && !u && !l && (r = nn(p, c));
}), h.subscribe(m), !t && s > 0 && (t = new b({
next: function(e) {
return h.next(e);
},
error: function(e) {
u = !0, d(), r = nn(f, i, e), h.error(e);
},
complete: function() {
l = !0, d(), r = nn(f, o), h.complete();
}
}), D(e).subscribe(t));
})(e);
};
}
function nn(e, t) {
var n = [...arguments].slice(2);
if (t === !0) {
e();
return;
}
if (t !== !1) {
var r = new b({ next: function() {
r.unsubscribe(), e();
} });
return D(t.apply(void 0, s([], o(n)))).subscribe(r);
}
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/switchMap.js
function P(e, t) {
return C(function(n, r) {
var i = null, a = 0, o = !1, s = function() {
return o && !i && r.complete();
};
n.subscribe(w(r, function(n) {
i?.unsubscribe();
var o = 0, c = a++;
D(e(n, c)).subscribe(i = w(r, function(e) {
return r.next(t ? t(n, e, c, o++) : e);
}, function() {
i = null, s();
}));
}, function() {
o = !0, s();
}));
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/takeUntil.js
function rn(e) {
return C(function(t, n) {
D(e).subscribe(w(n, function() {
return n.complete();
}, v)), !n.closed && t.subscribe(n);
});
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/tap.js
function an(e, t, n) {
var r = d(e) || t || n ? {
next: e,
error: t,
complete: n
} : e;
return r ? C(function(e, t) {
var n;
(n = r.subscribe) == null || n.call(r);
var i = !0;
e.subscribe(w(t, function(e) {
var n;
(n = r.next) == null || n.call(r, e), t.next(e);
}, function() {
var e;
i = !1, (e = r.complete) == null || e.call(r), t.complete();
}, function(e) {
var n;
i = !1, (n = r.error) == null || n.call(r, e), t.error(e);
}, function() {
var e, t;
i && ((e = r.unsubscribe) == null || e.call(r)), (t = r.finalize) == null || t.call(r);
}));
}) : x;
}
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/operators/withLatestFrom.js
function on() {
var e = [...arguments], t = Re(e);
return C(function(n, r) {
for (var i = e.length, a = Array(i), c = e.map(function() {
return !1;
}), l = !1, u = function(t) {
D(e[t]).subscribe(w(r, function(e) {
a[t] = e, !l && !c[t] && (c[t] = !0, (l = c.every(x)) && (c = null));
}, v));
}, d = 0; d < i; d++) u(d);
n.subscribe(w(r, function(e) {
if (l) {
var n = s([e], o(a));
r.next(t ? t.apply(void 0, s([], o(n))) : n);
}
}));
});
}
//#endregion
//#region src/lib/utils/state-utils.ts
function F(e, t, n) {
return e[t] ?? n;
}
function I(...e) {
return e.join(".");
}
//#endregion
//#region src/lib/state/state-selectors.ts
var L = (e) => ye(A((t) => e(t)), Zt(), M((e) => e !== void 0)), R = (e, t) => L((n) => F(n, e, t)), z = (e, t = !1) => L((n) => !!F(n, e, t)), sn = (e, t, n, r, i, a = 1) => {
switch (i) {
case "master": {
let i = I(n, r - 1, e);
return (e) => F(e, i, t);
}
case "aux":
case "fx":
case "mtx": {
let o = I(n, r - 1, i, a - 1, e);
return (e) => F(e, o, t);
}
}
}, cn = () => (e) => F(e, "m.mix"), ln = () => (e) => F(e, "m.pan"), un = () => (e) => !!F(e, "m.dim"), dn = (e) => (t) => F(t, `m.delay${e}`, 0) * 1e3, fn = (e, t, n, r) => sn("pan", 0, e, t, n, r), pn = (e, t, n, r) => {
let i = sn("mute", 0, e, t, n, r);
return (e) => !!i(e);
}, mn = (e, t) => {
let n = I(e, t - 1, "solo");
return (e) => !!F(e, n);
}, hn = (e, t, n, r = 1) => {
switch (n) {
case "master": {
let n = I(e, t - 1, "mix");
return (e) => F(e, n);
}
case "aux":
case "fx":
case "mtx": {
let i = I(e, t - 1, n, r - 1, "value");
return (e) => F(e, i);
}
}
}, gn = (e, t) => {
let n = I(e, t - 1, "delay");
return (e) => F(e, n, 0) * 1e3;
}, _n = (e, t, n, r) => {
let i = I(e, t - 1, n, r - 1, "post");
return (e) => !!F(e, i, 0);
}, vn = (e, t, n, r) => {
let i = sn("postproc", 0, e, t, n, r);
return (e) => !!i(e);
}, yn = (e = 1) => {
let t = I("f", e - 1, "bpm");
return (e) => F(e, t);
}, bn = (e = 1) => {
let t = I("f", e - 1, "fxtype");
return (e) => F(e, t);
}, B = (e, t) => {
if (![
"i",
"l",
"p",
"a"
].includes(e)) return () => -1;
let n = I(e, t - 1, "stereoIndex");
return (e) => F(e, n, -1);
}, xn = (e) => {
let t = I("a", e - 1, "matrix");
return (e) => !!F(e, t, 0);
}, Sn = (e, t) => {
let n = I(t, e - 1, "phantom");
return (e) => !!F(e, n);
}, Cn = (e, t) => {
let n = I(t, e - 1, "gain");
return (e) => F(e, n);
}, wn = (e, t) => {
let n = I("settings", e, ...t !== void 0 && t >= 0 ? [t] : []);
return (e) => F(e, n);
}, Tn = () => (e) => F(e, "var.currentLength", -1), En = () => (e) => F(e, "var.currentTrackPos", 0), Dn = (e, t) => Math.max(0, Math.floor(e * t)), On = (e, t) => Math.max(0, Math.floor(t - Dn(e, t))), kn = () => (e) => Dn(En()(e), Tn()(e)), An = () => (e) => On(En()(e), Tn()(e)), jn = () => (e) => F(e, "var.mtk.currentLength", -1), Mn = () => (e) => F(e, "var.mtk.currentTrackPos", 0), Nn = () => (e) => Dn(Mn()(e), jn()(e)), Pn = () => (e) => On(Mn()(e), jn()(e)), V = /* @__PURE__ */ function(e) {
return e.Opening = "OPENING", e.Open = "OPEN", e.Close = "CLOSE", e.Closing = "CLOSING", e.Error = "ERROR", e.Reconnecting = "RECONNECTING", e;
}({}), Fn = /* @__PURE__ */ function(e) {
return e[e.Stopped = 0] = "Stopped", e[e.Playing = 2] = "Playing", e[e.Paused = 3] = "Paused", e;
}({}), In = /* @__PURE__ */ function(e) {
return e[e.Stopped = 0] = "Stopped", e[e.Paused = 1] = "Paused", e[e.Playing = 2] = "Playing", e;
}({}), H = /* @__PURE__ */ function(e) {
return e[e.None = -1] = "None", e[e.Reverb = 0] = "Reverb", e[e.Delay = 1] = "Delay", e[e.Chorus = 2] = "Chorus", e[e.Room = 3] = "Room", e;
}({});
//#endregion
//#region src/lib/utils.ts
function U(e, t, n) {
return Math.min(n, Math.max(t, e));
}
function W(e) {
return Math.round((e + 2 ** -52) * 1e3) / 1e3;
}
function Ln(e) {
if (e < 0) return "";
let t = Math.floor(e), n = Math.floor(t / 60), r = t % 60;
return `${n}:${r.toString().length === 1 ? "0" : ""}${r}`;
}
function G(e, t) {
switch (t) {
case 1: return e - 1;
case 0: return e + 1;
default: return;
}
}
function Rn(e) {
switch (e) {
case 1: return "L";
case 2: return "R";
default: return "";
}
}
function zn(e) {
switch (e) {
case H.None: return "None";
case H.Chorus: return "Chorus";
case H.Reverb: return "Reverb";
case H.Delay: return "Delay";
case H.Room: return "Room";
}
}
function Bn(e) {
return e.replace(/[\^]/gi, "").substring(0, 20).toUpperCase();
}
function Vn(e, t) {
switch (e) {
case "i": return "CH " + t;
case "a": return "AUX " + t;
case "f": return "FX " + t;
case "s": return "SUB " + t;
case "v": return "VCA " + t;
case "l": return "LINE IN " + Rn(t);
case "p": return "PLAYER " + Rn(t);
}
}
function Hn(e) {
return "MTX " + e;
}
function Un(e, t) {
switch (e) {
case "solovol": return "SOLO LEVEL";
case "hpvol": return `HEADPHONE ${t} LEVEL`;
}
}
function Wn(e) {
return ht(Ut(e.state$.pipe(Kt(25)), Rt(250)).pipe(A(() => void 0)));
}
//#endregion
//#region src/lib/utils/value-converters/value-converters.ts
function Gn(e, t) {
return U(e, 0, t) / 1e3;
}
function Kn(e) {
return (e < .055 ? Math.sin(28.559933214452666 * e) : 1) * Math.exp((23.90844819639692 + (-26.23877598214595 + (12.195249692570245 - .4878099877028098 * e) * e) * e) * e) * .0002676529517952372;
}
function qn(e) {
let t = (23.90844819639692 + (-26.23877598214595 + (12.195249692570245 - .4878099877028098 * e) * e) * e) * e, n = 23.90844819639692 + (-52.4775519642919 + (36.58574907771074 - 1.9512399508112392 * e) * e) * e, r = Math.exp(t);
if (e < .055) {
let t = 28.559933214452666 * e;
return .0002676529517952372 * r * (28.559933214452666 * Math.cos(t) + Math.sin(t) * n);
}
return .0002676529517952372 * r * n;
}
function K(e) {
if (e <= -200) return 0;
if (e >= 10) return 1;
let t = 10 ** (e / 20), n = .5;
for (let e = 0; e < 20; e++) {
let e = (Kn(n) - t) / qn(n);
if (n -= e, n < 0 && (n = 1e-10), n > 1 && (n = 1), Math.abs(e) < 1e-15) break;
}
return Math.round(n * 1e11) / 1e11;
}
function q(e) {
let t = Kn(e);
return t < 1e-10 ? -Infinity : Math.round(20 * Math.log10(t) * 10) / 10 || 0;
}
var J = 20, Jn = 4e3;
function Yn(e) {
return Math.round((Jn - J) * e ** 3.0517 + J);
}
function Xn(e) {
let t = ((U(e, J, Jn) - J) / (Jn - J)) ** .32768620768751844;
return Math.floor(t * 1e7) / 1e7;
}
function Zn(e, t, n) {
return U((e - t) / (n - t), 0, 1);
}
function Qn(e, t, n) {
return U(Math.round((e * (n - t) + t) * 10) / 10, t, n);
}
//#endregion
//#region src/lib/facade/automix-controller.ts
var $n = class {
constructor(e, t, n) {
this.conn = e, this.store = t, this.group = n, this.state$ = this.store.state$.pipe(z(`automix.${this.group}.on`));
}
setState(e) {
this.conn.setdBool(`automix.${this.group}.on`, e);
}
enable() {
this.setState(!0);
}
disable() {
this.setState(!1);
}
toggle() {
this.state$.pipe(N(1)).subscribe((e) => this.setState(!e));
}
}, er = class {
setResponseTime(e) {
this.conn.setd("automix.time", e);
}
setResponseTimeMs(e) {
this.setResponseTime(Xn(e));
}
constructor(e, t) {
this.conn = e, this.store = t, this.responseTime$ = this.store.state$.pipe(R("automix.time")), this.responseTimeMs$ = this.responseTime$.pipe(A((e) => Yn(e))), this.groups = {
a: new $n(this.conn, this.store, "a"),
b: new $n(this.conn, this.store, "b")
};
}
};
//#endregion
//#region src/lib/facade/channel-id.ts
function tr(e, t) {
return `${e}.${t - 1}`;
}
function Y(e, t, n, r) {
return `${e}.${t - 1}.${n}.${r - 1}`;
}
function nr(e, t, n) {
return `${e}.${t - 1}.mtx.${n - 1}`;
}
//#endregion
//#region src/lib/utils/transitions/easings.ts
var X = /* @__PURE__ */ function(e) {
return e[e.Linear = 0] = "Linear", e[e.EaseIn = 1] = "EaseIn", e[e.EaseOut = 2] = "EaseOut", e[e.EaseInOut = 3] = "EaseInOut", e;
}({}), rr = {
0: (e) => e,
1: (e) => e * e,
2: (e) => e * (2 - e),
3: (e) => e * e * (3 - 2 * e)
};
//#endregion
//#region src/lib/transitions.ts
function ir(e, t, n) {
return e.pipe(on(t), P(([{ targetValue: e, fadeTime: t, easing: r, fps: i }, a]) => ar(a, e, t, r, i).pipe(rn(n.status$.pipe(M((e) => e.type === V.Close))))));
}
function ar(e, t, n, r, i) {
n = Math.max(n, i);
let a = Math.round(1e3 / i), o = Math.round(n / a);
r ||= X.Linear;
let s = rr[r] || rr[X.Linear];
return zt(a).pipe(N(o), A((n) => s((n + 1) / o) * (t - e) + e), Zt());
}
//#endregion
//#region src/lib/utils/async-helpers.ts
function or(e) {
return new Promise((t) => setTimeout(() => t(), e));
}
//#endregion
//#region src/lib/facade/channel.ts
var sr = class {
constructor(e, t, n, r, i = "master", a = 0) {
this.conn = e, this.store = t, this.channelType = n, this.channel = r, this.busType = i, this.bus = a, this.fullChannelId = `${this.channelType}.${this.channel - 1}`, this.faderLevelCommand = "mix", this.linkedChannelIds = [this.fullChannelId], this.transitionSources$ = new T(), this.stereoIndex$ = this.store.state$.pipe(L(B(this.channelType, this.channel))), this.faderLevel$ = this.store.state$.pipe(L(hn(this.channelType, this.channel, this.busType, this.bus))), this.faderLevelDB$ = this.faderLevel$.pipe(A((e) => q(e))), this.mute$ = this.store.state$.pipe(L(pn(this.channelType, this.channel, this.busType, this.bus))), this.rawName$ = this.store.state$.pipe(R(I(this.channelType, this.channel - 1, "name"))), this.auxIsMatrix$ = this.store.state$.pipe(L(xn(this.channel))), this.name$ = Lt(() => this.channelType !== "a", this.rawName$.pipe(A((e) => e || Vn(this.channelType, this.channel))), j([this.rawName$, this.auxIsMatrix$]).pipe(A(([e, t]) => e || (t ? Hn(this.channel) : Vn(this.channelType, this.channel))))), ir(this.transitionSources$, this.faderLevel$, e).subscribe((e) => this.setFaderLevelRaw(e));
}
fadeTo(e, t, n = X.Linear, r = 25) {
return e = U(e, 0, 1), this.transitionSources$.next({
targetValue: e,
fadeTime: t,
easing: n,
fps: r
}), or(t);
}
fadeToDB(e, t, n = X.Linear, r = 25) {
let i = K(e);
return this.fadeTo(i, t, n, r);
}
setFaderLevel(e) {
e = U(e, 0, 1), this.setFaderLevelRaw(e);
}
setFaderLevelRaw(e) {
this.linkedChannelIds.forEach((t) => {
this.conn.setd(`${t}.${this.faderLevelCommand}`, e);
});
}
setFaderLevelDB(e) {
this.setFaderLevel(K(e));
}
changeFaderLevel(e) {
this.faderLevel$.pipe(N(1)).subscribe((t) => this.setFaderLevel(W(t + e)));
}
changeFaderLevelDB(e) {
this.faderLevelDB$.pipe(N(1)).subscribe((t) => this.setFaderLevelDB(Math.max(t, -100) + e));
}
setMute(e) {
this.linkedChannelIds.forEach((t) => {
this.conn.setdBool(`${t}.mute`, e);
});
}
mute() {
this.setMute(!0);
}
unmute() {
this.setMute(!1);
}
toggleMute() {
this.mute$.pipe(N(1)).subscribe((e) => this.setMute(!e));
}
setName(e) {
e = Bn(e);
let t = I(this.channelType, this.channel - 1, "name");
this.conn.sets(t, e);
}
}, cr = class extends sr {
constructor(e, t, n, r, i, a) {
super(e, t, n, r, i, a), this.fullChannelId = Y(this.channelType, this.channel, this.busType, this.bus), this.faderLevelCommand = "value", this.post$ = this.store.state$.pipe(L(_n(this.channelType, this.channel, this.busType, this.bus))), this.linkedChannelIds = [this.fullChannelId];
}
setPost(e) {
this.linkedChannelIds.forEach((t) => {
this.conn.setdBool(`${t}.post`, e);
});
}
post() {
this.setPost(!0);
}
pre() {
this.setPost(!1);
}
togglePost() {
this.post$.pipe(N(1)).subscribe((e) => this.setPost(!e));
}
}, Z = class extends cr {
constructor(e, t, n, r, i) {
super(e, t, n, r, "aux", i), this.auxLinkChannelIds = [this.fullChannelId], this.pan$ = this.store.state$.pipe(L(fn(this.channelType, this.channel, this.busType, this.bus))), this.postProc$ = this.store.state$.pipe(L(vn(this.channelType, this.channel, this.busType, this.bus))), j([this.store.state$.pipe(L(B("a", i))), this.stereoIndex$]).pipe(A(([e, t]) => {
let a = G(i, e), o = G(r, t), s = [this.fullChannelId], c = [this.fullChannelId];
if (o !== void 0 && s.push(Y(n, o, this.busType, i)), a !== void 0) {
let e = Y(n, r, this.busType, a);
s.push(e), c.push(e);
}
return a !== void 0 && o !== void 0 && s.push(Y(n, o, this.busType, a)), {
allChannelIds: s,
auxLinkChannelIds: c
};
})).subscribe((e) => {
this.linkedChannelIds = e.allChannelIds, this.auxLinkChannelIds = e.auxLinkChannelIds;
});
}
setPan(e) {
e = U(e, 0, 1), e = W(e), this.auxLinkChannelIds.forEach((t) => {
this.conn.setd(`${t}.pan`, e);
});
}
changePan(e) {
this.pan$.pipe(N(1)).subscribe((t) => this.setPan(t + e));
}
setPostProc(e) {
this.linkedChannelIds.forEach((t) => {
this.conn.setdBool(`${t}.postproc`, e);
});
}
postProc() {
this.setPostProc(!0);
}
preProc() {
this.setPostProc(!1);
}
};
//#endregion
//#region src/lib/facade/matrix-utils.ts
function lr(e, t, n, r) {
e.setdBool(`a.${n - 1}.matrix`, r), t.state$.pipe(L(B("a", n)), N(1)).subscribe((t) => {
let i = G(n, t);
i !== void 0 && e.setdBool(`a.${i - 1}.matrix`, r);
});
}
//#endregion
//#region src/lib/facade/mtx-channel.ts
var ur = class {
constructor(e, t, n) {
this.conn = e, this.store = t, this.fullChannelId = n, this.faderLevel$ = this.store.state$.pipe(R(`${this.fullChannelId}.value`)), this.faderLevelDB$ = this.faderLevel$.pipe(A((e) => q(e))), this.mute$ = this.store.state$.pipe(z(`${this.fullChannelId}.mute`)), this.pan$ = this.store.state$.pipe(R(`${this.fullChannelId}.pan`, 0)), this.postProc$ = this.store.state$.pipe(z(`${this.fullChannelId}.postproc`)), this.linkedChannelIds = [this.fullChannelId], this.panLinkChannelIds = [this.fullChannelId], this.transitionSources$ = new T(), ir(this.transitionSources$, this.faderLevel$, e).subscribe((e) => this.setFaderLevelRaw(e));
}
fadeTo(e, t, n = X.Linear, r = 25) {
return e = U(e, 0, 1), this.transitionSources$.next({
targetValue: e,
fadeTime: t,
easing: n,
fps: r
}), or(t);
}
fadeToDB(e, t, n = X.Linear, r = 25) {
let i = K(e);
return this.fadeTo(i, t, n, r);
}
setFaderLevel(e) {
e = U(e, 0, 1), this.setFaderLevelRaw(e);
}
setFaderLevelRaw(e) {
this.linkedChannelIds.forEach((t) => {
this.conn.setd(`${t}.value`, e);
});
}
setFaderLevelDB(e) {
this.setFaderLevel(K(e));
}
changeFaderLevel(e) {
this.faderLevel$.pipe(N(1)).subscribe((t) => this.setFaderLevel(W(t + e)));
}
changeFaderLevelDB(e) {
this.faderLevelDB$.pipe(N(1)).subscribe((t) => this.setFaderLevelDB(Math.max(t, -100) + e));
}
setMute(e) {
this.linkedChannelIds.forEach((t) => {
this.conn.setdBool(`${t}.mute`, e);
});
}
mute() {
this.setMute(!0);
}
unmute() {
this.setMute(!1);
}
toggleMute() {
this.mute$.pipe(N(1)).subscribe((e) => this.setMute(!e));
}
setPan(e) {
e = U(e, 0, 1), e = W(e), this.panLinkChannelIds.forEach((t) => {
this.conn.setd(`${t}.pan`, e);
});
}
changePan(e) {
this.pan$.pipe(N(1)).subscribe((t) => this.setPan(t + e));
}
setPostProc(e) {
this.linkedChannelIds.forEach((t) => {
this.conn.setdBool(`${t}.postproc`, e);
});
}
postProc() {
this.setPostProc(!0);
}
preProc() {
this.setPostProc(!1);
}
}, dr = class extends ur {
constructor(e, t, n, r, i) {
super(e, t, nr(n, r, i)), this.channelType = n, this.channel = r, this.bus = i, this.name$ = this.store.state$.pipe(R(I(this.channelType, this.channel - 1, "name")), A((e) => e || Vn(this.channelType, this.channel)));
let a = t.state$.pipe(L(B(n, r)));
j([t.state$.pipe(L(B("a", i))), a]).pipe(A(([e, t]) => {
let a = G(i, e), o = G(r, t), s = [this.fullChannelId], c = [this.fullChannelId];
if (o !== void 0 && s.push(nr(n, o, i)), a !== void 0) {
let e = nr(n, r, a);
s.push(e), c.push(e);
}
return a !== void 0 && o !== void 0 && s.push(nr(n, o, a)), {
allChannelIds: s,
mtxLinkChannelIds: c
};
})).subscribe((e) => {
this.linkedChannelIds = e.allChannelIds, this.panLinkChannelIds = e.mtxLinkChannelIds;
});
}
setName(e) {
e = Bn(e);
let t = I(this.channelType, this.channel - 1, "name");
this.conn.sets(t, e);
}
}, fr = class extends ur {
constructor(e, t, n) {
super(e, t, `m.mtx.${n - 1}`), this.name$ = pt("MASTER"), t.state$.pipe(L(B("a", n)), A((e) => {
let t = G(n, e);
return t === void 0 ? [this.fullChannelId] : [this.fullChannelId, `m.mtx.${t - 1}`];
})).subscribe((e) => {
this.linkedChannelIds = e, this.panLinkChannelIds = e;
});
}
};
//#endregion
//#region src/lib/facade/object-store-ids.ts
function pr(e) {
return "auxbus" + e;
}
function mr(e) {
return "mtxbus" + e;
}
//#endregion
//#region src/lib/facade/mtx-bus.ts
var hr = class {
constructor(e, t, n) {
this.conn = e, this.store = t, this.bus = n, this.isMatrix$ = this.store.state$.pipe(L(xn(this.bus)));
}
aux(e) {
return this.store.objectStore.getOrCreate(`mtx${this.bus}a${e}`, () => new dr(this.conn, this.store, "a", e, this.bus));
}
sub(e) {
return this.store.objectStore.getOrCreate(`mtx${this.bus}s${e}`, () => new dr(this.conn, this.store, "s", e, this.bus));
}
master() {
return this.store.objectStore.getOrCreate(`mtxmaster${this.bus}`, () => new fr(this.conn, this.store, this.bus));
}
switchToAux() {
return lr(this.conn, this.store, this.bus, !1), this.store.objectStore.getOrCreate(pr(this.bus), () => new gr(this.conn, this.store, this.bus));
}
}, gr = class {
constructor(e, t, n) {
this.conn = e, this.store = t, this.bus = n, this.isMatrix$ = this.store.state$.pipe(L(xn(this.bus)));
}
input(e) {
return this.store.objectStore.getOrCreate(`aux${this.bus}i${e}`, () => new Z(this.conn, this.store, "i", e, this.bus));
}
line(e) {
return this.store.objectStore.getOrCreate(`aux${this.bus}l${e}`, () => new Z(this.conn, this.store, "l", e, this.bus));
}
player(e) {
return this.store.objectStore.getOrCreate(`aux${this.bus}p${e}`, () => new Z(this.conn, this.store, "p", e, this.bus));
}
fx(e) {
return this.store.objectStore.getOrCreate(`aux${this.bus}f${e}`, () => new Z(this.conn, this.store, "f", e, this.bus));
}
switchToMatrix() {
return lr(this.conn, this.store, this.bus, !0), this.store.objectStore.getOrCreate(mr(this.bus), () => new hr(this.conn, this.store, this.bus));
}
}, _r = {
ui12: {
model: "ui12",
input: 8,
line: 2,
player: 2,
fx: 4,
sub: 4,
aux: 4,
vca: 0,
multitrack: !1,
masterDim: !1
},
ui16: {
model: "ui16",
input: 12,
line: 2,
player: 2,
fx: 4,
sub: 4,
aux: 6,
vca: 0,
multitrack: !1,
masterDim: !1
},
ui24: {
model: "ui24",
input: 24,
line: 2,
player: 2,
fx: 4,
sub: 6,
aux: 10,
vca: 6,
multitrack: !0,
masterDim: !0
}
}, vr = class {
constructor(e) {
this.store = e, this.model$ = this.store.state$.pipe(R("model")), this.capabilities$ = this.model$.pipe(A((e) => _r[e])), this.firmware$ = this.store.state$.pipe(R("firmware")), this.model$.subscribe((e) => this.model = e);
}
}, yr = class {
constructor(e, t) {
this.conn = e, this.store = t, this.recording$ = this.store.state$.pipe(z("var.isRecording")), this.busy$ = this.store.state$.pipe(z("var.recBusy"));
}
recordToggle() {
this.conn.sendMessage("RECTOGGLE");
}
recordStart() {
this.recording$.pipe(N(1)).subscribe((e) => {
e || this.recordToggle();
});
}
recordStop() {
this.recording$.pipe(N(1)).subscribe((e) => {
e && this.recordToggle();
});
}
}, Q = class extends cr {
constructor(e, t, n, r, i) {
super(e, t, n, r, "fx", i), this.stereoIndex$.pipe(A((e) => {
let t = G(r, e);
return t === void 0 ? [this.fullChannelId] : [this.fullChannelId, Y(this.channelType, t, this.busType, this.bus)];
})).subscribe((e) => this.linkedChannelIds = e);
}
}, br = class {
constructor(e, t, n) {
this.conn = e, this.store = t, this.bus = n, this.fxType$ = this.store.state$.pipe(L(bn(this.bus))), this.bpm$ = this.store.state$.pipe(L(yn(this.bus)));
}
input(e) {
return this.store.objectStore.getOrCreate(`fx${this.bus}i${e}`, () => new Q(this.conn, this.store, "i", e, this.bus));
}
line(e) {
return this.store.objectStore.getOrCreate(`fx${this.bus}l${e}`, () => new Q(this.conn, this.store, "l", e, this.bus));
}
player(e) {
return this.store.objectStore.getOrCreate(`fx${this.bus}p${e}`, () => new Q(this.conn, this.store, "p", e, this.bus));
}
sub(e) {
return this.store.objectStore.getOrCreate(`fx${this.bus}s${e}`, () => new Q(this.conn, this.store, "s", e, this.bus));
}
setBpm(e) {
e = U(e, 20, 400), e = Math.round(e), this.conn.setd(`f.${this.bus - 1}.bpm`, e);
}
assertFxParamInRange(e) {
if (e < 1 || e > 6) throw Error("FX Parameter must be between 1 and 6.");
}
makeFxParamPath(e) {
return `f.${this.bus - 1}.par${e}`;
}
getParam(e) {
return this.assertFxParamInRange(e), this.store.state$.pipe(R(this.makeFxParamPath(e)));
}
setParam(e, t) {
this.assertFxParamInRange(e), t = U(t, 0, 1), this.conn.setd(this.makeFxParamPath(e), t);
}
}, xr = class {
constructor(e, t, n, r) {
this.conn = e, this.store = t, this.deviceInfo = n, this.channel = r, this.fullChannelId = `hw.${this.channel - 1}`, this.phantom$ = this.deviceInfo.model$.pipe(P((e) => {
switch (e) {
case "ui24": return this.store.state$.pipe(L(Sn(this.channel, "hw")));
case "ui16":
case "ui12": return this.store.state$.pipe(L(Sn(this.channel, "i")));
}
})), this.gain$ = this.deviceInfo.model$.pipe(P((e) => {
switch (e) {
case "ui24": return this.store.state$.pipe(L(Cn(this.channel, "hw")));
case "ui16":
case "ui12": return this.store.state$.pipe(L(Cn(this.channel, "i")));
}
})), this.gainDB$ = this.deviceInfo.model$.pipe(P((e) => {
switch (e) {
case "ui24": return this.gain$.pipe(A((e) => Qn(e, -6, 57)));
case "ui16":
case "ui12": return this.gain$.pipe(A((e) => Qn(e, -40, 50)));
}
})), this.deviceInfo.model$.subscribe((e) => {
switch (e) {
case "ui24":
this.fullChannelId = `hw.${this.channel - 1}`;
return;
case "ui16":
case "ui12":
this.fullChannelId = `i.${this.channel - 1}`;
return;
}
});
}
setPhantom(e) {
this.conn.setdBool(`${this.fullChannelId}.phantom`, e);
}
phantomOn() {
this.setPhantom(!0);
}
phantomOff() {
this.setPhantom(!1);
}
togglePhantom() {
this.phantom$.pipe(N(1)).subscribe((e) => this.setPhantom(!e));
}
setGain(e) {
e = U(e, 0, 1), this.conn.setd(`${this.fullChannelId}.gain`, e);
}
changeGain(e) {
this.gain$.pipe(N(1)).subscribe((t) => this.setGain(W(t + e)));
}
setGainDB(e) {
switch (this.deviceInfo.model) {
case "ui24":
this.setGain(Zn(e, -6, 57));
return;
case "ui16":
case "ui12":
this.setGain(Zn(e, -40, 50));
return;
}
}
changeGainDB(e) {
this.gainDB$.pipe(N(1)).subscribe((t) => this.setGainDB(t + e));
}
}, $ = class extends sr {
constructor(e, t, n, r) {
super(e, t, n, r), this.fullChannelId = tr(this.channelType, this.channel), this.faderLevelCommand = "mix", this.solo$ = this.store.state$.pipe(L(mn(this.channelType, this.channel))), this.pan$ = this.store.state$.pipe(L(fn(this.channelType, this.channel, this.busType, this.bus))), this.automixGroup$ = this.store.state$.pipe(R(`${this.fullChannelId}.amixgroup`), A((e) => {
switch (e) {
case 0: return "a";
case 1: return "b";
default: return "none";
}
})), this.automixWeight$ = this.store.state$.pipe(R(`${this.fullChannelId}.amix`)), this.automixWeightDB$ = this.automixWeight$.pipe(A((e) => Qn(e, -12, 12))), this.multiTrackSelected$ = this.store.state$.pipe(z(`${this.fullChannelId}.mtkrec`)), this.linkedChannelIds = [this.fullChannelId], this.stereoIndex$.pipe(A((e) => {
let t = G(r, e);
return t === void 0 ? [this.fullChannelId] : [this.fullChannelId, tr(this.channelType, t)];
})).subscribe((e) => this.linkedChannelIds = e);
}
setPan(e) {
e = U(e, 0, 1), e = W(e), this.conn.setd(`${this.fullChannelId}.pan`, e);
}
changePan(e) {
this.pan$.pipe(N(1)).subscribe((t) => this.setPan(t + e));
}
setSolo(e) {
this.linkedChannelIds.forEach((t) => {
this.conn.setdBool(`${t}.solo`, e);
});
}
solo() {
this.setSolo(!0);
}
unsolo() {
this.setSolo(!1);
}
toggleSolo() {
this.solo$.pipe(N(1)).subscribe((e) => this.setSolo(!e));
}
multiTrackAssertChannelType() {
if (this.channelType !== "i" && this.channelType !== "l") throw Error("Multitrack recording can only be used with input and line channels");
}
multiTrackSetSelection(e) {
this.multiTrackAssertChannelType(), this.conn.setdBool(`${this.fullChannelId}.mtkrec`, e);
}
multiTrackSelect() {
this.multiTrackSetSelection(!0);
}
multiTrackUnselect() {
this.multiTrackSetSelection(!1);
}
multiTrackToggle() {
this.multiTrackAssertChannelType(), this.multiTrackSelected$.pipe(N(1)).subscribe((e) => this.multiTrackSetSelection(!e));
}
automixAssignGroup(e) {
if (this.channelType !== "i") throw Error("Automix can only be used with input channels");
let t = -1;
switch (e) {
case "a":
t = 0;
break;
case "b":
t = 1;
break;
case "none":
t = -1;
break;
}
this.linkedChannelIds.forEach((e) => {
this.conn.setd(`${e}.amixgroup`, t);
});
}
automixRemove() {
this.automixAssignGroup("none");
}
automixSetWeight(e) {
e = U(e, 0, 1), this.linkedChannelIds.forEach((t) => {
this.conn.setd(`${t}.amix`, e);
});
}
automixSetWeightDB(e) {
this.automixSetWeight(Zn(e, -12, 12));
}
automixChangeWeightDB(e) {
this.automixWeightDB$.pipe(N(1)).subscribe((t) => this.automixSetWeightDB(t + e));
}
}, Sr = class extends $ {
constructor(e, t, n, r) {
super(e, t, n, r), this.delay$ = this.store.state$.pipe(L(gn(this.channelType, this.channel))), this.delayMaxValueMs = 250, n === "a" && (this.delayMaxValueMs = 500);
}
setDelay(e) {
let t = Gn(e, this.delayMaxValueMs);
this.conn.setd(`${this.fullChannelId}.delay`, t);
}
changeDelay(e) {
this.delay$.pipe(N(1)).subscribe((t) => this.setDelay(t + e));
}
}, Cr = class {
constructor(e, t) {
this.conn = e, this.store = t, this.name$ = pt("MASTER"), this.faderLevel$ = this.store.state$.pipe(L(cn())), this.faderLevelDB$ = this.faderLevel$.pipe(A((e) => q(e))), this.pan$ = this.store.state$.pipe(L(ln())), this.dim$ = this.store.state$.pipe(L(un())), this.delayL$ = this.store.state$.pipe(L(dn("L"))), this.delayR$ = this.store.state$.pipe(L(dn("R"))), this.transitionSources$ = new T(), ir(this.transitionSources$, this.faderLevel$, e).subscribe((e) => this.setFaderLevelRaw(e));
}
input(e) {
return this.store.objectStore.getOrCreate(`masteri${e}`, () => new Sr(this.conn, this.store, "i", e));
}
line(e) {
return this.store.objectStore.getOrCreate(`masterl${e}`, () => new Sr(this.conn, this.store, "l", e));
}
player(e) {
return this.store.objectStore.getOrCreate(`masterp${e}`, () => new $(this.conn, this.store, "p", e));
}
aux(e) {
return this.store.objectStore.getOrCreate(`mastera${e}`, () => new Sr(this.conn, this.store, "a", e));
}
mtx(e) {
return this.aux(e);
}
fx(e) {
return this.store.objectStore.getOrCreate(`masterf${e}`, () => new $(this.conn, this.store, "f", e));
}
sub(e) {
return this.store.objectStore.getOrCreate(`masters${e}`, () => new $(this.conn, this.store, "s", e));
}
vca(e) {
return this.store.objectStore.getOrCreate(`masterv${e}`, () => new $(this.conn, this.store, "v", e));
}
fadeTo(e, t, n = X.Linear, r = 25) {
return e = U(e, 0, 1), this.transitionSources$.next({
targetValue: e,
fadeTime: t,
easing: n,
fps: r
}), or(t);
}
fadeToDB(e, t, n = X.Linear, r = 25) {
let i = K(e);
return this.fadeTo(i, t, n, r);
}
setFaderLevel(e) {
e = U(e, 0, 1), this.setFaderLevelRaw(e);
}
setFaderLevelRaw(e) {
this.conn.setd("m.mix", e);
}
setFaderLevelDB(e) {
this.setFaderLevel(K(e));
}
changeFaderLevel(e) {
this.faderLevel$.pipe(N(1)).subscribe((t) => this.setFaderLevel(W(t + e)));
}
changeFaderLevelDB(e) {
this.faderLevelDB$.pipe(N(1)).subscribe((t) => this.setFaderLevelDB(Math.max(t, -100) + e));
}
setPan(e) {
e = U(e, 0, 1), e = W(e), this.conn.setd("m.pan", e);
}
changePan(e) {
this.pan$.pipe(N(1)).subscribe((t) => this.setPan(t + e));
}
setDim(e) {
this.conn.setdBool("m.dim", e);
}
dim() {
this.setDim(!0);
}
undim() {
this.setDim(!1);
}
toggleDim() {
this.dim$.pipe(N(1)).subscribe((e) => this.setDim(!e));
}
setDelayL(e) {
this.setDelay(e, "L");
}
setDelayR(e) {
this.setDelay(e, "R");
}
changeDelayL(e) {
this.delayL$.pipe(N(1)).subscribe((t) => this.setDelayL(t + e));
}
changeDelayR(e) {
this.delayR$.pipe(N(1)).subscribe((t) => this.setDelayR(t + e));
}
setDelay(e, t) {
let n = Gn(e, 500);
this.conn.setd(`m.delay${t}`, n);
}
}, wr = class {
constructor(e, t) {
this.conn = e, this.store = t, this.state$ = this.store.state$.pipe(R("var.mtk.currentState", In.Stopped)), this.session$ = this.store.state$.pipe(R("var.mtk.session")), this.length$ = this.store.state$.pipe(L(jn())), this.elapsedTime$ = this.store.state$.pipe(L(Nn())), this.remainingTime$ = this.store.state$.pipe(L(Pn())), this.recording$ = this.store.state$.pipe(z("var.mtk.rec.currentState")), this.busy$ = this.store.state$.pipe(z("var.mtk.rec.busy")), this.recordingTime$ = this.store.state$.pipe(R("var.mtk.rec.time", 0), on(this.recording$), A(([e, t]) => t ? e : 0)), this.soundcheck$ = this.store.state$.pipe(z("var.mtk.soundcheck"));
}
play() {
this.conn.sendMessage("MTK_PLAY");
}
pause() {
this.conn.sendMessage("MTK_PAUSE");
}
stop() {
this.conn.sendMessage("MTK_STOP");
}
recordToggle() {
this.conn.sendMessage("MTK_REC_TOGGLE");
}
recordStart() {
this.recording$.pipe(N(1)).subscribe((e) => {
e || this.recordToggle();
});
}
recordStop() {
this.recording$.pipe(N(1)).subscribe((e) => {
e && this.recordToggle();
});
}
setSoundcheck(e) {
this.conn.setdBool("var.mtk.soundcheck", e);
}
activateSoundcheck() {
this.setSoundcheck(!0);
}
deactivateSoundcheck() {
this.setSoundcheck(!1);
}
toggleSoundcheck() {
this.soundcheck$.pipe(N(1)).subscribe((e) => this.setSoundcheck(!e));
}
};
//#endregion
//#region src/lib/utils/bitmask.ts
function Tr(e, t) {
return t < 0 ? e : e ^ 1 << t;
}
function Er(e, t) {
return t < 0 ? e : e & ~(1 << t);
}
function Dr(e, t) {
return t < 0 ? e : e | 1 << t;
}
function Or(e, t) {
return t < 0 ? !1 : !!(e & 1 << t);
}
//#endregion
//#region src/lib/facade/mute-group.ts
function kr(e) {
switch (e) {
case "all": return 23;
case "fx": return 22;
default: return e - 1;
}
}
var Ar = class {
constructor(e, t, n) {
this.conn = e, this.store = t, this.id = n, this.mgMask$ = this.store.state$.pipe(R("mgmask")), this.state$ = this.mgMask$.pipe(A((e) => Or(e, this.groupIndex))), this.groupIndex = kr(n);
}
mute() {
this.mgMask$.pipe(N(1)).subscribe((e) => this.setMgMask(Dr(e, this.groupIndex)));
}
unmute() {
this.mgMask$.pipe(N(1)).subscribe((e) => this.setMgMask(Er(e, this.groupIndex)));
}
toggle() {
this.mgMask$.pipe(N(1)).subscribe((e) => this.setMgMask(Tr(e, this.groupIndex)));
}
setMgMask(e) {
this.conn.setd("mgmask", e);
}
}, jr = {
PLISTS: { keyed: !1 },
PLIST_TRACKS: { keyed: !0 },
SHOWLIST: { keyed: !1 },
SNAPSHOTLIST: { keyed: !0 },
CUELIST: { keyed: !0 }
};
function Mr(e, t, n) {
return new S((r) => {
let i = e.inbound$.pipe(M((e) => e.startsWith(n + "^")), N(1), A((e) => e.split("^").slice(1).filter(Boolean))).subscribe(r);
return e.sendMessage(t), i;
});
}
//#endregion
//#region src/lib/facade/player.ts
var Nr = class {
constructor(e, t) {
this.conn = e, this.store = t, this.state$ = this.store.state$.pipe(R("var.currentState", Fn.Stopped)), this.playlist$ = this.store.state$.pipe(R("var.currentPlaylist")), this.track$ = this.store.state$.pipe(R("var.currentTrack")), this.length$ = this.store.state$.pipe(L(Tn())), this.elapsedTime$ = this.store.state$.pipe(L(kn())), this.remainingTime$ = this.store.state$.pipe(L(An())), this.shuffle$ = this.store.state$.pipe(z("settings.shuffle")), this.playlistsWithTracks$ = this.store.resourceListState$.pipe(A((e) => {
let t = e.PLISTS ?? [];
return Object.fromEntries(t.map((t) => [t, e[`PLIST_TRACKS^${t}`] ?? []]));
})), this.playlists$ = this.store.resourceListState$.pipe(A((e) => e.PLISTS ?? []), Zt((e, t) => e.length === t.length && e.every((e, n) => e === t[n]))), this.conn.status$.pipe(M((e) => e.type === V.Open)).subscribe(() => this.refreshPlaylists());
}
play() {
this.conn.sendMessage("MEDIA_PLAY");
}
pause() {
this.conn.sendMessage("MEDIA_PAUSE");
}
stop() {
this.conn.sendMessage("MEDIA_STOP");
}
next() {
this.conn.sendMessage("MEDIA_NEXT");
}
prev() {
this.conn.sendMessage("MEDIA_PREV");
}
loadPlaylist(e) {
this.conn.sendMessage(`MEDIA_SWITCH_PLIST^${e}`);
}
loadTrack(e, t) {
this.conn.sendMessage(`MEDIA_SWITCH_TRACK^${e}^${t}`);
}
setShuffle(e) {
this.conn.setdBool("settings.shuffle", e);
}
toggleShuffle() {
this.shuffle$.pipe(N(1)).subscribe((e) => this.setShuffle(!e));
}
setPlayMode(e) {
this.conn.setd("settings.playMode", e);
}
setManual() {
this.setPlayMode(0);
}
setAuto() {
this.setPlayMode(3);
}
refreshPlaylists() {
Mr(this.conn, "MEDIA_GET_PLISTS", "PLISTS").subscribe((e) => e.forEach((e) => this.conn.sendMessage(`MEDIA_GET_PLIST_TRACKS^${e}`)));
}
}, Pr = class {
constructor(e, t) {
this.conn = e, this.store = t, this.currentShow$ = this.store.state$.pipe(R("var.currentShow")), this.currentSnapshot$ = this.store.state$.pipe(R("var.currentSnapshot")), this.currentCue$ = this.store.state$.pipe(R("var.currentCue")), this.shows$ = this.store.resourceListState$.pipe(A((e) => {
let t = e.SHOWLIST ?? [];
return Object.fromEntries(t.map((t) => [t, {
snapshots: e[`SNAPSHOTLIST^${t}`] ?? [],
cues: e[`CUELIST^${t}`] ?? []
}]));
})), this.conn.status$.pipe(M((e) => e.type === V.Open)).subscribe(() => this.refreshShows());
}
loadShow(e) {
this.conn.sendMessage(`LOADSHOW^${e}`);
}
loadSnapshot(e, t) {
this.conn.sendMessage(`LOADSNAPSHOT^${e}^${t}`);
}
loadCue(e, t) {
this.conn.sendMessage(`LOADCUE^${e}^${t}`);
}
saveSnapshot(e, t) {
this.conn.sendMessage(`SAVESNAPSHOT^${e}^${t}`);
}
saveCue(e, t) {
this.conn.sendMessage(`SAVECUE^${e}^${t}`);
}
updateCurrentSnapshot() {
j([this.currentShow$, this.currentSnapshot$]).pipe(N(1), M(([e, t]) => !!e && !!t)).subscribe(([e, t]) => this.saveSnapshot(e, t));
}
updateCurrentCue() {
j([this.currentShow$, this.currentCue$]).pipe(N(1), M(([e, t]) => !!e && !!t)).subscribe(([e, t]) => this.saveCue(e, t));
}
refreshShows() {
Mr(this.conn, "SHOWLIST", "SHOWLIST").subscribe((e) => e.forEach((e) => {
this.conn.sendMessage(`SNAPSHOTLIST^${e}`), this.conn.sendMessage(`CUELIST^${e}`);
}));
}
}, Fr = class {
constructor(e, t, n, r) {
this.conn = e, this.store = t, this.busName = n, this.busId = r, this.transitionSources$ = new T(), this.busPath = `settings.${this.busName}${this.busId ? "." + (this.busId - 1) : ""}`, this.faderLevel$ = this.store.state$.pipe(L(wn(this.busName, this.busId ? this.busId - 1 : void 0))), this.faderLevelDB$ = this.faderLevel$.pipe(A((e) => q(e))), this.name$ = pt(Un(this.busName, this.busId || -1)), ir(this.transitionSources$, this.faderLevel$, e).subscribe((e) => this.setFaderLevelRaw(e));
}
fadeTo(e, t, n = X.Linear, r = 25) {
return e = U(e, 0, 1), this.transitionSources$.next({
targetValue: e,
fadeTime: t,
easing: n,
fps: r
}), or(t);
}
fadeToDB(e, t, n = X.Linear, r = 25) {
let i = K(e);
return this.fadeTo(i, t, n, r);
}
setFaderLevel(e) {
e = U(e, 0, 1), this.setFaderLevelRaw(e);
}
setFaderLevelRaw(e) {
this.conn.setd(this.busPath, e);
}
setFaderLevelDB(e) {
this.setFaderLevel(K(e));
}
changeFaderLevel(e) {
this.faderLevel$.pipe(N(1)).subscribe((t) => this.setFaderLevel(W(t + e)));
}
changeFaderLevelDB(e) {
this.faderLevelDB$.pipe(N(1)).subscribe((t) => this.setFaderLevelDB(Math.max(t, -100) + e));
}
}, Ir = {
url: "",
deserializer: function(e) {
return JSON.parse(e.data);
},
serializer: function(e) {
return JSON.stringify(e);
}
}, Lr = "WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }", Rr = function(e) {
t(r, e);
function r(t, r) {
var i = e.call(this) || this;
if (i._socket = null, t instanceof S) i.destination = r, i.source = t;
else {
var a = i._config = n({}, Ir);
if (i._output = new T(), typeof t == "string") a.url = t;
else for (var o in t) t.hasOwnProperty(o) && (a[o] = t[o]);
if (!a.WebSocketCtor && WebSocket) a.WebSocketCtor = WebSocket;
else if (!a.WebSocketCtor) throw Error("no WebSocket constructor can be found");
i.destination = new E();
}
return i;
}
return r.prototype.lift = function(e) {
var t = new r(this._config, this.destination);
return t.operator = e, t.source = this, t;
}, r.prototype._resetState = function() {
this._socket = null, this.source || (this.destination = new E()), this._output = new T();
}, r.prototype.multiplex = function(e, t, n) {
var r = this;
return new S(function(i) {
try {
r.next(e());
} catch (e) {
i.error(e);
}
var a = r.subscribe({
next: function(e) {
try {
n(e) && i.next(e);
} catch (e) {
i.error(e);
}
},
error: function(e) {
return i.error(e);
},
complete: function() {
return i.complete();
}
});
return function() {
try {
r.next(t());
} catch (e) {
i.error(e);
}
a.unsubscribe();
};
});
}, r.prototype._connectSocket = function() {
var e = this, t = this._config, n = t.WebSocketCtor, r = t.protocol, i = t.url, a = t.binaryType, o = this._output, s = null;
try {
s = r ? new n(i, r) : new n(i), this._socket = s, a && (this._socket.binaryType = a);
} catch (e) {
o.error(e);
return;
}
var c = new h(function() {
e._socket = null, s && s.readyState === 1 && s.close();
});
s.onopen = function(t) {
if (!e._socket) {
s.close(), e._resetState();
return;
}
var n = e._config.openObserver;
n && n.next(t);
var r = e.destination;
e.destination = ue.create(function(t) {
if (s.readyState === 1) try {
var n = e._config.serializer;
s.send(n(t));
} catch (t) {
e.destination.error(t);
}
}, function(t) {
var n = e._config.closingObserver;
n && n.next(void 0), t && t.code ? s.close(t.code, t.reason) : o.error(TypeError(Lr)), e._resetState();
}, function() {
var t = e._config.closingObserver;
t && t.next(void 0), s.close(), e._resetState();
}), r && r instanceof E && c.add(r.subscribe(e.destination));
}, s.onerror = function(t) {
e._resetState(), o.error(t);
}, s.onclose = function(t) {
s === e._socket && e._resetState();
var n = e._config.closeObserver;
n && n.next(t), t.wasClean ? o.complete() : o.error(t);
}, s.onmessage = function(t) {
try {
var n = e._config.deserializer;
o.next(n(t));
} catch (e) {
o.error(e);
}
};
}, r.prototype._subscribe = function(e) {
var t = this, n = this.source;
return n ? n.subscribe(e) : (this._socket || this._connectSocket(), this._output.subscribe(e), e.add(function() {
var e = t._socket;
t._output.observers.length === 0 && (e && (e.readyState === 1 || e.readyState === 0) && e.close(), t._resetState());
}), e);
}, r.prototype.unsubscribe = function() {
var t = this._socket;
t && (t.readyState === 1 || t.readyState === 0) && t.close(), this._resetState(), e.prototype.unsubscribe.call(this);
}, r;
}(De);
//#endregion
//#region ../../node_modules/rxjs/dist/esm5/internal/observable/dom/webSocket.js
function zr(e) {
return new Rr(e);
}
//#endregion
//#region src/lib/mixer-connection.ts
var Br = class {
get status() {
return this._status;
}
constructor(e) {
this.reconnectTime = 2e3, this.keepaliveTime = 1e3, this.forceClose$ = new T(), this.statusSubject$ = new T(), this.outboundSubject$ = new T(), this.inboundSubject$ = new T(), this._status = V.Close, this.status$ = this.statusSubject$.asObservable(), this.outbound$ = this.outboundSubject$.asObservable(), this.inbound$ = this.inboundSubject$.asObservable(), this.allMessages$ = Bt(this.outbound$, this.inbound$), this.statusSubject$.subscribe((e) => {
this._status = e.type;
}), this.socket$ = zr({
url: `ws://${e.targetIP}`,
WebSocketCtor: e.webSocketCtor || WebSocket,
serializer: (e) => `3:::${e}`,
deserializer: ({ data: e }) => e,
openObserver: { next: () => this.statusSubject$.next({ type: V.Open }) },
closingObserver: { next: () => this.statusSubject$.next({ type: V.Closing }) },
closeObserver: { next: () => this.statusSubject$.next({ type: V.Close }) }
});
let t = this.status$.pipe(M((e) => e.type === V.Open)), n = this.status$.pipe(M((e) => e.type === V.Close));
t.pipe(P(() => zt(this.keepaliveTime).pipe(rn(n))), A(() => "ALIVE")).subscribe((e) => this.outboundSubject$.next(e)), this.outbound$.subscribe(this.socket$);
}
waitForOpenStatus() {
return ht(this.status$.pipe(M((e) => e.type === V.Open), A(() => {})));
}
connect() {
if (this.socketSubscription && !this.socketSubscription.closed) return this._status === V.Open ? Promise.resolve() : this.waitForOpenStatus();
this.statusSubject$.next({ type: V.Opening });
let e = this.socket$.pipe(an({ error: (e) => this.statusSubject$.next({
type: V.Error,
payload: e
}) }), $t({ delay: () => Rt(this.reconnectTime).pipe(rn(this.forceClose$), an(() => this.statusSubject$.next({ type: V.Reconnecting }))) }), M((e) => e.startsWith("3:::")), A((e) => e.slice(4)));
return this.socketSubscription = e.subscribe((e) => {
if (e.includes("\n")) for (let t of e.split("\n")) this.inboundSubject$.next(t);
else this.inboundSubject$.next(e);
}), this.waitForOpenStatus();
}
disconnect() {
return this.socket$.complete(), this.forceClose$.next(), ht(this.status$.pipe(M((e) => e.type === V.Close), A(() => {})));
}
reconnect() {
return this.status$.pipe(M((e) => e.type === V.Close), N(1), Xt(1e3)).subscribe(() => this.connect()), this.disconnect(), this.waitForOpenStatus();
}
sendMessage(e) {
this.outboundSubject$.next(e);
}
setd(e, t) {
this.sendMessage(`SETD^${e}^${t}`);
}
setdBool(e, t) {
this.sendMessage(`SETD^${e}^${Number(t)}`);
}
sets(e, t) {
this.sendMessage(`SETS^${e}^${t}`);
}
}, Vr = class {
constructor() {
this.store = /* @__PURE__ */ new Map();
}
get(e) {
return this.store.get(e);
}
set(e, t) {
this.store.set(e, t);
}
getOrCreate(e, t) {
let n = this.store.get(e);
if (n) return n;
let r = t();
return this.store.set(e, r), r;
}
}, Hr = class {
constructor(e) {
this.conn = e, this.messages$ = this.conn.allMessages$.pipe(M((e) => e.startsWith("SETD^") || e.startsWith("SETS^")), tn()), this.state$ = It(this.messages$.pipe(en((e, t) => {
let n = t.indexOf("^", 5), r = t.slice(0, 4), i = t.slice(5, n), a = t.slice(n + 1);
return e[i] = r === "SETD" ? Number(a) : a, e;
}, {})), { connector: () => new E(1) }), this.syncState$ = It(this.conn.allMessages$.pipe(M((e) => e.startsWith("BMSG^SYNC^")), A((e) => e.slice(10).split("^")), en((e, [t, n]) => ({
...e,
[t]: parseInt(n, 10)
}), {})), { connector: () => new E(1) }), this.resourceListState$ = It(this.conn.inbound$.pipe(M((e) => {
let t = e.indexOf("^");
return (t === -1 ? e : e.slice(0, t)) in jr;
}), A((e) => e.split("^")), en((e, t) => {
let n = jr[t[0]].keyed ? 2 : 1, r = t.slice(0, n).join("^");
return {
...e,
[r]: t.slice(n).filter(Boolean)
};
}, {})), { connector: () => new E(1) }), this.objectStore = new Vr(), this.state$.connect(), this.syncState$.connect(), this.resourceListState$.connect();
}
};
//#endregion
//#region src/lib/vu/vu.utils.ts
function Ur(e) {
return Qn(e, -80, 0);
}
function Wr(e) {
let t = atob(e), n = t.length, r = new Uint8Array(n);
for (let e = 0; e < n; e++) r[e] = t.charCodeAt(e);
return r;
}
function Gr(e) {
let t = [
{
key: "input",
amount: e[0],
blockSize: 6
},
{
key: "player",
amount: e[1],
blockSize: 6
},
{
key: "sub",
amount: e[2],
blockSize: 7
},
{
key: "fx",
amount: e[3],
blockSize: 7
},
{
key: "aux",
amount: e[4],
blockSize: 5
},
{
key: "master",
amount: e[5],
blockSize: 5
},
{
key: "line",
amount: e[6],
blockSize: 6
}
], n = {
input: [],
player: [],
sub: [],
fx: [],
aux: [],
master: [],
line: []
}, r = .004167508166392142, i = 8;
return t.forEach((t) => {
for (let a = 0; a < (t.amount || 0); a++) {
switch (t.key) {
case "input":
case "player":
case "line":
n[t.key].push({
vuPre: e[i + 0] * r,
vuPost: e[i + 1] * r,
vuPostFader: e[i + 2] * r
});
break;
case "aux":
n[t.key].push({
vuPost: e[i + 0] * r,
vuPostFader: e[i + 1] * r
});
break;
case "fx":
case "sub":
n[t.key].push({
vuPostL: e[i + 0] * r,
vuPostR: e[i + 1] * r,
vuPostFaderL: e[i + 2] * r,
vuPostFaderR: e[i + 3] * r
});
break;
case "master":
n[t.key].push({
vuPost: e[i + 0] * r,
vuPostFader: e[i + 1] * r
});
break;
}
i += t.blockSize;
}
}), n;
}
//#endregion
//#region src/lib/vu/vu-processor.ts
var Kr = class {
constructor(e) {
this.conn = e, this.vuData$ = this.conn.inbound$.pipe(M((e) => e.startsWith("VU2^")), A((e) => e.slice(4)), A((e) => Gr(Wr(e))), tn());
}
input(e) {
return this.vuData$.pipe(A((t) => t.input[e - 1]));
}
line(e) {
return this.vuData$.pipe(A((t) => t.line[e - 1]));
}
player(e) {
return this.vuData$.pipe(A((t) => t.player[e - 1]));
}
aux(e) {
return this.vuData$.pipe(A((t) => t.aux[e - 1]));
}
fx(e) {
return this.vuData$.pipe(A((t) => t.fx[e - 1]));
}
sub(e) {
return this.vuData$.pipe(A((t) => t.sub[e - 1]));
}
master() {
return this.vuData$.pipe(A((e) => {
if (e.master.length < 2) throw Error("Master VU data has less than 2 channels.");
return {
vuPostL: e.master[0].vuPost,
vuPostR: e.master[1].vuPost,
vuPostFaderL: e.master[0].vuPostFader,
vuPostFaderR: e.master[1].vuPostFader
};
}));
}
}, qr = {
ui24: {
0: ["i", 1],
1: ["i", 2],
2: ["i", 3],
3: ["i", 4],
4: ["i", 5],
5: ["i", 6],
6: ["i", 7],
7: ["i", 8],
8: ["i", 9],
9: ["i", 10],
10: ["i", 11],
11: ["i", 12],
12: ["i", 13],
13: ["i", 14],
14: ["i", 15],
15: ["i", 16],
16: ["i", 17],
17: ["i", 18],
18: ["i", 19],
19: ["i", 20],
20: ["i", 21],
21: ["i", 22],
22: ["i", 23],
23: ["i", 24],
24: ["l", 1],
25: ["l", 2],
26: ["p", 1],
27: ["p", 2],
28: ["f", 1],
29: ["f", 2],
30: ["f", 3],
31: ["f", 4],
32: ["s", 1],
33: ["s", 2],
34: ["s", 3],
35: ["s", 4],
36: ["s", 5],
37: ["s", 6],
38: ["a", 1],
39: ["a", 2],
40: ["a", 3],
41: ["a", 4],
42: ["a", 5],
43: ["a", 6],
44: ["a", 7],
45: ["a", 8],
46: ["a", 9],
47: ["a", 10],
48: ["v", 1],
49: ["v", 2],
50: ["v", 3],
51: ["v", 4],
52: ["v", 5],
53: ["v", 6]
},
ui16: {
0: ["i", 1],
1: ["i", 2],
2: ["i", 3],
3: ["i", 4],
4: ["i", 5],
5: ["i", 6],
6: ["i", 7],
7: ["i", 8],
8: ["i", 9],
9: ["i", 10],
10: ["i", 11],
11: ["i", 12],
12: ["l", 1],
13: ["l", 2],
14: ["p", 1],
15: ["p", 2],
16: ["f", 1],
17: ["f", 2],
18: ["f", 3],
19: ["f", 4],
20: ["s", 1],
21: ["s", 2],
22: ["s", 3],
23: ["s", 4],
24: ["a", 1],
25: ["a", 2],
26: ["a", 3],
27: ["a", 4],
28: ["a", 5],
29: ["a", 6]
},
ui12: {
0: ["i", 1],
1: ["i", 2],
2: ["i", 3],
3: ["i", 4],
4: ["i", 5],
5: ["i", 6],
6: ["i", 7],
7: ["i", 8],
8: ["l", 1],
9: ["l", 2],
10: ["p", 1],
11: ["p", 2],
12: ["f", 1],
13: ["f", 2],
14: ["f", 3],
15: ["f", 4],
16: ["s", 1],
17: ["s", 2],
18: ["s", 3],
19: ["s", 4],
20: ["a", 1],
21: ["a", 2],
22: ["a", 3],
23: ["a", 4]
}
};
function Jr(e) {
return qr[e];
}
function Yr(e, t, n) {
let r = Jr(t);
if (n === -1) return e.master;
if (r[n] !== void 0) {
let [t, i] = r[n];
switch (t) {
case "i": return e.master.input(i);
case "l": return e.master.line(i);
case "p": return e.master.player(i);
case "f": return e.master.fx(i);
case "s": return e.master.sub(i);
case "a": return e.master.aux(i);
case "v": return e.master.vca(i);
}
}
return null;
}
function Xr(e, t, n) {
if (t !== "master" && n === void 0) throw Error("Channel number is required");
let r = qr[e];
if (t === "master") return -1;
for (let [e, [i, a]] of Object.entries(r)) if (i === t && a === n) return +e;
return null;
}
//#endregion
//#region src/lib/facade/channel-sync.ts
var Zr = class {
constructor(e) {
this.sui = e, this.defaultSyncId = "SYNC_ID";
}
getSelectedChannelIndex(e) {
let t = e || this.defaultSyncId;
return this.sui.store.syncState$.pipe(A((e) => e[t]), M((e) => e !== void 0));
}
getSelectedChannel(e) {
return this.getSelectedChannelIndex(e).pipe(on(this.sui.deviceInfo.model$), A(([e, t]) => Yr(this.sui, t, e)));
}
selectChannelIndex(e, t) {
let n = `BMSG^SYNC^${t || this.defaultSyncId}^${e}`;
this.sui.conn.sendMessage(n);
}
selectChannel(e, t, n) {
let r = this.sui.deviceInfo.model;
if (r) {
if (e === "master" && typeof t != "number" && n === void 0) {
let e = Xr(r, "master");
if (e !== null) {
this.selectChannelIndex(e, t);
return;
}
}
if (e !== "master" && typeof t == "number") {
let i = Xr(r, e, t);
if (i !== null) {
this.selectChannelIndex(i, n);
return;
}
}
throw Error("Invalid arguments or channel not found");
}
}
}, Qr = class {
get options() {
return Object.freeze({ ...this._options });
}
constructor(e) {
typeof e == "string" ? this._options = { targetIP: e } : this._options = e, this.conn = new Br(this._options), this.store = new Hr(this.conn), this.deviceInfo = new vr(this.store), this.status$ = this.conn.status$, this.vuProcessor = new Kr(this.conn), this.master = new Cr(this.conn, this.store), this.player = new Nr(this.conn, this.store), this.recorderDualTrack = new yr(this.conn, this.store), this.recorderMultiTrack = new wr(this.conn, this.store), this.volume = {
solo: new Fr(this.conn, this.store, "solovol"),
headphone: (e) => this.store.objectStore.getOrCreate(`volume-hpvol${e}`, () => new Fr(this.conn, this.store, "hpvol", e))
}, this.shows = new Pr(this.conn, this.store), this.automix = new er(this.conn, this.store), this.channelSync = new Zr(this);
}
aux(e) {
return this.store.objectStore.getOrCreate(pr(e), () => new gr(this.conn, this.store, e));
}
mtx(e) {
return this.store.objectStore.getOrCreate(mr(e), () => new hr(this.conn, this.store, e));
}
fx(e) {
return this.store.objectStore.getOrCreate(`fxbus${e}`, () => new br(this.conn, this.store, e));
}
muteGroup(e) {
return this.store.objectStore.getOrCreate(`mutegroup${e}`, () => new Ar(this.conn, this.store, e));
}
clearMuteGroups() {
this.conn.setd("mgmask", 0);
}
hw(e) {
return this.store.objectStore.getOrCreate(`hw${e}`, () => new xr(this.conn, this.store, this.deviceInfo, e));
}
async connect() {
await this.conn.connect(), await Wn(this.store);
}
disconnect() {
return this.conn.disconnect();
}
async reconnect() {
await this.conn.reconnect(), await Wn(this.store);
}
};
//#endregion
//#region src/lib/type-guards.ts
function $r(e) {
return e instanceof sr;
}
function ei(e) {
return e instanceof $;
}
function ti(e) {
return e instanceof Sr;
}
function ni(e) {
return e instanceof Cr;
}
//#endregion
export { er as AutomixController, $n as AutomixGroup, gr as AuxBus, Z as AuxChannel, sr as Channel, Zr as ChannelSync, V as ConnectionStatus, K as DBToFaderValue, _r as DEVICE_CAPABILITIES, Sr as DelayableMasterChannel, vr as DeviceInfo, yr as DualTrackRecorder, X as Easings, br as FxBus, Q as FxChannel, H as FxType, xr as HwChannel, Cr as MasterBus, $ as MasterChannel, In as MtkState, hr as MtxBus, dr as MtxBusChannel, ur as MtxChannel, fr as MtxMasterChannel, wr as MultiTrackRecorder, Ar as MuteGroup, Nr as Player, Fn as PlayerState, cr as SendChannel, Pr as ShowController, Qr as SoundcraftUI, Fr as VolumeBus, Kr as VuProcessor, U as clamp, q as faderValueToDB, zn as fxTypeToString, Vn as getDefaultChannelName, Hn as getDefaultMatrixName, Un as getDefaultVolumeBusName, G as getLinkedChannelNumber, $r as isChannel, ti as isDelayableMasterChannel, ni as isMaster, ei as isMasterChannel, Ln as playerTimeToString, W as roundToThreeDecimals, Bn as sanitizeChannelName, Ur as vuValueToDB, Wn as waitForInitParams };