import { r as __name } from "./rolldown-runtime.mjs"; import { Ca as ReorderedArray, Pi as Fqn, ha as IteratorLike, ma as IterableContainer, ya as NonEmptyArray } from "./index.mjs"; //#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/default-weak-map.d.ts /** * Mnemonist DefaultWeakMap Typings * ================================ */ declare class DefaultWeakMap { // Constructor constructor(factory: (key: K) => V); // Methods clear(): void; set(key: K, value: V): this; delete(key: K): boolean; has(key: K): boolean; get(key: K): V; peek(key: K): V | undefined; inspect(): any; } //#endregion //#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/linked-list.d.ts /** * Mnemonist LinkedList Typings * ============================= */ declare class LinkedList implements Iterable { // Members size: number; // Constructor constructor(); // Methods clear(): void; first(): T | undefined; last(): T | undefined; peek(): T | undefined; push(value: T): number; shift(): T | undefined; unshift(value: T): number; forEach(callback: (value: T, index: number, list: this) => void, scope?: any): void; toArray(): Array; values(): IterableIterator; entries(): IterableIterator<[number, T]>; [Symbol.iterator](): IterableIterator; toString(): string; toJSON(): Array; inspect(): any; // Statics static from(iterable: Iterable | { [key: string]: I; }): LinkedList; } //#endregion //#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/multi-map.d.ts /** * Mnemonist MultiMap Typings * =========================== */ interface MultiMap = V[]> extends Iterable<[K, V]> { // Members dimension: number; size: number; // Methods clear(): void; set(key: K, value: V): this; delete(key: K): boolean; remove(key: K, value: V): boolean; has(key: K): boolean; get(key: K): C | undefined; multiplicity(key: K): number; forEach(callback: (value: V, key: K, map: this) => void, scope?: any): void; forEachAssociation(callback: (value: C, key: K, map: this) => void, scope?: any): void; keys(): IterableIterator; values(): IterableIterator; entries(): IterableIterator<[K, V]>; containers(): IterableIterator; associations(): IterableIterator<[K, C]>; [Symbol.iterator](): IterableIterator<[K, V]>; inspect(): any; toJSON(): any; } interface MultiMapConstructor { new (container: SetConstructor): MultiMap>; new (container?: ArrayConstructor): MultiMap; from(iterable: Iterable<[K, V]> | { [key: string]: V; }, Container: SetConstructor): MultiMap>; from(iterable: Iterable<[K, V]> | { [key: string]: V; }, Container?: ArrayConstructor): MultiMap; } declare const MultiMap: MultiMapConstructor; //#endregion //#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/queue.d.ts /** * Mnemonist Queue Typings * ======================== */ declare class Queue implements Iterable { // Members size: number; // Constructor constructor(); // Methods clear(): void; enqueue(item: T): number; dequeue(): T | undefined; peek(): T | undefined; forEach(callback: (item: T, index: number, queue: this) => void, scope?: any): void; toArray(): Array; values(): IterableIterator; entries(): IterableIterator<[number, T]>; [Symbol.iterator](): IterableIterator; toString(): string; toJSON(): Array; inspect(): any; // Statics static from(iterable: Iterable | { [key: string]: I; }): Queue; static of(...items: Array): Queue; } //#endregion //#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/stack.d.ts /** * Mnemonist Stack Typings * ======================== */ declare class Stack implements Iterable { // Members size: number; // Constructor constructor(); // Methods clear(): void; push(item: T): number; pop(): T | undefined; peek(): T | undefined; forEach(callback: (item: T, index: number, stack: this) => void, scope?: any): void; toArray(): Array; values(): IterableIterator; entries(): IterableIterator<[number, T]>; [Symbol.iterator](): IterableIterator; toString(): string; toJSON(): Array; inspect(): any; // Statics static from(iterable: Iterable | { [key: string]: I; }): Stack; static of(...items: Array): Stack; } //#endregion //#region src/utils/invariant.d.ts declare function nonNullable(value: T, message?: string | (() => string)): NonNullable; declare function invariant(condition: any, message?: string): asserts condition; declare function nonexhaustive(value: never): never; //#endregion //#region src/utils/common-head.d.ts /** * Common head of two arrays * * @param equals - Equality function, defaults to `Object.is` */ declare function commonHead(sources: ReadonlyArray, targets: ReadonlyArray, equals?: (a: T, b: T) => boolean): T[]; //#endregion //#region src/utils/compare-natural.d.ts declare function compareNatural(a: string | undefined, b: string | undefined): -1 | 0 | 1; declare function sortNatural(): >(elements: T) => ReorderedArray; declare function sortNatural>(elements: T): ReorderedArray; /** * Compares two strings lexicographically first, then hierarchically based on their depth.\ * From parent nodes to leaves * * @param separator - The separator to use for splitting the strings * @param deepestFirst - If true, deeper paths come first (reverse order) * * @example * const lines = [ * 'b.c', * 'b', * 'a.b.c', * ] * lines.sort(compareNaturalHierarchically('.')) * // [ * // 'a.b.c', * // 'b', * // 'b.c', * // ] */ declare function compareNaturalHierarchically(separator?: string, deepestFirst?: boolean): (a: string | undefined, b: string | undefined) => number; //#endregion //#region src/utils/fqn.d.ts declare function parentFqn(fqn: E): E | null; declare function nameFromFqn(fqn: E): string; /** * Check if one element is an ancestor of another * Composable version * @signature * isAncestor(another)(ancestor) */ declare function isAncestor(another: NoInfer): (ancestor: A) => boolean; /** * Check if one element is an ancestor of another * @signature * isAncestor(ancestor, another) */ declare function isAncestor(ancestor: A, another: A): boolean; declare function isSameHierarchy(one: NoInfer | WithId>): (another: T | WithId) => boolean; declare function isSameHierarchy(one: T | WithId, another: T | WithId): boolean; type WithId = { id: T; }; declare function isDescendantOf(ancestor: WithId): (descedant: WithId) => boolean; declare function isDescendantOf(descedant: WithId, ancestor: WithId): boolean; /** * How deep in the hierarchy the element is. * Root element has depth 1 */ declare function hierarchyLevel(elementOfFqn: E): number; /** * Calculate the distance as number of steps from one element to another, i.e. * going up to the common ancestor, then going down to the other element. * Sibling distance is always 1 * * Can be used for hierarchical clustering */ declare function hierarchyDistance(one: E, another: E): number; declare function commonAncestor(first: E, second: E): E | null; /** * Get all ancestor elements (i.e. parent, parent’s parent, etc.) * going up from parent to the root * @example * ```ts * ancestorsFqn('a.b.c.d') * // ['a.b.c', 'a.b', 'a'] * ``` */ declare function ancestorsFqn(fqn: Id): Id[]; /** * Compares two fully qualified names (fqns) hierarchically based on their depth. * From parent nodes to leaves * * @param {string} a - The first fqn to compare. * @param {string} b - The second fqn to compare. * @returns {number} - 0 if the fqns have the same depth. * - Positive number if a is deeper than b. * - Negative number if b is deeper than a. */ declare function compareFqnHierarchically(a: T, b: T): -1 | 0 | 1; declare function compareByFqnHierarchically(a: T, b: T): -1 | 0 | 1; /** * Sorts an array of objects hierarchically based on their fully qualified names (FQN). * Objects are sorted by the number of segments in their FQN (defined by dot-separated ID). * * @typeParam T - Object type that contains an 'id' string property * @typeParam A - Type extending IterableContainer of T * * @param array - Array of objects to be sorted * @returns A new array with items sorted by their FQN hierarchy depth (number of segments) * * @example * ```ts * const items = [ * { id: "a.b.c" }, * { id: "a" }, * { id: "a.b" } * ]; * sortByFqnHierarchically(items); * // Result: [ * // { id: "a" }, * // { id: "a.b" }, * // { id: "a.b.c" } * // ] * ``` */ declare function sortByFqnHierarchically>(array: A): ReorderedArray; /** * Keeps initial order of the elements, but ensures that parents are before children * * @example * ```ts * const items = [ * {id: 'a.c'}, * {id: 'a'}, * {id: 'a.b.c'}, * {id: 'a.b'}, * ]; * sortParentsFirst(items); * // Result: [ * // { id: "a" }, * // { id: "a.c" }, // because of initial order * // { id: "a.b" }, * // { id: "a.b.c" }, * // ] * ``` */ declare function sortParentsFirst, A extends IterableContainer>(array: A): ReorderedArray; /** * Sorts an array of objects naturally by their fully qualified name (FQN) identifier. * * @template T - Type of objects containing an 'id' string property * @template A - Type extending IterableContainer of T * * @param first - Optional. Either the array to sort or the sort direction ('asc'|'desc') * @param sort - Optional. The sort direction ('asc'|'desc'). Defaults to 'asc' if not specified * * @example * // As a function that returns a sorting function * const sorted = sortNaturalByFqn('desc')(myArray); * * // Direct array sorting * const sorted = sortNaturalByFqn(myArray, 'desc'); */ declare function sortNaturalByFqn(sort?: 'asc' | 'desc'): , A extends IterableContainer>(array: A) => ReorderedArray; declare function sortNaturalByFqn>(array: A, sort?: 'asc' | 'desc'): ReorderedArray; //#endregion //#region src/utils/getOrCreate.d.ts declare function getOrCreate(map: Map, key: K, create: (key: K) => V): V; declare function getOrCreate(map: WeakMap, key: K, create: (key: K) => V): V; //#endregion //#region src/utils/iterable/_types.d.ts declare function isIterable>(something: I | unknown): something is Iterable; //#endregion //#region src/utils/iterable/filter.d.ts /** * Filters an iterable based on a predicate. * Composabel first version of `ifilter`. * @signature * ifilter(predicate)(data) */ declare function ifilter(predicate: (v: T) => v is S): (iterable: Iterable) => IteratorLike; declare function ifilter(predicate: (v: T) => boolean): (iterable: Iterable) => IteratorLike; /** * Filters an iterable based on a predicate. * Data first version of `ifilter`. * @signature * ifilter(data, predicate) * @example * ifilter(new Set([1, 2, 3]), x => x % 2 === 1) // => Iterable<[1, 3]> */ declare function ifilter(iterable: Iterable, predicate: (v: T) => v is S): IteratorLike; declare function ifilter(iterable: Iterable, predicate: (v: T) => boolean): IteratorLike; //#endregion //#region src/utils/iterable/find.d.ts /** * Finds the first element in the iterable that satisfies the predicate. * Composable first version of `find`. * @signature * ifind(predicate)(data) */ declare function ifind(predicate: (item: T) => item is S): (iterable: Iterable) => S | undefined; declare function ifind(predicate: (item: T) => boolean): (iterable: Iterable) => T | undefined; /** * Finds the first element in the iterable that satisfies the predicate. * Data first version of `find`. * @signature * ifind(data, predicate) */ declare function ifind(iterable: Iterable, predicate: (item: T) => item is S): S | undefined; declare function ifind(iterable: Iterable, predicate: (item: T) => boolean): T | undefined; //#endregion //#region src/utils/iterable/first.d.ts /** * Takes the first N elements from an iterable. * Composable first version of `ifirst`. * @signature * ifirst(count)(data) */ declare function ifirst(count: number): (iterable: Iterable) => IteratorLike; /** * Takes the first N elements from an iterable. * Data first version of `ifirst`. * @signature * ifirst(data, count) * @example * ifirst([1, 2, 3, 4, 5], 3) // => Iterable<[1, 2, 3]> */ declare function ifirst(iterable: Iterable, count: number): IteratorLike; //#endregion //#region src/utils/iterable/flat.d.ts declare function iflat(): (iterable: Iterable>) => IteratorLike; declare function iflat(iterable: Iterable>): IteratorLike; //#endregion //#region src/utils/iterable/flatMap.d.ts type FlatMapFunction = (item: T) => Iterable; /** * Maps an iterable using a mapper function and flattens the result by one level. * Composable first version of `iflatMap`. * @signature * iflatMap(mapper)(data) */ declare function iflatMap(mapper: FlatMapFunction): (iterable: Iterable) => IteratorLike; /** * Maps an iterable using a mapper function and flattens the result by one level. * Data first version of `iflatMap`. * @signature * iflatMap(data, mapper) */ declare function iflatMap(iterable: Iterable, mapper: FlatMapFunction): IteratorLike; //#endregion //#region src/utils/iterable/head.d.ts declare function ihead(): (iterable: Iterable) => T | undefined; /** * Finds the first element in the iterable that satisfies the predicate. * Data first version of `find`. * @signature * ifind(data, predicate) */ declare function ihead(iterable: Iterable): T | undefined; //#endregion //#region src/utils/iterable/map.d.ts type MapFunction = (item: T) => S; /** * Maps an iterable using a mapper function. * Composable first version of `imap`. * @signature * imap(mapper)(data) */ declare function imap(mapper: MapFunction): (iterable: Iterable) => IteratorLike; /** * Maps an iterable using a mapper function. * Data first version of `imap`. * @signature * imap(data, mapper) */ declare function imap(iterable: Iterable, mapper: MapFunction): IteratorLike; //#endregion //#region src/utils/iterable/reduce.d.ts declare function ireduce(reducer: (acc: R, item: T) => R, initialValue: R): (iterable: Iterable) => R; declare function ireduce(iterable: Iterable, reducer: (acc: R, item: T) => R, initialValue: R): R; //#endregion //#region src/utils/iterable/some.d.ts /** * Checks if at least one element in the iterable satisfies the predicate. * Composable first version of `some`. * @signature * isome(predicate)(data) */ declare function isome(predicate: (item: T) => boolean): (iterable: Iterable) => boolean; /** * Checks if at least one element in the iterable satisfies the predicate. * Data first version of `some`. * @signature * isome(data, predicate) */ declare function isome(iterable: Iterable, predicate: (item: T) => boolean): boolean; //#endregion //#region src/utils/iterable/to.d.ts declare function toArray(): (iterable: Iterable | ArrayLike) => T[]; declare function toArray(iterable: Iterable | ArrayLike): T[]; declare function toSet(): (iterable: Iterable) => Set; declare function toSet(iterable: Iterable): Set; //#endregion //#region src/utils/iterable/unique.d.ts /** * Returns an iterable that yields only unique values. * It uses a Set to keep track of the values. */ declare function iunique(): (iterable: Iterable) => IteratorLike; declare function iunique(iterable: Iterable): IteratorLike; //#endregion //#region src/utils/memoize-prop.d.ts /** * Saves the value returned by fn() in a hidden property tag of obj object, so next time memoizeProp() is called, * that value will be returned, and fn won't be called. * * @example * ```ts * class Model { * // using same Symbol * get computed1() { * return memoizeProp(this, Symbol.for('computed1'), () => doOnce()) * } * // using string * get computed2() { * return memoizeProp(this, 'computed2', () => doOnce()) * } * * } * ``` */ declare function memoizeProp(obj: object, tag: Tag, fn: () => Res): Res; //#endregion //#region src/utils/promises.d.ts declare function delay(): Promise; declare function delay(ms: number): Promise; declare function delay(randomFrom: number, randomTo: number): Promise; declare function promiseNextTick(): Promise; declare function onNextTick(fn: () => Promise | void): void; //#endregion //#region src/utils/relations.d.ts type RelationshipLike = { source: { id: string; }; target: { id: string; }; }; /** * Compares two relations hierarchically. * From the most general (implicit) to the most specific (deepest in the tree) */ declare const compareRelations: (a: T, b: T) => number; //#endregion //#region src/utils/set.d.ts /** * Returns new set as a union of given sets * Keeps order of elements */ declare function union(...sets: ReadonlySet[]): Set; /** * Returns new set as an intersection of all sets * Keeps order from the first set */ declare function intersection(first: ReadonlySet, ...sets: NonEmptyArray>>): Set; /** * Returns new set as a difference of two sets (A-B) * Keeps order from the first set */ declare function difference(a: ReadonlySet, b: ReadonlySet>): Set; declare function equals(a: ReadonlySet, b: ReadonlySet): boolean; declare function symmetricDifference(a: ReadonlySet, b: ReadonlySet): Set; //#endregion //#region src/utils/object-hash.d.ts declare function objectHash(value: any): string; //#endregion //#region src/utils/string-hash.d.ts /** * @see https://gist.github.com/victor-homyakov/bcb7d7911e4a388b1c810f8c3ce17bcf */ declare function stringHash(str: string): string; //#endregion //#region src/utils/markdown/to-html.d.ts declare function markdownToHtml(markdown: string): string; //#endregion //#region src/utils/markdown/to-text.d.ts /** * Converts markdown to plain text, removing any markdown formatting. * @param markdown - The markdown to convert. * @returns The plain text. */ declare function markdownToText(markdown: string): string; //#endregion //#region src/utils/unsafe.d.ts /** * Casts a partial object to a full object type, mostly for tests. * Motivation: to avoid using `as` in the code */ declare function unsafePartial(value: Partial>): T; //#endregion 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 };