@likec4/core 1.58.0 → 1.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder/index.d.mts +2 -2
- package/dist/builder/index.mjs +2 -1
- package/dist/chunks/Builder.view-element.mjs +2 -0
- package/dist/{_chunks → chunks}/LikeC4Model.d.mts +24 -26
- package/dist/{_chunks → chunks}/_types.d.mts +302 -57
- package/dist/{_chunks → chunks}/_types2.d.mts +2 -2
- package/dist/chunks/assignTagColors.mjs +1 -0
- package/dist/chunks/calcDriftsFromSnapshot.mjs +1 -0
- package/dist/chunks/default-map.d.mts +29 -0
- package/dist/{_chunks → chunks}/index.d.mts +933 -194
- package/dist/{_chunks → chunks}/index2.d.mts +21 -19
- package/dist/{_chunks → chunks}/index3.d.mts +2 -2
- package/dist/{_chunks/index5.d.mts → chunks/index4.d.mts} +153 -4
- package/dist/{_chunks/index4.d.mts → chunks/index5.d.mts} +2 -2
- package/dist/chunks/libs/chroma-js.mjs +15 -0
- package/dist/chunks/libs/graphology-dag.mjs +1 -0
- package/dist/chunks/libs/graphology.mjs +1 -0
- package/dist/chunks/libs/hast-util-sanitize.mjs +1 -0
- package/dist/chunks/libs/hast-util-to-html.mjs +9 -0
- package/dist/chunks/libs/mdast.mjs +29 -0
- package/dist/chunks/libs/mnemonist.mjs +1 -0
- package/dist/chunks/libs/ohash.mjs +1 -0
- package/dist/chunks/libs/remark.mjs +3 -0
- package/dist/chunks/libs/remeda.mjs +1 -0
- package/dist/chunks/libs/unified.mjs +1 -0
- package/dist/chunks/model.mjs +4 -0
- package/dist/chunks/rolldown-runtime.mjs +1 -0
- package/dist/chunks/types.mjs +9 -0
- package/dist/compute-view/index.d.mts +56 -18
- package/dist/compute-view/index.mjs +2 -2
- package/dist/geometry/index.d.mts +2 -2
- package/dist/geometry/index.mjs +1 -1
- package/dist/index.d.mts +10 -10
- package/dist/index.mjs +1 -1
- package/dist/model/index.d.mts +3 -3
- package/dist/model/index.mjs +1 -1
- package/dist/styles/index.d.mts +3 -3
- package/dist/styles/index.mjs +1 -1
- package/dist/types/index.d.mts +3 -3
- package/dist/types/index.mjs +1 -1
- package/dist/utils/graphology/index.d.mts +618 -1
- package/dist/utils/graphology/index.mjs +1 -1
- package/dist/utils/index.d.mts +4 -4
- package/dist/utils/index.mjs +1 -1
- package/package.json +13 -14
- package/dist/THIRD-PARTY-LICENSES.md +0 -1034
- package/dist/_chunks/Builder.view-element.mjs +0 -2
- package/dist/_chunks/assignTagColors.mjs +0 -1
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +0 -1
- package/dist/_chunks/libs/bail.mjs +0 -1
- package/dist/_chunks/libs/ccount.mjs +0 -1
- package/dist/_chunks/libs/character-entities-html4.mjs +0 -1
- package/dist/_chunks/libs/character-entities-legacy.mjs +0 -1
- package/dist/_chunks/libs/character-entities.mjs +0 -2
- package/dist/_chunks/libs/chroma-js.mjs +0 -15
- package/dist/_chunks/libs/comma-separated-tokens.mjs +0 -1
- package/dist/_chunks/libs/decode-named-character-reference.mjs +0 -1
- package/dist/_chunks/libs/defu.mjs +0 -1
- package/dist/_chunks/libs/devlop.mjs +0 -1
- package/dist/_chunks/libs/escape-string-regexp.mjs +0 -1
- package/dist/_chunks/libs/extend.mjs +0 -1
- package/dist/_chunks/libs/graphology-dag.d.mts +0 -607
- package/dist/_chunks/libs/graphology-dag.mjs +0 -1
- package/dist/_chunks/libs/graphology.mjs +0 -1
- package/dist/_chunks/libs/hast-util-sanitize.mjs +0 -1
- package/dist/_chunks/libs/hast-util-to-html.mjs +0 -9
- package/dist/_chunks/libs/is-plain-obj.mjs +0 -1
- package/dist/_chunks/libs/longest-streak.mjs +0 -1
- package/dist/_chunks/libs/markdown-table.mjs +0 -2
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +0 -1
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +0 -3
- package/dist/_chunks/libs/mdast-util-gfm.mjs +0 -15
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +0 -11
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +0 -1
- package/dist/_chunks/libs/mnemonist.d.mts +0 -164
- package/dist/_chunks/libs/mnemonist.mjs +0 -1
- package/dist/_chunks/libs/natural-compare-lite.mjs +0 -9
- package/dist/_chunks/libs/ohash.mjs +0 -1
- package/dist/_chunks/libs/rehype-sanitize.mjs +0 -1
- package/dist/_chunks/libs/rehype-stringify.mjs +0 -1
- package/dist/_chunks/libs/remark-gfm.mjs +0 -1
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +0 -3
- package/dist/_chunks/libs/remark-parse.mjs +0 -1
- package/dist/_chunks/libs/remark-rehype.mjs +0 -1
- package/dist/_chunks/libs/remeda.mjs +0 -2
- package/dist/_chunks/libs/trough.mjs +0 -1
- package/dist/_chunks/libs/unified.mjs +0 -1
- package/dist/_chunks/manual-layout.mjs +0 -1
- package/dist/_chunks/mnemonist.d.mts +0 -1
- package/dist/_chunks/model.mjs +0 -4
- package/dist/_chunks/rolldown-runtime.mjs +0 -1
- package/dist/_chunks/types.mjs +0 -1
- /package/dist/{_chunks → chunks}/libs/@radix-ui/colors.mjs +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { r as __name } from "./rolldown-runtime.mjs";
|
|
1
2
|
//#region src/geometry/types.d.ts
|
|
2
3
|
interface XYPoint {
|
|
3
4
|
x: number;
|
|
@@ -35,26 +36,32 @@ interface BBox {
|
|
|
35
36
|
height: number;
|
|
36
37
|
}
|
|
37
38
|
declare const BBox: {
|
|
38
|
-
center({
|
|
39
|
-
x,
|
|
40
|
-
y,
|
|
41
|
-
width,
|
|
42
|
-
height
|
|
43
|
-
}: BBox): XYPoint;
|
|
39
|
+
center({ x, y, width, height }: BBox): XYPoint;
|
|
44
40
|
/**
|
|
45
41
|
* Returns the four corner points of the box in clockwise order starting from top-left
|
|
46
42
|
*/
|
|
47
|
-
toPoints({
|
|
48
|
-
x,
|
|
49
|
-
y,
|
|
50
|
-
width,
|
|
51
|
-
height
|
|
52
|
-
}: BBox): [XYPoint, XYPoint, XYPoint, XYPoint];
|
|
43
|
+
toPoints({ x, y, width, height }: BBox): [XYPoint, XYPoint, XYPoint, XYPoint];
|
|
53
44
|
fromPoints(points: Point[]): BBox;
|
|
54
45
|
merge(...boxes: BBox[]): BBox;
|
|
55
46
|
fromRectBox(rect: RectBox): BBox;
|
|
56
47
|
toRectBox(box: BBox): RectBox;
|
|
57
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Expands the box by the given amount in all directions, or separately for each direction
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* BBox.expand({ x: 0, y: 0, width: 10, height: 10 }, 5)
|
|
53
|
+
* // => { x: -5, y: -5, width: 20, height: 20 }
|
|
54
|
+
*
|
|
55
|
+
* BBox.expand({ x: 0, y: 0, width: 10, height: 10 }, { left: 5, right: 5, top: 5, bottom: 5 })
|
|
56
|
+
* // => { x: -5, y: -5, width: 20, height: 20 }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
expand(box: BBox, plus: number | {
|
|
60
|
+
left?: number;
|
|
61
|
+
right?: number;
|
|
62
|
+
top?: number;
|
|
63
|
+
bottom?: number;
|
|
64
|
+
}): BBox;
|
|
58
65
|
shrink(box: BBox, minus: number): BBox;
|
|
59
66
|
/**
|
|
60
67
|
* Returns true if `a` includes `b` (i.e. `b` is inside `a`)
|
|
@@ -68,12 +75,7 @@ interface RectBox {
|
|
|
68
75
|
y2: number;
|
|
69
76
|
}
|
|
70
77
|
declare const RectBox: {
|
|
71
|
-
center({
|
|
72
|
-
x1,
|
|
73
|
-
y1,
|
|
74
|
-
x2,
|
|
75
|
-
y2
|
|
76
|
-
}: RectBox): XYPoint;
|
|
78
|
+
center({ x1, y1, x2, y2 }: RectBox): XYPoint;
|
|
77
79
|
fromPoints(points: Point[]): RectBox;
|
|
78
80
|
merge(...boxes: RectBox[]): RectBox;
|
|
79
81
|
toBBox(box: RectBox): BBox;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as __name } from "./rolldown-runtime.mjs";
|
|
2
|
+
import { Br as DefaultTagColors, Cr as LikeC4StyleDefaults, Dt as LikeC4ProjectStylesConfig, Fr as ThemeColor, Ir as ThemeColorValues, Ji as Tag, Nr as SpacingSize, Nt as TagSpecification, Or as RelationshipColorValues, Ot as LikeC4ProjectStylesCustomStylesheets, Pr as TextSize, Sr as IconSize, Tr as LikeC4Theme, _r as CustomColorDefinitions, br as HexColor, et as ComputedNodeStyle, hr as ColorLiteral, jr as ShapeSize, mr as Color, pr as BorderStyle, va as NTuple, vr as ElementColorValues, wr as LikeC4StylesConfig, xr as IconPosition } from "./index.mjs";
|
|
2
3
|
import { LiteralUnion } from "type-fest";
|
|
3
4
|
import chroma from "chroma-js";
|
|
4
|
-
|
|
5
5
|
//#region src/styles/assignTagColors.d.ts
|
|
6
6
|
declare function assignTagColors(tags: {
|
|
7
7
|
[kind: string]: Partial<TagSpecification>;
|
|
@@ -1,6 +1,155 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
|
|
1
|
+
import { r as __name } from "./rolldown-runtime.mjs";
|
|
2
|
+
import { Ca as ReorderedArray, Pi as Fqn, ha as IteratorLike, ma as IterableContainer, ya as NonEmptyArray } from "./index.mjs";
|
|
3
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/default-weak-map.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Mnemonist DefaultWeakMap Typings
|
|
6
|
+
* ================================
|
|
7
|
+
*/
|
|
8
|
+
declare class DefaultWeakMap<K extends object, V> {
|
|
9
|
+
// Constructor
|
|
10
|
+
constructor(factory: (key: K) => V);
|
|
11
|
+
// Methods
|
|
12
|
+
clear(): void;
|
|
13
|
+
set(key: K, value: V): this;
|
|
14
|
+
delete(key: K): boolean;
|
|
15
|
+
has(key: K): boolean;
|
|
16
|
+
get(key: K): V;
|
|
17
|
+
peek(key: K): V | undefined;
|
|
18
|
+
inspect(): any;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/linked-list.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* Mnemonist LinkedList Typings
|
|
24
|
+
* =============================
|
|
25
|
+
*/
|
|
26
|
+
declare class LinkedList<T> implements Iterable<T> {
|
|
27
|
+
// Members
|
|
28
|
+
size: number;
|
|
29
|
+
// Constructor
|
|
30
|
+
constructor();
|
|
31
|
+
// Methods
|
|
32
|
+
clear(): void;
|
|
33
|
+
first(): T | undefined;
|
|
34
|
+
last(): T | undefined;
|
|
35
|
+
peek(): T | undefined;
|
|
36
|
+
push(value: T): number;
|
|
37
|
+
shift(): T | undefined;
|
|
38
|
+
unshift(value: T): number;
|
|
39
|
+
forEach(callback: (value: T, index: number, list: this) => void, scope?: any): void;
|
|
40
|
+
toArray(): Array<T>;
|
|
41
|
+
values(): IterableIterator<T>;
|
|
42
|
+
entries(): IterableIterator<[number, T]>;
|
|
43
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
44
|
+
toString(): string;
|
|
45
|
+
toJSON(): Array<T>;
|
|
46
|
+
inspect(): any;
|
|
47
|
+
// Statics
|
|
48
|
+
static from<I>(iterable: Iterable<I> | {
|
|
49
|
+
[key: string]: I;
|
|
50
|
+
}): LinkedList<I>;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/multi-map.d.ts
|
|
54
|
+
/**
|
|
55
|
+
* Mnemonist MultiMap Typings
|
|
56
|
+
* ===========================
|
|
57
|
+
*/
|
|
58
|
+
interface MultiMap<K, V, C extends V[] | Set<V> = V[]> extends Iterable<[K, V]> {
|
|
59
|
+
// Members
|
|
60
|
+
dimension: number;
|
|
61
|
+
size: number;
|
|
62
|
+
// Methods
|
|
63
|
+
clear(): void;
|
|
64
|
+
set(key: K, value: V): this;
|
|
65
|
+
delete(key: K): boolean;
|
|
66
|
+
remove(key: K, value: V): boolean;
|
|
67
|
+
has(key: K): boolean;
|
|
68
|
+
get(key: K): C | undefined;
|
|
69
|
+
multiplicity(key: K): number;
|
|
70
|
+
forEach(callback: (value: V, key: K, map: this) => void, scope?: any): void;
|
|
71
|
+
forEachAssociation(callback: (value: C, key: K, map: this) => void, scope?: any): void;
|
|
72
|
+
keys(): IterableIterator<K>;
|
|
73
|
+
values(): IterableIterator<V>;
|
|
74
|
+
entries(): IterableIterator<[K, V]>;
|
|
75
|
+
containers(): IterableIterator<C>;
|
|
76
|
+
associations(): IterableIterator<[K, C]>;
|
|
77
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
78
|
+
inspect(): any;
|
|
79
|
+
toJSON(): any;
|
|
80
|
+
}
|
|
81
|
+
interface MultiMapConstructor {
|
|
82
|
+
new <K, V>(container: SetConstructor): MultiMap<K, V, Set<V>>;
|
|
83
|
+
new <K, V>(container?: ArrayConstructor): MultiMap<K, V, V[]>;
|
|
84
|
+
from<K, V>(iterable: Iterable<[K, V]> | {
|
|
85
|
+
[key: string]: V;
|
|
86
|
+
}, Container: SetConstructor): MultiMap<K, V, Set<V>>;
|
|
87
|
+
from<K, V>(iterable: Iterable<[K, V]> | {
|
|
88
|
+
[key: string]: V;
|
|
89
|
+
}, Container?: ArrayConstructor): MultiMap<K, V, V[]>;
|
|
90
|
+
}
|
|
91
|
+
declare const MultiMap: MultiMapConstructor;
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/queue.d.ts
|
|
94
|
+
/**
|
|
95
|
+
* Mnemonist Queue Typings
|
|
96
|
+
* ========================
|
|
97
|
+
*/
|
|
98
|
+
declare class Queue<T> implements Iterable<T> {
|
|
99
|
+
// Members
|
|
100
|
+
size: number;
|
|
101
|
+
// Constructor
|
|
102
|
+
constructor();
|
|
103
|
+
// Methods
|
|
104
|
+
clear(): void;
|
|
105
|
+
enqueue(item: T): number;
|
|
106
|
+
dequeue(): T | undefined;
|
|
107
|
+
peek(): T | undefined;
|
|
108
|
+
forEach(callback: (item: T, index: number, queue: this) => void, scope?: any): void;
|
|
109
|
+
toArray(): Array<T>;
|
|
110
|
+
values(): IterableIterator<T>;
|
|
111
|
+
entries(): IterableIterator<[number, T]>;
|
|
112
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
113
|
+
toString(): string;
|
|
114
|
+
toJSON(): Array<T>;
|
|
115
|
+
inspect(): any;
|
|
116
|
+
// Statics
|
|
117
|
+
static from<I>(iterable: Iterable<I> | {
|
|
118
|
+
[key: string]: I;
|
|
119
|
+
}): Queue<I>;
|
|
120
|
+
static of<I>(...items: Array<I>): Queue<I>;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/stack.d.ts
|
|
124
|
+
/**
|
|
125
|
+
* Mnemonist Stack Typings
|
|
126
|
+
* ========================
|
|
127
|
+
*/
|
|
128
|
+
declare class Stack<T> implements Iterable<T> {
|
|
129
|
+
// Members
|
|
130
|
+
size: number;
|
|
131
|
+
// Constructor
|
|
132
|
+
constructor();
|
|
133
|
+
// Methods
|
|
134
|
+
clear(): void;
|
|
135
|
+
push(item: T): number;
|
|
136
|
+
pop(): T | undefined;
|
|
137
|
+
peek(): T | undefined;
|
|
138
|
+
forEach(callback: (item: T, index: number, stack: this) => void, scope?: any): void;
|
|
139
|
+
toArray(): Array<T>;
|
|
140
|
+
values(): IterableIterator<T>;
|
|
141
|
+
entries(): IterableIterator<[number, T]>;
|
|
142
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
143
|
+
toString(): string;
|
|
144
|
+
toJSON(): Array<T>;
|
|
145
|
+
inspect(): any;
|
|
146
|
+
// Statics
|
|
147
|
+
static from<I>(iterable: Iterable<I> | {
|
|
148
|
+
[key: string]: I;
|
|
149
|
+
}): Stack<I>;
|
|
150
|
+
static of<I>(...items: Array<I>): Stack<I>;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
4
153
|
//#region src/utils/invariant.d.ts
|
|
5
154
|
declare function nonNullable<T>(value: T, message?: string | (() => string)): NonNullable<T>;
|
|
6
155
|
declare function invariant(condition: any, message?: string): asserts condition;
|
|
@@ -412,4 +561,4 @@ declare function markdownToText(markdown: string): string;
|
|
|
412
561
|
*/
|
|
413
562
|
declare function unsafePartial<T>(value: Partial<NoInfer<T>>): T;
|
|
414
563
|
//#endregion
|
|
415
|
-
export { ancestorsFqn as A, parentFqn as B, iflatMap as C, ifilter as D, ifind as E, hierarchyLevel as F, compareNaturalHierarchically as G, sortNaturalByFqn as H, isAncestor as I, invariant as J, sortNatural as K, isDescendantOf as L, compareByFqnHierarchically as M, compareFqnHierarchically as N, isIterable as O, hierarchyDistance as P, isSameHierarchy as R, ihead as S, ifirst as T, sortParentsFirst as U, sortByFqnHierarchically as V, compareNatural as W, nonexhaustive as X, nonNullable as Y, toArray as _, objectHash as a, ireduce as b, intersection as c, compareRelations as d, delay as f, iunique as g, memoizeProp as h, stringHash as i, commonAncestor as j, getOrCreate as k, symmetricDifference as l, promiseNextTick as m, markdownToText as n, difference as o, onNextTick as p, commonHead as q, markdownToHtml as r, equals as s, unsafePartial as t, union as u, toSet as v, iflat as w, imap as x, isome as y, nameFromFqn as z };
|
|
564
|
+
export { MultiMap as $, ancestorsFqn as A, parentFqn as B, iflatMap as C, ifilter as D, ifind as E, hierarchyLevel as F, compareNaturalHierarchically as G, sortNaturalByFqn as H, isAncestor as I, invariant as J, sortNatural as K, isDescendantOf as L, compareByFqnHierarchically as M, compareFqnHierarchically as N, isIterable as O, hierarchyDistance as P, Queue as Q, isSameHierarchy as R, ihead as S, ifirst as T, sortParentsFirst as U, sortByFqnHierarchically as V, compareNatural as W, nonexhaustive as X, nonNullable as Y, Stack as Z, toArray as _, objectHash as a, ireduce as b, intersection as c, compareRelations as d, LinkedList as et, delay as f, iunique as g, memoizeProp as h, stringHash as i, commonAncestor as j, getOrCreate as k, symmetricDifference as l, promiseNextTick as m, markdownToText as n, difference as o, onNextTick as p, commonHead as q, markdownToHtml as r, equals as s, unsafePartial as t, DefaultWeakMap as tt, union as u, toSet as v, iflat as w, imap as x, isome as y, nameFromFqn as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __exportAll, r as __name } from "./rolldown-runtime.mjs";
|
|
2
|
+
import { $r as EdgeId, Ca as ReorderedArray, Gr as Any, Pi as Fqn, ha as IteratorLike, ma as IterableContainer, vi as Unknown } from "./index.mjs";
|
|
2
3
|
import { C as ElementModel, S as NodeModel, T as RelationshipModel, a as DeploymentNodeModel, c as NestedElementOfDeployedInstanceModel, i as DeploymentElementModel, l as RelationshipsAccum, r as DeployedInstanceModel, s as DeploymentRelationModel, w as AnyRelationshipModel, x as EdgeModel, y as LikeC4ViewModel } from "./LikeC4Model.mjs";
|
|
3
|
-
|
|
4
4
|
//#region src/model/connection/Connection.d.ts
|
|
5
5
|
interface Connection<Elem = ElementModel<Any> | DeploymentElementModel<Any>, Id = string> {
|
|
6
6
|
readonly id: Id;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{r as e}from"../rolldown-runtime.mjs";const{min:t,max:n}=Math;var r=e((e,r=0,i=1)=>t(n(r,e),i),`default`),i=e(e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=r(e[t],0,255)):t===3&&(e[t]=r(e[t],0,1));return e},`default`);const a={};for(let e of[`Boolean`,`Number`,`String`,`Function`,`Array`,`Date`,`RegExp`,`Undefined`,`Null`])a[`[object ${e}]`]=e.toLowerCase();function type_default(e){return a[Object.prototype.toString.call(e)]||`object`}e(type_default,`default`);var o=e((e,t=null)=>e.length>=3?Array.prototype.slice.call(e):type_default(e[0])==`object`&&t?t.split(``).filter(t=>e[0][t]!==void 0).map(t=>e[0][t]):e[0].slice(0),`default`),s=e(e=>{if(e.length<2)return null;let t=e.length-1;return type_default(e[t])==`string`?e[t].toLowerCase():null},`default`);const{PI:c,min:l,max:u}=Math,rnd2=e=>Math.round(e*100)/100,rnd3=e=>Math.round(e*100)/100,d=c*2,p=c/3,m=c/180,h=180/c;function reverse3(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var g={format:{},autodetect:[]},Color=class{constructor(...e){let t=this;if(type_default(e[0])===`object`&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];let n=s(e),r=!1;if(!n){r=!0,g.sorted||=(g.autodetect=g.autodetect.sort((e,t)=>t.p-e.p),!0);for(let t of g.autodetect)if(n=t.test(...e),n)break}if(g.format[n])t._rgb=i(g.format[n].apply(null,r?e:e.slice(0,-1)));else throw Error(`unknown format: `+e);t._rgb.length===3&&t._rgb.push(1)}toString(){return type_default(this.hex)==`function`?this.hex():`[${this._rgb.join(`,`)}]`}};const chroma=(...e)=>new Color(...e);chroma.version=`3.2.0`;const _={aliceblue:`#f0f8ff`,antiquewhite:`#faebd7`,aqua:`#00ffff`,aquamarine:`#7fffd4`,azure:`#f0ffff`,beige:`#f5f5dc`,bisque:`#ffe4c4`,black:`#000000`,blanchedalmond:`#ffebcd`,blue:`#0000ff`,blueviolet:`#8a2be2`,brown:`#a52a2a`,burlywood:`#deb887`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,cornflowerblue:`#6495ed`,cornsilk:`#fff8dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,darkkhaki:`#bdb76b`,darkmagenta:`#8b008b`,darkolivegreen:`#556b2f`,darkorange:`#ff8c00`,darkorchid:`#9932cc`,darkred:`#8b0000`,darksalmon:`#e9967a`,darkseagreen:`#8fbc8f`,darkslateblue:`#483d8b`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,darkturquoise:`#00ced1`,darkviolet:`#9400d3`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1e90ff`,firebrick:`#b22222`,floralwhite:`#fffaf0`,forestgreen:`#228b22`,fuchsia:`#ff00ff`,gainsboro:`#dcdcdc`,ghostwhite:`#f8f8ff`,gold:`#ffd700`,goldenrod:`#daa520`,gray:`#808080`,green:`#008000`,greenyellow:`#adff2f`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,indianred:`#cd5c5c`,indigo:`#4b0082`,ivory:`#fffff0`,khaki:`#f0e68c`,laserlemon:`#ffff54`,lavender:`#e6e6fa`,lavenderblush:`#fff0f5`,lawngreen:`#7cfc00`,lemonchiffon:`#fffacd`,lightblue:`#add8e6`,lightcoral:`#f08080`,lightcyan:`#e0ffff`,lightgoldenrod:`#fafad2`,lightgoldenrodyellow:`#fafad2`,lightgray:`#d3d3d3`,lightgreen:`#90ee90`,lightgrey:`#d3d3d3`,lightpink:`#ffb6c1`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,lightskyblue:`#87cefa`,lightslategray:`#778899`,lightslategrey:`#778899`,lightsteelblue:`#b0c4de`,lightyellow:`#ffffe0`,lime:`#00ff00`,limegreen:`#32cd32`,linen:`#faf0e6`,magenta:`#ff00ff`,maroon:`#800000`,maroon2:`#7f0000`,maroon3:`#b03060`,mediumaquamarine:`#66cdaa`,mediumblue:`#0000cd`,mediumorchid:`#ba55d3`,mediumpurple:`#9370db`,mediumseagreen:`#3cb371`,mediumslateblue:`#7b68ee`,mediumspringgreen:`#00fa9a`,mediumturquoise:`#48d1cc`,mediumvioletred:`#c71585`,midnightblue:`#191970`,mintcream:`#f5fffa`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,navajowhite:`#ffdead`,navy:`#000080`,oldlace:`#fdf5e6`,olive:`#808000`,olivedrab:`#6b8e23`,orange:`#ffa500`,orangered:`#ff4500`,orchid:`#da70d6`,palegoldenrod:`#eee8aa`,palegreen:`#98fb98`,paleturquoise:`#afeeee`,palevioletred:`#db7093`,papayawhip:`#ffefd5`,peachpuff:`#ffdab9`,peru:`#cd853f`,pink:`#ffc0cb`,plum:`#dda0dd`,powderblue:`#b0e0e6`,purple:`#800080`,purple2:`#7f007f`,purple3:`#a020f0`,rebeccapurple:`#663399`,red:`#ff0000`,rosybrown:`#bc8f8f`,royalblue:`#4169e1`,saddlebrown:`#8b4513`,salmon:`#fa8072`,sandybrown:`#f4a460`,seagreen:`#2e8b57`,seashell:`#fff5ee`,sienna:`#a0522d`,silver:`#c0c0c0`,skyblue:`#87ceeb`,slateblue:`#6a5acd`,slategray:`#708090`,slategrey:`#708090`,snow:`#fffafa`,springgreen:`#00ff7f`,steelblue:`#4682b4`,tan:`#d2b48c`,teal:`#008080`,thistle:`#d8bfd8`,tomato:`#ff6347`,turquoise:`#40e0d0`,violet:`#ee82ee`,wheat:`#f5deb3`,white:`#ffffff`,whitesmoke:`#f5f5f5`,yellow:`#ffff00`,yellowgreen:`#9acd32`},v=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,y=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,hex2rgb=e=>{if(e.match(v)){(e.length===4||e.length===7)&&(e=e.substr(1)),e.length===3&&(e=e.split(``),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);let t=parseInt(e,16);return[t>>16,t>>8&255,t&255,1]}if(e.match(y)){(e.length===5||e.length===9)&&(e=e.substr(1)),e.length===4&&(e=e.split(``),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);let t=parseInt(e,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((t&255)/255*100)/100]}throw Error(`unknown hex color: ${e}`)},{round:b}=Math,rgb2hex=(...e)=>{let[t,n,r,i]=o(e,`rgba`),a=s(e)||`auto`;i===void 0&&(i=1),a===`auto`&&(a=i<1?`rgba`:`rgb`),t=b(t),n=b(n),r=b(r);let c=`000000`+(t<<16|n<<8|r).toString(16);c=c.substr(c.length-6);let l=`0`+b(i*255).toString(16);switch(l=l.substr(l.length-2),a.toLowerCase()){case`rgba`:return`#${c}${l}`;case`argb`:return`#${l}${c}`;default:return`#${c}`}};Color.prototype.name=function(){let e=rgb2hex(this._rgb,`rgb`);for(let t of Object.keys(_))if(_[t]===e)return t.toLowerCase();return e},g.format.named=e=>{if(e=e.toLowerCase(),_[e])return hex2rgb(_[e]);throw Error(`unknown color name: `+e)},g.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&type_default(e)===`string`&&_[e.toLowerCase()])return`named`}}),Color.prototype.alpha=function(e,t=!1){return e!==void 0&&type_default(e)===`number`?t?(this._rgb[3]=e,this):new Color([this._rgb[0],this._rgb[1],this._rgb[2],e],`rgb`):this._rgb[3]},Color.prototype.clipped=function(){return this._rgb._clipped||!1};const x={Kn:18,labWhitePoint:`d65`,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},S=new Map([[`a`,[1.0985,.35585]],[`b`,[1.0985,.35585]],[`c`,[.98074,1.18232]],[`d50`,[.96422,.82521]],[`d55`,[.95682,.92149]],[`d65`,[.95047,1.08883]],[`e`,[1,1,1]],[`f2`,[.99186,.67393]],[`f7`,[.95041,1.08747]],[`f11`,[1.00962,.6435]],[`icc`,[.96422,.82521]]]);function setLabWhitePoint(e){let t=S.get(String(e).toLowerCase());if(!t)throw Error(`unknown Lab illuminant `+e);x.labWhitePoint=e,x.Xn=t[0],x.Zn=t[1]}function getLabWhitePoint(){return x.labWhitePoint}const lab2rgb=(...e)=>{e=o(e,`lab`);let[t,n,r]=e,[i,a,s]=lab2xyz(t,n,r),[c,l,u]=xyz2rgb(i,a,s);return[c,l,u,e.length>3?e[3]:1]},lab2xyz=(e,t,n)=>{let{kE:r,kK:i,kKE:a,Xn:o,Yn:s,Zn:c}=x,l=(e+16)/116,u=.002*t+l,d=l-.005*n,p=u*u*u,m=d*d*d,h=p>r?p:(116*u-16)/i,g=e>a?((e+16)/116)**3:e/i,_=m>r?m:(116*d-16)/i;return[h*o,g*s,_*c]},compand=e=>{let t=Math.sign(e);return e=Math.abs(e),(e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055)*t},xyz2rgb=(e,t,n)=>{let{MtxAdaptMa:r,MtxAdaptMaI:i,MtxXYZ2RGB:a,RefWhiteRGB:o,Xn:s,Yn:c,Zn:l}=x,u=s*r.m00+c*r.m10+l*r.m20,d=s*r.m01+c*r.m11+l*r.m21,p=s*r.m02+c*r.m12+l*r.m22,m=o.X*r.m00+o.Y*r.m10+o.Z*r.m20,h=o.X*r.m01+o.Y*r.m11+o.Z*r.m21,g=o.X*r.m02+o.Y*r.m12+o.Z*r.m22,_=(e*r.m00+t*r.m10+n*r.m20)*(m/u),v=(e*r.m01+t*r.m11+n*r.m21)*(h/d),y=(e*r.m02+t*r.m12+n*r.m22)*(g/p),b=_*i.m00+v*i.m10+y*i.m20,S=_*i.m01+v*i.m11+y*i.m21,C=_*i.m02+v*i.m12+y*i.m22,w=compand(b*a.m00+S*a.m10+C*a.m20),T=compand(b*a.m01+S*a.m11+C*a.m21),E=compand(b*a.m02+S*a.m12+C*a.m22);return[w*255,T*255,E*255]},rgb2lab=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=rgb2xyz(t,n,r),[l,u,d]=xyz2lab(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};function xyz2lab(e,t,n){let{Xn:r,Yn:i,Zn:a,kE:o,kK:s}=x,c=e/r,l=t/i,u=n/a,d=c>o?c**(1/3):(s*c+16)/116,p=l>o?l**(1/3):(s*l+16)/116,m=u>o?u**(1/3):(s*u+16)/116;return[116*p-16,500*(d-p),200*(p-m)]}function gammaAdjustSRGB(e){let t=Math.sign(e);return e=Math.abs(e),(e<=.04045?e/12.92:((e+.055)/1.055)**2.4)*t}const rgb2xyz=(e,t,n)=>{e=gammaAdjustSRGB(e/255),t=gammaAdjustSRGB(t/255),n=gammaAdjustSRGB(n/255);let{MtxRGB2XYZ:r,MtxAdaptMa:i,MtxAdaptMaI:a,Xn:o,Yn:s,Zn:c,As:l,Bs:u,Cs:d}=x,p=e*r.m00+t*r.m10+n*r.m20,m=e*r.m01+t*r.m11+n*r.m21,h=e*r.m02+t*r.m12+n*r.m22,g=o*i.m00+s*i.m10+c*i.m20,_=o*i.m01+s*i.m11+c*i.m21,v=o*i.m02+s*i.m12+c*i.m22,y=p*i.m00+m*i.m10+h*i.m20,b=p*i.m01+m*i.m11+h*i.m21,S=p*i.m02+m*i.m12+h*i.m22;return y*=g/l,b*=_/u,S*=v/d,p=y*a.m00+b*a.m10+S*a.m20,m=y*a.m01+b*a.m11+S*a.m21,h=y*a.m02+b*a.m12+S*a.m22,[p,m,h]};Color.prototype.lab=function(){return rgb2lab(this._rgb)},Object.assign(chroma,{lab:e((...e)=>new Color(...e,`lab`),`lab`),getLabWhitePoint,setLabWhitePoint}),g.format.lab=lab2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`lab`),type_default(e)===`array`&&e.length===3)return`lab`}}),Color.prototype.darken=function(e=1){let t=this,n=t.lab();return n[0]-=x.Kn*e,new Color(n,`lab`).alpha(t.alpha(),!0)},Color.prototype.brighten=function(e=1){return this.darken(-e)},Color.prototype.darker=Color.prototype.darken,Color.prototype.brighter=Color.prototype.brighten,Color.prototype.get=function(e){let[t,n]=e.split(`.`),r=this[t]();if(n){let e=t.indexOf(n)-(t.substr(0,2)===`ok`?2:0);if(e>-1)return r[e];throw Error(`unknown channel ${n} in mode ${t}`)}else return r};const{pow:C}=Math;Color.prototype.luminance=function(e,t=`rgb`){if(e!==void 0&&type_default(e)===`number`){if(e===0)return new Color([0,0,0,this._rgb[3]],`rgb`);if(e===1)return new Color([255,255,255,this._rgb[3]],`rgb`);let n=this.luminance(),r=20,test=(n,i)=>{let a=n.interpolate(i,.5,t),o=a.luminance();return Math.abs(e-o)<1e-7||!r--?a:o>e?test(n,a):test(a,i)};return new Color([...(n>e?test(new Color([0,0,0]),this):test(this,new Color([255,255,255]))).rgb(),this._rgb[3]])}return rgb2luminance(...this._rgb.slice(0,3))};const rgb2luminance=(e,t,n)=>(e=luminance_x(e),t=luminance_x(t),n=luminance_x(n),.2126*e+.7152*t+.0722*n),luminance_x=e=>(e/=255,e<=.03928?e/12.92:C((e+.055)/1.055,2.4));var w={},T=e((e,t,n=.5,...r)=>{let i=r[0]||`lrgb`;if(!w[i]&&!r.length&&(i=Object.keys(w)[0]),!w[i])throw Error(`interpolation mode ${i} is not defined`);return type_default(e)!==`object`&&(e=new Color(e)),type_default(t)!==`object`&&(t=new Color(t)),w[i](e,t,n).alpha(e.alpha()+n*(t.alpha()-e.alpha()))},`default`);Color.prototype.mix=Color.prototype.interpolate=function(e,t=.5,...n){return T(this,e,t,...n)},Color.prototype.premultiply=function(e=!1){let t=this._rgb,n=t[3];return e?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new Color([t[0]*n,t[1]*n,t[2]*n,n],`rgb`)};const{sin:E,cos:ee}=Math,lch2lab=(...e)=>{let[t,n,r]=o(e,`lch`);return isNaN(r)&&(r=0),r*=m,[t,ee(r)*n,E(r)*n]},lch2rgb=(...e)=>{e=o(e,`lch`);let[t,n,r]=e,[i,a,s]=lch2lab(t,n,r),[c,l,u]=lab2rgb(i,a,s);return[c,l,u,e.length>3?e[3]:1]},hcl2rgb=(...e)=>lch2rgb(...reverse3(o(e,`hcl`))),{sqrt:D,atan2:te,round:O}=Math,lab2lch=(...e)=>{let[t,n,r]=o(e,`lab`),i=D(n*n+r*r),a=(te(r,n)*h+360)%360;return O(i*1e4)===0&&(a=NaN),[t,i,a]},rgb2lch=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=rgb2lab(t,n,r),[l,u,d]=lab2lch(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};Color.prototype.lch=function(){return rgb2lch(this._rgb)},Color.prototype.hcl=function(){return reverse3(rgb2lch(this._rgb))};const k=e((...e)=>new Color(...e,`lch`),`lch`),hcl=(...e)=>new Color(...e,`hcl`);Object.assign(chroma,{lch:k,hcl}),g.format.lch=lch2rgb,g.format.hcl=hcl2rgb,[`lch`,`hcl`].forEach(e=>g.autodetect.push({p:2,test:(...t)=>{if(t=o(t,e),type_default(t)===`array`&&t.length===3)return e}})),Color.prototype.saturate=function(e=1){let t=this,n=t.lch();return n[1]+=x.Kn*e,n[1]<0&&(n[1]=0),new Color(n,`lch`).alpha(t.alpha(),!0)},Color.prototype.desaturate=function(e=1){return this.saturate(-e)},Color.prototype.set=function(e,t,n=!1){let[r,i]=e.split(`.`),a=this[r]();if(i){let e=r.indexOf(i)-(r.substr(0,2)===`ok`?2:0);if(e>-1){if(type_default(t)==`string`)switch(t.charAt(0)){case`+`:a[e]+=+t;break;case`-`:a[e]+=+t;break;case`*`:a[e]*=+t.substr(1);break;case`/`:a[e]/=+t.substr(1);break;default:a[e]=+t}else if(type_default(t)===`number`)a[e]=t;else throw Error(`unsupported value for Color.set`);let i=new Color(a,r);return n?(this._rgb=i._rgb,this):i}throw Error(`unknown channel ${i} in mode ${r}`)}else return a},Color.prototype.tint=function(e=.5,...t){return T(this,`white`,e,...t)},Color.prototype.shade=function(e=.5,...t){return T(this,`black`,e,...t)},w.rgb=e((e,t,n)=>{let r=e._rgb,i=t._rgb;return new Color(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`rgb`)},`rgb`);const{sqrt:A,pow:j}=Math,lrgb=(e,t,n)=>{let[r,i,a]=e._rgb,[o,s,c]=t._rgb;return new Color(A(j(r,2)*(1-n)+j(o,2)*n),A(j(i,2)*(1-n)+j(s,2)*n),A(j(a,2)*(1-n)+j(c,2)*n),`rgb`)};w.lrgb=lrgb;const lab=(e,t,n)=>{let r=e.lab(),i=t.lab();return new Color(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`lab`)};w.lab=lab;var M=e((e,t,n,r)=>{let i,a;r===`hsl`?(i=e.hsl(),a=t.hsl()):r===`hsv`?(i=e.hsv(),a=t.hsv()):r===`hcg`?(i=e.hcg(),a=t.hcg()):r===`hsi`?(i=e.hsi(),a=t.hsi()):r===`lch`||r===`hcl`?(r=`hcl`,i=e.hcl(),a=t.hcl()):r===`oklch`&&(i=e.oklch().reverse(),a=t.oklch().reverse());let o,s,c,l,u,d;(r.substr(0,1)===`h`||r===`oklch`)&&([o,c,u]=i,[s,l,d]=a);let p,m,h,g;return!isNaN(o)&&!isNaN(s)?(g=s>o&&s-o>180?s-(o+360):s<o&&o-s>180?s+360-o:s-o,m=o+n*g):isNaN(o)?isNaN(s)?m=NaN:(m=s,(u==1||u==0)&&r!=`hsv`&&(p=l)):(m=o,(d==1||d==0)&&r!=`hsv`&&(p=c)),p===void 0&&(p=c+n*(l-c)),h=u+n*(d-u),r===`oklch`?new Color([h,p,m],r):new Color([m,p,h],r)},`default`);const lch=(e,t,n)=>M(e,t,n,`lch`);w.lch=lch,w.hcl=lch;const num2rgb=e=>{if(type_default(e)==`number`&&e>=0&&e<=16777215)return[e>>16,e>>8&255,e&255,1];throw Error(`unknown num color: `+e)},rgb2num=(...e)=>{let[t,n,r]=o(e,`rgb`);return(t<<16)+(n<<8)+r};Color.prototype.num=function(){return rgb2num(this._rgb)},Object.assign(chroma,{num:e((...e)=>new Color(...e,`num`),`num`)}),g.format.num=num2rgb,g.autodetect.push({p:5,test:(...e)=>{if(e.length===1&&type_default(e[0])===`number`&&e[0]>=0&&e[0]<=16777215)return`num`}});const num=(e,t,n)=>{let r=e.num();return new Color(r+n*(t.num()-r),`num`)};w.num=num;const{floor:ne}=Math,hcg2rgb=(...e)=>{e=o(e,`hcg`);let[t,n,r]=e,i,a,s;r*=255;let c=n*255;if(n===0)i=a=s=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let e=ne(t),o=t-e,l=r*(1-n),u=l+c*(1-o),d=l+c*o,p=l+c;switch(e){case 0:[i,a,s]=[p,d,l];break;case 1:[i,a,s]=[u,p,l];break;case 2:[i,a,s]=[l,p,d];break;case 3:[i,a,s]=[l,u,p];break;case 4:[i,a,s]=[d,l,p];break;case 5:[i,a,s]=[p,l,u];break}}return[i,a,s,e.length>3?e[3]:1]},rgb2hcg=(...e)=>{let[t,n,r]=o(e,`rgb`),i=l(t,n,r),a=u(t,n,r),s=a-i,c=s*100/255,d=i/(255-s)*100,p;return s===0?p=NaN:(t===a&&(p=(n-r)/s),n===a&&(p=2+(r-t)/s),r===a&&(p=4+(t-n)/s),p*=60,p<0&&(p+=360)),[p,c,d]};Color.prototype.hcg=function(){return rgb2hcg(this._rgb)},chroma.hcg=e((...e)=>new Color(...e,`hcg`),`hcg`),g.format.hcg=hcg2rgb,g.autodetect.push({p:1,test:(...e)=>{if(e=o(e,`hcg`),type_default(e)===`array`&&e.length===3)return`hcg`}});const hcg=(e,t,n)=>M(e,t,n,`hcg`);w.hcg=hcg;const{cos:N}=Math,hsi2rgb=(...e)=>{e=o(e,`hsi`);let[t,n,i]=e,a,s,c;return isNaN(t)&&(t=0),isNaN(n)&&(n=0),t>360&&(t-=360),t<0&&(t+=360),t/=360,t<1/3?(c=(1-n)/3,a=(1+n*N(d*t)/N(p-d*t))/3,s=1-(c+a)):t<2/3?(t-=1/3,a=(1-n)/3,s=(1+n*N(d*t)/N(p-d*t))/3,c=1-(a+s)):(t-=2/3,s=(1-n)/3,c=(1+n*N(d*t)/N(p-d*t))/3,a=1-(s+c)),a=r(i*a*3),s=r(i*s*3),c=r(i*c*3),[a*255,s*255,c*255,e.length>3?e[3]:1]},{min:re,sqrt:ie,acos:ae}=Math,rgb2hsi=(...e)=>{let[t,n,r]=o(e,`rgb`);t/=255,n/=255,r/=255;let i,a=re(t,n,r),s=(t+n+r)/3,c=s>0?1-a/s:0;return c===0?i=NaN:(i=(t-n+(t-r))/2,i/=ie((t-n)*(t-n)+(t-r)*(n-r)),i=ae(i),r>n&&(i=d-i),i/=d),[i*360,c,s]};Color.prototype.hsi=function(){return rgb2hsi(this._rgb)},chroma.hsi=e((...e)=>new Color(...e,`hsi`),`hsi`),g.format.hsi=hsi2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsi`),type_default(e)===`array`&&e.length===3)return`hsi`}});const hsi=(e,t,n)=>M(e,t,n,`hsi`);w.hsi=hsi;const hsl2rgb=(...e)=>{e=o(e,`hsl`);let[t,n,r]=e,i,a,s;if(n===0)i=a=s=r*255;else{let e=[0,0,0],o=[0,0,0],c=r<.5?r*(1+n):r+n-r*n,l=2*r-c,u=t/360;e[0]=u+1/3,e[1]=u,e[2]=u-1/3;for(let t=0;t<3;t++)e[t]<0&&(e[t]+=1),e[t]>1&&--e[t],6*e[t]<1?o[t]=l+(c-l)*6*e[t]:2*e[t]<1?o[t]=c:3*e[t]<2?o[t]=l+(c-l)*(2/3-e[t])*6:o[t]=l;[i,a,s]=[o[0]*255,o[1]*255,o[2]*255]}return e.length>3?[i,a,s,e[3]]:[i,a,s,1]},oe=e((...e)=>{e=o(e,`rgba`);let[t,n,r]=e;t/=255,n/=255,r/=255;let i=l(t,n,r),a=u(t,n,r),s=(a+i)/2,c,d;return a===i?(c=0,d=NaN):c=s<.5?(a-i)/(a+i):(a-i)/(2-a-i),t==a?d=(n-r)/(a-i):n==a?d=2+(r-t)/(a-i):r==a&&(d=4+(t-n)/(a-i)),d*=60,d<0&&(d+=360),e.length>3&&e[3]!==void 0?[d,c,s,e[3]]:[d,c,s]},`rgb2hsl`);Color.prototype.hsl=function(){return oe(this._rgb)},chroma.hsl=e((...e)=>new Color(...e,`hsl`),`hsl`),g.format.hsl=hsl2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsl`),type_default(e)===`array`&&e.length===3)return`hsl`}});const hsl=(e,t,n)=>M(e,t,n,`hsl`);w.hsl=hsl;const{floor:se}=Math,hsv2rgb=(...e)=>{e=o(e,`hsv`);let[t,n,r]=e,i,a,s;if(r*=255,n===0)i=a=s=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let e=se(t),o=t-e,c=r*(1-n),l=r*(1-n*o),u=r*(1-n*(1-o));switch(e){case 0:[i,a,s]=[r,u,c];break;case 1:[i,a,s]=[l,r,c];break;case 2:[i,a,s]=[c,r,u];break;case 3:[i,a,s]=[c,l,r];break;case 4:[i,a,s]=[u,c,r];break;case 5:[i,a,s]=[r,c,l];break}}return[i,a,s,e.length>3?e[3]:1]},{min:ce,max:le}=Math,rgb2hsl=(...e)=>{e=o(e,`rgb`);let[t,n,r]=e,i=ce(t,n,r),a=le(t,n,r),s=a-i,c,l,u;return u=a/255,a===0?(c=NaN,l=0):(l=s/a,t===a&&(c=(n-r)/s),n===a&&(c=2+(r-t)/s),r===a&&(c=4+(t-n)/s),c*=60,c<0&&(c+=360)),[c,l,u]};Color.prototype.hsv=function(){return rgb2hsl(this._rgb)},chroma.hsv=e((...e)=>new Color(...e,`hsv`),`hsv`),g.format.hsv=hsv2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsv`),type_default(e)===`array`&&e.length===3)return`hsv`}});const hsv=(e,t,n)=>M(e,t,n,`hsv`);w.hsv=hsv;function multiplyMatrices(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>Array.isArray(e)?e.reduce((e,n,r)=>e+n*(t[r]||0),0):t.reduce((t,n)=>t+n*e,0)));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}const oklab2rgb=(...e)=>{e=o(e,`lab`);let[t,n,r,...i]=e,[a,s,c]=OKLab_to_XYZ([t,n,r]),[l,u,d]=xyz2rgb(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};function OKLab_to_XYZ(e){return multiplyMatrices([[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],multiplyMatrices([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],e).map(e=>e**3))}const rgb2oklab=(...e)=>{let[t,n,r,...i]=o(e,`rgb`);return[...XYZ_to_OKLab(rgb2xyz(t,n,r)),...i.length>0&&i[0]<1?[i[0]]:[]]};function XYZ_to_OKLab(e){return multiplyMatrices([[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],multiplyMatrices([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],e).map(e=>Math.cbrt(e)))}Color.prototype.oklab=function(){return rgb2oklab(this._rgb)},Object.assign(chroma,{oklab:e((...e)=>new Color(...e,`oklab`),`oklab`)}),g.format.oklab=oklab2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`oklab`),type_default(e)===`array`&&e.length===3)return`oklab`}});const oklab=(e,t,n)=>{let r=e.oklab(),i=t.oklab();return new Color(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`oklab`)};w.oklab=oklab,w.oklch=e((e,t,n)=>M(e,t,n,`oklch`),`oklch`);const{pow:P,sqrt:F,PI:L,cos:ue,sin:de,atan2:fe}=Math;var pe=e((e,t=`lrgb`,n=null)=>{let r=e.length;n||=Array.from(Array(r)).map(()=>1);let i=r/n.reduce(function(e,t){return e+t});if(n.forEach((e,t)=>{n[t]*=i}),e=e.map(e=>new Color(e)),t===`lrgb`)return _average_lrgb(e,n);let a=e.shift(),o=a.get(t),s=[],c=0,l=0;for(let e=0;e<o.length;e++)if(o[e]=(o[e]||0)*n[0],s.push(isNaN(o[e])?0:n[0]),t.charAt(e)===`h`&&!isNaN(o[e])){let t=o[e]/180*L;c+=ue(t)*n[0],l+=de(t)*n[0]}let u=a.alpha()*n[0];e.forEach((e,r)=>{let i=e.get(t);u+=e.alpha()*n[r+1];for(let e=0;e<o.length;e++)if(!isNaN(i[e]))if(s[e]+=n[r+1],t.charAt(e)===`h`){let t=i[e]/180*L;c+=ue(t)*n[r+1],l+=de(t)*n[r+1]}else o[e]+=i[e]*n[r+1]});for(let e=0;e<o.length;e++)if(t.charAt(e)===`h`){let t=fe(l/s[e],c/s[e])/L*180;for(;t<0;)t+=360;for(;t>=360;)t-=360;o[e]=t}else o[e]=o[e]/s[e];return u/=r,new Color(o,t).alpha(u>.99999?1:u,!0)},`default`);const _average_lrgb=(e,t)=>{let n=e.length,r=[0,0,0,0];for(let i=0;i<e.length;i++){let a=e[i],o=t[i]/n,s=a._rgb;r[0]+=P(s[0],2)*o,r[1]+=P(s[1],2)*o,r[2]+=P(s[2],2)*o,r[3]+=s[3]*o}return r[0]=F(r[0]),r[1]=F(r[1]),r[2]=F(r[2]),r[3]>.9999999&&(r[3]=1),new Color(i(r))},{pow:me}=Math;function scale_default(e){let t=`rgb`,n=chroma(`#ccc`),i=0,a=[0,1],o=[0,1],s=[],c=[0,0],l=!1,u=[],d=!1,p=0,m=1,h=!1,g={},_=!0,v=1,setColors=function(e){if(e||=[`#fff`,`#000`],e&&type_default(e)===`string`&&chroma.brewer&&chroma.brewer[e.toLowerCase()]&&(e=chroma.brewer[e.toLowerCase()]),type_default(e)===`array`){e.length===1&&(e=[e[0],e[0]]),e=e.slice(0);for(let t=0;t<e.length;t++)e[t]=chroma(e[t]);s.length=0;for(let t=0;t<e.length;t++)s.push(t/(e.length-1))}return resetCache(),u=e},getClass=function(e){if(l!=null){let t=l.length-1,n=0;for(;n<t&&e>=l[n];)n++;return n-1}return 0},tMapLightness=e=>e,tMapDomain=e=>e,getColor=function(e,i){let a,o;if(i??=!1,isNaN(e)||e===null)return n;o=i?e:l&&l.length>2?getClass(e)/(l.length-2):m===p?1:(e-p)/(m-p),o=tMapDomain(o),i||(o=tMapLightness(o)),v!==1&&(o=me(o,v)),o=c[0]+o*(1-c[0]-c[1]),o=r(o,0,1);let d=Math.floor(o*1e4);if(_&&g[d])a=g[d];else{if(type_default(u)===`array`)for(let e=0;e<s.length;e++){let n=s[e];if(o<=n){a=u[e];break}if(o>=n&&e===s.length-1){a=u[e];break}if(o>n&&o<s[e+1]){o=(o-n)/(s[e+1]-n),a=chroma.interpolate(u[e],u[e+1],o,t);break}}else type_default(u)===`function`&&(a=u(o));_&&(g[d]=a)}return a};var resetCache=()=>g={};setColors(e);let f=function(e){let t=chroma(getColor(e));return d&&t[d]?t[d]():t};return f.classes=function(e){if(e!=null){if(type_default(e)===`array`)l=e,a=[e[0],e[e.length-1]];else{let t=chroma.analyze(a);l=e===0?[t.min,t.max]:chroma.limits(t,`e`,e)}return f}return l},f.domain=function(e){if(!arguments.length)return o;o=e.slice(0),p=e[0],m=e[e.length-1],s=[];let t=u.length;if(e.length===t&&p!==m)for(let t of Array.from(e))s.push((t-p)/(m-p));else{for(let e=0;e<t;e++)s.push(e/(t-1));if(e.length>2){let t=e.map((t,n)=>n/(e.length-1)),n=e.map(e=>(e-p)/(m-p));n.every((e,n)=>t[n]===e)||(tMapDomain=e=>{if(e<=0||e>=1)return e;let r=0;for(;e>=n[r+1];)r++;let i=(e-n[r])/(n[r+1]-n[r]);return t[r]+i*(t[r+1]-t[r])})}}return a=[p,m],f},f.mode=function(e){return arguments.length?(t=e,resetCache(),f):t},f.range=function(e,t){return setColors(e,t),f},f.out=function(e){return d=e,f},f.spread=function(e){return arguments.length?(i=e,f):i},f.correctLightness=function(e){return e??=!0,h=e,resetCache(),tMapLightness=h?function(e){let t=getColor(0,!0).lab()[0],n=getColor(1,!0).lab()[0],r=t>n,i=getColor(e,!0).lab()[0],a=t+(n-t)*e,o=i-a,s=0,c=1,l=20;for(;Math.abs(o)>.01&&l-->0;)(function(){return r&&(o*=-1),o<0?(s=e,e+=(c-e)*.5):(c=e,e+=(s-e)*.5),i=getColor(e,!0).lab()[0],o=i-a})();return e}:e=>e,f},f.padding=function(e){return e==null?c:(type_default(e)===`number`&&(e=[e,e]),c=e,f)},f.colors=function(t,n){arguments.length<2&&(n=`hex`);let r=[];if(arguments.length===0)r=u.slice(0);else if(t===1)r=[f(.5)];else if(t>1){let e=a[0],n=a[1]-e;r=__range__(0,t,!1).map(r=>f(e+r/(t-1)*n))}else{e=[];let t=[];if(l&&l.length>2)for(let e=1,n=l.length,r=1<=n;r?e<n:e>n;r?e++:e--)t.push((l[e-1]+l[e])*.5);else t=a;r=t.map(e=>f(e))}return chroma[n]&&(r=r.map(e=>e[n]())),r},f.cache=function(e){return e==null?_:(_=e,f)},f.gamma=function(e){return e==null?v:(v=e,f)},f.nodata=function(e){return e==null?n:(n=chroma(e),f)},f}e(scale_default,`default`);function __range__(e,t,n){let r=[],i=e<t,a=n?i?t+1:t-1:t;for(let t=e;i?t<a:t>a;i?t++:t--)r.push(t);return r}const binom_row=function(e){let t=[1,1];for(let n=1;n<e;n++){let e=[1];for(let n=1;n<=t.length;n++)e[n]=(t[n]||0)+t[n-1];t=e}return t},bezier=function(e){let I,t,n,r;if(e=e.map(e=>new Color(e)),e.length===2)[t,n]=e.map(e=>e.lab()),I=function(e){return new Color([0,1,2].map(r=>t[r]+e*(n[r]-t[r])),`lab`)};else if(e.length===3)[t,n,r]=e.map(e=>e.lab()),I=function(e){return new Color([0,1,2].map(i=>(1-e)*(1-e)*t[i]+2*(1-e)*e*n[i]+e*e*r[i]),`lab`)};else if(e.length===4){let i;[t,n,r,i]=e.map(e=>e.lab()),I=function(e){return new Color([0,1,2].map(a=>(1-e)*(1-e)*(1-e)*t[a]+3*(1-e)*(1-e)*e*n[a]+3*(1-e)*e*e*r[a]+e*e*e*i[a]),`lab`)}}else if(e.length>=5){let t,n,r;t=e.map(e=>e.lab()),r=e.length-1,n=binom_row(r),I=function(e){let i=1-e;return new Color([0,1,2].map(a=>t.reduce((t,o,s)=>t+n[s]*i**(r-s)*e**s*o[a],0)),`lab`)}}else throw RangeError(`No point in running bezier with only one color.`);return I};var he=e(e=>{let t=bezier(e);return t.scale=()=>scale_default(t),t},`default`);const{round:R}=Math;Color.prototype.rgb=function(e=!0){return e===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(R)},Color.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,n)=>n<3?e===!1?t:R(t):t)};const rgb=(...e)=>new Color(...e,`rgb`);Object.assign(chroma,{rgb}),g.format.rgb=(...e)=>{let t=o(e,`rgba`);return t[3]===void 0&&(t[3]=1),t},g.autodetect.push({p:3,test:(...e)=>{if(e=o(e,`rgba`),type_default(e)===`array`&&(e.length===3||e.length===4&&type_default(e[3])==`number`&&e[3]>=0&&e[3]<=1))return`rgb`}});const blend=(e,t,n)=>{if(!blend[n])throw Error(`unknown blend mode `+n);return blend[n](e,t)},blend_f=e=>(t,n)=>{let r=chroma(n).rgb(),i=chroma(t).rgb();return chroma.rgb(e(r,i))},each=e=>(t,n)=>{let r=[];return r[0]=e(t[0],n[0]),r[1]=e(t[1],n[1]),r[2]=e(t[2],n[2]),r},normal=e=>e,multiply=(e,t)=>e*t/255,darken=(e,t)=>e>t?t:e,lighten=(e,t)=>e>t?e:t,screen=(e,t)=>255*(1-(1-e/255)*(1-t/255)),overlay=(e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)),burn=(e,t)=>255*(1-(1-t/255)/(e/255)),dodge=(e,t)=>e===255?255:(e=t/255*255/(1-e/255),e>255?255:e);blend.normal=blend_f(each(normal)),blend.multiply=blend_f(each(multiply)),blend.screen=blend_f(each(screen)),blend.overlay=blend_f(each(overlay)),blend.darken=blend_f(each(darken)),blend.lighten=blend_f(each(lighten)),blend.dodge=blend_f(each(dodge)),blend.burn=blend_f(each(burn));const{pow:ge,sin:_e,cos:ve}=Math;function cubehelix_default(e=300,t=-1.5,n=1,r=1,a=[0,1]){let o=0,s;type_default(a)===`array`?s=a[1]-a[0]:(s=0,a=[a,a]);let f=function(c){let l=d*((e+120)/360+t*c),u=ge(a[0]+s*c,r),p=(o===0?n:n[0]+c*o)*u*(1-u)/2,m=ve(l),h=_e(l),g=u+p*(-.14861*m+1.78277*h),_=u+p*(-.29227*m-.90649*h),v=u+1.97294*m*p;return chroma(i([g*255,_*255,v*255,1]))};return f.start=function(t){return t==null?e:(e=t,f)},f.rotations=function(e){return e==null?t:(t=e,f)},f.gamma=function(e){return e==null?r:(r=e,f)},f.hue=function(e){return e==null?n:(n=e,type_default(n)===`array`?(o=n[1]-n[0],o===0&&(n=n[1])):o=0,f)},f.lightness=function(e){return e==null?a:(type_default(e)===`array`?(a=e,s=e[1]-e[0]):(a=[e,e],s=0),f)},f.scale=()=>chroma.scale(f),f.hue(n),f}e(cubehelix_default,`default`);const{floor:ye,random:be}=Math;var xe=e((e=be)=>{let t=`#`;for(let n=0;n<6;n++)t+=`0123456789abcdef`.charAt(ye(e()*16));return new Color(t,`hex`)},`default`);const{log:z,pow:Se,floor:Ce,abs:we}=Math;function analyze(e,t=null){let n={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return type_default(e)===`object`&&(e=Object.values(e)),e.forEach(e=>{t&&type_default(e)===`object`&&(e=e[t]),e!=null&&!isNaN(e)&&(n.values.push(e),n.sum+=e,e<n.min&&(n.min=e),e>n.max&&(n.max=e),n.count+=1)}),n.domain=[n.min,n.max],n.limits=(e,t)=>limits(n,e,t),n}function limits(e,t=`equal`,n=7){type_default(e)==`array`&&(e=analyze(e));let{min:r,max:i}=e,a=e.values.sort((e,t)=>e-t);if(n===1)return[r,i];let o=[];if(t.substr(0,1)===`c`&&(o.push(r),o.push(i)),t.substr(0,1)===`e`){o.push(r);for(let e=1;e<n;e++)o.push(r+e/n*(i-r));o.push(i)}else if(t.substr(0,1)===`l`){if(r<=0)throw Error(`Logarithmic scales are only possible for values > 0`);let e=Math.LOG10E*z(r),t=Math.LOG10E*z(i);o.push(r);for(let r=1;r<n;r++)o.push(Se(10,e+r/n*(t-e)));o.push(i)}else if(t.substr(0,1)===`q`){o.push(r);for(let e=1;e<n;e++){let t=(a.length-1)*e/n,r=Ce(t);if(r===t)o.push(a[r]);else{let e=t-r;o.push(a[r]*(1-e)+a[r+1]*e)}}o.push(i)}else if(t.substr(0,1)===`k`){let e,t=a.length,s=Array(t),c=Array(n),l=!0,u=0,d=null;d=[],d.push(r);for(let e=1;e<n;e++)d.push(r+e/n*(i-r));for(d.push(i);l;){for(let e=0;e<n;e++)c[e]=0;for(let e=0;e<t;e++){let t=a[e],r=Number.MAX_VALUE,i;for(let a=0;a<n;a++){let n=we(d[a]-t);n<r&&(r=n,i=a),c[i]++,s[e]=i}}let r=Array(n);for(let e=0;e<n;e++)r[e]=null;for(let n=0;n<t;n++)e=s[n],r[e]===null?r[e]=a[n]:r[e]+=a[n];for(let e=0;e<n;e++)r[e]*=1/c[e];l=!1;for(let e=0;e<n;e++)if(r[e]!==d[e]){l=!0;break}d=r,u++,u>200&&(l=!1)}let p={};for(let e=0;e<n;e++)p[e]=[];for(let n=0;n<t;n++)e=s[n],p[e].push(a[n]);let m=[];for(let e=0;e<n;e++)m.push(p[e][0]),m.push(p[e][p[e].length-1]);m=m.sort((e,t)=>e-t),o.push(m[0]);for(let e=1;e<m.length;e+=2){let t=m[e];!isNaN(t)&&o.indexOf(t)===-1&&o.push(t)}}return o}var Te=e((e,t)=>{e=new Color(e),t=new Color(t);let n=e.luminance(),r=t.luminance();return n>r?(n+.05)/(r+.05):(r+.05)/(n+.05)},`default`);
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
*
|
|
5
|
+
* The APCA contrast prediction algorithm is based of the formulas published
|
|
6
|
+
* in the APCA-1.0.98G specification by Myndex. The specification is available at:
|
|
7
|
+
* https://raw.githubusercontent.com/Myndex/apca-w3/master/images/APCAw3_0.1.17_APCA0.0.98G.svg
|
|
8
|
+
*
|
|
9
|
+
* Note that the APCA implementation is still beta, so please update to
|
|
10
|
+
* future versions of chroma.js when they become available.
|
|
11
|
+
*
|
|
12
|
+
* You can read more about the APCA Readability Criterion at
|
|
13
|
+
* https://readtech.org/ARC/
|
|
14
|
+
*/
|
|
15
|
+
const Ee=.027,De=1.14,B=.022,Oe=1.414;var ke=e((e,t)=>{e=new Color(e),t=new Color(t),e.alpha()<1&&(e=T(t,e,e.alpha(),`rgb`));let n=lum(...e.rgb()),r=lum(...t.rgb()),i=n>=B?n:n+(B-n)**Oe,a=r>=B?r:r+(B-r)**Oe,o=a**.56-i**.57,s=a**.65-i**.62,c=Math.abs(a-i)<5e-4?0:i<a?o*De:s*De;return(Math.abs(c)<.1?0:c>0?c-Ee:c+Ee)*100},`default`);function lum(e,t,n){return .2126729*(e/255)**2.4+.7151522*(t/255)**2.4+.072175*(n/255)**2.4}const{sqrt:V,pow:H,min:Ae,max:je,atan2:Me,abs:Ne,cos:U,sin:Pe,exp:Fe,PI:Ie}=Math;function delta_e_default(e,t,n=1,r=1,i=1){var rad2deg=function(e){return 360*e/(2*Ie)},deg2rad=function(e){return 2*Ie*e/360};e=new Color(e),t=new Color(t);let[a,o,s]=Array.from(e.lab()),[c,l,u]=Array.from(t.lab()),d=(a+c)/2,p=(V(H(o,2)+H(s,2))+V(H(l,2)+H(u,2)))/2,m=.5*(1-V(H(p,7)/(H(p,7)+H(25,7)))),h=o*(1+m),g=l*(1+m),_=V(H(h,2)+H(s,2)),v=V(H(g,2)+H(u,2)),y=(_+v)/2,b=rad2deg(Me(s,h)),x=rad2deg(Me(u,g)),S=b>=0?b:b+360,C=x>=0?x:x+360,w=Ne(S-C)>180?(S+C+360)/2:(S+C)/2,T=1-.17*U(deg2rad(w-30))+.24*U(deg2rad(2*w))+.32*U(deg2rad(3*w+6))-.2*U(deg2rad(4*w-63)),E=C-S;E=Ne(E)<=180?E:C<=S?E+360:E-360,E=2*V(_*v)*Pe(deg2rad(E)/2);let ee=c-a,D=v-_,te=1+.015*H(d-50,2)/V(20+H(d-50,2)),O=1+.045*y,k=1+.015*y*T,A=30*Fe(-H((w-275)/25,2)),j=-(2*V(H(y,7)/(H(y,7)+H(25,7))))*Pe(2*deg2rad(A)),M=V(H(ee/(n*te),2)+H(D/(r*O),2)+H(E/(i*k),2)+j*(D/(r*O))*(E/(i*k)));return je(0,Ae(100,M))}e(delta_e_default,`default`);function distance_default(e,t,n=`lab`){e=new Color(e),t=new Color(t);let r=e.get(n),i=t.get(n),a=0;for(let e in r){let t=(r[e]||0)-(i[e]||0);a+=t*t}return Math.sqrt(a)}e(distance_default,`default`);var Le=e((...e)=>{try{return new Color(...e),!0}catch{return!1}},`default`),Re={cool(){return scale_default([chroma.hsl(180,1,.9),chroma.hsl(250,.7,.4)])},hot(){return scale_default([`#000`,`#f00`,`#ff0`,`#fff`],[0,.25,.75,1]).mode(`rgb`)}};const W={OrRd:[`#fff7ec`,`#fee8c8`,`#fdd49e`,`#fdbb84`,`#fc8d59`,`#ef6548`,`#d7301f`,`#b30000`,`#7f0000`],PuBu:[`#fff7fb`,`#ece7f2`,`#d0d1e6`,`#a6bddb`,`#74a9cf`,`#3690c0`,`#0570b0`,`#045a8d`,`#023858`],BuPu:[`#f7fcfd`,`#e0ecf4`,`#bfd3e6`,`#9ebcda`,`#8c96c6`,`#8c6bb1`,`#88419d`,`#810f7c`,`#4d004b`],Oranges:[`#fff5eb`,`#fee6ce`,`#fdd0a2`,`#fdae6b`,`#fd8d3c`,`#f16913`,`#d94801`,`#a63603`,`#7f2704`],BuGn:[`#f7fcfd`,`#e5f5f9`,`#ccece6`,`#99d8c9`,`#66c2a4`,`#41ae76`,`#238b45`,`#006d2c`,`#00441b`],YlOrBr:[`#ffffe5`,`#fff7bc`,`#fee391`,`#fec44f`,`#fe9929`,`#ec7014`,`#cc4c02`,`#993404`,`#662506`],YlGn:[`#ffffe5`,`#f7fcb9`,`#d9f0a3`,`#addd8e`,`#78c679`,`#41ab5d`,`#238443`,`#006837`,`#004529`],Reds:[`#fff5f0`,`#fee0d2`,`#fcbba1`,`#fc9272`,`#fb6a4a`,`#ef3b2c`,`#cb181d`,`#a50f15`,`#67000d`],RdPu:[`#fff7f3`,`#fde0dd`,`#fcc5c0`,`#fa9fb5`,`#f768a1`,`#dd3497`,`#ae017e`,`#7a0177`,`#49006a`],Greens:[`#f7fcf5`,`#e5f5e0`,`#c7e9c0`,`#a1d99b`,`#74c476`,`#41ab5d`,`#238b45`,`#006d2c`,`#00441b`],YlGnBu:[`#ffffd9`,`#edf8b1`,`#c7e9b4`,`#7fcdbb`,`#41b6c4`,`#1d91c0`,`#225ea8`,`#253494`,`#081d58`],Purples:[`#fcfbfd`,`#efedf5`,`#dadaeb`,`#bcbddc`,`#9e9ac8`,`#807dba`,`#6a51a3`,`#54278f`,`#3f007d`],GnBu:[`#f7fcf0`,`#e0f3db`,`#ccebc5`,`#a8ddb5`,`#7bccc4`,`#4eb3d3`,`#2b8cbe`,`#0868ac`,`#084081`],Greys:[`#ffffff`,`#f0f0f0`,`#d9d9d9`,`#bdbdbd`,`#969696`,`#737373`,`#525252`,`#252525`,`#000000`],YlOrRd:[`#ffffcc`,`#ffeda0`,`#fed976`,`#feb24c`,`#fd8d3c`,`#fc4e2a`,`#e31a1c`,`#bd0026`,`#800026`],PuRd:[`#f7f4f9`,`#e7e1ef`,`#d4b9da`,`#c994c7`,`#df65b0`,`#e7298a`,`#ce1256`,`#980043`,`#67001f`],Blues:[`#f7fbff`,`#deebf7`,`#c6dbef`,`#9ecae1`,`#6baed6`,`#4292c6`,`#2171b5`,`#08519c`,`#08306b`],PuBuGn:[`#fff7fb`,`#ece2f0`,`#d0d1e6`,`#a6bddb`,`#67a9cf`,`#3690c0`,`#02818a`,`#016c59`,`#014636`],Viridis:[`#440154`,`#482777`,`#3f4a8a`,`#31678e`,`#26838f`,`#1f9d8a`,`#6cce5a`,`#b6de2b`,`#fee825`],Spectral:[`#9e0142`,`#d53e4f`,`#f46d43`,`#fdae61`,`#fee08b`,`#ffffbf`,`#e6f598`,`#abdda4`,`#66c2a5`,`#3288bd`,`#5e4fa2`],RdYlGn:[`#a50026`,`#d73027`,`#f46d43`,`#fdae61`,`#fee08b`,`#ffffbf`,`#d9ef8b`,`#a6d96a`,`#66bd63`,`#1a9850`,`#006837`],RdBu:[`#67001f`,`#b2182b`,`#d6604d`,`#f4a582`,`#fddbc7`,`#f7f7f7`,`#d1e5f0`,`#92c5de`,`#4393c3`,`#2166ac`,`#053061`],PiYG:[`#8e0152`,`#c51b7d`,`#de77ae`,`#f1b6da`,`#fde0ef`,`#f7f7f7`,`#e6f5d0`,`#b8e186`,`#7fbc41`,`#4d9221`,`#276419`],PRGn:[`#40004b`,`#762a83`,`#9970ab`,`#c2a5cf`,`#e7d4e8`,`#f7f7f7`,`#d9f0d3`,`#a6dba0`,`#5aae61`,`#1b7837`,`#00441b`],RdYlBu:[`#a50026`,`#d73027`,`#f46d43`,`#fdae61`,`#fee090`,`#ffffbf`,`#e0f3f8`,`#abd9e9`,`#74add1`,`#4575b4`,`#313695`],BrBG:[`#543005`,`#8c510a`,`#bf812d`,`#dfc27d`,`#f6e8c3`,`#f5f5f5`,`#c7eae5`,`#80cdc1`,`#35978f`,`#01665e`,`#003c30`],RdGy:[`#67001f`,`#b2182b`,`#d6604d`,`#f4a582`,`#fddbc7`,`#ffffff`,`#e0e0e0`,`#bababa`,`#878787`,`#4d4d4d`,`#1a1a1a`],PuOr:[`#7f3b08`,`#b35806`,`#e08214`,`#fdb863`,`#fee0b6`,`#f7f7f7`,`#d8daeb`,`#b2abd2`,`#8073ac`,`#542788`,`#2d004b`],Set2:[`#66c2a5`,`#fc8d62`,`#8da0cb`,`#e78ac3`,`#a6d854`,`#ffd92f`,`#e5c494`,`#b3b3b3`],Accent:[`#7fc97f`,`#beaed4`,`#fdc086`,`#ffff99`,`#386cb0`,`#f0027f`,`#bf5b17`,`#666666`],Set1:[`#e41a1c`,`#377eb8`,`#4daf4a`,`#984ea3`,`#ff7f00`,`#ffff33`,`#a65628`,`#f781bf`,`#999999`],Set3:[`#8dd3c7`,`#ffffb3`,`#bebada`,`#fb8072`,`#80b1d3`,`#fdb462`,`#b3de69`,`#fccde5`,`#d9d9d9`,`#bc80bd`,`#ccebc5`,`#ffed6f`],Dark2:[`#1b9e77`,`#d95f02`,`#7570b3`,`#e7298a`,`#66a61e`,`#e6ab02`,`#a6761d`,`#666666`],Paired:[`#a6cee3`,`#1f78b4`,`#b2df8a`,`#33a02c`,`#fb9a99`,`#e31a1c`,`#fdbf6f`,`#ff7f00`,`#cab2d6`,`#6a3d9a`,`#ffff99`,`#b15928`],Pastel2:[`#b3e2cd`,`#fdcdac`,`#cbd5e8`,`#f4cae4`,`#e6f5c9`,`#fff2ae`,`#f1e2cc`,`#cccccc`],Pastel1:[`#fbb4ae`,`#b3cde3`,`#ccebc5`,`#decbe4`,`#fed9a6`,`#ffffcc`,`#e5d8bd`,`#fddaec`,`#f2f2f2`]},ze=Object.keys(W),Be=new Map(ze.map(e=>[e.toLowerCase(),e])),Ve=typeof Proxy==`function`?new Proxy(W,{get(e,t){let n=t.toLowerCase();if(Be.has(n))return e[Be.get(n)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(ze)}}):W,cmyk2rgb=(...e)=>{e=o(e,`cmyk`);let[t,n,r,i]=e,a=e.length>4?e[4]:1;return i===1?[0,0,0,a]:[t>=1?0:255*(1-t)*(1-i),n>=1?0:255*(1-n)*(1-i),r>=1?0:255*(1-r)*(1-i),a]},{max:He}=Math,rgb2cmyk=(...e)=>{let[t,n,r]=o(e,`rgb`);t/=255,n/=255,r/=255;let i=1-He(t,He(n,r)),a=i<1?1/(1-i):0;return[(1-t-i)*a,(1-n-i)*a,(1-r-i)*a,i]};Color.prototype.cmyk=function(){return rgb2cmyk(this._rgb)};const cmyk=(...e)=>new Color(...e,`cmyk`);Object.assign(chroma,{cmyk}),g.format.cmyk=cmyk2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`cmyk`),type_default(e)===`array`&&e.length===4)return`cmyk`}});const hsl2css=(...e)=>{let t=o(e,`hsla`),n=s(e)||`lsa`;return t[0]=rnd2(t[0]||0)+`deg`,t[1]=rnd2(t[1]*100)+`%`,t[2]=rnd2(t[2]*100)+`%`,n===`hsla`||t.length>3&&t[3]<1?(t[3]=`/ `+(t.length>3?t[3]:1),n=`hsla`):t.length=3,`${n.substr(0,3)}(${t.join(` `)})`},lab2css=(...e)=>{let t=o(e,`lab`),n=s(e)||`lab`;return t[0]=rnd2(t[0])+`%`,t[1]=rnd2(t[1]),t[2]=rnd2(t[2]),n===`laba`||t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(` `)})`},lch2css=(...e)=>{let t=o(e,`lch`),n=s(e)||`lab`;return t[0]=rnd2(t[0])+`%`,t[1]=rnd2(t[1]),t[2]=isNaN(t[2])?`none`:rnd2(t[2])+`deg`,n===`lcha`||t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(` `)})`},oklab2css=(...e)=>{let t=o(e,`lab`);return t[0]=rnd2(t[0]*100)+`%`,t[1]=rnd3(t[1]),t[2]=rnd3(t[2]),t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(` `)})`},rgb2oklch=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=rgb2oklab(t,n,r),[l,u,d]=lab2lch(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]},oklch2css=(...e)=>{let t=o(e,`lch`);return t[0]=rnd2(t[0]*100)+`%`,t[1]=rnd3(t[1]),t[2]=isNaN(t[2])?`none`:rnd2(t[2])+`deg`,t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(` `)})`},{round:G}=Math,rgb2css=(...e)=>{let t=o(e,`rgba`),n=s(e)||`rgb`;if(n.substr(0,3)===`hsl`)return hsl2css(oe(t),n);if(n.substr(0,3)===`lab`){let e=getLabWhitePoint();setLabWhitePoint(`d50`);let r=lab2css(rgb2lab(t),n);return setLabWhitePoint(e),r}if(n.substr(0,3)===`lch`){let e=getLabWhitePoint();setLabWhitePoint(`d50`);let r=lch2css(rgb2lch(t),n);return setLabWhitePoint(e),r}return n.substr(0,5)===`oklab`?oklab2css(rgb2oklab(t)):n.substr(0,5)===`oklch`?oklch2css(rgb2oklch(t)):(t[0]=G(t[0]),t[1]=G(t[1]),t[2]=G(t[2]),(n===`rgba`||t.length>3&&t[3]<1)&&(t[3]=`/ `+(t.length>3?t[3]:1),n=`rgba`),`${n.substr(0,3)}(${t.slice(0,n===`rgb`?3:4).join(` `)})`)},oklch2rgb=(...e)=>{e=o(e,`lch`);let[t,n,r,...i]=e,[a,s,c]=lch2lab(t,n,r),[l,u,d]=oklab2rgb(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]},K=`((?:-?\\d+)|(?:-?\\d+(?:\\.\\d+)?)%|none)`,q=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)%?)|none)`,J=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)%)|none)`,Y=`\\s*,\\s*`,X=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:deg)?)|none)`,Ue=RegExp(`^rgba?\\(\\s*`+[K,K,K].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),We=RegExp(`^rgb\\(\\s*`+[K,K,K].join(Y)+`\\s*\\)$`),Ge=RegExp(`^rgba\\(\\s*`+[K,K,K,q].join(Y)+`\\s*\\)$`),Ke=RegExp(`^hsla?\\(\\s*`+[X,J,J].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),qe=RegExp(`^hsl?\\(\\s*`+[X,J,J].join(Y)+`\\s*\\)$`),Je=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Z=RegExp(`^lab\\(\\s*`+[q,q,q].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),Ye=RegExp(`^lch\\(\\s*`+[q,q,X].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),Xe=RegExp(`^oklab\\(\\s*`+[q,q,q].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),Ze=RegExp(`^oklch\\(\\s*`+[q,q,X].join(`\\s+`)+`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?\\)$`),{round:Q}=Math,roundRGB=e=>e.map((e,t)=>t<=2?r(Q(e),0,255):e),percentToAbsolute=(e,t=0,n=100,r=!1)=>(typeof e==`string`&&e.endsWith(`%`)&&(e=parseFloat(e.substring(0,e.length-1))/100,e=r?t+(e+1)*.5*(n-t):t+e*(n-t)),+e),noneToValue=(e,t)=>e===`none`?t:e,css2rgb=e=>{if(e=e.toLowerCase().trim(),e===`transparent`)return[0,0,0,0];let t;if(g.format.named)try{return g.format.named(e)}catch{}if((t=e.match(Ue))||(t=e.match(We))){let e=t.slice(1,4);for(let t=0;t<3;t++)e[t]=+percentToAbsolute(noneToValue(e[t],0),0,255);e=roundRGB(e);let n=t[4]===void 0?1:+percentToAbsolute(t[4],0,1);return e[3]=n,e}if(t=e.match(Ge)){let e=t.slice(1,5);for(let t=0;t<4;t++)e[t]=+percentToAbsolute(e[t],0,255);return e}if((t=e.match(Ke))||(t=e.match(qe))){let e=t.slice(1,4);e[0]=+noneToValue(e[0].replace(`deg`,``),0),e[1]=percentToAbsolute(noneToValue(e[1],0),0,100)*.01,e[2]=percentToAbsolute(noneToValue(e[2],0),0,100)*.01;let n=roundRGB(hsl2rgb(e));return n[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),n}if(t=e.match(Je)){let e=t.slice(1,4);e[1]*=.01,e[2]*=.01;let n=hsl2rgb(e);for(let e=0;e<3;e++)n[e]=Q(n[e]);return n[3]=+t[4],n}if(t=e.match(Z)){let e=t.slice(1,4);e[0]=percentToAbsolute(noneToValue(e[0],0),0,100),e[1]=percentToAbsolute(noneToValue(e[1],0),-125,125,!0),e[2]=percentToAbsolute(noneToValue(e[2],0),-125,125,!0);let n=getLabWhitePoint();setLabWhitePoint(`d50`);let r=roundRGB(lab2rgb(e));return setLabWhitePoint(n),r[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),r}if(t=e.match(Ye)){let e=t.slice(1,4);e[0]=percentToAbsolute(e[0],0,100),e[1]=percentToAbsolute(noneToValue(e[1],0),0,150,!1),e[2]=+noneToValue(e[2].replace(`deg`,``),0);let n=getLabWhitePoint();setLabWhitePoint(`d50`);let r=roundRGB(lch2rgb(e));return setLabWhitePoint(n),r[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),r}if(t=e.match(Xe)){let e=t.slice(1,4);e[0]=percentToAbsolute(noneToValue(e[0],0),0,1),e[1]=percentToAbsolute(noneToValue(e[1],0),-.4,.4,!0),e[2]=percentToAbsolute(noneToValue(e[2],0),-.4,.4,!0);let n=roundRGB(oklab2rgb(e));return n[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),n}if(t=e.match(Ze)){let e=t.slice(1,4);e[0]=percentToAbsolute(noneToValue(e[0],0),0,1),e[1]=percentToAbsolute(noneToValue(e[1],0),0,.4,!1),e[2]=+noneToValue(e[2].replace(`deg`,``),0);let n=roundRGB(oklch2rgb(e));return n[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),n}};css2rgb.test=e=>Ue.test(e)||Ke.test(e)||Z.test(e)||Ye.test(e)||Xe.test(e)||Ze.test(e)||We.test(e)||Ge.test(e)||qe.test(e)||Je.test(e)||e===`transparent`,Color.prototype.css=function(e){return rgb2css(this._rgb,e)};const css=(...e)=>new Color(...e,`css`);chroma.css=css,g.format.css=css2rgb,g.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&type_default(e)===`string`&&css2rgb.test(e))return`css`}}),g.format.gl=(...e)=>{let t=o(e,`rgba`);return t[0]*=255,t[1]*=255,t[2]*=255,t};const gl=(...e)=>new Color(...e,`gl`);chroma.gl=gl,Color.prototype.gl=function(){let e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]},Color.prototype.hex=function(e){return rgb2hex(this._rgb,e)};const hex=(...e)=>new Color(...e,`hex`);chroma.hex=hex,g.format.hex=hex2rgb,g.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&type_default(e)===`string`&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return`hex`}});const{log:$}=Math,temperature2rgb=e=>{let t=e/100,n,r,i;return t<66?(n=255,r=t<6?0:-155.25485562709179-.44596950469579133*(r=t-2)+104.49216199393888*$(r),i=t<20?0:-254.76935184120902+.8274096064007395*(i=t-10)+115.67994401066147*$(i)):(n=351.97690566805693+.114206453784165*(n=t-55)-40.25366309332127*$(n),r=325.4494125711974+.07943456536662342*(r=t-50)-28.0852963507957*$(r),i=255),[n,r,i,1]},{round:Qe}=Math,rgb2temperature=(...e)=>{let t=o(e,`rgb`),n=t[0],r=t[2],i=1e3,a=4e4,s;for(;a-i>.4;){s=(a+i)*.5;let e=temperature2rgb(s);e[2]/e[0]>=r/n?a=s:i=s}return Qe(s)};Color.prototype.temp=Color.prototype.kelvin=Color.prototype.temperature=function(){return rgb2temperature(this._rgb)};const temp=(...e)=>new Color(...e,`temp`);Object.assign(chroma,{temp,kelvin:temp,temperature:temp}),g.format.temp=g.format.kelvin=g.format.temperature=temperature2rgb,Color.prototype.oklch=function(){return rgb2oklch(this._rgb)};const oklch=(...e)=>new Color(...e,`oklch`);Object.assign(chroma,{oklch}),g.format.oklch=oklch2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`oklch`),type_default(e)===`array`&&e.length===3)return`oklch`}}),Object.assign(chroma,{analyze,average:pe,bezier:he,blend,brewer:Ve,Color,colors:_,contrast:Te,contrastAPCA:ke,cubehelix:cubehelix_default,deltaE:delta_e_default,distance:distance_default,input:g,interpolate:T,limits,mix:T,random:xe,scale:scale_default,scales:Re,valid:Le});var $e=chroma;export{$e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../rolldown-runtime.mjs";var t=e((e=>{e.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<`u`,e.SYMBOL_SUPPORT=typeof Symbol<`u`})),n=e(((e,n)=>{var r=t(),i=r.ARRAY_BUFFER_SUPPORT,a=r.SYMBOL_SUPPORT;n.exports=function forEach(e,t){var n,r,o,s,c;if(!e)throw Error(`obliterator/forEach: invalid iterable.`);if(typeof t!=`function`)throw Error(`obliterator/forEach: expecting a callback.`);if(Array.isArray(e)||i&&ArrayBuffer.isView(e)||typeof e==`string`||e.toString()===`[object Arguments]`){for(o=0,s=e.length;o<s;o++)t(e[o],o);return}if(typeof e.forEach==`function`){e.forEach(t);return}if(a&&Symbol.iterator in e&&typeof e.next!=`function`&&(e=e[Symbol.iterator]()),typeof e.next==`function`){for(n=e,o=0;c=n.next(),c.done!==!0;)t(c.value,o),o++;return}for(r in e)e.hasOwnProperty(r)&&t(e[r],r)}})),r=e(((e,t)=>{function Iterator(e){if(typeof e!=`function`)throw Error(`obliterator/iterator: expecting a function!`);this.next=e}typeof Symbol<`u`&&(Iterator.prototype[Symbol.iterator]=function(){return this}),Iterator.of=function(){var e=arguments,t=e.length,n=0;return new Iterator(function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}})},Iterator.empty=function(){return new Iterator(function(){return{done:!0}})},Iterator.fromSequence=function(e){var t=0,n=e.length;return new Iterator(function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}})},Iterator.is=function(e){return e instanceof Iterator||typeof e==`object`&&!!e&&typeof e.next==`function`},t.exports=Iterator})),i=e(((e,t)=>{t.exports=function isGraph(e){return typeof e==`object`&&!!e&&typeof e.addUndirectedEdgeWithKey==`function`&&typeof e.dropNode==`function`&&typeof e.multi==`boolean`}})),a=e((e=>{var t=2**16-1,n=2**32-1,r=2**7-1,i=2**15-1,a=2**31-1;e.getPointerArray=function(e){var r=e-1;if(r<=255)return Uint8Array;if(r<=t)return Uint16Array;if(r<=n)return Uint32Array;throw Error(`mnemonist: Pointer Array of size > 4294967295 is not supported.`)},e.getSignedPointerArray=function(e){var t=e-1;return t<=r?Int8Array:t<=i?Int16Array:t<=a?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 o={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,s,c,l,u;for(l=0,u=t.length;l<u;l++)c=n?n(t[l]):t[l],s=e.getNumberType(c),a=o[s.name],a>i&&(i=a,r=s);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}})),o=e((e=>{var t=n(),r=a();function isArrayLike(e){return Array.isArray(e)||r.isTypedArray(e)}function guessLength(e){if(typeof e.length==`number`)return e.length;if(typeof e.size==`number`)return e.size}function toArray(e){var n=guessLength(e),r=typeof n==`number`?Array(n):[],i=0;return t(e,function(e){r[i++]=e}),r}function toArrayWithIndices(e){var n=guessLength(e),i=typeof n==`number`?r.getPointerArray(n):Array,a=typeof n==`number`?Array(n):[],o=typeof n==`number`?new i(n):[],s=0;return t(e,function(e){a[s]=e,o[s]=s++}),[a,o]}e.isArrayLike=isArrayLike,e.guessLength=guessLength,e.toArray=toArray,e.toArrayWithIndices=toArrayWithIndices})),s=e(((e,t)=>{var n=o(),i=r();function FixedDeque(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()}FixedDeque.prototype.clear=function(){this.start=0,this.size=0},FixedDeque.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},FixedDeque.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},FixedDeque.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]}},FixedDeque.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]}},FixedDeque.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]},FixedDeque.prototype.peekLast=function(){if(this.size!==0){var e=this.start+this.size-1;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},FixedDeque.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]},FixedDeque.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)},FixedDeque.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},FixedDeque.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}})},FixedDeque.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`&&(FixedDeque.prototype[Symbol.iterator]=FixedDeque.prototype.values),FixedDeque.prototype.inspect=function(){var e=this.toArray();return e.type=this.ArrayClass.name,e.capacity=this.capacity,Object.defineProperty(e,"constructor",{value:FixedDeque,enumerable:!1}),e},typeof Symbol<`u`&&(FixedDeque.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=FixedDeque.prototype.inspect),FixedDeque.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 FixedDeque(t,r);if(n.isArrayLike(e)){var a,o;for(a=0,o=e.length;a<o;a++)i.items[a]=e[a];return i.size=o,i}return n.forEach(e,function(e){i.push(e)}),i},t.exports=FixedDeque})),c=e((e=>{let t=i(),n=s();function simpleInDegree(e,t){let n=0;return e.forEachInNeighbor(t,()=>{n++}),n}function forEachNodeInTopologicalOrder(e,r){if(!t(e))throw Error(`graphology-dag/topological-sort: the given graph is not a valid graphology instance.`);if(e.type===`undirected`||e.undirectedSize!==0)throw Error(`graphology-dag/topological-sort: cannot work if graph is not directed.`);if(e.order===0)return;let i=new n(Array,e.order),a={},o=0;e.forEachNode((t,n)=>{let r=e.multi?simpleInDegree(e,t):e.inDegree(t);r===0?i.push([t,n,0]):(a[t]=r,o+=r)});let s=0;function neighborCallback(e,t){let n=--a[e];o--,n===0&&i.push([e,t,s+1]),a[e]=n}for(;i.size!==0;){let[t,n,a]=i.shift();s=a,r(t,n,a),e.forEachOutNeighbor(t,neighborCallback)}if(o!==0)throw Error(`graphology-dag/topological-sort: given graph is not acyclic.`)}function topologicalSort(e){if(!t(e))throw Error(`graphology-dag/topological-sort: the given graph is not a valid graphology instance.`);let n=Array(e.order),r=0;return forEachNodeInTopologicalOrder(e,e=>{n[r++]=e}),n}e.topologicalSort=topologicalSort})),l=e(((e,t)=>{let n=i();t.exports=function willCreateCycle(e,t,r){if(!n(e))throw Error(`graphology-dag/will-create-cycle: the given graph is not a valid graphology instance.`);if(t=``+t,r=``+r,t===r)return!0;if(!e.hasNode(t)||!e.hasNode(r)||e.hasDirectedEdge(t,r))return!1;if(e.hasDirectedEdge(r,t))return!0;let i=e.outNeighbors(r);function push(e){i.push(e)}for(;i.length!==0;){let n=i.pop();if(n===t)return!0;e.forEachOutNeighbor(n,push)}return!1}}));export{n as i,c as n,r,l as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";var e;function EventHandlers(){}EventHandlers.prototype=Object.create(null);function EventEmitter(){EventEmitter.init.call(this)}EventEmitter.EventEmitter=EventEmitter,EventEmitter.usingDomains=!1,EventEmitter.prototype.domain=void 0,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.init=function(){this.domain=null,EventEmitter.usingDomains&&e.active&&!(this instanceof e.Domain)&&(this.domain=e.active),(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new EventHandlers,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},EventEmitter.prototype.setMaxListeners=function setMaxListeners(e){if(typeof e!=`number`||e<0||isNaN(e))throw TypeError(`"n" argument must be a positive number`);return this._maxListeners=e,this};function $getMaxListeners(e){return e._maxListeners===void 0?EventEmitter.defaultMaxListeners:e._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return $getMaxListeners(this)};function emitNone(e,t,n){if(t)e.call(n);else for(var r=e.length,i=arrayClone(e,r),a=0;a<r;++a)i[a].call(n)}function emitOne(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=arrayClone(e,i),o=0;o<i;++o)a[o].call(n,r)}function emitTwo(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=arrayClone(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function emitThree(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=arrayClone(e,o),c=0;c<o;++c)s[c].call(n,r,i,a)}function emitMany(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=arrayClone(e,i),o=0;o<i;++o)a[o].apply(n,r)}EventEmitter.prototype.emit=function emit(e){var t,n,r,i,a,o,s,c=e===`error`;if(o=this._events,o)c&&=o.error==null;else if(!c)return!1;if(s=this.domain,c){if(t=arguments[1],s)t||=Error(`Uncaught, unspecified "error" event`),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit(`error`,t);else if(t instanceof Error)throw t;else{var l=Error(`Uncaught, unspecified "error" event. (`+t+`)`);throw l.context=t,l}return!1}if(n=o[e],!n)return!1;var u=typeof n==`function`;switch(r=arguments.length,r){case 1:emitNone(n,u,this);break;case 2:emitOne(n,u,this,arguments[1]);break;case 3:emitTwo(n,u,this,arguments[1],arguments[2]);break;case 4:emitThree(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];emitMany(n,u,this,i)}return!0};function _addListener(e,t,n,r){var i,a,o;if(typeof n!=`function`)throw TypeError(`"listener" argument must be a function`);if(a=e._events,a?(a.newListener&&(e.emit(`newListener`,t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new EventHandlers,e._eventsCount=0),!o)o=a[t]=n,++e._eventsCount;else if(typeof o==`function`?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=$getMaxListeners(e),i&&i>0&&o.length>i)){o.warned=!0;var s=Error(`Possible EventEmitter memory leak detected. `+o.length+` `+t+` listeners added. Use emitter.setMaxListeners() to increase limit`);s.name=`MaxListenersExceededWarning`,s.emitter=e,s.type=t,s.count=o.length,emitWarning(s)}return e}function emitWarning(e){typeof console.warn==`function`?console.warn(e):console.log(e)}EventEmitter.prototype.addListener=function addListener(e,t){return _addListener(this,e,t,!1)},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.prependListener=function prependListener(e,t){return _addListener(this,e,t,!0)};function _onceWrap(e,t,n){var r=!1;function g(){e.removeListener(t,g),r||(r=!0,n.apply(e,arguments))}return g.listener=n,g}EventEmitter.prototype.once=function once(e,t){if(typeof t!=`function`)throw TypeError(`"listener" argument must be a function`);return this.on(e,_onceWrap(this,e,t)),this},EventEmitter.prototype.prependOnceListener=function prependOnceListener(e,t){if(typeof t!=`function`)throw TypeError(`"listener" argument must be a function`);return this.prependListener(e,_onceWrap(this,e,t)),this},EventEmitter.prototype.removeListener=function removeListener(e,t){var n,r,i,a,o;if(typeof t!=`function`)throw TypeError(`"listener" argument must be a function`);if(r=this._events,!r||(n=r[e],!n))return this;if(n===t||n.listener&&n.listener===t)--this._eventsCount===0?this._events=new EventHandlers:(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length;a-->0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new EventHandlers,this;delete r[e]}else spliceOne(n,i);r.removeListener&&this.emit(`removeListener`,e,o||t)}return this},EventEmitter.prototype.off=function(e,t){return this.removeListener(e,t)},EventEmitter.prototype.removeAllListeners=function removeAllListeners(e){var t,n=this._events;if(!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new EventHandlers,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new EventHandlers:delete n[e]),this;if(arguments.length===0){for(var r=Object.keys(n),i=0,a;i<r.length;++i)a=r[i],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=new EventHandlers,this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t)do this.removeListener(e,t[t.length-1]);while(t[0]);return this},EventEmitter.prototype.listeners=function listeners(e){var t,n,r=this._events;return r?(t=r[e],n=t?typeof t==`function`?[t.listener||t]:unwrapListeners(t):[]):n=[],n},EventEmitter.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):listenerCount.call(e,t)},EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(e){var t=this._events;if(t){var n=t[e];if(typeof n==`function`)return 1;if(n)return n.length}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function spliceOne(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}function arrayClone(e,t){for(var n=Array(t);t--;)n[t]=e[t];return n}function unwrapListeners(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function assignPolyfill(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(let n in arguments[t])e[n]=arguments[t][n];return e}let t=assignPolyfill;typeof Object.assign==`function`&&(t=Object.assign);function getMatchingEdge(e,t,n,r){let i=e._nodes.get(t),a=null;return i&&(a=r===`mixed`?i.out&&i.out[n]||i.undirected&&i.undirected[n]:r===`directed`?i.out&&i.out[n]:i.undirected&&i.undirected[n]),a}function isPlainObject(e){return typeof e==`object`&&!!e}function isEmpty(e){let t;for(t in e)return!1;return!0}function privateProperty(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function readOnlyProperty(e,t,n){let r={enumerable:!0,configurable:!0};typeof n==`function`?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function validateHints(e){return!(!isPlainObject(e)||e.attributes&&!Array.isArray(e.attributes))}function incrementalIdStartingFromRandomByte(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function chain(){let e=arguments,t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function emptyIterator(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var GraphError=class extends Error{constructor(e){super(),this.name=`GraphError`,this.message=e}},n=class InvalidArgumentsGraphError extends GraphError{constructor(e){super(e),this.name=`InvalidArgumentsGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,InvalidArgumentsGraphError.prototype.constructor)}},r=class NotFoundGraphError extends GraphError{constructor(e){super(e),this.name=`NotFoundGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,NotFoundGraphError.prototype.constructor)}},i=class UsageGraphError extends GraphError{constructor(e){super(e),this.name=`UsageGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,UsageGraphError.prototype.constructor)}};function MixedNodeData(e,t){this.key=e,this.attributes=t,this.clear()}MixedNodeData.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function DirectedNodeData(e,t){this.key=e,this.attributes=t,this.clear()}DirectedNodeData.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function UndirectedNodeData(e,t){this.key=e,this.attributes=t,this.clear()}UndirectedNodeData.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function EdgeData(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}EdgeData.prototype.attach=function(){let e=`out`,t=`in`;this.undirected&&(e=t=`undirected`);let n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)},EdgeData.prototype.attachMulti=function(){let e=`out`,t=`in`,n=this.source.key,r=this.target.key;this.undirected&&(e=t=`undirected`);let i=this.source[e],a=i[r];if(a===void 0){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}a.previous=this,this.next=a,i[r]=this,this.target[t][n]=this},EdgeData.prototype.detach=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),delete this.source[n][t],delete this.target[r][e]},EdgeData.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};function findRelevantNodeData(e,t,n,i,a,o,s){let c,l,u,d;if(i=``+i,n===0){if(c=e._nodes.get(i),!c)throw new r(`Graph.${t}: could not find the "${i}" node in the graph.`);u=a,d=o}else if(n===3){if(a=``+a,l=e._edges.get(a),!l)throw new r(`Graph.${t}: could not find the "${a}" edge in the graph.`);let n=l.source.key,f=l.target.key;if(i===n)c=l.target;else if(i===f)c=l.source;else throw new r(`Graph.${t}: the "${i}" node is not attached to the "${a}" edge (${n}, ${f}).`);u=o,d=s}else{if(l=e._edges.get(i),!l)throw new r(`Graph.${t}: could not find the "${i}" edge in the graph.`);c=n===1?l.source:l.target,u=a,d=o}return[c,u,d]}function attachNodeAttributeGetter(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=findRelevantNodeData(this,t,n,e,r,i);return a.attributes[o]}}function attachNodeAttributesGetter(e,t,n){e.prototype[t]=function(e,r){let[i]=findRelevantNodeData(this,t,n,e,r);return i.attributes}}function attachNodeAttributeChecker(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=findRelevantNodeData(this,t,n,e,r,i);return a.attributes.hasOwnProperty(o)}}function attachNodeAttributeSetter(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=findRelevantNodeData(this,t,n,e,r,i,a);return o.attributes[s]=c,this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function attachNodeAttributeUpdater(e,t,r){e.prototype[t]=function(e,i,a,o){let[s,c,l]=findRelevantNodeData(this,t,r,e,i,a,o);if(typeof l!=`function`)throw new n(`Graph.${t}: updater should be a function.`);let u=s.attributes;return u[c]=l(u[c]),this.emit(`nodeAttributesUpdated`,{key:s.key,type:`set`,attributes:s.attributes,name:c}),this}}function attachNodeAttributeRemover(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=findRelevantNodeData(this,t,n,e,r,i);return delete a.attributes[o],this.emit(`nodeAttributesUpdated`,{key:a.key,type:`remove`,attributes:a.attributes,name:o}),this}}function attachNodeAttributesReplacer(e,t,r){e.prototype[t]=function(e,i,a){let[o,s]=findRelevantNodeData(this,t,r,e,i,a);if(!isPlainObject(s))throw new n(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=s,this.emit(`nodeAttributesUpdated`,{key:o.key,type:`replace`,attributes:o.attributes}),this}}function attachNodeAttributesMerger(e,r,i){e.prototype[r]=function(e,a,o){let[s,c]=findRelevantNodeData(this,r,i,e,a,o);if(!isPlainObject(c))throw new n(`Graph.${r}: provided attributes are not a plain object.`);return t(s.attributes,c),this.emit(`nodeAttributesUpdated`,{key:s.key,type:`merge`,attributes:s.attributes,data:c}),this}}function attachNodeAttributesUpdater(e,t,r){e.prototype[t]=function(e,i,a){let[o,s]=findRelevantNodeData(this,t,r,e,i,a);if(typeof s!=`function`)throw new n(`Graph.${t}: provided updater is not a function.`);return o.attributes=s(o.attributes),this.emit(`nodeAttributesUpdated`,{key:o.key,type:`update`,attributes:o.attributes}),this}}const a=[{name:e=>`get${e}Attribute`,attacher:attachNodeAttributeGetter},{name:e=>`get${e}Attributes`,attacher:attachNodeAttributesGetter},{name:e=>`has${e}Attribute`,attacher:attachNodeAttributeChecker},{name:e=>`set${e}Attribute`,attacher:attachNodeAttributeSetter},{name:e=>`update${e}Attribute`,attacher:attachNodeAttributeUpdater},{name:e=>`remove${e}Attribute`,attacher:attachNodeAttributeRemover},{name:e=>`replace${e}Attributes`,attacher:attachNodeAttributesReplacer},{name:e=>`merge${e}Attributes`,attacher:attachNodeAttributesMerger},{name:e=>`update${e}Attributes`,attacher:attachNodeAttributesUpdater}];function attachNodeAttributesMethods(e){a.forEach(function({name:t,attacher:n}){n(e,t(`Node`),0),n(e,t(`Source`),1),n(e,t(`Target`),2),n(e,t(`Opposite`),3)})}function attachEdgeAttributeGetter(e,t,n){e.prototype[t]=function(e,a){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new i(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new i(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=``+e,c=``+a;if(a=arguments[2],o=getMatchingEdge(this,s,c,n),!o)throw new r(`Graph.${t}: could not find an edge for the given path ("${s}" - "${c}").`)}else{if(n!==`mixed`)throw new i(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,o=this._edges.get(e),!o)throw new r(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return o.attributes[a]}}function attachEdgeAttributesGetter(e,t,n){e.prototype[t]=function(e){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new i(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new i(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=``+e,s=``+arguments[1];if(a=getMatchingEdge(this,o,s,n),!a)throw new r(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new i(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,a=this._edges.get(e),!a)throw new r(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return a.attributes}}function attachEdgeAttributeChecker(e,t,n){e.prototype[t]=function(e,a){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new i(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new i(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=``+e,c=``+a;if(a=arguments[2],o=getMatchingEdge(this,s,c,n),!o)throw new r(`Graph.${t}: could not find an edge for the given path ("${s}" - "${c}").`)}else{if(n!==`mixed`)throw new i(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,o=this._edges.get(e),!o)throw new r(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return o.attributes.hasOwnProperty(a)}}function attachEdgeAttributeSetter(e,t,n){e.prototype[t]=function(e,a,o){let s;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new i(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new i(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let c=``+e,l=``+a;if(a=arguments[2],o=arguments[3],s=getMatchingEdge(this,c,l,n),!s)throw new r(`Graph.${t}: could not find an edge for the given path ("${c}" - "${l}").`)}else{if(n!==`mixed`)throw new i(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,s=this._edges.get(e),!s)throw new r(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return s.attributes[a]=o,this.emit(`edgeAttributesUpdated`,{key:s.key,type:`set`,attributes:s.attributes,name:a}),this}}function attachEdgeAttributeUpdater(e,t,a){e.prototype[t]=function(e,o,s){let c;if(this.type!==`mixed`&&a!==`mixed`&&a!==this.type)throw new i(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new i(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let n=``+e,l=``+o;if(o=arguments[2],s=arguments[3],c=getMatchingEdge(this,n,l,a),!c)throw new r(`Graph.${t}: could not find an edge for the given path ("${n}" - "${l}").`)}else{if(a!==`mixed`)throw new i(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,c=this._edges.get(e),!c)throw new r(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof s!=`function`)throw new n(`Graph.${t}: updater should be a function.`);return c.attributes[o]=s(c.attributes[o]),this.emit(`edgeAttributesUpdated`,{key:c.key,type:`set`,attributes:c.attributes,name:o}),this}}function attachEdgeAttributeRemover(e,t,n){e.prototype[t]=function(e,a){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new i(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new i(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=``+e,c=``+a;if(a=arguments[2],o=getMatchingEdge(this,s,c,n),!o)throw new r(`Graph.${t}: could not find an edge for the given path ("${s}" - "${c}").`)}else{if(n!==`mixed`)throw new i(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,o=this._edges.get(e),!o)throw new r(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return delete o.attributes[a],this.emit(`edgeAttributesUpdated`,{key:o.key,type:`remove`,attributes:o.attributes,name:a}),this}}function attachEdgeAttributesReplacer(e,t,a){e.prototype[t]=function(e,o){let s;if(this.type!==`mixed`&&a!==`mixed`&&a!==this.type)throw new i(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new i(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let n=``+e,c=``+o;if(o=arguments[2],s=getMatchingEdge(this,n,c,a),!s)throw new r(`Graph.${t}: could not find an edge for the given path ("${n}" - "${c}").`)}else{if(a!==`mixed`)throw new i(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,s=this._edges.get(e),!s)throw new r(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!isPlainObject(o))throw new n(`Graph.${t}: provided attributes are not a plain object.`);return s.attributes=o,this.emit(`edgeAttributesUpdated`,{key:s.key,type:`replace`,attributes:s.attributes}),this}}function attachEdgeAttributesMerger(e,a,o){e.prototype[a]=function(e,s){let c;if(this.type!==`mixed`&&o!==`mixed`&&o!==this.type)throw new i(`Graph.${a}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new i(`Graph.${a}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let t=``+e,n=``+s;if(s=arguments[2],c=getMatchingEdge(this,t,n,o),!c)throw new r(`Graph.${a}: could not find an edge for the given path ("${t}" - "${n}").`)}else{if(o!==`mixed`)throw new i(`Graph.${a}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,c=this._edges.get(e),!c)throw new r(`Graph.${a}: could not find the "${e}" edge in the graph.`)}if(!isPlainObject(s))throw new n(`Graph.${a}: provided attributes are not a plain object.`);return t(c.attributes,s),this.emit(`edgeAttributesUpdated`,{key:c.key,type:`merge`,attributes:c.attributes,data:s}),this}}function attachEdgeAttributesUpdater(e,t,a){e.prototype[t]=function(e,o){let s;if(this.type!==`mixed`&&a!==`mixed`&&a!==this.type)throw new i(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new i(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let n=``+e,c=``+o;if(o=arguments[2],s=getMatchingEdge(this,n,c,a),!s)throw new r(`Graph.${t}: could not find an edge for the given path ("${n}" - "${c}").`)}else{if(a!==`mixed`)throw new i(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,s=this._edges.get(e),!s)throw new r(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof o!=`function`)throw new n(`Graph.${t}: provided updater is not a function.`);return s.attributes=o(s.attributes),this.emit(`edgeAttributesUpdated`,{key:s.key,type:`update`,attributes:s.attributes}),this}}const o=[{name:e=>`get${e}Attribute`,attacher:attachEdgeAttributeGetter},{name:e=>`get${e}Attributes`,attacher:attachEdgeAttributesGetter},{name:e=>`has${e}Attribute`,attacher:attachEdgeAttributeChecker},{name:e=>`set${e}Attribute`,attacher:attachEdgeAttributeSetter},{name:e=>`update${e}Attribute`,attacher:attachEdgeAttributeUpdater},{name:e=>`remove${e}Attribute`,attacher:attachEdgeAttributeRemover},{name:e=>`replace${e}Attributes`,attacher:attachEdgeAttributesReplacer},{name:e=>`merge${e}Attributes`,attacher:attachEdgeAttributesMerger},{name:e=>`update${e}Attributes`,attacher:attachEdgeAttributesUpdater}];function attachEdgeAttributesMethods(e){o.forEach(function({name:t,attacher:n}){n(e,t(`Edge`),`mixed`),n(e,t(`DirectedEdge`),`directed`),n(e,t(`UndirectedEdge`),`undirected`)})}const s=[{name:`edges`,type:`mixed`},{name:`inEdges`,type:`directed`,direction:`in`},{name:`outEdges`,type:`directed`,direction:`out`},{name:`inboundEdges`,type:`mixed`,direction:`in`},{name:`outboundEdges`,type:`mixed`,direction:`out`},{name:`directedEdges`,type:`directed`},{name:`undirectedEdges`,type:`undirected`}];function forEachSimple(e,t,n,r){let i=!1;for(let a in t){if(a===r)continue;let o=t[a];if(i=n(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&i)return o.key}}function forEachMulti(e,t,n,r){let i,a,o,s=!1;for(let c in t)if(c!==r){i=t[c];do{if(a=i.source,o=i.target,s=n(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),e&&s)return i.key;i=i.next}while(i!==void 0)}}function createIterator(e,t){let n=Object.keys(e),r=n.length,i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=r)return{done:!0};let o=n[a++];if(o===t){i=void 0;continue}i=e[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function forEachForKeySimple(e,t,n,r){let i=t[n];if(!i)return;let a=i.source,o=i.target;if(r(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&e)return i.key}function forEachForKeyMulti(e,t,n,r){let i=t[n];if(!i)return;let a=!1;do{if(a=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}function createIteratorForKey(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let e={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:e}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function createEdgeArray(e,t){if(e.size===0)return[];if(t===`mixed`||t===e.type)return Array.from(e._edges.keys());let n=t===`undirected`?e.undirectedSize:e.directedSize,r=Array(n),i=t===`undirected`,a=e._edges.values(),o=0,s,c;for(;s=a.next(),s.done!==!0;)c=s.value,c.undirected===i&&(r[o++]=c.key);return r}function forEachEdge(e,t,n,r){if(t.size===0)return;let i=n!==`mixed`&&n!==t.type,a=n===`undirected`,o,s,c=!1,l=t._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;let{key:t,attributes:n,source:l,target:u}=s;if(c=r(t,n,l.key,u.key,l.attributes,u.attributes,s.undirected),e&&c)return t}}function createEdgeIterator(e,t){if(e.size===0)return emptyIterator();let n=t!==`mixed`&&t!==e.type,r=t===`undirected`,i=e._edges.values();return{[Symbol.iterator](){return this},next(){let e,t;for(;;){if(e=i.next(),e.done)return e;if(t=e.value,!(n&&t.undirected!==r))break}return{value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected},done:!1}}}}function forEachEdgeForNode(e,t,n,r,i,a){let o=t?forEachMulti:forEachSimple,s;if(n!==`undirected`&&(r!==`out`&&(s=o(e,i.in,a),e&&s)||r!==`in`&&(s=o(e,i.out,a,r?void 0:i.key),e&&s))||n!==`directed`&&(s=o(e,i.undirected,a),e&&s))return s}function createEdgeArrayForNode(e,t,n,r){let i=[];return forEachEdgeForNode(!1,e,t,n,r,function(e){i.push(e)}),i}function createEdgeIteratorForNode(e,t,n){let r=emptyIterator();return e!==`undirected`&&(t!==`out`&&n.in!==void 0&&(r=chain(r,createIterator(n.in))),t!==`in`&&n.out!==void 0&&(r=chain(r,createIterator(n.out,t?void 0:n.key)))),e!==`directed`&&n.undirected!==void 0&&(r=chain(r,createIterator(n.undirected))),r}function forEachEdgeForPath(e,t,n,r,i,a,o){let s=n?forEachForKeyMulti:forEachForKeySimple,c;if(t!==`undirected`&&(i.in!==void 0&&r!==`out`&&(c=s(e,i.in,a,o),e&&c)||i.out!==void 0&&r!==`in`&&(r||i.key!==a)&&(c=s(e,i.out,a,o),e&&c))||t!==`directed`&&i.undirected!==void 0&&(c=s(e,i.undirected,a,o),e&&c))return c}function createEdgeArrayForPath(e,t,n,r,i){let a=[];return forEachEdgeForPath(!1,e,t,n,r,i,function(e){a.push(e)}),a}function createEdgeIteratorForPath(e,t,n,r){let i=emptyIterator();return e!==`undirected`&&(n.in!==void 0&&t!==`out`&&r in n.in&&(i=chain(i,createIteratorForKey(n.in,r))),n.out!==void 0&&t!==`in`&&r in n.out&&(t||n.key!==r)&&(i=chain(i,createIteratorForKey(n.out,r)))),e!==`directed`&&n.undirected!==void 0&&r in n.undirected&&(i=chain(i,createIteratorForKey(n.undirected,r))),i}function attachEdgeArrayCreator(e,t){let{name:i,type:a,direction:o}=t;e.prototype[i]=function(e,t){if(a!==`mixed`&&this.type!==`mixed`&&a!==this.type)return[];if(!arguments.length)return createEdgeArray(this,a);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new r(`Graph.${i}: could not find the "${e}" node in the graph.`);return createEdgeArrayForNode(this.multi,a===`mixed`?this.type:a,o,t)}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.${i}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new r(`Graph.${i}: could not find the "${t}" target node in the graph.`);return createEdgeArrayForPath(a,this.multi,o,n,t)}throw new n(`Graph.${i}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function attachForEachEdge(e,t){let{name:i,type:a,direction:o}=t,s=`forEach`+i[0].toUpperCase()+i.slice(1,-1);e.prototype[s]=function(e,t,i){if(a===`mixed`||this.type===`mixed`||a===this.type){if(arguments.length===1)return i=e,forEachEdge(!1,this,a,i);if(arguments.length===2){e=``+e,i=t;let n=this._nodes.get(e);if(n===void 0)throw new r(`Graph.${s}: could not find the "${e}" node in the graph.`);return forEachEdgeForNode(!1,this.multi,a===`mixed`?this.type:a,o,n,i)}if(arguments.length===3){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.${s}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new r(`Graph.${s}: could not find the "${t}" target node in the graph.`);return forEachEdgeForPath(!1,a,this.multi,o,n,t,i)}throw new n(`Graph.${s}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let c=`map`+i[0].toUpperCase()+i.slice(1);e.prototype[c]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n;if(e.length===0){let r=0;a!==`directed`&&(r+=this.undirectedSize),a!==`undirected`&&(r+=this.directedSize),n=Array(r);let i=0;e.push((e,r,a,o,s,c,l)=>{n[i++]=t(e,r,a,o,s,c,l)})}else n=[],e.push((e,r,i,a,o,s,c)=>{n.push(t(e,r,i,a,o,s,c))});return this[s].apply(this,e),n};let l=`filter`+i[0].toUpperCase()+i.slice(1);e.prototype[l]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n=[];return e.push((e,r,i,a,o,s,c)=>{t(e,r,i,a,o,s,c)&&n.push(e)}),this[s].apply(this,e),n};let u=`reduce`+i[0].toUpperCase()+i.slice(1);e.prototype[u]=function(){let e=Array.prototype.slice.call(arguments);if(e.length<2||e.length>4)throw new n(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${e.length}).`);if(typeof e[e.length-1]==`function`&&typeof e[e.length-2]!=`function`)throw new n(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let t,r;e.length===2?(t=e[0],r=e[1],e=[]):e.length===3?(t=e[1],r=e[2],e=[e[0]]):e.length===4&&(t=e[2],r=e[3],e=[e[0],e[1]]);let i=r;return e.push((e,n,r,a,o,s,c)=>{i=t(i,e,n,r,a,o,s,c)}),this[s].apply(this,e),i}}function attachFindEdge(e,t){let{name:i,type:a,direction:o}=t,s=`find`+i[0].toUpperCase()+i.slice(1,-1);e.prototype[s]=function(e,t,i){if(a!==`mixed`&&this.type!==`mixed`&&a!==this.type)return!1;if(arguments.length===1)return i=e,forEachEdge(!0,this,a,i);if(arguments.length===2){e=``+e,i=t;let n=this._nodes.get(e);if(n===void 0)throw new r(`Graph.${s}: could not find the "${e}" node in the graph.`);return forEachEdgeForNode(!0,this.multi,a===`mixed`?this.type:a,o,n,i)}if(arguments.length===3){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.${s}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new r(`Graph.${s}: could not find the "${t}" target node in the graph.`);return forEachEdgeForPath(!0,a,this.multi,o,n,t,i)}throw new n(`Graph.${s}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let c=`some`+i[0].toUpperCase()+i.slice(1,-1);e.prototype[c]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>t(e,n,r,i,a,o,s)),!!this[s].apply(this,e)};let l=`every`+i[0].toUpperCase()+i.slice(1,-1);e.prototype[l]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>!t(e,n,r,i,a,o,s)),!this[s].apply(this,e)}}function attachEdgeIteratorCreator(e,t){let{name:i,type:a,direction:o}=t,s=i.slice(0,-1)+`Entries`;e.prototype[s]=function(e,t){if(a!==`mixed`&&this.type!==`mixed`&&a!==this.type)return emptyIterator();if(!arguments.length)return createEdgeIterator(this,a);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.${s}: could not find the "${e}" node in the graph.`);return createEdgeIteratorForNode(a,o,t)}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.${s}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new r(`Graph.${s}: could not find the "${t}" target node in the graph.`);return createEdgeIteratorForPath(a,o,n,t)}throw new n(`Graph.${s}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function attachEdgeIterationMethods(e){s.forEach(t=>{attachEdgeArrayCreator(e,t),attachForEachEdge(e,t),attachFindEdge(e,t),attachEdgeIteratorCreator(e,t)})}const c=[{name:`neighbors`,type:`mixed`},{name:`inNeighbors`,type:`directed`,direction:`in`},{name:`outNeighbors`,type:`directed`,direction:`out`},{name:`inboundNeighbors`,type:`mixed`,direction:`in`},{name:`outboundNeighbors`,type:`mixed`,direction:`out`},{name:`directedNeighbors`,type:`directed`},{name:`undirectedNeighbors`,type:`undirected`}];function CompositeSetWrapper(){this.A=null,this.B=null}CompositeSetWrapper.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)},CompositeSetWrapper.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function forEachInObjectOnce(e,t,n,r,i){for(let a in r){let o=r[a],s=o.source,c=o.target,l=s===n?c:s;if(t&&t.has(l.key))continue;let u=i(l.key,l.attributes);if(e&&u)return l.key}}function forEachNeighbor(e,t,n,r,i){if(t!==`mixed`){if(t===`undirected`)return forEachInObjectOnce(e,null,r,r.undirected,i);if(typeof n==`string`)return forEachInObjectOnce(e,null,r,r[n],i)}let a=new CompositeSetWrapper,o;if(t!==`undirected`){if(n!==`out`){if(o=forEachInObjectOnce(e,null,r,r.in,i),e&&o)return o;a.wrap(r.in)}if(n!==`in`){if(o=forEachInObjectOnce(e,a,r,r.out,i),e&&o)return o;a.wrap(r.out)}}if(t!==`directed`&&(o=forEachInObjectOnce(e,a,r,r.undirected,i),e&&o))return o}function createNeighborArrayForNode(e,t,n){if(e!==`mixed`){if(e===`undirected`)return Object.keys(n.undirected);if(typeof t==`string`)return Object.keys(n[t])}let r=[];return forEachNeighbor(!1,e,t,n,function(e){r.push(e)}),r}function createDedupedObjectIterator(e,t,n){let r=Object.keys(n),i=r.length,a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return e&&e.wrap(n),{done:!0};let s=n[r[a++]],c=s.source,l=s.target;if(o=c===t?l:c,e&&e.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function createNeighborIterator(e,t,n){if(e!==`mixed`){if(e===`undirected`)return createDedupedObjectIterator(null,n,n.undirected);if(typeof t==`string`)return createDedupedObjectIterator(null,n,n[t])}let r=emptyIterator(),i=new CompositeSetWrapper;return e!==`undirected`&&(t!==`out`&&(r=chain(r,createDedupedObjectIterator(i,n,n.in))),t!==`in`&&(r=chain(r,createDedupedObjectIterator(i,n,n.out)))),e!==`directed`&&(r=chain(r,createDedupedObjectIterator(i,n,n.undirected))),r}function attachNeighborArrayCreator(e,t){let{name:n,type:i,direction:a}=t;e.prototype[n]=function(e){if(i!==`mixed`&&this.type!==`mixed`&&i!==this.type)return[];e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new r(`Graph.${n}: could not find the "${e}" node in the graph.`);return createNeighborArrayForNode(i===`mixed`?this.type:i,a,t)}}function attachForEachNeighbor(e,t){let{name:i,type:a,direction:o}=t,s=`forEach`+i[0].toUpperCase()+i.slice(1,-1);e.prototype[s]=function(e,t){if(a!==`mixed`&&this.type!==`mixed`&&a!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new r(`Graph.${s}: could not find the "${e}" node in the graph.`);forEachNeighbor(!1,a===`mixed`?this.type:a,o,n,t)};let c=`map`+i[0].toUpperCase()+i.slice(1);e.prototype[c]=function(e,t){let n=[];return this[s](e,(e,r)=>{n.push(t(e,r))}),n};let l=`filter`+i[0].toUpperCase()+i.slice(1);e.prototype[l]=function(e,t){let n=[];return this[s](e,(e,r)=>{t(e,r)&&n.push(e)}),n};let u=`reduce`+i[0].toUpperCase()+i.slice(1);e.prototype[u]=function(e,t,r){if(arguments.length<3)throw new n(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let i=r;return this[s](e,(e,n)=>{i=t(i,e,n)}),i}}function attachFindNeighbor(e,t){let{name:n,type:i,direction:a}=t,o=n[0].toUpperCase()+n.slice(1,-1),s=`find`+o;e.prototype[s]=function(e,t){if(i!==`mixed`&&this.type!==`mixed`&&i!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new r(`Graph.${s}: could not find the "${e}" node in the graph.`);return forEachNeighbor(!0,i===`mixed`?this.type:i,a,n,t)};let c=`some`+o;e.prototype[c]=function(e,t){return!!this[s](e,t)};let l=`every`+o;e.prototype[l]=function(e,t){return!this[s](e,(e,n)=>!t(e,n))}}function attachNeighborIteratorCreator(e,t){let{name:n,type:i,direction:a}=t,o=n.slice(0,-1)+`Entries`;e.prototype[o]=function(e){if(i!==`mixed`&&this.type!==`mixed`&&i!==this.type)return emptyIterator();e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new r(`Graph.${o}: could not find the "${e}" node in the graph.`);return createNeighborIterator(i===`mixed`?this.type:i,a,t)}}function attachNeighborIterationMethods(e){c.forEach(t=>{attachNeighborArrayCreator(e,t),attachForEachNeighbor(e,t),attachFindNeighbor(e,t),attachNeighborIteratorCreator(e,t)})}function forEachAdjacency(e,t,n,r,i){let a=r._nodes.values(),o=r.type,s,c,l,u,d,f,p;for(;s=a.next(),s.done!==!0;){let r=!1;if(c=s.value,o!==`undirected`)for(l in u=c.out,u){d=u[l];do{if(f=d.target,r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}if(o!==`directed`){for(l in u=c.undirected,u)if(!(t&&c.key>l)){d=u[l];do{if(f=d.target,f.key!==l&&(f=d.source),r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}}if(n&&!r&&(p=i(c.key,null,c.attributes,null,null,null,null),e&&p))return null}}function serializeNode(e,n){let r={key:e};return isEmpty(n.attributes)||(r.attributes=t({},n.attributes)),r}function serializeEdge(e,n,r){let i={key:n,source:r.source.key,target:r.target.key};return isEmpty(r.attributes)||(i.attributes=t({},r.attributes)),e===`mixed`&&r.undirected&&(i.undirected=!0),i}function validateSerializedNode(e){if(!isPlainObject(e))throw new n(`Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.`);if(!(`key`in e))throw new n(`Graph.import: serialized node is missing its key.`);if(`attributes`in e&&(!isPlainObject(e.attributes)||e.attributes===null))throw new n(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`)}function validateSerializedEdge(e){if(!isPlainObject(e))throw new n(`Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.`);if(!(`source`in e))throw new n(`Graph.import: serialized edge is missing its source.`);if(!(`target`in e))throw new n(`Graph.import: serialized edge is missing its target.`);if(`attributes`in e&&(!isPlainObject(e.attributes)||e.attributes===null))throw new n(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`);if(`undirected`in e&&typeof e.undirected!=`boolean`)throw new n(`Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.`)}const l=incrementalIdStartingFromRandomByte(),u=new Set([`directed`,`undirected`,`mixed`]),d=new Set([`domain`,`_events`,`_eventsCount`,`_maxListeners`]),f=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:`directed`},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:`undirected`},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:`directed`},{name:e=>`${e}UndirectedEdgeWithKey`,type:`undirected`}],p={allowSelfLoops:!0,multi:!1,type:`mixed`};function addNode(e,t,r){if(r&&!isPlainObject(r))throw new n(`Graph.addNode: invalid attributes. Expecting an object but got "${r}"`);if(t=``+t,r||={},e._nodes.has(t))throw new i(`Graph.addNode: the "${t}" node already exist in the graph.`);let a=new e.NodeDataClass(t,r);return e._nodes.set(t,a),e.emit(`nodeAdded`,{key:t,attributes:r}),a}function unsafeAddNode(e,t,n){let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function addEdge(e,t,a,o,s,c,l,u){if(!o&&e.type===`undirected`)throw new i(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(o&&e.type===`directed`)throw new i(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(u&&!isPlainObject(u))throw new n(`Graph.${t}: invalid attributes. Expecting an object but got "${u}"`);if(c=``+c,l=``+l,u||={},!e.allowSelfLoops&&c===l)throw new i(`Graph.${t}: source & target are the same ("${c}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=e._nodes.get(c),f=e._nodes.get(l);if(!d)throw new r(`Graph.${t}: source node "${c}" not found.`);if(!f)throw new r(`Graph.${t}: target node "${l}" not found.`);let p={key:null,undirected:o,source:c,target:l,attributes:u};if(a)s=e._edgeKeyGenerator();else if(s=``+s,e._edges.has(s))throw new i(`Graph.${t}: the "${s}" edge already exists in the graph.`);if(!e.multi&&(o?d.undirected[l]!==void 0:d.out[l]!==void 0))throw new i(`Graph.${t}: an edge linking "${c}" to "${l}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let m=new EdgeData(o,s,d,f,u);e._edges.set(s,m);let h=c===l;return o?(d.undirectedDegree++,f.undirectedDegree++,h&&(d.undirectedLoops++,e._undirectedSelfLoopCount++)):(d.outDegree++,f.inDegree++,h&&(d.directedLoops++,e._directedSelfLoopCount++)),e.multi?m.attachMulti():m.attach(),o?e._undirectedSize++:e._directedSize++,p.key=s,e.emit(`edgeAdded`,p),s}function mergeEdge(e,r,a,o,s,c,l,u,d){if(!o&&e.type===`undirected`)throw new i(`Graph.${r}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(o&&e.type===`directed`)throw new i(`Graph.${r}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(u){if(d){if(typeof u!=`function`)throw new n(`Graph.${r}: invalid updater function. Expecting a function but got "${u}"`)}else if(!isPlainObject(u))throw new n(`Graph.${r}: invalid attributes. Expecting an object but got "${u}"`)}c=``+c,l=``+l;let f;if(d&&(f=u,u=void 0),!e.allowSelfLoops&&c===l)throw new i(`Graph.${r}: source & target are the same ("${c}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let p=e._nodes.get(c),m=e._nodes.get(l),h,_;if(!a&&(h=e._edges.get(s),h)){if((h.source.key!==c||h.target.key!==l)&&(!o||h.source.key!==l||h.target.key!==c))throw new i(`Graph.${r}: inconsistency detected when attempting to merge the "${s}" edge with "${c}" source & "${l}" target vs. ("${h.source.key}", "${h.target.key}").`);_=h}if(!_&&!e.multi&&p&&(_=o?p.undirected[l]:p.out[l]),_){let n=[_.key,!1,!1,!1];if(d?!f:!u)return n;if(d){let t=_.attributes;_.attributes=f(t),e.emit(`edgeAttributesUpdated`,{type:`replace`,key:_.key,attributes:_.attributes})}else t(_.attributes,u),e.emit(`edgeAttributesUpdated`,{type:`merge`,key:_.key,attributes:_.attributes,data:u});return n}u||={},d&&f&&(u=f(u));let v={key:null,undirected:o,source:c,target:l,attributes:u};if(a)s=e._edgeKeyGenerator();else if(s=``+s,e._edges.has(s))throw new i(`Graph.${r}: the "${s}" edge already exists in the graph.`);let y=!1,b=!1;p||(p=unsafeAddNode(e,c,{}),y=!0,c===l&&(m=p,b=!0)),m||(m=unsafeAddNode(e,l,{}),b=!0),h=new EdgeData(o,s,p,m,u),e._edges.set(s,h);let x=c===l;return o?(p.undirectedDegree++,m.undirectedDegree++,x&&(p.undirectedLoops++,e._undirectedSelfLoopCount++)):(p.outDegree++,m.inDegree++,x&&(p.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),o?e._undirectedSize++:e._directedSize++,v.key=s,e.emit(`edgeAdded`,v),[s,!0,y,b]}function dropEdgeFromData(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,a=t.undirected,o=n===r;a?(n.undirectedDegree--,r.undirectedDegree--,o&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,o&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),a?e._undirectedSize--:e._directedSize--,e.emit(`edgeDropped`,{key:t.key,attributes:i,source:n.key,target:r.key,undirected:a})}var m=class Graph extends EventEmitter{constructor(e){if(super(),e=t({},p,e),typeof e.multi!=`boolean`)throw new n(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!u.has(e.type))throw new n(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!=`boolean`)throw new n(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let r=e.type===`mixed`?MixedNodeData:e.type===`directed`?DirectedNodeData:UndirectedNodeData;privateProperty(this,`NodeDataClass`,r);let i=`geid_`+l()+`_`,a=0,edgeKeyGenerator=()=>{let e;do e=i+a++;while(this._edges.has(e));return e};privateProperty(this,`_attributes`,{}),privateProperty(this,`_nodes`,new Map),privateProperty(this,`_edges`,new Map),privateProperty(this,`_directedSize`,0),privateProperty(this,`_undirectedSize`,0),privateProperty(this,`_directedSelfLoopCount`,0),privateProperty(this,`_undirectedSelfLoopCount`,0),privateProperty(this,`_edgeKeyGenerator`,edgeKeyGenerator),privateProperty(this,`_options`,e),d.forEach(e=>privateProperty(this,e,this[e])),readOnlyProperty(this,`order`,()=>this._nodes.size),readOnlyProperty(this,`size`,()=>this._edges.size),readOnlyProperty(this,`directedSize`,()=>this._directedSize),readOnlyProperty(this,`undirectedSize`,()=>this._undirectedSize),readOnlyProperty(this,`selfLoopCount`,()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),readOnlyProperty(this,`directedSelfLoopCount`,()=>this._directedSelfLoopCount),readOnlyProperty(this,`undirectedSelfLoopCount`,()=>this._undirectedSelfLoopCount),readOnlyProperty(this,`multi`,this._options.multi),readOnlyProperty(this,`type`,this._options.type),readOnlyProperty(this,`allowSelfLoops`,this._options.allowSelfLoops),readOnlyProperty(this,`implementation`,()=>`graphology`)}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(``+e)}hasDirectedEdge(e,t){if(this.type===`undirected`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&!n.undirected}else if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new n(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type===`directed`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&n.undirected}else if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new n(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){let t=``+e;return this._edges.has(t)}else if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out!==void 0&&n.out.hasOwnProperty(t)||n.undirected!==void 0&&n.undirected.hasOwnProperty(t):!1}throw new n(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type===`undirected`)return;if(e=``+e,t=``+t,this.multi)throw new i(`Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new r(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new r(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);let a=n.out&&n.out[t]||void 0;if(a)return a.key}undirectedEdge(e,t){if(this.type===`directed`)return;if(e=``+e,t=``+t,this.multi)throw new i(`Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new r(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new r(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);let a=n.undirected&&n.undirected[t]||void 0;if(a)return a.key}edge(e,t){if(this.multi)throw new i(`Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.`);e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new r(`Graph.edge: could not find the "${t}" target node in the graph.`);let a=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(a)return a.key}areDirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type===`undirected`?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.out}areInNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.in}areUndirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`directed`&&t in n.undirected}areNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&(t in n.in||t in n.out)||this.type!==`directed`&&t in n.undirected}areInboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.in||this.type!==`directed`&&t in n.undirected}areOutboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new r(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.out||this.type!==`directed`&&t in n.undirected}inDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree}outDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree}directedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree}undirectedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree}inboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree),n}outboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.outDegree),n}degree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!==`directed`&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree,i+=t.directedLoops),n-i}outboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!==`directed`&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.outDegree,i+=t.directedLoops),n-i}degreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!==`directed`&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree,i+=t.directedLoops*2),n-i}source(e){e=``+e;let t=this._edges.get(e);if(!t)throw new r(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=``+e;let t=this._edges.get(e);if(!t)throw new r(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=``+e;let t=this._edges.get(e);if(!t)throw new r(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=``+e,t=``+t;let n=this._edges.get(t);if(!n)throw new r(`Graph.opposite: could not find the "${t}" edge in the graph.`);let i=n.source.key,a=n.target.key;if(e===i)return a;if(e===a)return i;throw new r(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${i}, ${a}).`)}hasExtremity(e,t){e=``+e,t=``+t;let n=this._edges.get(e);if(!n)throw new r(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new r(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new r(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=``+e;let t=this._edges.get(e);if(!t)throw new r(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return addNode(this,e,t).key}mergeNode(e,r){if(r&&!isPlainObject(r))throw new n(`Graph.mergeNode: invalid attributes. Expecting an object but got "${r}"`);e=``+e,r||={};let i=this._nodes.get(e);return i?(r&&(t(i.attributes,r),this.emit(`nodeAttributesUpdated`,{type:`merge`,key:e,attributes:i.attributes,data:r})),[e,!1]):(i=new this.NodeDataClass(e,r),this._nodes.set(e,i),this.emit(`nodeAdded`,{key:e,attributes:r}),[e,!0])}updateNode(e,t){if(t&&typeof t!=`function`)throw new n(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=``+e;let r=this._nodes.get(e);if(r){if(t){let n=r.attributes;r.attributes=t(n),this.emit(`nodeAttributesUpdated`,{type:`replace`,key:e,attributes:r.attributes})}return[e,!1]}let i=t?t({}):{};return r=new this.NodeDataClass(e,i),this._nodes.set(e,r),this.emit(`nodeAdded`,{key:e,attributes:i}),[e,!0]}dropNode(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new r(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!==`undirected`){for(let e in t.out){n=t.out[e];do dropEdgeFromData(this,n),n=n.next;while(n)}for(let e in t.in){n=t.in[e];do dropEdgeFromData(this,n),n=n.next;while(n)}}if(this.type!==`directed`)for(let e in t.undirected){n=t.undirected[e];do dropEdgeFromData(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit(`nodeDropped`,{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){let e=``+arguments[0],n=``+arguments[1];if(t=getMatchingEdge(this,e,n,this.type),!t)throw new r(`Graph.dropEdge: could not find the "${e}" -> "${n}" edge in the graph.`)}else if(e=``+e,t=this._edges.get(e),!t)throw new r(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return dropEdgeFromData(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new i(`Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.`);if(this.multi)throw new i(`Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.`);e=``+e,t=``+t;let n=getMatchingEdge(this,e,t,`directed`);if(!n)throw new r(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return dropEdgeFromData(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new i(`Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.`);if(this.multi)throw new i(`Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.`);let n=getMatchingEdge(this,e,t,`undirected`);if(!n)throw new r(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return dropEdgeFromData(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit(`cleared`)}clearEdges(){let e=this._nodes.values(),t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit(`edgesCleared`)}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!=`function`)throw new n(`Graph.updateAttribute: updater should be a function.`);let r=this._attributes[e];return this._attributes[e]=t(r),this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit(`attributesUpdated`,{type:`remove`,attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!isPlainObject(e))throw new n(`Graph.replaceAttributes: provided attributes are not a plain object.`);return this._attributes=e,this.emit(`attributesUpdated`,{type:`replace`,attributes:this._attributes}),this}mergeAttributes(e){if(!isPlainObject(e))throw new n(`Graph.mergeAttributes: provided attributes are not a plain object.`);return t(this._attributes,e),this.emit(`attributesUpdated`,{type:`merge`,attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!=`function`)throw new n(`Graph.updateAttributes: provided updater is not a function.`);return this._attributes=e(this._attributes),this.emit(`attributesUpdated`,{type:`update`,attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!=`function`)throw new n(`Graph.updateEachNodeAttributes: expecting an updater function.`);if(t&&!validateHints(t))throw new n(`Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let r=this._nodes.values(),i,a;for(;i=r.next(),i.done!==!0;)a=i.value,a.attributes=e(a.key,a.attributes);this.emit(`eachNodeAttributesUpdated`,{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!=`function`)throw new n(`Graph.updateEachEdgeAttributes: expecting an updater function.`);if(t&&!validateHints(t))throw new n(`Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let r=this._edges.values(),i,a,o,s;for(;i=r.next(),i.done!==!0;)a=i.value,o=a.source,s=a.target,a.attributes=e(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected);this.emit(`eachEdgeAttributesUpdated`,{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!=`function`)throw new n(`Graph.forEachAdjacencyEntry: expecting a callback.`);forEachAdjacency(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new n(`Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.`);forEachAdjacency(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!=`function`)throw new n(`Graph.forEachAssymetricAdjacencyEntry: expecting a callback.`);forEachAdjacency(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new n(`Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.`);forEachAdjacency(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!=`function`)throw new n(`Graph.forEachNode: expecting a callback.`);let t=this._nodes.values(),r,i;for(;r=t.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)}findNode(e){if(typeof e!=`function`)throw new n(`Graph.findNode: expecting a callback.`);let t=this._nodes.values(),r,i;for(;r=t.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!=`function`)throw new n(`Graph.mapNode: expecting a callback.`);let t=this._nodes.values(),r,i,a=Array(this.order),o=0;for(;r=t.next(),r.done!==!0;)i=r.value,a[o++]=e(i.key,i.attributes);return a}someNode(e){if(typeof e!=`function`)throw new n(`Graph.someNode: expecting a callback.`);let t=this._nodes.values(),r,i;for(;r=t.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!=`function`)throw new n(`Graph.everyNode: expecting a callback.`);let t=this._nodes.values(),r,i;for(;r=t.next(),r.done!==!0;)if(i=r.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!=`function`)throw new n(`Graph.filterNodes: expecting a callback.`);let t=this._nodes.values(),r,i,a=[];for(;r=t.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)&&a.push(i.key);return a}reduceNodes(e,t){if(typeof e!=`function`)throw new n(`Graph.reduceNodes: expecting a callback.`);if(arguments.length<2)throw new n(`Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let r=t,i=this._nodes.values(),a,o;for(;a=i.next(),a.done!==!0;)o=a.value,r=e(r,o.key,o.attributes);return r}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let t=e.next();if(t.done)return t;let n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){let e=Array(this._nodes.size),t=0;this._nodes.forEach((n,r)=>{e[t++]=serializeNode(r,n)});let n=Array(this._edges.size);return t=0,this._edges.forEach((e,r)=>{n[t++]=serializeEdge(this.type,r,e)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,t=!1){if(e instanceof Graph)return e.forEachNode((e,n)=>{t?this.mergeNode(e,n):this.addNode(e,n)}),e.forEachEdge((e,n,r,i,a,o,s)=>{t?s?this.mergeUndirectedEdgeWithKey(e,r,i,n):this.mergeDirectedEdgeWithKey(e,r,i,n):s?this.addUndirectedEdgeWithKey(e,r,i,n):this.addDirectedEdgeWithKey(e,r,i,n)}),this;if(!isPlainObject(e))throw new n(`Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.`);if(e.attributes){if(!isPlainObject(e.attributes))throw new n(`Graph.import: invalid attributes. Expecting a plain object.`);t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let r,i,a,o,s;if(e.nodes){if(a=e.nodes,!Array.isArray(a))throw new n(`Graph.import: invalid nodes. Expecting an array.`);for(r=0,i=a.length;r<i;r++){o=a[r],validateSerializedNode(o);let{key:e,attributes:n}=o;t?this.mergeNode(e,n):this.addNode(e,n)}}if(e.edges){let o=!1;if(this.type===`undirected`&&(o=!0),a=e.edges,!Array.isArray(a))throw new n(`Graph.import: invalid edges. Expecting an array.`);for(r=0,i=a.length;r<i;r++){s=a[r],validateSerializedEdge(s);let{source:e,target:n,attributes:i,undirected:c=o}=s,l;`key`in s?(l=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,l.call(this,s.key,e,n,i)):(l=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,l.call(this,e,n,i))}}return this}nullCopy(e){let n=new Graph(t({},this._options,e));return n.replaceAttributes(t({},this.getAttributes())),n}emptyCopy(e){let n=this.nullCopy(e);return this._nodes.forEach((e,r)=>{let i=t({},e.attributes);e=new n.NodeDataClass(r,i),n._nodes.set(r,e)}),n}copy(e){if(e||={},typeof e.type==`string`&&e.type!==this.type&&e.type!==`mixed`)throw new i(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi==`boolean`&&e.multi!==this.multi&&e.multi!==!0)throw new i(`Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.`);if(typeof e.allowSelfLoops==`boolean`&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new i(`Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.`);let n=this.emptyCopy(e),r=this._edges.values(),a,o;for(;a=r.next(),a.done!==!0;)o=a.value,addEdge(n,`copy`,!1,o.undirected,o.key,o.source.key,o.target.key,t({},o.attributes));return n}toJSON(){return this.export()}toString(){return`[object Graph]`}inspect(){let e={};this._nodes.forEach((t,n)=>{e[n]=t.attributes});let t={},n={};this._edges.forEach((e,r)=>{let i=e.undirected?`--`:`->`,a=``,o=e.source.key,s=e.target.key,c;e.undirected&&o>s&&(c=o,o=s,s=c);let l=`(${o})${i}(${s})`;r.startsWith(`geid_`)?this.multi&&(n[l]===void 0?n[l]=0:n[l]++,a+=`${n[l]}. `):a+=`[${r}]: `,a+=l,t[a]=e.attributes});let r={};for(let e in this)this.hasOwnProperty(e)&&!d.has(e)&&typeof this[e]!=`function`&&typeof e!=`symbol`&&(r[e]=this[e]);return r.attributes=this._attributes,r.nodes=e,r.edges=t,privateProperty(r,`constructor`,this.constructor),r}};typeof Symbol<`u`&&(m.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=m.prototype.inspect),f.forEach(e=>{[`add`,`merge`,`update`].forEach(t=>{let n=e.name(t),r=t===`add`?addEdge:mergeEdge;e.generateKey?m.prototype[n]=function(i,a,o){return r(this,n,!0,(e.type||this.type)===`undirected`,null,i,a,o,t===`update`)}:m.prototype[n]=function(i,a,o,s){return r(this,n,!1,(e.type||this.type)===`undirected`,i,a,o,s,t===`update`)}})}),attachNodeAttributesMethods(m),attachEdgeAttributesMethods(m),attachEdgeIterationMethods(m),attachNeighborIterationMethods(m);var DirectedGraph=class extends m{constructor(e){let r=t({type:`directed`},e);if(`multi`in r&&r.multi!==!1)throw new n(`DirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(r.type!==`directed`)throw new n(`DirectedGraph.from: inconsistent "`+r.type+`" type in given options!`);super(r)}},UndirectedGraph=class extends m{constructor(e){let r=t({type:`undirected`},e);if(`multi`in r&&r.multi!==!1)throw new n(`UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(r.type!==`undirected`)throw new n(`UndirectedGraph.from: inconsistent "`+r.type+`" type in given options!`);super(r)}},MultiGraph=class extends m{constructor(e){let r=t({multi:!0},e);if(`multi`in r&&r.multi!==!0)throw new n(`MultiGraph.from: inconsistent indication that the graph should be simple in given options!`);super(r)}},MultiDirectedGraph=class extends m{constructor(e){let r=t({type:`directed`,multi:!0},e);if(`multi`in r&&r.multi!==!0)throw new n(`MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(r.type!==`directed`)throw new n(`MultiDirectedGraph.from: inconsistent "`+r.type+`" type in given options!`);super(r)}},MultiUndirectedGraph=class extends m{constructor(e){let r=t({type:`undirected`,multi:!0},e);if(`multi`in r&&r.multi!==!0)throw new n(`MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(r.type!==`undirected`)throw new n(`MultiUndirectedGraph.from: inconsistent "`+r.type+`" type in given options!`);super(r)}};function attachStaticFromMethod(e){e.from=function(n,r){let i=new e(t({},n.options,r));return i.import(n),i}}attachStaticFromMethod(m),attachStaticFromMethod(DirectedGraph),attachStaticFromMethod(UndirectedGraph),attachStaticFromMethod(MultiGraph),attachStaticFromMethod(MultiDirectedGraph),attachStaticFromMethod(MultiUndirectedGraph),m.Graph=m,m.DirectedGraph=DirectedGraph,m.UndirectedGraph=UndirectedGraph,m.MultiGraph=MultiGraph,m.MultiDirectedGraph=MultiDirectedGraph,m.MultiUndirectedGraph=MultiUndirectedGraph,m.InvalidArgumentsGraphError=n,m.NotFoundGraphError=r,m.UsageGraphError=i;export{m as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";import{E as e,T as t}from"./mdast.mjs";const n=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],r={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...n,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...n],h2:[[`className`,`sr-only`]],img:[...n,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...n,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...n],table:[...n],ul:[...n,[`className`,`contains-task-list`]],"*":`abbr.accept.acceptCharset.accessKey.action.align.alt.axis.border.cellPadding.cellSpacing.char.charOff.charSet.checked.clear.colSpan.color.cols.compact.coords.dateTime.dir.encType.frame.hSpace.headers.height.hrefLang.htmlFor.id.isMap.itemProp.label.lang.maxLength.media.method.multiple.name.noHref.noShade.noWrap.open.prompt.readOnly.rev.rowSpan.rows.rules.scope.selected.shape.size.span.start.summary.tabIndex.title.useMap.vAlign.value.width`.split(`.`)},clobber:[`ariaDescribedBy`,`ariaLabelledBy`,`id`,`name`],clobberPrefix:`user-content-`,protocols:{cite:[`http`,`https`],href:[`http`,`https`,`irc`,`ircs`,`mailto`,`xmpp`],longDesc:[`http`,`https`],src:[`http`,`https`]},required:{input:{disabled:!0,type:`checkbox`}},strip:[`script`],tagNames:`a.b.blockquote.br.code.dd.del.details.div.dl.dt.em.h1.h2.h3.h4.h5.h6.hr.i.img.input.ins.kbd.li.ol.p.picture.pre.q.rp.rt.ruby.s.samp.section.source.span.strike.strong.sub.summary.sup.table.tbody.td.tfoot.th.thead.tr.tt.ul.var`.split(`.`)},i={}.hasOwnProperty;function sanitize(e,t){let n={type:`root`,children:[]},i=transform({schema:t?{...r,...t}:r,stack:[]},e);return i&&(Array.isArray(i)?i.length===1?n=i[0]:n.children=i:n=i),n}function transform(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return comment(e,n);case`doctype`:return doctype(e,n);case`element`:return element(e,n);case`root`:return root(e,n);case`text`:return text(e,n);default:}}}function comment(e,t){if(e.schema.allowComments){let e=typeof t.value==`string`?t.value:``,n=e.indexOf(`-->`),r={type:`comment`,value:n<0?e:e.slice(0,n)};return patch(r,t),r}}function doctype(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return patch(e,t),e}}function element(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=children(e,t.children),a=properties(e,t.properties);e.stack.pop();let o=!1;if(n&&n!==`*`&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(o=!0,e.schema.ancestors&&i.call(e.schema.ancestors,n))){let t=e.schema.ancestors[n],r=-1;for(o=!1;++r<t.length;)e.stack.includes(t[r])&&(o=!0)}if(!o)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;let s={type:`element`,tagName:n,properties:a,children:r};return patch(s,t),s}function root(e,t){let n={type:`root`,children:children(e,t.children)};return patch(n,t),n}function text(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return patch(n,t),n}function children(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=transform(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function properties(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,a=e.schema.required,o=r&&i.call(r,n)?r[n]:void 0,s=r&&i.call(r,`*`)?r[`*`]:void 0,c=t&&typeof t==`object`?t:{},l={},u;for(u in c)if(i.call(c,u)){let t=c[u],n=propertyValue(e,findDefinition(o,u),u,t);n??=propertyValue(e,findDefinition(s,u),u,t),n!=null&&(l[u]=n)}if(a&&i.call(a,n)){let e=a[n];for(u in e)i.call(e,u)&&!i.call(l,u)&&(l[u]=e[u])}return l}function propertyValue(e,t,n,r){return t?Array.isArray(r)?propertyValueMany(e,t,n,r):propertyValuePrimitive(e,t,n,r):void 0}function propertyValueMany(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=propertyValuePrimitive(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function propertyValuePrimitive(e,t,n,r){if((typeof r==`boolean`||typeof r==`number`||typeof r==`string`)&&safeProtocol(e,n,r)){if(typeof t==`object`&&t.length>1){let e=!1,n=0;for(;++n<t.length;){let i=t[n];if(i&&typeof i==`object`&&`flags`in i){if(i.test(String(r))){e=!0;break}}else if(i===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function safeProtocol(e,t,n){let r=e.schema.protocols&&i.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;let a=String(n),o=a.indexOf(`:`),s=a.indexOf(`?`),c=a.indexOf(`#`),l=a.indexOf(`/`);if(o<0||l>-1&&o>l||s>-1&&o>s||c>-1&&o>c)return!0;let u=-1;for(;++u<r.length;){let e=r[u];if(o===e.length&&a.slice(0,e.length)===e)return!0}return!1}function patch(n,r){let i=t(r);r.data&&(n.data=e(r.data)),i&&(n.position=i)}function findDefinition(e,t){let n,r=-1;if(e)for(;++r<e.length;){let i=e[r],a=typeof i==`string`?i:i[0];if(a===t)return i;a===`data*`&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()===`data`)return n}export{r as n,sanitize as t};
|