@hpcc-js/util 3.5.8 → 3.5.9
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/dist/index.js +1483 -2
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +2 -2
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -3
package/dist/index.umd.cjs
CHANGED
|
@@ -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}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.24.0",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.8",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
|
-
//# sourceMappingURL=index.umd.cjs.map
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@hpcc-js/util`]={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,__name=(e,n)=>t(e,`name`,{value:n,configurable:!0}),n=`@hpcc-js/util`,r=`3.5.9`,i=`3.25.1`;function find(e,t){if(e==null)throw TypeError(`"o" is null or not defined`);let n=e.length>>>0;if(typeof t!=`function`)throw TypeError(`predicate must be a function`);let r=arguments[1],i=0;for(;i<n;){let n=e[i];if(t.call(r,n,i))return n;i++}}function compare(e,t){let n={update:[],exit:[],enter:[...t]};for(let t of e){let e=n.enter.indexOf(t);e>=0?(n.update.push(t),n.enter.splice(e,1)):n.exit.push(t)}return n}function compare2(e,t,n,r=(e,t)=>t){let i={update:[],exit:[],enter:[]};if(e===t)return i.update=e,i;let a={};t.forEach(e=>{a[n(e)]=e});for(let t of e){let e=n(t),o=a[e];o===void 0?i.exit.push(t):(delete a[e],i.update.push(r(t,o)))}for(let e in a)i.enter.push(a[e]);return i}function pad(e,t){for(;e.length<t;)e=`0`+e;return e}function fold(e,t){if(t.length===0)return e;for(let n=0;n<t.length;++n){let r=t.charCodeAt(n);e=(e<<5)-e+r,e|=0}return e<0?e*-2:e}function foldObject(e,t,n){return typeof t.hashSum==`function`?t.hashSum():Object.keys(t).sort().reduce((e,r)=>foldValue(e,t[r],r,n),e)}function foldValue(e,t,n,r){let i=fold(fold(fold(e,n),toString(t)),typeof t);return t===null?fold(i,`null`):t===void 0?fold(i,`undefined`):typeof t==`object`?r.indexOf(t)===-1?(r.push(t),foldObject(i,t,r)):fold(i,`[Circular]`+n):fold(i,t.toString())}function toString(e){return Object.prototype.toString.call(e)}function hashSum(e){return pad(foldValue(0,e,``,[]).toString(16),8)}var Cache=class{_cache={};_calcID;static hash(...e){return hashSum({...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){return this._cache[this._calcID(e)]||(t?this.set(t()):null)}},AsyncCache=class{_cache={};_calcID;static hash(...e){return hashSum({...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){return this._cache[this._calcID(e)]||(t?this.set(e,t()):Promise.resolve(null))}};function debounce(e,t){let n={};return(...r)=>{let i=hashSum(r);return n[i]||(n[i]={clockStart:Date.now(),promise:e(...r).then(e=>(t===void 0?n[i]=null:setTimeout(()=>{n[i]=null},Math.max(t-(Date.now()-n[i].clockStart),0)),e)).catch(e=>{throw n[i]=null,e})}),n[i].promise}}function promiseTimeout(e,t){let n,r=new Promise((t,r)=>{n=setTimeout(()=>{clearTimeout(n),r(`Timed out in `+e+`ms.`)},e)});return Promise.race([t,r]).then(e=>(clearTimeout(n),e)).catch(e=>{throw clearTimeout(n),e})}var AsyncOrderedQueue=class{_q=[];isTop(e){return this._q[0]===e}push(e){let t=e.then(e=>this.isTop(t)?(this._q.shift(),e):new Promise((n,r)=>{let i=setInterval(()=>{this.isTop(t)&&(clearInterval(i),this._q.shift(),n(e))},20)}));return this._q.push(t),t}};function sleep(e){return new Promise(t=>{setTimeout(()=>t(),e)})}var Dictionary=class{store={};constructor(e){if(e)for(let t in e)this.set(t,e[t])}set(e,t){let n=this.store[e];return this.store[e]=t,n}get(e){return this.store[e]}has(e){return this.store[e]!==void 0}remove(e){delete this.store[e]}keys(){let e=[];for(let t in this.store)e.push(t);return e}values(){let e=[];for(let t in this.store)e.push(this.store[t]);return e}},DictionaryNoCase=class extends Dictionary{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())}};function espTime2Seconds(e){if(!e)return 0;if(!isNaN(Number(e)))return Number(e);let t=e.indexOf(`ns`);if(t!==-1)return parseFloat(e.substr(0,t))/1e9;let n=e.indexOf(`ms`);if(n!==-1)return parseFloat(e.substr(0,n))/1e3;let r=e.indexOf(`s`);if(r!==-1&&e.indexOf(`days`)===-1)return parseFloat(e.substr(0,r));let i=e.split(` days `),a=i.length>1?parseFloat(i[0]):0,o=i.length>1?i[1]:i[0],s=0,c=o.split(`:`).reverse();for(let e=0;e<c.length;++e)s+=parseFloat(c[e])*60**e;return a*24*60*60+s}var GraphItem=class{_graph;parent;props={};constructor(e,t){this._graph=e,this.parent=t}},a=class Subgraph extends GraphItem{subgraphs=[];vertices=[];edges=[];_;constructor(e,t,n){super(e,t),t&&t._addSubgraph(this),this._=n}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 Error(`Subgraph already exists`);this.subgraphs.push(e)}_removeSubgraph(e){let t=this.subgraphs.indexOf(e);if(t<0)throw 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 Error(`Vertex already exists`);this.vertices.push(e)}_removeVertex(e){let t=this.vertices.indexOf(e);if(t<0)throw 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,n){return this._graph.createEdge(this,e,t,n)}_addEdge(e){if(this.edges.indexOf(e)>=0)throw Error(`Edge already exists`);this.edges.push(e)}_removeEdge(e){let t=this.edges.indexOf(e);if(t<0)throw Error(`Edge does not exist`);this.edges.splice(t,1)}_add(e){e instanceof Subgraph?this._addSubgraph(e):e instanceof Vertex?this._addVertex(e):this._addEdge(e)}},Vertex=class extends GraphItem{inEdges=[];outEdges=[];get edges(){return[...this.inEdges,...this.outEdges]}_;constructor(e,t,n){super(e,t),t._addVertex(this),this._=n}remove(e=!0,t){return this._graph.removeVertex(this,e,t)}addInEdge(e){this.inEdges.push(e)}removeInEdge(e){let t=this.inEdges.indexOf(e);if(t<0)throw Error(`In edge does not exist`);this.inEdges.splice(t,1)}addOutEdge(e){this.outEdges.push(e)}removeOutEdge(e){let t=this.outEdges.indexOf(e);if(t<0)throw Error(`Out edge does not exist`);this.outEdges.splice(t,1)}},Edge=class extends GraphItem{source;target;_;constructor(e,t,n,r,i){if(super(e,t),!n)throw Error(`Missing source vertex`);if(!r)throw Error(`Missing target vertex`);t._addEdge(this),this.source=n,this.source.addOutEdge(this),this.target=r,this.target.addInEdge(this),this._=i}remove(){this._graph.removeEdge(this)}},Graph=class{root;_allSubgraphs=[];_allSubgraphsMap={};_allVertices=[];_allVerticesMap={};_allEdges=[];_allEdgesMap={};idOf;constructor(e=e=>``+e._,t){this.root=new a(this,null,t),this.idOf=e}createSubgraph(e,t){let n=new a(this,e||this.root,t);return this._allSubgraphs.push(n),this._allSubgraphsMap[this.idOf(n)]=n,n}removeSubgraph(e,t=!0){let n=this._allSubgraphs.indexOf(e);if(n<0)throw Error(`Subgraph does not exist`);this._allSubgraphs.splice(n,1),delete this._allSubgraphsMap[this.idOf(e)],e.parent&&e.parent._removeSubgraph(e),e.edges.forEach(n=>t?this.removeEdge(n):e.parent._addEdge(n)),e.vertices.forEach(n=>t?this.removeVertex(n,t):e.parent._addVertex(n)),e.subgraphs.forEach(n=>t?this.removeSubgraph(n,t):e.parent._addSubgraph(n))}get subgraphs(){return this._allSubgraphs}subgraph(e){return this._allSubgraphsMap[e]}createVertex(e,t){let n=new Vertex(this,e,t);return this._allVertices.push(n),this._allVerticesMap[this.idOf(n)]=n,n}removeVertex(e,t=!0,n){let r=this._allVertices.indexOf(e);if(r<0)throw Error(`Vertex does not exist`);this._allVertices.splice(r,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,n?n(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,n,r){let i=new Edge(this,e,t,n,r);return this._allEdges.push(i),this._allEdgesMap[this.idOf(i)]=i,i}removeEdge(e){let t=this._allEdges.indexOf(e);if(t<0)throw 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(let n of e.subgraphs)switch(t(n)){case`abort`:return!0;case`stepover`:break;default:if(this._walk(n,t))return!0}for(let n of e.vertices)if(t(n)===`abort`)return!0}walk(e){this._walk(this.root,e);for(let t of this._allEdges)if(e(t)===`abort`)return!0}clone(){let e=this.constructor,t=new e(this.idOf,this.root._),n=ObjMap();return n.put(this.root,t.root),this.walk(e=>{let t=n.get(e.parent);if(e instanceof a)n.put(e,t.createSubgraph(e._));else if(e instanceof Vertex)n.put(e,t.createVertex(e._));else if(e instanceof Edge){let r=n.get(e.source),i=n.get(e.target);t.createEdge(r,i,e._)}}),t}};function ObjMap(){let e=[],t=[];return{put(n,r){let i=e.indexOf(n);i===-1?(e.push(n),t.push(r)):t[i]=r},get(n){return t[e.indexOf(n)]}}}var GraphItem$1=class{static{__name(this,`GraphItem`)}_graph;_;id(){return this._graph.id(this._)}constructor(e,t){this._graph=e,this._=t}},ChildGraphItem=class extends GraphItem$1{_parent;constructor(e,t){super(e,t)}clearParent(){return this._parent&&(this._parent.removeChild(this),delete this._parent),this}parent(e){return arguments.length===0?this._parent:(this._parent!==e&&(this._parent&&this._parent.removeChild(this),this._parent=e,this._parent&&this._parent.addChild(this)),this)}},Subgraph$1=class extends ChildGraphItem{static{__name(this,`Subgraph`)}_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)}},Vertex$1=class extends ChildGraphItem{static{__name(this,`Vertex`)}_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)}},Edge$1=class extends ChildGraphItem{static{__name(this,`Edge`)}_source;_target;constructor(e,t,n,r){super(e,t),this._source=n,this._target=r}},Graph2=class{_directed;_subgraphMap={};_vertexMap={};_edgeMap={};constructor(e=!0){this._directed=e}clear(){return this._subgraphMap={},this._vertexMap={},this._edgeMap={},this}clearParents(){for(let e in this._subgraphMap)this._subgraphMap[e].clearParent();for(let e in this._vertexMap)this._vertexMap[e].clearParent();return this}isDirected(){return this._directed}_idFunc=e=>typeof e.id==`function`?e.id():e.id;idFunc(e){return this._idFunc=e,this}_sourceFunc=e=>typeof e.source==`function`?e.source():e.source;sourceFunc(e){return this._sourceFunc=e,this}_targetFunc=e=>typeof e.target==`function`?e.target():e.target;targetFunc(e){return this._targetFunc=e,this}_updateFunc=(e,t)=>t;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){if(this.subgraphExists(e))return this.subgraph(e);if(this.vertexExists(e))return this.vertex(e);if(this.edgeExists(e))return this.edge(e)}itemExists(e){return this.edgeExists(e)||this.vertexExists(e)||this.subgraphExists(e)}allSubgraphs(){let e=[];for(let t in this._subgraphMap)e.push(this._subgraphMap[t]._);return e}subgraphs(){let e=[];for(let t in this._subgraphMap)this._subgraphMap[t].parent()===void 0&&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){let n=this._idFunc(e);if(this._subgraphMap[n])throw Error(`Subgraph '${n}' already exists.`);let r=new Subgraph$1(this,e);if(t){let e=this._idFunc(t);if(!this._subgraphMap[e])throw Error(`Subgraph '${e}' does not exist.`);r.parent(this._subgraphMap[e])}return this._subgraphMap[n]=r,this}mergeSubgraphs(e=[]){let t=compare2(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){let t=this._idFunc(e),n=this._subgraphMap[t];if(!n)throw Error(`Subgraph '${t}' does not exist.`);return n._=e,this}removeSubgraph(e,t=!0){let n=this._subgraphMap[e];if(!n)throw Error(`Subgraph '${e}' does not exist.`);return n.children().forEach(e=>{t?e.parent(n.parent()):e instanceof Subgraph$1?this.removeSubgraph(e.id()):this.removeVertex(e.id())}),delete this._subgraphMap[e],this}subgraphParent(e,t){let n=this._subgraphMap[e];if(!n)throw Error(`Subgraph '${e}' does not exist.`);if(t===void 0){let e=n.parent();return e?e._:void 0}let r=this._subgraphMap[t];if(!r)throw Error(`Vertex parent '${r}' does not exist.`);return n.parent(r),this}allVertices(){let e=[];for(let t in this._vertexMap)e.push(this._vertexMap[t]._);return e}vertices(){let e=[];for(let t in this._vertexMap)this._vertexMap[t].parent()===void 0&&e.push(this._vertexMap[t]._);return e}vertexExists(e){return!!this._vertexMap[e]}vertex(e){return this._vertexMap[e]._}allEdges(){let e=[];for(let t in this._edgeMap)e.push(this._edgeMap[t]._);return e}edges(){let e=[];for(let t in this._edgeMap)this._edgeMap[t].parent()===void 0&&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=>e.edgeCount()===1).map(e=>e._)}addVertex(e,t){let n=this._idFunc(e);if(this._vertexMap[n])throw Error(`Vertex '${n}' already exists.`);let r=new Vertex$1(this,e);if(t){let e=this._idFunc(t);if(!this.subgraphExists(e))throw Error(`Subgraph '${e}' does not exist.`);r.parent(this._subgraphMap[e])}return this._vertexMap[n]=r,this}mergeVertices(e){let t=compare2(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){let t=this._idFunc(e),n=this._vertexMap[t];if(!n)throw Error(`Vertex '${t}' does not exist.`);return n._=e,this}removeVertex(e){let t=this._vertexMap[e];if(!t)throw Error(`Vertex '${e}' does not exist.`);return t.edges().forEach(e=>{this.removeEdge(e.id())}),delete this._vertexMap[e],this}vertexParent(e,t){let n=this._vertexMap[e];if(!n)throw Error(`Vertex '${e}' does not exist.`);if(t===void 0){let e=n.parent();return e?e._:void 0}let r=this._subgraphMap[t];if(!r)throw Error(`Vertex parent '${r}' does not exist.`);return n.parent(r),this}edgeExists(e){return!!this._edgeMap[e]}edge(e){return this._edgeMap[e]._}addEdge(e,t){let n=this._idFunc(e),r=this._sourceFunc(e),i=this._targetFunc(e);if(this._edgeMap[n])throw Error(`Edge '${n}' already exists.`);if(!this.vertexExists(r))throw Error(`Edge Source '${r}' does not exist.`);if(!this.vertexExists(i))throw Error(`Edge Target '${i}' does not exist.`);let a=new Edge$1(this,e,this._vertexMap[r],this._vertexMap[i]);if(t){let e=this._idFunc(t);if(!this.subgraphExists(e))throw Error(`Subgraph '${e}' does not exist.`);a.parent(this._subgraphMap[e])}return this._edgeMap[n]=a,this._vertexMap[r].addOutEdge(a),this._vertexMap[i].addInEdge(a),this}mergeEdges(e){let t=compare2(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){let t=this._idFunc(e),n=this._edgeMap[t];if(!n)throw Error(`Edge '${t}' does not exist.`);let r=n._source.id(),i=this._sourceFunc(e);r!==i&&(this._vertexMap[r]?.removeOutEdge(t),this._vertexMap[i]?.addOutEdge(n));let a=n._target.id(),o=this._targetFunc(e);return a!==o&&(this._vertexMap[a]?.removeInEdge(t),this._vertexMap[o]?.addInEdge(n)),n._=e,n._source=this._vertexMap[i],n._target=this._vertexMap[o],this}removeEdge(e){let t=this._edgeMap[e];if(!t)throw Error(`Edge '${e}' does not exist.`);let n=this._idFunc(t._source._);if(!this.vertexExists(n))throw Error(`Edge Source'${n}' does not exist.`);this._vertexMap[n].removeOutEdge(e);let r=this._idFunc(t._target._);if(!this.vertexExists(r))throw Error(`Edge Target'${r}' does not exist.`);return this._vertexMap[r].removeInEdge(e),delete this._edgeMap[e],this}_hwalk(e,t){return e instanceof Subgraph$1?t(`subgraph`,e._,e.children().map(e=>this._hwalk(e,t))):t(`vertex`,e._)}hierarchy(e){let t=[];for(let n in this._subgraphMap){let r=this._subgraphMap[n];r.parent()===void 0&&t.push(this._hwalk(r,e))}for(let n in this._vertexMap){let r=this._vertexMap[n];r.parent()===void 0&&t.push(this._hwalk(r,e))}return t}dijkstra(e,t){let n=this.allEdges(),r=new Set,i={},a={},o={};function vertex_with_min_dist(e,t){let n=1/0,r=null;return e.forEach(e=>{t[e]<n&&(n=t[e],r=e)}),r}for(let e=0;e<n.length;e++){let t=this._sourceFunc(n[e]),i=this._targetFunc(n[e]);r.add(t),r.add(i),a[t]=1/0,a[i]=1/0,o[t]===void 0&&(o[t]={}),o[i]===void 0&&(o[i]={}),o[t][i]=1,o[i][t]=1}for(a[e]=0;r.size;){let e=vertex_with_min_dist(r,a);if(e===null)break;let n=Object.keys(o[e]).filter(e=>r.has(e));if(r.delete(e),e===t)break;for(let t of n){let n=a[e]+o[e][t];n<a[t]&&(a[t]=n,i[t]=e)}}let s=t,c=[s],l=0;for(;i[s]!==void 0;)c.unshift(i[s]),l+=o[s][i[s]],s=i[s];return{ids:c,len:l}}sort(e){let t=[],n={},visit=(e,r=[])=>{let i=e.id();n[i]||(n[i]=!0,r.push(e),e.outEdges().forEach(e=>{r.indexOf(e._target)<0&&visit(e._target,[...r])}),t.unshift(e._))};if(e)visit(this._vertexMap[e]);else for(let e in this._vertexMap)visit(this._vertexMap[e]);return t}},Set=class{_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){let t=this._content.indexOf(e);t>=0&&this._content.splice(t,1)}forEach(e){this._content.forEach(e)}},o=Array.isArray,s=Object.keys,c=Object.prototype.hasOwnProperty;function verboseDeepEquals(e,t,n=!1){if(e===t)return!0;if(e&&t){if(typeof e==`object`&&typeof t==`object`){let r=o(e),i=o(t),a,l,u;if(r&&i){if(l=e.length,l!==t.length)return console.warn(`lengths not equal: ${l} !== ${t.length}`),!1;for(a=l;a--!==0;)if(!verboseDeepEquals(e[a],t[a],n))return!1;return!0}if(r!==i)return console.warn(`arrays not equal: ${r} !== ${i}`),!1;let d=e instanceof Date,f=t instanceof Date;if(d!==f)return console.warn(`dates not equal: ${d} !== ${f}`),!1;if(d&&f){let n=e.getTime()===t.getTime();return n||console.warn(`dates not equal: ${e.getTime()} !== ${t.getTime()}`),n}let p=e instanceof RegExp,m=t instanceof RegExp;if(p!==m)return console.warn(`regexps not equal: ${p} !== ${m}`),!1;if(p&&m){let n=e.toString()===t.toString();return n||console.warn(`regexps not equal: ${e.toString()} !== ${t.toString()}`),n}let h=s(e);if(l=h.length,l!==s(t).length)return console.warn(`key lengths not equal: ${l} !== ${s(t).length}`),!1;for(a=l;a--!==0;)if(!c.call(t,h[a]))return console.warn(`${h[a]} in a but not b`),!1;for(a=l;a--!==0;)if(u=h[a],!verboseDeepEquals(e[u],t[u],n))return!1;return!0}else if(!n&&typeof e==`function`&&typeof t==`function`){let n=e.toString()===t.toString();return n||console.warn(`functions not equal: ${e.toString()} !== ${t.toString()}`),n}}let r=e!==e&&t!==t;return r||console.warn(`values not equal: ${e} !== ${t}`),r}function deepEquals(e,t,n=!1){if(e===t)return!0;if(e&&t){if(typeof e==`object`&&typeof t==`object`){let r=o(e),i=o(t),a,l,u;if(r&&i){if(l=e.length,l!==t.length)return!1;for(a=l;a--!==0;)if(!deepEquals(e[a],t[a],n))return!1;return!0}if(r!==i)return!1;let d=e instanceof Date,f=t instanceof Date;if(d!==f)return!1;if(d&&f)return e.getTime()===t.getTime();let p=e instanceof RegExp,m=t instanceof RegExp;if(p!==m)return!1;if(p&&m)return e.toString()===t.toString();let h=s(e);if(l=h.length,l!==s(t).length)return!1;for(a=l;a--!==0;)if(!c.call(t,h[a]))return!1;for(a=l;a--!==0;)if(u=h[a],!deepEquals(e[u],t[u],n))return!1;return!0}else if(!n&&typeof e==`function`&&typeof t==`function`)return e.toString()===t.toString()}return e!==e&&t!==t}function update(e,t,n=!1){return deepEquals(e,t,n)?e:t}var l=typeof globalThis<`u`?globalThis:window,u=typeof window<`u`&&l===window,d=typeof process<`u`&&process.versions!=null&&process.versions.node!=null,f=d&&process.env!=null&&(process.env.TRAVIS!=null||process.env.GITHUB_ACTIONS!=null||process.env.CI!=null);function getScriptSrc(e){let t=document.scripts||[];for(let n=document.scripts.length-1;n>=0;--n){let r=t[n];if(r.src){let t=r.src.indexOf(e);if(t>=0)return r.src.substring(0,t)}}return``}var Stack=class{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}},p=function(e){return 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}({}),m={debug:`cyan`,info:`green`,notice:`grey`,warning:`blue`,error:`red`,critical:`magenta`,alert:`magenta`,emergency:`magenta`},ConsoleWriter=class{write(e,t,n,r){d?console.log(`[${e}] ${p[t].toUpperCase()} ${n}: ${r}`):console.log(`[${e}] %c${p[t].toUpperCase()}%c ${n}: ${r}`,`color:${m[p[t]]}`,``)}},Logging=class{static _instance;_levelStack=new Stack;_level=1;_filter=``;_writer=new ConsoleWriter;static Instance(){return this._instance||=new this}constructor(){}stringify(e){let t=[];return JSON.stringify(e,function(e,n){if(typeof n==`object`&&n){if(t.indexOf(n)!==-1)return;t.push(n)}return n},2)}writer(e){return e===void 0?this._writer:(this._writer=e,this)}log(e,t,n){if(e<this._level||this._filter&&this._filter!==t)return;let r=new Date().toISOString();this._writer.rawWrite?this._writer.rawWrite(r,e,t,n):(typeof n!=`string`&&(n=this.stringify(n)),this._writer.write&&this._writer.write(r,e,t,n))}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 e===void 0?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 e===void 0?this._filter:(this._filter=e,this)}},h=Logging.Instance(),ScopedLogging=class{_scopeID;constructor(e){this._scopeID=e}debug(e){h.debug(this._scopeID,e)}info(e){h.info(this._scopeID,e)}notice(e){h.notice(this._scopeID,e)}warning(e){h.warning(this._scopeID,e)}error(e){h.error(this._scopeID,e)}critical(e){h.critical(this._scopeID,e)}alert(e){h.alert(this._scopeID,e)}emergency(e){h.emergency(this._scopeID,e)}pushLevel(e){return h.pushLevel(e),this}popLevel(){return h.popLevel(),this}};function scopedLogger(e,t=!1){return t&&h.filter(e),new ScopedLogging(e)}function degreesToRadians(e){return Math.PI/180*e}function radiansToDegrees(e){return 180/Math.PI*e}function polarToCartesian(e,t){return{x:e*Math.cos(t),y:e*Math.sin(t)}}function cartesianToPolar(e,t){return{r:Math.sqrt(e*e+t*t),theta:Math.atan2(t,e)}}function normalizeRadians(e,t=-Math.PI,n=Math.PI){return normalize(e,t,n)}function normalizeDegrees(e,t=-180,n=180){return normalize(e,t,n)}function normalize(e,t,n){let r=n-t,i=e-t;return i-Math.floor(i/r)*r+t}function inner(e,t){if(!(e===void 0||t===void 0)){for(let n of e.split(`.`)){if(!t.hasOwnProperty(n))return;t=t[n]}return t}}function exists(e,t){return inner(e,t)!==void 0}function _mixin(e,t){let n={};for(let r in t){if(!t.hasOwnProperty(r)||r===`__proto__`||r===`constructor`)continue;let i=t[r];i instanceof Array||typeof i==`object`&&(i=deepMixin(e[r],i)),(!(r in e)||e[r]!==i&&(!(r in n)||n[r]!==i))&&(e[r]=i)}return e}function deepMixin(e={},...t){if(typeof e!=`object`)throw Error(`Destination "${e}" must be an object.`);for(let n of t)_mixin(e,n);return e}function deepMixinT(e={},...t){return deepMixin(e,...t)}function safeStringify(e){let t=[];return JSON.stringify(e,function(e,n){if(typeof n==`object`&&n){if(t.indexOf(n)!==-1)return;t.push(n)}return n})}function isArray(e){return Array.isArray===void 0?Object.prototype.toString.call(e)===`[object Array]`:Array.isArray(e)}function classID2Meta(e){let t=e.split(`_`),n=t[1].split(`.`);return{module:`@hpcc-js/${t[0]}`,file:n[0],class:n[1]||n[0]}}var ObserverHandle=class{eventTarget;eventID;callback;constructor(e,t,n){this.eventTarget=e,this.eventID=t,this.callback=n}release(){this.eventTarget.removeObserver(this.eventID,this.callback)}unwatch(){this.release()}},Observable=class{_eventObservers={};constructor(...e){}addObserver(e,t){let n=this._eventObservers[e];return n||(n=[],this._eventObservers[e]=n),n.push(t),new ObserverHandle(this,e,t)}removeObserver(e,t){let n=this._eventObservers[e];if(n)for(let e=n.length-1;e>=0;--e)n[e]===t&&n.splice(e,1);return this}dispatchEvent(e,...t){let n=this._eventObservers[e];if(n)for(let e of n)e(...t);return this}_hasObserver(e){let t=this._eventObservers[e];for(let e in t)if(t[e])return!0;return!1}hasObserver(e){if(e!==void 0)return this._hasObserver(e);for(let e in this._eventObservers)if(this._hasObserver(e))return!0;return!1}},requestAnimationFrame;(function(){if(l.requestAnimationFrame)requestAnimationFrame=l.requestAnimationFrame;else{let e=0;requestAnimationFrame=function(t){let n=new Date().getTime(),r=Math.max(0,16-(n-e)),i=setTimeout(()=>t(n+r),r);return e=n+r,i}}})();var Message=class{get canConflate(){return!1}conflate(e){return!1}void(){return!1}},Dispatch=class{_observerID=0;_observers=[];_messageBuffer=[];_rafHandle=void 0;constructor(){}observers(){return this._observers}messages(){let 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){e.length!==0&&this.observers().forEach(t=>{let n=e.filter(e=>!e.void()&&(t.type===void 0||e instanceof t.type));n.length&&t.callback(n)})}hasObserver(){return this._observers.length>0}flush(){this._messageBuffer=[]}send(e){this.hasObserver()&&this.dispatch([e])}post(e){this.hasObserver()&&(this._messageBuffer.push(e),this._rafHandle===void 0&&(this._rafHandle=requestAnimationFrame(()=>this.dispatchAll())))}attach(e,t){let n=this,r=++this._observerID;return this._observers.push({id:r,type:t,callback:e}),{release(){n._observers=n._observers.filter(e=>e.id!==r)},unwatch(){this.release()}}}},XMLNode=class{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 e===void 0?this._children:this._children.filter(t=>t.name===e)}},SAXStackParser=class{root;stack=new Stack;constructor(){}walkDoc(e){let t=this._startXMLNode(e);if(e.attributes)for(let t=0;t<e.attributes.length;++t){let n=e.attributes.item(t);this.attributes(n.nodeName,n.nodeValue)}if(this.startXMLNode(t),e.childNodes)for(let t=0;t<e.childNodes.length;++t){let n=e.childNodes.item(t);n.nodeType===n.TEXT_NODE?this.characters(n.nodeValue):this.walkDoc(n)}this.endXMLNode(this.stack.pop())}_startXMLNode(e){let t=new XMLNode(e.nodeName);return this.stack.depth()?this.stack.top().appendChild(t):this.root=t,this.stack.push(t)}parse(e){let 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)}},XML2JSONParser=class extends SAXStackParser{startXMLNode(e){switch(super.startXMLNode(e),e.name){case`xs:element`:break;case`xs:simpleType`:break;default:break}}endXMLNode(e){switch(e.name){case`xs:element`:break;case`xs:simpleType`:break;default:break}super.endXMLNode(e)}};function xml2json(e){let t=new XML2JSONParser;return t.parse(e),t.root}var PropChangedMessage=class extends Message{property;newValue;oldValue;constructor(e,t,n){super(),this.property=e,this.newValue=t,this.oldValue=n}get canConflate(){return!0}conflate(e){return this.property===e.property?(this.newValue=e.newValue,!0):!1}void(){return deepEquals(this.newValue,this.oldValue)}},StateObject=class{_espState={};_dispatch=new Dispatch;_monitorHandle;_monitorTickCount=0;clear(e){this._espState={},e!==void 0&&this.set(e),this._monitorTickCount=0}get(e,t){return e===void 0?this._espState:this.has(e)?this._espState[e]:t}set(e,t){if(typeof e==`string`)return this.setSingle(e,t);this.setAll(e)}setSingle(e,t){let n=this._espState[e];this._espState[e]=t,this._dispatch.post(new PropChangedMessage(e,t,n))}setAll(e){for(let t in e)e.hasOwnProperty(t)&&this.setSingle(t,e[t])}has(e){return this._espState[e]!==void 0}addObserver(e,t,n){if(this.isCallback(t)){if(e!==`changed`)throw Error(`Invalid eventID: `+e);return this._dispatch.attach(e=>{t(e.map(e=>({id:e.property,oldValue:e.oldValue,newValue:e.newValue})))})}else{if(e!==`propChanged`)throw Error(`Invalid eventID: `+e);return this._dispatch.attach(e=>{let r=e.filter(e=>e.property===t);if(r.length){r.length>1&&console.warn(`Should only be 1 message?`);let e=r[r.length-1];n({id:e.property,oldValue:e.oldValue,newValue:e.newValue})}})}}on(e,t,n){return this.addObserver(e,t,n),this}isCallback(e){return typeof e==`function`}hasEventListener(){return this._dispatch.hasObserver()}async refresh(e=!1){return await Promise.resolve(),this}_monitor(){if(this._monitorHandle){this._monitorTickCount=0;return}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(typeof e!=`function`)throw Error(`Invalid Callback`);t&&setTimeout(()=>{let t=this.get(),n=[];for(let e in t)t.hasOwnProperty(t)&&n.push({id:e,newValue:t[e],oldValue:void 0});e(n)},0);let n=this.addObserver(`changed`,e);return this._monitor(),n}};function trim(e,t){if(typeof t!=`string`||t.length===0)return e;for(;e.indexOf(t)===0;)e=e.substring(1);for(;endsWith(e,t);)e=e.substring(0,e.length-1);return e}function endsWith(e,t,n){let r=e.toString();(typeof n!=`number`||!isFinite(n)||Math.floor(n)!==n||n>r.length)&&(n=r.length),n-=t.length;let i=r.lastIndexOf(t,n);return i!==-1&&i===n}function join(...e){let t=e.reduce((e,t)=>(e.length>0&&(t=t.replace(/^\//,``)),t=t.replace(/\/$/,``),[...e,...t.split(`/`)]),[]),n=[];for(let e of t)if(e!==`.`){if(e===`..`){n.pop();continue}n.push(e)}return n.join(`/`)}function dirname(e){return join(e,`..`)}var g=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function toUTF8Bytes(e){if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);let t=encodeURIComponent(e),n=[];for(let e=0;e<t.length;++e)t[e]===`%`?(n.push(parseInt(t.substring(e+1,e+3),16)),e+=2):n.push(t.charCodeAt(e));return Uint8Array.from(n)}function bytesToBase64(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length,a=n+2<e.length,o=i?e[n+1]:0,s=a?e[n+2]:0;t+=g[r>>2],t+=g[(r&3)<<4|o>>4],t+=i?g[(o&15)<<2|s>>6]:`=`,t+=a?g[s&63]:`=`}return t}function utf8ToBase64(e=``){let t=e==null?``:String(e),n=globalThis?.Buffer;return n?.from?n.from(t,`utf8`).toString(`base64`):bytesToBase64(toUTF8Bytes(t))}e.AsyncCache=AsyncCache,e.AsyncOrderedQueue=AsyncOrderedQueue,e.BUILD_VERSION=i,e.Cache=Cache,e.Dictionary=Dictionary,e.DictionaryNoCase=DictionaryNoCase,e.Dispatch=Dispatch,e.Edge=Edge,e.Graph=Graph,e.Graph2=Graph2,e.GraphItem=GraphItem,e.Level=p,e.Logging=Logging,e.Message=Message,e.Observable=Observable,e.PKG_NAME=n,e.PKG_VERSION=r,e.SAXStackParser=SAXStackParser,e.ScopedLogging=ScopedLogging,e.Stack=Stack,e.StateObject=StateObject,e.Subgraph=a,e.Vertex=Vertex,e.XMLNode=XMLNode,e.cartesianToPolar=cartesianToPolar,e.classID2Meta=classID2Meta,e.compare=compare,e.compare2=compare2,e.debounce=debounce,e.deepEquals=deepEquals,e.deepMixin=deepMixin,e.deepMixinT=deepMixinT,e.degreesToRadians=degreesToRadians,e.dirname=dirname,e.endsWith=endsWith,e.espTime2Seconds=espTime2Seconds,e.exists=exists,e.find=find,e.getScriptSrc=getScriptSrc,e.hashSum=hashSum,e.inner=inner,e.isArray=isArray,e.isBrowser=u,e.isCI=f,e.isNode=d,e.join=join,e.logger=h,e.normalize=normalize,e.normalizeDegrees=normalizeDegrees,e.normalizeRadians=normalizeRadians,e.polarToCartesian=polarToCartesian,e.promiseTimeout=promiseTimeout,e.radiansToDegrees=radiansToDegrees,e.root=l,e.safeStringify=safeStringify,e.scopedLogger=scopedLogger,e.sleep=sleep,e.trim=trim,e.update=update,e.utf8ToBase64=utf8ToBase64,e.verboseDeepEquals=verboseDeepEquals,e.xml2json=xml2json});
|
|
2
|
+
//# sourceMappingURL=index.umd.cjs.map
|