functype 0.43.0 → 0.44.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/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{K as e,Tt as t,_t as n}from"../src-DtA8LBtt.js";const r=`0.43.0`,i={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.orNull()`,`.match({Some, None})`],check:[`.isSome`,`.isNone`,`.isDefined`,`.isEmpty`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:[`Functor`,`Monad`,`Foldable`,`Traversable`,`PromiseLike`],methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.orElse(d)`,`.orThrow()`,`.match({Left, Right})`],check:[`.isRight`,`.isLeft`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Try(() => expr)`,`Success(v)`,`Failure(e)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.orElse(d)`,`.orThrow()`,`.toOption()`,`.toEither()`],check:[`.isSuccess`,`.isFailure`]}},List:{description:`Immutable array with functional operations`,interfaces:[`Functor`,`Monad`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`List([...])`,`List.of(...)`,`List.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.take(n)`,`.drop(n)`],extract:[`.fold(z, f)`,`.reduce(f)`,`.head`,`.tail`,`.toArray()`],check:[`.isEmpty`,`.nonEmpty`,`.size`,`.contains(v)`]}},Set:{description:`Immutable set of unique values`,interfaces:[`Functor`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.filter(p)`,`.union(s)`,`.intersection(s)`,`.difference(s)`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:[`SafeTraversable`,`Collection`,`Serializable`],methods:{create:[`Map([...])`,`Map.of(...)`,`Map.empty()`],transform:[`.set(k, v)`,`.delete(k)`,`.map(f)`,`.filter(p)`],extract:[`.get(k)`,`.keys()`,`.values()`,`.entries()`,`.fold(z, f)`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Lazy:{description:`Deferred computation with memoization`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Serializable`,`Traversable`],methods:{create:[`Lazy(() => expr)`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:[`Functor`,`Monad`,`Iterable`],methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`],transform:[`.map(f)`,`.filter(p)`,`.take(n)`,`.drop(n)`,`.concat(ll)`],extract:[`.head`,`.tail`,`.toArray()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress`,interfaces:[],methods:{create:[`Task.of(v)`,`Task.from(promise)`,`Task.sync(f)`,`Task.async(f)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`],extract:[`.run()`,`.cancel()`],other:[`.onProgress(cb)`,`.onCancel(cb)`]}},IO:{description:`Lazy effect type with typed errors and dependency injection`,interfaces:[`Functor`,`Monad`,`Foldable`,`Matchable`],methods:{create:[`IO(() => v)`,`IO.succeed(v)`,`IO.fail(e)`,`IO.sync(f)`,`IO.async(f)`,`IO.tryPromise({try, catch})`,`IO.fromEither(e)`,`IO.fromOption(o)`,`IO.fromTry(t)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run()`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit()`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...])`,`IO.race([...])`,`IO.bracket(acquire, use, release)`,`IO.gen(function*() {...})`,`IO.Do.bind().map()`,`IO.service(Tag)`,`.provideService(Tag, impl)`,`.provideLayer(layer)`]}},FPromise:{description:`Enhanced Promise with functional methods`,interfaces:[`PromiseLike`],methods:{create:[`FPromise.of(v)`,`FPromise.from(promise)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(f)`],extract:[`.toPromise()`,`.cancel()`]}},Cond:{description:`Conditional expression builder - replace if-else chains`,interfaces:[],methods:{create:[`Cond<T>()`],other:[`.case(pred, result)`,`.otherwise(result)`,`.eval()`]}},Match:{description:`Pattern matching - replace switch statements`,interfaces:[],methods:{create:[`Match(value)`],other:[`.case(pattern, result)`,`.when(pred, result)`,`.default(result)`,`.done()`]}},Brand:{description:`Nominal typing without runtime overhead`,interfaces:[],methods:{create:[`Brand<K, T>(value)`],extract:[`.unwrap()`,`.toString()`]}},ValidatedBrand:{description:`Branded types with runtime validation`,interfaces:[],methods:{create:[`ValidatedBrand(validator)`,`.of(v)`,`.from(v)`,`.unsafeOf(v)`],check:[`.is(v)`],other:[`.refine(validator)`]}},Tuple:{description:`Fixed-size typed array`,interfaces:[`Typeable`,`Valuable`,`Iterable`],methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`],extract:[`.first`,`.second`,`.toArray()`],transform:[`.map(f)`]}},Stack:{description:`Immutable LIFO stack`,interfaces:[`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Stack()`,`Stack.of(...)`],transform:[`.push(v)`,`.pop()`],extract:[`.peek()`,`.toArray()`],check:[`.isEmpty`,`.size`]}}},a={Functor:{description:`Transform contained values`,methods:[`.map<B>(f: A => B): Functor<B>`]},Applicative:{extends:`Functor`,description:`Apply wrapped functions`,methods:[`.ap<B>(ff: Applicative<A => B>): Applicative<B>`]},Monad:{extends:`Applicative`,description:`Chain operations returning wrapped values`,methods:[`.flatMap<B>(f: A => Monad<B>): Monad<B>`]},Foldable:{description:`Extract via pattern matching`,methods:[`.fold<B>(empty: () => B, f: A => B): B`,`.foldLeft<B>(z: B, op: (B, A) => B): B`,`.foldRight<B>(z: B, op: (A, B) => B): B`]},Extractable:{description:`Get contained value with fallback`,methods:[`.orElse(d: T): T`,`.orThrow(e?: Error): T`,`.orNull(): T | null`,`.orUndefined(): T | undefined`]},Matchable:{description:`Pattern match on type variants`,methods:[`.match<R>(patterns: Record<Tag, Handler>): R`]},Traversable:{description:`Iterate and check contents`,methods:[`.size: number`,`.isEmpty: boolean`,`.contains(v: A): boolean`,`.reduce<B>(f, init): B`]},Collection:{description:`Collection operations`,methods:[`.toArray(): A[]`,`.forEach(f: A => void): void`]},Serializable:{description:`Convert to string formats`,methods:[`.serialize().toJSON(): string`,`.serialize().toYAML(): string`]}},o={Core:[`Option`,`Either`,`Try`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`FPromise`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`]},s=()=>{let e=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(o)).foldLeft(e)((e,[r,a])=>{let o=e.add(r.toUpperCase());return n(a).foldLeft(o)((e,n)=>t(i[n]).fold(()=>e,t=>{let r=t.interfaces.length>0?` [${t.interfaces.join(`, `)}]`:``;return e.add(` ${n}${r}`).add(` ${t.description}`)})).add(``)}).concat(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
2
+ import{K as e,Tt as t,_t as n}from"../src-BuPnddUO.js";const r=`0.44.0`,i={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.orNull()`,`.match({Some, None})`],check:[`.isSome`,`.isNone`,`.isDefined`,`.isEmpty`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:[`Functor`,`Monad`,`Foldable`,`Traversable`,`PromiseLike`],methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.orElse(d)`,`.orThrow()`,`.match({Left, Right})`],check:[`.isRight`,`.isLeft`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Try(() => expr)`,`Success(v)`,`Failure(e)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.orElse(d)`,`.orThrow()`,`.toOption()`,`.toEither()`],check:[`.isSuccess`,`.isFailure`]}},List:{description:`Immutable array with functional operations`,interfaces:[`Functor`,`Monad`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`List([...])`,`List.of(...)`,`List.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.take(n)`,`.drop(n)`],extract:[`.fold(z, f)`,`.reduce(f)`,`.head`,`.tail`,`.toArray()`],check:[`.isEmpty`,`.nonEmpty`,`.size`,`.contains(v)`]}},Set:{description:`Immutable set of unique values`,interfaces:[`Functor`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.filter(p)`,`.union(s)`,`.intersection(s)`,`.difference(s)`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:[`SafeTraversable`,`Collection`,`Serializable`],methods:{create:[`Map([...])`,`Map.of(...)`,`Map.empty()`],transform:[`.set(k, v)`,`.delete(k)`,`.map(f)`,`.filter(p)`],extract:[`.get(k)`,`.keys()`,`.values()`,`.entries()`,`.fold(z, f)`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Lazy:{description:`Deferred computation with memoization`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Serializable`,`Traversable`],methods:{create:[`Lazy(() => expr)`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:[`Functor`,`Monad`,`Iterable`],methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`],transform:[`.map(f)`,`.filter(p)`,`.take(n)`,`.drop(n)`,`.concat(ll)`],extract:[`.head`,`.tail`,`.toArray()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress`,interfaces:[],methods:{create:[`Task.of(v)`,`Task.from(promise)`,`Task.sync(f)`,`Task.async(f)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`],extract:[`.run()`,`.cancel()`],other:[`.onProgress(cb)`,`.onCancel(cb)`]}},IO:{description:`Lazy effect type with typed errors and dependency injection`,interfaces:[`Functor`,`Monad`,`Foldable`,`Matchable`],methods:{create:[`IO(() => v)`,`IO.succeed(v)`,`IO.fail(e)`,`IO.sync(f)`,`IO.async(f)`,`IO.tryPromise({try, catch})`,`IO.fromEither(e)`,`IO.fromOption(o)`,`IO.fromTry(t)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run()`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit()`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...])`,`IO.race([...])`,`IO.bracket(acquire, use, release)`,`IO.gen(function*() {...})`,`IO.Do.bind().map()`,`IO.service(Tag)`,`.provideService(Tag, impl)`,`.provideLayer(layer)`]}},FPromise:{description:`Enhanced Promise with functional methods`,interfaces:[`PromiseLike`],methods:{create:[`FPromise.of(v)`,`FPromise.from(promise)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(f)`],extract:[`.toPromise()`,`.cancel()`]}},Cond:{description:`Conditional expression builder - replace if-else chains`,interfaces:[],methods:{create:[`Cond<T>()`],other:[`.case(pred, result)`,`.otherwise(result)`,`.eval()`]}},Match:{description:`Pattern matching - replace switch statements`,interfaces:[],methods:{create:[`Match(value)`],other:[`.case(pattern, result)`,`.when(pred, result)`,`.default(result)`,`.done()`]}},Brand:{description:`Nominal typing without runtime overhead`,interfaces:[],methods:{create:[`Brand<K, T>(value)`],extract:[`.unwrap()`,`.toString()`]}},ValidatedBrand:{description:`Branded types with runtime validation`,interfaces:[],methods:{create:[`ValidatedBrand(validator)`,`.of(v)`,`.from(v)`,`.unsafeOf(v)`],check:[`.is(v)`],other:[`.refine(validator)`]}},Tuple:{description:`Fixed-size typed array`,interfaces:[`Typeable`,`Valuable`,`Iterable`],methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`],extract:[`.first`,`.second`,`.toArray()`],transform:[`.map(f)`]}},Stack:{description:`Immutable LIFO stack`,interfaces:[`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Stack()`,`Stack.of(...)`],transform:[`.push(v)`,`.pop()`],extract:[`.peek()`,`.toArray()`],check:[`.isEmpty`,`.size`]}}},a={Functor:{description:`Transform contained values`,methods:[`.map<B>(f: A => B): Functor<B>`]},Applicative:{extends:`Functor`,description:`Apply wrapped functions`,methods:[`.ap<B>(ff: Applicative<A => B>): Applicative<B>`]},Monad:{extends:`Applicative`,description:`Chain operations returning wrapped values`,methods:[`.flatMap<B>(f: A => Monad<B>): Monad<B>`]},Foldable:{description:`Extract via pattern matching`,methods:[`.fold<B>(empty: () => B, f: A => B): B`,`.foldLeft<B>(z: B, op: (B, A) => B): B`,`.foldRight<B>(z: B, op: (A, B) => B): B`]},Extractable:{description:`Get contained value with fallback`,methods:[`.orElse(d: T): T`,`.orThrow(e?: Error): T`,`.orNull(): T | null`,`.orUndefined(): T | undefined`]},Matchable:{description:`Pattern match on type variants`,methods:[`.match<R>(patterns: Record<Tag, Handler>): R`]},Traversable:{description:`Iterate and check contents`,methods:[`.size: number`,`.isEmpty: boolean`,`.contains(v: A): boolean`,`.reduce<B>(f, init): B`]},Collection:{description:`Collection operations`,methods:[`.toArray(): A[]`,`.forEach(f: A => void): void`]},Serializable:{description:`Convert to string formats`,methods:[`.serialize().toJSON(): string`,`.serialize().toYAML(): string`]}},o={Core:[`Option`,`Either`,`Try`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`FPromise`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`]},s=()=>{let e=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(o)).foldLeft(e)((e,[r,a])=>{let o=e.add(r.toUpperCase());return n(a).foldLeft(o)((e,n)=>t(i[n]).fold(()=>e,t=>{let r=t.interfaces.length>0?` [${t.interfaces.join(`, `)}]`:``;return e.add(` ${n}${r}`).add(` ${t.description}`)})).add(``)}).concat(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
3
3
  `)},c=(e,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=n([`create`,`transform`,`extract`,`check`,`other`]),o=n([`${e}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((e,i)=>t(r.methods[i]).filter(e=>e.length>0).fold(()=>e,t=>{let r=e.add(i.toUpperCase());return n(t).foldLeft(r)((e,t)=>e.add(` ${t}`)).add(``)})).toArray().join(`
4
4
  `).trimEnd()},l=()=>{let e=n([`INTERFACES`,``]);return n(Object.entries(a)).foldLeft(e)((e,[t,r])=>{let i=r.extends?` extends ${r.extends}`:``,a=e.add(`${t}<A>${i}`).add(` ${r.description}`);return n(r.methods).foldLeft(a)((e,t)=>e.add(` ${t}`)).add(``)}).toArray().join(`
5
5
  `).trimEnd()},u=e=>JSON.stringify(e,null,2),d=()=>({version:r,categories:o,types:i}),f=e=>t(i[e]).map(t=>({name:e,data:t})).or(n(Object.entries(i)).find(([t])=>t.toLowerCase()===e.toLowerCase()).map(([e,t])=>({name:e,data:t}))).orUndefined(),p=()=>Object.keys(i),m=()=>a,h={Option:`export interface Option<T extends Type> extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
@@ -1,2 +1,2 @@
1
- import { Jn as Doable, a as EmptyListError, c as LeftError, d as isDoCapable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, qn as DoResult, r as DoAsync, s as FailureErrorType, t as $, u as NoneError } from "../index-CrsC0sQU.js";
1
+ import { Jn as Doable, a as EmptyListError, c as LeftError, d as isDoCapable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, qn as DoResult, r as DoAsync, s as FailureErrorType, t as $, u as NoneError } from "../index-DKAUrDCz.js";
2
2
  export { $, Do, DoAsync, DoGenerator, DoResult, Doable, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap };
package/dist/do/index.js CHANGED
@@ -1 +1 @@
1
- import{A as e,D as t,F as n,M as r,N as i,O as a,P as o,j as s,k as c}from"../src-DtA8LBtt.js";export{t as $,a as Do,c as DoAsync,e as EmptyListError,s as FailureError,r as LeftError,i as NoneError,o as isDoCapable,n as unwrap};
1
+ import{A as e,D as t,F as n,M as r,N as i,O as a,P as o,j as s,k as c}from"../src-BuPnddUO.js";export{t as $,a as Do,c as DoAsync,e as EmptyListError,s as FailureError,r as LeftError,i as NoneError,o as isDoCapable,n as unwrap};
@@ -1,2 +1,2 @@
1
- import { S as tryCatchAsync, _ as TypeCheckLeft, b as isRight, g as TestEither, h as Right, m as Left, p as Either, v as TypeCheckRight, x as tryCatch, y as isLeft } from "../index-CrsC0sQU.js";
1
+ import { S as tryCatchAsync, _ as TypeCheckLeft, b as isRight, g as TestEither, h as Right, m as Left, p as Either, v as TypeCheckRight, x as tryCatch, y as isLeft } from "../index-DKAUrDCz.js";
2
2
  export { Either, Left, Right, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
@@ -1 +1 @@
1
- import{ct as e,dt as t,ft as n,gt as r,ht as i,lt as a,mt as o,pt as s,ut as c}from"../src-DtA8LBtt.js";export{e as Either,a as Left,c as Right,t as TypeCheckLeft,n as TypeCheckRight,s as isLeft,o as isRight,i as tryCatch,r as tryCatchAsync};
1
+ import{ct as e,dt as t,ft as n,gt as r,ht as i,lt as a,mt as o,pt as s,ut as c}from"../src-BuPnddUO.js";export{e as Either,a as Left,c as Right,t as TypeCheckLeft,n as TypeCheckRight,s as isLeft,o as isRight,i as tryCatch,r as tryCatchAsync};
@@ -1,2 +1,2 @@
1
- import { cn as FPromise, ln as FPromiseCompanion, sn as ErrorContext } from "../index-CrsC0sQU.js";
1
+ import { cn as FPromise, ln as FPromiseCompanion, sn as ErrorContext } from "../index-DKAUrDCz.js";
2
2
  export { ErrorContext, FPromise, FPromiseCompanion };
@@ -1 +1 @@
1
- import{H as e,V as t}from"../src-DtA8LBtt.js";export{t as FPromise,e as FPromiseCompanion};
1
+ import{H as e,V as t}from"../src-BuPnddUO.js";export{t as FPromise,e as FPromiseCompanion};
@@ -941,29 +941,35 @@ type UntypedMatch<T extends Type> = {
941
941
  */
942
942
  type Match<T extends Type, R$1 extends Type> = {
943
943
  /**
944
- * Match against a pattern (value, nested object, or predicate)
944
+ * Match against a pattern (value, nested object, or predicate).
945
+ * The result type R2 is added to the union of possible results.
945
946
  */
946
- case: (pattern: Pattern<T>, result: PatternResult<T, R$1>) => Match<T, R$1>;
947
+ case: <R2 extends Type>(pattern: Pattern<T>, result: PatternResult<T, R2>) => Match<T, R$1 | R2>;
947
948
  /**
948
- * Add a case that matches a specific value (backward compatibility)
949
+ * Add a case that matches a specific value.
950
+ * The result type R2 is added to the union of possible results.
949
951
  */
950
- caseValue: (match: T, result: R$1 | (() => R$1)) => Match<T, R$1>;
952
+ caseValue: <R2 extends Type>(match: T, result: R2 | (() => R2)) => Match<T, R$1 | R2>;
951
953
  /**
952
- * Add a case that matches multiple values (backward compatibility)
954
+ * Add a case that matches multiple values.
955
+ * The result type R2 is added to the union of possible results.
953
956
  */
954
- caseValues: (matches: T[], result: R$1 | (() => R$1)) => Match<T, R$1>;
957
+ caseValues: <R2 extends Type>(matches: T[], result: R2 | (() => R2)) => Match<T, R$1 | R2>;
955
958
  /**
956
- * Match with a guard function (alias for readability)
959
+ * Match with a guard function (alias for readability).
960
+ * The result type R2 is added to the union of possible results.
957
961
  */
958
- when: (guard: (value: T) => boolean, result: PatternResult<T, R$1>) => Match<T, R$1>;
962
+ when: <R2 extends Type>(guard: (value: T) => boolean, result: PatternResult<T, R2>) => Match<T, R$1 | R2>;
959
963
  /**
960
- * Match multiple patterns (OR operation)
964
+ * Match multiple patterns (OR operation).
965
+ * The result type R2 is added to the union of possible results.
961
966
  */
962
- caseAny: (patterns: Pattern<T>[], result: PatternResult<T, R$1>) => Match<T, R$1>;
967
+ caseAny: <R2 extends Type>(patterns: Pattern<T>[], result: PatternResult<T, R2>) => Match<T, R$1 | R2>;
963
968
  /**
964
- * Default case - makes match non-exhaustive
969
+ * Default case - makes match non-exhaustive.
970
+ * The result type R2 is added to the union of possible results.
965
971
  */
966
- default: (result: PatternResult<T, R$1>) => R$1;
972
+ default: <R2 extends Type>(result: PatternResult<T, R2>) => R$1 | R2;
967
973
  /**
968
974
  * Force exhaustive matching (compile-time check for union types)
969
975
  */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { a as ExtractBrand, c as hasBrand, i as BrandedString, l as unwrapBrand, n as BrandedBoolean, o as Unwrap, r as BrandedNumber, s as createBrander, t as Brand } from "./Brand-BPeggBaO.js";
2
- import { $ as TestClockTag, $t as TaskFailure, A as OptionConstructor, An as PositiveNumber, At as ValidationRule, B as fromBinary, Bn as Functor, Bt as TaskErrorInfo, C as Functype, Cn as EmailAddress, Ct as OptionKind, D as List, Dn as NonNegativeNumber, Dt as FieldValidation, E as Collection, En as NonEmptyString, Et as FoldableUtils, F as Set, Fn as Try, Ft as TypedError, G as MatchableUtils, Gn as Extractable, Gt as Async, H as fromYAML, Hn as CollectionOps, Ht as formatError, I as SerializationResult, In as TypeNames, It as TypedErrorContext, J as Map, Jn as Doable, Jt as Err, K as ESMap, Kn as isExtractable, Kt as CancellationToken, L as createCustomSerializer, Ln as Promisable, Lt as ErrorChainElement, M as Stack, Mn as UrlString, Mt as ErrorCode, N as Valuable, Nn as ValidatedBrand, Nt as ErrorMessage, O as None, On as PatternString, Ot as FormValidation, P as ValuableParams, Pn as ValidatedBrandCompanion, Pt as ErrorStatus, Q as TestClock, Qt as Task$1, R as createSerializationCompanion, Rn as Applicative, Rt as ErrorFormatterOptions, S as tryCatchAsync, Sn as BoundedString, St as ListKind, T as FunctypeCollection, Tn as IntegerNumber, Tt as UniversalContainer, U as Ref, Un as ContainerOps, Ut as formatStackTrace, V as fromJSON, Vn as Monad, Vt as createErrorSerializer, W as Matchable, Wn as LazyList, Wt as safeStringify, X as Traversable, Xt as Sync, Y as SafeTraversable, Yn as ParseError, Yt as Ok, Z as Lazy, Zt as TaggedThrowable, _ as TypeCheckLeft, _n as CompanionMethods, _t as TagService, a as EmptyListError, an as createCancellationTokenSource, at as TimeoutError, b as isRight, bn as Companion, bt as HKT, c as LeftError, cn as FPromise, ct as LayerError, d as isDoCapable, dn as Throwable, dt as Exit, en as TaskMetadata, et as TestContext, f as unwrap, fn as ThrowableType, ft as ExitTag, g as TestEither, gn as Cond, gt as Tag, h as Right, hn as UntypedMatch, ht as HasService, i as DoGenerator, in as TaskSuccess, it as Task, j as Some, jn as UUID, jt as Validator, k as Option, kn as PositiveInteger, kt as Validation, l as LeftErrorType, ln as FPromiseCompanion, lt as LayerInput, m as Left, mn as Match, mt as ContextServices, n as Do, nn as TaskParams, nt as InterruptedError, o as FailureError, on as isTaggedThrowable, ot as UIO, p as Either, pn as Base, pt as Context, q as ESMapType, qn as DoResult, qt as CancellationTokenSource, r as DoAsync, rn as TaskResult, rt as RIO, s as FailureErrorType, sn as ErrorContext, st as Layer, t as $, tn as TaskOutcome, tt as IO, u as NoneError, un as NAME, ut as LayerOutput, v as TypeCheckRight, vn as InstanceType, vt as Identity, w as FunctypeBase, wn as ISO8601Date, wt as TryKind, x as tryCatch, xn as BoundedNumber, xt as Kind, y as isLeft, yn as isCompanion, yt as EitherKind, z as createSerializer, zn as AsyncMonad, zt as ErrorWithTaskInfo } from "./index-CrsC0sQU.js";
2
+ import { $ as TestClockTag, $t as TaskFailure, A as OptionConstructor, An as PositiveNumber, At as ValidationRule, B as fromBinary, Bn as Functor, Bt as TaskErrorInfo, C as Functype, Cn as EmailAddress, Ct as OptionKind, D as List, Dn as NonNegativeNumber, Dt as FieldValidation, E as Collection, En as NonEmptyString, Et as FoldableUtils, F as Set, Fn as Try, Ft as TypedError, G as MatchableUtils, Gn as Extractable, Gt as Async, H as fromYAML, Hn as CollectionOps, Ht as formatError, I as SerializationResult, In as TypeNames, It as TypedErrorContext, J as Map, Jn as Doable, Jt as Err, K as ESMap, Kn as isExtractable, Kt as CancellationToken, L as createCustomSerializer, Ln as Promisable, Lt as ErrorChainElement, M as Stack, Mn as UrlString, Mt as ErrorCode, N as Valuable, Nn as ValidatedBrand, Nt as ErrorMessage, O as None, On as PatternString, Ot as FormValidation, P as ValuableParams, Pn as ValidatedBrandCompanion, Pt as ErrorStatus, Q as TestClock, Qt as Task$1, R as createSerializationCompanion, Rn as Applicative, Rt as ErrorFormatterOptions, S as tryCatchAsync, Sn as BoundedString, St as ListKind, T as FunctypeCollection, Tn as IntegerNumber, Tt as UniversalContainer, U as Ref, Un as ContainerOps, Ut as formatStackTrace, V as fromJSON, Vn as Monad, Vt as createErrorSerializer, W as Matchable, Wn as LazyList, Wt as safeStringify, X as Traversable, Xt as Sync, Y as SafeTraversable, Yn as ParseError, Yt as Ok, Z as Lazy, Zt as TaggedThrowable, _ as TypeCheckLeft, _n as CompanionMethods, _t as TagService, a as EmptyListError, an as createCancellationTokenSource, at as TimeoutError, b as isRight, bn as Companion, bt as HKT, c as LeftError, cn as FPromise, ct as LayerError, d as isDoCapable, dn as Throwable, dt as Exit, en as TaskMetadata, et as TestContext, f as unwrap, fn as ThrowableType, ft as ExitTag, g as TestEither, gn as Cond, gt as Tag, h as Right, hn as UntypedMatch, ht as HasService, i as DoGenerator, in as TaskSuccess, it as Task, j as Some, jn as UUID, jt as Validator, k as Option, kn as PositiveInteger, kt as Validation, l as LeftErrorType, ln as FPromiseCompanion, lt as LayerInput, m as Left, mn as Match, mt as ContextServices, n as Do, nn as TaskParams, nt as InterruptedError, o as FailureError, on as isTaggedThrowable, ot as UIO, p as Either, pn as Base, pt as Context, q as ESMapType, qn as DoResult, qt as CancellationTokenSource, r as DoAsync, rn as TaskResult, rt as RIO, s as FailureErrorType, sn as ErrorContext, st as Layer, t as $, tn as TaskOutcome, tt as IO, u as NoneError, un as NAME, ut as LayerOutput, v as TypeCheckRight, vn as InstanceType, vt as Identity, w as FunctypeBase, wn as ISO8601Date, wt as TryKind, x as tryCatch, xn as BoundedNumber, xt as Kind, y as isLeft, yn as isCompanion, yt as EitherKind, z as createSerializer, zn as AsyncMonad, zt as ErrorWithTaskInfo } from "./index-DKAUrDCz.js";
3
3
  import { a as isTypeable, c as Pipe, i as TypeableParams, l as Foldable, n as ExtractTag, o as Serializable, r as Typeable, s as SerializationMethods, t as Tuple, u as Type } from "./Tuple-C4maYbiO.js";
4
4
  export { $, Applicative, Async, AsyncMonad, Base, BoundedNumber, BoundedString, Brand, BrandedBoolean, BrandedBoolean as BrandedBooleanType, BrandedNumber, BrandedNumber as BrandedNumberType, BrandedString, BrandedString as BrandedStringType, CancellationToken, CancellationTokenSource, Collection, CollectionOps, Companion, CompanionMethods, Cond, ContainerOps, Context, Context as ContextType, ContextServices, Do, DoAsync, DoGenerator, DoResult, Doable, ESMap, ESMapType, Either, EitherKind, EmailAddress, EmptyListError, Err, ErrorChainElement, ErrorCode, ErrorContext, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, Exit as ExitType, ExitTag, ExtractBrand, ExtractTag, Extractable, FPromise, FPromiseCompanion, FailureError, FailureErrorType, FieldValidation, Foldable, FoldableUtils, FormValidation, Functor, Functype, FunctypeBase, FunctypeCollection, HKT, HasService, IO, IO as IOType, Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, Kind, Layer, Layer as LayerType, LayerError, LayerInput, LayerOutput, Lazy, Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, List, ListKind, Map, Match, Matchable, MatchableUtils, Monad, NAME, NonEmptyString, NonNegativeNumber, None, NoneError, Ok, Option, OptionConstructor, OptionKind, ParseError, PatternString, Pipe, PositiveInteger, PositiveNumber, Promisable, RIO, Ref, Ref as RefType, Right, SafeTraversable, Serializable, SerializationMethods, SerializationResult, Set, Some, Stack, Sync, Tag, Tag as TagType, TagService, TaggedThrowable, Task$1 as Task, TaskErrorInfo, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, TestClock, TestClock as TestClockType, TestClockTag, TestContext, TestContext as TestContextType, TestEither, Throwable, ThrowableType, TimeoutError, Traversable, Try, TryKind, Tuple, Type, TypeCheckLeft, TypeCheckRight, TypeNames, Typeable, TypeableParams, TypedError, TypedErrorContext, UIO, UUID, UniversalContainer, UntypedMatch, Unwrap, UrlString, ValidatedBrand, ValidatedBrand as ValidatedBrandType, ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, safeStringify, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./Brand-Cfr5zy8F.js";import{$ as s,A as c,At as l,B as u,C as d,Ct as f,D as p,Dt as m,E as h,Et as g,F as _,G as v,H as y,I as b,J as x,K as S,L as C,M as w,Mt as T,N as E,Nt as D,O,Ot as k,P as A,Pt as j,Q as M,R as N,S as P,St as F,T as I,Tt as L,U as R,V as z,W as B,X as V,Y as H,Z as U,_ as W,_t as G,a as K,at as q,b as J,bt as Y,c as X,ct as Z,d as Q,dt as $,et as ee,f as te,ft as ne,g as re,gt as ie,h as ae,ht as oe,i as se,it as ce,j as le,jt as ue,k as de,kt as fe,l as pe,lt as me,m as he,mt as ge,n as _e,nt as ve,o as ye,ot as be,p as xe,pt as Se,q as Ce,r as we,rt as Te,s as Ee,st as De,t as Oe,tt as ke,u as Ae,ut as je,v as Me,vt as Ne,w as Pe,wt as Fe,x as Ie,xt as Le,y as Re,yt as ze,z as Be}from"./src-DtA8LBtt.js";import{n as Ve,t as He}from"./Tuple-CUljR3nx.js";export{p as $,v as Base,H as BoundedNumber,V as BoundedString,o as Brand,n as BrandedBoolean,i as BrandedNumber,t as BrandedString,Ve as Companion,Ce as Cond,re as Context,O as Do,de as DoAsync,K as ESMap,Z as Either,U as EmailAddress,c as EmptyListError,b as Err,ae as Exit,z as FPromise,y as FPromiseCompanion,le as FailureError,Re as FoldableUtils,Me as HKT,te as IO,M as ISO8601Date,W as Identity,s as IntegerNumber,xe as InterruptedError,Q as Layer,ye as Lazy,Le as LazyList,me as Left,w as LeftError,G as List,se as Map,S as Match,we as MatchableUtils,R as NAME,ee as NonEmptyString,ke as NonNegativeNumber,Fe as None,E as NoneError,C as Ok,L as Option,g as OptionConstructor,j as ParseError,ve as PatternString,Te as PositiveInteger,ce as PositiveNumber,F as Ref,je as Right,f as Set,m as Some,_e as Stack,Ae as Tag,N as Task,Ee as TestClock,X as TestClockTag,pe as TestContext,B as Throwable,he as TimeoutError,Y as Try,He as Tuple,$ as TypeCheckLeft,ne as TypeCheckRight,Ne as Typeable,P as TypedError,q as UUID,be as UrlString,De as ValidatedBrand,Ie as Validation,Oe as Valuable,e as createBrander,Be as createCancellationTokenSource,k as createCustomSerializer,d as createErrorSerializer,fe as createSerializationCompanion,l as createSerializer,Pe as formatError,I as formatStackTrace,ue as fromBinary,T as fromJSON,D as fromYAML,r as hasBrand,x as isCompanion,A as isDoCapable,J as isExtractable,Se as isLeft,ge as isRight,u as isTaggedThrowable,ze as isTypeable,h as safeStringify,oe as tryCatch,ie as tryCatchAsync,_ as unwrap,a as unwrapBrand};
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./Brand-Cfr5zy8F.js";import{$ as s,A as c,At as l,B as u,C as d,Ct as f,D as p,Dt as m,E as h,Et as g,F as _,G as v,H as y,I as b,J as x,K as S,L as C,M as w,Mt as T,N as E,Nt as D,O,Ot as k,P as A,Pt as j,Q as M,R as N,S as P,St as F,T as I,Tt as L,U as R,V as z,W as B,X as V,Y as H,Z as U,_ as W,_t as G,a as K,at as q,b as J,bt as Y,c as X,ct as Z,d as Q,dt as $,et as ee,f as te,ft as ne,g as re,gt as ie,h as ae,ht as oe,i as se,it as ce,j as le,jt as ue,k as de,kt as fe,l as pe,lt as me,m as he,mt as ge,n as _e,nt as ve,o as ye,ot as be,p as xe,pt as Se,q as Ce,r as we,rt as Te,s as Ee,st as De,t as Oe,tt as ke,u as Ae,ut as je,v as Me,vt as Ne,w as Pe,wt as Fe,x as Ie,xt as Le,y as Re,yt as ze,z as Be}from"./src-BuPnddUO.js";import{n as Ve,t as He}from"./Tuple-CUljR3nx.js";export{p as $,v as Base,H as BoundedNumber,V as BoundedString,o as Brand,n as BrandedBoolean,i as BrandedNumber,t as BrandedString,Ve as Companion,Ce as Cond,re as Context,O as Do,de as DoAsync,K as ESMap,Z as Either,U as EmailAddress,c as EmptyListError,b as Err,ae as Exit,z as FPromise,y as FPromiseCompanion,le as FailureError,Re as FoldableUtils,Me as HKT,te as IO,M as ISO8601Date,W as Identity,s as IntegerNumber,xe as InterruptedError,Q as Layer,ye as Lazy,Le as LazyList,me as Left,w as LeftError,G as List,se as Map,S as Match,we as MatchableUtils,R as NAME,ee as NonEmptyString,ke as NonNegativeNumber,Fe as None,E as NoneError,C as Ok,L as Option,g as OptionConstructor,j as ParseError,ve as PatternString,Te as PositiveInteger,ce as PositiveNumber,F as Ref,je as Right,f as Set,m as Some,_e as Stack,Ae as Tag,N as Task,Ee as TestClock,X as TestClockTag,pe as TestContext,B as Throwable,he as TimeoutError,Y as Try,He as Tuple,$ as TypeCheckLeft,ne as TypeCheckRight,Ne as Typeable,P as TypedError,q as UUID,be as UrlString,De as ValidatedBrand,Ie as Validation,Oe as Valuable,e as createBrander,Be as createCancellationTokenSource,k as createCustomSerializer,d as createErrorSerializer,fe as createSerializationCompanion,l as createSerializer,Pe as formatError,I as formatStackTrace,ue as fromBinary,T as fromJSON,D as fromYAML,r as hasBrand,x as isCompanion,A as isDoCapable,J as isExtractable,Se as isLeft,ge as isRight,u as isTaggedThrowable,ze as isTypeable,h as safeStringify,oe as tryCatch,ie as tryCatchAsync,_ as unwrap,a as unwrapBrand};
@@ -1,2 +1,2 @@
1
- import { D as List } from "../index-CrsC0sQU.js";
1
+ import { D as List } from "../index-DKAUrDCz.js";
2
2
  export { List };
@@ -1 +1 @@
1
- import{_t as e}from"../src-DtA8LBtt.js";export{e as List};
1
+ import{_t as e}from"../src-BuPnddUO.js";export{e as List};
@@ -1,2 +1,2 @@
1
- import { J as Map, Y as SafeTraversable } from "../index-CrsC0sQU.js";
1
+ import { J as Map, Y as SafeTraversable } from "../index-DKAUrDCz.js";
2
2
  export { Map, SafeTraversable };
package/dist/map/index.js CHANGED
@@ -1 +1 @@
1
- import{i as e}from"../src-DtA8LBtt.js";export{e as Map};
1
+ import{i as e}from"../src-BuPnddUO.js";export{e as Map};
@@ -1,2 +1,2 @@
1
- import { A as OptionConstructor, O as None, j as Some, k as Option } from "../index-CrsC0sQU.js";
1
+ import { A as OptionConstructor, O as None, j as Some, k as Option } from "../index-DKAUrDCz.js";
2
2
  export { None, Option, OptionConstructor, Some };
@@ -1 +1 @@
1
- import{Dt as e,Et as t,Tt as n,wt as r}from"../src-DtA8LBtt.js";export{r as None,n as Option,t as OptionConstructor,e as Some};
1
+ import{Dt as e,Et as t,Tt as n,wt as r}from"../src-BuPnddUO.js";export{r as None,n as Option,t as OptionConstructor,e as Some};
@@ -1,2 +1,2 @@
1
- import { F as Set } from "../index-CrsC0sQU.js";
1
+ import { F as Set } from "../index-DKAUrDCz.js";
2
2
  export { Set };
package/dist/set/index.js CHANGED
@@ -1 +1 @@
1
- import{Ct as e}from"../src-DtA8LBtt.js";export{e as Set};
1
+ import{Ct as e}from"../src-BuPnddUO.js";export{e as Set};
@@ -5,7 +5,7 @@ import{t as e}from"./Brand-Cfr5zy8F.js";import{n as t,r as n,t as r}from"./Tuple
5
5
  `)[1]?.split(`: `)[1];return ae(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return ie.fromJSON(t)}},ae=t(re,ie),oe=e=>{let t=e;return{get(){return t},set(e){t=e},update(e){t=e(t)},getAndSet(e){let n=t;return t=e,n},updateAndGet(e){return t=e(t),t},getAndUpdate(e){let n=t;return t=e(t),n},compareAndSet(e,n){return t===e?(t=n,!0):!1},modify(e){let[n,r]=e(t);return t=n,r}}},_=t(oe,{of:e=>oe(e)}),se=(e=0)=>{let t=_(e),n=e;return{get:()=>t.get(),set:e=>t.set(e),increment:()=>t.updateAndGet(e=>e+1),decrement:()=>t.updateAndGet(e=>e-1),reset:()=>t.set(n),compareAndSet:(e,n)=>t.compareAndSet(e,n)}},ce=()=>{let e=_([]);return{add:t=>e.update(e=>[...e,t]),addAll:t=>e.update(e=>[...e,...t]),build:()=>e.get(),clear:()=>e.set([]),size:()=>e.get().length}},v=e=>{let t={_tag:`LazyList`,[Symbol.iterator]:()=>e[Symbol.iterator](),map:t=>v((function*(){for(let n of e)yield t(n)})()),flatMap:t=>v((function*(){for(let n of e)yield*t(n)})()),filter:t=>v((function*(){for(let n of e)t(n)&&(yield n)})()),take:t=>v((function*(){let n=se(0);for(let r of e){if(n.get()>=t)break;yield r,n.increment()}})()),drop:t=>v((function*(){let n=se(0);for(let r of e)n.get()>=t&&(yield r),n.increment()})()),takeWhile:t=>v((function*(){for(let n of e){if(!t(n))break;yield n}})()),dropWhile:t=>v((function*(){let n=_(!0);for(let r of e)n.get()&&t(r)||(n.set(!1),yield r)})()),concat:t=>v((function*(){yield*e,yield*t})()),zip:t=>v((function*(){let n=e[Symbol.iterator](),r=t[Symbol.iterator]();for(;;){let e=n.next(),t=r.next();if(e.done||t.done)break;yield[e.value,t.value]}})()),toList:()=>S(Array.from(e)),toArray:()=>Array.from(e),forEach:t=>{for(let n of e)t(n)},reduce:(t,n)=>{let r=_(n);for(let n of e)r.set(t(r.get(),n));return r.get()},find:t=>{for(let n of e)if(t(n))return m(n);return m.none()},some:t=>{for(let n of e)if(t(n))return!0;return!1},every:t=>{for(let n of e)if(!t(n))return!1;return!0},count:()=>{let t=se(0);for(let n of e)t.increment();return t.get()},first:()=>{let t=e[Symbol.iterator]().next();return t.done?m.none():m(t.value)},last:()=>{let t=_(void 0),n=_(!1);for(let r of e)t.set(r),n.set(!0);return n.get()?m(t.get()):m.none()},fold:(t,n)=>{let r=e[Symbol.iterator]().next();return r.done?t():n(r.value)},foldLeft:t=>n=>{let r=_(t);for(let t of e)r.set(n(r.get(),t));return r.get()},foldRight:t=>n=>Array.from(e).reduceRight((e,t)=>n(t,e),t),pipe:e=>e(t),serialize:()=>{let t=Array.from(e);return{toJSON:()=>JSON.stringify({_tag:`LazyList`,value:t}),toYAML:()=>`_tag: LazyList\nvalue: ${i(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`LazyList`,value:t})).toString(`base64`)}},toString:()=>{let t=[],n=se(0),r=_(!1);for(let i of e)if(n.get()<10)t.push(i),n.increment();else{r.set(!0);break}let i=t.map(e=>String(e)).join(`, `);return r.get()?`LazyList(${i}, ...)`:`LazyList(${i})`}};return t},le=t(e=>v(e),{empty:()=>v([]),of:e=>v([e]),from:(...e)=>v(e),iterate:(e,t)=>v((function*(){let n=_(e);for(;;)yield n.get(),n.set(t(n.get()))})()),generate:e=>v((function*(){for(;;)yield e()})()),range:(e,t,n=1)=>v((function*(){if(n===0)throw Error(`Step cannot be zero`);let r=_(e);if(n>0)for(;r.get()<t;)yield r.get(),r.set(r.get()+n);else for(;r.get()>t;)yield r.get(),r.set(r.get()+n)})()),repeat:(e,t)=>v((function*(){if(t===void 0)for(;;)yield e;else{let n=se(0);for(;n.get()<t;)yield e,n.increment()}})()),cycle:e=>v((function*(){let t=Array.from(e);if(t.length!==0)for(;;)yield*t})())}),ue=e=>({_tag:`Success`,error:void 0,isSuccess(){return!0},isFailure(){return!1},orElse:t=>e,orThrow:t=>e,or:t=>ue(e),orNull:()=>e,orUndefined:()=>e,toEither:t=>C(e),map:t=>b(()=>t(e)),ap:t=>t.map(t=>t(e)),flatMap:t=>t(e),flatMapAsync:async t=>t(e),fold:(t,n)=>n(e),match:t=>t.Success(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),toString:()=>`Success(${i(e)})`,toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Success`,value:e}),toOption:()=>d(e),toList:()=>S([e]),toTry:()=>ue(e),pipe:t=>t(e),serialize:()=>o(`Success`,e),get size(){return 1},get isEmpty(){return!1},contains:t=>e===t,reduce:t=>e,reduceRight:t=>e,count:t=>t(e)?1:0,find:t=>t(e)?m(e):m(void 0),exists:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),y=e=>({_tag:`Failure`,error:e,isSuccess(){return!1},isFailure(){return!0},orElse:e=>e,orThrow:t=>{throw t??e},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:t=>w(e),map:t=>y(e),ap:t=>y(e),flatMap:t=>y(e),flatMapAsync:t=>Promise.resolve(y(e)),fold:(t,n)=>t(e),match:t=>t.Failure(e),foldLeft:e=>t=>e,foldRight:e=>t=>e,toString:()=>`Failure(${i(e)}))`,toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Failure`,value:e}),toOption:()=>p(),toList:()=>S([]),toTry:()=>y(e),pipe:t=>{throw e},serialize:()=>s({_tag:`Failure`,error:e.message,stack:e.stack}),get size(){return 0},get isEmpty(){return!0},contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce a Failure`)},reduceRight:e=>{throw Error(`Cannot reduceRight a Failure`)},count:e=>0,find:e=>m(null),exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),de=e=>{try{return ue(e())}catch(e){return y(e instanceof Error?e:Error(String(e)))}},fe={isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),fromJSON:e=>{let t=JSON.parse(e);if(t._tag===`Success`)return ue(t.value);{let e=Error(t.error);return t.stack&&(e.stack=t.stack),y(e)}},fromYAML:e=>{let t=e.split(`
6
6
  `),n=t[0]?.split(`: `)[1];if(!n)return y(Error(`Invalid YAML format for Try`));if(n===`Success`){let e=t[1]?.split(`: `)[1];return e?ue(JSON.parse(e)):y(Error(`Invalid YAML format for Try Success`))}else{let e=t[1]?.split(`: `)[1];if(!e)return y(Error(`Invalid YAML format for Try Failure`));let n=t[2]?.split(`: `),r=n&&n.length>1?n.slice(1).join(`: `):void 0,i=Error(e);return r&&(i.stack=r),y(i)}},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return fe.fromJSON(t)}},b=t(de,fe);function pe({_tag:e,impl:t}){return{...t,_tag:e}}function me(e,t){return!e||typeof e!=`object`||!(`_tag`in e)?!1:t?e._tag===t:!0}const x=e=>{let t=Array.from(e??[]),n={_tag:`List`,[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:e=>x(t.map(e)),ap:e=>x(t.flatMap(t=>Array.from(e).map(e=>e(t)))),flatMap:e=>x(t.flatMap(t=>Array.from(e(t)))),flatMapAsync:async e=>x((await Promise.all(t.map(async t=>await e(t)))).flatMap(e=>Array.from(e))),forEach:e=>t.forEach(e),contains:e=>t.includes(e),count:e=>t.filter(e).length,exists:e=>t.some(e),filter:e=>x(t.filter(e)),filterNot:e=>x(t.filter(t=>!e(t))),filterType:e=>x(t.filter(t=>me(t,e))),find:(e,n)=>m(t.find(t=>e(t)&&(n?me(t,n):!0))),get head(){return t[0]},get headOption(){return t.length>0?m(t[0]):p()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:e=>t.reduce(e),reduceRight:e=>t.reduceRight(e),fold:(e,n)=>{if(t.length===0)return e();let r=t[0];return n(r)},foldLeft:e=>n=>t.reduce(n,e),foldRight:e=>n=>t.reduceRight((e,t)=>n(t,e),e),match:e=>t.length===0?e.Empty():e.NonEmpty([...t]),remove:e=>x(t.filter(t=>t!==e)),removeAt:e=>e<0||e>=t.length?n:x([...t.slice(0,e),...t.slice(e+1)]),add:e=>x([...t,e]),get:e=>m(t[e]),concat:e=>x([...t,...e.toArray()]),drop:e=>x(t.slice(e)),dropRight:e=>x(t.slice(0,-e)),dropWhile:e=>x(t.slice(t.findIndex(t=>!e(t)))),flatten:()=>x(t.flatMap(e=>Array.isArray(e)?e:[e])),toList:()=>n,toSet:()=>ae(t),toOption:()=>t.length>0?m(t[0]):p(),toEither:e=>t.length>0?C(t[0]):w(e),toTry:()=>t.length>0?b(()=>t[0]):b(()=>{throw Error(`Empty list`)}),toString:()=>`List(${i(t)})`,toValue:()=>({_tag:`List`,value:t}),pipe:e=>e([...t]),serialize:()=>o(`List`,t),doUnwrap(){return t.length===0?{ok:!1,empty:!0}:{ok:!0,value:t[0]}}};return n},he=e=>x(e),ge={fromJSON:e=>S(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
7
7
  `)[1]?.split(`: `)[1];return S(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return ge.fromJSON(t)}},S=t(he,ge),_e=e=>({_tag:`Right`,value:e,isLeft(){return!1},isRight(){return!0},orElse:t=>e,orThrow:()=>e,or:t=>C(e),orNull:()=>e,orUndefined:()=>e,map:t=>C(t(e)),ap:t=>t._tag===`Right`?C(t.value(e)):w(t.value),mapAsync:t=>t(e).then(e=>C(e)).catch(e=>Promise.resolve(w(e))),merge:t=>t.isLeft()?w(t.value):C([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(e=>w(e)),toOption:()=>d(e),toList:()=>S([e]),toEither:t=>C(e),toTry:()=>b(()=>e),toJSON(){return{_tag:`Right`,value:e}},toString:()=>`Right(${i(e)})`,*[Symbol.iterator](){yield e},*yield(){yield e},traverse:t=>{let n=t(e);return n.isLeft()?w(n.value):C([n.value])},*lazyMap(t){yield C(t(e))},tap:t=>(t(e),C(e)),tapLeft:t=>C(e),mapLeft:t=>C(e),bimap:(t,n)=>C(n(e)),fold:(t,n)=>n(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),match:t=>t.Right(e),swap:()=>w(e),toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Right`,value:e}),pipeEither:(t,n)=>n(e),pipe:t=>t(e),serialize:()=>o(`Right`,e),get size(){return 1},get isEmpty(){return!1},contains:t=>e===t,reduce:t=>e,reduceRight:t=>e,count:t=>t(e)?1:0,find:t=>t(e)?d(e):p(),exists:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),ve=e=>({_tag:`Left`,value:e,isLeft(){return!0},isRight(){return!1},orElse:e=>e,orThrow:t=>{throw t??e},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:t=>w(e),ap:t=>w(e),mapAsync:t=>Promise.resolve(w(e)),merge:t=>w(e),flatMap:t=>w(e),flatMapAsync:t=>Promise.resolve(w(e)),toOption:()=>p(),toList:()=>S(),toEither:e=>w(e),toTry:()=>b(()=>{throw Error(String(e))}),toJSON(){return{_tag:`Left`,value:e}},toString:()=>`Left(${i(e)})`,*[Symbol.iterator](){},*yield(){},traverse:t=>w(e),*lazyMap(t){yield w(e)},tap:t=>w(e),tapLeft:t=>(t(e),w(e)),mapLeft:t=>w(t(e)),bimap:(t,n)=>w(t(e)),fold:(t,n)=>t(e),foldLeft:e=>t=>e,foldRight:e=>t=>e,match:t=>t.Left(e),swap:()=>C(e),toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Left`,value:e}),pipeEither:(t,n)=>t(e),pipe:t=>t(e),serialize:()=>o(`Left`,e),get size(){return 0},get isEmpty(){return!0},contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce a Left`)},reduceRight:e=>{throw Error(`Cannot reduceRight a Left`)},count:e=>0,find:e=>p(),exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),C=e=>_e(e),w=e=>ve(e),ye=e=>e.isRight(),be=e=>e.isLeft(),xe=(e,t)=>{try{return C(e())}catch(e){return w(t(e))}},Se=e=>_e(e);console.assert(Se);const Ce=e=>ve(e);console.assert(Ce);const we=async(e,t)=>{try{return C(await e())}catch(e){return w(t(e))}},Te=(e,t)=>t?C(e):w(e),Ee={left:e=>w(e),right:e=>C(e),isRight:e=>e.isRight(),isLeft:e=>e.isLeft(),sequence:e=>e.reduce((e,t)=>e.isLeft()?e:t.isLeft()?w(t.value):e.map(e=>[...e,t.value]),C([])),traverse:(e,t)=>Ee.sequence(e.map(t)),fromNullable:(e,t)=>e==null?w(t):C(e),fromPredicate:(e,t,n)=>t(e)?C(e):w(n),ap:(e,t)=>e.flatMap(e=>t.map(e)),fromPromise:async(e,t)=>{try{return C(await e)}catch(e){return w(t(e))}},fromJSON:e=>{let t=JSON.parse(e);return t._tag===`Right`?C(t.value):w(t.value)},fromYAML:e=>{let t=e.split(`
8
- `),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)throw Error(`Invalid YAML format for Either`);let i=JSON.parse(r);return n===`Right`?C(i):w(i)},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return Ee.fromJSON(t)}},De=t(Te,Ee);function T(t,n){return{brand:t,validate:n,of:r=>n(r)?m(e(t,r)):m.none(),from:r=>n(r)?C(e(t,r)):w(`Invalid ${t}: validation failed`),unsafeOf:r=>{if(!n(r))throw Error(`Invalid ${t}: validation failed`);return e(t,r)},is:e=>{try{return n(e)}catch{return!1}},unwrap:e=>e,refine:(e,t)=>T(e,e=>n(e)&&t(e))}}const Oe=T(`PositiveNumber`,e=>e>0),ke=T(`NonNegativeNumber`,e=>e>=0),Ae=T(`IntegerNumber`,e=>Number.isInteger(e)),je=Oe.refine(`PositiveInteger`,e=>Number.isInteger(e)),Me=T(`NonEmptyString`,e=>e.length>0),Ne=T(`EmailAddress`,e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)),Pe=T(`UrlString`,e=>{try{return new URL(e),!0}catch{return!1}}),Fe=T(`UUID`,e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)),Ie=T(`ISO8601Date`,e=>!isNaN(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(e));function Le(e,t,n){return T(e,e=>e>=t&&e<=n)}function Re(e,t,n){return T(e,e=>e.length>=t&&e.length<=n)}function ze(e,t){return T(e,e=>t.test(e))}const Be=e=>typeof e==`function`&&Object.keys(e).length>0,Ve=e=>{let t=e=>typeof e==`function`?e():e,n={when:(r,i)=>e.resolved?n:r?Ve({resolved:!0,value:t(i)}):n,elseWhen:(r,i)=>e.resolved?n:r?Ve({resolved:!0,value:t(i)}):n,else:n=>e.resolved?e.value:t(n),orThrow:()=>{if(!e.resolved)throw Error(`Conditional expression has no matching condition`);return e.value}};return n},He=()=>Ve({resolved:!1}),Ue=t(He,{of:()=>He(),match:e=>t=>{let n=t[e];if(n===void 0)throw Error(`No case defined for value: ${String(e)}`);return typeof n==`function`?n():n},lazy:()=>{let e={resolved:!1},t={when:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),elseWhen:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),else:t=>e.resolved?e.value:t()};return t}}),E=(e,t)=>t===e?!0:typeof t==`function`?t(e):t&&typeof t==`object`&&`_`in t?t._(e):typeof t==`object`&&t&&typeof e==`object`&&e?Object.entries(t).every(([t,n])=>{let r=e[t];return E(r,n)}):!1,D=e=>{let t=(e,t)=>typeof e==`function`?e(t):e,n=()=>{for(let{pattern:n,result:r}of e.patterns)if(E(e.value,n))return{matched:!0,result:t(r,e.value)};return{matched:!1}},r={case:(n,i)=>{if(e.resolved)return r;let a={...e,patterns:[...e.patterns,{pattern:n,result:i}]};return E(e.value,n)?D({...a,resolved:!0,result:t(i,e.value)}):D(a)},caseValue:(t,n)=>{if(e.resolved)return r;if(e.value===t){let t=typeof n==`function`?n():n;return D({...e,resolved:!0,result:t})}return r},caseValues:(t,n)=>{if(e.resolved)return r;if(t.includes(e.value)){let t=typeof n==`function`?n():n;return D({...e,resolved:!0,result:t})}return r},when:(e,t)=>r.case(e,t),caseAny:(n,i)=>{if(e.resolved)return r;for(let r of n)if(E(e.value,r))return D({...e,resolved:!0,result:t(i,e.value),patterns:[...e.patterns,{pattern:r,result:i}]});return D({...e,patterns:[...e.patterns,...n.map(e=>({pattern:e,result:i}))]})},default:n=>e.resolved?e.result:t(n,e.value),exhaustive:()=>{let t=n();if(!t.matched)throw Error(`Non-exhaustive match. No pattern matched value: ${JSON.stringify(e.value)}`);return t.result},orThrow:t=>{let r=n();if(!r.matched)throw Error(t??`No matching pattern for value: ${JSON.stringify(e.value)}`);return r.result},toOption:()=>{let e=n();return e.matched?m(e.result):m.none()}};return r},We=e=>{let t=(e,t)=>typeof e==`function`?e(t):e;return{case:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return E(e,n)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseValue:(t,n)=>D(e===t?{value:e,resolved:!0,result:typeof n==`function`?n():n,patterns:[]}:{value:e,resolved:!1,patterns:[]}),caseValues:(t,n)=>t.includes(e)?D({value:e,resolved:!0,result:typeof n==`function`?n():n,patterns:[]}):D({value:e,resolved:!1,patterns:[]}),when:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return n(e)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseAny:(n,r)=>{for(let i of n)if(E(e,i))return D({value:e,resolved:!0,result:t(r,e),patterns:n.map(e=>({pattern:e,result:r}))});return D({value:e,resolved:!1,patterns:n.map(e=>({pattern:e,result:r}))})}}},Ge=t(e=>We(e),{exhaustive:e=>t=>{let n=e[t];if(n===void 0)throw Error(`No case defined for value: ${String(t)}`);return n},partial:e=>({withDefault:t=>n=>{let r=e[n];return r===void 0?typeof t==`function`?t(n):t:typeof r==`function`?r(n):r}}),withGuards:e=>({withDefault:t=>n=>{for(let[t,r]of e)if(t(n))return typeof r==`function`?r(n):r;return typeof t==`function`?t(n):t}}),struct:()=>{let e=[],t={case:(n,r)=>(e.push({pattern:n,handler:r}),t),build:()=>t=>{for(let{pattern:n,handler:r}of e)if(E(t,n))return r(t);throw Error(`No matching pattern for value: ${JSON.stringify(t)}`)}};return t},builder:()=>{let e=[],t,n={case:(t,r)=>(e.push({pattern:t,result:r}),n),when:(t,r)=>(e.push({pattern:t,result:r}),n),default:n=>(t=n,{build:()=>n=>{for(let{pattern:t,result:r}of e)if(E(n,t))return typeof r==`function`?r(n):r;if(t!==void 0)return typeof t==`function`?t(n):t;throw Error(`No matching pattern for value: ${JSON.stringify(n)}`)}})};return n}});function Ke(e,t){return{...pe({_tag:e,impl:t}),toString(){return`${e}()`},doUnwrap(){if(`isSome`in t&&`isNone`in t){if(typeof t.isSome==`function`&&t.isSome()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isNone==`function`&&t.isNone())return{ok:!1,empty:!0}}if(`isLeft`in t&&`isRight`in t){if(typeof t.isRight==`function`&&t.isRight()&&`value`in t)return{ok:!0,value:t.value};if(typeof t.isLeft==`function`&&t.isLeft()&&`value`in t)return{ok:!1,empty:!1,error:t.value}}if(`isSuccess`in t&&`isFailure`in t){if(typeof t.isSuccess==`function`&&t.isSuccess()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isFailure==`function`&&t.isFailure()&&`getError`in t&&typeof t.getError==`function`)return{ok:!1,empty:!1,error:t.getError()}}if(`isEmpty`in t&&`head`in t){if(typeof t.isEmpty==`function`&&t.isEmpty())return{ok:!1,empty:!0};if(typeof t.head==`function`)return{ok:!0,value:t.head()};if(`head`in t)return{ok:!0,value:t.head}}return{ok:!0,value:t}}}}const qe=`Throwable`;var Je=class e extends Error{constructor(e,t){super(e,{cause:t?.cause}),this._tag=qe,this.name=t?.taskInfo?.name??qe,Object.defineProperties(this,{_tag:{value:qe,writable:!1,configurable:!1},data:{value:t?.data,writable:!1,configurable:!1},taskInfo:{value:t?.taskInfo,writable:!1,configurable:!1},name:{value:t?.taskInfo?.name??qe,writable:!1,configurable:!1}}),t?.cause&&Object.defineProperty(this,`cause`,{value:t.cause,writable:!1,configurable:!1}),t?.stack?this.stack=t.stack:Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static apply(t,n,r){if(t instanceof Error){let i=new e(t.message,{data:n,cause:t.cause??void 0,stack:t.stack??void 0,taskInfo:r});for(let e of Object.keys(t))if(!(e in i)){let n=i;n[e]=t[e]}return i}if(t&&typeof t==`object`){let i=t,a=new e(typeof i.message==`string`?i.message:typeof i.error==`string`?i.error:`Object error: ${JSON.stringify(i,Object.getOwnPropertyNames(i).filter(e=>i[e]!==void 0))}`,{data:n??i,taskInfo:r});for(let e of Object.keys(i))if(!(e in a)){let t=a;t[e]=i[e]}return a}if(typeof t==`function`){let i=t.name??`anonymous function`,a=t.toString().substring(0,100)+(t.toString().length>100?`...`:``);return new e(`Function error: ${i}`,{data:n??{functionType:typeof t,functionName:i,functionString:a},taskInfo:r})}let i=typeof t,a=t===null?`null`:t===void 0?`undefined`:String(t);if(i===`number`){let a=t;return new e(Number.isNaN(a)?`Number error: NaN`:Number.isFinite(a)?`Number error: ${a}`:`Number error: ${a>0?`Infinity`:`-Infinity`}`,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}if(i===`bigint`)return new e(`BigInt error: ${t}n`,{data:n??{errorType:i,errorValue:String(t),originalError:t},taskInfo:r});if(i===`boolean`)return new e(`Boolean error: ${t}`,{data:n??{errorType:i,errorValue:t,originalError:t},taskInfo:r});if(i===`symbol`){let a=t.description??`unnamed symbol`;return new e(`Symbol error: Symbol(${a})`,{data:n??{errorType:i,symbolDescription:a,originalError:t},taskInfo:r})}return new e(typeof t==`string`?t:`${i.charAt(0).toUpperCase()+i.slice(1)} error: ${a}`,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}};const O=e=>{let t=new Promise((t,n)=>{try{e(t,n)}catch(e){n(e)}});return{_tag:`FPromise`,map:e=>O((n,r)=>{t.then(t=>{try{n(e(t))}catch(e){r(e)}}).catch(r)}),flatMap:e=>O((n,r)=>{t.then(t=>{try{let i=e(t);`_tag`in i&&i._tag===`FPromise`?i.then(n,r):Promise.resolve(i).then(n,r)}catch(e){r(e)}}).catch(r)}),flatMapAsync:async e=>{let n=e(await t);return n instanceof Promise?n:new Promise((e,t)=>{n.then(e,t)})},tap:e=>O((n,r)=>{t.then(t=>{try{e(t),n(t)}catch(e){r(e)}}).catch(r)}),mapError:e=>O((n,r)=>{t.then(n).catch(t=>{try{r(e(t,{originalError:t,stack:t instanceof Error?t.stack:void 0,timestamp:Date.now()}))}catch(e){r(e)}})}),tapError:e=>O((n,r)=>{t.then(n).catch(t=>{try{e(t),r(t)}catch(e){r(e)}})}),recover:e=>O(n=>{t.then(n).catch(()=>n(e))}),recoverWith:e=>O(n=>{t.then(n).catch(t=>{try{n(e(t))}catch{n(null)}})}),recoverWithF:e=>O((n,r)=>{t.then(n).catch(t=>{try{e(t).then(n,r)}catch(e){r(e)}})}),filterError:(e,n)=>O((r,i)=>{t.then(r).catch(t=>{if(e(t))try{n(t).then(r,i)}catch(e){i(e)}else i(t)})}),logError:e=>O((n,r)=>{t.then(n).catch(t=>{try{e(t,{originalError:t,stack:t instanceof Error?t.stack:void 0,timestamp:Date.now()})}catch{}finally{r(t)}})}),then:(e,n)=>t.then(e,n),toPromise:()=>t,toEither:async()=>{try{return C(await t)}catch(e){return w(e)}},fold:(e,n)=>O((r,i)=>{t.then(e=>{try{r(n(e))}catch(e){i(e)}}).catch(t=>{try{r(e(t))}catch(e){i(e)}})})}},Ye={resolve:e=>O(t=>t(e)),reject:e=>O((t,n)=>n(e)),from:e=>O((t,n)=>{e.then(t).catch(n)}),fromEither:e=>e.isRight()?O(t=>t(e.value)):O((t,n)=>n(e.value)),all:e=>O((t,n)=>{Promise.all(e.map(e=>e instanceof Promise?e:Promise.resolve(e))).then(t).catch(n)}),allSettled:e=>O(t=>{let n=[],r=0;if(e.length===0){t([]);return}e.forEach((i,a)=>{Promise.resolve(i).then(i=>{n[a]=C(i),r++,r===e.length&&t(n)}).catch(i=>{n[a]=w(i),r++,r===e.length&&t(n)})})}),race:e=>O((t,n)=>{Promise.race(e).then(t,n)}),any:e=>O((t,n)=>{if(typeof Promise.any==`function`)Promise.any(e).then(t,n);else{let r=0,i=[];if(e.length===0){n(AggregateError([],`All promises were rejected`));return}e.forEach((a,o)=>{Promise.resolve(a).then(t).catch(t=>{i[o]=t,r++,r===e.length&&n(AggregateError(i,`All promises were rejected`))})})}}),retryWithBackoff:(e,t)=>{let{maxRetries:n,baseDelay:r=100,shouldRetry:i=()=>!0}=t;return O((t,a)=>{let o=0,s=()=>{e().toPromise().then(t).catch(e=>{if(o++,o<=n&&i(e,o)){let e=r*2**(o-1);setTimeout(s,e)}else a(e)})};s()})}},Xe=t(O,Ye);function Ze(e){return e instanceof Error&&typeof e==`object`&&e._tag===`Throwable`}const Qe=(e,t)=>{if(e.isRight())return A(e.orThrow(),t);if(e.isLeft())return k(e.fold(e=>e,()=>Error(`Unexpected right value`)),void 0,t);throw Error(`Unrecognized task outcome`)},k=(e,t,n)=>{let r={name:n?.name??`Task`,description:n?.description??``},a=Je.apply(e,t,r),o={...Ke(`Err`,{error:a,meta:r}),_tag:`Err`,_meta:r,value:void 0,error:a,isSuccess(){return!1},isFailure(){return!0},isOk(){return!1},isErr(){return!0},map:e=>k(a,t,n),flatMap:e=>k(a,t,n),ap:e=>k(a,t,n),mapAsync:e=>Promise.resolve(k(a,t,n)),flatMapAsync:e=>Promise.resolve(k(a,t,n)),mapError:e=>k(e(a),t,n),recover:e=>A(e,n),recoverWith:e=>A(e(a),n),orThrow:e=>{throw e??a},orElse:e=>e,or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:()=>w(a),toTry:()=>b(()=>{throw a}),toOption:()=>p(),toList:()=>S([]),fold:(e,t)=>e(a),match:e=>e.Err(a),foldLeft:e=>t=>e,foldRight:e=>t=>e,size:0,isEmpty:!0,contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce empty Err`)},reduceRight:e=>{throw Error(`Cannot reduceRight empty Err`)},count:e=>0,find:e=>p(),exists:e=>!1,forEach:e=>{},toPromise:()=>Promise.reject(a),doUnwrap(){return{ok:!1,empty:!1,error:a}},serialize:()=>({toJSON:()=>i({_tag:`Err`,error:a.message??a.toString()})??`{}`,toYAML:()=>`_tag: Err\nerror: ${a.message??a.toString()}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Err`,error:a.message??a.toString()})).toString(`base64`)}),pipe:e=>e(o)};return o},A=(e,t)=>{let n={name:t?.name??`Task`,description:t?.description??``},r={...Ke(`Ok`,{value:e,meta:n}),_tag:`Ok`,_meta:n,value:e,error:void 0,isSuccess(){return!0},isFailure(){return!1},isOk(){return!0},isErr(){return!1},map:n=>A(n(e),t),flatMap:n=>{let r=n(e);return r&&typeof r==`object`&&`isLeft`in r&&`isRight`in r?Qe(r,t):r},ap:n=>n.isOk()?A(n.value(e),t):k(n.error,void 0,t),mapAsync:async n=>A(await n(e),t),flatMapAsync:async t=>await t(e),mapError:n=>A(e,t),recover:n=>A(e,t),recoverWith:n=>A(e,t),orThrow:t=>e,orElse:t=>e,or:n=>A(e,t),orNull:()=>e,orUndefined:()=>e,toEither:()=>C(e),toTry:()=>b(()=>e),toOption:()=>d(e),toList:()=>S([e]),fold:(t,n)=>n(e),match:t=>t.Ok(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),size:1,isEmpty:!1,contains:t=>e===t,reduce:t=>e,reduceRight:t=>e,count:t=>t(e)?1:0,find:t=>t(e)?d(e):p(),exists:t=>t(e),forEach:t=>t(e),toPromise:()=>Promise.resolve(e),doUnwrap(){return{ok:!0,value:e}},serialize:()=>({toJSON:()=>i({_tag:`Ok`,value:e})??`{}`,toYAML:()=>`_tag: Ok\nvalue: ${i(e)??`undefined`}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Ok`,value:e})).toString(`base64`)}),pipe:e=>e(r)};return r},$e=()=>{let e=new AbortController,t=ce();return{token:{get isCancelled(){return e.signal.aborted},get signal(){return e.signal},onCancel(n){e.signal.aborted?n():t.add(n)}},cancel(){e.signal.aborted||(e.abort(),t.build().forEach(e=>{try{e()}catch(e){console.error(`Error in cancellation callback:`,e)}}))}}},et=e=>{let t=e?.name??`Task`,n=e?.description??``,r={Async:(e,r=e=>e,i=()=>{},a)=>Xe((o,s)=>{(async()=>{let s=_(!1),c=_(null),l=_(()=>{});if(a){if(a.isCancelled){try{await i()}catch(e){o(k(e,void 0,{name:t,description:n}));return}o(k(Error(`Task was cancelled before execution started`),void 0,{name:t,description:n}));return}a.onCancel(()=>{s.set(!0),c.set(Error(`Task was cancelled during execution`))}),l.set(()=>{})}try{let r=await e();try{await i()}catch(e){o(k(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(k(c.get(),void 0,{name:t,description:n})):o(k(Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}if(r&&typeof r==`object`&&`_tag`in r){let e=r;e._tag===`Ok`||e._tag===`Err`?o(e):o(A(r,{name:t,description:n}))}else o(A(r,{name:t,description:n}))}catch(e){try{await i()}catch(e){o(k(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(k(c.get(),void 0,{name:t,description:n})):o(k(Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}try{if(e instanceof Error&&Ze(e)){let i=Error(`${t}: ${e.message}`),a=Je.apply(i,void 0,{name:t,description:n});Object.defineProperty(a,`cause`,{value:e,writable:!1,configurable:!1}),Promise.resolve().then(()=>{try{r(e)}catch(e){console.error(`Error in error handler:`,e)}}),o(k(a,void 0,{name:t,description:n}))}else{let i=await r(e);if(i&&typeof i==`object`&&`_tag`in i){let e=i;e._tag===`Ok`||e._tag===`Err`?o(e):o(k(i,void 0,{name:t,description:n}))}else o(k(i,void 0,{name:t,description:n}))}}catch(e){o(k(e,void 0,{name:t,description:n}))}}finally{l.get()()}})().catch(e=>o(k(e,void 0,{name:t,description:n})))}),Sync:(e,r=e=>e,i=()=>{})=>{try{return A(e(),{name:t,description:n})}catch(e){return k(r(e),void 0,{name:t,description:n})}finally{i()}},AsyncWithProgress:(e,t,n=e=>e,i=()=>{},a)=>{let o=e=>{let n=Math.max(0,Math.min(100,e));n<=100&&t(n)};return r.Async(()=>e(o),n,i,a)}};return{...Ke(`Task`,r),_type:`Task`}},tt={success:(e,t)=>A(e,t),fail:(e,t,n)=>k(e,t,n),ok:(e,t)=>A(e,t),err:(e,t,n)=>k(e,t,n),fromEither:(e,t)=>Qe(e,t),fromTry:(e,t)=>e.isSuccess()?A(e.orThrow(),t):k(e.fold(e=>e,()=>Error(`Unexpected success`)),void 0,t),getErrorChain:e=>{if(!e)return[];let t=ce();t.add(e);let n=_(e);for(;n.get()&&n.get().cause;){let{cause:e}=n.get();if(e)t.add(e),n.set(e);else break;if(t.size()>100)break}return t.build()},formatErrorChain:(e,t)=>{let n=tt.getErrorChain(e),r=t?.separator??`
8
+ `),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)throw Error(`Invalid YAML format for Either`);let i=JSON.parse(r);return n===`Right`?C(i):w(i)},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return Ee.fromJSON(t)}},De=t(Te,Ee);function T(t,n){return{brand:t,validate:n,of:r=>n(r)?m(e(t,r)):m.none(),from:r=>n(r)?C(e(t,r)):w(`Invalid ${t}: validation failed`),unsafeOf:r=>{if(!n(r))throw Error(`Invalid ${t}: validation failed`);return e(t,r)},is:e=>{try{return n(e)}catch{return!1}},unwrap:e=>e,refine:(e,t)=>T(e,e=>n(e)&&t(e))}}const Oe=T(`PositiveNumber`,e=>e>0),ke=T(`NonNegativeNumber`,e=>e>=0),Ae=T(`IntegerNumber`,e=>Number.isInteger(e)),je=Oe.refine(`PositiveInteger`,e=>Number.isInteger(e)),Me=T(`NonEmptyString`,e=>e.length>0),Ne=T(`EmailAddress`,e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)),Pe=T(`UrlString`,e=>{try{return new URL(e),!0}catch{return!1}}),Fe=T(`UUID`,e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)),Ie=T(`ISO8601Date`,e=>!isNaN(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(e));function Le(e,t,n){return T(e,e=>e>=t&&e<=n)}function Re(e,t,n){return T(e,e=>e.length>=t&&e.length<=n)}function ze(e,t){return T(e,e=>t.test(e))}const Be=e=>typeof e==`function`&&Object.keys(e).length>0,Ve=e=>{let t=e=>typeof e==`function`?e():e,n={when:(r,i)=>e.resolved?n:r?Ve({resolved:!0,value:t(i)}):n,elseWhen:(r,i)=>e.resolved?n:r?Ve({resolved:!0,value:t(i)}):n,else:n=>e.resolved?e.value:t(n),orThrow:()=>{if(!e.resolved)throw Error(`Conditional expression has no matching condition`);return e.value}};return n},He=()=>Ve({resolved:!1}),Ue=t(He,{of:()=>He(),match:e=>t=>{let n=t[e];if(n===void 0)throw Error(`No case defined for value: ${String(e)}`);return typeof n==`function`?n():n},lazy:()=>{let e={resolved:!1},t={when:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),elseWhen:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),else:t=>e.resolved?e.value:t()};return t}}),E=(e,t)=>t===e?!0:typeof t==`function`?t(e):t&&typeof t==`object`&&`_`in t?t._(e):typeof t==`object`&&t&&typeof e==`object`&&e?Object.entries(t).every(([t,n])=>{let r=e[t];return E(r,n)}):!1,D=e=>{let t=(e,t)=>typeof e==`function`?e(t):e,n=()=>{for(let{pattern:n,result:r}of e.patterns)if(E(e.value,n))return{matched:!0,result:t(r,e.value)};return{matched:!1}},r={case:(n,i)=>e.resolved?r:E(e.value,n)?D({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]}):D({...e,patterns:[...e.patterns,{pattern:n,result:i}]}),caseValue:(t,n)=>{if(e.resolved)return r;if(e.value===t){let t=typeof n==`function`?n():n;return D({value:e.value,resolved:!0,result:t,patterns:[]})}return r},caseValues:(t,n)=>{if(e.resolved)return r;if(t.includes(e.value)){let t=typeof n==`function`?n():n;return D({value:e.value,resolved:!0,result:t,patterns:[]})}return r},when:(e,t)=>r.case(e,t),caseAny:(n,i)=>{if(e.resolved)return r;for(let r of n)if(E(e.value,r))return D({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]});return D({...e,patterns:[...e.patterns,...n.map(e=>({pattern:e,result:i}))]})},default:n=>e.resolved?e.result:t(n,e.value),exhaustive:()=>{if(e.resolved)return e.result;let t=n();if(!t.matched)throw Error(`Non-exhaustive match. No pattern matched value: ${JSON.stringify(e.value)}`);return t.result},orThrow:t=>{if(e.resolved)return e.result;let r=n();if(!r.matched)throw Error(t??`No matching pattern for value: ${JSON.stringify(e.value)}`);return r.result},toOption:()=>{if(e.resolved)return m(e.result);let t=n();return t.matched?m(t.result):m.none()}};return r},We=e=>{let t=(e,t)=>typeof e==`function`?e(t):e;return{case:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return E(e,n)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseValue:(t,n)=>D(e===t?{value:e,resolved:!0,result:typeof n==`function`?n():n,patterns:[]}:{value:e,resolved:!1,patterns:[]}),caseValues:(t,n)=>t.includes(e)?D({value:e,resolved:!0,result:typeof n==`function`?n():n,patterns:[]}):D({value:e,resolved:!1,patterns:[]}),when:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return n(e)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseAny:(n,r)=>{for(let i of n)if(E(e,i))return D({value:e,resolved:!0,result:t(r,e),patterns:n.map(e=>({pattern:e,result:r}))});return D({value:e,resolved:!1,patterns:n.map(e=>({pattern:e,result:r}))})}}},Ge=t(e=>We(e),{exhaustive:e=>t=>{let n=e[t];if(n===void 0)throw Error(`No case defined for value: ${String(t)}`);return n},partial:e=>({withDefault:t=>n=>{let r=e[n];return r===void 0?typeof t==`function`?t(n):t:typeof r==`function`?r(n):r}}),withGuards:e=>({withDefault:t=>n=>{for(let[t,r]of e)if(t(n))return typeof r==`function`?r(n):r;return typeof t==`function`?t(n):t}}),struct:()=>{let e=[],t={case:(n,r)=>(e.push({pattern:n,handler:r}),t),build:()=>t=>{for(let{pattern:n,handler:r}of e)if(E(t,n))return r(t);throw Error(`No matching pattern for value: ${JSON.stringify(t)}`)}};return t},builder:()=>{let e=[],t,n={case:(t,r)=>(e.push({pattern:t,result:r}),n),when:(t,r)=>(e.push({pattern:t,result:r}),n),default:n=>(t=n,{build:()=>n=>{for(let{pattern:t,result:r}of e)if(E(n,t))return typeof r==`function`?r(n):r;if(t!==void 0)return typeof t==`function`?t(n):t;throw Error(`No matching pattern for value: ${JSON.stringify(n)}`)}})};return n}});function Ke(e,t){return{...pe({_tag:e,impl:t}),toString(){return`${e}()`},doUnwrap(){if(`isSome`in t&&`isNone`in t){if(typeof t.isSome==`function`&&t.isSome()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isNone==`function`&&t.isNone())return{ok:!1,empty:!0}}if(`isLeft`in t&&`isRight`in t){if(typeof t.isRight==`function`&&t.isRight()&&`value`in t)return{ok:!0,value:t.value};if(typeof t.isLeft==`function`&&t.isLeft()&&`value`in t)return{ok:!1,empty:!1,error:t.value}}if(`isSuccess`in t&&`isFailure`in t){if(typeof t.isSuccess==`function`&&t.isSuccess()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isFailure==`function`&&t.isFailure()&&`getError`in t&&typeof t.getError==`function`)return{ok:!1,empty:!1,error:t.getError()}}if(`isEmpty`in t&&`head`in t){if(typeof t.isEmpty==`function`&&t.isEmpty())return{ok:!1,empty:!0};if(typeof t.head==`function`)return{ok:!0,value:t.head()};if(`head`in t)return{ok:!0,value:t.head}}return{ok:!0,value:t}}}}const qe=`Throwable`;var Je=class e extends Error{constructor(e,t){super(e,{cause:t?.cause}),this._tag=qe,this.name=t?.taskInfo?.name??qe,Object.defineProperties(this,{_tag:{value:qe,writable:!1,configurable:!1},data:{value:t?.data,writable:!1,configurable:!1},taskInfo:{value:t?.taskInfo,writable:!1,configurable:!1},name:{value:t?.taskInfo?.name??qe,writable:!1,configurable:!1}}),t?.cause&&Object.defineProperty(this,`cause`,{value:t.cause,writable:!1,configurable:!1}),t?.stack?this.stack=t.stack:Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static apply(t,n,r){if(t instanceof Error){let i=new e(t.message,{data:n,cause:t.cause??void 0,stack:t.stack??void 0,taskInfo:r});for(let e of Object.keys(t))if(!(e in i)){let n=i;n[e]=t[e]}return i}if(t&&typeof t==`object`){let i=t,a=new e(typeof i.message==`string`?i.message:typeof i.error==`string`?i.error:`Object error: ${JSON.stringify(i,Object.getOwnPropertyNames(i).filter(e=>i[e]!==void 0))}`,{data:n??i,taskInfo:r});for(let e of Object.keys(i))if(!(e in a)){let t=a;t[e]=i[e]}return a}if(typeof t==`function`){let i=t.name??`anonymous function`,a=t.toString().substring(0,100)+(t.toString().length>100?`...`:``);return new e(`Function error: ${i}`,{data:n??{functionType:typeof t,functionName:i,functionString:a},taskInfo:r})}let i=typeof t,a=t===null?`null`:t===void 0?`undefined`:String(t);if(i===`number`){let a=t;return new e(Number.isNaN(a)?`Number error: NaN`:Number.isFinite(a)?`Number error: ${a}`:`Number error: ${a>0?`Infinity`:`-Infinity`}`,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}if(i===`bigint`)return new e(`BigInt error: ${t}n`,{data:n??{errorType:i,errorValue:String(t),originalError:t},taskInfo:r});if(i===`boolean`)return new e(`Boolean error: ${t}`,{data:n??{errorType:i,errorValue:t,originalError:t},taskInfo:r});if(i===`symbol`){let a=t.description??`unnamed symbol`;return new e(`Symbol error: Symbol(${a})`,{data:n??{errorType:i,symbolDescription:a,originalError:t},taskInfo:r})}return new e(typeof t==`string`?t:`${i.charAt(0).toUpperCase()+i.slice(1)} error: ${a}`,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}};const O=e=>{let t=new Promise((t,n)=>{try{e(t,n)}catch(e){n(e)}});return{_tag:`FPromise`,map:e=>O((n,r)=>{t.then(t=>{try{n(e(t))}catch(e){r(e)}}).catch(r)}),flatMap:e=>O((n,r)=>{t.then(t=>{try{let i=e(t);`_tag`in i&&i._tag===`FPromise`?i.then(n,r):Promise.resolve(i).then(n,r)}catch(e){r(e)}}).catch(r)}),flatMapAsync:async e=>{let n=e(await t);return n instanceof Promise?n:new Promise((e,t)=>{n.then(e,t)})},tap:e=>O((n,r)=>{t.then(t=>{try{e(t),n(t)}catch(e){r(e)}}).catch(r)}),mapError:e=>O((n,r)=>{t.then(n).catch(t=>{try{r(e(t,{originalError:t,stack:t instanceof Error?t.stack:void 0,timestamp:Date.now()}))}catch(e){r(e)}})}),tapError:e=>O((n,r)=>{t.then(n).catch(t=>{try{e(t),r(t)}catch(e){r(e)}})}),recover:e=>O(n=>{t.then(n).catch(()=>n(e))}),recoverWith:e=>O(n=>{t.then(n).catch(t=>{try{n(e(t))}catch{n(null)}})}),recoverWithF:e=>O((n,r)=>{t.then(n).catch(t=>{try{e(t).then(n,r)}catch(e){r(e)}})}),filterError:(e,n)=>O((r,i)=>{t.then(r).catch(t=>{if(e(t))try{n(t).then(r,i)}catch(e){i(e)}else i(t)})}),logError:e=>O((n,r)=>{t.then(n).catch(t=>{try{e(t,{originalError:t,stack:t instanceof Error?t.stack:void 0,timestamp:Date.now()})}catch{}finally{r(t)}})}),then:(e,n)=>t.then(e,n),toPromise:()=>t,toEither:async()=>{try{return C(await t)}catch(e){return w(e)}},fold:(e,n)=>O((r,i)=>{t.then(e=>{try{r(n(e))}catch(e){i(e)}}).catch(t=>{try{r(e(t))}catch(e){i(e)}})})}},Ye={resolve:e=>O(t=>t(e)),reject:e=>O((t,n)=>n(e)),from:e=>O((t,n)=>{e.then(t).catch(n)}),fromEither:e=>e.isRight()?O(t=>t(e.value)):O((t,n)=>n(e.value)),all:e=>O((t,n)=>{Promise.all(e.map(e=>e instanceof Promise?e:Promise.resolve(e))).then(t).catch(n)}),allSettled:e=>O(t=>{let n=[],r=0;if(e.length===0){t([]);return}e.forEach((i,a)=>{Promise.resolve(i).then(i=>{n[a]=C(i),r++,r===e.length&&t(n)}).catch(i=>{n[a]=w(i),r++,r===e.length&&t(n)})})}),race:e=>O((t,n)=>{Promise.race(e).then(t,n)}),any:e=>O((t,n)=>{if(typeof Promise.any==`function`)Promise.any(e).then(t,n);else{let r=0,i=[];if(e.length===0){n(AggregateError([],`All promises were rejected`));return}e.forEach((a,o)=>{Promise.resolve(a).then(t).catch(t=>{i[o]=t,r++,r===e.length&&n(AggregateError(i,`All promises were rejected`))})})}}),retryWithBackoff:(e,t)=>{let{maxRetries:n,baseDelay:r=100,shouldRetry:i=()=>!0}=t;return O((t,a)=>{let o=0,s=()=>{e().toPromise().then(t).catch(e=>{if(o++,o<=n&&i(e,o)){let e=r*2**(o-1);setTimeout(s,e)}else a(e)})};s()})}},Xe=t(O,Ye);function Ze(e){return e instanceof Error&&typeof e==`object`&&e._tag===`Throwable`}const Qe=(e,t)=>{if(e.isRight())return A(e.orThrow(),t);if(e.isLeft())return k(e.fold(e=>e,()=>Error(`Unexpected right value`)),void 0,t);throw Error(`Unrecognized task outcome`)},k=(e,t,n)=>{let r={name:n?.name??`Task`,description:n?.description??``},a=Je.apply(e,t,r),o={...Ke(`Err`,{error:a,meta:r}),_tag:`Err`,_meta:r,value:void 0,error:a,isSuccess(){return!1},isFailure(){return!0},isOk(){return!1},isErr(){return!0},map:e=>k(a,t,n),flatMap:e=>k(a,t,n),ap:e=>k(a,t,n),mapAsync:e=>Promise.resolve(k(a,t,n)),flatMapAsync:e=>Promise.resolve(k(a,t,n)),mapError:e=>k(e(a),t,n),recover:e=>A(e,n),recoverWith:e=>A(e(a),n),orThrow:e=>{throw e??a},orElse:e=>e,or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:()=>w(a),toTry:()=>b(()=>{throw a}),toOption:()=>p(),toList:()=>S([]),fold:(e,t)=>e(a),match:e=>e.Err(a),foldLeft:e=>t=>e,foldRight:e=>t=>e,size:0,isEmpty:!0,contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce empty Err`)},reduceRight:e=>{throw Error(`Cannot reduceRight empty Err`)},count:e=>0,find:e=>p(),exists:e=>!1,forEach:e=>{},toPromise:()=>Promise.reject(a),doUnwrap(){return{ok:!1,empty:!1,error:a}},serialize:()=>({toJSON:()=>i({_tag:`Err`,error:a.message??a.toString()})??`{}`,toYAML:()=>`_tag: Err\nerror: ${a.message??a.toString()}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Err`,error:a.message??a.toString()})).toString(`base64`)}),pipe:e=>e(o)};return o},A=(e,t)=>{let n={name:t?.name??`Task`,description:t?.description??``},r={...Ke(`Ok`,{value:e,meta:n}),_tag:`Ok`,_meta:n,value:e,error:void 0,isSuccess(){return!0},isFailure(){return!1},isOk(){return!0},isErr(){return!1},map:n=>A(n(e),t),flatMap:n=>{let r=n(e);return r&&typeof r==`object`&&`isLeft`in r&&`isRight`in r?Qe(r,t):r},ap:n=>n.isOk()?A(n.value(e),t):k(n.error,void 0,t),mapAsync:async n=>A(await n(e),t),flatMapAsync:async t=>await t(e),mapError:n=>A(e,t),recover:n=>A(e,t),recoverWith:n=>A(e,t),orThrow:t=>e,orElse:t=>e,or:n=>A(e,t),orNull:()=>e,orUndefined:()=>e,toEither:()=>C(e),toTry:()=>b(()=>e),toOption:()=>d(e),toList:()=>S([e]),fold:(t,n)=>n(e),match:t=>t.Ok(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),size:1,isEmpty:!1,contains:t=>e===t,reduce:t=>e,reduceRight:t=>e,count:t=>t(e)?1:0,find:t=>t(e)?d(e):p(),exists:t=>t(e),forEach:t=>t(e),toPromise:()=>Promise.resolve(e),doUnwrap(){return{ok:!0,value:e}},serialize:()=>({toJSON:()=>i({_tag:`Ok`,value:e})??`{}`,toYAML:()=>`_tag: Ok\nvalue: ${i(e)??`undefined`}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Ok`,value:e})).toString(`base64`)}),pipe:e=>e(r)};return r},$e=()=>{let e=new AbortController,t=ce();return{token:{get isCancelled(){return e.signal.aborted},get signal(){return e.signal},onCancel(n){e.signal.aborted?n():t.add(n)}},cancel(){e.signal.aborted||(e.abort(),t.build().forEach(e=>{try{e()}catch(e){console.error(`Error in cancellation callback:`,e)}}))}}},et=e=>{let t=e?.name??`Task`,n=e?.description??``,r={Async:(e,r=e=>e,i=()=>{},a)=>Xe((o,s)=>{(async()=>{let s=_(!1),c=_(null),l=_(()=>{});if(a){if(a.isCancelled){try{await i()}catch(e){o(k(e,void 0,{name:t,description:n}));return}o(k(Error(`Task was cancelled before execution started`),void 0,{name:t,description:n}));return}a.onCancel(()=>{s.set(!0),c.set(Error(`Task was cancelled during execution`))}),l.set(()=>{})}try{let r=await e();try{await i()}catch(e){o(k(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(k(c.get(),void 0,{name:t,description:n})):o(k(Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}if(r&&typeof r==`object`&&`_tag`in r){let e=r;e._tag===`Ok`||e._tag===`Err`?o(e):o(A(r,{name:t,description:n}))}else o(A(r,{name:t,description:n}))}catch(e){try{await i()}catch(e){o(k(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(k(c.get(),void 0,{name:t,description:n})):o(k(Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}try{if(e instanceof Error&&Ze(e)){let i=Error(`${t}: ${e.message}`),a=Je.apply(i,void 0,{name:t,description:n});Object.defineProperty(a,`cause`,{value:e,writable:!1,configurable:!1}),Promise.resolve().then(()=>{try{r(e)}catch(e){console.error(`Error in error handler:`,e)}}),o(k(a,void 0,{name:t,description:n}))}else{let i=await r(e);if(i&&typeof i==`object`&&`_tag`in i){let e=i;e._tag===`Ok`||e._tag===`Err`?o(e):o(k(i,void 0,{name:t,description:n}))}else o(k(i,void 0,{name:t,description:n}))}}catch(e){o(k(e,void 0,{name:t,description:n}))}}finally{l.get()()}})().catch(e=>o(k(e,void 0,{name:t,description:n})))}),Sync:(e,r=e=>e,i=()=>{})=>{try{return A(e(),{name:t,description:n})}catch(e){return k(r(e),void 0,{name:t,description:n})}finally{i()}},AsyncWithProgress:(e,t,n=e=>e,i=()=>{},a)=>{let o=e=>{let n=Math.max(0,Math.min(100,e));n<=100&&t(n)};return r.Async(()=>e(o),n,i,a)}};return{...Ke(`Task`,r),_type:`Task`}},tt={success:(e,t)=>A(e,t),fail:(e,t,n)=>k(e,t,n),ok:(e,t)=>A(e,t),err:(e,t,n)=>k(e,t,n),fromEither:(e,t)=>Qe(e,t),fromTry:(e,t)=>e.isSuccess()?A(e.orThrow(),t):k(e.fold(e=>e,()=>Error(`Unexpected success`)),void 0,t),getErrorChain:e=>{if(!e)return[];let t=ce();t.add(e);let n=_(e);for(;n.get()&&n.get().cause;){let{cause:e}=n.get();if(e)t.add(e),n.set(e);else break;if(t.size()>100)break}return t.build()},formatErrorChain:(e,t)=>{let n=tt.getErrorChain(e),r=t?.separator??`
9
9
  `;return n.map((e,n)=>{if(!e)return`${n>0?`↳ `:``}Unknown error`;let{taskInfo:r}=e,i=t?.includeTasks&&r?.name?`[${r.name}] `:``,a=e.message??`No message`,o=_(`${n>0?`↳ `:``}${i}${a}`);return t?.includeStackTrace&&e.stack&&o.set(`${o.get()}\n${e.stack.split(`
10
10
  `).slice(1).join(`
11
11
  `)}`),o.get()}).join(r)},fromPromise:(e,t)=>(...n)=>j(t??{name:`PromiseTask`,description:`Task from Promise`}).Async(()=>e(...n),e=>e),toPromise:e=>new Promise((t,n)=>{e.isSuccess()?t(e.orThrow()):n(e.error)}),race:(e,t,n)=>j({name:n?.name??`TaskRace`,description:n?.description??`Race between multiple tasks`}).Async(async()=>{let n=ce();e.forEach(e=>n.add(e));let r=_(void 0);if(typeof t==`number`&&t>0){let e=Xe((e,n)=>{r.set(setTimeout(()=>{n(Error(`Task race timed out after ${t}ms`))},t))});n.add(e)}try{return await new Promise((e,t)=>{n.build().forEach(n=>{n.then(n=>{if(n&&typeof n==`object`&&`_tag`in n){let r=n;r._tag===`Ok`?e(r.orThrow()):r._tag===`Err`?t(r.error):e(n)}else e(n)},e=>t(e))})})}finally{r.get()&&clearTimeout(r.get())}},e=>e),fromNodeCallback:(e,t)=>{let n={name:t?.name??`NodeCallbackTask`,description:t?.description??`Task from Node.js callback function`};return(...t)=>j(n).Async(()=>new Promise((n,r)=>{try{e(...t,(e,t)=>{e?r(e):n(t)})}catch(e){r(e)}}),e=>e)},createCancellationTokenSource:$e,cancellable:(e,t)=>{let n=$e();return{task:j(t).Async(()=>e(n.token),e=>e,()=>{},n.token),cancel:()=>n.cancel()}},withProgress:(e,t=()=>{},n)=>{let r=$e(),i=_(0),a=e=>{i.set(Math.max(0,Math.min(100,e))),t(i.get())};return{task:j(n).Async(()=>e(a,r.token),e=>e,()=>{},r.token),cancel:()=>r.cancel(),currentProgress:()=>i.get()}}},j=t(et,tt);function nt(e){if(!e||typeof e!=`object`||!(`_tag`in e))return`unknown`;switch(e._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`}}const rt={Option:{of:e=>m(e),empty:()=>m.none()},Either:{of:e=>C(e),empty:e=>w(e)},List:{of:e=>S([e]),empty:()=>S([])},Try:{of:e=>b(()=>e),empty:e=>b(()=>{throw e??Error(`Try failed`)})}};function it(e){let t=e(),n=null,r;function i(a){let o=t.next(a);if(o.done)return r?r.of(o.value):S([o.value]);let s=o.value;if(typeof s!=`object`||!s)throw 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(!n&&`_tag`in s&&(n=nt(s),n!==`unknown`&&n in rt&&(r=rt[n]),n===`List`))return at(e);if(`doUnwrap`in s){let e=s.doUnwrap();if(!e.ok){if(!r)return S([]);if(!e.empty&&`error`in e){if(n===`Either`)return r.empty(e.error);if(n===`Try`)return r.empty(e.error instanceof Error?e.error:Error(String(e.error)))}return r.empty()}return i(e.value)}throw 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 i()}function at(e){function t(e){if(typeof e!=`object`||!e||!(`doUnwrap`in e))return[e];let t=e;if(`toArray`in t){let e=t.toArray();return e.length===0?[]:e}let n=t.doUnwrap();return n.ok?[n.value]:[]}function n(r){let i=e(),a=[],o=[],s=0;function c(e){let l=i.next(e);if(l.done){a.push(l.value);return}if(s<r.length){let e=r[s];o.push(e),s++,c(e);return}let u=t(l.value);if(u.length!==0)if(u.length>1){let e=u.flatMap(e=>n([...o,e]));a.push(...e)}else o.push(u[0]),s++,c(u[0])}return c(void 0),a}return S(n([]))}async function ot(e){let t=e(),n=null,r;async function i(e){let a=await t.next(e);if(a.done)return r?r.of(a.value):S([a.value]);let o=await Promise.resolve(a.value);if(typeof o!=`object`||!o)return i(o);if(!n&&`_tag`in o&&(n=nt(o),n!==`unknown`&&n in rt&&(r=rt[n])),`doUnwrap`in o){let e=o.doUnwrap();if(!e.ok){if(!r)return S([]);if(!e.empty&&`error`in e){if(n===`Either`)return r.empty(e.error);if(n===`Try`)return r.empty(e.error instanceof Error?e.error:Error(String(e.error)))}return r.empty()}return i(e.value)}return i(o)}return i()}function st(e){return typeof e==`object`&&!!e&&`doUnwrap`in e&&typeof e.doUnwrap==`function`}function ct(e){let t=e.doUnwrap();if(t.ok)return t.value;throw`error`in t?t.error:Error(`Cannot unwrap empty monad`)}function*lt(e){return yield e}const ut=(e=`Cannot unwrap None in Do-notation`)=>{let t=Error(e),n=Object.create(Error.prototype);return n.message=t.message,n.stack=t.stack,n.name=`NoneError`,n},dt=(e,t=`Cannot unwrap Left in Do-notation`)=>{let n=Error(t),r=Object.create(Error.prototype);return r.message=n.message,r.stack=n.stack,r.name=`LeftError`,r.value=e,r},ft=(e=`Cannot unwrap empty List in Do-notation`)=>{let t=Error(e),n=Object.create(Error.prototype);return n.message=t.message,n.stack=t.stack,n.name=`EmptyListError`,n},pt=(e,t=`Cannot unwrap Failure in Do-notation`)=>{let n=Error(t),r=Object.create(Error.prototype);return r.message=n.message,r.stack=n.stack,r.name=`FailureError`,r.cause=e,r},mt={includeTasks:!0,includeStackTrace:!1,separator:`
@@ -1,2 +1,2 @@
1
- import { Fn as Try, In as TypeNames } from "../index-CrsC0sQU.js";
1
+ import { Fn as Try, In as TypeNames } from "../index-DKAUrDCz.js";
2
2
  export { Try, TypeNames };
package/dist/try/index.js CHANGED
@@ -1 +1 @@
1
- import{bt as e}from"../src-DtA8LBtt.js";export{e as Try};
1
+ import{bt as e}from"../src-BuPnddUO.js";export{e as Try};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "type": "module",
5
5
  "description": "A functional programming library for TypeScript, using immutable data structures and type classes",
6
6
  "author": "jordan.burke@gmail.com",