@obinexusmk2/hypernum 0.1.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 +21 -0
- package/README.md +256 -0
- package/dist/index.cjs +3425 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1449 -0
- package/dist/index.js +3284 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +8 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/config/config-loader.d.ts +56 -0
- package/dist/types/config/config-loader.d.ts.map +1 -0
- package/dist/types/config/config-parser.d.ts +28 -0
- package/dist/types/config/config-parser.d.ts.map +1 -0
- package/dist/types/config/config-resolver.d.ts +21 -0
- package/dist/types/config/config-resolver.d.ts.map +1 -0
- package/dist/types/config/config-source.d.ts +27 -0
- package/dist/types/config/config-source.d.ts.map +1 -0
- package/dist/types/config/index.d.ts +68 -0
- package/dist/types/config/index.d.ts.map +1 -0
- package/dist/types/core/common.d.ts +169 -0
- package/dist/types/core/common.d.ts.map +1 -0
- package/dist/types/core/config.d.ts +197 -0
- package/dist/types/core/config.d.ts.map +1 -0
- package/dist/types/core/constants.d.ts +88 -0
- package/dist/types/core/constants.d.ts.map +1 -0
- package/dist/types/core/errors.d.ts +97 -0
- package/dist/types/core/errors.d.ts.map +1 -0
- package/dist/types/core/hypernum.d.ts +60 -0
- package/dist/types/core/hypernum.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +6 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/operations/arithmetic.d.ts +72 -0
- package/dist/types/operations/arithmetic.d.ts.map +1 -0
- package/dist/types/operations/bitwise.d.ts +98 -0
- package/dist/types/operations/bitwise.d.ts.map +1 -0
- package/dist/types/operations/comparison.d.ts +94 -0
- package/dist/types/operations/comparison.d.ts.map +1 -0
- package/dist/types/operations/conversion.d.ts +79 -0
- package/dist/types/operations/conversion.d.ts.map +1 -0
- package/dist/types/operations/factorial.d.ts +58 -0
- package/dist/types/operations/factorial.d.ts.map +1 -0
- package/dist/types/operations/index.d.ts +6 -0
- package/dist/types/operations/index.d.ts.map +1 -0
- package/dist/types/operations/power.d.ts +49 -0
- package/dist/types/operations/power.d.ts.map +1 -0
- package/dist/types/storage/Heap.d.ts +95 -0
- package/dist/types/storage/Heap.d.ts.map +1 -0
- package/dist/types/storage/index.d.ts +2 -0
- package/dist/types/storage/index.d.ts.map +1 -0
- package/dist/types/structures/ackermann.d.ts +74 -0
- package/dist/types/structures/ackermann.d.ts.map +1 -0
- package/dist/types/structures/big-array.d.ts +102 -0
- package/dist/types/structures/big-array.d.ts.map +1 -0
- package/dist/types/structures/index.d.ts +5 -0
- package/dist/types/structures/index.d.ts.map +1 -0
- package/dist/types/structures/number-tree.d.ts +114 -0
- package/dist/types/structures/number-tree.d.ts.map +1 -0
- package/dist/types/structures/power-tower.d.ts +74 -0
- package/dist/types/structures/power-tower.d.ts.map +1 -0
- package/dist/types/utils/formatting.d.ts +45 -0
- package/dist/types/utils/formatting.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/parser.d.ts +39 -0
- package/dist/types/utils/parser.d.ts.map +1 -0
- package/dist/types/utils/precision.d.ts +57 -0
- package/dist/types/utils/precision.d.ts.map +1 -0
- package/dist/types/utils/validation.d.ts +28 -0
- package/dist/types/utils/validation.d.ts.map +1 -0
- package/package.json +164 -0
- package/rollup.config.js +162 -0
- package/src/config/config-loader.ts +226 -0
- package/src/config/config-parser.ts +161 -0
- package/src/config/config-resolver.ts +52 -0
- package/src/config/config-source.ts +32 -0
- package/src/config/index.ts +159 -0
- package/src/core/common.ts +185 -0
- package/src/core/config.ts +393 -0
- package/src/core/constants.ts +102 -0
- package/src/core/errors.ts +203 -0
- package/src/core/hypernum.ts +241 -0
- package/src/core/index.ts +5 -0
- package/src/index.ts +183 -0
- package/src/operations/arithmetic.ts +333 -0
- package/src/operations/bitwise.ts +367 -0
- package/src/operations/comparison.ts +272 -0
- package/src/operations/conversion.ts +400 -0
- package/src/operations/factorial.ts +279 -0
- package/src/operations/index.ts +5 -0
- package/src/operations/power.ts +316 -0
- package/src/storage/Heap.ts +238 -0
- package/src/storage/index.ts +1 -0
- package/src/structures/ackermann.ts +233 -0
- package/src/structures/big-array.ts +306 -0
- package/src/structures/index.ts +4 -0
- package/src/structures/number-tree.ts +404 -0
- package/src/structures/power-tower.ts +278 -0
- package/src/types/common.d.ts +357 -0
- package/src/types/core.d.ts +161 -0
- package/src/types/index.d.ts +2 -0
- package/src/utils/formatting.ts +246 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/parser.ts +245 -0
- package/src/utils/precision.ts +217 -0
- package/src/utils/validation.ts +183 -0
- package/tsconfig.json +84 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion operations module for Hypernum library
|
|
3
|
+
* Provides functions for converting numbers between different formats and bases
|
|
4
|
+
*/
|
|
5
|
+
import { RoundingMode } from '../utils/precision';
|
|
6
|
+
/**
|
|
7
|
+
* Options for conversion operations
|
|
8
|
+
*/
|
|
9
|
+
export interface ConversionOptions {
|
|
10
|
+
/** Precision for decimal operations */
|
|
11
|
+
precision?: number;
|
|
12
|
+
/** Rounding mode for decimal operations */
|
|
13
|
+
roundingMode?: RoundingMode;
|
|
14
|
+
/** Whether to use uppercase for hex/base-N output */
|
|
15
|
+
uppercase?: boolean;
|
|
16
|
+
/** Whether to add prefix for base-N output (0x, 0b, etc.) */
|
|
17
|
+
prefix?: boolean;
|
|
18
|
+
/** Minimum number of digits (pad with zeros) */
|
|
19
|
+
minDigits?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Converts number to binary string representation
|
|
23
|
+
*/
|
|
24
|
+
export declare function toBinary(value: bigint | string | number, options?: ConversionOptions): string;
|
|
25
|
+
/**
|
|
26
|
+
* Converts number to octal string representation
|
|
27
|
+
*/
|
|
28
|
+
export declare function toOctal(value: bigint | string | number, options?: ConversionOptions): string;
|
|
29
|
+
/**
|
|
30
|
+
* Converts number to hexadecimal string representation
|
|
31
|
+
*/
|
|
32
|
+
export declare function toHexadecimal(value: bigint | string | number, options?: ConversionOptions): string;
|
|
33
|
+
/**
|
|
34
|
+
* Converts number to string in specified base
|
|
35
|
+
*/
|
|
36
|
+
export declare function toBase(value: bigint | string | number, base: number, options?: ConversionOptions): string;
|
|
37
|
+
/**
|
|
38
|
+
* Converts string from specified base to bigint
|
|
39
|
+
*/
|
|
40
|
+
export declare function fromBase(value: string, base: number): bigint;
|
|
41
|
+
/**
|
|
42
|
+
* Converts decimal string to fraction representation
|
|
43
|
+
*/
|
|
44
|
+
export declare function toFraction(value: string): [bigint, bigint];
|
|
45
|
+
/**
|
|
46
|
+
* Converts fraction to decimal string with specified precision
|
|
47
|
+
*/
|
|
48
|
+
export declare function fromFraction(numerator: bigint | string | number, denominator: bigint | string | number, options?: ConversionOptions): string;
|
|
49
|
+
/**
|
|
50
|
+
* Converts scientific notation to decimal string
|
|
51
|
+
*/
|
|
52
|
+
export declare function fromScientific(value: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Converts decimal to scientific notation
|
|
55
|
+
*/
|
|
56
|
+
export declare function toScientific(value: bigint | string | number, options?: ConversionOptions): string;
|
|
57
|
+
/**
|
|
58
|
+
* Converts Roman numeral to number
|
|
59
|
+
*/
|
|
60
|
+
export declare function fromRoman(value: string): bigint;
|
|
61
|
+
/**
|
|
62
|
+
* Converts number to Roman numeral
|
|
63
|
+
*/
|
|
64
|
+
export declare function toRoman(value: bigint | string | number, options?: ConversionOptions): string;
|
|
65
|
+
declare const _default: {
|
|
66
|
+
toBinary: typeof toBinary;
|
|
67
|
+
toOctal: typeof toOctal;
|
|
68
|
+
toHexadecimal: typeof toHexadecimal;
|
|
69
|
+
toBase: typeof toBase;
|
|
70
|
+
fromBase: typeof fromBase;
|
|
71
|
+
toFraction: typeof toFraction;
|
|
72
|
+
fromFraction: typeof fromFraction;
|
|
73
|
+
fromScientific: typeof fromScientific;
|
|
74
|
+
toScientific: typeof toScientific;
|
|
75
|
+
fromRoman: typeof fromRoman;
|
|
76
|
+
toRoman: typeof toRoman;
|
|
77
|
+
};
|
|
78
|
+
export default _default;
|
|
79
|
+
//# sourceMappingURL=conversion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversion.d.ts","sourceRoot":"","sources":["../../../src/operations/conversion.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOD,OAAO,EACL,YAAY,EAEb,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAUD;;GAEG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAYR;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAWR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAmBR;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,MAAM,CAgBR;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,GACZ,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBlB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EACnC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EACrC,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GACZ,MAAM,CAyBR;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAyBR;AAmBD;;EAEC;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiC7C;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAqDR;;;;;;;;;;;;;;AACD,wBAYE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factorial operations module for Hypernum library
|
|
3
|
+
* Provides efficient implementations for factorial and related computations
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Options for factorial operations
|
|
7
|
+
*/
|
|
8
|
+
export interface FactorialOptions {
|
|
9
|
+
/** Maximum allowed computation value */
|
|
10
|
+
maxValue?: number;
|
|
11
|
+
/** Whether to check for overflow */
|
|
12
|
+
checkOverflow?: boolean;
|
|
13
|
+
/** Cache computed values */
|
|
14
|
+
useCache?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Calculates factorial of a number (n!)
|
|
18
|
+
*/
|
|
19
|
+
export declare function factorial(value: bigint | string | number, options?: FactorialOptions): bigint;
|
|
20
|
+
/**
|
|
21
|
+
* Calculates binomial coefficient (n choose k)
|
|
22
|
+
*/
|
|
23
|
+
export declare function binomial(n: bigint | string | number, k: bigint | string | number, options?: FactorialOptions): bigint;
|
|
24
|
+
/**
|
|
25
|
+
* Calculates subfactorial (derangement number)
|
|
26
|
+
* Number of permutations of n elements with no fixed points
|
|
27
|
+
*/
|
|
28
|
+
export declare function subfactorial(value: bigint | string | number, options?: FactorialOptions): bigint;
|
|
29
|
+
/**
|
|
30
|
+
* Calculates rising factorial (Pochhammer symbol)
|
|
31
|
+
* x^(n) = x(x+1)(x+2)...(x+n-1)
|
|
32
|
+
*/
|
|
33
|
+
export declare function risingFactorial(x: bigint | string | number, n: bigint | string | number, options?: FactorialOptions): bigint;
|
|
34
|
+
/**
|
|
35
|
+
* Calculates falling factorial
|
|
36
|
+
* x_(n) = x(x-1)(x-2)...(x-n+1)
|
|
37
|
+
*/
|
|
38
|
+
export declare function fallingFactorial(x: bigint | string | number, n: bigint | string | number, options?: FactorialOptions): bigint;
|
|
39
|
+
/**
|
|
40
|
+
* Calculates multifactorial (n!!)
|
|
41
|
+
* Product of numbers from 1 to n that leave the same remainder as n when divided by k
|
|
42
|
+
*/
|
|
43
|
+
export declare function multiFactorial(value: bigint | string | number, k?: bigint | string | number, options?: FactorialOptions): bigint;
|
|
44
|
+
/**
|
|
45
|
+
* Calculates primorial (product of primes up to n)
|
|
46
|
+
*/
|
|
47
|
+
export declare function primorial(value: bigint | string | number, options?: FactorialOptions): bigint;
|
|
48
|
+
declare const _default: {
|
|
49
|
+
factorial: typeof factorial;
|
|
50
|
+
binomial: typeof binomial;
|
|
51
|
+
subfactorial: typeof subfactorial;
|
|
52
|
+
risingFactorial: typeof risingFactorial;
|
|
53
|
+
fallingFactorial: typeof fallingFactorial;
|
|
54
|
+
multiFactorial: typeof multiFactorial;
|
|
55
|
+
primorial: typeof primorial;
|
|
56
|
+
};
|
|
57
|
+
export default _default;
|
|
58
|
+
//# sourceMappingURL=factorial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factorial.d.ts","sourceRoot":"","sources":["../../../src/operations/factorial.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAWD;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAgCR;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAwBR;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAwBR;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAiBR;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAiBR;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,CAAC,GAAE,MAAM,GAAG,MAAM,GAAG,MAAW,EAChC,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAkCR;;;;;;;;;;AAID,wBAQE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/operations/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Power operations module for Hypernum library
|
|
3
|
+
* Provides efficient implementations for exponentiation and related operations
|
|
4
|
+
*/
|
|
5
|
+
import { RoundingMode } from '../utils/precision';
|
|
6
|
+
/**
|
|
7
|
+
* Options for power operations
|
|
8
|
+
*/
|
|
9
|
+
export interface PowerOptions {
|
|
10
|
+
/** Precision for decimal operations */
|
|
11
|
+
precision?: number;
|
|
12
|
+
/** Rounding mode for decimal operations */
|
|
13
|
+
roundingMode?: RoundingMode;
|
|
14
|
+
/** Whether to check for overflow */
|
|
15
|
+
checkOverflow?: boolean;
|
|
16
|
+
/** Maximum allowed computation steps */
|
|
17
|
+
maxSteps?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Raises a number to an integer power using binary exponentiation
|
|
21
|
+
*/
|
|
22
|
+
export declare function power(baseValue: bigint | string | number, exponentValue: bigint | string | number, options?: PowerOptions): bigint;
|
|
23
|
+
/**
|
|
24
|
+
* Calculates square root using Newton's method
|
|
25
|
+
*/
|
|
26
|
+
export declare function sqrt(value: bigint | string | number, options?: PowerOptions): bigint;
|
|
27
|
+
/**
|
|
28
|
+
* Calculates nth root using Newton's method
|
|
29
|
+
*/
|
|
30
|
+
export declare function nthRoot(value: bigint | string | number, n: bigint | string | number, options?: PowerOptions): bigint;
|
|
31
|
+
/**
|
|
32
|
+
* Calculates tetration (repeated exponentiation)
|
|
33
|
+
* a↑↑n = a^(a^(a^...)) (n times)
|
|
34
|
+
*/
|
|
35
|
+
export declare function tetration(base: bigint | string | number, height: bigint | string | number, options?: PowerOptions): bigint;
|
|
36
|
+
/**
|
|
37
|
+
* Calculates super-root (inverse tetration)
|
|
38
|
+
* Finds x where x↑↑n = value
|
|
39
|
+
*/
|
|
40
|
+
export declare function superRoot(value: bigint | string | number, height: bigint | string | number, options?: PowerOptions): bigint;
|
|
41
|
+
declare const _default: {
|
|
42
|
+
power: typeof power;
|
|
43
|
+
sqrt: typeof sqrt;
|
|
44
|
+
nthRoot: typeof nthRoot;
|
|
45
|
+
tetration: typeof tetration;
|
|
46
|
+
superRoot: typeof superRoot;
|
|
47
|
+
};
|
|
48
|
+
export default _default;
|
|
49
|
+
//# sourceMappingURL=power.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../../../src/operations/power.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUD,OAAO,EACL,YAAY,EAEb,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,oCAAoC;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AASD;;GAEG;AACH,wBAAgB,KAAK,CACnB,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EACnC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EACvC,OAAO,GAAE,YAAiB,GACzB,MAAM,CAyDR;AAED;;GAEG;AACH,wBAAgB,IAAI,CAClB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,OAAO,GAAE,YAAiB,GACzB,MAAM,CAgCR;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,OAAO,GAAE,YAAiB,GACzB,MAAM,CA6CR;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC9B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAChC,OAAO,GAAE,YAAiB,GACzB,MAAM,CAuCR;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAChC,OAAO,GAAE,YAAiB,GACzB,MAAM,CAmDR;;;;;;;;AAED,wBAME"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the result of a comparison operation
|
|
3
|
+
* -1: first value is less than second value
|
|
4
|
+
* 0: values are equal
|
|
5
|
+
* 1: first value is greater than second value
|
|
6
|
+
*/
|
|
7
|
+
export type ComparisonResult = -1 | 0 | 1;
|
|
8
|
+
/**
|
|
9
|
+
* Generic comparator function type for heap elements
|
|
10
|
+
*/
|
|
11
|
+
export type Comparator<T> = (a: T, b: T) => ComparisonResult;
|
|
12
|
+
/**
|
|
13
|
+
* Abstract base heap class implementing common heap operations
|
|
14
|
+
*/
|
|
15
|
+
declare abstract class Heap<T> {
|
|
16
|
+
protected heap: T[];
|
|
17
|
+
protected readonly compare: Comparator<T>;
|
|
18
|
+
constructor(comparator: Comparator<T>);
|
|
19
|
+
/**
|
|
20
|
+
* Gets the size of the heap
|
|
21
|
+
*/
|
|
22
|
+
size(): number;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if the heap is empty
|
|
25
|
+
*/
|
|
26
|
+
isEmpty(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Peeks at the root element without removing it
|
|
29
|
+
*/
|
|
30
|
+
peek(): T | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Inserts a new element into the heap
|
|
33
|
+
*/
|
|
34
|
+
push(value: T): void;
|
|
35
|
+
/**
|
|
36
|
+
* Removes and returns the root element
|
|
37
|
+
*/
|
|
38
|
+
pop(): T | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Removes all elements from the heap
|
|
41
|
+
*/
|
|
42
|
+
clear(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a heap from an array of elements
|
|
45
|
+
*/
|
|
46
|
+
static heapify<T extends {}>(array: T[], comparator: Comparator<T>): Heap<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the parent index of a node
|
|
49
|
+
*/
|
|
50
|
+
protected getParentIndex(index: number): number;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the left child index of a node
|
|
53
|
+
*/
|
|
54
|
+
protected getLeftChildIndex(index: number): number;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the right child index of a node
|
|
57
|
+
*/
|
|
58
|
+
protected getRightChildIndex(index: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* Swaps two elements in the heap
|
|
61
|
+
*/
|
|
62
|
+
protected swap(i: number, j: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* Moves an element up the heap until heap property is satisfied
|
|
65
|
+
*/
|
|
66
|
+
protected abstract siftUp(index: number): void;
|
|
67
|
+
/**
|
|
68
|
+
* Moves an element down the heap until heap property is satisfied
|
|
69
|
+
*/
|
|
70
|
+
protected abstract siftDown(index: number): void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* MinHeap implementation where the root is the smallest element
|
|
74
|
+
*/
|
|
75
|
+
export declare class MinHeap<T> extends Heap<T> {
|
|
76
|
+
constructor(comparator: Comparator<T>);
|
|
77
|
+
protected siftUp(index: number): void;
|
|
78
|
+
protected siftDown(index: number): void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* MaxHeap implementation where the root is the largest element
|
|
82
|
+
*/
|
|
83
|
+
export declare class MaxHeap<T> extends Heap<T> {
|
|
84
|
+
constructor(comparator: Comparator<T>);
|
|
85
|
+
protected siftUp(index: number): void;
|
|
86
|
+
protected siftDown(index: number): void;
|
|
87
|
+
}
|
|
88
|
+
export declare const isMinHeap: <T>(heap: Heap<T>) => heap is MinHeap<T>;
|
|
89
|
+
export declare const isMaxHeap: <T>(heap: Heap<T>) => heap is MaxHeap<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Custom comparator for large numbers
|
|
92
|
+
*/
|
|
93
|
+
export declare function createLargeNumberComparator(): (a: bigint, b: bigint) => number;
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=Heap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Heap.d.ts","sourceRoot":"","sources":["../../../src/storage/Heap.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,gBAAgB,CAAC;AAE7D;;GAEG;AACH,uBAAe,IAAI,CAAC,CAAC;IACnB,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;IACpB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;gBAE9B,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAKrC;;OAEG;IACI,IAAI,IAAI,MAAM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UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAIrC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWrC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAwBxC;AAGD,eAAO,MAAM,SAAS,YAAa,KAAK,CAAC,CAAC,uBAEzC,CAAC;AAEF,eAAO,MAAM,SAAS,YAAa,KAAK,CAAC,CAAC,uBAEzC,CAAC;AAEF;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAI9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface representing an Ackermann node in the computation structure
|
|
3
|
+
*/
|
|
4
|
+
interface IAckermannNode {
|
|
5
|
+
m: number;
|
|
6
|
+
n: number;
|
|
7
|
+
value: bigint;
|
|
8
|
+
prevM?: IAckermannNode;
|
|
9
|
+
prevN?: IAckermannNode;
|
|
10
|
+
nextM?: IAckermannNode;
|
|
11
|
+
nextN?: IAckermannNode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Type for Ackermann computation path step
|
|
15
|
+
*/
|
|
16
|
+
type ComputationStep = {
|
|
17
|
+
m: number;
|
|
18
|
+
n: number;
|
|
19
|
+
value: bigint;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Type for growth rate analysis
|
|
23
|
+
*/
|
|
24
|
+
type GrowthAnalysis = {
|
|
25
|
+
value: bigint;
|
|
26
|
+
increase: bigint;
|
|
27
|
+
multiplier: bigint;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Class representing the Ackermann function computation structure
|
|
31
|
+
* Implements caching and relationship tracking between values
|
|
32
|
+
*/
|
|
33
|
+
export declare class AckermannStructure {
|
|
34
|
+
private nodes;
|
|
35
|
+
private maxComputedM;
|
|
36
|
+
private maxComputedN;
|
|
37
|
+
private heap;
|
|
38
|
+
constructor();
|
|
39
|
+
/**
|
|
40
|
+
* Generates a unique key for node storage
|
|
41
|
+
*/
|
|
42
|
+
private static getNodeKey;
|
|
43
|
+
/**
|
|
44
|
+
* Computes the Ackermann function value
|
|
45
|
+
* Uses recursion with memoization
|
|
46
|
+
*/
|
|
47
|
+
private computeAckermann;
|
|
48
|
+
/**
|
|
49
|
+
* Adds a new node to the structure
|
|
50
|
+
*/
|
|
51
|
+
addNode(m: number, n: number): IAckermannNode;
|
|
52
|
+
/**
|
|
53
|
+
* Builds nodes for a range of m and n values
|
|
54
|
+
*/
|
|
55
|
+
buildRange(mRange: number, nRange: number): void;
|
|
56
|
+
/**
|
|
57
|
+
* Gets the computation path to reach A(m,n)
|
|
58
|
+
*/
|
|
59
|
+
getComputationPath(m: number, n: number): ComputationStep[];
|
|
60
|
+
/**
|
|
61
|
+
* Analyzes growth rate for a fixed m value
|
|
62
|
+
*/
|
|
63
|
+
analyzeGrowthRate(m: number): Map<number, GrowthAnalysis>;
|
|
64
|
+
/**
|
|
65
|
+
* Gets the largest computed value
|
|
66
|
+
*/
|
|
67
|
+
getLargestValue(): bigint;
|
|
68
|
+
/**
|
|
69
|
+
* Gets a specific Ackermann value if it exists
|
|
70
|
+
*/
|
|
71
|
+
getValue(m: number, n: number): bigint | undefined;
|
|
72
|
+
}
|
|
73
|
+
export default AckermannStructure;
|
|
74
|
+
//# sourceMappingURL=ackermann.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ackermann.d.ts","sourceRoot":"","sources":["../../../src/structures/ackermann.ts"],"names":[],"mappings":"AAGE;;GAEG;AACH,UAAU,cAAc;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAA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
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Comparator } from '@/core';
|
|
2
|
+
import { MinHeap, MaxHeap } from '../storage/Heap';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for segment tree node operations
|
|
5
|
+
*/
|
|
6
|
+
export interface SegmentTreeNode<T> {
|
|
7
|
+
value: T;
|
|
8
|
+
lazy?: T;
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Type for BigArray operation result
|
|
14
|
+
*/
|
|
15
|
+
export type OperationResult<T> = {
|
|
16
|
+
success: boolean;
|
|
17
|
+
value?: T;
|
|
18
|
+
error?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Options for BigArray initialization
|
|
22
|
+
*/
|
|
23
|
+
export interface BigArrayOptions<T> {
|
|
24
|
+
initialCapacity?: number;
|
|
25
|
+
growthFactor?: number;
|
|
26
|
+
comparator?: Comparator<T>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A specialized array implementation for handling large numbers and providing
|
|
30
|
+
* efficient operations with segment tree support
|
|
31
|
+
*/
|
|
32
|
+
export declare class BigArray<T> {
|
|
33
|
+
private data;
|
|
34
|
+
private segmentTree;
|
|
35
|
+
private readonly growthFactor;
|
|
36
|
+
private readonly comparator;
|
|
37
|
+
private size;
|
|
38
|
+
private capacity;
|
|
39
|
+
constructor(options?: BigArrayOptions<T>);
|
|
40
|
+
/**
|
|
41
|
+
* Gets the current size of the array
|
|
42
|
+
*/
|
|
43
|
+
getSize(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the current capacity of the array
|
|
46
|
+
*/
|
|
47
|
+
getCapacity(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Resizes the internal array when needed
|
|
50
|
+
*/
|
|
51
|
+
private resize;
|
|
52
|
+
/**
|
|
53
|
+
* Appends an element to the end of the array
|
|
54
|
+
*/
|
|
55
|
+
push(value: T): OperationResult<number>;
|
|
56
|
+
/**
|
|
57
|
+
* Removes and returns the last element
|
|
58
|
+
*/
|
|
59
|
+
pop(): OperationResult<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Gets element at specified index
|
|
62
|
+
*/
|
|
63
|
+
get(index: number): OperationResult<T>;
|
|
64
|
+
/**
|
|
65
|
+
* Sets element at specified index
|
|
66
|
+
*/
|
|
67
|
+
set(index: number, value: T): OperationResult<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Rebuilds the segment tree after major changes
|
|
70
|
+
*/
|
|
71
|
+
private rebuildSegmentTree;
|
|
72
|
+
/**
|
|
73
|
+
* Builds a segment tree node recursively
|
|
74
|
+
*/
|
|
75
|
+
private buildSegmentTree;
|
|
76
|
+
/**
|
|
77
|
+
* Updates the segment tree after a value change
|
|
78
|
+
*/
|
|
79
|
+
private updateSegmentTree;
|
|
80
|
+
/**
|
|
81
|
+
* Queries the maximum value in a range
|
|
82
|
+
*/
|
|
83
|
+
queryRange(start: number, end: number): OperationResult<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Recursively queries the segment tree
|
|
86
|
+
*/
|
|
87
|
+
private querySegmentTree;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a heap from the current array
|
|
90
|
+
*/
|
|
91
|
+
toHeap(isMin?: boolean): MinHeap<T> | MaxHeap<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Sorts the array in-place
|
|
94
|
+
*/
|
|
95
|
+
sort(ascending?: boolean): void;
|
|
96
|
+
/**
|
|
97
|
+
* Returns array as native array
|
|
98
|
+
*/
|
|
99
|
+
toArray(): T[];
|
|
100
|
+
}
|
|
101
|
+
export default BigArray;
|
|
102
|
+
//# sourceMappingURL=big-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"big-array.d.ts","sourceRoot":"","sources":["../../../src/structures/big-array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,OAAO,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EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;IAYvD;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAO1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA4BxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA4BzB;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC;IAWjE;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAuBxB;;OAEG;IACI,MAAM,CAAC,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAgB7D;;OAEG;IACI,IAAI,CAAC,SAAS,GAAE,OAAc,GAAG,IAAI;IAW5C;;OAEG;IACI,OAAO,IAAI,CAAC,EAAE;CAGtB;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/structures/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Comparator } from "@/core";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for tree node statistics
|
|
4
|
+
*/
|
|
5
|
+
interface NodeStats {
|
|
6
|
+
height: number;
|
|
7
|
+
size: number;
|
|
8
|
+
sum: bigint;
|
|
9
|
+
min: bigint;
|
|
10
|
+
max: bigint;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interface for tree traversal configuration
|
|
14
|
+
*/
|
|
15
|
+
interface TraversalConfig {
|
|
16
|
+
includeStats?: boolean;
|
|
17
|
+
skipSubtrees?: boolean;
|
|
18
|
+
maxDepth?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Class representing a node in the number tree
|
|
22
|
+
*/
|
|
23
|
+
declare class NumberNode {
|
|
24
|
+
value: bigint;
|
|
25
|
+
left: NumberNode | null;
|
|
26
|
+
right: NumberNode | null;
|
|
27
|
+
parent: NumberNode | null;
|
|
28
|
+
height: number;
|
|
29
|
+
size: number;
|
|
30
|
+
sum: bigint;
|
|
31
|
+
constructor(value: bigint | string | number);
|
|
32
|
+
/**
|
|
33
|
+
* Updates node statistics based on children
|
|
34
|
+
*/
|
|
35
|
+
updateStats(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Gets balance factor of the node
|
|
38
|
+
*/
|
|
39
|
+
getBalance(): number;
|
|
40
|
+
/**
|
|
41
|
+
* Gets complete statistics for the node and its subtree
|
|
42
|
+
*/
|
|
43
|
+
getStats(): NodeStats;
|
|
44
|
+
/**
|
|
45
|
+
* Finds minimum value node in the subtree
|
|
46
|
+
*/
|
|
47
|
+
findMin(): NumberNode;
|
|
48
|
+
/**
|
|
49
|
+
* Finds maximum value node in the subtree
|
|
50
|
+
*/
|
|
51
|
+
findMax(): NumberNode;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* AVL Tree implementation specialized for handling large numbers
|
|
55
|
+
*/
|
|
56
|
+
export declare class NumberTree {
|
|
57
|
+
private root;
|
|
58
|
+
private readonly comparator;
|
|
59
|
+
constructor(comparator?: Comparator<bigint>);
|
|
60
|
+
/**
|
|
61
|
+
* Gets the root node if it exists
|
|
62
|
+
*/
|
|
63
|
+
getRoot(): NumberNode | null;
|
|
64
|
+
/**
|
|
65
|
+
* Inserts a new value into the tree
|
|
66
|
+
*/
|
|
67
|
+
insert(value: bigint | string | number): NumberNode;
|
|
68
|
+
/**
|
|
69
|
+
* Recursively inserts a new node
|
|
70
|
+
*/
|
|
71
|
+
private insertNode;
|
|
72
|
+
/**
|
|
73
|
+
* Balances a node using AVL rotations
|
|
74
|
+
*/
|
|
75
|
+
private balance;
|
|
76
|
+
/**
|
|
77
|
+
* Performs left rotation
|
|
78
|
+
*/
|
|
79
|
+
private rotateLeft;
|
|
80
|
+
/**
|
|
81
|
+
* Performs right rotation
|
|
82
|
+
*/
|
|
83
|
+
private rotateRight;
|
|
84
|
+
/**
|
|
85
|
+
* Removes a value from the tree
|
|
86
|
+
*/
|
|
87
|
+
remove(value: bigint | string | number): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Recursively removes a node
|
|
90
|
+
*/
|
|
91
|
+
private removeNode;
|
|
92
|
+
/**
|
|
93
|
+
* Finds a node by value
|
|
94
|
+
*/
|
|
95
|
+
find(value: bigint | string | number): NumberNode | null;
|
|
96
|
+
/**
|
|
97
|
+
* Traverses the tree in specified order and returns values
|
|
98
|
+
*/
|
|
99
|
+
traverse(order?: 'inOrder' | 'preOrder' | 'postOrder', config?: TraversalConfig): bigint[];
|
|
100
|
+
/**
|
|
101
|
+
* Gets overall tree statistics
|
|
102
|
+
*/
|
|
103
|
+
getTreeStats(): NodeStats | null;
|
|
104
|
+
/**
|
|
105
|
+
* Gets the nth smallest value in the tree
|
|
106
|
+
*/
|
|
107
|
+
getNthValue(n: number): bigint | null;
|
|
108
|
+
/**
|
|
109
|
+
* Gets a range of values between start and end (inclusive)
|
|
110
|
+
*/
|
|
111
|
+
getRange(start: bigint | string | number, end: bigint | string | number): bigint[];
|
|
112
|
+
}
|
|
113
|
+
export default NumberTree;
|
|
114
|
+
//# sourceMappingURL=number-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-tree.d.ts","sourceRoot":"","sources":["../../../src/structures/number-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;GAEG;AACH,UAAU,SAAS;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IA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