node-poweredup 8.0.4 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.drone.yml +2 -2
- package/.gitmodules +0 -3
- package/.jsdoc.json +1 -2
- package/dist/browser/poweredup.js +1 -1
- package/dist/browser/poweredup.js.map +1 -1
- package/dist/node/color.js +5 -1
- package/dist/node/color.js.map +1 -1
- package/dist/node/consts.d.ts +21 -21
- package/dist/node/consts.js +27 -27
- package/dist/node/consts.js.map +1 -1
- package/dist/node/devices/absolutemotor.js +6 -2
- package/dist/node/devices/absolutemotor.js.map +1 -1
- package/dist/node/devices/basicmotor.js +5 -1
- package/dist/node/devices/basicmotor.js.map +1 -1
- package/dist/node/devices/colordistancesensor.js +7 -3
- package/dist/node/devices/colordistancesensor.js.map +1 -1
- package/dist/node/devices/currentsensor.js +6 -2
- package/dist/node/devices/currentsensor.js.map +1 -1
- package/dist/node/devices/device.d.ts +3 -1
- package/dist/node/devices/device.js +5 -1
- package/dist/node/devices/device.js.map +1 -1
- package/dist/node/devices/duplotrainbasecolorsensor.js +6 -2
- package/dist/node/devices/duplotrainbasecolorsensor.js.map +1 -1
- package/dist/node/devices/duplotrainbasemotor.js +5 -1
- package/dist/node/devices/duplotrainbasemotor.js.map +1 -1
- package/dist/node/devices/duplotrainbasespeaker.js +6 -2
- package/dist/node/devices/duplotrainbasespeaker.js.map +1 -1
- package/dist/node/devices/duplotrainbasespeedometer.js +6 -2
- package/dist/node/devices/duplotrainbasespeedometer.js.map +1 -1
- package/dist/node/devices/hubled.js +6 -2
- package/dist/node/devices/hubled.js.map +1 -1
- package/dist/node/devices/light.js +5 -1
- package/dist/node/devices/light.js.map +1 -1
- package/dist/node/devices/marioaccelerometer.js +6 -2
- package/dist/node/devices/marioaccelerometer.js.map +1 -1
- package/dist/node/devices/mariobarcodesensor.js +6 -2
- package/dist/node/devices/mariobarcodesensor.js.map +1 -1
- package/dist/node/devices/mariopantssensor.js +6 -2
- package/dist/node/devices/mariopantssensor.js.map +1 -1
- package/dist/node/devices/mediumlinearmotor.js +5 -1
- package/dist/node/devices/mediumlinearmotor.js.map +1 -1
- package/dist/node/devices/motionsensor.js +6 -2
- package/dist/node/devices/motionsensor.js.map +1 -1
- package/dist/node/devices/movehubmediumlinearmotor.js +5 -1
- package/dist/node/devices/movehubmediumlinearmotor.js.map +1 -1
- package/dist/node/devices/movehubtiltsensor.js +6 -2
- package/dist/node/devices/movehubtiltsensor.js.map +1 -1
- package/dist/node/devices/piezobuzzer.js +5 -1
- package/dist/node/devices/piezobuzzer.js.map +1 -1
- package/dist/node/devices/remotecontrolbutton.js +7 -3
- package/dist/node/devices/remotecontrolbutton.js.map +1 -1
- package/dist/node/devices/simplemediumlinearmotor.js +5 -1
- package/dist/node/devices/simplemediumlinearmotor.js.map +1 -1
- package/dist/node/devices/tachomotor.js +6 -2
- package/dist/node/devices/tachomotor.js.map +1 -1
- package/dist/node/devices/technic3x3colorlightmatrix.js +6 -2
- package/dist/node/devices/technic3x3colorlightmatrix.js.map +1 -1
- package/dist/node/devices/techniccolorsensor.js +6 -2
- package/dist/node/devices/techniccolorsensor.js.map +1 -1
- package/dist/node/devices/technicdistancesensor.js +6 -2
- package/dist/node/devices/technicdistancesensor.js.map +1 -1
- package/dist/node/devices/technicforcesensor.js +6 -2
- package/dist/node/devices/technicforcesensor.js.map +1 -1
- package/dist/node/devices/techniclargeangularmotor.js +5 -1
- package/dist/node/devices/techniclargeangularmotor.js.map +1 -1
- package/dist/node/devices/techniclargelinearmotor.js +5 -1
- package/dist/node/devices/techniclargelinearmotor.js.map +1 -1
- package/dist/node/devices/technicmediumangularmotor.js +5 -1
- package/dist/node/devices/technicmediumangularmotor.js.map +1 -1
- package/dist/node/devices/technicmediumhubaccelerometersensor.js +6 -2
- package/dist/node/devices/technicmediumhubaccelerometersensor.js.map +1 -1
- package/dist/node/devices/technicmediumhubgyrosensor.js +6 -2
- package/dist/node/devices/technicmediumhubgyrosensor.js.map +1 -1
- package/dist/node/devices/technicmediumhubtiltsensor.js +7 -3
- package/dist/node/devices/technicmediumhubtiltsensor.js.map +1 -1
- package/dist/node/devices/technicsmallangularmotor.js +5 -1
- package/dist/node/devices/technicsmallangularmotor.js.map +1 -1
- package/dist/node/devices/technicxlargelinearmotor.js +5 -1
- package/dist/node/devices/technicxlargelinearmotor.js.map +1 -1
- package/dist/node/devices/tiltsensor.js +6 -2
- package/dist/node/devices/tiltsensor.js.map +1 -1
- package/dist/node/devices/trainmotor.js +5 -1
- package/dist/node/devices/trainmotor.js.map +1 -1
- package/dist/node/devices/voltagesensor.js +6 -2
- package/dist/node/devices/voltagesensor.js.map +1 -1
- package/dist/node/hubs/basehub.d.ts +1 -0
- package/dist/node/hubs/basehub.js +5 -1
- package/dist/node/hubs/basehub.js.map +1 -1
- package/dist/node/hubs/duplotrainbase.d.ts +1 -0
- package/dist/node/hubs/duplotrainbase.js +5 -1
- package/dist/node/hubs/duplotrainbase.js.map +1 -1
- package/dist/node/hubs/hub.d.ts +1 -0
- package/dist/node/hubs/hub.js +12 -11
- package/dist/node/hubs/hub.js.map +1 -1
- package/dist/node/hubs/lpf2hub.js +5 -1
- package/dist/node/hubs/lpf2hub.js.map +1 -1
- package/dist/node/hubs/mario.d.ts +1 -0
- package/dist/node/hubs/mario.js +5 -1
- package/dist/node/hubs/mario.js.map +1 -1
- package/dist/node/hubs/movehub.d.ts +1 -0
- package/dist/node/hubs/movehub.js +7 -6
- package/dist/node/hubs/movehub.js.map +1 -1
- package/dist/node/hubs/remotecontrol.d.ts +1 -0
- package/dist/node/hubs/remotecontrol.js +5 -1
- package/dist/node/hubs/remotecontrol.js.map +1 -1
- package/dist/node/hubs/technicmediumhub.d.ts +1 -0
- package/dist/node/hubs/technicmediumhub.js +5 -1
- package/dist/node/hubs/technicmediumhub.js.map +1 -1
- package/dist/node/hubs/technicsmallhub.d.ts +1 -0
- package/dist/node/hubs/technicsmallhub.js +10 -6
- package/dist/node/hubs/technicsmallhub.js.map +1 -1
- package/dist/node/hubs/wedo2smarthub.d.ts +1 -0
- package/dist/node/hubs/wedo2smarthub.js +10 -6
- package/dist/node/hubs/wedo2smarthub.js.map +1 -1
- package/dist/node/index-browser.js +5 -1
- package/dist/node/index-browser.js.map +1 -1
- package/dist/node/index-node.js +5 -1
- package/dist/node/index-node.js.map +1 -1
- package/dist/node/interfaces.d.ts +1 -0
- package/dist/node/nobleabstraction.d.ts +1 -0
- package/dist/node/nobleabstraction.js.map +1 -1
- package/dist/node/poweredup-browser.js +10 -3
- package/dist/node/poweredup-browser.js.map +1 -1
- package/dist/node/poweredup-node.js +5 -3
- package/dist/node/poweredup-node.js.map +1 -1
- package/dist/node/utils.d.ts +2 -1
- package/dist/node/utils.js.map +1 -1
- package/dist/node/webbleabstraction.d.ts +2 -1
- package/dist/node/webbleabstraction.js +1 -1
- package/dist/node/webbleabstraction.js.map +1 -1
- package/docs/AbsoluteMotor.html +1037 -1066
- package/docs/BaseHub.html +622 -807
- package/docs/BasicMotor.html +707 -809
- package/docs/ColorDistanceSensor.html +1500 -1611
- package/docs/CurrentSensor.html +470 -623
- package/docs/Device.html +372 -502
- package/docs/DuploTrainBase.html +1004 -1225
- package/docs/DuploTrainBaseColorSensor.html +712 -874
- package/docs/DuploTrainBaseMotor.html +723 -841
- package/docs/DuploTrainBaseSpeaker.html +565 -693
- package/docs/DuploTraniBaseSpeedometer.html +396 -550
- package/docs/Hub.html +3842 -3987
- package/docs/HubLED.html +591 -731
- package/docs/LPF2Hub.html +983 -1188
- package/docs/Light.html +591 -731
- package/docs/Mario.html +1004 -1225
- package/docs/MarioAccelerometer.html +568 -732
- package/docs/MarioBarcodeSensor.html +568 -732
- package/docs/MarioPantsSensor.html +470 -623
- package/docs/MediumLinearMotor.html +679 -748
- package/docs/MotionSensor.html +470 -623
- package/docs/MoveHub.html +1004 -1225
- package/docs/MoveHubMediumLinearMotor.html +679 -748
- package/docs/MoveHubTiltSensor.html +483 -642
- package/docs/PiezoBuzzer.html +495 -642
- package/docs/PoweredUP.html +2223 -2174
- package/docs/RemoteControl.html +1004 -1225
- package/docs/RemoteControlButton.html +470 -623
- package/docs/SimpleMediumLinearMotor.html +396 -550
- package/docs/TachoMotor.html +1298 -1393
- package/docs/Technic3x3ColorLightMatrix.html +484 -628
- package/docs/TechnicColorSensor.html +726 -876
- package/docs/TechnicDistanceSensor.html +667 -824
- package/docs/TechnicForceSensor.html +614 -765
- package/docs/TechnicLargeAngularMotor.html +1046 -1091
- package/docs/TechnicLargeLinearMotor.html +1046 -1091
- package/docs/TechnicMediumAngularMotor.html +1046 -1091
- package/docs/TechnicMediumHub.html +1004 -1225
- package/docs/TechnicMediumHubAccelerometerSensor.html +496 -661
- package/docs/TechnicMediumHubGyroSensor.html +496 -661
- package/docs/TechnicMediumHubTiltSensor.html +820 -945
- package/docs/TechnicSmallAngularMotor.html +1046 -1091
- package/docs/TechnicXLargeLinearMotor.html +1046 -1091
- package/docs/TiltSensor.html +483 -642
- package/docs/TrainMotor.html +723 -841
- package/docs/VoltageSensor.html +470 -623
- package/docs/WeDo2SmartHub.html +890 -1102
- package/docs/consts.js.html +53 -116
- package/docs/devices_absolutemotor.js.html +35 -94
- package/docs/devices_basicmotor.js.html +34 -93
- package/docs/devices_colordistancesensor.js.html +33 -92
- package/docs/devices_currentsensor.js.html +35 -94
- package/docs/devices_device.js.html +32 -91
- package/docs/devices_duplotrainbasecolorsensor.js.html +35 -94
- package/docs/devices_duplotrainbasemotor.js.html +34 -93
- package/docs/devices_duplotrainbasespeaker.js.html +35 -94
- package/docs/devices_duplotrainbasespeedometer.js.html +35 -94
- package/docs/devices_hubled.js.html +35 -94
- package/docs/devices_light.js.html +34 -93
- package/docs/devices_marioaccelerometer.js.html +35 -94
- package/docs/devices_mariobarcodesensor.js.html +35 -94
- package/docs/devices_mariopantssensor.js.html +35 -94
- package/docs/devices_mediumlinearmotor.js.html +34 -93
- package/docs/devices_motionsensor.js.html +35 -94
- package/docs/devices_movehubmediumlinearmotor.js.html +34 -93
- package/docs/devices_movehubtiltsensor.js.html +35 -94
- package/docs/devices_piezobuzzer.js.html +34 -93
- package/docs/devices_remotecontrolbutton.js.html +36 -95
- package/docs/devices_simplemediumlinearmotor.js.html +34 -93
- package/docs/devices_tachomotor.js.html +33 -92
- package/docs/devices_technic3x3colorlightmatrix.js.html +35 -94
- package/docs/devices_techniccolorsensor.js.html +35 -94
- package/docs/devices_technicdistancesensor.js.html +35 -94
- package/docs/devices_technicforcesensor.js.html +35 -94
- package/docs/devices_techniclargeangularmotor.js.html +34 -93
- package/docs/devices_techniclargelinearmotor.js.html +34 -93
- package/docs/devices_technicmediumangularmotor.js.html +34 -93
- package/docs/devices_technicmediumhubaccelerometersensor.js.html +35 -94
- package/docs/devices_technicmediumhubgyrosensor.js.html +35 -94
- package/docs/devices_technicmediumhubtiltsensor.js.html +36 -95
- package/docs/devices_technicsmallangularmotor.js.html +34 -93
- package/docs/devices_technicxlargelinearmotor.js.html +34 -93
- package/docs/devices_tiltsensor.js.html +35 -94
- package/docs/devices_trainmotor.js.html +34 -93
- package/docs/devices_voltagesensor.js.html +35 -94
- package/docs/global.html +2094 -7927
- package/docs/hubs_basehub.js.html +31 -90
- package/docs/hubs_duplotrainbase.js.html +34 -93
- package/docs/hubs_hub.js.html +41 -103
- package/docs/hubs_lpf2hub.js.html +31 -90
- package/docs/hubs_mario.js.html +34 -93
- package/docs/hubs_movehub.js.html +36 -98
- package/docs/hubs_remotecontrol.js.html +34 -93
- package/docs/hubs_technicmediumhub.js.html +34 -93
- package/docs/hubs_technicsmallhub.js.html +39 -98
- package/docs/hubs_wedo2smarthub.js.html +36 -95
- package/docs/index.html +36 -83
- package/docs/poweredup-browser.js.html +36 -92
- package/docs/poweredup-node.js.html +32 -93
- package/docs/scripts/linenumber.js +21 -19
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/styles/jsdoc-default.css +192 -787
- package/docs/styles/prettify-jsdoc.css +1 -1
- package/docs/styles/prettify-tomorrow.css +8 -14
- package/package.json +13 -13
- package/src/devices/device.ts +2 -2
- package/src/devices/remotecontrolbutton.ts +1 -1
- package/src/devices/technicmediumhubtiltsensor.ts +1 -1
- package/src/hubs/hub.ts +2 -2
- package/src/hubs/movehub.ts +2 -2
- package/src/poweredup-browser.ts +5 -2
- package/src/poweredup-node.ts +0 -2
- package/src/webbleabstraction.ts +2 -2
- package/jsdoc-template/braintree/CHANGELOG.md +0 -31
- package/jsdoc-template/braintree/LICENSE +0 -27
- package/jsdoc-template/braintree/README.md +0 -90
- package/jsdoc-template/braintree/package.json +0 -39
- package/jsdoc-template/braintree/publish.js +0 -675
- package/jsdoc-template/braintree/static/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/jsdoc-template/braintree/static/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/jsdoc-template/braintree/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/jsdoc-template/braintree/static/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-Light-webfont.eot +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/jsdoc-template/braintree/static/fonts/OpenSans-Light-webfont.woff +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/jsdoc-template/braintree/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/jsdoc-template/braintree/static/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-Semibold-webfont.eot +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-Semibold-webfont.svg +0 -1830
- package/jsdoc-template/braintree/static/fonts/OpenSans-Semibold-webfont.ttf +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-Semibold-webfont.woff +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-SemiboldItalic-webfont.svg +0 -1830
- package/jsdoc-template/braintree/static/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
- package/jsdoc-template/braintree/static/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
- package/jsdoc-template/braintree/static/icons/home.svg +0 -4
- package/jsdoc-template/braintree/static/icons/search.svg +0 -4
- package/jsdoc-template/braintree/static/scripts/linenumber.js +0 -23
- package/jsdoc-template/braintree/static/scripts/pagelocation.js +0 -89
- package/jsdoc-template/braintree/static/styles/collapse.css +0 -27
- package/jsdoc-template/braintree/static/styles/jsdoc-default.css +0 -953
- package/jsdoc-template/braintree/static/styles/prettify-jsdoc.css +0 -111
- package/jsdoc-template/braintree/static/styles/prettify-tomorrow.css +0 -138
- package/jsdoc-template/braintree/tmpl/augments.tmpl +0 -10
- package/jsdoc-template/braintree/tmpl/container.tmpl +0 -213
- package/jsdoc-template/braintree/tmpl/details.tmpl +0 -223
- package/jsdoc-template/braintree/tmpl/example.tmpl +0 -2
- package/jsdoc-template/braintree/tmpl/examples.tmpl +0 -14
- package/jsdoc-template/braintree/tmpl/exceptions.tmpl +0 -28
- package/jsdoc-template/braintree/tmpl/layout.tmpl +0 -150
- package/jsdoc-template/braintree/tmpl/mainpage.tmpl +0 -9
- package/jsdoc-template/braintree/tmpl/members.tmpl +0 -38
- package/jsdoc-template/braintree/tmpl/method.tmpl +0 -128
- package/jsdoc-template/braintree/tmpl/params.tmpl +0 -125
- package/jsdoc-template/braintree/tmpl/properties.tmpl +0 -111
- package/jsdoc-template/braintree/tmpl/returns.tmpl +0 -17
- package/jsdoc-template/braintree/tmpl/source.tmpl +0 -9
- package/jsdoc-template/braintree/tmpl/tutorial.tmpl +0 -23
- package/jsdoc-template/braintree/tmpl/type.tmpl +0 -11
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see poweredup.js.LICENSE.txt */
|
|
2
|
-
(()=>{var e={9742:(e,t)=>{"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,o=c(e),s=o[0],a=o[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),f=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;return 2===a&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[f++]=255&t),1===a&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=16383,a=0,c=n-i;a<c;a+=s)o.push(u(e,a,a+s>c?c:a+s));return 1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=o.length;s<a;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function c(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 u(e,t,n){for(var i,o,s=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},8764:(e,t,r)=>{"use strict";const n=r(9742),i=r(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|p(e,t);let n=a(r);const i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(X(e,Uint8Array)){const t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return _(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return h(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(X(e,SharedArrayBuffer)||e&&X(e.buffer,SharedArrayBuffer)))return h(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,r);const i=function(e){if(c.isBuffer(e)){const t=0|d(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||q(e.length)?a(0):_(e):"Buffer"===e.type&&Array.isArray(e.data)?_(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function l(e){return f(e),a(e<0?0:0|d(e))}function _(e){const t=e.length<0?0:0|d(e.length),r=a(t);for(let n=0;n<t;n+=1)r[n]=255&e[n];return r}function h(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,c.prototype),n}function d(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(e).length;default:if(i)return n?-1:$(e).length;t=(""+t).toLowerCase(),i=!0}}function E(e,t,r){let 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 C(this,t,r);case"utf8":case"utf-8":return I(this,t,r);case"ascii":return L(this,t,r);case"latin1":case"binary":return D(this,t,r);case"base64":return S(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function O(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function T(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),q(r=+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:b(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){let o,s=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;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){let n=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===c)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let n=0;n<c;n++)if(u(e,o+n)!==u(t,n)){r=!1;break}if(r)return o}return-1}function M(e,t,r,n){r=Number(r)||0;const i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=t.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(t.substr(2*s,2),16);if(q(n))return s;e[r+s]=n}return s}function v(e,t,r,n){return z($(t,e.length-r),e,r,n)}function y(e,t,r,n){return z(function(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function R(e,t,r,n){return z(K(t),e,r,n)}function m(e,t,r,n){return z(function(e,t){let r,n,i;const o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function S(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function I(e,t,r){r=Math.min(e.length,r);const n=[];let i=t;for(;i<r;){const t=e[i];let o=null,s=t>239?4:t>223?3:t>191?2:1;if(i+s<=r){let r,n,a,c;switch(s){case 1:t<128&&(o=t);break;case 2:r=e[i+1],128==(192&r)&&(c=(31&t)<<6|63&r,c>127&&(o=c));break;case 3:r=e[i+1],n=e[i+2],128==(192&r)&&128==(192&n)&&(c=(15&t)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=e[i+1],n=e[i+2],a=e[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(e){const t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=A));return r}(n)}t.kMaxLength=s,c.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(e,t,r){return u(e,t,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(e,t,r){return function(e,t,r){return f(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},c.allocUnsafe=function(e){return l(e)},c.allocUnsafeSlow=function(e){return l(e)},c.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==c.prototype},c.compare=function(e,t){if(X(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),X(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,n=t.length;for(let i=0,o=Math.min(r,n);i<o;++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(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const n=c.allocUnsafe(t);let i=0;for(r=0;r<e.length;++r){let t=e[r];if(X(t,Uint8Array))i+t.length>n.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(n,i)):Uint8Array.prototype.set.call(n,t,i);else{if(!c.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,i)}i+=t.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)O(this,t,t+1);return this},c.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)O(this,t,t+3),O(this,t+1,t+2);return this},c.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)O(this,t,t+7),O(this,t+1,t+6),O(this,t+2,t+5),O(this,t+3,t+4);return this},c.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?I(this,0,e):E.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,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(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(e,t,r,n,i){if(X(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);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;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0);const a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r);for(let e=0;e<a;++e)if(u[e]!==f[e]){o=u[e],s=f[e];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return T(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return T(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)}const 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");let o=!1;for(;;)switch(n){case"hex":return M(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":case"latin1":case"binary":return y(this,e,t,r);case"base64":return R(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function L(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function D(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function C(e,t,r){const n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=t;n<r;++n)i+=Z[e[n]];return i}function N(e,t,r){const n=e.slice(t,r);let i="";for(let e=0;e<n.length-1;e+=2)i+=String.fromCharCode(n[e]+256*n[e+1]);return i}function g(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 P(e,t,r,n,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function B(e,t,r,n,i){x(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function U(e,t,r,n,i){x(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o>>=8,e[r+6]=o,o>>=8,e[r+5]=o,o>>=8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function w(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(e,t,r,n,o){return t=+t,r>>>=0,o||w(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function j(e,t,r,n,o){return t=+t,r>>>=0,o||w(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);const n=this.subarray(e,t);return Object.setPrototypeOf(n,c.prototype),n},c.prototype.readUintLE=c.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||g(e,t,this.length);let n=this[e],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[e+o]*i;return n},c.prototype.readUintBE=c.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||g(e,t,this.length);let n=this[e+--t],i=1;for(;t>0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||g(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||g(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||g(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||g(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||g(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=Q((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||k(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),c.prototype.readBigUInt64BE=Q((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||k(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),c.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||g(e,t,this.length);let n=this[e],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[e+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||g(e,t,this.length);let n=t,i=1,o=this[e+--n];for(;n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return e>>>=0,t||g(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||g(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||g(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||g(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 e>>>=0,t||g(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=Q((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||k(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),c.prototype.readBigInt64BE=Q((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||k(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),c.prototype.readFloatLE=function(e,t){return e>>>=0,t||g(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||g(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||g(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||g(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||P(this,e,t,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||P(this,e,t,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=Q((function(e,t=0){return B(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=Q((function(e,t=0){return U(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n)}let i=0,o=1,s=0;for(this[t]=255&e;++i<r&&(o*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/o>>0)-s&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/o>>0)-s&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,127,-128),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||P(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=Q((function(e,t=0){return B(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=Q((function(e,t=0){return U(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(e,t,r){return H(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return H(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return j(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return j(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");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("Index out of range");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);const i=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i},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),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);if(1===e.length){const t=e.charCodeAt(0);("utf8"===n&&t<128||"latin1"===n)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{const o=c.isBuffer(e)?e:c.from(e,n),s=o.length;if(0===s)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=o[i%s]}return this};const F={};function W(e,t,r){F[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function G(e){let t="",r=e.length;const n="-"===e[0]?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function x(e,t,r,n,i,o){if(e>r||e<t){const n="bigint"==typeof t?"n":"";let i;throw i=o>3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${t}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,r){V(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||k(t,e.length-(r+1))}(n,i,o)}function V(e,t){if("number"!=typeof e)throw new F.ERR_INVALID_ARG_TYPE(t,"number",e)}function k(e,t,r){if(Math.floor(e)!==e)throw V(e,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}W("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),W("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),W("ERR_OUT_OF_RANGE",(function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=G(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=G(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n}),RangeError);const Y=/[^+/0-9A-Za-z-_]/g;function $(e,t){let r;t=t||1/0;const n=e.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.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;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function K(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(Y,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function z(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function q(e){return e!=e}const Z=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function Q(e){return"undefined"==typeof BigInt?J:e}function J(){throw new Error("BigInt not supported")}},1227:(e,t,r)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(2447)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},2447:(e,t,r)=>{e.exports=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if("%%"===r)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];r=o.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(7824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},7187:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}p(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&p(e,"error",t,{once:!0})}(e,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=f.bind(n);return i.listener=r,n.wrapFn=i,i}function _(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):d(i,i.length)}function h(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function p(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(o){n.once&&e.removeEventListener(t,i),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,f=d(c,u);for(r=0;r<u;++r)n(f[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,l(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,l(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return _(this,e,!0)},o.prototype.rawListeners=function(e){return _(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},o.prototype.listenerCount=h,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},645:(e,t)=>{t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,c=(1<<a)-1,u=c>>1,f=-7,l=r?i-1:0,_=r?-1:1,h=e[t+l];for(l+=_,o=h&(1<<-f)-1,h>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=_,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=_,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),o-=u}return(h?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<<u)-1,l=f>>1,_=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,d=n?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+l>=1?_/c:_*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*c-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+h]=255&a,h+=d,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[r+h]=255&s,h+=d,s/=256,u-=8);e[r+h-d]|=128*p}},7824:e=>{var t=1e3,r=60*t,n=60*r,i=24*n;function o(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,s){s=s||{};var a,c,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var s=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return 6048e5*s;case"days":case"day":case"d":return s*i;case"hours":case"hour":case"hrs":case"hr":case"h":return s*n;case"minutes":case"minute":case"mins":case"min":case"m":return s*r;case"seconds":case"second":case"secs":case"sec":case"s":return s*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}(e);if("number"===u&&isFinite(e))return s.long?(a=e,(c=Math.abs(a))>=i?o(a,c,i,"day"):c>=n?o(a,c,n,"hour"):c>=r?o(a,c,r,"minute"):c>=t?o(a,c,t,"second"):a+" ms"):function(e){var o=Math.abs(e);return o>=i?Math.round(e/i)+"d":o>=n?Math.round(e/n)+"h":o>=r?Math.round(e/r)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},148:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Color=void 0;const s=o(r(4312));t.Color=class{constructor(e,t){this._brightness=100,this._color=e,this._brightness=t||100}toValue(){return this._color===s.Color.NONE?this._color:this._color+(Math.round(this._brightness/10)<<4)}}},4312:(e,t)=>{"use strict";var r,n,i,o,s,a,c,u,f,l,_,h,d,p,E,O,T,b,M,v,y,R,m,S,I,A,L;Object.defineProperty(t,"__esModule",{value:!0}),t.MarioColor=t.MarioPantsType=t.PortInputFormatSetupSubCommand=t.ModeInformationType=t.HWNetworkSubFamily=t.HWNetworkFamily=t.HWNetWorkCommandType=t.ErrorCode=t.IOTypeID=t.Event=t.AlertPayload=t.AlertOperation=t.AlertType=t.ActionType=t.HubPropertyPayload=t.HubPropertyOperation=t.HubPropertyReference=t.MessageType=t.BLECharacteristic=t.BLEService=t.BLEManufacturerData=t.DuploTrainBaseSound=t.BrakingStyle=t.ButtonState=t.ColorNames=t.Color=t.DeviceTypeNames=t.DeviceType=t.HubTypeNames=t.HubType=void 0,function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEDO2_SMART_HUB=1]="WEDO2_SMART_HUB",e[e.MOVE_HUB=2]="MOVE_HUB",e[e.HUB=3]="HUB",e[e.REMOTE_CONTROL=4]="REMOTE_CONTROL",e[e.DUPLO_TRAIN_BASE=5]="DUPLO_TRAIN_BASE",e[e.TECHNIC_MEDIUM_HUB=6]="TECHNIC_MEDIUM_HUB",e[e.MARIO=7]="MARIO",e[e.TECHNIC_SMALL_HUB=8]="TECHNIC_SMALL_HUB"}(r=t.HubType||(t.HubType={})),t.HubTypeNames=r,function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.SIMPLE_MEDIUM_LINEAR_MOTOR=1]="SIMPLE_MEDIUM_LINEAR_MOTOR",e[e.TRAIN_MOTOR=2]="TRAIN_MOTOR",e[e.LIGHT=8]="LIGHT",e[e.VOLTAGE_SENSOR=20]="VOLTAGE_SENSOR",e[e.CURRENT_SENSOR=21]="CURRENT_SENSOR",e[e.PIEZO_BUZZER=22]="PIEZO_BUZZER",e[e.HUB_LED=23]="HUB_LED",e[e.TILT_SENSOR=34]="TILT_SENSOR",e[e.MOTION_SENSOR=35]="MOTION_SENSOR",e[e.COLOR_DISTANCE_SENSOR=37]="COLOR_DISTANCE_SENSOR",e[e.MEDIUM_LINEAR_MOTOR=38]="MEDIUM_LINEAR_MOTOR",e[e.MOVE_HUB_MEDIUM_LINEAR_MOTOR=39]="MOVE_HUB_MEDIUM_LINEAR_MOTOR",e[e.MOVE_HUB_TILT_SENSOR=40]="MOVE_HUB_TILT_SENSOR",e[e.DUPLO_TRAIN_BASE_MOTOR=41]="DUPLO_TRAIN_BASE_MOTOR",e[e.DUPLO_TRAIN_BASE_SPEAKER=42]="DUPLO_TRAIN_BASE_SPEAKER",e[e.DUPLO_TRAIN_BASE_COLOR_SENSOR=43]="DUPLO_TRAIN_BASE_COLOR_SENSOR",e[e.DUPLO_TRAIN_BASE_SPEEDOMETER=44]="DUPLO_TRAIN_BASE_SPEEDOMETER",e[e.TECHNIC_LARGE_LINEAR_MOTOR=46]="TECHNIC_LARGE_LINEAR_MOTOR",e[e.TECHNIC_XLARGE_LINEAR_MOTOR=47]="TECHNIC_XLARGE_LINEAR_MOTOR",e[e.TECHNIC_MEDIUM_ANGULAR_MOTOR=48]="TECHNIC_MEDIUM_ANGULAR_MOTOR",e[e.TECHNIC_LARGE_ANGULAR_MOTOR=49]="TECHNIC_LARGE_ANGULAR_MOTOR",e[e.TECHNIC_MEDIUM_HUB_GEST_SENSOR=54]="TECHNIC_MEDIUM_HUB_GEST_SENSOR",e[e.REMOTE_CONTROL_BUTTON=55]="REMOTE_CONTROL_BUTTON",e[e.REMOTE_CONTROL_RSSI=56]="REMOTE_CONTROL_RSSI",e[e.TECHNIC_MEDIUM_HUB_ACCELEROMETER=57]="TECHNIC_MEDIUM_HUB_ACCELEROMETER",e[e.TECHNIC_MEDIUM_HUB_GYRO_SENSOR=58]="TECHNIC_MEDIUM_HUB_GYRO_SENSOR",e[e.TECHNIC_MEDIUM_HUB_TILT_SENSOR=59]="TECHNIC_MEDIUM_HUB_TILT_SENSOR",e[e.TECHNIC_MEDIUM_HUB_TEMPERATURE_SENSOR=60]="TECHNIC_MEDIUM_HUB_TEMPERATURE_SENSOR",e[e.TECHNIC_COLOR_SENSOR=61]="TECHNIC_COLOR_SENSOR",e[e.TECHNIC_DISTANCE_SENSOR=62]="TECHNIC_DISTANCE_SENSOR",e[e.TECHNIC_FORCE_SENSOR=63]="TECHNIC_FORCE_SENSOR",e[e.TECHNIC_3X3_COLOR_LIGHT_MATRIX=64]="TECHNIC_3X3_COLOR_LIGHT_MATRIX",e[e.TECHNIC_SMALL_ANGULAR_MOTOR=65]="TECHNIC_SMALL_ANGULAR_MOTOR",e[e.MARIO_ACCELEROMETER=71]="MARIO_ACCELEROMETER",e[e.MARIO_BARCODE_SENSOR=73]="MARIO_BARCODE_SENSOR",e[e.MARIO_PANTS_SENSOR=74]="MARIO_PANTS_SENSOR",e[e.TECHNIC_MEDIUM_ANGULAR_MOTOR_GREY=75]="TECHNIC_MEDIUM_ANGULAR_MOTOR_GREY",e[e.TECHNIC_LARGE_ANGULAR_MOTOR_GREY=76]="TECHNIC_LARGE_ANGULAR_MOTOR_GREY"}(n=t.DeviceType||(t.DeviceType={})),t.DeviceTypeNames=n,function(e){e[e.BLACK=0]="BLACK",e[e.PINK=1]="PINK",e[e.PURPLE=2]="PURPLE",e[e.BLUE=3]="BLUE",e[e.LIGHT_BLUE=4]="LIGHT_BLUE",e[e.CYAN=5]="CYAN",e[e.GREEN=6]="GREEN",e[e.YELLOW=7]="YELLOW",e[e.ORANGE=8]="ORANGE",e[e.RED=9]="RED",e[e.WHITE=10]="WHITE",e[e.NONE=255]="NONE"}(i=t.Color||(t.Color={})),t.ColorNames=i,(L=t.ButtonState||(t.ButtonState={}))[L.PRESSED=2]="PRESSED",L[L.RELEASED=0]="RELEASED",L[L.UP=1]="UP",L[L.DOWN=255]="DOWN",L[L.STOP=127]="STOP",(A=t.BrakingStyle||(t.BrakingStyle={}))[A.FLOAT=0]="FLOAT",A[A.HOLD=126]="HOLD",A[A.BRAKE=127]="BRAKE",(I=t.DuploTrainBaseSound||(t.DuploTrainBaseSound={}))[I.BRAKE=3]="BRAKE",I[I.STATION_DEPARTURE=5]="STATION_DEPARTURE",I[I.WATER_REFILL=7]="WATER_REFILL",I[I.HORN=9]="HORN",I[I.STEAM=10]="STEAM",(S=t.BLEManufacturerData||(t.BLEManufacturerData={}))[S.DUPLO_TRAIN_BASE_ID=32]="DUPLO_TRAIN_BASE_ID",S[S.MOVE_HUB_ID=64]="MOVE_HUB_ID",S[S.HUB_ID=65]="HUB_ID",S[S.REMOTE_CONTROL_ID=66]="REMOTE_CONTROL_ID",S[S.MARIO_ID=67]="MARIO_ID",S[S.TECHNIC_MEDIUM_HUB_ID=128]="TECHNIC_MEDIUM_HUB_ID",S[S.TECHNIC_SMALL_HUB_ID=131]="TECHNIC_SMALL_HUB_ID",(m=t.BLEService||(t.BLEService={})).WEDO2_SMART_HUB="00001523-1212-efde-1523-785feabcd123",m.WEDO2_SMART_HUB_2="00004f0e-1212-efde-1523-785feabcd123",m.WEDO2_SMART_HUB_3="2a19",m.WEDO2_SMART_HUB_4="180f",m.WEDO2_SMART_HUB_5="180a",m.LPF2_HUB="00001623-1212-efde-1623-785feabcd123",(R=t.BLECharacteristic||(t.BLECharacteristic={})).WEDO2_BATTERY="2a19",R.WEDO2_FIRMWARE_REVISION="2a26",R.WEDO2_BUTTON="00001526-1212-efde-1523-785feabcd123",R.WEDO2_PORT_TYPE="00001527-1212-efde-1523-785feabcd123",R.WEDO2_LOW_VOLTAGE_ALERT="00001528-1212-efde-1523-785feabcd123",R.WEDO2_HIGH_CURRENT_ALERT="00001529-1212-efde-1523-785feabcd123",R.WEDO2_LOW_SIGNAL_ALERT="0000152a-1212-efde-1523-785feabcd123",R.WEDO2_DISCONNECT="0000152b-1212-efde-1523-785feabcd123",R.WEDO2_SENSOR_VALUE="00001560-1212-efde-1523-785feabcd123",R.WEDO2_VALUE_FORMAT="00001561-1212-efde-1523-785feabcd123",R.WEDO2_PORT_TYPE_WRITE="00001563-1212-efde-1523-785feabcd123",R.WEDO2_MOTOR_VALUE_WRITE="00001565-1212-efde-1523-785feabcd123",R.WEDO2_NAME_ID="00001524-1212-efde-1523-785feabcd123",R.LPF2_ALL="00001624-1212-efde-1623-785feabcd123",(y=t.MessageType||(t.MessageType={}))[y.HUB_PROPERTIES=1]="HUB_PROPERTIES",y[y.HUB_ACTIONS=2]="HUB_ACTIONS",y[y.HUB_ALERTS=3]="HUB_ALERTS",y[y.HUB_ATTACHED_IO=4]="HUB_ATTACHED_IO",y[y.GENERIC_ERROR_MESSAGES=5]="GENERIC_ERROR_MESSAGES",y[y.HW_NETWORK_COMMANDS=8]="HW_NETWORK_COMMANDS",y[y.FW_UPDATE_GO_INTO_BOOT_MODE=16]="FW_UPDATE_GO_INTO_BOOT_MODE",y[y.FW_UPDATE_LOCK_MEMORY=17]="FW_UPDATE_LOCK_MEMORY",y[y.FW_UPDATE_LOCK_STATUS_REQUEST=18]="FW_UPDATE_LOCK_STATUS_REQUEST",y[y.FW_LOCK_STATUS=19]="FW_LOCK_STATUS",y[y.PORT_INFORMATION_REQUEST=33]="PORT_INFORMATION_REQUEST",y[y.PORT_MODE_INFORMATION_REQUEST=34]="PORT_MODE_INFORMATION_REQUEST",y[y.PORT_INPUT_FORMAT_SETUP_SINGLE=65]="PORT_INPUT_FORMAT_SETUP_SINGLE",y[y.PORT_INPUT_FORMAT_SETUP_COMBINEDMODE=66]="PORT_INPUT_FORMAT_SETUP_COMBINEDMODE",y[y.PORT_INFORMATION=67]="PORT_INFORMATION",y[y.PORT_MODE_INFORMATION=68]="PORT_MODE_INFORMATION",y[y.PORT_VALUE_SINGLE=69]="PORT_VALUE_SINGLE",y[y.PORT_VALUE_COMBINEDMODE=70]="PORT_VALUE_COMBINEDMODE",y[y.PORT_INPUT_FORMAT_SINGLE=71]="PORT_INPUT_FORMAT_SINGLE",y[y.PORT_INPUT_FORMAT_COMBINEDMODE=72]="PORT_INPUT_FORMAT_COMBINEDMODE",y[y.VIRTUAL_PORT_SETUP=97]="VIRTUAL_PORT_SETUP",y[y.PORT_OUTPUT_COMMAND=129]="PORT_OUTPUT_COMMAND",y[y.PORT_OUTPUT_COMMAND_FEEDBACK=130]="PORT_OUTPUT_COMMAND_FEEDBACK",(v=t.HubPropertyReference||(t.HubPropertyReference={}))[v.ADVERTISING_NAME=1]="ADVERTISING_NAME",v[v.BUTTON=2]="BUTTON",v[v.FW_VERSION=3]="FW_VERSION",v[v.HW_VERSION=4]="HW_VERSION",v[v.RSSI=5]="RSSI",v[v.BATTERY_VOLTAGE=6]="BATTERY_VOLTAGE",v[v.BATTERY_TYPE=7]="BATTERY_TYPE",v[v.MANUFACTURER_NAME=8]="MANUFACTURER_NAME",v[v.RADIO_FIRMWARE_VERSION=9]="RADIO_FIRMWARE_VERSION",v[v.LEGO_WIRELESS_PROTOCOL_VERSION=10]="LEGO_WIRELESS_PROTOCOL_VERSION",v[v.SYSTEM_TYPE_ID=11]="SYSTEM_TYPE_ID",v[v.HW_NETWORK_ID=12]="HW_NETWORK_ID",v[v.PRIMARY_MAC_ADDRESS=13]="PRIMARY_MAC_ADDRESS",v[v.SECONDARY_MAC_ADDRESS=14]="SECONDARY_MAC_ADDRESS",v[v.HARDWARE_NETWORK_FAMILY=15]="HARDWARE_NETWORK_FAMILY",(M=t.HubPropertyOperation||(t.HubPropertyOperation={}))[M.SET_DOWNSTREAM=1]="SET_DOWNSTREAM",M[M.ENABLE_UPDATES_DOWNSTREAM=2]="ENABLE_UPDATES_DOWNSTREAM",M[M.DISABLE_UPDATES_DOWNSTREAM=3]="DISABLE_UPDATES_DOWNSTREAM",M[M.RESET_DOWNSTREAM=4]="RESET_DOWNSTREAM",M[M.REQUEST_UPDATE_DOWNSTREAM=5]="REQUEST_UPDATE_DOWNSTREAM",M[M.UPDATE_UPSTREAM=6]="UPDATE_UPSTREAM",(b=t.HubPropertyPayload||(t.HubPropertyPayload={}))[b.ADVERTISING_NAME=1]="ADVERTISING_NAME",b[b.BUTTON_STATE=2]="BUTTON_STATE",b[b.FW_VERSION=3]="FW_VERSION",b[b.HW_VERSION=4]="HW_VERSION",b[b.RSSI=5]="RSSI",b[b.BATTERY_VOLTAGE=6]="BATTERY_VOLTAGE",b[b.BATTERY_TYPE=7]="BATTERY_TYPE",b[b.MANUFACTURER_NAME=8]="MANUFACTURER_NAME",b[b.RADIO_FIRMWARE_VERSION=9]="RADIO_FIRMWARE_VERSION",b[b.LWP_PROTOCOL_VERSION=10]="LWP_PROTOCOL_VERSION",b[b.SYSTEM_TYPE_ID=11]="SYSTEM_TYPE_ID",b[b.HW_NETWORK_ID=12]="HW_NETWORK_ID",b[b.PRIMARY_MAC_ADDRESS=13]="PRIMARY_MAC_ADDRESS",b[b.SECONDARY_MAC_ADDRESS=14]="SECONDARY_MAC_ADDRESS",b[b.HW_NETWORK_FAMILY=15]="HW_NETWORK_FAMILY",(T=t.ActionType||(t.ActionType={}))[T.SWITCH_OFF_HUB=1]="SWITCH_OFF_HUB",T[T.DISCONNECT=2]="DISCONNECT",T[T.VCC_PORT_CONTROL_ON=3]="VCC_PORT_CONTROL_ON",T[T.VCC_PORT_CONTROL_OFF=4]="VCC_PORT_CONTROL_OFF",T[T.ACTIVATE_BUSY_INDICATION=5]="ACTIVATE_BUSY_INDICATION",T[T.RESET_BUSY_INDICATION=6]="RESET_BUSY_INDICATION",T[T.SHUTDOWN=47]="SHUTDOWN",T[T.HUB_WILL_SWITCH_OFF=48]="HUB_WILL_SWITCH_OFF",T[T.HUB_WILL_DISCONNECT=49]="HUB_WILL_DISCONNECT",T[T.HUB_WILL_GO_INTO_BOOT_MODE=50]="HUB_WILL_GO_INTO_BOOT_MODE",(O=t.AlertType||(t.AlertType={}))[O.LOW_VOLTAGE=1]="LOW_VOLTAGE",O[O.HIGH_CURRENT=2]="HIGH_CURRENT",O[O.LOW_SIGNAL_STRENGTH=3]="LOW_SIGNAL_STRENGTH",O[O.OVER_POWER_CONDITION=4]="OVER_POWER_CONDITION",(E=t.AlertOperation||(t.AlertOperation={}))[E.LOW_VOLTAGE=1]="LOW_VOLTAGE",E[E.HIGH_CURRENT=2]="HIGH_CURRENT",E[E.LOW_SIGNAL_STRENGTH=3]="LOW_SIGNAL_STRENGTH",E[E.OVER_POWER_CONDITION=4]="OVER_POWER_CONDITION",(p=t.AlertPayload||(t.AlertPayload={}))[p.STATUS_OK=0]="STATUS_OK",p[p.ALERT=255]="ALERT",(d=t.Event||(t.Event={}))[d.DETACHED_IO=0]="DETACHED_IO",d[d.ATTACHED_IO=1]="ATTACHED_IO",d[d.ATTACHED_VIRTUAL_IO=2]="ATTACHED_VIRTUAL_IO",(h=t.IOTypeID||(t.IOTypeID={}))[h.MOTOR=1]="MOTOR",h[h.SYSTEM_TRAIN_MOTOR=2]="SYSTEM_TRAIN_MOTOR",h[h.BUTTON=5]="BUTTON",h[h.LED_LIGHT=8]="LED_LIGHT",h[h.VOLTAGE=20]="VOLTAGE",h[h.CURRENT=21]="CURRENT",h[h.PIEZO_TONE_SOUND=22]="PIEZO_TONE_SOUND",h[h.RGB_LIGHT=23]="RGB_LIGHT",h[h.EXTERNAL_TILT_SENSOR=34]="EXTERNAL_TILT_SENSOR",h[h.MOTION_SENSOR=35]="MOTION_SENSOR",h[h.VISION_SENSOR=37]="VISION_SENSOR",h[h.EXTERNAL_MOTOR=38]="EXTERNAL_MOTOR",h[h.INTERNAL_MOTOR=39]="INTERNAL_MOTOR",h[h.INTERNAL_TILT=40]="INTERNAL_TILT",(_=t.ErrorCode||(t.ErrorCode={}))[_.ACK=1]="ACK",_[_.MACK=2]="MACK",_[_.BUFFER_OVERFLOW=3]="BUFFER_OVERFLOW",_[_.TIMEOUT=4]="TIMEOUT",_[_.COMMAND_NOT_RECOGNIZED=5]="COMMAND_NOT_RECOGNIZED",_[_.INVALID_USE=6]="INVALID_USE",_[_.OVERCURRENT=7]="OVERCURRENT",_[_.INTERNAL_ERROR=8]="INTERNAL_ERROR",(l=t.HWNetWorkCommandType||(t.HWNetWorkCommandType={}))[l.CONNECTION_REQUEST=2]="CONNECTION_REQUEST",l[l.FAMILY_REQUEST=3]="FAMILY_REQUEST",l[l.FAMILY_SET=4]="FAMILY_SET",l[l.JOIN_DENIED=5]="JOIN_DENIED",l[l.GET_FAMILY=6]="GET_FAMILY",l[l.FAMILY=7]="FAMILY",l[l.GET_SUBFAMILY=8]="GET_SUBFAMILY",l[l.SUBFAMILY=9]="SUBFAMILY",l[l.SUBFAMILY_SET=10]="SUBFAMILY_SET",l[l.GET_EXTENDED_FAMILY=11]="GET_EXTENDED_FAMILY",l[l.EXTENDED_FAMILY=12]="EXTENDED_FAMILY",l[l.EXTENDED_FAMILY_SET=13]="EXTENDED_FAMILY_SET",l[l.RESET_LONG_PRESS_TIMING=14]="RESET_LONG_PRESS_TIMING",(f=t.HWNetworkFamily||(t.HWNetworkFamily={}))[f.GREEN=1]="GREEN",f[f.YELLOW=2]="YELLOW",f[f.RED=3]="RED",f[f.BLUE=4]="BLUE",f[f.PURPLE=5]="PURPLE",f[f.LIGHT_BLUE=6]="LIGHT_BLUE",f[f.TEAL=7]="TEAL",f[f.PINK=8]="PINK",f[f.WHITE=0]="WHITE",(u=t.HWNetworkSubFamily||(t.HWNetworkSubFamily={}))[u.ONE_FLASH=1]="ONE_FLASH",u[u.TWO_FLASHES=2]="TWO_FLASHES",u[u.THREE_FLASHES=3]="THREE_FLASHES",u[u.FOUR_FLASHES=4]="FOUR_FLASHES",u[u.FIVE_FLASHES=5]="FIVE_FLASHES",u[u.SIX_FLASHES=6]="SIX_FLASHES",u[u.SEVEN_FLASHES=7]="SEVEN_FLASHES",(c=t.ModeInformationType||(t.ModeInformationType={}))[c.NAME=0]="NAME",c[c.RAW=1]="RAW",c[c.PCT=2]="PCT",c[c.SI=3]="SI",c[c.SYMBOL=4]="SYMBOL",c[c.MAPPING=5]="MAPPING",c[c.USED_INTERNALLY=6]="USED_INTERNALLY",c[c.MOTOR_BIAS=7]="MOTOR_BIAS",c[c.CAPABILITY_BITS=8]="CAPABILITY_BITS",c[c.VALUE_FORMAT=128]="VALUE_FORMAT",(a=t.PortInputFormatSetupSubCommand||(t.PortInputFormatSetupSubCommand={}))[a.SET_MODEANDDATASET_COMBINATIONS=1]="SET_MODEANDDATASET_COMBINATIONS",a[a.LOCK_LPF2_DEVICE_FOR_SETUP=2]="LOCK_LPF2_DEVICE_FOR_SETUP",a[a.UNLOCKANDSTARTWITHMULTIUPDATEENABLED=3]="UNLOCKANDSTARTWITHMULTIUPDATEENABLED",a[a.UNLOCKANDSTARTWITHMULTIUPDATEDISABLED=4]="UNLOCKANDSTARTWITHMULTIUPDATEDISABLED",a[a.NOT_USED=5]="NOT_USED",a[a.RESET_SENSOR=6]="RESET_SENSOR",(s=t.MarioPantsType||(t.MarioPantsType={}))[s.NONE=0]="NONE",s[s.PROPELLER=6]="PROPELLER",s[s.CAT=17]="CAT",s[s.FIRE=18]="FIRE",s[s.NORMAL=33]="NORMAL",s[s.BUILDER=34]="BUILDER",(o=t.MarioColor||(t.MarioColor={}))[o.WHITE=4864]="WHITE",o[o.RED=5376]="RED",o[o.BLUE=5888]="BLUE",o[o.YELLOW=6144]="YELLOW",o[o.BLACK=6656]="BLACK",o[o.GREEN=9472]="GREEN",o[o.BROWN=27136]="BROWN",o[o.CYAN=16897]="CYAN"},9045:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.AbsoluteMotor=void 0;const a=r(9847),c=s(r(4312)),u=r(8593);class f extends a.TachoMotor{constructor(e,r,n={},i=c.DeviceType.UNKNOWN){super(e,r,Object.assign({},n,t.ModeMap),i)}receive(e){switch(this._mode){case l.ABSOLUTE:const t=(0,u.normalizeAngle)(e.readInt16LE(this.isWeDo2SmartHub?2:4));this.notify("absolute",{angle:t});break;default:super.receive(e)}}gotoAngle(e,t=100){if(!this.isVirtualPort&&e instanceof Array)throw new Error("Only virtual ports can accept multiple positions");if(this.isWeDo2SmartHub)throw new Error("Absolute positioning is not available on the WeDo 2.0 Smart Hub");return this.cancelEventTimer(),new Promise((r=>{let i;null==t&&(t=100),e instanceof Array?(i=n.from([129,this.portId,17,14,0,0,0,0,0,0,0,0,(0,u.mapSpeed)(t),this._maxPower,this._brakeStyle,this.useProfile()]),i.writeInt32LE((0,u.normalizeAngle)(e[0]),4),i.writeInt32LE((0,u.normalizeAngle)(e[1]),8)):(i=n.from([129,this.portId,17,13,0,0,0,0,(0,u.mapSpeed)(t),this._maxPower,this._brakeStyle,this.useProfile()]),i.writeInt32LE((0,u.normalizeAngle)(e),4)),this.send(i),this._finishedCallbacks.push((()=>r()))}))}gotoRealZero(e=100){return new Promise((t=>{const r=this.mode;let n=!1;this.on("absolute",(async({angle:i})=>{if(!n)return n=!0,i<0?i=Math.abs(i):e=-e,await this.rotateByDegrees(i,e),r&&this.subscribe(r),t()})),this.requestUpdate()}))}resetZero(){return new Promise((e=>{const t=n.from([129,this.portId,17,81,2,0,0,0,0]);return this.send(t),e()}))}}var l;t.AbsoluteMotor=f,function(e){e[e.ROTATION=2]="ROTATION",e[e.ABSOLUTE=3]="ABSOLUTE"}(l=t.Mode||(t.Mode={})),t.ModeMap={rotate:l.ROTATION,absolute:l.ABSOLUTE}},2897:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.BasicMotor=void 0;const a=r(5468),c=s(r(4312)),u=r(8593);class f extends a.Device{constructor(e,t,r,n=c.DeviceType.UNKNOWN){super(e,t,r,n)}setPower(e,t=!0){return t&&this.cancelEventTimer(),this.writeDirect(0,n.from([(0,u.mapSpeed)(e)]))}rampPower(e,t,r){return this.cancelEventTimer(),new Promise((n=>{(0,u.calculateRamp)(this,e,t,r).on("changePower",(e=>{this.setPower(e,!1)})).on("finished",n)}))}stop(){return this.cancelEventTimer(),this.setPower(0)}brake(){return this.cancelEventTimer(),this.setPower(c.BrakingStyle.BRAKE)}}t.BasicMotor=f},9126:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Output=t.ModeMap=t.Mode=t.ColorDistanceSensor=void 0;const a=r(5468),c=s(r(4312)),u=r(8593);class f extends a.Device{constructor(e,r){super(e,r,t.ModeMap,c.DeviceType.COLOR_DISTANCE_SENSOR)}receive(e){switch(this._mode){case l.COLOR:if(e[this.isWeDo2SmartHub?2:4]<=10){const t=(0,u.parseColor)(e[this.isWeDo2SmartHub?2:4]);this.notify("color",{color:t})}break;case l.DISTANCE:if(this.isWeDo2SmartHub)break;if(e[4]<=10){let t=Math.floor(25.4*e[4])-20;t<0&&(t=0),this.notify("distance",{distance:t})}break;case l.DISTANCE_COUNT:if(this.isWeDo2SmartHub)break;if(8!==e.length)break;const t=e.readUInt32LE(4);this.notify("distanceCount",{count:t});break;case l.REFLECT:if(this.isWeDo2SmartHub)break;const r=e[4];this.notify("reflect",{reflect:r});break;case l.AMBIENT:if(this.isWeDo2SmartHub)break;const n=e[4];this.notify("ambient",{ambient:n});break;case l.RGB_I:if(this.isWeDo2SmartHub)break;if(10!==e.length)break;const i=e.readUInt16LE(4),o=e.readUInt16LE(6),s=e.readUInt16LE(8);this.notify("rgbIntensity",{red:i,green:o,blue:s});break;case l.COLOR_AND_DISTANCE:if(this.isWeDo2SmartHub)break;let a=e[5];const c=e[7];if(c>0&&(a+=1/c),a=Math.floor(25.4*a)-20,e[4]<=10){const t=e[4];this.notify("colorAndDistance",{color:t,distance:a})}}}setPFExtendedChannel(e){let t=0;e>=4&&(e-=4,t=1);const r=n.alloc(2);return r[0]=(e-1<<4)+(t<<3),r[1]=96,this.sendPFIRMessage(r)}setPFPower(e,t,r){let i=0;e>4&&(e-=4,i=1);const o=n.alloc(2);return o[0]=(e-1<<4)+(i<<3)+("RED"===t?4:5),o[1]=this._pfPowerToPWM(r)<<4,this.sendPFIRMessage(o)}startPFMotors(e,t,r){let i=0;e>4&&(e-=4,i=1);const o=n.alloc(2);return o[0]=(e-1+4+(i<<3)<<4)+this._pfPowerToPWM(t),o[1]=this._pfPowerToPWM(r)<<4,this.sendPFIRMessage(o)}sendPFIRMessage(e){if(this.isWeDo2SmartHub)throw new Error("Power Functions IR is not available on the WeDo 2.0 Smart Hub");{const t=n.alloc(2);return t[0]=(e[0]<<4)+(e[1]>>4),t[1]=e[0]>>4,this.subscribe(l.PF_IR),this.writeDirect(7,t)}}setColor(e){return new Promise((t=>{if(!1===e&&(e=0),this.isWeDo2SmartHub)throw new Error("Setting LED color is not available on the WeDo 2.0 Smart Hub");return this.subscribe(l.LED),this.writeDirect(5,n.from([e])),t()}))}setDistanceCount(e){return new Promise((t=>{if(this.isWeDo2SmartHub)throw new Error("Setting distance count is not available on the WeDo 2.0 Smart Hub");{const t=n.alloc(4);t.writeUInt32LE(e%2**32),this.writeDirect(2,t)}return t()}))}_pfPowerToPWM(e){return 15&e}}var l,_;t.ColorDistanceSensor=f,function(e){e[e.COLOR=0]="COLOR",e[e.DISTANCE=1]="DISTANCE",e[e.DISTANCE_COUNT=2]="DISTANCE_COUNT",e[e.REFLECT=3]="REFLECT",e[e.AMBIENT=4]="AMBIENT",e[e.LED=5]="LED",e[e.RGB_I=6]="RGB_I",e[e.PF_IR=7]="PF_IR",e[e.COLOR_AND_DISTANCE=8]="COLOR_AND_DISTANCE"}(l=t.Mode||(t.Mode={})),t.ModeMap={color:l.COLOR,distance:l.DISTANCE,distanceCount:l.DISTANCE_COUNT,reflect:l.REFLECT,ambient:l.AMBIENT,rgbIntensity:l.RGB_I,colorAndDistance:l.COLOR_AND_DISTANCE},(_=t.Output||(t.Output={})).RED="RED",_.BLUE="BLUE"},4499:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.CurrentSensor=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.CURRENT_SENSOR)}receive(e){switch(this.mode){case u.CURRENT:if(this.isWeDo2SmartHub){const t=e.readInt16LE(2)/1e3;this.notify("current",{current:t})}else{let t=f[this.hub.type];void 0===t&&(t=f[a.HubType.UNKNOWN]);let r=l[this.hub.type];void 0===r&&(r=l[a.HubType.UNKNOWN]);const n=e.readUInt16LE(4)*t/r;this.notify("current",{current:n})}}}}var u;t.CurrentSensor=c,function(e){e[e.CURRENT=0]="CURRENT"}(u=t.Mode||(t.Mode={})),t.ModeMap={current:u.CURRENT};const f={[a.HubType.UNKNOWN]:2444,[a.HubType.TECHNIC_MEDIUM_HUB]:4175},l={[a.HubType.UNKNOWN]:4095}},5468:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Device=void 0;const a=r(7187),c=s(r(4312));class u extends a.EventEmitter{constructor(e,t,r={},n=c.DeviceType.UNKNOWN){super(),this.autoSubscribe=!0,this.values={},this._busy=!1,this._finishedCallbacks=[],this._connected=!0,this._modeMap={},this._isVirtualPort=!1,this._eventTimer=null,this._hub=e,this._portId=t,this._type=n,this._modeMap=r,this._isWeDo2SmartHub=this.hub.type===c.HubType.WEDO2_SMART_HUB,this._isVirtualPort=this.hub.isPortVirtual(t);const i=e=>{"detach"!==e&&this.autoSubscribe&&void 0!==this._modeMap[e]&&this.subscribe(this._modeMap[e])},o=e=>{e.portId===this.portId&&(this._connected=!1,this.hub.removeListener("detach",o),this.emit("detach"))};for(const e in this._modeMap)this.hub.listenerCount(e)>0&&i(e);this.hub.on("newListener",i),this.on("newListener",i),this.hub.on("detach",o)}get connected(){return this._connected}get hub(){return this._hub}get portId(){return this._portId}get portName(){return this.hub.getPortNameForPortId(this.portId)}get type(){return this._type}get typeName(){return c.DeviceTypeNames[this.type]}get mode(){return this._mode}get isWeDo2SmartHub(){return this._isWeDo2SmartHub}get isVirtualPort(){return this._isVirtualPort}writeDirect(e,t){return this.isWeDo2SmartHub?this.send(n.concat([n.from([this.portId,1,2]),t]),c.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE):this.send(n.concat([n.from([129,this.portId,17,81,e]),t]),c.BLECharacteristic.LPF2_ALL)}send(e,t=c.BLECharacteristic.LPF2_ALL){return this._ensureConnected(),this.hub.send(e,t)}subscribe(e){this._ensureConnected(),e!==this._mode&&(this._mode=e,this.hub.subscribe(this.portId,this.type,e))}unsubscribe(e){this._ensureConnected()}receive(e){this.notify("receive",{message:e})}notify(e,t){this.values[e]=t,this.emit(e,t),this.hub.listenerCount(e)>0&&this.hub.emit(e,this,t)}requestUpdate(){this.send(n.from([33,this.portId,0]))}finish(e){if(16!=(16&e))for(this._busy=1==(1&e);this._finishedCallbacks.length>Number(this._busy);){const e=this._finishedCallbacks.shift();e&&e()}}setEventTimer(e){this._eventTimer=e}cancelEventTimer(){this._eventTimer&&(clearTimeout(this._eventTimer),this._eventTimer=null)}_ensureConnected(){if(!this.connected)throw new Error("Device is not connected")}}t.Device=u},1718:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.DuploTrainBaseColorSensor=void 0;const s=r(5468),a=o(r(4312)),c=r(8593);class u extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.DUPLO_TRAIN_BASE_COLOR_SENSOR)}receive(e){switch(this._mode){case f.INTENSITY:const t=e[4];this.notify("intensity",{intensity:t});break;case f.COLOR:if(e[4]<=10){const t=(0,c.parseColor)(e[4]);this.notify("color",{color:t})}break;case f.REFLECTIVITY:const r=e[4];this.notify("reflect",{reflect:r});break;case f.RGB:const n=Math.floor(e.readUInt16LE(4)/4),i=Math.floor(e.readUInt16LE(6)/4),o=Math.floor(e.readUInt16LE(8)/4);this.notify("rgb",{red:n,green:i,blue:o})}}}var f;t.DuploTrainBaseColorSensor=u,function(e){e[e.INTENSITY=0]="INTENSITY",e[e.COLOR=1]="COLOR",e[e.REFLECTIVITY=2]="REFLECTIVITY",e[e.RGB=3]="RGB"}(f=t.Mode||(t.Mode={})),t.ModeMap={intensity:f.INTENSITY,color:f.COLOR,reflect:f.REFLECTIVITY,rgb:f.RGB}},9539:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.DuploTrainBaseMotor=void 0;const s=r(2897),a=o(r(4312));class c extends s.BasicMotor{constructor(e,t){super(e,t,{},a.DeviceType.DUPLO_TRAIN_BASE_MOTOR)}}t.DuploTrainBaseMotor=c},6758:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Mode=t.DuploTrainBaseSpeaker=void 0;const a=r(5468),c=s(r(4312));class u extends a.Device{constructor(e,t){super(e,t,{},c.DeviceType.DUPLO_TRAIN_BASE_SPEAKER)}playSound(e){return new Promise((t=>(this.subscribe(f.SOUND),this.writeDirect(1,n.from([e])),t())))}playTone(e){this.subscribe(f.TONE),this.writeDirect(2,n.from([e]))}}var f;t.DuploTrainBaseSpeaker=u,function(e){e[e.SOUND=1]="SOUND",e[e.TONE=2]="TONE"}(f=t.Mode||(t.Mode={}))},1668:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.DuploTrainBaseSpeedometer=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.DUPLO_TRAIN_BASE_SPEEDOMETER)}receive(e){switch(this._mode){case u.SPEED:const t=e.readInt16LE(4);this.notify("speed",{speed:t})}}}var u;t.DuploTrainBaseSpeedometer=c,function(e){e[e.SPEED=0]="SPEED"}(u=t.Mode||(t.Mode={})),t.ModeMap={speed:u.SPEED}},783:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Mode=t.HubLED=void 0;const a=r(5468),c=s(r(4312));class u extends a.Device{constructor(e,t){super(e,t,{},c.DeviceType.HUB_LED)}setColor(e){return new Promise((t=>("boolean"==typeof e&&(e=0),this.isWeDo2SmartHub?(this.send(n.from([6,23,1,1]),c.BLECharacteristic.WEDO2_PORT_TYPE_WRITE),this.send(n.from([6,4,1,e]),c.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE)):(this.subscribe(f.COLOR),this.writeDirect(0,n.from([e]))),t())))}setRGB(e,t,r){return new Promise((i=>(this.isWeDo2SmartHub?(this.send(n.from([6,23,1,2]),c.BLECharacteristic.WEDO2_PORT_TYPE_WRITE),this.send(n.from([6,4,3,e,t,r]),c.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE)):(this.subscribe(f.RGB),this.writeDirect(1,n.from([e,t,r]))),i())))}}var f;t.HubLED=u,function(e){e[e.COLOR=0]="COLOR",e[e.RGB=1]="RGB"}(f=t.Mode||(t.Mode={}))},3677:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Light=void 0;const a=r(5468),c=s(r(4312)),u=r(8593);class f extends a.Device{constructor(e,t){super(e,t,{},c.DeviceType.LIGHT)}setBrightness(e,t=!0){return t&&this.cancelEventTimer(),new Promise((t=>(this.writeDirect(0,n.from([e])),t())))}rampBrightness(e,t,r){return this.cancelEventTimer(),new Promise((n=>{(0,u.calculateRamp)(this,e,t,r).on("changePower",(e=>{this.setBrightness(e,!1)})).on("finished",n)}))}}t.Light=f},3859:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.MarioAccelerometer=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.MARIO_ACCELEROMETER)}receive(e){switch(this._mode){case u.ACCEL:const t=e[4],r=e[5],n=e[6];this.notify("accel",{x:t,y:r,z:n});break;case u.GEST:const i=e[4];this.notify("gesture",{gesture:i})}}}var u;t.MarioAccelerometer=c,function(e){e[e.ACCEL=0]="ACCEL",e[e.GEST=1]="GEST"}(u=t.Mode||(t.Mode={})),t.ModeMap={accel:u.ACCEL,gesture:u.GEST}},4477:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.MarioBarcodeSensor=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.MARIO_BARCODE_SENSOR)}receive(e){switch(this._mode){case u.BARCODE:const t=e.readUInt16LE(4),r=e.readUInt16LE(6);65535===r?this.notify("barcode",{barcode:t}):65535===t&&this.notify("barcode",{color:r});break;case u.RGB:const n=e[4],i=e[5],o=e[6];this.notify("rgb",{r:n,g:i,b:o})}}}var u;t.MarioBarcodeSensor=c,function(e){e[e.BARCODE=0]="BARCODE",e[e.RGB=1]="RGB"}(u=t.Mode||(t.Mode={})),t.ModeMap={barcode:u.BARCODE,rgb:u.RGB}},7085:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.MarioPantsSensor=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.MARIO_PANTS_SENSOR)}receive(e){switch(this._mode){case u.PANTS:const t=e[4];this.notify("pants",{pants:t})}}}var u;t.MarioPantsSensor=c,function(e){e[e.PANTS=0]="PANTS"}(u=t.Mode||(t.Mode={})),t.ModeMap={pants:u.PANTS}},7375:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.MediumLinearMotor=void 0;const s=r(9847),a=o(r(4312));class c extends s.TachoMotor{constructor(e,t){super(e,t,{},a.DeviceType.MEDIUM_LINEAR_MOTOR)}}t.MediumLinearMotor=c},7201:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.MotionSensor=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.MOTION_SENSOR)}receive(e){switch(this._mode){case u.DISTANCE:let t=e[this.isWeDo2SmartHub?2:4];1===e[this.isWeDo2SmartHub?3:5]&&(t+=255),t*=10,this.notify("distance",{distance:t})}}}var u;t.MotionSensor=c,function(e){e[e.DISTANCE=0]="DISTANCE"}(u=t.Mode||(t.Mode={})),t.ModeMap={distance:u.DISTANCE}},4772:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.MoveHubMediumLinearMotor=void 0;const s=r(9847),a=o(r(4312));class c extends s.TachoMotor{constructor(e,t){super(e,t,{},a.DeviceType.MOVE_HUB_MEDIUM_LINEAR_MOTOR)}}t.MoveHubMediumLinearMotor=c},6227:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.MoveHubTiltSensor=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.MOVE_HUB_TILT_SENSOR)}receive(e){switch(this._mode){case u.TILT:const t=-e.readInt8(4),r=e.readInt8(5);this.notify("tilt",{x:t,y:r})}}}var u;t.MoveHubTiltSensor=c,function(e){e[e.TILT=0]="TILT"}(u=t.Mode||(t.Mode={})),t.ModeMap={tilt:u.TILT}},222:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PiezoBuzzer=void 0;const a=r(5468),c=s(r(4312));class u extends a.Device{constructor(e,t){super(e,t,{},c.DeviceType.PIEZO_BUZZER)}playTone(e,t){return new Promise((i=>{const o=n.from([5,2,4,0,0,0,0]);o.writeUInt16LE(e,3),o.writeUInt16LE(t,5),this.send(o,c.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE),r.g.setTimeout(i,t)}))}}t.PiezoBuzzer=u},3387:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ButtonState=t.ModeMap=t.Mode=t.RemoteControlButton=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.REMOTE_CONTROL_BUTTON)}receive(e){switch(this._mode){case u.BUTTON_EVENTS:const t=e[4];this.notify("remoteButton",{event:t})}}}var u;t.RemoteControlButton=c,function(e){e[e.BUTTON_EVENTS=0]="BUTTON_EVENTS"}(u=t.Mode||(t.Mode={})),t.ModeMap={remoteButton:u.BUTTON_EVENTS},t.ButtonState={UP:1,DOWN:255,STOP:127,RELEASED:0}},3652:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleMediumLinearMotor=void 0;const s=r(2897),a=o(r(4312));class c extends s.BasicMotor{constructor(e,t){super(e,t,{},a.DeviceType.SIMPLE_MEDIUM_LINEAR_MOTOR)}}t.SimpleMediumLinearMotor=c},9847:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TachoMotor=void 0;const a=r(2897),c=s(r(4312)),u=r(8593);class f extends a.BasicMotor{constructor(e,r,n={},i=c.DeviceType.UNKNOWN){super(e,r,Object.assign({},n,t.ModeMap),i),this._brakeStyle=c.BrakingStyle.BRAKE,this._maxPower=100,this.useAccelerationProfile=!0,this.useDecelerationProfile=!0}receive(e){switch(this._mode){case l.ROTATION:const t=e.readInt32LE(this.isWeDo2SmartHub?2:4);this.notify("rotate",{degrees:t})}}setBrakingStyle(e){this._brakeStyle=e}setMaxPower(e){this._maxPower=e}setAccelerationTime(e,t=0){const r=n.from([129,this.portId,17,5,0,0,t]);r.writeUInt16LE(e,4),this.send(r)}setDecelerationTime(e,t=0){const r=n.from([129,this.portId,17,6,0,0,t]);r.writeUInt16LE(e,4),this.send(r)}setSpeed(e,t){if(!this.isVirtualPort&&e instanceof Array)throw new Error("Only virtual ports can accept multiple speeds");if(this.isWeDo2SmartHub)throw new Error("Motor speed is not available on the WeDo 2.0 Smart Hub");return this.cancelEventTimer(),new Promise((r=>{let i;null==e&&(e=100),void 0!==t?(i=e instanceof Array?n.from([129,this.portId,17,10,0,0,(0,u.mapSpeed)(e[0]),(0,u.mapSpeed)(e[1]),this._maxPower,this._brakeStyle,this.useProfile()]):n.from([129,this.portId,17,9,0,0,(0,u.mapSpeed)(e),this._maxPower,this._brakeStyle,this.useProfile()]),i.writeUInt16LE(t,4)):i=e instanceof Array?n.from([129,this.portId,17,8,(0,u.mapSpeed)(e[0]),(0,u.mapSpeed)(e[1]),this._maxPower,this.useProfile()]):n.from([129,this.portId,17,7,(0,u.mapSpeed)(e),this._maxPower,this.useProfile()]),this.send(i),this._finishedCallbacks.push((()=>r()))}))}rotateByDegrees(e,t){if(!this.isVirtualPort&&t instanceof Array)throw new Error("Only virtual ports can accept multiple speeds");if(this.isWeDo2SmartHub)throw new Error("Rotation is not available on the WeDo 2.0 Smart Hub");return this.cancelEventTimer(),new Promise((r=>{let i;null==t&&(t=100),i=t instanceof Array?n.from([129,this.portId,17,12,0,0,0,0,(0,u.mapSpeed)(t[0]),(0,u.mapSpeed)(t[1]),this._maxPower,this._brakeStyle,this.useProfile()]):n.from([129,this.portId,17,11,0,0,0,0,(0,u.mapSpeed)(t),this._maxPower,this._brakeStyle,this.useProfile()]),i.writeUInt32LE(e,4),this.send(i),this._finishedCallbacks.push((()=>r()))}))}useProfile(){let e=0;return this.useAccelerationProfile&&(e+=1),this.useDecelerationProfile&&(e+=2),e}}var l;t.TachoMotor=f,function(e){e[e.ROTATION=2]="ROTATION"}(l=t.Mode||(t.Mode={})),t.ModeMap={rotate:l.ROTATION}},5917:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Mode=t.Technic3x3ColorLightMatrix=void 0;const a=r(148),c=r(5468),u=s(r(4312));class f extends c.Device{constructor(e,t){super(e,t,{},u.DeviceType.TECHNIC_3X3_COLOR_LIGHT_MATRIX)}setMatrix(e){return new Promise((t=>{this.subscribe(l.PIX_0);const r=new Array(9);for(let t=0;t<r.length;t++)"number"==typeof e&&(r[t]=e+160),e[t]instanceof a.Color&&(r[t]=e[t].toValue()),e[t]===u.Color.NONE&&(r[t]=u.Color.NONE),e[t]<=10&&(r[t]=e[t]+160);return this.writeDirect(l.PIX_0,n.from(r)),t()}))}}var l;t.Technic3x3ColorLightMatrix=f,function(e){e[e.LEV_0=0]="LEV_0",e[e.COL_0=1]="COL_0",e[e.PIX_0=2]="PIX_0",e[e.TRANS=3]="TRANS"}(l=t.Mode||(t.Mode={}))},6481:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicColorSensor=void 0;const a=r(5468),c=s(r(4312)),u=r(8593);class f extends a.Device{constructor(e,r){super(e,r,t.ModeMap,c.DeviceType.TECHNIC_COLOR_SENSOR)}receive(e){switch(this._mode){case l.COLOR:if(e[4]<=10){const t=(0,u.parseColor)(e[4]);this.notify("color",{color:t})}break;case l.REFLECTIVITY:const t=e[4];this.notify("reflect",{reflect:t});break;case l.AMBIENT_LIGHT:const r=e[4];this.notify("ambient",{ambient:r})}}setBrightness(e,t,r){this.writeDirect(3,n.from([e,t,r]))}}var l;t.TechnicColorSensor=f,function(e){e[e.COLOR=0]="COLOR",e[e.REFLECTIVITY=1]="REFLECTIVITY",e[e.AMBIENT_LIGHT=2]="AMBIENT_LIGHT"}(l=t.Mode||(t.Mode={})),t.ModeMap={color:l.COLOR,reflect:l.REFLECTIVITY,ambient:l.AMBIENT_LIGHT}},6147:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicDistanceSensor=void 0;const a=r(5468),c=s(r(4312));class u extends a.Device{constructor(e,r){super(e,r,t.ModeMap,c.DeviceType.TECHNIC_DISTANCE_SENSOR)}receive(e){switch(this._mode){case f.DISTANCE:const t=e.readUInt16LE(4);this.notify("distance",{distance:t});break;case f.FAST_DISTANCE:const r=e.readUInt16LE(4);this.notify("fastDistance",{fastDistance:r})}}setBrightness(e,t,r,i){this.writeDirect(5,n.from([e,r,t,i]))}}var f;t.TechnicDistanceSensor=u,function(e){e[e.DISTANCE=0]="DISTANCE",e[e.FAST_DISTANCE=1]="FAST_DISTANCE"}(f=t.Mode||(t.Mode={})),t.ModeMap={distance:f.DISTANCE,fastDistance:f.FAST_DISTANCE}},2826:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicForceSensor=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.TECHNIC_FORCE_SENSOR)}receive(e){switch(this._mode){case u.FORCE:const t=e[this.isWeDo2SmartHub?2:4]/10;this.notify("force",{force:t});break;case u.TOUCHED:const r=!!e[4];this.notify("touched",{touched:r});break;case u.TAPPED:const n=e[4];this.notify("tapped",{tapped:n})}}}var u;t.TechnicForceSensor=c,function(e){e[e.FORCE=0]="FORCE",e[e.TOUCHED=1]="TOUCHED",e[e.TAPPED=2]="TAPPED"}(u=t.Mode||(t.Mode={})),t.ModeMap={force:u.FORCE,touched:u.TOUCHED,tapped:u.TAPPED}},2667:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TechnicLargeAngularMotor=void 0;const s=r(9045),a=o(r(4312));class c extends s.AbsoluteMotor{constructor(e,t,r={},n=a.DeviceType.TECHNIC_LARGE_ANGULAR_MOTOR){super(e,t,{},n)}}t.TechnicLargeAngularMotor=c},1665:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TechnicLargeLinearMotor=void 0;const s=r(9045),a=o(r(4312));class c extends s.AbsoluteMotor{constructor(e,t){super(e,t,{},a.DeviceType.TECHNIC_LARGE_LINEAR_MOTOR)}}t.TechnicLargeLinearMotor=c},3841:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TechnicMediumAngularMotor=void 0;const s=r(9045),a=o(r(4312));class c extends s.AbsoluteMotor{constructor(e,t,r={},n=a.DeviceType.TECHNIC_MEDIUM_ANGULAR_MOTOR){super(e,t,{},n)}}t.TechnicMediumAngularMotor=c},4321:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicMediumHubAccelerometerSensor=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.TECHNIC_MEDIUM_HUB_ACCELEROMETER)}receive(e){switch(this._mode){case u.ACCEL:const t=Math.round(e.readInt16LE(4)/4.096),r=Math.round(e.readInt16LE(6)/4.096),n=Math.round(e.readInt16LE(8)/4.096);this.notify("accel",{x:t,y:r,z:n})}}}var u;t.TechnicMediumHubAccelerometerSensor=c,function(e){e[e.ACCEL=0]="ACCEL"}(u=t.Mode||(t.Mode={})),t.ModeMap={accel:u.ACCEL}},8425:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicMediumHubGyroSensor=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.TECHNIC_MEDIUM_HUB_GYRO_SENSOR)}receive(e){switch(this._mode){case u.GYRO:const t=Math.round(7*e.readInt16LE(4)/400),r=Math.round(7*e.readInt16LE(6)/400),n=Math.round(7*e.readInt16LE(8)/400);this.notify("gyro",{x:t,y:r,z:n})}}}var u;t.TechnicMediumHubGyroSensor=c,function(e){e[e.GYRO=0]="GYRO"}(u=t.Mode||(t.Mode={})),t.ModeMap={gyro:u.GYRO}},2644:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicMediumHubTiltSensor=void 0;const a=r(5468),c=s(r(4312));class u extends a.Device{constructor(e,r){super(e,r,t.ModeMap,c.DeviceType.TECHNIC_MEDIUM_HUB_TILT_SENSOR),this._impactThreshold=10,this._impactHoldoff=10}receive(e){switch(this._mode){case f.TILT:let t=-e.readInt16LE(4);const r=e.readInt16LE(6),n=e.readInt16LE(8);90!==r&&-90!==r||(t=Math.sign(r)*(t+180),t>180&&(t-=360),t<-180&&(t+=360)),this.notify("tilt",{x:n,y:r,z:t});break;case f.IMPACT_COUNT:if(8!==e.length)break;const i=e.readUInt32LE(4);this.notify("tiltCount",{count:i})}}setImpactCount(e){return new Promise((t=>{const r=n.alloc(4);return r.writeUInt32LE(e%2**32),this.writeDirect(1,r),t()}))}setImpactThreshold(e){return this._impactThreshold=e,new Promise((e=>(this.writeDirect(2,n.from([this._impactThreshold,this._impactHoldoff])),e())))}setImpactHoldoff(e){return this._impactHoldoff=e,new Promise((e=>(this.writeDirect(2,n.from([this._impactThreshold,this._impactHoldoff])),e())))}}var f;t.TechnicMediumHubTiltSensor=u,function(e){e[e.TILT=0]="TILT",e[e.IMPACT_COUNT=1]="IMPACT_COUNT"}(f=t.Mode||(t.Mode={})),t.ModeMap={tilt:f.TILT,impactCount:f.IMPACT_COUNT}},5922:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TechnicSmallAngularMotor=void 0;const s=r(9045),a=o(r(4312));class c extends s.AbsoluteMotor{constructor(e,t,r={},n=a.DeviceType.TECHNIC_SMALL_ANGULAR_MOTOR){super(e,t,{},n)}}t.TechnicSmallAngularMotor=c},6121:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TechnicXLargeLinearMotor=void 0;const s=r(9045),a=o(r(4312));class c extends s.AbsoluteMotor{constructor(e,t){super(e,t,{},a.DeviceType.TECHNIC_XLARGE_LINEAR_MOTOR)}}t.TechnicXLargeLinearMotor=c},8762:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TiltSensor=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.TILT_SENSOR)}receive(e){switch(this._mode){case u.TILT:const t=e.readInt8(this.isWeDo2SmartHub?2:4),r=e.readInt8(this.isWeDo2SmartHub?3:5);this.notify("tilt",{x:t,y:r})}}}var u;t.TiltSensor=c,function(e){e[e.TILT=0]="TILT"}(u=t.Mode||(t.Mode={})),t.ModeMap={tilt:u.TILT}},8036:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TrainMotor=void 0;const s=r(2897),a=o(r(4312));class c extends s.BasicMotor{constructor(e,t){super(e,t,{},a.DeviceType.TRAIN_MOTOR)}}t.TrainMotor=c},9257:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.VoltageSensor=void 0;const s=r(5468),a=o(r(4312));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.VOLTAGE_SENSOR)}receive(e){switch(this._mode){case u.VOLTAGE:if(this.isWeDo2SmartHub){const t=e.readInt16LE(2)/40;this.notify("voltage",{voltage:t})}else{let t=f[this.hub.type];void 0===t&&(t=f[a.HubType.UNKNOWN]);let r=l[this.hub.type];void 0===r&&(r=l[a.HubType.UNKNOWN]);const n=e.readUInt16LE(4)*t/r;this.notify("voltage",{voltage:n})}}}}var u;t.VoltageSensor=c,function(e){e[e.VOLTAGE=0]="VOLTAGE"}(u=t.Mode||(t.Mode={})),t.ModeMap={voltage:u.VOLTAGE};const f={[a.HubType.UNKNOWN]:9.615,[a.HubType.DUPLO_TRAIN_BASE]:6.4,[a.HubType.REMOTE_CONTROL]:6.4},l={[a.HubType.UNKNOWN]:3893,[a.HubType.DUPLO_TRAIN_BASE]:3047,[a.HubType.REMOTE_CONTROL]:3200,[a.HubType.TECHNIC_MEDIUM_HUB]:4095}},6503:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.BaseHub=void 0;const s=r(7187),a=r(9126),c=r(4499),u=r(5468),f=r(1718),l=r(9539),_=r(6758),h=r(1668),d=r(783),p=r(3677),E=r(3859),O=r(4477),T=r(7085),b=r(7375),M=r(7201),v=r(4772),y=r(6227),R=r(222),m=r(3387),S=r(3652),I=r(6481),A=r(6147),L=r(2826),D=r(2667),C=r(1665),N=r(5922),g=r(3841),P=r(4321),B=r(8425),U=r(2644),w=r(6121),H=r(8762),j=r(8036),F=r(9257),W=o(r(4312)),G=r(1227),x=r(5917),V=G("basehub");class k extends s.EventEmitter{constructor(e,t={},r=W.HubType.UNKNOWN){super(),this._attachedDevices={},this._name="",this._firmwareVersion="0.0.00.0000",this._hardwareVersion="0.0.00.0000",this._primaryMACAddress="00:00:00:00:00:00",this._batteryLevel=100,this._rssi=-60,this._portMap={},this._virtualPorts=[],this._attachCallbacks=[],this.setMaxListeners(23),this._type=r,this._bleDevice=e,this._portMap=Object.assign({},t),e.on("disconnect",(()=>{this.emit("disconnect")}))}get name(){return this._bleDevice.name}get connected(){return this._bleDevice.connected}get connecting(){return this._bleDevice.connecting}get type(){return this._type}get ports(){return Object.keys(this._portMap)}get firmwareVersion(){return this._firmwareVersion}get hardwareVersion(){return this._hardwareVersion}get primaryMACAddress(){return this._primaryMACAddress}get uuid(){return this._bleDevice.uuid}get batteryLevel(){return this._batteryLevel}get rssi(){return this._rssi}connect(){if(this._bleDevice.connecting)throw new Error("Already connecting");if(this._bleDevice.connected)throw new Error("Already connected");return this._bleDevice.connect()}disconnect(){return this._bleDevice.disconnect()}getDeviceAtPort(e){const t=this._portMap[e];return void 0!==t?this._attachedDevices[t]:void 0}waitForDeviceAtPort(e){return new Promise((t=>{const r=this.getDeviceAtPort(e);if(r)return t(r);this._attachCallbacks.push((r=>r.portName===e&&(t(r),!0)))}))}getDevices(){return Object.values(this._attachedDevices)}getDevicesByType(e){return this.getDevices().filter((t=>t.type===e))}waitForDeviceByType(e){return new Promise((t=>{const r=this.getDevicesByType(e);if(r.length>=1)return t(r[0]);this._attachCallbacks.push((r=>r.type===e&&(t(r),!0)))}))}getPortNameForPortId(e){for(const t of Object.keys(this._portMap))if(this._portMap[t]===e)return t}isPortVirtual(e){return this._virtualPorts.indexOf(e)>-1}sleep(e){return new Promise((t=>{r.g.setTimeout(t,e)}))}wait(e){return Promise.all(e)}send(e,t){return Promise.resolve()}subscribe(e,t,r){}unsubscribe(e,t,r){}manuallyAttachDevice(e,t){if(this._attachedDevices[t]){if(this._attachedDevices[t].type===e)return V(`Device of ${e} already attached to portId ${t}, returning existing device`),this._attachedDevices[t];throw new Error(`Already a different type of device attached to portId ${t}. Only use this method when you are certain what's attached.`)}{V(`No device attached to portId ${t}, creating and attaching device type ${e}`);const r=this._createDevice(e,t);return this._attachDevice(r),r}}_attachDevice(e){if(this._attachedDevices[e.portId]&&this._attachedDevices[e.portId].type===e.type)return;this._attachedDevices[e.portId]=e,this.emit("attach",e),V(`Attached device type ${e.type} (${W.DeviceTypeNames[e.type]}) on port ${e.portName} (${e.portId})`);let t=this._attachCallbacks.length;for(;t--;)(0,this._attachCallbacks[t])(e)&&this._attachCallbacks.splice(t,1)}_detachDevice(e){delete this._attachedDevices[e.portId],this.emit("detach",e),V(`Detached device type ${e.type} (${W.DeviceTypeNames[e.type]}) on port ${e.portName} (${e.portId})`)}_createDevice(e,t){let r;return r={[W.DeviceType.LIGHT]:p.Light,[W.DeviceType.TRAIN_MOTOR]:j.TrainMotor,[W.DeviceType.SIMPLE_MEDIUM_LINEAR_MOTOR]:S.SimpleMediumLinearMotor,[W.DeviceType.MOVE_HUB_MEDIUM_LINEAR_MOTOR]:v.MoveHubMediumLinearMotor,[W.DeviceType.MOTION_SENSOR]:M.MotionSensor,[W.DeviceType.TILT_SENSOR]:H.TiltSensor,[W.DeviceType.MOVE_HUB_TILT_SENSOR]:y.MoveHubTiltSensor,[W.DeviceType.PIEZO_BUZZER]:R.PiezoBuzzer,[W.DeviceType.TECHNIC_COLOR_SENSOR]:I.TechnicColorSensor,[W.DeviceType.TECHNIC_DISTANCE_SENSOR]:A.TechnicDistanceSensor,[W.DeviceType.TECHNIC_FORCE_SENSOR]:L.TechnicForceSensor,[W.DeviceType.TECHNIC_MEDIUM_HUB_TILT_SENSOR]:U.TechnicMediumHubTiltSensor,[W.DeviceType.TECHNIC_MEDIUM_HUB_GYRO_SENSOR]:B.TechnicMediumHubGyroSensor,[W.DeviceType.TECHNIC_MEDIUM_HUB_ACCELEROMETER]:P.TechnicMediumHubAccelerometerSensor,[W.DeviceType.MEDIUM_LINEAR_MOTOR]:b.MediumLinearMotor,[W.DeviceType.TECHNIC_SMALL_ANGULAR_MOTOR]:N.TechnicSmallAngularMotor,[W.DeviceType.TECHNIC_MEDIUM_ANGULAR_MOTOR]:g.TechnicMediumAngularMotor,[W.DeviceType.TECHNIC_LARGE_ANGULAR_MOTOR]:D.TechnicLargeAngularMotor,[W.DeviceType.TECHNIC_LARGE_LINEAR_MOTOR]:C.TechnicLargeLinearMotor,[W.DeviceType.TECHNIC_XLARGE_LINEAR_MOTOR]:w.TechnicXLargeLinearMotor,[W.DeviceType.COLOR_DISTANCE_SENSOR]:a.ColorDistanceSensor,[W.DeviceType.VOLTAGE_SENSOR]:F.VoltageSensor,[W.DeviceType.CURRENT_SENSOR]:c.CurrentSensor,[W.DeviceType.REMOTE_CONTROL_BUTTON]:m.RemoteControlButton,[W.DeviceType.HUB_LED]:d.HubLED,[W.DeviceType.DUPLO_TRAIN_BASE_COLOR_SENSOR]:f.DuploTrainBaseColorSensor,[W.DeviceType.DUPLO_TRAIN_BASE_MOTOR]:l.DuploTrainBaseMotor,[W.DeviceType.DUPLO_TRAIN_BASE_SPEAKER]:_.DuploTrainBaseSpeaker,[W.DeviceType.DUPLO_TRAIN_BASE_SPEEDOMETER]:h.DuploTrainBaseSpeedometer,[W.DeviceType.MARIO_ACCELEROMETER]:E.MarioAccelerometer,[W.DeviceType.MARIO_BARCODE_SENSOR]:O.MarioBarcodeSensor,[W.DeviceType.MARIO_PANTS_SENSOR]:T.MarioPantsSensor,[W.DeviceType.TECHNIC_MEDIUM_ANGULAR_MOTOR_GREY]:g.TechnicMediumAngularMotor,[W.DeviceType.TECHNIC_LARGE_ANGULAR_MOTOR_GREY]:D.TechnicLargeAngularMotor,[W.DeviceType.TECHNIC_3X3_COLOR_LIGHT_MATRIX]:x.Technic3x3ColorLightMatrix}[e],r?new r(this,t,void 0,e):new u.Device(this,t,void 0,e)}_getDeviceByPortId(e){return this._attachedDevices[e]}}t.BaseHub=k},5688:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.DuploTrainBase=void 0;const s=r(551),a=o(r(4312)),c=r(1227)("duplotrainbase");class u extends s.LPF2Hub{static IsDuploTrainBase(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(a.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===a.BLEManufacturerData.DUPLO_TRAIN_BASE_ID}constructor(e){super(e,t.PortMap,a.HubType.DUPLO_TRAIN_BASE),c("Discovered Duplo Train Base")}async connect(){c("Connecting to Duplo Train Base"),await super.connect(),c("Connect completed")}}t.DuploTrainBase=u,t.PortMap={MOTOR:0,COLOR:18,SPEEDOMETER:19}},8647:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.Hub=void 0;const a=s(r(3731)),c=r(551),u=o(r(4312)),f=r(1227)("hub");class l extends c.LPF2Hub{constructor(e){super(e,t.PortMap,u.HubType.HUB),this._currentPort=59,f("Discovered Powered UP Hub")}static IsHub(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(u.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===u.BLEManufacturerData.HUB_ID}async connect(){f("Connecting to Powered UP Hub"),await super.connect(),f("Connect completed")}_checkFirmware(e){if(1===(0,a.default)("1.1.00.0004",e))throw new Error(`Your Powered Up Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`)}}t.Hub=l,t.PortMap={A:0,B:1,HUB_LED:50,CURRENT_SENSOR:59,VOLTAGE_SENSOR:60}},551:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.LPF2Hub=void 0;const a=r(6503),c=s(r(4312)),u=r(8593),f=r(1227),l=f("lpf2hub"),_=f("lpf2hubmodeinfo");class h extends a.BaseHub{constructor(){super(...arguments),this._messageBuffer=n.alloc(0),this._propertyRequestCallbacks={}}async connect(){l("LPF2Hub connecting"),await super.connect(),await this._bleDevice.discoverCharacteristicsForService(c.BLEService.LPF2_HUB),this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.LPF2_ALL,this._parseMessage.bind(this)),await this._requestHubPropertyReports(c.HubPropertyPayload.BUTTON_STATE),await this._requestHubPropertyValue(c.HubPropertyPayload.FW_VERSION),await this._requestHubPropertyValue(c.HubPropertyPayload.HW_VERSION),await this._requestHubPropertyReports(c.HubPropertyPayload.RSSI),await this._requestHubPropertyReports(c.HubPropertyPayload.BATTERY_VOLTAGE),await this._requestHubPropertyValue(c.HubPropertyPayload.PRIMARY_MAC_ADDRESS),this.emit("connect"),l("LPF2Hub connected")}shutdown(){return this.send(n.from([2,1]),c.BLECharacteristic.LPF2_ALL)}async setName(e){if(e.length>14)throw new Error("Name must be 14 characters or less");let t=n.from([1,1,1]);t=n.concat([t,n.from(e,"ascii")]),await this.send(t,c.BLECharacteristic.LPF2_ALL),await this.send(t,c.BLECharacteristic.LPF2_ALL),this._name=e}send(e,t){return(e=n.concat([n.alloc(2),e]))[0]=e.length,l("Sent Message (LPF2_ALL)",e),this._bleDevice.writeToCharacteristic(t,e)}subscribe(e,t,r){return this.send(n.from([65,e,r,1,0,0,0,1]),c.BLECharacteristic.LPF2_ALL)}unsubscribe(e,t){return this.send(n.from([65,e,t,1,0,0,0,0]),c.BLECharacteristic.LPF2_ALL)}createVirtualPort(e,t){const r=this.getDeviceAtPort(e);if(!r)throw new Error(`Port ${e} does not have an attached device`);const i=this.getDeviceAtPort(t);if(!i)throw new Error(`Port ${t} does not have an attached device`);if(r.type!==i.type)throw new Error("Both devices must be of the same type to create a virtual port");return this.send(n.from([97,1,r.portId,i.portId]),c.BLECharacteristic.LPF2_ALL)}_checkFirmware(e){}_parseMessage(e){if(e&&(this._messageBuffer=n.concat([this._messageBuffer,e])),this._messageBuffer.length<=0)return;const t=this._messageBuffer[0];if(t<=this._messageBuffer.length){const e=this._messageBuffer.slice(0,t);switch(this._messageBuffer=this._messageBuffer.slice(t),l("Received Message (LPF2_ALL)",e),e[2]){case c.MessageType.HUB_PROPERTIES:{const t=e[3],r=this._propertyRequestCallbacks[t];r?r(e):this._parseHubPropertyResponse(e),delete this._propertyRequestCallbacks[t];break}case c.MessageType.HUB_ATTACHED_IO:this._parsePortMessage(e);break;case c.MessageType.PORT_INFORMATION:this._parsePortInformationResponse(e);break;case c.MessageType.PORT_MODE_INFORMATION:this._parseModeInformationResponse(e);break;case c.MessageType.PORT_VALUE_SINGLE:this._parseSensorMessage(e);break;case c.MessageType.PORT_OUTPUT_COMMAND_FEEDBACK:this._parsePortAction(e)}this._messageBuffer.length>0&&this._parseMessage()}}_requestHubPropertyValue(e){return new Promise((t=>{this._propertyRequestCallbacks[e]=e=>(this._parseHubPropertyResponse(e),t()),this.send(n.from([1,e,5]),c.BLECharacteristic.LPF2_ALL)}))}_requestHubPropertyReports(e){return this.send(n.from([1,e,2]),c.BLECharacteristic.LPF2_ALL)}_parseHubPropertyResponse(e){if(e[3]===c.HubPropertyPayload.BUTTON_STATE){if(1===e[5])return void this.emit("button",{event:c.ButtonState.PRESSED});if(0===e[5])return void this.emit("button",{event:c.ButtonState.RELEASED})}else if(e[3]===c.HubPropertyPayload.FW_VERSION)this._firmwareVersion=(0,u.decodeVersion)(e.readInt32LE(5)),this._checkFirmware(this._firmwareVersion);else if(e[3]===c.HubPropertyPayload.HW_VERSION)this._hardwareVersion=(0,u.decodeVersion)(e.readInt32LE(5));else if(e[3]===c.HubPropertyPayload.RSSI){const t=e.readInt8(5);0!==t&&(this._rssi=t,this.emit("rssi",{rssi:this._rssi}))}else if(e[3]===c.HubPropertyPayload.PRIMARY_MAC_ADDRESS)this._primaryMACAddress=(0,u.decodeMACAddress)(e.slice(5));else if(e[3]===c.HubPropertyPayload.BATTERY_VOLTAGE){const t=e[5];t!==this._batteryLevel&&(this._batteryLevel=t,this.emit("batteryLevel",{batteryLevel:t}))}}async _parsePortMessage(e){const t=e[3],r=e[4],n=r?e.readUInt16LE(5):0;if(r===c.Event.ATTACHED_IO){if(_.enabled){const r=c.DeviceTypeNames[e[5]]||"Unknown";_(`Port ${(0,u.toHex)(t)}, type ${(0,u.toHex)(n,4)} (${r})`);const i=(0,u.decodeVersion)(e.readInt32LE(7)),o=(0,u.decodeVersion)(e.readInt32LE(11));_(`Port ${(0,u.toHex)(t)}, hardware version ${i}, software version ${o}`),await this._sendPortInformationRequest(t)}const r=this._createDevice(n,t);this._attachDevice(r)}else if(r===c.Event.DETACHED_IO){const e=this._getDeviceByPortId(t);if(e&&(this._detachDevice(e),this.isPortVirtual(t))){const e=this.getPortNameForPortId(t);e&&delete this._portMap[e],this._virtualPorts=this._virtualPorts.filter((e=>e!==t))}}else if(r===c.Event.ATTACHED_VIRTUAL_IO){const t=this.getPortNameForPortId(e[7])+this.getPortNameForPortId(e[8]),r=e[3];this._portMap[t]=r,this._virtualPorts.push(r);const i=this._createDevice(n,r);this._attachDevice(i)}}async _sendPortInformationRequest(e){await this.send(n.from([33,e,1]),c.BLECharacteristic.LPF2_ALL),await this.send(n.from([33,e,2]),c.BLECharacteristic.LPF2_ALL)}async _parsePortInformationResponse(e){const t=e[3];if(2===e[4]){const r=[];for(let t=5;t<e.length;t+=2)r.push(e.readUInt16LE(t));return void _(`Port ${(0,u.toHex)(t)}, mode combinations [${r.map((e=>(0,u.toBin)(e,0))).join(", ")}]`)}const r=e[6],n=(0,u.toBin)(e.readUInt16LE(7),r),i=(0,u.toBin)(e.readUInt16LE(9),r);_(`Port ${(0,u.toHex)(t)}, total modes ${r}, input modes ${n}, output modes ${i}`);for(let e=0;e<r;e++)await this._sendModeInformationRequest(t,e,c.ModeInformationType.NAME),await this._sendModeInformationRequest(t,e,c.ModeInformationType.RAW),await this._sendModeInformationRequest(t,e,c.ModeInformationType.PCT),await this._sendModeInformationRequest(t,e,c.ModeInformationType.SI),await this._sendModeInformationRequest(t,e,c.ModeInformationType.SYMBOL),await this._sendModeInformationRequest(t,e,c.ModeInformationType.VALUE_FORMAT)}_sendModeInformationRequest(e,t,r){return this.send(n.from([34,e,t,r]),c.BLECharacteristic.LPF2_ALL)}_parseModeInformationResponse(e){const t=(0,u.toHex)(e[3]),r=e[4];switch(e[5]){case c.ModeInformationType.NAME:_(`Port ${t}, mode ${r}, name ${e.slice(6,e.length).toString()}`);break;case c.ModeInformationType.RAW:_(`Port ${t}, mode ${r}, RAW min ${e.readFloatLE(6)}, max ${e.readFloatLE(10)}`);break;case c.ModeInformationType.PCT:_(`Port ${t}, mode ${r}, PCT min ${e.readFloatLE(6)}, max ${e.readFloatLE(10)}`);break;case c.ModeInformationType.SI:_(`Port ${t}, mode ${r}, SI min ${e.readFloatLE(6)}, max ${e.readFloatLE(10)}`);break;case c.ModeInformationType.SYMBOL:_(`Port ${t}, mode ${r}, SI symbol ${e.slice(6,e.length).toString()}`);break;case c.ModeInformationType.VALUE_FORMAT:const n=e[6],i=["8bit","16bit","32bit","float"][e[7]],o=e[8],s=e[9];_(`Port ${t}, mode ${r}, Value ${n} x ${i}, Decimal format ${o}.${s}`)}}_parsePortAction(e){for(let t=3;t<e.length;t+=2){const r=this._getDeviceByPortId(e[t]);r&&r.finish(e[t+1])}}_parseSensorMessage(e){const t=e[3],r=this._getDeviceByPortId(t);r&&r.receive(e)}}t.LPF2Hub=h},9279:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.Mario=void 0;const s=r(551),a=o(r(4312)),c=r(1227)("movehub");class u extends s.LPF2Hub{static IsMario(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(a.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===a.BLEManufacturerData.MARIO_ID}constructor(e){super(e,t.PortMap,a.HubType.MARIO),c("Discovered Mario")}async connect(){c("Connecting to Mario"),await super.connect(),c("Connect completed")}}t.Mario=u,t.PortMap={}},9556:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.MoveHub=void 0;const a=s(r(3731)),c=r(551),u=o(r(4312)),f=r(1227)("movehub");class l extends c.LPF2Hub{static IsMoveHub(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(u.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===u.BLEManufacturerData.MOVE_HUB_ID}constructor(e){super(e,t.PortMap,u.HubType.MOVE_HUB),f("Discovered Move Hub")}async connect(){f("Connecting to Move Hub"),await super.connect(),f("Connect completed")}_checkFirmware(e){if(1===(0,a.default)("2.0.00.0017",e))throw new Error(`Your Move Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`)}}t.MoveHub=l,t.PortMap={A:0,B:1,C:2,D:3,HUB_LED:50,TILT_SENSOR:58,CURRENT_SENSOR:59,VOLTAGE_SENSOR:60}},7309:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.RemoteControl=void 0;const s=r(551),a=o(r(4312)),c=r(1227)("remotecontrol");class u extends s.LPF2Hub{static IsRemoteControl(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(a.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===a.BLEManufacturerData.REMOTE_CONTROL_ID}constructor(e){super(e,t.PortMap,a.HubType.REMOTE_CONTROL),c("Discovered Powered UP Remote")}async connect(){c("Connecting to Powered UP Remote"),await super.connect(),c("Connect completed")}}t.RemoteControl=u,t.PortMap={LEFT:0,RIGHT:1,HUB_LED:52,VOLTAGE_SENSOR:59,REMOTE_CONTROL_RSSI:60}},8848:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.TechnicMediumHub=void 0;const s=r(551),a=o(r(4312)),c=r(1227)("technicmediumhub");class u extends s.LPF2Hub{static IsTechnicMediumHub(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(a.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===a.BLEManufacturerData.TECHNIC_MEDIUM_HUB_ID}constructor(e){super(e,t.PortMap,a.HubType.TECHNIC_MEDIUM_HUB),c("Discovered Control+ Hub")}async connect(){c("Connecting to Control+ Hub"),await super.connect(),c("Connect completed")}}t.TechnicMediumHub=u,t.PortMap={A:0,B:1,C:2,D:3,HUB_LED:50,CURRENT_SENSOR:59,VOLTAGE_SENSOR:60,ACCELEROMETER:97,GYRO_SENSOR:98,TILT_SENSOR:99}},806:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.TechnicSmallHub=void 0;const s=r(551),a=o(r(4312)),c=r(1227)("hub");class u extends s.LPF2Hub{constructor(e){super(e,t.PortMap,a.HubType.TECHNIC_SMALL_HUB),this._currentPort=59,c("Discovered Spike Essential Hub")}static IsTechnicSmallHub(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(a.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===a.BLEManufacturerData.TECHNIC_SMALL_HUB_ID}async connect(){c("Connecting to Spike Essential Hub"),await super.connect(),c("Connect completed")}}t.TechnicSmallHub=u,t.PortMap={A:0,B:1,HUB_LED:49,CURRENT_SENSOR:59,VOLTAGE_SENSOR:60,ACCELEROMETER:97,GYRO_SENSOR:98,TILT_SENSOR:99}},2426:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.WeDo2SmartHub=void 0;const a=r(6503),c=s(r(4312)),u=r(8593),f=r(1227)("wedo2smarthub");class l extends a.BaseHub{constructor(e){super(e,t.PortMap,c.HubType.WEDO2_SMART_HUB),this._lastTiltX=0,this._lastTiltY=0,f("Discovered WeDo 2.0 Smart Hub")}static IsWeDo2SmartHub(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(c.BLEService.WEDO2_SMART_HUB.replace(/-/g,""))>=0}connect(){return new Promise((async e=>{f("Connecting to WeDo 2.0 Smart Hub"),await super.connect(),await this._bleDevice.discoverCharacteristicsForService(c.BLEService.WEDO2_SMART_HUB),await this._bleDevice.discoverCharacteristicsForService(c.BLEService.WEDO2_SMART_HUB_2),u.isWebBluetooth?(await this._bleDevice.discoverCharacteristicsForService("battery_service"),await this._bleDevice.discoverCharacteristicsForService("device_information")):(await this._bleDevice.discoverCharacteristicsForService(c.BLEService.WEDO2_SMART_HUB_3),await this._bleDevice.discoverCharacteristicsForService(c.BLEService.WEDO2_SMART_HUB_4),await this._bleDevice.discoverCharacteristicsForService(c.BLEService.WEDO2_SMART_HUB_5)),f("Connect completed"),this.emit("connect"),e(),this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.WEDO2_PORT_TYPE,this._parsePortMessage.bind(this)),this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.WEDO2_SENSOR_VALUE,this._parseSensorMessage.bind(this)),this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.WEDO2_BUTTON,this._parseSensorMessage.bind(this)),u.isWebBluetooth?(this._bleDevice.readFromCharacteristic("00002a19-0000-1000-8000-00805f9b34fb",((e,t)=>{t&&this._parseBatteryMessage(t)})),this._bleDevice.subscribeToCharacteristic("00002a19-0000-1000-8000-00805f9b34fb",this._parseHighCurrentAlert.bind(this))):(this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.WEDO2_BATTERY,this._parseBatteryMessage.bind(this)),this._bleDevice.readFromCharacteristic(c.BLECharacteristic.WEDO2_BATTERY,((e,t)=>{t&&this._parseBatteryMessage(t)}))),this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.WEDO2_HIGH_CURRENT_ALERT,this._parseHighCurrentAlert.bind(this)),u.isWebBluetooth?this._bleDevice.readFromCharacteristic("00002a26-0000-1000-8000-00805f9b34fb",((e,t)=>{t&&this._parseFirmwareRevisionString(t)})):this._bleDevice.readFromCharacteristic(c.BLECharacteristic.WEDO2_FIRMWARE_REVISION,((e,t)=>{t&&this._parseFirmwareRevisionString(t)}))}))}shutdown(){return this.send(n.from([0]),c.BLECharacteristic.WEDO2_DISCONNECT)}setName(e){if(e.length>14)throw new Error("Name must be 14 characters or less");return new Promise((t=>{const r=n.from(e,"ascii");return this.send(r,c.BLECharacteristic.WEDO2_NAME_ID),this.send(r,c.BLECharacteristic.WEDO2_NAME_ID),this._name=e,t()}))}send(e,t){return f.enabled&&f(`Sent Message (${this._getCharacteristicNameFromUUID(t)})`,e),this._bleDevice.writeToCharacteristic(t,e)}subscribe(e,t,r){this.send(n.from([1,2,e,t,r,1,0,0,0,0,1]),c.BLECharacteristic.WEDO2_PORT_TYPE_WRITE)}unsubscribe(e,t,r){this.send(n.from([1,2,e,t,r,1,0,0,0,0,0]),c.BLECharacteristic.WEDO2_PORT_TYPE_WRITE)}_getCharacteristicNameFromUUID(e){const t=Object.keys(c.BLECharacteristic);for(let r=0;r<t.length;r++){const n=t[r];if(c.BLECharacteristic[n]===e)return n}return"UNKNOWN"}_parseHighCurrentAlert(e){f("Received Message (WEDO2_HIGH_CURRENT_ALERT)",e)}_parseBatteryMessage(e){f("Received Message (WEDO2_BATTERY)",e);const t=e[0];t!==this._batteryLevel&&(this._batteryLevel=t,this.emit("batteryLevel",{batteryLevel:t}))}_parseFirmwareRevisionString(e){f("Received Message (WEDO2_FIRMWARE_REVISION)",e),this._firmwareVersion=e.toString()}_parsePortMessage(e){f("Received Message (WEDO2_PORT_TYPE)",e);const t=e[0],r=e[1],n=r?e[3]:0;if(1===r){const e=this._createDevice(n,t);this._attachDevice(e)}else if(0===r){const e=this._getDeviceByPortId(t);e&&this._detachDevice(e)}}_parseSensorMessage(e){if(f("Received Message (WEDO2_SENSOR_VALUE)",e),1===e[0])return void this.emit("button",{event:c.ButtonState.PRESSED});if(0===e[0])return void this.emit("button",{event:c.ButtonState.RELEASED});const t=e[1],r=this._getDeviceByPortId(t);r&&r.receive(e)}}t.WeDo2SmartHub=l,t.PortMap={A:1,B:2,CURRENT_SENSOR:3,VOLTAGE_SENSOR:4,PIEZO_BUZZER:5,HUB_LED:6}},389:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});const s=o(r(4312)),a=r(9804),c=r(148),u=r(6503),f=r(5688),l=r(8647),_=r(9279),h=r(9556),d=r(7309),p=r(8848),E=r(2426),O=r(9126),T=r(4499),b=r(5468),M=r(1718),v=r(9539),y=r(6758),R=r(1668),m=r(783),S=r(3677),I=r(7375),A=r(7201),L=r(4772),D=r(6227),C=r(222),N=r(3387),g=r(3652),P=r(6481),B=r(6147),U=r(2826),w=r(2667),H=r(1665),j=r(5922),F=r(3841),W=r(4321),G=r(8425),x=r(2644),V=r(6121),k=r(5917),Y=r(8762),$=r(8036),K=r(9257),z=r(9847),X=r(9045),q=r(2897),Z=r(8593);window.PoweredUP={PoweredUP:a.PoweredUP,BaseHub:u.BaseHub,WeDo2SmartHub:E.WeDo2SmartHub,TechnicMediumHub:p.TechnicMediumHub,Hub:l.Hub,RemoteControl:d.RemoteControl,DuploTrainBase:f.DuploTrainBase,Consts:s,Color:c.Color,ColorDistanceSensor:O.ColorDistanceSensor,Device:b.Device,DuploTrainBaseColorSensor:M.DuploTrainBaseColorSensor,DuploTrainBaseMotor:v.DuploTrainBaseMotor,DuploTrainBaseSpeaker:y.DuploTrainBaseSpeaker,DuploTrainBaseSpeedometer:R.DuploTrainBaseSpeedometer,HubLED:m.HubLED,Light:S.Light,Mario:_.Mario,MediumLinearMotor:I.MediumLinearMotor,MotionSensor:A.MotionSensor,MoveHub:h.MoveHub,MoveHubMediumLinearMotor:L.MoveHubMediumLinearMotor,MoveHubTiltSensor:D.MoveHubTiltSensor,PiezoBuzzer:C.PiezoBuzzer,RemoteControlButton:N.RemoteControlButton,SimpleMediumLinearMotor:g.SimpleMediumLinearMotor,TechnicColorSensor:P.TechnicColorSensor,TechnicDistanceSensor:B.TechnicDistanceSensor,TechnicForceSensor:U.TechnicForceSensor,TechnicMediumHubAccelerometerSensor:W.TechnicMediumHubAccelerometerSensor,TechnicMediumHubGyroSensor:G.TechnicMediumHubGyroSensor,TechnicMediumHubTiltSensor:x.TechnicMediumHubTiltSensor,TechnicSmallAngularMotor:j.TechnicSmallAngularMotor,TechnicMediumAngularMotor:F.TechnicMediumAngularMotor,TechnicLargeAngularMotor:w.TechnicLargeAngularMotor,TechnicLargeLinearMotor:H.TechnicLargeLinearMotor,TechnicXLargeLinearMotor:V.TechnicXLargeLinearMotor,Technic3x3ColorLightMatrix:k.Technic3x3ColorLightMatrix,TiltSensor:Y.TiltSensor,TrainMotor:$.TrainMotor,VoltageSensor:K.VoltageSensor,CurrentSensor:T.CurrentSensor,TachoMotor:z.TachoMotor,AbsoluteMotor:X.AbsoluteMotor,BasicMotor:q.BasicMotor,isWebBluetooth:Z.isWebBluetooth}},9804:function(e,t,r){"use strict";var n=r(8764).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PoweredUP=void 0;const a=r(6165),c=r(5688),u=r(8647),f=r(9279),l=r(9556),_=r(7309),h=r(8848),d=r(2426),p=s(r(4312)),E=r(7187),O=r(1227),T=r(806),b=O("poweredup");class M extends E.EventEmitter{constructor(){super(),this._connectedHubs={},this._discoveryEventHandler=this._discoveryEventHandler.bind(this)}async scan(){try{const e=await navigator.bluetooth.requestDevice({filters:[{services:[p.BLEService.WEDO2_SMART_HUB]},{services:[p.BLEService.LPF2_HUB]}],optionalServices:[p.BLEService.WEDO2_SMART_HUB_2,"battery_service","device_information"]}),t=await e.gatt.connect();return this._discoveryEventHandler.call(this,t),!0}catch(e){return!1}}getHubs(){return Object.values(this._connectedHubs)}getHubByUUID(e){return this._connectedHubs[e]}getHubByPrimaryMACAddress(e){return Object.values(this._connectedHubs).filter((t=>t.primaryMACAddress===e))[0]}getHubsByName(e){return Object.values(this._connectedHubs).filter((t=>t.name===e))}getHubsByType(e){return Object.values(this._connectedHubs).filter((t=>t.type===e))}_determineLPF2HubType(e){return new Promise((t=>{let r=n.alloc(0);e.subscribeToCharacteristic(p.BLECharacteristic.LPF2_ALL,(i=>{for(r=n.concat([r,i]);r[0]<=r.length;){const n=r[0],i=r.slice(0,n);if(r=r.slice(n),1===i[2]&&11===i[3]){switch(i[5]){case p.BLEManufacturerData.REMOTE_CONTROL_ID:t(p.HubType.REMOTE_CONTROL);break;case p.BLEManufacturerData.MOVE_HUB_ID:t(p.HubType.MOVE_HUB);break;case p.BLEManufacturerData.HUB_ID:t(p.HubType.HUB);break;case p.BLEManufacturerData.DUPLO_TRAIN_BASE_ID:t(p.HubType.DUPLO_TRAIN_BASE);break;case p.BLEManufacturerData.TECHNIC_SMALL_HUB_ID:t(p.HubType.TECHNIC_SMALL_HUB);break;case p.BLEManufacturerData.TECHNIC_MEDIUM_HUB_ID:t(p.HubType.TECHNIC_MEDIUM_HUB)}b("Hub type determined")}else b("Stashed in mailbox (LPF2_ALL)",i),e.addToCharacteristicMailbox(p.BLECharacteristic.LPF2_ALL,i)}})),e.writeToCharacteristic(p.BLECharacteristic.LPF2_ALL,n.from([5,0,1,11,5]))}))}async _discoveryEventHandler(e){const t=new a.WebBLEDevice(e);let r,n=p.HubType.UNKNOWN,i=!1;try{await t.discoverCharacteristicsForService(p.BLEService.WEDO2_SMART_HUB),n=p.HubType.WEDO2_SMART_HUB}catch(e){}try{n!==p.HubType.WEDO2_SMART_HUB&&(await t.discoverCharacteristicsForService(p.BLEService.LPF2_HUB),i=!0)}catch(e){}switch(i&&(n=await this._determineLPF2HubType(t)),n){case p.HubType.WEDO2_SMART_HUB:r=new d.WeDo2SmartHub(t);break;case p.HubType.MOVE_HUB:r=new l.MoveHub(t);break;case p.HubType.HUB:r=new u.Hub(t);break;case p.HubType.REMOTE_CONTROL:r=new _.RemoteControl(t);break;case p.HubType.DUPLO_TRAIN_BASE:r=new c.DuploTrainBase(t);break;case p.HubType.TECHNIC_SMALL_HUB:r=new T.TechnicSmallHub(t);break;case p.HubType.TECHNIC_MEDIUM_HUB:r=new h.TechnicMediumHub(t);break;case p.HubType.MARIO:r=new f.Mario(t);break;default:return}t.on("discoverComplete",(()=>{r.on("connect",(()=>{b(`Hub ${r.uuid} connected`),this._connectedHubs[r.uuid]=r})),r.on("disconnect",(()=>{b(`Hub ${r.uuid} disconnected`),delete this._connectedHubs[r.uuid]})),b(`Hub ${r.uuid} discovered`),this.emit("discover",r)}))}}t.PoweredUP=M},8593:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseColor=t.calculateRamp=t.roundAngleToNearest90=t.normalizeAngle=t.decodeMACAddress=t.decodeVersion=t.mapSpeed=t.toBin=t.toHex=t.isWebBluetooth=void 0;const n=r(7187);t.isWebBluetooth=!("undefined"==typeof navigator||!navigator||!navigator.bluetooth),t.toHex=(e,t=2)=>e.toString(16).padStart(t,"0"),t.toBin=(e,t=8)=>e.toString(2).padStart(t,"0"),t.mapSpeed=e=>127===e?127:(e>100?e=100:e<-100&&(e=-100),e),t.decodeVersion=e=>{const t=e.toString(16).padStart(8,"0");return[t[0],t[1],t.substring(2,4),t.substring(4)].join(".")},t.decodeMACAddress=e=>Array.from(e).map((e=>(0,t.toHex)(e,2))).join(":"),t.normalizeAngle=e=>e>=180?e-(e+180)/360*360:e<-180?e+(180-e)/360*360:e,t.roundAngleToNearest90=e=>(e=(0,t.normalizeAngle)(e))<-135?-180:e<-45?-90:e<45?0:e<135?90:-180,t.calculateRamp=(e,t,r,i)=>{const o=new n.EventEmitter,s=Math.abs(r-t);let a=i/s,c=1;a<50&&s>0&&(c=50/a,a=50),t>r&&(c=-c);let u=0;const f=setInterval((()=>{let e=Math.round(t+ ++u*c);(r>t&&e>r||t>r&&e<r)&&(e=r),o.emit("changePower",e),e===r&&(clearInterval(f),o.emit("finished"))}),a);return e.setEventTimer(f),o},t.parseColor=e=>(1!==e&&5!==e||(e+=1),e)},6165:(e,t,r)=>{"use strict";var n=r(8764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.WebBLEDevice=void 0;const i=r(1227),o=r(7187),s=i("bledevice");class a extends o.EventEmitter{constructor(e){super(),this._name="",this._listeners={},this._characteristics={},this._queue=Promise.resolve(),this._mailbox=[],this._connected=!1,this._connecting=!1,this._webBLEServer=e,this._uuid=e.device.id,this._name=e.device.name,e.device.addEventListener("gattserverdisconnected",(()=>{this._connecting=!1,this._connected=!1,this.emit("disconnect")})),setTimeout((()=>{this.emit("discoverComplete")}),2e3)}get uuid(){return this._uuid}get name(){return this._name}get connecting(){return this._connecting}get connected(){return this._connected}connect(){return new Promise((e=>(this._connected=!0,e())))}disconnect(){return new Promise((e=>(this._webBLEServer.device.gatt.disconnect(),this._connected=!1,e())))}async discoverCharacteristicsForService(e){s("Service/characteristic discovery started");const t=await this._webBLEServer.getPrimaryService(e),r=await t.getCharacteristics();for(const e of r)this._characteristics[e.uuid]=e;s("Service/characteristic discovery finished")}subscribeToCharacteristic(e,t){this._listeners[e]&&this._characteristics[e].removeEventListener("characteristicvaluechanged",this._listeners[e]),this._listeners[e]=e=>{const r=n.alloc(e.target.value.buffer.byteLength),i=new Uint8Array(e.target.value.buffer);for(let e=0;e<r.length;e++)r[e]=i[e];return s("Incoming data",r),t(r)},this._characteristics[e].addEventListener("characteristicvaluechanged",this._listeners[e]);const r=Array.from(this._mailbox);this._mailbox=[];for(const e of r)s("Replayed from mailbox (LPF2_ALL)",e),t(e);this._characteristics[e].startNotifications()}addToCharacteristicMailbox(e,t){this._mailbox.push(t)}readFromCharacteristic(e,t){this._characteristics[e].readValue().then((e=>{const r=n.alloc(e.buffer.byteLength),i=new Uint8Array(e.buffer);for(let e=0;e<r.length;e++)r[e]=i[e];t(null,r)}))}writeToCharacteristic(e,t){return this._queue=this._queue.then((()=>this._characteristics[e].writeValueWithoutResponse(t)))}_sanitizeUUID(e){return e.replace(/-/g,"")}}t.WebBLEDevice=a},3731:(e,t,r)=>{"use strict";function n(e,t){const r=c(e),n=c(t),i=r.pop(),o=n.pop(),s=_(r,n);return 0!==s?s:i&&o?_(i.split("."),o.split(".")):i||o?i?-1:1:0}r.r(t),r.d(t,{default:()=>n,validate:()=>i,compare:()=>o,satisfies:()=>s});const i=e=>"string"==typeof e&&/^[v\d]/.test(e)&&a.test(e),o=(e,t,r)=>{p(r);const i=n(e,t);return h[r].includes(i)},s=(e,t)=>{const r=t.match(/^([<>=~^]+)/),n=r?r[1]:"=";if("^"!==n&&"~"!==n)return o(e,t,n);const[i,s,a]=c(e),[u,f,h]=c(t);return 0===l(i,u)&&("^"===n?_([s,a],[f,h])>=0:0===l(s,f)&&l(a,h)>=0)};n.validate=i,n.compare=o,n.sastisfies=s;const a=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,c=e=>{if("string"!=typeof e)throw new TypeError("Invalid argument expected string");const t=e.match(a);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},u=e=>"*"===e||"x"===e||"X"===e,f=e=>{const t=parseInt(e,10);return isNaN(t)?e:t},l=(e,t)=>{if(u(e)||u(t))return 0;const[r,n]=((e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t])(f(e),f(t));return r>n?1:r<n?-1:0},_=(e,t)=>{for(let r=0;r<Math.max(e.length,t.length);r++){const n=l(e[r]||0,t[r]||0);if(0!==n)return n}return 0},h={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]},d=Object.keys(h),p=e=>{if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===d.indexOf(e))throw new Error(`Invalid operator, expected one of ${d.join("|")}`)}}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(389)})();
|
|
2
|
+
(()=>{var e={7526:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],i=t[1];return 3*(r+i)/4-i},t.toByteArray=function(e){var t,r,o=a(e),s=o[0],c=o[1],u=new n(function(e,t,r){return 3*(t+r)/4-r}(0,s,c)),f=0,l=c>0?s-4:s;for(r=0;r<l;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;return 2===c&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[f++]=255&t),1===c&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t),u},t.fromByteArray=function(e){for(var t,i=e.length,n=i%3,o=[],s=16383,a=0,u=i-n;a<u;a+=s)o.push(c(e,a,a+s>u?u:a+s));return 1===n?(t=e[i-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===n&&(t=(e[i-2]<<8)+e[i-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],i=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],i[o.charCodeAt(s)]=s;function a(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 c(e,t,i){for(var n,o,s=[],a=t;a<i;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=n)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},8287:(e,t,r)=>{"use strict";const i=r(7526),n=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=c,t.IS=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|p(e,t);let i=a(r);const n=i.write(e,t);return n!==r&&(i=i.slice(0,n)),i}(e,t);if(ArrayBuffer.isView(e))return function(e){if(X(e,Uint8Array)){const t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return _(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return h(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(X(e,SharedArrayBuffer)||e&&X(e.buffer,SharedArrayBuffer)))return h(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return c.from(i,t,r);const n=function(e){if(c.isBuffer(e)){const t=0|d(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||q(e.length)?a(0):_(e):"Buffer"===e.type&&Array.isArray(e.data)?_(e.data):void 0}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function l(e){return f(e),a(e<0?0:0|d(e))}function _(e){const t=e.length<0?0:0|d(e.length),r=a(t);for(let i=0;i<t;i+=1)r[i]=255&e[i];return r}function h(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let i;return i=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(i,c.prototype),i}function d(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;let n=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(e).length;default:if(n)return i?-1:$(e).length;t=(""+t).toLowerCase(),n=!0}}function E(e,t,r){let i=!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 L(this,t,r);case"utf8":case"utf-8":return g(this,t,r);case"ascii":return A(this,t,r);case"latin1":case"binary":return D(this,t,r);case"base64":return S(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function O(e,t,r){const i=e[t];e[t]=e[r],e[r]=i}function T(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),q(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=c.from(t,i)),c.isBuffer(t))return 0===t.length?-1:b(e,t,r,i,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,i,n){let o,s=1,a=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){let i=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===i?0:o-i)){if(-1===i&&(i=o),o-i+1===c)return i*s}else-1!==i&&(o-=o-i),i=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let i=0;i<c;i++)if(u(e,o+i)!==u(t,i)){r=!1;break}if(r)return o}return-1}function v(e,t,r,i){r=Number(r)||0;const n=e.length-r;i?(i=Number(i))>n&&(i=n):i=n;const o=t.length;let s;for(i>o/2&&(i=o/2),s=0;s<i;++s){const i=parseInt(t.substr(2*s,2),16);if(q(i))return s;e[r+s]=i}return s}function M(e,t,r,i){return z($(t,e.length-r),e,r,i)}function y(e,t,r,i){return z(function(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function R(e,t,r,i){return z(K(t),e,r,i)}function m(e,t,r,i){return z(function(e,t){let r,i,n;const o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),i=r>>8,n=r%256,o.push(n),o.push(i);return o}(t,e.length-r),e,r,i)}function S(e,t,r){return 0===t&&r===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,r))}function g(e,t,r){r=Math.min(e.length,r);const i=[];let n=t;for(;n<r;){const t=e[n];let o=null,s=t>239?4:t>223?3:t>191?2:1;if(n+s<=r){let r,i,a,c;switch(s){case 1:t<128&&(o=t);break;case 2:r=e[n+1],128==(192&r)&&(c=(31&t)<<6|63&r,c>127&&(o=c));break;case 3:r=e[n+1],i=e[n+2],128==(192&r)&&128==(192&i)&&(c=(15&t)<<12|(63&r)<<6|63&i,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=e[n+1],i=e[n+2],a=e[n+3],128==(192&r)&&128==(192&i)&&128==(192&a)&&(c=(15&t)<<18|(63&r)<<12|(63&i)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),n+=s}return function(e){const t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);let r="",i=0;for(;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=I));return r}(i)}c.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(e,t,r){return u(e,t,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(e,t,r){return function(e,t,r){return f(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},c.allocUnsafe=function(e){return l(e)},c.allocUnsafeSlow=function(e){return l(e)},c.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==c.prototype},c.compare=function(e,t){if(X(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),X(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,i=t.length;for(let n=0,o=Math.min(r,i);n<o;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<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(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const i=c.allocUnsafe(t);let n=0;for(r=0;r<e.length;++r){let t=e[r];if(X(t,Uint8Array))n+t.length>i.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(i,n)):Uint8Array.prototype.set.call(i,t,n);else{if(!c.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(i,n)}n+=t.length}return i},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)O(this,t,t+1);return this},c.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)O(this,t,t+3),O(this,t+1,t+2);return this},c.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)O(this,t,t+7),O(this,t+1,t+6),O(this,t+2,t+5),O(this,t+3,t+4);return this},c.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?g(this,0,e):E.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,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(){let e="";const r=t.IS;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(e,t,r,i,n){if(X(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=r)return 0;if(i>=n)return-1;if(t>=r)return 1;if(this===e)return 0;let o=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(t>>>=0);const a=Math.min(o,s),u=this.slice(i,n),f=e.slice(t,r);for(let e=0;e<a;++e)if(u[e]!==f[e]){o=u[e],s=f[e];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return T(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return T(this,e,t,r,!1)},c.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=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===i&&(i="utf8")):(i=r,r=void 0)}const n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return M(this,e,t,r);case"ascii":case"latin1":case"binary":return y(this,e,t,r);case"base64":return R(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function A(e,t,r){let i="";r=Math.min(e.length,r);for(let n=t;n<r;++n)i+=String.fromCharCode(127&e[n]);return i}function D(e,t,r){let i="";r=Math.min(e.length,r);for(let n=t;n<r;++n)i+=String.fromCharCode(e[n]);return i}function L(e,t,r){const i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);let n="";for(let i=t;i<r;++i)n+=Z[e[i]];return n}function C(e,t,r){const i=e.slice(t,r);let n="";for(let e=0;e<i.length-1;e+=2)n+=String.fromCharCode(i[e]+256*i[e+1]);return n}function P(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 N(e,t,r,i,n,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function B(e,t,r,i,n){x(t,i,n,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function w(e,t,r,i,n){x(t,i,n,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o>>=8,e[r+6]=o,o>>=8,e[r+5]=o,o>>=8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function U(e,t,r,i,n,o){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(e,t,r,i,o){return t=+t,r>>>=0,o||U(e,0,r,4),n.write(e,t,r,i,23,4),r+4}function j(e,t,r,i,o){return t=+t,r>>>=0,o||U(e,0,r,8),n.write(e,t,r,i,52,8),r+8}c.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);const i=this.subarray(e,t);return Object.setPrototypeOf(i,c.prototype),i},c.prototype.readUintLE=c.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||P(e,t,this.length);let i=this[e],n=1,o=0;for(;++o<t&&(n*=256);)i+=this[e+o]*n;return i},c.prototype.readUintBE=c.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||P(e,t,this.length);let i=this[e+--t],n=1;for(;t>0&&(n*=256);)i+=this[e+--t]*n;return i},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=Q((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||k(e,this.length-8);const i=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,n=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(i)+(BigInt(n)<<BigInt(32))})),c.prototype.readBigUInt64BE=Q((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||k(e,this.length-8);const i=t*2**24+65536*this[++e]+256*this[++e]+this[++e],n=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(i)<<BigInt(32))+BigInt(n)})),c.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||P(e,t,this.length);let i=this[e],n=1,o=0;for(;++o<t&&(n*=256);)i+=this[e+o]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*t)),i},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||P(e,t,this.length);let i=t,n=1,o=this[e+--i];for(;i>0&&(n*=256);)o+=this[e+--i]*n;return n*=128,o>=n&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||P(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||P(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||P(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 e>>>=0,t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=Q((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||k(e,this.length-8);const i=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),c.prototype.readBigInt64BE=Q((function(e){V(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||k(e,this.length-8);const i=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),c.prototype.readFloatLE=function(e,t){return e>>>=0,t||P(e,4,this.length),n.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||P(e,4,this.length),n.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||P(e,8,this.length),n.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||P(e,8,this.length),n.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,i){e=+e,t>>>=0,r>>>=0,i||N(this,e,t,r,Math.pow(2,8*r)-1,0);let n=1,o=0;for(this[t]=255&e;++o<r&&(n*=256);)this[t+o]=e/n&255;return t+r},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,t,r,i){e=+e,t>>>=0,r>>>=0,i||N(this,e,t,r,Math.pow(2,8*r)-1,0);let n=r-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=Q((function(e,t=0){return B(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=Q((function(e,t=0){return w(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t>>>=0,!i){const i=Math.pow(2,8*r-1);N(this,e,t,r,i-1,-i)}let n=0,o=1,s=0;for(this[t]=255&e;++n<r&&(o*=256);)e<0&&0===s&&0!==this[t+n-1]&&(s=1),this[t+n]=(e/o|0)-s&255;return t+r},c.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t>>>=0,!i){const i=Math.pow(2,8*r-1);N(this,e,t,r,i-1,-i)}let n=r-1,o=1,s=0;for(this[t+n]=255&e;--n>=0&&(o*=256);)e<0&&0===s&&0!==this[t+n+1]&&(s=1),this[t+n]=(e/o|0)-s&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,1,127,-128),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||N(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=Q((function(e,t=0){return B(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=Q((function(e,t=0){return w(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(e,t,r){return H(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return H(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return j(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return j(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,i){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===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("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);const n=i-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,i):Uint8Array.prototype.set.call(e,this.subarray(r,i),t),n},c.prototype.fill=function(e,t,r,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){const t=e.charCodeAt(0);("utf8"===i&&t<128||"latin1"===i)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let n;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(n=t;n<r;++n)this[n]=e;else{const o=c.isBuffer(e)?e:c.from(e,i),s=o.length;if(0===s)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(n=0;n<r-t;++n)this[n+t]=o[n%s]}return this};const F={};function W(e,t,r){F[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function G(e){let t="",r=e.length;const i="-"===e[0]?1:0;for(;r>=i+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function x(e,t,r,i,n,o){if(e>r||e<t){const i="bigint"==typeof t?"n":"";let n;throw n=o>3?0===t||t===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(o+1)}${i}`:`>= -(2${i} ** ${8*(o+1)-1}${i}) and < 2 ** ${8*(o+1)-1}${i}`:`>= ${t}${i} and <= ${r}${i}`,new F.ERR_OUT_OF_RANGE("value",n,e)}!function(e,t,r){V(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||k(t,e.length-(r+1))}(i,n,o)}function V(e,t){if("number"!=typeof e)throw new F.ERR_INVALID_ARG_TYPE(t,"number",e)}function k(e,t,r){if(Math.floor(e)!==e)throw V(e,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}W("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),W("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),W("ERR_OUT_OF_RANGE",(function(e,t,r){let i=`The value of "${e}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=G(String(r)):"bigint"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=G(n)),n+="n"),i+=` It must be ${t}. Received ${n}`,i}),RangeError);const Y=/[^+/0-9A-Za-z-_]/g;function $(e,t){let r;t=t||1/0;const i=e.length;let n=null;const o=[];for(let s=0;s<i;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(t-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.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;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function K(e){return i.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(Y,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function z(e,t,r,i){let n;for(n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function q(e){return e!=e}const Z=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const i=16*r;for(let n=0;n<16;++n)t[i+n]=e[r]+e[n]}return t}();function Q(e){return"undefined"==typeof BigInt?J:e}function J(){throw new Error("BigInt not supported")}},8385:(e,t,r)=>{"use strict";r.r(t),r.d(t,{compare:()=>f,compareVersions:()=>u,satisfies:()=>d,validate:()=>p,validateStrict:()=>E});const i=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,n=e=>{if("string"!=typeof e)throw new TypeError("Invalid argument expected string");const t=e.match(i);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},o=e=>"*"===e||"x"===e||"X"===e,s=e=>{const t=parseInt(e,10);return isNaN(t)?e:t},a=(e,t)=>{if(o(e)||o(t))return 0;const[r,i]=((e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t])(s(e),s(t));return r>i?1:r<i?-1:0},c=(e,t)=>{for(let r=0;r<Math.max(e.length,t.length);r++){const i=a(e[r]||"0",t[r]||"0");if(0!==i)return i}return 0},u=(e,t)=>{const r=n(e),i=n(t),o=r.pop(),s=i.pop(),a=c(r,i);return 0!==a?a:o&&s?c(o.split("."),s.split(".")):o||s?o?-1:1:0},f=(e,t,r)=>{h(r);const i=u(e,t);return l[r].includes(i)},l={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},_=Object.keys(l),h=e=>{if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===_.indexOf(e))throw new Error(`Invalid operator, expected one of ${_.join("|")}`)},d=(e,t)=>{if((t=t.replace(/([><=]+)\s+/g,"$1")).includes("||"))return t.split("||").some((t=>d(e,t)));if(t.includes(" - ")){const[r,i]=t.split(" - ",2);return d(e,`>=${r} <=${i}`)}if(t.includes(" "))return t.trim().replace(/\s{2,}/g," ").split(" ").every((t=>d(e,t)));const r=t.match(/^([<>=~^]+)/),i=r?r[1]:"=";if("^"!==i&&"~"!==i)return f(e,t,i);const[o,s,a,,u]=n(e),[l,_,h,,p]=n(t),E=[o,s,a],O=[l,null!=_?_:"x",null!=h?h:"x"];if(p){if(!u)return!1;if(0!==c(E,O))return!1;if(-1===c(u.split("."),p.split(".")))return!1}const T=O.findIndex((e=>"0"!==e))+1,b="~"===i?2:T>1?T:1;return 0===c(E.slice(0,b),O.slice(0,b))&&-1!==c(E.slice(b),O.slice(b))},p=e=>"string"==typeof e&&/^[v\d]/.test(e)&&i.test(e),E=e=>"string"==typeof e&&/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/.test(e)},7833:(e,t,r)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let i=0,n=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(i++,"%c"===e&&(n=i))})),t.splice(n,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(736)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},736:(e,t,r)=>{e.exports=function(e){function t(e){let r,n,o,s=null;function a(...e){if(!a.enabled)return;const i=a,n=Number(new Date),o=n-(r||n);i.diff=o,i.prev=r,i.curr=n,r=n,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,n)=>{if("%%"===r)return"%";s++;const o=t.formatters[n];if("function"==typeof o){const t=e[s];r=o.call(i,t),e.splice(s,1),s--}return r})),t.formatArgs.call(i,e),(i.log||t.log).apply(i,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=i,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(n!==t.namespaces&&(n=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function i(e,r){const i=t(this.namespace+(void 0===r?":":r)+e);return i.log=this.log,i}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const i=("string"==typeof e?e:"").split(/[\s,]+/),n=i.length;for(r=0;r<n;r++)i[r]&&("-"===(e=i[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,i;for(r=0,i=t.skips.length;r<i;r++)if(t.skips[r].test(e))return!1;for(r=0,i=t.names.length;r<i;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(6585),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},7007:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,i){function n(r){e.removeListener(t,o),i(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}p(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&p(e,"error",t,{once:!0})}(e,n)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,i){var n,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(n=c(e))>0&&s.length>n&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=f.bind(i);return n.listener=r,i.wrapFn=n,n}function _(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):d(n,n.length)}function h(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function p(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function n(o){i.once&&e.removeEventListener(t,n),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else{var u=c.length,f=d(c,u);for(r=0;r<u;++r)i(f[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,l(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,l(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,i,n,o,s;if(a(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,n=o;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,o=Object.keys(r);for(i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return _(this,e,!0)},o.prototype.rawListeners=function(e){return _(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},o.prototype.listenerCount=h,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},251:(e,t)=>{t.read=function(e,t,r,i,n){var o,s,a=8*n-i-1,c=(1<<a)-1,u=c>>1,f=-7,l=r?n-1:0,_=r?-1:1,h=e[t+l];for(l+=_,o=h&(1<<-f)-1,h>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=_,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=i;f>0;s=256*s+e[t+l],l+=_,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,i),o-=u}return(h?-1:1)*s*Math.pow(2,o-i)},t.write=function(e,t,r,i,n,o){var s,a,c,u=8*o-n-1,f=(1<<u)-1,l=f>>1,_=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:o-1,d=i?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+l>=1?_/c:_*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*c-1)*Math.pow(2,n),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,n),s=0));n>=8;e[r+h]=255&a,h+=d,a/=256,n-=8);for(s=s<<n|a,u+=n;u>0;e[r+h]=255&s,h+=d,s/=256,u-=8);e[r+h-d]|=128*p}},6585:e=>{var t=1e3,r=60*t,i=60*r,n=24*i,o=7*n;function s(e,t,r,i){var n=t>=1.5*r;return Math.round(e/r)+" "+i+(n?"s":"")}e.exports=function(e,a){a=a||{};var c,u,f=typeof e;if("string"===f&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(s){var a=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===f&&isFinite(e))return a.long?(c=e,(u=Math.abs(c))>=n?s(c,u,n,"day"):u>=i?s(c,u,i,"hour"):u>=r?s(c,u,r,"minute"):u>=t?s(c,u,t,"second"):c+" ms"):function(e){var o=Math.abs(e);return o>=n?Math.round(e/n)+"d":o>=i?Math.round(e/i)+"h":o>=r?Math.round(e/r)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},8359:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Color=void 0;const s=o(r(8066));t.Color=class{constructor(e,t){this._brightness=100,this._color=e,this._brightness=t||100}toValue(){return this._color===s.Color.NONE?this._color:this._color+(Math.round(this._brightness/10)<<4)}}},8066:(e,t)=>{"use strict";var r,i,n,o,s,a,c,u,f,l,_,h,d,p,E,O,T,b,v,M,y,R,m,S,g,I,A;Object.defineProperty(t,"__esModule",{value:!0}),t.MarioColor=t.MarioPantsType=t.PortInputFormatSetupSubCommand=t.ModeInformationType=t.HWNetworkSubFamily=t.HWNetworkFamily=t.HWNetWorkCommandType=t.ErrorCode=t.IOTypeID=t.Event=t.AlertPayload=t.AlertOperation=t.AlertType=t.ActionType=t.HubPropertyPayload=t.HubPropertyOperation=t.HubPropertyReference=t.MessageType=t.BLECharacteristic=t.BLEService=t.BLEManufacturerData=t.DuploTrainBaseSound=t.BrakingStyle=t.ButtonState=t.ColorNames=t.Color=t.DeviceTypeNames=t.DeviceType=t.HubTypeNames=t.HubType=void 0,function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEDO2_SMART_HUB=1]="WEDO2_SMART_HUB",e[e.MOVE_HUB=2]="MOVE_HUB",e[e.HUB=3]="HUB",e[e.REMOTE_CONTROL=4]="REMOTE_CONTROL",e[e.DUPLO_TRAIN_BASE=5]="DUPLO_TRAIN_BASE",e[e.TECHNIC_MEDIUM_HUB=6]="TECHNIC_MEDIUM_HUB",e[e.MARIO=7]="MARIO",e[e.TECHNIC_SMALL_HUB=8]="TECHNIC_SMALL_HUB"}(r||(t.HubType=r={})),t.HubTypeNames=r,function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.SIMPLE_MEDIUM_LINEAR_MOTOR=1]="SIMPLE_MEDIUM_LINEAR_MOTOR",e[e.TRAIN_MOTOR=2]="TRAIN_MOTOR",e[e.LIGHT=8]="LIGHT",e[e.VOLTAGE_SENSOR=20]="VOLTAGE_SENSOR",e[e.CURRENT_SENSOR=21]="CURRENT_SENSOR",e[e.PIEZO_BUZZER=22]="PIEZO_BUZZER",e[e.HUB_LED=23]="HUB_LED",e[e.TILT_SENSOR=34]="TILT_SENSOR",e[e.MOTION_SENSOR=35]="MOTION_SENSOR",e[e.COLOR_DISTANCE_SENSOR=37]="COLOR_DISTANCE_SENSOR",e[e.MEDIUM_LINEAR_MOTOR=38]="MEDIUM_LINEAR_MOTOR",e[e.MOVE_HUB_MEDIUM_LINEAR_MOTOR=39]="MOVE_HUB_MEDIUM_LINEAR_MOTOR",e[e.MOVE_HUB_TILT_SENSOR=40]="MOVE_HUB_TILT_SENSOR",e[e.DUPLO_TRAIN_BASE_MOTOR=41]="DUPLO_TRAIN_BASE_MOTOR",e[e.DUPLO_TRAIN_BASE_SPEAKER=42]="DUPLO_TRAIN_BASE_SPEAKER",e[e.DUPLO_TRAIN_BASE_COLOR_SENSOR=43]="DUPLO_TRAIN_BASE_COLOR_SENSOR",e[e.DUPLO_TRAIN_BASE_SPEEDOMETER=44]="DUPLO_TRAIN_BASE_SPEEDOMETER",e[e.TECHNIC_LARGE_LINEAR_MOTOR=46]="TECHNIC_LARGE_LINEAR_MOTOR",e[e.TECHNIC_XLARGE_LINEAR_MOTOR=47]="TECHNIC_XLARGE_LINEAR_MOTOR",e[e.TECHNIC_MEDIUM_ANGULAR_MOTOR=48]="TECHNIC_MEDIUM_ANGULAR_MOTOR",e[e.TECHNIC_LARGE_ANGULAR_MOTOR=49]="TECHNIC_LARGE_ANGULAR_MOTOR",e[e.TECHNIC_MEDIUM_HUB_GEST_SENSOR=54]="TECHNIC_MEDIUM_HUB_GEST_SENSOR",e[e.REMOTE_CONTROL_BUTTON=55]="REMOTE_CONTROL_BUTTON",e[e.REMOTE_CONTROL_RSSI=56]="REMOTE_CONTROL_RSSI",e[e.TECHNIC_MEDIUM_HUB_ACCELEROMETER=57]="TECHNIC_MEDIUM_HUB_ACCELEROMETER",e[e.TECHNIC_MEDIUM_HUB_GYRO_SENSOR=58]="TECHNIC_MEDIUM_HUB_GYRO_SENSOR",e[e.TECHNIC_MEDIUM_HUB_TILT_SENSOR=59]="TECHNIC_MEDIUM_HUB_TILT_SENSOR",e[e.TECHNIC_MEDIUM_HUB_TEMPERATURE_SENSOR=60]="TECHNIC_MEDIUM_HUB_TEMPERATURE_SENSOR",e[e.TECHNIC_COLOR_SENSOR=61]="TECHNIC_COLOR_SENSOR",e[e.TECHNIC_DISTANCE_SENSOR=62]="TECHNIC_DISTANCE_SENSOR",e[e.TECHNIC_FORCE_SENSOR=63]="TECHNIC_FORCE_SENSOR",e[e.TECHNIC_3X3_COLOR_LIGHT_MATRIX=64]="TECHNIC_3X3_COLOR_LIGHT_MATRIX",e[e.TECHNIC_SMALL_ANGULAR_MOTOR=65]="TECHNIC_SMALL_ANGULAR_MOTOR",e[e.MARIO_ACCELEROMETER=71]="MARIO_ACCELEROMETER",e[e.MARIO_BARCODE_SENSOR=73]="MARIO_BARCODE_SENSOR",e[e.MARIO_PANTS_SENSOR=74]="MARIO_PANTS_SENSOR",e[e.TECHNIC_MEDIUM_ANGULAR_MOTOR_GREY=75]="TECHNIC_MEDIUM_ANGULAR_MOTOR_GREY",e[e.TECHNIC_LARGE_ANGULAR_MOTOR_GREY=76]="TECHNIC_LARGE_ANGULAR_MOTOR_GREY"}(i||(t.DeviceType=i={})),t.DeviceTypeNames=i,function(e){e[e.BLACK=0]="BLACK",e[e.PINK=1]="PINK",e[e.PURPLE=2]="PURPLE",e[e.BLUE=3]="BLUE",e[e.LIGHT_BLUE=4]="LIGHT_BLUE",e[e.CYAN=5]="CYAN",e[e.GREEN=6]="GREEN",e[e.YELLOW=7]="YELLOW",e[e.ORANGE=8]="ORANGE",e[e.RED=9]="RED",e[e.WHITE=10]="WHITE",e[e.NONE=255]="NONE"}(n||(t.Color=n={})),t.ColorNames=n,function(e){e[e.PRESSED=2]="PRESSED",e[e.RELEASED=0]="RELEASED",e[e.UP=1]="UP",e[e.DOWN=255]="DOWN",e[e.STOP=127]="STOP"}(o||(t.ButtonState=o={})),function(e){e[e.FLOAT=0]="FLOAT",e[e.HOLD=126]="HOLD",e[e.BRAKE=127]="BRAKE"}(s||(t.BrakingStyle=s={})),function(e){e[e.BRAKE=3]="BRAKE",e[e.STATION_DEPARTURE=5]="STATION_DEPARTURE",e[e.WATER_REFILL=7]="WATER_REFILL",e[e.HORN=9]="HORN",e[e.STEAM=10]="STEAM"}(a||(t.DuploTrainBaseSound=a={})),function(e){e[e.DUPLO_TRAIN_BASE_ID=32]="DUPLO_TRAIN_BASE_ID",e[e.MOVE_HUB_ID=64]="MOVE_HUB_ID",e[e.HUB_ID=65]="HUB_ID",e[e.REMOTE_CONTROL_ID=66]="REMOTE_CONTROL_ID",e[e.MARIO_ID=67]="MARIO_ID",e[e.TECHNIC_MEDIUM_HUB_ID=128]="TECHNIC_MEDIUM_HUB_ID",e[e.TECHNIC_SMALL_HUB_ID=131]="TECHNIC_SMALL_HUB_ID"}(c||(t.BLEManufacturerData=c={})),function(e){e.WEDO2_SMART_HUB="00001523-1212-efde-1523-785feabcd123",e.WEDO2_SMART_HUB_2="00004f0e-1212-efde-1523-785feabcd123",e.WEDO2_SMART_HUB_3="2a19",e.WEDO2_SMART_HUB_4="180f",e.WEDO2_SMART_HUB_5="180a",e.LPF2_HUB="00001623-1212-efde-1623-785feabcd123"}(u||(t.BLEService=u={})),function(e){e.WEDO2_BATTERY="2a19",e.WEDO2_FIRMWARE_REVISION="2a26",e.WEDO2_BUTTON="00001526-1212-efde-1523-785feabcd123",e.WEDO2_PORT_TYPE="00001527-1212-efde-1523-785feabcd123",e.WEDO2_LOW_VOLTAGE_ALERT="00001528-1212-efde-1523-785feabcd123",e.WEDO2_HIGH_CURRENT_ALERT="00001529-1212-efde-1523-785feabcd123",e.WEDO2_LOW_SIGNAL_ALERT="0000152a-1212-efde-1523-785feabcd123",e.WEDO2_DISCONNECT="0000152b-1212-efde-1523-785feabcd123",e.WEDO2_SENSOR_VALUE="00001560-1212-efde-1523-785feabcd123",e.WEDO2_VALUE_FORMAT="00001561-1212-efde-1523-785feabcd123",e.WEDO2_PORT_TYPE_WRITE="00001563-1212-efde-1523-785feabcd123",e.WEDO2_MOTOR_VALUE_WRITE="00001565-1212-efde-1523-785feabcd123",e.WEDO2_NAME_ID="00001524-1212-efde-1523-785feabcd123",e.LPF2_ALL="00001624-1212-efde-1623-785feabcd123"}(f||(t.BLECharacteristic=f={})),function(e){e[e.HUB_PROPERTIES=1]="HUB_PROPERTIES",e[e.HUB_ACTIONS=2]="HUB_ACTIONS",e[e.HUB_ALERTS=3]="HUB_ALERTS",e[e.HUB_ATTACHED_IO=4]="HUB_ATTACHED_IO",e[e.GENERIC_ERROR_MESSAGES=5]="GENERIC_ERROR_MESSAGES",e[e.HW_NETWORK_COMMANDS=8]="HW_NETWORK_COMMANDS",e[e.FW_UPDATE_GO_INTO_BOOT_MODE=16]="FW_UPDATE_GO_INTO_BOOT_MODE",e[e.FW_UPDATE_LOCK_MEMORY=17]="FW_UPDATE_LOCK_MEMORY",e[e.FW_UPDATE_LOCK_STATUS_REQUEST=18]="FW_UPDATE_LOCK_STATUS_REQUEST",e[e.FW_LOCK_STATUS=19]="FW_LOCK_STATUS",e[e.PORT_INFORMATION_REQUEST=33]="PORT_INFORMATION_REQUEST",e[e.PORT_MODE_INFORMATION_REQUEST=34]="PORT_MODE_INFORMATION_REQUEST",e[e.PORT_INPUT_FORMAT_SETUP_SINGLE=65]="PORT_INPUT_FORMAT_SETUP_SINGLE",e[e.PORT_INPUT_FORMAT_SETUP_COMBINEDMODE=66]="PORT_INPUT_FORMAT_SETUP_COMBINEDMODE",e[e.PORT_INFORMATION=67]="PORT_INFORMATION",e[e.PORT_MODE_INFORMATION=68]="PORT_MODE_INFORMATION",e[e.PORT_VALUE_SINGLE=69]="PORT_VALUE_SINGLE",e[e.PORT_VALUE_COMBINEDMODE=70]="PORT_VALUE_COMBINEDMODE",e[e.PORT_INPUT_FORMAT_SINGLE=71]="PORT_INPUT_FORMAT_SINGLE",e[e.PORT_INPUT_FORMAT_COMBINEDMODE=72]="PORT_INPUT_FORMAT_COMBINEDMODE",e[e.VIRTUAL_PORT_SETUP=97]="VIRTUAL_PORT_SETUP",e[e.PORT_OUTPUT_COMMAND=129]="PORT_OUTPUT_COMMAND",e[e.PORT_OUTPUT_COMMAND_FEEDBACK=130]="PORT_OUTPUT_COMMAND_FEEDBACK"}(l||(t.MessageType=l={})),function(e){e[e.ADVERTISING_NAME=1]="ADVERTISING_NAME",e[e.BUTTON=2]="BUTTON",e[e.FW_VERSION=3]="FW_VERSION",e[e.HW_VERSION=4]="HW_VERSION",e[e.RSSI=5]="RSSI",e[e.BATTERY_VOLTAGE=6]="BATTERY_VOLTAGE",e[e.BATTERY_TYPE=7]="BATTERY_TYPE",e[e.MANUFACTURER_NAME=8]="MANUFACTURER_NAME",e[e.RADIO_FIRMWARE_VERSION=9]="RADIO_FIRMWARE_VERSION",e[e.LEGO_WIRELESS_PROTOCOL_VERSION=10]="LEGO_WIRELESS_PROTOCOL_VERSION",e[e.SYSTEM_TYPE_ID=11]="SYSTEM_TYPE_ID",e[e.HW_NETWORK_ID=12]="HW_NETWORK_ID",e[e.PRIMARY_MAC_ADDRESS=13]="PRIMARY_MAC_ADDRESS",e[e.SECONDARY_MAC_ADDRESS=14]="SECONDARY_MAC_ADDRESS",e[e.HARDWARE_NETWORK_FAMILY=15]="HARDWARE_NETWORK_FAMILY"}(_||(t.HubPropertyReference=_={})),function(e){e[e.SET_DOWNSTREAM=1]="SET_DOWNSTREAM",e[e.ENABLE_UPDATES_DOWNSTREAM=2]="ENABLE_UPDATES_DOWNSTREAM",e[e.DISABLE_UPDATES_DOWNSTREAM=3]="DISABLE_UPDATES_DOWNSTREAM",e[e.RESET_DOWNSTREAM=4]="RESET_DOWNSTREAM",e[e.REQUEST_UPDATE_DOWNSTREAM=5]="REQUEST_UPDATE_DOWNSTREAM",e[e.UPDATE_UPSTREAM=6]="UPDATE_UPSTREAM"}(h||(t.HubPropertyOperation=h={})),function(e){e[e.ADVERTISING_NAME=1]="ADVERTISING_NAME",e[e.BUTTON_STATE=2]="BUTTON_STATE",e[e.FW_VERSION=3]="FW_VERSION",e[e.HW_VERSION=4]="HW_VERSION",e[e.RSSI=5]="RSSI",e[e.BATTERY_VOLTAGE=6]="BATTERY_VOLTAGE",e[e.BATTERY_TYPE=7]="BATTERY_TYPE",e[e.MANUFACTURER_NAME=8]="MANUFACTURER_NAME",e[e.RADIO_FIRMWARE_VERSION=9]="RADIO_FIRMWARE_VERSION",e[e.LWP_PROTOCOL_VERSION=10]="LWP_PROTOCOL_VERSION",e[e.SYSTEM_TYPE_ID=11]="SYSTEM_TYPE_ID",e[e.HW_NETWORK_ID=12]="HW_NETWORK_ID",e[e.PRIMARY_MAC_ADDRESS=13]="PRIMARY_MAC_ADDRESS",e[e.SECONDARY_MAC_ADDRESS=14]="SECONDARY_MAC_ADDRESS",e[e.HW_NETWORK_FAMILY=15]="HW_NETWORK_FAMILY"}(d||(t.HubPropertyPayload=d={})),function(e){e[e.SWITCH_OFF_HUB=1]="SWITCH_OFF_HUB",e[e.DISCONNECT=2]="DISCONNECT",e[e.VCC_PORT_CONTROL_ON=3]="VCC_PORT_CONTROL_ON",e[e.VCC_PORT_CONTROL_OFF=4]="VCC_PORT_CONTROL_OFF",e[e.ACTIVATE_BUSY_INDICATION=5]="ACTIVATE_BUSY_INDICATION",e[e.RESET_BUSY_INDICATION=6]="RESET_BUSY_INDICATION",e[e.SHUTDOWN=47]="SHUTDOWN",e[e.HUB_WILL_SWITCH_OFF=48]="HUB_WILL_SWITCH_OFF",e[e.HUB_WILL_DISCONNECT=49]="HUB_WILL_DISCONNECT",e[e.HUB_WILL_GO_INTO_BOOT_MODE=50]="HUB_WILL_GO_INTO_BOOT_MODE"}(p||(t.ActionType=p={})),function(e){e[e.LOW_VOLTAGE=1]="LOW_VOLTAGE",e[e.HIGH_CURRENT=2]="HIGH_CURRENT",e[e.LOW_SIGNAL_STRENGTH=3]="LOW_SIGNAL_STRENGTH",e[e.OVER_POWER_CONDITION=4]="OVER_POWER_CONDITION"}(E||(t.AlertType=E={})),function(e){e[e.LOW_VOLTAGE=1]="LOW_VOLTAGE",e[e.HIGH_CURRENT=2]="HIGH_CURRENT",e[e.LOW_SIGNAL_STRENGTH=3]="LOW_SIGNAL_STRENGTH",e[e.OVER_POWER_CONDITION=4]="OVER_POWER_CONDITION"}(O||(t.AlertOperation=O={})),function(e){e[e.STATUS_OK=0]="STATUS_OK",e[e.ALERT=255]="ALERT"}(T||(t.AlertPayload=T={})),function(e){e[e.DETACHED_IO=0]="DETACHED_IO",e[e.ATTACHED_IO=1]="ATTACHED_IO",e[e.ATTACHED_VIRTUAL_IO=2]="ATTACHED_VIRTUAL_IO"}(b||(t.Event=b={})),function(e){e[e.MOTOR=1]="MOTOR",e[e.SYSTEM_TRAIN_MOTOR=2]="SYSTEM_TRAIN_MOTOR",e[e.BUTTON=5]="BUTTON",e[e.LED_LIGHT=8]="LED_LIGHT",e[e.VOLTAGE=20]="VOLTAGE",e[e.CURRENT=21]="CURRENT",e[e.PIEZO_TONE_SOUND=22]="PIEZO_TONE_SOUND",e[e.RGB_LIGHT=23]="RGB_LIGHT",e[e.EXTERNAL_TILT_SENSOR=34]="EXTERNAL_TILT_SENSOR",e[e.MOTION_SENSOR=35]="MOTION_SENSOR",e[e.VISION_SENSOR=37]="VISION_SENSOR",e[e.EXTERNAL_MOTOR=38]="EXTERNAL_MOTOR",e[e.INTERNAL_MOTOR=39]="INTERNAL_MOTOR",e[e.INTERNAL_TILT=40]="INTERNAL_TILT"}(v||(t.IOTypeID=v={})),function(e){e[e.ACK=1]="ACK",e[e.MACK=2]="MACK",e[e.BUFFER_OVERFLOW=3]="BUFFER_OVERFLOW",e[e.TIMEOUT=4]="TIMEOUT",e[e.COMMAND_NOT_RECOGNIZED=5]="COMMAND_NOT_RECOGNIZED",e[e.INVALID_USE=6]="INVALID_USE",e[e.OVERCURRENT=7]="OVERCURRENT",e[e.INTERNAL_ERROR=8]="INTERNAL_ERROR"}(M||(t.ErrorCode=M={})),function(e){e[e.CONNECTION_REQUEST=2]="CONNECTION_REQUEST",e[e.FAMILY_REQUEST=3]="FAMILY_REQUEST",e[e.FAMILY_SET=4]="FAMILY_SET",e[e.JOIN_DENIED=5]="JOIN_DENIED",e[e.GET_FAMILY=6]="GET_FAMILY",e[e.FAMILY=7]="FAMILY",e[e.GET_SUBFAMILY=8]="GET_SUBFAMILY",e[e.SUBFAMILY=9]="SUBFAMILY",e[e.SUBFAMILY_SET=10]="SUBFAMILY_SET",e[e.GET_EXTENDED_FAMILY=11]="GET_EXTENDED_FAMILY",e[e.EXTENDED_FAMILY=12]="EXTENDED_FAMILY",e[e.EXTENDED_FAMILY_SET=13]="EXTENDED_FAMILY_SET",e[e.RESET_LONG_PRESS_TIMING=14]="RESET_LONG_PRESS_TIMING"}(y||(t.HWNetWorkCommandType=y={})),function(e){e[e.GREEN=1]="GREEN",e[e.YELLOW=2]="YELLOW",e[e.RED=3]="RED",e[e.BLUE=4]="BLUE",e[e.PURPLE=5]="PURPLE",e[e.LIGHT_BLUE=6]="LIGHT_BLUE",e[e.TEAL=7]="TEAL",e[e.PINK=8]="PINK",e[e.WHITE=0]="WHITE"}(R||(t.HWNetworkFamily=R={})),function(e){e[e.ONE_FLASH=1]="ONE_FLASH",e[e.TWO_FLASHES=2]="TWO_FLASHES",e[e.THREE_FLASHES=3]="THREE_FLASHES",e[e.FOUR_FLASHES=4]="FOUR_FLASHES",e[e.FIVE_FLASHES=5]="FIVE_FLASHES",e[e.SIX_FLASHES=6]="SIX_FLASHES",e[e.SEVEN_FLASHES=7]="SEVEN_FLASHES"}(m||(t.HWNetworkSubFamily=m={})),function(e){e[e.NAME=0]="NAME",e[e.RAW=1]="RAW",e[e.PCT=2]="PCT",e[e.SI=3]="SI",e[e.SYMBOL=4]="SYMBOL",e[e.MAPPING=5]="MAPPING",e[e.USED_INTERNALLY=6]="USED_INTERNALLY",e[e.MOTOR_BIAS=7]="MOTOR_BIAS",e[e.CAPABILITY_BITS=8]="CAPABILITY_BITS",e[e.VALUE_FORMAT=128]="VALUE_FORMAT"}(S||(t.ModeInformationType=S={})),function(e){e[e.SET_MODEANDDATASET_COMBINATIONS=1]="SET_MODEANDDATASET_COMBINATIONS",e[e.LOCK_LPF2_DEVICE_FOR_SETUP=2]="LOCK_LPF2_DEVICE_FOR_SETUP",e[e.UNLOCKANDSTARTWITHMULTIUPDATEENABLED=3]="UNLOCKANDSTARTWITHMULTIUPDATEENABLED",e[e.UNLOCKANDSTARTWITHMULTIUPDATEDISABLED=4]="UNLOCKANDSTARTWITHMULTIUPDATEDISABLED",e[e.NOT_USED=5]="NOT_USED",e[e.RESET_SENSOR=6]="RESET_SENSOR"}(g||(t.PortInputFormatSetupSubCommand=g={})),function(e){e[e.NONE=0]="NONE",e[e.PROPELLER=6]="PROPELLER",e[e.CAT=17]="CAT",e[e.FIRE=18]="FIRE",e[e.NORMAL=33]="NORMAL",e[e.BUILDER=34]="BUILDER"}(I||(t.MarioPantsType=I={})),function(e){e[e.WHITE=4864]="WHITE",e[e.RED=5376]="RED",e[e.BLUE=5888]="BLUE",e[e.YELLOW=6144]="YELLOW",e[e.BLACK=6656]="BLACK",e[e.GREEN=9472]="GREEN",e[e.BROWN=27136]="BROWN",e[e.CYAN=16897]="CYAN"}(A||(t.MarioColor=A={}))},42:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.AbsoluteMotor=void 0;const a=r(7508),c=s(r(8066)),u=r(6185);class f extends a.TachoMotor{constructor(e,r,i={},n=c.DeviceType.UNKNOWN){super(e,r,Object.assign({},i,t.ModeMap),n)}receive(e){if(this._mode===l.ABSOLUTE){const t=(0,u.normalizeAngle)(e.readInt16LE(this.isWeDo2SmartHub?2:4));this.notify("absolute",{angle:t})}else super.receive(e)}gotoAngle(e,t=100){if(!this.isVirtualPort&&e instanceof Array)throw new Error("Only virtual ports can accept multiple positions");if(this.isWeDo2SmartHub)throw new Error("Absolute positioning is not available on the WeDo 2.0 Smart Hub");return this.cancelEventTimer(),new Promise((r=>{let n;null==t&&(t=100),e instanceof Array?(n=i.from([129,this.portId,17,14,0,0,0,0,0,0,0,0,(0,u.mapSpeed)(t),this._maxPower,this._brakeStyle,this.useProfile()]),n.writeInt32LE((0,u.normalizeAngle)(e[0]),4),n.writeInt32LE((0,u.normalizeAngle)(e[1]),8)):(n=i.from([129,this.portId,17,13,0,0,0,0,(0,u.mapSpeed)(t),this._maxPower,this._brakeStyle,this.useProfile()]),n.writeInt32LE((0,u.normalizeAngle)(e),4)),this.send(n),this._finishedCallbacks.push((()=>r()))}))}gotoRealZero(e=100){return new Promise((t=>{const r=this.mode;let i=!1;this.on("absolute",(async({angle:n})=>{if(!i)return i=!0,n<0?n=Math.abs(n):e=-e,await this.rotateByDegrees(n,e),r&&this.subscribe(r),t()})),this.requestUpdate()}))}resetZero(){return new Promise((e=>{const t=i.from([129,this.portId,17,81,2,0,0,0,0]);return this.send(t),e()}))}}var l;t.AbsoluteMotor=f,function(e){e[e.ROTATION=2]="ROTATION",e[e.ABSOLUTE=3]="ABSOLUTE"}(l||(t.Mode=l={})),t.ModeMap={rotate:l.ROTATION,absolute:l.ABSOLUTE}},5373:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.BasicMotor=void 0;const a=r(3124),c=s(r(8066)),u=r(6185);class f extends a.Device{constructor(e,t,r,i=c.DeviceType.UNKNOWN){super(e,t,r,i)}setPower(e,t=!0){return t&&this.cancelEventTimer(),this.writeDirect(0,i.from([(0,u.mapSpeed)(e)]))}rampPower(e,t,r){return this.cancelEventTimer(),new Promise((i=>{(0,u.calculateRamp)(this,e,t,r).on("changePower",(e=>{this.setPower(e,!1)})).on("finished",i)}))}stop(){return this.cancelEventTimer(),this.setPower(0)}brake(){return this.cancelEventTimer(),this.setPower(c.BrakingStyle.BRAKE)}}t.BasicMotor=f},5466:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Output=t.ModeMap=t.Mode=t.ColorDistanceSensor=void 0;const a=r(3124),c=s(r(8066)),u=r(6185);class f extends a.Device{constructor(e,r){super(e,r,t.ModeMap,c.DeviceType.COLOR_DISTANCE_SENSOR)}receive(e){switch(this._mode){case l.COLOR:if(e[this.isWeDo2SmartHub?2:4]<=10){const t=(0,u.parseColor)(e[this.isWeDo2SmartHub?2:4]);this.notify("color",{color:t})}break;case l.DISTANCE:if(this.isWeDo2SmartHub)break;if(e[4]<=10){let t=Math.floor(25.4*e[4])-20;t<0&&(t=0),this.notify("distance",{distance:t})}break;case l.DISTANCE_COUNT:if(this.isWeDo2SmartHub)break;if(8!==e.length)break;const t=e.readUInt32LE(4);this.notify("distanceCount",{count:t});break;case l.REFLECT:if(this.isWeDo2SmartHub)break;const r=e[4];this.notify("reflect",{reflect:r});break;case l.AMBIENT:if(this.isWeDo2SmartHub)break;const i=e[4];this.notify("ambient",{ambient:i});break;case l.RGB_I:if(this.isWeDo2SmartHub)break;if(10!==e.length)break;const n=e.readUInt16LE(4),o=e.readUInt16LE(6),s=e.readUInt16LE(8);this.notify("rgbIntensity",{red:n,green:o,blue:s});break;case l.COLOR_AND_DISTANCE:if(this.isWeDo2SmartHub)break;let a=e[5];const c=e[7];if(c>0&&(a+=1/c),a=Math.floor(25.4*a)-20,e[4]<=10){const t=e[4];this.notify("colorAndDistance",{color:t,distance:a})}}}setPFExtendedChannel(e){let t=0;e>=4&&(e-=4,t=1);const r=i.alloc(2);return r[0]=(e-1<<4)+(t<<3),r[1]=96,this.sendPFIRMessage(r)}setPFPower(e,t,r){let n=0;e>4&&(e-=4,n=1);const o=i.alloc(2);return o[0]=(e-1<<4)+(n<<3)+("RED"===t?4:5),o[1]=this._pfPowerToPWM(r)<<4,this.sendPFIRMessage(o)}startPFMotors(e,t,r){let n=0;e>4&&(e-=4,n=1);const o=i.alloc(2);return o[0]=(e-1+4+(n<<3)<<4)+this._pfPowerToPWM(t),o[1]=this._pfPowerToPWM(r)<<4,this.sendPFIRMessage(o)}sendPFIRMessage(e){if(this.isWeDo2SmartHub)throw new Error("Power Functions IR is not available on the WeDo 2.0 Smart Hub");{const t=i.alloc(2);return t[0]=(e[0]<<4)+(e[1]>>4),t[1]=e[0]>>4,this.subscribe(l.PF_IR),this.writeDirect(7,t)}}setColor(e){return new Promise((t=>{if(!1===e&&(e=0),this.isWeDo2SmartHub)throw new Error("Setting LED color is not available on the WeDo 2.0 Smart Hub");return this.subscribe(l.LED),this.writeDirect(5,i.from([e])),t()}))}setDistanceCount(e){return new Promise((t=>{if(this.isWeDo2SmartHub)throw new Error("Setting distance count is not available on the WeDo 2.0 Smart Hub");{const t=i.alloc(4);t.writeUInt32LE(e%2**32),this.writeDirect(2,t)}return t()}))}_pfPowerToPWM(e){return 15&e}}var l,_;t.ColorDistanceSensor=f,function(e){e[e.COLOR=0]="COLOR",e[e.DISTANCE=1]="DISTANCE",e[e.DISTANCE_COUNT=2]="DISTANCE_COUNT",e[e.REFLECT=3]="REFLECT",e[e.AMBIENT=4]="AMBIENT",e[e.LED=5]="LED",e[e.RGB_I=6]="RGB_I",e[e.PF_IR=7]="PF_IR",e[e.COLOR_AND_DISTANCE=8]="COLOR_AND_DISTANCE"}(l||(t.Mode=l={})),t.ModeMap={color:l.COLOR,distance:l.DISTANCE,distanceCount:l.DISTANCE_COUNT,reflect:l.REFLECT,ambient:l.AMBIENT,rgbIntensity:l.RGB_I,colorAndDistance:l.COLOR_AND_DISTANCE},function(e){e.RED="RED",e.BLUE="BLUE"}(_||(t.Output=_={}))},3839:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.CurrentSensor=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.CURRENT_SENSOR)}receive(e){if(this.mode===u.CURRENT)if(this.isWeDo2SmartHub){const t=e.readInt16LE(2)/1e3;this.notify("current",{current:t})}else{let t=f[this.hub.type];void 0===t&&(t=f[a.HubType.UNKNOWN]);let r=l[this.hub.type];void 0===r&&(r=l[a.HubType.UNKNOWN]);const i=e.readUInt16LE(4)*t/r;this.notify("current",{current:i})}}}var u;t.CurrentSensor=c,function(e){e[e.CURRENT=0]="CURRENT"}(u||(t.Mode=u={})),t.ModeMap={current:u.CURRENT};const f={[a.HubType.UNKNOWN]:2444,[a.HubType.TECHNIC_MEDIUM_HUB]:4175},l={[a.HubType.UNKNOWN]:4095}},3124:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Device=void 0;const a=r(7007),c=s(r(8066));class u extends a.EventEmitter{constructor(e,t,r={},i=c.DeviceType.UNKNOWN){super(),this.autoSubscribe=!0,this.values={},this._busy=!1,this._finishedCallbacks=[],this._connected=!0,this._modeMap={},this._isVirtualPort=!1,this._eventTimer=null,this._hub=e,this._portId=t,this._type=i,this._modeMap=r,this._isWeDo2SmartHub=this.hub.type===c.HubType.WEDO2_SMART_HUB,this._isVirtualPort=this.hub.isPortVirtual(t);const n=e=>{"detach"!==e&&this.autoSubscribe&&void 0!==this._modeMap[e]&&this.subscribe(this._modeMap[e])},o=e=>{e.portId===this.portId&&(this._connected=!1,this.hub.removeListener("detach",o),this.emit("detach"))};for(const e in this._modeMap)this.hub.listenerCount(e)>0&&n(e);this.hub.on("newListener",n),this.on("newListener",n),this.hub.on("detach",o)}get connected(){return this._connected}get hub(){return this._hub}get portId(){return this._portId}get portName(){return this.hub.getPortNameForPortId(this.portId)}get type(){return this._type}get typeName(){return c.DeviceTypeNames[this.type]}get mode(){return this._mode}get isWeDo2SmartHub(){return this._isWeDo2SmartHub}get isVirtualPort(){return this._isVirtualPort}writeDirect(e,t){return this.isWeDo2SmartHub?this.send(i.concat([i.from([this.portId,1,2]),t]),c.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE):this.send(i.concat([i.from([129,this.portId,17,81,e]),t]),c.BLECharacteristic.LPF2_ALL)}send(e,t=c.BLECharacteristic.LPF2_ALL){return this._ensureConnected(),this.hub.send(e,t)}subscribe(e){this._ensureConnected(),e!==this._mode&&(this._mode=e,this.hub.subscribe(this.portId,this.type,e))}unsubscribe(e){this._ensureConnected()}receive(e){this.notify("receive",{message:e})}notify(e,t){this.values[e]=t,this.emit(e,t),this.hub.listenerCount(e)>0&&this.hub.emit(e,this,t)}requestUpdate(){this.send(i.from([33,this.portId,0]))}finish(e){if(16&~e)for(this._busy=!(1&~e);this._finishedCallbacks.length>Number(this._busy);){const e=this._finishedCallbacks.shift();e&&e()}}setEventTimer(e){this._eventTimer=e}cancelEventTimer(){this._eventTimer&&(clearTimeout(this._eventTimer),this._eventTimer=null)}_ensureConnected(){if(!this.connected)throw new Error("Device is not connected")}}t.Device=u},692:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.DuploTrainBaseColorSensor=void 0;const s=r(3124),a=o(r(8066)),c=r(6185);class u extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.DUPLO_TRAIN_BASE_COLOR_SENSOR)}receive(e){switch(this._mode){case f.INTENSITY:const t=e[4];this.notify("intensity",{intensity:t});break;case f.COLOR:if(e[4]<=10){const t=(0,c.parseColor)(e[4]);this.notify("color",{color:t})}break;case f.REFLECTIVITY:const r=e[4];this.notify("reflect",{reflect:r});break;case f.RGB:const i=Math.floor(e.readUInt16LE(4)/4),n=Math.floor(e.readUInt16LE(6)/4),o=Math.floor(e.readUInt16LE(8)/4);this.notify("rgb",{red:i,green:n,blue:o})}}}var f;t.DuploTrainBaseColorSensor=u,function(e){e[e.INTENSITY=0]="INTENSITY",e[e.COLOR=1]="COLOR",e[e.REFLECTIVITY=2]="REFLECTIVITY",e[e.RGB=3]="RGB"}(f||(t.Mode=f={})),t.ModeMap={intensity:f.INTENSITY,color:f.COLOR,reflect:f.REFLECTIVITY,rgb:f.RGB}},1940:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.DuploTrainBaseMotor=void 0;const s=r(5373),a=o(r(8066));class c extends s.BasicMotor{constructor(e,t){super(e,t,{},a.DeviceType.DUPLO_TRAIN_BASE_MOTOR)}}t.DuploTrainBaseMotor=c},5636:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Mode=t.DuploTrainBaseSpeaker=void 0;const a=r(3124),c=s(r(8066));class u extends a.Device{constructor(e,t){super(e,t,{},c.DeviceType.DUPLO_TRAIN_BASE_SPEAKER)}playSound(e){return new Promise((t=>(this.subscribe(f.SOUND),this.writeDirect(1,i.from([e])),t())))}playTone(e){this.subscribe(f.TONE),this.writeDirect(2,i.from([e]))}}var f;t.DuploTrainBaseSpeaker=u,function(e){e[e.SOUND=1]="SOUND",e[e.TONE=2]="TONE"}(f||(t.Mode=f={}))},1472:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.DuploTrainBaseSpeedometer=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.DUPLO_TRAIN_BASE_SPEEDOMETER)}receive(e){if(this._mode===u.SPEED){const t=e.readInt16LE(4);this.notify("speed",{speed:t})}}}var u;t.DuploTrainBaseSpeedometer=c,function(e){e[e.SPEED=0]="SPEED"}(u||(t.Mode=u={})),t.ModeMap={speed:u.SPEED}},1422:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Mode=t.HubLED=void 0;const a=r(3124),c=s(r(8066));class u extends a.Device{constructor(e,t){super(e,t,{},c.DeviceType.HUB_LED)}setColor(e){return new Promise((t=>("boolean"==typeof e&&(e=0),this.isWeDo2SmartHub?(this.send(i.from([6,23,1,1]),c.BLECharacteristic.WEDO2_PORT_TYPE_WRITE),this.send(i.from([6,4,1,e]),c.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE)):(this.subscribe(f.COLOR),this.writeDirect(0,i.from([e]))),t())))}setRGB(e,t,r){return new Promise((n=>(this.isWeDo2SmartHub?(this.send(i.from([6,23,1,2]),c.BLECharacteristic.WEDO2_PORT_TYPE_WRITE),this.send(i.from([6,4,3,e,t,r]),c.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE)):(this.subscribe(f.RGB),this.writeDirect(1,i.from([e,t,r]))),n())))}}var f;t.HubLED=u,function(e){e[e.COLOR=0]="COLOR",e[e.RGB=1]="RGB"}(f||(t.Mode=f={}))},9128:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Light=void 0;const a=r(3124),c=s(r(8066)),u=r(6185);class f extends a.Device{constructor(e,t){super(e,t,{},c.DeviceType.LIGHT)}setBrightness(e,t=!0){return t&&this.cancelEventTimer(),new Promise((t=>(this.writeDirect(0,i.from([e])),t())))}rampBrightness(e,t,r){return this.cancelEventTimer(),new Promise((i=>{(0,u.calculateRamp)(this,e,t,r).on("changePower",(e=>{this.setBrightness(e,!1)})).on("finished",i)}))}}t.Light=f},399:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.MarioAccelerometer=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.MARIO_ACCELEROMETER)}receive(e){switch(this._mode){case u.ACCEL:const t=e[4],r=e[5],i=e[6];this.notify("accel",{x:t,y:r,z:i});break;case u.GEST:const n=e[4];this.notify("gesture",{gesture:n})}}}var u;t.MarioAccelerometer=c,function(e){e[e.ACCEL=0]="ACCEL",e[e.GEST=1]="GEST"}(u||(t.Mode=u={})),t.ModeMap={accel:u.ACCEL,gesture:u.GEST}},6556:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.MarioBarcodeSensor=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.MARIO_BARCODE_SENSOR)}receive(e){switch(this._mode){case u.BARCODE:const t=e.readUInt16LE(4),r=e.readUInt16LE(6);65535===r?this.notify("barcode",{barcode:t}):65535===t&&this.notify("barcode",{color:r});break;case u.RGB:const i=e[4],n=e[5],o=e[6];this.notify("rgb",{r:i,g:n,b:o})}}}var u;t.MarioBarcodeSensor=c,function(e){e[e.BARCODE=0]="BARCODE",e[e.RGB=1]="RGB"}(u||(t.Mode=u={})),t.ModeMap={barcode:u.BARCODE,rgb:u.RGB}},9834:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.MarioPantsSensor=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.MARIO_PANTS_SENSOR)}receive(e){if(this._mode===u.PANTS){const t=e[4];this.notify("pants",{pants:t})}}}var u;t.MarioPantsSensor=c,function(e){e[e.PANTS=0]="PANTS"}(u||(t.Mode=u={})),t.ModeMap={pants:u.PANTS}},9823:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.MediumLinearMotor=void 0;const s=r(7508),a=o(r(8066));class c extends s.TachoMotor{constructor(e,t){super(e,t,{},a.DeviceType.MEDIUM_LINEAR_MOTOR)}}t.MediumLinearMotor=c},5530:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.MotionSensor=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.MOTION_SENSOR)}receive(e){if(this._mode===u.DISTANCE){let t=e[this.isWeDo2SmartHub?2:4];1===e[this.isWeDo2SmartHub?3:5]&&(t+=255),t*=10,this.notify("distance",{distance:t})}}}var u;t.MotionSensor=c,function(e){e[e.DISTANCE=0]="DISTANCE"}(u||(t.Mode=u={})),t.ModeMap={distance:u.DISTANCE}},8941:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.MoveHubMediumLinearMotor=void 0;const s=r(7508),a=o(r(8066));class c extends s.TachoMotor{constructor(e,t){super(e,t,{},a.DeviceType.MOVE_HUB_MEDIUM_LINEAR_MOTOR)}}t.MoveHubMediumLinearMotor=c},4081:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.MoveHubTiltSensor=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.MOVE_HUB_TILT_SENSOR)}receive(e){if(this._mode===u.TILT){const t=-e.readInt8(4),r=e.readInt8(5);this.notify("tilt",{x:t,y:r})}}}var u;t.MoveHubTiltSensor=c,function(e){e[e.TILT=0]="TILT"}(u||(t.Mode=u={})),t.ModeMap={tilt:u.TILT}},8055:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PiezoBuzzer=void 0;const a=r(3124),c=s(r(8066));class u extends a.Device{constructor(e,t){super(e,t,{},c.DeviceType.PIEZO_BUZZER)}playTone(e,t){return new Promise((n=>{const o=i.from([5,2,4,0,0,0,0]);o.writeUInt16LE(e,3),o.writeUInt16LE(t,5),this.send(o,c.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE),r.g.setTimeout(n,t)}))}}t.PiezoBuzzer=u},87:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ButtonState=t.ModeMap=t.Mode=t.RemoteControlButton=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.REMOTE_CONTROL_BUTTON)}receive(e){if(this._mode===u.BUTTON_EVENTS){const t=e[4];this.notify("remoteButton",{event:t})}}}var u;t.RemoteControlButton=c,function(e){e[e.BUTTON_EVENTS=0]="BUTTON_EVENTS"}(u||(t.Mode=u={})),t.ModeMap={remoteButton:u.BUTTON_EVENTS},t.ButtonState={UP:1,DOWN:255,STOP:127,RELEASED:0}},8693:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleMediumLinearMotor=void 0;const s=r(5373),a=o(r(8066));class c extends s.BasicMotor{constructor(e,t){super(e,t,{},a.DeviceType.SIMPLE_MEDIUM_LINEAR_MOTOR)}}t.SimpleMediumLinearMotor=c},7508:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TachoMotor=void 0;const a=r(5373),c=s(r(8066)),u=r(6185);class f extends a.BasicMotor{constructor(e,r,i={},n=c.DeviceType.UNKNOWN){super(e,r,Object.assign({},i,t.ModeMap),n),this._brakeStyle=c.BrakingStyle.BRAKE,this._maxPower=100,this.useAccelerationProfile=!0,this.useDecelerationProfile=!0}receive(e){if(this._mode===l.ROTATION){const t=e.readInt32LE(this.isWeDo2SmartHub?2:4);this.notify("rotate",{degrees:t})}}setBrakingStyle(e){this._brakeStyle=e}setMaxPower(e){this._maxPower=e}setAccelerationTime(e,t=0){const r=i.from([129,this.portId,17,5,0,0,t]);r.writeUInt16LE(e,4),this.send(r)}setDecelerationTime(e,t=0){const r=i.from([129,this.portId,17,6,0,0,t]);r.writeUInt16LE(e,4),this.send(r)}setSpeed(e,t){if(!this.isVirtualPort&&e instanceof Array)throw new Error("Only virtual ports can accept multiple speeds");if(this.isWeDo2SmartHub)throw new Error("Motor speed is not available on the WeDo 2.0 Smart Hub");return this.cancelEventTimer(),new Promise((r=>{let n;null==e&&(e=100),void 0!==t?(n=e instanceof Array?i.from([129,this.portId,17,10,0,0,(0,u.mapSpeed)(e[0]),(0,u.mapSpeed)(e[1]),this._maxPower,this._brakeStyle,this.useProfile()]):i.from([129,this.portId,17,9,0,0,(0,u.mapSpeed)(e),this._maxPower,this._brakeStyle,this.useProfile()]),n.writeUInt16LE(t,4)):n=e instanceof Array?i.from([129,this.portId,17,8,(0,u.mapSpeed)(e[0]),(0,u.mapSpeed)(e[1]),this._maxPower,this.useProfile()]):i.from([129,this.portId,17,7,(0,u.mapSpeed)(e),this._maxPower,this.useProfile()]),this.send(n),this._finishedCallbacks.push((()=>r()))}))}rotateByDegrees(e,t){if(!this.isVirtualPort&&t instanceof Array)throw new Error("Only virtual ports can accept multiple speeds");if(this.isWeDo2SmartHub)throw new Error("Rotation is not available on the WeDo 2.0 Smart Hub");return this.cancelEventTimer(),new Promise((r=>{let n;null==t&&(t=100),n=t instanceof Array?i.from([129,this.portId,17,12,0,0,0,0,(0,u.mapSpeed)(t[0]),(0,u.mapSpeed)(t[1]),this._maxPower,this._brakeStyle,this.useProfile()]):i.from([129,this.portId,17,11,0,0,0,0,(0,u.mapSpeed)(t),this._maxPower,this._brakeStyle,this.useProfile()]),n.writeUInt32LE(e,4),this.send(n),this._finishedCallbacks.push((()=>r()))}))}useProfile(){let e=0;return this.useAccelerationProfile&&(e+=1),this.useDecelerationProfile&&(e+=2),e}}var l;t.TachoMotor=f,function(e){e[e.ROTATION=2]="ROTATION"}(l||(t.Mode=l={})),t.ModeMap={rotate:l.ROTATION}},3164:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Mode=t.Technic3x3ColorLightMatrix=void 0;const a=r(8359),c=r(3124),u=s(r(8066));class f extends c.Device{constructor(e,t){super(e,t,{},u.DeviceType.TECHNIC_3X3_COLOR_LIGHT_MATRIX)}setMatrix(e){return new Promise((t=>{this.subscribe(l.PIX_0);const r=new Array(9);for(let t=0;t<r.length;t++)"number"==typeof e&&(r[t]=e+160),e[t]instanceof a.Color&&(r[t]=e[t].toValue()),e[t]===u.Color.NONE&&(r[t]=u.Color.NONE),e[t]<=10&&(r[t]=e[t]+160);return this.writeDirect(l.PIX_0,i.from(r)),t()}))}}var l;t.Technic3x3ColorLightMatrix=f,function(e){e[e.LEV_0=0]="LEV_0",e[e.COL_0=1]="COL_0",e[e.PIX_0=2]="PIX_0",e[e.TRANS=3]="TRANS"}(l||(t.Mode=l={}))},9161:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicColorSensor=void 0;const a=r(3124),c=s(r(8066)),u=r(6185);class f extends a.Device{constructor(e,r){super(e,r,t.ModeMap,c.DeviceType.TECHNIC_COLOR_SENSOR)}receive(e){switch(this._mode){case l.COLOR:if(e[4]<=10){const t=(0,u.parseColor)(e[4]);this.notify("color",{color:t})}break;case l.REFLECTIVITY:const t=e[4];this.notify("reflect",{reflect:t});break;case l.AMBIENT_LIGHT:const r=e[4];this.notify("ambient",{ambient:r})}}setBrightness(e,t,r){this.writeDirect(3,i.from([e,t,r]))}}var l;t.TechnicColorSensor=f,function(e){e[e.COLOR=0]="COLOR",e[e.REFLECTIVITY=1]="REFLECTIVITY",e[e.AMBIENT_LIGHT=2]="AMBIENT_LIGHT"}(l||(t.Mode=l={})),t.ModeMap={color:l.COLOR,reflect:l.REFLECTIVITY,ambient:l.AMBIENT_LIGHT}},6719:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicDistanceSensor=void 0;const a=r(3124),c=s(r(8066));class u extends a.Device{constructor(e,r){super(e,r,t.ModeMap,c.DeviceType.TECHNIC_DISTANCE_SENSOR)}receive(e){switch(this._mode){case f.DISTANCE:const t=e.readUInt16LE(4);this.notify("distance",{distance:t});break;case f.FAST_DISTANCE:const r=e.readUInt16LE(4);this.notify("fastDistance",{fastDistance:r})}}setBrightness(e,t,r,n){this.writeDirect(5,i.from([e,r,t,n]))}}var f;t.TechnicDistanceSensor=u,function(e){e[e.DISTANCE=0]="DISTANCE",e[e.FAST_DISTANCE=1]="FAST_DISTANCE"}(f||(t.Mode=f={})),t.ModeMap={distance:f.DISTANCE,fastDistance:f.FAST_DISTANCE}},381:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicForceSensor=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.TECHNIC_FORCE_SENSOR)}receive(e){switch(this._mode){case u.FORCE:const t=e[this.isWeDo2SmartHub?2:4]/10;this.notify("force",{force:t});break;case u.TOUCHED:const r=!!e[4];this.notify("touched",{touched:r});break;case u.TAPPED:const i=e[4];this.notify("tapped",{tapped:i})}}}var u;t.TechnicForceSensor=c,function(e){e[e.FORCE=0]="FORCE",e[e.TOUCHED=1]="TOUCHED",e[e.TAPPED=2]="TAPPED"}(u||(t.Mode=u={})),t.ModeMap={force:u.FORCE,touched:u.TOUCHED,tapped:u.TAPPED}},3488:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TechnicLargeAngularMotor=void 0;const s=r(42),a=o(r(8066));class c extends s.AbsoluteMotor{constructor(e,t,r={},i=a.DeviceType.TECHNIC_LARGE_ANGULAR_MOTOR){super(e,t,{},i)}}t.TechnicLargeAngularMotor=c},3281:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TechnicLargeLinearMotor=void 0;const s=r(42),a=o(r(8066));class c extends s.AbsoluteMotor{constructor(e,t){super(e,t,{},a.DeviceType.TECHNIC_LARGE_LINEAR_MOTOR)}}t.TechnicLargeLinearMotor=c},4230:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TechnicMediumAngularMotor=void 0;const s=r(42),a=o(r(8066));class c extends s.AbsoluteMotor{constructor(e,t,r={},i=a.DeviceType.TECHNIC_MEDIUM_ANGULAR_MOTOR){super(e,t,{},i)}}t.TechnicMediumAngularMotor=c},8971:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicMediumHubAccelerometerSensor=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.TECHNIC_MEDIUM_HUB_ACCELEROMETER)}receive(e){if(this._mode===u.ACCEL){const t=Math.round(e.readInt16LE(4)/4.096),r=Math.round(e.readInt16LE(6)/4.096),i=Math.round(e.readInt16LE(8)/4.096);this.notify("accel",{x:t,y:r,z:i})}}}var u;t.TechnicMediumHubAccelerometerSensor=c,function(e){e[e.ACCEL=0]="ACCEL"}(u||(t.Mode=u={})),t.ModeMap={accel:u.ACCEL}},2835:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicMediumHubGyroSensor=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.TECHNIC_MEDIUM_HUB_GYRO_SENSOR)}receive(e){if(this._mode===u.GYRO){const t=Math.round(7*e.readInt16LE(4)/400),r=Math.round(7*e.readInt16LE(6)/400),i=Math.round(7*e.readInt16LE(8)/400);this.notify("gyro",{x:t,y:r,z:i})}}}var u;t.TechnicMediumHubGyroSensor=c,function(e){e[e.GYRO=0]="GYRO"}(u||(t.Mode=u={})),t.ModeMap={gyro:u.GYRO}},5039:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TechnicMediumHubTiltSensor=void 0;const a=r(3124),c=s(r(8066));class u extends a.Device{constructor(e,r){super(e,r,t.ModeMap,c.DeviceType.TECHNIC_MEDIUM_HUB_TILT_SENSOR),this._impactThreshold=10,this._impactHoldoff=10}receive(e){switch(this._mode){case f.TILT:let t=-e.readInt16LE(4);const r=e.readInt16LE(6),i=e.readInt16LE(8);90!==r&&-90!==r||(t=Math.sign(r)*(t+180),t>180&&(t-=360),t<-180&&(t+=360)),this.notify("tilt",{x:i,y:r,z:t});break;case f.IMPACT_COUNT:if(8!==e.length)break;const n=e.readUInt32LE(4);this.notify("impactCount",{count:n})}}setImpactCount(e){return new Promise((t=>{const r=i.alloc(4);return r.writeUInt32LE(e%2**32),this.writeDirect(1,r),t()}))}setImpactThreshold(e){return this._impactThreshold=e,new Promise((e=>(this.writeDirect(2,i.from([this._impactThreshold,this._impactHoldoff])),e())))}setImpactHoldoff(e){return this._impactHoldoff=e,new Promise((e=>(this.writeDirect(2,i.from([this._impactThreshold,this._impactHoldoff])),e())))}}var f;t.TechnicMediumHubTiltSensor=u,function(e){e[e.TILT=0]="TILT",e[e.IMPACT_COUNT=1]="IMPACT_COUNT"}(f||(t.Mode=f={})),t.ModeMap={tilt:f.TILT,impactCount:f.IMPACT_COUNT}},1188:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TechnicSmallAngularMotor=void 0;const s=r(42),a=o(r(8066));class c extends s.AbsoluteMotor{constructor(e,t,r={},i=a.DeviceType.TECHNIC_SMALL_ANGULAR_MOTOR){super(e,t,{},i)}}t.TechnicSmallAngularMotor=c},4843:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TechnicXLargeLinearMotor=void 0;const s=r(42),a=o(r(8066));class c extends s.AbsoluteMotor{constructor(e,t){super(e,t,{},a.DeviceType.TECHNIC_XLARGE_LINEAR_MOTOR)}}t.TechnicXLargeLinearMotor=c},5047:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.TiltSensor=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.TILT_SENSOR)}receive(e){if(this._mode===u.TILT){const t=e.readInt8(this.isWeDo2SmartHub?2:4),r=e.readInt8(this.isWeDo2SmartHub?3:5);this.notify("tilt",{x:t,y:r})}}}var u;t.TiltSensor=c,function(e){e[e.TILT=0]="TILT"}(u||(t.Mode=u={})),t.ModeMap={tilt:u.TILT}},717:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.TrainMotor=void 0;const s=r(5373),a=o(r(8066));class c extends s.BasicMotor{constructor(e,t){super(e,t,{},a.DeviceType.TRAIN_MOTOR)}}t.TrainMotor=c},9152:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ModeMap=t.Mode=t.VoltageSensor=void 0;const s=r(3124),a=o(r(8066));class c extends s.Device{constructor(e,r){super(e,r,t.ModeMap,a.DeviceType.VOLTAGE_SENSOR)}receive(e){if(this._mode===u.VOLTAGE)if(this.isWeDo2SmartHub){const t=e.readInt16LE(2)/40;this.notify("voltage",{voltage:t})}else{let t=f[this.hub.type];void 0===t&&(t=f[a.HubType.UNKNOWN]);let r=l[this.hub.type];void 0===r&&(r=l[a.HubType.UNKNOWN]);const i=e.readUInt16LE(4)*t/r;this.notify("voltage",{voltage:i})}}}var u;t.VoltageSensor=c,function(e){e[e.VOLTAGE=0]="VOLTAGE"}(u||(t.Mode=u={})),t.ModeMap={voltage:u.VOLTAGE};const f={[a.HubType.UNKNOWN]:9.615,[a.HubType.DUPLO_TRAIN_BASE]:6.4,[a.HubType.REMOTE_CONTROL]:6.4},l={[a.HubType.UNKNOWN]:3893,[a.HubType.DUPLO_TRAIN_BASE]:3047,[a.HubType.REMOTE_CONTROL]:3200,[a.HubType.TECHNIC_MEDIUM_HUB]:4095}},9597:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.BaseHub=void 0;const s=r(7007),a=r(5466),c=r(3839),u=r(3124),f=r(692),l=r(1940),_=r(5636),h=r(1472),d=r(1422),p=r(9128),E=r(399),O=r(6556),T=r(9834),b=r(9823),v=r(5530),M=r(8941),y=r(4081),R=r(8055),m=r(87),S=r(8693),g=r(9161),I=r(6719),A=r(381),D=r(3488),L=r(3281),C=r(1188),P=r(4230),N=r(8971),B=r(2835),w=r(5039),U=r(4843),H=r(5047),j=r(717),F=r(9152),W=o(r(8066)),G=r(7833),x=r(3164),V=G("basehub");class k extends s.EventEmitter{constructor(e,t={},r=W.HubType.UNKNOWN){super(),this._attachedDevices={},this._name="",this._firmwareVersion="0.0.00.0000",this._hardwareVersion="0.0.00.0000",this._primaryMACAddress="00:00:00:00:00:00",this._batteryLevel=100,this._rssi=-60,this._portMap={},this._virtualPorts=[],this._attachCallbacks=[],this.setMaxListeners(23),this._type=r,this._bleDevice=e,this._portMap=Object.assign({},t),e.on("disconnect",(()=>{this.emit("disconnect")}))}get name(){return this._bleDevice.name}get connected(){return this._bleDevice.connected}get connecting(){return this._bleDevice.connecting}get type(){return this._type}get ports(){return Object.keys(this._portMap)}get firmwareVersion(){return this._firmwareVersion}get hardwareVersion(){return this._hardwareVersion}get primaryMACAddress(){return this._primaryMACAddress}get uuid(){return this._bleDevice.uuid}get batteryLevel(){return this._batteryLevel}get rssi(){return this._rssi}connect(){if(this._bleDevice.connecting)throw new Error("Already connecting");if(this._bleDevice.connected)throw new Error("Already connected");return this._bleDevice.connect()}disconnect(){return this._bleDevice.disconnect()}getDeviceAtPort(e){const t=this._portMap[e];return void 0!==t?this._attachedDevices[t]:void 0}waitForDeviceAtPort(e){return new Promise((t=>{const r=this.getDeviceAtPort(e);if(r)return t(r);this._attachCallbacks.push((r=>r.portName===e&&(t(r),!0)))}))}getDevices(){return Object.values(this._attachedDevices)}getDevicesByType(e){return this.getDevices().filter((t=>t.type===e))}waitForDeviceByType(e){return new Promise((t=>{const r=this.getDevicesByType(e);if(r.length>=1)return t(r[0]);this._attachCallbacks.push((r=>r.type===e&&(t(r),!0)))}))}getPortNameForPortId(e){for(const t of Object.keys(this._portMap))if(this._portMap[t]===e)return t}isPortVirtual(e){return this._virtualPorts.indexOf(e)>-1}sleep(e){return new Promise((t=>{r.g.setTimeout(t,e)}))}wait(e){return Promise.all(e)}send(e,t){return Promise.resolve()}subscribe(e,t,r){}unsubscribe(e,t,r){}manuallyAttachDevice(e,t){if(this._attachedDevices[t]){if(this._attachedDevices[t].type===e)return V(`Device of ${e} already attached to portId ${t}, returning existing device`),this._attachedDevices[t];throw new Error(`Already a different type of device attached to portId ${t}. Only use this method when you are certain what's attached.`)}{V(`No device attached to portId ${t}, creating and attaching device type ${e}`);const r=this._createDevice(e,t);return this._attachDevice(r),r}}_attachDevice(e){if(this._attachedDevices[e.portId]&&this._attachedDevices[e.portId].type===e.type)return;this._attachedDevices[e.portId]=e,this.emit("attach",e),V(`Attached device type ${e.type} (${W.DeviceTypeNames[e.type]}) on port ${e.portName} (${e.portId})`);let t=this._attachCallbacks.length;for(;t--;)(0,this._attachCallbacks[t])(e)&&this._attachCallbacks.splice(t,1)}_detachDevice(e){delete this._attachedDevices[e.portId],this.emit("detach",e),V(`Detached device type ${e.type} (${W.DeviceTypeNames[e.type]}) on port ${e.portName} (${e.portId})`)}_createDevice(e,t){let r;return r={[W.DeviceType.LIGHT]:p.Light,[W.DeviceType.TRAIN_MOTOR]:j.TrainMotor,[W.DeviceType.SIMPLE_MEDIUM_LINEAR_MOTOR]:S.SimpleMediumLinearMotor,[W.DeviceType.MOVE_HUB_MEDIUM_LINEAR_MOTOR]:M.MoveHubMediumLinearMotor,[W.DeviceType.MOTION_SENSOR]:v.MotionSensor,[W.DeviceType.TILT_SENSOR]:H.TiltSensor,[W.DeviceType.MOVE_HUB_TILT_SENSOR]:y.MoveHubTiltSensor,[W.DeviceType.PIEZO_BUZZER]:R.PiezoBuzzer,[W.DeviceType.TECHNIC_COLOR_SENSOR]:g.TechnicColorSensor,[W.DeviceType.TECHNIC_DISTANCE_SENSOR]:I.TechnicDistanceSensor,[W.DeviceType.TECHNIC_FORCE_SENSOR]:A.TechnicForceSensor,[W.DeviceType.TECHNIC_MEDIUM_HUB_TILT_SENSOR]:w.TechnicMediumHubTiltSensor,[W.DeviceType.TECHNIC_MEDIUM_HUB_GYRO_SENSOR]:B.TechnicMediumHubGyroSensor,[W.DeviceType.TECHNIC_MEDIUM_HUB_ACCELEROMETER]:N.TechnicMediumHubAccelerometerSensor,[W.DeviceType.MEDIUM_LINEAR_MOTOR]:b.MediumLinearMotor,[W.DeviceType.TECHNIC_SMALL_ANGULAR_MOTOR]:C.TechnicSmallAngularMotor,[W.DeviceType.TECHNIC_MEDIUM_ANGULAR_MOTOR]:P.TechnicMediumAngularMotor,[W.DeviceType.TECHNIC_LARGE_ANGULAR_MOTOR]:D.TechnicLargeAngularMotor,[W.DeviceType.TECHNIC_LARGE_LINEAR_MOTOR]:L.TechnicLargeLinearMotor,[W.DeviceType.TECHNIC_XLARGE_LINEAR_MOTOR]:U.TechnicXLargeLinearMotor,[W.DeviceType.COLOR_DISTANCE_SENSOR]:a.ColorDistanceSensor,[W.DeviceType.VOLTAGE_SENSOR]:F.VoltageSensor,[W.DeviceType.CURRENT_SENSOR]:c.CurrentSensor,[W.DeviceType.REMOTE_CONTROL_BUTTON]:m.RemoteControlButton,[W.DeviceType.HUB_LED]:d.HubLED,[W.DeviceType.DUPLO_TRAIN_BASE_COLOR_SENSOR]:f.DuploTrainBaseColorSensor,[W.DeviceType.DUPLO_TRAIN_BASE_MOTOR]:l.DuploTrainBaseMotor,[W.DeviceType.DUPLO_TRAIN_BASE_SPEAKER]:_.DuploTrainBaseSpeaker,[W.DeviceType.DUPLO_TRAIN_BASE_SPEEDOMETER]:h.DuploTrainBaseSpeedometer,[W.DeviceType.MARIO_ACCELEROMETER]:E.MarioAccelerometer,[W.DeviceType.MARIO_BARCODE_SENSOR]:O.MarioBarcodeSensor,[W.DeviceType.MARIO_PANTS_SENSOR]:T.MarioPantsSensor,[W.DeviceType.TECHNIC_MEDIUM_ANGULAR_MOTOR_GREY]:P.TechnicMediumAngularMotor,[W.DeviceType.TECHNIC_LARGE_ANGULAR_MOTOR_GREY]:D.TechnicLargeAngularMotor,[W.DeviceType.TECHNIC_3X3_COLOR_LIGHT_MATRIX]:x.Technic3x3ColorLightMatrix}[e],r?new r(this,t,void 0,e):new u.Device(this,t,void 0,e)}_getDeviceByPortId(e){return this._attachedDevices[e]}}t.BaseHub=k},8062:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.DuploTrainBase=void 0;const s=r(8650),a=o(r(8066)),c=r(7833)("duplotrainbase");class u extends s.LPF2Hub{static IsDuploTrainBase(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(a.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===a.BLEManufacturerData.DUPLO_TRAIN_BASE_ID}constructor(e){super(e,t.PortMap,a.HubType.DUPLO_TRAIN_BASE),c("Discovered Duplo Train Base")}async connect(){c("Connecting to Duplo Train Base"),await super.connect(),c("Connect completed")}}t.DuploTrainBase=u,t.PortMap={MOTOR:0,COLOR:18,SPEEDOMETER:19}},1718:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.Hub=void 0;const s=r(8385),a=r(8650),c=o(r(8066)),u=r(7833)("hub");class f extends a.LPF2Hub{static IsHub(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(c.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===c.BLEManufacturerData.HUB_ID}constructor(e){super(e,t.PortMap,c.HubType.HUB),this._currentPort=59,u("Discovered Powered UP Hub")}async connect(){u("Connecting to Powered UP Hub"),await super.connect(),u("Connect completed")}_checkFirmware(e){if(1===(0,s.compareVersions)("1.1.00.0004",e))throw new Error(`Your Powered Up Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`)}}t.Hub=f,t.PortMap={A:0,B:1,HUB_LED:50,CURRENT_SENSOR:59,VOLTAGE_SENSOR:60}},8650:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.LPF2Hub=void 0;const a=r(9597),c=s(r(8066)),u=r(6185),f=r(7833),l=f("lpf2hub"),_=f("lpf2hubmodeinfo");class h extends a.BaseHub{constructor(){super(...arguments),this._messageBuffer=i.alloc(0),this._propertyRequestCallbacks={}}async connect(){l("LPF2Hub connecting"),await super.connect(),await this._bleDevice.discoverCharacteristicsForService(c.BLEService.LPF2_HUB),this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.LPF2_ALL,this._parseMessage.bind(this)),await this._requestHubPropertyReports(c.HubPropertyPayload.BUTTON_STATE),await this._requestHubPropertyValue(c.HubPropertyPayload.FW_VERSION),await this._requestHubPropertyValue(c.HubPropertyPayload.HW_VERSION),await this._requestHubPropertyReports(c.HubPropertyPayload.RSSI),await this._requestHubPropertyReports(c.HubPropertyPayload.BATTERY_VOLTAGE),await this._requestHubPropertyValue(c.HubPropertyPayload.PRIMARY_MAC_ADDRESS),this.emit("connect"),l("LPF2Hub connected")}shutdown(){return this.send(i.from([2,1]),c.BLECharacteristic.LPF2_ALL)}async setName(e){if(e.length>14)throw new Error("Name must be 14 characters or less");let t=i.from([1,1,1]);t=i.concat([t,i.from(e,"ascii")]),await this.send(t,c.BLECharacteristic.LPF2_ALL),await this.send(t,c.BLECharacteristic.LPF2_ALL),this._name=e}send(e,t){return(e=i.concat([i.alloc(2),e]))[0]=e.length,l("Sent Message (LPF2_ALL)",e),this._bleDevice.writeToCharacteristic(t,e)}subscribe(e,t,r){return this.send(i.from([65,e,r,1,0,0,0,1]),c.BLECharacteristic.LPF2_ALL)}unsubscribe(e,t){return this.send(i.from([65,e,t,1,0,0,0,0]),c.BLECharacteristic.LPF2_ALL)}createVirtualPort(e,t){const r=this.getDeviceAtPort(e);if(!r)throw new Error(`Port ${e} does not have an attached device`);const n=this.getDeviceAtPort(t);if(!n)throw new Error(`Port ${t} does not have an attached device`);if(r.type!==n.type)throw new Error("Both devices must be of the same type to create a virtual port");return this.send(i.from([97,1,r.portId,n.portId]),c.BLECharacteristic.LPF2_ALL)}_checkFirmware(e){}_parseMessage(e){if(e&&(this._messageBuffer=i.concat([this._messageBuffer,e])),this._messageBuffer.length<=0)return;const t=this._messageBuffer[0];if(t<=this._messageBuffer.length){const e=this._messageBuffer.slice(0,t);switch(this._messageBuffer=this._messageBuffer.slice(t),l("Received Message (LPF2_ALL)",e),e[2]){case c.MessageType.HUB_PROPERTIES:{const t=e[3],r=this._propertyRequestCallbacks[t];r?r(e):this._parseHubPropertyResponse(e),delete this._propertyRequestCallbacks[t];break}case c.MessageType.HUB_ATTACHED_IO:this._parsePortMessage(e);break;case c.MessageType.PORT_INFORMATION:this._parsePortInformationResponse(e);break;case c.MessageType.PORT_MODE_INFORMATION:this._parseModeInformationResponse(e);break;case c.MessageType.PORT_VALUE_SINGLE:this._parseSensorMessage(e);break;case c.MessageType.PORT_OUTPUT_COMMAND_FEEDBACK:this._parsePortAction(e)}this._messageBuffer.length>0&&this._parseMessage()}}_requestHubPropertyValue(e){return new Promise((t=>{this._propertyRequestCallbacks[e]=e=>(this._parseHubPropertyResponse(e),t()),this.send(i.from([1,e,5]),c.BLECharacteristic.LPF2_ALL)}))}_requestHubPropertyReports(e){return this.send(i.from([1,e,2]),c.BLECharacteristic.LPF2_ALL)}_parseHubPropertyResponse(e){if(e[3]===c.HubPropertyPayload.BUTTON_STATE){if(1===e[5])return void this.emit("button",{event:c.ButtonState.PRESSED});if(0===e[5])return void this.emit("button",{event:c.ButtonState.RELEASED})}else if(e[3]===c.HubPropertyPayload.FW_VERSION)this._firmwareVersion=(0,u.decodeVersion)(e.readInt32LE(5)),this._checkFirmware(this._firmwareVersion);else if(e[3]===c.HubPropertyPayload.HW_VERSION)this._hardwareVersion=(0,u.decodeVersion)(e.readInt32LE(5));else if(e[3]===c.HubPropertyPayload.RSSI){const t=e.readInt8(5);0!==t&&(this._rssi=t,this.emit("rssi",{rssi:this._rssi}))}else if(e[3]===c.HubPropertyPayload.PRIMARY_MAC_ADDRESS)this._primaryMACAddress=(0,u.decodeMACAddress)(e.slice(5));else if(e[3]===c.HubPropertyPayload.BATTERY_VOLTAGE){const t=e[5];t!==this._batteryLevel&&(this._batteryLevel=t,this.emit("batteryLevel",{batteryLevel:t}))}}async _parsePortMessage(e){const t=e[3],r=e[4],i=r?e.readUInt16LE(5):0;if(r===c.Event.ATTACHED_IO){if(_.enabled){const r=c.DeviceTypeNames[e[5]]||"Unknown";_(`Port ${(0,u.toHex)(t)}, type ${(0,u.toHex)(i,4)} (${r})`);const n=(0,u.decodeVersion)(e.readInt32LE(7)),o=(0,u.decodeVersion)(e.readInt32LE(11));_(`Port ${(0,u.toHex)(t)}, hardware version ${n}, software version ${o}`),await this._sendPortInformationRequest(t)}const r=this._createDevice(i,t);this._attachDevice(r)}else if(r===c.Event.DETACHED_IO){const e=this._getDeviceByPortId(t);if(e&&(this._detachDevice(e),this.isPortVirtual(t))){const e=this.getPortNameForPortId(t);e&&delete this._portMap[e],this._virtualPorts=this._virtualPorts.filter((e=>e!==t))}}else if(r===c.Event.ATTACHED_VIRTUAL_IO){const t=this.getPortNameForPortId(e[7])+this.getPortNameForPortId(e[8]),r=e[3];this._portMap[t]=r,this._virtualPorts.push(r);const n=this._createDevice(i,r);this._attachDevice(n)}}async _sendPortInformationRequest(e){await this.send(i.from([33,e,1]),c.BLECharacteristic.LPF2_ALL),await this.send(i.from([33,e,2]),c.BLECharacteristic.LPF2_ALL)}async _parsePortInformationResponse(e){const t=e[3];if(2===e[4]){const r=[];for(let t=5;t<e.length;t+=2)r.push(e.readUInt16LE(t));return void _(`Port ${(0,u.toHex)(t)}, mode combinations [${r.map((e=>(0,u.toBin)(e,0))).join(", ")}]`)}const r=e[6],i=(0,u.toBin)(e.readUInt16LE(7),r),n=(0,u.toBin)(e.readUInt16LE(9),r);_(`Port ${(0,u.toHex)(t)}, total modes ${r}, input modes ${i}, output modes ${n}`);for(let e=0;e<r;e++)await this._sendModeInformationRequest(t,e,c.ModeInformationType.NAME),await this._sendModeInformationRequest(t,e,c.ModeInformationType.RAW),await this._sendModeInformationRequest(t,e,c.ModeInformationType.PCT),await this._sendModeInformationRequest(t,e,c.ModeInformationType.SI),await this._sendModeInformationRequest(t,e,c.ModeInformationType.SYMBOL),await this._sendModeInformationRequest(t,e,c.ModeInformationType.VALUE_FORMAT)}_sendModeInformationRequest(e,t,r){return this.send(i.from([34,e,t,r]),c.BLECharacteristic.LPF2_ALL)}_parseModeInformationResponse(e){const t=(0,u.toHex)(e[3]),r=e[4];switch(e[5]){case c.ModeInformationType.NAME:_(`Port ${t}, mode ${r}, name ${e.slice(6,e.length).toString()}`);break;case c.ModeInformationType.RAW:_(`Port ${t}, mode ${r}, RAW min ${e.readFloatLE(6)}, max ${e.readFloatLE(10)}`);break;case c.ModeInformationType.PCT:_(`Port ${t}, mode ${r}, PCT min ${e.readFloatLE(6)}, max ${e.readFloatLE(10)}`);break;case c.ModeInformationType.SI:_(`Port ${t}, mode ${r}, SI min ${e.readFloatLE(6)}, max ${e.readFloatLE(10)}`);break;case c.ModeInformationType.SYMBOL:_(`Port ${t}, mode ${r}, SI symbol ${e.slice(6,e.length).toString()}`);break;case c.ModeInformationType.VALUE_FORMAT:const i=e[6],n=["8bit","16bit","32bit","float"][e[7]],o=e[8],s=e[9];_(`Port ${t}, mode ${r}, Value ${i} x ${n}, Decimal format ${o}.${s}`)}}_parsePortAction(e){for(let t=3;t<e.length;t+=2){const r=this._getDeviceByPortId(e[t]);r&&r.finish(e[t+1])}}_parseSensorMessage(e){const t=e[3],r=this._getDeviceByPortId(t);r&&r.receive(e)}}t.LPF2Hub=h},3005:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.Mario=void 0;const s=r(8650),a=o(r(8066)),c=r(7833)("movehub");class u extends s.LPF2Hub{static IsMario(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(a.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===a.BLEManufacturerData.MARIO_ID}constructor(e){super(e,t.PortMap,a.HubType.MARIO),c("Discovered Mario")}async connect(){c("Connecting to Mario"),await super.connect(),c("Connect completed")}}t.Mario=u,t.PortMap={}},7365:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.MoveHub=void 0;const s=r(8385),a=r(8650),c=o(r(8066)),u=r(7833)("movehub");class f extends a.LPF2Hub{static IsMoveHub(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(c.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===c.BLEManufacturerData.MOVE_HUB_ID}constructor(e){super(e,t.PortMap,c.HubType.MOVE_HUB),u("Discovered Move Hub")}async connect(){u("Connecting to Move Hub"),await super.connect(),u("Connect completed")}_checkFirmware(e){if(1===(0,s.compareVersions)("2.0.00.0017",e))throw new Error(`Your Move Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`)}}t.MoveHub=f,t.PortMap={A:0,B:1,C:2,D:3,HUB_LED:50,TILT_SENSOR:58,CURRENT_SENSOR:59,VOLTAGE_SENSOR:60}},7410:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.RemoteControl=void 0;const s=r(8650),a=o(r(8066)),c=r(7833)("remotecontrol");class u extends s.LPF2Hub{static IsRemoteControl(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(a.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===a.BLEManufacturerData.REMOTE_CONTROL_ID}constructor(e){super(e,t.PortMap,a.HubType.REMOTE_CONTROL),c("Discovered Powered UP Remote")}async connect(){c("Connecting to Powered UP Remote"),await super.connect(),c("Connect completed")}}t.RemoteControl=u,t.PortMap={LEFT:0,RIGHT:1,HUB_LED:52,VOLTAGE_SENSOR:59,REMOTE_CONTROL_RSSI:60}},5661:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.TechnicMediumHub=void 0;const s=r(8650),a=o(r(8066)),c=r(7833)("technicmediumhub");class u extends s.LPF2Hub{static IsTechnicMediumHub(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(a.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===a.BLEManufacturerData.TECHNIC_MEDIUM_HUB_ID}constructor(e){super(e,t.PortMap,a.HubType.TECHNIC_MEDIUM_HUB),c("Discovered Control+ Hub")}async connect(){c("Connecting to Control+ Hub"),await super.connect(),c("Connect completed")}}t.TechnicMediumHub=u,t.PortMap={A:0,B:1,C:2,D:3,HUB_LED:50,CURRENT_SENSOR:59,VOLTAGE_SENSOR:60,ACCELEROMETER:97,GYRO_SENSOR:98,TILT_SENSOR:99}},8293:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.TechnicSmallHub=void 0;const s=r(8650),a=o(r(8066)),c=r(7833)("hub");class u extends s.LPF2Hub{static IsTechnicSmallHub(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(a.BLEService.LPF2_HUB.replace(/-/g,""))>=0&&e.advertisement.manufacturerData&&e.advertisement.manufacturerData.length>3&&e.advertisement.manufacturerData[3]===a.BLEManufacturerData.TECHNIC_SMALL_HUB_ID}constructor(e){super(e,t.PortMap,a.HubType.TECHNIC_SMALL_HUB),this._currentPort=59,c("Discovered Spike Essential Hub")}async connect(){c("Connecting to Spike Essential Hub"),await super.connect(),c("Connect completed")}}t.TechnicSmallHub=u,t.PortMap={A:0,B:1,HUB_LED:49,CURRENT_SENSOR:59,VOLTAGE_SENSOR:60,ACCELEROMETER:97,GYRO_SENSOR:98,TILT_SENSOR:99}},5940:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PortMap=t.WeDo2SmartHub=void 0;const a=r(9597),c=s(r(8066)),u=r(6185),f=r(7833)("wedo2smarthub");class l extends a.BaseHub{static IsWeDo2SmartHub(e){return e.advertisement&&e.advertisement.serviceUuids&&e.advertisement.serviceUuids.indexOf(c.BLEService.WEDO2_SMART_HUB.replace(/-/g,""))>=0}constructor(e){super(e,t.PortMap,c.HubType.WEDO2_SMART_HUB),this._lastTiltX=0,this._lastTiltY=0,f("Discovered WeDo 2.0 Smart Hub")}connect(){return new Promise((async e=>{f("Connecting to WeDo 2.0 Smart Hub"),await super.connect(),await this._bleDevice.discoverCharacteristicsForService(c.BLEService.WEDO2_SMART_HUB),await this._bleDevice.discoverCharacteristicsForService(c.BLEService.WEDO2_SMART_HUB_2),u.isWebBluetooth?(await this._bleDevice.discoverCharacteristicsForService("battery_service"),await this._bleDevice.discoverCharacteristicsForService("device_information")):(await this._bleDevice.discoverCharacteristicsForService(c.BLEService.WEDO2_SMART_HUB_3),await this._bleDevice.discoverCharacteristicsForService(c.BLEService.WEDO2_SMART_HUB_4),await this._bleDevice.discoverCharacteristicsForService(c.BLEService.WEDO2_SMART_HUB_5)),f("Connect completed"),this.emit("connect"),e(),this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.WEDO2_PORT_TYPE,this._parsePortMessage.bind(this)),this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.WEDO2_SENSOR_VALUE,this._parseSensorMessage.bind(this)),this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.WEDO2_BUTTON,this._parseSensorMessage.bind(this)),u.isWebBluetooth?(this._bleDevice.readFromCharacteristic("00002a19-0000-1000-8000-00805f9b34fb",((e,t)=>{t&&this._parseBatteryMessage(t)})),this._bleDevice.subscribeToCharacteristic("00002a19-0000-1000-8000-00805f9b34fb",this._parseHighCurrentAlert.bind(this))):(this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.WEDO2_BATTERY,this._parseBatteryMessage.bind(this)),this._bleDevice.readFromCharacteristic(c.BLECharacteristic.WEDO2_BATTERY,((e,t)=>{t&&this._parseBatteryMessage(t)}))),this._bleDevice.subscribeToCharacteristic(c.BLECharacteristic.WEDO2_HIGH_CURRENT_ALERT,this._parseHighCurrentAlert.bind(this)),u.isWebBluetooth?this._bleDevice.readFromCharacteristic("00002a26-0000-1000-8000-00805f9b34fb",((e,t)=>{t&&this._parseFirmwareRevisionString(t)})):this._bleDevice.readFromCharacteristic(c.BLECharacteristic.WEDO2_FIRMWARE_REVISION,((e,t)=>{t&&this._parseFirmwareRevisionString(t)}))}))}shutdown(){return this.send(i.from([0]),c.BLECharacteristic.WEDO2_DISCONNECT)}setName(e){if(e.length>14)throw new Error("Name must be 14 characters or less");return new Promise((t=>{const r=i.from(e,"ascii");return this.send(r,c.BLECharacteristic.WEDO2_NAME_ID),this.send(r,c.BLECharacteristic.WEDO2_NAME_ID),this._name=e,t()}))}send(e,t){return f.enabled&&f(`Sent Message (${this._getCharacteristicNameFromUUID(t)})`,e),this._bleDevice.writeToCharacteristic(t,e)}subscribe(e,t,r){this.send(i.from([1,2,e,t,r,1,0,0,0,0,1]),c.BLECharacteristic.WEDO2_PORT_TYPE_WRITE)}unsubscribe(e,t,r){this.send(i.from([1,2,e,t,r,1,0,0,0,0,0]),c.BLECharacteristic.WEDO2_PORT_TYPE_WRITE)}_getCharacteristicNameFromUUID(e){const t=Object.keys(c.BLECharacteristic);for(let r=0;r<t.length;r++){const i=t[r];if(c.BLECharacteristic[i]===e)return i}return"UNKNOWN"}_parseHighCurrentAlert(e){f("Received Message (WEDO2_HIGH_CURRENT_ALERT)",e)}_parseBatteryMessage(e){f("Received Message (WEDO2_BATTERY)",e);const t=e[0];t!==this._batteryLevel&&(this._batteryLevel=t,this.emit("batteryLevel",{batteryLevel:t}))}_parseFirmwareRevisionString(e){f("Received Message (WEDO2_FIRMWARE_REVISION)",e),this._firmwareVersion=e.toString()}_parsePortMessage(e){f("Received Message (WEDO2_PORT_TYPE)",e);const t=e[0],r=e[1],i=r?e[3]:0;if(1===r){const e=this._createDevice(i,t);this._attachDevice(e)}else if(0===r){const e=this._getDeviceByPortId(t);e&&this._detachDevice(e)}}_parseSensorMessage(e){if(f("Received Message (WEDO2_SENSOR_VALUE)",e),1===e[0])return void this.emit("button",{event:c.ButtonState.PRESSED});if(0===e[0])return void this.emit("button",{event:c.ButtonState.RELEASED});const t=e[1],r=this._getDeviceByPortId(t);r&&r.receive(e)}}t.WeDo2SmartHub=l,t.PortMap={A:1,B:2,CURRENT_SENSOR:3,VOLTAGE_SENSOR:4,PIEZO_BUZZER:5,HUB_LED:6}},1681:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});const s=o(r(8066)),a=r(8440),c=r(8359),u=r(9597),f=r(8062),l=r(1718),_=r(3005),h=r(7365),d=r(7410),p=r(5661),E=r(5940),O=r(5466),T=r(3839),b=r(3124),v=r(692),M=r(1940),y=r(5636),R=r(1472),m=r(1422),S=r(9128),g=r(9823),I=r(5530),A=r(8941),D=r(4081),L=r(8055),C=r(87),P=r(8693),N=r(9161),B=r(6719),w=r(381),U=r(3488),H=r(3281),j=r(1188),F=r(4230),W=r(8971),G=r(2835),x=r(5039),V=r(4843),k=r(3164),Y=r(5047),$=r(717),K=r(9152),z=r(7508),X=r(42),q=r(5373),Z=r(6185);window.PoweredUP={PoweredUP:a.PoweredUP,BaseHub:u.BaseHub,WeDo2SmartHub:E.WeDo2SmartHub,TechnicMediumHub:p.TechnicMediumHub,Hub:l.Hub,RemoteControl:d.RemoteControl,DuploTrainBase:f.DuploTrainBase,Consts:s,Color:c.Color,ColorDistanceSensor:O.ColorDistanceSensor,Device:b.Device,DuploTrainBaseColorSensor:v.DuploTrainBaseColorSensor,DuploTrainBaseMotor:M.DuploTrainBaseMotor,DuploTrainBaseSpeaker:y.DuploTrainBaseSpeaker,DuploTrainBaseSpeedometer:R.DuploTrainBaseSpeedometer,HubLED:m.HubLED,Light:S.Light,Mario:_.Mario,MediumLinearMotor:g.MediumLinearMotor,MotionSensor:I.MotionSensor,MoveHub:h.MoveHub,MoveHubMediumLinearMotor:A.MoveHubMediumLinearMotor,MoveHubTiltSensor:D.MoveHubTiltSensor,PiezoBuzzer:L.PiezoBuzzer,RemoteControlButton:C.RemoteControlButton,SimpleMediumLinearMotor:P.SimpleMediumLinearMotor,TechnicColorSensor:N.TechnicColorSensor,TechnicDistanceSensor:B.TechnicDistanceSensor,TechnicForceSensor:w.TechnicForceSensor,TechnicMediumHubAccelerometerSensor:W.TechnicMediumHubAccelerometerSensor,TechnicMediumHubGyroSensor:G.TechnicMediumHubGyroSensor,TechnicMediumHubTiltSensor:x.TechnicMediumHubTiltSensor,TechnicSmallAngularMotor:j.TechnicSmallAngularMotor,TechnicMediumAngularMotor:F.TechnicMediumAngularMotor,TechnicLargeAngularMotor:U.TechnicLargeAngularMotor,TechnicLargeLinearMotor:H.TechnicLargeLinearMotor,TechnicXLargeLinearMotor:V.TechnicXLargeLinearMotor,Technic3x3ColorLightMatrix:k.Technic3x3ColorLightMatrix,TiltSensor:Y.TiltSensor,TrainMotor:$.TrainMotor,VoltageSensor:K.VoltageSensor,CurrentSensor:T.CurrentSensor,TachoMotor:z.TachoMotor,AbsoluteMotor:X.AbsoluteMotor,BasicMotor:q.BasicMotor,isWebBluetooth:Z.isWebBluetooth}},8440:function(e,t,r){"use strict";var i=r(8287).hp,n=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PoweredUP=void 0;const a=r(3613),c=r(8062),u=r(1718),f=r(3005),l=r(7365),_=r(7410),h=r(5661),d=r(5940),p=s(r(8066)),E=r(7007),O=r(7833),T=r(8293),b=O("poweredup");class v extends E.EventEmitter{constructor(){super(),this._connectedHubs={},this._discoveryEventHandler=this._discoveryEventHandler.bind(this)}async scan(){try{const e=await navigator.bluetooth.requestDevice({filters:[{services:[p.BLEService.WEDO2_SMART_HUB]},{services:[p.BLEService.LPF2_HUB]}],optionalServices:[p.BLEService.WEDO2_SMART_HUB_2,"battery_service","device_information"]}),t=await e.gatt.connect();return this._discoveryEventHandler.call(this,t),!0}catch(e){return!1}}getHubs(){return Object.values(this._connectedHubs)}getHubByUUID(e){return this._connectedHubs[e]}getHubByPrimaryMACAddress(e){return Object.values(this._connectedHubs).filter((t=>t.primaryMACAddress===e))[0]}getHubsByName(e){return Object.values(this._connectedHubs).filter((t=>t.name===e))}getHubsByType(e){return Object.values(this._connectedHubs).filter((t=>t.type===e))}_determineLPF2HubType(e){return new Promise((async t=>{let r=i.alloc(0);await e.subscribeToCharacteristic(p.BLECharacteristic.LPF2_ALL,(n=>{for(r=i.concat([r,n]);r[0]<=r.length;){const i=r[0],n=r.slice(0,i);if(r=r.slice(i),1===n[2]&&11===n[3]){switch(n[5]){case p.BLEManufacturerData.REMOTE_CONTROL_ID:t(p.HubType.REMOTE_CONTROL);break;case p.BLEManufacturerData.MOVE_HUB_ID:t(p.HubType.MOVE_HUB);break;case p.BLEManufacturerData.HUB_ID:t(p.HubType.HUB);break;case p.BLEManufacturerData.DUPLO_TRAIN_BASE_ID:t(p.HubType.DUPLO_TRAIN_BASE);break;case p.BLEManufacturerData.TECHNIC_SMALL_HUB_ID:t(p.HubType.TECHNIC_SMALL_HUB);break;case p.BLEManufacturerData.TECHNIC_MEDIUM_HUB_ID:t(p.HubType.TECHNIC_MEDIUM_HUB);break;case p.BLEManufacturerData.MARIO_ID:t(p.HubType.MARIO)}b("Hub type determined")}else b("Stashed in mailbox (LPF2_ALL)",n),e.addToCharacteristicMailbox(p.BLECharacteristic.LPF2_ALL,n)}})),e.writeToCharacteristic(p.BLECharacteristic.LPF2_ALL,i.from([5,0,1,11,5]))}))}async _discoveryEventHandler(e){const t=new a.WebBLEDevice(e);let r,i=p.HubType.UNKNOWN,n=!1;try{await t.discoverCharacteristicsForService(p.BLEService.WEDO2_SMART_HUB),i=p.HubType.WEDO2_SMART_HUB}catch(e){}try{i!==p.HubType.WEDO2_SMART_HUB&&(await t.discoverCharacteristicsForService(p.BLEService.LPF2_HUB),n=!0)}catch(e){}switch(n&&(i=await this._determineLPF2HubType(t)),i){case p.HubType.WEDO2_SMART_HUB:r=new d.WeDo2SmartHub(t);break;case p.HubType.MOVE_HUB:r=new l.MoveHub(t);break;case p.HubType.HUB:r=new u.Hub(t);break;case p.HubType.REMOTE_CONTROL:r=new _.RemoteControl(t);break;case p.HubType.DUPLO_TRAIN_BASE:r=new c.DuploTrainBase(t);break;case p.HubType.TECHNIC_SMALL_HUB:r=new T.TechnicSmallHub(t);break;case p.HubType.TECHNIC_MEDIUM_HUB:r=new h.TechnicMediumHub(t);break;case p.HubType.MARIO:r=new f.Mario(t);break;default:return}t.on("discoverComplete",(()=>{r.on("connect",(()=>{b(`Hub ${r.uuid} connected`),this._connectedHubs[r.uuid]=r})),r.on("disconnect",(()=>{b(`Hub ${r.uuid} disconnected`),delete this._connectedHubs[r.uuid]})),b(`Hub ${r.uuid} discovered`),this.emit("discover",r)}))}}t.PoweredUP=v},6185:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseColor=t.calculateRamp=t.roundAngleToNearest90=t.normalizeAngle=t.decodeMACAddress=t.decodeVersion=t.mapSpeed=t.toBin=t.toHex=t.isWebBluetooth=void 0;const i=r(7007);t.isWebBluetooth=!("undefined"==typeof navigator||!navigator||!navigator.bluetooth),t.toHex=(e,t=2)=>e.toString(16).padStart(t,"0"),t.toBin=(e,t=8)=>e.toString(2).padStart(t,"0"),t.mapSpeed=e=>127===e?127:(e>100?e=100:e<-100&&(e=-100),e),t.decodeVersion=e=>{const t=e.toString(16).padStart(8,"0");return[t[0],t[1],t.substring(2,4),t.substring(4)].join(".")},t.decodeMACAddress=e=>Array.from(e).map((e=>(0,t.toHex)(e,2))).join(":"),t.normalizeAngle=e=>e>=180?e-(e+180)/360*360:e<-180?e+(180-e)/360*360:e,t.roundAngleToNearest90=e=>(e=(0,t.normalizeAngle)(e))<-135?-180:e<-45?-90:e<45?0:e<135?90:-180,t.calculateRamp=(e,t,r,n)=>{const o=new i.EventEmitter,s=Math.abs(r-t);let a=n/s,c=1;a<50&&s>0&&(c=50/a,a=50),t>r&&(c=-c);let u=0;const f=setInterval((()=>{let e=Math.round(t+ ++u*c);(r>t&&e>r||t>r&&e<r)&&(e=r),o.emit("changePower",e),e===r&&(clearInterval(f),o.emit("finished"))}),a);return e.setEventTimer(f),o},t.parseColor=e=>(1!==e&&5!==e||(e+=1),e)},3613:(e,t,r)=>{"use strict";var i=r(8287).hp;Object.defineProperty(t,"__esModule",{value:!0}),t.WebBLEDevice=void 0;const n=r(7833),o=r(7007),s=n("bledevice");class a extends o.EventEmitter{constructor(e){super(),this._name="",this._listeners={},this._characteristics={},this._queue=Promise.resolve(),this._mailbox=[],this._connected=!1,this._connecting=!1,this._webBLEServer=e,this._uuid=e.device.id,this._name=e.device.name,e.device.addEventListener("gattserverdisconnected",(()=>{this._connecting=!1,this._connected=!1,this.emit("disconnect")})),setTimeout((()=>{this.emit("discoverComplete")}),2e3)}get uuid(){return this._uuid}get name(){return this._name}get connecting(){return this._connecting}get connected(){return this._connected}connect(){return new Promise((e=>(this._connected=!0,e())))}disconnect(){return new Promise((e=>(this._webBLEServer.device.gatt.disconnect(),this._connected=!1,e())))}async discoverCharacteristicsForService(e){s("Service/characteristic discovery started");const t=await this._webBLEServer.getPrimaryService(e),r=await t.getCharacteristics();for(const e of r)this._characteristics[e.uuid]=e;s("Service/characteristic discovery finished")}subscribeToCharacteristic(e,t){this._listeners[e]&&this._characteristics[e].removeEventListener("characteristicvaluechanged",this._listeners[e]),this._listeners[e]=e=>{const r=i.alloc(e.target.value.buffer.byteLength),n=new Uint8Array(e.target.value.buffer);for(let e=0;e<r.length;e++)r[e]=n[e];return s("Incoming data",r),t(r)},this._characteristics[e].addEventListener("characteristicvaluechanged",this._listeners[e]);const r=Array.from(this._mailbox);this._mailbox=[];for(const e of r)s("Replayed from mailbox (LPF2_ALL)",e),t(e);return this._characteristics[e].startNotifications()}addToCharacteristicMailbox(e,t){this._mailbox.push(t)}readFromCharacteristic(e,t){this._characteristics[e].readValue().then((e=>{const r=i.alloc(e.buffer.byteLength),n=new Uint8Array(e.buffer);for(let e=0;e<r.length;e++)r[e]=n[e];t(null,r)}))}writeToCharacteristic(e,t){return this._queue=this._queue.then((()=>this._characteristics[e].writeValueWithoutResponse(t)))}_sanitizeUUID(e){return e.replace(/-/g,"")}}t.WebBLEDevice=a}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var o=t[i]={exports:{}};return e[i].call(o.exports,o,o.exports,r),o.exports}r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(1681)})();
|
|
3
3
|
//# sourceMappingURL=poweredup.js.map
|