UNPKG

ixfx

Version:

Bundle of ixfx libraries

10 lines 67.9 kB
import{n as e}from"./chunk-BKBlUVio.js";import{$ as t,Bt as n,Ct as r,Dt as i,Et as a,Lt as o,Ot as s,Q as c,St as ee,X as te,Z as ne,_t as re,at as ie,bt as ae,ct as oe,dt as se,et as ce,ft as le,gt as ue,h as de,it as fe,jt as l,k as u,lt as pe,mt as me,nt as he,ot as ge,pt as _e,rt as ve,st as ye,tt as be,ut as xe,vt as Se,xt as Ce,yt as we,z as d}from"./src-DlHqXvlb.js";import{A as f,C as Te,M as p,R as m,n as Ee,u as De,v as Oe}from"./src-CrVWx2VD.js";import{I as ke,V as Ae,r as je}from"./src-BGZztchK.js";import{n as h}from"./src-CIW3LrR8.js";import{B as Me,g,v as Ne,y as Pe,z as Fe}from"./src-CTRxqO-R.js";var Ie=class e extends Array{#e;#t;constructor(e=0){super(),p(Oe(e,`positive`,`capacity`)),this.#e=e,this.#t=0}add(t){let n=e.from(this);return n[this.#t]=t,n.#e=this.#e,this.#e>0?n.#t=this.#t+1===this.#e?0:this.#t+1:n.#t=this.#t+1,n}get pointer(){return this.#t}get isFull(){return this.#e===0?!1:this.length===this.#e}};function Le(e,t,n=l){let r=Be(e,t,n);return r?r.startIndex:-1}function Re(e,t,n=l){let r=0,i=e.length;for(;r<i;){let a=r+i>>1;n(e[a],t)<0?r=a+1:i=a}return r}function ze(e,t,n=l){let r=0,i=e.length;for(;r<i;){let a=r+i>>1;n(e[a],t)<=0?r=a+1:i=a}return r}function Be(e,t,n=l){if(e.length===0)return;let r=Re(e,t,n);if(!(r>=e.length||n(e[r],t)!==0))return{startIndex:r,endIndex:ze(e,t,n)-1}}function Ve(e,t,n=l){if(typeof n!=`function`)throw TypeError(`Param 'comparer' is not a function`);if(!Array.isArray(e))throw TypeError(`Param 'data' is not an array`);return ze(e,t,n)}const _=(e,t)=>{if(e===void 0)throw TypeError(`Param 'a' is undefined`);if(t===void 0)throw TypeError(`Param 'b' is undefined`);return e.start===t.start?e.end-t.end:e.start-t.start},He=(e,t)=>{if(e===void 0)throw TypeError(`Param 'a' is undefined`);if(t===void 0)throw TypeError(`Param 'b' is undefined`);return e.start-t.start},Ue=(e,t)=>{if(e===void 0)throw TypeError(`Param 'a' is undefined`);if(t===void 0)throw TypeError(`Param 'b' is undefined`);return e.end===t.end?e.start-t.start:e.end-t.end},We=(e,t)=>{if(e===void 0)throw TypeError(`Param 'a' is undefined`);if(t===void 0)throw TypeError(`Param 'b' is undefined`);return e.end-t.end};function Ge(e){return e.toSorted(_)}function Ke(e){return e.toSorted(Ue)}function*qe(e,t){if(!Array.isArray(e))throw TypeError(`Param 'sortedEvents' is not an array`);let n=Be(e,{start:t,end:t},He);if(n)for(let t=n.startIndex;t<=n.endIndex;t++)yield{event:e[t],index:t}}function*Je(e,t){if(!Array.isArray(e))throw TypeError(`Param 'eventsByEnd' is not an array`);let n=Be(e,{start:t,end:t},We);if(n)for(let t=n.startIndex;t<=n.endIndex;t++)yield{event:e[t],index:t}}function Ye(e,t=!1){let n=[];if(t)for(let t of e)n.push(t.event);else for(let{event:t,index:r}of e)n[r]=t;return n}function*Xe(e,t,n=!1,r=!0){for(let i=0;i<e.length;i++){let a=e[i],o=r?t>=a.start:t>a.start;(n?t<=a.end:t<a.end)&&o&&(yield{event:a,index:i})}}function Ze(e,t,n,r){let i=Ve(e,{start:t,end:t},_);if(r===`stretch`){let r=[...e];for(let{event:i,index:a}of Xe(e,t,!1,!1))r[a]={...i,end:i.end+n};e=r}for(;e[i-1]?.start===t;)i--;let a=e.slice(0,i),o=e.slice(i).map(e=>v(e,n)),s=[...a,...o];if(s.length!==e.length)throw Error(`Bug in insertSpace: result length ${s.length} does not match original length ${e.length}`);return s}function Qe(e,t){m(rt(t));let n=[];for(let r of e){let e=ct(r,t);if(e===`none`){n.push(r);continue}if(e!==`equal`){if(e===`full-border`){r.start<t.start?n.push({...r,end:t.start}):r.end>t.end&&n.push({...r,start:t.end});continue}if(e===`full`){n.push({...r,end:t.start}),n.push({...r,start:t.end});continue}if(e===`partial`){r.start<t.start?n.push({...r,end:t.start}):r.end>t.end&&n.push({...r,start:t.end});continue}}}return n}function $e(e){return e.start===e.end}function et(e){return{...e,start:e.start,end:e.start+e.duration}}function tt(e){return{...e,start:e.start,duration:e.end-e.start}}function*nt(e){if(!(e.length<=1))for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];yield{indexA:t-1,indexB:t,a:n,b:r,startInterval:r.start-n.start,endInterval:r.end-n.end,betweenInterval:r.start-n.end}}}function rt(e){return it(e)?e.end<e.start?{success:!1,error:`Invalid EventItem. End (${e.end}) is before start (${e.start})`}:{success:!0,value:e}:{success:!1,error:`Item is not a valid EventItem`}}function it(e){return typeof e!=`object`||!e?!1:`start`in e&&`end`in e&&typeof e.start==`number`&&typeof e.end==`number`}function at(e,t,n){let r=Le(e,t,_);if(r===-1)return e;if(n===`shuffle-following`)return[...e.slice(0,r),...e.slice(r+1).map(e=>v(e,t.start-t.end))];if(n===`slice-following`){let n=t.start-e[r+1].start;return[...e.slice(0,r),...e.slice(r+1).map(e=>v(e,n))]}else if(n===`shuffle-leading`)return[...e.slice(0,r).map(e=>v(e,t.end-t.start)),...e.slice(r+1)];else if(n===`slice-leading`){let n=t.end-e[r-1].end;return[...e.slice(0,r).map(e=>v(e,n)),...e.slice(r+1)]}return e.toSpliced(r,1)}function ot(e,t){if(`percentage`in t){let n=e.start+(e.end-e.start)*t.percentage;return[{...e,start:e.start,end:n},{...e,start:n,end:e.end}]}else{let n=t.start;return[{...e,start:e.start,end:n},{...e,start:n,end:e.end}]}}function st(e,t){return{...e,start:t(e.start),end:t(e.end)}}function v(e,t){return{...e,start:e.start+t,end:e.end+t}}function ct(e,t){return t.start>e.end||t.end<e.start?`none`:t.start===e.start&&t.end===e.end?`equal`:t.start>e.start&&t.end<e.end?`full`:t.start>=e.start&&t.end<=e.end?`full-border`:`partial`}function lt(e,t={}){let n=t.startAt??0,r=t.gap??0,i=[];for(let t of e)i.push({...t,start:n,end:n+(t.end-t.start)}),n=i.at(-1).end+r;return i}function ut(e,t,n=`event`){return e.map((e,r)=>({start:e,end:e+t,id:`${n}-${r}`}))}function dt(e){let t=2**53-1,n=-(2**53-1);for(let r of e)r.start<t&&(t=r.start),r.end>n&&(n=r.end);return{start:t,end:n}}function ft(e){return e.reduce((e,t)=>e+(t.end-t.start),0)}const pt=(e,t,n)=>{let r=t.length+n.length,i=e.discardPolicy??`additions`,a=e.capacity??r,o=r-a;switch(e.debug&&console.log(`Stack.push: stackLen: ${t.length} potentialLen: ${r} toRemove: ${o} policy: ${i}`),i){case`additions`:return e.debug&&console.log(`Stack.push:DiscardAdditions: stackLen: ${t.length} slice: ${r-a} toAddLen: ${n.length}`),t.length===e.capacity?t:[...t,...n.slice(0,n.length-o)];case`newer`:{if(n.length>=a)return n.slice(n.length-a);let e=a-n.length;return[...t.slice(0,e),...n]}case`older`:return[...t,...n].slice(o);default:throw Error(`Unknown discard policy ${i}`)}},mt=(e,t,...n)=>{let r=t.length+n.length;return e.capacity&&r>e.capacity?pt(e,t,n):[...t,...n]},ht=(e,t)=>{if(t.length===0)throw Error(`Stack is empty`);return t.slice(0,-1)},gt=(e,t)=>t.at(-1),_t=(e,t)=>t.length===0,vt=(e,t)=>e.capacity?t.length>=e.capacity:!1;var y=class{opts;data;constructor(e={},t=[]){this.opts=e,this.data=t}push(...e){return e.length===0||(this.data=mt(this.opts,this.data,...e)),this.data.length}forEach(e){this.data.forEach(e)}forEachFromTop(e){[...this.data].reverse().forEach(e)}pop(){let e=gt(this.opts,this.data);return this.data=ht(this.opts,this.data),e}get isEmpty(){return _t(this.opts,this.data)}get isFull(){return vt(this.opts,this.data)}get peek(){return gt(this.opts,this.data)}get length(){return this.data.length}};const yt=(e={},...t)=>new y({...e},[...t]),bt=(e,t)=>{e.debug&&console.log(`queue:${t}`)},xt=(e,t,n)=>{let r=t.length+n.length,i=e.capacity??r,a=r-i,o=e.discardPolicy??`additions`;switch(o){case`additions`:return t.length===0?n.slice(0,n.length-a):t.length===e.capacity?t:[...t,...n.slice(0,a-1)];case`newer`:if(a>=t.length)return t.length===0?[...n.slice(0,i-1),n.at(-1)]:n.slice(Math.max(0,n.length-i),Math.min(n.length,i)+1);{let e=Math.max(1,n.length-t.length),r=n.slice(n.length-e,n.length);return[...t.slice(0,Math.min(t.length,i-1)),...r]}case`older`:return[...t,...n].slice(a);default:throw Error(`Unknown overflow policy ${o}`)}},St=(e,t,...n)=>{if(e===void 0)throw Error(`opts parameter undefined`);let r=t.length+n.length,i=e.capacity&&r>e.capacity,a=i?xt(e,t,n):[...t,...n];if(e.capacity&&a.length!==e.capacity&&i)throw Error(`Bug! Expected return to be at capacity. Return len: ${a.length} capacity: ${e.capacity} opts: ${JSON.stringify(e)}`);if(!e.capacity&&a.length!==r)throw Error(`Bug! Return length not expected. Return len: ${a.length} expected: ${r} opts: ${JSON.stringify(e)}`);return a},Ct=(e,t)=>{if(t.length===0)throw Error(`Queue is empty`);return t.slice(1)},wt=(e,t)=>t[0],Tt=(e,t)=>t.length===0,Et=(e,t)=>e.capacity?t.length>=e.capacity:!1;var b=class extends h{options;data;eq;constructor(e={},t=[]){if(super(),e===void 0)throw Error(`opts parameter undefined`);this.options=e,this.data=t,this.eq=e.eq??a}clear(){let e=[...this.data];this.data=[],this.fireEvent(`removed`,{finalData:this.data,removed:e}),this.onClear()}onClear(){}at(e){if(e>=this.data.length)throw Error(`Index outside bounds of queue`);let t=this.data.at(e);if(t===void 0)throw Error(`Index appears to be outside range of queue`);return t}enqueue(...e){this.data=St(this.options,this.data,...e);let t=this.data.length;return this.onEnqueue(this.data,e),t}onEnqueue(e,t){this.fireEvent(`enqueue`,{added:t,finalData:e})}dequeue(){let e=wt(this.options,this.data);if(e!==void 0)return this.data=Ct(this.options,this.data),this.fireEvent(`dequeue`,{removed:e,finalData:this.data}),this.onRemoved([e],this.data),e}onRemoved(e,t){this.fireEvent(`removed`,{removed:e,finalData:t})}removeWhere(e){let t=this.data.length,n=this.data.filter(t=>e(t));return n.length===0?0:(this.data=this.data.filter(t=>!e(t)),this.onRemoved(n,this.data),t-this.data.length)}toArray(){return[...this.data]}get isEmpty(){return Tt(this.options,this.data)}get isFull(){return Et(this.options,this.data)}get length(){return this.data.length}get peek(){return wt(this.options,this.data)}};function Dt(e={},...t){return new b({...e},[...t])}var Ot=class extends b{constructor(e={}){e.eq===void 0&&(e={...e,eq:(e,t)=>a(e.item,t.item)}),super(e)}enqueueWithPriority(e,t){p(Te(t,`positive`)),super.enqueue({item:e,priority:t})}changePriority(e,t,n=!1,r){if(e===void 0)throw Error(`Item cannot be undefined`);let i;for(let t of this.data)if(r){if(r(t.item,e)){i=t;break}}else if(this.eq(t,{item:e,priority:0})){i=t;break}if(i===void 0&&!n)throw Error(`Item not found in priority queue. Item: ${JSON.stringify(e)}`);i!==void 0&&this.removeWhere(e=>i===e),this.enqueueWithPriority(e,t)}dequeueMax(){let e=g(Ne(this.data,(e,t)=>e.priority>=t.priority));if(e!==void 0)return this.removeWhere(t=>t===e),e.item}dequeueMin(){let e=g(Ne(this.data,(e,t)=>e.priority>=t.priority));if(e!==void 0)return this.removeWhere(t=>t.item===e),e.item}peekMax(){let e=g(Ne(this.data,(e,t)=>e.priority>=t.priority));if(e!==void 0)return e.item}peekMin(){let e=g(Pe(this.data,(e,t)=>e.priority>=t.priority));if(e!==void 0)return e.item}};function kt(e={}){return new Ot(e)}const At=(e,t)=>{let n=new Map(e.entries());for(let e of t){if(e[0]===void 0)throw Error(`key cannot be undefined`);if(e[1]===void 0)throw Error(`value cannot be undefined`);n.set(e[0],e[1])}return n},jt=(e,t)=>{let n=new Map(e.entries());for(let e of t){if(e.key===void 0)throw Error(`key cannot be undefined`);if(e.value===void 0)throw Error(`value cannot be undefined`);n.set(e.key,e.value)}return n},Mt=(e,t)=>e.has(t),x=(e,...t)=>{if(e===void 0)throw Error(`map parameter is undefined`);if(t===void 0)throw Error(`data parameter i.s undefined`);if(t.length===0)return e;let n=t[0];return n.key!==void 0&&n.value!==void 0?jt(e,t):At(e,t)},Nt=(e,t,n)=>{let r=new Map(e.entries());return r.set(t,n),r},Pt=(e,t)=>{let n=new Map(e.entries());return n.delete(t),n},S=e=>{if(e===void 0)return S([]);if(Array.isArray(e))return S(x(new Map,...e));let t=e;return{add:(...e)=>S(x(t,...e)),set:(e,n)=>S(Nt(t,e,n)),get:e=>t.get(e),delete:e=>S(Pt(t,e)),clear:()=>S(),has:e=>t.has(e),entries:()=>t.entries(),values:()=>t.values(),isEmpty:()=>t.size===0}};var Ft=class extends Map{defaultValue;constructor(e=0){super(),this.defaultValue=e}get(e){let t=super.get(e);return t===void 0?this.defaultValue:t}reset(e){return super.set(e,this.defaultValue),this.defaultValue}multiply(e,t){let n=super.get(e)??this.defaultValue;return n*=t,super.set(e,n),n}divide(e,t){let n=super.get(e)??this.defaultValue;return n/=t,super.set(e,n),n}mapValue(e){for(let[t,n]of this.entries()){let r=e(n,t);super.set(t,r)}}findValueMax(){if(this.size===0)return NaN;let e=Number.MIN_VALUE;for(let t of this.values())t>e&&(e=t);return e}findValueMin(){if(this.size===0)return NaN;let e=2**53-1;for(let t of this.values())t<e&&(e=t);return e}*keysByValue(e){for(let[t,n]of this.entries())n===e&&(yield t)}*entriesSorted(e){let t=[...this.entries()];e?t.sort(e):t.sort((e,t)=>e[1]-t[1]);for(let e of t)yield e}*filterKeysByValue(e){for(let[t,n]of this.entries())e(n)&&(yield t)}deleteKeys(e){let t=0;for(let n of e)super.delete(n)&&t++;return t}add(e,t=1){let n=super.get(e)??this.defaultValue;return n+=t,super.set(e,n),n}subtract(e,t=1){let n=super.get(e)??this.defaultValue;return n-=t,super.set(e,n),n}},C=class{rows=[];rowLabels=[];colLabels=[];columnMaxLength=0;getColumnLabelIndex(e){for(let[t,n]of this.colLabels.entries())if(n===e)return t}getRowLabelIndex(e){for(let[t,n]of this.rowLabels.entries())if(n===e)return t}print(){console.table([...this.rowsWithLabelsObject()])}asArray(){let e=[];for(let t of this.rows)t===void 0?e.push([]):e.push([...t]);return e}get rowCount(){return this.rows.length}get columnCount(){return this.columnMaxLength}*rowsWithLabelsObject(){for(let e=0;e<this.rows.length;e++)yield this.getRowWithLabelsObject(e)}*rowsWithLabelsArray(){for(let e=0;e<this.rows.length;e++)yield this.getRowWithLabelsArray(e)}labelColumns(...e){this.colLabels=e}labelColumn(e,t){this.colLabels[e]=t}labelRows(...e){this.rowLabels=e}labelRow(e,t){this.rowLabels[e]=t}appendRow(...e){return this.columnMaxLength=Math.max(this.columnMaxLength,e.length),this.rows.push(e),e}getRowWithLabelsArray(e){let t=this.rows.at(e);if(t!==void 0)return t.map((e,t)=>[this.colLabels.at(t),e])}getRowWithLabelsObject(e){let t=this.rows.at(e);if(t===void 0)return;let n={};for(let e=0;e<this.colLabels.length;e++){let r=this.colLabels.at(e)??e.toString();n[r]=t[e]}return n}#e(e){let t=typeof e==`number`?e:this.getRowLabelIndex(e);if(t===void 0)return{success:!1,error:`row-label-notfound`};if(t<0)return{success:!1,error:`row-index-invalid`};if(t<this.rows.length)return{success:!0,value:this.rows[t]};let n=[];return this.rows[t]=n,{success:!0,value:n}}row(e){let t=this.#t(e);if(f(t))throw Error(t.error);return[...t.value]}set(e,t,n){let r=this.#e(e);if(f(r))throw Error(r.error);let i=r.value,a=typeof t==`number`?t:this.getColumnLabelIndex(t);if(a===void 0)throw Error(`Column label '${t}' not found or is invalid`);if(a<0)throw Error(`Column index invalid (less than zero)`);i[a]=n}get(e,t){let n=this.#t(e);if(f(n))throw Error(n.error);let r=this.#n(n.value,t);if(f(r))throw Error(r.error);return r.value.value}#t(e){let t=0;if(typeof e==`number`)t=e;else if(t=this.getRowLabelIndex(e),typeof t!=`number`)return{error:`row-label-notfound`,success:!1};return typeof t==`number`?t<0||t>=this.rows.length?{error:`row-index-out-of-range`,success:!1}:{success:!0,value:this.rows[t]}:{error:`row-invalid`,success:!1}}#n(e,t){let n=typeof t==`number`?t:this.getColumnLabelIndex(t);return typeof n==`number`?n<0||n>=e.length?{success:!1,error:`col-index-out-of-range`}:{success:!0,value:{index:n,value:e[n]}}:{success:!1,error:`col-label-notfound`}}setRow(e,t,n){let r=this.#e(e);if(f(r))throw Error(r.error);let i=r.value,a=typeof n==`number`?n:this.columnMaxLength;for(let e=0;e<a;e++)i[e]=t;return i}},It=e({adjacentVertices:()=>Kt,areAdjacent:()=>an,bfs:()=>on,clone:()=>ln,connect:()=>tn,connectTo:()=>en,connectWithEdges:()=>nn,createVertex:()=>Lt,dfs:()=>sn,disconnect:()=>$t,distance:()=>Ut,distanceDefault:()=>Qt,dumpGraph:()=>Vt,edges:()=>Wt,get:()=>zt,getCycles:()=>mn,getOrCreate:()=>Xt,getOrFail:()=>Zt,graph:()=>un,graphFromVertices:()=>pn,hasKey:()=>Rt,hasNoOuts:()=>Jt,hasOnlyOuts:()=>Yt,hasOut:()=>T,isAcyclic:()=>dn,pathDijkstra:()=>cn,toAdjacencyMatrix:()=>Bt,topologicalSort:()=>fn,transitiveReduction:()=>hn,updateGraphVertex:()=>E,vertexHasOut:()=>qt,vertices:()=>Gt});const Lt=e=>({id:e,out:[]});function Rt(e,t){return p(w(e)),e.vertices.has(t)}function zt(e,t){return p(w(e)),p(Ee(t,`non-empty`,`key`)),e.vertices.get(t)}function Bt(e){p(w(e));let t=[...e.vertices.values()],n=new C;n.labelColumns(...t.map(e=>e.id)),n.labelRows(...t.map(e=>e.id));for(let e=0;e<t.length;e++){n.setRow(e,!1,t.length);let r=t[e];for(let[i,a]of t.entries())r.out.some(e=>e.id===a.id)&&n.set(e,i,!0)}return n}const Vt=e=>Ht(e).join(` `),Ht=e=>{let t=[],n=`vertices`in e?e.vertices.values():e;for(let e of n){let n=rn(e);t.push(...n.map(e=>` ${e}`))}return t},Ut=(e,t)=>t.weight===void 0?1:t.weight;function*Wt(e){p(w(e));let t=[...e.vertices.values()];for(let e of t)for(let t of e.out)yield t}function*Gt(e){p(w(e));let t=[...e.vertices.values()];for(let e of t)yield e}function w(e,t=`graph`){if(e===void 0)return{success:!1,error:`Param '${t}' is undefined. Expected Graph`};if(e===null)return{success:!1,error:`Param '${t}' is null. Expected Graph`};if(typeof e==`object`){if(!(`vertices`in e))return{success:!1,error:`Param '${t}.vertices' does not exist. Is it a Graph type?`}}else return{success:!1,error:`Param '${t} is type '${typeof e}'. Expected an object Graph`};return{success:!0,value:e}}function*Kt(e,t){if(p(w(e)),t===void 0)return;let n=typeof t==`string`?e.vertices.get(t):t;if(n===void 0)throw Error(`Vertex not found ${JSON.stringify(t)}`);for(let t of n.out){let n=e.vertices.get(t.id);if(n===void 0)throw Error(`Could not find vertex: ${t.id}`);yield n}}const qt=(e,t)=>{if(e===void 0)return!1;let n=typeof t==`string`?t:t.id;return e.out.some(e=>e.id===n)},Jt=(e,t)=>{p(w(e));let n=typeof t==`string`?e.vertices.get(t):t;return n===void 0?!1:n.out.length===0},Yt=(e,t,...n)=>{p(w(e));let r=D(e,t),i=n.map(t=>D(e,t));if(i.length!==r.out.length)return!1;for(let t of i)if(!T(e,r,t))return!1;return!0},T=(e,t,n)=>{p(w(e));let r=D(e,t),i=typeof n==`string`?n:n.id;return r.out.some(e=>e.id===i)},Xt=(e,t)=>{p(w(e));let n=e.vertices.get(t);if(n!==void 0)return{graph:e,vertex:n};let r=Lt(t);return{graph:E(e,r),vertex:r}},Zt=(e,t)=>{p(w(e));let n=e.vertices.get(t);if(n===void 0)throw Error(`Vertex '${t}' not found in graph`);return n},E=(e,t)=>(p(w(e)),{...e,vertices:e.vertices.set(t.id,t)}),Qt=(e,t)=>t.weight===void 0?1:t.weight;function $t(e,t,n){p(w(e));let r=D(e,t),i=D(e,n);return T(e,r,i)?E(e,{...r,out:r.out.filter(e=>e.id!==i.id)}):e}function en(e,t,n,r){p(w(e));let i=Xt(e,t);e=i.graph;let a=Xt(e,n);e=a.graph;let o={id:n,weight:r};return T(e,i.vertex,a.vertex)||(e=E(e,{...i.vertex,out:[...i.vertex.out,o]})),{graph:e,edge:o}}function tn(e,t){if(typeof e!=`object`)throw TypeError(`Param 'graph' is expected to be a DirectedGraph object. Got: ${typeof e}`);if(typeof t!=`object`)throw TypeError(`Param 'options' is expected to be ConnectOptions object. Got: ${typeof t}`);return nn(e,t).graph}function nn(e,t){p(w(e));let{to:n,weight:r,from:i}=t,a=t.bidi??!1,o=Array.isArray(n)?n:[n],s=[];for(let t of o){let n=en(e,i,t,r);e=n.graph,s.push(n.edge)}if(!a)return{graph:e,edges:s};for(let t of o){let n=en(e,t,i,r);e=n.graph,s.push(n.edge)}return{graph:e,edges:s}}const rn=e=>{let t=[e.id],n=e=>e.weight===void 0?e.id:`${e.id} (${e.weight})`;for(let r of e.out)t.push(` -> ${n(r)}`);return e.out.length===0&&(t[0]+=` (terminal)`),t};function an(e,t,n){if(p(w(e)),T(e,t,n.id)||T(e,n,t.id))return!0}function D(e,t){if(p(w(e)),t===void 0)throw Error(`Param 'idOrVertex' is undefined. Expected string or Vertex`);let n=typeof t==`string`?e.vertices.get(t):t;if(n===void 0)throw Error(`Id not found ${t}`);return n}function*on(e,t,n){p(w(e));let r=D(e,t),i=n===void 0?void 0:D(e,n),a=new b,o=new Set;for(a.enqueue(r);!a.isEmpty;){let t=a.dequeue();if(yield t,i!==void 0&&i===t)return;for(let n of Kt(e,t))o.has(n.id)||(o.add(n.id),a.enqueue(D(e,n.id)))}}function*sn(e,t){p(w(e));let n=D(e,t),r=new y,i=new Set;for(r.push(n);!r.isEmpty;){let t=r.pop();if(t!==void 0&&!i.has(t.id)){i.add(t.id),yield t;for(let n of t.out){let t=e.vertices.get(n.id);t&&r.push(t)}}}}const cn=(e,t)=>{p(w(e));let n=typeof t==`string`?e.vertices.get(t):t;if(n===void 0)throw Error(`source vertex not found`);let r=new Map,i=new Map;r.set(n.id,0);let a=new Ot,o=[...e.vertices.values()];for(let e of o)e.id!==n.id&&(r.set(e.id,2**53-1),i.set(e.id,null)),a.enqueueWithPriority(e.id,2**53-1);for(;!a.isEmpty;){let t=a.dequeueMin();if(t===void 0)throw Error(`Bug. Queue unexpectedly empty`);let n=e.vertices.get(t);for(let o of n.out){let s=r.get(t)+Ut(e,o);s<r.get(o.id)&&(r.set(o.id,s),i.set(o.id,n),a.changePriority(o.id,s,!0))}}return{distances:r,previous:i,pathTo:e=>{let t=[];for(;e!==n.id;){let n=i.get(e);if(n==null)throw Error(`Id not present: ${e}`);t.push({id:e,weight:r.get(e)}),e=n.id}return t}}},ln=e=>(p(w(e)),{vertices:S([...e.vertices.entries()])}),un=(...e)=>{let t={vertices:S()};for(let n of e)t=tn(t,n);return t};function dn(e){return p(w(e)),mn(e).length===0}function fn(e){p(w(e));let t=new Ft(0);for(let n of Wt(e))t.add(n.id,1);let n=new b,r=0;for(let i of Gt(e))t.get(i.id)===0&&n.enqueue(i),r++;let i=[];for(;!n.isEmpty;){let r=n.dequeue();i.push(r);for(let i of r.out)t.subtract(i.id,1)===0&&n.enqueue(e.vertices.get(i.id))}if(i.length!==r)throw Error(`Graph contains cycles`);return pn(i)}function pn(e){return{vertices:S([...Me(e,e=>[e.id,e])])}}function mn(e){p(w(e));let t=0,n=new y,r=new Map,i=[];for(let t of e.vertices.values())r.set(t.id,{...t,lowlink:NaN,index:NaN,onStack:!1});let a=e=>{e.index=t,e.lowlink=t,t++,n.push(e),e.onStack=!0;for(let t of e.out){let n=r.get(t.id);Number.isNaN(n.index)?(a(n),e.lowlink=Math.min(e.lowlink,n.lowlink)):n.onStack&&(e.lowlink=Math.min(e.lowlink,n.lowlink))}if(e.lowlink===e.index){let t=[],r;for(;e!==r;)r=n.pop(),r.onStack=!1,t.push({id:r.id,out:r.out});t.length>1&&i.push(t)}};for(let e of r.values())Number.isNaN(e.index)&&a(e);return i}function hn(e){p(w(e));for(let t of Gt(e))for(let n of Kt(e,t))for(let r of sn(e,n))if(n.id!==r.id&&T(e,t,r))return hn($t(e,t,r));return e}var gn=e({adjacentVertices:()=>An,connect:()=>Cn,connectTo:()=>Sn,connectWithEdges:()=>wn,createVertex:()=>_n,dumpGraph:()=>Dn,edgesForVertex:()=>jn,getConnection:()=>xn,getOrCreate:()=>yn,graph:()=>Tn,hasConnection:()=>bn,toAdjacencyMatrix:()=>En,updateGraphVertex:()=>vn});const _n=e=>({id:e}),vn=(e,t)=>({...e,vertices:e.vertices.set(t.id,t)}),yn=(e,t)=>{let n=e.vertices.get(t);if(n!==void 0)return{graph:e,vertex:n};let r=_n(t);return{graph:vn(e,r),vertex:r}};function O(e,t){if(typeof t!=`string`&&typeof t!=`object`)throw TypeError(`Param 'idOrVertex' is undefined. Expected string or Vertex. Got: ${typeof t}`);if(typeof e!=`object`)throw TypeError(`Param 'graph' is expected to be object. Got: ${typeof e}`);let n=typeof t==`string`?e.vertices.get(t):t;if(n===void 0)throw Error(`Id not found ${t}`);return n}const bn=(e,t,n)=>xn(e,t,n)!==void 0,xn=(e,t,n)=>{let r=O(e,t),i=O(e,n);for(let t of e.edges)if(t.a==r.id&&t.b===i.id||t.a==i.id&&t.b===r.id)return t};function Sn(e,t,n,r){e=yn(e,t).graph,e=yn(e,n).graph;let i=xn(e,t,n);return i===void 0?(i={a:t,b:n,weight:r},{graph:{...e,edges:[...e.edges,i]},edge:i}):{graph:e,edge:i}}function Cn(e,t){return wn(e,t).graph}function wn(e,t){let{a:n,weight:r,b:i}=t,a=Array.isArray(i)?i:[i],o=[];for(let t of a){let i=Sn(e,n,t,r);e=i.graph,o.push(i.edge)}return{graph:e,edges:o}}const Tn=(...e)=>{let t={vertices:S(),edges:[]};for(let n of e)t=Cn(t,n);return t};function En(e){let t=[...e.vertices.values()],n=new C;n.labelColumns(...t.map(e=>e.id)),n.labelRows(...t.map(e=>e.id));for(let r=0;r<t.length;r++){n.setRow(r,!1,t.length);let i=t[r];for(let[a,o]of t.entries())bn(e,i,o)&&n.set(r,a,!0)}return n}const Dn=e=>On(e).join(` `),On=e=>{let t=[];t.push(`Vertices: ${[...e.vertices.values()].map(e=>e.id).join(`, `)}`),t.push(`Edges:`);for(let n of e.edges)t.push(kn(n));return t},kn=e=>{let t=e.weight?` (${e.weight})`:``;return`${e.a} <-> ${e.b}${t}`};function*An(e,t){if(t!==void 0){if((typeof t==`string`?e.vertices.get(t):t)===void 0)throw Error(`Vertex not found ${JSON.stringify(t)}`);for(let n of e.edges)n.a===t?yield O(e,n.b):n.b===t&&(yield O(e,n.a))}}function*jn(e,t){if(typeof e!=`object`)throw TypeError(`Param 'graph' is expected to be an object. Got: ${typeof e}`);if(t!==void 0){if((typeof t==`string`?e.vertices.get(t):t)===void 0)throw Error(`Vertex not found ${JSON.stringify(t)}`);for(let n of e.edges)(n.a===t||n.b===t)&&(yield n)}}var Mn=e({Directed:()=>It,Undirected:()=>gn});const Nn=(e={})=>new k(e);var k=class extends h{capacity;store;evictPolicy;autoDeleteElapsedMs;autoDeletePolicy;autoDeleteTimer;disposed=!1;constructor(e={}){if(super(),this.capacity=e.capacity??-1,p(Oe(this.capacity,`nonZero`,`capacity`)),this.store=new Map,e.evictPolicy&&this.capacity<=0)throw Error(`evictPolicy is set, but no capacity limit is set`);this.evictPolicy=e.evictPolicy??`none`,this.autoDeleteElapsedMs=e.autoDeleteElapsedMs??-1,this.autoDeletePolicy=e.autoDeletePolicy??`none`,this.autoDeleteElapsedMs>0&&(this.autoDeleteTimer=setInterval(()=>{this.#e()},Math.max(1e3,this.autoDeleteElapsedMs*2)))}dispose(){this.disposed||(this.disposed=!0,this.autoDeleteTimer&&=(clearInterval(this.autoDeleteTimer),void 0))}get keyLength(){return this.store.size}*entries(){for(let e of this.store.entries())yield[e[0],e[1].value]}*values(){for(let e of this.store.values())yield e.value}*keys(){yield*this.store.keys()}elapsedSet(e){let t=this.store.get(e);if(t!==void 0)return Date.now()-t.lastSet}elapsedGet(e){let t=this.store.get(e);if(t!==void 0)return Date.now()-t.lastGet}has(e){return this.store.has(e)}get(e){let t=this.store.get(e);if(t)return(this.autoDeletePolicy===`either`||this.autoDeletePolicy===`get`)&&this.store.set(e,{...t,lastGet:performance.now()}),t.value}delete(e){let t=this.store.get(e);if(!t)return!1;let n=this.store.delete(e);return this.fireEvent(`removed`,{key:e,value:t.value}),n}clear(){this.store.clear()}touch(e){let t=this.store.get(e);return t?(this.store.set(e,{...t,lastSet:Date.now(),lastGet:Date.now()}),!0):!1}findEvicteeKey(){if(this.evictPolicy===`none`)return;let e=``;if(this.evictPolicy===`oldestGet`)e=`lastGet`;else if(this.evictPolicy===`oldestSet`)e=`lastSet`;else throw Error(`Unknown eviction policy ${this.evictPolicy}`);return we(this.store,e)[0][0]}#e(){this.autoDeletePolicy!==`none`&&this.deleteWithElapsed(this.autoDeleteElapsedMs,this.autoDeletePolicy)}deleteWithElapsed(e,t){let n=[...this.store.entries()],r=[],i=de(e,1e3),a=performance.now();for(let e of n){let n=a-e[1].lastGet,o=a-e[1].lastSet;(t===`get`?n:t===`set`?o:Math.max(n,o))>=i&&r.push([e[0],e[1].value])}for(let e of r){this.store.delete(e[0]);let t={key:e[0],value:e[1]};this.fireEvent(`expired`,t),this.fireEvent(`removed`,t)}return r}set(e,t){let n=this.store.get(e);if(n){this.store.set(e,{...n,lastSet:performance.now()});return}if(this.keyLength===this.capacity&&this.capacity>0){let e=this.findEvicteeKey();if(!e)throw Error(`ExpiringMap full (capacity: ${this.capacity})`);let t=this.store.get(e);if(this.store.delete(e),t){let n={key:e,value:t.value};this.fireEvent(`expired`,n),this.fireEvent(`removed`,n)}}this.store.set(e,{lastGet:0,lastSet:performance.now(),value:t}),this.fireEvent(`newKey`,{key:e,value:t})}};const Pn=(e,t)=>{for(let n of e.entries()){let e=n[1];for(let r of e)if(t(r,n[0]))return n}},Fn=e=>{if(typeof e!=`object`)throw TypeError(`Param 'map' is not an object. Got: ${typeof e}`);if(!(`entries`in e))throw TypeError(`Param 'map' does not have 'entries' function`);let t,n=-(2**53-1);for(let r of e.entries()){let e=r[1];if(typeof e!=`object`)throw TypeError(`All items in map are expected to be an object type. Got: ${typeof e}`);if(!(`length`in e))throw TypeError(`All items in map must have a 'length' field`);e.length>n&&(t=r)}return t},In=(e,t,n=a)=>{if(typeof e!=`object`)throw TypeError(`Param 'map' is expected to be an object. Got: ${typeof e}`);if(!(`entries`in e))throw TypeError(`Param 'map' is expected to have 'entries()'`);for(let r of e.entries()){let e=r[1];for(let i of e)if(n(i,t))return r}},Ln=e=>{let t=[...e.entries()].map(e=>[e[0],[...e[1]]]);return new Map(t)},Rn=(e,t,n=a)=>{let r=[...e.entries()],i=[...t.entries()];if(r.length!==i.length)return!1;for(let e of r){let t=i.find(t=>t[0]===e[0]);if(!t||!ke(Array.from(e[1]),Array.from(t[1]),n))return!1}return!0};var zn=class{map;groupBy;valueEq;constructor(e=d,t=a,n=[]){this.groupBy=e,this.valueEq=t,Array.isArray(n)?this.map=new Map(n):this.map=new Map(n.entries())}get getRawMapUnsafe(){return this.map}has(e){return this.map.has(e)}hasKeyValue(e,t){let n=this.map.get(e);if(!n)return!1;for(let e of n)if(this.valueEq(e,t))return!0;return!1}debugString(){let e=``;return[...this.map.keys()].every(t=>{let n=this.map.get(t);n!==void 0&&(e+=`${t} (${n.length}) = ${JSON.stringify(n)}\r\n`)}),e}count(e){let t=this.map.get(e);return t?t.length:0}firstKeyByValue(e,t=a){let n=In(this,e,t);if(n)return n[0]}*entriesFlat(){for(let e of this.map.entries())for(let t of e[1])yield[e[0],t]}*entries(){for(let[e,t]of this.map.entries())yield[e,[...t]]}*valuesFor(e){let t=this.map.get(e);t&&(yield*t.values())}*keys(){yield*this.map.keys()}*valuesFlat(){for(let e of this.map)yield*e[1]}getRawArray(e){let t=this.map.get(e);if(t)return t}*values(){for(let e of this.map)yield e[1]}*keysAndCounts(){for(let e of this.map)yield[e[0],e[1].length]}get lengthKeys(){return this.map.size}get isEmpty(){return this.map.size===0}},A=class extends zn{addKeyedValues(e,...t){let n=this.map.get(e);n===void 0?this.map.set(e,t):this.map.set(e,[...n,...t])}setValues(e,t){this.map.set(e,t)}addValue(...e){for(let t of e){let e=this.groupBy(t);this.addKeyedValues(e,t)}}deleteKeyValue(e,t){let n=this.map.get(e);if(n===void 0)return!1;let r=n.filter(e=>!this.valueEq(e,t));return this.map.set(e,r),r.length<n.length}deleteByValue(e){let t=!1,n=[...this.map.entries()];for(let r of n)for(let n of r[1])this.valueEq(n,e)&&(t=!0,this.deleteKeyValue(r[0],e));return t}delete(e){let t=this.map.get(e);return!t||t.length===0?!1:(this.map.delete(e),!0)}clear(){this.map.clear()}};function Bn(e=d,t=a){return new A(e,t)}const Vn=(...e)=>{let t=x(new Map,...e);return{add:(...e)=>{t=x(t,...e)},delete:e=>{t=Pt(t,e)},clear:()=>{t=x(new Map)},set:(e,n)=>{t=Nt(t,e,n)},get:e=>t.get(e),entries:()=>t.entries(),values:()=>t.values(),isEmpty:()=>t.size===0,has:e=>Mt(t,e)}};var j=class extends h{#e=new Map;groupBy;type;constructor(e,t={}){super(),this.type=e,this.groupBy=t.groupBy??o}get typeName(){return this.type.name}get lengthKeys(){return this.#e.size}get lengthMax(){let e=0;for(let t of this.#e.values())e=Math.max(e,this.type.count(t));return e}debugString(){let e=[...this.#e.keys()],t=`Keys: ${e.join(`, `)}\r\n`;for(let n of e){let e=this.#e.get(n);if(e===void 0)t+=` - ${n} (undefined)\r\n`;else{let r=this.type.toArrayCopy(e);r!==void 0&&(t+=` - ${n} (${this.type.count(e)}) = ${JSON.stringify(r)}\r\n`)}}return t}get isEmpty(){return this.#e.size===0}clear(){this.#e.clear(),super.fireEvent(`clear`,!0)}addKeyedValues(e,...t){let n=this.#e.get(e);n===void 0?(this.#e.set(e,this.type.addKeyedValues(void 0,t)),super.fireEvent(`addedKey`,{key:e}),super.fireEvent(`addedValues`,{values:t})):(this.#e.set(e,this.type.addKeyedValues(n,t)),super.fireEvent(`addedValues`,{values:t}))}set(e,t){return this.addKeyedValues(e,...t),this}addValue(...e){for(let t of e)this.addKeyedValues(this.groupBy(t),t)}hasKeyValue(e,t,n){let r=this.#e.get(e);return r===void 0?!1:this.type.has(r,t,n)}has(e){return this.#e.has(e)}deleteKeyValue(e,t){let n=this.#e.get(e);return n===void 0?!1:this.deleteKeyValueFromMap(n,e,t)}deleteKeyValueFromMap(e,t,n){let r=this.type.count(e),i=this.type.without(e,n),a=i.length;return this.#e.set(t,this.type.addKeyedValues(void 0,i)),r>a}deleteByValue(e){let t=!1;return[...this.#e.keys()].filter(n=>{let r=this.#e.get(n);if(!r)throw Error(`Bug: map could not be accessed`);this.deleteKeyValueFromMap(r,n,e)&&(t=!0,this.count(n)===0&&this.delete(n))}),t}delete(e){return this.#e.get(e)===void 0?!1:(this.#e.delete(e),this.fireEvent(`deleteKey`,{key:e}),!0)}firstKeyByValue(e,t=a){return[...this.#e.keys()].find(n=>{let r=this.#e.get(n);if(r===void 0)throw Error(`Bug: map could not be accessed`);return this.type.has(r,e,t)})}count(e){let t=this.#e.get(e);return t===void 0?0:this.type.count(t)}*valuesFor(e){let t=this.#e.get(e);t!==void 0&&(yield*this.type.iterable(t))}getSource(e){return this.#e.get(e)}*keys(){yield*this.#e.keys()}*entriesFlat(){for(let e of this.#e.entries())for(let t of this.type.iterable(e[1]))yield[e[0],t]}*valuesFlat(){for(let e of this.#e.entries())yield*this.type.iterable(e[1])}*entries(){for(let[e,t]of this.#e.entries())yield[e,[...this.type.iterable(t)]]}*keysAndCounts(){for(let e of this.keys())yield[e,this.count(e)]}merge(e){for(let t of e.keys())this.addKeyedValues(t,...e.valuesFor(t))}get size(){return this.#e.size}get[Symbol.toStringTag](){return this.#e[Symbol.toStringTag]}};const Hn=e=>{let t=e?.hash??o,n=(e,n)=>t(e)===t(n);return new j({get name(){return`set`},iterable:e=>e.values(),addKeyedValues:(e,n)=>ne(e,t,`skip`,...n),count:e=>e.size,find:(e,t)=>ie(e,t),filter:(e,t)=>be(e,t),toArrayCopy:e=>ae(e),has:(e,t)=>se(e,t,n),without:(e,t)=>je(ae(e),t,n)},e)},Un=e=>{let t=a;return new j({get name(){return`circular`},addKeyedValues:(t,n)=>{let r=t??new Ie(e.capacity);for(let e of n)r=r.add(e);return r},count:e=>e.length,find:(e,t)=>e.find(t),filter:(e,t)=>e.filter(t),toArrayCopy:e=>[...e],iterable:e=>e.values(),has:(e,n)=>e.find(e=>t(e,n))!==void 0,without:(e,n)=>e.filter(e=>!t(e,n))},e)},Wn=(e={})=>{let t=e.convertToString,n=t===void 0?a:(e,n)=>t(e)===t(n),r=e.comparer??n;return new j({get name(){return`array`},addKeyedValues:(e,t)=>e===void 0?[...t]:[...e,...t],iterable:e=>e.values(),count:e=>e.length,find:(e,t)=>e.find(e=>t(e)),filter:(e,t)=>e.filter(e=>t(e)),toArrayCopy:e=>[...e],has:(e,t)=>e.some(e=>r(e,t)),without:(e,t)=>e.filter(e=>!r(e,t))},e)};var Gn=class e extends zn{addKeyedValues(e,...t){return this.addBatch([[e,t]])}addValue(...t){let n=new A(this.groupBy,this.valueEq,this.getRawMapUnsafe);return n.addValue(...t),new e(this.groupBy,this.valueEq,[...n.entries()])}addBatch(t){let n=new A(this.groupBy,this.valueEq,this.getRawMapUnsafe);for(let e of t)n.addKeyedValues(e[0],...e[1]);return new e(this.groupBy,this.valueEq,[...n.entries()])}clear(){return new e(this.groupBy,this.valueEq)}deleteKeyValue(t,n,r){let i=r??this.valueEq,a=[...this.map.entries()].map(e=>{let r=e[0];return r===t?[r,e[1].filter(e=>!i(e,n))]:e}).filter(e=>e[1].length>0);return new e(this.groupBy,this.valueEq,a)}deleteByValue(t,n){let r=[...this.map.entries()],i=n??this.valueEq,a=r.map(e=>[e[0],e[1].filter(e=>!i(e,t))]).filter(e=>e[1].length>0);return new e(this.groupBy,this.valueEq,a)}delete(t){let n=[...this.map.entries()].filter(e=>e[0]!==t);return new e(this.groupBy,this.valueEq,n)}};const Kn=(e=d,t=a)=>new Gn(e,t);var qn=class extends h{#e=new Map;add(...e){for(let t of e)`key`in t&&`value`in t?this.set(t.key,t.value):this.set(t[0],t[1])}set(e,t){let n=this.#e.has(e);this.#e.set(e,t);let r={key:e,value:t};n?this.fireEvent(`key-added`,r):this.fireEvent(`key-updated`,r),this.fireEvent(`added`,r)}delete(e){let t=this.#e.get(e);t!==void 0&&(this.#e.delete(e),this.fireEvent(`removed`,{key:e,value:t}))}clear(){this.#e.clear(),this.fireEvent(`cleared`,void 0)}get(e){return this.#e.get(e)}has(e){return this.#e.has(e)}isEmpty(){return this.#e.size===0}entries(){return this.#e.entries()}values(){return this.#e.values()}},Jn=e({ExpiringMap:()=>k,MapOfMutableImpl:()=>j,MapOfSimple:()=>Gn,MapOfSimpleMutable:()=>A,MapWithEvents:()=>qn,NumberMap:()=>Ft,addObjectEntriesMutate:()=>te,addValue:()=>ne,addValueMutate:()=>c,addValueMutator:()=>t,cloneShallow:()=>Ln,deleteByValueCompareMutate:()=>ce,equals:()=>Rn,expiringMap:()=>Nn,filterValues:()=>be,findBySomeKey:()=>he,findEntryByPredicate:()=>ve,findEntryByValue:()=>fe,findValue:()=>ie,firstEntry:()=>Pn,firstEntryByValue:()=>In,fromIterable:()=>ge,fromObject:()=>ye,getClosestIntegerKey:()=>oe,getOrGenerate:()=>pe,getOrGenerateSync:()=>xe,hasAnyValue:()=>se,hasKeyValue:()=>le,immutable:()=>S,longestEntry:()=>Fn,mapOfSimpleMutable:()=>Bn,mapToArray:()=>_e,mapToObjectTransform:()=>me,mergeByKey:()=>ue,mutable:()=>Vn,ofArrayMutable:()=>Wn,ofCircularMutable:()=>Un,ofSetMutable:()=>Hn,ofSimple:()=>Kn,ofSimpleMutable:()=>Bn,some:()=>re,sortByValue:()=>Se,sortByValueProperty:()=>we,toArray:()=>ae,toObject:()=>Ce,transformMap:()=>ee,zipKeyValue:()=>r}),M=class e{opts;#e;constructor(e={},t=[]){if(e===void 0)throw Error(`opts parameter undefined`);this.opts=e,this.#e=t}forEach(e){for(let t=this.#e.length-1;t>=0;t--)e(this.#e[t])}forEachFromFront(e){this.#e.forEach(t=>{e(t)})}enqueue(...t){return new e(this.opts,St(this.opts,this.#e,...t))}dequeue(){return new e(this.opts,Ct(this.opts,this.#e))}get isEmpty(){return Tt(this.opts,this.#e)}get isFull(){return Et(this.opts,this.#e)}get length(){return this.#e.length}get peek(){return wt(this.opts,this.#e)}toArray(){return[...this.#e]}};const Yn=(e={},...t)=>(e={...e},new M(e,[...t]));var Xn=e({PriorityMutable:()=>Ot,QueueImmutable:()=>M,QueueMutable:()=>b,debug:()=>bt,dequeue:()=>Ct,enqueue:()=>St,immutable:()=>Yn,isEmpty:()=>Tt,isFull:()=>Et,mutable:()=>Dt,peek:()=>wt,priority:()=>kt,trimQueue:()=>xt});const Zn=e=>new N(e);var N=class extends h{store=new Map;keyString;constructor(e){super(),this.keyString=e??d}get size(){return this.store.size}add(...e){let t=!1;for(let n of e){let e=this.has(n);this.store.set(this.keyString(n),n),super.fireEvent(`add`,{value:n,updated:e}),e||(t=!0)}return t}values(){return this.store.values()}clear(){this.store.clear(),super.fireEvent(`clear`,!0)}delete(e){let t=this.store.delete(this.keyString(e));return t&&super.fireEvent(`delete`,e),t}has(e){return this.store.has(this.keyString(e))}toArray(){return[...this.store.values()]}},P=class e{store;keyString;constructor(e,t){this.store=t??new Map,this.keyString=e??d}get size(){return this.store.size}add(...t){let n=new Map(this.store);for(let e of t){let t=this.keyString(e);n.set(t,e)}return new e(this.keyString,n)}delete(t){let n=new Map(this.store),r=this.keyString(t);return n.delete(r)?new e(this.keyString,n):this}has(e){let t=this.keyString(e);return this.store.has(t)}toArray(){return[...this.store.values()]}*values(){yield*this.store.values()}};const Qn=(e=o)=>new P(e);var $n=class e{#e;#t;children=new Map;values=[];constructor(e=1,t=0){this.#e=t,this.#t=e}sizeLocal(){return this.values.length}sizeChildren(){return[...this.children.values()].length}sizeChildrenDeep(){let e=this.sizeChildren();for(let t of this.children.values())e+=t.sizeChildrenDeep();return e}size(){let e=this.values.length;for(let t of this.children.values())e+=t.size();return e}add(e){if(typeof e!=`string`)throw Error(`Param 'value' must be a string. Got: ${typeof e}`);if(e.length===0)throw Error(`Param 'value' is empty`);let t=this.#r(e,!0);if(t===this){this.hasLocal(e)||this.values.push(e);return}if(!t)throw Error(`Could not create child set for: ${e}`);t.add(e)}remove(e){if(typeof e!=`string`)throw Error(`Param 'value' must be a string. Got: ${typeof e}`);if(e.length===0)throw Error(`Param 'value' is empty`);let t=this.#r(e,!1);return t===void 0?!1:t===this?this.hasLocal(e)?(this.values=this.values.filter(t=>t!==e),!0):!1:t.remove(e)}debugDump(){let e=this.#n();for(let t of e)console.log(t)}#n(e=0){let t=[];t.push(`Depth: ${this.#e} Max: ${this.#t}`);for(let[n,r]of this.children.entries()){let i=r.#n(e+1);t.push(` key: ${n}`);for(let n of i)t.push(` `.repeat(e+1)+n)}t.push(`Values: (${this.values.length})`);for(let e of this.values)t.push(` ${e}`);return t.map(t=>` `.repeat(e)+t)}#r(t,n){if(t===void 0)throw Error(`Param 'value' undefined`);if(this.#e===this.#t||t.length<=this.#e)return this;let r=t[this.#e];if(r===void 0)throw Error(`Logic error. Depth: ${this.#e} Len: ${t.length}`);let i=this.children.get(r);return i===void 0&&n&&(i=new e(this.#t,this.#e+1),this.children.set(r,i)),i}hasLocal(e){for(let t of this.values)if(t===e)return!0;return!1}has(e){if(typeof e!=`string`)return!1;let t=this.#r(e,!1);return t===void 0?!1:t===this?this.hasLocal(e):t.has(e)}},er=e({MassiveSet:()=>$n,SetStringImmutable:()=>P,SetStringMutable:()=>N,immutable:()=>Qn,mutable:()=>Zn}),tr=class e{opts;data;constructor(e={},t=[]){this.opts=e,this.data=t}push(...t){return new e(this.opts,mt(this.opts,this.data,...t))}pop(){return new e(this.opts,ht(this.opts,this.data))}forEach(e){this.data.forEach(e)}forEachFromTop(e){[...this.data].reverse().forEach(e)}get isEmpty(){return _t(this.opts,this.data)}get isFull(){return vt(this.opts,this.data)}get peek(){return gt(this.opts,this.data)}get length(){return this.data.length}};const nr=(e={},...t)=>new tr({...e},[...t]);var rr=e({StackImmutable:()=>tr,StackMutable:()=>y,immutable:()=>nr,isEmpty:()=>_t,isFull:()=>vt,mutable:()=>yt,peek:()=>gt,pop:()=>ht,push:()=>mt,trimStack:()=>pt});const ir=(e,t,n=s,r)=>{let i=sr(e,t,n),a=or(e,t,n),o={valueChanged:!i,a:e,b:t,added:a.added,removed:a.removed,childChanged:!1},c={value:o,childrenStore:[],parent:r},ee=a.identical.map(e=>ir(e[0],e[1],n,c)),te=ar(o)||ee.some(e=>ar(e.value));return Gr(c,ee),c.toString=()=>lr(c,0),c.value.childChanged=te,xr(c),c},ar=e=>e===void 0?!1:!!(e.valueChanged||e.childChanged||e.added.length>0||e.removed.length>0),or=(e,t,n=s)=>{let r=[...e.children()],i=[...t.children()],a=[],o=[];for(let e of r){let t=-1;for(let[r,o]of i.entries())if(sr(e,o,n)){a.push([e,o]),t=r;break}t===-1?o.push(e):i.splice(t,1)}return{added:[...i],identical:a,removed:o}},sr=(e,t,n)=>!!(e.getIdentity()===t.getIdentity()||n(e.getValue(),t.getValue())),cr=e=>JSON.stringify(e.getValue()),lr=(e,t=0)=>{if(e===void 0)return`(undefined)`;let n=ur(e.value,t);for(let r of e.childrenStore)n+=lr(r,t+2);return n},ur=(e,t)=>{let n=` `.repeat(t);if(e===void 0)return`${n}(undefined)`;let r=[];if(r.push(`a: ${cr(e.a)} b: ${cr(e.b)}`),e.valueChanged?r.push(`Value changed. Child changed: ${e.childChanged}`):r.push(`Value unchanged. Child changed: ${e.childChanged}`),e.added.length>0){r.push(`Added:`);for(let t of e.added)r.push(` - `+cr(t))}if(e.removed.length>0){r.push(`Removed: ${e.removed.length}`);for(let t of e.removed)r.push(` - `+cr(t))}return r.push(`---- `),r.map(e=>n+e).join(` `)};var dr=e({add:()=>Rr,addValue:()=>zr,asDynamicTraversable:()=>B,breadthFirst:()=>yr,children:()=>Sr,childrenLength:()=>Hr,childrenValues:()=>Cr,compare:()=>fr,computeMaxDepth:()=>Ir,createNode:()=>z,depthFirst:()=>vr,findAnyChildByValue:()=>kr,findChildByValue:()=>Er,findParentsValue:()=>Pr,followValue:()=>qr,fromPlainObject:()=>Br,getRoot:()=>Ar,hasAnyChild:()=>Or,hasAnyParent:()=>jr,hasChild:()=>Tr,hasParent:()=>Fr,nodeDepth:()=>wr,parents:()=>L,parentsValues:()=>Mr,queryByValue:()=>Dr,queryParentsValue:()=>Nr,remove:()=>hr,removeValuelessNodesFromChild:()=>gr,root:()=>R,rootWrapped:()=>Vr,setChildren:()=>Gr,siblings:()=>_r,stripParentage:()=>pr,throwTreeTest:()=>xr,toStringDeep:()=>Kr,treeTest:()=>br,value:()=>Ur,wrap:()=>I});function fr(e,t,n){return ir(B(e),B(t),n)}function pr(e){return{value:e.value,childrenStore:e.childrenStore.map(e=>pr(e))}}const F=e=>`wraps`in e?e.wraps:e,mr=e=>`wraps`in e?e:I(e);function I(e){return{*children(){for(let t of e.childrenStore)yield I(t)},getValue:()=>e.value,getIdentity:()=>e,*queryValue(t){for(let n of Dr(t,F(e)))yield I(n)},*queryParentsValue(e,t,n){for(let r of Nr(F(e),t,n))yield I(r)},*parentsValues(e){yield*Mr(F(e))},findParentsValue(e,t,n){let r=Pr(e,t,n);if(r!==void 0)return I(r)},getParent:()=>e.parent===void 0?void 0:I(e.parent),hasParent:t=>Fr(e,F(t)),hasAnyParent:t=>jr(e,F(t)),hasChild:t=>Tr(F(t),e),hasAnyChild:t=>Or(F(t),e),remove:()=>{hr(e)},addValue:t=>I(zr(t,e)),add:t=>(Rr(F(t),e),mr(t)),wraps:e}}function hr(e){let t=e.parent;if(t===void 0)return!1;e.parent=void 0;let n=t.childrenStore.length;return t.childrenStore=je(t.childrenStore,e),n!==t.childrenStore.length}function gr(e){if(e.value!==void 0)return!1;let t=e.parent;if(!t)return!1;let n=[..._r(e)];return hr(e),n.length===0?gr(t):!0}function*_r(e,t=a){let n=e.parent;if(n!==void 0)for(let r of n.childrenStore)t(r,e)||(yield r)}function*vr(e){if(!R)return;let t=new y;t.push(...e.childrenStore);let n=t.pop();for(;n&&(yield n,n&&t.push(...n.childrenStore),!t.isEmpty);)n=t.pop()}function*yr(e){if(!e)return;let t=new b;t.enqueue(...e.childrenStore);let n=t.dequeue();for(;n&&(yield n,n&&t.enqueue(...n.childrenStore),!t.isEmpty);)n=t.dequeue()}function br(e,t=[]){if(e.parent===e)return[!1,`Root has itself as parent`,e];if(t.includes(e))return[!1,`Same node instance is appearing further in tree`,e];if(t.push(e),Ae(e.childrenStore))return[!1,`Children list contains duplicates`,e];for(let n of e.childrenStore){if(n.parent!==e)return[!1,`Member of childrenStore does not have .parent set`,n];if(Or(e,n))return[!1,`Child has parent as its own child`,n];let r=br(n,t);if(!r[0])return r}return[!0,``,e]}function xr(e){let t=br(e);if(!t[0])throw Error(`${t[1]} Node: ${u(t[2].value,30)}`,{cause:t[2]})}function*Sr(e){for(let t of e.childrenStore)yield t}function*Cr(e){for(let t of e.childrenStore)t.value!==void 0&&(yield t.value)}function*L(e){let t=e.parent;for(;t;)yield t,t=t.parent}function wr(e){return[...L(e)].length}function Tr(e,t,n=a){for(let r of t.childrenStore)if(n(r,e))return!0;return!1}function Er(e,t,n=a){for(let r of t.childrenStore)if(n(e,r.value))return r}function*Dr(e,t,n=a){for(let r of t.childrenStore)n(e,r.value)&&(yield r)}function Or(e,t){for(let n of yr(t))if(n===e)return!0;return!1}function kr(e,t,n=a){for(let r of yr(t))if(n(r.value,e))return r}function Ar(e){return e.parent?Ar(e.parent):e}function jr(e,t){for(let n of L(e))if(n===t)return!0;return!1}function*Mr(e){for(let t of L(e))t.value!==void 0&&(yield t.value);return!1}function*Nr(e,t,n=a){for(let r of L(e))r.value!==void 0&&n(r.value,t)&&(yield r);return!1}function Pr(e,t,n=a){return[...Nr(e,t,n)][0]}function Fr(e,t){return e.parent===t}function Ir(e){return Lr(e,0)}function Lr(e,t=0){let n=t;for(let r of e.childrenStore)n=Math.max(n,Lr(r,t+1));return n}function Rr(e,t){Wr(e,t);let n=e.parent;t.childrenStore=[...t.childrenStore,e],e.parent=t,n&&(n.childrenStore=je(n.childrenStore,e))}function zr(e,t){return z(e,t)}function R(e){return z(e)}function Br(e,t=``,n,r=[]){let i=Object.entries(e);n=n===void 0?R():zr({label:t,value:e},n);for(let e of i){let t=e[1];r.includes(t)||(r.push(t),typeof e[1]==`object`?Br(t,e[0],n,r):zr({label:e[0],value:t},n))}return n}function Vr(e){return I(z(e))}function z(e,t){let n={childrenStore:[],parent:t,value:e};return t!==void 0&&(t.childrenStore=[...t.childrenStore,n]),n}function Hr(e){return e.childrenStore.length}function Ur(e){return e.value}function B(e){return{*children(){for(let t of e.childrenStore)yield B(t)},getParent(){if(e.parent!==void 0)return B(e.parent)},getValue(){return e.value},getIdentity(){return e}}}function Wr(e,t){if(t===e)throw Error(`Cannot add self as child`);if(e.parent!==t){if(jr(t,e))throw Error(`Child contains parent (1)`,{cause:e});if(jr(e,t))throw Error(`Parent already contains child`,{cause:e});if(Or(t,e))throw Error(`Child contains parent (2)`,{cause:e})}}function Gr(e,t){for(let n of t)Wr(n,e);e.childrenStore=[...t];for(let n of t)n.parent=e}function Kr(e,t=0){let n=`${` `.repeat(t)} + ${e.value?JSON.stringify(e.value):`-`}`;return e.childrenStore.length>0?`${n}\n${e.childrenStore.map(e=>Kr(e,t+1)).join(` `)}`:n}function*qr(e,t,n=1){for(let r of e.childrenStore){let e=r.value;e!==void 0&&t(e,n)&&(yield r.value,yield*qr(r,t,n+1))}}var Jr=e({asDynamicTraversable:()=>ni,children:()=>V,create:()=>ii,createSimplified:()=>oi,createWrapped:()=>ri,depthFirst:()=>Qr,getByPath:()=>ei,prettyPrint:()=>Xr,prettyPrintEntries:()=>Yr,toStringDeep:()=>Zr,traceByPath:()=>ti});function Yr(e){if(e.length===0)return`(empty)`;let t=``;for(let[n,r]of e.entries())t+=` `.repeat(n),t+=r.name+` = `+JSON.stringify(r.leafValue)+` `;return t}const Xr=(e,t=0,n={})=>{p(De(e,`node`));let r=si(e,n.name??`node`),i=`${` `.repeat(t)} + name: ${r.name} value: ${JSON.stringify(r.leafValue)}`,a=[...V(e,n)];return a.length>0?i+` `+a.map(e=>Xr(e.leafValue,t+1,{...n,name:e.name})).join(` `):i},Zr=(e,t=0)=>{let n=` `.repeat(t)+` ${e.value?.name}`;if(e.value!==void 0){if(`sourceValue`in e.value&&`leafValue`in e.value){let t=u(e.value.sourceValue,20),r=u(e.value.leafValue,20);t=t===r?``:`source: `+t,n+=` = ${r} ${t}`}else `sourceValue`in e.value&&e.value.sourceValue!==void 0&&(n+=` = ${e.value.sourceValue}`);`ancestors`in e.value&&(n+=` (ancestors: ${e.value.ancestors.join(`, `)})`)}n+=` `;for(let r of e.childrenStore)n+=Zr(r,t+1);return n};function*V(e,t={}){p(De(e,`node`));let r=t.filter??`none`,i=e=>r===`none`?[!0,n(e)]:r===`leaves`&&n(e)?[!0,!0]:r===`branches`&&!n(e)?[!0,!1]:[!1,n(e)];if(Array.isArray(e))for(let[t,n]of e.entries()){let e=i(n);e[0]&&(yield{name:t.toString(),_kind:`entry`,sourceValue:n,leafValue:e[1]?n:void 0})}else if(typeof e==`object`){let t=`entries`in e?e.entries():Object.entries(e);for(let[e,n]of t){let[t,r]=i(n);t&&(yield{name:e,_kind:`entry`,sourceValue:n,leafValue:r?n:void 0})}}}function*Qr(e,t={},n=[]){for(let r of V(e,t))yield{...r,ancestors:[...n],_kind:`entry-ancestors`},yield*Qr(r.sourceValue,t,[...n,r.name])}function $r(e,t){for(let n of V(t))if(n.name===e)return n}function ei(e,t,n={}){let r=Fe(ti(e,t,n));if(!r)throw Error(`Could not trace path: ${e} `);return r}function*ti(e,t,n={}){p(De(e,`path`),De(t,`node`));let r=n.separator??`.`,i=e.split(r),a=[];for(let e of i){let n=$r(e,t);if(!n){yield{name:e,sourceValue:void 0,leafValue:void 0,ancestors:a,_kind:`entry-ancestors`};return}t=n.sourceValue,yield{...n,ancestors:[...a],_kind:`entry-ancestors`},a.push(e)}}const ni=(e,t={},n=[],r)=>{let i=t.name??`object`,a={*children(){for(let{name:r,sourceValue:o,leafValue:s}of V(e,t))yield ni(o,{...t,name:r},[...n,i],a)},getParent(){return r},getValue(){return{name:i,sourceValue:e,ancestors:n,_kind:`entry-static