@hpcc-js/util 3.6.0 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var e = Object.defineProperty, __name = (t, n) => e(t, "name", {
|
|
3
3
|
value: n,
|
|
4
4
|
configurable: !0
|
|
5
|
-
}), t = "@hpcc-js/util", n = "3.6.
|
|
5
|
+
}), t = "@hpcc-js/util", n = "3.6.2", r = "3.27.0";
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/array.ts
|
|
8
8
|
function find(e, t) {
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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.6.0`,i=`3.26.0`;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});
|
|
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.6.2`,i=`3.27.0`;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
2
|
//# sourceMappingURL=index.umd.cjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/util",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.2",
|
|
4
4
|
"description": "hpcc-js - Utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"types/*"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"clean": "rimraf --glob lib* types dist dist-test *.tsbuildinfo .turbo",
|
|
24
|
+
"clean": "rimraf --glob lib* types types-3.4 dist dist-test *.tsbuildinfo .turbo",
|
|
25
25
|
"bundle": "vite build",
|
|
26
26
|
"bundle-watch": "vite build --watch",
|
|
27
27
|
"bundle-serve": "vite --port 5523",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@xmldom/xmldom": "0.9.10"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@hpcc-js/esbuild-plugins": "^1.9.
|
|
46
|
+
"@hpcc-js/esbuild-plugins": "^1.9.2",
|
|
47
47
|
"detect-indent": "7.0.2",
|
|
48
48
|
"mkdirp": "3.0.1"
|
|
49
49
|
},
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
59
59
|
},
|
|
60
60
|
"homepage": "https://github.com/hpcc-systems/Visualization/tree/main/packages/util",
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "9d31241482c78decca86e3bf624244ce5b40f3d6"
|
|
62
62
|
}
|