@likec4/core 1.47.0 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/THIRD-PARTY-LICENSES.md +1012 -0
- package/dist/_chunks/Builder.view-element.mjs +2 -0
- package/dist/_chunks/LikeC4Model.d.mts +1283 -0
- package/dist/_chunks/RichText.mjs +1 -0
- package/dist/_chunks/_types.d.mts +777 -0
- package/dist/_chunks/_types2.d.mts +36 -0
- package/dist/_chunks/assignTagColors.mjs +1 -0
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +1 -0
- package/dist/_chunks/guards.d.mts +2026 -0
- package/dist/_chunks/guards.mjs +4 -0
- package/dist/_chunks/index.d.mts +288 -0
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +15 -0
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -0
- package/dist/_chunks/libs/bail.mjs +1 -0
- package/dist/_chunks/libs/ccount.mjs +1 -0
- package/dist/_chunks/libs/character-entities-html4.mjs +1 -0
- package/dist/_chunks/libs/character-entities-legacy.mjs +1 -0
- package/dist/_chunks/libs/character-entities.mjs +2 -0
- package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -0
- package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -0
- package/dist/_chunks/libs/defu.mjs +1 -0
- package/dist/_chunks/libs/devlop.mjs +1 -0
- package/dist/_chunks/libs/escape-string-regexp.mjs +1 -0
- package/dist/_chunks/libs/extend.mjs +1 -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/is-plain-obj.mjs +1 -0
- package/dist/_chunks/libs/longest-streak.mjs +1 -0
- package/dist/_chunks/libs/markdown-table.mjs +2 -0
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -0
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -0
- package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -0
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -0
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -0
- package/dist/_chunks/libs/mnemonist.d.mts +164 -0
- package/dist/_chunks/libs/mnemonist.mjs +1 -0
- package/dist/_chunks/libs/natural-compare-lite.mjs +9 -0
- package/dist/_chunks/libs/ohash.mjs +1 -0
- package/dist/_chunks/libs/rehype-sanitize.mjs +1 -0
- package/dist/_chunks/libs/rehype-stringify.mjs +1 -0
- package/dist/_chunks/libs/remark-gfm.mjs +1 -0
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -0
- package/dist/_chunks/libs/remark-parse.mjs +1 -0
- package/dist/_chunks/libs/remark-rehype.mjs +1 -0
- package/dist/_chunks/libs/remeda.mjs +1 -0
- package/dist/_chunks/libs/trough.mjs +1 -0
- package/dist/_chunks/libs/unified.mjs +1 -0
- package/dist/_chunks/rolldown-runtime.mjs +1 -0
- package/dist/_chunks/theme.d.mts +148 -0
- package/dist/_chunks/to-text.d.mts +404 -0
- package/dist/_chunks/to-text.mjs +1 -0
- package/dist/_chunks/vector.d.mts +198 -0
- package/dist/_chunks/vector.mjs +1 -0
- package/dist/builder/index.d.mts +5 -775
- package/dist/builder/index.mjs +1 -1053
- package/dist/compute-view/index.d.mts +156 -56
- package/dist/compute-view/index.mjs +2 -229
- package/dist/geometry/index.d.mts +2 -109
- package/dist/geometry/index.mjs +1 -328
- package/dist/index.d.mts +14 -20
- package/dist/index.mjs +1 -18
- package/dist/model/index.d.mts +5 -57
- package/dist/model/index.mjs +1 -4
- package/dist/styles/index.d.mts +3 -117
- package/dist/styles/index.mjs +1 -63
- package/dist/types/index.d.mts +3 -47
- package/dist/types/index.mjs +1 -17
- package/dist/utils/graphology/index.d.mts +2 -1864
- package/dist/utils/graphology/index.mjs +1 -1
- package/dist/utils/index.d.mts +4 -124
- package/dist/utils/index.mjs +1 -44
- package/package.json +20 -24
- package/compute-view/relationships/package.json +0 -4
- package/dist/compute-view/relationships-view/index.d.mts +0 -51
- package/dist/compute-view/relationships-view/index.mjs +0 -185
- package/dist/model/connection/deployment/index.d.mts +0 -15
- package/dist/model/connection/deployment/index.mjs +0 -2
- package/dist/model/connection/index.d.mts +0 -75
- package/dist/model/connection/index.mjs +0 -3
- package/dist/model/connection/model/index.d.mts +0 -15
- package/dist/model/connection/model/index.mjs +0 -2
- package/dist/shared/core.3ZhnKAlZ.mjs +0 -106
- package/dist/shared/core.78IWAHAE.mjs +0 -332
- package/dist/shared/core.B85MJLTf.mjs +0 -5
- package/dist/shared/core.BFd1lU9R.mjs +0 -29
- package/dist/shared/core.BKlholso.mjs +0 -3
- package/dist/shared/core.BNN-3vPH.mjs +0 -1255
- package/dist/shared/core.BPGOjone.d.mts +0 -46
- package/dist/shared/core.BP_QHEXs.mjs +0 -785
- package/dist/shared/core.BbE4y-yl.mjs +0 -177
- package/dist/shared/core.Bdy3hhTc.mjs +0 -28382
- package/dist/shared/core.BfCKSW-g.d.mts +0 -1266
- package/dist/shared/core.BhNcrwzK.mjs +0 -7
- package/dist/shared/core.BkVA6gjl.mjs +0 -5
- package/dist/shared/core.BoYfZOBm.mjs +0 -3
- package/dist/shared/core.BsSXS-_R.mjs +0 -7
- package/dist/shared/core.C3JowhaZ.mjs +0 -32
- package/dist/shared/core.C4x8aaWa.mjs +0 -27
- package/dist/shared/core.CAgYpDtM.d.mts +0 -98
- package/dist/shared/core.CHf8VEa3.mjs +0 -1206
- package/dist/shared/core.CLSZtnFh.mjs +0 -69
- package/dist/shared/core.C_3y3eqV.d.mts +0 -139
- package/dist/shared/core.CbT8JVYL.mjs +0 -5
- package/dist/shared/core.CdNCAwq7.mjs +0 -176
- package/dist/shared/core.CmGY9blO.mjs +0 -6717
- package/dist/shared/core.CmPXpJ8l.mjs +0 -21
- package/dist/shared/core.Coi_LOUZ.mjs +0 -7
- package/dist/shared/core.CqAJJpK_.mjs +0 -3
- package/dist/shared/core.CywrQs86.d.mts +0 -31
- package/dist/shared/core.D00YbOhQ.d.mts +0 -300
- package/dist/shared/core.D0WZutNd.mjs +0 -94
- package/dist/shared/core.D4npX2q8.mjs +0 -18
- package/dist/shared/core.DB0Ue5Wx.d.mts +0 -70
- package/dist/shared/core.DC5IAaDT.d.mts +0 -334
- package/dist/shared/core.DE9qzhn8.d.mts +0 -83
- package/dist/shared/core.DGcIbsj4.mjs +0 -3946
- package/dist/shared/core.DH7TXqXf.mjs +0 -136
- package/dist/shared/core.DKhRkHRN.d.mts +0 -41
- package/dist/shared/core.DRJma0Ol.mjs +0 -22
- package/dist/shared/core.DU5SRqNF.mjs +0 -2209
- package/dist/shared/core.DXhDWKFZ.d.mts +0 -3
- package/dist/shared/core.DbfO90vF.mjs +0 -434
- package/dist/shared/core.DcS-0zys.mjs +0 -10
- package/dist/shared/core.Dh119QSP.mjs +0 -4995
- package/dist/shared/core.DjcWextK.mjs +0 -1371
- package/dist/shared/core.Dojz4bvg.d.mts +0 -504
- package/dist/shared/core.FZ305VYd.mjs +0 -21
- package/dist/shared/core.OtRNdMxy.d.mts +0 -352
- package/dist/shared/core.RfnaEmgA.mjs +0 -7
- package/dist/shared/core.btEq3i3f.mjs +0 -300
- package/dist/shared/core.oSV6SRfk.mjs +0 -13
- package/dist/shared/core.om36dXXW.mjs +0 -41
- package/dist/shared/core.osFs8tU7.d.mts +0 -466
- package/dist/shared/core.q10OP9oJ.mjs +0 -5
- package/dist/shared/core.tpvDGvdC.d.mts +0 -87
- package/dist/shared/core.uFk_o9X6.mjs +0 -13
- package/dist/types/_aux.d.mts +0 -4
- package/dist/types/_aux.mjs +0 -8
- package/dist/types/expression-model.d.mts +0 -190
- package/dist/types/expression-model.mjs +0 -109
- package/dist/types/expression.d.mts +0 -6
- package/dist/types/expression.mjs +0 -113
- package/dist/types/fqnRef.d.mts +0 -60
- package/dist/types/fqnRef.mjs +0 -45
- package/dist/types/scalar.d.mts +0 -2
- package/dist/types/scalar.mjs +0 -4
- package/dist/utils/iterable/index.d.mts +0 -132
- package/dist/utils/iterable/index.mjs +0 -62
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Er as DefaultTagColors, Fi as Tag, Sr as ThemeColorValues, _r as ShapeSize, _t as TagSpecification, ar as ElementColorValues, br as TextSize, cr as IconPosition, dr as LikeC4StylesConfig, dt as LikeC4ProjectStylesConfig, er as BorderStyle, fr as LikeC4Theme, ft as LikeC4ProjectStylesCustomStylesheets, hr as RelationshipColorValues, ir as CustomColorDefinitions, lr as IconSize, nr as ColorLiteral, ot as ComputedNodeStyle, ra as NTuple, tr as Color, ur as LikeC4StyleDefaults, xr as ThemeColor, yr as SpacingSize } from "./guards.mjs";
|
|
2
|
+
import { LiteralUnion } from "type-fest";
|
|
3
|
+
|
|
4
|
+
//#region src/styles/assignTagColors.d.ts
|
|
5
|
+
declare function assignTagColors(tags: {
|
|
6
|
+
[kind: string]: Partial<TagSpecification>;
|
|
7
|
+
}): Record<Tag, TagSpecification>;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/styles/LikeC4Styles.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Styles of a LikeC4 project
|
|
12
|
+
*
|
|
13
|
+
* Accepts an array of LikeC4ProjectStylesConfig objects as a parameter
|
|
14
|
+
* and constructs a LikeC4Styles merged with the default styles.
|
|
15
|
+
*
|
|
16
|
+
* The class provides methods to get the default element colors, relationship
|
|
17
|
+
* colors, group colors, font size in pixels, padding in pixels, and to compute
|
|
18
|
+
* the ThemeColorValues from a given color.
|
|
19
|
+
*/
|
|
20
|
+
declare class LikeC4Styles {
|
|
21
|
+
protected config: LikeC4StylesConfig;
|
|
22
|
+
protected customCss?: LikeC4ProjectStylesCustomStylesheets | undefined;
|
|
23
|
+
readonly theme: LikeC4Theme;
|
|
24
|
+
readonly defaults: LikeC4StyleDefaults;
|
|
25
|
+
static readonly DEFAULT: LikeC4Styles;
|
|
26
|
+
static from(stylesConfig: LikeC4ProjectStylesConfig | undefined, customColors?: CustomColorDefinitions | undefined): LikeC4Styles;
|
|
27
|
+
private constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Default element colors
|
|
30
|
+
*/
|
|
31
|
+
get elementColors(): ElementColorValues;
|
|
32
|
+
/**
|
|
33
|
+
* Default relationship colors
|
|
34
|
+
*/
|
|
35
|
+
get relationshipColors(): RelationshipColorValues;
|
|
36
|
+
/**
|
|
37
|
+
* Default group colors
|
|
38
|
+
*/
|
|
39
|
+
get groupColors(): ElementColorValues;
|
|
40
|
+
isDefaultColor(color: LiteralUnion<ThemeColor, string>): color is ThemeColor;
|
|
41
|
+
/**
|
|
42
|
+
* Get color values
|
|
43
|
+
*
|
|
44
|
+
* @param color - The color to use
|
|
45
|
+
* @default color From the defaults
|
|
46
|
+
*/
|
|
47
|
+
colors(color?: LiteralUnion<ThemeColor, string>): ThemeColorValues;
|
|
48
|
+
private compoundColorsCache;
|
|
49
|
+
/**
|
|
50
|
+
* Get colors for compound nodes
|
|
51
|
+
*
|
|
52
|
+
* @param baseElementColors - The base element colors to compute from
|
|
53
|
+
*/
|
|
54
|
+
colorsForCompounds<Depth extends number = 6>(baseElementColors: ElementColorValues, depth?: Depth): NTuple<ElementColorValues, Depth>;
|
|
55
|
+
/**
|
|
56
|
+
* Get font size in pixels
|
|
57
|
+
*
|
|
58
|
+
* @param textSize - The text size to use
|
|
59
|
+
* @default textSize From the defaults
|
|
60
|
+
*/
|
|
61
|
+
fontSize(textSize?: TextSize): number;
|
|
62
|
+
/**
|
|
63
|
+
* Get padding in pixels
|
|
64
|
+
*
|
|
65
|
+
* @param paddingSize - The padding size to use
|
|
66
|
+
* @default paddingSize From the defaults
|
|
67
|
+
*/
|
|
68
|
+
padding(paddingSize?: SpacingSize): number;
|
|
69
|
+
/**
|
|
70
|
+
* Get icon size in pixels
|
|
71
|
+
*
|
|
72
|
+
* @param iconSize - The icon size to use
|
|
73
|
+
* @default iconSize From the defaults
|
|
74
|
+
*/
|
|
75
|
+
iconSize(iconSize?: IconSize): number;
|
|
76
|
+
isThemeColor(color: string): color is ThemeColor;
|
|
77
|
+
/**
|
|
78
|
+
* Calculate sizes and values based on the node styles
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const { sizes, values } = styles.nodeSizes(node.style)
|
|
83
|
+
*
|
|
84
|
+
* // sizes
|
|
85
|
+
* sizes.size // enum Size
|
|
86
|
+
* sizes.padding // enum SpacingSize
|
|
87
|
+
* sizes.textSize // enum TextSize
|
|
88
|
+
* sizes.iconSize // enum ShapeSize
|
|
89
|
+
*
|
|
90
|
+
* // values
|
|
91
|
+
* values.sizes // { width: number, height: number }
|
|
92
|
+
* values.padding // number
|
|
93
|
+
* values.textSize // number
|
|
94
|
+
* values.iconSize // number
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
nodeSizes(nodestyles: ComputedNodeStyle): {
|
|
98
|
+
sizes: Omit<{
|
|
99
|
+
icon?: never;
|
|
100
|
+
readonly iconColor?: Color;
|
|
101
|
+
readonly iconSize?: IconSize;
|
|
102
|
+
readonly iconPosition?: IconPosition;
|
|
103
|
+
shape?: never;
|
|
104
|
+
color?: never;
|
|
105
|
+
readonly border?: BorderStyle;
|
|
106
|
+
readonly opacity?: number;
|
|
107
|
+
readonly multiple?: boolean;
|
|
108
|
+
readonly size?: ShapeSize;
|
|
109
|
+
readonly padding?: SpacingSize;
|
|
110
|
+
readonly textSize?: TextSize;
|
|
111
|
+
}, "size" | "padding" | "iconSize" | "textSize"> & Required<{
|
|
112
|
+
readonly size?: ShapeSize;
|
|
113
|
+
readonly padding?: SpacingSize;
|
|
114
|
+
readonly iconSize?: IconSize;
|
|
115
|
+
readonly textSize?: TextSize;
|
|
116
|
+
}>;
|
|
117
|
+
values: {
|
|
118
|
+
sizes: {
|
|
119
|
+
readonly width: number;
|
|
120
|
+
readonly height: number;
|
|
121
|
+
};
|
|
122
|
+
padding: number;
|
|
123
|
+
textSize: number;
|
|
124
|
+
iconSize: number;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Compute ThemeColorValues from a given color
|
|
129
|
+
* @param color - HEX, RGB, RGBA, etc.
|
|
130
|
+
*/
|
|
131
|
+
computeFrom(color: string): ThemeColorValues;
|
|
132
|
+
equals(other: LikeC4Styles): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Get color values for a tag (including default tag colors)
|
|
135
|
+
*/
|
|
136
|
+
tagColor(tag: typeof DefaultTagColors[number] | ThemeColor | ColorLiteral): ThemeColorValues['elements'];
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/styles/compute-color-values.d.ts
|
|
140
|
+
declare function computeColorValues(color: ColorLiteral): ThemeColorValues;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/styles/defaults.d.ts
|
|
143
|
+
declare const styleDefaults: LikeC4StyleDefaults;
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/styles/theme.d.ts
|
|
146
|
+
declare const defaultTheme: LikeC4Theme;
|
|
147
|
+
//#endregion
|
|
148
|
+
export { assignTagColors as a, LikeC4Styles as i, styleDefaults as n, computeColorValues as r, defaultTheme as t };
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import { $i as IterableContainer, bi as Fqn, ea as IteratorLike, ia as NonEmptyArray, sa as ReorderedArray } from "./guards.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/invariant.d.ts
|
|
4
|
+
declare function nonNullable<T>(value: T, message?: string | (() => string)): NonNullable<T>;
|
|
5
|
+
declare function invariant(condition: any, message?: string): asserts condition;
|
|
6
|
+
declare function nonexhaustive(value: never): never;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/utils/common-head.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Common head of two arrays
|
|
11
|
+
*
|
|
12
|
+
* @param equals - Equality function, defaults to `Object.is`
|
|
13
|
+
*/
|
|
14
|
+
declare function commonHead<T>(sources: ReadonlyArray<T>, targets: ReadonlyArray<T>, equals?: (a: T, b: T) => boolean): T[];
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/utils/compare-natural.d.ts
|
|
17
|
+
declare function compareNatural(a: string | undefined, b: string | undefined): -1 | 0 | 1;
|
|
18
|
+
declare function sortNatural(): <T extends IterableContainer<string>>(elements: T) => ReorderedArray<T>;
|
|
19
|
+
declare function sortNatural<T extends IterableContainer<string>>(elements: T): ReorderedArray<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Compares two strings lexicographically first, then hierarchically based on their depth.\
|
|
22
|
+
* From parent nodes to leaves
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const lines = [
|
|
26
|
+
* 'b.c',
|
|
27
|
+
* 'b',
|
|
28
|
+
* 'a.b.c',
|
|
29
|
+
* ]
|
|
30
|
+
* lines.sort(compareNaturalHierarchically('.'))
|
|
31
|
+
* // [
|
|
32
|
+
* // 'a.b.c',
|
|
33
|
+
* // 'b',
|
|
34
|
+
* // 'b.c',
|
|
35
|
+
* // ]
|
|
36
|
+
*/
|
|
37
|
+
declare function compareNaturalHierarchically(separator?: string, deepestFirst?: boolean): (a: string | undefined, b: string | undefined) => number;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/utils/fqn.d.ts
|
|
40
|
+
declare function parentFqn<E extends string>(fqn: E): E | null;
|
|
41
|
+
declare function nameFromFqn<E extends string>(fqn: E): string;
|
|
42
|
+
/**
|
|
43
|
+
* Check if one element is an ancestor of another
|
|
44
|
+
* Composable version
|
|
45
|
+
* @signature
|
|
46
|
+
* isAncestor(another)(ancestor)
|
|
47
|
+
*/
|
|
48
|
+
declare function isAncestor<A extends string | {
|
|
49
|
+
id: string;
|
|
50
|
+
}>(another: NoInfer<A>): (ancestor: A) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Check if one element is an ancestor of another
|
|
53
|
+
* @signature
|
|
54
|
+
* isAncestor(ancestor, another)
|
|
55
|
+
*/
|
|
56
|
+
declare function isAncestor<A extends string | {
|
|
57
|
+
id: string;
|
|
58
|
+
}>(ancestor: A, another: A): boolean;
|
|
59
|
+
declare function isSameHierarchy<T extends string>(one: NoInfer<T> | WithId<NoInfer<T>>): (another: T | WithId<T>) => boolean;
|
|
60
|
+
declare function isSameHierarchy<T extends string>(one: T | WithId<T>, another: T | WithId<T>): boolean;
|
|
61
|
+
type WithId<T = string> = {
|
|
62
|
+
id: T;
|
|
63
|
+
};
|
|
64
|
+
declare function isDescendantOf<T extends string>(ancestor: WithId<T>): (descedant: WithId<T>) => boolean;
|
|
65
|
+
declare function isDescendantOf<T extends string>(descedant: WithId<T>, ancestor: WithId<T>): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* How deep in the hierarchy the element is.
|
|
68
|
+
* Root element has depth 1
|
|
69
|
+
*/
|
|
70
|
+
declare function hierarchyLevel<E extends string | {
|
|
71
|
+
id: Fqn;
|
|
72
|
+
}>(elementOfFqn: E): number;
|
|
73
|
+
/**
|
|
74
|
+
* Calculate the distance as number of steps from one element to another, i.e.
|
|
75
|
+
* going up to the common ancestor, then going down to the other element.
|
|
76
|
+
* Sibling distance is always 1
|
|
77
|
+
*
|
|
78
|
+
* Can be used for hierarchical clustering
|
|
79
|
+
*/
|
|
80
|
+
declare function hierarchyDistance<E extends string | {
|
|
81
|
+
id: Fqn;
|
|
82
|
+
}>(one: E, another: E): number;
|
|
83
|
+
declare function commonAncestor<E extends string>(first: E, second: E): E | null;
|
|
84
|
+
/**
|
|
85
|
+
* Get all ancestor elements (i.e. parent, parent’s parent, etc.)
|
|
86
|
+
* going up from parent to the root
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* ancestorsFqn('a.b.c.d')
|
|
90
|
+
* // ['a.b.c', 'a.b', 'a']
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
declare function ancestorsFqn<Id extends string>(fqn: Id): Id[];
|
|
94
|
+
/**
|
|
95
|
+
* Compares two fully qualified names (fqns) hierarchically based on their depth.
|
|
96
|
+
* From parent nodes to leaves
|
|
97
|
+
*
|
|
98
|
+
* @param {string} a - The first fqn to compare.
|
|
99
|
+
* @param {string} b - The second fqn to compare.
|
|
100
|
+
* @returns {number} - 0 if the fqns have the same depth.
|
|
101
|
+
* - Positive number if a is deeper than b.
|
|
102
|
+
* - Negative number if b is deeper than a.
|
|
103
|
+
*/
|
|
104
|
+
declare function compareFqnHierarchically<T extends string = string>(a: T, b: T): -1 | 0 | 1;
|
|
105
|
+
declare function compareByFqnHierarchically<T extends {
|
|
106
|
+
id: string;
|
|
107
|
+
}>(a: T, b: T): -1 | 0 | 1;
|
|
108
|
+
/**
|
|
109
|
+
* Sorts an array of objects hierarchically based on their fully qualified names (FQN).
|
|
110
|
+
* Objects are sorted by the number of segments in their FQN (defined by dot-separated ID).
|
|
111
|
+
*
|
|
112
|
+
* @typeParam T - Object type that contains an 'id' string property
|
|
113
|
+
* @typeParam A - Type extending IterableContainer of T
|
|
114
|
+
*
|
|
115
|
+
* @param array - Array of objects to be sorted
|
|
116
|
+
* @returns A new array with items sorted by their FQN hierarchy depth (number of segments)
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const items = [
|
|
121
|
+
* { id: "a.b.c" },
|
|
122
|
+
* { id: "a" },
|
|
123
|
+
* { id: "a.b" }
|
|
124
|
+
* ];
|
|
125
|
+
* sortByFqnHierarchically(items);
|
|
126
|
+
* // Result: [
|
|
127
|
+
* // { id: "a" },
|
|
128
|
+
* // { id: "a.b" },
|
|
129
|
+
* // { id: "a.b.c" }
|
|
130
|
+
* // ]
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
declare function sortByFqnHierarchically<T extends {
|
|
134
|
+
id: string;
|
|
135
|
+
}, A extends IterableContainer<T>>(array: A): ReorderedArray<A>;
|
|
136
|
+
/**
|
|
137
|
+
* Keeps initial order of the elements, but ensures that parents are before children
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const items = [
|
|
142
|
+
* {id: 'a.c'},
|
|
143
|
+
* {id: 'a'},
|
|
144
|
+
* {id: 'a.b.c'},
|
|
145
|
+
* {id: 'a.b'},
|
|
146
|
+
* ];
|
|
147
|
+
* sortParentsFirst(items);
|
|
148
|
+
* // Result: [
|
|
149
|
+
* // { id: "a" },
|
|
150
|
+
* // { id: "a.c" }, // because of initial order
|
|
151
|
+
* // { id: "a.b" },
|
|
152
|
+
* // { id: "a.b.c" },
|
|
153
|
+
* // ]
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
declare function sortParentsFirst<T extends WithId<string>, A extends IterableContainer<T>>(array: A): ReorderedArray<A>;
|
|
157
|
+
/**
|
|
158
|
+
* Sorts an array of objects naturally by their fully qualified name (FQN) identifier.
|
|
159
|
+
*
|
|
160
|
+
* @template T - Type of objects containing an 'id' string property
|
|
161
|
+
* @template A - Type extending IterableContainer of T
|
|
162
|
+
*
|
|
163
|
+
* @param first - Optional. Either the array to sort or the sort direction ('asc'|'desc')
|
|
164
|
+
* @param sort - Optional. The sort direction ('asc'|'desc'). Defaults to 'asc' if not specified
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* // As a function that returns a sorting function
|
|
168
|
+
* const sorted = sortNaturalByFqn('desc')(myArray);
|
|
169
|
+
*
|
|
170
|
+
* // Direct array sorting
|
|
171
|
+
* const sorted = sortNaturalByFqn(myArray, 'desc');
|
|
172
|
+
*/
|
|
173
|
+
declare function sortNaturalByFqn(sort?: 'asc' | 'desc'): <I extends WithId<string>, A extends IterableContainer<I>>(array: A) => ReorderedArray<A>;
|
|
174
|
+
declare function sortNaturalByFqn<A extends IterableContainer<WithId>>(array: A, sort?: 'asc' | 'desc'): ReorderedArray<A>;
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/utils/getOrCreate.d.ts
|
|
177
|
+
declare function getOrCreate<K, V>(map: Map<K, V>, key: K, create: (key: K) => V): V;
|
|
178
|
+
declare function getOrCreate<K extends WeakKey, V>(map: WeakMap<K, V>, key: K, create: (key: K) => V): V;
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/utils/iterable/_types.d.ts
|
|
181
|
+
declare function isIterable<T, I extends Iterable<T>>(something: I | unknown): something is Iterable<T>;
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/utils/iterable/filter.d.ts
|
|
184
|
+
/**
|
|
185
|
+
* Filters an iterable based on a predicate.
|
|
186
|
+
* Composabel first version of `ifilter`.
|
|
187
|
+
* @signature
|
|
188
|
+
* ifilter(predicate)(data)
|
|
189
|
+
*/
|
|
190
|
+
declare function ifilter<T, S extends T>(predicate: (v: T) => v is S): (iterable: Iterable<T>) => IteratorLike<S>;
|
|
191
|
+
declare function ifilter<T>(predicate: (v: T) => boolean): (iterable: Iterable<T>) => IteratorLike<T>;
|
|
192
|
+
/**
|
|
193
|
+
* Filters an iterable based on a predicate.
|
|
194
|
+
* Data first version of `ifilter`.
|
|
195
|
+
* @signature
|
|
196
|
+
* ifilter(data, predicate)
|
|
197
|
+
* @example
|
|
198
|
+
* ifilter(new Set([1, 2, 3]), x => x % 2 === 1) // => Iterable<[1, 3]>
|
|
199
|
+
*/
|
|
200
|
+
declare function ifilter<T, S extends T>(iterable: Iterable<T>, predicate: (v: T) => v is S): IteratorLike<S>;
|
|
201
|
+
declare function ifilter<T>(iterable: Iterable<T>, predicate: (v: T) => boolean): IteratorLike<T>;
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/utils/iterable/find.d.ts
|
|
204
|
+
/**
|
|
205
|
+
* Finds the first element in the iterable that satisfies the predicate.
|
|
206
|
+
* Composable first version of `find`.
|
|
207
|
+
* @signature
|
|
208
|
+
* ifind(predicate)(data)
|
|
209
|
+
*/
|
|
210
|
+
declare function ifind<T, S extends T>(predicate: (item: T) => item is S): (iterable: Iterable<T>) => S | undefined;
|
|
211
|
+
declare function ifind<T>(predicate: (item: T) => boolean): (iterable: Iterable<T>) => T | undefined;
|
|
212
|
+
/**
|
|
213
|
+
* Finds the first element in the iterable that satisfies the predicate.
|
|
214
|
+
* Data first version of `find`.
|
|
215
|
+
* @signature
|
|
216
|
+
* ifind(data, predicate)
|
|
217
|
+
*/
|
|
218
|
+
declare function ifind<T, S extends T>(iterable: Iterable<T>, predicate: (item: T) => item is S): S | undefined;
|
|
219
|
+
declare function ifind<T>(iterable: Iterable<T>, predicate: (item: T) => boolean): T | undefined;
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/utils/iterable/first.d.ts
|
|
222
|
+
/**
|
|
223
|
+
* Takes the first N elements from an iterable.
|
|
224
|
+
* Composable first version of `ifirst`.
|
|
225
|
+
* @signature
|
|
226
|
+
* ifirst(count)(data)
|
|
227
|
+
*/
|
|
228
|
+
declare function ifirst<T>(count: number): (iterable: Iterable<T>) => IteratorLike<T>;
|
|
229
|
+
/**
|
|
230
|
+
* Takes the first N elements from an iterable.
|
|
231
|
+
* Data first version of `ifirst`.
|
|
232
|
+
* @signature
|
|
233
|
+
* ifirst(data, count)
|
|
234
|
+
* @example
|
|
235
|
+
* ifirst([1, 2, 3, 4, 5], 3) // => Iterable<[1, 2, 3]>
|
|
236
|
+
*/
|
|
237
|
+
declare function ifirst<T>(iterable: Iterable<T>, count: number): IteratorLike<T>;
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region src/utils/iterable/flat.d.ts
|
|
240
|
+
declare function iflat(): <T>(iterable: Iterable<IteratorLike<T>>) => IteratorLike<T>;
|
|
241
|
+
declare function iflat<T>(iterable: Iterable<IteratorLike<T>>): IteratorLike<T>;
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/utils/iterable/flatMap.d.ts
|
|
244
|
+
type FlatMapFunction<T, S> = (item: T) => Iterable<S>;
|
|
245
|
+
/**
|
|
246
|
+
* Maps an iterable using a mapper function and flattens the result by one level.
|
|
247
|
+
* Composable first version of `iflatMap`.
|
|
248
|
+
* @signature
|
|
249
|
+
* iflatMap(mapper)(data)
|
|
250
|
+
*/
|
|
251
|
+
declare function iflatMap<T, S>(mapper: FlatMapFunction<T, S>): (iterable: Iterable<T>) => IteratorLike<S>;
|
|
252
|
+
/**
|
|
253
|
+
* Maps an iterable using a mapper function and flattens the result by one level.
|
|
254
|
+
* Data first version of `iflatMap`.
|
|
255
|
+
* @signature
|
|
256
|
+
* iflatMap(data, mapper)
|
|
257
|
+
*/
|
|
258
|
+
declare function iflatMap<T, S>(iterable: Iterable<T>, mapper: FlatMapFunction<T, S>): IteratorLike<S>;
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/utils/iterable/head.d.ts
|
|
261
|
+
declare function ihead<T>(): (iterable: Iterable<T>) => T | undefined;
|
|
262
|
+
/**
|
|
263
|
+
* Finds the first element in the iterable that satisfies the predicate.
|
|
264
|
+
* Data first version of `find`.
|
|
265
|
+
* @signature
|
|
266
|
+
* ifind(data, predicate)
|
|
267
|
+
*/
|
|
268
|
+
declare function ihead<T>(iterable: Iterable<T>): T | undefined;
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/utils/iterable/map.d.ts
|
|
271
|
+
type MapFunction<T, S> = (item: T) => S;
|
|
272
|
+
/**
|
|
273
|
+
* Maps an iterable using a mapper function.
|
|
274
|
+
* Composable first version of `imap`.
|
|
275
|
+
* @signature
|
|
276
|
+
* imap(mapper)(data)
|
|
277
|
+
*/
|
|
278
|
+
declare function imap<T, S>(mapper: MapFunction<T, S>): (iterable: Iterable<T>) => IteratorLike<S>;
|
|
279
|
+
/**
|
|
280
|
+
* Maps an iterable using a mapper function.
|
|
281
|
+
* Data first version of `imap`.
|
|
282
|
+
* @signature
|
|
283
|
+
* imap(data, mapper)
|
|
284
|
+
*/
|
|
285
|
+
declare function imap<T, S>(iterable: Iterable<T>, mapper: MapFunction<T, S>): IteratorLike<S>;
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/utils/iterable/reduce.d.ts
|
|
288
|
+
declare function ireduce<T, R>(reducer: (acc: R, item: T) => R, initialValue: R): (iterable: Iterable<T>) => R;
|
|
289
|
+
declare function ireduce<T, R>(iterable: Iterable<T>, reducer: (acc: R, item: T) => R, initialValue: R): R;
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/utils/iterable/some.d.ts
|
|
292
|
+
/**
|
|
293
|
+
* Checks if at least one element in the iterable satisfies the predicate.
|
|
294
|
+
* Composable first version of `some`.
|
|
295
|
+
* @signature
|
|
296
|
+
* isome(predicate)(data)
|
|
297
|
+
*/
|
|
298
|
+
declare function isome<T>(predicate: (item: T) => boolean): (iterable: Iterable<T>) => boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Checks if at least one element in the iterable satisfies the predicate.
|
|
301
|
+
* Data first version of `some`.
|
|
302
|
+
* @signature
|
|
303
|
+
* isome(data, predicate)
|
|
304
|
+
*/
|
|
305
|
+
declare function isome<T>(iterable: Iterable<T>, predicate: (item: T) => boolean): boolean;
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/utils/iterable/to.d.ts
|
|
308
|
+
declare function toArray(): <T>(iterable: Iterable<T> | ArrayLike<T>) => T[];
|
|
309
|
+
declare function toArray<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
310
|
+
declare function toSet(): <T>(iterable: Iterable<T>) => Set<T>;
|
|
311
|
+
declare function toSet<T>(iterable: Iterable<T>): Set<T>;
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/utils/iterable/unique.d.ts
|
|
314
|
+
/**
|
|
315
|
+
* Returns an iterable that yields only unique values.
|
|
316
|
+
* It uses a Set to keep track of the values.
|
|
317
|
+
*/
|
|
318
|
+
declare function iunique(): <T>(iterable: Iterable<T>) => IteratorLike<T>;
|
|
319
|
+
declare function iunique<T>(iterable: Iterable<T>): IteratorLike<T>;
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/utils/memoize-prop.d.ts
|
|
322
|
+
/**
|
|
323
|
+
* Saves the value returned by fn() in a hidden property tag of obj object, so next time memoizeProp() is called,
|
|
324
|
+
* that value will be returned, and fn won't be called.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* class Model {
|
|
329
|
+
* // using same Symbol
|
|
330
|
+
* get computed1() {
|
|
331
|
+
* return memoizeProp(this, Symbol.for('computed1'), () => doOnce())
|
|
332
|
+
* }
|
|
333
|
+
* // using string
|
|
334
|
+
* get computed2() {
|
|
335
|
+
* return memoizeProp(this, 'computed2', () => doOnce())
|
|
336
|
+
* }
|
|
337
|
+
*
|
|
338
|
+
* }
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
declare function memoizeProp<Tag extends symbol | string, Res>(obj: object, tag: Tag, fn: () => Res): Res;
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/utils/promises.d.ts
|
|
344
|
+
declare function delay(): Promise<string>;
|
|
345
|
+
declare function delay(ms: number): Promise<string>;
|
|
346
|
+
declare function delay(randomFrom: number, randomTo: number): Promise<string>;
|
|
347
|
+
declare function promiseNextTick(): Promise<void>;
|
|
348
|
+
declare function onNextTick(fn: () => Promise<void> | void): void;
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/utils/relations.d.ts
|
|
351
|
+
type RelationshipLike = {
|
|
352
|
+
source: {
|
|
353
|
+
id: string;
|
|
354
|
+
};
|
|
355
|
+
target: {
|
|
356
|
+
id: string;
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Compares two relations hierarchically.
|
|
361
|
+
* From the most general (implicit) to the most specific (deepest in the tree)
|
|
362
|
+
*/
|
|
363
|
+
declare const compareRelations: <T extends RelationshipLike>(a: T, b: T) => number;
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/utils/set.d.ts
|
|
366
|
+
/**
|
|
367
|
+
* Returns new set as a union of given sets
|
|
368
|
+
* Keeps order of elements
|
|
369
|
+
*/
|
|
370
|
+
declare function union<T>(...sets: ReadonlySet<T>[]): Set<T>;
|
|
371
|
+
/**
|
|
372
|
+
* Returns new set as an intersection of all sets
|
|
373
|
+
* Keeps order from the first set
|
|
374
|
+
*/
|
|
375
|
+
declare function intersection<T>(first: ReadonlySet<T>, ...sets: NonEmptyArray<ReadonlySet<NoInfer<T>>>): Set<T>;
|
|
376
|
+
/**
|
|
377
|
+
* Returns new set as a difference of two sets (A-B)
|
|
378
|
+
* Keeps order from the first set
|
|
379
|
+
*/
|
|
380
|
+
declare function difference<T>(a: ReadonlySet<T>, b: ReadonlySet<NoInfer<T>>): Set<T>;
|
|
381
|
+
declare function equals<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean;
|
|
382
|
+
declare function symmetricDifference<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): Set<T>;
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/utils/object-hash.d.ts
|
|
385
|
+
declare function objectHash(value: any): string;
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region src/utils/string-hash.d.ts
|
|
388
|
+
/**
|
|
389
|
+
* @see https://gist.github.com/victor-homyakov/bcb7d7911e4a388b1c810f8c3ce17bcf
|
|
390
|
+
*/
|
|
391
|
+
declare function stringHash(str: string): string;
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/utils/markdown/to-html.d.ts
|
|
394
|
+
declare function markdownToHtml(markdown: string): string;
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/utils/markdown/to-text.d.ts
|
|
397
|
+
/**
|
|
398
|
+
* Converts markdown to plain text, removing any markdown formatting.
|
|
399
|
+
* @param markdown - The markdown to convert.
|
|
400
|
+
* @returns The plain text.
|
|
401
|
+
*/
|
|
402
|
+
declare function markdownToText(markdown: string): string;
|
|
403
|
+
//#endregion
|
|
404
|
+
export { commonAncestor as A, sortByFqnHierarchically as B, iflat as C, isIterable as D, ifilter as E, isAncestor as F, sortNatural as G, sortParentsFirst as H, isDescendantOf as I, nonNullable as J, commonHead as K, isSameHierarchy as L, compareFqnHierarchically as M, hierarchyDistance as N, getOrCreate as O, hierarchyLevel as P, nameFromFqn as R, iflatMap as S, ifind as T, compareNatural as U, sortNaturalByFqn as V, compareNaturalHierarchically as W, nonexhaustive as Y, toSet as _, difference as a, imap as b, symmetricDifference as c, delay as d, onNextTick as f, toArray as g, iunique as h, objectHash as i, compareByFqnHierarchically as j, ancestorsFqn as k, union as l, memoizeProp as m, markdownToHtml as n, equals as o, promiseNextTick as p, invariant as q, stringHash as r, intersection as s, markdownToText as t, compareRelations as u, isome as v, ifirst as w, ihead as x, ireduce as y, parentFqn as z };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as __toESM}from"./rolldown-runtime.mjs";import{t as defu}from"./libs/defu.mjs";import{F as e$1,P as e$4,Q as t$5,R as e$2,T as t$3,a as t$2,et as t,f as e$3,k as e,l as t$4,t as t$1}from"./libs/remeda.mjs";import{s as import_set}from"./libs/mnemonist.mjs";import{t as require_natural_compare_lite}from"./libs/natural-compare-lite.mjs";import{t as hash}from"./libs/ohash.mjs";import{n as defaultSchema}from"./libs/hast-util-sanitize.mjs";import{t as rehypeSanitize}from"./libs/rehype-sanitize.mjs";import{t as rehypeStringify}from"./libs/rehype-stringify.mjs";import{c as toString,t as fromMarkdown}from"./libs/mdast-util-from-markdown.mjs";import{t as remarkGfm}from"./libs/remark-gfm.mjs";import{t as remarkAlert}from"./libs/remark-github-blockquote-alert.mjs";import{t as remarkParse}from"./libs/remark-parse.mjs";import{t as remarkRehype}from"./libs/remark-rehype.mjs";import{t as unified}from"./libs/unified.mjs";function nonNullable(n,r){if(n===void 0||n==null){let i=typeof r==`function`?r():r;throw Error(i??`Expected defined value, but received ${n}`)}return n}function invariant(n,r){if(!n)throw Error(r??`Invariant failed`)}function nonexhaustive(n){throw Error(`NonExhaustive value: ${n}`)}function commonHead(n,r,i){return n.length===0||r.length===0?[]:(i??=Object.is,t(t$1(n,r),t$2(([n,r])=>i(n,r)),t$3(([n,r])=>n)))}var import_natural_compare_lite=__toESM(require_natural_compare_lite(),1);function compareNatural(n,r){return n===r?0:e(n)?e(r)?(0,import_natural_compare_lite.default)(n,r):1:e(r)?-1:0}function _sortNatural(n){return t$4(n,compareNatural)}function sortNatural(...n){return n.length===0?_sortNatural:_sortNatural(n[0])}function compareNaturalHierarchically(n=`.`,r=!1){return(i,a)=>{if(i===a)return 0;if(!i)return-1;if(!a)return 1;let o=i.split(n),s=a.split(n),c=Math.min(o.length,s.length);for(let n=0;n<c;n++){let r=o[n],i=s[n],a=(0,import_natural_compare_lite.default)(r,i);if(a!==0)return a}let l=o.length-s.length;return r?-1*l:l}}function isString(n){return n!=null&&typeof n==`string`}function isNonEmptyArray(n){return!!n&&Array.isArray(n)&&n.length>0}function hasProp(n,r){return n[r]!=null}function isAnyOf(...n){return(r=>n.some(n=>n(r)))}function parentFqn(n){let r=n.lastIndexOf(`.`);return r>0?n.slice(0,r):null}function nameFromFqn(n){let r=n.lastIndexOf(`.`);return r>0?n.slice(r+1):n}const asString=n=>isString(n)?n:n.id;function isAncestor(n,r){let i=asString(n);return r?asString(r).startsWith(i+`.`):n=>{let r=asString(n);return i.startsWith(r+`.`)}}function isSameHierarchy(n,r){if(!r)return r=>isSameHierarchy(n,r);let i=asString(n),a=asString(r);return i===a||a.startsWith(i+`.`)||i.startsWith(a+`.`)}function isDescendantOf(n,r){return r?isAncestor(r,n):r=>isAncestor(n,r)}function hierarchyLevel(n){return(isString(n)?n:n.id).split(`.`).length}function hierarchyDistance(n,r){let i=isString(n)?n:n.id,a=isString(r)?r:r.id;if(i===a)return 0;let o=hierarchyLevel(i),s=hierarchyLevel(a);if(isSameHierarchy(i,a))return Math.abs(o-s);let c=commonAncestor(i,a),l=c?hierarchyLevel(c):0;return o+s-(2*l+1)}function commonAncestor(n,r){let i=n.split(`.`);if(i.length<2)return null;let a=r.split(`.`);if(a.length<2)return null;let o=[];for(let n=0;n<Math.min(i.length,a.length)-1&&i[n]===a[n];n++)o.push(i[n]);return o.length===0?null:o.join(`.`)}function ancestorsFqn(n){let r=n.split(`.`);if(r.pop(),!t$5(r,2))return r;for(let n=1;n<r.length;n++)r[n]=r[n-1]+`.`+r[n];return r.reverse()}function compareFqnHierarchically(n,r){let i=n.split(`.`).length,a=r.split(`.`).length;switch(!0){case i>a:return 1;case i<a:return-1;default:return 0}}function compareByFqnHierarchically(n,r){return compareFqnHierarchically(n.id,r.id)}function sortByFqnHierarchically(n){return n.map(n=>({item:n,fqn:n.id.split(`.`)})).sort((n,r)=>n.fqn.length-r.fqn.length).map(({item:n})=>n)}function findTopAncestor(n,r){let i=r;for(let r of n)r!==i&&isAncestor(r,i)&&(i=r);return i===r?null:i}function sortParentsFirst(n){let r=[],i=[...n],a;for(;a=i.shift();){let n;for(;n=findTopAncestor(i,a);)r.push(...i.splice(i.indexOf(n),1));r.push(a)}return r}function sortNaturalByFqn(n,r){if(!n||isString(n)){let r=n??`asc`;return n=>sortNaturalByFqn(n,r)}let i=r===`desc`?-1:1;return n.map(n=>({item:n,fqn:n.id.split(`.`)})).sort((n,r)=>{if(n.fqn.length!==r.fqn.length)return(n.fqn.length-r.fqn.length)*i;for(let i=0;i<n.fqn.length;i++){let a=compareNatural(n.fqn[i],r.fqn[i]);if(a!==0)return a}return 0}).map(({item:n})=>n)}function getOrCreate(n,r,i){let a=n.get(r);return a||(a=i(r),n.set(r,a)),a}function isIterable(n){return typeof n==`object`&&!!n&&Symbol.iterator in n}function ifilter(n,r){let a=r??n;invariant(e$1(a));function*o(n){for(let r of n)a(r)&&(yield r)}return r?o(n):o}function ifind(n,r){let a=r??n;invariant(e$1(a));function o(n){for(let r of n)if(a(r))return r}return r?o(n):o}function ifirst(n,r){let i=r??n;invariant(typeof i==`number`&&i>=0,`Count must be a non-negative number`);function*a(n){let r=0;for(let a of n){if(r>=i)break;yield a,r++}}return r===void 0?n=>a(n):a(n)}function iflat(n){return n?_iflat(n):_iflat}function*_iflat(n){for(let r of n)yield*r}function iflatMap(n,r){let a=r??n;invariant(e$1(a));function*o(n){for(let r of n)yield*a(r)}return r?o(n):o}function ihead(n){return n?_head(n):_head}function _head(n){let{value:r}=n[Symbol.iterator]().next();return r}function imap(n,r){let a=r??n;invariant(e$1(a));function*o(n){for(let r of n)yield a(r)}return r?o(n):o}function ireduce(n,r,a){let o=e$2(a)?r:n,c=a??r;invariant(e$1(o));function l(n){let r=c;for(let i of n)r=o(r,i);return r}return e$2(a)?l(n):l}function isome(n,r){let a=r??n;invariant(e$1(a));function o(n){for(let r of n)if(a(r))return!0;return!1}return r?o(n):o}function toArray(n){return n?Array.from(n):n=>Array.from(n)}function toSet(n){return n?new Set(n):n=>new Set(n)}function iunique(n){return n?_iunique(n):_iunique}function*_iunique(n){let r=new Set;for(let i of n)r.has(i)||(r.add(i),yield i)}function memoizeProp(n,r,i){let a=typeof r==`symbol`?r:Symbol.for(r);return n.hasOwnProperty(a)||Object.defineProperty(n,a,{enumerable:!1,writable:!1,value:i()}),n[a]}function delay(...n){let r=100;return n.length===2?r=e$3(n[0],n[1]):n.length===1&&(r=n[0]),new Promise(n=>{setTimeout(()=>{n(`LIKEC4_DELAY`)},r??100)})}function promiseNextTick(){return Promise.resolve().then(()=>void 0)}function onNextTick(n){Promise.resolve().then(n)}const compareRelations=(n,r)=>{let i=commonAncestor(n.source.id,n.target.id),a=commonAncestor(r.source.id,r.target.id);if(i&&!a)return 1;if(!i&&a)return-1;let o=i&&a?compareFqnHierarchically(i,a):0;if(o!==0)return o;let s=compareFqnHierarchically(n.source.id,r.source.id);return s===0?compareFqnHierarchically(n.target.id,r.target.id):s};function union(...n){let r=new Set;for(let i of n)for(let n of i)r.add(n);return r}function intersection(n,...r){let i=new Set;if(n.size===0)return i;let a=t$5(r,2)?(0,import_set.intersection)(...r):r[0];if(a.size===0)return i;for(let r of n)a.has(r)&&i.add(r);return i}function difference(n,r){if(n.size===0)return new Set;if(r.size===0)return new Set(n);let i=new Set;for(let a of n)r.has(a)||i.add(a);return i}function equals(n,r){return n.size===r.size&&[...n].every(n=>r.has(n))}function symmetricDifference(n,r){return(0,import_set.symmetricDifference)(n,r)}function hasIntersection(n,r){if(n.size===0||r.size===0)return!1;r.size<n.size&&([n,r]=[r,n]);for(let i of n)if(r.has(i))return!0;return!1}function objectHash(n){return invariant(typeof n==`object`&&e$4(n),`objectHash: value must be an object`),hash(n)}function stringHash(n){let r=5381,i=n.length;invariant(i>0,`stringHash: empty string`);for(let a=0;a<i;a++)r=r*33^n.charCodeAt(a);return(r>>>0).toString(36)}function parser(){return unified().use(remarkParse).use(remarkGfm).use(remarkAlert).use(remarkRehype,{allowDangerousHtml:!0}).use(rehypeSanitize,defu({attributes:{"*":[`className`],svg:[`width`,`height`,`viewBox`,`fill`,`ariaHidden`],path:[`d`,`fill`,`stroke`,`strokeWidth`,`strokeLinecap`,`strokeLinejoin`]},tagNames:[`svg`,`g`,`path`,`div`]},defaultSchema)).use(rehypeStringify,{allowDangerousHtml:!0})}function markdownToHtml(n){return(``+parser().processSync(n)).trim()}function markdownToText(n){return toString(fromMarkdown(n),{includeHtml:!1,includeImageAlt:!1})}export{nonNullable as $,ancestorsFqn as A,parentFqn as B,iflatMap as C,ifilter as D,ifind as E,hierarchyLevel as F,isAnyOf as G,sortNaturalByFqn as H,isAncestor as I,compareNatural as J,isNonEmptyArray as K,isDescendantOf as L,compareByFqnHierarchically as M,compareFqnHierarchically as N,isIterable as O,hierarchyDistance as P,invariant as Q,isSameHierarchy as R,ihead as S,ifirst as T,sortParentsFirst as U,sortByFqnHierarchically as V,hasProp as W,sortNatural as X,compareNaturalHierarchically as Y,commonHead as Z,toArray as _,difference as a,ireduce as b,intersection as c,compareRelations as d,nonexhaustive as et,delay as f,iunique as g,memoizeProp as h,objectHash as i,commonAncestor as j,getOrCreate as k,symmetricDifference as l,promiseNextTick as m,markdownToHtml as n,equals as o,onNextTick as p,isString as q,stringHash as r,hasIntersection as s,markdownToText as t,union as u,toSet as v,iflat as w,imap as x,isome as y,nameFromFqn as z};
|