@transitive-sdk/utils-web 0.8.4 → 0.9.1
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/client/react-web-component/index.js +1 -13
- package/client/shared.jsx +17 -22
- package/dist/utils-web.js +1 -1
- package/docs/client.md +2 -4
- package/package.json +3 -2
- package/dist/_utils-web.js +0 -1
- package/esdist/utils-web.js +0 -15
|
@@ -11,7 +11,6 @@ const lifeCycleHooks = {
|
|
|
11
11
|
attachedCallback: 'webComponentAttached',
|
|
12
12
|
connectedCallback: 'webComponentConnected',
|
|
13
13
|
disconnectedCallback: 'webComponentDisconnected',
|
|
14
|
-
attributeChangedCallback: 'webComponentAttributeChanged',
|
|
15
14
|
adoptedCallback: 'webComponentAdopted'
|
|
16
15
|
};
|
|
17
16
|
|
|
@@ -20,18 +19,12 @@ module.exports = {
|
|
|
20
19
|
* @param {JSX.Element} wrapper: the wrapper component class to be instantiated and wrapped
|
|
21
20
|
* @param {string} tagName - The name of the web component. Has to be minus "-" delimited.
|
|
22
21
|
* @param {boolean} useShadowDom - If the value is set to "true" the web component will use the `shadowDom`. The default value is true.
|
|
23
|
-
* @param {string[]} observedAttributes - The observed attributes of the web component
|
|
24
22
|
*/
|
|
25
|
-
create: (wrapper, tagName, useShadowDom = true,
|
|
26
|
-
compRef = undefined) => {
|
|
23
|
+
create: (wrapper, tagName, useShadowDom = true, compRef = undefined) => {
|
|
27
24
|
|
|
28
25
|
const proto = class extends HTMLElement {
|
|
29
26
|
instance = null; // the instance we create of the wrapper
|
|
30
27
|
|
|
31
|
-
static get observedAttributes() {
|
|
32
|
-
return observedAttributes;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
28
|
callConstructorHook() {
|
|
36
29
|
if (this.instance['webComponentConstructed']) {
|
|
37
30
|
this.instance['webComponentConstructed'].apply(this.instance, [this])
|
|
@@ -82,11 +75,6 @@ module.exports = {
|
|
|
82
75
|
this.callLifeCycleHook('disconnectedCallback');
|
|
83
76
|
}
|
|
84
77
|
|
|
85
|
-
attributeChangedCallback(attributeName, oldValue, newValue, namespace) {
|
|
86
|
-
this.callLifeCycleHook('attributeChangedCallback',
|
|
87
|
-
[attributeName, oldValue, newValue, namespace]);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
78
|
adoptedCallback(oldDocument, newDocument) {
|
|
91
79
|
this.callLifeCycleHook('adoptedCallback', [oldDocument, newDocument]);
|
|
92
80
|
}
|
package/client/shared.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { Button, Accordion, AccordionContext, Card, Badge }
|
|
3
|
-
from 'react-bootstrap';
|
|
3
|
+
from 'react-bootstrap';
|
|
4
4
|
import ReactWebComponent from './react-web-component';
|
|
5
5
|
|
|
6
6
|
import { parseCookie } from './client';
|
|
@@ -138,15 +138,12 @@ const componentPermitsRefs = (Component) =>
|
|
|
138
138
|
|
|
139
139
|
|
|
140
140
|
/** Create a WebComponent from the given react component and name that is
|
|
141
|
-
reactive to
|
|
142
|
-
Example:
|
|
141
|
+
reactive to all attributes. Used in web capabilities. Example:
|
|
143
142
|
```js
|
|
144
|
-
createWebComponent(Diagnostics, 'health-monitoring-device',
|
|
143
|
+
createWebComponent(Diagnostics, 'health-monitoring-device', TR_PKG_VERSION);
|
|
145
144
|
```
|
|
146
145
|
*/
|
|
147
|
-
export const createWebComponent = (Component, name,
|
|
148
|
-
reactiveAttributes = [],
|
|
149
|
-
version = '0.0.0',
|
|
146
|
+
export const createWebComponent = (Component, name, version = '0.0.0',
|
|
150
147
|
options = {}) => {
|
|
151
148
|
|
|
152
149
|
// Only create a ref if the component accepts it. This avoids an ugly
|
|
@@ -157,7 +154,6 @@ export const createWebComponent = (Component, name,
|
|
|
157
154
|
class Wrapper extends React.Component {
|
|
158
155
|
|
|
159
156
|
onDisconnect = null;
|
|
160
|
-
|
|
161
157
|
state = {};
|
|
162
158
|
|
|
163
159
|
/* function used by `Component` to register a onDisconnect handler */
|
|
@@ -165,8 +161,19 @@ export const createWebComponent = (Component, name,
|
|
|
165
161
|
this.onDisconnect = fn;
|
|
166
162
|
}
|
|
167
163
|
|
|
164
|
+
webComponentConstructed(instance) {
|
|
165
|
+
// Observe all changes to attributes and update React state from it
|
|
166
|
+
const observer = new MutationObserver((mutationRecords) => {
|
|
167
|
+
const update = {};
|
|
168
|
+
mutationRecords.forEach(({attributeName}) => {
|
|
169
|
+
update[attributeName] = instance.getAttribute(attributeName);
|
|
170
|
+
});
|
|
171
|
+
this.setState(old => ({...old, ...update}));
|
|
172
|
+
}).observe(instance, { attributes: true });
|
|
173
|
+
}
|
|
174
|
+
|
|
168
175
|
webComponentDisconnected() {
|
|
169
|
-
//
|
|
176
|
+
// This ensures that the react component unmounts and all useEffect
|
|
170
177
|
// cleanups are called.
|
|
171
178
|
this.setState({_disconnected: true});
|
|
172
179
|
try {
|
|
@@ -176,18 +183,6 @@ export const createWebComponent = (Component, name,
|
|
|
176
183
|
}
|
|
177
184
|
}
|
|
178
185
|
|
|
179
|
-
/* Note this relies on the changes made in
|
|
180
|
-
github:amay0048/react-web-component#780950800e2962f45f0f029be618bb8b84610c89
|
|
181
|
-
that we used in our copy.
|
|
182
|
-
TODO: move this into our copy, i.e., do it internally to react-web-component
|
|
183
|
-
and update props.
|
|
184
|
-
*/
|
|
185
|
-
webComponentAttributeChanged(name, oldValue, newValue) {
|
|
186
|
-
const newState = this.state;
|
|
187
|
-
newState[name] = newValue;
|
|
188
|
-
this.setState(newState);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
186
|
/* method exposed to the wrapped component via prop that allows setting
|
|
192
187
|
* the "config" state variable inside the wrapper (not the component
|
|
193
188
|
* itself). This config is retrieved by the portal for inclusion in the
|
|
@@ -222,5 +217,5 @@ export const createWebComponent = (Component, name,
|
|
|
222
217
|
};
|
|
223
218
|
|
|
224
219
|
ReactWebComponent.create(Wrapper, name, options.shadowDOM || false,
|
|
225
|
-
|
|
220
|
+
compRef);
|
|
226
221
|
};
|
package/dist/utils-web.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={720:(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.set(e,n)}function c(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,s(e,t,"get"))}function u(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,s(e,t,"set"),n),n}function s(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var l={get:n(712),set:n(298),unset:n(305),forEach:n(848),map:n(707),isEmpty:n(699),eq:n(113),isPlainObject:n(452),merge:n(831)},f=n(362),p=f.topicToPath,h=f.pathToTopic,d=f.toFlatObject,b=f.topicMatch,y=f.forMatchIterator,v=function e(t,n){if(n&&0!=n.length){l.unset(t,n);var r=n.slice(0,-1),o=0==r.length?t:l.get(t,r);return l.isEmpty(o)?e(t,r):n}},g=function e(t,n){if(0!=n.length){var r=n[0];if(r)for(var o in t)o==r||"*"==r||r.startsWith("+")?e(t[o],n.slice(1)):delete t[o]}},m=new WeakMap,w=new WeakMap,O=new WeakMap,S=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,e),a(this,m,{writable:!0,value:{}}),a(this,w,{writable:!0,value:[]}),a(this,O,{writable:!0,value:[]}),u(this,m,t)}var t,n;return t=e,n=[{key:"updateFromArray",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=l.get(c(this,m),e);if(null==t){if(null==o)return{};v(c(this,m),e)}else{if(l.eq(o,t))return{};l.set(c(this,m),e,t)}var i,a=h(e),u=r({},a,t);if(t instanceof Object){var s=d(t);i={},l.forEach(s,(function(e,t){i["".concat(a).concat(t)]=e}))}else i=u;return c(this,w).forEach((function(e){return e(u,n)})),c(this,O).forEach((function(e){return e(i,n)})),i}},{key:"update",value:function(e,t,n){if("string"==typeof e)return this.updateFromTopic(e,t,n);if(e instanceof Array)return this.updateFromArray(e,t,n);throw new Error("unrecognized path expression")}},{key:"updateFromTopic",value:function(e,t,n){return this.updateFromArray(p(e),t,n)}},{key:"updateFromModifier",value:function(e,t){var n=this;return l.map(e,(function(e,r){return n.updateFromTopic(r,e,t)}))}},{key:"subscribe",value:function(e){e instanceof Function?c(this,w).push(e):console.warn("DataCache.subscribe expects a function as argument. Did you mean to use subscribePath?")}},{key:"subscribePath",value:function(e,t){c(this,w).push((function(n,r){l.forEach(n,(function(n,o){var i=b(e,o);i&&t(n,o,i,r)}))}))}},{key:"subscribePathFlat",value:function(e,t){c(this,O).push((function(n,r){l.forEach(n,(function(n,o){var i=b(e,o);i&&t(n,o,i,r)}))}))}},{key:"unsubscribe",value:function(e){u(this,w,c(this,w).filter((function(t){return t!=e})))}},{key:"get",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return 0==e.length?c(this,m):l.get(c(this,m),e)}},{key:"getByTopic",value:function(e){return this.get(p(e))}},{key:"filter",value:function(e){var t=JSON.parse(JSON.stringify(this.get()));return g(t,e),t}},{key:"filterByTopic",value:function(e){return this.filter(p(e))}},{key:"forMatch",value:function(e,t){var n=p(e);this.forPathMatch(n,t)}},{key:"forPathMatch",value:function(e,t){y(this.get(),e,t)}}],n&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.exports={DataCache:S,updateObject:function(e,t){return l.forEach(t,(function(t,n){var r=p(n);null==t?v(e,r):l.set(e,r,t)})),e}}},890:(e,t,n)=>{"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}var c=n(362),u=c.mqttParsePayload,s=c.topicMatch,l=c.topicToPath,f=c.pathToTopic,p=c.toFlatObject,h=c.getLogger,d=c.mergeVersions,b=c.parseMQTTTopic,y=c.isSubTopicOf,v=c.versionCompare,g=c.encodeTopicElement,m=n(720).DataCache,w=n(517),O=h("MqttSync"),S="$SYS/broker/uptime",E=function(){},k=function(e){return e.endsWith("/#")?e:e.endsWith("/")?e.concat("#"):e.concat("/#")},j=function(e){return e.replace(/\/\//g,"/")},C=function(){function e(t){var n=this,r=t.mqttClient,o=t.onChange,a=t.ignoreRetain,c=t.migrate,s=t.onReady,p=t.sliceTopic;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,"data",new m),i(this,"subscribedPaths",{}),i(this,"publishedPaths",{}),i(this,"publishedMessages",{}),i(this,"publishQueue",new Map),i(this,"heartbeatWaitersOnce",[]),i(this,"heartbeats",0),i(this,"beforeDisconnectHooks",[]),this.mqtt=r,this.mqtt.on("message",(function(e,t,r){var i=t&&t.toString();if(O.debug("got message",e,i.slice(0,180),i.length>180?"... (".concat(i.length," bytes)"):"",r.retain),e==S)n.heartbeats>0&&(n.heartbeatWaitersOnce.forEach((function(e){return e()})),n.heartbeatWaitersOnce=[]),1==n.heartbeats&&!c&&s&&s(),n.heartbeats++;else if(r.retain||a){O.debug("processing message",e),p&&(e=f(l(e).slice(p)));var h=u(t);if(n.isPublished(e))n.publishedMessages[e]=h,n.data.update(e,h,{external:!0});else if(n.isSubscribed(e)){O.debug("applying received update",e);var d=n.data.update(e,h);o&&Object.keys(d).length>0&&o(d)}}})),this.mqtt.subscribe(S,{rap:!0},O.debug),(null==c?void 0:c.length)>0&&this.migrate(c,(function(){O.debug("done migrating",s),s&&n.waitForHeartbeatOnce(s)}))}var t,n;return t=e,n=[{key:"publishAtLevel",value:function(e,t,n){var r=this;O.debug("publishingAtLevel ".concat(n),e,t),n>0?w.forEach(t,(function(t,o){var i="".concat(e,"/").concat(g(o));O.debug("publishing ".concat(i)),r.publishAtLevel(i,t,n-1)})):this.mqtt.publish(e,JSON.stringify(t),{retain:!0},(function(e){e&&O.warn("Error when publishing migration result",e)}))}},{key:"migrate",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=e.length;if(0!=r){var o=function(){return 0==--r&&n&&n()};e.forEach((function(e){var n=e.topic,r=e.newVersion,i=e.transform,a=void 0===i?void 0:i,c=e.flat,u=void 0!==c&&c,s=e.level,h=void 0===s?0:s;O.debug("migrating",n,r);var y=b(n),g=y.organization,m=y.device,S=y.capability,E=y.sub,k="/".concat(g,"/").concat(m,"/").concat(S),C=0==E.length?"/#":f(E),T="".concat(k,"/+").concat(C);t.subscribe(T,(function(e){if(e)return O.warn("Error during migration",e),void o();t.waitForHeartbeatOnce((function(){O.debug("got heartbeat",n,T);var e=t.data.getByTopic(k);if(!e)return t.unsubscribe(T),void o();var i=d(e,C,{maxVersion:r}),c=w.get(i,l(C)),s=a?a(c):c,b=j("".concat(k,"/").concat(r,"/").concat(C));if(O.debug("publishing merged",b),u){var y=p(s),g=l(b);w.forEach(y,(function(e,n){var r=f(g.concat(l(n)));t.mqtt.publish(r,JSON.stringify(e),{retain:!0},(function(e){e&&O.warn("Error when publishing migration result for ".concat(n),e)}))}))}else t.publishAtLevel(b,s,h);t.unsubscribe(T),t.waitForHeartbeatOnce((function(){var n=Object.keys(e).filter((function(e){return v(e,r)<0})).map((function(e){return j("".concat(k,"/").concat(e,"/").concat(C))}));O.debug({prefixesToClear:n}),t.clear(n),o()}))}))}))}))}else n&&n()}},{key:"clear",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=[],i=function(t){e.forEach((function(e){return s("".concat(e,"/#"),t)&&(!r.filter||r.filter(t))&&o.push(t)}))};this.mqtt.on("message",i),e.forEach((function(e){"string"==typeof e?t.mqtt.subscribe("".concat(e,"/#")):O.warn("Ignoring",e,"since it is not a string.")}));var a="undefined"!=typeof Buffer?Buffer.alloc(0):null;this.waitForHeartbeatOnce((function(){t.mqtt.removeListener("message",i),e.forEach((function(e){return t.mqtt.unsubscribe("".concat(e,"/#"))}));var r=o.length;O.debug("clearing ".concat(r," retained messages from ").concat(e)),o.forEach((function(e){t.mqtt.publish(e,a,{retain:!0})})),n&&n(r)}))}},{key:"waitForHeartbeatOnce",value:function(e){var t=this;setTimeout((function(){return t.heartbeatWaitersOnce.push(e)}),1)}},{key:"isSubscribed",value:function(e){return Object.keys(this.subscribedPaths).some((function(t){return s(t,e)}))}},{key:"isPublished",value:function(e){var t=this;return Object.keys(this.publishedPaths).some((function(n){return s(n,e)&&!t.publishedPaths[n].atomic}))}},{key:"subscribe",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:E;if(e=k(e),this.subscribedPaths[e])return O.debug("already subscribed to",e),void n();this.mqtt.subscribe(e,{rap:!0},(function(r,o){O.debug("subscribe",e,"granted:",o),o&&o.some((function(t){return t.topic==e&&t.qos<128}))?(t.subscribedPaths[e]=1,n(null)):n("not permitted to subscribe to topic ".concat(e,", ").concat(JSON.stringify(o)))}))}},{key:"unsubscribe",value:function(e){this.subscribedPaths[e]&&(this.mqtt.unsubscribe(e),delete this.subscribedPaths[e])}},{key:"_actuallyPublish",value:function(e,t){return this.mqtt.connected?(O.debug("actually publishing",e),this.mqtt.publish(e,null==t?null:JSON.stringify(t),{retain:!0}),!0):(O.warn("not connected, not publishing",e),!1)}},{key:"_processQueue_rec",value:function(e){var t=this;if(this.publishQueue.size>0){var n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.publishQueue.entries().next().value,2),o=n[0],i=n[1];this._actuallyPublish(o,i)?(this.publishQueue.delete(o),this._processQueue_rec(e)):setTimeout((function(){return t._processQueue_rec(e)}),5e3)}else e()}},{key:"_processQueue",value:function(){var e=this;this._processing||(this._processing=!0,this._processQueue_rec((function(){return e._processing=!1})))}},{key:"setThrottle",value:function(e){this._processQueueThrottled=w.throttle(this._processQueue.bind(this),e)}},{key:"clearThrottle",value:function(){delete this._processQueueThrottled}},{key:"addToQueue",value:function(e,t){this.publishQueue.set(e,t)}},{key:"_enqueue",value:function(e,t){var n;O.debug("enqueuing",e),this.addToQueue(e,t),this._processQueueThrottled?this._processQueueThrottled():this._processQueue(),null==t?delete this.publishedMessages[e]:this.publishedMessages[e]="object"==a(n=t)?JSON.parse(JSON.stringify(n)):n}},{key:"publish",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{atomic:!1};return e=k(e),!w.isEqual(this.publishedPaths[e],n)&&(this.publishedPaths[e]=n,n.atomic?(this.data.subscribePath(e,(function(n,r,o,i){if(null==i||!i.external){O.debug("processing change (atomic)",r,e);var a=e.slice(0,e.length-2),c=f(l(r).slice(0,l(a).length));t._enqueue(c,t.data.getByTopic(c))}})),!0):(this.mqtt.subscribe(e),void this.data.subscribePath(e,(function(e,n,r,o){if(null==o||!o.external)return O.debug("processing change",n),w.each(t.publishedMessages,(function(e,r){if(O.trace("oldKey",r),r==n)return!0;if(y(r,n)&&t._enqueue(r,null),y(n,r)){t._enqueue(r,null);var o=p(e);w.each(o,(function(e,n){var o="".concat(r).concat(n);t._enqueue(o,e)}))}})),t._enqueue(n,e),!0}))))}},{key:"beforeDisconnect",value:function(){var e=this;this.beforeDisconnectHooks.forEach((function(t){return t(e)}))}},{key:"onBeforeDisconnect",value:function(e){this.beforeDisconnectHooks.push(e)}}],n&&o(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.exports=C},362:(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(13),i=n(84),a={get:n(712),set:n(298),unset:n(305),forEach:n(848),map:n(707),isEmpty:n(699),eq:n(113),isPlainObject:n(452),merge:n(831)},c=n(316),u=n(22),s=n(499);c.setAll=function(e){return Object.values(c.getLoggers()).forEach((function(t){return t.setLevel(e)}))};var l={warn:u.yellow,error:u.red,info:u.green,debug:u.gray},f=c.methodFactory;c.methodFactory=function(e,t,n){var r=f(e,t,n);if("undefined"!=typeof window){var o="".concat(n," ").concat(e);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(void 0,["[".concat(o,"]")].concat(t))}}var i,a="".concat(n," ").concat(l[i=e]?l[i](i):i);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(void 0,["[".concat(u.blue((new Date).toISOString())," ").concat(a,"]")].concat(t))}};var p=c.getLogger,h=function(e){return e.replace(/%/g,"%25").replace(/\//g,"%2F")},d=function(e){return e.replace(/%25/g,"%").replace(/%2F/g,"/")},b=function(e){return"/".concat(e.map((function(e){return e.startsWith("+")?"+":e})).map(h).join("/"))},y=function(e){var t=e.split("/").map(d);return t.length>0&&0==t[0].length&&t.shift(),t.length>0&&0==t.at(-1).length&&t.pop(),t},v=function(e,t){return function e(t,n){if(0==t.length)return!0;if("#"==t[0][0])return!0;if(0==n.length)return!0;if(t[0]==n[0])return e(t.slice(1),n.slice(1));if("+"==t[0][0]){var o=e(t.slice(1),n.slice(1));return o&&Object.assign(r({},t[0].slice(1),n[0]),o)}return!1}(y(e),y(t))},g=function e(t,n){return 0==t.length||t[0]==n[0]&&e(t.slice(1),n.slice(1))},m=function(e,t){return o(i(e),i(t))},w=["B","KB","MB","GB","TB"];e.exports={parseMQTTUsername:function(e){var t=e.split(":");return{organization:t[0],client:t[1],sub:t.slice(2)}},parseMQTTTopic:function(e){var t=y(e);return{organization:t[0],device:t[1],capabilityScope:t[2],capabilityName:t[3],capability:"".concat(t[2],"/").concat(t[3]),version:t[4],sub:t.slice(5)}},pathToTopic:b,topicToPath:y,toFlatObject:function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a.forEach(t,(function(t,o){var i=n.concat(String(o));(a.isPlainObject(t)||t instanceof Array)&&null!==t?e(t,i,r):r[b(i)]=t})),r},topicMatch:v,mqttParsePayload:function(e){return 0==e.length?null:JSON.parse(e.toString("utf-8"))},getRandomId:function(){return Math.random().toString(36).slice(2)},versionCompare:m,loglevel:c,getLogger:p,mergeVersions:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e)return t?a.set({},t,e):e;var r=Object.keys(e).filter((function(e){return(!n.maxVersion||m(e,n.maxVersion)<=0)&&(!n.minVersion||m(n.minVersion,e)<=0)})).sort(m),o={},i=t&&y(t);return r.forEach((function(t){var n=i?a.get(e[t],i):e[t];a.merge(o,n)})),i?a.set({},i,o):o},mqttClearRetained:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e3,o=[],i=function(e){t.forEach((function(t){return v("".concat(t,"/#"),e)&&o.push(e)}))};e.on("message",i),t.forEach((function(t){"string"==typeof t?e.subscribe("".concat(t,"/#")):console.warn("Ignoring",t,"since it is not a string.")}));var a="undefined"!=typeof Buffer?Buffer.alloc(0):null;setTimeout((function(){e.removeListener("message",i),t.forEach((function(t){return e.unsubscribe("".concat(t,"/#"))}));var r=o.length;console.log("clearing ".concat(r," retained messages from ").concat(t)),o.forEach((function(t){e.publish(t,a,{retain:!0})})),n&&n(r)}),r)},isSubTopicOf:function(e,t){var n=y(t),r=y(e);return g(n,r)&&n.length<r.length},clone:function(e){return JSON.parse(JSON.stringify(e))},setFromPath:function e(t,n,r){if(0==n.length)return t;var o=n.shift();0==n.length?t[o]=r:(t[o]||(t[o]={}),e(t[o],n,r))},forMatchIterator:function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(0!=n.length&&"#"!=n[0]){var c=n[0];if(c)for(var u in t)if(u==c||"*"==c||c.startsWith("+")){var s=c.startsWith("+")&&c.length>1?Object.assign({},a,r({},c.slice(1),u)):a;e(t[u],n.slice(1),o,i.concat([u]),s)}}else o(t,i,a)},encodeTopicElement:h,decodeTopicElement:d,constants:s,visit:function e(t,n,r){var o;t&&(r(t),null===(o=t[n])||void 0===o||o.forEach((function(t){return e(t,n,r)})))},wait:function(e){return new Promise((function(t){setTimeout(t,e)}))},formatBytes:function(e){if(!e)return"--";for(var t=0;e>1024;)e/=1024,t++;return"".concat(e.toFixed(2)," ").concat(w[t])},formatDuration:function(e){if(!e)return"--";var t={};e>3600&&(t.h=Math.floor(e/3600),e%=3600),e>60&&(t.m=Math.floor(e/60),e%=60),t.s=Math.floor(e);var n="";return t.h>0&&(n+="".concat(t.h,"h ")),t.m>0&&(n+="".concat(t.m,"m ")),!t.h&&(n+="".concat(t.s,"s")),n.trim()},tryJSONParse:function(e){try{return JSON.parse(e)}catch(e){return null}},decodeJWT:function(e){return JSON.parse(atob(e.split(".")[1]))}}},499:e=>{e.exports={rosReleases:{kinetic:{rosVersion:1,ubuntuCodename:"xenial"},melodic:{rosVersion:1,ubuntuCodename:"bionic"},noetic:{rosVersion:1,ubuntuCodename:"focal"},dashing:{rosVersion:2},eloquent:{rosVersion:2},foxy:{rosVersion:2},galactic:{rosVersion:2},humble:{rosVersion:2},iron:{rosVersion:2},rolling:{rosVersion:2}}}},216:(e,t,n)=>{"use strict";n.r(t),n.d(t,{MqttSync:()=>c,fetchJson:()=>s,parseCookie:()=>u});var r=n(362),o={};for(const e in r)["default","MqttSync","parseCookie","fetchJson"].indexOf(e)<0&&(o[e]=()=>r[e]);n.d(t,o);var i=n(720);o={};for(const e in i)["default","MqttSync","parseCookie","fetchJson"].indexOf(e)<0&&(o[e]=()=>i[e]);n.d(t,o);var a=n(890),c=n.n(a)(),u=function(e){return e.split(";").map((function(e){return e.split("=")})).reduce((function(e,t){return e[decodeURIComponent(t[0].trim())]=t[1]&&decodeURIComponent(t[1].trim()),e}),{})},s=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};fetch(e,{method:n.method||(n.body?"post":"get"),mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:n.body?JSON.stringify(n.body):void 0}).then((function(n){var r=!n.ok&&"fetching ".concat(e," failed: ").concat(n.status," ").concat(n.statusText);n.json().then((function(e){return t(r,e)})).catch((function(e){throw new Error(e)}))})).catch((function(e){return t("error: ".concat(e))}))}},782:(e,t,n)=>{"use strict";n.d(t,{H:()=>v,D:()=>g});var r=n(689),o=n.n(r),i=n(517),a=n.n(i);const c=require("mqtt-browser");var u=n.n(c),s=n(216);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var b=n(890),y=(0,s.getLogger)("utils-web/hooks");y.setLevel("info");var v=function(e){var t=e.jwt,n=e.id,i=e.mqttUrl,c=h((0,r.useState)("connecting"),2),l=c[0],f=c[1],p=h((0,r.useState)(),2),d=p[0],v=p[1],g=h((0,r.useState)({}),2),m=g[0],w=g[1];return(0,r.useEffect)((function(){var e=(0,s.decodeJWT)(t),r=u().connect(i,{username:JSON.stringify({id:n,payload:e}),password:t});return r.on("connect",(function(){y.debug("connected");var e=new b({mqttClient:r,ignoreRetain:!0});v(e),f("connected"),e.data.subscribe(a().throttle((function(){return w((0,s.clone)(e.data.get()))}),50))})),r.on("error",(function(e){y.error(e),f("error: ".concat(e))})),function(){y.info("cleaning up useMQTTSync"),d&&d.beforeDisconnect?(d.beforeDisconnect(),d.waitForHeartbeatOnce((function(){return r.end()}))):r.end()}}),[t,n]),{status:l,ready:"connected"==l,StatusComponent:function(){return o().createElement("div",null,l)},mqttSync:d,data:m}},g=function(e){var t=e.jwt,n=e.id,r=e.host,o=e.ssl,i=e.capability,a=e.versionNS,c=h(i.split("/"),2),u=c[0],l=c[1],p=(0,s.decodeJWT)(t).device,d=[n,p,u,l],b=(0,s.pathToTopic)(d),y=[].concat(d,[a]),g=(0,s.pathToTopic)(y),m="".concat(o&&JSON.parse(o)?"wss":"ws","://mqtt.").concat(r);return f(f({},v({jwt:t,id:n,mqttUrl:m})),{},{device:p,prefixPath:d,prefix:b,prefixPathVersion:y,prefixVersion:g})}},809:e=>{function t(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}e.exports=function(e){if(!e.attributes)return{};var r,o,i,a={},c=(i=e.attributes,function(e){if(Array.isArray(e))return n(e)}(i)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||t(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){return function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e.name,e.value)})),u=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=t(e))){r&&(e=r);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw a}}}}(c);try{for(u.s();!(o=u.n()).done;){r=o.value;var s=Object.keys(r)[0];a[s.replace(/-([a-z])/g,(function(e){return e[1].toUpperCase()}))]=r[s]}}catch(e){u.e(e)}finally{u.f()}return a}},613:(e,t,n)=>{e.exports=function(){try{return n(962).styleElements}catch(e){return[]}}},927:(e,t,n)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}function u(e){var t=h();return function(){var n,r=b(e);if(t){var o=b(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return s(this,n)}}function s(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return l(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){var t="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return p(e,arguments,b(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},f(e)}function p(e,t,n){return p=h()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&d(o,n.prototype),o},p.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=n(689),g=n(405),m=n(430),w=n(613),O=n(809);n(622),n(268);var S={attachedCallback:"webComponentAttached",connectedCallback:"webComponentConnected",disconnectedCallback:"webComponentDisconnected",attributeChangedCallback:"webComponentAttributeChanged",adoptedCallback:"webComponentAdopted"};e.exports={create:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,s=function(t){c(f,t);var s=u(f);function f(){var e;o(this,f);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return y(l(e=s.call.apply(s,[this].concat(n))),"instance",null),e}return a(f,[{key:"callConstructorHook",value:function(){this.instance.webComponentConstructed&&this.instance.webComponentConstructed.apply(this.instance,[this])}},{key:"callLifeCycleHook",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=S[e];n&&this.instance&&this.instance[n]&&this.instance[n].apply(this.instance,t)}},{key:"connectedCallback",value:function(){var t=this,r=t;if(n){var o=t.attachShadow({mode:"open"});r=document.createElement("div"),w().forEach((function(e){o.appendChild(e.cloneNode(o))})),o.appendChild(r),m(o)}g.render(v.createElement(e,O(t)),r,(function(){t.instance=this,t.callConstructorHook(),t.callLifeCycleHook("connectedCallback")}))}},{key:"disconnectedCallback",value:function(){this.callLifeCycleHook("disconnectedCallback")}},{key:"attributeChangedCallback",value:function(e,t,n,r){this.callLifeCycleHook("attributeChangedCallback",[e,t,n,r])}},{key:"adoptedCallback",value:function(e,t){this.callLifeCycleHook("adoptedCallback",[e,t])}},{key:"call",value:function(e,t){var n,r;return null==i||null===(n=i.current)||void 0===n||null===(r=n[e])||void 0===r?void 0:r.call(null==i?void 0:i.current,t)}},{key:"getConfig",value:function(){return this.instance.state.config}}],[{key:"observedAttributes",get:function(){return r}}]),f}(f(HTMLElement));customElements.define(t,s)}}},498:(e,t,n)=>{"use strict";n.d(t,{EK:()=>j,SV:()=>q,ZM:()=>C,U5:()=>k,B7:()=>x,ax:()=>P,eZ:()=>M});var r=n(689),o=n.n(r);const i=require("react-bootstrap");var a=n(927),c=n.n(a);function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function h(e,t,n){return t&&p(e.prototype,t),n&&p(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function b(e,t){return b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},b(e,t)}function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=m(e);if(t){var o=m(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return v(this,n)}}function v(e,t){if(t&&("object"===u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n(216);var S={badge:{width:"4em"},code:{color:"#700",borderLeft:"3px solid #aaa",padding:"0.5em 0px 0.5em 2em",backgroundColor:"#f0f0f0",borderRadius:"4px",marginTop:"0.5em"},inlineCode:{color:"#700",margin:"0px 0.5em 0px 0.5em"}},E=[o().createElement(i.Badge,{bg:"success",style:S.badge},"OK"),o().createElement(i.Badge,{bg:"warning",style:S.badge},"Warn"),o().createElement(i.Badge,{bg:"danger",style:S.badge},"Error"),o().createElement(i.Badge,{bg:"secondary",style:S.badge},"Stale")],k=function(e){var t=e.level;return E[t]||o().createElement("span",null,t)},j=function(e){var t=e.children;return o().createElement("pre",{style:S.code},t)},C=function(e){var t=e.children;return o().createElement("tt",{style:S.inlineCode},t)},T={},P=o().createContext({}),x=function(e){var t=e.duration,n=e.onTimeout,a=e.onStart,c=e.setOnDisconnect,u=e.children;t=t||60;var s=w((0,r.useState)(t),2),l=s[0],f=s[1],p=w((0,r.useState)(!1),2),h=p[0],d=p[1],b=(0,r.useMemo)((function(){return Math.random().toString(36).slice(2)}),[]),y=function(){console.log("stopping timer for",b),n&&setTimeout(n,1),clearInterval(T[b]),T[b]=null,d(!1)};(0,r.useEffect)((function(){var e;l>0&&!h&&(e=T[b],console.log(e,T,l),!e&&l>0&&(d(!0),T[b]=setInterval((function(){return f((function(e){if(--e>0)return e;y()}))}),1e3),a&&setTimeout(a,1)))}),[l]),(0,r.useEffect)((function(){return y}),[]),c&&c((function(){y()}));var v=function(){return f(t)};return o().createElement(P.Provider,{value:{reset:v,duration:t,timer:l}},l>0?o().createElement("div",null,u,l<60&&o().createElement("div",null,"Timeout in: ",l," seconds")):o().createElement("div",null,"Timed out. ",o().createElement(i.Button,{onClick:v},"Resume")))},q=function(e){d(n,e);var t=y(n);function n(e){var r;return f(this,n),(r=t.call(this,e)).state={hasError:!1},r}return h(n,[{key:"componentDidCatch",value:function(e,t){console.warn("ErrorBoundary caught:",e,t)}},{key:"render",value:function(){return this.state.hasError?o().createElement("div",null,this.props.message||"Something went wrong here."):this.props.children}}],[{key:"getDerivedStateFromError",value:function(e){return{hasError:!0}}}]),n}(o().Component),_=function(e){var t;return e.$$typeof==Symbol.for("react.forward_ref")||(null===(t=e.prototype)||void 0===t?void 0:t.render)},M=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"0.0.0",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=_(e)?o().createRef():null,u=function(n){d(u,n);var c=y(u);function u(){var e;f(this,u);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return l(g(e=c.call.apply(c,[this].concat(n))),"onDisconnect",null),l(g(e),"state",{}),e}return h(u,[{key:"setOnDisconnect",value:function(e){this.onDisconnect=e}},{key:"webComponentDisconnected",value:function(){this.setState({_disconnected:!0});try{this.onDisconnect&&this.onDisconnect()}catch(e){console.log("Error during onDisconnect of web-component",e)}}},{key:"webComponentAttributeChanged",value:function(e,t,n){var r=this.state;r[e]=n,this.setState(r)}},{key:"setConfig",value:function(e){this.setState({config:e})}},{key:"render",value:function(){var n=i.stylesheets||["https://cdn.jsdelivr.net/gh/transitiverobotics/transitive-utils@0.8.3/web/css/bootstrap_transitive-bs-root.min.css"];return o().createElement("div",{id:"cap-".concat(t,"-").concat(r),className:i.className||"transitive-bs-root"},o().createElement("style",null,n.map((function(e){return"@import url(".concat(e,");")}))),!this.state._disconnected&&o().createElement(e,s({ref:a},this.props,this.state,{setOnDisconnect:this.setOnDisconnect.bind(this),setConfig:this.setConfig.bind(this)})))}}]),u}(o().Component);c().create(u,t,i.shadowDOM||!1,n,a)}},268:e=>{"use strict";e.exports=require("@webcomponents/custom-elements")},622:e=>{"use strict";e.exports=require("@webcomponents/shadydom")},22:e=>{"use strict";e.exports=require("chalk")},517:e=>{"use strict";e.exports=require("lodash")},848:e=>{"use strict";e.exports=require("lodash/forEach")},712:e=>{"use strict";e.exports=require("lodash/get")},699:e=>{"use strict";e.exports=require("lodash/isEmpty")},113:e=>{"use strict";e.exports=require("lodash/isEqual")},452:e=>{"use strict";e.exports=require("lodash/isPlainObject")},707:e=>{"use strict";e.exports=require("lodash/map")},831:e=>{"use strict";e.exports=require("lodash/merge")},298:e=>{"use strict";e.exports=require("lodash/set")},305:e=>{"use strict";e.exports=require("lodash/unset")},316:e=>{"use strict";e.exports=require("loglevel")},689:e=>{"use strict";e.exports=require("react")},405:e=>{"use strict";e.exports=require("react-dom")},430:e=>{"use strict";e.exports=require("react-shadow-dom-retarget-events")},962:e=>{"use strict";e.exports=require("react-web-component-style-loader/exports")},13:e=>{"use strict";e.exports=require("semver/functions/compare")},84:e=>{"use strict";e.exports=require("semver/ranges/min-version")}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.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 r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{Code:()=>e.EK,ErrorBoundary:()=>e.SV,InlineCode:()=>e.ZM,LevelBadge:()=>e.U5,Timer:()=>e.B7,TimerContext:()=>e.ax,createWebComponent:()=>e.eZ,useMqttSync:()=>t.H,useTransitive:()=>t.D});var e=n(498),t=n(782),o=n(216),i={};for(const e in o)["default","Code","ErrorBoundary","InlineCode","LevelBadge","Timer","TimerContext","createWebComponent","useMqttSync","useTransitive"].indexOf(e)<0&&(i[e]=()=>o[e]);n.d(r,i)})();var o=exports;for(var i in r)o[i]=r[i];r.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{var e={720:(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.set(e,n)}function c(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,s(e,t,"get"))}function u(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,s(e,t,"set"),n),n}function s(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var l={get:n(712),set:n(298),unset:n(305),forEach:n(848),map:n(707),isEmpty:n(699),eq:n(113),isPlainObject:n(452),merge:n(831)},f=n(362),p=f.topicToPath,h=f.pathToTopic,d=f.toFlatObject,b=f.topicMatch,y=f.forMatchIterator,v=function e(t,n){if(n&&0!=n.length){l.unset(t,n);var r=n.slice(0,-1),o=0==r.length?t:l.get(t,r);return l.isEmpty(o)?e(t,r):n}},g=function e(t,n){if(0!=n.length){var r=n[0];if(r)for(var o in t)o==r||"*"==r||r.startsWith("+")?e(t[o],n.slice(1)):delete t[o]}},m=new WeakMap,w=new WeakMap,O=new WeakMap,S=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,e),a(this,m,{writable:!0,value:{}}),a(this,w,{writable:!0,value:[]}),a(this,O,{writable:!0,value:[]}),u(this,m,t)}var t,n;return t=e,n=[{key:"updateFromArray",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=l.get(c(this,m),e);if(null==t){if(null==o)return{};v(c(this,m),e)}else{if(l.eq(o,t))return{};l.set(c(this,m),e,t)}var i,a=h(e),u=r({},a,t);if(t instanceof Object){var s=d(t);i={},l.forEach(s,(function(e,t){i["".concat(a).concat(t)]=e}))}else i=u;return c(this,w).forEach((function(e){return e(u,n)})),c(this,O).forEach((function(e){return e(i,n)})),i}},{key:"update",value:function(e,t,n){if("string"==typeof e)return this.updateFromTopic(e,t,n);if(e instanceof Array)return this.updateFromArray(e,t,n);throw new Error("unrecognized path expression")}},{key:"updateFromTopic",value:function(e,t,n){return this.updateFromArray(p(e),t,n)}},{key:"updateFromModifier",value:function(e,t){var n=this;return l.map(e,(function(e,r){return n.updateFromTopic(r,e,t)}))}},{key:"subscribe",value:function(e){e instanceof Function?c(this,w).push(e):console.warn("DataCache.subscribe expects a function as argument. Did you mean to use subscribePath?")}},{key:"subscribePath",value:function(e,t){c(this,w).push((function(n,r){l.forEach(n,(function(n,o){var i=b(e,o);i&&t(n,o,i,r)}))}))}},{key:"subscribePathFlat",value:function(e,t){c(this,O).push((function(n,r){l.forEach(n,(function(n,o){var i=b(e,o);i&&t(n,o,i,r)}))}))}},{key:"unsubscribe",value:function(e){u(this,w,c(this,w).filter((function(t){return t!=e})))}},{key:"get",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return 0==e.length?c(this,m):l.get(c(this,m),e)}},{key:"getByTopic",value:function(e){return this.get(p(e))}},{key:"filter",value:function(e){var t=JSON.parse(JSON.stringify(this.get()));return g(t,e),t}},{key:"filterByTopic",value:function(e){return this.filter(p(e))}},{key:"forMatch",value:function(e,t){var n=p(e);this.forPathMatch(n,t)}},{key:"forPathMatch",value:function(e,t){y(this.get(),e,t)}}],n&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.exports={DataCache:S,updateObject:function(e,t){return l.forEach(t,(function(t,n){var r=p(n);null==t?v(e,r):l.set(e,r,t)})),e}}},890:(e,t,n)=>{"use strict";function r(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||o(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}var s=n(362),l=s.mqttParsePayload,f=s.topicMatch,p=s.topicToPath,h=s.pathToTopic,d=s.toFlatObject,b=s.getLogger,y=s.mergeVersions,v=s.parseMQTTTopic,g=(s.isSubTopicOf,s.versionCompare),m=s.encodeTopicElement,w=s.visitAncestor,O=n(720).DataCache,S=n(517),j=b("MqttSync"),E="$SYS/broker/uptime",k="$_",P=function(){},T=function(e){return e.endsWith("/#")?e:e.endsWith("/")?e.concat("#"):e.concat("/#")},C=function(e){return e.replace(/\/\//g,"/")},x=function(){function e(t){var n=this,o=t.mqttClient,i=t.onChange,a=t.ignoreRetain,u=t.migrate,s=t.onReady,f=t.sliceTopic;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c(this,"data",new O),c(this,"subscribedPaths",{}),c(this,"publishedPaths",{}),c(this,"publishedMessages",new O),c(this,"publishQueue",new Map),c(this,"heartbeatWaitersOnce",[]),c(this,"heartbeats",0),c(this,"beforeDisconnectHooks",[]),this.mqtt=o,this.mqtt.on("message",(function(e,t,o){var c=t&&t.toString();if(j.debug("got message",e,c.slice(0,180),c.length>180?"... (".concat(c.length," bytes)"):"",o.retain),e==E)n.heartbeats>0&&(n.heartbeatWaitersOnce.forEach((function(e){return e()})),n.heartbeatWaitersOnce=[]),1==n.heartbeats&&!u&&s&&s(),n.heartbeats++;else if(o.retain||a){var d=p(e);j.debug("processing message",e,d),f&&(d=d.slice(f),e=h(d));var b=l(t);if(n.isPublished(e))n.publishedMessages.updateFromArray([].concat(r(d),[k]),b),n.data.update(e,b,{external:!0});else if(n.isSubscribed(e)){j.debug("applying received update",e);var y=n.data.update(e,b);i&&Object.keys(y).length>0&&i(y)}}})),this.mqtt.subscribe(E,{rap:!0},j.debug),(null==u?void 0:u.length)>0&&this.migrate(u,(function(){j.debug("done migrating",s),s&&n.waitForHeartbeatOnce(s)}))}var t,n;return t=e,n=[{key:"publishAtLevel",value:function(e,t,n){var r=this;j.debug("publishingAtLevel ".concat(n),e,t),n>0?S.forEach(t,(function(t,o){var i="".concat(e,"/").concat(m(o));j.debug("publishing ".concat(i)),r.publishAtLevel(i,t,n-1)})):this.mqtt.publish(e,JSON.stringify(t),{retain:!0},(function(e){e&&j.warn("Error when publishing migration result",e)}))}},{key:"migrate",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=e.length;if(0!=r){var o=function(){return 0==--r&&n&&n()};e.forEach((function(e){var n=e.topic,r=e.newVersion,i=e.transform,a=void 0===i?void 0:i,c=e.flat,u=void 0!==c&&c,s=e.level,l=void 0===s?0:s;j.debug("migrating",n,r);var f=v(n),b=f.organization,m=f.device,w=f.capability,O=f.sub,E="/".concat(b,"/").concat(m,"/").concat(w),k=0==O.length?"/#":h(O),P="".concat(E,"/+").concat(k);t.subscribe(P,(function(e){if(e)return j.warn("Error during migration",e),void o();t.waitForHeartbeatOnce((function(){j.debug("got heartbeat",n,P);var e=t.data.getByTopic(E);if(!e)return t.unsubscribe(P),void o();var i=y(e,k,{maxVersion:r}),c=S.get(i,p(k)),s=a?a(c):c,f=C("".concat(E,"/").concat(r,"/").concat(k));if(j.debug("publishing merged",f),u){var b=d(s),v=p(f);S.forEach(b,(function(e,n){var r=h(v.concat(p(n)));t.mqtt.publish(r,JSON.stringify(e),{retain:!0},(function(e){e&&j.warn("Error when publishing migration result for ".concat(n),e)}))}))}else t.publishAtLevel(f,s,l);t.unsubscribe(P),t.waitForHeartbeatOnce((function(){var n=Object.keys(e).filter((function(e){return g(e,r)<0})).map((function(e){return C("".concat(E,"/").concat(e,"/").concat(k))}));j.debug({prefixesToClear:n}),t.clear(n),o()}))}))}))}))}else n&&n()}},{key:"clear",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=[],i=function(t){e.forEach((function(e){return f("".concat(e,"/#"),t)&&(!r.filter||r.filter(t))&&o.push(t)}))};this.mqtt.on("message",i),e.forEach((function(e){"string"==typeof e?t.mqtt.subscribe("".concat(e,"/#")):j.warn("Ignoring",e,"since it is not a string.")}));var a="undefined"!=typeof Buffer?Buffer.alloc(0):null;this.waitForHeartbeatOnce((function(){t.mqtt.removeListener("message",i),e.forEach((function(e){return t.mqtt.unsubscribe("".concat(e,"/#"))}));var r=o.length;j.debug("clearing ".concat(r," retained messages from ").concat(e)),o.forEach((function(e){t.mqtt.publish(e,a,{retain:!0})})),n&&n(r)}))}},{key:"waitForHeartbeatOnce",value:function(e){var t=this;setTimeout((function(){return t.heartbeatWaitersOnce.push(e)}),1)}},{key:"isSubscribed",value:function(e){return Object.keys(this.subscribedPaths).some((function(t){return f(t,e)}))}},{key:"isPublished",value:function(e){var t=this;return Object.keys(this.publishedPaths).some((function(n){return f(n,e)&&!t.publishedPaths[n].atomic}))}},{key:"subscribe",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:P;if(e=T(e),this.subscribedPaths[e])return j.debug("already subscribed to",e),void n();this.mqtt.subscribe(e,{rap:!0},(function(r,o){j.debug("subscribe",e,"granted:",o),o&&o.some((function(t){return t.topic==e&&t.qos<128}))?(t.subscribedPaths[e]=1,n(null)):n("not permitted to subscribe to topic ".concat(e,", ").concat(JSON.stringify(o)))}))}},{key:"unsubscribe",value:function(e){this.subscribedPaths[e]&&(this.mqtt.unsubscribe(e),delete this.subscribedPaths[e])}},{key:"_actuallyPublish",value:function(e,t){return this.mqtt.connected?(j.debug("actually publishing",e),this.mqtt.publish(e,null==t?null:JSON.stringify(t),{retain:!0}),!0):(j.warn("not connected, not publishing",e),!1)}},{key:"_processQueue_rec",value:function(e){var t=this;if(this.publishQueue.size>0){var n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||o(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.publishQueue.entries().next().value,2),r=n[0],i=n[1];this._actuallyPublish(r,i)?(this.publishQueue.delete(r),this._processQueue_rec(e)):setTimeout((function(){return t._processQueue_rec(e)}),5e3)}else e()}},{key:"_processQueue",value:function(){var e=this;this._processing||(this._processing=!0,this._processQueue_rec((function(){return e._processing=!1})))}},{key:"setThrottle",value:function(e){this._processQueueThrottled=S.throttle(this._processQueue.bind(this),e)}},{key:"clearThrottle",value:function(){delete this._processQueueThrottled}},{key:"addToQueue",value:function(e,t){this.publishQueue.set(e,t)}},{key:"_enqueue",value:function(e,t){j.debug("enqueuing",e),this.addToQueue(e,t),this._processQueueThrottled?this._processQueueThrottled():this._processQueue();var n,o=p(e);this.publishedMessages.updateFromArray([].concat(r(o),[k]),null==t?null:"object"==u(n=t)?JSON.parse(JSON.stringify(n)):n)}},{key:"publish",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{atomic:!1};return e=T(e),!S.isEqual(this.publishedPaths[e],n)&&(this.publishedPaths[e]=n,n.atomic?(this.data.subscribePath(e,(function(n,r,o,i){if(null==i||!i.external){j.debug("processing change (atomic)",r,e);var a=e.slice(0,e.length-2),c=h(p(r).slice(0,p(a).length));t._enqueue(c,t.data.getByTopic(c))}})),!0):(this.mqtt.subscribe(e),void this.data.subscribePath(e,(function(e,n,r,o){if(null==o||!o.external){j.debug("processing change",n);var i=p(n),a=t.publishedMessages.get(i);return S.each(a,(function(e,r){if(r==k)return!0;var o=Object.keys(d(e)).filter((function(e){return e.endsWith(k)}));j.debug("flat->atomic: ",{toClear:o},r),o.forEach((function(e){var o=e.slice(0,-(k.length+1)),i="".concat(n,"/").concat(r,"/").concat(o);t._enqueue(i,null)}))})),w(t.publishedMessages.get(),i,(function(e,n){var r=e.$_;if(r&&S.isObject(r)){j.debug("atomic->flat",{oldVal:r});var o=h(n);t._enqueue(o,null);var i=d(r);S.each(i,(function(e,n){var r="".concat(o).concat(n);t._enqueue(r,e)}))}})),t._enqueue(n,e),!0}}))))}},{key:"beforeDisconnect",value:function(){var e=this;this.beforeDisconnectHooks.forEach((function(t){return t(e)}))}},{key:"onBeforeDisconnect",value:function(e){this.beforeDisconnectHooks.push(e)}}],n&&a(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.exports=x},362:(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(13),i=n(84),a={get:n(712),set:n(298),unset:n(305),forEach:n(848),map:n(707),isEmpty:n(699),eq:n(113),isPlainObject:n(452),merge:n(831)},c=n(316),u=n(22),s=n(499);c.setAll=function(e){return Object.values(c.getLoggers()).forEach((function(t){return t.setLevel(e)}))};var l={warn:u.yellow,error:u.red,info:u.green,debug:u.gray},f=c.methodFactory;c.methodFactory=function(e,t,n){var r=f(e,t,n);if("undefined"!=typeof window){var o="".concat(n," ").concat(e);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(void 0,["[".concat(o,"]")].concat(t))}}var i,a="".concat(n," ").concat(l[i=e]?l[i](i):i);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(void 0,["[".concat(u.blue((new Date).toISOString())," ").concat(a,"]")].concat(t))}};var p=c.getLogger,h=function(e){return e.replace(/%/g,"%25").replace(/\//g,"%2F")},d=function(e){return e.replace(/%25/g,"%").replace(/%2F/g,"/")},b=function(e){return"/".concat(e.map((function(e){return e.startsWith("+")?"+":e})).map(h).join("/"))},y=function(e){var t=e.split("/").map(d);return t.length>0&&0==t[0].length&&t.shift(),t.length>0&&0==t.at(-1).length&&t.pop(),t},v=function(e,t){return function e(t,n){if(0==t.length)return!0;if("#"==t[0][0])return!0;if(0==n.length)return!0;if(t[0]==n[0])return e(t.slice(1),n.slice(1));if("+"==t[0][0]){var o=e(t.slice(1),n.slice(1));return o&&Object.assign(r({},t[0].slice(1),n[0]),o)}return!1}(y(e),y(t))},g=function e(t,n){return 0==t.length||t[0]==n[0]&&e(t.slice(1),n.slice(1))},m=function(e,t){return o(i(e),i(t))},w=["B","KB","MB","GB","TB"];e.exports={parseMQTTUsername:function(e){var t=e.split(":");return{organization:t[0],client:t[1],sub:t.slice(2)}},parseMQTTTopic:function(e){var t=y(e);return{organization:t[0],device:t[1],capabilityScope:t[2],capabilityName:t[3],capability:"".concat(t[2],"/").concat(t[3]),version:t[4],sub:t.slice(5)}},pathToTopic:b,topicToPath:y,toFlatObject:function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a.forEach(t,(function(t,o){var i=n.concat(String(o));(a.isPlainObject(t)||t instanceof Array)&&null!==t?e(t,i,r):r[b(i)]=t})),r},topicMatch:v,mqttParsePayload:function(e){return 0==e.length?null:JSON.parse(e.toString("utf-8"))},getRandomId:function(){return Math.random().toString(36).slice(2)},versionCompare:m,loglevel:c,getLogger:p,mergeVersions:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e)return t?a.set({},t,e):e;var r=Object.keys(e).filter((function(e){return(!n.maxVersion||m(e,n.maxVersion)<=0)&&(!n.minVersion||m(n.minVersion,e)<=0)})).sort(m),o={},i=t&&y(t);return r.forEach((function(t){var n=i?a.get(e[t],i):e[t];a.merge(o,n)})),i?a.set({},i,o):o},mqttClearRetained:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e3,o=[],i=function(e){t.forEach((function(t){return v("".concat(t,"/#"),e)&&o.push(e)}))};e.on("message",i),t.forEach((function(t){"string"==typeof t?e.subscribe("".concat(t,"/#")):console.warn("Ignoring",t,"since it is not a string.")}));var a="undefined"!=typeof Buffer?Buffer.alloc(0):null;setTimeout((function(){e.removeListener("message",i),t.forEach((function(t){return e.unsubscribe("".concat(t,"/#"))}));var r=o.length;console.log("clearing ".concat(r," retained messages from ").concat(t)),o.forEach((function(t){e.publish(t,a,{retain:!0})})),n&&n(r)}),r)},isSubTopicOf:function(e,t){var n=y(t),r=y(e);return g(n,r)&&n.length<r.length},clone:function(e){return JSON.parse(JSON.stringify(e))},setFromPath:function e(t,n,r){if(0==n.length)return t;var o=n.shift();0==n.length?t[o]=r:(t[o]||(t[o]={}),e(t[o],n,r))},forMatchIterator:function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(0!=n.length&&"#"!=n[0]){var c=n[0];if(c)for(var u in t)if(u==c||"*"==c||c.startsWith("+")){var s=c.startsWith("+")&&c.length>1?Object.assign({},a,r({},c.slice(1),u)):a;e(t[u],n.slice(1),o,i.concat([u]),s)}}else o(t,i,a)},encodeTopicElement:h,decodeTopicElement:d,constants:s,visit:function e(t,n,r){var o;t&&(r(t),null===(o=t[n])||void 0===o||o.forEach((function(t){return e(t,n,r)})))},wait:function(e){return new Promise((function(t){setTimeout(t,e)}))},formatBytes:function(e){if(!e)return"--";for(var t=0;e>1024;)e/=1024,t++;return"".concat(e.toFixed(2)," ").concat(w[t])},formatDuration:function(e){if(!e)return"--";var t={};e>3600&&(t.h=Math.floor(e/3600),e%=3600),e>60&&(t.m=Math.floor(e/60),e%=60),t.s=Math.floor(e);var n="";return t.h>0&&(n+="".concat(t.h,"h ")),t.m>0&&(n+="".concat(t.m,"m ")),!t.h&&(n+="".concat(t.s,"s")),n.trim()},tryJSONParse:function(e){try{return JSON.parse(e)}catch(e){return null}},decodeJWT:function(e){return JSON.parse(atob(e.split(".")[1]))},visitAncestor:function e(t,n,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];r(t,o);var i=n[0];if(i){var a=t[i];a&&e(a,n.slice(1),r,o.concat(i))}}}},499:e=>{e.exports={rosReleases:{kinetic:{rosVersion:1,ubuntuCodename:"xenial"},melodic:{rosVersion:1,ubuntuCodename:"bionic"},noetic:{rosVersion:1,ubuntuCodename:"focal"},dashing:{rosVersion:2},eloquent:{rosVersion:2},foxy:{rosVersion:2},galactic:{rosVersion:2},humble:{rosVersion:2},iron:{rosVersion:2},rolling:{rosVersion:2}}}},216:(e,t,n)=>{"use strict";n.r(t),n.d(t,{MqttSync:()=>c,fetchJson:()=>s,parseCookie:()=>u});var r=n(362),o={};for(const e in r)["default","MqttSync","parseCookie","fetchJson"].indexOf(e)<0&&(o[e]=()=>r[e]);n.d(t,o);var i=n(720);o={};for(const e in i)["default","MqttSync","parseCookie","fetchJson"].indexOf(e)<0&&(o[e]=()=>i[e]);n.d(t,o);var a=n(890),c=n.n(a)(),u=function(e){return e.split(";").map((function(e){return e.split("=")})).reduce((function(e,t){return e[decodeURIComponent(t[0].trim())]=t[1]&&decodeURIComponent(t[1].trim()),e}),{})},s=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};fetch(e,{method:n.method||(n.body?"post":"get"),mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:n.body?JSON.stringify(n.body):void 0}).then((function(n){var r=!n.ok&&"fetching ".concat(e," failed: ").concat(n.status," ").concat(n.statusText);n.json().then((function(e){return t(r,e)})).catch((function(e){throw new Error(e)}))})).catch((function(e){return t("error: ".concat(e))}))}},782:(e,t,n)=>{"use strict";n.d(t,{H:()=>v,D:()=>g});var r=n(689),o=n.n(r),i=n(517),a=n.n(i);const c=require("mqtt-browser");var u=n.n(c),s=n(216);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var b=n(890),y=(0,s.getLogger)("utils-web/hooks");y.setLevel("info");var v=function(e){var t=e.jwt,n=e.id,i=e.mqttUrl,c=h((0,r.useState)("connecting"),2),l=c[0],f=c[1],p=h((0,r.useState)(),2),d=p[0],v=p[1],g=h((0,r.useState)({}),2),m=g[0],w=g[1];return(0,r.useEffect)((function(){var e=(0,s.decodeJWT)(t),r=u().connect(i,{username:JSON.stringify({id:n,payload:e}),password:t});return r.on("connect",(function(){y.debug("connected");var e=new b({mqttClient:r,ignoreRetain:!0});v(e),f("connected"),e.data.subscribe(a().throttle((function(){return w((0,s.clone)(e.data.get()))}),50))})),r.on("error",(function(e){y.error(e),f("error: ".concat(e))})),function(){y.info("cleaning up useMQTTSync"),d&&d.beforeDisconnect?(d.beforeDisconnect(),d.waitForHeartbeatOnce((function(){return r.end()}))):r.end()}}),[t,n]),{status:l,ready:"connected"==l,StatusComponent:function(){return o().createElement("div",null,l)},mqttSync:d,data:m}},g=function(e){var t=e.jwt,n=e.id,r=e.host,o=e.ssl,i=e.capability,a=e.versionNS,c=h(i.split("/"),2),u=c[0],l=c[1],p=(0,s.decodeJWT)(t).device,d=[n,p,u,l],b=(0,s.pathToTopic)(d),y=[].concat(d,[a]),g=(0,s.pathToTopic)(y),m="".concat(o&&JSON.parse(o)?"wss":"ws","://mqtt.").concat(r);return f(f({},v({jwt:t,id:n,mqttUrl:m})),{},{device:p,prefixPath:d,prefix:b,prefixPathVersion:y,prefixVersion:g})}},809:e=>{function t(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}e.exports=function(e){if(!e.attributes)return{};var r,o,i,a={},c=(i=e.attributes,function(e){if(Array.isArray(e))return n(e)}(i)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||t(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){return function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e.name,e.value)})),u=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=t(e))){r&&(e=r);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw a}}}}(c);try{for(u.s();!(o=u.n()).done;){r=o.value;var s=Object.keys(r)[0];a[s.replace(/-([a-z])/g,(function(e){return e[1].toUpperCase()}))]=r[s]}}catch(e){u.e(e)}finally{u.f()}return a}},613:(e,t,n)=>{e.exports=function(){try{return n(962).styleElements}catch(e){return[]}}},927:(e,t,n)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}function u(e){var t=h();return function(){var n,r=b(e);if(t){var o=b(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return s(this,n)}}function s(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return l(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){var t="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return p(e,arguments,b(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},f(e)}function p(e,t,n){return p=h()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&d(o,n.prototype),o},p.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=n(689),g=n(405),m=n(430),w=n(613),O=n(809);n(622),n(268);var S={attachedCallback:"webComponentAttached",connectedCallback:"webComponentConnected",disconnectedCallback:"webComponentDisconnected",adoptedCallback:"webComponentAdopted"};e.exports={create:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=function(t){c(s,t);var i=u(s);function s(){var e;o(this,s);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return y(l(e=i.call.apply(i,[this].concat(n))),"instance",null),e}return a(s,[{key:"callConstructorHook",value:function(){this.instance.webComponentConstructed&&this.instance.webComponentConstructed.apply(this.instance,[this])}},{key:"callLifeCycleHook",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=S[e];n&&this.instance&&this.instance[n]&&this.instance[n].apply(this.instance,t)}},{key:"connectedCallback",value:function(){var t=this,r=t;if(n){var o=t.attachShadow({mode:"open"});r=document.createElement("div"),w().forEach((function(e){o.appendChild(e.cloneNode(o))})),o.appendChild(r),m(o)}g.render(v.createElement(e,O(t)),r,(function(){t.instance=this,t.callConstructorHook(),t.callLifeCycleHook("connectedCallback")}))}},{key:"disconnectedCallback",value:function(){this.callLifeCycleHook("disconnectedCallback")}},{key:"adoptedCallback",value:function(e,t){this.callLifeCycleHook("adoptedCallback",[e,t])}},{key:"call",value:function(e,t){var n,o;return null==r||null===(n=r.current)||void 0===n||null===(o=n[e])||void 0===o?void 0:o.call(null==r?void 0:r.current,t)}},{key:"getConfig",value:function(){return this.instance.state.config}}]),s}(f(HTMLElement));customElements.define(t,i)}}},498:(e,t,n)=>{"use strict";n.d(t,{EK:()=>T,SV:()=>A,ZM:()=>C,U5:()=>P,B7:()=>_,ax:()=>q,eZ:()=>D});var r=n(689),o=n.n(r);const i=require("react-bootstrap");var a=n(927),c=n.n(a);function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function b(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&v(e,t)}function v(e,t){return v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},v(e,t)}function g(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=O(e);if(t){var o=O(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return m(this,n)}}function m(e,t){if(t&&("object"===u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return w(e)}function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function O(e){return O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},O(e)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return j(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?j(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n(216);var E={badge:{width:"4em"},code:{color:"#700",borderLeft:"3px solid #aaa",padding:"0.5em 0px 0.5em 2em",backgroundColor:"#f0f0f0",borderRadius:"4px",marginTop:"0.5em"},inlineCode:{color:"#700",margin:"0px 0.5em 0px 0.5em"}},k=[o().createElement(i.Badge,{bg:"success",style:E.badge},"OK"),o().createElement(i.Badge,{bg:"warning",style:E.badge},"Warn"),o().createElement(i.Badge,{bg:"danger",style:E.badge},"Error"),o().createElement(i.Badge,{bg:"secondary",style:E.badge},"Stale")],P=function(e){var t=e.level;return k[t]||o().createElement("span",null,t)},T=function(e){var t=e.children;return o().createElement("pre",{style:E.code},t)},C=function(e){var t=e.children;return o().createElement("tt",{style:E.inlineCode},t)},x={},q=o().createContext({}),_=function(e){var t=e.duration,n=e.onTimeout,a=e.onStart,c=e.setOnDisconnect,u=e.children;t=t||60;var s=S((0,r.useState)(t),2),l=s[0],f=s[1],p=S((0,r.useState)(!1),2),h=p[0],d=p[1],b=(0,r.useMemo)((function(){return Math.random().toString(36).slice(2)}),[]),y=function(){console.log("stopping timer for",b),n&&setTimeout(n,1),clearInterval(x[b]),x[b]=null,d(!1)};(0,r.useEffect)((function(){var e;l>0&&!h&&(e=x[b],console.log(e,x,l),!e&&l>0&&(d(!0),x[b]=setInterval((function(){return f((function(e){if(--e>0)return e;y()}))}),1e3),a&&setTimeout(a,1)))}),[l]),(0,r.useEffect)((function(){return y}),[]),c&&c((function(){y()}));var v=function(){return f(t)};return o().createElement(q.Provider,{value:{reset:v,duration:t,timer:l}},l>0?o().createElement("div",null,u,l<60&&o().createElement("div",null,"Timeout in: ",l," seconds")):o().createElement("div",null,"Timed out. ",o().createElement(i.Button,{onClick:v},"Resume")))},A=function(e){y(n,e);var t=g(n);function n(e){var r;return h(this,n),(r=t.call(this,e)).state={hasError:!1},r}return b(n,[{key:"componentDidCatch",value:function(e,t){console.warn("ErrorBoundary caught:",e,t)}},{key:"render",value:function(){return this.state.hasError?o().createElement("div",null,this.props.message||"Something went wrong here."):this.props.children}}],[{key:"getDerivedStateFromError",value:function(e){return{hasError:!0}}}]),n}(o().Component),M=function(e){var t;return e.$$typeof==Symbol.for("react.forward_ref")||(null===(t=e.prototype)||void 0===t?void 0:t.render)},D=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0.0.0",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=M(e)?o().createRef():null,a=function(a){y(u,a);var c=g(u);function u(){var e;h(this,u);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return p(w(e=c.call.apply(c,[this].concat(n))),"onDisconnect",null),p(w(e),"state",{}),e}return b(u,[{key:"setOnDisconnect",value:function(e){this.onDisconnect=e}},{key:"webComponentConstructed",value:function(e){var t=this;new MutationObserver((function(n){var r={};n.forEach((function(t){var n=t.attributeName;r[n]=e.getAttribute(n)})),t.setState((function(e){return f(f({},e),r)}))})).observe(e,{attributes:!0})}},{key:"webComponentDisconnected",value:function(){this.setState({_disconnected:!0});try{this.onDisconnect&&this.onDisconnect()}catch(e){console.log("Error during onDisconnect of web-component",e)}}},{key:"setConfig",value:function(e){this.setState({config:e})}},{key:"render",value:function(){var a=r.stylesheets||["https://cdn.jsdelivr.net/gh/transitiverobotics/transitive-utils@0.8.3/web/css/bootstrap_transitive-bs-root.min.css"];return o().createElement("div",{id:"cap-".concat(t,"-").concat(n),className:r.className||"transitive-bs-root"},o().createElement("style",null,a.map((function(e){return"@import url(".concat(e,");")}))),!this.state._disconnected&&o().createElement(e,s({ref:i},this.props,this.state,{setOnDisconnect:this.setOnDisconnect.bind(this),setConfig:this.setConfig.bind(this)})))}}]),u}(o().Component);c().create(a,t,r.shadowDOM||!1,i)}},268:e=>{"use strict";e.exports=require("@webcomponents/custom-elements")},622:e=>{"use strict";e.exports=require("@webcomponents/shadydom")},22:e=>{"use strict";e.exports=require("chalk")},517:e=>{"use strict";e.exports=require("lodash")},848:e=>{"use strict";e.exports=require("lodash/forEach")},712:e=>{"use strict";e.exports=require("lodash/get")},699:e=>{"use strict";e.exports=require("lodash/isEmpty")},113:e=>{"use strict";e.exports=require("lodash/isEqual")},452:e=>{"use strict";e.exports=require("lodash/isPlainObject")},707:e=>{"use strict";e.exports=require("lodash/map")},831:e=>{"use strict";e.exports=require("lodash/merge")},298:e=>{"use strict";e.exports=require("lodash/set")},305:e=>{"use strict";e.exports=require("lodash/unset")},316:e=>{"use strict";e.exports=require("loglevel")},689:e=>{"use strict";e.exports=require("react")},405:e=>{"use strict";e.exports=require("react-dom")},430:e=>{"use strict";e.exports=require("react-shadow-dom-retarget-events")},962:e=>{"use strict";e.exports=require("react-web-component-style-loader/exports")},13:e=>{"use strict";e.exports=require("semver/functions/compare")},84:e=>{"use strict";e.exports=require("semver/ranges/min-version")}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.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 r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{Code:()=>e.EK,ErrorBoundary:()=>e.SV,InlineCode:()=>e.ZM,LevelBadge:()=>e.U5,Timer:()=>e.B7,TimerContext:()=>e.ax,createWebComponent:()=>e.eZ,useMqttSync:()=>t.H,useTransitive:()=>t.D});var e=n(498),t=n(782),o=n(216),i={};for(const e in o)["default","Code","ErrorBoundary","InlineCode","LevelBadge","Timer","TimerContext","createWebComponent","useMqttSync","useTransitive"].indexOf(e)<0&&(i[e]=()=>o[e]);n.d(r,i)})();var o=exports;for(var i in r)o[i]=r[i];r.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
|
package/docs/client.md
CHANGED
|
@@ -78,18 +78,16 @@ Reusable component for showing code
|
|
|
78
78
|
## createWebComponent
|
|
79
79
|
|
|
80
80
|
Create a WebComponent from the given react component and name that is
|
|
81
|
-
reactive to
|
|
82
|
-
Example:
|
|
81
|
+
reactive to all attributes. Used in web capabilities. Example:
|
|
83
82
|
|
|
84
83
|
```js
|
|
85
|
-
createWebComponent(Diagnostics, 'health-monitoring-device',
|
|
84
|
+
createWebComponent(Diagnostics, 'health-monitoring-device', TR_PKG_VERSION);
|
|
86
85
|
```
|
|
87
86
|
|
|
88
87
|
#### Parameters
|
|
89
88
|
|
|
90
89
|
* `Component`  
|
|
91
90
|
* `name`  
|
|
92
|
-
* `reactiveAttributes` (optional, default `[]`)
|
|
93
91
|
* `version` (optional, default `'0.0.0'`)
|
|
94
92
|
* `options` (optional, default `{}`)
|
|
95
93
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transitive-sdk/utils-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Web utils for the Transitive framework",
|
|
5
5
|
"homepage": "https://transitiverobotics.com",
|
|
6
6
|
"author": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"test": "webpack serve -c webpack-test.config.js",
|
|
20
20
|
"build-test": "webpack -c webpack-test.config.js",
|
|
21
21
|
"prepare": "webpack --no-watch --mode=production && cd css && npx cleancss -o bootstrap_transitive-bs-root.min.css bootstrap_transitive-bs-root.css",
|
|
22
|
-
"prepack": "cat ../docs.js | node --input-type=module - client"
|
|
22
|
+
"prepack": "cat ../docs.js | node --input-type=module - client",
|
|
23
|
+
"dev": "webpack"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@babel/runtime": "^7.16.7",
|
package/dist/_utils-web.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{var e={720:(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.set(e,n)}function c(e,t){return function(e,t){return t.get?t.get.call(e):t.value}(e,s(e,t,"get"))}function u(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,s(e,t,"set"),n),n}function s(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}var l={get:n(712),set:n(298),unset:n(305),forEach:n(848),map:n(707),isEmpty:n(699),eq:n(113),isPlainObject:n(452),merge:n(831)},f=n(362),p=f.topicToPath,h=f.pathToTopic,d=f.toFlatObject,b=f.topicMatch,y=f.forMatchIterator,v=function e(t,n){if(n&&0!=n.length){l.unset(t,n);var r=n.slice(0,-1),o=0==r.length?t:l.get(t,r);return l.isEmpty(o)?e(t,r):n}},g=function e(t,n){if(0!=n.length){var r=n[0];if(r)for(var o in t)o==r||"*"==r||r.startsWith("+")?e(t[o],n.slice(1)):delete t[o]}},m=new WeakMap,w=new WeakMap,O=new WeakMap,S=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,e),a(this,m,{writable:!0,value:{}}),a(this,w,{writable:!0,value:[]}),a(this,O,{writable:!0,value:[]}),u(this,m,t)}var t,n;return t=e,n=[{key:"updateFromArray",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=l.get(c(this,m),e);if(null==t){if(null==o)return{};v(c(this,m),e)}else{if(l.eq(o,t))return{};l.set(c(this,m),e,t)}var i,a=h(e),u=r({},a,t);if(t instanceof Object){var s=d(t);i={},l.forEach(s,(function(e,t){i["".concat(a).concat(t)]=e}))}else i=u;return c(this,w).forEach((function(e){return e(u,n)})),c(this,O).forEach((function(e){return e(i,n)})),i}},{key:"update",value:function(e,t,n){if("string"==typeof e)return this.updateFromTopic(e,t,n);if(e instanceof Array)return this.updateFromArray(e,t,n);throw new Error("unrecognized path expression")}},{key:"updateFromTopic",value:function(e,t,n){return this.updateFromArray(p(e),t,n)}},{key:"updateFromModifier",value:function(e,t){var n=this;return l.map(e,(function(e,r){return n.updateFromTopic(r,e,t)}))}},{key:"subscribe",value:function(e){e instanceof Function?c(this,w).push(e):console.warn("DataCache.subscribe expects a function as argument. Did you mean to use subscribePath?")}},{key:"subscribePath",value:function(e,t){c(this,w).push((function(n,r){l.forEach(n,(function(n,o){var i=b(e,o);i&&t(n,o,i,r)}))}))}},{key:"subscribePathFlat",value:function(e,t){c(this,O).push((function(n,r){l.forEach(n,(function(n,o){var i=b(e,o);i&&t(n,o,i,r)}))}))}},{key:"unsubscribe",value:function(e){u(this,w,c(this,w).filter((function(t){return t!=e})))}},{key:"get",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return 0==e.length?c(this,m):l.get(c(this,m),e)}},{key:"getByTopic",value:function(e){return this.get(p(e))}},{key:"filter",value:function(e){var t=JSON.parse(JSON.stringify(this.get()));return g(t,e),t}},{key:"filterByTopic",value:function(e){return this.filter(p(e))}},{key:"forMatch",value:function(e,t){var n=p(e);this.forPathMatch(n,t)}},{key:"forPathMatch",value:function(e,t){y(this.get(),e,t)}}],n&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.exports={DataCache:S,updateObject:function(e,t){return l.forEach(t,(function(t,n){var r=p(n);null==t?v(e,r):l.set(e,r,t)})),e}}},890:(e,t,n)=>{"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}var c=n(362),u=c.mqttParsePayload,s=c.topicMatch,l=c.topicToPath,f=c.pathToTopic,p=c.toFlatObject,h=c.getLogger,d=c.mergeVersions,b=c.parseMQTTTopic,y=c.isSubTopicOf,v=c.versionCompare,g=c.encodeTopicElement,m=n(720).DataCache,w=n(517),O=h("MqttSync"),S="$SYS/broker/uptime",E=function(){},k=function(e){return e.endsWith("/#")?e:e.endsWith("/")?e.concat("#"):e.concat("/#")},j=function(e){return e.replace(/\/\//g,"/")},C=function(){function e(t){var n=this,r=t.mqttClient,o=t.onChange,a=t.ignoreRetain,c=t.migrate,s=t.onReady,p=t.sliceTopic;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,"data",new m),i(this,"subscribedPaths",{}),i(this,"publishedPaths",{}),i(this,"publishedMessages",{}),i(this,"publishQueue",new Map),i(this,"heartbeatWaitersOnce",[]),i(this,"heartbeats",0),i(this,"beforeDisconnectHooks",[]),this.mqtt=r,this.mqtt.on("message",(function(e,t,r){var i=t&&t.toString();if(O.debug("got message",e,i.slice(0,180),i.length>180?"... (".concat(i.length," bytes)"):"",r.retain),e==S)n.heartbeats>0&&(n.heartbeatWaitersOnce.forEach((function(e){return e()})),n.heartbeatWaitersOnce=[]),1==n.heartbeats&&!c&&s&&s(),n.heartbeats++;else if(r.retain||a){O.debug("processing message",e),p&&(e=f(l(e).slice(p)));var h=u(t);if(n.isPublished(e))n.publishedMessages[e]=h,n.data.update(e,h,{external:!0});else if(n.isSubscribed(e)){O.debug("applying received update",e);var d=n.data.update(e,h);o&&Object.keys(d).length>0&&o(d)}}})),this.mqtt.subscribe(S,{rap:!0},O.debug),(null==c?void 0:c.length)>0&&this.migrate(c,(function(){O.debug("done migrating",s),s&&n.waitForHeartbeatOnce(s)}))}var t,n;return t=e,n=[{key:"publishAtLevel",value:function(e,t,n){var r=this;O.debug("publishingAtLevel ".concat(n),e,t),n>0?w.forEach(t,(function(t,o){var i="".concat(e,"/").concat(g(o));O.debug("publishing ".concat(i)),r.publishAtLevel(i,t,n-1)})):this.mqtt.publish(e,JSON.stringify(t),{retain:!0},(function(e){e&&O.warn("Error when publishing migration result",e)}))}},{key:"migrate",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=e.length;if(0!=r){var o=function(){return 0==--r&&n&&n()};e.forEach((function(e){var n=e.topic,r=e.newVersion,i=e.transform,a=void 0===i?void 0:i,c=e.flat,u=void 0!==c&&c,s=e.level,h=void 0===s?0:s;O.debug("migrating",n,r);var y=b(n),g=y.organization,m=y.device,S=y.capability,E=y.sub,k="/".concat(g,"/").concat(m,"/").concat(S),C=0==E.length?"/#":f(E),T="".concat(k,"/+").concat(C);t.subscribe(T,(function(e){if(e)return O.warn("Error during migration",e),void o();t.waitForHeartbeatOnce((function(){O.debug("got heartbeat",n,T);var e=t.data.getByTopic(k);if(!e)return t.unsubscribe(T),void o();var i=d(e,C,{maxVersion:r}),c=w.get(i,l(C)),s=a?a(c):c,b=j("".concat(k,"/").concat(r,"/").concat(C));if(O.debug("publishing merged",b),u){var y=p(s),g=l(b);w.forEach(y,(function(e,n){var r=f(g.concat(l(n)));t.mqtt.publish(r,JSON.stringify(e),{retain:!0},(function(e){e&&O.warn("Error when publishing migration result for ".concat(n),e)}))}))}else t.publishAtLevel(b,s,h);t.unsubscribe(T),t.waitForHeartbeatOnce((function(){var n=Object.keys(e).filter((function(e){return v(e,r)<0})).map((function(e){return j("".concat(k,"/").concat(e,"/").concat(C))}));O.debug({prefixesToClear:n}),t.clear(n),o()}))}))}))}))}else n&&n()}},{key:"clear",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=[],i=function(t){e.forEach((function(e){return s("".concat(e,"/#"),t)&&(!r.filter||r.filter(t))&&o.push(t)}))};this.mqtt.on("message",i),e.forEach((function(e){"string"==typeof e?t.mqtt.subscribe("".concat(e,"/#")):O.warn("Ignoring",e,"since it is not a string.")}));var a="undefined"!=typeof Buffer?Buffer.alloc(0):null;this.waitForHeartbeatOnce((function(){t.mqtt.removeListener("message",i),e.forEach((function(e){return t.mqtt.unsubscribe("".concat(e,"/#"))}));var r=o.length;O.debug("clearing ".concat(r," retained messages from ").concat(e)),o.forEach((function(e){t.mqtt.publish(e,a,{retain:!0})})),n&&n(r)}))}},{key:"waitForHeartbeatOnce",value:function(e){var t=this;setTimeout((function(){return t.heartbeatWaitersOnce.push(e)}),1)}},{key:"isSubscribed",value:function(e){return Object.keys(this.subscribedPaths).some((function(t){return s(t,e)}))}},{key:"isPublished",value:function(e){var t=this;return Object.keys(this.publishedPaths).some((function(n){return s(n,e)&&!t.publishedPaths[n].atomic}))}},{key:"subscribe",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:E;if(e=k(e),this.subscribedPaths[e])return O.debug("already subscribed to",e),void n();this.mqtt.subscribe(e,{rap:!0},(function(r,o){O.debug("subscribe",e,"granted:",o),o&&o.some((function(t){return t.topic==e&&t.qos<128}))?(t.subscribedPaths[e]=1,n(null)):n("not permitted to subscribe to topic ".concat(e,", ").concat(JSON.stringify(o)))}))}},{key:"unsubscribe",value:function(e){this.subscribedPaths[e]&&(this.mqtt.unsubscribe(e),delete this.subscribedPaths[e])}},{key:"_actuallyPublish",value:function(e,t){return this.mqtt.connected?(O.debug("actually publishing",e),this.mqtt.publish(e,null==t?null:JSON.stringify(t),{retain:!0}),!0):(O.warn("not connected, not publishing",e),!1)}},{key:"_processQueue_rec",value:function(e){var t=this;if(this.publishQueue.size>0){var n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.publishQueue.entries().next().value,2),o=n[0],i=n[1];this._actuallyPublish(o,i)?(this.publishQueue.delete(o),this._processQueue_rec(e)):setTimeout((function(){return t._processQueue_rec(e)}),5e3)}else e()}},{key:"_processQueue",value:function(){var e=this;this._processing||(this._processing=!0,this._processQueue_rec((function(){return e._processing=!1})))}},{key:"setThrottle",value:function(e){this._processQueueThrottled=w.throttle(this._processQueue.bind(this),e)}},{key:"clearThrottle",value:function(){delete this._processQueueThrottled}},{key:"addToQueue",value:function(e,t){this.publishQueue.set(e,t)}},{key:"_enqueue",value:function(e,t){var n;O.debug("enqueuing",e),this.addToQueue(e,t),this._processQueueThrottled?this._processQueueThrottled():this._processQueue(),null==t?delete this.publishedMessages[e]:this.publishedMessages[e]="object"==a(n=t)?JSON.parse(JSON.stringify(n)):n}},{key:"publish",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{atomic:!1};return e=k(e),!w.isEqual(this.publishedPaths[e],n)&&(this.publishedPaths[e]=n,n.atomic?(this.data.subscribePath(e,(function(n,r,o,i){if(null==i||!i.external){O.debug("processing change (atomic)",r,e);var a=e.slice(0,e.length-2),c=f(l(r).slice(0,l(a).length));t._enqueue(c,t.data.getByTopic(c))}})),!0):(this.mqtt.subscribe(e),void this.data.subscribePath(e,(function(e,n,r,o){if(null==o||!o.external)return O.debug("processing change",n),w.each(t.publishedMessages,(function(e,r){if(O.trace("oldKey",r),r==n)return!0;if(y(r,n)&&t._enqueue(r,null),y(n,r)){t._enqueue(r,null);var o=p(e);w.each(o,(function(e,n){var o="".concat(r).concat(n);t._enqueue(o,e)}))}})),t._enqueue(n,e),!0}))))}},{key:"beforeDisconnect",value:function(){var e=this;this.beforeDisconnectHooks.forEach((function(t){return t(e)}))}},{key:"onBeforeDisconnect",value:function(e){this.beforeDisconnectHooks.push(e)}}],n&&o(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();e.exports=C},362:(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(13),i=n(84),a={get:n(712),set:n(298),unset:n(305),forEach:n(848),map:n(707),isEmpty:n(699),eq:n(113),isPlainObject:n(452),merge:n(831)},c=n(316),u=n(22),s=n(499);c.setAll=function(e){return Object.values(c.getLoggers()).forEach((function(t){return t.setLevel(e)}))};var l={warn:u.yellow,error:u.red,info:u.green,debug:u.gray},f=c.methodFactory;c.methodFactory=function(e,t,n){var r=f(e,t,n);if("undefined"!=typeof window){var o="".concat(n," ").concat(e);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(void 0,["[".concat(o,"]")].concat(t))}}var i,a="".concat(n," ").concat(l[i=e]?l[i](i):i);return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(void 0,["[".concat(u.blue((new Date).toISOString())," ").concat(a,"]")].concat(t))}};var p=c.getLogger,h=function(e){return e.replace(/%/g,"%25").replace(/\//g,"%2F")},d=function(e){return e.replace(/%25/g,"%").replace(/%2F/g,"/")},b=function(e){return"/".concat(e.map((function(e){return e.startsWith("+")?"+":e})).map(h).join("/"))},y=function(e){var t=e.split("/").map(d);return t.length>0&&0==t[0].length&&t.shift(),t.length>0&&0==t.at(-1).length&&t.pop(),t},v=function(e,t){return function e(t,n){if(0==t.length)return!0;if("#"==t[0][0])return!0;if(0==n.length)return!0;if(t[0]==n[0])return e(t.slice(1),n.slice(1));if("+"==t[0][0]){var o=e(t.slice(1),n.slice(1));return o&&Object.assign(r({},t[0].slice(1),n[0]),o)}return!1}(y(e),y(t))},g=function e(t,n){return 0==t.length||t[0]==n[0]&&e(t.slice(1),n.slice(1))},m=function(e,t){return o(i(e),i(t))},w=["B","KB","MB","GB","TB"];e.exports={parseMQTTUsername:function(e){var t=e.split(":");return{organization:t[0],client:t[1],sub:t.slice(2)}},parseMQTTTopic:function(e){var t=y(e);return{organization:t[0],device:t[1],capabilityScope:t[2],capabilityName:t[3],capability:"".concat(t[2],"/").concat(t[3]),version:t[4],sub:t.slice(5)}},pathToTopic:b,topicToPath:y,toFlatObject:function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a.forEach(t,(function(t,o){var i=n.concat(String(o));(a.isPlainObject(t)||t instanceof Array)&&null!==t?e(t,i,r):r[b(i)]=t})),r},topicMatch:v,mqttParsePayload:function(e){return 0==e.length?null:JSON.parse(e.toString("utf-8"))},getRandomId:function(){return Math.random().toString(36).slice(2)},versionCompare:m,loglevel:c,getLogger:p,mergeVersions:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e)return t?a.set({},t,e):e;var r=Object.keys(e).filter((function(e){return(!n.maxVersion||m(e,n.maxVersion)<=0)&&(!n.minVersion||m(n.minVersion,e)<=0)})).sort(m),o={},i=t&&y(t);return r.forEach((function(t){var n=i?a.get(e[t],i):e[t];a.merge(o,n)})),i?a.set({},i,o):o},mqttClearRetained:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e3,o=[],i=function(e){t.forEach((function(t){return v("".concat(t,"/#"),e)&&o.push(e)}))};e.on("message",i),t.forEach((function(t){"string"==typeof t?e.subscribe("".concat(t,"/#")):console.warn("Ignoring",t,"since it is not a string.")}));var a="undefined"!=typeof Buffer?Buffer.alloc(0):null;setTimeout((function(){e.removeListener("message",i),t.forEach((function(t){return e.unsubscribe("".concat(t,"/#"))}));var r=o.length;console.log("clearing ".concat(r," retained messages from ").concat(t)),o.forEach((function(t){e.publish(t,a,{retain:!0})})),n&&n(r)}),r)},isSubTopicOf:function(e,t){var n=y(t),r=y(e);return g(n,r)&&n.length<r.length},clone:function(e){return JSON.parse(JSON.stringify(e))},setFromPath:function e(t,n,r){if(0==n.length)return t;var o=n.shift();0==n.length?t[o]=r:(t[o]||(t[o]={}),e(t[o],n,r))},forMatchIterator:function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(0!=n.length&&"#"!=n[0]){var c=n[0];if(c)for(var u in t)if(u==c||"*"==c||c.startsWith("+")){var s=c.startsWith("+")&&c.length>1?Object.assign({},a,r({},c.slice(1),u)):a;e(t[u],n.slice(1),o,i.concat([u]),s)}}else o(t,i,a)},encodeTopicElement:h,decodeTopicElement:d,constants:s,visit:function e(t,n,r){var o;t&&(r(t),null===(o=t[n])||void 0===o||o.forEach((function(t){return e(t,n,r)})))},wait:function(e){return new Promise((function(t){setTimeout(t,e)}))},formatBytes:function(e){if(!e)return"--";for(var t=0;e>1024;)e/=1024,t++;return"".concat(e.toFixed(2)," ").concat(w[t])},formatDuration:function(e){if(!e)return"--";var t={};e>3600&&(t.h=Math.floor(e/3600),e%=3600),e>60&&(t.m=Math.floor(e/60),e%=60),t.s=Math.floor(e);var n="";return t.h>0&&(n+="".concat(t.h,"h ")),t.m>0&&(n+="".concat(t.m,"m ")),!t.h&&(n+="".concat(t.s,"s")),n.trim()},tryJSONParse:function(e){try{return JSON.parse(e)}catch(e){return null}},decodeJWT:function(e){return JSON.parse(atob(e.split(".")[1]))}}},499:e=>{e.exports={rosReleases:{kinetic:{rosVersion:1,ubuntuCodename:"xenial"},melodic:{rosVersion:1,ubuntuCodename:"bionic"},noetic:{rosVersion:1,ubuntuCodename:"focal"},dashing:{rosVersion:2},eloquent:{rosVersion:2},foxy:{rosVersion:2},galactic:{rosVersion:2},humble:{rosVersion:2},iron:{rosVersion:2},rolling:{rosVersion:2}}}},216:(e,t,n)=>{"use strict";n.r(t),n.d(t,{MqttSync:()=>c,fetchJson:()=>s,parseCookie:()=>u});var r=n(362),o={};for(const e in r)["default","MqttSync","parseCookie","fetchJson"].indexOf(e)<0&&(o[e]=()=>r[e]);n.d(t,o);var i=n(720);o={};for(const e in i)["default","MqttSync","parseCookie","fetchJson"].indexOf(e)<0&&(o[e]=()=>i[e]);n.d(t,o);var a=n(890),c=n.n(a)(),u=function(e){return e.split(";").map((function(e){return e.split("=")})).reduce((function(e,t){return e[decodeURIComponent(t[0].trim())]=t[1]&&decodeURIComponent(t[1].trim()),e}),{})},s=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};fetch(e,{method:n.method||(n.body?"post":"get"),mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:n.body?JSON.stringify(n.body):void 0}).then((function(n){var r=!n.ok&&"fetching ".concat(e," failed: ").concat(n.status," ").concat(n.statusText);n.json().then((function(e){return t(r,e)})).catch((function(e){throw new Error(e)}))})).catch((function(e){return t("error: ".concat(e))}))}},782:(e,t,n)=>{"use strict";n.d(t,{H:()=>v,D:()=>g});var r=n(689),o=n.n(r),i=n(517),a=n.n(i);const c=require("mqtt-browser");var u=n.n(c),s=n(216);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var b=n(890),y=(0,s.getLogger)("utils-web/hooks");y.setLevel("info");var v=function(e){var t=e.jwt,n=e.id,i=e.mqttUrl,c=h((0,r.useState)("connecting"),2),l=c[0],f=c[1],p=h((0,r.useState)(),2),d=p[0],v=p[1],g=h((0,r.useState)({}),2),m=g[0],w=g[1];return(0,r.useEffect)((function(){var e=(0,s.decodeJWT)(t),r=u().connect(i,{username:JSON.stringify({id:n,payload:e}),password:t});return r.on("connect",(function(){y.debug("connected");var e=new b({mqttClient:r,ignoreRetain:!0});v(e),f("connected"),e.data.subscribe(a().throttle((function(){return w((0,s.clone)(e.data.get()))}),50))})),r.on("error",(function(e){y.error(e),f("error: ".concat(e))})),function(){y.info("cleaning up useMQTTSync"),d&&d.beforeDisconnect?(d.beforeDisconnect(),d.waitForHeartbeatOnce((function(){return r.end()}))):r.end()}}),[t,n]),{status:l,ready:"connected"==l,StatusComponent:function(){return o().createElement("div",null,l)},mqttSync:d,data:m}},g=function(e){var t=e.jwt,n=e.id,r=e.host,o=e.ssl,i=e.capability,a=e.versionNS,c=h(i.split("/"),2),u=c[0],l=c[1],p=(0,s.decodeJWT)(t).device,d=[n,p,u,l],b=(0,s.pathToTopic)(d),y=[].concat(d,[a]),g=(0,s.pathToTopic)(y),m="".concat(o&&JSON.parse(o)?"wss":"ws","://mqtt.").concat(r);return f(f({},v({jwt:t,id:n,mqttUrl:m})),{},{device:p,prefixPath:d,prefix:b,prefixPathVersion:y,prefixVersion:g})}},809:e=>{function t(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}e.exports=function(e){if(!e.attributes)return{};var r,o,i,a={},c=(i=e.attributes,function(e){if(Array.isArray(e))return n(e)}(i)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||t(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){return function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e.name,e.value)})),u=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=t(e))){r&&(e=r);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw a}}}}(c);try{for(u.s();!(o=u.n()).done;){r=o.value;var s=Object.keys(r)[0];a[s.replace(/-([a-z])/g,(function(e){return e[1].toUpperCase()}))]=r[s]}}catch(e){u.e(e)}finally{u.f()}return a}},613:(e,t,n)=>{e.exports=function(){try{return n(962).styleElements}catch(e){return[]}}},927:(e,t,n)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}function u(e){var t=h();return function(){var n,r=b(e);if(t){var o=b(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return s(this,n)}}function s(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return l(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){var t="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return p(e,arguments,b(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},f(e)}function p(e,t,n){return p=h()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&d(o,n.prototype),o},p.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=n(689),g=n(405),m=n(430),w=n(613),O=n(809);n(622),n(268);var S={attachedCallback:"webComponentAttached",connectedCallback:"webComponentConnected",disconnectedCallback:"webComponentDisconnected",attributeChangedCallback:"webComponentAttributeChanged",adoptedCallback:"webComponentAdopted"};e.exports={create:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,s=function(t){c(f,t);var s=u(f);function f(){var e;o(this,f);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return y(l(e=s.call.apply(s,[this].concat(n))),"instance",null),e}return a(f,[{key:"callConstructorHook",value:function(){this.instance.webComponentConstructed&&this.instance.webComponentConstructed.apply(this.instance,[this])}},{key:"callLifeCycleHook",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=S[e];n&&this.instance&&this.instance[n]&&this.instance[n].apply(this.instance,t)}},{key:"connectedCallback",value:function(){var t=this,r=t;if(n){var o=t.attachShadow({mode:"open"});r=document.createElement("div"),w().forEach((function(e){o.appendChild(e.cloneNode(o))})),o.appendChild(r),m(o)}g.render(v.createElement(e,O(t)),r,(function(){t.instance=this,t.callConstructorHook(),t.callLifeCycleHook("connectedCallback")}))}},{key:"disconnectedCallback",value:function(){this.callLifeCycleHook("disconnectedCallback")}},{key:"attributeChangedCallback",value:function(e,t,n,r){this.callLifeCycleHook("attributeChangedCallback",[e,t,n,r])}},{key:"adoptedCallback",value:function(e,t){this.callLifeCycleHook("adoptedCallback",[e,t])}},{key:"call",value:function(e,t){var n,r;return null==i||null===(n=i.current)||void 0===n||null===(r=n[e])||void 0===r?void 0:r.call(null==i?void 0:i.current,t)}},{key:"getConfig",value:function(){return this.instance.state.config}}],[{key:"observedAttributes",get:function(){return r}}]),f}(f(HTMLElement));customElements.define(t,s)}}},498:(e,t,n)=>{"use strict";n.d(t,{EK:()=>j,SV:()=>q,ZM:()=>C,U5:()=>k,B7:()=>x,ax:()=>P,eZ:()=>M});var r=n(689),o=n.n(r);const i=require("react-bootstrap");var a=n(927),c=n.n(a);function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function h(e,t,n){return t&&p(e.prototype,t),n&&p(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function b(e,t){return b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},b(e,t)}function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=m(e);if(t){var o=m(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return v(this,n)}}function v(e,t){if(t&&("object"===u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n(216);var S={badge:{width:"4em"},code:{color:"#700",borderLeft:"3px solid #aaa",padding:"0.5em 0px 0.5em 2em",backgroundColor:"#f0f0f0",borderRadius:"4px",marginTop:"0.5em"},inlineCode:{color:"#700",margin:"0px 0.5em 0px 0.5em"}},E=[o().createElement(i.Badge,{bg:"success",style:S.badge},"OK"),o().createElement(i.Badge,{bg:"warning",style:S.badge},"Warn"),o().createElement(i.Badge,{bg:"danger",style:S.badge},"Error"),o().createElement(i.Badge,{bg:"secondary",style:S.badge},"Stale")],k=function(e){var t=e.level;return E[t]||o().createElement("span",null,t)},j=function(e){var t=e.children;return o().createElement("pre",{style:S.code},t)},C=function(e){var t=e.children;return o().createElement("tt",{style:S.inlineCode},t)},T={},P=o().createContext({}),x=function(e){var t=e.duration,n=e.onTimeout,a=e.onStart,c=e.setOnDisconnect,u=e.children;t=t||60;var s=w((0,r.useState)(t),2),l=s[0],f=s[1],p=w((0,r.useState)(!1),2),h=p[0],d=p[1],b=(0,r.useMemo)((function(){return Math.random().toString(36).slice(2)}),[]),y=function(){console.log("stopping timer for",b),n&&setTimeout(n,1),clearInterval(T[b]),T[b]=null,d(!1)};(0,r.useEffect)((function(){var e;l>0&&!h&&(e=T[b],console.log(e,T,l),!e&&l>0&&(d(!0),T[b]=setInterval((function(){return f((function(e){if(--e>0)return e;y()}))}),1e3),a&&setTimeout(a,1)))}),[l]),(0,r.useEffect)((function(){return y}),[]),c&&c((function(){y()}));var v=function(){return f(t)};return o().createElement(P.Provider,{value:{reset:v,duration:t,timer:l}},l>0?o().createElement("div",null,u,l<60&&o().createElement("div",null,"Timeout in: ",l," seconds")):o().createElement("div",null,"Timed out. ",o().createElement(i.Button,{onClick:v},"Resume")))},q=function(e){d(n,e);var t=y(n);function n(e){var r;return f(this,n),(r=t.call(this,e)).state={hasError:!1},r}return h(n,[{key:"componentDidCatch",value:function(e,t){console.warn("ErrorBoundary caught:",e,t)}},{key:"render",value:function(){return this.state.hasError?o().createElement("div",null,this.props.message||"Something went wrong here."):this.props.children}}],[{key:"getDerivedStateFromError",value:function(e){return{hasError:!0}}}]),n}(o().Component),_=function(e){var t;return e.$$typeof==Symbol.for("react.forward_ref")||(null===(t=e.prototype)||void 0===t?void 0:t.render)},M=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"0.0.0",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=_(e)?o().createRef():null,u=function(n){d(u,n);var c=y(u);function u(){var e;f(this,u);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return l(g(e=c.call.apply(c,[this].concat(n))),"onDisconnect",null),l(g(e),"state",{}),e}return h(u,[{key:"setOnDisconnect",value:function(e){this.onDisconnect=e}},{key:"webComponentDisconnected",value:function(){this.setState({_disconnected:!0});try{this.onDisconnect&&this.onDisconnect()}catch(e){console.log("Error during onDisconnect of web-component",e)}}},{key:"webComponentAttributeChanged",value:function(e,t,n){var r=this.state;r[e]=n,this.setState(r)}},{key:"setConfig",value:function(e){this.setState({config:e})}},{key:"render",value:function(){var n=i.stylesheets||["https://cdn.jsdelivr.net/gh/transitiverobotics/transitive-utils@0.8.3/web/css/bootstrap_transitive-bs-root.min.css"];return o().createElement("div",{id:"cap-".concat(t,"-").concat(r),className:i.className||"transitive-bs-root"},o().createElement("style",null,n.map((function(e){return"@import url(".concat(e,");")}))),!this.state._disconnected&&o().createElement(e,s({ref:a},this.state,this.props,{setOnDisconnect:this.setOnDisconnect.bind(this),setConfig:this.setConfig.bind(this)})))}}]),u}(o().Component);c().create(u,t,i.shadowDOM||!1,n,a)}},268:e=>{"use strict";e.exports=require("@webcomponents/custom-elements")},622:e=>{"use strict";e.exports=require("@webcomponents/shadydom")},22:e=>{"use strict";e.exports=require("chalk")},517:e=>{"use strict";e.exports=require("lodash")},848:e=>{"use strict";e.exports=require("lodash/forEach")},712:e=>{"use strict";e.exports=require("lodash/get")},699:e=>{"use strict";e.exports=require("lodash/isEmpty")},113:e=>{"use strict";e.exports=require("lodash/isEqual")},452:e=>{"use strict";e.exports=require("lodash/isPlainObject")},707:e=>{"use strict";e.exports=require("lodash/map")},831:e=>{"use strict";e.exports=require("lodash/merge")},298:e=>{"use strict";e.exports=require("lodash/set")},305:e=>{"use strict";e.exports=require("lodash/unset")},316:e=>{"use strict";e.exports=require("loglevel")},689:e=>{"use strict";e.exports=require("react")},405:e=>{"use strict";e.exports=require("react-dom")},430:e=>{"use strict";e.exports=require("react-shadow-dom-retarget-events")},962:e=>{"use strict";e.exports=require("react-web-component-style-loader/exports")},13:e=>{"use strict";e.exports=require("semver/functions/compare")},84:e=>{"use strict";e.exports=require("semver/ranges/min-version")}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.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 r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{Code:()=>e.EK,ErrorBoundary:()=>e.SV,InlineCode:()=>e.ZM,LevelBadge:()=>e.U5,Timer:()=>e.B7,TimerContext:()=>e.ax,createWebComponent:()=>e.eZ,useMqttSync:()=>t.H,useTransitive:()=>t.D});var e=n(498),t=n(782),o=n(216),i={};for(const e in o)["default","Code","ErrorBoundary","InlineCode","LevelBadge","Timer","TimerContext","createWebComponent","useMqttSync","useTransitive"].indexOf(e)<0&&(i[e]=()=>o[e]);n.d(r,i)})();var o=exports;for(var i in r)o[i]=r[i];r.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
|
package/esdist/utils-web.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var Js=Object.create;var Te=Object.defineProperty;var Ys=Object.getOwnPropertyDescriptor;var Ks=Object.getOwnPropertyNames;var Zs=Object.getPrototypeOf,en=Object.prototype.hasOwnProperty;var b=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Rt=(t,e)=>{for(var r in e)Te(t,r,{get:e[r],enumerable:!0})},Oe=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ks(e))!en.call(t,n)&&n!==r&&Te(t,n,{get:()=>e[n],enumerable:!(s=Ys(e,n))||s.enumerable});return t},N=(t,e,r)=>(Oe(t,e,"default"),r&&Oe(r,e,"default")),P=(t,e,r)=>(r=t!=null?Js(Zs(t)):{},Oe(e||!t||!t.__esModule?Te(r,"default",{value:t,enumerable:!0}):r,t)),tn=t=>Oe(Te({},"__esModule",{value:!0}),t);var Xe=b((Ai,Ie)=>{(function(){"use strict";var t={}.hasOwnProperty,e="[native code]";function r(){for(var s=[],n=0;n<arguments.length;n++){var o=arguments[n];if(o){var i=typeof o;if(i==="string"||i==="number")s.push(o);else if(Array.isArray(o)){if(o.length){var a=r.apply(null,o);a&&s.push(a)}}else if(i==="object"){if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]")){s.push(o.toString());continue}for(var l in o)t.call(o,l)&&o[l]&&s.push(l)}}}return s.join(" ")}typeof Ie<"u"&&Ie.exports?(r.default=r,Ie.exports=r):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return r}):window.classNames=r})()});var jt=b((_i,kt)=>{kt.exports=()=>{try{return require("react-web-component-style-loader/exports").styleElements}catch{return[]}}});var _t=b((Ui,Gt)=>{Gt.exports=function(e){if(!e.attributes)return{};let r={},s,o=[...e.attributes].map(i=>({[i.name]:i.value}));for(s of o){let i=Object.keys(s)[0],a=i.replace(/-([a-z])/g,l=>l[1].toUpperCase());r[a]=s[i]}return r}});var Ht=b((Hi,Ut)=>{var un=require("react"),fn=require("react-dom"),hn=require("react-shadow-dom-retarget-events"),pn=jt(),dn=_t();require("@webcomponents/shadydom");require("@webcomponents/custom-elements");var gn={attachedCallback:"webComponentAttached",connectedCallback:"webComponentConnected",disconnectedCallback:"webComponentDisconnected",attributeChangedCallback:"webComponentAttributeChanged",adoptedCallback:"webComponentAdopted"};Ut.exports={create:(t,e,r=!0,s=[],n=void 0)=>{let o=class extends HTMLElement{instance=null;static get observedAttributes(){return s}callConstructorHook(){this.instance.webComponentConstructed&&this.instance.webComponentConstructed.apply(this.instance,[this])}callLifeCycleHook(i,a=[]){let l=gn[i];l&&this.instance&&this.instance[l]&&this.instance[l].apply(this.instance,a)}connectedCallback(){let i=this,a=i;if(r){let l=i.attachShadow({mode:"open"});a=document.createElement("div"),pn().forEach(u=>{l.appendChild(u.cloneNode(l))}),l.appendChild(a),hn(l)}fn.render(un.createElement(t,dn(i)),a,function(){i.instance=this,i.callConstructorHook(),i.callLifeCycleHook("connectedCallback")})}disconnectedCallback(){this.callLifeCycleHook("disconnectedCallback")}attributeChangedCallback(i,a,l,c){this.callLifeCycleHook("attributeChangedCallback",[i,a,l,c])}adoptedCallback(i,a){this.callLifeCycleHook("adoptedCallback",[i,a])}call(i,a){return n?.current?.[i]?.call(n?.current,a)}getConfig(){return this.instance.state.config}};customElements.define(e,o)}}});var he=b((Vi,Xt)=>{var mn=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};Xt.exports=mn});var Je=b((Wi,Vt)=>{var bn="2.0.0",En=Number.MAX_SAFE_INTEGER||9007199254740991,yn=16;Vt.exports={SEMVER_SPEC_VERSION:bn,MAX_LENGTH:256,MAX_SAFE_INTEGER:En,MAX_SAFE_COMPONENT_LENGTH:yn}});var Ne=b((G,Wt)=>{var{MAX_SAFE_COMPONENT_LENGTH:Ye}=Je(),vn=he();G=Wt.exports={};var xn=G.re=[],h=G.src=[],p=G.t={},$n=0,m=(t,e,r)=>{let s=$n++;vn(s,e),p[t]=s,h[s]=e,xn[s]=new RegExp(e,r?"g":void 0)};m("NUMERICIDENTIFIER","0|[1-9]\\d*");m("NUMERICIDENTIFIERLOOSE","[0-9]+");m("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*");m("MAINVERSION",`(${h[p.NUMERICIDENTIFIER]})\\.(${h[p.NUMERICIDENTIFIER]})\\.(${h[p.NUMERICIDENTIFIER]})`);m("MAINVERSIONLOOSE",`(${h[p.NUMERICIDENTIFIERLOOSE]})\\.(${h[p.NUMERICIDENTIFIERLOOSE]})\\.(${h[p.NUMERICIDENTIFIERLOOSE]})`);m("PRERELEASEIDENTIFIER",`(?:${h[p.NUMERICIDENTIFIER]}|${h[p.NONNUMERICIDENTIFIER]})`);m("PRERELEASEIDENTIFIERLOOSE",`(?:${h[p.NUMERICIDENTIFIERLOOSE]}|${h[p.NONNUMERICIDENTIFIER]})`);m("PRERELEASE",`(?:-(${h[p.PRERELEASEIDENTIFIER]}(?:\\.${h[p.PRERELEASEIDENTIFIER]})*))`);m("PRERELEASELOOSE",`(?:-?(${h[p.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${h[p.PRERELEASEIDENTIFIERLOOSE]})*))`);m("BUILDIDENTIFIER","[0-9A-Za-z-]+");m("BUILD",`(?:\\+(${h[p.BUILDIDENTIFIER]}(?:\\.${h[p.BUILDIDENTIFIER]})*))`);m("FULLPLAIN",`v?${h[p.MAINVERSION]}${h[p.PRERELEASE]}?${h[p.BUILD]}?`);m("FULL",`^${h[p.FULLPLAIN]}$`);m("LOOSEPLAIN",`[v=\\s]*${h[p.MAINVERSIONLOOSE]}${h[p.PRERELEASELOOSE]}?${h[p.BUILD]}?`);m("LOOSE",`^${h[p.LOOSEPLAIN]}$`);m("GTLT","((?:<|>)?=?)");m("XRANGEIDENTIFIERLOOSE",`${h[p.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);m("XRANGEIDENTIFIER",`${h[p.NUMERICIDENTIFIER]}|x|X|\\*`);m("XRANGEPLAIN",`[v=\\s]*(${h[p.XRANGEIDENTIFIER]})(?:\\.(${h[p.XRANGEIDENTIFIER]})(?:\\.(${h[p.XRANGEIDENTIFIER]})(?:${h[p.PRERELEASE]})?${h[p.BUILD]}?)?)?`);m("XRANGEPLAINLOOSE",`[v=\\s]*(${h[p.XRANGEIDENTIFIERLOOSE]})(?:\\.(${h[p.XRANGEIDENTIFIERLOOSE]})(?:\\.(${h[p.XRANGEIDENTIFIERLOOSE]})(?:${h[p.PRERELEASELOOSE]})?${h[p.BUILD]}?)?)?`);m("XRANGE",`^${h[p.GTLT]}\\s*${h[p.XRANGEPLAIN]}$`);m("XRANGELOOSE",`^${h[p.GTLT]}\\s*${h[p.XRANGEPLAINLOOSE]}$`);m("COERCE",`(^|[^\\d])(\\d{1,${Ye}})(?:\\.(\\d{1,${Ye}}))?(?:\\.(\\d{1,${Ye}}))?(?:$|[^\\d])`);m("COERCERTL",h[p.COERCE],!0);m("LONETILDE","(?:~>?)");m("TILDETRIM",`(\\s*)${h[p.LONETILDE]}\\s+`,!0);G.tildeTrimReplace="$1~";m("TILDE",`^${h[p.LONETILDE]}${h[p.XRANGEPLAIN]}$`);m("TILDELOOSE",`^${h[p.LONETILDE]}${h[p.XRANGEPLAINLOOSE]}$`);m("LONECARET","(?:\\^)");m("CARETTRIM",`(\\s*)${h[p.LONECARET]}\\s+`,!0);G.caretTrimReplace="$1^";m("CARET",`^${h[p.LONECARET]}${h[p.XRANGEPLAIN]}$`);m("CARETLOOSE",`^${h[p.LONECARET]}${h[p.XRANGEPLAINLOOSE]}$`);m("COMPARATORLOOSE",`^${h[p.GTLT]}\\s*(${h[p.LOOSEPLAIN]})$|^$`);m("COMPARATOR",`^${h[p.GTLT]}\\s*(${h[p.FULLPLAIN]})$|^$`);m("COMPARATORTRIM",`(\\s*)${h[p.GTLT]}\\s*(${h[p.LOOSEPLAIN]}|${h[p.XRANGEPLAIN]})`,!0);G.comparatorTrimReplace="$1$2$3";m("HYPHENRANGE",`^\\s*(${h[p.XRANGEPLAIN]})\\s+-\\s+(${h[p.XRANGEPLAIN]})\\s*$`);m("HYPHENRANGELOOSE",`^\\s*(${h[p.XRANGEPLAINLOOSE]})\\s+-\\s+(${h[p.XRANGEPLAINLOOSE]})\\s*$`);m("STAR","(<|>)?=?\\s*\\*");m("GTE0","^\\s*>=\\s*0.0.0\\s*$");m("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")});var Ae=b((zi,zt)=>{var wn=["includePrerelease","loose","rtl"],On=t=>t?typeof t!="object"?{loose:!0}:wn.filter(e=>t[e]).reduce((e,r)=>(e[r]=!0,e),{}):{};zt.exports=On});var Kt=b((Qi,Yt)=>{var Qt=/^[0-9]+$/,Jt=(t,e)=>{let r=Qt.test(t),s=Qt.test(e);return r&&s&&(t=+t,e=+e),t===e?0:r&&!s?-1:s&&!r?1:t<e?-1:1},Tn=(t,e)=>Jt(e,t);Yt.exports={compareIdentifiers:Jt,rcompareIdentifiers:Tn}});var de=b((Ji,rr)=>{var Ce=he(),{MAX_LENGTH:Zt,MAX_SAFE_INTEGER:Se}=Je(),{re:er,t:tr}=Ne(),In=Ae(),{compareIdentifiers:pe}=Kt(),Ke=class t{constructor(e,r){if(r=In(r),e instanceof t){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid Version: ${e}`);if(e.length>Zt)throw new TypeError(`version is longer than ${Zt} characters`);Ce("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let s=e.trim().match(r.loose?er[tr.LOOSE]:er[tr.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>Se||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Se||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Se||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let o=+n;if(o>=0&&o<Se)return o}return n}):this.prerelease=[],this.build=s[5]?s[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(Ce("SemVer.compare",this.version,this.options,e),!(e instanceof t)){if(typeof e=="string"&&e===this.version)return 0;e=new t(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof t||(e=new t(e,this.options)),pe(this.major,e.major)||pe(this.minor,e.minor)||pe(this.patch,e.patch)}comparePre(e){if(e instanceof t||(e=new t(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let r=0;do{let s=this.prerelease[r],n=e.prerelease[r];if(Ce("prerelease compare",r,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return pe(s,n)}while(++r)}compareBuild(e){e instanceof t||(e=new t(e,this.options));let r=0;do{let s=this.build[r],n=e.build[r];if(Ce("prerelease compare",r,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return pe(s,n)}while(++r)}inc(e,r){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r),this.inc("pre",r);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r),this.inc("pre",r);break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{let s=this.prerelease.length;for(;--s>=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);s===-1&&this.prerelease.push(0)}r&&(this.prerelease[0]===r?isNaN(this.prerelease[1])&&(this.prerelease=[r,0]):this.prerelease=[r,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}};rr.exports=Ke});var _=b((Yi,nr)=>{var sr=de(),Rn=(t,e,r)=>new sr(t,r).compare(new sr(e,r));nr.exports=Rn});var ir=b((Ki,or)=>{"use strict";or.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}});var lr=b((Zi,ar)=>{"use strict";ar.exports=x;x.Node=X;x.create=x;function x(t){var e=this;if(e instanceof x||(e=new x),e.tail=null,e.head=null,e.length=0,t&&typeof t.forEach=="function")t.forEach(function(n){e.push(n)});else if(arguments.length>0)for(var r=0,s=arguments.length;r<s;r++)e.push(arguments[r]);return e}x.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,r=t.prev;return e&&(e.prev=r),r&&(r.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=r),t.list.length--,t.next=null,t.prev=null,t.list=null,e};x.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}};x.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}};x.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)An(this,arguments[t]);return this.length};x.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)Cn(this,arguments[t]);return this.length};x.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}};x.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}};x.prototype.forEach=function(t,e){e=e||this;for(var r=this.head,s=0;r!==null;s++)t.call(e,r.value,s,this),r=r.next};x.prototype.forEachReverse=function(t,e){e=e||this;for(var r=this.tail,s=this.length-1;r!==null;s--)t.call(e,r.value,s,this),r=r.prev};x.prototype.get=function(t){for(var e=0,r=this.head;r!==null&&e<t;e++)r=r.next;if(e===t&&r!==null)return r.value};x.prototype.getReverse=function(t){for(var e=0,r=this.tail;r!==null&&e<t;e++)r=r.prev;if(e===t&&r!==null)return r.value};x.prototype.map=function(t,e){e=e||this;for(var r=new x,s=this.head;s!==null;)r.push(t.call(e,s.value,this)),s=s.next;return r};x.prototype.mapReverse=function(t,e){e=e||this;for(var r=new x,s=this.tail;s!==null;)r.push(t.call(e,s.value,this)),s=s.prev;return r};x.prototype.reduce=function(t,e){var r,s=this.head;if(arguments.length>1)r=e;else if(this.head)s=this.head.next,r=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var n=0;s!==null;n++)r=t(r,s.value,n),s=s.next;return r};x.prototype.reduceReverse=function(t,e){var r,s=this.tail;if(arguments.length>1)r=e;else if(this.tail)s=this.tail.prev,r=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var n=this.length-1;s!==null;n--)r=t(r,s.value,n),s=s.prev;return r};x.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;r!==null;e++)t[e]=r.value,r=r.next;return t};x.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;r!==null;e++)t[e]=r.value,r=r.prev;return t};x.prototype.slice=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new x;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var s=0,n=this.head;n!==null&&s<t;s++)n=n.next;for(;n!==null&&s<e;s++,n=n.next)r.push(n.value);return r};x.prototype.sliceReverse=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new x;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var s=this.length,n=this.tail;n!==null&&s>e;s--)n=n.prev;for(;n!==null&&s>t;s--,n=n.prev)r.push(n.value);return r};x.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var s=0,n=this.head;n!==null&&s<t;s++)n=n.next;for(var o=[],s=0;n&&s<e;s++)o.push(n.value),n=this.removeNode(n);n===null&&(n=this.tail),n!==this.head&&n!==this.tail&&(n=n.prev);for(var s=0;s<r.length;s++)n=Nn(this,n,r[s]);return o};x.prototype.reverse=function(){for(var t=this.head,e=this.tail,r=t;r!==null;r=r.prev){var s=r.prev;r.prev=r.next,r.next=s}return this.head=e,this.tail=t,this};function Nn(t,e,r){var s=e===t.head?new X(r,null,e,t):new X(r,e,e.next,t);return s.next===null&&(t.tail=s),s.prev===null&&(t.head=s),t.length++,s}function An(t,e){t.tail=new X(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function Cn(t,e){t.head=new X(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function X(t,e,r,s){if(!(this instanceof X))return new X(t,e,r,s);this.list=s,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}try{ir()(x)}catch{}});var pr=b((ea,hr)=>{"use strict";var Sn=lr(),V=Symbol("max"),j=Symbol("length"),Z=Symbol("lengthCalculator"),me=Symbol("allowStale"),W=Symbol("maxAge"),k=Symbol("dispose"),cr=Symbol("noDisposeOnSet"),A=Symbol("lruList"),B=Symbol("cache"),fr=Symbol("updateAgeOnGet"),Ze=()=>1,tt=class{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");let r=this[V]=e.max||1/0,s=e.length||Ze;if(this[Z]=typeof s!="function"?Ze:s,this[me]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[W]=e.maxAge||0,this[k]=e.dispose,this[cr]=e.noDisposeOnSet||!1,this[fr]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[V]=e||1/0,ge(this)}get max(){return this[V]}set allowStale(e){this[me]=!!e}get allowStale(){return this[me]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[W]=e,ge(this)}get maxAge(){return this[W]}set lengthCalculator(e){typeof e!="function"&&(e=Ze),e!==this[Z]&&(this[Z]=e,this[j]=0,this[A].forEach(r=>{r.length=this[Z](r.value,r.key),this[j]+=r.length})),ge(this)}get lengthCalculator(){return this[Z]}get length(){return this[j]}get itemCount(){return this[A].length}rforEach(e,r){r=r||this;for(let s=this[A].tail;s!==null;){let n=s.prev;ur(this,e,s,r),s=n}}forEach(e,r){r=r||this;for(let s=this[A].head;s!==null;){let n=s.next;ur(this,e,s,r),s=n}}keys(){return this[A].toArray().map(e=>e.key)}values(){return this[A].toArray().map(e=>e.value)}reset(){this[k]&&this[A]&&this[A].length&&this[A].forEach(e=>this[k](e.key,e.value)),this[B]=new Map,this[A]=new Sn,this[j]=0}dump(){return this[A].map(e=>Le(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[A]}set(e,r,s){if(s=s||this[W],s&&typeof s!="number")throw new TypeError("maxAge must be a number");let n=s?Date.now():0,o=this[Z](r,e);if(this[B].has(e)){if(o>this[V])return ee(this,this[B].get(e)),!1;let l=this[B].get(e).value;return this[k]&&(this[cr]||this[k](e,l.value)),l.now=n,l.maxAge=s,l.value=r,this[j]+=o-l.length,l.length=o,this.get(e),ge(this),!0}let i=new rt(e,r,o,n,s);return i.length>this[V]?(this[k]&&this[k](e,r),!1):(this[j]+=i.length,this[A].unshift(i),this[B].set(e,this[A].head),ge(this),!0)}has(e){if(!this[B].has(e))return!1;let r=this[B].get(e).value;return!Le(this,r)}get(e){return et(this,e,!0)}peek(e){return et(this,e,!1)}pop(){let e=this[A].tail;return e?(ee(this,e),e.value):null}del(e){ee(this,this[B].get(e))}load(e){this.reset();let r=Date.now();for(let s=e.length-1;s>=0;s--){let n=e[s],o=n.e||0;if(o===0)this.set(n.k,n.v);else{let i=o-r;i>0&&this.set(n.k,n.v,i)}}}prune(){this[B].forEach((e,r)=>et(this,r,!1))}},et=(t,e,r)=>{let s=t[B].get(e);if(s){let n=s.value;if(Le(t,n)){if(ee(t,s),!t[me])return}else r&&(t[fr]&&(s.value.now=Date.now()),t[A].unshiftNode(s));return n.value}},Le=(t,e)=>{if(!e||!e.maxAge&&!t[W])return!1;let r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[W]&&r>t[W]},ge=t=>{if(t[j]>t[V])for(let e=t[A].tail;t[j]>t[V]&&e!==null;){let r=e.prev;ee(t,e),e=r}},ee=(t,e)=>{if(e){let r=e.value;t[k]&&t[k](r.key,r.value),t[j]-=r.length,t[B].delete(r.key),t[A].removeNode(e)}},rt=class{constructor(e,r,s,n,o){this.key=e,this.value=r,this.length=s,this.now=n,this.maxAge=o||0}},ur=(t,e,r,s)=>{let n=r.value;Le(t,n)&&(ee(t,r),t[me]||(n=void 0)),n&&e.call(s,n.value,n.key,t)};hr.exports=tt});var gr=b((ta,dr)=>{var Ln=_(),Pn=(t,e,r)=>Ln(t,e,r)===0;dr.exports=Pn});var br=b((ra,mr)=>{var qn=_(),Dn=(t,e,r)=>qn(t,e,r)!==0;mr.exports=Dn});var st=b((sa,Er)=>{var Fn=_(),Bn=(t,e,r)=>Fn(t,e,r)>0;Er.exports=Bn});var vr=b((na,yr)=>{var Mn=_(),kn=(t,e,r)=>Mn(t,e,r)>=0;yr.exports=kn});var $r=b((oa,xr)=>{var jn=_(),Gn=(t,e,r)=>jn(t,e,r)<0;xr.exports=Gn});var Or=b((ia,wr)=>{var _n=_(),Un=(t,e,r)=>_n(t,e,r)<=0;wr.exports=Un});var Ir=b((aa,Tr)=>{var Hn=gr(),Xn=br(),Vn=st(),Wn=vr(),zn=$r(),Qn=Or(),Jn=(t,e,r,s)=>{switch(e){case"===":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t===r;case"!==":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t!==r;case"":case"=":case"==":return Hn(t,r,s);case"!=":return Xn(t,r,s);case">":return Vn(t,r,s);case">=":return Wn(t,r,s);case"<":return zn(t,r,s);case"<=":return Qn(t,r,s);default:throw new TypeError(`Invalid operator: ${e}`)}};Tr.exports=Jn});var Lr=b((la,Sr)=>{var be=Symbol("SemVer ANY"),it=class t{static get ANY(){return be}constructor(e,r){if(r=Yn(r),e instanceof t){if(e.loose===!!r.loose)return e;e=e.value}ot("comparator",e,r),this.options=r,this.loose=!!r.loose,this.parse(e),this.semver===be?this.value="":this.value=this.operator+this.semver.version,ot("comp",this)}parse(e){let r=this.options.loose?Rr[Nr.COMPARATORLOOSE]:Rr[Nr.COMPARATOR],s=e.match(r);if(!s)throw new TypeError(`Invalid comparator: ${e}`);this.operator=s[1]!==void 0?s[1]:"",this.operator==="="&&(this.operator=""),s[2]?this.semver=new Ar(s[2],this.options.loose):this.semver=be}toString(){return this.value}test(e){if(ot("Comparator.test",e,this.options.loose),this.semver===be||e===be)return!0;if(typeof e=="string")try{e=new Ar(e,this.options)}catch{return!1}return nt(e,this.operator,this.semver,this.options)}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Comparator is required");if((!r||typeof r!="object")&&(r={loose:!!r,includePrerelease:!1}),this.operator==="")return this.value===""?!0:new Cr(e.value,r).test(this.value);if(e.operator==="")return e.value===""?!0:new Cr(this.value,r).test(e.semver);let s=(this.operator===">="||this.operator===">")&&(e.operator===">="||e.operator===">"),n=(this.operator==="<="||this.operator==="<")&&(e.operator==="<="||e.operator==="<"),o=this.semver.version===e.semver.version,i=(this.operator===">="||this.operator==="<=")&&(e.operator===">="||e.operator==="<="),a=nt(this.semver,"<",e.semver,r)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<"),l=nt(this.semver,">",e.semver,r)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return s||n||o&&i||a||l}};Sr.exports=it;var Yn=Ae(),{re:Rr,t:Nr}=Ne(),nt=Ir(),ot=he(),Ar=de(),Cr=at()});var at=b((ca,Fr)=>{var lt=class t{constructor(e,r){if(r=Zn(r),e instanceof t)return e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease?e:new t(e.raw,r);if(e instanceof ct)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(s=>this.parseRange(s.trim())).filter(s=>s.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);if(this.set.length>1){let s=this.set[0];if(this.set=this.set.filter(n=>!qr(n[0])),this.set.length===0)this.set=[s];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&no(n[0])){this.set=[n];break}}}this.format()}format(){return this.range=this.set.map(e=>e.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(e){e=e.trim();let s=`parseRange:${Object.keys(this.options).join(",")}:${e}`,n=Pr.get(s);if(n)return n;let o=this.options.loose,i=o?S[C.HYPHENRANGELOOSE]:S[C.HYPHENRANGE];e=e.replace(i,go(this.options.includePrerelease)),R("hyphen replace",e),e=e.replace(S[C.COMPARATORTRIM],to),R("comparator trim",e,S[C.COMPARATORTRIM]),e=e.replace(S[C.TILDETRIM],ro),e=e.replace(S[C.CARETTRIM],so),e=e.split(/\s+/).join(" ");let a=o?S[C.COMPARATORLOOSE]:S[C.COMPARATOR],l=e.split(" ").map(g=>oo(g,this.options)).join(" ").split(/\s+/).map(g=>po(g,this.options)).filter(this.options.loose?g=>!!g.match(a):()=>!0).map(g=>new ct(g,this.options)),c=l.length,u=new Map;for(let g of l){if(qr(g))return[g];u.set(g.value,g)}u.size>1&&u.has("")&&u.delete("");let f=[...u.values()];return Pr.set(s,f),f}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(s=>Dr(s,r)&&e.set.some(n=>Dr(n,r)&&s.every(o=>n.every(i=>o.intersects(i,r)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new eo(e,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(mo(this.set[r],e,this.options))return!0;return!1}};Fr.exports=lt;var Kn=pr(),Pr=new Kn({max:1e3}),Zn=Ae(),ct=Lr(),R=he(),eo=de(),{re:S,t:C,comparatorTrimReplace:to,tildeTrimReplace:ro,caretTrimReplace:so}=Ne(),qr=t=>t.value==="<0.0.0-0",no=t=>t.value==="",Dr=(t,e)=>{let r=!0,s=t.slice(),n=s.pop();for(;r&&s.length;)r=s.every(o=>n.intersects(o,e)),n=s.pop();return r},oo=(t,e)=>(R("comp",t,e),t=lo(t,e),R("caret",t),t=io(t,e),R("tildes",t),t=uo(t,e),R("xrange",t),t=ho(t,e),R("stars",t),t),L=t=>!t||t.toLowerCase()==="x"||t==="*",io=(t,e)=>t.trim().split(/\s+/).map(r=>ao(r,e)).join(" "),ao=(t,e)=>{let r=e.loose?S[C.TILDELOOSE]:S[C.TILDE];return t.replace(r,(s,n,o,i,a)=>{R("tilde",t,s,n,o,i,a);let l;return L(n)?l="":L(o)?l=`>=${n}.0.0 <${+n+1}.0.0-0`:L(i)?l=`>=${n}.${o}.0 <${n}.${+o+1}.0-0`:a?(R("replaceTilde pr",a),l=`>=${n}.${o}.${i}-${a} <${n}.${+o+1}.0-0`):l=`>=${n}.${o}.${i} <${n}.${+o+1}.0-0`,R("tilde return",l),l})},lo=(t,e)=>t.trim().split(/\s+/).map(r=>co(r,e)).join(" "),co=(t,e)=>{R("caret",t,e);let r=e.loose?S[C.CARETLOOSE]:S[C.CARET],s=e.includePrerelease?"-0":"";return t.replace(r,(n,o,i,a,l)=>{R("caret",t,n,o,i,a,l);let c;return L(o)?c="":L(i)?c=`>=${o}.0.0${s} <${+o+1}.0.0-0`:L(a)?o==="0"?c=`>=${o}.${i}.0${s} <${o}.${+i+1}.0-0`:c=`>=${o}.${i}.0${s} <${+o+1}.0.0-0`:l?(R("replaceCaret pr",l),o==="0"?i==="0"?c=`>=${o}.${i}.${a}-${l} <${o}.${i}.${+a+1}-0`:c=`>=${o}.${i}.${a}-${l} <${o}.${+i+1}.0-0`:c=`>=${o}.${i}.${a}-${l} <${+o+1}.0.0-0`):(R("no pr"),o==="0"?i==="0"?c=`>=${o}.${i}.${a}${s} <${o}.${i}.${+a+1}-0`:c=`>=${o}.${i}.${a}${s} <${o}.${+i+1}.0-0`:c=`>=${o}.${i}.${a} <${+o+1}.0.0-0`),R("caret return",c),c})},uo=(t,e)=>(R("replaceXRanges",t,e),t.split(/\s+/).map(r=>fo(r,e)).join(" ")),fo=(t,e)=>{t=t.trim();let r=e.loose?S[C.XRANGELOOSE]:S[C.XRANGE];return t.replace(r,(s,n,o,i,a,l)=>{R("xRange",t,s,n,o,i,a,l);let c=L(o),u=c||L(i),f=u||L(a),g=f;return n==="="&&g&&(n=""),l=e.includePrerelease?"-0":"",c?n===">"||n==="<"?s="<0.0.0-0":s="*":n&&g?(u&&(i=0),a=0,n===">"?(n=">=",u?(o=+o+1,i=0,a=0):(i=+i+1,a=0)):n==="<="&&(n="<",u?o=+o+1:i=+i+1),n==="<"&&(l="-0"),s=`${n+o}.${i}.${a}${l}`):u?s=`>=${o}.0.0${l} <${+o+1}.0.0-0`:f&&(s=`>=${o}.${i}.0${l} <${o}.${+i+1}.0-0`),R("xRange return",s),s})},ho=(t,e)=>(R("replaceStars",t,e),t.trim().replace(S[C.STAR],"")),po=(t,e)=>(R("replaceGTE0",t,e),t.trim().replace(S[e.includePrerelease?C.GTE0PRE:C.GTE0],"")),go=t=>(e,r,s,n,o,i,a,l,c,u,f,g,M)=>(L(s)?r="":L(n)?r=`>=${s}.0.0${t?"-0":""}`:L(o)?r=`>=${s}.${n}.0${t?"-0":""}`:i?r=`>=${r}`:r=`>=${r}${t?"-0":""}`,L(c)?l="":L(u)?l=`<${+c+1}.0.0-0`:L(f)?l=`<${c}.${+u+1}.0-0`:g?l=`<=${c}.${u}.${f}-${g}`:t?l=`<${c}.${u}.${+f+1}-0`:l=`<=${l}`,`${r} ${l}`.trim()),mo=(t,e,r)=>{for(let s=0;s<t.length;s++)if(!t[s].test(e))return!1;if(e.prerelease.length&&!r.includePrerelease){for(let s=0;s<t.length;s++)if(R(t[s].semver),t[s].semver!==ct.ANY&&t[s].semver.prerelease.length>0){let n=t[s].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}});var kr=b((ua,Mr)=>{var ut=de(),bo=at(),Br=st(),Eo=(t,e)=>{t=new bo(t,e);let r=new ut("0.0.0");if(t.test(r)||(r=new ut("0.0.0-0"),t.test(r)))return r;r=null;for(let s=0;s<t.set.length;++s){let n=t.set[s],o=null;n.forEach(i=>{let a=new ut(i.semver.version);switch(i.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!o||Br(a,o))&&(o=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${i.operator}`)}}),o&&(!r||Br(r,o))&&(r=o)}return r&&t.test(r)?r:null};Mr.exports=Eo});var Gr=b((jr,Pe)=>{(function(t,e){"use strict";typeof define=="function"&&define.amd?define(e):typeof Pe=="object"&&Pe.exports?Pe.exports=e():t.log=e()})(jr,function(){"use strict";var t=function(){},e="undefined",r=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"];function n(y,O){var I=y[O];if(typeof I.bind=="function")return I.bind(y);try{return Function.prototype.bind.call(I,y)}catch{return function(){return Function.prototype.apply.apply(I,[y,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function i(y){return y==="debug"&&(y="log"),typeof console===e?!1:y==="trace"&&r?o:console[y]!==void 0?n(console,y):console.log!==void 0?n(console,"log"):t}function a(y,O){for(var I=0;I<s.length;I++){var $=s[I];this[$]=I<y?t:this.methodFactory($,y,O)}this.log=this.debug}function l(y,O,I){return function(){typeof console!==e&&(a.call(this,O,I),this[y].apply(this,arguments))}}function c(y,O,I){return i(y)||l.apply(this,arguments)}function u(y,O,I){var $=this,J;O=O??"WARN";var q="loglevel";typeof y=="string"?q+=":"+y:typeof y=="symbol"&&(q=void 0);function we(E){var D=(s[E]||"silent").toUpperCase();if(!(typeof window===e||!q)){try{window.localStorage[q]=D;return}catch{}try{window.document.cookie=encodeURIComponent(q)+"="+D+";"}catch{}}}function ue(){var E;if(!(typeof window===e||!q)){try{E=window.localStorage[q]}catch{}if(typeof E===e)try{var D=window.document.cookie,H=D.indexOf(encodeURIComponent(q)+"=");H!==-1&&(E=/^([^;]+)/.exec(D.slice(H))[1])}catch{}return $.levels[E]===void 0&&(E=void 0),E}}function fe(){if(!(typeof window===e||!q)){try{window.localStorage.removeItem(q);return}catch{}try{window.document.cookie=encodeURIComponent(q)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}$.name=y,$.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},$.methodFactory=I||c,$.getLevel=function(){return J},$.setLevel=function(E,D){if(typeof E=="string"&&$.levels[E.toUpperCase()]!==void 0&&(E=$.levels[E.toUpperCase()]),typeof E=="number"&&E>=0&&E<=$.levels.SILENT){if(J=E,D!==!1&&we(E),a.call($,E,y),typeof console===e&&E<$.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+E},$.setDefaultLevel=function(E){O=E,ue()||$.setLevel(E,!1)},$.resetLevel=function(){$.setLevel(O,!1),fe()},$.enableAll=function(E){$.setLevel($.levels.TRACE,E)},$.disableAll=function(E){$.setLevel($.levels.SILENT,E)};var Y=ue();Y==null&&(Y=O),$.setLevel(Y,!1)}var f=new u,g={};f.getLogger=function(O){if(typeof O!="symbol"&&typeof O!="string"||O==="")throw new TypeError("You must supply a name when creating a logger.");var I=g[O];return I||(I=g[O]=new u(O,f.getLevel(),f.methodFactory)),I};var M=typeof window!==e?window.log:void 0;return f.noConflict=function(){return typeof window!==e&&window.log===f&&(window.log=M),f},f.getLoggers=function(){return g},f.default=f,f})});var Ur=b((fa,_r)=>{"use strict";_r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var ft=b((ha,Xr)=>{var Ee=Ur(),Hr={};for(let t of Object.keys(Ee))Hr[Ee[t]]=t;var d={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};Xr.exports=d;for(let t of Object.keys(d)){if(!("channels"in d[t]))throw new Error("missing channels property: "+t);if(!("labels"in d[t]))throw new Error("missing channel labels property: "+t);if(d[t].labels.length!==d[t].channels)throw new Error("channel and label counts mismatch: "+t);let{channels:e,labels:r}=d[t];delete d[t].channels,delete d[t].labels,Object.defineProperty(d[t],"channels",{value:e}),Object.defineProperty(d[t],"labels",{value:r})}d.rgb.hsl=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,n=Math.min(e,r,s),o=Math.max(e,r,s),i=o-n,a,l;o===n?a=0:e===o?a=(r-s)/i:r===o?a=2+(s-e)/i:s===o&&(a=4+(e-r)/i),a=Math.min(a*60,360),a<0&&(a+=360);let c=(n+o)/2;return o===n?l=0:c<=.5?l=i/(o+n):l=i/(2-o-n),[a,l*100,c*100]};d.rgb.hsv=function(t){let e,r,s,n,o,i=t[0]/255,a=t[1]/255,l=t[2]/255,c=Math.max(i,a,l),u=c-Math.min(i,a,l),f=function(g){return(c-g)/6/u+1/2};return u===0?(n=0,o=0):(o=u/c,e=f(i),r=f(a),s=f(l),i===c?n=s-r:a===c?n=1/3+e-s:l===c&&(n=2/3+r-e),n<0?n+=1:n>1&&(n-=1)),[n*360,o*100,c*100]};d.rgb.hwb=function(t){let e=t[0],r=t[1],s=t[2],n=d.rgb.hsl(t)[0],o=1/255*Math.min(e,Math.min(r,s));return s=1-1/255*Math.max(e,Math.max(r,s)),[n,o*100,s*100]};d.rgb.cmyk=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,n=Math.min(1-e,1-r,1-s),o=(1-e-n)/(1-n)||0,i=(1-r-n)/(1-n)||0,a=(1-s-n)/(1-n)||0;return[o*100,i*100,a*100,n*100]};function yo(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2}d.rgb.keyword=function(t){let e=Hr[t];if(e)return e;let r=1/0,s;for(let n of Object.keys(Ee)){let o=Ee[n],i=yo(t,o);i<r&&(r=i,s=n)}return s};d.keyword.rgb=function(t){return Ee[t]};d.rgb.xyz=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,s=s>.04045?((s+.055)/1.055)**2.4:s/12.92;let n=e*.4124+r*.3576+s*.1805,o=e*.2126+r*.7152+s*.0722,i=e*.0193+r*.1192+s*.9505;return[n*100,o*100,i*100]};d.rgb.lab=function(t){let e=d.rgb.xyz(t),r=e[0],s=e[1],n=e[2];r/=95.047,s/=100,n/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;let o=116*s-16,i=500*(r-s),a=200*(s-n);return[o,i,a]};d.hsl.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100,n,o,i;if(r===0)return i=s*255,[i,i,i];s<.5?n=s*(1+r):n=s+r-s*r;let a=2*s-n,l=[0,0,0];for(let c=0;c<3;c++)o=e+1/3*-(c-1),o<0&&o++,o>1&&o--,6*o<1?i=a+(n-a)*6*o:2*o<1?i=n:3*o<2?i=a+(n-a)*(2/3-o)*6:i=a,l[c]=i*255;return l};d.hsl.hsv=function(t){let e=t[0],r=t[1]/100,s=t[2]/100,n=r,o=Math.max(s,.01);s*=2,r*=s<=1?s:2-s,n*=o<=1?o:2-o;let i=(s+r)/2,a=s===0?2*n/(o+n):2*r/(s+r);return[e,a*100,i*100]};d.hsv.rgb=function(t){let e=t[0]/60,r=t[1]/100,s=t[2]/100,n=Math.floor(e)%6,o=e-Math.floor(e),i=255*s*(1-r),a=255*s*(1-r*o),l=255*s*(1-r*(1-o));switch(s*=255,n){case 0:return[s,l,i];case 1:return[a,s,i];case 2:return[i,s,l];case 3:return[i,a,s];case 4:return[l,i,s];case 5:return[s,i,a]}};d.hsv.hsl=function(t){let e=t[0],r=t[1]/100,s=t[2]/100,n=Math.max(s,.01),o,i;i=(2-r)*s;let a=(2-r)*n;return o=r*n,o/=a<=1?a:2-a,o=o||0,i/=2,[e,o*100,i*100]};d.hwb.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100,n=r+s,o;n>1&&(r/=n,s/=n);let i=Math.floor(6*e),a=1-s;o=6*e-i,i&1&&(o=1-o);let l=r+o*(a-r),c,u,f;switch(i){default:case 6:case 0:c=a,u=l,f=r;break;case 1:c=l,u=a,f=r;break;case 2:c=r,u=a,f=l;break;case 3:c=r,u=l,f=a;break;case 4:c=l,u=r,f=a;break;case 5:c=a,u=r,f=l;break}return[c*255,u*255,f*255]};d.cmyk.rgb=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,n=t[3]/100,o=1-Math.min(1,e*(1-n)+n),i=1-Math.min(1,r*(1-n)+n),a=1-Math.min(1,s*(1-n)+n);return[o*255,i*255,a*255]};d.xyz.rgb=function(t){let e=t[0]/100,r=t[1]/100,s=t[2]/100,n,o,i;return n=e*3.2406+r*-1.5372+s*-.4986,o=e*-.9689+r*1.8758+s*.0415,i=e*.0557+r*-.204+s*1.057,n=n>.0031308?1.055*n**(1/2.4)-.055:n*12.92,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,i=i>.0031308?1.055*i**(1/2.4)-.055:i*12.92,n=Math.min(Math.max(0,n),1),o=Math.min(Math.max(0,o),1),i=Math.min(Math.max(0,i),1),[n*255,o*255,i*255]};d.xyz.lab=function(t){let e=t[0],r=t[1],s=t[2];e/=95.047,r/=100,s/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,s=s>.008856?s**(1/3):7.787*s+16/116;let n=116*r-16,o=500*(e-r),i=200*(r-s);return[n,o,i]};d.lab.xyz=function(t){let e=t[0],r=t[1],s=t[2],n,o,i;o=(e+16)/116,n=r/500+o,i=o-s/200;let a=o**3,l=n**3,c=i**3;return o=a>.008856?a:(o-16/116)/7.787,n=l>.008856?l:(n-16/116)/7.787,i=c>.008856?c:(i-16/116)/7.787,n*=95.047,o*=100,i*=108.883,[n,o,i]};d.lab.lch=function(t){let e=t[0],r=t[1],s=t[2],n;n=Math.atan2(s,r)*360/2/Math.PI,n<0&&(n+=360);let i=Math.sqrt(r*r+s*s);return[e,i,n]};d.lch.lab=function(t){let e=t[0],r=t[1],n=t[2]/360*2*Math.PI,o=r*Math.cos(n),i=r*Math.sin(n);return[e,o,i]};d.rgb.ansi16=function(t,e=null){let[r,s,n]=t,o=e===null?d.rgb.hsv(t)[2]:e;if(o=Math.round(o/50),o===0)return 30;let i=30+(Math.round(n/255)<<2|Math.round(s/255)<<1|Math.round(r/255));return o===2&&(i+=60),i};d.hsv.ansi16=function(t){return d.rgb.ansi16(d.hsv.rgb(t),t[2])};d.rgb.ansi256=function(t){let e=t[0],r=t[1],s=t[2];return e===r&&r===s?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(s/255*5)};d.ansi16.rgb=function(t){let e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];let r=(~~(t>50)+1)*.5,s=(e&1)*r*255,n=(e>>1&1)*r*255,o=(e>>2&1)*r*255;return[s,n,o]};d.ansi256.rgb=function(t){if(t>=232){let o=(t-232)*10+8;return[o,o,o]}t-=16;let e,r=Math.floor(t/36)/5*255,s=Math.floor((e=t%36)/6)/5*255,n=e%6/5*255;return[r,s,n]};d.rgb.hex=function(t){let r=(((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255)).toString(16).toUpperCase();return"000000".substring(r.length)+r};d.hex.rgb=function(t){let e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let r=e[0];e[0].length===3&&(r=r.split("").map(a=>a+a).join(""));let s=parseInt(r,16),n=s>>16&255,o=s>>8&255,i=s&255;return[n,o,i]};d.rgb.hcg=function(t){let e=t[0]/255,r=t[1]/255,s=t[2]/255,n=Math.max(Math.max(e,r),s),o=Math.min(Math.min(e,r),s),i=n-o,a,l;return i<1?a=o/(1-i):a=0,i<=0?l=0:n===e?l=(r-s)/i%6:n===r?l=2+(s-e)/i:l=4+(e-r)/i,l/=6,l%=1,[l*360,i*100,a*100]};d.hsl.hcg=function(t){let e=t[1]/100,r=t[2]/100,s=r<.5?2*e*r:2*e*(1-r),n=0;return s<1&&(n=(r-.5*s)/(1-s)),[t[0],s*100,n*100]};d.hsv.hcg=function(t){let e=t[1]/100,r=t[2]/100,s=e*r,n=0;return s<1&&(n=(r-s)/(1-s)),[t[0],s*100,n*100]};d.hcg.rgb=function(t){let e=t[0]/360,r=t[1]/100,s=t[2]/100;if(r===0)return[s*255,s*255,s*255];let n=[0,0,0],o=e%1*6,i=o%1,a=1-i,l=0;switch(Math.floor(o)){case 0:n[0]=1,n[1]=i,n[2]=0;break;case 1:n[0]=a,n[1]=1,n[2]=0;break;case 2:n[0]=0,n[1]=1,n[2]=i;break;case 3:n[0]=0,n[1]=a,n[2]=1;break;case 4:n[0]=i,n[1]=0,n[2]=1;break;default:n[0]=1,n[1]=0,n[2]=a}return l=(1-r)*s,[(r*n[0]+l)*255,(r*n[1]+l)*255,(r*n[2]+l)*255]};d.hcg.hsv=function(t){let e=t[1]/100,r=t[2]/100,s=e+r*(1-e),n=0;return s>0&&(n=e/s),[t[0],n*100,s*100]};d.hcg.hsl=function(t){let e=t[1]/100,s=t[2]/100*(1-e)+.5*e,n=0;return s>0&&s<.5?n=e/(2*s):s>=.5&&s<1&&(n=e/(2*(1-s))),[t[0],n*100,s*100]};d.hcg.hwb=function(t){let e=t[1]/100,r=t[2]/100,s=e+r*(1-e);return[t[0],(s-e)*100,(1-s)*100]};d.hwb.hcg=function(t){let e=t[1]/100,s=1-t[2]/100,n=s-e,o=0;return n<1&&(o=(s-n)/(1-n)),[t[0],n*100,o*100]};d.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};d.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};d.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};d.gray.hsl=function(t){return[0,0,t[0]]};d.gray.hsv=d.gray.hsl;d.gray.hwb=function(t){return[0,100,t[0]]};d.gray.cmyk=function(t){return[0,0,0,t[0]]};d.gray.lab=function(t){return[t[0],0,0]};d.gray.hex=function(t){let e=Math.round(t[0]/100*255)&255,s=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(s.length)+s};d.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]}});var Wr=b((pa,Vr)=>{var qe=ft();function vo(){let t={},e=Object.keys(qe);for(let r=e.length,s=0;s<r;s++)t[e[s]]={distance:-1,parent:null};return t}function xo(t){let e=vo(),r=[t];for(e[t].distance=0;r.length;){let s=r.pop(),n=Object.keys(qe[s]);for(let o=n.length,i=0;i<o;i++){let a=n[i],l=e[a];l.distance===-1&&(l.distance=e[s].distance+1,l.parent=s,r.unshift(a))}}return e}function $o(t,e){return function(r){return e(t(r))}}function wo(t,e){let r=[e[t].parent,t],s=qe[e[t].parent][t],n=e[t].parent;for(;e[n].parent;)r.unshift(e[n].parent),s=$o(qe[e[n].parent][n],s),n=e[n].parent;return s.conversion=r,s}Vr.exports=function(t){let e=xo(t),r={},s=Object.keys(e);for(let n=s.length,o=0;o<n;o++){let i=s[o];e[i].parent!==null&&(r[i]=wo(i,e))}return r}});var Qr=b((da,zr)=>{var ht=ft(),Oo=Wr(),te={},To=Object.keys(ht);function Io(t){let e=function(...r){let s=r[0];return s==null?s:(s.length>1&&(r=s),t(r))};return"conversion"in t&&(e.conversion=t.conversion),e}function Ro(t){let e=function(...r){let s=r[0];if(s==null)return s;s.length>1&&(r=s);let n=t(r);if(typeof n=="object")for(let o=n.length,i=0;i<o;i++)n[i]=Math.round(n[i]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}To.forEach(t=>{te[t]={},Object.defineProperty(te[t],"channels",{value:ht[t].channels}),Object.defineProperty(te[t],"labels",{value:ht[t].labels});let e=Oo(t);Object.keys(e).forEach(s=>{let n=e[s];te[t][s]=Ro(n),te[t][s].raw=Io(n)})});zr.exports=te});var ts=b((ga,es)=>{"use strict";var Jr=(t,e)=>(...r)=>`\x1B[${t(...r)+e}m`,Yr=(t,e)=>(...r)=>{let s=t(...r);return`\x1B[${38+e};5;${s}m`},Kr=(t,e)=>(...r)=>{let s=t(...r);return`\x1B[${38+e};2;${s[0]};${s[1]};${s[2]}m`},De=t=>t,Zr=(t,e,r)=>[t,e,r],re=(t,e,r)=>{Object.defineProperty(t,e,{get:()=>{let s=r();return Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0}),s},enumerable:!0,configurable:!0})},pt,se=(t,e,r,s)=>{pt===void 0&&(pt=Qr());let n=s?10:0,o={};for(let[i,a]of Object.entries(pt)){let l=i==="ansi16"?"ansi":i;i===e?o[l]=t(r,n):typeof a=="object"&&(o[l]=t(a[e],n))}return o};function No(){let t=new Map,e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[r,s]of Object.entries(e)){for(let[n,o]of Object.entries(s))e[n]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},s[n]=e[n],t.set(o[0],o[1]);Object.defineProperty(e,r,{value:s,enumerable:!1})}return Object.defineProperty(e,"codes",{value:t,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",re(e.color,"ansi",()=>se(Jr,"ansi16",De,!1)),re(e.color,"ansi256",()=>se(Yr,"ansi256",De,!1)),re(e.color,"ansi16m",()=>se(Kr,"rgb",Zr,!1)),re(e.bgColor,"ansi",()=>se(Jr,"ansi16",De,!0)),re(e.bgColor,"ansi256",()=>se(Yr,"ansi256",De,!0)),re(e.bgColor,"ansi16m",()=>se(Kr,"rgb",Zr,!0)),e}Object.defineProperty(es,"exports",{enumerable:!0,get:No})});var ss=b((ma,rs)=>{"use strict";rs.exports={stdout:!1,stderr:!1}});var os=b((ba,ns)=>{"use strict";var Ao=(t,e,r)=>{let s=t.indexOf(e);if(s===-1)return t;let n=e.length,o=0,i="";do i+=t.substr(o,s-o)+e+r,o=s+n,s=t.indexOf(e,o);while(s!==-1);return i+=t.substr(o),i},Co=(t,e,r,s)=>{let n=0,o="";do{let i=t[s-1]==="\r";o+=t.substr(n,(i?s-1:s)-n)+e+(i?`\r
|
|
2
|
-
`:`
|
|
3
|
-
`)+r,n=s+1,s=t.indexOf(`
|
|
4
|
-
`,n)}while(s!==-1);return o+=t.substr(n),o};ns.exports={stringReplaceAll:Ao,stringEncaseCRLFWithFirstIndex:Co}});var us=b((Ea,cs)=>{"use strict";var So=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,is=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,Lo=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,Po=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,qo=new Map([["n",`
|
|
5
|
-
`],["r","\r"],["t"," "],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e","\x1B"],["a","\x07"]]);function ls(t){let e=t[0]==="u",r=t[1]==="{";return e&&!r&&t.length===5||t[0]==="x"&&t.length===3?String.fromCharCode(parseInt(t.slice(1),16)):e&&r?String.fromCodePoint(parseInt(t.slice(2,-1),16)):qo.get(t)||t}function Do(t,e){let r=[],s=e.trim().split(/\s*,\s*/g),n;for(let o of s){let i=Number(o);if(!Number.isNaN(i))r.push(i);else if(n=o.match(Lo))r.push(n[2].replace(Po,(a,l,c)=>l?ls(l):c));else throw new Error(`Invalid Chalk template style argument: ${o} (in style '${t}')`)}return r}function Fo(t){is.lastIndex=0;let e=[],r;for(;(r=is.exec(t))!==null;){let s=r[1];if(r[2]){let n=Do(s,r[2]);e.push([s].concat(n))}else e.push([s])}return e}function as(t,e){let r={};for(let n of e)for(let o of n.styles)r[o[0]]=n.inverse?null:o.slice(1);let s=t;for(let[n,o]of Object.entries(r))if(Array.isArray(o)){if(!(n in s))throw new Error(`Unknown Chalk style: ${n}`);s=o.length>0?s[n](...o):s[n]}return s}cs.exports=(t,e)=>{let r=[],s=[],n=[];if(e.replace(So,(o,i,a,l,c,u)=>{if(i)n.push(ls(i));else if(l){let f=n.join("");n=[],s.push(r.length===0?f:as(t,r)(f)),r.push({inverse:a,styles:Fo(l)})}else if(c){if(r.length===0)throw new Error("Found extraneous } in Chalk template literal");s.push(as(t,r)(n.join(""))),n=[],r.pop()}else n.push(u)}),s.push(n.join("")),r.length>0){let o=`Chalk template literal is missing ${r.length} closing bracket${r.length===1?"":"s"} (\`}\`)`;throw new Error(o)}return s.join("")}});var bs=b((ya,ms)=>{"use strict";var ye=ts(),{stdout:gt,stderr:mt}=ss(),{stringReplaceAll:Bo,stringEncaseCRLFWithFirstIndex:Mo}=os(),{isArray:Fe}=Array,hs=["ansi","ansi","ansi256","ansi16m"],ne=Object.create(null),ko=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=gt?gt.level:0;t.level=e.level===void 0?r:e.level},bt=class{constructor(e){return ps(e)}},ps=t=>{let e={};return ko(e,t),e.template=(...r)=>gs(e.template,...r),Object.setPrototypeOf(e,Be.prototype),Object.setPrototypeOf(e.template,e),e.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},e.template.Instance=bt,e.template};function Be(t){return ps(t)}for(let[t,e]of Object.entries(ye))ne[t]={get(){let r=Me(this,Et(e.open,e.close,this._styler),this._isEmpty);return Object.defineProperty(this,t,{value:r}),r}};ne.visible={get(){let t=Me(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:t}),t}};var ds=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(let t of ds)ne[t]={get(){let{level:e}=this;return function(...r){let s=Et(ye.color[hs[e]][t](...r),ye.color.close,this._styler);return Me(this,s,this._isEmpty)}}};for(let t of ds){let e="bg"+t[0].toUpperCase()+t.slice(1);ne[e]={get(){let{level:r}=this;return function(...s){let n=Et(ye.bgColor[hs[r]][t](...s),ye.bgColor.close,this._styler);return Me(this,n,this._isEmpty)}}}}var jo=Object.defineProperties(()=>{},{...ne,level:{enumerable:!0,get(){return this._generator.level},set(t){this._generator.level=t}}}),Et=(t,e,r)=>{let s,n;return r===void 0?(s=t,n=e):(s=r.openAll+t,n=e+r.closeAll),{open:t,close:e,openAll:s,closeAll:n,parent:r}},Me=(t,e,r)=>{let s=(...n)=>Fe(n[0])&&Fe(n[0].raw)?fs(s,gs(s,...n)):fs(s,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(s,jo),s._generator=t,s._styler=e,s._isEmpty=r,s},fs=(t,e)=>{if(t.level<=0||!e)return t._isEmpty?"":e;let r=t._styler;if(r===void 0)return e;let{openAll:s,closeAll:n}=r;if(e.indexOf("\x1B")!==-1)for(;r!==void 0;)e=Bo(e,r.close,r.open),r=r.parent;let o=e.indexOf(`
|
|
6
|
-
`);return o!==-1&&(e=Mo(e,n,s,o)),s+e+n},dt,gs=(t,...e)=>{let[r]=e;if(!Fe(r)||!Fe(r.raw))return e.join(" ");let s=e.slice(1),n=[r.raw[0]];for(let o=1;o<r.length;o++)n.push(String(s[o-1]).replace(/[{}\\]/g,"\\$&"),String(r.raw[o]));return dt===void 0&&(dt=us()),dt(t,n.join(""))};Object.defineProperties(Be.prototype,ne);var ke=Be();ke.supportsColor=gt;ke.stderr=Be({level:mt?mt.level:0});ke.stderr.supportsColor=mt;ms.exports=ke});var ys=b((va,Es)=>{Es.exports={rosReleases:{kinetic:{rosVersion:1,ubuntuCodename:"xenial"},melodic:{rosVersion:1,ubuntuCodename:"bionic"},noetic:{rosVersion:1,ubuntuCodename:"focal"},dashing:{rosVersion:2},eloquent:{rosVersion:2},foxy:{rosVersion:2},galactic:{rosVersion:2},humble:{rosVersion:2},iron:{rosVersion:2},rolling:{rosVersion:2}}}});var Ge=b((xa,Ss)=>{var Go=_(),vs=kr(),oe={get:require("lodash/get"),set:require("lodash/set"),unset:require("lodash/unset"),forEach:require("lodash/forEach"),map:require("lodash/map"),isEmpty:require("lodash/isEmpty"),eq:require("lodash/isEqual"),isPlainObject:require("lodash/isPlainObject"),merge:require("lodash/merge")},ie=Gr(),ve=bs(),_o=ys();ie.setAll=t=>Object.values(ie.getLoggers()).forEach(e=>e.setLevel(t));var xs={warn:ve.yellow,error:ve.red,info:ve.green,debug:ve.gray},Uo=t=>xs[t]?xs[t](t):t,Ho=ie.methodFactory;ie.methodFactory=(t,e,r)=>{let s=Ho(t,e,r);if(typeof window<"u"){let o=`${r} ${t}`;return(...i)=>s(`[${o}]`,...i)}let n=`${r} ${Uo(t)}`;return(...o)=>s(`[${ve.blue(new Date().toISOString())} ${n}]`,...o)};var Xo=ie.getLogger,Vo=t=>JSON.parse(JSON.stringify(t)),Wo=t=>JSON.parse(atob(t.split(".")[1])),zo=t=>{try{return JSON.parse(t)}catch{return null}},$s=(t,e,r)=>{t&&(r(t),t[e]?.forEach(s=>$s(s,e,r)))},Qo=t=>new Promise(e=>{setTimeout(e,t)}),ws=(t,e=[],r={})=>(oe.forEach(t,(s,n)=>{let o=e.concat(String(n));(oe.isPlainObject(s)||s instanceof Array)&&s!==null?ws(s,o,r):r[Ns(o)]=s}),r),Os=(t,e,r,s=[],n={})=>{if(e.length==0||e[0]=="#"){r(t,s,n);return}let o=e[0];if(o){for(let i in t)if(i==o||o=="*"||o.startsWith("+")){let a=o.startsWith("+")&&o.length>1?Object.assign({},n,{[o.slice(1)]:i}):n;Os(t[i],e.slice(1),r,s.concat([i]),a)}}},Ts=(t,e,r)=>{if(e.length==0)return t;let s=e.shift();e.length==0?t[s]=r:(t[s]||(t[s]={}),Ts(t[s],e,r))},Is=t=>t.replace(/%/g,"%25").replace(/\//g,"%2F"),Rs=t=>t.replace(/%25/g,"%").replace(/%2F/g,"/"),Ns=t=>{let e=r=>r.startsWith("+")?"+":r;return`/${t.map(e).map(Is).join("/")}`},z=t=>{let e=t.split("/").map(Rs);return e.length>0&&e[0].length==0&&e.shift(),e.length>0&&e.at(-1).length==0&&e.pop(),e},As=(t,e)=>{let r=(o,i)=>{if(o.length==0||o[0][0]=="#"||i.length==0)return!0;if(o[0]==i[0])return r(o.slice(1),i.slice(1));if(o[0][0]=="+"){let a=r(o.slice(1),i.slice(1));return a&&Object.assign({[o[0].slice(1)]:i[0]},a)}return!1},s=z(t),n=z(e);return r(s,n)},Jo=(t,e)=>{let r=z(e),s=z(t);return Cs(r,s)&&r.length<s.length},Cs=(t,e)=>t.length==0?!0:t[0]==e[0]&&Cs(t.slice(1),e.slice(1)),Yo=t=>{let e=t.split(":");return{organization:e[0],client:e[1],sub:e.slice(2)}},Ko=t=>{let e=z(t);return{organization:e[0],device:e[1],capabilityScope:e[2],capabilityName:e[3],capability:`${e[2]}/${e[3]}`,version:e[4],sub:e.slice(5)}},Zo=t=>t.length==0?null:JSON.parse(t.toString("utf-8")),ei=(t,e,r,s=1e3)=>{let n=[],o=a=>{e.forEach(l=>As(`${l}/#`,a)&&n.push(a))};t.on("message",o),e.forEach(a=>{typeof a=="string"?t.subscribe(`${a}/#`):console.warn("Ignoring",a,"since it is not a string.")});let i=typeof Buffer<"u"?Buffer.alloc(0):null;setTimeout(()=>{t.removeListener("message",o),e.forEach(l=>t.unsubscribe(`${l}/#`));let a=n.length;console.log(`clearing ${a} retained messages from ${e}`),n.forEach(l=>{t.publish(l,i,{retain:!0})}),r&&r(a)},s)},ti=()=>Math.random().toString(36).slice(2),je=(t,e)=>Go(vs(t),vs(e)),ri=(t,e=void 0,r={})=>{if(!t)return e?oe.set({},e,t):t;let s=Object.keys(t).filter(i=>(!r.maxVersion||je(i,r.maxVersion)<=0)&&(!r.minVersion||je(r.minVersion,i)<=0)).sort(je),n={},o=e&&z(e);return s.forEach(i=>{let a=o?oe.get(t[i],o):t[i];oe.merge(n,a)}),o?oe.set({},o,n):n},si=["B","KB","MB","GB","TB"],ni=t=>{if(!t)return"--";let e=0;for(;t>1024;)t/=1024,e++;return`${t.toFixed(2)} ${si[e]}`},oi=t=>{if(!t)return"--";let e={};t>3600&&(e.h=Math.floor(t/3600),t=t%3600),t>60&&(e.m=Math.floor(t/60),t=t%60),e.s=Math.floor(t);let r="";return e.h>0&&(r+=`${e.h}h `),e.m>0&&(r+=`${e.m}m `),!e.h&&(r+=`${e.s}s`),r.trim()};Ss.exports={parseMQTTUsername:Yo,parseMQTTTopic:Ko,pathToTopic:Ns,topicToPath:z,toFlatObject:ws,topicMatch:As,mqttParsePayload:Zo,getRandomId:ti,versionCompare:je,loglevel:ie,getLogger:Xo,mergeVersions:ri,mqttClearRetained:ei,isSubTopicOf:Jo,clone:Vo,setFromPath:Ts,forMatchIterator:Os,encodeTopicElement:Is,decodeTopicElement:Rs,constants:_o,visit:$s,wait:Qo,formatBytes:ni,formatDuration:oi,tryJSONParse:zo,decodeJWT:Wo}});var xt=b(($a,qs)=>{var F={get:require("lodash/get"),set:require("lodash/set"),unset:require("lodash/unset"),forEach:require("lodash/forEach"),map:require("lodash/map"),isEmpty:require("lodash/isEmpty"),eq:require("lodash/isEqual"),isPlainObject:require("lodash/isPlainObject"),merge:require("lodash/merge")},{topicToPath:xe,pathToTopic:ii,toFlatObject:ai,topicMatch:Ls,forMatchIterator:li}=Ge(),vt=(t,e)=>{if(!e||e.length==0)return;F.unset(t,e);let r=e.slice(0,-1),s=r.length==0?t:F.get(t,r);return F.isEmpty(s)?vt(t,r):e},ci=(t,e)=>(F.forEach(e,(r,s)=>{let n=xe(s);r==null?vt(t,n):F.set(t,n,r)}),t),Ps=(t,e)=>{if(e.length==0)return;let r=e[0];if(r)for(let s in t)s!=r&&r!="*"&&!r.startsWith("+")?delete t[s]:Ps(t[s],e.slice(1))},yt=class{#e={};#t=[];#r=[];constructor(e={}){this.#e=e}updateFromArray(e,r,s={}){let n=F.get(this.#e,e);if(r==null){if(n==null)return{};vt(this.#e,e)}else{if(F.eq(n,r))return{};F.set(this.#e,e,r)}let o=ii(e),i={[o]:r},a;if(r instanceof Object){let l=ai(r);a={},F.forEach(l,(c,u)=>{a[`${o}${u}`]=c})}else a=i;return this.#t.forEach(l=>l(i,s)),this.#r.forEach(l=>l(a,s)),a}update(e,r,s){if(typeof e=="string")return this.updateFromTopic(e,r,s);if(e instanceof Array)return this.updateFromArray(e,r,s);throw new Error("unrecognized path expression")}updateFromTopic(e,r,s){return this.updateFromArray(xe(e),r,s)}updateFromModifier(e,r){return F.map(e,(s,n)=>this.updateFromTopic(n,s,r))}subscribe(e){e instanceof Function?this.#t.push(e):console.warn("DataCache.subscribe expects a function as argument. Did you mean to use subscribePath?")}subscribePath(e,r){this.#t.push((s,n)=>{F.forEach(s,(o,i)=>{let a=Ls(e,i);a&&r(o,i,a,n)})})}subscribePathFlat(e,r){this.#r.push((s,n)=>{F.forEach(s,(o,i)=>{let a=Ls(e,i);a&&r(o,i,a,n)})})}unsubscribe(e){this.#t=this.#t.filter(r=>r!=e)}get(e=[]){return e.length==0?this.#e:F.get(this.#e,e)}getByTopic(e){return this.get(xe(e))}filter(e){let r=JSON.parse(JSON.stringify(this.get()));return Ps(r,e),r}filterByTopic(e){return this.filter(xe(e))}forMatch(e,r){let s=xe(e);this.forPathMatch(s,r)}forPathMatch(e,r){li(this.get(),e,r)}};qs.exports={DataCache:yt,updateObject:ci}});var Ot=b((wa,js)=>{"use strict";var{mqttParsePayload:ui,topicMatch:$t,topicToPath:ae,pathToTopic:_e,toFlatObject:Ds,getLogger:fi,mergeVersions:hi,parseMQTTTopic:pi,isSubTopicOf:Fs,versionCompare:di,encodeTopicElement:gi}=Ge(),{DataCache:mi}=xt(),Q=require("lodash"),T=fi("MqttSync"),Bs="$SYS/broker/uptime",bi=()=>{},Ei=t=>typeof t=="object"?JSON.parse(JSON.stringify(t)):t,Ms=t=>t.endsWith("/#")?t:t.endsWith("/")?t.concat("#"):t.concat("/#"),ks=t=>t.replace(/\/\//g,"/"),wt=class{data=new mi;subscribedPaths={};publishedPaths={};publishedMessages={};publishQueue=new Map;heartbeatWaitersOnce=[];heartbeats=0;beforeDisconnectHooks=[];constructor({mqttClient:e,onChange:r,ignoreRetain:s,migrate:n,onReady:o,sliceTopic:i}){this.mqtt=e,this.mqtt.on("message",(a,l,c)=>{let u=l&&l.toString();if(T.debug("got message",a,u.slice(0,180),u.length>180?`... (${u.length} bytes)`:"",c.retain),a==Bs)this.heartbeats>0&&(this.heartbeatWaitersOnce.forEach(f=>f()),this.heartbeatWaitersOnce=[]),this.heartbeats==1&&!n&&o&&o(),this.heartbeats++;else if(c.retain||s){T.debug("processing message",a),i&&(a=_e(ae(a).slice(i)));let f=ui(l);if(this.isPublished(a))this.publishedMessages[a]=f,this.data.update(a,f,{external:!0});else if(this.isSubscribed(a)){T.debug("applying received update",a);let g=this.data.update(a,f);r&&Object.keys(g).length>0&&r(g)}}}),this.mqtt.subscribe(Bs,{rap:!0},T.debug),n?.length>0&&this.migrate(n,()=>{T.debug("done migrating",o),o&&this.waitForHeartbeatOnce(o)})}publishAtLevel(e,r,s){T.debug(`publishingAtLevel ${s}`,e,r),s>0?Q.forEach(r,(n,o)=>{let i=`${e}/${gi(o)}`;T.debug(`publishing ${i}`),this.publishAtLevel(i,n,s-1)}):this.mqtt.publish(e,JSON.stringify(r),{retain:!0},n=>{n&&T.warn("Error when publishing migration result",n)})}migrate(e,r=void 0){let s=e.length;if(s==0){r&&r();return}let n=()=>--s==0&&r&&r();e.forEach(({topic:o,newVersion:i,transform:a=void 0,flat:l=!1,level:c=0})=>{T.debug("migrating",o,i);let{organization:u,device:f,capability:g,sub:M}=pi(o),y=`/${u}/${f}/${g}`,O=M.length==0?"/#":_e(M),I=`${y}/+${O}`;this.subscribe(I,$=>{if($){T.warn("Error during migration",$),n();return}this.waitForHeartbeatOnce(()=>{T.debug("got heartbeat",o,I);let J=this.data.getByTopic(y);if(!J){this.unsubscribe(I),n();return}let q=hi(J,O,{maxVersion:i}),we=Q.get(q,ae(O)),ue=a?a(we):we,fe=ks(`${y}/${i}/${O}`);if(T.debug("publishing merged",fe),l){let Y=Ds(ue),E=ae(fe);Q.forEach(Y,(D,H)=>{let He=_e(E.concat(ae(H)));this.mqtt.publish(He,JSON.stringify(D),{retain:!0},It=>{It&&T.warn(`Error when publishing migration result for ${H}`,It)})})}else this.publishAtLevel(fe,ue,c);this.unsubscribe(I),this.waitForHeartbeatOnce(()=>{let E=Object.keys(J).filter(D=>di(D,i)<0).map(D=>ks(`${y}/${D}/${O}`));T.debug({prefixesToClear:E}),this.clear(E),n()})})})})}clear(e,r=void 0,s={}){let n=[],o=a=>{e.forEach(l=>$t(`${l}/#`,a)&&(!s.filter||s.filter(a))&&n.push(a))};this.mqtt.on("message",o),e.forEach(a=>{typeof a=="string"?this.mqtt.subscribe(`${a}/#`):T.warn("Ignoring",a,"since it is not a string.")});let i=typeof Buffer<"u"?Buffer.alloc(0):null;this.waitForHeartbeatOnce(()=>{this.mqtt.removeListener("message",o),e.forEach(l=>this.mqtt.unsubscribe(`${l}/#`));let a=n.length;T.debug(`clearing ${a} retained messages from ${e}`),n.forEach(l=>{this.mqtt.publish(l,i,{retain:!0})}),r&&r(a)})}waitForHeartbeatOnce(e){setTimeout(()=>this.heartbeatWaitersOnce.push(e),1)}isSubscribed(e){return Object.keys(this.subscribedPaths).some(r=>$t(r,e))}isPublished(e){return Object.keys(this.publishedPaths).some(r=>$t(r,e)&&!this.publishedPaths[r].atomic)}subscribe(e,r=bi){if(e=Ms(e),this.subscribedPaths[e]){T.debug("already subscribed to",e),r();return}this.mqtt.subscribe(e,{rap:!0},(s,n)=>{T.debug("subscribe",e,"granted:",n),n&&n.some(o=>o.topic==e&&o.qos<128)?(this.subscribedPaths[e]=1,r(null)):r(`not permitted to subscribe to topic ${e}, ${JSON.stringify(n)}`)})}unsubscribe(e){this.subscribedPaths[e]&&(this.mqtt.unsubscribe(e),delete this.subscribedPaths[e])}_actuallyPublish(e,r){return this.mqtt.connected?(T.debug("actually publishing",e),this.mqtt.publish(e,r==null?null:JSON.stringify(r),{retain:!0}),!0):(T.warn("not connected, not publishing",e),!1)}_processQueue_rec(e){if(this.publishQueue.size>0){let[r,s]=this.publishQueue.entries().next().value;this._actuallyPublish(r,s)?(this.publishQueue.delete(r),this._processQueue_rec(e)):setTimeout(()=>this._processQueue_rec(e),5e3)}else e()}_processQueue(){this._processing||(this._processing=!0,this._processQueue_rec(()=>this._processing=!1))}setThrottle(e){this._processQueueThrottled=Q.throttle(this._processQueue.bind(this),e)}clearThrottle(){delete this._processQueueThrottled}addToQueue(e,r){this.publishQueue.set(e,r)}_enqueue(e,r){T.debug("enqueuing",e),this.addToQueue(e,r),this._processQueueThrottled?this._processQueueThrottled():this._processQueue(),r==null?delete this.publishedMessages[e]:this.publishedMessages[e]=Ei(r)}publish(e,r={atomic:!1}){if(e=Ms(e),Q.isEqual(this.publishedPaths[e],r))return!1;if(this.publishedPaths[e]=r,r.atomic)return this.data.subscribePath(e,(s,n,o,i)=>{if(i?.external)return;T.debug("processing change (atomic)",n,e);let a=e.slice(0,e.length-2),l=_e(ae(n).slice(0,ae(a).length));this._enqueue(l,this.data.getByTopic(l))}),!0;this.mqtt.subscribe(e),this.data.subscribePath(e,(s,n,o,i)=>{if(!i?.external)return T.debug("processing change",n),Q.each(this.publishedMessages,(a,l)=>{if(T.trace("oldKey",l),l==n)return!0;if(Fs(l,n)&&this._enqueue(l,null),Fs(n,l)){this._enqueue(l,null);let c=Ds(a);Q.each(c,(u,f)=>{let g=`${l}${f}`;this._enqueue(g,u)})}}),this._enqueue(n,s),!0})}beforeDisconnect(){this.beforeDisconnectHooks.forEach(e=>e(this))}onBeforeDisconnect(e){this.beforeDisconnectHooks.push(e)}};js.exports=wt});var ce={};Rt(ce,{Code:()=>xi,ErrorBoundary:()=>Tt,InlineCode:()=>$i,LevelBadge:()=>vi,MqttSync:()=>_s,Timer:()=>wi,TimerContext:()=>Vs,createWebComponent:()=>Ti,fetchJson:()=>Hs,parseCookie:()=>Us,useMqttSync:()=>Qs,useTransitive:()=>Ri});module.exports=tn(ce);var w=P(require("react"));var Ve=P(require("react")),We=require("react"),rn=require("react/jsx-runtime"),sn=["xxl","xl","lg","md","sm","xs"],nn="xs",Nt=Ve.createContext({prefixes:{},breakpoints:sn,minBreakpoint:nn}),{Consumer:Ci,Provider:Si}=Nt;function Re(t,e){let{prefixes:r}=(0,We.useContext)(Nt);return t||r[e]||e}var At=P(require("react")),Ct=require("react/jsx-runtime"),on=["as","disabled"];function an(t,e){if(t==null)return{};var r={},s=Object.keys(t),n,o;for(o=0;o<s.length;o++)n=s[o],!(e.indexOf(n)>=0)&&(r[n]=t[n]);return r}function ln(t){return!t||t.trim()==="#"}function ze({tagName:t,disabled:e,href:r,target:s,rel:n,role:o,onClick:i,tabIndex:a=0,type:l}){t||(r!=null||s!=null||n!=null?t="a":t="button");let c={tagName:t};if(t==="button")return[{type:l||"button",disabled:e},c];let u=g=>{if((e||t==="a"&&ln(r))&&g.preventDefault(),e){g.stopPropagation();return}i?.(g)},f=g=>{g.key===" "&&(g.preventDefault(),u(g))};return t==="a"&&(r||(r="#"),e&&(r=void 0)),[{role:o??"button",disabled:void 0,tabIndex:e?void 0:a,href:r,target:t==="a"?s:void 0,"aria-disabled":e||void 0,rel:t==="a"?n:void 0,onClick:u,onKeyDown:f},c]}var cn=At.forwardRef((t,e)=>{let{as:r,disabled:s}=t,n=an(t,on),[o,{tagName:i}]=ze(Object.assign({tagName:r,disabled:s},n));return(0,Ct.jsx)(i,Object.assign({},n,o,{ref:e}))});cn.displayName="Button";var St=P(Xe()),Lt=P(require("react"));var Pt=require("react/jsx-runtime"),qt=Lt.forwardRef(({bsPrefix:t,bg:e="primary",pill:r=!1,text:s,className:n,as:o="span",...i},a)=>{let l=Re(t,"badge");return(0,Pt.jsx)(o,{ref:a,...i,className:(0,St.default)(n,l,r&&"rounded-pill",s&&`text-${s}`,e&&`bg-${e}`)})});qt.displayName="Badge";var K=qt;var Dt=P(Xe()),Ft=P(require("react"));var Bt=require("react/jsx-runtime"),Mt=Ft.forwardRef(({as:t,bsPrefix:e,variant:r="primary",size:s,active:n=!1,disabled:o=!1,className:i,...a},l)=>{let c=Re(e,"btn"),[u,{tagName:f}]=ze({tagName:t,disabled:o,...a});return(0,Bt.jsx)(f,{...u,...a,ref:l,disabled:o,className:(0,Dt.default)(i,c,n&&"active",r&&`${c}-${r}`,s&&`${c}-${s}`,a.href&&o&&"disabled")})});Mt.displayName="Button";var Qe=Mt;var Xs=P(Ht());var v={};Rt(v,{MqttSync:()=>_s,fetchJson:()=>Hs,parseCookie:()=>Us});N(v,P(Ge()));N(v,P(xt()));var Gs=P(Ot()),_s=Gs.default,Us=t=>t.split(";").map(e=>e.split("=")).reduce((e,r)=>(e[decodeURIComponent(r[0].trim())]=r[1]&&decodeURIComponent(r[1].trim()),e),{}),Hs=(t,e,r={})=>{fetch(t,{method:r.method||(r.body?"post":"get"),mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:r.body?JSON.stringify(r.body):void 0}).then(s=>{let n=!s.ok&&`fetching ${t} failed: ${s.status} ${s.statusText}`;s.json().then(o=>e(n,o)).catch(o=>{throw new Error(o)})}).catch(s=>e(`error: ${s}`))};var le={badge:{width:"4em"},code:{color:"#700",borderLeft:"3px solid #aaa",padding:"0.5em 0px 0.5em 2em",backgroundColor:"#f0f0f0",borderRadius:"4px",marginTop:"0.5em"},inlineCode:{color:"#700",margin:"0px 0.5em 0px 0.5em"}},yi=[w.default.createElement(K,{bg:"success",style:le.badge},"OK"),w.default.createElement(K,{bg:"warning",style:le.badge},"Warn"),w.default.createElement(K,{bg:"danger",style:le.badge},"Error"),w.default.createElement(K,{bg:"secondary",style:le.badge},"Stale")],vi=({level:t})=>yi[t]||w.default.createElement("span",null,t),xi=({children:t})=>w.default.createElement("pre",{style:le.code},t),$i=({children:t})=>w.default.createElement("tt",{style:le.inlineCode},t),$e={},Vs=w.default.createContext({}),wi=({duration:t,onTimeout:e,onStart:r,setOnDisconnect:s,children:n})=>{t=t||60;let[o,i]=(0,w.useState)(t),[a,l]=(0,w.useState)(!1),c=(0,w.useMemo)(()=>Math.random().toString(36).slice(2),[]),u=()=>{console.log("stopping timer for",c),e&&setTimeout(e,1),clearInterval($e[c]),$e[c]=null,l(!1)},f=()=>{let M=$e[c];return console.log(M,$e,o),!M&&o>0&&(l(!0),$e[c]=setInterval(()=>i(y=>{if(--y>0)return y;u()}),1e3),r&&setTimeout(r,1)),u};(0,w.useEffect)(()=>{o>0&&!a&&f()},[o]),(0,w.useEffect)(()=>u,[]),s&&s(()=>{u()});let g=()=>i(t);return w.default.createElement(Vs.Provider,{value:{reset:g,duration:t,timer:o}},o>0?w.default.createElement("div",null,n,o<60&&w.default.createElement("div",null,"Timeout in: ",o," seconds")):w.default.createElement("div",null,"Timed out. ",w.default.createElement(Qe,{onClick:g},"Resume")))},Tt=class extends w.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0}}componentDidCatch(e,r){console.warn("ErrorBoundary caught:",e,r)}render(){return this.state.hasError?w.default.createElement("div",null,this.props.message||"Something went wrong here."):this.props.children}},Oi=t=>t.$$typeof==Symbol.for("react.forward_ref")||t.prototype?.render,Ti=(t,e,r=[],s="0.0.0",n={})=>{let o=Oi(t)?w.default.createRef():null;class i extends w.default.Component{onDisconnect=null;state={};setOnDisconnect(l){this.onDisconnect=l}webComponentDisconnected(){this.setState({_disconnected:!0});try{this.onDisconnect&&this.onDisconnect()}catch(l){console.log("Error during onDisconnect of web-component",l)}}webComponentAttributeChanged(l,c,u){let f=this.state;f[l]=u,this.setState(f)}setConfig(l){this.setState({config:l})}render(){let l=n.stylesheets||["https://cdn.jsdelivr.net/gh/transitiverobotics/transitive-utils@0.8.3/web/css/bootstrap_transitive-bs-root.min.css"];return w.default.createElement("div",{id:`cap-${e}-${s}`,className:n.className||"transitive-bs-root"},w.default.createElement("style",null,l.map(c=>`@import url(${c});`)),!this.state._disconnected&&w.default.createElement(t,{ref:o,...this.state,...this.props,setOnDisconnect:this.setOnDisconnect.bind(this),setConfig:this.setConfig.bind(this)}))}}Xs.default.create(i,e,n.shadowDOM||!1,r,o)};var U=P(require("react")),Ws=P(require("lodash")),zs=P(require("mqtt-browser"));var Ii=Ot(),Ue=(0,v.getLogger)("utils-web/hooks");Ue.setLevel("info");var Qs=({jwt:t,id:e,mqttUrl:r})=>{let[s,n]=(0,U.useState)("connecting"),[o,i]=(0,U.useState)(),[a,l]=(0,U.useState)({});return(0,U.useEffect)(()=>{let c=(0,v.decodeJWT)(t),u=zs.default.connect(r,{username:JSON.stringify({id:e,payload:c}),password:t});return u.on("connect",()=>{Ue.debug("connected");let f=new Ii({mqttClient:u,ignoreRetain:!0});i(f),n("connected"),f.data.subscribe(Ws.default.throttle(()=>l((0,v.clone)(f.data.get())),50))}),u.on("error",f=>{Ue.error(f),n(`error: ${f}`)}),()=>{Ue.info("cleaning up useMQTTSync"),o&&o.beforeDisconnect?(o.beforeDisconnect(),o.waitForHeartbeatOnce(()=>u.end())):u.end()}},[t,e]),{status:s,ready:s=="connected",StatusComponent:()=>U.default.createElement("div",null,s),mqttSync:o,data:a}},Ri=({jwt:t,id:e,host:r,ssl:s,capability:n,versionNS:o})=>{let[i,a]=n.split("/"),{device:l}=(0,v.decodeJWT)(t),c=[e,l,i,a],u=(0,v.pathToTopic)(c),f=[...c,o],g=(0,v.pathToTopic)(f),M=`${s&&JSON.parse(s)?"wss":"ws"}://mqtt.${r}`;return{...Qs({jwt:t,id:e,mqttUrl:M}),device:l,prefixPath:c,prefix:u,prefixPathVersion:f,prefixVersion:g}};N(ce,v,module.exports);
|
|
7
|
-
/*! Bundled license information:
|
|
8
|
-
|
|
9
|
-
classnames/index.js:
|
|
10
|
-
(*!
|
|
11
|
-
Copyright (c) 2018 Jed Watson.
|
|
12
|
-
Licensed under the MIT License (MIT), see
|
|
13
|
-
http://jedwatson.github.io/classnames
|
|
14
|
-
*)
|
|
15
|
-
*/
|