Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@keiser/echip-webusb

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keiser/echip-webusb - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

4

index.d.ts
// Generated by dts-bundle v0.7.3
export default class EChipReaderWatcher extends USBDevice {
export class EChipReaderWatcher extends USBDevice {
constructor();

@@ -10,2 +10,4 @@ stop(): void;

}
const _default: EChipReaderWatcher;
export default _default;

@@ -12,0 +14,0 @@ export class USBDevice {

@@ -8,2 +8,2 @@ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EChip=t():e.EChip=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=12)}([function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));class n{static info(e){this.enabled()&&console.info(e)}static warn(e){this.enabled()&&console.warn(e)}static error(e){this.enabled()&&console.error(e)}static enabled(){return!0===window.DEBUG_ECHIP}}},function(e,t,r){"use strict";(function(e){

*/
var n=r(8),i=r(9),s=r(10);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(this,e)}return u(this,e,t,r)}function u(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=l(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),i=(e=a(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(c.isBuffer(t)){var r=0|d(t.length);return 0===(e=a(e,r)).length?e:(t.copy(e,0,0,r),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):l(e,t);if("Buffer"===t.type&&s(t.data))return l(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function h(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function f(e,t){if(h(t),e=a(e,t<0?0:0|d(t)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function l(e,t){var r=t.length<0?0:0|d(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function d(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function w(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,r);case"utf8":case"utf-8":return B(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return R(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,i){var s,o=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,r/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var h=-1;for(s=r;s<a;s++)if(u(e,s)===u(t,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===c)return h*o}else-1!==h&&(s-=s-h),h=-1}else for(r+c>a&&(r=a-c),s=r;s>=0;s--){for(var f=!0,l=0;l<c;l++)if(u(e,s+l)!==u(t,l)){f=!1;break}if(f)return s}return-1}function m(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function b(e,t,r,n){return F(j(t,e.length-r),e,r,n)}function D(e,t,r,n){return F(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function E(e,t,r,n){return D(e,t,r,n)}function A(e,t,r,n){return F(W(t),e,r,n)}function _(e,t,r,n){return F(function(e,t){for(var r,n,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}(t,e.length-r),e,r,n)}function T(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function B(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s,o,a,c,u=e[i],h=null,f=u>239?4:u>223?3:u>191?2:1;if(i+f<=r)switch(f){case 1:u<128&&(h=u);break;case 2:128==(192&(s=e[i+1]))&&(c=(31&u)<<6|63&s)>127&&(h=c);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,f=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=f}return function(e){var t=e.length;if(t<=S)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=S));return r}(n)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=o(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,r){return u(null,e,t,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,r){return function(e,t,r,n){return h(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},c.allocUnsafe=function(e){return f(null,e)},c.allocUnsafeSlow=function(e){return f(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=c.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?B(this,0,e):w.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,r,n,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),u=this.slice(n,i),h=e.slice(t,r),f=0;f<a;++f)if(u[f]!==h[f]){s=u[f],o=h[f];break}return s<o?-1:o<s?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return g(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return g(this,e,t,r,!1)},c.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return D(this,e,t,r);case"latin1":case"binary":return E(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function I(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function R(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function P(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=t;s<r;++s)i+=q(e[s]);return i}function U(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function C(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,r,n,i,s){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i<s;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function M(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i<s;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function x(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(e,t,r,n,s){return s||x(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function L(e,t,r,n,s){return s||x(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;r=new c(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+e]}return r},c.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},c.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUInt8=function(e,t){return t||C(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||C(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||C(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return t||C(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||C(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){t||C(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||C(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||C(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||C(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||C(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[t]=255&e;++s<r&&(i*=256);)this[t+s]=e/i&255;return t+r},c.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<r&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return N(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return N(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,s=n-r;if(this===e&&r<t&&t<n)for(i=s-1;i>=0;--i)e[i+t]=this[i+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},c.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var o=c.isBuffer(e)?e:j(new c(e,n).toString()),a=o.length;for(s=0;s<r-t;++s)this[s+t]=o[s%a]}return this};var Y=/[^+\/0-9A-Za-z-_]/g;function q(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var r;t=t||1/0;for(var n=e.length,i=null,s=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function W(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Y,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(7))},function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return i}));class n{constructor(){this.listeners=[]}on(e){return this.listeners.push(e),{dispose:()=>this.off(e)}}off(e){let t=this.listeners.indexOf(e);t>-1&&this.listeners.splice(t,1)}emit(e){this.listeners.forEach(t=>t(e))}}class i extends Event{constructor(e,t){super(e),this.device=t.device}}},function(e,t,r){"use strict";(function(e){r.d(t,"a",(function(){return s}));var n=r(2);class i{constructor(e){this._opened=!1,this._claimedInterface=null,this.nodeUsbDevice=e,this.deviceClass=e.deviceDescriptor.bDeviceClass,this.deviceSubclass=e.deviceDescriptor.bDeviceSubClass,this.deviceProtocol=e.deviceDescriptor.bDeviceProtocol,this.vendorId=e.deviceDescriptor.idVendor,this.productId=e.deviceDescriptor.idProduct}get configuration(){return this.configurationTransform(this.nodeUsbDevice.configDescriptor)}get configurations(){return this.nodeUsbDevice.allConfigDescriptors.map(e=>this.configurationTransform(e))}get opened(){return this._opened}open(){try{this.nodeUsbDevice.open(),this._opened=!0}catch(e){return Promise.reject(e)}return Promise.resolve()}close(){try{this.nodeUsbDevice.close()}catch(e){return Promise.reject(e)}return Promise.resolve()}async selectConfiguration(e){return new Promise((t,r)=>{this.nodeUsbDevice.setConfiguration(e,e=>{if(e)return r(e);t()})})}async claimInterface(e){try{const t=this.nodeUsbDevice.interfaces.find(t=>t.interfaceNumber===e);if(!t)throw new Error("Interface not found");return t.claim(),this._claimedInterface=t,Promise.resolve()}catch(e){return Promise.reject(e)}}releaseInterface(e){return new Promise((t,r)=>{const n=this.nodeUsbDevice.interfaces.find(t=>t.interfaceNumber===e);if(!n)return r("Interface not found");n.release(e=>{if(e)return r(e);this._claimedInterface=null,t()})})}selectAlternateInterface(e,t){return new Promise((r,n)=>{const i=this.nodeUsbDevice.interfaces.find(t=>t.interfaceNumber===e);if(!i)return n("Interface not found");i.setAltSetting(t,e=>{if(e)return n(e);r()})})}controlTransferIn(e,t){return new Promise((r,n)=>{this.nodeUsbDevice.controlTransfer(this.requestTypeTransform(e.requestType),e.request,e.value,e.index,t,(e,t)=>e?n(e.message):t?void r({data:new DataView(t),status:"ok"}):n("No buffer returned"))})}controlTransferOut(t,r){return new Promise((n,i)=>{this.nodeUsbDevice.controlTransfer(this.requestTypeTransform(t.requestType),t.request,t.value,t.index,r?this.arrayBufferToBuffer(r):e.from(""),(e,t)=>{if(e)return i(e.message);n({bytesWritten:r?r.byteLength:0,status:"ok"})})})}transferIn(e,t){return new Promise((r,n)=>{if(!this._claimedInterface)return n("No interface claimed");const i=this._claimedInterface.endpoint(e);if(!i||"in"!==i.direction)return n("No endpoint found");i.transfer(t,(e,t)=>{if(e)return n(e.message);r({data:new DataView(t.buffer,0,t.length),status:"ok"})})})}transferOut(e,t){return new Promise((r,n)=>{if(!this._claimedInterface)return n("No interface claimed");const i=this._claimedInterface.endpoint(e);if(!i||"out"!==i.direction)return n("No endpoint found");i.transfer(this.arrayBufferToBuffer(t),e=>{if(e)return n(e.message);r({bytesWritten:t?t.byteLength:0,status:"ok"})})})}reset(){return new Promise((e,t)=>{this.nodeUsbDevice.reset(r=>{if(r)return navigator.usb.dispatchEvent(new n.b("disconnect",{device:this.asWebUSBDevice()})),t(r);e()})})}asWebUSBDevice(){return this}configurationTransform(e){const t=e.interfaces.reduce((e,t)=>e.concat(t),[]);return{configurationValue:e.bConfigurationValue,configurationName:"",interfaces:t.map(t=>this.interfaceTransform(e,t))}}interfaceTransform(e,t){const r=e.interfaces.reduce((e,t)=>e.concat(t),[]);return{interfaceNumber:t.bInterfaceNumber,alternate:this.interfaceAltTransform(t,this.nodeUsbDevice.interface(t.bInterfaceNumber)),alternates:r.map(e=>this.interfaceAltTransform(t,this.nodeUsbDevice.interface(e.bInterfaceNumber)))}}interfaceAltTransform(e,t){return{alternateSetting:e.bAlternateSetting,interfaceClass:e.bInterfaceClass,interfaceSubclass:e.bInterfaceSubClass,interfaceProtocol:e.bInterfaceProtocol,interfaceName:"",endpoints:t.endpoints.map(e=>this.endpointTransform(e))}}endpointTransform(e){return{endpointNumber:e.descriptor.bEndpointAddress,direction:e.direction,type:this.endpointTypeTransform(e.transferType),packetSize:e.descriptor.wMaxPacketSize}}endpointTypeTransform(e){switch(e){case window.node_usb.LIBUSB_TRANSFER_TYPE_BULK:return"bulk";case window.node_usb.LIBUSB_TRANSFER_TYPE_INTERRUPT:return"interrupt";case window.node_usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:return"isochronous"}}requestTypeTransform(e){switch(e){case"standard":return window.node_usb.LIBUSB_REQUEST_TYPE_STANDARD;case"class":return window.node_usb.LIBUSB_REQUEST_TYPE_CLASS;case"vendor":return window.node_usb.LIBUSB_REQUEST_TYPE_VENDOR}}arrayBufferToBuffer(t){return t instanceof ArrayBuffer?e.from(t):e.from("")}}function s(e){return new i(e)}}).call(this,r(1).Buffer)},function(e,t,r){"use strict";(function(e){r.d(t,"a",(function(){return d}));var n=r(0),i=r(6),s=r(5);const o=64,a=500,c=200,u=1,h=e=>12===e[0]&&0!==e[7],f=()=>new Promise(e=>setTimeout(()=>{e()},c));class l{constructor(e){const t=new Uint8Array(e.buffer);this.commCommandBufferStatus=t[11],this.dataOutBufferStatus=t[12],this.dataInBufferStatus=t[13],this.detectKey=165===t[16],this.data=t.slice(16,t.length)}}class d{constructor(e,t=(e=>{})){this.mutex=new s.Mutex,this.searching=!1,this.usbDevice=e,this.onDetectKeys=t;const r=this.usbDevice.configurations[0].interfaces[0].alternates[u];this.interrupt=r.endpoints[0],this.bulkIn=r.endpoints[1],this.bulkOut=r.endpoints[2]}async claim(){const e=this.usbDevice.configurations[0],t=e.interfaces[0];try{null!==this.usbDevice.configuration&&void 0!==this.usbDevice.configuration&&this.usbDevice.configuration.configurationValue===e.configurationValue||await this.usbDevice.selectConfiguration(e.configurationValue),await this.usbDevice.claimInterface(t.interfaceNumber),await this.usbDevice.selectAlternateInterface(t.interfaceNumber,t.alternates[u].alternateSetting),await this.deviceReset()}catch(e){throw new Error("1-Wire Device interface cannot be claimed.")}return!0}async startSearch(){this.searching||(this.searching=!0,this.awaitKey())}async close(){this.searching=!1;let e=await this.mutex.acquire();try{this.usbDevice.configuration&&this.usbDevice.configuration.interfaces[0]&&await this.usbDevice.releaseInterface(this.usbDevice.configuration.interfaces[0].interfaceNumber)}catch(e){console.log("Close: "+e)}e()}awaitKey(){setTimeout(async()=>{if(this.searching){let e=await this.mutex.acquire();try{await Promise.race([this.keySearch(),f()])}catch(e){console.log("Await: "+e)}e(),this.awaitKey()}},a)}async keySearch(){let e=[];try{let t=await this.romSearch();if(t.result){for(h(t.key)&&e.push(t.key);t.result&&!t.lastDevice;)(t=await t.next()).result&&h(t.key)&&e.push(t.key);this.onDetectKeys(e)}}catch(e){this.deviceReset()}}async deviceStatus(){let e=await this.usbDevice.transferIn(this.interrupt.endpointNumber,32);if(!e.data)throw new Error("1-Wire Device status read error.");return new l(e.data)}async bufferClear(){0!==(await this.deviceStatus()).commCommandBufferStatus&&await this.bufferClear()}async setSpeed(e){const t=e?2:1;if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:2,value:2,index:t})).status)throw new Error("1-Wire Device set speed failed.")}async reset(){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:3147,index:1})).status)throw new Error("1-Wire Device reset request failed.");await this.bufferClear()}async deviceReset(){if(await this.usbDevice.reset(),"ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:0,value:0,index:0})).status)throw new Error("1-Wire Device reset failed.");await this.bufferClear()}async write(e,t=!1){try{if("ok"!==(await this.usbDevice.transferOut(this.bulkIn.endpointNumber,e.buffer)).status)throw new Error;if(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:4213,index:e.length}),t){let t=0;do{t+=(await this.read(e.length-t)).length}while(t<e.length)}}catch(e){throw new Error("1-Wire Device write failed.")}}async writeBit(e){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:545|e<<3,index:0})).status)throw new Error("1-Wire Device write bit failed.")}async read(e){let t=this.usbDevice.transferIn(this.bulkOut.endpointNumber,e),r=new Promise((e,t)=>setTimeout(()=>t(),c));try{let e=await Promise.race([t,r]);if("ok"!==e.status||!e.data)throw new Error;return new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength)}catch(e){throw new Error("1-Wire Device read failed.")}}async readBit(){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:41,index:0})).status)throw new Error("1-Wire Device read bit transfer failed.");return(await this.read(1))[0]}async clearByte(){await this.read(1)}async romCommand(e=null,t=!1){let r=e?t?105:85:t?60:204,n=e?e.buffer:new Uint8Array(8).buffer,i=await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:101,index:r});if("ok"!==i.status)throw new Error("1-Wire Device rom transfer failed.");await this.setSpeed(t),i=await this.usbDevice.transferOut(this.bulkIn.endpointNumber,n)}async romMatch(e,t=!1){return this.romCommand(e,t)}async romSearch(e=0){await this.setSpeed(!1),await this.reset(),await this.write(new Uint8Array([240]),!0);let t=await this.romSubSearch({idBitNumber:1,lastZero:0,romByteNumber:0,romByteMask:1,searchResult:!1,idBit:0,cmpIdBit:0,searchDirection:0,romId:new Uint8Array(8),lastDevice:!1,lastDiscrepancy:e});return{result:t.searchResult,key:t.romId,lastDevice:t.lastDevice,next:async()=>this.romSearch(t.lastDiscrepancy)}}async romSubSearch(t){return t.idBit=await this.readBit(),t.cmpIdBit=await this.readBit(),1!==t.idBit||1!==t.cmpIdBit?(t.idBit!==t.cmpIdBit?t.searchDirection=t.idBit:(t.idBitNumber<t.lastDiscrepancy?t.searchDirection=(t.romId[t.romByteNumber]&t.romByteMask)>0?1:0:t.searchDirection=t.idBitNumber===t.lastDiscrepancy?1:0,0===t.searchDirection&&(t.lastZero=t.idBitNumber)),1===t.searchDirection?t.romId[t.romByteNumber]|=t.romByteMask:t.romId[t.romByteNumber]&=~t.romByteMask,await this.writeBit(t.searchDirection),t.idBitNumber++,t.romByteMask<<=1,t.romByteMask>=256&&(t.romByteNumber++,t.romByteMask=1),t.romByteNumber<8?this.romSubSearch(t):(t.idBitNumber>=65&&0===Object(i.a)(new e(t.romId))&&(t.lastDiscrepancy=t.lastZero,0===t.lastDiscrepancy&&(t.lastDevice=!0),t.searchResult=!0),!1!==t.searchResult&&0!==t.romId[0]||(t.lastDiscrepancy=0,t.lastDevice=!0,t.searchResult=!1),t)):t}async keyWrite(e,t=0,r=new Uint8Array(0),n=!1){const i=255&t,s=(65280&t)>>8,a=r.length-1;console.log("Starting Write");const c=async(e,t=0,r=new Uint8Array(0),n=!1)=>{console.log(`Write: ${t} - ${r.byteLength}`);const a=async(e,t=0)=>{const r=Math.min(o,e.length-t),n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=e[t+i];await this.write(n),e.length-(t+r)>0&&await a(e,t+r)};await this.reset(),await this.romMatch(e,n);const u=new Uint8Array([15,i,s]);await this.write(u,!0),await a(r),await this.reset(),await this.romMatch(e,n);const h=new Uint8Array([170]);await this.write(h);const f=await this.read(r.length);await this.clearByte(),f.length===r.length&&f.every((e,t)=>e===r[t])||await c(e,t,r,n)};await this.setSpeed(!1),await c(e,t,r,n),await this.reset(),await this.romMatch(e,n);const u=new Uint8Array([85,i,s,a]);await this.write(u,!0)}async keyWriteAll(e,t=[],r=!1){const i=async(e,t=0,r=[],n=!1)=>{const s=32*t;await this.keyWrite(e,s,r[t],n),r.length>t+1&&await i(e,t+1,r,n)},s=await this.mutex.acquire(),o=performance.now();try{await this.deviceReset(),await i(e,0,t,r),n.a.info("Write All Completed: "+Math.round(performance.now()-o)+"ms")}finally{s()}}async keyWriteDiff(e,t=[],r=[],i=!1){const s=async(e,t=0,r=[],n=[],i=!1)=>{const o=32*t;r[t].length===n[t].length&&r[t].every((e,r)=>e===n[t][r])||await this.keyWrite(e,o,r[t],i),r.length>t+1&&await s(e,t+1,r,n,i)};if(r.length!==t.length)throw new Error("Cannot perform diff on provided data");const o=await this.mutex.acquire(),a=performance.now();try{await this.deviceReset(),await s(e,0,t,r,i),n.a.info("Write Diff Completed: "+Math.round(performance.now()-a)+"ms")}finally{o()}}async keyReadAll(e,t=!1){const r=async(e,t=0)=>{const n=Math.min(o,e.length-t);(await this.read(n)).forEach(r=>e[t++]=r),t<e.length&&await r(e,t)},i=async(e=new Array(256),t=0)=>{e[t]=new Uint8Array(32);let n=new Uint8Array(32).fill(255);return await this.write(n),await r(e[t++]),t<e.length&&await i(e,t),e},s=async t=>{await this.setSpeed(!1),await this.reset(),await this.romMatch(e,t);const r=new Uint8Array([240,0,0]);return await this.write(r,!0),i()},a=await this.mutex.acquire(),c=performance.now();try{try{return await this.deviceReset(),await s(t)}catch(e){return n.a.warn("Read All "+(t?"Overdrive ":"")+"Failed: "+e.message),await this.deviceReset(),await s(!1)}}catch(e){n.a.error("Read All Failed: "+e.message),await this.deviceReset()}finally{a(),n.a.info("Read All Completed: "+Math.round(performance.now()-c)+"ms")}}}}).call(this,r(1).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(11);t.Mutex=n.default},function(e,t,r){"use strict";var n=r(1);var i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:e=>new n.Buffer(e);let s=[0,94,188,226,97,63,221,131,194,156,126,32,163,253,31,65,157,195,33,127,252,162,64,30,95,1,227,189,62,96,130,220,35,125,159,193,66,28,254,160,225,191,93,3,128,222,60,98,190,224,2,92,223,129,99,61,124,34,192,158,29,67,161,255,70,24,250,164,39,121,155,197,132,218,56,102,229,187,89,7,219,133,103,57,186,228,6,88,25,71,165,251,120,38,196,154,101,59,217,135,4,90,184,230,167,249,27,69,198,152,122,36,248,166,68,26,153,199,37,123,58,100,134,216,91,5,231,185,140,210,48,110,237,179,81,15,78,16,242,172,47,113,147,205,17,79,173,243,112,46,204,146,211,141,111,49,178,236,14,80,175,241,19,77,206,144,114,44,109,51,209,143,12,82,176,238,50,108,142,208,83,13,239,177,240,174,76,18,145,207,45,115,202,148,118,40,171,245,23,73,8,86,180,234,105,55,213,139,87,9,235,181,54,104,138,212,149,203,41,119,244,170,72,22,233,183,85,11,136,214,52,106,43,117,151,201,74,20,246,168,116,42,200,150,21,75,169,247,182,232,10,84,215,137,107,53];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));const o=function(e,t){const r=(e,r)=>t(e,r)>>>0;return r.signed=t,r.unsigned=r,r.model=e,r}("dallas-1-wire",(function(e,t){n.Buffer.isBuffer(e)||(e=i(e));let r=~~t;for(let t=0;t<e.length;t++){const n=e[t];r=255&s[255&(r^n)]}return r}));t.a=o},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";t.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){for(var t,r=u(e),n=r[0],o=r[1],a=new s(function(e,t,r){return 3*(t+r)/4-r}(0,n,o)),c=0,h=o>0?n-4:n,f=0;f<h;f+=4)t=i[e.charCodeAt(f)]<<18|i[e.charCodeAt(f+1)]<<12|i[e.charCodeAt(f+2)]<<6|i[e.charCodeAt(f+3)],a[c++]=t>>16&255,a[c++]=t>>8&255,a[c++]=255&t;2===o&&(t=i[e.charCodeAt(f)]<<2|i[e.charCodeAt(f+1)]>>4,a[c++]=255&t);1===o&&(t=i[e.charCodeAt(f)]<<10|i[e.charCodeAt(f+1)]<<4|i[e.charCodeAt(f+2)]>>2,a[c++]=t>>8&255,a[c++]=255&t);return a},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,s=[],o=0,a=r-i;o<a;o+=16383)s.push(h(e,o,o+16383>a?a:o+16383));1===i?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return s.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a<c;++a)n[a]=o[a],i[o.charCodeAt(a)]=a;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function h(e,t,r){for(var i,s,o=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(n[(s=i)>>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,r,n,i){var s,o,a=8*i-n-1,c=(1<<a)-1,u=c>>1,h=-7,f=r?i-1:0,l=r?-1:1,d=e[t+f];for(f+=l,s=d&(1<<-h)-1,d>>=-h,h+=a;h>0;s=256*s+e[t+f],f+=l,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+f],f+=l,h-=8);if(0===s)s=1-u;else{if(s===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var o,a,c,u=8*s-i-1,h=(1<<u)-1,f=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,w=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(o++,c/=2),o+f>=h?(a=0,o=h):o+f>=1?(a=(t*c-1)*Math.pow(2,i),o+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;e[r+d]=255&o,d+=p,o/=256,u-=8);e[r+d-p]|=128*w}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){this._queue=[],this._pending=!1}return e.prototype.isLocked=function(){return this._pending},e.prototype.acquire=function(){var e=this,t=new Promise((function(t){return e._queue.push(t)}));return this._pending||this._dispatchNext(),t},e.prototype.runExclusive=function(e){return this.acquire().then((function(t){var r;try{r=e()}catch(e){throw t(),e}return Promise.resolve(r).then((function(e){return t(),e}),(function(e){throw t(),e}))}))},e.prototype._dispatchNext=function(){this._queue.length>0?(this._pending=!0,this._queue.shift()(this._dispatchNext.bind(this))):this._pending=!1},e}();t.default=n},function(e,t,r){"use strict";r.r(t);var n=r(3);class i{constructor(e,t){this.connectedDevices=[],this.vendorId=e,this.productId=t,navigator.usb.addEventListener("connect",e=>{this.attached(e)}),navigator.usb.addEventListener("disconnect",e=>{this.detached(e)}),this.checkDevices()}get isConnected(){return this.connectedDevices.length>0}async start(){await this.requestPermission()}async requestPermission(){if(this.checkNodeDevices())return;let e;try{e=await navigator.usb.requestDevice({filters:[{vendorId:this.vendorId,productId:this.productId}]})}catch(e){throw new Error("USB Device permission denied.")}e&&this.connected(e)}async checkDevices(){if(this.checkNodeDevices())return;(await navigator.usb.getDevices()).some(e=>{if(this.matchesTarget(e))return this.connected(e),!0})}checkNodeDevices(){if(void 0===window.node_usb)return!1;let e;try{e=window.node_usb.findByIds(this.vendorId,this.productId)}catch(e){return!1}if(e){const t=Object(n.a)(e);return this.connected(t),!0}return!1}attached(e){e.device&&this.matchesTarget(e.device)&&this.connected(e.device)}detached(e){e.device&&this.matchesTarget(e.device)&&this.isConnectedDevices(e.device)&&this.disconnected(e.device)}async connected(e){if(this.isConnectedDevices(e))throw new Error("USB Device already connected.");try{await e.open(),this.connectedDevices.push(e)}catch(e){throw new Error("USB Device cannot be opened.\n[Check driver installation.]")}}async disconnected(e){let t=this.connectedDevices.indexOf(e);if(t>=0){try{await e.close()}catch(e){}this.connectedDevices.splice(t,1)}}matchesTarget(e){return e.vendorId===this.vendorId&&e.productId===this.productId}isConnectedDevices(e){return this.connectedDevices.indexOf(e)>=0}}var s,o,a,c=r(0),u=r(2);class h{constructor(e){this.disposed=!1,this.onDisconnectListener=null,this.onDisconnectEvent=new u.a,this.onDisconnectListener=e(()=>this.disconnected())}get diposed(){return this.disposed}onDisconnect(e){return this.onDisconnectEvent.on(e)}disconnected(){this.onDisconnectEvent.emit(null),this.dispose()}dispose(){this.onDisconnectListener&&(this.onDisconnectListener.dispose(),this.onDisconnectListener=null),this.disposed=!0}}function f(e=[]){let t={machineData:{},rawData:e,validStructure:!1};if(0===e.length||!w(e))return t;for(let r=1;r<=8;r++)for(let n=0;n<3;n++){let i=32*r-2,s=10*n;if(1===e[i][s]){let r=A(e[i][s+1],e[i][s+2]);t.machineData[r]={position:{chest:v(e[i][s+3]),rom2:v(e[i][s+4]),rom1:v(e[i][s+5]),seat:v(e[i][s+6])},sets:[]};let n=e[i][s+7];l(e,t.machineData[r],n)}}return t.validStructure=!0,t}!function(e){e.dec="dec",e.int="int"}(s||(s={})),function(e){e.lb="lb",e.kg="kg",e.ne="ne",e.er="er"}(o||(o={})),function(e){e.power6r="power6r",e.a4206r="a4206r",e.a42010r="a42010r"}(a||(a={}));const l=(e,t,r)=>{let n=r%30,i=e[32*Math.floor(r/32)+31][n],c=e[r],u=_(c[7],c[8]),h={version:A(c[12],c[11],c[10],c[9]),serial:"",time:B(c[0],c[1],c[2],c[3]).toISOString(),resistance:_(c[4],c[5]),precision:s.int,units:o.lb,repetitions:c[6],peak:null,work:null,distance:null,seat:v(c[26]),rom2:v(c[27]),rom1:v(c[28]),chest:v(c[29]),test:null};if(h.serial=I(c[13],c[14],c[15],c[16],c[17],h.version),E(h.version))switch(128==(128&c[17])&&(h.resistance=h.resistance/10,h.precision=s.dec),96&c[17]){case 0:h.units=o.lb;break;case 32:h.units=o.kg;break;case 64:h.units=o.ne;break;case 96:h.units=o.er}if(b(h.version))if(h.repetitions>=252&&h.repetitions<=254){let e={type:a.power6r,low:null,high:null};switch(h.repetitions){case 254:e.type=a.power6r,e.low=O(c,18),e.high=O(c,24),h.repetitions=6;break;case 253:e.type=a.a4206r,h.repetitions=6;break;case 252:e.type=a.a42010r,h.repetitions=10}h.test=e}else D(h.version)&&(h.peak=_(c[20],c[21]),h.work=Math.round(_(c[22],c[23],c[24],c[25])/64*100)/100,12800==(65280&u)&&(h.distance=_(c[18],c[19])));t.sets||(t.sets=[]),t.sets.push(h),30!=(30&i)&&l(e,t,i)};function d(e){let t=U();let r=0,n=0;return Object.keys(e).forEach(i=>{if(r>24&&n>242)throw new Error("Data structure exceeds memory capacity.");const s=e[i],o=parseInt(i,16),a=32*Math.floor(r/3)+30,c=r%3*10;t[a][c]=1;const u=T(o);t[a][c+1]=u[0],t[a][c+2]=u[1],t[a][c+3]=m(s.position.chest),t[a][c+4]=m(s.position.rom2),t[a][c+5]=m(s.position.rom1),t[a][c+6]=m(s.position.seat),t[a][c+7]=n,s.sets.forEach((e,r)=>{let i=32*Math.floor(n/30)+n%30;p(o,e,s.position,t[i]);let a=32*Math.floor(n/30)+31,c=n%30;t[a][c]=r+1<s.sets.length?n+1:254,n++}),r++}),x(t),t}const p=(e,t,r,n)=>{const i=S(new Date(t.time)),o=T(t.resistance*(t.precision===s.dec?10:1));let c=t.repetitions;if(t.test)switch(t.test.type){case a.power6r:c=254;break;case a.a4206r:c=253;break;case a.a42010r:c=252}let u=T(e),h=T(parseInt(t.version,16)),f=R(t.serial),l=P(t.serial,t.version,t.precision,t.units);n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=o[0],n[5]=o[1],n[6]=c,n[7]=u[0],n[8]=u[1],n[9]=h[3],n[10]=h[2],n[11]=h[1],n[12]=h[0],n[13]=f[0],n[14]=f[1],n[15]=f[2],n[16]=f[3],n[17]=l,t.test?k(t.test,n):C(t,n)},w=e=>e.every((e,t)=>~~(t/2)%16==15?g(e):y(e)||g(e)),y=e=>e.every(e=>85===e),g=e=>{let t=0;for(let r of e)for(let e=0;e<8;e++){let e=(r^t)%2;t>>=1,r>>=1,e&&(t^=40961)}return 45057===t},v=e=>255===e?null:e,m=e=>null===e?255:e,b=e=>parseInt(e,16)>795179504,D=e=>parseInt(e,16)>851074185,E=e=>parseInt(e,16)>831409920,A=(...e)=>{let t="";return e.reverse().forEach(e=>t+=("00"+e.toString(16)).substr(-2).toUpperCase()),t},_=(...e)=>{let t=0;return e.forEach((e,r)=>t+=(255&e)<<8*r),t},T=e=>[255&e,(65280&e)>>8,(16711680&e)>>16,(4278190080&e)>>24],B=(...e)=>new Date(1e3*_(...e)),S=e=>T(e.getTime()/1e3),I=(e,t,r,n,i,s)=>{let o=(e=>("00"+(e.getUTCMonth()+1)).substr(-2)+("00"+e.getUTCDate()).substr(-2)+" "+e.getUTCFullYear()+" "+("00"+e.getUTCHours()).substr(-2)+("00"+e.getUTCMinutes()).substr(-2)+" "+("00"+e.getUTCSeconds()).substr(-2))(B(e,t,r,n));return E(s)?o+=("00"+(32+(31&i)).toString()).substr(-2):(o+=((240&i)/16).toString(16),o+=(31&i).toString(16)),o},R=e=>{const t=/(\d{2})(\d{2}) (\d{4}) (\d{2})(\d{2}) (\d{2})/.exec(e);if(null===t||7!==t.length)throw new Error("Invalid serial string.");const r=t.slice(1).map(e=>parseInt(e,10)),n=Date.UTC(r[2],r[0]-1,r[1],r[3],r[4],r[5]);return T(n/1e3)},P=(e,t,r,n)=>{let i=0;switch(i=E(t)?parseInt(e.substr(-2),10)-32:parseInt(e.substr(-2),10),r===s.dec&&(i|=128),n){case o.kg:i|=32;break;case o.ne:i|=64;break;case o.er:i|=96}return i},U=()=>{let e=new Array(256);for(let t=0;t<e.length;t++){e[t]=new Uint8Array(32);for(let r=0;r<e[t].length;r++)t>0&&(t%32==30||t%32==31)?r===e[t].length-1?e[t][r]=207:e[t][r]=255:e[t][r]=85}return e},C=(e,t)=>{const r=T(e.peak||0),n=T(64*(e.work||0)),i=T(e.distance||0);t[18]=i[0],t[19]=i[1],t[20]=r[0],t[21]=r[1],t[22]=n[0],t[23]=n[1],t[24]=n[2],t[25]=n[3],t[26]=m(e.seat),t[27]=m(e.rom2),t[28]=m(e.rom1),t[29]=m(e.chest)},k=(e,t)=>{e.low&&M(e.low,18,t),e.high&&M(e.high,24,t)},O=(e,t)=>({power:e[t]+((31&e[t+2])<<8),velocity:e[t+1]+((224&e[t+2])<<3),force:e[t+3]+((240&e[t+5])<<4),position:e[t+4]+((15&e[t+5])<<8)}),M=(e,t,r)=>{r[t++]=255&e.power,r[t++]=255&e.velocity,r[t++]=((7936&e.power)>>8)+((1792&e.velocity)>>3),r[t++]=255&e.force,r[t++]=255&e.position,r[t++]=((3840&e.position)>>8)+((3840&e.force)>>4)},x=e=>{e.forEach(e=>{if(!y(e)){let t=0;for(let r=0;r<30;r++){let n=e[r];for(let e=0;e<8;e++){let e=(n^t)%2;t>>=1,n>>=1,e&&(t^=40961)}}let r=T(65535^t);e[30]=r[0],e[31]=r[1]}})};class N extends h{constructor(e,t,r){super(r),this.echipId=e,this.owDevice=t,this.data=this.loadData(),c.a.info("EChip connected: "+this.id)}get id(){return this.echipId.reduce((e,t)=>e+=(15&t).toString(16)+(t>>4&15).toString(16),"").split("").reverse().join("")}destroy(){this.disconnected()}async getData(){return this.data}async clearData(){let e=d({});try{let t=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,e,t,!1)}catch(t){await this.owDevice.keyWriteAll(this.echipId,e,!1)}this.data=new Promise(t=>t(f(e)))}async setData(e){let t=d(e),r=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,t,r,!1),this.data=new Promise(e=>e(f(t)))}async dispose(){await super.dispose(),c.a.info("EChip disconnected: "+this.id)}async loadData(){let e=f(await this.owDevice.keyReadAll(this.echipId,!1));return e.validStructure||c.a.warn("Invalid Data Structure"),e}}var L=r(4);class Y{constructor(e,t){this.disposed=!1,this.onDisconnectListener=null,this.onEChipDetectEvent=new u.a,this.onDisconnectEvent=new u.a,this.activeKeys=new Map,this.onDisconnectListener=t(e=>this.disconnected(e)),this.usbDevice=e,this.owDevice=new L.a(e,e=>this.echipsDetected(e)),this.claimed=this.owDevice.claim().then(()=>(c.a.info("EChip Reader connected."),this.owDevice.startSearch(),!0))}get diposed(){return this.disposed}onDisconnect(e){return this.onDisconnectEvent.on(e)}onEChipDetect(e){this.onEChipDetectEvent.on(e)}echipsDetected(e){let t=[];e.forEach(e=>{let r=e.join();if(t.push(r),!this.activeKeys.has(r)){let t=new N(e,this.owDevice,e=>this.onDisconnect(e));this.activeKeys.set(r,t),this.onEChipDetectEvent.emit(t)}}),this.activeKeys.forEach((e,r)=>{t.includes(r)||(e.destroy(),this.activeKeys.delete(r))})}disconnected(e){this.usbDevice===e&&(this.onDisconnectEvent.emit(null),this.dispose())}async dispose(){await this.owDevice.close(),this.onDisconnectListener&&(this.onDisconnectListener.dispose(),this.onDisconnectListener=null),this.disposed=!0,c.a.info("EChip Reader disconnected.")}}r.d(t,"default",(function(){return W}));const q=1274,j=9360;class W extends i{constructor(){super(q,j),this.onConnectEvent=new u.a,this.onDisconnectEvent=new u.a}stop(){this.connectedDevices.forEach(e=>this.disconnected(e))}onConnect(e){return this.onConnectEvent.on(e)}onDisconnect(e){return this.onDisconnectEvent.on(e)}async connected(e){await super.connected(e);const t=new Y(e,e=>this.onDisconnect(e));await t.claimed,this.onConnectEvent.emit(t)}async disconnected(e){await super.disconnected(e),this.onDisconnectEvent.emit(e)}}}])}));
var n=r(8),i=r(9),s=r(10);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(this,e)}return u(this,e,t,r)}function u(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=l(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),i=(e=a(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(c.isBuffer(t)){var r=0|d(t.length);return 0===(e=a(e,r)).length?e:(t.copy(e,0,0,r),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):l(e,t);if("Buffer"===t.type&&s(t.data))return l(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function h(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function f(e,t){if(h(t),e=a(e,t<0?0:0|d(t)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function l(e,t){var r=t.length<0?0:0|d(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function d(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function w(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,r);case"utf8":case"utf-8":return B(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return R(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,i){var s,o=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,r/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var h=-1;for(s=r;s<a;s++)if(u(e,s)===u(t,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===c)return h*o}else-1!==h&&(s-=s-h),h=-1}else for(r+c>a&&(r=a-c),s=r;s>=0;s--){for(var f=!0,l=0;l<c;l++)if(u(e,s+l)!==u(t,l)){f=!1;break}if(f)return s}return-1}function m(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function b(e,t,r,n){return F(j(t,e.length-r),e,r,n)}function D(e,t,r,n){return F(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function E(e,t,r,n){return D(e,t,r,n)}function A(e,t,r,n){return F(W(t),e,r,n)}function _(e,t,r,n){return F(function(e,t){for(var r,n,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}(t,e.length-r),e,r,n)}function T(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function B(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s,o,a,c,u=e[i],h=null,f=u>239?4:u>223?3:u>191?2:1;if(i+f<=r)switch(f){case 1:u<128&&(h=u);break;case 2:128==(192&(s=e[i+1]))&&(c=(31&u)<<6|63&s)>127&&(h=c);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,f=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=f}return function(e){var t=e.length;if(t<=S)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=S));return r}(n)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=o(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,r){return u(null,e,t,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,r){return function(e,t,r,n){return h(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},c.allocUnsafe=function(e){return f(null,e)},c.allocUnsafeSlow=function(e){return f(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=c.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?B(this,0,e):w.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,r,n,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),u=this.slice(n,i),h=e.slice(t,r),f=0;f<a;++f)if(u[f]!==h[f]){s=u[f],o=h[f];break}return s<o?-1:o<s?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return g(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return g(this,e,t,r,!1)},c.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return D(this,e,t,r);case"latin1":case"binary":return E(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function I(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function R(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function P(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=t;s<r;++s)i+=q(e[s]);return i}function U(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function C(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,r,n,i,s){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i<s;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function M(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i<s;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function x(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(e,t,r,n,s){return s||x(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function L(e,t,r,n,s){return s||x(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;r=new c(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+e]}return r},c.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},c.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUInt8=function(e,t){return t||C(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||C(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||C(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return t||C(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||C(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){t||C(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||C(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||C(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||C(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||C(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[t]=255&e;++s<r&&(i*=256);)this[t+s]=e/i&255;return t+r},c.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<r&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return N(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return N(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,s=n-r;if(this===e&&r<t&&t<n)for(i=s-1;i>=0;--i)e[i+t]=this[i+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},c.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var o=c.isBuffer(e)?e:j(new c(e,n).toString()),a=o.length;for(s=0;s<r-t;++s)this[s+t]=o[s%a]}return this};var Y=/[^+\/0-9A-Za-z-_]/g;function q(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var r;t=t||1/0;for(var n=e.length,i=null,s=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function W(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Y,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(7))},function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return i}));class n{constructor(){this.listeners=[]}on(e){return this.listeners.push(e),{dispose:()=>this.off(e)}}off(e){let t=this.listeners.indexOf(e);t>-1&&this.listeners.splice(t,1)}emit(e){this.listeners.forEach(t=>t(e))}}class i extends Event{constructor(e,t){super(e),this.device=t.device}}},function(e,t,r){"use strict";(function(e){r.d(t,"a",(function(){return s}));var n=r(2);class i{constructor(e){this._opened=!1,this._claimedInterface=null,this.nodeUsbDevice=e,this.deviceClass=e.deviceDescriptor.bDeviceClass,this.deviceSubclass=e.deviceDescriptor.bDeviceSubClass,this.deviceProtocol=e.deviceDescriptor.bDeviceProtocol,this.vendorId=e.deviceDescriptor.idVendor,this.productId=e.deviceDescriptor.idProduct}get configuration(){return this.configurationTransform(this.nodeUsbDevice.configDescriptor)}get configurations(){return this.nodeUsbDevice.allConfigDescriptors.map(e=>this.configurationTransform(e))}get opened(){return this._opened}open(){try{this.nodeUsbDevice.open(),this._opened=!0}catch(e){return Promise.reject(e)}return Promise.resolve()}close(){try{this.nodeUsbDevice.close()}catch(e){return Promise.reject(e)}return Promise.resolve()}async selectConfiguration(e){return new Promise((t,r)=>{this.nodeUsbDevice.setConfiguration(e,e=>{if(e)return r(e);t()})})}async claimInterface(e){try{const t=this.nodeUsbDevice.interfaces.find(t=>t.interfaceNumber===e);if(!t)throw new Error("Interface not found");return t.claim(),this._claimedInterface=t,Promise.resolve()}catch(e){return Promise.reject(e)}}releaseInterface(e){return new Promise((t,r)=>{const n=this.nodeUsbDevice.interfaces.find(t=>t.interfaceNumber===e);if(!n)return r("Interface not found");n.release(e=>{if(e)return r(e);this._claimedInterface=null,t()})})}selectAlternateInterface(e,t){return new Promise((r,n)=>{const i=this.nodeUsbDevice.interfaces.find(t=>t.interfaceNumber===e);if(!i)return n("Interface not found");i.setAltSetting(t,e=>{if(e)return n(e);r()})})}controlTransferIn(e,t){return new Promise((r,n)=>{this.nodeUsbDevice.controlTransfer(this.requestTypeTransform(e.requestType),e.request,e.value,e.index,t,(e,t)=>e?n(e.message):t?void r({data:new DataView(t),status:"ok"}):n("No buffer returned"))})}controlTransferOut(t,r){return new Promise((n,i)=>{this.nodeUsbDevice.controlTransfer(this.requestTypeTransform(t.requestType),t.request,t.value,t.index,r?this.arrayBufferToBuffer(r):e.from(""),(e,t)=>{if(e)return i(e.message);n({bytesWritten:r?r.byteLength:0,status:"ok"})})})}transferIn(e,t){return new Promise((r,n)=>{if(!this._claimedInterface)return n("No interface claimed");const i=this._claimedInterface.endpoint(e);if(!i||"in"!==i.direction)return n("No endpoint found");i.transfer(t,(e,t)=>{if(e)return n(e.message);r({data:new DataView(t.buffer,0,t.length),status:"ok"})})})}transferOut(e,t){return new Promise((r,n)=>{if(!this._claimedInterface)return n("No interface claimed");const i=this._claimedInterface.endpoint(e);if(!i||"out"!==i.direction)return n("No endpoint found");i.transfer(this.arrayBufferToBuffer(t),e=>{if(e)return n(e.message);r({bytesWritten:t?t.byteLength:0,status:"ok"})})})}reset(){return new Promise((e,t)=>{this.nodeUsbDevice.reset(r=>{if(r)return navigator.usb.dispatchEvent(new n.b("disconnect",{device:this.asWebUSBDevice()})),t(r);e()})})}asWebUSBDevice(){return this}configurationTransform(e){const t=e.interfaces.reduce((e,t)=>e.concat(t),[]);return{configurationValue:e.bConfigurationValue,configurationName:"",interfaces:t.map(t=>this.interfaceTransform(e,t))}}interfaceTransform(e,t){const r=e.interfaces.reduce((e,t)=>e.concat(t),[]);return{interfaceNumber:t.bInterfaceNumber,alternate:this.interfaceAltTransform(t,this.nodeUsbDevice.interface(t.bInterfaceNumber)),alternates:r.map(e=>this.interfaceAltTransform(t,this.nodeUsbDevice.interface(e.bInterfaceNumber)))}}interfaceAltTransform(e,t){return{alternateSetting:e.bAlternateSetting,interfaceClass:e.bInterfaceClass,interfaceSubclass:e.bInterfaceSubClass,interfaceProtocol:e.bInterfaceProtocol,interfaceName:"",endpoints:t.endpoints.map(e=>this.endpointTransform(e))}}endpointTransform(e){return{endpointNumber:e.descriptor.bEndpointAddress,direction:e.direction,type:this.endpointTypeTransform(e.transferType),packetSize:e.descriptor.wMaxPacketSize}}endpointTypeTransform(e){switch(e){case window.node_usb.LIBUSB_TRANSFER_TYPE_BULK:return"bulk";case window.node_usb.LIBUSB_TRANSFER_TYPE_INTERRUPT:return"interrupt";case window.node_usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:return"isochronous"}}requestTypeTransform(e){switch(e){case"standard":return window.node_usb.LIBUSB_REQUEST_TYPE_STANDARD;case"class":return window.node_usb.LIBUSB_REQUEST_TYPE_CLASS;case"vendor":return window.node_usb.LIBUSB_REQUEST_TYPE_VENDOR}}arrayBufferToBuffer(t){return t instanceof ArrayBuffer?e.from(t):e.from("")}}function s(e){return new i(e)}}).call(this,r(1).Buffer)},function(e,t,r){"use strict";(function(e){r.d(t,"a",(function(){return d}));var n=r(0),i=r(6),s=r(5);const o=64,a=500,c=200,u=1,h=e=>12===e[0]&&0!==e[7],f=()=>new Promise(e=>setTimeout(()=>{e()},c));class l{constructor(e){const t=new Uint8Array(e.buffer);this.commCommandBufferStatus=t[11],this.dataOutBufferStatus=t[12],this.dataInBufferStatus=t[13],this.detectKey=165===t[16],this.data=t.slice(16,t.length)}}class d{constructor(e,t=(e=>{})){this.mutex=new s.Mutex,this.searching=!1,this.usbDevice=e,this.onDetectKeys=t;const r=this.usbDevice.configurations[0].interfaces[0].alternates[u];this.interrupt=r.endpoints[0],this.bulkIn=r.endpoints[1],this.bulkOut=r.endpoints[2]}async claim(){const e=this.usbDevice.configurations[0],t=e.interfaces[0];try{null!==this.usbDevice.configuration&&void 0!==this.usbDevice.configuration&&this.usbDevice.configuration.configurationValue===e.configurationValue||await this.usbDevice.selectConfiguration(e.configurationValue),await this.usbDevice.claimInterface(t.interfaceNumber),await this.usbDevice.selectAlternateInterface(t.interfaceNumber,t.alternates[u].alternateSetting),await this.deviceReset()}catch(e){throw new Error("1-Wire Device interface cannot be claimed.")}return!0}async startSearch(){this.searching||(this.searching=!0,this.awaitKey())}async close(){this.searching=!1;let e=await this.mutex.acquire();try{this.usbDevice.configuration&&this.usbDevice.configuration.interfaces[0]&&await this.usbDevice.releaseInterface(this.usbDevice.configuration.interfaces[0].interfaceNumber)}catch(e){console.log("Close: "+e)}e()}awaitKey(){setTimeout(async()=>{if(this.searching){let e=await this.mutex.acquire();try{await Promise.race([this.keySearch(),f()])}catch(e){console.log("Await: "+e)}e(),this.awaitKey()}},a)}async keySearch(){let e=[];try{let t=await this.romSearch();if(t.result){for(h(t.key)&&e.push(t.key);t.result&&!t.lastDevice;)(t=await t.next()).result&&h(t.key)&&e.push(t.key);this.onDetectKeys(e)}}catch(e){this.deviceReset()}}async deviceStatus(){let e=await this.usbDevice.transferIn(this.interrupt.endpointNumber,32);if(!e.data)throw new Error("1-Wire Device status read error.");return new l(e.data)}async bufferClear(){0!==(await this.deviceStatus()).commCommandBufferStatus&&await this.bufferClear()}async setSpeed(e){const t=e?2:1;if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:2,value:2,index:t})).status)throw new Error("1-Wire Device set speed failed.")}async reset(){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:3147,index:1})).status)throw new Error("1-Wire Device reset request failed.");await this.bufferClear()}async deviceReset(){if(await this.usbDevice.reset(),"ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:0,value:0,index:0})).status)throw new Error("1-Wire Device reset failed.");await this.bufferClear()}async write(e,t=!1){try{if("ok"!==(await this.usbDevice.transferOut(this.bulkIn.endpointNumber,e.buffer)).status)throw new Error;if(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:4213,index:e.length}),t){let t=0;do{t+=(await this.read(e.length-t)).length}while(t<e.length)}}catch(e){throw new Error("1-Wire Device write failed.")}}async writeBit(e){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:545|e<<3,index:0})).status)throw new Error("1-Wire Device write bit failed.")}async read(e){let t=this.usbDevice.transferIn(this.bulkOut.endpointNumber,e),r=new Promise((e,t)=>setTimeout(()=>t(),c));try{let e=await Promise.race([t,r]);if("ok"!==e.status||!e.data)throw new Error;return new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength)}catch(e){throw new Error("1-Wire Device read failed.")}}async readBit(){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:41,index:0})).status)throw new Error("1-Wire Device read bit transfer failed.");return(await this.read(1))[0]}async clearByte(){await this.read(1)}async romCommand(e=null,t=!1){let r=e?t?105:85:t?60:204,n=e?e.buffer:new Uint8Array(8).buffer,i=await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:101,index:r});if("ok"!==i.status)throw new Error("1-Wire Device rom transfer failed.");await this.setSpeed(t),i=await this.usbDevice.transferOut(this.bulkIn.endpointNumber,n)}async romMatch(e,t=!1){return this.romCommand(e,t)}async romSearch(e=0){await this.setSpeed(!1),await this.reset(),await this.write(new Uint8Array([240]),!0);let t=await this.romSubSearch({idBitNumber:1,lastZero:0,romByteNumber:0,romByteMask:1,searchResult:!1,idBit:0,cmpIdBit:0,searchDirection:0,romId:new Uint8Array(8),lastDevice:!1,lastDiscrepancy:e});return{result:t.searchResult,key:t.romId,lastDevice:t.lastDevice,next:async()=>this.romSearch(t.lastDiscrepancy)}}async romSubSearch(t){return t.idBit=await this.readBit(),t.cmpIdBit=await this.readBit(),1!==t.idBit||1!==t.cmpIdBit?(t.idBit!==t.cmpIdBit?t.searchDirection=t.idBit:(t.idBitNumber<t.lastDiscrepancy?t.searchDirection=(t.romId[t.romByteNumber]&t.romByteMask)>0?1:0:t.searchDirection=t.idBitNumber===t.lastDiscrepancy?1:0,0===t.searchDirection&&(t.lastZero=t.idBitNumber)),1===t.searchDirection?t.romId[t.romByteNumber]|=t.romByteMask:t.romId[t.romByteNumber]&=~t.romByteMask,await this.writeBit(t.searchDirection),t.idBitNumber++,t.romByteMask<<=1,t.romByteMask>=256&&(t.romByteNumber++,t.romByteMask=1),t.romByteNumber<8?this.romSubSearch(t):(t.idBitNumber>=65&&0===Object(i.a)(new e(t.romId))&&(t.lastDiscrepancy=t.lastZero,0===t.lastDiscrepancy&&(t.lastDevice=!0),t.searchResult=!0),!1!==t.searchResult&&0!==t.romId[0]||(t.lastDiscrepancy=0,t.lastDevice=!0,t.searchResult=!1),t)):t}async keyWrite(e,t=0,r=new Uint8Array(0),n=!1){const i=255&t,s=(65280&t)>>8,a=r.length-1;console.log("Starting Write");const c=async(e,t=0,r=new Uint8Array(0),n=!1)=>{console.log(`Write: ${t} - ${r.byteLength}`);const a=async(e,t=0)=>{const r=Math.min(o,e.length-t),n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=e[t+i];await this.write(n),e.length-(t+r)>0&&await a(e,t+r)};await this.reset(),await this.romMatch(e,n);const u=new Uint8Array([15,i,s]);await this.write(u,!0),await a(r),await this.reset(),await this.romMatch(e,n);const h=new Uint8Array([170]);await this.write(h);const f=await this.read(r.length);await this.clearByte(),f.length===r.length&&f.every((e,t)=>e===r[t])||await c(e,t,r,n)};await this.setSpeed(!1),await c(e,t,r,n),await this.reset(),await this.romMatch(e,n);const u=new Uint8Array([85,i,s,a]);await this.write(u,!0)}async keyWriteAll(e,t=[],r=!1){const i=async(e,t=0,r=[],n=!1)=>{const s=32*t;await this.keyWrite(e,s,r[t],n),r.length>t+1&&await i(e,t+1,r,n)},s=await this.mutex.acquire(),o=performance.now();try{await this.deviceReset(),await i(e,0,t,r),n.a.info("Write All Completed: "+Math.round(performance.now()-o)+"ms")}finally{s()}}async keyWriteDiff(e,t=[],r=[],i=!1){const s=async(e,t=0,r=[],n=[],i=!1)=>{const o=32*t;r[t].length===n[t].length&&r[t].every((e,r)=>e===n[t][r])||await this.keyWrite(e,o,r[t],i),r.length>t+1&&await s(e,t+1,r,n,i)};if(r.length!==t.length)throw new Error("Cannot perform diff on provided data");const o=await this.mutex.acquire(),a=performance.now();try{await this.deviceReset(),await s(e,0,t,r,i),n.a.info("Write Diff Completed: "+Math.round(performance.now()-a)+"ms")}finally{o()}}async keyReadAll(e,t=!1){const r=async(e,t=0)=>{const n=Math.min(o,e.length-t);(await this.read(n)).forEach(r=>e[t++]=r),t<e.length&&await r(e,t)},i=async(e=new Array(256),t=0)=>{e[t]=new Uint8Array(32);let n=new Uint8Array(32).fill(255);return await this.write(n),await r(e[t++]),t<e.length&&await i(e,t),e},s=async t=>{await this.setSpeed(!1),await this.reset(),await this.romMatch(e,t);const r=new Uint8Array([240,0,0]);return await this.write(r,!0),i()},a=await this.mutex.acquire(),c=performance.now();try{try{return await this.deviceReset(),await s(t)}catch(e){return n.a.warn("Read All "+(t?"Overdrive ":"")+"Failed: "+e.message),await this.deviceReset(),await s(!1)}}catch(e){n.a.error("Read All Failed: "+e.message),await this.deviceReset()}finally{a(),n.a.info("Read All Completed: "+Math.round(performance.now()-c)+"ms")}}}}).call(this,r(1).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(11);t.Mutex=n.default},function(e,t,r){"use strict";var n=r(1);var i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:e=>new n.Buffer(e);let s=[0,94,188,226,97,63,221,131,194,156,126,32,163,253,31,65,157,195,33,127,252,162,64,30,95,1,227,189,62,96,130,220,35,125,159,193,66,28,254,160,225,191,93,3,128,222,60,98,190,224,2,92,223,129,99,61,124,34,192,158,29,67,161,255,70,24,250,164,39,121,155,197,132,218,56,102,229,187,89,7,219,133,103,57,186,228,6,88,25,71,165,251,120,38,196,154,101,59,217,135,4,90,184,230,167,249,27,69,198,152,122,36,248,166,68,26,153,199,37,123,58,100,134,216,91,5,231,185,140,210,48,110,237,179,81,15,78,16,242,172,47,113,147,205,17,79,173,243,112,46,204,146,211,141,111,49,178,236,14,80,175,241,19,77,206,144,114,44,109,51,209,143,12,82,176,238,50,108,142,208,83,13,239,177,240,174,76,18,145,207,45,115,202,148,118,40,171,245,23,73,8,86,180,234,105,55,213,139,87,9,235,181,54,104,138,212,149,203,41,119,244,170,72,22,233,183,85,11,136,214,52,106,43,117,151,201,74,20,246,168,116,42,200,150,21,75,169,247,182,232,10,84,215,137,107,53];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));const o=function(e,t){const r=(e,r)=>t(e,r)>>>0;return r.signed=t,r.unsigned=r,r.model=e,r}("dallas-1-wire",(function(e,t){n.Buffer.isBuffer(e)||(e=i(e));let r=~~t;for(let t=0;t<e.length;t++){const n=e[t];r=255&s[255&(r^n)]}return r}));t.a=o},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";t.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){for(var t,r=u(e),n=r[0],o=r[1],a=new s(function(e,t,r){return 3*(t+r)/4-r}(0,n,o)),c=0,h=o>0?n-4:n,f=0;f<h;f+=4)t=i[e.charCodeAt(f)]<<18|i[e.charCodeAt(f+1)]<<12|i[e.charCodeAt(f+2)]<<6|i[e.charCodeAt(f+3)],a[c++]=t>>16&255,a[c++]=t>>8&255,a[c++]=255&t;2===o&&(t=i[e.charCodeAt(f)]<<2|i[e.charCodeAt(f+1)]>>4,a[c++]=255&t);1===o&&(t=i[e.charCodeAt(f)]<<10|i[e.charCodeAt(f+1)]<<4|i[e.charCodeAt(f+2)]>>2,a[c++]=t>>8&255,a[c++]=255&t);return a},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,s=[],o=0,a=r-i;o<a;o+=16383)s.push(h(e,o,o+16383>a?a:o+16383));1===i?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return s.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a<c;++a)n[a]=o[a],i[o.charCodeAt(a)]=a;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function h(e,t,r){for(var i,s,o=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(n[(s=i)>>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,r,n,i){var s,o,a=8*i-n-1,c=(1<<a)-1,u=c>>1,h=-7,f=r?i-1:0,l=r?-1:1,d=e[t+f];for(f+=l,s=d&(1<<-h)-1,d>>=-h,h+=a;h>0;s=256*s+e[t+f],f+=l,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+f],f+=l,h-=8);if(0===s)s=1-u;else{if(s===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var o,a,c,u=8*s-i-1,h=(1<<u)-1,f=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,w=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(o++,c/=2),o+f>=h?(a=0,o=h):o+f>=1?(a=(t*c-1)*Math.pow(2,i),o+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;e[r+d]=255&o,d+=p,o/=256,u-=8);e[r+d-p]|=128*w}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){this._queue=[],this._pending=!1}return e.prototype.isLocked=function(){return this._pending},e.prototype.acquire=function(){var e=this,t=new Promise((function(t){return e._queue.push(t)}));return this._pending||this._dispatchNext(),t},e.prototype.runExclusive=function(e){return this.acquire().then((function(t){var r;try{r=e()}catch(e){throw t(),e}return Promise.resolve(r).then((function(e){return t(),e}),(function(e){throw t(),e}))}))},e.prototype._dispatchNext=function(){this._queue.length>0?(this._pending=!0,this._queue.shift()(this._dispatchNext.bind(this))):this._pending=!1},e}();t.default=n},function(e,t,r){"use strict";r.r(t);var n=r(3);class i{constructor(e,t){this.connectedDevices=[],this.vendorId=e,this.productId=t,navigator.usb.addEventListener("connect",e=>{this.attached(e)}),navigator.usb.addEventListener("disconnect",e=>{this.detached(e)}),this.checkDevices()}get isConnected(){return this.connectedDevices.length>0}async start(){await this.requestPermission()}async requestPermission(){if(this.checkNodeDevices())return;let e;try{e=await navigator.usb.requestDevice({filters:[{vendorId:this.vendorId,productId:this.productId}]})}catch(e){throw new Error("USB Device permission denied.")}e&&this.connected(e)}async checkDevices(){if(this.checkNodeDevices())return;(await navigator.usb.getDevices()).some(e=>{if(this.matchesTarget(e))return this.connected(e),!0})}checkNodeDevices(){if(void 0===window.node_usb)return!1;let e;try{e=window.node_usb.findByIds(this.vendorId,this.productId)}catch(e){return!1}if(e){const t=Object(n.a)(e);return this.connected(t),!0}return!1}attached(e){e.device&&this.matchesTarget(e.device)&&this.connected(e.device)}detached(e){e.device&&this.matchesTarget(e.device)&&this.isConnectedDevices(e.device)&&this.disconnected(e.device)}async connected(e){if(this.isConnectedDevices(e))throw new Error("USB Device already connected.");try{await e.open(),this.connectedDevices.push(e)}catch(e){throw new Error("USB Device cannot be opened.\n[Check driver installation.]")}}async disconnected(e){let t=this.connectedDevices.indexOf(e);if(t>=0){try{await e.close()}catch(e){}this.connectedDevices.splice(t,1)}}matchesTarget(e){return e.vendorId===this.vendorId&&e.productId===this.productId}isConnectedDevices(e){return this.connectedDevices.indexOf(e)>=0}}var s,o,a,c=r(0),u=r(2);class h{constructor(e){this.disposed=!1,this.onDisconnectListener=null,this.onDisconnectEvent=new u.a,this.onDisconnectListener=e(()=>this.disconnected())}get diposed(){return this.disposed}onDisconnect(e){return this.onDisconnectEvent.on(e)}disconnected(){this.onDisconnectEvent.emit(null),this.dispose()}dispose(){this.onDisconnectListener&&(this.onDisconnectListener.dispose(),this.onDisconnectListener=null),this.disposed=!0}}function f(e=[]){let t={machineData:{},rawData:e,validStructure:!1};if(0===e.length||!w(e))return t;for(let r=1;r<=8;r++)for(let n=0;n<3;n++){let i=32*r-2,s=10*n;if(1===e[i][s]){let r=A(e[i][s+1],e[i][s+2]);t.machineData[r]={position:{chest:v(e[i][s+3]),rom2:v(e[i][s+4]),rom1:v(e[i][s+5]),seat:v(e[i][s+6])},sets:[]};let n=e[i][s+7];l(e,t.machineData[r],n)}}return t.validStructure=!0,t}!function(e){e.dec="dec",e.int="int"}(s||(s={})),function(e){e.lb="lb",e.kg="kg",e.ne="ne",e.er="er"}(o||(o={})),function(e){e.power6r="power6r",e.a4206r="a4206r",e.a42010r="a42010r"}(a||(a={}));const l=(e,t,r)=>{let n=r%30,i=e[32*Math.floor(r/32)+31][n],c=e[r],u=_(c[7],c[8]),h={version:A(c[12],c[11],c[10],c[9]),serial:"",time:B(c[0],c[1],c[2],c[3]).toISOString(),resistance:_(c[4],c[5]),precision:s.int,units:o.lb,repetitions:c[6],peak:null,work:null,distance:null,seat:v(c[26]),rom2:v(c[27]),rom1:v(c[28]),chest:v(c[29]),test:null};if(h.serial=I(c[13],c[14],c[15],c[16],c[17],h.version),E(h.version))switch(128==(128&c[17])&&(h.resistance=h.resistance/10,h.precision=s.dec),96&c[17]){case 0:h.units=o.lb;break;case 32:h.units=o.kg;break;case 64:h.units=o.ne;break;case 96:h.units=o.er}if(b(h.version))if(h.repetitions>=252&&h.repetitions<=254){let e={type:a.power6r,low:null,high:null};switch(h.repetitions){case 254:e.type=a.power6r,e.low=O(c,18),e.high=O(c,24),h.repetitions=6;break;case 253:e.type=a.a4206r,h.repetitions=6;break;case 252:e.type=a.a42010r,h.repetitions=10}h.test=e}else D(h.version)&&(h.peak=_(c[20],c[21]),h.work=Math.round(_(c[22],c[23],c[24],c[25])/64*100)/100,12800==(65280&u)&&(h.distance=_(c[18],c[19])));t.sets||(t.sets=[]),t.sets.push(h),30!=(30&i)&&l(e,t,i)};function d(e){let t=U();let r=0,n=0;return Object.keys(e).forEach(i=>{if(r>24&&n>242)throw new Error("Data structure exceeds memory capacity.");const s=e[i],o=parseInt(i,16),a=32*Math.floor(r/3)+30,c=r%3*10;t[a][c]=1;const u=T(o);t[a][c+1]=u[0],t[a][c+2]=u[1],t[a][c+3]=m(s.position.chest),t[a][c+4]=m(s.position.rom2),t[a][c+5]=m(s.position.rom1),t[a][c+6]=m(s.position.seat),t[a][c+7]=n,s.sets.forEach((e,r)=>{let i=32*Math.floor(n/30)+n%30;p(o,e,s.position,t[i]);let a=32*Math.floor(n/30)+31,c=n%30;t[a][c]=r+1<s.sets.length?n+1:254,n++}),r++}),x(t),t}const p=(e,t,r,n)=>{const i=S(new Date(t.time)),o=T(t.resistance*(t.precision===s.dec?10:1));let c=t.repetitions;if(t.test)switch(t.test.type){case a.power6r:c=254;break;case a.a4206r:c=253;break;case a.a42010r:c=252}let u=T(e),h=T(parseInt(t.version,16)),f=R(t.serial),l=P(t.serial,t.version,t.precision,t.units);n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=o[0],n[5]=o[1],n[6]=c,n[7]=u[0],n[8]=u[1],n[9]=h[3],n[10]=h[2],n[11]=h[1],n[12]=h[0],n[13]=f[0],n[14]=f[1],n[15]=f[2],n[16]=f[3],n[17]=l,t.test?k(t.test,n):C(t,n)},w=e=>e.every((e,t)=>~~(t/2)%16==15?g(e):y(e)||g(e)),y=e=>e.every(e=>85===e),g=e=>{let t=0;for(let r of e)for(let e=0;e<8;e++){let e=(r^t)%2;t>>=1,r>>=1,e&&(t^=40961)}return 45057===t},v=e=>255===e?null:e,m=e=>null===e?255:e,b=e=>parseInt(e,16)>795179504,D=e=>parseInt(e,16)>851074185,E=e=>parseInt(e,16)>831409920,A=(...e)=>{let t="";return e.reverse().forEach(e=>t+=("00"+e.toString(16)).substr(-2).toUpperCase()),t},_=(...e)=>{let t=0;return e.forEach((e,r)=>t+=(255&e)<<8*r),t},T=e=>[255&e,(65280&e)>>8,(16711680&e)>>16,(4278190080&e)>>24],B=(...e)=>new Date(1e3*_(...e)),S=e=>T(e.getTime()/1e3),I=(e,t,r,n,i,s)=>{let o=(e=>("00"+(e.getUTCMonth()+1)).substr(-2)+("00"+e.getUTCDate()).substr(-2)+" "+e.getUTCFullYear()+" "+("00"+e.getUTCHours()).substr(-2)+("00"+e.getUTCMinutes()).substr(-2)+" "+("00"+e.getUTCSeconds()).substr(-2))(B(e,t,r,n));return E(s)?o+=("00"+(32+(31&i)).toString()).substr(-2):(o+=((240&i)/16).toString(16),o+=(31&i).toString(16)),o},R=e=>{const t=/(\d{2})(\d{2}) (\d{4}) (\d{2})(\d{2}) (\d{2})/.exec(e);if(null===t||7!==t.length)throw new Error("Invalid serial string.");const r=t.slice(1).map(e=>parseInt(e,10)),n=Date.UTC(r[2],r[0]-1,r[1],r[3],r[4],r[5]);return T(n/1e3)},P=(e,t,r,n)=>{let i=0;switch(i=E(t)?parseInt(e.substr(-2),10)-32:parseInt(e.substr(-2),10),r===s.dec&&(i|=128),n){case o.kg:i|=32;break;case o.ne:i|=64;break;case o.er:i|=96}return i},U=()=>{let e=new Array(256);for(let t=0;t<e.length;t++){e[t]=new Uint8Array(32);for(let r=0;r<e[t].length;r++)t>0&&(t%32==30||t%32==31)?r===e[t].length-1?e[t][r]=207:e[t][r]=255:e[t][r]=85}return e},C=(e,t)=>{const r=T(e.peak||0),n=T(64*(e.work||0)),i=T(e.distance||0);t[18]=i[0],t[19]=i[1],t[20]=r[0],t[21]=r[1],t[22]=n[0],t[23]=n[1],t[24]=n[2],t[25]=n[3],t[26]=m(e.seat),t[27]=m(e.rom2),t[28]=m(e.rom1),t[29]=m(e.chest)},k=(e,t)=>{e.low&&M(e.low,18,t),e.high&&M(e.high,24,t)},O=(e,t)=>({power:e[t]+((31&e[t+2])<<8),velocity:e[t+1]+((224&e[t+2])<<3),force:e[t+3]+((240&e[t+5])<<4),position:e[t+4]+((15&e[t+5])<<8)}),M=(e,t,r)=>{r[t++]=255&e.power,r[t++]=255&e.velocity,r[t++]=((7936&e.power)>>8)+((1792&e.velocity)>>3),r[t++]=255&e.force,r[t++]=255&e.position,r[t++]=((3840&e.position)>>8)+((3840&e.force)>>4)},x=e=>{e.forEach(e=>{if(!y(e)){let t=0;for(let r=0;r<30;r++){let n=e[r];for(let e=0;e<8;e++){let e=(n^t)%2;t>>=1,n>>=1,e&&(t^=40961)}}let r=T(65535^t);e[30]=r[0],e[31]=r[1]}})};class N extends h{constructor(e,t,r){super(r),this.echipId=e,this.owDevice=t,this.data=this.loadData(),c.a.info("EChip connected: "+this.id)}get id(){return this.echipId.reduce((e,t)=>e+=(15&t).toString(16)+(t>>4&15).toString(16),"").split("").reverse().join("")}destroy(){this.disconnected()}async getData(){return this.data}async clearData(){let e=d({});try{let t=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,e,t,!1)}catch(t){await this.owDevice.keyWriteAll(this.echipId,e,!1)}this.data=new Promise(t=>t(f(e)))}async setData(e){let t=d(e),r=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,t,r,!1),this.data=new Promise(e=>e(f(t)))}async dispose(){await super.dispose(),c.a.info("EChip disconnected: "+this.id)}async loadData(){let e=f(await this.owDevice.keyReadAll(this.echipId,!1));return e.validStructure||c.a.warn("Invalid Data Structure"),e}}var L=r(4);class Y{constructor(e,t){this.disposed=!1,this.onDisconnectListener=null,this.onEChipDetectEvent=new u.a,this.onDisconnectEvent=new u.a,this.activeKeys=new Map,this.onDisconnectListener=t(e=>this.disconnected(e)),this.usbDevice=e,this.owDevice=new L.a(e,e=>this.echipsDetected(e)),this.claimed=this.owDevice.claim().then(()=>(c.a.info("EChip Reader connected."),this.owDevice.startSearch(),!0))}get diposed(){return this.disposed}onDisconnect(e){return this.onDisconnectEvent.on(e)}onEChipDetect(e){this.onEChipDetectEvent.on(e)}echipsDetected(e){let t=[];e.forEach(e=>{let r=e.join();if(t.push(r),!this.activeKeys.has(r)){let t=new N(e,this.owDevice,e=>this.onDisconnect(e));this.activeKeys.set(r,t),this.onEChipDetectEvent.emit(t)}}),this.activeKeys.forEach((e,r)=>{t.includes(r)||(e.destroy(),this.activeKeys.delete(r))})}disconnected(e){this.usbDevice===e&&(this.onDisconnectEvent.emit(null),this.dispose())}async dispose(){await this.owDevice.close(),this.onDisconnectListener&&(this.onDisconnectListener.dispose(),this.onDisconnectListener=null),this.disposed=!0,c.a.info("EChip Reader disconnected.")}}r.d(t,"EChipReaderWatcher",(function(){return W}));const q=1274,j=9360;class W extends i{constructor(){super(q,j),this.onConnectEvent=new u.a,this.onDisconnectEvent=new u.a}stop(){this.connectedDevices.forEach(e=>this.disconnected(e))}onConnect(e){return this.onConnectEvent.on(e)}onDisconnect(e){return this.onDisconnectEvent.on(e)}async connected(e){await super.connected(e);const t=new Y(e,e=>this.onDisconnect(e));await t.claimed,this.onConnectEvent.emit(t)}async disconnected(e){await super.disconnected(e),this.onDisconnectEvent.emit(e)}}t.default=new W}])}));
{
"name": "@keiser/echip-webusb",
"version": "1.1.3",
"version": "1.2.0",
"description": "Keiser Air eChip WebUSB Library",

@@ -5,0 +5,0 @@ "keywords": [

@@ -16,10 +16,12 @@ # Keiser Air eChip WebUSB Library

Import module using preferred module loading technique and construct a new `EChipReaderWatcher` class.
Import singleton instance from module using preferred module loading technique.
```ts
import EChipReaderWatcher from '@keiser/echip-webusb'
const echipReaderWatcher = new EChipReaderWatcher()
if (EChipReaderWatcher.isConnected) {
console.log('EChip Reader Connected 😄')
}
```
The `EChipReaderWatcher` handles permissions and USB connection events. On first load, the browser will not have provided a grant to the site to access the USB device, so the `echipReaderWatcher.start()` method must be called by an event that originates from a user action. This may only be required once on the first visit to the site, or it may be required each time the site is loaded based on browser vendors preferred implementation.
The `EChipReaderWatcher` handles permissions and USB connection events. On first load, the browser will not have provided a grant to the site to access the USB device, so the `EChipReaderWatcher.start()` method must be called by an event that originates from a user action. This may only be required once on the first visit to the site, or it may be required each time the site is loaded based on browser vendors preferred implementation.

@@ -29,3 +31,3 @@ ```ts

try {
await echipReaderWatcher.start()
await EChipReaderWatcher.start()
} catch (error) {

@@ -37,6 +39,6 @@ console.error(error.message)

Once the `echipReaderWatcher.start()` method has been called the class will prompt the browser for permission and begin watching for devices matching the EChip Readers device signature. To be alerted when a device is found, pass a function to the `echipReaderWatcher.onConnect()` method.
Once the `EChipReaderWatcher.start()` method has been called the class will prompt the browser for permission and begin watching for devices matching the EChip Readers device signature. To be alerted when a device is found, pass a function to the `EChipReaderWatcher.onConnect()` method.
```ts
echipReaderWatcher.onConnect((echipReader) => {
EChipReaderWatcher.onConnect((echipReader) => {
console.log('EChip Reader Connected 😄')

@@ -46,3 +48,3 @@ })

The `echipReaderWatcher.onConnect()` will pass in an `EChipReader` object which is the object bound to the physical device connected. This library is capable of handling multiple EChip Reader devices simultaneously, so the `onConnect()` method has potential for returning multiple `EChipReader` devices over the course of the application's life.
The `EChipReaderWatcher.onConnect()` will pass in an `EChipReader` object which is the object bound to the physical device connected. This library is capable of handling multiple EChip Reader devices simultaneously, so the `onConnect()` method has potential for returning multiple `EChipReader` devices over the course of the application's life.

@@ -64,3 +66,3 @@ ```ts

The `EChipReader` object also has an `onEChipDetect()` method which will alert when a valid EChip has been placed into the reader. The event passes in an `EChip` object that can be used to interact with the EChip data directly. Just like the `echipReaderWatcher.onConnect()` method, the `EChipReader.onEChipDetect()` method can be called multiple times for multiple EChips all being handled concurrently. Once an EChip is disconnected, the `EChip` object is disposed and cannot be reused.
The `EChipReader` object also has an `onEChipDetect()` method which will alert when a valid EChip has been placed into the reader. The event passes in an `EChip` object that can be used to interact with the EChip data directly. Just like the `EChipReaderWatcher.onConnect()` method, the `EChipReader.onEChipDetect()` method can be called multiple times for multiple EChips all being handled concurrently. Once an EChip is disconnected, the `EChip` object is disposed and cannot be reused.

@@ -72,3 +74,2 @@ Full example usage:

document.addEventListener('DOMContentLoaded', event => {
const echipReaderWatcher = new EChipReaderWatcher()
const connectButton = document.querySelector('#connect') as HTMLInputElement

@@ -79,3 +80,3 @@

try {
await echipReaderWatcher.start()
await EChipReaderWatcher.start()
} catch (error) {

@@ -87,6 +88,6 @@ console.error(error.message)

echipReaderWatcher.onConnect((echipReader) => {
EChipReaderWatcher.onConnect((echipReader) => {
console.log('EChip Reader Connected 😄')
echipReader.onEChipDetect((echip) => {
echipReader.onEChipDetect(async (echip) => {
console.log('EChip Connected: ' + echip.id)

@@ -105,4 +106,48 @@ console.log(await echip.getData())

_Coming Soon_
### EChipReaderWatcher
The `EChipReaderWatcher` is a singleton class which handles the USB device monitoring and permissions handling. There can be only one `EChipReaderWatcher` instance created within a `window` scope, so the library instantiates the class during import and preserves a single instance for all imports.
#### Properties
| Name | Type | Usage |
| ---- | ----------- | ----- |
| `isConnected` | `Boolean` | Indicates whether an eChip Reader Device is connected |
#### Properties
| Name | Parameters | Return Type | Usage |
| ---- | ---------- | ----------- | ----- |
| `onConnect` | `Listener<EChipReader>` | `Disposable` | Adds an event listener for when an eChip Reader Device is connected |
```ts
import EChipReaderWatcher from '@keiser/echip-webusb'
document.addEventListener('DOMContentLoaded', event => {
const connectButton = document.querySelector('#connect') as HTMLInputElement
if (connectButton) {
connectButton.addEventListener('click', async () => {
try {
await EChipReaderWatcher.start()
} catch (error) {
console.error(error.message)
}
})
}
EChipReaderWatcher.onConnect((echipReader) => {
console.log('EChip Reader Connected 😄')
echipReader.onEChipDetect(async (echip) => {
console.log('EChip Connected: ' + echip.id)
console.log(await echip.getData())
})
echipReader.onDisconnect(() => {
console.log('EChip Reader Disconnected 😞')
})
})
})
```
## References

@@ -109,0 +154,0 @@ [Maxim Integrated 1-Wire USB Android notes](https://www.maximintegrated.com/en/app-notes/index.mvp/id/5705)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc