@keiser/echip-webusb
Advanced tools
Comparing version 1.0.11 to 1.1.0
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.EChip=e():t.EChip=e()}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=10)}([function(t,e,r){"use strict";r.d(e,"a",(function(){return n}));class n{static info(t){this.enabled()&&console.info(t)}static warn(t){this.enabled()&&console.warn(t)}static error(t){this.enabled()&&console.error(t)}static enabled(){return!0===window.DEBUG_ECHIP}}},function(t,e,r){"use strict";(function(t){ | ||
!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){ | ||
/*! | ||
@@ -8,2 +8,2 @@ * The buffer module from node.js, for the browser. | ||
*/ | ||
var n=r(6),i=r(7),s=r(8);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return u(this,t,e,r)}function u(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=l(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,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(e,r),i=(t=a(t,n)).write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(c.isBuffer(e)){var r=0|d(e.length);return 0===(t=a(t,r)).length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):l(t,e);if("Buffer"===e.type&&s(e.data))return l(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(h(e),t=a(t,e<0?0:0|d(e)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function l(t,e){var r=e.length<0?0:0|d(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function d(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(n)return j(t).length;e=(""+e).toLowerCase(),n=!0}}function w(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return R(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.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:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,i);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var s,o=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var h=-1;for(s=r;s<a;s++)if(u(t,s)===u(e,-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(t,s+l)!==u(e,l)){f=!1;break}if(f)return s}return-1}function m(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=e.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(e.substr(2*o,2),16);if(isNaN(a))return o;t[r+o]=a}return o}function b(t,e,r,n){return F(j(e,t.length-r),t,r,n)}function D(t,e,r,n){return F(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return D(t,e,r,n)}function A(t,e,r,n){return F(W(e),t,r,n)}function B(t,e,r,n){return F(function(t,e){for(var r,n,i,s=[],o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}(e,t.length-r),t,r,n)}function _(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function R(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var s,o,a,c,u=t[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=t[i+1]))&&(c=(31&u)<<6|63&s)>127&&(h=c);break;case 3:s=t[i+1],o=t[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=t[i+1],o=t[i+2],a=t[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(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=S));return r}(n)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=o(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,r){return u(null,t,e,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(t,e,r){return function(t,e,r,n){return h(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},c.allocUnsafe=function(t){return f(null,t)},c.allocUnsafeSlow=function(t){return f(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,s=Math.min(r,n);i<s;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).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(t,e){if(!s(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=c.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[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 t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?R(this,0,t):w.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,r,n,i){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,i),h=t.slice(e,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(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return g(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return g(this,t,e,r,!1)},c.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>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,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return D(this,t,e,r);case"latin1":case"binary":return E(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,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 T(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function I(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function U(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=e;s<r;++s)i+=q(t[s]);return i}function P(t,e,r){for(var n=t.slice(e,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function k(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,n,i,s){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function M(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i<s;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function x(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i<s;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function O(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Y(t,e,r,n,s){return s||O(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function L(t,e,r,n,s){return s||O(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=c.prototype;else{var i=e-t;r=new c(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+t]}return r},c.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||k(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n},c.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUInt8=function(t,e){return e||k(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||k(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||k(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||k(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||k(t,e,this.length);for(var n=e,i=1,s=this[t+--n];n>0&&(i*=256);)s+=this[t+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},c.prototype.readInt8=function(t,e){return e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||k(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||k(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||k(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||k(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[e]=255&t;++s<r&&(i*=256);)this[e+s]=t/i&255;return e+r},c.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):x(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):x(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);C(this,t,e,r,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s<r&&(o*=256);)t<0&&0===a&&0!==this[e+s-1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);C(this,t,e,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):x(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):x(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return Y(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return Y(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<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),t.length-e<n-r&&(n=t.length-e+r);var i,s=n-r;if(this===t&&r<e&&e<n)for(i=s-1;i>=0;--i)t[i+e]=this[i+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),e);return s},c.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=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 t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var s;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var o=c.isBuffer(t)?t:j(new c(t,n).toString()),a=o.length;for(s=0;s<r-e;++s)this[s+e]=o[s%a]}return this};var N=/[^+\/0-9A-Za-z-_]/g;function q(t){return t<16?"0"+t.toString(16):t.toString(16)}function j(t,e){var r;e=e||1/0;for(var n=t.length,i=null,s=[],o=0;o<n;++o){if((r=t.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=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((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function W(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(N,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}}).call(this,r(5))},function(t,e,r){"use strict";(function(t){r.d(e,"a",(function(){return d}));var n=r(0),i=r(4),s=r(3);const o=64,a=500,c=200,u=1,h=t=>12===t[0]&&0!==t[7],f=()=>new Promise(t=>setTimeout(()=>{t()},c));class l{constructor(t){const e=new Uint8Array(t.buffer);this.commCommandBufferStatus=e[11],this.dataOutBufferStatus=e[12],this.dataInBufferStatus=e[13],this.detectKey=165===e[16],this.data=e.slice(16,e.length)}}class d{constructor(t,e=(t=>{})){this.mutex=new s.Mutex,this.searching=!1,this.usbDevice=t,this.onDetectKeys=e;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 t=this.usbDevice.configurations[0],e=t.interfaces[0];try{null!==this.usbDevice.configuration&&void 0!==this.usbDevice.configuration&&this.usbDevice.configuration.configurationValue===t.configurationValue||await this.usbDevice.selectConfiguration(t.configurationValue),await this.usbDevice.claimInterface(e.interfaceNumber),await this.usbDevice.selectAlternateInterface(e.interfaceNumber,e.alternates[u].alternateSetting),await this.deviceReset()}catch(t){throw new Error("1-Wire Device interface cannot be claimed.")}return!0}async startSearch(){this.searching||(this.searching=!0,this.awaitKey())}async close(){if(this.searching=!1,this.usbDevice.configuration&&this.usbDevice.configuration.interfaces[0]){let t=await this.mutex.acquire();try{await this.usbDevice.releaseInterface(this.usbDevice.configuration.interfaces[0].interfaceNumber)}catch(t){}t()}}awaitKey(){setTimeout(async()=>{if(this.searching){let t=await this.mutex.acquire();try{await Promise.race([this.keySearch(),f()])}catch(t){}t(),this.awaitKey()}},a)}async keySearch(){let t=[];try{let e=await this.romSearch();if(e.result){for(h(e.key)&&t.push(e.key);e.result&&!e.lastDevice;)(e=await e.next()).result&&h(e.key)&&t.push(e.key);this.onDetectKeys(t)}}catch(t){this.deviceReset()}}async deviceStatus(){let t=await this.usbDevice.transferIn(this.interrupt.endpointNumber,32);if(!t.data)throw new Error("1-Wire Device status read error.");return new l(t.data)}async bufferClear(){0!==(await this.deviceStatus()).commCommandBufferStatus&&await this.bufferClear()}async setSpeed(t){const e=t?2:1;if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:2,value:2,index:e})).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(t,e=!1){try{if("ok"!==(await this.usbDevice.transferOut(this.bulkIn.endpointNumber,t.buffer)).status)throw new Error;if(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:4213,index:t.length}),e){let e=0;do{e+=(await this.read(t.length-e)).length}while(e<t.length)}}catch(t){throw new Error("1-Wire Device write failed.")}}async writeBit(t){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:545|t<<3,index:0})).status)throw new Error("1-Wire Device write bit failed.")}async read(t){let e=this.usbDevice.transferIn(this.bulkOut.endpointNumber,t),r=new Promise((t,e)=>setTimeout(()=>e(),c));try{let t=await Promise.race([e,r]);if(!(t instanceof USBInTransferResult)||"ok"!==t.status||void 0===t.data)throw new Error;return new Uint8Array(t.data.buffer)}catch(t){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(t=null,e=!1){let r=t?e?105:85:e?60:204,n=t?t.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(e),i=await this.usbDevice.transferOut(this.bulkIn.endpointNumber,n)}async romMatch(t,e=!1){return this.romCommand(t,e)}async romSearch(t=0){await this.setSpeed(!1),await this.reset(),await this.write(new Uint8Array([240]),!0);let e=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:t});return{result:e.searchResult,key:e.romId,lastDevice:e.lastDevice,next:async()=>this.romSearch(e.lastDiscrepancy)}}async romSubSearch(e){return e.idBit=await this.readBit(),e.cmpIdBit=await this.readBit(),1!==e.idBit||1!==e.cmpIdBit?(e.idBit!==e.cmpIdBit?e.searchDirection=e.idBit:(e.idBitNumber<e.lastDiscrepancy?e.searchDirection=(e.romId[e.romByteNumber]&e.romByteMask)>0?1:0:e.searchDirection=e.idBitNumber===e.lastDiscrepancy?1:0,0===e.searchDirection&&(e.lastZero=e.idBitNumber)),1===e.searchDirection?e.romId[e.romByteNumber]|=e.romByteMask:e.romId[e.romByteNumber]&=~e.romByteMask,await this.writeBit(e.searchDirection),e.idBitNumber++,e.romByteMask<<=1,e.romByteMask>=256&&(e.romByteNumber++,e.romByteMask=1),e.romByteNumber<8?this.romSubSearch(e):(e.idBitNumber>=65&&0===Object(i.a)(new t(e.romId))&&(e.lastDiscrepancy=e.lastZero,0===e.lastDiscrepancy&&(e.lastDevice=!0),e.searchResult=!0),!1!==e.searchResult&&0!==e.romId[0]||(e.lastDiscrepancy=0,e.lastDevice=!0,e.searchResult=!1),e)):e}async keyWrite(t,e=0,r=new Uint8Array(0),n=!1){const i=255&e,s=(65280&e)>>8,a=r.length-1,c=async(t,e=0,r=new Uint8Array(0),n=!1)=>{const a=async(t,e=0)=>{const r=Math.min(o,t.length-e),n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t[e+i];await this.write(n),t.length-(e+r)>0&&await a(t,e+r)};await this.reset(),await this.romMatch(t,n);const u=new Uint8Array([15,i,s]);await this.write(u,!0),await a(r),await this.reset(),await this.romMatch(t,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((t,e)=>t===r[e])||await c(t,e,r,n)};await this.setSpeed(!1),await c(t,e,r,n),await this.reset(),await this.romMatch(t,n);const u=new Uint8Array([85,i,s,a]);await this.write(u,!0)}async keyWriteAll(t,e=[],r=!1){const i=async(t,e=0,r=[],n=!1)=>{const s=32*e;await this.keyWrite(t,s,r[e],n),r.length>e+1&&await i(t,e+1,r,n)},s=await this.mutex.acquire(),o=performance.now();try{await this.deviceReset(),await i(t,0,e,r),n.a.info("Write All Completed: "+Math.round(performance.now()-o)+"ms")}finally{s()}}async keyWriteDiff(t,e=[],r=[],i=!1){const s=async(t,e=0,r=[],n=[],i=!1)=>{const o=32*e;r[e].length===n[e].length&&r[e].every((t,r)=>t===n[e][r])||await this.keyWrite(t,o,r[e],i),r.length>e+1&&await s(t,e+1,r,n,i)};if(r.length!==e.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(t,0,e,r,i),n.a.info("Write Diff Completed: "+Math.round(performance.now()-a)+"ms")}finally{o()}}async keyReadAll(t,e=!1){const r=async(t,e=0)=>{const n=Math.min(o,t.length-e);(await this.read(n)).forEach(r=>t[e++]=r),e<t.length&&await r(t,e)},i=async(t=new Array(256),e=0)=>{t[e]=new Uint8Array(32);let n=new Uint8Array(32).fill(255);return await this.write(n),await r(t[e++]),e<t.length&&await i(t,e),t},s=async e=>{await this.setSpeed(!1),await this.reset(),await this.romMatch(t,e);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(e)}catch(t){return n.a.warn("Read All "+(e?"Overdrive ":"")+"Failed: "+t.message),await this.deviceReset(),await s(!1)}}catch(t){n.a.error("Read All Failed: "+t.message),await this.deviceReset()}finally{a(),n.a.info("Read All Completed: "+Math.round(performance.now()-c)+"ms")}}}}).call(this,r(1).Buffer)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(9);e.Mutex=n.default},function(t,e,r){"use strict";var n=r(1);var i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:t=>new n.Buffer(t);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(t,e){const r=(t,r)=>e(t,r)>>>0;return r.signed=e,r.unsigned=r,r.model=t,r}("dallas-1-wire",(function(t,e){n.Buffer.isBuffer(t)||(t=i(t));let r=~~e;for(let e=0;e<t.length;e++){const n=t[e];r=255&s[255&(r^n)]}return r}));e.a=o},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){for(var e,r=u(t),n=r[0],o=r[1],a=new s(function(t,e,r){return 3*(e+r)/4-r}(0,n,o)),c=0,h=o>0?n-4:n,f=0;f<h;f+=4)e=i[t.charCodeAt(f)]<<18|i[t.charCodeAt(f+1)]<<12|i[t.charCodeAt(f+2)]<<6|i[t.charCodeAt(f+3)],a[c++]=e>>16&255,a[c++]=e>>8&255,a[c++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,a[c++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,a[c++]=e>>8&255,a[c++]=255&e);return a},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,s=[],o=0,a=r-i;o<a;o+=16383)s.push(h(t,o,o+16383>a?a:o+16383));1===i?(e=t[r-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<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(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var i,s,o=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[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(t,e){e.read=function(t,e,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=t[e+f];for(f+=l,s=d&(1<<-h)-1,d>>=-h,h+=a;h>0;s=256*s+t[e+f],f+=l,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+t[e+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)},e.write=function(t,e,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=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),(e+=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=(e*c-1)*Math.pow(2,i),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*w}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){this._queue=[],this._pending=!1}return t.prototype.isLocked=function(){return this._pending},t.prototype.acquire=function(){var t=this,e=new Promise((function(e){return t._queue.push(e)}));return this._pending||this._dispatchNext(),e},t.prototype.runExclusive=function(t){return this.acquire().then((function(e){var r;try{r=t()}catch(t){throw e(),t}return Promise.resolve(r).then((function(t){return e(),t}),(function(t){throw e(),t}))}))},t.prototype._dispatchNext=function(){this._queue.length>0?(this._pending=!0,this._queue.shift()(this._dispatchNext.bind(this))):this._pending=!1},t}();e.default=n},function(t,e,r){"use strict";r.r(e);class n{constructor(t,e){this.connectedDevices=[],this.vendorId=t,this.productId=e,navigator.usb.addEventListener("connect",t=>{this.attached(t)}),navigator.usb.addEventListener("disconnect",t=>{this.detached(t)}),this.checkDevices()}get isConnected(){return this.connectedDevices.length>0}async start(){await this.requestPermission()}async requestPermission(){let t;try{t=await navigator.usb.requestDevice({filters:[{vendorId:this.vendorId,productId:this.productId}]})}catch(t){throw new Error("USB Device permission denied.")}t&&this.connected(t)}async checkDevices(){(await navigator.usb.getDevices()).some(t=>!!this.matchesTarget(t)&&(this.connected(t),!0))}attached(t){t instanceof USBConnectionEvent&&this.matchesTarget(t.device)&&this.connected(t.device)}detached(t){t instanceof USBConnectionEvent&&this.matchesTarget(t.device)&&this.isConnectedDevices(t.device)&&this.disconnected(t.device)}async connected(t){if(this.isConnectedDevices(t))throw new Error("USB Device already connected.");try{await t.open(),this.connectedDevices.push(t)}catch(t){throw new Error("USB Device cannot be opened.\n[Check driver installation.]")}}async disconnected(t){let e=this.connectedDevices.indexOf(t);if(e>=0){try{await t.close()}catch(t){}this.connectedDevices.splice(e,1)}}matchesTarget(t){return t.vendorId===this.vendorId&&t.productId===this.productId}isConnectedDevices(t){return this.connectedDevices.indexOf(t)>=0}}var i,s,o,a=r(0);class c{constructor(){this.listeners=[]}on(t){return this.listeners.push(t),{dispose:()=>this.off(t)}}off(t){let e=this.listeners.indexOf(t);e>-1&&this.listeners.splice(e,1)}emit(t){this.listeners.forEach(e=>e(t))}}class u{constructor(t){this.disposed=!1,this.onDisconnectListener=null,this.onDisconnectEvent=new c,this.onDisconnectListener=t(()=>this.disconnected())}get diposed(){return this.disposed}onDisconnect(t){return this.onDisconnectEvent.on(t)}disconnected(){this.onDisconnectEvent.emit(null),this.dispose()}dispose(){this.onDisconnectListener&&(this.onDisconnectListener.dispose(),this.onDisconnectListener=null),this.disposed=!0}}function h(t=[]){let e={machineData:{},rawData:t,validStructure:!1};if(0===t.length||!p(t))return e;for(let r=1;r<=8;r++)for(let n=0;n<3;n++){let i=32*r-2,s=10*n;if(1===t[i][s]){let r=E(t[i][s+1],t[i][s+2]);e.machineData[r]={position:{chest:g(t[i][s+3]),rom2:g(t[i][s+4]),rom1:g(t[i][s+5]),seat:g(t[i][s+6])},sets:[]};let n=t[i][s+7];f(t,e.machineData[r],n)}}return e.validStructure=!0,e}!function(t){t.dec="dec",t.int="int"}(i||(i={})),function(t){t.lb="lb",t.kg="kg",t.ne="ne",t.er="er"}(s||(s={})),function(t){t.power6r="power6r",t.a4206r="a4206r",t.a42010r="a42010r"}(o||(o={}));const f=(t,e,r)=>{let n=r%30,a=t[32*Math.floor(r/32)+31][n],c=t[r],u=A(c[7],c[8]),h={version:E(c[12],c[11],c[10],c[9]),serial:"",time:_(c[0],c[1],c[2],c[3]).toISOString(),resistance:A(c[4],c[5]),precision:i.int,units:s.lb,repetitions:c[6],peak:null,work:null,distance:null,seat:g(c[26]),rom2:g(c[27]),rom1:g(c[28]),chest:g(c[29]),test:null};if(h.serial=S(c[13],c[14],c[15],c[16],c[17],h.version),D(h.version))switch(128==(128&c[17])&&(h.resistance=h.resistance/10,h.precision=i.dec),96&c[17]){case 0:h.units=s.lb;break;case 32:h.units=s.kg;break;case 64:h.units=s.ne;break;case 96:h.units=s.er}if(m(h.version))if(h.repetitions>=252&&h.repetitions<=254){let t={type:o.power6r,low:null,high:null};switch(h.repetitions){case 254:t.type=o.power6r,t.low=C(c,18),t.high=C(c,24),h.repetitions=6;break;case 253:t.type=o.a4206r,h.repetitions=6;break;case 252:t.type=o.a42010r,h.repetitions=10}h.test=t}else b(h.version)&&(h.peak=A(c[20],c[21]),h.work=Math.round(A(c[22],c[23],c[24],c[25])/64*100)/100,12800==(65280&u)&&(h.distance=A(c[18],c[19])));e.sets||(e.sets=[]),e.sets.push(h),30!=(30&a)&&f(t,e,a)};function l(t){let e=U();let r=0,n=0;return Object.keys(t).forEach(i=>{if(r>24&&n>242)throw new Error("Data structure exceeds memory capacity.");const s=t[i],o=parseInt(i,16),a=32*Math.floor(r/3)+30,c=r%3*10;e[a][c]=1;const u=B(o);e[a][c+1]=u[0],e[a][c+2]=u[1],e[a][c+3]=v(s.position.chest),e[a][c+4]=v(s.position.rom2),e[a][c+5]=v(s.position.rom1),e[a][c+6]=v(s.position.seat),e[a][c+7]=n,s.sets.forEach((t,r)=>{let i=32*Math.floor(n/30)+n%30;d(o,t,s.position,e[i]);let a=32*Math.floor(n/30)+31,c=n%30;e[a][c]=r+1<s.sets.length?n+1:254,n++}),r++}),x(e),e}const d=(t,e,r,n)=>{const s=R(new Date(e.time)),a=B(e.resistance*(e.precision===i.dec?10:1));let c=e.repetitions;if(e.test)switch(e.test.type){case o.power6r:c=254;break;case o.a4206r:c=253;break;case o.a42010r:c=252}let u=B(t),h=B(parseInt(e.version,16)),f=T(e.serial),l=I(e.serial,e.version,e.precision,e.units);n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=a[0],n[5]=a[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,e.test?k(e.test,n):P(e,n)},p=t=>t.every((t,e)=>~~(e/2)%16==15?y(t):w(t)||y(t)),w=t=>t.every(t=>85===t),y=t=>{let e=0;for(let r of t)for(let t=0;t<8;t++){let t=(r^e)%2;e>>=1,r>>=1,t&&(e^=40961)}return 45057===e},g=t=>255===t?null:t,v=t=>null===t?255:t,m=t=>parseInt(t,16)>795179504,b=t=>parseInt(t,16)>851074185,D=t=>parseInt(t,16)>831409920,E=(...t)=>{let e="";return t.reverse().forEach(t=>e+=("00"+t.toString(16)).substr(-2).toUpperCase()),e},A=(...t)=>{let e=0;return t.forEach((t,r)=>e+=(255&t)<<8*r),e},B=t=>[255&t,(65280&t)>>8,(16711680&t)>>16,(4278190080&t)>>24],_=(...t)=>new Date(1e3*A(...t)),R=t=>B(t.getTime()/1e3),S=(t,e,r,n,i,s)=>{let o=(t=>("00"+(t.getUTCMonth()+1)).substr(-2)+("00"+t.getUTCDate()).substr(-2)+" "+t.getUTCFullYear()+" "+("00"+t.getUTCHours()).substr(-2)+("00"+t.getUTCMinutes()).substr(-2)+" "+("00"+t.getUTCSeconds()).substr(-2))(_(t,e,r,n));return D(s)?o+=("00"+(32+(31&i)).toString()).substr(-2):(o+=((240&i)/16).toString(16),o+=(31&i).toString(16)),o},T=t=>{const e=/(\d{2})(\d{2}) (\d{4}) (\d{2})(\d{2}) (\d{2})/.exec(t);if(null===e||7!==e.length)throw new Error("Invalid serial string.");const r=e.slice(1).map(t=>parseInt(t,10)),n=Date.UTC(r[2],r[0]-1,r[1],r[3],r[4],r[5]);return B(n/1e3)},I=(t,e,r,n)=>{let o=0;switch(o=D(e)?parseInt(t.substr(-2),10)-32:parseInt(t.substr(-2),10),r===i.dec&&(o|=128),n){case s.kg:o|=32;break;case s.ne:o|=64;break;case s.er:o|=96}return o},U=()=>{let t=new Array(256);for(let e=0;e<t.length;e++){t[e]=new Uint8Array(32);for(let r=0;r<t[e].length;r++)e>0&&(e%32==30||e%32==31)?r===t[e].length-1?t[e][r]=207:t[e][r]=255:t[e][r]=85}return t},P=(t,e)=>{const r=B(t.peak||0),n=B(64*(t.work||0)),i=B(t.distance||0);e[18]=i[0],e[19]=i[1],e[20]=r[0],e[21]=r[1],e[22]=n[0],e[23]=n[1],e[24]=n[2],e[25]=n[3],e[26]=v(t.seat),e[27]=v(t.rom2),e[28]=v(t.rom1),e[29]=v(t.chest)},k=(t,e)=>{t.low&&M(t.low,18,e),t.high&&M(t.high,24,e)},C=(t,e)=>({power:t[e]+((31&t[e+2])<<8),velocity:t[e+1]+((224&t[e+2])<<3),force:t[e+3]+((240&t[e+5])<<4),position:t[e+4]+((15&t[e+5])<<8)}),M=(t,e,r)=>{r[e++]=255&t.power,r[e++]=255&t.velocity,r[e++]=((7936&t.power)>>8)+((1792&t.velocity)>>3),r[e++]=255&t.force,r[e++]=255&t.position,r[e++]=((3840&t.position)>>8)+((3840&t.force)>>4)},x=t=>{t.forEach(t=>{if(!w(t)){let e=0;for(let r=0;r<30;r++){let n=t[r];for(let t=0;t<8;t++){let t=(n^e)%2;e>>=1,n>>=1,t&&(e^=40961)}}let r=B(65535^e);t[30]=r[0],t[31]=r[1]}})};class O extends u{constructor(t,e,r){super(r),this.echipId=t,this.owDevice=e,this.data=this.loadData(),a.a.info("EChip connected: "+this.id)}get id(){return this.echipId.reduce((t,e)=>t+=(15&e).toString(16)+(e>>4&15).toString(16),"").split("").reverse().join("")}destroy(){this.disconnected()}async getData(){return this.data}async clearData(){let t=l({});try{let e=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,t,e,!1)}catch(e){await this.owDevice.keyWriteAll(this.echipId,t,!1)}this.data=new Promise(e=>e(h(t)))}async setData(t){let e=l(t),r=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,e,r,!1),this.data=new Promise(t=>t(h(e)))}async dispose(){await super.dispose(),a.a.info("EChip disconnected: "+this.id)}async loadData(){let t=h(await this.owDevice.keyReadAll(this.echipId,!1));return t.validStructure||a.a.warn("Invalid Data Structure"),t}}var Y=r(2);class L{constructor(t,e){this.disposed=!1,this.onDisconnectListener=null,this.onEChipDetectEvent=new c,this.onDisconnectEvent=new c,this.activeKeys=new Map,this.onDisconnectListener=e(t=>this.disconnected(t)),this.usbDevice=t,this.owDevice=new Y.a(t,t=>this.echipsDetected(t)),this.claimed=this.owDevice.claim().then(()=>(a.a.info("EChip Reader connected."),this.owDevice.startSearch(),!0))}get diposed(){return this.disposed}onDisconnect(t){return this.onDisconnectEvent.on(t)}onEChipDetect(t){this.onEChipDetectEvent.on(t)}echipsDetected(t){let e=[];t.forEach(t=>{let r=t.join();if(e.push(r),!this.activeKeys.has(r)){let e=new O(t,this.owDevice,t=>this.onDisconnect(t));this.activeKeys.set(r,e),this.onEChipDetectEvent.emit(e)}}),this.activeKeys.forEach((t,r)=>{e.includes(r)||(t.destroy(),this.activeKeys.delete(r))})}disconnected(t){this.usbDevice===t&&(this.onDisconnectEvent.emit(null),this.dispose())}async dispose(){await this.owDevice.close(),this.onDisconnectListener&&(this.onDisconnectListener.dispose(),this.onDisconnectListener=null),this.disposed=!0,a.a.info("EChip Reader disconnected.")}}r.d(e,"default",(function(){return j}));const N=1274,q=9360;class j extends n{constructor(){super(N,q),this.onConnectEvent=new c,this.onDisconnectEvent=new c}stop(){this.connectedDevices.forEach(t=>this.disconnected(t))}onConnect(t){return this.onConnectEvent.on(t)}onDisconnect(t){return this.onDisconnectEvent.on(t)}async connected(t){await super.connected(t);const e=new L(t,t=>this.onDisconnect(t));await e.claimed,this.onConnectEvent.emit(e)}async disconnected(t){await super.disconnected(t),this.onDisconnectEvent.emit(t)}}}])})); | ||
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)}}}])})); |
{ | ||
"name": "@keiser/echip-webusb", | ||
"version": "1.0.11", | ||
"version": "1.1.0", | ||
"description": "Keiser Air eChip WebUSB Library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -12,3 +12,3 @@ import EChip from './echip'; | ||
private activeKeys; | ||
constructor(usbDevice: USBDevice, onDisconnect: (listener: Listener<USBDevice>) => Disposable); | ||
constructor(usbDevice: WebUSBDevice, onDisconnect: (listener: Listener<WebUSBDevice>) => Disposable); | ||
readonly diposed: boolean; | ||
@@ -18,4 +18,4 @@ onDisconnect(listener: Listener<null>): Disposable; | ||
private echipsDetected; | ||
protected disconnected(device: USBDevice): void; | ||
protected disconnected(device: WebUSBDevice): void; | ||
protected dispose(): Promise<void>; | ||
} |
@@ -1,5 +0,5 @@ | ||
import WebUSBDevice from './webUsbDevice'; | ||
import USBDevice from './usbDevice'; | ||
import EChipReader from './echipReader'; | ||
import { Listener } from './typedEvent'; | ||
export default class EChipReaderWatcher extends WebUSBDevice { | ||
export default class EChipReaderWatcher extends USBDevice { | ||
private onConnectEvent; | ||
@@ -11,4 +11,4 @@ private onDisconnectEvent; | ||
private onDisconnect; | ||
protected connected(device: USBDevice): Promise<void>; | ||
protected disconnected(device: USBDevice): Promise<void>; | ||
protected connected(device: WebUSBDevice): Promise<void>; | ||
protected disconnected(device: WebUSBDevice): Promise<void>; | ||
} |
@@ -9,3 +9,3 @@ export default class OWDevice { | ||
private onDetectKeys; | ||
constructor(usbDevice: USBDevice, onDetectKeys?: (keyId: Array<Uint8Array>) => void); | ||
constructor(usbDevice: WebUSBDevice, onDetectKeys?: (keyId: Array<Uint8Array>) => void); | ||
claim(): Promise<boolean>; | ||
@@ -12,0 +12,0 @@ startSearch(): Promise<void>; |
@@ -13,1 +13,5 @@ export interface Listener<T> { | ||
} | ||
export declare class WebUSBConnectionEvent extends Event { | ||
readonly device: WebUSBDevice; | ||
constructor(type: string, eventInitDict: USBConnectionEventInit); | ||
} |
@@ -42,3 +42,3 @@ // Type definitions for W3C Web USB API 1.0 | ||
interface USBConnectionEventInit extends EventInit { | ||
device: USBDevice | ||
device: WebUSBDevice | ||
} | ||
@@ -102,3 +102,3 @@ | ||
constructor(type: string, eventInitDict: USBConnectionEventInit) | ||
readonly device: USBDevice | ||
readonly device: WebUSBDevice | ||
} | ||
@@ -111,7 +111,7 @@ | ||
declare class USB extends EventTarget { | ||
declare class WebUSB extends EventTarget { | ||
onconnect(): (this: this, ev: Event) => any | ||
ondisconnect(): (this: this, ev: Event) => any | ||
getDevices(): Promise<USBDevice[]> | ||
requestDevice(options?: USBDeviceRequestOptions): Promise<USBDevice> | ||
getDevices(): Promise<WebUSBDevice[]> | ||
requestDevice(options?: USBDeviceRequestOptions): Promise<WebUSBDevice> | ||
@@ -121,3 +121,3 @@ addEventListener(type: "connect" | "disconnect", listener: EventListener, useCapture?: boolean): void | ||
declare class USBDevice { | ||
declare class WebUSBDevice { | ||
readonly usbVersionMajor: number | ||
@@ -157,3 +157,3 @@ readonly usbVersionMinor: number | ||
interface Navigator { | ||
readonly usb: USB | ||
readonly usb: WebUSB | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88998
17
944
1