@makefully/engagefully 0.4.1 → 0.4.2

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/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.4.2] - 2026-12-02
8
+
9
+ ### Changed
10
+
11
+ - Slim webpack config (JS-only babel-loader; drop unused asset `file-loader` rules)
12
+ - Babel preset-env follows package `browserslist` (single target source of truth)
13
+ - Refresh `@babel/core`, `@babel/preset-env`, and `babel-loader`; remove unused `file-loader`
14
+ - Align CI Node to 24 (same as release); release workflow continues to run `npm test` before publish
15
+
7
16
  ## [0.4.1] - 2026-12-02
8
17
 
9
18
  ### Changed
@@ -1 +1 @@
1
- (()=>{"use strict";var e={665:(e,t,n)=>{var i=n(187),r=n.n(i);Promise.resolve(!1),Promise.resolve(!0);var o=Promise.resolve();function s(e,t){return e||(e=0),new Promise(function(n){return setTimeout(function(){return n(t)},e)})}function a(){return Math.random().toString(36).substring(2)}var c=0,l=0;function u(){var e=(new Date).getTime();return e===c?1e3*e+ ++l:(c=e,l=0,1e3*e)}var d="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);const h={create:function(e){var t={messagesCallback:null,bc:new BroadcastChannel(e),subFns:[]};return t.bc.onmessage=function(e){t.messagesCallback&&t.messagesCallback(e.data)},t},close:function(e){e.bc.close(),e.subFns=[]},onMessage:function(e,t){e.messagesCallback=t},postMessage:function(e,t){try{return e.bc.postMessage(t,!1),o}catch(e){return Promise.reject(e)}},canBeUsed:function(){if(d&&"undefined"==typeof window)return!1;if("function"==typeof BroadcastChannel){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}return!1},type:"native",averageResponseTime:function(){return 150},microSeconds:u};var f=function(){function e(e){this.ttl=e,this.set=new Set,this.timeMap=new Map}return e.prototype.has=function(e){return this.set.has(e)},e.prototype.add=function(e){var t=this;this.timeMap.set(e,p()),this.set.add(e),setTimeout(function(){!function(e){for(var t=p()-e.ttl,n=e.set[Symbol.iterator]();;){var i=n.next().value;if(!i)return;if(!(e.timeMap.get(i)<t))return;e.timeMap.delete(i),e.set.delete(i)}}(t)},0)},e.prototype.clear=function(){this.set.clear(),this.timeMap.clear()},e}();function p(){return(new Date).getTime()}function b(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=JSON.parse(JSON.stringify(e));return void 0===t.webWorkerSupport&&(t.webWorkerSupport=!0),t.idb||(t.idb={}),t.idb.ttl||(t.idb.ttl=45e3),t.idb.fallbackInterval||(t.idb.fallbackInterval=150),e.idb&&"function"==typeof e.idb.onclose&&(t.idb.onclose=e.idb.onclose),t.localstorage||(t.localstorage={}),t.localstorage.removeTimeout||(t.localstorage.removeTimeout=6e4),e.methods&&(t.methods=e.methods),t.node||(t.node={}),t.node.ttl||(t.node.ttl=12e4),t.node.maxParallelWrites||(t.node.maxParallelWrites=2048),void 0===t.node.useFastPath&&(t.node.useFastPath=!0),t}var v="messages";function _(){if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof window){if(void 0!==window.mozIndexedDB)return window.mozIndexedDB;if(void 0!==window.webkitIndexedDB)return window.webkitIndexedDB;if(void 0!==window.msIndexedDB)return window.msIndexedDB}return!1}function m(e){e.closed||g(e).then(function(){return s(e.options.idb.fallbackInterval)}).then(function(){return m(e)})}function g(e){return e.closed?o:e.messagesCallback?(t=e.db,n=e.lastCursorId,i=t.transaction(v).objectStore(v),r=[],new Promise(function(e){(function(){try{var e=IDBKeyRange.bound(n+1,1/0);return i.openCursor(e)}catch(e){return i.openCursor()}}()).onsuccess=function(t){var i=t.target.result;i?i.value.id<n+1?i.continue(n+1):(r.push(i.value),i.continue()):e(r)}})).then(function(t){var n=t.filter(function(e){return!!e}).map(function(t){return t.id>e.lastCursorId&&(e.lastCursorId=t.id),t}).filter(function(t){return function(e,t){return!(e.uuid===t.uuid||t.eMIs.has(e.id)||e.data.time<t.messagesCallbackTime)}(t,e)}).sort(function(e,t){return e.time-t.time});return n.forEach(function(t){e.messagesCallback&&(e.eMIs.add(t.id),e.messagesCallback(t.data))}),o}):o;var t,n,i,r}const y={create:function(e,t){return t=b(t),function(e){var t="pubkey.broadcast-channel-0-"+e,n=_().open(t,1);return n.onupgradeneeded=function(e){e.target.result.createObjectStore(v,{keyPath:"id",autoIncrement:!0})},new Promise(function(e,t){n.onerror=function(e){return t(e)},n.onsuccess=function(){e(n.result)}})}(e).then(function(n){var i={closed:!1,lastCursorId:0,channelName:e,options:t,uuid:a(),eMIs:new f(2*t.idb.ttl),writeBlockPromise:o,messagesCallback:null,readQueuePromises:[],db:n};return n.onclose=function(){i.closed=!0,t.idb.onclose&&t.idb.onclose()},m(i),i})},close:function(e){e.closed=!0,e.db.close()},onMessage:function(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t,g(e)},postMessage:function(e,t){return e.writeBlockPromise=e.writeBlockPromise.then(function(){return function(e,t,n){var i={uuid:t,time:(new Date).getTime(),data:n},r=e.transaction([v],"readwrite");return new Promise(function(e,t){r.oncomplete=function(){return e()},r.onerror=function(e){return t(e)},r.objectStore(v).add(i)})}(e.db,e.uuid,t)}).then(function(){var t,n;0===Math.floor(11*Math.random()+0)&&(t=e.db,n=e.options.idb.ttl,function(e,t){var n=(new Date).getTime()-t,i=e.transaction(v).objectStore(v),r=[];return new Promise(function(e){i.openCursor().onsuccess=function(t){var i=t.target.result;if(i){var o=i.value;if(!(o.time<n))return void e(r);r.push(o),i.continue()}else e(r)}})}(t,n).then(function(e){return Promise.all(e.map(function(e){return function(e,t){var n=e.transaction([v],"readwrite").objectStore(v).delete(t);return new Promise(function(e){n.onsuccess=function(){return e()}})}(t,e.id)}))}))}),e.writeBlockPromise},canBeUsed:function(){return!d&&!!_()},type:"idb",averageResponseTime:function(e){return 2*e.idb.fallbackInterval},microSeconds:u};function w(){var e;if("undefined"==typeof window)return null;try{e=window.localStorage,e=window["ie8-eventlistener/storage"]||window.localStorage}catch(e){}return e}function x(e){return"pubkey.broadcastChannel-"+e}function P(){if(d)return!1;var e=w();if(!e)return!1;try{var t="__broadcastchannel_check";e.setItem(t,"works"),e.removeItem(t)}catch(e){return!1}return!0}const E={create:function(e,t){if(t=b(t),!P())throw new Error("BroadcastChannel: localstorage cannot be used");var n=a(),i=new f(t.localstorage.removeTimeout),r={channelName:e,uuid:n,eMIs:i};return r.listener=function(e){var t=x(e),o=function(e){var o;e.key===t&&(o=JSON.parse(e.newValue),r.messagesCallback&&o.uuid!==n&&o.token&&!i.has(o.token)&&(o.data.time&&o.data.time<r.messagesCallbackTime||(i.add(o.token),r.messagesCallback(o.data))))};return window.addEventListener("storage",o),o}(e),r},close:function(e){var t;t=e.listener,window.removeEventListener("storage",t)},onMessage:function(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t},postMessage:function(e,t){return new Promise(function(n){s().then(function(){var i=x(e.channelName),r={token:a(),time:(new Date).getTime(),data:t,uuid:e.uuid},o=JSON.stringify(r);w().setItem(i,o);var s=document.createEvent("Event");s.initEvent("storage",!0,!0),s.key=i,s.newValue=o,window.dispatchEvent(s),n()})})},canBeUsed:P,type:"localstorage",averageResponseTime:function(){var e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")?240:120},microSeconds:u};var L=u,T=new Set;const S={create:function(e){var t={name:e,messagesCallback:null};return T.add(t),t},close:function(e){T.delete(e)},onMessage:function(e,t){e.messagesCallback=t},postMessage:function(e,t){return new Promise(function(n){return setTimeout(function(){Array.from(T).filter(function(t){return t.name===e.name}).filter(function(t){return t!==e}).filter(function(e){return!!e.messagesCallback}).forEach(function(e){return e.messagesCallback(t)}),n()},5)})},canBeUsed:function(){return!0},type:"simulate",averageResponseTime:function(){return 5},microSeconds:L};var C=[h,y,E],O=new Set,M=0,D=function(e,t){var n,i,r;this.id=M++,O.add(this),this.name=e,this.options=b(t),this.method=function(e){var t=[].concat(e.methods,C).filter(Boolean);if(e.type){if("simulate"===e.type)return S;var n=t.find(function(t){return t.type===e.type});if(n)return n;throw new Error("method-type "+e.type+" not found")}e.webWorkerSupport||d||(t=t.filter(function(e){return"idb"!==e.type}));var i=t.find(function(e){return e.canBeUsed()});if(i)return i;throw new Error("No useable method found in "+JSON.stringify(C.map(function(e){return e.type})))}(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._uMP=new Set,this._befC=[],this._prepP=null,(r=i=(n=this).method.create(n.name,n.options))&&"function"==typeof r.then?(n._prepP=i,i.then(function(e){n._state=e})):n._state=i};function k(e,t,n){var i={time:e.method.microSeconds(),type:t,data:n};return(e._prepP?e._prepP:o).then(function(){var t=e.method.postMessage(e._state,i);return e._uMP.add(t),t.catch().then(function(){return e._uMP.delete(t)}),t})}function B(e){return e._addEL.message.length>0||e._addEL.internal.length>0}function R(e,t,n){e._addEL[t].push(n),function(e){if(!e._iL&&B(e)){var t=function(t){e._addEL[t.type].forEach(function(e){var n=e.time-1e5;t.time>=n&&e.fn(t.data)})},n=e.method.microSeconds();e._prepP?e._prepP.then(function(){e._iL=!0,e.method.onMessage(e._state,t,n)}):(e._iL=!0,e.method.onMessage(e._state,t,n))}}(e)}function j(e,t,n){e._addEL[t]=e._addEL[t].filter(function(e){return e!==n}),function(e){if(e._iL&&!B(e)){e._iL=!1;var t=e.method.microSeconds();e.method.onMessage(e._state,null,t)}}(e)}function I(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function A(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}D._pubkey=!0,D.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(e));return k(this,"message",e)},postInternal:function(e){return k(this,"internal",e)},set onmessage(e){var t={time:this.method.microSeconds(),fn:e};j(this,"message",this._onML),e&&"function"==typeof e?(this._onML=t,R(this,"message",t)):this._onML=null},addEventListener:function(e,t){R(this,e,{time:this.method.microSeconds(),fn:t})},removeEventListener:function(e,t){j(this,e,this._addEL[e].find(function(e){return e.fn===t}))},close:function(){var e=this;if(!this.closed){O.delete(this),this.closed=!0;var t=this._prepP?this._prepP:o;return this._onML=null,this._addEL.message=[],t.then(function(){return Promise.all(Array.from(e._uMP))}).then(function(){return Promise.all(e._befC.map(function(e){return e()}))}).then(function(){return e.method.close(e._state)})}},get type(){return this.method.type},get isClosed(){return this.closed}};const N={Amount:class{constructor(e){this.control=e,this.value=0}update(e,t){let n=!1;e.value!==this.value&&(n=!0,this.value=e.value),n&&t.emit(this.control,e,this)}},Button:class{constructor(e){this.control=e,this.value=0}update(e,t){e.value!==this.value&&(this.value=e.value,1===this.value&&t.emit(`${this.control}:pressed`,e,this),0===this.value&&t.emit(`${this.control}:released`,e,this),t.emit(this.control,e,this))}poll(){return this.value}toJSON(){return{control:this.control,type:"Button",value:this.value}}},Data:class{constructor(e){this.control=e,this.value=null}update(e,t){this.value=e.value,t.emit(this.control,e,this)}},Dial:class{constructor(e){this.control=e,this.value=0}update(e,t){e.value!==this.value&&(this.value=e.value,t.emit(this.control,e,this))}},Drop:class{constructor(e){this.control=e,this.value="",this.x=0,this.y=0}update(e,t){e.value===this.value&&e.x===this.x&&e.y===this.y||(this.value=e.value,this.x=e.x,this.y=e.y,t.emit(this.control,e,this))}},PageAction:class{constructor(e,t="PageDevice"){const n=e.devices||e;this.channel=new D(t),n.forEach(e=>{e.on("updated",e=>{const n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?I(Object(n),!0).forEach(function(t){A(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):I(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},e);n.device=`${t}-${e.device}`,n.control=`Page${e.control}`,delete n.target,delete n.event,this.channel.postMessage(n)})})}},Pointer:class{constructor(e){this.control=e,this.value=0,this.x=0,this.y=0}update(e,t){e.value===this.value&&e.x===this.x&&e.y===this.y||(this.value=e.value,this.x=e.x,this.y=e.y,t.emit(this.control,e,this))}},Joystick:class{constructor(e){this.control=e,this.x=0,this.y=0}update(e,t){e.x===this.x&&e.y===this.y||(this.x=e.x,this.y=e.y,t.emit(this.control,e,this))}}};function F(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function W(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?F(Object(n),!0).forEach(function(t){U(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):F(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function U(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const $=new Set(["mouse","touch","pen"]);class z extends(r()){constructor(e=[],t={}){super(),this.devices=[],this.controls={},this.inputPrecedence=[],this.controlMap=W(W({},N),t),e.forEach(e=>this.addDevice(e))}get preferredInput(){return this.inputPrecedence[0]||null}noteInput(e){if(!e||e===this.inputPrecedence[0])return;const t=this.inputPrecedence.indexOf(e);t>0&&this.inputPrecedence.splice(t,1),this.inputPrecedence.unshift(e),this.emit("input-precedence-updated",this.inputPrecedence)}addControl(e,t){const n=this.controlMap[t];if(n)return this.controls[e]=new n(e);{const n=this.controls[e]=new this.controlMap.Data(e);return console.warn(`${e}: "${t}" has no associated control class. Using 'Data'.`),n}}addDevice(e){this.devices.push(e),e.on("input-activity",e=>{this.noteInput(e)}),e.on("updated",t=>{const n=function(e,t){if(null!=t&&t.inputMethod)return t.inputMethod;const n=null==e?void 0:e.inputMethod;if("pointer"===n){var i;const e=null==t||null===(i=t.event)||void 0===i?void 0:i.pointerType;return $.has(e)?e:"pointer"}return n||null}(e,t);n&&this.noteInput(n);const i=t.control;let r=this.controls[i];(r||(r=this.addControl(i,t.type),r))&&r.update(t,this)})}getControl(e,t){let n=this.controls[e];return!n&&t&&(n=this.addControl(e,t)),n}poll(e){var t,n;return null===(t=this.controls[e])||void 0===t||null===(n=t.poll)||void 0===n?void 0:n.call(t)}}const Z=z;function q(e){return"string"==typeof e?{control:e,data:void 0}:{control:e.control,data:e.data}}function J(e){return e.startsWith("Key")||e.startsWith("Arrow")||e.startsWith("Digit")||e.startsWith("Numpad")||"Space"===e||"Enter"===e||"Escape"===e||"Tab"===e||"Backspace"===e||"ShiftLeft"===e||"ShiftRight"===e||"ControlLeft"===e||"ControlRight"===e||"AltLeft"===e||"AltRight"===e}class K extends(r()){constructor(e,t={},n={}){if(super(),this.controller=e,this.enabled="function"==typeof n.enabled?n.enabled:()=>!0,this.preventDefault=!1!==n.preventDefault,this.autoTick=!1!==n.autoTick,this._bindings=new Map,this._controlIndex=new Map,this._heldByAction=new Map,this._lastEvent=new Map,this._listeners=[],this._disposed=!1,this._wasEnabled=!0,this._raf=0,this._applyBindings(t),this.preventDefault&&(this._onKeyDownCapture=e=>{this.enabled()&&this._keyboardCodes.has(e.code)&&e.preventDefault()},window.addEventListener("keydown",this._onKeyDownCapture,!0)),this._onBlur=()=>{this.clearHeld()},window.addEventListener("blur",this._onBlur),this.autoTick){const e=()=>{this._disposed||(this._raf=requestAnimationFrame(e),this._tick())};this._raf=requestAnimationFrame(e)}}_applyBindings(e){this._keyboardCodes=new Set;for(const[t,n]of Object.entries(e)){const e=(n||[]).map(q);this._bindings.set(t,e),this._heldByAction.set(t,new Set);for(const n of e){J(n.control)&&this._keyboardCodes.add(n.control);let e=this._controlIndex.get(n.control);e||(e=[],this._controlIndex.set(n.control,e)),e.push({action:t,data:n.data});const i=e=>this._onPhysicalPressed(n.control,e),r=e=>this._onPhysicalReleased(n.control,e);this.controller.on(`${n.control}:pressed`,i),this.controller.on(`${n.control}:released`,r),this._listeners.push({event:`${n.control}:pressed`,fn:i},{event:`${n.control}:released`,fn:r})}}}_isEnabled(){const e=this.enabled();return this._wasEnabled&&!e&&this.clearHeld(),this._wasEnabled=e,e}_onPhysicalPressed(e,t){if(!this._isEnabled())return;const n=this._controlIndex.get(e);if(n)for(const{action:i,data:r}of n){const n=this._heldByAction.get(i),o=0===n.size;n.add(e);const s={action:i,control:e,data:r,device:null==t?void 0:t.device,raw:t};this._lastEvent.set(i,s),o&&this.emit(`${i}:pressed`,s),this.emit(i,s)}}_onPhysicalReleased(e,t){const n=this._controlIndex.get(e);if(n)for(const{action:i,data:r}of n){const n=this._heldByAction.get(i);if(!n.has(e))continue;n.delete(e);const o={action:i,control:e,data:r,device:null==t?void 0:t.device,raw:t};if(0===n.size)this._lastEvent.delete(i),this.emit(`${i}:released`,o);else{const e=this._bindings.get(i)||[];for(const r of e)if(n.has(r.control)){this._lastEvent.set(i,{action:i,control:r.control,data:r.data,device:null==t?void 0:t.device,raw:t});break}}}}_tick(){if(this._isEnabled())for(const[e,t]of this._heldByAction){if(0===t.size)continue;const n=this._lastEvent.get(e);n&&this.emit(`${e}:held`,n)}}held(e){const t=this._heldByAction.get(e);return Boolean(t&&t.size>0)}heldEvent(e){return this.held(e)&&this._lastEvent.get(e)||null}clearHeld(){for(const[e,t]of this._heldByAction){if(0===t.size)continue;const n=this._lastEvent.get(e);t.clear(),this._lastEvent.delete(e),this.emit(`${e}:released`,n||{action:e,control:null,data:void 0})}}dispose(){if(!this._disposed){this._disposed=!0,cancelAnimationFrame(this._raf);for(const{event:e,fn:t}of this._listeners)this.controller.off(e,t);this._listeners.length=0,this._onKeyDownCapture&&window.removeEventListener("keydown",this._onKeyDownCapture,!0),window.removeEventListener("blur",this._onBlur),this.removeAllListeners()}}}const H=K,V=JSON.parse('{"00002a7e-0000-1000-8000-00805f9b34fb":"aerobic_heart_rate_lower_limit","00002a84-0000-1000-8000-00805f9b34fb":"aerobic_heart_rate_upper_limit","00002a7f-0000-1000-8000-00805f9b34fb":"aerobic_threshold","00002a80-0000-1000-8000-00805f9b34fb":"age","00002a5a-0000-1000-8000-00805f9b34fb":"aggregate","00002a43-0000-1000-8000-00805f9b34fb":"alert_category_id","00002a42-0000-1000-8000-00805f9b34fb":"alert_category_id_bit_mask","00002a06-0000-1000-8000-00805f9b34fb":"alert_level","00002a44-0000-1000-8000-00805f9b34fb":"alert_notification_control_point","00002a3f-0000-1000-8000-00805f9b34fb":"alert_status","00002ab3-0000-1000-8000-00805f9b34fb":"altitude","00002a81-0000-1000-8000-00805f9b34fb":"anaerobic_heart_rate_lower_limit","00002a82-0000-1000-8000-00805f9b34fb":"anaerobic_heart_rate_upper_limit","00002a83-0000-1000-8000-00805f9b34fb":"anaerobic_threshold","00002a58-0000-1000-8000-00805f9b34fb":"analog","00002a73-0000-1000-8000-00805f9b34fb":"apparent_wind_direction","00002a72-0000-1000-8000-00805f9b34fb":"apparent_wind_speed","00002a01-0000-1000-8000-00805f9b34fb":"gap.appearance","00002aa3-0000-1000-8000-00805f9b34fb":"barometric_pressure_trend","00002a19-0000-1000-8000-00805f9b34fb":"battery_level","00002a49-0000-1000-8000-00805f9b34fb":"blood_pressure_feature","00002a35-0000-1000-8000-00805f9b34fb":"blood_pressure_measurement","00002a9b-0000-1000-8000-00805f9b34fb":"body_composition_feature","00002a9c-0000-1000-8000-00805f9b34fb":"body_composition_measurement","00002a38-0000-1000-8000-00805f9b34fb":"body_sensor_location","00002aa4-0000-1000-8000-00805f9b34fb":"bond_management_control_point","00002aa5-0000-1000-8000-00805f9b34fb":"bond_management_feature","00002a22-0000-1000-8000-00805f9b34fb":"boot_keyboard_input_report","00002a32-0000-1000-8000-00805f9b34fb":"boot_keyboard_output_report","00002a33-0000-1000-8000-00805f9b34fb":"boot_mouse_input_report","00002aa6-0000-1000-8000-00805f9b34fb":"gap.central_address_resolution_support","00002aa8-0000-1000-8000-00805f9b34fb":"cgm_feature","00002aa7-0000-1000-8000-00805f9b34fb":"cgm_measurement","00002aab-0000-1000-8000-00805f9b34fb":"cgm_session_run_time","00002aaa-0000-1000-8000-00805f9b34fb":"cgm_session_start_time","00002aac-0000-1000-8000-00805f9b34fb":"cgm_specific_ops_control_point","00002aa9-0000-1000-8000-00805f9b34fb":"cgm_status","00002a5c-0000-1000-8000-00805f9b34fb":"csc_feature","00002a5b-0000-1000-8000-00805f9b34fb":"csc_measurement","00002a2b-0000-1000-8000-00805f9b34fb":"current_time","00002a66-0000-1000-8000-00805f9b34fb":"cycling_power_control_point","00002a65-0000-1000-8000-00805f9b34fb":"cycling_power_feature","00002a63-0000-1000-8000-00805f9b34fb":"cycling_power_measurement","00002a64-0000-1000-8000-00805f9b34fb":"cycling_power_vector","00002a99-0000-1000-8000-00805f9b34fb":"database_change_increment","00002a85-0000-1000-8000-00805f9b34fb":"date_of_birth","00002a86-0000-1000-8000-00805f9b34fb":"date_of_threshold_assessment","00002a08-0000-1000-8000-00805f9b34fb":"date_time","00002a0a-0000-1000-8000-00805f9b34fb":"day_date_time","00002a09-0000-1000-8000-00805f9b34fb":"day_of_week","00002a7d-0000-1000-8000-00805f9b34fb":"descriptor_value_changed","00002a00-0000-1000-8000-00805f9b34fb":"gap.device_name","00002a7b-0000-1000-8000-00805f9b34fb":"dew_point","00002a56-0000-1000-8000-00805f9b34fb":"digital","00002a0d-0000-1000-8000-00805f9b34fb":"dst_offset","00002a6c-0000-1000-8000-00805f9b34fb":"elevation","00002a87-0000-1000-8000-00805f9b34fb":"email_address","00002a0c-0000-1000-8000-00805f9b34fb":"exact_time_256","00002a88-0000-1000-8000-00805f9b34fb":"fat_burn_heart_rate_lower_limit","00002a89-0000-1000-8000-00805f9b34fb":"fat_burn_heart_rate_upper_limit","00002a26-0000-1000-8000-00805f9b34fb":"firmware_revision_string","00002a8a-0000-1000-8000-00805f9b34fb":"first_name","00002a8b-0000-1000-8000-00805f9b34fb":"five_zone_heart_rate_limits","00002ab2-0000-1000-8000-00805f9b34fb":"floor_number","00002a8c-0000-1000-8000-00805f9b34fb":"gender","00002a51-0000-1000-8000-00805f9b34fb":"glucose_feature","00002a18-0000-1000-8000-00805f9b34fb":"glucose_measurement","00002a34-0000-1000-8000-00805f9b34fb":"glucose_measurement_context","00002a74-0000-1000-8000-00805f9b34fb":"gust_factor","00002a27-0000-1000-8000-00805f9b34fb":"hardware_revision_string","00002a39-0000-1000-8000-00805f9b34fb":"heart_rate_control_point","00002a8d-0000-1000-8000-00805f9b34fb":"heart_rate_max","00002a37-0000-1000-8000-00805f9b34fb":"heart_rate_measurement","00002a7a-0000-1000-8000-00805f9b34fb":"heat_index","00002a8e-0000-1000-8000-00805f9b34fb":"height","00002a4c-0000-1000-8000-00805f9b34fb":"hid_control_point","00002a4a-0000-1000-8000-00805f9b34fb":"hid_information","00002a8f-0000-1000-8000-00805f9b34fb":"hip_circumference","00002a6f-0000-1000-8000-00805f9b34fb":"humidity","00002aad-0000-1000-8000-00805f9b34fb":"indoor_positioning_configuration","00002a1e-0000-1000-8000-00805f9b34fb":"intermediate_temperature","00002a77-0000-1000-8000-00805f9b34fb":"irradiance","00002aa2-0000-1000-8000-00805f9b34fb":"language","00002a90-0000-1000-8000-00805f9b34fb":"last_name","00002aae-0000-1000-8000-00805f9b34fb":"latitude","00002a6b-0000-1000-8000-00805f9b34fb":"ln_control_point","00002a6a-0000-1000-8000-00805f9b34fb":"ln_feature","00002ab0-0000-1000-8000-00805f9b34fb":"local_north_coordinate","00002a0f-0000-1000-8000-00805f9b34fb":"local_time_information","00002a67-0000-1000-8000-00805f9b34fb":"location_and_speed","00002ab5-0000-1000-8000-00805f9b34fb":"location_name","00002aaf-0000-1000-8000-00805f9b34fb":"longitude","00002a2c-0000-1000-8000-00805f9b34fb":"magnetic_declination","00002aa0-0000-1000-8000-00805f9b34fb":"magnetic_flux_density_2D","00002aa1-0000-1000-8000-00805f9b34fb":"magnetic_flux_density_3D","00002a29-0000-1000-8000-00805f9b34fb":"manufacturer_name_string","00002a91-0000-1000-8000-00805f9b34fb":"maximum_recommended_heart_rate","00002a21-0000-1000-8000-00805f9b34fb":"measurement_interval","00002a24-0000-1000-8000-00805f9b34fb":"model_number_string","00002a68-0000-1000-8000-00805f9b34fb":"navigation","00002a46-0000-1000-8000-00805f9b34fb":"new_alert","00002a04-0000-1000-8000-00805f9b34fb":"gap.peripheral_preferred_connection_parameters","00002a02-0000-1000-8000-00805f9b34fb":"gap.peripheral_privacy_flag","00002a5f-0000-1000-8000-00805f9b34fb":"plx_continuous_measurement","00002a60-0000-1000-8000-00805f9b34fb":"plx_features","00002a5e-0000-1000-8000-00805f9b34fb":"plx_spot_check_measurement","00002a50-0000-1000-8000-00805f9b34fb":"pnp_id","00002a75-0000-1000-8000-00805f9b34fb":"pollen_concentration","00002a69-0000-1000-8000-00805f9b34fb":"position_quality","00002a6d-0000-1000-8000-00805f9b34fb":"pressure","00002a4e-0000-1000-8000-00805f9b34fb":"protocol_mode","00002a78-0000-1000-8000-00805f9b34fb":"rainfall","00002a03-0000-1000-8000-00805f9b34fb":"gap.reconnection_address","00002a52-0000-1000-8000-00805f9b34fb":"record_access_control_point","00002a14-0000-1000-8000-00805f9b34fb":"reference_time_information","00002a4d-0000-1000-8000-00805f9b34fb":"report","00002a4b-0000-1000-8000-00805f9b34fb":"report_map","00002a92-0000-1000-8000-00805f9b34fb":"resting_heart_rate","00002a40-0000-1000-8000-00805f9b34fb":"ringer_control_point","00002a41-0000-1000-8000-00805f9b34fb":"ringer_setting","00002a54-0000-1000-8000-00805f9b34fb":"rsc_feature","00002a53-0000-1000-8000-00805f9b34fb":"rsc_measurement","00002a55-0000-1000-8000-00805f9b34fb":"sc_control_point","00002a4f-0000-1000-8000-00805f9b34fb":"scan_interval_window","00002a31-0000-1000-8000-00805f9b34fb":"scan_refresh","00002a5d-0000-1000-8000-00805f9b34fb":"sensor_location","00002a25-0000-1000-8000-00805f9b34fb":"serial_number_string","00002a05-0000-1000-8000-00805f9b34fb":"gatt.service_changed","00002a28-0000-1000-8000-00805f9b34fb":"software_revision_string","00002a93-0000-1000-8000-00805f9b34fb":"sport_type_for_aerobic_and_anaerobic_thresholds","00002a47-0000-1000-8000-00805f9b34fb":"supported_new_alert_category","00002a48-0000-1000-8000-00805f9b34fb":"supported_unread_alert_category","00002a23-0000-1000-8000-00805f9b34fb":"system_id","00002a6e-0000-1000-8000-00805f9b34fb":"temperature","00002a1c-0000-1000-8000-00805f9b34fb":"temperature_measurement","00002a1d-0000-1000-8000-00805f9b34fb":"temperature_type","00002a94-0000-1000-8000-00805f9b34fb":"three_zone_heart_rate_limits","00002a12-0000-1000-8000-00805f9b34fb":"time_accuracy","00002a13-0000-1000-8000-00805f9b34fb":"time_source","00002a16-0000-1000-8000-00805f9b34fb":"time_update_control_point","00002a17-0000-1000-8000-00805f9b34fb":"time_update_state","00002a11-0000-1000-8000-00805f9b34fb":"time_with_dst","00002a0e-0000-1000-8000-00805f9b34fb":"time_zone","00002a71-0000-1000-8000-00805f9b34fb":"true_wind_direction","00002a70-0000-1000-8000-00805f9b34fb":"true_wind_speed","00002a95-0000-1000-8000-00805f9b34fb":"two_zone_heart_rate_limit","00002a07-0000-1000-8000-00805f9b34fb":"tx_power_level","00002ab4-0000-1000-8000-00805f9b34fb":"uncertainty","00002a45-0000-1000-8000-00805f9b34fb":"unread_alert_status","00002a9f-0000-1000-8000-00805f9b34fb":"user_control_point","00002a9a-0000-1000-8000-00805f9b34fb":"user_index","00002a76-0000-1000-8000-00805f9b34fb":"uv_index","00002a96-0000-1000-8000-00805f9b34fb":"vo2_max","00002a97-0000-1000-8000-00805f9b34fb":"waist_circumference","00002a98-0000-1000-8000-00805f9b34fb":"weight","00002a9d-0000-1000-8000-00805f9b34fb":"weight_measurement","00002a9e-0000-1000-8000-00805f9b34fb":"weight_scale_feature","00002a79-0000-1000-8000-00805f9b34fb":"wind_chill"}'),G={default:{convert:e=>e.byteLength?e:null},"00002901-0000-1000-8000-00805f9b34fb":{convert:e=>new TextDecoder("utf-8").decode(e)},"00002904-0000-1000-8000-00805f9b34fb":{convert:e=>e.getUint8()}},X=[{description:"Reserved For Future Use",convert:e=>e.byteLength?e:null},{description:"Boolean",convert:e=>e.getInt8()},{description:"unsigned 2-bit integer",convert:e=>e.getUint8()},{description:"unsigned 4-bit integer",convert:e=>e.getUint8()},{description:"unsigned 8-bit integer",convert:e=>e.getUint8()},{description:"unsigned 12-bit integer",convert:e=>e.getUint16()},{description:"unsigned 16-bit integer",convert:e=>e.getUint16()},{description:"unsigned 24-bit integer",convert:e=>e.getUint32()},{description:"unsigned 32-bit integer",convert:e=>e.getUint32()},{description:"unsigned 48-bit integer",convert:e=>e.getBigUint64()},{description:"unsigned 64-bit integer",convert:e=>e.getBigUint64()},{description:"unsigned 128-bit integer",convert:e=>[e.getBigUint64(),e.getBigUint64(8)]},{description:"signed 8-bit integer",convert:e=>e.getInt8()},{description:"signed 12-bit integer",convert:e=>e.getInt16()},{description:"signed 16-bit integer",convert:e=>e.getInt16()},{description:"signed 24-bit integer",convert:e=>e.getInt32()},{description:"signed 32-bit integer",convert:e=>e.getInt32()},{description:"signed 48-bit integer",convert:e=>e.getBigInt64()},{description:"signed 64-bit integer",convert:e=>e.getBigInt64()},{description:"signed 128-bit integer",convert:e=>[e.getBigInt64(),e.getBigInt64(8)]},{description:"IEEE-754 32-bit floating point",convert:e=>e.getFloat32()},{description:"IEEE-754 64-bit floating point",convert:e=>e.getFloat64()},{description:"IEEE-11073 16-bit SFLOAT",convert:e=>e},{description:"IEEE-11073 32-bit FLOAT",convert:e=>e},{description:"IEEE-20601 format",convert:e=>e},{description:"UTF-8 string",convert:e=>new TextDecoder("utf-8").decode(e)},{description:"UTF-16 string",convert:e=>new TextDecoder("utf-16").decode(e)},{description:"Opaque Structure",convert:e=>e}];function Y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function Q(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(n),!0).forEach(function(t){ee(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ee(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const te=(e,t)=>{const n=null==t?void 0:t.descriptors;if(n){const t=n.find(t=>t.uuid===e);if(t)return t.value}return null},ne=e=>"string"==typeof e?e:te("2901",e)||te("00002904-0000-1000-8000-00805f9b34fb",e),ie=te.bind(null,"2904"),re=({description:e},t="CustomType")=>{switch(e){case"Reserved For Future Use":case"Opaque Structure":return t;case"Boolean":return"Button";case"UTF-8 string":case"UTF-16 string":return"Text";default:return"Amount"}};let oe=null,se=null;try{oe=window.ble||window.top.ble,se=window.cordova||window.top.cordova}catch(e){}class ae extends(r()){constructor(e={acceptAllDevices:!0},t="BLEDevice",n={}){var i;super(),this.deviceName=t,this.uuidMap=Q(Q({},V),n),this.ble=null!==(i=window.ble)&&void 0!==i?i:window.top.ble,this.writes={},null!=e&&e.id?(this.device=e,this.options=null):(this.device=null,this.options=e)}async initialize(e){var t=this;if(!this.device&&(this.device=await this.requestDevice(e||this.options),!this.device))throw"No device selected.";const n=await this.connect();if(n){const e=n.characteristics;this.device=n,e.forEach(async function(e){const i=e.properties,r=e.characteristic.toLowerCase(),o=t.uuidMap[r],s=ne(o)||r,a=e.descriptors||[],c=X[ie(o)||27];if(console.log(s,e),a.forEach(e=>{console.log(`${e.uuid} | ${s}`,e)}),i.indexOf("Read"),i.indexOf("Write")>=0){if(t.writes[s])throw new Error(`There is already a writable characteristic named "${s}".`);t.writes[s]=i=>{var r;return t.ble.withPromises.write(n.id,e.service,e.characteristic,null!==(r=i.buffer)&&void 0!==r?r:i)}}if(i.indexOf("Notify")>=0){const i=re(c,s);let r=null;t.ble.startNotification(n.id,e.service,e.characteristic,(e,n)=>{const o=c.convert(new DataView(e));r!==o&&(r=o,t.emit("updated",{control:s,device:t.deviceName,type:i,value:o}))},e=>{throw e})}})}}requestDevice(e){return console.log("Requesting Device..."),new Promise((t,n)=>{var i;console.log("Starting Scan... "),"ios"!==se.platformId&&this.ble.isLocationEnabled(()=>{console.log("Location is enabled")},()=>{console.log("Location is disabled")}),this.ble.startScan("ios"===se.platformId&&null!==(i=null==e?void 0:e.optionalServices)&&void 0!==i?i:[],n=>{var i;const r=null!==(i=null==e?void 0:e.optionalServices)&&void 0!==i?i:[];let o=null;if(console.log("Found",n),"ios"===se.platformId)o=n;else{const e=new Uint8Array(n.advertising),t=Array.prototype.map.call(e,e=>("00"+e.toString(16)).slice(-2)).join("");console.log(t.match(/[a-fA-F0-9]{4}/g).join("-")),r.forEach(e=>{const i=e.replace(/\-/g,"");t.match(/[a-fA-F0-9]{2}/g).reverse().join("").indexOf(i)>=0&&(o=n,console.log(`Found a match! ${e}`))})}o&&(this.ble.stopScan(),t(o))},e=>{console.log("Error",e),this.ble.stopScan(),n(e)})})}connect(){return new Promise((e,t)=>{if(!this.device)throw t(),"No device selected.";this.ble.connect(this.device.id,t=>{this.emit("updated",{control:`${this.deviceName}Connection`,device:this.deviceName,target:t,type:"Button",value:1}),e(t)},()=>{console.log(`${this.deviceName} disconnected.`),this.emit("updated",{control:`${this.deviceName}Connection`,device:this.deviceName,type:"Button",value:0}),this.writes={}})})}disconnect(){this.ble.isConnected(this.device.id,()=>{this.ble.disconnect(this.device.id)},()=>{throw"Device not connected."})}write(e,t){if(!this.writes[e])throw new Error(`No writable characteristic "${e}".`);return this.writes[e](t)}}class ce extends(r()){constructor(e={acceptAllDevices:!0},t="BLEDevice",n={}){super(),this.deviceName=t,this.uuidMap=Q(Q({},V),n),this.writes={},null!=e&&e.gatt?(this.device=e,this.options=null):(this.device=null,this.options=e)}async initialize(e){var t=this;const n=!!this.device;if(!n){if(!navigator.bluetooth)throw"This web browser does not support Bluetooth.";if(this.device=await navigator.bluetooth.requestDevice(e||this.options),!this.device)throw"No device selected."}this.device.addEventListener("gattserverdisconnected",()=>{console.log(`${this.deviceName} disconnected.`),this.emit("updated",{control:`${this.deviceName}Connection`,device:this.deviceName,type:"Button",value:0}),this.writes={}});try{if(!await this.connect())throw"Not able to connect to device.";{const e=this.device.gatt,n=await e.getPrimaryServices(),i="00002904-0000-1000-8000-00805f9b34fb";n.forEach(async function(e){(await e.getCharacteristics()).forEach(async function(e){const n=e.properties,r=t.uuidMap[e.uuid],o=ne(r)||e.uuid;let s=X[27];console.log(o,e);try{const t=await e.getDescriptors();let n=!1;if(t.forEach(async function(e){try{var t;const r=(null!==(t=G[e.uuid])&&void 0!==t?t:G.default).convert(await e.readValue());e.uuid===i&&(s=X[r]||X[0],n=!0),console.log(`${e.uuid} | ${o}`,r)}catch(t){console.warn(`Error converting data from descriptor "${e.uuid}".`,t)}}),!n){const e=ie(r);e&&(s=X[e])}}catch(e){}if(n.read,n.write){if(t.writes[o])throw new Error(`There is already a writable characteristic named "${o}".`);t.writes[o]=t=>{var n;const i=t instanceof DataView?t:new DataView(null!==(n=t.buffer)&&void 0!==n?n:t);return e.writeValueWithResponse(i)}}if(n.notify){const n=e=>{const n=e.currentTarget,a=s.convert(n.value);r!==a&&(r=a,t.emit("updated",{control:o,device:t.deviceName,type:i,value:a}))},i=re(s,o);let r=null;await e.startNotifications(),e.addEventListener("characteristicvaluechanged",n)}})})}}catch(e){var i,r;throw n||(null!==(i=this.device)&&void 0!==i&&null!==(r=i.gatt)&&void 0!==r&&r.connected&&this.device.gatt.disconnect(),this.device=null),e}}async connect(){if(this.device){const e=this.device.gatt;return await e.connect(),!!e.connected&&(this.emit("updated",{control:`${this.deviceName}Connection`,device:this.deviceName,target:this.device,type:"Button",value:1}),!0)}throw"No device selected."}disconnect(){var e,t;if(null!==(e=this.device)&&void 0!==e&&null!==(t=e.gatt)&&void 0!==t&&t.connected)return this.device.gatt.disconnect();throw"Device not connected."}write(e,t){if(!this.writes[e])throw new Error(`No writable characteristic "${e}".`);return this.writes[e](t)}}const le=oe?ae:ce;class ue extends(r()){constructor(e,t="FabricDevice"){super(),this.inputMethod="pointer",this.pressed=0,e.on("mousedown",n=>{this.pressed=1,this.emit("updated",{control:"FabricPointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.pointer.x,y:n.pointer.y})}),e.on("mousemove",n=>{this.emit("updated",{control:"FabricPointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.pointer.x,y:n.pointer.y})}),e.on("mouseup",n=>{this.pressed=0,this.emit("updated",{control:"FabricPointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.pointer.x,y:n.pointer.y})}),e.on("dropped",n=>{this.emit("updated",{control:"FabricDrop",device:t,event:n,target:e,type:"Drop",value:n.dropZone?n.dropZone.dropZone:"",x:n.dropZone?n.dropZoneX:n.x,y:n.dropZone?n.dropZoneY:n.y}),n.stopPropagation()}),e.on("dragover",n=>{this.emit("updated",{control:"FabricDrag",device:t,event:n,target:e,type:"Drop",value:n.dropZone?n.dropZone.dropZone:"",x:n.dropZone?n.dropZoneX:n.x,y:n.dropZone?n.dropZoneY:n.y}),n.stopPropagation()}),e.on("rotating",n=>{this.emit("updated",{control:"FabricDial",device:t,event:n,target:e,type:"Dial",value:e.angle/360})})}}const de=ue,he=function(e,t){const n=e.x,i=e.y,r=Math.sqrt(n*n+i*i);if(r>1)e.x*=1/r,e.y*=1/r;else if(r<t)e.x=0,e.y=0;else{const r=1-t;e.x=(n-t)/r,e.y=(i-t)/r}return e},fe=()=>{const e=[...window.navigator.getGamepads()];for(let t=0;t<e.length;t++){const n=e[t];if(n){const e=ve[n.index];e?e.update(n):ve[n.index]=new _e(n)}}window.requestAnimationFrame(fe)},pe={duration:500,startDelay:0,strongMagnitude:1,weakMagnitude:1},be={a0:"LeftStick",a1:"RightStick",b0:"AButton",b1:"BButton",b2:"XButton",b3:"YButton",b4:"LeftBumper",b5:"RightBumper",b6:"LeftTrigger",b7:"RightTrigger",b8:"BackButton",b9:"StartButton",b10:"LeftStickButton",b11:"RightStickButton",b12:"UpDPad",b13:"DownDPad",b14:"LeftDPad",b15:"RightDPad"},ve=[];window.addEventListener("gamepadconnected",()=>{fe()});class _e extends(r()){constructor(e,t="",n=.1){super(),this.source=e,this.deadzone=n,this.axes=[];for(let t=0;t<e.axes.length>>1;t++)this.axes.push(he({x:e.axes[2*t],y:e.axes[2*t+1]},n));this.buttons=[];for(let t=0;t<e.buttons.length;t++)this.buttons.push(e.buttons[t].value);this.id=t||`${e.id} - ${e.index}`}dualRumble(e=500,t=0,n=1,i=1){pe.duration=e,pe.startDelay=t,pe.strongMagnitude=n,pe.weakMagnitude=i,this.source.vibrationActuator.playEffect("dual-rumble",pe)}update(e){const t=this.axes,n=this.buttons;for(let n=0;n<t.length;n++){const i=t[n],r=he({x:e.axes[2*n],y:e.axes[2*n+1]},this.deadzone);if(i.x!==r.x||i.y!==r.y){const e=r.x,t=r.y;i.x=e,i.y=t,this.emit("updated",{control:be[`a${n}`],device:this.id,target:this,type:"Joystick",x:e,y:t})}}for(let t=0;t<e.buttons.length;t++){const i=e.buttons[t].value;i!==n[t]&&(n[t]=i,this.emit("updated",{control:be[`b${t}`],device:this.id,target:this,type:"Button",value:i}))}}}class me extends(r()){constructor(){super(),this.inputMethod="gamepad",this.eventHandlers=[],window.addEventListener("gamepadconnected",()=>{this.emit("input-activity","gamepad"),this.updateGamepads()}),this.updateGamepads()}updateGamepads(){for(let e=0;e<this.eventHandlers.length;e++)this.eventHandlers[e].gamepad.off("updated",this.eventHandlers[e].handler);this.eventHandlers.length=0;for(let e=0;e<ve.length;e++){const t=e=>{this.emit("updated",e)};ve[e].on("updated",t),this.eventHandlers.push({gamepad:ve[e],handler:t})}}}const ge=me;class ye extends(r()){constructor(e="Keyboard"){super(),this.inputMethod="keyboard",window.addEventListener("keydown",t=>{this.emit("updated",{control:t.code,device:e,event:t,type:"Button",value:1})}),window.addEventListener("keyup",t=>{this.emit("updated",{control:t.code,device:e,event:t,type:"Button",value:0})})}}const we=ye;class xe extends(r()){constructor(e="PageDevice"){super(),this.channel=new D(e),this.channel.addEventListener("message",e=>{this.emit("updated",e)})}}const Pe=xe;class Ee extends(r()){constructor(e,t="PixiDevice"){super(),this.inputMethod="pointer",this.pressed=0,e.on("pointerdown",n=>{this.pressed=1,this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.x,y:n.y})}),e.on("pointermove",n=>{this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.x,y:n.y})}),e.on("pointerup",n=>{this.pressed=0,this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.x,y:n.y})})}}const Le=Ee;class Te extends(r()){constructor(e,t="PointerDevice"){super(),this.inputMethod="pointer",this.pressed=0,e.addEventListener("pointerdown",n=>{var i,r,o,s;this.pressed=1,this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:null!==(i=n.x)&&void 0!==i?i:null===(r=n.pointer)||void 0===r?void 0:r.x,y:null!==(o=n.y)&&void 0!==o?o:null===(s=n.pointer)||void 0===s?void 0:s.y})}),e.addEventListener("pointermove",n=>{var i,r,o,s;this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:null!==(i=n.x)&&void 0!==i?i:null===(r=n.pointer)||void 0===r?void 0:r.x,y:null!==(o=n.y)&&void 0!==o?o:null===(s=n.pointer)||void 0===s?void 0:s.y})}),e.addEventListener("pointerup",n=>{var i,r,o,s;this.pressed=0,this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:null!==(i=n.x)&&void 0!==i?i:null===(r=n.pointer)||void 0===r?void 0:r.x,y:null!==(o=n.y)&&void 0!==o?o:null===(s=n.pointer)||void 0===s?void 0:s.y})})}}const Se=Te,Ce=[250,500,1e3,2e3];function Oe(){return"undefined"==typeof window?null:window.SpeechRecognition||window.webkitSpeechRecognition||null}function Me(e){return String(null!=e?e:"").replace(/\s+/g," ").trim().toLowerCase()}function De(e=[]){return Array.isArray(e)?e.filter(e=>e&&"string"==typeof e.control&&e.type&&Array.isArray(e.phrases)).map(e=>({control:e.control,type:e.type,phrases:e.phrases.map(Me).filter(Boolean),value:e.value,x:e.x,y:e.y,releaseMs:"number"==typeof e.releaseMs?e.releaseMs:null})).filter(e=>e.phrases.length>0):[]}class ke extends(r()){static supported(){return null!=Oe()}constructor(e={}){super(),"string"==typeof e&&(e={device:e}),this.device=e.device||"Speech",this.inputMethod="speech",this.transcriptControl=e.transcriptControl||"SpeechTranscript",this.lang=e.lang||"en-US",this.interimResults=Boolean(e.interimResults),this.cooldownMs="number"==typeof e.cooldownMs?e.cooldownMs:800,this._Ctor=Oe(),this._mappings=De(e.mappings),this._cooldownUntil=new Map,this._releaseTimers=new Map,this._recognition=null,this._active=!1,this._listening=!1,this._starting=!1,this._recovering=!1,this._intentionalStop=!1,this._failCount=0,this._destroyed=!1,this._restartTimer=null,this._stopWaitTimer=null,this._startWatchTimer=null,this._warmResult=null,this._warmPromise=null,this._onBlur=()=>{this.setActive(!1)},"undefined"!=typeof window&&window.addEventListener("blur",this._onBlur)}setMappings(e){this._mappings=De(e)}setActive(e){const t=Boolean(e);if(this._active!==t){if(this._active=t,!t)return this._failCount=0,void this._stopRecognition();this.emit("input-activity","speech"),this._shouldListen()&&this._scheduleStart(0)}}start(){this.setActive(!0)}stop(){this.setActive(!1)}destroy(){this._destroyed=!0,"undefined"!=typeof window&&window.removeEventListener("blur",this._onBlur),this._clearRestartTimer(),this._clearStopWaitTimer(),this._clearStartWatchTimer(),this._clearAllReleaseTimers(),this.setActive(!1),this.removeAllListeners()}_shouldListen(){return this._active&&!this._destroyed&&null!=this._Ctor}_clearRestartTimer(){null!=this._restartTimer&&(clearTimeout(this._restartTimer),this._restartTimer=null)}_clearStopWaitTimer(){null!=this._stopWaitTimer&&(clearTimeout(this._stopWaitTimer),this._stopWaitTimer=null)}_clearStartWatchTimer(){null!=this._startWatchTimer&&(clearTimeout(this._startWatchTimer),this._startWatchTimer=null)}_clearAllReleaseTimers(){for(const e of this._releaseTimers.values())clearTimeout(e);this._releaseTimers.clear()}_clearReleaseTimer(e){const t=this._releaseTimers.get(e);null!=t&&(clearTimeout(t),this._releaseTimers.delete(e))}_detach(e){e.onstart=null,e.onresult=null,e.onerror=null,e.onend=null}_scheduleStart(e){this._clearRestartTimer(),this._shouldListen()&&(this._restartTimer=setTimeout(()=>{this._restartTimer=null,this._startRecognition()},e))}_noteRecoverableFailure(){var e;if(this._failCount+=1,this._starting=!1,this._listening=!1,!this._shouldListen())return void(this._recovering=!1);if(this._failCount>Ce.length)return this._recovering=!1,void this.setActive(!1);this._recovering=!0;const t=null!==(e=Ce[this._failCount-1])&&void 0!==e?e:Ce[Ce.length-1];this._scheduleStart(t)}_warmCapture(e=!1){if(e&&(this._warmResult=null),null!=this._warmResult)return Promise.resolve(this._warmResult);if(this._warmPromise)return this._warmPromise;const t="undefined"!=typeof navigator?navigator.mediaDevices:null;if(null==t||!t.getUserMedia)return this._warmResult=!0,Promise.resolve(!0);const n=t.getUserMedia({audio:!0}).then(e=>{for(const t of e.getTracks())t.stop();return this._warmResult=!0,!0}).catch(()=>(this._warmResult=!1,!1)),i=Promise.race([n,new Promise(e=>{setTimeout(()=>{var t;return e(null!==(t=this._warmResult)&&void 0!==t&&t)},1500)})]);return this._warmPromise=i.finally(()=>{this._warmPromise=null}),this._warmPromise}_stopRecognition(){this._clearRestartTimer(),this._clearStartWatchTimer(),this._starting=!1,this._recovering=!1;const e=this._recognition;if(!e)return this._intentionalStop=!1,this._clearStopWaitTimer(),void(this._listening=!1);this._intentionalStop=!0;try{e.stop()}catch(t){try{e.abort()}catch(e){}}this._clearStopWaitTimer(),this._stopWaitTimer=setTimeout(()=>{this._stopWaitTimer=null,this._recognition===e&&(this._recognition=null,this._detach(e)),this._intentionalStop=!1,this._listening=!1,this._shouldListen()&&this._scheduleStart(250)},500)}async _startRecognition(){if(!this._shouldListen()||this._listening||this._starting||this._recognition)return;if(this._clearRestartTimer(),this._starting=!0,(null==this._warmResult||this._failCount>0)&&(await this._warmCapture(this._failCount>0),!this._shouldListen()||this._listening||this._recognition))return void(this._starting=!1);const e=new this._Ctor;this._recognition=e,e.continuous=!0,e.interimResults=!0,e.lang=this.lang,e.onstart=()=>{this._recognition===e&&(this._clearStartWatchTimer(),this._starting=!1,this._failCount=0,this._recovering=!1,this._listening=!0)},e.onresult=t=>{this._recognition===e&&this._handleResult(t)},e.onerror=t=>{if(this._recognition!==e)return;const n=t.error||"";if("aborted"!==n&&"no-speech"!==n){if(this._clearStartWatchTimer(),this._recognition=null,this._detach(e),this._starting=!1,this._listening=!1,"not-allowed"===n||"service-not-allowed"===n)return this._intentionalStop=!1,this._clearStopWaitTimer(),this._recovering=!1,void this.setActive(!1);this._intentionalStop||("audio-capture"===n&&(this._warmResult=null),this._noteRecoverableFailure())}},e.onend=()=>{this._clearStartWatchTimer(),this._recognition===e&&(this._recognition=null,this._detach(e)),this._starting=!1,this._listening=!1,this._intentionalStop=!1,this._clearStopWaitTimer(),this._shouldListen()&&this._scheduleStart(250)};try{e.start(),this._clearStartWatchTimer(),this._startWatchTimer=setTimeout(()=>{if(this._startWatchTimer=null,this._recognition===e&&!this._listening){try{e.abort()}catch(e){}this._recognition===e&&(this._recognition=null,this._detach(e),this._noteRecoverableFailure())}},3e3)}catch(t){this._clearStartWatchTimer(),this._recognition=null,this._detach(e),this._noteRecoverableFailure()}}_handleResult(e){const t=Date.now();for(let i=e.resultIndex;i<e.results.length;i++){var n;const r=e.results[i];if(!r)continue;const o=r[0],s=null!==(n=null==o?void 0:o.transcript)&&void 0!==n?n:"",a=String(s).replace(/\s+/g," ").trim();if(!a)continue;const c=Boolean(r.isFinal),l="number"==typeof(null==o?void 0:o.confidence)?o.confidence:void 0;if(!c){this.interimResults&&this.emit("updated",{control:this.transcriptControl,device:this.device,type:"Data",value:{text:a,isFinal:!1,confidence:l,matchedControls:[]},event:e});continue}const u=Me(a),d=[],h=[],f=new Set;for(const e of this._mappings)e.phrases.includes(u)&&(t<(this._cooldownUntil.get(e.control)||0)||(d.push(e),f.has(e.control)||(f.add(e.control),h.push(e.control))));this.emit("updated",{control:this.transcriptControl,device:this.device,type:"Data",value:{text:a,isFinal:!0,confidence:l,matchedControls:h},event:e});for(const n of d)this._cooldownUntil.set(n.control,t+this.cooldownMs),this._emitMapping(n,e)}}_emitMapping(e,t){this._clearReleaseTimer(e.control);const n=e.type;if("Button"===n)return this.emit("updated",{control:e.control,device:this.device,type:"Button",value:1,event:t}),void queueMicrotask(()=>{this._destroyed||this.emit("updated",{control:e.control,device:this.device,type:"Button",value:0,event:t})});if("Joystick"===n){const n="number"==typeof e.x?e.x:0,i="number"==typeof e.y?e.y:0;return this.emit("updated",{control:e.control,device:this.device,type:"Joystick",x:n,y:i,event:t}),void(null!=e.releaseMs&&this._releaseTimers.set(e.control,setTimeout(()=>{this._releaseTimers.delete(e.control),this._destroyed||this.emit("updated",{control:e.control,device:this.device,type:"Joystick",x:0,y:0,event:t})},e.releaseMs)))}const i=e.value;this.emit("updated",{control:e.control,device:this.device,type:n,value:i,event:t}),null==e.releaseMs||"Amount"!==n&&"Dial"!==n||this._releaseTimers.set(e.control,setTimeout(()=>{this._releaseTimers.delete(e.control),this._destroyed||this.emit("updated",{control:e.control,device:this.device,type:n,value:0,event:t})},e.releaseMs))}}const Be={BLEDevice:le,FabricDevice:de,GamepadDevice:ge,KeyboardDevice:we,PageDevice:Pe,PixiDevice:Le,PointerDevice:Se,SpeechDevice:ke};window.engagefully={Controller:Z,ActionMap:H,actions:N,devices:Be,quantizeStick:function(e,t,n={}){var i,r,o;const s=null!==(i=n.sectors)&&void 0!==i?i:8,a=null!==(r=n.deadzone)&&void 0!==r?r:.35,c=null!==(o=n.forward)&&void 0!==o?o:"-y";if(Math.hypot(e,t)<a||s<1)return null;const l="+y"===c?t:-t,u=Math.atan2(e,l);return{sector:(Math.round(u/(2*Math.PI/s))%s+s)%s}},focusGate:function(e={}){const t="function"==typeof e.extra?e.extra:()=>!1;return()=>{if(t())return!1;const e="undefined"!=typeof document?document.activeElement:null;if(!e||e===document.body)return!0;const n=e.tagName;return"INPUT"!==n&&"TEXTAREA"!==n&&"SELECT"!==n&&!e.isContentEditable}}}},187:e=>{var t,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=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(n,i){function r(n){e.removeListener(t,o),i(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",r),n([].slice.call(arguments))}b(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&b(e,"error",t,{once:!0})}(e,r)})},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 l(e,t,n,i){var r,o,s,l;if(a(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),(r=c(e))>0&&s.length>r&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,l=u,console&&console.warn&&console.warn(l)}return e}function u(){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 d(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=u.bind(i);return r.listener=n,i.wrapFn=r,r}function h(e,t,n){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(r):p(r,r.length)}function f(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function b(e,t,n,i){if("function"==typeof e.on)i.once?e.once(t,n):e.on(t,n);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 r(o){i.once&&e.removeEventListener(t,r),n(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||r(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||r(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=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){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 l=c.length,u=p(c,l);for(n=0;n<l;++n)i(u[n],this,t)}return!0},o.prototype.addListener=function(e,t){return l(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return l(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,i,r,o,s;if(a(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(r=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,r=o;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,r),1===n.length&&(i[e]=n[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,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var r,o=Object.keys(n);for(i=0;i<o.length;++i)"removeListener"!==(r=o[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[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 h(this,e,!0)},o.prototype.rawListeners=function(e){return h(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(665)})();
1
+ (()=>{"use strict";var e={665:(e,t,n)=>{var i=n(187),r=n.n(i);Promise.resolve(!1),Promise.resolve(!0);var o=Promise.resolve();function s(e,t){return e||(e=0),new Promise(function(n){return setTimeout(function(){return n(t)},e)})}function a(){return Math.random().toString(36).substring(2)}var c=0,l=0;function u(){var e=(new Date).getTime();return e===c?1e3*e+ ++l:(c=e,l=0,1e3*e)}var d="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);const h={create:function(e){var t={messagesCallback:null,bc:new BroadcastChannel(e),subFns:[]};return t.bc.onmessage=function(e){t.messagesCallback&&t.messagesCallback(e.data)},t},close:function(e){e.bc.close(),e.subFns=[]},onMessage:function(e,t){e.messagesCallback=t},postMessage:function(e,t){try{return e.bc.postMessage(t,!1),o}catch(e){return Promise.reject(e)}},canBeUsed:function(){if(d&&"undefined"==typeof window)return!1;if("function"==typeof BroadcastChannel){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}return!1},type:"native",averageResponseTime:function(){return 150},microSeconds:u};var f=function(){function e(e){this.ttl=e,this.set=new Set,this.timeMap=new Map}return e.prototype.has=function(e){return this.set.has(e)},e.prototype.add=function(e){var t=this;this.timeMap.set(e,p()),this.set.add(e),setTimeout(function(){!function(e){for(var t=p()-e.ttl,n=e.set[Symbol.iterator]();;){var i=n.next().value;if(!i)return;if(!(e.timeMap.get(i)<t))return;e.timeMap.delete(i),e.set.delete(i)}}(t)},0)},e.prototype.clear=function(){this.set.clear(),this.timeMap.clear()},e}();function p(){return(new Date).getTime()}function b(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=JSON.parse(JSON.stringify(e));return void 0===t.webWorkerSupport&&(t.webWorkerSupport=!0),t.idb||(t.idb={}),t.idb.ttl||(t.idb.ttl=45e3),t.idb.fallbackInterval||(t.idb.fallbackInterval=150),e.idb&&"function"==typeof e.idb.onclose&&(t.idb.onclose=e.idb.onclose),t.localstorage||(t.localstorage={}),t.localstorage.removeTimeout||(t.localstorage.removeTimeout=6e4),e.methods&&(t.methods=e.methods),t.node||(t.node={}),t.node.ttl||(t.node.ttl=12e4),t.node.maxParallelWrites||(t.node.maxParallelWrites=2048),void 0===t.node.useFastPath&&(t.node.useFastPath=!0),t}var _="messages";function v(){if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof window){if(void 0!==window.mozIndexedDB)return window.mozIndexedDB;if(void 0!==window.webkitIndexedDB)return window.webkitIndexedDB;if(void 0!==window.msIndexedDB)return window.msIndexedDB}return!1}function m(e){e.closed||g(e).then(function(){return s(e.options.idb.fallbackInterval)}).then(function(){return m(e)})}function g(e){return e.closed?o:e.messagesCallback?(t=e.db,n=e.lastCursorId,i=t.transaction(_).objectStore(_),r=[],new Promise(function(e){(function(){try{var e=IDBKeyRange.bound(n+1,1/0);return i.openCursor(e)}catch(e){return i.openCursor()}}()).onsuccess=function(t){var i=t.target.result;i?i.value.id<n+1?i.continue(n+1):(r.push(i.value),i.continue()):e(r)}})).then(function(t){var n=t.filter(function(e){return!!e}).map(function(t){return t.id>e.lastCursorId&&(e.lastCursorId=t.id),t}).filter(function(t){return function(e,t){return!(e.uuid===t.uuid||t.eMIs.has(e.id)||e.data.time<t.messagesCallbackTime)}(t,e)}).sort(function(e,t){return e.time-t.time});return n.forEach(function(t){e.messagesCallback&&(e.eMIs.add(t.id),e.messagesCallback(t.data))}),o}):o;var t,n,i,r}const y={create:function(e,t){return t=b(t),function(e){var t="pubkey.broadcast-channel-0-"+e,n=v().open(t,1);return n.onupgradeneeded=function(e){e.target.result.createObjectStore(_,{keyPath:"id",autoIncrement:!0})},new Promise(function(e,t){n.onerror=function(e){return t(e)},n.onsuccess=function(){e(n.result)}})}(e).then(function(n){var i={closed:!1,lastCursorId:0,channelName:e,options:t,uuid:a(),eMIs:new f(2*t.idb.ttl),writeBlockPromise:o,messagesCallback:null,readQueuePromises:[],db:n};return n.onclose=function(){i.closed=!0,t.idb.onclose&&t.idb.onclose()},m(i),i})},close:function(e){e.closed=!0,e.db.close()},onMessage:function(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t,g(e)},postMessage:function(e,t){return e.writeBlockPromise=e.writeBlockPromise.then(function(){return function(e,t,n){var i={uuid:t,time:(new Date).getTime(),data:n},r=e.transaction([_],"readwrite");return new Promise(function(e,t){r.oncomplete=function(){return e()},r.onerror=function(e){return t(e)},r.objectStore(_).add(i)})}(e.db,e.uuid,t)}).then(function(){var t,n;0===Math.floor(11*Math.random()+0)&&(t=e.db,n=e.options.idb.ttl,function(e,t){var n=(new Date).getTime()-t,i=e.transaction(_).objectStore(_),r=[];return new Promise(function(e){i.openCursor().onsuccess=function(t){var i=t.target.result;if(i){var o=i.value;if(!(o.time<n))return void e(r);r.push(o),i.continue()}else e(r)}})}(t,n).then(function(e){return Promise.all(e.map(function(e){return function(e,t){var n=e.transaction([_],"readwrite").objectStore(_).delete(t);return new Promise(function(e){n.onsuccess=function(){return e()}})}(t,e.id)}))}))}),e.writeBlockPromise},canBeUsed:function(){return!d&&!!v()},type:"idb",averageResponseTime:function(e){return 2*e.idb.fallbackInterval},microSeconds:u};function w(){var e;if("undefined"==typeof window)return null;try{e=window.localStorage,e=window["ie8-eventlistener/storage"]||window.localStorage}catch(e){}return e}function x(e){return"pubkey.broadcastChannel-"+e}function E(){if(d)return!1;var e=w();if(!e)return!1;try{var t="__broadcastchannel_check";e.setItem(t,"works"),e.removeItem(t)}catch(e){return!1}return!0}const L={create:function(e,t){if(t=b(t),!E())throw new Error("BroadcastChannel: localstorage cannot be used");var n=a(),i=new f(t.localstorage.removeTimeout),r={channelName:e,uuid:n,eMIs:i};return r.listener=function(e){var t=x(e),o=function(e){var o;e.key===t&&(o=JSON.parse(e.newValue),r.messagesCallback&&o.uuid!==n&&o.token&&!i.has(o.token)&&(o.data.time&&o.data.time<r.messagesCallbackTime||(i.add(o.token),r.messagesCallback(o.data))))};return window.addEventListener("storage",o),o}(e),r},close:function(e){var t;t=e.listener,window.removeEventListener("storage",t)},onMessage:function(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t},postMessage:function(e,t){return new Promise(function(n){s().then(function(){var i=x(e.channelName),r={token:a(),time:(new Date).getTime(),data:t,uuid:e.uuid},o=JSON.stringify(r);w().setItem(i,o);var s=document.createEvent("Event");s.initEvent("storage",!0,!0),s.key=i,s.newValue=o,window.dispatchEvent(s),n()})})},canBeUsed:E,type:"localstorage",averageResponseTime:function(){var e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")?240:120},microSeconds:u};var T=u,P=new Set;const C={create:function(e){var t={name:e,messagesCallback:null};return P.add(t),t},close:function(e){P.delete(e)},onMessage:function(e,t){e.messagesCallback=t},postMessage:function(e,t){return new Promise(function(n){return setTimeout(function(){Array.from(P).filter(function(t){return t.name===e.name}).filter(function(t){return t!==e}).filter(function(e){return!!e.messagesCallback}).forEach(function(e){return e.messagesCallback(t)}),n()},5)})},canBeUsed:function(){return!0},type:"simulate",averageResponseTime:function(){return 5},microSeconds:T};var S=[h,y,L],M=new Set,B=0,k=function(e,t){var n,i,r;this.id=B++,M.add(this),this.name=e,this.options=b(t),this.method=function(e){var t=[].concat(e.methods,S).filter(Boolean);if(e.type){if("simulate"===e.type)return C;var n=t.find(function(t){return t.type===e.type});if(n)return n;throw new Error("method-type "+e.type+" not found")}e.webWorkerSupport||d||(t=t.filter(function(e){return"idb"!==e.type}));var i=t.find(function(e){return e.canBeUsed()});if(i)return i;throw new Error("No useable method found in "+JSON.stringify(S.map(function(e){return e.type})))}(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._uMP=new Set,this._befC=[],this._prepP=null,(r=i=(n=this).method.create(n.name,n.options))&&"function"==typeof r.then?(n._prepP=i,i.then(function(e){n._state=e})):n._state=i};function D(e,t,n){var i={time:e.method.microSeconds(),type:t,data:n};return(e._prepP?e._prepP:o).then(function(){var t=e.method.postMessage(e._state,i);return e._uMP.add(t),t.catch().then(function(){return e._uMP.delete(t)}),t})}function R(e){return e._addEL.message.length>0||e._addEL.internal.length>0}function I(e,t,n){e._addEL[t].push(n),function(e){if(!e._iL&&R(e)){var t=function(t){e._addEL[t.type].forEach(function(e){var n=e.time-1e5;t.time>=n&&e.fn(t.data)})},n=e.method.microSeconds();e._prepP?e._prepP.then(function(){e._iL=!0,e.method.onMessage(e._state,t,n)}):(e._iL=!0,e.method.onMessage(e._state,t,n))}}(e)}function A(e,t,n){e._addEL[t]=e._addEL[t].filter(function(e){return e!==n}),function(e){if(e._iL&&!R(e)){e._iL=!1;var t=e.method.microSeconds();e.method.onMessage(e._state,null,t)}}(e)}k._pubkey=!0,k.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(e));return D(this,"message",e)},postInternal:function(e){return D(this,"internal",e)},set onmessage(e){var t={time:this.method.microSeconds(),fn:e};A(this,"message",this._onML),e&&"function"==typeof e?(this._onML=t,I(this,"message",t)):this._onML=null},addEventListener:function(e,t){I(this,e,{time:this.method.microSeconds(),fn:t})},removeEventListener:function(e,t){A(this,e,this._addEL[e].find(function(e){return e.fn===t}))},close:function(){var e=this;if(!this.closed){M.delete(this),this.closed=!0;var t=this._prepP?this._prepP:o;return this._onML=null,this._addEL.message=[],t.then(function(){return Promise.all(Array.from(e._uMP))}).then(function(){return Promise.all(e._befC.map(function(e){return e()}))}).then(function(){return e.method.close(e._state)})}},get type(){return this.method.type},get isClosed(){return this.closed}};const N={Amount:class{constructor(e){this.control=e,this.value=0}update(e,t){let n=!1;e.value!==this.value&&(n=!0,this.value=e.value),n&&t.emit(this.control,e,this)}},Button:class{constructor(e){this.control=e,this.value=0}update(e,t){e.value!==this.value&&(this.value=e.value,1===this.value&&t.emit(`${this.control}:pressed`,e,this),0===this.value&&t.emit(`${this.control}:released`,e,this),t.emit(this.control,e,this))}poll(){return this.value}toJSON(){return{control:this.control,type:"Button",value:this.value}}},Data:class{constructor(e){this.control=e,this.value=null}update(e,t){this.value=e.value,t.emit(this.control,e,this)}},Dial:class{constructor(e){this.control=e,this.value=0}update(e,t){e.value!==this.value&&(this.value=e.value,t.emit(this.control,e,this))}},Drop:class{constructor(e){this.control=e,this.value="",this.x=0,this.y=0}update(e,t){e.value===this.value&&e.x===this.x&&e.y===this.y||(this.value=e.value,this.x=e.x,this.y=e.y,t.emit(this.control,e,this))}},PageAction:class{constructor(e,t="PageDevice"){const n=e.devices||e;this.channel=new k(t),n.forEach(e=>{e.on("updated",e=>{const n={...e};n.device=`${t}-${e.device}`,n.control=`Page${e.control}`,delete n.target,delete n.event,this.channel.postMessage(n)})})}},Pointer:class{constructor(e){this.control=e,this.value=0,this.x=0,this.y=0}update(e,t){e.value===this.value&&e.x===this.x&&e.y===this.y||(this.value=e.value,this.x=e.x,this.y=e.y,t.emit(this.control,e,this))}},Joystick:class{constructor(e){this.control=e,this.x=0,this.y=0}update(e,t){e.x===this.x&&e.y===this.y||(this.x=e.x,this.y=e.y,t.emit(this.control,e,this))}}},F=new Set(["mouse","touch","pen"]);class O extends(r()){constructor(e=[],t={}){super(),this.devices=[],this.controls={},this.inputPrecedence=[],this.controlMap={...N,...t},e.forEach(e=>this.addDevice(e))}get preferredInput(){return this.inputPrecedence[0]||null}noteInput(e){if(!e||e===this.inputPrecedence[0])return;const t=this.inputPrecedence.indexOf(e);t>0&&this.inputPrecedence.splice(t,1),this.inputPrecedence.unshift(e),this.emit("input-precedence-updated",this.inputPrecedence)}addControl(e,t){const n=this.controlMap[t];if(n)return this.controls[e]=new n(e);{const n=this.controls[e]=new this.controlMap.Data(e);return console.warn(`${e}: "${t}" has no associated control class. Using 'Data'.`),n}}addDevice(e){this.devices.push(e),e.on("input-activity",e=>{this.noteInput(e)}),e.on("updated",t=>{const n=function(e,t){if(t?.inputMethod)return t.inputMethod;const n=e?.inputMethod;if("pointer"===n){const e=t?.event?.pointerType;return F.has(e)?e:"pointer"}return n||null}(e,t);n&&this.noteInput(n);const i=t.control;let r=this.controls[i];(r||(r=this.addControl(i,t.type),r))&&r.update(t,this)})}getControl(e,t){let n=this.controls[e];return!n&&t&&(n=this.addControl(e,t)),n}poll(e){return this.controls[e]?.poll?.()}}const W=O;function U(e){return"string"==typeof e?{control:e,data:void 0}:{control:e.control,data:e.data}}function $(e){return e.startsWith("Key")||e.startsWith("Arrow")||e.startsWith("Digit")||e.startsWith("Numpad")||"Space"===e||"Enter"===e||"Escape"===e||"Tab"===e||"Backspace"===e||"ShiftLeft"===e||"ShiftRight"===e||"ControlLeft"===e||"ControlRight"===e||"AltLeft"===e||"AltRight"===e}class j extends(r()){constructor(e,t={},n={}){if(super(),this.controller=e,this.enabled="function"==typeof n.enabled?n.enabled:()=>!0,this.preventDefault=!1!==n.preventDefault,this.autoTick=!1!==n.autoTick,this._bindings=new Map,this._controlIndex=new Map,this._heldByAction=new Map,this._lastEvent=new Map,this._listeners=[],this._disposed=!1,this._wasEnabled=!0,this._raf=0,this._applyBindings(t),this.preventDefault&&(this._onKeyDownCapture=e=>{this.enabled()&&this._keyboardCodes.has(e.code)&&e.preventDefault()},window.addEventListener("keydown",this._onKeyDownCapture,!0)),this._onBlur=()=>{this.clearHeld()},window.addEventListener("blur",this._onBlur),this.autoTick){const e=()=>{this._disposed||(this._raf=requestAnimationFrame(e),this._tick())};this._raf=requestAnimationFrame(e)}}_applyBindings(e){this._keyboardCodes=new Set;for(const[t,n]of Object.entries(e)){const e=(n||[]).map(U);this._bindings.set(t,e),this._heldByAction.set(t,new Set);for(const n of e){$(n.control)&&this._keyboardCodes.add(n.control);let e=this._controlIndex.get(n.control);e||(e=[],this._controlIndex.set(n.control,e)),e.push({action:t,data:n.data});const i=e=>this._onPhysicalPressed(n.control,e),r=e=>this._onPhysicalReleased(n.control,e);this.controller.on(`${n.control}:pressed`,i),this.controller.on(`${n.control}:released`,r),this._listeners.push({event:`${n.control}:pressed`,fn:i},{event:`${n.control}:released`,fn:r})}}}_isEnabled(){const e=this.enabled();return this._wasEnabled&&!e&&this.clearHeld(),this._wasEnabled=e,e}_onPhysicalPressed(e,t){if(!this._isEnabled())return;const n=this._controlIndex.get(e);if(n)for(const{action:i,data:r}of n){const n=this._heldByAction.get(i),o=0===n.size;n.add(e);const s={action:i,control:e,data:r,device:t?.device,raw:t};this._lastEvent.set(i,s),o&&this.emit(`${i}:pressed`,s),this.emit(i,s)}}_onPhysicalReleased(e,t){const n=this._controlIndex.get(e);if(n)for(const{action:i,data:r}of n){const n=this._heldByAction.get(i);if(!n.has(e))continue;n.delete(e);const o={action:i,control:e,data:r,device:t?.device,raw:t};if(0===n.size)this._lastEvent.delete(i),this.emit(`${i}:released`,o);else{const e=this._bindings.get(i)||[];for(const r of e)if(n.has(r.control)){this._lastEvent.set(i,{action:i,control:r.control,data:r.data,device:t?.device,raw:t});break}}}}_tick(){if(this._isEnabled())for(const[e,t]of this._heldByAction){if(0===t.size)continue;const n=this._lastEvent.get(e);n&&this.emit(`${e}:held`,n)}}held(e){const t=this._heldByAction.get(e);return Boolean(t&&t.size>0)}heldEvent(e){return this.held(e)&&this._lastEvent.get(e)||null}clearHeld(){for(const[e,t]of this._heldByAction){if(0===t.size)continue;const n=this._lastEvent.get(e);t.clear(),this._lastEvent.delete(e),this.emit(`${e}:released`,n||{action:e,control:null,data:void 0})}}dispose(){if(!this._disposed){this._disposed=!0,cancelAnimationFrame(this._raf);for(const{event:e,fn:t}of this._listeners)this.controller.off(e,t);this._listeners.length=0,this._onKeyDownCapture&&window.removeEventListener("keydown",this._onKeyDownCapture,!0),window.removeEventListener("blur",this._onBlur),this.removeAllListeners()}}}const z=j,Z=JSON.parse('{"00002a7e-0000-1000-8000-00805f9b34fb":"aerobic_heart_rate_lower_limit","00002a84-0000-1000-8000-00805f9b34fb":"aerobic_heart_rate_upper_limit","00002a7f-0000-1000-8000-00805f9b34fb":"aerobic_threshold","00002a80-0000-1000-8000-00805f9b34fb":"age","00002a5a-0000-1000-8000-00805f9b34fb":"aggregate","00002a43-0000-1000-8000-00805f9b34fb":"alert_category_id","00002a42-0000-1000-8000-00805f9b34fb":"alert_category_id_bit_mask","00002a06-0000-1000-8000-00805f9b34fb":"alert_level","00002a44-0000-1000-8000-00805f9b34fb":"alert_notification_control_point","00002a3f-0000-1000-8000-00805f9b34fb":"alert_status","00002ab3-0000-1000-8000-00805f9b34fb":"altitude","00002a81-0000-1000-8000-00805f9b34fb":"anaerobic_heart_rate_lower_limit","00002a82-0000-1000-8000-00805f9b34fb":"anaerobic_heart_rate_upper_limit","00002a83-0000-1000-8000-00805f9b34fb":"anaerobic_threshold","00002a58-0000-1000-8000-00805f9b34fb":"analog","00002a73-0000-1000-8000-00805f9b34fb":"apparent_wind_direction","00002a72-0000-1000-8000-00805f9b34fb":"apparent_wind_speed","00002a01-0000-1000-8000-00805f9b34fb":"gap.appearance","00002aa3-0000-1000-8000-00805f9b34fb":"barometric_pressure_trend","00002a19-0000-1000-8000-00805f9b34fb":"battery_level","00002a49-0000-1000-8000-00805f9b34fb":"blood_pressure_feature","00002a35-0000-1000-8000-00805f9b34fb":"blood_pressure_measurement","00002a9b-0000-1000-8000-00805f9b34fb":"body_composition_feature","00002a9c-0000-1000-8000-00805f9b34fb":"body_composition_measurement","00002a38-0000-1000-8000-00805f9b34fb":"body_sensor_location","00002aa4-0000-1000-8000-00805f9b34fb":"bond_management_control_point","00002aa5-0000-1000-8000-00805f9b34fb":"bond_management_feature","00002a22-0000-1000-8000-00805f9b34fb":"boot_keyboard_input_report","00002a32-0000-1000-8000-00805f9b34fb":"boot_keyboard_output_report","00002a33-0000-1000-8000-00805f9b34fb":"boot_mouse_input_report","00002aa6-0000-1000-8000-00805f9b34fb":"gap.central_address_resolution_support","00002aa8-0000-1000-8000-00805f9b34fb":"cgm_feature","00002aa7-0000-1000-8000-00805f9b34fb":"cgm_measurement","00002aab-0000-1000-8000-00805f9b34fb":"cgm_session_run_time","00002aaa-0000-1000-8000-00805f9b34fb":"cgm_session_start_time","00002aac-0000-1000-8000-00805f9b34fb":"cgm_specific_ops_control_point","00002aa9-0000-1000-8000-00805f9b34fb":"cgm_status","00002a5c-0000-1000-8000-00805f9b34fb":"csc_feature","00002a5b-0000-1000-8000-00805f9b34fb":"csc_measurement","00002a2b-0000-1000-8000-00805f9b34fb":"current_time","00002a66-0000-1000-8000-00805f9b34fb":"cycling_power_control_point","00002a65-0000-1000-8000-00805f9b34fb":"cycling_power_feature","00002a63-0000-1000-8000-00805f9b34fb":"cycling_power_measurement","00002a64-0000-1000-8000-00805f9b34fb":"cycling_power_vector","00002a99-0000-1000-8000-00805f9b34fb":"database_change_increment","00002a85-0000-1000-8000-00805f9b34fb":"date_of_birth","00002a86-0000-1000-8000-00805f9b34fb":"date_of_threshold_assessment","00002a08-0000-1000-8000-00805f9b34fb":"date_time","00002a0a-0000-1000-8000-00805f9b34fb":"day_date_time","00002a09-0000-1000-8000-00805f9b34fb":"day_of_week","00002a7d-0000-1000-8000-00805f9b34fb":"descriptor_value_changed","00002a00-0000-1000-8000-00805f9b34fb":"gap.device_name","00002a7b-0000-1000-8000-00805f9b34fb":"dew_point","00002a56-0000-1000-8000-00805f9b34fb":"digital","00002a0d-0000-1000-8000-00805f9b34fb":"dst_offset","00002a6c-0000-1000-8000-00805f9b34fb":"elevation","00002a87-0000-1000-8000-00805f9b34fb":"email_address","00002a0c-0000-1000-8000-00805f9b34fb":"exact_time_256","00002a88-0000-1000-8000-00805f9b34fb":"fat_burn_heart_rate_lower_limit","00002a89-0000-1000-8000-00805f9b34fb":"fat_burn_heart_rate_upper_limit","00002a26-0000-1000-8000-00805f9b34fb":"firmware_revision_string","00002a8a-0000-1000-8000-00805f9b34fb":"first_name","00002a8b-0000-1000-8000-00805f9b34fb":"five_zone_heart_rate_limits","00002ab2-0000-1000-8000-00805f9b34fb":"floor_number","00002a8c-0000-1000-8000-00805f9b34fb":"gender","00002a51-0000-1000-8000-00805f9b34fb":"glucose_feature","00002a18-0000-1000-8000-00805f9b34fb":"glucose_measurement","00002a34-0000-1000-8000-00805f9b34fb":"glucose_measurement_context","00002a74-0000-1000-8000-00805f9b34fb":"gust_factor","00002a27-0000-1000-8000-00805f9b34fb":"hardware_revision_string","00002a39-0000-1000-8000-00805f9b34fb":"heart_rate_control_point","00002a8d-0000-1000-8000-00805f9b34fb":"heart_rate_max","00002a37-0000-1000-8000-00805f9b34fb":"heart_rate_measurement","00002a7a-0000-1000-8000-00805f9b34fb":"heat_index","00002a8e-0000-1000-8000-00805f9b34fb":"height","00002a4c-0000-1000-8000-00805f9b34fb":"hid_control_point","00002a4a-0000-1000-8000-00805f9b34fb":"hid_information","00002a8f-0000-1000-8000-00805f9b34fb":"hip_circumference","00002a6f-0000-1000-8000-00805f9b34fb":"humidity","00002aad-0000-1000-8000-00805f9b34fb":"indoor_positioning_configuration","00002a1e-0000-1000-8000-00805f9b34fb":"intermediate_temperature","00002a77-0000-1000-8000-00805f9b34fb":"irradiance","00002aa2-0000-1000-8000-00805f9b34fb":"language","00002a90-0000-1000-8000-00805f9b34fb":"last_name","00002aae-0000-1000-8000-00805f9b34fb":"latitude","00002a6b-0000-1000-8000-00805f9b34fb":"ln_control_point","00002a6a-0000-1000-8000-00805f9b34fb":"ln_feature","00002ab0-0000-1000-8000-00805f9b34fb":"local_north_coordinate","00002a0f-0000-1000-8000-00805f9b34fb":"local_time_information","00002a67-0000-1000-8000-00805f9b34fb":"location_and_speed","00002ab5-0000-1000-8000-00805f9b34fb":"location_name","00002aaf-0000-1000-8000-00805f9b34fb":"longitude","00002a2c-0000-1000-8000-00805f9b34fb":"magnetic_declination","00002aa0-0000-1000-8000-00805f9b34fb":"magnetic_flux_density_2D","00002aa1-0000-1000-8000-00805f9b34fb":"magnetic_flux_density_3D","00002a29-0000-1000-8000-00805f9b34fb":"manufacturer_name_string","00002a91-0000-1000-8000-00805f9b34fb":"maximum_recommended_heart_rate","00002a21-0000-1000-8000-00805f9b34fb":"measurement_interval","00002a24-0000-1000-8000-00805f9b34fb":"model_number_string","00002a68-0000-1000-8000-00805f9b34fb":"navigation","00002a46-0000-1000-8000-00805f9b34fb":"new_alert","00002a04-0000-1000-8000-00805f9b34fb":"gap.peripheral_preferred_connection_parameters","00002a02-0000-1000-8000-00805f9b34fb":"gap.peripheral_privacy_flag","00002a5f-0000-1000-8000-00805f9b34fb":"plx_continuous_measurement","00002a60-0000-1000-8000-00805f9b34fb":"plx_features","00002a5e-0000-1000-8000-00805f9b34fb":"plx_spot_check_measurement","00002a50-0000-1000-8000-00805f9b34fb":"pnp_id","00002a75-0000-1000-8000-00805f9b34fb":"pollen_concentration","00002a69-0000-1000-8000-00805f9b34fb":"position_quality","00002a6d-0000-1000-8000-00805f9b34fb":"pressure","00002a4e-0000-1000-8000-00805f9b34fb":"protocol_mode","00002a78-0000-1000-8000-00805f9b34fb":"rainfall","00002a03-0000-1000-8000-00805f9b34fb":"gap.reconnection_address","00002a52-0000-1000-8000-00805f9b34fb":"record_access_control_point","00002a14-0000-1000-8000-00805f9b34fb":"reference_time_information","00002a4d-0000-1000-8000-00805f9b34fb":"report","00002a4b-0000-1000-8000-00805f9b34fb":"report_map","00002a92-0000-1000-8000-00805f9b34fb":"resting_heart_rate","00002a40-0000-1000-8000-00805f9b34fb":"ringer_control_point","00002a41-0000-1000-8000-00805f9b34fb":"ringer_setting","00002a54-0000-1000-8000-00805f9b34fb":"rsc_feature","00002a53-0000-1000-8000-00805f9b34fb":"rsc_measurement","00002a55-0000-1000-8000-00805f9b34fb":"sc_control_point","00002a4f-0000-1000-8000-00805f9b34fb":"scan_interval_window","00002a31-0000-1000-8000-00805f9b34fb":"scan_refresh","00002a5d-0000-1000-8000-00805f9b34fb":"sensor_location","00002a25-0000-1000-8000-00805f9b34fb":"serial_number_string","00002a05-0000-1000-8000-00805f9b34fb":"gatt.service_changed","00002a28-0000-1000-8000-00805f9b34fb":"software_revision_string","00002a93-0000-1000-8000-00805f9b34fb":"sport_type_for_aerobic_and_anaerobic_thresholds","00002a47-0000-1000-8000-00805f9b34fb":"supported_new_alert_category","00002a48-0000-1000-8000-00805f9b34fb":"supported_unread_alert_category","00002a23-0000-1000-8000-00805f9b34fb":"system_id","00002a6e-0000-1000-8000-00805f9b34fb":"temperature","00002a1c-0000-1000-8000-00805f9b34fb":"temperature_measurement","00002a1d-0000-1000-8000-00805f9b34fb":"temperature_type","00002a94-0000-1000-8000-00805f9b34fb":"three_zone_heart_rate_limits","00002a12-0000-1000-8000-00805f9b34fb":"time_accuracy","00002a13-0000-1000-8000-00805f9b34fb":"time_source","00002a16-0000-1000-8000-00805f9b34fb":"time_update_control_point","00002a17-0000-1000-8000-00805f9b34fb":"time_update_state","00002a11-0000-1000-8000-00805f9b34fb":"time_with_dst","00002a0e-0000-1000-8000-00805f9b34fb":"time_zone","00002a71-0000-1000-8000-00805f9b34fb":"true_wind_direction","00002a70-0000-1000-8000-00805f9b34fb":"true_wind_speed","00002a95-0000-1000-8000-00805f9b34fb":"two_zone_heart_rate_limit","00002a07-0000-1000-8000-00805f9b34fb":"tx_power_level","00002ab4-0000-1000-8000-00805f9b34fb":"uncertainty","00002a45-0000-1000-8000-00805f9b34fb":"unread_alert_status","00002a9f-0000-1000-8000-00805f9b34fb":"user_control_point","00002a9a-0000-1000-8000-00805f9b34fb":"user_index","00002a76-0000-1000-8000-00805f9b34fb":"uv_index","00002a96-0000-1000-8000-00805f9b34fb":"vo2_max","00002a97-0000-1000-8000-00805f9b34fb":"waist_circumference","00002a98-0000-1000-8000-00805f9b34fb":"weight","00002a9d-0000-1000-8000-00805f9b34fb":"weight_measurement","00002a9e-0000-1000-8000-00805f9b34fb":"weight_scale_feature","00002a79-0000-1000-8000-00805f9b34fb":"wind_chill"}'),q={default:{convert:e=>e.byteLength?e:null},"00002901-0000-1000-8000-00805f9b34fb":{convert:e=>new TextDecoder("utf-8").decode(e)},"00002904-0000-1000-8000-00805f9b34fb":{convert:e=>e.getUint8()}},J=[{description:"Reserved For Future Use",convert:e=>e.byteLength?e:null},{description:"Boolean",convert:e=>e.getInt8()},{description:"unsigned 2-bit integer",convert:e=>e.getUint8()},{description:"unsigned 4-bit integer",convert:e=>e.getUint8()},{description:"unsigned 8-bit integer",convert:e=>e.getUint8()},{description:"unsigned 12-bit integer",convert:e=>e.getUint16()},{description:"unsigned 16-bit integer",convert:e=>e.getUint16()},{description:"unsigned 24-bit integer",convert:e=>e.getUint32()},{description:"unsigned 32-bit integer",convert:e=>e.getUint32()},{description:"unsigned 48-bit integer",convert:e=>e.getBigUint64()},{description:"unsigned 64-bit integer",convert:e=>e.getBigUint64()},{description:"unsigned 128-bit integer",convert:e=>[e.getBigUint64(),e.getBigUint64(8)]},{description:"signed 8-bit integer",convert:e=>e.getInt8()},{description:"signed 12-bit integer",convert:e=>e.getInt16()},{description:"signed 16-bit integer",convert:e=>e.getInt16()},{description:"signed 24-bit integer",convert:e=>e.getInt32()},{description:"signed 32-bit integer",convert:e=>e.getInt32()},{description:"signed 48-bit integer",convert:e=>e.getBigInt64()},{description:"signed 64-bit integer",convert:e=>e.getBigInt64()},{description:"signed 128-bit integer",convert:e=>[e.getBigInt64(),e.getBigInt64(8)]},{description:"IEEE-754 32-bit floating point",convert:e=>e.getFloat32()},{description:"IEEE-754 64-bit floating point",convert:e=>e.getFloat64()},{description:"IEEE-11073 16-bit SFLOAT",convert:e=>e},{description:"IEEE-11073 32-bit FLOAT",convert:e=>e},{description:"IEEE-20601 format",convert:e=>e},{description:"UTF-8 string",convert:e=>new TextDecoder("utf-8").decode(e)},{description:"UTF-16 string",convert:e=>new TextDecoder("utf-16").decode(e)},{description:"Opaque Structure",convert:e=>e}],K=(e,t)=>{const n=t?.descriptors;if(n){const t=n.find(t=>t.uuid===e);if(t)return t.value}return null},H=e=>"string"==typeof e?e:K("2901",e)||K("00002904-0000-1000-8000-00805f9b34fb",e),V=K.bind(null,"2904"),G=({description:e},t="CustomType")=>{switch(e){case"Reserved For Future Use":case"Opaque Structure":return t;case"Boolean":return"Button";case"UTF-8 string":case"UTF-16 string":return"Text";default:return"Amount"}};let X=null,Y=null;try{X=window.ble||window.top.ble,Y=window.cordova||window.top.cordova}catch(e){}class Q extends(r()){constructor(e={acceptAllDevices:!0},t="BLEDevice",n={}){super(),this.deviceName=t,this.uuidMap={...Z,...n},this.ble=window.ble??window.top.ble,this.writes={},e?.id?(this.device=e,this.options=null):(this.device=null,this.options=e)}async initialize(e){if(!this.device&&(this.device=await this.requestDevice(e||this.options),!this.device))throw"No device selected.";const t=await this.connect();if(t){const e=t.characteristics;this.device=t,e.forEach(async e=>{const n=e.properties,i=e.characteristic.toLowerCase(),r=this.uuidMap[i],o=H(r)||i,s=e.descriptors||[],a=J[V(r)||27];if(console.log(o,e),s.forEach(e=>{console.log(`${e.uuid} | ${o}`,e)}),n.indexOf("Read"),n.indexOf("Write")>=0){if(this.writes[o])throw new Error(`There is already a writable characteristic named "${o}".`);this.writes[o]=n=>this.ble.withPromises.write(t.id,e.service,e.characteristic,n.buffer??n)}if(n.indexOf("Notify")>=0){const n=G(a,o);let i=null;this.ble.startNotification(t.id,e.service,e.characteristic,(e,t)=>{const r=a.convert(new DataView(e));i!==r&&(i=r,this.emit("updated",{control:o,device:this.deviceName,type:n,value:r}))},e=>{throw e})}})}}requestDevice(e){return console.log("Requesting Device..."),new Promise((t,n)=>{console.log("Starting Scan... "),"ios"!==Y.platformId&&this.ble.isLocationEnabled(()=>{console.log("Location is enabled")},()=>{console.log("Location is disabled")}),this.ble.startScan("ios"===Y.platformId?e?.optionalServices??[]:[],n=>{const i=e?.optionalServices??[];let r=null;if(console.log("Found",n),"ios"===Y.platformId)r=n;else{const e=new Uint8Array(n.advertising),t=Array.prototype.map.call(e,e=>("00"+e.toString(16)).slice(-2)).join("");console.log(t.match(/[a-fA-F0-9]{4}/g).join("-")),i.forEach(e=>{const i=e.replace(/\-/g,"");t.match(/[a-fA-F0-9]{2}/g).reverse().join("").indexOf(i)>=0&&(r=n,console.log(`Found a match! ${e}`))})}r&&(this.ble.stopScan(),t(r))},e=>{console.log("Error",e),this.ble.stopScan(),n(e)})})}connect(){return new Promise((e,t)=>{if(!this.device)throw t(),"No device selected.";this.ble.connect(this.device.id,t=>{this.emit("updated",{control:`${this.deviceName}Connection`,device:this.deviceName,target:t,type:"Button",value:1}),e(t)},()=>{console.log(`${this.deviceName} disconnected.`),this.emit("updated",{control:`${this.deviceName}Connection`,device:this.deviceName,type:"Button",value:0}),this.writes={}})})}disconnect(){this.ble.isConnected(this.device.id,()=>{this.ble.disconnect(this.device.id)},()=>{throw"Device not connected."})}write(e,t){if(!this.writes[e])throw new Error(`No writable characteristic "${e}".`);return this.writes[e](t)}}class ee extends(r()){constructor(e={acceptAllDevices:!0},t="BLEDevice",n={}){super(),this.deviceName=t,this.uuidMap={...Z,...n},this.writes={},e?.gatt?(this.device=e,this.options=null):(this.device=null,this.options=e)}async initialize(e){const t=!!this.device;if(!t){if(!navigator.bluetooth)throw"This web browser does not support Bluetooth.";if(this.device=await navigator.bluetooth.requestDevice(e||this.options),!this.device)throw"No device selected."}this.device.addEventListener("gattserverdisconnected",()=>{console.log(`${this.deviceName} disconnected.`),this.emit("updated",{control:`${this.deviceName}Connection`,device:this.deviceName,type:"Button",value:0}),this.writes={}});try{if(!await this.connect())throw"Not able to connect to device.";{const e=this.device.gatt,t=await e.getPrimaryServices(),n="00002904-0000-1000-8000-00805f9b34fb";t.forEach(async e=>{(await e.getCharacteristics()).forEach(async e=>{const t=e.properties,i=this.uuidMap[e.uuid],r=H(i)||e.uuid;let o=J[27];console.log(r,e);try{const t=await e.getDescriptors();let s=!1;if(t.forEach(async e=>{try{const t=(q[e.uuid]??q.default).convert(await e.readValue());e.uuid===n&&(o=J[t]||J[0],s=!0),console.log(`${e.uuid} | ${r}`,t)}catch(t){console.warn(`Error converting data from descriptor "${e.uuid}".`,t)}}),!s){const e=V(i);e&&(o=J[e])}}catch(e){}if(t.read,t.write){if(this.writes[r])throw new Error(`There is already a writable characteristic named "${r}".`);this.writes[r]=t=>{const n=t instanceof DataView?t:new DataView(t.buffer??t);return e.writeValueWithResponse(n)}}if(t.notify){const t=e=>{const t=e.currentTarget,s=o.convert(t.value);i!==s&&(i=s,this.emit("updated",{control:r,device:this.deviceName,type:n,value:s}))},n=G(o,r);let i=null;await e.startNotifications(),e.addEventListener("characteristicvaluechanged",t)}})})}}catch(e){throw t||(this.device?.gatt?.connected&&this.device.gatt.disconnect(),this.device=null),e}}async connect(){if(this.device){const e=this.device.gatt;return await e.connect(),!!e.connected&&(this.emit("updated",{control:`${this.deviceName}Connection`,device:this.deviceName,target:this.device,type:"Button",value:1}),!0)}throw"No device selected."}disconnect(){if(this.device?.gatt?.connected)return this.device.gatt.disconnect();throw"Device not connected."}write(e,t){if(!this.writes[e])throw new Error(`No writable characteristic "${e}".`);return this.writes[e](t)}}const te=X?Q:ee;class ne extends(r()){constructor(e,t="FabricDevice"){super(),this.inputMethod="pointer",this.pressed=0,e.on("mousedown",n=>{this.pressed=1,this.emit("updated",{control:"FabricPointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.pointer.x,y:n.pointer.y})}),e.on("mousemove",n=>{this.emit("updated",{control:"FabricPointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.pointer.x,y:n.pointer.y})}),e.on("mouseup",n=>{this.pressed=0,this.emit("updated",{control:"FabricPointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.pointer.x,y:n.pointer.y})}),e.on("dropped",n=>{this.emit("updated",{control:"FabricDrop",device:t,event:n,target:e,type:"Drop",value:n.dropZone?n.dropZone.dropZone:"",x:n.dropZone?n.dropZoneX:n.x,y:n.dropZone?n.dropZoneY:n.y}),n.stopPropagation()}),e.on("dragover",n=>{this.emit("updated",{control:"FabricDrag",device:t,event:n,target:e,type:"Drop",value:n.dropZone?n.dropZone.dropZone:"",x:n.dropZone?n.dropZoneX:n.x,y:n.dropZone?n.dropZoneY:n.y}),n.stopPropagation()}),e.on("rotating",n=>{this.emit("updated",{control:"FabricDial",device:t,event:n,target:e,type:"Dial",value:e.angle/360})})}}const ie=ne,re=function(e,t){const n=e.x,i=e.y,r=Math.sqrt(n*n+i*i);if(r>1)e.x*=1/r,e.y*=1/r;else if(r<t)e.x=0,e.y=0;else{const r=1-t;e.x=(n-t)/r,e.y=(i-t)/r}return e},oe=()=>{const e=[...window.navigator.getGamepads()];for(let t=0;t<e.length;t++){const n=e[t];if(n){const e=ce[n.index];e?e.update(n):ce[n.index]=new le(n)}}window.requestAnimationFrame(oe)},se={duration:500,startDelay:0,strongMagnitude:1,weakMagnitude:1},ae={a0:"LeftStick",a1:"RightStick",b0:"AButton",b1:"BButton",b2:"XButton",b3:"YButton",b4:"LeftBumper",b5:"RightBumper",b6:"LeftTrigger",b7:"RightTrigger",b8:"BackButton",b9:"StartButton",b10:"LeftStickButton",b11:"RightStickButton",b12:"UpDPad",b13:"DownDPad",b14:"LeftDPad",b15:"RightDPad"},ce=[];window.addEventListener("gamepadconnected",()=>{oe()});class le extends(r()){constructor(e,t="",n=.1){super(),this.source=e,this.deadzone=n,this.axes=[];for(let t=0;t<e.axes.length>>1;t++)this.axes.push(re({x:e.axes[2*t],y:e.axes[2*t+1]},n));this.buttons=[];for(let t=0;t<e.buttons.length;t++)this.buttons.push(e.buttons[t].value);this.id=t||`${e.id} - ${e.index}`}dualRumble(e=500,t=0,n=1,i=1){se.duration=e,se.startDelay=t,se.strongMagnitude=n,se.weakMagnitude=i,this.source.vibrationActuator.playEffect("dual-rumble",se)}update(e){const t=this.axes,n=this.buttons;for(let n=0;n<t.length;n++){const i=t[n],r=re({x:e.axes[2*n],y:e.axes[2*n+1]},this.deadzone);if(i.x!==r.x||i.y!==r.y){const e=r.x,t=r.y;i.x=e,i.y=t,this.emit("updated",{control:ae[`a${n}`],device:this.id,target:this,type:"Joystick",x:e,y:t})}}for(let t=0;t<e.buttons.length;t++){const i=e.buttons[t].value;i!==n[t]&&(n[t]=i,this.emit("updated",{control:ae[`b${t}`],device:this.id,target:this,type:"Button",value:i}))}}}class ue extends(r()){constructor(){super(),this.inputMethod="gamepad",this.eventHandlers=[],window.addEventListener("gamepadconnected",()=>{this.emit("input-activity","gamepad"),this.updateGamepads()}),this.updateGamepads()}updateGamepads(){for(let e=0;e<this.eventHandlers.length;e++)this.eventHandlers[e].gamepad.off("updated",this.eventHandlers[e].handler);this.eventHandlers.length=0;for(let e=0;e<ce.length;e++){const t=e=>{this.emit("updated",e)};ce[e].on("updated",t),this.eventHandlers.push({gamepad:ce[e],handler:t})}}}const de=ue;class he extends(r()){constructor(e="Keyboard"){super(),this.inputMethod="keyboard",window.addEventListener("keydown",t=>{this.emit("updated",{control:t.code,device:e,event:t,type:"Button",value:1})}),window.addEventListener("keyup",t=>{this.emit("updated",{control:t.code,device:e,event:t,type:"Button",value:0})})}}const fe=he;class pe extends(r()){constructor(e="PageDevice"){super(),this.channel=new k(e),this.channel.addEventListener("message",e=>{this.emit("updated",e)})}}const be=pe;class _e extends(r()){constructor(e,t="PixiDevice"){super(),this.inputMethod="pointer",this.pressed=0,e.on("pointerdown",n=>{this.pressed=1,this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.x,y:n.y})}),e.on("pointermove",n=>{this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.x,y:n.y})}),e.on("pointerup",n=>{this.pressed=0,this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.x,y:n.y})})}}const ve=_e;class me extends(r()){constructor(e,t="PointerDevice"){super(),this.inputMethod="pointer",this.pressed=0,e.addEventListener("pointerdown",n=>{this.pressed=1,this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.x??n.pointer?.x,y:n.y??n.pointer?.y})}),e.addEventListener("pointermove",n=>{this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.x??n.pointer?.x,y:n.y??n.pointer?.y})}),e.addEventListener("pointerup",n=>{this.pressed=0,this.emit("updated",{control:"Pointer",device:t,event:n,target:e,type:"Pointer",value:this.pressed,x:n.x??n.pointer?.x,y:n.y??n.pointer?.y})})}}const ge=me,ye=[250,500,1e3,2e3];function we(){return"undefined"==typeof window?null:window.SpeechRecognition||window.webkitSpeechRecognition||null}function xe(e){return String(e??"").replace(/\s+/g," ").trim().toLowerCase()}function Ee(e=[]){return Array.isArray(e)?e.filter(e=>e&&"string"==typeof e.control&&e.type&&Array.isArray(e.phrases)).map(e=>({control:e.control,type:e.type,phrases:e.phrases.map(xe).filter(Boolean),value:e.value,x:e.x,y:e.y,releaseMs:"number"==typeof e.releaseMs?e.releaseMs:null})).filter(e=>e.phrases.length>0):[]}class Le extends(r()){static supported(){return null!=we()}constructor(e={}){super(),"string"==typeof e&&(e={device:e}),this.device=e.device||"Speech",this.inputMethod="speech",this.transcriptControl=e.transcriptControl||"SpeechTranscript",this.lang=e.lang||"en-US",this.interimResults=Boolean(e.interimResults),this.cooldownMs="number"==typeof e.cooldownMs?e.cooldownMs:800,this._Ctor=we(),this._mappings=Ee(e.mappings),this._cooldownUntil=new Map,this._releaseTimers=new Map,this._recognition=null,this._active=!1,this._listening=!1,this._starting=!1,this._recovering=!1,this._intentionalStop=!1,this._failCount=0,this._destroyed=!1,this._restartTimer=null,this._stopWaitTimer=null,this._startWatchTimer=null,this._warmResult=null,this._warmPromise=null,this._onBlur=()=>{this.setActive(!1)},"undefined"!=typeof window&&window.addEventListener("blur",this._onBlur)}setMappings(e){this._mappings=Ee(e)}setActive(e){const t=Boolean(e);if(this._active!==t){if(this._active=t,!t)return this._failCount=0,void this._stopRecognition();this.emit("input-activity","speech"),this._shouldListen()&&this._scheduleStart(0)}}start(){this.setActive(!0)}stop(){this.setActive(!1)}destroy(){this._destroyed=!0,"undefined"!=typeof window&&window.removeEventListener("blur",this._onBlur),this._clearRestartTimer(),this._clearStopWaitTimer(),this._clearStartWatchTimer(),this._clearAllReleaseTimers(),this.setActive(!1),this.removeAllListeners()}_shouldListen(){return this._active&&!this._destroyed&&null!=this._Ctor}_clearRestartTimer(){null!=this._restartTimer&&(clearTimeout(this._restartTimer),this._restartTimer=null)}_clearStopWaitTimer(){null!=this._stopWaitTimer&&(clearTimeout(this._stopWaitTimer),this._stopWaitTimer=null)}_clearStartWatchTimer(){null!=this._startWatchTimer&&(clearTimeout(this._startWatchTimer),this._startWatchTimer=null)}_clearAllReleaseTimers(){for(const e of this._releaseTimers.values())clearTimeout(e);this._releaseTimers.clear()}_clearReleaseTimer(e){const t=this._releaseTimers.get(e);null!=t&&(clearTimeout(t),this._releaseTimers.delete(e))}_detach(e){e.onstart=null,e.onresult=null,e.onerror=null,e.onend=null}_scheduleStart(e){this._clearRestartTimer(),this._shouldListen()&&(this._restartTimer=setTimeout(()=>{this._restartTimer=null,this._startRecognition()},e))}_noteRecoverableFailure(){if(this._failCount+=1,this._starting=!1,this._listening=!1,!this._shouldListen())return void(this._recovering=!1);if(this._failCount>ye.length)return this._recovering=!1,void this.setActive(!1);this._recovering=!0;const e=ye[this._failCount-1]??ye[ye.length-1];this._scheduleStart(e)}_warmCapture(e=!1){if(e&&(this._warmResult=null),null!=this._warmResult)return Promise.resolve(this._warmResult);if(this._warmPromise)return this._warmPromise;const t="undefined"!=typeof navigator?navigator.mediaDevices:null;if(!t?.getUserMedia)return this._warmResult=!0,Promise.resolve(!0);const n=t.getUserMedia({audio:!0}).then(e=>{for(const t of e.getTracks())t.stop();return this._warmResult=!0,!0}).catch(()=>(this._warmResult=!1,!1)),i=Promise.race([n,new Promise(e=>{setTimeout(()=>e(this._warmResult??!1),1500)})]);return this._warmPromise=i.finally(()=>{this._warmPromise=null}),this._warmPromise}_stopRecognition(){this._clearRestartTimer(),this._clearStartWatchTimer(),this._starting=!1,this._recovering=!1;const e=this._recognition;if(!e)return this._intentionalStop=!1,this._clearStopWaitTimer(),void(this._listening=!1);this._intentionalStop=!0;try{e.stop()}catch(t){try{e.abort()}catch(e){}}this._clearStopWaitTimer(),this._stopWaitTimer=setTimeout(()=>{this._stopWaitTimer=null,this._recognition===e&&(this._recognition=null,this._detach(e)),this._intentionalStop=!1,this._listening=!1,this._shouldListen()&&this._scheduleStart(250)},500)}async _startRecognition(){if(!this._shouldListen()||this._listening||this._starting||this._recognition)return;if(this._clearRestartTimer(),this._starting=!0,(null==this._warmResult||this._failCount>0)&&(await this._warmCapture(this._failCount>0),!this._shouldListen()||this._listening||this._recognition))return void(this._starting=!1);const e=new this._Ctor;this._recognition=e,e.continuous=!0,e.interimResults=!0,e.lang=this.lang,e.onstart=()=>{this._recognition===e&&(this._clearStartWatchTimer(),this._starting=!1,this._failCount=0,this._recovering=!1,this._listening=!0)},e.onresult=t=>{this._recognition===e&&this._handleResult(t)},e.onerror=t=>{if(this._recognition!==e)return;const n=t.error||"";if("aborted"!==n&&"no-speech"!==n){if(this._clearStartWatchTimer(),this._recognition=null,this._detach(e),this._starting=!1,this._listening=!1,"not-allowed"===n||"service-not-allowed"===n)return this._intentionalStop=!1,this._clearStopWaitTimer(),this._recovering=!1,void this.setActive(!1);this._intentionalStop||("audio-capture"===n&&(this._warmResult=null),this._noteRecoverableFailure())}},e.onend=()=>{this._clearStartWatchTimer(),this._recognition===e&&(this._recognition=null,this._detach(e)),this._starting=!1,this._listening=!1,this._intentionalStop=!1,this._clearStopWaitTimer(),this._shouldListen()&&this._scheduleStart(250)};try{e.start(),this._clearStartWatchTimer(),this._startWatchTimer=setTimeout(()=>{if(this._startWatchTimer=null,this._recognition===e&&!this._listening){try{e.abort()}catch(e){}this._recognition===e&&(this._recognition=null,this._detach(e),this._noteRecoverableFailure())}},3e3)}catch(t){this._clearStartWatchTimer(),this._recognition=null,this._detach(e),this._noteRecoverableFailure()}}_handleResult(e){const t=Date.now();for(let n=e.resultIndex;n<e.results.length;n++){const i=e.results[n];if(!i)continue;const r=i[0],o=String(r?.transcript??"").replace(/\s+/g," ").trim();if(!o)continue;const s=Boolean(i.isFinal),a="number"==typeof r?.confidence?r.confidence:void 0;if(!s){this.interimResults&&this.emit("updated",{control:this.transcriptControl,device:this.device,type:"Data",value:{text:o,isFinal:!1,confidence:a,matchedControls:[]},event:e});continue}const c=xe(o),l=[],u=[],d=new Set;for(const e of this._mappings)e.phrases.includes(c)&&(t<(this._cooldownUntil.get(e.control)||0)||(l.push(e),d.has(e.control)||(d.add(e.control),u.push(e.control))));this.emit("updated",{control:this.transcriptControl,device:this.device,type:"Data",value:{text:o,isFinal:!0,confidence:a,matchedControls:u},event:e});for(const n of l)this._cooldownUntil.set(n.control,t+this.cooldownMs),this._emitMapping(n,e)}}_emitMapping(e,t){this._clearReleaseTimer(e.control);const n=e.type;if("Button"===n)return this.emit("updated",{control:e.control,device:this.device,type:"Button",value:1,event:t}),void queueMicrotask(()=>{this._destroyed||this.emit("updated",{control:e.control,device:this.device,type:"Button",value:0,event:t})});if("Joystick"===n){const n="number"==typeof e.x?e.x:0,i="number"==typeof e.y?e.y:0;return this.emit("updated",{control:e.control,device:this.device,type:"Joystick",x:n,y:i,event:t}),void(null!=e.releaseMs&&this._releaseTimers.set(e.control,setTimeout(()=>{this._releaseTimers.delete(e.control),this._destroyed||this.emit("updated",{control:e.control,device:this.device,type:"Joystick",x:0,y:0,event:t})},e.releaseMs)))}const i=e.value;this.emit("updated",{control:e.control,device:this.device,type:n,value:i,event:t}),null==e.releaseMs||"Amount"!==n&&"Dial"!==n||this._releaseTimers.set(e.control,setTimeout(()=>{this._releaseTimers.delete(e.control),this._destroyed||this.emit("updated",{control:e.control,device:this.device,type:n,value:0,event:t})},e.releaseMs))}}const Te={BLEDevice:te,FabricDevice:ie,GamepadDevice:de,KeyboardDevice:fe,PageDevice:be,PixiDevice:ve,PointerDevice:ge,SpeechDevice:Le};window.engagefully={Controller:W,ActionMap:z,actions:N,devices:Te,quantizeStick:function(e,t,n={}){const i=n.sectors??8,r=n.deadzone??.35,o=n.forward??"-y";if(Math.hypot(e,t)<r||i<1)return null;const s="+y"===o?t:-t,a=Math.atan2(e,s);return{sector:(Math.round(a/(2*Math.PI/i))%i+i)%i}},focusGate:function(e={}){const t="function"==typeof e.extra?e.extra:()=>!1;return()=>{if(t())return!1;const e="undefined"!=typeof document?document.activeElement:null;if(!e||e===document.body)return!0;const n=e.tagName;return"INPUT"!==n&&"TEXTAREA"!==n&&"SELECT"!==n&&!e.isContentEditable}}}},187:e=>{var t,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=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(n,i){function r(n){e.removeListener(t,o),i(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",r),n([].slice.call(arguments))}b(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&b(e,"error",t,{once:!0})}(e,r)})},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 l(e,t,n,i){var r,o,s,l;if(a(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),(r=c(e))>0&&s.length>r&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,l=u,console&&console.warn&&console.warn(l)}return e}function u(){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 d(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=u.bind(i);return r.listener=n,i.wrapFn=r,r}function h(e,t,n){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(r):p(r,r.length)}function f(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function b(e,t,n,i){if("function"==typeof e.on)i.once?e.once(t,n):e.on(t,n);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 r(o){i.once&&e.removeEventListener(t,r),n(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||r(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||r(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=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){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 l=c.length,u=p(c,l);for(n=0;n<l;++n)i(u[n],this,t)}return!0},o.prototype.addListener=function(e,t){return l(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return l(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,i,r,o,s;if(a(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(r=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,r=o;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,r),1===n.length&&(i[e]=n[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,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var r,o=Object.keys(n);for(i=0;i<o.length;++i)"removeListener"!==(r=o[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[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 h(this,e,!0)},o.prototype.rawListeners=function(e){return h(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(665)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makefully/engagefully",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Device-agnostic input: keyboard/gamepad/pointer → Button/Joystick, plus ActionMap logical bindings.",
5
5
  "main": "./lib/engagefully.js",
6
6
  "module": "./src/index.js",
@@ -61,10 +61,9 @@
61
61
  "events": "^3.3.0"
62
62
  },
63
63
  "devDependencies": {
64
- "@babel/core": "^7.4.3",
65
- "@babel/preset-env": "^7.4.3",
66
- "babel-loader": "^8.0.2",
67
- "file-loader": "^6.2.0",
64
+ "@babel/core": "^7.29.16",
65
+ "@babel/preset-env": "^7.29.14",
66
+ "babel-loader": "^10.1.1",
68
67
  "happy-dom": "^21.0.4",
69
68
  "vitest": "^5.1.2",
70
69
  "webpack": "^5.68.0",