UNPKG

soundcraft-ui-connection

Version:

Library for controlling the Soundcraft Ui series audio mixers

5 lines 72.7 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const tn=require("modern-isomorphic-ws");var ge=function(n,e){return ge=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])},ge(n,e)};function O(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ge(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var $e=function(){return $e=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},$e.apply(this,arguments)};function nn(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function c(h){try{u(r.next(h))}catch(l){o(l)}}function a(h){try{u(r.throw(h))}catch(l){o(l)}}function u(h){h.done?i(h.value):s(h.value).then(c,a)}u((r=r.apply(n,e||[])).next())})}function ot(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(u){return function(h){return a([u,h])}}function a(u){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(t=0)),t;)try{if(r=1,s&&(i=u[0]&2?s.return:u[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,u[1])).done)return i;switch(s=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,s=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){t.label=u[1];break}if(u[0]===6&&t.label<i[1]){t.label=i[1],i=u;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(u);break}i[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(n,t)}catch(h){u=[6,h],s=0}finally{r=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function G(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function R(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i}function j(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return n.concat(i||Array.prototype.slice.call(e))}function U(n){return this instanceof U?(this.v=n,this):new U(n)}function rn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(f){return function(y){return Promise.resolve(y).then(f,l)}}function c(f,y){r[f]&&(s[f]=function(d){return new Promise(function(T,D){i.push([f,d,T,D])>1||a(f,d)})},y&&(s[f]=y(s[f])))}function a(f,y){try{u(r[f](y))}catch(d){v(i[0][3],d)}}function u(f){f.value instanceof U?Promise.resolve(f.value.v).then(h,l):v(i[0][2],f)}function h(f){a("next",f)}function l(f){a("throw",f)}function v(f,y){f(y),i.shift(),i.length&&a(i[0][0],i[0][1])}}function sn(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof G=="function"?G(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=n[i]&&function(o){return new Promise(function(c,a){o=n[i](o),s(c,a,o.done,o.value)})}}function s(i,o,c,a){Promise.resolve(a).then(function(u){i({value:u,done:c})},o)}}function S(n){return typeof n=="function"}function Ee(n){var e=function(r){Error.call(r),r.stack=new Error().stack},t=n(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var be=Ee(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
`+t.map(function(r,s){return s+1+") "+r.toString()}).join(`
  `):"",this.name="UnsubscriptionError",this.errors=t}});function ae(n,e){if(n){var t=n.indexOf(e);0<=t&&n.splice(t,1)}}var z=(function(){function n(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var e,t,r,s,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=G(o),a=c.next();!a.done;a=c.next()){var u=a.value;u.remove(this)}}catch(d){e={error:d}}finally{try{a&&!a.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else o.remove(this);var h=this.initialTeardown;if(S(h))try{h()}catch(d){i=d instanceof be?d.errors:[d]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var v=G(l),f=v.next();!f.done;f=v.next()){var y=f.value;try{Ye(y)}catch(d){i=i??[],d instanceof be?i=j(j([],R(i)),R(d.errors)):i.push(d)}}}catch(d){r={error:d}}finally{try{f&&!f.done&&(s=v.return)&&s.call(v)}finally{if(r)throw r.error}}}if(i)throw new be(i)}},n.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)Ye(e);else{if(e instanceof n){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},n.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},n.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},n.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&ae(t,e)},n.prototype.remove=function(e){var t=this._finalizers;t&&ae(t,e),e instanceof n&&e._removeParent(this)},n.EMPTY=(function(){var e=new n;return e.closed=!0,e})(),n})(),at=z.EMPTY;function ct(n){return n instanceof z||n&&"closed"in n&&S(n.remove)&&S(n.add)&&S(n.unsubscribe)}function Ye(n){S(n)?n():n.unsubscribe()}var on={Promise:void 0},an={setTimeout:function(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];return setTimeout.apply(void 0,j([n,e],R(t)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function ut(n){an.setTimeout(function(){throw n})}function ce(){}function ie(n){n()}var he=(function(n){O(e,n);function e(t){var r=n.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ct(t)&&t.add(r)):r.destination=hn,r}return e.create=function(t,r,s){return new V(t,r,s)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e})(z),cn=(function(){function n(e){this.partialObserver=e}return n.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(r){se(r)}},n.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(r){se(r)}else se(e)},n.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){se(t)}},n})(),V=(function(n){O(e,n);function e(t,r,s){var i=n.call(this)||this,o;return S(t)||!t?o={next:t??void 0,error:r??void 0,complete:s??void 0}:o=t,i.destination=new cn(o),i}return e})(he);function se(n){ut(n)}function un(n){throw n}var hn={closed:!0,next:ce,error:un,complete:ce},_e=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function F(n){return n}function ln(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return ht(n)}function ht(n){return n.length===0?F:n.length===1?n[0]:function(t){return n.reduce(function(r,s){return s(r)},t)}}var w=(function(){function n(e){e&&(this._subscribe=e)}return n.prototype.lift=function(e){var t=new n;return t.source=this,t.operator=e,t},n.prototype.subscribe=function(e,t,r){var s=this,i=pn(e)?e:new V(e,t,r);return ie(function(){var o=s,c=o.operator,a=o.source;i.add(c?c.call(i,a):a?s._subscribe(i):s._trySubscribe(i))}),i},n.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},n.prototype.forEach=function(e,t){var r=this;return t=He(t),new t(function(s,i){var o=new V({next:function(c){try{e(c)}catch(a){i(a),o.unsubscribe()}},error:i,complete:s});r.subscribe(o)})},n.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},n.prototype[_e]=function(){return this},n.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ht(e)(this)},n.prototype.toPromise=function(e){var t=this;return e=He(e),new e(function(r,s){var i;t.subscribe(function(o){return i=o},function(o){return s(o)},function(){return r(i)})})},n.create=function(e){return new n(e)},n})();function He(n){var e;return(e=n??on.Promise)!==null&&e!==void 0?e:Promise}function fn(n){return n&&S(n.next)&&S(n.error)&&S(n.complete)}function pn(n){return n&&n instanceof he||fn(n)&&ct(n)}function dn(n){return S(n?.lift)}function _(n){return function(e){if(dn(e))return e.lift(function(t){try{return n(t,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function x(n,e,t,r,s){return new vn(n,e,t,r,s)}var vn=(function(n){O(e,n);function e(t,r,s,i,o,c){var a=n.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=c,a._next=r?function(u){try{r(u)}catch(h){t.error(h)}}:n.prototype._next,a._error=i?function(u){try{i(u)}catch(h){t.error(h)}finally{this.unsubscribe()}}:n.prototype._error,a._complete=s?function(){try{s()}catch(u){t.error(u)}finally{this.unsubscribe()}}:n.prototype._complete,a}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e})(he),mn=Ee(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),P=(function(n){O(e,n);function e(){var t=n.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var r=new Se(this,this);return r.operator=t,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new mn},e.prototype.next=function(t){var r=this;ie(function(){var s,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=G(r.currentObservers),c=o.next();!c.done;c=o.next()){var a=c.value;a.next(t)}}catch(u){s={error:u}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(s)throw s.error}}}})},e.prototype.error=function(t){var r=this;ie(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=t;for(var s=r.observers;s.length;)s.shift().error(t)}})},e.prototype.complete=function(){var t=this;ie(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var r=t.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var r=this,s=this,i=s.hasError,o=s.isStopped,c=s.observers;return i||o?at:(this.currentObservers=null,c.push(t),new z(function(){r.currentObservers=null,ae(c,t)}))},e.prototype._checkFinalizedStatuses=function(t){var r=this,s=r.hasError,i=r.thrownError,o=r.isStopped;s?t.error(i):o&&t.complete()},e.prototype.asObservable=function(){var t=new w;return t.source=this,t},e.create=function(t,r){return new Se(t,r)},e})(w),Se=(function(n){O(e,n);function e(t,r){var s=n.call(this)||this;return s.destination=t,s.source=r,s}return e.prototype.next=function(t){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,t)},e.prototype.error=function(t){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,t)},e.prototype.complete=function(){var t,r;(r=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||r===void 0||r.call(t)},e.prototype._subscribe=function(t){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(t))!==null&&s!==void 0?s:at},e})(P),Pe={now:function(){return(Pe.delegate||Date).now()},delegate:void 0},J=(function(n){O(e,n);function e(t,r,s){t===void 0&&(t=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Pe);var i=n.call(this)||this;return i._bufferSize=t,i._windowTime=r,i._timestampProvider=s,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,r),i}return e.prototype.next=function(t){var r=this,s=r.isStopped,i=r._buffer,o=r._infiniteTimeWindow,c=r._timestampProvider,a=r._windowTime;s||(i.push(t),!o&&i.push(c.now()+a)),this._trimBuffer(),n.prototype.next.call(this,t)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(t),s=this,i=s._infiniteTimeWindow,o=s._buffer,c=o.slice(),a=0;a<c.length&&!t.closed;a+=i?1:2)t.next(c[a]);return this._checkFinalizedStatuses(t),r},e.prototype._trimBuffer=function(){var t=this,r=t._bufferSize,s=t._timestampProvider,i=t._buffer,o=t._infiniteTimeWindow,c=(o?1:2)*r;if(r<1/0&&c<i.length&&i.splice(0,i.length-c),!o){for(var a=s.now(),u=0,h=1;h<i.length&&i[h]<=a;h+=2)u=h;u&&i.splice(0,u+1)}},e})(P),bn=(function(n){O(e,n);function e(t,r){return n.call(this)||this}return e.prototype.schedule=function(t,r){return this},e})(z),Ke={setInterval:function(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];return setInterval.apply(void 0,j([n,e],R(t)))},clearInterval:function(n){return clearInterval(n)},delegate:void 0},yn=(function(n){O(e,n);function e(t,r){var s=n.call(this,t,r)||this;return s.scheduler=t,s.work=r,s.pending=!1,s}return e.prototype.schedule=function(t,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=t;var i=this.id,o=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(o,i,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(o,this.id,r),this},e.prototype.requestAsyncId=function(t,r,s){return s===void 0&&(s=0),Ke.setInterval(t.flush.bind(t,this),s)},e.prototype.recycleAsyncId=function(t,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&Ke.clearInterval(r)},e.prototype.execute=function(t,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(t,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,r){var s=!1,i;try{this.work(t)}catch(o){s=!0,i=o||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),i},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,r=t.id,s=t.scheduler,i=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,ae(i,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},e})(bn),qe=(function(){function n(e,t){t===void 0&&(t=n.now),this.schedulerActionCtor=e,this.now=t}return n.prototype.schedule=function(e,t,r){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},n.now=Pe.now,n})(),gn=(function(n){O(e,n);function e(t,r){r===void 0&&(r=qe.now);var s=n.call(this,t,r)||this;return s.actions=[],s._active=!1,s}return e.prototype.flush=function(t){var r=this.actions;if(this._active){r.push(t);return}var s;this._active=!0;do if(s=t.execute(t.state,t.delay))break;while(t=r.shift());if(this._active=!1,s){for(;t=r.shift();)t.unsubscribe();throw s}},e})(qe),le=new gn(yn),$n=le,lt=new w(function(n){return n.complete()});function ft(n){return n&&S(n.schedule)}function De(n){return n[n.length-1]}function pt(n){return S(De(n))?n.pop():void 0}function Le(n){return ft(De(n))?n.pop():void 0}function Sn(n,e){return typeof De(n)=="number"?n.pop():e}var dt=(function(n){return n&&typeof n.length=="number"&&typeof n!="function"});function vt(n){return S(n?.then)}function mt(n){return S(n[_e])}function bt(n){return Symbol.asyncIterator&&S(n?.[Symbol.asyncIterator])}function yt(n){return new TypeError("You provided "+(n!==null&&typeof n=="object"?"an invalid object":"'"+n+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function wn(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var gt=wn();function $t(n){return S(n?.[gt])}function St(n){return rn(this,arguments,function(){var t,r,s,i;return ot(this,function(o){switch(o.label){case 0:t=n.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,U(t.read())];case 3:return r=o.sent(),s=r.value,i=r.done,i?[4,U(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,U(s)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function wt(n){return S(n?.getReader)}function C(n){if(n instanceof w)return n;if(n!=null){if(mt(n))return xn(n);if(dt(n))return In(n);if(vt(n))return Tn(n);if(bt(n))return xt(n);if($t(n))return kn(n);if(wt(n))return Cn(n)}throw yt(n)}function xn(n){return new w(function(e){var t=n[_e]();if(S(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function In(n){return new w(function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()})}function Tn(n){return new w(function(e){n.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,ut)})}function kn(n){return new w(function(e){var t,r;try{for(var s=G(n),i=s.next();!i.done;i=s.next()){var o=i.value;if(e.next(o),e.closed)return}}catch(c){t={error:c}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}e.complete()})}function xt(n){return new w(function(e){Mn(n,e).catch(function(t){return e.error(t)})})}function Cn(n){return xt(St(n))}function Mn(n,e){var t,r,s,i;return nn(this,void 0,void 0,function(){var o,c;return ot(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),t=sn(n),a.label=1;case 1:return[4,t.next()];case 2:if(r=a.sent(),!!r.done)return[3,4];if(o=r.value,e.next(o),e.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=a.sent(),s={error:c},[3,11];case 6:return a.trys.push([6,,9,10]),r&&!r.done&&(i=t.return)?[4,i.call(t)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function A(n,e,t,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var i=e.schedule(function(){t(),s?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(i),!s)return i}function It(n,e){return e===void 0&&(e=0),_(function(t,r){t.subscribe(x(r,function(s){return A(r,n,function(){return r.next(s)},e)},function(){return A(r,n,function(){return r.complete()},e)},function(s){return A(r,n,function(){return r.error(s)},e)}))})}function Tt(n,e){return e===void 0&&(e=0),_(function(t,r){r.add(n.schedule(function(){return t.subscribe(r)},e))})}function En(n,e){return C(n).pipe(Tt(e),It(e))}function _n(n,e){return C(n).pipe(Tt(e),It(e))}function Pn(n,e){return new w(function(t){var r=0;return e.schedule(function(){r===n.length?t.complete():(t.next(n[r++]),t.closed||this.schedule())})})}function Dn(n,e){return new w(function(t){var r;return A(t,e,function(){r=n[gt](),A(t,e,function(){var s,i,o;try{s=r.next(),i=s.value,o=s.done}catch(c){t.error(c);return}o?t.complete():t.next(i)},0,!0)}),function(){return S(r?.return)&&r.return()}})}function kt(n,e){if(!n)throw new Error("Iterable cannot be null");return new w(function(t){A(t,e,function(){var r=n[Symbol.asyncIterator]();A(t,e,function(){r.next().then(function(s){s.done?t.complete():t.next(s.value)})},0,!0)})})}function Ln(n,e){return kt(St(n),e)}function On(n,e){if(n!=null){if(mt(n))return En(n,e);if(dt(n))return Pn(n,e);if(vt(n))return _n(n,e);if(bt(n))return kt(n,e);if($t(n))return Dn(n,e);if(wt(n))return Ln(n,e)}throw yt(n)}function fe(n,e){return e?On(n,e):C(n)}function Ct(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=Le(n);return fe(n,t)}var An=Ee(function(n){return function(){n(this),this.name="EmptyError",this.message="no elements in sequence"}});function oe(n,e){return new Promise(function(t,r){var s=new V({next:function(i){t(i),s.unsubscribe()},error:r,complete:function(){r(new An)}});n.subscribe(s)})}function Rn(n){return n instanceof Date&&!isNaN(n)}function p(n,e){return _(function(t,r){var s=0;t.subscribe(x(r,function(i){r.next(n.call(e,i,s++))}))})}var jn=Array.isArray;function Fn(n,e){return jn(e)?n.apply(void 0,j([],R(e))):n(e)}function Bn(n){return p(function(e){return Fn(n,e)})}var Nn=Array.isArray,Wn=Object.getPrototypeOf,Un=Object.prototype,Gn=Object.keys;function Vn(n){if(n.length===1){var e=n[0];if(Nn(e))return{args:e,keys:null};if(zn(e)){var t=Gn(e);return{args:t.map(function(r){return e[r]}),keys:t}}}return{args:n,keys:null}}function zn(n){return n&&typeof n=="object"&&Wn(n)===Un}function Yn(n,e){return n.reduce(function(t,r,s){return t[r]=e[s],t},{})}function we(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=Le(n),r=pt(n),s=Vn(n),i=s.args,o=s.keys;if(i.length===0)return fe([],t);var c=new w(Hn(i,t,o?function(a){return Yn(o,a)}:F));return r?c.pipe(Bn(r)):c}function Hn(n,e,t){return t===void 0&&(t=F),function(r){Je(e,function(){for(var s=n.length,i=new Array(s),o=s,c=s,a=function(h){Je(e,function(){var l=fe(n[h],e),v=!1;l.subscribe(x(r,function(f){i[h]=f,v||(v=!0,c--),c||r.next(t(i.slice()))},function(){--o||r.complete()}))},r)},u=0;u<s;u++)a(u)},r)}}function Je(n,e,t){n?A(t,n,e):e()}function Kn(n,e,t,r,s,i,o,c){var a=[],u=0,h=0,l=!1,v=function(){l&&!a.length&&!u&&e.complete()},f=function(d){return u<r?y(d):a.push(d)},y=function(d){u++;var T=!1;C(t(d,h++)).subscribe(x(e,function(D){e.next(D)},function(){T=!0},void 0,function(){if(T)try{u--;for(var D=function(){var Y=a.shift();o||y(Y)};a.length&&u<r;)D();v()}catch(Y){e.error(Y)}}))};return n.subscribe(x(e,f,function(){l=!0,v()})),function(){}}function pe(n,e,t){return t===void 0&&(t=1/0),S(e)?pe(function(r,s){return p(function(i,o){return e(r,i,s,o)})(C(n(r,s)))},t):(typeof e=="number"&&(t=e),_(function(r,s){return Kn(r,s,n,t)}))}function qn(n){return n===void 0&&(n=1/0),pe(F,n)}function Jn(n){return new w(function(e){C(n()).subscribe(e)})}var Xn={connector:function(){return new P},resetOnDisconnect:!0};function Xe(n,e){e===void 0&&(e=Xn);var t=null,r=e.connector,s=e.resetOnDisconnect,i=s===void 0?!0:s,o=r(),c=new w(function(a){return o.subscribe(a)});return c.connect=function(){return(!t||t.closed)&&(t=Jn(function(){return n}).subscribe(o),i&&t.add(function(){return o=r()})),t},c}function te(n,e,t){n===void 0&&(n=0),t===void 0&&(t=$n);var r=-1;return e!=null&&(ft(e)?t=e:r=e),new w(function(s){var i=Rn(n)?+n-t.now():n;i<0&&(i=0);var o=0;return t.schedule(function(){s.closed||(s.next(o++),0<=r?this.schedule(void 0,r):s.complete())},i)})}function Mt(n,e){return n===void 0&&(n=0),e===void 0&&(e=le),n<0&&(n=0),te(n,n,e)}function Zn(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=Le(n),r=Sn(n,1/0),s=n;return s.length?s.length===1?C(s[0]):qn(r)(fe(s,t)):lt}var Qn=Array.isArray;function er(n){return n.length===1&&Qn(n[0])?n[0]:n}function M(n,e){return _(function(t,r){var s=0;t.subscribe(x(r,function(i){return n.call(e,i,s++)&&r.next(i)}))})}function tr(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n=er(n),n.length===1?C(n[0]):new w(nr(n))}function nr(n){return function(e){for(var t=[],r=function(i){t.push(C(n[i]).subscribe(x(e,function(o){if(t){for(var c=0;c<t.length;c++)c!==i&&t[c].unsubscribe();t=null}e.next(o)})))},s=0;t&&!e.closed&&s<n.length;s++)r(s)}}function rr(n,e,t,r,s){return function(i,o){var c=t,a=e,u=0;i.subscribe(x(o,function(h){var l=u++;a=c?n(a,h,l):(c=!0,h),o.next(a)},s))}}function sr(n,e){return e===void 0&&(e=le),_(function(t,r){var s=null,i=null,o=null,c=function(){if(s){s.unsubscribe(),s=null;var u=i;i=null,r.next(u)}};function a(){var u=o+n,h=e.now();if(h<u){s=this.schedule(void 0,u-h),r.add(s);return}c()}t.subscribe(x(r,function(u){i=u,o=e.now(),s||(s=e.schedule(a,n),r.add(s))},function(){c(),r.complete()},void 0,function(){i=s=null}))})}function m(n){return n<=0?function(){return lt}:_(function(e,t){var r=0;e.subscribe(x(t,function(s){++r<=n&&(t.next(s),n<=r&&t.complete())}))})}function ir(n){return p(function(){return n})}function or(n,e){return pe(function(t,r){return C(n(t,r)).pipe(m(1),ir(t))})}function ar(n,e){e===void 0&&(e=le);var t=te(n,e);return or(function(){return t})}function Et(n,e){return e===void 0&&(e=F),n=n??cr,_(function(t,r){var s,i=!0;t.subscribe(x(r,function(o){var c=e(o);(i||!n(s,c))&&(i=!1,s=c,r.next(o))}))})}function cr(n,e){return n===e}function ur(n){n===void 0&&(n=1/0);var e;n&&typeof n=="object"?e=n:e={count:n};var t=e.count,r=t===void 0?1/0:t,s=e.delay,i=e.resetOnSuccess,o=i===void 0?!1:i;return r<=0?F:_(function(c,a){var u=0,h,l=function(){var v=!1;h=c.subscribe(x(a,function(f){o&&(u=0),a.next(f)},void 0,function(f){if(u++<r){var y=function(){h?(h.unsubscribe(),h=null,l()):v=!0};if(s!=null){var d=typeof s=="number"?te(s):C(s(f,u)),T=x(a,function(){T.unsubscribe(),y()},function(){a.complete()});d.subscribe(T)}else y()}else a.error(f)})),v&&(h.unsubscribe(),h=null,l())};l()})}function Ze(n,e){return _(rr(n,e,arguments.length>=2,!0))}function _t(n){n===void 0&&(n={});var e=n.connector,t=e===void 0?function(){return new P}:e,r=n.resetOnError,s=r===void 0?!0:r,i=n.resetOnComplete,o=i===void 0?!0:i,c=n.resetOnRefCountZero,a=c===void 0?!0:c;return function(u){var h,l,v,f=0,y=!1,d=!1,T=function(){l?.unsubscribe(),l=void 0},D=function(){T(),h=v=void 0,y=d=!1},Y=function(){var H=h;D(),H?.unsubscribe()};return _(function(H,ze){f++,!d&&!y&&T();var ne=v=v??t();ze.add(function(){f--,f===0&&!d&&!y&&(l=ye(Y,a))}),ne.subscribe(ze),!h&&f>0&&(h=new V({next:function(re){return ne.next(re)},error:function(re){d=!0,T(),l=ye(D,s,re),ne.error(re)},complete:function(){y=!0,T(),l=ye(D,o),ne.complete()}}),C(H).subscribe(h))})(u)}}function ye(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];if(e===!0){n();return}if(e!==!1){var s=new V({next:function(){s.unsubscribe(),n()}});return C(e.apply(void 0,j([],R(t)))).subscribe(s)}}function X(n,e){return _(function(t,r){var s=null,i=0,o=!1,c=function(){return o&&!s&&r.complete()};t.subscribe(x(r,function(a){s?.unsubscribe();var u=0,h=i++;C(n(a,h)).subscribe(s=x(r,function(l){return r.next(e?e(a,l,h,u++):l)},function(){s=null,c()}))},function(){o=!0,c()}))})}function xe(n){return _(function(e,t){C(n).subscribe(x(t,function(){return t.complete()},ce)),!t.closed&&e.subscribe(t)})}function Qe(n,e,t){var r=S(n)||e||t?{next:n,error:e,complete:t}:n;return r?_(function(s,i){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var c=!0;s.subscribe(x(i,function(a){var u;(u=r.next)===null||u===void 0||u.call(r,a),i.next(a)},function(){var a;c=!1,(a=r.complete)===null||a===void 0||a.call(r),i.complete()},function(a){var u;c=!1,(u=r.error)===null||u===void 0||u.call(r,a),i.error(a)},function(){var a,u;c&&((a=r.unsubscribe)===null||a===void 0||a.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):F}function Oe(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=pt(n);return _(function(r,s){for(var i=n.length,o=new Array(i),c=n.map(function(){return!1}),a=!1,u=function(l){C(n[l]).subscribe(x(s,function(v){o[l]=v,!a&&!c[l]&&(c[l]=!0,(a=c.every(F))&&(c=null))},ce))},h=0;h<i;h++)u(h);r.subscribe(x(s,function(l){if(a){var v=j([l],R(o));s.next(t?t.apply(void 0,j([],R(v))):v)}}))})}function $(n,e,t){return n[e]??t}function E(...n){return n.join(".")}const b=n=>ln(p(e=>n(e)),Et(),M(e=>e!==void 0)),g=(n,e)=>b(t=>$(t,n,e)),Pt=(n,e,t,r,s,i=1)=>{switch(s){case"master":{const o=E(t,r-1,n);return c=>$(c,o,e)}case"aux":case"fx":return o=>{const c=E(t,r-1,s,i-1,n);return $(o,c,e)}}},hr=()=>n=>$(n,"m.mix"),lr=()=>n=>$(n,"m.pan"),fr=()=>n=>$(n,"m.dim"),et=n=>e=>$(e,`m.delay${n}`,0)*1e3,Dt=(n,e,t,r)=>Pt("pan",0,n,e,t,r),pr=(n,e,t,r)=>Pt("mute",0,n,e,t,r),dr=(n,e)=>{const t=E(n,e-1,"solo");return r=>$(r,t)},vr=(n,e,t,r=1)=>{switch(t){case"master":{const s=E(n,e-1,"mix");return i=>$(i,s)}case"aux":case"fx":{const s=E(n,e-1,t,r-1,"value");return i=>$(i,s)}}},mr=(n,e)=>{const t=E(n,e-1,"delay");return r=>$(r,t,0)*1e3},br=(n,e,t,r)=>{const s=E(n,e-1,t,r-1,"post");return i=>$(i,s,0)},yr=(n=1)=>{const e=E("f",n-1,"bpm");return t=>$(t,e)},gr=(n=1)=>{const e=E("f",n-1,"fxtype");return t=>$(t,e)},Lt=(n,e)=>{const t=E(n,e-1,"stereoIndex");return r=>["i","l","p","a"].includes(n)?$(r,t,-1):-1},tt=(n,e)=>{const t=E(e,n-1,"phantom");return r=>$(r,t)},nt=(n,e)=>{const t=E(e,n-1,"gain");return r=>$(r,t)},$r=(n,e)=>{const t=E("settings",n,...e!==void 0&&e>=0?[e]:[]);return r=>$(r,t)},Ae=()=>n=>$(n,"var.currentLength",-1),Ot=()=>n=>$(n,"var.currentTrackPos",0),Re=(n,e)=>Math.max(0,Math.floor(n*e)),At=(n,e)=>Math.max(0,Math.floor(e-Re(n,e))),Sr=()=>n=>{const e=Ot()(n),t=Ae()(n);return Re(e,t)},wr=()=>n=>{const e=Ot()(n),t=Ae()(n);return At(e,t)},je=()=>n=>$(n,"var.mtk.currentLength",-1),Rt=()=>n=>$(n,"var.mtk.currentTrackPos",0),xr=()=>n=>{const e=Rt()(n),t=je()(n);return Re(e,t)},Ir=()=>n=>{const e=Rt()(n),t=je()(n);return At(e,t)};var k=(n=>(n.Opening="OPENING",n.Open="OPEN",n.Close="CLOSE",n.Closing="CLOSING",n.Error="ERROR",n.Reconnecting="RECONNECTING",n))(k||{}),Fe=(n=>(n[n.Stopped=0]="Stopped",n[n.Playing=2]="Playing",n[n.Paused=3]="Paused",n))(Fe||{}),Be=(n=>(n[n.Stopped=0]="Stopped",n[n.Paused=1]="Paused",n[n.Playing=2]="Playing",n))(Be||{}),B=(n=>(n[n.None=-1]="None",n[n.Reverb=0]="Reverb",n[n.Delay=1]="Delay",n[n.Chorus=2]="Chorus",n[n.Room=3]="Room",n))(B||{});function I(n,e,t){return Math.min(t,Math.max(e,n))}function de(n){return Math.round((n+Number.EPSILON)*1e3)/1e3}function jt(n){return n.match(/^-?\d+$/)?parseInt(n,10):n.match(/^\d+\.\d+$/)?parseFloat(n):n}function Tr(n){if(n<0)return"";const e=Math.floor(n),t=Math.floor(e/60),r=e%60;return`${t}:${r.toString().length===1?"0":""}${r}`}function ee(n,e){switch(e){case 1:return n-1;case 0:return n+1;default:return n}}function rt(n){switch(n){case 1:return"L";case 2:return"R";default:return""}}function kr(n){switch(n){case B.None:return"None";case B.Chorus:return"Chorus";case B.Reverb:return"Reverb";case B.Delay:return"Delay";case B.Room:return"Room"}}function Ne(n,e){switch(n){case"i":return"CH "+e;case"a":return"AUX "+e;case"f":return"FX "+e;case"s":return"SUB "+e;case"v":return"VCA "+e;case"l":return"LINE IN "+rt(e);case"p":return"PLAYER "+rt(e);case"solovol":return"SOLO LEVEL";case"hpvol":return`HEADPHONE ${e} LEVEL`}}function Ie(n){return oe(tr(n.state$.pipe(sr(25)),te(250)))}const Ft=[[-1/0,0],[-100,.00126941502],[-99,.0014193058],[-98,.00158625841],[-97,.00177210569],[-96,.0019787848],[-95,.00220842659],[-94,.00246331096],[-93,.00274592638],[-92,.00305891037],[-91,.00340510905],[-90,.00378751755],[-89,.00420932472],[-88,.00467389822],[-87,.00518476963],[-86,.00574563444],[-85,.00636033714],[-84,.00703287125],[-83,.00776734948],[-82,.00856804848],[-81,.00943937898],[-80,.01038584113],[-79,.01141215861],[-78,.01252317429],[-77,.01372399926],[-76,.01501996815],[-75,.0164167881],[-74,.01792064309],[-73,.01953828335],[-72,.02127727866],[-71,.02314623445],[-70,.02515518665],[-69,.02731607854],[-68,.02964346856],[-67,.03215561062],[-66,.03487607837],[-65,.0378363952],[-64,.04108065367],[-63,.04467409104],[-62,.04872117192],[-61,.05341050774],[-60,.05882352591],[-59,.06435465068],[-58,.06995738298],[-57,.07563393563],[-56,.08138664067],[-55,.08721791208],[-54,.09313031286],[-53,.09912653267],[-52,.10520938411],[-51,.11138185114],[-50,.11764705926],[-49,.12400831282],[-48,.13046910241],[-47,.13703311235],[-46,.14370423928],[-45,.15048661083],[-44,.15738460608],[-43,.16440286487],[-42,.17154632322],[-41,.17882022634],[-40,.18623016588],[-39,.19378209766],[-38,.20148238726],[-37,.20933783613],[-36,.21735573001],[-35,.22554387664],[-34,.23391066305],[-33,.24246510724],[-32,.25121692196],[-31,.26017658552],[-30,.26935542002],[-29.9,.27028582105],[-29.8,.27121854806],[-29.7,.27215361455],[-29.6,.2730910331],[-29.5,.27403081628],[-29.4,.27497297851],[-29.3,.27591753239],[-29.2,.2768644914],[-29.1,.27781386906],[-29,.27876567934],[-28.9,.27971993526],[-28.8,.28067665175],[-28.7,.28163584229],[-28.6,.28259752039],[-28.5,.28356170142],[-28.4,.28452839889],[-28.3,.28549762792],[-28.2,.28646940272],[-28.1,.2874437375],[-28,.28842064831],[-27.9,.28940014914],[-27.8,.29038225533],[-27.7,.29136698227],[-27.6,.29235434486],[-27.5,.29334435938],[-27.4,.29433704074],[-27.3,.29533240478],[-27.2,.2963304678],[-27.1,.29733124515],[-27,.29833475361],[-26.9,.29934100923],[-26.8,.30035002832],[-26.7,.30136182765],[-26.6,.3023764235],[-26.5,.30339383334],[-26.4,.30441407394],[-26.3,.30543716229],[-26.2,.30646311585],[-26.1,.30749195209],[-26,.30852368847],[-25.9,.30955834268],[-25.8,.31059593312],[-25.7,.31163647724],[-25.6,.31267999392],[-25.5,.31372650107],[-25.4,.31477601733],[-25.3,.31582856132],[-25.2,.31688415236],[-25.1,.31794280931],[-25,.31900455104],[-24.9,.32006939733],[-24.8,.32113736775],[-24.7,.32220848184],[-24.6,.32328275964],[-24.5,.32436022116],[-24.4,.32544088666],[-24.3,.32652477687],[-24.2,.32761191227],[-24.1,.32870231359],[-24,.32979600201],[-23.9,.33089299873],[-23.8,.33199332491],[-23.7,.33309700247],[-23.6,.33420405304],[-23.5,.33531449875],[-23.4,.33642836171],[-23.3,.33754566452],[-23.2,.33866642928],[-23.1,.33979067928],[-23,.34091843711],[-22.9,.34204972652],[-22.8,.34318457078],[-22.7,.34432299319],[-22.6,.34546501818],[-22.5,.34661066951],[-22.4,.3477599714],[-22.3,.34891294874],[-22.2,.35006962623],[-22.1,.35123002878],[-22,.35239418154],[-21.9,.35356211034],[-21.8,.35473384033],[-21.7,.35590939806],[-21.6,.35708880937],[-21.5,.35827210057],[-21.4,.35945929866],[-21.3,.36065043067],[-21.2,.36184552335],[-21.1,.36304460443],[-21,.3642477016],[-20.9,.36545484257],[-20.8,.36666605598],[-20.7,.36788136989],[-20.6,.36910081329],[-20.5,.37032441515],[-20.4,.37155220495],[-20.3,.37278421177],[-20.2,.37402046612],[-20.1,.37526099756],[-20,.37650583661],[-19.9,.37775501423],[-19.8,.37900856114],[-19.7,.38026650855],[-19.6,.38152888836],[-19.5,.38279573224],[-19.4,.38406707242],[-19.3,.38534294115],[-19.2,.38662337163],[-19.1,.38790839631],[-19,.3891980492],[-18.9,.3904923636],[-18.8,.39179137361],[-18.7,.39309511357],[-18.6,.39440361829],[-18.5,.39571692259],[-18.4,.39703506161],[-18.3,.39835807122],[-18.2,.39968598739],[-18.1,.40101884631],[-18,.40235668444],[-17.9,.40369953902],[-17.8,.40504744719],[-17.7,.40640044678],[-17.6,.4077585754],[-17.5,.40912187181],[-17.4,.41049037443],[-17.3,.41186412238],[-17.2,.413243155],[-17.1,.41462751222],[-17,.41601723386],[-16.9,.41741236055],[-16.8,.41881293315],[-16.7,.42021899263],[-16.6,.42163058079],[-16.5,.42304773943],[-16.4,.4244705108],[-16.3,.42589893762],[-16.2,.42733306286],[-16.1,.42877293006],[-16,.43021858274],[-15.9,.43167006527],[-15.8,.433127422],[-15.7,.43459069787],[-15.6,.43605993828],[-15.5,.43753518863],[-15.4,.43901649513],[-15.3,.44050390413],[-15.2,.4419974623],[-15.1,.44349721679],[-15,.44500321534],[-14.9,.44651550555],[-14.8,.44803413586],[-14.7,.4495591548],[-14.6,.4510906114],[-14.5,.45262855513],[-14.4,.45417303545],[-14.3,.45572410279],[-14.2,.45728180732],[-14.1,.45884620002],[-14,.46041733201],[-13.9,.46199525474],[-13.8,.46358002012],[-13.7,.46517168032],[-13.6,.46677028784],[-13.5,.46837589552],[-13.4,.46998855658],[-13.3,.47160832456],[-13.2,.47323525313],[-13.1,.47486939642],[-13,.47651080892],[-12.9,.47815954522],[-12.8,.47981566039],[-12.7,.4814792095],[-12.6,.48315024807],[-12.5,.48482883186],[-12.4,.48651501676],[-12.3,.48820885899],[-12.2,.48991041491],[-12.1,.49161974108],[-12,.49333689432],[-11.9,.49506193132],[-11.8,.49679490936],[-11.7,.49853588548],[-11.6,.50028491695],[-11.5,.5020420613],[-11.4,.50380737579],[-11.3,.50558091793],[-11.2,.50736274524],[-11.1,.50915291533],[-11,.51095148548],[-10.9,.51275851321],[-10.8,.51457405591],[-10.7,.51639817073],[-10.6,.51823091484],[-10.5,.52007234516],[-10.4,.52192251827],[-10.3,.52378149075],[-10.2,.52564931882],[-10.1,.52752605826],[-10,.5294117647],[-9.9,.53130649327],[-9.8,.53321029863],[-9.7,.53512323508],[-9.6,.53704535618],[-9.5,.53897671518],[-9.4,.54091736441],[-9.3,.54286735586],[-9.2,.54482674052],[-9.1,.54679556866],[-9,.54877388978],[-8.9,.5507617523],[-8.8,.55275920394],[-8.7,.55476629105],[-8.6,.55678305926],[-8.5,.55880955269],[-8.4,.56084581441],[-8.3,.5628918861],[-8.2,.56494780804],[-8.1,.56701361912],[-8,.56908935658],[-7.9,.57117505604],[-7.8,.57327075163],[-7.7,.57537647523],[-7.6,.57749225723],[-7.5,.5796181258],[-7.4,.58175410703],[-7.3,.58390022506],[-7.2,.58605650149],[-7.1,.58822295559],[-7,.59039960429],[-6.9,.59258646169],[-6.8,.59478353942],[-6.7,.59699084621],[-6.6,.59920838778],[-6.5,.60143616702],[-6.4,.60367418348],[-6.3,.60592243349],[-6.2,.60818091012],[-6.1,.61044960283],[-6,.61272849748],[-5.9,.6150175762],[-5.8,.61731681728],[-5.7,.61962619505],[-5.6,.62194567965],[-5.5,.62427523721],[-5.4,.62661482923],[-5.3,.62896441302],[-5.2,.63132394117],[-5.1,.63369336171],[-5,.63607261766],[-4.9,.63846164738],[-4.8,.64086038404],[-4.7,.64326875575],[-4.6,.6456866854],[-4.5,.64811409055],[-4.4,.65055088326],[-4.3,.65299697022],[-4.2,.65545225237],[-4.1,.6579166252],[-4,.66038997821],[-3.9,.6628721953],[-3.8,.66536315437],[-3.7,.66786272742],[-3.6,.67037078051],[-3.5,.67288717377],[-3.4,.67541176116],[-3.3,.67794439074],[-3.2,.68048490444],[-3.1,.68303313828],[-3,.685588922],[-2.9,.68815207965],[-2.8,.69072242902],[-2.7,.69329978223],[-2.6,.69588394539],[-2.5,.69847471884],[-2.4,.70107189735],[-2.3,.70367526991],[-2.2,.70628462004],[-2.1,.7088997261],[-2,.7115203609],[-1.9,.71414629236],[-1.8,.71677728344],[-1.7,.71941309224],[-1.6,.72205347242],[-1.5,.72469817317],[-1.4,.7273469395],[-1.3,.72999951243],[-1.2,.73265562946],[-1.1,.7353150243],[-1,.73797742761],[-.9,.74064256705],[-.8,.74331016751],[-.7,.7459799514],[-.6,.74865163909],[-.5,.75132494903],[-.4,.75399959798],[-.3,.75667530153],[-.2,.75935177424],[-.1,.76202873001],[0,.76470588235],[.1,.7673829447],[.2,.77005963068],[.3,.77273565461],[.4,.77541073144],[.5,.77808457747],[.6,.78075691027],[.7,.78342744932],[.8,.78609591597],[.9,.788762034],[1,.79142552969],[1.1,.79408613226],[1.2,.79674357391],[1.3,.79939759037],[1.4,.80204792085],[1.5,.80469430843],[1.6,.80733650032],[1.7,.80997424785],[1.8,.81260730696],[1.9,.81523543815],[2,.81785840681],[2.1,.82047598323],[2.2,.82308794296],[2.3,.82569406676],[2.4,.82829414081],[2.5,.83088795675],[2.6,.8334753119],[2.7,.83605600931],[2.8,.83862985772],[2.9,.84119667177],[3,.84375627202],[3.1,.84630848491],[3.2,.84885314284],[3.3,.85139008425],[3.4,.85391915357],[3.5,.85644020114],[3.6,.85895308337],[3.7,.86145766254],[3.8,.86395380691],[3.9,.86644139059],[4,.86892029358],[4.1,.87139040159],[4.2,.87385160607],[4.3,.87630380417],[4.4,.87874689855],[4.5,.8811807974],[4.6,.8836054143],[4.7,.88602066817],[4.8,.88842648314],[4.9,.89082278844],[5,.89320951837],[5.1,.89558661211],[5.2,.89795401365],[5.3,.90031167166],[5.4,.90265953944],[5.5,.9049975747],[5.6,.90732573954],[5.7,.90964400026],[5.8,.91195232733],[5.9,.91425069513],[6,.91653908203],[6.1,.91881747005],[6.2,.92108584497],[6.3,.92334419597],[6.4,.92559251573],[6.5,.92783080021],[6.6,.93005904852],[6.7,.93227726285],[6.8,.93448544835],[6.9,.93668361302],[7,.93887176758],[7.1,.94104992537],[7.2,.9432181023],[7.3,.94537631667],[7.4,.94752458909],[7.5,.94966294241],[7.6,.9517914016],[7.7,.95390999367],[7.8,.95601874754],[7.9,.95811769404],[8,.96020686568],[8.1,.96228629674],[8.2,.96435602299],[8.3,.96641608179],[8.4,.96846651193],[8.5,.97050735351],[8.6,.97253864795],[8.7,.9745604379],[8.8,.9765727671],[8.9,.97857568043],[9,.98056922374],[9.1,.98255344384],[9.2,.98452838843],[9.3,.98649410604],[9.4,.98845064599],[9.5,.99039805829],[9.6,.99233639364],[9.7,.99426570335],[9.8,.9961860393],[9.9,.99809745389],[10,1],[1/0,1]];function Bt(n,e){return I(n,0,e)/1e3}function Nt(n,e,t,r){for(let s=0;s<n.length;s++)if(!(n[s][t]<e))return s===0||s===1||e===n[s][t]?n[s][r]:n[s-1][r]+(n[s][r]-n[s-1][r])*(e-n[s-1][t])/(n[s][t]-n[s-1][t]);return n[0][r]}function W(n){return Nt(Ft,n,0,1)}function ve(n){const e=Nt(Ft,n,1,0);return Math.round(e*10)/10}const Z=20,Te=4e3;function Cr(n){return Math.round((Te-Z)*Math.pow(n,3.0517)+Z)}function Mr(n){const e=I(n,Z,Te),t=Math.pow((e-Z)/(Te-Z),.32768620768751844);return Math.floor(t*1e7)/1e7}function ke(n,e,t){const r=(n-e)/(t-e);return I(r,0,1)}function ue(n,e,t){const r=Math.round((n*(t-e)+e)*10)/10;return I(r,e,t)}class Ce{constructor(e,t,r){this.conn=e,this.store=t,this.group=r,this.state$=this.store.state$.pipe(g(`automix.${this.group}.on`))}setState(e){this.conn.sendMessage(`SETD^automix.${this.group}.on^${e}`)}enable(){this.setState(1)}disable(){this.setState(0)}toggle(){this.state$.pipe(m(1)).subscribe(e=>this.setState(e^1))}}class Wt{constructor(e,t){this.conn=e,this.store=t,this.responseTime$=this.store.state$.pipe(g("automix.time")),this.responseTimeMs$=this.responseTime$.pipe(p(r=>Cr(r))),this.groups={a:new Ce(this.conn,this.store,"a"),b:new Ce(this.conn,this.store,"b")}}setResponseTime(e){this.conn.sendMessage(`SETD^automix.time^${e}`)}setResponseTimeMs(e){this.setResponseTime(Mr(e))}}var L=(n=>(n[n.Linear=0]="Linear",n[n.EaseIn=1]="EaseIn",n[n.EaseOut=2]="EaseOut",n[n.EaseInOut=3]="EaseInOut",n))(L||{});const st={0:n=>n,1:n=>n*n,2:n=>n*(2-n),3:n=>n*(2-n)};function We(n,e,t){return n.pipe(Oe(e),X(([{targetValue:r,fadeTime:s,easing:i,fps:o},c])=>Er(c,r,s,i,o).pipe(xe(t.status$.pipe(M(a=>a.type===k.Close))))))}function Er(n,e,t,r,s){t=Math.max(t,s);const i=Math.round(1e3/s),o=Math.round(t/i);r=r||L.Linear;const c=st[r]||st[L.Linear];return Mt(i).pipe(m(o),p(a=>c((a+1)/o)*(e-n)+n),Et())}function Ue(n){return new Promise(e=>setTimeout(()=>e(),n))}class me{constructor(e,t,r,s,i="master",o=0){this.conn=e,this.store=t,this.channelType=r,this.channel=s,this.busType=i,this.bus=o,this.fullChannelId=`${this.channelType}.${this.channel-1}`,this.faderLevelCommand="mix",this.linkedChannelIds=[],this.transitionSources$=new P,this.stereoIndex$=this.store.state$.pipe(b(Lt(this.channelType,this.channel))),this.faderLevel$=this.store.state$.pipe(b(vr(this.channelType,this.channel,this.busType,this.bus))),this.faderLevelDB$=this.faderLevel$.pipe(p(u=>ve(u))),this.mute$=this.store.state$.pipe(b(pr(this.channelType,this.channel,this.busType,this.bus))),this.name$=this.store.state$.pipe(g(E(this.channelType,this.channel-1,"name")),p(u=>u||Ne(this.channelType,this.channel)));const c=i+o+r+s,a=this.store.objectStore.get(c);if(a)return a;this.store.objectStore.set(c,this),We(this.transitionSources$,this.faderLevel$,e).subscribe(u=>this.setFaderLevelRaw(u))}fadeTo(e,t,r=L.Linear,s=25){return e=I(e,0,1),this.transitionSources$.next({targetValue:e,fadeTime:t,easing:r,fps:s}),Ue(t)}fadeToDB(e,t,r=L.Linear,s=25){const i=W(e);return this.fadeTo(i,t,r,s)}setFaderLevel(e){e=I(e,0,1),this.setFaderLevelRaw(e)}setFaderLevelRaw(e){[...this.linkedChannelIds,this.fullChannelId].forEach(t=>{const r=`SETD^${t}.${this.faderLevelCommand}^${e}`;this.conn.sendMessage(r)})}setFaderLevelDB(e){this.setFaderLevel(W(e))}changeFaderLevelDB(e){this.faderLevelDB$.pipe(m(1)).subscribe(t=>this.setFaderLevelDB(Math.max(t,-100)+e))}setMute(e){[...this.linkedChannelIds,this.fullChannelId].forEach(t=>{const r=`SETD^${t}.mute^${e}`;this.conn.sendMessage(r)})}mute(){this.setMute(1)}unmute(){this.setMute(0)}toggleMute(){this.mute$.pipe(m(1)).subscribe(e=>this.setMute(e^1))}setName(e){e=e.replace(/[\^]/gi,"").substring(0,20).toUpperCase();const t=E(this.channelType,this.channel-1,"name");this.conn.sendMessage(`SETS^${t}^${e}`)}}class Ge extends me{constructor(e,t,r,s,i,o){super(e,t,r,s,i,o),this.fullChannelId=this.constructChannelId(this.channelType,this.channel,this.busType,this.bus),this.faderLevelCommand="value",this.post$=this.store.state$.pipe(b(br(this.channelType,this.channel,this.busType,this.bus)))}constructChannelId(e,t,r,s){return`${e}.${t-1}.${r}.${s-1}`}setPost(e){[...this.linkedChannelIds,this.fullChannelId].forEach(t=>{const r=`SETD^${t}.post^${e}`;this.conn.sendMessage(r)})}post(){this.setPost(1)}pre(){this.setPost(0)}togglePost(){this.post$.pipe(m(1)).subscribe(e=>this.setPost(e^1))}}class K extends Ge{constructor(e,t,r,s,i){super(e,t,r,s,"aux",i),this.auxLinkChannelIds=[],this.pan$=this.store.state$.pipe(b(Dt(this.channelType,this.channel,this.busType,this.bus))),we([this.store.state$.pipe(b(Lt("a",i))),this.stereoIndex$]).pipe(p(([o,c])=>{const a=ee(i,o),u=ee(s,c),h=[],l=[];if(u!==void 0&&h.push(this.constructChannelId(r,u,this.busType,i)),a!==void 0){const v=this.constructChannelId(r,s,this.busType,a);h.push(v),l.push(v)}return a!==void 0&&u!==void 0&&h.push(this.constructChannelId(r,u,this.busType,a)),{allChannelIds:h,auxLinkChannelIds:l}})).subscribe(o=>{this.linkedChannelIds=o.allChannelIds,this.auxLinkChannelIds=o.auxLinkChannelIds})}setPan(e){e=I(e,0,1),e=de(e),[...this.auxLinkChannelIds,this.fullChannelId].forEach(t=>{const r=`SETD^${t}.pan^${e}`;this.conn.sendMessage(r)})}changePan(e){this.pan$.pipe(m(1)).subscribe(t=>this.setPan(t+e))}setPostProc(e){[...this.linkedChannelIds,this.fullChannelId].forEach(t=>{const r=`SETD^${t}.postproc^${e}`;this.conn.sendMessage(r)})}postProc(){this.setPostProc(1)}preProc(){this.setPostProc(0)}}class Ut{constructor(e,t,r){this.conn=e,this.store=t,this.bus=r}input(e){return new K(this.conn,this.store,"i",e,this.bus)}line(e){return new K(this.conn,this.store,"l",e,this.bus)}player(e){return new K(this.conn,this.store,"p",e,this.bus)}fx(e){return new K(this.conn,this.store,"f",e,this.bus)}}const Gt={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}};class Vt{constructor(e){this.store=e,this.model$=this.store.state$.pipe(g("model")),this.capabilities$=this.model$.pipe(p(t=>Gt[t])),this.firmware$=this.store.state$.pipe(g("firmware")),this.model$.subscribe(t=>this.model=t)}}class zt{constructor(e,t){this.conn=e,this.store=t,this.recording$=this.store.state$.pipe(g("var.isRecording",0)),this.busy$=this.store.state$.pipe(g("var.recBusy",0))}recordToggle(){this.conn.sendMessage("RECTOGGLE")}recordStart(){this.recording$.pipe(m(1)).subscribe(e=>{e||this.recordToggle()})}recordStop(){this.recording$.pipe(m(1)).subscribe(e=>{e&&this.recordToggle()})}}class q extends Ge{constructor(e,t,r,s,i){super(e,t,r,s,"fx",i),this.stereoIndex$.pipe(p(o=>{const c=ee(s,o);return c!==void 0?[this.constructChannelId(this.channelType,c,this.busType,this.bus)]:[]})).subscribe(o=>this.linkedChannelIds=o)}}class Yt{constructor(e,t,r){this.conn=e,this.store=t,this.bus=r,this.fxType$=this.store.state$.pipe(b(gr(this.bus))),this.bpm$=this.store.state$.pipe(b(yr(this.bus)));const s="fxbus"+r,i=this.store.objectStore.get(s);if(i)return i;this.store.objectStore.set(s,this)}input(e){return new q(this.conn,this.store,"i",e,this.bus)}line(e){return new q(this.conn,this.store,"l",e,this.bus)}player(e){return new q(this.conn,this.store,"p",e,this.bus)}sub(e){return new q(this.conn,this.store,"s",e,this.bus)}setBpm(e){e=I(e,20,400),e=Math.round(e),this.conn.sendMessage(`SETD^f.${this.bus-1}.bpm^${e}`)}assertFxParamInRange(e){if(e<1||e>6)throw new 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(g(this.makeFxParamPath(e)))}setParam(e,t){this.assertFxParamInRange(e),t=I(t,0,1),this.conn.sendMessage(`SETD^${this.makeFxParamPath(e)}^${t}`)}}class Ht{constructor(e,t,r,s){this.conn=e,this.store=t,this.deviceInfo=r,this.channel=s,this.fullChannelId=`hw.${this.channel-1}`,this.phantom$=this.deviceInfo.model$.pipe(X(c=>{switch(c){case"ui24":return this.store.state$.pipe(b(tt(this.channel,"hw")));case"ui16":case"ui12":return this.store.state$.pipe(b(tt(this.channel,"i")))}})),this.gain$=this.deviceInfo.model$.pipe(X(c=>{switch(c){case"ui24":return this.store.state$.pipe(b(nt(this.channel,"hw")));case"ui16":case"ui12":return this.store.state$.pipe(b(nt(this.channel,"i")))}})),this.gainDB$=this.deviceInfo.model$.pipe(X(c=>{switch(c){case"ui24":return this.gain$.pipe(p(a=>ue(a,-6,57)));case"ui16":case"ui12":return this.gain$.pipe(p(a=>ue(a,-40,50)))}}));const i="hw"+s,o=this.store.objectStore.get(i);if(o)return o;this.store.objectStore.set(i,this),this.deviceInfo.model$.subscribe(c=>{switch(c){case"ui24":this.fullChannelId=`hw.${this.channel-1}`;return;case"ui16":case"ui12":this.fullChannelId=`i.${this.channel-1}`;return}})}setPhantom(e){const t=`SETD^${this.fullChannelId}.phantom^${e}`;this.conn.sendMessage(t)}phantomOn(){this.setPhantom(1)}phantomOff(){this.setPhantom(0)}togglePhantom(){this.phantom$.pipe(m(1)).subscribe(e=>this.setPhantom(e^1))}setGain(e){e=I(e,0,1);const t=`SETD^${this.fullChannelId}.gain^${e}`;this.conn.sendMessage(t)}setGainDB(e){switch(this.deviceInfo.model){case"ui24":this.setGain(ke(e,-6,57));return;case"ui16":case"ui12":this.setGain(ke(e,-40,50));return}}changeGainDB(e){this.gainDB$.pipe(m(1)).subscribe(t=>this.setGainDB(t+e))}}class N extends me{constructor(e,t,r,s){super(e,t,r,s),this.fullChannelId=this.constructChannelId(this.channelType,this.channel),this.faderLevelCommand="mix",this.solo$=this.store.state$.pipe(b(dr(this.channelType,this.channel))),this.pan$=this.store.state$.pipe(b(Dt(this.channelType,this.channel,this.busType,this.bus))),this.automixGroup$=this.store.state$.pipe(g(`${this.fullChannelId}.amixgroup`),p(i=>{switch(i){case 0:return"a";case 1:return"b";default:return"none"}})),this.automixWeight$=this.store.state$.pipe(g(`${this.fullChannelId}.amix`)),this.automixWeightDB$=this.automixWeight$.pipe(p(i=>ue(i,-12,12))),this.multiTrackSelected$=this.store.state$.pipe(g(`${this.fullChannelId}.mtkrec`)),this.stereoIndex$.pipe(p(i=>{const o=ee(s,i);return o!==void 0?[this.constructChannelId(this.channelType,o)]:[]})).subscribe(i=>this.linkedChannelIds=i)}constructChannelId(e,t){return`${e}.${t-1}`}setPan(e){e=I(e,0,1),e=de(e);const t=`SETD^${this.fullChannelId}.pan^${e}`;this.conn.sendMessage(t)}changePan(e){this.pan$.pipe(m(1)).subscribe(t=>this.setPan(t+e))}setSolo(e){[...this.linkedChannelIds,this.fullChannelId].forEach(t=>{const r=`SETD^${t}.solo^${e}`;this.conn.sendMessage(r)})}solo(){this.setSolo(1)}unsolo(){this.setSolo(0)}toggleSolo(){this.solo$.pipe(m(1)).subscribe(e=>this.setSolo(e^1))}multiTrackAssertChannelType(){if(this.channelType!=="i"&&this.channelType!=="l")throw new Error("Multitrack recording can only be used with input and line channels")}multiTrackSetSelection(e){this.multiTrackAssertChannelType();const t=`SETD^${this.fullChannelId}.mtkrec^${e}`;this.conn.sendMessage(t)}multiTrackSelect(){this.multiTrackSetSelection(1)}multiTrackUnselect(){this.multiTrackSetSelection(0)}multiTrackToggle(){this.multiTrackAssertChannelType(),this.multiTrackSelected$.pipe(m(1)).subscribe(e=>this.multiTrackSetSelection(e^1))}automixAssignGroup(e){if(this.channelType!=="i")throw new 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,this.fullChannelId].forEach(r=>{const s=`SETD^${r}.amixgroup^${t}`;this.conn.sendMessage(s)})}automixRemove(){this.automixAssignGroup("none")}automixSetWeight(e){e=I(e,0,1),[...this.linkedChannelIds,this.fullChannelId].forEach(t=>{const r=`SETD^${t}.amix^${e}`;this.conn.sendMessage(r)})}automixSetWeightDB(e){this.automixSetWeight(ke(e,-12,12))}automixChangeWeightDB(e){this.automixWeightDB$.pipe(m(1)).subscribe(t=>this.automixSetWeightDB(t+e))}}class Q extends N{constructor(e,t,r,s){super(e,t,r,s),this.delay$=this.store.state$.pipe(b(mr(this.channelType,this.channel))),this.delayMaxValueMs=250,r==="a"&&(this.delayMaxValueMs=500)}setDelay(e){const t=Bt(e,this.delayMaxValueMs),r=`SETD^${this.fullChannelId}.delay^${t}`;this.conn.sendMessage(r)}changeDelay(e){this.delay$.pipe(m(1)).subscribe(t=>this.setDelay(t+e))}}class Ve{constructor(e,t){this.conn=e,this.store=t,this.name$=Ct("MASTER"),this.faderLevel$=this.store.state$.pipe(b(hr())),this.faderLevelDB$=this.faderLevel$.pipe(p(r=>ve(r))),this.pan$=this.store.state$.pipe(b(lr())),this.dim$=this.store.state$.pipe(b(fr())),this.delayL$=this.store.state$.pipe(b(et("L"))),this.delayR$=this.store.state$.pipe(b(et("R"))),this.transitionSources$=new P,We(this.transitionSources$,this.faderLevel$,e).subscribe(r=>this.setFaderLevelRaw(r))}input(e){return new Q(this.conn,this.store,"i",e)}line(e){return new Q(this.conn,this.store,"l",e)}player(e){return new N(this.conn,this.store,"p",e)}aux(e){return new Q(this.conn,this.store,"a",e)}fx(e){return new N(this.conn,this.store,"f",e)}sub(e){return new N(this.conn,this.store,"s",e)}vca(e){return new N(this.conn,this.store,"v",e)}fadeTo(e,t,r=L.Linear,s=25){return e=I(e,0,1),this.transitionSources$.next({targetValue:e,fadeTime:t,easing:r,fps:s}),Ue(t)}fadeToDB(e,t,r=L.Linear,s=25){const i=W(e);return this.fadeTo(i,t,r,s)}setFaderLevel(e){e=I(e,0,1),this.setFaderLevelRaw(e)}setFaderLevelRaw(e){const t=`SETD^m.mix^${e}`;this.conn.sendMessage(t)}setFaderLevelDB(e){this.setFaderLevel(W(e))}changeFaderLevelDB(e){this.faderLevelDB$.pipe(m(1)).subscribe(t=>this.setFaderLevelDB(Math.max(t,-100)+e))}setPan(e){e=I(e,0,1),e=de(e);const t=`SETD^m.pan^${e}`;this.conn.sendMessage(t)}changePan(e){this.pan$.pipe(m(1)).subscribe(t=>this.setPan(t+e))}setDim(e){const t=`SETD^m.dim^${e}`;this.conn.sendMessage(t)}dim(){this.setDim(1)}undim(){this.setDim(0)}toggleDim(){this.dim$.pipe(m(1)).subscribe(e=>this.setDim(e^1))}setDelayL(e){this.setDelay(e,"L")}setDelayR(e){this.setDelay(e,"R")}changeDelayL(e){this.delayL$.pipe(m(1)).subscribe(t=>this.setDelayL(t+e))}changeDelayR(e){this.delayR$.pipe(m(1)).subscribe(t=>this.setDelayR(t+e))}setDelay(e,t){const r=Bt(e,500);this.conn.sendMessage(`SETD^m.delay${t}^${r}`)}}class Kt{constructor(e,t){this.conn=e,this.store=t,this.state$=this.store.state$.pipe(g("var.mtk.currentState",Be.Stopped)),this.session$=this.store.state$.pipe(g("var.mtk.session"),p(r=>typeof r=="number"?r.toString().padStart(4,"0"):r)),this.length$=this.store.state$.pipe(b(je())),this.elapsedTime$=this.store.state$.pipe(b(xr())),this.remainingTime$=this.store.state$.pipe(b(Ir())),this.recording$=this.store.state$.pipe(g("var.mtk.rec.currentState",0)),this.busy$=this.store.state$.pipe(g("var.mtk.rec.busy",0)),this.recordingTime$=this.store.state$.pipe(g("var.mtk.rec.time",0),Oe(this.recording$),p(([r,s])=>s?r:0)),this.soundcheck$=this.store.state$.pipe(g("var.mtk.soundcheck",0))}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(m(1)).subscribe(e=>{e||this.recordToggle()})}recordStop(){this.recording$.pipe(m(1)).subscribe(e=>{e&&this.recordToggle()})}setSoundcheck(e){const t=`SETD^var.mtk.soundcheck^${e}`;this.conn.sendMessage(t)}activateSoundcheck(){this.setSoundcheck(1)}deactivateSoundcheck(){this.setSoundcheck(0)}toggleSoundcheck(){this.soundcheck$.pipe(m(1)).subscribe(e=>this.setSoundcheck(e^1))}}function _r(n,e){return e<0?n:n^1<<e}function Pr(n,e){return e<0?n:n&~(1<<e)}function Dr(n,e){return e<0?n:n|1<<e}function Lr(n,e){return e<0?n:n&1<<e?1:0}function Or(n){switch(n){case"all":return 23;case"fx":return 22;default:return n-1}}class qt{constructor(e,t,r){this.conn=e,this.store=t,this.id=r,this.mgMask$=this.store.state$.pipe(g("mgmask")),this.state$=this.mgMask$.pipe(p(o=>Lr(o,this.groupIndex))),this.groupIndex=Or(r);const s="mutegroup"+r,i=this.store.objectStore.get(s);if(i)return i;this.store.objectStore.set(s,this)}mute(){this.mgMask$.pipe(m(1)).subscribe(e=>this.setMgMask(Dr(e,this.groupIndex)))}unmute(){this.mgMask$.pipe(m(1)).subscribe(e=>this.setMgMask(Pr(e,this.groupIndex)))}toggle(){this.mgMask$.pipe(m(1)).subscribe(e=>this.setMgMask(_r(e,this.groupIndex)))}setMgMask(e){const t=`SETD^mgmask^${e}`;this.conn.sendMessage(t)}}class Jt{constructor(e,t){this.conn=e,this.store=t,this.state$=this.store.state$.pipe(g("var.currentState",Fe.Stopped)),this.playlist$=this.store.state$.pipe(g("var.currentPlaylist")),this.track$=this.store.state$.pipe(g("var.currentTrack")),this.length$=this.store.state$.pipe(b(Ae())),this.elapsedTime$=this.store.state$.pipe(b(Sr())),this.remainingTime$=this.store.state$.pipe(b(wr())),this.shuffle$=this.store.state$.pipe(g("settings.shuffle",0))}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.sendMessage(`SETD^settings.shuffle^${e}`)}toggleShuffle(){this.shuffle$.pipe(m(1)).subscribe(e=>this.setShuffle(e^1))}setPlayMode(e){this.conn.sendMessage(`SETD^settings.playMode^${e}`)}setManual(){this.setPlayMode(0)}setAuto(){this.setPlayMode(3)}}class Xt{constructor(e,t){this.conn=e,this.store=t,this.currentShow$=this.store.state$.pipe(g("var.currentShow")),this.currentSnapshot$=this.store.state$.pipe(g("var.currentSnapshot")),this.currentCue$=this.store.state$.pipe(g("var.currentCue"))}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(){we([this.currentShow$,this.currentSnapshot$]).pipe(m(1),M(([e,t])=>!!e&&!!t)).subscribe(([e,t])=>this.saveSnapshot(e,t))}updateCurrentCue(){we([this.currentShow$,this.currentCue$]).pipe(m(1),M(([e,t])=>!!e&&!!t)).subscribe(([e,t])=>this.saveCue(e,t))}}class Me{constructor(e,t,r,s){this.conn=e,this.store=t,this.busName=r,this.busId=s,this.transitionSources$=new P,this.faderLevel$=this.store.state$.pipe(b($r(this.busName,this.busId?this.busId-1:void 0))),this.faderLevelDB$=this.faderLevel$.pipe(p(c=>ve(c))),this.name$=Ct(Ne(this.busName,this.busId||-1));const i="volume-"+this.busName+this.busId,o=this.store.objectStore.get(i);if(o)return o;this.store.objectStore.set(i,this),We(this.transitionSources$,this.faderLevel$,e).subscribe(c=>this.setFaderLevelRaw(c))}fadeTo(e,t,r=L.Linear,s=25){return e=I(e,0,1),this.transitionSources$.next({targetValue:e,fadeTime:t,easing:r,fps:s}),Ue(t)}fadeToDB(e,t,r=L.Linear,s=25){const i=W(e);return this.fadeTo(i,t,r,s)}setFaderLevel(e){e=I(e,0,1),this.setFaderLevelRaw(e)}setFaderLevelRaw(e){const r=`SETD^settings.${`${this.busName}${this.busId?"."+(this.busId-1):""}`}^${e}`;this.conn.sendMessage(r)}setFaderLevelDB(e){this.setFaderLevel(W(e))}changeFaderLevelDB(e){this.faderLevelDB$.pipe(m(1)).subscribe(t=>this.setFaderLevelDB(Math.max(t,-100)+e))}}var Ar={url:"",deserializer:function(n){return JSON.parse(n.data)},serializer:function(n){return JSON.stringify(n)}},Rr="WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }",jr=(function(n){O(e,n);function e(t,r){var s=n.call(this)||this;if(s._socket=null,t instanceof w)s.destination=r,s.source=t;else{var i=s._config=$e({},Ar);if(s._output=new P,typeof t=="string")i.url=t;else for(var o in t)t.hasOwnProperty(o)&&(i[o]=t[o]);if(!i.WebSocketCtor&&WebSocket)i.WebSocketCtor=WebSocket;else if(!i.WebSocketCtor)throw new Error("no WebSocket constructor can be found");s.destination=new J}return s}return e.prototype.lift=function(t){var r=new e(this._config,this.destination);return r.operator=t,r.source=this,r},e.prototype._resetState=function(){this._socket=null,this.source||(this.destination=new J),this._output=new P},e.prototype.multiplex=function(t,r,s){var i=this;return new w(function(o){try{i.next(t())}catch(a){o.error(a)}var c=i.subscribe({next:function(a){try{s(a)&&o.next(a)}catch(u){o.error(u)}},error:function(a){return o.error(a)},complete:function(){return o.complete()}});return function(){try{i.next(r())}catch(a){o.error(a)}c.unsubscribe()}})},e.prototype._connectSocket=function(){var t=this,r=this._config,s=r.WebSocketCtor,i=r.protocol,o=r.url,c=r.binaryType,a=this._output,u=null;try{u=i?new s(o,i):new s(o),this._socket=u,c&&(this._socket.binaryType=c)}catch(l){a.error(l);return}var h=new z(function(){t._socket=null,u&&u.readyState===1&&u.close()});u.onopen=function(l){var v=t._socket;if(!v){u.close(),t._resetState();return}var f=t._config.openObserver;f&&f.next(l);var y=t.destination;t.destination=he.create(function(d){if(u.readyState===1)try{var T=t._config.serializer;u.send(T(d))}catch(D){t.destination.error(D)}},function(d){var T=t._config.closingObserver;T&&T.next(void 0),d&&d.code?u.close(d.code,d.reason):a.error(new TypeError(Rr)),t._resetState()},function(){var d=t._config.closingObserver;d&&d.next(void 0),u.close(),t._resetState()}),y&&y instanceof J&&h.add(y.subscribe(t.destination))},u.onerror=function(l){t._resetState(),a.error(l)},u.onclose=function(l){u===t._socket&&t._resetState();var v=t._config.closeObserver;v&&v.next(l),l.wasClean?a.complete():a.error(l)},u.onmessage=function(l){try{var v=t._config.deserializer;a.next(v(l))}catch(f){a.error(f)}}},e.prototype._subscribe=function(t){var r=this,s=this.source;return s?s.subscribe(t):(this._socket||this._connectSocket(),this._output.subscribe(t),t.add(function(){var i=r._socket;r._output.observers.length===0&&(i&&(i.readyState===1||i.readyState===0)&&i.close(),r._resetState())}),t)},e.prototype.unsubscribe=function(){var t=this._socket;t&&(t.readyState===1||t.readyState===0)&&t.close(),this._resetState(),n.prototype.unsubscribe.call(this)},e})(Se);function Fr(n){return new jr(n)}class Br{constructor(e){this.reconnectTime=2e3,this.keepaliveTime=1e3,this.forceClose$=new P,this.statusSubject$=new P,this.outboundSubject$=new P,this.inboundSubject$=new P,this._status=k.Close,this.status$=this.statusSubject$.asObservable(),this.outbound$=this.outboundSubject$.asObservable(),this.inbound$=this.inboundSubject$.asObservable(),this.allMessages$=Zn(this.outbound$,this.inbound$),this.statusSubject$.subscribe(s=>{this._status=s.type}),this.socket$=Fr({url:`ws://${e.targetIP}`,WebSocketCtor:e.webSocketCtor||tn,serializer:s=>`3:::${s}`,deserializer:({data:s})=>s,openObserver:{next:()=>this.statusSubject$.next({type:k.Open})},closingObserver:{next:()=>this.statusSubject$.next({type:k.Closing})},closeObserver:{next:()=>this.statusSubject$.next({type:k.Close})}});const t=this.status$.pipe(M(s=>s.type===k.Open)),r=this.status$.pipe(M(s=>s.type===k.Close));t.pipe(X(()=>Mt(this.keepaliveTime).pipe(xe(r))),p(()=>"ALIVE")).subscribe(s=>this.outboundSubject$.next(s)),this.outbound$.subscribe(this.socket$)}get status(){return this._status}connect(){return this.statusSubject$.next({type:k.Opening}),this.socket$.pipe(Qe({error:t=>this.statusSubject$.next({type:k.Error,payload:t})}),ur({delay:()=>te(this.reconnectTime).pipe(xe(this.forceClose$),Qe(()=>this.statusSubject$.next({type:k.Reconnecting})))}),p(t=>{const r=t.match(/^(3:::)([\s\S]*)/);return r&&r[2]}),M(t=>t!==null),pe(t=>t.split(`
`))).subscribe(t=>this.inboundSubject$.next(t)),oe(this.status$.pipe(M(t=>t.type===k.Open),p(()=>{})))}disconnect(){return this.socket$.complete(),this.forceClose$.next(),oe(this.status$.pipe(M(e=>e.type===k.Close),p(()=>{})))}reconnect(){return this.status$.pipe(M(e=>e.type===k.Close),m(1),ar(1e3)).subscribe(()=>this.connect()),this.disconnect(),oe(this.status$.pipe(M(e=>e.type===k.Open),p(()=>{})))}sendMessage(e){this.outboundSubject$.next(e)}}class Nr{constructor(){this.store=new Map}get(e){return this.store.get(e)}set(e,t){this.store.set(e,t)}}class Wr{constructor(e){this.conn=e,this.setdSetsMessageMatches$=this.conn.allMessages$.pipe(p(t=>t.match(/(SETD|SETS)\^([a-zA-Z0-9.]+)\^(.*)/)),M(t=>t!==null),_t()),this.messages$=this.setdSetsMessageMatches$.pipe(p(([t])=>t)),this.state$=Xe(this.setdSetsMessageMatches$.pipe(Ze((t,[,,r,s])=>(t[r]=jt(s),t),{})),{connector:()=>new J(1)}),this.syncState$=Xe(this.conn.allMessages$.pipe(M(t=>t.startsWith("BMSG^SYNC^")),p(t=>t.slice(10).split("^")),Ze((t,[r,s])=>({...t,[r]:parseInt(s,10)}),{})),{connector:()=>new J(1)}),this.objectStore=new Nr,this.state$.connect(),this.syncState$.connect()}}function Ur(n){return ue(n,-80,0)}function Gr(n){const e=atob(n),t=e.length,r=new Uint8Array(t);for(let s=0;s<t;s++)r[s]=e.charCodeAt(s);return r}function Vr(n){const e=[{key:"input",amount:n[0],blockSize:6},{key:"player",amount:n[1],blockSize:6},{key:"sub",amount:n[2],blockSize:7},{key:"fx",amount:n[3],blockSize:7},{key:"aux",amount:n[4],blockSize:5},{key:"master",amount:n[5],blockSize:5},{key:"line",amount:n[6],blockSize:6}],t={input:[],player:[],sub:[],fx:[],aux:[],master:[],line:[]},r=.004167508166392142;let s=8;return e.forEach(i=>{for(let o=0;o<(i.amount||0);o++){switch(i.key){case"input":case"player":case"line":{t[i.key].push({vuPre:n[s+0]*r,vuPost:n[s+1]*r,vuPostFader:n[s+2]*r});break}case"aux":{t[i.key].push({vuPost:n[s+0]*r,vuPostFader:n[s+1]*r});break}case"fx":case"sub":{t[i.key].push({vuPostL:n[s+0]*r,vuPostR:n[s+1]*r,vuPostFaderL:n[s+2]*r,vuPostFaderR:n[s+3]*r});break}case"master":{t[i.key].push({vuPost:n[s+0]*r,vuPostFader:n[s+1]*r});break}}s+=i.blockSize}}),t}class Zt{constructor(e){this.conn=e,this.vuData$=this.conn.inbound$.pipe(M(t=>t.startsWith("VU2^")),p(t=>t.slice(4)),p(t=>Vr(Gr(t))),_t())}input(e){return this.vuData$.pipe(p(t=>t.input[e-1]))}line(e){return this.vuData$.pipe(p(t=>t.line[e-1]))}player(e){return this.vuData$.pipe(p(t=>t.player[e-1]))}aux(e){return this.vuData$.pipe(p(t=>t.aux[e-1]))}fx(e){return this.vuData$.pipe(p(t=>t.fx[e-1]))}sub(e){return this.vuData$.pipe(p(t=>t.sub[e-1]))}master(){return this.vuData$.pipe(p(e=>{if(e.master.length<2)throw new 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}}))}}const Qt={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 zr(n){return Qt[n]}function Yr(n,e,t){const r=zr(e);if(t===-1)return n.master;if(r[t]!==void 0){const[s,i]=r[t];switch(s){case"i":return n.master.input(i);case"l":return n.master.line(i);case"p":return n.master.player(i);case"f":return n.master.fx(i);case"s":return n.master.sub(i);case"a":return n.master.aux(i);case"v":return n.master.vca(i)}}return null}function it(n,e,t){if(e!=="master"&&t===void 0)throw new Error("Channel number is required");const r=Qt[n];if(e==="master")return-1;for(const[s,[i,o]]of Object.entries(r))if(i===e&&o===t)return+s;return null}class en{constructor(e){this.sui=e,this.defaultSyncId="SYNC_ID"}getSelectedChannelIndex(e){const t=e||this.defaultSyncId;return this.sui.store.syncState$.pipe(p(r=>r[t]),M(r=>r!==void 0))}getSelectedChannel(e){return this.getSelectedChannelIndex(e).pipe(Oe(this.sui.deviceInfo.model$),p(([t,r])=>Yr(this.sui,r,t)))}selectChannelIndex(e,t){const r=`BMSG^SYNC^${t||this.defaultSyncId}^${e}`;this.sui.conn.sendMessage(r)}selectChannel(e,t,r){const s=this.sui.deviceInfo.model;if(s){if(e==="master"&&typeof t!="number"&&r===void 0){const i=it(s,"master");if(i!==null){this.selectChannelIndex(i,t);return}}if(e!=="master"&&typeof t=="number"){const i=it(s,e,t);if(i!==null){this.selectChannelIndex(i,r);return}}throw new Error("Invalid arguments or channel not found")}}}class Hr{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 Wr(this.conn),this.deviceInfo=new Vt(this.store),this.status$=this.conn.status$,this.vuProcessor=new Zt(this.conn),this.master=new Ve(this.conn,this.store),this.player=new Jt(this.conn,this.store),this.recorderDualTrack=new zt(this.conn,this.store),this.recorderMultiTrack=new Kt(this.conn,this.store),this.volume={solo:new Me(this.conn,this.store,"solovol"),headphone:t=>new Me(this.conn,this.store,"hpvol",t)},this.shows=new Xt(this.conn,this.store),this.automix=new Wt(this.conn,this.store),this.channelSync=new en(this)}aux(e){return new Ut(this.conn,this.store,e)}fx(e){return new Yt(this.conn,this.store,e)}muteGroup(e){return new qt(this.conn,this.store,e)}clearMuteGroups(){this.conn.sendMessage("SETD^mgmask^0")}hw(e){return new Ht(this.conn,this.store,this.deviceInfo,e)}async connect(){await this.conn.connect(),await Ie(this.store)}disconnect(){return this.conn.disconnect()}async reconnect(){await this.conn.reconnect(),await Ie(this.store)}}function Kr(n){return n instanceof me}function qr(n){return n instanceof N}function Jr(n){return n instanceof Q}function Xr(n){return n instanceof Ve}exports.AutomixController=Wt;exports.AutomixGroup=Ce;exports.AuxBus=Ut;exports.AuxChannel=K;exports.Channel=me;exports.ChannelSync=en;exports.ConnectionStatus=k;exports.DBToFaderValue=W;exports.DEVICE_CAPABILITIES=Gt;exports.DelayableMasterChannel=Q;exports.DeviceInfo=Vt;exports.DualTrackRecorder=zt;exports.Easings=L;exports.FxBus=Yt;exports.FxChannel=q;exports.FxType=B;exports.HwChannel=Ht;exports.MasterBus=Ve;exports.MasterChannel=N;exports.MtkState=Be;exports.MultiTrackRecorder=Kt;exports.MuteGroup=qt;exports.Player=Jt;exports.PlayerState=Fe;exports.SendChannel=Ge;exports.ShowController=Xt;exports.SoundcraftUI=Hr;exports.VolumeBus=Me;exports.VuProcessor=Zt;exports.clamp=I;exports.constructReadableChannelName=Ne;exports.faderValueToDB=ve;exports.fxTypeToString=kr;exports.getLinkedChannelNumber=ee;exports.isChannel=Kr;exports.isDelayableMasterChannel=Jr;exports.isMaster=Xr;exports.isMasterChannel=qr;exports.playerTimeToString=Tr;exports.roundToThreeDecimals=de;exports.transformStringValue=jt;exports.vuValueToDB=Ur;exports.waitForInitParams=Ie;