@hpcc-js/util 3.5.2 → 3.5.5

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.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@hpcc-js/util"]={})}(this,function(e){"use strict";var t,r,s,n,i=Object.defineProperty,o=(e,t)=>i(e,"name",{value:t,configurable:!0});function a(e,t){if(null==e)throw new TypeError('"o" is null or not defined');const r=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");const s=arguments[1];let n=0;for(;n<r;){const r=e[n];if(t.call(s,r,n))return r;n++}}function h(e,t){const r={update:[],exit:[],enter:[...t]};for(const s of e){const e=r.enter.indexOf(s);e>=0?(r.update.push(s),r.enter.splice(e,1)):r.exit.push(s)}return r}function c(e,t,r,s=(e,t)=>t){const n={update:[],exit:[],enter:[]};if(e===t)return n.update=e,n;const i={};t.forEach(e=>{i[r(e)]=e});for(const o of e){const e=r(o),t=i[e];void 0!==t?(delete i[e],n.update.push(s(o,t))):n.exit.push(o)}for(const o in i)n.enter.push(i[o]);return n}function u(e,t){for(;e.length<t;)e="0"+e;return e}function d(e,t){if(0===t.length)return e;for(let r=0;r<t.length;++r){e=(e<<5)-e+t.charCodeAt(r),e|=0}return e<0?-2*e:e}function l(e,t,r){return"function"==typeof t.hashSum?t.hashSum():Object.keys(t).sort().reduce((e,s)=>p(e,t[s],s,r),e)}function p(e,t,r,s){const n=d(d(d(e,r),g(t)),typeof t);return null===t?d(n,"null"):void 0===t?d(n,"undefined"):"object"==typeof t?-1!==s.indexOf(t)?d(n,"[Circular]"+r):(s.push(t),l(n,t,s)):d(n,t.toString())}function g(e){return Object.prototype.toString.call(e)}function f(e){return u(p(0,e,"",[]).toString(16),8)}o(a,"find"),o(h,"compare"),o(c,"compare2"),o(u,"pad"),o(d,"fold"),o(l,"foldObject"),o(p,"foldValue"),o(g,"toString"),o(f,"hashSum");const _=class _Cache{_cache={};_calcID;static hash(...e){return f({...e})}constructor(e){this._calcID=e}has(e){return this._calcID(e)in this._cache}set(e){return this._cache[this._calcID(e)]=e,e}get(e,t){const r=this._cache[this._calcID(e)];return r||(t?this.set(t()):null)}};o(_,"Cache");let v=_;const b=class _AsyncCache{_cache={};_calcID;static hash(...e){return f({...e})}constructor(e){this._calcID=e}has(e){return this._calcID(e)in this._cache}set(e,t){return this._cache[this._calcID(e)]=t,t}get(e,t){const r=this._cache[this._calcID(e)];return r||(t?this.set(e,t()):Promise.resolve(null))}};o(b,"AsyncCache");let E=b;function x(e,t){const r={};return(...s)=>{const n=f(s);return r[n]||(r[n]={clockStart:Date.now(),promise:e(...s).then(e=>(void 0===t?r[n]=null:setTimeout(()=>{r[n]=null},Math.max(t-(Date.now()-r[n].clockStart),0)),e)).catch(e=>{throw r[n]=null,e})}),r[n].promise}}function m(e,t){let r;const s=new Promise((t,s)=>{r=setTimeout(()=>{clearTimeout(r),s("Timed out in "+e+"ms.")},e)});return Promise.race([t,s]).then(e=>(clearTimeout(r),e)).catch(e=>{throw clearTimeout(r),e})}o(x,"debounce"),o(m,"promiseTimeout");const w=class _AsyncOrderedQueue{_q=[];isTop(e){return this._q[0]===e}push(e){const t=e.then(e=>this.isTop(t)?(this._q.shift(),e):new Promise((r,s)=>{const n=setInterval(()=>{this.isTop(t)&&(clearInterval(n),this._q.shift(),r(e))},20)}));return this._q.push(t),t}};o(w,"AsyncOrderedQueue");let M=w;function S(e){return new Promise(t=>{setTimeout(()=>t(),e)})}o(S,"sleep");const y=class _Dictionary{store={};constructor(e){if(e)for(const t in e)this.set(t,e[t])}set(e,t){const r=this.store[e];return this.store[e]=t,r}get(e){return this.store[e]}has(e){return void 0!==this.store[e]}remove(e){delete this.store[e]}keys(){const e=[];for(const t in this.store)e.push(t);return e}values(){const e=[];for(const t in this.store)e.push(this.store[t]);return e}};o(y,"Dictionary");let O=y;const V=class _DictionaryNoCase extends O{constructor(e){super(e)}set(e,t){return super.set(e.toLowerCase(),t)}get(e){return super.get(e.toLowerCase())}has(e){return super.has(e.toLowerCase())}remove(e){return super.remove(e.toLowerCase())}};o(V,"DictionaryNoCase");let I=V;function D(e){if(!e)return 0;if(!isNaN(Number(e)))return Number(e);const t=e.indexOf("ns");if(-1!==t)return parseFloat(e.substr(0,t))/1e9;const r=e.indexOf("ms");if(-1!==r)return parseFloat(e.substr(0,r))/1e3;const s=e.indexOf("s");if(-1!==s&&-1===e.indexOf("days"))return parseFloat(e.substr(0,s));const n=e.split(" days "),i=n.length>1?parseFloat(n[0]):0;let o=0;const a=(n.length>1?n[1]:n[0]).split(":").reverse();for(let h=0;h<a.length;++h)o+=parseFloat(a[h])*Math.pow(60,h);return 24*i*60*60+o}o(D,"espTime2Seconds");let T=(o(t=class{_graph;parent;props={};constructor(e,t){this._graph=e,this.parent=t}},"GraphItem"),t),k=(o(r=class extends T{subgraphs=[];vertices=[];edges=[];_;constructor(e,t,r){super(e,t),t&&t._addSubgraph(this),this._=r}remove(e=!0){this._graph.removeSubgraph(this,e)}createSubgraph(e){return this._graph.createSubgraph(this,e)}_addSubgraph(e){if(this.subgraphs.indexOf(e)>=0)throw new Error("Subgraph already exists");this.subgraphs.push(e)}_removeSubgraph(e){const t=this.subgraphs.indexOf(e);if(t<0)throw new Error("Subgraph does not exist");this.subgraphs.splice(t,1)}removeAllSubgraphs(){for(let e=this.subgraphs.length-1;e>=0;--e)this._graph.removeSubgraph(this.subgraphs[e],!0)}createVertex(e){return this._graph.createVertex(this,e)}_addVertex(e){if(this.vertices.indexOf(e)>=0)throw new Error("Vertex already exists");this.vertices.push(e)}_removeVertex(e){const t=this.vertices.indexOf(e);if(t<0)throw new Error("Vertex does not exist");this.vertices.splice(t,1)}removeAllVertices(){for(let e=this.vertices.length-1;e>=0;--e)this._graph.removeVertex(this.vertices[e],!0)}createEdge(e,t,r){return this._graph.createEdge(this,e,t,r)}_addEdge(e){if(this.edges.indexOf(e)>=0)throw new Error("Edge already exists");this.edges.push(e)}_removeEdge(e){const t=this.edges.indexOf(e);if(t<0)throw new Error("Edge does not exist");this.edges.splice(t,1)}_add(e){e instanceof r?this._addSubgraph(e):e instanceof F?this._addVertex(e):this._addEdge(e)}},"Subgraph"),r),F=(o(s=class extends T{inEdges=[];outEdges=[];get edges(){return[...this.inEdges,...this.outEdges]}_;constructor(e,t,r){super(e,t),t._addVertex(this),this._=r}remove(e=!0,t){return this._graph.removeVertex(this,e,t)}addInEdge(e){this.inEdges.push(e)}removeInEdge(e){const t=this.inEdges.indexOf(e);if(t<0)throw new Error("In edge does not exist");this.inEdges.splice(t,1)}addOutEdge(e){this.outEdges.push(e)}removeOutEdge(e){const t=this.outEdges.indexOf(e);if(t<0)throw new Error("Out edge does not exist");this.outEdges.splice(t,1)}},"Vertex"),s),C=(o(n=class extends T{source;target;_;constructor(e,t,r,s,n){if(super(e,t),!r)throw new Error("Missing source vertex");if(!s)throw new Error("Missing target vertex");t._addEdge(this),this.source=r,this.source.addOutEdge(this),this.target=s,this.target.addInEdge(this),this._=n}remove(){this._graph.removeEdge(this)}},"Edge"),n);const $=class _Graph{root;_allSubgraphs=[];_allSubgraphsMap={};_allVertices=[];_allVerticesMap={};_allEdges=[];_allEdgesMap={};idOf;constructor(e=e=>""+e._,t){this.root=new k(this,null,t),this.idOf=e}createSubgraph(e,t){const r=new k(this,e||this.root,t);return this._allSubgraphs.push(r),this._allSubgraphsMap[this.idOf(r)]=r,r}removeSubgraph(e,t=!0){const r=this._allSubgraphs.indexOf(e);if(r<0)throw new Error("Subgraph does not exist");this._allSubgraphs.splice(r,1),delete this._allSubgraphsMap[this.idOf(e)],e.parent&&e.parent._removeSubgraph(e),e.edges.forEach(r=>t?this.removeEdge(r):e.parent._addEdge(r)),e.vertices.forEach(r=>t?this.removeVertex(r,t):e.parent._addVertex(r)),e.subgraphs.forEach(r=>t?this.removeSubgraph(r,t):e.parent._addSubgraph(r))}get subgraphs(){return this._allSubgraphs}subgraph(e){return this._allSubgraphsMap[e]}createVertex(e,t){const r=new F(this,e,t);return this._allVertices.push(r),this._allVerticesMap[this.idOf(r)]=r,r}removeVertex(e,t=!0,r){const s=this._allVertices.indexOf(e);if(s<0)throw new Error("Vertex does not exist");this._allVertices.splice(s,1),delete this._allVerticesMap[this.idOf(e)],e.parent&&e.parent._removeVertex(e),t||e.inEdges.forEach(t=>{e.outEdges.forEach(e=>{this.createEdge(this.root,t.source,e.target,r?r(t.source._,e.target._):void 0)})}),e.inEdges.forEach(e=>this.removeEdge(e)),e.outEdges.forEach(e=>this.removeEdge(e))}get vertices(){return this._allVertices}vertex(e){return this._allVerticesMap[e]}createEdge(e,t,r,s){const n=new C(this,e,t,r,s);return this._allEdges.push(n),this._allEdgesMap[this.idOf(n)]=n,n}removeEdge(e){const t=this._allEdges.indexOf(e);if(t<0)throw new Error("Edge does not exist");this._allEdges.splice(t,1),delete this._allEdgesMap[this.idOf(e)],e.parent&&e.parent._removeEdge(e),e.source.removeOutEdge(e),e.target.removeInEdge(e)}get edges(){return this._allEdges}edge(e){return this._allEdgesMap[e]}_walk(e,t){for(const r of e.subgraphs)switch(t(r)){case"abort":return!0;case"stepover":break;default:if(this._walk(r,t))return!0}for(const r of e.vertices)if("abort"===t(r))return!0}walk(e){this._walk(this.root,e);for(const t of this._allEdges)if("abort"===e(t))return!0}clone(){const e=new(0,this.constructor)(this.idOf,this.root._),t=A();return t.put(this.root,e.root),this.walk(e=>{const r=t.get(e.parent);if(e instanceof k)t.put(e,r.createSubgraph(e._));else if(e instanceof F)t.put(e,r.createVertex(e._));else if(e instanceof C){const s=t.get(e.source),n=t.get(e.target);r.createEdge(s,n,e._)}}),e}};o($,"Graph");let L=$;function A(){const e=[],t=[];return{put(r,s){const n=e.indexOf(r);-1===n?(e.push(r),t.push(s)):t[n]=s},get:r=>t[e.indexOf(r)]}}o(A,"ObjMap");const N=class _GraphItem{_graph;_;id(){return this._graph.id(this._)}constructor(e,t){this._graph=e,this._=t}};o(N,"GraphItem");let P=N;const j=class _ChildGraphItem extends P{_parent;constructor(e,t){super(e,t)}clearParent(){return this._parent&&(this._parent.removeChild(this),delete this._parent),this}parent(e){return 0===arguments.length?this._parent:(this._parent!==e&&(this._parent&&this._parent.removeChild(this),this._parent=e,this._parent&&this._parent.addChild(this)),this)}};o(j,"ChildGraphItem");let q=j;const X=class _Subgraph extends q{_children=[];constructor(e,t){super(e,t)}children(){return this._children}addChild(e){this._children.push(e)}removeChild(e){this._children=this._children.filter(t=>t.id!==e.id)}};o(X,"Subgraph");let G=X;const B=class _Vertex extends q{_inEdges=[];_outEdges=[];constructor(e,t){super(e,t)}edges(){return[...this._inEdges,...this._outEdges]}edgeCount(){return this._outEdges.length+this._inEdges.length}inEdges(){return this._inEdges}addInEdge(e){this._inEdges.push(e)}removeInEdge(e){this._inEdges=this._inEdges.filter(t=>t._.id!==e)}outEdges(){return this._outEdges}addOutEdge(e){this._outEdges.push(e)}removeOutEdge(e){this._outEdges=this._outEdges.filter(t=>t._.id!==e)}};o(B,"Vertex");let R=B;const H=class _Edge extends q{_source;_target;constructor(e,t,r,s){super(e,t),this._source=r,this._target=s}};o(H,"Edge");let z=H;const U=class _Graph2{_directed;_subgraphMap={};_vertexMap={};_edgeMap={};constructor(e=!0){this._directed=e}clear(){return this._subgraphMap={},this._vertexMap={},this._edgeMap={},this}clearParents(){for(const e in this._subgraphMap)this._subgraphMap[e].clearParent();for(const e in this._vertexMap)this._vertexMap[e].clearParent();return this}isDirected(){return this._directed}_idFunc=o(e=>"function"==typeof e.id?e.id():e.id,"_idFunc");idFunc(e){return this._idFunc=e,this}_sourceFunc=o(e=>"function"==typeof e.source?e.source():e.source,"_sourceFunc");sourceFunc(e){return this._sourceFunc=e,this}_targetFunc=o(e=>"function"==typeof e.target?e.target():e.target,"_targetFunc");targetFunc(e){return this._targetFunc=e,this}_updateFunc=o((e,t)=>t,"_updateFunc");updateFunc(e){return this._updateFunc=e,this}id(e){return this._idFunc(e)}type(e){return this.subgraphExists(e)?"S":this.vertexExists(e)?"V":this.edgeExists(e)?"E":""}isSubgraph(e){return this.subgraphExists(this.id(e))}isVertex(e){return this.vertexExists(this.id(e))}isEdge(e){return this.edgeExists(this.id(e))}allItems(){return[...this.allSubgraphs(),...this.allVertices(),...this.allEdges()]}item(e){return this.subgraphExists(e)?this.subgraph(e):this.vertexExists(e)?this.vertex(e):this.edgeExists(e)?this.edge(e):void 0}itemExists(e){return this.edgeExists(e)||this.vertexExists(e)||this.subgraphExists(e)}allSubgraphs(){const e=[];for(const t in this._subgraphMap)e.push(this._subgraphMap[t]._);return e}subgraphs(){const e=[];for(const t in this._subgraphMap)void 0===this._subgraphMap[t].parent()&&e.push(this._subgraphMap[t]._);return e}subgraphExists(e){return!!this._subgraphMap[e]}subgraph(e){return this._subgraphMap[e]._}subgraphSubgraphs(e){return this._subgraphMap[e].children().filter(e=>this.isSubgraph(e._)).map(e=>e._)}subgraphVertices(e){return this._subgraphMap[e].children().filter(e=>this.isVertex(e._)).map(e=>e._)}subgraphEdges(e){return this._subgraphMap[e].children().filter(e=>this.isEdge(e._)).map(e=>e._)}addSubgraph(e,t){const r=this._idFunc(e);if(this._subgraphMap[r])throw new Error(`Subgraph '${r}' already exists.`);const s=new G(this,e);if(t){const e=this._idFunc(t);if(!this._subgraphMap[e])throw new Error(`Subgraph '${e}' does not exist.`);s.parent(this._subgraphMap[e])}return this._subgraphMap[r]=s,this}mergeSubgraphs(e=[]){const t=c(this.allSubgraphs(),e,e=>this._idFunc(e),this._updateFunc);return t.exit.forEach(e=>this.removeSubgraph(this._idFunc(e))),t.enter.forEach(e=>this.addSubgraph(e)),t.update.forEach(e=>this.updateSubgraph(e)),this}updateSubgraph(e){const t=this._idFunc(e),r=this._subgraphMap[t];if(!r)throw new Error(`Subgraph '${t}' does not exist.`);return r._=e,this}removeSubgraph(e,t=!0){const r=this._subgraphMap[e];if(!r)throw new Error(`Subgraph '${e}' does not exist.`);return r.children().forEach(e=>{t?e.parent(r.parent()):e instanceof G?this.removeSubgraph(e.id()):this.removeVertex(e.id())}),delete this._subgraphMap[e],this}subgraphParent(e,t){const r=this._subgraphMap[e];if(!r)throw new Error(`Subgraph '${e}' does not exist.`);if(void 0===t){const e=r.parent();return e?e._:void 0}const s=this._subgraphMap[t];if(!s)throw new Error(`Vertex parent '${s}' does not exist.`);return r.parent(s),this}allVertices(){const e=[];for(const t in this._vertexMap)e.push(this._vertexMap[t]._);return e}vertices(){const e=[];for(const t in this._vertexMap)void 0===this._vertexMap[t].parent()&&e.push(this._vertexMap[t]._);return e}vertexExists(e){return!!this._vertexMap[e]}vertex(e){return this._vertexMap[e]._}allEdges(){const e=[];for(const t in this._edgeMap)e.push(this._edgeMap[t]._);return e}edges(){const e=[];for(const t in this._edgeMap)void 0===this._edgeMap[t].parent()&&e.push(this._edgeMap[t]._);return e}vertexEdges(e){return this._vertexMap[e].edges().map(e=>e._)}inEdges(e){return this._vertexMap[e].inEdges().map(e=>e._)}outEdges(e){return this._vertexMap[e].outEdges().map(e=>e._)}_neighbors(e){return[...this._vertexMap[e].outEdges().map(e=>e._target),...this._vertexMap[e].inEdges().map(e=>e._source)]}neighbors(e){return this._neighbors(e).map(e=>e._)}singleNeighbors(e){return this._neighbors(e).filter(e=>1===e.edgeCount()).map(e=>e._)}addVertex(e,t){const r=this._idFunc(e);if(this._vertexMap[r])throw new Error(`Vertex '${r}' already exists.`);const s=new R(this,e);if(t){const e=this._idFunc(t);if(!this.subgraphExists(e))throw new Error(`Subgraph '${e}' does not exist.`);s.parent(this._subgraphMap[e])}return this._vertexMap[r]=s,this}mergeVertices(e){const t=c(this.allVertices(),e,e=>this._idFunc(e),this._updateFunc);return t.exit.forEach(e=>this.removeVertex(this._idFunc(e))),t.enter.forEach(e=>this.addVertex(e)),t.update.forEach(e=>this.updateVertex(e)),this}updateVertex(e){const t=this._idFunc(e),r=this._vertexMap[t];if(!r)throw new Error(`Vertex '${t}' does not exist.`);return r._=e,this}removeVertex(e){const t=this._vertexMap[e];if(!t)throw new Error(`Vertex '${e}' does not exist.`);return t.edges().forEach(e=>{this.removeEdge(e.id())}),delete this._vertexMap[e],this}vertexParent(e,t){const r=this._vertexMap[e];if(!r)throw new Error(`Vertex '${e}' does not exist.`);if(void 0===t){const e=r.parent();return e?e._:void 0}const s=this._subgraphMap[t];if(!s)throw new Error(`Vertex parent '${s}' does not exist.`);return r.parent(s),this}edgeExists(e){return!!this._edgeMap[e]}edge(e){return this._edgeMap[e]._}addEdge(e,t){const r=this._idFunc(e),s=this._sourceFunc(e),n=this._targetFunc(e);if(this._edgeMap[r])throw new Error(`Edge '${r}' already exists.`);if(!this.vertexExists(s))throw new Error(`Edge Source '${s}' does not exist.`);if(!this.vertexExists(n))throw new Error(`Edge Target '${n}' does not exist.`);const i=new z(this,e,this._vertexMap[s],this._vertexMap[n]);if(t){const e=this._idFunc(t);if(!this.subgraphExists(e))throw new Error(`Subgraph '${e}' does not exist.`);i.parent(this._subgraphMap[e])}return this._edgeMap[r]=i,this._vertexMap[s].addOutEdge(i),this._vertexMap[n].addInEdge(i),this}mergeEdges(e){const t=c(this.allEdges(),e,e=>this._idFunc(e),this._updateFunc);return t.exit.forEach(e=>this.removeEdge(this._idFunc(e))),t.enter.forEach(e=>this.addEdge(e)),t.update.forEach(e=>this.updateEdge(e)),this}updateEdge(e){const t=this._idFunc(e),r=this._edgeMap[t];if(!r)throw new Error(`Edge '${t}' does not exist.`);const s=r._source.id(),n=this._sourceFunc(e);s!==n&&(this._vertexMap[s]?.removeOutEdge(t),this._vertexMap[n]?.addOutEdge(r));const i=r._target.id(),o=this._targetFunc(e);return i!==o&&(this._vertexMap[i]?.removeInEdge(t),this._vertexMap[o]?.addInEdge(r)),r._=e,r._source=this._vertexMap[n],r._target=this._vertexMap[o],this}removeEdge(e){const t=this._edgeMap[e];if(!t)throw new Error(`Edge '${e}' does not exist.`);const r=this._idFunc(t._source._);if(!this.vertexExists(r))throw new Error(`Edge Source'${r}' does not exist.`);this._vertexMap[r].removeOutEdge(e);const s=this._idFunc(t._target._);if(!this.vertexExists(s))throw new Error(`Edge Target'${s}' does not exist.`);return this._vertexMap[s].removeInEdge(e),delete this._edgeMap[e],this}_hwalk(e,t){return e instanceof G?t("subgraph",e._,e.children().map(e=>this._hwalk(e,t))):t("vertex",e._)}hierarchy(e){const t=[];for(const r in this._subgraphMap){const s=this._subgraphMap[r];void 0===s.parent()&&t.push(this._hwalk(s,e))}for(const r in this._vertexMap){const s=this._vertexMap[r];void 0===s.parent()&&t.push(this._hwalk(s,e))}return t}dijkstra(e,t){const r=this.allEdges(),s=new Q,n={},i={},a={};function h(e,t){let r=1/0,s=null;return e.forEach(e=>{t[e]<r&&(r=t[e],s=e)}),s}o(h,"vertex_with_min_dist");for(let o=0;o<r.length;o++){const e=this._sourceFunc(r[o]),t=this._targetFunc(r[o]),n=1;s.add(e),s.add(t),i[e]=1/0,i[t]=1/0,void 0===a[e]&&(a[e]={}),void 0===a[t]&&(a[t]={}),a[e][t]=n,a[t][e]=n}for(i[e]=0;s.size;){const e=h(s,i);if(null===e)break;const r=Object.keys(a[e]).filter(e=>s.has(e));if(s.delete(e),e===t)break;for(const t of r){const r=i[e]+a[e][t];r<i[t]&&(i[t]=r,n[t]=e)}}let c=t;const u=[c];let d=0;for(;void 0!==n[c];)u.unshift(n[c]),d+=a[c][n[c]],c=n[c];return{ids:u,len:d}}sort(e){const t=[],r={},s=o((e,n=[])=>{const i=e.id();r[i]||(r[i]=!0,n.push(e),e.outEdges().forEach(e=>{n.indexOf(e._target)<0&&s(e._target,[...n])}),t.unshift(e._))},"visit");if(e)s(this._vertexMap[e]);else for(const n in this._vertexMap)s(this._vertexMap[n]);return t}};o(U,"Graph2");let W=U;const J=class _Set{_content=[];get size(){return this._content.length}has(e){return this._content.indexOf(e)>=0}add(e){this.has(e)||this._content.push(e)}delete(e){const t=this._content.indexOf(e);t>=0&&this._content.splice(t,1)}forEach(e){this._content.forEach(e)}};o(J,"Set");let Q=J;const K=Array.isArray,Y=Object.keys,Z=Object.prototype.hasOwnProperty;function ee(e,t,r=!1){if(e===t)return!0;if(e&&t){if("object"==typeof e&&"object"==typeof t){const s=K(e),n=K(t);let i,o,a;if(s&&n){if(o=e.length,o!==t.length)return console.warn(`lengths not equal: ${o} !== ${t.length}`),!1;for(i=o;0!==i--;)if(!ee(e[i],t[i],r))return!1;return!0}if(s!==n)return console.warn(`arrays not equal: ${s} !== ${n}`),!1;const h=e instanceof Date,c=t instanceof Date;if(h!==c)return console.warn(`dates not equal: ${h} !== ${c}`),!1;if(h&&c){const r=e.getTime()===t.getTime();return r||console.warn(`dates not equal: ${e.getTime()} !== ${t.getTime()}`),r}const u=e instanceof RegExp,d=t instanceof RegExp;if(u!==d)return console.warn(`regexps not equal: ${u} !== ${d}`),!1;if(u&&d){const r=e.toString()===t.toString();return r||console.warn(`regexps not equal: ${e.toString()} !== ${t.toString()}`),r}const l=Y(e);if(o=l.length,o!==Y(t).length)return console.warn(`key lengths not equal: ${o} !== ${Y(t).length}`),!1;for(i=o;0!==i--;)if(!Z.call(t,l[i]))return console.warn(`${l[i]} in a but not b`),!1;for(i=o;0!==i--;)if(a=l[i],!ee(e[a],t[a],r))return!1;return!0}if(!r&&"function"==typeof e&&"function"==typeof t){const r=e.toString()===t.toString();return r||console.warn(`functions not equal: ${e.toString()} !== ${t.toString()}`),r}}const s=e!=e&&t!=t;return s||console.warn(`values not equal: ${e} !== ${t}`),s}function te(e,t,r=!1){if(e===t)return!0;if(e&&t){if("object"==typeof e&&"object"==typeof t){const s=K(e),n=K(t);let i,o,a;if(s&&n){if(o=e.length,o!==t.length)return!1;for(i=o;0!==i--;)if(!te(e[i],t[i],r))return!1;return!0}if(s!==n)return!1;const h=e instanceof Date,c=t instanceof Date;if(h!==c)return!1;if(h&&c)return e.getTime()===t.getTime();const u=e instanceof RegExp,d=t instanceof RegExp;if(u!==d)return!1;if(u&&d)return e.toString()===t.toString();const l=Y(e);if(o=l.length,o!==Y(t).length)return!1;for(i=o;0!==i--;)if(!Z.call(t,l[i]))return!1;for(i=o;0!==i--;)if(a=l[i],!te(e[a],t[a],r))return!1;return!0}if(!r&&"function"==typeof e&&"function"==typeof t)return e.toString()===t.toString()}return e!=e&&t!=t}function re(e,t,r=!1){return te(e,t,r)?e:t}o(ee,"verboseDeepEquals"),o(te,"deepEquals"),o(re,"update");const se="undefined"!=typeof globalThis?globalThis:window,ne="undefined"!=typeof window&&se===window,ie="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,oe=ie&&null!=process.env&&(null!=process.env.TRAVIS||null!=process.env.GITHUB_ACTIONS||null!=process.env.CI);function ae(e){const t=document.scripts||[];for(let r=document.scripts.length-1;r>=0;--r){const s=t[r];if(s.src){const t=s.src.indexOf(e);if(t>=0)return s.src.substring(0,t)}}return""}o(ae,"getScriptSrc");const he=class _Stack{stack=[];push(e){return this.stack.push(e),e}pop(){return this.stack.pop()}top(){return this.stack.length?this.stack[this.stack.length-1]:void 0}depth(){return this.stack.length}};o(he,"Stack");let ce=he;var ue=(e=>(e[e.debug=0]="debug",e[e.info=1]="info",e[e.notice=2]="notice",e[e.warning=3]="warning",e[e.error=4]="error",e[e.critical=5]="critical",e[e.alert=6]="alert",e[e.emergency=7]="emergency",e))(ue||{});const de={debug:"cyan",info:"green",notice:"grey",warning:"blue",error:"red",critical:"magenta",alert:"magenta",emergency:"magenta"},le=class _ConsoleWriter{write(e,t,r,s){ie?console.log(`[${e}] ${ue[t].toUpperCase()} ${r}: ${s}`):console.log(`[${e}] %c${ue[t].toUpperCase()}%c ${r}: ${s}`,`color:${de[ue[t]]}`,"")}};o(le,"ConsoleWriter");let pe=le;const ge=class _Logging{_levelStack=new ce;_level=1;_filter="";_writer=new pe;static Instance(){return this._instance||(this._instance=new this)}constructor(){}stringify(e){const t=[];return JSON.stringify(e,function(e,r){if("object"==typeof r&&null!==r){if(-1!==t.indexOf(r))return;t.push(r)}return r},2)}writer(e){return void 0===e?this._writer:(this._writer=e,this)}log(e,t,r){if(e<this._level)return;if(this._filter&&this._filter!==t)return;const s=(new Date).toISOString();this._writer.rawWrite?this._writer.rawWrite(s,e,t,r):("string"!=typeof r&&(r=this.stringify(r)),this._writer.write&&this._writer.write(s,e,t,r))}debug(e,t){this.log(0,e,t)}info(e,t){this.log(1,e,t)}notice(e,t){this.log(2,e,t)}warning(e,t){this.log(3,e,t)}error(e,t){this.log(4,e,t)}critical(e,t){this.log(5,e,t)}alert(e,t){this.log(6,e,t)}emergency(e,t){this.log(7,e,t)}level(e){return void 0===e?this._level:(this._level=e,this)}pushLevel(e){return this._levelStack.push(this._level),this._level=e,this}popLevel(){return this._level=this._levelStack.pop(),this}filter(e){return void 0===e?this._filter:(this._filter=e,this)}};var fe,_e;o(ge,"Logging"),((e,t,r)=>{t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(ge,"symbol"!=typeof(fe="_instance")?fe+"":fe,_e);let ve=ge;const be=ve.Instance(),Ee=class _ScopedLogging{_scopeID;constructor(e){this._scopeID=e}debug(e){be.debug(this._scopeID,e)}info(e){be.info(this._scopeID,e)}notice(e){be.notice(this._scopeID,e)}warning(e){be.warning(this._scopeID,e)}error(e){be.error(this._scopeID,e)}critical(e){be.critical(this._scopeID,e)}alert(e){be.alert(this._scopeID,e)}emergency(e){be.emergency(this._scopeID,e)}pushLevel(e){return be.pushLevel(e),this}popLevel(){return be.popLevel(),this}};o(Ee,"ScopedLogging");let xe=Ee;function me(e,t=!1){return t&&be.filter(e),new xe(e)}function we(e){return e*(Math.PI/180)}function Me(e){return e*(180/Math.PI)}function Se(e,t){return{x:e*Math.cos(t),y:e*Math.sin(t)}}function ye(e,t){return{r:Math.sqrt(e*e+t*t),theta:Math.atan2(t,e)}}function Oe(e,t=-Math.PI,r=Math.PI){return Ie(e,t,r)}function Ve(e,t=-180,r=180){return Ie(e,t,r)}function Ie(e,t,r){const s=r-t,n=e-t;return n-Math.floor(n/s)*s+t}function De(e,t){if(void 0!==e&&void 0!==t){for(const r of e.split(".")){if(!t.hasOwnProperty(r))return;t=t[r]}return t}}function Te(e,t){return void 0!==De(e,t)}function ke(e,t){const r={};for(const s in t){if(!t.hasOwnProperty(s))continue;if("__proto__"===s||"constructor"===s)continue;let n=t[s];n instanceof Array||"object"==typeof n&&(n=Fe(e[s],n)),s in e&&(e[s]===n||s in r&&r[s]===n)||(e[s]=n)}return e}function Fe(e={},...t){if("object"!=typeof e)throw new Error(`Destination "${e}" must be an object.`);for(const r of t)ke(e,r);return e}function Ce(e={},...t){return Fe(e,...t)}function $e(e){const t=[];return JSON.stringify(e,function(e,r){if("object"==typeof r&&null!==r){if(-1!==t.indexOf(r))return;t.push(r)}return r})}function Le(e){return void 0!==Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}function Ae(e){const t=e.split("_"),r=t[1].split(".");return{module:`@hpcc-js/${t[0]}`,file:r[0],class:r[1]||r[0]}}o(me,"scopedLogger"),o(we,"degreesToRadians"),o(Me,"radiansToDegrees"),o(Se,"polarToCartesian"),o(ye,"cartesianToPolar"),o(Oe,"normalizeRadians"),o(Ve,"normalizeDegrees"),o(Ie,"normalize"),o(De,"inner"),o(Te,"exists"),o(ke,"_mixin"),o(Fe,"deepMixin"),o(Ce,"deepMixinT"),o($e,"safeStringify"),o(Le,"isArray"),o(Ae,"classID2Meta");const Ne=class _ObserverHandle{eventTarget;eventID;callback;constructor(e,t,r){this.eventTarget=e,this.eventID=t,this.callback=r}release(){this.eventTarget.removeObserver(this.eventID,this.callback)}unwatch(){this.release()}};o(Ne,"ObserverHandle");let Pe=Ne;const je=class _Observable{_eventObservers={};constructor(...e){}addObserver(e,t){let r=this._eventObservers[e];return r||(r=[],this._eventObservers[e]=r),r.push(t),new Pe(this,e,t)}removeObserver(e,t){const r=this._eventObservers[e];if(r)for(let s=r.length-1;s>=0;--s)r[s]===t&&r.splice(s,1);return this}dispatchEvent(e,...t){const r=this._eventObservers[e];if(r)for(const s of r)s(...t);return this}_hasObserver(e){const t=this._eventObservers[e];for(const r in t)if(t[r])return!0;return!1}hasObserver(e){if(void 0!==e)return this._hasObserver(e);for(const t in this._eventObservers)if(this._hasObserver(t))return!0;return!1}};o(je,"Observable");let qe,Xe=je;!function(){if(se.requestAnimationFrame)qe=se.requestAnimationFrame;else{let e=0;qe=o(function(t){const r=(new Date).getTime(),s=Math.max(0,16-(r-e)),n=setTimeout(()=>t(r+s),s);return e=r+s,n},"requestAnimationFrame")}}();const Ge=class _Message{get canConflate(){return!1}conflate(e){return!1}void(){return!1}};o(Ge,"Message");let Be=Ge;const Re=class _Dispatch{_observerID=0;_observers=[];_messageBuffer=[];_rafHandle=void 0;constructor(){}observers(){return this._observers}messages(){const e=[];return this._messageBuffer.forEach(t=>{e.some(e=>e.canConflate&&e.conflate(t))||e.push(t)}),e}dispatchAll(){this._rafHandle=void 0,this.dispatch(this.messages()),this.flush()}dispatch(e){0!==e.length&&this.observers().forEach(t=>{const r=e.filter(e=>!e.void()&&(void 0===t.type||e instanceof t.type));r.length&&t.callback(r)})}hasObserver(){return this._observers.length>0}flush(){this._messageBuffer=[]}send(e){this.hasObserver()&&this.dispatch([e])}post(e){this.hasObserver()&&(this._messageBuffer.push(e),void 0===this._rafHandle&&(this._rafHandle=qe(()=>this.dispatchAll())))}attach(e,t){const r=this,s=++this._observerID;return this._observers.push({id:s,type:t,callback:e}),{release(){r._observers=r._observers.filter(e=>e.id!==s)},unwatch(){this.release()}}}};o(Re,"Dispatch");let He=Re;const ze=class _XMLNode{name="";$={};_children=[];content="";constructor(e){this.name=e}appendAttribute(e,t){this.$[e]=t}appendContent(e){this.content+=e}appendChild(e){this._children.push(e)}children(e){return void 0===e?this._children:this._children.filter(t=>t.name===e)}};o(ze,"XMLNode");let Ue=ze;const We=class _SAXStackParser{root;stack=new ce;constructor(){}walkDoc(e){const t=this._startXMLNode(e);if(e.attributes)for(let r=0;r<e.attributes.length;++r){const t=e.attributes.item(r);this.attributes(t.nodeName,t.nodeValue)}if(this.startXMLNode(t),e.childNodes)for(let r=0;r<e.childNodes.length;++r){const t=e.childNodes.item(r);t.nodeType===t.TEXT_NODE?this.characters(t.nodeValue):this.walkDoc(t)}this.endXMLNode(this.stack.pop())}_startXMLNode(e){const t=new Ue(e.nodeName);return this.stack.depth()?this.stack.top().appendChild(t):this.root=t,this.stack.push(t)}parse(e){const t=(new DOMParser).parseFromString(e,"application/xml");this.startDocument(),this.walkDoc(t),this.endDocument()}startDocument(){}endDocument(){}startXMLNode(e){}endXMLNode(e){}attributes(e,t){this.stack.top().appendAttribute(e,t)}characters(e){this.stack.top().appendContent(e)}};o(We,"SAXStackParser");let Je=We;const Qe=class _XML2JSONParser extends Je{startXMLNode(e){super.startXMLNode(e),e.name}endXMLNode(e){e.name,super.endXMLNode(e)}};o(Qe,"XML2JSONParser");let Ke=Qe;function Ye(e){const t=new Ke;return t.parse(e),t.root}o(Ye,"xml2json");const Ze=class _PropChangedMessage extends Be{constructor(e,t,r){super(),this.property=e,this.newValue=t,this.oldValue=r}get canConflate(){return!0}conflate(e){return this.property===e.property&&(this.newValue=e.newValue,!0)}void(){return te(this.newValue,this.oldValue)}};o(Ze,"PropChangedMessage");let et=Ze;const tt=class _StateObject{_espState={};_dispatch=new He;_monitorHandle;_monitorTickCount=0;clear(e){this._espState={},void 0!==e&&this.set(e),this._monitorTickCount=0}get(e,t){return void 0===e?this._espState:this.has(e)?this._espState[e]:t}set(e,t){if("string"==typeof e)return this.setSingle(e,t);this.setAll(e)}setSingle(e,t){const r=this._espState[e];this._espState[e]=t,this._dispatch.post(new et(e,t,r))}setAll(e){for(const t in e)e.hasOwnProperty(t)&&this.setSingle(t,e[t])}has(e){return void 0!==this._espState[e]}addObserver(e,t,r){if(this.isCallback(t)){if("changed"!==e)throw new Error("Invalid eventID: "+e);return this._dispatch.attach(e=>{t(e.map(e=>({id:e.property,oldValue:e.oldValue,newValue:e.newValue})))})}if("propChanged"!==e)throw new Error("Invalid eventID: "+e);return this._dispatch.attach(e=>{const s=e.filter(e=>e.property===t);if(s.length){s.length>1&&console.warn("Should only be 1 message?");const e=s[s.length-1];r({id:e.property,oldValue:e.oldValue,newValue:e.newValue})}})}on(e,t,r){return this.addObserver(e,t,r),this}isCallback(e){return"function"==typeof e}hasEventListener(){return this._dispatch.hasObserver()}async refresh(e=!1){return await Promise.resolve(),this}_monitor(){this._monitorHandle?this._monitorTickCount=0:this._monitorHandle=setTimeout(()=>{(this.hasEventListener()?this.refresh():Promise.resolve()).then(()=>{this._monitor()}),delete this._monitorHandle},this._monitorTimeoutDuration())}_monitorTimeoutDuration(){return++this._monitorTickCount,this._monitorTickCount<=1?0:3e4}watch(e,t=!0){if("function"!=typeof e)throw new Error("Invalid Callback");t&&setTimeout(()=>{const t=this.get(),r=[];for(const e in t)t.hasOwnProperty(t)&&r.push({id:e,newValue:t[e],oldValue:void 0});e(r)},0);const r=this.addObserver("changed",e);return this._monitor(),r}};o(tt,"StateObject");let rt=tt;function st(e,t){if("string"!=typeof t)return e;if(0===t.length)return e;for(;0===e.indexOf(t);)e=e.substring(1);for(;nt(e,t);)e=e.substring(0,e.length-1);return e}function nt(e,t,r){const s=e.toString();("number"!=typeof r||!isFinite(r)||Math.floor(r)!==r||r>s.length)&&(r=s.length),r-=t.length;const n=s.lastIndexOf(t,r);return-1!==n&&n===r}function it(...e){const t=e.reduce((e,t)=>(e.length>0&&(t=t.replace(/^\//,"")),t=t.replace(/\/$/,""),[...e,...t.split("/")]),[]),r=[];for(const s of t)"."!==s&&(".."!==s?r.push(s):r.pop());return r.join("/")}function ot(e){return it(e,"..")}o(st,"trim"),o(nt,"endsWith"),o(it,"join"),o(ot,"dirname");const at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function ht(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);const t=encodeURIComponent(e),r=[];for(let s=0;s<t.length;++s)"%"===t[s]?(r.push(parseInt(t.substring(s+1,s+3),16)),s+=2):r.push(t.charCodeAt(s));return Uint8Array.from(r)}function ct(e){let t="";for(let r=0;r<e.length;r+=3){const s=e[r],n=r+1<e.length,i=r+2<e.length,o=n?e[r+1]:0,a=i?e[r+2]:0;t+=at[s>>2],t+=at[(3&s)<<4|o>>4],t+=n?at[(15&o)<<2|a>>6]:"=",t+=i?at[63&a]:"="}return t}function ut(e=""){const t=null==e?"":String(e),r=globalThis?.Buffer;return r?.from?r.from(t,"utf8").toString("base64"):ct(ht(t))}o(ht,"toUTF8Bytes"),o(ct,"bytesToBase64"),o(ut,"utf8ToBase64"),e.AsyncCache=E,e.AsyncOrderedQueue=M,e.BUILD_VERSION="3.21.3",e.Cache=v,e.Dictionary=O,e.DictionaryNoCase=I,e.Dispatch=He,e.Edge=C,e.Graph=L,e.Graph2=W,e.GraphItem=T,e.Level=ue,e.Logging=ve,e.Message=Be,e.Observable=Xe,e.PKG_NAME="@hpcc-js/util",e.PKG_VERSION="3.5.2",e.SAXStackParser=Je,e.ScopedLogging=xe,e.Stack=ce,e.StateObject=rt,e.Subgraph=k,e.Vertex=F,e.XMLNode=Ue,e.cartesianToPolar=ye,e.classID2Meta=Ae,e.compare=h,e.compare2=c,e.debounce=x,e.deepEquals=te,e.deepMixin=Fe,e.deepMixinT=Ce,e.degreesToRadians=we,e.dirname=ot,e.endsWith=nt,e.espTime2Seconds=D,e.exists=Te,e.find=a,e.getScriptSrc=ae,e.hashSum=f,e.inner=De,e.isArray=Le,e.isBrowser=ne,e.isCI=oe,e.isNode=ie,e.join=it,e.logger=be,e.normalize=Ie,e.normalizeDegrees=Ve,e.normalizeRadians=Oe,e.polarToCartesian=Se,e.promiseTimeout=m,e.radiansToDegrees=Me,e.root=se,e.safeStringify=$e,e.scopedLogger=me,e.sleep=S,e.trim=st,e.update=re,e.utf8ToBase64=ut,e.verboseDeepEquals=ee,e.xml2json=Ye,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@hpcc-js/util"]={})}(this,function(e){"use strict";var t,r,s,n,i=Object.defineProperty,o=(e,t)=>i(e,"name",{value:t,configurable:!0});function a(e,t){if(null==e)throw new TypeError('"o" is null or not defined');const r=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");const s=arguments[1];let n=0;for(;n<r;){const r=e[n];if(t.call(s,r,n))return r;n++}}function h(e,t){const r={update:[],exit:[],enter:[...t]};for(const s of e){const e=r.enter.indexOf(s);e>=0?(r.update.push(s),r.enter.splice(e,1)):r.exit.push(s)}return r}function c(e,t,r,s=(e,t)=>t){const n={update:[],exit:[],enter:[]};if(e===t)return n.update=e,n;const i={};t.forEach(e=>{i[r(e)]=e});for(const o of e){const e=r(o),t=i[e];void 0!==t?(delete i[e],n.update.push(s(o,t))):n.exit.push(o)}for(const o in i)n.enter.push(i[o]);return n}function u(e,t){for(;e.length<t;)e="0"+e;return e}function d(e,t){if(0===t.length)return e;for(let r=0;r<t.length;++r){e=(e<<5)-e+t.charCodeAt(r),e|=0}return e<0?-2*e:e}function l(e,t,r){return"function"==typeof t.hashSum?t.hashSum():Object.keys(t).sort().reduce((e,s)=>p(e,t[s],s,r),e)}function p(e,t,r,s){const n=d(d(d(e,r),g(t)),typeof t);return null===t?d(n,"null"):void 0===t?d(n,"undefined"):"object"==typeof t?-1!==s.indexOf(t)?d(n,"[Circular]"+r):(s.push(t),l(n,t,s)):d(n,t.toString())}function g(e){return Object.prototype.toString.call(e)}function f(e){return u(p(0,e,"",[]).toString(16),8)}o(a,"find"),o(h,"compare"),o(c,"compare2"),o(u,"pad"),o(d,"fold"),o(l,"foldObject"),o(p,"foldValue"),o(g,"toString"),o(f,"hashSum");const _=class _Cache{_cache={};_calcID;static hash(...e){return f({...e})}constructor(e){this._calcID=e}has(e){return this._calcID(e)in this._cache}set(e){return this._cache[this._calcID(e)]=e,e}get(e,t){const r=this._cache[this._calcID(e)];return r||(t?this.set(t()):null)}};o(_,"Cache");let v=_;const b=class _AsyncCache{_cache={};_calcID;static hash(...e){return f({...e})}constructor(e){this._calcID=e}has(e){return this._calcID(e)in this._cache}set(e,t){return this._cache[this._calcID(e)]=t,t}get(e,t){const r=this._cache[this._calcID(e)];return r||(t?this.set(e,t()):Promise.resolve(null))}};o(b,"AsyncCache");let E=b;function x(e,t){const r={};return(...s)=>{const n=f(s);return r[n]||(r[n]={clockStart:Date.now(),promise:e(...s).then(e=>(void 0===t?r[n]=null:setTimeout(()=>{r[n]=null},Math.max(t-(Date.now()-r[n].clockStart),0)),e)).catch(e=>{throw r[n]=null,e})}),r[n].promise}}function m(e,t){let r;const s=new Promise((t,s)=>{r=setTimeout(()=>{clearTimeout(r),s("Timed out in "+e+"ms.")},e)});return Promise.race([t,s]).then(e=>(clearTimeout(r),e)).catch(e=>{throw clearTimeout(r),e})}o(x,"debounce"),o(m,"promiseTimeout");const w=class _AsyncOrderedQueue{_q=[];isTop(e){return this._q[0]===e}push(e){const t=e.then(e=>this.isTop(t)?(this._q.shift(),e):new Promise((r,s)=>{const n=setInterval(()=>{this.isTop(t)&&(clearInterval(n),this._q.shift(),r(e))},20)}));return this._q.push(t),t}};o(w,"AsyncOrderedQueue");let M=w;function S(e){return new Promise(t=>{setTimeout(()=>t(),e)})}o(S,"sleep");const y=class _Dictionary{store={};constructor(e){if(e)for(const t in e)this.set(t,e[t])}set(e,t){const r=this.store[e];return this.store[e]=t,r}get(e){return this.store[e]}has(e){return void 0!==this.store[e]}remove(e){delete this.store[e]}keys(){const e=[];for(const t in this.store)e.push(t);return e}values(){const e=[];for(const t in this.store)e.push(this.store[t]);return e}};o(y,"Dictionary");let O=y;const V=class _DictionaryNoCase extends O{constructor(e){super(e)}set(e,t){return super.set(e.toLowerCase(),t)}get(e){return super.get(e.toLowerCase())}has(e){return super.has(e.toLowerCase())}remove(e){return super.remove(e.toLowerCase())}};o(V,"DictionaryNoCase");let I=V;function D(e){if(!e)return 0;if(!isNaN(Number(e)))return Number(e);const t=e.indexOf("ns");if(-1!==t)return parseFloat(e.substr(0,t))/1e9;const r=e.indexOf("ms");if(-1!==r)return parseFloat(e.substr(0,r))/1e3;const s=e.indexOf("s");if(-1!==s&&-1===e.indexOf("days"))return parseFloat(e.substr(0,s));const n=e.split(" days "),i=n.length>1?parseFloat(n[0]):0;let o=0;const a=(n.length>1?n[1]:n[0]).split(":").reverse();for(let h=0;h<a.length;++h)o+=parseFloat(a[h])*Math.pow(60,h);return 24*i*60*60+o}o(D,"espTime2Seconds");let T=(o(t=class{_graph;parent;props={};constructor(e,t){this._graph=e,this.parent=t}},"GraphItem"),t),k=(o(r=class extends T{subgraphs=[];vertices=[];edges=[];_;constructor(e,t,r){super(e,t),t&&t._addSubgraph(this),this._=r}remove(e=!0){this._graph.removeSubgraph(this,e)}createSubgraph(e){return this._graph.createSubgraph(this,e)}_addSubgraph(e){if(this.subgraphs.indexOf(e)>=0)throw new Error("Subgraph already exists");this.subgraphs.push(e)}_removeSubgraph(e){const t=this.subgraphs.indexOf(e);if(t<0)throw new Error("Subgraph does not exist");this.subgraphs.splice(t,1)}removeAllSubgraphs(){for(let e=this.subgraphs.length-1;e>=0;--e)this._graph.removeSubgraph(this.subgraphs[e],!0)}createVertex(e){return this._graph.createVertex(this,e)}_addVertex(e){if(this.vertices.indexOf(e)>=0)throw new Error("Vertex already exists");this.vertices.push(e)}_removeVertex(e){const t=this.vertices.indexOf(e);if(t<0)throw new Error("Vertex does not exist");this.vertices.splice(t,1)}removeAllVertices(){for(let e=this.vertices.length-1;e>=0;--e)this._graph.removeVertex(this.vertices[e],!0)}createEdge(e,t,r){return this._graph.createEdge(this,e,t,r)}_addEdge(e){if(this.edges.indexOf(e)>=0)throw new Error("Edge already exists");this.edges.push(e)}_removeEdge(e){const t=this.edges.indexOf(e);if(t<0)throw new Error("Edge does not exist");this.edges.splice(t,1)}_add(e){e instanceof r?this._addSubgraph(e):e instanceof F?this._addVertex(e):this._addEdge(e)}},"Subgraph"),r),F=(o(s=class extends T{inEdges=[];outEdges=[];get edges(){return[...this.inEdges,...this.outEdges]}_;constructor(e,t,r){super(e,t),t._addVertex(this),this._=r}remove(e=!0,t){return this._graph.removeVertex(this,e,t)}addInEdge(e){this.inEdges.push(e)}removeInEdge(e){const t=this.inEdges.indexOf(e);if(t<0)throw new Error("In edge does not exist");this.inEdges.splice(t,1)}addOutEdge(e){this.outEdges.push(e)}removeOutEdge(e){const t=this.outEdges.indexOf(e);if(t<0)throw new Error("Out edge does not exist");this.outEdges.splice(t,1)}},"Vertex"),s),C=(o(n=class extends T{source;target;_;constructor(e,t,r,s,n){if(super(e,t),!r)throw new Error("Missing source vertex");if(!s)throw new Error("Missing target vertex");t._addEdge(this),this.source=r,this.source.addOutEdge(this),this.target=s,this.target.addInEdge(this),this._=n}remove(){this._graph.removeEdge(this)}},"Edge"),n);const $=class _Graph{root;_allSubgraphs=[];_allSubgraphsMap={};_allVertices=[];_allVerticesMap={};_allEdges=[];_allEdgesMap={};idOf;constructor(e=e=>""+e._,t){this.root=new k(this,null,t),this.idOf=e}createSubgraph(e,t){const r=new k(this,e||this.root,t);return this._allSubgraphs.push(r),this._allSubgraphsMap[this.idOf(r)]=r,r}removeSubgraph(e,t=!0){const r=this._allSubgraphs.indexOf(e);if(r<0)throw new Error("Subgraph does not exist");this._allSubgraphs.splice(r,1),delete this._allSubgraphsMap[this.idOf(e)],e.parent&&e.parent._removeSubgraph(e),e.edges.forEach(r=>t?this.removeEdge(r):e.parent._addEdge(r)),e.vertices.forEach(r=>t?this.removeVertex(r,t):e.parent._addVertex(r)),e.subgraphs.forEach(r=>t?this.removeSubgraph(r,t):e.parent._addSubgraph(r))}get subgraphs(){return this._allSubgraphs}subgraph(e){return this._allSubgraphsMap[e]}createVertex(e,t){const r=new F(this,e,t);return this._allVertices.push(r),this._allVerticesMap[this.idOf(r)]=r,r}removeVertex(e,t=!0,r){const s=this._allVertices.indexOf(e);if(s<0)throw new Error("Vertex does not exist");this._allVertices.splice(s,1),delete this._allVerticesMap[this.idOf(e)],e.parent&&e.parent._removeVertex(e),t||e.inEdges.forEach(t=>{e.outEdges.forEach(e=>{this.createEdge(this.root,t.source,e.target,r?r(t.source._,e.target._):void 0)})}),e.inEdges.forEach(e=>this.removeEdge(e)),e.outEdges.forEach(e=>this.removeEdge(e))}get vertices(){return this._allVertices}vertex(e){return this._allVerticesMap[e]}createEdge(e,t,r,s){const n=new C(this,e,t,r,s);return this._allEdges.push(n),this._allEdgesMap[this.idOf(n)]=n,n}removeEdge(e){const t=this._allEdges.indexOf(e);if(t<0)throw new Error("Edge does not exist");this._allEdges.splice(t,1),delete this._allEdgesMap[this.idOf(e)],e.parent&&e.parent._removeEdge(e),e.source.removeOutEdge(e),e.target.removeInEdge(e)}get edges(){return this._allEdges}edge(e){return this._allEdgesMap[e]}_walk(e,t){for(const r of e.subgraphs)switch(t(r)){case"abort":return!0;case"stepover":break;default:if(this._walk(r,t))return!0}for(const r of e.vertices)if("abort"===t(r))return!0}walk(e){this._walk(this.root,e);for(const t of this._allEdges)if("abort"===e(t))return!0}clone(){const e=new(0,this.constructor)(this.idOf,this.root._),t=A();return t.put(this.root,e.root),this.walk(e=>{const r=t.get(e.parent);if(e instanceof k)t.put(e,r.createSubgraph(e._));else if(e instanceof F)t.put(e,r.createVertex(e._));else if(e instanceof C){const s=t.get(e.source),n=t.get(e.target);r.createEdge(s,n,e._)}}),e}};o($,"Graph");let L=$;function A(){const e=[],t=[];return{put(r,s){const n=e.indexOf(r);-1===n?(e.push(r),t.push(s)):t[n]=s},get:r=>t[e.indexOf(r)]}}o(A,"ObjMap");const N=class _GraphItem{_graph;_;id(){return this._graph.id(this._)}constructor(e,t){this._graph=e,this._=t}};o(N,"GraphItem");let P=N;const j=class _ChildGraphItem extends P{_parent;constructor(e,t){super(e,t)}clearParent(){return this._parent&&(this._parent.removeChild(this),delete this._parent),this}parent(e){return 0===arguments.length?this._parent:(this._parent!==e&&(this._parent&&this._parent.removeChild(this),this._parent=e,this._parent&&this._parent.addChild(this)),this)}};o(j,"ChildGraphItem");let q=j;const X=class _Subgraph extends q{_children=[];constructor(e,t){super(e,t)}children(){return this._children}addChild(e){this._children.push(e)}removeChild(e){this._children=this._children.filter(t=>t.id!==e.id)}};o(X,"Subgraph");let G=X;const B=class _Vertex extends q{_inEdges=[];_outEdges=[];constructor(e,t){super(e,t)}edges(){return[...this._inEdges,...this._outEdges]}edgeCount(){return this._outEdges.length+this._inEdges.length}inEdges(){return this._inEdges}addInEdge(e){this._inEdges.push(e)}removeInEdge(e){this._inEdges=this._inEdges.filter(t=>t._.id!==e)}outEdges(){return this._outEdges}addOutEdge(e){this._outEdges.push(e)}removeOutEdge(e){this._outEdges=this._outEdges.filter(t=>t._.id!==e)}};o(B,"Vertex");let R=B;const H=class _Edge extends q{_source;_target;constructor(e,t,r,s){super(e,t),this._source=r,this._target=s}};o(H,"Edge");let z=H;const U=class _Graph2{_directed;_subgraphMap={};_vertexMap={};_edgeMap={};constructor(e=!0){this._directed=e}clear(){return this._subgraphMap={},this._vertexMap={},this._edgeMap={},this}clearParents(){for(const e in this._subgraphMap)this._subgraphMap[e].clearParent();for(const e in this._vertexMap)this._vertexMap[e].clearParent();return this}isDirected(){return this._directed}_idFunc=o(e=>"function"==typeof e.id?e.id():e.id,"_idFunc");idFunc(e){return this._idFunc=e,this}_sourceFunc=o(e=>"function"==typeof e.source?e.source():e.source,"_sourceFunc");sourceFunc(e){return this._sourceFunc=e,this}_targetFunc=o(e=>"function"==typeof e.target?e.target():e.target,"_targetFunc");targetFunc(e){return this._targetFunc=e,this}_updateFunc=o((e,t)=>t,"_updateFunc");updateFunc(e){return this._updateFunc=e,this}id(e){return this._idFunc(e)}type(e){return this.subgraphExists(e)?"S":this.vertexExists(e)?"V":this.edgeExists(e)?"E":""}isSubgraph(e){return this.subgraphExists(this.id(e))}isVertex(e){return this.vertexExists(this.id(e))}isEdge(e){return this.edgeExists(this.id(e))}allItems(){return[...this.allSubgraphs(),...this.allVertices(),...this.allEdges()]}item(e){return this.subgraphExists(e)?this.subgraph(e):this.vertexExists(e)?this.vertex(e):this.edgeExists(e)?this.edge(e):void 0}itemExists(e){return this.edgeExists(e)||this.vertexExists(e)||this.subgraphExists(e)}allSubgraphs(){const e=[];for(const t in this._subgraphMap)e.push(this._subgraphMap[t]._);return e}subgraphs(){const e=[];for(const t in this._subgraphMap)void 0===this._subgraphMap[t].parent()&&e.push(this._subgraphMap[t]._);return e}subgraphExists(e){return!!this._subgraphMap[e]}subgraph(e){return this._subgraphMap[e]._}subgraphSubgraphs(e){return this._subgraphMap[e].children().filter(e=>this.isSubgraph(e._)).map(e=>e._)}subgraphVertices(e){return this._subgraphMap[e].children().filter(e=>this.isVertex(e._)).map(e=>e._)}subgraphEdges(e){return this._subgraphMap[e].children().filter(e=>this.isEdge(e._)).map(e=>e._)}addSubgraph(e,t){const r=this._idFunc(e);if(this._subgraphMap[r])throw new Error(`Subgraph '${r}' already exists.`);const s=new G(this,e);if(t){const e=this._idFunc(t);if(!this._subgraphMap[e])throw new Error(`Subgraph '${e}' does not exist.`);s.parent(this._subgraphMap[e])}return this._subgraphMap[r]=s,this}mergeSubgraphs(e=[]){const t=c(this.allSubgraphs(),e,e=>this._idFunc(e),this._updateFunc);return t.exit.forEach(e=>this.removeSubgraph(this._idFunc(e))),t.enter.forEach(e=>this.addSubgraph(e)),t.update.forEach(e=>this.updateSubgraph(e)),this}updateSubgraph(e){const t=this._idFunc(e),r=this._subgraphMap[t];if(!r)throw new Error(`Subgraph '${t}' does not exist.`);return r._=e,this}removeSubgraph(e,t=!0){const r=this._subgraphMap[e];if(!r)throw new Error(`Subgraph '${e}' does not exist.`);return r.children().forEach(e=>{t?e.parent(r.parent()):e instanceof G?this.removeSubgraph(e.id()):this.removeVertex(e.id())}),delete this._subgraphMap[e],this}subgraphParent(e,t){const r=this._subgraphMap[e];if(!r)throw new Error(`Subgraph '${e}' does not exist.`);if(void 0===t){const e=r.parent();return e?e._:void 0}const s=this._subgraphMap[t];if(!s)throw new Error(`Vertex parent '${s}' does not exist.`);return r.parent(s),this}allVertices(){const e=[];for(const t in this._vertexMap)e.push(this._vertexMap[t]._);return e}vertices(){const e=[];for(const t in this._vertexMap)void 0===this._vertexMap[t].parent()&&e.push(this._vertexMap[t]._);return e}vertexExists(e){return!!this._vertexMap[e]}vertex(e){return this._vertexMap[e]._}allEdges(){const e=[];for(const t in this._edgeMap)e.push(this._edgeMap[t]._);return e}edges(){const e=[];for(const t in this._edgeMap)void 0===this._edgeMap[t].parent()&&e.push(this._edgeMap[t]._);return e}vertexEdges(e){return this._vertexMap[e].edges().map(e=>e._)}inEdges(e){return this._vertexMap[e].inEdges().map(e=>e._)}outEdges(e){return this._vertexMap[e].outEdges().map(e=>e._)}_neighbors(e){return[...this._vertexMap[e].outEdges().map(e=>e._target),...this._vertexMap[e].inEdges().map(e=>e._source)]}neighbors(e){return this._neighbors(e).map(e=>e._)}singleNeighbors(e){return this._neighbors(e).filter(e=>1===e.edgeCount()).map(e=>e._)}addVertex(e,t){const r=this._idFunc(e);if(this._vertexMap[r])throw new Error(`Vertex '${r}' already exists.`);const s=new R(this,e);if(t){const e=this._idFunc(t);if(!this.subgraphExists(e))throw new Error(`Subgraph '${e}' does not exist.`);s.parent(this._subgraphMap[e])}return this._vertexMap[r]=s,this}mergeVertices(e){const t=c(this.allVertices(),e,e=>this._idFunc(e),this._updateFunc);return t.exit.forEach(e=>this.removeVertex(this._idFunc(e))),t.enter.forEach(e=>this.addVertex(e)),t.update.forEach(e=>this.updateVertex(e)),this}updateVertex(e){const t=this._idFunc(e),r=this._vertexMap[t];if(!r)throw new Error(`Vertex '${t}' does not exist.`);return r._=e,this}removeVertex(e){const t=this._vertexMap[e];if(!t)throw new Error(`Vertex '${e}' does not exist.`);return t.edges().forEach(e=>{this.removeEdge(e.id())}),delete this._vertexMap[e],this}vertexParent(e,t){const r=this._vertexMap[e];if(!r)throw new Error(`Vertex '${e}' does not exist.`);if(void 0===t){const e=r.parent();return e?e._:void 0}const s=this._subgraphMap[t];if(!s)throw new Error(`Vertex parent '${s}' does not exist.`);return r.parent(s),this}edgeExists(e){return!!this._edgeMap[e]}edge(e){return this._edgeMap[e]._}addEdge(e,t){const r=this._idFunc(e),s=this._sourceFunc(e),n=this._targetFunc(e);if(this._edgeMap[r])throw new Error(`Edge '${r}' already exists.`);if(!this.vertexExists(s))throw new Error(`Edge Source '${s}' does not exist.`);if(!this.vertexExists(n))throw new Error(`Edge Target '${n}' does not exist.`);const i=new z(this,e,this._vertexMap[s],this._vertexMap[n]);if(t){const e=this._idFunc(t);if(!this.subgraphExists(e))throw new Error(`Subgraph '${e}' does not exist.`);i.parent(this._subgraphMap[e])}return this._edgeMap[r]=i,this._vertexMap[s].addOutEdge(i),this._vertexMap[n].addInEdge(i),this}mergeEdges(e){const t=c(this.allEdges(),e,e=>this._idFunc(e),this._updateFunc);return t.exit.forEach(e=>this.removeEdge(this._idFunc(e))),t.enter.forEach(e=>this.addEdge(e)),t.update.forEach(e=>this.updateEdge(e)),this}updateEdge(e){const t=this._idFunc(e),r=this._edgeMap[t];if(!r)throw new Error(`Edge '${t}' does not exist.`);const s=r._source.id(),n=this._sourceFunc(e);s!==n&&(this._vertexMap[s]?.removeOutEdge(t),this._vertexMap[n]?.addOutEdge(r));const i=r._target.id(),o=this._targetFunc(e);return i!==o&&(this._vertexMap[i]?.removeInEdge(t),this._vertexMap[o]?.addInEdge(r)),r._=e,r._source=this._vertexMap[n],r._target=this._vertexMap[o],this}removeEdge(e){const t=this._edgeMap[e];if(!t)throw new Error(`Edge '${e}' does not exist.`);const r=this._idFunc(t._source._);if(!this.vertexExists(r))throw new Error(`Edge Source'${r}' does not exist.`);this._vertexMap[r].removeOutEdge(e);const s=this._idFunc(t._target._);if(!this.vertexExists(s))throw new Error(`Edge Target'${s}' does not exist.`);return this._vertexMap[s].removeInEdge(e),delete this._edgeMap[e],this}_hwalk(e,t){return e instanceof G?t("subgraph",e._,e.children().map(e=>this._hwalk(e,t))):t("vertex",e._)}hierarchy(e){const t=[];for(const r in this._subgraphMap){const s=this._subgraphMap[r];void 0===s.parent()&&t.push(this._hwalk(s,e))}for(const r in this._vertexMap){const s=this._vertexMap[r];void 0===s.parent()&&t.push(this._hwalk(s,e))}return t}dijkstra(e,t){const r=this.allEdges(),s=new Q,n={},i={},a={};function h(e,t){let r=1/0,s=null;return e.forEach(e=>{t[e]<r&&(r=t[e],s=e)}),s}o(h,"vertex_with_min_dist");for(let o=0;o<r.length;o++){const e=this._sourceFunc(r[o]),t=this._targetFunc(r[o]),n=1;s.add(e),s.add(t),i[e]=1/0,i[t]=1/0,void 0===a[e]&&(a[e]={}),void 0===a[t]&&(a[t]={}),a[e][t]=n,a[t][e]=n}for(i[e]=0;s.size;){const e=h(s,i);if(null===e)break;const r=Object.keys(a[e]).filter(e=>s.has(e));if(s.delete(e),e===t)break;for(const t of r){const r=i[e]+a[e][t];r<i[t]&&(i[t]=r,n[t]=e)}}let c=t;const u=[c];let d=0;for(;void 0!==n[c];)u.unshift(n[c]),d+=a[c][n[c]],c=n[c];return{ids:u,len:d}}sort(e){const t=[],r={},s=o((e,n=[])=>{const i=e.id();r[i]||(r[i]=!0,n.push(e),e.outEdges().forEach(e=>{n.indexOf(e._target)<0&&s(e._target,[...n])}),t.unshift(e._))},"visit");if(e)s(this._vertexMap[e]);else for(const n in this._vertexMap)s(this._vertexMap[n]);return t}};o(U,"Graph2");let W=U;const J=class _Set{_content=[];get size(){return this._content.length}has(e){return this._content.indexOf(e)>=0}add(e){this.has(e)||this._content.push(e)}delete(e){const t=this._content.indexOf(e);t>=0&&this._content.splice(t,1)}forEach(e){this._content.forEach(e)}};o(J,"Set");let Q=J;const K=Array.isArray,Y=Object.keys,Z=Object.prototype.hasOwnProperty;function ee(e,t,r=!1){if(e===t)return!0;if(e&&t){if("object"==typeof e&&"object"==typeof t){const s=K(e),n=K(t);let i,o,a;if(s&&n){if(o=e.length,o!==t.length)return console.warn(`lengths not equal: ${o} !== ${t.length}`),!1;for(i=o;0!==i--;)if(!ee(e[i],t[i],r))return!1;return!0}if(s!==n)return console.warn(`arrays not equal: ${s} !== ${n}`),!1;const h=e instanceof Date,c=t instanceof Date;if(h!==c)return console.warn(`dates not equal: ${h} !== ${c}`),!1;if(h&&c){const r=e.getTime()===t.getTime();return r||console.warn(`dates not equal: ${e.getTime()} !== ${t.getTime()}`),r}const u=e instanceof RegExp,d=t instanceof RegExp;if(u!==d)return console.warn(`regexps not equal: ${u} !== ${d}`),!1;if(u&&d){const r=e.toString()===t.toString();return r||console.warn(`regexps not equal: ${e.toString()} !== ${t.toString()}`),r}const l=Y(e);if(o=l.length,o!==Y(t).length)return console.warn(`key lengths not equal: ${o} !== ${Y(t).length}`),!1;for(i=o;0!==i--;)if(!Z.call(t,l[i]))return console.warn(`${l[i]} in a but not b`),!1;for(i=o;0!==i--;)if(a=l[i],!ee(e[a],t[a],r))return!1;return!0}if(!r&&"function"==typeof e&&"function"==typeof t){const r=e.toString()===t.toString();return r||console.warn(`functions not equal: ${e.toString()} !== ${t.toString()}`),r}}const s=e!=e&&t!=t;return s||console.warn(`values not equal: ${e} !== ${t}`),s}function te(e,t,r=!1){if(e===t)return!0;if(e&&t){if("object"==typeof e&&"object"==typeof t){const s=K(e),n=K(t);let i,o,a;if(s&&n){if(o=e.length,o!==t.length)return!1;for(i=o;0!==i--;)if(!te(e[i],t[i],r))return!1;return!0}if(s!==n)return!1;const h=e instanceof Date,c=t instanceof Date;if(h!==c)return!1;if(h&&c)return e.getTime()===t.getTime();const u=e instanceof RegExp,d=t instanceof RegExp;if(u!==d)return!1;if(u&&d)return e.toString()===t.toString();const l=Y(e);if(o=l.length,o!==Y(t).length)return!1;for(i=o;0!==i--;)if(!Z.call(t,l[i]))return!1;for(i=o;0!==i--;)if(a=l[i],!te(e[a],t[a],r))return!1;return!0}if(!r&&"function"==typeof e&&"function"==typeof t)return e.toString()===t.toString()}return e!=e&&t!=t}function re(e,t,r=!1){return te(e,t,r)?e:t}o(ee,"verboseDeepEquals"),o(te,"deepEquals"),o(re,"update");const se="undefined"!=typeof globalThis?globalThis:window,ne="undefined"!=typeof window&&se===window,ie="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,oe=ie&&null!=process.env&&(null!=process.env.TRAVIS||null!=process.env.GITHUB_ACTIONS||null!=process.env.CI);function ae(e){const t=document.scripts||[];for(let r=document.scripts.length-1;r>=0;--r){const s=t[r];if(s.src){const t=s.src.indexOf(e);if(t>=0)return s.src.substring(0,t)}}return""}o(ae,"getScriptSrc");const he=class _Stack{stack=[];push(e){return this.stack.push(e),e}pop(){return this.stack.pop()}top(){return this.stack.length?this.stack[this.stack.length-1]:void 0}depth(){return this.stack.length}};o(he,"Stack");let ce=he;var ue=(e=>(e[e.debug=0]="debug",e[e.info=1]="info",e[e.notice=2]="notice",e[e.warning=3]="warning",e[e.error=4]="error",e[e.critical=5]="critical",e[e.alert=6]="alert",e[e.emergency=7]="emergency",e))(ue||{});const de={debug:"cyan",info:"green",notice:"grey",warning:"blue",error:"red",critical:"magenta",alert:"magenta",emergency:"magenta"},le=class _ConsoleWriter{write(e,t,r,s){ie?console.log(`[${e}] ${ue[t].toUpperCase()} ${r}: ${s}`):console.log(`[${e}] %c${ue[t].toUpperCase()}%c ${r}: ${s}`,`color:${de[ue[t]]}`,"")}};o(le,"ConsoleWriter");let pe=le;const ge=class _Logging{_levelStack=new ce;_level=1;_filter="";_writer=new pe;static Instance(){return this._instance||(this._instance=new this)}constructor(){}stringify(e){const t=[];return JSON.stringify(e,function(e,r){if("object"==typeof r&&null!==r){if(-1!==t.indexOf(r))return;t.push(r)}return r},2)}writer(e){return void 0===e?this._writer:(this._writer=e,this)}log(e,t,r){if(e<this._level)return;if(this._filter&&this._filter!==t)return;const s=(new Date).toISOString();this._writer.rawWrite?this._writer.rawWrite(s,e,t,r):("string"!=typeof r&&(r=this.stringify(r)),this._writer.write&&this._writer.write(s,e,t,r))}debug(e,t){this.log(0,e,t)}info(e,t){this.log(1,e,t)}notice(e,t){this.log(2,e,t)}warning(e,t){this.log(3,e,t)}error(e,t){this.log(4,e,t)}critical(e,t){this.log(5,e,t)}alert(e,t){this.log(6,e,t)}emergency(e,t){this.log(7,e,t)}level(e){return void 0===e?this._level:(this._level=e,this)}pushLevel(e){return this._levelStack.push(this._level),this._level=e,this}popLevel(){return this._level=this._levelStack.pop(),this}filter(e){return void 0===e?this._filter:(this._filter=e,this)}};var fe,_e;o(ge,"Logging"),((e,t,r)=>{t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(ge,"symbol"!=typeof(fe="_instance")?fe+"":fe,_e);let ve=ge;const be=ve.Instance(),Ee=class _ScopedLogging{_scopeID;constructor(e){this._scopeID=e}debug(e){be.debug(this._scopeID,e)}info(e){be.info(this._scopeID,e)}notice(e){be.notice(this._scopeID,e)}warning(e){be.warning(this._scopeID,e)}error(e){be.error(this._scopeID,e)}critical(e){be.critical(this._scopeID,e)}alert(e){be.alert(this._scopeID,e)}emergency(e){be.emergency(this._scopeID,e)}pushLevel(e){return be.pushLevel(e),this}popLevel(){return be.popLevel(),this}};o(Ee,"ScopedLogging");let xe=Ee;function me(e,t=!1){return t&&be.filter(e),new xe(e)}function we(e){return e*(Math.PI/180)}function Me(e){return e*(180/Math.PI)}function Se(e,t){return{x:e*Math.cos(t),y:e*Math.sin(t)}}function ye(e,t){return{r:Math.sqrt(e*e+t*t),theta:Math.atan2(t,e)}}function Oe(e,t=-Math.PI,r=Math.PI){return Ie(e,t,r)}function Ve(e,t=-180,r=180){return Ie(e,t,r)}function Ie(e,t,r){const s=r-t,n=e-t;return n-Math.floor(n/s)*s+t}function De(e,t){if(void 0!==e&&void 0!==t){for(const r of e.split(".")){if(!t.hasOwnProperty(r))return;t=t[r]}return t}}function Te(e,t){return void 0!==De(e,t)}function ke(e,t){const r={};for(const s in t){if(!t.hasOwnProperty(s))continue;if("__proto__"===s||"constructor"===s)continue;let n=t[s];n instanceof Array||"object"==typeof n&&(n=Fe(e[s],n)),s in e&&(e[s]===n||s in r&&r[s]===n)||(e[s]=n)}return e}function Fe(e={},...t){if("object"!=typeof e)throw new Error(`Destination "${e}" must be an object.`);for(const r of t)ke(e,r);return e}function Ce(e={},...t){return Fe(e,...t)}function $e(e){const t=[];return JSON.stringify(e,function(e,r){if("object"==typeof r&&null!==r){if(-1!==t.indexOf(r))return;t.push(r)}return r})}function Le(e){return void 0!==Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}function Ae(e){const t=e.split("_"),r=t[1].split(".");return{module:`@hpcc-js/${t[0]}`,file:r[0],class:r[1]||r[0]}}o(me,"scopedLogger"),o(we,"degreesToRadians"),o(Me,"radiansToDegrees"),o(Se,"polarToCartesian"),o(ye,"cartesianToPolar"),o(Oe,"normalizeRadians"),o(Ve,"normalizeDegrees"),o(Ie,"normalize"),o(De,"inner"),o(Te,"exists"),o(ke,"_mixin"),o(Fe,"deepMixin"),o(Ce,"deepMixinT"),o($e,"safeStringify"),o(Le,"isArray"),o(Ae,"classID2Meta");const Ne=class _ObserverHandle{eventTarget;eventID;callback;constructor(e,t,r){this.eventTarget=e,this.eventID=t,this.callback=r}release(){this.eventTarget.removeObserver(this.eventID,this.callback)}unwatch(){this.release()}};o(Ne,"ObserverHandle");let Pe=Ne;const je=class _Observable{_eventObservers={};constructor(...e){}addObserver(e,t){let r=this._eventObservers[e];return r||(r=[],this._eventObservers[e]=r),r.push(t),new Pe(this,e,t)}removeObserver(e,t){const r=this._eventObservers[e];if(r)for(let s=r.length-1;s>=0;--s)r[s]===t&&r.splice(s,1);return this}dispatchEvent(e,...t){const r=this._eventObservers[e];if(r)for(const s of r)s(...t);return this}_hasObserver(e){const t=this._eventObservers[e];for(const r in t)if(t[r])return!0;return!1}hasObserver(e){if(void 0!==e)return this._hasObserver(e);for(const t in this._eventObservers)if(this._hasObserver(t))return!0;return!1}};o(je,"Observable");let qe,Xe=je;!function(){if(se.requestAnimationFrame)qe=se.requestAnimationFrame;else{let e=0;qe=o(function(t){const r=(new Date).getTime(),s=Math.max(0,16-(r-e)),n=setTimeout(()=>t(r+s),s);return e=r+s,n},"requestAnimationFrame")}}();const Ge=class _Message{get canConflate(){return!1}conflate(e){return!1}void(){return!1}};o(Ge,"Message");let Be=Ge;const Re=class _Dispatch{_observerID=0;_observers=[];_messageBuffer=[];_rafHandle=void 0;constructor(){}observers(){return this._observers}messages(){const e=[];return this._messageBuffer.forEach(t=>{e.some(e=>e.canConflate&&e.conflate(t))||e.push(t)}),e}dispatchAll(){this._rafHandle=void 0,this.dispatch(this.messages()),this.flush()}dispatch(e){0!==e.length&&this.observers().forEach(t=>{const r=e.filter(e=>!e.void()&&(void 0===t.type||e instanceof t.type));r.length&&t.callback(r)})}hasObserver(){return this._observers.length>0}flush(){this._messageBuffer=[]}send(e){this.hasObserver()&&this.dispatch([e])}post(e){this.hasObserver()&&(this._messageBuffer.push(e),void 0===this._rafHandle&&(this._rafHandle=qe(()=>this.dispatchAll())))}attach(e,t){const r=this,s=++this._observerID;return this._observers.push({id:s,type:t,callback:e}),{release(){r._observers=r._observers.filter(e=>e.id!==s)},unwatch(){this.release()}}}};o(Re,"Dispatch");let He=Re;const ze=class _XMLNode{name="";$={};_children=[];content="";constructor(e){this.name=e}appendAttribute(e,t){this.$[e]=t}appendContent(e){this.content+=e}appendChild(e){this._children.push(e)}children(e){return void 0===e?this._children:this._children.filter(t=>t.name===e)}};o(ze,"XMLNode");let Ue=ze;const We=class _SAXStackParser{root;stack=new ce;constructor(){}walkDoc(e){const t=this._startXMLNode(e);if(e.attributes)for(let r=0;r<e.attributes.length;++r){const t=e.attributes.item(r);this.attributes(t.nodeName,t.nodeValue)}if(this.startXMLNode(t),e.childNodes)for(let r=0;r<e.childNodes.length;++r){const t=e.childNodes.item(r);t.nodeType===t.TEXT_NODE?this.characters(t.nodeValue):this.walkDoc(t)}this.endXMLNode(this.stack.pop())}_startXMLNode(e){const t=new Ue(e.nodeName);return this.stack.depth()?this.stack.top().appendChild(t):this.root=t,this.stack.push(t)}parse(e){const t=(new DOMParser).parseFromString(e,"application/xml");this.startDocument(),this.walkDoc(t),this.endDocument()}startDocument(){}endDocument(){}startXMLNode(e){}endXMLNode(e){}attributes(e,t){this.stack.top().appendAttribute(e,t)}characters(e){this.stack.top().appendContent(e)}};o(We,"SAXStackParser");let Je=We;const Qe=class _XML2JSONParser extends Je{startXMLNode(e){super.startXMLNode(e),e.name}endXMLNode(e){e.name,super.endXMLNode(e)}};o(Qe,"XML2JSONParser");let Ke=Qe;function Ye(e){const t=new Ke;return t.parse(e),t.root}o(Ye,"xml2json");const Ze=class _PropChangedMessage extends Be{constructor(e,t,r){super(),this.property=e,this.newValue=t,this.oldValue=r}property;newValue;oldValue;get canConflate(){return!0}conflate(e){return this.property===e.property&&(this.newValue=e.newValue,!0)}void(){return te(this.newValue,this.oldValue)}};o(Ze,"PropChangedMessage");let et=Ze;const tt=class _StateObject{_espState={};_dispatch=new He;_monitorHandle;_monitorTickCount=0;clear(e){this._espState={},void 0!==e&&this.set(e),this._monitorTickCount=0}get(e,t){return void 0===e?this._espState:this.has(e)?this._espState[e]:t}set(e,t){if("string"==typeof e)return this.setSingle(e,t);this.setAll(e)}setSingle(e,t){const r=this._espState[e];this._espState[e]=t,this._dispatch.post(new et(e,t,r))}setAll(e){for(const t in e)e.hasOwnProperty(t)&&this.setSingle(t,e[t])}has(e){return void 0!==this._espState[e]}addObserver(e,t,r){if(this.isCallback(t)){if("changed"!==e)throw new Error("Invalid eventID: "+e);return this._dispatch.attach(e=>{t(e.map(e=>({id:e.property,oldValue:e.oldValue,newValue:e.newValue})))})}if("propChanged"!==e)throw new Error("Invalid eventID: "+e);return this._dispatch.attach(e=>{const s=e.filter(e=>e.property===t);if(s.length){s.length>1&&console.warn("Should only be 1 message?");const e=s[s.length-1];r({id:e.property,oldValue:e.oldValue,newValue:e.newValue})}})}on(e,t,r){return this.addObserver(e,t,r),this}isCallback(e){return"function"==typeof e}hasEventListener(){return this._dispatch.hasObserver()}async refresh(e=!1){return await Promise.resolve(),this}_monitor(){this._monitorHandle?this._monitorTickCount=0:this._monitorHandle=setTimeout(()=>{(this.hasEventListener()?this.refresh():Promise.resolve()).then(()=>{this._monitor()}),delete this._monitorHandle},this._monitorTimeoutDuration())}_monitorTimeoutDuration(){return++this._monitorTickCount,this._monitorTickCount<=1?0:3e4}watch(e,t=!0){if("function"!=typeof e)throw new Error("Invalid Callback");t&&setTimeout(()=>{const t=this.get(),r=[];for(const e in t)t.hasOwnProperty(t)&&r.push({id:e,newValue:t[e],oldValue:void 0});e(r)},0);const r=this.addObserver("changed",e);return this._monitor(),r}};o(tt,"StateObject");let rt=tt;function st(e,t){if("string"!=typeof t)return e;if(0===t.length)return e;for(;0===e.indexOf(t);)e=e.substring(1);for(;nt(e,t);)e=e.substring(0,e.length-1);return e}function nt(e,t,r){const s=e.toString();("number"!=typeof r||!isFinite(r)||Math.floor(r)!==r||r>s.length)&&(r=s.length),r-=t.length;const n=s.lastIndexOf(t,r);return-1!==n&&n===r}function it(...e){const t=e.reduce((e,t)=>(e.length>0&&(t=t.replace(/^\//,"")),t=t.replace(/\/$/,""),[...e,...t.split("/")]),[]),r=[];for(const s of t)"."!==s&&(".."!==s?r.push(s):r.pop());return r.join("/")}function ot(e){return it(e,"..")}o(st,"trim"),o(nt,"endsWith"),o(it,"join"),o(ot,"dirname");const at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function ht(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);const t=encodeURIComponent(e),r=[];for(let s=0;s<t.length;++s)"%"===t[s]?(r.push(parseInt(t.substring(s+1,s+3),16)),s+=2):r.push(t.charCodeAt(s));return Uint8Array.from(r)}function ct(e){let t="";for(let r=0;r<e.length;r+=3){const s=e[r],n=r+1<e.length,i=r+2<e.length,o=n?e[r+1]:0,a=i?e[r+2]:0;t+=at[s>>2],t+=at[(3&s)<<4|o>>4],t+=n?at[(15&o)<<2|a>>6]:"=",t+=i?at[63&a]:"="}return t}function ut(e=""){const t=null==e?"":String(e),r=globalThis?.Buffer;return r?.from?r.from(t,"utf8").toString("base64"):ct(ht(t))}o(ht,"toUTF8Bytes"),o(ct,"bytesToBase64"),o(ut,"utf8ToBase64"),e.AsyncCache=E,e.AsyncOrderedQueue=M,e.BUILD_VERSION="3.21.5",e.Cache=v,e.Dictionary=O,e.DictionaryNoCase=I,e.Dispatch=He,e.Edge=C,e.Graph=L,e.Graph2=W,e.GraphItem=T,e.Level=ue,e.Logging=ve,e.Message=Be,e.Observable=Xe,e.PKG_NAME="@hpcc-js/util",e.PKG_VERSION="3.5.5",e.SAXStackParser=Je,e.ScopedLogging=xe,e.Stack=ce,e.StateObject=rt,e.Subgraph=k,e.Vertex=F,e.XMLNode=Ue,e.cartesianToPolar=ye,e.classID2Meta=Ae,e.compare=h,e.compare2=c,e.debounce=x,e.deepEquals=te,e.deepMixin=Fe,e.deepMixinT=Ce,e.degreesToRadians=we,e.dirname=ot,e.endsWith=nt,e.espTime2Seconds=D,e.exists=Te,e.find=a,e.getScriptSrc=ae,e.hashSum=f,e.inner=De,e.isArray=Le,e.isBrowser=ne,e.isCI=oe,e.isNode=ie,e.join=it,e.logger=be,e.normalize=Ie,e.normalizeDegrees=Ve,e.normalizeRadians=Oe,e.polarToCartesian=Se,e.promiseTimeout=m,e.radiansToDegrees=Me,e.root=se,e.safeStringify=$e,e.scopedLogger=me,e.sleep=S,e.trim=st,e.update=re,e.utf8ToBase64=ut,e.verboseDeepEquals=ee,e.xml2json=Ye,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=index.umd.cjs.map