rxpoweredup
Version:
A Typescript RxJS-based library for controlling LEGO Powered UP hubs & peripherals.
15 lines (13 loc) • 114 kB
JavaScript
/*! *****************************************************************************
Copyright (C) Microsoft. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var e;!function(e){!function(){var t="object"==typeof globalThis?globalThis:"object"==typeof global?global:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),r=n(e);function n(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==t.Reflect&&(r=n(t.Reflect,r)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,o=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",s=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!i&&!a,u={create:i?function(){return pe(Object.create(null))}:a?function(){return pe({__proto__:null})}:function(){return pe({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},l=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),d="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:ue(),h="function"==typeof WeakMap?WeakMap:le(),f=n?Symbol.for("@reflect-metadata:registry"):void 0,y=oe(),m=se(y);function g(e,t,r,n){if(L(r)){if(!G(e))throw new TypeError;if(!Y(t))throw new TypeError;return I(e,t)}if(!G(e))throw new TypeError;if(!j(t))throw new TypeError;if(!j(n)&&!L(n)&&!U(n))throw new TypeError;return U(n)&&(n=void 0),_(e,t,r=$(r),n)}function b(e,t){function r(r,n){if(!j(r))throw new TypeError;if(!L(n)&&!K(n))throw new TypeError;k(e,t,r,n)}return r}function v(e,t,r,n){if(!j(r))throw new TypeError;return L(n)||(n=$(n)),k(e,t,r,n)}function w(e,t,r){if(!j(t))throw new TypeError;return L(r)||(r=$(r)),O(e,t,r)}function S(e,t,r){if(!j(t))throw new TypeError;return L(r)||(r=$(r)),E(e,t,r)}function F(e,t,r){if(!j(t))throw new TypeError;return L(r)||(r=$(r)),A(e,t,r)}function M(e,t,r){if(!j(t))throw new TypeError;return L(r)||(r=$(r)),x(e,t,r)}function T(e,t){if(!j(e))throw new TypeError;return L(t)||(t=$(t)),C(e,t)}function P(e,t){if(!j(e))throw new TypeError;return L(t)||(t=$(t)),D(e,t)}function R(e,t,r){if(!j(t))throw new TypeError;if(L(r)||(r=$(r)),!j(t))throw new TypeError;L(r)||(r=$(r));var n=ae(t,r,!1);return!L(n)&&n.OrdinaryDeleteMetadata(e,t,r)}function I(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!L(n)&&!U(n)){if(!Y(n))throw new TypeError;t=n}}return t}function _(e,t,r,n){for(var o=e.length-1;o>=0;--o){var s=(0,e[o])(t,r,n);if(!L(s)&&!U(s)){if(!j(s))throw new TypeError;n=s}}return n}function O(e,t,r){if(E(e,t,r))return!0;var n=re(t);return!U(n)&&O(e,n,r)}function E(e,t,r){var n=ae(t,r,!1);return!L(n)&&B(n.OrdinaryHasOwnMetadata(e,t,r))}function A(e,t,r){if(E(e,t,r))return x(e,t,r);var n=re(t);return U(n)?void 0:A(e,n,r)}function x(e,t,r){var n=ae(t,r,!1);if(!L(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function k(e,t,r,n){ae(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function C(e,t){var r=D(e,t),n=re(e);if(null===n)return r;var o=C(n,t);if(o.length<=0)return r;if(r.length<=0)return o;for(var s=new d,i=[],a=0,c=r;a<c.length;a++){var u=c[a];s.has(u)||(s.add(u),i.push(u))}for(var l=0,p=o;l<p.length;l++){u=p[l];s.has(u)||(s.add(u),i.push(u))}return i}function D(e,t){var r=ae(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function V(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function L(e){return void 0===e}function U(e){return null===e}function W(e){return"symbol"==typeof e}function j(e){return"object"==typeof e?null!==e:"function"==typeof e}function H(e,t){switch(V(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r="string",n=Z(e,o);if(void 0!==n){var s=n.call(e,r);if(j(s))throw new TypeError;return s}return N(e)}function N(e,t){var r,n,o=e.toString;if(z(o)&&!j(n=o.call(e)))return n;if(z(r=e.valueOf)&&!j(n=r.call(e)))return n;throw new TypeError}function B(e){return!!e}function q(e){return""+e}function $(e){var t=H(e);return W(t)?t:q(t)}function G(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function z(e){return"function"==typeof e}function Y(e){return"function"==typeof e}function K(e){switch(V(e)){case 3:case 4:return!0;default:return!1}}function Q(e,t){return e===t||e!=e&&t!=t}function Z(e,t){var r=e[t];if(null!=r){if(!z(r))throw new TypeError;return r}}function X(e){var t=Z(e,s);if(!z(t))throw new TypeError;var r=t.call(e);if(!j(r))throw new TypeError;return r}function J(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function re(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===l)return t;if(t!==l)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var o=n.constructor;return"function"!=typeof o||o===e?t:o}function ne(){var e,r,n,o;L(f)||void 0===t.Reflect||f in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=ie(t.Reflect));var s=new h,i={registerProvider:a,getProvider:u,setProvider:y};return i;function a(t){if(!Object.isExtensible(i))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case L(r):r=t;break;case r===t:break;case L(n):n=t;break;case n===t:break;default:void 0===o&&(o=new d),o.add(t)}}function c(t,s){if(!L(r)){if(r.isProviderFor(t,s))return r;if(!L(n)){if(n.isProviderFor(t,s))return r;if(!L(o))for(var i=X(o);;){var a=ee(i);if(!a)return;var c=J(a);if(c.isProviderFor(t,s))return te(i),c}}}if(!L(e)&&e.isProviderFor(t,s))return e}function u(e,t){var r,n=s.get(e);return L(n)||(r=n.get(t)),L(r)?(L(r=c(e,t))||(L(n)&&(n=new p,s.set(e,n)),n.set(t,r)),r):r}function l(e){if(L(e))throw new TypeError;return r===e||n===e||!L(o)&&o.has(e)}function y(e,t,r){if(!l(r))throw new Error("Metadata provider not registered.");var n=u(e,t);if(n!==r){if(!L(n))return!1;var o=s.get(e);L(o)&&(o=new p,s.set(e,o)),o.set(t,r)}return!0}}function oe(){var e;return!L(f)&&j(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[f]),L(e)&&(e=ne()),!L(f)&&j(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,f,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function se(e){var t=new h,r={isProviderFor:function(e,r){var n=t.get(e);return!L(n)&&n.has(r)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:o,OrdinaryGetOwnMetadata:s,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:c};return y.registerProvider(r),r;function n(n,o,s){var i=t.get(n),a=!1;if(L(i)){if(!s)return;i=new p,t.set(n,i),a=!0}var c=i.get(o);if(L(c)){if(!s)return;if(c=new p,i.set(o,c),!e.setProvider(n,o,r))throw i.delete(o),a&&t.delete(n),new Error("Wrong provider for target.")}return c}function o(e,t,r){var o=n(t,r,!1);return!L(o)&&B(o.has(e))}function s(e,t,r){var o=n(t,r,!1);if(!L(o))return o.get(e)}function i(e,t,r,o){n(r,o,!0).set(e,t)}function a(e,t){var r=[],o=n(e,t,!1);if(L(o))return r;for(var s=X(o.keys()),i=0;;){var a=ee(s);if(!a)return r.length=i,r;var c=J(a);try{r[i]=c}catch(e){try{te(s)}finally{throw e}}i++}}function c(e,r,o){var s=n(r,o,!1);if(L(s))return!1;if(!s.delete(e))return!1;if(0===s.size){var i=t.get(r);L(i)||(i.delete(o),0===i.size&&t.delete(i))}return!0}}function ie(e){var t=e.defineMetadata,r=e.hasOwnMetadata,n=e.getOwnMetadata,o=e.getOwnMetadataKeys,s=e.deleteMetadata,i=new h;return{isProviderFor:function(e,t){var r=i.get(e);return!(L(r)||!r.has(t))||!!o(e,t).length&&(L(r)&&(r=new d,i.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:o,OrdinaryDeleteMetadata:s}}function ae(e,t,r){var n=y.getProvider(e,t);if(!L(n))return n;if(r){if(y.setProvider(e,t,m))return m;throw new Error("Illegal state.")}}function ce(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[s]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}();return function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,Q(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,n)},t.prototype.values=function(){return new r(this._keys,this._values,o)},t.prototype.entries=function(){return new r(this._keys,this._values,i)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[s]=function(){return this.entries()},t.prototype._find=function(e,t){if(!Q(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(Q(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();function n(e,t){return e}function o(e,t){return t}function i(e,t){return[e,t]}}function ue(){return function(){function e(){this._map=new p}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[s]=function(){return this.keys()},e}()}function le(){var e=16,t=u.create(),n=o();return function(){function e(){this._key=o()}return e.prototype.has=function(e){var t=s(e,!1);return void 0!==t&&u.has(t,this._key)},e.prototype.get=function(e){var t=s(e,!1);return void 0!==t?u.get(t,this._key):void 0},e.prototype.set=function(e,t){return s(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=s(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=o()},e}();function o(){var e;do{e="@@WeakMap@@"+c()}while(u.has(t,e));return t[e]=!0,e}function s(e,t){if(!r.call(e,n)){if(!t)return;Object.defineProperty(e,n,{value:u.create()})}return e[n]}function i(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function a(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):i(t,e),t}return i(new Array(e),e)}function c(){var t=a(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",n=0;n<e;++n){var o=t[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function pe(e){return e.__=void 0,delete e.__,e}e("decorate",g),e("metadata",b),e("defineMetadata",v),e("hasMetadata",w),e("hasOwnMetadata",S),e("getMetadata",F),e("getOwnMetadata",M),e("getMetadataKeys",T),e("getOwnMetadataKeys",P),e("deleteMetadata",R)}(r,t),void 0===t.Reflect&&(t.Reflect=e)}()}(e||(e={}));const t="00001623-1212-efde-1623-785feabcd123";var r,n,o,s,i,a,c,u;!function(e){e[e.properties=1]="properties",e[e.action=2]="action",e[e.attachedIO=4]="attachedIO",e[e.genericError=5]="genericError",e[e.portInformationRequest=33]="portInformationRequest",e[e.portModeInformationRequest=34]="portModeInformationRequest",e[e.portInputFormatSetupSingle=65]="portInputFormatSetupSingle",e[e.portInformation=67]="portInformation",e[e.portModeInformation=68]="portModeInformation",e[e.portValueSingle=69]="portValueSingle",e[e.portInputFormatSetupSingleHandshake=71]="portInputFormatSetupSingleHandshake",e[e.virtualPortSetup=97]="virtualPortSetup",e[e.portOutputCommand=129]="portOutputCommand",e[e.portOutputCommandFeedback=130]="portOutputCommandFeedback"}(r||(r={})),function(e){e[e.switchOff=1]="switchOff",e[e.disconnect=2]="disconnect",e[e.willSwitchOff=48]="willSwitchOff",e[e.willDisconnect=49]="willDisconnect"}(n||(n={})),function(e){e[e.name=0]="name",e[e.rawRange=1]="rawRange",e[e.pctRange=2]="pctRange",e[e.siRange=3]="siRange",e[e.symbol=4]="symbol",e[e.mapping=5]="mapping",e[e.motorBias=7]="motorBias",e[e.capabilityBits=8]="capabilityBits",e[e.valueFormat=9]="valueFormat"}(o||(o={})),function(e){e[e.portValue=0]="portValue",e[e.modeInfo=1]="modeInfo"}(s||(s={})),function(e){e[e.modeInfo=1]="modeInfo"}(i||(i={})),function(e){e[e.Detached=0]="Detached",e[e.Attached=1]="Attached",e[e.AttachedVirtual=2]="AttachedVirtual"}(a||(a={})),function(e){e[e.motor=1]="motor",e[e.systemTrainMotor=2]="systemTrainMotor",e[e.button=5]="button",e[e.ledLight=8]="ledLight",e[e.voltage=20]="voltage",e[e.current=21]="current",e[e.piezoTone=22]="piezoTone",e[e.rgbLight=23]="rgbLight",e[e.externalTiltSensor=34]="externalTiltSensor",e[e.motionSensor=35]="motionSensor",e[e.visionSensor=37]="visionSensor",e[e.externalMotorWithTacho=38]="externalMotorWithTacho",e[e.internalMotorWithTacho=39]="internalMotorWithTacho",e[e.internalTilt=40]="internalTilt",e[e.largeTechnicMotor=46]="largeTechnicMotor",e[e.xLargeTechnicMotor=47]="xLargeTechnicMotor",e[e.gestureSensor=54]="gestureSensor",e[e.handsetButtonGroup=55]="handsetButtonGroup",e[e.accelerometerSensor=57]="accelerometerSensor",e[e.gyroscopeSensor=58]="gyroscopeSensor",e[e.tiltSensor=59]="tiltSensor",e[e.temperatureSensor=60]="temperatureSensor",e[e.mediumTechnicAngularMotor=75]="mediumTechnicAngularMotor",e[e.largeTechnicAngularMotor=76]="largeTechnicAngularMotor"}(c||(c={})),function(e){e[e.setProperty=1]="setProperty",e[e.enableUpdates=2]="enableUpdates",e[e.disableUpdates=3]="disableUpdates",e[e.reset=4]="reset",e[e.requestUpdate=5]="requestUpdate",e[e.update=6]="update"}(u||(u={}));var l,p;!function(e){e[e.advertisingName=1]="advertisingName",e[e.button=2]="button",e[e.firmwareVersion=3]="firmwareVersion",e[e.hardwareVersion=4]="hardwareVersion",e[e.RSSI=5]="RSSI",e[e.batteryVoltage=6]="batteryVoltage",e[e.manufacturerName=8]="manufacturerName",e[e.systemTypeId=11]="systemTypeId",e[e.primaryMacAddress=13]="primaryMacAddress"}(l||(l={})),function(e){e[e.WeDoHub=0]="WeDoHub",e[e.DuploTrain=1]="DuploTrain",e[e.BoostHub=2]="BoostHub",e[e.TwoPortHub=3]="TwoPortHub",e[e.TwoPortHandset=4]="TwoPortHandset",e[e.Unknown=5]="Unknown",e[e.FourPortHub=6]="FourPortHub"}(p||(p={}));const d={0:p.WeDoHub,32:p.DuploTrain,64:p.BoostHub,65:p.TwoPortHub,66:p.TwoPortHandset,128:p.FourPortHub};var h,f;!function(e){e.speed="SPEED",e.position="POS",e.absolutePosition="APOS",e.power="POWER",e.color="COL O",e.rgb="RGB O",e.currentS="CUR S",e.currentL="CUR L",e.voltageS="VLT S",e.voltageL="VLT L",e.handsetRCKey="RCKEY",e.handsetKeyA="KEYA",e.handsetKeyR="KEYR",e.handsetKeyD="KEYD",e.handsetKeySD="KEYSD",e.raw="RAW",e.impact="IMP",e.load="LOAD",e.temperature="TEMP",e.gravity="GRV",e.gesture="GEST",e.lpf2Train="LPF2-TRAIN",e.lpf2MMotor="LPF2-MMOTOR"}(h||(h={})),function(e){e.percent="PCT",e.degree="DEG",e.milliAmps="mA",e.milliVolts="mV",e.button="btn",e.count="CNT",e.generic="",e.milliG="mG"}(f||(f={}));const y={maxSpeed:100,minSpeed:-100,minPower:0,maxPower:100,minRawAngle:-134217727,maxRawAngle:134217727,minServoDegreesRange:15,maxServoDegreesRange:360,maxAccDecTime:1e4,minAccDecTime:0};var m,g,b,v,w,S,F,M;!function(e){e[e.float=0]="float",e[e.hold=126]="hold",e[e.brake=127]="brake"}(m||(m={})),function(e){e[e.bufferIfNecessary=0]="bufferIfNecessary",e[e.executeImmediately=16]="executeImmediately"}(g||(g={})),function(e){e[e.noAction=0]="noAction",e[e.commandFeedback=1]="commandFeedback"}(b||(b={})),function(e){e[e.dontUseProfiles=0]="dontUseProfiles",e[e.useAccelerationProfile=1]="useAccelerationProfile",e[e.useDecelerationProfile=2]="useDecelerationProfile",e[e.useAccelerationAndDecelerationProfiles=3]="useAccelerationAndDecelerationProfiles"}(v||(v={})),function(e){e[e.setAccTime=5]="setAccTime",e[e.setDecTime=6]="setDecTime",e[e.startSpeed=7]="startSpeed",e[e.startSpeedSynchronized=8]="startSpeedSynchronized",e[e.startSpeedForDegrees=11]="startSpeedForDegrees",e[e.gotoAbsolutePosition=13]="gotoAbsolutePosition",e[e.gotoAbsolutePositionSynchronized=14]="gotoAbsolutePositionSynchronized",e[e.writeDirectModeData=81]="writeDirectModeData"}(w||(w={})),function(e){e[e.bufferEmptyCommandInProgress=1]="bufferEmptyCommandInProgress",e[e.bufferEmptyCommandCompleted=2]="bufferEmptyCommandCompleted",e[e.currentCommandDiscarded=4]="currentCommandDiscarded",e[e.idle=8]="idle",e[e.busyOrFull=16]="busyOrFull",e[e.executionError=32]="executionError"}(S||(S={})),function(e){e[e.ACK=1]="ACK",e[e.MACK=2]="MACK",e[e.bufferOverflow=3]="bufferOverflow",e[e.timeout=4]="timeout",e[e.commandNotRecognized=5]="commandNotRecognized",e[e.invalidUse=6]="invalidUse",e[e.overcurrent=7]="overcurrent",e[e.internalError=8]="internalError"}(F||(F={})),function(e){e[e.None=0]="None",e[e.Plus=1]="Plus",e[e.Red=127]="Red",e[e.Minus=255]="Minus"}(M||(M={}));var T;!function(e){e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warning=2]="Warning",e[e.Error=3]="Error"}(T||(T={}));const P={motor:{[h.power]:0,[h.position]:2,[h.absolutePosition]:3,[h.lpf2Train]:0,[h.lpf2MMotor]:0},voltage:0,tilt:0,temperature:0,rgbLightRgbColor:1};var R,I;!function(e){e[e.Disconnect=0]="Disconnect",e[e.Connect=1]="Connect"}(R||(R={})),function(e){e[e.Transient=0]="Transient",e[e.Singleton=1]="Singleton",e[e.ResolutionScoped=2]="ResolutionScoped",e[e.ContainerScoped=3]="ContainerScoped"}(I||(I={}));var _=I,O=function(e,t){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},O(e,t)};function E(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}O(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function A(e,t,r,n){var o,s=arguments.length,i=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(s<3?o(i):s>3?o(t,r,i):o(t,r))||i);return s>3&&i&&Object.defineProperty(t,r,i),i}function x(e,t){return function(r,n){t(r,n,e)}}function k(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function C(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))}function D(e,t){var r,n,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function V(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function L(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function U(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(L(arguments[t]));return e}function W(e,t,r){if(r||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function j(e){return this instanceof j?(this.v=e,this):new j(e)}function H(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function i(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))},t&&(n[e]=t(n[e])))}function a(e,t){try{(r=o[e](t)).value instanceof j?Promise.resolve(r.value.v).then(c,u):l(s[0][2],r)}catch(e){l(s[0][3],e)}var r}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function N(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=V(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;var B="injectionTokens";function q(e){return!!e.useClass}function $(e){return!!e.useFactory}var G=function(){function e(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return e.prototype.createProxy=function(e){var t,r=this,n=!1;return new Proxy({},this.createHandler((function(){return n||(t=e(r.wrap()),n=!0),t})))},e.prototype.createHandler=function(e){var t={};return this.reflectMethods.forEach((function(r){t[r]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t[0]=e(),Reflect[r].apply(void 0,U(t))}})),t},e}();function z(e){return"string"==typeof e||"symbol"==typeof e}function Y(e){return"object"==typeof e&&"token"in e&&"transform"in e}function K(e){return!!e.useToken}function Q(e){return null!=e.useValue}var Z=function(){function e(){this._registryMap=new Map}return e.prototype.entries=function(){return this._registryMap.entries()},e.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},e.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},e.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},e.prototype.setAll=function(e,t){this._registryMap.set(e,t)},e.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},e.prototype.clear=function(){this._registryMap.clear()},e.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},e}(),X=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return E(t,e),t}(Z),J=function(){this.scopedResolutions=new Map};function ee(e,t,r){var n,o,s=L(e.toString().match(/constructor\(([\w, ]+)\)/)||[],2)[1],i=function(e,t){return null===e?"at position #"+t:'"'+e.split(",")[t].trim()+'" at position #'+t}(void 0===s?null:s,t);return n="Cannot inject the dependency "+i+' of "'+e.name+'" constructor. Reason:',void 0===o&&(o=" "),U([n],r.message.split("\n").map((function(e){return o+e}))).join("\n")}var te=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return E(t,e),t}(Z),re=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return E(t,e),t}(Z),ne=function(){this.preResolution=new te,this.postResolution=new re},oe=new Map,se=function(){function e(e){this.parent=e,this._registry=new X,this.interceptors=new ne,this.disposed=!1,this.disposables=new Set}return e.prototype.register=function(e,t,r){var n;if(void 0===r&&(r={lifecycle:_.Transient}),this.ensureNotDisposed(),n=function(e){return q(e)||Q(e)||K(e)||$(e)}(t)?t:{useClass:t},K(n))for(var o=[e],s=n;null!=s;){var i=s.useToken;if(o.includes(i))throw new Error("Token registration cycle detected! "+U(o,[i]).join(" -> "));o.push(i);var a=this._registry.get(i);s=a&&K(a.provider)?a.provider:null}if((r.lifecycle===_.Singleton||r.lifecycle==_.ContainerScoped||r.lifecycle==_.ResolutionScoped)&&(Q(n)||$(n)))throw new Error('Cannot use lifecycle "'+_[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:n,options:r}),this},e.prototype.registerType=function(e,t){return this.ensureNotDisposed(),z(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},e.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},e.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),z(e)){if(z(t))return this.register(e,{useToken:t},{lifecycle:_.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:_.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return t&&!z(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:_.Singleton})},e.prototype.resolve=function(e,t){void 0===t&&(t=new J),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&z(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),r){var n=this.resolveRegistration(r,t);return this.executePostResolutionInterceptor(e,n,"Single"),n}if(function(e){return"function"==typeof e||e instanceof G}(e)){n=this.construct(e,t);return this.executePostResolutionInterceptor(e,n,"Single"),n}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},e.prototype.executePreResolutionInterceptor=function(e,t){var r,n;if(this.interceptors.preResolution.has(e)){var o=[];try{for(var s=V(this.interceptors.preResolution.getAll(e)),i=s.next();!i.done;i=s.next()){var a=i.value;"Once"!=a.options.frequency&&o.push(a),a.callback(e,t)}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,o)}},e.prototype.executePostResolutionInterceptor=function(e,t,r){var n,o;if(this.interceptors.postResolution.has(e)){var s=[];try{for(var i=V(this.interceptors.postResolution.getAll(e)),a=i.next();!a.done;a=i.next()){var c=a.value;"Once"!=c.options.frequency&&s.push(c),c.callback(e,t,r)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}this.interceptors.postResolution.setAll(e,s)}},e.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===_.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var r,n=e.options.lifecycle===_.Singleton,o=e.options.lifecycle===_.ContainerScoped,s=n||o;return r=Q(e.provider)?e.provider.useValue:K(e.provider)?s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):q(e.provider)?s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):$(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t),e.options.lifecycle===_.ResolutionScoped&&t.scopedResolutions.set(e,r),r},e.prototype.resolveAll=function(e,t){var r=this;void 0===t&&(t=new J),this.ensureNotDisposed();var n=this.getAllRegistrations(e);if(!n&&z(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),n){var o=n.map((function(e){return r.resolveRegistration(e,t)}));return this.executePostResolutionInterceptor(e,o,"All"),o}var s=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,s,"All"),s},e.prototype.isRegistered=function(e,t){return void 0===t&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},e.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},e.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var r=V(this._registry.entries()),n=r.next();!n.done;n=r.next()){var o=L(n.value,2),s=o[0],i=o[1];this._registry.setAll(s,i.filter((function(e){return!Q(e.provider)})).map((function(e){return e.instance=void 0,e})))}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.createChildContainer=function(){var t,r;this.ensureNotDisposed();var n=new e(this);try{for(var o=V(this._registry.entries()),s=o.next();!s.done;s=o.next()){var i=L(s.value,2),a=i[0],c=i[1];c.some((function(e){return e.options.lifecycle===_.ContainerScoped}))&&n._registry.setAll(a,c.map((function(e){return e.options.lifecycle===_.ContainerScoped?{provider:e.provider,options:e.options}:e})))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return n},e.prototype.beforeResolution=function(e,t,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:r})},e.prototype.afterResolution=function(e,t,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:r})},e.prototype.dispose=function(){return C(this,void 0,void 0,(function(){var e;return D(this,(function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach((function(t){var r=t.dispose();r&&e.push(r)})),[4,Promise.all(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},e.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},e.prototype.construct=function(e,t){var r=this;if(e instanceof G)return e.createProxy((function(e){return r.resolve(e,t)}));var n,o=function(){var n=oe.get(e);if(!n||0===n.length){if(0===e.length)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=n.map(r.resolveParams(t,e));return new(e.bind.apply(e,U([void 0],o)))}();return"function"!=typeof(n=o).dispose||n.dispose.length>0||this.disposables.add(o),o},e.prototype.resolveParams=function(e,t){var r=this;return function(n,o){var s,i,a,c;try{return"object"==typeof(c=n)&&"token"in c&&"multiple"in c?Y(n)?n.multiple?(s=r.resolve(n.transform)).transform.apply(s,U([r.resolveAll(n.token)],n.transformArgs)):(i=r.resolve(n.transform)).transform.apply(i,U([r.resolve(n.token,e)],n.transformArgs)):n.multiple?r.resolveAll(n.token):r.resolve(n.token,e):Y(n)?(a=r.resolve(n.transform,e)).transform.apply(a,U([r.resolve(n.token,e)],n.transformArgs)):r.resolve(n,e)}catch(e){throw new Error(ee(t,o,e))}}},e.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},e}(),ie=new se;function ae(e){return t=e,function(e,r,n){var o=Reflect.getOwnMetadata(B,e)||{};o[n]=t,Reflect.defineMetadata(B,o,e)};var t}function ce(){return function(e){oe.set(e,function(e){var t=Reflect.getMetadata("design:paramtypes",e)||[],r=Reflect.getOwnMetadata(B,e)||{};return Object.keys(r).forEach((function(e){t[+e]=r[e]})),t}(e))}}if("undefined"==typeof Reflect||!Reflect.getMetadata)throw new Error("tsyringe requires a reflect polyfill. Please add 'import \"reflect-metadata\"' to the top of your entry point.");function ue(e,t){return!!(e&1<<t)}function le(e,t){return(e<<8)+t}function pe(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]}function de(e){return[255&e,e>>8&255]}function he(e){return[...e].reduce(((e,t,r)=>e+(t<<8*r)),0)}function fe(e){return e>32767?e-65536:e}function ye(...e){const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r}function me(e){return`message type '${`${ge(e.header.messageType)} (${r[e.header.messageType]})`}', payload ${[...e.payload].map((e=>ge(e))).join(" ")}`}function ge(e){return`0x${e.toString(16).padStart(2,"0")}`}class be{rawValueDivisor;constructor(e){this.rawValueDivisor=e}fromRawValue(e){return he(e)/this.rawValueDivisor}toValueThreshold(e){return e*this.rawValueDivisor}}let ve=class{fallbackRawValueDivisor=400;rawValueDivisors={[p.TwoPortHub]:380,[p.FourPortHub]:420,[p.TwoPortHandset]:500};createForHubType(e){return new be(this.getRawValueDivisor(e))}getRawValueDivisor(e){const t=this.rawValueDivisors[e];return void 0===t?this.fallbackRawValueDivisor:t}};ve=A([ce()],ve);let we=class{fromRawValue(e){return fe(he(e))}toValueThreshold(e){return e}};we=A([ce()],we);let Se=class{fromRawValue(e){return function(e){return e>2147483647?e-4294967296:e}(he(e))}toValueThreshold(e){return e}};Se=A([ce()],Se);let Fe=class{rawValueDivisor=10;fromRawValue(e){return fe(he(e))/this.rawValueDivisor}toValueThreshold(e){return e*this.rawValueDivisor}};Fe=A([ce()],Fe);let Me=class{fromRawValue(e){const t=he(e.slice(0,2)),r=he(e.slice(2,4));return{roll:-fe(he(e.slice(4,6)))%180|0,pitch:fe(r)%180|0,yaw:-fe(t)%180|0}}toValueThreshold(e){return Math.min(Math.abs(e.roll),Math.abs(e.pitch),Math.abs(e.yaw))}};Me=A([ce()],Me);class Te{fromRawValue(e){return{red:e[0],green:e[1],blue:e[2]}}toValueThreshold(e){return Math.min(e.red,e.green,e.blue)}}class Pe{static voltage(e){return ie.resolve(ve).createForHubType(e)}static get absolutePosition(){return ie.resolve(we)}static get position(){return ie.resolve(Se)}static get temperature(){return ie.resolve(Fe)}static get tilt(){return ie.resolve(Me)}static get color(){return ie.resolve(Te)}}class Re extends Error{type="Connection error";constructor(e){super(e)}}let Ie=class{createInvalidPropertyValueError(e,t){return new Re(`Invalid property value ${t} for property ${l[e]}`)}createGattUnavailableError(){return new Re("Hub GATT is unavailable")}createGattConnectionError(){return new Re("Hub GATT connection error")}};Ie=A([ce()],Ie);class _e extends Error{code;commandType;constructor(e,t){super(`Generic error ${F[e]} for command ${r[t]}`),this.code=e,this.commandType=t}}class Oe{logger;logMessageTypes;logMessageTypesSet;constructor(e,t){this.logger=e,this.logMessageTypes=t,this.logMessageTypesSet=new Set("all"===t?[]:t)}handle(e){if("all"===this.logMessageTypes||this.logMessageTypesSet.has(e.header.messageType)){const t=me(e);this.logger.debug(t)}return e}}function Ee(e){return"function"==typeof e}function Ae(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var xe=Ae((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}}));function ke(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var Ce=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=V(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(Ee(c))try{c()}catch(e){o=e instanceof xe?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=V(u),p=l.next();!p.done;p=l.next()){var d=p.value;try{Le(d)}catch(e){o=null!=o?o:[],e instanceof xe?o=W(W([],L(o)),L(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{p&&!p.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new xe(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)Le(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).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)&&ke(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&ke(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),De=Ce.EMPTY;function Ve(e){return e instanceof Ce||e&&"closed"in e&&Ee(e.remove)&&Ee(e.add)&&Ee(e.unsubscribe)}function Le(e){Ee(e)?e():e.unsubscribe()}var Ue={Promise:void 0},We=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,W([e,t],L(r)))};function je(e){We((function(){throw e}))}function He(){}function Ne(e){e()}var Be=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,Ve(t)&&t.add(r)):r.destination=ze,r}return E(t,e),t.create=function(e,t,r){return new $e(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Ce),qe=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){Ge(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Ge(e)}else Ge(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Ge(e)}},e}(),$e=function(e){function t(t,r,n){var o,s=e.call(this)||this;return o=Ee(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,s.destination=new qe(o),s}return E(t,e),t}(Be);function Ge(e){je(e)}var ze={closed:!0,next:He,error:function(e){throw e},complete:He},Ye="function"==typeof Symbol&&Symbol.observable||"@@observable";function Ke(e){return e}var Qe=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,s=(n=e)&&n instanceof Be||function(e){return e&&Ee(e.next)&&Ee(e.error)&&Ee(e.complete)}(n)&&Ve(n)?e:new $e(e,t,r);return Ne((function(){var e=o,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?o._subscribe(s):o._trySubscribe(s))})),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=Ze(t))((function(t,n){var o=new $e({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[Ye]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?Ke:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Ze(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function Ze(e){var t;return null!==(t=null!=e?e:Ue.Promise)&&void 0!==t?t:Promise}function Xe(e){return function(t){if(function(e){return Ee(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function Je(e,t,r,n,o){return new et(e,t,r,n,o)}var et=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return E(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(Be),tt=Ae((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),rt=function(e){function t(){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 E(t,e),t.prototype.lift=function(e){var t=new nt(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new tt},t.prototype.next=function(e){var t=this;Ne((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=V(t.currentObservers),s=o.next();!s.done;s=o.next()){s.value.next(e)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;Ne((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;Ne((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,s=r.observers;return n||o?De:(this.currentObservers=null,s.push(e),new Ce((function(){t.currentObservers=null,ke(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new Qe;return e.source=this,e},t.create=function(e,t){return new nt(e,t)},t}(Qe),nt=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return E(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:De},t}(rt),ot=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return E(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){var e=this,t=e.hasError,r=e.thrownError,n=e._value;if(t)throw r;return this._throwIfClosed(),n},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(rt),st={now:function(){return(st.delegate||Date).now()},delegate:void 0},it=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=st);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=r,o._timestampProvider=n,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,r),o}return E(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,o=r._buffer,s=r._infiniteTimeWindow,i=r._timestampProvider,a=r._windowTime;n||(o.push(t),!s&&o.push(i.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),o=0;o<n.length&&!e.closed;o+=r?1:2)e.next(n[o]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,o=e._infiniteTimeWindow,s=(o?1:2)*t;if(t<1/0&&s<n.length&&n.splice(0,n.length-s),!o){for(var i=r.now(),a=0,c=1;c<n.length&&n[c]<=i;c+=2)a=c;a&&n.splice(0,a+1)}},t}(rt),at=function(e){function t(t,r){return e.call(this)||this}return E(t,e),t.prototype.schedule=function(e,t){return this},t}(Ce),ct=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,W([e,t],L(r)))},ut=function(e){return clearInterval(e)},lt=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return E(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,o=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(o,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),ct(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&ut(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,ke(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(at),pt=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=st.now,e}(),dt=new(function(e){function t(t,r){void 0===r&&(r=pt.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return E(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}(pt))(lt),ht=dt,ft=new Qe((functio