functype 0.14.7 → 0.16.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/README.md +2 -41
- package/README.processed.md +867 -0
- package/dist/{Either-BbfiAy_6.d.ts → Either-C-P6QnvK.d.ts} +28 -31
- package/dist/branded/index.d.ts +12 -5
- package/dist/branded/index.mjs +1 -1
- package/dist/chunk-OR6V4TCO.mjs +2 -0
- package/dist/chunk-OR6V4TCO.mjs.map +1 -0
- package/dist/chunk-ZRLVS2S5.mjs +45 -0
- package/dist/chunk-ZRLVS2S5.mjs.map +1 -0
- package/dist/do/index.d.ts +3 -3
- package/dist/do/index.mjs +1 -1
- package/dist/either/index.d.ts +2 -2
- package/dist/either/index.mjs +1 -1
- package/dist/fpromise/index.d.ts +2 -2
- package/dist/fpromise/index.mjs +1 -1
- package/dist/index.d.ts +65 -58
- package/dist/index.mjs +1 -1
- package/dist/list/index.d.ts +2 -2
- package/dist/list/index.mjs +1 -1
- package/dist/map/index.d.ts +2 -2
- package/dist/map/index.mjs +1 -1
- package/dist/option/index.d.ts +2 -2
- package/dist/option/index.mjs +1 -1
- package/dist/set/index.d.ts +2 -2
- package/dist/set/index.mjs +1 -1
- package/dist/try/index.d.ts +2 -2
- package/dist/try/index.mjs +1 -1
- package/dist/tuple/index.d.ts +1 -1
- package/package.json +19 -16
- package/dist/chunk-45FTMTJA.mjs +0 -43
- package/dist/chunk-45FTMTJA.mjs.map +0 -1
- package/dist/chunk-YBBRJTHY.mjs +0 -2
- package/dist/chunk-YBBRJTHY.mjs.map +0 -1
- package/dist/{Typeable-CitTP1ay.d.ts → Typeable-DiGVtDnq.d.ts} +2 -2
package/dist/do/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { O as Option, E as Either, L as List, T as Try, x as Reshapeable,
|
|
2
|
-
export { D as DoResult } from '../Either-
|
|
3
|
-
import '../Typeable-
|
|
1
|
+
import { O as Option, E as Either, L as List, T as Try, x as Reshapeable, b as Doable } from '../Either-C-P6QnvK.js';
|
|
2
|
+
export { D as DoResult } from '../Either-C-P6QnvK.js';
|
|
3
|
+
import '../Typeable-DiGVtDnq.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Generator-based Do-notation for monadic comprehensions
|
package/dist/do/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{X as $,T as Do,U as DoAsync,_ as EmptyListError,$ as FailureError,Z as LeftError,Y as NoneError,V as isDoCapable,W as unwrap}from'../chunk-ZRLVS2S5.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-OR6V4TCO.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/either/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { E as Either, e as Left, R as Right, d as TestEither, h as TypeCheckLeft, g as TypeCheckRight, f as isLeft, i as isRight, t as tryCatch, j as tryCatchAsync } from '../Either-
|
|
2
|
-
import '../Typeable-
|
|
1
|
+
export { E as Either, e as Left, R as Right, d as TestEither, h as TypeCheckLeft, g as TypeCheckRight, f as isLeft, i as isRight, t as tryCatch, j as tryCatchAsync } from '../Either-C-P6QnvK.js';
|
|
2
|
+
import '../Typeable-DiGVtDnq.js';
|
package/dist/either/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{t as Either,m as Left,l as Right,r as TypeCheckLeft,q as TypeCheckRight,o as isLeft,n as isRight,p as tryCatch,s as tryCatchAsync}from'../chunk-
|
|
1
|
+
export{t as Either,m as Left,l as Right,r as TypeCheckLeft,q as TypeCheckRight,o as isLeft,n as isRight,p as tryCatch,s as tryCatchAsync}from'../chunk-ZRLVS2S5.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-OR6V4TCO.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/fpromise/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as Either } from '../Either-
|
|
2
|
-
import { T as Type } from '../Typeable-
|
|
1
|
+
import { E as Either } from '../Either-C-P6QnvK.js';
|
|
2
|
+
import { T as Type } from '../Typeable-DiGVtDnq.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Error context information that provides additional metadata about errors.
|
package/dist/fpromise/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{N as FPromise,M as FPromiseCompanion}from'../chunk-
|
|
1
|
+
export{N as FPromise,M as FPromiseCompanion}from'../chunk-ZRLVS2S5.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-OR6V4TCO.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Brand } from './branded/index.js';
|
|
2
|
-
export { BrandedBoolean, BrandedNumber, BrandedString, ExtractBrand,
|
|
3
|
-
import { L as List, O as Option, E as Either, D as DoResult,
|
|
4
|
-
export {
|
|
5
|
-
import { T as Type, F as Foldable, P as Pipe, S as Serializable, a as Typeable } from './Typeable-
|
|
6
|
-
export { E as ExtractTag, b as SerializationMethods, c as TypeableParams, i as isTypeable } from './Typeable-
|
|
2
|
+
export { BrandedBoolean, BrandedBoolean as BrandedBooleanType, BrandedNumber, BrandedNumber as BrandedNumberType, BrandedString, BrandedString as BrandedStringType, ExtractBrand, Unwrap, createBrander, hasBrand, unwrap as unwrapBrand } from './branded/index.js';
|
|
3
|
+
import { L as List, O as Option, E as Either, D as DoResult, F as FunctypeBase, a as Extractable, A as AsyncMonad, P as Promisable, b as Doable, T as Try, c as Traversable, M as Matchable } from './Either-C-P6QnvK.js';
|
|
4
|
+
export { u as Applicative, C as Collection, r as CollectionOps, s as ContainerOps, v as Functor, l as Functype, m as FunctypeCollection, e as Left, n as MatchableUtils, w as Monad, N as None, o as OptionConstructor, R as Right, p as Set, S as Some, d as TestEither, h as TypeCheckLeft, g as TypeCheckRight, q as TypeNames, k as isExtractable, f as isLeft, i as isRight, t as tryCatch, j as tryCatchAsync } from './Either-C-P6QnvK.js';
|
|
5
|
+
import { T as Type, F as Foldable, P as Pipe, S as Serializable, a as Typeable } from './Typeable-DiGVtDnq.js';
|
|
6
|
+
export { E as ExtractTag, b as SerializationMethods, c as TypeableParams, i as isTypeable } from './Typeable-DiGVtDnq.js';
|
|
7
7
|
import { FPromise } from './fpromise/index.js';
|
|
8
8
|
export { ErrorContext, FPromiseCompanion } from './fpromise/index.js';
|
|
9
9
|
export { $, Do, DoAsync, DoGenerator, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap } from './do/index.js';
|
|
@@ -735,57 +735,59 @@ interface TaskMetadata {
|
|
|
735
735
|
readonly name: string;
|
|
736
736
|
readonly description: string;
|
|
737
737
|
}
|
|
738
|
-
interface TaskOutcome<T> extends
|
|
739
|
-
readonly _tag: "
|
|
738
|
+
interface TaskOutcome<T> extends FunctypeBase<T, "Ok" | "Err">, Extractable<T>, AsyncMonad<T>, Promisable<T>, Doable<T> {
|
|
739
|
+
readonly _tag: "Ok" | "Err";
|
|
740
740
|
readonly _meta: TaskMetadata;
|
|
741
|
+
readonly value?: T;
|
|
742
|
+
readonly error?: Throwable;
|
|
741
743
|
readonly map: <U>(f: (value: T) => U) => TaskOutcome<U>;
|
|
742
|
-
readonly flatMap: <U>(f: (value: T) => Either<Throwable, U>) => TaskOutcome<U>;
|
|
743
|
-
readonly ap: <U>(ff:
|
|
744
|
-
readonly merge: <T1>(other: Either<Throwable, T1>) => TaskOutcome<[T, T1]>;
|
|
744
|
+
readonly flatMap: <U>(f: (value: T) => TaskOutcome<U> | Either<Throwable, U>) => TaskOutcome<U>;
|
|
745
|
+
readonly ap: <U>(ff: TaskOutcome<(value: T) => U>) => TaskOutcome<U>;
|
|
745
746
|
readonly mapAsync: <U>(f: (value: T) => Promise<U>) => Promise<TaskOutcome<U>>;
|
|
746
|
-
readonly flatMapAsync: <U>(f: (value: T) => Promise<
|
|
747
|
+
readonly flatMapAsync: <U>(f: (value: T) => Promise<TaskOutcome<U>>) => Promise<TaskOutcome<U>>;
|
|
747
748
|
readonly mapError: (f: (error: Throwable) => Throwable) => TaskOutcome<T>;
|
|
748
|
-
readonly recover: (value: T) =>
|
|
749
|
-
readonly recoverWith: (f: (error: Throwable) => T) =>
|
|
750
|
-
readonly isSuccess: () => this is
|
|
751
|
-
readonly isFailure: () => this is
|
|
749
|
+
readonly recover: (value: T) => Ok<T>;
|
|
750
|
+
readonly recoverWith: (f: (error: Throwable) => T) => Ok<T>;
|
|
751
|
+
readonly isSuccess: () => this is Ok<T>;
|
|
752
|
+
readonly isFailure: () => this is Err<T>;
|
|
753
|
+
readonly isOk: () => this is Ok<T>;
|
|
754
|
+
readonly isErr: () => this is Err<T>;
|
|
755
|
+
readonly toEither: () => Either<Throwable, T>;
|
|
756
|
+
readonly toTry: () => Try<T>;
|
|
757
|
+
readonly toOption: () => Option<T>;
|
|
758
|
+
readonly toList: () => List<T>;
|
|
759
|
+
readonly fold: <U>(onErr: (error: Throwable) => U, onOk: (value: T) => U) => U;
|
|
760
|
+
readonly match: <U>(patterns: {
|
|
761
|
+
Ok: (value: T) => U;
|
|
762
|
+
Err: (error: Throwable) => U;
|
|
763
|
+
}) => U;
|
|
752
764
|
}
|
|
753
|
-
|
|
754
|
-
|
|
765
|
+
type TaskSuccess<T> = Ok<T>;
|
|
766
|
+
type TaskFailure<T> = Err<T>;
|
|
767
|
+
interface Err<T> extends TaskOutcome<T> {
|
|
768
|
+
readonly _tag: "Err";
|
|
769
|
+
readonly value: undefined;
|
|
755
770
|
readonly error: Throwable;
|
|
756
771
|
}
|
|
757
772
|
/**
|
|
758
|
-
*
|
|
773
|
+
* Err constructor - Creates a failed TaskOutcome
|
|
759
774
|
* @param error - The error object
|
|
760
775
|
* @param data - Additional data related to the error
|
|
761
776
|
* @param params - Task parameters
|
|
762
777
|
*/
|
|
763
|
-
declare const
|
|
764
|
-
interface
|
|
765
|
-
readonly _tag: "
|
|
778
|
+
declare const Err: <T>(error: unknown, data?: unknown, params?: TaskParams) => Err<T>;
|
|
779
|
+
interface Ok<T> extends TaskOutcome<T> {
|
|
780
|
+
readonly _tag: "Ok";
|
|
781
|
+
readonly value: T;
|
|
782
|
+
readonly error: undefined;
|
|
766
783
|
}
|
|
767
784
|
/**
|
|
768
|
-
*
|
|
785
|
+
* Ok constructor - Creates a successful TaskOutcome
|
|
769
786
|
* @param data - The successful value
|
|
770
787
|
* @param params - Task parameters
|
|
771
788
|
*/
|
|
772
|
-
declare const
|
|
789
|
+
declare const Ok: <T>(data: T, params?: TaskParams) => Ok<T>;
|
|
773
790
|
type TaskResult<T> = Promise<TaskOutcome<T>>;
|
|
774
|
-
/**
|
|
775
|
-
* Ok constructor - Creates a successful TaskOutcome
|
|
776
|
-
* Alias for TaskSuccess for cleaner, more concise code
|
|
777
|
-
* @param value - The successful value
|
|
778
|
-
* @param params - Optional task parameters
|
|
779
|
-
*/
|
|
780
|
-
declare const Ok: <T>(value: T, params?: TaskParams) => TaskSuccess<T>;
|
|
781
|
-
/**
|
|
782
|
-
* Err constructor - Creates a failed TaskOutcome
|
|
783
|
-
* Alias for TaskFailure for cleaner, more concise code
|
|
784
|
-
* @param error - The error value
|
|
785
|
-
* @param data - Optional additional error data
|
|
786
|
-
* @param params - Optional task parameters
|
|
787
|
-
*/
|
|
788
|
-
declare const Err: <T>(error: unknown, data?: unknown, params?: TaskParams) => TaskFailure<T>;
|
|
789
791
|
/**
|
|
790
792
|
* The CancellationToken is a control structure that allows long-running tasks to be cancelled
|
|
791
793
|
* Cancellation is cooperative, meaning the task must check the token and respond to cancellation requests
|
|
@@ -854,21 +856,33 @@ declare const Task: (<T = unknown>(params?: TaskParams) => {
|
|
|
854
856
|
/**
|
|
855
857
|
* Create a successful Task result
|
|
856
858
|
*/
|
|
857
|
-
success: <T>(data: T, params?: TaskParams) =>
|
|
859
|
+
success: <T>(data: T, params?: TaskParams) => Ok<T>;
|
|
858
860
|
/**
|
|
859
861
|
* Create a failed Task result
|
|
860
862
|
*/
|
|
861
|
-
fail: <T>(error: unknown, data?: unknown, params?: TaskParams) =>
|
|
863
|
+
fail: <T>(error: unknown, data?: unknown, params?: TaskParams) => Err<T>;
|
|
862
864
|
/**
|
|
863
865
|
* Create a successful Task result (alias for success)
|
|
864
866
|
* Preferred for new code
|
|
865
867
|
*/
|
|
866
|
-
ok: <T>(data: T, params?: TaskParams) =>
|
|
868
|
+
ok: <T>(data: T, params?: TaskParams) => Ok<T>;
|
|
867
869
|
/**
|
|
868
870
|
* Create a failed Task result (alias for fail)
|
|
869
871
|
* Preferred for new code
|
|
870
872
|
*/
|
|
871
|
-
err: <T>(error: unknown, data?: unknown, params?: TaskParams) =>
|
|
873
|
+
err: <T>(error: unknown, data?: unknown, params?: TaskParams) => Err<T>;
|
|
874
|
+
/**
|
|
875
|
+
* Create TaskOutcome from Either
|
|
876
|
+
* @param either - Either to convert
|
|
877
|
+
* @param params - Task parameters
|
|
878
|
+
*/
|
|
879
|
+
fromEither: <T>(either: Either<Throwable, T>, params?: TaskParams) => TaskOutcome<T>;
|
|
880
|
+
/**
|
|
881
|
+
* Create TaskOutcome from Try
|
|
882
|
+
* @param tryValue - Try to convert
|
|
883
|
+
* @param params - Task parameters
|
|
884
|
+
*/
|
|
885
|
+
fromTry: <T>(tryValue: Try<T>, params?: TaskParams) => TaskOutcome<T>;
|
|
872
886
|
/**
|
|
873
887
|
* Extract the error chain from a Throwable error
|
|
874
888
|
* Returns an array of errors from outermost to innermost
|
|
@@ -1368,13 +1382,6 @@ interface Lazy<T extends Type> extends FunctypeBase<T, "Lazy">, Extractable<T>,
|
|
|
1368
1382
|
readonly _tag: "Lazy";
|
|
1369
1383
|
/** Whether the computation has been evaluated */
|
|
1370
1384
|
readonly isEvaluated: boolean;
|
|
1371
|
-
/**
|
|
1372
|
-
* Forces evaluation of the lazy value and returns the result.
|
|
1373
|
-
* The result is memoized after first evaluation.
|
|
1374
|
-
* @returns The computed value
|
|
1375
|
-
* @throws Any error thrown by the computation
|
|
1376
|
-
*/
|
|
1377
|
-
get(): T;
|
|
1378
1385
|
/**
|
|
1379
1386
|
* Returns the computed value or a default value if computation fails
|
|
1380
1387
|
* @param defaultValue - The value to return if computation fails
|
|
@@ -1387,12 +1394,12 @@ interface Lazy<T extends Type> extends FunctypeBase<T, "Lazy">, Extractable<T>,
|
|
|
1387
1394
|
*/
|
|
1388
1395
|
getOrNull(): T | null;
|
|
1389
1396
|
/**
|
|
1390
|
-
* Returns the computed value or throws
|
|
1391
|
-
* @param error -
|
|
1397
|
+
* Returns the computed value or throws an error if computation fails
|
|
1398
|
+
* @param error - Optional custom error to throw. If not provided, throws the computation error or a default error
|
|
1392
1399
|
* @returns The computed value
|
|
1393
|
-
* @throws The specified error
|
|
1400
|
+
* @throws The specified error, computation error, or a default error
|
|
1394
1401
|
*/
|
|
1395
|
-
getOrThrow(error
|
|
1402
|
+
getOrThrow(error?: Error): T;
|
|
1396
1403
|
/**
|
|
1397
1404
|
* Maps the value inside the Lazy using the provided function
|
|
1398
1405
|
* @param f - The mapping function
|
|
@@ -1533,8 +1540,8 @@ interface Lazy<T extends Type> extends FunctypeBase<T, "Lazy">, Extractable<T>,
|
|
|
1533
1540
|
* return 42
|
|
1534
1541
|
* })
|
|
1535
1542
|
* // Nothing printed yet
|
|
1536
|
-
* const result = expensive.
|
|
1537
|
-
* const cached = expensive.
|
|
1543
|
+
* const result = expensive.getOrThrow() // Prints "Computing..." and returns 42
|
|
1544
|
+
* const cached = expensive.getOrThrow() // Returns 42 without printing
|
|
1538
1545
|
*
|
|
1539
1546
|
* @example
|
|
1540
1547
|
* // Error handling
|
|
@@ -1552,14 +1559,14 @@ interface Lazy<T extends Type> extends FunctypeBase<T, "Lazy">, Extractable<T>,
|
|
|
1552
1559
|
* .map(x => x * 2)
|
|
1553
1560
|
* .flatMap(x => Lazy(() => x + 5))
|
|
1554
1561
|
* .recover(err => 0)
|
|
1555
|
-
* .
|
|
1562
|
+
* .getOrThrow() // 25
|
|
1556
1563
|
*
|
|
1557
1564
|
* @example
|
|
1558
1565
|
* // Integration with functype
|
|
1559
1566
|
* const userOption = Option({ id: 1, name: "Alice" })
|
|
1560
1567
|
* const userName = Lazy.fromOption(userOption, () => ({ id: 0, name: "Anonymous" }))
|
|
1561
1568
|
* .map(user => user.name)
|
|
1562
|
-
* .
|
|
1569
|
+
* .getOrThrow() // "Alice"
|
|
1563
1570
|
*/
|
|
1564
1571
|
declare const Lazy: (<T extends Type>(thunk: () => T) => Lazy<T>) & {
|
|
1565
1572
|
/**
|
|
@@ -1805,4 +1812,4 @@ declare const Stack: (<A extends Type>(values?: A[]) => Stack<A>) & {
|
|
|
1805
1812
|
fromBinary: <A>(binary: string) => Stack<A>;
|
|
1806
1813
|
};
|
|
1807
1814
|
|
|
1808
|
-
export { type Async, Base, BoundedNumber, BoundedString, Brand, type CancellationToken, type CancellationTokenSource, Companion, Cond, DoResult, ESMap, type ESMapType, Either, type EitherKind, EmailAddress, Err, type ErrorChainElement, type ErrorCode, type ErrorFormatterOptions, type ErrorMessage, type ErrorStatus, type ErrorWithTaskInfo, Extractable, FPromise, type FieldValidation, Foldable, FoldableUtils, type FormValidation, FunctypeBase, HKT, ISO8601Date, Identity, IntegerNumber, type Kind, Lazy, LazyList, Lazy as LazyType, List, type ListKind, Match, Matchable, NAME, NonEmptyString, NonNegativeNumber, Ok, Option, type OptionKind, ParseError, PatternString, Pipe, PositiveInteger, PositiveNumber, Ref, Ref as RefType, Serializable, Stack, type Sync, type TaggedThrowable, Task, type TaskErrorInfo, TaskFailure, type TaskMetadata, type TaskOutcome, type TaskParams, type TaskResult, TaskSuccess, Throwable, type ThrowableType, Traversable, Try, type TryKind, Type, Typeable, TypedError, type TypedErrorContext, UUID, type UniversalContainer, UrlString, ValidatedBrand, type ValidatedBrandCompanion, Validation, type ValidationRule, type Validator, Valuable, type ValuableParams, createCancellationTokenSource, createErrorSerializer, formatError, formatStackTrace, isTaggedThrowable, safeStringify };
|
|
1815
|
+
export { type Async, AsyncMonad, Base, BoundedNumber, BoundedString, Brand, type CancellationToken, type CancellationTokenSource, Companion, Cond, DoResult, Doable, ESMap, type ESMapType, Either, type EitherKind, EmailAddress, Err, type ErrorChainElement, type ErrorCode, type ErrorFormatterOptions, type ErrorMessage, type ErrorStatus, type ErrorWithTaskInfo, Extractable, FPromise, type FieldValidation, Foldable, FoldableUtils, type FormValidation, FunctypeBase, HKT, ISO8601Date, Identity, IntegerNumber, type Kind, Lazy, LazyList, Lazy as LazyType, List, type ListKind, Match, Matchable, NAME, NonEmptyString, NonNegativeNumber, Ok, Option, type OptionKind, ParseError, PatternString, Pipe, PositiveInteger, PositiveNumber, Promisable, Ref, Ref as RefType, Serializable, Stack, type Sync, type TaggedThrowable, Task, type TaskErrorInfo, type TaskFailure, type TaskMetadata, type TaskOutcome, type TaskParams, type TaskResult, type TaskSuccess, Throwable, type ThrowableType, Traversable, Try, type TryKind, Type, Typeable, TypedError, type TypedErrorContext, UUID, type UniversalContainer, UrlString, ValidatedBrand, type ValidatedBrandCompanion, ValidatedBrand as ValidatedBrandType, Validation, type ValidationRule, type Validator, Valuable, type ValuableParams, createCancellationTokenSource, createErrorSerializer, formatError, formatStackTrace, isTaggedThrowable, safeStringify };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{X as $,J as Base,E as BoundedNumber,F as BoundedString,H as Cond,T as Do,U as DoAsync,ma as ESMap,t as Either,A as EmailAddress,_ as EmptyListError,P as Err,N as FPromise,M as FPromiseCompanion,$ as FailureError,ia as FoldableUtils,ja as HKT,D as ISO8601Date,ka as Identity,x as IntegerNumber,la as Lazy,g as LazyList,m as Left,Z as LeftError,k as List,na as Map,I as Match,oa as MatchableUtils,K as NAME,z as NonEmptyString,w as NonNegativeNumber,b as None,Y as NoneError,Q as Ok,d as Option,c as OptionConstructor,ea as ParseError,G as PatternString,y as PositiveInteger,v as PositiveNumber,f as Ref,l as Right,e as Set,a as Some,pa as Stack,S as Task,L as Throwable,h as Try,r as TypeCheckLeft,q as TypeCheckRight,i as Typeable,fa as TypedError,C as UUID,B as UrlString,u as ValidatedBrand,ga as Validation,qa as Valuable,R as createCancellationTokenSource,da as createErrorSerializer,ca as formatError,ba as formatStackTrace,V as isDoCapable,ha as isExtractable,o as isLeft,n as isRight,O as isTaggedThrowable,j as isTypeable,aa as safeStringify,p as tryCatch,s as tryCatchAsync,W as unwrap}from'./chunk-ZRLVS2S5.mjs';export{a as Companion,b as Tuple}from'./chunk-BQJB6CCW.mjs';export{a as Brand,g as BrandedBoolean,f as BrandedNumber,e as BrandedString,d as createBrander,c as hasBrand,b as unwrapBrand}from'./chunk-OR6V4TCO.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/list/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { L as List } from '../Either-
|
|
2
|
-
import '../Typeable-
|
|
1
|
+
export { L as List } from '../Either-C-P6QnvK.js';
|
|
2
|
+
import '../Typeable-DiGVtDnq.js';
|
package/dist/list/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{k as List}from'../chunk-
|
|
1
|
+
export{k as List}from'../chunk-ZRLVS2S5.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-OR6V4TCO.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as Typeable, S as Serializable, P as Pipe, F as Foldable, T as Type } from '../Typeable-
|
|
1
|
+
import { c as Traversable, C as Collection, O as Option } from '../Either-C-P6QnvK.js';
|
|
2
|
+
import { a as Typeable, S as Serializable, P as Pipe, F as Foldable, T as Type } from '../Typeable-DiGVtDnq.js';
|
|
3
3
|
import { Tuple } from '../tuple/index.js';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/map/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{na as Map}from'../chunk-ZRLVS2S5.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-OR6V4TCO.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/option/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { N as None, O as Option, o as OptionConstructor, S as Some } from '../Either-
|
|
2
|
-
import '../Typeable-
|
|
1
|
+
export { N as None, O as Option, o as OptionConstructor, S as Some } from '../Either-C-P6QnvK.js';
|
|
2
|
+
import '../Typeable-DiGVtDnq.js';
|
package/dist/option/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{b as None,d as Option,c as OptionConstructor,a as Some}from'../chunk-
|
|
1
|
+
export{b as None,d as Option,c as OptionConstructor,a as Some}from'../chunk-ZRLVS2S5.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-OR6V4TCO.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/set/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { p as Set } from '../Either-
|
|
2
|
-
import '../Typeable-
|
|
1
|
+
export { p as Set } from '../Either-C-P6QnvK.js';
|
|
2
|
+
import '../Typeable-DiGVtDnq.js';
|
package/dist/set/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{e as Set}from'../chunk-
|
|
1
|
+
export{e as Set}from'../chunk-ZRLVS2S5.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-OR6V4TCO.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/try/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { T as Try, q as TypeNames } from '../Either-
|
|
2
|
-
import '../Typeable-
|
|
1
|
+
export { T as Try, q as TypeNames } from '../Either-C-P6QnvK.js';
|
|
2
|
+
import '../Typeable-DiGVtDnq.js';
|
package/dist/try/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{h as Try}from'../chunk-
|
|
1
|
+
export{h as Try}from'../chunk-ZRLVS2S5.mjs';import'../chunk-BQJB6CCW.mjs';import'../chunk-OR6V4TCO.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/tuple/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as Type, F as Foldable, P as Pipe, S as Serializable, a as Typeable } from '../Typeable-
|
|
1
|
+
import { T as Type, F as Foldable, P as Pipe, S as Serializable, a as Typeable } from '../Typeable-DiGVtDnq.js';
|
|
2
2
|
|
|
3
3
|
interface Tuple<T extends Type[]> extends Foldable<T[number]>, Pipe<Tuple<T>>, Serializable<Tuple<T>>, Typeable<"Tuple"> {
|
|
4
4
|
get<K extends number>(index: K): T[K];
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "A
|
|
5
|
+
"description": "A functional programming library for TypeScript, using immutable data structures and type classes",
|
|
6
6
|
"author": "jordan.burke@gmail.com",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -12,33 +12,34 @@
|
|
|
12
12
|
"homepage": "https://github.com/jordanburke/functype#readme",
|
|
13
13
|
"url": "https://github.com/jordanburke/functype",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@eslint/compat": "^1.
|
|
15
|
+
"@eslint/compat": "^1.4.0",
|
|
16
16
|
"@eslint/eslintrc": "^3.3.1",
|
|
17
|
-
"@eslint/js": "^9.
|
|
17
|
+
"@eslint/js": "^9.37.0",
|
|
18
18
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
19
|
-
"@semantic-release/github": "^11.0.
|
|
19
|
+
"@semantic-release/github": "^11.0.6",
|
|
20
20
|
"@semantic-release/npm": "^12.0.2",
|
|
21
|
-
"@semantic-release/release-notes-generator": "^14.0
|
|
22
|
-
"@types/node": "^22.18.
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
24
|
-
"@typescript-eslint/parser": "^8.
|
|
21
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
22
|
+
"@types/node": "^22.18.8",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^8.46.0",
|
|
24
|
+
"@typescript-eslint/parser": "^8.46.0",
|
|
25
25
|
"@vitest/coverage-v8": "^3.2.4",
|
|
26
26
|
"@vitest/ui": "^3.2.4",
|
|
27
|
-
"cross-env": "^10.
|
|
28
|
-
"eslint": "^9.
|
|
27
|
+
"cross-env": "^10.1.0",
|
|
28
|
+
"eslint": "^9.37.0",
|
|
29
29
|
"eslint-config-functype": "1.3.0",
|
|
30
30
|
"eslint-config-prettier": "^10.1.8",
|
|
31
31
|
"eslint-plugin-functional": "^9.0.2",
|
|
32
32
|
"eslint-plugin-prettier": "^5.5.4",
|
|
33
33
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
34
|
-
"fast-check": "^4.
|
|
35
|
-
"globals": "^16.
|
|
34
|
+
"fast-check": "^4.3.0",
|
|
35
|
+
"globals": "^16.4.0",
|
|
36
36
|
"prettier": "^3.6.2",
|
|
37
37
|
"rimraf": "^6.0.1",
|
|
38
|
-
"semantic-release": "^24.2.
|
|
38
|
+
"semantic-release": "^24.2.9",
|
|
39
39
|
"ts-node": "^10.9.2",
|
|
40
40
|
"tsup": "^8.5.0",
|
|
41
|
-
"
|
|
41
|
+
"tsx": "^4.20.6",
|
|
42
|
+
"typedoc": "^0.28.13",
|
|
42
43
|
"typescript": "5.9.2",
|
|
43
44
|
"vitest": "^3.2.4"
|
|
44
45
|
},
|
|
@@ -166,8 +167,10 @@
|
|
|
166
167
|
"clean": "rimraf dist",
|
|
167
168
|
"bench": "vitest bench",
|
|
168
169
|
"bench:ui": "vitest bench --ui",
|
|
169
|
-
"docs": "
|
|
170
|
+
"docs:preprocess": "tsx scripts/preprocess-docs.ts",
|
|
171
|
+
"docs": "pnpm docs:preprocess && typedoc",
|
|
170
172
|
"docs:watch": "typedoc --watch",
|
|
173
|
+
"docs:validate": "tsx scripts/validate-docs.ts",
|
|
171
174
|
"postdocs": "node -e \"console.log('Documentation generated in ./typedocs')\"",
|
|
172
175
|
"analyze:size": "pnpm build && node ./scripts/analyze-bundle-size.js"
|
|
173
176
|
}
|
package/dist/chunk-45FTMTJA.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {a,b as b$1}from'./chunk-BQJB6CCW.mjs';import {a as a$1}from'./chunk-YBBRJTHY.mjs';import fe from'safe-stable-stringify';var Y=Set;var N=t=>{let e=new Y(t),r={_tag:"Set",[Symbol.iterator]:()=>e[Symbol.iterator](),add:n=>N([...e,n]),remove:n=>{let o=new Y(e);return o.delete(n),N(o)},contains:n=>e.has(n),has:n=>e.has(n),map:n=>N(Array.from(e).map(n)),ap:n=>{let o=new Y;for(let a of e)for(let s of n)o.add(s(a));return N(o)},flatMap:n=>{let o=new Y;for(let a of e)for(let s of n(a))o.add(s);return N(o)},flatMapAsync:async n=>{let o=new Y;for(let a of e){let s=await n(a);for(let i of s)o.add(i);}return N(o)},fold:(n,o)=>{if(e.size===0)return n();let a=Array.from(e);if(a.length===0)return n();let s=a[0];return s===void 0?n():o(s)},foldLeft:n=>o=>{let a=n;for(let s of e)a=o(a,s);return a},foldRight:n=>o=>Array.from(e).reduceRight((s,i)=>o(i,s),n),get size(){return e.size},get isEmpty(){return e.size===0},reduce:n=>{let o=Array.from(e);if(o.length===0)throw new Error("Cannot reduce empty Set");return o.reduce(n)},reduceRight:n=>{let o=Array.from(e);if(o.length===0)throw new Error("Cannot reduceRight empty Set");return o.reduceRight(n)},count:n=>{let o=0;for(let a of e)n(a)&&o++;return o},find:n=>{for(let o of e)if(n(o))return f(o);return f(null)},exists:n=>{for(let o of e)if(n(o))return true;return false},forEach:n=>{e.forEach(n);},filter:n=>{let o=new Y;for(let a of e)n(a)&&o.add(a);return N(o)},filterNot:n=>{let o=new Y;for(let a of e)n(a)||o.add(a);return N(o)},drop:n=>N(Array.from(e).slice(n)),dropRight:n=>N(Array.from(e).slice(0,-n)),dropWhile:n=>{let o=Array.from(e),a=o.findIndex(s=>!n(s));return N(a===-1?[]:o.slice(a))},flatten:()=>{let n=new Y;for(let o of e)if(Array.isArray(o))for(let a of o)n.add(a);else if(o&&typeof o=="object"&&Symbol.iterator in o)for(let a of o)n.add(a);else n.add(o);return N(n)},get head(){return Array.from(e)[0]},get headOption(){let n=Array.from(e)[0];return f(n)},toList:()=>m(Array.from(e)),toSet:()=>r,toArray:()=>Array.from(e),toString:()=>`Set(${Array.from(e).toString()})`,toValue:()=>({_tag:"Set",value:Array.from(e)}),pipe:n=>n(Array.from(e)),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Set",value:Array.from(e)}),toYAML:()=>`_tag: Set
|
|
2
|
-
value: ${JSON.stringify(Array.from(e))}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Set",value:Array.from(e)})).toString("base64")})};return r},tt=t=>N(t),Ne={fromJSON:t=>{let e=JSON.parse(t);return te(e.value)},fromYAML:t=>{let r=t.split(`
|
|
3
|
-
`)[1]?.split(": ")[1];if(!r)return te([]);let n=JSON.parse(r);return te(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Ne.fromJSON(e)}},te=a(tt,Ne);function k(t){let e=t;return {get(){return e},set(n){e=n;},update(n){e=n(e);},getAndSet(n){let o=e;return e=n,o},updateAndGet(n){return e=n(e),e},getAndUpdate(n){let o=e;return e=n(e),o},compareAndSet(n,o){return e===n?(e=o,true):false},modify(n){let[o,a]=n(e);return e=o,a}}}k.of=k;var ae=(t=0)=>{let e=k(t),r=t;return {get:()=>e.get(),set:n=>e.set(n),increment:()=>e.updateAndGet(n=>n+1),decrement:()=>e.updateAndGet(n=>n-1),reset:()=>e.set(r),compareAndSet:(n,o)=>e.compareAndSet(n,o)}};var Ee=()=>{let t=k([]);return {add:e=>t.update(r=>[...r,e]),addAll:e=>t.update(r=>[...r,...e]),build:()=>t.get(),clear:()=>t.set([]),size:()=>t.get().length}};var S=t=>{let e={_tag:"LazyList",[Symbol.iterator]:()=>t[Symbol.iterator](),map:r=>S((function*(){for(let n of t)yield r(n);})()),flatMap:r=>S((function*(){for(let n of t)yield*r(n);})()),filter:r=>S((function*(){for(let n of t)r(n)&&(yield n);})()),take:r=>S((function*(){let n=ae(0);for(let o of t){if(n.get()>=r)break;yield o,n.increment();}})()),drop:r=>S((function*(){let n=ae(0);for(let o of t)n.get()>=r&&(yield o),n.increment();})()),takeWhile:r=>S((function*(){for(let n of t){if(!r(n))break;yield n;}})()),dropWhile:r=>S((function*(){let n=k(true);for(let o of t)n.get()&&r(o)||(n.set(false),yield o);})()),concat:r=>S((function*(){yield*t,yield*r;})()),zip:r=>S((function*(){let n=t[Symbol.iterator](),o=r[Symbol.iterator]();for(;;){let a=n.next(),s=o.next();if(a.done||s.done)break;yield [a.value,s.value];}})()),toList:()=>m(Array.from(t)),toArray:()=>Array.from(t),forEach:r=>{for(let n of t)r(n);},reduce:(r,n)=>{let o=k(n);for(let a of t)o.set(r(o.get(),a));return o.get()},find:r=>{for(let n of t)if(r(n))return f(n);return f.none()},some:r=>{for(let n of t)if(r(n))return true;return false},every:r=>{for(let n of t)if(!r(n))return false;return true},count:()=>{let r=ae(0);for(let n of t)r.increment();return r.get()},first:()=>{let n=t[Symbol.iterator]().next();return n.done?f.none():f(n.value)},last:()=>{let r=k(void 0),n=k(false);for(let o of t)r.set(o),n.set(true);return n.get()?f(r.get()):f.none()},fold:(r,n)=>{let a=t[Symbol.iterator]().next();return a.done?r():n(a.value)},foldLeft:r=>n=>{let o=k(r);for(let a of t)o.set(n(o.get(),a));return o.get()},foldRight:r=>n=>Array.from(t).reduceRight((a,s)=>n(s,a),r),pipe:r=>r(e),serialize:()=>{let r=Array.from(t);return {toJSON:()=>JSON.stringify({_tag:"LazyList",value:r}),toYAML:()=>`_tag: LazyList
|
|
4
|
-
value: ${fe(r)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"LazyList",value:r})).toString("base64")}},toString:()=>{let n=[],o=ae(0),a=k(false);for(let i of t)if(o.get()<10)n.push(i),o.increment();else {a.set(true);break}let s=n.map(i=>String(i)).join(", ");return a.get()?`LazyList(${s}, ...)`:`LazyList(${s})`}};return e},nt=t=>S(t),ot={empty:()=>S([]),of:t=>S([t]),from:(...t)=>S(t),iterate:(t,e)=>S((function*(){let r=k(t);for(;;)yield r.get(),r.set(e(r.get()));})()),generate:t=>S((function*(){for(;;)yield t();})()),range:(t,e,r=1)=>S((function*(){if(r===0)throw new Error("Step cannot be zero");let n=k(t);if(r>0)for(;n.get()<e;)yield n.get(),n.set(n.get()+r);else for(;n.get()>e;)yield n.get(),n.set(n.get()+r);})()),repeat:(t,e)=>S((function*(){if(e===void 0)for(;;)yield t;else {let r=ae(0);for(;r.get()<e;)yield t,r.increment();}})()),cycle:t=>S((function*(){let e=Array.from(t);if(e.length!==0)for(;;)yield*e;})())},Kt=a(nt,ot);var Te=t=>({_tag:"Success",error:void 0,isSuccess(){return true},isFailure(){return false},get:()=>t,getOrElse:e=>t,getOrThrow:e=>t,orElse:e=>Te(t),orNull:()=>t,orUndefined:()=>t,orThrow:e=>t,toEither:e=>c(t),map:e=>B(()=>e(t)),ap:e=>e.map(r=>r(t)),flatMap:e=>e(t),flatMapAsync:async e=>e(t),fold:(e,r)=>r(t),match:e=>e.Success(t),foldLeft:e=>r=>r(e,t),foldRight:e=>r=>r(t,e),toString:()=>`Success(${fe(t)})`,toPromise:()=>Promise.resolve(t),toValue:()=>({_tag:"Success",value:t}),toOption:()=>w(t),toList:()=>m([t]),toTry:()=>Te(t),pipe:e=>e(t),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Success",value:t}),toYAML:()=>`_tag: Success
|
|
5
|
-
value: ${fe(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Success",value:t})).toString("base64")}),get size(){return 1},get isEmpty(){return false},contains:e=>t===e,reduce:e=>t,reduceRight:e=>t,count:e=>e(t)?1:0,find:e=>e(t)?f(t):f(void 0),exists:e=>e(t),forEach:e=>e(t),doUnwrap(){return {ok:true,value:t}}}),D=t=>({_tag:"Failure",error:t,isSuccess(){return false},isFailure(){return true},get:()=>{throw t},getOrElse:e=>e,getOrThrow:e=>{throw e??t},orElse:e=>e,orNull:()=>null,orUndefined:()=>{},orThrow:e=>{throw e},toEither:e=>p(t),map:e=>D(t),ap:e=>D(t),flatMap:e=>D(t),flatMapAsync:e=>Promise.resolve(D(t)),fold:(e,r)=>e(t),match:e=>e.Failure(t),foldLeft:e=>r=>e,foldRight:e=>r=>e,toString:()=>`Failure(${fe(t)}))`,toPromise:()=>Promise.reject(t),toValue:()=>({_tag:"Failure",value:t}),toOption:()=>b(),toList:()=>m([]),toTry:()=>D(t),pipe:e=>{throw t},serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Failure",error:t.message,stack:t.stack}),toYAML:()=>`_tag: Failure
|
|
6
|
-
error: ${t.message}
|
|
7
|
-
stack: ${t.stack}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Failure",error:t.message,stack:t.stack})).toString("base64")}),get size(){return 0},get isEmpty(){return true},contains:e=>false,reduce:e=>{throw new Error("Cannot reduce a Failure")},reduceRight:e=>{throw new Error("Cannot reduceRight a Failure")},count:e=>0,find:e=>f(null),exists:e=>false,forEach:e=>{},doUnwrap(){return {ok:false,empty:false,error:t}}}),at=t=>{try{return Te(t())}catch(e){return D(e instanceof Error?e:new Error(String(e)))}},Me={fromJSON:t=>{let e=JSON.parse(t);if(e._tag==="Success")return Te(e.value);{let r=new Error(e.error);return e.stack&&(r.stack=e.stack),D(r)}},fromYAML:t=>{let e=t.split(`
|
|
8
|
-
`),r=e[0]?.split(": ")[1];if(!r)return D(new Error("Invalid YAML format for Try"));if(r==="Success"){let n=e[1]?.split(": ")[1];if(!n)return D(new Error("Invalid YAML format for Try Success"));let o=JSON.parse(n);return Te(o)}else {let n=e[1]?.split(": ")[1];if(!n)return D(new Error("Invalid YAML format for Try Failure"));let o=e[2]?.split(": "),a=o&&o.length>1?o.slice(1).join(": "):void 0,s=new Error(n);return a&&(s.stack=a),D(s)}},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Me.fromJSON(e)}},B=a(at,Me);function Re({_tag:t,impl:e}){return {...e,_tag:t}}function be(t,e){return !t||typeof t!="object"||!("_tag"in t)?false:e?t._tag===e:true}var v=t=>{let e=Array.from(t??[]),r={_tag:"List",[Symbol.iterator]:()=>e[Symbol.iterator](),get size(){return e.length},get length(){return e.length},map:n=>v(e.map(n)),ap:n=>v(e.flatMap(o=>Array.from(n).map(a=>a(o)))),flatMap:n=>v(e.flatMap(o=>Array.from(n(o)))),flatMapAsync:async n=>{let o=await Promise.all(e.map(async a=>await n(a)));return v(o.flatMap(a=>Array.from(a)))},forEach:n=>e.forEach(n),contains:n=>e.includes(n),count:n=>e.filter(n).length,exists:n=>e.some(n),filter:n=>v(e.filter(n)),filterNot:n=>v(e.filter(o=>!n(o))),filterType:n=>v(e.filter(o=>be(o,n))),find:(n,o)=>{let a=e.find(s=>n(s)&&(o?be(s,o):true));return f(a)},get head(){return e[0]},get headOption(){return e.length>0?f(e[0]):b()},get isEmpty(){return e.length===0},toArray:()=>[...e],reduce:n=>e.reduce(n),reduceRight:n=>e.reduceRight(n),fold:(n,o)=>{if(e.length===0)return n();let a=e[0];return o(a)},foldLeft:n=>o=>e.reduce(o,n),foldRight:n=>o=>e.reduceRight((a,s)=>o(s,a),n),match:n=>e.length===0?n.Empty():n.NonEmpty([...e]),remove:n=>v(e.filter(o=>o!==n)),removeAt:n=>n<0||n>=e.length?r:v([...e.slice(0,n),...e.slice(n+1)]),add:n=>v([...e,n]),get:n=>f(e[n]),concat:n=>v([...e,...n.toArray()]),drop:n=>v(e.slice(n)),dropRight:n=>v(e.slice(0,-n)),dropWhile:n=>v(e.slice(e.findIndex(o=>!n(o)))),flatten:()=>v(e.flatMap(n=>Array.isArray(n)?n:[n])),toList:()=>r,toSet:()=>te(e),toOption:()=>e.length>0?f(e[0]):b(),toEither:n=>e.length>0?c(e[0]):p(n),toTry:()=>e.length>0?B(()=>e[0]):B(()=>{throw new Error("Empty list")}),toString:()=>`List(${fe(e)})`,toValue:()=>({_tag:"List",value:e}),pipe:n=>n([...e]),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"List",value:e}),toYAML:()=>`_tag: List
|
|
9
|
-
value: ${fe(e)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"List",value:e})).toString("base64")}),doUnwrap(){return e.length===0?{ok:false,empty:true}:{ok:true,value:e[0]}}};return r},st=t=>v(t),Ce={fromJSON:t=>{let e=JSON.parse(t);return m(e.value)},fromYAML:t=>{let r=t.split(`
|
|
10
|
-
`)[1]?.split(": ")[1];if(!r)return m([]);let n=JSON.parse(r);return m(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Ce.fromJSON(e)}},m=a(st,Ce);var Ie=t=>({_tag:"Right",value:t,isLeft(){return false},isRight(){return true},get:()=>t,getOrElse:e=>t,getOrThrow:()=>t,orElse:e=>c(t),orNull:()=>t,orUndefined:()=>t,map:e=>c(e(t)),ap:e=>e._tag==="Right"?c(e.value(t)):p(e.value),mapAsync:e=>e(t).then(r=>c(r)).catch(r=>Promise.resolve(p(r))),merge:e=>e.isLeft()?p(e.value):c([t,e.value]),flatMap:e=>e(t),flatMapAsync:e=>e(t).catch(r=>p(r)),toOption:()=>w(t),toList:()=>m([t]),toEither:e=>c(t),toTry:()=>B(()=>t),toJSON(){return {_tag:"Right",value:t}},toString:()=>`Right(${fe(t)})`,*[Symbol.iterator](){yield t;},*yield(){yield t;},traverse:e=>{let r=e(t);return r.isLeft()?p(r.value):c([r.value])},*lazyMap(e){yield c(e(t));},tap:e=>(e(t),c(t)),tapLeft:e=>c(t),mapLeft:e=>c(t),bimap:(e,r)=>c(r(t)),fold:(e,r)=>r(t),foldLeft:e=>r=>r(e,t),foldRight:e=>r=>r(t,e),match:e=>e.Right(t),swap:()=>p(t),toPromise:()=>Promise.resolve(t),toValue:()=>({_tag:"Right",value:t}),pipeEither:(e,r)=>r(t),pipe:e=>e(t),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Right",value:t}),toYAML:()=>`_tag: Right
|
|
11
|
-
value: ${fe(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Right",value:t})).toString("base64")}),get size(){return 1},get isEmpty(){return false},contains:e=>t===e,reduce:e=>t,reduceRight:e=>t,count:e=>e(t)?1:0,find:e=>e(t)?w(t):b(),exists:e=>e(t),forEach:e=>e(t),doUnwrap(){return {ok:true,value:t}}}),ze=t=>({_tag:"Left",value:t,isLeft(){return true},isRight(){return false},get:()=>{throw new Error(`Cannot call get() on Left(${fe(t)})`)},getOrElse:e=>e,getOrThrow:e=>{throw e??t},orElse:e=>e,orNull:()=>null,orUndefined:()=>{},map:e=>p(t),ap:e=>p(t),mapAsync:e=>Promise.resolve(p(t)),merge:e=>p(t),flatMap:e=>p(t),flatMapAsync:e=>Promise.resolve(p(t)),toOption:()=>b(),toList:()=>m(),toEither:e=>p(e),toTry:()=>B(()=>{throw new Error(String(t))}),toJSON(){return {_tag:"Left",value:t}},toString:()=>`Left(${fe(t)})`,*[Symbol.iterator](){},*yield(){},traverse:e=>p(t),*lazyMap(e){yield p(t);},tap:e=>p(t),tapLeft:e=>(e(t),p(t)),mapLeft:e=>p(e(t)),bimap:(e,r)=>p(e(t)),fold:(e,r)=>e(t),foldLeft:e=>r=>e,foldRight:e=>r=>e,match:e=>e.Left(t),swap:()=>c(t),toPromise:()=>Promise.reject(t),toValue:()=>({_tag:"Left",value:t}),pipeEither:(e,r)=>e(t),pipe:e=>e(t),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Left",value:t}),toYAML:()=>`_tag: Left
|
|
12
|
-
value: ${fe(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Left",value:t})).toString("base64")}),get size(){return 0},get isEmpty(){return true},contains:e=>false,reduce:e=>{throw new Error("Cannot reduce a Left")},reduceRight:e=>{throw new Error("Cannot reduceRight a Left")},count:e=>0,find:e=>b(),exists:e=>false,forEach:e=>{},doUnwrap(){return {ok:false,empty:false,error:t}}}),c=t=>Ie(t),p=t=>ze(t),ur=t=>t.isRight(),lr=t=>t.isLeft(),pr=(t,e)=>{try{return c(t())}catch(r){return p(e(r))}},it=t=>Ie(t);console.assert(it);var ut=t=>ze(t);console.assert(ut);var cr=async(t,e)=>{try{let r=await t();return c(r)}catch(r){return p(e(r))}},Ve={sequence:t=>t.reduce((e,r)=>e.isLeft()?e:r.isLeft()?p(r.value):e.map(n=>[...n,r.value]),c([])),traverse:(t,e)=>Ve.sequence(t.map(e)),fromNullable:(t,e)=>t==null?p(e):c(t),fromPredicate:(t,e,r)=>e(t)?c(t):p(r),ap:(t,e)=>t.flatMap(r=>e.map(r)),fromPromise:async(t,e)=>{try{let r=await t;return c(r)}catch(r){return p(e(r))}},fromJSON:t=>{let e=JSON.parse(t);return e._tag==="Right"?c(e.value):p(e.value)},fromYAML:t=>{let e=t.split(`
|
|
13
|
-
`),r=e[0]?.split(": ")[1],n=e[1]?.split(": ")[1];if(!r||!n)throw new Error("Invalid YAML format for Either");let o=JSON.parse(n);return r==="Right"?c(o):p(o)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Ve.fromJSON(e)}};function V(t,e){return {brand:t,validate:e,of:r=>e(r)?f(a$1(t,r)):f.none(),from:r=>e(r)?c(a$1(t,r)):p(`Invalid ${t}: validation failed`),unsafeOf:r=>{if(!e(r))throw new Error(`Invalid ${t}: validation failed`);return a$1(t,r)},is:r=>{try{return e(r)}catch{return false}},unwrap:r=>r,refine:(r,n)=>V(r,o=>e(o)&&n(o))}}var lt=V("PositiveNumber",t=>t>0),yr=V("NonNegativeNumber",t=>t>=0),gr=V("IntegerNumber",t=>Number.isInteger(t)),hr=lt.refine("PositiveInteger",t=>Number.isInteger(t)),Er=V("NonEmptyString",t=>t.length>0),Rr=V("EmailAddress",t=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)),Ar=V("UrlString",t=>{try{return new URL(t),!0}catch{return !1}}),Lr=V("UUID",t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)),kr=V("ISO8601Date",t=>!isNaN(Date.parse(t))&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(t));function xr(t,e,r){return V(t,n=>n>=e&&n<=r)}function br(t,e,r){return V(t,n=>n.length>=e&&n.length<=r)}function wr(t,e){return V(t,r=>e.test(r))}var we=t=>{let e=n=>typeof n=="function"?n():n,r={when:(n,o)=>t.resolved?r:n?we({resolved:true,value:e(o)}):r,elseWhen:(n,o)=>t.resolved?r:n?we({resolved:true,value:e(o)}):r,else:n=>t.resolved?t.value:e(n),getOrThrow:()=>{if(!t.resolved)throw new Error("Conditional expression has no matching condition");return t.value}};return r},Ke=()=>we({resolved:false}),pt={of:()=>Ke(),match:t=>e=>{let r=e[t];if(r===void 0)throw new Error(`No case defined for value: ${String(t)}`);return typeof r=="function"?r():r},lazy:()=>{let t={resolved:false},e={when:(r,n)=>(t.resolved||r()&&(t.resolved=true,t.value=n()),e),elseWhen:(r,n)=>(t.resolved||r()&&(t.resolved=true,t.value=n()),e),else:r=>t.resolved?t.value:r()};return e}},vr=a(Ke,pt);var se=(t,e)=>e===t?true:typeof e=="function"?e(t):e&&typeof e=="object"&&"_"in e?e._(t):typeof e=="object"&&e!==null&&typeof t=="object"&&t!==null?Object.entries(e).every(([r,n])=>{let o=t[r];return se(o,n)}):false,re=t=>{let e=(o,a)=>typeof o=="function"?o(a):o,r=()=>{for(let{pattern:o,result:a}of t.patterns)if(se(t.value,o))return {matched:true,result:e(a,t.value)};return {matched:false}},n={case:(o,a)=>{if(t.resolved)return n;let s={...t,patterns:[...t.patterns,{pattern:o,result:a}]};return se(t.value,o)?re({...s,resolved:true,result:e(a,t.value)}):re(s)},caseValue:(o,a)=>{if(t.resolved)return n;if(t.value===o){let s=typeof a=="function"?a():a;return re({...t,resolved:true,result:s})}return n},caseValues:(o,a)=>{if(t.resolved)return n;if(o.includes(t.value)){let s=typeof a=="function"?a():a;return re({...t,resolved:true,result:s})}return n},when:(o,a)=>n.case(o,a),caseAny:(o,a)=>{if(t.resolved)return n;for(let s of o)if(se(t.value,s))return re({...t,resolved:true,result:e(a,t.value),patterns:[...t.patterns,{pattern:s,result:a}]});return re({...t,patterns:[...t.patterns,...o.map(s=>({pattern:s,result:a}))]})},default:o=>t.resolved?t.result:e(o,t.value),exhaustive:()=>{let o=r();if(!o.matched)throw new Error(`Non-exhaustive match. No pattern matched value: ${JSON.stringify(t.value)}`);return o.result},getOrThrow:o=>{let a=r();if(!a.matched)throw new Error(o??`No matching pattern for value: ${JSON.stringify(t.value)}`);return a.result},toOption:()=>{let o=r();return o.matched?f(o.result):f.none()}};return n},ct=t=>re({value:t,resolved:false,patterns:[]}),Tt={exhaustive:t=>e=>{let r=t[e];if(r===void 0)throw new Error(`No case defined for value: ${String(e)}`);return r},partial:t=>({withDefault:e=>r=>{let n=t[r];return n!==void 0?typeof n=="function"?n(r):n:typeof e=="function"?e(r):e}}),withGuards:t=>({withDefault:e=>r=>{for(let[n,o]of t)if(n(r))return typeof o=="function"?o(r):o;return typeof e=="function"?e(r):e}}),struct:()=>{let t=[],e={case:(r,n)=>(t.push({pattern:r,handler:n}),e),build:()=>r=>{for(let{pattern:n,handler:o}of t)if(se(r,n))return o(r);throw new Error(`No matching pattern for value: ${JSON.stringify(r)}`)}};return e},builder:()=>{let t=[],e,r={case:(n,o)=>(t.push({pattern:n,result:o}),r),when:(n,o)=>(t.push({pattern:n,result:o}),r),default:n=>(e=n,{build:()=>o=>{for(let{pattern:a,result:s}of t)if(se(o,a))return typeof s=="function"?s(o):s;if(e!==void 0)return typeof e=="function"?e(o):e;throw new Error(`No matching pattern for value: ${JSON.stringify(o)}`)}})};return r}},_r=a(ct,Tt);function De(t,e){return {...Re({_tag:t,impl:e}),toString(){return `${t}()`},doUnwrap(){if("isSome"in e&&"isNone"in e){if(typeof e.isSome=="function"&&e.isSome()&&"get"in e&&typeof e.get=="function")return {ok:true,value:e.get()};if(typeof e.isNone=="function"&&e.isNone())return {ok:false,empty:true}}if("isLeft"in e&&"isRight"in e){if(typeof e.isRight=="function"&&e.isRight()&&"value"in e)return {ok:true,value:e.value};if(typeof e.isLeft=="function"&&e.isLeft()&&"value"in e)return {ok:false,empty:false,error:e.value}}if("isSuccess"in e&&"isFailure"in e){if(typeof e.isSuccess=="function"&&e.isSuccess()&&"get"in e&&typeof e.get=="function")return {ok:true,value:e.get()};if(typeof e.isFailure=="function"&&e.isFailure()&&"getError"in e&&typeof e.getError=="function")return {ok:false,empty:false,error:e.getError()}}if("isEmpty"in e&&"head"in e){if(typeof e.isEmpty=="function"&&e.isEmpty())return {ok:false,empty:true};if(typeof e.head=="function")return {ok:true,value:e.head()};if("head"in e)return {ok:true,value:e.head}}return {ok:true,value:e}}}}var Ae="Throwable",q=class t extends Error{constructor(r,n){super(r,{cause:n?.cause});this._tag=Ae;this.name=n?.taskInfo?.name??Ae,Object.defineProperties(this,{_tag:{value:Ae,writable:false,configurable:false},data:{value:n?.data,writable:false,configurable:false},taskInfo:{value:n?.taskInfo,writable:false,configurable:false},name:{value:n?.taskInfo?.name??Ae,writable:false,configurable:false}}),n?.cause&&Object.defineProperty(this,"cause",{value:n.cause,writable:false,configurable:false}),n?.stack?this.stack=n.stack:Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}static apply(r,n,o){if(r instanceof Error){let u=new t(r.message,{data:n,cause:r.cause??void 0,stack:r.stack??void 0,taskInfo:o});for(let l of Object.keys(r))if(!(l in u)){let d=u,y=r;d[l]=y[l];}return u}if(r&&typeof r=="object"){let u=r,l=typeof u.message=="string"?u.message:typeof u.error=="string"?u.error:`Object error: ${JSON.stringify(u,Object.getOwnPropertyNames(u).filter(y=>u[y]!==void 0))}`,d=new t(l,{data:n??u,taskInfo:o});for(let y of Object.keys(u))if(!(y in d)){let A=d;A[y]=u[y];}return d}if(typeof r=="function"){let u=r.name??"anonymous function",l=r.toString().substring(0,100)+(r.toString().length>100?"...":"");return new t(`Function error: ${u}`,{data:n??{functionType:typeof r,functionName:u,functionString:l},taskInfo:o})}let a=typeof r,s=r===null?"null":r===void 0?"undefined":String(r);if(a==="number"){let u=r,l=Number.isNaN(u)?"Number error: NaN":Number.isFinite(u)?`Number error: ${u}`:`Number error: ${u>0?"Infinity":"-Infinity"}`;return new t(l,{data:n??{errorType:a,errorValue:u,originalError:r},taskInfo:o})}if(a==="bigint")return new t(`BigInt error: ${r}n`,{data:n??{errorType:a,errorValue:String(r),originalError:r},taskInfo:o});if(a==="boolean")return new t(`Boolean error: ${r}`,{data:n??{errorType:a,errorValue:r,originalError:r},taskInfo:o});if(a==="symbol"){let u=r.description??"unnamed symbol";return new t(`Symbol error: Symbol(${u})`,{data:n??{errorType:a,symbolDescription:u,originalError:r},taskInfo:o})}let i=typeof r=="string"?r:`${a.charAt(0).toUpperCase()+a.slice(1)} error: ${s}`;return new t(i,{data:n??{errorType:a,errorValue:s,originalError:r},taskInfo:o})}};var x=t=>{let e=new Promise((r,n)=>{try{t(r,n);}catch(o){n(o);}});return {_tag:"FPromise",map:r=>x((n,o)=>{e.then(a=>{try{n(r(a));}catch(s){o(s);}}).catch(o);}),flatMap:r=>x((n,o)=>{e.then(a=>{try{let s=r(a);"_tag"in s&&s._tag==="FPromise"?s.then(n,o):Promise.resolve(s).then(n,o);}catch(s){o(s);}}).catch(o);}),flatMapAsync:async r=>{let n=await e,o=r(n);return o instanceof Promise?o:new Promise((a,s)=>{o.then(a,s);})},tap:r=>x((n,o)=>{e.then(a=>{try{r(a),n(a);}catch(s){o(s);}}).catch(o);}),mapError:r=>x((n,o)=>{e.then(n).catch(a=>{try{let s={originalError:a,stack:a instanceof Error?a.stack:void 0,timestamp:Date.now()};o(r(a,s));}catch(s){o(s);}});}),tapError:r=>x((n,o)=>{e.then(n).catch(a=>{try{r(a),o(a);}catch(s){o(s);}});}),recover:r=>x(n=>{e.then(n).catch(()=>n(r));}),recoverWith:r=>x(n=>{e.then(n).catch(o=>{try{n(r(o));}catch{n(null);}});}),recoverWithF:r=>x((n,o)=>{e.then(n).catch(a=>{try{r(a).then(n,o);}catch(s){o(s);}});}),filterError:(r,n)=>x((o,a)=>{e.then(o).catch(s=>{if(r(s))try{n(s).then(o,a);}catch(i){a(i);}else a(s);});}),logError:r=>x((n,o)=>{e.then(n).catch(a=>{try{let s={originalError:a,stack:a instanceof Error?a.stack:void 0,timestamp:Date.now()};r(a,s);}catch{}finally{o(a);}});}),then:(r,n)=>e.then(r,n),toPromise:()=>e,toEither:async()=>{try{let r=await e;return c(r)}catch(r){return p(r)}},fold:(r,n)=>x((o,a)=>{e.then(s=>{try{o(n(s));}catch(i){a(i);}}).catch(s=>{try{o(r(s));}catch(i){a(i);}});})}},ft={resolve:t=>x(e=>e(t)),reject:t=>x((e,r)=>r(t)),from:t=>x((e,r)=>{t.then(e).catch(r);}),fromEither:t=>t.isRight()?x(e=>e(t.value)):x((e,r)=>r(t.value)),all:t=>x((e,r)=>{Promise.all(t.map(n=>n instanceof Promise?n:Promise.resolve(n))).then(e).catch(r);}),allSettled:t=>x(e=>{let r=[],n=0;if(t.length===0){e([]);return}t.forEach((o,a)=>{Promise.resolve(o).then(s=>{r[a]=c(s),n++,n===t.length&&e(r);}).catch(s=>{r[a]=p(s),n++,n===t.length&&e(r);});});}),race:t=>x((e,r)=>{Promise.race(t).then(e,r);}),any:t=>x((e,r)=>{if(typeof Promise.any=="function")Promise.any(t).then(e,r);else {let n=0,o=[];if(t.length===0){r(new AggregateError([],"All promises were rejected"));return}t.forEach((a,s)=>{Promise.resolve(a).then(e).catch(i=>{o[s]=i,n++,n===t.length&&r(new AggregateError(o,"All promises were rejected"));});});}}),retryWithBackoff:(t,e)=>{let{maxRetries:r,baseDelay:n=100,shouldRetry:o=()=>true}=e;return x((a,s)=>{let i=0,u=()=>{t().toPromise().then(a).catch(l=>{if(i++,i<=r&&o(l,i)){let d=n*Math.pow(2,i-1);setTimeout(u,d);}else s(l);});};u();})}},Ue=a(x,ft);function dt(t){return t instanceof Error&&typeof t=="object"&&true&&t._tag==="Throwable"}var I=(t,e)=>{if(t.isRight())return Q(t.get(),e);if(t.isLeft())return de(t,void 0,e);throw new Error("Unrecognized task outcome")},de=(t,e,r)=>{let n={name:r?.name??"Task",description:r?.description??""},o=q.apply(t,e,n),a=p(o),{isLeft:s,isRight:i,...u}=a;return {...u,_tag:"TaskFailure",_meta:n,error:o,map:l=>{let d=a.map(l);return I(d,r)},flatMap:l=>{let d=a.flatMap(l);return I(d,r)},ap:l=>{let d=a.ap(l);return I(d,r)},merge:l=>{let d=a.merge(l);return I(d,r)},mapAsync:async l=>{let d=await a.mapAsync(l);return I(d,r)},flatMapAsync:async l=>{let d=await a.flatMapAsync(l);return I(d,r)},isSuccess(){return false},isFailure(){return true},mapError:l=>de(l(o),e,r),recover:l=>Q(l,r),recoverWith:l=>Q(l(o),r)}},Q=(t,e)=>{let r={name:e?.name??"Task",description:e?.description??""},n=c(t),{isLeft:o,isRight:a,...s}=n;return {...s,_tag:"TaskSuccess",_meta:r,map:i=>{let u=n.map(i);return I(u,e)},flatMap:i=>{let u=n.flatMap(i);return I(u,e)},ap:i=>{let u=n.ap(i);return I(u,e)},merge:i=>{let u=n.merge(i);return I(u,e)},mapAsync:async i=>{let u=await n.mapAsync(i);return I(u,e)},flatMapAsync:async i=>{let u=await n.flatMapAsync(i);return I(u,e)},isSuccess(){return true},isFailure(){return false},mapError:i=>Q(t,e),recover:i=>Q(t,e),recoverWith:i=>Q(t,e)}},ve=(t,e)=>Q(t,e),_=(t,e,r)=>de(t,e,r),Se=()=>{let t=new AbortController,e=Ee();return {token:{get isCancelled(){return t.signal.aborted},get signal(){return t.signal},onCancel(n){t.signal.aborted?n():e.add(n);}},cancel(){t.signal.aborted||(t.abort(),e.build().forEach(n=>{try{n();}catch(o){console.error("Error in cancellation callback:",o);}}));}}},mt=t=>{let e=t?.name??"Task",r=t?.description??"",n={Async:(o,a=u=>u,s=()=>{},i)=>Ue((u,l)=>{(async()=>{let d=k(false),y=k(null),A=k(()=>{});if(i){if(i.isCancelled){try{await s();}catch(E){u(_(E,void 0,{name:e,description:r}));return}u(_(new Error("Task was cancelled before execution started"),void 0,{name:e,description:r}));return}let R=()=>{d.set(true),y.set(new Error("Task was cancelled during execution"));};i.onCancel(R),A.set(()=>{});}try{let R=await o();try{await s();}catch(E){u(_(E,void 0,{name:e,description:r}));return}if(d.get()){y.get()?u(_(y.get(),void 0,{name:e,description:r})):u(_(new Error("Task was cancelled during execution"),void 0,{name:e,description:r}));return}if(R&&typeof R=="object"&&"_tag"in R){let E=R;E._tag==="TaskSuccess"||E._tag==="TaskFailure"?u(E):u(ve(R,{name:e,description:r}));}else u(ve(R,{name:e,description:r}));}catch(R){try{await s();}catch(E){u(_(E,void 0,{name:e,description:r}));return}if(d.get()){y.get()?u(_(y.get(),void 0,{name:e,description:r})):u(_(new Error("Task was cancelled during execution"),void 0,{name:e,description:r}));return}try{if(R instanceof Error&&dt(R)){let E=new Error(`${e}: ${R.message}`),F=q.apply(E,void 0,{name:e,description:r});Object.defineProperty(F,"cause",{value:R,writable:!1,configurable:!1}),Promise.resolve().then(()=>{try{a(R);}catch(Z){console.error("Error in error handler:",Z);}}),u(_(F,void 0,{name:e,description:r}));}else {let E=await a(R);if(E&&typeof E=="object"&&"_tag"in E){let F=E;F._tag==="TaskSuccess"||F._tag==="TaskFailure"?u(F):u(_(E,void 0,{name:e,description:r}));}else u(_(E,void 0,{name:e,description:r}));}}catch(E){u(_(E,void 0,{name:e,description:r}));}}finally{A.get()();}})().catch(d=>u(_(d,void 0,{name:e,description:r})));}),Sync:(o,a=i=>i,s=()=>{})=>{try{return Q(o(),{name:e,description:r})}catch(i){return de(a(i),void 0,{name:e,description:r})}finally{s();}},AsyncWithProgress:(o,a,s=l=>l,i=()=>{},u)=>{let l=d=>{let y=Math.max(0,Math.min(100,d));y<=100&&a(y);};return n.Async(()=>o(l),s,i,u)}};return {...De("Task",n),_type:"Task"}},$e={success:(t,e)=>Q(t,e),fail:(t,e,r)=>de(t,e,r),ok:(t,e)=>ve(t,e),err:(t,e,r)=>_(t,e,r),getErrorChain:t=>{if(!t)return [];let e=Ee();e.add(t);let r=k(t);for(;r.get()&&r.get().cause;){let{cause:n}=r.get();if(n)e.add(n),r.set(n);else break;if(e.size()>100)break}return e.build()},formatErrorChain:(t,e)=>{let r=$e.getErrorChain(t),n=e?.separator??`
|
|
14
|
-
`;return r.map((o,a)=>{if(!o)return `${a>0?"\u21B3 ":""}Unknown error`;let{taskInfo:s}=o,i=e?.includeTasks&&s?.name?`[${s.name}] `:"",u=o.message??"No message",l=k(`${a>0?"\u21B3 ":""}${i}${u}`);return e?.includeStackTrace&&o.stack&&l.set(`${l.get()}
|
|
15
|
-
${o.stack.split(`
|
|
16
|
-
`).slice(1).join(`
|
|
17
|
-
`)}`),l.get()}).join(n)},fromPromise:(t,e)=>(...r)=>$(e??{name:"PromiseTask",description:"Task from Promise"}).Async(()=>t(...r),o=>o),toPromise:t=>new Promise((e,r)=>{t.isSuccess()?e(t.get()):r(t.error);}),race:(t,e,r)=>{let n=r?.name??"TaskRace",o=r?.description??"Race between multiple tasks";return $({name:n,description:o}).Async(async()=>{let s=Ee();t.forEach(u=>s.add(u));let i=k(void 0);if(typeof e=="number"&&e>0){let u=Ue((l,d)=>{i.set(setTimeout(()=>{d(new Error(`Task race timed out after ${e}ms`));},e));});s.add(u);}try{return await new Promise((u,l)=>{s.build().forEach(d=>{d.then(y=>{if(y&&typeof y=="object"&&"_tag"in y){let A=y;A._tag==="TaskSuccess"?u(A.get()):A._tag==="TaskFailure"?l(A.error):u(y);}else u(y);},y=>l(y));});})}finally{i.get()&&clearTimeout(i.get());}},s=>s)},fromNodeCallback:(t,e)=>{let r=e?.name??"NodeCallbackTask",n=e?.description??"Task from Node.js callback function",o={name:r,description:n};return (...a)=>$(o).Async(()=>new Promise((s,i)=>{try{t(...a,(u,l)=>{u?i(u):s(l);});}catch(u){i(u);}}),s=>s)},createCancellationTokenSource:Se,cancellable:(t,e)=>{let r=Se();return {task:$(e).Async(()=>t(r.token),o=>o,()=>{},r.token),cancel:()=>r.cancel()}},withProgress:(t,e=()=>{},r)=>{let n=Se(),o=k(0),a=i=>{o.set(Math.max(0,Math.min(100,i))),e(o.get());};return {task:$(r).Async(()=>t(a,n.token),i=>i,()=>{},n.token),cancel:()=>n.cancel(),currentProgress:()=>o.get()}}},$=a(mt,$e);function Je(t){if(!t||typeof t!="object"||!("_tag"in t))return "unknown";switch(t._tag){case "Some":case "None":return "Option";case "Left":case "Right":return "Either";case "List":return "List";case "Success":case "Failure":return "Try";default:return "unknown"}}var Le={Option:{of:t=>f(t),empty:()=>f.none()},Either:{of:t=>c(t),empty:t=>p(t)},List:{of:t=>m([t]),empty:()=>m([])},Try:{of:t=>B(()=>t),empty:t=>B(()=>{throw t??new Error("Try failed")})}};function Xr(t){let e=t(),r=null,n;function o(a){let s=e.next(a);if(s.done)return n?n.of(s.value):m([s.value]);let i=s.value;if(i==null||typeof i!="object")throw new Error("Do-notation error: All yielded values must be monadic. Use yield* $(Option(value)), yield* $(Right(value)), etc. Raw values should be assigned directly without yielding.");if(!r&&"_tag"in i&&(r=Je(i),r!=="unknown"&&r in Le&&(n=Le[r]),r==="List"))return yt(t);if("doUnwrap"in i){let u=i.doUnwrap();if(!u.ok){if(!n)return m([]);if(!u.empty&&"error"in u){if(r==="Either")return n.empty(u.error);if(r==="Try")return n.empty(u.error instanceof Error?u.error:new Error(String(u.error)))}return n.empty()}return o(u.value)}throw new Error("Do-notation error: All yielded values must be monadic. Use yield* $(Option(value)), yield* $(Right(value)), etc. Raw values should be assigned directly without yielding.")}return o()}function yt(t){function e(o){if(o==null||typeof o!="object")return [o];if(!("doUnwrap"in o))return [o];let a=o;if("toArray"in a){let i=a.toArray();return i.length===0?[]:i}let s=a.doUnwrap();return s.ok?[s.value]:[]}function r(o){let a=t(),s=[],i=[],u=0;function l(d){let y=a.next(d);if(y.done){s.push(y.value);return}if(u<o.length){let R=o[u];i.push(R),u++,l(R);return}let A=e(y.value);if(A.length!==0)if(A.length>1){let R=A.flatMap(E=>{let F=[...i,E];return r(F)});s.push(...R);}else i.push(A[0]),u++,l(A[0]);}return l(void 0),s}let n=r([]);return m(n)}async function en(t){let e=t(),r=null,n;async function o(a){let s=await e.next(a);if(s.done)return n?n.of(s.value):m([s.value]);let i=await Promise.resolve(s.value);if(i==null||typeof i!="object")return o(i);if(!r&&"_tag"in i&&(r=Je(i),r!=="unknown"&&r in Le&&(n=Le[r])),"doUnwrap"in i){let u=i.doUnwrap();if(!u.ok){if(!n)return m([]);if(!u.empty&&"error"in u){if(r==="Either")return n.empty(u.error);if(r==="Try")return n.empty(u.error instanceof Error?u.error:new Error(String(u.error)))}return n.empty()}return o(u.value)}return o(i)}return o()}function tn(t){return t!==null&&typeof t=="object"&&"doUnwrap"in t&&typeof t.doUnwrap=="function"}function rn(t){let e=t.doUnwrap();if(e.ok)return e.value;throw "error"in e?e.error:new Error("Cannot unwrap empty monad")}function*nn(t){return yield t}var on=(t="Cannot unwrap None in Do-notation")=>{let e=new Error(t),r=Object.create(Error.prototype);return r.message=e.message,r.stack=e.stack,r.name="NoneError",r},an=(t,e="Cannot unwrap Left in Do-notation")=>{let r=new Error(e),n=Object.create(Error.prototype);return n.message=r.message,n.stack=r.stack,n.name="LeftError",n.value=t,n},sn=(t="Cannot unwrap empty List in Do-notation")=>{let e=new Error(t),r=Object.create(Error.prototype);return r.message=e.message,r.stack=e.stack,r.name="EmptyListError",r},un=(t,e="Cannot unwrap Failure in Do-notation")=>{let r=new Error(e),n=Object.create(Error.prototype);return n.message=r.message,n.stack=r.stack,n.name="FailureError",n.cause=t,n};var je={includeTasks:true,includeStackTrace:false,separator:`
|
|
18
|
-
`,includeData:false,maxStackFrames:3,title:"Error",colors:false};function We(t){let e=new WeakSet;return JSON.stringify(t,(r,n)=>{if(typeof n=="bigint")return `${n.toString()}n`;if(typeof n=="object"&&n!==null){if(e.has(n))return "[Circular Reference]";e.add(n);}return r==="stack"&&typeof n=="string"?ke(n):n},2)}function ke(t){if(t===void 0||t==="")return "";let e=t.split(`
|
|
19
|
-
`),r=e[0],n=e.slice(1).map(o=>o.trim());return [r,...n].join(`
|
|
20
|
-
`)}function Tn(t,e){let r={...je,...e},n=t instanceof Error?t:q.apply(t),o=$?.getErrorChain?$.getErrorChain(n):[n],a=r.colors?`\x1B[31m${r.title}:\x1B[0m ${n.message}`:`${r.title}: ${n.message}`,s=o.map((u,l)=>{let d=" ".repeat(l),y=l>0?"\u21B3 ":"",{taskInfo:A}=u,R=r.includeTasks&&A?.name?r.colors?`\x1B[36m[${A.name}]\x1B[0m `:`[${A.name}] `:"",E=`${d}${y}${R}${u.message}`;if(r.includeStackTrace&&u.stack){let Z=ke(u.stack).split(`
|
|
21
|
-
`).slice(1),ne=r.maxStackFrames??je.maxStackFrames??3,ye=Z.slice(0,ne).map(ge=>`${d} ${r.colors?"\x1B[90m":""}${ge}${r.colors?"\x1B[0m":""}`).join(`
|
|
22
|
-
`);E+=`
|
|
23
|
-
${ye}`,Z.length>ne&&(E+=`
|
|
24
|
-
${d} ${r.colors?"\x1B[90m":""}...${Z.length-ne} more stack frames${r.colors?"\x1B[0m":""}`);}return E}).join(r.separator),i=`${a}
|
|
25
|
-
|
|
26
|
-
${s}`;if(r.includeData){let{data:u}=n;if(u){let l=r.colors?`
|
|
27
|
-
|
|
28
|
-
\x1B[33mContext:\x1B[0m
|
|
29
|
-
${We(u)}`:`
|
|
30
|
-
|
|
31
|
-
Context:
|
|
32
|
-
${We(u)}`;i+=l;}}return i}function fn(){return function(e){if(!e)return e;let r=e instanceof Error?e:new Error(String(e)),n={message:r.message,name:r.name||"Error",stack:r.stack?ke(r.stack):void 0};if(r.taskInfo&&(n.taskInfo=r.taskInfo),r.data&&(n.data=r.data),typeof $?.getErrorChain=="function")try{let o=$.getErrorChain(r);o.length>1&&(n.errorChain=$.formatErrorChain(r,{includeTasks:!0}),n.structuredErrorChain=o.map(a=>({message:a.message,name:a.name,taskInfo:a.taskInfo,stack:a.stack?ke(a.stack):void 0})));}catch{}return Object.getOwnPropertyNames(r).forEach(o=>{if(!n[o]){let a=r[o];n[o]=a;}}),n}}var mn=t=>{let e=new Error(t);return e.name="ParseError",e};var J=(t,e,r,n)=>{let o=q.apply(e,r,{name:t,description:e});return Object.assign(o,{code:t,message:e,status:gt(t),context:r,timestamp:new Date().toISOString(),traceId:n?.traceId})},gt=t=>({VALIDATION_FAILED:400,BAD_REQUEST:400,AUTH_REQUIRED:401,PERMISSION_DENIED:403,NOT_FOUND:404,TIMEOUT:408,CONFLICT:409,RATE_LIMITED:429,INTERNAL_ERROR:500,NETWORK_ERROR:503})[t],ht={validation:(t,e,r)=>J("VALIDATION_FAILED",`Validation failed: ${t} ${r}`,{field:t,value:e,rule:r}),network:(t,e,r)=>J("NETWORK_ERROR",`Network error: ${e} ${t}${r?` (${r})`:""}`,{url:t,method:e,statusCode:r}),auth:(t,e)=>J("AUTH_REQUIRED",`Authentication required: ${t}${e?` (role: ${e})`:""}`,{resource:t,requiredRole:e}),notFound:(t,e)=>J("NOT_FOUND",`Not found: ${t} with id ${e}`,{resource:t,id:e}),permission:(t,e,r)=>J("PERMISSION_DENIED",`Permission denied: cannot ${t} ${e}`,{action:t,resource:e,userId:r}),rateLimit:(t,e,r)=>J("RATE_LIMITED",`Rate limit exceeded: ${t} requests per ${e}`,{limit:t,window:e,retryAfter:r}),internal:t=>J("INTERNAL_ERROR",`Internal server error: ${t}`,{errorId:t,timestamp:new Date().toISOString()}),badRequest:(t,e)=>J("BAD_REQUEST",`Bad request: ${t}`,{reason:t,expected:e}),conflict:(t,e)=>J("CONFLICT",`Conflict: ${t} already exists with value ${e}`,{resource:t,conflictingValue:e}),timeout:(t,e)=>J("TIMEOUT",`Request timeout: ${e} exceeded ${t}ms`,{duration:t,operation:e}),isTypedError:t=>typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&"status"in t&&"context"in t&&"_tag"in t&&t._tag==="Throwable",hasCode:(t,e)=>t.code===e},U=Object.assign(J,ht);var M={rule:t=>e=>{if(t==="email")return typeof e!="string"||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?p(U.validation("value",e,"must be a valid email")):c(e);if(t==="url")try{return new URL(String(e)),c(e)}catch{return p(U.validation("value",e,"must be a valid URL"))}if(t==="uuid")return typeof e!="string"||!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)?p(U.validation("value",e,"must be a valid UUID")):c(e);if(t==="required")return e==null||e===""?p(U.validation("value",e,"is required")):c(e);if(t==="numeric")return typeof e!="number"&&!/^\d+$/.test(String(e))?p(U.validation("value",e,"must be numeric")):c(e);if(t==="alpha")return typeof e!="string"||!/^[a-zA-Z]+$/.test(e)?p(U.validation("value",e,"must contain only letters")):c(e);if(t==="alphanumeric")return typeof e!="string"||!/^[a-zA-Z0-9]+$/.test(e)?p(U.validation("value",e,"must be alphanumeric")):c(e);if(t.startsWith("min:")){let r=Number(t.split(":")[1]),n=Number(e);return isNaN(n)||n<r?p(U.validation("value",e,`must be at least ${r}`)):c(e)}if(t.startsWith("max:")){let r=Number(t.split(":")[1]),n=Number(e);return isNaN(n)||n>r?p(U.validation("value",e,`must be at most ${r}`)):c(e)}if(t.startsWith("minLength:")){let r=Number(t.split(":")[1]);return String(e).length<r?p(U.validation("value",e,`must be at least ${r} characters`)):c(e)}if(t.startsWith("maxLength:")){let r=Number(t.split(":")[1]);return String(e).length>r?p(U.validation("value",e,`must be at most ${r} characters`)):c(e)}if(t.startsWith("pattern:")){let r=t.substring(8);return new RegExp(r).test(String(e))?c(e):p(U.validation("value",e,`must match pattern ${r}`))}if(t.startsWith("in:")){let r=t.substring(3).split(",");return r.includes(String(e))?c(e):p(U.validation("value",e,`must be one of: ${r.join(", ")}`))}if(t.startsWith("notIn:")){let r=t.substring(6).split(",");return r.includes(String(e))?p(U.validation("value",e,`must not be one of: ${r.join(", ")}`)):c(e)}if(t==="date"){let r=new Date(String(e));return isNaN(r.getTime())?p(U.validation("value",e,"must be a valid date")):c(e)}if(t==="future"){let r=new Date(String(e));return isNaN(r.getTime())||r<=new Date?p(U.validation("value",e,"must be a future date")):c(e)}if(t==="past"){let r=new Date(String(e));return isNaN(r.getTime())||r>=new Date?p(U.validation("value",e,"must be a past date")):c(e)}return c(e)},combine:(...t)=>e=>{for(let r of t){let n=r(e);if(n.isLeft())return n}return c(e)},custom:(t,e)=>r=>t(r)?c(r):p(U.validation("value",r,e)),form:(t,e)=>{let r=[],n={};for(let[o,a]of Object.entries(t)){let s=e[o],i=a(s);if(i.isLeft()){let u=i.fold(d=>d,()=>{throw new Error("Should not be left")}),l=U.validation(o,s,u.context.rule);r.push(l);}else n[o]=i.get();}return r.length>0?p(m(r)):c(n)}},Et={...M,validators:{email:M.rule("email"),url:M.rule("url"),uuid:M.rule("uuid"),required:M.rule("required"),numeric:M.rule("numeric"),positiveNumber:M.combine(M.rule("numeric"),M.rule("min:0")),nonEmptyString:M.combine(M.rule("required"),M.custom(t=>typeof t=="string"&&t.trim().length>0,"must not be empty"))}},Ln=Object.assign(M.rule,Et);function Rt(t){return t!=null&&typeof t=="object"&&"getOrElse"in t&&typeof t.getOrElse=="function"&&"getOrThrow"in t&&typeof t.getOrThrow=="function"&&"get"in t&&typeof t.get=="function"&&"orElse"in t&&typeof t.orElse=="function"&&"orNull"in t&&typeof t.orNull=="function"&&"orUndefined"in t&&typeof t.orUndefined=="function"}var On={toOption:t=>t.fold(()=>b(),e=>w(e)),toList:t=>t.fold(()=>m([]),e=>m([e])),toEither:(t,e)=>t.fold(()=>p(e),r=>c(r)),isEmpty:t=>t.fold(()=>true,()=>false),size:t=>t.fold(()=>0,()=>1)};var X=t=>t!==null&&typeof t=="object"&&(t._tag==="Some"||t._tag==="None"),G=t=>t!==null&&typeof t=="object"&&t._tag==="List",ie=t=>t!==null&&typeof t=="object"&&(t._tag==="Left"||t._tag==="Right"),ue=t=>t!==null&&typeof t=="object"&&(t._tag==="Success"||t._tag==="Failure"),j=()=>{let t=(s,i)=>{if(X(s))return s.map(u=>i(u));if(G(s))return s.map(u=>i(u));if(ie(s))return s.map(u=>i(u));if(ue(s))return s.map(u=>i(u));throw new Error(`Unsupported functor type: ${JSON.stringify(s)}`)},e=s=>{if(X(s))return s.get();if(G(s)){let i=s.toArray();if(i.length>0&&G(i[0])){let u=[];for(let l of i)G(l)&&u.push(...l.toArray());return m(u)}return s.flatten()}if(ie(s))return s.isRight()?s.fold(()=>null,i=>i):s;if(ue(s))return s.isSuccess()?s.get():s;throw new Error(`Unsupported functor type for flatten: ${JSON.stringify(s)}`)},r=(s,i)=>{if(X(s))return s.flatMap(u=>i(u));if(G(s))return s.flatMap(u=>i(u));if(ie(s))return s.flatMap(u=>i(u));if(ue(s))return s.flatMap(u=>i(u));throw new Error(`Unsupported functor type for flatMap: ${JSON.stringify(s)}`)},n=(s,i)=>{if(X(s)&&X(i))return s.flatMap(u=>i.map(l=>u(l)));if(G(s)&&G(i))return s.flatMap(u=>i.map(l=>u(l)));if(ie(s)&&ie(i))return s.flatMap(u=>i.map(l=>u(l)));if(ue(s)&&ue(i))return s.flatMap(u=>i.map(l=>u(l)));throw new Error(`Unsupported functor type for ap: ${JSON.stringify(s)}`)},o=s=>{if(X(s)){let i=s;if(i.isEmpty)return m([f.none()]);let u=i.get();if(G(u))return u.map(l=>f(l));throw new Error("Unsupported inner container type for sequence")}if(G(s)){let u=s.toArray();if(u.length===0)return f.none();let l=u[0];if(X(l)){for(let y of u)if(y.isEmpty)return f.none();let d=u.map(y=>y.get());return f(m(d))}throw new Error("Unsupported inner container type for sequence")}throw new Error(`Unsupported outer container type for sequence: ${JSON.stringify(s)}`)};return {_tag:"HKT",map:t,flatten:e,flatMap:r,ap:n,sequence:o,traverse:(s,i)=>o(t(s,u=>i(u))),_type:"HKT"}},le=j();j.map=(t,e)=>le.map(t,e);j.flatten=t=>le.flatten(t);j.flatMap=(t,e)=>le.flatMap(t,e);j.ap=(t,e)=>le.ap(t,e);j.sequence=t=>le.sequence(t);j.traverse=(t,e)=>le.traverse(t,e);j.isOption=X;j.isList=G;j.isEither=ie;j.isTry=ue;function Mn(t){return {id:t,isSame:r=>r.id===t}}var ee=t=>{let e=false,r,n,o=false,a=()=>{if(!e)try{r=t(),e=!0;}catch(i){throw n=i,o=true,e=true,i}if(o)throw n;return r};return {_tag:"Lazy",get isEvaluated(){return e},get:a,getOrElse:i=>{try{return a()}catch{return i}},getOrNull:()=>{try{return a()}catch{return null}},orNull:()=>{try{return a()}catch{return null}},getOrThrow:i=>{try{return a()}catch(u){throw i??u}},orElse:i=>z(()=>{try{return a()}catch{return i.get()}}),orUndefined:()=>{try{return a()}catch{return}},map:i=>z(()=>i(a())),ap:i=>z(()=>i.get()(a())),mapAsync:async i=>{let u=a(),l=await i(u);return z(()=>l)},flatMap:i=>z(()=>i(a()).get()),flatMapAsync:async i=>{let u=a(),l=await i(u);return z(()=>l.get())},filter:i=>z(()=>{let u=a();return i(u)?w(u):b}),recover:i=>z(()=>{try{return a()}catch(u){return i(u)}}),recoverWith:i=>z(()=>{try{return a()}catch(u){return i(u).get()}}),toOption:()=>{try{return w(a())}catch{return b}},toEither:()=>{try{return c(a())}catch(i){return p(i)}},toEitherWith:i=>{try{return c(a())}catch(u){return p(i(u))}},toTry:()=>B(()=>a()),tap:i=>z(()=>{let u=a();return i(u),u}),tapError:i=>z(()=>{try{return a()}catch(u){throw i(u),u}}),fold:i=>i(a()),foldWith:(i,u)=>{try{return u(a())}catch(l){return i(l)}},foldLeft:i=>u=>u(i,a()),foldRight:i=>u=>u(a(),i),match:i=>i.Lazy(a()),toString:()=>e&&!o?`Lazy(${fe(r)})`:e&&o?`Lazy(<error: ${n instanceof Error?n.message:String(n)}>)`:"Lazy(<not evaluated>)",toValue:()=>e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false},get size(){try{return a(),1}catch{return 0}},get isEmpty(){try{return a(),!1}catch{return true}},contains:i=>{try{return a()===i}catch{return false}},reduce:i=>a(),reduceRight:i=>a(),count:i=>{try{return i(a())?1:0}catch{return 0}},find:i=>{try{let u=a();return i(u)?w(u):b}catch{return b}},exists:i=>{try{return i(a())}catch{return false}},forEach:i=>{try{i(a());}catch{}},pipe:i=>i(a()),serialize:()=>({toJSON:()=>JSON.stringify(e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false}),toYAML:()=>e&&!o?`_tag: Lazy
|
|
33
|
-
evaluated: true
|
|
34
|
-
value: ${fe(r)}`:`_tag: Lazy
|
|
35
|
-
evaluated: false`,toBinary:()=>Buffer.from(JSON.stringify(e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false})).toString("base64")}),typeable:"Lazy"}},At={of:t=>ee(t),fromValue:t=>ee(()=>t),fromOption:(t,e)=>ee(()=>t._tag==="Some"?t.value:e()),fromTry:t=>ee(()=>t.get()),fromEither:t=>ee(()=>t.fold(e=>{throw e},e=>e)),fromPromise:t=>ee(()=>{throw new Error("Promise not yet resolved. Use await on the promise before creating Lazy.")}),fail:t=>ee(()=>{throw t})},z=a(ee,At);var me=Map;var H=t=>{let r={values:new me(t)},n=()=>Array.from(r.values.entries()).map(([T,h])=>b$1([T,h])),o=T=>H(new me(r.values).set(T.toArray()[0],T.toArray()[1]).entries()),a=T=>{let h=new me(r.values);return h.delete(T)?H(h.entries()):H(r.values.entries())},s=T=>{let h=T.toArray();return r.values.get(h[0])===h[1]},i=()=>r.values.size,u=T=>H(Array.from(r.values.entries()).map(([h,C])=>[h,T(C)])),l=T=>{let h=H(r.values.entries()).toList();return H(h.flatMap(T).toArray())},d=T=>{let h=[];for(let[C,oe]of r.values.entries()){let ce=T.get(C);ce._tag==="Some"&&ce.value&&h.push([C,ce.value(oe)]);}return H(h)},y=async T=>{let h=new me;for(let[C,oe]of r.values.entries()){let ce=await T(oe);for(let Ze of ce.toList()){let[Xe,et]=Ze.toArray();h.set(Xe,et);}}return H(h.entries())},A=T=>m(n()).reduce(T),R=T=>m(n()).reduceRight(T),E=T=>h=>m(n()).foldLeft(T)(h),F=T=>h=>m(n()).foldRight(T)(h),Z=T=>f(r.values.get(T)),ne=(T,h)=>f(r.values.get(T)).getOrElse(h),pe=()=>r.values.size===0,ye=(T,h)=>f(r.values.get(T)).orElse(h),ge=(T,h)=>{if(pe())return T();let C=n();if(C.length===0)return T();let oe=C[0];return oe===void 0?T():h(oe)},Pe=()=>m(n()),g=()=>te(n()),O=()=>`Map(${n().toString()})`,P=T=>pe()?T.Empty():T.NonEmpty(n());return {_tag:"Map",[Symbol.iterator]:()=>r.values.entries(),add:o,remove:a,contains:s,get size(){return i()},map:u,ap:d,flatMap:l,flatMapAsync:y,reduce:A,reduceRight:R,foldLeft:E,foldRight:F,fold:ge,match:P,get:Z,getOrElse:ne,get isEmpty(){return pe()},orElse:ye,toList:Pe,toSet:g,toString:O,toValue:()=>({_tag:"Map",value:Array.from(r.values.entries())}),pipe:T=>T(Array.from(r.values.entries())),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Map",value:Array.from(r.values.entries())}),toYAML:()=>`_tag: Map
|
|
36
|
-
value: ${JSON.stringify(Array.from(r.values.entries()))}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Map",value:Array.from(r.values.entries())})).toString("base64")})}},Lt=t=>H(t),Ye={fromJSON:t=>{let e=JSON.parse(t);return Oe(e.value)},fromYAML:t=>{let r=t.split(`
|
|
37
|
-
`)[1]?.split(": ")[1];if(!r)return Oe([]);let n=JSON.parse(r);return Oe(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Ye.fromJSON(e)}},Oe=a(Lt,Ye);var kt={default:t=>e=>t(e),when:(t,e)=>r=>t(r)?e(r):void 0};var K=(t=[])=>{let e="Stack",r=[...t],n=()=>r.length,o=()=>r.length===0;return {_tag:e,get size(){return n()},get isEmpty(){return o()},contains:g=>r.includes(g),reduce:g=>{if(r.length===0)throw new Error("Cannot reduce an empty stack");return r.reduce(g)},reduceRight:g=>{if(r.length===0)throw new Error("Cannot reduce an empty stack");return r.reduceRight(g)},push:g=>K([...r,g]),pop:()=>{if(o())return [K([]),f(null)];let g=[...r],O=g.pop();return [K(g),f(O)]},peek:()=>o()?f(null):f(r[r.length-1]),map:g=>K(r.map(g)),flatMap:g=>o()?K([]):r.reduce((O,P)=>g(P).toArray().reduce((h,C)=>h.push(C),O),K([])),ap:g=>{let O=[];return r.forEach(P=>{g.toArray().forEach(T=>{O.push(T(P));});}),K(O)},flatMapAsync:async g=>o()?K([]):(await Promise.all(r.map(async P=>await g(P)))).reduce((P,T)=>T.toArray().reduce((h,C)=>h.push(C),P),K([])),toList:()=>m(r),toArray:()=>[...r],toString:()=>`Stack(${r.join(", ")})`,fold:(g,O)=>{if(o())return g();let P=r[r.length-1];return P!==void 0?O(P):g()},foldLeft:g=>O=>r.reduce(O,g),foldRight:g=>O=>r.reduceRight((P,T)=>O(T,P),g),match:g=>o()?g.Empty():g.NonEmpty([...r]),toValue:()=>({_tag:"Stack",value:r}),pipe:g=>g([...r]),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Stack",value:r}),toYAML:()=>`_tag: Stack
|
|
38
|
-
value: ${JSON.stringify(r)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Stack",value:r})).toString("base64")})}},xt=(t=[])=>K(t),qe={empty:()=>K([]),of:t=>K([t]),fromJSON:t=>{let e=JSON.parse(t);return Be(e.value)},fromYAML:t=>{let r=t.split(`
|
|
39
|
-
`)[1]?.split(": ")[1];if(!r)return Be([]);let n=JSON.parse(r);return Be(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return qe.fromJSON(e)}},Be=a(xt,qe);function lo(t){let e=Re({_tag:t._tag,impl:t.impl});return {...e,toValue:()=>({_tag:e._tag,value:t.value})}}var w=t=>({_tag:"Some",value:t,isEmpty:false,isSome(){return true},isNone(){return false},get:()=>t,getOrElse:()=>t,getOrThrow:()=>t,orElse:e=>w(t),orNull:()=>t,orUndefined:()=>t,map:e=>w(e(t)),ap:e=>e._tag==="Some"&&e.value?w(e.value(t)):W,filter(e){return e(t)?w(t):W},count:e=>e(t)?1:0,find:e=>e(t)?w(t):W,exists:e=>e(t),forEach:e=>e(t),fold:(e,r)=>r(t),match:e=>e.Some(t),flatMap:e=>e(t),flatMapAsync:async e=>await e(t),reduce:e=>e(void 0,t),reduceRight:e=>e(void 0,t),foldLeft:e=>r=>r(e,t),foldRight:e=>r=>r(t,e),toList:()=>m([t]),contains:e=>e===t,size:1,toOption:()=>w(t),toEither:e=>c(t),toTry:()=>B(()=>t),toPromise:()=>Promise.resolve(t),toString:()=>`Some(${fe(t)})`,toValue:()=>({_tag:"Some",value:t}),pipe:e=>e(t),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Some",value:t}),toYAML:()=>`_tag: Some
|
|
40
|
-
value: ${fe(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Some",value:t})).toString("base64")}),doUnwrap(){return {ok:true,value:t}}}),W={_tag:"None",value:void 0,isEmpty:true,isSome(){return false},isNone(){return true},get:()=>{throw new Error("Cannot call get() on None")},getOrElse:t=>t,getOrThrow(t){throw t},orElse:t=>t,orNull:()=>null,orUndefined:()=>{},map:t=>W,ap:t=>W,filter(t){return W},count:t=>0,find:t=>W,exists:t=>false,forEach:t=>{},flatMap:t=>W,flatMapAsync:t=>Promise.resolve(W),reduce:()=>{},reduceRight:()=>{},fold:(t,e)=>t(),match:t=>t.None(),foldLeft:t=>()=>t,foldRight:t=>()=>t,toList:()=>m([]),contains:()=>false,size:0,toOption:()=>W,toEither:t=>p(t),toTry:()=>B(()=>{throw new Error("None")}),toPromise:()=>Promise.reject(new Error("Cannot convert None to Promise")),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0}),pipe:t=>t(void 0),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"None",value:null}),toYAML:()=>`_tag: None
|
|
41
|
-
value: null`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"None",value:null})).toString("base64")}),doUnwrap(){return {ok:false,empty:true}}},b=()=>W,bt=t=>t!=null?w(t):b(),He={from:t=>f(t),none:()=>b(),fromJSON:t=>{let e=JSON.parse(t);return e._tag==="Some"?w(e.value):b()},fromYAML:t=>{let e=t.split(`
|
|
42
|
-
`),r=e[0]?.split(": ")[1],n=e[1]?.split(": ")[1];if(!r||!n)return b();let o=n==="null"?null:JSON.parse(n);return r==="Some"?w(o):b()},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return He.fromJSON(e)}},f=a(bt,He);export{an as $,Rr as A,Ar as B,Lr as C,kr as D,xr as E,br as F,wr as G,vr as H,_r as I,De as J,Ae as K,q as L,ft as M,Ue as N,dt as O,de as P,Q,ve as R,_ as S,Se as T,$ as U,Xr as V,en as W,tn as X,rn as Y,nn as Z,on as _,w as a,sn as aa,b,un as ba,bt as c,We as ca,f as d,ke as da,te as e,Tn as ea,k as f,fn as fa,Kt as g,mn as ga,B as h,U as ha,Re as i,Ln as ia,be as j,Rt as ja,m as k,On as ka,c as l,j as la,p as m,Mn as ma,ur as n,z as na,lr as o,me as oa,pr as p,Oe as pa,it as q,kt as qa,ut as r,Be as ra,cr as s,lo as sa,Ve as t,V as u,lt as v,yr as w,gr as x,hr as y,Er as z};//# sourceMappingURL=chunk-45FTMTJA.mjs.map
|
|
43
|
-
//# sourceMappingURL=chunk-45FTMTJA.mjs.map
|