@likec4/core 1.56.0 → 1.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{r as e,t}from"../rolldown-runtime.mjs";import{a as n,i as r,o as i,r as a}from"./graphology-dag.mjs";var o=t(((e,t)=>{var n=i();function r(e){this.size=0,this.items=new Map,this.inverse=e}function a(){this.size=0,this.items=new Map,this.inverse=new r(this)}function o(){this.size=0,this.items.clear(),this.inverse.items.clear()}a.prototype.clear=o,r.prototype.clear=o;function s(e,t){if(this.items.has(e)){var n=this.items.get(e);if(n===t)return this;this.inverse.items.delete(n)}if(this.inverse.items.has(t)){var r=this.inverse.items.get(t);if(r===e)return this;this.items.delete(r)}return this.items.set(e,t),this.inverse.items.set(t,e),this.size=this.items.size,this.inverse.size=this.inverse.items.size,this}a.prototype.set=s,r.prototype.set=s;function c(e){if(this.items.has(e)){var t=this.items.get(e);return this.items.delete(e),this.inverse.items.delete(t),this.size=this.items.size,this.inverse.size=this.inverse.items.size,!0}return!1}a.prototype.delete=c,r.prototype.delete=c,[`has`,`get`,`forEach`,`keys`,`values`,`entries`].forEach(function(e){a.prototype[e]=r.prototype[e]=function(){return Map.prototype[e].apply(this.items,arguments)}}),typeof Symbol<`u`&&(a.prototype[Symbol.iterator]=a.prototype.entries,r.prototype[Symbol.iterator]=r.prototype.entries),a.prototype.inspect=function(){var e={left:this.items,right:this.inverse.items};return Object.defineProperty(e,`constructor`,{value:a,enumerable:!1}),e},typeof Symbol<`u`&&(a.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a.prototype.inspect),r.prototype.inspect=function(){var e={left:this.inverse.items,right:this.items};return Object.defineProperty(e,`constructor`,{value:r,enumerable:!1}),e},typeof Symbol<`u`&&(r.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=r.prototype.inspect),a.from=function(e){var t=new a;return n(e,function(e,n){t.set(n,e)}),t},t.exports=a})),s=t(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`mnemonist/DefaultMap.constructor: expecting a function.`);this.items=new Map,this.factory=e,this.size=0}n.prototype.clear=function(){this.items.clear(),this.size=0},n.prototype.get=function(e){var t=this.items.get(e);return t===void 0&&(t=this.factory(e,this.size),this.items.set(e,t),this.size++),t},n.prototype.peek=function(e){return this.items.get(e)},n.prototype.set=function(e,t){return this.items.set(e,t),this.size=this.items.size,this},n.prototype.has=function(e){return this.items.has(e)},n.prototype.delete=function(e){var t=this.items.delete(e);return this.size=this.items.size,t},n.prototype.forEach=function(e,t){t=arguments.length>1?t:this,this.items.forEach(e,t)},n.prototype.entries=function(){return this.items.entries()},n.prototype.keys=function(){return this.items.keys()},n.prototype.values=function(){return this.items.values()},typeof Symbol<`u`&&(n.prototype[Symbol.iterator]=n.prototype.entries),n.prototype.inspect=function(){return this.items},typeof Symbol<`u`&&(n.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=n.prototype.inspect),n.autoIncrement=function(){var e=0;return function(){return e++}},t.exports=n})),c=t(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`mnemonist/DefaultWeakMap.constructor: expecting a function.`);this.items=new WeakMap,this.factory=e}n.prototype.clear=function(){this.items=new WeakMap},n.prototype.get=function(e){var t=this.items.get(e);return t===void 0&&(t=this.factory(e),this.items.set(e,t)),t},n.prototype.peek=function(e){return this.items.get(e)},n.prototype.set=function(e,t){return this.items.set(e,t),this},n.prototype.has=function(e){return this.items.has(e)},n.prototype.delete=function(e){return this.items.delete(e)},n.prototype.inspect=function(){return this.items},typeof Symbol<`u`&&(n.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=n.prototype.inspect),t.exports=n})),l=t(((e,t)=>{var r=n(),a=i();function o(){this.clear()}o.prototype.clear=function(){this.head=null,this.tail=null,this.size=0},o.prototype.first=function(){return this.head?this.head.item:void 0},o.prototype.peek=o.prototype.first,o.prototype.last=function(){return this.tail?this.tail.item:void 0},o.prototype.push=function(e){var t={item:e,next:null};return this.head?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),this.size++,this.size},o.prototype.unshift=function(e){var t={item:e,next:null};return this.head?(this.head.next||(this.tail=this.head),t.next=this.head,this.head=t):(this.head=t,this.tail=t),this.size++,this.size},o.prototype.shift=function(){if(this.size){var e=this.head;return this.head=e.next,this.size--,e.item}},o.prototype.forEach=function(e,t){if(this.size){t=arguments.length>1?t:this;for(var n=this.head,r=0;n;)e.call(t,n.item,r,this),n=n.next,r++}},o.prototype.toArray=function(){if(!this.size)return[];for(var e=Array(this.size),t=0,n=this.size,r=this.head;t<n;t++)e[t]=r.item,r=r.next;return e},o.prototype.values=function(){var e=this.head;return new r(function(){if(!e)return{done:!0};var t=e.item;return e=e.next,{value:t,done:!1}})},o.prototype.entries=function(){var e=this.head,t=0;return new r(function(){if(!e)return{done:!0};var n=e.item;return e=e.next,t++,{value:[t-1,n],done:!1}})},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.values),o.prototype.toString=function(){return this.toArray().join(`,`)},o.prototype.toJSON=function(){return this.toArray()},o.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,`constructor`,{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.from=function(e){var t=new o;return a(e,function(e){t.push(e)}),t},t.exports=o})),u=t(((e,t)=>{var r=n(),a=i();function o(e){this.Container=e||Array,this.items=new Map,this.clear(),Object.defineProperty(this.items,`constructor`,{value:o,enumerable:!1})}o.prototype.clear=function(){this.size=0,this.dimension=0,this.items.clear()},o.prototype.set=function(e,t){var n=this.items.get(e),r;return n||(this.dimension++,n=new this.Container,this.items.set(e,n)),this.Container===Set?(r=n.size,n.add(t),r<n.size&&this.size++):(n.push(t),this.size++),this},o.prototype.delete=function(e){var t=this.items.get(e);return t?(this.size-=this.Container===Set?t.size:t.length,this.dimension--,this.items.delete(e),!0):!1},o.prototype.remove=function(e,t){var n=this.items.get(e),r,i;return n?this.Container===Set?(r=n.delete(t),r&&this.size--,n.size===0&&(this.items.delete(e),this.dimension--),r):(i=n.indexOf(t),i===-1?!1:(this.size--,n.length===1?(this.items.delete(e),this.dimension--,!0):(n.splice(i,1),!0))):!1},o.prototype.has=function(e){return this.items.has(e)},o.prototype.get=function(e){return this.items.get(e)},o.prototype.multiplicity=function(e){var t=this.items.get(e);return t===void 0?0:this.Container===Set?t.size:t.length},o.prototype.count=o.prototype.multiplicity,o.prototype.forEach=function(e,t){t=arguments.length>1?t:this;var n;function r(r){e.call(t,r,n)}this.items.forEach(function(e,t){n=t,e.forEach(r)})},o.prototype.forEachAssociation=function(e,t){t=arguments.length>1?t:this,this.items.forEach(e,t)},o.prototype.keys=function(){return this.items.keys()},o.prototype.values=function(){var e=this.items.values(),t=!1,n,i,a,o;return this.Container===Set?new r(function r(){if(!t){if(i=e.next(),i.done)return{done:!0};t=!0,n=i.value.values()}return i=n.next(),i.done?(t=!1,r()):{done:!1,value:i.value}}):new r(function r(){if(!t){if(i=e.next(),i.done)return{done:!0};t=!0,n=i.value,a=0,o=n.length}return a>=o?(t=!1,r()):{done:!1,value:n[a++]}})},o.prototype.entries=function(){var e=this.items.entries(),t=!1,n,i,a,o,s;return this.Container===Set?new r(function r(){if(!t){if(i=e.next(),i.done)return{done:!0};t=!0,a=i.value[0],n=i.value[1].values()}return i=n.next(),i.done?(t=!1,r()):{done:!1,value:[a,i.value]}}):new r(function r(){if(!t){if(i=e.next(),i.done)return{done:!0};t=!0,a=i.value[0],n=i.value[1],o=0,s=n.length}return o>=s?(t=!1,r()):{done:!1,value:[a,n[o++]]}})},o.prototype.containers=function(){return this.items.values()},o.prototype.associations=function(){return this.items.entries()},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.entries),o.prototype.inspect=function(){return this.items},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.prototype.toJSON=function(){return this.items},o.from=function(e,t){var n=new o(t);return a(e,function(e,t){n.set(t,e)}),n},t.exports=o})),d=t(((e,t)=>{var r=n(),a=i();function o(){this.clear()}o.prototype.clear=function(){this.items=[],this.offset=0,this.size=0},o.prototype.enqueue=function(e){return this.items.push(e),++this.size},o.prototype.dequeue=function(){if(this.size){var e=this.items[this.offset];return++this.offset*2>=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,e}},o.prototype.peek=function(){if(this.size)return this.items[this.offset]},o.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.offset,r=0,i=this.items.length;n<i;n++,r++)e.call(t,this.items[n],r,this)},o.prototype.toArray=function(){return this.items.slice(this.offset)},o.prototype.values=function(){var e=this.items,t=this.offset;return new r(function(){if(t>=e.length)return{done:!0};var n=e[t];return t++,{value:n,done:!1}})},o.prototype.entries=function(){var e=this.items,t=this.offset,n=0;return new r(function(){if(t>=e.length)return{done:!0};var r=e[t];return t++,{value:[n++,r],done:!1}})},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.values),o.prototype.toString=function(){return this.toArray().join(`,`)},o.prototype.toJSON=function(){return this.toArray()},o.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,`constructor`,{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.from=function(e){var t=new o;return a(e,function(e){t.enqueue(e)}),t},o.of=function(){return o.from(arguments)},t.exports=o})),f=t(((e,t)=>{var o=n(),s=i(),c=r(),l=a();function u(e,t,n){if(arguments.length<2&&(n=e,e=null,t=null),this.capacity=n,typeof this.capacity!=`number`||this.capacity<=0)throw Error(`mnemonist/lru-cache: capacity should be positive number.`);if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw Error(`mnemonist/lru-cache: capacity should be a finite positive integer.`);var r=c.getPointerArray(n);this.forward=new r(n),this.backward=new r(n),this.K=typeof e==`function`?new e(n):Array(n),this.V=typeof t==`function`?new t(n):Array(n),this.size=0,this.head=0,this.tail=0,this.items={}}u.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items={}},u.prototype.splayOnTop=function(e){var t=this.head;if(this.head===e)return this;var n=this.backward[e],r=this.forward[e];return this.tail===e?this.tail=n:this.backward[r]=n,this.forward[n]=r,this.backward[t]=e,this.head=e,this.forward[e]=t,this},u.prototype.set=function(e,t){var n=this.items[e];if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],delete this.items[this.K[n]]),this.items[e]=n,this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},u.prototype.setpop=function(e,t){var n=null,r=null,i=this.items[e];return i===void 0?(this.size<this.capacity?i=this.size++:(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],delete this.items[r]),this.items[e]=i,this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},u.prototype.has=function(e){return e in this.items},u.prototype.get=function(e){var t=this.items[e];if(t!==void 0)return this.splayOnTop(t),this.V[t]},u.prototype.peek=function(e){var t=this.items[e];if(t!==void 0)return this.V[t]},u.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=0,r=this.size,i=this.head,a=this.K,o=this.V,s=this.forward;n<r;)e.call(t,o[i],a[i],this),i=s[i],n++},u.prototype.keys=function(){var e=0,t=this.size,n=this.head,r=this.K,i=this.forward;return new o(function(){if(e>=t)return{done:!0};var a=r[n];return e++,e<t&&(n=i[n]),{done:!1,value:a}})},u.prototype.values=function(){var e=0,t=this.size,n=this.head,r=this.V,i=this.forward;return new o(function(){if(e>=t)return{done:!0};var a=r[n];return e++,e<t&&(n=i[n]),{done:!1,value:a}})},u.prototype.entries=function(){var e=0,t=this.size,n=this.head,r=this.K,i=this.V,a=this.forward;return new o(function(){if(e>=t)return{done:!0};var o=r[n],s=i[n];return e++,e<t&&(n=a[n]),{done:!1,value:[o,s]}})},typeof Symbol<`u`&&(u.prototype[Symbol.iterator]=u.prototype.entries),u.prototype.inspect=function(){for(var e=new Map,t=this.entries(),n;n=t.next(),!n.done;)e.set(n.value[0],n.value[1]);return Object.defineProperty(e,`constructor`,{value:u,enumerable:!1}),e},typeof Symbol<`u`&&(u.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=u.prototype.inspect),u.from=function(e,t,n,r){if(arguments.length<2){if(r=l.guessLength(e),typeof r!=`number`)throw Error(`mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(r=t,t=null,n=null);var i=new u(t,n,r);return s(e,function(e,t){i.set(t,e)}),i},t.exports=u})),p=t(((e,t)=>{var n=f(),o=i(),s=r(),c=a();function l(e,t,n){if(arguments.length<2&&(n=e,e=null,t=null),this.capacity=n,typeof this.capacity!=`number`||this.capacity<=0)throw Error(`mnemonist/lru-map: capacity should be positive number.`);if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw Error(`mnemonist/lru-map: capacity should be a finite positive integer.`);var r=s.getPointerArray(n);this.forward=new r(n),this.backward=new r(n),this.K=typeof e==`function`?new e(n):Array(n),this.V=typeof t==`function`?new t(n):Array(n),this.size=0,this.head=0,this.tail=0,this.items=new Map}l.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items.clear()},l.prototype.set=function(e,t){var n=this.items.get(e);if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],this.items.delete(this.K[n])),this.items.set(e,n),this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},l.prototype.setpop=function(e,t){var n=null,r=null,i=this.items.get(e);return i===void 0?(this.size<this.capacity?i=this.size++:(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],this.items.delete(r)),this.items.set(e,i),this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},l.prototype.has=function(e){return this.items.has(e)},l.prototype.get=function(e){var t=this.items.get(e);if(t!==void 0)return this.splayOnTop(t),this.V[t]},l.prototype.peek=function(e){var t=this.items.get(e);if(t!==void 0)return this.V[t]},l.prototype.splayOnTop=n.prototype.splayOnTop,l.prototype.forEach=n.prototype.forEach,l.prototype.keys=n.prototype.keys,l.prototype.values=n.prototype.values,l.prototype.entries=n.prototype.entries,typeof Symbol<`u`&&(l.prototype[Symbol.iterator]=l.prototype.entries),l.prototype.inspect=n.prototype.inspect,l.from=function(e,t,n,r){if(arguments.length<2){if(r=c.guessLength(e),typeof r!=`number`)throw Error(`mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(r=t,t=null,n=null);var i=new l(t,n,r);return o(e,function(e,t){i.set(t,e)}),i},t.exports=l})),m=t(((e,t)=>{var n=p(),o=i(),s=r(),c=a();function l(e,t,r){arguments.length<2?n.call(this,e):n.call(this,e,t,r);var i=s.getPointerArray(this.capacity);this.deleted=new i(this.capacity),this.deletedSize=0}for(var u in n.prototype)l.prototype[u]=n.prototype[u];typeof Symbol<`u`&&(l.prototype[Symbol.iterator]=n.prototype[Symbol.iterator]),l.prototype.clear=function(){n.prototype.clear.call(this),this.deletedSize=0},l.prototype.set=function(e,t){var n=this.items.get(e);if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?(n=this.deletedSize>0?this.deleted[--this.deletedSize]:this.size,this.size++):(n=this.tail,this.tail=this.backward[n],this.items.delete(this.K[n])),this.items.set(e,n),this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},l.prototype.setpop=function(e,t){var n=null,r=null,i=this.items.get(e);return i===void 0?(this.size<this.capacity?(i=this.deletedSize>0?this.deleted[--this.deletedSize]:this.size,this.size++):(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],this.items.delete(r)),this.items.set(e,i),this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},l.prototype.delete=function(e){var t=this.items.get(e);if(t===void 0)return!1;if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,!0;var n=this.backward[t],r=this.forward[t];return this.head===t&&(this.head=r),this.tail===t&&(this.tail=n),this.forward[n]=r,this.backward[r]=n,this.size--,this.deleted[this.deletedSize++]=t,!0},l.prototype.remove=function(e,t=void 0){var n=this.items.get(e);if(n===void 0)return t;var r=this.V[n];if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,r;var i=this.backward[n],a=this.forward[n];return this.head===n&&(this.head=a),this.tail===n&&(this.tail=i),this.forward[i]=a,this.backward[a]=i,this.size--,this.deleted[this.deletedSize++]=n,r},l.from=function(e,t,n,r){if(arguments.length<2){if(r=c.guessLength(e),typeof r!=`number`)throw Error(`mnemonist/lru-map.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(r=t,t=null,n=null);var i=new l(t,n,r);return o(e,function(e,t){i.set(t,e)}),i},t.exports=l})),h=t((e=>{e.intersection=function(){if(arguments.length<2)throw Error(`mnemonist/Set.intersection: needs at least two arguments.`);var e=new Set,t=1/0,n=null,r,i,a=arguments.length;for(i=0;i<a;i++){if(r=arguments[i],r.size===0)return e;r.size<t&&(t=r.size,n=r)}for(var o=n.values(),s,c,l,u;s=o.next(),!s.done;){for(c=s.value,l=!0,i=0;i<a;i++)if(u=arguments[i],u!==n&&!u.has(c)){l=!1;break}l&&e.add(c)}return e},e.union=function(){if(arguments.length<2)throw Error(`mnemonist/Set.union: needs at least two arguments.`);var e=new Set,t,n=arguments.length,r,i;for(t=0;t<n;t++)for(r=arguments[t].values();i=r.next(),!i.done;)e.add(i.value);return e},e.difference=function(e,t){if(!e.size)return new Set;if(!t.size)return new Set(e);for(var n=new Set,r=e.values(),i;i=r.next(),!i.done;)t.has(i.value)||n.add(i.value);return n},e.symmetricDifference=function(e,t){for(var n=new Set,r=e.values(),i;i=r.next(),!i.done;)t.has(i.value)||n.add(i.value);for(r=t.values();i=r.next(),!i.done;)e.has(i.value)||n.add(i.value);return n},e.isSubset=function(e,t){var n=e.values(),r;if(e===t)return!0;if(e.size>t.size)return!1;for(;r=n.next(),!r.done;)if(!t.has(r.value))return!1;return!0},e.isSuperset=function(t,n){return e.isSubset(n,t)},e.add=function(e,t){for(var n=t.values(),r;r=n.next(),!r.done;)e.add(r.value)},e.subtract=function(e,t){for(var n=t.values(),r;r=n.next(),!r.done;)e.delete(r.value)},e.intersect=function(e,t){for(var n=e.values(),r;r=n.next(),!r.done;)t.has(r.value)||e.delete(r.value)},e.disjunct=function(e,t){for(var n=e.values(),r,i=[];r=n.next(),!r.done;)t.has(r.value)&&i.push(r.value);for(n=t.values();r=n.next(),!r.done;)e.has(r.value)||e.add(r.value);for(var a=0,o=i.length;a<o;a++)e.delete(i[a])},e.intersectionSize=function(e,t){var n;if(e.size>t.size&&(n=e,e=t,t=n),e.size===0)return 0;if(e===t)return e.size;for(var r=e.values(),i,a=0;i=r.next(),!i.done;)t.has(i.value)&&a++;return a},e.unionSize=function(t,n){var r=e.intersectionSize(t,n);return t.size+n.size-r},e.jaccard=function(t,n){var r=e.intersectionSize(t,n);return r===0?0:r/(t.size+n.size-r)},e.overlap=function(t,n){var r=e.intersectionSize(t,n);return r===0?0:r/Math.min(t.size,n.size)}})),g=t(((e,t)=>{var r=n(),a=i();function o(){this.clear()}o.prototype.clear=function(){this.items=[],this.size=0},o.prototype.push=function(e){return this.items.push(e),++this.size},o.prototype.pop=function(){if(this.size!==0)return this.size--,this.items.pop()},o.prototype.peek=function(){return this.items[this.size-1]},o.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=0,r=this.items.length;n<r;n++)e.call(t,this.items[r-n-1],n,this)},o.prototype.toArray=function(){for(var e=Array(this.size),t=this.size-1,n=this.size;n--;)e[n]=this.items[t-n];return e},o.prototype.values=function(){var e=this.items,t=e.length,n=0;return new r(function(){if(n>=t)return{done:!0};var r=e[t-n-1];return n++,{value:r,done:!1}})},o.prototype.entries=function(){var e=this.items,t=e.length,n=0;return new r(function(){if(n>=t)return{done:!0};var r=e[t-n-1];return{value:[n++,r],done:!1}})},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.values),o.prototype.toString=function(){return this.toArray().join(`,`)},o.prototype.toJSON=function(){return this.toArray()},o.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,`constructor`,{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.from=function(e){var t=new o;return a(e,function(e){t.push(e)}),t},o.of=function(){return o.from(arguments)},t.exports=o}));o();var _=e(s(),1),v=e(c(),1),y=e(l(),1),b=e(u(),1),x=e(d(),1),S=e(p(),1);m();var C=h(),w=e(g(),1);export{b as a,w as c,S as i,v as n,x as o,y as r,C as s,_ as t};
1
+ import{r as e,t}from"../rolldown-runtime.mjs";import{i as n,r}from"./graphology-dag.mjs";var i=t((e=>{e.intersection=function(){if(arguments.length<2)throw Error(`mnemonist/Set.intersection: needs at least two arguments.`);var e=new Set,t=1/0,n=null,r,i,a=arguments.length;for(i=0;i<a;i++){if(r=arguments[i],r.size===0)return e;r.size<t&&(t=r.size,n=r)}for(var o=n.values(),s,c,l,u;s=o.next(),!s.done;){for(c=s.value,l=!0,i=0;i<a;i++)if(u=arguments[i],u!==n&&!u.has(c)){l=!1;break}l&&e.add(c)}return e},e.union=function(){if(arguments.length<2)throw Error(`mnemonist/Set.union: needs at least two arguments.`);var e=new Set,t,n=arguments.length,r,i;for(t=0;t<n;t++)for(r=arguments[t].values();i=r.next(),!i.done;)e.add(i.value);return e},e.difference=function(e,t){if(!e.size)return new Set;if(!t.size)return new Set(e);for(var n=new Set,r=e.values(),i;i=r.next(),!i.done;)t.has(i.value)||n.add(i.value);return n},e.symmetricDifference=function(e,t){for(var n=new Set,r=e.values(),i;i=r.next(),!i.done;)t.has(i.value)||n.add(i.value);for(r=t.values();i=r.next(),!i.done;)e.has(i.value)||n.add(i.value);return n},e.isSubset=function(e,t){var n=e.values(),r;if(e===t)return!0;if(e.size>t.size)return!1;for(;r=n.next(),!r.done;)if(!t.has(r.value))return!1;return!0},e.isSuperset=function(t,n){return e.isSubset(n,t)},e.add=function(e,t){for(var n=t.values(),r;r=n.next(),!r.done;)e.add(r.value)},e.subtract=function(e,t){for(var n=t.values(),r;r=n.next(),!r.done;)e.delete(r.value)},e.intersect=function(e,t){for(var n=e.values(),r;r=n.next(),!r.done;)t.has(r.value)||e.delete(r.value)},e.disjunct=function(e,t){for(var n=e.values(),r,i=[];r=n.next(),!r.done;)t.has(r.value)&&i.push(r.value);for(n=t.values();r=n.next(),!r.done;)e.has(r.value)||e.add(r.value);for(var a=0,o=i.length;a<o;a++)e.delete(i[a])},e.intersectionSize=function(e,t){var n;if(e.size>t.size&&(n=e,e=t,t=n),e.size===0)return 0;if(e===t)return e.size;for(var r=e.values(),i,a=0;i=r.next(),!i.done;)t.has(i.value)&&a++;return a},e.unionSize=function(t,n){var r=e.intersectionSize(t,n);return t.size+n.size-r},e.jaccard=function(t,n){var r=e.intersectionSize(t,n);return r===0?0:r/(t.size+n.size-r)},e.overlap=function(t,n){var r=e.intersectionSize(t,n);return r===0?0:r/Math.min(t.size,n.size)}})),a=t((e=>{var t=function(e,t){return e<t?-1:+(e>t)},n=function(e,t){return e<t?1:e>t?-1:0};function r(e){return function(t,n){return e(n,t)}}function i(e){return e===2?function(e,t){return e[0]<t[0]?-1:e[0]>t[0]?1:e[1]<t[1]?-1:+(e[1]>t[1])}:function(t,n){for(var r=0;r<e;){if(t[r]<n[r])return-1;if(t[r]>n[r])return 1;r++}return 0}}e.DEFAULT_COMPARATOR=t,e.DEFAULT_REVERSE_COMPARATOR=n,e.reverseComparator=r,e.createTupleComparator=i})),o=t(((e,t)=>{var r=a(),i=n(),o=r.DEFAULT_COMPARATOR,s=r.reverseComparator;function c(e){if(this.clear(),this.comparator=e||o,typeof this.comparator!=`function`)throw Error(`mnemonist/FibonacciHeap.constructor: given comparator should be a function.`)}c.prototype.clear=function(){this.root=null,this.min=null,this.size=0};function l(e){return{item:e,degree:0}}function u(e,t){e.root?(t.right=e.root.right,t.left=e.root,e.root.right.left=t,e.root.right=t):e.root=t}c.prototype.push=function(e){var t=l(e);return t.left=t,t.right=t,u(this,t),(!this.min||this.comparator(t.item,this.min.item)<=0)&&(this.min=t),++this.size},c.prototype.peek=function(){return this.min?this.min.item:void 0};function d(e){for(var t=[],n=e,r=!1;!(n===e&&r);)n===e&&(r=!0),t.push(n),n=n.right;return t}function f(e,t){e.root===t&&(e.root=t.right),t.left.right=t.right,t.right.left=t.left}function p(e,t){e.child?(t.right=e.child.right,t.left=e.child,e.child.right.left=t,e.child.right=t):e.child=t}function m(e,t,n){f(e,t),t.left=t,t.right=t,p(n,t),n.degree++,t.parent=n}function h(e){var t=Array(e.size),n=d(e.root),r,i,a,o,s,c;for(r=0,i=n.length;r<i;r++){for(a=n[r],s=a.degree;t[s];)o=t[s],e.comparator(a.item,o.item)>0&&(c=a,a=o,o=c),m(e,o,a),t[s]=null,s++;t[s]=a}for(r=0;r<e.size;r++)t[r]&&e.comparator(t[r].item,e.min.item)<=0&&(e.min=t[r])}c.prototype.pop=function(){if(this.size){var e=this.min;if(e.child){var t=d(e.child),n,r,i;for(r=0,i=t.length;r<i;r++)n=t[r],u(this,n),delete n.parent}return f(this,e),e===e.right?(this.min=null,this.root=null):(this.min=e.right,h(this)),this.size--,e.item}},c.prototype.inspect=function(){var e={size:this.size};return this.min&&`item`in this.min&&(e.top=this.min.item),Object.defineProperty(e,"constructor",{value:c,enumerable:!1}),e},typeof Symbol<`u`&&(c.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=c.prototype.inspect);function g(e){if(this.clear(),this.comparator=e||o,typeof this.comparator!=`function`)throw Error(`mnemonist/FibonacciHeap.constructor: given comparator should be a function.`);this.comparator=s(this.comparator)}g.prototype=c.prototype,c.from=function(e,t){var n=new c(t);return i(e,function(e){n.push(e)}),n},g.from=function(e,t){var n=new g(t);return i(e,function(e){n.push(e)}),n},c.MinFibonacciHeap=c,c.MaxFibonacciHeap=g,t.exports=c})),s=t((e=>{var t=2**8-1,n=2**16-1,r=2**32-1,i=2**7-1,a=2**15-1,o=2**31-1;e.getPointerArray=function(e){var i=e-1;if(i<=t)return Uint8Array;if(i<=n)return Uint16Array;if(i<=r)return Uint32Array;throw Error(`mnemonist: Pointer Array of size > 4294967295 is not supported.`)},e.getSignedPointerArray=function(e){var t=e-1;return t<=i?Int8Array:t<=a?Int16Array:t<=o?Int32Array:Float64Array},e.getNumberType=function(e){return e===(e|0)?Math.sign(e)===-1?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var s={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};e.getMinimalRepresentation=function(t,n){var r=null,i=0,a,o,c,l,u;for(l=0,u=t.length;l<u;l++)c=n?n(t[l]):t[l],o=e.getNumberType(c),a=s[o.name],a>i&&(i=a,r=o);return r},e.isTypedArray=function(e){return typeof ArrayBuffer<`u`&&ArrayBuffer.isView(e)},e.concat=function(){var e=0,t,n,r;for(t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=new arguments[0].constructor(e);for(t=0,n=0;t<r;t++)i.set(arguments[t],n),n+=arguments[t].length;return i},e.indices=function(t){for(var n=new(e.getPointerArray(t))(t),r=0;r<t;r++)n[r]=r;return n}})),c=t((e=>{var t=n(),r=s();function i(e){return Array.isArray(e)||r.isTypedArray(e)}function a(e){if(typeof e.length==`number`)return e.length;if(typeof e.size==`number`)return e.size}function o(e){var n=a(e),r=typeof n==`number`?Array(n):[],i=0;return t(e,function(e){r[i++]=e}),r}function c(e){var n=a(e),i=typeof n==`number`?r.getPointerArray(n):Array,o=typeof n==`number`?Array(n):[],s=typeof n==`number`?new i(n):[],c=0;return t(e,function(e){o[c]=e,s[c]=c++}),[o,s]}e.isArrayLike=i,e.guessLength=a,e.toArray=o,e.toArrayWithIndices=c})),l=t(((e,t)=>{var r=n(),i=a(),o=c(),s=i.DEFAULT_COMPARATOR,l=i.reverseComparator;function u(e,t,n,r){for(var i=t[r],a,o;r>n;){if(a=r-1>>1,o=t[a],e(i,o)<0){t[r]=o,r=a;continue}break}t[r]=i}function d(e,t,n){for(var r=t.length,i=n,a=t[n],o=2*n+1,s;o<r;)s=o+1,s<r&&e(t[o],t[s])>=0&&(o=s),t[n]=t[o],n=o,o=2*n+1;t[n]=a,u(e,t,i,n)}function f(e,t,n){t.push(n),u(e,t,0,t.length-1)}function p(e,t){var n=t.pop();if(t.length!==0){var r=t[0];return t[0]=n,d(e,t,0),r}return n}function m(e,t,n){if(t.length===0)throw Error(`mnemonist/heap.replace: cannot pop an empty heap.`);var r=t[0];return t[0]=n,d(e,t,0),r}function h(e,t,n){var r;return t.length!==0&&e(t[0],n)<0&&(r=t[0],t[0]=n,n=r,d(e,t,0)),n}function g(e,t){for(var n=t.length>>1;--n>=0;)d(e,t,n)}function _(e,t){for(var n=t.length,r=0,i=Array(n);r<n;)i[r++]=p(e,t);return i}function v(e,t,n){arguments.length===2&&(n=t,t=e,e=s);var i=l(e),a,c,u,d=1/0,f;if(t===1){if(o.isArrayLike(n)){for(a=0,c=n.length;a<c;a++)u=n[a],(d===1/0||e(u,d)<0)&&(d=u);return f=new n.constructor(1),f[0]=d,f}return r(n,function(t){(d===1/0||e(t,d)<0)&&(d=t)}),[d]}if(o.isArrayLike(n)){if(t>=n.length)return n.slice().sort(e);for(f=n.slice(0,t),g(i,f),a=t,c=n.length;a<c;a++)i(n[a],f[0])>0&&m(i,f,n[a]);return f.sort(e)}var p=o.guessLength(n);return p!==null&&p<t&&(t=p),f=Array(t),a=0,r(n,function(e){a<t?f[a]=e:(a===t&&g(i,f),i(e,f[0])>0&&m(i,f,e)),a++}),f.length>a&&(f.length=a),f.sort(e)}function y(e,t,n){arguments.length===2&&(n=t,t=e,e=s);var i=l(e),a,c,u,d=-1/0,f;if(t===1){if(o.isArrayLike(n)){for(a=0,c=n.length;a<c;a++)u=n[a],(d===-1/0||e(u,d)>0)&&(d=u);return f=new n.constructor(1),f[0]=d,f}return r(n,function(t){(d===-1/0||e(t,d)>0)&&(d=t)}),[d]}if(o.isArrayLike(n)){if(t>=n.length)return n.slice().sort(i);for(f=n.slice(0,t),g(e,f),a=t,c=n.length;a<c;a++)e(n[a],f[0])>0&&m(e,f,n[a]);return f.sort(i)}var p=o.guessLength(n);return p!==null&&p<t&&(t=p),f=Array(t),a=0,r(n,function(n){a<t?f[a]=n:(a===t&&g(e,f),e(n,f[0])>0&&m(e,f,n)),a++}),f.length>a&&(f.length=a),f.sort(i)}function b(e){if(this.clear(),this.comparator=e||s,typeof this.comparator!=`function`)throw Error(`mnemonist/Heap.constructor: given comparator should be a function.`)}b.prototype.clear=function(){this.items=[],this.size=0},b.prototype.push=function(e){return f(this.comparator,this.items,e),++this.size},b.prototype.peek=function(){return this.items[0]},b.prototype.pop=function(){return this.size!==0&&this.size--,p(this.comparator,this.items)},b.prototype.replace=function(e){return m(this.comparator,this.items,e)},b.prototype.pushpop=function(e){return h(this.comparator,this.items,e)},b.prototype.consume=function(){return this.size=0,_(this.comparator,this.items)},b.prototype.toArray=function(){return _(this.comparator,this.items.slice())},b.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,"constructor",{value:b,enumerable:!1}),e},typeof Symbol<`u`&&(b.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=b.prototype.inspect);function x(e){if(this.clear(),this.comparator=e||s,typeof this.comparator!=`function`)throw Error(`mnemonist/MaxHeap.constructor: given comparator should be a function.`);this.comparator=l(this.comparator)}x.prototype=b.prototype,b.from=function(e,t){var n=new b(t),r=o.isArrayLike(e)?e.slice():o.toArray(e);return g(n.comparator,r),n.items=r,n.size=r.length,n},x.from=function(e,t){var n=new x(t),r=o.isArrayLike(e)?e.slice():o.toArray(e);return g(n.comparator,r),n.items=r,n.size=r.length,n},b.siftUp=d,b.siftDown=u,b.push=f,b.pop=p,b.replace=m,b.pushpop=h,b.heapify=g,b.consume=_,b.nsmallest=v,b.nlargest=y,b.MinHeap=b,b.MaxHeap=x,t.exports=b})),u=t(((e,t)=>{var n=``;function r(e,t,n){for(var r=t.length,i=[],a=r,o=-1,s,c=0,l;a--;)o=Math.max(e[t[a]+n],o);for(l=o>>24&&32||o>>16&&24||o>>8&&16||8;c<l;c+=4){for(a=16;a--;)i[a]=[];for(a=r;a--;)i[e[t[a]+n]>>c&15].push(t[a]);for(s=0;s<16;s++)for(o=i[s].length;o--;)t[++a]=i[s][o]}}function i(e,t,n,r){return e[n]-e[r]||(n%3==2?e[n+1]-e[r+1]||t[n+2]-t[r+2]:t[n+1]-t[r+1])}function a(e,t){var n=[],o=[],s=2*t/3|0,c=t-s,l=s+1>>1,u=s,d=0,f,p=[],m=[];if(t===1)return[0];for(;u--;)n[u]=(u*3>>1)+1;for(u=3;u--;)r(e,n,u);for(d=o[(n[0]/3|0)+(n[0]%3==1?0:l)]=1,u=1;u<s;u++)(e[n[u]]!==e[n[u-1]]||e[n[u]+1]!==e[n[u-1]+1]||e[n[u]+2]!==e[n[u-1]+2])&&d++,o[(n[u]/3|0)+(n[u]%3==1?0:l)]=d;if(d<s)for(o=a(o,s),u=s;u--;)n[u]=o[u]<l?o[u]*3+1:(o[u]-l)*3+2;for(u=s;u--;)p[n[u]]=u;for(p[t]=-1,p[t+1]=-2,o=t%3==1?[t-1]:[],u=0;u<s;u++)n[u]%3==1&&o.push(n[u]-1);for(r(e,o,0),u=0,d=0,f=0;u<s&&d<c;)m[f++]=i(e,p,n[u],o[d])<0?n[u++]:o[d++];for(;u<s;)m[f++]=n[u++];for(;d<c;)m[f++]=o[d++];return m}function o(e){var t=e.length,n=t%3,r=Array(t+n),i,a;if(typeof e!=`string`){var o=Object.create(null);for(a=0;a<t;a++)o[e[a]]||(o[e[a]]=!0);var s=Object.create(null),c=Object.keys(o).sort();for(a=0,i=c.length;a<i;a++)s[c[a]]=a+1;for(a=0;a<t;a++)r[a]=s[e[a]]}else for(a=0;a<t;a++)r[a]=e.charCodeAt(a);for(a=t;a<t+n;a++)r[a]=0;return r}function s(e){this.hasArbitrarySequence=typeof e!=`string`,this.string=e,this.length=e.length,this.array=a(o(e),this.length)}s.prototype.toString=function(){return this.array.join(`,`)},s.prototype.toJSON=function(){return this.array},s.prototype.inspect=function(){for(var e=Array(this.length),t=0;t<this.length;t++)e[t]=this.string.slice(this.array[t]);return Object.defineProperty(e,"constructor",{value:s,enumerable:!1}),e},typeof Symbol<`u`&&(s.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=s.prototype.inspect);function c(e){if(this.hasArbitrarySequence=typeof e[0]!=`string`,this.size=e.length,this.hasArbitrarySequence){this.text=[];for(var t=0,r=this.size;t<r;t++)this.text.push.apply(this.text,e[t]),t<r-1&&this.text.push(n)}else this.text=e.join(n);this.firstLength=e[0].length,this.length=this.text.length,this.array=a(o(this.text),this.length)}c.prototype.longestCommonSubsequence=function(){var e=this.hasArbitrarySequence?[]:``,t,n,r,i,a;for(n=1;n<this.length;n++)if(i=this.array[n],a=this.array[n-1],!(i<this.firstLength&&a<this.firstLength)&&!(i>this.firstLength&&a>this.firstLength)){for(t=Math.min(this.length-i,this.length-a),r=0;r<t;r++)if(this.text[i+r]!==this.text[a+r]){t=r;break}t>e.length&&(e=this.text.slice(i,i+t))}return e},c.prototype.toString=function(){return this.array.join(`,`)},c.prototype.toJSON=function(){return this.array},c.prototype.inspect=function(){for(var e=Array(this.length),t=0;t<this.length;t++)e[t]=this.text.slice(this.array[t]);return Object.defineProperty(e,"constructor",{value:c,enumerable:!1}),e},typeof Symbol<`u`&&(c.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=c.prototype.inspect),s.GeneralizedSuffixArray=c,t.exports=s})),d=t(((e,t)=>{var i=r(),a=n(),o=c(),l=s(),u=function(e){return Math.max(1,Math.ceil(e*1.5))},d=function(e){return new(l.getPointerArray(e))(e)};function f(e,t){if(arguments.length<1)throw Error(`mnemonist/vector: expecting at least a byte array constructor.`);var n=t||0,r=u,i=0,a=!1;typeof t==`object`&&(n=t.initialCapacity||0,i=t.initialLength||0,r=t.policy||r,a=t.factory===!0),this.factory=a?e:null,this.ArrayClass=e,this.length=i,this.capacity=Math.max(i,n),this.policy=r,this.array=new e(this.capacity)}f.prototype.set=function(e,t){if(this.length<e)throw Error(`Vector(`+this.ArrayClass.name+`).set: index out of bounds.`);return this.array[e]=t,this},f.prototype.get=function(e){if(!(this.length<e))return this.array[e]},f.prototype.applyPolicy=function(e){var t=this.policy(e||this.capacity);if(typeof t!=`number`||t<0)throw Error(`mnemonist/vector.applyPolicy: policy returned an invalid value (expecting a positive integer).`);if(t<=this.capacity)throw Error(`mnemonist/vector.applyPolicy: policy returned a less or equal capacity to allocate.`);return t},f.prototype.reallocate=function(e){if(e===this.capacity)return this;var t=this.array;if(e<this.length&&(this.length=e),e>this.capacity)if(this.factory===null?this.array=new this.ArrayClass(e):this.array=this.factory(e),l.isTypedArray(this.array))this.array.set(t,0);else for(var n=0,r=this.length;n<r;n++)this.array[n]=t[n];else this.array=t.slice(0,e);return this.capacity=e,this},f.prototype.grow=function(e){var t;if(typeof e==`number`){if(this.capacity>=e)return this;for(t=this.capacity;t<e;)t=this.applyPolicy(t);return this.reallocate(t),this}return t=this.applyPolicy(),this.reallocate(t),this},f.prototype.resize=function(e){return e===this.length?this:e<this.length?(this.length=e,this):(this.length=e,this.reallocate(e),this)},f.prototype.push=function(e){return this.capacity===this.length&&this.grow(),this.array[this.length++]=e,this.length},f.prototype.pop=function(){if(this.length!==0)return this.array[--this.length]},f.prototype.values=function(){var e=this.array,t=this.length,n=0;return new i(function(){if(n>=t)return{done:!0};var r=e[n];return n++,{value:r,done:!1}})},f.prototype.entries=function(){var e=this.array,t=this.length,n=0;return new i(function(){if(n>=t)return{done:!0};var r=e[n];return{value:[n++,r],done:!1}})},typeof Symbol<`u`&&(f.prototype[Symbol.iterator]=f.prototype.values),f.prototype.inspect=function(){var e=this.array.slice(0,this.length);return e.type=this.array.constructor.name,e.items=this.length,e.capacity=this.capacity,Object.defineProperty(e,"constructor",{value:f,enumerable:!1}),e},typeof Symbol<`u`&&(f.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=f.prototype.inspect),f.from=function(e,t,n){if(arguments.length<3&&(n=o.guessLength(e),typeof n!=`number`))throw Error(`mnemonist/vector.from: could not guess iterable length. Please provide desired capacity as last argument.`);var r=new f(t,n);return a(e,function(e){r.push(e)}),r};function p(e){var t=function(t){f.call(this,e,t)};for(var n in f.prototype)f.prototype.hasOwnProperty(n)&&(t.prototype[n]=f.prototype[n]);return t.from=function(t,n){return f.from(t,e,n)},typeof Symbol<`u`&&(t.prototype[Symbol.iterator]=t.prototype.values),t}f.Int8Vector=p(Int8Array),f.Uint8Vector=p(Uint8Array),f.Uint8ClampedVector=p(Uint8ClampedArray),f.Int16Vector=p(Int16Array),f.Uint16Vector=p(Uint16Array),f.Int32Vector=p(Int32Array),f.Uint32Vector=p(Uint32Array),f.Float32Vector=p(Float32Array),f.Float64Vector=p(Float64Array),f.PointerVector=p(d),t.exports=f})),f=t(((e,t)=>{var r=n();function i(e){this.size=0,this.items=new Map,this.inverse=e}function a(){this.size=0,this.items=new Map,this.inverse=new i(this)}function o(){this.size=0,this.items.clear(),this.inverse.items.clear()}a.prototype.clear=o,i.prototype.clear=o;function s(e,t){if(this.items.has(e)){var n=this.items.get(e);if(n===t)return this;this.inverse.items.delete(n)}if(this.inverse.items.has(t)){var r=this.inverse.items.get(t);if(r===e)return this;this.items.delete(r)}return this.items.set(e,t),this.inverse.items.set(t,e),this.size=this.items.size,this.inverse.size=this.inverse.items.size,this}a.prototype.set=s,i.prototype.set=s;function c(e){if(this.items.has(e)){var t=this.items.get(e);return this.items.delete(e),this.inverse.items.delete(t),this.size=this.items.size,this.inverse.size=this.inverse.items.size,!0}return!1}a.prototype.delete=c,i.prototype.delete=c,[`has`,`get`,`forEach`,`keys`,`values`,`entries`].forEach(function(e){a.prototype[e]=i.prototype[e]=function(){return Map.prototype[e].apply(this.items,arguments)}}),typeof Symbol<`u`&&(a.prototype[Symbol.iterator]=a.prototype.entries,i.prototype[Symbol.iterator]=i.prototype.entries),a.prototype.inspect=function(){var e={left:this.items,right:this.inverse.items};return Object.defineProperty(e,"constructor",{value:a,enumerable:!1}),e},typeof Symbol<`u`&&(a.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a.prototype.inspect),i.prototype.inspect=function(){var e={left:this.inverse.items,right:this.items};return Object.defineProperty(e,"constructor",{value:i,enumerable:!1}),e},typeof Symbol<`u`&&(i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=i.prototype.inspect),a.from=function(e){var t=new a;return r(e,function(e,n){t.set(n,e)}),t},t.exports=a})),p=t((e=>{function t(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e&~(e>>1)}e.msb32=t;function n(e){return e|=e>>1,e|=e>>2,e|=e>>4,e&~(e>>1)}e.msb8=n,e.test=function(e,t){return e>>t&1},e.criticalBit8=function(e,t){return n(e^t)},e.criticalBit8Mask=function(e,t){return~n(e^t)>>>0&255},e.testCriticalBit8=function(e,t){return 1+(e|t)>>8},e.criticalBit32Mask=function(e,n){return~t(e^n)>>>0&4294967295},e.popcount=function(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,e+=e>>16,e&127};for(var r=new Uint8Array(2**8),i=0,a=r.length;i<a;i++)r[i]=e.popcount(i);e.table8Popcount=function(e){return r[e&255]+r[e>>8&255]+r[e>>16&255]+r[e>>24&255]}})),m=t(((e,t)=>{var n=r(),i=p();function a(e){this.length=e,this.clear()}a.prototype.clear=function(){this.size=0,this.array=new Uint32Array(Math.ceil(this.length/32))},a.prototype.set=function(e,t){var n=e>>5,r=e&31,i=this.array[n],a=t===0||t===!1?this.array[n]&=~(1<<r):this.array[n]|=1<<r;return a>>>=0,a>i?this.size++:a<i&&this.size--,this},a.prototype.reset=function(e){var t=e>>5,n=e&31,r=this.array[t];return(this.array[t]&=~(1<<n))<r&&this.size--,this},a.prototype.flip=function(e){var t=e>>5,n=e&31,r=this.array[t],i=this.array[t]^=1<<n;return i>>>=0,i>r?this.size++:i<r&&this.size--,this},a.prototype.get=function(e){var t=e>>5,n=e&31;return this.array[t]>>n&1},a.prototype.test=function(e){return!!this.get(e)},a.prototype.rank=function(e){if(this.size===0)return 0;for(var t=e>>5,n=e&31,r=0,a=0;a<t;a++)r+=i.table8Popcount(this.array[a]);var o=this.array[t]&(1<<n)-1;return r+=i.table8Popcount(o),r},a.prototype.select=function(e){if(this.size===0||e>=this.length)return-1;for(var t,n=32,r=0,i=0,a=0,o=this.array.length;a<o;a++)if(t=this.array[a],t!==0){a===o-1&&(n=this.length%32||32);for(var s=0;s<n;s++,r++)if(i+=t>>s&1,i===e)return r}},a.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.length,r,i,a=32,o=0,s=this.array.length;o<s;o++){r=this.array[o],o===s-1&&(a=n%32||32);for(var c=0;c<a;c++)i=r>>c&1,e.call(t,i,o*32+c)}},a.prototype.values=function(){var e=this.length,t=!1,r,i,a=this.array,o=a.length,s=0,c=-1,l=32;return new n(function n(){if(!t){if(s>=o)return{done:!0};s===o-1&&(l=e%32||32),r=a[s++],t=!0,c=-1}return c++,c>=l?(t=!1,n()):(i=r>>c&1,{value:i})})},a.prototype.entries=function(){var e=this.length,t=!1,r,i,a=this.array,o,s=a.length,c=0,l=-1,u=32;return new n(function n(){if(!t){if(c>=s)return{done:!0};c===s-1&&(u=e%32||32),r=a[c++],t=!0,l=-1}return l++,o=~-c*32+l,l>=u?(t=!1,n()):(i=r>>l&1,{value:[o,i]})})},typeof Symbol<`u`&&(a.prototype[Symbol.iterator]=a.prototype.values),a.prototype.inspect=function(){var e=new Uint8Array(this.length);return this.forEach(function(t,n){e[n]=t}),Object.defineProperty(e,"constructor",{value:a,enumerable:!1}),e},typeof Symbol<`u`&&(a.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a.prototype.inspect),a.prototype.toJSON=function(){return Array.from(this.array)},t.exports=a})),h=t(((e,t)=>{var n=r(),i=p(),a=function(e){return Math.max(1,Math.ceil(e*1.5))};function o(e){return new Uint32Array(Math.ceil(e/32))}function s(e){var t=e||0,n=a;typeof e==`object`&&(t=e.initialLength||e.initialCapacity||0,n=e.policy||n),this.size=0,this.length=t,this.capacity=Math.ceil(this.length/32)*32,this.policy=n,this.array=o(this.capacity)}s.prototype.set=function(e,t){if(this.length<e)throw Error(`BitVector.set: index out of bounds.`);var n=e>>5,r=e&31,i=this.array[n],a=t===0||t===!1?this.array[n]&=~(1<<r):this.array[n]|=1<<r;return a>>>=0,a>i?this.size++:a<i&&this.size--,this},s.prototype.reset=function(e){var t=e>>5,n=e&31,r=this.array[t];return(this.array[t]&=~(1<<n))<r&&this.size--,this},s.prototype.flip=function(e){var t=e>>5,n=e&31,r=this.array[t],i=this.array[t]^=1<<n;return i>>>=0,i>r?this.size++:i<r&&this.size--,this},s.prototype.applyPolicy=function(e){var t=this.policy(e||this.capacity);if(typeof t!=`number`||t<0)throw Error(`mnemonist/bit-vector.applyPolicy: policy returned an invalid value (expecting a positive integer).`);if(t<=this.capacity)throw Error(`mnemonist/bit-vector.applyPolicy: policy returned a less or equal capacity to allocate.`);return Math.ceil(t/32)*32},s.prototype.reallocate=function(e){var t=e;if(e=Math.ceil(e/32)*32,t<this.length&&(this.length=t),e===this.capacity)return this;var n=this.array,r=e/32;return r===this.array.length?this:(r>this.array.length?(this.array=new Uint32Array(r),this.array.set(n,0)):this.array=n.slice(0,r),this.capacity=e,this)},s.prototype.grow=function(e){var t;if(typeof e==`number`){if(this.capacity>=e)return this;for(t=this.capacity;t<e;)t=this.applyPolicy(t);return this.reallocate(t),this}return t=this.applyPolicy(),this.reallocate(t),this},s.prototype.resize=function(e){return e===this.length?this:e<this.length?(this.length=e,this):(this.length=e,this.reallocate(e),this)},s.prototype.push=function(e){if(this.capacity===this.length&&this.grow(),e===0||e===!1)return++this.length;this.size++;var t=this.length++,n=t>>5,r=t&31;return this.array[n]|=1<<r,this.length},s.prototype.pop=function(){if(this.length!==0){var e=--this.length,t=e>>5,n=e&31;return this.array[t]>>n&1}},s.prototype.get=function(e){if(!(this.length<e)){var t=e>>5,n=e&31;return this.array[t]>>n&1}},s.prototype.test=function(e){return this.length<e?!1:!!this.get(e)},s.prototype.rank=function(e){if(this.size===0)return 0;for(var t=e>>5,n=e&31,r=0,a=0;a<t;a++)r+=i.table8Popcount(this.array[a]);var o=this.array[t]&(1<<n)-1;return r+=i.table8Popcount(o),r},s.prototype.select=function(e){if(this.size===0||e>=this.length)return-1;for(var t,n=32,r=0,i=0,a=0,o=this.array.length;a<o;a++)if(t=this.array[a],t!==0){a===o-1&&(n=this.length%32||32);for(var s=0;s<n;s++,r++)if(i+=t>>s&1,i===e)return r}},s.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.length,r,i,a=32,o=0,s=this.array.length;o<s;o++){r=this.array[o],o===s-1&&(a=n%32||32);for(var c=0;c<a;c++)i=r>>c&1,e.call(t,i,o*32+c)}},s.prototype.values=function(){var e=this.length,t=!1,r,i,a=this.array,o=a.length,s=0,c=-1,l=32;return new n(function n(){if(!t){if(s>=o)return{done:!0};s===o-1&&(l=e%32||32),r=a[s++],t=!0,c=-1}return c++,c>=l?(t=!1,n()):(i=r>>c&1,{value:i})})},s.prototype.entries=function(){var e=this.length,t=!1,r,i,a=this.array,o,s=a.length,c=0,l=-1,u=32;return new n(function n(){if(!t){if(c>=s)return{done:!0};c===s-1&&(u=e%32||32),r=a[c++],t=!0,l=-1}return l++,o=~-c*32+l,l>=u?(t=!1,n()):(i=r>>l&1,{value:[o,i]})})},typeof Symbol<`u`&&(s.prototype[Symbol.iterator]=s.prototype.values),s.prototype.inspect=function(){var e=new Uint8Array(this.length);return this.forEach(function(t,n){e[n]=t}),Object.defineProperty(e,"constructor",{value:s,enumerable:!1}),e},typeof Symbol<`u`&&(s.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=s.prototype.inspect),s.prototype.toJSON=function(){return Array.from(this.array.slice(0,(this.length>>5)+1))},t.exports=s})),g=t(((e,t)=>{function n(e,t){return(e&65535)*t+(((e>>>16)*t&65535)<<16)&4294967295}function r(e,t){return(e&65535)+(t>>>16)+(((e>>>16)+t&65535)<<16)&4294967295}function i(e,t){return e<<t|e>>>32-t}t.exports=function e(t,a){var o=3432918353,s=461845907,c=15,l=13,u=5,d=1801774676,f=t,p,m,h;for(m=0,h=a.length-4;m<=h;m+=4)p=a[m]|a[m+1]<<8|a[m+2]<<16|a[m+3]<<24,p=n(p,o),p=i(p,c),p=n(p,s),f^=p,f=i(f,l),f=n(f,u),f=r(f,d);switch(p=0,a.length&3){case 3:p^=a[m+2]<<16;case 2:p^=a[m+1]<<8;case 1:p^=a[m],p=n(p,o),p=i(p,c),p=n(p,s),f^=p;default:}return f^=a.length,f^=f>>>16,f=n(f,2246822507),f^=f>>>13,f=n(f,3266489909),f^=f>>>16,f>>>0}})),_=t(((e,t)=>{var r=g(),i=n(),a=Math.LN2*Math.LN2,o={errorRate:.005};function s(e){var t=new Uint16Array(e.length),n,r;for(n=0,r=e.length;n<r;n++)t[n]=e.charCodeAt(n);return t}function c(e,t,n){return r(t*4221880213&4294967295,n)%(e*8)}function l(e){var t={};if(!e)throw Error(`mnemonist/BloomFilter.constructor: a BloomFilter must be created with a capacity.`);if(typeof e==`object`?t=e:t.capacity=e,typeof t.capacity!=`number`||t.capacity<=0)throw Error("mnemonist/BloomFilter.constructor: `capacity` option should be a positive integer.");if(this.capacity=t.capacity,this.errorRate=t.errorRate||o.errorRate,typeof this.errorRate!=`number`||t.errorRate<=0)throw Error("mnemonist/BloomFilter.constructor: `errorRate` option should be a positive float.");this.clear()}l.prototype.clear=function(){var e=-1/a*this.capacity*Math.log(this.errorRate)/8|0;this.hashFunctions=e*8/this.capacity*Math.LN2|0,this.data=new Uint8Array(e)},l.prototype.add=function(e){for(var t=s(e),n=0,r=this.hashFunctions;n<r;n++){var i=c(this.data.length,n,t),a=1<<(7&i);this.data[i>>3]|=a}return this},l.prototype.test=function(e){for(var t=s(e),n=0,r=this.hashFunctions;n<r;n++){var i=c(this.data.length,n,t);if(!(this.data[i>>3]&1<<(7&i)))return!1}return!0},l.prototype.toJSON=function(){return this.data},l.from=function(e,t){if(!t&&(t=e.length||e.size,typeof t!=`number`))throw Error(`BloomFilter.from: could not infer the filter's capacity. Try passing it as second argument.`);var n=new l(t);return i(e,function(e){n.add(e)}),n},t.exports=l})),v=t(((e,t)=>{var r=n();function i(e){if(typeof e!=`function`)throw Error("mnemonist/BKTree.constructor: given `distance` should be a function.");this.distance=e,this.clear()}i.prototype.add=function(e){if(!this.root)return this.root={item:e,children:{}},this.size++,this;for(var t=this.root,n;n=this.distance(e,t.item),t.children[n];)t=t.children[n];return t.children[n]={item:e,children:{}},this.size++,this},i.prototype.search=function(e,t){if(!this.root)return[];for(var n=[],r=[this.root],i,a,o,s,c;r.length;)for(i=r.pop(),o=this.distance(t,i.item),o<=e&&n.push({item:i.item,distance:o}),s=o-e,c=o+e+1;s<c;s++)a=i.children[s],a&&r.push(a);return n},i.prototype.clear=function(){this.size=0,this.root=null},i.prototype.toJSON=function(){return this.root},i.prototype.inspect=function(){for(var e=[],t=[this.root],n,r;t.length;)if(n=t.pop(),n)for(r in e.push(n.item),n.children)t.push(n.children[r]);return Object.defineProperty(e,"constructor",{value:i,enumerable:!1}),e},typeof Symbol<`u`&&(i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=i.prototype.inspect),i.from=function(e,t){var n=new i(t);return r(e,function(e){n.add(e)}),n},t.exports=i})),y=t(((e,t)=>{var n=c(),i=r();function a(e,t){if(arguments.length<2)throw Error(`mnemonist/fixed-deque: expecting an Array class and a capacity.`);if(typeof t!=`number`||t<=0)throw Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=e,this.capacity=t,this.items=new e(this.capacity),this.clear()}a.prototype.clear=function(){this.start=0,this.size=0},a.prototype.push=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-deque.push: deque capacity (`+this.capacity+`) exceeded!`);var t=this.start+this.size;return t>=this.capacity&&(t-=this.capacity),this.items[t]=e,++this.size},a.prototype.unshift=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-deque.unshift: deque capacity (`+this.capacity+`) exceeded!`);var t=this.start-1;return this.start===0&&(t=this.capacity-1),this.items[t]=e,this.start=t,++this.size},a.prototype.pop=function(){if(this.size!==0){this.size--;var e=this.start+this.size;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},a.prototype.shift=function(){if(this.size!==0){var e=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[e]}},a.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]},a.prototype.peekLast=function(){if(this.size!==0){var e=this.start+this.size-1;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},a.prototype.get=function(e){if(!(this.size===0||e>=this.capacity))return e=this.start+e,e>=this.capacity&&(e-=this.capacity),this.items[e]},a.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.capacity,r=this.size,i=this.start,a=0;a<r;)e.call(t,this.items[i],a,this),i++,a++,i===n&&(i=0)},a.prototype.toArray=function(){var e=this.start+this.size;if(e<this.capacity)return this.items.slice(this.start,e);for(var t=new this.ArrayClass(this.size),n=this.capacity,r=this.size,i=this.start,a=0;a<r;)t[a]=this.items[i],i++,a++,i===n&&(i=0);return t},a.prototype.values=function(){var e=this.items,t=this.capacity,n=this.size,r=this.start,a=0;return new i(function(){if(a>=n)return{done:!0};var i=e[r];return r++,a++,r===t&&(r=0),{value:i,done:!1}})},a.prototype.entries=function(){var e=this.items,t=this.capacity,n=this.size,r=this.start,a=0;return new i(function(){if(a>=n)return{done:!0};var i=e[r];return r++,r===t&&(r=0),{value:[a++,i],done:!1}})},typeof Symbol<`u`&&(a.prototype[Symbol.iterator]=a.prototype.values),a.prototype.inspect=function(){var e=this.toArray();return e.type=this.ArrayClass.name,e.capacity=this.capacity,Object.defineProperty(e,"constructor",{value:a,enumerable:!1}),e},typeof Symbol<`u`&&(a.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a.prototype.inspect),a.from=function(e,t,r){if(arguments.length<3&&(r=n.guessLength(e),typeof r!=`number`))throw Error(`mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.`);var i=new a(t,r);if(n.isArrayLike(e)){var o,s;for(o=0,s=e.length;o<s;o++)i.items[o]=e[o];return i.size=s,i}return n.forEach(e,function(e){i.push(e)}),i},t.exports=a})),b=t(((e,t)=>{var n=c(),r=y();function i(e,t){if(arguments.length<2)throw Error(`mnemonist/circular-buffer: expecting an Array class and a capacity.`);if(typeof t!=`number`||t<=0)throw Error("mnemonist/circular-buffer: `capacity` should be a positive number.");this.ArrayClass=e,this.capacity=t,this.items=new e(this.capacity),this.clear()}function a(e){i.prototype[e]=r.prototype[e]}Object.keys(r.prototype).forEach(a),typeof Symbol<`u`&&Object.getOwnPropertySymbols(r.prototype).forEach(a),i.prototype.push=function(e){var t=this.start+this.size;return t>=this.capacity&&(t-=this.capacity),this.items[t]=e,this.size===this.capacity?(t++,t>=this.capacity?this.start=0:this.start=t,this.size):++this.size},i.prototype.unshift=function(e){var t=this.start-1;return this.start===0&&(t=this.capacity-1),this.items[t]=e,this.size===this.capacity?(this.start=t,this.size):(this.start=t,++this.size)},i.from=function(e,t,r){if(arguments.length<3&&(r=n.guessLength(e),typeof r!=`number`))throw Error(`mnemonist/circular-buffer.from: could not guess iterable length. Please provide desired capacity as last argument.`);var a=new i(t,r);if(n.isArrayLike(e)){var o,s;for(o=0,s=e.length;o<s;o++)a.items[o]=e[o];return a.size=s,a}return n.forEach(e,function(e){a.push(e)}),a},t.exports=i})),x=t(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`mnemonist/DefaultMap.constructor: expecting a function.`);this.items=new Map,this.factory=e,this.size=0}n.prototype.clear=function(){this.items.clear(),this.size=0},n.prototype.get=function(e){var t=this.items.get(e);return t===void 0&&(t=this.factory(e,this.size),this.items.set(e,t),this.size++),t},n.prototype.peek=function(e){return this.items.get(e)},n.prototype.set=function(e,t){return this.items.set(e,t),this.size=this.items.size,this},n.prototype.has=function(e){return this.items.has(e)},n.prototype.delete=function(e){var t=this.items.delete(e);return this.size=this.items.size,t},n.prototype.forEach=function(e,t){t=arguments.length>1?t:this,this.items.forEach(e,t)},n.prototype.entries=function(){return this.items.entries()},n.prototype.keys=function(){return this.items.keys()},n.prototype.values=function(){return this.items.values()},typeof Symbol<`u`&&(n.prototype[Symbol.iterator]=n.prototype.entries),n.prototype.inspect=function(){return this.items},typeof Symbol<`u`&&(n.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=n.prototype.inspect),n.autoIncrement=function(){var e=0;return function(){return e++}},t.exports=n})),S=t(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`mnemonist/DefaultWeakMap.constructor: expecting a function.`);this.items=new WeakMap,this.factory=e}n.prototype.clear=function(){this.items=new WeakMap},n.prototype.get=function(e){var t=this.items.get(e);return t===void 0&&(t=this.factory(e),this.items.set(e,t)),t},n.prototype.peek=function(e){return this.items.get(e)},n.prototype.set=function(e,t){return this.items.set(e,t),this},n.prototype.has=function(e){return this.items.has(e)},n.prototype.delete=function(e){return this.items.delete(e)},n.prototype.inspect=function(){return this.items},typeof Symbol<`u`&&(n.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=n.prototype.inspect),t.exports=n})),C=t(((e,t)=>{var n=s();function r(e){var t=n.getPointerArray(e),r=n.getPointerArray(Math.log2(e));this.size=e,this.dimension=e,this.parents=new t(e),this.ranks=new r(e);for(var i=0;i<e;i++)this.parents[i]=i}r.prototype.find=function(e){for(var t=e,n,r;n=this.parents[t],t!==n;)t=n;for(;r=this.parents[e],r!==t;)this.parents[e]=t,e=r;return t},r.prototype.union=function(e,t){var n=this.find(e),r=this.find(t);if(n===r)return this;this.dimension--;var i=this.ranks[e],a=this.ranks[t];return i<a?this.parents[n]=r:i>a?this.parents[r]=n:(this.parents[r]=n,this.ranks[n]++),this},r.prototype.connected=function(e,t){return this.find(e)===this.find(t)},r.prototype.mapping=function(){for(var e=n.getPointerArray(this.dimension),t={},r=new e(this.size),i=0,a,o=0,s=this.parents.length;o<s;o++)a=this.find(o),t[a]===void 0?(r[o]=i,t[a]=i++):r[o]=t[a];return r},r.prototype.compile=function(){for(var e={},t=Array(this.dimension),n=0,r,i=0,a=this.parents.length;i<a;i++)r=this.find(i),e[r]===void 0?(t[n]=[i],e[r]=n++):t[e[r]].push(i);return t},r.prototype.inspect=function(){var e=this.compile();return Object.defineProperty(e,"constructor",{value:r,enumerable:!1}),e},typeof Symbol<`u`&&(r.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=r.prototype.inspect),t.exports=r})),w=t(((e,t)=>{var n=a(),r=l(),i=n.DEFAULT_COMPARATOR,o=n.reverseComparator;function s(e,t,n,i){for(var a=n,o=i,s=t[i],c=2*i+1,l;c<a;)l=c+1,l<a&&e(t[c],t[l])>=0&&(c=l),t[i]=t[c],i=c,c=2*i+1;t[i]=s,r.siftDown(e,t,o,i)}function c(e,t,n,r){for(var i=r,a=new e(r),o,c;i>0;)o=n[--i],i!==0&&(c=n[0],n[0]=o,s(t,n,--r,0),o=c),a[i]=o;return a}function u(e,t,n){if(arguments.length===2&&(n=t,t=null),this.ArrayClass=e,this.capacity=n,this.items=new e(n),this.clear(),this.comparator=t||i,typeof n!=`number`&&n<=0)throw Error(`mnemonist/FixedReverseHeap.constructor: capacity should be a number > 0.`);if(typeof this.comparator!=`function`)throw Error(`mnemonist/FixedReverseHeap.constructor: given comparator should be a function.`);this.comparator=o(this.comparator)}u.prototype.clear=function(){this.size=0},u.prototype.push=function(e){return this.size<this.capacity?(this.items[this.size]=e,r.siftDown(this.comparator,this.items,0,this.size),this.size++):this.comparator(e,this.items[0])>0&&r.replace(this.comparator,this.items,e),this.size},u.prototype.peek=function(){return this.items[0]},u.prototype.consume=function(){var e=c(this.ArrayClass,this.comparator,this.items,this.size);return this.size=0,e},u.prototype.toArray=function(){return c(this.ArrayClass,this.comparator,this.items.slice(0,this.size),this.size)},u.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,"constructor",{value:u,enumerable:!1}),e},typeof Symbol<`u`&&(u.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=u.prototype.inspect),t.exports=u})),T=t(((e,t)=>{var r=n(),i=function(e){return e};function a(e){if(this.items=new Map,this.clear(),Array.isArray(e)?(this.writeHashFunction=e[0],this.readHashFunction=e[1]):(this.writeHashFunction=e,this.readHashFunction=e),this.writeHashFunction||=i,this.readHashFunction||=i,typeof this.writeHashFunction!=`function`||typeof this.readHashFunction!=`function`)throw Error(`mnemonist/FuzzyMap.constructor: invalid hash function given.`)}a.prototype.clear=function(){this.items.clear(),this.size=0},a.prototype.add=function(e){var t=this.writeHashFunction(e);return this.items.set(t,e),this.size=this.items.size,this},a.prototype.set=function(e,t){return e=this.writeHashFunction(e),this.items.set(e,t),this.size=this.items.size,this},a.prototype.get=function(e){return e=this.readHashFunction(e),this.items.get(e)},a.prototype.has=function(e){return e=this.readHashFunction(e),this.items.has(e)},a.prototype.forEach=function(e,t){t=arguments.length>1?t:this,this.items.forEach(function(n){e.call(t,n,n)})},a.prototype.values=function(){return this.items.values()},typeof Symbol<`u`&&(a.prototype[Symbol.iterator]=a.prototype.values),a.prototype.inspect=function(){var e=Array.from(this.items.values());return Object.defineProperty(e,"constructor",{value:a,enumerable:!1}),e},typeof Symbol<`u`&&(a.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a.prototype.inspect),a.from=function(e,t,n){var i=new a(t);return r(e,function(e,t){n?i.set(t,e):i.add(e)}),i},t.exports=a})),E=t(((e,t)=>{var i=r(),a=n();function o(e){this.Container=e||Array,this.items=new Map,this.clear(),Object.defineProperty(this.items,"constructor",{value:o,enumerable:!1})}o.prototype.clear=function(){this.size=0,this.dimension=0,this.items.clear()},o.prototype.set=function(e,t){var n=this.items.get(e),r;return n||(this.dimension++,n=new this.Container,this.items.set(e,n)),this.Container===Set?(r=n.size,n.add(t),r<n.size&&this.size++):(n.push(t),this.size++),this},o.prototype.delete=function(e){var t=this.items.get(e);return t?(this.size-=this.Container===Set?t.size:t.length,this.dimension--,this.items.delete(e),!0):!1},o.prototype.remove=function(e,t){var n=this.items.get(e),r,i;return n?this.Container===Set?(r=n.delete(t),r&&this.size--,n.size===0&&(this.items.delete(e),this.dimension--),r):(i=n.indexOf(t),i===-1?!1:(this.size--,n.length===1?(this.items.delete(e),this.dimension--,!0):(n.splice(i,1),!0))):!1},o.prototype.has=function(e){return this.items.has(e)},o.prototype.get=function(e){return this.items.get(e)},o.prototype.multiplicity=function(e){var t=this.items.get(e);return t===void 0?0:this.Container===Set?t.size:t.length},o.prototype.count=o.prototype.multiplicity,o.prototype.forEach=function(e,t){t=arguments.length>1?t:this;var n;function r(r){e.call(t,r,n)}this.items.forEach(function(e,t){n=t,e.forEach(r)})},o.prototype.forEachAssociation=function(e,t){t=arguments.length>1?t:this,this.items.forEach(e,t)},o.prototype.keys=function(){return this.items.keys()},o.prototype.values=function(){var e=this.items.values(),t=!1,n,r,a,o;return this.Container===Set?new i(function i(){if(!t){if(r=e.next(),r.done)return{done:!0};t=!0,n=r.value.values()}return r=n.next(),r.done?(t=!1,i()):{done:!1,value:r.value}}):new i(function i(){if(!t){if(r=e.next(),r.done)return{done:!0};t=!0,n=r.value,a=0,o=n.length}return a>=o?(t=!1,i()):{done:!1,value:n[a++]}})},o.prototype.entries=function(){var e=this.items.entries(),t=!1,n,r,a,o,s;return this.Container===Set?new i(function i(){if(!t){if(r=e.next(),r.done)return{done:!0};t=!0,a=r.value[0],n=r.value[1].values()}return r=n.next(),r.done?(t=!1,i()):{done:!1,value:[a,r.value]}}):new i(function i(){if(!t){if(r=e.next(),r.done)return{done:!0};t=!0,a=r.value[0],n=r.value[1],o=0,s=n.length}return o>=s?(t=!1,i()):{done:!1,value:[a,n[o++]]}})},o.prototype.containers=function(){return this.items.values()},o.prototype.associations=function(){return this.items.entries()},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.entries),o.prototype.inspect=function(){return this.items},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.prototype.toJSON=function(){return this.items},o.from=function(e,t){var n=new o(t);return a(e,function(e,t){n.set(t,e)}),n},t.exports=o})),D=t(((e,t)=>{var r=E(),i=n(),a=function(e){return e};function o(e,t){if(this.items=new r(t),this.clear(),Array.isArray(e)?(this.writeHashFunction=e[0],this.readHashFunction=e[1]):(this.writeHashFunction=e,this.readHashFunction=e),this.writeHashFunction||=a,this.readHashFunction||=a,typeof this.writeHashFunction!=`function`||typeof this.readHashFunction!=`function`)throw Error(`mnemonist/FuzzyMultiMap.constructor: invalid hash function given.`)}o.prototype.clear=function(){this.items.clear(),this.size=0,this.dimension=0},o.prototype.add=function(e){var t=this.writeHashFunction(e);return this.items.set(t,e),this.size=this.items.size,this.dimension=this.items.dimension,this},o.prototype.set=function(e,t){return e=this.writeHashFunction(e),this.items.set(e,t),this.size=this.items.size,this.dimension=this.items.dimension,this},o.prototype.get=function(e){return e=this.readHashFunction(e),this.items.get(e)},o.prototype.has=function(e){return e=this.readHashFunction(e),this.items.has(e)},o.prototype.forEach=function(e,t){t=arguments.length>1?t:this,this.items.forEach(function(n){e.call(t,n,n)})},o.prototype.values=function(){return this.items.values()},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.values),o.prototype.inspect=function(){var e=Array.from(this);return Object.defineProperty(e,"constructor",{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.from=function(e,t,n,r){arguments.length===3&&typeof n==`boolean`&&(r=n,n=Array);var a=new o(t,n);return i(e,function(e,t){r?a.set(t,e):a.add(e)}),a},t.exports=o})),ee=t(((e,t)=>{var n=1024;function r(e){return(e&e-1)==0}function i(e,t){if(arguments.length<1)throw Error(`mnemonist/hashed-array-tree: expecting at least a byte array constructor.`);var i=t||0,a=n,o=0;if(typeof t==`object`&&(i=t.initialCapacity||0,o=t.initialLength||0,a=t.blockSize||n),!a||!r(a))throw Error(`mnemonist/hashed-array-tree: block size should be a power of two.`);var s=Math.ceil(Math.max(o,i)/a);this.ArrayClass=e,this.length=o,this.capacity=s*a,this.blockSize=a,this.offsetMask=a-1,this.blockMask=Math.log2(a),this.blocks=Array(s);for(var c=0;c<s;c++)this.blocks[c]=new this.ArrayClass(this.blockSize)}i.prototype.set=function(e,t){if(this.length<e)throw Error(`HashedArrayTree(`+this.ArrayClass.name+`).set: index out of bounds.`);var n=e>>this.blockMask,r=e&this.offsetMask;return this.blocks[n][r]=t,this},i.prototype.get=function(e){if(!(this.length<e)){var t=e>>this.blockMask,n=e&this.offsetMask;return this.blocks[t][n]}},i.prototype.grow=function(e){if(typeof e!=`number`&&(e=this.capacity+this.blockSize),this.capacity>=e)return this;for(;this.capacity<e;)this.blocks.push(new this.ArrayClass(this.blockSize)),this.capacity+=this.blockSize;return this},i.prototype.resize=function(e){return e===this.length?this:e<this.length?(this.length=e,this):(this.length=e,this.grow(e),this)},i.prototype.push=function(e){this.capacity===this.length&&this.grow();var t=this.length,n=t>>this.blockMask,r=t&this.offsetMask;return this.blocks[n][r]=e,++this.length},i.prototype.pop=function(){if(this.length!==0)return this.blocks[this.blocks.length-1][--this.length&this.offsetMask]},i.prototype.inspect=function(){for(var e=new this.ArrayClass(this.length),t,n=0,r=this.length;n<r;n++)t=n>>this.blockMask,e[n]=this.blocks[t][n&this.offsetMask];return e.type=this.ArrayClass.name,e.items=this.length,e.capacity=this.capacity,e.blockSize=this.blockSize,Object.defineProperty(e,"constructor",{value:i,enumerable:!1}),e},typeof Symbol<`u`&&(i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=i.prototype.inspect),t.exports=i})),O=t(((e,t)=>{var n=r(),i=c();function a(e,t){if(arguments.length<2)throw Error(`mnemonist/fixed-stack: expecting an Array class and a capacity.`);if(typeof t!=`number`||t<=0)throw Error("mnemonist/fixed-stack: `capacity` should be a positive number.");this.capacity=t,this.ArrayClass=e,this.items=new this.ArrayClass(this.capacity),this.clear()}a.prototype.clear=function(){this.size=0},a.prototype.push=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-stack.push: stack capacity (`+this.capacity+`) exceeded!`);return this.items[this.size++]=e,this.size},a.prototype.pop=function(){if(this.size!==0)return this.items[--this.size]},a.prototype.peek=function(){return this.items[this.size-1]},a.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=0,r=this.items.length;n<r;n++)e.call(t,this.items[r-n-1],n,this)},a.prototype.toArray=function(){for(var e=new this.ArrayClass(this.size),t=this.size-1,n=this.size;n--;)e[n]=this.items[t-n];return e},a.prototype.values=function(){var e=this.items,t=this.size,r=0;return new n(function(){if(r>=t)return{done:!0};var n=e[t-r-1];return r++,{value:n,done:!1}})},a.prototype.entries=function(){var e=this.items,t=this.size,r=0;return new n(function(){if(r>=t)return{done:!0};var n=e[t-r-1];return{value:[r++,n],done:!1}})},typeof Symbol<`u`&&(a.prototype[Symbol.iterator]=a.prototype.values),a.prototype.toString=function(){return this.toArray().join(`,`)},a.prototype.toJSON=function(){return this.toArray()},a.prototype.inspect=function(){var e=this.toArray();return e.type=this.ArrayClass.name,e.capacity=this.capacity,Object.defineProperty(e,"constructor",{value:a,enumerable:!1}),e},typeof Symbol<`u`&&(a.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a.prototype.inspect),a.from=function(e,t,n){if(arguments.length<3&&(n=i.guessLength(e),typeof n!=`number`))throw Error(`mnemonist/fixed-stack.from: could not guess iterable length. Please provide desired capacity as last argument.`);var r=new a(t,n);if(i.isArrayLike(e)){var o,s;for(o=0,s=e.length;o<s;o++)r.items[o]=e[o];return r.size=s,r}return i.forEach(e,function(e){r.push(e)}),r},t.exports=a})),k=t(((e,t)=>{var n=c(),r=s(),i=O();function a(e,t,n,r,i,o,s,c){var l=s+(c-s)/2|0,u=~-l,d=-~l,f=n[l];r[o]=f+1;var p=t?t(e[f]):e[f][1],m=o*2+1,h=o*2+2,g=-1/0,_=-1/0;s<=u&&(g=a(e,t,n,r,i,m,s,u)),d<=c&&(_=a(e,t,n,r,i,h,d,c));var v=Math.max(p,g,_),y=f;return v===g?y=i[r[m]-1]:v===_&&(y=i[r[h]-1]),i[f]=y,v}function o(e,t){this.size=e.length,this.intervals=e;var n=null,o=null;Array.isArray(t)&&(n=t[0],o=t[1]);var s=e.length,c=r.getPointerArray(s+1),l=new c(s),u;for(u=1;u<s;u++)l[u]=u;l.sort(function(t,r){return t=e[t],r=e[r],n?(t=n(t),r=n(r)):(t=t[0],r=r[0]),t<r?-1:+(t>r)});var d=Math.ceil(Math.log2(s+1)),f=new c(2**d-1),p=new c(s);a(e,o,l,f,p,0,0,s-1),l=null,this.height=d,this.tree=f,this.augmentations=p,this.startGetter=n,this.endGetter=o,this.stack=new i(c,this.height)}o.prototype.intervalsContainingPoint=function(e){var t=[],n=this.stack;n.clear(),n.push(0);for(var r=this.tree.length,i,a,o,s,c,l,u,d,f;n.size;)i=n.pop(),a=this.tree[i]-1,o=this.intervals[a],s=this.intervals[this.augmentations[a]],u=this.endGetter?this.endGetter(s):s[1],!(e>u)&&(d=i*2+1,d<r&&this.tree[d]!==0&&n.push(d),c=this.startGetter?this.startGetter(o):o[0],l=this.endGetter?this.endGetter(o):o[1],e>=c&&e<=l&&t.push(o),!(e<c)&&(f=i*2+2,f<r&&this.tree[f]!==0&&n.push(f)));return t},o.prototype.intervalsOverlappingInterval=function(e){var t=this.startGetter?this.startGetter(e):e[0],n=this.endGetter?this.endGetter(e):e[1],r=[],i=this.stack;i.clear(),i.push(0);for(var a=this.tree.length,o,s,c,l,u,d,f,p,m;i.size;)o=i.pop(),s=this.tree[o]-1,c=this.intervals[s],l=this.intervals[this.augmentations[s]],f=this.endGetter?this.endGetter(l):l[1],!(t>f)&&(p=o*2+1,p<a&&this.tree[p]!==0&&i.push(p),u=this.startGetter?this.startGetter(c):c[0],d=this.endGetter?this.endGetter(c):c[1],n>=u&&t<=d&&r.push(c),!(n<u)&&(m=o*2+2,m<a&&this.tree[m]!==0&&i.push(m)));return r},o.prototype.inspect=function(){var e=this.intervals.slice();return Object.defineProperty(e,"constructor",{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.from=function(e,t){return n.isArrayLike(e)?new o(e,t):new o(Array.from(e),t)},t.exports=o})),A=t((e=>{e.search=function(e,t,n,r){var i=0;n=n===void 0?0:n,r=r===void 0?e.length:r,r--;for(var a;n<=r;)if(i=n+r>>>1,a=e[i],a>t)r=~-i;else if(a<t)n=-~i;else return i;return-1},e.searchWithComparator=function(e,t,n){for(var r=0,i=0,a=~-t.length,o;i<=a;)if(r=i+a>>>1,o=e(t[r],n),o>0)a=~-r;else if(o<0)i=-~r;else return r;return-1},e.lowerBound=function(e,t,n,r){var i=0;for(n=n===void 0?0:n,r=r===void 0?e.length:r;n<r;)i=n+r>>>1,t<=e[i]?r=i:n=-~i;return n},e.lowerBoundWithComparator=function(e,t,n){for(var r=0,i=0,a=t.length;i<a;)r=i+a>>>1,e(n,t[r])<=0?a=r:i=-~r;return i},e.lowerBoundIndices=function(e,t,n,r,i){var a=0;for(r=r===void 0?0:r,i=i===void 0?e.length:i;r<i;)a=r+i>>>1,n<=e[t[a]]?i=a:r=-~a;return r},e.upperBound=function(e,t,n,r){var i=0;for(n=n===void 0?0:n,r=r===void 0?e.length:r;n<r;)i=n+r>>>1,t>=e[i]?n=-~i:r=i;return n},e.upperBoundWithComparator=function(e,t,n){for(var r=0,i=0,a=t.length;i<a;)r=i+a>>>1,e(n,t[r])>=0?i=-~r:a=r;return i}})),j=t((e=>{var t=s(),n=c().isArrayLike,r=A(),i=o();function a(e,n){if(e.length===0)return n.slice();if(n.length===0)return e.slice();var r;e[0]>n[0]&&(r=e,e=n,n=r);var i=e[e.length-1],a=n[0];if(i<=a)return t.isTypedArray(e)?t.concat(e,n):e.concat(n);var o=new e.constructor(e.length+n.length),s,c,l;for(s=0,c=e.length;s<c&&(l=e[s],l<=a);s++)o[s]=l;for(var u=s,d=e.length,f=0,p=n.length,m,h;u<d&&f<p;)m=e[u],h=n[f],m<=h?(o[s++]=m,u++):(o[s++]=h,f++);for(;u<d;)o[s++]=e[u++];for(;f<p;)o[s++]=n[f++];return o}function l(e,n){if(e.length===0)return n.slice();if(n.length===0)return e.slice();var r;e[0]>n[0]&&(r=e,e=n,n=r);var i=e[e.length-1],a=n[0];if(i<a)return t.isTypedArray(e)?t.concat(e,n):e.concat(n);var o=new e.constructor,s,c,l;for(s=0,c=e.length;s<c&&(l=e[s],l<a);s++)o.push(l);for(var u=s,d=e.length,f=0,p=n.length,m,h;u<d&&f<p;)m=e[u],h=n[f],m<=h?((o.length===0||o[o.length-1]!==m)&&o.push(m),u++):((o.length===0||o[o.length-1]!==h)&&o.push(h),f++);for(;u<d;)m=e[u++],(o.length===0||o[o.length-1]!==m)&&o.push(m);for(;f<p;)h=n[f++],(o.length===0||o[o.length-1]!==h)&&o.push(h);return o}e.intersectionUniqueArrays=function(e,t){if(e.length===0||t.length===0)return new e.constructor(0);var n;e[0]>t[0]&&(n=e,e=t,t=n);var i=e[e.length-1],a=t[0];if(i<a)return new e.constructor(0);for(var o=new e.constructor,s=r.lowerBound(e,a),c=e.length,l=0,u=r.upperBound(t,i),d,f;s<c&&l<u;)d=e[s],f=t[l],d<f?s=r.lowerBound(e,f,s+1):d>f?l=r.lowerBound(t,d,l+1):(o.push(d),s++,l++);return o};function u(e){var n=0,r=-1/0,o,s,c,l=[];for(s=0,c=e.length;s<c;s++)o=e[s].length,o!==0&&(l.push(e[s]),n+=o,o>r&&(r=o));if(l.length===0)return new e[0].constructor(0);if(l.length===1)return l[0].slice();if(l.length===2)return a(l[0],l[1]);e=l;var u=new e[0].constructor(n),d=new(t.getPointerArray(r))(e.length),f=new i(function(t,n){return t=e[t][d[t]],n=e[n][d[n]],t<n?-1:+(t>n)});for(s=0;s<c;s++)f.push(s);s=0;for(var p,m;f.size;)p=f.pop(),m=e[p][d[p]++],u[s++]=m,d[p]<e[p].length&&f.push(p);return u}function d(e){var n=-1/0,r,a,o,s=[];for(a=0,o=e.length;a<o;a++)r=e[a].length,r!==0&&(s.push(e[a]),r>n&&(n=r));if(s.length===0)return new e[0].constructor(0);if(s.length===1)return s[0].slice();if(s.length===2)return l(s[0],s[1]);e=s;var c=new e[0].constructor,u=new(t.getPointerArray(n))(e.length),d=new i(function(t,n){return t=e[t][u[t]],n=e[n][u[n]],t<n?-1:+(t>n)});for(a=0;a<o;a++)d.push(a);for(var f,p;d.size;)f=d.pop(),p=e[f][u[f]++],(c.length===0||c[c.length-1]!==p)&&c.push(p),u[f]<e[f].length&&d.push(f);return c}e.kWayIntersectionUniqueArrays=function(e){var t=-1/0,n=-1/0,i=1/0,a,o,s,c,l;for(c=0,l=e.length;c<l;c++){if(s=e[c].length,s===0)return[];s>t&&(t=s),a=e[c][0],o=e[c][s-1],a>n&&(n=a),o<i&&(i=o)}if(n>i)return[];if(n===i)return[n];var u,d,f=e[0],p,m,h,g,_,v,y=n;for(c=1;c<l;c++){for(u=f,d=e[c],f=[],p=0,m=r.lowerBound(d,y),h=u.length,g=d.length;p<h&&m<g;)_=u[p],v=d[m],_<v?p=r.lowerBound(u,v,p+1):_>v?m=r.lowerBound(d,_,m+1):(f.push(_),p++,m++);if(f.length===0)return f;y=f[0]}return f},e.merge=function(){if(arguments.length===2){if(n(arguments[0]))return a(arguments[0],arguments[1])}else if(n(arguments[0]))return u(arguments);return null},e.unionUnique=function(){if(arguments.length===2){if(n(arguments[0]))return l(arguments[0],arguments[1])}else if(n(arguments[0]))return d(arguments);return null},e.intersectionUnique=function(){if(arguments.length===2){if(n(arguments[0]))return e.intersectionUniqueArrays(arguments[0],arguments[1])}else if(n(arguments[0]))return e.kWayIntersectionUniqueArrays(arguments);return null}})),te=t(((e,t)=>{var i=r(),a=n(),o=j();function s(e){return e}function c(e){if(this.clear(),Array.isArray(e)?(this.documentTokenizer=e[0],this.queryTokenizer=e[1]):(this.documentTokenizer=e,this.queryTokenizer=e),this.documentTokenizer||=s,this.queryTokenizer||=s,typeof this.documentTokenizer!=`function`)throw Error(`mnemonist/InvertedIndex.constructor: document tokenizer is not a function.`);if(typeof this.queryTokenizer!=`function`)throw Error(`mnemonist/InvertedIndex.constructor: query tokenizer is not a function.`)}c.prototype.clear=function(){this.items=[],this.mapping=new Map,this.size=0,this.dimension=0},c.prototype.add=function(e){this.size++;var t=this.items.length;this.items.push(e);var n=this.documentTokenizer(e);if(!Array.isArray(n))throw Error(`mnemonist/InvertedIndex.add: tokenizer function should return an array of tokens.`);for(var r=new Set,i,a,o=0,s=n.length;o<s;o++)i=n[o],!r.has(i)&&(r.add(i),a=this.mapping.get(i),a||(a=[],this.mapping.set(i,a)),a.push(t));return this.dimension=this.mapping.size,this},c.prototype.get=function(e){if(!this.size)return[];var t=this.queryTokenizer(e);if(!Array.isArray(t))throw Error(`mnemonist/InvertedIndex.query: tokenizer function should return an array of tokens.`);if(!t.length)return[];var n=this.mapping.get(t[0]),r,i,a;if(n===void 0||n.length===0)return[];if(t.length>1)for(i=1,a=t.length;i<a;i++){if(r=this.mapping.get(t[i]),r===void 0||r.length===0)return[];n=o.intersectionUniqueArrays(n,r)}var s=Array(n.length);for(i=0,a=s.length;i<a;i++)s[i]=this.items[n[i]];return s},c.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=0,r=this.documents.length;n<r;n++)e.call(t,this.documents[n],n,this)},c.prototype.documents=function(){var e=this.items,t=e.length,n=0;return new i(function(){return n>=t?{done:!0}:{value:e[n++],done:!1}})},c.prototype.tokens=function(){return this.mapping.keys()},typeof Symbol<`u`&&(c.prototype[Symbol.iterator]=c.prototype.documents),c.prototype.inspect=function(){var e=this.items.slice();return Object.defineProperty(e,"constructor",{value:c,enumerable:!1}),e},typeof Symbol<`u`&&(c.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=c.prototype.inspect),c.from=function(e,t){var n=new c(t);return a(e,function(e){n.add(e)}),n},t.exports=c})),M=t((e=>{var t=new Float64Array(64),n=new Float64Array(64);function r(e,r,i){var a,o,s,c,l;for(t[0]=r,n[0]=i,o=0;o>=0;)if(s=t[o],c=n[o]-1,s<c){for(a=e[s];s<c;){for(;e[c]>=a&&s<c;)c--;for(s<c&&(e[s++]=e[c]);e[s]<=a&&s<c;)s++;s<c&&(e[c--]=e[s])}e[s]=a,t[o+1]=s+1,n[o+1]=n[o],n[o++]=s,n[o]-t[o]>n[o-1]-t[o-1]&&(l=t[o],t[o]=t[o-1],t[o-1]=l,l=n[o],n[o]=n[o-1],n[o-1]=l)}else o--;return e}e.inplaceQuickSort=r;function i(e,r,i,a){var o,s,c,l,u,d;for(t[0]=i,n[0]=a,s=0;s>=0;)if(c=t[s],l=n[s]-1,c<l){for(u=r[c],o=e[u];c<l;){for(;e[r[l]]>=o&&c<l;)l--;for(c<l&&(r[c++]=r[l]);e[r[c]]<=o&&c<l;)c++;c<l&&(r[l--]=r[c])}r[c]=u,t[s+1]=c+1,n[s+1]=n[s],n[s++]=c,n[s]-t[s]>n[s-1]-t[s-1]&&(d=t[s],t[s]=t[s-1],t[s-1]=d,d=n[s],n[s]=n[s-1],n[s-1]=d)}else s--;return r}e.inplaceQuickSortIndices=i})),ne=t(((e,t)=>{var n=c(),r=s(),i=a().createTupleComparator,o=w(),l=M().inplaceQuickSortIndices;function u(e,t,n,r){var i,a=0,o;for(i=0;i<e;i++)o=t[i][n]-r[i],a+=o*o;return a}function d(e,t){var n=t.length,i=Array(e),a=Array(n),o,s=new(r.getPointerArray(n))(n),c,l,u,d=!0;for(c=0;c<e;c++){for(o=new Float64Array(n),l=0;l<n;l++)u=t[l],o[l]=u[1][c],d&&(a[l]=u[0],s[l]=l);d=!1,i[c]=o}return{axes:i,ids:s,labels:a}}function f(e,t,n,i){for(var a=i.length,o=r.getPointerArray(a+1),s=new o(a),c=new o(a),u=new o(a),d=[[0,0,n.length,-1,0]],f,p,m,h,g,_,v,y,b=0;d.length!==0;)f=d.pop(),y=f[0],_=f[1],v=f[2],p=f[3],m=f[4],l(t[y],n,_,v),a=v-_,h=_+(a>>>1),g=n[h],s[b]=g,p>-1&&(m===0?c[p]=b+1:u[p]=b+1),y=(y+1)%e,h!==_&&h!==v-1&&d.push([y,h+1,v,b,1]),h!==_&&d.push([y,_,h,b,0]),b++;return{axes:t,labels:i,pivots:s,lefts:c,rights:u}}function p(e,t){this.dimensions=e,this.visited=0,this.axes=t.axes,this.labels=t.labels,this.pivots=t.pivots,this.lefts=t.lefts,this.rights=t.rights,this.size=this.labels.length}p.prototype.nearestNeighbor=function(e){var t=1/0,n=null,r=this.dimensions,i=this.axes,a=this.pivots,o=this.lefts,s=this.rights,c=0;function l(d,f){c++;var p=o[f],m=s[f],h=a[f],g=u(r,i,h,e);if(!(g<t&&(n=h,t=g,g===0))){var _=i[d][h]-e[d];d=(d+1)%r,_>0?p!==0&&l(d,p-1):m!==0&&l(d,m-1),_*_<t&&(_>0?m!==0&&l(d,m-1):p!==0&&l(d,p-1))}}return l(0,0),this.visited=c,this.labels[n]};var m=i(3),h=i(2);p.prototype.kNearestNeighbors=function(e,t){if(e<=0)throw Error(`mnemonist/kd-tree.kNearestNeighbors: k should be a positive number.`);if(e=Math.min(e,this.size),e===1)return[this.nearestNeighbor(t)];var n=new o(Array,m,e),r=this.dimensions,i=this.axes,a=this.pivots,s=this.lefts,c=this.rights,l=0;function d(o,f){var p=s[f],m=c[f],h=a[f],g=u(r,i,h,t);n.push([g,l++,h]);var _=t[o],v=i[o][h],y=_-v;o=(o+1)%r,_<v?p!==0&&d(o,p-1):m!==0&&d(o,m-1),(y*y<n.peek()[0]||n.size<e)&&(_<v?m!==0&&d(o,m-1):p!==0&&d(o,p-1))}d(0,0),this.visited=l;for(var f=n.consume(),p=0;p<f.length;p++)f[p]=this.labels[f[p][2]];return f},p.prototype.linearKNearestNeighbors=function(e,t){if(e<=0)throw Error(`mnemonist/kd-tree.kNearestNeighbors: k should be a positive number.`);e=Math.min(e,this.size);var n=new o(Array,h,e),r,i,a;for(r=0,i=this.size;r<i;r++)a=u(this.dimensions,this.axes,this.pivots[r],t),n.push([a,r]);var s=n.consume();for(r=0;r<s.length;r++)s[r]=this.labels[this.pivots[s[r][1]]];return s},p.prototype.inspect=function(){var e=new Map;e.dimensions=this.dimensions,Object.defineProperty(e,"constructor",{value:p,enumerable:!1});var t,n,r;for(t=0;t<this.size;t++){for(r=Array(this.dimensions),n=0;n<this.dimensions;n++)r[n]=this.axes[n][t];e.set(this.labels[t],r)}return e},typeof Symbol<`u`&&(p.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=p.prototype.inspect),p.from=function(e,t){var r=d(t,n.toArray(e));return new p(t,f(t,r.axes,r.ids,r.labels))},p.fromAxes=function(e,t){t||=r.indices(e[0].length);var n=e.length;return new p(n,f(e.length,e,r.indices(t.length),t))},t.exports=p})),N=t(((e,t)=>{var i=r(),a=n();function o(){this.clear()}o.prototype.clear=function(){this.head=null,this.tail=null,this.size=0},o.prototype.first=function(){return this.head?this.head.item:void 0},o.prototype.peek=o.prototype.first,o.prototype.last=function(){return this.tail?this.tail.item:void 0},o.prototype.push=function(e){var t={item:e,next:null};return this.head?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),this.size++,this.size},o.prototype.unshift=function(e){var t={item:e,next:null};return this.head?(this.head.next||(this.tail=this.head),t.next=this.head,this.head=t):(this.head=t,this.tail=t),this.size++,this.size},o.prototype.shift=function(){if(this.size){var e=this.head;return this.head=e.next,this.size--,e.item}},o.prototype.forEach=function(e,t){if(this.size){t=arguments.length>1?t:this;for(var n=this.head,r=0;n;)e.call(t,n.item,r,this),n=n.next,r++}},o.prototype.toArray=function(){if(!this.size)return[];for(var e=Array(this.size),t=0,n=this.size,r=this.head;t<n;t++)e[t]=r.item,r=r.next;return e},o.prototype.values=function(){var e=this.head;return new i(function(){if(!e)return{done:!0};var t=e.item;return e=e.next,{value:t,done:!1}})},o.prototype.entries=function(){var e=this.head,t=0;return new i(function(){if(!e)return{done:!0};var n=e.item;return e=e.next,t++,{value:[t-1,n],done:!1}})},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.values),o.prototype.toString=function(){return this.toArray().join(`,`)},o.prototype.toJSON=function(){return this.toArray()},o.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,"constructor",{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.from=function(e){var t=new o;return a(e,function(e){t.push(e)}),t},t.exports=o})),P=t(((e,t)=>{var i=r(),a=n(),o=s(),l=c();function u(e,t,n){if(arguments.length<2&&(n=e,e=null,t=null),this.capacity=n,typeof this.capacity!=`number`||this.capacity<=0)throw Error(`mnemonist/lru-cache: capacity should be positive number.`);if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw Error(`mnemonist/lru-cache: capacity should be a finite positive integer.`);var r=o.getPointerArray(n);this.forward=new r(n),this.backward=new r(n),this.K=typeof e==`function`?new e(n):Array(n),this.V=typeof t==`function`?new t(n):Array(n),this.size=0,this.head=0,this.tail=0,this.items={}}u.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items={}},u.prototype.splayOnTop=function(e){var t=this.head;if(this.head===e)return this;var n=this.backward[e],r=this.forward[e];return this.tail===e?this.tail=n:this.backward[r]=n,this.forward[n]=r,this.backward[t]=e,this.head=e,this.forward[e]=t,this},u.prototype.set=function(e,t){var n=this.items[e];if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],delete this.items[this.K[n]]),this.items[e]=n,this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},u.prototype.setpop=function(e,t){var n=null,r=null,i=this.items[e];return i===void 0?(this.size<this.capacity?i=this.size++:(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],delete this.items[r]),this.items[e]=i,this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},u.prototype.has=function(e){return e in this.items},u.prototype.get=function(e){var t=this.items[e];if(t!==void 0)return this.splayOnTop(t),this.V[t]},u.prototype.peek=function(e){var t=this.items[e];if(t!==void 0)return this.V[t]},u.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=0,r=this.size,i=this.head,a=this.K,o=this.V,s=this.forward;n<r;)e.call(t,o[i],a[i],this),i=s[i],n++},u.prototype.keys=function(){var e=0,t=this.size,n=this.head,r=this.K,a=this.forward;return new i(function(){if(e>=t)return{done:!0};var i=r[n];return e++,e<t&&(n=a[n]),{done:!1,value:i}})},u.prototype.values=function(){var e=0,t=this.size,n=this.head,r=this.V,a=this.forward;return new i(function(){if(e>=t)return{done:!0};var i=r[n];return e++,e<t&&(n=a[n]),{done:!1,value:i}})},u.prototype.entries=function(){var e=0,t=this.size,n=this.head,r=this.K,a=this.V,o=this.forward;return new i(function(){if(e>=t)return{done:!0};var i=r[n],s=a[n];return e++,e<t&&(n=o[n]),{done:!1,value:[i,s]}})},typeof Symbol<`u`&&(u.prototype[Symbol.iterator]=u.prototype.entries),u.prototype.inspect=function(){for(var e=new Map,t=this.entries(),n;n=t.next(),!n.done;)e.set(n.value[0],n.value[1]);return Object.defineProperty(e,"constructor",{value:u,enumerable:!1}),e},typeof Symbol<`u`&&(u.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=u.prototype.inspect),u.from=function(e,t,n,r){if(arguments.length<2){if(r=l.guessLength(e),typeof r!=`number`)throw Error(`mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(r=t,t=null,n=null);var i=new u(t,n,r);return a(e,function(e,t){i.set(t,e)}),i},t.exports=u})),F=t(((e,t)=>{var r=P(),i=n(),a=s(),o=c();function l(e,t,n){arguments.length<2?r.call(this,e):r.call(this,e,t,n);var i=a.getPointerArray(this.capacity);this.deleted=new i(this.capacity),this.deletedSize=0}for(var u in r.prototype)l.prototype[u]=r.prototype[u];typeof Symbol<`u`&&(l.prototype[Symbol.iterator]=r.prototype[Symbol.iterator]),l.prototype.clear=function(){r.prototype.clear.call(this),this.deletedSize=0},l.prototype.set=function(e,t){var n=this.items[e];if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?(n=this.deletedSize>0?this.deleted[--this.deletedSize]:this.size,this.size++):(n=this.tail,this.tail=this.backward[n],delete this.items[this.K[n]]),this.items[e]=n,this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},l.prototype.setpop=function(e,t){var n=null,r=null,i=this.items[e];return i===void 0?(this.size<this.capacity?(i=this.deletedSize>0?this.deleted[--this.deletedSize]:this.size,this.size++):(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],delete this.items[r]),this.items[e]=i,this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},l.prototype.delete=function(e){var t=this.items[e];if(t===void 0)return!1;if(delete this.items[e],this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,!0;var n=this.backward[t],r=this.forward[t];return this.head===t&&(this.head=r),this.tail===t&&(this.tail=n),this.forward[n]=r,this.backward[r]=n,this.size--,this.deleted[this.deletedSize++]=t,!0},l.prototype.remove=function(e,t=void 0){var n=this.items[e];if(n===void 0)return t;var r=this.V[n];if(delete this.items[e],this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,r;var i=this.backward[n],a=this.forward[n];return this.head===n&&(this.head=a),this.tail===n&&(this.tail=i),this.forward[i]=a,this.backward[a]=i,this.size--,this.deleted[this.deletedSize++]=n,r},l.from=function(e,t,n,r){if(arguments.length<2){if(r=o.guessLength(e),typeof r!=`number`)throw Error(`mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(r=t,t=null,n=null);var a=new l(t,n,r);return i(e,function(e,t){a.set(t,e)}),a},t.exports=l})),I=t(((e,t)=>{var r=P(),i=n(),a=s(),o=c();function l(e,t,n){if(arguments.length<2&&(n=e,e=null,t=null),this.capacity=n,typeof this.capacity!=`number`||this.capacity<=0)throw Error(`mnemonist/lru-map: capacity should be positive number.`);if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw Error(`mnemonist/lru-map: capacity should be a finite positive integer.`);var r=a.getPointerArray(n);this.forward=new r(n),this.backward=new r(n),this.K=typeof e==`function`?new e(n):Array(n),this.V=typeof t==`function`?new t(n):Array(n),this.size=0,this.head=0,this.tail=0,this.items=new Map}l.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items.clear()},l.prototype.set=function(e,t){var n=this.items.get(e);if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],this.items.delete(this.K[n])),this.items.set(e,n),this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},l.prototype.setpop=function(e,t){var n=null,r=null,i=this.items.get(e);return i===void 0?(this.size<this.capacity?i=this.size++:(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],this.items.delete(r)),this.items.set(e,i),this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},l.prototype.has=function(e){return this.items.has(e)},l.prototype.get=function(e){var t=this.items.get(e);if(t!==void 0)return this.splayOnTop(t),this.V[t]},l.prototype.peek=function(e){var t=this.items.get(e);if(t!==void 0)return this.V[t]},l.prototype.splayOnTop=r.prototype.splayOnTop,l.prototype.forEach=r.prototype.forEach,l.prototype.keys=r.prototype.keys,l.prototype.values=r.prototype.values,l.prototype.entries=r.prototype.entries,typeof Symbol<`u`&&(l.prototype[Symbol.iterator]=l.prototype.entries),l.prototype.inspect=r.prototype.inspect,l.from=function(e,t,n,r){if(arguments.length<2){if(r=o.guessLength(e),typeof r!=`number`)throw Error(`mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(r=t,t=null,n=null);var a=new l(t,n,r);return i(e,function(e,t){a.set(t,e)}),a},t.exports=l})),L=t(((e,t)=>{var r=I(),i=n(),a=s(),o=c();function l(e,t,n){arguments.length<2?r.call(this,e):r.call(this,e,t,n);var i=a.getPointerArray(this.capacity);this.deleted=new i(this.capacity),this.deletedSize=0}for(var u in r.prototype)l.prototype[u]=r.prototype[u];typeof Symbol<`u`&&(l.prototype[Symbol.iterator]=r.prototype[Symbol.iterator]),l.prototype.clear=function(){r.prototype.clear.call(this),this.deletedSize=0},l.prototype.set=function(e,t){var n=this.items.get(e);if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?(n=this.deletedSize>0?this.deleted[--this.deletedSize]:this.size,this.size++):(n=this.tail,this.tail=this.backward[n],this.items.delete(this.K[n])),this.items.set(e,n),this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},l.prototype.setpop=function(e,t){var n=null,r=null,i=this.items.get(e);return i===void 0?(this.size<this.capacity?(i=this.deletedSize>0?this.deleted[--this.deletedSize]:this.size,this.size++):(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],this.items.delete(r)),this.items.set(e,i),this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},l.prototype.delete=function(e){var t=this.items.get(e);if(t===void 0)return!1;if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,!0;var n=this.backward[t],r=this.forward[t];return this.head===t&&(this.head=r),this.tail===t&&(this.tail=n),this.forward[n]=r,this.backward[r]=n,this.size--,this.deleted[this.deletedSize++]=t,!0},l.prototype.remove=function(e,t=void 0){var n=this.items.get(e);if(n===void 0)return t;var r=this.V[n];if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,r;var i=this.backward[n],a=this.forward[n];return this.head===n&&(this.head=a),this.tail===n&&(this.tail=i),this.forward[i]=a,this.backward[a]=i,this.size--,this.deleted[this.deletedSize++]=n,r},l.from=function(e,t,n,r){if(arguments.length<2){if(r=o.guessLength(e),typeof r!=`number`)throw Error(`mnemonist/lru-map.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(r=t,t=null,n=null);var a=new l(t,n,r);return i(e,function(e,t){a.set(t,e)}),a},t.exports=l})),R=t(((e,t)=>{var i=r(),a=n(),o=w(),s=function(e,t){return e[1]>t[1]?-1:+(e[1]<t[1])};function c(){this.items=new Map,Object.defineProperty(this.items,"constructor",{value:c,enumerable:!1}),this.clear()}c.prototype.clear=function(){this.size=0,this.dimension=0,this.items.clear()},c.prototype.add=function(e,t){if(t===0)return this;if(t<0)return this.remove(e,-t);if(t||=1,typeof t!=`number`)throw Error(`mnemonist/multi-set.add: given count should be a number.`);this.size+=t;let n=this.items.get(e);return n===void 0?this.dimension++:t+=n,this.items.set(e,t),this},c.prototype.set=function(e,t){var n;if(typeof t!=`number`)throw Error(`mnemonist/multi-set.set: given count should be a number.`);return t<=0?(n=this.items.get(e),n!==void 0&&(this.size-=n,this.dimension--),this.items.delete(e),this):(t||=1,n=this.items.get(e),typeof n==`number`?this.items.set(e,n+t):(this.dimension++,this.items.set(e,t)),this.size+=t,this)},c.prototype.has=function(e){return this.items.has(e)},c.prototype.delete=function(e){var t=this.items.get(e);return t===0?!1:(this.size-=t,this.dimension--,this.items.delete(e),!0)},c.prototype.remove=function(e,t){if(t!==0){if(t<0)return this.add(e,-t);if(t||=1,typeof t!=`number`)throw Error(`mnemonist/multi-set.remove: given count should be a number.`);var n=this.items.get(e);if(n!==void 0){var r=Math.max(0,n-t);r===0?(this.items.delete(e),this.size-=n,this.dimension--):(this.items.set(e,r),this.size-=t)}}},c.prototype.edit=function(e,t){var n=this.multiplicity(e);if(n!==0){var r=this.multiplicity(t);return this.items.set(t,n+r),this.items.delete(e),this}},c.prototype.multiplicity=function(e){var t=this.items.get(e);return t===void 0?0:t},c.prototype.get=c.prototype.multiplicity,c.prototype.count=c.prototype.multiplicity,c.prototype.frequency=function(e){return this.size===0?0:this.multiplicity(e)/this.size},c.prototype.top=function(e){if(typeof e!=`number`||e<=0)throw Error(`mnemonist/multi-set.top: n must be a number > 0.`);for(var t=new o(Array,s,e),n=this.items.entries(),r;r=n.next(),!r.done;)t.push(r.value);return t.consume()},c.prototype.forEach=function(e,t){t=arguments.length>1?t:this;var n;this.items.forEach(function(r,i){for(n=0;n<r;n++)e.call(t,i,i)})},c.prototype.forEachMultiplicity=function(e,t){t=arguments.length>1?t:this,this.items.forEach(e,t)},c.prototype.keys=function(){return this.items.keys()},c.prototype.values=function(){var e=this.items.entries(),t=!1,n,r,a,o;return new i(function i(){if(!t){if(n=e.next(),n.done)return{done:!0};t=!0,r=n.value[0],a=n.value[1],o=0}return o>=a?(t=!1,i()):(o++,{done:!1,value:r})})},c.prototype.multiplicities=function(){return this.items.entries()},typeof Symbol<`u`&&(c.prototype[Symbol.iterator]=c.prototype.values),c.prototype.inspect=function(){return this.items},typeof Symbol<`u`&&(c.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=c.prototype.inspect),c.prototype.toJSON=function(){return this.items},c.from=function(e){var t=new c;return a(e,function(e){t.add(e)}),t},c.isSubset=function(e,t){var n=e.multiplicities(),r,i,a;if(e===t)return!0;if(e.dimension>t.dimension)return!1;for(;r=n.next(),!r.done;)if(i=r.value[0],a=r.value[1],t.multiplicity(i)<a)return!1;return!0},c.isSuperset=function(e,t){return c.isSubset(t,e)},t.exports=c})),z=t(((e,t)=>{var i=r(),a=n();function o(e,t,n){return((e**2-Math.abs(t-n)**2)/2|0)+e+1}function s(e,t){for(var n=0,r=0,i=t+1;r<i;r++)n+=o(e,t,r);return n}function c(e,t){return e.length>t.length?-1:e.length<t.length?1:e<t?-1:+(e>t)}function l(e,t){var n=e+1,r=t/n|0,i=r+1,a,o,s=t-r*n,c=n-s,l=Array(e+1);for(a=0;a<c;a++)l[a]=[a*r,r];var u=(a-1)*r+r;for(o=0;o<s;o++)l[a+o]=[u+o*i,i];return l}function u(e,t){var n=t.length,r=e+1,i=n/r|0,a=i+1,o,s,c,l=n-i*r,u=r-l,d=Array(e+1);for(s=0;s<u;s++)o=s*i,d[s]=t.slice(o,o+i);var f=(s-1)*i+i;for(c=0;c<l;c++)o=f+c*a,d[s+c]=t.slice(o,o+a);return d}function d(e,t,n){if(t===0)return 0;var r=n.length,i=e+1,a=r/i|0,o=a+1,s=i-(r-a*i);if(t<=s-1)return t*a;var c=t-s;return s*a+c*o}function f(e,t,n,r,i,a){var o=i-n,s=i+n,c=e-n,l=i+t-c,u=i+t+c,d=r-a;return[Math.max(0,o,l),Math.min(s,u,d)]}function p(e,t,n,r,i,a){var o=t.length,s=f(e,o-n,r,o,i,a),c=s[0],l=s[1],u=``,d=[],p,m,h;for(m=c,h=l+1;m<h;m++)p=t.slice(m,m+a),p!==u&&(d.push(p),u=p);return d}function m(e,t){if(typeof e!=`function`)throw Error("mnemonist/passjoin-index: `levenshtein` should be a function returning edit distance between two strings.");if(typeof t!=`number`||t<1)throw Error("mnemonist/passjoin-index: `k` should be a number > 0");this.levenshtein=e,this.k=t,this.clear()}m.prototype.clear=function(){this.size=0,this.strings=[],this.invertedIndices={}},m.prototype.add=function(e){var t=e.length,n=this.size;this.strings.push(e),this.size++;var r=u(this.k,e),i=this.invertedIndices[t];i===void 0&&(i={},this.invertedIndices[t]=i);var a,o,s,c,l;for(c=0,l=r.length;c<l;c++)a=r[c],s=a+c,o=i[s],o===void 0?(o=[n],i[s]=o):o.push(n);return this},m.prototype.search=function(e){var t=e.length,n=this.k,r=new Set,i,a,o,s,c,u,d,f,m,h,g,_,v,y,b;for(f=Math.max(0,t-n),m=t+n+1;f<m;f++){var x=this.invertedIndices[f];if(x!==void 0){for(d=l(n,f),h=0,g=d.length;h<g;h++)for(o=d[h][0],s=d[h][1],u=p(n,e,f,h,o,s),u.length||(u=[``]),_=0,v=u.length;_<v;_++)if(c=u[_]+h,i=x[c],i!==void 0)for(y=0,b=i.length;y<b;y++)a=this.strings[i[y]],(t<=n&&f<=n||!r.has(a)&&this.levenshtein(e,a)<=n)&&r.add(a)}}return r},m.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=0,r=this.strings.length;n<r;n++)e.call(t,this.strings[n],n,this)},m.prototype.values=function(){var e=this.strings,t=e.length,n=0;return new i(function(){if(n>=t)return{done:!0};var r=e[n];return n++,{value:r,done:!1}})},typeof Symbol<`u`&&(m.prototype[Symbol.iterator]=m.prototype.values),m.prototype.inspect=function(){var e=this.strings.slice();return Object.defineProperty(e,"constructor",{value:m,enumerable:!1}),e},typeof Symbol<`u`&&(m.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=m.prototype.inspect),m.from=function(e,t,n){var r=new m(t,n);return a(e,function(e){r.add(e)}),r},m.countKeys=s,m.comparator=c,m.partition=l,m.segments=u,m.segmentPos=d,m.multiMatchAwareInterval=f,m.multiMatchAwareSubstrings=p,t.exports=m})),B=t(((e,t)=>{var i=r(),a=n();function o(){this.clear()}o.prototype.clear=function(){this.items=[],this.offset=0,this.size=0},o.prototype.enqueue=function(e){return this.items.push(e),++this.size},o.prototype.dequeue=function(){if(this.size){var e=this.items[this.offset];return++this.offset*2>=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,e}},o.prototype.peek=function(){if(this.size)return this.items[this.offset]},o.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.offset,r=0,i=this.items.length;n<i;n++,r++)e.call(t,this.items[n],r,this)},o.prototype.toArray=function(){return this.items.slice(this.offset)},o.prototype.values=function(){var e=this.items,t=this.offset;return new i(function(){if(t>=e.length)return{done:!0};var n=e[t];return t++,{value:n,done:!1}})},o.prototype.entries=function(){var e=this.items,t=this.offset,n=0;return new i(function(){if(t>=e.length)return{done:!0};var r=e[t];return t++,{value:[n++,r],done:!1}})},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.values),o.prototype.toString=function(){return this.toArray().join(`,`)},o.prototype.toJSON=function(){return this.toArray()},o.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,"constructor",{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.from=function(e){var t=new o;return a(e,function(e){t.enqueue(e)}),t},o.of=function(){return o.from(arguments)},t.exports=o})),V=t(((e,t)=>{var i=r(),a=n();function o(){this.clear()}o.prototype.clear=function(){this.items=[],this.size=0},o.prototype.push=function(e){return this.items.push(e),++this.size},o.prototype.pop=function(){if(this.size!==0)return this.size--,this.items.pop()},o.prototype.peek=function(){return this.items[this.size-1]},o.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=0,r=this.items.length;n<r;n++)e.call(t,this.items[r-n-1],n,this)},o.prototype.toArray=function(){for(var e=Array(this.size),t=this.size-1,n=this.size;n--;)e[n]=this.items[t-n];return e},o.prototype.values=function(){var e=this.items,t=e.length,n=0;return new i(function(){if(n>=t)return{done:!0};var r=e[t-n-1];return n++,{value:r,done:!1}})},o.prototype.entries=function(){var e=this.items,t=e.length,n=0;return new i(function(){if(n>=t)return{done:!0};var r=e[t-n-1];return{value:[n++,r],done:!1}})},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.values),o.prototype.toString=function(){return this.toArray().join(`,`)},o.prototype.toJSON=function(){return this.toArray()},o.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,"constructor",{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.from=function(e){var t=new o;return a(e,function(e){t.push(e)}),t},o.of=function(){return o.from(arguments)},t.exports=o})),H=t(((e,t)=>{var n=r(),i=s().getPointerArray;function a(e){var t=i(e);this.start=0,this.size=0,this.capacity=e,this.dense=new t(e),this.sparse=new t(e)}a.prototype.clear=function(){this.start=0,this.size=0},a.prototype.has=function(e){if(this.size===0)return!1;var t=this.sparse[e];return(t<this.capacity&&t>=this.start&&t<this.start+this.size||t<(this.start+this.size)%this.capacity)&&this.dense[t]===e},a.prototype.enqueue=function(e){var t=this.sparse[e];return this.size!==0&&(t<this.capacity&&t>=this.start&&t<this.start+this.size||t<(this.start+this.size)%this.capacity)&&this.dense[t]===e?this:(t=(this.start+this.size)%this.capacity,this.dense[t]=e,this.sparse[e]=t,this.size++,this)},a.prototype.dequeue=function(){if(this.size!==0){var e=this.start;this.size--,this.start++,this.start===this.capacity&&(this.start=0);var t=this.dense[e];return this.sparse[t]=this.capacity,t}},a.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.capacity,r=this.size,i=this.start,a=0;a<r;)e.call(t,this.dense[i],a,this),i++,a++,i===n&&(i=0)},a.prototype.values=function(){var e=this.dense,t=this.capacity,r=this.size,i=this.start,a=0;return new n(function(){if(a>=r)return{done:!0};var n=e[i];return i++,a++,i===t&&(i=0),{value:n,done:!1}})},typeof Symbol<`u`&&(a.prototype[Symbol.iterator]=a.prototype.values),a.prototype.inspect=function(){var e=[];return this.forEach(function(t){e.push(t)}),Object.defineProperty(e,"constructor",{value:a,enumerable:!1}),e.capacity=this.capacity,e},typeof Symbol<`u`&&(a.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a.prototype.inspect),t.exports=a})),U=t(((e,t)=>{var n=r(),i=s().getPointerArray;function a(e,t){arguments.length<2&&(t=e,e=Array);var n=i(t);this.size=0,this.length=t,this.dense=new n(t),this.sparse=new n(t),this.vals=new e(t)}a.prototype.clear=function(){this.size=0},a.prototype.has=function(e){var t=this.sparse[e];return t<this.size&&this.dense[t]===e},a.prototype.get=function(e){var t=this.sparse[e];if(t<this.size&&this.dense[t]===e)return this.vals[t]},a.prototype.set=function(e,t){var n=this.sparse[e];return n<this.size&&this.dense[n]===e?(this.vals[n]=t,this):(this.dense[this.size]=e,this.sparse[e]=this.size,this.vals[this.size]=t,this.size++,this)},a.prototype.delete=function(e){var t=this.sparse[e];return t>=this.size||this.dense[t]!==e?!1:(t=this.dense[this.size-1],this.dense[this.sparse[e]]=t,this.sparse[t]=this.sparse[e],this.size--,!0)},a.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=0;n<this.size;n++)e.call(t,this.vals[n],this.dense[n])},a.prototype.keys=function(){var e=this.size,t=this.dense,r=0;return new n(function(){if(r<e){var n=t[r];return r++,{value:n}}return{done:!0}})},a.prototype.values=function(){var e=this.size,t=this.vals,r=0;return new n(function(){if(r<e){var n=t[r];return r++,{value:n}}return{done:!0}})},a.prototype.entries=function(){var e=this.size,t=this.dense,r=this.vals,i=0;return new n(function(){if(i<e){var n=[t[i],r[i]];return i++,{value:n}}return{done:!0}})},typeof Symbol<`u`&&(a.prototype[Symbol.iterator]=a.prototype.entries),a.prototype.inspect=function(){for(var e=new Map,t=0;t<this.size;t++)e.set(this.dense[t],this.vals[t]);return Object.defineProperty(e,"constructor",{value:a,enumerable:!1}),e.length=this.length,this.vals.constructor!==Array&&(e.type=this.vals.constructor.name),e},typeof Symbol<`u`&&(a.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a.prototype.inspect),t.exports=a})),W=t(((e,t)=>{var n=r(),i=s().getPointerArray;function a(e){var t=i(e);this.size=0,this.length=e,this.dense=new t(e),this.sparse=new t(e)}a.prototype.clear=function(){this.size=0},a.prototype.has=function(e){var t=this.sparse[e];return t<this.size&&this.dense[t]===e},a.prototype.add=function(e){var t=this.sparse[e];return t<this.size&&this.dense[t]===e?this:(this.dense[this.size]=e,this.sparse[e]=this.size,this.size++,this)},a.prototype.delete=function(e){var t=this.sparse[e];return t>=this.size||this.dense[t]!==e?!1:(t=this.dense[this.size-1],this.dense[this.sparse[e]]=t,this.sparse[t]=this.sparse[e],this.size--,!0)},a.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n,r=0;r<this.size;r++)n=this.dense[r],e.call(t,n,n)},a.prototype.values=function(){var e=this.size,t=this.dense,r=0;return new n(function(){if(r<e){var n=t[r];return r++,{value:n}}return{done:!0}})},typeof Symbol<`u`&&(a.prototype[Symbol.iterator]=a.prototype.values),a.prototype.inspect=function(){for(var e=new Set,t=0;t<this.size;t++)e.add(this.dense[t]);return Object.defineProperty(e,"constructor",{value:a,enumerable:!1}),e.length=this.length,e},typeof Symbol<`u`&&(a.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=a.prototype.inspect),t.exports=a})),G=t(((e,t)=>{var r=n(),i=2,a=2,o=new Set([0,1,2]),s={0:`Returns only the top suggestion`,1:`Returns suggestions with the smallest edit distance`,2:`Returns every suggestion (no early termination)`};function c(e){var t=new Set;return typeof e==`number`&&t.add(e),{suggestions:t,count:0}}function l(e,t,n){return{term:e||``,distance:t||0,count:n||0}}function u(e,t,n,r){r||=new Set,t++;var i,a=e.length,o;if(a>1)for(o=0;o<a;o++)i=e.substring(0,o)+e.substring(o+1),r.has(i)||(r.add(i),t<n&&u(i,t,n,r));return r}function d(e,t,n,r,i,a){var o=n.suggestions.values().next().value;t<2&&n.suggestions.size>0&&e[o].length-a.length>r.length-a.length&&(n.suggestions=new Set,n.count=0),(t===2||!n.suggestions.size||e[o].length-a.length>=r.length-a.length)&&n.suggestions.add(i)}function f(e,t){var n=e.length,r=t.length,i=[[]],a=n+r,o=new Map,s,c,l;for(i[0][0]=a,s=0;s<=n;s++)i[s+1]||(i[s+1]=[]),i[s+1][1]=s,i[s+1][0]=a;for(l=0;l<=r;l++)i[1][l+1]=l,i[0][l+1]=a;var u=e+t,d;for(s=0,c=u.length;s<c;s++)d=u[s],o.has(d)||o.set(d,0);for(s=1;s<=n;s++){var f=0;for(l=1;l<=r;l++){var p=o.get(t[l-1]),m=f;e[s-1]===t[l-1]?(i[s+1][l+1]=i[s][l],f=l):i[s+1][l+1]=Math.min(i[s][l],i[s+1][l],i[s][l+1])+1,i[s+1][l+1]=Math.min(i[s+1][l+1],i[p][m]+(s-p-1)+1+(l-m-1))}o.set(e[s-1],s)}return i[n+1][r+1]}function p(e,t,n,r,i,a){var o=a.length;if(o-r>i)return[];for(var s=[a],u=new Set,d=new Set,p=[],m,h;s.length>0&&(m=s.shift(),!(n<2&&p.length>0&&o-m.length>p[0].distance));){if(h=e[m],h!==void 0){if(typeof h==`number`&&(h=c(h)),h.count>0&&!d.has(m)){d.add(m);var g=l(m,o-m.length,h.count);if(p.push(g),n<2&&o-m.length===0)break}h.suggestions.forEach(i=>{var s=t[i];if(!d.has(s)){d.add(s);var c=0;if(a!==s)if(s.length===m.length)c=o-m.length;else if(o===m.length)c=s.length-m.length;else{for(var u=0,h=0,g=s.length;u<g&&u<o&&s[u]===a[u];)u++;for(;h<g-u&&h<o&&s[g-h-1]===a[o-h-1];)h++;c=u>0||h>0?f(s.substr(u,g-u-h),a.substr(u,o-u-h)):f(s,a)}if(n<2&&p.length>0&&p[0].distance>c&&(p=[]),!(n<2&&p.length>0&&c>p[0].distance)&&c<=r){var _=e[s];_!==void 0&&p.push(l(s,c,_.count))}}})}if(o-m.length<r){if(n<2&&p.length>0&&o-m.length>=p[0].distance)continue;for(var _=0,v=m.length;_<v;_++){var y=m.substring(0,_)+m.substring(_+1);u.has(y)||(u.add(y),s.push(y))}}}return n===0?p.slice(0,1):p}function m(e){if(e||={},this.clear(),this.maxDistance=typeof e.maxDistance==`number`?e.maxDistance:i,this.verbosity=typeof e.verbosity==`number`?e.verbosity:a,typeof this.maxDistance!=`number`||this.maxDistance<=0)throw Error("mnemonist/SymSpell.constructor: invalid `maxDistance` option. Should be a integer greater than 0.");if(!o.has(this.verbosity))throw Error("mnemonist/SymSpell.constructor: invalid `verbosity` option. Should be either 0, 1 or 2.")}m.prototype.clear=function(){this.size=0,this.dictionary=Object.create(null),this.maxLength=0,this.words=[]},m.prototype.add=function(e){var t=this.dictionary[e];if(t===void 0?(t=c(),t.count++,this.dictionary[e]=t,e.length>this.maxLength&&(this.maxLength=e.length)):(typeof t==`number`&&(t=c(t),this.dictionary[e]=t),t.count++),t.count===1){var n=this.words.length;this.words.push(e),u(e,0,this.maxDistance).forEach(t=>{var r=this.dictionary[t];r===void 0?this.dictionary[t]=n:(typeof r==`number`&&(r=c(r),this.dictionary[t]=r),r.suggestions.has(n)||d(this.words,this.verbosity,r,e,n,t))})}return this.size++,this},m.prototype.search=function(e){return p(this.dictionary,this.words,this.verbosity,this.maxDistance,this.maxLength,e)},m.prototype.inspect=function(){var e=[];for(var t in e.size=this.size,e.maxDistance=this.maxDistance,e.verbosity=this.verbosity,e.behavior=s[this.verbosity],this.dictionary)typeof this.dictionary[t]==`object`&&this.dictionary[t].count&&e.push([t,this.dictionary[t].count]);return Object.defineProperty(e,"constructor",{value:m,enumerable:!1}),e},typeof Symbol<`u`&&(m.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=m.prototype.inspect),m.from=function(e,t){var n=new m(t);return r(e,function(e){n.add(e)}),n},t.exports=m})),K=t(((e,t)=>{var i=n(),a=r(),o=`\0`;function s(e){this.mode=e===Array?`array`:`string`,this.clear()}s.prototype.clear=function(){this.root={},this.size=0},s.prototype.set=function(e,t){for(var n=this.root,r,i=0,a=e.length;i<a;i++)r=e[i],n=n[r]||(n[r]={});return o in n||this.size++,n[o]=t,this},s.prototype.update=function(e,t){for(var n=this.root,r,i=0,a=e.length;i<a;i++)r=e[i],n=n[r]||(n[r]={});return o in n||this.size++,n[o]=t(n[o]),this},s.prototype.get=function(e){var t=this.root,n,r,i;for(r=0,i=e.length;r<i;r++)if(n=e[r],t=t[n],t===void 0)return;if(o in t)return t[o]},s.prototype.delete=function(e){var t=this.root,n=null,r=null,i,a,s,c;for(s=0,c=e.length;s<c;s++){if(a=e[s],i=t,t=t[a],t===void 0)return!1;n===null?Object.keys(t).length<2&&(n=i,r=a):Object.keys(t).length>1&&(n=null,r=null)}return o in t?(this.size--,n?delete n[r]:delete t[o],!0):!1},s.prototype.has=function(e){for(var t=this.root,n,r=0,i=e.length;r<i;r++)if(n=e[r],t=t[n],t===void 0)return!1;return o in t},s.prototype.find=function(e){var t=typeof e==`string`,n=this.root,r=[],i,a,s;for(a=0,s=e.length;a<s;a++)if(i=e[a],n=n[i],n===void 0)return r;for(var c=[n],l=[e],u;c.length;)for(u in e=l.pop(),n=c.pop(),n){if(u===o){r.push([e,n[o]]);continue}c.push(n[u]),l.push(t?e+u:e.concat(u))}return r},s.prototype.values=function(e){var t=this.root,n=[],r,i,s;if(e){for(i=0,s=e.length;i<s;i++)if(r=e[i],t=t[r],t===void 0)return a.empty()}return n.push(t),new a(function(){for(var e,t=!1,r;n.length;){for(r in e=n.pop(),e){if(r===o){t=!0;continue}n.push(e[r])}if(t)return{done:!1,value:e[o]}}return{done:!0}})},s.prototype.prefixes=function(e){var t=this.root,n=[],r=[],i,s,c,l=this.mode===`string`;if(e){for(s=0,c=e.length;s<c;s++)if(i=e[s],t=t[i],t===void 0)return a.empty()}else e=l?``:[];return n.push(t),r.push(e),new a(function(){for(var e,t,i=!1,a;n.length;){for(a in e=n.pop(),t=r.pop(),e){if(a===o){i=!0;continue}n.push(e[a]),r.push(l?t+a:t.concat(a))}if(i)return{done:!1,value:t}}return{done:!0}})},s.prototype.keys=s.prototype.prefixes,s.prototype.entries=function(e){var t=this.root,n=[],r=[],i,s,c,l=this.mode===`string`;if(e){for(s=0,c=e.length;s<c;s++)if(i=e[s],t=t[i],t===void 0)return a.empty()}else e=l?``:[];return n.push(t),r.push(e),new a(function(){for(var e,t,i=!1,a;n.length;){for(a in e=n.pop(),t=r.pop(),e){if(a===o){i=!0;continue}n.push(e[a]),r.push(l?t+a:t.concat(a))}if(i)return{done:!1,value:[t,e[o]]}}return{done:!0}})},typeof Symbol<`u`&&(s.prototype[Symbol.iterator]=s.prototype.entries),s.prototype.inspect=function(){for(var e=Array(this.size),t=this.entries(),n,r=0;n=t.next(),!n.done;)e[r++]=n.value;return Object.defineProperty(e,"constructor",{value:s,enumerable:!1}),e},typeof Symbol<`u`&&(s.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=s.prototype.inspect),s.prototype.toJSON=function(){return this.root},s.from=function(e){var t=new s;return i(e,function(e,n){t.set(n,e)}),t},s.SENTINEL=o,t.exports=s})),q=t(((e,t)=>{var r=n(),i=K(),a=`\0`;function o(e){this.mode=e===Array?`array`:`string`,this.clear()}for(var s in i.prototype)o.prototype[s]=i.prototype[s];delete o.prototype.set,delete o.prototype.get,delete o.prototype.values,delete o.prototype.entries,o.prototype.add=function(e){for(var t=this.root,n,r=0,i=e.length;r<i;r++)n=e[r],t=t[n]||(t[n]={});return a in t||this.size++,t[a]=!0,this},o.prototype.find=function(e){var t=typeof e==`string`,n=this.root,r=[],i,o,s;for(o=0,s=e.length;o<s;o++)if(i=e[o],n=n[i],n===void 0)return r;for(var c=[n],l=[e],u;c.length;)for(u in e=l.pop(),n=c.pop(),n){if(u===a){r.push(e);continue}c.push(n[u]),l.push(t?e+u:e.concat(u))}return r},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.keys),o.prototype.inspect=function(){for(var e=new Set,t=this.keys(),n;n=t.next(),!n.done;)e.add(n.value);return Object.defineProperty(e,"constructor",{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.prototype.toJSON=function(){return this.root},o.from=function(e){var t=new o;return r(e,function(e){t.add(e)}),t},o.SENTINEL=a,t.exports=o})),J=t(((e,t)=>{var n=c(),r=s(),i=M().inplaceQuickSortIndices,a=A().lowerBoundIndices,o=l(),u=r.getPointerArray;function d(e,t){return e.distance<t.distance?1:e.distance>t.distance?-1:0}function f(e,t,n){for(var r=n.length,o=u(r),s=0,c=new o(r),l=new o(r),d=new o(r),f=new Float64Array(r),p=[0,0,r],m=new Float64Array(r),h,g,_,v,y,b,x,S,C;p.length;)if(y=p.pop(),v=p.pop(),h=p.pop(),g=n[y-1],y--,C=y-v,c[h]=g,C!==0){if(C===1){x=e(t[g],t[n[v]]),f[h]=x,s++,d[h]=s,c[s]=n[v];continue}for(S=v;S<y;S++)m[n[S]]=e(t[g],t[n[S]]);i(m,n,v,y),_=v+C/2-1,x=_===(_|0)?(m[n[_]]+m[n[_+1]])/2:m[n[Math.ceil(_)]],f[h]=x,b=a(m,n,x,v,y),y-b>0&&(s++,d[h]=s,p.push(s,b,y)),b-v>0&&(s++,l[h]=s,p.push(s,v,b))}return{nodes:c,lefts:l,rights:d,mus:f}}function p(e,t){if(typeof e!=`function`)throw Error("mnemonist/VPTree.constructor: given `distance` must be a function.");if(!t)throw Error(`mnemonist/VPTree.constructor: you must provide items to the tree. A VPTree cannot be updated after its creation.`);this.distance=e,this.heap=new o(d),this.D=0;var r=n.toArrayWithIndices(t);this.items=r[0];var i=r[1];this.size=i.length;var a=f(e,this.items,i);this.nodes=a.nodes,this.lefts=a.lefts,this.rights=a.rights,this.mus=a.mus}p.prototype.nearestNeighbors=function(e,t){var n=this.heap,r=[0],i=1/0,a,o,s,c,l,u,d;for(this.D=0;r.length;)a=r.pop(),o=this.nodes[a],s=this.items[o],d=this.distance(s,t),this.D++,d<i&&(n.push({distance:d,item:s}),n.size>e&&n.pop(),n.size>=e&&(i=n.peek().distance)),c=this.lefts[a],l=this.rights[a],!(!c&&!l)&&(u=this.mus[a],d<u?(c&&d<u+i&&r.push(c),l&&d>=u-i&&r.push(l)):(l&&d>=u-i&&r.push(l),c&&d<u+i&&r.push(c)));for(var f=Array(n.size),p=n.size-1;p>=0;p--)f[p]=n.pop();return f},p.prototype.neighbors=function(e,t){var n=[],r=[0],i,a,o,s,c,l,u;for(this.D=0;r.length;)i=r.pop(),a=this.nodes[i],o=this.items[a],u=this.distance(o,t),this.D++,u<=e&&n.push({distance:u,item:o}),s=this.lefts[i],c=this.rights[i],!(!s&&!c)&&(l=this.mus[i],u<l?(s&&u<l+e&&r.push(s),c&&u>=l-e&&r.push(c)):(c&&u>=l-e&&r.push(c),s&&u<l+e&&r.push(s)));return n},p.prototype.inspect=function(){var e=this.items.slice();return Object.defineProperty(e,"constructor",{value:p,enumerable:!1}),e},typeof Symbol<`u`&&(p.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=p.prototype.inspect),p.from=function(e,t){return new p(t,e)},t.exports=p})),Y=e(i(),1),X=e(o(),1),Z=e(l(),1),re=e(u(),1),Q=e(d(),1);f(),m(),h(),_(),v(),b();var ie=e(x(),1),ae=e(S(),1);y(),C(),w(),T(),D(),ee(),k(),te(),ne();var oe=e(N(),1);P(),F();var se=e(I(),1);L();var ce=e(E(),1);R(),z();var le=e(B(),1);O();var $=e(V(),1);H(),U(),W(),G(),q(),K(),J(),X.default.MinFibonacciHeap,X.default.MaxFibonacciHeap,Z.default.MinHeap,Z.default.MaxHeap,re.default.GeneralizedSuffixArray,Q.default.Uint8Vector,Q.default.Uint8ClampedVector,Q.default.Int8Vector,Q.default.Uint16Vector,Q.default.Int16Vector,Q.default.Uint32Vector,Q.default.Int32Vector,Q.default.Float32Vector,Q.default.Float64Vector,Q.default.PointerVector;export{ce as a,$ as c,se as i,ae as n,le as o,oe as r,Y as s,ie as t};
@@ -1 +1 @@
1
- import{C as e,H as t,K as n,M as r,O as i,Q as a,T as o,V as s,X as c,Y as l,_ as u,c as d,et as f,h as p,i as m,j as h,m as g}from"./libs/remeda.mjs";import{At as _,Jt as v,Ut as y,_t as b,g as x,gt as S,h as C,xn as w}from"./types.mjs";import{castDraft as T,produce as E}from"immer";function D(e,t){let{nodes:n,edges:r,hasManualLayout:i,...a}=e,o=new Map(n.map(e=>[e.id,e])),s=new Map(r.map(e=>[e.id,e])),c=t.nodes.map(e=>{let t=o.get(e.id);return t?{...t,x:e.x,y:e.y,width:e.width,height:e.height,labelBBox:e.labelBBox}:e}),l=t.edges.map(e=>{let t=s.get(e.id);return t?{...t,points:e.points,label:e.label,labelBBox:e.labelBBox,...e.controlPoints!=null&&{controlPoints:e.controlPoints}}:e}),u={...t,...a,[b]:`layouted`,bounds:t.bounds,nodes:c,edges:l};return i?u[S]=`auto`:delete u[S],u}function O(r){return f(r,l(e=>!!e.notation),t(g(`notation`)),e(p(t(g(`shape`)),e(p(t(g(`color`)),e(p(o(g(`kind`)),m())),c(),o(([e,t])=>({kinds:t,color:e})))),c(),n(([e,t])=>t.map(({color:t,kinds:n})=>({shape:e,color:t,kinds:n}))))),c(),n(([e,t])=>t.map(({shape:t,color:n,kinds:r})=>({title:e,shape:t,color:n,kinds:r}))),d(g(`shape`),g(`title`),[e=>e.kinds.length,`desc`]))}const k=(e,t)=>e===t||r(e)&&r(t)?!1:!s(e,t);function A(e,t){e.color=t.color,e.kind=t.kind,e.navigateTo=t.navigateTo??null,e.links=t.links?[...t.links]:null,e.tags=[...t.tags],r(t.style.border)?delete e.style.border:e.style.border=t.style.border,h(t.style.opacity)?e.style.opacity=t.style.opacity:delete e.style.opacity,r(t.style.multiple)?delete e.style.multiple:e.style.multiple=t.style.multiple}function j(e,t,n){if(k(t.icon??`none`,e.icon??`none`)){let a=i(e.icon)&&e.icon!==`none`;switch(!0){case a&&i(t.icon)&&t.icon!==`none`:return e.icon=t.icon,!0;case a&&(r(t.icon)||t.icon===`none`):return e.icon=`none`,!0;case!a&&i(t.icon)&&t.icon!==`none`:return n?(e.icon=t.icon,!0):!1}}return!0}function M(e,t,n){let i=!0;return k(e.style.iconColor,t.style.iconColor)&&(r(t.style.iconColor)?delete e.style.iconColor:e.style.iconColor=t.style.iconColor),k(e.style.iconSize,t.style.iconSize)&&(n?r(t.style.iconSize)?delete e.style.iconSize:e.style.iconSize=t.style.iconSize:i=!1),k(e.style.iconPosition,t.style.iconPosition)&&(n?r(t.style.iconPosition)?delete e.style.iconPosition:e.style.iconPosition=t.style.iconPosition:i=!1),i}function N(e,t){return e?`md`in t?(e.md=t.md,delete e.txt,e):(`txt`in t&&(e.txt=t.txt,delete e.md),e):t}function P(e,t,n){let i=!0;return k(e.title,t.title)&&(n?e.title=t.title:i=!1),k(e.description,t.description)&&(r(t.description)?delete e.description:n?e.description=N(e.description,t.description):i=!1),k(e.technology,t.technology)&&(r(t.technology)?delete e.technology:n?e.technology=t.technology:i=!1),i}function F(e,t,n){return e.title=t.title,r(t.description)?delete e.description:e.description=N(e.description,t.description),r(t.technology)?delete e.technology:e.technology=t.technology,!0}function I(e,t){w(e.id===t.id,`applyManualLayout: view ids do not match`),w(e._stage===`layouted`,`applyManualLayout: expected layouted view`),w(t._stage===`layouted`,`applyManualLayout: expected layouted snapshot`),w(e._layout!==`manual`,`applyManualLayout: expected auto-layouted view`);let n=new Set;e._type!==t._type&&n.add(`type-changed`);let r=L(t.nodes,e.nodes,n),i=R(t.edges,e.edges,n),o=O(r);return E(t,s=>{s.title=e.title??t.title,s.description=e.description??t.description,s.tags=e.tags?[...e.tags]:null,s.links=e.links?[...e.links]:null,s.sourcePath=e.sourcePath,s[S]=`manual`,o&&o.length>0?s.notation={nodes:o}:delete s.notation,s.nodes=T(r),s.edges=T(i),C(e)&&s._type===`dynamic`&&(s.variant=e.variant),x(e)&&s._type===`element`&&(e.viewOf?s.viewOf=e.viewOf:delete s.viewOf,e.extends?s.extends=e.extends:delete s.extends);let c=[...n];a(c,1)?s.drifts=c:(s.hash=e.hash,delete s.drifts)})}function L(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id);return t?(i.delete(t.id),E(e,i=>{A(i,t);let o=new Set,s=e.children.length>0,c=t.children.length>0;(k(i.modelRef,t.modelRef)||k(i.deploymentRef,t.deploymentRef))&&o.add(`modelRef-changed`),c&&!s&&o.add(`became-compound`),!c&&s&&o.add(`became-leaf`),k(i.parent,t.parent)&&o.add(`parent-changed`);let l=i.width+5>=t.width&&i.height+5>=t.height;k(i.shape,t.shape)&&(l?i.shape=t.shape:o.add(`shape-changed`)),M(i,t,l)||o.add(`label-changed`),j(i,t,l&&c===s)||o.add(`label-changed`),(s?F:P)(i,t,l)||o.add(`label-changed`),k(i.notes,t.notes)&&(r(t.notes)?delete i.notes:i.notes=N(i.notes,t.notes)),k(e.notation,t.notation)&&(i.notation=t.notation??null),s&&c&&_(new Set(e.children),new Set(t.children)).size>0&&o.add(`children-changed`);let u=[...o];a(u,1)?(n.add(`nodes-drift`),i.drifts=u):delete i.drifts})):(n.add(`nodes-removed`),{...e,drifts:[`removed`]})});return i.size>0&&n.add(`nodes-added`),o}function R(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id)??f(i.values(),v(t=>t.source===e.source&&t.target===e.target),y());return t&&i.delete(t.id),E(e,i=>{if(!t){i.drifts=[`removed`],n.add(`edges-removed`);return}let o=new Set,s=e.id===t.id;switch(!0){case s&&e.source==t.source&&e.target==t.target:k(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break;case s&&e.source==t.target&&e.target==t.source:e.source!==e.target&&o.add(`direction-changed`);break;case s:e.source!=t.source&&o.add(`source-changed`),e.target!=t.target&&o.add(`target-changed`);break;default:w(e.id!=t.id,`Unexpected case in edge drift detection, ids should not match`),w(e.source==t.source,`Unexpected case in edge drift detection, sources should match`),w(e.target==t.target,`Unexpected case in edge drift detection, targets should match`),k(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break}if(i.color=t.color,i.line=t.line,i.navigateTo=t.navigateTo??null,i.tags=t.tags?[...t.tags]:null,k(e.notes,t.notes)&&(r(e.notes)!==r(t.notes)&&o.add(`notes-changed`),i.notes=t.notes??e.notes),t.astPath?i.astPath=t.astPath:delete i.astPath,k(u(e,[`label`,`description`,`technology`,`labelBBox`]),u(t,[`label`,`description`,`technology`,`labelBBox`])))switch(!0){case t.labelBBox&&!e.labelBBox:o.add(`label-added`);break;case e.labelBBox&&!t.labelBBox:o.add(`label-removed`);break;case!!e.labelBBox&&!!t.labelBBox:t.labelBBox.width*t.labelBBox.height>(e.labelBBox.width+5)*(e.labelBBox.height+5)&&(i.labelBBox.width=Math.round(t.labelBBox.width),i.labelBBox.height=Math.round(t.labelBBox.height)),k(e.label,t.label)&&(r(t.label)!==r(e.label)&&o.add(`label-changed`),i.label=t.label??e.label),k(e.description,t.description)&&(r(t.description)!==r(e.description)&&o.add(`label-changed`),t.description&&(i.description=N(e.description,t.description))),k(e.technology,t.technology)&&(r(t.technology)!==r(e.technology)&&o.add(`label-changed`),i.technology=t.technology??e.technology??null);break;default:w(!e.labelBBox,`Unexpected case in edge labelBBox drift detection`),w(!t.labelBBox,`Unexpected case in next labelBBox drift detection`);break}let c=[...o];a(c,1)?(n.add(`edges-drift`),i.drifts=c):delete i.drifts})});return i.size>0&&n.add(`edges-added`),o}function z(e,t){let{drifts:n,...r}=I(e,t);if(!n||n.length===0)return E(e,e=>{delete e.drifts,e[S]=`auto`});let i=new Set;n.includes(`type-changed`)&&i.add(`type-changed`);let o=new Map(r.nodes.map(e=>[e.id,e])),s=new Map(r.edges.map(e=>[e.id,e])),c=e.nodes.map(e=>{let t=o.get(e.id);return t&&o.delete(t.id),E(e,e=>{if(!t){i.add(`nodes-added`),e.drifts=[`added`];return}t.drifts?(i.add(`nodes-drift`),e.drifts=[...t.drifts]):delete e.drifts})});o.size>0&&i.add(`nodes-removed`);let l=e.edges.map(e=>{let t=s.get(e.id)??f(s.values(),v(t=>t.source===e.source&&t.target===e.target),y());return t&&s.delete(t.id),E(e,e=>{if(!t){i.add(`edges-added`),e.drifts=[`added`];return}t.drifts?(i.add(`edges-drift`),e.drifts=[...t.drifts]):delete e.drifts})});s.size>0&&i.add(`edges-removed`);let u=[...i];return E(e,e=>{a(u,1)?e.drifts=u:delete e.drifts,e.nodes=T(c),e.edges=T(l),e[S]=`auto`})}export{D as i,I as n,O as r,z as t};
1
+ import{C as e,H as t,K as n,M as r,O as i,Q as a,T as o,V as s,X as c,Y as l,_ as u,c as d,et as f,h as p,i as m,j as h,m as g}from"./libs/remeda.mjs";import{Sn as _,Wt as v,Yt as y,_t as b,g as x,gt as S,h as C,jt as w}from"./types.mjs";import{castDraft as T,produce as E}from"immer";function D(e,t){let{nodes:n,edges:r,hasManualLayout:i,...a}=e,o=new Map(n.map(e=>[e.id,e])),s=new Map(r.map(e=>[e.id,e])),c=t.nodes.map(e=>{let t=o.get(e.id);return t?{...t,x:e.x,y:e.y,width:e.width,height:e.height,labelBBox:e.labelBBox}:e}),l=t.edges.map(e=>{let t=s.get(e.id);return t?{...t,points:e.points,label:e.label,labelBBox:e.labelBBox,...e.controlPoints!=null&&{controlPoints:e.controlPoints}}:e}),u={...t,...a,[b]:`layouted`,bounds:t.bounds,nodes:c,edges:l};return i?u[S]=`auto`:delete u[S],u}function O(r){return f(r,l(e=>!!e.notation),t(g(`notation`)),e(p(t(g(`shape`)),e(p(t(g(`color`)),e(p(o(g(`kind`)),m())),c(),o(([e,t])=>({kinds:t,color:e})))),c(),n(([e,t])=>t.map(({color:t,kinds:n})=>({shape:e,color:t,kinds:n}))))),c(),n(([e,t])=>t.map(({shape:t,color:n,kinds:r})=>({title:e,shape:t,color:n,kinds:r}))),d(g(`shape`),g(`title`),[e=>e.kinds.length,`desc`]))}const k=(e,t)=>e===t||r(e)&&r(t)?!1:!s(e,t);function A(e,t){e.color=t.color,e.kind=t.kind,e.navigateTo=t.navigateTo??null,e.links=t.links?[...t.links]:null,e.tags=[...t.tags],r(t.style.border)?delete e.style.border:e.style.border=t.style.border,h(t.style.opacity)?e.style.opacity=t.style.opacity:delete e.style.opacity,r(t.style.multiple)?delete e.style.multiple:e.style.multiple=t.style.multiple}function j(e,t,n){if(k(t.icon??`none`,e.icon??`none`)){let a=i(e.icon)&&e.icon!==`none`;switch(!0){case a&&i(t.icon)&&t.icon!==`none`:return e.icon=t.icon,!0;case a&&(r(t.icon)||t.icon===`none`):return e.icon=`none`,!0;case!a&&i(t.icon)&&t.icon!==`none`:return n?(e.icon=t.icon,!0):!1}}return!0}function M(e,t,n){let i=!0;return k(e.style.iconColor,t.style.iconColor)&&(r(t.style.iconColor)?delete e.style.iconColor:e.style.iconColor=t.style.iconColor),k(e.style.iconSize,t.style.iconSize)&&(n?r(t.style.iconSize)?delete e.style.iconSize:e.style.iconSize=t.style.iconSize:i=!1),k(e.style.iconPosition,t.style.iconPosition)&&(n?r(t.style.iconPosition)?delete e.style.iconPosition:e.style.iconPosition=t.style.iconPosition:i=!1),i}function N(e,t){return e?`md`in t?(e.md=t.md,delete e.txt,e):(`txt`in t&&(e.txt=t.txt,delete e.md),e):t}function P(e,t,n){let i=!0;return k(e.title,t.title)&&(n?e.title=t.title:i=!1),k(e.description,t.description)&&(r(t.description)?delete e.description:n?e.description=N(e.description,t.description):i=!1),k(e.technology,t.technology)&&(r(t.technology)?delete e.technology:n?e.technology=t.technology:i=!1),i}function F(e,t,n){return e.title=t.title,r(t.description)?delete e.description:e.description=N(e.description,t.description),r(t.technology)?delete e.technology:e.technology=t.technology,!0}function I(e,t){_(e.id===t.id,`applyManualLayout: view ids do not match`),_(e._stage===`layouted`,`applyManualLayout: expected layouted view`),_(t._stage===`layouted`,`applyManualLayout: expected layouted snapshot`),_(e._layout!==`manual`,`applyManualLayout: expected auto-layouted view`);let n=new Set;e._type!==t._type&&n.add(`type-changed`);let r=L(t.nodes,e.nodes,n),i=R(t.edges,e.edges,n),o=O(r);return E(t,s=>{s.title=e.title??t.title,s.description=e.description??t.description,s.tags=e.tags?[...e.tags]:null,s.links=e.links?[...e.links]:null,s.sourcePath=e.sourcePath,s[S]=`manual`,o&&o.length>0?s.notation={nodes:o}:delete s.notation,s.nodes=T(r),s.edges=T(i),C(e)&&s._type===`dynamic`&&(s.variant=e.variant),x(e)&&s._type===`element`&&(e.viewOf?s.viewOf=e.viewOf:delete s.viewOf,e.extends?s.extends=e.extends:delete s.extends);let c=[...n];a(c,1)?s.drifts=c:(s.hash=e.hash,delete s.drifts)})}function L(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id);return t?(i.delete(t.id),E(e,i=>{A(i,t);let o=new Set,s=e.children.length>0,c=t.children.length>0;(k(i.modelRef,t.modelRef)||k(i.deploymentRef,t.deploymentRef))&&o.add(`modelRef-changed`),c&&!s&&o.add(`became-compound`),!c&&s&&o.add(`became-leaf`),k(i.parent,t.parent)&&o.add(`parent-changed`);let l=i.width+5>=t.width&&i.height+5>=t.height;k(i.shape,t.shape)&&(l?i.shape=t.shape:o.add(`shape-changed`)),M(i,t,l)||o.add(`label-changed`),j(i,t,l&&c===s)||o.add(`label-changed`),(s?F:P)(i,t,l)||o.add(`label-changed`),k(i.notes,t.notes)&&(r(t.notes)?delete i.notes:i.notes=N(i.notes,t.notes)),k(e.notation,t.notation)&&(i.notation=t.notation??null),s&&c&&w(new Set(e.children),new Set(t.children)).size>0&&o.add(`children-changed`);let u=[...o];a(u,1)?(n.add(`nodes-drift`),i.drifts=u):delete i.drifts})):(n.add(`nodes-removed`),{...e,drifts:[`removed`]})});return i.size>0&&n.add(`nodes-added`),o}function R(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id)??f(i.values(),y(t=>t.source===e.source&&t.target===e.target),v());return t&&i.delete(t.id),E(e,i=>{if(!t){i.drifts=[`removed`],n.add(`edges-removed`);return}let o=new Set,s=e.id===t.id;switch(!0){case s&&e.source==t.source&&e.target==t.target:k(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break;case s&&e.source==t.target&&e.target==t.source:e.source!==e.target&&o.add(`direction-changed`);break;case s:e.source!=t.source&&o.add(`source-changed`),e.target!=t.target&&o.add(`target-changed`);break;default:_(e.id!=t.id,`Unexpected case in edge drift detection, ids should not match`),_(e.source==t.source,`Unexpected case in edge drift detection, sources should match`),_(e.target==t.target,`Unexpected case in edge drift detection, targets should match`),k(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break}if(i.color=t.color,i.line=t.line,i.navigateTo=t.navigateTo??null,i.tags=t.tags?[...t.tags]:null,k(e.notes,t.notes)&&(r(e.notes)!==r(t.notes)&&o.add(`notes-changed`),i.notes=t.notes??e.notes),t.astPath?i.astPath=t.astPath:delete i.astPath,k(u(e,[`label`,`description`,`technology`,`labelBBox`]),u(t,[`label`,`description`,`technology`,`labelBBox`])))switch(!0){case t.labelBBox&&!e.labelBBox:o.add(`label-added`);break;case e.labelBBox&&!t.labelBBox:o.add(`label-removed`);break;case!!e.labelBBox&&!!t.labelBBox:t.labelBBox.width*t.labelBBox.height>(e.labelBBox.width+5)*(e.labelBBox.height+5)&&(i.labelBBox.width=Math.round(t.labelBBox.width),i.labelBBox.height=Math.round(t.labelBBox.height)),k(e.label,t.label)&&(r(t.label)!==r(e.label)&&o.add(`label-changed`),i.label=t.label??e.label),k(e.description,t.description)&&(r(t.description)!==r(e.description)&&o.add(`label-changed`),t.description&&(i.description=N(e.description,t.description))),k(e.technology,t.technology)&&(r(t.technology)!==r(e.technology)&&o.add(`label-changed`),i.technology=t.technology??e.technology??null);break;default:_(!e.labelBBox,`Unexpected case in edge labelBBox drift detection`),_(!t.labelBBox,`Unexpected case in next labelBBox drift detection`);break}let c=[...o];a(c,1)?(n.add(`edges-drift`),i.drifts=c):delete i.drifts})});return i.size>0&&n.add(`edges-added`),o}function z(e,t){let{drifts:n,...r}=I(e,t);if(!n||n.length===0)return E(e,e=>{delete e.drifts,e[S]=`auto`});let i=new Set;n.includes(`type-changed`)&&i.add(`type-changed`);let o=new Map(r.nodes.map(e=>[e.id,e])),s=new Map(r.edges.map(e=>[e.id,e])),c=e.nodes.map(e=>{let t=o.get(e.id);return t&&o.delete(t.id),E(e,e=>{if(!t){i.add(`nodes-added`),e.drifts=[`added`];return}t.drifts?(i.add(`nodes-drift`),e.drifts=[...t.drifts]):delete e.drifts})});o.size>0&&i.add(`nodes-removed`);let l=e.edges.map(e=>{let t=s.get(e.id)??f(s.values(),y(t=>t.source===e.source&&t.target===e.target),v());return t&&s.delete(t.id),E(e,e=>{if(!t){i.add(`edges-added`),e.drifts=[`added`];return}t.drifts?(i.add(`edges-drift`),e.drifts=[...t.drifts]):delete e.drifts})});s.size>0&&i.add(`edges-removed`);let u=[...i];return E(e,e=>{a(u,1)?e.drifts=u:delete e.drifts,e.nodes=T(c),e.edges=T(l),e[S]=`auto`})}export{D as i,I as n,O as r,z as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime.mjs";import{A as t,E as n,I as r,L as i,N as a,O as o,Q as s,T as c,X as l,c as ee,et as u,i as d,l as f,m as te,r as p,s as ne}from"./libs/remeda.mjs";import{$ as re,$t as ie,Bt as ae,Dn as m,Dt as oe,En as h,Et as g,H as se,It as _,Jt as ce,O as le,On as v,Sn as y,Ut as b,Y as x,_t as S,cn as C,ct as ue,dn as w,dt as de,en as fe,ft as pe,gn as me,hn as he,j as ge,jt as T,kt as E,ln as _e,mn as ve,mt as ye,nn as D,on as O,pn as be,qt as xe,sn as k,t as A,tn as j,un as Se,ut as Ce,vt as M,wt as we,xn as N,yt as Te}from"./types.mjs";import{t as P}from"./libs/mnemonist.mjs";import{n as Ee,t as De}from"./manual-layout.mjs";var F=class{Aux;id;_literalId;hierarchyLevel;imported;constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this._literalId=this.$element.id;let[n,r]=ye(this.id);n?(this.imported={from:n,fqn:r},this.hierarchyLevel=O(r)):(this.imported=null,this.hierarchyLevel=O(this.id))}get name(){return Se(this.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get tags(){return _(this,Symbol.for(`tags`),()=>d([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get metadata(){return this.$element.metadata??{}}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return A.memoize(this,`summary`,m(this.$element))}get description(){return A.memoize(this,`description`,h(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return _(this,Symbol.for(`defaultView`),()=>b(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return _(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$element.style}))}get projectId(){return this.imported?.from??this.$model.projectId}isAncestorOf(e){return k(this,e)}isDescendantOf(e){return k(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=D(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?be([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}get allOutgoing(){return _(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return _(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return _(this,Symbol.for(`views`),()=>{let e=new Set;for(let t of this.$model.views())t.includesElement(this.id)&&e.add(t);return e})}scopedViews(){return _(this,Symbol.for(`scopedViews`),()=>{let e=new Set;for(let t of this.$model.views())t.isScopedElementView()&&t.viewOf.id===this.id&&e.add(t);return e})}isDeployed(){return o(b(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!i(this.$element.metadata)}getMetadata(e){return e?this.$element.metadata?.[e]:this.$element.metadata??{}}isTagged(e){return this.tags.includes(e)}},Oe=class{Aux;get style(){return _(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$node.style}))}get name(){return Se(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return A.memoize(this,`summary`,m(this.$node))}get description(){return A.memoize(this,`description`,h(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=D(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}*views(){for(let e of this.$model.views())e._type===`deployment`&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return _(this,Symbol.for(`allOutgoing`),()=>z.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return _(this,Symbol.for(`allIncoming`),()=>z.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!i(this.$node.metadata)}getMetadata(e){return e?this.$node.metadata?.[e]:this.$node.metadata??{}}isTagged(e){return this.tags.includes(e)}},I=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this._literalId=t.id,this.title=t.title,this.hierarchyLevel=O(t.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get metadata(){return this.$node.metadata??{}}get tags(){return _(this,Symbol.for(`tags`),()=>d([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(e=`desc`){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(let e of this.descendants(`desc`))e.isInstance()&&(yield e)}onlyOneInstance(){let e=this.children();if(e.size!==1)return null;let t=b(e);return t?t.isInstance()?t:t.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let n of this.instances()){for(let t of n.element.outgoing())e.add(t);for(let e of n.element.incoming())t.add(e)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:e,incoming:t}=this.relationshipsFromInstances();return E(t,e)}},L=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t,n){super(),this.$model=e,this.$instance=t,this.element=n,this.id=t.id,this._literalId=t.id,this.title=t.title??n.title,this.hierarchyLevel=O(t.id)}get $node(){return this.$instance}get parent(){return y(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return _(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.element.$element.style,...this.$instance.style}))}get tags(){return _(this,Symbol.for(`tags`),()=>d([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get metadata(){return this.$instance.metadata??this.element.metadata??{}}get summary(){return A.memoize(this,`summary`,m(this.$instance)??m(this.element.$element))}get description(){return A.memoize(this,`description`,h(this.$instance)??h(this.element.$element))}get technology(){return this.$instance.technology??this.element.technology??null}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(let e of this.$model.views())if(e._type===`deployment`){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}},ke=class{constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return _(this,`style `,()=>({shape:this.element.shape,color:this.element.color,...this.element.$element.style}))}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get summary(){return this.element.summary}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}},R=class{boundary;source;target;constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);let n=D(this.source.id,this.target.id);this.boundary=n?this.$model.node(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return o(this.$relationship.title)?this.$relationship.title:null}get technology(){return r(this.$relationship.technology)?(this.kind&&this.$model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return A.memoize(this,`summary`,m(this.$relationship))}get description(){return A.memoize(this,`description`,h(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.$model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},z=class e{static empty(){return new e}static from(t,n){return new e(new Set(t),new Set(n))}constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(t){return e.from(E(this.model,t.model),E(this.deployment,t.deployment))}difference(t){return e.from(g(this.model,t.model),g(this.deployment,t.deployment))}union(t){return e.from(T(this.model,t.model),T(this.deployment,t.deployment))}};const B=e=>typeof e==`string`?e:e.id,Ae=`/`,V=e=>{if(N(!e.includes(`
2
- `),`View title cannot contain newlines`),e.includes(`/`)){let t=e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0);return s(t,1)?t:[``]}return[e.trim()]},H=e=>V(e).join(`/`),je=e=>{let t=V(e);return s(t,2)?t.slice(0,-1).join(`/`):null},Me=e=>e.includes(`/`)?V(e).pop()??e:e.trim();var Ne=class{#e=new Map;#t=new Map;#n=new P.default(()=>new Set);#r=new P.default(()=>new Set);#i=new Set;#a=new Map;#o=new P.default(()=>new Set);#s=new P.default(()=>new Set);#c=new P.default(()=>new Set);#l=new P.default(()=>new Set);#u=new Map;$deployments;constructor(e){this.$model=e;let t=this.$deployments=e.$data.deployments,n=p(t.elements);for(let e of ve(n)){let t=this.addElement(e);for(let e of t.tags)this.#l.get(e).add(t);t.isInstance()&&this.#r.get(t.element.id).add(t)}for(let e of p(t.relations)){let t=this.addRelation(e);for(let e of t.tags)this.#l.get(e).add(t)}}get $styles(){return this.$model.$styles}get projectId(){return this.$model.projectId}get project(){return this.$model.project}get specification(){return this.$model.specification}element(e){if(e instanceof I||e instanceof L)return e;let t=B(e);return y(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){let t=this.element(e);return N(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){let t=this.findElement(e);return t?(N(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){let t=this.element(e);return N(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){let t=this.findElement(e);return t?(N(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let e of this.#e.values())e.isDeploymentNode()&&(yield e)}*nodesOfKind(e){for(let t of this.#e.values())t.isDeploymentNode()&&t.kind===e&&(yield t)}*instances(){for(let e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){let t=B(e),n=this.#r.get(t);n&&(yield*n)}deploymentRef(e){if(x.isInsideInstanceRef(e)){let{deployment:t,element:n}=e;return fe(this.#u,`${t}@${n}`,()=>new ke(this.instance(t),this.$model.element(n)))}return this.element(e.deployment)}relationships(){return this.#a.values()}relationship(e){let t=B(e);return y(this.#a.get(t),`DeploymentRelationModel ${t} not found`)}findRelationship(e){return this.#a.get(e)??null}*views(){for(let e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){let t=B(e);return this.#t.get(t)||null}children(e){let t=B(e);return this.#n.get(t)}*siblings(e){let t=B(e),n=this.parent(e)?.children()??this.roots();for(let e of n)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this.#t.get(t);)yield n,t=n.id}*descendants(e,t=`desc`){for(let n of this.children(e))t===`asc`?(yield n,yield*this.descendants(n.id)):(yield*this.descendants(n.id),yield n)}*incoming(e,t=`all`){let n=B(e);for(let e of this.#o.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this.#s.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}addElement(e){if(this.#e.has(e.id))throw Error(`Element ${e.id} already exists`);let t=se(e)?new I(this,Object.freeze(e)):new L(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);let n=w(t.id);return n?(N(this.#e.has(n),`Parent ${n} of ${t.id} not found`),this.#t.set(t.id,this.node(n)),this.#n.get(n).add(t)):(N(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#a.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new R(this,Object.freeze(e));this.#a.set(t.id,t),this.#o.get(t.target.id).add(t),this.#s.get(t.source.id).add(t);let n=t.boundary?.id??null;if(n)for(let e of[n,...j(n)])this.#c.get(e).add(t);for(let e of j(t.source.id)){if(e===n)break;this.#s.get(e).add(t)}for(let e of j(t.target.id)){if(e===n)break;this.#o.get(e).add(t)}return t}},U=class{source;target;boundary;constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(x.flatten(t.source)),this.target=e.element(x.flatten(t.target));let n=D(this.source.id,this.target.id);this.boundary=n?this.model.element(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return r(this.$relationship.title)?null:this.$relationship.title}get technology(){return r(this.$relationship.technology)?(this.kind&&this.model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return A.memoize(this,`summary`,m(this.$relationship))}get description(){return A.memoize(this,`description`,h(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},W=class{Aux;$viewModel;$view;$edge;constructor(e,t,n,r){this.source=n,this.target=r,this.$viewModel=e,this.$view=e.$view,this.$edge=t}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.$viewModel.node(this.$edge.parent):null}get label(){return this.$edge.label??null}get description(){return A.memoize(this,`description`,this.$edge.description)}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?ue(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.$viewModel.$model.view(this.$edge.navigateTo):null}get color(){return this.$edge.color}get line(){return this.$edge.line??this.$viewModel.$styles.defaults.relationship.line}get head(){return this.$edge.head??this.$viewModel.$styles.defaults.relationship.arrow}get tail(){return this.$edge.tail}isStep(){return pe(this.id)}*relationships(e){for(let t of this.$edge.relations)if(e){let n=this.$viewModel.$model.findRelationship(t,e);n&&(yield n)}else yield this.$viewModel.$model.relationship(t)}includesRelation(e){let t=typeof e==`string`?e:e.id;return this.$edge.relations.includes(t)}isTagged(e){return this.tags.includes(e)}},G=class{Aux;$viewModel;$view;$node;constructor(e,t){this.$viewModel=e,this.$view=e.$view,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return A.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return A.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let e=this.$node.modelRef;return e?this.$viewModel.$model.element(e):null}get deployment(){let e=this.$node.deploymentRef;return e?this.$viewModel.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get icon(){return this.$node.icon??null}get tags(){return this.$node.tags}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$viewModel.$model.view(this.$node.navigateTo):null}get style(){return this.$node.style}get x(){return`x`in this.$node?this.$node.x:void 0}get y(){return`y`in this.$node?this.$node.y:void 0}get width(){return`width`in this.$node?this.$node.width:void 0}get height(){return`height`in this.$node?this.$node.height:void 0}children(){return _(this,`children`,()=>new Set(this.$node.children.map(e=>this.$viewModel.node(e))))}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*siblings(){let e=this.parent?.children()??this.$viewModel.roots();for(let t of e)t.id!==this.id&&(yield t)}*incoming(e=`all`){for(let t of this.$node.inEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.target.id===this.id:case e===`to-descendants`&&n.target.id!==this.id:yield n;break}}}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoing(e=`all`){for(let t of this.$node.outEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.source.id===this.id:case e===`from-descendants`&&n.source.id!==this.id:yield n;break}}}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}isLayouted(){return`width`in this.$node&&`height`in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return o(this.$node.modelRef)}hasDeployment(){return o(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return de(this.$node)}isTagged(e){return this.tags.includes(e)}},K=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new P.default(e=>new Set);#c;id;$model;title;folder;viewPath;constructor(e,t,n,r){this.$model=e,this.#e=n,this.id=n.id,this.folder=t,this.#c=r;for(let e of this.#e.nodes){let t=new G(this,Object.freeze(e));this.#n.set(e.id,t),e.parent||this.#t.add(t),e.deploymentRef&&this.#a.add(e.deploymentRef),e.modelRef&&this.#i.add(e.modelRef);for(let e of t.tags)this.#s.get(e).add(t)}for(let e of this.#e.edges){let t=new W(this,Object.freeze(e),this.node(e.source),this.node(e.target));for(let e of t.tags)this.#s.get(e).add(t);for(let t of e.relations)this.#o.add(t);this.#r.set(e.id,t)}this.title=n.title?Me(n.title):null,this.viewPath=n.title?H(n.title):n.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[M]}get stage(){return this.#e[S]}get bounds(){if(`bounds`in this.#e)return this.#e.bounds;if(this.#c)return this.#c.bounds;throw Error(`View is not layouted`)}get titleOrId(){return this.title??this.viewOf?.title??this.id}get titleOrUntitled(){return this.title??`Untitled`}get breadcrumbs(){return _(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return A.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let e=this.#e.viewOf;return e?this.$model.element(e):null}return null}get mode(){return this.isDynamicView()?this.#e.variant??`diagram`:null}get includedTags(){return[...this.#s.keys()]}get $view(){if(!this.isLayouted()||`drifts`in this.#e)return this.#e;let e=this.#c;return e?_(this,`withDriftReasons`,()=>De(this.#e,e)):this.#e}get $layouted(){if(!this.isLayouted())throw Error(`View is not layouted`);return this.$manual??this.#e}get hasManualLayout(){return this.#c!==void 0}get hasLayoutDrifts(){if(!this.isLayouted())return!1;let e=this.$manual;return!!e?.drifts&&e.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let e=this.#c;return e?this.#e._layout===`manual`?this.#e:_(this,`snapshotWithManualLayout`,()=>Ee(this.#e,e)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let e of this.#n.values())e.hasChildren()&&(yield e)}node(e){let t=B(e);return y(this.#n.get(t),`Node ${t} not found in view ${this.#e.id}`)}findNode(e){return this.#n.get(B(e))??null}findNodeWithElement(e){let t=B(e);return this.#i.has(t)?xe(this.#n.values(),e=>e.hasElement()&&e.element.id===t)??null:null}nodes(){return this.#n.values()}edge(e){let t=B(e);return y(this.#r.get(t),`Edge ${t} not found in view ${this.#e.id}`)}findEdge(e){return this.#r.get(B(e))??null}edges(){return this.#r.values()}*edgesWithRelation(e){for(let t of this.#r.values())t.includesRelation(e)&&(yield t)}*elements(){for(let e of this.#n.values())e.hasElement()&&(yield e)}isTagged(e){return this.tags.includes(e)}includesElement(e){return this.#i.has(B(e))}includesDeployment(e){return this.#a.has(B(e))}includesRelation(e){return this.#o.has(B(e))}isComputed(){return this.#e[S]===`computed`}isLayouted(){return this.#e[S]===`layouted`}isDiagram(){return this.#e[S]===`layouted`}isElementView(){return this.#e[M]===`element`}isScopedElementView(){return this.#e._type===`element`&&o(this.#e.viewOf)}isDeploymentView(){return this.#e[M]===`deployment`}isDynamicView(){return this.#e[M]===`dynamic`}},q=class e{$model;path;title;isRoot;parentPath;defaultViewId;constructor(e,t,r){this.$model=e,this.path=t.join(`/`),this.isRoot=this.path===``,this.title=n(t),this.isRoot?this.parentPath=void 0:this.parentPath=t.slice(0,-1).join(`/`),this.defaultViewId=r}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return N(!this.isRoot,`Root view folder has no breadcrumbs`),_(this,`breadcrumbs`,()=>{let e=this.parent;return e?e.isRoot?[e,this]:[...e.breadcrumbs,this]:[this]})}get parent(){return N(!this.isRoot,`Root view folder has no parent`),r(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return _(this,`folders`,()=>{let t=[];for(let n of this.children)n instanceof e&&t.push(n);return t})}get views(){return _(this,`views`,()=>{let e=[];for(let t of this.children)t instanceof K&&e.push(t);return e})}},J=class e{Aux;_elements=new Map;_parents=new Map;_children=new P.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new P.default(()=>new Set);_outgoing=new P.default(()=>new Set);_internal=new P.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new P.default(()=>new Set);_allTags=new P.default(()=>new Set);static fromParsed(t){return new e(t)}static create(t){return new e(t)}static fromDump(t){let{_stage:n=`layouted`,projectId:r=`unknown`,project:i,globals:a,imports:o,deployments:s,views:c,relations:l,elements:ee,specification:u}=t;return new e({[S]:n,projectId:r,project:i,globals:{predicates:a?.predicates??{},dynamicPredicates:a?.dynamicPredicates??{},styles:a?.styles??{}},imports:o??{},deployments:{elements:s?.elements??{},relations:s?.relations??{}},views:c??{},relations:l??{},elements:ee??{},specification:u})}deployment;$data;constructor(e){this.$data=e;for(let[,t]of l(e.elements)){let e=this.addElement(t);for(let t of e.tags)this._allTags.get(t).add(e)}for(let[t,n]of l(e.imports??{}))for(let e of ve(n)){let n=this.addImportedElement(t,e);for(let e of n.tags)this._allTags.get(e).add(n)}for(let t of p(e.relations)){let e=this.addRelation(t);for(let t of e.tags)this._allTags.get(t).add(e)}if(this.deployment=new Ne(this),Te(e,`computed`)||Te(e,`layouted`)){let t=me(`/`),n=u(p(e.views),c(e=>({view:e,path:H(e.title??e.id),folderPath:e.title&&je(e.title)||``})),f((e,n)=>t(e.folderPath,n.folderPath))),r=e=>{let t=this._viewFolders.get(e);if(!t){let r=ne(e,`/`);N(s(r,1),`View group path "${e}" must have at least one element`);let i;i=e===``?n.find(e=>e.view.id===`index`):n.find(t=>t.path===e),t=new q(this,r,i?.view.id),this._viewFolders.set(e,t)}return t};this._rootViewFolder=r(``);for(let{folderPath:e}of n)this._viewFolders.has(e)||ne(e,`/`).reduce((e,t)=>{let n=e.join(`/`),a=r(i(n)?t:n+`/`+t);return this._viewFolderItems.get(n).add(a),e.push(t),e},[]);for(let{view:t,folderPath:i}of n){let n=new K(this,r(i),t,e.manualLayouts?.[t.id]);this._viewFolderItems.get(i).add(n),this._views.set(t.id,n);for(let e of n.tags)this._allTags.get(e).add(n)}}else this._rootViewFolder=new q(this,[``],void 0),this._viewFolders.set(this._rootViewFolder.path,this._rootViewFolder)}get asParsed(){return this}get asComputed(){return this}get asLayouted(){return this}get $styles(){return _(this,`styles`,()=>ge.from(this.project.styles,this.specification.customColors))}isParsed(){return this.stage===`parsed`}isLayouted(){return this.stage===`layouted`}isComputed(){return this.stage===`computed`}get $model(){return this.$data}get stage(){return this.$data[S]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??_(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return _(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(e){if(e instanceof F)return e;let t=B(e);return y(this._elements.get(t),`Element ${t} not found`)}findElement(e){return this._elements.get(B(e))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(e,t){if(t===`deployment`)return this.deployment.relationship(e);let n=B(e),r=this._relations.get(n)??null;return r||t===`model`?y(r,`Model relation ${n} not found`):y(this.deployment.findRelationship(n),`No model/deployment relation ${n} not found`)}findRelationship(e,t){if(t===`deployment`)return this.deployment.findRelationship(e);let n=this._relations.get(B(e))??null;return n||t===`model`?n:this.deployment.findRelationship(e)}views(){return this._views.values()}view(e){let t=B(e);return y(this._views.get(t),`View ${t} not found`)}findView(e){return this._views.get(e)??null}findManualLayout(e){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[e]??null:null}viewFolder(e){return y(this._viewFolders.get(e),`View folder ${e} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(e){return N(this._viewFolders.has(e),`View folder ${e} not found`),this._viewFolderItems.get(e)}parent(e){let t=B(e);return this._parents.get(t)||null}children(e){let t=B(e);return this._children.get(t)}*siblings(e){let t=B(e),n=this._parents.get(t),r=n?this._children.get(n.id).values():this.roots();for(let e of r)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this._parents.get(t);)yield n,t=n.id}*descendants(e){for(let t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t=`all`){let n=B(e);for(let e of this._incoming.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this._outgoing.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}get tags(){return _(this,`tags`,()=>f([...this._allTags.keys()],he))}get tagsSortedByUsage(){return _(this,`tagsSortedByUsage`,()=>u([...this._allTags.entries()],c(([e,t])=>({tag:e,count:t.size,tagged:t})),f((e,t)=>he(e.tag,t.tag)),ee([te(`count`),`desc`])))}findByTag(e,t){return ce(this._allTags.get(e),e=>t===`elements`?e instanceof F:t===`views`?e instanceof K:t===`relationships`?e instanceof U:!0)}*elementsOfKind(e){for(let t of this._elements.values())t.kind===e&&(yield t)}*elementsWhere(e){let t=le(e);for(let e of this._elements.values())t(e)&&(yield e)}*relationshipsWhere(e){let t=le(e);for(let e of this._relations.values())t(e)&&(yield e)}addElement(e){if(this._elements.has(e.id))throw Error(`Element ${e.id} already exists`);let t=new F(this,Object.freeze(e));this._elements.set(t.id,t);let n=w(t.id);return n?(N(this._elements.has(n),`Parent ${n} of ${t.id} not found`),this._parents.set(t.id,this.element(n)),this._children.get(n).add(t)):this._rootElements.add(t),t}addImportedElement(e,t){N(!Ce(t.id),`Imported element already has global FQN`);let n=re(e,t.id);if(this._elements.has(n))throw Error(`Element ${n} already exists`);let r=new F(this,Object.freeze({...t,id:n}));this._elements.set(r.id,r);let i=w(r.id);for(;i;){if(i.includes(`.`)&&this._elements.has(i))return this._parents.set(r.id,this.element(i)),this._children.get(i).add(r),r;i=w(i)}return this._rootElements.add(r),r}addRelation(e){if(this._relations.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new U(this,Object.freeze(e)),{source:n,target:r}=t;this._relations.set(t.id,t),this._incoming.get(r.id).add(t),this._outgoing.get(n.id).add(t);let i=D(n.id,r.id);if(i)for(let e of[i,...j(i)])this._internal.get(e).add(t);for(let e of j(n.id)){if(e===i)break;this._outgoing.get(e).add(t)}for(let e of j(r.id)){if(e===i)break;this._incoming.get(e).add(t)}return t}};(function(e){e.EMPTY=J.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(J||={});let Pe;(function(e){e.isInside=e=>t=>k(e,t.source.id)&&k(e,t.target.id);let t=e.isDirectedBetween=(e,t)=>n=>(n.source.id===e||k(e,n.source.id))&&(n.target.id===t||k(t,n.target.id));e.isAnyBetween=(e,n)=>{let r=t(e,n),i=t(n,e);return e=>r(e)||i(e)};let n=e.isIncoming=e=>t=>(t.target.id===e||k(e,t.target.id))&&!k(e,t.source.id),r=e.isOutgoing=e=>t=>(t.source.id===e||k(e,t.source.id))&&!k(e,t.target.id);e.isAnyInOut=e=>{let t=n(e),i=r(e);return e=>t(e)||i(e)}})(Pe||={});const Y=Symbol.for(`nodejs.util.inspect.custom`);var Fe=class e{id;constructor(e,t,n){this.source=e,this.target=t,this.relations=n,this.id=we(`deployment:${e.id}:${t.id}`)}get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){let e=[...this.relations.model].map(e=>` `+e.expression);e.length?e.unshift(` model:`):e.unshift(` model: []`);let t=[...this.relations.deployment].map(e=>` `+e.expression);return t.length?t.unshift(` deployment:`):t.unshift(` deployment: []`),[this.expression,...e,...t].join(`
3
- `)}hasDirectDeploymentRelation(){for(let e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(t){return Array.isArray(t)?t.reduce((e,t)=>e.mergeWith(t),this):(N(this.source.id===t.source.id,`Cannot merge connections with different sources`),N(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,this.relations.union(t.relations)))}difference(t){return new e(this.source,this.target,this.relations.difference(t.relations))}intersect(t){return new e(this.source,this.target,this.relations.intersect(t.relations))}equals(t){return N(t instanceof e,`Other should ne DeploymentConnectionModel`),this.id===t.id&&this.source.id===t.source.id&&this.target.id===t.target.id&&oe(this.relations.model,t.relations.model)&&oe(this.relations.deployment,t.relations.deployment)}update(t){return t&&={model:this.relations.model,deployment:this.relations.deployment,...t},new e(this.source,this.target,t?new z(t.model??new Set,t.deployment??new Set):this.relations)}};function X(e,t){if(!t){let t=e;return e=>X(e,t)}let n=e.source===t.source,r=e.target===t.target;if(n&&r)return!1;let i=k(t.source.id,e.source.id),a=k(t.target.id,e.target.id);return i&&a||n&&a||r&&i}function Ie(e,t){let n=t;for(let t of e)X(t,n)&&(n=t);return n===t?null:n}function Le(e){let t=[],n=e.slice(),r;for(;r=n.shift();){let e;for(;e=Ie(n,r);){let r=n.indexOf(e);t.push(n.splice(r,1)[0])}t.push(r)}return t}function Re(e){return e.boundary?.id?`.${e.boundary.id}`:``}function ze(e,t){if(!e||ie(e)){let t=e??`asc`;return e=>Be(e,t)}return Be(e,t??`asc`)}function Be(e,t){return u(e,c(e=>({id:Re(e),conn:e})),be(t),c(e=>e.conn))}function Ve(e,t){return e.filter(e=>X(t,e))}function He(e,t){return e.filter(X(t))}function Ue(e){let t=new Map;for(let n of e){let e=t.get(n.id);e?t.set(n.id,n.mergeWith(e)):t.set(n.id,n)}return[...t.values()]}function We(e,t){let n=new Map([...t].map(e=>[e.id,e]));return[...e].reduce((e,t)=>{let r=n.get(t.id);if(!r)return e.push(t),e;let i=t.difference(r);return i.nonEmpty()&&e.push(i),e},[])}function Z(e,t){return t?e.source===t.source&&e.target===t.target:t=>e.source===t.source&&e.target===t.target}function Ge(e,t){return t?e.source===t.source:t=>e.source===t.source}function Ke(e,t){return t?e.target===t.target:t=>e.target===t.target}function qe(e,t){if(!t){let t=e;return e=>qe(e,t)}let n=e;return C(n.source,t)&&!C(n.target,t)}function Je(e,t){if(!t){let t=e;return e=>Je(e,t)}let n=e;return C(n.target,t)&&!C(n.source,t)}function Ye(e,t){if(!t){let t=e;return e=>Ye(e,t)}let n=e;return C(n.source,t)!==C(n.target,t)}var Q=class e{id;constructor(e,t,n=new Set){this.source=e,this.target=t,this.relations=n,this.id=we(`model:${e.id}:${t.id}`)}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&ae(this.relations,a(Z(this)))}get directRelations(){return new Set(ce(this.relations,Z(this)))}nonEmpty(){return this.relations.size>0}mergeWith(t){return N(this.source.id===t.source.id,`Cannot merge connections with different sources`),N(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,T(this.relations,t.relations))}difference(t){return new e(this.source,this.target,g(this.relations,t.relations))}intersect(t){return N(t instanceof e,`Cannot intersect connection with different type`),new e(this.source,this.target,E(this.relations,t.relations))}equals(t){N(t instanceof e,`Cannot merge connection with different type`);let n=t;return this.id===n.id&&this.source.id===n.source.id&&this.target.id===n.target.id&&oe(this.relations,n.relations)}update(t){return new e(this.source,this.target,t)}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?` relations:`:` relations: [ ]`,...[...this.relations].map(e=>` `+e.expression)].join(`
4
- `)}reversed(){return new e(this.target,this.source)}},Xe=e({findConnection:()=>$,findConnectionsBetween:()=>Ze,findConnectionsWithin:()=>Qe});function $(e,t,n=`directed`){if(e===t||_e(e,t))return[];let r=e.allOutgoing.intersect(t.allIncoming),i=r.nonEmpty?[new Fe(e,t,r)]:[];return n===`directed`?i:[...i,...$(t,e,`directed`)]}function Ze(e,t,n=`both`){if(e.allIncoming.isEmpty&&e.allOutgoing.isEmpty)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of $(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function Qe(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...Ze(t,r.slice(n+1),`both`)),e),[])}var $e=e({findConnection:()=>et,findConnectionsBetween:()=>tt,findConnectionsWithin:()=>nt});function et(e,t,n=`directed`){if(e===t||_e(e,t))return[];let r=E(e.allOutgoing,t.allIncoming),i=r.size>0?new Q(e,t,r):null;if(n===`directed`)return i?[i]:[];let a=E(e.allIncoming,t.allOutgoing),o=a.size>0?new Q(t,e,a):null;return i&&o?[i,o]:i?[i]:o?[o]:[]}function tt(e,t,n=`both`){if(e.allIncoming.size===0&&e.allOutgoing.size===0)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of et(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function nt(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...tt(t,r.slice(n+1),`both`)),e),[])}function rt(e){return e instanceof I}function it(e){return e instanceof L}function at(e){return rt(e)||it(e)}function ot(e){return e instanceof ke}function st(e){return e instanceof R}function ct(e){return e instanceof U}function lt(e){return e instanceof F}function ut(e){return e instanceof K}function dt(e){return e instanceof G}function ft(e){return e instanceof W}export{Fe as A,Ae as B,Ye as C,Ue as D,qe as E,K as F,I as G,je as H,G as I,F as J,R as K,W as L,Pe as M,J as N,ze as O,q as P,U as R,Ke as S,X as T,H as U,Me as V,L as W,Ve as _,ft as a,Ge as b,ot as c,et as d,tt as f,We as g,Q as h,st as i,Y as j,Le as k,dt as l,Xe as m,at as n,lt as o,$e as p,z as q,rt as r,ut as s,it as t,ct as u,Ie as v,Je as w,Z as x,He as y,Ne as z};
1
+ import{n as e}from"./rolldown-runtime.mjs";import{A as t,E as n,I as r,L as i,N as a,O as o,Q as s,T as c,X as l,c as ee,et as u,i as d,l as f,m as te,r as p,s as ne}from"./libs/remeda.mjs";import{$ as re,At as m,Cn as h,Dn as g,Dt as _,H as ie,Jt as ae,Lt as v,Mt as oe,O as se,On as y,Ot as b,Sn as x,Tt as ce,Vt as le,Wt as S,Y as C,Yt as ue,_n as de,_t as w,cn as T,ct as fe,dn as pe,dt as me,en as he,fn as E,ft as ge,gn as _e,hn as ve,j as ye,kn as D,ln as O,mn as be,mt as xe,nn as k,rn as A,sn as j,t as M,tn as Se,un as Ce,ut as we,vt as N,yt as Te}from"./types.mjs";import{t as P}from"./libs/mnemonist.mjs";import{n as Ee,t as De}from"./manual-layout.mjs";var F=class{$model;$element;Aux;id;_literalId;hierarchyLevel;imported;constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this._literalId=this.$element.id;let[n,r]=xe(this.id);n?(this.imported={from:n,fqn:r},this.hierarchyLevel=j(r)):(this.imported=null,this.hierarchyLevel=j(this.id))}get name(){return pe(this.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get tags(){return v(this,Symbol.for(`tags`),()=>d([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get metadata(){return this.$element.metadata??{}}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return M.memoize(this,`summary`,y(this.$element))}get description(){return M.memoize(this,`description`,g(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return v(this,Symbol.for(`defaultView`),()=>S(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return v(this,`style`,()=>D({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$element.style}))}get projectId(){return this.imported?.from??this.$model.projectId}isAncestorOf(e){return T(this,e)}isDescendantOf(e){return T(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=A(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?be([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}get allOutgoing(){return v(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return v(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return v(this,Symbol.for(`views`),()=>{let e=new Set;for(let t of this.$model.views())t.includesElement(this.id)&&e.add(t);return e})}scopedViews(){return v(this,Symbol.for(`scopedViews`),()=>{let e=new Set;for(let t of this.$model.views())t.isScopedElementView()&&t.viewOf.id===this.id&&e.add(t);return e})}isDeployed(){return o(S(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!i(this.$element.metadata)}getMetadata(e){return e?this.$element.metadata?.[e]:this.$element.metadata??{}}isTagged(e){return this.tags.includes(e)}},Oe=class{Aux;get style(){return v(this,`style`,()=>D({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$node.style}))}get name(){return pe(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return M.memoize(this,`summary`,y(this.$node))}get description(){return M.memoize(this,`description`,g(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=A(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}*views(){for(let e of this.$model.views())e._type===`deployment`&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return v(this,Symbol.for(`allOutgoing`),()=>z.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return v(this,Symbol.for(`allIncoming`),()=>z.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!i(this.$node.metadata)}getMetadata(e){return e?this.$node.metadata?.[e]:this.$node.metadata??{}}isTagged(e){return this.tags.includes(e)}},I=class extends Oe{$model;$node;id;_literalId;title;hierarchyLevel;constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this._literalId=t.id,this.title=t.title,this.hierarchyLevel=j(t.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get metadata(){return this.$node.metadata??{}}get tags(){return v(this,Symbol.for(`tags`),()=>d([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(e=`desc`){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(let e of this.descendants(`desc`))e.isInstance()&&(yield e)}onlyOneInstance(){let e=this.children();if(e.size!==1)return null;let t=S(e);return t?t.isInstance()?t:t.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let n of this.instances()){for(let t of n.element.outgoing())e.add(t);for(let e of n.element.incoming())t.add(e)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:e,incoming:t}=this.relationshipsFromInstances();return m(t,e)}},L=class extends Oe{$model;$instance;element;id;_literalId;title;hierarchyLevel;constructor(e,t,n){super(),this.$model=e,this.$instance=t,this.element=n,this.id=t.id,this._literalId=t.id,this.title=t.title??n.title,this.hierarchyLevel=j(t.id)}get $node(){return this.$instance}get parent(){return h(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return v(this,`style`,()=>D({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.element.$element.style,...this.$instance.style}))}get tags(){return v(this,Symbol.for(`tags`),()=>d([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get metadata(){return this.$instance.metadata??this.element.metadata??{}}get summary(){return M.memoize(this,`summary`,y(this.$instance)??y(this.element.$element))}get description(){return M.memoize(this,`description`,g(this.$instance)??g(this.element.$element))}get technology(){return this.$instance.technology??this.element.technology??null}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(let e of this.$model.views())if(e._type===`deployment`){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}},ke=class{instance;element;constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return v(this,`style `,()=>({shape:this.element.shape,color:this.element.color,...this.element.$element.style}))}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get summary(){return this.element.summary}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}},R=class{$model;$relationship;boundary;source;target;constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);let n=A(this.source.id,this.target.id);this.boundary=n?this.$model.node(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return o(this.$relationship.title)?this.$relationship.title:null}get technology(){return r(this.$relationship.technology)?(this.kind&&this.$model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return M.memoize(this,`summary`,y(this.$relationship))}get description(){return M.memoize(this,`description`,g(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.$model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},z=class e{model;deployment;static empty(){return new e}static from(t,n){return new e(new Set(t),new Set(n))}constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(t){return e.from(m(this.model,t.model),m(this.deployment,t.deployment))}difference(t){return e.from(_(this.model,t.model),_(this.deployment,t.deployment))}union(t){return e.from(oe(this.model,t.model),oe(this.deployment,t.deployment))}};const B=e=>typeof e==`string`?e:e.id,Ae=`/`,V=e=>{if(x(!e.includes(`
2
+ `),`View title cannot contain newlines`),e.includes(`/`)){let t=e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0);return s(t,1)?t:[``]}return[e.trim()]},H=e=>V(e).join(`/`),je=e=>{let t=V(e);return s(t,2)?t.slice(0,-1).join(`/`):null},Me=e=>e.includes(`/`)?V(e).pop()??e:e.trim();var Ne=class{$model;#e=new Map;#t=new Map;#n=new P.default(()=>new Set);#r=new P.default(()=>new Set);#i=new Set;#a=new Map;#o=new P.default(()=>new Set);#s=new P.default(()=>new Set);#c=new P.default(()=>new Set);#l=new P.default(()=>new Set);#u=new Map;$deployments;constructor(e){this.$model=e;let t=this.$deployments=e.$data.deployments,n=p(t.elements);for(let e of ve(n)){let t=this.addElement(e);for(let e of t.tags)this.#l.get(e).add(t);t.isInstance()&&this.#r.get(t.element.id).add(t)}for(let e of p(t.relations)){let t=this.addRelation(e);for(let e of t.tags)this.#l.get(e).add(t)}}get $styles(){return this.$model.$styles}get projectId(){return this.$model.projectId}get project(){return this.$model.project}get specification(){return this.$model.specification}element(e){if(e instanceof I||e instanceof L)return e;let t=B(e);return h(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){let t=this.element(e);return x(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){let t=this.findElement(e);return t?(x(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){let t=this.element(e);return x(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){let t=this.findElement(e);return t?(x(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let e of this.#e.values())e.isDeploymentNode()&&(yield e)}*nodesOfKind(e){for(let t of this.#e.values())t.isDeploymentNode()&&t.kind===e&&(yield t)}*instances(){for(let e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){let t=B(e),n=this.#r.get(t);n&&(yield*n)}deploymentRef(e){if(C.isInsideInstanceRef(e)){let{deployment:t,element:n}=e;return Se(this.#u,`${t}@${n}`,()=>new ke(this.instance(t),this.$model.element(n)))}return this.element(e.deployment)}relationships(){return this.#a.values()}relationship(e){let t=B(e);return h(this.#a.get(t),`DeploymentRelationModel ${t} not found`)}findRelationship(e){return this.#a.get(e)??null}*views(){for(let e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){let t=B(e);return this.#t.get(t)||null}children(e){let t=B(e);return this.#n.get(t)}*siblings(e){let t=B(e),n=this.parent(e)?.children()??this.roots();for(let e of n)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this.#t.get(t);)yield n,t=n.id}*descendants(e,t=`desc`){for(let n of this.children(e))t===`asc`?(yield n,yield*this.descendants(n.id)):(yield*this.descendants(n.id),yield n)}*incoming(e,t=`all`){let n=B(e);for(let e of this.#o.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this.#s.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}addElement(e){if(this.#e.has(e.id))throw Error(`Element ${e.id} already exists`);let t=ie(e)?new I(this,Object.freeze(e)):new L(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);let n=E(t.id);return n?(x(this.#e.has(n),`Parent ${n} of ${t.id} not found`),this.#t.set(t.id,this.node(n)),this.#n.get(n).add(t)):(x(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#a.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new R(this,Object.freeze(e));this.#a.set(t.id,t),this.#o.get(t.target.id).add(t),this.#s.get(t.source.id).add(t);let n=t.boundary?.id??null;if(n)for(let e of[n,...k(n)])this.#c.get(e).add(t);for(let e of k(t.source.id)){if(e===n)break;this.#s.get(e).add(t)}for(let e of k(t.target.id)){if(e===n)break;this.#o.get(e).add(t)}return t}},U=class{model;$relationship;source;target;boundary;constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(C.flatten(t.source)),this.target=e.element(C.flatten(t.target));let n=A(this.source.id,this.target.id);this.boundary=n?this.model.element(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return r(this.$relationship.title)?null:this.$relationship.title}get technology(){return r(this.$relationship.technology)?(this.kind&&this.model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return M.memoize(this,`summary`,y(this.$relationship))}get description(){return M.memoize(this,`description`,g(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},W=class{source;target;Aux;$viewModel;$view;$edge;constructor(e,t,n,r){this.source=n,this.target=r,this.$viewModel=e,this.$view=e.$view,this.$edge=t}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.$viewModel.node(this.$edge.parent):null}get label(){return this.$edge.label??null}get description(){return M.memoize(this,`description`,this.$edge.description)}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?fe(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.$viewModel.$model.view(this.$edge.navigateTo):null}get color(){return this.$edge.color}get line(){return this.$edge.line??this.$viewModel.$styles.defaults.relationship.line}get head(){return this.$edge.head??this.$viewModel.$styles.defaults.relationship.arrow}get tail(){return this.$edge.tail}isStep(){return ge(this.id)}*relationships(e){for(let t of this.$edge.relations)if(e){let n=this.$viewModel.$model.findRelationship(t,e);n&&(yield n)}else yield this.$viewModel.$model.relationship(t)}includesRelation(e){let t=typeof e==`string`?e:e.id;return this.$edge.relations.includes(t)}isTagged(e){return this.tags.includes(e)}},G=class{Aux;$viewModel;$view;$node;constructor(e,t){this.$viewModel=e,this.$view=e.$view,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return M.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return M.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let e=this.$node.modelRef;return e?this.$viewModel.$model.element(e):null}get deployment(){let e=this.$node.deploymentRef;return e?this.$viewModel.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get icon(){return this.$node.icon??null}get tags(){return this.$node.tags}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$viewModel.$model.view(this.$node.navigateTo):null}get style(){return this.$node.style}get x(){return`x`in this.$node?this.$node.x:void 0}get y(){return`y`in this.$node?this.$node.y:void 0}get width(){return`width`in this.$node?this.$node.width:void 0}get height(){return`height`in this.$node?this.$node.height:void 0}children(){return v(this,`children`,()=>new Set(this.$node.children.map(e=>this.$viewModel.node(e))))}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*siblings(){let e=this.parent?.children()??this.$viewModel.roots();for(let t of e)t.id!==this.id&&(yield t)}*incoming(e=`all`){for(let t of this.$node.inEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.target.id===this.id:case e===`to-descendants`&&n.target.id!==this.id:yield n;break}}}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoing(e=`all`){for(let t of this.$node.outEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.source.id===this.id:case e===`from-descendants`&&n.source.id!==this.id:yield n;break}}}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}isLayouted(){return`width`in this.$node&&`height`in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return o(this.$node.modelRef)}hasDeployment(){return o(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return me(this.$node)}isTagged(e){return this.tags.includes(e)}},K=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new P.default(e=>new Set);#c;id;$model;title;folder;viewPath;constructor(e,t,n,r){this.$model=e,this.#e=n,this.id=n.id,this.folder=t,this.#c=r;for(let e of this.#e.nodes){let t=new G(this,Object.freeze(e));this.#n.set(e.id,t),e.parent||this.#t.add(t),e.deploymentRef&&this.#a.add(e.deploymentRef),e.modelRef&&this.#i.add(e.modelRef);for(let e of t.tags)this.#s.get(e).add(t)}for(let e of this.#e.edges){let t=new W(this,Object.freeze(e),this.node(e.source),this.node(e.target));for(let e of t.tags)this.#s.get(e).add(t);for(let t of e.relations)this.#o.add(t);this.#r.set(e.id,t)}this.title=n.title?Me(n.title):null,this.viewPath=n.title?H(n.title):n.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[N]}get stage(){return this.#e[w]}get bounds(){if(`bounds`in this.#e)return this.#e.bounds;if(this.#c)return this.#c.bounds;throw Error(`View is not layouted`)}get titleOrId(){return this.title??this.viewOf?.title??this.id}get titleOrUntitled(){return this.title??`Untitled`}get breadcrumbs(){return v(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return M.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let e=this.#e.viewOf;return e?this.$model.element(e):null}return null}get mode(){return this.isDynamicView()?this.#e.variant??`diagram`:null}get includedTags(){return[...this.#s.keys()]}get $view(){if(!this.isLayouted()||`drifts`in this.#e)return this.#e;let e=this.#c;return e?v(this,`withDriftReasons`,()=>De(this.#e,e)):this.#e}get $layouted(){if(!this.isLayouted())throw Error(`View is not layouted`);return this.$manual??this.#e}get hasManualLayout(){return this.#c!==void 0}get hasLayoutDrifts(){if(!this.isLayouted())return!1;let e=this.$manual;return!!e?.drifts&&e.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let e=this.#c;return e?this.#e._layout===`manual`?this.#e:v(this,`snapshotWithManualLayout`,()=>Ee(this.#e,e)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let e of this.#n.values())e.hasChildren()&&(yield e)}node(e){let t=B(e);return h(this.#n.get(t),`Node ${t} not found in view ${this.#e.id}`)}findNode(e){return this.#n.get(B(e))??null}findNodeWithElement(e){let t=B(e);return this.#i.has(t)?ae(this.#n.values(),e=>e.hasElement()&&e.element.id===t)??null:null}nodes(){return this.#n.values()}edge(e){let t=B(e);return h(this.#r.get(t),`Edge ${t} not found in view ${this.#e.id}`)}findEdge(e){return this.#r.get(B(e))??null}edges(){return this.#r.values()}*edgesWithRelation(e){for(let t of this.#r.values())t.includesRelation(e)&&(yield t)}*elements(){for(let e of this.#n.values())e.hasElement()&&(yield e)}isTagged(e){return this.tags.includes(e)}includesElement(e){return this.#i.has(B(e))}includesDeployment(e){return this.#a.has(B(e))}includesRelation(e){return this.#o.has(B(e))}isComputed(){return this.#e[w]===`computed`}isLayouted(){return this.#e[w]===`layouted`}isDiagram(){return this.#e[w]===`layouted`}isElementView(){return this.#e[N]===`element`}isScopedElementView(){return this.#e._type===`element`&&o(this.#e.viewOf)}isDeploymentView(){return this.#e[N]===`deployment`}isDynamicView(){return this.#e[N]===`dynamic`}},q=class e{$model;path;title;isRoot;parentPath;defaultViewId;constructor(e,t,r){this.$model=e,this.path=t.join(`/`),this.isRoot=this.path===``,this.title=n(t),this.isRoot?this.parentPath=void 0:this.parentPath=t.slice(0,-1).join(`/`),this.defaultViewId=r}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return x(!this.isRoot,`Root view folder has no breadcrumbs`),v(this,`breadcrumbs`,()=>{let e=this.parent;return e?e.isRoot?[e,this]:[...e.breadcrumbs,this]:[this]})}get parent(){return x(!this.isRoot,`Root view folder has no parent`),r(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return v(this,`folders`,()=>{let t=[];for(let n of this.children)n instanceof e&&t.push(n);return t})}get views(){return v(this,`views`,()=>{let e=[];for(let t of this.children)t instanceof K&&e.push(t);return e})}},J=class e{Aux;_elements=new Map;_parents=new Map;_children=new P.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new P.default(()=>new Set);_outgoing=new P.default(()=>new Set);_internal=new P.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new P.default(()=>new Set);_allTags=new P.default(()=>new Set);static fromParsed(t){return new e(t)}static create(t){return new e(t)}static fromDump(t){let{_stage:n=`layouted`,projectId:r=`unknown`,project:i,globals:a,imports:o,deployments:s,views:c,relations:l,elements:ee,specification:u}=t;return new e({[w]:n,projectId:r,project:i,globals:{predicates:a?.predicates??{},dynamicPredicates:a?.dynamicPredicates??{},styles:a?.styles??{}},imports:o??{},deployments:{elements:s?.elements??{},relations:s?.relations??{}},views:c??{},relations:l??{},elements:ee??{},specification:u})}deployment;$data;constructor(e){this.$data=e;for(let[,t]of l(e.elements)){let e=this.addElement(t);for(let t of e.tags)this._allTags.get(t).add(e)}for(let[t,n]of l(e.imports??{}))for(let e of ve(n)){let n=this.addImportedElement(t,e);for(let e of n.tags)this._allTags.get(e).add(n)}for(let t of p(e.relations)){let e=this.addRelation(t);for(let t of e.tags)this._allTags.get(t).add(e)}if(this.deployment=new Ne(this),Te(e,`computed`)||Te(e,`layouted`)){let t=de(`/`),n=u(p(e.views),c(e=>({view:e,path:H(e.title??e.id),folderPath:e.title&&je(e.title)||``})),f((e,n)=>t(e.folderPath,n.folderPath))),r=e=>{let t=this._viewFolders.get(e);if(!t){let r=ne(e,`/`);x(s(r,1),`View group path "${e}" must have at least one element`);let i;i=e===``?n.find(e=>e.view.id===`index`):n.find(t=>t.path===e),t=new q(this,r,i?.view.id),this._viewFolders.set(e,t)}return t};this._rootViewFolder=r(``);for(let{folderPath:e}of n)this._viewFolders.has(e)||ne(e,`/`).reduce((e,t)=>{let n=e.join(`/`),a=r(i(n)?t:n+`/`+t);return this._viewFolderItems.get(n).add(a),e.push(t),e},[]);for(let{view:t,folderPath:i}of n){let n=new K(this,r(i),t,e.manualLayouts?.[t.id]);this._viewFolderItems.get(i).add(n),this._views.set(t.id,n);for(let e of n.tags)this._allTags.get(e).add(n)}}else this._rootViewFolder=new q(this,[``],void 0),this._viewFolders.set(this._rootViewFolder.path,this._rootViewFolder)}get asParsed(){return this}get asComputed(){return this}get asLayouted(){return this}get $styles(){return v(this,`styles`,()=>ye.from(this.project.styles,this.specification.customColors))}isParsed(){return this.stage===`parsed`}isLayouted(){return this.stage===`layouted`}isComputed(){return this.stage===`computed`}get $model(){return this.$data}get stage(){return this.$data[w]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??v(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return v(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(e){if(e instanceof F)return e;let t=B(e);return h(this._elements.get(t),`Element ${t} not found`)}findElement(e){return this._elements.get(B(e))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(e,t){if(t===`deployment`)return this.deployment.relationship(e);let n=B(e),r=this._relations.get(n)??null;return r||t===`model`?h(r,`Model relation ${n} not found`):h(this.deployment.findRelationship(n),`No model/deployment relation ${n} not found`)}findRelationship(e,t){if(t===`deployment`)return this.deployment.findRelationship(e);let n=this._relations.get(B(e))??null;return n||t===`model`?n:this.deployment.findRelationship(e)}views(){return this._views.values()}view(e){let t=B(e);return h(this._views.get(t),`View ${t} not found`)}findView(e){return this._views.get(e)??null}findManualLayout(e){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[e]??null:null}viewFolder(e){return h(this._viewFolders.get(e),`View folder ${e} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(e){return x(this._viewFolders.has(e),`View folder ${e} not found`),this._viewFolderItems.get(e)}parent(e){let t=B(e);return this._parents.get(t)||null}children(e){let t=B(e);return this._children.get(t)}*siblings(e){let t=B(e),n=this._parents.get(t),r=n?this._children.get(n.id).values():this.roots();for(let e of r)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this._parents.get(t);)yield n,t=n.id}*descendants(e){for(let t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t=`all`){let n=B(e);for(let e of this._incoming.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this._outgoing.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}get tags(){return v(this,`tags`,()=>f([...this._allTags.keys()],_e))}get tagsSortedByUsage(){return v(this,`tagsSortedByUsage`,()=>u([...this._allTags.entries()],c(([e,t])=>({tag:e,count:t.size,tagged:t})),f((e,t)=>_e(e.tag,t.tag)),ee([te(`count`),`desc`])))}findByTag(e,t){return ue(this._allTags.get(e),e=>t===`elements`?e instanceof F:t===`views`?e instanceof K:t===`relationships`?e instanceof U:!0)}*elementsOfKind(e){for(let t of this._elements.values())t.kind===e&&(yield t)}*elementsWhere(e){let t=se(e);for(let e of this._elements.values())t(e)&&(yield e)}*relationshipsWhere(e){let t=se(e);for(let e of this._relations.values())t(e)&&(yield e)}addElement(e){if(this._elements.has(e.id))throw Error(`Element ${e.id} already exists`);let t=new F(this,Object.freeze(e));this._elements.set(t.id,t);let n=E(t.id);return n?(x(this._elements.has(n),`Parent ${n} of ${t.id} not found`),this._parents.set(t.id,this.element(n)),this._children.get(n).add(t)):this._rootElements.add(t),t}addImportedElement(e,t){x(!we(t.id),`Imported element already has global FQN`);let n=re(e,t.id);if(this._elements.has(n))throw Error(`Element ${n} already exists`);let r=new F(this,Object.freeze({...t,id:n}));this._elements.set(r.id,r);let i=E(r.id);for(;i;){if(i.includes(`.`)&&this._elements.has(i))return this._parents.set(r.id,this.element(i)),this._children.get(i).add(r),r;i=E(i)}return this._rootElements.add(r),r}addRelation(e){if(this._relations.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new U(this,Object.freeze(e)),{source:n,target:r}=t;this._relations.set(t.id,t),this._incoming.get(r.id).add(t),this._outgoing.get(n.id).add(t);let i=A(n.id,r.id);if(i)for(let e of[i,...k(i)])this._internal.get(e).add(t);for(let e of k(n.id)){if(e===i)break;this._outgoing.get(e).add(t)}for(let e of k(r.id)){if(e===i)break;this._incoming.get(e).add(t)}return t}};(function(e){e.EMPTY=J.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(J||={});let Pe;(function(e){e.isInside=e=>t=>T(e,t.source.id)&&T(e,t.target.id);let t=e.isDirectedBetween=(e,t)=>n=>(n.source.id===e||T(e,n.source.id))&&(n.target.id===t||T(t,n.target.id));e.isAnyBetween=(e,n)=>{let r=t(e,n),i=t(n,e);return e=>r(e)||i(e)};let n=e.isIncoming=e=>t=>(t.target.id===e||T(e,t.target.id))&&!T(e,t.source.id),r=e.isOutgoing=e=>t=>(t.source.id===e||T(e,t.source.id))&&!T(e,t.target.id);e.isAnyInOut=e=>{let t=n(e),i=r(e);return e=>t(e)||i(e)}})(Pe||={});const Y=Symbol.for(`nodejs.util.inspect.custom`);var Fe=class e{source;target;relations;id;constructor(e,t,n){this.source=e,this.target=t,this.relations=n,this.id=ce(`deployment:${e.id}:${t.id}`)}get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,"constructor",{value:e,enumerable:!1}),i}toString(){let e=[...this.relations.model].map(e=>` `+e.expression);e.length?e.unshift(` model:`):e.unshift(` model: []`);let t=[...this.relations.deployment].map(e=>` `+e.expression);return t.length?t.unshift(` deployment:`):t.unshift(` deployment: []`),[this.expression,...e,...t].join(`
3
+ `)}hasDirectDeploymentRelation(){for(let e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(t){return Array.isArray(t)?t.reduce((e,t)=>e.mergeWith(t),this):(x(this.source.id===t.source.id,`Cannot merge connections with different sources`),x(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,this.relations.union(t.relations)))}difference(t){return new e(this.source,this.target,this.relations.difference(t.relations))}intersect(t){return new e(this.source,this.target,this.relations.intersect(t.relations))}equals(t){return x(t instanceof e,`Other should ne DeploymentConnectionModel`),this.id===t.id&&this.source.id===t.source.id&&this.target.id===t.target.id&&b(this.relations.model,t.relations.model)&&b(this.relations.deployment,t.relations.deployment)}update(t){return t&&={model:this.relations.model,deployment:this.relations.deployment,...t},new e(this.source,this.target,t?new z(t.model??new Set,t.deployment??new Set):this.relations)}};function X(e,t){if(!t){let t=e;return e=>X(e,t)}let n=e.source===t.source,r=e.target===t.target;if(n&&r)return!1;let i=T(t.source.id,e.source.id),a=T(t.target.id,e.target.id);return i&&a||n&&a||r&&i}function Ie(e,t){let n=t;for(let t of e)X(t,n)&&(n=t);return n===t?null:n}function Le(e){let t=[],n=e.slice(),r;for(;r=n.shift();){let e;for(;e=Ie(n,r);){let r=n.indexOf(e);t.push(n.splice(r,1)[0])}t.push(r)}return t}function Re(e){return e.boundary?.id?`.${e.boundary.id}`:``}function ze(e,t){if(!e||he(e)){let t=e??`asc`;return e=>Be(e,t)}return Be(e,t??`asc`)}function Be(e,t){return u(e,c(e=>({id:Re(e),conn:e})),be(t),c(e=>e.conn))}function Ve(e,t){return e.filter(e=>X(t,e))}function He(e,t){return e.filter(X(t))}function Ue(e){let t=new Map;for(let n of e){let e=t.get(n.id);e?t.set(n.id,n.mergeWith(e)):t.set(n.id,n)}return[...t.values()]}function We(e,t){let n=new Map([...t].map(e=>[e.id,e]));return[...e].reduce((e,t)=>{let r=n.get(t.id);if(!r)return e.push(t),e;let i=t.difference(r);return i.nonEmpty()&&e.push(i),e},[])}function Z(e,t){return t?e.source===t.source&&e.target===t.target:t=>e.source===t.source&&e.target===t.target}function Ge(e,t){return t?e.source===t.source:t=>e.source===t.source}function Ke(e,t){return t?e.target===t.target:t=>e.target===t.target}function qe(e,t){if(!t){let t=e;return e=>qe(e,t)}let n=e;return O(n.source,t)&&!O(n.target,t)}function Je(e,t){if(!t){let t=e;return e=>Je(e,t)}let n=e;return O(n.target,t)&&!O(n.source,t)}function Ye(e,t){if(!t){let t=e;return e=>Ye(e,t)}let n=e;return O(n.source,t)!==O(n.target,t)}var Q=class e{source;target;relations;id;constructor(e,t,n=new Set){this.source=e,this.target=t,this.relations=n,this.id=ce(`model:${e.id}:${t.id}`)}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&le(this.relations,a(Z(this)))}get directRelations(){return new Set(ue(this.relations,Z(this)))}nonEmpty(){return this.relations.size>0}mergeWith(t){return x(this.source.id===t.source.id,`Cannot merge connections with different sources`),x(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,oe(this.relations,t.relations))}difference(t){return new e(this.source,this.target,_(this.relations,t.relations))}intersect(t){return x(t instanceof e,`Cannot intersect connection with different type`),new e(this.source,this.target,m(this.relations,t.relations))}equals(t){x(t instanceof e,`Cannot merge connection with different type`);let n=t;return this.id===n.id&&this.source.id===n.source.id&&this.target.id===n.target.id&&b(this.relations,n.relations)}update(t){return new e(this.source,this.target,t)}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,"constructor",{value:e,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?` relations:`:` relations: [ ]`,...[...this.relations].map(e=>` `+e.expression)].join(`
4
+ `)}reversed(){return new e(this.target,this.source)}},Xe=e({findConnection:()=>$,findConnectionsBetween:()=>Ze,findConnectionsWithin:()=>Qe});function $(e,t,n=`directed`){if(e===t||Ce(e,t))return[];let r=e.allOutgoing.intersect(t.allIncoming),i=r.nonEmpty?[new Fe(e,t,r)]:[];return n===`directed`?i:[...i,...$(t,e,`directed`)]}function Ze(e,t,n=`both`){if(e.allIncoming.isEmpty&&e.allOutgoing.isEmpty)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of $(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function Qe(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...Ze(t,r.slice(n+1),`both`)),e),[])}var $e=e({findConnection:()=>et,findConnectionsBetween:()=>tt,findConnectionsWithin:()=>nt});function et(e,t,n=`directed`){if(e===t||Ce(e,t))return[];let r=m(e.allOutgoing,t.allIncoming),i=r.size>0?new Q(e,t,r):null;if(n===`directed`)return i?[i]:[];let a=m(e.allIncoming,t.allOutgoing),o=a.size>0?new Q(t,e,a):null;return i&&o?[i,o]:i?[i]:o?[o]:[]}function tt(e,t,n=`both`){if(e.allIncoming.size===0&&e.allOutgoing.size===0)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of et(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function nt(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...tt(t,r.slice(n+1),`both`)),e),[])}function rt(e){return e instanceof I}function it(e){return e instanceof L}function at(e){return rt(e)||it(e)}function ot(e){return e instanceof ke}function st(e){return e instanceof R}function ct(e){return e instanceof U}function lt(e){return e instanceof F}function ut(e){return e instanceof K}function dt(e){return e instanceof G}function ft(e){return e instanceof W}export{Fe as A,Ae as B,Ye as C,Ue as D,qe as E,K as F,I as G,je as H,G as I,F as J,R as K,W as L,Pe as M,J as N,ze as O,q as P,U as R,Ke as S,X as T,H as U,Me as V,L as W,Ve as _,ft as a,Ge as b,ot as c,et as d,tt as f,We as g,Q as h,st as i,Y as j,Le as k,dt as l,Xe as m,at as n,lt as o,$e as p,z as q,rt as r,ut as s,it as t,ct as u,Ie as v,Je as w,Z as x,He as y,Ne as z};