diff --git a/.github/actions/build-arch-package/dist/index.js b/.github/actions/build-arch-package/dist/index.js index fc187856..8495d33c 100644 --- a/.github/actions/build-arch-package/dist/index.js +++ b/.github/actions/build-arch-package/dist/index.js @@ -502,6 +502,33 @@ function makeCompareSet(equivalence) { var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth); var isEqual = (u) => hasProperty(u, symbol2); +// node_modules/effect/dist/internal/array.js +var isArrayNonEmpty = (self) => self.length > 0; + +// node_modules/effect/dist/internal/count.js +var normalize = (n) => n > 0 ? Math.floor(n) : 0; + +// node_modules/effect/dist/internal/record.js +function assignProperty(self, key, value) { + if (key === "__proto__") { + Object.defineProperty(self, key, { + value, + writable: true, + enumerable: true, + configurable: true + }); + } else { + self[key] = value; + } +} +function assignProperties(self, source) { + for (const key of Reflect.ownKeys(source)) { + if (Object.prototype.propertyIsEnumerable.call(source, key)) { + assignProperty(self, key, source[key]); + } + } +} + // node_modules/effect/dist/Redactable.js var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Redactable"); var isRedactable = (u) => hasProperty(u, symbolRedactable); @@ -744,27 +771,6 @@ var pickInternalCall = () => { }; var internalCall = /* @__PURE__ */ pickInternalCall(); -// node_modules/effect/dist/internal/record.js -function assignProperty(self, key, value) { - if (key === "__proto__") { - Object.defineProperty(self, key, { - value, - writable: true, - enumerable: true, - configurable: true - }); - } else { - self[key] = value; - } -} -function assignProperties(self, source) { - for (const key of Reflect.ownKeys(source)) { - if (Object.prototype.propertyIsEnumerable.call(source, key)) { - assignProperty(self, key, source[key]); - } - } -} - // node_modules/effect/dist/internal/core.js var EffectTypeId = `~effect/Effect`; var ExitTypeId = `~effect/Exit`; @@ -1133,12 +1139,6 @@ var done = (value) => { return exitFail(Done(value)); }; -// node_modules/effect/dist/Effectable.js -var Prototype2 = (options) => makePrimitiveProto({ - op: options.label, - [evaluate]: options.evaluate -}); - // node_modules/effect/dist/internal/option.js var TypeId = "~effect/Option"; var CommonProto = { @@ -1300,9 +1300,64 @@ var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone var fromNullishOr = (a) => a == null ? none2() : some2(a); var fromUndefinedOr = (a) => a === undefined ? none2() : some2(a); var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined); -var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value))); var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value)); -var filter = /* @__PURE__ */ dual(2, (self, predicate) => isNone2(self) ? none2() : predicate(self.value) ? some2(self.value) : none2()); + +// node_modules/effect/dist/Result.js +var succeed2 = succeed; +var fail2 = fail; +var isResult2 = isResult; +var isFailure2 = isFailure; +var isSuccess2 = isSuccess; +var match2 = /* @__PURE__ */ dual(2, (self, { + onFailure, + onSuccess +}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); + +// node_modules/effect/dist/Iterable.js +var headUnsafe = (self) => { + const iterator = self[Symbol.iterator](); + const result = iterator.next(); + if (result.done) + throw new Error("headUnsafe: empty iterable"); + return result.value; +}; +var constEmpty = { + [Symbol.iterator]() { + return constEmptyIterator; + } +}; +var constEmptyIterator = { + next() { + return { + done: true, + value: undefined + }; + } +}; + +// node_modules/effect/dist/Array.js +var Array2 = globalThis.Array; +var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); +var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); +var isArray = Array2.isArray; +var isArrayNonEmpty2 = isArrayNonEmpty; +var isReadonlyArrayNonEmpty = isArrayNonEmpty; +var empty = () => []; +var of = (a) => [a]; +var map = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); +// node_modules/effect/dist/BigInt.js +var BigInt2 = globalThis.BigInt; +var toNumber = (b) => { + if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { + return none2(); + } + return some2(Number(b)); +}; +// node_modules/effect/dist/Effectable.js +var Prototype2 = (options) => makePrimitiveProto({ + op: options.label, + [evaluate]: options.evaluate +}); // node_modules/effect/dist/Context.js var ServiceTypeId = "~effect/Context/Service"; @@ -1443,7 +1498,7 @@ var Proto = { var hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot; var isContext = (u) => hasProperty(u, TypeId3); var isReference = (u) => !!u[ReferenceTypeId]; -var empty = () => emptyContext2; +var empty2 = () => emptyContext2; var emptyContext2 = /* @__PURE__ */ makeUnsafe(/* @__PURE__ */ new Map); var make2 = (key, service) => makeUnsafe(new Map([[key.key, service]])); var add = /* @__PURE__ */ dual(3, (self, key, service) => addUnsafe(self, key.key, service)); @@ -1517,6 +1572,7 @@ var mergeAll = (...ctxs) => { return makeUnsafe(map); }; var Reference = Service; + // node_modules/effect/dist/Duration.js var TypeId4 = "~effect/Duration"; var bigint0 = /* @__PURE__ */ BigInt(0); @@ -1740,7 +1796,7 @@ var minutes = (minutes) => make3(minutes * 60000); var hours = (hours) => make3(hours * 3600000); var days = (days) => make3(days * 86400000); var weeks = (weeks) => make3(weeks * 604800000); -var toMillis = (self) => match2(fromInputUnsafe(self), { +var toMillis = (self) => match3(fromInputUnsafe(self), { onMillis: identity, onNanos: (nanos) => Number(nanos) / 1e6, onInfinity: () => Infinity, @@ -1758,7 +1814,7 @@ var toNanosUnsafe = (input) => { return roundMillisToNanos(self.value.millis); } }; -var match2 = /* @__PURE__ */ dual(2, (self, options) => { +var match3 = /* @__PURE__ */ dual(2, (self, options) => { switch (self.value._tag) { case "Millis": return options.onMillis(self.value.millis); @@ -1785,55 +1841,6 @@ var Equivalence = (self, that) => matchPair(self, that, { onInfinity: (self, that) => self.value._tag === that.value._tag }); var equals2 = /* @__PURE__ */ dual(2, (self, that) => Equivalence(self, that)); -// node_modules/effect/dist/internal/array.js -var isArrayNonEmpty = (self) => self.length > 0; - -// node_modules/effect/dist/internal/count.js -var normalize = (n) => n > 0 ? Math.floor(n) : 0; - -// node_modules/effect/dist/Result.js -var succeed2 = succeed; -var fail2 = fail; -var isResult2 = isResult; -var isFailure2 = isFailure; -var isSuccess2 = isSuccess; -var match3 = /* @__PURE__ */ dual(2, (self, { - onFailure, - onSuccess -}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); - -// node_modules/effect/dist/Iterable.js -var headUnsafe = (self) => { - const iterator = self[Symbol.iterator](); - const result = iterator.next(); - if (result.done) - throw new Error("headUnsafe: empty iterable"); - return result.value; -}; -var constEmpty = { - [Symbol.iterator]() { - return constEmptyIterator; - } -}; -var constEmptyIterator = { - next() { - return { - done: true, - value: undefined - }; - } -}; - -// node_modules/effect/dist/Array.js -var Array2 = globalThis.Array; -var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); -var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); -var isArray = Array2.isArray; -var isArrayNonEmpty2 = isArrayNonEmpty; -var isReadonlyArrayNonEmpty = isArrayNonEmpty; -var empty2 = () => []; -var of = (a) => [a]; -var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); // node_modules/effect/dist/Scheduler.js var Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", { @@ -2581,7 +2588,7 @@ class FiberImpl { } this._stack.length = 0; this._children = undefined; - this.context = empty(); + this.context = empty2(); } runLoop(effect) { const prevFiber = globalThis[currentFiberTypeId]; @@ -2769,7 +2776,7 @@ var fiberInterruptAs = /* @__PURE__ */ dual((args) => hasProperty(args[0], Fiber })); var fiberInterruptAll = (fibers) => withFiber((parent) => { const annotations = fiberStackAnnotations(parent); - let fiberArr = empty2(); + let fiberArr = empty(); for (const fiber of fibers) { fiber.interruptUnsafe(parent.id, annotations); fiberArr.push(fiber); @@ -2793,7 +2800,7 @@ var suspend = /* @__PURE__ */ makePrimitive({ return this[args](); } }); -var fromResult = /* @__PURE__ */ match3({ +var fromResult = /* @__PURE__ */ match2({ onFailure: fail3, onSuccess: succeed3 }); @@ -3086,7 +3093,7 @@ var tapCont = function(value) { var tapEffectCont = function(value) { return new ContImpl(this.payload, returnPayload, exitSucceed(value)); }; -var asSome = (self) => map4(self, some2); +var asSome = (self) => map3(self, some2); var andThen = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? returnPayload : andThenCont, f)); var tap = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? tapEffectCont : tapCont, f)); var asVoid = (self) => new ContImpl(self, returnPayload, exitVoid); @@ -3128,8 +3135,8 @@ var flatMapEager = /* @__PURE__ */ dual(2, (self, f) => { } return flatMap2(self, f); }); -var map4 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); -var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map4(self, f)); +var map3 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); +var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map3(self, f)); var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError(self, f)); var exitInterrupt = (fiberId) => exitFailCause(causeInterrupt(fiberId)); var exitIsSuccess = (self) => self._tag === "Success"; @@ -3505,7 +3512,7 @@ var all = (arg, options) => { } return suspend(() => { const out = {}; - return as(forEach(Object.entries(arg), ([key, effect]) => map4(options?.mode === "result" ? result(effect) : effect, (value) => { + return as(forEach(Object.entries(arg), ([key, effect]) => map3(options?.mode === "result" ? result(effect) : effect, (value) => { assignProperty(out, key, value); }), { discard: true, @@ -3785,7 +3792,7 @@ var fiberRunIn = /* @__PURE__ */ dual(2, (self, scope) => { self.addObserver(() => scopeRemoveFinalizerUnsafe(scope, key)); return self; }); -var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty()); +var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty2()); var runSyncExitWith = (context) => { const runFork = runForkWith(context); return (effect) => { @@ -3799,7 +3806,7 @@ var runSyncExitWith = (context) => { return fiber._exit ?? exitDie(new AsyncFiberError(fiber)); }; }; -var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty()); +var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty2()); var succeedTrue = /* @__PURE__ */ succeed3(true); var succeedFalse = /* @__PURE__ */ succeed3(false); @@ -3921,7 +3928,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = noopSpan({ name, parent, - annotations: add(options?.annotations ?? empty(), DisablePropagation, true) + annotations: add(options?.annotations ?? empty2(), DisablePropagation, true) }); } else { const tracer = fiber.getRef(Tracer); @@ -3934,7 +3941,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = tracer.span({ name, parent, - annotations: options?.annotations ?? empty(), + annotations: options?.annotations ?? empty2(), links, startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : bigint02, kind: options?.kind ?? "internal", @@ -4223,10 +4230,24 @@ function interruptChildrenPatch() { fiberMiddleware.interruptChildren ??= fiberInterruptChildren; } +// node_modules/effect/dist/Cause.js +var isFailReason2 = isFailReason; +var fromReasons = causeFromReasons; +var fail4 = causeFail; +var die2 = causeDie; +var hasInterruptsOnly2 = hasInterruptsOnly; +var map4 = causeMap; +var squash = causeSquash; +var findError2 = findError; +var isDone2 = isDone; +var Done2 = Done; +var done2 = done; +var UnknownError2 = UnknownError; + // node_modules/effect/dist/Exit.js var succeed4 = exitSucceed; var failCause2 = exitFailCause; -var fail4 = exitFail; +var fail5 = exitFail; var void_2 = exitVoid; var isSuccess3 = exitIsSuccess; var isFailure3 = exitIsFailure; @@ -4263,8 +4284,8 @@ var _await = (self) => callback((resume) => { }); }); var completeWith = /* @__PURE__ */ dual(2, (self, effect) => sync(() => doneUnsafe(self, effect))); -var done2 = completeWith; -var isDone2 = (self) => sync(() => isDoneUnsafe(self)); +var done3 = completeWith; +var isDone3 = (self) => sync(() => isDoneUnsafe(self)); var isDoneUnsafe = (self) => self.effect !== undefined; var doneUnsafe = (self, effect) => { if (self.effect) @@ -4337,7 +4358,7 @@ var memoMapBuild = (memoMap, layer, scope, build) => { memoMap.map.set(layer, entry); return scopeAddFinalizerExit(scope, entry.finalizer).pipe(flatMap2(() => build(memoMap, layerScope)), onExit((exit) => { entry.effect = exit; - return done2(deferred, exit); + return done3(deferred, exit); })); }; @@ -4375,7 +4396,7 @@ class CurrentMemoMap extends (/* @__PURE__ */ Service()("effect/Layer/CurrentMem return current ? forkMemoMapUnsafe(current) : makeMemoMapUnsafe(); } } -var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map4(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); +var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map3(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); var buildWithScope = /* @__PURE__ */ dual(2, (self, scope) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope))); var succeed5 = function() { if (arguments.length === 1) { @@ -4397,32 +4418,19 @@ var effect = function() { } return effectImpl(arguments[0], arguments[1]); }; -var effectImpl = (service, effect) => effectContext(map4(effect, (value) => make2(service, value))); +var effectImpl = (service, effect) => effectContext(map3(effect, (value) => make2(service, value))); var effectContext = (effect) => fromBuildMemo((_, scope) => provide(effect, scope)); var mergeAllEffect = (layers, memoMap, scope) => { const parentScope = forkUnsafe2(scope, "parallel"); return forEach(layers, (layer) => layer.build(memoMap, forkUnsafe2(parentScope, "sequential")), { concurrency: layers.length - }).pipe(map4((context) => mergeAll(...context))); + }).pipe(map3((context) => mergeAll(...context))); }; var mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope)); -var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map4((merged) => f(merged, context))))); +var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map3((merged) => f(merged, context))))); var provide2 = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, identity)); var provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self))); -// node_modules/effect/dist/Cause.js -var isFailReason2 = isFailReason; -var fromReasons = causeFromReasons; -var fail5 = causeFail; -var hasInterruptsOnly2 = hasInterruptsOnly; -var map5 = causeMap; -var squash = causeSquash; -var findError2 = findError; -var isDone3 = isDone; -var Done2 = Done; -var done3 = done; -var UnknownError2 = UnknownError; - // node_modules/effect/dist/internal/random.js var nextBetween = (min, max, draw) => { const value = draw * (max - min) + min; @@ -4442,7 +4450,7 @@ var nextBetween = (min, max, draw) => { // node_modules/effect/dist/Pull.js var catchDone = /* @__PURE__ */ dual(2, (effect, f) => catchCauseFilter(effect, filterDoneLeftover, (l) => f(l))); var isDoneCause = (cause) => cause.reasons.some(isDoneFailure); -var isDoneFailure = (failure) => failure._tag === "Fail" && isDone3(failure.error); +var isDoneFailure = (failure) => failure._tag === "Fail" && isDone2(failure.error); var filterDone = (cause) => { let done; let hasFailure = false; @@ -4484,7 +4492,6 @@ var forEach2 = forEach; var whileLoop2 = whileLoop; var tryPromise2 = tryPromise; var succeed6 = succeed3; -var succeedNone2 = succeedNone; var suspend2 = suspend; var sync3 = sync; var void_3 = void_; @@ -4494,7 +4501,7 @@ var gen2 = gen; var fail6 = fail3; var failCause3 = failCause; var failCauseSync2 = failCauseSync; -var die2 = die; +var die3 = die; var try_2 = try_; var yieldNow2 = yieldNow; var withFiber2 = withFiber; @@ -4503,7 +4510,7 @@ var flatMap3 = flatMap2; var andThen2 = andThen; var tap2 = tap; var exit2 = exit; -var map6 = map4; +var map5 = map3; var as2 = as; var catch_2 = catch_; var catchTag2 = catchTag; @@ -4550,3606 +4557,3026 @@ var effectify = (fn, onError, onSyncError) => (...args) => callback2((resume) => } }); } catch (err) { - resume(onSyncError ? fail6(onSyncError(err, args)) : die2(err)); + resume(onSyncError ? fail6(onSyncError(err, args)) : die3(err)); } }); var mapEager2 = mapEager; var mapErrorEager2 = mapErrorEager; var flatMapEager2 = flatMapEager; var fnUntracedEager2 = fnUntracedEager; -// node_modules/effect/dist/BigInt.js -var BigInt2 = globalThis.BigInt; -var toNumber = (b) => { - if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { - return none2(); + +// node_modules/effect/dist/internal/schema/annotations.js +function resolve(ast) { + return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; +} +var STRUCTURAL_ANNOTATION_KEY = "~structural"; +var SENTINELS_ANNOTATION_KEY = "~sentinels"; +var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; +var getExpected = /* @__PURE__ */ memoize((ast) => { + const identifier = resolve(ast)?.identifier; + if (typeof identifier === "string") + return identifier; + return ast.getExpected(getExpected); +}); + +// node_modules/effect/dist/internal/schema/parser.js +var missing = /* @__PURE__ */ Symbol(); +var succeed7 = succeed4; +var missingExit = /* @__PURE__ */ succeed7(missing); +var sameExit = /* @__PURE__ */ succeed7(missing); +var toOption = (value) => value === missing ? none2() : some2(value); +var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed7(option.value); + +// node_modules/effect/dist/SchemaIssue.js +var TypeId7 = "~effect/SchemaIssue/Issue"; +function isIssue(u) { + return hasProperty(u, TypeId7) && u[TypeId7] === TypeId7; +} +function hasInput(issue) { + return Object.hasOwn(issue, "input"); +} + +class IssueNodeImpl { + [TypeId7] = TypeId7; + constructor(input, options) { + if (options?.reportInput === true && input !== missing) { + this.input = input; + } + } +} +var Filter = class extends IssueNodeImpl { + _tag = "Filter"; + filter; + issue; + constructor(filter, issue, input, options) { + super(input, options); + this.filter = filter; + this.issue = issue; } - return some2(Number(b)); }; - -// node_modules/effect/dist/ByteSize.js -var bigint03 = /* @__PURE__ */ BigInt(0); -var bigint12 = /* @__PURE__ */ BigInt(1); -var decimalBase = /* @__PURE__ */ BigInt(1000); -var binaryBase = /* @__PURE__ */ BigInt(1024); -var decimalUnits = [{ - symbol: "B", - factor: bigint12, - names: ["B", "byte", "bytes"] -}, { - symbol: "kB", - factor: decimalBase, - names: ["kB", "kilobyte", "kilobytes"] -}, { - symbol: "MB", - factor: decimalBase ** /* @__PURE__ */ BigInt(2), - names: ["MB", "megabyte", "megabytes"] -}, { - symbol: "GB", - factor: decimalBase ** /* @__PURE__ */ BigInt(3), - names: ["GB", "gigabyte", "gigabytes"] -}, { - symbol: "TB", - factor: decimalBase ** /* @__PURE__ */ BigInt(4), - names: ["TB", "terabyte", "terabytes"] -}, { - symbol: "PB", - factor: decimalBase ** /* @__PURE__ */ BigInt(5), - names: ["PB", "petabyte", "petabytes"] -}, { - symbol: "EB", - factor: decimalBase ** /* @__PURE__ */ BigInt(6), - names: ["EB", "exabyte", "exabytes"] -}, { - symbol: "ZB", - factor: decimalBase ** /* @__PURE__ */ BigInt(7), - names: ["ZB", "zettabyte", "zettabytes"] -}, { - symbol: "YB", - factor: decimalBase ** /* @__PURE__ */ BigInt(8), - names: ["YB", "yottabyte", "yottabytes"] -}, { - symbol: "RB", - factor: decimalBase ** /* @__PURE__ */ BigInt(9), - names: ["RB", "ronnabyte", "ronnabytes"] -}, { - symbol: "QB", - factor: decimalBase ** /* @__PURE__ */ BigInt(10), - names: ["QB", "quettabyte", "quettabytes"] -}]; -var binaryUnits = [decimalUnits[0], { - symbol: "KiB", - factor: binaryBase, - names: ["KiB", "kibibyte", "kibibytes"] -}, { - symbol: "MiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(2), - names: ["MiB", "mebibyte", "mebibytes"] -}, { - symbol: "GiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(3), - names: ["GiB", "gibibyte", "gibibytes"] -}, { - symbol: "TiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(4), - names: ["TiB", "tebibyte", "tebibytes"] -}, { - symbol: "PiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(5), - names: ["PiB", "pebibyte", "pebibytes"] -}, { - symbol: "EiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(6), - names: ["EiB", "exbibyte", "exbibytes"] -}, { - symbol: "ZiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(7), - names: ["ZiB", "zebibyte", "zebibytes"] -}, { - symbol: "YiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(8), - names: ["YiB", "yobibyte", "yobibytes"] -}]; -var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; -var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); -var make5 = (value) => value; -var invalid2 = (message) => { - throw new Error(`Invalid ByteSize: ${message}`); +var Encoding = class extends IssueNodeImpl { + _tag = "Encoding"; + ast; + issue; + constructor(ast, issue, input, options) { + super(input, options); + this.ast = ast; + this.issue = issue; + } }; -var fromNumber = (input) => { - if (!Number.isSafeInteger(input) || input < 0) { - return invalid2(`expected a non-negative safe integer, received ${input}`); +var Pointer = class extends IssueNodeImpl { + _tag = "Pointer"; + path; + issue; + constructor(path, issue) { + super(); + this.path = path; + this.issue = issue; } - return make5(BigInt(input)); }; -var parse = (input) => { - const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); - if (match === null) - return invalid2(`unsupported syntax ${JSON.stringify(input)}`); - const unit = unitsByName.get(match[3]); - if (unit === undefined) - return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); - const fraction = match[2] ?? ""; - const scale = BigInt(10) ** BigInt(fraction.length); - const numerator = BigInt(match[1] + fraction) * unit.factor; - if (numerator % scale !== bigint03) { - return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); +var MissingKey = class extends IssueNodeImpl { + _tag = "MissingKey"; + annotations; + constructor(annotations) { + super(); + this.annotations = annotations; } - return make5(numerator / scale); }; -var fromInputUnsafe2 = (input) => { - switch (typeof input) { - case "bigint": - if (input < bigint03) - return invalid2(`expected a non-negative bigint, received ${input}`); - return make5(input); - case "number": - return fromNumber(input); - case "string": - return parse(input); +var UnexpectedKey = class extends IssueNodeImpl { + _tag = "UnexpectedKey"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; } - return invalid2(`unsupported input ${input}`); }; -var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); - -// node_modules/effect/dist/PlatformError.js -var TypeId7 = "~effect/PlatformError"; - -class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { - get message() { - return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; +var Composite = class extends IssueNodeImpl { + _tag = "Composite"; + ast; + issues; + constructor(ast, issues, input, options) { + super(input, options); + this.ast = ast; + this.issues = issues; + } +}; +var InvalidType = class extends IssueNodeImpl { + _tag = "InvalidType"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; + } +}; +var InvalidValue = class extends IssueNodeImpl { + _tag = "InvalidValue"; + annotations; + constructor(annotations, input, options) { + super(input, options); + this.annotations = annotations; + } +}; +var AnyOf = class extends IssueNodeImpl { + _tag = "AnyOf"; + ast; + issues; + constructor(ast, issues, input, options) { + super(input, options); + this.ast = ast; + this.issues = issues; + } +}; +var OneOf = class extends IssueNodeImpl { + _tag = "OneOf"; + ast; + successes; + constructor(ast, successes, input, options) { + super(input, options); + this.ast = ast; + this.successes = successes; } +}; +function makeFilterIssue(entry, input, options) { + if (isIssue(entry)) { + return entry; + } + if (typeof entry === "string") { + return new InvalidValue({ + message: entry + }, input, options); + } + const inner = typeof entry.issue === "string" ? new InvalidValue({ + message: entry.issue + }, input, options) : entry.issue; + return new Pointer(entry.path, inner); } - -class SystemError extends Error3 { - get message() { - return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; +function makeSingle(out, input, options) { + if (out === undefined) { + return; + } + if (typeof out === "boolean") { + return out ? undefined : new InvalidValue(undefined, input, options); } + return makeFilterIssue(out, input, options); } - -class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { - constructor(reason) { - if ("cause" in reason) { - super({ - reason, - cause: reason.cause - }); - } else { - super({ - reason - }); +function normalizeFilterOutput(ast, out, input, options) { + if (Array.isArray(out)) { + if (!isReadonlyArrayNonEmpty(out)) { + return; } + return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map(out, (entry) => makeFilterIssue(entry, input, options)), input, options); } - [TypeId7] = TypeId7; - get message() { - return this.reason.message; - } + return makeSingle(out, input, options); } -var systemError = (options) => new PlatformError(new SystemError(options)); -var badArgument = (options) => new PlatformError(new BadArgument(options)); - -// node_modules/effect/dist/Fiber.js -var join = fiberJoin; -var interrupt3 = fiberInterrupt; -var runIn = fiberRunIn; - -// node_modules/effect/dist/Latch.js -var makeUnsafe4 = makeLatchUnsafe; -var make6 = makeLatch; - -// node_modules/effect/dist/MutableRef.js -var TypeId8 = "~effect/MutableRef"; -var MutableRefProto = { - [TypeId8]: TypeId8, - ...PipeInspectableProto, - toJSON() { - return { - _id: "MutableRef", - current: toJson(this.current) - }; +var defaultLeafHook = (issue) => { + const message = findMessage(issue); + if (message !== undefined) + return message; + switch (issue._tag) { + case "InvalidType": + return getExpectedMessage(getExpected(issue.ast), issue); + case "InvalidValue": { + const expected = findExpected(issue); + if (expected !== undefined) + return getExpectedMessage(expected, issue); + const input = formatInput(issue); + return input === undefined ? "Expected a valid value" : `Invalid data ${input}`; + } + case "MissingKey": + return "Missing key"; + case "UnexpectedKey": { + const input = formatInput(issue); + return input === undefined ? "Expected no excess property" : `Unexpected key with value ${input}`; + } + case "Forbidden": + return "Forbidden operation"; + case "OneOf": { + const input = formatInput(issue); + return input === undefined ? "Expected exactly one member to match" : `Expected exactly one member to match the input ${input}`; + } } }; -var make7 = (value) => { - const ref = Object.create(MutableRefProto); - ref.current = value; - return ref; -}; - -// node_modules/effect/dist/MutableList.js -var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); -var make8 = () => ({ - head: undefined, - tail: undefined, - length: 0 -}); -var emptyBucket = () => ({ - array: [], - mutable: true, - offset: 0, - next: undefined -}); -var append2 = (self, message) => { - if (!self.tail) { - self.head = self.tail = emptyBucket(); - } else if (!self.tail.mutable) { - self.tail.next = emptyBucket(); - self.tail = self.tail.next; - } - self.tail.array.push(message); - self.length++; -}; -var clear = (self) => { - self.head = self.tail = undefined; - self.length = 0; -}; -var takeN = (self, n) => { - n = normalize(n); - if (n <= 0 || !self.head) - return []; - n = Math.min(n, self.length); - if (n === self.length && self.head?.offset === 0 && !self.head.next) { - const array = self.head.array; - clear(self); - return array; +var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue); +function formatInput(issue) { + return hasInput(issue) ? format(issue.input) : undefined; +} +function findExpected(issue) { + const expected = issue.annotations?.expected; + return typeof expected === "string" ? expected : undefined; +} +function getExpectedMessage(expected, issue) { + const input = formatInput(issue); + return input === undefined ? `Expected ${expected}` : `Expected ${expected}, got ${input}`; +} +function formatCheck(check) { + const expected = check.annotations?.expected; + if (typeof expected === "string") + return expected; + switch (check._tag) { + case "Filter": + return ""; + case "FilterGroup": + return check.checks.map((check) => formatCheck(check)).join(" & "); } - const array = new Array(n); - let index = 0; - let chunk = self.head; - while (chunk) { - while (chunk.offset < chunk.array.length) { - array[index++] = chunk.array[chunk.offset]; - if (chunk.mutable) - chunk.array[chunk.offset] = undefined; - chunk.offset++; - if (index === n) { - self.head = chunk; - self.length -= n; - if (self.length === 0) - clear(self); - return array; +} +function makeFormatterDefault() { + return (issue) => formatIssue(issue, ""); +} +var defaultFormatter = /* @__PURE__ */ makeFormatterDefault(); +function formatIssue(issue, path) { + let message; + switch (issue._tag) { + case "Filter": { + const annotated = defaultCheckHook(issue); + if (annotated !== undefined) { + message = annotated; + } else { + if (issue.issue._tag !== "InvalidValue") { + return formatIssue(issue.issue, path); + } + const expected = findExpected(issue.issue); + message = expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue); } + break; } - chunk = chunk.next; - } - clear(self); - return array; -}; -var take = (self) => { - if (!self.head) - return Empty; - const message = self.head.array[self.head.offset]; - if (self.head.mutable) - self.head.array[self.head.offset] = undefined; - self.head.offset++; - self.length--; - if (self.head.offset === self.head.array.length) { - if (self.head.next) { - self.head = self.head.next; - } else { - clear(self); + case "Encoding": + return formatIssue(issue.issue, path); + case "Pointer": + return formatIssue(issue.issue, path + formatPath(issue.path)); + case "Composite": + case "AnyOf": { + if (issue._tag === "Composite" || issue.issues.length > 0) { + return issue.issues.map((issue) => formatIssue(issue, path)).join(` +`); + } + message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue); + break; } + default: + message = defaultLeafHook(issue); + break; } - return message; -}; + return path ? `${message} + at ${path}` : message; +} +function findMessage(issue) { + if (issue._tag === "Pointer") + return; + if (issue._tag === "Encoding") + return findMessage(issue.issue); + const annotations = issue._tag === "Filter" ? issue.filter.annotations : ("annotations" in issue) ? issue.annotations : issue.ast.annotations; + const message = annotations?.[issue._tag === "MissingKey" ? "messageMissingKey" : issue._tag === "UnexpectedKey" ? "messageUnexpectedKey" : "message"]; + if (typeof message === "string") + return message; +} -// node_modules/effect/dist/Queue.js -var TypeId9 = "~effect/Queue"; -var EnqueueTypeId = "~effect/Queue/Enqueue"; -var DequeueTypeId = "~effect/Queue/Dequeue"; -var variance = { - _A: identity, - _E: identity -}; -var QueueProto = { - [TypeId9]: variance, - [EnqueueTypeId]: variance, - [DequeueTypeId]: variance, - ...PipeInspectableProto, - toJSON() { - return { - _id: "effect/Queue", - state: this.state._tag, - size: sizeUnsafe(this) - }; - } -}; -var make9 = (options) => withFiber((fiber) => { - const self = Object.create(QueueProto); - self.dispatcher = fiber.currentDispatcher; - self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; - self.strategy = options?.strategy ?? "suspend"; - self.messages = make8(); - self.scheduleRunning = false; - self.state = { - _tag: "Open", - takers: new Set, - offers: new Set, - awaiters: new Set - }; - return succeed3(self); -}); -var bounded = (capacity) => make9({ - capacity -}); -var offer = (self, message) => suspend(() => { - if (self.state._tag !== "Open") { - return exitFalse; - } else if (self.messages.length >= self.capacity) { - switch (self.strategy) { - case "dropping": - return exitFalse; - case "suspend": - if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return exitTrue; - } - return offerRemainingSingle(self, message); - case "sliding": - take(self.messages); - append2(self.messages, message); - return exitTrue; - } - } - append2(self.messages, message); - scheduleReleaseTaker(self); - return exitTrue; -}); -var offerUnsafe = (self, message) => { - if (self.state._tag !== "Open") { - return false; - } else if (self.messages.length >= self.capacity) { - if (self.strategy === "sliding") { - take(self.messages); - append2(self.messages, message); - return true; - } else if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return true; +// node_modules/effect/dist/internal/schema/cause.js +function getSchemaIssue(cause) { + let issue; + for (const reason of cause.reasons) { + if (!isFailReason2(reason) || !isIssue(reason.error)) { + return; } - return false; - } - append2(self.messages, message); - scheduleReleaseTaker(self); - return true; -}; -var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); -var failCauseUnsafe = (self, cause) => { - if (self.state._tag !== "Open") { - return false; - } - const exit = exitFailCause(cause); - const fail = exitZipRight(exit, exitFailDone); - if (self.state.offers.size === 0 && self.messages.length === 0) { - finalize(self, fail); - return true; + issue ??= reason.error; } - self.state = { - ...self.state, - _tag: "Closing", - exit: fail - }; - return true; -}; -var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); -var shutdown = (self) => sync(() => { - if (self.state._tag === "Done") { - return true; + return issue; +} +function getSchemaIssueOrThrow(cause, message) { + const issue = getSchemaIssue(cause); + if (issue === undefined) { + throw new Error(message, { + cause + }); } - clear(self.messages); - const offers = self.state.offers; - finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); - if (offers.size > 0) { - for (const entry of offers) { - if (entry._tag === "Single") { - entry.resume(exitFalse); - } else { - entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); - } - } - offers.clear(); - } - return true; + return issue; +} + +// node_modules/effect/dist/SchemaGetter.js +var makeGetter = (fields) => Object.assign(Object.create(Prototype), fields); +var passthrough_ = /* @__PURE__ */ makeGetter({ + _tag: "Passthrough" }); -var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); -var takeBetween = (self, min, max) => { - min = normalize(min); - max = normalize(max); - return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); +function passthrough() { + return passthrough_; +} +function transform(f) { + return makeGetter({ + _tag: "Transform", + transform: f + }); +} +function transformEffect(f) { + return makeGetter({ + _tag: "TransformEffect", + transform: f + }); +} +function String2() { + return transform(globalThis.String); +} +function Number3() { + return transform(globalThis.Number); +} +function parseJson(options) { + return transformEffect((input, parseOptions) => try_2({ + try: () => JSON.parse(input, options?.reviver), + catch: () => new InvalidValue({ + expected: "a valid JSON string" + }, input, parseOptions) + })); +} +function stringifyJson(options) { + return transformEffect((input, parseOptions) => try_2({ + try: () => { + const output = JSON.stringify(input, options?.replacer, options?.space); + if (output === undefined) { + throw new TypeError("Value cannot be represented as JSON"); + } + return output; + }, + catch: () => new InvalidValue({ + expected: "a JSON-serializable value" + }, input, parseOptions) + })); +} +function encodeBase642() { + return transform(encodeBase64); +} +function decodeBase642() { + return transformEffect((input, options) => mapErrorEager2(fromResult2(decodeBase64(input)), () => new InvalidValue({ + expected: "a valid Base64 string" + }, input, options))); +} + +// node_modules/effect/dist/ByteSize.js +var bigint03 = /* @__PURE__ */ BigInt(0); +var bigint12 = /* @__PURE__ */ BigInt(1); +var decimalBase = /* @__PURE__ */ BigInt(1000); +var binaryBase = /* @__PURE__ */ BigInt(1024); +var decimalUnits = [{ + symbol: "B", + factor: bigint12, + names: ["B", "byte", "bytes"] +}, { + symbol: "kB", + factor: decimalBase, + names: ["kB", "kilobyte", "kilobytes"] +}, { + symbol: "MB", + factor: decimalBase ** /* @__PURE__ */ BigInt(2), + names: ["MB", "megabyte", "megabytes"] +}, { + symbol: "GB", + factor: decimalBase ** /* @__PURE__ */ BigInt(3), + names: ["GB", "gigabyte", "gigabytes"] +}, { + symbol: "TB", + factor: decimalBase ** /* @__PURE__ */ BigInt(4), + names: ["TB", "terabyte", "terabytes"] +}, { + symbol: "PB", + factor: decimalBase ** /* @__PURE__ */ BigInt(5), + names: ["PB", "petabyte", "petabytes"] +}, { + symbol: "EB", + factor: decimalBase ** /* @__PURE__ */ BigInt(6), + names: ["EB", "exabyte", "exabytes"] +}, { + symbol: "ZB", + factor: decimalBase ** /* @__PURE__ */ BigInt(7), + names: ["ZB", "zettabyte", "zettabytes"] +}, { + symbol: "YB", + factor: decimalBase ** /* @__PURE__ */ BigInt(8), + names: ["YB", "yottabyte", "yottabytes"] +}, { + symbol: "RB", + factor: decimalBase ** /* @__PURE__ */ BigInt(9), + names: ["RB", "ronnabyte", "ronnabytes"] +}, { + symbol: "QB", + factor: decimalBase ** /* @__PURE__ */ BigInt(10), + names: ["QB", "quettabyte", "quettabytes"] +}]; +var binaryUnits = [decimalUnits[0], { + symbol: "KiB", + factor: binaryBase, + names: ["KiB", "kibibyte", "kibibytes"] +}, { + symbol: "MiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(2), + names: ["MiB", "mebibyte", "mebibytes"] +}, { + symbol: "GiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(3), + names: ["GiB", "gibibyte", "gibibytes"] +}, { + symbol: "TiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(4), + names: ["TiB", "tebibyte", "tebibytes"] +}, { + symbol: "PiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(5), + names: ["PiB", "pebibyte", "pebibytes"] +}, { + symbol: "EiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(6), + names: ["EiB", "exbibyte", "exbibytes"] +}, { + symbol: "ZiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(7), + names: ["ZiB", "zebibyte", "zebibytes"] +}, { + symbol: "YiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(8), + names: ["YiB", "yobibyte", "yobibytes"] +}]; +var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; +var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); +var make5 = (value) => value; +var invalid2 = (message) => { + throw new Error(`Invalid ByteSize: ${message}`); }; -var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); -var poll = (self) => suspend(() => { - const result = takeUnsafe(self); - if (result === undefined) { - return succeed3(none2()); - } - if (result._tag === "Success") { - return succeed3(some2(result.value)); - } - return succeed3(none2()); -}); -var takeUnsafe = (self) => { - if (self.state._tag === "Done") { - return self.state.exit; - } - if (self.messages.length > 0) { - const message = take(self.messages); - releaseCapacity(self); - return exitSucceed(message); - } else if (self.capacity <= 0 && self.state.offers.size > 0) { - const message = takeOfferUnsafe(self.state.offers); - releaseCapacity(self); - return exitSucceed(message); +var fromNumber = (input) => { + if (!Number.isSafeInteger(input) || input < 0) { + return invalid2(`expected a non-negative safe integer, received ${input}`); } - return; + return make5(BigInt(input)); }; -var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; -var exitFalse = /* @__PURE__ */ exitSucceed(false); -var exitTrue = /* @__PURE__ */ exitSucceed(true); -var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); -var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); -var releaseTakers = (self) => { - if (self.state._tag === "Done" || self.state.takers.size === 0) { - return; - } - for (const taker of self.state.takers) { - self.state.takers.delete(taker); - taker(exitVoid); - if (self.messages.length === 0) { - break; - } +var fromStringUnsafe = (input) => { + const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); + if (match === null) + return invalid2(`unsupported syntax ${JSON.stringify(input)}`); + const unit = unitsByName.get(match[3]); + if (unit === undefined) + return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); + const fraction = match[2] ?? ""; + const scale = BigInt(10) ** BigInt(fraction.length); + const numerator = BigInt(match[1] + fraction) * unit.factor; + if (numerator % scale !== bigint03) { + return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); } + return make5(numerator / scale); }; -var scheduleReleaseTaker = (self) => { - if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { - return; +var fromInputUnsafe2 = (input) => { + switch (typeof input) { + case "bigint": + if (input < bigint03) + return invalid2(`expected a non-negative bigint, received ${input}`); + return make5(input); + case "number": + return fromNumber(input); + case "string": + return fromStringUnsafe(input); } - self.scheduleRunning = true; - self.dispatcher.scheduleTask(() => { - self.scheduleRunning = false; - releaseTakers(self); - }, 0); + return invalid2(`unsupported input ${input}`); }; -var takeBetweenUnsafe = (self, min, max) => { - if (self.state._tag === "Done") { - return self.state.exit; - } else if (max <= 0 || min <= 0) { - return exitSucceed([]); - } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { - const messages = [takeOfferUnsafe(self.state.offers)]; - releaseCapacity(self); - return exitSucceed(messages); +var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); + +// node_modules/effect/dist/SchemaTransformation.js +var TypeId8 = "~effect/SchemaTransformation/Transformation"; +var Transformation = class extends Class { + [TypeId8] = TypeId8; + _tag = "Transformation"; + decode; + encode; + constructor(decode, encode) { + super(); + this.decode = decode; + this.encode = encode; } - min = Math.min(min, self.capacity || 1); - if (min <= self.messages.length) { - const messages = takeN(self.messages, max); - releaseCapacity(self); - return exitSucceed(messages); + flip() { + return new Transformation(this.encode, this.decode); } }; -var offerRemainingSingle = (self, message) => { - return callback((resume) => { - if (self.state._tag !== "Open") { - return resume(exitFalse); - } - const entry = { - _tag: "Single", - message, - resume - }; - self.state.offers.add(entry); - return sync(() => { - if (self.state._tag === "Open") { - self.state.offers.delete(entry); - } - }); - }); -}; -var takeOfferUnsafe = (offers) => { - const entry = offers.values().next().value; - if (entry._tag === "Single") { - offers.delete(entry); - entry.resume(exitTrue); - return entry.message; +function isTransformation(u) { + return hasProperty(u, TypeId8) && u[TypeId8] === TypeId8; +} +var makeTransformation = (options) => { + if (isTransformation(options)) { + return options; } - const message = entry.remaining[entry.offset++]; - if (entry.offset === entry.remaining.length) { - offers.delete(entry); - entry.resume(exitSucceed([])); + return new Transformation(options.decode, options.encode); +}; +function transformEffect2(options) { + return new Transformation(transformEffect(options.decode), transformEffect(options.encode)); +} +function transform2(options) { + return new Transformation(transform(options.decode), transform(options.encode)); +} +var passthrough_2 = /* @__PURE__ */ new Transformation(/* @__PURE__ */ passthrough(), /* @__PURE__ */ passthrough()); +function passthrough2() { + return passthrough_2; +} +var numberFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ String2()); +var isJsonError = (input) => isObject(input) && typeof input["message"] === "string"; +var decodeJsonError = (input) => { + const hasCause = Object.hasOwn(input, "cause"); + const err = hasCause ? new Error(input.message, { + cause: decodeDefect(input.cause) + }) : new Error(input.message); + if (typeof input.name === "string" && input.name !== "Error") + err.name = input.name; + if (typeof input.stack === "string") + err.stack = input.stack; + return err; +}; +var encodeUnknownAsJson = (input) => { + try { + const json = formatJson(input); + return json === undefined ? format(input) : JSON.parse(json); + } catch { + return format(input); } - return message; }; -var releaseCapacity = (self) => { - if (self.state._tag === "Done") { - return isDoneCause(self.state.exit.cause); - } else if (self.state.offers.size === 0) { - if (self.state._tag === "Closing" && self.messages.length === 0) { - finalize(self, self.state.exit); - return isDoneCause(self.state.exit.cause); - } - return false; +var encodeJsonError = (input, options, encodeDefect) => { + const encoded = { + name: input.name, + message: typeof input.message === "string" ? input.message : "" + }; + if (options?.includeStack && typeof input.stack === "string") { + encoded.stack = input.stack; } - for (const entry of self.state.offers) { - let n = self.capacity - self.messages.length; - if (n <= 0) - break; - else if (entry._tag === "Single") { - append2(self.messages, entry.message); - self.state.offers.delete(entry); - entry.resume(exitTrue); - } else { - for (;entry.offset < entry.remaining.length; entry.offset++) { - if (n === 0) - return false; - append2(self.messages, entry.remaining[entry.offset]); - n--; - } - self.state.offers.delete(entry); - entry.resume(exitSucceed([])); - } + if (!options?.excludeCause && input.cause !== undefined) { + encoded.cause = encodeDefect(input.cause); } - return false; + return encoded; }; -var awaitTake = (self) => callback((resume) => { - if (self.state._tag === "Done") { - return resume(self.state.exit); - } - self.state.takers.add(resume); - return sync(() => { - if (self.state._tag !== "Done") { - self.state.takers.delete(resume); +var makeEncodeDefect = (options) => { + const seen = new WeakSet; + const encode = (input) => { + if (isError(input)) { + if (seen.has(input)) { + return "[Circular]"; + } + seen.add(input); + const encoded = encodeJsonError(input, options, encode); + seen.delete(input); + return encoded; } - }); -}); -var finalize = (self, exit) => { - if (self.state._tag === "Done") { - return; - } - const openState = self.state; - self.state = { - _tag: "Done", - exit + return encodeUnknownAsJson(input); }; - for (const taker of openState.takers) { - taker(exit); + return encode; +}; +var decodeDefect = (input) => isJsonError(input) ? decodeJsonError(input) : input; +var defectFromJson = (options) => transform2({ + decode: decodeDefect, + encode: makeEncodeDefect(options) +}); +var urlFromString = /* @__PURE__ */ transformEffect2({ + decode: (s, options) => URL.canParse(s) ? succeed6(new URL(s)) : fail6(new InvalidValue({ + expected: "a valid URL string" + }, s, options)), + encode: (url) => succeed6(url.href) +}); +var uint8ArrayFromBase64String = /* @__PURE__ */ new Transformation(/* @__PURE__ */ decodeBase642(), /* @__PURE__ */ encodeBase642()); +function fromJsonString(options) { + return new Transformation(parseJson(options ?? {}), stringifyJson(options)); +} + +// node_modules/effect/dist/SchemaAST.js +function makeGuard(tag) { + return (ast) => ast._tag === tag; +} +var isDeclaration = /* @__PURE__ */ makeGuard("Declaration"); +var isNever2 = /* @__PURE__ */ makeGuard("Never"); +var isLiteral = /* @__PURE__ */ makeGuard("Literal"); +var isUniqueSymbol = /* @__PURE__ */ makeGuard("UniqueSymbol"); +var isArrays = /* @__PURE__ */ makeGuard("Arrays"); +var isObjects = /* @__PURE__ */ makeGuard("Objects"); +var isUnion = /* @__PURE__ */ makeGuard("Union"); +var isSuspend = /* @__PURE__ */ makeGuard("Suspend"); +var Link = class { + to; + transformation; + constructor(to, transformation) { + this.to = to; + this.transformation = transformation; } - openState.takers.clear(); - for (const awaiter of openState.awaiters) { - awaiter(exit); +}; +var defaultParseOptions = {}; +var Context = class { + isOptional; + isMutable; + constructorDefault; + annotations; + constructor(isOptional, isMutable, constructorDefault = undefined, annotations = undefined) { + this.isOptional = isOptional; + this.isMutable = isMutable; + this.constructorDefault = constructorDefault; + this.annotations = annotations; } - openState.awaiters.clear(); }; +var TypeId9 = "~effect/Schema"; -// node_modules/effect/dist/Semaphore.js -var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); -var waitForPermits = (self, n, effect) => callback((resume) => { - if (self.free >= n) - return resume(effect); - const observer = () => { - if (self.free < n) - return; - self.waiters.delete(observer); - resume(effect); - }; - self.waiters.add(observer); - return sync(() => { - self.waiters.delete(observer); - }); -}); - -class SemaphoreImpl { - waiters = /* @__PURE__ */ new Set; - taken = 0; - permits; - constructor(permits) { - this.permits = permits; +class ASTNodeImpl { + [TypeId9] = TypeId9; + annotations; + checks; + encoding; + context; + constructor(annotations = undefined, checks = undefined, encoding = undefined, context = undefined) { + this.annotations = annotations; + this.checks = checks; + this.encoding = encoding; + this.context = context; } - get free() { - return this.permits - this.taken; + toString() { + return `<${this._tag}>`; } - take(n) { - const take = suspend(() => { - if (this.free < n) { - return waitForPermits(this, n, take); - } - this.taken += n; - return succeed3(n); - }); - return take; +} +var Declaration = class extends ASTNodeImpl { + _tag = "Declaration"; + typeParameters; + run; + encodingChecks; + encodingRun; + constructor(typeParameters, run, annotations, checks, encoding, context, encodingChecks, encodingRun) { + super(annotations, checks, encoding, context); + this.typeParameters = typeParameters; + this.run = run; + this.encodingChecks = encodingChecks; + this.encodingRun = encodingRun; } - takeIfAvailable(n) { - return suspend(() => { - if (this.free < n) - return succeed3(false); - this.taken += n; - return succeed3(true); - }); + getParser() { + let run; + return (input, options) => { + if (input === missing) + return missingExit; + return (run ??= this.run(this.typeParameters))(input, this, options); + }; } - releaseUnsafe(fiber, n) { - this.taken -= n; - if (this.waiters.size > 0) { - fiber.currentDispatcher.scheduleTask(() => { - for (const observer of this.waiters) { - if (this.free <= 0) - break; - observer(); - } - }, 0); + _rebuild(recur, checks, encodingChecks, run, encodingRun) { + const tps = mapOrSame(this.typeParameters, recur); + return tps === this.typeParameters && checks === this.checks && encodingChecks === this.encodingChecks && run === this.run && encodingRun === this.encodingRun ? this : new Declaration(tps, run, this.annotations, checks, undefined, this.context, encodingChecks, encodingRun); + } + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks, this.run, this.encodingRun); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks, this.encodingRun ?? this.run, this.run); + } + getExpected() { + const expected = this.annotations?.expected; + if (typeof expected === "string") + return expected; + return ""; + } +}; +var Unknown = class extends ASTNodeImpl { + _tag = "Unknown"; + getParser() { + return fromRefinement(this, isUnknown); + } + getExpected() { + return "unknown"; + } +}; +var unknown = /* @__PURE__ */ new Unknown; +var Literal = class extends ASTNodeImpl { + _tag = "Literal"; + literal; + constructor(literal, annotations, checks, encoding, context) { + super(annotations, checks, encoding, context); + if (typeof literal === "number" && !globalThis.Number.isFinite(literal)) { + throw new Error(`A numeric literal must be finite, got ${format(literal)}`); } - return this.free; + this.literal = literal; } - resize(permits) { - return withFiber((fiber) => { - this.permits = permits; - if (this.free < 0) - return void_; - this.releaseUnsafe(fiber, 0); - return void_; - }); + getParser() { + return fromConst(this, this.literal); } - release(n) { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); + matchPart(s, _options) { + return s === globalThis.String(this.literal) ? this.literal : undefined; } - get releaseAll() { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); + toCodecJson() { + return typeof this.literal === "bigint" ? literalToString(this) : this; } - withPermits(n) { - return (self) => uninterruptibleMask((restore) => { - const acquire = suspend(() => { - if (this.free < n) { - const wait = waitForPermits(this, n, void_); - return flatMap2(restore(wait), () => acquire); - } - this.taken += n; - return onExitPrimitive(restore(self), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); - return acquire; - }); + toCodecStringTree() { + return typeof this.literal === "string" ? this : literalToString(this); } - withPermit = /* @__PURE__ */ this.withPermits(1); - withPermitsIfAvailable(n) { - return (self) => uninterruptibleMask((restore) => { - if (this.free < n) - return succeedNone; - this.taken += n; - return onExitPrimitive(restore(asSome(self)), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); + getExpected() { + return typeof this.literal === "string" ? JSON.stringify(this.literal) : globalThis.String(this.literal); } +}; +function literalToString(ast) { + const literalAsString = globalThis.String(ast.literal); + return replaceEncoding(ast, [new Link(new Literal(literalAsString), new Transformation(transform(() => ast.literal), transform(() => literalAsString)))]); } - -// node_modules/effect/dist/Channel.js -var TypeId10 = "~effect/Channel"; -var isChannel = (u) => hasProperty(u, TypeId10); -var ChannelProto = { - [TypeId10]: { - _Env: identity, - _InErr: identity, - _InElem: identity, - _OutErr: identity, - _OutElem: identity - }, - pipe() { - return pipeArguments(this, arguments); +var String3 = class extends ASTNodeImpl { + _tag = "String"; + getParser() { + return fromRefinement(this, isString); + } + matchPart(s, options) { + const checks = this.checks; + return checks && !options.disableChecks && collectIssues(checks, s, undefined, this, options) ? undefined : s; + } + getExpected() { + return "string"; } }; -var fromTransform = (transform) => { - const self = Object.create(ChannelProto); - self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); - return self; -}; -var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); -var fromPull = (effect) => fromTransform((_, __) => effect); -var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { - const closableScope = forkUnsafe2(scope); - const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); - const pull = yield* onError2(f(upstream, scope, closableScope), onCause); - return onError2(pull, onCause); -})); -var toTransform = (channel) => channel.transform; -var asyncQueue = (scope, f, options) => make9({ - capacity: options?.bufferSize, - strategy: options?.strategy -}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); -var callbackArray = (f, options) => fromTransform((_, scope) => map6(asyncQueue(scope, f, options), takeAll2)); -var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); -var succeed7 = (value) => fromEffect(succeed6(value)); -var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done3())); -var fail7 = (error) => fromPull(succeed6(fail6(error))); -var failCause5 = (cause) => fromPull(failCause3(cause)); -var fromEffect = (effect) => fromPull(sync3(() => { - let done = false; - return suspend2(() => { - if (done) - return done3(); - done = true; - return effect; - }); -})); -var fromEffectDrain = (effect) => fromPull(flatMap3(effect, () => done3())); -var map7 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { - let i = 0; - return map6(pull, (o) => f(o, i++)); -}))); -var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); -var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done3))))); -var concurrencyIsSequential = (concurrency) => concurrency === undefined || concurrency !== "unbounded" && concurrency <= 1; -var flatMap4 = /* @__PURE__ */ dual((args) => isChannel(args[0]), (self, f, options) => concurrencyIsSequential(options?.concurrency) ? flatMapSequential(self, f) : flatMapConcurrent(self, f, options)); -var flatMapSequential = (self, f) => fromTransform((upstream, scope) => map6(toTransform(self)(upstream, scope), (pull) => { - let childPull; - let childScope; - const makePull = flatMap3(pull, (value) => { - childScope ??= forkUnsafe2(scope); - return flatMapEager2(toTransform(f(value))(upstream, childScope), (pull) => { - childPull = catchHalt(pull); - return childPull; - }); - }); - const catchHalt = catchDone((_) => { - childPull = undefined; - if (childScope.state._tag === "Open" && scopeFinalizerCountUnsafe(childScope) === 1) { - return makePull; - } - const close2 = close(childScope, void_2); - childScope = undefined; - return flatMap3(close2, () => makePull); - }); - return suspend2(() => childPull ?? makePull); -})); -var flatMapConcurrent = (self, f, options) => self.pipe(map7(f), mergeAll3(options)); -var flattenArray = (self) => transformPull(self, (pull) => { - let array; - let index = 0; - const pump = suspend2(function loop() { - if (array === undefined) { - return flatMap3(pull, (array_) => { - switch (array_.length) { - case 0: - return loop(); - case 1: - return succeed6(array_[0]); - default: { - array = array_; - return succeed6(array_[index++]); - } - } - }); +var string2 = /* @__PURE__ */ new String3; +var Number4 = class extends ASTNodeImpl { + _tag = "Number"; + getParser() { + return fromRefinement(this, isNumber); + } + matchKey(s, options) { + return this._match(isStringNumberRegExp, s, options); + } + matchPart(s, options) { + return this._match(isStringFiniteRegExp, s, options); + } + _match(regexp, s, options) { + if (!regexp.test(s)) + return; + const value = globalThis.Number(s); + if (options.disableChecks || !this.checks) + return value; + return collectIssues(this.checks, value, undefined, this, options) ? undefined : value; + } + toCodecJson() { + if (this.checks && (hasCheck(this.checks, "effect/schema/isFinite") || hasCheck(this.checks, "effect/schema/isInt"))) { + return this; } - const next = array[index++]; - if (index >= array.length) { - array = undefined; - index = 0; + return replaceEncoding(this, [numberToJson]); + } + toCodecStringTree() { + if (this.toCodecJson() === this) { + return replaceEncoding(this, [finiteToString]); } - return succeed6(next); - }); - return succeed6(pump); -}); -var drain = (self) => transformPull(self, (pull) => succeed6(forever2(pull, { - disableYield: true -}))); -var catchCause3 = /* @__PURE__ */ dual(2, (self, f) => fromTransform((upstream, scope) => { - let forkedScope = forkUnsafe2(scope); - return map6(toTransform(self)(upstream, forkedScope), (pull) => { - let currentPull = pull.pipe(catchCause2((cause) => { - if (isDoneCause(cause)) { - return failCause3(cause); - } - const toClose = forkedScope; - forkedScope = forkUnsafe2(scope); - return close(toClose, failCause2(cause)).pipe(andThen2(toTransform(f(cause))(upstream, forkedScope)), flatMap3((childPull) => { - currentPull = childPull; - return childPull; - })); - })); - return suspend2(() => currentPull); - }); -})); -var catchCauseFilter2 = /* @__PURE__ */ dual(3, (self, filter, f) => catchCause3(self, (cause) => { - const result = filter(cause); - return isFailure2(result) ? failCause5(result.failure) : f(result.success, cause); -})); -var catch_3 = /* @__PURE__ */ dual(2, (self, f) => catchCauseFilter2(self, findError2, (e) => f(e))); -var mapError3 = /* @__PURE__ */ dual(2, (self, f) => catch_3(self, (err) => fail7(f(err)))); -var mergeAll3 = /* @__PURE__ */ dual(2, (channels, { - bufferSize = 16, - concurrency, - switch: switch_ = false -}) => fromTransformBracket(fnUntraced2(function* (upstream, scope, forkedScope) { - const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : Math.max(1, concurrency); - const semaphore = switch_ ? undefined : makeUnsafe5(concurrencyN); - const doneLatch = yield* make6(true); - const fibers = new Set; - const queue = yield* bounded(bufferSize); - yield* addFinalizer2(forkedScope, shutdown(queue)); - const pull = yield* toTransform(channels)(upstream, scope); - yield* gen2(function* () { - while (true) { - let pullFiber; - if (semaphore) { - if (fibers.size < concurrencyN) { - yield* semaphore.take(1); - } else { - pullFiber = yield* forkChild2(pull); - yield* raceFirst2(semaphore.take(1), andThen2(join(pullFiber), never2)); - } - } - const channel = pullFiber === undefined ? yield* pull : yield* join(pullFiber); - const childScope = forkUnsafe2(forkedScope); - const childPull = yield* toTransform(channel)(upstream, childScope); - while (fibers.size >= concurrencyN) { - const fiber = headUnsafe(fibers); - fibers.delete(fiber); - if (fibers.size === 0) - yield* doneLatch.open; - yield* interrupt3(fiber); + return replaceEncoding(this, [numberToString]); + } + getExpected() { + return "number"; + } +}; +function hasCheck(checks, id) { + return checks.some((check) => check.annotations?.representation?.id === id || check._tag === "FilterGroup" && hasCheck(check.checks, id)); +} +var number2 = /* @__PURE__ */ new Number4; +var Boolean = class extends ASTNodeImpl { + _tag = "Boolean"; + getParser() { + return fromRefinement(this, isBoolean); + } + getExpected() { + return "boolean"; + } +}; +var boolean = /* @__PURE__ */ new Boolean; +var Arrays = class extends ASTNodeImpl { + _tag = "Arrays"; + isMutable; + elements; + rest; + encodingChecks; + constructor(isMutable, elements, rest, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.isMutable = isMutable; + this.elements = elements; + this.rest = rest; + this.encodingChecks = encodingChecks; + let hasOptional = false; + for (let i = 0;i < elements.length; i++) { + if (isOptional(elements[i])) { + hasOptional = true; + } else if (hasOptional) { + throw new Error("A required element cannot follow an optional element. ts(1257)"); } - const fiber = yield* childPull.pipe(tap2(() => yieldNow2), flatMap3((value) => offer(queue, value)), forever2({ - disableYield: true - }), onError2(fnUntraced2(function* (cause) { - const halt = filterDone(cause); - yield* exit2(close(childScope, !isFailure2(halt) ? succeed4(halt.success.value) : failCause2(halt.failure))); - if (!fibers.has(fiber)) - return; - fibers.delete(fiber); - if (semaphore) - yield* semaphore.release(1); - if (fibers.size === 0) - yield* doneLatch.open; - if (isSuccess2(halt)) - return; - return yield* failCause4(queue, cause); - })), forkChild2); - doneLatch.closeUnsafe(); - fibers.add(fiber); - } - }).pipe(catchCause2((cause) => { - const halt = filterDone(cause); - if (isSuccess2(halt)) { - return doneLatch.whenOpen(failCause4(queue, cause)); } - return failCause4(queue, cause); - }), forkIn2(forkedScope)); - return take2(queue); -}))); -var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { - const strategy = options?.haltStrategy ?? "both"; - const queue = yield* bounded(0); - yield* addFinalizer2(forkedScope, shutdown(queue)); - let done = 0; - function onExit(side, cause) { - done++; - if (!isDoneCause(cause)) { - return failCause4(queue, cause); + if (hasOptional && rest.length > 1) { + throw new Error("A required element cannot follow an optional element. ts(1257)"); } - switch (strategy) { - case "both": { - return done === 2 ? failCause4(queue, cause) : void_3; - } - case "left": - case "right": { - return side === strategy ? failCause4(queue, cause) : void_3; - } - case "either": { - return failCause4(queue, cause); + for (let i = 1;i < rest.length; i++) { + if (isOptional(rest[i])) { + throw new Error("An optional element cannot follow a rest element. ts(1266)"); } } } - const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); - yield* runSide("left", left, forkUnsafe2(forkedScope)); - yield* runSide("right", right, forkUnsafe2(forkedScope)); - return take2(queue); -}))); -var mergeEffect = /* @__PURE__ */ dual(2, (self, effect) => merge2(self, fromEffectDrain(effect), { - haltStrategy: "left" -})); -var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { - let stringBuilder = ""; - let midCRLF = false; - let done = none2(); - function splitLinesArray(chunk) { - const chunkBuilder = []; - function pushLine(segment) { - if (stringBuilder.length === 0) { - chunkBuilder.push(segment); - } else { - chunkBuilder.push(stringBuilder + segment); - stringBuilder = ""; + getParser(compile, compileField = compile) { + const ast = this; + let elements; + let rest; + const elementLen = ast.elements.length; + const tailLen = Math.max(0, ast.rest.length - 1); + function getParser(tailThreshold, index) { + if (index < elementLen) { + return elements[index]; + } else if (index >= tailThreshold) { + return rest[index - tailThreshold + 1]; } + return rest[0]; } - for (let i = 0;i < chunk.length; i++) { - const str = chunk[i]; - if (str.length !== 0) { - let from = 0; - let indexOfCR = str.indexOf("\r"); - let indexOfLF = str.indexOf(` -`); - if (midCRLF) { - if (indexOfLF === 0) { - from = 1; - indexOfLF = str.indexOf(` -`, from); - } - midCRLF = false; - } - while (indexOfCR !== -1 || indexOfLF !== -1) { - if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { - pushLine(str.substring(from, indexOfLF)); - from = indexOfLF + 1; - indexOfLF = str.indexOf(` -`, from); + return fnUntracedEager2(function* (input, options) { + if (input === missing) { + return missing; + } + if (!Array.isArray(input)) { + return yield* fail6(new InvalidType(ast, input, options)); + } + if (!elements) { + elements = ast.elements.map((ast) => ({ + ast, + parser: compileField(ast) + })); + rest = ast.rest.map((ast) => ({ + ast, + parser: compileField(ast) + })); + } + const len = input.length; + const state = { + ast, + getParser, + input, + len, + tailThreshold: Math.max(elementLen, len - tailLen), + output: new globalThis.Array(len), + issues: undefined, + options + }; + const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen); + const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); + const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, { + concurrency, + end + }); + if (eff) + yield* eff; + if (ast.rest.length === 0 && len > elementLen) { + for (let i = elementLen;i <= len - 1; i++) { + const unexpected = new UnexpectedKey(ast, input[i], options); + const issue = new Pointer([i], unexpected); + if (options.errors === "all") { + if (state.issues) + state.issues.push(issue); + else + state.issues = [issue]; } else { - pushLine(str.substring(from, indexOfCR)); - if (str.length === indexOfCR + 1) { - midCRLF = true; - from = str.length; - indexOfCR = -1; - } else { - from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); - indexOfCR = str.indexOf("\r", from); - indexOfLF = str.indexOf(` -`, from); - } + return yield* fail6(new Composite(ast, [issue], input, options)); } } - stringBuilder = stringBuilder + str.substring(from); } - } - return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; - } - const pullOrFlush = suspend2(() => { - if (done._tag === "Some") { - return done3(done.value); - } - return matchEffect2(upstream, { - onSuccess: loop, - onFailure: failCause3, - onDone: (leftover) => { - done = some2(leftover); - if (stringBuilder.length > 0) { - const last = stringBuilder; - stringBuilder = ""; - midCRLF = false; - return succeed6([last]); - } - return done3(leftover); + if (state.issues) { + return yield* fail6(new Composite(ast, state.issues, input, options)); } + return state.output; }); - }); - function loop(chunk) { - const lines = splitLinesArray(chunk); - return lines !== null ? succeed6(lines) : pullOrFlush; } - return pullOrFlush; -})); -var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); -var unwrap = (channel) => fromTransform((upstream, scope) => { - let pull; - return succeed6(suspend2(() => { - if (pull) - return pull; - return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); - })); -}); -var runWith = (self, f, onHalt) => suspend2(() => { - const scope = makeUnsafe3(); - const makePull = toTransform(self)(done3(), scope); - return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); -}); -var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { - disableYield: true -}))); -var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { - let state = initial(); - return runWith(self, (pull) => whileLoop2({ - while: constTrue, - body: () => pull, - step: (value) => { - state = f(state, value); - } - }), () => succeed6(state)); -})); -var toPullScoped = (self, scope) => toTransform(self)(done3(), scope); - -// node_modules/effect/dist/internal/stream.js -var TypeId11 = "~effect/Stream"; -var streamVariance = { - _R: identity, - _E: identity, - _A: identity -}; -var Stream = function(channel) { - this.channel = channel; -}; -Stream.prototype = { - [TypeId11]: streamVariance, - pipe() { - return pipeArguments(this, arguments); + _rebuild(recur, checks, encodingChecks) { + const elements = mapOrSame(this.elements, recur); + const rest = mapOrSame(this.rest, recur); + return elements === this.elements && rest === this.rest && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Arrays(this.isMutable, elements, rest, this.annotations, checks, undefined, this.context, encodingChecks); } -}; -var fromChannel = (channel) => new Stream(channel); - -// node_modules/effect/dist/Sink.js -var TypeId12 = "~effect/Sink"; -var endVoid = /* @__PURE__ */ succeed6([undefined]); -var sinkVariance = { - _A: identity, - _In: identity, - _L: identity, - _E: identity, - _R: identity -}; -var SinkProto = { - [TypeId12]: sinkVariance, - pipe() { - return pipeArguments(this, arguments); + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks); + } + getExpected() { + return "array"; } }; -var isSink = (u) => hasProperty(u, TypeId12); -var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ - disableYield: true -})), catchDone(succeed6))); -var fromTransform2 = (transform) => { - const self = Object.create(SinkProto); - self.transform = transform; - return self; -}; -var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done3))); -var drain2 = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { - disableYield: true -}), () => endVoid)); -var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { - discard: true -})); -var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ - disableYield: true -}), catchDone(() => endVoid))); -var unwrap2 = (effect) => fromChannel2(unwrap(map6(effect, toChannel))); - -// node_modules/effect/dist/internal/rcRef.js -var TypeId13 = "~effect/RcRef"; -var stateEmpty = { - _tag: "Empty" +function stepArray(s, item, exit, i) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, i, exit); + } + const value = exit === sameExit ? item : exit[args]; + if (value !== missing) { + s.output[i] = value; + } else { + const p = s.getParser(s.tailThreshold, i); + if (isOptional(p.ast)) + return; + const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); + } + } +} +var parseArrayOptions = { + onItem(s, item, i) { + const value = i < s.len ? item : missing; + return s.getParser(s.tailThreshold, i).parser(value, s.options); + }, + step: stepArray }; -var stateClosed = { - _tag: "Closed" +var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); +var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); +var wrapPropertyKeyIssue = (s, ast, key, exit) => { + if (exit.cause.reasons.length === 0) { + return exit; + } + const issue = getSchemaIssue(exit.cause); + if (issue === undefined) { + return failCause2(map4(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); + } + const pointer = new Pointer([key], issue); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(pointer); + else + s.issues = [pointer]; + } else { + return fail5(new Composite(ast, [pointer], s.input, s.options)); + } }; -var variance2 = { - _A: identity, - _E: identity +var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; +function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) { + let stringKeys; + let symbolKeys; + function go(parameter) { + switch (parameter._tag) { + case "String": + case "TemplateLiteral": + return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== undefined); + case "Number": + return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== undefined); + case "Symbol": + return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== undefined); + case "Union": + return [...new Set(parameter.types.flatMap(go))]; + default: + return []; + } + } + return go(parameterFromPropertyKey(toEncoded(parameter))); +} +var PropertySignature = class { + name; + type; + constructor(name, type) { + this.name = name; + this.type = type; + } }; - -class RcRefImpl { - [TypeId13] = variance2; - pipe() { - return pipeArguments(this, arguments); +function isIndexSignatureParameterSide(ast) { + switch (ast._tag) { + case "String": + case "Number": + case "Symbol": + case "TemplateLiteral": + return true; + case "Union": + return ast.types.every(isIndexSignatureParameterSide); + default: + return false; } - state = stateEmpty; - semaphore = /* @__PURE__ */ makeUnsafe5(1); - acquire; - context; - scope; - idleTimeToLive; - constructor(acquire, context, scope, idleTimeToLive) { - this.acquire = acquire; - this.context = context; - this.scope = scope; - this.idleTimeToLive = idleTimeToLive; +} +function isIndexSignatureParameterEncodedSide(ast) { + const encoded = getLastEncoding(ast); + switch (encoded._tag) { + case "String": + case "Number": + case "Symbol": + case "TemplateLiteral": + return true; + case "Union": + return encoded.types.every(isIndexSignatureParameterEncodedSide); + default: + return false; } } -var make10 = (options) => withFiber2((fiber) => { - const context = fiber.context; - const scope = get(context, Scope); - const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive ? fromInputUnsafe(options.idleTimeToLive) : undefined); - return as2(addFinalizerExit(scope, () => { - const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; - ref.state = stateClosed; - return close2; - }), ref); -}); -var getState = (self) => uninterruptibleMask2(function loop(restore) { - switch (self.state._tag) { - case "Closed": { - return interrupt2; - } - case "Acquired": { - self.state.refCount++; - return self.state.fiber ? as2(interrupt3(self.state.fiber), self.state) : succeed6(self.state); +function isIndexSignatureParameter(ast) { + return isIndexSignatureParameterSide(ast) && isIndexSignatureParameterEncodedSide(ast); +} +var IndexSignature = class { + parameter; + type; + constructor(parameter, type) { + if (!isIndexSignatureParameter(parameter)) { + throw new Error(`Invalid index signature parameter ${parameter._tag}`); } - case "Empty": { - const scope = makeUnsafe3(); - return self.semaphore.withPermit(suspend2(() => { - if (self.state._tag !== "Empty") { - return loop(restore); - } - return restore(provideContext2(self.acquire, add(self.context, Scope, scope))).pipe(flatMap3((value) => { - if (self.state._tag === "Closed") { - return interrupt2; - } - const state = { - _tag: "Acquired", - value, - scope, - fiber: undefined, - refCount: 1, - invalidated: false - }; - self.state = state; - return succeed6(state); - }), onExit2((exit) => isFailure3(exit) ? close(scope, exit) : void_3)); - })); + this.parameter = parameter; + this.type = type; + if (isOptional(type) && !containsUndefined(type)) { + throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead."); } } -}); -var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { - const self = self_; - const state = yield* getState(self); - const scope = yield* scope2; - const isFinite2 = self.idleTimeToLive !== undefined && isFinite(self.idleTimeToLive); - yield* addFinalizerExit(scope, () => { - state.refCount--; - if (state.refCount > 0) { - return void_3; - } - if (self.idleTimeToLive === undefined || state.invalidated) { - if (self.state === state) { - self.state = stateEmpty; - } - return close(state.scope, void_2); - } else if (!isFinite2) { - return void_3; - } - state.fiber = sleep2(self.idleTimeToLive).pipe(flatMap3(() => { - if (self.state === state && state.refCount === 0) { - self.state = stateEmpty; - return close(state.scope, void_2); +}; +var Objects = class extends ASTNodeImpl { + _tag = "Objects"; + propertySignatures; + indexSignatures; + encodingChecks; + constructor(propertySignatures, indexSignatures, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.propertySignatures = propertySignatures; + this.indexSignatures = indexSignatures; + this.encodingChecks = encodingChecks; + const seen = new Set; + const duplicates = []; + for (const propertySignature of propertySignatures) { + const name = propertySignature.name; + if (seen.has(name)) { + duplicates.push(name); + } else { + seen.add(name); } - return void_3; - }), ensuring2(sync3(() => { - state.fiber = undefined; - })), runForkWith2(self.context), runIn(self.scope)); - return void_3; - }); - return state.value; -}); - -// node_modules/effect/dist/RcRef.js -var make11 = make10; -var get3 = get2; - -// node_modules/effect/dist/Stream.js -var TypeId14 = "~effect/Stream"; -var isStream = (u) => hasProperty(u, TypeId14); -var fromChannel3 = fromChannel; -var fromEffect2 = (effect) => fromChannel3(fromEffect(map6(effect, of))); -var fromPull2 = (pull) => fromChannel3(fromPull(pull)); -var transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))); -var toChannel2 = (stream) => stream.channel; -var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); -var empty4 = /* @__PURE__ */ fromChannel3(empty3); -var succeed8 = (value) => fromChannel3(succeed7(of(value))); -var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); -var fromArray2 = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel3(succeed7(array)) : empty4; -var unwrap3 = (effect) => fromChannel3(unwrap(map6(effect, toChannel2))); -var map8 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { - let i = 0; - return fromChannel3(map7(self.channel, map2((o) => f(o, i++)))); -})); -var flatMap5 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options) => self.channel.pipe(flattenArray, flatMap4((a) => f(a).channel, options), fromChannel3)); -var flatten4 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => flatMap5(self, identity, options)); -var drain3 = (self) => fromChannel3(drain(self.channel)); -var concat = /* @__PURE__ */ dual(2, (self, that) => flatten4(fromArray2([self, that]))); -var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); -var mergeEffect2 = /* @__PURE__ */ dual(2, (self, effect) => self.channel.pipe(mergeEffect(effect), fromChannel3)); -var mapError4 = /* @__PURE__ */ dual(2, (self, f) => fromChannel3(mapError3(self.channel, f))); -var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { - let done; - let leftover; - const upstreamWithLeftover = suspend2(() => { - if (leftover !== undefined) { - const chunk = leftover; - leftover = undefined; - return succeed6(chunk); } - return upstream; - }).pipe(catch_2((error) => { - done = fail4(error); - return done3(); - })); - const pull = map6(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { - leftover = leftover_; - return of(value); - }); - return suspend2(() => done ? done : pull); -}))); -var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { - const decoder = new TextDecoder(options?.encoding); - return map8(self, (chunk) => decoder.decode(chunk, { - stream: true - })); -})); -var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); -var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map6(([a]) => a)))); -var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { - for (let i = 0;i < chunk.length; i++) { - acc.push(chunk[i]); - } - return acc; -}); -var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channel, initial, (acc, arr) => { - for (let i = 0;i < arr.length; i++) { - acc = f(acc, arr[i]); - } - return acc; -})); -var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => { - let i = 0; - return whileLoop2({ - while: () => i < arr.length, - body: () => f(arr[i++]), - step: constVoid - }); -})); -var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); - -// node_modules/effect/dist/FileSystem.js -var TypeId15 = "~effect/FileSystem"; -var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); -var make12 = (impl) => FileSystem.of({ - ...impl, - [TypeId15]: TypeId15, - exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), - readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ - try: () => new TextDecoder(encoding).decode(_), - catch: (cause) => badArgument({ - module: "FileSystem", - method: "readFileString", - description: "invalid encoding", - cause - }) - })), - stream: fnUntraced2(function* (path, options) { - const file = yield* impl.open(path, { - flag: "r" - }); - const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset); - if (offset) { - yield* file.seek(offset, "start"); + if (duplicates.length > 0) { + throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); } - const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead); - let totalBytesRead = BigInt(0); - const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024)); - const readChunk = file.readAlloc(chunkSize); - return fromPull2(succeed6(flatMap3(suspend2(() => { - if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { - return done3(); - } - return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; - }), match({ - onNone: () => done3(), - onSome: (buf) => { - totalBytesRead += BigInt(buf.length); - return succeed6(of(buf)); - } - })))); - }, unwrap3), - sink: (path, options) => pipe(impl.open(path, { - ...options, - flag: options?.flag ?? "w" - }), map6((file) => forEach3((_) => file.writeAll(_))), unwrap2), - writeFileString: (path, data, options) => flatMap3(try_2({ - try: () => new TextEncoder().encode(data), - catch: (cause) => badArgument({ - module: "FileSystem", - method: "writeFileString", - description: "could not encode string", - cause - }) - }), (_) => impl.writeFile(path, _, options)) -}); -var FileTypeId = "~effect/FileSystem/File"; -class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBackend")) { -} -// node_modules/effect/dist/internal/matcher.js -var TypeId16 = "~effect/Match/Matcher"; -var TypeMatcherProto = { - [TypeId16]: { - _input: identity, - _filters: identity, - _remaining: identity, - _result: identity, - _return: identity, - _args: identity - }, - _tag: "TypeMatcher", - add(_case) { - return makeTypeMatcher(this.select, [...this.cases, _case]); - }, - pipe() { - return pipeArguments(this, arguments); } -}; -function makeTypeMatcher(select, cases) { - const matcher = Object.create(TypeMatcherProto); - matcher.select = select; - matcher.cases = cases; - return matcher; -} -var ValueMatcherProto = { - [TypeId16]: { - _input: identity, - _filters: identity, - _result: identity, - _return: identity, - _flavor: identity - }, - _tag: "ValueMatcher", - add(_case) { - if (isSuccess2(this.value)) { - return this; + getParser(compile, compileField = compile) { + const ast = this; + const expectedKeys = []; + for (const ps of ast.propertySignatures) { + expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name); } - if (_case._tag === "When" && _case.guard(this.provided) === true) { - return makeValueMatcher(this.provided, succeed2(_case.evaluate(this.provided))); - } else if (_case._tag === "Not" && _case.guard(this.provided) === false) { - return makeValueMatcher(this.provided, succeed2(_case.evaluate(this.provided))); + const hasProperties = expectedKeys.length; + const indexCount = ast.indexSignatures.length; + let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : undefined; + if (!hasProperties && !indexCount) { + return fromRefinement(ast, isNotNullish); } - return this; - }, - pipe() { - return pipeArguments(this, arguments); - } -}; -function makeValueMatcher(provided, value) { - const matcher = Object.create(ValueMatcherProto); - matcher.provided = provided; - matcher.value = value; - return matcher; -} -var makeWhen = (guard, evaluate) => ({ - _tag: "When", - guard, - evaluate -}); -var value = (i) => makeValueMatcher(i, fail2(i)); -var discriminator = (field) => (...pattern) => { - const f = pattern[pattern.length - 1]; - const values = pattern.slice(0, -1); - const pred = values.length === 1 ? (_) => _ != null && _[field] === values[0] : (_) => _ != null && values.includes(_[field]); - return (self) => self.add(makeWhen(pred, f)); -}; -var tag = /* @__PURE__ */ discriminator("_tag"); -var result2 = (self) => { - if (self._tag === "ValueMatcher") { - return self.value; - } - const len = self.cases.length; - if (len === 1) { - const _case = self.cases[0]; - return (...args) => { - const input = self.select(...args); - if (_case._tag === "When" && _case.guard(input) === true) { - return succeed2(_case.evaluate(input, ...args)); - } else if (_case._tag === "Not" && _case.guard(input) === false) { - return succeed2(_case.evaluate(input, ...args)); + let properties; + let indexes; + const finishIndex = (s, key, k2, inputValue, exitValue) => { + if (exitValue._tag === "Failure") { + return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_2; } - return fail2(input); - }; - } - return (...args) => { - const input = self.select(...args); - for (let i = 0;i < len; i++) { - const _case = self.cases[i]; - if (_case._tag === "When" && _case.guard(input) === true) { - return succeed2(_case.evaluate(input, ...args)); - } else if (_case._tag === "Not" && _case.guard(input) === false) { - return succeed2(_case.evaluate(input, ...args)); + const value = exitValue === sameExit ? inputValue : exitValue[args]; + if (k2 !== missing && value !== missing) { + if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) + return void_2; + assignProperty(s.out, k2, value); } - } - return fail2(input); - }; -}; -var getExhaustiveAbsurdErrorMessage = "effect/match/Match/exhaustive: absurd"; -var exhaustive = (self) => { - const toResult = result2(self); - if (isResult2(toResult)) { - if (isSuccess2(toResult)) { - return toResult.success; - } - throw new Error(getExhaustiveAbsurdErrorMessage); - } - return (...args) => { - const result = toResult(...args); - if (isSuccess2(result)) { - return result.success; - } - throw new Error(getExhaustiveAbsurdErrorMessage); - }; -}; - -// node_modules/effect/dist/Match.js -var value2 = value; -var tag2 = tag; -var exhaustive2 = exhaustive; -// node_modules/effect/dist/Ref.js -var TypeId17 = "~effect/Ref"; -var RefProto = { - [TypeId17]: { - _A: identity - }, - ...PipeInspectableProto, - toJSON() { - return { - _id: "Ref", - ref: this.ref - }; - } -}; -var makeUnsafe6 = (value) => { - const self = Object.create(RefProto); - self.ref = make7(value); - return self; -}; -var make13 = (value) => sync3(() => makeUnsafe6(value)); -var get4 = (self) => sync3(() => self.ref.current); -var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { - self.ref.current = f(self.ref.current); -})); -// node_modules/effect/dist/internal/schema/annotations.js -function resolve(ast) { - return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; -} -var STRUCTURAL_ANNOTATION_KEY = "~structural"; -var SENTINELS_ANNOTATION_KEY = "~sentinels"; -var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; -var getExpected = /* @__PURE__ */ memoize((ast) => { - const identifier = resolve(ast)?.identifier; - if (typeof identifier === "string") - return identifier; - return ast.getExpected(getExpected); -}); - -// node_modules/effect/dist/internal/schema/parser.js -var missing = /* @__PURE__ */ Symbol(); -var succeed9 = succeed4; -var missingExit = /* @__PURE__ */ succeed9(missing); -var sameExit = /* @__PURE__ */ succeed9(missing); -var toOption = (value) => value === missing ? none2() : some2(value); -var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed9(option.value); - -// node_modules/effect/dist/SchemaIssue.js -var TypeId18 = "~effect/SchemaIssue/Issue"; -function isIssue(u) { - return hasProperty(u, TypeId18) && u[TypeId18] === TypeId18; -} -function hasInput(issue) { - return Object.hasOwn(issue, "input"); -} - -class IssueNodeImpl { - [TypeId18] = TypeId18; - constructor(input, options) { - if (options?.reportInput === true && input !== missing) { - this.input = input; - } - } -} -var Filter = class extends IssueNodeImpl { - _tag = "Filter"; - filter; - issue; - constructor(filter, issue, input, options) { - super(input, options); - this.filter = filter; - this.issue = issue; - } -}; -var Encoding = class extends IssueNodeImpl { - _tag = "Encoding"; - ast; - issue; - constructor(ast, issue, input, options) { - super(input, options); - this.ast = ast; - this.issue = issue; - } -}; -var Pointer = class extends IssueNodeImpl { - _tag = "Pointer"; - path; - issue; - constructor(path, issue) { - super(); - this.path = path; - this.issue = issue; - } -}; -var MissingKey = class extends IssueNodeImpl { - _tag = "MissingKey"; - annotations; - constructor(annotations) { - super(); - this.annotations = annotations; - } -}; -var UnexpectedKey = class extends IssueNodeImpl { - _tag = "UnexpectedKey"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; - } -}; -var Composite = class extends IssueNodeImpl { - _tag = "Composite"; - ast; - issues; - constructor(ast, issues, input, options) { - super(input, options); - this.ast = ast; - this.issues = issues; - } -}; -var InvalidType = class extends IssueNodeImpl { - _tag = "InvalidType"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; - } -}; -var InvalidValue = class extends IssueNodeImpl { - _tag = "InvalidValue"; - annotations; - constructor(annotations, input, options) { - super(input, options); - this.annotations = annotations; - } -}; -var AnyOf = class extends IssueNodeImpl { - _tag = "AnyOf"; - ast; - issues; - constructor(ast, issues, input, options) { - super(input, options); - this.ast = ast; - this.issues = issues; - } -}; -var OneOf = class extends IssueNodeImpl { - _tag = "OneOf"; - ast; - successes; - constructor(ast, successes, input, options) { - super(input, options); - this.ast = ast; - this.successes = successes; - } -}; -function makeFilterIssue(entry, input, options) { - if (isIssue(entry)) { - return entry; - } - if (typeof entry === "string") { - return new InvalidValue({ - message: entry - }, input, options); - } - const inner = typeof entry.issue === "string" ? new InvalidValue({ - message: entry.issue - }, input, options) : entry.issue; - return new Pointer(entry.path, inner); -} -function makeSingle(out, input, options) { - if (out === undefined) { - return; - } - if (typeof out === "boolean") { - return out ? undefined : new InvalidValue(undefined, input, options); - } - return makeFilterIssue(out, input, options); -} -function normalizeFilterOutput(ast, out, input, options) { - if (Array.isArray(out)) { - if (!isReadonlyArrayNonEmpty(out)) { - return; - } - return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map2(out, (entry) => makeFilterIssue(entry, input, options)), input, options); - } - return makeSingle(out, input, options); -} -var defaultLeafHook = (issue) => { - const message = findMessage(issue); - if (message !== undefined) - return message; - switch (issue._tag) { - case "InvalidType": - return getExpectedMessage(getExpected(issue.ast), issue); - case "InvalidValue": { - const expected = findExpected(issue); - if (expected !== undefined) - return getExpectedMessage(expected, issue); - const input = formatInput(issue); - return input === undefined ? "Expected a valid value" : `Invalid data ${input}`; - } - case "MissingKey": - return "Missing key"; - case "UnexpectedKey": { - const input = formatInput(issue); - return input === undefined ? "Expected no excess property" : `Unexpected key with value ${input}`; - } - case "Forbidden": - return "Forbidden operation"; - case "OneOf": { - const input = formatInput(issue); - return input === undefined ? "Expected exactly one member to match" : `Expected exactly one member to match the input ${input}`; - } - } -}; -var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue); -function formatInput(issue) { - return hasInput(issue) ? format(issue.input) : undefined; -} -function findExpected(issue) { - const expected = issue.annotations?.expected; - return typeof expected === "string" ? expected : undefined; -} -function getExpectedMessage(expected, issue) { - const input = formatInput(issue); - return input === undefined ? `Expected ${expected}` : `Expected ${expected}, got ${input}`; -} -function formatCheck(check) { - const expected = check.annotations?.expected; - if (typeof expected === "string") - return expected; - switch (check._tag) { - case "Filter": - return ""; - case "FilterGroup": - return check.checks.map((check) => formatCheck(check)).join(" & "); - } -} -function makeFormatterDefault() { - return (issue) => formatIssue(issue, ""); -} -var defaultFormatter = /* @__PURE__ */ makeFormatterDefault(); -function formatIssue(issue, path) { - let message; - switch (issue._tag) { - case "Filter": { - const annotated = defaultCheckHook(issue); - if (annotated !== undefined) { - message = annotated; - } else { - if (issue.issue._tag !== "InvalidValue") { - return formatIssue(issue.issue, path); - } - const expected = findExpected(issue.issue); - message = expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue); - } - break; - } - case "Encoding": - return formatIssue(issue.issue, path); - case "Pointer": - return formatIssue(issue.issue, path + formatPath(issue.path)); - case "Composite": - case "AnyOf": { - if (issue._tag === "Composite" || issue.issues.length > 0) { - return issue.issues.map((issue) => formatIssue(issue, path)).join(` -`); - } - message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue); - break; - } - default: - message = defaultLeafHook(issue); - break; - } - return path ? `${message} - at ${path}` : message; -} -function findMessage(issue) { - if (issue._tag === "Pointer") - return; - if (issue._tag === "Encoding") - return findMessage(issue.issue); - const annotations = issue._tag === "Filter" ? issue.filter.annotations : ("annotations" in issue) ? issue.annotations : issue.ast.annotations; - const message = annotations?.[issue._tag === "MissingKey" ? "messageMissingKey" : issue._tag === "UnexpectedKey" ? "messageUnexpectedKey" : "message"]; - if (typeof message === "string") - return message; -} - -// node_modules/effect/dist/internal/schema/cause.js -function getSchemaIssue(cause) { - let issue; - for (const reason of cause.reasons) { - if (!isFailReason2(reason) || !isIssue(reason.error)) { - return; - } - issue ??= reason.error; - } - return issue; -} -function getSchemaIssueOrThrow(cause, message) { - const issue = getSchemaIssue(cause); - if (issue === undefined) { - throw new Error(message, { - cause - }); - } - return issue; -} - -// node_modules/effect/dist/SchemaGetter.js -var Getter = class extends Class { - run; - constructor(run) { - super(); - this.run = run; - } - map(f) { - return new Getter((oe, options) => this.run(oe, options).pipe(mapEager2(map(f)))); - } - compose(other) { - if (isPassthrough(this)) { - return other; - } - if (isPassthrough(other)) { - return this; - } - return new Getter((oe, options) => this.run(oe, options).pipe(flatMapEager2((ot) => other.run(ot, options)))); - } -}; -var passthrough_ = /* @__PURE__ */ new Getter(succeed6); -function isPassthrough(getter) { - return getter.run === passthrough_.run; -} -function passthrough() { - return passthrough_; -} -function onSome(f) { - return new Getter((oe, options) => isNone2(oe) ? succeedNone2 : f(oe.value, options)); -} -function transform(f) { - return transformOptional(map(f)); -} -function transformEffect(f) { - return onSome((e, options) => f(e, options).pipe(mapEager2(some2))); -} -function transformOptional(f) { - return new Getter((oe) => succeed6(f(oe))); -} -function withDefault(defaultValue) { - return new Getter((o) => { - const filtered = filter(o, isNotUndefined); - return isSome2(filtered) ? succeed6(filtered) : mapEager2(defaultValue, some2); - }); -} -function String2() { - return transform(globalThis.String); -} -function Number3() { - return transform(globalThis.Number); -} -function parseJson(options) { - return onSome((input, parseOptions) => try_2({ - try: () => some2(JSON.parse(input, options?.reviver)), - catch: () => new InvalidValue({ - expected: "a valid JSON string" - }, input, parseOptions) - })); -} -function stringifyJson(options) { - return onSome((input, parseOptions) => try_2({ - try: () => { - const output = JSON.stringify(input, options?.replacer, options?.space); - if (output === undefined) { - throw new TypeError("Value cannot be represented as JSON"); - } - return some2(output); - }, - catch: () => new InvalidValue({ - expected: "a JSON-serializable value" - }, input, parseOptions) - })); -} -function encodeBase642() { - return transform(encodeBase64); -} -function decodeBase642() { - return transformEffect((input, options) => mapErrorEager2(fromResult2(decodeBase64(input)), () => new InvalidValue({ - expected: "a valid Base64 string" - }, input, options))); -} - -// node_modules/effect/dist/SchemaTransformation.js -var TypeId19 = "~effect/SchemaTransformation/Transformation"; -var Transformation = class { - [TypeId19] = TypeId19; - _tag = "Transformation"; - decode; - encode; - constructor(decode, encode) { - this.decode = decode; - this.encode = encode; - } - flip() { - return new Transformation(this.encode, this.decode); - } - compose(other) { - return new Transformation(this.decode.compose(other.decode), other.encode.compose(this.encode)); - } -}; -function isTransformation(u) { - return hasProperty(u, TypeId19) && u[TypeId19] === TypeId19; -} -var make14 = (options) => { - if (isTransformation(options)) { - return options; - } - return new Transformation(options.decode, options.encode); -}; -function transformEffect2(options) { - return new Transformation(transformEffect(options.decode), transformEffect(options.encode)); -} -function transform2(options) { - return new Transformation(transform(options.decode), transform(options.encode)); -} -var passthrough_2 = /* @__PURE__ */ new Transformation(/* @__PURE__ */ passthrough(), /* @__PURE__ */ passthrough()); -function passthrough2() { - return passthrough_2; -} -var numberFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ String2()); -var isJsonError = (input) => isObject(input) && typeof input["message"] === "string"; -var decodeJsonError = (input) => { - const hasCause = Object.hasOwn(input, "cause"); - const err = hasCause ? new Error(input.message, { - cause: decodeDefect(input.cause) - }) : new Error(input.message); - if (typeof input.name === "string" && input.name !== "Error") - err.name = input.name; - if (typeof input.stack === "string") - err.stack = input.stack; - return err; -}; -var encodeUnknownAsJson = (input) => { - try { - const json = formatJson(input); - return json === undefined ? format(input) : JSON.parse(json); - } catch { - return format(input); - } -}; -var encodeJsonError = (input, options, encodeDefect) => { - const encoded = { - name: input.name, - message: typeof input.message === "string" ? input.message : "" - }; - if (options?.includeStack && typeof input.stack === "string") { - encoded.stack = input.stack; - } - if (!options?.excludeCause && input.cause !== undefined) { - encoded.cause = encodeDefect(input.cause); - } - return encoded; -}; -var makeEncodeDefect = (options) => { - const seen = new WeakSet; - const encode = (input) => { - if (isError(input)) { - if (seen.has(input)) { - return "[Circular]"; - } - seen.add(input); - const encoded = encodeJsonError(input, options, encode); - seen.delete(input); - return encoded; - } - return encodeUnknownAsJson(input); - }; - return encode; -}; -var decodeDefect = (input) => isJsonError(input) ? decodeJsonError(input) : input; -var defectFromJson = (options) => transform2({ - decode: decodeDefect, - encode: makeEncodeDefect(options) -}); -var urlFromString = /* @__PURE__ */ transformEffect2({ - decode: (s, options) => URL.canParse(s) ? succeed6(new URL(s)) : fail6(new InvalidValue({ - expected: "a valid URL string" - }, s, options)), - encode: (url) => succeed6(url.href) -}); -var uint8ArrayFromBase64String = /* @__PURE__ */ new Transformation(/* @__PURE__ */ decodeBase642(), /* @__PURE__ */ encodeBase642()); -function fromJsonString(options) { - return new Transformation(parseJson(options ?? {}), stringifyJson(options)); -} - -// node_modules/effect/dist/SchemaAST.js -function makeGuard(tag) { - return (ast) => ast._tag === tag; -} -var isDeclaration = /* @__PURE__ */ makeGuard("Declaration"); -var isNever2 = /* @__PURE__ */ makeGuard("Never"); -var isLiteral = /* @__PURE__ */ makeGuard("Literal"); -var isUniqueSymbol = /* @__PURE__ */ makeGuard("UniqueSymbol"); -var isArrays = /* @__PURE__ */ makeGuard("Arrays"); -var isObjects = /* @__PURE__ */ makeGuard("Objects"); -var isUnion = /* @__PURE__ */ makeGuard("Union"); -var isSuspend = /* @__PURE__ */ makeGuard("Suspend"); -var Link = class { - to; - transformation; - constructor(to, transformation) { - this.to = to; - this.transformation = transformation; - } -}; -var defaultParseOptions = {}; -var Context = class { - isOptional; - isMutable; - constructorDefault; - annotations; - constructor(isOptional, isMutable, constructorDefault = undefined, annotations = undefined) { - this.isOptional = isOptional; - this.isMutable = isMutable; - this.constructorDefault = constructorDefault; - this.annotations = annotations; - } -}; -var TypeId20 = "~effect/Schema"; - -class ASTNodeImpl { - [TypeId20] = TypeId20; - annotations; - checks; - encoding; - context; - constructor(annotations = undefined, checks = undefined, encoding = undefined, context = undefined) { - this.annotations = annotations; - this.checks = checks; - this.encoding = encoding; - this.context = context; - } - toString() { - return `<${this._tag}>`; - } -} -var Declaration = class extends ASTNodeImpl { - _tag = "Declaration"; - typeParameters; - run; - encodingChecks; - encodingRun; - constructor(typeParameters, run, annotations, checks, encoding, context, encodingChecks, encodingRun) { - super(annotations, checks, encoding, context); - this.typeParameters = typeParameters; - this.run = run; - this.encodingChecks = encodingChecks; - this.encodingRun = encodingRun; - } - getParser() { - let run; - return (input, options) => { - if (input === missing) - return missingExit; - return (run ??= this.run(this.typeParameters))(input, this, options); + return void_2; }; - } - _rebuild(recur, checks, encodingChecks, run, encodingRun) { - const tps = mapOrSame(this.typeParameters, recur); - return tps === this.typeParameters && checks === this.checks && encodingChecks === this.encodingChecks && run === this.run && encodingRun === this.encodingRun ? this : new Declaration(tps, run, this.annotations, checks, undefined, this.context, encodingChecks, encodingRun); - } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks, this.run, this.encodingRun); - } - flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks, this.encodingRun ?? this.run, this.run); - } - getExpected() { - const expected = this.annotations?.expected; - if (typeof expected === "string") - return expected; - return ""; - } -}; -var Unknown = class extends ASTNodeImpl { - _tag = "Unknown"; - getParser() { - return fromRefinement(this, isUnknown); - } - getExpected() { - return "unknown"; - } -}; -var unknown = /* @__PURE__ */ new Unknown; -var Literal = class extends ASTNodeImpl { - _tag = "Literal"; - literal; - constructor(literal, annotations, checks, encoding, context) { - super(annotations, checks, encoding, context); - if (typeof literal === "number" && !globalThis.Number.isFinite(literal)) { - throw new Error(`A numeric literal must be finite, got ${format(literal)}`); - } - this.literal = literal; - } - getParser() { - return fromConst(this, this.literal); - } - matchPart(s, _options) { - return s === globalThis.String(this.literal) ? this.literal : undefined; - } - toCodecJson() { - return typeof this.literal === "bigint" ? literalToString(this) : this; - } - toCodecStringTree() { - return typeof this.literal === "string" ? this : literalToString(this); - } - getExpected() { - return typeof this.literal === "string" ? JSON.stringify(this.literal) : globalThis.String(this.literal); - } -}; -function literalToString(ast) { - const literalAsString = globalThis.String(ast.literal); - return replaceEncoding(ast, [new Link(new Literal(literalAsString), new Transformation(transform(() => ast.literal), transform(() => literalAsString)))]); -} -var String3 = class extends ASTNodeImpl { - _tag = "String"; - getParser() { - return fromRefinement(this, isString); - } - matchPart(s, options) { - const checks = this.checks; - return checks && !options.disableChecks && collectIssues(checks, s, undefined, this, options) ? undefined : s; - } - getExpected() { - return "string"; - } -}; -var string2 = /* @__PURE__ */ new String3; -var Number4 = class extends ASTNodeImpl { - _tag = "Number"; - getParser() { - return fromRefinement(this, isNumber); - } - matchKey(s, options) { - return this._match(isStringNumberRegExp, s, options); - } - matchPart(s, options) { - return this._match(isStringFiniteRegExp, s, options); - } - _match(regexp, s, options) { - if (!regexp.test(s)) - return; - const value = globalThis.Number(s); - if (options.disableChecks || !this.checks) - return value; - return collectIssues(this.checks, value, undefined, this, options) ? undefined : value; - } - toCodecJson() { - if (this.checks && (hasCheck(this.checks, "effect/schema/isFinite") || hasCheck(this.checks, "effect/schema/isInt"))) { - return this; - } - return replaceEncoding(this, [numberToJson]); - } - toCodecStringTree() { - if (this.toCodecJson() === this) { - return replaceEncoding(this, [finiteToString]); - } - return replaceEncoding(this, [numberToString]); - } - getExpected() { - return "number"; - } -}; -function hasCheck(checks, id) { - return checks.some((check) => check.annotations?.representation?.id === id || check._tag === "FilterGroup" && hasCheck(check.checks, id)); -} -var number2 = /* @__PURE__ */ new Number4; -var Boolean = class extends ASTNodeImpl { - _tag = "Boolean"; - getParser() { - return fromRefinement(this, isBoolean); - } - getExpected() { - return "boolean"; - } -}; -var boolean = /* @__PURE__ */ new Boolean; -var Arrays = class extends ASTNodeImpl { - _tag = "Arrays"; - isMutable; - elements; - rest; - encodingChecks; - constructor(isMutable, elements, rest, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.isMutable = isMutable; - this.elements = elements; - this.rest = rest; - this.encodingChecks = encodingChecks; - let hasOptional = false; - for (let i = 0;i < elements.length; i++) { - if (isOptional(elements[i])) { - hasOptional = true; - } else if (hasOptional) { - throw new Error("A required element cannot follow an optional element. ts(1257)"); - } - } - if (hasOptional && rest.length > 1) { - throw new Error("A required element cannot follow an optional element. ts(1257)"); - } - for (let i = 1;i < rest.length; i++) { - if (isOptional(rest[i])) { - throw new Error("An optional element cannot follow a rest element. ts(1266)"); - } - } - } - getParser(compile, compileConstructorDefault = compile) { - const ast = this; - let elements; - let rest; - const elementLen = ast.elements.length; - const tailLen = Math.max(0, ast.rest.length - 1); - function getParser(tailThreshold, index) { - if (index < elementLen) { - return elements[index]; - } else if (index >= tailThreshold) { - return rest[index - tailThreshold + 1]; + const parseIndex = (s, key, index, exitKey) => { + if (!exitKey) { + const eff = index.parserKey(key, s.options); + if (!effectIsExit(eff)) { + return flatMap3(exit2(eff), (exit) => parseIndex(s, key, index, exit)); + } + exitKey = eff; } - return rest[0]; - } - return fnUntracedEager2(function* (input, options) { + if (exitKey._tag === "Failure") { + return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_2; + } + const k2 = exitKey === sameExit ? key : exitKey[args]; + const inputValue = s.input[key]; + const result = index.parserValue(inputValue, s.options); + return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, k2, inputValue, exit)); + }; + const parseStringIndex = (s, key, index) => { + const inputValue = s.input[key]; + const result = index.parserValue(inputValue, s.options); + return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, key, inputValue, exit)); + }; + const parseIndexes = indexCount ? iterateConcurrent()({ + onItem: (s, [key, index]) => index.is.parameter === string2 ? parseStringIndex(s, key, index) : parseIndex(s, key, index), + step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined + }) : undefined; + const compileMembers = () => { + if (!properties) { + properties = ast.propertySignatures.map((ps) => ({ + parser: compileField(ps.type), + name: ps.name, + type: ps.type + })); + indexes = indexCount ? ast.indexSignatures.map((is) => ({ + is, + parserKey: compile(parameterFromPropertyKey(is.parameter)), + parserValue: compileField(is.type) + })) : undefined; + } + return properties; + }; + const fallback = fnUntracedEager2(function* (input, options) { if (input === missing) { return missing; } - if (!Array.isArray(input)) { + if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { return yield* fail6(new InvalidType(ast, input, options)); } - if (!elements) { - elements = ast.elements.map((ast) => ({ - ast, - parser: compileConstructorDefault(ast) - })); - rest = ast.rest.map((ast) => ({ - ast, - parser: compileConstructorDefault(ast) - })); - } - const len = input.length; + compileMembers(); + const record = input; + const out = {}; const state = { ast, - getParser, - input, - len, - tailThreshold: Math.max(elementLen, len - tailLen), - output: new globalThis.Array(len), + input: record, + out, issues: undefined, options }; - const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen); + const errorsAllOption = options.errors === "all"; + const onExcessPropertyError = options.onExcessProperty === "error"; const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); - const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, { - concurrency, - end - }); - if (eff) - yield* eff; - if (ast.rest.length === 0 && len > elementLen) { - for (let i = elementLen;i <= len - 1; i++) { - const unexpected = new UnexpectedKey(ast, input[i], options); - const issue = new Pointer([i], unexpected); - if (options.errors === "all") { - if (state.issues) - state.issues.push(issue); - else - state.issues = [issue]; - } else { - return yield* fail6(new Composite(ast, [issue], input, options)); + const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : undefined; + if (onExcessPropertyError) { + expectedKeysSet ??= new Set(expectedKeys); + const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet; + if (indexKeys) { + for (const keys of indexKeys) { + for (const key of keys) + coveredKeys.add(key); + } + } + const inputKeys = Reflect.ownKeys(record); + for (let i = 0;i < inputKeys.length; i++) { + const key = inputKeys[i]; + if (!coveredKeys.has(key)) { + const unexpected = new UnexpectedKey(ast, record[key], options); + const issue = new Pointer([key], unexpected); + if (errorsAllOption) { + if (state.issues) { + state.issues.push(issue); + } else { + state.issues = [issue]; + } + continue; + } else { + return yield* fail6(new Composite(ast, [issue], input, options)); + } + } + } + } + if (hasProperties) { + const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { + concurrency + }); + if (eff) + yield* eff; + } + if (indexCount && concurrency === 1) { + for (let i = 0;i < indexCount; i++) { + const index = indexes[i]; + const parse = index.is.parameter === string2 ? parseStringIndex : parseIndex; + const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); + for (let j = 0;j < keys.length; j++) { + const eff = parse(state, keys[j], index); + if (!effectIsExit(eff)) + yield* eff; + else if (eff._tag === "Failure") + return yield* eff; + } + } + } else if (parseIndexes) { + const keyPairs = empty(); + for (let i = 0;i < indexCount; i++) { + const index = indexes[i]; + const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); + for (let j = 0;j < keys.length; j++) { + keyPairs.push([keys[j], index]); } } + const eff = parseIndexes(state, keyPairs, { + concurrency + }); + if (eff) + yield* eff; } if (state.issues) { return yield* fail6(new Composite(ast, state.issues, input, options)); } - return state.output; + return out; }); + if (indexCount) + return fallback; + const resume = (state, index, pending) => { + const property = properties[index]; + return flatMap3(exit2(pending), (exit) => { + const terminal = stepProperty(state, property, exit); + if (terminal) + return terminal; + const done = () => succeed7(state.out); + const eff = parseProperties(state, properties.slice(index + 1)); + return eff ? flatMapEager2(eff, done) : done(); + }); + }; + return (input, options) => { + if (input === missing) + return missingExit; + if (options.errors === "all" || options.onExcessProperty !== undefined || options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1) { + return fallback(input, options); + } + if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { + return fail6(new InvalidType(ast, input, options)); + } + const props = compileMembers(); + const record = input; + const out = {}; + const state = { + ast, + input: record, + out, + issues: undefined, + options + }; + try { + for (let index = 0;index < props.length; index++) { + const property = props[index]; + const name = property.name; + const hasKey = hasPropertySignature(record, name); + const value = hasKey ? record[name] : missing; + const exit = property.parser(value, options); + if (!effectIsExit(exit)) { + return resume(state, index, exit); + } + if (exit === sameExit) { + if (hasKey) + assignProperty(out, name, value); + continue; + } + const terminal = stepProperty(state, property, exit); + if (terminal) + return terminal; + } + } catch (error) { + return die3(error); + } + return succeed7(out); + }; } - _rebuild(recur, checks, encodingChecks) { - const elements = mapOrSame(this.elements, recur); - const rest = mapOrSame(this.rest, recur); - return elements === this.elements && rest === this.rest && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Arrays(this.isMutable, elements, rest, this.annotations, checks, undefined, this.context, encodingChecks); - } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks); + _rebuild(recur, recurParameter, checks, encodingChecks) { + const props = mapOrSame(this.propertySignatures, (ps) => { + const t = recur(ps.type); + return t === ps.type ? ps : new PropertySignature(ps.name, t); + }); + const indexes = mapOrSame(this.indexSignatures, (is) => { + const p = recurParameter(is.parameter); + const t = recur(is.type); + return p === is.parameter && t === is.type ? is : new IndexSignature(p, t); + }); + return props === this.propertySignatures && indexes === this.indexSignatures && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Objects(props, indexes, this.annotations, checks, undefined, this.context, encodingChecks); } flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks); + return this._rebuild(recur, recur, this.encodingChecks, this.checks); } - getExpected() { - return "array"; + recur(recur, recurParameter = recur) { + return this._rebuild(recur, recurParameter, this.checks, this.encodingChecks); } -}; -var parseArrayOptions = { - onItem(s, item, i) { - const value = i < s.len ? item : missing; - return s.getParser(s.tailThreshold, i).parser(value, s.options); - }, - step(s, item, exit, i) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, i, exit); - } - const value = exit === sameExit ? item : exit[args]; - if (value !== missing) { - s.output[i] = value; - } else { - const p = s.getParser(s.tailThreshold, i); - if (isOptional(p.ast)) - return; - const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); - } - } + getExpected() { + if (this.propertySignatures.length === 0 && this.indexSignatures.length === 0) + return "object | array"; + return "object"; } }; -var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); -var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); -var wrapPropertyKeyIssue = (s, ast, key, exit) => { - if (exit.cause.reasons.length === 0) { - return exit; - } - const issue = getSchemaIssue(exit.cause); - if (issue === undefined) { - return failCause2(map5(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); +function stepProperty(s, p, exit) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, p.name, exit); } - const pointer = new Pointer([key], issue); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(pointer); - else - s.issues = [pointer]; - } else { - return fail4(new Composite(ast, [pointer], s.input, s.options)); + if (exit === sameExit) + return; + const value = exit[args]; + if (value !== missing) { + assignProperty(s.out, p.name, value); + return; } -}; -var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; -function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) { - let stringKeys; - let symbolKeys; - function go(parameter) { - switch (parameter._tag) { - case "String": - case "TemplateLiteral": - return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== undefined); - case "Number": - return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== undefined); - case "Symbol": - return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== undefined); - case "Union": - return [...new Set(parameter.types.flatMap(go))]; - default: - return []; + delete s.out[p.name]; + if (!isOptional(p.type)) { + const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + return; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); } } - return go(parameterFromPropertyKey(toEncoded(parameter))); } -var PropertySignature = class { - name; - type; - constructor(name, type) { - this.name = name; - this.type = type; - } +var parsePropertiesOptions = { + onItem(s, p) { + if (!hasPropertySignature(s.input, p.name)) { + return p.parser(missing, s.options); + } + const value = s.input[p.name]; + assignProperty(s.out, p.name, value); + return p.parser(value, s.options); + }, + step: stepProperty }; -function isIndexSignatureParameterSide(ast) { +var parseProperties = /* @__PURE__ */ iterateEager()(parsePropertiesOptions); +var parsePropertiesConcurrent = /* @__PURE__ */ iterateConcurrent()(parsePropertiesOptions); +function combineChecks(a, b) { + if (!a) + return b; + if (!b) + return a; + return [...a, ...b]; +} +function struct(fields, checks, annotations) { + return new Objects(Reflect.ownKeys(fields).map((key) => { + return new PropertySignature(key, fields[key].ast); + }), [], annotations, checks); +} +function getAST(self) { + return self.ast; +} +function tuple(elements, checks = undefined) { + return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks); +} +function union(members, options, checks) { + return new Union(members.map(getAST), options, undefined, checks); +} +var toCandidate = /* @__PURE__ */ memoizeIdempotent((ast) => { + while (true) { + if (isSuspend(ast)) + return unknown; + const encoding = ast.encoding; + if (!encoding) { + return ast.recur?.(toCandidate, identity) ?? ast; + } + if (encoding.some((link) => link.transformation._tag === "Middleware" && link.transformation.decode !== identity)) + return unknown; + ast = encoding[encoding.length - 1].to; + } +}); +function getCandidateTypes(ast) { switch (ast._tag) { + case "Null": + return ["null"]; + case "Undefined": + return ["undefined"]; case "String": - case "Number": - case "Symbol": case "TemplateLiteral": - return true; - case "Union": - return ast.types.every(isIndexSignatureParameterSide); - default: - return false; - } -} -function isIndexSignatureParameterEncodedSide(ast) { - const encoded = getLastEncoding(ast); - switch (encoded._tag) { - case "String": + return ["string"]; case "Number": + return ["number"]; + case "Boolean": + return ["boolean"]; case "Symbol": - case "TemplateLiteral": - return true; + case "UniqueSymbol": + return ["symbol"]; + case "BigInt": + return ["bigint"]; + case "Arrays": + return ["array"]; + case "ObjectKeyword": + return ["object", "array", "function"]; + case "Objects": + return ast.propertySignatures.length || ast.indexSignatures.length ? ["object"] : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; + case "Enum": + return Array.from(new Set(ast.enums.map(([, v]) => typeof v))); + case "Literal": + return [typeof ast.literal]; case "Union": - return encoded.types.every(isIndexSignatureParameterEncodedSide); + return Array.from(new Set(ast.types.flatMap(getCandidateTypes))); default: - return false; + return ["null", "undefined", "string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; } } -function isIndexSignatureParameter(ast) { - return isIndexSignatureParameterSide(ast) && isIndexSignatureParameterEncodedSide(ast); -} -var IndexSignature = class { - parameter; - type; - constructor(parameter, type) { - if (!isIndexSignatureParameter(parameter)) { - throw new Error(`Invalid index signature parameter ${parameter._tag}`); +function collectSentinels(ast) { + switch (ast._tag) { + default: + return []; + case "Declaration": { + const s = ast.annotations?.[SENTINELS_ANNOTATION_KEY]; + return Array.isArray(s) ? s : []; } - this.parameter = parameter; - this.type = type; - if (isOptional(type) && !containsUndefined(type)) { - throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead."); + case "Objects": + return ast.propertySignatures.flatMap((ps) => { + const type = ps.type; + if (!isOptional(type)) { + if (isLiteral(type)) { + return [{ + key: ps.name, + literal: type.literal + }]; + } + if (isUniqueSymbol(type)) { + return [{ + key: ps.name, + literal: type.symbol + }]; + } + } + return []; + }); + case "Arrays": + return ast.elements.flatMap((e, i) => { + if (!isOptional(e)) { + if (isLiteral(e)) { + return [{ + key: i, + literal: e.literal + }]; + } + if (isUniqueSymbol(e)) { + return [{ + key: i, + literal: e.symbol + }]; + } + } + return []; + }); + case "Union": { + if (ast.types.length === 0) + return []; + const members = ast.types.map((type) => collectSentinels(toCandidate(type))); + return members[0].filter((s) => members.every((sentinels) => sentinels.some((o) => o.key === s.key && o.literal === s.literal))); } + case "Suspend": + return collectSentinels(ast.thunk()); } -}; -var Objects = class extends ASTNodeImpl { - _tag = "Objects"; - propertySignatures; - indexSignatures; - encodingChecks; - constructor(propertySignatures, indexSignatures, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.propertySignatures = propertySignatures; - this.indexSignatures = indexSignatures; - this.encodingChecks = encodingChecks; - const seen = new Set; - const duplicates = []; - for (const propertySignature of propertySignatures) { - const name = propertySignature.name; - if (seen.has(name)) { - duplicates.push(name); +} +var candidateIndexCache = /* @__PURE__ */ new WeakMap; +var emptyCandidates = /* @__PURE__ */ Object.freeze([]); +var hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : (key in input); +function getIndex(types) { + let index = candidateIndexCache.get(types); + if (index) + return index; + let bySentinel; + let sentinelCandidateCount = 0; + let otherwise; + let literalCandidates; + let onlyLiterals = true; + for (let i = 0;i < types.length; i++) { + const a = types[i]; + const encoded = toCandidate(a); + if (isNever2(encoded)) + continue; + if (onlyLiterals) { + if (isLiteral(encoded) || isUniqueSymbol(encoded)) { + literalCandidates ??= new Map; + const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol; + let arr = literalCandidates.get(literal); + if (!arr) + literalCandidates.set(literal, arr = []); + arr.push(a); } else { - seen.add(name); + onlyLiterals = false; + } + } + const sentinels = collectSentinels(encoded); + if (sentinels.length) { + bySentinel ??= new Map; + sentinelCandidateCount++; + for (const { + key, + literal + } of sentinels) { + let entry = bySentinel.get(key); + if (!entry) + bySentinel.set(key, entry = [new Map, new Set]); + entry[1].add(i); + let indexes = entry[0].get(literal); + if (!indexes) + entry[0].set(literal, indexes = new Set); + indexes.add(i); } - } - if (duplicates.length > 0) { - throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); + } else { + otherwise ??= {}; + const candidateTypes = getCandidateTypes(encoded); + for (const t of candidateTypes) + (otherwise[t] ??= []).push(i); } } - getParser(compile, compileConstructorDefault = compile) { - const ast = this; - const expectedKeys = []; - for (const ps of ast.propertySignatures) { - expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name); - } - const hasProperties = expectedKeys.length; - const indexCount = ast.indexSignatures.length; - let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : undefined; - if (!hasProperties && !indexCount) { - return fromRefinement(ast, isNotNullish); + if (onlyLiterals && literalCandidates) { + literalCandidates.forEach(Object.freeze); + index = (input) => literalCandidates.get(input) ?? emptyCandidates; + } else if (bySentinel?.size === 1 && !otherwise) { + const [key, [byValue]] = bySentinel.entries().next().value; + const candidates = byValue; + for (const [literal, indexes] of byValue) { + candidates.set(literal, Object.freeze(Array.from(indexes, (index) => types[index]))); } - let properties; - let indexes; - const finishIndex = (s, key, k2, inputValue, exitValue) => { - if (exitValue._tag === "Failure") { - return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_2; - } - const value = exitValue === sameExit ? inputValue : exitValue[args]; - if (k2 !== missing && value !== missing) { - if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) - return void_2; - assignProperty(s.out, k2, value); - } - return void_2; - }; - const parseIndex = (s, key, index, exitKey) => { - if (!exitKey) { - const eff = index.parserKey(key, s.options); - if (!effectIsExit(eff)) { - return flatMap3(exit2(eff), (exit) => parseIndex(s, key, index, exit)); - } - exitKey = eff; - } - if (exitKey._tag === "Failure") { - return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_2; - } - const k2 = exitKey === sameExit ? key : exitKey[args]; - const inputValue = s.input[key]; - const result = index.parserValue(inputValue, s.options); - return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, k2, inputValue, exit)); - }; - const parseStringIndex = (s, key, index) => { - const inputValue = s.input[key]; - const result = index.parserValue(inputValue, s.options); - return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, key, inputValue, exit)); - }; - const parseIndexes = indexCount ? iterateConcurrent()({ - onItem: (s, [key, index]) => index.is.parameter === string2 ? parseStringIndex(s, key, index) : parseIndex(s, key, index), - step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined - }) : undefined; - const compileMembers = () => { - if (!properties) { - properties = ast.propertySignatures.map((ps) => ({ - parser: compileConstructorDefault(ps.type), - name: ps.name, - type: ps.type - })); - indexes = indexCount ? ast.indexSignatures.map((is) => ({ - is, - parserKey: compile(parameterFromPropertyKey(is.parameter)), - parserValue: compileConstructorDefault(is.type) - })) : undefined; + index = (input, isConstructor) => { + if (isObjectKeyword(input)) { + const value = hasPropertySignature(input, key) ? input[key] : undefined; + if (value !== undefined) + return candidates.get(value) ?? emptyCandidates; + if (isConstructor) + return types; } - return properties; + return emptyCandidates; }; - const fallback = fnUntracedEager2(function* (input, options) { - if (input === missing) { - return missing; - } - if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { - return yield* fail6(new InvalidType(ast, input, options)); + } else if (bySentinel) { + let commonSentinel; + for (const entry of bySentinel) { + if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) { + commonSentinel = entry; } - compileMembers(); - const record = input; - const out = {}; - const state = { - ast, - input: record, - out, - issues: undefined, - options - }; - const errorsAllOption = options.errors === "all"; - const onExcessPropertyError = options.onExcessProperty === "error"; - const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); - const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : undefined; - if (onExcessPropertyError) { - expectedKeysSet ??= new Set(expectedKeys); - const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet; - if (indexKeys) { - for (const keys of indexKeys) { - for (const key of keys) - coveredKeys.add(key); - } + } + index = (input, isConstructor) => { + const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; + const base = otherwise?.[runtimeType] ?? emptyCandidates; + if (!isObjectKeyword(input)) + return base.map((i) => types[i]); + const selected = new Set(base); + let directKey; + if (commonSentinel) { + const [key, [byValue]] = commonSentinel; + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + if (!match) + return base.map((i) => types[i]); + for (const i of match) + selected.add(i); + directKey = key; } - const inputKeys = Reflect.ownKeys(record); - for (let i = 0;i < inputKeys.length; i++) { - const key = inputKeys[i]; - if (!coveredKeys.has(key)) { - const unexpected = new UnexpectedKey(ast, record[key], options); - const issue = new Pointer([key], unexpected); - if (errorsAllOption) { - if (state.issues) { - state.issues.push(issue); - } else { - state.issues = [issue]; - } - continue; - } else { - return yield* fail6(new Composite(ast, [issue], input, options)); + } + if (directKey === undefined) { + for (const [key, [byValue, all]] of bySentinel) { + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + if (match) { + for (const i of match) + selected.add(i); } + } else if (isConstructor) { + for (const i of all) + selected.add(i); } } } - if (hasProperties) { - const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { - concurrency - }); - if (eff) - yield* eff; - } - if (indexCount && concurrency === 1) { - for (let i = 0;i < indexCount; i++) { - const index = indexes[i]; - const parse = index.is.parameter === string2 ? parseStringIndex : parseIndex; - const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); - for (let j = 0;j < keys.length; j++) { - const eff = parse(state, keys[j], index); - if (!effectIsExit(eff)) - yield* eff; - else if (eff._tag === "Failure") - return yield* eff; - } - } - } else if (parseIndexes) { - const keyPairs = empty2(); - for (let i = 0;i < indexCount; i++) { - const index = indexes[i]; - const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); - for (let j = 0;j < keys.length; j++) { - keyPairs.push([keys[j], index]); + for (const [key, [byValue, all]] of bySentinel) { + if (key === directKey) + continue; + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + for (const i of selected) { + if (all.has(i) && !match?.has(i)) + selected.delete(i); } } - const eff = parseIndexes(state, keyPairs, { - concurrency - }); - if (eff) - yield* eff; - } - if (state.issues) { - return yield* fail6(new Composite(ast, state.issues, input, options)); } - return out; - }); - if (indexCount) - return fallback; - const resume = (state, index, pending) => { - const property = properties[index]; - return flatMap3(exit2(pending), (exit) => { - const terminal = stepProperty(state, property, exit); - if (terminal) - return terminal; - const done = () => succeed9(state.out); - const eff = parseProperties(state, properties.slice(index + 1)); - return eff ? flatMapEager2(eff, done) : done(); - }); + return Array.from(selected).sort((a, b) => a - b).map((i) => types[i]); + }; + } else { + index = (input) => { + const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; + return (otherwise?.[runtimeType] ?? emptyCandidates).map((i) => types[i]).filter(filterLiterals(input)); }; + } + candidateIndexCache.set(types, index); + return index; +} +function filterLiterals(input) { + return (ast) => { + const encoded = toCandidate(ast); + return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true; + }; +} +function getCandidates(input, types, isConstructor = false) { + return getIndex(types)(input, isConstructor); +} +var Union = class extends ASTNodeImpl { + _tag = "Union"; + types; + options; + encodingChecks; + constructor(types, options, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.types = types; + this.options = options; + this.encodingChecks = encodingChecks; + } + getParser(compile, compileField) { + const ast = this; return (input, options) => { - if (input === missing) + if (input === missing) { return missingExit; - if (options.errors === "all" || options.onExcessProperty !== undefined || options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1) { - return fallback(input, options); } - if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { - return fail6(new InvalidType(ast, input, options)); + const candidates = getCandidates(input, ast.types, compileField !== undefined); + if (candidates.length === 0) { + return fail6(new AnyOf(ast, [], input, options)); + } + if (candidates.length === 1) { + const result = compile(candidates[0])(input, options); + if (result._tag === "Success") + return result; + return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchCause2(result, (cause) => failSingleUnionCandidate(ast, cause, input, options)); } - const props = compileMembers(); - const record = input; - const out = {}; const state = { ast, - input: record, - out, + compile, + input, + out: undefined, + successes: ast.options?.mode === "oneOf" ? [] : undefined, issues: undefined, options }; - try { - for (let index = 0;index < props.length; index++) { - const property = props[index]; - const name = property.name; - const hasKey = hasPropertySignature(record, name); - const value = hasKey ? record[name] : missing; - const exit = property.parser(value, options); - if (!effectIsExit(exit)) { - return resume(state, index, exit); + const eff = parseUnion(state, candidates); + if (!eff) { + if (state.out) + return state.out; + return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + } + return flatMapEager2(eff, (_) => { + if (state.out === sameExit) + return succeed6(input); + if (state.out) + return state.out; + return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + }); + }; + } + _rebuild(recur, checks, encodingChecks) { + const types = mapOrSame(this.types, recur); + return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks); + } + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks); + } + matchPart(s, options) { + for (const type of this.types) { + const out = type.matchPart(s, options); + if (out !== undefined) + return out; + } + return; + } + getExpected(getExpected) { + const expected = this.annotations?.expected; + if (typeof expected === "string") + return expected; + if (this.types.length === 0) + return "never"; + const types = this.types.map((type) => { + const encoded = toEncoded(type); + switch (encoded._tag) { + case "Arrays": { + const literals = encoded.elements.filter(isLiteral); + if (literals.length > 0) { + return `${formatIsMutable(encoded.isMutable)}[ ${literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ")}, ... ]`; } - if (exit === sameExit) { - if (hasKey) - assignProperty(out, name, value); - continue; + break; + } + case "Objects": { + const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)); + if (literals.length > 0) { + return `{ ${literals.map((ps) => `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${formatIsOptional(ps.type.context?.isOptional)}: ${getExpected(ps.type)}`).join(", ")}, ... }`; } - const terminal = stepProperty(state, property, exit); - if (terminal) - return terminal; + break; } - } catch (error) { - return die2(error); } - return succeed9(out); - }; - } - _rebuild(recur, recurParameter, checks, encodingChecks) { - const props = mapOrSame(this.propertySignatures, (ps) => { - const t = recur(ps.type); - return t === ps.type ? ps : new PropertySignature(ps.name, t); + return getExpected(encoded); }); - const indexes = mapOrSame(this.indexSignatures, (is) => { - const p = recurParameter(is.parameter); - const t = recur(is.type); - return p === is.parameter && t === is.type ? is : new IndexSignature(p, t); + return Array.from(new Set(types)).join(" | "); + } +}; +function failSingleUnionCandidate(ast, cause, input, options) { + const issue = getSchemaIssue(cause); + if (!issue) + return failCause2(cause); + return fail5(new AnyOf(ast, [issue], input, options)); +} +var parseUnion = /* @__PURE__ */ iterateEager()({ + onItem(s, ast) { + const parser = s.compile(ast); + return parser(s.input, s.options); + }, + step(s, candidate, exit) { + if (exit._tag === "Failure") { + const issue = getSchemaIssue(exit.cause); + if (issue === undefined) { + return exit; + } + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + if (s.out && s.successes) { + s.successes.push(candidate); + return fail5(new OneOf(s.ast, s.successes, s.input, s.options)); + } + s.out = exit; + if (s.successes) { + s.successes.push(candidate); + } else { + return void_2; + } + } + } +}); +var nonFiniteLiterals = /* @__PURE__ */ new Union([/* @__PURE__ */ new Literal("Infinity"), /* @__PURE__ */ new Literal("-Infinity"), /* @__PURE__ */ new Literal("NaN")]); +function formatIsMutable(isMutable) { + return isMutable ? "" : "readonly "; +} +function formatIsOptional(isOptional) { + return isOptional ? "?" : ""; +} +var Filter2 = class extends Class { + _tag = "Filter"; + run; + annotations; + aborted; + constructor(run, annotations = undefined, aborted = false) { + super(); + this.run = run; + this.annotations = annotations; + this.aborted = aborted; + } + annotate(annotations) { + return new Filter2(this.run, { + ...this.annotations, + ...annotations + }, this.aborted); + } + abort() { + return new Filter2(this.run, this.annotations, true); + } + and(other, annotations) { + return new FilterGroup([this, other], annotations); + } +}; +var FilterGroup = class extends Class { + _tag = "FilterGroup"; + checks; + annotations; + constructor(checks, annotations = undefined) { + super(); + this.checks = checks; + this.annotations = annotations; + } + annotate(annotations) { + return new FilterGroup(this.checks, { + ...this.annotations, + ...annotations }); - return props === this.propertySignatures && indexes === this.indexSignatures && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Objects(props, indexes, this.annotations, checks, undefined, this.context, encodingChecks); } - flip(recur) { - return this._rebuild(recur, recur, this.encodingChecks, this.checks); + and(other, annotations) { + return new FilterGroup([this, other], annotations); + } +}; +function makeFilter(filter, annotations, aborted = false) { + return new Filter2((input, ast, options) => normalizeFilterOutput(ast, filter(input, ast, options), input, options), annotations, aborted); +} +function isFinite2(annotations) { + return makeFilter((n) => globalThis.Number.isFinite(n), { + expected: "a finite number", + representation: { + id: "effect/schema/isFinite", + payload: null + }, + toJsonSchema: () => ({ + type: "number" + }), + toCode: () => ({ + runtime: "Schema.isFinite()" + }), + arbitraryConstraint: { + number: "finite" + }, + ...annotations + }); +} +var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]); +var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n)))); +function isPattern(regExp, annotations) { + const source = regExp.source; + const pattern = new globalThis.RegExp(source, regExp.flags); + return makeFilter((s) => { + pattern.lastIndex = 0; + return pattern.test(s); + }, { + expected: `a string matching the RegExp ${source}`, + representation: { + id: "effect/schema/isPattern", + payload: { + source, + flags: regExp.flags + } + }, + toJsonSchema: () => ({ + pattern: source + }), + arbitraryConstraint: { + patterns: [{ + source: regExp.source, + flags: regExp.flags + }] + }, + ...annotations + }); +} +function modifyOwnPropertyDescriptors(ast, f) { + const d = Object.getOwnPropertyDescriptors(ast); + f(d); + return Object.create(Object.getPrototypeOf(ast), d); +} +var contextOwners = /* @__PURE__ */ new WeakMap; +function getContextOwner(ast) { + return contextOwners.get(ast) ?? ast; +} +function replaceEncoding(ast, encoding) { + if (ast.encoding === encoding) { + return ast; + } + return modifyOwnPropertyDescriptors(ast, (d) => { + d.encoding.value = encoding; + }); +} +function replaceContext(ast, context) { + if (ast.context === context) { + return ast; } - recur(recur, recurParameter = recur) { - return this._rebuild(recur, recurParameter, this.checks, this.encodingChecks); + const owner = getContextOwner(ast); + if (owner.context === context) { + return owner; } - getExpected() { - if (this.propertySignatures.length === 0 && this.indexSignatures.length === 0) - return "object | array"; - return "object"; + const out = modifyOwnPropertyDescriptors(ast, (d) => { + d.context.value = context; + }); + contextOwners.set(out, owner); + return out; +} +function getLastEncoding(ast) { + return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast; +} +function annotate(ast, annotations) { + if (ast.checks) { + const last = ast.checks[ast.checks.length - 1]; + return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations))); } -}; -function stepProperty(s, p, exit) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, p.name, exit); + return modifyOwnPropertyDescriptors(ast, (d) => { + d.annotations.value = { + ...d.annotations.value, + ...annotations + }; + }); +} +function replaceChecks(ast, checks) { + if (ast._tag === "Suspend" && checks) { + throw new Error("Cannot add checks to Suspend"); } - if (exit === sameExit) - return; - const value = exit[args]; - if (value !== missing) { - assignProperty(s.out, p.name, value); - return; + if (ast.checks === checks) { + return ast; } - delete s.out[p.name]; - if (!isOptional(p.type)) { - const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - return; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); + return modifyOwnPropertyDescriptors(ast, (d) => { + d.checks.value = checks; + }); +} +function appendChecks(ast, checks) { + return replaceChecks(ast, combineChecks(ast.checks, checks)); +} +function mapLink(link, f) { + const to = f(link.to); + return to === link.to ? link : new Link(to, link.transformation); +} +function updateLastLink(encoding, f) { + const links = encoding; + const last = links[links.length - 1]; + const out = mapLink(last, f); + return out === last ? encoding : append(encoding.slice(0, encoding.length - 1), out); +} +function applyToLastLink(f) { + return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast; +} +function applyToSelfOrLastLinkEncodingIdempotent(f, options) { + function out(ast) { + if (ast.encoding) { + const last = ast.encoding[ast.encoding.length - 1]; + return options?.stopAt?.(last) ? ast : replaceEncoding(ast, updateLastLink(ast.encoding, out)); } + return f(ast); } + return memoizeIdempotent(out); } -var parsePropertiesOptions = { - onItem(s, p) { - if (!hasPropertySignature(s.input, p.name)) { - return p.parser(missing, s.options); +function appendTransformation(from, transformation, to) { + const link = new Link(from, transformation); + return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]); +} +function mapOrSame(as, f) { + let changed = false; + const out = new Array(as.length); + for (let i = 0;i < as.length; i++) { + const a = as[i]; + const fa = f(a); + if (fa !== a) { + changed = true; } - const value = s.input[p.name]; - assignProperty(s.out, p.name, value); - return p.parser(value, s.options); - }, - step: stepProperty -}; -var parseProperties = /* @__PURE__ */ iterateEager()(parsePropertiesOptions); -var parsePropertiesConcurrent = /* @__PURE__ */ iterateConcurrent()(parsePropertiesOptions); -function combineChecks(a, b) { - if (!a) - return b; - if (!b) - return a; - return [...a, ...b]; + out[i] = fa; + } + return changed ? out : as; } -function struct(fields, checks, annotations) { - return new Objects(Reflect.ownKeys(fields).map((key) => { - return new PropertySignature(key, fields[key].ast); - }), [], annotations, checks); +function annotateKey(ast, annotations) { + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, { + ...ast.context.annotations, + ...annotations + }) : new Context(false, false, undefined, annotations); + return replaceContext(ast, context); } -function getAST(self) { - return self.ast; +var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { + const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false); + return optionalKeyLastLink(replaceContext(ast, context)); +}); +var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); +function withConstructorDefault(ast, defaultValue) { + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue); + return replaceContext(ast, context); } -function tuple(elements, checks = undefined) { - return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks); +function decodeTo(from, to, transformation) { + return appendTransformation(from, transformation, to); } -function union(members, options, checks) { - return new Union(members.map(getAST), options, undefined, checks); +function isOptional(ast) { + return ast.context?.isOptional ?? false; } -var toCandidate = /* @__PURE__ */ memoizeIdempotent((ast) => { - while (true) { - if (isSuspend(ast)) - return unknown; - const encoding = ast.encoding; - if (!encoding) { - return ast.recur?.(toCandidate, identity) ?? ast; - } - if (encoding.some((link) => link.transformation._tag === "Middleware" && link.transformation.decode !== identity)) - return unknown; - ast = encoding[encoding.length - 1].to; +function isStructuralCheck(check) { + return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck); +} +function extractStructuralChecks(checks) { + function extract(check) { + if (isStructuralCheck(check)) + return [check]; + return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []; + } + const out = checks.flatMap(extract); + return isArrayNonEmpty2(out) ? out : undefined; +} +var toType = /* @__PURE__ */ memoizeIdempotent((ast) => { + if (ast.encoding) { + return toType(replaceEncoding(ast, undefined)); + } + const out = ast; + const type = out.recur?.(toType) ?? out; + const encodingChecks = type.encodingChecks; + if (encodingChecks) { + const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : undefined; + return modifyOwnPropertyDescriptors(type, (d) => { + d.encodingChecks.value = undefined; + d.checks.value = combineChecks(type.checks, checks); + }); } + return type; }); -function getCandidateTypes(ast) { +var toEncoded = /* @__PURE__ */ memoizeIdempotent((ast) => { + return toType(flip2(ast)); +}); +function flipEncoding(ast, encoding) { + const links = encoding; + const len = links.length; + const last = links[len - 1]; + const ls = [new Link(flip2(replaceEncoding(ast, undefined)), links[0].transformation.flip())]; + for (let i = 1;i < len; i++) { + ls.unshift(new Link(flip2(links[i - 1].to), links[i].transformation.flip())); + } + const to = flip2(last.to); + if (to.encoding) { + return replaceEncoding(to, [...to.encoding, ...ls]); + } else { + return replaceEncoding(to, ls); + } +} +var flip2 = /* @__PURE__ */ memoize((ast) => { + if (ast.encoding) { + return flipEncoding(ast, ast.encoding); + } + const out = ast; + return out.flip?.(flip2) ?? out.recur?.(flip2) ?? out; +}); +function containsUndefined(ast) { switch (ast._tag) { - case "Null": - return ["null"]; case "Undefined": - return ["undefined"]; - case "String": - case "TemplateLiteral": - return ["string"]; - case "Number": - return ["number"]; - case "Boolean": - return ["boolean"]; - case "Symbol": - case "UniqueSymbol": - return ["symbol"]; - case "BigInt": - return ["bigint"]; - case "Arrays": - return ["array"]; - case "ObjectKeyword": - return ["object", "array", "function"]; - case "Objects": - return ast.propertySignatures.length || ast.indexSignatures.length ? ["object"] : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; - case "Enum": - return Array.from(new Set(ast.enums.map(([, v]) => typeof v))); - case "Literal": - return [typeof ast.literal]; + return true; case "Union": - return Array.from(new Set(ast.types.flatMap(getCandidateTypes))); + return ast.types.some(containsUndefined); default: - return ["null", "undefined", "string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; + return false; } } -function collectSentinels(ast) { +function fromConst(ast, value) { + const succeed = value === 0 ? sameExit : succeed7(value); + return (input, options) => { + if (input === missing) + return missingExit; + if (input === value) + return succeed; + return fail6(new InvalidType(ast, input, options)); + }; +} +function fromRefinement(ast, refinement) { + return (input, options) => { + if (input === missing) + return missingExit; + if (refinement(input)) + return sameExit; + return fail6(new InvalidType(ast, input, options)); + }; +} +var parameterFromPropertyKey = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => { switch (ast._tag) { default: - return []; - case "Declaration": { - const s = ast.annotations?.[SENTINELS_ANNOTATION_KEY]; - return Array.isArray(s) ? s : []; - } - case "Objects": - return ast.propertySignatures.flatMap((ps) => { - const type = ps.type; - if (!isOptional(type)) { - if (isLiteral(type)) { - return [{ - key: ps.name, - literal: type.literal - }]; - } - if (isUniqueSymbol(type)) { - return [{ - key: ps.name, - literal: type.symbol - }]; - } - } - return []; - }); - case "Arrays": - return ast.elements.flatMap((e, i) => { - if (!isOptional(e)) { - if (isLiteral(e)) { - return [{ - key: i, - literal: e.literal - }]; - } - if (isUniqueSymbol(e)) { - return [{ - key: i, - literal: e.symbol - }]; - } - } - return []; - }); - case "Union": { - if (ast.types.length === 0) - return []; - const members = ast.types.map((type) => collectSentinels(toCandidate(type))); - return members[0].filter((s) => members.every((sentinels) => sentinels.some((o) => o.key === s.key && o.literal === s.literal))); - } - case "Suspend": - return collectSentinels(ast.thunk()); + return ast; + case "Number": + return ast.toCodecStringTree(); + case "Union": + return ast.recur(parameterFromPropertyKey); } +}); +var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`); +var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`); +function isStringFinite(annotations) { + return isPattern(isStringFiniteRegExp, { + expected: "a string representing a finite number", + representation: { + id: "effect/schema/isStringFinite", + payload: null + }, + toJsonSchema: () => ({ + pattern: isStringFiniteRegExp.source + }), + ...annotations + }); } -var candidateIndexCache = /* @__PURE__ */ new WeakMap; -var emptyCandidates = /* @__PURE__ */ Object.freeze([]); -var hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : (key in input); -function getIndex(types) { - let index = candidateIndexCache.get(types); - if (index) - return index; - let bySentinel; - let sentinelCandidateCount = 0; - let otherwise; - let literalCandidates; - let onlyLiterals = true; - for (let i = 0;i < types.length; i++) { - const a = types[i]; - const encoded = toCandidate(a); - if (isNever2(encoded)) - continue; - if (onlyLiterals) { - if (isLiteral(encoded) || isUniqueSymbol(encoded)) { - literalCandidates ??= new Map; - const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol; - let arr = literalCandidates.get(literal); - if (!arr) - literalCandidates.set(literal, arr = []); - arr.push(a); - } else { - onlyLiterals = false; - } - } - const sentinels = collectSentinels(encoded); - if (sentinels.length) { - bySentinel ??= new Map; - sentinelCandidateCount++; - for (const { - key, - literal - } of sentinels) { - let entry = bySentinel.get(key); - if (!entry) - bySentinel.set(key, entry = [new Map, new Set]); - entry[1].add(i); - let indexes = entry[0].get(literal); - if (!indexes) - entry[0].set(literal, indexes = new Set); - indexes.add(i); +var finiteString = /* @__PURE__ */ appendChecks(string2, [/* @__PURE__ */ isStringFinite()]); +var finiteToString = /* @__PURE__ */ new Link(finiteString, numberFromString); +var numberToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finiteString, nonFiniteLiterals]), numberFromString); +var BIGINT_PATTERN = "-?\\d+"; +var isStringBigIntRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${BIGINT_PATTERN}$`); +var REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"; +var isStringSymbolRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${REGEXP_PATTERN}$`); +function collectIssues(checks, value, issues, ast, options) { + for (let i = 0;i < checks.length; i++) { + const check = checks[i]; + if (check._tag === "FilterGroup") { + issues = collectIssues(check.checks, value, issues, ast, options); + if (issues && (options.errors !== "all" || issues[issues.length - 1].filter.aborted)) { + return issues; } } else { - otherwise ??= {}; - const candidateTypes = getCandidateTypes(encoded); - for (const t of candidateTypes) - (otherwise[t] ??= []).push(i); - } - } - if (onlyLiterals && literalCandidates) { - literalCandidates.forEach(Object.freeze); - index = (input) => literalCandidates.get(input) ?? emptyCandidates; - } else if (bySentinel?.size === 1 && !otherwise) { - const [key, [byValue]] = bySentinel.entries().next().value; - const candidates = byValue; - for (const [literal, indexes] of byValue) { - candidates.set(literal, Object.freeze(Array.from(indexes, (index) => types[index]))); - } - index = (input, isConstructor) => { - if (isObjectKeyword(input)) { - const value = hasPropertySignature(input, key) ? input[key] : undefined; - if (value !== undefined) - return candidates.get(value) ?? emptyCandidates; - if (isConstructor) - return types; - } - return emptyCandidates; - }; - } else if (bySentinel) { - let commonSentinel; - for (const entry of bySentinel) { - if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) { - commonSentinel = entry; + const issue = check.run(value, ast, options); + if (issue) { + const filter = new Filter(check, issue, value, options); + if (issues) + issues.push(filter); + else + issues = [filter]; + if (options.errors !== "all" || check.aborted) { + return issues; + } } } - index = (input, isConstructor) => { - const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; - const base = otherwise?.[runtimeType] ?? emptyCandidates; - if (!isObjectKeyword(input)) - return base.map((i) => types[i]); - const selected = new Set(base); - let directKey; - if (commonSentinel) { - const [key, [byValue]] = commonSentinel; - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - if (!match) - return base.map((i) => types[i]); - for (const i of match) - selected.add(i); - directKey = key; + } + return issues; +} +function getConstructorDescriptor(ast) { + if (!isDeclaration(ast)) + return; + const getDescriptor = ast.annotations?.[CONSTRUCTOR_ANNOTATION_KEY]; + return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; +} +function isJsonLeaf(u) { + return u === null || typeof u === "string" || typeof u === "boolean" || typeof u === "number" && globalThis.Number.isFinite(u); +} +function isStringTreeLeaf(u) { + return u === undefined || typeof u === "string"; +} +function isTree(u, isLeaf) { + const cache = new WeakMap; + const stack = []; + outer: + while (true) { + if (typeof u !== "object" || u === null) { + if (!isLeaf(u)) { + return false; } - } - if (directKey === undefined) { - for (const [key, [byValue, all]] of bySentinel) { - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - if (match) { - for (const i of match) - selected.add(i); + } else { + const value = u; + const cached = cache.get(value); + if (cached === false) { + return false; + } + if (cached === undefined) { + const isArray = Array.isArray(value); + if (!isArray) { + const prototype = Object.getPrototypeOf(value); + if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) { + return false; } - } else if (isConstructor) { - for (const i of all) - selected.add(i); } + cache.set(value, false); + stack.push({ + value, + keys: isArray ? value.length : Object.keys(value), + index: 0 + }); } } - for (const [key, [byValue, all]] of bySentinel) { - if (key === directKey) - continue; - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - for (const i of selected) { - if (all.has(i) && !match?.has(i)) - selected.delete(i); + while (stack.length > 0) { + const frame = stack[stack.length - 1]; + const keys = frame.keys; + if (typeof keys === "number") { + if (frame.index < keys) { + u = frame.value[frame.index++]; + continue outer; } + } else if (frame.index < keys.length) { + u = frame.value[keys[frame.index++]]; + continue outer; } + cache.set(frame.value, true); + stack.pop(); } - return Array.from(selected).sort((a, b) => a - b).map((i) => types[i]); - }; - } else { - index = (input) => { - const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; - return (otherwise?.[runtimeType] ?? emptyCandidates).map((i) => types[i]).filter(filterLiterals(input)); - }; - } - candidateIndexCache.set(types, index); - return index; + return true; + } } -function filterLiterals(input) { - return (ast) => { - const encoded = toCandidate(ast); - return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true; - }; +function isJson(u) { + return isTree(u, isJsonLeaf); } -function getCandidates(input, types, isConstructor = false) { - return getIndex(types)(input, isConstructor); +var Json = /* @__PURE__ */ new Declaration([], () => (input, ast, options) => isJson(input) ? sameExit : fail6(new InvalidType(ast, input, options)), { + representation: { + id: "effect/schema/Json", + payload: null + }, + expected: "JSON value", + toCodecJson: () => { + return; + }, + toCodecStringTree: () => unknownToStringTree +}); +function isStringTree(u) { + return isTree(u, isStringTreeLeaf); } -var Union = class extends ASTNodeImpl { - _tag = "Union"; - types; - options; - encodingChecks; - constructor(types, options, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.types = types; - this.options = options; - this.encodingChecks = encodingChecks; +var StringTree = /* @__PURE__ */ new Declaration([], () => (input, ast, options) => isStringTree(input) ? sameExit : fail6(new InvalidType(ast, input, options)), { + expected: "StringTree", + toCodecStringTree: () => { + return; } - getParser(compile, compileConstructorDefault) { - const ast = this; - return (input, options) => { - if (input === missing) { - return missingExit; - } - const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined); - if (candidates.length === 0) { - return fail6(new AnyOf(ast, [], input, options)); - } - if (candidates.length === 1) { - const result = compile(candidates[0])(input, options); - if (result._tag === "Success") - return result; - return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchCause2(result, (cause) => failSingleUnionCandidate(ast, cause, input, options)); - } - const state = { - ast, - compile, - input, - out: undefined, - successes: ast.options?.mode === "oneOf" ? [] : undefined, - issues: undefined, - options - }; - const eff = parseUnion(state, candidates); - if (!eff) { - if (state.out) - return state.out; - return fail6(new AnyOf(ast, state.issues ?? [], input, options)); - } - return flatMapEager2(eff, (_) => { - if (state.out === sameExit) - return succeed6(input); - if (state.out) - return state.out; - return fail6(new AnyOf(ast, state.issues ?? [], input, options)); - }); +}); +var unknownToStringTree = /* @__PURE__ */ new Link(StringTree, /* @__PURE__ */ passthrough2()); + +// node_modules/effect/dist/Brand.js +function nominal() { + return Object.assign((input) => input, { + option: (input) => some2(input), + result: (input) => succeed2(input), + is: (_) => true + }); +} +// node_modules/effect/dist/Fiber.js +var join = fiberJoin; +var interrupt3 = fiberInterrupt; +var runIn = fiberRunIn; + +// node_modules/effect/dist/Latch.js +var makeUnsafe4 = makeLatchUnsafe; +var make6 = makeLatch; + +// node_modules/effect/dist/MutableRef.js +var TypeId10 = "~effect/MutableRef"; +var MutableRefProto = { + [TypeId10]: TypeId10, + ...PipeInspectableProto, + toJSON() { + return { + _id: "MutableRef", + current: toJson(this.current) }; } - _rebuild(recur, checks, encodingChecks) { - const types = mapOrSame(this.types, recur); - return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks); +}; +var make7 = (value) => { + const ref = Object.create(MutableRefProto); + ref.current = value; + return ref; +}; + +// node_modules/effect/dist/MutableList.js +var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); +var make8 = () => ({ + head: undefined, + tail: undefined, + length: 0 +}); +var emptyBucket = () => ({ + array: [], + mutable: true, + offset: 0, + next: undefined +}); +var append2 = (self, message) => { + if (!self.tail) { + self.head = self.tail = emptyBucket(); + } else if (!self.tail.mutable) { + self.tail.next = emptyBucket(); + self.tail = self.tail.next; } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks); + self.tail.array.push(message); + self.length++; +}; +var clear = (self) => { + self.head = self.tail = undefined; + self.length = 0; +}; +var takeN = (self, n) => { + n = normalize(n); + if (n <= 0 || !self.head) + return []; + n = Math.min(n, self.length); + if (n === self.length && self.head?.offset === 0 && !self.head.next) { + const array = self.head.array; + clear(self); + return array; } - flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks); + const array = new Array(n); + let index = 0; + let chunk = self.head; + while (chunk) { + while (chunk.offset < chunk.array.length) { + array[index++] = chunk.array[chunk.offset]; + if (chunk.mutable) + chunk.array[chunk.offset] = undefined; + chunk.offset++; + if (index === n) { + self.head = chunk; + self.length -= n; + if (self.length === 0) + clear(self); + return array; + } + } + chunk = chunk.next; + } + clear(self); + return array; +}; +var take = (self) => { + if (!self.head) + return Empty; + const message = self.head.array[self.head.offset]; + if (self.head.mutable) + self.head.array[self.head.offset] = undefined; + self.head.offset++; + self.length--; + if (self.head.offset === self.head.array.length) { + if (self.head.next) { + self.head = self.head.next; + } else { + clear(self); + } + } + return message; +}; + +// node_modules/effect/dist/Queue.js +var TypeId11 = "~effect/Queue"; +var EnqueueTypeId = "~effect/Queue/Enqueue"; +var DequeueTypeId = "~effect/Queue/Dequeue"; +var variance = { + _A: identity, + _E: identity +}; +var QueueProto = { + [TypeId11]: variance, + [EnqueueTypeId]: variance, + [DequeueTypeId]: variance, + ...PipeInspectableProto, + toJSON() { + return { + _id: "effect/Queue", + state: this.state._tag, + size: sizeUnsafe(this) + }; + } +}; +var make9 = (options) => withFiber((fiber) => { + const self = Object.create(QueueProto); + self.dispatcher = fiber.currentDispatcher; + self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; + self.strategy = options?.strategy ?? "suspend"; + self.messages = make8(); + self.scheduleRunning = false; + self.state = { + _tag: "Open", + takers: new Set, + offers: new Set, + awaiters: new Set + }; + return succeed3(self); +}); +var bounded = (capacity) => make9({ + capacity +}); +var offer = (self, message) => suspend(() => { + if (self.state._tag !== "Open") { + return exitFalse; + } else if (self.messages.length >= self.capacity) { + switch (self.strategy) { + case "dropping": + return exitFalse; + case "suspend": + if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return exitTrue; + } + return offerRemainingSingle(self, message); + case "sliding": + take(self.messages); + append2(self.messages, message); + return exitTrue; + } } - matchPart(s, options) { - for (const type of this.types) { - const out = type.matchPart(s, options); - if (out !== undefined) - return out; + append2(self.messages, message); + scheduleReleaseTaker(self); + return exitTrue; +}); +var offerUnsafe = (self, message) => { + if (self.state._tag !== "Open") { + return false; + } else if (self.messages.length >= self.capacity) { + if (self.strategy === "sliding") { + take(self.messages); + append2(self.messages, message); + return true; + } else if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return true; } - return; + return false; } - getExpected(getExpected) { - const expected = this.annotations?.expected; - if (typeof expected === "string") - return expected; - if (this.types.length === 0) - return "never"; - const types = this.types.map((type) => { - const encoded = toEncoded(type); - switch (encoded._tag) { - case "Arrays": { - const literals = encoded.elements.filter(isLiteral); - if (literals.length > 0) { - return `${formatIsMutable(encoded.isMutable)}[ ${literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ")}, ... ]`; - } - break; - } - case "Objects": { - const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)); - if (literals.length > 0) { - return `{ ${literals.map((ps) => `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${formatIsOptional(ps.type.context?.isOptional)}: ${getExpected(ps.type)}`).join(", ")}, ... }`; - } - break; - } - } - return getExpected(encoded); - }); - return Array.from(new Set(types)).join(" | "); + append2(self.messages, message); + scheduleReleaseTaker(self); + return true; +}; +var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); +var failCauseUnsafe = (self, cause) => { + if (self.state._tag !== "Open") { + return false; + } + const exit = exitFailCause(cause); + const fail = exitZipRight(exit, exitFailDone); + if (self.state.offers.size === 0 && self.messages.length === 0) { + finalize(self, fail); + return true; } + self.state = { + ...self.state, + _tag: "Closing", + exit: fail + }; + return true; }; -function failSingleUnionCandidate(ast, cause, input, options) { - const issue = getSchemaIssue(cause); - if (!issue) - return failCause2(cause); - return fail4(new AnyOf(ast, [issue], input, options)); -} -var parseUnion = /* @__PURE__ */ iterateEager()({ - onItem(s, ast) { - const parser = s.compile(ast); - return parser(s.input, s.options); - }, - step(s, candidate, exit) { - if (exit._tag === "Failure") { - const issue = getSchemaIssue(exit.cause); - if (issue === undefined) { - return exit; - } - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - if (s.out && s.successes) { - s.successes.push(candidate); - return fail4(new OneOf(s.ast, s.successes, s.input, s.options)); - } - s.out = exit; - if (s.successes) { - s.successes.push(candidate); +var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); +var shutdown = (self) => sync(() => { + if (self.state._tag === "Done") { + return true; + } + clear(self.messages); + const offers = self.state.offers; + finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); + if (offers.size > 0) { + for (const entry of offers) { + if (entry._tag === "Single") { + entry.resume(exitFalse); } else { - return void_2; + entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); } } + offers.clear(); } + return true; }); -var nonFiniteLiterals = /* @__PURE__ */ new Union([/* @__PURE__ */ new Literal("Infinity"), /* @__PURE__ */ new Literal("-Infinity"), /* @__PURE__ */ new Literal("NaN")]); -function formatIsMutable(isMutable) { - return isMutable ? "" : "readonly "; -} -function formatIsOptional(isOptional) { - return isOptional ? "?" : ""; -} -var Filter2 = class extends Class { - _tag = "Filter"; - run; - annotations; - aborted; - constructor(run, annotations = undefined, aborted = false) { - super(); - this.run = run; - this.annotations = annotations; - this.aborted = aborted; - } - annotate(annotations) { - return new Filter2(this.run, { - ...this.annotations, - ...annotations - }, this.aborted); - } - abort() { - return new Filter2(this.run, this.annotations, true); - } - and(other, annotations) { - return new FilterGroup([this, other], annotations); - } +var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); +var takeBetween = (self, min, max) => { + min = normalize(min); + max = normalize(max); + return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); }; -var FilterGroup = class extends Class { - _tag = "FilterGroup"; - checks; - annotations; - constructor(checks, annotations = undefined) { - super(); - this.checks = checks; - this.annotations = annotations; +var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); +var poll = (self) => suspend(() => { + const result = takeUnsafe(self); + if (result === undefined) { + return succeed3(none2()); } - annotate(annotations) { - return new FilterGroup(this.checks, { - ...this.annotations, - ...annotations - }); + if (result._tag === "Success") { + return succeed3(some2(result.value)); } - and(other, annotations) { - return new FilterGroup([this, other], annotations); + return succeed3(none2()); +}); +var takeUnsafe = (self) => { + if (self.state._tag === "Done") { + return self.state.exit; + } + if (self.messages.length > 0) { + const message = take(self.messages); + releaseCapacity(self); + return exitSucceed(message); + } else if (self.capacity <= 0 && self.state.offers.size > 0) { + const message = takeOfferUnsafe(self.state.offers); + releaseCapacity(self); + return exitSucceed(message); } + return; }; -function makeFilter(filter, annotations, aborted = false) { - return new Filter2((input, ast, options) => normalizeFilterOutput(ast, filter(input, ast, options), input, options), annotations, aborted); -} -function isFinite2(annotations) { - return makeFilter((n) => globalThis.Number.isFinite(n), { - expected: "a finite number", - representation: { - id: "effect/schema/isFinite", - payload: null - }, - toJsonSchema: () => ({ - type: "number" - }), - toCode: () => ({ - runtime: "Schema.isFinite()" - }), - arbitraryConstraint: { - number: "finite" - }, - ...annotations - }); -} -var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]); -var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n)))); -function isPattern(regExp, annotations) { - const source = regExp.source; - const pattern = new globalThis.RegExp(source, regExp.flags); - return makeFilter((s) => { - pattern.lastIndex = 0; - return pattern.test(s); - }, { - expected: `a string matching the RegExp ${source}`, - representation: { - id: "effect/schema/isPattern", - payload: { - source, - flags: regExp.flags - } - }, - toJsonSchema: () => ({ - pattern: source - }), - arbitraryConstraint: { - patterns: [{ - source: regExp.source, - flags: regExp.flags - }] - }, - ...annotations - }); -} -function modifyOwnPropertyDescriptors(ast, f) { - const d = Object.getOwnPropertyDescriptors(ast); - f(d); - return Object.create(Object.getPrototypeOf(ast), d); -} -var contextOwners = /* @__PURE__ */ new WeakMap; -function getContextOwner(ast) { - return contextOwners.get(ast) ?? ast; -} -function replaceEncoding(ast, encoding) { - if (ast.encoding === encoding) { - return ast; +var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; +var exitFalse = /* @__PURE__ */ exitSucceed(false); +var exitTrue = /* @__PURE__ */ exitSucceed(true); +var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); +var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); +var releaseTakers = (self) => { + if (self.state._tag === "Done" || self.state.takers.size === 0) { + return; } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.encoding.value = encoding; - }); -} -function replaceContext(ast, context) { - if (ast.context === context) { - return ast; + for (const taker of self.state.takers) { + self.state.takers.delete(taker); + taker(exitVoid); + if (self.messages.length === 0) { + break; + } } - const owner = getContextOwner(ast); - if (owner.context === context) { - return owner; +}; +var scheduleReleaseTaker = (self) => { + if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { + return; } - const out = modifyOwnPropertyDescriptors(ast, (d) => { - d.context.value = context; - }); - contextOwners.set(out, owner); - return out; -} -function getLastEncoding(ast) { - return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast; -} -function annotate(ast, annotations) { - if (ast.checks) { - const last = ast.checks[ast.checks.length - 1]; - return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations))); + self.scheduleRunning = true; + self.dispatcher.scheduleTask(() => { + self.scheduleRunning = false; + releaseTakers(self); + }, 0); +}; +var takeBetweenUnsafe = (self, min, max) => { + if (self.state._tag === "Done") { + return self.state.exit; + } else if (max <= 0 || min <= 0) { + return exitSucceed([]); + } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { + const messages = [takeOfferUnsafe(self.state.offers)]; + releaseCapacity(self); + return exitSucceed(messages); } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.annotations.value = { - ...d.annotations.value, - ...annotations + min = Math.min(min, self.capacity || 1); + if (min <= self.messages.length) { + const messages = takeN(self.messages, max); + releaseCapacity(self); + return exitSucceed(messages); + } +}; +var offerRemainingSingle = (self, message) => { + return callback((resume) => { + if (self.state._tag !== "Open") { + return resume(exitFalse); + } + const entry = { + _tag: "Single", + message, + resume }; + self.state.offers.add(entry); + return sync(() => { + if (self.state._tag === "Open") { + self.state.offers.delete(entry); + } + }); }); -} -function replaceChecks(ast, checks) { - if (ast._tag === "Suspend" && checks) { - throw new Error("Cannot add checks to Suspend"); +}; +var takeOfferUnsafe = (offers) => { + const entry = offers.values().next().value; + if (entry._tag === "Single") { + offers.delete(entry); + entry.resume(exitTrue); + return entry.message; } - if (ast.checks === checks) { - return ast; + const message = entry.remaining[entry.offset++]; + if (entry.offset === entry.remaining.length) { + offers.delete(entry); + entry.resume(exitSucceed([])); } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.checks.value = checks; - }); -} -function appendChecks(ast, checks) { - return replaceChecks(ast, combineChecks(ast.checks, checks)); -} -function mapLink(link, f) { - const to = f(link.to); - return to === link.to ? link : new Link(to, link.transformation); -} -function updateLastLink(encoding, f) { - const links = encoding; - const last = links[links.length - 1]; - const out = mapLink(last, f); - return out === last ? encoding : append(encoding.slice(0, encoding.length - 1), out); -} -function applyToLastLink(f) { - return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast; -} -function applyToSelfOrLastLinkEncodingIdempotent(f, options) { - function out(ast) { - if (ast.encoding) { - const last = ast.encoding[ast.encoding.length - 1]; - return options?.stopAt?.(last) ? ast : replaceEncoding(ast, updateLastLink(ast.encoding, out)); + return message; +}; +var releaseCapacity = (self) => { + if (self.state._tag === "Done") { + return isDoneCause(self.state.exit.cause); + } else if (self.state.offers.size === 0) { + if (self.state._tag === "Closing" && self.messages.length === 0) { + finalize(self, self.state.exit); + return isDoneCause(self.state.exit.cause); } - return f(ast); + return false; } - return memoizeIdempotent(out); -} -function appendTransformation(from, transformation, to) { - const link = new Link(from, transformation); - return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]); -} -function mapOrSame(as, f) { - let changed = false; - const out = new Array(as.length); - for (let i = 0;i < as.length; i++) { - const a = as[i]; - const fa = f(a); - if (fa !== a) { - changed = true; + for (const entry of self.state.offers) { + let n = self.capacity - self.messages.length; + if (n <= 0) + break; + else if (entry._tag === "Single") { + append2(self.messages, entry.message); + self.state.offers.delete(entry); + entry.resume(exitTrue); + } else { + for (;entry.offset < entry.remaining.length; entry.offset++) { + if (n === 0) + return false; + append2(self.messages, entry.remaining[entry.offset]); + n--; + } + self.state.offers.delete(entry); + entry.resume(exitSucceed([])); } - out[i] = fa; } - return changed ? out : as; -} -function annotateKey(ast, annotations) { - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, { - ...ast.context.annotations, - ...annotations - }) : new Context(false, false, undefined, annotations); - return replaceContext(ast, context); -} -var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { - const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false); - return optionalKeyLastLink(replaceContext(ast, context)); + return false; +}; +var awaitTake = (self) => callback((resume) => { + if (self.state._tag === "Done") { + return resume(self.state.exit); + } + self.state.takers.add(resume); + return sync(() => { + if (self.state._tag !== "Done") { + self.state.takers.delete(resume); + } + }); }); -var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); -function withConstructorDefault(ast, defaultValue) { - const transformation = new Transformation(withDefault(defaultValue), passthrough()); - const constructorDefault = new Link(unknown, transformation); - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) : new Context(false, false, constructorDefault); - return replaceContext(ast, context); -} -function decodeTo(from, to, transformation) { - return appendTransformation(from, transformation, to); -} -function isOptional(ast) { - return ast.context?.isOptional ?? false; -} -function isStructuralCheck(check) { - return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck); -} -function extractStructuralChecks(checks) { - function extract(check) { - if (isStructuralCheck(check)) - return [check]; - return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []; +var finalize = (self, exit) => { + if (self.state._tag === "Done") { + return; + } + const openState = self.state; + self.state = { + _tag: "Done", + exit + }; + for (const taker of openState.takers) { + taker(exit); + } + openState.takers.clear(); + for (const awaiter of openState.awaiters) { + awaiter(exit); + } + openState.awaiters.clear(); +}; + +// node_modules/effect/dist/Semaphore.js +var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); +var waitForPermits = (self, n, effect) => callback((resume) => { + if (self.free >= n) + return resume(effect); + const observer = () => { + if (self.free < n) + return; + self.waiters.delete(observer); + resume(effect); + }; + self.waiters.add(observer); + return sync(() => { + self.waiters.delete(observer); + }); +}); + +class SemaphoreImpl { + waiters = /* @__PURE__ */ new Set; + taken = 0; + permits; + constructor(permits) { + this.permits = permits; + } + get free() { + return this.permits - this.taken; + } + take(n) { + const take = suspend(() => { + if (this.free < n) { + return waitForPermits(this, n, take); + } + this.taken += n; + return succeed3(n); + }); + return take; } - const out = checks.flatMap(extract); - return isArrayNonEmpty2(out) ? out : undefined; -} -var toType = /* @__PURE__ */ memoizeIdempotent((ast) => { - if (ast.encoding) { - return toType(replaceEncoding(ast, undefined)); + takeIfAvailable(n) { + return suspend(() => { + if (this.free < n) + return succeed3(false); + this.taken += n; + return succeed3(true); + }); } - const out = ast; - const type = out.recur?.(toType) ?? out; - const encodingChecks = type.encodingChecks; - if (encodingChecks) { - const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : undefined; - return modifyOwnPropertyDescriptors(type, (d) => { - d.encodingChecks.value = undefined; - d.checks.value = combineChecks(type.checks, checks); + releaseUnsafe(fiber, n) { + this.taken -= n; + if (this.waiters.size > 0) { + fiber.currentDispatcher.scheduleTask(() => { + for (const observer of this.waiters) { + if (this.free <= 0) + break; + observer(); + } + }, 0); + } + return this.free; + } + resize(permits) { + return withFiber((fiber) => { + this.permits = permits; + if (this.free < 0) + return void_; + this.releaseUnsafe(fiber, 0); + return void_; }); } - return type; -}); -var toEncoded = /* @__PURE__ */ memoizeIdempotent((ast) => { - return toType(flip2(ast)); -}); -function flipEncoding(ast, encoding) { - const links = encoding; - const len = links.length; - const last = links[len - 1]; - const ls = [new Link(flip2(replaceEncoding(ast, undefined)), links[0].transformation.flip())]; - for (let i = 1;i < len; i++) { - ls.unshift(new Link(flip2(links[i - 1].to), links[i].transformation.flip())); + release(n) { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); } - const to = flip2(last.to); - if (to.encoding) { - return replaceEncoding(to, [...to.encoding, ...ls]); - } else { - return replaceEncoding(to, ls); + get releaseAll() { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); } -} -var flip2 = /* @__PURE__ */ memoize((ast) => { - if (ast.encoding) { - return flipEncoding(ast, ast.encoding); + withPermits(n) { + return (self) => uninterruptibleMask((restore) => { + const acquire = suspend(() => { + if (this.free < n) { + const wait = waitForPermits(this, n, void_); + return flatMap2(restore(wait), () => acquire); + } + this.taken += n; + return onExitPrimitive(restore(self), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); + return acquire; + }); } - const out = ast; - return out.flip?.(flip2) ?? out.recur?.(flip2) ?? out; -}); -function containsUndefined(ast) { - switch (ast._tag) { - case "Undefined": - return true; - case "Union": - return ast.types.some(containsUndefined); - default: - return false; + withPermit = /* @__PURE__ */ this.withPermits(1); + withPermitsIfAvailable(n) { + return (self) => uninterruptibleMask((restore) => { + if (this.free < n) + return succeedNone; + this.taken += n; + return onExitPrimitive(restore(asSome(self)), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); } } -function fromConst(ast, value) { - const succeed = value === 0 ? sameExit : succeed9(value); - return (input, options) => { - if (input === missing) - return missingExit; - if (input === value) - return succeed; - return fail6(new InvalidType(ast, input, options)); - }; -} -function fromRefinement(ast, refinement) { - return (input, options) => { - if (input === missing) - return missingExit; - if (refinement(input)) - return sameExit; - return fail6(new InvalidType(ast, input, options)); - }; -} -var parameterFromPropertyKey = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => { - switch (ast._tag) { - default: - return ast; - case "Number": - return ast.toCodecStringTree(); - case "Union": - return ast.recur(parameterFromPropertyKey); + +// node_modules/effect/dist/Channel.js +var TypeId12 = "~effect/Channel"; +var isChannel = (u) => hasProperty(u, TypeId12); +var ChannelProto = { + [TypeId12]: { + _Env: identity, + _InErr: identity, + _InElem: identity, + _OutErr: identity, + _OutElem: identity + }, + pipe() { + return pipeArguments(this, arguments); } -}); -var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`); -var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`); -function isStringFinite(annotations) { - return isPattern(isStringFiniteRegExp, { - expected: "a string representing a finite number", - representation: { - id: "effect/schema/isStringFinite", - payload: null - }, - toJsonSchema: () => ({ - pattern: isStringFiniteRegExp.source - }), - ...annotations +}; +var fromTransform = (transform) => { + const self = Object.create(ChannelProto); + self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); + return self; +}; +var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); +var fromPull = (effect) => fromTransform((_, __) => effect); +var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { + const closableScope = forkUnsafe2(scope); + const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); + const pull = yield* onError2(f(upstream, scope, closableScope), onCause); + return onError2(pull, onCause); +})); +var toTransform = (channel) => channel.transform; +var asyncQueue = (scope, f, options) => make9({ + capacity: options?.bufferSize, + strategy: options?.strategy +}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); +var callbackArray = (f, options) => fromTransform((_, scope) => map5(asyncQueue(scope, f, options), takeAll2)); +var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); +var succeed8 = (value) => fromEffect(succeed6(value)); +var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done2())); +var fail7 = (error) => fromPull(succeed6(fail6(error))); +var failCause5 = (cause) => fromPull(failCause3(cause)); +var fromEffect = (effect) => fromPull(sync3(() => { + let done = false; + return suspend2(() => { + if (done) + return done2(); + done = true; + return effect; }); -} -var finiteString = /* @__PURE__ */ appendChecks(string2, [/* @__PURE__ */ isStringFinite()]); -var finiteToString = /* @__PURE__ */ new Link(finiteString, numberFromString); -var numberToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finiteString, nonFiniteLiterals]), numberFromString); -var BIGINT_PATTERN = "-?\\d+"; -var isStringBigIntRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${BIGINT_PATTERN}$`); -var REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"; -var isStringSymbolRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${REGEXP_PATTERN}$`); -function collectIssues(checks, value, issues, ast, options) { - for (let i = 0;i < checks.length; i++) { - const check = checks[i]; - if (check._tag === "FilterGroup") { - issues = collectIssues(check.checks, value, issues, ast, options); - if (issues && (options.errors !== "all" || issues[issues.length - 1].filter.aborted)) { - return issues; +})); +var fromEffectDrain = (effect) => fromPull(flatMap3(effect, () => done2())); +var map6 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { + let i = 0; + return map5(pull, (o) => f(o, i++)); +}))); +var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); +var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done2))))); +var concurrencyIsSequential = (concurrency) => concurrency === undefined || concurrency !== "unbounded" && concurrency <= 1; +var flatMap4 = /* @__PURE__ */ dual((args) => isChannel(args[0]), (self, f, options) => concurrencyIsSequential(options?.concurrency) ? flatMapSequential(self, f) : flatMapConcurrent(self, f, options)); +var flatMapSequential = (self, f) => fromTransform((upstream, scope) => map5(toTransform(self)(upstream, scope), (pull) => { + let childPull; + let childScope; + const makePull = flatMap3(pull, (value) => { + childScope ??= forkUnsafe2(scope); + return flatMapEager2(toTransform(f(value))(upstream, childScope), (pull) => { + childPull = catchHalt(pull); + return childPull; + }); + }); + const catchHalt = catchDone((_) => { + childPull = undefined; + if (childScope.state._tag === "Open" && scopeFinalizerCountUnsafe(childScope) === 1) { + return makePull; + } + const close2 = close(childScope, void_2); + childScope = undefined; + return flatMap3(close2, () => makePull); + }); + return suspend2(() => childPull ?? makePull); +})); +var flatMapConcurrent = (self, f, options) => self.pipe(map6(f), mergeAll3(options)); +var flattenArray = (self) => transformPull(self, (pull) => { + let array; + let index = 0; + const pump = suspend2(function loop() { + if (array === undefined) { + return flatMap3(pull, (array_) => { + switch (array_.length) { + case 0: + return loop(); + case 1: + return succeed6(array_[0]); + default: { + array = array_; + return succeed6(array_[index++]); + } + } + }); + } + const next = array[index++]; + if (index >= array.length) { + array = undefined; + index = 0; + } + return succeed6(next); + }); + return succeed6(pump); +}); +var drain = (self) => transformPull(self, (pull) => succeed6(forever2(pull, { + disableYield: true +}))); +var catchCause3 = /* @__PURE__ */ dual(2, (self, f) => fromTransform((upstream, scope) => { + let forkedScope = forkUnsafe2(scope); + return map5(toTransform(self)(upstream, forkedScope), (pull) => { + let currentPull = pull.pipe(catchCause2((cause) => { + if (isDoneCause(cause)) { + return failCause3(cause); } - } else { - const issue = check.run(value, ast, options); - if (issue) { - const filter = new Filter(check, issue, value, options); - if (issues) - issues.push(filter); - else - issues = [filter]; - if (options.errors !== "all" || check.aborted) { - return issues; + const toClose = forkedScope; + forkedScope = forkUnsafe2(scope); + return close(toClose, failCause2(cause)).pipe(andThen2(toTransform(f(cause))(upstream, forkedScope)), flatMap3((childPull) => { + currentPull = childPull; + return childPull; + })); + })); + return suspend2(() => currentPull); + }); +})); +var catchCauseFilter2 = /* @__PURE__ */ dual(3, (self, filter, f) => catchCause3(self, (cause) => { + const result = filter(cause); + return isFailure2(result) ? failCause5(result.failure) : f(result.success, cause); +})); +var catch_3 = /* @__PURE__ */ dual(2, (self, f) => catchCauseFilter2(self, findError2, (e) => f(e))); +var mapError4 = /* @__PURE__ */ dual(2, (self, f) => catch_3(self, (err) => fail7(f(err)))); +var mergeAll3 = /* @__PURE__ */ dual(2, (channels, { + bufferSize = 16, + concurrency, + switch: switch_ = false +}) => fromTransformBracket(fnUntraced2(function* (upstream, scope, forkedScope) { + const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : Math.max(1, concurrency); + const semaphore = switch_ ? undefined : makeUnsafe5(concurrencyN); + const doneLatch = yield* make6(true); + const fibers = new Set; + const queue = yield* bounded(bufferSize); + yield* addFinalizer2(forkedScope, shutdown(queue)); + const pull = yield* toTransform(channels)(upstream, scope); + yield* gen2(function* () { + while (true) { + let pullFiber; + if (semaphore) { + if (fibers.size < concurrencyN) { + yield* semaphore.take(1); + } else { + pullFiber = yield* forkChild2(pull); + yield* raceFirst2(semaphore.take(1), andThen2(join(pullFiber), never2)); } } + const channel = pullFiber === undefined ? yield* pull : yield* join(pullFiber); + const childScope = forkUnsafe2(forkedScope); + const childPull = yield* toTransform(channel)(upstream, childScope); + while (fibers.size >= concurrencyN) { + const fiber = headUnsafe(fibers); + fibers.delete(fiber); + if (fibers.size === 0) + yield* doneLatch.open; + yield* interrupt3(fiber); + } + const fiber = yield* childPull.pipe(tap2(() => yieldNow2), flatMap3((value) => offer(queue, value)), forever2({ + disableYield: true + }), onError2(fnUntraced2(function* (cause) { + const halt = filterDone(cause); + yield* exit2(close(childScope, !isFailure2(halt) ? succeed4(halt.success.value) : failCause2(halt.failure))); + if (!fibers.has(fiber)) + return; + fibers.delete(fiber); + if (semaphore) + yield* semaphore.release(1); + if (fibers.size === 0) + yield* doneLatch.open; + if (isSuccess2(halt)) + return; + return yield* failCause4(queue, cause); + })), forkChild2); + doneLatch.closeUnsafe(); + fibers.add(fiber); + } + }).pipe(catchCause2((cause) => { + const halt = filterDone(cause); + if (isSuccess2(halt)) { + return doneLatch.whenOpen(failCause4(queue, cause)); + } + return failCause4(queue, cause); + }), forkIn2(forkedScope)); + return take2(queue); +}))); +var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { + const strategy = options?.haltStrategy ?? "both"; + const queue = yield* bounded(0); + yield* addFinalizer2(forkedScope, shutdown(queue)); + let done = 0; + function onExit(side, cause) { + done++; + if (!isDoneCause(cause)) { + return failCause4(queue, cause); + } + switch (strategy) { + case "both": { + return done === 2 ? failCause4(queue, cause) : void_3; + } + case "left": + case "right": { + return side === strategy ? failCause4(queue, cause) : void_3; + } + case "either": { + return failCause4(queue, cause); + } } } - return issues; -} -function getConstructorDescriptor(ast) { - if (!isDeclaration(ast)) - return; - const getDescriptor = ast.annotations?.[CONSTRUCTOR_ANNOTATION_KEY]; - return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; -} -function isJsonLeaf(u) { - return u === null || typeof u === "string" || typeof u === "boolean" || typeof u === "number" && globalThis.Number.isFinite(u); -} -function isStringTreeLeaf(u) { - return u === undefined || typeof u === "string"; -} -function isTree(u, isLeaf) { - const cache = new WeakMap; - const stack = []; - outer: - while (true) { - if (typeof u !== "object" || u === null) { - if (!isLeaf(u)) { - return false; - } + const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); + yield* runSide("left", left, forkUnsafe2(forkedScope)); + yield* runSide("right", right, forkUnsafe2(forkedScope)); + return take2(queue); +}))); +var mergeEffect = /* @__PURE__ */ dual(2, (self, effect) => merge2(self, fromEffectDrain(effect), { + haltStrategy: "left" +})); +var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { + let stringBuilder = ""; + let midCRLF = false; + let done = none2(); + function splitLinesArray(chunk) { + const chunkBuilder = []; + function pushLine(segment) { + if (stringBuilder.length === 0) { + chunkBuilder.push(segment); } else { - const value = u; - const cached = cache.get(value); - if (cached === false) { - return false; - } - if (cached === undefined) { - const isArray = Array.isArray(value); - if (!isArray) { - const prototype = Object.getPrototypeOf(value); - if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) { - return false; - } - } - cache.set(value, false); - stack.push({ - value, - keys: isArray ? value.length : Object.keys(value), - index: 0 - }); - } + chunkBuilder.push(stringBuilder + segment); + stringBuilder = ""; } - while (stack.length > 0) { - const frame = stack[stack.length - 1]; - const keys = frame.keys; - if (typeof keys === "number") { - if (frame.index < keys) { - u = frame.value[frame.index++]; - continue outer; + } + for (let i = 0;i < chunk.length; i++) { + const str = chunk[i]; + if (str.length !== 0) { + let from = 0; + let indexOfCR = str.indexOf("\r"); + let indexOfLF = str.indexOf(` +`); + if (midCRLF) { + if (indexOfLF === 0) { + from = 1; + indexOfLF = str.indexOf(` +`, from); } - } else if (frame.index < keys.length) { - u = frame.value[keys[frame.index++]]; - continue outer; + midCRLF = false; } - cache.set(frame.value, true); - stack.pop(); - } - return true; - } -} -function isJson(u) { - return isTree(u, isJsonLeaf); -} -var Json = /* @__PURE__ */ new Declaration([], () => (input, ast, options) => isJson(input) ? sameExit : fail6(new InvalidType(ast, input, options)), { - representation: { - id: "effect/schema/Json", - payload: null - }, - expected: "JSON value", - toCodecJson: () => { - return; - }, - toCodecStringTree: () => unknownToStringTree -}); -function isStringTree(u) { - return isTree(u, isStringTreeLeaf); -} -var StringTree = /* @__PURE__ */ new Declaration([], () => (input, ast, options) => isStringTree(input) ? sameExit : fail6(new InvalidType(ast, input, options)), { - expected: "StringTree", - toCodecStringTree: () => { - return; - } -}); -var unknownToStringTree = /* @__PURE__ */ new Link(StringTree, /* @__PURE__ */ passthrough2()); - -// node_modules/effect/dist/SchemaParser.js -function makeEffect(schema) { - const ast = schema.ast; - let parser; - return (input, options) => { - return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { - ...options.parseOptions, - disableChecks: true - } : { - disableChecks: true - } : options?.parseOptions); - }; -} -function makeOption(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return some2(exit.value); + while (indexOfCR !== -1 || indexOfLF !== -1) { + if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { + pushLine(str.substring(from, indexOfLF)); + from = indexOfLF + 1; + indexOfLF = str.indexOf(` +`, from); + } else { + pushLine(str.substring(from, indexOfCR)); + if (str.length === indexOfCR + 1) { + midCRLF = true; + from = str.length; + indexOfCR = -1; + } else { + from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); + indexOfCR = str.indexOf("\r", from); + indexOfLF = str.indexOf(` +`, from); + } + } + } + stringBuilder = stringBuilder + str.substring(from); + } } - getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); - return none2(); - }; -} -function make15(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return exit.value; + return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; + } + const pullOrFlush = suspend2(() => { + if (done._tag === "Some") { + return done2(done.value); } - const issue = getSchemaIssueOrThrow(exit.cause, "Constructor adapter can only throw schema issues"); - throw new Error("Schema validation failed", { - cause: issue + return matchEffect2(upstream, { + onSuccess: loop, + onFailure: failCause3, + onDone: (leftover) => { + done = some2(leftover); + if (stringBuilder.length > 0) { + const last = stringBuilder; + stringBuilder = ""; + midCRLF = false; + return succeed6([last]); + } + return done2(leftover); + } }); - }; -} -function is2(schema) { - return _is(schema.ast); -} -function _is(ast) { - const parser = asExit(run2(toType(ast))); - return (input) => { - const exit = parser(input, defaultParseOptions); - if (isSuccess3(exit)) { - return true; + }); + function loop(chunk) { + const lines = splitLinesArray(chunk); + return lines !== null ? succeed6(lines) : pullOrFlush; + } + return pullOrFlush; +})); +var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); +var unwrap = (channel) => fromTransform((upstream, scope) => { + let pull; + return succeed6(suspend2(() => { + if (pull) + return pull; + return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); + })); +}); +var runWith = (self, f, onHalt) => suspend2(() => { + const scope = makeUnsafe3(); + const makePull = toTransform(self)(done2(), scope); + return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); +}); +var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { + disableYield: true +}))); +var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { + let state = initial(); + return runWith(self, (pull) => whileLoop2({ + while: constTrue, + body: () => pull, + step: (value) => { + state = f(state, value); } - getSchemaIssueOrThrow(exit.cause, "Type guard adapter can only return false for schema issues"); - return false; - }; -} -function decodeUnknownEffect(schema, options) { - const parser = run2(schema.ast); - return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); -} -var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { - ...options, - ...overrideOptions -} : options; -var getValue = (value) => { - if (value === missing) { - return fail6(new InvalidValue); + }), () => succeed6(state)); +})); +var toPullScoped = (self, scope) => toTransform(self)(done2(), scope); +// node_modules/effect/dist/internal/schema/interpreter.js +var flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager2(result, f); +function compileTransformation(transformation) { + if (transformation._tag === "Middleware") { + return (result, current, options) => { + const transformed = result === sameExit ? transformation.decode(succeed7(toOption(current)), options) : transformation.decode(mapEager2(result, toOption), options); + return fromOptionalEffect(transformed); + }; } - return succeed6(value); -}; -function run2(ast) { - return runWithCompiler(normalCompiler, ast); -} -function runWithCompiler(compiler, ast) { - let parser; - return (input, options) => { - const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); - if (result === sameExit) { - return succeed6(input); + const getter = transformation.decode; + switch (getter._tag) { + case "Passthrough": + return (result, current) => result === sameExit ? succeed7(current) : result; + case "Transform": { + const transform = (value) => value === missing ? missingExit : succeed7(getter.transform(value)); + return (result, current) => flatMapTransformation(result, current, transform); } - if (!effectIsExit(result)) { - return flatMapEager2(result, getValue); + case "TransformOptional": { + const transform = (value) => fromOptionExit(getter.transform(toOption(value))); + return (result, current) => flatMapTransformation(result, current, transform); } - return result[args] === missing ? getValue(missing) : result; - }; -} -function asExit(parser) { - return (input, options) => runSyncExit2(parser(input, options)); -} -var normalCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, normalCompiler)); -var constructorCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault)); -var compileDefaulted = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault, ast.context?.constructorDefault)); -function compileConstructorDefault(ast) { - return ast.context?.constructorDefault ? compileDefaulted(ast) : constructorCompiler(ast); -} -function applyTransformation(result, current, transformation, options) { - let transformed; - if (effectIsExit(result) && result._tag === "Success") { - const optional = toOption(result === sameExit ? current : result[args]); - transformed = transformation._tag === "Transformation" ? transformation.decode.run(optional, options) : transformation.decode(succeed9(optional), options); - } else if (transformation._tag === "Transformation") { - transformed = flatMapEager2(result, (value) => transformation.decode.run(toOption(value), options)); - } else { - transformed = transformation.decode(mapEager2(result, toOption), options); + case "TransformEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => value === missing ? missingExit : getter.transform(value, options)); + case "TransformOptionalEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => fromOptionalEffect(getter.transform(toOption(value), options))); } - return effectIsExit(transformed) && transformed._tag === "Success" ? fromOptionExit(transformed[args]) : flatMapEager2(transformed, fromOptionExit); } +var fromOptionalEffect = (effect) => flatMapEager2(effect, fromOptionExit); +var wrapEncoding = (ast, input, options, effect) => catchCause2(effect, (cause) => failCauseSync2(() => map4(cause, (issue) => new Encoding(ast, issue, input, options)))); function makeConstructorParser(descriptor, compile) { + const transform = compileTransformation(descriptor.link.transformation); let sourceParser; return (input, options) => { if (input === missing) @@ -8157,20 +7584,45 @@ function makeConstructorParser(descriptor, compile) { if (descriptor.isConstructed(input)) return sameExit; const result = (sourceParser ??= compile(descriptor.link.to))(input, options); - return applyTransformation(result, input, descriptor.link.transformation, options); + return transform(result, input, options); + }; +} +function withDefault(ast, parser) { + const defaultValue = ast.context.constructorDefault; + return (input, options) => { + if (input !== missing && input !== undefined) + return parser(input, options); + const result = defaultValue; + if (effectIsExit(result) && result._tag === "Success") { + const local = parser(result[args], options); + return local === sameExit ? result : local; + } + return flatMapEager2(wrapEncoding(ast, input, options, result), (value) => { + const local = parser(value, options); + return local === sameExit ? succeed7(value) : local; + }); }; } -function makeParser(ast, compile, compileConstructorDefault, constructorDefault) { - const descriptor = compileConstructorDefault ? getConstructorDescriptor(ast) : undefined; - const parser = descriptor ? makeConstructorParser(descriptor, compile) : ast.getParser(compile, compileConstructorDefault); +function compileField(ast, compile) { + const parser = compile(ast); + return ast.context?.constructorDefault === undefined ? parser : withDefault(ast, parser); +} +function compile(ast, compile, compileField, base, specialize) { + if (ast._tag === "Declaration") { + for (const parameter of ast.typeParameters) + compile(parameter); + } + const descriptor = compileField ? getConstructorDescriptor(ast) : undefined; + const parser = descriptor ? makeConstructorParser(descriptor, compile) : base ?? ast.getParser(compile, compileField); const checks = ast.checks; - const links = constructorDefault ? ast.encoding ? [...ast.encoding, constructorDefault] : [constructorDefault] : ast.encoding; + const links = ast.encoding; + const transformations = links?.map((link) => compileTransformation(link.transformation)); const encodingChecks = ast.encodingChecks; if (!links && !checks && !encodingChecks) { return parser; } let encodingParsers; - const parseLocal = (input, options) => { + const parseChecks = (input, options) => { let result = parser(input, options); if (encodingChecks && !options.disableChecks) { if (effectIsExit(result)) { @@ -8220,6 +7672,7 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) } return result; }; + const parseLocal = specialize === undefined ? parseChecks : specialize(parseChecks); if (!links) { return parseLocal; } @@ -8228,7 +7681,7 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) let current = input; let result = parsers[parsers.length - 1](input, options); for (let i = links.length - 1;i >= 0; i--) { - result = applyTransformation(result, current, links[i].transformation, options); + result = transformations[i](result, current, options); if (i !== 0) { const next = parsers[i - 1]; if (result._tag === "Success") { @@ -8237,28 +7690,281 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) } else { result = flatMapEager2(result, (value) => { const nextResult = next(value, options); - return nextResult === sameExit ? succeed9(value) : nextResult; + return nextResult === sameExit ? succeed7(value) : nextResult; }); } } } - if (result._tag === "Success") { - const value = result[args]; - const local = parseLocal(value, options); - return local === sameExit ? result : local; - } - result = catchCause2(result, (cause) => failCauseSync2(() => map5(cause, (issue) => new Encoding(ast, issue, input, options)))); - return flatMapEager2(result, (value) => { - const local = parseLocal(value, options); - return local === sameExit ? succeed9(value) : local; - }); + if (result._tag === "Success") { + const value = result[args]; + const local = parseLocal(value, options); + return local === sameExit ? result : local; + } + result = wrapEncoding(ast, input, options, result); + return flatMapEager2(result, (value) => { + const local = parseLocal(value, options); + return local === sameExit ? succeed7(value) : local; + }); + }; +} + +// node_modules/effect/dist/internal/schema/compilerRegistry.js +var invalid3 = /* @__PURE__ */ Symbol(); +var cache = /* @__PURE__ */ new WeakMap; +var compiler; +var compilerAdaptersEnabled = false; +var decodeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "parser") : resolve2(ast).parser; +var makeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "makeEffect") : resolve2(ast).makeEffect; +var makeField = (ast) => compileField(ast, makeChild); + +class InterpretedEntry { + ast; + constructor(ast) { + this.ast = ast; + } + get decodeEffect() { + return this.cachedDecodeEffect ??= compile(this.ast, decodeChild); + } + get parser() { + return this.decodeEffect; + } + get makeEffect() { + return this.cachedMakeEffect ??= compile(this.ast, makeChild, makeField); + } +} + +class CompilerEntry extends InterpretedEntry { + compiled; + resolve; + constructor(ast, compiled, resolve) { + super(ast); + this.compiled = compiled; + this.resolve = resolve; + } + save(key, value) { + Object.defineProperty(this, key, { + value + }); + return value; + } + operation(key) { + const compiled = this.compiled; + return typeof compiled === "function" ? compiled(this.ast, this.resolve, key) : compiled?.[key]; + } + get is() { + return this.save("is", this.operation("is")); + } + get decode() { + return this.save("decode", this.operation("decode")); + } + get make() { + return this.save("make", this.operation("make")); + } + get decodeEffect() { + return this.save("decodeEffect", this.operation("decodeEffect") ?? compile(this.ast, (ast) => lazyParser(this.resolve, ast, "parser"))); + } + get parser() { + const decode = this.decode; + return decode === undefined ? this.decodeEffect : this.save("parser", withDecode(decode, () => this.decodeEffect)); + } + get makeEffect() { + const makeEffect = this.operation("makeEffect"); + if (makeEffect !== undefined) + return this.save("makeEffect", makeEffect); + const child = (ast) => lazyParser(this.resolve, ast, "makeEffect"); + return this.save("makeEffect", compile(this.ast, child, (ast) => compileField(ast, child))); + } +} +function withDecode(fastDecode, decodeEffect) { + let detailed; + return (input, options) => { + if (input !== missing) { + try { + const value = fastDecode(input, options); + if (value !== invalid3) + return value === input ? sameExit : succeed7(value); + } catch (error) { + return die3(error); + } + } + return (detailed ??= decodeEffect())(input, options); + }; +} +function lazyParser(resolve, ast, operation) { + const entry = resolve(ast); + if (entry.compiled === undefined || Object.hasOwn(entry, operation)) { + return entry[operation]; + } + let parser; + return (input, options) => (parser ??= entry[operation])(input, options); +} +function resolve2(ast) { + const cached = cache.get(ast); + if (cached !== undefined) + return cached; + const entry = compiler === undefined ? new InterpretedEntry(ast) : new CompilerEntry(ast, compiler(ast, resolve2), resolve2); + cache.set(ast, entry); + return entry; +} + +// node_modules/effect/dist/SchemaParser.js +function makeEffect(schema) { + const ast = schema.ast; + let parser; + return (input, options) => { + return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions); + }; +} +function makeOption(schema) { + const parser = makeEffect(schema); + return (input, options) => { + const exit = runSyncExit2(parser(input, options)); + if (isSuccess3(exit)) { + return some2(exit.value); + } + getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); + return none2(); + }; +} +function make10(schema) { + return makeConstructorSync(toType(schema.ast)); +} +function is(schema) { + return _is(schema.ast); +} +function makeIs(ast) { + if (!compilerAdaptersEnabled) { + const parser = asExit(run(ast)); + return (input) => { + const exit = parser(input, defaultParseOptions); + if (isSuccess3(exit)) + return true; + getSchemaIssueOrThrow(exit.cause, "Type guard adapter can only return false for schema issues"); + return false; + }; + } + const entry = resolve2(ast); + const guard = entry.is; + if (guard !== undefined) { + return (input) => { + try { + return guard(input, defaultParseOptions); + } catch (error) { + getSchemaIssueOrThrow(die2(error), "Type guard adapter can only return false for schema issues"); + return false; + } + }; + } + const parser = entry.parser; + return (input) => { + const exit = runSyncExit2(parserResult(parser(input, defaultParseOptions), input)); + if (isSuccess3(exit)) + return true; + getSchemaIssueOrThrow(exit.cause, "Type guard adapter can only return false for schema issues"); + return false; + }; +} +function _is(ast) { + const typeAST = toType(ast); + let guard = (input) => { + guard = makeIs(typeAST); + return guard(input); + }; + return (input) => { + return guard(input); + }; +} +function decodeUnknownEffect(schema, options) { + const parser = run(schema.ast); + return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); +} +var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { + ...options, + ...overrideOptions +} : options; +var getValue = (value) => { + if (value === missing) { + return fail6(new InvalidValue); + } + return succeed6(value); +}; +function run(ast) { + return runWithCompiler(normalCompiler, ast); +} +function parserResult(result, input) { + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; +} +function runWithCompiler(compiler, ast) { + let parser; + return (input, options) => { + const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; + }; +} +function asExit(parser) { + return (input, options) => runSyncExit2(parser(input, options)); +} +function runSync2(effect, message) { + const exit = runSyncExit2(effect); + if (isSuccess3(exit)) { + return exit.value; + } + const issue = getSchemaIssueOrThrow(exit.cause, message); + throw new Error("Schema validation failed", { + cause: issue + }); +} +function makeConstructorSync(ast) { + let entry; + let parser; + return (input, options) => { + entry ??= resolve2(ast); + const parseOptions = options?.disableChecks ? options.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions ?? defaultParseOptions; + const make = entry.make; + if (make !== undefined && input !== missing) { + let output; + try { + output = make(input, parseOptions); + } catch (error) { + getSchemaIssueOrThrow(die2(error), "Constructor adapter can only throw schema issues"); + throw error; + } + if (output !== invalid3 && output !== missing) + return output; + } + const result = (parser ??= entry.makeEffect)(input, parseOptions); + return runSync2(parserResult(result, input), "Constructor adapter can only throw schema issues"); }; } +var normalCompiler = (ast) => resolve2(ast).parser; +var constructorCompiler = (ast) => resolve2(ast).makeEffect; // node_modules/effect/dist/internal/schema/make.js -var TypeId21 = "~effect/Schema/Schema"; +var TypeId13 = "~effect/Schema/Schema"; var SchemaProto = { - [TypeId21]: TypeId21, + [TypeId13]: TypeId13, pipe() { return pipeArguments(this, arguments); }, @@ -8272,7 +7978,7 @@ var SchemaProto = { return this.rebuild(appendChecks(this.ast, checks)); } }; -function make16(ast, options) { +function make11(ast, options) { function Schema() {} const self = Object.setPrototypeOf(Schema, SchemaProto); if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) { @@ -8283,9 +7989,9 @@ function make16(ast, options) { Object.assign(self, options); } self.ast = ast; - self.rebuild = (ast) => make16(ast, options); + self.rebuild = (ast) => make11(ast, options); self.makeEffect = makeEffect(self); - self.make = make15(self); + self.make = make10(self); self.makeOption = makeOption(self); return self; } @@ -8300,10 +8006,10 @@ function isSchemaError(u) { } // node_modules/effect/dist/Schema.js -var TypeId22 = TypeId21; +var TypeId14 = TypeId13; function declareConstructor() { return (typeParameters, run, annotations) => { - return make17(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make17(ast))), annotations)); + return make12(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make12(ast))), annotations)); }; } function declare(is, annotations) { @@ -8336,10 +8042,10 @@ function fromIssueEffect(self) { if (effectIsExit(self)) { return fromIssueExit(self); } - return catchCause2(self, (cause) => failCauseSync2(() => map5(cause, (issue) => new SchemaError(issue)))); + return catchCause2(self, (cause) => failCauseSync2(() => map4(cause, (issue) => new SchemaError(issue)))); } function fromIssueExit(exit) { - return isSuccess3(exit) ? exit : failCause2(map5(exit.cause, (issue) => new SchemaError(issue))); + return isSuccess3(exit) ? exit : failCause2(map4(exit.cause, (issue) => new SchemaError(issue))); } function decodeUnknownEffect2(schema, options) { const parser = decodeUnknownEffect(schema, options); @@ -8348,18 +8054,18 @@ function decodeUnknownEffect2(schema, options) { }; } var decodeEffect2 = decodeUnknownEffect2; -var make17 = make16; +var make12 = make11; function isSchema(u) { - return hasProperty(u, TypeId22) && u[TypeId22] === TypeId22; + return hasProperty(u, TypeId14) && u[TypeId14] === TypeId14; } -var optionalKey2 = /* @__PURE__ */ lambda((schema) => make17(optionalKey(schema.ast), { +var optionalKey2 = /* @__PURE__ */ lambda((schema) => make12(optionalKey(schema.ast), { schema })); -var toType2 = /* @__PURE__ */ lambda((schema) => make17(toType(schema.ast), { +var toType2 = /* @__PURE__ */ lambda((schema) => make12(toType(schema.ast), { schema })); function Literal2(literal) { - const out = make17(new Literal(literal), { + const out = make12(new Literal(literal), { literal, transform(to) { return out.pipe(decodeTo2(Literal2(to), { @@ -8370,12 +8076,12 @@ function Literal2(literal) { }); return out; } -var Unknown2 = /* @__PURE__ */ make17(unknown); -var String4 = /* @__PURE__ */ make17(string2); -var Number5 = /* @__PURE__ */ make17(number2); -var Boolean2 = /* @__PURE__ */ make17(boolean); +var Unknown2 = /* @__PURE__ */ make12(unknown); +var String4 = /* @__PURE__ */ make12(string2); +var Number5 = /* @__PURE__ */ make12(number2); +var Boolean2 = /* @__PURE__ */ make12(boolean); function makeStruct(ast, fields) { - return make17(ast, { + return make12(ast, { fields, mapFields(f, options) { const fields = f(this.fields); @@ -8387,7 +8093,7 @@ function Struct(fields) { return makeStruct(struct(fields, undefined), fields); } function makeTuple(ast, elements) { - return make17(ast, { + return make12(ast, { elements, mapElements(f, options) { const elements = f(this.elements); @@ -8398,11 +8104,11 @@ function makeTuple(ast, elements) { function Tuple(elements) { return makeTuple(tuple(elements), elements); } -var ArraySchema = /* @__PURE__ */ lambda((schema) => make17(new Arrays(false, [], [schema.ast]), { +var ArraySchema = /* @__PURE__ */ lambda((schema) => make12(new Arrays(false, [], [schema.ast]), { value: schema })); function makeUnion(ast, members) { - return make17(ast, { + return make12(ast, { members, mapMembers(f, options) { const members = f(this.members); @@ -8415,7 +8121,7 @@ function Union2(members, options) { } function Literals(literals) { const members = literals.map(Literal2); - return make17(union(members, undefined, undefined), { + return make12(union(members, undefined, undefined), { literals, members, mapMembers(f) { @@ -8431,23 +8137,23 @@ function Literals(literals) { } function decodeTo2(to, transformation) { return (from) => { - return make17(decodeTo(from.ast, to.ast, transformation ? make14(transformation) : passthrough2()), { + return make12(decodeTo(from.ast, to.ast, transformation ? makeTransformation(transformation) : passthrough2()), { from, to }); }; } function withConstructorDefault2(defaultValue) { - return (schema) => make17(withConstructorDefault(schema.ast, defaultValue), { + return (schema) => make12(withConstructorDefault(schema.ast, defaultValue), { schema }); } -function tag3(literal) { +function tag(literal) { return Literal2(literal).pipe(withConstructorDefault2(succeed6(literal))); } function TaggedStruct(value, fields) { return Struct({ - _tag: tag3(value), + _tag: tag(value), ...fields }); } @@ -8483,7 +8189,7 @@ function toTaggedUnion(tag) { discriminantKeys.add(key); discriminants.push(literal); assignProperty(cases, literal, schema); - assignProperty(guards, literal, is2(toType2(schema))); + assignProperty(guards, literal, is(toType2(schema))); return; } } @@ -8538,7 +8244,7 @@ function TaggedUnion(casesByTag) { match, matchOrElse } = toTaggedUnion("_tag")(union); - return make17(union.ast, { + return make12(union.ast, { cases, isAnyOf, guards, @@ -8546,12 +8252,12 @@ function TaggedUnion(casesByTag) { matchOrElse }); } -function instanceOf2(constructor, annotations) { +function instanceOf(constructor, annotations) { return declare((u) => u instanceof constructor, annotations); } function link() { return (encodeTo, transformation) => { - return new Link(encodeTo.ast, make14(transformation)); + return new Link(encodeTo.ast, makeTransformation(transformation)); }; } var makeFilter2 = makeFilter; @@ -8583,7 +8289,7 @@ function isBase64(annotations) { ...annotations }); } -var Finite = /* @__PURE__ */ make17(finite); +var Finite = /* @__PURE__ */ make12(finite); function isInt(annotations) { return makeFilter2((n) => globalThis.Number.isSafeInteger(n), { expected: "an integer", @@ -8635,7 +8341,7 @@ function Defect(options) { defectSchemaCache[key] = schema; return schema; } -var RegExp2 = /* @__PURE__ */ instanceOf2(globalThis.RegExp, { +var RegExp2 = /* @__PURE__ */ instanceOf(globalThis.RegExp, { representation: { id: "effect/schema/RegExp", payload: null @@ -8664,7 +8370,7 @@ var RegExp2 = /* @__PURE__ */ instanceOf2(globalThis.RegExp, { var URLString = /* @__PURE__ */ String4.annotate({ expected: "a string that will be decoded as a URL" }); -var URL2 = /* @__PURE__ */ instanceOf2(globalThis.URL, { +var URL2 = /* @__PURE__ */ instanceOf(globalThis.URL, { representation: { id: "effect/schema/URL", payload: null @@ -8683,7 +8389,7 @@ var JsonString = /* @__PURE__ */ String4.annotate({ function fromJsonString2(schema, options) { return JsonString.pipe(decodeTo2(schema, fromJsonString(options))); } -var File = /* @__PURE__ */ instanceOf2(globalThis.File, { +var File = /* @__PURE__ */ instanceOf(globalThis.File, { representation: { id: "effect/schema/File", payload: null @@ -8699,7 +8405,7 @@ var File = /* @__PURE__ */ instanceOf2(globalThis.File, { name: String4, lastModified: Int }), transformEffect2({ - decode: (e, options) => match3(decodeBase64(e.data), { + decode: (e, options) => match2(decodeBase64(e.data), { onFailure: () => fail6(new InvalidValue({ expected: "a valid Base64 string" }, e.data, options)), @@ -8727,7 +8433,7 @@ var File = /* @__PURE__ */ instanceOf2(globalThis.File, { }) })) }); -var FormData2 = /* @__PURE__ */ instanceOf2(globalThis.FormData, { +var FormData2 = /* @__PURE__ */ instanceOf(globalThis.FormData, { representation: { id: "effect/schema/FormData", payload: null @@ -8738,10 +8444,10 @@ var FormData2 = /* @__PURE__ */ instanceOf2(globalThis.FormData, { }), expected: "FormData", toCodecJson: () => link()(ArraySchema(Tuple([String4, Union2([Struct({ - _tag: tag3("String"), + _tag: tag("String"), value: String4 }), Struct({ - _tag: tag3("File"), + _tag: tag("File"), value: File })])])), transformEffect2({ decode: (e) => { @@ -8768,7 +8474,7 @@ var FormData2 = /* @__PURE__ */ instanceOf2(globalThis.FormData, { } })) }); -var URLSearchParams2 = /* @__PURE__ */ instanceOf2(globalThis.URLSearchParams, { +var URLSearchParams2 = /* @__PURE__ */ instanceOf(globalThis.URLSearchParams, { representation: { id: "effect/schema/URLSearchParams", payload: null @@ -8790,7 +8496,7 @@ var Base64String = /* @__PURE__ */ String4.annotate({ format: "byte", contentEncoding: "base64" }); -var Uint8Array2 = /* @__PURE__ */ instanceOf2(globalThis.Uint8Array, { +var Uint8Array2 = /* @__PURE__ */ instanceOf(globalThis.Uint8Array, { representation: { id: "effect/schema/Uint8Array", payload: null @@ -8827,7 +8533,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { } }); } - static [TypeId22] = TypeId22; + static [TypeId14] = TypeId14; get [ClassTypeId]() { return ClassTypeId; } @@ -8844,7 +8550,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { return getClassSchema(this).rebuild(ast); } static make(input, options) { - return make15(getClassSchema(this))(input ?? {}, options); + return make10(getClassSchema(this))(input ?? {}, options); } static makeOption(input, options) { return makeOption(getClassSchema(this))(input ?? {}, options); @@ -8903,7 +8609,7 @@ function getClassSchemaFactory(from, identifier, annotations) { const ClassTypeId = getClassTypeId(identifier); const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId); const transformation = getClassTransformation(self); - const to = make17(new Declaration([from.ast], () => (input, ast, options) => { + const to = make12(new Declaration([from.ast], () => (input, ast, options) => { return isClassValue(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)); }, { identifier, @@ -8933,7 +8639,7 @@ var Error4 = (identifier) => (schema, annotations) => { var TaggedError3 = (identifier) => { return (tagValue, schema, annotations) => { const struct = isStruct(schema) ? schema.mapFields((fields) => ({ - _tag: tag3(tagValue), + _tag: tag(tagValue), ...fields }), { unsafePreserveChecks: true @@ -8941,385 +8647,351 @@ var TaggedError3 = (identifier) => { return Error4(identifier ?? tagValue)(struct, annotations); }; }; -var Json2 = /* @__PURE__ */ make17(/* @__PURE__ */ annotate(Json, { +var Json2 = /* @__PURE__ */ make12(/* @__PURE__ */ annotate(Json, { toCode: () => ({ runtime: "Schema.Json", Type: "Schema.Json" }) })); -// node_modules/effect/dist/Brand.js -function nominal() { - return Object.assign((input) => input, { - option: (input) => some2(input), - result: (input) => succeed2(input), - is: (_) => true - }); -} +// node_modules/effect/dist/PlatformError.js +var TypeId15 = "~effect/PlatformError"; -// node_modules/effect/dist/unstable/process/ChildProcessSpawner.js -var ExitCode = /* @__PURE__ */ nominal(); -var ProcessId = /* @__PURE__ */ nominal(); -var HandleTypeId = "~effect/process/ChildProcessSpawner/ChildProcessHandle"; -var HandleProto = { - [HandleTypeId]: HandleTypeId, - ...BaseProto, - toJSON() { - return { - _id: "ChildProcessHandle", - pid: this.pid - }; +class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { + get message() { + return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; } -}; -var makeHandle = (params) => Object.setPrototypeOf({ - ...params -}, HandleProto); -var make18 = (spawn) => { - const streamString = (command, options) => spawn(command).pipe(map6((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); - const streamLines = (command, options) => splitLines2(streamString(command, options)); - return ChildProcessSpawner.of({ - spawn, - exitCode: (command) => scoped2(flatMap3(spawn(command), (handle) => handle.exitCode)), - streamString, - streamLines, - lines: (command, options) => runCollect(streamLines(command, options)), - string: (command, options) => mkString(streamString(command, options)) - }); -}; +} -class ChildProcessSpawner extends (/* @__PURE__ */ Service()("effect/process/ChildProcessSpawner")) { +class SystemError extends Error3 { + get message() { + return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; + } } -// node_modules/effect/dist/unstable/process/ChildProcess.js -var TypeId23 = "~effect/process/ChildProcess"; -var Proto2 = { - .../* @__PURE__ */ Prototype2({ - label: "Command", - evaluate(fiber) { - return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this); +class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { + constructor(reason) { + if ("cause" in reason) { + super({ + reason, + cause: reason.cause + }); + } else { + super({ + reason + }); } - }), - [TypeId23]: TypeId23 -}; -var makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto2), { - _tag: "StandardCommand", - command, - args, - options -}); -var make19 = function make(...args) { - if (isTemplateString(args[0])) { - const [templates, ...expressions] = args; - const tokens = parseTemplates(templates, expressions); - return makeStandardCommand(tokens[0] ?? "", tokens.slice(1), {}); - } - if (typeof args[0] === "object" && !Array.isArray(args[0]) && !isTemplateString(args[0])) { - const options = args[0]; - return function(templates, ...expressions) { - const tokens = parseTemplates(templates, expressions); - return makeStandardCommand(tokens[0] ?? "", tokens.slice(1), options); - }; } - if (typeof args[0] === "string" && !Array.isArray(args[1])) { - const [command, options = {}] = args; - return makeStandardCommand(command, [], options); + [TypeId15] = TypeId15; + get message() { + return this.reason.message; } - const [command, cmdArgs = [], options = {}] = args; - return makeStandardCommand(command, cmdArgs, options); +} +var systemError = (options) => new PlatformError(new SystemError(options)); +var badArgument = (options) => new PlatformError(new BadArgument(options)); + +// node_modules/effect/dist/internal/stream.js +var TypeId16 = "~effect/Stream"; +var streamVariance = { + _R: identity, + _E: identity, + _A: identity }; -var isTemplateString = (u) => Array.isArray(u) && ("raw" in u) && Array.isArray(u.raw); -var parseFdName = (name) => { - const match = /^fd(\d+)$/.exec(name); - if (match === null) - return; - const fd = parseInt(match[1], 10); - return fd >= 3 ? fd : undefined; +var Stream = function(channel) { + this.channel = channel; }; -var fdName = (fd) => `fd${fd}`; -var parseTemplates = (templates, expressions) => { - let tokens = []; - for (const [index, template] of templates.entries()) { - tokens = parseTemplate(templates, expressions, tokens, template, index); +Stream.prototype = { + [TypeId16]: streamVariance, + pipe() { + return pipeArguments(this, arguments); } - return tokens; }; -var parseTemplate = (templates, expressions, prevTokens, template, index) => { - const rawTemplate = templates.raw[index]; - if (rawTemplate === undefined) { - throw new Error(`Invalid backslash sequence: ${templates.raw[index]}`); - } - const { - hasLeadingWhitespace, - hasTrailingWhitespace, - tokens - } = splitByWhitespaces(template, rawTemplate); - const nextTokens = concatTokens(prevTokens, tokens, hasLeadingWhitespace); - if (index === expressions.length) { - return nextTokens; - } - const expression = expressions[index]; - const expressionTokens = Array.isArray(expression) ? expression.map((expression) => parseExpression(expression)) : [parseExpression(expression)]; - return concatTokens(nextTokens, expressionTokens, hasTrailingWhitespace); +var fromChannel = (channel) => new Stream(channel); + +// node_modules/effect/dist/Sink.js +var TypeId17 = "~effect/Sink"; +var endVoid = /* @__PURE__ */ succeed6([undefined]); +var sinkVariance = { + _A: identity, + _In: identity, + _L: identity, + _E: identity, + _R: identity }; -var parseExpression = (expression) => { - const type = typeof expression; - if (type === "string") { - return expression; +var SinkProto = { + [TypeId17]: sinkVariance, + pipe() { + return pipeArguments(this, arguments); } - return String(expression); -}; -var DELIMITERS = /* @__PURE__ */ new Set([" ", "\t", "\r", ` -`]); -var ESCAPE_LENGTH = { - x: 3, - u: 5 }; -var splitByWhitespaces = (template, rawTemplate) => { - if (rawTemplate.length === 0) { - return { - tokens: [], - hasLeadingWhitespace: false, - hasTrailingWhitespace: false - }; - } - const hasLeadingWhitespace = DELIMITERS.has(rawTemplate[0]); - const tokens = []; - let templateCursor = 0; - for (let templateIndex = 0, rawIndex = 0;templateIndex < template.length; templateIndex += 1, rawIndex += 1) { - const rawCharacter = rawTemplate[rawIndex]; - if (DELIMITERS.has(rawCharacter)) { - if (templateCursor !== templateIndex) { - tokens.push(template.slice(templateCursor, templateIndex)); - } - templateCursor = templateIndex + 1; - } else if (rawCharacter === "\\") { - const nextRawCharacter = rawTemplate[rawIndex + 1]; - if (nextRawCharacter === ` -`) { - templateIndex -= 1; - rawIndex += 1; - } else if (nextRawCharacter === "u" && rawTemplate[rawIndex + 2] === "{") { - const end = rawTemplate.indexOf("}", rawIndex + 3); - if (parseInt(rawTemplate.slice(rawIndex + 3, end), 16) > 65535) { - templateIndex += 1; - } - rawIndex = end; - } else { - rawIndex += ESCAPE_LENGTH[nextRawCharacter] ?? 1; - } - } - } - const hasTrailingWhitespace = templateCursor === template.length; - if (!hasTrailingWhitespace) { - tokens.push(template.slice(templateCursor)); - } - return { - tokens, - hasLeadingWhitespace, - hasTrailingWhitespace - }; +var isSink = (u) => hasProperty(u, TypeId17); +var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ + disableYield: true +})), catchDone(succeed6))); +var fromTransform2 = (transform) => { + const self = Object.create(SinkProto); + self.transform = transform; + return self; }; -var concatTokens = (prevTokens, nextTokens, isSeparated) => isSeparated || prevTokens.length === 0 || nextTokens.length === 0 ? [...prevTokens, ...nextTokens] : [...prevTokens.slice(0, -1), `${prevTokens.at(-1)}${nextTokens.at(0)}`, ...nextTokens.slice(1)]; -// node_modules/@timmo001/effect-gh/src/errors.ts -class GhCommandError extends TaggedError3()("GhCommandError", { - executable: String4, - exitCode: Int, - stderr: String4, - stderrTruncated: Boolean2 -}) { -} - -class GhPlatformError extends TaggedError3()("GhPlatformError", { executable: String4, cause: Defect() }) { -} +var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done2))); +var drain2 = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { + disableYield: true +}), () => endVoid)); +var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { + discard: true +})); +var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ + disableYield: true +}), catchDone(() => endVoid))); +var unwrap2 = (effect) => fromChannel2(unwrap(map5(effect, toChannel))); -class GhTimeoutError extends TaggedError3()("GhTimeoutError", { executable: String4, timeoutMs: Finite }) { -} +// node_modules/effect/dist/internal/rcRef.js +var TypeId18 = "~effect/RcRef"; +var stateEmpty = { + _tag: "Empty" +}; +var stateClosed = { + _tag: "Closed" +}; +var variance2 = { + _A: identity, + _E: identity +}; -class GhDecodeError extends TaggedError3()("GhDecodeError", { cause: Defect() }) { +class RcRefImpl { + [TypeId18] = variance2; + pipe() { + return pipeArguments(this, arguments); + } + state = stateEmpty; + semaphore = /* @__PURE__ */ makeUnsafe5(1); + acquire; + context; + scope; + idleTimeToLive; + constructor(acquire, context, scope, idleTimeToLive) { + this.acquire = acquire; + this.context = context; + this.scope = scope; + this.idleTimeToLive = idleTimeToLive; + } } - -// node_modules/@timmo001/effect-gh/src/gh.ts -var GhOutput = Struct({ - stdout: String4, - stderr: String4, - exitCode: Int +var make13 = (options) => withFiber2((fiber) => { + const context = fiber.context; + const scope = get(context, Scope); + const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== undefined ? fromInputUnsafe(options.idleTimeToLive) : undefined); + return as2(addFinalizerExit(scope, () => { + const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; + ref.state = stateClosed; + return close2; + }), ref); }); -var GhChunk = TaggedUnion({ - Stdout: { text: String4 }, - Stderr: { text: String4 } +var getState = (self) => uninterruptibleMask2(function loop(restore) { + switch (self.state._tag) { + case "Closed": { + return interrupt2; + } + case "Acquired": { + self.state.refCount++; + return self.state.fiber ? as2(interrupt3(self.state.fiber), self.state) : succeed6(self.state); + } + case "Empty": { + const scope = makeUnsafe3(); + return self.semaphore.withPermit(suspend2(() => { + if (self.state._tag !== "Empty") { + return loop(restore); + } + return restore(provideContext2(self.acquire, add(self.context, Scope, scope))).pipe(flatMap3((value) => { + if (self.state._tag === "Closed") { + return interrupt2; + } + const state = { + _tag: "Acquired", + value, + scope, + fiber: undefined, + refCount: 1, + invalidated: false + }; + self.state = state; + return succeed6(state); + }), onExit2((exit) => isFailure3(exit) ? close(scope, exit) : void_3)); + })); + } + } }); - -class Gh extends Service()("@timmo001/effect-gh/Gh") { -} -var stderrLimit = 65536; -var layer = (defaults = {}) => effect(Gh, gen2(function* () { - const spawner = yield* ChildProcessSpawner; - const open = fn2("Gh.stream")(function* (args, options) { - const executable = options.executable ?? "gh"; - const handle = yield* spawner.spawn(make19(executable, args, { - cwd: options.cwd, - env: { - ...defaults.env, - ...options.env, - GH_PROMPT_DISABLED: "1", - GH_PAGER: "cat", - PAGER: "cat", - NO_COLOR: "1", - CLICOLOR: "0", - CLICOLOR_FORCE: "0", - GH_FORCE_TTY: undefined, - GH_SPINNER_DISABLED: "1" - }, - extendEnv: true, - shell: false, - stdin: options.stdin === undefined ? "ignore" : "pipe", - stdout: "pipe", - stderr: "pipe", - forceKillAfter: "1 second" - })).pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))); - let stderr = ""; - let stderrTruncated = false; - const output = merge3(handle.stdout.pipe(decodeText(), map8((text) => GhChunk.cases.Stdout.make({ text }))), handle.stderr.pipe(decodeText(), map8((text) => { - stderrTruncated ||= stderr.length + text.length > stderrLimit; - stderr = (stderr + text).slice(-stderrLimit); - return GhChunk.cases.Stderr.make({ text }); - }))).pipe(mapError4((cause) => new GhPlatformError({ executable, cause }))); - const completion = gen2(function* () { - const exitCode = yield* handle.exitCode.pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))); - if (exitCode !== 0) { - return yield* new GhCommandError({ - executable, - exitCode, - stderr, - stderrTruncated - }); +var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { + const self = self_; + const state = yield* getState(self); + const scope = yield* scope2; + const isFinite2 = self.idleTimeToLive !== undefined && isFinite(self.idleTimeToLive); + yield* addFinalizerExit(scope, () => { + state.refCount--; + if (state.refCount > 0) { + return void_3; + } + if (self.idleTimeToLive === undefined || state.invalidated) { + if (self.state === state) { + self.state = stateEmpty; } - }); - const completed = output.pipe(concat(fromEffect2(completion).pipe(drain3))); - if (options.stdin === undefined) - return completed; - const input = isString(options.stdin) ? new TextEncoder().encode(options.stdin) : options.stdin; - return completed.pipe(mergeEffect2(run(succeed8(input), handle.stdin).pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))))); - }); - const stream = (args, overrides) => suspend4(() => { - const options = { ...defaults, ...overrides }; - const output = unwrap3(open(args, options)); - if (options.timeout == null) - return output; - if (!isFinite(fromInputUnsafe(options.timeout))) - return output; - const timeoutMs = toMillis(options.timeout); - return output.pipe(mergeEffect2(sleep2(options.timeout).pipe(andThen2(fail6(new GhTimeoutError({ - executable: options.executable ?? "gh", - timeoutMs - })))))); - }); - const execute = fn2("Gh.execute")(function* (args, options) { - return yield* stream(args, options).pipe(runFold2(() => ({ stdout: "", stderr: "", exitCode: 0 }), (output, chunk) => value2(chunk).pipe(tag2("Stdout", ({ text }) => ({ - ...output, - stdout: output.stdout + text - })), tag2("Stderr", ({ text }) => ({ - ...output, - stderr: output.stderr + text - })), exhaustive2))); - }); - const json = fn2("Gh.json")(function* (args, schema, options) { - const output = yield* execute(args, options); - return yield* decodeEffect2(fromJsonString2(schema))(output.stdout).pipe(mapError2((cause) => new GhDecodeError({ cause }))); - }); - return Gh.of({ execute, json, stream }); -})); -// src/action/ActionInputs.ts -var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; -var readRawInput = (name) => { - const value = process.env[inputEnvName(name)]; - return value === undefined || value === "" ? undefined : value; -}; -var readInputs = (names) => { - const inputs = {}; - for (const name of names) { - const value = readRawInput(name); - if (value !== undefined) - inputs[name] = value; - } - return inputs; -}; -var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); -// node_modules/effect/dist/Runtime.js -var defaultTeardown = (exit, onExit) => { - if (isSuccess3(exit)) - return onExit(0); - if (hasInterruptsOnly2(exit.cause)) - return onExit(130); - return onExit(getErrorExitCode(squash(exit.cause))); -}; -var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { - const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { - if (hasInterruptsOnly2(cause)) + return close(state.scope, void_2); + } else if (!isFinite2) { return void_3; - const isReported = getErrorReported(squash(cause)); - return isReported ? logError(cause) : void_3; - })); - try { - const keepAlive = globalThis.setInterval(constVoid, 2147483647); - fiber.addObserver(() => { - clearInterval(keepAlive); - }); - } catch {} - const teardown = options?.teardown ?? defaultTeardown; - return f({ - fiber, - teardown + } + state.fiber = sleep2(self.idleTimeToLive).pipe(flatMap3(() => { + if (self.state === state && state.refCount === 0) { + self.state = stateEmpty; + return close(state.scope, void_2); + } + return void_3; + }), ensuring2(sync3(() => { + state.fiber = undefined; + })), runForkWith2(self.context), runIn(self.scope)); + return void_3; }); + return state.value; }); -var errorExitCode = "~effect/Runtime/errorExitCode"; -var getErrorExitCode = (u) => { - if (typeof u === "object" && u !== null && errorExitCode in u) { - const code = u[errorExitCode]; - if (typeof code === "number") { - return code; + +// node_modules/effect/dist/RcRef.js +var make14 = make13; +var get3 = get2; + +// node_modules/effect/dist/Stream.js +var TypeId19 = "~effect/Stream"; +var isStream = (u) => hasProperty(u, TypeId19); +var fromChannel3 = fromChannel; +var fromEffect2 = (effect) => fromChannel3(fromEffect(map5(effect, of))); +var fromPull2 = (pull) => fromChannel3(fromPull(pull)); +var transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))); +var toChannel2 = (stream) => stream.channel; +var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); +var empty4 = /* @__PURE__ */ fromChannel3(empty3); +var succeed9 = (value) => fromChannel3(succeed8(of(value))); +var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); +var fromArray2 = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel3(succeed8(array)) : empty4; +var unwrap3 = (effect) => fromChannel3(unwrap(map5(effect, toChannel2))); +var map7 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { + let i = 0; + return fromChannel3(map6(self.channel, map((o) => f(o, i++)))); +})); +var flatMap5 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options) => self.channel.pipe(flattenArray, flatMap4((a) => f(a).channel, options), fromChannel3)); +var flatten4 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => flatMap5(self, identity, options)); +var drain3 = (self) => fromChannel3(drain(self.channel)); +var concat = /* @__PURE__ */ dual(2, (self, that) => flatten4(fromArray2([self, that]))); +var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); +var mergeEffect2 = /* @__PURE__ */ dual(2, (self, effect) => self.channel.pipe(mergeEffect(effect), fromChannel3)); +var mapError5 = /* @__PURE__ */ dual(2, (self, f) => fromChannel3(mapError4(self.channel, f))); +var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { + let done; + let leftover; + const upstreamWithLeftover = suspend2(() => { + if (leftover !== undefined) { + const chunk = leftover; + leftover = undefined; + return succeed6(chunk); } + return upstream; + }).pipe(catch_2((error) => { + done = fail5(error); + return done2(); + })); + const pull = map5(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { + leftover = leftover_; + return of(value); + }); + return suspend2(() => done ? done : pull); +}))); +var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { + const decoder = new TextDecoder(options?.encoding); + return map7(self, (chunk) => decoder.decode(chunk, { + stream: true + })); +})); +var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); +var run2 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map5(([a]) => a)))); +var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { + for (let i = 0;i < chunk.length; i++) { + acc.push(chunk[i]); } - return 1; -}; -var errorReported = "~effect/Runtime/errorReported"; -var getErrorReported = (u) => { - if (typeof u === "object" && u !== null && errorReported in u) { - const isReported = u[errorReported]; - if (typeof isReported === "boolean") { - return isReported; - } + return acc; +}); +var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channel, initial, (acc, arr) => { + for (let i = 0;i < arr.length; i++) { + acc = f(acc, arr[i]); } - return true; -}; + return acc; +})); +var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => { + let i = 0; + return whileLoop2({ + while: () => i < arr.length, + body: () => f(arr[i++]), + step: constVoid + }); +})); +var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); -// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js -var runMain = /* @__PURE__ */ makeRunMain(({ - fiber, - teardown -}) => { - let receivedSignal = false; - fiber.addObserver((exit) => { - process.removeListener("SIGINT", onSigint); - process.removeListener("SIGTERM", onSigint); - teardown(exit, (code) => { - if (receivedSignal || code !== 0) { - process.exit(code); - } +// node_modules/effect/dist/FileSystem.js +var TypeId20 = "~effect/FileSystem"; +var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); +var make15 = (impl) => FileSystem.of({ + ...impl, + [TypeId20]: TypeId20, + exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), + readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ + try: () => new TextDecoder(encoding).decode(_), + catch: (cause) => badArgument({ + module: "FileSystem", + method: "readFileString", + description: "invalid encoding", + cause + }) + })), + stream: fnUntraced2(function* (path, options) { + const file = yield* impl.open(path, { + flag: "r" }); - }); - function onSigint() { - receivedSignal = true; - fiber.interruptUnsafe(fiber.id); - } - process.on("SIGINT", onSigint); - process.on("SIGTERM", onSigint); + const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset); + if (offset) { + yield* file.seek(offset, "start"); + } + const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead); + let totalBytesRead = BigInt(0); + const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024)); + const readChunk = file.readAlloc(chunkSize); + return fromPull2(succeed6(flatMap3(suspend2(() => { + if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { + return done2(); + } + return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; + }), match({ + onNone: () => done2(), + onSome: (buf) => { + totalBytesRead += BigInt(buf.length); + return succeed6(of(buf)); + } + })))); + }, unwrap3), + sink: (path, options) => pipe(impl.open(path, { + ...options, + flag: options?.flag ?? "w" + }), map5((file) => forEach3((_) => file.writeAll(_))), unwrap2), + writeFileString: (path, data, options) => flatMap3(try_2({ + try: () => new TextEncoder().encode(data), + catch: (cause) => badArgument({ + module: "FileSystem", + method: "writeFileString", + description: "could not encode string", + cause + }) + }), (_) => impl.writeFile(path, _, options)) }); +var FileTypeId = "~effect/FileSystem/File"; +class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBackend")) { +} -// node_modules/@effect/platform-node/dist/NodeRuntime.js -var runMain2 = runMain; // node_modules/effect/dist/Path.js -var TypeId24 = "~effect/Path"; -var Path2 = /* @__PURE__ */ Service("effect/Path"); +var TypeId21 = "~effect/Path"; +var Path = /* @__PURE__ */ Service("effect/Path"); function normalizeStringPosix(path, allowAboveRoot) { let res = ""; let lastSegmentLength = 0; @@ -9425,7 +9097,7 @@ function fromFileUrl(url) { } return succeed6(decodeURIComponent(pathname)); } -var resolve2 = function resolve() { +var resolve3 = function resolve() { let resolvedPath = ""; let resolvedAbsolute = false; let cwd = undefined; @@ -9462,7 +9134,7 @@ var resolve2 = function resolve() { var CHAR_FORWARD_SLASH = 47; function toFileUrl(filepath) { const outURL = new URL("file://"); - let resolved = resolve2(filepath); + let resolved = resolve3(filepath); const filePathLast = filepath.charCodeAt(filepath.length - 1); if (filePathLast === CHAR_FORWARD_SLASH && resolved[resolved.length - 1] !== "/") { resolved += "/"; @@ -9494,9 +9166,9 @@ function encodePathChars(filepath) { } return filepath; } -var posixImpl = /* @__PURE__ */ Path2.of({ - [TypeId24]: TypeId24, - resolve: resolve2, +var posixImpl = /* @__PURE__ */ Path.of({ + [TypeId21]: TypeId21, + resolve: resolve3, normalize(path) { if (path.length === 0) return "."; @@ -9663,144 +9335,782 @@ var posixImpl = /* @__PURE__ */ Path2.of({ } } } - if (start === end) - end = firstNonSlashEnd; - else if (end === -1) - end = path.length; - return path.slice(start, end); - } else { - for (i = path.length - 1;i >= 0; --i) { - if (path.charCodeAt(i) === 47) { - if (!matchedSlash) { - start = i + 1; - break; - } - } else if (end === -1) { - matchedSlash = false; - end = i + 1; - } + if (start === end) + end = firstNonSlashEnd; + else if (end === -1) + end = path.length; + return path.slice(start, end); + } else { + for (i = path.length - 1;i >= 0; --i) { + if (path.charCodeAt(i) === 47) { + if (!matchedSlash) { + start = i + 1; + break; + } + } else if (end === -1) { + matchedSlash = false; + end = i + 1; + } + } + if (end === -1) + return ""; + return path.slice(start, end); + } + }, + extname(path) { + let startDot = -1; + let startPart = 0; + let end = -1; + let matchedSlash = true; + let preDotState = 0; + for (let i = path.length - 1;i >= 0; --i) { + const code = path.charCodeAt(i); + if (code === 47) { + if (!matchedSlash) { + startPart = i + 1; + break; + } + continue; + } + if (end === -1) { + matchedSlash = false; + end = i + 1; + } + if (code === 46) { + if (startDot === -1) { + startDot = i; + } else if (preDotState !== 1) { + preDotState = 1; + } + } else if (startDot !== -1) { + preDotState = -1; + } + } + if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + return ""; + } + return path.slice(startDot, end); + }, + format: function format(pathObject) { + if (pathObject === null || typeof pathObject !== "object") { + throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); + } + return _format("/", pathObject); + }, + parse(path) { + const ret = { + root: "", + dir: "", + base: "", + ext: "", + name: "" + }; + if (path.length === 0) + return ret; + let code = path.charCodeAt(0); + const isAbsolute = code === 47; + let start; + if (isAbsolute) { + ret.root = "/"; + start = 1; + } else { + start = 0; + } + let startDot = -1; + let startPart = 0; + let end = -1; + let matchedSlash = true; + let i = path.length - 1; + let preDotState = 0; + for (;i >= start; --i) { + code = path.charCodeAt(i); + if (code === 47) { + if (!matchedSlash) { + startPart = i + 1; + break; + } + continue; + } + if (end === -1) { + matchedSlash = false; + end = i + 1; + } + if (code === 46) { + if (startDot === -1) + startDot = i; + else if (preDotState !== 1) + preDotState = 1; + } else if (startDot !== -1) { + preDotState = -1; + } + } + if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + if (end !== -1) { + if (startPart === 0 && isAbsolute) + ret.base = ret.name = path.slice(1, end); + else + ret.base = ret.name = path.slice(startPart, end); + } + } else { + if (startPart === 0 && isAbsolute) { + ret.name = path.slice(1, startDot); + ret.base = path.slice(1, end); + } else { + ret.name = path.slice(startPart, startDot); + ret.base = path.slice(startPart, end); + } + ret.ext = path.slice(startDot, end); + } + if (startPart > 0) + ret.dir = path.slice(0, startPart - 1); + else if (isAbsolute) + ret.dir = "/"; + return ret; + }, + sep: "/", + fromFileUrl, + toFileUrl, + toNamespacedPath: identity +}); +// node_modules/effect/dist/internal/ulid.js +var maxTimestamp = 2 ** 48 - 1; +var base32Chars = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; +var ulidString = (timestampMillis, bytes) => { + if (bytes.length !== 10) { + throw new Error(`ULID randomness must be exactly 10 bytes, received ${bytes.length}`); + } + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxTimestamp); + let out = ""; + for (let shift = 45;shift >= 0; shift -= 5) { + out += base32Chars[Math.floor(timestamp / 2 ** shift) & 31]; + } + let accumulator = 0; + let bits = 0; + for (const byte of bytes) { + accumulator = accumulator << 8 | byte; + bits += 8; + while (bits >= 5) { + bits -= 5; + out += base32Chars[accumulator >>> bits & 31]; + } + accumulator &= (1 << bits) - 1; + } + return out; +}; + +// node_modules/effect/dist/internal/uuid.js +var hex = (byte) => byte.toString(16).padStart(2, "0"); +var stringify = (bytes) => { + const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; + return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); +}; +var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); +function v4Bytes(bytes = randomBytes()) { + bytes[6] = bytes[6] & 15 | 64; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); +var maxV7Timestamp = 2 ** 48 - 1; +function v7Bytes(timestampMillis, bytes = randomBytes()) { + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); + bytes[0] = Math.floor(timestamp / 2 ** 40); + bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; + bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; + bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; + bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; + bytes[5] = timestamp & 255; + bytes[6] = bytes[6] & 15 | 112; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); + +// node_modules/effect/dist/Crypto.js +var TypeId22 = "~effect/Crypto"; +var Crypto = /* @__PURE__ */ Service("effect/Crypto"); +var make16 = (impl) => { + const randomBytesUnsafe = impl.randomBytes; + const randomBytes = (size) => map5(validateSize("randomBytes", size), randomBytesUnsafe); + const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; + const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; + const nextIntUnsafe = () => { + while (true) { + const bytes = randomBytesUnsafe(7); + const value = readUint53(bytes); + if ((bytes[0] & 32) === 0) { + return value + Number.MIN_SAFE_INTEGER; + } + if (value < Number.MAX_SAFE_INTEGER) { + return value + 1; } - if (end === -1) - return ""; - return path.slice(start, end); } - }, - extname(path) { - let startDot = -1; - let startPart = 0; - let end = -1; - let matchedSlash = true; - let preDotState = 0; - for (let i = path.length - 1;i >= 0; --i) { - const code = path.charCodeAt(i); - if (code === 47) { - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; + }; + return Crypto.of({ + [TypeId22]: TypeId22, + randomBytes, + nextDoubleUnsafe, + nextIntUnsafe, + digest: impl.digest, + random: sync3(() => nextDoubleUnsafe()), + randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), + randomInt: sync3(() => nextIntUnsafe()), + randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), + randomIntBetween(min, max, options) { + const extra = options?.halfOpen === true ? 0 : 1; + return sync3(() => { + const minInt = Math.ceil(min); + const maxInt = Math.floor(max); + return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; + }); + }, + randomShuffle: (elements) => sync3(() => { + const buffer = Array.from(elements); + for (let i = buffer.length - 1;i >= 1; i = i - 1) { + const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); + const value = buffer[i]; + buffer[i] = buffer[index]; + buffer[index] = value; } - if (end === -1) { - matchedSlash = false; - end = i + 1; + return buffer; + }), + randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), + randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))), + randomULID: clockWith2((clock) => succeed6(ulidString(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(10)))) + }); +}; +var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ + module: "Crypto", + method, + description: "size must be a non-negative safe integer" +})); +// node_modules/effect/dist/internal/matcher.js +var TypeId23 = "~effect/Match/Matcher"; +var TypeMatcherProto = { + [TypeId23]: { + _input: identity, + _filters: identity, + _remaining: identity, + _result: identity, + _return: identity, + _args: identity + }, + _tag: "TypeMatcher", + add(_case) { + return makeTypeMatcher(this.select, [...this.cases, _case]); + }, + pipe() { + return pipeArguments(this, arguments); + } +}; +function makeTypeMatcher(select, cases) { + const matcher = Object.create(TypeMatcherProto); + matcher.select = select; + matcher.cases = cases; + return matcher; +} +var ValueMatcherProto = { + [TypeId23]: { + _input: identity, + _filters: identity, + _result: identity, + _return: identity, + _flavor: identity + }, + _tag: "ValueMatcher", + add(_case) { + if (isSuccess2(this.value)) { + return this; + } + if (_case._tag === "When" && _case.guard(this.provided) === true) { + return makeValueMatcher(this.provided, succeed2(_case.evaluate(this.provided))); + } else if (_case._tag === "Not" && _case.guard(this.provided) === false) { + return makeValueMatcher(this.provided, succeed2(_case.evaluate(this.provided))); + } + return this; + }, + pipe() { + return pipeArguments(this, arguments); + } +}; +function makeValueMatcher(provided, value) { + const matcher = Object.create(ValueMatcherProto); + matcher.provided = provided; + matcher.value = value; + return matcher; +} +var makeWhen = (guard, evaluate) => ({ + _tag: "When", + guard, + evaluate +}); +var value = (i) => makeValueMatcher(i, fail2(i)); +var discriminator = (field) => (...pattern) => { + const f = pattern[pattern.length - 1]; + const values = pattern.slice(0, -1); + const pred = values.length === 1 ? (_) => _ != null && _[field] === values[0] : (_) => _ != null && values.includes(_[field]); + return (self) => self.add(makeWhen(pred, f)); +}; +var tag2 = /* @__PURE__ */ discriminator("_tag"); +var result2 = (self) => { + if (self._tag === "ValueMatcher") { + return self.value; + } + const len = self.cases.length; + if (len === 1) { + const _case = self.cases[0]; + return (...args) => { + const input = self.select(...args); + if (_case._tag === "When" && _case.guard(input) === true) { + return succeed2(_case.evaluate(input, ...args)); + } else if (_case._tag === "Not" && _case.guard(input) === false) { + return succeed2(_case.evaluate(input, ...args)); } - if (code === 46) { - if (startDot === -1) { - startDot = i; - } else if (preDotState !== 1) { - preDotState = 1; - } - } else if (startDot !== -1) { - preDotState = -1; + return fail2(input); + }; + } + return (...args) => { + const input = self.select(...args); + for (let i = 0;i < len; i++) { + const _case = self.cases[i]; + if (_case._tag === "When" && _case.guard(input) === true) { + return succeed2(_case.evaluate(input, ...args)); + } else if (_case._tag === "Not" && _case.guard(input) === false) { + return succeed2(_case.evaluate(input, ...args)); } } - if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - return ""; + return fail2(input); + }; +}; +var getExhaustiveAbsurdErrorMessage = "effect/match/Match/exhaustive: absurd"; +var exhaustive = (self) => { + const toResult = result2(self); + if (isResult2(toResult)) { + if (isSuccess2(toResult)) { + return toResult.success; + } + throw new Error(getExhaustiveAbsurdErrorMessage); + } + return (...args) => { + const result = toResult(...args); + if (isSuccess2(result)) { + return result.success; + } + throw new Error(getExhaustiveAbsurdErrorMessage); + }; +}; + +// node_modules/effect/dist/Match.js +var value2 = value; +var tag3 = tag2; +var exhaustive2 = exhaustive; +// node_modules/effect/dist/Ref.js +var TypeId24 = "~effect/Ref"; +var RefProto = { + [TypeId24]: { + _A: identity + }, + ...PipeInspectableProto, + toJSON() { + return { + _id: "Ref", + ref: this.ref + }; + } +}; +var makeUnsafe6 = (value) => { + const self = Object.create(RefProto); + self.ref = make7(value); + return self; +}; +var make17 = (value) => sync3(() => makeUnsafe6(value)); +var get4 = (self) => sync3(() => self.ref.current); +var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { + self.ref.current = f(self.ref.current); +})); +// node_modules/effect/dist/Runtime.js +var defaultTeardown = (exit, onExit) => { + if (isSuccess3(exit)) + return onExit(0); + if (hasInterruptsOnly2(exit.cause)) + return onExit(130); + return onExit(getErrorExitCode(squash(exit.cause))); +}; +var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { + const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { + if (hasInterruptsOnly2(cause)) + return void_3; + const isReported = getErrorReported(squash(cause)); + return isReported ? logError(cause) : void_3; + })); + try { + const keepAlive = globalThis.setInterval(constVoid, 2147483647); + fiber.addObserver(() => { + clearInterval(keepAlive); + }); + } catch {} + const teardown = options?.teardown ?? defaultTeardown; + return f({ + fiber, + teardown + }); +}); +var errorExitCode = "~effect/Runtime/errorExitCode"; +var getErrorExitCode = (u) => { + if (typeof u === "object" && u !== null && errorExitCode in u) { + const code = u[errorExitCode]; + if (typeof code === "number") { + return code; } - return path.slice(startDot, end); - }, - format: function format(pathObject) { - if (pathObject === null || typeof pathObject !== "object") { - throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); + } + return 1; +}; +var errorReported = "~effect/Runtime/errorReported"; +var getErrorReported = (u) => { + if (typeof u === "object" && u !== null && errorReported in u) { + const isReported = u[errorReported]; + if (typeof isReported === "boolean") { + return isReported; } - return _format("/", pathObject); - }, - parse(path) { - const ret = { - root: "", - dir: "", - base: "", - ext: "", - name: "" + } + return true; +}; +// node_modules/effect/dist/Stdio.js +var TypeId25 = "~effect/Stdio"; +var Stdio = /* @__PURE__ */ Service(TypeId25); +var make18 = (options) => ({ + [TypeId25]: TypeId25, + stdinIsTerminal: succeed6(false), + stdoutIsTerminal: succeed6(false), + ...options +}); +// node_modules/effect/dist/Terminal.js +var TypeId26 = "~effect/Terminal"; +var QuitErrorTypeId = "~effect/Terminal/QuitError"; + +class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ + _tag: /* @__PURE__ */ tag("QuitError") +})) { + [QuitErrorTypeId] = QuitErrorTypeId; +} +var Terminal = /* @__PURE__ */ Service("effect/Terminal"); +var make19 = (impl) => Terminal.of({ + ...impl, + [TypeId26]: TypeId26 +}); +// node_modules/effect/dist/unstable/process/ChildProcessSpawner.js +var ExitCode = /* @__PURE__ */ nominal(); +var ProcessId = /* @__PURE__ */ nominal(); +var HandleTypeId = "~effect/process/ChildProcessSpawner/ChildProcessHandle"; +var HandleProto = { + [HandleTypeId]: HandleTypeId, + ...BaseProto, + toJSON() { + return { + _id: "ChildProcessHandle", + pid: this.pid }; - if (path.length === 0) - return ret; - let code = path.charCodeAt(0); - const isAbsolute = code === 47; - let start; - if (isAbsolute) { - ret.root = "/"; - start = 1; - } else { - start = 0; + } +}; +var makeHandle = (params) => Object.setPrototypeOf({ + ...params +}, HandleProto); +var make20 = (spawn) => { + const streamString = (command, options) => spawn(command).pipe(map5((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); + const streamLines = (command, options) => splitLines2(streamString(command, options)); + return ChildProcessSpawner.of({ + spawn, + exitCode: (command) => scoped2(flatMap3(spawn(command), (handle) => handle.exitCode)), + streamString, + streamLines, + lines: (command, options) => runCollect(streamLines(command, options)), + string: (command, options) => mkString(streamString(command, options)) + }); +}; + +class ChildProcessSpawner extends (/* @__PURE__ */ Service()("effect/process/ChildProcessSpawner")) { +} + +// node_modules/effect/dist/unstable/process/ChildProcess.js +var TypeId27 = "~effect/process/ChildProcess"; +var Proto2 = { + .../* @__PURE__ */ Prototype2({ + label: "Command", + evaluate(fiber) { + return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this); } - let startDot = -1; - let startPart = 0; - let end = -1; - let matchedSlash = true; - let i = path.length - 1; - let preDotState = 0; - for (;i >= start; --i) { - code = path.charCodeAt(i); - if (code === 47) { - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; - } - if (end === -1) { - matchedSlash = false; - end = i + 1; + }), + [TypeId27]: TypeId27 +}; +var makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto2), { + _tag: "StandardCommand", + command, + args, + options +}); +var make21 = function make(...args) { + if (isTemplateString(args[0])) { + const [templates, ...expressions] = args; + const tokens = parseTemplates(templates, expressions); + return makeStandardCommand(tokens[0] ?? "", tokens.slice(1), {}); + } + if (typeof args[0] === "object" && !Array.isArray(args[0]) && !isTemplateString(args[0])) { + const options = args[0]; + return function(templates, ...expressions) { + const tokens = parseTemplates(templates, expressions); + return makeStandardCommand(tokens[0] ?? "", tokens.slice(1), options); + }; + } + if (typeof args[0] === "string" && !Array.isArray(args[1])) { + const [command, options = {}] = args; + return makeStandardCommand(command, [], options); + } + const [command, cmdArgs = [], options = {}] = args; + return makeStandardCommand(command, cmdArgs, options); +}; +var isTemplateString = (u) => Array.isArray(u) && ("raw" in u) && Array.isArray(u.raw); +var parseFdName = (name) => { + const match = /^fd(\d+)$/.exec(name); + if (match === null) + return; + const fd = parseInt(match[1], 10); + return fd >= 3 ? fd : undefined; +}; +var fdName = (fd) => `fd${fd}`; +var parseTemplates = (templates, expressions) => { + let tokens = []; + for (const [index, template] of templates.entries()) { + tokens = parseTemplate(templates, expressions, tokens, template, index); + } + return tokens; +}; +var parseTemplate = (templates, expressions, prevTokens, template, index) => { + const rawTemplate = templates.raw[index]; + if (rawTemplate === undefined) { + throw new Error(`Invalid backslash sequence: ${templates.raw[index]}`); + } + const { + hasLeadingWhitespace, + hasTrailingWhitespace, + tokens + } = splitByWhitespaces(template, rawTemplate); + const nextTokens = concatTokens(prevTokens, tokens, hasLeadingWhitespace); + if (index === expressions.length) { + return nextTokens; + } + const expression = expressions[index]; + const expressionTokens = Array.isArray(expression) ? expression.map((expression) => parseExpression(expression)) : [parseExpression(expression)]; + return concatTokens(nextTokens, expressionTokens, hasTrailingWhitespace); +}; +var parseExpression = (expression) => { + const type = typeof expression; + if (type === "string") { + return expression; + } + return String(expression); +}; +var DELIMITERS = /* @__PURE__ */ new Set([" ", "\t", "\r", ` +`]); +var ESCAPE_LENGTH = { + x: 3, + u: 5 +}; +var splitByWhitespaces = (template, rawTemplate) => { + if (rawTemplate.length === 0) { + return { + tokens: [], + hasLeadingWhitespace: false, + hasTrailingWhitespace: false + }; + } + const hasLeadingWhitespace = DELIMITERS.has(rawTemplate[0]); + const tokens = []; + let templateCursor = 0; + for (let templateIndex = 0, rawIndex = 0;templateIndex < template.length; templateIndex += 1, rawIndex += 1) { + const rawCharacter = rawTemplate[rawIndex]; + if (DELIMITERS.has(rawCharacter)) { + if (templateCursor !== templateIndex) { + tokens.push(template.slice(templateCursor, templateIndex)); } - if (code === 46) { - if (startDot === -1) - startDot = i; - else if (preDotState !== 1) - preDotState = 1; - } else if (startDot !== -1) { - preDotState = -1; + templateCursor = templateIndex + 1; + } else if (rawCharacter === "\\") { + const nextRawCharacter = rawTemplate[rawIndex + 1]; + if (nextRawCharacter === ` +`) { + templateIndex -= 1; + rawIndex += 1; + } else if (nextRawCharacter === "u" && rawTemplate[rawIndex + 2] === "{") { + const end = rawTemplate.indexOf("}", rawIndex + 3); + if (parseInt(rawTemplate.slice(rawIndex + 3, end), 16) > 65535) { + templateIndex += 1; + } + rawIndex = end; + } else { + rawIndex += ESCAPE_LENGTH[nextRawCharacter] ?? 1; } } - if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - if (end !== -1) { - if (startPart === 0 && isAbsolute) - ret.base = ret.name = path.slice(1, end); - else - ret.base = ret.name = path.slice(startPart, end); + } + const hasTrailingWhitespace = templateCursor === template.length; + if (!hasTrailingWhitespace) { + tokens.push(template.slice(templateCursor)); + } + return { + tokens, + hasLeadingWhitespace, + hasTrailingWhitespace + }; +}; +var concatTokens = (prevTokens, nextTokens, isSeparated) => isSeparated || prevTokens.length === 0 || nextTokens.length === 0 ? [...prevTokens, ...nextTokens] : [...prevTokens.slice(0, -1), `${prevTokens.at(-1)}${nextTokens.at(0)}`, ...nextTokens.slice(1)]; +// node_modules/@timmo001/effect-gh/src/errors.ts +class GhCommandError extends TaggedError3()("GhCommandError", { + executable: String4, + exitCode: Int, + stderr: String4, + stderrTruncated: Boolean2 +}) { +} + +class GhPlatformError extends TaggedError3()("GhPlatformError", { executable: String4, cause: Defect() }) { +} + +class GhTimeoutError extends TaggedError3()("GhTimeoutError", { executable: String4, timeoutMs: Finite }) { +} + +class GhDecodeError extends TaggedError3()("GhDecodeError", { cause: Defect() }) { +} + +// node_modules/@timmo001/effect-gh/src/gh.ts +var GhOutput = Struct({ + stdout: String4, + stderr: String4, + exitCode: Int +}); +var GhChunk = TaggedUnion({ + Stdout: { text: String4 }, + Stderr: { text: String4 } +}); + +class Gh extends Service()("@timmo001/effect-gh/Gh") { +} +var stderrLimit = 65536; +var layer = (defaults = {}) => effect(Gh, gen2(function* () { + const spawner = yield* ChildProcessSpawner; + const open = fn2("Gh.stream")(function* (args, options) { + const executable = options.executable ?? "gh"; + const handle = yield* spawner.spawn(make21(executable, args, { + cwd: options.cwd, + env: { + ...defaults.env, + ...options.env, + GH_PROMPT_DISABLED: "1", + GH_PAGER: "cat", + PAGER: "cat", + NO_COLOR: "1", + CLICOLOR: "0", + CLICOLOR_FORCE: "0", + GH_FORCE_TTY: undefined, + GH_SPINNER_DISABLED: "1" + }, + extendEnv: true, + shell: false, + stdin: options.stdin === undefined ? "ignore" : "pipe", + stdout: "pipe", + stderr: "pipe", + forceKillAfter: "1 second" + })).pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))); + let stderr = ""; + let stderrTruncated = false; + const output = merge3(handle.stdout.pipe(decodeText(), map7((text) => GhChunk.cases.Stdout.make({ text }))), handle.stderr.pipe(decodeText(), map7((text) => { + stderrTruncated ||= stderr.length + text.length > stderrLimit; + stderr = (stderr + text).slice(-stderrLimit); + return GhChunk.cases.Stderr.make({ text }); + }))).pipe(mapError5((cause) => new GhPlatformError({ executable, cause }))); + const completion = gen2(function* () { + const exitCode = yield* handle.exitCode.pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))); + if (exitCode !== 0) { + return yield* new GhCommandError({ + executable, + exitCode, + stderr, + stderrTruncated + }); } - } else { - if (startPart === 0 && isAbsolute) { - ret.name = path.slice(1, startDot); - ret.base = path.slice(1, end); - } else { - ret.name = path.slice(startPart, startDot); - ret.base = path.slice(startPart, end); + }); + const completed = output.pipe(concat(fromEffect2(completion).pipe(drain3))); + if (options.stdin === undefined) + return completed; + const input = isString(options.stdin) ? new TextEncoder().encode(options.stdin) : options.stdin; + return completed.pipe(mergeEffect2(run2(succeed9(input), handle.stdin).pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))))); + }); + const stream = (args, overrides) => suspend4(() => { + const options = { ...defaults, ...overrides }; + const output = unwrap3(open(args, options)); + if (options.timeout == null) + return output; + if (!isFinite(fromInputUnsafe(options.timeout))) + return output; + const timeoutMs = toMillis(options.timeout); + return output.pipe(mergeEffect2(sleep2(options.timeout).pipe(andThen2(fail6(new GhTimeoutError({ + executable: options.executable ?? "gh", + timeoutMs + })))))); + }); + const execute = fn2("Gh.execute")(function* (args, options) { + return yield* stream(args, options).pipe(runFold2(() => ({ stdout: "", stderr: "", exitCode: 0 }), (output, chunk) => value2(chunk).pipe(tag3("Stdout", ({ text }) => ({ + ...output, + stdout: output.stdout + text + })), tag3("Stderr", ({ text }) => ({ + ...output, + stderr: output.stderr + text + })), exhaustive2))); + }); + const json = fn2("Gh.json")(function* (args, schema, options) { + const output = yield* execute(args, options); + return yield* decodeEffect2(fromJsonString2(schema))(output.stdout).pipe(mapError2((cause) => new GhDecodeError({ cause }))); + }); + return Gh.of({ execute, json, stream }); +})); +// src/action/ActionInputs.ts +var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; +var readRawInput = (name) => { + const value = process.env[inputEnvName(name)]; + return value === undefined || value === "" ? undefined : value; +}; +var readInputs = (names) => { + const inputs = {}; + for (const name of names) { + const value = readRawInput(name); + if (value !== undefined) + inputs[name] = value; + } + return inputs; +}; +var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); +// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js +var runMain = /* @__PURE__ */ makeRunMain(({ + fiber, + teardown +}) => { + let receivedSignal = false; + fiber.addObserver((exit) => { + process.removeListener("SIGINT", onSigint); + process.removeListener("SIGTERM", onSigint); + teardown(exit, (code) => { + if (receivedSignal || code !== 0) { + process.exit(code); } - ret.ext = path.slice(startDot, end); - } - if (startPart > 0) - ret.dir = path.slice(0, startPart - 1); - else if (isAbsolute) - ret.dir = "/"; - return ret; - }, - sep: "/", - fromFileUrl, - toFileUrl, - toNamespacedPath: identity + }); + }); + function onSigint() { + receivedSignal = true; + fiber.interruptUnsafe(fiber.id); + } + process.on("SIGINT", onSigint); + process.on("SIGTERM", onSigint); }); +// node_modules/@effect/platform-node/dist/NodeRuntime.js +var runMain2 = runMain; // node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js import * as NodeChildProcess from "node:child_process"; import { PassThrough } from "node:stream"; @@ -9893,10 +10203,10 @@ var pullIntoWritable = (options) => options.pull.pipe(flatMap3((chunk) => { disableYield: true }), options.endOnDone !== false ? catchDone((_) => { if ("closed" in options.writable && options.writable.closed) { - return done3(_); + return done2(_); } return callback2((resume) => { - const onFinish = () => resume(done3(_)); + const onFinish = () => resume(done2(_)); options.writable.once("finish", onFinish); options.writable.end(); return sync3(() => { @@ -9929,11 +10239,11 @@ var readableToPullUnsafe = (options) => { latch.openUnsafe(); } function onError(error) { - exit.current = fail4(options.onError(error)); + exit.current = fail5(options.onError(error)); latch.openUnsafe(); } function onEnd() { - exit.current = fail4(Done2()); + exit.current = fail5(Done2()); latch.openUnsafe(); } readable.on("readable", onReadable); @@ -10002,9 +10312,9 @@ var isProcessAlive = (childProcess, exitSignal) => { var taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { windowsHide: true }, onExit); -var make20 = /* @__PURE__ */ gen2(function* () { +var make22 = /* @__PURE__ */ gen2(function* () { const fs = yield* FileSystem; - const path = yield* Path2; + const path = yield* Path; const resolveWorkingDirectory = fnUntraced2(function* (options) { if (isUndefined(options.cwd)) return; @@ -10125,7 +10435,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { }); } if (config.stream) { - yield* forkScoped2(run(config.stream, sink)); + yield* forkScoped2(run2(config.stream, sink)); } inputSinks.set(fd, sink); break; @@ -10165,7 +10475,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { }); } if (isStream(config.stream)) { - return as2(forkScoped2(run(config.stream, sink)), sink); + return as2(forkScoped2(run2(config.stream, sink)), sink); } return succeed6(sink); }); @@ -10321,7 +10631,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { env, stdio }, process.platform)), fnUntraced2(function* ([childProcess, exitSignal]) { - const exited = yield* isDone2(exitSignal); + const exited = yield* isDone3(exitSignal); if (exited) { const [code] = yield* _await(exitSignal); if (code !== 0 && isNotNull(code)) { @@ -10363,7 +10673,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds); - const isRunning = map6(isDone2(exitSignal), (done) => !done); + const isRunning = map5(isDone3(exitSignal), (done) => !done); const exitCode = flatMap3(_await(exitSignal), ([code, signal]) => { if (isNotNull(code)) { return succeed6(ExitCode(code)); @@ -10400,7 +10710,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { const sourceStream = unwrap3(succeed6(getSourceStream(handles[handles.length - 1], options.from))); const toOption = options.to ?? "stdin"; if (toOption === "stdin") { - handles.push(yield* spawnCommand(make19(command.command, command.args, { + handles.push(yield* spawnCommand(make21(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -10412,7 +10722,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { if (isNotUndefined(fd)) { const fdName2 = fdName(fd); const existingFds = command.options.additionalFds ?? {}; - handles.push(yield* spawnCommand(make19(command.command, command.args, { + handles.push(yield* spawnCommand(make21(command.command, command.args, { ...command.options, additionalFds: { ...existingFds, @@ -10423,7 +10733,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { } }))); } else { - handles.push(yield* spawnCommand(make19(command.command, command.args, { + handles.push(yield* spawnCommand(make21(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -10462,9 +10772,9 @@ var make20 = /* @__PURE__ */ gen2(function* () { } } }); - return make18(spawnCommand); + return make20(spawnCommand); }); -var layer2 = /* @__PURE__ */ effect(ChildProcessSpawner, make20); +var layer2 = /* @__PURE__ */ effect(ChildProcessSpawner, make22); var flattenCommand = (command) => { const commands = []; const pipeOptions = []; @@ -10494,92 +10804,6 @@ var flattenCommand = (command) => { }; }; -// node_modules/effect/dist/internal/uuid.js -var hex = (byte) => byte.toString(16).padStart(2, "0"); -var stringify = (bytes) => { - const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; - return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); -}; -var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); -function v4Bytes(bytes = randomBytes()) { - bytes[6] = bytes[6] & 15 | 64; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); -var maxV7Timestamp = 2 ** 48 - 1; -function v7Bytes(timestampMillis, bytes = randomBytes()) { - const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); - bytes[0] = Math.floor(timestamp / 2 ** 40); - bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; - bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; - bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; - bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; - bytes[5] = timestamp & 255; - bytes[6] = bytes[6] & 15 | 112; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); - -// node_modules/effect/dist/Crypto.js -var TypeId25 = "~effect/Crypto"; -var Crypto2 = /* @__PURE__ */ Service("effect/Crypto"); -var make21 = (impl) => { - const randomBytesUnsafe = impl.randomBytes; - const randomBytes = (size) => map6(validateSize("randomBytes", size), randomBytesUnsafe); - const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; - const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; - const nextIntUnsafe = () => { - while (true) { - const bytes = randomBytesUnsafe(7); - const value = readUint53(bytes); - if ((bytes[0] & 32) === 0) { - return value + Number.MIN_SAFE_INTEGER; - } - if (value < Number.MAX_SAFE_INTEGER) { - return value + 1; - } - } - }; - return Crypto2.of({ - [TypeId25]: TypeId25, - randomBytes, - nextDoubleUnsafe, - nextIntUnsafe, - digest: impl.digest, - random: sync3(() => nextDoubleUnsafe()), - randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), - randomInt: sync3(() => nextIntUnsafe()), - randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), - randomIntBetween(min, max, options) { - const extra = options?.halfOpen === true ? 0 : 1; - return sync3(() => { - const minInt = Math.ceil(min); - const maxInt = Math.floor(max); - return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; - }); - }, - randomShuffle: (elements) => sync3(() => { - const buffer = Array.from(elements); - for (let i = buffer.length - 1;i >= 1; i = i - 1) { - const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); - const value = buffer[i]; - buffer[i] = buffer[index]; - buffer[index] = value; - } - return buffer; - }), - randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), - randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))) - }); -}; -var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ - module: "Crypto", - method, - description: "size must be a non-negative safe integer" -})); - // node_modules/@effect/platform-node-shared/dist/NodeCrypto.js import * as NodeCrypto from "node:crypto"; var toHashAlgorithm = (algorithm) => { @@ -10604,20 +10828,20 @@ var digest = (algorithm, data) => try_2({ cause }) }); -var make22 = /* @__PURE__ */ make21({ +var make23 = /* @__PURE__ */ make16({ randomBytes: NodeCrypto.randomBytes, digest }); -var layer3 = /* @__PURE__ */ succeed5(Crypto2, make22); +var layer3 = /* @__PURE__ */ succeed5(Crypto, make23); // node_modules/@effect/platform-node/dist/NodeCrypto.js var layer4 = layer3; // node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js -import * as Crypto3 from "node:crypto"; +import * as Crypto2 from "node:crypto"; import * as NFS from "node:fs"; import * as OS from "node:os"; -import * as Path3 from "node:path"; +import * as Path2 from "node:path"; var handleBadArgument = (method) => (err) => badArgument({ module: "FileSystem", method, @@ -10690,8 +10914,8 @@ var makeTempDirectoryFactory = (method) => { const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException("FileSystem", method), handleBadArgument(method)); return (options) => suspend2(() => { const prefix = options?.prefix ?? ""; - const directory = typeof options?.directory === "string" ? Path3.join(options.directory, ".") : OS.tmpdir(); - return nodeMkdtemp(prefix ? Path3.join(directory, prefix) : directory + "/"); + const directory = typeof options?.directory === "string" ? Path2.join(options.directory, ".") : OS.tmpdir(); + return nodeMkdtemp(prefix ? Path2.join(directory, prefix) : directory + "/"); }); }; var makeTempDirectory = /* @__PURE__ */ makeTempDirectoryFactory("makeTempDirectory"); @@ -10713,7 +10937,7 @@ var makeTempDirectoryScoped = /* @__PURE__ */ (() => { var openFactory = (method) => { const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method)); const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method)); - return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map6((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); + return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map5((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); }; var open2 = /* @__PURE__ */ openFactory("open"); var makeFile = /* @__PURE__ */ (() => { @@ -10762,7 +10986,7 @@ var makeFile = /* @__PURE__ */ (() => { read(buffer) { return suspend2(() => { const position = this.position; - return map6(nodeRead(this.fd, { + return map5(nodeRead(this.fd, { buffer, position }), (bytesRead) => { @@ -10779,7 +11003,7 @@ var makeFile = /* @__PURE__ */ (() => { } const buffer = Buffer.allocUnsafeSlow(size); const position = this.position; - return map6(nodeReadAlloc(this.fd, { + return map5(nodeReadAlloc(this.fd, { buffer, position }), (bytesRead) => { @@ -10800,7 +11024,7 @@ var makeFile = /* @__PURE__ */ (() => { }); } truncate(length) { - return map6(nodeTruncate(this.fd, length || undefined), () => { + return map5(nodeTruncate(this.fd, length || undefined), () => { if (!this.append) { const len = BigInt(length ?? 0); if (this.position > len) { @@ -10812,7 +11036,7 @@ var makeFile = /* @__PURE__ */ (() => { write(buffer) { return suspend2(() => { const position = this.position; - return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map6(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { + return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map5(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { if (!this.append) { this.position = position + BigInt(bytesWritten); } @@ -10850,8 +11074,8 @@ var makeTempFileFactory = (method) => { const makeDirectory = makeTempDirectoryFactory(method); return fnUntraced2(function* (options) { const directory = yield* makeDirectory(options); - const random = Crypto3.randomBytes(6).toString("hex"); - const name = Path3.join(directory, options?.suffix ? `${random}${options.suffix}` : random); + const random = Crypto2.randomBytes(6).toString("hex"); + const name = Path2.join(directory, options?.suffix ? `${random}${options.suffix}` : random); yield* writeFile2(name, new Uint8Array(0)); return name; }); @@ -10860,7 +11084,7 @@ var makeTempFile = /* @__PURE__ */ makeTempFileFactory("makeTempFile"); var makeTempFileScoped = /* @__PURE__ */ (() => { const makeFile = /* @__PURE__ */ makeTempFileFactory("makeTempFileScoped"); const removeDirectory = /* @__PURE__ */ removeFactory("makeTempFileScoped"); - return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path3.dirname(file), { + return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path2.dirname(file), { recursive: true }))); })(); @@ -10933,7 +11157,7 @@ var utimes2 = /* @__PURE__ */ (() => { return (path, atime, mtime) => nodeUtimes(path, atime, mtime); })(); var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sync3(() => { - const directory = info.type === "Directory" ? path : Path3.dirname(path); + const directory = info.type === "Directory" ? path : Path2.dirname(path); const watcher = NFS.watch(path, { recursive: options?.recursive ?? false }, (event, path) => { @@ -10941,7 +11165,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy return; switch (event) { case "rename": { - runFork2(matchEffect3(stat2(Path3.resolve(directory, path)), { + runFork2(matchEffect3(stat2(Path2.resolve(directory, path)), { onSuccess: (_) => offer(queue, { _tag: "Create", path @@ -10963,7 +11187,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy } }); watcher.on("error", (error) => { - failCauseUnsafe(queue, fail5(systemError({ + failCauseUnsafe(queue, fail4(systemError({ module: "FileSystem", _tag: "Unknown", method: "watch", @@ -10976,7 +11200,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy }); return watcher; }), (watcher) => sync3(() => watcher.close()))); -var watch2 = (backend, path, options) => stat2(path).pipe(map6((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); +var watch2 = (backend, path, options) => stat2(path).pipe(map5((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); var writeFile2 = (path, data, options) => callback2((resume, signal) => { try { NFS.writeFile(path, data, { @@ -10994,7 +11218,7 @@ var writeFile2 = (path, data, options) => callback2((resume, signal) => { resume(fail6(handleBadArgument("writeFile")(err))); } }); -var makeFileSystem = /* @__PURE__ */ map6(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make12({ +var makeFileSystem = /* @__PURE__ */ map5(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make15({ access: access2, chmod: chmod2, chown: chown2, @@ -11053,18 +11277,18 @@ var fileUrlOps = (windows) => ({ }) }) }); -var layerPosix = /* @__PURE__ */ succeed5(Path2)({ - [TypeId24]: TypeId24, +var layerPosix = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.posix, .../* @__PURE__ */ fileUrlOps(false) }); -var layerWin32 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId24]: TypeId24, +var layerWin32 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.win32, .../* @__PURE__ */ fileUrlOps(true) }); -var layer7 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId24]: TypeId24, +var layer7 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath, .../* @__PURE__ */ fileUrlOps(undefined) }); @@ -11072,18 +11296,8 @@ var layer7 = /* @__PURE__ */ succeed5(Path2)({ // node_modules/@effect/platform-node/dist/NodePath.js var layer8 = layer7; -// node_modules/effect/dist/Stdio.js -var TypeId26 = "~effect/Stdio"; -var Stdio2 = /* @__PURE__ */ Service(TypeId26); -var make23 = (options) => ({ - [TypeId26]: TypeId26, - stdinIsTerminal: succeed6(false), - stdoutIsTerminal: succeed6(false), - ...options -}); - // node_modules/@effect/platform-node-shared/dist/NodeStdio.js -var layer9 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make23({ +var layer9 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make18({ args: /* @__PURE__ */ sync3(() => process.argv.slice(2)), stdinIsTerminal: /* @__PURE__ */ sync3(() => process.stdin.isTTY === true), stdoutIsTerminal: /* @__PURE__ */ sync3(() => process.stdout.isTTY === true), @@ -11122,24 +11336,9 @@ var layer9 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make23({ // node_modules/@effect/platform-node/dist/NodeStdio.js var layer10 = layer9; -// node_modules/effect/dist/Terminal.js -var TypeId27 = "~effect/Terminal"; -var QuitErrorTypeId = "~effect/Terminal/QuitError"; - -class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ - _tag: /* @__PURE__ */ tag3("QuitError") -})) { - [QuitErrorTypeId] = QuitErrorTypeId; -} -var Terminal2 = /* @__PURE__ */ Service("effect/Terminal"); -var make24 = (impl) => Terminal2.of({ - ...impl, - [TypeId27]: TypeId27 -}); - // node_modules/@effect/platform-node-shared/dist/NodeTerminal.js import * as readline from "node:readline"; -var make25 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { +var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { const stdin = process.stdin; const stdout = process.stdout; const lines = yield* make9(); @@ -11153,7 +11352,7 @@ var make25 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu }; stdin.once("end", onStdinEnd); yield* addFinalizer3(() => sync3(() => stdin.off("end", onStdinEnd))); - const rlRef = yield* make11({ + const rlRef = yield* make14({ acquire: acquireRelease2(sync3(() => { const rl = readline.createInterface({ input: stdin, @@ -11244,7 +11443,7 @@ var make25 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu cause: err })))); })); - return make24({ + return make19({ columns, rows, readInput, @@ -11252,7 +11451,7 @@ var make25 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu display }); }); -var layer11 = /* @__PURE__ */ effect(Terminal2, /* @__PURE__ */ make25(defaultShouldQuit)); +var layer11 = /* @__PURE__ */ effect(Terminal, /* @__PURE__ */ make24(defaultShouldQuit)); function defaultShouldQuit(input) { return input.key.ctrl && (input.key.name === "c" || input.key.name === "d"); } @@ -11307,7 +11506,7 @@ var layer14 = sync2(Service2, () => { class TestService extends Service()("@timmo001/workflows/Annotations/Test") { } var testLayer = effectContext(gen2(function* () { - const recorded = yield* make13([]); + const recorded = yield* make17([]); const write = (line) => update(recorded, (lines) => [...lines, line]); const service = TestService.of({ error: fn2("Annotations.Test.error")(function* (message, properties) { @@ -11329,7 +11528,7 @@ var testLayer = effectContext(gen2(function* () { return yield* get4(recorded); }) }); - return empty().pipe(add(Service2, service), add(TestService, service)); + return empty2().pipe(add(Service2, service), add(TestService, service)); })); class ActionFailure extends TaggedError3()("ActionFailure", { @@ -11353,7 +11552,7 @@ class Service3 extends Service()("@timmo001/workflows/CommandExecutor") { } var layer15 = effect(Service3, gen2(function* () { const spawner = yield* ChildProcessSpawner; - const make = (command, args, options) => make19(command, args, { + const make = (command, args, options) => make21(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true @@ -11392,7 +11591,7 @@ var layer15 = effect(Service3, gen2(function* () { const stream = fn2("CommandExecutor.stream")(function* (command, args, options) { const label = options?.label ?? `${command} ${args.join(" ")}`.trim(); return yield* scoped2(gen2(function* () { - const handle = yield* spawner.spawn(make19(command, args, { + const handle = yield* spawner.spawn(make21(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true, @@ -11446,7 +11645,7 @@ var runAction = (program, layer) => { }; // src/action/GitHubCommand.ts -var make26 = fn2("GitHubCommand.make")(function* (label) { +var make25 = fn2("GitHubCommand.make")(function* (label) { const gh = yield* Gh; let stderrTail = ""; const writeStderr = (text) => sync3(() => { @@ -11455,7 +11654,7 @@ var make26 = fn2("GitHubCommand.make")(function* (label) { }); const mapError = mapError2((error) => new ActionFailure({ title: "Command failed", - message: value2(error).pipe(tag2("GhCommandError", (error) => stderrTail.trim() || `Command failed with exit code ${error.exitCode}: ${label}`), tag2("GhTimeoutError", (error) => `Command timed out after ${error.timeoutMs}ms: ${label}`), tag2("GhPlatformError", "GhDecodeError", (error) => String(error.cause)), exhaustive2) + message: value2(error).pipe(tag3("GhCommandError", (error) => stderrTail.trim() || `Command failed with exit code ${error.exitCode}: ${label}`), tag3("GhTimeoutError", (error) => `Command timed out after ${error.timeoutMs}ms: ${label}`), tag3("GhPlatformError", "GhDecodeError", (error) => String(error.cause)), exhaustive2) })); const stream = fn2("GitHubCommand.stream")(function* (args, options = {}) { yield* gh.stream(args, options).pipe(runForEach2((chunk) => isTagged(chunk, "Stderr") ? writeStderr(chunk.text) : sync3(() => { @@ -11689,7 +11888,7 @@ var dispatch = fn2("BuildArchPackage.dispatch")(function* (inputs) { const artifactName = yield* requireInput(inputs.artifactName, "artifact-name"); const sourceRunId = yield* requireInput(inputs.sourceRunId, "source-run-id"); const payload = JSON.stringify(dispatchPayload(artifactName, inputs.sourceRepository, sourceRunId, inputs.sourceSha)); - const github = yield* make26('bash -c printf %s "$DISPATCH_PAYLOAD" | gh api --method POST repos/timmo001/arch-repo/dispatches --input -'); + const github = yield* make25('bash -c printf %s "$DISPATCH_PAYLOAD" | gh api --method POST repos/timmo001/arch-repo/dispatches --input -'); yield* github.stream([ "api", "--method", diff --git a/.github/actions/build-python-pypi-release/dist/index.js b/.github/actions/build-python-pypi-release/dist/index.js index 1aa7347e..dc707e6e 100644 --- a/.github/actions/build-python-pypi-release/dist/index.js +++ b/.github/actions/build-python-pypi-release/dist/index.js @@ -487,6 +487,33 @@ function makeCompareSet(equivalence) { var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth); var isEqual = (u) => hasProperty(u, symbol2); +// node_modules/effect/dist/internal/array.js +var isArrayNonEmpty = (self) => self.length > 0; + +// node_modules/effect/dist/internal/count.js +var normalize = (n) => n > 0 ? Math.floor(n) : 0; + +// node_modules/effect/dist/internal/record.js +function assignProperty(self, key, value) { + if (key === "__proto__") { + Object.defineProperty(self, key, { + value, + writable: true, + enumerable: true, + configurable: true + }); + } else { + self[key] = value; + } +} +function assignProperties(self, source) { + for (const key of Reflect.ownKeys(source)) { + if (Object.prototype.propertyIsEnumerable.call(source, key)) { + assignProperty(self, key, source[key]); + } + } +} + // node_modules/effect/dist/Redactable.js var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Redactable"); var isRedactable = (u) => hasProperty(u, symbolRedactable); @@ -729,27 +756,6 @@ var pickInternalCall = () => { }; var internalCall = /* @__PURE__ */ pickInternalCall(); -// node_modules/effect/dist/internal/record.js -function assignProperty(self, key, value) { - if (key === "__proto__") { - Object.defineProperty(self, key, { - value, - writable: true, - enumerable: true, - configurable: true - }); - } else { - self[key] = value; - } -} -function assignProperties(self, source) { - for (const key of Reflect.ownKeys(source)) { - if (Object.prototype.propertyIsEnumerable.call(source, key)) { - assignProperty(self, key, source[key]); - } - } -} - // node_modules/effect/dist/internal/core.js var EffectTypeId = `~effect/Effect`; var ExitTypeId = `~effect/Exit`; @@ -1118,12 +1124,6 @@ var done = (value) => { return exitFail(Done(value)); }; -// node_modules/effect/dist/Effectable.js -var Prototype2 = (options) => makePrimitiveProto({ - op: options.label, - [evaluate]: options.evaluate -}); - // node_modules/effect/dist/internal/option.js var TypeId = "~effect/Option"; var CommonProto = { @@ -1285,9 +1285,40 @@ var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone var fromNullishOr = (a) => a == null ? none2() : some2(a); var fromUndefinedOr = (a) => a === undefined ? none2() : some2(a); var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined); -var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value))); var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value)); -var filter = /* @__PURE__ */ dual(2, (self, predicate) => isNone2(self) ? none2() : predicate(self.value) ? some2(self.value) : none2()); + +// node_modules/effect/dist/Result.js +var succeed2 = succeed; +var fail2 = fail; +var isFailure2 = isFailure; +var match2 = /* @__PURE__ */ dual(2, (self, { + onFailure, + onSuccess +}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); + +// node_modules/effect/dist/Array.js +var Array2 = globalThis.Array; +var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); +var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); +var isArray = Array2.isArray; +var isArrayNonEmpty2 = isArrayNonEmpty; +var isReadonlyArrayNonEmpty = isArrayNonEmpty; +var empty = () => []; +var of = (a) => [a]; +var map = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); +// node_modules/effect/dist/BigInt.js +var BigInt2 = globalThis.BigInt; +var toNumber = (b) => { + if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { + return none2(); + } + return some2(Number(b)); +}; +// node_modules/effect/dist/Effectable.js +var Prototype2 = (options) => makePrimitiveProto({ + op: options.label, + [evaluate]: options.evaluate +}); // node_modules/effect/dist/Context.js var ServiceTypeId = "~effect/Context/Service"; @@ -1428,7 +1459,7 @@ var Proto = { var hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot; var isContext = (u) => hasProperty(u, TypeId3); var isReference = (u) => !!u[ReferenceTypeId]; -var empty = () => emptyContext2; +var empty2 = () => emptyContext2; var emptyContext2 = /* @__PURE__ */ makeUnsafe(/* @__PURE__ */ new Map); var make2 = (key, service) => makeUnsafe(new Map([[key.key, service]])); var add = /* @__PURE__ */ dual(3, (self, key, service) => addUnsafe(self, key.key, service)); @@ -1502,6 +1533,7 @@ var mergeAll = (...ctxs) => { return makeUnsafe(map); }; var Reference = Service; + // node_modules/effect/dist/Duration.js var TypeId4 = "~effect/Duration"; var bigint0 = /* @__PURE__ */ BigInt(0); @@ -1725,7 +1757,7 @@ var minutes = (minutes) => make3(minutes * 60000); var hours = (hours) => make3(hours * 3600000); var days = (days) => make3(days * 86400000); var weeks = (weeks) => make3(weeks * 604800000); -var toMillis = (self) => match2(fromInputUnsafe(self), { +var toMillis = (self) => match3(fromInputUnsafe(self), { onMillis: identity, onNanos: (nanos) => Number(nanos) / 1e6, onInfinity: () => Infinity, @@ -1743,7 +1775,7 @@ var toNanosUnsafe = (input) => { return roundMillisToNanos(self.value.millis); } }; -var match2 = /* @__PURE__ */ dual(2, (self, options) => { +var match3 = /* @__PURE__ */ dual(2, (self, options) => { switch (self.value._tag) { case "Millis": return options.onMillis(self.value.millis); @@ -1771,32 +1803,6 @@ var Equivalence = (self, that) => matchPair(self, that, { }); var equals2 = /* @__PURE__ */ dual(2, (self, that) => Equivalence(self, that)); -// node_modules/effect/dist/internal/array.js -var isArrayNonEmpty = (self) => self.length > 0; - -// node_modules/effect/dist/internal/count.js -var normalize = (n) => n > 0 ? Math.floor(n) : 0; - -// node_modules/effect/dist/Result.js -var succeed2 = succeed; -var fail2 = fail; -var isFailure2 = isFailure; -var match3 = /* @__PURE__ */ dual(2, (self, { - onFailure, - onSuccess -}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); - -// node_modules/effect/dist/Array.js -var Array2 = globalThis.Array; -var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); -var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); -var isArray = Array2.isArray; -var isArrayNonEmpty2 = isArrayNonEmpty; -var isReadonlyArrayNonEmpty = isArrayNonEmpty; -var empty2 = () => []; -var of = (a) => [a]; -var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); - // node_modules/effect/dist/Scheduler.js var Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", { fiberCached: true, @@ -2543,7 +2549,7 @@ class FiberImpl { } this._stack.length = 0; this._children = undefined; - this.context = empty(); + this.context = empty2(); } runLoop(effect) { const prevFiber = globalThis[currentFiberTypeId]; @@ -2715,7 +2721,7 @@ var fiberInterruptAs = /* @__PURE__ */ dual((args) => hasProperty(args[0], Fiber })); var fiberInterruptAll = (fibers) => withFiber((parent) => { const annotations = fiberStackAnnotations(parent); - let fiberArr = empty2(); + let fiberArr = empty(); for (const fiber of fibers) { fiber.interruptUnsafe(parent.id, annotations); fiberArr.push(fiber); @@ -2739,7 +2745,7 @@ var suspend = /* @__PURE__ */ makePrimitive({ return this[args](); } }); -var fromResult = /* @__PURE__ */ match3({ +var fromResult = /* @__PURE__ */ match2({ onFailure: fail3, onSuccess: succeed3 }); @@ -3032,7 +3038,7 @@ var tapCont = function(value) { var tapEffectCont = function(value) { return new ContImpl(this.payload, returnPayload, exitSucceed(value)); }; -var asSome = (self) => map4(self, some2); +var asSome = (self) => map3(self, some2); var andThen = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? returnPayload : andThenCont, f)); var tap = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? tapEffectCont : tapCont, f)); var asVoid = (self) => new ContImpl(self, returnPayload, exitVoid); @@ -3074,8 +3080,8 @@ var flatMapEager = /* @__PURE__ */ dual(2, (self, f) => { } return flatMap2(self, f); }); -var map4 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); -var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map4(self, f)); +var map3 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); +var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map3(self, f)); var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError(self, f)); var exitInterrupt = (fiberId) => exitFailCause(causeInterrupt(fiberId)); var exitIsSuccess = (self) => self._tag === "Success"; @@ -3450,7 +3456,7 @@ var all = (arg, options) => { } return suspend(() => { const out = {}; - return as(forEach(Object.entries(arg), ([key, effect]) => map4(options?.mode === "result" ? result(effect) : effect, (value) => { + return as(forEach(Object.entries(arg), ([key, effect]) => map3(options?.mode === "result" ? result(effect) : effect, (value) => { assignProperty(out, key, value); }), { discard: true, @@ -3726,7 +3732,7 @@ var fiberRunIn = /* @__PURE__ */ dual(2, (self, scope) => { self.addObserver(() => scopeRemoveFinalizerUnsafe(scope, key)); return self; }); -var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty()); +var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty2()); var runSyncExitWith = (context) => { const runFork = runForkWith(context); return (effect) => { @@ -3740,7 +3746,7 @@ var runSyncExitWith = (context) => { return fiber._exit ?? exitDie(new AsyncFiberError(fiber)); }; }; -var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty()); +var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty2()); var succeedTrue = /* @__PURE__ */ succeed3(true); var succeedFalse = /* @__PURE__ */ succeed3(false); @@ -3861,7 +3867,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = noopSpan({ name, parent, - annotations: add(options?.annotations ?? empty(), DisablePropagation, true) + annotations: add(options?.annotations ?? empty2(), DisablePropagation, true) }); } else { const tracer = fiber.getRef(Tracer); @@ -3874,7 +3880,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = tracer.span({ name, parent, - annotations: options?.annotations ?? empty(), + annotations: options?.annotations ?? empty2(), links, startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : bigint02, kind: options?.kind ?? "internal", @@ -4160,10 +4166,23 @@ var tracerLogger = /* @__PURE__ */ loggerMake(({ span.event(toStringUnknown(Array.isArray(message) && message.length === 1 ? message[0] : message), clock.currentTimeNanosUnsafe(), attributes); }); +// node_modules/effect/dist/Cause.js +var isFailReason2 = isFailReason; +var fromReasons = causeFromReasons; +var fail4 = causeFail; +var die2 = causeDie; +var hasInterruptsOnly2 = hasInterruptsOnly; +var map4 = causeMap; +var squash = causeSquash; +var isDone2 = isDone; +var Done2 = Done; +var done2 = done; +var UnknownError2 = UnknownError; + // node_modules/effect/dist/Exit.js var succeed4 = exitSucceed; var failCause2 = exitFailCause; -var fail4 = exitFail; +var fail5 = exitFail; var void_2 = exitVoid; var isSuccess3 = exitIsSuccess; var isFailure3 = exitIsFailure; @@ -4200,8 +4219,8 @@ var _await = (self) => callback((resume) => { }); }); var completeWith = /* @__PURE__ */ dual(2, (self, effect) => sync(() => doneUnsafe(self, effect))); -var done2 = completeWith; -var isDone2 = (self) => sync(() => isDoneUnsafe(self)); +var done3 = completeWith; +var isDone3 = (self) => sync(() => isDoneUnsafe(self)); var isDoneUnsafe = (self) => self.effect !== undefined; var doneUnsafe = (self, effect) => { if (self.effect) @@ -4274,7 +4293,7 @@ var memoMapBuild = (memoMap, layer, scope, build) => { memoMap.map.set(layer, entry); return scopeAddFinalizerExit(scope, entry.finalizer).pipe(flatMap2(() => build(memoMap, layerScope)), onExit((exit) => { entry.effect = exit; - return done2(deferred, exit); + return done3(deferred, exit); })); }; @@ -4312,7 +4331,7 @@ class CurrentMemoMap extends (/* @__PURE__ */ Service()("effect/Layer/CurrentMem return current ? forkMemoMapUnsafe(current) : makeMemoMapUnsafe(); } } -var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map4(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); +var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map3(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); var buildWithScope = /* @__PURE__ */ dual(2, (self, scope) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope))); var succeed5 = function() { if (arguments.length === 1) { @@ -4334,31 +4353,19 @@ var effect = function() { } return effectImpl(arguments[0], arguments[1]); }; -var effectImpl = (service, effect) => effectContext(map4(effect, (value) => make2(service, value))); +var effectImpl = (service, effect) => effectContext(map3(effect, (value) => make2(service, value))); var effectContext = (effect) => fromBuildMemo((_, scope) => provide(effect, scope)); var mergeAllEffect = (layers, memoMap, scope) => { const parentScope = forkUnsafe2(scope, "parallel"); return forEach(layers, (layer) => layer.build(memoMap, forkUnsafe2(parentScope, "sequential")), { concurrency: layers.length - }).pipe(map4((context) => mergeAll(...context))); + }).pipe(map3((context) => mergeAll(...context))); }; var mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope)); -var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map4((merged) => f(merged, context))))); +var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map3((merged) => f(merged, context))))); var provide2 = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, identity)); var provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self))); -// node_modules/effect/dist/Cause.js -var isFailReason2 = isFailReason; -var fromReasons = causeFromReasons; -var fail5 = causeFail; -var hasInterruptsOnly2 = hasInterruptsOnly; -var map5 = causeMap; -var squash = causeSquash; -var isDone3 = isDone; -var Done2 = Done; -var done3 = done; -var UnknownError2 = UnknownError; - // node_modules/effect/dist/internal/random.js var nextBetween = (min, max, draw) => { const value = draw * (max - min) + min; @@ -4378,7 +4385,7 @@ var nextBetween = (min, max, draw) => { // node_modules/effect/dist/Pull.js var catchDone = /* @__PURE__ */ dual(2, (effect, f) => catchCauseFilter(effect, filterDoneLeftover, (l) => f(l))); var isDoneCause = (cause) => cause.reasons.some(isDoneFailure); -var isDoneFailure = (failure) => failure._tag === "Fail" && isDone3(failure.error); +var isDoneFailure = (failure) => failure._tag === "Fail" && isDone2(failure.error); var filterDone = (cause) => { let done; let hasFailure = false; @@ -4420,7 +4427,6 @@ var forEach2 = forEach; var whileLoop2 = whileLoop; var tryPromise2 = tryPromise; var succeed6 = succeed3; -var succeedNone2 = succeedNone; var suspend2 = suspend; var sync3 = sync; var void_3 = void_; @@ -4429,7 +4435,7 @@ var gen2 = gen; var fail6 = fail3; var failCause3 = failCause; var failCauseSync2 = failCauseSync; -var die2 = die; +var die3 = die; var try_2 = try_; var withFiber2 = withFiber; var fromResult2 = fromResult; @@ -4437,7 +4443,7 @@ var flatMap3 = flatMap2; var andThen2 = andThen; var tap2 = tap; var exit2 = exit; -var map6 = map4; +var map5 = map3; var as2 = as; var catch_2 = catch_; var catchTag2 = catchTag; @@ -4483,272 +4489,97 @@ var effectify = (fn, onError, onSyncError) => (...args) => callback2((resume) => } }); } catch (err) { - resume(onSyncError ? fail6(onSyncError(err, args)) : die2(err)); + resume(onSyncError ? fail6(onSyncError(err, args)) : die3(err)); } }); var mapEager2 = mapEager; var mapErrorEager2 = mapErrorEager; var flatMapEager2 = flatMapEager; var fnUntracedEager2 = fnUntracedEager; -// node_modules/effect/dist/MutableRef.js -var TypeId7 = "~effect/MutableRef"; -var MutableRefProto = { - [TypeId7]: TypeId7, - ...PipeInspectableProto, - toJSON() { - return { - _id: "MutableRef", - current: toJson(this.current) - }; + +// node_modules/effect/dist/internal/schema/annotations.js +function resolve(ast) { + return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; +} +var STRUCTURAL_ANNOTATION_KEY = "~structural"; +var SENTINELS_ANNOTATION_KEY = "~sentinels"; +var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; +var getExpected = /* @__PURE__ */ memoize((ast) => { + const identifier = resolve(ast)?.identifier; + if (typeof identifier === "string") + return identifier; + return ast.getExpected(getExpected); +}); + +// node_modules/effect/dist/internal/schema/parser.js +var missing = /* @__PURE__ */ Symbol(); +var succeed7 = succeed4; +var missingExit = /* @__PURE__ */ succeed7(missing); +var sameExit = /* @__PURE__ */ succeed7(missing); +var toOption = (value) => value === missing ? none2() : some2(value); +var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed7(option.value); + +// node_modules/effect/dist/SchemaIssue.js +var TypeId7 = "~effect/SchemaIssue/Issue"; +function isIssue(u) { + return hasProperty(u, TypeId7) && u[TypeId7] === TypeId7; +} +function hasInput(issue) { + return Object.hasOwn(issue, "input"); +} + +class IssueNodeImpl { + [TypeId7] = TypeId7; + constructor(input, options) { + if (options?.reportInput === true && input !== missing) { + this.input = input; + } + } +} +var Filter = class extends IssueNodeImpl { + _tag = "Filter"; + filter; + issue; + constructor(filter, issue, input, options) { + super(input, options); + this.filter = filter; + this.issue = issue; } }; -var make5 = (value) => { - const ref = Object.create(MutableRefProto); - ref.current = value; - return ref; +var Encoding = class extends IssueNodeImpl { + _tag = "Encoding"; + ast; + issue; + constructor(ast, issue, input, options) { + super(input, options); + this.ast = ast; + this.issue = issue; + } }; - -// node_modules/effect/dist/Ref.js -var TypeId8 = "~effect/Ref"; -var RefProto = { - [TypeId8]: { - _A: identity - }, - ...PipeInspectableProto, - toJSON() { - return { - _id: "Ref", - ref: this.ref - }; +var Pointer = class extends IssueNodeImpl { + _tag = "Pointer"; + path; + issue; + constructor(path, issue) { + super(); + this.path = path; + this.issue = issue; } }; -var makeUnsafe4 = (value) => { - const self = Object.create(RefProto); - self.ref = make5(value); - return self; +var MissingKey = class extends IssueNodeImpl { + _tag = "MissingKey"; + annotations; + constructor(annotations) { + super(); + this.annotations = annotations; + } }; -var make6 = (value) => sync3(() => makeUnsafe4(value)); -var get2 = (self) => sync3(() => self.ref.current); -var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { - self.ref.current = f(self.ref.current); -})); -// node_modules/effect/dist/BigInt.js -var BigInt2 = globalThis.BigInt; -var toNumber = (b) => { - if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { - return none2(); - } - return some2(Number(b)); -}; - -// node_modules/effect/dist/ByteSize.js -var bigint03 = /* @__PURE__ */ BigInt(0); -var bigint12 = /* @__PURE__ */ BigInt(1); -var decimalBase = /* @__PURE__ */ BigInt(1000); -var binaryBase = /* @__PURE__ */ BigInt(1024); -var decimalUnits = [{ - symbol: "B", - factor: bigint12, - names: ["B", "byte", "bytes"] -}, { - symbol: "kB", - factor: decimalBase, - names: ["kB", "kilobyte", "kilobytes"] -}, { - symbol: "MB", - factor: decimalBase ** /* @__PURE__ */ BigInt(2), - names: ["MB", "megabyte", "megabytes"] -}, { - symbol: "GB", - factor: decimalBase ** /* @__PURE__ */ BigInt(3), - names: ["GB", "gigabyte", "gigabytes"] -}, { - symbol: "TB", - factor: decimalBase ** /* @__PURE__ */ BigInt(4), - names: ["TB", "terabyte", "terabytes"] -}, { - symbol: "PB", - factor: decimalBase ** /* @__PURE__ */ BigInt(5), - names: ["PB", "petabyte", "petabytes"] -}, { - symbol: "EB", - factor: decimalBase ** /* @__PURE__ */ BigInt(6), - names: ["EB", "exabyte", "exabytes"] -}, { - symbol: "ZB", - factor: decimalBase ** /* @__PURE__ */ BigInt(7), - names: ["ZB", "zettabyte", "zettabytes"] -}, { - symbol: "YB", - factor: decimalBase ** /* @__PURE__ */ BigInt(8), - names: ["YB", "yottabyte", "yottabytes"] -}, { - symbol: "RB", - factor: decimalBase ** /* @__PURE__ */ BigInt(9), - names: ["RB", "ronnabyte", "ronnabytes"] -}, { - symbol: "QB", - factor: decimalBase ** /* @__PURE__ */ BigInt(10), - names: ["QB", "quettabyte", "quettabytes"] -}]; -var binaryUnits = [decimalUnits[0], { - symbol: "KiB", - factor: binaryBase, - names: ["KiB", "kibibyte", "kibibytes"] -}, { - symbol: "MiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(2), - names: ["MiB", "mebibyte", "mebibytes"] -}, { - symbol: "GiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(3), - names: ["GiB", "gibibyte", "gibibytes"] -}, { - symbol: "TiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(4), - names: ["TiB", "tebibyte", "tebibytes"] -}, { - symbol: "PiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(5), - names: ["PiB", "pebibyte", "pebibytes"] -}, { - symbol: "EiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(6), - names: ["EiB", "exbibyte", "exbibytes"] -}, { - symbol: "ZiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(7), - names: ["ZiB", "zebibyte", "zebibytes"] -}, { - symbol: "YiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(8), - names: ["YiB", "yobibyte", "yobibytes"] -}]; -var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; -var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); -var make7 = (value) => value; -var invalid2 = (message) => { - throw new Error(`Invalid ByteSize: ${message}`); -}; -var fromNumber = (input) => { - if (!Number.isSafeInteger(input) || input < 0) { - return invalid2(`expected a non-negative safe integer, received ${input}`); - } - return make7(BigInt(input)); -}; -var parse = (input) => { - const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); - if (match === null) - return invalid2(`unsupported syntax ${JSON.stringify(input)}`); - const unit = unitsByName.get(match[3]); - if (unit === undefined) - return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); - const fraction = match[2] ?? ""; - const scale = BigInt(10) ** BigInt(fraction.length); - const numerator = BigInt(match[1] + fraction) * unit.factor; - if (numerator % scale !== bigint03) { - return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); - } - return make7(numerator / scale); -}; -var fromInputUnsafe2 = (input) => { - switch (typeof input) { - case "bigint": - if (input < bigint03) - return invalid2(`expected a non-negative bigint, received ${input}`); - return make7(input); - case "number": - return fromNumber(input); - case "string": - return parse(input); - } - return invalid2(`unsupported input ${input}`); -}; -var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); - -// node_modules/effect/dist/internal/schema/annotations.js -function resolve(ast) { - return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; -} -var STRUCTURAL_ANNOTATION_KEY = "~structural"; -var SENTINELS_ANNOTATION_KEY = "~sentinels"; -var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; -var getExpected = /* @__PURE__ */ memoize((ast) => { - const identifier = resolve(ast)?.identifier; - if (typeof identifier === "string") - return identifier; - return ast.getExpected(getExpected); -}); - -// node_modules/effect/dist/internal/schema/parser.js -var missing = /* @__PURE__ */ Symbol(); -var succeed7 = succeed4; -var missingExit = /* @__PURE__ */ succeed7(missing); -var sameExit = /* @__PURE__ */ succeed7(missing); -var toOption = (value) => value === missing ? none2() : some2(value); -var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed7(option.value); - -// node_modules/effect/dist/SchemaIssue.js -var TypeId9 = "~effect/SchemaIssue/Issue"; -function isIssue(u) { - return hasProperty(u, TypeId9) && u[TypeId9] === TypeId9; -} -function hasInput(issue) { - return Object.hasOwn(issue, "input"); -} - -class IssueNodeImpl { - [TypeId9] = TypeId9; - constructor(input, options) { - if (options?.reportInput === true && input !== missing) { - this.input = input; - } - } -} -var Filter = class extends IssueNodeImpl { - _tag = "Filter"; - filter; - issue; - constructor(filter, issue, input, options) { - super(input, options); - this.filter = filter; - this.issue = issue; - } -}; -var Encoding = class extends IssueNodeImpl { - _tag = "Encoding"; - ast; - issue; - constructor(ast, issue, input, options) { - super(input, options); - this.ast = ast; - this.issue = issue; - } -}; -var Pointer = class extends IssueNodeImpl { - _tag = "Pointer"; - path; - issue; - constructor(path, issue) { - super(); - this.path = path; - this.issue = issue; - } -}; -var MissingKey = class extends IssueNodeImpl { - _tag = "MissingKey"; - annotations; - constructor(annotations) { - super(); - this.annotations = annotations; - } -}; -var UnexpectedKey = class extends IssueNodeImpl { - _tag = "UnexpectedKey"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; +var UnexpectedKey = class extends IssueNodeImpl { + _tag = "UnexpectedKey"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; } }; var Composite = class extends IssueNodeImpl { @@ -4825,7 +4656,7 @@ function normalizeFilterOutput(ast, out, input, options) { if (!isReadonlyArrayNonEmpty(out)) { return; } - return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map2(out, (entry) => makeFilterIssue(entry, input, options)), input, options); + return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map(out, (entry) => makeFilterIssue(entry, input, options)), input, options); } return makeSingle(out, input, options); } @@ -4953,48 +4784,23 @@ function getSchemaIssueOrThrow(cause, message) { } // node_modules/effect/dist/SchemaGetter.js -var Getter = class extends Class { - run; - constructor(run) { - super(); - this.run = run; - } - map(f) { - return new Getter((oe, options) => this.run(oe, options).pipe(mapEager2(map(f)))); - } - compose(other) { - if (isPassthrough(this)) { - return other; - } - if (isPassthrough(other)) { - return this; - } - return new Getter((oe, options) => this.run(oe, options).pipe(flatMapEager2((ot) => other.run(ot, options)))); - } -}; -var passthrough_ = /* @__PURE__ */ new Getter(succeed6); -function isPassthrough(getter) { - return getter.run === passthrough_.run; -} +var makeGetter = (fields) => Object.assign(Object.create(Prototype), fields); +var passthrough_ = /* @__PURE__ */ makeGetter({ + _tag: "Passthrough" +}); function passthrough() { return passthrough_; } -function onSome(f) { - return new Getter((oe, options) => isNone2(oe) ? succeedNone2 : f(oe.value, options)); -} function transform(f) { - return transformOptional(map(f)); + return makeGetter({ + _tag: "Transform", + transform: f + }); } function transformEffect(f) { - return onSome((e, options) => f(e, options).pipe(mapEager2(some2))); -} -function transformOptional(f) { - return new Getter((oe) => succeed6(f(oe))); -} -function withDefault(defaultValue) { - return new Getter((o) => { - const filtered = filter(o, isNotUndefined); - return isSome2(filtered) ? succeed6(filtered) : mapEager2(defaultValue, some2); + return makeGetter({ + _tag: "TransformEffect", + transform: f }); } function String2() { @@ -5012,74 +4818,197 @@ function decodeBase642() { }, input, options))); } -// node_modules/effect/dist/SchemaTransformation.js -var TypeId10 = "~effect/SchemaTransformation/Transformation"; -var Transformation = class { - [TypeId10] = TypeId10; - _tag = "Transformation"; - decode; - encode; - constructor(decode, encode) { - this.decode = decode; - this.encode = encode; - } - flip() { - return new Transformation(this.encode, this.decode); - } - compose(other) { - return new Transformation(this.decode.compose(other.decode), other.encode.compose(this.encode)); - } -}; -function isTransformation(u) { - return hasProperty(u, TypeId10) && u[TypeId10] === TypeId10; -} -var make8 = (options) => { - if (isTransformation(options)) { - return options; - } - return new Transformation(options.decode, options.encode); -}; -function transformEffect2(options) { - return new Transformation(transformEffect(options.decode), transformEffect(options.encode)); -} -function transform2(options) { - return new Transformation(transform(options.decode), transform(options.encode)); -} -var passthrough_2 = /* @__PURE__ */ new Transformation(/* @__PURE__ */ passthrough(), /* @__PURE__ */ passthrough()); -function passthrough2() { - return passthrough_2; -} -var numberFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ String2()); -var urlFromString = /* @__PURE__ */ transformEffect2({ - decode: (s, options) => URL.canParse(s) ? succeed6(new URL(s)) : fail6(new InvalidValue({ - expected: "a valid URL string" - }, s, options)), - encode: (url) => succeed6(url.href) -}); -var uint8ArrayFromBase64String = /* @__PURE__ */ new Transformation(/* @__PURE__ */ decodeBase642(), /* @__PURE__ */ encodeBase642()); - -// node_modules/effect/dist/SchemaAST.js -function makeGuard(tag) { - return (ast) => ast._tag === tag; -} -var isDeclaration = /* @__PURE__ */ makeGuard("Declaration"); -var isNever2 = /* @__PURE__ */ makeGuard("Never"); -var isLiteral = /* @__PURE__ */ makeGuard("Literal"); -var isUniqueSymbol = /* @__PURE__ */ makeGuard("UniqueSymbol"); -var isArrays = /* @__PURE__ */ makeGuard("Arrays"); -var isObjects = /* @__PURE__ */ makeGuard("Objects"); -var isSuspend = /* @__PURE__ */ makeGuard("Suspend"); -var Link = class { - to; - transformation; - constructor(to, transformation) { - this.to = to; - this.transformation = transformation; - } -}; -var defaultParseOptions = {}; -var Context = class { - isOptional; +// node_modules/effect/dist/ByteSize.js +var bigint03 = /* @__PURE__ */ BigInt(0); +var bigint12 = /* @__PURE__ */ BigInt(1); +var decimalBase = /* @__PURE__ */ BigInt(1000); +var binaryBase = /* @__PURE__ */ BigInt(1024); +var decimalUnits = [{ + symbol: "B", + factor: bigint12, + names: ["B", "byte", "bytes"] +}, { + symbol: "kB", + factor: decimalBase, + names: ["kB", "kilobyte", "kilobytes"] +}, { + symbol: "MB", + factor: decimalBase ** /* @__PURE__ */ BigInt(2), + names: ["MB", "megabyte", "megabytes"] +}, { + symbol: "GB", + factor: decimalBase ** /* @__PURE__ */ BigInt(3), + names: ["GB", "gigabyte", "gigabytes"] +}, { + symbol: "TB", + factor: decimalBase ** /* @__PURE__ */ BigInt(4), + names: ["TB", "terabyte", "terabytes"] +}, { + symbol: "PB", + factor: decimalBase ** /* @__PURE__ */ BigInt(5), + names: ["PB", "petabyte", "petabytes"] +}, { + symbol: "EB", + factor: decimalBase ** /* @__PURE__ */ BigInt(6), + names: ["EB", "exabyte", "exabytes"] +}, { + symbol: "ZB", + factor: decimalBase ** /* @__PURE__ */ BigInt(7), + names: ["ZB", "zettabyte", "zettabytes"] +}, { + symbol: "YB", + factor: decimalBase ** /* @__PURE__ */ BigInt(8), + names: ["YB", "yottabyte", "yottabytes"] +}, { + symbol: "RB", + factor: decimalBase ** /* @__PURE__ */ BigInt(9), + names: ["RB", "ronnabyte", "ronnabytes"] +}, { + symbol: "QB", + factor: decimalBase ** /* @__PURE__ */ BigInt(10), + names: ["QB", "quettabyte", "quettabytes"] +}]; +var binaryUnits = [decimalUnits[0], { + symbol: "KiB", + factor: binaryBase, + names: ["KiB", "kibibyte", "kibibytes"] +}, { + symbol: "MiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(2), + names: ["MiB", "mebibyte", "mebibytes"] +}, { + symbol: "GiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(3), + names: ["GiB", "gibibyte", "gibibytes"] +}, { + symbol: "TiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(4), + names: ["TiB", "tebibyte", "tebibytes"] +}, { + symbol: "PiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(5), + names: ["PiB", "pebibyte", "pebibytes"] +}, { + symbol: "EiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(6), + names: ["EiB", "exbibyte", "exbibytes"] +}, { + symbol: "ZiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(7), + names: ["ZiB", "zebibyte", "zebibytes"] +}, { + symbol: "YiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(8), + names: ["YiB", "yobibyte", "yobibytes"] +}]; +var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; +var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); +var make5 = (value) => value; +var invalid2 = (message) => { + throw new Error(`Invalid ByteSize: ${message}`); +}; +var fromNumber = (input) => { + if (!Number.isSafeInteger(input) || input < 0) { + return invalid2(`expected a non-negative safe integer, received ${input}`); + } + return make5(BigInt(input)); +}; +var fromStringUnsafe = (input) => { + const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); + if (match === null) + return invalid2(`unsupported syntax ${JSON.stringify(input)}`); + const unit = unitsByName.get(match[3]); + if (unit === undefined) + return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); + const fraction = match[2] ?? ""; + const scale = BigInt(10) ** BigInt(fraction.length); + const numerator = BigInt(match[1] + fraction) * unit.factor; + if (numerator % scale !== bigint03) { + return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); + } + return make5(numerator / scale); +}; +var fromInputUnsafe2 = (input) => { + switch (typeof input) { + case "bigint": + if (input < bigint03) + return invalid2(`expected a non-negative bigint, received ${input}`); + return make5(input); + case "number": + return fromNumber(input); + case "string": + return fromStringUnsafe(input); + } + return invalid2(`unsupported input ${input}`); +}; +var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); + +// node_modules/effect/dist/SchemaTransformation.js +var TypeId8 = "~effect/SchemaTransformation/Transformation"; +var Transformation = class extends Class { + [TypeId8] = TypeId8; + _tag = "Transformation"; + decode; + encode; + constructor(decode, encode) { + super(); + this.decode = decode; + this.encode = encode; + } + flip() { + return new Transformation(this.encode, this.decode); + } +}; +function isTransformation(u) { + return hasProperty(u, TypeId8) && u[TypeId8] === TypeId8; +} +var makeTransformation = (options) => { + if (isTransformation(options)) { + return options; + } + return new Transformation(options.decode, options.encode); +}; +function transformEffect2(options) { + return new Transformation(transformEffect(options.decode), transformEffect(options.encode)); +} +function transform2(options) { + return new Transformation(transform(options.decode), transform(options.encode)); +} +var passthrough_2 = /* @__PURE__ */ new Transformation(/* @__PURE__ */ passthrough(), /* @__PURE__ */ passthrough()); +function passthrough2() { + return passthrough_2; +} +var numberFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ String2()); +var urlFromString = /* @__PURE__ */ transformEffect2({ + decode: (s, options) => URL.canParse(s) ? succeed6(new URL(s)) : fail6(new InvalidValue({ + expected: "a valid URL string" + }, s, options)), + encode: (url) => succeed6(url.href) +}); +var uint8ArrayFromBase64String = /* @__PURE__ */ new Transformation(/* @__PURE__ */ decodeBase642(), /* @__PURE__ */ encodeBase642()); + +// node_modules/effect/dist/SchemaAST.js +function makeGuard(tag) { + return (ast) => ast._tag === tag; +} +var isDeclaration = /* @__PURE__ */ makeGuard("Declaration"); +var isNever2 = /* @__PURE__ */ makeGuard("Never"); +var isLiteral = /* @__PURE__ */ makeGuard("Literal"); +var isUniqueSymbol = /* @__PURE__ */ makeGuard("UniqueSymbol"); +var isArrays = /* @__PURE__ */ makeGuard("Arrays"); +var isObjects = /* @__PURE__ */ makeGuard("Objects"); +var isSuspend = /* @__PURE__ */ makeGuard("Suspend"); +var Link = class { + to; + transformation; + constructor(to, transformation) { + this.to = to; + this.transformation = transformation; + } +}; +var defaultParseOptions = {}; +var Context = class { + isOptional; isMutable; constructorDefault; annotations; @@ -5090,10 +5019,10 @@ var Context = class { this.annotations = annotations; } }; -var TypeId11 = "~effect/Schema"; +var TypeId9 = "~effect/Schema"; class ASTNodeImpl { - [TypeId11] = TypeId11; + [TypeId9] = TypeId9; annotations; checks; encoding; @@ -5268,7 +5197,7 @@ var Arrays = class extends ASTNodeImpl { } } } - getParser(compile, compileConstructorDefault = compile) { + getParser(compile, compileField = compile) { const ast = this; let elements; let rest; @@ -5292,11 +5221,11 @@ var Arrays = class extends ASTNodeImpl { if (!elements) { elements = ast.elements.map((ast) => ({ ast, - parser: compileConstructorDefault(ast) + parser: compileField(ast) })); rest = ast.rest.map((ast) => ({ ast, - parser: compileConstructorDefault(ast) + parser: compileField(ast) })); } const len = input.length; @@ -5353,33 +5282,34 @@ var Arrays = class extends ASTNodeImpl { return "array"; } }; +function stepArray(s, item, exit, i) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, i, exit); + } + const value = exit === sameExit ? item : exit[args]; + if (value !== missing) { + s.output[i] = value; + } else { + const p = s.getParser(s.tailThreshold, i); + if (isOptional(p.ast)) + return; + const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); + } + } +} var parseArrayOptions = { onItem(s, item, i) { const value = i < s.len ? item : missing; return s.getParser(s.tailThreshold, i).parser(value, s.options); }, - step(s, item, exit, i) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, i, exit); - } - const value = exit === sameExit ? item : exit[args]; - if (value !== missing) { - s.output[i] = value; - } else { - const p = s.getParser(s.tailThreshold, i); - if (isOptional(p.ast)) - return; - const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); - } - } - } + step: stepArray }; var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); @@ -5389,7 +5319,7 @@ var wrapPropertyKeyIssue = (s, ast, key, exit) => { } const issue = getSchemaIssue(exit.cause); if (issue === undefined) { - return failCause2(map5(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); + return failCause2(map4(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); } const pointer = new Pointer([key], issue); if (s.options.errors === "all") { @@ -5398,7 +5328,7 @@ var wrapPropertyKeyIssue = (s, ast, key, exit) => { else s.issues = [pointer]; } else { - return fail4(new Composite(ast, [pointer], s.input, s.options)); + return fail5(new Composite(ast, [pointer], s.input, s.options)); } }; var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; @@ -5498,7 +5428,7 @@ var Objects = class extends ASTNodeImpl { throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); } } - getParser(compile, compileConstructorDefault = compile) { + getParser(compile, compileField = compile) { const ast = this; const expectedKeys = []; for (const ps of ast.propertySignatures) { @@ -5552,14 +5482,14 @@ var Objects = class extends ASTNodeImpl { const compileMembers = () => { if (!properties) { properties = ast.propertySignatures.map((ps) => ({ - parser: compileConstructorDefault(ps.type), + parser: compileField(ps.type), name: ps.name, type: ps.type })); indexes = indexCount ? ast.indexSignatures.map((is) => ({ is, parserKey: compile(parameterFromPropertyKey(is.parameter)), - parserValue: compileConstructorDefault(is.type) + parserValue: compileField(is.type) })) : undefined; } return properties; @@ -5634,7 +5564,7 @@ var Objects = class extends ASTNodeImpl { } } } else if (parseIndexes) { - const keyPairs = empty2(); + const keyPairs = empty(); for (let i = 0;i < indexCount; i++) { const index = indexes[i]; const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); @@ -5705,7 +5635,7 @@ var Objects = class extends ASTNodeImpl { return terminal; } } catch (error) { - return die2(error); + return die3(error); } return succeed7(out); }; @@ -5755,7 +5685,7 @@ function stepProperty(s, p, exit) { s.issues = [issue]; return; } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); + return fail5(new Composite(s.ast, [issue], s.input, s.options)); } } } @@ -6054,13 +5984,13 @@ var Union = class extends ASTNodeImpl { this.options = options; this.encodingChecks = encodingChecks; } - getParser(compile, compileConstructorDefault) { + getParser(compile, compileField) { const ast = this; return (input, options) => { if (input === missing) { return missingExit; } - const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined); + const candidates = getCandidates(input, ast.types, compileField !== undefined); if (candidates.length === 0) { return fail6(new AnyOf(ast, [], input, options)); } @@ -6145,7 +6075,7 @@ function failSingleUnionCandidate(ast, cause, input, options) { const issue = getSchemaIssue(cause); if (!issue) return failCause2(cause); - return fail4(new AnyOf(ast, [issue], input, options)); + return fail5(new AnyOf(ast, [issue], input, options)); } var parseUnion = /* @__PURE__ */ iterateEager()({ onItem(s, ast) { @@ -6165,7 +6095,7 @@ var parseUnion = /* @__PURE__ */ iterateEager()({ } else { if (s.out && s.successes) { s.successes.push(candidate); - return fail4(new OneOf(s.ast, s.successes, s.input, s.options)); + return fail5(new OneOf(s.ast, s.successes, s.input, s.options)); } s.out = exit; if (s.successes) { @@ -6390,9 +6320,7 @@ var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { }); var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); function withConstructorDefault(ast, defaultValue) { - const transformation = new Transformation(withDefault(defaultValue), passthrough()); - const constructorDefault = new Link(unknown, transformation); - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) : new Context(false, false, constructorDefault); + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue); return replaceContext(ast, context); } function decodeTo(from, to, transformation) { @@ -6546,1417 +6474,1691 @@ function getConstructorDescriptor(ast) { return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; } -// node_modules/effect/dist/SchemaParser.js -function makeEffect(schema) { - const ast = schema.ast; - let parser; - return (input, options) => { - return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { - ...options.parseOptions, - disableChecks: true - } : { - disableChecks: true - } : options?.parseOptions); - }; -} -function makeOption(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return some2(exit.value); - } - getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); - return none2(); - }; -} -function make9(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return exit.value; - } - const issue = getSchemaIssueOrThrow(exit.cause, "Constructor adapter can only throw schema issues"); - throw new Error("Schema validation failed", { - cause: issue - }); - }; -} -function decodeUnknownEffect(schema, options) { - const parser = run(schema.ast); - return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); +// node_modules/effect/dist/Brand.js +function nominal() { + return Object.assign((input) => input, { + option: (input) => some2(input), + result: (input) => succeed2(input), + is: (_) => true + }); } -var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { - ...options, - ...overrideOptions -} : options; -var getValue = (value) => { - if (value === missing) { - return fail6(new InvalidValue); - } - return succeed6(value); +// node_modules/effect/dist/Fiber.js +var interrupt3 = fiberInterrupt; +var runIn = fiberRunIn; + +// node_modules/effect/dist/Latch.js +var makeUnsafe4 = makeLatchUnsafe; + +// node_modules/effect/dist/MutableRef.js +var TypeId10 = "~effect/MutableRef"; +var MutableRefProto = { + [TypeId10]: TypeId10, + ...PipeInspectableProto, + toJSON() { + return { + _id: "MutableRef", + current: toJson(this.current) + }; + } }; -function run(ast) { - return runWithCompiler(normalCompiler, ast); -} -function runWithCompiler(compiler, ast) { - let parser; - return (input, options) => { - const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); - if (result === sameExit) { - return succeed6(input); - } - if (!effectIsExit(result)) { - return flatMapEager2(result, getValue); - } - return result[args] === missing ? getValue(missing) : result; - }; -} -var normalCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, normalCompiler)); -var constructorCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault)); -var compileDefaulted = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault, ast.context?.constructorDefault)); -function compileConstructorDefault(ast) { - return ast.context?.constructorDefault ? compileDefaulted(ast) : constructorCompiler(ast); -} -function applyTransformation(result, current, transformation, options) { - let transformed; - if (effectIsExit(result) && result._tag === "Success") { - const optional = toOption(result === sameExit ? current : result[args]); - transformed = transformation._tag === "Transformation" ? transformation.decode.run(optional, options) : transformation.decode(succeed7(optional), options); - } else if (transformation._tag === "Transformation") { - transformed = flatMapEager2(result, (value) => transformation.decode.run(toOption(value), options)); - } else { - transformed = transformation.decode(mapEager2(result, toOption), options); +var make6 = (value) => { + const ref = Object.create(MutableRefProto); + ref.current = value; + return ref; +}; + +// node_modules/effect/dist/MutableList.js +var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); +var make7 = () => ({ + head: undefined, + tail: undefined, + length: 0 +}); +var emptyBucket = () => ({ + array: [], + mutable: true, + offset: 0, + next: undefined +}); +var append2 = (self, message) => { + if (!self.tail) { + self.head = self.tail = emptyBucket(); + } else if (!self.tail.mutable) { + self.tail.next = emptyBucket(); + self.tail = self.tail.next; } - return effectIsExit(transformed) && transformed._tag === "Success" ? fromOptionExit(transformed[args]) : flatMapEager2(transformed, fromOptionExit); -} -function makeConstructorParser(descriptor, compile) { - let sourceParser; - return (input, options) => { - if (input === missing) - return missingExit; - if (descriptor.isConstructed(input)) - return sameExit; - const result = (sourceParser ??= compile(descriptor.link.to))(input, options); - return applyTransformation(result, input, descriptor.link.transformation, options); - }; -} -function makeParser(ast, compile, compileConstructorDefault, constructorDefault) { - const descriptor = compileConstructorDefault ? getConstructorDescriptor(ast) : undefined; - const parser = descriptor ? makeConstructorParser(descriptor, compile) : ast.getParser(compile, compileConstructorDefault); - const checks = ast.checks; - const links = constructorDefault ? ast.encoding ? [...ast.encoding, constructorDefault] : [constructorDefault] : ast.encoding; - const encodingChecks = ast.encodingChecks; - if (!links && !checks && !encodingChecks) { - return parser; + self.tail.array.push(message); + self.length++; +}; +var clear = (self) => { + self.head = self.tail = undefined; + self.length = 0; +}; +var takeN = (self, n) => { + n = normalize(n); + if (n <= 0 || !self.head) + return []; + n = Math.min(n, self.length); + if (n === self.length && self.head?.offset === 0 && !self.head.next) { + const array = self.head.array; + clear(self); + return array; } - let encodingParsers; - const parseLocal = (input, options) => { - let result = parser(input, options); - if (encodingChecks && !options.disableChecks) { - if (effectIsExit(result)) { - if (result._tag === "Success") { - const output = result === sameExit ? input : result[args]; - if (input !== missing && output !== missing) { - const issues = collectIssues(encodingChecks, input, undefined, ast, options); - if (issues) { - result = fail6(new Composite(ast, issues, input, options)); - } - } - } - } else { - result = flatMap3(result, (value) => { - if (input !== missing && value !== missing) { - const issues = collectIssues(encodingChecks, input, undefined, ast, options); - if (issues) { - return fail6(new Composite(ast, issues, input, options)); - } - } - return succeed6(value); - }); - } - } - if (checks && !options.disableChecks) { - if (effectIsExit(result)) { - if (result._tag === "Success") { - const value = result === sameExit ? input : result[args]; - if (value === missing) - return result; - const issues = collectIssues(checks, value, undefined, ast, options); - if (issues) { - result = fail6(new Composite(ast, issues, value, options)); - } - } - } else { - result = flatMap3(result, (value) => { - if (value !== missing) { - const issues = collectIssues(checks, value, undefined, ast, options); - if (issues) { - return fail6(new Composite(ast, issues, value, options)); - } - } - return succeed6(value); - }); + const array = new Array(n); + let index = 0; + let chunk = self.head; + while (chunk) { + while (chunk.offset < chunk.array.length) { + array[index++] = chunk.array[chunk.offset]; + if (chunk.mutable) + chunk.array[chunk.offset] = undefined; + chunk.offset++; + if (index === n) { + self.head = chunk; + self.length -= n; + if (self.length === 0) + clear(self); + return array; } } - return result; - }; - if (!links) { - return parseLocal; + chunk = chunk.next; } - return (input, options) => { - const parsers = encodingParsers ??= links.map((link) => compile(link.to)); - let current = input; - let result = parsers[parsers.length - 1](input, options); - for (let i = links.length - 1;i >= 0; i--) { - result = applyTransformation(result, current, links[i].transformation, options); - if (i !== 0) { - const next = parsers[i - 1]; - if (result._tag === "Success") { - current = result[args]; - result = next(current, options); - } else { - result = flatMapEager2(result, (value) => { - const nextResult = next(value, options); - return nextResult === sameExit ? succeed7(value) : nextResult; - }); - } - } - } - if (result._tag === "Success") { - const value = result[args]; - const local = parseLocal(value, options); - return local === sameExit ? result : local; + clear(self); + return array; +}; +var take = (self) => { + if (!self.head) + return Empty; + const message = self.head.array[self.head.offset]; + if (self.head.mutable) + self.head.array[self.head.offset] = undefined; + self.head.offset++; + self.length--; + if (self.head.offset === self.head.array.length) { + if (self.head.next) { + self.head = self.head.next; + } else { + clear(self); } - result = catchCause2(result, (cause) => failCauseSync2(() => map5(cause, (issue) => new Encoding(ast, issue, input, options)))); - return flatMapEager2(result, (value) => { - const local = parseLocal(value, options); - return local === sameExit ? succeed7(value) : local; - }); - }; -} - -// node_modules/effect/dist/internal/schema/make.js -var TypeId12 = "~effect/Schema/Schema"; -var SchemaProto = { - [TypeId12]: TypeId12, - pipe() { - return pipeArguments(this, arguments); - }, - annotate(annotations) { - return this.rebuild(annotate(this.ast, annotations)); - }, - annotateKey(annotations) { - return this.rebuild(annotateKey(this.ast, annotations)); - }, - check(...checks) { - return this.rebuild(appendChecks(this.ast, checks)); } + return message; }; -function make10(ast, options) { - function Schema() {} - const self = Object.setPrototypeOf(Schema, SchemaProto); - if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) { - Object.defineProperties(self, Object.getOwnPropertyDescriptors({ - ...options - })); - } else { - Object.assign(self, options); - } - self.ast = ast; - self.rebuild = (ast) => make10(ast, options); - self.makeEffect = makeEffect(self); - self.make = make9(self); - self.makeOption = makeOption(self); - return self; -} - -// node_modules/effect/dist/Struct.js -var lambda = (f) => f; - -// node_modules/effect/dist/internal/schemaError.js -var SchemaErrorTypeId = "~effect/Schema/SchemaError"; -function isSchemaError(u) { - return hasProperty(u, SchemaErrorTypeId) && u[SchemaErrorTypeId] === SchemaErrorTypeId; -} -// node_modules/effect/dist/Schema.js -var TypeId13 = TypeId12; -function declareConstructor() { - return (typeParameters, run, annotations) => { - return make11(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make11(ast))), annotations)); - }; -} -function declare(is, annotations) { - return declareConstructor()([], () => (input, ast, options) => is(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)), annotations); -} -class SchemaError extends (/* @__PURE__ */ TaggedError2("SchemaError")) { - [SchemaErrorTypeId] = SchemaErrorTypeId; - constructor(issue) { - const stackTraceLimit = getStackTraceLimit(); - setStackTraceLimit(0); - try { - super({ - issue - }); - } finally { - setStackTraceLimit(stackTraceLimit); +// node_modules/effect/dist/Queue.js +var TypeId11 = "~effect/Queue"; +var EnqueueTypeId = "~effect/Queue/Enqueue"; +var DequeueTypeId = "~effect/Queue/Dequeue"; +var variance = { + _A: identity, + _E: identity +}; +var QueueProto = { + [TypeId11]: variance, + [EnqueueTypeId]: variance, + [DequeueTypeId]: variance, + ...PipeInspectableProto, + toJSON() { + return { + _id: "effect/Queue", + state: this.state._tag, + size: sizeUnsafe(this) + }; + } +}; +var make8 = (options) => withFiber((fiber) => { + const self = Object.create(QueueProto); + self.dispatcher = fiber.currentDispatcher; + self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; + self.strategy = options?.strategy ?? "suspend"; + self.messages = make7(); + self.scheduleRunning = false; + self.state = { + _tag: "Open", + takers: new Set, + offers: new Set, + awaiters: new Set + }; + return succeed3(self); +}); +var bounded = (capacity) => make8({ + capacity +}); +var offer = (self, message) => suspend(() => { + if (self.state._tag !== "Open") { + return exitFalse; + } else if (self.messages.length >= self.capacity) { + switch (self.strategy) { + case "dropping": + return exitFalse; + case "suspend": + if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return exitTrue; + } + return offerRemainingSingle(self, message); + case "sliding": + take(self.messages); + append2(self.messages, message); + return exitTrue; } } - get message() { - return defaultFormatter(this.issue); + append2(self.messages, message); + scheduleReleaseTaker(self); + return exitTrue; +}); +var offerUnsafe = (self, message) => { + if (self.state._tag !== "Open") { + return false; + } else if (self.messages.length >= self.capacity) { + if (self.strategy === "sliding") { + take(self.messages); + append2(self.messages, message); + return true; + } else if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return true; + } + return false; } - toString() { - return `SchemaError(${this.message})`; + append2(self.messages, message); + scheduleReleaseTaker(self); + return true; +}; +var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); +var failCauseUnsafe = (self, cause) => { + if (self.state._tag !== "Open") { + return false; } -} -function isSchemaError2(u) { - return isSchemaError(u); -} -function fromIssueEffect(self) { - if (effectIsExit(self)) { - return fromIssueExit(self); + const exit = exitFailCause(cause); + const fail = exitZipRight(exit, exitFailDone); + if (self.state.offers.size === 0 && self.messages.length === 0) { + finalize(self, fail); + return true; } - return catchCause2(self, (cause) => failCauseSync2(() => map5(cause, (issue) => new SchemaError(issue)))); -} -function fromIssueExit(exit) { - return isSuccess3(exit) ? exit : failCause2(map5(exit.cause, (issue) => new SchemaError(issue))); -} -function decodeUnknownEffect2(schema, options) { - const parser = decodeUnknownEffect(schema, options); - return (input, options) => { - return fromIssueEffect(parser(input, options)); + self.state = { + ...self.state, + _tag: "Closing", + exit: fail }; -} -var make11 = make10; -function isSchema(u) { - return hasProperty(u, TypeId13) && u[TypeId13] === TypeId13; -} -var optionalKey2 = /* @__PURE__ */ lambda((schema) => make11(optionalKey(schema.ast), { - schema -})); -function Literal2(literal) { - const out = make11(new Literal(literal), { - literal, - transform(to) { - return out.pipe(decodeTo2(Literal2(to), { - decode: transform(() => to), - encode: transform(() => literal) - })); + return true; +}; +var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); +var shutdown = (self) => sync(() => { + if (self.state._tag === "Done") { + return true; + } + clear(self.messages); + const offers = self.state.offers; + finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); + if (offers.size > 0) { + for (const entry of offers) { + if (entry._tag === "Single") { + entry.resume(exitFalse); + } else { + entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); + } } - }); - return out; -} -var String4 = /* @__PURE__ */ make11(string2); -var Number5 = /* @__PURE__ */ make11(number2); -function makeStruct(ast, fields) { - return make11(ast, { - fields, - mapFields(f, options) { - const fields = f(this.fields); - return makeStruct(struct(fields, options?.unsafePreserveChecks ? this.ast.checks : undefined), fields); + offers.clear(); + } + return true; +}); +var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); +var takeBetween = (self, min, max) => { + min = normalize(min); + max = normalize(max); + return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); +}; +var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); +var poll = (self) => suspend(() => { + const result = takeUnsafe(self); + if (result === undefined) { + return succeed3(none2()); + } + if (result._tag === "Success") { + return succeed3(some2(result.value)); + } + return succeed3(none2()); +}); +var takeUnsafe = (self) => { + if (self.state._tag === "Done") { + return self.state.exit; + } + if (self.messages.length > 0) { + const message = take(self.messages); + releaseCapacity(self); + return exitSucceed(message); + } else if (self.capacity <= 0 && self.state.offers.size > 0) { + const message = takeOfferUnsafe(self.state.offers); + releaseCapacity(self); + return exitSucceed(message); + } + return; +}; +var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; +var exitFalse = /* @__PURE__ */ exitSucceed(false); +var exitTrue = /* @__PURE__ */ exitSucceed(true); +var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); +var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); +var releaseTakers = (self) => { + if (self.state._tag === "Done" || self.state.takers.size === 0) { + return; + } + for (const taker of self.state.takers) { + self.state.takers.delete(taker); + taker(exitVoid); + if (self.messages.length === 0) { + break; } - }); -} -function Struct(fields) { - return makeStruct(struct(fields, undefined), fields); -} -function makeTuple(ast, elements) { - return make11(ast, { - elements, - mapElements(f, options) { - const elements = f(this.elements); - return makeTuple(tuple(elements, options?.unsafePreserveChecks ? this.ast.checks : undefined), elements); + } +}; +var scheduleReleaseTaker = (self) => { + if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { + return; + } + self.scheduleRunning = true; + self.dispatcher.scheduleTask(() => { + self.scheduleRunning = false; + releaseTakers(self); + }, 0); +}; +var takeBetweenUnsafe = (self, min, max) => { + if (self.state._tag === "Done") { + return self.state.exit; + } else if (max <= 0 || min <= 0) { + return exitSucceed([]); + } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { + const messages = [takeOfferUnsafe(self.state.offers)]; + releaseCapacity(self); + return exitSucceed(messages); + } + min = Math.min(min, self.capacity || 1); + if (min <= self.messages.length) { + const messages = takeN(self.messages, max); + releaseCapacity(self); + return exitSucceed(messages); + } +}; +var offerRemainingSingle = (self, message) => { + return callback((resume) => { + if (self.state._tag !== "Open") { + return resume(exitFalse); } + const entry = { + _tag: "Single", + message, + resume + }; + self.state.offers.add(entry); + return sync(() => { + if (self.state._tag === "Open") { + self.state.offers.delete(entry); + } + }); }); -} -function Tuple(elements) { - return makeTuple(tuple(elements), elements); -} -var ArraySchema = /* @__PURE__ */ lambda((schema) => make11(new Arrays(false, [], [schema.ast]), { - value: schema -})); -function makeUnion(ast, members) { - return make11(ast, { - members, - mapMembers(f, options) { - const members = f(this.members); - return makeUnion(union(members, this.ast.options, options?.unsafePreserveChecks ? this.ast.checks : undefined), members); +}; +var takeOfferUnsafe = (offers) => { + const entry = offers.values().next().value; + if (entry._tag === "Single") { + offers.delete(entry); + entry.resume(exitTrue); + return entry.message; + } + const message = entry.remaining[entry.offset++]; + if (entry.offset === entry.remaining.length) { + offers.delete(entry); + entry.resume(exitSucceed([])); + } + return message; +}; +var releaseCapacity = (self) => { + if (self.state._tag === "Done") { + return isDoneCause(self.state.exit.cause); + } else if (self.state.offers.size === 0) { + if (self.state._tag === "Closing" && self.messages.length === 0) { + finalize(self, self.state.exit); + return isDoneCause(self.state.exit.cause); } - }); -} -function Union2(members, options) { - return makeUnion(union(members, options, undefined), members); -} -function Literals(literals) { - const members = literals.map(Literal2); - return make11(union(members, undefined, undefined), { - literals, - members, - mapMembers(f) { - return Union2(f(this.members)); - }, - pick(literals) { - return Literals(literals); - }, - transform(to) { - return Union2(members.map((member, index) => member.transform(to[index]))); + return false; + } + for (const entry of self.state.offers) { + let n = self.capacity - self.messages.length; + if (n <= 0) + break; + else if (entry._tag === "Single") { + append2(self.messages, entry.message); + self.state.offers.delete(entry); + entry.resume(exitTrue); + } else { + for (;entry.offset < entry.remaining.length; entry.offset++) { + if (n === 0) + return false; + append2(self.messages, entry.remaining[entry.offset]); + n--; + } + self.state.offers.delete(entry); + entry.resume(exitSucceed([])); + } + } + return false; +}; +var awaitTake = (self) => callback((resume) => { + if (self.state._tag === "Done") { + return resume(self.state.exit); + } + self.state.takers.add(resume); + return sync(() => { + if (self.state._tag !== "Done") { + self.state.takers.delete(resume); } }); -} -function decodeTo2(to, transformation) { - return (from) => { - return make11(decodeTo(from.ast, to.ast, transformation ? make8(transformation) : passthrough2()), { - from, - to - }); +}); +var finalize = (self, exit) => { + if (self.state._tag === "Done") { + return; + } + const openState = self.state; + self.state = { + _tag: "Done", + exit }; -} -function withConstructorDefault2(defaultValue) { - return (schema) => make11(withConstructorDefault(schema.ast, defaultValue), { - schema - }); -} -function tag(literal) { - return Literal2(literal).pipe(withConstructorDefault2(succeed6(literal))); -} -function TaggedStruct(value, fields) { - return Struct({ - _tag: tag(value), - ...fields - }); -} -function instanceOf(constructor, annotations) { - return declare((u) => u instanceof constructor, annotations); -} -function link() { - return (encodeTo, transformation) => { - return new Link(encodeTo.ast, make8(transformation)); + for (const taker of openState.takers) { + taker(exit); + } + openState.takers.clear(); + for (const awaiter of openState.awaiters) { + awaiter(exit); + } + openState.awaiters.clear(); +}; + +// node_modules/effect/dist/Semaphore.js +var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); +var waitForPermits = (self, n, effect) => callback((resume) => { + if (self.free >= n) + return resume(effect); + const observer = () => { + if (self.free < n) + return; + self.waiters.delete(observer); + resume(effect); }; -} -var makeFilter2 = makeFilter; -function isPattern2(regExp, annotations) { - const source = regExp.source; - const flags = regExp.flags; - const runtimeRegExp = flags === "" ? `new RegExp(${format(source)})` : `new RegExp(${format(source)}, ${format(flags)})`; - return isPattern(regExp, { - toCode: () => ({ - runtime: `Schema.isPattern(${runtimeRegExp})` - }), - ...annotations - }); -} -function isBase64(annotations) { - const regExp = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; - return isPattern2(regExp, { - expected: "a base64 encoded string", - representation: { - id: "effect/schema/isBase64", - payload: null - }, - toJsonSchema: () => ({ - pattern: regExp.source - }), - toCode: () => ({ - runtime: "Schema.isBase64()" - }), - ...annotations - }); -} -function isInt(annotations) { - return makeFilter2((n) => globalThis.Number.isSafeInteger(n), { - expected: "an integer", - representation: { - id: "effect/schema/isInt", - payload: null - }, - toJsonSchema: () => ({ - type: "integer" - }), - toCode: () => ({ - runtime: "Schema.isInt()" - }), - arbitraryConstraint: { - number: "integer" - }, - ...annotations + self.waiters.add(observer); + return sync(() => { + self.waiters.delete(observer); }); -} -var Int = /* @__PURE__ */ Number5.check(/* @__PURE__ */ isInt()); -var RegExp2 = /* @__PURE__ */ instanceOf(globalThis.RegExp, { - representation: { - id: "effect/schema/RegExp", - payload: null - }, - toCode: () => ({ - runtime: `Schema.RegExp`, - Type: `globalThis.RegExp` - }), - expected: "RegExp", - toCodecJson: () => link()(Struct({ - source: String4, - flags: String4 - }), transformEffect2({ - decode: (e, options) => try_2({ - try: () => new globalThis.RegExp(e.source, e.flags), - catch: () => new InvalidValue({ - expected: "valid RegExp source and flags" - }, e, options) - }), - encode: (regExp) => succeed6({ - source: regExp.source, - flags: regExp.flags - }) - })) -}); -var URLString = /* @__PURE__ */ String4.annotate({ - expected: "a string that will be decoded as a URL" -}); -var URL2 = /* @__PURE__ */ instanceOf(globalThis.URL, { - representation: { - id: "effect/schema/URL", - payload: null - }, - toCode: () => ({ - runtime: `Schema.URL`, - Type: `globalThis.URL` - }), - expected: "URL", - toCodecJson: () => link()(URLString, urlFromString) }); -var File = /* @__PURE__ */ instanceOf(globalThis.File, { - representation: { - id: "effect/schema/File", - payload: null - }, - toCode: () => ({ - runtime: `Schema.File`, - Type: `globalThis.File` - }), - expected: "File", - toCodecJson: () => link()(Struct({ - data: String4.check(isBase64()), - type: String4, - name: String4, - lastModified: Int - }), transformEffect2({ - decode: (e, options) => match3(decodeBase64(e.data), { - onFailure: () => fail6(new InvalidValue({ - expected: "a valid Base64 string" - }, e.data, options)), - onSuccess: (bytes) => { - const buffer = new globalThis.Uint8Array(bytes); - return succeed6(new globalThis.File([buffer], e.name, { - type: e.type, - lastModified: e.lastModified - })); - } - }), - encode: (file, options) => tryPromise2({ - try: async () => { - const bytes = new globalThis.Uint8Array(await file.arrayBuffer()); - return { - data: encodeBase64(bytes), - type: file.type, - name: file.name, - lastModified: file.lastModified - }; - }, - catch: () => new InvalidValue({ - expected: "a readable File" - }, file, options) - }) - })) -}); -var FormData2 = /* @__PURE__ */ instanceOf(globalThis.FormData, { - representation: { - id: "effect/schema/FormData", - payload: null - }, - toCode: () => ({ - runtime: `Schema.FormData`, - Type: `globalThis.FormData` - }), - expected: "FormData", - toCodecJson: () => link()(ArraySchema(Tuple([String4, Union2([Struct({ - _tag: tag("String"), - value: String4 - }), Struct({ - _tag: tag("File"), - value: File - })])])), transformEffect2({ - decode: (e) => { - const out = new globalThis.FormData; - for (const [key, entry] of e) { - out.append(key, entry.value); + +class SemaphoreImpl { + waiters = /* @__PURE__ */ new Set; + taken = 0; + permits; + constructor(permits) { + this.permits = permits; + } + get free() { + return this.permits - this.taken; + } + take(n) { + const take = suspend(() => { + if (this.free < n) { + return waitForPermits(this, n, take); } - return succeed6(out); - }, - encode: (formData) => { - return succeed6(globalThis.Array.from(formData.entries()).map(([key, value]) => { - if (typeof value === "string") { - return [key, { - _tag: "String", - value - }]; - } else { - return [key, { - _tag: "File", - value - }]; + this.taken += n; + return succeed3(n); + }); + return take; + } + takeIfAvailable(n) { + return suspend(() => { + if (this.free < n) + return succeed3(false); + this.taken += n; + return succeed3(true); + }); + } + releaseUnsafe(fiber, n) { + this.taken -= n; + if (this.waiters.size > 0) { + fiber.currentDispatcher.scheduleTask(() => { + for (const observer of this.waiters) { + if (this.free <= 0) + break; + observer(); } - })); + }, 0); } - })) -}); -var URLSearchParams2 = /* @__PURE__ */ instanceOf(globalThis.URLSearchParams, { - representation: { - id: "effect/schema/URLSearchParams", - payload: null - }, - toCode: () => ({ - runtime: `Schema.URLSearchParams`, - Type: `globalThis.URLSearchParams` - }), - expected: "URLSearchParams", - toCodecJson: () => link()(String4.annotate({ - expected: "a query string that will be decoded as URLSearchParams" - }), transform2({ - decode: (e) => new globalThis.URLSearchParams(e), - encode: (params) => params.toString() - })) -}); -var Base64String = /* @__PURE__ */ String4.annotate({ - expected: "a base64 encoded string that will be decoded as Uint8Array", - format: "byte", - contentEncoding: "base64" -}); -var Uint8Array2 = /* @__PURE__ */ instanceOf(globalThis.Uint8Array, { - representation: { - id: "effect/schema/Uint8Array", - payload: null - }, - toCode: () => ({ - runtime: `Schema.Uint8Array`, - Type: `globalThis.Uint8Array` - }), - expected: "Uint8Array", - toCodecJson: () => link()(Base64String, uint8ArrayFromBase64String) -}); -var arbitraryMinimumDateTimestamp = -8640000000000000; -var arbitraryMaximumDateTimestamp = 8640000000000000; -var arbitraryMinimumZonedDateTimeTimestamp = arbitraryMinimumDateTimestamp + 14 * 60 * 60 * 1000; -var arbitraryMaximumZonedDateTimeTimestamp = arbitraryMaximumDateTimestamp - 14 * 60 * 60 * 1000; -var arbitraryMinimumTimeZoneOffset = -12 * 60 * 60 * 1000; -var arbitraryMaximumTimeZoneOffset = 14 * 60 * 60 * 1000; -var immerable = /* @__PURE__ */ globalThis.Symbol.for("immer-draftable"); -var payloadToken = {}; -function makeClass(Inherited, identifier, struct2, annotations, proto) { - const getClassSchema = getClassSchemaFactory(struct2, identifier, annotations); - const ClassTypeId = getClassTypeId(identifier); - const out = class extends Inherited { - constructor(...[input, options]) { - const internalOptions = options; - const payload = internalOptions?.["~payload"]; - const value = payload?.token === payloadToken ? payload.value : struct2.make(input ?? {}, options); - super(value, { - ...options, - disableChecks: true, - "~payload": { - token: payloadToken, - value + return this.free; + } + resize(permits) { + return withFiber((fiber) => { + this.permits = permits; + if (this.free < 0) + return void_; + this.releaseUnsafe(fiber, 0); + return void_; + }); + } + release(n) { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); + } + get releaseAll() { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); + } + withPermits(n) { + return (self) => uninterruptibleMask((restore) => { + const acquire = suspend(() => { + if (this.free < n) { + const wait = waitForPermits(this, n, void_); + return flatMap2(restore(wait), () => acquire); } + this.taken += n; + return onExitPrimitive(restore(self), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); }); - } - static [TypeId13] = TypeId13; - get [ClassTypeId]() { - return ClassTypeId; - } - static [immerable] = true; - static identifier = identifier; - static fields = struct2.fields; - static get ast() { - return getClassSchema(this).ast; - } - static pipe() { - return pipeArguments(this, arguments); - } - static rebuild(ast) { - return getClassSchema(this).rebuild(ast); - } - static make(input, options) { - return make9(getClassSchema(this))(input ?? {}, options); - } - static makeOption(input, options) { - return makeOption(getClassSchema(this))(input ?? {}, options); - } - static makeEffect(input, options) { - return getClassSchema(this).makeEffect(input ?? {}, options); - } - static annotate(annotations) { - return this.rebuild(annotate(this.ast, annotations)); - } - static annotateKey(annotations) { - return this.rebuild(annotateKey(this.ast, annotations)); - } - static check(...checks) { - return this.rebuild(appendChecks(this.ast, checks)); - } - static extend(identifier2) { - return (schema, annotations) => { - const extension = isStruct(schema) ? schema : Struct(schema); - const fields = { - ...struct2.fields, - ...extension.fields - }; - const ast = struct(fields, struct2.ast.checks, { - identifier: identifier2 - }); - return makeClass(this, identifier2, makeStruct(appendChecks(ast, extension.ast.checks), fields), annotations, proto); - }; - } - static mapFields(f, options) { - return struct2.mapFields(f, options); - } - }; - if (proto !== undefined) { - Object.assign(out.prototype, proto(identifier)); + return acquire; + }); + } + withPermit = /* @__PURE__ */ this.withPermits(1); + withPermitsIfAvailable(n) { + return (self) => uninterruptibleMask((restore) => { + if (this.free < n) + return succeedNone; + this.taken += n; + return onExitPrimitive(restore(asSome(self)), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); } - return out; -} -function getClassTransformation(self) { - return new Transformation(transform((input) => new self(input, { - "~payload": { - token: payloadToken, - value: input - } - })), passthrough()); -} -function getClassTypeId(identifier) { - return `~effect/Schema/Class/${identifier}`; } -function getClassSchemaFactory(from, identifier, annotations) { - let memo; - return (self) => { - if (memo !== undefined) { - return memo; - } - const ClassTypeId = getClassTypeId(identifier); - const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId); - const transformation = getClassTransformation(self); - const to = make11(new Declaration([from.ast], () => (input, ast, options) => { - return isClassValue(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)); - }, { - identifier, - [CONSTRUCTOR_ANNOTATION_KEY]: ([from]) => ({ - isConstructed: isClassValue, - link: new Link(from, transformation) - }), - toCodec: ([from]) => new Link(from.ast, transformation), - toEquivalence: ([from]) => from, - toFormatter: ([from]) => (t) => `${self.identifier}(${from(t)})`, - [SENTINELS_ANNOTATION_KEY]: collectSentinels(from.ast), - ...annotations - })); - return memo = decodeTo2(to, transformation)(from); - }; -} -function isStruct(schema) { - return isSchema(schema); -} -var Error4 = (identifier) => (schema, annotations) => { - const struct = isStruct(schema) ? schema : Struct(schema); - const self = makeClass(Error2, identifier, struct, annotations, (identifier) => ({ - name: identifier - })); - return self; -}; -var TaggedError3 = (identifier) => { - return (tagValue, schema, annotations) => { - const struct = isStruct(schema) ? schema.mapFields((fields) => ({ - _tag: tag(tagValue), - ...fields - }), { - unsafePreserveChecks: true - }) : TaggedStruct(tagValue, schema); - return Error4(identifier ?? tagValue)(struct, annotations); - }; -}; -// node_modules/effect/dist/Fiber.js -var interrupt3 = fiberInterrupt; -var runIn = fiberRunIn; - -// node_modules/effect/dist/Latch.js -var makeUnsafe5 = makeLatchUnsafe; -// node_modules/effect/dist/MutableList.js -var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); -var make12 = () => ({ - head: undefined, - tail: undefined, - length: 0 -}); -var emptyBucket = () => ({ - array: [], - mutable: true, - offset: 0, - next: undefined -}); -var append2 = (self, message) => { - if (!self.tail) { - self.head = self.tail = emptyBucket(); - } else if (!self.tail.mutable) { - self.tail.next = emptyBucket(); - self.tail = self.tail.next; +// node_modules/effect/dist/Channel.js +var TypeId12 = "~effect/Channel"; +var isChannel = (u) => hasProperty(u, TypeId12); +var ChannelProto = { + [TypeId12]: { + _Env: identity, + _InErr: identity, + _InElem: identity, + _OutErr: identity, + _OutElem: identity + }, + pipe() { + return pipeArguments(this, arguments); } - self.tail.array.push(message); - self.length++; }; -var clear = (self) => { - self.head = self.tail = undefined; - self.length = 0; +var fromTransform = (transform) => { + const self = Object.create(ChannelProto); + self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); + return self; }; -var takeN = (self, n) => { - n = normalize(n); - if (n <= 0 || !self.head) - return []; - n = Math.min(n, self.length); - if (n === self.length && self.head?.offset === 0 && !self.head.next) { - const array = self.head.array; - clear(self); - return array; +var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); +var fromPull = (effect) => fromTransform((_, __) => effect); +var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { + const closableScope = forkUnsafe2(scope); + const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); + const pull = yield* onError2(f(upstream, scope, closableScope), onCause); + return onError2(pull, onCause); +})); +var toTransform = (channel) => channel.transform; +var asyncQueue = (scope, f, options) => make8({ + capacity: options?.bufferSize, + strategy: options?.strategy +}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); +var callbackArray = (f, options) => fromTransform((_, scope) => map5(asyncQueue(scope, f, options), takeAll2)); +var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); +var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done2())); +var map6 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { + let i = 0; + return map5(pull, (o) => f(o, i++)); +}))); +var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); +var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done2))))); +var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { + const strategy = options?.haltStrategy ?? "both"; + const queue = yield* bounded(0); + yield* addFinalizer2(forkedScope, shutdown(queue)); + let done = 0; + function onExit(side, cause) { + done++; + if (!isDoneCause(cause)) { + return failCause4(queue, cause); + } + switch (strategy) { + case "both": { + return done === 2 ? failCause4(queue, cause) : void_3; + } + case "left": + case "right": { + return side === strategy ? failCause4(queue, cause) : void_3; + } + case "either": { + return failCause4(queue, cause); + } + } } - const array = new Array(n); - let index = 0; - let chunk = self.head; - while (chunk) { - while (chunk.offset < chunk.array.length) { - array[index++] = chunk.array[chunk.offset]; - if (chunk.mutable) - chunk.array[chunk.offset] = undefined; - chunk.offset++; - if (index === n) { - self.head = chunk; - self.length -= n; - if (self.length === 0) - clear(self); - return array; + const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); + yield* runSide("left", left, forkUnsafe2(forkedScope)); + yield* runSide("right", right, forkUnsafe2(forkedScope)); + return take2(queue); +}))); +var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { + let stringBuilder = ""; + let midCRLF = false; + let done = none2(); + function splitLinesArray(chunk) { + const chunkBuilder = []; + function pushLine(segment) { + if (stringBuilder.length === 0) { + chunkBuilder.push(segment); + } else { + chunkBuilder.push(stringBuilder + segment); + stringBuilder = ""; } } - chunk = chunk.next; + for (let i = 0;i < chunk.length; i++) { + const str = chunk[i]; + if (str.length !== 0) { + let from = 0; + let indexOfCR = str.indexOf("\r"); + let indexOfLF = str.indexOf(` +`); + if (midCRLF) { + if (indexOfLF === 0) { + from = 1; + indexOfLF = str.indexOf(` +`, from); + } + midCRLF = false; + } + while (indexOfCR !== -1 || indexOfLF !== -1) { + if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { + pushLine(str.substring(from, indexOfLF)); + from = indexOfLF + 1; + indexOfLF = str.indexOf(` +`, from); + } else { + pushLine(str.substring(from, indexOfCR)); + if (str.length === indexOfCR + 1) { + midCRLF = true; + from = str.length; + indexOfCR = -1; + } else { + from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); + indexOfCR = str.indexOf("\r", from); + indexOfLF = str.indexOf(` +`, from); + } + } + } + stringBuilder = stringBuilder + str.substring(from); + } + } + return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; } - clear(self); - return array; -}; -var take = (self) => { - if (!self.head) - return Empty; - const message = self.head.array[self.head.offset]; - if (self.head.mutable) - self.head.array[self.head.offset] = undefined; - self.head.offset++; - self.length--; - if (self.head.offset === self.head.array.length) { - if (self.head.next) { - self.head = self.head.next; - } else { - clear(self); + const pullOrFlush = suspend2(() => { + if (done._tag === "Some") { + return done2(done.value); } + return matchEffect2(upstream, { + onSuccess: loop, + onFailure: failCause3, + onDone: (leftover) => { + done = some2(leftover); + if (stringBuilder.length > 0) { + const last = stringBuilder; + stringBuilder = ""; + midCRLF = false; + return succeed6([last]); + } + return done2(leftover); + } + }); + }); + function loop(chunk) { + const lines = splitLinesArray(chunk); + return lines !== null ? succeed6(lines) : pullOrFlush; } - return message; -}; - -// node_modules/effect/dist/Queue.js -var TypeId14 = "~effect/Queue"; -var EnqueueTypeId = "~effect/Queue/Enqueue"; -var DequeueTypeId = "~effect/Queue/Dequeue"; -var variance = { - _A: identity, - _E: identity -}; -var QueueProto = { - [TypeId14]: variance, - [EnqueueTypeId]: variance, - [DequeueTypeId]: variance, - ...PipeInspectableProto, - toJSON() { - return { - _id: "effect/Queue", - state: this.state._tag, - size: sizeUnsafe(this) - }; - } -}; -var make13 = (options) => withFiber((fiber) => { - const self = Object.create(QueueProto); - self.dispatcher = fiber.currentDispatcher; - self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; - self.strategy = options?.strategy ?? "suspend"; - self.messages = make12(); - self.scheduleRunning = false; - self.state = { - _tag: "Open", - takers: new Set, - offers: new Set, - awaiters: new Set - }; - return succeed3(self); + return pullOrFlush; +})); +var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); +var unwrap = (channel) => fromTransform((upstream, scope) => { + let pull; + return succeed6(suspend2(() => { + if (pull) + return pull; + return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); + })); }); -var bounded = (capacity) => make13({ - capacity +var runWith = (self, f, onHalt) => suspend2(() => { + const scope = makeUnsafe3(); + const makePull = toTransform(self)(done2(), scope); + return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); }); -var offer = (self, message) => suspend(() => { - if (self.state._tag !== "Open") { - return exitFalse; - } else if (self.messages.length >= self.capacity) { - switch (self.strategy) { - case "dropping": - return exitFalse; - case "suspend": - if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return exitTrue; - } - return offerRemainingSingle(self, message); - case "sliding": - take(self.messages); - append2(self.messages, message); - return exitTrue; +var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { + disableYield: true +}))); +var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { + let state = initial(); + return runWith(self, (pull) => whileLoop2({ + while: constTrue, + body: () => pull, + step: (value) => { + state = f(state, value); } + }), () => succeed6(state)); +})); +var toPullScoped = (self, scope) => toTransform(self)(done2(), scope); +// node_modules/effect/dist/internal/schema/interpreter.js +var flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager2(result, f); +function compileTransformation(transformation) { + if (transformation._tag === "Middleware") { + return (result, current, options) => { + const transformed = result === sameExit ? transformation.decode(succeed7(toOption(current)), options) : transformation.decode(mapEager2(result, toOption), options); + return fromOptionalEffect(transformed); + }; } - append2(self.messages, message); - scheduleReleaseTaker(self); - return exitTrue; -}); -var offerUnsafe = (self, message) => { - if (self.state._tag !== "Open") { - return false; - } else if (self.messages.length >= self.capacity) { - if (self.strategy === "sliding") { - take(self.messages); - append2(self.messages, message); - return true; - } else if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return true; + const getter = transformation.decode; + switch (getter._tag) { + case "Passthrough": + return (result, current) => result === sameExit ? succeed7(current) : result; + case "Transform": { + const transform = (value) => value === missing ? missingExit : succeed7(getter.transform(value)); + return (result, current) => flatMapTransformation(result, current, transform); } - return false; + case "TransformOptional": { + const transform = (value) => fromOptionExit(getter.transform(toOption(value))); + return (result, current) => flatMapTransformation(result, current, transform); + } + case "TransformEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => value === missing ? missingExit : getter.transform(value, options)); + case "TransformOptionalEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => fromOptionalEffect(getter.transform(toOption(value), options))); } - append2(self.messages, message); - scheduleReleaseTaker(self); - return true; -}; -var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); -var failCauseUnsafe = (self, cause) => { - if (self.state._tag !== "Open") { - return false; +} +var fromOptionalEffect = (effect) => flatMapEager2(effect, fromOptionExit); +var wrapEncoding = (ast, input, options, effect) => catchCause2(effect, (cause) => failCauseSync2(() => map4(cause, (issue) => new Encoding(ast, issue, input, options)))); +function makeConstructorParser(descriptor, compile) { + const transform = compileTransformation(descriptor.link.transformation); + let sourceParser; + return (input, options) => { + if (input === missing) + return missingExit; + if (descriptor.isConstructed(input)) + return sameExit; + const result = (sourceParser ??= compile(descriptor.link.to))(input, options); + return transform(result, input, options); + }; +} +function withDefault(ast, parser) { + const defaultValue = ast.context.constructorDefault; + return (input, options) => { + if (input !== missing && input !== undefined) + return parser(input, options); + const result = defaultValue; + if (effectIsExit(result) && result._tag === "Success") { + const local = parser(result[args], options); + return local === sameExit ? result : local; + } + return flatMapEager2(wrapEncoding(ast, input, options, result), (value) => { + const local = parser(value, options); + return local === sameExit ? succeed7(value) : local; + }); + }; +} +function compileField(ast, compile) { + const parser = compile(ast); + return ast.context?.constructorDefault === undefined ? parser : withDefault(ast, parser); +} +function compile(ast, compile, compileField, base, specialize) { + if (ast._tag === "Declaration") { + for (const parameter of ast.typeParameters) + compile(parameter); } - const exit = exitFailCause(cause); - const fail = exitZipRight(exit, exitFailDone); - if (self.state.offers.size === 0 && self.messages.length === 0) { - finalize(self, fail); - return true; + const descriptor = compileField ? getConstructorDescriptor(ast) : undefined; + const parser = descriptor ? makeConstructorParser(descriptor, compile) : base ?? ast.getParser(compile, compileField); + const checks = ast.checks; + const links = ast.encoding; + const transformations = links?.map((link) => compileTransformation(link.transformation)); + const encodingChecks = ast.encodingChecks; + if (!links && !checks && !encodingChecks) { + return parser; } - self.state = { - ...self.state, - _tag: "Closing", - exit: fail + let encodingParsers; + const parseChecks = (input, options) => { + let result = parser(input, options); + if (encodingChecks && !options.disableChecks) { + if (effectIsExit(result)) { + if (result._tag === "Success") { + const output = result === sameExit ? input : result[args]; + if (input !== missing && output !== missing) { + const issues = collectIssues(encodingChecks, input, undefined, ast, options); + if (issues) { + result = fail6(new Composite(ast, issues, input, options)); + } + } + } + } else { + result = flatMap3(result, (value) => { + if (input !== missing && value !== missing) { + const issues = collectIssues(encodingChecks, input, undefined, ast, options); + if (issues) { + return fail6(new Composite(ast, issues, input, options)); + } + } + return succeed6(value); + }); + } + } + if (checks && !options.disableChecks) { + if (effectIsExit(result)) { + if (result._tag === "Success") { + const value = result === sameExit ? input : result[args]; + if (value === missing) + return result; + const issues = collectIssues(checks, value, undefined, ast, options); + if (issues) { + result = fail6(new Composite(ast, issues, value, options)); + } + } + } else { + result = flatMap3(result, (value) => { + if (value !== missing) { + const issues = collectIssues(checks, value, undefined, ast, options); + if (issues) { + return fail6(new Composite(ast, issues, value, options)); + } + } + return succeed6(value); + }); + } + } + return result; }; - return true; -}; -var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); -var shutdown = (self) => sync(() => { - if (self.state._tag === "Done") { - return true; + const parseLocal = specialize === undefined ? parseChecks : specialize(parseChecks); + if (!links) { + return parseLocal; } - clear(self.messages); - const offers = self.state.offers; - finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); - if (offers.size > 0) { - for (const entry of offers) { - if (entry._tag === "Single") { - entry.resume(exitFalse); - } else { - entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); + return (input, options) => { + const parsers = encodingParsers ??= links.map((link) => compile(link.to)); + let current = input; + let result = parsers[parsers.length - 1](input, options); + for (let i = links.length - 1;i >= 0; i--) { + result = transformations[i](result, current, options); + if (i !== 0) { + const next = parsers[i - 1]; + if (result._tag === "Success") { + current = result[args]; + result = next(current, options); + } else { + result = flatMapEager2(result, (value) => { + const nextResult = next(value, options); + return nextResult === sameExit ? succeed7(value) : nextResult; + }); + } } } - offers.clear(); + if (result._tag === "Success") { + const value = result[args]; + const local = parseLocal(value, options); + return local === sameExit ? result : local; + } + result = wrapEncoding(ast, input, options, result); + return flatMapEager2(result, (value) => { + const local = parseLocal(value, options); + return local === sameExit ? succeed7(value) : local; + }); + }; +} + +// node_modules/effect/dist/internal/schema/compilerRegistry.js +var invalid3 = /* @__PURE__ */ Symbol(); +var cache = /* @__PURE__ */ new WeakMap; +var compiler; +var compilerAdaptersEnabled = false; +var decodeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "parser") : resolve2(ast).parser; +var makeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "makeEffect") : resolve2(ast).makeEffect; +var makeField = (ast) => compileField(ast, makeChild); + +class InterpretedEntry { + ast; + constructor(ast) { + this.ast = ast; } - return true; -}); -var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); -var takeBetween = (self, min, max) => { - min = normalize(min); - max = normalize(max); - return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); -}; -var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); -var poll = (self) => suspend(() => { - const result = takeUnsafe(self); - if (result === undefined) { - return succeed3(none2()); + get decodeEffect() { + return this.cachedDecodeEffect ??= compile(this.ast, decodeChild); } - if (result._tag === "Success") { - return succeed3(some2(result.value)); + get parser() { + return this.decodeEffect; } - return succeed3(none2()); -}); -var takeUnsafe = (self) => { - if (self.state._tag === "Done") { - return self.state.exit; + get makeEffect() { + return this.cachedMakeEffect ??= compile(this.ast, makeChild, makeField); } - if (self.messages.length > 0) { - const message = take(self.messages); - releaseCapacity(self); - return exitSucceed(message); - } else if (self.capacity <= 0 && self.state.offers.size > 0) { - const message = takeOfferUnsafe(self.state.offers); - releaseCapacity(self); - return exitSucceed(message); +} + +class CompilerEntry extends InterpretedEntry { + compiled; + resolve; + constructor(ast, compiled, resolve) { + super(ast); + this.compiled = compiled; + this.resolve = resolve; } - return; -}; -var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; -var exitFalse = /* @__PURE__ */ exitSucceed(false); -var exitTrue = /* @__PURE__ */ exitSucceed(true); -var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); -var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); -var releaseTakers = (self) => { - if (self.state._tag === "Done" || self.state.takers.size === 0) { - return; + save(key, value) { + Object.defineProperty(this, key, { + value + }); + return value; } - for (const taker of self.state.takers) { - self.state.takers.delete(taker); - taker(exitVoid); - if (self.messages.length === 0) { - break; - } + operation(key) { + const compiled = this.compiled; + return typeof compiled === "function" ? compiled(this.ast, this.resolve, key) : compiled?.[key]; } -}; -var scheduleReleaseTaker = (self) => { - if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { - return; + get is() { + return this.save("is", this.operation("is")); } - self.scheduleRunning = true; - self.dispatcher.scheduleTask(() => { - self.scheduleRunning = false; - releaseTakers(self); - }, 0); -}; -var takeBetweenUnsafe = (self, min, max) => { - if (self.state._tag === "Done") { - return self.state.exit; - } else if (max <= 0 || min <= 0) { - return exitSucceed([]); - } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { - const messages = [takeOfferUnsafe(self.state.offers)]; - releaseCapacity(self); - return exitSucceed(messages); + get decode() { + return this.save("decode", this.operation("decode")); } - min = Math.min(min, self.capacity || 1); - if (min <= self.messages.length) { - const messages = takeN(self.messages, max); - releaseCapacity(self); - return exitSucceed(messages); + get make() { + return this.save("make", this.operation("make")); } -}; -var offerRemainingSingle = (self, message) => { - return callback((resume) => { - if (self.state._tag !== "Open") { - return resume(exitFalse); - } - const entry = { - _tag: "Single", - message, - resume - }; - self.state.offers.add(entry); - return sync(() => { - if (self.state._tag === "Open") { - self.state.offers.delete(entry); - } - }); - }); -}; -var takeOfferUnsafe = (offers) => { - const entry = offers.values().next().value; - if (entry._tag === "Single") { - offers.delete(entry); - entry.resume(exitTrue); - return entry.message; + get decodeEffect() { + return this.save("decodeEffect", this.operation("decodeEffect") ?? compile(this.ast, (ast) => lazyParser(this.resolve, ast, "parser"))); } - const message = entry.remaining[entry.offset++]; - if (entry.offset === entry.remaining.length) { - offers.delete(entry); - entry.resume(exitSucceed([])); + get parser() { + const decode = this.decode; + return decode === undefined ? this.decodeEffect : this.save("parser", withDecode(decode, () => this.decodeEffect)); } - return message; -}; -var releaseCapacity = (self) => { - if (self.state._tag === "Done") { - return isDoneCause(self.state.exit.cause); - } else if (self.state.offers.size === 0) { - if (self.state._tag === "Closing" && self.messages.length === 0) { - finalize(self, self.state.exit); - return isDoneCause(self.state.exit.cause); - } - return false; + get makeEffect() { + const makeEffect = this.operation("makeEffect"); + if (makeEffect !== undefined) + return this.save("makeEffect", makeEffect); + const child = (ast) => lazyParser(this.resolve, ast, "makeEffect"); + return this.save("makeEffect", compile(this.ast, child, (ast) => compileField(ast, child))); } - for (const entry of self.state.offers) { - let n = self.capacity - self.messages.length; - if (n <= 0) - break; - else if (entry._tag === "Single") { - append2(self.messages, entry.message); - self.state.offers.delete(entry); - entry.resume(exitTrue); - } else { - for (;entry.offset < entry.remaining.length; entry.offset++) { - if (n === 0) - return false; - append2(self.messages, entry.remaining[entry.offset]); - n--; +} +function withDecode(fastDecode, decodeEffect) { + let detailed; + return (input, options) => { + if (input !== missing) { + try { + const value = fastDecode(input, options); + if (value !== invalid3) + return value === input ? sameExit : succeed7(value); + } catch (error) { + return die3(error); } - self.state.offers.delete(entry); - entry.resume(exitSucceed([])); } + return (detailed ??= decodeEffect())(input, options); + }; +} +function lazyParser(resolve, ast, operation) { + const entry = resolve(ast); + if (entry.compiled === undefined || Object.hasOwn(entry, operation)) { + return entry[operation]; } - return false; -}; -var awaitTake = (self) => callback((resume) => { - if (self.state._tag === "Done") { - return resume(self.state.exit); - } - self.state.takers.add(resume); - return sync(() => { - if (self.state._tag !== "Done") { - self.state.takers.delete(resume); + let parser; + return (input, options) => (parser ??= entry[operation])(input, options); +} +function resolve2(ast) { + const cached = cache.get(ast); + if (cached !== undefined) + return cached; + const entry = compiler === undefined ? new InterpretedEntry(ast) : new CompilerEntry(ast, compiler(ast, resolve2), resolve2); + cache.set(ast, entry); + return entry; +} + +// node_modules/effect/dist/SchemaParser.js +function makeEffect(schema) { + const ast = schema.ast; + let parser; + return (input, options) => { + return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions); + }; +} +function makeOption(schema) { + const parser = makeEffect(schema); + return (input, options) => { + const exit = runSyncExit2(parser(input, options)); + if (isSuccess3(exit)) { + return some2(exit.value); } - }); -}); -var finalize = (self, exit) => { - if (self.state._tag === "Done") { - return; - } - const openState = self.state; - self.state = { - _tag: "Done", - exit + getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); + return none2(); }; - for (const taker of openState.takers) { - taker(exit); - } - openState.takers.clear(); - for (const awaiter of openState.awaiters) { - awaiter(exit); +} +function make9(schema) { + return makeConstructorSync(toType(schema.ast)); +} +function decodeUnknownEffect(schema, options) { + const parser = run(schema.ast); + return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); +} +var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { + ...options, + ...overrideOptions +} : options; +var getValue = (value) => { + if (value === missing) { + return fail6(new InvalidValue); } - openState.awaiters.clear(); + return succeed6(value); }; - -// node_modules/effect/dist/Semaphore.js -var makeUnsafe6 = (permits) => new SemaphoreImpl(permits); -var waitForPermits = (self, n, effect) => callback((resume) => { - if (self.free >= n) - return resume(effect); - const observer = () => { - if (self.free < n) - return; - self.waiters.delete(observer); - resume(effect); +function run(ast) { + return runWithCompiler(normalCompiler, ast); +} +function parserResult(result, input) { + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; +} +function runWithCompiler(compiler, ast) { + let parser; + return (input, options) => { + const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; }; - self.waiters.add(observer); - return sync(() => { - self.waiters.delete(observer); +} +function runSync2(effect, message) { + const exit = runSyncExit2(effect); + if (isSuccess3(exit)) { + return exit.value; + } + const issue = getSchemaIssueOrThrow(exit.cause, message); + throw new Error("Schema validation failed", { + cause: issue }); -}); +} +function makeConstructorSync(ast) { + let entry; + let parser; + return (input, options) => { + entry ??= resolve2(ast); + const parseOptions = options?.disableChecks ? options.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions ?? defaultParseOptions; + const make = entry.make; + if (make !== undefined && input !== missing) { + let output; + try { + output = make(input, parseOptions); + } catch (error) { + getSchemaIssueOrThrow(die2(error), "Constructor adapter can only throw schema issues"); + throw error; + } + if (output !== invalid3 && output !== missing) + return output; + } + const result = (parser ??= entry.makeEffect)(input, parseOptions); + return runSync2(parserResult(result, input), "Constructor adapter can only throw schema issues"); + }; +} +var normalCompiler = (ast) => resolve2(ast).parser; +var constructorCompiler = (ast) => resolve2(ast).makeEffect; -class SemaphoreImpl { - waiters = /* @__PURE__ */ new Set; - taken = 0; - permits; - constructor(permits) { - this.permits = permits; - } - get free() { - return this.permits - this.taken; +// node_modules/effect/dist/internal/schema/make.js +var TypeId13 = "~effect/Schema/Schema"; +var SchemaProto = { + [TypeId13]: TypeId13, + pipe() { + return pipeArguments(this, arguments); + }, + annotate(annotations) { + return this.rebuild(annotate(this.ast, annotations)); + }, + annotateKey(annotations) { + return this.rebuild(annotateKey(this.ast, annotations)); + }, + check(...checks) { + return this.rebuild(appendChecks(this.ast, checks)); } - take(n) { - const take = suspend(() => { - if (this.free < n) { - return waitForPermits(this, n, take); - } - this.taken += n; - return succeed3(n); - }); - return take; +}; +function make10(ast, options) { + function Schema() {} + const self = Object.setPrototypeOf(Schema, SchemaProto); + if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) { + Object.defineProperties(self, Object.getOwnPropertyDescriptors({ + ...options + })); + } else { + Object.assign(self, options); } - takeIfAvailable(n) { - return suspend(() => { - if (this.free < n) - return succeed3(false); - this.taken += n; - return succeed3(true); - }); - } - releaseUnsafe(fiber, n) { - this.taken -= n; - if (this.waiters.size > 0) { - fiber.currentDispatcher.scheduleTask(() => { - for (const observer of this.waiters) { - if (this.free <= 0) - break; - observer(); - } - }, 0); + self.ast = ast; + self.rebuild = (ast) => make10(ast, options); + self.makeEffect = makeEffect(self); + self.make = make9(self); + self.makeOption = makeOption(self); + return self; +} + +// node_modules/effect/dist/Struct.js +var lambda = (f) => f; + +// node_modules/effect/dist/internal/schemaError.js +var SchemaErrorTypeId = "~effect/Schema/SchemaError"; +function isSchemaError(u) { + return hasProperty(u, SchemaErrorTypeId) && u[SchemaErrorTypeId] === SchemaErrorTypeId; +} + +// node_modules/effect/dist/Schema.js +var TypeId14 = TypeId13; +function declareConstructor() { + return (typeParameters, run, annotations) => { + return make11(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make11(ast))), annotations)); + }; +} +function declare(is, annotations) { + return declareConstructor()([], () => (input, ast, options) => is(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)), annotations); +} +class SchemaError extends (/* @__PURE__ */ TaggedError2("SchemaError")) { + [SchemaErrorTypeId] = SchemaErrorTypeId; + constructor(issue) { + const stackTraceLimit = getStackTraceLimit(); + setStackTraceLimit(0); + try { + super({ + issue + }); + } finally { + setStackTraceLimit(stackTraceLimit); } - return this.free; } - resize(permits) { - return withFiber((fiber) => { - this.permits = permits; - if (this.free < 0) - return void_; - this.releaseUnsafe(fiber, 0); - return void_; - }); - } - release(n) { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); + get message() { + return defaultFormatter(this.issue); } - get releaseAll() { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); + toString() { + return `SchemaError(${this.message})`; } - withPermits(n) { - return (self) => uninterruptibleMask((restore) => { - const acquire = suspend(() => { - if (this.free < n) { - const wait = waitForPermits(this, n, void_); - return flatMap2(restore(wait), () => acquire); - } - this.taken += n; - return onExitPrimitive(restore(self), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); - return acquire; - }); +} +function isSchemaError2(u) { + return isSchemaError(u); +} +function fromIssueEffect(self) { + if (effectIsExit(self)) { + return fromIssueExit(self); } - withPermit = /* @__PURE__ */ this.withPermits(1); - withPermitsIfAvailable(n) { - return (self) => uninterruptibleMask((restore) => { - if (this.free < n) - return succeedNone; - this.taken += n; - return onExitPrimitive(restore(asSome(self)), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); + return catchCause2(self, (cause) => failCauseSync2(() => map4(cause, (issue) => new SchemaError(issue)))); +} +function fromIssueExit(exit) { + return isSuccess3(exit) ? exit : failCause2(map4(exit.cause, (issue) => new SchemaError(issue))); +} +function decodeUnknownEffect2(schema, options) { + const parser = decodeUnknownEffect(schema, options); + return (input, options) => { + return fromIssueEffect(parser(input, options)); + }; +} +var make11 = make10; +function isSchema(u) { + return hasProperty(u, TypeId14) && u[TypeId14] === TypeId14; +} +var optionalKey2 = /* @__PURE__ */ lambda((schema) => make11(optionalKey(schema.ast), { + schema +})); +function Literal2(literal) { + const out = make11(new Literal(literal), { + literal, + transform(to) { + return out.pipe(decodeTo2(Literal2(to), { + decode: transform(() => to), + encode: transform(() => literal) + })); + } + }); + return out; +} +var String4 = /* @__PURE__ */ make11(string2); +var Number5 = /* @__PURE__ */ make11(number2); +function makeStruct(ast, fields) { + return make11(ast, { + fields, + mapFields(f, options) { + const fields = f(this.fields); + return makeStruct(struct(fields, options?.unsafePreserveChecks ? this.ast.checks : undefined), fields); + } + }); +} +function Struct(fields) { + return makeStruct(struct(fields, undefined), fields); +} +function makeTuple(ast, elements) { + return make11(ast, { + elements, + mapElements(f, options) { + const elements = f(this.elements); + return makeTuple(tuple(elements, options?.unsafePreserveChecks ? this.ast.checks : undefined), elements); + } + }); +} +function Tuple(elements) { + return makeTuple(tuple(elements), elements); +} +var ArraySchema = /* @__PURE__ */ lambda((schema) => make11(new Arrays(false, [], [schema.ast]), { + value: schema +})); +function makeUnion(ast, members) { + return make11(ast, { + members, + mapMembers(f, options) { + const members = f(this.members); + return makeUnion(union(members, this.ast.options, options?.unsafePreserveChecks ? this.ast.checks : undefined), members); + } + }); +} +function Union2(members, options) { + return makeUnion(union(members, options, undefined), members); +} +function Literals(literals) { + const members = literals.map(Literal2); + return make11(union(members, undefined, undefined), { + literals, + members, + mapMembers(f) { + return Union2(f(this.members)); + }, + pick(literals) { + return Literals(literals); + }, + transform(to) { + return Union2(members.map((member, index) => member.transform(to[index]))); + } + }); +} +function decodeTo2(to, transformation) { + return (from) => { + return make11(decodeTo(from.ast, to.ast, transformation ? makeTransformation(transformation) : passthrough2()), { + from, + to }); - } + }; } - -// node_modules/effect/dist/Channel.js -var TypeId15 = "~effect/Channel"; -var isChannel = (u) => hasProperty(u, TypeId15); -var ChannelProto = { - [TypeId15]: { - _Env: identity, - _InErr: identity, - _InElem: identity, - _OutErr: identity, - _OutElem: identity +function withConstructorDefault2(defaultValue) { + return (schema) => make11(withConstructorDefault(schema.ast, defaultValue), { + schema + }); +} +function tag(literal) { + return Literal2(literal).pipe(withConstructorDefault2(succeed6(literal))); +} +function TaggedStruct(value, fields) { + return Struct({ + _tag: tag(value), + ...fields + }); +} +function instanceOf(constructor, annotations) { + return declare((u) => u instanceof constructor, annotations); +} +function link() { + return (encodeTo, transformation) => { + return new Link(encodeTo.ast, makeTransformation(transformation)); + }; +} +var makeFilter2 = makeFilter; +function isPattern2(regExp, annotations) { + const source = regExp.source; + const flags = regExp.flags; + const runtimeRegExp = flags === "" ? `new RegExp(${format(source)})` : `new RegExp(${format(source)}, ${format(flags)})`; + return isPattern(regExp, { + toCode: () => ({ + runtime: `Schema.isPattern(${runtimeRegExp})` + }), + ...annotations + }); +} +function isBase64(annotations) { + const regExp = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; + return isPattern2(regExp, { + expected: "a base64 encoded string", + representation: { + id: "effect/schema/isBase64", + payload: null + }, + toJsonSchema: () => ({ + pattern: regExp.source + }), + toCode: () => ({ + runtime: "Schema.isBase64()" + }), + ...annotations + }); +} +function isInt(annotations) { + return makeFilter2((n) => globalThis.Number.isSafeInteger(n), { + expected: "an integer", + representation: { + id: "effect/schema/isInt", + payload: null + }, + toJsonSchema: () => ({ + type: "integer" + }), + toCode: () => ({ + runtime: "Schema.isInt()" + }), + arbitraryConstraint: { + number: "integer" + }, + ...annotations + }); +} +var Int = /* @__PURE__ */ Number5.check(/* @__PURE__ */ isInt()); +var RegExp2 = /* @__PURE__ */ instanceOf(globalThis.RegExp, { + representation: { + id: "effect/schema/RegExp", + payload: null }, - pipe() { - return pipeArguments(this, arguments); - } -}; -var fromTransform = (transform) => { - const self = Object.create(ChannelProto); - self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); - return self; -}; -var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); -var fromPull = (effect) => fromTransform((_, __) => effect); -var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { - const closableScope = forkUnsafe2(scope); - const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); - const pull = yield* onError2(f(upstream, scope, closableScope), onCause); - return onError2(pull, onCause); -})); -var toTransform = (channel) => channel.transform; -var asyncQueue = (scope, f, options) => make13({ - capacity: options?.bufferSize, - strategy: options?.strategy -}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); -var callbackArray = (f, options) => fromTransform((_, scope) => map6(asyncQueue(scope, f, options), takeAll2)); -var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); -var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done3())); -var map7 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { - let i = 0; - return map6(pull, (o) => f(o, i++)); -}))); -var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); -var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done3))))); -var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { - const strategy = options?.haltStrategy ?? "both"; - const queue = yield* bounded(0); - yield* addFinalizer2(forkedScope, shutdown(queue)); - let done = 0; - function onExit(side, cause) { - done++; - if (!isDoneCause(cause)) { - return failCause4(queue, cause); + toCode: () => ({ + runtime: `Schema.RegExp`, + Type: `globalThis.RegExp` + }), + expected: "RegExp", + toCodecJson: () => link()(Struct({ + source: String4, + flags: String4 + }), transformEffect2({ + decode: (e, options) => try_2({ + try: () => new globalThis.RegExp(e.source, e.flags), + catch: () => new InvalidValue({ + expected: "valid RegExp source and flags" + }, e, options) + }), + encode: (regExp) => succeed6({ + source: regExp.source, + flags: regExp.flags + }) + })) +}); +var URLString = /* @__PURE__ */ String4.annotate({ + expected: "a string that will be decoded as a URL" +}); +var URL2 = /* @__PURE__ */ instanceOf(globalThis.URL, { + representation: { + id: "effect/schema/URL", + payload: null + }, + toCode: () => ({ + runtime: `Schema.URL`, + Type: `globalThis.URL` + }), + expected: "URL", + toCodecJson: () => link()(URLString, urlFromString) +}); +var File = /* @__PURE__ */ instanceOf(globalThis.File, { + representation: { + id: "effect/schema/File", + payload: null + }, + toCode: () => ({ + runtime: `Schema.File`, + Type: `globalThis.File` + }), + expected: "File", + toCodecJson: () => link()(Struct({ + data: String4.check(isBase64()), + type: String4, + name: String4, + lastModified: Int + }), transformEffect2({ + decode: (e, options) => match2(decodeBase64(e.data), { + onFailure: () => fail6(new InvalidValue({ + expected: "a valid Base64 string" + }, e.data, options)), + onSuccess: (bytes) => { + const buffer = new globalThis.Uint8Array(bytes); + return succeed6(new globalThis.File([buffer], e.name, { + type: e.type, + lastModified: e.lastModified + })); + } + }), + encode: (file, options) => tryPromise2({ + try: async () => { + const bytes = new globalThis.Uint8Array(await file.arrayBuffer()); + return { + data: encodeBase64(bytes), + type: file.type, + name: file.name, + lastModified: file.lastModified + }; + }, + catch: () => new InvalidValue({ + expected: "a readable File" + }, file, options) + }) + })) +}); +var FormData2 = /* @__PURE__ */ instanceOf(globalThis.FormData, { + representation: { + id: "effect/schema/FormData", + payload: null + }, + toCode: () => ({ + runtime: `Schema.FormData`, + Type: `globalThis.FormData` + }), + expected: "FormData", + toCodecJson: () => link()(ArraySchema(Tuple([String4, Union2([Struct({ + _tag: tag("String"), + value: String4 + }), Struct({ + _tag: tag("File"), + value: File + })])])), transformEffect2({ + decode: (e) => { + const out = new globalThis.FormData; + for (const [key, entry] of e) { + out.append(key, entry.value); + } + return succeed6(out); + }, + encode: (formData) => { + return succeed6(globalThis.Array.from(formData.entries()).map(([key, value]) => { + if (typeof value === "string") { + return [key, { + _tag: "String", + value + }]; + } else { + return [key, { + _tag: "File", + value + }]; + } + })); + } + })) +}); +var URLSearchParams2 = /* @__PURE__ */ instanceOf(globalThis.URLSearchParams, { + representation: { + id: "effect/schema/URLSearchParams", + payload: null + }, + toCode: () => ({ + runtime: `Schema.URLSearchParams`, + Type: `globalThis.URLSearchParams` + }), + expected: "URLSearchParams", + toCodecJson: () => link()(String4.annotate({ + expected: "a query string that will be decoded as URLSearchParams" + }), transform2({ + decode: (e) => new globalThis.URLSearchParams(e), + encode: (params) => params.toString() + })) +}); +var Base64String = /* @__PURE__ */ String4.annotate({ + expected: "a base64 encoded string that will be decoded as Uint8Array", + format: "byte", + contentEncoding: "base64" +}); +var Uint8Array2 = /* @__PURE__ */ instanceOf(globalThis.Uint8Array, { + representation: { + id: "effect/schema/Uint8Array", + payload: null + }, + toCode: () => ({ + runtime: `Schema.Uint8Array`, + Type: `globalThis.Uint8Array` + }), + expected: "Uint8Array", + toCodecJson: () => link()(Base64String, uint8ArrayFromBase64String) +}); +var arbitraryMinimumDateTimestamp = -8640000000000000; +var arbitraryMaximumDateTimestamp = 8640000000000000; +var arbitraryMinimumZonedDateTimeTimestamp = arbitraryMinimumDateTimestamp + 14 * 60 * 60 * 1000; +var arbitraryMaximumZonedDateTimeTimestamp = arbitraryMaximumDateTimestamp - 14 * 60 * 60 * 1000; +var arbitraryMinimumTimeZoneOffset = -12 * 60 * 60 * 1000; +var arbitraryMaximumTimeZoneOffset = 14 * 60 * 60 * 1000; +var immerable = /* @__PURE__ */ globalThis.Symbol.for("immer-draftable"); +var payloadToken = {}; +function makeClass(Inherited, identifier, struct2, annotations, proto) { + const getClassSchema = getClassSchemaFactory(struct2, identifier, annotations); + const ClassTypeId = getClassTypeId(identifier); + const out = class extends Inherited { + constructor(...[input, options]) { + const internalOptions = options; + const payload = internalOptions?.["~payload"]; + const value = payload?.token === payloadToken ? payload.value : struct2.make(input ?? {}, options); + super(value, { + ...options, + disableChecks: true, + "~payload": { + token: payloadToken, + value + } + }); + } + static [TypeId14] = TypeId14; + get [ClassTypeId]() { + return ClassTypeId; + } + static [immerable] = true; + static identifier = identifier; + static fields = struct2.fields; + static get ast() { + return getClassSchema(this).ast; + } + static pipe() { + return pipeArguments(this, arguments); } - switch (strategy) { - case "both": { - return done === 2 ? failCause4(queue, cause) : void_3; - } - case "left": - case "right": { - return side === strategy ? failCause4(queue, cause) : void_3; - } - case "either": { - return failCause4(queue, cause); - } + static rebuild(ast) { + return getClassSchema(this).rebuild(ast); } - } - const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); - yield* runSide("left", left, forkUnsafe2(forkedScope)); - yield* runSide("right", right, forkUnsafe2(forkedScope)); - return take2(queue); -}))); -var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { - let stringBuilder = ""; - let midCRLF = false; - let done = none2(); - function splitLinesArray(chunk) { - const chunkBuilder = []; - function pushLine(segment) { - if (stringBuilder.length === 0) { - chunkBuilder.push(segment); - } else { - chunkBuilder.push(stringBuilder + segment); - stringBuilder = ""; - } + static make(input, options) { + return make9(getClassSchema(this))(input ?? {}, options); } - for (let i = 0;i < chunk.length; i++) { - const str = chunk[i]; - if (str.length !== 0) { - let from = 0; - let indexOfCR = str.indexOf("\r"); - let indexOfLF = str.indexOf(` -`); - if (midCRLF) { - if (indexOfLF === 0) { - from = 1; - indexOfLF = str.indexOf(` -`, from); - } - midCRLF = false; - } - while (indexOfCR !== -1 || indexOfLF !== -1) { - if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { - pushLine(str.substring(from, indexOfLF)); - from = indexOfLF + 1; - indexOfLF = str.indexOf(` -`, from); - } else { - pushLine(str.substring(from, indexOfCR)); - if (str.length === indexOfCR + 1) { - midCRLF = true; - from = str.length; - indexOfCR = -1; - } else { - from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); - indexOfCR = str.indexOf("\r", from); - indexOfLF = str.indexOf(` -`, from); - } - } - } - stringBuilder = stringBuilder + str.substring(from); - } + static makeOption(input, options) { + return makeOption(getClassSchema(this))(input ?? {}, options); } - return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; - } - const pullOrFlush = suspend2(() => { - if (done._tag === "Some") { - return done3(done.value); + static makeEffect(input, options) { + return getClassSchema(this).makeEffect(input ?? {}, options); } - return matchEffect2(upstream, { - onSuccess: loop, - onFailure: failCause3, - onDone: (leftover) => { - done = some2(leftover); - if (stringBuilder.length > 0) { - const last = stringBuilder; - stringBuilder = ""; - midCRLF = false; - return succeed6([last]); - } - return done3(leftover); - } - }); - }); - function loop(chunk) { - const lines = splitLinesArray(chunk); - return lines !== null ? succeed6(lines) : pullOrFlush; + static annotate(annotations) { + return this.rebuild(annotate(this.ast, annotations)); + } + static annotateKey(annotations) { + return this.rebuild(annotateKey(this.ast, annotations)); + } + static check(...checks) { + return this.rebuild(appendChecks(this.ast, checks)); + } + static extend(identifier2) { + return (schema, annotations) => { + const extension = isStruct(schema) ? schema : Struct(schema); + const fields = { + ...struct2.fields, + ...extension.fields + }; + const ast = struct(fields, struct2.ast.checks, { + identifier: identifier2 + }); + return makeClass(this, identifier2, makeStruct(appendChecks(ast, extension.ast.checks), fields), annotations, proto); + }; + } + static mapFields(f, options) { + return struct2.mapFields(f, options); + } + }; + if (proto !== undefined) { + Object.assign(out.prototype, proto(identifier)); } - return pullOrFlush; -})); -var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); -var unwrap = (channel) => fromTransform((upstream, scope) => { - let pull; - return succeed6(suspend2(() => { - if (pull) - return pull; - return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); + return out; +} +function getClassTransformation(self) { + return new Transformation(transform((input) => new self(input, { + "~payload": { + token: payloadToken, + value: input + } + })), passthrough()); +} +function getClassTypeId(identifier) { + return `~effect/Schema/Class/${identifier}`; +} +function getClassSchemaFactory(from, identifier, annotations) { + let memo; + return (self) => { + if (memo !== undefined) { + return memo; + } + const ClassTypeId = getClassTypeId(identifier); + const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId); + const transformation = getClassTransformation(self); + const to = make11(new Declaration([from.ast], () => (input, ast, options) => { + return isClassValue(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)); + }, { + identifier, + [CONSTRUCTOR_ANNOTATION_KEY]: ([from]) => ({ + isConstructed: isClassValue, + link: new Link(from, transformation) + }), + toCodec: ([from]) => new Link(from.ast, transformation), + toEquivalence: ([from]) => from, + toFormatter: ([from]) => (t) => `${self.identifier}(${from(t)})`, + [SENTINELS_ANNOTATION_KEY]: collectSentinels(from.ast), + ...annotations + })); + return memo = decodeTo2(to, transformation)(from); + }; +} +function isStruct(schema) { + return isSchema(schema); +} +var Error4 = (identifier) => (schema, annotations) => { + const struct = isStruct(schema) ? schema : Struct(schema); + const self = makeClass(Error2, identifier, struct, annotations, (identifier) => ({ + name: identifier })); -}); -var runWith = (self, f, onHalt) => suspend2(() => { - const scope = makeUnsafe3(); - const makePull = toTransform(self)(done3(), scope); - return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); -}); -var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { - disableYield: true -}))); -var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { - let state = initial(); - return runWith(self, (pull) => whileLoop2({ - while: constTrue, - body: () => pull, - step: (value) => { - state = f(state, value); + return self; +}; +var TaggedError3 = (identifier) => { + return (tagValue, schema, annotations) => { + const struct = isStruct(schema) ? schema.mapFields((fields) => ({ + _tag: tag(tagValue), + ...fields + }), { + unsafePreserveChecks: true + }) : TaggedStruct(tagValue, schema); + return Error4(identifier ?? tagValue)(struct, annotations); + }; +}; +// node_modules/effect/dist/PlatformError.js +var TypeId15 = "~effect/PlatformError"; + +class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { + get message() { + return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; + } +} + +class SystemError extends Error3 { + get message() { + return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; + } +} + +class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { + constructor(reason) { + if ("cause" in reason) { + super({ + reason, + cause: reason.cause + }); + } else { + super({ + reason + }); } - }), () => succeed6(state)); -})); -var toPullScoped = (self, scope) => toTransform(self)(done3(), scope); + } + [TypeId15] = TypeId15; + get message() { + return this.reason.message; + } +} +var systemError = (options) => new PlatformError(new SystemError(options)); +var badArgument = (options) => new PlatformError(new BadArgument(options)); // node_modules/effect/dist/internal/stream.js var TypeId16 = "~effect/Stream"; var streamVariance = { _R: identity, _E: identity, - _A: identity -}; -var Stream = function(channel) { - this.channel = channel; + _A: identity +}; +var Stream = function(channel) { + this.channel = channel; +}; +Stream.prototype = { + [TypeId16]: streamVariance, + pipe() { + return pipeArguments(this, arguments); + } +}; +var fromChannel = (channel) => new Stream(channel); + +// node_modules/effect/dist/Sink.js +var TypeId17 = "~effect/Sink"; +var endVoid = /* @__PURE__ */ succeed6([undefined]); +var sinkVariance = { + _A: identity, + _In: identity, + _L: identity, + _E: identity, + _R: identity }; -Stream.prototype = { - [TypeId16]: streamVariance, +var SinkProto = { + [TypeId17]: sinkVariance, pipe() { return pipeArguments(this, arguments); } }; -var fromChannel = (channel) => new Stream(channel); +var isSink = (u) => hasProperty(u, TypeId17); +var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ + disableYield: true +})), catchDone(succeed6))); +var fromTransform2 = (transform) => { + const self = Object.create(SinkProto); + self.transform = transform; + return self; +}; +var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done2))); +var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { + disableYield: true +}), () => endVoid)); +var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { + discard: true +})); +var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ + disableYield: true +}), catchDone(() => endVoid))); +var unwrap2 = (effect) => fromChannel2(unwrap(map5(effect, toChannel))); // node_modules/effect/dist/internal/rcRef.js -var TypeId17 = "~effect/RcRef"; +var TypeId18 = "~effect/RcRef"; var stateEmpty = { _tag: "Empty" }; @@ -7969,12 +8171,12 @@ var variance2 = { }; class RcRefImpl { - [TypeId17] = variance2; + [TypeId18] = variance2; pipe() { return pipeArguments(this, arguments); } state = stateEmpty; - semaphore = /* @__PURE__ */ makeUnsafe6(1); + semaphore = /* @__PURE__ */ makeUnsafe5(1); acquire; context; scope; @@ -7986,10 +8188,10 @@ class RcRefImpl { this.idleTimeToLive = idleTimeToLive; } } -var make14 = (options) => withFiber2((fiber) => { +var make12 = (options) => withFiber2((fiber) => { const context = fiber.context; const scope = get(context, Scope); - const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive ? fromInputUnsafe(options.idleTimeToLive) : undefined); + const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== undefined ? fromInputUnsafe(options.idleTimeToLive) : undefined); return as2(addFinalizerExit(scope, () => { const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; ref.state = stateClosed; @@ -8030,7 +8232,7 @@ var getState = (self) => uninterruptibleMask2(function loop(restore) { } } }); -var get3 = /* @__PURE__ */ fnUntraced2(function* (self_) { +var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { const self = self_; const state = yield* getState(self); const scope = yield* scope2; @@ -8063,45 +8265,8 @@ var get3 = /* @__PURE__ */ fnUntraced2(function* (self_) { }); // node_modules/effect/dist/RcRef.js -var make15 = make14; -var get4 = get3; - -// node_modules/effect/dist/Sink.js -var TypeId18 = "~effect/Sink"; -var endVoid = /* @__PURE__ */ succeed6([undefined]); -var sinkVariance = { - _A: identity, - _In: identity, - _L: identity, - _E: identity, - _R: identity -}; -var SinkProto = { - [TypeId18]: sinkVariance, - pipe() { - return pipeArguments(this, arguments); - } -}; -var isSink = (u) => hasProperty(u, TypeId18); -var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ - disableYield: true -})), catchDone(succeed6))); -var fromTransform2 = (transform) => { - const self = Object.create(SinkProto); - self.transform = transform; - return self; -}; -var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done3))); -var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { - disableYield: true -}), () => endVoid)); -var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { - discard: true -})); -var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ - disableYield: true -}), catchDone(() => endVoid))); -var unwrap2 = (effect) => fromChannel2(unwrap(map6(effect, toChannel))); +var make13 = make12; +var get3 = get2; // node_modules/effect/dist/Stream.js var TypeId19 = "~effect/Stream"; @@ -8113,10 +8278,10 @@ var toChannel2 = (stream) => stream.channel; var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); var empty4 = /* @__PURE__ */ fromChannel3(empty3); var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); -var unwrap3 = (effect) => fromChannel3(unwrap(map6(effect, toChannel2))); -var map8 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { +var unwrap3 = (effect) => fromChannel3(unwrap(map5(effect, toChannel2))); +var map7 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { let i = 0; - return fromChannel3(map7(self.channel, map2((o) => f(o, i++)))); + return fromChannel3(map6(self.channel, map((o) => f(o, i++)))); })); var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { @@ -8130,10 +8295,10 @@ var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (up } return upstream; }).pipe(catch_2((error) => { - done = fail4(error); - return done3(); + done = fail5(error); + return done2(); })); - const pull = map6(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { + const pull = map5(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { leftover = leftover_; return of(value); }); @@ -8141,12 +8306,12 @@ var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (up }))); var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { const decoder = new TextDecoder(options?.encoding); - return map8(self, (chunk) => decoder.decode(chunk, { + return map7(self, (chunk) => decoder.decode(chunk, { stream: true })); })); var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); -var run2 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map6(([a]) => a)))); +var run2 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map5(([a]) => a)))); var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { for (let i = 0;i < chunk.length; i++) { acc.push(chunk[i]); @@ -8168,137 +8333,13 @@ var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, }); })); var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); -// src/action/ActionInputs.ts -var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; -var readRawInput = (name) => { - const value = process.env[inputEnvName(name)]; - return value === undefined || value === "" ? undefined : value; -}; -var readInputs = (names) => { - const inputs = {}; - for (const name of names) { - const value = readRawInput(name); - if (value !== undefined) - inputs[name] = value; - } - return inputs; -}; -var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); -// node_modules/effect/dist/Runtime.js -var defaultTeardown = (exit, onExit) => { - if (isSuccess3(exit)) - return onExit(0); - if (hasInterruptsOnly2(exit.cause)) - return onExit(130); - return onExit(getErrorExitCode(squash(exit.cause))); -}; -var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { - const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { - if (hasInterruptsOnly2(cause)) - return void_3; - const isReported = getErrorReported(squash(cause)); - return isReported ? logError(cause) : void_3; - })); - try { - const keepAlive = globalThis.setInterval(constVoid, 2147483647); - fiber.addObserver(() => { - clearInterval(keepAlive); - }); - } catch {} - const teardown = options?.teardown ?? defaultTeardown; - return f({ - fiber, - teardown - }); -}); -var errorExitCode = "~effect/Runtime/errorExitCode"; -var getErrorExitCode = (u) => { - if (typeof u === "object" && u !== null && errorExitCode in u) { - const code = u[errorExitCode]; - if (typeof code === "number") { - return code; - } - } - return 1; -}; -var errorReported = "~effect/Runtime/errorReported"; -var getErrorReported = (u) => { - if (typeof u === "object" && u !== null && errorReported in u) { - const isReported = u[errorReported]; - if (typeof isReported === "boolean") { - return isReported; - } - } - return true; -}; - -// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js -var runMain = /* @__PURE__ */ makeRunMain(({ - fiber, - teardown -}) => { - let receivedSignal = false; - fiber.addObserver((exit) => { - process.removeListener("SIGINT", onSigint); - process.removeListener("SIGTERM", onSigint); - teardown(exit, (code) => { - if (receivedSignal || code !== 0) { - process.exit(code); - } - }); - }); - function onSigint() { - receivedSignal = true; - fiber.interruptUnsafe(fiber.id); - } - process.on("SIGINT", onSigint); - process.on("SIGTERM", onSigint); -}); - -// node_modules/@effect/platform-node/dist/NodeRuntime.js -var runMain2 = runMain; -// node_modules/effect/dist/PlatformError.js -var TypeId20 = "~effect/PlatformError"; - -class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { - get message() { - return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; - } -} - -class SystemError extends Error3 { - get message() { - return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; - } -} - -class PlatformError2 extends (/* @__PURE__ */ TaggedError2("PlatformError")) { - constructor(reason) { - if ("cause" in reason) { - super({ - reason, - cause: reason.cause - }); - } else { - super({ - reason - }); - } - } - [TypeId20] = TypeId20; - get message() { - return this.reason.message; - } -} -var systemError = (options) => new PlatformError2(new SystemError(options)); -var badArgument = (options) => new PlatformError2(new BadArgument(options)); // node_modules/effect/dist/FileSystem.js -var TypeId21 = "~effect/FileSystem"; -var FileSystem2 = /* @__PURE__ */ Service("effect/FileSystem"); -var make16 = (impl) => FileSystem2.of({ +var TypeId20 = "~effect/FileSystem"; +var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); +var make14 = (impl) => FileSystem.of({ ...impl, - [TypeId21]: TypeId21, + [TypeId20]: TypeId20, exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ try: () => new TextDecoder(encoding).decode(_), @@ -8323,11 +8364,11 @@ var make16 = (impl) => FileSystem2.of({ const readChunk = file.readAlloc(chunkSize); return fromPull2(succeed6(flatMap3(suspend2(() => { if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { - return done3(); + return done2(); } return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; }), match({ - onNone: () => done3(), + onNone: () => done2(), onSome: (buf) => { totalBytesRead += BigInt(buf.length); return succeed6(of(buf)); @@ -8337,7 +8378,7 @@ var make16 = (impl) => FileSystem2.of({ sink: (path, options) => pipe(impl.open(path, { ...options, flag: options?.flag ?? "w" - }), map6((file) => forEach3((_) => file.writeAll(_))), unwrap2), + }), map5((file) => forEach3((_) => file.writeAll(_))), unwrap2), writeFileString: (path, data, options) => flatMap3(try_2({ try: () => new TextEncoder().encode(data), catch: (cause) => badArgument({ @@ -8353,8 +8394,8 @@ class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBa } // node_modules/effect/dist/Path.js -var TypeId22 = "~effect/Path"; -var Path2 = /* @__PURE__ */ Service("effect/Path"); +var TypeId21 = "~effect/Path"; +var Path = /* @__PURE__ */ Service("effect/Path"); function normalizeStringPosix(path, allowAboveRoot) { let res = ""; let lastSegmentLength = 0; @@ -8460,7 +8501,7 @@ function fromFileUrl(url) { } return succeed6(decodeURIComponent(pathname)); } -var resolve2 = function resolve() { +var resolve3 = function resolve() { let resolvedPath = ""; let resolvedAbsolute = false; let cwd = undefined; @@ -8497,7 +8538,7 @@ var resolve2 = function resolve() { var CHAR_FORWARD_SLASH = 47; function toFileUrl(filepath) { const outURL = new URL("file://"); - let resolved = resolve2(filepath); + let resolved = resolve3(filepath); const filePathLast = filepath.charCodeAt(filepath.length - 1); if (filePathLast === CHAR_FORWARD_SLASH && resolved[resolved.length - 1] !== "/") { resolved += "/"; @@ -8529,9 +8570,9 @@ function encodePathChars(filepath) { } return filepath; } -var posixImpl = /* @__PURE__ */ Path2.of({ - [TypeId22]: TypeId22, - resolve: resolve2, +var posixImpl = /* @__PURE__ */ Path.of({ + [TypeId21]: TypeId21, + resolve: resolve3, normalize(path) { if (path.length === 0) return "."; @@ -8822,29 +8863,266 @@ var posixImpl = /* @__PURE__ */ Path2.of({ ret.name = path.slice(startPart, startDot); ret.base = path.slice(startPart, end); } - ret.ext = path.slice(startDot, end); - } - if (startPart > 0) - ret.dir = path.slice(0, startPart - 1); - else if (isAbsolute) - ret.dir = "/"; - return ret; + ret.ext = path.slice(startDot, end); + } + if (startPart > 0) + ret.dir = path.slice(0, startPart - 1); + else if (isAbsolute) + ret.dir = "/"; + return ret; + }, + sep: "/", + fromFileUrl, + toFileUrl, + toNamespacedPath: identity +}); +// node_modules/effect/dist/internal/ulid.js +var maxTimestamp = 2 ** 48 - 1; +var base32Chars = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; +var ulidString = (timestampMillis, bytes) => { + if (bytes.length !== 10) { + throw new Error(`ULID randomness must be exactly 10 bytes, received ${bytes.length}`); + } + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxTimestamp); + let out = ""; + for (let shift = 45;shift >= 0; shift -= 5) { + out += base32Chars[Math.floor(timestamp / 2 ** shift) & 31]; + } + let accumulator = 0; + let bits = 0; + for (const byte of bytes) { + accumulator = accumulator << 8 | byte; + bits += 8; + while (bits >= 5) { + bits -= 5; + out += base32Chars[accumulator >>> bits & 31]; + } + accumulator &= (1 << bits) - 1; + } + return out; +}; + +// node_modules/effect/dist/internal/uuid.js +var hex = (byte) => byte.toString(16).padStart(2, "0"); +var stringify = (bytes) => { + const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; + return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); +}; +var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); +function v4Bytes(bytes = randomBytes()) { + bytes[6] = bytes[6] & 15 | 64; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); +var maxV7Timestamp = 2 ** 48 - 1; +function v7Bytes(timestampMillis, bytes = randomBytes()) { + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); + bytes[0] = Math.floor(timestamp / 2 ** 40); + bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; + bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; + bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; + bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; + bytes[5] = timestamp & 255; + bytes[6] = bytes[6] & 15 | 112; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); + +// node_modules/effect/dist/Crypto.js +var TypeId22 = "~effect/Crypto"; +var Crypto = /* @__PURE__ */ Service("effect/Crypto"); +var make15 = (impl) => { + const randomBytesUnsafe = impl.randomBytes; + const randomBytes = (size) => map5(validateSize("randomBytes", size), randomBytesUnsafe); + const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; + const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; + const nextIntUnsafe = () => { + while (true) { + const bytes = randomBytesUnsafe(7); + const value = readUint53(bytes); + if ((bytes[0] & 32) === 0) { + return value + Number.MIN_SAFE_INTEGER; + } + if (value < Number.MAX_SAFE_INTEGER) { + return value + 1; + } + } + }; + return Crypto.of({ + [TypeId22]: TypeId22, + randomBytes, + nextDoubleUnsafe, + nextIntUnsafe, + digest: impl.digest, + random: sync3(() => nextDoubleUnsafe()), + randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), + randomInt: sync3(() => nextIntUnsafe()), + randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), + randomIntBetween(min, max, options) { + const extra = options?.halfOpen === true ? 0 : 1; + return sync3(() => { + const minInt = Math.ceil(min); + const maxInt = Math.floor(max); + return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; + }); + }, + randomShuffle: (elements) => sync3(() => { + const buffer = Array.from(elements); + for (let i = buffer.length - 1;i >= 1; i = i - 1) { + const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); + const value = buffer[i]; + buffer[i] = buffer[index]; + buffer[index] = value; + } + return buffer; + }), + randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), + randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))), + randomULID: clockWith2((clock) => succeed6(ulidString(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(10)))) + }); +}; +var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ + module: "Crypto", + method, + description: "size must be a non-negative safe integer" +})); +// node_modules/effect/dist/Ref.js +var TypeId23 = "~effect/Ref"; +var RefProto = { + [TypeId23]: { + _A: identity }, - sep: "/", - fromFileUrl, - toFileUrl, - toNamespacedPath: identity + ...PipeInspectableProto, + toJSON() { + return { + _id: "Ref", + ref: this.ref + }; + } +}; +var makeUnsafe6 = (value) => { + const self = Object.create(RefProto); + self.ref = make6(value); + return self; +}; +var make16 = (value) => sync3(() => makeUnsafe6(value)); +var get4 = (self) => sync3(() => self.ref.current); +var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { + self.ref.current = f(self.ref.current); +})); +// node_modules/effect/dist/Runtime.js +var defaultTeardown = (exit, onExit) => { + if (isSuccess3(exit)) + return onExit(0); + if (hasInterruptsOnly2(exit.cause)) + return onExit(130); + return onExit(getErrorExitCode(squash(exit.cause))); +}; +var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { + const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { + if (hasInterruptsOnly2(cause)) + return void_3; + const isReported = getErrorReported(squash(cause)); + return isReported ? logError(cause) : void_3; + })); + try { + const keepAlive = globalThis.setInterval(constVoid, 2147483647); + fiber.addObserver(() => { + clearInterval(keepAlive); + }); + } catch {} + const teardown = options?.teardown ?? defaultTeardown; + return f({ + fiber, + teardown + }); +}); +var errorExitCode = "~effect/Runtime/errorExitCode"; +var getErrorExitCode = (u) => { + if (typeof u === "object" && u !== null && errorExitCode in u) { + const code = u[errorExitCode]; + if (typeof code === "number") { + return code; + } + } + return 1; +}; +var errorReported = "~effect/Runtime/errorReported"; +var getErrorReported = (u) => { + if (typeof u === "object" && u !== null && errorReported in u) { + const isReported = u[errorReported]; + if (typeof isReported === "boolean") { + return isReported; + } + } + return true; +}; +// node_modules/effect/dist/Stdio.js +var TypeId24 = "~effect/Stdio"; +var Stdio = /* @__PURE__ */ Service(TypeId24); +var make17 = (options) => ({ + [TypeId24]: TypeId24, + stdinIsTerminal: succeed6(false), + stdoutIsTerminal: succeed6(false), + ...options }); +// node_modules/effect/dist/Terminal.js +var TypeId25 = "~effect/Terminal"; +var QuitErrorTypeId = "~effect/Terminal/QuitError"; -// node_modules/effect/dist/Brand.js -function nominal() { - return Object.assign((input) => input, { - option: (input) => some2(input), - result: (input) => succeed2(input), - is: (_) => true - }); +class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ + _tag: /* @__PURE__ */ tag("QuitError") +})) { + [QuitErrorTypeId] = QuitErrorTypeId; } +var Terminal = /* @__PURE__ */ Service("effect/Terminal"); +var make18 = (impl) => Terminal.of({ + ...impl, + [TypeId25]: TypeId25 +}); +// src/action/ActionInputs.ts +var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; +var readRawInput = (name) => { + const value = process.env[inputEnvName(name)]; + return value === undefined || value === "" ? undefined : value; +}; +var readInputs = (names) => { + const inputs = {}; + for (const name of names) { + const value = readRawInput(name); + if (value !== undefined) + inputs[name] = value; + } + return inputs; +}; +var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); +// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js +var runMain = /* @__PURE__ */ makeRunMain(({ + fiber, + teardown +}) => { + let receivedSignal = false; + fiber.addObserver((exit) => { + process.removeListener("SIGINT", onSigint); + process.removeListener("SIGTERM", onSigint); + teardown(exit, (code) => { + if (receivedSignal || code !== 0) { + process.exit(code); + } + }); + }); + function onSigint() { + receivedSignal = true; + fiber.interruptUnsafe(fiber.id); + } + process.on("SIGINT", onSigint); + process.on("SIGTERM", onSigint); +}); +// node_modules/@effect/platform-node/dist/NodeRuntime.js +var runMain2 = runMain; // node_modules/effect/dist/unstable/process/ChildProcessSpawner.js var ExitCode = /* @__PURE__ */ nominal(); var ProcessId = /* @__PURE__ */ nominal(); @@ -8862,8 +9140,8 @@ var HandleProto = { var makeHandle = (params) => Object.setPrototypeOf({ ...params }, HandleProto); -var make17 = (spawn) => { - const streamString = (command, options) => spawn(command).pipe(map6((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); +var make19 = (spawn) => { + const streamString = (command, options) => spawn(command).pipe(map5((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); const streamLines = (command, options) => splitLines2(streamString(command, options)); return ChildProcessSpawner.of({ spawn, @@ -8879,7 +9157,7 @@ class ChildProcessSpawner extends (/* @__PURE__ */ Service()("effect/process/Chi } // node_modules/effect/dist/unstable/process/ChildProcess.js -var TypeId23 = "~effect/process/ChildProcess"; +var TypeId26 = "~effect/process/ChildProcess"; var Proto2 = { .../* @__PURE__ */ Prototype2({ label: "Command", @@ -8887,7 +9165,7 @@ var Proto2 = { return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this); } }), - [TypeId23]: TypeId23 + [TypeId26]: TypeId26 }; var makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto2), { _tag: "StandardCommand", @@ -8895,7 +9173,7 @@ var makeStandardCommand = (command, args, options) => Object.assign(Object.creat args, options }); -var make18 = function make(...args) { +var make20 = function make(...args) { if (isTemplateString(args[0])) { const [templates, ...expressions] = args; const tokens = parseTemplates(templates, expressions); @@ -9101,10 +9379,10 @@ var pullIntoWritable = (options) => options.pull.pipe(flatMap3((chunk) => { disableYield: true }), options.endOnDone !== false ? catchDone((_) => { if ("closed" in options.writable && options.writable.closed) { - return done3(_); + return done2(_); } return callback2((resume) => { - const onFinish = () => resume(done3(_)); + const onFinish = () => resume(done2(_)); options.writable.once("finish", onFinish); options.writable.end(); return sync3(() => { @@ -9131,17 +9409,17 @@ var fromReadableChannel = (options) => fromTransform((_, scope) => readableToPul var readableToPullUnsafe = (options) => { const readable = options.readable; const closeOnDone = options.closeOnDone ?? true; - const exit = options.exit ?? make5(undefined); - const latch = options.latch ?? makeUnsafe5(false); + const exit = options.exit ?? make6(undefined); + const latch = options.latch ?? makeUnsafe4(false); function onReadable() { latch.openUnsafe(); } function onError(error) { - exit.current = fail4(options.onError(error)); + exit.current = fail5(options.onError(error)); latch.openUnsafe(); } function onEnd() { - exit.current = fail4(Done2()); + exit.current = fail5(Done2()); latch.openUnsafe(); } readable.on("readable", onReadable); @@ -9210,9 +9488,9 @@ var isProcessAlive = (childProcess, exitSignal) => { var taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { windowsHide: true }, onExit); -var make19 = /* @__PURE__ */ gen2(function* () { - const fs = yield* FileSystem2; - const path = yield* Path2; +var make21 = /* @__PURE__ */ gen2(function* () { + const fs = yield* FileSystem; + const path = yield* Path; const resolveWorkingDirectory = fnUntraced2(function* (options) { if (isUndefined(options.cwd)) return; @@ -9529,7 +9807,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { env, stdio }, process.platform)), fnUntraced2(function* ([childProcess, exitSignal]) { - const exited = yield* isDone2(exitSignal); + const exited = yield* isDone3(exitSignal); if (exited) { const [code] = yield* _await(exitSignal); if (code !== 0 && isNotNull(code)) { @@ -9571,7 +9849,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds); - const isRunning = map6(isDone2(exitSignal), (done) => !done); + const isRunning = map5(isDone3(exitSignal), (done) => !done); const exitCode = flatMap3(_await(exitSignal), ([code, signal]) => { if (isNotNull(code)) { return succeed6(ExitCode(code)); @@ -9608,7 +9886,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { const sourceStream = unwrap3(succeed6(getSourceStream(handles[handles.length - 1], options.from))); const toOption = options.to ?? "stdin"; if (toOption === "stdin") { - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -9620,7 +9898,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { if (isNotUndefined(fd)) { const fdName2 = fdName(fd); const existingFds = command.options.additionalFds ?? {}; - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, additionalFds: { ...existingFds, @@ -9631,7 +9909,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { } }))); } else { - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -9670,9 +9948,9 @@ var make19 = /* @__PURE__ */ gen2(function* () { } } }); - return make17(spawnCommand); + return make19(spawnCommand); }); -var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make19); +var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make21); var flattenCommand = (command) => { const commands = []; const pipeOptions = []; @@ -9702,92 +9980,6 @@ var flattenCommand = (command) => { }; }; -// node_modules/effect/dist/internal/uuid.js -var hex = (byte) => byte.toString(16).padStart(2, "0"); -var stringify = (bytes) => { - const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; - return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); -}; -var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); -function v4Bytes(bytes = randomBytes()) { - bytes[6] = bytes[6] & 15 | 64; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); -var maxV7Timestamp = 2 ** 48 - 1; -function v7Bytes(timestampMillis, bytes = randomBytes()) { - const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); - bytes[0] = Math.floor(timestamp / 2 ** 40); - bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; - bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; - bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; - bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; - bytes[5] = timestamp & 255; - bytes[6] = bytes[6] & 15 | 112; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); - -// node_modules/effect/dist/Crypto.js -var TypeId24 = "~effect/Crypto"; -var Crypto2 = /* @__PURE__ */ Service("effect/Crypto"); -var make20 = (impl) => { - const randomBytesUnsafe = impl.randomBytes; - const randomBytes = (size) => map6(validateSize("randomBytes", size), randomBytesUnsafe); - const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; - const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; - const nextIntUnsafe = () => { - while (true) { - const bytes = randomBytesUnsafe(7); - const value = readUint53(bytes); - if ((bytes[0] & 32) === 0) { - return value + Number.MIN_SAFE_INTEGER; - } - if (value < Number.MAX_SAFE_INTEGER) { - return value + 1; - } - } - }; - return Crypto2.of({ - [TypeId24]: TypeId24, - randomBytes, - nextDoubleUnsafe, - nextIntUnsafe, - digest: impl.digest, - random: sync3(() => nextDoubleUnsafe()), - randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), - randomInt: sync3(() => nextIntUnsafe()), - randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), - randomIntBetween(min, max, options) { - const extra = options?.halfOpen === true ? 0 : 1; - return sync3(() => { - const minInt = Math.ceil(min); - const maxInt = Math.floor(max); - return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; - }); - }, - randomShuffle: (elements) => sync3(() => { - const buffer = Array.from(elements); - for (let i = buffer.length - 1;i >= 1; i = i - 1) { - const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); - const value = buffer[i]; - buffer[i] = buffer[index]; - buffer[index] = value; - } - return buffer; - }), - randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), - randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))) - }); -}; -var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ - module: "Crypto", - method, - description: "size must be a non-negative safe integer" -})); - // node_modules/@effect/platform-node-shared/dist/NodeCrypto.js import * as NodeCrypto from "node:crypto"; var toHashAlgorithm = (algorithm) => { @@ -9812,20 +10004,20 @@ var digest = (algorithm, data) => try_2({ cause }) }); -var make21 = /* @__PURE__ */ make20({ +var make22 = /* @__PURE__ */ make15({ randomBytes: NodeCrypto.randomBytes, digest }); -var layer2 = /* @__PURE__ */ succeed5(Crypto2, make21); +var layer2 = /* @__PURE__ */ succeed5(Crypto, make22); // node_modules/@effect/platform-node/dist/NodeCrypto.js var layer3 = layer2; // node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js -import * as Crypto3 from "node:crypto"; +import * as Crypto2 from "node:crypto"; import * as NFS from "node:fs"; import * as OS from "node:os"; -import * as Path3 from "node:path"; +import * as Path2 from "node:path"; var handleBadArgument = (method) => (err) => badArgument({ module: "FileSystem", method, @@ -9898,8 +10090,8 @@ var makeTempDirectoryFactory = (method) => { const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException("FileSystem", method), handleBadArgument(method)); return (options) => suspend2(() => { const prefix = options?.prefix ?? ""; - const directory = typeof options?.directory === "string" ? Path3.join(options.directory, ".") : OS.tmpdir(); - return nodeMkdtemp(prefix ? Path3.join(directory, prefix) : directory + "/"); + const directory = typeof options?.directory === "string" ? Path2.join(options.directory, ".") : OS.tmpdir(); + return nodeMkdtemp(prefix ? Path2.join(directory, prefix) : directory + "/"); }); }; var makeTempDirectory = /* @__PURE__ */ makeTempDirectoryFactory("makeTempDirectory"); @@ -9921,7 +10113,7 @@ var makeTempDirectoryScoped = /* @__PURE__ */ (() => { var openFactory = (method) => { const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method)); const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method)); - return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map6((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); + return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map5((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); }; var open2 = /* @__PURE__ */ openFactory("open"); var makeFile = /* @__PURE__ */ (() => { @@ -9970,7 +10162,7 @@ var makeFile = /* @__PURE__ */ (() => { read(buffer) { return suspend2(() => { const position = this.position; - return map6(nodeRead(this.fd, { + return map5(nodeRead(this.fd, { buffer, position }), (bytesRead) => { @@ -9987,7 +10179,7 @@ var makeFile = /* @__PURE__ */ (() => { } const buffer = Buffer.allocUnsafeSlow(size); const position = this.position; - return map6(nodeReadAlloc(this.fd, { + return map5(nodeReadAlloc(this.fd, { buffer, position }), (bytesRead) => { @@ -10008,7 +10200,7 @@ var makeFile = /* @__PURE__ */ (() => { }); } truncate(length) { - return map6(nodeTruncate(this.fd, length || undefined), () => { + return map5(nodeTruncate(this.fd, length || undefined), () => { if (!this.append) { const len = BigInt(length ?? 0); if (this.position > len) { @@ -10020,7 +10212,7 @@ var makeFile = /* @__PURE__ */ (() => { write(buffer) { return suspend2(() => { const position = this.position; - return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map6(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { + return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map5(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { if (!this.append) { this.position = position + BigInt(bytesWritten); } @@ -10058,8 +10250,8 @@ var makeTempFileFactory = (method) => { const makeDirectory = makeTempDirectoryFactory(method); return fnUntraced2(function* (options) { const directory = yield* makeDirectory(options); - const random = Crypto3.randomBytes(6).toString("hex"); - const name = Path3.join(directory, options?.suffix ? `${random}${options.suffix}` : random); + const random = Crypto2.randomBytes(6).toString("hex"); + const name = Path2.join(directory, options?.suffix ? `${random}${options.suffix}` : random); yield* writeFile2(name, new Uint8Array(0)); return name; }); @@ -10068,7 +10260,7 @@ var makeTempFile = /* @__PURE__ */ makeTempFileFactory("makeTempFile"); var makeTempFileScoped = /* @__PURE__ */ (() => { const makeFile = /* @__PURE__ */ makeTempFileFactory("makeTempFileScoped"); const removeDirectory = /* @__PURE__ */ removeFactory("makeTempFileScoped"); - return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path3.dirname(file), { + return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path2.dirname(file), { recursive: true }))); })(); @@ -10141,7 +10333,7 @@ var utimes2 = /* @__PURE__ */ (() => { return (path, atime, mtime) => nodeUtimes(path, atime, mtime); })(); var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sync3(() => { - const directory = info.type === "Directory" ? path : Path3.dirname(path); + const directory = info.type === "Directory" ? path : Path2.dirname(path); const watcher = NFS.watch(path, { recursive: options?.recursive ?? false }, (event, path) => { @@ -10149,7 +10341,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy return; switch (event) { case "rename": { - runFork2(matchEffect3(stat2(Path3.resolve(directory, path)), { + runFork2(matchEffect3(stat2(Path2.resolve(directory, path)), { onSuccess: (_) => offer(queue, { _tag: "Create", path @@ -10171,7 +10363,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy } }); watcher.on("error", (error) => { - failCauseUnsafe(queue, fail5(systemError({ + failCauseUnsafe(queue, fail4(systemError({ module: "FileSystem", _tag: "Unknown", method: "watch", @@ -10184,7 +10376,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy }); return watcher; }), (watcher) => sync3(() => watcher.close()))); -var watch2 = (backend, path, options) => stat2(path).pipe(map6((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); +var watch2 = (backend, path, options) => stat2(path).pipe(map5((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); var writeFile2 = (path, data, options) => callback2((resume, signal) => { try { NFS.writeFile(path, data, { @@ -10202,7 +10394,7 @@ var writeFile2 = (path, data, options) => callback2((resume, signal) => { resume(fail6(handleBadArgument("writeFile")(err))); } }); -var makeFileSystem = /* @__PURE__ */ map6(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make16({ +var makeFileSystem = /* @__PURE__ */ map5(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make14({ access: access2, chmod: chmod2, chown: chown2, @@ -10231,7 +10423,7 @@ var makeFileSystem = /* @__PURE__ */ map6(/* @__PURE__ */ serviceOption2(WatchBa }, writeFile: writeFile2 })); -var layer4 = /* @__PURE__ */ effect(FileSystem2)(makeFileSystem); +var layer4 = /* @__PURE__ */ effect(FileSystem)(makeFileSystem); // node_modules/@effect/platform-node/dist/NodeFileSystem.js var layer5 = layer4; @@ -10261,18 +10453,18 @@ var fileUrlOps = (windows) => ({ }) }) }); -var layerPosix = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layerPosix = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.posix, .../* @__PURE__ */ fileUrlOps(false) }); -var layerWin32 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layerWin32 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.win32, .../* @__PURE__ */ fileUrlOps(true) }); -var layer6 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layer6 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath, .../* @__PURE__ */ fileUrlOps(undefined) }); @@ -10280,18 +10472,8 @@ var layer6 = /* @__PURE__ */ succeed5(Path2)({ // node_modules/@effect/platform-node/dist/NodePath.js var layer7 = layer6; -// node_modules/effect/dist/Stdio.js -var TypeId25 = "~effect/Stdio"; -var Stdio2 = /* @__PURE__ */ Service(TypeId25); -var make22 = (options) => ({ - [TypeId25]: TypeId25, - stdinIsTerminal: succeed6(false), - stdoutIsTerminal: succeed6(false), - ...options -}); - // node_modules/@effect/platform-node-shared/dist/NodeStdio.js -var layer8 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make22({ +var layer8 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make17({ args: /* @__PURE__ */ sync3(() => process.argv.slice(2)), stdinIsTerminal: /* @__PURE__ */ sync3(() => process.stdin.isTTY === true), stdoutIsTerminal: /* @__PURE__ */ sync3(() => process.stdout.isTTY === true), @@ -10330,27 +10512,12 @@ var layer8 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make22({ // node_modules/@effect/platform-node/dist/NodeStdio.js var layer9 = layer8; -// node_modules/effect/dist/Terminal.js -var TypeId26 = "~effect/Terminal"; -var QuitErrorTypeId = "~effect/Terminal/QuitError"; - -class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ - _tag: /* @__PURE__ */ tag("QuitError") -})) { - [QuitErrorTypeId] = QuitErrorTypeId; -} -var Terminal2 = /* @__PURE__ */ Service("effect/Terminal"); -var make23 = (impl) => Terminal2.of({ - ...impl, - [TypeId26]: TypeId26 -}); - // node_modules/@effect/platform-node-shared/dist/NodeTerminal.js import * as readline from "node:readline"; -var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { +var make23 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { const stdin = process.stdin; const stdout = process.stdout; - const lines = yield* make13(); + const lines = yield* make8(); let inputEnded = stdin.readableEnded; let readlineActive = false; const onStdinEnd = () => { @@ -10361,7 +10528,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu }; stdin.once("end", onStdinEnd); yield* addFinalizer3(() => sync3(() => stdin.off("end", onStdinEnd))); - const rlRef = yield* make15({ + const rlRef = yield* make13({ acquire: acquireRelease2(sync3(() => { const rl = readline.createInterface({ input: stdin, @@ -10405,7 +10572,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu const columns = sync3(() => stdout.columns ?? 0); const rows = sync3(() => stdout.rows ?? 0); const readInput = gen2(function* () { - const queue = yield* make13(); + const queue = yield* make8(); const handleKeypress = (s, k) => { const userInput = { input: fromUndefinedOr(s), @@ -10435,13 +10602,13 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu if (inputEnded) { handleEnd(); } else { - yield* get4(rlRef); + yield* get3(rlRef); stdin.once("end", handleEnd); } return queue; }); const readLine = suspend2(() => poll(lines).pipe(flatMap3(match({ - onNone: () => scoped2(andThen2(get4(rlRef), take2(lines))), + onNone: () => scoped2(andThen2(get3(rlRef), take2(lines))), onSome: succeed6 })), mapError2(() => new QuitError({})))); const display = (prompt) => uninterruptible2(callback2((resume) => { @@ -10452,7 +10619,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu cause: err })))); })); - return make23({ + return make18({ columns, rows, readInput, @@ -10460,7 +10627,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu display }); }); -var layer10 = /* @__PURE__ */ effect(Terminal2, /* @__PURE__ */ make24(defaultShouldQuit)); +var layer10 = /* @__PURE__ */ effect(Terminal, /* @__PURE__ */ make23(defaultShouldQuit)); function defaultShouldQuit(input) { return input.key.ctrl && (input.key.name === "c" || input.key.name === "d"); } @@ -10515,7 +10682,7 @@ var layer13 = sync2(Service2, () => { class TestService extends Service()("@timmo001/workflows/Annotations/Test") { } var testLayer = effectContext(gen2(function* () { - const recorded = yield* make6([]); + const recorded = yield* make16([]); const write = (line) => update(recorded, (lines) => [...lines, line]); const service = TestService.of({ error: fn2("Annotations.Test.error")(function* (message, properties) { @@ -10534,10 +10701,10 @@ var testLayer = effectContext(gen2(function* () { yield* write("::endgroup::"); }), lines: fn2("Annotations.Test.lines")(function* () { - return yield* get2(recorded); + return yield* get4(recorded); }) }); - return empty().pipe(add(Service2, service), add(TestService, service)); + return empty2().pipe(add(Service2, service), add(TestService, service)); })); class ActionFailure extends TaggedError3()("ActionFailure", { @@ -10560,7 +10727,7 @@ class Service3 extends Service()("@timmo001/workflows/CommandExecutor") { } var layer14 = effect(Service3, gen2(function* () { const spawner = yield* ChildProcessSpawner; - const make = (command, args, options) => make18(command, args, { + const make = (command, args, options) => make20(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true @@ -10599,7 +10766,7 @@ var layer14 = effect(Service3, gen2(function* () { const stream = fn2("CommandExecutor.stream")(function* (command, args, options) { const label = options?.label ?? `${command} ${args.join(" ")}`.trim(); return yield* scoped2(gen2(function* () { - const handle = yield* spawner.spawn(make18(command, args, { + const handle = yield* spawner.spawn(make20(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true, diff --git a/.github/actions/foundation-smoke/dist/index.js b/.github/actions/foundation-smoke/dist/index.js index 570455b8..9e6de6ce 100644 --- a/.github/actions/foundation-smoke/dist/index.js +++ b/.github/actions/foundation-smoke/dist/index.js @@ -487,6 +487,33 @@ function makeCompareSet(equivalence) { var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth); var isEqual = (u) => hasProperty(u, symbol2); +// node_modules/effect/dist/internal/array.js +var isArrayNonEmpty = (self) => self.length > 0; + +// node_modules/effect/dist/internal/count.js +var normalize = (n) => n > 0 ? Math.floor(n) : 0; + +// node_modules/effect/dist/internal/record.js +function assignProperty(self, key, value) { + if (key === "__proto__") { + Object.defineProperty(self, key, { + value, + writable: true, + enumerable: true, + configurable: true + }); + } else { + self[key] = value; + } +} +function assignProperties(self, source) { + for (const key of Reflect.ownKeys(source)) { + if (Object.prototype.propertyIsEnumerable.call(source, key)) { + assignProperty(self, key, source[key]); + } + } +} + // node_modules/effect/dist/Redactable.js var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Redactable"); var isRedactable = (u) => hasProperty(u, symbolRedactable); @@ -729,27 +756,6 @@ var pickInternalCall = () => { }; var internalCall = /* @__PURE__ */ pickInternalCall(); -// node_modules/effect/dist/internal/record.js -function assignProperty(self, key, value) { - if (key === "__proto__") { - Object.defineProperty(self, key, { - value, - writable: true, - enumerable: true, - configurable: true - }); - } else { - self[key] = value; - } -} -function assignProperties(self, source) { - for (const key of Reflect.ownKeys(source)) { - if (Object.prototype.propertyIsEnumerable.call(source, key)) { - assignProperty(self, key, source[key]); - } - } -} - // node_modules/effect/dist/internal/core.js var EffectTypeId = `~effect/Effect`; var ExitTypeId = `~effect/Exit`; @@ -1118,12 +1124,6 @@ var done = (value) => { return exitFail(Done(value)); }; -// node_modules/effect/dist/Effectable.js -var Prototype2 = (options) => makePrimitiveProto({ - op: options.label, - [evaluate]: options.evaluate -}); - // node_modules/effect/dist/internal/option.js var TypeId = "~effect/Option"; var CommonProto = { @@ -1285,9 +1285,40 @@ var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone var fromNullishOr = (a) => a == null ? none2() : some2(a); var fromUndefinedOr = (a) => a === undefined ? none2() : some2(a); var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined); -var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value))); var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value)); -var filter = /* @__PURE__ */ dual(2, (self, predicate) => isNone2(self) ? none2() : predicate(self.value) ? some2(self.value) : none2()); + +// node_modules/effect/dist/Result.js +var succeed2 = succeed; +var fail2 = fail; +var isFailure2 = isFailure; +var match2 = /* @__PURE__ */ dual(2, (self, { + onFailure, + onSuccess +}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); + +// node_modules/effect/dist/Array.js +var Array2 = globalThis.Array; +var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); +var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); +var isArray = Array2.isArray; +var isArrayNonEmpty2 = isArrayNonEmpty; +var isReadonlyArrayNonEmpty = isArrayNonEmpty; +var empty = () => []; +var of = (a) => [a]; +var map = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); +// node_modules/effect/dist/BigInt.js +var BigInt2 = globalThis.BigInt; +var toNumber = (b) => { + if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { + return none2(); + } + return some2(Number(b)); +}; +// node_modules/effect/dist/Effectable.js +var Prototype2 = (options) => makePrimitiveProto({ + op: options.label, + [evaluate]: options.evaluate +}); // node_modules/effect/dist/Context.js var ServiceTypeId = "~effect/Context/Service"; @@ -1428,7 +1459,7 @@ var Proto = { var hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot; var isContext = (u) => hasProperty(u, TypeId3); var isReference = (u) => !!u[ReferenceTypeId]; -var empty = () => emptyContext2; +var empty2 = () => emptyContext2; var emptyContext2 = /* @__PURE__ */ makeUnsafe(/* @__PURE__ */ new Map); var make2 = (key, service) => makeUnsafe(new Map([[key.key, service]])); var add = /* @__PURE__ */ dual(3, (self, key, service) => addUnsafe(self, key.key, service)); @@ -1502,6 +1533,7 @@ var mergeAll = (...ctxs) => { return makeUnsafe(map); }; var Reference = Service; + // node_modules/effect/dist/Duration.js var TypeId4 = "~effect/Duration"; var bigint0 = /* @__PURE__ */ BigInt(0); @@ -1725,7 +1757,7 @@ var minutes = (minutes) => make3(minutes * 60000); var hours = (hours) => make3(hours * 3600000); var days = (days) => make3(days * 86400000); var weeks = (weeks) => make3(weeks * 604800000); -var toMillis = (self) => match2(fromInputUnsafe(self), { +var toMillis = (self) => match3(fromInputUnsafe(self), { onMillis: identity, onNanos: (nanos) => Number(nanos) / 1e6, onInfinity: () => Infinity, @@ -1743,7 +1775,7 @@ var toNanosUnsafe = (input) => { return roundMillisToNanos(self.value.millis); } }; -var match2 = /* @__PURE__ */ dual(2, (self, options) => { +var match3 = /* @__PURE__ */ dual(2, (self, options) => { switch (self.value._tag) { case "Millis": return options.onMillis(self.value.millis); @@ -1771,32 +1803,6 @@ var Equivalence = (self, that) => matchPair(self, that, { }); var equals2 = /* @__PURE__ */ dual(2, (self, that) => Equivalence(self, that)); -// node_modules/effect/dist/internal/array.js -var isArrayNonEmpty = (self) => self.length > 0; - -// node_modules/effect/dist/internal/count.js -var normalize = (n) => n > 0 ? Math.floor(n) : 0; - -// node_modules/effect/dist/Result.js -var succeed2 = succeed; -var fail2 = fail; -var isFailure2 = isFailure; -var match3 = /* @__PURE__ */ dual(2, (self, { - onFailure, - onSuccess -}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); - -// node_modules/effect/dist/Array.js -var Array2 = globalThis.Array; -var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); -var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); -var isArray = Array2.isArray; -var isArrayNonEmpty2 = isArrayNonEmpty; -var isReadonlyArrayNonEmpty = isArrayNonEmpty; -var empty2 = () => []; -var of = (a) => [a]; -var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); - // node_modules/effect/dist/Scheduler.js var Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", { fiberCached: true, @@ -2543,7 +2549,7 @@ class FiberImpl { } this._stack.length = 0; this._children = undefined; - this.context = empty(); + this.context = empty2(); } runLoop(effect) { const prevFiber = globalThis[currentFiberTypeId]; @@ -2715,7 +2721,7 @@ var fiberInterruptAs = /* @__PURE__ */ dual((args) => hasProperty(args[0], Fiber })); var fiberInterruptAll = (fibers) => withFiber((parent) => { const annotations = fiberStackAnnotations(parent); - let fiberArr = empty2(); + let fiberArr = empty(); for (const fiber of fibers) { fiber.interruptUnsafe(parent.id, annotations); fiberArr.push(fiber); @@ -2739,7 +2745,7 @@ var suspend = /* @__PURE__ */ makePrimitive({ return this[args](); } }); -var fromResult = /* @__PURE__ */ match3({ +var fromResult = /* @__PURE__ */ match2({ onFailure: fail3, onSuccess: succeed3 }); @@ -3032,7 +3038,7 @@ var tapCont = function(value) { var tapEffectCont = function(value) { return new ContImpl(this.payload, returnPayload, exitSucceed(value)); }; -var asSome = (self) => map4(self, some2); +var asSome = (self) => map3(self, some2); var andThen = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? returnPayload : andThenCont, f)); var tap = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? tapEffectCont : tapCont, f)); var asVoid = (self) => new ContImpl(self, returnPayload, exitVoid); @@ -3074,8 +3080,8 @@ var flatMapEager = /* @__PURE__ */ dual(2, (self, f) => { } return flatMap2(self, f); }); -var map4 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); -var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map4(self, f)); +var map3 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); +var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map3(self, f)); var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError(self, f)); var exitInterrupt = (fiberId) => exitFailCause(causeInterrupt(fiberId)); var exitIsSuccess = (self) => self._tag === "Success"; @@ -3450,7 +3456,7 @@ var all = (arg, options) => { } return suspend(() => { const out = {}; - return as(forEach(Object.entries(arg), ([key, effect]) => map4(options?.mode === "result" ? result(effect) : effect, (value) => { + return as(forEach(Object.entries(arg), ([key, effect]) => map3(options?.mode === "result" ? result(effect) : effect, (value) => { assignProperty(out, key, value); }), { discard: true, @@ -3726,7 +3732,7 @@ var fiberRunIn = /* @__PURE__ */ dual(2, (self, scope) => { self.addObserver(() => scopeRemoveFinalizerUnsafe(scope, key)); return self; }); -var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty()); +var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty2()); var runSyncExitWith = (context) => { const runFork = runForkWith(context); return (effect) => { @@ -3740,7 +3746,7 @@ var runSyncExitWith = (context) => { return fiber._exit ?? exitDie(new AsyncFiberError(fiber)); }; }; -var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty()); +var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty2()); var succeedTrue = /* @__PURE__ */ succeed3(true); var succeedFalse = /* @__PURE__ */ succeed3(false); @@ -3861,7 +3867,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = noopSpan({ name, parent, - annotations: add(options?.annotations ?? empty(), DisablePropagation, true) + annotations: add(options?.annotations ?? empty2(), DisablePropagation, true) }); } else { const tracer = fiber.getRef(Tracer); @@ -3874,7 +3880,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = tracer.span({ name, parent, - annotations: options?.annotations ?? empty(), + annotations: options?.annotations ?? empty2(), links, startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : bigint02, kind: options?.kind ?? "internal", @@ -4160,10 +4166,23 @@ var tracerLogger = /* @__PURE__ */ loggerMake(({ span.event(toStringUnknown(Array.isArray(message) && message.length === 1 ? message[0] : message), clock.currentTimeNanosUnsafe(), attributes); }); +// node_modules/effect/dist/Cause.js +var isFailReason2 = isFailReason; +var fromReasons = causeFromReasons; +var fail4 = causeFail; +var die2 = causeDie; +var hasInterruptsOnly2 = hasInterruptsOnly; +var map4 = causeMap; +var squash = causeSquash; +var isDone2 = isDone; +var Done2 = Done; +var done2 = done; +var UnknownError2 = UnknownError; + // node_modules/effect/dist/Exit.js var succeed4 = exitSucceed; var failCause2 = exitFailCause; -var fail4 = exitFail; +var fail5 = exitFail; var void_2 = exitVoid; var isSuccess3 = exitIsSuccess; var isFailure3 = exitIsFailure; @@ -4200,8 +4219,8 @@ var _await = (self) => callback((resume) => { }); }); var completeWith = /* @__PURE__ */ dual(2, (self, effect) => sync(() => doneUnsafe(self, effect))); -var done2 = completeWith; -var isDone2 = (self) => sync(() => isDoneUnsafe(self)); +var done3 = completeWith; +var isDone3 = (self) => sync(() => isDoneUnsafe(self)); var isDoneUnsafe = (self) => self.effect !== undefined; var doneUnsafe = (self, effect) => { if (self.effect) @@ -4274,7 +4293,7 @@ var memoMapBuild = (memoMap, layer, scope, build) => { memoMap.map.set(layer, entry); return scopeAddFinalizerExit(scope, entry.finalizer).pipe(flatMap2(() => build(memoMap, layerScope)), onExit((exit) => { entry.effect = exit; - return done2(deferred, exit); + return done3(deferred, exit); })); }; @@ -4312,7 +4331,7 @@ class CurrentMemoMap extends (/* @__PURE__ */ Service()("effect/Layer/CurrentMem return current ? forkMemoMapUnsafe(current) : makeMemoMapUnsafe(); } } -var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map4(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); +var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map3(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); var buildWithScope = /* @__PURE__ */ dual(2, (self, scope) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope))); var succeed5 = function() { if (arguments.length === 1) { @@ -4334,31 +4353,19 @@ var effect = function() { } return effectImpl(arguments[0], arguments[1]); }; -var effectImpl = (service, effect) => effectContext(map4(effect, (value) => make2(service, value))); +var effectImpl = (service, effect) => effectContext(map3(effect, (value) => make2(service, value))); var effectContext = (effect) => fromBuildMemo((_, scope) => provide(effect, scope)); var mergeAllEffect = (layers, memoMap, scope) => { const parentScope = forkUnsafe2(scope, "parallel"); return forEach(layers, (layer) => layer.build(memoMap, forkUnsafe2(parentScope, "sequential")), { concurrency: layers.length - }).pipe(map4((context) => mergeAll(...context))); + }).pipe(map3((context) => mergeAll(...context))); }; var mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope)); -var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map4((merged) => f(merged, context))))); +var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map3((merged) => f(merged, context))))); var provide2 = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, identity)); var provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self))); -// node_modules/effect/dist/Cause.js -var isFailReason2 = isFailReason; -var fromReasons = causeFromReasons; -var fail5 = causeFail; -var hasInterruptsOnly2 = hasInterruptsOnly; -var map5 = causeMap; -var squash = causeSquash; -var isDone3 = isDone; -var Done2 = Done; -var done3 = done; -var UnknownError2 = UnknownError; - // node_modules/effect/dist/internal/random.js var nextBetween = (min, max, draw) => { const value = draw * (max - min) + min; @@ -4378,7 +4385,7 @@ var nextBetween = (min, max, draw) => { // node_modules/effect/dist/Pull.js var catchDone = /* @__PURE__ */ dual(2, (effect, f) => catchCauseFilter(effect, filterDoneLeftover, (l) => f(l))); var isDoneCause = (cause) => cause.reasons.some(isDoneFailure); -var isDoneFailure = (failure) => failure._tag === "Fail" && isDone3(failure.error); +var isDoneFailure = (failure) => failure._tag === "Fail" && isDone2(failure.error); var filterDone = (cause) => { let done; let hasFailure = false; @@ -4420,7 +4427,6 @@ var forEach2 = forEach; var whileLoop2 = whileLoop; var tryPromise2 = tryPromise; var succeed6 = succeed3; -var succeedNone2 = succeedNone; var suspend2 = suspend; var sync3 = sync; var void_3 = void_; @@ -4429,7 +4435,7 @@ var gen2 = gen; var fail6 = fail3; var failCause3 = failCause; var failCauseSync2 = failCauseSync; -var die2 = die; +var die3 = die; var try_2 = try_; var withFiber2 = withFiber; var fromResult2 = fromResult; @@ -4437,7 +4443,7 @@ var flatMap3 = flatMap2; var andThen2 = andThen; var tap2 = tap; var exit2 = exit; -var map6 = map4; +var map5 = map3; var as2 = as; var catch_2 = catch_; var catchTag2 = catchTag; @@ -4483,1442 +4489,287 @@ var effectify = (fn, onError, onSyncError) => (...args) => callback2((resume) => } }); } catch (err) { - resume(onSyncError ? fail6(onSyncError(err, args)) : die2(err)); + resume(onSyncError ? fail6(onSyncError(err, args)) : die3(err)); } }); var mapEager2 = mapEager; var mapErrorEager2 = mapErrorEager; var flatMapEager2 = flatMapEager; var fnUntracedEager2 = fnUntracedEager; -// node_modules/effect/dist/BigInt.js -var BigInt2 = globalThis.BigInt; -var toNumber = (b) => { - if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { - return none2(); - } - return some2(Number(b)); -}; -// node_modules/effect/dist/ByteSize.js -var bigint03 = /* @__PURE__ */ BigInt(0); -var bigint12 = /* @__PURE__ */ BigInt(1); -var decimalBase = /* @__PURE__ */ BigInt(1000); -var binaryBase = /* @__PURE__ */ BigInt(1024); -var decimalUnits = [{ - symbol: "B", - factor: bigint12, - names: ["B", "byte", "bytes"] -}, { - symbol: "kB", - factor: decimalBase, - names: ["kB", "kilobyte", "kilobytes"] -}, { - symbol: "MB", - factor: decimalBase ** /* @__PURE__ */ BigInt(2), - names: ["MB", "megabyte", "megabytes"] -}, { - symbol: "GB", - factor: decimalBase ** /* @__PURE__ */ BigInt(3), - names: ["GB", "gigabyte", "gigabytes"] -}, { - symbol: "TB", - factor: decimalBase ** /* @__PURE__ */ BigInt(4), - names: ["TB", "terabyte", "terabytes"] -}, { - symbol: "PB", - factor: decimalBase ** /* @__PURE__ */ BigInt(5), - names: ["PB", "petabyte", "petabytes"] -}, { - symbol: "EB", - factor: decimalBase ** /* @__PURE__ */ BigInt(6), - names: ["EB", "exabyte", "exabytes"] -}, { - symbol: "ZB", - factor: decimalBase ** /* @__PURE__ */ BigInt(7), - names: ["ZB", "zettabyte", "zettabytes"] -}, { - symbol: "YB", - factor: decimalBase ** /* @__PURE__ */ BigInt(8), - names: ["YB", "yottabyte", "yottabytes"] -}, { - symbol: "RB", - factor: decimalBase ** /* @__PURE__ */ BigInt(9), - names: ["RB", "ronnabyte", "ronnabytes"] -}, { - symbol: "QB", - factor: decimalBase ** /* @__PURE__ */ BigInt(10), - names: ["QB", "quettabyte", "quettabytes"] -}]; -var binaryUnits = [decimalUnits[0], { - symbol: "KiB", - factor: binaryBase, - names: ["KiB", "kibibyte", "kibibytes"] -}, { - symbol: "MiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(2), - names: ["MiB", "mebibyte", "mebibytes"] -}, { - symbol: "GiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(3), - names: ["GiB", "gibibyte", "gibibytes"] -}, { - symbol: "TiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(4), - names: ["TiB", "tebibyte", "tebibytes"] -}, { - symbol: "PiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(5), - names: ["PiB", "pebibyte", "pebibytes"] -}, { - symbol: "EiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(6), - names: ["EiB", "exbibyte", "exbibytes"] -}, { - symbol: "ZiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(7), - names: ["ZiB", "zebibyte", "zebibytes"] -}, { - symbol: "YiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(8), - names: ["YiB", "yobibyte", "yobibytes"] -}]; -var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; -var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); -var make5 = (value) => value; -var invalid2 = (message) => { - throw new Error(`Invalid ByteSize: ${message}`); -}; -var fromNumber = (input) => { - if (!Number.isSafeInteger(input) || input < 0) { - return invalid2(`expected a non-negative safe integer, received ${input}`); +// node_modules/effect/dist/internal/schema/annotations.js +function resolve(ast) { + return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; +} +var STRUCTURAL_ANNOTATION_KEY = "~structural"; +var SENTINELS_ANNOTATION_KEY = "~sentinels"; +var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; +var getExpected = /* @__PURE__ */ memoize((ast) => { + const identifier = resolve(ast)?.identifier; + if (typeof identifier === "string") + return identifier; + return ast.getExpected(getExpected); +}); + +// node_modules/effect/dist/internal/schema/parser.js +var missing = /* @__PURE__ */ Symbol(); +var succeed7 = succeed4; +var missingExit = /* @__PURE__ */ succeed7(missing); +var sameExit = /* @__PURE__ */ succeed7(missing); +var toOption = (value) => value === missing ? none2() : some2(value); +var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed7(option.value); + +// node_modules/effect/dist/SchemaIssue.js +var TypeId7 = "~effect/SchemaIssue/Issue"; +function isIssue(u) { + return hasProperty(u, TypeId7) && u[TypeId7] === TypeId7; +} +function hasInput(issue) { + return Object.hasOwn(issue, "input"); +} + +class IssueNodeImpl { + [TypeId7] = TypeId7; + constructor(input, options) { + if (options?.reportInput === true && input !== missing) { + this.input = input; + } } - return make5(BigInt(input)); -}; -var parse = (input) => { - const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); - if (match === null) - return invalid2(`unsupported syntax ${JSON.stringify(input)}`); - const unit = unitsByName.get(match[3]); - if (unit === undefined) - return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); - const fraction = match[2] ?? ""; - const scale = BigInt(10) ** BigInt(fraction.length); - const numerator = BigInt(match[1] + fraction) * unit.factor; - if (numerator % scale !== bigint03) { - return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); +} +var Filter = class extends IssueNodeImpl { + _tag = "Filter"; + filter; + issue; + constructor(filter, issue, input, options) { + super(input, options); + this.filter = filter; + this.issue = issue; } - return make5(numerator / scale); }; -var fromInputUnsafe2 = (input) => { - switch (typeof input) { - case "bigint": - if (input < bigint03) - return invalid2(`expected a non-negative bigint, received ${input}`); - return make5(input); - case "number": - return fromNumber(input); - case "string": - return parse(input); +var Encoding = class extends IssueNodeImpl { + _tag = "Encoding"; + ast; + issue; + constructor(ast, issue, input, options) { + super(input, options); + this.ast = ast; + this.issue = issue; } - return invalid2(`unsupported input ${input}`); }; -var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); - -// node_modules/effect/dist/PlatformError.js -var TypeId7 = "~effect/PlatformError"; - -class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { - get message() { - return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; +var Pointer = class extends IssueNodeImpl { + _tag = "Pointer"; + path; + issue; + constructor(path, issue) { + super(); + this.path = path; + this.issue = issue; } -} - -class SystemError extends Error3 { - get message() { - return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; +}; +var MissingKey = class extends IssueNodeImpl { + _tag = "MissingKey"; + annotations; + constructor(annotations) { + super(); + this.annotations = annotations; } -} - -class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { - constructor(reason) { - if ("cause" in reason) { - super({ - reason, - cause: reason.cause - }); - } else { - super({ - reason - }); - } +}; +var UnexpectedKey = class extends IssueNodeImpl { + _tag = "UnexpectedKey"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; } - [TypeId7] = TypeId7; - get message() { - return this.reason.message; +}; +var Composite = class extends IssueNodeImpl { + _tag = "Composite"; + ast; + issues; + constructor(ast, issues, input, options) { + super(input, options); + this.ast = ast; + this.issues = issues; } -} -var systemError = (options) => new PlatformError(new SystemError(options)); -var badArgument = (options) => new PlatformError(new BadArgument(options)); - -// node_modules/effect/dist/Fiber.js -var interrupt3 = fiberInterrupt; -var runIn = fiberRunIn; - -// node_modules/effect/dist/Latch.js -var makeUnsafe4 = makeLatchUnsafe; - -// node_modules/effect/dist/MutableRef.js -var TypeId8 = "~effect/MutableRef"; -var MutableRefProto = { - [TypeId8]: TypeId8, - ...PipeInspectableProto, - toJSON() { - return { - _id: "MutableRef", - current: toJson(this.current) - }; +}; +var InvalidType = class extends IssueNodeImpl { + _tag = "InvalidType"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; } }; -var make6 = (value) => { - const ref = Object.create(MutableRefProto); - ref.current = value; - return ref; +var InvalidValue = class extends IssueNodeImpl { + _tag = "InvalidValue"; + annotations; + constructor(annotations, input, options) { + super(input, options); + this.annotations = annotations; + } }; - -// node_modules/effect/dist/MutableList.js -var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); -var make7 = () => ({ - head: undefined, - tail: undefined, - length: 0 -}); -var emptyBucket = () => ({ - array: [], - mutable: true, - offset: 0, - next: undefined -}); -var append2 = (self, message) => { - if (!self.tail) { - self.head = self.tail = emptyBucket(); - } else if (!self.tail.mutable) { - self.tail.next = emptyBucket(); - self.tail = self.tail.next; +var AnyOf = class extends IssueNodeImpl { + _tag = "AnyOf"; + ast; + issues; + constructor(ast, issues, input, options) { + super(input, options); + this.ast = ast; + this.issues = issues; } - self.tail.array.push(message); - self.length++; }; -var clear = (self) => { - self.head = self.tail = undefined; - self.length = 0; +var OneOf = class extends IssueNodeImpl { + _tag = "OneOf"; + ast; + successes; + constructor(ast, successes, input, options) { + super(input, options); + this.ast = ast; + this.successes = successes; + } }; -var takeN = (self, n) => { - n = normalize(n); - if (n <= 0 || !self.head) - return []; - n = Math.min(n, self.length); - if (n === self.length && self.head?.offset === 0 && !self.head.next) { - const array = self.head.array; - clear(self); - return array; +function makeFilterIssue(entry, input, options) { + if (isIssue(entry)) { + return entry; } - const array = new Array(n); - let index = 0; - let chunk = self.head; - while (chunk) { - while (chunk.offset < chunk.array.length) { - array[index++] = chunk.array[chunk.offset]; - if (chunk.mutable) - chunk.array[chunk.offset] = undefined; - chunk.offset++; - if (index === n) { - self.head = chunk; - self.length -= n; - if (self.length === 0) - clear(self); - return array; - } - } - chunk = chunk.next; + if (typeof entry === "string") { + return new InvalidValue({ + message: entry + }, input, options); } - clear(self); - return array; -}; -var take = (self) => { - if (!self.head) - return Empty; - const message = self.head.array[self.head.offset]; - if (self.head.mutable) - self.head.array[self.head.offset] = undefined; - self.head.offset++; - self.length--; - if (self.head.offset === self.head.array.length) { - if (self.head.next) { - self.head = self.head.next; - } else { - clear(self); + const inner = typeof entry.issue === "string" ? new InvalidValue({ + message: entry.issue + }, input, options) : entry.issue; + return new Pointer(entry.path, inner); +} +function makeSingle(out, input, options) { + if (out === undefined) { + return; + } + if (typeof out === "boolean") { + return out ? undefined : new InvalidValue(undefined, input, options); + } + return makeFilterIssue(out, input, options); +} +function normalizeFilterOutput(ast, out, input, options) { + if (Array.isArray(out)) { + if (!isReadonlyArrayNonEmpty(out)) { + return; } + return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map(out, (entry) => makeFilterIssue(entry, input, options)), input, options); } - return message; -}; - -// node_modules/effect/dist/Queue.js -var TypeId9 = "~effect/Queue"; -var EnqueueTypeId = "~effect/Queue/Enqueue"; -var DequeueTypeId = "~effect/Queue/Dequeue"; -var variance = { - _A: identity, - _E: identity -}; -var QueueProto = { - [TypeId9]: variance, - [EnqueueTypeId]: variance, - [DequeueTypeId]: variance, - ...PipeInspectableProto, - toJSON() { - return { - _id: "effect/Queue", - state: this.state._tag, - size: sizeUnsafe(this) - }; - } -}; -var make8 = (options) => withFiber((fiber) => { - const self = Object.create(QueueProto); - self.dispatcher = fiber.currentDispatcher; - self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; - self.strategy = options?.strategy ?? "suspend"; - self.messages = make7(); - self.scheduleRunning = false; - self.state = { - _tag: "Open", - takers: new Set, - offers: new Set, - awaiters: new Set - }; - return succeed3(self); -}); -var bounded = (capacity) => make8({ - capacity -}); -var offer = (self, message) => suspend(() => { - if (self.state._tag !== "Open") { - return exitFalse; - } else if (self.messages.length >= self.capacity) { - switch (self.strategy) { - case "dropping": - return exitFalse; - case "suspend": - if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return exitTrue; - } - return offerRemainingSingle(self, message); - case "sliding": - take(self.messages); - append2(self.messages, message); - return exitTrue; + return makeSingle(out, input, options); +} +var defaultLeafHook = (issue) => { + const message = findMessage(issue); + if (message !== undefined) + return message; + switch (issue._tag) { + case "InvalidType": + return getExpectedMessage(getExpected(issue.ast), issue); + case "InvalidValue": { + const expected = findExpected(issue); + if (expected !== undefined) + return getExpectedMessage(expected, issue); + const input = formatInput(issue); + return input === undefined ? "Expected a valid value" : `Invalid data ${input}`; } - } - append2(self.messages, message); - scheduleReleaseTaker(self); - return exitTrue; -}); -var offerUnsafe = (self, message) => { - if (self.state._tag !== "Open") { - return false; - } else if (self.messages.length >= self.capacity) { - if (self.strategy === "sliding") { - take(self.messages); - append2(self.messages, message); - return true; - } else if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return true; + case "MissingKey": + return "Missing key"; + case "UnexpectedKey": { + const input = formatInput(issue); + return input === undefined ? "Expected no excess property" : `Unexpected key with value ${input}`; + } + case "Forbidden": + return "Forbidden operation"; + case "OneOf": { + const input = formatInput(issue); + return input === undefined ? "Expected exactly one member to match" : `Expected exactly one member to match the input ${input}`; } - return false; - } - append2(self.messages, message); - scheduleReleaseTaker(self); - return true; -}; -var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); -var failCauseUnsafe = (self, cause) => { - if (self.state._tag !== "Open") { - return false; - } - const exit = exitFailCause(cause); - const fail = exitZipRight(exit, exitFailDone); - if (self.state.offers.size === 0 && self.messages.length === 0) { - finalize(self, fail); - return true; } - self.state = { - ...self.state, - _tag: "Closing", - exit: fail - }; - return true; }; -var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); -var shutdown = (self) => sync(() => { - if (self.state._tag === "Done") { - return true; +var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue); +function formatInput(issue) { + return hasInput(issue) ? format(issue.input) : undefined; +} +function findExpected(issue) { + const expected = issue.annotations?.expected; + return typeof expected === "string" ? expected : undefined; +} +function getExpectedMessage(expected, issue) { + const input = formatInput(issue); + return input === undefined ? `Expected ${expected}` : `Expected ${expected}, got ${input}`; +} +function formatCheck(check) { + const expected = check.annotations?.expected; + if (typeof expected === "string") + return expected; + switch (check._tag) { + case "Filter": + return ""; + case "FilterGroup": + return check.checks.map((check) => formatCheck(check)).join(" & "); } - clear(self.messages); - const offers = self.state.offers; - finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); - if (offers.size > 0) { - for (const entry of offers) { - if (entry._tag === "Single") { - entry.resume(exitFalse); +} +function makeFormatterDefault() { + return (issue) => formatIssue(issue, ""); +} +var defaultFormatter = /* @__PURE__ */ makeFormatterDefault(); +function formatIssue(issue, path) { + let message; + switch (issue._tag) { + case "Filter": { + const annotated = defaultCheckHook(issue); + if (annotated !== undefined) { + message = annotated; } else { - entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); + if (issue.issue._tag !== "InvalidValue") { + return formatIssue(issue.issue, path); + } + const expected = findExpected(issue.issue); + message = expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue); } + break; } - offers.clear(); - } - return true; -}); -var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); -var takeBetween = (self, min, max) => { - min = normalize(min); - max = normalize(max); - return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); -}; -var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); -var poll = (self) => suspend(() => { - const result = takeUnsafe(self); - if (result === undefined) { - return succeed3(none2()); - } - if (result._tag === "Success") { - return succeed3(some2(result.value)); - } - return succeed3(none2()); -}); -var takeUnsafe = (self) => { - if (self.state._tag === "Done") { - return self.state.exit; - } - if (self.messages.length > 0) { - const message = take(self.messages); - releaseCapacity(self); - return exitSucceed(message); - } else if (self.capacity <= 0 && self.state.offers.size > 0) { - const message = takeOfferUnsafe(self.state.offers); - releaseCapacity(self); - return exitSucceed(message); - } - return; -}; -var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; -var exitFalse = /* @__PURE__ */ exitSucceed(false); -var exitTrue = /* @__PURE__ */ exitSucceed(true); -var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); -var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); -var releaseTakers = (self) => { - if (self.state._tag === "Done" || self.state.takers.size === 0) { - return; - } - for (const taker of self.state.takers) { - self.state.takers.delete(taker); - taker(exitVoid); - if (self.messages.length === 0) { + case "Encoding": + return formatIssue(issue.issue, path); + case "Pointer": + return formatIssue(issue.issue, path + formatPath(issue.path)); + case "Composite": + case "AnyOf": { + if (issue._tag === "Composite" || issue.issues.length > 0) { + return issue.issues.map((issue) => formatIssue(issue, path)).join(` +`); + } + message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue); break; } + default: + message = defaultLeafHook(issue); + break; } -}; -var scheduleReleaseTaker = (self) => { - if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { + return path ? `${message} + at ${path}` : message; +} +function findMessage(issue) { + if (issue._tag === "Pointer") return; - } - self.scheduleRunning = true; - self.dispatcher.scheduleTask(() => { - self.scheduleRunning = false; - releaseTakers(self); - }, 0); -}; -var takeBetweenUnsafe = (self, min, max) => { - if (self.state._tag === "Done") { - return self.state.exit; - } else if (max <= 0 || min <= 0) { - return exitSucceed([]); - } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { - const messages = [takeOfferUnsafe(self.state.offers)]; - releaseCapacity(self); - return exitSucceed(messages); - } - min = Math.min(min, self.capacity || 1); - if (min <= self.messages.length) { - const messages = takeN(self.messages, max); - releaseCapacity(self); - return exitSucceed(messages); - } -}; -var offerRemainingSingle = (self, message) => { - return callback((resume) => { - if (self.state._tag !== "Open") { - return resume(exitFalse); - } - const entry = { - _tag: "Single", - message, - resume - }; - self.state.offers.add(entry); - return sync(() => { - if (self.state._tag === "Open") { - self.state.offers.delete(entry); - } - }); - }); -}; -var takeOfferUnsafe = (offers) => { - const entry = offers.values().next().value; - if (entry._tag === "Single") { - offers.delete(entry); - entry.resume(exitTrue); - return entry.message; - } - const message = entry.remaining[entry.offset++]; - if (entry.offset === entry.remaining.length) { - offers.delete(entry); - entry.resume(exitSucceed([])); - } - return message; -}; -var releaseCapacity = (self) => { - if (self.state._tag === "Done") { - return isDoneCause(self.state.exit.cause); - } else if (self.state.offers.size === 0) { - if (self.state._tag === "Closing" && self.messages.length === 0) { - finalize(self, self.state.exit); - return isDoneCause(self.state.exit.cause); - } - return false; - } - for (const entry of self.state.offers) { - let n = self.capacity - self.messages.length; - if (n <= 0) - break; - else if (entry._tag === "Single") { - append2(self.messages, entry.message); - self.state.offers.delete(entry); - entry.resume(exitTrue); - } else { - for (;entry.offset < entry.remaining.length; entry.offset++) { - if (n === 0) - return false; - append2(self.messages, entry.remaining[entry.offset]); - n--; - } - self.state.offers.delete(entry); - entry.resume(exitSucceed([])); - } - } - return false; -}; -var awaitTake = (self) => callback((resume) => { - if (self.state._tag === "Done") { - return resume(self.state.exit); - } - self.state.takers.add(resume); - return sync(() => { - if (self.state._tag !== "Done") { - self.state.takers.delete(resume); - } - }); -}); -var finalize = (self, exit) => { - if (self.state._tag === "Done") { - return; - } - const openState = self.state; - self.state = { - _tag: "Done", - exit - }; - for (const taker of openState.takers) { - taker(exit); - } - openState.takers.clear(); - for (const awaiter of openState.awaiters) { - awaiter(exit); - } - openState.awaiters.clear(); -}; - -// node_modules/effect/dist/Semaphore.js -var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); -var waitForPermits = (self, n, effect) => callback((resume) => { - if (self.free >= n) - return resume(effect); - const observer = () => { - if (self.free < n) - return; - self.waiters.delete(observer); - resume(effect); - }; - self.waiters.add(observer); - return sync(() => { - self.waiters.delete(observer); - }); -}); - -class SemaphoreImpl { - waiters = /* @__PURE__ */ new Set; - taken = 0; - permits; - constructor(permits) { - this.permits = permits; - } - get free() { - return this.permits - this.taken; - } - take(n) { - const take = suspend(() => { - if (this.free < n) { - return waitForPermits(this, n, take); - } - this.taken += n; - return succeed3(n); - }); - return take; - } - takeIfAvailable(n) { - return suspend(() => { - if (this.free < n) - return succeed3(false); - this.taken += n; - return succeed3(true); - }); - } - releaseUnsafe(fiber, n) { - this.taken -= n; - if (this.waiters.size > 0) { - fiber.currentDispatcher.scheduleTask(() => { - for (const observer of this.waiters) { - if (this.free <= 0) - break; - observer(); - } - }, 0); - } - return this.free; - } - resize(permits) { - return withFiber((fiber) => { - this.permits = permits; - if (this.free < 0) - return void_; - this.releaseUnsafe(fiber, 0); - return void_; - }); - } - release(n) { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); - } - get releaseAll() { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); - } - withPermits(n) { - return (self) => uninterruptibleMask((restore) => { - const acquire = suspend(() => { - if (this.free < n) { - const wait = waitForPermits(this, n, void_); - return flatMap2(restore(wait), () => acquire); - } - this.taken += n; - return onExitPrimitive(restore(self), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); - return acquire; - }); - } - withPermit = /* @__PURE__ */ this.withPermits(1); - withPermitsIfAvailable(n) { - return (self) => uninterruptibleMask((restore) => { - if (this.free < n) - return succeedNone; - this.taken += n; - return onExitPrimitive(restore(asSome(self)), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); - } -} - -// node_modules/effect/dist/Channel.js -var TypeId10 = "~effect/Channel"; -var isChannel = (u) => hasProperty(u, TypeId10); -var ChannelProto = { - [TypeId10]: { - _Env: identity, - _InErr: identity, - _InElem: identity, - _OutErr: identity, - _OutElem: identity - }, - pipe() { - return pipeArguments(this, arguments); - } -}; -var fromTransform = (transform) => { - const self = Object.create(ChannelProto); - self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); - return self; -}; -var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); -var fromPull = (effect) => fromTransform((_, __) => effect); -var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { - const closableScope = forkUnsafe2(scope); - const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); - const pull = yield* onError2(f(upstream, scope, closableScope), onCause); - return onError2(pull, onCause); -})); -var toTransform = (channel) => channel.transform; -var asyncQueue = (scope, f, options) => make8({ - capacity: options?.bufferSize, - strategy: options?.strategy -}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); -var callbackArray = (f, options) => fromTransform((_, scope) => map6(asyncQueue(scope, f, options), takeAll2)); -var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); -var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done3())); -var map7 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { - let i = 0; - return map6(pull, (o) => f(o, i++)); -}))); -var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); -var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done3))))); -var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { - const strategy = options?.haltStrategy ?? "both"; - const queue = yield* bounded(0); - yield* addFinalizer2(forkedScope, shutdown(queue)); - let done = 0; - function onExit(side, cause) { - done++; - if (!isDoneCause(cause)) { - return failCause4(queue, cause); - } - switch (strategy) { - case "both": { - return done === 2 ? failCause4(queue, cause) : void_3; - } - case "left": - case "right": { - return side === strategy ? failCause4(queue, cause) : void_3; - } - case "either": { - return failCause4(queue, cause); - } - } - } - const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); - yield* runSide("left", left, forkUnsafe2(forkedScope)); - yield* runSide("right", right, forkUnsafe2(forkedScope)); - return take2(queue); -}))); -var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { - let stringBuilder = ""; - let midCRLF = false; - let done = none2(); - function splitLinesArray(chunk) { - const chunkBuilder = []; - function pushLine(segment) { - if (stringBuilder.length === 0) { - chunkBuilder.push(segment); - } else { - chunkBuilder.push(stringBuilder + segment); - stringBuilder = ""; - } - } - for (let i = 0;i < chunk.length; i++) { - const str = chunk[i]; - if (str.length !== 0) { - let from = 0; - let indexOfCR = str.indexOf("\r"); - let indexOfLF = str.indexOf(` -`); - if (midCRLF) { - if (indexOfLF === 0) { - from = 1; - indexOfLF = str.indexOf(` -`, from); - } - midCRLF = false; - } - while (indexOfCR !== -1 || indexOfLF !== -1) { - if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { - pushLine(str.substring(from, indexOfLF)); - from = indexOfLF + 1; - indexOfLF = str.indexOf(` -`, from); - } else { - pushLine(str.substring(from, indexOfCR)); - if (str.length === indexOfCR + 1) { - midCRLF = true; - from = str.length; - indexOfCR = -1; - } else { - from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); - indexOfCR = str.indexOf("\r", from); - indexOfLF = str.indexOf(` -`, from); - } - } - } - stringBuilder = stringBuilder + str.substring(from); - } - } - return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; - } - const pullOrFlush = suspend2(() => { - if (done._tag === "Some") { - return done3(done.value); - } - return matchEffect2(upstream, { - onSuccess: loop, - onFailure: failCause3, - onDone: (leftover) => { - done = some2(leftover); - if (stringBuilder.length > 0) { - const last = stringBuilder; - stringBuilder = ""; - midCRLF = false; - return succeed6([last]); - } - return done3(leftover); - } - }); - }); - function loop(chunk) { - const lines = splitLinesArray(chunk); - return lines !== null ? succeed6(lines) : pullOrFlush; - } - return pullOrFlush; -})); -var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); -var unwrap = (channel) => fromTransform((upstream, scope) => { - let pull; - return succeed6(suspend2(() => { - if (pull) - return pull; - return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); - })); -}); -var runWith = (self, f, onHalt) => suspend2(() => { - const scope = makeUnsafe3(); - const makePull = toTransform(self)(done3(), scope); - return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); -}); -var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { - disableYield: true -}))); -var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { - let state = initial(); - return runWith(self, (pull) => whileLoop2({ - while: constTrue, - body: () => pull, - step: (value) => { - state = f(state, value); - } - }), () => succeed6(state)); -})); -var toPullScoped = (self, scope) => toTransform(self)(done3(), scope); - -// node_modules/effect/dist/internal/stream.js -var TypeId11 = "~effect/Stream"; -var streamVariance = { - _R: identity, - _E: identity, - _A: identity -}; -var Stream = function(channel) { - this.channel = channel; -}; -Stream.prototype = { - [TypeId11]: streamVariance, - pipe() { - return pipeArguments(this, arguments); - } -}; -var fromChannel = (channel) => new Stream(channel); - -// node_modules/effect/dist/Sink.js -var TypeId12 = "~effect/Sink"; -var endVoid = /* @__PURE__ */ succeed6([undefined]); -var sinkVariance = { - _A: identity, - _In: identity, - _L: identity, - _E: identity, - _R: identity -}; -var SinkProto = { - [TypeId12]: sinkVariance, - pipe() { - return pipeArguments(this, arguments); - } -}; -var isSink = (u) => hasProperty(u, TypeId12); -var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ - disableYield: true -})), catchDone(succeed6))); -var fromTransform2 = (transform) => { - const self = Object.create(SinkProto); - self.transform = transform; - return self; -}; -var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done3))); -var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { - disableYield: true -}), () => endVoid)); -var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { - discard: true -})); -var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ - disableYield: true -}), catchDone(() => endVoid))); -var unwrap2 = (effect) => fromChannel2(unwrap(map6(effect, toChannel))); - -// node_modules/effect/dist/internal/rcRef.js -var TypeId13 = "~effect/RcRef"; -var stateEmpty = { - _tag: "Empty" -}; -var stateClosed = { - _tag: "Closed" -}; -var variance2 = { - _A: identity, - _E: identity -}; - -class RcRefImpl { - [TypeId13] = variance2; - pipe() { - return pipeArguments(this, arguments); - } - state = stateEmpty; - semaphore = /* @__PURE__ */ makeUnsafe5(1); - acquire; - context; - scope; - idleTimeToLive; - constructor(acquire, context, scope, idleTimeToLive) { - this.acquire = acquire; - this.context = context; - this.scope = scope; - this.idleTimeToLive = idleTimeToLive; - } -} -var make9 = (options) => withFiber2((fiber) => { - const context = fiber.context; - const scope = get(context, Scope); - const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive ? fromInputUnsafe(options.idleTimeToLive) : undefined); - return as2(addFinalizerExit(scope, () => { - const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; - ref.state = stateClosed; - return close2; - }), ref); -}); -var getState = (self) => uninterruptibleMask2(function loop(restore) { - switch (self.state._tag) { - case "Closed": { - return interrupt2; - } - case "Acquired": { - self.state.refCount++; - return self.state.fiber ? as2(interrupt3(self.state.fiber), self.state) : succeed6(self.state); - } - case "Empty": { - const scope = makeUnsafe3(); - return self.semaphore.withPermit(suspend2(() => { - if (self.state._tag !== "Empty") { - return loop(restore); - } - return restore(provideContext2(self.acquire, add(self.context, Scope, scope))).pipe(flatMap3((value) => { - if (self.state._tag === "Closed") { - return interrupt2; - } - const state = { - _tag: "Acquired", - value, - scope, - fiber: undefined, - refCount: 1, - invalidated: false - }; - self.state = state; - return succeed6(state); - }), onExit2((exit) => isFailure3(exit) ? close(scope, exit) : void_3)); - })); - } - } -}); -var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { - const self = self_; - const state = yield* getState(self); - const scope = yield* scope2; - const isFinite2 = self.idleTimeToLive !== undefined && isFinite(self.idleTimeToLive); - yield* addFinalizerExit(scope, () => { - state.refCount--; - if (state.refCount > 0) { - return void_3; - } - if (self.idleTimeToLive === undefined || state.invalidated) { - if (self.state === state) { - self.state = stateEmpty; - } - return close(state.scope, void_2); - } else if (!isFinite2) { - return void_3; - } - state.fiber = sleep2(self.idleTimeToLive).pipe(flatMap3(() => { - if (self.state === state && state.refCount === 0) { - self.state = stateEmpty; - return close(state.scope, void_2); - } - return void_3; - }), ensuring2(sync3(() => { - state.fiber = undefined; - })), runForkWith2(self.context), runIn(self.scope)); - return void_3; - }); - return state.value; -}); - -// node_modules/effect/dist/RcRef.js -var make10 = make9; -var get3 = get2; - -// node_modules/effect/dist/Stream.js -var TypeId14 = "~effect/Stream"; -var isStream = (u) => hasProperty(u, TypeId14); -var fromChannel3 = fromChannel; -var fromPull2 = (pull) => fromChannel3(fromPull(pull)); -var transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))); -var toChannel2 = (stream) => stream.channel; -var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); -var empty4 = /* @__PURE__ */ fromChannel3(empty3); -var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); -var unwrap3 = (effect) => fromChannel3(unwrap(map6(effect, toChannel2))); -var map8 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { - let i = 0; - return fromChannel3(map7(self.channel, map2((o) => f(o, i++)))); -})); -var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); -var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { - let done; - let leftover; - const upstreamWithLeftover = suspend2(() => { - if (leftover !== undefined) { - const chunk = leftover; - leftover = undefined; - return succeed6(chunk); - } - return upstream; - }).pipe(catch_2((error) => { - done = fail4(error); - return done3(); - })); - const pull = map6(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { - leftover = leftover_; - return of(value); - }); - return suspend2(() => done ? done : pull); -}))); -var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { - const decoder = new TextDecoder(options?.encoding); - return map8(self, (chunk) => decoder.decode(chunk, { - stream: true - })); -})); -var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); -var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map6(([a]) => a)))); -var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { - for (let i = 0;i < chunk.length; i++) { - acc.push(chunk[i]); - } - return acc; -}); -var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channel, initial, (acc, arr) => { - for (let i = 0;i < arr.length; i++) { - acc = f(acc, arr[i]); - } - return acc; -})); -var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => { - let i = 0; - return whileLoop2({ - while: () => i < arr.length, - body: () => f(arr[i++]), - step: constVoid - }); -})); -var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); - -// node_modules/effect/dist/FileSystem.js -var TypeId15 = "~effect/FileSystem"; -var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); -var make11 = (impl) => FileSystem.of({ - ...impl, - [TypeId15]: TypeId15, - exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), - readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ - try: () => new TextDecoder(encoding).decode(_), - catch: (cause) => badArgument({ - module: "FileSystem", - method: "readFileString", - description: "invalid encoding", - cause - }) - })), - stream: fnUntraced2(function* (path, options) { - const file = yield* impl.open(path, { - flag: "r" - }); - const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset); - if (offset) { - yield* file.seek(offset, "start"); - } - const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead); - let totalBytesRead = BigInt(0); - const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024)); - const readChunk = file.readAlloc(chunkSize); - return fromPull2(succeed6(flatMap3(suspend2(() => { - if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { - return done3(); - } - return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; - }), match({ - onNone: () => done3(), - onSome: (buf) => { - totalBytesRead += BigInt(buf.length); - return succeed6(of(buf)); - } - })))); - }, unwrap3), - sink: (path, options) => pipe(impl.open(path, { - ...options, - flag: options?.flag ?? "w" - }), map6((file) => forEach3((_) => file.writeAll(_))), unwrap2), - writeFileString: (path, data, options) => flatMap3(try_2({ - try: () => new TextEncoder().encode(data), - catch: (cause) => badArgument({ - module: "FileSystem", - method: "writeFileString", - description: "could not encode string", - cause - }) - }), (_) => impl.writeFile(path, _, options)) -}); -var FileTypeId = "~effect/FileSystem/File"; -class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBackend")) { -} -// node_modules/effect/dist/Ref.js -var TypeId16 = "~effect/Ref"; -var RefProto = { - [TypeId16]: { - _A: identity - }, - ...PipeInspectableProto, - toJSON() { - return { - _id: "Ref", - ref: this.ref - }; - } -}; -var makeUnsafe6 = (value) => { - const self = Object.create(RefProto); - self.ref = make6(value); - return self; -}; -var make12 = (value) => sync3(() => makeUnsafe6(value)); -var get4 = (self) => sync3(() => self.ref.current); -var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { - self.ref.current = f(self.ref.current); -})); -// node_modules/effect/dist/internal/schema/annotations.js -function resolve(ast) { - return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; -} -var STRUCTURAL_ANNOTATION_KEY = "~structural"; -var SENTINELS_ANNOTATION_KEY = "~sentinels"; -var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; -var getExpected = /* @__PURE__ */ memoize((ast) => { - const identifier = resolve(ast)?.identifier; - if (typeof identifier === "string") - return identifier; - return ast.getExpected(getExpected); -}); - -// node_modules/effect/dist/internal/schema/parser.js -var missing = /* @__PURE__ */ Symbol(); -var succeed8 = succeed4; -var missingExit = /* @__PURE__ */ succeed8(missing); -var sameExit = /* @__PURE__ */ succeed8(missing); -var toOption = (value) => value === missing ? none2() : some2(value); -var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed8(option.value); - -// node_modules/effect/dist/SchemaIssue.js -var TypeId17 = "~effect/SchemaIssue/Issue"; -function isIssue(u) { - return hasProperty(u, TypeId17) && u[TypeId17] === TypeId17; -} -function hasInput(issue) { - return Object.hasOwn(issue, "input"); -} - -class IssueNodeImpl { - [TypeId17] = TypeId17; - constructor(input, options) { - if (options?.reportInput === true && input !== missing) { - this.input = input; - } - } -} -var Filter = class extends IssueNodeImpl { - _tag = "Filter"; - filter; - issue; - constructor(filter, issue, input, options) { - super(input, options); - this.filter = filter; - this.issue = issue; - } -}; -var Encoding = class extends IssueNodeImpl { - _tag = "Encoding"; - ast; - issue; - constructor(ast, issue, input, options) { - super(input, options); - this.ast = ast; - this.issue = issue; - } -}; -var Pointer = class extends IssueNodeImpl { - _tag = "Pointer"; - path; - issue; - constructor(path, issue) { - super(); - this.path = path; - this.issue = issue; - } -}; -var MissingKey = class extends IssueNodeImpl { - _tag = "MissingKey"; - annotations; - constructor(annotations) { - super(); - this.annotations = annotations; - } -}; -var UnexpectedKey = class extends IssueNodeImpl { - _tag = "UnexpectedKey"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; - } -}; -var Composite = class extends IssueNodeImpl { - _tag = "Composite"; - ast; - issues; - constructor(ast, issues, input, options) { - super(input, options); - this.ast = ast; - this.issues = issues; - } -}; -var InvalidType = class extends IssueNodeImpl { - _tag = "InvalidType"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; - } -}; -var InvalidValue = class extends IssueNodeImpl { - _tag = "InvalidValue"; - annotations; - constructor(annotations, input, options) { - super(input, options); - this.annotations = annotations; - } -}; -var AnyOf = class extends IssueNodeImpl { - _tag = "AnyOf"; - ast; - issues; - constructor(ast, issues, input, options) { - super(input, options); - this.ast = ast; - this.issues = issues; - } -}; -var OneOf = class extends IssueNodeImpl { - _tag = "OneOf"; - ast; - successes; - constructor(ast, successes, input, options) { - super(input, options); - this.ast = ast; - this.successes = successes; - } -}; -function makeFilterIssue(entry, input, options) { - if (isIssue(entry)) { - return entry; - } - if (typeof entry === "string") { - return new InvalidValue({ - message: entry - }, input, options); - } - const inner = typeof entry.issue === "string" ? new InvalidValue({ - message: entry.issue - }, input, options) : entry.issue; - return new Pointer(entry.path, inner); -} -function makeSingle(out, input, options) { - if (out === undefined) { - return; - } - if (typeof out === "boolean") { - return out ? undefined : new InvalidValue(undefined, input, options); - } - return makeFilterIssue(out, input, options); -} -function normalizeFilterOutput(ast, out, input, options) { - if (Array.isArray(out)) { - if (!isReadonlyArrayNonEmpty(out)) { - return; - } - return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map2(out, (entry) => makeFilterIssue(entry, input, options)), input, options); - } - return makeSingle(out, input, options); -} -var defaultLeafHook = (issue) => { - const message = findMessage(issue); - if (message !== undefined) - return message; - switch (issue._tag) { - case "InvalidType": - return getExpectedMessage(getExpected(issue.ast), issue); - case "InvalidValue": { - const expected = findExpected(issue); - if (expected !== undefined) - return getExpectedMessage(expected, issue); - const input = formatInput(issue); - return input === undefined ? "Expected a valid value" : `Invalid data ${input}`; - } - case "MissingKey": - return "Missing key"; - case "UnexpectedKey": { - const input = formatInput(issue); - return input === undefined ? "Expected no excess property" : `Unexpected key with value ${input}`; - } - case "Forbidden": - return "Forbidden operation"; - case "OneOf": { - const input = formatInput(issue); - return input === undefined ? "Expected exactly one member to match" : `Expected exactly one member to match the input ${input}`; - } - } -}; -var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue); -function formatInput(issue) { - return hasInput(issue) ? format(issue.input) : undefined; -} -function findExpected(issue) { - const expected = issue.annotations?.expected; - return typeof expected === "string" ? expected : undefined; -} -function getExpectedMessage(expected, issue) { - const input = formatInput(issue); - return input === undefined ? `Expected ${expected}` : `Expected ${expected}, got ${input}`; -} -function formatCheck(check) { - const expected = check.annotations?.expected; - if (typeof expected === "string") - return expected; - switch (check._tag) { - case "Filter": - return ""; - case "FilterGroup": - return check.checks.map((check) => formatCheck(check)).join(" & "); - } -} -function makeFormatterDefault() { - return (issue) => formatIssue(issue, ""); -} -var defaultFormatter = /* @__PURE__ */ makeFormatterDefault(); -function formatIssue(issue, path) { - let message; - switch (issue._tag) { - case "Filter": { - const annotated = defaultCheckHook(issue); - if (annotated !== undefined) { - message = annotated; - } else { - if (issue.issue._tag !== "InvalidValue") { - return formatIssue(issue.issue, path); - } - const expected = findExpected(issue.issue); - message = expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue); - } - break; - } - case "Encoding": - return formatIssue(issue.issue, path); - case "Pointer": - return formatIssue(issue.issue, path + formatPath(issue.path)); - case "Composite": - case "AnyOf": { - if (issue._tag === "Composite" || issue.issues.length > 0) { - return issue.issues.map((issue) => formatIssue(issue, path)).join(` -`); - } - message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue); - break; - } - default: - message = defaultLeafHook(issue); - break; - } - return path ? `${message} - at ${path}` : message; -} -function findMessage(issue) { - if (issue._tag === "Pointer") - return; - if (issue._tag === "Encoding") - return findMessage(issue.issue); - const annotations = issue._tag === "Filter" ? issue.filter.annotations : ("annotations" in issue) ? issue.annotations : issue.ast.annotations; - const message = annotations?.[issue._tag === "MissingKey" ? "messageMissingKey" : issue._tag === "UnexpectedKey" ? "messageUnexpectedKey" : "message"]; - if (typeof message === "string") - return message; -} - -// node_modules/effect/dist/internal/schema/cause.js -function getSchemaIssue(cause) { - let issue; - for (const reason of cause.reasons) { - if (!isFailReason2(reason) || !isIssue(reason.error)) { - return; - } - issue ??= reason.error; + if (issue._tag === "Encoding") + return findMessage(issue.issue); + const annotations = issue._tag === "Filter" ? issue.filter.annotations : ("annotations" in issue) ? issue.annotations : issue.ast.annotations; + const message = annotations?.[issue._tag === "MissingKey" ? "messageMissingKey" : issue._tag === "UnexpectedKey" ? "messageUnexpectedKey" : "message"]; + if (typeof message === "string") + return message; +} + +// node_modules/effect/dist/internal/schema/cause.js +function getSchemaIssue(cause) { + let issue; + for (const reason of cause.reasons) { + if (!isFailReason2(reason) || !isIssue(reason.error)) { + return; + } + issue ??= reason.error; } return issue; } @@ -5933,87 +4784,185 @@ function getSchemaIssueOrThrow(cause, message) { } // node_modules/effect/dist/SchemaGetter.js -var Getter = class extends Class { - run; - constructor(run) { - super(); - this.run = run; +var makeGetter = (fields) => Object.assign(Object.create(Prototype), fields); +var passthrough_ = /* @__PURE__ */ makeGetter({ + _tag: "Passthrough" +}); +function passthrough() { + return passthrough_; +} +function transform(f) { + return makeGetter({ + _tag: "Transform", + transform: f + }); +} +function transformEffect(f) { + return makeGetter({ + _tag: "TransformEffect", + transform: f + }); +} +function String2() { + return transform(globalThis.String); +} +function Number3() { + return transform(globalThis.Number); +} +function encodeBase642() { + return transform(encodeBase64); +} +function decodeBase642() { + return transformEffect((input, options) => mapErrorEager2(fromResult2(decodeBase64(input)), () => new InvalidValue({ + expected: "a valid Base64 string" + }, input, options))); +} + +// node_modules/effect/dist/ByteSize.js +var bigint03 = /* @__PURE__ */ BigInt(0); +var bigint12 = /* @__PURE__ */ BigInt(1); +var decimalBase = /* @__PURE__ */ BigInt(1000); +var binaryBase = /* @__PURE__ */ BigInt(1024); +var decimalUnits = [{ + symbol: "B", + factor: bigint12, + names: ["B", "byte", "bytes"] +}, { + symbol: "kB", + factor: decimalBase, + names: ["kB", "kilobyte", "kilobytes"] +}, { + symbol: "MB", + factor: decimalBase ** /* @__PURE__ */ BigInt(2), + names: ["MB", "megabyte", "megabytes"] +}, { + symbol: "GB", + factor: decimalBase ** /* @__PURE__ */ BigInt(3), + names: ["GB", "gigabyte", "gigabytes"] +}, { + symbol: "TB", + factor: decimalBase ** /* @__PURE__ */ BigInt(4), + names: ["TB", "terabyte", "terabytes"] +}, { + symbol: "PB", + factor: decimalBase ** /* @__PURE__ */ BigInt(5), + names: ["PB", "petabyte", "petabytes"] +}, { + symbol: "EB", + factor: decimalBase ** /* @__PURE__ */ BigInt(6), + names: ["EB", "exabyte", "exabytes"] +}, { + symbol: "ZB", + factor: decimalBase ** /* @__PURE__ */ BigInt(7), + names: ["ZB", "zettabyte", "zettabytes"] +}, { + symbol: "YB", + factor: decimalBase ** /* @__PURE__ */ BigInt(8), + names: ["YB", "yottabyte", "yottabytes"] +}, { + symbol: "RB", + factor: decimalBase ** /* @__PURE__ */ BigInt(9), + names: ["RB", "ronnabyte", "ronnabytes"] +}, { + symbol: "QB", + factor: decimalBase ** /* @__PURE__ */ BigInt(10), + names: ["QB", "quettabyte", "quettabytes"] +}]; +var binaryUnits = [decimalUnits[0], { + symbol: "KiB", + factor: binaryBase, + names: ["KiB", "kibibyte", "kibibytes"] +}, { + symbol: "MiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(2), + names: ["MiB", "mebibyte", "mebibytes"] +}, { + symbol: "GiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(3), + names: ["GiB", "gibibyte", "gibibytes"] +}, { + symbol: "TiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(4), + names: ["TiB", "tebibyte", "tebibytes"] +}, { + symbol: "PiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(5), + names: ["PiB", "pebibyte", "pebibytes"] +}, { + symbol: "EiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(6), + names: ["EiB", "exbibyte", "exbibytes"] +}, { + symbol: "ZiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(7), + names: ["ZiB", "zebibyte", "zebibytes"] +}, { + symbol: "YiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(8), + names: ["YiB", "yobibyte", "yobibytes"] +}]; +var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; +var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); +var make5 = (value) => value; +var invalid2 = (message) => { + throw new Error(`Invalid ByteSize: ${message}`); +}; +var fromNumber = (input) => { + if (!Number.isSafeInteger(input) || input < 0) { + return invalid2(`expected a non-negative safe integer, received ${input}`); } - map(f) { - return new Getter((oe, options) => this.run(oe, options).pipe(mapEager2(map(f)))); + return make5(BigInt(input)); +}; +var fromStringUnsafe = (input) => { + const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); + if (match === null) + return invalid2(`unsupported syntax ${JSON.stringify(input)}`); + const unit = unitsByName.get(match[3]); + if (unit === undefined) + return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); + const fraction = match[2] ?? ""; + const scale = BigInt(10) ** BigInt(fraction.length); + const numerator = BigInt(match[1] + fraction) * unit.factor; + if (numerator % scale !== bigint03) { + return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); } - compose(other) { - if (isPassthrough(this)) { - return other; - } - if (isPassthrough(other)) { - return this; - } - return new Getter((oe, options) => this.run(oe, options).pipe(flatMapEager2((ot) => other.run(ot, options)))); + return make5(numerator / scale); +}; +var fromInputUnsafe2 = (input) => { + switch (typeof input) { + case "bigint": + if (input < bigint03) + return invalid2(`expected a non-negative bigint, received ${input}`); + return make5(input); + case "number": + return fromNumber(input); + case "string": + return fromStringUnsafe(input); } + return invalid2(`unsupported input ${input}`); }; -var passthrough_ = /* @__PURE__ */ new Getter(succeed6); -function isPassthrough(getter) { - return getter.run === passthrough_.run; -} -function passthrough() { - return passthrough_; -} -function onSome(f) { - return new Getter((oe, options) => isNone2(oe) ? succeedNone2 : f(oe.value, options)); -} -function transform(f) { - return transformOptional(map(f)); -} -function transformEffect(f) { - return onSome((e, options) => f(e, options).pipe(mapEager2(some2))); -} -function transformOptional(f) { - return new Getter((oe) => succeed6(f(oe))); -} -function withDefault(defaultValue) { - return new Getter((o) => { - const filtered = filter(o, isNotUndefined); - return isSome2(filtered) ? succeed6(filtered) : mapEager2(defaultValue, some2); - }); -} -function String2() { - return transform(globalThis.String); -} -function Number3() { - return transform(globalThis.Number); -} -function encodeBase642() { - return transform(encodeBase64); -} -function decodeBase642() { - return transformEffect((input, options) => mapErrorEager2(fromResult2(decodeBase64(input)), () => new InvalidValue({ - expected: "a valid Base64 string" - }, input, options))); -} +var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); // node_modules/effect/dist/SchemaTransformation.js -var TypeId18 = "~effect/SchemaTransformation/Transformation"; -var Transformation = class { - [TypeId18] = TypeId18; +var TypeId8 = "~effect/SchemaTransformation/Transformation"; +var Transformation = class extends Class { + [TypeId8] = TypeId8; _tag = "Transformation"; decode; encode; constructor(decode, encode) { + super(); this.decode = decode; this.encode = encode; } flip() { return new Transformation(this.encode, this.decode); } - compose(other) { - return new Transformation(this.decode.compose(other.decode), other.encode.compose(this.encode)); - } }; function isTransformation(u) { - return hasProperty(u, TypeId18) && u[TypeId18] === TypeId18; + return hasProperty(u, TypeId8) && u[TypeId8] === TypeId8; } -var make13 = (options) => { +var makeTransformation = (options) => { if (isTransformation(options)) { return options; } @@ -6070,10 +5019,10 @@ var Context = class { this.annotations = annotations; } }; -var TypeId19 = "~effect/Schema"; +var TypeId9 = "~effect/Schema"; class ASTNodeImpl { - [TypeId19] = TypeId19; + [TypeId9] = TypeId9; annotations; checks; encoding; @@ -6239,1379 +5188,2002 @@ var Arrays = class extends ASTNodeImpl { throw new Error("A required element cannot follow an optional element. ts(1257)"); } } - if (hasOptional && rest.length > 1) { - throw new Error("A required element cannot follow an optional element. ts(1257)"); - } - for (let i = 1;i < rest.length; i++) { - if (isOptional(rest[i])) { - throw new Error("An optional element cannot follow a rest element. ts(1266)"); - } + if (hasOptional && rest.length > 1) { + throw new Error("A required element cannot follow an optional element. ts(1257)"); + } + for (let i = 1;i < rest.length; i++) { + if (isOptional(rest[i])) { + throw new Error("An optional element cannot follow a rest element. ts(1266)"); + } + } + } + getParser(compile, compileField = compile) { + const ast = this; + let elements; + let rest; + const elementLen = ast.elements.length; + const tailLen = Math.max(0, ast.rest.length - 1); + function getParser(tailThreshold, index) { + if (index < elementLen) { + return elements[index]; + } else if (index >= tailThreshold) { + return rest[index - tailThreshold + 1]; + } + return rest[0]; + } + return fnUntracedEager2(function* (input, options) { + if (input === missing) { + return missing; + } + if (!Array.isArray(input)) { + return yield* fail6(new InvalidType(ast, input, options)); + } + if (!elements) { + elements = ast.elements.map((ast) => ({ + ast, + parser: compileField(ast) + })); + rest = ast.rest.map((ast) => ({ + ast, + parser: compileField(ast) + })); + } + const len = input.length; + const state = { + ast, + getParser, + input, + len, + tailThreshold: Math.max(elementLen, len - tailLen), + output: new globalThis.Array(len), + issues: undefined, + options + }; + const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen); + const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); + const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, { + concurrency, + end + }); + if (eff) + yield* eff; + if (ast.rest.length === 0 && len > elementLen) { + for (let i = elementLen;i <= len - 1; i++) { + const unexpected = new UnexpectedKey(ast, input[i], options); + const issue = new Pointer([i], unexpected); + if (options.errors === "all") { + if (state.issues) + state.issues.push(issue); + else + state.issues = [issue]; + } else { + return yield* fail6(new Composite(ast, [issue], input, options)); + } + } + } + if (state.issues) { + return yield* fail6(new Composite(ast, state.issues, input, options)); + } + return state.output; + }); + } + _rebuild(recur, checks, encodingChecks) { + const elements = mapOrSame(this.elements, recur); + const rest = mapOrSame(this.rest, recur); + return elements === this.elements && rest === this.rest && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Arrays(this.isMutable, elements, rest, this.annotations, checks, undefined, this.context, encodingChecks); + } + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks); + } + getExpected() { + return "array"; + } +}; +function stepArray(s, item, exit, i) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, i, exit); + } + const value = exit === sameExit ? item : exit[args]; + if (value !== missing) { + s.output[i] = value; + } else { + const p = s.getParser(s.tailThreshold, i); + if (isOptional(p.ast)) + return; + const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); + } + } +} +var parseArrayOptions = { + onItem(s, item, i) { + const value = i < s.len ? item : missing; + return s.getParser(s.tailThreshold, i).parser(value, s.options); + }, + step: stepArray +}; +var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); +var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); +var wrapPropertyKeyIssue = (s, ast, key, exit) => { + if (exit.cause.reasons.length === 0) { + return exit; + } + const issue = getSchemaIssue(exit.cause); + if (issue === undefined) { + return failCause2(map4(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); + } + const pointer = new Pointer([key], issue); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(pointer); + else + s.issues = [pointer]; + } else { + return fail5(new Composite(ast, [pointer], s.input, s.options)); + } +}; +var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; +function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) { + let stringKeys; + let symbolKeys; + function go(parameter) { + switch (parameter._tag) { + case "String": + case "TemplateLiteral": + return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== undefined); + case "Number": + return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== undefined); + case "Symbol": + return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== undefined); + case "Union": + return [...new Set(parameter.types.flatMap(go))]; + default: + return []; + } + } + return go(parameterFromPropertyKey(toEncoded(parameter))); +} +var PropertySignature = class { + name; + type; + constructor(name, type) { + this.name = name; + this.type = type; + } +}; +function isIndexSignatureParameterSide(ast) { + switch (ast._tag) { + case "String": + case "Number": + case "Symbol": + case "TemplateLiteral": + return true; + case "Union": + return ast.types.every(isIndexSignatureParameterSide); + default: + return false; + } +} +function isIndexSignatureParameterEncodedSide(ast) { + const encoded = getLastEncoding(ast); + switch (encoded._tag) { + case "String": + case "Number": + case "Symbol": + case "TemplateLiteral": + return true; + case "Union": + return encoded.types.every(isIndexSignatureParameterEncodedSide); + default: + return false; + } +} +function isIndexSignatureParameter(ast) { + return isIndexSignatureParameterSide(ast) && isIndexSignatureParameterEncodedSide(ast); +} +var IndexSignature = class { + parameter; + type; + constructor(parameter, type) { + if (!isIndexSignatureParameter(parameter)) { + throw new Error(`Invalid index signature parameter ${parameter._tag}`); + } + this.parameter = parameter; + this.type = type; + if (isOptional(type) && !containsUndefined(type)) { + throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead."); + } + } +}; +var Objects = class extends ASTNodeImpl { + _tag = "Objects"; + propertySignatures; + indexSignatures; + encodingChecks; + constructor(propertySignatures, indexSignatures, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.propertySignatures = propertySignatures; + this.indexSignatures = indexSignatures; + this.encodingChecks = encodingChecks; + const seen = new Set; + const duplicates = []; + for (const propertySignature of propertySignatures) { + const name = propertySignature.name; + if (seen.has(name)) { + duplicates.push(name); + } else { + seen.add(name); + } + } + if (duplicates.length > 0) { + throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); } } - getParser(compile, compileConstructorDefault = compile) { + getParser(compile, compileField = compile) { const ast = this; - let elements; - let rest; - const elementLen = ast.elements.length; - const tailLen = Math.max(0, ast.rest.length - 1); - function getParser(tailThreshold, index) { - if (index < elementLen) { - return elements[index]; - } else if (index >= tailThreshold) { - return rest[index - tailThreshold + 1]; - } - return rest[0]; + const expectedKeys = []; + for (const ps of ast.propertySignatures) { + expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name); } - return fnUntracedEager2(function* (input, options) { + const hasProperties = expectedKeys.length; + const indexCount = ast.indexSignatures.length; + let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : undefined; + if (!hasProperties && !indexCount) { + return fromRefinement(ast, isNotNullish); + } + let properties; + let indexes; + const finishIndex = (s, key, k2, inputValue, exitValue) => { + if (exitValue._tag === "Failure") { + return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_2; + } + const value = exitValue === sameExit ? inputValue : exitValue[args]; + if (k2 !== missing && value !== missing) { + if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) + return void_2; + assignProperty(s.out, k2, value); + } + return void_2; + }; + const parseIndex = (s, key, index, exitKey) => { + if (!exitKey) { + const eff = index.parserKey(key, s.options); + if (!effectIsExit(eff)) { + return flatMap3(exit2(eff), (exit) => parseIndex(s, key, index, exit)); + } + exitKey = eff; + } + if (exitKey._tag === "Failure") { + return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_2; + } + const k2 = exitKey === sameExit ? key : exitKey[args]; + const inputValue = s.input[key]; + const result = index.parserValue(inputValue, s.options); + return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, k2, inputValue, exit)); + }; + const parseStringIndex = (s, key, index) => { + const inputValue = s.input[key]; + const result = index.parserValue(inputValue, s.options); + return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, key, inputValue, exit)); + }; + const parseIndexes = indexCount ? iterateConcurrent()({ + onItem: (s, [key, index]) => index.is.parameter === string2 ? parseStringIndex(s, key, index) : parseIndex(s, key, index), + step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined + }) : undefined; + const compileMembers = () => { + if (!properties) { + properties = ast.propertySignatures.map((ps) => ({ + parser: compileField(ps.type), + name: ps.name, + type: ps.type + })); + indexes = indexCount ? ast.indexSignatures.map((is) => ({ + is, + parserKey: compile(parameterFromPropertyKey(is.parameter)), + parserValue: compileField(is.type) + })) : undefined; + } + return properties; + }; + const fallback = fnUntracedEager2(function* (input, options) { if (input === missing) { return missing; } - if (!Array.isArray(input)) { + if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { return yield* fail6(new InvalidType(ast, input, options)); } - if (!elements) { - elements = ast.elements.map((ast) => ({ - ast, - parser: compileConstructorDefault(ast) - })); - rest = ast.rest.map((ast) => ({ - ast, - parser: compileConstructorDefault(ast) - })); - } - const len = input.length; + compileMembers(); + const record = input; + const out = {}; const state = { ast, - getParser, - input, - len, - tailThreshold: Math.max(elementLen, len - tailLen), - output: new globalThis.Array(len), + input: record, + out, issues: undefined, options }; - const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen); + const errorsAllOption = options.errors === "all"; + const onExcessPropertyError = options.onExcessProperty === "error"; const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); - const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, { - concurrency, - end - }); - if (eff) - yield* eff; - if (ast.rest.length === 0 && len > elementLen) { - for (let i = elementLen;i <= len - 1; i++) { - const unexpected = new UnexpectedKey(ast, input[i], options); - const issue = new Pointer([i], unexpected); - if (options.errors === "all") { - if (state.issues) - state.issues.push(issue); - else - state.issues = [issue]; - } else { - return yield* fail6(new Composite(ast, [issue], input, options)); + const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : undefined; + if (onExcessPropertyError) { + expectedKeysSet ??= new Set(expectedKeys); + const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet; + if (indexKeys) { + for (const keys of indexKeys) { + for (const key of keys) + coveredKeys.add(key); + } + } + const inputKeys = Reflect.ownKeys(record); + for (let i = 0;i < inputKeys.length; i++) { + const key = inputKeys[i]; + if (!coveredKeys.has(key)) { + const unexpected = new UnexpectedKey(ast, record[key], options); + const issue = new Pointer([key], unexpected); + if (errorsAllOption) { + if (state.issues) { + state.issues.push(issue); + } else { + state.issues = [issue]; + } + continue; + } else { + return yield* fail6(new Composite(ast, [issue], input, options)); + } + } + } + } + if (hasProperties) { + const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { + concurrency + }); + if (eff) + yield* eff; + } + if (indexCount && concurrency === 1) { + for (let i = 0;i < indexCount; i++) { + const index = indexes[i]; + const parse = index.is.parameter === string2 ? parseStringIndex : parseIndex; + const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); + for (let j = 0;j < keys.length; j++) { + const eff = parse(state, keys[j], index); + if (!effectIsExit(eff)) + yield* eff; + else if (eff._tag === "Failure") + return yield* eff; + } + } + } else if (parseIndexes) { + const keyPairs = empty(); + for (let i = 0;i < indexCount; i++) { + const index = indexes[i]; + const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); + for (let j = 0;j < keys.length; j++) { + keyPairs.push([keys[j], index]); } } + const eff = parseIndexes(state, keyPairs, { + concurrency + }); + if (eff) + yield* eff; } if (state.issues) { return yield* fail6(new Composite(ast, state.issues, input, options)); } - return state.output; + return out; }); + if (indexCount) + return fallback; + const resume = (state, index, pending) => { + const property = properties[index]; + return flatMap3(exit2(pending), (exit) => { + const terminal = stepProperty(state, property, exit); + if (terminal) + return terminal; + const done = () => succeed7(state.out); + const eff = parseProperties(state, properties.slice(index + 1)); + return eff ? flatMapEager2(eff, done) : done(); + }); + }; + return (input, options) => { + if (input === missing) + return missingExit; + if (options.errors === "all" || options.onExcessProperty !== undefined || options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1) { + return fallback(input, options); + } + if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { + return fail6(new InvalidType(ast, input, options)); + } + const props = compileMembers(); + const record = input; + const out = {}; + const state = { + ast, + input: record, + out, + issues: undefined, + options + }; + try { + for (let index = 0;index < props.length; index++) { + const property = props[index]; + const name = property.name; + const hasKey = hasPropertySignature(record, name); + const value = hasKey ? record[name] : missing; + const exit = property.parser(value, options); + if (!effectIsExit(exit)) { + return resume(state, index, exit); + } + if (exit === sameExit) { + if (hasKey) + assignProperty(out, name, value); + continue; + } + const terminal = stepProperty(state, property, exit); + if (terminal) + return terminal; + } + } catch (error) { + return die3(error); + } + return succeed7(out); + }; } - _rebuild(recur, checks, encodingChecks) { - const elements = mapOrSame(this.elements, recur); - const rest = mapOrSame(this.rest, recur); - return elements === this.elements && rest === this.rest && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Arrays(this.isMutable, elements, rest, this.annotations, checks, undefined, this.context, encodingChecks); - } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks); + _rebuild(recur, recurParameter, checks, encodingChecks) { + const props = mapOrSame(this.propertySignatures, (ps) => { + const t = recur(ps.type); + return t === ps.type ? ps : new PropertySignature(ps.name, t); + }); + const indexes = mapOrSame(this.indexSignatures, (is) => { + const p = recurParameter(is.parameter); + const t = recur(is.type); + return p === is.parameter && t === is.type ? is : new IndexSignature(p, t); + }); + return props === this.propertySignatures && indexes === this.indexSignatures && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Objects(props, indexes, this.annotations, checks, undefined, this.context, encodingChecks); } flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks); + return this._rebuild(recur, recur, this.encodingChecks, this.checks); } - getExpected() { - return "array"; + recur(recur, recurParameter = recur) { + return this._rebuild(recur, recurParameter, this.checks, this.encodingChecks); } -}; -var parseArrayOptions = { - onItem(s, item, i) { - const value = i < s.len ? item : missing; - return s.getParser(s.tailThreshold, i).parser(value, s.options); - }, - step(s, item, exit, i) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, i, exit); - } - const value = exit === sameExit ? item : exit[args]; - if (value !== missing) { - s.output[i] = value; - } else { - const p = s.getParser(s.tailThreshold, i); - if (isOptional(p.ast)) - return; - const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); - } - } + getExpected() { + if (this.propertySignatures.length === 0 && this.indexSignatures.length === 0) + return "object | array"; + return "object"; } }; -var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); -var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); -var wrapPropertyKeyIssue = (s, ast, key, exit) => { - if (exit.cause.reasons.length === 0) { - return exit; - } - const issue = getSchemaIssue(exit.cause); - if (issue === undefined) { - return failCause2(map5(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); +function stepProperty(s, p, exit) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, p.name, exit); } - const pointer = new Pointer([key], issue); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(pointer); - else - s.issues = [pointer]; - } else { - return fail4(new Composite(ast, [pointer], s.input, s.options)); + if (exit === sameExit) + return; + const value = exit[args]; + if (value !== missing) { + assignProperty(s.out, p.name, value); + return; } -}; -var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; -function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) { - let stringKeys; - let symbolKeys; - function go(parameter) { - switch (parameter._tag) { - case "String": - case "TemplateLiteral": - return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== undefined); - case "Number": - return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== undefined); - case "Symbol": - return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== undefined); - case "Union": - return [...new Set(parameter.types.flatMap(go))]; - default: - return []; + delete s.out[p.name]; + if (!isOptional(p.type)) { + const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + return; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); } } - return go(parameterFromPropertyKey(toEncoded(parameter))); } -var PropertySignature = class { - name; - type; - constructor(name, type) { - this.name = name; - this.type = type; - } +var parsePropertiesOptions = { + onItem(s, p) { + if (!hasPropertySignature(s.input, p.name)) { + return p.parser(missing, s.options); + } + const value = s.input[p.name]; + assignProperty(s.out, p.name, value); + return p.parser(value, s.options); + }, + step: stepProperty }; -function isIndexSignatureParameterSide(ast) { +var parseProperties = /* @__PURE__ */ iterateEager()(parsePropertiesOptions); +var parsePropertiesConcurrent = /* @__PURE__ */ iterateConcurrent()(parsePropertiesOptions); +function combineChecks(a, b) { + if (!a) + return b; + if (!b) + return a; + return [...a, ...b]; +} +function struct(fields, checks, annotations) { + return new Objects(Reflect.ownKeys(fields).map((key) => { + return new PropertySignature(key, fields[key].ast); + }), [], annotations, checks); +} +function getAST(self) { + return self.ast; +} +function tuple(elements, checks = undefined) { + return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks); +} +function union(members, options, checks) { + return new Union(members.map(getAST), options, undefined, checks); +} +var toCandidate = /* @__PURE__ */ memoizeIdempotent((ast) => { + while (true) { + if (isSuspend(ast)) + return unknown; + const encoding = ast.encoding; + if (!encoding) { + return ast.recur?.(toCandidate, identity) ?? ast; + } + if (encoding.some((link) => link.transformation._tag === "Middleware" && link.transformation.decode !== identity)) + return unknown; + ast = encoding[encoding.length - 1].to; + } +}); +function getCandidateTypes(ast) { switch (ast._tag) { + case "Null": + return ["null"]; + case "Undefined": + return ["undefined"]; case "String": - case "Number": - case "Symbol": case "TemplateLiteral": - return true; - case "Union": - return ast.types.every(isIndexSignatureParameterSide); - default: - return false; - } -} -function isIndexSignatureParameterEncodedSide(ast) { - const encoded = getLastEncoding(ast); - switch (encoded._tag) { - case "String": + return ["string"]; case "Number": + return ["number"]; + case "Boolean": + return ["boolean"]; case "Symbol": - case "TemplateLiteral": - return true; + case "UniqueSymbol": + return ["symbol"]; + case "BigInt": + return ["bigint"]; + case "Arrays": + return ["array"]; + case "ObjectKeyword": + return ["object", "array", "function"]; + case "Objects": + return ast.propertySignatures.length || ast.indexSignatures.length ? ["object"] : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; + case "Enum": + return Array.from(new Set(ast.enums.map(([, v]) => typeof v))); + case "Literal": + return [typeof ast.literal]; case "Union": - return encoded.types.every(isIndexSignatureParameterEncodedSide); + return Array.from(new Set(ast.types.flatMap(getCandidateTypes))); default: - return false; + return ["null", "undefined", "string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; } } -function isIndexSignatureParameter(ast) { - return isIndexSignatureParameterSide(ast) && isIndexSignatureParameterEncodedSide(ast); -} -var IndexSignature = class { - parameter; - type; - constructor(parameter, type) { - if (!isIndexSignatureParameter(parameter)) { - throw new Error(`Invalid index signature parameter ${parameter._tag}`); - } - this.parameter = parameter; - this.type = type; - if (isOptional(type) && !containsUndefined(type)) { - throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead."); +function collectSentinels(ast) { + switch (ast._tag) { + default: + return []; + case "Declaration": { + const s = ast.annotations?.[SENTINELS_ANNOTATION_KEY]; + return Array.isArray(s) ? s : []; } - } -}; -var Objects = class extends ASTNodeImpl { - _tag = "Objects"; - propertySignatures; - indexSignatures; - encodingChecks; - constructor(propertySignatures, indexSignatures, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.propertySignatures = propertySignatures; - this.indexSignatures = indexSignatures; - this.encodingChecks = encodingChecks; - const seen = new Set; - const duplicates = []; - for (const propertySignature of propertySignatures) { - const name = propertySignature.name; - if (seen.has(name)) { - duplicates.push(name); + case "Objects": + return ast.propertySignatures.flatMap((ps) => { + const type = ps.type; + if (!isOptional(type)) { + if (isLiteral(type)) { + return [{ + key: ps.name, + literal: type.literal + }]; + } + if (isUniqueSymbol(type)) { + return [{ + key: ps.name, + literal: type.symbol + }]; + } + } + return []; + }); + case "Arrays": + return ast.elements.flatMap((e, i) => { + if (!isOptional(e)) { + if (isLiteral(e)) { + return [{ + key: i, + literal: e.literal + }]; + } + if (isUniqueSymbol(e)) { + return [{ + key: i, + literal: e.symbol + }]; + } + } + return []; + }); + case "Union": { + if (ast.types.length === 0) + return []; + const members = ast.types.map((type) => collectSentinels(toCandidate(type))); + return members[0].filter((s) => members.every((sentinels) => sentinels.some((o) => o.key === s.key && o.literal === s.literal))); + } + case "Suspend": + return collectSentinels(ast.thunk()); + } +} +var candidateIndexCache = /* @__PURE__ */ new WeakMap; +var emptyCandidates = /* @__PURE__ */ Object.freeze([]); +var hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : (key in input); +function getIndex(types) { + let index = candidateIndexCache.get(types); + if (index) + return index; + let bySentinel; + let sentinelCandidateCount = 0; + let otherwise; + let literalCandidates; + let onlyLiterals = true; + for (let i = 0;i < types.length; i++) { + const a = types[i]; + const encoded = toCandidate(a); + if (isNever2(encoded)) + continue; + if (onlyLiterals) { + if (isLiteral(encoded) || isUniqueSymbol(encoded)) { + literalCandidates ??= new Map; + const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol; + let arr = literalCandidates.get(literal); + if (!arr) + literalCandidates.set(literal, arr = []); + arr.push(a); } else { - seen.add(name); + onlyLiterals = false; } } - if (duplicates.length > 0) { - throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); + const sentinels = collectSentinels(encoded); + if (sentinels.length) { + bySentinel ??= new Map; + sentinelCandidateCount++; + for (const { + key, + literal + } of sentinels) { + let entry = bySentinel.get(key); + if (!entry) + bySentinel.set(key, entry = [new Map, new Set]); + entry[1].add(i); + let indexes = entry[0].get(literal); + if (!indexes) + entry[0].set(literal, indexes = new Set); + indexes.add(i); + } + } else { + otherwise ??= {}; + const candidateTypes = getCandidateTypes(encoded); + for (const t of candidateTypes) + (otherwise[t] ??= []).push(i); } } - getParser(compile, compileConstructorDefault = compile) { - const ast = this; - const expectedKeys = []; - for (const ps of ast.propertySignatures) { - expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name); - } - const hasProperties = expectedKeys.length; - const indexCount = ast.indexSignatures.length; - let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : undefined; - if (!hasProperties && !indexCount) { - return fromRefinement(ast, isNotNullish); + if (onlyLiterals && literalCandidates) { + literalCandidates.forEach(Object.freeze); + index = (input) => literalCandidates.get(input) ?? emptyCandidates; + } else if (bySentinel?.size === 1 && !otherwise) { + const [key, [byValue]] = bySentinel.entries().next().value; + const candidates = byValue; + for (const [literal, indexes] of byValue) { + candidates.set(literal, Object.freeze(Array.from(indexes, (index) => types[index]))); } - let properties; - let indexes; - const finishIndex = (s, key, k2, inputValue, exitValue) => { - if (exitValue._tag === "Failure") { - return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_2; - } - const value = exitValue === sameExit ? inputValue : exitValue[args]; - if (k2 !== missing && value !== missing) { - if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) - return void_2; - assignProperty(s.out, k2, value); - } - return void_2; - }; - const parseIndex = (s, key, index, exitKey) => { - if (!exitKey) { - const eff = index.parserKey(key, s.options); - if (!effectIsExit(eff)) { - return flatMap3(exit2(eff), (exit) => parseIndex(s, key, index, exit)); - } - exitKey = eff; - } - if (exitKey._tag === "Failure") { - return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_2; - } - const k2 = exitKey === sameExit ? key : exitKey[args]; - const inputValue = s.input[key]; - const result = index.parserValue(inputValue, s.options); - return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, k2, inputValue, exit)); - }; - const parseStringIndex = (s, key, index) => { - const inputValue = s.input[key]; - const result = index.parserValue(inputValue, s.options); - return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, key, inputValue, exit)); - }; - const parseIndexes = indexCount ? iterateConcurrent()({ - onItem: (s, [key, index]) => index.is.parameter === string2 ? parseStringIndex(s, key, index) : parseIndex(s, key, index), - step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined - }) : undefined; - const compileMembers = () => { - if (!properties) { - properties = ast.propertySignatures.map((ps) => ({ - parser: compileConstructorDefault(ps.type), - name: ps.name, - type: ps.type - })); - indexes = indexCount ? ast.indexSignatures.map((is) => ({ - is, - parserKey: compile(parameterFromPropertyKey(is.parameter)), - parserValue: compileConstructorDefault(is.type) - })) : undefined; + index = (input, isConstructor) => { + if (isObjectKeyword(input)) { + const value = hasPropertySignature(input, key) ? input[key] : undefined; + if (value !== undefined) + return candidates.get(value) ?? emptyCandidates; + if (isConstructor) + return types; } - return properties; + return emptyCandidates; }; - const fallback = fnUntracedEager2(function* (input, options) { - if (input === missing) { - return missing; - } - if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { - return yield* fail6(new InvalidType(ast, input, options)); + } else if (bySentinel) { + let commonSentinel; + for (const entry of bySentinel) { + if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) { + commonSentinel = entry; } - compileMembers(); - const record = input; - const out = {}; - const state = { - ast, - input: record, - out, - issues: undefined, - options - }; - const errorsAllOption = options.errors === "all"; - const onExcessPropertyError = options.onExcessProperty === "error"; - const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); - const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : undefined; - if (onExcessPropertyError) { - expectedKeysSet ??= new Set(expectedKeys); - const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet; - if (indexKeys) { - for (const keys of indexKeys) { - for (const key of keys) - coveredKeys.add(key); - } + } + index = (input, isConstructor) => { + const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; + const base = otherwise?.[runtimeType] ?? emptyCandidates; + if (!isObjectKeyword(input)) + return base.map((i) => types[i]); + const selected = new Set(base); + let directKey; + if (commonSentinel) { + const [key, [byValue]] = commonSentinel; + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + if (!match) + return base.map((i) => types[i]); + for (const i of match) + selected.add(i); + directKey = key; } - const inputKeys = Reflect.ownKeys(record); - for (let i = 0;i < inputKeys.length; i++) { - const key = inputKeys[i]; - if (!coveredKeys.has(key)) { - const unexpected = new UnexpectedKey(ast, record[key], options); - const issue = new Pointer([key], unexpected); - if (errorsAllOption) { - if (state.issues) { - state.issues.push(issue); - } else { - state.issues = [issue]; - } - continue; - } else { - return yield* fail6(new Composite(ast, [issue], input, options)); + } + if (directKey === undefined) { + for (const [key, [byValue, all]] of bySentinel) { + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + if (match) { + for (const i of match) + selected.add(i); } + } else if (isConstructor) { + for (const i of all) + selected.add(i); } } } - if (hasProperties) { - const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { - concurrency - }); - if (eff) - yield* eff; - } - if (indexCount && concurrency === 1) { - for (let i = 0;i < indexCount; i++) { - const index = indexes[i]; - const parse = index.is.parameter === string2 ? parseStringIndex : parseIndex; - const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); - for (let j = 0;j < keys.length; j++) { - const eff = parse(state, keys[j], index); - if (!effectIsExit(eff)) - yield* eff; - else if (eff._tag === "Failure") - return yield* eff; - } - } - } else if (parseIndexes) { - const keyPairs = empty2(); - for (let i = 0;i < indexCount; i++) { - const index = indexes[i]; - const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); - for (let j = 0;j < keys.length; j++) { - keyPairs.push([keys[j], index]); + for (const [key, [byValue, all]] of bySentinel) { + if (key === directKey) + continue; + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + for (const i of selected) { + if (all.has(i) && !match?.has(i)) + selected.delete(i); } } - const eff = parseIndexes(state, keyPairs, { - concurrency - }); - if (eff) - yield* eff; } - if (state.issues) { - return yield* fail6(new Composite(ast, state.issues, input, options)); - } - return out; - }); - if (indexCount) - return fallback; - const resume = (state, index, pending) => { - const property = properties[index]; - return flatMap3(exit2(pending), (exit) => { - const terminal = stepProperty(state, property, exit); - if (terminal) - return terminal; - const done = () => succeed8(state.out); - const eff = parseProperties(state, properties.slice(index + 1)); - return eff ? flatMapEager2(eff, done) : done(); - }); + return Array.from(selected).sort((a, b) => a - b).map((i) => types[i]); + }; + } else { + index = (input) => { + const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; + return (otherwise?.[runtimeType] ?? emptyCandidates).map((i) => types[i]).filter(filterLiterals(input)); }; + } + candidateIndexCache.set(types, index); + return index; +} +function filterLiterals(input) { + return (ast) => { + const encoded = toCandidate(ast); + return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true; + }; +} +function getCandidates(input, types, isConstructor = false) { + return getIndex(types)(input, isConstructor); +} +var Union = class extends ASTNodeImpl { + _tag = "Union"; + types; + options; + encodingChecks; + constructor(types, options, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.types = types; + this.options = options; + this.encodingChecks = encodingChecks; + } + getParser(compile, compileField) { + const ast = this; return (input, options) => { - if (input === missing) + if (input === missing) { return missingExit; - if (options.errors === "all" || options.onExcessProperty !== undefined || options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1) { - return fallback(input, options); } - if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { - return fail6(new InvalidType(ast, input, options)); + const candidates = getCandidates(input, ast.types, compileField !== undefined); + if (candidates.length === 0) { + return fail6(new AnyOf(ast, [], input, options)); + } + if (candidates.length === 1) { + const result = compile(candidates[0])(input, options); + if (result._tag === "Success") + return result; + return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchCause2(result, (cause) => failSingleUnionCandidate(ast, cause, input, options)); } - const props = compileMembers(); - const record = input; - const out = {}; const state = { ast, - input: record, - out, + compile, + input, + out: undefined, + successes: ast.options?.mode === "oneOf" ? [] : undefined, issues: undefined, options }; - try { - for (let index = 0;index < props.length; index++) { - const property = props[index]; - const name = property.name; - const hasKey = hasPropertySignature(record, name); - const value = hasKey ? record[name] : missing; - const exit = property.parser(value, options); - if (!effectIsExit(exit)) { - return resume(state, index, exit); + const eff = parseUnion(state, candidates); + if (!eff) { + if (state.out) + return state.out; + return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + } + return flatMapEager2(eff, (_) => { + if (state.out === sameExit) + return succeed6(input); + if (state.out) + return state.out; + return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + }); + }; + } + _rebuild(recur, checks, encodingChecks) { + const types = mapOrSame(this.types, recur); + return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks); + } + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks); + } + matchPart(s, options) { + for (const type of this.types) { + const out = type.matchPart(s, options); + if (out !== undefined) + return out; + } + return; + } + getExpected(getExpected) { + const expected = this.annotations?.expected; + if (typeof expected === "string") + return expected; + if (this.types.length === 0) + return "never"; + const types = this.types.map((type) => { + const encoded = toEncoded(type); + switch (encoded._tag) { + case "Arrays": { + const literals = encoded.elements.filter(isLiteral); + if (literals.length > 0) { + return `${formatIsMutable(encoded.isMutable)}[ ${literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ")}, ... ]`; } - if (exit === sameExit) { - if (hasKey) - assignProperty(out, name, value); - continue; + break; + } + case "Objects": { + const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)); + if (literals.length > 0) { + return `{ ${literals.map((ps) => `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${formatIsOptional(ps.type.context?.isOptional)}: ${getExpected(ps.type)}`).join(", ")}, ... }`; } - const terminal = stepProperty(state, property, exit); - if (terminal) - return terminal; + break; } - } catch (error) { - return die2(error); } - return succeed8(out); - }; - } - _rebuild(recur, recurParameter, checks, encodingChecks) { - const props = mapOrSame(this.propertySignatures, (ps) => { - const t = recur(ps.type); - return t === ps.type ? ps : new PropertySignature(ps.name, t); - }); - const indexes = mapOrSame(this.indexSignatures, (is) => { - const p = recurParameter(is.parameter); - const t = recur(is.type); - return p === is.parameter && t === is.type ? is : new IndexSignature(p, t); - }); - return props === this.propertySignatures && indexes === this.indexSignatures && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Objects(props, indexes, this.annotations, checks, undefined, this.context, encodingChecks); + return getExpected(encoded); + }); + return Array.from(new Set(types)).join(" | "); + } +}; +function failSingleUnionCandidate(ast, cause, input, options) { + const issue = getSchemaIssue(cause); + if (!issue) + return failCause2(cause); + return fail5(new AnyOf(ast, [issue], input, options)); +} +var parseUnion = /* @__PURE__ */ iterateEager()({ + onItem(s, ast) { + const parser = s.compile(ast); + return parser(s.input, s.options); + }, + step(s, candidate, exit) { + if (exit._tag === "Failure") { + const issue = getSchemaIssue(exit.cause); + if (issue === undefined) { + return exit; + } + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + if (s.out && s.successes) { + s.successes.push(candidate); + return fail5(new OneOf(s.ast, s.successes, s.input, s.options)); + } + s.out = exit; + if (s.successes) { + s.successes.push(candidate); + } else { + return void_2; + } + } + } +}); +var nonFiniteLiterals = /* @__PURE__ */ new Union([/* @__PURE__ */ new Literal("Infinity"), /* @__PURE__ */ new Literal("-Infinity"), /* @__PURE__ */ new Literal("NaN")]); +function formatIsMutable(isMutable) { + return isMutable ? "" : "readonly "; +} +function formatIsOptional(isOptional) { + return isOptional ? "?" : ""; +} +var Filter2 = class extends Class { + _tag = "Filter"; + run; + annotations; + aborted; + constructor(run, annotations = undefined, aborted = false) { + super(); + this.run = run; + this.annotations = annotations; + this.aborted = aborted; + } + annotate(annotations) { + return new Filter2(this.run, { + ...this.annotations, + ...annotations + }, this.aborted); + } + abort() { + return new Filter2(this.run, this.annotations, true); + } + and(other, annotations) { + return new FilterGroup([this, other], annotations); + } +}; +var FilterGroup = class extends Class { + _tag = "FilterGroup"; + checks; + annotations; + constructor(checks, annotations = undefined) { + super(); + this.checks = checks; + this.annotations = annotations; + } + annotate(annotations) { + return new FilterGroup(this.checks, { + ...this.annotations, + ...annotations + }); + } + and(other, annotations) { + return new FilterGroup([this, other], annotations); + } +}; +function makeFilter(filter, annotations, aborted = false) { + return new Filter2((input, ast, options) => normalizeFilterOutput(ast, filter(input, ast, options), input, options), annotations, aborted); +} +function isFinite2(annotations) { + return makeFilter((n) => globalThis.Number.isFinite(n), { + expected: "a finite number", + representation: { + id: "effect/schema/isFinite", + payload: null + }, + toJsonSchema: () => ({ + type: "number" + }), + toCode: () => ({ + runtime: "Schema.isFinite()" + }), + arbitraryConstraint: { + number: "finite" + }, + ...annotations + }); +} +var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]); +var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n)))); +function isPattern(regExp, annotations) { + const source = regExp.source; + const pattern = new globalThis.RegExp(source, regExp.flags); + return makeFilter((s) => { + pattern.lastIndex = 0; + return pattern.test(s); + }, { + expected: `a string matching the RegExp ${source}`, + representation: { + id: "effect/schema/isPattern", + payload: { + source, + flags: regExp.flags + } + }, + toJsonSchema: () => ({ + pattern: source + }), + arbitraryConstraint: { + patterns: [{ + source: regExp.source, + flags: regExp.flags + }] + }, + ...annotations + }); +} +function modifyOwnPropertyDescriptors(ast, f) { + const d = Object.getOwnPropertyDescriptors(ast); + f(d); + return Object.create(Object.getPrototypeOf(ast), d); +} +var contextOwners = /* @__PURE__ */ new WeakMap; +function getContextOwner(ast) { + return contextOwners.get(ast) ?? ast; +} +function replaceEncoding(ast, encoding) { + if (ast.encoding === encoding) { + return ast; } - flip(recur) { - return this._rebuild(recur, recur, this.encodingChecks, this.checks); + return modifyOwnPropertyDescriptors(ast, (d) => { + d.encoding.value = encoding; + }); +} +function replaceContext(ast, context) { + if (ast.context === context) { + return ast; } - recur(recur, recurParameter = recur) { - return this._rebuild(recur, recurParameter, this.checks, this.encodingChecks); + const owner = getContextOwner(ast); + if (owner.context === context) { + return owner; } - getExpected() { - if (this.propertySignatures.length === 0 && this.indexSignatures.length === 0) - return "object | array"; - return "object"; + const out = modifyOwnPropertyDescriptors(ast, (d) => { + d.context.value = context; + }); + contextOwners.set(out, owner); + return out; +} +function getLastEncoding(ast) { + return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast; +} +function annotate(ast, annotations) { + if (ast.checks) { + const last = ast.checks[ast.checks.length - 1]; + return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations))); } -}; -function stepProperty(s, p, exit) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, p.name, exit); + return modifyOwnPropertyDescriptors(ast, (d) => { + d.annotations.value = { + ...d.annotations.value, + ...annotations + }; + }); +} +function replaceChecks(ast, checks) { + if (ast._tag === "Suspend" && checks) { + throw new Error("Cannot add checks to Suspend"); } - if (exit === sameExit) - return; - const value = exit[args]; - if (value !== missing) { - assignProperty(s.out, p.name, value); - return; + if (ast.checks === checks) { + return ast; } - delete s.out[p.name]; - if (!isOptional(p.type)) { - const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - return; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); + return modifyOwnPropertyDescriptors(ast, (d) => { + d.checks.value = checks; + }); +} +function appendChecks(ast, checks) { + return replaceChecks(ast, combineChecks(ast.checks, checks)); +} +function mapLink(link, f) { + const to = f(link.to); + return to === link.to ? link : new Link(to, link.transformation); +} +function updateLastLink(encoding, f) { + const links = encoding; + const last = links[links.length - 1]; + const out = mapLink(last, f); + return out === last ? encoding : append(encoding.slice(0, encoding.length - 1), out); +} +function applyToLastLink(f) { + return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast; +} +function applyToSelfOrLastLinkEncodingIdempotent(f, options) { + function out(ast) { + if (ast.encoding) { + const last = ast.encoding[ast.encoding.length - 1]; + return options?.stopAt?.(last) ? ast : replaceEncoding(ast, updateLastLink(ast.encoding, out)); } + return f(ast); } + return memoizeIdempotent(out); } -var parsePropertiesOptions = { - onItem(s, p) { - if (!hasPropertySignature(s.input, p.name)) { - return p.parser(missing, s.options); +function appendTransformation(from, transformation, to) { + const link = new Link(from, transformation); + return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]); +} +function mapOrSame(as, f) { + let changed = false; + const out = new Array(as.length); + for (let i = 0;i < as.length; i++) { + const a = as[i]; + const fa = f(a); + if (fa !== a) { + changed = true; } - const value = s.input[p.name]; - assignProperty(s.out, p.name, value); - return p.parser(value, s.options); - }, - step: stepProperty -}; -var parseProperties = /* @__PURE__ */ iterateEager()(parsePropertiesOptions); -var parsePropertiesConcurrent = /* @__PURE__ */ iterateConcurrent()(parsePropertiesOptions); -function combineChecks(a, b) { - if (!a) - return b; - if (!b) - return a; - return [...a, ...b]; + out[i] = fa; + } + return changed ? out : as; } -function struct(fields, checks, annotations) { - return new Objects(Reflect.ownKeys(fields).map((key) => { - return new PropertySignature(key, fields[key].ast); - }), [], annotations, checks); +function annotateKey(ast, annotations) { + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, { + ...ast.context.annotations, + ...annotations + }) : new Context(false, false, undefined, annotations); + return replaceContext(ast, context); } -function getAST(self) { - return self.ast; +var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { + const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false); + return optionalKeyLastLink(replaceContext(ast, context)); +}); +var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); +function withConstructorDefault(ast, defaultValue) { + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue); + return replaceContext(ast, context); } -function tuple(elements, checks = undefined) { - return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks); +function decodeTo(from, to, transformation) { + return appendTransformation(from, transformation, to); } -function union(members, options, checks) { - return new Union(members.map(getAST), options, undefined, checks); +function isOptional(ast) { + return ast.context?.isOptional ?? false; } -var toCandidate = /* @__PURE__ */ memoizeIdempotent((ast) => { - while (true) { - if (isSuspend(ast)) - return unknown; - const encoding = ast.encoding; - if (!encoding) { - return ast.recur?.(toCandidate, identity) ?? ast; - } - if (encoding.some((link) => link.transformation._tag === "Middleware" && link.transformation.decode !== identity)) - return unknown; - ast = encoding[encoding.length - 1].to; +function isStructuralCheck(check) { + return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck); +} +function extractStructuralChecks(checks) { + function extract(check) { + if (isStructuralCheck(check)) + return [check]; + return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []; + } + const out = checks.flatMap(extract); + return isArrayNonEmpty2(out) ? out : undefined; +} +var toType = /* @__PURE__ */ memoizeIdempotent((ast) => { + if (ast.encoding) { + return toType(replaceEncoding(ast, undefined)); + } + const out = ast; + const type = out.recur?.(toType) ?? out; + const encodingChecks = type.encodingChecks; + if (encodingChecks) { + const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : undefined; + return modifyOwnPropertyDescriptors(type, (d) => { + d.encodingChecks.value = undefined; + d.checks.value = combineChecks(type.checks, checks); + }); + } + return type; +}); +var toEncoded = /* @__PURE__ */ memoizeIdempotent((ast) => { + return toType(flip2(ast)); +}); +function flipEncoding(ast, encoding) { + const links = encoding; + const len = links.length; + const last = links[len - 1]; + const ls = [new Link(flip2(replaceEncoding(ast, undefined)), links[0].transformation.flip())]; + for (let i = 1;i < len; i++) { + ls.unshift(new Link(flip2(links[i - 1].to), links[i].transformation.flip())); + } + const to = flip2(last.to); + if (to.encoding) { + return replaceEncoding(to, [...to.encoding, ...ls]); + } else { + return replaceEncoding(to, ls); + } +} +var flip2 = /* @__PURE__ */ memoize((ast) => { + if (ast.encoding) { + return flipEncoding(ast, ast.encoding); } + const out = ast; + return out.flip?.(flip2) ?? out.recur?.(flip2) ?? out; }); -function getCandidateTypes(ast) { +function containsUndefined(ast) { switch (ast._tag) { - case "Null": - return ["null"]; case "Undefined": - return ["undefined"]; - case "String": - case "TemplateLiteral": - return ["string"]; - case "Number": - return ["number"]; - case "Boolean": - return ["boolean"]; - case "Symbol": - case "UniqueSymbol": - return ["symbol"]; - case "BigInt": - return ["bigint"]; - case "Arrays": - return ["array"]; - case "ObjectKeyword": - return ["object", "array", "function"]; - case "Objects": - return ast.propertySignatures.length || ast.indexSignatures.length ? ["object"] : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; - case "Enum": - return Array.from(new Set(ast.enums.map(([, v]) => typeof v))); - case "Literal": - return [typeof ast.literal]; + return true; case "Union": - return Array.from(new Set(ast.types.flatMap(getCandidateTypes))); + return ast.types.some(containsUndefined); default: - return ["null", "undefined", "string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; + return false; } } -function collectSentinels(ast) { +function fromConst(ast, value) { + const succeed = value === 0 ? sameExit : succeed7(value); + return (input, options) => { + if (input === missing) + return missingExit; + if (input === value) + return succeed; + return fail6(new InvalidType(ast, input, options)); + }; +} +function fromRefinement(ast, refinement) { + return (input, options) => { + if (input === missing) + return missingExit; + if (refinement(input)) + return sameExit; + return fail6(new InvalidType(ast, input, options)); + }; +} +var parameterFromPropertyKey = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => { switch (ast._tag) { default: - return []; - case "Declaration": { - const s = ast.annotations?.[SENTINELS_ANNOTATION_KEY]; - return Array.isArray(s) ? s : []; - } - case "Objects": - return ast.propertySignatures.flatMap((ps) => { - const type = ps.type; - if (!isOptional(type)) { - if (isLiteral(type)) { - return [{ - key: ps.name, - literal: type.literal - }]; - } - if (isUniqueSymbol(type)) { - return [{ - key: ps.name, - literal: type.symbol - }]; - } - } - return []; - }); - case "Arrays": - return ast.elements.flatMap((e, i) => { - if (!isOptional(e)) { - if (isLiteral(e)) { - return [{ - key: i, - literal: e.literal - }]; - } - if (isUniqueSymbol(e)) { - return [{ - key: i, - literal: e.symbol - }]; - } - } - return []; - }); - case "Union": { - if (ast.types.length === 0) - return []; - const members = ast.types.map((type) => collectSentinels(toCandidate(type))); - return members[0].filter((s) => members.every((sentinels) => sentinels.some((o) => o.key === s.key && o.literal === s.literal))); - } - case "Suspend": - return collectSentinels(ast.thunk()); + return ast; + case "Number": + return ast.toCodecStringTree(); + case "Union": + return ast.recur(parameterFromPropertyKey); } +}); +var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`); +var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`); +function isStringFinite(annotations) { + return isPattern(isStringFiniteRegExp, { + expected: "a string representing a finite number", + representation: { + id: "effect/schema/isStringFinite", + payload: null + }, + toJsonSchema: () => ({ + pattern: isStringFiniteRegExp.source + }), + ...annotations + }); } -var candidateIndexCache = /* @__PURE__ */ new WeakMap; -var emptyCandidates = /* @__PURE__ */ Object.freeze([]); -var hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : (key in input); -function getIndex(types) { - let index = candidateIndexCache.get(types); - if (index) - return index; - let bySentinel; - let sentinelCandidateCount = 0; - let otherwise; - let literalCandidates; - let onlyLiterals = true; - for (let i = 0;i < types.length; i++) { - const a = types[i]; - const encoded = toCandidate(a); - if (isNever2(encoded)) - continue; - if (onlyLiterals) { - if (isLiteral(encoded) || isUniqueSymbol(encoded)) { - literalCandidates ??= new Map; - const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol; - let arr = literalCandidates.get(literal); - if (!arr) - literalCandidates.set(literal, arr = []); - arr.push(a); - } else { - onlyLiterals = false; - } - } - const sentinels = collectSentinels(encoded); - if (sentinels.length) { - bySentinel ??= new Map; - sentinelCandidateCount++; - for (const { - key, - literal - } of sentinels) { - let entry = bySentinel.get(key); - if (!entry) - bySentinel.set(key, entry = [new Map, new Set]); - entry[1].add(i); - let indexes = entry[0].get(literal); - if (!indexes) - entry[0].set(literal, indexes = new Set); - indexes.add(i); - } - } else { - otherwise ??= {}; - const candidateTypes = getCandidateTypes(encoded); - for (const t of candidateTypes) - (otherwise[t] ??= []).push(i); - } - } - if (onlyLiterals && literalCandidates) { - literalCandidates.forEach(Object.freeze); - index = (input) => literalCandidates.get(input) ?? emptyCandidates; - } else if (bySentinel?.size === 1 && !otherwise) { - const [key, [byValue]] = bySentinel.entries().next().value; - const candidates = byValue; - for (const [literal, indexes] of byValue) { - candidates.set(literal, Object.freeze(Array.from(indexes, (index) => types[index]))); - } - index = (input, isConstructor) => { - if (isObjectKeyword(input)) { - const value = hasPropertySignature(input, key) ? input[key] : undefined; - if (value !== undefined) - return candidates.get(value) ?? emptyCandidates; - if (isConstructor) - return types; - } - return emptyCandidates; - }; - } else if (bySentinel) { - let commonSentinel; - for (const entry of bySentinel) { - if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) { - commonSentinel = entry; - } - } - index = (input, isConstructor) => { - const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; - const base = otherwise?.[runtimeType] ?? emptyCandidates; - if (!isObjectKeyword(input)) - return base.map((i) => types[i]); - const selected = new Set(base); - let directKey; - if (commonSentinel) { - const [key, [byValue]] = commonSentinel; - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - if (!match) - return base.map((i) => types[i]); - for (const i of match) - selected.add(i); - directKey = key; - } - } - if (directKey === undefined) { - for (const [key, [byValue, all]] of bySentinel) { - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - if (match) { - for (const i of match) - selected.add(i); - } - } else if (isConstructor) { - for (const i of all) - selected.add(i); - } - } +var finiteString = /* @__PURE__ */ appendChecks(string2, [/* @__PURE__ */ isStringFinite()]); +var finiteToString = /* @__PURE__ */ new Link(finiteString, numberFromString); +var numberToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finiteString, nonFiniteLiterals]), numberFromString); +var BIGINT_PATTERN = "-?\\d+"; +var isStringBigIntRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${BIGINT_PATTERN}$`); +var REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"; +var isStringSymbolRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${REGEXP_PATTERN}$`); +function collectIssues(checks, value, issues, ast, options) { + for (let i = 0;i < checks.length; i++) { + const check = checks[i]; + if (check._tag === "FilterGroup") { + issues = collectIssues(check.checks, value, issues, ast, options); + if (issues && (options.errors !== "all" || issues[issues.length - 1].filter.aborted)) { + return issues; } - for (const [key, [byValue, all]] of bySentinel) { - if (key === directKey) - continue; - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - for (const i of selected) { - if (all.has(i) && !match?.has(i)) - selected.delete(i); - } + } else { + const issue = check.run(value, ast, options); + if (issue) { + const filter = new Filter(check, issue, value, options); + if (issues) + issues.push(filter); + else + issues = [filter]; + if (options.errors !== "all" || check.aborted) { + return issues; } } - return Array.from(selected).sort((a, b) => a - b).map((i) => types[i]); - }; - } else { - index = (input) => { - const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; - return (otherwise?.[runtimeType] ?? emptyCandidates).map((i) => types[i]).filter(filterLiterals(input)); - }; + } } - candidateIndexCache.set(types, index); - return index; + return issues; } -function filterLiterals(input) { - return (ast) => { - const encoded = toCandidate(ast); - return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true; - }; +function getConstructorDescriptor(ast) { + if (!isDeclaration(ast)) + return; + const getDescriptor = ast.annotations?.[CONSTRUCTOR_ANNOTATION_KEY]; + return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; } -function getCandidates(input, types, isConstructor = false) { - return getIndex(types)(input, isConstructor); + +// node_modules/effect/dist/Brand.js +function nominal() { + return Object.assign((input) => input, { + option: (input) => some2(input), + result: (input) => succeed2(input), + is: (_) => true + }); } -var Union = class extends ASTNodeImpl { - _tag = "Union"; - types; - options; - encodingChecks; - constructor(types, options, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.types = types; - this.options = options; - this.encodingChecks = encodingChecks; +// node_modules/effect/dist/Fiber.js +var interrupt3 = fiberInterrupt; +var runIn = fiberRunIn; + +// node_modules/effect/dist/Latch.js +var makeUnsafe4 = makeLatchUnsafe; + +// node_modules/effect/dist/MutableRef.js +var TypeId10 = "~effect/MutableRef"; +var MutableRefProto = { + [TypeId10]: TypeId10, + ...PipeInspectableProto, + toJSON() { + return { + _id: "MutableRef", + current: toJson(this.current) + }; } - getParser(compile, compileConstructorDefault) { - const ast = this; - return (input, options) => { - if (input === missing) { - return missingExit; - } - const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined); - if (candidates.length === 0) { - return fail6(new AnyOf(ast, [], input, options)); - } - if (candidates.length === 1) { - const result = compile(candidates[0])(input, options); - if (result._tag === "Success") - return result; - return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchCause2(result, (cause) => failSingleUnionCandidate(ast, cause, input, options)); - } - const state = { - ast, - compile, - input, - out: undefined, - successes: ast.options?.mode === "oneOf" ? [] : undefined, - issues: undefined, - options - }; - const eff = parseUnion(state, candidates); - if (!eff) { - if (state.out) - return state.out; - return fail6(new AnyOf(ast, state.issues ?? [], input, options)); +}; +var make6 = (value) => { + const ref = Object.create(MutableRefProto); + ref.current = value; + return ref; +}; + +// node_modules/effect/dist/MutableList.js +var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); +var make7 = () => ({ + head: undefined, + tail: undefined, + length: 0 +}); +var emptyBucket = () => ({ + array: [], + mutable: true, + offset: 0, + next: undefined +}); +var append2 = (self, message) => { + if (!self.tail) { + self.head = self.tail = emptyBucket(); + } else if (!self.tail.mutable) { + self.tail.next = emptyBucket(); + self.tail = self.tail.next; + } + self.tail.array.push(message); + self.length++; +}; +var clear = (self) => { + self.head = self.tail = undefined; + self.length = 0; +}; +var takeN = (self, n) => { + n = normalize(n); + if (n <= 0 || !self.head) + return []; + n = Math.min(n, self.length); + if (n === self.length && self.head?.offset === 0 && !self.head.next) { + const array = self.head.array; + clear(self); + return array; + } + const array = new Array(n); + let index = 0; + let chunk = self.head; + while (chunk) { + while (chunk.offset < chunk.array.length) { + array[index++] = chunk.array[chunk.offset]; + if (chunk.mutable) + chunk.array[chunk.offset] = undefined; + chunk.offset++; + if (index === n) { + self.head = chunk; + self.length -= n; + if (self.length === 0) + clear(self); + return array; } - return flatMapEager2(eff, (_) => { - if (state.out === sameExit) - return succeed6(input); - if (state.out) - return state.out; - return fail6(new AnyOf(ast, state.issues ?? [], input, options)); - }); - }; + } + chunk = chunk.next; } - _rebuild(recur, checks, encodingChecks) { - const types = mapOrSame(this.types, recur); - return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks); + clear(self); + return array; +}; +var take = (self) => { + if (!self.head) + return Empty; + const message = self.head.array[self.head.offset]; + if (self.head.mutable) + self.head.array[self.head.offset] = undefined; + self.head.offset++; + self.length--; + if (self.head.offset === self.head.array.length) { + if (self.head.next) { + self.head = self.head.next; + } else { + clear(self); + } } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks); + return message; +}; + +// node_modules/effect/dist/Queue.js +var TypeId11 = "~effect/Queue"; +var EnqueueTypeId = "~effect/Queue/Enqueue"; +var DequeueTypeId = "~effect/Queue/Dequeue"; +var variance = { + _A: identity, + _E: identity +}; +var QueueProto = { + [TypeId11]: variance, + [EnqueueTypeId]: variance, + [DequeueTypeId]: variance, + ...PipeInspectableProto, + toJSON() { + return { + _id: "effect/Queue", + state: this.state._tag, + size: sizeUnsafe(this) + }; } - flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks); +}; +var make8 = (options) => withFiber((fiber) => { + const self = Object.create(QueueProto); + self.dispatcher = fiber.currentDispatcher; + self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; + self.strategy = options?.strategy ?? "suspend"; + self.messages = make7(); + self.scheduleRunning = false; + self.state = { + _tag: "Open", + takers: new Set, + offers: new Set, + awaiters: new Set + }; + return succeed3(self); +}); +var bounded = (capacity) => make8({ + capacity +}); +var offer = (self, message) => suspend(() => { + if (self.state._tag !== "Open") { + return exitFalse; + } else if (self.messages.length >= self.capacity) { + switch (self.strategy) { + case "dropping": + return exitFalse; + case "suspend": + if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return exitTrue; + } + return offerRemainingSingle(self, message); + case "sliding": + take(self.messages); + append2(self.messages, message); + return exitTrue; + } } - matchPart(s, options) { - for (const type of this.types) { - const out = type.matchPart(s, options); - if (out !== undefined) - return out; + append2(self.messages, message); + scheduleReleaseTaker(self); + return exitTrue; +}); +var offerUnsafe = (self, message) => { + if (self.state._tag !== "Open") { + return false; + } else if (self.messages.length >= self.capacity) { + if (self.strategy === "sliding") { + take(self.messages); + append2(self.messages, message); + return true; + } else if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return true; } - return; + return false; } - getExpected(getExpected) { - const expected = this.annotations?.expected; - if (typeof expected === "string") - return expected; - if (this.types.length === 0) - return "never"; - const types = this.types.map((type) => { - const encoded = toEncoded(type); - switch (encoded._tag) { - case "Arrays": { - const literals = encoded.elements.filter(isLiteral); - if (literals.length > 0) { - return `${formatIsMutable(encoded.isMutable)}[ ${literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ")}, ... ]`; - } - break; - } - case "Objects": { - const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)); - if (literals.length > 0) { - return `{ ${literals.map((ps) => `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${formatIsOptional(ps.type.context?.isOptional)}: ${getExpected(ps.type)}`).join(", ")}, ... }`; - } - break; - } - } - return getExpected(encoded); - }); - return Array.from(new Set(types)).join(" | "); + append2(self.messages, message); + scheduleReleaseTaker(self); + return true; +}; +var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); +var failCauseUnsafe = (self, cause) => { + if (self.state._tag !== "Open") { + return false; } + const exit = exitFailCause(cause); + const fail = exitZipRight(exit, exitFailDone); + if (self.state.offers.size === 0 && self.messages.length === 0) { + finalize(self, fail); + return true; + } + self.state = { + ...self.state, + _tag: "Closing", + exit: fail + }; + return true; }; -function failSingleUnionCandidate(ast, cause, input, options) { - const issue = getSchemaIssue(cause); - if (!issue) - return failCause2(cause); - return fail4(new AnyOf(ast, [issue], input, options)); -} -var parseUnion = /* @__PURE__ */ iterateEager()({ - onItem(s, ast) { - const parser = s.compile(ast); - return parser(s.input, s.options); - }, - step(s, candidate, exit) { - if (exit._tag === "Failure") { - const issue = getSchemaIssue(exit.cause); - if (issue === undefined) { - return exit; - } - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - if (s.out && s.successes) { - s.successes.push(candidate); - return fail4(new OneOf(s.ast, s.successes, s.input, s.options)); - } - s.out = exit; - if (s.successes) { - s.successes.push(candidate); +var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); +var shutdown = (self) => sync(() => { + if (self.state._tag === "Done") { + return true; + } + clear(self.messages); + const offers = self.state.offers; + finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); + if (offers.size > 0) { + for (const entry of offers) { + if (entry._tag === "Single") { + entry.resume(exitFalse); } else { - return void_2; + entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); } } + offers.clear(); } + return true; }); -var nonFiniteLiterals = /* @__PURE__ */ new Union([/* @__PURE__ */ new Literal("Infinity"), /* @__PURE__ */ new Literal("-Infinity"), /* @__PURE__ */ new Literal("NaN")]); -function formatIsMutable(isMutable) { - return isMutable ? "" : "readonly "; -} -function formatIsOptional(isOptional) { - return isOptional ? "?" : ""; -} -var Filter2 = class extends Class { - _tag = "Filter"; - run; - annotations; - aborted; - constructor(run, annotations = undefined, aborted = false) { - super(); - this.run = run; - this.annotations = annotations; - this.aborted = aborted; - } - annotate(annotations) { - return new Filter2(this.run, { - ...this.annotations, - ...annotations - }, this.aborted); - } - abort() { - return new Filter2(this.run, this.annotations, true); - } - and(other, annotations) { - return new FilterGroup([this, other], annotations); - } +var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); +var takeBetween = (self, min, max) => { + min = normalize(min); + max = normalize(max); + return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); }; -var FilterGroup = class extends Class { - _tag = "FilterGroup"; - checks; - annotations; - constructor(checks, annotations = undefined) { - super(); - this.checks = checks; - this.annotations = annotations; +var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); +var poll = (self) => suspend(() => { + const result = takeUnsafe(self); + if (result === undefined) { + return succeed3(none2()); } - annotate(annotations) { - return new FilterGroup(this.checks, { - ...this.annotations, - ...annotations - }); + if (result._tag === "Success") { + return succeed3(some2(result.value)); } - and(other, annotations) { - return new FilterGroup([this, other], annotations); + return succeed3(none2()); +}); +var takeUnsafe = (self) => { + if (self.state._tag === "Done") { + return self.state.exit; + } + if (self.messages.length > 0) { + const message = take(self.messages); + releaseCapacity(self); + return exitSucceed(message); + } else if (self.capacity <= 0 && self.state.offers.size > 0) { + const message = takeOfferUnsafe(self.state.offers); + releaseCapacity(self); + return exitSucceed(message); } + return; }; -function makeFilter(filter, annotations, aborted = false) { - return new Filter2((input, ast, options) => normalizeFilterOutput(ast, filter(input, ast, options), input, options), annotations, aborted); -} -function isFinite2(annotations) { - return makeFilter((n) => globalThis.Number.isFinite(n), { - expected: "a finite number", - representation: { - id: "effect/schema/isFinite", - payload: null - }, - toJsonSchema: () => ({ - type: "number" - }), - toCode: () => ({ - runtime: "Schema.isFinite()" - }), - arbitraryConstraint: { - number: "finite" - }, - ...annotations - }); -} -var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]); -var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n)))); -function isPattern(regExp, annotations) { - const source = regExp.source; - const pattern = new globalThis.RegExp(source, regExp.flags); - return makeFilter((s) => { - pattern.lastIndex = 0; - return pattern.test(s); - }, { - expected: `a string matching the RegExp ${source}`, - representation: { - id: "effect/schema/isPattern", - payload: { - source, - flags: regExp.flags - } - }, - toJsonSchema: () => ({ - pattern: source - }), - arbitraryConstraint: { - patterns: [{ - source: regExp.source, - flags: regExp.flags - }] - }, - ...annotations - }); -} -function modifyOwnPropertyDescriptors(ast, f) { - const d = Object.getOwnPropertyDescriptors(ast); - f(d); - return Object.create(Object.getPrototypeOf(ast), d); -} -var contextOwners = /* @__PURE__ */ new WeakMap; -function getContextOwner(ast) { - return contextOwners.get(ast) ?? ast; -} -function replaceEncoding(ast, encoding) { - if (ast.encoding === encoding) { - return ast; +var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; +var exitFalse = /* @__PURE__ */ exitSucceed(false); +var exitTrue = /* @__PURE__ */ exitSucceed(true); +var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); +var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); +var releaseTakers = (self) => { + if (self.state._tag === "Done" || self.state.takers.size === 0) { + return; } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.encoding.value = encoding; - }); -} -function replaceContext(ast, context) { - if (ast.context === context) { - return ast; + for (const taker of self.state.takers) { + self.state.takers.delete(taker); + taker(exitVoid); + if (self.messages.length === 0) { + break; + } } - const owner = getContextOwner(ast); - if (owner.context === context) { - return owner; +}; +var scheduleReleaseTaker = (self) => { + if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { + return; } - const out = modifyOwnPropertyDescriptors(ast, (d) => { - d.context.value = context; - }); - contextOwners.set(out, owner); - return out; -} -function getLastEncoding(ast) { - return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast; -} -function annotate(ast, annotations) { - if (ast.checks) { - const last = ast.checks[ast.checks.length - 1]; - return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations))); + self.scheduleRunning = true; + self.dispatcher.scheduleTask(() => { + self.scheduleRunning = false; + releaseTakers(self); + }, 0); +}; +var takeBetweenUnsafe = (self, min, max) => { + if (self.state._tag === "Done") { + return self.state.exit; + } else if (max <= 0 || min <= 0) { + return exitSucceed([]); + } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { + const messages = [takeOfferUnsafe(self.state.offers)]; + releaseCapacity(self); + return exitSucceed(messages); } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.annotations.value = { - ...d.annotations.value, - ...annotations + min = Math.min(min, self.capacity || 1); + if (min <= self.messages.length) { + const messages = takeN(self.messages, max); + releaseCapacity(self); + return exitSucceed(messages); + } +}; +var offerRemainingSingle = (self, message) => { + return callback((resume) => { + if (self.state._tag !== "Open") { + return resume(exitFalse); + } + const entry = { + _tag: "Single", + message, + resume }; + self.state.offers.add(entry); + return sync(() => { + if (self.state._tag === "Open") { + self.state.offers.delete(entry); + } + }); }); -} -function replaceChecks(ast, checks) { - if (ast._tag === "Suspend" && checks) { - throw new Error("Cannot add checks to Suspend"); +}; +var takeOfferUnsafe = (offers) => { + const entry = offers.values().next().value; + if (entry._tag === "Single") { + offers.delete(entry); + entry.resume(exitTrue); + return entry.message; } - if (ast.checks === checks) { - return ast; + const message = entry.remaining[entry.offset++]; + if (entry.offset === entry.remaining.length) { + offers.delete(entry); + entry.resume(exitSucceed([])); } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.checks.value = checks; - }); -} -function appendChecks(ast, checks) { - return replaceChecks(ast, combineChecks(ast.checks, checks)); -} -function mapLink(link, f) { - const to = f(link.to); - return to === link.to ? link : new Link(to, link.transformation); -} -function updateLastLink(encoding, f) { - const links = encoding; - const last = links[links.length - 1]; - const out = mapLink(last, f); - return out === last ? encoding : append(encoding.slice(0, encoding.length - 1), out); -} -function applyToLastLink(f) { - return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast; -} -function applyToSelfOrLastLinkEncodingIdempotent(f, options) { - function out(ast) { - if (ast.encoding) { - const last = ast.encoding[ast.encoding.length - 1]; - return options?.stopAt?.(last) ? ast : replaceEncoding(ast, updateLastLink(ast.encoding, out)); + return message; +}; +var releaseCapacity = (self) => { + if (self.state._tag === "Done") { + return isDoneCause(self.state.exit.cause); + } else if (self.state.offers.size === 0) { + if (self.state._tag === "Closing" && self.messages.length === 0) { + finalize(self, self.state.exit); + return isDoneCause(self.state.exit.cause); } - return f(ast); + return false; } - return memoizeIdempotent(out); -} -function appendTransformation(from, transformation, to) { - const link = new Link(from, transformation); - return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]); -} -function mapOrSame(as, f) { - let changed = false; - const out = new Array(as.length); - for (let i = 0;i < as.length; i++) { - const a = as[i]; - const fa = f(a); - if (fa !== a) { - changed = true; + for (const entry of self.state.offers) { + let n = self.capacity - self.messages.length; + if (n <= 0) + break; + else if (entry._tag === "Single") { + append2(self.messages, entry.message); + self.state.offers.delete(entry); + entry.resume(exitTrue); + } else { + for (;entry.offset < entry.remaining.length; entry.offset++) { + if (n === 0) + return false; + append2(self.messages, entry.remaining[entry.offset]); + n--; + } + self.state.offers.delete(entry); + entry.resume(exitSucceed([])); } - out[i] = fa; } - return changed ? out : as; -} -function annotateKey(ast, annotations) { - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, { - ...ast.context.annotations, - ...annotations - }) : new Context(false, false, undefined, annotations); - return replaceContext(ast, context); -} -var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { - const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false); - return optionalKeyLastLink(replaceContext(ast, context)); + return false; +}; +var awaitTake = (self) => callback((resume) => { + if (self.state._tag === "Done") { + return resume(self.state.exit); + } + self.state.takers.add(resume); + return sync(() => { + if (self.state._tag !== "Done") { + self.state.takers.delete(resume); + } + }); }); -var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); -function withConstructorDefault(ast, defaultValue) { - const transformation = new Transformation(withDefault(defaultValue), passthrough()); - const constructorDefault = new Link(unknown, transformation); - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) : new Context(false, false, constructorDefault); - return replaceContext(ast, context); -} -function decodeTo(from, to, transformation) { - return appendTransformation(from, transformation, to); -} -function isOptional(ast) { - return ast.context?.isOptional ?? false; -} -function isStructuralCheck(check) { - return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck); -} -function extractStructuralChecks(checks) { - function extract(check) { - if (isStructuralCheck(check)) - return [check]; - return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []; +var finalize = (self, exit) => { + if (self.state._tag === "Done") { + return; + } + const openState = self.state; + self.state = { + _tag: "Done", + exit + }; + for (const taker of openState.takers) { + taker(exit); + } + openState.takers.clear(); + for (const awaiter of openState.awaiters) { + awaiter(exit); + } + openState.awaiters.clear(); +}; + +// node_modules/effect/dist/Semaphore.js +var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); +var waitForPermits = (self, n, effect) => callback((resume) => { + if (self.free >= n) + return resume(effect); + const observer = () => { + if (self.free < n) + return; + self.waiters.delete(observer); + resume(effect); + }; + self.waiters.add(observer); + return sync(() => { + self.waiters.delete(observer); + }); +}); + +class SemaphoreImpl { + waiters = /* @__PURE__ */ new Set; + taken = 0; + permits; + constructor(permits) { + this.permits = permits; + } + get free() { + return this.permits - this.taken; + } + take(n) { + const take = suspend(() => { + if (this.free < n) { + return waitForPermits(this, n, take); + } + this.taken += n; + return succeed3(n); + }); + return take; } - const out = checks.flatMap(extract); - return isArrayNonEmpty2(out) ? out : undefined; -} -var toType = /* @__PURE__ */ memoizeIdempotent((ast) => { - if (ast.encoding) { - return toType(replaceEncoding(ast, undefined)); + takeIfAvailable(n) { + return suspend(() => { + if (this.free < n) + return succeed3(false); + this.taken += n; + return succeed3(true); + }); } - const out = ast; - const type = out.recur?.(toType) ?? out; - const encodingChecks = type.encodingChecks; - if (encodingChecks) { - const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : undefined; - return modifyOwnPropertyDescriptors(type, (d) => { - d.encodingChecks.value = undefined; - d.checks.value = combineChecks(type.checks, checks); + releaseUnsafe(fiber, n) { + this.taken -= n; + if (this.waiters.size > 0) { + fiber.currentDispatcher.scheduleTask(() => { + for (const observer of this.waiters) { + if (this.free <= 0) + break; + observer(); + } + }, 0); + } + return this.free; + } + resize(permits) { + return withFiber((fiber) => { + this.permits = permits; + if (this.free < 0) + return void_; + this.releaseUnsafe(fiber, 0); + return void_; }); } - return type; -}); -var toEncoded = /* @__PURE__ */ memoizeIdempotent((ast) => { - return toType(flip2(ast)); -}); -function flipEncoding(ast, encoding) { - const links = encoding; - const len = links.length; - const last = links[len - 1]; - const ls = [new Link(flip2(replaceEncoding(ast, undefined)), links[0].transformation.flip())]; - for (let i = 1;i < len; i++) { - ls.unshift(new Link(flip2(links[i - 1].to), links[i].transformation.flip())); + release(n) { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); } - const to = flip2(last.to); - if (to.encoding) { - return replaceEncoding(to, [...to.encoding, ...ls]); - } else { - return replaceEncoding(to, ls); + get releaseAll() { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); } -} -var flip2 = /* @__PURE__ */ memoize((ast) => { - if (ast.encoding) { - return flipEncoding(ast, ast.encoding); + withPermits(n) { + return (self) => uninterruptibleMask((restore) => { + const acquire = suspend(() => { + if (this.free < n) { + const wait = waitForPermits(this, n, void_); + return flatMap2(restore(wait), () => acquire); + } + this.taken += n; + return onExitPrimitive(restore(self), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); + return acquire; + }); } - const out = ast; - return out.flip?.(flip2) ?? out.recur?.(flip2) ?? out; -}); -function containsUndefined(ast) { - switch (ast._tag) { - case "Undefined": - return true; - case "Union": - return ast.types.some(containsUndefined); - default: - return false; + withPermit = /* @__PURE__ */ this.withPermits(1); + withPermitsIfAvailable(n) { + return (self) => uninterruptibleMask((restore) => { + if (this.free < n) + return succeedNone; + this.taken += n; + return onExitPrimitive(restore(asSome(self)), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); } } -function fromConst(ast, value) { - const succeed = value === 0 ? sameExit : succeed8(value); - return (input, options) => { - if (input === missing) - return missingExit; - if (input === value) - return succeed; - return fail6(new InvalidType(ast, input, options)); - }; -} -function fromRefinement(ast, refinement) { - return (input, options) => { - if (input === missing) - return missingExit; - if (refinement(input)) - return sameExit; - return fail6(new InvalidType(ast, input, options)); - }; -} -var parameterFromPropertyKey = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => { - switch (ast._tag) { - default: - return ast; - case "Number": - return ast.toCodecStringTree(); - case "Union": - return ast.recur(parameterFromPropertyKey); + +// node_modules/effect/dist/Channel.js +var TypeId12 = "~effect/Channel"; +var isChannel = (u) => hasProperty(u, TypeId12); +var ChannelProto = { + [TypeId12]: { + _Env: identity, + _InErr: identity, + _InElem: identity, + _OutErr: identity, + _OutElem: identity + }, + pipe() { + return pipeArguments(this, arguments); } -}); -var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`); -var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`); -function isStringFinite(annotations) { - return isPattern(isStringFiniteRegExp, { - expected: "a string representing a finite number", - representation: { - id: "effect/schema/isStringFinite", - payload: null - }, - toJsonSchema: () => ({ - pattern: isStringFiniteRegExp.source - }), - ...annotations - }); -} -var finiteString = /* @__PURE__ */ appendChecks(string2, [/* @__PURE__ */ isStringFinite()]); -var finiteToString = /* @__PURE__ */ new Link(finiteString, numberFromString); -var numberToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finiteString, nonFiniteLiterals]), numberFromString); -var BIGINT_PATTERN = "-?\\d+"; -var isStringBigIntRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${BIGINT_PATTERN}$`); -var REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"; -var isStringSymbolRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${REGEXP_PATTERN}$`); -function collectIssues(checks, value, issues, ast, options) { - for (let i = 0;i < checks.length; i++) { - const check = checks[i]; - if (check._tag === "FilterGroup") { - issues = collectIssues(check.checks, value, issues, ast, options); - if (issues && (options.errors !== "all" || issues[issues.length - 1].filter.aborted)) { - return issues; +}; +var fromTransform = (transform) => { + const self = Object.create(ChannelProto); + self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); + return self; +}; +var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); +var fromPull = (effect) => fromTransform((_, __) => effect); +var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { + const closableScope = forkUnsafe2(scope); + const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); + const pull = yield* onError2(f(upstream, scope, closableScope), onCause); + return onError2(pull, onCause); +})); +var toTransform = (channel) => channel.transform; +var asyncQueue = (scope, f, options) => make8({ + capacity: options?.bufferSize, + strategy: options?.strategy +}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); +var callbackArray = (f, options) => fromTransform((_, scope) => map5(asyncQueue(scope, f, options), takeAll2)); +var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); +var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done2())); +var map6 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { + let i = 0; + return map5(pull, (o) => f(o, i++)); +}))); +var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); +var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done2))))); +var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { + const strategy = options?.haltStrategy ?? "both"; + const queue = yield* bounded(0); + yield* addFinalizer2(forkedScope, shutdown(queue)); + let done = 0; + function onExit(side, cause) { + done++; + if (!isDoneCause(cause)) { + return failCause4(queue, cause); + } + switch (strategy) { + case "both": { + return done === 2 ? failCause4(queue, cause) : void_3; } - } else { - const issue = check.run(value, ast, options); - if (issue) { - const filter = new Filter(check, issue, value, options); - if (issues) - issues.push(filter); - else - issues = [filter]; - if (options.errors !== "all" || check.aborted) { - return issues; + case "left": + case "right": { + return side === strategy ? failCause4(queue, cause) : void_3; + } + case "either": { + return failCause4(queue, cause); + } + } + } + const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); + yield* runSide("left", left, forkUnsafe2(forkedScope)); + yield* runSide("right", right, forkUnsafe2(forkedScope)); + return take2(queue); +}))); +var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { + let stringBuilder = ""; + let midCRLF = false; + let done = none2(); + function splitLinesArray(chunk) { + const chunkBuilder = []; + function pushLine(segment) { + if (stringBuilder.length === 0) { + chunkBuilder.push(segment); + } else { + chunkBuilder.push(stringBuilder + segment); + stringBuilder = ""; + } + } + for (let i = 0;i < chunk.length; i++) { + const str = chunk[i]; + if (str.length !== 0) { + let from = 0; + let indexOfCR = str.indexOf("\r"); + let indexOfLF = str.indexOf(` +`); + if (midCRLF) { + if (indexOfLF === 0) { + from = 1; + indexOfLF = str.indexOf(` +`, from); + } + midCRLF = false; + } + while (indexOfCR !== -1 || indexOfLF !== -1) { + if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { + pushLine(str.substring(from, indexOfLF)); + from = indexOfLF + 1; + indexOfLF = str.indexOf(` +`, from); + } else { + pushLine(str.substring(from, indexOfCR)); + if (str.length === indexOfCR + 1) { + midCRLF = true; + from = str.length; + indexOfCR = -1; + } else { + from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); + indexOfCR = str.indexOf("\r", from); + indexOfLF = str.indexOf(` +`, from); + } + } } + stringBuilder = stringBuilder + str.substring(from); } } + return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; } - return issues; -} -function getConstructorDescriptor(ast) { - if (!isDeclaration(ast)) - return; - const getDescriptor = ast.annotations?.[CONSTRUCTOR_ANNOTATION_KEY]; - return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; -} - -// node_modules/effect/dist/SchemaParser.js -function makeEffect(schema) { - const ast = schema.ast; - let parser; - return (input, options) => { - return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { - ...options.parseOptions, - disableChecks: true - } : { - disableChecks: true - } : options?.parseOptions); - }; -} -function makeOption(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return some2(exit.value); - } - getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); - return none2(); - }; -} -function make14(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return exit.value; + const pullOrFlush = suspend2(() => { + if (done._tag === "Some") { + return done2(done.value); } - const issue = getSchemaIssueOrThrow(exit.cause, "Constructor adapter can only throw schema issues"); - throw new Error("Schema validation failed", { - cause: issue + return matchEffect2(upstream, { + onSuccess: loop, + onFailure: failCause3, + onDone: (leftover) => { + done = some2(leftover); + if (stringBuilder.length > 0) { + const last = stringBuilder; + stringBuilder = ""; + midCRLF = false; + return succeed6([last]); + } + return done2(leftover); + } }); - }; -} -function decodeUnknownEffect(schema, options) { - const parser = run2(schema.ast); - return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); -} -var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { - ...options, - ...overrideOptions -} : options; -var getValue = (value) => { - if (value === missing) { - return fail6(new InvalidValue); + }); + function loop(chunk) { + const lines = splitLinesArray(chunk); + return lines !== null ? succeed6(lines) : pullOrFlush; } - return succeed6(value); -}; -function run2(ast) { - return runWithCompiler(normalCompiler, ast); -} -function runWithCompiler(compiler, ast) { - let parser; - return (input, options) => { - const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); - if (result === sameExit) { - return succeed6(input); + return pullOrFlush; +})); +var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); +var unwrap = (channel) => fromTransform((upstream, scope) => { + let pull; + return succeed6(suspend2(() => { + if (pull) + return pull; + return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); + })); +}); +var runWith = (self, f, onHalt) => suspend2(() => { + const scope = makeUnsafe3(); + const makePull = toTransform(self)(done2(), scope); + return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); +}); +var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { + disableYield: true +}))); +var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { + let state = initial(); + return runWith(self, (pull) => whileLoop2({ + while: constTrue, + body: () => pull, + step: (value) => { + state = f(state, value); } - if (!effectIsExit(result)) { - return flatMapEager2(result, getValue); + }), () => succeed6(state)); +})); +var toPullScoped = (self, scope) => toTransform(self)(done2(), scope); +// node_modules/effect/dist/internal/schema/interpreter.js +var flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager2(result, f); +function compileTransformation(transformation) { + if (transformation._tag === "Middleware") { + return (result, current, options) => { + const transformed = result === sameExit ? transformation.decode(succeed7(toOption(current)), options) : transformation.decode(mapEager2(result, toOption), options); + return fromOptionalEffect(transformed); + }; + } + const getter = transformation.decode; + switch (getter._tag) { + case "Passthrough": + return (result, current) => result === sameExit ? succeed7(current) : result; + case "Transform": { + const transform = (value) => value === missing ? missingExit : succeed7(getter.transform(value)); + return (result, current) => flatMapTransformation(result, current, transform); } - return result[args] === missing ? getValue(missing) : result; - }; -} -var normalCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, normalCompiler)); -var constructorCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault)); -var compileDefaulted = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault, ast.context?.constructorDefault)); -function compileConstructorDefault(ast) { - return ast.context?.constructorDefault ? compileDefaulted(ast) : constructorCompiler(ast); -} -function applyTransformation(result, current, transformation, options) { - let transformed; - if (effectIsExit(result) && result._tag === "Success") { - const optional = toOption(result === sameExit ? current : result[args]); - transformed = transformation._tag === "Transformation" ? transformation.decode.run(optional, options) : transformation.decode(succeed8(optional), options); - } else if (transformation._tag === "Transformation") { - transformed = flatMapEager2(result, (value) => transformation.decode.run(toOption(value), options)); - } else { - transformed = transformation.decode(mapEager2(result, toOption), options); + case "TransformOptional": { + const transform = (value) => fromOptionExit(getter.transform(toOption(value))); + return (result, current) => flatMapTransformation(result, current, transform); + } + case "TransformEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => value === missing ? missingExit : getter.transform(value, options)); + case "TransformOptionalEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => fromOptionalEffect(getter.transform(toOption(value), options))); } - return effectIsExit(transformed) && transformed._tag === "Success" ? fromOptionExit(transformed[args]) : flatMapEager2(transformed, fromOptionExit); } +var fromOptionalEffect = (effect) => flatMapEager2(effect, fromOptionExit); +var wrapEncoding = (ast, input, options, effect) => catchCause2(effect, (cause) => failCauseSync2(() => map4(cause, (issue) => new Encoding(ast, issue, input, options)))); function makeConstructorParser(descriptor, compile) { + const transform = compileTransformation(descriptor.link.transformation); let sourceParser; return (input, options) => { if (input === missing) @@ -7619,20 +7191,45 @@ function makeConstructorParser(descriptor, compile) { if (descriptor.isConstructed(input)) return sameExit; const result = (sourceParser ??= compile(descriptor.link.to))(input, options); - return applyTransformation(result, input, descriptor.link.transformation, options); + return transform(result, input, options); + }; +} +function withDefault(ast, parser) { + const defaultValue = ast.context.constructorDefault; + return (input, options) => { + if (input !== missing && input !== undefined) + return parser(input, options); + const result = defaultValue; + if (effectIsExit(result) && result._tag === "Success") { + const local = parser(result[args], options); + return local === sameExit ? result : local; + } + return flatMapEager2(wrapEncoding(ast, input, options, result), (value) => { + const local = parser(value, options); + return local === sameExit ? succeed7(value) : local; + }); }; } -function makeParser(ast, compile, compileConstructorDefault, constructorDefault) { - const descriptor = compileConstructorDefault ? getConstructorDescriptor(ast) : undefined; - const parser = descriptor ? makeConstructorParser(descriptor, compile) : ast.getParser(compile, compileConstructorDefault); +function compileField(ast, compile) { + const parser = compile(ast); + return ast.context?.constructorDefault === undefined ? parser : withDefault(ast, parser); +} +function compile(ast, compile, compileField, base, specialize) { + if (ast._tag === "Declaration") { + for (const parameter of ast.typeParameters) + compile(parameter); + } + const descriptor = compileField ? getConstructorDescriptor(ast) : undefined; + const parser = descriptor ? makeConstructorParser(descriptor, compile) : base ?? ast.getParser(compile, compileField); const checks = ast.checks; - const links = constructorDefault ? ast.encoding ? [...ast.encoding, constructorDefault] : [constructorDefault] : ast.encoding; + const links = ast.encoding; + const transformations = links?.map((link) => compileTransformation(link.transformation)); const encodingChecks = ast.encodingChecks; if (!links && !checks && !encodingChecks) { return parser; } let encodingParsers; - const parseLocal = (input, options) => { + const parseChecks = (input, options) => { let result = parser(input, options); if (encodingChecks && !options.disableChecks) { if (effectIsExit(result)) { @@ -7682,6 +7279,7 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) } return result; }; + const parseLocal = specialize === undefined ? parseChecks : specialize(parseChecks); if (!links) { return parseLocal; } @@ -7690,7 +7288,7 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) let current = input; let result = parsers[parsers.length - 1](input, options); for (let i = links.length - 1;i >= 0; i--) { - result = applyTransformation(result, current, links[i].transformation, options); + result = transformations[i](result, current, options); if (i !== 0) { const next = parsers[i - 1]; if (result._tag === "Success") { @@ -7699,28 +7297,233 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) } else { result = flatMapEager2(result, (value) => { const nextResult = next(value, options); - return nextResult === sameExit ? succeed8(value) : nextResult; + return nextResult === sameExit ? succeed7(value) : nextResult; }); } } } - if (result._tag === "Success") { - const value = result[args]; - const local = parseLocal(value, options); - return local === sameExit ? result : local; - } - result = catchCause2(result, (cause) => failCauseSync2(() => map5(cause, (issue) => new Encoding(ast, issue, input, options)))); - return flatMapEager2(result, (value) => { - const local = parseLocal(value, options); - return local === sameExit ? succeed8(value) : local; - }); + if (result._tag === "Success") { + const value = result[args]; + const local = parseLocal(value, options); + return local === sameExit ? result : local; + } + result = wrapEncoding(ast, input, options, result); + return flatMapEager2(result, (value) => { + const local = parseLocal(value, options); + return local === sameExit ? succeed7(value) : local; + }); + }; +} + +// node_modules/effect/dist/internal/schema/compilerRegistry.js +var invalid3 = /* @__PURE__ */ Symbol(); +var cache = /* @__PURE__ */ new WeakMap; +var compiler; +var compilerAdaptersEnabled = false; +var decodeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "parser") : resolve2(ast).parser; +var makeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "makeEffect") : resolve2(ast).makeEffect; +var makeField = (ast) => compileField(ast, makeChild); + +class InterpretedEntry { + ast; + constructor(ast) { + this.ast = ast; + } + get decodeEffect() { + return this.cachedDecodeEffect ??= compile(this.ast, decodeChild); + } + get parser() { + return this.decodeEffect; + } + get makeEffect() { + return this.cachedMakeEffect ??= compile(this.ast, makeChild, makeField); + } +} + +class CompilerEntry extends InterpretedEntry { + compiled; + resolve; + constructor(ast, compiled, resolve) { + super(ast); + this.compiled = compiled; + this.resolve = resolve; + } + save(key, value) { + Object.defineProperty(this, key, { + value + }); + return value; + } + operation(key) { + const compiled = this.compiled; + return typeof compiled === "function" ? compiled(this.ast, this.resolve, key) : compiled?.[key]; + } + get is() { + return this.save("is", this.operation("is")); + } + get decode() { + return this.save("decode", this.operation("decode")); + } + get make() { + return this.save("make", this.operation("make")); + } + get decodeEffect() { + return this.save("decodeEffect", this.operation("decodeEffect") ?? compile(this.ast, (ast) => lazyParser(this.resolve, ast, "parser"))); + } + get parser() { + const decode = this.decode; + return decode === undefined ? this.decodeEffect : this.save("parser", withDecode(decode, () => this.decodeEffect)); + } + get makeEffect() { + const makeEffect = this.operation("makeEffect"); + if (makeEffect !== undefined) + return this.save("makeEffect", makeEffect); + const child = (ast) => lazyParser(this.resolve, ast, "makeEffect"); + return this.save("makeEffect", compile(this.ast, child, (ast) => compileField(ast, child))); + } +} +function withDecode(fastDecode, decodeEffect) { + let detailed; + return (input, options) => { + if (input !== missing) { + try { + const value = fastDecode(input, options); + if (value !== invalid3) + return value === input ? sameExit : succeed7(value); + } catch (error) { + return die3(error); + } + } + return (detailed ??= decodeEffect())(input, options); + }; +} +function lazyParser(resolve, ast, operation) { + const entry = resolve(ast); + if (entry.compiled === undefined || Object.hasOwn(entry, operation)) { + return entry[operation]; + } + let parser; + return (input, options) => (parser ??= entry[operation])(input, options); +} +function resolve2(ast) { + const cached = cache.get(ast); + if (cached !== undefined) + return cached; + const entry = compiler === undefined ? new InterpretedEntry(ast) : new CompilerEntry(ast, compiler(ast, resolve2), resolve2); + cache.set(ast, entry); + return entry; +} + +// node_modules/effect/dist/SchemaParser.js +function makeEffect(schema) { + const ast = schema.ast; + let parser; + return (input, options) => { + return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions); + }; +} +function makeOption(schema) { + const parser = makeEffect(schema); + return (input, options) => { + const exit = runSyncExit2(parser(input, options)); + if (isSuccess3(exit)) { + return some2(exit.value); + } + getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); + return none2(); + }; +} +function make9(schema) { + return makeConstructorSync(toType(schema.ast)); +} +function decodeUnknownEffect(schema, options) { + const parser = run(schema.ast); + return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); +} +var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { + ...options, + ...overrideOptions +} : options; +var getValue = (value) => { + if (value === missing) { + return fail6(new InvalidValue); + } + return succeed6(value); +}; +function run(ast) { + return runWithCompiler(normalCompiler, ast); +} +function parserResult(result, input) { + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; +} +function runWithCompiler(compiler, ast) { + let parser; + return (input, options) => { + const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; + }; +} +function runSync2(effect, message) { + const exit = runSyncExit2(effect); + if (isSuccess3(exit)) { + return exit.value; + } + const issue = getSchemaIssueOrThrow(exit.cause, message); + throw new Error("Schema validation failed", { + cause: issue + }); +} +function makeConstructorSync(ast) { + let entry; + let parser; + return (input, options) => { + entry ??= resolve2(ast); + const parseOptions = options?.disableChecks ? options.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions ?? defaultParseOptions; + const make = entry.make; + if (make !== undefined && input !== missing) { + let output; + try { + output = make(input, parseOptions); + } catch (error) { + getSchemaIssueOrThrow(die2(error), "Constructor adapter can only throw schema issues"); + throw error; + } + if (output !== invalid3 && output !== missing) + return output; + } + const result = (parser ??= entry.makeEffect)(input, parseOptions); + return runSync2(parserResult(result, input), "Constructor adapter can only throw schema issues"); }; } +var normalCompiler = (ast) => resolve2(ast).parser; +var constructorCompiler = (ast) => resolve2(ast).makeEffect; // node_modules/effect/dist/internal/schema/make.js -var TypeId20 = "~effect/Schema/Schema"; +var TypeId13 = "~effect/Schema/Schema"; var SchemaProto = { - [TypeId20]: TypeId20, + [TypeId13]: TypeId13, pipe() { return pipeArguments(this, arguments); }, @@ -7734,7 +7537,7 @@ var SchemaProto = { return this.rebuild(appendChecks(this.ast, checks)); } }; -function make15(ast, options) { +function make10(ast, options) { function Schema() {} const self = Object.setPrototypeOf(Schema, SchemaProto); if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) { @@ -7745,9 +7548,9 @@ function make15(ast, options) { Object.assign(self, options); } self.ast = ast; - self.rebuild = (ast) => make15(ast, options); + self.rebuild = (ast) => make10(ast, options); self.makeEffect = makeEffect(self); - self.make = make14(self); + self.make = make9(self); self.makeOption = makeOption(self); return self; } @@ -7762,10 +7565,10 @@ function isSchemaError(u) { } // node_modules/effect/dist/Schema.js -var TypeId21 = TypeId20; +var TypeId14 = TypeId13; function declareConstructor() { return (typeParameters, run, annotations) => { - return make16(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make16(ast))), annotations)); + return make11(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make11(ast))), annotations)); }; } function declare(is, annotations) { @@ -7798,10 +7601,10 @@ function fromIssueEffect(self) { if (effectIsExit(self)) { return fromIssueExit(self); } - return catchCause2(self, (cause) => failCauseSync2(() => map5(cause, (issue) => new SchemaError(issue)))); + return catchCause2(self, (cause) => failCauseSync2(() => map4(cause, (issue) => new SchemaError(issue)))); } function fromIssueExit(exit) { - return isSuccess3(exit) ? exit : failCause2(map5(exit.cause, (issue) => new SchemaError(issue))); + return isSuccess3(exit) ? exit : failCause2(map4(exit.cause, (issue) => new SchemaError(issue))); } function decodeUnknownEffect2(schema, options) { const parser = decodeUnknownEffect(schema, options); @@ -7809,15 +7612,15 @@ function decodeUnknownEffect2(schema, options) { return fromIssueEffect(parser(input, options)); }; } -var make16 = make15; +var make11 = make10; function isSchema(u) { - return hasProperty(u, TypeId21) && u[TypeId21] === TypeId21; + return hasProperty(u, TypeId14) && u[TypeId14] === TypeId14; } -var optionalKey2 = /* @__PURE__ */ lambda((schema) => make16(optionalKey(schema.ast), { +var optionalKey2 = /* @__PURE__ */ lambda((schema) => make11(optionalKey(schema.ast), { schema })); function Literal2(literal) { - const out = make16(new Literal(literal), { + const out = make11(new Literal(literal), { literal, transform(to) { return out.pipe(decodeTo2(Literal2(to), { @@ -7828,10 +7631,10 @@ function Literal2(literal) { }); return out; } -var String4 = /* @__PURE__ */ make16(string2); -var Number5 = /* @__PURE__ */ make16(number2); +var String4 = /* @__PURE__ */ make11(string2); +var Number5 = /* @__PURE__ */ make11(number2); function makeStruct(ast, fields) { - return make16(ast, { + return make11(ast, { fields, mapFields(f, options) { const fields = f(this.fields); @@ -7843,7 +7646,7 @@ function Struct(fields) { return makeStruct(struct(fields, undefined), fields); } function makeTuple(ast, elements) { - return make16(ast, { + return make11(ast, { elements, mapElements(f, options) { const elements = f(this.elements); @@ -7854,11 +7657,11 @@ function makeTuple(ast, elements) { function Tuple(elements) { return makeTuple(tuple(elements), elements); } -var ArraySchema = /* @__PURE__ */ lambda((schema) => make16(new Arrays(false, [], [schema.ast]), { +var ArraySchema = /* @__PURE__ */ lambda((schema) => make11(new Arrays(false, [], [schema.ast]), { value: schema })); function makeUnion(ast, members) { - return make16(ast, { + return make11(ast, { members, mapMembers(f, options) { const members = f(this.members); @@ -7871,14 +7674,14 @@ function Union2(members, options) { } function decodeTo2(to, transformation) { return (from) => { - return make16(decodeTo(from.ast, to.ast, transformation ? make13(transformation) : passthrough2()), { + return make11(decodeTo(from.ast, to.ast, transformation ? makeTransformation(transformation) : passthrough2()), { from, to }); }; } function withConstructorDefault2(defaultValue) { - return (schema) => make16(withConstructorDefault(schema.ast, defaultValue), { + return (schema) => make11(withConstructorDefault(schema.ast, defaultValue), { schema }); } @@ -7896,7 +7699,7 @@ function instanceOf(constructor, annotations) { } function link() { return (encodeTo, transformation) => { - return new Link(encodeTo.ast, make13(transformation)); + return new Link(encodeTo.ast, makeTransformation(transformation)); }; } var makeFilter2 = makeFilter; @@ -8005,7 +7808,7 @@ var File = /* @__PURE__ */ instanceOf(globalThis.File, { name: String4, lastModified: Int }), transformEffect2({ - decode: (e, options) => match3(decodeBase64(e.data), { + decode: (e, options) => match2(decodeBase64(e.data), { onFailure: () => fail6(new InvalidValue({ expected: "a valid Base64 string" }, e.data, options)), @@ -8133,7 +7936,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { } }); } - static [TypeId21] = TypeId21; + static [TypeId14] = TypeId14; get [ClassTypeId]() { return ClassTypeId; } @@ -8150,7 +7953,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { return getClassSchema(this).rebuild(ast); } static make(input, options) { - return make14(getClassSchema(this))(input ?? {}, options); + return make9(getClassSchema(this))(input ?? {}, options); } static makeOption(input, options) { return makeOption(getClassSchema(this))(input ?? {}, options); @@ -8209,7 +8012,7 @@ function getClassSchemaFactory(from, identifier, annotations) { const ClassTypeId = getClassTypeId(identifier); const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId); const transformation = getClassTransformation(self); - const to = make16(new Declaration([from.ast], () => (input, ast, options) => { + const to = make11(new Declaration([from.ast], () => (input, ast, options) => { return isClassValue(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)); }, { identifier, @@ -8247,120 +8050,336 @@ var TaggedError3 = (identifier) => { return Error4(identifier ?? tagValue)(struct, annotations); }; }; -// src/action/ActionInputs.ts -var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; -var readRawInput = (name) => { - const value = process.env[inputEnvName(name)]; - return value === undefined || value === "" ? undefined : value; +// node_modules/effect/dist/PlatformError.js +var TypeId15 = "~effect/PlatformError"; + +class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { + get message() { + return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; + } +} + +class SystemError extends Error3 { + get message() { + return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; + } +} + +class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { + constructor(reason) { + if ("cause" in reason) { + super({ + reason, + cause: reason.cause + }); + } else { + super({ + reason + }); + } + } + [TypeId15] = TypeId15; + get message() { + return this.reason.message; + } +} +var systemError = (options) => new PlatformError(new SystemError(options)); +var badArgument = (options) => new PlatformError(new BadArgument(options)); + +// node_modules/effect/dist/internal/stream.js +var TypeId16 = "~effect/Stream"; +var streamVariance = { + _R: identity, + _E: identity, + _A: identity }; -var readInputs = (names) => { - const inputs = {}; - for (const name of names) { - const value = readRawInput(name); - if (value !== undefined) - inputs[name] = value; +var Stream = function(channel) { + this.channel = channel; +}; +Stream.prototype = { + [TypeId16]: streamVariance, + pipe() { + return pipeArguments(this, arguments); } - return inputs; }; -var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); +var fromChannel = (channel) => new Stream(channel); -// src/action/ActionOutputs.ts -import { randomBytes } from "node:crypto"; -var githubOutputPath = () => process.env.GITHUB_OUTPUT; -var setOutput = (name, value) => gen2(function* () { - const path = githubOutputPath(); - if (path === undefined) { - yield* sync3(() => { - process.stdout.write(`::set-output name=${name}::${value} -`); - }); - return; +// node_modules/effect/dist/Sink.js +var TypeId17 = "~effect/Sink"; +var endVoid = /* @__PURE__ */ succeed6([undefined]); +var sinkVariance = { + _A: identity, + _In: identity, + _L: identity, + _E: identity, + _R: identity +}; +var SinkProto = { + [TypeId17]: sinkVariance, + pipe() { + return pipeArguments(this, arguments); } - const fs = yield* FileSystem; - const delimiter = `ghadelim_${randomBytes(16).toString("hex")}`; - yield* fs.writeFileString(path, `${name}<<${delimiter} -${value} -${delimiter} -`, { - flag: "a" - }).pipe(orDie2); -}); -// node_modules/effect/dist/Runtime.js -var defaultTeardown = (exit, onExit) => { - if (isSuccess3(exit)) - return onExit(0); - if (hasInterruptsOnly2(exit.cause)) - return onExit(130); - return onExit(getErrorExitCode(squash(exit.cause))); }; -var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { - const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { - if (hasInterruptsOnly2(cause)) +var isSink = (u) => hasProperty(u, TypeId17); +var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ + disableYield: true +})), catchDone(succeed6))); +var fromTransform2 = (transform) => { + const self = Object.create(SinkProto); + self.transform = transform; + return self; +}; +var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done2))); +var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { + disableYield: true +}), () => endVoid)); +var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { + discard: true +})); +var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ + disableYield: true +}), catchDone(() => endVoid))); +var unwrap2 = (effect) => fromChannel2(unwrap(map5(effect, toChannel))); + +// node_modules/effect/dist/internal/rcRef.js +var TypeId18 = "~effect/RcRef"; +var stateEmpty = { + _tag: "Empty" +}; +var stateClosed = { + _tag: "Closed" +}; +var variance2 = { + _A: identity, + _E: identity +}; + +class RcRefImpl { + [TypeId18] = variance2; + pipe() { + return pipeArguments(this, arguments); + } + state = stateEmpty; + semaphore = /* @__PURE__ */ makeUnsafe5(1); + acquire; + context; + scope; + idleTimeToLive; + constructor(acquire, context, scope, idleTimeToLive) { + this.acquire = acquire; + this.context = context; + this.scope = scope; + this.idleTimeToLive = idleTimeToLive; + } +} +var make12 = (options) => withFiber2((fiber) => { + const context = fiber.context; + const scope = get(context, Scope); + const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== undefined ? fromInputUnsafe(options.idleTimeToLive) : undefined); + return as2(addFinalizerExit(scope, () => { + const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; + ref.state = stateClosed; + return close2; + }), ref); +}); +var getState = (self) => uninterruptibleMask2(function loop(restore) { + switch (self.state._tag) { + case "Closed": { + return interrupt2; + } + case "Acquired": { + self.state.refCount++; + return self.state.fiber ? as2(interrupt3(self.state.fiber), self.state) : succeed6(self.state); + } + case "Empty": { + const scope = makeUnsafe3(); + return self.semaphore.withPermit(suspend2(() => { + if (self.state._tag !== "Empty") { + return loop(restore); + } + return restore(provideContext2(self.acquire, add(self.context, Scope, scope))).pipe(flatMap3((value) => { + if (self.state._tag === "Closed") { + return interrupt2; + } + const state = { + _tag: "Acquired", + value, + scope, + fiber: undefined, + refCount: 1, + invalidated: false + }; + self.state = state; + return succeed6(state); + }), onExit2((exit) => isFailure3(exit) ? close(scope, exit) : void_3)); + })); + } + } +}); +var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { + const self = self_; + const state = yield* getState(self); + const scope = yield* scope2; + const isFinite2 = self.idleTimeToLive !== undefined && isFinite(self.idleTimeToLive); + yield* addFinalizerExit(scope, () => { + state.refCount--; + if (state.refCount > 0) { return void_3; - const isReported = getErrorReported(squash(cause)); - return isReported ? logError(cause) : void_3; + } + if (self.idleTimeToLive === undefined || state.invalidated) { + if (self.state === state) { + self.state = stateEmpty; + } + return close(state.scope, void_2); + } else if (!isFinite2) { + return void_3; + } + state.fiber = sleep2(self.idleTimeToLive).pipe(flatMap3(() => { + if (self.state === state && state.refCount === 0) { + self.state = stateEmpty; + return close(state.scope, void_2); + } + return void_3; + }), ensuring2(sync3(() => { + state.fiber = undefined; + })), runForkWith2(self.context), runIn(self.scope)); + return void_3; + }); + return state.value; +}); + +// node_modules/effect/dist/RcRef.js +var make13 = make12; +var get3 = get2; + +// node_modules/effect/dist/Stream.js +var TypeId19 = "~effect/Stream"; +var isStream = (u) => hasProperty(u, TypeId19); +var fromChannel3 = fromChannel; +var fromPull2 = (pull) => fromChannel3(fromPull(pull)); +var transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))); +var toChannel2 = (stream) => stream.channel; +var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); +var empty4 = /* @__PURE__ */ fromChannel3(empty3); +var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); +var unwrap3 = (effect) => fromChannel3(unwrap(map5(effect, toChannel2))); +var map7 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { + let i = 0; + return fromChannel3(map6(self.channel, map((o) => f(o, i++)))); +})); +var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); +var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { + let done; + let leftover; + const upstreamWithLeftover = suspend2(() => { + if (leftover !== undefined) { + const chunk = leftover; + leftover = undefined; + return succeed6(chunk); + } + return upstream; + }).pipe(catch_2((error) => { + done = fail5(error); + return done2(); })); - try { - const keepAlive = globalThis.setInterval(constVoid, 2147483647); - fiber.addObserver(() => { - clearInterval(keepAlive); - }); - } catch {} - const teardown = options?.teardown ?? defaultTeardown; - return f({ - fiber, - teardown + const pull = map5(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { + leftover = leftover_; + return of(value); }); -}); -var errorExitCode = "~effect/Runtime/errorExitCode"; -var getErrorExitCode = (u) => { - if (typeof u === "object" && u !== null && errorExitCode in u) { - const code = u[errorExitCode]; - if (typeof code === "number") { - return code; - } + return suspend2(() => done ? done : pull); +}))); +var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { + const decoder = new TextDecoder(options?.encoding); + return map7(self, (chunk) => decoder.decode(chunk, { + stream: true + })); +})); +var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); +var run2 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map5(([a]) => a)))); +var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { + for (let i = 0;i < chunk.length; i++) { + acc.push(chunk[i]); } - return 1; -}; -var errorReported = "~effect/Runtime/errorReported"; -var getErrorReported = (u) => { - if (typeof u === "object" && u !== null && errorReported in u) { - const isReported = u[errorReported]; - if (typeof isReported === "boolean") { - return isReported; - } + return acc; +}); +var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channel, initial, (acc, arr) => { + for (let i = 0;i < arr.length; i++) { + acc = f(acc, arr[i]); } - return true; -}; + return acc; +})); +var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => { + let i = 0; + return whileLoop2({ + while: () => i < arr.length, + body: () => f(arr[i++]), + step: constVoid + }); +})); +var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); -// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js -var runMain = /* @__PURE__ */ makeRunMain(({ - fiber, - teardown -}) => { - let receivedSignal = false; - fiber.addObserver((exit) => { - process.removeListener("SIGINT", onSigint); - process.removeListener("SIGTERM", onSigint); - teardown(exit, (code) => { - if (receivedSignal || code !== 0) { - process.exit(code); - } +// node_modules/effect/dist/FileSystem.js +var TypeId20 = "~effect/FileSystem"; +var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); +var make14 = (impl) => FileSystem.of({ + ...impl, + [TypeId20]: TypeId20, + exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), + readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ + try: () => new TextDecoder(encoding).decode(_), + catch: (cause) => badArgument({ + module: "FileSystem", + method: "readFileString", + description: "invalid encoding", + cause + }) + })), + stream: fnUntraced2(function* (path, options) { + const file = yield* impl.open(path, { + flag: "r" }); - }); - function onSigint() { - receivedSignal = true; - fiber.interruptUnsafe(fiber.id); - } - process.on("SIGINT", onSigint); - process.on("SIGTERM", onSigint); + const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset); + if (offset) { + yield* file.seek(offset, "start"); + } + const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead); + let totalBytesRead = BigInt(0); + const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024)); + const readChunk = file.readAlloc(chunkSize); + return fromPull2(succeed6(flatMap3(suspend2(() => { + if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { + return done2(); + } + return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; + }), match({ + onNone: () => done2(), + onSome: (buf) => { + totalBytesRead += BigInt(buf.length); + return succeed6(of(buf)); + } + })))); + }, unwrap3), + sink: (path, options) => pipe(impl.open(path, { + ...options, + flag: options?.flag ?? "w" + }), map5((file) => forEach3((_) => file.writeAll(_))), unwrap2), + writeFileString: (path, data, options) => flatMap3(try_2({ + try: () => new TextEncoder().encode(data), + catch: (cause) => badArgument({ + module: "FileSystem", + method: "writeFileString", + description: "could not encode string", + cause + }) + }), (_) => impl.writeFile(path, _, options)) }); +var FileTypeId = "~effect/FileSystem/File"; +class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBackend")) { +} -// node_modules/@effect/platform-node/dist/NodeRuntime.js -var runMain2 = runMain; // node_modules/effect/dist/Path.js -var TypeId22 = "~effect/Path"; -var Path2 = /* @__PURE__ */ Service("effect/Path"); +var TypeId21 = "~effect/Path"; +var Path = /* @__PURE__ */ Service("effect/Path"); function normalizeStringPosix(path, allowAboveRoot) { let res = ""; let lastSegmentLength = 0; @@ -8466,7 +8485,7 @@ function fromFileUrl(url) { } return succeed6(decodeURIComponent(pathname)); } -var resolve2 = function resolve() { +var resolve3 = function resolve() { let resolvedPath = ""; let resolvedAbsolute = false; let cwd = undefined; @@ -8503,7 +8522,7 @@ var resolve2 = function resolve() { var CHAR_FORWARD_SLASH = 47; function toFileUrl(filepath) { const outURL = new URL("file://"); - let resolved = resolve2(filepath); + let resolved = resolve3(filepath); const filePathLast = filepath.charCodeAt(filepath.length - 1); if (filePathLast === CHAR_FORWARD_SLASH && resolved[resolved.length - 1] !== "/") { resolved += "/"; @@ -8535,9 +8554,9 @@ function encodePathChars(filepath) { } return filepath; } -var posixImpl = /* @__PURE__ */ Path2.of({ - [TypeId22]: TypeId22, - resolve: resolve2, +var posixImpl = /* @__PURE__ */ Path.of({ + [TypeId21]: TypeId21, + resolve: resolve3, normalize(path) { if (path.length === 0) return "."; @@ -8813,44 +8832,303 @@ var posixImpl = /* @__PURE__ */ Path2.of({ preDotState = -1; } } - if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - if (end !== -1) { - if (startPart === 0 && isAbsolute) - ret.base = ret.name = path.slice(1, end); - else - ret.base = ret.name = path.slice(startPart, end); - } - } else { - if (startPart === 0 && isAbsolute) { - ret.name = path.slice(1, startDot); - ret.base = path.slice(1, end); - } else { - ret.name = path.slice(startPart, startDot); - ret.base = path.slice(startPart, end); - } - ret.ext = path.slice(startDot, end); + if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + if (end !== -1) { + if (startPart === 0 && isAbsolute) + ret.base = ret.name = path.slice(1, end); + else + ret.base = ret.name = path.slice(startPart, end); + } + } else { + if (startPart === 0 && isAbsolute) { + ret.name = path.slice(1, startDot); + ret.base = path.slice(1, end); + } else { + ret.name = path.slice(startPart, startDot); + ret.base = path.slice(startPart, end); + } + ret.ext = path.slice(startDot, end); + } + if (startPart > 0) + ret.dir = path.slice(0, startPart - 1); + else if (isAbsolute) + ret.dir = "/"; + return ret; + }, + sep: "/", + fromFileUrl, + toFileUrl, + toNamespacedPath: identity +}); +// node_modules/effect/dist/internal/ulid.js +var maxTimestamp = 2 ** 48 - 1; +var base32Chars = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; +var ulidString = (timestampMillis, bytes) => { + if (bytes.length !== 10) { + throw new Error(`ULID randomness must be exactly 10 bytes, received ${bytes.length}`); + } + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxTimestamp); + let out = ""; + for (let shift = 45;shift >= 0; shift -= 5) { + out += base32Chars[Math.floor(timestamp / 2 ** shift) & 31]; + } + let accumulator = 0; + let bits = 0; + for (const byte of bytes) { + accumulator = accumulator << 8 | byte; + bits += 8; + while (bits >= 5) { + bits -= 5; + out += base32Chars[accumulator >>> bits & 31]; + } + accumulator &= (1 << bits) - 1; + } + return out; +}; + +// node_modules/effect/dist/internal/uuid.js +var hex = (byte) => byte.toString(16).padStart(2, "0"); +var stringify = (bytes) => { + const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; + return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); +}; +var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); +function v4Bytes(bytes = randomBytes()) { + bytes[6] = bytes[6] & 15 | 64; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); +var maxV7Timestamp = 2 ** 48 - 1; +function v7Bytes(timestampMillis, bytes = randomBytes()) { + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); + bytes[0] = Math.floor(timestamp / 2 ** 40); + bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; + bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; + bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; + bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; + bytes[5] = timestamp & 255; + bytes[6] = bytes[6] & 15 | 112; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); + +// node_modules/effect/dist/Crypto.js +var TypeId22 = "~effect/Crypto"; +var Crypto = /* @__PURE__ */ Service("effect/Crypto"); +var make15 = (impl) => { + const randomBytesUnsafe = impl.randomBytes; + const randomBytes = (size) => map5(validateSize("randomBytes", size), randomBytesUnsafe); + const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; + const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; + const nextIntUnsafe = () => { + while (true) { + const bytes = randomBytesUnsafe(7); + const value = readUint53(bytes); + if ((bytes[0] & 32) === 0) { + return value + Number.MIN_SAFE_INTEGER; + } + if (value < Number.MAX_SAFE_INTEGER) { + return value + 1; + } + } + }; + return Crypto.of({ + [TypeId22]: TypeId22, + randomBytes, + nextDoubleUnsafe, + nextIntUnsafe, + digest: impl.digest, + random: sync3(() => nextDoubleUnsafe()), + randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), + randomInt: sync3(() => nextIntUnsafe()), + randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), + randomIntBetween(min, max, options) { + const extra = options?.halfOpen === true ? 0 : 1; + return sync3(() => { + const minInt = Math.ceil(min); + const maxInt = Math.floor(max); + return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; + }); + }, + randomShuffle: (elements) => sync3(() => { + const buffer = Array.from(elements); + for (let i = buffer.length - 1;i >= 1; i = i - 1) { + const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); + const value = buffer[i]; + buffer[i] = buffer[index]; + buffer[index] = value; + } + return buffer; + }), + randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), + randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))), + randomULID: clockWith2((clock) => succeed6(ulidString(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(10)))) + }); +}; +var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ + module: "Crypto", + method, + description: "size must be a non-negative safe integer" +})); +// node_modules/effect/dist/Ref.js +var TypeId23 = "~effect/Ref"; +var RefProto = { + [TypeId23]: { + _A: identity + }, + ...PipeInspectableProto, + toJSON() { + return { + _id: "Ref", + ref: this.ref + }; + } +}; +var makeUnsafe6 = (value) => { + const self = Object.create(RefProto); + self.ref = make6(value); + return self; +}; +var make16 = (value) => sync3(() => makeUnsafe6(value)); +var get4 = (self) => sync3(() => self.ref.current); +var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { + self.ref.current = f(self.ref.current); +})); +// node_modules/effect/dist/Runtime.js +var defaultTeardown = (exit, onExit) => { + if (isSuccess3(exit)) + return onExit(0); + if (hasInterruptsOnly2(exit.cause)) + return onExit(130); + return onExit(getErrorExitCode(squash(exit.cause))); +}; +var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { + const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { + if (hasInterruptsOnly2(cause)) + return void_3; + const isReported = getErrorReported(squash(cause)); + return isReported ? logError(cause) : void_3; + })); + try { + const keepAlive = globalThis.setInterval(constVoid, 2147483647); + fiber.addObserver(() => { + clearInterval(keepAlive); + }); + } catch {} + const teardown = options?.teardown ?? defaultTeardown; + return f({ + fiber, + teardown + }); +}); +var errorExitCode = "~effect/Runtime/errorExitCode"; +var getErrorExitCode = (u) => { + if (typeof u === "object" && u !== null && errorExitCode in u) { + const code = u[errorExitCode]; + if (typeof code === "number") { + return code; + } + } + return 1; +}; +var errorReported = "~effect/Runtime/errorReported"; +var getErrorReported = (u) => { + if (typeof u === "object" && u !== null && errorReported in u) { + const isReported = u[errorReported]; + if (typeof isReported === "boolean") { + return isReported; } - if (startPart > 0) - ret.dir = path.slice(0, startPart - 1); - else if (isAbsolute) - ret.dir = "/"; - return ret; - }, - sep: "/", - fromFileUrl, - toFileUrl, - toNamespacedPath: identity + } + return true; +}; +// node_modules/effect/dist/Stdio.js +var TypeId24 = "~effect/Stdio"; +var Stdio = /* @__PURE__ */ Service(TypeId24); +var make17 = (options) => ({ + [TypeId24]: TypeId24, + stdinIsTerminal: succeed6(false), + stdoutIsTerminal: succeed6(false), + ...options }); +// node_modules/effect/dist/Terminal.js +var TypeId25 = "~effect/Terminal"; +var QuitErrorTypeId = "~effect/Terminal/QuitError"; -// node_modules/effect/dist/Brand.js -function nominal() { - return Object.assign((input) => input, { - option: (input) => some2(input), - result: (input) => succeed2(input), - is: (_) => true - }); +class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ + _tag: /* @__PURE__ */ tag("QuitError") +})) { + [QuitErrorTypeId] = QuitErrorTypeId; } +var Terminal = /* @__PURE__ */ Service("effect/Terminal"); +var make18 = (impl) => Terminal.of({ + ...impl, + [TypeId25]: TypeId25 +}); +// src/action/ActionInputs.ts +var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; +var readRawInput = (name) => { + const value = process.env[inputEnvName(name)]; + return value === undefined || value === "" ? undefined : value; +}; +var readInputs = (names) => { + const inputs = {}; + for (const name of names) { + const value = readRawInput(name); + if (value !== undefined) + inputs[name] = value; + } + return inputs; +}; +var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); + +// src/action/ActionOutputs.ts +import { randomBytes as randomBytes2 } from "node:crypto"; +var githubOutputPath = () => process.env.GITHUB_OUTPUT; +var setOutput = (name, value) => gen2(function* () { + const path = githubOutputPath(); + if (path === undefined) { + yield* sync3(() => { + process.stdout.write(`::set-output name=${name}::${value} +`); + }); + return; + } + const fs = yield* FileSystem; + const delimiter = `ghadelim_${randomBytes2(16).toString("hex")}`; + yield* fs.writeFileString(path, `${name}<<${delimiter} +${value} +${delimiter} +`, { + flag: "a" + }).pipe(orDie2); +}); +// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js +var runMain = /* @__PURE__ */ makeRunMain(({ + fiber, + teardown +}) => { + let receivedSignal = false; + fiber.addObserver((exit) => { + process.removeListener("SIGINT", onSigint); + process.removeListener("SIGTERM", onSigint); + teardown(exit, (code) => { + if (receivedSignal || code !== 0) { + process.exit(code); + } + }); + }); + function onSigint() { + receivedSignal = true; + fiber.interruptUnsafe(fiber.id); + } + process.on("SIGINT", onSigint); + process.on("SIGTERM", onSigint); +}); +// node_modules/@effect/platform-node/dist/NodeRuntime.js +var runMain2 = runMain; // node_modules/effect/dist/unstable/process/ChildProcessSpawner.js var ExitCode = /* @__PURE__ */ nominal(); var ProcessId = /* @__PURE__ */ nominal(); @@ -8868,8 +9146,8 @@ var HandleProto = { var makeHandle = (params) => Object.setPrototypeOf({ ...params }, HandleProto); -var make17 = (spawn) => { - const streamString = (command, options) => spawn(command).pipe(map6((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); +var make19 = (spawn) => { + const streamString = (command, options) => spawn(command).pipe(map5((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); const streamLines = (command, options) => splitLines2(streamString(command, options)); return ChildProcessSpawner.of({ spawn, @@ -8885,7 +9163,7 @@ class ChildProcessSpawner extends (/* @__PURE__ */ Service()("effect/process/Chi } // node_modules/effect/dist/unstable/process/ChildProcess.js -var TypeId23 = "~effect/process/ChildProcess"; +var TypeId26 = "~effect/process/ChildProcess"; var Proto2 = { .../* @__PURE__ */ Prototype2({ label: "Command", @@ -8893,7 +9171,7 @@ var Proto2 = { return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this); } }), - [TypeId23]: TypeId23 + [TypeId26]: TypeId26 }; var makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto2), { _tag: "StandardCommand", @@ -8901,7 +9179,7 @@ var makeStandardCommand = (command, args, options) => Object.assign(Object.creat args, options }); -var make18 = function make(...args) { +var make20 = function make(...args) { if (isTemplateString(args[0])) { const [templates, ...expressions] = args; const tokens = parseTemplates(templates, expressions); @@ -9107,10 +9385,10 @@ var pullIntoWritable = (options) => options.pull.pipe(flatMap3((chunk) => { disableYield: true }), options.endOnDone !== false ? catchDone((_) => { if ("closed" in options.writable && options.writable.closed) { - return done3(_); + return done2(_); } return callback2((resume) => { - const onFinish = () => resume(done3(_)); + const onFinish = () => resume(done2(_)); options.writable.once("finish", onFinish); options.writable.end(); return sync3(() => { @@ -9143,11 +9421,11 @@ var readableToPullUnsafe = (options) => { latch.openUnsafe(); } function onError(error) { - exit.current = fail4(options.onError(error)); + exit.current = fail5(options.onError(error)); latch.openUnsafe(); } function onEnd() { - exit.current = fail4(Done2()); + exit.current = fail5(Done2()); latch.openUnsafe(); } readable.on("readable", onReadable); @@ -9216,9 +9494,9 @@ var isProcessAlive = (childProcess, exitSignal) => { var taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { windowsHide: true }, onExit); -var make19 = /* @__PURE__ */ gen2(function* () { +var make21 = /* @__PURE__ */ gen2(function* () { const fs = yield* FileSystem; - const path = yield* Path2; + const path = yield* Path; const resolveWorkingDirectory = fnUntraced2(function* (options) { if (isUndefined(options.cwd)) return; @@ -9339,7 +9617,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { }); } if (config.stream) { - yield* forkScoped2(run(config.stream, sink)); + yield* forkScoped2(run2(config.stream, sink)); } inputSinks.set(fd, sink); break; @@ -9379,7 +9657,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { }); } if (isStream(config.stream)) { - return as2(forkScoped2(run(config.stream, sink)), sink); + return as2(forkScoped2(run2(config.stream, sink)), sink); } return succeed6(sink); }); @@ -9535,7 +9813,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { env, stdio }, process.platform)), fnUntraced2(function* ([childProcess, exitSignal]) { - const exited = yield* isDone2(exitSignal); + const exited = yield* isDone3(exitSignal); if (exited) { const [code] = yield* _await(exitSignal); if (code !== 0 && isNotNull(code)) { @@ -9577,7 +9855,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds); - const isRunning = map6(isDone2(exitSignal), (done) => !done); + const isRunning = map5(isDone3(exitSignal), (done) => !done); const exitCode = flatMap3(_await(exitSignal), ([code, signal]) => { if (isNotNull(code)) { return succeed6(ExitCode(code)); @@ -9614,7 +9892,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { const sourceStream = unwrap3(succeed6(getSourceStream(handles[handles.length - 1], options.from))); const toOption = options.to ?? "stdin"; if (toOption === "stdin") { - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -9626,7 +9904,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { if (isNotUndefined(fd)) { const fdName2 = fdName(fd); const existingFds = command.options.additionalFds ?? {}; - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, additionalFds: { ...existingFds, @@ -9637,7 +9915,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { } }))); } else { - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -9676,9 +9954,9 @@ var make19 = /* @__PURE__ */ gen2(function* () { } } }); - return make17(spawnCommand); + return make19(spawnCommand); }); -var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make19); +var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make21); var flattenCommand = (command) => { const commands = []; const pipeOptions = []; @@ -9708,92 +9986,6 @@ var flattenCommand = (command) => { }; }; -// node_modules/effect/dist/internal/uuid.js -var hex = (byte) => byte.toString(16).padStart(2, "0"); -var stringify = (bytes) => { - const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; - return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); -}; -var randomBytes2 = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); -function v4Bytes(bytes = randomBytes2()) { - bytes[6] = bytes[6] & 15 | 64; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); -var maxV7Timestamp = 2 ** 48 - 1; -function v7Bytes(timestampMillis, bytes = randomBytes2()) { - const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); - bytes[0] = Math.floor(timestamp / 2 ** 40); - bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; - bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; - bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; - bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; - bytes[5] = timestamp & 255; - bytes[6] = bytes[6] & 15 | 112; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); - -// node_modules/effect/dist/Crypto.js -var TypeId24 = "~effect/Crypto"; -var Crypto2 = /* @__PURE__ */ Service("effect/Crypto"); -var make20 = (impl) => { - const randomBytesUnsafe = impl.randomBytes; - const randomBytes = (size) => map6(validateSize("randomBytes", size), randomBytesUnsafe); - const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; - const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; - const nextIntUnsafe = () => { - while (true) { - const bytes = randomBytesUnsafe(7); - const value = readUint53(bytes); - if ((bytes[0] & 32) === 0) { - return value + Number.MIN_SAFE_INTEGER; - } - if (value < Number.MAX_SAFE_INTEGER) { - return value + 1; - } - } - }; - return Crypto2.of({ - [TypeId24]: TypeId24, - randomBytes, - nextDoubleUnsafe, - nextIntUnsafe, - digest: impl.digest, - random: sync3(() => nextDoubleUnsafe()), - randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), - randomInt: sync3(() => nextIntUnsafe()), - randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), - randomIntBetween(min, max, options) { - const extra = options?.halfOpen === true ? 0 : 1; - return sync3(() => { - const minInt = Math.ceil(min); - const maxInt = Math.floor(max); - return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; - }); - }, - randomShuffle: (elements) => sync3(() => { - const buffer = Array.from(elements); - for (let i = buffer.length - 1;i >= 1; i = i - 1) { - const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); - const value = buffer[i]; - buffer[i] = buffer[index]; - buffer[index] = value; - } - return buffer; - }), - randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), - randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))) - }); -}; -var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ - module: "Crypto", - method, - description: "size must be a non-negative safe integer" -})); - // node_modules/@effect/platform-node-shared/dist/NodeCrypto.js import * as NodeCrypto from "node:crypto"; var toHashAlgorithm = (algorithm) => { @@ -9818,20 +10010,20 @@ var digest = (algorithm, data) => try_2({ cause }) }); -var make21 = /* @__PURE__ */ make20({ +var make22 = /* @__PURE__ */ make15({ randomBytes: NodeCrypto.randomBytes, digest }); -var layer2 = /* @__PURE__ */ succeed5(Crypto2, make21); +var layer2 = /* @__PURE__ */ succeed5(Crypto, make22); // node_modules/@effect/platform-node/dist/NodeCrypto.js var layer3 = layer2; // node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js -import * as Crypto3 from "node:crypto"; +import * as Crypto2 from "node:crypto"; import * as NFS from "node:fs"; import * as OS from "node:os"; -import * as Path3 from "node:path"; +import * as Path2 from "node:path"; var handleBadArgument = (method) => (err) => badArgument({ module: "FileSystem", method, @@ -9904,8 +10096,8 @@ var makeTempDirectoryFactory = (method) => { const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException("FileSystem", method), handleBadArgument(method)); return (options) => suspend2(() => { const prefix = options?.prefix ?? ""; - const directory = typeof options?.directory === "string" ? Path3.join(options.directory, ".") : OS.tmpdir(); - return nodeMkdtemp(prefix ? Path3.join(directory, prefix) : directory + "/"); + const directory = typeof options?.directory === "string" ? Path2.join(options.directory, ".") : OS.tmpdir(); + return nodeMkdtemp(prefix ? Path2.join(directory, prefix) : directory + "/"); }); }; var makeTempDirectory = /* @__PURE__ */ makeTempDirectoryFactory("makeTempDirectory"); @@ -9927,7 +10119,7 @@ var makeTempDirectoryScoped = /* @__PURE__ */ (() => { var openFactory = (method) => { const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method)); const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method)); - return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map6((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); + return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map5((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); }; var open2 = /* @__PURE__ */ openFactory("open"); var makeFile = /* @__PURE__ */ (() => { @@ -9976,7 +10168,7 @@ var makeFile = /* @__PURE__ */ (() => { read(buffer) { return suspend2(() => { const position = this.position; - return map6(nodeRead(this.fd, { + return map5(nodeRead(this.fd, { buffer, position }), (bytesRead) => { @@ -9993,7 +10185,7 @@ var makeFile = /* @__PURE__ */ (() => { } const buffer = Buffer.allocUnsafeSlow(size); const position = this.position; - return map6(nodeReadAlloc(this.fd, { + return map5(nodeReadAlloc(this.fd, { buffer, position }), (bytesRead) => { @@ -10014,7 +10206,7 @@ var makeFile = /* @__PURE__ */ (() => { }); } truncate(length) { - return map6(nodeTruncate(this.fd, length || undefined), () => { + return map5(nodeTruncate(this.fd, length || undefined), () => { if (!this.append) { const len = BigInt(length ?? 0); if (this.position > len) { @@ -10026,7 +10218,7 @@ var makeFile = /* @__PURE__ */ (() => { write(buffer) { return suspend2(() => { const position = this.position; - return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map6(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { + return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map5(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { if (!this.append) { this.position = position + BigInt(bytesWritten); } @@ -10064,8 +10256,8 @@ var makeTempFileFactory = (method) => { const makeDirectory = makeTempDirectoryFactory(method); return fnUntraced2(function* (options) { const directory = yield* makeDirectory(options); - const random = Crypto3.randomBytes(6).toString("hex"); - const name = Path3.join(directory, options?.suffix ? `${random}${options.suffix}` : random); + const random = Crypto2.randomBytes(6).toString("hex"); + const name = Path2.join(directory, options?.suffix ? `${random}${options.suffix}` : random); yield* writeFile2(name, new Uint8Array(0)); return name; }); @@ -10074,7 +10266,7 @@ var makeTempFile = /* @__PURE__ */ makeTempFileFactory("makeTempFile"); var makeTempFileScoped = /* @__PURE__ */ (() => { const makeFile = /* @__PURE__ */ makeTempFileFactory("makeTempFileScoped"); const removeDirectory = /* @__PURE__ */ removeFactory("makeTempFileScoped"); - return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path3.dirname(file), { + return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path2.dirname(file), { recursive: true }))); })(); @@ -10147,7 +10339,7 @@ var utimes2 = /* @__PURE__ */ (() => { return (path, atime, mtime) => nodeUtimes(path, atime, mtime); })(); var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sync3(() => { - const directory = info.type === "Directory" ? path : Path3.dirname(path); + const directory = info.type === "Directory" ? path : Path2.dirname(path); const watcher = NFS.watch(path, { recursive: options?.recursive ?? false }, (event, path) => { @@ -10155,7 +10347,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy return; switch (event) { case "rename": { - runFork2(matchEffect3(stat2(Path3.resolve(directory, path)), { + runFork2(matchEffect3(stat2(Path2.resolve(directory, path)), { onSuccess: (_) => offer(queue, { _tag: "Create", path @@ -10177,7 +10369,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy } }); watcher.on("error", (error) => { - failCauseUnsafe(queue, fail5(systemError({ + failCauseUnsafe(queue, fail4(systemError({ module: "FileSystem", _tag: "Unknown", method: "watch", @@ -10190,7 +10382,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy }); return watcher; }), (watcher) => sync3(() => watcher.close()))); -var watch2 = (backend, path, options) => stat2(path).pipe(map6((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); +var watch2 = (backend, path, options) => stat2(path).pipe(map5((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); var writeFile2 = (path, data, options) => callback2((resume, signal) => { try { NFS.writeFile(path, data, { @@ -10208,7 +10400,7 @@ var writeFile2 = (path, data, options) => callback2((resume, signal) => { resume(fail6(handleBadArgument("writeFile")(err))); } }); -var makeFileSystem = /* @__PURE__ */ map6(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make11({ +var makeFileSystem = /* @__PURE__ */ map5(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make14({ access: access2, chmod: chmod2, chown: chown2, @@ -10267,18 +10459,18 @@ var fileUrlOps = (windows) => ({ }) }) }); -var layerPosix = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layerPosix = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.posix, .../* @__PURE__ */ fileUrlOps(false) }); -var layerWin32 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layerWin32 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.win32, .../* @__PURE__ */ fileUrlOps(true) }); -var layer6 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layer6 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath, .../* @__PURE__ */ fileUrlOps(undefined) }); @@ -10286,18 +10478,8 @@ var layer6 = /* @__PURE__ */ succeed5(Path2)({ // node_modules/@effect/platform-node/dist/NodePath.js var layer7 = layer6; -// node_modules/effect/dist/Stdio.js -var TypeId25 = "~effect/Stdio"; -var Stdio2 = /* @__PURE__ */ Service(TypeId25); -var make22 = (options) => ({ - [TypeId25]: TypeId25, - stdinIsTerminal: succeed6(false), - stdoutIsTerminal: succeed6(false), - ...options -}); - // node_modules/@effect/platform-node-shared/dist/NodeStdio.js -var layer8 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make22({ +var layer8 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make17({ args: /* @__PURE__ */ sync3(() => process.argv.slice(2)), stdinIsTerminal: /* @__PURE__ */ sync3(() => process.stdin.isTTY === true), stdoutIsTerminal: /* @__PURE__ */ sync3(() => process.stdout.isTTY === true), @@ -10336,24 +10518,9 @@ var layer8 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make22({ // node_modules/@effect/platform-node/dist/NodeStdio.js var layer9 = layer8; -// node_modules/effect/dist/Terminal.js -var TypeId26 = "~effect/Terminal"; -var QuitErrorTypeId = "~effect/Terminal/QuitError"; - -class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ - _tag: /* @__PURE__ */ tag("QuitError") -})) { - [QuitErrorTypeId] = QuitErrorTypeId; -} -var Terminal2 = /* @__PURE__ */ Service("effect/Terminal"); -var make23 = (impl) => Terminal2.of({ - ...impl, - [TypeId26]: TypeId26 -}); - // node_modules/@effect/platform-node-shared/dist/NodeTerminal.js import * as readline from "node:readline"; -var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { +var make23 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { const stdin = process.stdin; const stdout = process.stdout; const lines = yield* make8(); @@ -10367,7 +10534,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu }; stdin.once("end", onStdinEnd); yield* addFinalizer3(() => sync3(() => stdin.off("end", onStdinEnd))); - const rlRef = yield* make10({ + const rlRef = yield* make13({ acquire: acquireRelease2(sync3(() => { const rl = readline.createInterface({ input: stdin, @@ -10458,7 +10625,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu cause: err })))); })); - return make23({ + return make18({ columns, rows, readInput, @@ -10466,7 +10633,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu display }); }); -var layer10 = /* @__PURE__ */ effect(Terminal2, /* @__PURE__ */ make24(defaultShouldQuit)); +var layer10 = /* @__PURE__ */ effect(Terminal, /* @__PURE__ */ make23(defaultShouldQuit)); function defaultShouldQuit(input) { return input.key.ctrl && (input.key.name === "c" || input.key.name === "d"); } @@ -10521,7 +10688,7 @@ var layer13 = sync2(Service2, () => { class TestService extends Service()("@timmo001/workflows/Annotations/Test") { } var testLayer = effectContext(gen2(function* () { - const recorded = yield* make12([]); + const recorded = yield* make16([]); const write = (line) => update(recorded, (lines) => [...lines, line]); const service = TestService.of({ error: fn2("Annotations.Test.error")(function* (message, properties) { @@ -10543,7 +10710,7 @@ var testLayer = effectContext(gen2(function* () { return yield* get4(recorded); }) }); - return empty().pipe(add(Service2, service), add(TestService, service)); + return empty2().pipe(add(Service2, service), add(TestService, service)); })); class ActionFailure extends TaggedError3()("ActionFailure", { @@ -10566,7 +10733,7 @@ class Service3 extends Service()("@timmo001/workflows/CommandExecutor") { } var layer14 = effect(Service3, gen2(function* () { const spawner = yield* ChildProcessSpawner; - const make = (command, args, options) => make18(command, args, { + const make = (command, args, options) => make20(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true @@ -10605,7 +10772,7 @@ var layer14 = effect(Service3, gen2(function* () { const stream = fn2("CommandExecutor.stream")(function* (command, args, options) { const label = options?.label ?? `${command} ${args.join(" ")}`.trim(); return yield* scoped2(gen2(function* () { - const handle = yield* spawner.spawn(make18(command, args, { + const handle = yield* spawner.spawn(make20(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true, diff --git a/.github/actions/publish-aur/dist/index.js b/.github/actions/publish-aur/dist/index.js index 2fc25348..bb34df12 100644 --- a/.github/actions/publish-aur/dist/index.js +++ b/.github/actions/publish-aur/dist/index.js @@ -487,6 +487,33 @@ function makeCompareSet(equivalence) { var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth); var isEqual = (u) => hasProperty(u, symbol2); +// node_modules/effect/dist/internal/array.js +var isArrayNonEmpty = (self) => self.length > 0; + +// node_modules/effect/dist/internal/count.js +var normalize = (n) => n > 0 ? Math.floor(n) : 0; + +// node_modules/effect/dist/internal/record.js +function assignProperty(self, key, value) { + if (key === "__proto__") { + Object.defineProperty(self, key, { + value, + writable: true, + enumerable: true, + configurable: true + }); + } else { + self[key] = value; + } +} +function assignProperties(self, source) { + for (const key of Reflect.ownKeys(source)) { + if (Object.prototype.propertyIsEnumerable.call(source, key)) { + assignProperty(self, key, source[key]); + } + } +} + // node_modules/effect/dist/Redactable.js var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Redactable"); var isRedactable = (u) => hasProperty(u, symbolRedactable); @@ -729,27 +756,6 @@ var pickInternalCall = () => { }; var internalCall = /* @__PURE__ */ pickInternalCall(); -// node_modules/effect/dist/internal/record.js -function assignProperty(self, key, value) { - if (key === "__proto__") { - Object.defineProperty(self, key, { - value, - writable: true, - enumerable: true, - configurable: true - }); - } else { - self[key] = value; - } -} -function assignProperties(self, source) { - for (const key of Reflect.ownKeys(source)) { - if (Object.prototype.propertyIsEnumerable.call(source, key)) { - assignProperty(self, key, source[key]); - } - } -} - // node_modules/effect/dist/internal/core.js var EffectTypeId = `~effect/Effect`; var ExitTypeId = `~effect/Exit`; @@ -1118,12 +1124,6 @@ var done = (value) => { return exitFail(Done(value)); }; -// node_modules/effect/dist/Effectable.js -var Prototype2 = (options) => makePrimitiveProto({ - op: options.label, - [evaluate]: options.evaluate -}); - // node_modules/effect/dist/internal/option.js var TypeId = "~effect/Option"; var CommonProto = { @@ -1285,9 +1285,40 @@ var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone var fromNullishOr = (a) => a == null ? none2() : some2(a); var fromUndefinedOr = (a) => a === undefined ? none2() : some2(a); var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined); -var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value))); var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value)); -var filter = /* @__PURE__ */ dual(2, (self, predicate) => isNone2(self) ? none2() : predicate(self.value) ? some2(self.value) : none2()); + +// node_modules/effect/dist/Result.js +var succeed2 = succeed; +var fail2 = fail; +var isFailure2 = isFailure; +var match2 = /* @__PURE__ */ dual(2, (self, { + onFailure, + onSuccess +}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); + +// node_modules/effect/dist/Array.js +var Array2 = globalThis.Array; +var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); +var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); +var isArray = Array2.isArray; +var isArrayNonEmpty2 = isArrayNonEmpty; +var isReadonlyArrayNonEmpty = isArrayNonEmpty; +var empty = () => []; +var of = (a) => [a]; +var map = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); +// node_modules/effect/dist/BigInt.js +var BigInt2 = globalThis.BigInt; +var toNumber = (b) => { + if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { + return none2(); + } + return some2(Number(b)); +}; +// node_modules/effect/dist/Effectable.js +var Prototype2 = (options) => makePrimitiveProto({ + op: options.label, + [evaluate]: options.evaluate +}); // node_modules/effect/dist/Context.js var ServiceTypeId = "~effect/Context/Service"; @@ -1428,7 +1459,7 @@ var Proto = { var hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot; var isContext = (u) => hasProperty(u, TypeId3); var isReference = (u) => !!u[ReferenceTypeId]; -var empty = () => emptyContext2; +var empty2 = () => emptyContext2; var emptyContext2 = /* @__PURE__ */ makeUnsafe(/* @__PURE__ */ new Map); var make2 = (key, service) => makeUnsafe(new Map([[key.key, service]])); var add = /* @__PURE__ */ dual(3, (self, key, service) => addUnsafe(self, key.key, service)); @@ -1502,6 +1533,7 @@ var mergeAll = (...ctxs) => { return makeUnsafe(map); }; var Reference = Service; + // node_modules/effect/dist/Duration.js var TypeId4 = "~effect/Duration"; var bigint0 = /* @__PURE__ */ BigInt(0); @@ -1725,7 +1757,7 @@ var minutes = (minutes) => make3(minutes * 60000); var hours = (hours) => make3(hours * 3600000); var days = (days) => make3(days * 86400000); var weeks = (weeks) => make3(weeks * 604800000); -var toMillis = (self) => match2(fromInputUnsafe(self), { +var toMillis = (self) => match3(fromInputUnsafe(self), { onMillis: identity, onNanos: (nanos) => Number(nanos) / 1e6, onInfinity: () => Infinity, @@ -1743,7 +1775,7 @@ var toNanosUnsafe = (input) => { return roundMillisToNanos(self.value.millis); } }; -var match2 = /* @__PURE__ */ dual(2, (self, options) => { +var match3 = /* @__PURE__ */ dual(2, (self, options) => { switch (self.value._tag) { case "Millis": return options.onMillis(self.value.millis); @@ -1771,32 +1803,6 @@ var Equivalence = (self, that) => matchPair(self, that, { }); var equals2 = /* @__PURE__ */ dual(2, (self, that) => Equivalence(self, that)); -// node_modules/effect/dist/internal/array.js -var isArrayNonEmpty = (self) => self.length > 0; - -// node_modules/effect/dist/internal/count.js -var normalize = (n) => n > 0 ? Math.floor(n) : 0; - -// node_modules/effect/dist/Result.js -var succeed2 = succeed; -var fail2 = fail; -var isFailure2 = isFailure; -var match3 = /* @__PURE__ */ dual(2, (self, { - onFailure, - onSuccess -}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); - -// node_modules/effect/dist/Array.js -var Array2 = globalThis.Array; -var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); -var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); -var isArray = Array2.isArray; -var isArrayNonEmpty2 = isArrayNonEmpty; -var isReadonlyArrayNonEmpty = isArrayNonEmpty; -var empty2 = () => []; -var of = (a) => [a]; -var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); - // node_modules/effect/dist/Scheduler.js var Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", { fiberCached: true, @@ -2543,7 +2549,7 @@ class FiberImpl { } this._stack.length = 0; this._children = undefined; - this.context = empty(); + this.context = empty2(); } runLoop(effect) { const prevFiber = globalThis[currentFiberTypeId]; @@ -2715,7 +2721,7 @@ var fiberInterruptAs = /* @__PURE__ */ dual((args) => hasProperty(args[0], Fiber })); var fiberInterruptAll = (fibers) => withFiber((parent) => { const annotations = fiberStackAnnotations(parent); - let fiberArr = empty2(); + let fiberArr = empty(); for (const fiber of fibers) { fiber.interruptUnsafe(parent.id, annotations); fiberArr.push(fiber); @@ -2739,7 +2745,7 @@ var suspend = /* @__PURE__ */ makePrimitive({ return this[args](); } }); -var fromResult = /* @__PURE__ */ match3({ +var fromResult = /* @__PURE__ */ match2({ onFailure: fail3, onSuccess: succeed3 }); @@ -3032,7 +3038,7 @@ var tapCont = function(value) { var tapEffectCont = function(value) { return new ContImpl(this.payload, returnPayload, exitSucceed(value)); }; -var asSome = (self) => map4(self, some2); +var asSome = (self) => map3(self, some2); var andThen = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? returnPayload : andThenCont, f)); var tap = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? tapEffectCont : tapCont, f)); var asVoid = (self) => new ContImpl(self, returnPayload, exitVoid); @@ -3074,8 +3080,8 @@ var flatMapEager = /* @__PURE__ */ dual(2, (self, f) => { } return flatMap2(self, f); }); -var map4 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); -var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map4(self, f)); +var map3 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); +var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map3(self, f)); var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError(self, f)); var exitInterrupt = (fiberId) => exitFailCause(causeInterrupt(fiberId)); var exitIsSuccess = (self) => self._tag === "Success"; @@ -3450,7 +3456,7 @@ var all = (arg, options) => { } return suspend(() => { const out = {}; - return as(forEach(Object.entries(arg), ([key, effect]) => map4(options?.mode === "result" ? result(effect) : effect, (value) => { + return as(forEach(Object.entries(arg), ([key, effect]) => map3(options?.mode === "result" ? result(effect) : effect, (value) => { assignProperty(out, key, value); }), { discard: true, @@ -3726,7 +3732,7 @@ var fiberRunIn = /* @__PURE__ */ dual(2, (self, scope) => { self.addObserver(() => scopeRemoveFinalizerUnsafe(scope, key)); return self; }); -var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty()); +var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty2()); var runSyncExitWith = (context) => { const runFork = runForkWith(context); return (effect) => { @@ -3740,7 +3746,7 @@ var runSyncExitWith = (context) => { return fiber._exit ?? exitDie(new AsyncFiberError(fiber)); }; }; -var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty()); +var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty2()); var succeedTrue = /* @__PURE__ */ succeed3(true); var succeedFalse = /* @__PURE__ */ succeed3(false); @@ -3861,7 +3867,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = noopSpan({ name, parent, - annotations: add(options?.annotations ?? empty(), DisablePropagation, true) + annotations: add(options?.annotations ?? empty2(), DisablePropagation, true) }); } else { const tracer = fiber.getRef(Tracer); @@ -3874,7 +3880,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = tracer.span({ name, parent, - annotations: options?.annotations ?? empty(), + annotations: options?.annotations ?? empty2(), links, startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : bigint02, kind: options?.kind ?? "internal", @@ -4160,10 +4166,23 @@ var tracerLogger = /* @__PURE__ */ loggerMake(({ span.event(toStringUnknown(Array.isArray(message) && message.length === 1 ? message[0] : message), clock.currentTimeNanosUnsafe(), attributes); }); +// node_modules/effect/dist/Cause.js +var isFailReason2 = isFailReason; +var fromReasons = causeFromReasons; +var fail4 = causeFail; +var die2 = causeDie; +var hasInterruptsOnly2 = hasInterruptsOnly; +var map4 = causeMap; +var squash = causeSquash; +var isDone2 = isDone; +var Done2 = Done; +var done2 = done; +var UnknownError2 = UnknownError; + // node_modules/effect/dist/Exit.js var succeed4 = exitSucceed; var failCause2 = exitFailCause; -var fail4 = exitFail; +var fail5 = exitFail; var void_2 = exitVoid; var isSuccess3 = exitIsSuccess; var isFailure3 = exitIsFailure; @@ -4200,8 +4219,8 @@ var _await = (self) => callback((resume) => { }); }); var completeWith = /* @__PURE__ */ dual(2, (self, effect) => sync(() => doneUnsafe(self, effect))); -var done2 = completeWith; -var isDone2 = (self) => sync(() => isDoneUnsafe(self)); +var done3 = completeWith; +var isDone3 = (self) => sync(() => isDoneUnsafe(self)); var isDoneUnsafe = (self) => self.effect !== undefined; var doneUnsafe = (self, effect) => { if (self.effect) @@ -4274,7 +4293,7 @@ var memoMapBuild = (memoMap, layer, scope, build) => { memoMap.map.set(layer, entry); return scopeAddFinalizerExit(scope, entry.finalizer).pipe(flatMap2(() => build(memoMap, layerScope)), onExit((exit) => { entry.effect = exit; - return done2(deferred, exit); + return done3(deferred, exit); })); }; @@ -4312,7 +4331,7 @@ class CurrentMemoMap extends (/* @__PURE__ */ Service()("effect/Layer/CurrentMem return current ? forkMemoMapUnsafe(current) : makeMemoMapUnsafe(); } } -var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map4(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); +var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map3(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); var buildWithScope = /* @__PURE__ */ dual(2, (self, scope) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope))); var succeed5 = function() { if (arguments.length === 1) { @@ -4334,31 +4353,19 @@ var effect = function() { } return effectImpl(arguments[0], arguments[1]); }; -var effectImpl = (service, effect) => effectContext(map4(effect, (value) => make2(service, value))); +var effectImpl = (service, effect) => effectContext(map3(effect, (value) => make2(service, value))); var effectContext = (effect) => fromBuildMemo((_, scope) => provide(effect, scope)); var mergeAllEffect = (layers, memoMap, scope) => { const parentScope = forkUnsafe2(scope, "parallel"); return forEach(layers, (layer) => layer.build(memoMap, forkUnsafe2(parentScope, "sequential")), { concurrency: layers.length - }).pipe(map4((context) => mergeAll(...context))); + }).pipe(map3((context) => mergeAll(...context))); }; var mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope)); -var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map4((merged) => f(merged, context))))); +var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map3((merged) => f(merged, context))))); var provide2 = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, identity)); var provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self))); -// node_modules/effect/dist/Cause.js -var isFailReason2 = isFailReason; -var fromReasons = causeFromReasons; -var fail5 = causeFail; -var hasInterruptsOnly2 = hasInterruptsOnly; -var map5 = causeMap; -var squash = causeSquash; -var isDone3 = isDone; -var Done2 = Done; -var done3 = done; -var UnknownError2 = UnknownError; - // node_modules/effect/dist/internal/random.js var nextBetween = (min, max, draw) => { const value = draw * (max - min) + min; @@ -4378,7 +4385,7 @@ var nextBetween = (min, max, draw) => { // node_modules/effect/dist/Pull.js var catchDone = /* @__PURE__ */ dual(2, (effect, f) => catchCauseFilter(effect, filterDoneLeftover, (l) => f(l))); var isDoneCause = (cause) => cause.reasons.some(isDoneFailure); -var isDoneFailure = (failure) => failure._tag === "Fail" && isDone3(failure.error); +var isDoneFailure = (failure) => failure._tag === "Fail" && isDone2(failure.error); var filterDone = (cause) => { let done; let hasFailure = false; @@ -4420,7 +4427,6 @@ var forEach2 = forEach; var whileLoop2 = whileLoop; var tryPromise2 = tryPromise; var succeed6 = succeed3; -var succeedNone2 = succeedNone; var suspend2 = suspend; var sync3 = sync; var void_3 = void_; @@ -4429,7 +4435,7 @@ var gen2 = gen; var fail6 = fail3; var failCause3 = failCause; var failCauseSync2 = failCauseSync; -var die2 = die; +var die3 = die; var try_2 = try_; var withFiber2 = withFiber; var fromResult2 = fromResult; @@ -4437,7 +4443,7 @@ var flatMap3 = flatMap2; var andThen2 = andThen; var tap2 = tap; var exit2 = exit; -var map6 = map4; +var map5 = map3; var as2 = as; var catch_2 = catch_; var catchTag2 = catchTag; @@ -4483,272 +4489,97 @@ var effectify = (fn, onError, onSyncError) => (...args) => callback2((resume) => } }); } catch (err) { - resume(onSyncError ? fail6(onSyncError(err, args)) : die2(err)); + resume(onSyncError ? fail6(onSyncError(err, args)) : die3(err)); } }); var mapEager2 = mapEager; var mapErrorEager2 = mapErrorEager; var flatMapEager2 = flatMapEager; var fnUntracedEager2 = fnUntracedEager; -// node_modules/effect/dist/MutableRef.js -var TypeId7 = "~effect/MutableRef"; -var MutableRefProto = { - [TypeId7]: TypeId7, - ...PipeInspectableProto, - toJSON() { - return { - _id: "MutableRef", - current: toJson(this.current) - }; + +// node_modules/effect/dist/internal/schema/annotations.js +function resolve(ast) { + return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; +} +var STRUCTURAL_ANNOTATION_KEY = "~structural"; +var SENTINELS_ANNOTATION_KEY = "~sentinels"; +var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; +var getExpected = /* @__PURE__ */ memoize((ast) => { + const identifier = resolve(ast)?.identifier; + if (typeof identifier === "string") + return identifier; + return ast.getExpected(getExpected); +}); + +// node_modules/effect/dist/internal/schema/parser.js +var missing = /* @__PURE__ */ Symbol(); +var succeed7 = succeed4; +var missingExit = /* @__PURE__ */ succeed7(missing); +var sameExit = /* @__PURE__ */ succeed7(missing); +var toOption = (value) => value === missing ? none2() : some2(value); +var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed7(option.value); + +// node_modules/effect/dist/SchemaIssue.js +var TypeId7 = "~effect/SchemaIssue/Issue"; +function isIssue(u) { + return hasProperty(u, TypeId7) && u[TypeId7] === TypeId7; +} +function hasInput(issue) { + return Object.hasOwn(issue, "input"); +} + +class IssueNodeImpl { + [TypeId7] = TypeId7; + constructor(input, options) { + if (options?.reportInput === true && input !== missing) { + this.input = input; + } + } +} +var Filter = class extends IssueNodeImpl { + _tag = "Filter"; + filter; + issue; + constructor(filter, issue, input, options) { + super(input, options); + this.filter = filter; + this.issue = issue; } }; -var make5 = (value) => { - const ref = Object.create(MutableRefProto); - ref.current = value; - return ref; +var Encoding = class extends IssueNodeImpl { + _tag = "Encoding"; + ast; + issue; + constructor(ast, issue, input, options) { + super(input, options); + this.ast = ast; + this.issue = issue; + } }; - -// node_modules/effect/dist/Ref.js -var TypeId8 = "~effect/Ref"; -var RefProto = { - [TypeId8]: { - _A: identity - }, - ...PipeInspectableProto, - toJSON() { - return { - _id: "Ref", - ref: this.ref - }; +var Pointer = class extends IssueNodeImpl { + _tag = "Pointer"; + path; + issue; + constructor(path, issue) { + super(); + this.path = path; + this.issue = issue; } }; -var makeUnsafe4 = (value) => { - const self = Object.create(RefProto); - self.ref = make5(value); - return self; +var MissingKey = class extends IssueNodeImpl { + _tag = "MissingKey"; + annotations; + constructor(annotations) { + super(); + this.annotations = annotations; + } }; -var make6 = (value) => sync3(() => makeUnsafe4(value)); -var get2 = (self) => sync3(() => self.ref.current); -var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { - self.ref.current = f(self.ref.current); -})); -// node_modules/effect/dist/BigInt.js -var BigInt2 = globalThis.BigInt; -var toNumber = (b) => { - if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { - return none2(); - } - return some2(Number(b)); -}; - -// node_modules/effect/dist/ByteSize.js -var bigint03 = /* @__PURE__ */ BigInt(0); -var bigint12 = /* @__PURE__ */ BigInt(1); -var decimalBase = /* @__PURE__ */ BigInt(1000); -var binaryBase = /* @__PURE__ */ BigInt(1024); -var decimalUnits = [{ - symbol: "B", - factor: bigint12, - names: ["B", "byte", "bytes"] -}, { - symbol: "kB", - factor: decimalBase, - names: ["kB", "kilobyte", "kilobytes"] -}, { - symbol: "MB", - factor: decimalBase ** /* @__PURE__ */ BigInt(2), - names: ["MB", "megabyte", "megabytes"] -}, { - symbol: "GB", - factor: decimalBase ** /* @__PURE__ */ BigInt(3), - names: ["GB", "gigabyte", "gigabytes"] -}, { - symbol: "TB", - factor: decimalBase ** /* @__PURE__ */ BigInt(4), - names: ["TB", "terabyte", "terabytes"] -}, { - symbol: "PB", - factor: decimalBase ** /* @__PURE__ */ BigInt(5), - names: ["PB", "petabyte", "petabytes"] -}, { - symbol: "EB", - factor: decimalBase ** /* @__PURE__ */ BigInt(6), - names: ["EB", "exabyte", "exabytes"] -}, { - symbol: "ZB", - factor: decimalBase ** /* @__PURE__ */ BigInt(7), - names: ["ZB", "zettabyte", "zettabytes"] -}, { - symbol: "YB", - factor: decimalBase ** /* @__PURE__ */ BigInt(8), - names: ["YB", "yottabyte", "yottabytes"] -}, { - symbol: "RB", - factor: decimalBase ** /* @__PURE__ */ BigInt(9), - names: ["RB", "ronnabyte", "ronnabytes"] -}, { - symbol: "QB", - factor: decimalBase ** /* @__PURE__ */ BigInt(10), - names: ["QB", "quettabyte", "quettabytes"] -}]; -var binaryUnits = [decimalUnits[0], { - symbol: "KiB", - factor: binaryBase, - names: ["KiB", "kibibyte", "kibibytes"] -}, { - symbol: "MiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(2), - names: ["MiB", "mebibyte", "mebibytes"] -}, { - symbol: "GiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(3), - names: ["GiB", "gibibyte", "gibibytes"] -}, { - symbol: "TiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(4), - names: ["TiB", "tebibyte", "tebibytes"] -}, { - symbol: "PiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(5), - names: ["PiB", "pebibyte", "pebibytes"] -}, { - symbol: "EiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(6), - names: ["EiB", "exbibyte", "exbibytes"] -}, { - symbol: "ZiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(7), - names: ["ZiB", "zebibyte", "zebibytes"] -}, { - symbol: "YiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(8), - names: ["YiB", "yobibyte", "yobibytes"] -}]; -var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; -var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); -var make7 = (value) => value; -var invalid2 = (message) => { - throw new Error(`Invalid ByteSize: ${message}`); -}; -var fromNumber = (input) => { - if (!Number.isSafeInteger(input) || input < 0) { - return invalid2(`expected a non-negative safe integer, received ${input}`); - } - return make7(BigInt(input)); -}; -var parse = (input) => { - const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); - if (match === null) - return invalid2(`unsupported syntax ${JSON.stringify(input)}`); - const unit = unitsByName.get(match[3]); - if (unit === undefined) - return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); - const fraction = match[2] ?? ""; - const scale = BigInt(10) ** BigInt(fraction.length); - const numerator = BigInt(match[1] + fraction) * unit.factor; - if (numerator % scale !== bigint03) { - return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); - } - return make7(numerator / scale); -}; -var fromInputUnsafe2 = (input) => { - switch (typeof input) { - case "bigint": - if (input < bigint03) - return invalid2(`expected a non-negative bigint, received ${input}`); - return make7(input); - case "number": - return fromNumber(input); - case "string": - return parse(input); - } - return invalid2(`unsupported input ${input}`); -}; -var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); - -// node_modules/effect/dist/internal/schema/annotations.js -function resolve(ast) { - return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; -} -var STRUCTURAL_ANNOTATION_KEY = "~structural"; -var SENTINELS_ANNOTATION_KEY = "~sentinels"; -var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; -var getExpected = /* @__PURE__ */ memoize((ast) => { - const identifier = resolve(ast)?.identifier; - if (typeof identifier === "string") - return identifier; - return ast.getExpected(getExpected); -}); - -// node_modules/effect/dist/internal/schema/parser.js -var missing = /* @__PURE__ */ Symbol(); -var succeed7 = succeed4; -var missingExit = /* @__PURE__ */ succeed7(missing); -var sameExit = /* @__PURE__ */ succeed7(missing); -var toOption = (value) => value === missing ? none2() : some2(value); -var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed7(option.value); - -// node_modules/effect/dist/SchemaIssue.js -var TypeId9 = "~effect/SchemaIssue/Issue"; -function isIssue(u) { - return hasProperty(u, TypeId9) && u[TypeId9] === TypeId9; -} -function hasInput(issue) { - return Object.hasOwn(issue, "input"); -} - -class IssueNodeImpl { - [TypeId9] = TypeId9; - constructor(input, options) { - if (options?.reportInput === true && input !== missing) { - this.input = input; - } - } -} -var Filter = class extends IssueNodeImpl { - _tag = "Filter"; - filter; - issue; - constructor(filter, issue, input, options) { - super(input, options); - this.filter = filter; - this.issue = issue; - } -}; -var Encoding = class extends IssueNodeImpl { - _tag = "Encoding"; - ast; - issue; - constructor(ast, issue, input, options) { - super(input, options); - this.ast = ast; - this.issue = issue; - } -}; -var Pointer = class extends IssueNodeImpl { - _tag = "Pointer"; - path; - issue; - constructor(path, issue) { - super(); - this.path = path; - this.issue = issue; - } -}; -var MissingKey = class extends IssueNodeImpl { - _tag = "MissingKey"; - annotations; - constructor(annotations) { - super(); - this.annotations = annotations; - } -}; -var UnexpectedKey = class extends IssueNodeImpl { - _tag = "UnexpectedKey"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; +var UnexpectedKey = class extends IssueNodeImpl { + _tag = "UnexpectedKey"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; } }; var Composite = class extends IssueNodeImpl { @@ -4825,7 +4656,7 @@ function normalizeFilterOutput(ast, out, input, options) { if (!isReadonlyArrayNonEmpty(out)) { return; } - return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map2(out, (entry) => makeFilterIssue(entry, input, options)), input, options); + return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map(out, (entry) => makeFilterIssue(entry, input, options)), input, options); } return makeSingle(out, input, options); } @@ -4953,48 +4784,23 @@ function getSchemaIssueOrThrow(cause, message) { } // node_modules/effect/dist/SchemaGetter.js -var Getter = class extends Class { - run; - constructor(run) { - super(); - this.run = run; - } - map(f) { - return new Getter((oe, options) => this.run(oe, options).pipe(mapEager2(map(f)))); - } - compose(other) { - if (isPassthrough(this)) { - return other; - } - if (isPassthrough(other)) { - return this; - } - return new Getter((oe, options) => this.run(oe, options).pipe(flatMapEager2((ot) => other.run(ot, options)))); - } -}; -var passthrough_ = /* @__PURE__ */ new Getter(succeed6); -function isPassthrough(getter) { - return getter.run === passthrough_.run; -} +var makeGetter = (fields) => Object.assign(Object.create(Prototype), fields); +var passthrough_ = /* @__PURE__ */ makeGetter({ + _tag: "Passthrough" +}); function passthrough() { return passthrough_; } -function onSome(f) { - return new Getter((oe, options) => isNone2(oe) ? succeedNone2 : f(oe.value, options)); -} function transform(f) { - return transformOptional(map(f)); + return makeGetter({ + _tag: "Transform", + transform: f + }); } function transformEffect(f) { - return onSome((e, options) => f(e, options).pipe(mapEager2(some2))); -} -function transformOptional(f) { - return new Getter((oe) => succeed6(f(oe))); -} -function withDefault(defaultValue) { - return new Getter((o) => { - const filtered = filter(o, isNotUndefined); - return isSome2(filtered) ? succeed6(filtered) : mapEager2(defaultValue, some2); + return makeGetter({ + _tag: "TransformEffect", + transform: f }); } function String2() { @@ -5012,74 +4818,197 @@ function decodeBase642() { }, input, options))); } -// node_modules/effect/dist/SchemaTransformation.js -var TypeId10 = "~effect/SchemaTransformation/Transformation"; -var Transformation = class { - [TypeId10] = TypeId10; - _tag = "Transformation"; - decode; - encode; - constructor(decode, encode) { - this.decode = decode; - this.encode = encode; - } - flip() { - return new Transformation(this.encode, this.decode); - } - compose(other) { - return new Transformation(this.decode.compose(other.decode), other.encode.compose(this.encode)); - } -}; -function isTransformation(u) { - return hasProperty(u, TypeId10) && u[TypeId10] === TypeId10; -} -var make8 = (options) => { - if (isTransformation(options)) { - return options; - } - return new Transformation(options.decode, options.encode); -}; -function transformEffect2(options) { - return new Transformation(transformEffect(options.decode), transformEffect(options.encode)); -} -function transform2(options) { - return new Transformation(transform(options.decode), transform(options.encode)); -} -var passthrough_2 = /* @__PURE__ */ new Transformation(/* @__PURE__ */ passthrough(), /* @__PURE__ */ passthrough()); -function passthrough2() { - return passthrough_2; -} -var numberFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ String2()); -var urlFromString = /* @__PURE__ */ transformEffect2({ - decode: (s, options) => URL.canParse(s) ? succeed6(new URL(s)) : fail6(new InvalidValue({ - expected: "a valid URL string" - }, s, options)), - encode: (url) => succeed6(url.href) -}); -var uint8ArrayFromBase64String = /* @__PURE__ */ new Transformation(/* @__PURE__ */ decodeBase642(), /* @__PURE__ */ encodeBase642()); - -// node_modules/effect/dist/SchemaAST.js -function makeGuard(tag) { - return (ast) => ast._tag === tag; -} -var isDeclaration = /* @__PURE__ */ makeGuard("Declaration"); -var isNever2 = /* @__PURE__ */ makeGuard("Never"); -var isLiteral = /* @__PURE__ */ makeGuard("Literal"); -var isUniqueSymbol = /* @__PURE__ */ makeGuard("UniqueSymbol"); -var isArrays = /* @__PURE__ */ makeGuard("Arrays"); -var isObjects = /* @__PURE__ */ makeGuard("Objects"); -var isSuspend = /* @__PURE__ */ makeGuard("Suspend"); -var Link = class { - to; - transformation; - constructor(to, transformation) { - this.to = to; - this.transformation = transformation; - } -}; -var defaultParseOptions = {}; -var Context = class { - isOptional; +// node_modules/effect/dist/ByteSize.js +var bigint03 = /* @__PURE__ */ BigInt(0); +var bigint12 = /* @__PURE__ */ BigInt(1); +var decimalBase = /* @__PURE__ */ BigInt(1000); +var binaryBase = /* @__PURE__ */ BigInt(1024); +var decimalUnits = [{ + symbol: "B", + factor: bigint12, + names: ["B", "byte", "bytes"] +}, { + symbol: "kB", + factor: decimalBase, + names: ["kB", "kilobyte", "kilobytes"] +}, { + symbol: "MB", + factor: decimalBase ** /* @__PURE__ */ BigInt(2), + names: ["MB", "megabyte", "megabytes"] +}, { + symbol: "GB", + factor: decimalBase ** /* @__PURE__ */ BigInt(3), + names: ["GB", "gigabyte", "gigabytes"] +}, { + symbol: "TB", + factor: decimalBase ** /* @__PURE__ */ BigInt(4), + names: ["TB", "terabyte", "terabytes"] +}, { + symbol: "PB", + factor: decimalBase ** /* @__PURE__ */ BigInt(5), + names: ["PB", "petabyte", "petabytes"] +}, { + symbol: "EB", + factor: decimalBase ** /* @__PURE__ */ BigInt(6), + names: ["EB", "exabyte", "exabytes"] +}, { + symbol: "ZB", + factor: decimalBase ** /* @__PURE__ */ BigInt(7), + names: ["ZB", "zettabyte", "zettabytes"] +}, { + symbol: "YB", + factor: decimalBase ** /* @__PURE__ */ BigInt(8), + names: ["YB", "yottabyte", "yottabytes"] +}, { + symbol: "RB", + factor: decimalBase ** /* @__PURE__ */ BigInt(9), + names: ["RB", "ronnabyte", "ronnabytes"] +}, { + symbol: "QB", + factor: decimalBase ** /* @__PURE__ */ BigInt(10), + names: ["QB", "quettabyte", "quettabytes"] +}]; +var binaryUnits = [decimalUnits[0], { + symbol: "KiB", + factor: binaryBase, + names: ["KiB", "kibibyte", "kibibytes"] +}, { + symbol: "MiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(2), + names: ["MiB", "mebibyte", "mebibytes"] +}, { + symbol: "GiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(3), + names: ["GiB", "gibibyte", "gibibytes"] +}, { + symbol: "TiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(4), + names: ["TiB", "tebibyte", "tebibytes"] +}, { + symbol: "PiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(5), + names: ["PiB", "pebibyte", "pebibytes"] +}, { + symbol: "EiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(6), + names: ["EiB", "exbibyte", "exbibytes"] +}, { + symbol: "ZiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(7), + names: ["ZiB", "zebibyte", "zebibytes"] +}, { + symbol: "YiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(8), + names: ["YiB", "yobibyte", "yobibytes"] +}]; +var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; +var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); +var make5 = (value) => value; +var invalid2 = (message) => { + throw new Error(`Invalid ByteSize: ${message}`); +}; +var fromNumber = (input) => { + if (!Number.isSafeInteger(input) || input < 0) { + return invalid2(`expected a non-negative safe integer, received ${input}`); + } + return make5(BigInt(input)); +}; +var fromStringUnsafe = (input) => { + const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); + if (match === null) + return invalid2(`unsupported syntax ${JSON.stringify(input)}`); + const unit = unitsByName.get(match[3]); + if (unit === undefined) + return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); + const fraction = match[2] ?? ""; + const scale = BigInt(10) ** BigInt(fraction.length); + const numerator = BigInt(match[1] + fraction) * unit.factor; + if (numerator % scale !== bigint03) { + return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); + } + return make5(numerator / scale); +}; +var fromInputUnsafe2 = (input) => { + switch (typeof input) { + case "bigint": + if (input < bigint03) + return invalid2(`expected a non-negative bigint, received ${input}`); + return make5(input); + case "number": + return fromNumber(input); + case "string": + return fromStringUnsafe(input); + } + return invalid2(`unsupported input ${input}`); +}; +var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); + +// node_modules/effect/dist/SchemaTransformation.js +var TypeId8 = "~effect/SchemaTransformation/Transformation"; +var Transformation = class extends Class { + [TypeId8] = TypeId8; + _tag = "Transformation"; + decode; + encode; + constructor(decode, encode) { + super(); + this.decode = decode; + this.encode = encode; + } + flip() { + return new Transformation(this.encode, this.decode); + } +}; +function isTransformation(u) { + return hasProperty(u, TypeId8) && u[TypeId8] === TypeId8; +} +var makeTransformation = (options) => { + if (isTransformation(options)) { + return options; + } + return new Transformation(options.decode, options.encode); +}; +function transformEffect2(options) { + return new Transformation(transformEffect(options.decode), transformEffect(options.encode)); +} +function transform2(options) { + return new Transformation(transform(options.decode), transform(options.encode)); +} +var passthrough_2 = /* @__PURE__ */ new Transformation(/* @__PURE__ */ passthrough(), /* @__PURE__ */ passthrough()); +function passthrough2() { + return passthrough_2; +} +var numberFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ String2()); +var urlFromString = /* @__PURE__ */ transformEffect2({ + decode: (s, options) => URL.canParse(s) ? succeed6(new URL(s)) : fail6(new InvalidValue({ + expected: "a valid URL string" + }, s, options)), + encode: (url) => succeed6(url.href) +}); +var uint8ArrayFromBase64String = /* @__PURE__ */ new Transformation(/* @__PURE__ */ decodeBase642(), /* @__PURE__ */ encodeBase642()); + +// node_modules/effect/dist/SchemaAST.js +function makeGuard(tag) { + return (ast) => ast._tag === tag; +} +var isDeclaration = /* @__PURE__ */ makeGuard("Declaration"); +var isNever2 = /* @__PURE__ */ makeGuard("Never"); +var isLiteral = /* @__PURE__ */ makeGuard("Literal"); +var isUniqueSymbol = /* @__PURE__ */ makeGuard("UniqueSymbol"); +var isArrays = /* @__PURE__ */ makeGuard("Arrays"); +var isObjects = /* @__PURE__ */ makeGuard("Objects"); +var isSuspend = /* @__PURE__ */ makeGuard("Suspend"); +var Link = class { + to; + transformation; + constructor(to, transformation) { + this.to = to; + this.transformation = transformation; + } +}; +var defaultParseOptions = {}; +var Context = class { + isOptional; isMutable; constructorDefault; annotations; @@ -5090,10 +5019,10 @@ var Context = class { this.annotations = annotations; } }; -var TypeId11 = "~effect/Schema"; +var TypeId9 = "~effect/Schema"; class ASTNodeImpl { - [TypeId11] = TypeId11; + [TypeId9] = TypeId9; annotations; checks; encoding; @@ -5268,7 +5197,7 @@ var Arrays = class extends ASTNodeImpl { } } } - getParser(compile, compileConstructorDefault = compile) { + getParser(compile, compileField = compile) { const ast = this; let elements; let rest; @@ -5292,11 +5221,11 @@ var Arrays = class extends ASTNodeImpl { if (!elements) { elements = ast.elements.map((ast) => ({ ast, - parser: compileConstructorDefault(ast) + parser: compileField(ast) })); rest = ast.rest.map((ast) => ({ ast, - parser: compileConstructorDefault(ast) + parser: compileField(ast) })); } const len = input.length; @@ -5353,33 +5282,34 @@ var Arrays = class extends ASTNodeImpl { return "array"; } }; +function stepArray(s, item, exit, i) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, i, exit); + } + const value = exit === sameExit ? item : exit[args]; + if (value !== missing) { + s.output[i] = value; + } else { + const p = s.getParser(s.tailThreshold, i); + if (isOptional(p.ast)) + return; + const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); + } + } +} var parseArrayOptions = { onItem(s, item, i) { const value = i < s.len ? item : missing; return s.getParser(s.tailThreshold, i).parser(value, s.options); }, - step(s, item, exit, i) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, i, exit); - } - const value = exit === sameExit ? item : exit[args]; - if (value !== missing) { - s.output[i] = value; - } else { - const p = s.getParser(s.tailThreshold, i); - if (isOptional(p.ast)) - return; - const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); - } - } - } + step: stepArray }; var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); @@ -5389,7 +5319,7 @@ var wrapPropertyKeyIssue = (s, ast, key, exit) => { } const issue = getSchemaIssue(exit.cause); if (issue === undefined) { - return failCause2(map5(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); + return failCause2(map4(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); } const pointer = new Pointer([key], issue); if (s.options.errors === "all") { @@ -5398,7 +5328,7 @@ var wrapPropertyKeyIssue = (s, ast, key, exit) => { else s.issues = [pointer]; } else { - return fail4(new Composite(ast, [pointer], s.input, s.options)); + return fail5(new Composite(ast, [pointer], s.input, s.options)); } }; var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; @@ -5498,7 +5428,7 @@ var Objects = class extends ASTNodeImpl { throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); } } - getParser(compile, compileConstructorDefault = compile) { + getParser(compile, compileField = compile) { const ast = this; const expectedKeys = []; for (const ps of ast.propertySignatures) { @@ -5552,14 +5482,14 @@ var Objects = class extends ASTNodeImpl { const compileMembers = () => { if (!properties) { properties = ast.propertySignatures.map((ps) => ({ - parser: compileConstructorDefault(ps.type), + parser: compileField(ps.type), name: ps.name, type: ps.type })); indexes = indexCount ? ast.indexSignatures.map((is) => ({ is, parserKey: compile(parameterFromPropertyKey(is.parameter)), - parserValue: compileConstructorDefault(is.type) + parserValue: compileField(is.type) })) : undefined; } return properties; @@ -5634,7 +5564,7 @@ var Objects = class extends ASTNodeImpl { } } } else if (parseIndexes) { - const keyPairs = empty2(); + const keyPairs = empty(); for (let i = 0;i < indexCount; i++) { const index = indexes[i]; const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); @@ -5705,7 +5635,7 @@ var Objects = class extends ASTNodeImpl { return terminal; } } catch (error) { - return die2(error); + return die3(error); } return succeed7(out); }; @@ -5755,7 +5685,7 @@ function stepProperty(s, p, exit) { s.issues = [issue]; return; } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); + return fail5(new Composite(s.ast, [issue], s.input, s.options)); } } } @@ -6054,13 +5984,13 @@ var Union = class extends ASTNodeImpl { this.options = options; this.encodingChecks = encodingChecks; } - getParser(compile, compileConstructorDefault) { + getParser(compile, compileField) { const ast = this; return (input, options) => { if (input === missing) { return missingExit; } - const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined); + const candidates = getCandidates(input, ast.types, compileField !== undefined); if (candidates.length === 0) { return fail6(new AnyOf(ast, [], input, options)); } @@ -6145,7 +6075,7 @@ function failSingleUnionCandidate(ast, cause, input, options) { const issue = getSchemaIssue(cause); if (!issue) return failCause2(cause); - return fail4(new AnyOf(ast, [issue], input, options)); + return fail5(new AnyOf(ast, [issue], input, options)); } var parseUnion = /* @__PURE__ */ iterateEager()({ onItem(s, ast) { @@ -6165,7 +6095,7 @@ var parseUnion = /* @__PURE__ */ iterateEager()({ } else { if (s.out && s.successes) { s.successes.push(candidate); - return fail4(new OneOf(s.ast, s.successes, s.input, s.options)); + return fail5(new OneOf(s.ast, s.successes, s.input, s.options)); } s.out = exit; if (s.successes) { @@ -6390,9 +6320,7 @@ var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { }); var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); function withConstructorDefault(ast, defaultValue) { - const transformation = new Transformation(withDefault(defaultValue), passthrough()); - const constructorDefault = new Link(unknown, transformation); - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) : new Context(false, false, constructorDefault); + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue); return replaceContext(ast, context); } function decodeTo(from, to, transformation) { @@ -6546,1417 +6474,1691 @@ function getConstructorDescriptor(ast) { return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; } -// node_modules/effect/dist/SchemaParser.js -function makeEffect(schema) { - const ast = schema.ast; - let parser; - return (input, options) => { - return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { - ...options.parseOptions, - disableChecks: true - } : { - disableChecks: true - } : options?.parseOptions); - }; -} -function makeOption(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return some2(exit.value); - } - getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); - return none2(); - }; -} -function make9(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return exit.value; - } - const issue = getSchemaIssueOrThrow(exit.cause, "Constructor adapter can only throw schema issues"); - throw new Error("Schema validation failed", { - cause: issue - }); - }; -} -function decodeUnknownEffect(schema, options) { - const parser = run(schema.ast); - return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); +// node_modules/effect/dist/Brand.js +function nominal() { + return Object.assign((input) => input, { + option: (input) => some2(input), + result: (input) => succeed2(input), + is: (_) => true + }); } -var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { - ...options, - ...overrideOptions -} : options; -var getValue = (value) => { - if (value === missing) { - return fail6(new InvalidValue); - } - return succeed6(value); +// node_modules/effect/dist/Fiber.js +var interrupt3 = fiberInterrupt; +var runIn = fiberRunIn; + +// node_modules/effect/dist/Latch.js +var makeUnsafe4 = makeLatchUnsafe; + +// node_modules/effect/dist/MutableRef.js +var TypeId10 = "~effect/MutableRef"; +var MutableRefProto = { + [TypeId10]: TypeId10, + ...PipeInspectableProto, + toJSON() { + return { + _id: "MutableRef", + current: toJson(this.current) + }; + } }; -function run(ast) { - return runWithCompiler(normalCompiler, ast); -} -function runWithCompiler(compiler, ast) { - let parser; - return (input, options) => { - const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); - if (result === sameExit) { - return succeed6(input); - } - if (!effectIsExit(result)) { - return flatMapEager2(result, getValue); - } - return result[args] === missing ? getValue(missing) : result; - }; -} -var normalCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, normalCompiler)); -var constructorCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault)); -var compileDefaulted = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault, ast.context?.constructorDefault)); -function compileConstructorDefault(ast) { - return ast.context?.constructorDefault ? compileDefaulted(ast) : constructorCompiler(ast); -} -function applyTransformation(result, current, transformation, options) { - let transformed; - if (effectIsExit(result) && result._tag === "Success") { - const optional = toOption(result === sameExit ? current : result[args]); - transformed = transformation._tag === "Transformation" ? transformation.decode.run(optional, options) : transformation.decode(succeed7(optional), options); - } else if (transformation._tag === "Transformation") { - transformed = flatMapEager2(result, (value) => transformation.decode.run(toOption(value), options)); - } else { - transformed = transformation.decode(mapEager2(result, toOption), options); +var make6 = (value) => { + const ref = Object.create(MutableRefProto); + ref.current = value; + return ref; +}; + +// node_modules/effect/dist/MutableList.js +var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); +var make7 = () => ({ + head: undefined, + tail: undefined, + length: 0 +}); +var emptyBucket = () => ({ + array: [], + mutable: true, + offset: 0, + next: undefined +}); +var append2 = (self, message) => { + if (!self.tail) { + self.head = self.tail = emptyBucket(); + } else if (!self.tail.mutable) { + self.tail.next = emptyBucket(); + self.tail = self.tail.next; } - return effectIsExit(transformed) && transformed._tag === "Success" ? fromOptionExit(transformed[args]) : flatMapEager2(transformed, fromOptionExit); -} -function makeConstructorParser(descriptor, compile) { - let sourceParser; - return (input, options) => { - if (input === missing) - return missingExit; - if (descriptor.isConstructed(input)) - return sameExit; - const result = (sourceParser ??= compile(descriptor.link.to))(input, options); - return applyTransformation(result, input, descriptor.link.transformation, options); - }; -} -function makeParser(ast, compile, compileConstructorDefault, constructorDefault) { - const descriptor = compileConstructorDefault ? getConstructorDescriptor(ast) : undefined; - const parser = descriptor ? makeConstructorParser(descriptor, compile) : ast.getParser(compile, compileConstructorDefault); - const checks = ast.checks; - const links = constructorDefault ? ast.encoding ? [...ast.encoding, constructorDefault] : [constructorDefault] : ast.encoding; - const encodingChecks = ast.encodingChecks; - if (!links && !checks && !encodingChecks) { - return parser; + self.tail.array.push(message); + self.length++; +}; +var clear = (self) => { + self.head = self.tail = undefined; + self.length = 0; +}; +var takeN = (self, n) => { + n = normalize(n); + if (n <= 0 || !self.head) + return []; + n = Math.min(n, self.length); + if (n === self.length && self.head?.offset === 0 && !self.head.next) { + const array = self.head.array; + clear(self); + return array; } - let encodingParsers; - const parseLocal = (input, options) => { - let result = parser(input, options); - if (encodingChecks && !options.disableChecks) { - if (effectIsExit(result)) { - if (result._tag === "Success") { - const output = result === sameExit ? input : result[args]; - if (input !== missing && output !== missing) { - const issues = collectIssues(encodingChecks, input, undefined, ast, options); - if (issues) { - result = fail6(new Composite(ast, issues, input, options)); - } - } - } - } else { - result = flatMap3(result, (value) => { - if (input !== missing && value !== missing) { - const issues = collectIssues(encodingChecks, input, undefined, ast, options); - if (issues) { - return fail6(new Composite(ast, issues, input, options)); - } - } - return succeed6(value); - }); - } - } - if (checks && !options.disableChecks) { - if (effectIsExit(result)) { - if (result._tag === "Success") { - const value = result === sameExit ? input : result[args]; - if (value === missing) - return result; - const issues = collectIssues(checks, value, undefined, ast, options); - if (issues) { - result = fail6(new Composite(ast, issues, value, options)); - } - } - } else { - result = flatMap3(result, (value) => { - if (value !== missing) { - const issues = collectIssues(checks, value, undefined, ast, options); - if (issues) { - return fail6(new Composite(ast, issues, value, options)); - } - } - return succeed6(value); - }); + const array = new Array(n); + let index = 0; + let chunk = self.head; + while (chunk) { + while (chunk.offset < chunk.array.length) { + array[index++] = chunk.array[chunk.offset]; + if (chunk.mutable) + chunk.array[chunk.offset] = undefined; + chunk.offset++; + if (index === n) { + self.head = chunk; + self.length -= n; + if (self.length === 0) + clear(self); + return array; } } - return result; - }; - if (!links) { - return parseLocal; + chunk = chunk.next; } - return (input, options) => { - const parsers = encodingParsers ??= links.map((link) => compile(link.to)); - let current = input; - let result = parsers[parsers.length - 1](input, options); - for (let i = links.length - 1;i >= 0; i--) { - result = applyTransformation(result, current, links[i].transformation, options); - if (i !== 0) { - const next = parsers[i - 1]; - if (result._tag === "Success") { - current = result[args]; - result = next(current, options); - } else { - result = flatMapEager2(result, (value) => { - const nextResult = next(value, options); - return nextResult === sameExit ? succeed7(value) : nextResult; - }); - } - } - } - if (result._tag === "Success") { - const value = result[args]; - const local = parseLocal(value, options); - return local === sameExit ? result : local; + clear(self); + return array; +}; +var take = (self) => { + if (!self.head) + return Empty; + const message = self.head.array[self.head.offset]; + if (self.head.mutable) + self.head.array[self.head.offset] = undefined; + self.head.offset++; + self.length--; + if (self.head.offset === self.head.array.length) { + if (self.head.next) { + self.head = self.head.next; + } else { + clear(self); } - result = catchCause2(result, (cause) => failCauseSync2(() => map5(cause, (issue) => new Encoding(ast, issue, input, options)))); - return flatMapEager2(result, (value) => { - const local = parseLocal(value, options); - return local === sameExit ? succeed7(value) : local; - }); - }; -} - -// node_modules/effect/dist/internal/schema/make.js -var TypeId12 = "~effect/Schema/Schema"; -var SchemaProto = { - [TypeId12]: TypeId12, - pipe() { - return pipeArguments(this, arguments); - }, - annotate(annotations) { - return this.rebuild(annotate(this.ast, annotations)); - }, - annotateKey(annotations) { - return this.rebuild(annotateKey(this.ast, annotations)); - }, - check(...checks) { - return this.rebuild(appendChecks(this.ast, checks)); } + return message; }; -function make10(ast, options) { - function Schema() {} - const self = Object.setPrototypeOf(Schema, SchemaProto); - if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) { - Object.defineProperties(self, Object.getOwnPropertyDescriptors({ - ...options - })); - } else { - Object.assign(self, options); - } - self.ast = ast; - self.rebuild = (ast) => make10(ast, options); - self.makeEffect = makeEffect(self); - self.make = make9(self); - self.makeOption = makeOption(self); - return self; -} - -// node_modules/effect/dist/Struct.js -var lambda = (f) => f; - -// node_modules/effect/dist/internal/schemaError.js -var SchemaErrorTypeId = "~effect/Schema/SchemaError"; -function isSchemaError(u) { - return hasProperty(u, SchemaErrorTypeId) && u[SchemaErrorTypeId] === SchemaErrorTypeId; -} -// node_modules/effect/dist/Schema.js -var TypeId13 = TypeId12; -function declareConstructor() { - return (typeParameters, run, annotations) => { - return make11(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make11(ast))), annotations)); - }; -} -function declare(is, annotations) { - return declareConstructor()([], () => (input, ast, options) => is(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)), annotations); -} -class SchemaError extends (/* @__PURE__ */ TaggedError2("SchemaError")) { - [SchemaErrorTypeId] = SchemaErrorTypeId; - constructor(issue) { - const stackTraceLimit = getStackTraceLimit(); - setStackTraceLimit(0); - try { - super({ - issue - }); - } finally { - setStackTraceLimit(stackTraceLimit); +// node_modules/effect/dist/Queue.js +var TypeId11 = "~effect/Queue"; +var EnqueueTypeId = "~effect/Queue/Enqueue"; +var DequeueTypeId = "~effect/Queue/Dequeue"; +var variance = { + _A: identity, + _E: identity +}; +var QueueProto = { + [TypeId11]: variance, + [EnqueueTypeId]: variance, + [DequeueTypeId]: variance, + ...PipeInspectableProto, + toJSON() { + return { + _id: "effect/Queue", + state: this.state._tag, + size: sizeUnsafe(this) + }; + } +}; +var make8 = (options) => withFiber((fiber) => { + const self = Object.create(QueueProto); + self.dispatcher = fiber.currentDispatcher; + self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; + self.strategy = options?.strategy ?? "suspend"; + self.messages = make7(); + self.scheduleRunning = false; + self.state = { + _tag: "Open", + takers: new Set, + offers: new Set, + awaiters: new Set + }; + return succeed3(self); +}); +var bounded = (capacity) => make8({ + capacity +}); +var offer = (self, message) => suspend(() => { + if (self.state._tag !== "Open") { + return exitFalse; + } else if (self.messages.length >= self.capacity) { + switch (self.strategy) { + case "dropping": + return exitFalse; + case "suspend": + if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return exitTrue; + } + return offerRemainingSingle(self, message); + case "sliding": + take(self.messages); + append2(self.messages, message); + return exitTrue; } } - get message() { - return defaultFormatter(this.issue); + append2(self.messages, message); + scheduleReleaseTaker(self); + return exitTrue; +}); +var offerUnsafe = (self, message) => { + if (self.state._tag !== "Open") { + return false; + } else if (self.messages.length >= self.capacity) { + if (self.strategy === "sliding") { + take(self.messages); + append2(self.messages, message); + return true; + } else if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return true; + } + return false; } - toString() { - return `SchemaError(${this.message})`; + append2(self.messages, message); + scheduleReleaseTaker(self); + return true; +}; +var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); +var failCauseUnsafe = (self, cause) => { + if (self.state._tag !== "Open") { + return false; } -} -function isSchemaError2(u) { - return isSchemaError(u); -} -function fromIssueEffect(self) { - if (effectIsExit(self)) { - return fromIssueExit(self); + const exit = exitFailCause(cause); + const fail = exitZipRight(exit, exitFailDone); + if (self.state.offers.size === 0 && self.messages.length === 0) { + finalize(self, fail); + return true; } - return catchCause2(self, (cause) => failCauseSync2(() => map5(cause, (issue) => new SchemaError(issue)))); -} -function fromIssueExit(exit) { - return isSuccess3(exit) ? exit : failCause2(map5(exit.cause, (issue) => new SchemaError(issue))); -} -function decodeUnknownEffect2(schema, options) { - const parser = decodeUnknownEffect(schema, options); - return (input, options) => { - return fromIssueEffect(parser(input, options)); + self.state = { + ...self.state, + _tag: "Closing", + exit: fail }; -} -var make11 = make10; -function isSchema(u) { - return hasProperty(u, TypeId13) && u[TypeId13] === TypeId13; -} -var optionalKey2 = /* @__PURE__ */ lambda((schema) => make11(optionalKey(schema.ast), { - schema -})); -function Literal2(literal) { - const out = make11(new Literal(literal), { - literal, - transform(to) { - return out.pipe(decodeTo2(Literal2(to), { - decode: transform(() => to), - encode: transform(() => literal) - })); + return true; +}; +var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); +var shutdown = (self) => sync(() => { + if (self.state._tag === "Done") { + return true; + } + clear(self.messages); + const offers = self.state.offers; + finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); + if (offers.size > 0) { + for (const entry of offers) { + if (entry._tag === "Single") { + entry.resume(exitFalse); + } else { + entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); + } } - }); - return out; -} -var String4 = /* @__PURE__ */ make11(string2); -var Number5 = /* @__PURE__ */ make11(number2); -function makeStruct(ast, fields) { - return make11(ast, { - fields, - mapFields(f, options) { - const fields = f(this.fields); - return makeStruct(struct(fields, options?.unsafePreserveChecks ? this.ast.checks : undefined), fields); + offers.clear(); + } + return true; +}); +var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); +var takeBetween = (self, min, max) => { + min = normalize(min); + max = normalize(max); + return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); +}; +var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); +var poll = (self) => suspend(() => { + const result = takeUnsafe(self); + if (result === undefined) { + return succeed3(none2()); + } + if (result._tag === "Success") { + return succeed3(some2(result.value)); + } + return succeed3(none2()); +}); +var takeUnsafe = (self) => { + if (self.state._tag === "Done") { + return self.state.exit; + } + if (self.messages.length > 0) { + const message = take(self.messages); + releaseCapacity(self); + return exitSucceed(message); + } else if (self.capacity <= 0 && self.state.offers.size > 0) { + const message = takeOfferUnsafe(self.state.offers); + releaseCapacity(self); + return exitSucceed(message); + } + return; +}; +var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; +var exitFalse = /* @__PURE__ */ exitSucceed(false); +var exitTrue = /* @__PURE__ */ exitSucceed(true); +var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); +var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); +var releaseTakers = (self) => { + if (self.state._tag === "Done" || self.state.takers.size === 0) { + return; + } + for (const taker of self.state.takers) { + self.state.takers.delete(taker); + taker(exitVoid); + if (self.messages.length === 0) { + break; } - }); -} -function Struct(fields) { - return makeStruct(struct(fields, undefined), fields); -} -function makeTuple(ast, elements) { - return make11(ast, { - elements, - mapElements(f, options) { - const elements = f(this.elements); - return makeTuple(tuple(elements, options?.unsafePreserveChecks ? this.ast.checks : undefined), elements); + } +}; +var scheduleReleaseTaker = (self) => { + if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { + return; + } + self.scheduleRunning = true; + self.dispatcher.scheduleTask(() => { + self.scheduleRunning = false; + releaseTakers(self); + }, 0); +}; +var takeBetweenUnsafe = (self, min, max) => { + if (self.state._tag === "Done") { + return self.state.exit; + } else if (max <= 0 || min <= 0) { + return exitSucceed([]); + } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { + const messages = [takeOfferUnsafe(self.state.offers)]; + releaseCapacity(self); + return exitSucceed(messages); + } + min = Math.min(min, self.capacity || 1); + if (min <= self.messages.length) { + const messages = takeN(self.messages, max); + releaseCapacity(self); + return exitSucceed(messages); + } +}; +var offerRemainingSingle = (self, message) => { + return callback((resume) => { + if (self.state._tag !== "Open") { + return resume(exitFalse); } + const entry = { + _tag: "Single", + message, + resume + }; + self.state.offers.add(entry); + return sync(() => { + if (self.state._tag === "Open") { + self.state.offers.delete(entry); + } + }); }); -} -function Tuple(elements) { - return makeTuple(tuple(elements), elements); -} -var ArraySchema = /* @__PURE__ */ lambda((schema) => make11(new Arrays(false, [], [schema.ast]), { - value: schema -})); -function makeUnion(ast, members) { - return make11(ast, { - members, - mapMembers(f, options) { - const members = f(this.members); - return makeUnion(union(members, this.ast.options, options?.unsafePreserveChecks ? this.ast.checks : undefined), members); +}; +var takeOfferUnsafe = (offers) => { + const entry = offers.values().next().value; + if (entry._tag === "Single") { + offers.delete(entry); + entry.resume(exitTrue); + return entry.message; + } + const message = entry.remaining[entry.offset++]; + if (entry.offset === entry.remaining.length) { + offers.delete(entry); + entry.resume(exitSucceed([])); + } + return message; +}; +var releaseCapacity = (self) => { + if (self.state._tag === "Done") { + return isDoneCause(self.state.exit.cause); + } else if (self.state.offers.size === 0) { + if (self.state._tag === "Closing" && self.messages.length === 0) { + finalize(self, self.state.exit); + return isDoneCause(self.state.exit.cause); } - }); -} -function Union2(members, options) { - return makeUnion(union(members, options, undefined), members); -} -function Literals(literals) { - const members = literals.map(Literal2); - return make11(union(members, undefined, undefined), { - literals, - members, - mapMembers(f) { - return Union2(f(this.members)); - }, - pick(literals) { - return Literals(literals); - }, - transform(to) { - return Union2(members.map((member, index) => member.transform(to[index]))); + return false; + } + for (const entry of self.state.offers) { + let n = self.capacity - self.messages.length; + if (n <= 0) + break; + else if (entry._tag === "Single") { + append2(self.messages, entry.message); + self.state.offers.delete(entry); + entry.resume(exitTrue); + } else { + for (;entry.offset < entry.remaining.length; entry.offset++) { + if (n === 0) + return false; + append2(self.messages, entry.remaining[entry.offset]); + n--; + } + self.state.offers.delete(entry); + entry.resume(exitSucceed([])); + } + } + return false; +}; +var awaitTake = (self) => callback((resume) => { + if (self.state._tag === "Done") { + return resume(self.state.exit); + } + self.state.takers.add(resume); + return sync(() => { + if (self.state._tag !== "Done") { + self.state.takers.delete(resume); } }); -} -function decodeTo2(to, transformation) { - return (from) => { - return make11(decodeTo(from.ast, to.ast, transformation ? make8(transformation) : passthrough2()), { - from, - to - }); +}); +var finalize = (self, exit) => { + if (self.state._tag === "Done") { + return; + } + const openState = self.state; + self.state = { + _tag: "Done", + exit }; -} -function withConstructorDefault2(defaultValue) { - return (schema) => make11(withConstructorDefault(schema.ast, defaultValue), { - schema - }); -} -function tag(literal) { - return Literal2(literal).pipe(withConstructorDefault2(succeed6(literal))); -} -function TaggedStruct(value, fields) { - return Struct({ - _tag: tag(value), - ...fields - }); -} -function instanceOf(constructor, annotations) { - return declare((u) => u instanceof constructor, annotations); -} -function link() { - return (encodeTo, transformation) => { - return new Link(encodeTo.ast, make8(transformation)); + for (const taker of openState.takers) { + taker(exit); + } + openState.takers.clear(); + for (const awaiter of openState.awaiters) { + awaiter(exit); + } + openState.awaiters.clear(); +}; + +// node_modules/effect/dist/Semaphore.js +var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); +var waitForPermits = (self, n, effect) => callback((resume) => { + if (self.free >= n) + return resume(effect); + const observer = () => { + if (self.free < n) + return; + self.waiters.delete(observer); + resume(effect); }; -} -var makeFilter2 = makeFilter; -function isPattern2(regExp, annotations) { - const source = regExp.source; - const flags = regExp.flags; - const runtimeRegExp = flags === "" ? `new RegExp(${format(source)})` : `new RegExp(${format(source)}, ${format(flags)})`; - return isPattern(regExp, { - toCode: () => ({ - runtime: `Schema.isPattern(${runtimeRegExp})` - }), - ...annotations - }); -} -function isBase64(annotations) { - const regExp = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; - return isPattern2(regExp, { - expected: "a base64 encoded string", - representation: { - id: "effect/schema/isBase64", - payload: null - }, - toJsonSchema: () => ({ - pattern: regExp.source - }), - toCode: () => ({ - runtime: "Schema.isBase64()" - }), - ...annotations - }); -} -function isInt(annotations) { - return makeFilter2((n) => globalThis.Number.isSafeInteger(n), { - expected: "an integer", - representation: { - id: "effect/schema/isInt", - payload: null - }, - toJsonSchema: () => ({ - type: "integer" - }), - toCode: () => ({ - runtime: "Schema.isInt()" - }), - arbitraryConstraint: { - number: "integer" - }, - ...annotations + self.waiters.add(observer); + return sync(() => { + self.waiters.delete(observer); }); -} -var Int = /* @__PURE__ */ Number5.check(/* @__PURE__ */ isInt()); -var RegExp2 = /* @__PURE__ */ instanceOf(globalThis.RegExp, { - representation: { - id: "effect/schema/RegExp", - payload: null - }, - toCode: () => ({ - runtime: `Schema.RegExp`, - Type: `globalThis.RegExp` - }), - expected: "RegExp", - toCodecJson: () => link()(Struct({ - source: String4, - flags: String4 - }), transformEffect2({ - decode: (e, options) => try_2({ - try: () => new globalThis.RegExp(e.source, e.flags), - catch: () => new InvalidValue({ - expected: "valid RegExp source and flags" - }, e, options) - }), - encode: (regExp) => succeed6({ - source: regExp.source, - flags: regExp.flags - }) - })) -}); -var URLString = /* @__PURE__ */ String4.annotate({ - expected: "a string that will be decoded as a URL" -}); -var URL2 = /* @__PURE__ */ instanceOf(globalThis.URL, { - representation: { - id: "effect/schema/URL", - payload: null - }, - toCode: () => ({ - runtime: `Schema.URL`, - Type: `globalThis.URL` - }), - expected: "URL", - toCodecJson: () => link()(URLString, urlFromString) }); -var File = /* @__PURE__ */ instanceOf(globalThis.File, { - representation: { - id: "effect/schema/File", - payload: null - }, - toCode: () => ({ - runtime: `Schema.File`, - Type: `globalThis.File` - }), - expected: "File", - toCodecJson: () => link()(Struct({ - data: String4.check(isBase64()), - type: String4, - name: String4, - lastModified: Int - }), transformEffect2({ - decode: (e, options) => match3(decodeBase64(e.data), { - onFailure: () => fail6(new InvalidValue({ - expected: "a valid Base64 string" - }, e.data, options)), - onSuccess: (bytes) => { - const buffer = new globalThis.Uint8Array(bytes); - return succeed6(new globalThis.File([buffer], e.name, { - type: e.type, - lastModified: e.lastModified - })); - } - }), - encode: (file, options) => tryPromise2({ - try: async () => { - const bytes = new globalThis.Uint8Array(await file.arrayBuffer()); - return { - data: encodeBase64(bytes), - type: file.type, - name: file.name, - lastModified: file.lastModified - }; - }, - catch: () => new InvalidValue({ - expected: "a readable File" - }, file, options) - }) - })) -}); -var FormData2 = /* @__PURE__ */ instanceOf(globalThis.FormData, { - representation: { - id: "effect/schema/FormData", - payload: null - }, - toCode: () => ({ - runtime: `Schema.FormData`, - Type: `globalThis.FormData` - }), - expected: "FormData", - toCodecJson: () => link()(ArraySchema(Tuple([String4, Union2([Struct({ - _tag: tag("String"), - value: String4 - }), Struct({ - _tag: tag("File"), - value: File - })])])), transformEffect2({ - decode: (e) => { - const out = new globalThis.FormData; - for (const [key, entry] of e) { - out.append(key, entry.value); + +class SemaphoreImpl { + waiters = /* @__PURE__ */ new Set; + taken = 0; + permits; + constructor(permits) { + this.permits = permits; + } + get free() { + return this.permits - this.taken; + } + take(n) { + const take = suspend(() => { + if (this.free < n) { + return waitForPermits(this, n, take); } - return succeed6(out); - }, - encode: (formData) => { - return succeed6(globalThis.Array.from(formData.entries()).map(([key, value]) => { - if (typeof value === "string") { - return [key, { - _tag: "String", - value - }]; - } else { - return [key, { - _tag: "File", - value - }]; + this.taken += n; + return succeed3(n); + }); + return take; + } + takeIfAvailable(n) { + return suspend(() => { + if (this.free < n) + return succeed3(false); + this.taken += n; + return succeed3(true); + }); + } + releaseUnsafe(fiber, n) { + this.taken -= n; + if (this.waiters.size > 0) { + fiber.currentDispatcher.scheduleTask(() => { + for (const observer of this.waiters) { + if (this.free <= 0) + break; + observer(); } - })); + }, 0); } - })) -}); -var URLSearchParams2 = /* @__PURE__ */ instanceOf(globalThis.URLSearchParams, { - representation: { - id: "effect/schema/URLSearchParams", - payload: null - }, - toCode: () => ({ - runtime: `Schema.URLSearchParams`, - Type: `globalThis.URLSearchParams` - }), - expected: "URLSearchParams", - toCodecJson: () => link()(String4.annotate({ - expected: "a query string that will be decoded as URLSearchParams" - }), transform2({ - decode: (e) => new globalThis.URLSearchParams(e), - encode: (params) => params.toString() - })) -}); -var Base64String = /* @__PURE__ */ String4.annotate({ - expected: "a base64 encoded string that will be decoded as Uint8Array", - format: "byte", - contentEncoding: "base64" -}); -var Uint8Array2 = /* @__PURE__ */ instanceOf(globalThis.Uint8Array, { - representation: { - id: "effect/schema/Uint8Array", - payload: null - }, - toCode: () => ({ - runtime: `Schema.Uint8Array`, - Type: `globalThis.Uint8Array` - }), - expected: "Uint8Array", - toCodecJson: () => link()(Base64String, uint8ArrayFromBase64String) -}); -var arbitraryMinimumDateTimestamp = -8640000000000000; -var arbitraryMaximumDateTimestamp = 8640000000000000; -var arbitraryMinimumZonedDateTimeTimestamp = arbitraryMinimumDateTimestamp + 14 * 60 * 60 * 1000; -var arbitraryMaximumZonedDateTimeTimestamp = arbitraryMaximumDateTimestamp - 14 * 60 * 60 * 1000; -var arbitraryMinimumTimeZoneOffset = -12 * 60 * 60 * 1000; -var arbitraryMaximumTimeZoneOffset = 14 * 60 * 60 * 1000; -var immerable = /* @__PURE__ */ globalThis.Symbol.for("immer-draftable"); -var payloadToken = {}; -function makeClass(Inherited, identifier, struct2, annotations, proto) { - const getClassSchema = getClassSchemaFactory(struct2, identifier, annotations); - const ClassTypeId = getClassTypeId(identifier); - const out = class extends Inherited { - constructor(...[input, options]) { - const internalOptions = options; - const payload = internalOptions?.["~payload"]; - const value = payload?.token === payloadToken ? payload.value : struct2.make(input ?? {}, options); - super(value, { - ...options, - disableChecks: true, - "~payload": { - token: payloadToken, - value + return this.free; + } + resize(permits) { + return withFiber((fiber) => { + this.permits = permits; + if (this.free < 0) + return void_; + this.releaseUnsafe(fiber, 0); + return void_; + }); + } + release(n) { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); + } + get releaseAll() { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); + } + withPermits(n) { + return (self) => uninterruptibleMask((restore) => { + const acquire = suspend(() => { + if (this.free < n) { + const wait = waitForPermits(this, n, void_); + return flatMap2(restore(wait), () => acquire); } + this.taken += n; + return onExitPrimitive(restore(self), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); }); - } - static [TypeId13] = TypeId13; - get [ClassTypeId]() { - return ClassTypeId; - } - static [immerable] = true; - static identifier = identifier; - static fields = struct2.fields; - static get ast() { - return getClassSchema(this).ast; - } - static pipe() { - return pipeArguments(this, arguments); - } - static rebuild(ast) { - return getClassSchema(this).rebuild(ast); - } - static make(input, options) { - return make9(getClassSchema(this))(input ?? {}, options); - } - static makeOption(input, options) { - return makeOption(getClassSchema(this))(input ?? {}, options); - } - static makeEffect(input, options) { - return getClassSchema(this).makeEffect(input ?? {}, options); - } - static annotate(annotations) { - return this.rebuild(annotate(this.ast, annotations)); - } - static annotateKey(annotations) { - return this.rebuild(annotateKey(this.ast, annotations)); - } - static check(...checks) { - return this.rebuild(appendChecks(this.ast, checks)); - } - static extend(identifier2) { - return (schema, annotations) => { - const extension = isStruct(schema) ? schema : Struct(schema); - const fields = { - ...struct2.fields, - ...extension.fields - }; - const ast = struct(fields, struct2.ast.checks, { - identifier: identifier2 - }); - return makeClass(this, identifier2, makeStruct(appendChecks(ast, extension.ast.checks), fields), annotations, proto); - }; - } - static mapFields(f, options) { - return struct2.mapFields(f, options); - } - }; - if (proto !== undefined) { - Object.assign(out.prototype, proto(identifier)); + return acquire; + }); + } + withPermit = /* @__PURE__ */ this.withPermits(1); + withPermitsIfAvailable(n) { + return (self) => uninterruptibleMask((restore) => { + if (this.free < n) + return succeedNone; + this.taken += n; + return onExitPrimitive(restore(asSome(self)), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); } - return out; -} -function getClassTransformation(self) { - return new Transformation(transform((input) => new self(input, { - "~payload": { - token: payloadToken, - value: input - } - })), passthrough()); -} -function getClassTypeId(identifier) { - return `~effect/Schema/Class/${identifier}`; } -function getClassSchemaFactory(from, identifier, annotations) { - let memo; - return (self) => { - if (memo !== undefined) { - return memo; - } - const ClassTypeId = getClassTypeId(identifier); - const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId); - const transformation = getClassTransformation(self); - const to = make11(new Declaration([from.ast], () => (input, ast, options) => { - return isClassValue(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)); - }, { - identifier, - [CONSTRUCTOR_ANNOTATION_KEY]: ([from]) => ({ - isConstructed: isClassValue, - link: new Link(from, transformation) - }), - toCodec: ([from]) => new Link(from.ast, transformation), - toEquivalence: ([from]) => from, - toFormatter: ([from]) => (t) => `${self.identifier}(${from(t)})`, - [SENTINELS_ANNOTATION_KEY]: collectSentinels(from.ast), - ...annotations - })); - return memo = decodeTo2(to, transformation)(from); - }; -} -function isStruct(schema) { - return isSchema(schema); -} -var Error4 = (identifier) => (schema, annotations) => { - const struct = isStruct(schema) ? schema : Struct(schema); - const self = makeClass(Error2, identifier, struct, annotations, (identifier) => ({ - name: identifier - })); - return self; -}; -var TaggedError3 = (identifier) => { - return (tagValue, schema, annotations) => { - const struct = isStruct(schema) ? schema.mapFields((fields) => ({ - _tag: tag(tagValue), - ...fields - }), { - unsafePreserveChecks: true - }) : TaggedStruct(tagValue, schema); - return Error4(identifier ?? tagValue)(struct, annotations); - }; -}; -// node_modules/effect/dist/Fiber.js -var interrupt3 = fiberInterrupt; -var runIn = fiberRunIn; - -// node_modules/effect/dist/Latch.js -var makeUnsafe5 = makeLatchUnsafe; -// node_modules/effect/dist/MutableList.js -var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); -var make12 = () => ({ - head: undefined, - tail: undefined, - length: 0 -}); -var emptyBucket = () => ({ - array: [], - mutable: true, - offset: 0, - next: undefined -}); -var append2 = (self, message) => { - if (!self.tail) { - self.head = self.tail = emptyBucket(); - } else if (!self.tail.mutable) { - self.tail.next = emptyBucket(); - self.tail = self.tail.next; +// node_modules/effect/dist/Channel.js +var TypeId12 = "~effect/Channel"; +var isChannel = (u) => hasProperty(u, TypeId12); +var ChannelProto = { + [TypeId12]: { + _Env: identity, + _InErr: identity, + _InElem: identity, + _OutErr: identity, + _OutElem: identity + }, + pipe() { + return pipeArguments(this, arguments); } - self.tail.array.push(message); - self.length++; }; -var clear = (self) => { - self.head = self.tail = undefined; - self.length = 0; +var fromTransform = (transform) => { + const self = Object.create(ChannelProto); + self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); + return self; }; -var takeN = (self, n) => { - n = normalize(n); - if (n <= 0 || !self.head) - return []; - n = Math.min(n, self.length); - if (n === self.length && self.head?.offset === 0 && !self.head.next) { - const array = self.head.array; - clear(self); - return array; +var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); +var fromPull = (effect) => fromTransform((_, __) => effect); +var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { + const closableScope = forkUnsafe2(scope); + const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); + const pull = yield* onError2(f(upstream, scope, closableScope), onCause); + return onError2(pull, onCause); +})); +var toTransform = (channel) => channel.transform; +var asyncQueue = (scope, f, options) => make8({ + capacity: options?.bufferSize, + strategy: options?.strategy +}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); +var callbackArray = (f, options) => fromTransform((_, scope) => map5(asyncQueue(scope, f, options), takeAll2)); +var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); +var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done2())); +var map6 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { + let i = 0; + return map5(pull, (o) => f(o, i++)); +}))); +var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); +var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done2))))); +var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { + const strategy = options?.haltStrategy ?? "both"; + const queue = yield* bounded(0); + yield* addFinalizer2(forkedScope, shutdown(queue)); + let done = 0; + function onExit(side, cause) { + done++; + if (!isDoneCause(cause)) { + return failCause4(queue, cause); + } + switch (strategy) { + case "both": { + return done === 2 ? failCause4(queue, cause) : void_3; + } + case "left": + case "right": { + return side === strategy ? failCause4(queue, cause) : void_3; + } + case "either": { + return failCause4(queue, cause); + } + } } - const array = new Array(n); - let index = 0; - let chunk = self.head; - while (chunk) { - while (chunk.offset < chunk.array.length) { - array[index++] = chunk.array[chunk.offset]; - if (chunk.mutable) - chunk.array[chunk.offset] = undefined; - chunk.offset++; - if (index === n) { - self.head = chunk; - self.length -= n; - if (self.length === 0) - clear(self); - return array; + const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); + yield* runSide("left", left, forkUnsafe2(forkedScope)); + yield* runSide("right", right, forkUnsafe2(forkedScope)); + return take2(queue); +}))); +var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { + let stringBuilder = ""; + let midCRLF = false; + let done = none2(); + function splitLinesArray(chunk) { + const chunkBuilder = []; + function pushLine(segment) { + if (stringBuilder.length === 0) { + chunkBuilder.push(segment); + } else { + chunkBuilder.push(stringBuilder + segment); + stringBuilder = ""; } } - chunk = chunk.next; + for (let i = 0;i < chunk.length; i++) { + const str = chunk[i]; + if (str.length !== 0) { + let from = 0; + let indexOfCR = str.indexOf("\r"); + let indexOfLF = str.indexOf(` +`); + if (midCRLF) { + if (indexOfLF === 0) { + from = 1; + indexOfLF = str.indexOf(` +`, from); + } + midCRLF = false; + } + while (indexOfCR !== -1 || indexOfLF !== -1) { + if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { + pushLine(str.substring(from, indexOfLF)); + from = indexOfLF + 1; + indexOfLF = str.indexOf(` +`, from); + } else { + pushLine(str.substring(from, indexOfCR)); + if (str.length === indexOfCR + 1) { + midCRLF = true; + from = str.length; + indexOfCR = -1; + } else { + from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); + indexOfCR = str.indexOf("\r", from); + indexOfLF = str.indexOf(` +`, from); + } + } + } + stringBuilder = stringBuilder + str.substring(from); + } + } + return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; } - clear(self); - return array; -}; -var take = (self) => { - if (!self.head) - return Empty; - const message = self.head.array[self.head.offset]; - if (self.head.mutable) - self.head.array[self.head.offset] = undefined; - self.head.offset++; - self.length--; - if (self.head.offset === self.head.array.length) { - if (self.head.next) { - self.head = self.head.next; - } else { - clear(self); + const pullOrFlush = suspend2(() => { + if (done._tag === "Some") { + return done2(done.value); } + return matchEffect2(upstream, { + onSuccess: loop, + onFailure: failCause3, + onDone: (leftover) => { + done = some2(leftover); + if (stringBuilder.length > 0) { + const last = stringBuilder; + stringBuilder = ""; + midCRLF = false; + return succeed6([last]); + } + return done2(leftover); + } + }); + }); + function loop(chunk) { + const lines = splitLinesArray(chunk); + return lines !== null ? succeed6(lines) : pullOrFlush; } - return message; -}; - -// node_modules/effect/dist/Queue.js -var TypeId14 = "~effect/Queue"; -var EnqueueTypeId = "~effect/Queue/Enqueue"; -var DequeueTypeId = "~effect/Queue/Dequeue"; -var variance = { - _A: identity, - _E: identity -}; -var QueueProto = { - [TypeId14]: variance, - [EnqueueTypeId]: variance, - [DequeueTypeId]: variance, - ...PipeInspectableProto, - toJSON() { - return { - _id: "effect/Queue", - state: this.state._tag, - size: sizeUnsafe(this) - }; - } -}; -var make13 = (options) => withFiber((fiber) => { - const self = Object.create(QueueProto); - self.dispatcher = fiber.currentDispatcher; - self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; - self.strategy = options?.strategy ?? "suspend"; - self.messages = make12(); - self.scheduleRunning = false; - self.state = { - _tag: "Open", - takers: new Set, - offers: new Set, - awaiters: new Set - }; - return succeed3(self); + return pullOrFlush; +})); +var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); +var unwrap = (channel) => fromTransform((upstream, scope) => { + let pull; + return succeed6(suspend2(() => { + if (pull) + return pull; + return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); + })); }); -var bounded = (capacity) => make13({ - capacity +var runWith = (self, f, onHalt) => suspend2(() => { + const scope = makeUnsafe3(); + const makePull = toTransform(self)(done2(), scope); + return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); }); -var offer = (self, message) => suspend(() => { - if (self.state._tag !== "Open") { - return exitFalse; - } else if (self.messages.length >= self.capacity) { - switch (self.strategy) { - case "dropping": - return exitFalse; - case "suspend": - if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return exitTrue; - } - return offerRemainingSingle(self, message); - case "sliding": - take(self.messages); - append2(self.messages, message); - return exitTrue; +var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { + disableYield: true +}))); +var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { + let state = initial(); + return runWith(self, (pull) => whileLoop2({ + while: constTrue, + body: () => pull, + step: (value) => { + state = f(state, value); } + }), () => succeed6(state)); +})); +var toPullScoped = (self, scope) => toTransform(self)(done2(), scope); +// node_modules/effect/dist/internal/schema/interpreter.js +var flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager2(result, f); +function compileTransformation(transformation) { + if (transformation._tag === "Middleware") { + return (result, current, options) => { + const transformed = result === sameExit ? transformation.decode(succeed7(toOption(current)), options) : transformation.decode(mapEager2(result, toOption), options); + return fromOptionalEffect(transformed); + }; } - append2(self.messages, message); - scheduleReleaseTaker(self); - return exitTrue; -}); -var offerUnsafe = (self, message) => { - if (self.state._tag !== "Open") { - return false; - } else if (self.messages.length >= self.capacity) { - if (self.strategy === "sliding") { - take(self.messages); - append2(self.messages, message); - return true; - } else if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return true; + const getter = transformation.decode; + switch (getter._tag) { + case "Passthrough": + return (result, current) => result === sameExit ? succeed7(current) : result; + case "Transform": { + const transform = (value) => value === missing ? missingExit : succeed7(getter.transform(value)); + return (result, current) => flatMapTransformation(result, current, transform); } - return false; + case "TransformOptional": { + const transform = (value) => fromOptionExit(getter.transform(toOption(value))); + return (result, current) => flatMapTransformation(result, current, transform); + } + case "TransformEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => value === missing ? missingExit : getter.transform(value, options)); + case "TransformOptionalEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => fromOptionalEffect(getter.transform(toOption(value), options))); } - append2(self.messages, message); - scheduleReleaseTaker(self); - return true; -}; -var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); -var failCauseUnsafe = (self, cause) => { - if (self.state._tag !== "Open") { - return false; +} +var fromOptionalEffect = (effect) => flatMapEager2(effect, fromOptionExit); +var wrapEncoding = (ast, input, options, effect) => catchCause2(effect, (cause) => failCauseSync2(() => map4(cause, (issue) => new Encoding(ast, issue, input, options)))); +function makeConstructorParser(descriptor, compile) { + const transform = compileTransformation(descriptor.link.transformation); + let sourceParser; + return (input, options) => { + if (input === missing) + return missingExit; + if (descriptor.isConstructed(input)) + return sameExit; + const result = (sourceParser ??= compile(descriptor.link.to))(input, options); + return transform(result, input, options); + }; +} +function withDefault(ast, parser) { + const defaultValue = ast.context.constructorDefault; + return (input, options) => { + if (input !== missing && input !== undefined) + return parser(input, options); + const result = defaultValue; + if (effectIsExit(result) && result._tag === "Success") { + const local = parser(result[args], options); + return local === sameExit ? result : local; + } + return flatMapEager2(wrapEncoding(ast, input, options, result), (value) => { + const local = parser(value, options); + return local === sameExit ? succeed7(value) : local; + }); + }; +} +function compileField(ast, compile) { + const parser = compile(ast); + return ast.context?.constructorDefault === undefined ? parser : withDefault(ast, parser); +} +function compile(ast, compile, compileField, base, specialize) { + if (ast._tag === "Declaration") { + for (const parameter of ast.typeParameters) + compile(parameter); } - const exit = exitFailCause(cause); - const fail = exitZipRight(exit, exitFailDone); - if (self.state.offers.size === 0 && self.messages.length === 0) { - finalize(self, fail); - return true; + const descriptor = compileField ? getConstructorDescriptor(ast) : undefined; + const parser = descriptor ? makeConstructorParser(descriptor, compile) : base ?? ast.getParser(compile, compileField); + const checks = ast.checks; + const links = ast.encoding; + const transformations = links?.map((link) => compileTransformation(link.transformation)); + const encodingChecks = ast.encodingChecks; + if (!links && !checks && !encodingChecks) { + return parser; } - self.state = { - ...self.state, - _tag: "Closing", - exit: fail + let encodingParsers; + const parseChecks = (input, options) => { + let result = parser(input, options); + if (encodingChecks && !options.disableChecks) { + if (effectIsExit(result)) { + if (result._tag === "Success") { + const output = result === sameExit ? input : result[args]; + if (input !== missing && output !== missing) { + const issues = collectIssues(encodingChecks, input, undefined, ast, options); + if (issues) { + result = fail6(new Composite(ast, issues, input, options)); + } + } + } + } else { + result = flatMap3(result, (value) => { + if (input !== missing && value !== missing) { + const issues = collectIssues(encodingChecks, input, undefined, ast, options); + if (issues) { + return fail6(new Composite(ast, issues, input, options)); + } + } + return succeed6(value); + }); + } + } + if (checks && !options.disableChecks) { + if (effectIsExit(result)) { + if (result._tag === "Success") { + const value = result === sameExit ? input : result[args]; + if (value === missing) + return result; + const issues = collectIssues(checks, value, undefined, ast, options); + if (issues) { + result = fail6(new Composite(ast, issues, value, options)); + } + } + } else { + result = flatMap3(result, (value) => { + if (value !== missing) { + const issues = collectIssues(checks, value, undefined, ast, options); + if (issues) { + return fail6(new Composite(ast, issues, value, options)); + } + } + return succeed6(value); + }); + } + } + return result; }; - return true; -}; -var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); -var shutdown = (self) => sync(() => { - if (self.state._tag === "Done") { - return true; + const parseLocal = specialize === undefined ? parseChecks : specialize(parseChecks); + if (!links) { + return parseLocal; } - clear(self.messages); - const offers = self.state.offers; - finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); - if (offers.size > 0) { - for (const entry of offers) { - if (entry._tag === "Single") { - entry.resume(exitFalse); - } else { - entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); + return (input, options) => { + const parsers = encodingParsers ??= links.map((link) => compile(link.to)); + let current = input; + let result = parsers[parsers.length - 1](input, options); + for (let i = links.length - 1;i >= 0; i--) { + result = transformations[i](result, current, options); + if (i !== 0) { + const next = parsers[i - 1]; + if (result._tag === "Success") { + current = result[args]; + result = next(current, options); + } else { + result = flatMapEager2(result, (value) => { + const nextResult = next(value, options); + return nextResult === sameExit ? succeed7(value) : nextResult; + }); + } } } - offers.clear(); + if (result._tag === "Success") { + const value = result[args]; + const local = parseLocal(value, options); + return local === sameExit ? result : local; + } + result = wrapEncoding(ast, input, options, result); + return flatMapEager2(result, (value) => { + const local = parseLocal(value, options); + return local === sameExit ? succeed7(value) : local; + }); + }; +} + +// node_modules/effect/dist/internal/schema/compilerRegistry.js +var invalid3 = /* @__PURE__ */ Symbol(); +var cache = /* @__PURE__ */ new WeakMap; +var compiler; +var compilerAdaptersEnabled = false; +var decodeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "parser") : resolve2(ast).parser; +var makeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "makeEffect") : resolve2(ast).makeEffect; +var makeField = (ast) => compileField(ast, makeChild); + +class InterpretedEntry { + ast; + constructor(ast) { + this.ast = ast; } - return true; -}); -var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); -var takeBetween = (self, min, max) => { - min = normalize(min); - max = normalize(max); - return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); -}; -var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); -var poll = (self) => suspend(() => { - const result = takeUnsafe(self); - if (result === undefined) { - return succeed3(none2()); + get decodeEffect() { + return this.cachedDecodeEffect ??= compile(this.ast, decodeChild); } - if (result._tag === "Success") { - return succeed3(some2(result.value)); + get parser() { + return this.decodeEffect; } - return succeed3(none2()); -}); -var takeUnsafe = (self) => { - if (self.state._tag === "Done") { - return self.state.exit; + get makeEffect() { + return this.cachedMakeEffect ??= compile(this.ast, makeChild, makeField); } - if (self.messages.length > 0) { - const message = take(self.messages); - releaseCapacity(self); - return exitSucceed(message); - } else if (self.capacity <= 0 && self.state.offers.size > 0) { - const message = takeOfferUnsafe(self.state.offers); - releaseCapacity(self); - return exitSucceed(message); +} + +class CompilerEntry extends InterpretedEntry { + compiled; + resolve; + constructor(ast, compiled, resolve) { + super(ast); + this.compiled = compiled; + this.resolve = resolve; + } + save(key, value) { + Object.defineProperty(this, key, { + value + }); + return value; } - return; -}; -var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; -var exitFalse = /* @__PURE__ */ exitSucceed(false); -var exitTrue = /* @__PURE__ */ exitSucceed(true); -var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); -var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); -var releaseTakers = (self) => { - if (self.state._tag === "Done" || self.state.takers.size === 0) { - return; + operation(key) { + const compiled = this.compiled; + return typeof compiled === "function" ? compiled(this.ast, this.resolve, key) : compiled?.[key]; } - for (const taker of self.state.takers) { - self.state.takers.delete(taker); - taker(exitVoid); - if (self.messages.length === 0) { - break; - } + get is() { + return this.save("is", this.operation("is")); } -}; -var scheduleReleaseTaker = (self) => { - if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { - return; + get decode() { + return this.save("decode", this.operation("decode")); } - self.scheduleRunning = true; - self.dispatcher.scheduleTask(() => { - self.scheduleRunning = false; - releaseTakers(self); - }, 0); -}; -var takeBetweenUnsafe = (self, min, max) => { - if (self.state._tag === "Done") { - return self.state.exit; - } else if (max <= 0 || min <= 0) { - return exitSucceed([]); - } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { - const messages = [takeOfferUnsafe(self.state.offers)]; - releaseCapacity(self); - return exitSucceed(messages); + get make() { + return this.save("make", this.operation("make")); } - min = Math.min(min, self.capacity || 1); - if (min <= self.messages.length) { - const messages = takeN(self.messages, max); - releaseCapacity(self); - return exitSucceed(messages); + get decodeEffect() { + return this.save("decodeEffect", this.operation("decodeEffect") ?? compile(this.ast, (ast) => lazyParser(this.resolve, ast, "parser"))); } -}; -var offerRemainingSingle = (self, message) => { - return callback((resume) => { - if (self.state._tag !== "Open") { - return resume(exitFalse); - } - const entry = { - _tag: "Single", - message, - resume - }; - self.state.offers.add(entry); - return sync(() => { - if (self.state._tag === "Open") { - self.state.offers.delete(entry); - } - }); - }); -}; -var takeOfferUnsafe = (offers) => { - const entry = offers.values().next().value; - if (entry._tag === "Single") { - offers.delete(entry); - entry.resume(exitTrue); - return entry.message; + get parser() { + const decode = this.decode; + return decode === undefined ? this.decodeEffect : this.save("parser", withDecode(decode, () => this.decodeEffect)); } - const message = entry.remaining[entry.offset++]; - if (entry.offset === entry.remaining.length) { - offers.delete(entry); - entry.resume(exitSucceed([])); + get makeEffect() { + const makeEffect = this.operation("makeEffect"); + if (makeEffect !== undefined) + return this.save("makeEffect", makeEffect); + const child = (ast) => lazyParser(this.resolve, ast, "makeEffect"); + return this.save("makeEffect", compile(this.ast, child, (ast) => compileField(ast, child))); } - return message; -}; -var releaseCapacity = (self) => { - if (self.state._tag === "Done") { - return isDoneCause(self.state.exit.cause); - } else if (self.state.offers.size === 0) { - if (self.state._tag === "Closing" && self.messages.length === 0) { - finalize(self, self.state.exit); - return isDoneCause(self.state.exit.cause); +} +function withDecode(fastDecode, decodeEffect) { + let detailed; + return (input, options) => { + if (input !== missing) { + try { + const value = fastDecode(input, options); + if (value !== invalid3) + return value === input ? sameExit : succeed7(value); + } catch (error) { + return die3(error); + } } - return false; + return (detailed ??= decodeEffect())(input, options); + }; +} +function lazyParser(resolve, ast, operation) { + const entry = resolve(ast); + if (entry.compiled === undefined || Object.hasOwn(entry, operation)) { + return entry[operation]; } - for (const entry of self.state.offers) { - let n = self.capacity - self.messages.length; - if (n <= 0) - break; - else if (entry._tag === "Single") { - append2(self.messages, entry.message); - self.state.offers.delete(entry); - entry.resume(exitTrue); - } else { - for (;entry.offset < entry.remaining.length; entry.offset++) { - if (n === 0) - return false; - append2(self.messages, entry.remaining[entry.offset]); - n--; - } - self.state.offers.delete(entry); - entry.resume(exitSucceed([])); + let parser; + return (input, options) => (parser ??= entry[operation])(input, options); +} +function resolve2(ast) { + const cached = cache.get(ast); + if (cached !== undefined) + return cached; + const entry = compiler === undefined ? new InterpretedEntry(ast) : new CompilerEntry(ast, compiler(ast, resolve2), resolve2); + cache.set(ast, entry); + return entry; +} + +// node_modules/effect/dist/SchemaParser.js +function makeEffect(schema) { + const ast = schema.ast; + let parser; + return (input, options) => { + return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions); + }; +} +function makeOption(schema) { + const parser = makeEffect(schema); + return (input, options) => { + const exit = runSyncExit2(parser(input, options)); + if (isSuccess3(exit)) { + return some2(exit.value); } + getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); + return none2(); + }; +} +function make9(schema) { + return makeConstructorSync(toType(schema.ast)); +} +function decodeUnknownEffect(schema, options) { + const parser = run(schema.ast); + return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); +} +var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { + ...options, + ...overrideOptions +} : options; +var getValue = (value) => { + if (value === missing) { + return fail6(new InvalidValue); } - return false; + return succeed6(value); }; -var awaitTake = (self) => callback((resume) => { - if (self.state._tag === "Done") { - return resume(self.state.exit); +function run(ast) { + return runWithCompiler(normalCompiler, ast); +} +function parserResult(result, input) { + if (result === sameExit) { + return succeed6(input); } - self.state.takers.add(resume); - return sync(() => { - if (self.state._tag !== "Done") { - self.state.takers.delete(resume); - } - }); -}); -var finalize = (self, exit) => { - if (self.state._tag === "Done") { - return; + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); } - const openState = self.state; - self.state = { - _tag: "Done", - exit + return result[args] === missing ? getValue(missing) : result; +} +function runWithCompiler(compiler, ast) { + let parser; + return (input, options) => { + const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; }; - for (const taker of openState.takers) { - taker(exit); - } - openState.takers.clear(); - for (const awaiter of openState.awaiters) { - awaiter(exit); +} +function runSync2(effect, message) { + const exit = runSyncExit2(effect); + if (isSuccess3(exit)) { + return exit.value; } - openState.awaiters.clear(); -}; - -// node_modules/effect/dist/Semaphore.js -var makeUnsafe6 = (permits) => new SemaphoreImpl(permits); -var waitForPermits = (self, n, effect) => callback((resume) => { - if (self.free >= n) - return resume(effect); - const observer = () => { - if (self.free < n) - return; - self.waiters.delete(observer); - resume(effect); - }; - self.waiters.add(observer); - return sync(() => { - self.waiters.delete(observer); + const issue = getSchemaIssueOrThrow(exit.cause, message); + throw new Error("Schema validation failed", { + cause: issue }); -}); +} +function makeConstructorSync(ast) { + let entry; + let parser; + return (input, options) => { + entry ??= resolve2(ast); + const parseOptions = options?.disableChecks ? options.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions ?? defaultParseOptions; + const make = entry.make; + if (make !== undefined && input !== missing) { + let output; + try { + output = make(input, parseOptions); + } catch (error) { + getSchemaIssueOrThrow(die2(error), "Constructor adapter can only throw schema issues"); + throw error; + } + if (output !== invalid3 && output !== missing) + return output; + } + const result = (parser ??= entry.makeEffect)(input, parseOptions); + return runSync2(parserResult(result, input), "Constructor adapter can only throw schema issues"); + }; +} +var normalCompiler = (ast) => resolve2(ast).parser; +var constructorCompiler = (ast) => resolve2(ast).makeEffect; -class SemaphoreImpl { - waiters = /* @__PURE__ */ new Set; - taken = 0; - permits; - constructor(permits) { - this.permits = permits; - } - get free() { - return this.permits - this.taken; +// node_modules/effect/dist/internal/schema/make.js +var TypeId13 = "~effect/Schema/Schema"; +var SchemaProto = { + [TypeId13]: TypeId13, + pipe() { + return pipeArguments(this, arguments); + }, + annotate(annotations) { + return this.rebuild(annotate(this.ast, annotations)); + }, + annotateKey(annotations) { + return this.rebuild(annotateKey(this.ast, annotations)); + }, + check(...checks) { + return this.rebuild(appendChecks(this.ast, checks)); } - take(n) { - const take = suspend(() => { - if (this.free < n) { - return waitForPermits(this, n, take); - } - this.taken += n; - return succeed3(n); - }); - return take; +}; +function make10(ast, options) { + function Schema() {} + const self = Object.setPrototypeOf(Schema, SchemaProto); + if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) { + Object.defineProperties(self, Object.getOwnPropertyDescriptors({ + ...options + })); + } else { + Object.assign(self, options); } - takeIfAvailable(n) { - return suspend(() => { - if (this.free < n) - return succeed3(false); - this.taken += n; - return succeed3(true); - }); - } - releaseUnsafe(fiber, n) { - this.taken -= n; - if (this.waiters.size > 0) { - fiber.currentDispatcher.scheduleTask(() => { - for (const observer of this.waiters) { - if (this.free <= 0) - break; - observer(); - } - }, 0); + self.ast = ast; + self.rebuild = (ast) => make10(ast, options); + self.makeEffect = makeEffect(self); + self.make = make9(self); + self.makeOption = makeOption(self); + return self; +} + +// node_modules/effect/dist/Struct.js +var lambda = (f) => f; + +// node_modules/effect/dist/internal/schemaError.js +var SchemaErrorTypeId = "~effect/Schema/SchemaError"; +function isSchemaError(u) { + return hasProperty(u, SchemaErrorTypeId) && u[SchemaErrorTypeId] === SchemaErrorTypeId; +} + +// node_modules/effect/dist/Schema.js +var TypeId14 = TypeId13; +function declareConstructor() { + return (typeParameters, run, annotations) => { + return make11(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make11(ast))), annotations)); + }; +} +function declare(is, annotations) { + return declareConstructor()([], () => (input, ast, options) => is(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)), annotations); +} +class SchemaError extends (/* @__PURE__ */ TaggedError2("SchemaError")) { + [SchemaErrorTypeId] = SchemaErrorTypeId; + constructor(issue) { + const stackTraceLimit = getStackTraceLimit(); + setStackTraceLimit(0); + try { + super({ + issue + }); + } finally { + setStackTraceLimit(stackTraceLimit); } - return this.free; } - resize(permits) { - return withFiber((fiber) => { - this.permits = permits; - if (this.free < 0) - return void_; - this.releaseUnsafe(fiber, 0); - return void_; - }); - } - release(n) { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); + get message() { + return defaultFormatter(this.issue); } - get releaseAll() { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); + toString() { + return `SchemaError(${this.message})`; } - withPermits(n) { - return (self) => uninterruptibleMask((restore) => { - const acquire = suspend(() => { - if (this.free < n) { - const wait = waitForPermits(this, n, void_); - return flatMap2(restore(wait), () => acquire); - } - this.taken += n; - return onExitPrimitive(restore(self), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); - return acquire; - }); +} +function isSchemaError2(u) { + return isSchemaError(u); +} +function fromIssueEffect(self) { + if (effectIsExit(self)) { + return fromIssueExit(self); } - withPermit = /* @__PURE__ */ this.withPermits(1); - withPermitsIfAvailable(n) { - return (self) => uninterruptibleMask((restore) => { - if (this.free < n) - return succeedNone; - this.taken += n; - return onExitPrimitive(restore(asSome(self)), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); + return catchCause2(self, (cause) => failCauseSync2(() => map4(cause, (issue) => new SchemaError(issue)))); +} +function fromIssueExit(exit) { + return isSuccess3(exit) ? exit : failCause2(map4(exit.cause, (issue) => new SchemaError(issue))); +} +function decodeUnknownEffect2(schema, options) { + const parser = decodeUnknownEffect(schema, options); + return (input, options) => { + return fromIssueEffect(parser(input, options)); + }; +} +var make11 = make10; +function isSchema(u) { + return hasProperty(u, TypeId14) && u[TypeId14] === TypeId14; +} +var optionalKey2 = /* @__PURE__ */ lambda((schema) => make11(optionalKey(schema.ast), { + schema +})); +function Literal2(literal) { + const out = make11(new Literal(literal), { + literal, + transform(to) { + return out.pipe(decodeTo2(Literal2(to), { + decode: transform(() => to), + encode: transform(() => literal) + })); + } + }); + return out; +} +var String4 = /* @__PURE__ */ make11(string2); +var Number5 = /* @__PURE__ */ make11(number2); +function makeStruct(ast, fields) { + return make11(ast, { + fields, + mapFields(f, options) { + const fields = f(this.fields); + return makeStruct(struct(fields, options?.unsafePreserveChecks ? this.ast.checks : undefined), fields); + } + }); +} +function Struct(fields) { + return makeStruct(struct(fields, undefined), fields); +} +function makeTuple(ast, elements) { + return make11(ast, { + elements, + mapElements(f, options) { + const elements = f(this.elements); + return makeTuple(tuple(elements, options?.unsafePreserveChecks ? this.ast.checks : undefined), elements); + } + }); +} +function Tuple(elements) { + return makeTuple(tuple(elements), elements); +} +var ArraySchema = /* @__PURE__ */ lambda((schema) => make11(new Arrays(false, [], [schema.ast]), { + value: schema +})); +function makeUnion(ast, members) { + return make11(ast, { + members, + mapMembers(f, options) { + const members = f(this.members); + return makeUnion(union(members, this.ast.options, options?.unsafePreserveChecks ? this.ast.checks : undefined), members); + } + }); +} +function Union2(members, options) { + return makeUnion(union(members, options, undefined), members); +} +function Literals(literals) { + const members = literals.map(Literal2); + return make11(union(members, undefined, undefined), { + literals, + members, + mapMembers(f) { + return Union2(f(this.members)); + }, + pick(literals) { + return Literals(literals); + }, + transform(to) { + return Union2(members.map((member, index) => member.transform(to[index]))); + } + }); +} +function decodeTo2(to, transformation) { + return (from) => { + return make11(decodeTo(from.ast, to.ast, transformation ? makeTransformation(transformation) : passthrough2()), { + from, + to }); - } + }; } - -// node_modules/effect/dist/Channel.js -var TypeId15 = "~effect/Channel"; -var isChannel = (u) => hasProperty(u, TypeId15); -var ChannelProto = { - [TypeId15]: { - _Env: identity, - _InErr: identity, - _InElem: identity, - _OutErr: identity, - _OutElem: identity +function withConstructorDefault2(defaultValue) { + return (schema) => make11(withConstructorDefault(schema.ast, defaultValue), { + schema + }); +} +function tag(literal) { + return Literal2(literal).pipe(withConstructorDefault2(succeed6(literal))); +} +function TaggedStruct(value, fields) { + return Struct({ + _tag: tag(value), + ...fields + }); +} +function instanceOf(constructor, annotations) { + return declare((u) => u instanceof constructor, annotations); +} +function link() { + return (encodeTo, transformation) => { + return new Link(encodeTo.ast, makeTransformation(transformation)); + }; +} +var makeFilter2 = makeFilter; +function isPattern2(regExp, annotations) { + const source = regExp.source; + const flags = regExp.flags; + const runtimeRegExp = flags === "" ? `new RegExp(${format(source)})` : `new RegExp(${format(source)}, ${format(flags)})`; + return isPattern(regExp, { + toCode: () => ({ + runtime: `Schema.isPattern(${runtimeRegExp})` + }), + ...annotations + }); +} +function isBase64(annotations) { + const regExp = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; + return isPattern2(regExp, { + expected: "a base64 encoded string", + representation: { + id: "effect/schema/isBase64", + payload: null + }, + toJsonSchema: () => ({ + pattern: regExp.source + }), + toCode: () => ({ + runtime: "Schema.isBase64()" + }), + ...annotations + }); +} +function isInt(annotations) { + return makeFilter2((n) => globalThis.Number.isSafeInteger(n), { + expected: "an integer", + representation: { + id: "effect/schema/isInt", + payload: null + }, + toJsonSchema: () => ({ + type: "integer" + }), + toCode: () => ({ + runtime: "Schema.isInt()" + }), + arbitraryConstraint: { + number: "integer" + }, + ...annotations + }); +} +var Int = /* @__PURE__ */ Number5.check(/* @__PURE__ */ isInt()); +var RegExp2 = /* @__PURE__ */ instanceOf(globalThis.RegExp, { + representation: { + id: "effect/schema/RegExp", + payload: null }, - pipe() { - return pipeArguments(this, arguments); - } -}; -var fromTransform = (transform) => { - const self = Object.create(ChannelProto); - self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); - return self; -}; -var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); -var fromPull = (effect) => fromTransform((_, __) => effect); -var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { - const closableScope = forkUnsafe2(scope); - const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); - const pull = yield* onError2(f(upstream, scope, closableScope), onCause); - return onError2(pull, onCause); -})); -var toTransform = (channel) => channel.transform; -var asyncQueue = (scope, f, options) => make13({ - capacity: options?.bufferSize, - strategy: options?.strategy -}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); -var callbackArray = (f, options) => fromTransform((_, scope) => map6(asyncQueue(scope, f, options), takeAll2)); -var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); -var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done3())); -var map7 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { - let i = 0; - return map6(pull, (o) => f(o, i++)); -}))); -var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); -var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done3))))); -var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { - const strategy = options?.haltStrategy ?? "both"; - const queue = yield* bounded(0); - yield* addFinalizer2(forkedScope, shutdown(queue)); - let done = 0; - function onExit(side, cause) { - done++; - if (!isDoneCause(cause)) { - return failCause4(queue, cause); + toCode: () => ({ + runtime: `Schema.RegExp`, + Type: `globalThis.RegExp` + }), + expected: "RegExp", + toCodecJson: () => link()(Struct({ + source: String4, + flags: String4 + }), transformEffect2({ + decode: (e, options) => try_2({ + try: () => new globalThis.RegExp(e.source, e.flags), + catch: () => new InvalidValue({ + expected: "valid RegExp source and flags" + }, e, options) + }), + encode: (regExp) => succeed6({ + source: regExp.source, + flags: regExp.flags + }) + })) +}); +var URLString = /* @__PURE__ */ String4.annotate({ + expected: "a string that will be decoded as a URL" +}); +var URL2 = /* @__PURE__ */ instanceOf(globalThis.URL, { + representation: { + id: "effect/schema/URL", + payload: null + }, + toCode: () => ({ + runtime: `Schema.URL`, + Type: `globalThis.URL` + }), + expected: "URL", + toCodecJson: () => link()(URLString, urlFromString) +}); +var File = /* @__PURE__ */ instanceOf(globalThis.File, { + representation: { + id: "effect/schema/File", + payload: null + }, + toCode: () => ({ + runtime: `Schema.File`, + Type: `globalThis.File` + }), + expected: "File", + toCodecJson: () => link()(Struct({ + data: String4.check(isBase64()), + type: String4, + name: String4, + lastModified: Int + }), transformEffect2({ + decode: (e, options) => match2(decodeBase64(e.data), { + onFailure: () => fail6(new InvalidValue({ + expected: "a valid Base64 string" + }, e.data, options)), + onSuccess: (bytes) => { + const buffer = new globalThis.Uint8Array(bytes); + return succeed6(new globalThis.File([buffer], e.name, { + type: e.type, + lastModified: e.lastModified + })); + } + }), + encode: (file, options) => tryPromise2({ + try: async () => { + const bytes = new globalThis.Uint8Array(await file.arrayBuffer()); + return { + data: encodeBase64(bytes), + type: file.type, + name: file.name, + lastModified: file.lastModified + }; + }, + catch: () => new InvalidValue({ + expected: "a readable File" + }, file, options) + }) + })) +}); +var FormData2 = /* @__PURE__ */ instanceOf(globalThis.FormData, { + representation: { + id: "effect/schema/FormData", + payload: null + }, + toCode: () => ({ + runtime: `Schema.FormData`, + Type: `globalThis.FormData` + }), + expected: "FormData", + toCodecJson: () => link()(ArraySchema(Tuple([String4, Union2([Struct({ + _tag: tag("String"), + value: String4 + }), Struct({ + _tag: tag("File"), + value: File + })])])), transformEffect2({ + decode: (e) => { + const out = new globalThis.FormData; + for (const [key, entry] of e) { + out.append(key, entry.value); + } + return succeed6(out); + }, + encode: (formData) => { + return succeed6(globalThis.Array.from(formData.entries()).map(([key, value]) => { + if (typeof value === "string") { + return [key, { + _tag: "String", + value + }]; + } else { + return [key, { + _tag: "File", + value + }]; + } + })); + } + })) +}); +var URLSearchParams2 = /* @__PURE__ */ instanceOf(globalThis.URLSearchParams, { + representation: { + id: "effect/schema/URLSearchParams", + payload: null + }, + toCode: () => ({ + runtime: `Schema.URLSearchParams`, + Type: `globalThis.URLSearchParams` + }), + expected: "URLSearchParams", + toCodecJson: () => link()(String4.annotate({ + expected: "a query string that will be decoded as URLSearchParams" + }), transform2({ + decode: (e) => new globalThis.URLSearchParams(e), + encode: (params) => params.toString() + })) +}); +var Base64String = /* @__PURE__ */ String4.annotate({ + expected: "a base64 encoded string that will be decoded as Uint8Array", + format: "byte", + contentEncoding: "base64" +}); +var Uint8Array2 = /* @__PURE__ */ instanceOf(globalThis.Uint8Array, { + representation: { + id: "effect/schema/Uint8Array", + payload: null + }, + toCode: () => ({ + runtime: `Schema.Uint8Array`, + Type: `globalThis.Uint8Array` + }), + expected: "Uint8Array", + toCodecJson: () => link()(Base64String, uint8ArrayFromBase64String) +}); +var arbitraryMinimumDateTimestamp = -8640000000000000; +var arbitraryMaximumDateTimestamp = 8640000000000000; +var arbitraryMinimumZonedDateTimeTimestamp = arbitraryMinimumDateTimestamp + 14 * 60 * 60 * 1000; +var arbitraryMaximumZonedDateTimeTimestamp = arbitraryMaximumDateTimestamp - 14 * 60 * 60 * 1000; +var arbitraryMinimumTimeZoneOffset = -12 * 60 * 60 * 1000; +var arbitraryMaximumTimeZoneOffset = 14 * 60 * 60 * 1000; +var immerable = /* @__PURE__ */ globalThis.Symbol.for("immer-draftable"); +var payloadToken = {}; +function makeClass(Inherited, identifier, struct2, annotations, proto) { + const getClassSchema = getClassSchemaFactory(struct2, identifier, annotations); + const ClassTypeId = getClassTypeId(identifier); + const out = class extends Inherited { + constructor(...[input, options]) { + const internalOptions = options; + const payload = internalOptions?.["~payload"]; + const value = payload?.token === payloadToken ? payload.value : struct2.make(input ?? {}, options); + super(value, { + ...options, + disableChecks: true, + "~payload": { + token: payloadToken, + value + } + }); + } + static [TypeId14] = TypeId14; + get [ClassTypeId]() { + return ClassTypeId; + } + static [immerable] = true; + static identifier = identifier; + static fields = struct2.fields; + static get ast() { + return getClassSchema(this).ast; + } + static pipe() { + return pipeArguments(this, arguments); } - switch (strategy) { - case "both": { - return done === 2 ? failCause4(queue, cause) : void_3; - } - case "left": - case "right": { - return side === strategy ? failCause4(queue, cause) : void_3; - } - case "either": { - return failCause4(queue, cause); - } + static rebuild(ast) { + return getClassSchema(this).rebuild(ast); } - } - const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); - yield* runSide("left", left, forkUnsafe2(forkedScope)); - yield* runSide("right", right, forkUnsafe2(forkedScope)); - return take2(queue); -}))); -var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { - let stringBuilder = ""; - let midCRLF = false; - let done = none2(); - function splitLinesArray(chunk) { - const chunkBuilder = []; - function pushLine(segment) { - if (stringBuilder.length === 0) { - chunkBuilder.push(segment); - } else { - chunkBuilder.push(stringBuilder + segment); - stringBuilder = ""; - } + static make(input, options) { + return make9(getClassSchema(this))(input ?? {}, options); } - for (let i = 0;i < chunk.length; i++) { - const str = chunk[i]; - if (str.length !== 0) { - let from = 0; - let indexOfCR = str.indexOf("\r"); - let indexOfLF = str.indexOf(` -`); - if (midCRLF) { - if (indexOfLF === 0) { - from = 1; - indexOfLF = str.indexOf(` -`, from); - } - midCRLF = false; - } - while (indexOfCR !== -1 || indexOfLF !== -1) { - if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { - pushLine(str.substring(from, indexOfLF)); - from = indexOfLF + 1; - indexOfLF = str.indexOf(` -`, from); - } else { - pushLine(str.substring(from, indexOfCR)); - if (str.length === indexOfCR + 1) { - midCRLF = true; - from = str.length; - indexOfCR = -1; - } else { - from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); - indexOfCR = str.indexOf("\r", from); - indexOfLF = str.indexOf(` -`, from); - } - } - } - stringBuilder = stringBuilder + str.substring(from); - } + static makeOption(input, options) { + return makeOption(getClassSchema(this))(input ?? {}, options); } - return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; - } - const pullOrFlush = suspend2(() => { - if (done._tag === "Some") { - return done3(done.value); + static makeEffect(input, options) { + return getClassSchema(this).makeEffect(input ?? {}, options); } - return matchEffect2(upstream, { - onSuccess: loop, - onFailure: failCause3, - onDone: (leftover) => { - done = some2(leftover); - if (stringBuilder.length > 0) { - const last = stringBuilder; - stringBuilder = ""; - midCRLF = false; - return succeed6([last]); - } - return done3(leftover); - } - }); - }); - function loop(chunk) { - const lines = splitLinesArray(chunk); - return lines !== null ? succeed6(lines) : pullOrFlush; + static annotate(annotations) { + return this.rebuild(annotate(this.ast, annotations)); + } + static annotateKey(annotations) { + return this.rebuild(annotateKey(this.ast, annotations)); + } + static check(...checks) { + return this.rebuild(appendChecks(this.ast, checks)); + } + static extend(identifier2) { + return (schema, annotations) => { + const extension = isStruct(schema) ? schema : Struct(schema); + const fields = { + ...struct2.fields, + ...extension.fields + }; + const ast = struct(fields, struct2.ast.checks, { + identifier: identifier2 + }); + return makeClass(this, identifier2, makeStruct(appendChecks(ast, extension.ast.checks), fields), annotations, proto); + }; + } + static mapFields(f, options) { + return struct2.mapFields(f, options); + } + }; + if (proto !== undefined) { + Object.assign(out.prototype, proto(identifier)); } - return pullOrFlush; -})); -var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); -var unwrap = (channel) => fromTransform((upstream, scope) => { - let pull; - return succeed6(suspend2(() => { - if (pull) - return pull; - return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); + return out; +} +function getClassTransformation(self) { + return new Transformation(transform((input) => new self(input, { + "~payload": { + token: payloadToken, + value: input + } + })), passthrough()); +} +function getClassTypeId(identifier) { + return `~effect/Schema/Class/${identifier}`; +} +function getClassSchemaFactory(from, identifier, annotations) { + let memo; + return (self) => { + if (memo !== undefined) { + return memo; + } + const ClassTypeId = getClassTypeId(identifier); + const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId); + const transformation = getClassTransformation(self); + const to = make11(new Declaration([from.ast], () => (input, ast, options) => { + return isClassValue(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)); + }, { + identifier, + [CONSTRUCTOR_ANNOTATION_KEY]: ([from]) => ({ + isConstructed: isClassValue, + link: new Link(from, transformation) + }), + toCodec: ([from]) => new Link(from.ast, transformation), + toEquivalence: ([from]) => from, + toFormatter: ([from]) => (t) => `${self.identifier}(${from(t)})`, + [SENTINELS_ANNOTATION_KEY]: collectSentinels(from.ast), + ...annotations + })); + return memo = decodeTo2(to, transformation)(from); + }; +} +function isStruct(schema) { + return isSchema(schema); +} +var Error4 = (identifier) => (schema, annotations) => { + const struct = isStruct(schema) ? schema : Struct(schema); + const self = makeClass(Error2, identifier, struct, annotations, (identifier) => ({ + name: identifier })); -}); -var runWith = (self, f, onHalt) => suspend2(() => { - const scope = makeUnsafe3(); - const makePull = toTransform(self)(done3(), scope); - return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); -}); -var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { - disableYield: true -}))); -var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { - let state = initial(); - return runWith(self, (pull) => whileLoop2({ - while: constTrue, - body: () => pull, - step: (value) => { - state = f(state, value); + return self; +}; +var TaggedError3 = (identifier) => { + return (tagValue, schema, annotations) => { + const struct = isStruct(schema) ? schema.mapFields((fields) => ({ + _tag: tag(tagValue), + ...fields + }), { + unsafePreserveChecks: true + }) : TaggedStruct(tagValue, schema); + return Error4(identifier ?? tagValue)(struct, annotations); + }; +}; +// node_modules/effect/dist/PlatformError.js +var TypeId15 = "~effect/PlatformError"; + +class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { + get message() { + return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; + } +} + +class SystemError extends Error3 { + get message() { + return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; + } +} + +class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { + constructor(reason) { + if ("cause" in reason) { + super({ + reason, + cause: reason.cause + }); + } else { + super({ + reason + }); } - }), () => succeed6(state)); -})); -var toPullScoped = (self, scope) => toTransform(self)(done3(), scope); + } + [TypeId15] = TypeId15; + get message() { + return this.reason.message; + } +} +var systemError = (options) => new PlatformError(new SystemError(options)); +var badArgument = (options) => new PlatformError(new BadArgument(options)); // node_modules/effect/dist/internal/stream.js var TypeId16 = "~effect/Stream"; var streamVariance = { _R: identity, _E: identity, - _A: identity -}; -var Stream = function(channel) { - this.channel = channel; + _A: identity +}; +var Stream = function(channel) { + this.channel = channel; +}; +Stream.prototype = { + [TypeId16]: streamVariance, + pipe() { + return pipeArguments(this, arguments); + } +}; +var fromChannel = (channel) => new Stream(channel); + +// node_modules/effect/dist/Sink.js +var TypeId17 = "~effect/Sink"; +var endVoid = /* @__PURE__ */ succeed6([undefined]); +var sinkVariance = { + _A: identity, + _In: identity, + _L: identity, + _E: identity, + _R: identity }; -Stream.prototype = { - [TypeId16]: streamVariance, +var SinkProto = { + [TypeId17]: sinkVariance, pipe() { return pipeArguments(this, arguments); } }; -var fromChannel = (channel) => new Stream(channel); +var isSink = (u) => hasProperty(u, TypeId17); +var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ + disableYield: true +})), catchDone(succeed6))); +var fromTransform2 = (transform) => { + const self = Object.create(SinkProto); + self.transform = transform; + return self; +}; +var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done2))); +var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { + disableYield: true +}), () => endVoid)); +var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { + discard: true +})); +var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ + disableYield: true +}), catchDone(() => endVoid))); +var unwrap2 = (effect) => fromChannel2(unwrap(map5(effect, toChannel))); // node_modules/effect/dist/internal/rcRef.js -var TypeId17 = "~effect/RcRef"; +var TypeId18 = "~effect/RcRef"; var stateEmpty = { _tag: "Empty" }; @@ -7969,12 +8171,12 @@ var variance2 = { }; class RcRefImpl { - [TypeId17] = variance2; + [TypeId18] = variance2; pipe() { return pipeArguments(this, arguments); } state = stateEmpty; - semaphore = /* @__PURE__ */ makeUnsafe6(1); + semaphore = /* @__PURE__ */ makeUnsafe5(1); acquire; context; scope; @@ -7986,10 +8188,10 @@ class RcRefImpl { this.idleTimeToLive = idleTimeToLive; } } -var make14 = (options) => withFiber2((fiber) => { +var make12 = (options) => withFiber2((fiber) => { const context = fiber.context; const scope = get(context, Scope); - const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive ? fromInputUnsafe(options.idleTimeToLive) : undefined); + const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== undefined ? fromInputUnsafe(options.idleTimeToLive) : undefined); return as2(addFinalizerExit(scope, () => { const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; ref.state = stateClosed; @@ -8030,7 +8232,7 @@ var getState = (self) => uninterruptibleMask2(function loop(restore) { } } }); -var get3 = /* @__PURE__ */ fnUntraced2(function* (self_) { +var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { const self = self_; const state = yield* getState(self); const scope = yield* scope2; @@ -8063,45 +8265,8 @@ var get3 = /* @__PURE__ */ fnUntraced2(function* (self_) { }); // node_modules/effect/dist/RcRef.js -var make15 = make14; -var get4 = get3; - -// node_modules/effect/dist/Sink.js -var TypeId18 = "~effect/Sink"; -var endVoid = /* @__PURE__ */ succeed6([undefined]); -var sinkVariance = { - _A: identity, - _In: identity, - _L: identity, - _E: identity, - _R: identity -}; -var SinkProto = { - [TypeId18]: sinkVariance, - pipe() { - return pipeArguments(this, arguments); - } -}; -var isSink = (u) => hasProperty(u, TypeId18); -var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ - disableYield: true -})), catchDone(succeed6))); -var fromTransform2 = (transform) => { - const self = Object.create(SinkProto); - self.transform = transform; - return self; -}; -var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done3))); -var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { - disableYield: true -}), () => endVoid)); -var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { - discard: true -})); -var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ - disableYield: true -}), catchDone(() => endVoid))); -var unwrap2 = (effect) => fromChannel2(unwrap(map6(effect, toChannel))); +var make13 = make12; +var get3 = get2; // node_modules/effect/dist/Stream.js var TypeId19 = "~effect/Stream"; @@ -8113,10 +8278,10 @@ var toChannel2 = (stream) => stream.channel; var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); var empty4 = /* @__PURE__ */ fromChannel3(empty3); var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); -var unwrap3 = (effect) => fromChannel3(unwrap(map6(effect, toChannel2))); -var map8 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { +var unwrap3 = (effect) => fromChannel3(unwrap(map5(effect, toChannel2))); +var map7 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { let i = 0; - return fromChannel3(map7(self.channel, map2((o) => f(o, i++)))); + return fromChannel3(map6(self.channel, map((o) => f(o, i++)))); })); var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { @@ -8130,10 +8295,10 @@ var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (up } return upstream; }).pipe(catch_2((error) => { - done = fail4(error); - return done3(); + done = fail5(error); + return done2(); })); - const pull = map6(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { + const pull = map5(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { leftover = leftover_; return of(value); }); @@ -8141,12 +8306,12 @@ var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (up }))); var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { const decoder = new TextDecoder(options?.encoding); - return map8(self, (chunk) => decoder.decode(chunk, { + return map7(self, (chunk) => decoder.decode(chunk, { stream: true })); })); var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); -var run2 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map6(([a]) => a)))); +var run2 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map5(([a]) => a)))); var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { for (let i = 0;i < chunk.length; i++) { acc.push(chunk[i]); @@ -8168,137 +8333,13 @@ var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, }); })); var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); -// src/action/ActionInputs.ts -var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; -var readRawInput = (name) => { - const value = process.env[inputEnvName(name)]; - return value === undefined || value === "" ? undefined : value; -}; -var readInputs = (names) => { - const inputs = {}; - for (const name of names) { - const value = readRawInput(name); - if (value !== undefined) - inputs[name] = value; - } - return inputs; -}; -var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); -// node_modules/effect/dist/Runtime.js -var defaultTeardown = (exit, onExit) => { - if (isSuccess3(exit)) - return onExit(0); - if (hasInterruptsOnly2(exit.cause)) - return onExit(130); - return onExit(getErrorExitCode(squash(exit.cause))); -}; -var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { - const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { - if (hasInterruptsOnly2(cause)) - return void_3; - const isReported = getErrorReported(squash(cause)); - return isReported ? logError(cause) : void_3; - })); - try { - const keepAlive = globalThis.setInterval(constVoid, 2147483647); - fiber.addObserver(() => { - clearInterval(keepAlive); - }); - } catch {} - const teardown = options?.teardown ?? defaultTeardown; - return f({ - fiber, - teardown - }); -}); -var errorExitCode = "~effect/Runtime/errorExitCode"; -var getErrorExitCode = (u) => { - if (typeof u === "object" && u !== null && errorExitCode in u) { - const code = u[errorExitCode]; - if (typeof code === "number") { - return code; - } - } - return 1; -}; -var errorReported = "~effect/Runtime/errorReported"; -var getErrorReported = (u) => { - if (typeof u === "object" && u !== null && errorReported in u) { - const isReported = u[errorReported]; - if (typeof isReported === "boolean") { - return isReported; - } - } - return true; -}; - -// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js -var runMain = /* @__PURE__ */ makeRunMain(({ - fiber, - teardown -}) => { - let receivedSignal = false; - fiber.addObserver((exit) => { - process.removeListener("SIGINT", onSigint); - process.removeListener("SIGTERM", onSigint); - teardown(exit, (code) => { - if (receivedSignal || code !== 0) { - process.exit(code); - } - }); - }); - function onSigint() { - receivedSignal = true; - fiber.interruptUnsafe(fiber.id); - } - process.on("SIGINT", onSigint); - process.on("SIGTERM", onSigint); -}); - -// node_modules/@effect/platform-node/dist/NodeRuntime.js -var runMain2 = runMain; -// node_modules/effect/dist/PlatformError.js -var TypeId20 = "~effect/PlatformError"; - -class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { - get message() { - return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; - } -} - -class SystemError extends Error3 { - get message() { - return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; - } -} - -class PlatformError2 extends (/* @__PURE__ */ TaggedError2("PlatformError")) { - constructor(reason) { - if ("cause" in reason) { - super({ - reason, - cause: reason.cause - }); - } else { - super({ - reason - }); - } - } - [TypeId20] = TypeId20; - get message() { - return this.reason.message; - } -} -var systemError = (options) => new PlatformError2(new SystemError(options)); -var badArgument = (options) => new PlatformError2(new BadArgument(options)); // node_modules/effect/dist/FileSystem.js -var TypeId21 = "~effect/FileSystem"; -var FileSystem2 = /* @__PURE__ */ Service("effect/FileSystem"); -var make16 = (impl) => FileSystem2.of({ +var TypeId20 = "~effect/FileSystem"; +var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); +var make14 = (impl) => FileSystem.of({ ...impl, - [TypeId21]: TypeId21, + [TypeId20]: TypeId20, exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ try: () => new TextDecoder(encoding).decode(_), @@ -8323,11 +8364,11 @@ var make16 = (impl) => FileSystem2.of({ const readChunk = file.readAlloc(chunkSize); return fromPull2(succeed6(flatMap3(suspend2(() => { if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { - return done3(); + return done2(); } return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; }), match({ - onNone: () => done3(), + onNone: () => done2(), onSome: (buf) => { totalBytesRead += BigInt(buf.length); return succeed6(of(buf)); @@ -8337,7 +8378,7 @@ var make16 = (impl) => FileSystem2.of({ sink: (path, options) => pipe(impl.open(path, { ...options, flag: options?.flag ?? "w" - }), map6((file) => forEach3((_) => file.writeAll(_))), unwrap2), + }), map5((file) => forEach3((_) => file.writeAll(_))), unwrap2), writeFileString: (path, data, options) => flatMap3(try_2({ try: () => new TextEncoder().encode(data), catch: (cause) => badArgument({ @@ -8353,8 +8394,8 @@ class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBa } // node_modules/effect/dist/Path.js -var TypeId22 = "~effect/Path"; -var Path2 = /* @__PURE__ */ Service("effect/Path"); +var TypeId21 = "~effect/Path"; +var Path = /* @__PURE__ */ Service("effect/Path"); function normalizeStringPosix(path, allowAboveRoot) { let res = ""; let lastSegmentLength = 0; @@ -8460,7 +8501,7 @@ function fromFileUrl(url) { } return succeed6(decodeURIComponent(pathname)); } -var resolve2 = function resolve() { +var resolve3 = function resolve() { let resolvedPath = ""; let resolvedAbsolute = false; let cwd = undefined; @@ -8497,7 +8538,7 @@ var resolve2 = function resolve() { var CHAR_FORWARD_SLASH = 47; function toFileUrl(filepath) { const outURL = new URL("file://"); - let resolved = resolve2(filepath); + let resolved = resolve3(filepath); const filePathLast = filepath.charCodeAt(filepath.length - 1); if (filePathLast === CHAR_FORWARD_SLASH && resolved[resolved.length - 1] !== "/") { resolved += "/"; @@ -8529,9 +8570,9 @@ function encodePathChars(filepath) { } return filepath; } -var posixImpl = /* @__PURE__ */ Path2.of({ - [TypeId22]: TypeId22, - resolve: resolve2, +var posixImpl = /* @__PURE__ */ Path.of({ + [TypeId21]: TypeId21, + resolve: resolve3, normalize(path) { if (path.length === 0) return "."; @@ -8822,29 +8863,266 @@ var posixImpl = /* @__PURE__ */ Path2.of({ ret.name = path.slice(startPart, startDot); ret.base = path.slice(startPart, end); } - ret.ext = path.slice(startDot, end); - } - if (startPart > 0) - ret.dir = path.slice(0, startPart - 1); - else if (isAbsolute) - ret.dir = "/"; - return ret; + ret.ext = path.slice(startDot, end); + } + if (startPart > 0) + ret.dir = path.slice(0, startPart - 1); + else if (isAbsolute) + ret.dir = "/"; + return ret; + }, + sep: "/", + fromFileUrl, + toFileUrl, + toNamespacedPath: identity +}); +// node_modules/effect/dist/internal/ulid.js +var maxTimestamp = 2 ** 48 - 1; +var base32Chars = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; +var ulidString = (timestampMillis, bytes) => { + if (bytes.length !== 10) { + throw new Error(`ULID randomness must be exactly 10 bytes, received ${bytes.length}`); + } + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxTimestamp); + let out = ""; + for (let shift = 45;shift >= 0; shift -= 5) { + out += base32Chars[Math.floor(timestamp / 2 ** shift) & 31]; + } + let accumulator = 0; + let bits = 0; + for (const byte of bytes) { + accumulator = accumulator << 8 | byte; + bits += 8; + while (bits >= 5) { + bits -= 5; + out += base32Chars[accumulator >>> bits & 31]; + } + accumulator &= (1 << bits) - 1; + } + return out; +}; + +// node_modules/effect/dist/internal/uuid.js +var hex = (byte) => byte.toString(16).padStart(2, "0"); +var stringify = (bytes) => { + const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; + return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); +}; +var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); +function v4Bytes(bytes = randomBytes()) { + bytes[6] = bytes[6] & 15 | 64; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); +var maxV7Timestamp = 2 ** 48 - 1; +function v7Bytes(timestampMillis, bytes = randomBytes()) { + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); + bytes[0] = Math.floor(timestamp / 2 ** 40); + bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; + bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; + bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; + bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; + bytes[5] = timestamp & 255; + bytes[6] = bytes[6] & 15 | 112; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); + +// node_modules/effect/dist/Crypto.js +var TypeId22 = "~effect/Crypto"; +var Crypto = /* @__PURE__ */ Service("effect/Crypto"); +var make15 = (impl) => { + const randomBytesUnsafe = impl.randomBytes; + const randomBytes = (size) => map5(validateSize("randomBytes", size), randomBytesUnsafe); + const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; + const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; + const nextIntUnsafe = () => { + while (true) { + const bytes = randomBytesUnsafe(7); + const value = readUint53(bytes); + if ((bytes[0] & 32) === 0) { + return value + Number.MIN_SAFE_INTEGER; + } + if (value < Number.MAX_SAFE_INTEGER) { + return value + 1; + } + } + }; + return Crypto.of({ + [TypeId22]: TypeId22, + randomBytes, + nextDoubleUnsafe, + nextIntUnsafe, + digest: impl.digest, + random: sync3(() => nextDoubleUnsafe()), + randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), + randomInt: sync3(() => nextIntUnsafe()), + randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), + randomIntBetween(min, max, options) { + const extra = options?.halfOpen === true ? 0 : 1; + return sync3(() => { + const minInt = Math.ceil(min); + const maxInt = Math.floor(max); + return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; + }); + }, + randomShuffle: (elements) => sync3(() => { + const buffer = Array.from(elements); + for (let i = buffer.length - 1;i >= 1; i = i - 1) { + const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); + const value = buffer[i]; + buffer[i] = buffer[index]; + buffer[index] = value; + } + return buffer; + }), + randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), + randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))), + randomULID: clockWith2((clock) => succeed6(ulidString(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(10)))) + }); +}; +var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ + module: "Crypto", + method, + description: "size must be a non-negative safe integer" +})); +// node_modules/effect/dist/Ref.js +var TypeId23 = "~effect/Ref"; +var RefProto = { + [TypeId23]: { + _A: identity }, - sep: "/", - fromFileUrl, - toFileUrl, - toNamespacedPath: identity + ...PipeInspectableProto, + toJSON() { + return { + _id: "Ref", + ref: this.ref + }; + } +}; +var makeUnsafe6 = (value) => { + const self = Object.create(RefProto); + self.ref = make6(value); + return self; +}; +var make16 = (value) => sync3(() => makeUnsafe6(value)); +var get4 = (self) => sync3(() => self.ref.current); +var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { + self.ref.current = f(self.ref.current); +})); +// node_modules/effect/dist/Runtime.js +var defaultTeardown = (exit, onExit) => { + if (isSuccess3(exit)) + return onExit(0); + if (hasInterruptsOnly2(exit.cause)) + return onExit(130); + return onExit(getErrorExitCode(squash(exit.cause))); +}; +var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { + const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { + if (hasInterruptsOnly2(cause)) + return void_3; + const isReported = getErrorReported(squash(cause)); + return isReported ? logError(cause) : void_3; + })); + try { + const keepAlive = globalThis.setInterval(constVoid, 2147483647); + fiber.addObserver(() => { + clearInterval(keepAlive); + }); + } catch {} + const teardown = options?.teardown ?? defaultTeardown; + return f({ + fiber, + teardown + }); +}); +var errorExitCode = "~effect/Runtime/errorExitCode"; +var getErrorExitCode = (u) => { + if (typeof u === "object" && u !== null && errorExitCode in u) { + const code = u[errorExitCode]; + if (typeof code === "number") { + return code; + } + } + return 1; +}; +var errorReported = "~effect/Runtime/errorReported"; +var getErrorReported = (u) => { + if (typeof u === "object" && u !== null && errorReported in u) { + const isReported = u[errorReported]; + if (typeof isReported === "boolean") { + return isReported; + } + } + return true; +}; +// node_modules/effect/dist/Stdio.js +var TypeId24 = "~effect/Stdio"; +var Stdio = /* @__PURE__ */ Service(TypeId24); +var make17 = (options) => ({ + [TypeId24]: TypeId24, + stdinIsTerminal: succeed6(false), + stdoutIsTerminal: succeed6(false), + ...options }); +// node_modules/effect/dist/Terminal.js +var TypeId25 = "~effect/Terminal"; +var QuitErrorTypeId = "~effect/Terminal/QuitError"; -// node_modules/effect/dist/Brand.js -function nominal() { - return Object.assign((input) => input, { - option: (input) => some2(input), - result: (input) => succeed2(input), - is: (_) => true - }); +class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ + _tag: /* @__PURE__ */ tag("QuitError") +})) { + [QuitErrorTypeId] = QuitErrorTypeId; } +var Terminal = /* @__PURE__ */ Service("effect/Terminal"); +var make18 = (impl) => Terminal.of({ + ...impl, + [TypeId25]: TypeId25 +}); +// src/action/ActionInputs.ts +var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; +var readRawInput = (name) => { + const value = process.env[inputEnvName(name)]; + return value === undefined || value === "" ? undefined : value; +}; +var readInputs = (names) => { + const inputs = {}; + for (const name of names) { + const value = readRawInput(name); + if (value !== undefined) + inputs[name] = value; + } + return inputs; +}; +var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); +// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js +var runMain = /* @__PURE__ */ makeRunMain(({ + fiber, + teardown +}) => { + let receivedSignal = false; + fiber.addObserver((exit) => { + process.removeListener("SIGINT", onSigint); + process.removeListener("SIGTERM", onSigint); + teardown(exit, (code) => { + if (receivedSignal || code !== 0) { + process.exit(code); + } + }); + }); + function onSigint() { + receivedSignal = true; + fiber.interruptUnsafe(fiber.id); + } + process.on("SIGINT", onSigint); + process.on("SIGTERM", onSigint); +}); +// node_modules/@effect/platform-node/dist/NodeRuntime.js +var runMain2 = runMain; // node_modules/effect/dist/unstable/process/ChildProcessSpawner.js var ExitCode = /* @__PURE__ */ nominal(); var ProcessId = /* @__PURE__ */ nominal(); @@ -8862,8 +9140,8 @@ var HandleProto = { var makeHandle = (params) => Object.setPrototypeOf({ ...params }, HandleProto); -var make17 = (spawn) => { - const streamString = (command, options) => spawn(command).pipe(map6((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); +var make19 = (spawn) => { + const streamString = (command, options) => spawn(command).pipe(map5((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); const streamLines = (command, options) => splitLines2(streamString(command, options)); return ChildProcessSpawner.of({ spawn, @@ -8879,7 +9157,7 @@ class ChildProcessSpawner extends (/* @__PURE__ */ Service()("effect/process/Chi } // node_modules/effect/dist/unstable/process/ChildProcess.js -var TypeId23 = "~effect/process/ChildProcess"; +var TypeId26 = "~effect/process/ChildProcess"; var Proto2 = { .../* @__PURE__ */ Prototype2({ label: "Command", @@ -8887,7 +9165,7 @@ var Proto2 = { return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this); } }), - [TypeId23]: TypeId23 + [TypeId26]: TypeId26 }; var makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto2), { _tag: "StandardCommand", @@ -8895,7 +9173,7 @@ var makeStandardCommand = (command, args, options) => Object.assign(Object.creat args, options }); -var make18 = function make(...args) { +var make20 = function make(...args) { if (isTemplateString(args[0])) { const [templates, ...expressions] = args; const tokens = parseTemplates(templates, expressions); @@ -9101,10 +9379,10 @@ var pullIntoWritable = (options) => options.pull.pipe(flatMap3((chunk) => { disableYield: true }), options.endOnDone !== false ? catchDone((_) => { if ("closed" in options.writable && options.writable.closed) { - return done3(_); + return done2(_); } return callback2((resume) => { - const onFinish = () => resume(done3(_)); + const onFinish = () => resume(done2(_)); options.writable.once("finish", onFinish); options.writable.end(); return sync3(() => { @@ -9131,17 +9409,17 @@ var fromReadableChannel = (options) => fromTransform((_, scope) => readableToPul var readableToPullUnsafe = (options) => { const readable = options.readable; const closeOnDone = options.closeOnDone ?? true; - const exit = options.exit ?? make5(undefined); - const latch = options.latch ?? makeUnsafe5(false); + const exit = options.exit ?? make6(undefined); + const latch = options.latch ?? makeUnsafe4(false); function onReadable() { latch.openUnsafe(); } function onError(error) { - exit.current = fail4(options.onError(error)); + exit.current = fail5(options.onError(error)); latch.openUnsafe(); } function onEnd() { - exit.current = fail4(Done2()); + exit.current = fail5(Done2()); latch.openUnsafe(); } readable.on("readable", onReadable); @@ -9210,9 +9488,9 @@ var isProcessAlive = (childProcess, exitSignal) => { var taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { windowsHide: true }, onExit); -var make19 = /* @__PURE__ */ gen2(function* () { - const fs = yield* FileSystem2; - const path = yield* Path2; +var make21 = /* @__PURE__ */ gen2(function* () { + const fs = yield* FileSystem; + const path = yield* Path; const resolveWorkingDirectory = fnUntraced2(function* (options) { if (isUndefined(options.cwd)) return; @@ -9529,7 +9807,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { env, stdio }, process.platform)), fnUntraced2(function* ([childProcess, exitSignal]) { - const exited = yield* isDone2(exitSignal); + const exited = yield* isDone3(exitSignal); if (exited) { const [code] = yield* _await(exitSignal); if (code !== 0 && isNotNull(code)) { @@ -9571,7 +9849,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds); - const isRunning = map6(isDone2(exitSignal), (done) => !done); + const isRunning = map5(isDone3(exitSignal), (done) => !done); const exitCode = flatMap3(_await(exitSignal), ([code, signal]) => { if (isNotNull(code)) { return succeed6(ExitCode(code)); @@ -9608,7 +9886,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { const sourceStream = unwrap3(succeed6(getSourceStream(handles[handles.length - 1], options.from))); const toOption = options.to ?? "stdin"; if (toOption === "stdin") { - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -9620,7 +9898,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { if (isNotUndefined(fd)) { const fdName2 = fdName(fd); const existingFds = command.options.additionalFds ?? {}; - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, additionalFds: { ...existingFds, @@ -9631,7 +9909,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { } }))); } else { - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -9670,9 +9948,9 @@ var make19 = /* @__PURE__ */ gen2(function* () { } } }); - return make17(spawnCommand); + return make19(spawnCommand); }); -var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make19); +var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make21); var flattenCommand = (command) => { const commands = []; const pipeOptions = []; @@ -9702,92 +9980,6 @@ var flattenCommand = (command) => { }; }; -// node_modules/effect/dist/internal/uuid.js -var hex = (byte) => byte.toString(16).padStart(2, "0"); -var stringify = (bytes) => { - const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; - return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); -}; -var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); -function v4Bytes(bytes = randomBytes()) { - bytes[6] = bytes[6] & 15 | 64; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); -var maxV7Timestamp = 2 ** 48 - 1; -function v7Bytes(timestampMillis, bytes = randomBytes()) { - const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); - bytes[0] = Math.floor(timestamp / 2 ** 40); - bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; - bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; - bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; - bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; - bytes[5] = timestamp & 255; - bytes[6] = bytes[6] & 15 | 112; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); - -// node_modules/effect/dist/Crypto.js -var TypeId24 = "~effect/Crypto"; -var Crypto2 = /* @__PURE__ */ Service("effect/Crypto"); -var make20 = (impl) => { - const randomBytesUnsafe = impl.randomBytes; - const randomBytes = (size) => map6(validateSize("randomBytes", size), randomBytesUnsafe); - const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; - const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; - const nextIntUnsafe = () => { - while (true) { - const bytes = randomBytesUnsafe(7); - const value = readUint53(bytes); - if ((bytes[0] & 32) === 0) { - return value + Number.MIN_SAFE_INTEGER; - } - if (value < Number.MAX_SAFE_INTEGER) { - return value + 1; - } - } - }; - return Crypto2.of({ - [TypeId24]: TypeId24, - randomBytes, - nextDoubleUnsafe, - nextIntUnsafe, - digest: impl.digest, - random: sync3(() => nextDoubleUnsafe()), - randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), - randomInt: sync3(() => nextIntUnsafe()), - randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), - randomIntBetween(min, max, options) { - const extra = options?.halfOpen === true ? 0 : 1; - return sync3(() => { - const minInt = Math.ceil(min); - const maxInt = Math.floor(max); - return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; - }); - }, - randomShuffle: (elements) => sync3(() => { - const buffer = Array.from(elements); - for (let i = buffer.length - 1;i >= 1; i = i - 1) { - const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); - const value = buffer[i]; - buffer[i] = buffer[index]; - buffer[index] = value; - } - return buffer; - }), - randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), - randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))) - }); -}; -var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ - module: "Crypto", - method, - description: "size must be a non-negative safe integer" -})); - // node_modules/@effect/platform-node-shared/dist/NodeCrypto.js import * as NodeCrypto from "node:crypto"; var toHashAlgorithm = (algorithm) => { @@ -9812,20 +10004,20 @@ var digest = (algorithm, data) => try_2({ cause }) }); -var make21 = /* @__PURE__ */ make20({ +var make22 = /* @__PURE__ */ make15({ randomBytes: NodeCrypto.randomBytes, digest }); -var layer2 = /* @__PURE__ */ succeed5(Crypto2, make21); +var layer2 = /* @__PURE__ */ succeed5(Crypto, make22); // node_modules/@effect/platform-node/dist/NodeCrypto.js var layer3 = layer2; // node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js -import * as Crypto3 from "node:crypto"; +import * as Crypto2 from "node:crypto"; import * as NFS from "node:fs"; import * as OS from "node:os"; -import * as Path3 from "node:path"; +import * as Path2 from "node:path"; var handleBadArgument = (method) => (err) => badArgument({ module: "FileSystem", method, @@ -9898,8 +10090,8 @@ var makeTempDirectoryFactory = (method) => { const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException("FileSystem", method), handleBadArgument(method)); return (options) => suspend2(() => { const prefix = options?.prefix ?? ""; - const directory = typeof options?.directory === "string" ? Path3.join(options.directory, ".") : OS.tmpdir(); - return nodeMkdtemp(prefix ? Path3.join(directory, prefix) : directory + "/"); + const directory = typeof options?.directory === "string" ? Path2.join(options.directory, ".") : OS.tmpdir(); + return nodeMkdtemp(prefix ? Path2.join(directory, prefix) : directory + "/"); }); }; var makeTempDirectory = /* @__PURE__ */ makeTempDirectoryFactory("makeTempDirectory"); @@ -9921,7 +10113,7 @@ var makeTempDirectoryScoped = /* @__PURE__ */ (() => { var openFactory = (method) => { const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method)); const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method)); - return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map6((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); + return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map5((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); }; var open2 = /* @__PURE__ */ openFactory("open"); var makeFile = /* @__PURE__ */ (() => { @@ -9970,7 +10162,7 @@ var makeFile = /* @__PURE__ */ (() => { read(buffer) { return suspend2(() => { const position = this.position; - return map6(nodeRead(this.fd, { + return map5(nodeRead(this.fd, { buffer, position }), (bytesRead) => { @@ -9987,7 +10179,7 @@ var makeFile = /* @__PURE__ */ (() => { } const buffer = Buffer.allocUnsafeSlow(size); const position = this.position; - return map6(nodeReadAlloc(this.fd, { + return map5(nodeReadAlloc(this.fd, { buffer, position }), (bytesRead) => { @@ -10008,7 +10200,7 @@ var makeFile = /* @__PURE__ */ (() => { }); } truncate(length) { - return map6(nodeTruncate(this.fd, length || undefined), () => { + return map5(nodeTruncate(this.fd, length || undefined), () => { if (!this.append) { const len = BigInt(length ?? 0); if (this.position > len) { @@ -10020,7 +10212,7 @@ var makeFile = /* @__PURE__ */ (() => { write(buffer) { return suspend2(() => { const position = this.position; - return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map6(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { + return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map5(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { if (!this.append) { this.position = position + BigInt(bytesWritten); } @@ -10058,8 +10250,8 @@ var makeTempFileFactory = (method) => { const makeDirectory = makeTempDirectoryFactory(method); return fnUntraced2(function* (options) { const directory = yield* makeDirectory(options); - const random = Crypto3.randomBytes(6).toString("hex"); - const name = Path3.join(directory, options?.suffix ? `${random}${options.suffix}` : random); + const random = Crypto2.randomBytes(6).toString("hex"); + const name = Path2.join(directory, options?.suffix ? `${random}${options.suffix}` : random); yield* writeFile2(name, new Uint8Array(0)); return name; }); @@ -10068,7 +10260,7 @@ var makeTempFile = /* @__PURE__ */ makeTempFileFactory("makeTempFile"); var makeTempFileScoped = /* @__PURE__ */ (() => { const makeFile = /* @__PURE__ */ makeTempFileFactory("makeTempFileScoped"); const removeDirectory = /* @__PURE__ */ removeFactory("makeTempFileScoped"); - return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path3.dirname(file), { + return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path2.dirname(file), { recursive: true }))); })(); @@ -10141,7 +10333,7 @@ var utimes2 = /* @__PURE__ */ (() => { return (path, atime, mtime) => nodeUtimes(path, atime, mtime); })(); var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sync3(() => { - const directory = info.type === "Directory" ? path : Path3.dirname(path); + const directory = info.type === "Directory" ? path : Path2.dirname(path); const watcher = NFS.watch(path, { recursive: options?.recursive ?? false }, (event, path) => { @@ -10149,7 +10341,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy return; switch (event) { case "rename": { - runFork2(matchEffect3(stat2(Path3.resolve(directory, path)), { + runFork2(matchEffect3(stat2(Path2.resolve(directory, path)), { onSuccess: (_) => offer(queue, { _tag: "Create", path @@ -10171,7 +10363,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy } }); watcher.on("error", (error) => { - failCauseUnsafe(queue, fail5(systemError({ + failCauseUnsafe(queue, fail4(systemError({ module: "FileSystem", _tag: "Unknown", method: "watch", @@ -10184,7 +10376,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy }); return watcher; }), (watcher) => sync3(() => watcher.close()))); -var watch2 = (backend, path, options) => stat2(path).pipe(map6((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); +var watch2 = (backend, path, options) => stat2(path).pipe(map5((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); var writeFile2 = (path, data, options) => callback2((resume, signal) => { try { NFS.writeFile(path, data, { @@ -10202,7 +10394,7 @@ var writeFile2 = (path, data, options) => callback2((resume, signal) => { resume(fail6(handleBadArgument("writeFile")(err))); } }); -var makeFileSystem = /* @__PURE__ */ map6(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make16({ +var makeFileSystem = /* @__PURE__ */ map5(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make14({ access: access2, chmod: chmod2, chown: chown2, @@ -10231,7 +10423,7 @@ var makeFileSystem = /* @__PURE__ */ map6(/* @__PURE__ */ serviceOption2(WatchBa }, writeFile: writeFile2 })); -var layer4 = /* @__PURE__ */ effect(FileSystem2)(makeFileSystem); +var layer4 = /* @__PURE__ */ effect(FileSystem)(makeFileSystem); // node_modules/@effect/platform-node/dist/NodeFileSystem.js var layer5 = layer4; @@ -10261,18 +10453,18 @@ var fileUrlOps = (windows) => ({ }) }) }); -var layerPosix = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layerPosix = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.posix, .../* @__PURE__ */ fileUrlOps(false) }); -var layerWin32 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layerWin32 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.win32, .../* @__PURE__ */ fileUrlOps(true) }); -var layer6 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layer6 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath, .../* @__PURE__ */ fileUrlOps(undefined) }); @@ -10280,18 +10472,8 @@ var layer6 = /* @__PURE__ */ succeed5(Path2)({ // node_modules/@effect/platform-node/dist/NodePath.js var layer7 = layer6; -// node_modules/effect/dist/Stdio.js -var TypeId25 = "~effect/Stdio"; -var Stdio2 = /* @__PURE__ */ Service(TypeId25); -var make22 = (options) => ({ - [TypeId25]: TypeId25, - stdinIsTerminal: succeed6(false), - stdoutIsTerminal: succeed6(false), - ...options -}); - // node_modules/@effect/platform-node-shared/dist/NodeStdio.js -var layer8 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make22({ +var layer8 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make17({ args: /* @__PURE__ */ sync3(() => process.argv.slice(2)), stdinIsTerminal: /* @__PURE__ */ sync3(() => process.stdin.isTTY === true), stdoutIsTerminal: /* @__PURE__ */ sync3(() => process.stdout.isTTY === true), @@ -10330,27 +10512,12 @@ var layer8 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make22({ // node_modules/@effect/platform-node/dist/NodeStdio.js var layer9 = layer8; -// node_modules/effect/dist/Terminal.js -var TypeId26 = "~effect/Terminal"; -var QuitErrorTypeId = "~effect/Terminal/QuitError"; - -class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ - _tag: /* @__PURE__ */ tag("QuitError") -})) { - [QuitErrorTypeId] = QuitErrorTypeId; -} -var Terminal2 = /* @__PURE__ */ Service("effect/Terminal"); -var make23 = (impl) => Terminal2.of({ - ...impl, - [TypeId26]: TypeId26 -}); - // node_modules/@effect/platform-node-shared/dist/NodeTerminal.js import * as readline from "node:readline"; -var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { +var make23 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { const stdin = process.stdin; const stdout = process.stdout; - const lines = yield* make13(); + const lines = yield* make8(); let inputEnded = stdin.readableEnded; let readlineActive = false; const onStdinEnd = () => { @@ -10361,7 +10528,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu }; stdin.once("end", onStdinEnd); yield* addFinalizer3(() => sync3(() => stdin.off("end", onStdinEnd))); - const rlRef = yield* make15({ + const rlRef = yield* make13({ acquire: acquireRelease2(sync3(() => { const rl = readline.createInterface({ input: stdin, @@ -10405,7 +10572,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu const columns = sync3(() => stdout.columns ?? 0); const rows = sync3(() => stdout.rows ?? 0); const readInput = gen2(function* () { - const queue = yield* make13(); + const queue = yield* make8(); const handleKeypress = (s, k) => { const userInput = { input: fromUndefinedOr(s), @@ -10435,13 +10602,13 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu if (inputEnded) { handleEnd(); } else { - yield* get4(rlRef); + yield* get3(rlRef); stdin.once("end", handleEnd); } return queue; }); const readLine = suspend2(() => poll(lines).pipe(flatMap3(match({ - onNone: () => scoped2(andThen2(get4(rlRef), take2(lines))), + onNone: () => scoped2(andThen2(get3(rlRef), take2(lines))), onSome: succeed6 })), mapError2(() => new QuitError({})))); const display = (prompt) => uninterruptible2(callback2((resume) => { @@ -10452,7 +10619,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu cause: err })))); })); - return make23({ + return make18({ columns, rows, readInput, @@ -10460,7 +10627,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu display }); }); -var layer10 = /* @__PURE__ */ effect(Terminal2, /* @__PURE__ */ make24(defaultShouldQuit)); +var layer10 = /* @__PURE__ */ effect(Terminal, /* @__PURE__ */ make23(defaultShouldQuit)); function defaultShouldQuit(input) { return input.key.ctrl && (input.key.name === "c" || input.key.name === "d"); } @@ -10515,7 +10682,7 @@ var layer13 = sync2(Service2, () => { class TestService extends Service()("@timmo001/workflows/Annotations/Test") { } var testLayer = effectContext(gen2(function* () { - const recorded = yield* make6([]); + const recorded = yield* make16([]); const write = (line) => update(recorded, (lines) => [...lines, line]); const service = TestService.of({ error: fn2("Annotations.Test.error")(function* (message, properties) { @@ -10534,10 +10701,10 @@ var testLayer = effectContext(gen2(function* () { yield* write("::endgroup::"); }), lines: fn2("Annotations.Test.lines")(function* () { - return yield* get2(recorded); + return yield* get4(recorded); }) }); - return empty().pipe(add(Service2, service), add(TestService, service)); + return empty2().pipe(add(Service2, service), add(TestService, service)); })); class ActionFailure extends TaggedError3()("ActionFailure", { @@ -10560,7 +10727,7 @@ class Service3 extends Service()("@timmo001/workflows/CommandExecutor") { } var layer14 = effect(Service3, gen2(function* () { const spawner = yield* ChildProcessSpawner; - const make = (command, args, options) => make18(command, args, { + const make = (command, args, options) => make20(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true @@ -10599,7 +10766,7 @@ var layer14 = effect(Service3, gen2(function* () { const stream = fn2("CommandExecutor.stream")(function* (command, args, options) { const label = options?.label ?? `${command} ${args.join(" ")}`.trim(); return yield* scoped2(gen2(function* () { - const handle = yield* spawner.spawn(make18(command, args, { + const handle = yield* spawner.spawn(make20(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true, diff --git a/.github/actions/release-bun-cli/dist/index.js b/.github/actions/release-bun-cli/dist/index.js index 3c51339d..78880148 100644 --- a/.github/actions/release-bun-cli/dist/index.js +++ b/.github/actions/release-bun-cli/dist/index.js @@ -502,6 +502,33 @@ function makeCompareSet(equivalence) { var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth); var isEqual = (u) => hasProperty(u, symbol2); +// node_modules/effect/dist/internal/array.js +var isArrayNonEmpty = (self) => self.length > 0; + +// node_modules/effect/dist/internal/count.js +var normalize = (n) => n > 0 ? Math.floor(n) : 0; + +// node_modules/effect/dist/internal/record.js +function assignProperty(self, key, value) { + if (key === "__proto__") { + Object.defineProperty(self, key, { + value, + writable: true, + enumerable: true, + configurable: true + }); + } else { + self[key] = value; + } +} +function assignProperties(self, source) { + for (const key of Reflect.ownKeys(source)) { + if (Object.prototype.propertyIsEnumerable.call(source, key)) { + assignProperty(self, key, source[key]); + } + } +} + // node_modules/effect/dist/Redactable.js var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Redactable"); var isRedactable = (u) => hasProperty(u, symbolRedactable); @@ -744,27 +771,6 @@ var pickInternalCall = () => { }; var internalCall = /* @__PURE__ */ pickInternalCall(); -// node_modules/effect/dist/internal/record.js -function assignProperty(self, key, value) { - if (key === "__proto__") { - Object.defineProperty(self, key, { - value, - writable: true, - enumerable: true, - configurable: true - }); - } else { - self[key] = value; - } -} -function assignProperties(self, source) { - for (const key of Reflect.ownKeys(source)) { - if (Object.prototype.propertyIsEnumerable.call(source, key)) { - assignProperty(self, key, source[key]); - } - } -} - // node_modules/effect/dist/internal/core.js var EffectTypeId = `~effect/Effect`; var ExitTypeId = `~effect/Exit`; @@ -1133,12 +1139,6 @@ var done = (value) => { return exitFail(Done(value)); }; -// node_modules/effect/dist/Effectable.js -var Prototype2 = (options) => makePrimitiveProto({ - op: options.label, - [evaluate]: options.evaluate -}); - // node_modules/effect/dist/internal/option.js var TypeId = "~effect/Option"; var CommonProto = { @@ -1300,9 +1300,64 @@ var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone var fromNullishOr = (a) => a == null ? none2() : some2(a); var fromUndefinedOr = (a) => a === undefined ? none2() : some2(a); var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined); -var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value))); var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value)); -var filter = /* @__PURE__ */ dual(2, (self, predicate) => isNone2(self) ? none2() : predicate(self.value) ? some2(self.value) : none2()); + +// node_modules/effect/dist/Result.js +var succeed2 = succeed; +var fail2 = fail; +var isResult2 = isResult; +var isFailure2 = isFailure; +var isSuccess2 = isSuccess; +var match2 = /* @__PURE__ */ dual(2, (self, { + onFailure, + onSuccess +}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); + +// node_modules/effect/dist/Iterable.js +var headUnsafe = (self) => { + const iterator = self[Symbol.iterator](); + const result = iterator.next(); + if (result.done) + throw new Error("headUnsafe: empty iterable"); + return result.value; +}; +var constEmpty = { + [Symbol.iterator]() { + return constEmptyIterator; + } +}; +var constEmptyIterator = { + next() { + return { + done: true, + value: undefined + }; + } +}; + +// node_modules/effect/dist/Array.js +var Array2 = globalThis.Array; +var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); +var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); +var isArray = Array2.isArray; +var isArrayNonEmpty2 = isArrayNonEmpty; +var isReadonlyArrayNonEmpty = isArrayNonEmpty; +var empty = () => []; +var of = (a) => [a]; +var map = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); +// node_modules/effect/dist/BigInt.js +var BigInt2 = globalThis.BigInt; +var toNumber = (b) => { + if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { + return none2(); + } + return some2(Number(b)); +}; +// node_modules/effect/dist/Effectable.js +var Prototype2 = (options) => makePrimitiveProto({ + op: options.label, + [evaluate]: options.evaluate +}); // node_modules/effect/dist/Context.js var ServiceTypeId = "~effect/Context/Service"; @@ -1443,7 +1498,7 @@ var Proto = { var hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot; var isContext = (u) => hasProperty(u, TypeId3); var isReference = (u) => !!u[ReferenceTypeId]; -var empty = () => emptyContext2; +var empty2 = () => emptyContext2; var emptyContext2 = /* @__PURE__ */ makeUnsafe(/* @__PURE__ */ new Map); var make2 = (key, service) => makeUnsafe(new Map([[key.key, service]])); var add = /* @__PURE__ */ dual(3, (self, key, service) => addUnsafe(self, key.key, service)); @@ -1517,6 +1572,7 @@ var mergeAll = (...ctxs) => { return makeUnsafe(map); }; var Reference = Service; + // node_modules/effect/dist/Duration.js var TypeId4 = "~effect/Duration"; var bigint0 = /* @__PURE__ */ BigInt(0); @@ -1740,7 +1796,7 @@ var minutes = (minutes) => make3(minutes * 60000); var hours = (hours) => make3(hours * 3600000); var days = (days) => make3(days * 86400000); var weeks = (weeks) => make3(weeks * 604800000); -var toMillis = (self) => match2(fromInputUnsafe(self), { +var toMillis = (self) => match3(fromInputUnsafe(self), { onMillis: identity, onNanos: (nanos) => Number(nanos) / 1e6, onInfinity: () => Infinity, @@ -1758,7 +1814,7 @@ var toNanosUnsafe = (input) => { return roundMillisToNanos(self.value.millis); } }; -var match2 = /* @__PURE__ */ dual(2, (self, options) => { +var match3 = /* @__PURE__ */ dual(2, (self, options) => { switch (self.value._tag) { case "Millis": return options.onMillis(self.value.millis); @@ -1785,55 +1841,6 @@ var Equivalence = (self, that) => matchPair(self, that, { onInfinity: (self, that) => self.value._tag === that.value._tag }); var equals2 = /* @__PURE__ */ dual(2, (self, that) => Equivalence(self, that)); -// node_modules/effect/dist/internal/array.js -var isArrayNonEmpty = (self) => self.length > 0; - -// node_modules/effect/dist/internal/count.js -var normalize = (n) => n > 0 ? Math.floor(n) : 0; - -// node_modules/effect/dist/Result.js -var succeed2 = succeed; -var fail2 = fail; -var isResult2 = isResult; -var isFailure2 = isFailure; -var isSuccess2 = isSuccess; -var match3 = /* @__PURE__ */ dual(2, (self, { - onFailure, - onSuccess -}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); - -// node_modules/effect/dist/Iterable.js -var headUnsafe = (self) => { - const iterator = self[Symbol.iterator](); - const result = iterator.next(); - if (result.done) - throw new Error("headUnsafe: empty iterable"); - return result.value; -}; -var constEmpty = { - [Symbol.iterator]() { - return constEmptyIterator; - } -}; -var constEmptyIterator = { - next() { - return { - done: true, - value: undefined - }; - } -}; - -// node_modules/effect/dist/Array.js -var Array2 = globalThis.Array; -var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); -var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); -var isArray = Array2.isArray; -var isArrayNonEmpty2 = isArrayNonEmpty; -var isReadonlyArrayNonEmpty = isArrayNonEmpty; -var empty2 = () => []; -var of = (a) => [a]; -var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); // node_modules/effect/dist/Scheduler.js var Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", { @@ -2581,7 +2588,7 @@ class FiberImpl { } this._stack.length = 0; this._children = undefined; - this.context = empty(); + this.context = empty2(); } runLoop(effect) { const prevFiber = globalThis[currentFiberTypeId]; @@ -2769,7 +2776,7 @@ var fiberInterruptAs = /* @__PURE__ */ dual((args) => hasProperty(args[0], Fiber })); var fiberInterruptAll = (fibers) => withFiber((parent) => { const annotations = fiberStackAnnotations(parent); - let fiberArr = empty2(); + let fiberArr = empty(); for (const fiber of fibers) { fiber.interruptUnsafe(parent.id, annotations); fiberArr.push(fiber); @@ -2793,7 +2800,7 @@ var suspend = /* @__PURE__ */ makePrimitive({ return this[args](); } }); -var fromResult = /* @__PURE__ */ match3({ +var fromResult = /* @__PURE__ */ match2({ onFailure: fail3, onSuccess: succeed3 }); @@ -3086,7 +3093,7 @@ var tapCont = function(value) { var tapEffectCont = function(value) { return new ContImpl(this.payload, returnPayload, exitSucceed(value)); }; -var asSome = (self) => map4(self, some2); +var asSome = (self) => map3(self, some2); var andThen = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? returnPayload : andThenCont, f)); var tap = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? tapEffectCont : tapCont, f)); var asVoid = (self) => new ContImpl(self, returnPayload, exitVoid); @@ -3128,8 +3135,8 @@ var flatMapEager = /* @__PURE__ */ dual(2, (self, f) => { } return flatMap2(self, f); }); -var map4 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); -var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map4(self, f)); +var map3 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); +var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map3(self, f)); var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError(self, f)); var exitInterrupt = (fiberId) => exitFailCause(causeInterrupt(fiberId)); var exitIsSuccess = (self) => self._tag === "Success"; @@ -3505,7 +3512,7 @@ var all = (arg, options) => { } return suspend(() => { const out = {}; - return as(forEach(Object.entries(arg), ([key, effect]) => map4(options?.mode === "result" ? result(effect) : effect, (value) => { + return as(forEach(Object.entries(arg), ([key, effect]) => map3(options?.mode === "result" ? result(effect) : effect, (value) => { assignProperty(out, key, value); }), { discard: true, @@ -3785,7 +3792,7 @@ var fiberRunIn = /* @__PURE__ */ dual(2, (self, scope) => { self.addObserver(() => scopeRemoveFinalizerUnsafe(scope, key)); return self; }); -var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty()); +var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty2()); var runSyncExitWith = (context) => { const runFork = runForkWith(context); return (effect) => { @@ -3799,7 +3806,7 @@ var runSyncExitWith = (context) => { return fiber._exit ?? exitDie(new AsyncFiberError(fiber)); }; }; -var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty()); +var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty2()); var succeedTrue = /* @__PURE__ */ succeed3(true); var succeedFalse = /* @__PURE__ */ succeed3(false); @@ -3921,7 +3928,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = noopSpan({ name, parent, - annotations: add(options?.annotations ?? empty(), DisablePropagation, true) + annotations: add(options?.annotations ?? empty2(), DisablePropagation, true) }); } else { const tracer = fiber.getRef(Tracer); @@ -3934,7 +3941,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = tracer.span({ name, parent, - annotations: options?.annotations ?? empty(), + annotations: options?.annotations ?? empty2(), links, startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : bigint02, kind: options?.kind ?? "internal", @@ -4223,10 +4230,24 @@ function interruptChildrenPatch() { fiberMiddleware.interruptChildren ??= fiberInterruptChildren; } +// node_modules/effect/dist/Cause.js +var isFailReason2 = isFailReason; +var fromReasons = causeFromReasons; +var fail4 = causeFail; +var die2 = causeDie; +var hasInterruptsOnly2 = hasInterruptsOnly; +var map4 = causeMap; +var squash = causeSquash; +var findError2 = findError; +var isDone2 = isDone; +var Done2 = Done; +var done2 = done; +var UnknownError2 = UnknownError; + // node_modules/effect/dist/Exit.js var succeed4 = exitSucceed; var failCause2 = exitFailCause; -var fail4 = exitFail; +var fail5 = exitFail; var void_2 = exitVoid; var isSuccess3 = exitIsSuccess; var isFailure3 = exitIsFailure; @@ -4263,8 +4284,8 @@ var _await = (self) => callback((resume) => { }); }); var completeWith = /* @__PURE__ */ dual(2, (self, effect) => sync(() => doneUnsafe(self, effect))); -var done2 = completeWith; -var isDone2 = (self) => sync(() => isDoneUnsafe(self)); +var done3 = completeWith; +var isDone3 = (self) => sync(() => isDoneUnsafe(self)); var isDoneUnsafe = (self) => self.effect !== undefined; var doneUnsafe = (self, effect) => { if (self.effect) @@ -4337,7 +4358,7 @@ var memoMapBuild = (memoMap, layer, scope, build) => { memoMap.map.set(layer, entry); return scopeAddFinalizerExit(scope, entry.finalizer).pipe(flatMap2(() => build(memoMap, layerScope)), onExit((exit) => { entry.effect = exit; - return done2(deferred, exit); + return done3(deferred, exit); })); }; @@ -4375,7 +4396,7 @@ class CurrentMemoMap extends (/* @__PURE__ */ Service()("effect/Layer/CurrentMem return current ? forkMemoMapUnsafe(current) : makeMemoMapUnsafe(); } } -var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map4(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); +var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map3(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); var buildWithScope = /* @__PURE__ */ dual(2, (self, scope) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope))); var succeed5 = function() { if (arguments.length === 1) { @@ -4397,32 +4418,19 @@ var effect = function() { } return effectImpl(arguments[0], arguments[1]); }; -var effectImpl = (service, effect) => effectContext(map4(effect, (value) => make2(service, value))); +var effectImpl = (service, effect) => effectContext(map3(effect, (value) => make2(service, value))); var effectContext = (effect) => fromBuildMemo((_, scope) => provide(effect, scope)); var mergeAllEffect = (layers, memoMap, scope) => { const parentScope = forkUnsafe2(scope, "parallel"); return forEach(layers, (layer) => layer.build(memoMap, forkUnsafe2(parentScope, "sequential")), { concurrency: layers.length - }).pipe(map4((context) => mergeAll(...context))); + }).pipe(map3((context) => mergeAll(...context))); }; var mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope)); -var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map4((merged) => f(merged, context))))); +var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map3((merged) => f(merged, context))))); var provide2 = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, identity)); var provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self))); -// node_modules/effect/dist/Cause.js -var isFailReason2 = isFailReason; -var fromReasons = causeFromReasons; -var fail5 = causeFail; -var hasInterruptsOnly2 = hasInterruptsOnly; -var map5 = causeMap; -var squash = causeSquash; -var findError2 = findError; -var isDone3 = isDone; -var Done2 = Done; -var done3 = done; -var UnknownError2 = UnknownError; - // node_modules/effect/dist/internal/random.js var nextBetween = (min, max, draw) => { const value = draw * (max - min) + min; @@ -4442,7 +4450,7 @@ var nextBetween = (min, max, draw) => { // node_modules/effect/dist/Pull.js var catchDone = /* @__PURE__ */ dual(2, (effect, f) => catchCauseFilter(effect, filterDoneLeftover, (l) => f(l))); var isDoneCause = (cause) => cause.reasons.some(isDoneFailure); -var isDoneFailure = (failure) => failure._tag === "Fail" && isDone3(failure.error); +var isDoneFailure = (failure) => failure._tag === "Fail" && isDone2(failure.error); var filterDone = (cause) => { let done; let hasFailure = false; @@ -4484,7 +4492,6 @@ var forEach2 = forEach; var whileLoop2 = whileLoop; var tryPromise2 = tryPromise; var succeed6 = succeed3; -var succeedNone2 = succeedNone; var suspend2 = suspend; var sync3 = sync; var void_3 = void_; @@ -4494,7 +4501,7 @@ var gen2 = gen; var fail6 = fail3; var failCause3 = failCause; var failCauseSync2 = failCauseSync; -var die2 = die; +var die3 = die; var try_2 = try_; var yieldNow2 = yieldNow; var withFiber2 = withFiber; @@ -4503,7 +4510,7 @@ var flatMap3 = flatMap2; var andThen2 = andThen; var tap2 = tap; var exit2 = exit; -var map6 = map4; +var map5 = map3; var as2 = as; var catch_2 = catch_; var catchTag2 = catchTag; @@ -4550,3610 +4557,3029 @@ var effectify = (fn, onError, onSyncError) => (...args) => callback2((resume) => } }); } catch (err) { - resume(onSyncError ? fail6(onSyncError(err, args)) : die2(err)); + resume(onSyncError ? fail6(onSyncError(err, args)) : die3(err)); } }); var mapEager2 = mapEager; var mapErrorEager2 = mapErrorEager; var flatMapEager2 = flatMapEager; var fnUntracedEager2 = fnUntracedEager; -// node_modules/effect/dist/BigInt.js -var BigInt2 = globalThis.BigInt; -var toNumber = (b) => { - if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { - return none2(); + +// node_modules/effect/dist/internal/schema/annotations.js +function resolve(ast) { + return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; +} +var STRUCTURAL_ANNOTATION_KEY = "~structural"; +var SENTINELS_ANNOTATION_KEY = "~sentinels"; +var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; +var getExpected = /* @__PURE__ */ memoize((ast) => { + const identifier = resolve(ast)?.identifier; + if (typeof identifier === "string") + return identifier; + return ast.getExpected(getExpected); +}); + +// node_modules/effect/dist/internal/schema/parser.js +var missing = /* @__PURE__ */ Symbol(); +var succeed7 = succeed4; +var missingExit = /* @__PURE__ */ succeed7(missing); +var sameExit = /* @__PURE__ */ succeed7(missing); +var toOption = (value) => value === missing ? none2() : some2(value); +var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed7(option.value); + +// node_modules/effect/dist/SchemaIssue.js +var TypeId7 = "~effect/SchemaIssue/Issue"; +function isIssue(u) { + return hasProperty(u, TypeId7) && u[TypeId7] === TypeId7; +} +function hasInput(issue) { + return Object.hasOwn(issue, "input"); +} + +class IssueNodeImpl { + [TypeId7] = TypeId7; + constructor(input, options) { + if (options?.reportInput === true && input !== missing) { + this.input = input; + } + } +} +var Filter = class extends IssueNodeImpl { + _tag = "Filter"; + filter; + issue; + constructor(filter, issue, input, options) { + super(input, options); + this.filter = filter; + this.issue = issue; } - return some2(Number(b)); }; - -// node_modules/effect/dist/ByteSize.js -var bigint03 = /* @__PURE__ */ BigInt(0); -var bigint12 = /* @__PURE__ */ BigInt(1); -var decimalBase = /* @__PURE__ */ BigInt(1000); -var binaryBase = /* @__PURE__ */ BigInt(1024); -var decimalUnits = [{ - symbol: "B", - factor: bigint12, - names: ["B", "byte", "bytes"] -}, { - symbol: "kB", - factor: decimalBase, - names: ["kB", "kilobyte", "kilobytes"] -}, { - symbol: "MB", - factor: decimalBase ** /* @__PURE__ */ BigInt(2), - names: ["MB", "megabyte", "megabytes"] -}, { - symbol: "GB", - factor: decimalBase ** /* @__PURE__ */ BigInt(3), - names: ["GB", "gigabyte", "gigabytes"] -}, { - symbol: "TB", - factor: decimalBase ** /* @__PURE__ */ BigInt(4), - names: ["TB", "terabyte", "terabytes"] -}, { - symbol: "PB", - factor: decimalBase ** /* @__PURE__ */ BigInt(5), - names: ["PB", "petabyte", "petabytes"] -}, { - symbol: "EB", - factor: decimalBase ** /* @__PURE__ */ BigInt(6), - names: ["EB", "exabyte", "exabytes"] -}, { - symbol: "ZB", - factor: decimalBase ** /* @__PURE__ */ BigInt(7), - names: ["ZB", "zettabyte", "zettabytes"] -}, { - symbol: "YB", - factor: decimalBase ** /* @__PURE__ */ BigInt(8), - names: ["YB", "yottabyte", "yottabytes"] -}, { - symbol: "RB", - factor: decimalBase ** /* @__PURE__ */ BigInt(9), - names: ["RB", "ronnabyte", "ronnabytes"] -}, { - symbol: "QB", - factor: decimalBase ** /* @__PURE__ */ BigInt(10), - names: ["QB", "quettabyte", "quettabytes"] -}]; -var binaryUnits = [decimalUnits[0], { - symbol: "KiB", - factor: binaryBase, - names: ["KiB", "kibibyte", "kibibytes"] -}, { - symbol: "MiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(2), - names: ["MiB", "mebibyte", "mebibytes"] -}, { - symbol: "GiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(3), - names: ["GiB", "gibibyte", "gibibytes"] -}, { - symbol: "TiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(4), - names: ["TiB", "tebibyte", "tebibytes"] -}, { - symbol: "PiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(5), - names: ["PiB", "pebibyte", "pebibytes"] -}, { - symbol: "EiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(6), - names: ["EiB", "exbibyte", "exbibytes"] -}, { - symbol: "ZiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(7), - names: ["ZiB", "zebibyte", "zebibytes"] -}, { - symbol: "YiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(8), - names: ["YiB", "yobibyte", "yobibytes"] -}]; -var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; -var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); -var make5 = (value) => value; -var invalid2 = (message) => { - throw new Error(`Invalid ByteSize: ${message}`); +var Encoding = class extends IssueNodeImpl { + _tag = "Encoding"; + ast; + issue; + constructor(ast, issue, input, options) { + super(input, options); + this.ast = ast; + this.issue = issue; + } }; -var fromNumber = (input) => { - if (!Number.isSafeInteger(input) || input < 0) { - return invalid2(`expected a non-negative safe integer, received ${input}`); +var Pointer = class extends IssueNodeImpl { + _tag = "Pointer"; + path; + issue; + constructor(path, issue) { + super(); + this.path = path; + this.issue = issue; } - return make5(BigInt(input)); }; -var parse = (input) => { - const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); - if (match === null) - return invalid2(`unsupported syntax ${JSON.stringify(input)}`); - const unit = unitsByName.get(match[3]); - if (unit === undefined) - return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); - const fraction = match[2] ?? ""; - const scale = BigInt(10) ** BigInt(fraction.length); - const numerator = BigInt(match[1] + fraction) * unit.factor; - if (numerator % scale !== bigint03) { - return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); +var MissingKey = class extends IssueNodeImpl { + _tag = "MissingKey"; + annotations; + constructor(annotations) { + super(); + this.annotations = annotations; } - return make5(numerator / scale); }; -var fromInputUnsafe2 = (input) => { - switch (typeof input) { - case "bigint": - if (input < bigint03) - return invalid2(`expected a non-negative bigint, received ${input}`); - return make5(input); - case "number": - return fromNumber(input); - case "string": - return parse(input); +var UnexpectedKey = class extends IssueNodeImpl { + _tag = "UnexpectedKey"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; } - return invalid2(`unsupported input ${input}`); }; -var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); - -// node_modules/effect/dist/PlatformError.js -var TypeId7 = "~effect/PlatformError"; - -class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { - get message() { - return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; +var Composite = class extends IssueNodeImpl { + _tag = "Composite"; + ast; + issues; + constructor(ast, issues, input, options) { + super(input, options); + this.ast = ast; + this.issues = issues; + } +}; +var InvalidType = class extends IssueNodeImpl { + _tag = "InvalidType"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; + } +}; +var InvalidValue = class extends IssueNodeImpl { + _tag = "InvalidValue"; + annotations; + constructor(annotations, input, options) { + super(input, options); + this.annotations = annotations; + } +}; +var AnyOf = class extends IssueNodeImpl { + _tag = "AnyOf"; + ast; + issues; + constructor(ast, issues, input, options) { + super(input, options); + this.ast = ast; + this.issues = issues; + } +}; +var OneOf = class extends IssueNodeImpl { + _tag = "OneOf"; + ast; + successes; + constructor(ast, successes, input, options) { + super(input, options); + this.ast = ast; + this.successes = successes; } +}; +function makeFilterIssue(entry, input, options) { + if (isIssue(entry)) { + return entry; + } + if (typeof entry === "string") { + return new InvalidValue({ + message: entry + }, input, options); + } + const inner = typeof entry.issue === "string" ? new InvalidValue({ + message: entry.issue + }, input, options) : entry.issue; + return new Pointer(entry.path, inner); } - -class SystemError extends Error3 { - get message() { - return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; +function makeSingle(out, input, options) { + if (out === undefined) { + return; + } + if (typeof out === "boolean") { + return out ? undefined : new InvalidValue(undefined, input, options); } + return makeFilterIssue(out, input, options); } - -class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { - constructor(reason) { - if ("cause" in reason) { - super({ - reason, - cause: reason.cause - }); - } else { - super({ - reason - }); +function normalizeFilterOutput(ast, out, input, options) { + if (Array.isArray(out)) { + if (!isReadonlyArrayNonEmpty(out)) { + return; } + return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map(out, (entry) => makeFilterIssue(entry, input, options)), input, options); } - [TypeId7] = TypeId7; - get message() { - return this.reason.message; - } + return makeSingle(out, input, options); } -var systemError = (options) => new PlatformError(new SystemError(options)); -var badArgument = (options) => new PlatformError(new BadArgument(options)); - -// node_modules/effect/dist/Fiber.js -var join = fiberJoin; -var interrupt3 = fiberInterrupt; -var runIn = fiberRunIn; - -// node_modules/effect/dist/Latch.js -var makeUnsafe4 = makeLatchUnsafe; -var make6 = makeLatch; - -// node_modules/effect/dist/MutableRef.js -var TypeId8 = "~effect/MutableRef"; -var MutableRefProto = { - [TypeId8]: TypeId8, - ...PipeInspectableProto, - toJSON() { - return { - _id: "MutableRef", - current: toJson(this.current) - }; +var defaultLeafHook = (issue) => { + const message = findMessage(issue); + if (message !== undefined) + return message; + switch (issue._tag) { + case "InvalidType": + return getExpectedMessage(getExpected(issue.ast), issue); + case "InvalidValue": { + const expected = findExpected(issue); + if (expected !== undefined) + return getExpectedMessage(expected, issue); + const input = formatInput(issue); + return input === undefined ? "Expected a valid value" : `Invalid data ${input}`; + } + case "MissingKey": + return "Missing key"; + case "UnexpectedKey": { + const input = formatInput(issue); + return input === undefined ? "Expected no excess property" : `Unexpected key with value ${input}`; + } + case "Forbidden": + return "Forbidden operation"; + case "OneOf": { + const input = formatInput(issue); + return input === undefined ? "Expected exactly one member to match" : `Expected exactly one member to match the input ${input}`; + } } }; -var make7 = (value) => { - const ref = Object.create(MutableRefProto); - ref.current = value; - return ref; -}; - -// node_modules/effect/dist/MutableList.js -var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); -var make8 = () => ({ - head: undefined, - tail: undefined, - length: 0 -}); -var emptyBucket = () => ({ - array: [], - mutable: true, - offset: 0, - next: undefined -}); -var append2 = (self, message) => { - if (!self.tail) { - self.head = self.tail = emptyBucket(); - } else if (!self.tail.mutable) { - self.tail.next = emptyBucket(); - self.tail = self.tail.next; - } - self.tail.array.push(message); - self.length++; -}; -var clear = (self) => { - self.head = self.tail = undefined; - self.length = 0; -}; -var takeN = (self, n) => { - n = normalize(n); - if (n <= 0 || !self.head) - return []; - n = Math.min(n, self.length); - if (n === self.length && self.head?.offset === 0 && !self.head.next) { - const array = self.head.array; - clear(self); - return array; +var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue); +function formatInput(issue) { + return hasInput(issue) ? format(issue.input) : undefined; +} +function findExpected(issue) { + const expected = issue.annotations?.expected; + return typeof expected === "string" ? expected : undefined; +} +function getExpectedMessage(expected, issue) { + const input = formatInput(issue); + return input === undefined ? `Expected ${expected}` : `Expected ${expected}, got ${input}`; +} +function formatCheck(check) { + const expected = check.annotations?.expected; + if (typeof expected === "string") + return expected; + switch (check._tag) { + case "Filter": + return ""; + case "FilterGroup": + return check.checks.map((check) => formatCheck(check)).join(" & "); } - const array = new Array(n); - let index = 0; - let chunk = self.head; - while (chunk) { - while (chunk.offset < chunk.array.length) { - array[index++] = chunk.array[chunk.offset]; - if (chunk.mutable) - chunk.array[chunk.offset] = undefined; - chunk.offset++; - if (index === n) { - self.head = chunk; - self.length -= n; - if (self.length === 0) - clear(self); - return array; +} +function makeFormatterDefault() { + return (issue) => formatIssue(issue, ""); +} +var defaultFormatter = /* @__PURE__ */ makeFormatterDefault(); +function formatIssue(issue, path) { + let message; + switch (issue._tag) { + case "Filter": { + const annotated = defaultCheckHook(issue); + if (annotated !== undefined) { + message = annotated; + } else { + if (issue.issue._tag !== "InvalidValue") { + return formatIssue(issue.issue, path); + } + const expected = findExpected(issue.issue); + message = expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue); } + break; } - chunk = chunk.next; - } - clear(self); - return array; -}; -var take = (self) => { - if (!self.head) - return Empty; - const message = self.head.array[self.head.offset]; - if (self.head.mutable) - self.head.array[self.head.offset] = undefined; - self.head.offset++; - self.length--; - if (self.head.offset === self.head.array.length) { - if (self.head.next) { - self.head = self.head.next; - } else { - clear(self); + case "Encoding": + return formatIssue(issue.issue, path); + case "Pointer": + return formatIssue(issue.issue, path + formatPath(issue.path)); + case "Composite": + case "AnyOf": { + if (issue._tag === "Composite" || issue.issues.length > 0) { + return issue.issues.map((issue) => formatIssue(issue, path)).join(` +`); + } + message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue); + break; } + default: + message = defaultLeafHook(issue); + break; } - return message; -}; + return path ? `${message} + at ${path}` : message; +} +function findMessage(issue) { + if (issue._tag === "Pointer") + return; + if (issue._tag === "Encoding") + return findMessage(issue.issue); + const annotations = issue._tag === "Filter" ? issue.filter.annotations : ("annotations" in issue) ? issue.annotations : issue.ast.annotations; + const message = annotations?.[issue._tag === "MissingKey" ? "messageMissingKey" : issue._tag === "UnexpectedKey" ? "messageUnexpectedKey" : "message"]; + if (typeof message === "string") + return message; +} -// node_modules/effect/dist/Queue.js -var TypeId9 = "~effect/Queue"; -var EnqueueTypeId = "~effect/Queue/Enqueue"; -var DequeueTypeId = "~effect/Queue/Dequeue"; -var variance = { - _A: identity, - _E: identity -}; -var QueueProto = { - [TypeId9]: variance, - [EnqueueTypeId]: variance, - [DequeueTypeId]: variance, - ...PipeInspectableProto, - toJSON() { - return { - _id: "effect/Queue", - state: this.state._tag, - size: sizeUnsafe(this) - }; - } -}; -var make9 = (options) => withFiber((fiber) => { - const self = Object.create(QueueProto); - self.dispatcher = fiber.currentDispatcher; - self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; - self.strategy = options?.strategy ?? "suspend"; - self.messages = make8(); - self.scheduleRunning = false; - self.state = { - _tag: "Open", - takers: new Set, - offers: new Set, - awaiters: new Set - }; - return succeed3(self); -}); -var bounded = (capacity) => make9({ - capacity -}); -var offer = (self, message) => suspend(() => { - if (self.state._tag !== "Open") { - return exitFalse; - } else if (self.messages.length >= self.capacity) { - switch (self.strategy) { - case "dropping": - return exitFalse; - case "suspend": - if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return exitTrue; - } - return offerRemainingSingle(self, message); - case "sliding": - take(self.messages); - append2(self.messages, message); - return exitTrue; - } - } - append2(self.messages, message); - scheduleReleaseTaker(self); - return exitTrue; -}); -var offerUnsafe = (self, message) => { - if (self.state._tag !== "Open") { - return false; - } else if (self.messages.length >= self.capacity) { - if (self.strategy === "sliding") { - take(self.messages); - append2(self.messages, message); - return true; - } else if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return true; +// node_modules/effect/dist/internal/schema/cause.js +function getSchemaIssue(cause) { + let issue; + for (const reason of cause.reasons) { + if (!isFailReason2(reason) || !isIssue(reason.error)) { + return; } - return false; - } - append2(self.messages, message); - scheduleReleaseTaker(self); - return true; -}; -var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); -var failCauseUnsafe = (self, cause) => { - if (self.state._tag !== "Open") { - return false; - } - const exit = exitFailCause(cause); - const fail = exitZipRight(exit, exitFailDone); - if (self.state.offers.size === 0 && self.messages.length === 0) { - finalize(self, fail); - return true; + issue ??= reason.error; } - self.state = { - ...self.state, - _tag: "Closing", - exit: fail - }; - return true; -}; -var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); -var shutdown = (self) => sync(() => { - if (self.state._tag === "Done") { - return true; + return issue; +} +function getSchemaIssueOrThrow(cause, message) { + const issue = getSchemaIssue(cause); + if (issue === undefined) { + throw new Error(message, { + cause + }); } - clear(self.messages); - const offers = self.state.offers; - finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); - if (offers.size > 0) { - for (const entry of offers) { - if (entry._tag === "Single") { - entry.resume(exitFalse); - } else { - entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); - } - } - offers.clear(); - } - return true; + return issue; +} + +// node_modules/effect/dist/SchemaGetter.js +var makeGetter = (fields) => Object.assign(Object.create(Prototype), fields); +var passthrough_ = /* @__PURE__ */ makeGetter({ + _tag: "Passthrough" }); -var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); -var takeBetween = (self, min, max) => { - min = normalize(min); - max = normalize(max); - return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); +function passthrough() { + return passthrough_; +} +function transform(f) { + return makeGetter({ + _tag: "Transform", + transform: f + }); +} +function transformEffect(f) { + return makeGetter({ + _tag: "TransformEffect", + transform: f + }); +} +function String2() { + return transform(globalThis.String); +} +function Number3() { + return transform(globalThis.Number); +} +function parseJson(options) { + return transformEffect((input, parseOptions) => try_2({ + try: () => JSON.parse(input, options?.reviver), + catch: () => new InvalidValue({ + expected: "a valid JSON string" + }, input, parseOptions) + })); +} +function stringifyJson(options) { + return transformEffect((input, parseOptions) => try_2({ + try: () => { + const output = JSON.stringify(input, options?.replacer, options?.space); + if (output === undefined) { + throw new TypeError("Value cannot be represented as JSON"); + } + return output; + }, + catch: () => new InvalidValue({ + expected: "a JSON-serializable value" + }, input, parseOptions) + })); +} +function encodeBase642() { + return transform(encodeBase64); +} +function decodeBase642() { + return transformEffect((input, options) => mapErrorEager2(fromResult2(decodeBase64(input)), () => new InvalidValue({ + expected: "a valid Base64 string" + }, input, options))); +} + +// node_modules/effect/dist/ByteSize.js +var bigint03 = /* @__PURE__ */ BigInt(0); +var bigint12 = /* @__PURE__ */ BigInt(1); +var decimalBase = /* @__PURE__ */ BigInt(1000); +var binaryBase = /* @__PURE__ */ BigInt(1024); +var decimalUnits = [{ + symbol: "B", + factor: bigint12, + names: ["B", "byte", "bytes"] +}, { + symbol: "kB", + factor: decimalBase, + names: ["kB", "kilobyte", "kilobytes"] +}, { + symbol: "MB", + factor: decimalBase ** /* @__PURE__ */ BigInt(2), + names: ["MB", "megabyte", "megabytes"] +}, { + symbol: "GB", + factor: decimalBase ** /* @__PURE__ */ BigInt(3), + names: ["GB", "gigabyte", "gigabytes"] +}, { + symbol: "TB", + factor: decimalBase ** /* @__PURE__ */ BigInt(4), + names: ["TB", "terabyte", "terabytes"] +}, { + symbol: "PB", + factor: decimalBase ** /* @__PURE__ */ BigInt(5), + names: ["PB", "petabyte", "petabytes"] +}, { + symbol: "EB", + factor: decimalBase ** /* @__PURE__ */ BigInt(6), + names: ["EB", "exabyte", "exabytes"] +}, { + symbol: "ZB", + factor: decimalBase ** /* @__PURE__ */ BigInt(7), + names: ["ZB", "zettabyte", "zettabytes"] +}, { + symbol: "YB", + factor: decimalBase ** /* @__PURE__ */ BigInt(8), + names: ["YB", "yottabyte", "yottabytes"] +}, { + symbol: "RB", + factor: decimalBase ** /* @__PURE__ */ BigInt(9), + names: ["RB", "ronnabyte", "ronnabytes"] +}, { + symbol: "QB", + factor: decimalBase ** /* @__PURE__ */ BigInt(10), + names: ["QB", "quettabyte", "quettabytes"] +}]; +var binaryUnits = [decimalUnits[0], { + symbol: "KiB", + factor: binaryBase, + names: ["KiB", "kibibyte", "kibibytes"] +}, { + symbol: "MiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(2), + names: ["MiB", "mebibyte", "mebibytes"] +}, { + symbol: "GiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(3), + names: ["GiB", "gibibyte", "gibibytes"] +}, { + symbol: "TiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(4), + names: ["TiB", "tebibyte", "tebibytes"] +}, { + symbol: "PiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(5), + names: ["PiB", "pebibyte", "pebibytes"] +}, { + symbol: "EiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(6), + names: ["EiB", "exbibyte", "exbibytes"] +}, { + symbol: "ZiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(7), + names: ["ZiB", "zebibyte", "zebibytes"] +}, { + symbol: "YiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(8), + names: ["YiB", "yobibyte", "yobibytes"] +}]; +var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; +var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); +var make5 = (value) => value; +var invalid2 = (message) => { + throw new Error(`Invalid ByteSize: ${message}`); }; -var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); -var poll = (self) => suspend(() => { - const result = takeUnsafe(self); - if (result === undefined) { - return succeed3(none2()); - } - if (result._tag === "Success") { - return succeed3(some2(result.value)); - } - return succeed3(none2()); -}); -var takeUnsafe = (self) => { - if (self.state._tag === "Done") { - return self.state.exit; - } - if (self.messages.length > 0) { - const message = take(self.messages); - releaseCapacity(self); - return exitSucceed(message); - } else if (self.capacity <= 0 && self.state.offers.size > 0) { - const message = takeOfferUnsafe(self.state.offers); - releaseCapacity(self); - return exitSucceed(message); +var fromNumber = (input) => { + if (!Number.isSafeInteger(input) || input < 0) { + return invalid2(`expected a non-negative safe integer, received ${input}`); } - return; + return make5(BigInt(input)); }; -var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; -var exitFalse = /* @__PURE__ */ exitSucceed(false); -var exitTrue = /* @__PURE__ */ exitSucceed(true); -var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); -var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); -var releaseTakers = (self) => { - if (self.state._tag === "Done" || self.state.takers.size === 0) { - return; - } - for (const taker of self.state.takers) { - self.state.takers.delete(taker); - taker(exitVoid); - if (self.messages.length === 0) { - break; - } +var fromStringUnsafe = (input) => { + const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); + if (match === null) + return invalid2(`unsupported syntax ${JSON.stringify(input)}`); + const unit = unitsByName.get(match[3]); + if (unit === undefined) + return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); + const fraction = match[2] ?? ""; + const scale = BigInt(10) ** BigInt(fraction.length); + const numerator = BigInt(match[1] + fraction) * unit.factor; + if (numerator % scale !== bigint03) { + return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); } + return make5(numerator / scale); }; -var scheduleReleaseTaker = (self) => { - if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { - return; +var fromInputUnsafe2 = (input) => { + switch (typeof input) { + case "bigint": + if (input < bigint03) + return invalid2(`expected a non-negative bigint, received ${input}`); + return make5(input); + case "number": + return fromNumber(input); + case "string": + return fromStringUnsafe(input); } - self.scheduleRunning = true; - self.dispatcher.scheduleTask(() => { - self.scheduleRunning = false; - releaseTakers(self); - }, 0); + return invalid2(`unsupported input ${input}`); }; -var takeBetweenUnsafe = (self, min, max) => { - if (self.state._tag === "Done") { - return self.state.exit; - } else if (max <= 0 || min <= 0) { - return exitSucceed([]); - } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { - const messages = [takeOfferUnsafe(self.state.offers)]; - releaseCapacity(self); - return exitSucceed(messages); +var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); + +// node_modules/effect/dist/SchemaTransformation.js +var TypeId8 = "~effect/SchemaTransformation/Transformation"; +var Transformation = class extends Class { + [TypeId8] = TypeId8; + _tag = "Transformation"; + decode; + encode; + constructor(decode, encode) { + super(); + this.decode = decode; + this.encode = encode; } - min = Math.min(min, self.capacity || 1); - if (min <= self.messages.length) { - const messages = takeN(self.messages, max); - releaseCapacity(self); - return exitSucceed(messages); + flip() { + return new Transformation(this.encode, this.decode); } }; -var offerRemainingSingle = (self, message) => { - return callback((resume) => { - if (self.state._tag !== "Open") { - return resume(exitFalse); - } - const entry = { - _tag: "Single", - message, - resume - }; - self.state.offers.add(entry); - return sync(() => { - if (self.state._tag === "Open") { - self.state.offers.delete(entry); - } - }); - }); -}; -var takeOfferUnsafe = (offers) => { - const entry = offers.values().next().value; - if (entry._tag === "Single") { - offers.delete(entry); - entry.resume(exitTrue); - return entry.message; +function isTransformation(u) { + return hasProperty(u, TypeId8) && u[TypeId8] === TypeId8; +} +var makeTransformation = (options) => { + if (isTransformation(options)) { + return options; } - const message = entry.remaining[entry.offset++]; - if (entry.offset === entry.remaining.length) { - offers.delete(entry); - entry.resume(exitSucceed([])); + return new Transformation(options.decode, options.encode); +}; +function transformEffect2(options) { + return new Transformation(transformEffect(options.decode), transformEffect(options.encode)); +} +function transform2(options) { + return new Transformation(transform(options.decode), transform(options.encode)); +} +var passthrough_2 = /* @__PURE__ */ new Transformation(/* @__PURE__ */ passthrough(), /* @__PURE__ */ passthrough()); +function passthrough2() { + return passthrough_2; +} +var numberFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ String2()); +var isJsonError = (input) => isObject(input) && typeof input["message"] === "string"; +var decodeJsonError = (input) => { + const hasCause = Object.hasOwn(input, "cause"); + const err = hasCause ? new Error(input.message, { + cause: decodeDefect(input.cause) + }) : new Error(input.message); + if (typeof input.name === "string" && input.name !== "Error") + err.name = input.name; + if (typeof input.stack === "string") + err.stack = input.stack; + return err; +}; +var encodeUnknownAsJson = (input) => { + try { + const json = formatJson(input); + return json === undefined ? format(input) : JSON.parse(json); + } catch { + return format(input); } - return message; }; -var releaseCapacity = (self) => { - if (self.state._tag === "Done") { - return isDoneCause(self.state.exit.cause); - } else if (self.state.offers.size === 0) { - if (self.state._tag === "Closing" && self.messages.length === 0) { - finalize(self, self.state.exit); - return isDoneCause(self.state.exit.cause); - } - return false; +var encodeJsonError = (input, options, encodeDefect) => { + const encoded = { + name: input.name, + message: typeof input.message === "string" ? input.message : "" + }; + if (options?.includeStack && typeof input.stack === "string") { + encoded.stack = input.stack; } - for (const entry of self.state.offers) { - let n = self.capacity - self.messages.length; - if (n <= 0) - break; - else if (entry._tag === "Single") { - append2(self.messages, entry.message); - self.state.offers.delete(entry); - entry.resume(exitTrue); - } else { - for (;entry.offset < entry.remaining.length; entry.offset++) { - if (n === 0) - return false; - append2(self.messages, entry.remaining[entry.offset]); - n--; - } - self.state.offers.delete(entry); - entry.resume(exitSucceed([])); - } + if (!options?.excludeCause && input.cause !== undefined) { + encoded.cause = encodeDefect(input.cause); } - return false; + return encoded; }; -var awaitTake = (self) => callback((resume) => { - if (self.state._tag === "Done") { - return resume(self.state.exit); - } - self.state.takers.add(resume); - return sync(() => { - if (self.state._tag !== "Done") { - self.state.takers.delete(resume); +var makeEncodeDefect = (options) => { + const seen = new WeakSet; + const encode = (input) => { + if (isError(input)) { + if (seen.has(input)) { + return "[Circular]"; + } + seen.add(input); + const encoded = encodeJsonError(input, options, encode); + seen.delete(input); + return encoded; } - }); -}); -var finalize = (self, exit) => { - if (self.state._tag === "Done") { - return; - } - const openState = self.state; - self.state = { - _tag: "Done", - exit + return encodeUnknownAsJson(input); }; - for (const taker of openState.takers) { - taker(exit); + return encode; +}; +var decodeDefect = (input) => isJsonError(input) ? decodeJsonError(input) : input; +var defectFromJson = (options) => transform2({ + decode: decodeDefect, + encode: makeEncodeDefect(options) +}); +var urlFromString = /* @__PURE__ */ transformEffect2({ + decode: (s, options) => URL.canParse(s) ? succeed6(new URL(s)) : fail6(new InvalidValue({ + expected: "a valid URL string" + }, s, options)), + encode: (url) => succeed6(url.href) +}); +var uint8ArrayFromBase64String = /* @__PURE__ */ new Transformation(/* @__PURE__ */ decodeBase642(), /* @__PURE__ */ encodeBase642()); +function fromJsonString(options) { + return new Transformation(parseJson(options ?? {}), stringifyJson(options)); +} + +// node_modules/effect/dist/SchemaAST.js +function makeGuard(tag) { + return (ast) => ast._tag === tag; +} +var isDeclaration = /* @__PURE__ */ makeGuard("Declaration"); +var isNever2 = /* @__PURE__ */ makeGuard("Never"); +var isLiteral = /* @__PURE__ */ makeGuard("Literal"); +var isUniqueSymbol = /* @__PURE__ */ makeGuard("UniqueSymbol"); +var isArrays = /* @__PURE__ */ makeGuard("Arrays"); +var isObjects = /* @__PURE__ */ makeGuard("Objects"); +var isUnion = /* @__PURE__ */ makeGuard("Union"); +var isSuspend = /* @__PURE__ */ makeGuard("Suspend"); +var Link = class { + to; + transformation; + constructor(to, transformation) { + this.to = to; + this.transformation = transformation; } - openState.takers.clear(); - for (const awaiter of openState.awaiters) { - awaiter(exit); +}; +var defaultParseOptions = {}; +var Context = class { + isOptional; + isMutable; + constructorDefault; + annotations; + constructor(isOptional, isMutable, constructorDefault = undefined, annotations = undefined) { + this.isOptional = isOptional; + this.isMutable = isMutable; + this.constructorDefault = constructorDefault; + this.annotations = annotations; } - openState.awaiters.clear(); }; +var TypeId9 = "~effect/Schema"; -// node_modules/effect/dist/Semaphore.js -var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); -var waitForPermits = (self, n, effect) => callback((resume) => { - if (self.free >= n) - return resume(effect); - const observer = () => { - if (self.free < n) - return; - self.waiters.delete(observer); - resume(effect); - }; - self.waiters.add(observer); - return sync(() => { - self.waiters.delete(observer); - }); -}); - -class SemaphoreImpl { - waiters = /* @__PURE__ */ new Set; - taken = 0; - permits; - constructor(permits) { - this.permits = permits; +class ASTNodeImpl { + [TypeId9] = TypeId9; + annotations; + checks; + encoding; + context; + constructor(annotations = undefined, checks = undefined, encoding = undefined, context = undefined) { + this.annotations = annotations; + this.checks = checks; + this.encoding = encoding; + this.context = context; } - get free() { - return this.permits - this.taken; + toString() { + return `<${this._tag}>`; } - take(n) { - const take = suspend(() => { - if (this.free < n) { - return waitForPermits(this, n, take); - } - this.taken += n; - return succeed3(n); - }); - return take; +} +var Declaration = class extends ASTNodeImpl { + _tag = "Declaration"; + typeParameters; + run; + encodingChecks; + encodingRun; + constructor(typeParameters, run, annotations, checks, encoding, context, encodingChecks, encodingRun) { + super(annotations, checks, encoding, context); + this.typeParameters = typeParameters; + this.run = run; + this.encodingChecks = encodingChecks; + this.encodingRun = encodingRun; } - takeIfAvailable(n) { - return suspend(() => { - if (this.free < n) - return succeed3(false); - this.taken += n; - return succeed3(true); - }); + getParser() { + let run; + return (input, options) => { + if (input === missing) + return missingExit; + return (run ??= this.run(this.typeParameters))(input, this, options); + }; } - releaseUnsafe(fiber, n) { - this.taken -= n; - if (this.waiters.size > 0) { - fiber.currentDispatcher.scheduleTask(() => { - for (const observer of this.waiters) { - if (this.free <= 0) - break; - observer(); - } - }, 0); + _rebuild(recur, checks, encodingChecks, run, encodingRun) { + const tps = mapOrSame(this.typeParameters, recur); + return tps === this.typeParameters && checks === this.checks && encodingChecks === this.encodingChecks && run === this.run && encodingRun === this.encodingRun ? this : new Declaration(tps, run, this.annotations, checks, undefined, this.context, encodingChecks, encodingRun); + } + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks, this.run, this.encodingRun); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks, this.encodingRun ?? this.run, this.run); + } + getExpected() { + const expected = this.annotations?.expected; + if (typeof expected === "string") + return expected; + return ""; + } +}; +var Unknown = class extends ASTNodeImpl { + _tag = "Unknown"; + getParser() { + return fromRefinement(this, isUnknown); + } + getExpected() { + return "unknown"; + } +}; +var unknown = /* @__PURE__ */ new Unknown; +var Literal = class extends ASTNodeImpl { + _tag = "Literal"; + literal; + constructor(literal, annotations, checks, encoding, context) { + super(annotations, checks, encoding, context); + if (typeof literal === "number" && !globalThis.Number.isFinite(literal)) { + throw new Error(`A numeric literal must be finite, got ${format(literal)}`); } - return this.free; + this.literal = literal; } - resize(permits) { - return withFiber((fiber) => { - this.permits = permits; - if (this.free < 0) - return void_; - this.releaseUnsafe(fiber, 0); - return void_; - }); + getParser() { + return fromConst(this, this.literal); } - release(n) { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); + matchPart(s, _options) { + return s === globalThis.String(this.literal) ? this.literal : undefined; } - get releaseAll() { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); + toCodecJson() { + return typeof this.literal === "bigint" ? literalToString(this) : this; } - withPermits(n) { - return (self) => uninterruptibleMask((restore) => { - const acquire = suspend(() => { - if (this.free < n) { - const wait = waitForPermits(this, n, void_); - return flatMap2(restore(wait), () => acquire); - } - this.taken += n; - return onExitPrimitive(restore(self), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); - return acquire; - }); + toCodecStringTree() { + return typeof this.literal === "string" ? this : literalToString(this); } - withPermit = /* @__PURE__ */ this.withPermits(1); - withPermitsIfAvailable(n) { - return (self) => uninterruptibleMask((restore) => { - if (this.free < n) - return succeedNone; - this.taken += n; - return onExitPrimitive(restore(asSome(self)), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); + getExpected() { + return typeof this.literal === "string" ? JSON.stringify(this.literal) : globalThis.String(this.literal); } +}; +function literalToString(ast) { + const literalAsString = globalThis.String(ast.literal); + return replaceEncoding(ast, [new Link(new Literal(literalAsString), new Transformation(transform(() => ast.literal), transform(() => literalAsString)))]); } - -// node_modules/effect/dist/Channel.js -var TypeId10 = "~effect/Channel"; -var isChannel = (u) => hasProperty(u, TypeId10); -var ChannelProto = { - [TypeId10]: { - _Env: identity, - _InErr: identity, - _InElem: identity, - _OutErr: identity, - _OutElem: identity - }, - pipe() { - return pipeArguments(this, arguments); +var String3 = class extends ASTNodeImpl { + _tag = "String"; + getParser() { + return fromRefinement(this, isString); + } + matchPart(s, options) { + const checks = this.checks; + return checks && !options.disableChecks && collectIssues(checks, s, undefined, this, options) ? undefined : s; + } + getExpected() { + return "string"; } }; -var fromTransform = (transform) => { - const self = Object.create(ChannelProto); - self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); - return self; -}; -var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); -var fromPull = (effect) => fromTransform((_, __) => effect); -var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { - const closableScope = forkUnsafe2(scope); - const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); - const pull = yield* onError2(f(upstream, scope, closableScope), onCause); - return onError2(pull, onCause); -})); -var toTransform = (channel) => channel.transform; -var asyncQueue = (scope, f, options) => make9({ - capacity: options?.bufferSize, - strategy: options?.strategy -}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); -var callbackArray = (f, options) => fromTransform((_, scope) => map6(asyncQueue(scope, f, options), takeAll2)); -var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); -var succeed7 = (value) => fromEffect(succeed6(value)); -var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done3())); -var fail7 = (error) => fromPull(succeed6(fail6(error))); -var failCause5 = (cause) => fromPull(failCause3(cause)); -var fromEffect = (effect) => fromPull(sync3(() => { - let done = false; - return suspend2(() => { - if (done) - return done3(); - done = true; - return effect; - }); -})); -var fromEffectDrain = (effect) => fromPull(flatMap3(effect, () => done3())); -var map7 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { - let i = 0; - return map6(pull, (o) => f(o, i++)); -}))); -var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); -var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done3))))); -var concurrencyIsSequential = (concurrency) => concurrency === undefined || concurrency !== "unbounded" && concurrency <= 1; -var flatMap4 = /* @__PURE__ */ dual((args) => isChannel(args[0]), (self, f, options) => concurrencyIsSequential(options?.concurrency) ? flatMapSequential(self, f) : flatMapConcurrent(self, f, options)); -var flatMapSequential = (self, f) => fromTransform((upstream, scope) => map6(toTransform(self)(upstream, scope), (pull) => { - let childPull; - let childScope; - const makePull = flatMap3(pull, (value) => { - childScope ??= forkUnsafe2(scope); - return flatMapEager2(toTransform(f(value))(upstream, childScope), (pull) => { - childPull = catchHalt(pull); - return childPull; - }); - }); - const catchHalt = catchDone((_) => { - childPull = undefined; - if (childScope.state._tag === "Open" && scopeFinalizerCountUnsafe(childScope) === 1) { - return makePull; - } - const close2 = close(childScope, void_2); - childScope = undefined; - return flatMap3(close2, () => makePull); - }); - return suspend2(() => childPull ?? makePull); -})); -var flatMapConcurrent = (self, f, options) => self.pipe(map7(f), mergeAll3(options)); -var flattenArray = (self) => transformPull(self, (pull) => { - let array; - let index = 0; - const pump = suspend2(function loop() { - if (array === undefined) { - return flatMap3(pull, (array_) => { - switch (array_.length) { - case 0: - return loop(); - case 1: - return succeed6(array_[0]); - default: { - array = array_; - return succeed6(array_[index++]); - } - } - }); +var string2 = /* @__PURE__ */ new String3; +var Number4 = class extends ASTNodeImpl { + _tag = "Number"; + getParser() { + return fromRefinement(this, isNumber); + } + matchKey(s, options) { + return this._match(isStringNumberRegExp, s, options); + } + matchPart(s, options) { + return this._match(isStringFiniteRegExp, s, options); + } + _match(regexp, s, options) { + if (!regexp.test(s)) + return; + const value = globalThis.Number(s); + if (options.disableChecks || !this.checks) + return value; + return collectIssues(this.checks, value, undefined, this, options) ? undefined : value; + } + toCodecJson() { + if (this.checks && (hasCheck(this.checks, "effect/schema/isFinite") || hasCheck(this.checks, "effect/schema/isInt"))) { + return this; } - const next = array[index++]; - if (index >= array.length) { - array = undefined; - index = 0; + return replaceEncoding(this, [numberToJson]); + } + toCodecStringTree() { + if (this.toCodecJson() === this) { + return replaceEncoding(this, [finiteToString]); } - return succeed6(next); - }); - return succeed6(pump); -}); -var drain = (self) => transformPull(self, (pull) => succeed6(forever2(pull, { - disableYield: true -}))); -var catchCause3 = /* @__PURE__ */ dual(2, (self, f) => fromTransform((upstream, scope) => { - let forkedScope = forkUnsafe2(scope); - return map6(toTransform(self)(upstream, forkedScope), (pull) => { - let currentPull = pull.pipe(catchCause2((cause) => { - if (isDoneCause(cause)) { - return failCause3(cause); - } - const toClose = forkedScope; - forkedScope = forkUnsafe2(scope); - return close(toClose, failCause2(cause)).pipe(andThen2(toTransform(f(cause))(upstream, forkedScope)), flatMap3((childPull) => { - currentPull = childPull; - return childPull; - })); - })); - return suspend2(() => currentPull); - }); -})); -var catchCauseFilter2 = /* @__PURE__ */ dual(3, (self, filter, f) => catchCause3(self, (cause) => { - const result = filter(cause); - return isFailure2(result) ? failCause5(result.failure) : f(result.success, cause); -})); -var catch_3 = /* @__PURE__ */ dual(2, (self, f) => catchCauseFilter2(self, findError2, (e) => f(e))); -var mapError3 = /* @__PURE__ */ dual(2, (self, f) => catch_3(self, (err) => fail7(f(err)))); -var mergeAll3 = /* @__PURE__ */ dual(2, (channels, { - bufferSize = 16, - concurrency, - switch: switch_ = false -}) => fromTransformBracket(fnUntraced2(function* (upstream, scope, forkedScope) { - const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : Math.max(1, concurrency); - const semaphore = switch_ ? undefined : makeUnsafe5(concurrencyN); - const doneLatch = yield* make6(true); - const fibers = new Set; - const queue = yield* bounded(bufferSize); - yield* addFinalizer2(forkedScope, shutdown(queue)); - const pull = yield* toTransform(channels)(upstream, scope); - yield* gen2(function* () { - while (true) { - let pullFiber; - if (semaphore) { - if (fibers.size < concurrencyN) { - yield* semaphore.take(1); - } else { - pullFiber = yield* forkChild2(pull); - yield* raceFirst2(semaphore.take(1), andThen2(join(pullFiber), never2)); - } - } - const channel = pullFiber === undefined ? yield* pull : yield* join(pullFiber); - const childScope = forkUnsafe2(forkedScope); - const childPull = yield* toTransform(channel)(upstream, childScope); - while (fibers.size >= concurrencyN) { - const fiber = headUnsafe(fibers); - fibers.delete(fiber); - if (fibers.size === 0) - yield* doneLatch.open; - yield* interrupt3(fiber); + return replaceEncoding(this, [numberToString]); + } + getExpected() { + return "number"; + } +}; +function hasCheck(checks, id) { + return checks.some((check) => check.annotations?.representation?.id === id || check._tag === "FilterGroup" && hasCheck(check.checks, id)); +} +var number2 = /* @__PURE__ */ new Number4; +var Boolean = class extends ASTNodeImpl { + _tag = "Boolean"; + getParser() { + return fromRefinement(this, isBoolean); + } + getExpected() { + return "boolean"; + } +}; +var boolean = /* @__PURE__ */ new Boolean; +var Arrays = class extends ASTNodeImpl { + _tag = "Arrays"; + isMutable; + elements; + rest; + encodingChecks; + constructor(isMutable, elements, rest, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.isMutable = isMutable; + this.elements = elements; + this.rest = rest; + this.encodingChecks = encodingChecks; + let hasOptional = false; + for (let i = 0;i < elements.length; i++) { + if (isOptional(elements[i])) { + hasOptional = true; + } else if (hasOptional) { + throw new Error("A required element cannot follow an optional element. ts(1257)"); } - const fiber = yield* childPull.pipe(tap2(() => yieldNow2), flatMap3((value) => offer(queue, value)), forever2({ - disableYield: true - }), onError2(fnUntraced2(function* (cause) { - const halt = filterDone(cause); - yield* exit2(close(childScope, !isFailure2(halt) ? succeed4(halt.success.value) : failCause2(halt.failure))); - if (!fibers.has(fiber)) - return; - fibers.delete(fiber); - if (semaphore) - yield* semaphore.release(1); - if (fibers.size === 0) - yield* doneLatch.open; - if (isSuccess2(halt)) - return; - return yield* failCause4(queue, cause); - })), forkChild2); - doneLatch.closeUnsafe(); - fibers.add(fiber); - } - }).pipe(catchCause2((cause) => { - const halt = filterDone(cause); - if (isSuccess2(halt)) { - return doneLatch.whenOpen(failCause4(queue, cause)); } - return failCause4(queue, cause); - }), forkIn2(forkedScope)); - return take2(queue); -}))); -var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { - const strategy = options?.haltStrategy ?? "both"; - const queue = yield* bounded(0); - yield* addFinalizer2(forkedScope, shutdown(queue)); - let done = 0; - function onExit(side, cause) { - done++; - if (!isDoneCause(cause)) { - return failCause4(queue, cause); + if (hasOptional && rest.length > 1) { + throw new Error("A required element cannot follow an optional element. ts(1257)"); } - switch (strategy) { - case "both": { - return done === 2 ? failCause4(queue, cause) : void_3; - } - case "left": - case "right": { - return side === strategy ? failCause4(queue, cause) : void_3; - } - case "either": { - return failCause4(queue, cause); + for (let i = 1;i < rest.length; i++) { + if (isOptional(rest[i])) { + throw new Error("An optional element cannot follow a rest element. ts(1266)"); } } } - const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); - yield* runSide("left", left, forkUnsafe2(forkedScope)); - yield* runSide("right", right, forkUnsafe2(forkedScope)); - return take2(queue); -}))); -var mergeEffect = /* @__PURE__ */ dual(2, (self, effect) => merge2(self, fromEffectDrain(effect), { - haltStrategy: "left" -})); -var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { - let stringBuilder = ""; - let midCRLF = false; - let done = none2(); - function splitLinesArray(chunk) { - const chunkBuilder = []; - function pushLine(segment) { - if (stringBuilder.length === 0) { - chunkBuilder.push(segment); - } else { - chunkBuilder.push(stringBuilder + segment); - stringBuilder = ""; + getParser(compile, compileField = compile) { + const ast = this; + let elements; + let rest; + const elementLen = ast.elements.length; + const tailLen = Math.max(0, ast.rest.length - 1); + function getParser(tailThreshold, index) { + if (index < elementLen) { + return elements[index]; + } else if (index >= tailThreshold) { + return rest[index - tailThreshold + 1]; } + return rest[0]; } - for (let i = 0;i < chunk.length; i++) { - const str = chunk[i]; - if (str.length !== 0) { - let from = 0; - let indexOfCR = str.indexOf("\r"); - let indexOfLF = str.indexOf(` -`); - if (midCRLF) { - if (indexOfLF === 0) { - from = 1; - indexOfLF = str.indexOf(` -`, from); - } - midCRLF = false; - } - while (indexOfCR !== -1 || indexOfLF !== -1) { - if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { - pushLine(str.substring(from, indexOfLF)); - from = indexOfLF + 1; - indexOfLF = str.indexOf(` -`, from); + return fnUntracedEager2(function* (input, options) { + if (input === missing) { + return missing; + } + if (!Array.isArray(input)) { + return yield* fail6(new InvalidType(ast, input, options)); + } + if (!elements) { + elements = ast.elements.map((ast) => ({ + ast, + parser: compileField(ast) + })); + rest = ast.rest.map((ast) => ({ + ast, + parser: compileField(ast) + })); + } + const len = input.length; + const state = { + ast, + getParser, + input, + len, + tailThreshold: Math.max(elementLen, len - tailLen), + output: new globalThis.Array(len), + issues: undefined, + options + }; + const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen); + const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); + const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, { + concurrency, + end + }); + if (eff) + yield* eff; + if (ast.rest.length === 0 && len > elementLen) { + for (let i = elementLen;i <= len - 1; i++) { + const unexpected = new UnexpectedKey(ast, input[i], options); + const issue = new Pointer([i], unexpected); + if (options.errors === "all") { + if (state.issues) + state.issues.push(issue); + else + state.issues = [issue]; } else { - pushLine(str.substring(from, indexOfCR)); - if (str.length === indexOfCR + 1) { - midCRLF = true; - from = str.length; - indexOfCR = -1; - } else { - from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); - indexOfCR = str.indexOf("\r", from); - indexOfLF = str.indexOf(` -`, from); - } + return yield* fail6(new Composite(ast, [issue], input, options)); } } - stringBuilder = stringBuilder + str.substring(from); } - } - return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; - } - const pullOrFlush = suspend2(() => { - if (done._tag === "Some") { - return done3(done.value); - } - return matchEffect2(upstream, { - onSuccess: loop, - onFailure: failCause3, - onDone: (leftover) => { - done = some2(leftover); - if (stringBuilder.length > 0) { - const last = stringBuilder; - stringBuilder = ""; - midCRLF = false; - return succeed6([last]); - } - return done3(leftover); + if (state.issues) { + return yield* fail6(new Composite(ast, state.issues, input, options)); } + return state.output; }); - }); - function loop(chunk) { - const lines = splitLinesArray(chunk); - return lines !== null ? succeed6(lines) : pullOrFlush; } - return pullOrFlush; -})); -var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); -var unwrap = (channel) => fromTransform((upstream, scope) => { - let pull; - return succeed6(suspend2(() => { - if (pull) - return pull; - return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); - })); -}); -var runWith = (self, f, onHalt) => suspend2(() => { - const scope = makeUnsafe3(); - const makePull = toTransform(self)(done3(), scope); - return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); -}); -var runDrain = (self) => runWith(self, (pull) => forever2(pull, { - disableYield: true -})); -var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { - disableYield: true -}))); -var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { - let state = initial(); - return runWith(self, (pull) => whileLoop2({ - while: constTrue, - body: () => pull, - step: (value) => { - state = f(state, value); - } - }), () => succeed6(state)); -})); -var toPullScoped = (self, scope) => toTransform(self)(done3(), scope); - -// node_modules/effect/dist/internal/stream.js -var TypeId11 = "~effect/Stream"; -var streamVariance = { - _R: identity, - _E: identity, - _A: identity -}; -var Stream = function(channel) { - this.channel = channel; -}; -Stream.prototype = { - [TypeId11]: streamVariance, - pipe() { - return pipeArguments(this, arguments); + _rebuild(recur, checks, encodingChecks) { + const elements = mapOrSame(this.elements, recur); + const rest = mapOrSame(this.rest, recur); + return elements === this.elements && rest === this.rest && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Arrays(this.isMutable, elements, rest, this.annotations, checks, undefined, this.context, encodingChecks); } -}; -var fromChannel = (channel) => new Stream(channel); - -// node_modules/effect/dist/Sink.js -var TypeId12 = "~effect/Sink"; -var endVoid = /* @__PURE__ */ succeed6([undefined]); -var sinkVariance = { - _A: identity, - _In: identity, - _L: identity, - _E: identity, - _R: identity -}; -var SinkProto = { - [TypeId12]: sinkVariance, - pipe() { - return pipeArguments(this, arguments); + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks); + } + getExpected() { + return "array"; } }; -var isSink = (u) => hasProperty(u, TypeId12); -var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ - disableYield: true -})), catchDone(succeed6))); -var fromTransform2 = (transform) => { - const self = Object.create(SinkProto); - self.transform = transform; - return self; -}; -var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done3))); -var drain2 = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { - disableYield: true -}), () => endVoid)); -var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { - discard: true -})); -var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ - disableYield: true -}), catchDone(() => endVoid))); -var unwrap2 = (effect) => fromChannel2(unwrap(map6(effect, toChannel))); - -// node_modules/effect/dist/internal/rcRef.js -var TypeId13 = "~effect/RcRef"; -var stateEmpty = { - _tag: "Empty" +function stepArray(s, item, exit, i) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, i, exit); + } + const value = exit === sameExit ? item : exit[args]; + if (value !== missing) { + s.output[i] = value; + } else { + const p = s.getParser(s.tailThreshold, i); + if (isOptional(p.ast)) + return; + const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); + } + } +} +var parseArrayOptions = { + onItem(s, item, i) { + const value = i < s.len ? item : missing; + return s.getParser(s.tailThreshold, i).parser(value, s.options); + }, + step: stepArray }; -var stateClosed = { - _tag: "Closed" +var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); +var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); +var wrapPropertyKeyIssue = (s, ast, key, exit) => { + if (exit.cause.reasons.length === 0) { + return exit; + } + const issue = getSchemaIssue(exit.cause); + if (issue === undefined) { + return failCause2(map4(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); + } + const pointer = new Pointer([key], issue); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(pointer); + else + s.issues = [pointer]; + } else { + return fail5(new Composite(ast, [pointer], s.input, s.options)); + } }; -var variance2 = { - _A: identity, - _E: identity +var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; +function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) { + let stringKeys; + let symbolKeys; + function go(parameter) { + switch (parameter._tag) { + case "String": + case "TemplateLiteral": + return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== undefined); + case "Number": + return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== undefined); + case "Symbol": + return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== undefined); + case "Union": + return [...new Set(parameter.types.flatMap(go))]; + default: + return []; + } + } + return go(parameterFromPropertyKey(toEncoded(parameter))); +} +var PropertySignature = class { + name; + type; + constructor(name, type) { + this.name = name; + this.type = type; + } }; - -class RcRefImpl { - [TypeId13] = variance2; - pipe() { - return pipeArguments(this, arguments); +function isIndexSignatureParameterSide(ast) { + switch (ast._tag) { + case "String": + case "Number": + case "Symbol": + case "TemplateLiteral": + return true; + case "Union": + return ast.types.every(isIndexSignatureParameterSide); + default: + return false; } - state = stateEmpty; - semaphore = /* @__PURE__ */ makeUnsafe5(1); - acquire; - context; - scope; - idleTimeToLive; - constructor(acquire, context, scope, idleTimeToLive) { - this.acquire = acquire; - this.context = context; - this.scope = scope; - this.idleTimeToLive = idleTimeToLive; +} +function isIndexSignatureParameterEncodedSide(ast) { + const encoded = getLastEncoding(ast); + switch (encoded._tag) { + case "String": + case "Number": + case "Symbol": + case "TemplateLiteral": + return true; + case "Union": + return encoded.types.every(isIndexSignatureParameterEncodedSide); + default: + return false; } } -var make10 = (options) => withFiber2((fiber) => { - const context = fiber.context; - const scope = get(context, Scope); - const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive ? fromInputUnsafe(options.idleTimeToLive) : undefined); - return as2(addFinalizerExit(scope, () => { - const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; - ref.state = stateClosed; - return close2; - }), ref); -}); -var getState = (self) => uninterruptibleMask2(function loop(restore) { - switch (self.state._tag) { - case "Closed": { - return interrupt2; - } - case "Acquired": { - self.state.refCount++; - return self.state.fiber ? as2(interrupt3(self.state.fiber), self.state) : succeed6(self.state); +function isIndexSignatureParameter(ast) { + return isIndexSignatureParameterSide(ast) && isIndexSignatureParameterEncodedSide(ast); +} +var IndexSignature = class { + parameter; + type; + constructor(parameter, type) { + if (!isIndexSignatureParameter(parameter)) { + throw new Error(`Invalid index signature parameter ${parameter._tag}`); } - case "Empty": { - const scope = makeUnsafe3(); - return self.semaphore.withPermit(suspend2(() => { - if (self.state._tag !== "Empty") { - return loop(restore); - } - return restore(provideContext2(self.acquire, add(self.context, Scope, scope))).pipe(flatMap3((value) => { - if (self.state._tag === "Closed") { - return interrupt2; - } - const state = { - _tag: "Acquired", - value, - scope, - fiber: undefined, - refCount: 1, - invalidated: false - }; - self.state = state; - return succeed6(state); - }), onExit2((exit) => isFailure3(exit) ? close(scope, exit) : void_3)); - })); + this.parameter = parameter; + this.type = type; + if (isOptional(type) && !containsUndefined(type)) { + throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead."); } } -}); -var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { - const self = self_; - const state = yield* getState(self); - const scope = yield* scope2; - const isFinite2 = self.idleTimeToLive !== undefined && isFinite(self.idleTimeToLive); - yield* addFinalizerExit(scope, () => { - state.refCount--; - if (state.refCount > 0) { - return void_3; - } - if (self.idleTimeToLive === undefined || state.invalidated) { - if (self.state === state) { - self.state = stateEmpty; - } - return close(state.scope, void_2); - } else if (!isFinite2) { - return void_3; - } - state.fiber = sleep2(self.idleTimeToLive).pipe(flatMap3(() => { - if (self.state === state && state.refCount === 0) { - self.state = stateEmpty; - return close(state.scope, void_2); +}; +var Objects = class extends ASTNodeImpl { + _tag = "Objects"; + propertySignatures; + indexSignatures; + encodingChecks; + constructor(propertySignatures, indexSignatures, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.propertySignatures = propertySignatures; + this.indexSignatures = indexSignatures; + this.encodingChecks = encodingChecks; + const seen = new Set; + const duplicates = []; + for (const propertySignature of propertySignatures) { + const name = propertySignature.name; + if (seen.has(name)) { + duplicates.push(name); + } else { + seen.add(name); } - return void_3; - }), ensuring2(sync3(() => { - state.fiber = undefined; - })), runForkWith2(self.context), runIn(self.scope)); - return void_3; - }); - return state.value; -}); - -// node_modules/effect/dist/RcRef.js -var make11 = make10; -var get3 = get2; - -// node_modules/effect/dist/Stream.js -var TypeId14 = "~effect/Stream"; -var isStream = (u) => hasProperty(u, TypeId14); -var fromChannel3 = fromChannel; -var fromEffect2 = (effect) => fromChannel3(fromEffect(map6(effect, of))); -var fromPull2 = (pull) => fromChannel3(fromPull(pull)); -var transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))); -var toChannel2 = (stream) => stream.channel; -var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); -var empty4 = /* @__PURE__ */ fromChannel3(empty3); -var succeed8 = (value) => fromChannel3(succeed7(of(value))); -var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); -var fromArray2 = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel3(succeed7(array)) : empty4; -var unwrap3 = (effect) => fromChannel3(unwrap(map6(effect, toChannel2))); -var map8 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { - let i = 0; - return fromChannel3(map7(self.channel, map2((o) => f(o, i++)))); -})); -var flatMap5 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options) => self.channel.pipe(flattenArray, flatMap4((a) => f(a).channel, options), fromChannel3)); -var flatten4 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => flatMap5(self, identity, options)); -var drain3 = (self) => fromChannel3(drain(self.channel)); -var concat = /* @__PURE__ */ dual(2, (self, that) => flatten4(fromArray2([self, that]))); -var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); -var mergeEffect2 = /* @__PURE__ */ dual(2, (self, effect) => self.channel.pipe(mergeEffect(effect), fromChannel3)); -var mapError4 = /* @__PURE__ */ dual(2, (self, f) => fromChannel3(mapError3(self.channel, f))); -var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { - let done; - let leftover; - const upstreamWithLeftover = suspend2(() => { - if (leftover !== undefined) { - const chunk = leftover; - leftover = undefined; - return succeed6(chunk); } - return upstream; - }).pipe(catch_2((error) => { - done = fail4(error); - return done3(); - })); - const pull = map6(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { - leftover = leftover_; - return of(value); - }); - return suspend2(() => done ? done : pull); -}))); -var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { - const decoder = new TextDecoder(options?.encoding); - return map8(self, (chunk) => decoder.decode(chunk, { - stream: true - })); -})); -var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); -var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map6(([a]) => a)))); -var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { - for (let i = 0;i < chunk.length; i++) { - acc.push(chunk[i]); - } - return acc; -}); -var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channel, initial, (acc, arr) => { - for (let i = 0;i < arr.length; i++) { - acc = f(acc, arr[i]); - } - return acc; -})); -var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => { - let i = 0; - return whileLoop2({ - while: () => i < arr.length, - body: () => f(arr[i++]), - step: constVoid - }); -})); -var runDrain2 = (self) => runDrain(self.channel); -var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); - -// node_modules/effect/dist/FileSystem.js -var TypeId15 = "~effect/FileSystem"; -var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); -var make12 = (impl) => FileSystem.of({ - ...impl, - [TypeId15]: TypeId15, - exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), - readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ - try: () => new TextDecoder(encoding).decode(_), - catch: (cause) => badArgument({ - module: "FileSystem", - method: "readFileString", - description: "invalid encoding", - cause - }) - })), - stream: fnUntraced2(function* (path, options) { - const file = yield* impl.open(path, { - flag: "r" - }); - const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset); - if (offset) { - yield* file.seek(offset, "start"); + if (duplicates.length > 0) { + throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); } - const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead); - let totalBytesRead = BigInt(0); - const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024)); - const readChunk = file.readAlloc(chunkSize); - return fromPull2(succeed6(flatMap3(suspend2(() => { - if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { - return done3(); - } - return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; - }), match({ - onNone: () => done3(), - onSome: (buf) => { - totalBytesRead += BigInt(buf.length); - return succeed6(of(buf)); - } - })))); - }, unwrap3), - sink: (path, options) => pipe(impl.open(path, { - ...options, - flag: options?.flag ?? "w" - }), map6((file) => forEach3((_) => file.writeAll(_))), unwrap2), - writeFileString: (path, data, options) => flatMap3(try_2({ - try: () => new TextEncoder().encode(data), - catch: (cause) => badArgument({ - module: "FileSystem", - method: "writeFileString", - description: "could not encode string", - cause - }) - }), (_) => impl.writeFile(path, _, options)) -}); -var FileTypeId = "~effect/FileSystem/File"; -class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBackend")) { -} -// node_modules/effect/dist/internal/matcher.js -var TypeId16 = "~effect/Match/Matcher"; -var TypeMatcherProto = { - [TypeId16]: { - _input: identity, - _filters: identity, - _remaining: identity, - _result: identity, - _return: identity, - _args: identity - }, - _tag: "TypeMatcher", - add(_case) { - return makeTypeMatcher(this.select, [...this.cases, _case]); - }, - pipe() { - return pipeArguments(this, arguments); } -}; -function makeTypeMatcher(select, cases) { - const matcher = Object.create(TypeMatcherProto); - matcher.select = select; - matcher.cases = cases; - return matcher; -} -var ValueMatcherProto = { - [TypeId16]: { - _input: identity, - _filters: identity, - _result: identity, - _return: identity, - _flavor: identity - }, - _tag: "ValueMatcher", - add(_case) { - if (isSuccess2(this.value)) { - return this; + getParser(compile, compileField = compile) { + const ast = this; + const expectedKeys = []; + for (const ps of ast.propertySignatures) { + expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name); } - if (_case._tag === "When" && _case.guard(this.provided) === true) { - return makeValueMatcher(this.provided, succeed2(_case.evaluate(this.provided))); - } else if (_case._tag === "Not" && _case.guard(this.provided) === false) { - return makeValueMatcher(this.provided, succeed2(_case.evaluate(this.provided))); + const hasProperties = expectedKeys.length; + const indexCount = ast.indexSignatures.length; + let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : undefined; + if (!hasProperties && !indexCount) { + return fromRefinement(ast, isNotNullish); } - return this; - }, - pipe() { - return pipeArguments(this, arguments); - } -}; -function makeValueMatcher(provided, value) { - const matcher = Object.create(ValueMatcherProto); - matcher.provided = provided; - matcher.value = value; - return matcher; -} -var makeWhen = (guard, evaluate) => ({ - _tag: "When", - guard, - evaluate -}); -var value = (i) => makeValueMatcher(i, fail2(i)); -var discriminator = (field) => (...pattern) => { - const f = pattern[pattern.length - 1]; - const values = pattern.slice(0, -1); - const pred = values.length === 1 ? (_) => _ != null && _[field] === values[0] : (_) => _ != null && values.includes(_[field]); - return (self) => self.add(makeWhen(pred, f)); -}; -var tag = /* @__PURE__ */ discriminator("_tag"); -var result2 = (self) => { - if (self._tag === "ValueMatcher") { - return self.value; - } - const len = self.cases.length; - if (len === 1) { - const _case = self.cases[0]; - return (...args) => { - const input = self.select(...args); - if (_case._tag === "When" && _case.guard(input) === true) { - return succeed2(_case.evaluate(input, ...args)); - } else if (_case._tag === "Not" && _case.guard(input) === false) { - return succeed2(_case.evaluate(input, ...args)); + let properties; + let indexes; + const finishIndex = (s, key, k2, inputValue, exitValue) => { + if (exitValue._tag === "Failure") { + return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_2; } - return fail2(input); + const value = exitValue === sameExit ? inputValue : exitValue[args]; + if (k2 !== missing && value !== missing) { + if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) + return void_2; + assignProperty(s.out, k2, value); + } + return void_2; }; - } - return (...args) => { - const input = self.select(...args); - for (let i = 0;i < len; i++) { - const _case = self.cases[i]; - if (_case._tag === "When" && _case.guard(input) === true) { - return succeed2(_case.evaluate(input, ...args)); - } else if (_case._tag === "Not" && _case.guard(input) === false) { - return succeed2(_case.evaluate(input, ...args)); + const parseIndex = (s, key, index, exitKey) => { + if (!exitKey) { + const eff = index.parserKey(key, s.options); + if (!effectIsExit(eff)) { + return flatMap3(exit2(eff), (exit) => parseIndex(s, key, index, exit)); + } + exitKey = eff; } - } - return fail2(input); - }; -}; -var getExhaustiveAbsurdErrorMessage = "effect/match/Match/exhaustive: absurd"; -var exhaustive = (self) => { - const toResult = result2(self); - if (isResult2(toResult)) { - if (isSuccess2(toResult)) { - return toResult.success; - } - throw new Error(getExhaustiveAbsurdErrorMessage); - } - return (...args) => { - const result = toResult(...args); - if (isSuccess2(result)) { - return result.success; - } - throw new Error(getExhaustiveAbsurdErrorMessage); - }; -}; - -// node_modules/effect/dist/Match.js -var value2 = value; -var tag2 = tag; -var exhaustive2 = exhaustive; -// node_modules/effect/dist/Ref.js -var TypeId17 = "~effect/Ref"; -var RefProto = { - [TypeId17]: { - _A: identity - }, - ...PipeInspectableProto, - toJSON() { - return { - _id: "Ref", - ref: this.ref + if (exitKey._tag === "Failure") { + return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_2; + } + const k2 = exitKey === sameExit ? key : exitKey[args]; + const inputValue = s.input[key]; + const result = index.parserValue(inputValue, s.options); + return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, k2, inputValue, exit)); }; - } -}; -var makeUnsafe6 = (value) => { - const self = Object.create(RefProto); - self.ref = make7(value); - return self; -}; -var make13 = (value) => sync3(() => makeUnsafe6(value)); -var get4 = (self) => sync3(() => self.ref.current); -var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { - self.ref.current = f(self.ref.current); -})); -// node_modules/effect/dist/internal/schema/annotations.js -function resolve(ast) { - return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; -} -var STRUCTURAL_ANNOTATION_KEY = "~structural"; -var SENTINELS_ANNOTATION_KEY = "~sentinels"; -var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; -var getExpected = /* @__PURE__ */ memoize((ast) => { - const identifier = resolve(ast)?.identifier; - if (typeof identifier === "string") - return identifier; - return ast.getExpected(getExpected); -}); - -// node_modules/effect/dist/internal/schema/parser.js -var missing = /* @__PURE__ */ Symbol(); -var succeed9 = succeed4; -var missingExit = /* @__PURE__ */ succeed9(missing); -var sameExit = /* @__PURE__ */ succeed9(missing); -var toOption = (value) => value === missing ? none2() : some2(value); -var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed9(option.value); - -// node_modules/effect/dist/SchemaIssue.js -var TypeId18 = "~effect/SchemaIssue/Issue"; -function isIssue(u) { - return hasProperty(u, TypeId18) && u[TypeId18] === TypeId18; -} -function hasInput(issue) { - return Object.hasOwn(issue, "input"); -} - -class IssueNodeImpl { - [TypeId18] = TypeId18; - constructor(input, options) { - if (options?.reportInput === true && input !== missing) { - this.input = input; - } - } -} -var Filter = class extends IssueNodeImpl { - _tag = "Filter"; - filter; - issue; - constructor(filter, issue, input, options) { - super(input, options); - this.filter = filter; - this.issue = issue; - } -}; -var Encoding = class extends IssueNodeImpl { - _tag = "Encoding"; - ast; - issue; - constructor(ast, issue, input, options) { - super(input, options); - this.ast = ast; - this.issue = issue; - } -}; -var Pointer = class extends IssueNodeImpl { - _tag = "Pointer"; - path; - issue; - constructor(path, issue) { - super(); - this.path = path; - this.issue = issue; - } -}; -var MissingKey = class extends IssueNodeImpl { - _tag = "MissingKey"; - annotations; - constructor(annotations) { - super(); - this.annotations = annotations; - } -}; -var UnexpectedKey = class extends IssueNodeImpl { - _tag = "UnexpectedKey"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; - } -}; -var Composite = class extends IssueNodeImpl { - _tag = "Composite"; - ast; - issues; - constructor(ast, issues, input, options) { - super(input, options); - this.ast = ast; - this.issues = issues; - } -}; -var InvalidType = class extends IssueNodeImpl { - _tag = "InvalidType"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; - } -}; -var InvalidValue = class extends IssueNodeImpl { - _tag = "InvalidValue"; - annotations; - constructor(annotations, input, options) { - super(input, options); - this.annotations = annotations; - } -}; -var AnyOf = class extends IssueNodeImpl { - _tag = "AnyOf"; - ast; - issues; - constructor(ast, issues, input, options) { - super(input, options); - this.ast = ast; - this.issues = issues; - } -}; -var OneOf = class extends IssueNodeImpl { - _tag = "OneOf"; - ast; - successes; - constructor(ast, successes, input, options) { - super(input, options); - this.ast = ast; - this.successes = successes; - } -}; -function makeFilterIssue(entry, input, options) { - if (isIssue(entry)) { - return entry; - } - if (typeof entry === "string") { - return new InvalidValue({ - message: entry - }, input, options); - } - const inner = typeof entry.issue === "string" ? new InvalidValue({ - message: entry.issue - }, input, options) : entry.issue; - return new Pointer(entry.path, inner); -} -function makeSingle(out, input, options) { - if (out === undefined) { - return; - } - if (typeof out === "boolean") { - return out ? undefined : new InvalidValue(undefined, input, options); - } - return makeFilterIssue(out, input, options); -} -function normalizeFilterOutput(ast, out, input, options) { - if (Array.isArray(out)) { - if (!isReadonlyArrayNonEmpty(out)) { - return; - } - return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map2(out, (entry) => makeFilterIssue(entry, input, options)), input, options); - } - return makeSingle(out, input, options); -} -var defaultLeafHook = (issue) => { - const message = findMessage(issue); - if (message !== undefined) - return message; - switch (issue._tag) { - case "InvalidType": - return getExpectedMessage(getExpected(issue.ast), issue); - case "InvalidValue": { - const expected = findExpected(issue); - if (expected !== undefined) - return getExpectedMessage(expected, issue); - const input = formatInput(issue); - return input === undefined ? "Expected a valid value" : `Invalid data ${input}`; - } - case "MissingKey": - return "Missing key"; - case "UnexpectedKey": { - const input = formatInput(issue); - return input === undefined ? "Expected no excess property" : `Unexpected key with value ${input}`; - } - case "Forbidden": - return "Forbidden operation"; - case "OneOf": { - const input = formatInput(issue); - return input === undefined ? "Expected exactly one member to match" : `Expected exactly one member to match the input ${input}`; - } - } -}; -var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue); -function formatInput(issue) { - return hasInput(issue) ? format(issue.input) : undefined; -} -function findExpected(issue) { - const expected = issue.annotations?.expected; - return typeof expected === "string" ? expected : undefined; -} -function getExpectedMessage(expected, issue) { - const input = formatInput(issue); - return input === undefined ? `Expected ${expected}` : `Expected ${expected}, got ${input}`; -} -function formatCheck(check) { - const expected = check.annotations?.expected; - if (typeof expected === "string") - return expected; - switch (check._tag) { - case "Filter": - return ""; - case "FilterGroup": - return check.checks.map((check) => formatCheck(check)).join(" & "); - } -} -function makeFormatterDefault() { - return (issue) => formatIssue(issue, ""); -} -var defaultFormatter = /* @__PURE__ */ makeFormatterDefault(); -function formatIssue(issue, path) { - let message; - switch (issue._tag) { - case "Filter": { - const annotated = defaultCheckHook(issue); - if (annotated !== undefined) { - message = annotated; - } else { - if (issue.issue._tag !== "InvalidValue") { - return formatIssue(issue.issue, path); - } - const expected = findExpected(issue.issue); - message = expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue); + const parseStringIndex = (s, key, index) => { + const inputValue = s.input[key]; + const result = index.parserValue(inputValue, s.options); + return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, key, inputValue, exit)); + }; + const parseIndexes = indexCount ? iterateConcurrent()({ + onItem: (s, [key, index]) => index.is.parameter === string2 ? parseStringIndex(s, key, index) : parseIndex(s, key, index), + step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined + }) : undefined; + const compileMembers = () => { + if (!properties) { + properties = ast.propertySignatures.map((ps) => ({ + parser: compileField(ps.type), + name: ps.name, + type: ps.type + })); + indexes = indexCount ? ast.indexSignatures.map((is) => ({ + is, + parserKey: compile(parameterFromPropertyKey(is.parameter)), + parserValue: compileField(is.type) + })) : undefined; } - break; - } - case "Encoding": - return formatIssue(issue.issue, path); - case "Pointer": - return formatIssue(issue.issue, path + formatPath(issue.path)); - case "Composite": - case "AnyOf": { - if (issue._tag === "Composite" || issue.issues.length > 0) { - return issue.issues.map((issue) => formatIssue(issue, path)).join(` -`); + return properties; + }; + const fallback = fnUntracedEager2(function* (input, options) { + if (input === missing) { + return missing; } - message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue); - break; - } - default: - message = defaultLeafHook(issue); - break; - } - return path ? `${message} - at ${path}` : message; -} -function findMessage(issue) { - if (issue._tag === "Pointer") - return; - if (issue._tag === "Encoding") - return findMessage(issue.issue); - const annotations = issue._tag === "Filter" ? issue.filter.annotations : ("annotations" in issue) ? issue.annotations : issue.ast.annotations; - const message = annotations?.[issue._tag === "MissingKey" ? "messageMissingKey" : issue._tag === "UnexpectedKey" ? "messageUnexpectedKey" : "message"]; - if (typeof message === "string") - return message; -} - -// node_modules/effect/dist/internal/schema/cause.js -function getSchemaIssue(cause) { - let issue; - for (const reason of cause.reasons) { - if (!isFailReason2(reason) || !isIssue(reason.error)) { - return; - } - issue ??= reason.error; - } - return issue; -} -function getSchemaIssueOrThrow(cause, message) { - const issue = getSchemaIssue(cause); - if (issue === undefined) { - throw new Error(message, { - cause - }); - } - return issue; -} - -// node_modules/effect/dist/SchemaGetter.js -var Getter = class extends Class { - run; - constructor(run) { - super(); - this.run = run; - } - map(f) { - return new Getter((oe, options) => this.run(oe, options).pipe(mapEager2(map(f)))); - } - compose(other) { - if (isPassthrough(this)) { - return other; - } - if (isPassthrough(other)) { - return this; - } - return new Getter((oe, options) => this.run(oe, options).pipe(flatMapEager2((ot) => other.run(ot, options)))); - } -}; -var passthrough_ = /* @__PURE__ */ new Getter(succeed6); -function isPassthrough(getter) { - return getter.run === passthrough_.run; -} -function passthrough() { - return passthrough_; -} -function onSome(f) { - return new Getter((oe, options) => isNone2(oe) ? succeedNone2 : f(oe.value, options)); -} -function transform(f) { - return transformOptional(map(f)); -} -function transformEffect(f) { - return onSome((e, options) => f(e, options).pipe(mapEager2(some2))); -} -function transformOptional(f) { - return new Getter((oe) => succeed6(f(oe))); -} -function withDefault(defaultValue) { - return new Getter((o) => { - const filtered = filter(o, isNotUndefined); - return isSome2(filtered) ? succeed6(filtered) : mapEager2(defaultValue, some2); - }); -} -function String2() { - return transform(globalThis.String); -} -function Number3() { - return transform(globalThis.Number); -} -function parseJson(options) { - return onSome((input, parseOptions) => try_2({ - try: () => some2(JSON.parse(input, options?.reviver)), - catch: () => new InvalidValue({ - expected: "a valid JSON string" - }, input, parseOptions) - })); -} -function stringifyJson(options) { - return onSome((input, parseOptions) => try_2({ - try: () => { - const output = JSON.stringify(input, options?.replacer, options?.space); - if (output === undefined) { - throw new TypeError("Value cannot be represented as JSON"); + if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { + return yield* fail6(new InvalidType(ast, input, options)); } - return some2(output); - }, - catch: () => new InvalidValue({ - expected: "a JSON-serializable value" - }, input, parseOptions) - })); -} -function encodeBase642() { - return transform(encodeBase64); -} -function decodeBase642() { - return transformEffect((input, options) => mapErrorEager2(fromResult2(decodeBase64(input)), () => new InvalidValue({ - expected: "a valid Base64 string" - }, input, options))); -} - -// node_modules/effect/dist/SchemaTransformation.js -var TypeId19 = "~effect/SchemaTransformation/Transformation"; -var Transformation = class { - [TypeId19] = TypeId19; - _tag = "Transformation"; - decode; - encode; - constructor(decode, encode) { - this.decode = decode; - this.encode = encode; - } - flip() { - return new Transformation(this.encode, this.decode); - } - compose(other) { - return new Transformation(this.decode.compose(other.decode), other.encode.compose(this.encode)); - } -}; -function isTransformation(u) { - return hasProperty(u, TypeId19) && u[TypeId19] === TypeId19; -} -var make14 = (options) => { - if (isTransformation(options)) { - return options; - } - return new Transformation(options.decode, options.encode); -}; -function transformEffect2(options) { - return new Transformation(transformEffect(options.decode), transformEffect(options.encode)); -} -function transform2(options) { - return new Transformation(transform(options.decode), transform(options.encode)); -} -var passthrough_2 = /* @__PURE__ */ new Transformation(/* @__PURE__ */ passthrough(), /* @__PURE__ */ passthrough()); -function passthrough2() { - return passthrough_2; -} -var numberFromString = /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ String2()); -var isJsonError = (input) => isObject(input) && typeof input["message"] === "string"; -var decodeJsonError = (input) => { - const hasCause = Object.hasOwn(input, "cause"); - const err = hasCause ? new Error(input.message, { - cause: decodeDefect(input.cause) - }) : new Error(input.message); - if (typeof input.name === "string" && input.name !== "Error") - err.name = input.name; - if (typeof input.stack === "string") - err.stack = input.stack; - return err; -}; -var encodeUnknownAsJson = (input) => { - try { - const json = formatJson(input); - return json === undefined ? format(input) : JSON.parse(json); - } catch { - return format(input); - } -}; -var encodeJsonError = (input, options, encodeDefect) => { - const encoded = { - name: input.name, - message: typeof input.message === "string" ? input.message : "" - }; - if (options?.includeStack && typeof input.stack === "string") { - encoded.stack = input.stack; - } - if (!options?.excludeCause && input.cause !== undefined) { - encoded.cause = encodeDefect(input.cause); - } - return encoded; -}; -var makeEncodeDefect = (options) => { - const seen = new WeakSet; - const encode = (input) => { - if (isError(input)) { - if (seen.has(input)) { - return "[Circular]"; + compileMembers(); + const record = input; + const out = {}; + const state = { + ast, + input: record, + out, + issues: undefined, + options + }; + const errorsAllOption = options.errors === "all"; + const onExcessPropertyError = options.onExcessProperty === "error"; + const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); + const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : undefined; + if (onExcessPropertyError) { + expectedKeysSet ??= new Set(expectedKeys); + const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet; + if (indexKeys) { + for (const keys of indexKeys) { + for (const key of keys) + coveredKeys.add(key); + } + } + const inputKeys = Reflect.ownKeys(record); + for (let i = 0;i < inputKeys.length; i++) { + const key = inputKeys[i]; + if (!coveredKeys.has(key)) { + const unexpected = new UnexpectedKey(ast, record[key], options); + const issue = new Pointer([key], unexpected); + if (errorsAllOption) { + if (state.issues) { + state.issues.push(issue); + } else { + state.issues = [issue]; + } + continue; + } else { + return yield* fail6(new Composite(ast, [issue], input, options)); + } + } + } } - seen.add(input); - const encoded = encodeJsonError(input, options, encode); - seen.delete(input); - return encoded; - } - return encodeUnknownAsJson(input); - }; - return encode; -}; -var decodeDefect = (input) => isJsonError(input) ? decodeJsonError(input) : input; -var defectFromJson = (options) => transform2({ - decode: decodeDefect, - encode: makeEncodeDefect(options) -}); -var urlFromString = /* @__PURE__ */ transformEffect2({ - decode: (s, options) => URL.canParse(s) ? succeed6(new URL(s)) : fail6(new InvalidValue({ - expected: "a valid URL string" - }, s, options)), - encode: (url) => succeed6(url.href) -}); -var uint8ArrayFromBase64String = /* @__PURE__ */ new Transformation(/* @__PURE__ */ decodeBase642(), /* @__PURE__ */ encodeBase642()); -function fromJsonString(options) { - return new Transformation(parseJson(options ?? {}), stringifyJson(options)); -} - -// node_modules/effect/dist/SchemaAST.js -function makeGuard(tag) { - return (ast) => ast._tag === tag; -} -var isDeclaration = /* @__PURE__ */ makeGuard("Declaration"); -var isNever2 = /* @__PURE__ */ makeGuard("Never"); -var isLiteral = /* @__PURE__ */ makeGuard("Literal"); -var isUniqueSymbol = /* @__PURE__ */ makeGuard("UniqueSymbol"); -var isArrays = /* @__PURE__ */ makeGuard("Arrays"); -var isObjects = /* @__PURE__ */ makeGuard("Objects"); -var isUnion = /* @__PURE__ */ makeGuard("Union"); -var isSuspend = /* @__PURE__ */ makeGuard("Suspend"); -var Link = class { - to; - transformation; - constructor(to, transformation) { - this.to = to; - this.transformation = transformation; - } -}; -var defaultParseOptions = {}; -var Context = class { - isOptional; - isMutable; - constructorDefault; - annotations; - constructor(isOptional, isMutable, constructorDefault = undefined, annotations = undefined) { - this.isOptional = isOptional; - this.isMutable = isMutable; - this.constructorDefault = constructorDefault; - this.annotations = annotations; - } -}; -var TypeId20 = "~effect/Schema"; - -class ASTNodeImpl { - [TypeId20] = TypeId20; - annotations; - checks; - encoding; - context; - constructor(annotations = undefined, checks = undefined, encoding = undefined, context = undefined) { - this.annotations = annotations; - this.checks = checks; - this.encoding = encoding; - this.context = context; - } - toString() { - return `<${this._tag}>`; - } -} -var Declaration = class extends ASTNodeImpl { - _tag = "Declaration"; - typeParameters; - run; - encodingChecks; - encodingRun; - constructor(typeParameters, run, annotations, checks, encoding, context, encodingChecks, encodingRun) { - super(annotations, checks, encoding, context); - this.typeParameters = typeParameters; - this.run = run; - this.encodingChecks = encodingChecks; - this.encodingRun = encodingRun; - } - getParser() { - let run; + if (hasProperties) { + const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { + concurrency + }); + if (eff) + yield* eff; + } + if (indexCount && concurrency === 1) { + for (let i = 0;i < indexCount; i++) { + const index = indexes[i]; + const parse = index.is.parameter === string2 ? parseStringIndex : parseIndex; + const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); + for (let j = 0;j < keys.length; j++) { + const eff = parse(state, keys[j], index); + if (!effectIsExit(eff)) + yield* eff; + else if (eff._tag === "Failure") + return yield* eff; + } + } + } else if (parseIndexes) { + const keyPairs = empty(); + for (let i = 0;i < indexCount; i++) { + const index = indexes[i]; + const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); + for (let j = 0;j < keys.length; j++) { + keyPairs.push([keys[j], index]); + } + } + const eff = parseIndexes(state, keyPairs, { + concurrency + }); + if (eff) + yield* eff; + } + if (state.issues) { + return yield* fail6(new Composite(ast, state.issues, input, options)); + } + return out; + }); + if (indexCount) + return fallback; + const resume = (state, index, pending) => { + const property = properties[index]; + return flatMap3(exit2(pending), (exit) => { + const terminal = stepProperty(state, property, exit); + if (terminal) + return terminal; + const done = () => succeed7(state.out); + const eff = parseProperties(state, properties.slice(index + 1)); + return eff ? flatMapEager2(eff, done) : done(); + }); + }; return (input, options) => { if (input === missing) return missingExit; - return (run ??= this.run(this.typeParameters))(input, this, options); - }; - } - _rebuild(recur, checks, encodingChecks, run, encodingRun) { - const tps = mapOrSame(this.typeParameters, recur); - return tps === this.typeParameters && checks === this.checks && encodingChecks === this.encodingChecks && run === this.run && encodingRun === this.encodingRun ? this : new Declaration(tps, run, this.annotations, checks, undefined, this.context, encodingChecks, encodingRun); - } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks, this.run, this.encodingRun); - } - flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks, this.encodingRun ?? this.run, this.run); - } - getExpected() { - const expected = this.annotations?.expected; - if (typeof expected === "string") - return expected; - return ""; - } -}; -var Unknown = class extends ASTNodeImpl { - _tag = "Unknown"; - getParser() { - return fromRefinement(this, isUnknown); - } - getExpected() { - return "unknown"; - } -}; -var unknown = /* @__PURE__ */ new Unknown; -var Literal = class extends ASTNodeImpl { - _tag = "Literal"; - literal; - constructor(literal, annotations, checks, encoding, context) { - super(annotations, checks, encoding, context); - if (typeof literal === "number" && !globalThis.Number.isFinite(literal)) { - throw new Error(`A numeric literal must be finite, got ${format(literal)}`); - } - this.literal = literal; - } - getParser() { - return fromConst(this, this.literal); - } - matchPart(s, _options) { - return s === globalThis.String(this.literal) ? this.literal : undefined; - } - toCodecJson() { - return typeof this.literal === "bigint" ? literalToString(this) : this; - } - toCodecStringTree() { - return typeof this.literal === "string" ? this : literalToString(this); + if (options.errors === "all" || options.onExcessProperty !== undefined || options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1) { + return fallback(input, options); + } + if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { + return fail6(new InvalidType(ast, input, options)); + } + const props = compileMembers(); + const record = input; + const out = {}; + const state = { + ast, + input: record, + out, + issues: undefined, + options + }; + try { + for (let index = 0;index < props.length; index++) { + const property = props[index]; + const name = property.name; + const hasKey = hasPropertySignature(record, name); + const value = hasKey ? record[name] : missing; + const exit = property.parser(value, options); + if (!effectIsExit(exit)) { + return resume(state, index, exit); + } + if (exit === sameExit) { + if (hasKey) + assignProperty(out, name, value); + continue; + } + const terminal = stepProperty(state, property, exit); + if (terminal) + return terminal; + } + } catch (error) { + return die3(error); + } + return succeed7(out); + }; } - getExpected() { - return typeof this.literal === "string" ? JSON.stringify(this.literal) : globalThis.String(this.literal); + _rebuild(recur, recurParameter, checks, encodingChecks) { + const props = mapOrSame(this.propertySignatures, (ps) => { + const t = recur(ps.type); + return t === ps.type ? ps : new PropertySignature(ps.name, t); + }); + const indexes = mapOrSame(this.indexSignatures, (is) => { + const p = recurParameter(is.parameter); + const t = recur(is.type); + return p === is.parameter && t === is.type ? is : new IndexSignature(p, t); + }); + return props === this.propertySignatures && indexes === this.indexSignatures && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Objects(props, indexes, this.annotations, checks, undefined, this.context, encodingChecks); } -}; -function literalToString(ast) { - const literalAsString = globalThis.String(ast.literal); - return replaceEncoding(ast, [new Link(new Literal(literalAsString), new Transformation(transform(() => ast.literal), transform(() => literalAsString)))]); -} -var String3 = class extends ASTNodeImpl { - _tag = "String"; - getParser() { - return fromRefinement(this, isString); + flip(recur) { + return this._rebuild(recur, recur, this.encodingChecks, this.checks); } - matchPart(s, options) { - const checks = this.checks; - return checks && !options.disableChecks && collectIssues(checks, s, undefined, this, options) ? undefined : s; + recur(recur, recurParameter = recur) { + return this._rebuild(recur, recurParameter, this.checks, this.encodingChecks); } getExpected() { - return "string"; + if (this.propertySignatures.length === 0 && this.indexSignatures.length === 0) + return "object | array"; + return "object"; } }; -var string2 = /* @__PURE__ */ new String3; -var Number4 = class extends ASTNodeImpl { - _tag = "Number"; - getParser() { - return fromRefinement(this, isNumber); - } - matchKey(s, options) { - return this._match(isStringNumberRegExp, s, options); +function stepProperty(s, p, exit) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, p.name, exit); } - matchPart(s, options) { - return this._match(isStringFiniteRegExp, s, options); + if (exit === sameExit) + return; + const value = exit[args]; + if (value !== missing) { + assignProperty(s.out, p.name, value); + return; } - _match(regexp, s, options) { - if (!regexp.test(s)) + delete s.out[p.name]; + if (!isOptional(p.type)) { + const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; return; - const value = globalThis.Number(s); - if (options.disableChecks || !this.checks) - return value; - return collectIssues(this.checks, value, undefined, this, options) ? undefined : value; - } - toCodecJson() { - if (this.checks && (hasCheck(this.checks, "effect/schema/isFinite") || hasCheck(this.checks, "effect/schema/isInt"))) { - return this; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); } - return replaceEncoding(this, [numberToJson]); } - toCodecStringTree() { - if (this.toCodecJson() === this) { - return replaceEncoding(this, [finiteToString]); +} +var parsePropertiesOptions = { + onItem(s, p) { + if (!hasPropertySignature(s.input, p.name)) { + return p.parser(missing, s.options); } - return replaceEncoding(this, [numberToString]); - } - getExpected() { - return "number"; - } + const value = s.input[p.name]; + assignProperty(s.out, p.name, value); + return p.parser(value, s.options); + }, + step: stepProperty }; -function hasCheck(checks, id) { - return checks.some((check) => check.annotations?.representation?.id === id || check._tag === "FilterGroup" && hasCheck(check.checks, id)); +var parseProperties = /* @__PURE__ */ iterateEager()(parsePropertiesOptions); +var parsePropertiesConcurrent = /* @__PURE__ */ iterateConcurrent()(parsePropertiesOptions); +function combineChecks(a, b) { + if (!a) + return b; + if (!b) + return a; + return [...a, ...b]; } -var number2 = /* @__PURE__ */ new Number4; -var Boolean = class extends ASTNodeImpl { - _tag = "Boolean"; - getParser() { - return fromRefinement(this, isBoolean); +function struct(fields, checks, annotations) { + return new Objects(Reflect.ownKeys(fields).map((key) => { + return new PropertySignature(key, fields[key].ast); + }), [], annotations, checks); +} +function getAST(self) { + return self.ast; +} +function tuple(elements, checks = undefined) { + return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks); +} +function union(members, options, checks) { + return new Union(members.map(getAST), options, undefined, checks); +} +var toCandidate = /* @__PURE__ */ memoizeIdempotent((ast) => { + while (true) { + if (isSuspend(ast)) + return unknown; + const encoding = ast.encoding; + if (!encoding) { + return ast.recur?.(toCandidate, identity) ?? ast; + } + if (encoding.some((link) => link.transformation._tag === "Middleware" && link.transformation.decode !== identity)) + return unknown; + ast = encoding[encoding.length - 1].to; } - getExpected() { - return "boolean"; +}); +function getCandidateTypes(ast) { + switch (ast._tag) { + case "Null": + return ["null"]; + case "Undefined": + return ["undefined"]; + case "String": + case "TemplateLiteral": + return ["string"]; + case "Number": + return ["number"]; + case "Boolean": + return ["boolean"]; + case "Symbol": + case "UniqueSymbol": + return ["symbol"]; + case "BigInt": + return ["bigint"]; + case "Arrays": + return ["array"]; + case "ObjectKeyword": + return ["object", "array", "function"]; + case "Objects": + return ast.propertySignatures.length || ast.indexSignatures.length ? ["object"] : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; + case "Enum": + return Array.from(new Set(ast.enums.map(([, v]) => typeof v))); + case "Literal": + return [typeof ast.literal]; + case "Union": + return Array.from(new Set(ast.types.flatMap(getCandidateTypes))); + default: + return ["null", "undefined", "string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; } -}; -var boolean = /* @__PURE__ */ new Boolean; -var Arrays = class extends ASTNodeImpl { - _tag = "Arrays"; - isMutable; - elements; - rest; - encodingChecks; - constructor(isMutable, elements, rest, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.isMutable = isMutable; - this.elements = elements; - this.rest = rest; - this.encodingChecks = encodingChecks; - let hasOptional = false; - for (let i = 0;i < elements.length; i++) { - if (isOptional(elements[i])) { - hasOptional = true; - } else if (hasOptional) { - throw new Error("A required element cannot follow an optional element. ts(1257)"); +} +function collectSentinels(ast) { + switch (ast._tag) { + default: + return []; + case "Declaration": { + const s = ast.annotations?.[SENTINELS_ANNOTATION_KEY]; + return Array.isArray(s) ? s : []; + } + case "Objects": + return ast.propertySignatures.flatMap((ps) => { + const type = ps.type; + if (!isOptional(type)) { + if (isLiteral(type)) { + return [{ + key: ps.name, + literal: type.literal + }]; + } + if (isUniqueSymbol(type)) { + return [{ + key: ps.name, + literal: type.symbol + }]; + } + } + return []; + }); + case "Arrays": + return ast.elements.flatMap((e, i) => { + if (!isOptional(e)) { + if (isLiteral(e)) { + return [{ + key: i, + literal: e.literal + }]; + } + if (isUniqueSymbol(e)) { + return [{ + key: i, + literal: e.symbol + }]; + } + } + return []; + }); + case "Union": { + if (ast.types.length === 0) + return []; + const members = ast.types.map((type) => collectSentinels(toCandidate(type))); + return members[0].filter((s) => members.every((sentinels) => sentinels.some((o) => o.key === s.key && o.literal === s.literal))); + } + case "Suspend": + return collectSentinels(ast.thunk()); + } +} +var candidateIndexCache = /* @__PURE__ */ new WeakMap; +var emptyCandidates = /* @__PURE__ */ Object.freeze([]); +var hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : (key in input); +function getIndex(types) { + let index = candidateIndexCache.get(types); + if (index) + return index; + let bySentinel; + let sentinelCandidateCount = 0; + let otherwise; + let literalCandidates; + let onlyLiterals = true; + for (let i = 0;i < types.length; i++) { + const a = types[i]; + const encoded = toCandidate(a); + if (isNever2(encoded)) + continue; + if (onlyLiterals) { + if (isLiteral(encoded) || isUniqueSymbol(encoded)) { + literalCandidates ??= new Map; + const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol; + let arr = literalCandidates.get(literal); + if (!arr) + literalCandidates.set(literal, arr = []); + arr.push(a); + } else { + onlyLiterals = false; } } - if (hasOptional && rest.length > 1) { - throw new Error("A required element cannot follow an optional element. ts(1257)"); - } - for (let i = 1;i < rest.length; i++) { - if (isOptional(rest[i])) { - throw new Error("An optional element cannot follow a rest element. ts(1266)"); + const sentinels = collectSentinels(encoded); + if (sentinels.length) { + bySentinel ??= new Map; + sentinelCandidateCount++; + for (const { + key, + literal + } of sentinels) { + let entry = bySentinel.get(key); + if (!entry) + bySentinel.set(key, entry = [new Map, new Set]); + entry[1].add(i); + let indexes = entry[0].get(literal); + if (!indexes) + entry[0].set(literal, indexes = new Set); + indexes.add(i); } + } else { + otherwise ??= {}; + const candidateTypes = getCandidateTypes(encoded); + for (const t of candidateTypes) + (otherwise[t] ??= []).push(i); } } - getParser(compile, compileConstructorDefault = compile) { - const ast = this; - let elements; - let rest; - const elementLen = ast.elements.length; - const tailLen = Math.max(0, ast.rest.length - 1); - function getParser(tailThreshold, index) { - if (index < elementLen) { - return elements[index]; - } else if (index >= tailThreshold) { - return rest[index - tailThreshold + 1]; - } - return rest[0]; + if (onlyLiterals && literalCandidates) { + literalCandidates.forEach(Object.freeze); + index = (input) => literalCandidates.get(input) ?? emptyCandidates; + } else if (bySentinel?.size === 1 && !otherwise) { + const [key, [byValue]] = bySentinel.entries().next().value; + const candidates = byValue; + for (const [literal, indexes] of byValue) { + candidates.set(literal, Object.freeze(Array.from(indexes, (index) => types[index]))); } - return fnUntracedEager2(function* (input, options) { - if (input === missing) { - return missing; + index = (input, isConstructor) => { + if (isObjectKeyword(input)) { + const value = hasPropertySignature(input, key) ? input[key] : undefined; + if (value !== undefined) + return candidates.get(value) ?? emptyCandidates; + if (isConstructor) + return types; } - if (!Array.isArray(input)) { - return yield* fail6(new InvalidType(ast, input, options)); + return emptyCandidates; + }; + } else if (bySentinel) { + let commonSentinel; + for (const entry of bySentinel) { + if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) { + commonSentinel = entry; } - if (!elements) { - elements = ast.elements.map((ast) => ({ - ast, - parser: compileConstructorDefault(ast) - })); - rest = ast.rest.map((ast) => ({ - ast, - parser: compileConstructorDefault(ast) - })); + } + index = (input, isConstructor) => { + const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; + const base = otherwise?.[runtimeType] ?? emptyCandidates; + if (!isObjectKeyword(input)) + return base.map((i) => types[i]); + const selected = new Set(base); + let directKey; + if (commonSentinel) { + const [key, [byValue]] = commonSentinel; + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + if (!match) + return base.map((i) => types[i]); + for (const i of match) + selected.add(i); + directKey = key; + } } - const len = input.length; - const state = { - ast, - getParser, - input, - len, - tailThreshold: Math.max(elementLen, len - tailLen), - output: new globalThis.Array(len), - issues: undefined, - options - }; - const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen); - const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); - const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, { - concurrency, - end - }); - if (eff) - yield* eff; - if (ast.rest.length === 0 && len > elementLen) { - for (let i = elementLen;i <= len - 1; i++) { - const unexpected = new UnexpectedKey(ast, input[i], options); - const issue = new Pointer([i], unexpected); - if (options.errors === "all") { - if (state.issues) - state.issues.push(issue); - else - state.issues = [issue]; - } else { - return yield* fail6(new Composite(ast, [issue], input, options)); + if (directKey === undefined) { + for (const [key, [byValue, all]] of bySentinel) { + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + if (match) { + for (const i of match) + selected.add(i); + } + } else if (isConstructor) { + for (const i of all) + selected.add(i); } } } - if (state.issues) { - return yield* fail6(new Composite(ast, state.issues, input, options)); - } - return state.output; - }); - } - _rebuild(recur, checks, encodingChecks) { - const elements = mapOrSame(this.elements, recur); - const rest = mapOrSame(this.rest, recur); - return elements === this.elements && rest === this.rest && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Arrays(this.isMutable, elements, rest, this.annotations, checks, undefined, this.context, encodingChecks); - } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks); - } - flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks); - } - getExpected() { - return "array"; - } -}; -var parseArrayOptions = { - onItem(s, item, i) { - const value = i < s.len ? item : missing; - return s.getParser(s.tailThreshold, i).parser(value, s.options); - }, - step(s, item, exit, i) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, i, exit); - } - const value = exit === sameExit ? item : exit[args]; - if (value !== missing) { - s.output[i] = value; - } else { - const p = s.getParser(s.tailThreshold, i); - if (isOptional(p.ast)) - return; - const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); - } - } - } -}; -var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); -var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); -var wrapPropertyKeyIssue = (s, ast, key, exit) => { - if (exit.cause.reasons.length === 0) { - return exit; - } - const issue = getSchemaIssue(exit.cause); - if (issue === undefined) { - return failCause2(map5(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); - } - const pointer = new Pointer([key], issue); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(pointer); - else - s.issues = [pointer]; - } else { - return fail4(new Composite(ast, [pointer], s.input, s.options)); - } -}; -var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; -function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) { - let stringKeys; - let symbolKeys; - function go(parameter) { - switch (parameter._tag) { - case "String": - case "TemplateLiteral": - return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== undefined); - case "Number": - return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== undefined); - case "Symbol": - return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== undefined); - case "Union": - return [...new Set(parameter.types.flatMap(go))]; - default: - return []; - } - } - return go(parameterFromPropertyKey(toEncoded(parameter))); -} -var PropertySignature = class { - name; - type; - constructor(name, type) { - this.name = name; - this.type = type; - } -}; -function isIndexSignatureParameterSide(ast) { - switch (ast._tag) { - case "String": - case "Number": - case "Symbol": - case "TemplateLiteral": - return true; - case "Union": - return ast.types.every(isIndexSignatureParameterSide); - default: - return false; + for (const [key, [byValue, all]] of bySentinel) { + if (key === directKey) + continue; + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + for (const i of selected) { + if (all.has(i) && !match?.has(i)) + selected.delete(i); + } + } + } + return Array.from(selected).sort((a, b) => a - b).map((i) => types[i]); + }; + } else { + index = (input) => { + const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; + return (otherwise?.[runtimeType] ?? emptyCandidates).map((i) => types[i]).filter(filterLiterals(input)); + }; } + candidateIndexCache.set(types, index); + return index; } -function isIndexSignatureParameterEncodedSide(ast) { - const encoded = getLastEncoding(ast); - switch (encoded._tag) { - case "String": - case "Number": - case "Symbol": - case "TemplateLiteral": - return true; - case "Union": - return encoded.types.every(isIndexSignatureParameterEncodedSide); - default: - return false; - } +function filterLiterals(input) { + return (ast) => { + const encoded = toCandidate(ast); + return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true; + }; } -function isIndexSignatureParameter(ast) { - return isIndexSignatureParameterSide(ast) && isIndexSignatureParameterEncodedSide(ast); +function getCandidates(input, types, isConstructor = false) { + return getIndex(types)(input, isConstructor); } -var IndexSignature = class { - parameter; - type; - constructor(parameter, type) { - if (!isIndexSignatureParameter(parameter)) { - throw new Error(`Invalid index signature parameter ${parameter._tag}`); - } - this.parameter = parameter; - this.type = type; - if (isOptional(type) && !containsUndefined(type)) { - throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead."); - } - } -}; -var Objects = class extends ASTNodeImpl { - _tag = "Objects"; - propertySignatures; - indexSignatures; +var Union = class extends ASTNodeImpl { + _tag = "Union"; + types; + options; encodingChecks; - constructor(propertySignatures, indexSignatures, annotations, checks, encoding, context, encodingChecks) { + constructor(types, options, annotations, checks, encoding, context, encodingChecks) { super(annotations, checks, encoding, context); - this.propertySignatures = propertySignatures; - this.indexSignatures = indexSignatures; + this.types = types; + this.options = options; this.encodingChecks = encodingChecks; - const seen = new Set; - const duplicates = []; - for (const propertySignature of propertySignatures) { - const name = propertySignature.name; - if (seen.has(name)) { - duplicates.push(name); - } else { - seen.add(name); - } - } - if (duplicates.length > 0) { - throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); - } } - getParser(compile, compileConstructorDefault = compile) { + getParser(compile, compileField) { const ast = this; - const expectedKeys = []; - for (const ps of ast.propertySignatures) { - expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name); - } - const hasProperties = expectedKeys.length; - const indexCount = ast.indexSignatures.length; - let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : undefined; - if (!hasProperties && !indexCount) { - return fromRefinement(ast, isNotNullish); - } - let properties; - let indexes; - const finishIndex = (s, key, k2, inputValue, exitValue) => { - if (exitValue._tag === "Failure") { - return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_2; - } - const value = exitValue === sameExit ? inputValue : exitValue[args]; - if (k2 !== missing && value !== missing) { - if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) - return void_2; - assignProperty(s.out, k2, value); - } - return void_2; - }; - const parseIndex = (s, key, index, exitKey) => { - if (!exitKey) { - const eff = index.parserKey(key, s.options); - if (!effectIsExit(eff)) { - return flatMap3(exit2(eff), (exit) => parseIndex(s, key, index, exit)); - } - exitKey = eff; - } - if (exitKey._tag === "Failure") { - return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_2; - } - const k2 = exitKey === sameExit ? key : exitKey[args]; - const inputValue = s.input[key]; - const result = index.parserValue(inputValue, s.options); - return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, k2, inputValue, exit)); - }; - const parseStringIndex = (s, key, index) => { - const inputValue = s.input[key]; - const result = index.parserValue(inputValue, s.options); - return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, key, inputValue, exit)); - }; - const parseIndexes = indexCount ? iterateConcurrent()({ - onItem: (s, [key, index]) => index.is.parameter === string2 ? parseStringIndex(s, key, index) : parseIndex(s, key, index), - step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined - }) : undefined; - const compileMembers = () => { - if (!properties) { - properties = ast.propertySignatures.map((ps) => ({ - parser: compileConstructorDefault(ps.type), - name: ps.name, - type: ps.type - })); - indexes = indexCount ? ast.indexSignatures.map((is) => ({ - is, - parserKey: compile(parameterFromPropertyKey(is.parameter)), - parserValue: compileConstructorDefault(is.type) - })) : undefined; - } - return properties; - }; - const fallback = fnUntracedEager2(function* (input, options) { + return (input, options) => { if (input === missing) { - return missing; + return missingExit; } - if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { - return yield* fail6(new InvalidType(ast, input, options)); + const candidates = getCandidates(input, ast.types, compileField !== undefined); + if (candidates.length === 0) { + return fail6(new AnyOf(ast, [], input, options)); + } + if (candidates.length === 1) { + const result = compile(candidates[0])(input, options); + if (result._tag === "Success") + return result; + return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchCause2(result, (cause) => failSingleUnionCandidate(ast, cause, input, options)); } - compileMembers(); - const record = input; - const out = {}; const state = { ast, - input: record, - out, + compile, + input, + out: undefined, + successes: ast.options?.mode === "oneOf" ? [] : undefined, issues: undefined, options }; - const errorsAllOption = options.errors === "all"; - const onExcessPropertyError = options.onExcessProperty === "error"; - const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); - const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : undefined; - if (onExcessPropertyError) { - expectedKeysSet ??= new Set(expectedKeys); - const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet; - if (indexKeys) { - for (const keys of indexKeys) { - for (const key of keys) - coveredKeys.add(key); - } - } - const inputKeys = Reflect.ownKeys(record); - for (let i = 0;i < inputKeys.length; i++) { - const key = inputKeys[i]; - if (!coveredKeys.has(key)) { - const unexpected = new UnexpectedKey(ast, record[key], options); - const issue = new Pointer([key], unexpected); - if (errorsAllOption) { - if (state.issues) { - state.issues.push(issue); - } else { - state.issues = [issue]; - } - continue; - } else { - return yield* fail6(new Composite(ast, [issue], input, options)); - } - } - } - } - if (hasProperties) { - const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { - concurrency - }); - if (eff) - yield* eff; + const eff = parseUnion(state, candidates); + if (!eff) { + if (state.out) + return state.out; + return fail6(new AnyOf(ast, state.issues ?? [], input, options)); } - if (indexCount && concurrency === 1) { - for (let i = 0;i < indexCount; i++) { - const index = indexes[i]; - const parse = index.is.parameter === string2 ? parseStringIndex : parseIndex; - const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); - for (let j = 0;j < keys.length; j++) { - const eff = parse(state, keys[j], index); - if (!effectIsExit(eff)) - yield* eff; - else if (eff._tag === "Failure") - return yield* eff; + return flatMapEager2(eff, (_) => { + if (state.out === sameExit) + return succeed6(input); + if (state.out) + return state.out; + return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + }); + }; + } + _rebuild(recur, checks, encodingChecks) { + const types = mapOrSame(this.types, recur); + return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks); + } + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks); + } + matchPart(s, options) { + for (const type of this.types) { + const out = type.matchPart(s, options); + if (out !== undefined) + return out; + } + return; + } + getExpected(getExpected) { + const expected = this.annotations?.expected; + if (typeof expected === "string") + return expected; + if (this.types.length === 0) + return "never"; + const types = this.types.map((type) => { + const encoded = toEncoded(type); + switch (encoded._tag) { + case "Arrays": { + const literals = encoded.elements.filter(isLiteral); + if (literals.length > 0) { + return `${formatIsMutable(encoded.isMutable)}[ ${literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ")}, ... ]`; } + break; } - } else if (parseIndexes) { - const keyPairs = empty2(); - for (let i = 0;i < indexCount; i++) { - const index = indexes[i]; - const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); - for (let j = 0;j < keys.length; j++) { - keyPairs.push([keys[j], index]); + case "Objects": { + const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)); + if (literals.length > 0) { + return `{ ${literals.map((ps) => `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${formatIsOptional(ps.type.context?.isOptional)}: ${getExpected(ps.type)}`).join(", ")}, ... }`; } + break; } - const eff = parseIndexes(state, keyPairs, { - concurrency - }); - if (eff) - yield* eff; - } - if (state.issues) { - return yield* fail6(new Composite(ast, state.issues, input, options)); } - return out; + return getExpected(encoded); }); - if (indexCount) - return fallback; - const resume = (state, index, pending) => { - const property = properties[index]; - return flatMap3(exit2(pending), (exit) => { - const terminal = stepProperty(state, property, exit); - if (terminal) - return terminal; - const done = () => succeed9(state.out); - const eff = parseProperties(state, properties.slice(index + 1)); - return eff ? flatMapEager2(eff, done) : done(); - }); - }; - return (input, options) => { - if (input === missing) - return missingExit; - if (options.errors === "all" || options.onExcessProperty !== undefined || options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1) { - return fallback(input, options); + return Array.from(new Set(types)).join(" | "); + } +}; +function failSingleUnionCandidate(ast, cause, input, options) { + const issue = getSchemaIssue(cause); + if (!issue) + return failCause2(cause); + return fail5(new AnyOf(ast, [issue], input, options)); +} +var parseUnion = /* @__PURE__ */ iterateEager()({ + onItem(s, ast) { + const parser = s.compile(ast); + return parser(s.input, s.options); + }, + step(s, candidate, exit) { + if (exit._tag === "Failure") { + const issue = getSchemaIssue(exit.cause); + if (issue === undefined) { + return exit; } - if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { - return fail6(new InvalidType(ast, input, options)); + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + if (s.out && s.successes) { + s.successes.push(candidate); + return fail5(new OneOf(s.ast, s.successes, s.input, s.options)); } - const props = compileMembers(); - const record = input; - const out = {}; - const state = { - ast, - input: record, - out, - issues: undefined, - options - }; - try { - for (let index = 0;index < props.length; index++) { - const property = props[index]; - const name = property.name; - const hasKey = hasPropertySignature(record, name); - const value = hasKey ? record[name] : missing; - const exit = property.parser(value, options); - if (!effectIsExit(exit)) { - return resume(state, index, exit); - } - if (exit === sameExit) { - if (hasKey) - assignProperty(out, name, value); - continue; - } - const terminal = stepProperty(state, property, exit); - if (terminal) - return terminal; - } - } catch (error) { - return die2(error); + s.out = exit; + if (s.successes) { + s.successes.push(candidate); + } else { + return void_2; } - return succeed9(out); - }; + } } - _rebuild(recur, recurParameter, checks, encodingChecks) { - const props = mapOrSame(this.propertySignatures, (ps) => { - const t = recur(ps.type); - return t === ps.type ? ps : new PropertySignature(ps.name, t); - }); - const indexes = mapOrSame(this.indexSignatures, (is) => { - const p = recurParameter(is.parameter); - const t = recur(is.type); - return p === is.parameter && t === is.type ? is : new IndexSignature(p, t); - }); - return props === this.propertySignatures && indexes === this.indexSignatures && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Objects(props, indexes, this.annotations, checks, undefined, this.context, encodingChecks); +}); +var nonFiniteLiterals = /* @__PURE__ */ new Union([/* @__PURE__ */ new Literal("Infinity"), /* @__PURE__ */ new Literal("-Infinity"), /* @__PURE__ */ new Literal("NaN")]); +function formatIsMutable(isMutable) { + return isMutable ? "" : "readonly "; +} +function formatIsOptional(isOptional) { + return isOptional ? "?" : ""; +} +var Filter2 = class extends Class { + _tag = "Filter"; + run; + annotations; + aborted; + constructor(run, annotations = undefined, aborted = false) { + super(); + this.run = run; + this.annotations = annotations; + this.aborted = aborted; } - flip(recur) { - return this._rebuild(recur, recur, this.encodingChecks, this.checks); + annotate(annotations) { + return new Filter2(this.run, { + ...this.annotations, + ...annotations + }, this.aborted); } - recur(recur, recurParameter = recur) { - return this._rebuild(recur, recurParameter, this.checks, this.encodingChecks); + abort() { + return new Filter2(this.run, this.annotations, true); } - getExpected() { - if (this.propertySignatures.length === 0 && this.indexSignatures.length === 0) - return "object | array"; - return "object"; + and(other, annotations) { + return new FilterGroup([this, other], annotations); } }; -function stepProperty(s, p, exit) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, p.name, exit); +var FilterGroup = class extends Class { + _tag = "FilterGroup"; + checks; + annotations; + constructor(checks, annotations = undefined) { + super(); + this.checks = checks; + this.annotations = annotations; + } + annotate(annotations) { + return new FilterGroup(this.checks, { + ...this.annotations, + ...annotations + }); + } + and(other, annotations) { + return new FilterGroup([this, other], annotations); + } +}; +function makeFilter(filter, annotations, aborted = false) { + return new Filter2((input, ast, options) => normalizeFilterOutput(ast, filter(input, ast, options), input, options), annotations, aborted); +} +function isFinite2(annotations) { + return makeFilter((n) => globalThis.Number.isFinite(n), { + expected: "a finite number", + representation: { + id: "effect/schema/isFinite", + payload: null + }, + toJsonSchema: () => ({ + type: "number" + }), + toCode: () => ({ + runtime: "Schema.isFinite()" + }), + arbitraryConstraint: { + number: "finite" + }, + ...annotations + }); +} +var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]); +var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n)))); +function isPattern(regExp, annotations) { + const source = regExp.source; + const pattern = new globalThis.RegExp(source, regExp.flags); + return makeFilter((s) => { + pattern.lastIndex = 0; + return pattern.test(s); + }, { + expected: `a string matching the RegExp ${source}`, + representation: { + id: "effect/schema/isPattern", + payload: { + source, + flags: regExp.flags + } + }, + toJsonSchema: () => ({ + pattern: source + }), + arbitraryConstraint: { + patterns: [{ + source: regExp.source, + flags: regExp.flags + }] + }, + ...annotations + }); +} +function modifyOwnPropertyDescriptors(ast, f) { + const d = Object.getOwnPropertyDescriptors(ast); + f(d); + return Object.create(Object.getPrototypeOf(ast), d); +} +var contextOwners = /* @__PURE__ */ new WeakMap; +function getContextOwner(ast) { + return contextOwners.get(ast) ?? ast; +} +function replaceEncoding(ast, encoding) { + if (ast.encoding === encoding) { + return ast; + } + return modifyOwnPropertyDescriptors(ast, (d) => { + d.encoding.value = encoding; + }); +} +function replaceContext(ast, context) { + if (ast.context === context) { + return ast; + } + const owner = getContextOwner(ast); + if (owner.context === context) { + return owner; + } + const out = modifyOwnPropertyDescriptors(ast, (d) => { + d.context.value = context; + }); + contextOwners.set(out, owner); + return out; +} +function getLastEncoding(ast) { + return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast; +} +function annotate(ast, annotations) { + if (ast.checks) { + const last = ast.checks[ast.checks.length - 1]; + return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations))); } - if (exit === sameExit) - return; - const value = exit[args]; - if (value !== missing) { - assignProperty(s.out, p.name, value); - return; + return modifyOwnPropertyDescriptors(ast, (d) => { + d.annotations.value = { + ...d.annotations.value, + ...annotations + }; + }); +} +function replaceChecks(ast, checks) { + if (ast._tag === "Suspend" && checks) { + throw new Error("Cannot add checks to Suspend"); } - delete s.out[p.name]; - if (!isOptional(p.type)) { - const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - return; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); - } + if (ast.checks === checks) { + return ast; } + return modifyOwnPropertyDescriptors(ast, (d) => { + d.checks.value = checks; + }); } -var parsePropertiesOptions = { - onItem(s, p) { - if (!hasPropertySignature(s.input, p.name)) { - return p.parser(missing, s.options); - } - const value = s.input[p.name]; - assignProperty(s.out, p.name, value); - return p.parser(value, s.options); - }, - step: stepProperty -}; -var parseProperties = /* @__PURE__ */ iterateEager()(parsePropertiesOptions); -var parsePropertiesConcurrent = /* @__PURE__ */ iterateConcurrent()(parsePropertiesOptions); -function combineChecks(a, b) { - if (!a) - return b; - if (!b) - return a; - return [...a, ...b]; +function appendChecks(ast, checks) { + return replaceChecks(ast, combineChecks(ast.checks, checks)); } -function struct(fields, checks, annotations) { - return new Objects(Reflect.ownKeys(fields).map((key) => { - return new PropertySignature(key, fields[key].ast); - }), [], annotations, checks); +function mapLink(link, f) { + const to = f(link.to); + return to === link.to ? link : new Link(to, link.transformation); } -function getAST(self) { - return self.ast; +function updateLastLink(encoding, f) { + const links = encoding; + const last = links[links.length - 1]; + const out = mapLink(last, f); + return out === last ? encoding : append(encoding.slice(0, encoding.length - 1), out); } -function tuple(elements, checks = undefined) { - return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks); +function applyToLastLink(f) { + return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast; } -function union(members, options, checks) { - return new Union(members.map(getAST), options, undefined, checks); +function applyToSelfOrLastLinkEncodingIdempotent(f, options) { + function out(ast) { + if (ast.encoding) { + const last = ast.encoding[ast.encoding.length - 1]; + return options?.stopAt?.(last) ? ast : replaceEncoding(ast, updateLastLink(ast.encoding, out)); + } + return f(ast); + } + return memoizeIdempotent(out); } -var toCandidate = /* @__PURE__ */ memoizeIdempotent((ast) => { - while (true) { - if (isSuspend(ast)) - return unknown; - const encoding = ast.encoding; - if (!encoding) { - return ast.recur?.(toCandidate, identity) ?? ast; +function appendTransformation(from, transformation, to) { + const link = new Link(from, transformation); + return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]); +} +function mapOrSame(as, f) { + let changed = false; + const out = new Array(as.length); + for (let i = 0;i < as.length; i++) { + const a = as[i]; + const fa = f(a); + if (fa !== a) { + changed = true; } - if (encoding.some((link) => link.transformation._tag === "Middleware" && link.transformation.decode !== identity)) - return unknown; - ast = encoding[encoding.length - 1].to; + out[i] = fa; } + return changed ? out : as; +} +function annotateKey(ast, annotations) { + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, { + ...ast.context.annotations, + ...annotations + }) : new Context(false, false, undefined, annotations); + return replaceContext(ast, context); +} +var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { + const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false); + return optionalKeyLastLink(replaceContext(ast, context)); }); -function getCandidateTypes(ast) { - switch (ast._tag) { - case "Null": - return ["null"]; - case "Undefined": - return ["undefined"]; - case "String": - case "TemplateLiteral": - return ["string"]; - case "Number": - return ["number"]; - case "Boolean": - return ["boolean"]; - case "Symbol": - case "UniqueSymbol": - return ["symbol"]; - case "BigInt": - return ["bigint"]; - case "Arrays": - return ["array"]; - case "ObjectKeyword": - return ["object", "array", "function"]; - case "Objects": - return ast.propertySignatures.length || ast.indexSignatures.length ? ["object"] : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; - case "Enum": - return Array.from(new Set(ast.enums.map(([, v]) => typeof v))); - case "Literal": - return [typeof ast.literal]; - case "Union": - return Array.from(new Set(ast.types.flatMap(getCandidateTypes))); - default: - return ["null", "undefined", "string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; +var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); +function withConstructorDefault(ast, defaultValue) { + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue); + return replaceContext(ast, context); +} +function decodeTo(from, to, transformation) { + return appendTransformation(from, transformation, to); +} +function isOptional(ast) { + return ast.context?.isOptional ?? false; +} +function isStructuralCheck(check) { + return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck); +} +function extractStructuralChecks(checks) { + function extract(check) { + if (isStructuralCheck(check)) + return [check]; + return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []; } + const out = checks.flatMap(extract); + return isArrayNonEmpty2(out) ? out : undefined; } -function collectSentinels(ast) { - switch (ast._tag) { - default: - return []; - case "Declaration": { - const s = ast.annotations?.[SENTINELS_ANNOTATION_KEY]; - return Array.isArray(s) ? s : []; - } - case "Objects": - return ast.propertySignatures.flatMap((ps) => { - const type = ps.type; - if (!isOptional(type)) { - if (isLiteral(type)) { - return [{ - key: ps.name, - literal: type.literal - }]; - } - if (isUniqueSymbol(type)) { - return [{ - key: ps.name, - literal: type.symbol - }]; - } - } - return []; - }); - case "Arrays": - return ast.elements.flatMap((e, i) => { - if (!isOptional(e)) { - if (isLiteral(e)) { - return [{ - key: i, - literal: e.literal - }]; - } - if (isUniqueSymbol(e)) { - return [{ - key: i, - literal: e.symbol - }]; - } - } - return []; - }); - case "Union": { - if (ast.types.length === 0) - return []; - const members = ast.types.map((type) => collectSentinels(toCandidate(type))); - return members[0].filter((s) => members.every((sentinels) => sentinels.some((o) => o.key === s.key && o.literal === s.literal))); - } - case "Suspend": - return collectSentinels(ast.thunk()); +var toType = /* @__PURE__ */ memoizeIdempotent((ast) => { + if (ast.encoding) { + return toType(replaceEncoding(ast, undefined)); + } + const out = ast; + const type = out.recur?.(toType) ?? out; + const encodingChecks = type.encodingChecks; + if (encodingChecks) { + const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : undefined; + return modifyOwnPropertyDescriptors(type, (d) => { + d.encodingChecks.value = undefined; + d.checks.value = combineChecks(type.checks, checks); + }); + } + return type; +}); +var toEncoded = /* @__PURE__ */ memoizeIdempotent((ast) => { + return toType(flip2(ast)); +}); +function flipEncoding(ast, encoding) { + const links = encoding; + const len = links.length; + const last = links[len - 1]; + const ls = [new Link(flip2(replaceEncoding(ast, undefined)), links[0].transformation.flip())]; + for (let i = 1;i < len; i++) { + ls.unshift(new Link(flip2(links[i - 1].to), links[i].transformation.flip())); + } + const to = flip2(last.to); + if (to.encoding) { + return replaceEncoding(to, [...to.encoding, ...ls]); + } else { + return replaceEncoding(to, ls); } } -var candidateIndexCache = /* @__PURE__ */ new WeakMap; -var emptyCandidates = /* @__PURE__ */ Object.freeze([]); -var hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : (key in input); -function getIndex(types) { - let index = candidateIndexCache.get(types); - if (index) - return index; - let bySentinel; - let sentinelCandidateCount = 0; - let otherwise; - let literalCandidates; - let onlyLiterals = true; - for (let i = 0;i < types.length; i++) { - const a = types[i]; - const encoded = toCandidate(a); - if (isNever2(encoded)) - continue; - if (onlyLiterals) { - if (isLiteral(encoded) || isUniqueSymbol(encoded)) { - literalCandidates ??= new Map; - const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol; - let arr = literalCandidates.get(literal); - if (!arr) - literalCandidates.set(literal, arr = []); - arr.push(a); - } else { - onlyLiterals = false; - } - } - const sentinels = collectSentinels(encoded); - if (sentinels.length) { - bySentinel ??= new Map; - sentinelCandidateCount++; - for (const { - key, - literal - } of sentinels) { - let entry = bySentinel.get(key); - if (!entry) - bySentinel.set(key, entry = [new Map, new Set]); - entry[1].add(i); - let indexes = entry[0].get(literal); - if (!indexes) - entry[0].set(literal, indexes = new Set); - indexes.add(i); - } - } else { - otherwise ??= {}; - const candidateTypes = getCandidateTypes(encoded); - for (const t of candidateTypes) - (otherwise[t] ??= []).push(i); - } +var flip2 = /* @__PURE__ */ memoize((ast) => { + if (ast.encoding) { + return flipEncoding(ast, ast.encoding); } - if (onlyLiterals && literalCandidates) { - literalCandidates.forEach(Object.freeze); - index = (input) => literalCandidates.get(input) ?? emptyCandidates; - } else if (bySentinel?.size === 1 && !otherwise) { - const [key, [byValue]] = bySentinel.entries().next().value; - const candidates = byValue; - for (const [literal, indexes] of byValue) { - candidates.set(literal, Object.freeze(Array.from(indexes, (index) => types[index]))); - } - index = (input, isConstructor) => { - if (isObjectKeyword(input)) { - const value = hasPropertySignature(input, key) ? input[key] : undefined; - if (value !== undefined) - return candidates.get(value) ?? emptyCandidates; - if (isConstructor) - return types; + const out = ast; + return out.flip?.(flip2) ?? out.recur?.(flip2) ?? out; +}); +function containsUndefined(ast) { + switch (ast._tag) { + case "Undefined": + return true; + case "Union": + return ast.types.some(containsUndefined); + default: + return false; + } +} +function fromConst(ast, value) { + const succeed = value === 0 ? sameExit : succeed7(value); + return (input, options) => { + if (input === missing) + return missingExit; + if (input === value) + return succeed; + return fail6(new InvalidType(ast, input, options)); + }; +} +function fromRefinement(ast, refinement) { + return (input, options) => { + if (input === missing) + return missingExit; + if (refinement(input)) + return sameExit; + return fail6(new InvalidType(ast, input, options)); + }; +} +var parameterFromPropertyKey = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => { + switch (ast._tag) { + default: + return ast; + case "Number": + return ast.toCodecStringTree(); + case "Union": + return ast.recur(parameterFromPropertyKey); + } +}); +var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`); +var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`); +function isStringFinite(annotations) { + return isPattern(isStringFiniteRegExp, { + expected: "a string representing a finite number", + representation: { + id: "effect/schema/isStringFinite", + payload: null + }, + toJsonSchema: () => ({ + pattern: isStringFiniteRegExp.source + }), + ...annotations + }); +} +var finiteString = /* @__PURE__ */ appendChecks(string2, [/* @__PURE__ */ isStringFinite()]); +var finiteToString = /* @__PURE__ */ new Link(finiteString, numberFromString); +var numberToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finiteString, nonFiniteLiterals]), numberFromString); +var BIGINT_PATTERN = "-?\\d+"; +var isStringBigIntRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${BIGINT_PATTERN}$`); +var REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"; +var isStringSymbolRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${REGEXP_PATTERN}$`); +function collectIssues(checks, value, issues, ast, options) { + for (let i = 0;i < checks.length; i++) { + const check = checks[i]; + if (check._tag === "FilterGroup") { + issues = collectIssues(check.checks, value, issues, ast, options); + if (issues && (options.errors !== "all" || issues[issues.length - 1].filter.aborted)) { + return issues; } - return emptyCandidates; - }; - } else if (bySentinel) { - let commonSentinel; - for (const entry of bySentinel) { - if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) { - commonSentinel = entry; + } else { + const issue = check.run(value, ast, options); + if (issue) { + const filter = new Filter(check, issue, value, options); + if (issues) + issues.push(filter); + else + issues = [filter]; + if (options.errors !== "all" || check.aborted) { + return issues; + } } } - index = (input, isConstructor) => { - const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; - const base = otherwise?.[runtimeType] ?? emptyCandidates; - if (!isObjectKeyword(input)) - return base.map((i) => types[i]); - const selected = new Set(base); - let directKey; - if (commonSentinel) { - const [key, [byValue]] = commonSentinel; - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - if (!match) - return base.map((i) => types[i]); - for (const i of match) - selected.add(i); - directKey = key; + } + return issues; +} +function getConstructorDescriptor(ast) { + if (!isDeclaration(ast)) + return; + const getDescriptor = ast.annotations?.[CONSTRUCTOR_ANNOTATION_KEY]; + return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; +} +function isJsonLeaf(u) { + return u === null || typeof u === "string" || typeof u === "boolean" || typeof u === "number" && globalThis.Number.isFinite(u); +} +function isStringTreeLeaf(u) { + return u === undefined || typeof u === "string"; +} +function isTree(u, isLeaf) { + const cache = new WeakMap; + const stack = []; + outer: + while (true) { + if (typeof u !== "object" || u === null) { + if (!isLeaf(u)) { + return false; } - } - if (directKey === undefined) { - for (const [key, [byValue, all]] of bySentinel) { - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - if (match) { - for (const i of match) - selected.add(i); + } else { + const value = u; + const cached = cache.get(value); + if (cached === false) { + return false; + } + if (cached === undefined) { + const isArray = Array.isArray(value); + if (!isArray) { + const prototype = Object.getPrototypeOf(value); + if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) { + return false; } - } else if (isConstructor) { - for (const i of all) - selected.add(i); } + cache.set(value, false); + stack.push({ + value, + keys: isArray ? value.length : Object.keys(value), + index: 0 + }); } } - for (const [key, [byValue, all]] of bySentinel) { - if (key === directKey) - continue; - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - for (const i of selected) { - if (all.has(i) && !match?.has(i)) - selected.delete(i); + while (stack.length > 0) { + const frame = stack[stack.length - 1]; + const keys = frame.keys; + if (typeof keys === "number") { + if (frame.index < keys) { + u = frame.value[frame.index++]; + continue outer; } + } else if (frame.index < keys.length) { + u = frame.value[keys[frame.index++]]; + continue outer; } + cache.set(frame.value, true); + stack.pop(); } - return Array.from(selected).sort((a, b) => a - b).map((i) => types[i]); - }; - } else { - index = (input) => { - const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; - return (otherwise?.[runtimeType] ?? emptyCandidates).map((i) => types[i]).filter(filterLiterals(input)); - }; - } - candidateIndexCache.set(types, index); - return index; + return true; + } } -function filterLiterals(input) { - return (ast) => { - const encoded = toCandidate(ast); - return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true; - }; +function isJson(u) { + return isTree(u, isJsonLeaf); } -function getCandidates(input, types, isConstructor = false) { - return getIndex(types)(input, isConstructor); +var Json = /* @__PURE__ */ new Declaration([], () => (input, ast, options) => isJson(input) ? sameExit : fail6(new InvalidType(ast, input, options)), { + representation: { + id: "effect/schema/Json", + payload: null + }, + expected: "JSON value", + toCodecJson: () => { + return; + }, + toCodecStringTree: () => unknownToStringTree +}); +function isStringTree(u) { + return isTree(u, isStringTreeLeaf); } -var Union = class extends ASTNodeImpl { - _tag = "Union"; - types; - options; - encodingChecks; - constructor(types, options, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.types = types; - this.options = options; - this.encodingChecks = encodingChecks; +var StringTree = /* @__PURE__ */ new Declaration([], () => (input, ast, options) => isStringTree(input) ? sameExit : fail6(new InvalidType(ast, input, options)), { + expected: "StringTree", + toCodecStringTree: () => { + return; } - getParser(compile, compileConstructorDefault) { - const ast = this; - return (input, options) => { - if (input === missing) { - return missingExit; - } - const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined); - if (candidates.length === 0) { - return fail6(new AnyOf(ast, [], input, options)); - } - if (candidates.length === 1) { - const result = compile(candidates[0])(input, options); - if (result._tag === "Success") - return result; - return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchCause2(result, (cause) => failSingleUnionCandidate(ast, cause, input, options)); - } - const state = { - ast, - compile, - input, - out: undefined, - successes: ast.options?.mode === "oneOf" ? [] : undefined, - issues: undefined, - options - }; - const eff = parseUnion(state, candidates); - if (!eff) { - if (state.out) - return state.out; - return fail6(new AnyOf(ast, state.issues ?? [], input, options)); - } - return flatMapEager2(eff, (_) => { - if (state.out === sameExit) - return succeed6(input); - if (state.out) - return state.out; - return fail6(new AnyOf(ast, state.issues ?? [], input, options)); - }); +}); +var unknownToStringTree = /* @__PURE__ */ new Link(StringTree, /* @__PURE__ */ passthrough2()); + +// node_modules/effect/dist/Brand.js +function nominal() { + return Object.assign((input) => input, { + option: (input) => some2(input), + result: (input) => succeed2(input), + is: (_) => true + }); +} +// node_modules/effect/dist/Fiber.js +var join = fiberJoin; +var interrupt3 = fiberInterrupt; +var runIn = fiberRunIn; + +// node_modules/effect/dist/Latch.js +var makeUnsafe4 = makeLatchUnsafe; +var make6 = makeLatch; + +// node_modules/effect/dist/MutableRef.js +var TypeId10 = "~effect/MutableRef"; +var MutableRefProto = { + [TypeId10]: TypeId10, + ...PipeInspectableProto, + toJSON() { + return { + _id: "MutableRef", + current: toJson(this.current) }; } - _rebuild(recur, checks, encodingChecks) { - const types = mapOrSame(this.types, recur); - return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks); +}; +var make7 = (value) => { + const ref = Object.create(MutableRefProto); + ref.current = value; + return ref; +}; + +// node_modules/effect/dist/MutableList.js +var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); +var make8 = () => ({ + head: undefined, + tail: undefined, + length: 0 +}); +var emptyBucket = () => ({ + array: [], + mutable: true, + offset: 0, + next: undefined +}); +var append2 = (self, message) => { + if (!self.tail) { + self.head = self.tail = emptyBucket(); + } else if (!self.tail.mutable) { + self.tail.next = emptyBucket(); + self.tail = self.tail.next; } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks); + self.tail.array.push(message); + self.length++; +}; +var clear = (self) => { + self.head = self.tail = undefined; + self.length = 0; +}; +var takeN = (self, n) => { + n = normalize(n); + if (n <= 0 || !self.head) + return []; + n = Math.min(n, self.length); + if (n === self.length && self.head?.offset === 0 && !self.head.next) { + const array = self.head.array; + clear(self); + return array; } - flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks); + const array = new Array(n); + let index = 0; + let chunk = self.head; + while (chunk) { + while (chunk.offset < chunk.array.length) { + array[index++] = chunk.array[chunk.offset]; + if (chunk.mutable) + chunk.array[chunk.offset] = undefined; + chunk.offset++; + if (index === n) { + self.head = chunk; + self.length -= n; + if (self.length === 0) + clear(self); + return array; + } + } + chunk = chunk.next; + } + clear(self); + return array; +}; +var take = (self) => { + if (!self.head) + return Empty; + const message = self.head.array[self.head.offset]; + if (self.head.mutable) + self.head.array[self.head.offset] = undefined; + self.head.offset++; + self.length--; + if (self.head.offset === self.head.array.length) { + if (self.head.next) { + self.head = self.head.next; + } else { + clear(self); + } + } + return message; +}; + +// node_modules/effect/dist/Queue.js +var TypeId11 = "~effect/Queue"; +var EnqueueTypeId = "~effect/Queue/Enqueue"; +var DequeueTypeId = "~effect/Queue/Dequeue"; +var variance = { + _A: identity, + _E: identity +}; +var QueueProto = { + [TypeId11]: variance, + [EnqueueTypeId]: variance, + [DequeueTypeId]: variance, + ...PipeInspectableProto, + toJSON() { + return { + _id: "effect/Queue", + state: this.state._tag, + size: sizeUnsafe(this) + }; + } +}; +var make9 = (options) => withFiber((fiber) => { + const self = Object.create(QueueProto); + self.dispatcher = fiber.currentDispatcher; + self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; + self.strategy = options?.strategy ?? "suspend"; + self.messages = make8(); + self.scheduleRunning = false; + self.state = { + _tag: "Open", + takers: new Set, + offers: new Set, + awaiters: new Set + }; + return succeed3(self); +}); +var bounded = (capacity) => make9({ + capacity +}); +var offer = (self, message) => suspend(() => { + if (self.state._tag !== "Open") { + return exitFalse; + } else if (self.messages.length >= self.capacity) { + switch (self.strategy) { + case "dropping": + return exitFalse; + case "suspend": + if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return exitTrue; + } + return offerRemainingSingle(self, message); + case "sliding": + take(self.messages); + append2(self.messages, message); + return exitTrue; + } } - matchPart(s, options) { - for (const type of this.types) { - const out = type.matchPart(s, options); - if (out !== undefined) - return out; + append2(self.messages, message); + scheduleReleaseTaker(self); + return exitTrue; +}); +var offerUnsafe = (self, message) => { + if (self.state._tag !== "Open") { + return false; + } else if (self.messages.length >= self.capacity) { + if (self.strategy === "sliding") { + take(self.messages); + append2(self.messages, message); + return true; + } else if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return true; } - return; + return false; } - getExpected(getExpected) { - const expected = this.annotations?.expected; - if (typeof expected === "string") - return expected; - if (this.types.length === 0) - return "never"; - const types = this.types.map((type) => { - const encoded = toEncoded(type); - switch (encoded._tag) { - case "Arrays": { - const literals = encoded.elements.filter(isLiteral); - if (literals.length > 0) { - return `${formatIsMutable(encoded.isMutable)}[ ${literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ")}, ... ]`; - } - break; - } - case "Objects": { - const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)); - if (literals.length > 0) { - return `{ ${literals.map((ps) => `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${formatIsOptional(ps.type.context?.isOptional)}: ${getExpected(ps.type)}`).join(", ")}, ... }`; - } - break; - } - } - return getExpected(encoded); - }); - return Array.from(new Set(types)).join(" | "); + append2(self.messages, message); + scheduleReleaseTaker(self); + return true; +}; +var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); +var failCauseUnsafe = (self, cause) => { + if (self.state._tag !== "Open") { + return false; + } + const exit = exitFailCause(cause); + const fail = exitZipRight(exit, exitFailDone); + if (self.state.offers.size === 0 && self.messages.length === 0) { + finalize(self, fail); + return true; } + self.state = { + ...self.state, + _tag: "Closing", + exit: fail + }; + return true; }; -function failSingleUnionCandidate(ast, cause, input, options) { - const issue = getSchemaIssue(cause); - if (!issue) - return failCause2(cause); - return fail4(new AnyOf(ast, [issue], input, options)); -} -var parseUnion = /* @__PURE__ */ iterateEager()({ - onItem(s, ast) { - const parser = s.compile(ast); - return parser(s.input, s.options); - }, - step(s, candidate, exit) { - if (exit._tag === "Failure") { - const issue = getSchemaIssue(exit.cause); - if (issue === undefined) { - return exit; - } - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - if (s.out && s.successes) { - s.successes.push(candidate); - return fail4(new OneOf(s.ast, s.successes, s.input, s.options)); - } - s.out = exit; - if (s.successes) { - s.successes.push(candidate); +var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); +var shutdown = (self) => sync(() => { + if (self.state._tag === "Done") { + return true; + } + clear(self.messages); + const offers = self.state.offers; + finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); + if (offers.size > 0) { + for (const entry of offers) { + if (entry._tag === "Single") { + entry.resume(exitFalse); } else { - return void_2; + entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); } } + offers.clear(); } + return true; }); -var nonFiniteLiterals = /* @__PURE__ */ new Union([/* @__PURE__ */ new Literal("Infinity"), /* @__PURE__ */ new Literal("-Infinity"), /* @__PURE__ */ new Literal("NaN")]); -function formatIsMutable(isMutable) { - return isMutable ? "" : "readonly "; -} -function formatIsOptional(isOptional) { - return isOptional ? "?" : ""; -} -var Filter2 = class extends Class { - _tag = "Filter"; - run; - annotations; - aborted; - constructor(run, annotations = undefined, aborted = false) { - super(); - this.run = run; - this.annotations = annotations; - this.aborted = aborted; - } - annotate(annotations) { - return new Filter2(this.run, { - ...this.annotations, - ...annotations - }, this.aborted); - } - abort() { - return new Filter2(this.run, this.annotations, true); - } - and(other, annotations) { - return new FilterGroup([this, other], annotations); - } +var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); +var takeBetween = (self, min, max) => { + min = normalize(min); + max = normalize(max); + return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); }; -var FilterGroup = class extends Class { - _tag = "FilterGroup"; - checks; - annotations; - constructor(checks, annotations = undefined) { - super(); - this.checks = checks; - this.annotations = annotations; +var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); +var poll = (self) => suspend(() => { + const result = takeUnsafe(self); + if (result === undefined) { + return succeed3(none2()); } - annotate(annotations) { - return new FilterGroup(this.checks, { - ...this.annotations, - ...annotations - }); + if (result._tag === "Success") { + return succeed3(some2(result.value)); } - and(other, annotations) { - return new FilterGroup([this, other], annotations); + return succeed3(none2()); +}); +var takeUnsafe = (self) => { + if (self.state._tag === "Done") { + return self.state.exit; + } + if (self.messages.length > 0) { + const message = take(self.messages); + releaseCapacity(self); + return exitSucceed(message); + } else if (self.capacity <= 0 && self.state.offers.size > 0) { + const message = takeOfferUnsafe(self.state.offers); + releaseCapacity(self); + return exitSucceed(message); } + return; }; -function makeFilter(filter, annotations, aborted = false) { - return new Filter2((input, ast, options) => normalizeFilterOutput(ast, filter(input, ast, options), input, options), annotations, aborted); -} -function isFinite2(annotations) { - return makeFilter((n) => globalThis.Number.isFinite(n), { - expected: "a finite number", - representation: { - id: "effect/schema/isFinite", - payload: null - }, - toJsonSchema: () => ({ - type: "number" - }), - toCode: () => ({ - runtime: "Schema.isFinite()" - }), - arbitraryConstraint: { - number: "finite" - }, - ...annotations - }); -} -var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]); -var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n)))); -function isPattern(regExp, annotations) { - const source = regExp.source; - const pattern = new globalThis.RegExp(source, regExp.flags); - return makeFilter((s) => { - pattern.lastIndex = 0; - return pattern.test(s); - }, { - expected: `a string matching the RegExp ${source}`, - representation: { - id: "effect/schema/isPattern", - payload: { - source, - flags: regExp.flags - } - }, - toJsonSchema: () => ({ - pattern: source - }), - arbitraryConstraint: { - patterns: [{ - source: regExp.source, - flags: regExp.flags - }] - }, - ...annotations - }); -} -function modifyOwnPropertyDescriptors(ast, f) { - const d = Object.getOwnPropertyDescriptors(ast); - f(d); - return Object.create(Object.getPrototypeOf(ast), d); -} -var contextOwners = /* @__PURE__ */ new WeakMap; -function getContextOwner(ast) { - return contextOwners.get(ast) ?? ast; -} -function replaceEncoding(ast, encoding) { - if (ast.encoding === encoding) { - return ast; +var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; +var exitFalse = /* @__PURE__ */ exitSucceed(false); +var exitTrue = /* @__PURE__ */ exitSucceed(true); +var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); +var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); +var releaseTakers = (self) => { + if (self.state._tag === "Done" || self.state.takers.size === 0) { + return; } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.encoding.value = encoding; - }); -} -function replaceContext(ast, context) { - if (ast.context === context) { - return ast; + for (const taker of self.state.takers) { + self.state.takers.delete(taker); + taker(exitVoid); + if (self.messages.length === 0) { + break; + } } - const owner = getContextOwner(ast); - if (owner.context === context) { - return owner; +}; +var scheduleReleaseTaker = (self) => { + if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { + return; } - const out = modifyOwnPropertyDescriptors(ast, (d) => { - d.context.value = context; - }); - contextOwners.set(out, owner); - return out; -} -function getLastEncoding(ast) { - return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast; -} -function annotate(ast, annotations) { - if (ast.checks) { - const last = ast.checks[ast.checks.length - 1]; - return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations))); + self.scheduleRunning = true; + self.dispatcher.scheduleTask(() => { + self.scheduleRunning = false; + releaseTakers(self); + }, 0); +}; +var takeBetweenUnsafe = (self, min, max) => { + if (self.state._tag === "Done") { + return self.state.exit; + } else if (max <= 0 || min <= 0) { + return exitSucceed([]); + } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { + const messages = [takeOfferUnsafe(self.state.offers)]; + releaseCapacity(self); + return exitSucceed(messages); } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.annotations.value = { - ...d.annotations.value, - ...annotations + min = Math.min(min, self.capacity || 1); + if (min <= self.messages.length) { + const messages = takeN(self.messages, max); + releaseCapacity(self); + return exitSucceed(messages); + } +}; +var offerRemainingSingle = (self, message) => { + return callback((resume) => { + if (self.state._tag !== "Open") { + return resume(exitFalse); + } + const entry = { + _tag: "Single", + message, + resume }; + self.state.offers.add(entry); + return sync(() => { + if (self.state._tag === "Open") { + self.state.offers.delete(entry); + } + }); }); -} -function replaceChecks(ast, checks) { - if (ast._tag === "Suspend" && checks) { - throw new Error("Cannot add checks to Suspend"); +}; +var takeOfferUnsafe = (offers) => { + const entry = offers.values().next().value; + if (entry._tag === "Single") { + offers.delete(entry); + entry.resume(exitTrue); + return entry.message; } - if (ast.checks === checks) { - return ast; + const message = entry.remaining[entry.offset++]; + if (entry.offset === entry.remaining.length) { + offers.delete(entry); + entry.resume(exitSucceed([])); } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.checks.value = checks; - }); -} -function appendChecks(ast, checks) { - return replaceChecks(ast, combineChecks(ast.checks, checks)); -} -function mapLink(link, f) { - const to = f(link.to); - return to === link.to ? link : new Link(to, link.transformation); -} -function updateLastLink(encoding, f) { - const links = encoding; - const last = links[links.length - 1]; - const out = mapLink(last, f); - return out === last ? encoding : append(encoding.slice(0, encoding.length - 1), out); -} -function applyToLastLink(f) { - return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast; -} -function applyToSelfOrLastLinkEncodingIdempotent(f, options) { - function out(ast) { - if (ast.encoding) { - const last = ast.encoding[ast.encoding.length - 1]; - return options?.stopAt?.(last) ? ast : replaceEncoding(ast, updateLastLink(ast.encoding, out)); + return message; +}; +var releaseCapacity = (self) => { + if (self.state._tag === "Done") { + return isDoneCause(self.state.exit.cause); + } else if (self.state.offers.size === 0) { + if (self.state._tag === "Closing" && self.messages.length === 0) { + finalize(self, self.state.exit); + return isDoneCause(self.state.exit.cause); } - return f(ast); + return false; } - return memoizeIdempotent(out); -} -function appendTransformation(from, transformation, to) { - const link = new Link(from, transformation); - return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]); -} -function mapOrSame(as, f) { - let changed = false; - const out = new Array(as.length); - for (let i = 0;i < as.length; i++) { - const a = as[i]; - const fa = f(a); - if (fa !== a) { - changed = true; + for (const entry of self.state.offers) { + let n = self.capacity - self.messages.length; + if (n <= 0) + break; + else if (entry._tag === "Single") { + append2(self.messages, entry.message); + self.state.offers.delete(entry); + entry.resume(exitTrue); + } else { + for (;entry.offset < entry.remaining.length; entry.offset++) { + if (n === 0) + return false; + append2(self.messages, entry.remaining[entry.offset]); + n--; + } + self.state.offers.delete(entry); + entry.resume(exitSucceed([])); } - out[i] = fa; } - return changed ? out : as; -} -function annotateKey(ast, annotations) { - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, { - ...ast.context.annotations, - ...annotations - }) : new Context(false, false, undefined, annotations); - return replaceContext(ast, context); -} -var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { - const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false); - return optionalKeyLastLink(replaceContext(ast, context)); + return false; +}; +var awaitTake = (self) => callback((resume) => { + if (self.state._tag === "Done") { + return resume(self.state.exit); + } + self.state.takers.add(resume); + return sync(() => { + if (self.state._tag !== "Done") { + self.state.takers.delete(resume); + } + }); }); -var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); -function withConstructorDefault(ast, defaultValue) { - const transformation = new Transformation(withDefault(defaultValue), passthrough()); - const constructorDefault = new Link(unknown, transformation); - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) : new Context(false, false, constructorDefault); - return replaceContext(ast, context); -} -function decodeTo(from, to, transformation) { - return appendTransformation(from, transformation, to); -} -function isOptional(ast) { - return ast.context?.isOptional ?? false; -} -function isStructuralCheck(check) { - return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck); -} -function extractStructuralChecks(checks) { - function extract(check) { - if (isStructuralCheck(check)) - return [check]; - return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []; +var finalize = (self, exit) => { + if (self.state._tag === "Done") { + return; + } + const openState = self.state; + self.state = { + _tag: "Done", + exit + }; + for (const taker of openState.takers) { + taker(exit); + } + openState.takers.clear(); + for (const awaiter of openState.awaiters) { + awaiter(exit); + } + openState.awaiters.clear(); +}; + +// node_modules/effect/dist/Semaphore.js +var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); +var waitForPermits = (self, n, effect) => callback((resume) => { + if (self.free >= n) + return resume(effect); + const observer = () => { + if (self.free < n) + return; + self.waiters.delete(observer); + resume(effect); + }; + self.waiters.add(observer); + return sync(() => { + self.waiters.delete(observer); + }); +}); + +class SemaphoreImpl { + waiters = /* @__PURE__ */ new Set; + taken = 0; + permits; + constructor(permits) { + this.permits = permits; + } + get free() { + return this.permits - this.taken; + } + take(n) { + const take = suspend(() => { + if (this.free < n) { + return waitForPermits(this, n, take); + } + this.taken += n; + return succeed3(n); + }); + return take; } - const out = checks.flatMap(extract); - return isArrayNonEmpty2(out) ? out : undefined; -} -var toType = /* @__PURE__ */ memoizeIdempotent((ast) => { - if (ast.encoding) { - return toType(replaceEncoding(ast, undefined)); + takeIfAvailable(n) { + return suspend(() => { + if (this.free < n) + return succeed3(false); + this.taken += n; + return succeed3(true); + }); } - const out = ast; - const type = out.recur?.(toType) ?? out; - const encodingChecks = type.encodingChecks; - if (encodingChecks) { - const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : undefined; - return modifyOwnPropertyDescriptors(type, (d) => { - d.encodingChecks.value = undefined; - d.checks.value = combineChecks(type.checks, checks); + releaseUnsafe(fiber, n) { + this.taken -= n; + if (this.waiters.size > 0) { + fiber.currentDispatcher.scheduleTask(() => { + for (const observer of this.waiters) { + if (this.free <= 0) + break; + observer(); + } + }, 0); + } + return this.free; + } + resize(permits) { + return withFiber((fiber) => { + this.permits = permits; + if (this.free < 0) + return void_; + this.releaseUnsafe(fiber, 0); + return void_; }); } - return type; -}); -var toEncoded = /* @__PURE__ */ memoizeIdempotent((ast) => { - return toType(flip2(ast)); -}); -function flipEncoding(ast, encoding) { - const links = encoding; - const len = links.length; - const last = links[len - 1]; - const ls = [new Link(flip2(replaceEncoding(ast, undefined)), links[0].transformation.flip())]; - for (let i = 1;i < len; i++) { - ls.unshift(new Link(flip2(links[i - 1].to), links[i].transformation.flip())); + release(n) { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); } - const to = flip2(last.to); - if (to.encoding) { - return replaceEncoding(to, [...to.encoding, ...ls]); - } else { - return replaceEncoding(to, ls); + get releaseAll() { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); } -} -var flip2 = /* @__PURE__ */ memoize((ast) => { - if (ast.encoding) { - return flipEncoding(ast, ast.encoding); + withPermits(n) { + return (self) => uninterruptibleMask((restore) => { + const acquire = suspend(() => { + if (this.free < n) { + const wait = waitForPermits(this, n, void_); + return flatMap2(restore(wait), () => acquire); + } + this.taken += n; + return onExitPrimitive(restore(self), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); + return acquire; + }); } - const out = ast; - return out.flip?.(flip2) ?? out.recur?.(flip2) ?? out; -}); -function containsUndefined(ast) { - switch (ast._tag) { - case "Undefined": - return true; - case "Union": - return ast.types.some(containsUndefined); - default: - return false; + withPermit = /* @__PURE__ */ this.withPermits(1); + withPermitsIfAvailable(n) { + return (self) => uninterruptibleMask((restore) => { + if (this.free < n) + return succeedNone; + this.taken += n; + return onExitPrimitive(restore(asSome(self)), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); } } -function fromConst(ast, value) { - const succeed = value === 0 ? sameExit : succeed9(value); - return (input, options) => { - if (input === missing) - return missingExit; - if (input === value) - return succeed; - return fail6(new InvalidType(ast, input, options)); - }; -} -function fromRefinement(ast, refinement) { - return (input, options) => { - if (input === missing) - return missingExit; - if (refinement(input)) - return sameExit; - return fail6(new InvalidType(ast, input, options)); - }; -} -var parameterFromPropertyKey = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => { - switch (ast._tag) { - default: - return ast; - case "Number": - return ast.toCodecStringTree(); - case "Union": - return ast.recur(parameterFromPropertyKey); + +// node_modules/effect/dist/Channel.js +var TypeId12 = "~effect/Channel"; +var isChannel = (u) => hasProperty(u, TypeId12); +var ChannelProto = { + [TypeId12]: { + _Env: identity, + _InErr: identity, + _InElem: identity, + _OutErr: identity, + _OutElem: identity + }, + pipe() { + return pipeArguments(this, arguments); } -}); -var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`); -var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`); -function isStringFinite(annotations) { - return isPattern(isStringFiniteRegExp, { - expected: "a string representing a finite number", - representation: { - id: "effect/schema/isStringFinite", - payload: null - }, - toJsonSchema: () => ({ - pattern: isStringFiniteRegExp.source - }), - ...annotations +}; +var fromTransform = (transform) => { + const self = Object.create(ChannelProto); + self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); + return self; +}; +var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); +var fromPull = (effect) => fromTransform((_, __) => effect); +var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { + const closableScope = forkUnsafe2(scope); + const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); + const pull = yield* onError2(f(upstream, scope, closableScope), onCause); + return onError2(pull, onCause); +})); +var toTransform = (channel) => channel.transform; +var asyncQueue = (scope, f, options) => make9({ + capacity: options?.bufferSize, + strategy: options?.strategy +}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); +var callbackArray = (f, options) => fromTransform((_, scope) => map5(asyncQueue(scope, f, options), takeAll2)); +var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); +var succeed8 = (value) => fromEffect(succeed6(value)); +var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done2())); +var fail7 = (error) => fromPull(succeed6(fail6(error))); +var failCause5 = (cause) => fromPull(failCause3(cause)); +var fromEffect = (effect) => fromPull(sync3(() => { + let done = false; + return suspend2(() => { + if (done) + return done2(); + done = true; + return effect; }); -} -var finiteString = /* @__PURE__ */ appendChecks(string2, [/* @__PURE__ */ isStringFinite()]); -var finiteToString = /* @__PURE__ */ new Link(finiteString, numberFromString); -var numberToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finiteString, nonFiniteLiterals]), numberFromString); -var BIGINT_PATTERN = "-?\\d+"; -var isStringBigIntRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${BIGINT_PATTERN}$`); -var REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"; -var isStringSymbolRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${REGEXP_PATTERN}$`); -function collectIssues(checks, value, issues, ast, options) { - for (let i = 0;i < checks.length; i++) { - const check = checks[i]; - if (check._tag === "FilterGroup") { - issues = collectIssues(check.checks, value, issues, ast, options); - if (issues && (options.errors !== "all" || issues[issues.length - 1].filter.aborted)) { - return issues; +})); +var fromEffectDrain = (effect) => fromPull(flatMap3(effect, () => done2())); +var map6 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { + let i = 0; + return map5(pull, (o) => f(o, i++)); +}))); +var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); +var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done2))))); +var concurrencyIsSequential = (concurrency) => concurrency === undefined || concurrency !== "unbounded" && concurrency <= 1; +var flatMap4 = /* @__PURE__ */ dual((args) => isChannel(args[0]), (self, f, options) => concurrencyIsSequential(options?.concurrency) ? flatMapSequential(self, f) : flatMapConcurrent(self, f, options)); +var flatMapSequential = (self, f) => fromTransform((upstream, scope) => map5(toTransform(self)(upstream, scope), (pull) => { + let childPull; + let childScope; + const makePull = flatMap3(pull, (value) => { + childScope ??= forkUnsafe2(scope); + return flatMapEager2(toTransform(f(value))(upstream, childScope), (pull) => { + childPull = catchHalt(pull); + return childPull; + }); + }); + const catchHalt = catchDone((_) => { + childPull = undefined; + if (childScope.state._tag === "Open" && scopeFinalizerCountUnsafe(childScope) === 1) { + return makePull; + } + const close2 = close(childScope, void_2); + childScope = undefined; + return flatMap3(close2, () => makePull); + }); + return suspend2(() => childPull ?? makePull); +})); +var flatMapConcurrent = (self, f, options) => self.pipe(map6(f), mergeAll3(options)); +var flattenArray = (self) => transformPull(self, (pull) => { + let array; + let index = 0; + const pump = suspend2(function loop() { + if (array === undefined) { + return flatMap3(pull, (array_) => { + switch (array_.length) { + case 0: + return loop(); + case 1: + return succeed6(array_[0]); + default: { + array = array_; + return succeed6(array_[index++]); + } + } + }); + } + const next = array[index++]; + if (index >= array.length) { + array = undefined; + index = 0; + } + return succeed6(next); + }); + return succeed6(pump); +}); +var drain = (self) => transformPull(self, (pull) => succeed6(forever2(pull, { + disableYield: true +}))); +var catchCause3 = /* @__PURE__ */ dual(2, (self, f) => fromTransform((upstream, scope) => { + let forkedScope = forkUnsafe2(scope); + return map5(toTransform(self)(upstream, forkedScope), (pull) => { + let currentPull = pull.pipe(catchCause2((cause) => { + if (isDoneCause(cause)) { + return failCause3(cause); } - } else { - const issue = check.run(value, ast, options); - if (issue) { - const filter = new Filter(check, issue, value, options); - if (issues) - issues.push(filter); - else - issues = [filter]; - if (options.errors !== "all" || check.aborted) { - return issues; + const toClose = forkedScope; + forkedScope = forkUnsafe2(scope); + return close(toClose, failCause2(cause)).pipe(andThen2(toTransform(f(cause))(upstream, forkedScope)), flatMap3((childPull) => { + currentPull = childPull; + return childPull; + })); + })); + return suspend2(() => currentPull); + }); +})); +var catchCauseFilter2 = /* @__PURE__ */ dual(3, (self, filter, f) => catchCause3(self, (cause) => { + const result = filter(cause); + return isFailure2(result) ? failCause5(result.failure) : f(result.success, cause); +})); +var catch_3 = /* @__PURE__ */ dual(2, (self, f) => catchCauseFilter2(self, findError2, (e) => f(e))); +var mapError4 = /* @__PURE__ */ dual(2, (self, f) => catch_3(self, (err) => fail7(f(err)))); +var mergeAll3 = /* @__PURE__ */ dual(2, (channels, { + bufferSize = 16, + concurrency, + switch: switch_ = false +}) => fromTransformBracket(fnUntraced2(function* (upstream, scope, forkedScope) { + const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : Math.max(1, concurrency); + const semaphore = switch_ ? undefined : makeUnsafe5(concurrencyN); + const doneLatch = yield* make6(true); + const fibers = new Set; + const queue = yield* bounded(bufferSize); + yield* addFinalizer2(forkedScope, shutdown(queue)); + const pull = yield* toTransform(channels)(upstream, scope); + yield* gen2(function* () { + while (true) { + let pullFiber; + if (semaphore) { + if (fibers.size < concurrencyN) { + yield* semaphore.take(1); + } else { + pullFiber = yield* forkChild2(pull); + yield* raceFirst2(semaphore.take(1), andThen2(join(pullFiber), never2)); } } + const channel = pullFiber === undefined ? yield* pull : yield* join(pullFiber); + const childScope = forkUnsafe2(forkedScope); + const childPull = yield* toTransform(channel)(upstream, childScope); + while (fibers.size >= concurrencyN) { + const fiber = headUnsafe(fibers); + fibers.delete(fiber); + if (fibers.size === 0) + yield* doneLatch.open; + yield* interrupt3(fiber); + } + const fiber = yield* childPull.pipe(tap2(() => yieldNow2), flatMap3((value) => offer(queue, value)), forever2({ + disableYield: true + }), onError2(fnUntraced2(function* (cause) { + const halt = filterDone(cause); + yield* exit2(close(childScope, !isFailure2(halt) ? succeed4(halt.success.value) : failCause2(halt.failure))); + if (!fibers.has(fiber)) + return; + fibers.delete(fiber); + if (semaphore) + yield* semaphore.release(1); + if (fibers.size === 0) + yield* doneLatch.open; + if (isSuccess2(halt)) + return; + return yield* failCause4(queue, cause); + })), forkChild2); + doneLatch.closeUnsafe(); + fibers.add(fiber); + } + }).pipe(catchCause2((cause) => { + const halt = filterDone(cause); + if (isSuccess2(halt)) { + return doneLatch.whenOpen(failCause4(queue, cause)); + } + return failCause4(queue, cause); + }), forkIn2(forkedScope)); + return take2(queue); +}))); +var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { + const strategy = options?.haltStrategy ?? "both"; + const queue = yield* bounded(0); + yield* addFinalizer2(forkedScope, shutdown(queue)); + let done = 0; + function onExit(side, cause) { + done++; + if (!isDoneCause(cause)) { + return failCause4(queue, cause); + } + switch (strategy) { + case "both": { + return done === 2 ? failCause4(queue, cause) : void_3; + } + case "left": + case "right": { + return side === strategy ? failCause4(queue, cause) : void_3; + } + case "either": { + return failCause4(queue, cause); + } } } - return issues; -} -function getConstructorDescriptor(ast) { - if (!isDeclaration(ast)) - return; - const getDescriptor = ast.annotations?.[CONSTRUCTOR_ANNOTATION_KEY]; - return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; -} -function isJsonLeaf(u) { - return u === null || typeof u === "string" || typeof u === "boolean" || typeof u === "number" && globalThis.Number.isFinite(u); -} -function isStringTreeLeaf(u) { - return u === undefined || typeof u === "string"; -} -function isTree(u, isLeaf) { - const cache = new WeakMap; - const stack = []; - outer: - while (true) { - if (typeof u !== "object" || u === null) { - if (!isLeaf(u)) { - return false; - } + const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); + yield* runSide("left", left, forkUnsafe2(forkedScope)); + yield* runSide("right", right, forkUnsafe2(forkedScope)); + return take2(queue); +}))); +var mergeEffect = /* @__PURE__ */ dual(2, (self, effect) => merge2(self, fromEffectDrain(effect), { + haltStrategy: "left" +})); +var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { + let stringBuilder = ""; + let midCRLF = false; + let done = none2(); + function splitLinesArray(chunk) { + const chunkBuilder = []; + function pushLine(segment) { + if (stringBuilder.length === 0) { + chunkBuilder.push(segment); } else { - const value = u; - const cached = cache.get(value); - if (cached === false) { - return false; - } - if (cached === undefined) { - const isArray = Array.isArray(value); - if (!isArray) { - const prototype = Object.getPrototypeOf(value); - if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) { - return false; - } - } - cache.set(value, false); - stack.push({ - value, - keys: isArray ? value.length : Object.keys(value), - index: 0 - }); - } + chunkBuilder.push(stringBuilder + segment); + stringBuilder = ""; } - while (stack.length > 0) { - const frame = stack[stack.length - 1]; - const keys = frame.keys; - if (typeof keys === "number") { - if (frame.index < keys) { - u = frame.value[frame.index++]; - continue outer; + } + for (let i = 0;i < chunk.length; i++) { + const str = chunk[i]; + if (str.length !== 0) { + let from = 0; + let indexOfCR = str.indexOf("\r"); + let indexOfLF = str.indexOf(` +`); + if (midCRLF) { + if (indexOfLF === 0) { + from = 1; + indexOfLF = str.indexOf(` +`, from); } - } else if (frame.index < keys.length) { - u = frame.value[keys[frame.index++]]; - continue outer; + midCRLF = false; } - cache.set(frame.value, true); - stack.pop(); - } - return true; - } -} -function isJson(u) { - return isTree(u, isJsonLeaf); -} -var Json = /* @__PURE__ */ new Declaration([], () => (input, ast, options) => isJson(input) ? sameExit : fail6(new InvalidType(ast, input, options)), { - representation: { - id: "effect/schema/Json", - payload: null - }, - expected: "JSON value", - toCodecJson: () => { - return; - }, - toCodecStringTree: () => unknownToStringTree -}); -function isStringTree(u) { - return isTree(u, isStringTreeLeaf); -} -var StringTree = /* @__PURE__ */ new Declaration([], () => (input, ast, options) => isStringTree(input) ? sameExit : fail6(new InvalidType(ast, input, options)), { - expected: "StringTree", - toCodecStringTree: () => { - return; - } -}); -var unknownToStringTree = /* @__PURE__ */ new Link(StringTree, /* @__PURE__ */ passthrough2()); - -// node_modules/effect/dist/SchemaParser.js -function makeEffect(schema) { - const ast = schema.ast; - let parser; - return (input, options) => { - return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { - ...options.parseOptions, - disableChecks: true - } : { - disableChecks: true - } : options?.parseOptions); - }; -} -function makeOption(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return some2(exit.value); + while (indexOfCR !== -1 || indexOfLF !== -1) { + if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { + pushLine(str.substring(from, indexOfLF)); + from = indexOfLF + 1; + indexOfLF = str.indexOf(` +`, from); + } else { + pushLine(str.substring(from, indexOfCR)); + if (str.length === indexOfCR + 1) { + midCRLF = true; + from = str.length; + indexOfCR = -1; + } else { + from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); + indexOfCR = str.indexOf("\r", from); + indexOfLF = str.indexOf(` +`, from); + } + } + } + stringBuilder = stringBuilder + str.substring(from); + } } - getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); - return none2(); - }; -} -function make15(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return exit.value; + return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; + } + const pullOrFlush = suspend2(() => { + if (done._tag === "Some") { + return done2(done.value); } - const issue = getSchemaIssueOrThrow(exit.cause, "Constructor adapter can only throw schema issues"); - throw new Error("Schema validation failed", { - cause: issue + return matchEffect2(upstream, { + onSuccess: loop, + onFailure: failCause3, + onDone: (leftover) => { + done = some2(leftover); + if (stringBuilder.length > 0) { + const last = stringBuilder; + stringBuilder = ""; + midCRLF = false; + return succeed6([last]); + } + return done2(leftover); + } }); - }; -} -function is2(schema) { - return _is(schema.ast); -} -function _is(ast) { - const parser = asExit(run2(toType(ast))); - return (input) => { - const exit = parser(input, defaultParseOptions); - if (isSuccess3(exit)) { - return true; + }); + function loop(chunk) { + const lines = splitLinesArray(chunk); + return lines !== null ? succeed6(lines) : pullOrFlush; + } + return pullOrFlush; +})); +var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); +var unwrap = (channel) => fromTransform((upstream, scope) => { + let pull; + return succeed6(suspend2(() => { + if (pull) + return pull; + return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); + })); +}); +var runWith = (self, f, onHalt) => suspend2(() => { + const scope = makeUnsafe3(); + const makePull = toTransform(self)(done2(), scope); + return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); +}); +var runDrain = (self) => runWith(self, (pull) => forever2(pull, { + disableYield: true +})); +var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { + disableYield: true +}))); +var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { + let state = initial(); + return runWith(self, (pull) => whileLoop2({ + while: constTrue, + body: () => pull, + step: (value) => { + state = f(state, value); } - getSchemaIssueOrThrow(exit.cause, "Type guard adapter can only return false for schema issues"); - return false; - }; -} -function decodeUnknownEffect(schema, options) { - const parser = run2(schema.ast); - return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); -} -var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { - ...options, - ...overrideOptions -} : options; -var getValue = (value) => { - if (value === missing) { - return fail6(new InvalidValue); + }), () => succeed6(state)); +})); +var toPullScoped = (self, scope) => toTransform(self)(done2(), scope); +// node_modules/effect/dist/internal/schema/interpreter.js +var flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager2(result, f); +function compileTransformation(transformation) { + if (transformation._tag === "Middleware") { + return (result, current, options) => { + const transformed = result === sameExit ? transformation.decode(succeed7(toOption(current)), options) : transformation.decode(mapEager2(result, toOption), options); + return fromOptionalEffect(transformed); + }; } - return succeed6(value); -}; -function run2(ast) { - return runWithCompiler(normalCompiler, ast); -} -function runWithCompiler(compiler, ast) { - let parser; - return (input, options) => { - const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); - if (result === sameExit) { - return succeed6(input); + const getter = transformation.decode; + switch (getter._tag) { + case "Passthrough": + return (result, current) => result === sameExit ? succeed7(current) : result; + case "Transform": { + const transform = (value) => value === missing ? missingExit : succeed7(getter.transform(value)); + return (result, current) => flatMapTransformation(result, current, transform); } - if (!effectIsExit(result)) { - return flatMapEager2(result, getValue); + case "TransformOptional": { + const transform = (value) => fromOptionExit(getter.transform(toOption(value))); + return (result, current) => flatMapTransformation(result, current, transform); } - return result[args] === missing ? getValue(missing) : result; - }; -} -function asExit(parser) { - return (input, options) => runSyncExit2(parser(input, options)); -} -var normalCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, normalCompiler)); -var constructorCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault)); -var compileDefaulted = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault, ast.context?.constructorDefault)); -function compileConstructorDefault(ast) { - return ast.context?.constructorDefault ? compileDefaulted(ast) : constructorCompiler(ast); -} -function applyTransformation(result, current, transformation, options) { - let transformed; - if (effectIsExit(result) && result._tag === "Success") { - const optional = toOption(result === sameExit ? current : result[args]); - transformed = transformation._tag === "Transformation" ? transformation.decode.run(optional, options) : transformation.decode(succeed9(optional), options); - } else if (transformation._tag === "Transformation") { - transformed = flatMapEager2(result, (value) => transformation.decode.run(toOption(value), options)); - } else { - transformed = transformation.decode(mapEager2(result, toOption), options); + case "TransformEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => value === missing ? missingExit : getter.transform(value, options)); + case "TransformOptionalEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => fromOptionalEffect(getter.transform(toOption(value), options))); } - return effectIsExit(transformed) && transformed._tag === "Success" ? fromOptionExit(transformed[args]) : flatMapEager2(transformed, fromOptionExit); } +var fromOptionalEffect = (effect) => flatMapEager2(effect, fromOptionExit); +var wrapEncoding = (ast, input, options, effect) => catchCause2(effect, (cause) => failCauseSync2(() => map4(cause, (issue) => new Encoding(ast, issue, input, options)))); function makeConstructorParser(descriptor, compile) { + const transform = compileTransformation(descriptor.link.transformation); let sourceParser; return (input, options) => { if (input === missing) @@ -8161,20 +7587,45 @@ function makeConstructorParser(descriptor, compile) { if (descriptor.isConstructed(input)) return sameExit; const result = (sourceParser ??= compile(descriptor.link.to))(input, options); - return applyTransformation(result, input, descriptor.link.transformation, options); + return transform(result, input, options); + }; +} +function withDefault(ast, parser) { + const defaultValue = ast.context.constructorDefault; + return (input, options) => { + if (input !== missing && input !== undefined) + return parser(input, options); + const result = defaultValue; + if (effectIsExit(result) && result._tag === "Success") { + const local = parser(result[args], options); + return local === sameExit ? result : local; + } + return flatMapEager2(wrapEncoding(ast, input, options, result), (value) => { + const local = parser(value, options); + return local === sameExit ? succeed7(value) : local; + }); }; } -function makeParser(ast, compile, compileConstructorDefault, constructorDefault) { - const descriptor = compileConstructorDefault ? getConstructorDescriptor(ast) : undefined; - const parser = descriptor ? makeConstructorParser(descriptor, compile) : ast.getParser(compile, compileConstructorDefault); +function compileField(ast, compile) { + const parser = compile(ast); + return ast.context?.constructorDefault === undefined ? parser : withDefault(ast, parser); +} +function compile(ast, compile, compileField, base, specialize) { + if (ast._tag === "Declaration") { + for (const parameter of ast.typeParameters) + compile(parameter); + } + const descriptor = compileField ? getConstructorDescriptor(ast) : undefined; + const parser = descriptor ? makeConstructorParser(descriptor, compile) : base ?? ast.getParser(compile, compileField); const checks = ast.checks; - const links = constructorDefault ? ast.encoding ? [...ast.encoding, constructorDefault] : [constructorDefault] : ast.encoding; + const links = ast.encoding; + const transformations = links?.map((link) => compileTransformation(link.transformation)); const encodingChecks = ast.encodingChecks; if (!links && !checks && !encodingChecks) { return parser; } let encodingParsers; - const parseLocal = (input, options) => { + const parseChecks = (input, options) => { let result = parser(input, options); if (encodingChecks && !options.disableChecks) { if (effectIsExit(result)) { @@ -8224,6 +7675,7 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) } return result; }; + const parseLocal = specialize === undefined ? parseChecks : specialize(parseChecks); if (!links) { return parseLocal; } @@ -8232,7 +7684,7 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) let current = input; let result = parsers[parsers.length - 1](input, options); for (let i = links.length - 1;i >= 0; i--) { - result = applyTransformation(result, current, links[i].transformation, options); + result = transformations[i](result, current, options); if (i !== 0) { const next = parsers[i - 1]; if (result._tag === "Success") { @@ -8241,28 +7693,281 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) } else { result = flatMapEager2(result, (value) => { const nextResult = next(value, options); - return nextResult === sameExit ? succeed9(value) : nextResult; + return nextResult === sameExit ? succeed7(value) : nextResult; }); } } } - if (result._tag === "Success") { - const value = result[args]; - const local = parseLocal(value, options); - return local === sameExit ? result : local; - } - result = catchCause2(result, (cause) => failCauseSync2(() => map5(cause, (issue) => new Encoding(ast, issue, input, options)))); - return flatMapEager2(result, (value) => { - const local = parseLocal(value, options); - return local === sameExit ? succeed9(value) : local; - }); + if (result._tag === "Success") { + const value = result[args]; + const local = parseLocal(value, options); + return local === sameExit ? result : local; + } + result = wrapEncoding(ast, input, options, result); + return flatMapEager2(result, (value) => { + const local = parseLocal(value, options); + return local === sameExit ? succeed7(value) : local; + }); + }; +} + +// node_modules/effect/dist/internal/schema/compilerRegistry.js +var invalid3 = /* @__PURE__ */ Symbol(); +var cache = /* @__PURE__ */ new WeakMap; +var compiler; +var compilerAdaptersEnabled = false; +var decodeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "parser") : resolve2(ast).parser; +var makeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "makeEffect") : resolve2(ast).makeEffect; +var makeField = (ast) => compileField(ast, makeChild); + +class InterpretedEntry { + ast; + constructor(ast) { + this.ast = ast; + } + get decodeEffect() { + return this.cachedDecodeEffect ??= compile(this.ast, decodeChild); + } + get parser() { + return this.decodeEffect; + } + get makeEffect() { + return this.cachedMakeEffect ??= compile(this.ast, makeChild, makeField); + } +} + +class CompilerEntry extends InterpretedEntry { + compiled; + resolve; + constructor(ast, compiled, resolve) { + super(ast); + this.compiled = compiled; + this.resolve = resolve; + } + save(key, value) { + Object.defineProperty(this, key, { + value + }); + return value; + } + operation(key) { + const compiled = this.compiled; + return typeof compiled === "function" ? compiled(this.ast, this.resolve, key) : compiled?.[key]; + } + get is() { + return this.save("is", this.operation("is")); + } + get decode() { + return this.save("decode", this.operation("decode")); + } + get make() { + return this.save("make", this.operation("make")); + } + get decodeEffect() { + return this.save("decodeEffect", this.operation("decodeEffect") ?? compile(this.ast, (ast) => lazyParser(this.resolve, ast, "parser"))); + } + get parser() { + const decode = this.decode; + return decode === undefined ? this.decodeEffect : this.save("parser", withDecode(decode, () => this.decodeEffect)); + } + get makeEffect() { + const makeEffect = this.operation("makeEffect"); + if (makeEffect !== undefined) + return this.save("makeEffect", makeEffect); + const child = (ast) => lazyParser(this.resolve, ast, "makeEffect"); + return this.save("makeEffect", compile(this.ast, child, (ast) => compileField(ast, child))); + } +} +function withDecode(fastDecode, decodeEffect) { + let detailed; + return (input, options) => { + if (input !== missing) { + try { + const value = fastDecode(input, options); + if (value !== invalid3) + return value === input ? sameExit : succeed7(value); + } catch (error) { + return die3(error); + } + } + return (detailed ??= decodeEffect())(input, options); + }; +} +function lazyParser(resolve, ast, operation) { + const entry = resolve(ast); + if (entry.compiled === undefined || Object.hasOwn(entry, operation)) { + return entry[operation]; + } + let parser; + return (input, options) => (parser ??= entry[operation])(input, options); +} +function resolve2(ast) { + const cached = cache.get(ast); + if (cached !== undefined) + return cached; + const entry = compiler === undefined ? new InterpretedEntry(ast) : new CompilerEntry(ast, compiler(ast, resolve2), resolve2); + cache.set(ast, entry); + return entry; +} + +// node_modules/effect/dist/SchemaParser.js +function makeEffect(schema) { + const ast = schema.ast; + let parser; + return (input, options) => { + return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions); + }; +} +function makeOption(schema) { + const parser = makeEffect(schema); + return (input, options) => { + const exit = runSyncExit2(parser(input, options)); + if (isSuccess3(exit)) { + return some2(exit.value); + } + getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); + return none2(); + }; +} +function make10(schema) { + return makeConstructorSync(toType(schema.ast)); +} +function is(schema) { + return _is(schema.ast); +} +function makeIs(ast) { + if (!compilerAdaptersEnabled) { + const parser = asExit(run(ast)); + return (input) => { + const exit = parser(input, defaultParseOptions); + if (isSuccess3(exit)) + return true; + getSchemaIssueOrThrow(exit.cause, "Type guard adapter can only return false for schema issues"); + return false; + }; + } + const entry = resolve2(ast); + const guard = entry.is; + if (guard !== undefined) { + return (input) => { + try { + return guard(input, defaultParseOptions); + } catch (error) { + getSchemaIssueOrThrow(die2(error), "Type guard adapter can only return false for schema issues"); + return false; + } + }; + } + const parser = entry.parser; + return (input) => { + const exit = runSyncExit2(parserResult(parser(input, defaultParseOptions), input)); + if (isSuccess3(exit)) + return true; + getSchemaIssueOrThrow(exit.cause, "Type guard adapter can only return false for schema issues"); + return false; + }; +} +function _is(ast) { + const typeAST = toType(ast); + let guard = (input) => { + guard = makeIs(typeAST); + return guard(input); + }; + return (input) => { + return guard(input); + }; +} +function decodeUnknownEffect(schema, options) { + const parser = run(schema.ast); + return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); +} +var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { + ...options, + ...overrideOptions +} : options; +var getValue = (value) => { + if (value === missing) { + return fail6(new InvalidValue); + } + return succeed6(value); +}; +function run(ast) { + return runWithCompiler(normalCompiler, ast); +} +function parserResult(result, input) { + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; +} +function runWithCompiler(compiler, ast) { + let parser; + return (input, options) => { + const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; + }; +} +function asExit(parser) { + return (input, options) => runSyncExit2(parser(input, options)); +} +function runSync2(effect, message) { + const exit = runSyncExit2(effect); + if (isSuccess3(exit)) { + return exit.value; + } + const issue = getSchemaIssueOrThrow(exit.cause, message); + throw new Error("Schema validation failed", { + cause: issue + }); +} +function makeConstructorSync(ast) { + let entry; + let parser; + return (input, options) => { + entry ??= resolve2(ast); + const parseOptions = options?.disableChecks ? options.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions ?? defaultParseOptions; + const make = entry.make; + if (make !== undefined && input !== missing) { + let output; + try { + output = make(input, parseOptions); + } catch (error) { + getSchemaIssueOrThrow(die2(error), "Constructor adapter can only throw schema issues"); + throw error; + } + if (output !== invalid3 && output !== missing) + return output; + } + const result = (parser ??= entry.makeEffect)(input, parseOptions); + return runSync2(parserResult(result, input), "Constructor adapter can only throw schema issues"); }; } +var normalCompiler = (ast) => resolve2(ast).parser; +var constructorCompiler = (ast) => resolve2(ast).makeEffect; // node_modules/effect/dist/internal/schema/make.js -var TypeId21 = "~effect/Schema/Schema"; +var TypeId13 = "~effect/Schema/Schema"; var SchemaProto = { - [TypeId21]: TypeId21, + [TypeId13]: TypeId13, pipe() { return pipeArguments(this, arguments); }, @@ -8276,7 +7981,7 @@ var SchemaProto = { return this.rebuild(appendChecks(this.ast, checks)); } }; -function make16(ast, options) { +function make11(ast, options) { function Schema() {} const self = Object.setPrototypeOf(Schema, SchemaProto); if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) { @@ -8287,9 +7992,9 @@ function make16(ast, options) { Object.assign(self, options); } self.ast = ast; - self.rebuild = (ast) => make16(ast, options); + self.rebuild = (ast) => make11(ast, options); self.makeEffect = makeEffect(self); - self.make = make15(self); + self.make = make10(self); self.makeOption = makeOption(self); return self; } @@ -8304,10 +8009,10 @@ function isSchemaError(u) { } // node_modules/effect/dist/Schema.js -var TypeId22 = TypeId21; +var TypeId14 = TypeId13; function declareConstructor() { return (typeParameters, run, annotations) => { - return make17(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make17(ast))), annotations)); + return make12(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make12(ast))), annotations)); }; } function declare(is, annotations) { @@ -8340,10 +8045,10 @@ function fromIssueEffect(self) { if (effectIsExit(self)) { return fromIssueExit(self); } - return catchCause2(self, (cause) => failCauseSync2(() => map5(cause, (issue) => new SchemaError(issue)))); + return catchCause2(self, (cause) => failCauseSync2(() => map4(cause, (issue) => new SchemaError(issue)))); } function fromIssueExit(exit) { - return isSuccess3(exit) ? exit : failCause2(map5(exit.cause, (issue) => new SchemaError(issue))); + return isSuccess3(exit) ? exit : failCause2(map4(exit.cause, (issue) => new SchemaError(issue))); } function decodeUnknownEffect2(schema, options) { const parser = decodeUnknownEffect(schema, options); @@ -8352,18 +8057,18 @@ function decodeUnknownEffect2(schema, options) { }; } var decodeEffect2 = decodeUnknownEffect2; -var make17 = make16; +var make12 = make11; function isSchema(u) { - return hasProperty(u, TypeId22) && u[TypeId22] === TypeId22; + return hasProperty(u, TypeId14) && u[TypeId14] === TypeId14; } -var optionalKey2 = /* @__PURE__ */ lambda((schema) => make17(optionalKey(schema.ast), { +var optionalKey2 = /* @__PURE__ */ lambda((schema) => make12(optionalKey(schema.ast), { schema })); -var toType2 = /* @__PURE__ */ lambda((schema) => make17(toType(schema.ast), { +var toType2 = /* @__PURE__ */ lambda((schema) => make12(toType(schema.ast), { schema })); function Literal2(literal) { - const out = make17(new Literal(literal), { + const out = make12(new Literal(literal), { literal, transform(to) { return out.pipe(decodeTo2(Literal2(to), { @@ -8374,12 +8079,12 @@ function Literal2(literal) { }); return out; } -var Unknown2 = /* @__PURE__ */ make17(unknown); -var String4 = /* @__PURE__ */ make17(string2); -var Number5 = /* @__PURE__ */ make17(number2); -var Boolean2 = /* @__PURE__ */ make17(boolean); +var Unknown2 = /* @__PURE__ */ make12(unknown); +var String4 = /* @__PURE__ */ make12(string2); +var Number5 = /* @__PURE__ */ make12(number2); +var Boolean2 = /* @__PURE__ */ make12(boolean); function makeStruct(ast, fields) { - return make17(ast, { + return make12(ast, { fields, mapFields(f, options) { const fields = f(this.fields); @@ -8391,7 +8096,7 @@ function Struct(fields) { return makeStruct(struct(fields, undefined), fields); } function makeTuple(ast, elements) { - return make17(ast, { + return make12(ast, { elements, mapElements(f, options) { const elements = f(this.elements); @@ -8402,11 +8107,11 @@ function makeTuple(ast, elements) { function Tuple(elements) { return makeTuple(tuple(elements), elements); } -var ArraySchema = /* @__PURE__ */ lambda((schema) => make17(new Arrays(false, [], [schema.ast]), { +var ArraySchema = /* @__PURE__ */ lambda((schema) => make12(new Arrays(false, [], [schema.ast]), { value: schema })); function makeUnion(ast, members) { - return make17(ast, { + return make12(ast, { members, mapMembers(f, options) { const members = f(this.members); @@ -8419,7 +8124,7 @@ function Union2(members, options) { } function Literals(literals) { const members = literals.map(Literal2); - return make17(union(members, undefined, undefined), { + return make12(union(members, undefined, undefined), { literals, members, mapMembers(f) { @@ -8435,23 +8140,23 @@ function Literals(literals) { } function decodeTo2(to, transformation) { return (from) => { - return make17(decodeTo(from.ast, to.ast, transformation ? make14(transformation) : passthrough2()), { + return make12(decodeTo(from.ast, to.ast, transformation ? makeTransformation(transformation) : passthrough2()), { from, to }); }; } function withConstructorDefault2(defaultValue) { - return (schema) => make17(withConstructorDefault(schema.ast, defaultValue), { + return (schema) => make12(withConstructorDefault(schema.ast, defaultValue), { schema }); } -function tag3(literal) { +function tag(literal) { return Literal2(literal).pipe(withConstructorDefault2(succeed6(literal))); } function TaggedStruct(value, fields) { return Struct({ - _tag: tag3(value), + _tag: tag(value), ...fields }); } @@ -8487,7 +8192,7 @@ function toTaggedUnion(tag) { discriminantKeys.add(key); discriminants.push(literal); assignProperty(cases, literal, schema); - assignProperty(guards, literal, is2(toType2(schema))); + assignProperty(guards, literal, is(toType2(schema))); return; } } @@ -8542,7 +8247,7 @@ function TaggedUnion(casesByTag) { match, matchOrElse } = toTaggedUnion("_tag")(union); - return make17(union.ast, { + return make12(union.ast, { cases, isAnyOf, guards, @@ -8550,12 +8255,12 @@ function TaggedUnion(casesByTag) { matchOrElse }); } -function instanceOf2(constructor, annotations) { +function instanceOf(constructor, annotations) { return declare((u) => u instanceof constructor, annotations); } function link() { return (encodeTo, transformation) => { - return new Link(encodeTo.ast, make14(transformation)); + return new Link(encodeTo.ast, makeTransformation(transformation)); }; } var makeFilter2 = makeFilter; @@ -8587,7 +8292,7 @@ function isBase64(annotations) { ...annotations }); } -var Finite = /* @__PURE__ */ make17(finite); +var Finite = /* @__PURE__ */ make12(finite); function isInt(annotations) { return makeFilter2((n) => globalThis.Number.isSafeInteger(n), { expected: "an integer", @@ -8639,7 +8344,7 @@ function Defect(options) { defectSchemaCache[key] = schema; return schema; } -var RegExp2 = /* @__PURE__ */ instanceOf2(globalThis.RegExp, { +var RegExp2 = /* @__PURE__ */ instanceOf(globalThis.RegExp, { representation: { id: "effect/schema/RegExp", payload: null @@ -8668,7 +8373,7 @@ var RegExp2 = /* @__PURE__ */ instanceOf2(globalThis.RegExp, { var URLString = /* @__PURE__ */ String4.annotate({ expected: "a string that will be decoded as a URL" }); -var URL2 = /* @__PURE__ */ instanceOf2(globalThis.URL, { +var URL2 = /* @__PURE__ */ instanceOf(globalThis.URL, { representation: { id: "effect/schema/URL", payload: null @@ -8687,7 +8392,7 @@ var JsonString = /* @__PURE__ */ String4.annotate({ function fromJsonString2(schema, options) { return JsonString.pipe(decodeTo2(schema, fromJsonString(options))); } -var File = /* @__PURE__ */ instanceOf2(globalThis.File, { +var File = /* @__PURE__ */ instanceOf(globalThis.File, { representation: { id: "effect/schema/File", payload: null @@ -8703,7 +8408,7 @@ var File = /* @__PURE__ */ instanceOf2(globalThis.File, { name: String4, lastModified: Int }), transformEffect2({ - decode: (e, options) => match3(decodeBase64(e.data), { + decode: (e, options) => match2(decodeBase64(e.data), { onFailure: () => fail6(new InvalidValue({ expected: "a valid Base64 string" }, e.data, options)), @@ -8731,7 +8436,7 @@ var File = /* @__PURE__ */ instanceOf2(globalThis.File, { }) })) }); -var FormData2 = /* @__PURE__ */ instanceOf2(globalThis.FormData, { +var FormData2 = /* @__PURE__ */ instanceOf(globalThis.FormData, { representation: { id: "effect/schema/FormData", payload: null @@ -8742,10 +8447,10 @@ var FormData2 = /* @__PURE__ */ instanceOf2(globalThis.FormData, { }), expected: "FormData", toCodecJson: () => link()(ArraySchema(Tuple([String4, Union2([Struct({ - _tag: tag3("String"), + _tag: tag("String"), value: String4 }), Struct({ - _tag: tag3("File"), + _tag: tag("File"), value: File })])])), transformEffect2({ decode: (e) => { @@ -8772,7 +8477,7 @@ var FormData2 = /* @__PURE__ */ instanceOf2(globalThis.FormData, { } })) }); -var URLSearchParams2 = /* @__PURE__ */ instanceOf2(globalThis.URLSearchParams, { +var URLSearchParams2 = /* @__PURE__ */ instanceOf(globalThis.URLSearchParams, { representation: { id: "effect/schema/URLSearchParams", payload: null @@ -8794,7 +8499,7 @@ var Base64String = /* @__PURE__ */ String4.annotate({ format: "byte", contentEncoding: "base64" }); -var Uint8Array2 = /* @__PURE__ */ instanceOf2(globalThis.Uint8Array, { +var Uint8Array2 = /* @__PURE__ */ instanceOf(globalThis.Uint8Array, { representation: { id: "effect/schema/Uint8Array", payload: null @@ -8831,7 +8536,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { } }); } - static [TypeId22] = TypeId22; + static [TypeId14] = TypeId14; get [ClassTypeId]() { return ClassTypeId; } @@ -8848,7 +8553,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { return getClassSchema(this).rebuild(ast); } static make(input, options) { - return make15(getClassSchema(this))(input ?? {}, options); + return make10(getClassSchema(this))(input ?? {}, options); } static makeOption(input, options) { return makeOption(getClassSchema(this))(input ?? {}, options); @@ -8907,7 +8612,7 @@ function getClassSchemaFactory(from, identifier, annotations) { const ClassTypeId = getClassTypeId(identifier); const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId); const transformation = getClassTransformation(self); - const to = make17(new Declaration([from.ast], () => (input, ast, options) => { + const to = make12(new Declaration([from.ast], () => (input, ast, options) => { return isClassValue(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)); }, { identifier, @@ -8937,7 +8642,7 @@ var Error4 = (identifier) => (schema, annotations) => { var TaggedError3 = (identifier) => { return (tagValue, schema, annotations) => { const struct = isStruct(schema) ? schema.mapFields((fields) => ({ - _tag: tag3(tagValue), + _tag: tag(tagValue), ...fields }), { unsafePreserveChecks: true @@ -8945,385 +8650,352 @@ var TaggedError3 = (identifier) => { return Error4(identifier ?? tagValue)(struct, annotations); }; }; -var Json2 = /* @__PURE__ */ make17(/* @__PURE__ */ annotate(Json, { +var Json2 = /* @__PURE__ */ make12(/* @__PURE__ */ annotate(Json, { toCode: () => ({ runtime: "Schema.Json", Type: "Schema.Json" }) })); -// node_modules/effect/dist/Brand.js -function nominal() { - return Object.assign((input) => input, { - option: (input) => some2(input), - result: (input) => succeed2(input), - is: (_) => true - }); -} +// node_modules/effect/dist/PlatformError.js +var TypeId15 = "~effect/PlatformError"; -// node_modules/effect/dist/unstable/process/ChildProcessSpawner.js -var ExitCode = /* @__PURE__ */ nominal(); -var ProcessId = /* @__PURE__ */ nominal(); -var HandleTypeId = "~effect/process/ChildProcessSpawner/ChildProcessHandle"; -var HandleProto = { - [HandleTypeId]: HandleTypeId, - ...BaseProto, - toJSON() { - return { - _id: "ChildProcessHandle", - pid: this.pid - }; +class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { + get message() { + return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; } -}; -var makeHandle = (params) => Object.setPrototypeOf({ - ...params -}, HandleProto); -var make18 = (spawn) => { - const streamString = (command, options) => spawn(command).pipe(map6((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); - const streamLines = (command, options) => splitLines2(streamString(command, options)); - return ChildProcessSpawner.of({ - spawn, - exitCode: (command) => scoped2(flatMap3(spawn(command), (handle) => handle.exitCode)), - streamString, - streamLines, - lines: (command, options) => runCollect(streamLines(command, options)), - string: (command, options) => mkString(streamString(command, options)) - }); -}; +} -class ChildProcessSpawner extends (/* @__PURE__ */ Service()("effect/process/ChildProcessSpawner")) { +class SystemError extends Error3 { + get message() { + return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; + } } -// node_modules/effect/dist/unstable/process/ChildProcess.js -var TypeId23 = "~effect/process/ChildProcess"; -var Proto2 = { - .../* @__PURE__ */ Prototype2({ - label: "Command", - evaluate(fiber) { - return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this); +class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { + constructor(reason) { + if ("cause" in reason) { + super({ + reason, + cause: reason.cause + }); + } else { + super({ + reason + }); } - }), - [TypeId23]: TypeId23 -}; -var makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto2), { - _tag: "StandardCommand", - command, - args, - options -}); -var make19 = function make(...args) { - if (isTemplateString(args[0])) { - const [templates, ...expressions] = args; - const tokens = parseTemplates(templates, expressions); - return makeStandardCommand(tokens[0] ?? "", tokens.slice(1), {}); } - if (typeof args[0] === "object" && !Array.isArray(args[0]) && !isTemplateString(args[0])) { - const options = args[0]; - return function(templates, ...expressions) { - const tokens = parseTemplates(templates, expressions); - return makeStandardCommand(tokens[0] ?? "", tokens.slice(1), options); - }; - } - if (typeof args[0] === "string" && !Array.isArray(args[1])) { - const [command, options = {}] = args; - return makeStandardCommand(command, [], options); + [TypeId15] = TypeId15; + get message() { + return this.reason.message; } - const [command, cmdArgs = [], options = {}] = args; - return makeStandardCommand(command, cmdArgs, options); +} +var systemError = (options) => new PlatformError(new SystemError(options)); +var badArgument = (options) => new PlatformError(new BadArgument(options)); + +// node_modules/effect/dist/internal/stream.js +var TypeId16 = "~effect/Stream"; +var streamVariance = { + _R: identity, + _E: identity, + _A: identity }; -var isTemplateString = (u) => Array.isArray(u) && ("raw" in u) && Array.isArray(u.raw); -var parseFdName = (name) => { - const match = /^fd(\d+)$/.exec(name); - if (match === null) - return; - const fd = parseInt(match[1], 10); - return fd >= 3 ? fd : undefined; +var Stream = function(channel) { + this.channel = channel; }; -var fdName = (fd) => `fd${fd}`; -var parseTemplates = (templates, expressions) => { - let tokens = []; - for (const [index, template] of templates.entries()) { - tokens = parseTemplate(templates, expressions, tokens, template, index); +Stream.prototype = { + [TypeId16]: streamVariance, + pipe() { + return pipeArguments(this, arguments); } - return tokens; }; -var parseTemplate = (templates, expressions, prevTokens, template, index) => { - const rawTemplate = templates.raw[index]; - if (rawTemplate === undefined) { - throw new Error(`Invalid backslash sequence: ${templates.raw[index]}`); - } - const { - hasLeadingWhitespace, - hasTrailingWhitespace, - tokens - } = splitByWhitespaces(template, rawTemplate); - const nextTokens = concatTokens(prevTokens, tokens, hasLeadingWhitespace); - if (index === expressions.length) { - return nextTokens; - } - const expression = expressions[index]; - const expressionTokens = Array.isArray(expression) ? expression.map((expression) => parseExpression(expression)) : [parseExpression(expression)]; - return concatTokens(nextTokens, expressionTokens, hasTrailingWhitespace); +var fromChannel = (channel) => new Stream(channel); + +// node_modules/effect/dist/Sink.js +var TypeId17 = "~effect/Sink"; +var endVoid = /* @__PURE__ */ succeed6([undefined]); +var sinkVariance = { + _A: identity, + _In: identity, + _L: identity, + _E: identity, + _R: identity }; -var parseExpression = (expression) => { - const type = typeof expression; - if (type === "string") { - return expression; +var SinkProto = { + [TypeId17]: sinkVariance, + pipe() { + return pipeArguments(this, arguments); } - return String(expression); }; -var DELIMITERS = /* @__PURE__ */ new Set([" ", "\t", "\r", ` -`]); -var ESCAPE_LENGTH = { - x: 3, - u: 5 +var isSink = (u) => hasProperty(u, TypeId17); +var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ + disableYield: true +})), catchDone(succeed6))); +var fromTransform2 = (transform) => { + const self = Object.create(SinkProto); + self.transform = transform; + return self; }; -var splitByWhitespaces = (template, rawTemplate) => { - if (rawTemplate.length === 0) { - return { - tokens: [], - hasLeadingWhitespace: false, - hasTrailingWhitespace: false - }; +var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done2))); +var drain2 = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { + disableYield: true +}), () => endVoid)); +var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { + discard: true +})); +var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ + disableYield: true +}), catchDone(() => endVoid))); +var unwrap2 = (effect) => fromChannel2(unwrap(map5(effect, toChannel))); + +// node_modules/effect/dist/internal/rcRef.js +var TypeId18 = "~effect/RcRef"; +var stateEmpty = { + _tag: "Empty" +}; +var stateClosed = { + _tag: "Closed" +}; +var variance2 = { + _A: identity, + _E: identity +}; + +class RcRefImpl { + [TypeId18] = variance2; + pipe() { + return pipeArguments(this, arguments); } - const hasLeadingWhitespace = DELIMITERS.has(rawTemplate[0]); - const tokens = []; - let templateCursor = 0; - for (let templateIndex = 0, rawIndex = 0;templateIndex < template.length; templateIndex += 1, rawIndex += 1) { - const rawCharacter = rawTemplate[rawIndex]; - if (DELIMITERS.has(rawCharacter)) { - if (templateCursor !== templateIndex) { - tokens.push(template.slice(templateCursor, templateIndex)); - } - templateCursor = templateIndex + 1; - } else if (rawCharacter === "\\") { - const nextRawCharacter = rawTemplate[rawIndex + 1]; - if (nextRawCharacter === ` -`) { - templateIndex -= 1; - rawIndex += 1; - } else if (nextRawCharacter === "u" && rawTemplate[rawIndex + 2] === "{") { - const end = rawTemplate.indexOf("}", rawIndex + 3); - if (parseInt(rawTemplate.slice(rawIndex + 3, end), 16) > 65535) { - templateIndex += 1; + state = stateEmpty; + semaphore = /* @__PURE__ */ makeUnsafe5(1); + acquire; + context; + scope; + idleTimeToLive; + constructor(acquire, context, scope, idleTimeToLive) { + this.acquire = acquire; + this.context = context; + this.scope = scope; + this.idleTimeToLive = idleTimeToLive; + } +} +var make13 = (options) => withFiber2((fiber) => { + const context = fiber.context; + const scope = get(context, Scope); + const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== undefined ? fromInputUnsafe(options.idleTimeToLive) : undefined); + return as2(addFinalizerExit(scope, () => { + const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; + ref.state = stateClosed; + return close2; + }), ref); +}); +var getState = (self) => uninterruptibleMask2(function loop(restore) { + switch (self.state._tag) { + case "Closed": { + return interrupt2; + } + case "Acquired": { + self.state.refCount++; + return self.state.fiber ? as2(interrupt3(self.state.fiber), self.state) : succeed6(self.state); + } + case "Empty": { + const scope = makeUnsafe3(); + return self.semaphore.withPermit(suspend2(() => { + if (self.state._tag !== "Empty") { + return loop(restore); } - rawIndex = end; - } else { - rawIndex += ESCAPE_LENGTH[nextRawCharacter] ?? 1; - } + return restore(provideContext2(self.acquire, add(self.context, Scope, scope))).pipe(flatMap3((value) => { + if (self.state._tag === "Closed") { + return interrupt2; + } + const state = { + _tag: "Acquired", + value, + scope, + fiber: undefined, + refCount: 1, + invalidated: false + }; + self.state = state; + return succeed6(state); + }), onExit2((exit) => isFailure3(exit) ? close(scope, exit) : void_3)); + })); } } - const hasTrailingWhitespace = templateCursor === template.length; - if (!hasTrailingWhitespace) { - tokens.push(template.slice(templateCursor)); - } - return { - tokens, - hasLeadingWhitespace, - hasTrailingWhitespace - }; -}; -var concatTokens = (prevTokens, nextTokens, isSeparated) => isSeparated || prevTokens.length === 0 || nextTokens.length === 0 ? [...prevTokens, ...nextTokens] : [...prevTokens.slice(0, -1), `${prevTokens.at(-1)}${nextTokens.at(0)}`, ...nextTokens.slice(1)]; -// node_modules/@timmo001/effect-gh/src/errors.ts -class GhCommandError extends TaggedError3()("GhCommandError", { - executable: String4, - exitCode: Int, - stderr: String4, - stderrTruncated: Boolean2 -}) { -} - -class GhPlatformError extends TaggedError3()("GhPlatformError", { executable: String4, cause: Defect() }) { -} - -class GhTimeoutError extends TaggedError3()("GhTimeoutError", { executable: String4, timeoutMs: Finite }) { -} - -class GhDecodeError extends TaggedError3()("GhDecodeError", { cause: Defect() }) { -} - -// node_modules/@timmo001/effect-gh/src/gh.ts -var GhOutput = Struct({ - stdout: String4, - stderr: String4, - exitCode: Int -}); -var GhChunk = TaggedUnion({ - Stdout: { text: String4 }, - Stderr: { text: String4 } }); - -class Gh extends Service()("@timmo001/effect-gh/Gh") { -} -var stderrLimit = 65536; -var layer = (defaults = {}) => effect(Gh, gen2(function* () { - const spawner = yield* ChildProcessSpawner; - const open = fn2("Gh.stream")(function* (args, options) { - const executable = options.executable ?? "gh"; - const handle = yield* spawner.spawn(make19(executable, args, { - cwd: options.cwd, - env: { - ...defaults.env, - ...options.env, - GH_PROMPT_DISABLED: "1", - GH_PAGER: "cat", - PAGER: "cat", - NO_COLOR: "1", - CLICOLOR: "0", - CLICOLOR_FORCE: "0", - GH_FORCE_TTY: undefined, - GH_SPINNER_DISABLED: "1" - }, - extendEnv: true, - shell: false, - stdin: options.stdin === undefined ? "ignore" : "pipe", - stdout: "pipe", - stderr: "pipe", - forceKillAfter: "1 second" - })).pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))); - let stderr = ""; - let stderrTruncated = false; - const output = merge3(handle.stdout.pipe(decodeText(), map8((text) => GhChunk.cases.Stdout.make({ text }))), handle.stderr.pipe(decodeText(), map8((text) => { - stderrTruncated ||= stderr.length + text.length > stderrLimit; - stderr = (stderr + text).slice(-stderrLimit); - return GhChunk.cases.Stderr.make({ text }); - }))).pipe(mapError4((cause) => new GhPlatformError({ executable, cause }))); - const completion = gen2(function* () { - const exitCode = yield* handle.exitCode.pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))); - if (exitCode !== 0) { - return yield* new GhCommandError({ - executable, - exitCode, - stderr, - stderrTruncated - }); +var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { + const self = self_; + const state = yield* getState(self); + const scope = yield* scope2; + const isFinite2 = self.idleTimeToLive !== undefined && isFinite(self.idleTimeToLive); + yield* addFinalizerExit(scope, () => { + state.refCount--; + if (state.refCount > 0) { + return void_3; + } + if (self.idleTimeToLive === undefined || state.invalidated) { + if (self.state === state) { + self.state = stateEmpty; } - }); - const completed = output.pipe(concat(fromEffect2(completion).pipe(drain3))); - if (options.stdin === undefined) - return completed; - const input = isString(options.stdin) ? new TextEncoder().encode(options.stdin) : options.stdin; - return completed.pipe(mergeEffect2(run(succeed8(input), handle.stdin).pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))))); - }); - const stream = (args, overrides) => suspend4(() => { - const options = { ...defaults, ...overrides }; - const output = unwrap3(open(args, options)); - if (options.timeout == null) - return output; - if (!isFinite(fromInputUnsafe(options.timeout))) - return output; - const timeoutMs = toMillis(options.timeout); - return output.pipe(mergeEffect2(sleep2(options.timeout).pipe(andThen2(fail6(new GhTimeoutError({ - executable: options.executable ?? "gh", - timeoutMs - })))))); - }); - const execute = fn2("Gh.execute")(function* (args, options) { - return yield* stream(args, options).pipe(runFold2(() => ({ stdout: "", stderr: "", exitCode: 0 }), (output, chunk) => value2(chunk).pipe(tag2("Stdout", ({ text }) => ({ - ...output, - stdout: output.stdout + text - })), tag2("Stderr", ({ text }) => ({ - ...output, - stderr: output.stderr + text - })), exhaustive2))); - }); - const json = fn2("Gh.json")(function* (args, schema, options) { - const output = yield* execute(args, options); - return yield* decodeEffect2(fromJsonString2(schema))(output.stdout).pipe(mapError2((cause) => new GhDecodeError({ cause }))); - }); - return Gh.of({ execute, json, stream }); -})); -// src/action/ActionInputs.ts -var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; -var readRawInput = (name) => { - const value = process.env[inputEnvName(name)]; - return value === undefined || value === "" ? undefined : value; -}; -var readInputs = (names) => { - const inputs = {}; - for (const name of names) { - const value = readRawInput(name); - if (value !== undefined) - inputs[name] = value; - } - return inputs; -}; -var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); -// node_modules/effect/dist/Runtime.js -var defaultTeardown = (exit, onExit) => { - if (isSuccess3(exit)) - return onExit(0); - if (hasInterruptsOnly2(exit.cause)) - return onExit(130); - return onExit(getErrorExitCode(squash(exit.cause))); -}; -var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { - const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { - if (hasInterruptsOnly2(cause)) + return close(state.scope, void_2); + } else if (!isFinite2) { return void_3; - const isReported = getErrorReported(squash(cause)); - return isReported ? logError(cause) : void_3; - })); - try { - const keepAlive = globalThis.setInterval(constVoid, 2147483647); - fiber.addObserver(() => { - clearInterval(keepAlive); - }); - } catch {} - const teardown = options?.teardown ?? defaultTeardown; - return f({ - fiber, - teardown + } + state.fiber = sleep2(self.idleTimeToLive).pipe(flatMap3(() => { + if (self.state === state && state.refCount === 0) { + self.state = stateEmpty; + return close(state.scope, void_2); + } + return void_3; + }), ensuring2(sync3(() => { + state.fiber = undefined; + })), runForkWith2(self.context), runIn(self.scope)); + return void_3; }); + return state.value; }); -var errorExitCode = "~effect/Runtime/errorExitCode"; -var getErrorExitCode = (u) => { - if (typeof u === "object" && u !== null && errorExitCode in u) { - const code = u[errorExitCode]; - if (typeof code === "number") { - return code; + +// node_modules/effect/dist/RcRef.js +var make14 = make13; +var get3 = get2; + +// node_modules/effect/dist/Stream.js +var TypeId19 = "~effect/Stream"; +var isStream = (u) => hasProperty(u, TypeId19); +var fromChannel3 = fromChannel; +var fromEffect2 = (effect) => fromChannel3(fromEffect(map5(effect, of))); +var fromPull2 = (pull) => fromChannel3(fromPull(pull)); +var transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))); +var toChannel2 = (stream) => stream.channel; +var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); +var empty4 = /* @__PURE__ */ fromChannel3(empty3); +var succeed9 = (value) => fromChannel3(succeed8(of(value))); +var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); +var fromArray2 = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel3(succeed8(array)) : empty4; +var unwrap3 = (effect) => fromChannel3(unwrap(map5(effect, toChannel2))); +var map7 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { + let i = 0; + return fromChannel3(map6(self.channel, map((o) => f(o, i++)))); +})); +var flatMap5 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options) => self.channel.pipe(flattenArray, flatMap4((a) => f(a).channel, options), fromChannel3)); +var flatten4 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => flatMap5(self, identity, options)); +var drain3 = (self) => fromChannel3(drain(self.channel)); +var concat = /* @__PURE__ */ dual(2, (self, that) => flatten4(fromArray2([self, that]))); +var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); +var mergeEffect2 = /* @__PURE__ */ dual(2, (self, effect) => self.channel.pipe(mergeEffect(effect), fromChannel3)); +var mapError5 = /* @__PURE__ */ dual(2, (self, f) => fromChannel3(mapError4(self.channel, f))); +var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { + let done; + let leftover; + const upstreamWithLeftover = suspend2(() => { + if (leftover !== undefined) { + const chunk = leftover; + leftover = undefined; + return succeed6(chunk); } + return upstream; + }).pipe(catch_2((error) => { + done = fail5(error); + return done2(); + })); + const pull = map5(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { + leftover = leftover_; + return of(value); + }); + return suspend2(() => done ? done : pull); +}))); +var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { + const decoder = new TextDecoder(options?.encoding); + return map7(self, (chunk) => decoder.decode(chunk, { + stream: true + })); +})); +var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); +var run2 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map5(([a]) => a)))); +var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { + for (let i = 0;i < chunk.length; i++) { + acc.push(chunk[i]); } - return 1; -}; -var errorReported = "~effect/Runtime/errorReported"; -var getErrorReported = (u) => { - if (typeof u === "object" && u !== null && errorReported in u) { - const isReported = u[errorReported]; - if (typeof isReported === "boolean") { - return isReported; - } + return acc; +}); +var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channel, initial, (acc, arr) => { + for (let i = 0;i < arr.length; i++) { + acc = f(acc, arr[i]); } - return true; -}; + return acc; +})); +var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => { + let i = 0; + return whileLoop2({ + while: () => i < arr.length, + body: () => f(arr[i++]), + step: constVoid + }); +})); +var runDrain2 = (self) => runDrain(self.channel); +var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); -// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js -var runMain = /* @__PURE__ */ makeRunMain(({ - fiber, - teardown -}) => { - let receivedSignal = false; - fiber.addObserver((exit) => { - process.removeListener("SIGINT", onSigint); - process.removeListener("SIGTERM", onSigint); - teardown(exit, (code) => { - if (receivedSignal || code !== 0) { - process.exit(code); - } +// node_modules/effect/dist/FileSystem.js +var TypeId20 = "~effect/FileSystem"; +var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); +var make15 = (impl) => FileSystem.of({ + ...impl, + [TypeId20]: TypeId20, + exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), + readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ + try: () => new TextDecoder(encoding).decode(_), + catch: (cause) => badArgument({ + module: "FileSystem", + method: "readFileString", + description: "invalid encoding", + cause + }) + })), + stream: fnUntraced2(function* (path, options) { + const file = yield* impl.open(path, { + flag: "r" }); - }); - function onSigint() { - receivedSignal = true; - fiber.interruptUnsafe(fiber.id); - } - process.on("SIGINT", onSigint); - process.on("SIGTERM", onSigint); + const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset); + if (offset) { + yield* file.seek(offset, "start"); + } + const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead); + let totalBytesRead = BigInt(0); + const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024)); + const readChunk = file.readAlloc(chunkSize); + return fromPull2(succeed6(flatMap3(suspend2(() => { + if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { + return done2(); + } + return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; + }), match({ + onNone: () => done2(), + onSome: (buf) => { + totalBytesRead += BigInt(buf.length); + return succeed6(of(buf)); + } + })))); + }, unwrap3), + sink: (path, options) => pipe(impl.open(path, { + ...options, + flag: options?.flag ?? "w" + }), map5((file) => forEach3((_) => file.writeAll(_))), unwrap2), + writeFileString: (path, data, options) => flatMap3(try_2({ + try: () => new TextEncoder().encode(data), + catch: (cause) => badArgument({ + module: "FileSystem", + method: "writeFileString", + description: "could not encode string", + cause + }) + }), (_) => impl.writeFile(path, _, options)) }); +var FileTypeId = "~effect/FileSystem/File"; +class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBackend")) { +} -// node_modules/@effect/platform-node/dist/NodeRuntime.js -var runMain2 = runMain; // node_modules/effect/dist/Path.js -var TypeId24 = "~effect/Path"; -var Path2 = /* @__PURE__ */ Service("effect/Path"); +var TypeId21 = "~effect/Path"; +var Path = /* @__PURE__ */ Service("effect/Path"); function normalizeStringPosix(path, allowAboveRoot) { let res = ""; let lastSegmentLength = 0; @@ -9429,7 +9101,7 @@ function fromFileUrl(url) { } return succeed6(decodeURIComponent(pathname)); } -var resolve2 = function resolve() { +var resolve3 = function resolve() { let resolvedPath = ""; let resolvedAbsolute = false; let cwd = undefined; @@ -9466,7 +9138,7 @@ var resolve2 = function resolve() { var CHAR_FORWARD_SLASH = 47; function toFileUrl(filepath) { const outURL = new URL("file://"); - let resolved = resolve2(filepath); + let resolved = resolve3(filepath); const filePathLast = filepath.charCodeAt(filepath.length - 1); if (filePathLast === CHAR_FORWARD_SLASH && resolved[resolved.length - 1] !== "/") { resolved += "/"; @@ -9498,9 +9170,9 @@ function encodePathChars(filepath) { } return filepath; } -var posixImpl = /* @__PURE__ */ Path2.of({ - [TypeId24]: TypeId24, - resolve: resolve2, +var posixImpl = /* @__PURE__ */ Path.of({ + [TypeId21]: TypeId21, + resolve: resolve3, normalize(path) { if (path.length === 0) return "."; @@ -9667,144 +9339,782 @@ var posixImpl = /* @__PURE__ */ Path2.of({ } } } - if (start === end) - end = firstNonSlashEnd; - else if (end === -1) - end = path.length; - return path.slice(start, end); - } else { - for (i = path.length - 1;i >= 0; --i) { - if (path.charCodeAt(i) === 47) { - if (!matchedSlash) { - start = i + 1; - break; - } - } else if (end === -1) { - matchedSlash = false; - end = i + 1; - } + if (start === end) + end = firstNonSlashEnd; + else if (end === -1) + end = path.length; + return path.slice(start, end); + } else { + for (i = path.length - 1;i >= 0; --i) { + if (path.charCodeAt(i) === 47) { + if (!matchedSlash) { + start = i + 1; + break; + } + } else if (end === -1) { + matchedSlash = false; + end = i + 1; + } + } + if (end === -1) + return ""; + return path.slice(start, end); + } + }, + extname(path) { + let startDot = -1; + let startPart = 0; + let end = -1; + let matchedSlash = true; + let preDotState = 0; + for (let i = path.length - 1;i >= 0; --i) { + const code = path.charCodeAt(i); + if (code === 47) { + if (!matchedSlash) { + startPart = i + 1; + break; + } + continue; + } + if (end === -1) { + matchedSlash = false; + end = i + 1; + } + if (code === 46) { + if (startDot === -1) { + startDot = i; + } else if (preDotState !== 1) { + preDotState = 1; + } + } else if (startDot !== -1) { + preDotState = -1; + } + } + if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + return ""; + } + return path.slice(startDot, end); + }, + format: function format(pathObject) { + if (pathObject === null || typeof pathObject !== "object") { + throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); + } + return _format("/", pathObject); + }, + parse(path) { + const ret = { + root: "", + dir: "", + base: "", + ext: "", + name: "" + }; + if (path.length === 0) + return ret; + let code = path.charCodeAt(0); + const isAbsolute = code === 47; + let start; + if (isAbsolute) { + ret.root = "/"; + start = 1; + } else { + start = 0; + } + let startDot = -1; + let startPart = 0; + let end = -1; + let matchedSlash = true; + let i = path.length - 1; + let preDotState = 0; + for (;i >= start; --i) { + code = path.charCodeAt(i); + if (code === 47) { + if (!matchedSlash) { + startPart = i + 1; + break; + } + continue; + } + if (end === -1) { + matchedSlash = false; + end = i + 1; + } + if (code === 46) { + if (startDot === -1) + startDot = i; + else if (preDotState !== 1) + preDotState = 1; + } else if (startDot !== -1) { + preDotState = -1; + } + } + if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + if (end !== -1) { + if (startPart === 0 && isAbsolute) + ret.base = ret.name = path.slice(1, end); + else + ret.base = ret.name = path.slice(startPart, end); + } + } else { + if (startPart === 0 && isAbsolute) { + ret.name = path.slice(1, startDot); + ret.base = path.slice(1, end); + } else { + ret.name = path.slice(startPart, startDot); + ret.base = path.slice(startPart, end); + } + ret.ext = path.slice(startDot, end); + } + if (startPart > 0) + ret.dir = path.slice(0, startPart - 1); + else if (isAbsolute) + ret.dir = "/"; + return ret; + }, + sep: "/", + fromFileUrl, + toFileUrl, + toNamespacedPath: identity +}); +// node_modules/effect/dist/internal/ulid.js +var maxTimestamp = 2 ** 48 - 1; +var base32Chars = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; +var ulidString = (timestampMillis, bytes) => { + if (bytes.length !== 10) { + throw new Error(`ULID randomness must be exactly 10 bytes, received ${bytes.length}`); + } + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxTimestamp); + let out = ""; + for (let shift = 45;shift >= 0; shift -= 5) { + out += base32Chars[Math.floor(timestamp / 2 ** shift) & 31]; + } + let accumulator = 0; + let bits = 0; + for (const byte of bytes) { + accumulator = accumulator << 8 | byte; + bits += 8; + while (bits >= 5) { + bits -= 5; + out += base32Chars[accumulator >>> bits & 31]; + } + accumulator &= (1 << bits) - 1; + } + return out; +}; + +// node_modules/effect/dist/internal/uuid.js +var hex = (byte) => byte.toString(16).padStart(2, "0"); +var stringify = (bytes) => { + const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; + return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); +}; +var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); +function v4Bytes(bytes = randomBytes()) { + bytes[6] = bytes[6] & 15 | 64; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); +var maxV7Timestamp = 2 ** 48 - 1; +function v7Bytes(timestampMillis, bytes = randomBytes()) { + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); + bytes[0] = Math.floor(timestamp / 2 ** 40); + bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; + bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; + bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; + bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; + bytes[5] = timestamp & 255; + bytes[6] = bytes[6] & 15 | 112; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); + +// node_modules/effect/dist/Crypto.js +var TypeId22 = "~effect/Crypto"; +var Crypto = /* @__PURE__ */ Service("effect/Crypto"); +var make16 = (impl) => { + const randomBytesUnsafe = impl.randomBytes; + const randomBytes = (size) => map5(validateSize("randomBytes", size), randomBytesUnsafe); + const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; + const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; + const nextIntUnsafe = () => { + while (true) { + const bytes = randomBytesUnsafe(7); + const value = readUint53(bytes); + if ((bytes[0] & 32) === 0) { + return value + Number.MIN_SAFE_INTEGER; + } + if (value < Number.MAX_SAFE_INTEGER) { + return value + 1; } - if (end === -1) - return ""; - return path.slice(start, end); } - }, - extname(path) { - let startDot = -1; - let startPart = 0; - let end = -1; - let matchedSlash = true; - let preDotState = 0; - for (let i = path.length - 1;i >= 0; --i) { - const code = path.charCodeAt(i); - if (code === 47) { - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; + }; + return Crypto.of({ + [TypeId22]: TypeId22, + randomBytes, + nextDoubleUnsafe, + nextIntUnsafe, + digest: impl.digest, + random: sync3(() => nextDoubleUnsafe()), + randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), + randomInt: sync3(() => nextIntUnsafe()), + randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), + randomIntBetween(min, max, options) { + const extra = options?.halfOpen === true ? 0 : 1; + return sync3(() => { + const minInt = Math.ceil(min); + const maxInt = Math.floor(max); + return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; + }); + }, + randomShuffle: (elements) => sync3(() => { + const buffer = Array.from(elements); + for (let i = buffer.length - 1;i >= 1; i = i - 1) { + const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); + const value = buffer[i]; + buffer[i] = buffer[index]; + buffer[index] = value; } - if (end === -1) { - matchedSlash = false; - end = i + 1; + return buffer; + }), + randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), + randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))), + randomULID: clockWith2((clock) => succeed6(ulidString(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(10)))) + }); +}; +var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ + module: "Crypto", + method, + description: "size must be a non-negative safe integer" +})); +// node_modules/effect/dist/internal/matcher.js +var TypeId23 = "~effect/Match/Matcher"; +var TypeMatcherProto = { + [TypeId23]: { + _input: identity, + _filters: identity, + _remaining: identity, + _result: identity, + _return: identity, + _args: identity + }, + _tag: "TypeMatcher", + add(_case) { + return makeTypeMatcher(this.select, [...this.cases, _case]); + }, + pipe() { + return pipeArguments(this, arguments); + } +}; +function makeTypeMatcher(select, cases) { + const matcher = Object.create(TypeMatcherProto); + matcher.select = select; + matcher.cases = cases; + return matcher; +} +var ValueMatcherProto = { + [TypeId23]: { + _input: identity, + _filters: identity, + _result: identity, + _return: identity, + _flavor: identity + }, + _tag: "ValueMatcher", + add(_case) { + if (isSuccess2(this.value)) { + return this; + } + if (_case._tag === "When" && _case.guard(this.provided) === true) { + return makeValueMatcher(this.provided, succeed2(_case.evaluate(this.provided))); + } else if (_case._tag === "Not" && _case.guard(this.provided) === false) { + return makeValueMatcher(this.provided, succeed2(_case.evaluate(this.provided))); + } + return this; + }, + pipe() { + return pipeArguments(this, arguments); + } +}; +function makeValueMatcher(provided, value) { + const matcher = Object.create(ValueMatcherProto); + matcher.provided = provided; + matcher.value = value; + return matcher; +} +var makeWhen = (guard, evaluate) => ({ + _tag: "When", + guard, + evaluate +}); +var value = (i) => makeValueMatcher(i, fail2(i)); +var discriminator = (field) => (...pattern) => { + const f = pattern[pattern.length - 1]; + const values = pattern.slice(0, -1); + const pred = values.length === 1 ? (_) => _ != null && _[field] === values[0] : (_) => _ != null && values.includes(_[field]); + return (self) => self.add(makeWhen(pred, f)); +}; +var tag2 = /* @__PURE__ */ discriminator("_tag"); +var result2 = (self) => { + if (self._tag === "ValueMatcher") { + return self.value; + } + const len = self.cases.length; + if (len === 1) { + const _case = self.cases[0]; + return (...args) => { + const input = self.select(...args); + if (_case._tag === "When" && _case.guard(input) === true) { + return succeed2(_case.evaluate(input, ...args)); + } else if (_case._tag === "Not" && _case.guard(input) === false) { + return succeed2(_case.evaluate(input, ...args)); } - if (code === 46) { - if (startDot === -1) { - startDot = i; - } else if (preDotState !== 1) { - preDotState = 1; - } - } else if (startDot !== -1) { - preDotState = -1; + return fail2(input); + }; + } + return (...args) => { + const input = self.select(...args); + for (let i = 0;i < len; i++) { + const _case = self.cases[i]; + if (_case._tag === "When" && _case.guard(input) === true) { + return succeed2(_case.evaluate(input, ...args)); + } else if (_case._tag === "Not" && _case.guard(input) === false) { + return succeed2(_case.evaluate(input, ...args)); } } - if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - return ""; + return fail2(input); + }; +}; +var getExhaustiveAbsurdErrorMessage = "effect/match/Match/exhaustive: absurd"; +var exhaustive = (self) => { + const toResult = result2(self); + if (isResult2(toResult)) { + if (isSuccess2(toResult)) { + return toResult.success; + } + throw new Error(getExhaustiveAbsurdErrorMessage); + } + return (...args) => { + const result = toResult(...args); + if (isSuccess2(result)) { + return result.success; + } + throw new Error(getExhaustiveAbsurdErrorMessage); + }; +}; + +// node_modules/effect/dist/Match.js +var value2 = value; +var tag3 = tag2; +var exhaustive2 = exhaustive; +// node_modules/effect/dist/Ref.js +var TypeId24 = "~effect/Ref"; +var RefProto = { + [TypeId24]: { + _A: identity + }, + ...PipeInspectableProto, + toJSON() { + return { + _id: "Ref", + ref: this.ref + }; + } +}; +var makeUnsafe6 = (value) => { + const self = Object.create(RefProto); + self.ref = make7(value); + return self; +}; +var make17 = (value) => sync3(() => makeUnsafe6(value)); +var get4 = (self) => sync3(() => self.ref.current); +var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { + self.ref.current = f(self.ref.current); +})); +// node_modules/effect/dist/Runtime.js +var defaultTeardown = (exit, onExit) => { + if (isSuccess3(exit)) + return onExit(0); + if (hasInterruptsOnly2(exit.cause)) + return onExit(130); + return onExit(getErrorExitCode(squash(exit.cause))); +}; +var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { + const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { + if (hasInterruptsOnly2(cause)) + return void_3; + const isReported = getErrorReported(squash(cause)); + return isReported ? logError(cause) : void_3; + })); + try { + const keepAlive = globalThis.setInterval(constVoid, 2147483647); + fiber.addObserver(() => { + clearInterval(keepAlive); + }); + } catch {} + const teardown = options?.teardown ?? defaultTeardown; + return f({ + fiber, + teardown + }); +}); +var errorExitCode = "~effect/Runtime/errorExitCode"; +var getErrorExitCode = (u) => { + if (typeof u === "object" && u !== null && errorExitCode in u) { + const code = u[errorExitCode]; + if (typeof code === "number") { + return code; } - return path.slice(startDot, end); - }, - format: function format(pathObject) { - if (pathObject === null || typeof pathObject !== "object") { - throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); + } + return 1; +}; +var errorReported = "~effect/Runtime/errorReported"; +var getErrorReported = (u) => { + if (typeof u === "object" && u !== null && errorReported in u) { + const isReported = u[errorReported]; + if (typeof isReported === "boolean") { + return isReported; } - return _format("/", pathObject); - }, - parse(path) { - const ret = { - root: "", - dir: "", - base: "", - ext: "", - name: "" + } + return true; +}; +// node_modules/effect/dist/Stdio.js +var TypeId25 = "~effect/Stdio"; +var Stdio = /* @__PURE__ */ Service(TypeId25); +var make18 = (options) => ({ + [TypeId25]: TypeId25, + stdinIsTerminal: succeed6(false), + stdoutIsTerminal: succeed6(false), + ...options +}); +// node_modules/effect/dist/Terminal.js +var TypeId26 = "~effect/Terminal"; +var QuitErrorTypeId = "~effect/Terminal/QuitError"; + +class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ + _tag: /* @__PURE__ */ tag("QuitError") +})) { + [QuitErrorTypeId] = QuitErrorTypeId; +} +var Terminal = /* @__PURE__ */ Service("effect/Terminal"); +var make19 = (impl) => Terminal.of({ + ...impl, + [TypeId26]: TypeId26 +}); +// node_modules/effect/dist/unstable/process/ChildProcessSpawner.js +var ExitCode = /* @__PURE__ */ nominal(); +var ProcessId = /* @__PURE__ */ nominal(); +var HandleTypeId = "~effect/process/ChildProcessSpawner/ChildProcessHandle"; +var HandleProto = { + [HandleTypeId]: HandleTypeId, + ...BaseProto, + toJSON() { + return { + _id: "ChildProcessHandle", + pid: this.pid }; - if (path.length === 0) - return ret; - let code = path.charCodeAt(0); - const isAbsolute = code === 47; - let start; - if (isAbsolute) { - ret.root = "/"; - start = 1; - } else { - start = 0; + } +}; +var makeHandle = (params) => Object.setPrototypeOf({ + ...params +}, HandleProto); +var make20 = (spawn) => { + const streamString = (command, options) => spawn(command).pipe(map5((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); + const streamLines = (command, options) => splitLines2(streamString(command, options)); + return ChildProcessSpawner.of({ + spawn, + exitCode: (command) => scoped2(flatMap3(spawn(command), (handle) => handle.exitCode)), + streamString, + streamLines, + lines: (command, options) => runCollect(streamLines(command, options)), + string: (command, options) => mkString(streamString(command, options)) + }); +}; + +class ChildProcessSpawner extends (/* @__PURE__ */ Service()("effect/process/ChildProcessSpawner")) { +} + +// node_modules/effect/dist/unstable/process/ChildProcess.js +var TypeId27 = "~effect/process/ChildProcess"; +var Proto2 = { + .../* @__PURE__ */ Prototype2({ + label: "Command", + evaluate(fiber) { + return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this); } - let startDot = -1; - let startPart = 0; - let end = -1; - let matchedSlash = true; - let i = path.length - 1; - let preDotState = 0; - for (;i >= start; --i) { - code = path.charCodeAt(i); - if (code === 47) { - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; - } - if (end === -1) { - matchedSlash = false; - end = i + 1; + }), + [TypeId27]: TypeId27 +}; +var makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto2), { + _tag: "StandardCommand", + command, + args, + options +}); +var make21 = function make(...args) { + if (isTemplateString(args[0])) { + const [templates, ...expressions] = args; + const tokens = parseTemplates(templates, expressions); + return makeStandardCommand(tokens[0] ?? "", tokens.slice(1), {}); + } + if (typeof args[0] === "object" && !Array.isArray(args[0]) && !isTemplateString(args[0])) { + const options = args[0]; + return function(templates, ...expressions) { + const tokens = parseTemplates(templates, expressions); + return makeStandardCommand(tokens[0] ?? "", tokens.slice(1), options); + }; + } + if (typeof args[0] === "string" && !Array.isArray(args[1])) { + const [command, options = {}] = args; + return makeStandardCommand(command, [], options); + } + const [command, cmdArgs = [], options = {}] = args; + return makeStandardCommand(command, cmdArgs, options); +}; +var isTemplateString = (u) => Array.isArray(u) && ("raw" in u) && Array.isArray(u.raw); +var parseFdName = (name) => { + const match = /^fd(\d+)$/.exec(name); + if (match === null) + return; + const fd = parseInt(match[1], 10); + return fd >= 3 ? fd : undefined; +}; +var fdName = (fd) => `fd${fd}`; +var parseTemplates = (templates, expressions) => { + let tokens = []; + for (const [index, template] of templates.entries()) { + tokens = parseTemplate(templates, expressions, tokens, template, index); + } + return tokens; +}; +var parseTemplate = (templates, expressions, prevTokens, template, index) => { + const rawTemplate = templates.raw[index]; + if (rawTemplate === undefined) { + throw new Error(`Invalid backslash sequence: ${templates.raw[index]}`); + } + const { + hasLeadingWhitespace, + hasTrailingWhitespace, + tokens + } = splitByWhitespaces(template, rawTemplate); + const nextTokens = concatTokens(prevTokens, tokens, hasLeadingWhitespace); + if (index === expressions.length) { + return nextTokens; + } + const expression = expressions[index]; + const expressionTokens = Array.isArray(expression) ? expression.map((expression) => parseExpression(expression)) : [parseExpression(expression)]; + return concatTokens(nextTokens, expressionTokens, hasTrailingWhitespace); +}; +var parseExpression = (expression) => { + const type = typeof expression; + if (type === "string") { + return expression; + } + return String(expression); +}; +var DELIMITERS = /* @__PURE__ */ new Set([" ", "\t", "\r", ` +`]); +var ESCAPE_LENGTH = { + x: 3, + u: 5 +}; +var splitByWhitespaces = (template, rawTemplate) => { + if (rawTemplate.length === 0) { + return { + tokens: [], + hasLeadingWhitespace: false, + hasTrailingWhitespace: false + }; + } + const hasLeadingWhitespace = DELIMITERS.has(rawTemplate[0]); + const tokens = []; + let templateCursor = 0; + for (let templateIndex = 0, rawIndex = 0;templateIndex < template.length; templateIndex += 1, rawIndex += 1) { + const rawCharacter = rawTemplate[rawIndex]; + if (DELIMITERS.has(rawCharacter)) { + if (templateCursor !== templateIndex) { + tokens.push(template.slice(templateCursor, templateIndex)); } - if (code === 46) { - if (startDot === -1) - startDot = i; - else if (preDotState !== 1) - preDotState = 1; - } else if (startDot !== -1) { - preDotState = -1; + templateCursor = templateIndex + 1; + } else if (rawCharacter === "\\") { + const nextRawCharacter = rawTemplate[rawIndex + 1]; + if (nextRawCharacter === ` +`) { + templateIndex -= 1; + rawIndex += 1; + } else if (nextRawCharacter === "u" && rawTemplate[rawIndex + 2] === "{") { + const end = rawTemplate.indexOf("}", rawIndex + 3); + if (parseInt(rawTemplate.slice(rawIndex + 3, end), 16) > 65535) { + templateIndex += 1; + } + rawIndex = end; + } else { + rawIndex += ESCAPE_LENGTH[nextRawCharacter] ?? 1; } } - if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - if (end !== -1) { - if (startPart === 0 && isAbsolute) - ret.base = ret.name = path.slice(1, end); - else - ret.base = ret.name = path.slice(startPart, end); + } + const hasTrailingWhitespace = templateCursor === template.length; + if (!hasTrailingWhitespace) { + tokens.push(template.slice(templateCursor)); + } + return { + tokens, + hasLeadingWhitespace, + hasTrailingWhitespace + }; +}; +var concatTokens = (prevTokens, nextTokens, isSeparated) => isSeparated || prevTokens.length === 0 || nextTokens.length === 0 ? [...prevTokens, ...nextTokens] : [...prevTokens.slice(0, -1), `${prevTokens.at(-1)}${nextTokens.at(0)}`, ...nextTokens.slice(1)]; +// node_modules/@timmo001/effect-gh/src/errors.ts +class GhCommandError extends TaggedError3()("GhCommandError", { + executable: String4, + exitCode: Int, + stderr: String4, + stderrTruncated: Boolean2 +}) { +} + +class GhPlatformError extends TaggedError3()("GhPlatformError", { executable: String4, cause: Defect() }) { +} + +class GhTimeoutError extends TaggedError3()("GhTimeoutError", { executable: String4, timeoutMs: Finite }) { +} + +class GhDecodeError extends TaggedError3()("GhDecodeError", { cause: Defect() }) { +} + +// node_modules/@timmo001/effect-gh/src/gh.ts +var GhOutput = Struct({ + stdout: String4, + stderr: String4, + exitCode: Int +}); +var GhChunk = TaggedUnion({ + Stdout: { text: String4 }, + Stderr: { text: String4 } +}); + +class Gh extends Service()("@timmo001/effect-gh/Gh") { +} +var stderrLimit = 65536; +var layer = (defaults = {}) => effect(Gh, gen2(function* () { + const spawner = yield* ChildProcessSpawner; + const open = fn2("Gh.stream")(function* (args, options) { + const executable = options.executable ?? "gh"; + const handle = yield* spawner.spawn(make21(executable, args, { + cwd: options.cwd, + env: { + ...defaults.env, + ...options.env, + GH_PROMPT_DISABLED: "1", + GH_PAGER: "cat", + PAGER: "cat", + NO_COLOR: "1", + CLICOLOR: "0", + CLICOLOR_FORCE: "0", + GH_FORCE_TTY: undefined, + GH_SPINNER_DISABLED: "1" + }, + extendEnv: true, + shell: false, + stdin: options.stdin === undefined ? "ignore" : "pipe", + stdout: "pipe", + stderr: "pipe", + forceKillAfter: "1 second" + })).pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))); + let stderr = ""; + let stderrTruncated = false; + const output = merge3(handle.stdout.pipe(decodeText(), map7((text) => GhChunk.cases.Stdout.make({ text }))), handle.stderr.pipe(decodeText(), map7((text) => { + stderrTruncated ||= stderr.length + text.length > stderrLimit; + stderr = (stderr + text).slice(-stderrLimit); + return GhChunk.cases.Stderr.make({ text }); + }))).pipe(mapError5((cause) => new GhPlatformError({ executable, cause }))); + const completion = gen2(function* () { + const exitCode = yield* handle.exitCode.pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))); + if (exitCode !== 0) { + return yield* new GhCommandError({ + executable, + exitCode, + stderr, + stderrTruncated + }); } - } else { - if (startPart === 0 && isAbsolute) { - ret.name = path.slice(1, startDot); - ret.base = path.slice(1, end); - } else { - ret.name = path.slice(startPart, startDot); - ret.base = path.slice(startPart, end); + }); + const completed = output.pipe(concat(fromEffect2(completion).pipe(drain3))); + if (options.stdin === undefined) + return completed; + const input = isString(options.stdin) ? new TextEncoder().encode(options.stdin) : options.stdin; + return completed.pipe(mergeEffect2(run2(succeed9(input), handle.stdin).pipe(mapError2((cause) => new GhPlatformError({ executable, cause }))))); + }); + const stream = (args, overrides) => suspend4(() => { + const options = { ...defaults, ...overrides }; + const output = unwrap3(open(args, options)); + if (options.timeout == null) + return output; + if (!isFinite(fromInputUnsafe(options.timeout))) + return output; + const timeoutMs = toMillis(options.timeout); + return output.pipe(mergeEffect2(sleep2(options.timeout).pipe(andThen2(fail6(new GhTimeoutError({ + executable: options.executable ?? "gh", + timeoutMs + })))))); + }); + const execute = fn2("Gh.execute")(function* (args, options) { + return yield* stream(args, options).pipe(runFold2(() => ({ stdout: "", stderr: "", exitCode: 0 }), (output, chunk) => value2(chunk).pipe(tag3("Stdout", ({ text }) => ({ + ...output, + stdout: output.stdout + text + })), tag3("Stderr", ({ text }) => ({ + ...output, + stderr: output.stderr + text + })), exhaustive2))); + }); + const json = fn2("Gh.json")(function* (args, schema, options) { + const output = yield* execute(args, options); + return yield* decodeEffect2(fromJsonString2(schema))(output.stdout).pipe(mapError2((cause) => new GhDecodeError({ cause }))); + }); + return Gh.of({ execute, json, stream }); +})); +// src/action/ActionInputs.ts +var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; +var readRawInput = (name) => { + const value = process.env[inputEnvName(name)]; + return value === undefined || value === "" ? undefined : value; +}; +var readInputs = (names) => { + const inputs = {}; + for (const name of names) { + const value = readRawInput(name); + if (value !== undefined) + inputs[name] = value; + } + return inputs; +}; +var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); +// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js +var runMain = /* @__PURE__ */ makeRunMain(({ + fiber, + teardown +}) => { + let receivedSignal = false; + fiber.addObserver((exit) => { + process.removeListener("SIGINT", onSigint); + process.removeListener("SIGTERM", onSigint); + teardown(exit, (code) => { + if (receivedSignal || code !== 0) { + process.exit(code); } - ret.ext = path.slice(startDot, end); - } - if (startPart > 0) - ret.dir = path.slice(0, startPart - 1); - else if (isAbsolute) - ret.dir = "/"; - return ret; - }, - sep: "/", - fromFileUrl, - toFileUrl, - toNamespacedPath: identity + }); + }); + function onSigint() { + receivedSignal = true; + fiber.interruptUnsafe(fiber.id); + } + process.on("SIGINT", onSigint); + process.on("SIGTERM", onSigint); }); +// node_modules/@effect/platform-node/dist/NodeRuntime.js +var runMain2 = runMain; // node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js import * as NodeChildProcess from "node:child_process"; import { PassThrough } from "node:stream"; @@ -9897,10 +10207,10 @@ var pullIntoWritable = (options) => options.pull.pipe(flatMap3((chunk) => { disableYield: true }), options.endOnDone !== false ? catchDone((_) => { if ("closed" in options.writable && options.writable.closed) { - return done3(_); + return done2(_); } return callback2((resume) => { - const onFinish = () => resume(done3(_)); + const onFinish = () => resume(done2(_)); options.writable.once("finish", onFinish); options.writable.end(); return sync3(() => { @@ -9933,11 +10243,11 @@ var readableToPullUnsafe = (options) => { latch.openUnsafe(); } function onError(error) { - exit.current = fail4(options.onError(error)); + exit.current = fail5(options.onError(error)); latch.openUnsafe(); } function onEnd() { - exit.current = fail4(Done2()); + exit.current = fail5(Done2()); latch.openUnsafe(); } readable.on("readable", onReadable); @@ -10006,9 +10316,9 @@ var isProcessAlive = (childProcess, exitSignal) => { var taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { windowsHide: true }, onExit); -var make20 = /* @__PURE__ */ gen2(function* () { +var make22 = /* @__PURE__ */ gen2(function* () { const fs = yield* FileSystem; - const path = yield* Path2; + const path = yield* Path; const resolveWorkingDirectory = fnUntraced2(function* (options) { if (isUndefined(options.cwd)) return; @@ -10129,7 +10439,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { }); } if (config.stream) { - yield* forkScoped2(run(config.stream, sink)); + yield* forkScoped2(run2(config.stream, sink)); } inputSinks.set(fd, sink); break; @@ -10169,7 +10479,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { }); } if (isStream(config.stream)) { - return as2(forkScoped2(run(config.stream, sink)), sink); + return as2(forkScoped2(run2(config.stream, sink)), sink); } return succeed6(sink); }); @@ -10325,7 +10635,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { env, stdio }, process.platform)), fnUntraced2(function* ([childProcess, exitSignal]) { - const exited = yield* isDone2(exitSignal); + const exited = yield* isDone3(exitSignal); if (exited) { const [code] = yield* _await(exitSignal); if (code !== 0 && isNotNull(code)) { @@ -10367,7 +10677,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds); - const isRunning = map6(isDone2(exitSignal), (done) => !done); + const isRunning = map5(isDone3(exitSignal), (done) => !done); const exitCode = flatMap3(_await(exitSignal), ([code, signal]) => { if (isNotNull(code)) { return succeed6(ExitCode(code)); @@ -10404,7 +10714,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { const sourceStream = unwrap3(succeed6(getSourceStream(handles[handles.length - 1], options.from))); const toOption = options.to ?? "stdin"; if (toOption === "stdin") { - handles.push(yield* spawnCommand(make19(command.command, command.args, { + handles.push(yield* spawnCommand(make21(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -10416,7 +10726,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { if (isNotUndefined(fd)) { const fdName2 = fdName(fd); const existingFds = command.options.additionalFds ?? {}; - handles.push(yield* spawnCommand(make19(command.command, command.args, { + handles.push(yield* spawnCommand(make21(command.command, command.args, { ...command.options, additionalFds: { ...existingFds, @@ -10427,7 +10737,7 @@ var make20 = /* @__PURE__ */ gen2(function* () { } }))); } else { - handles.push(yield* spawnCommand(make19(command.command, command.args, { + handles.push(yield* spawnCommand(make21(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -10466,9 +10776,9 @@ var make20 = /* @__PURE__ */ gen2(function* () { } } }); - return make18(spawnCommand); + return make20(spawnCommand); }); -var layer2 = /* @__PURE__ */ effect(ChildProcessSpawner, make20); +var layer2 = /* @__PURE__ */ effect(ChildProcessSpawner, make22); var flattenCommand = (command) => { const commands = []; const pipeOptions = []; @@ -10498,92 +10808,6 @@ var flattenCommand = (command) => { }; }; -// node_modules/effect/dist/internal/uuid.js -var hex = (byte) => byte.toString(16).padStart(2, "0"); -var stringify = (bytes) => { - const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; - return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); -}; -var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); -function v4Bytes(bytes = randomBytes()) { - bytes[6] = bytes[6] & 15 | 64; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); -var maxV7Timestamp = 2 ** 48 - 1; -function v7Bytes(timestampMillis, bytes = randomBytes()) { - const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); - bytes[0] = Math.floor(timestamp / 2 ** 40); - bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; - bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; - bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; - bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; - bytes[5] = timestamp & 255; - bytes[6] = bytes[6] & 15 | 112; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); - -// node_modules/effect/dist/Crypto.js -var TypeId25 = "~effect/Crypto"; -var Crypto2 = /* @__PURE__ */ Service("effect/Crypto"); -var make21 = (impl) => { - const randomBytesUnsafe = impl.randomBytes; - const randomBytes = (size) => map6(validateSize("randomBytes", size), randomBytesUnsafe); - const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; - const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; - const nextIntUnsafe = () => { - while (true) { - const bytes = randomBytesUnsafe(7); - const value = readUint53(bytes); - if ((bytes[0] & 32) === 0) { - return value + Number.MIN_SAFE_INTEGER; - } - if (value < Number.MAX_SAFE_INTEGER) { - return value + 1; - } - } - }; - return Crypto2.of({ - [TypeId25]: TypeId25, - randomBytes, - nextDoubleUnsafe, - nextIntUnsafe, - digest: impl.digest, - random: sync3(() => nextDoubleUnsafe()), - randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), - randomInt: sync3(() => nextIntUnsafe()), - randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), - randomIntBetween(min, max, options) { - const extra = options?.halfOpen === true ? 0 : 1; - return sync3(() => { - const minInt = Math.ceil(min); - const maxInt = Math.floor(max); - return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; - }); - }, - randomShuffle: (elements) => sync3(() => { - const buffer = Array.from(elements); - for (let i = buffer.length - 1;i >= 1; i = i - 1) { - const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); - const value = buffer[i]; - buffer[i] = buffer[index]; - buffer[index] = value; - } - return buffer; - }), - randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), - randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))) - }); -}; -var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ - module: "Crypto", - method, - description: "size must be a non-negative safe integer" -})); - // node_modules/@effect/platform-node-shared/dist/NodeCrypto.js import * as NodeCrypto from "node:crypto"; var toHashAlgorithm = (algorithm) => { @@ -10608,20 +10832,20 @@ var digest = (algorithm, data) => try_2({ cause }) }); -var make22 = /* @__PURE__ */ make21({ +var make23 = /* @__PURE__ */ make16({ randomBytes: NodeCrypto.randomBytes, digest }); -var layer3 = /* @__PURE__ */ succeed5(Crypto2, make22); +var layer3 = /* @__PURE__ */ succeed5(Crypto, make23); // node_modules/@effect/platform-node/dist/NodeCrypto.js var layer4 = layer3; // node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js -import * as Crypto3 from "node:crypto"; +import * as Crypto2 from "node:crypto"; import * as NFS from "node:fs"; import * as OS from "node:os"; -import * as Path3 from "node:path"; +import * as Path2 from "node:path"; var handleBadArgument = (method) => (err) => badArgument({ module: "FileSystem", method, @@ -10694,8 +10918,8 @@ var makeTempDirectoryFactory = (method) => { const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException("FileSystem", method), handleBadArgument(method)); return (options) => suspend2(() => { const prefix = options?.prefix ?? ""; - const directory = typeof options?.directory === "string" ? Path3.join(options.directory, ".") : OS.tmpdir(); - return nodeMkdtemp(prefix ? Path3.join(directory, prefix) : directory + "/"); + const directory = typeof options?.directory === "string" ? Path2.join(options.directory, ".") : OS.tmpdir(); + return nodeMkdtemp(prefix ? Path2.join(directory, prefix) : directory + "/"); }); }; var makeTempDirectory = /* @__PURE__ */ makeTempDirectoryFactory("makeTempDirectory"); @@ -10717,7 +10941,7 @@ var makeTempDirectoryScoped = /* @__PURE__ */ (() => { var openFactory = (method) => { const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method)); const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method)); - return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map6((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); + return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map5((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); }; var open2 = /* @__PURE__ */ openFactory("open"); var makeFile = /* @__PURE__ */ (() => { @@ -10766,7 +10990,7 @@ var makeFile = /* @__PURE__ */ (() => { read(buffer) { return suspend2(() => { const position = this.position; - return map6(nodeRead(this.fd, { + return map5(nodeRead(this.fd, { buffer, position }), (bytesRead) => { @@ -10783,7 +11007,7 @@ var makeFile = /* @__PURE__ */ (() => { } const buffer = Buffer.allocUnsafeSlow(size); const position = this.position; - return map6(nodeReadAlloc(this.fd, { + return map5(nodeReadAlloc(this.fd, { buffer, position }), (bytesRead) => { @@ -10804,7 +11028,7 @@ var makeFile = /* @__PURE__ */ (() => { }); } truncate(length) { - return map6(nodeTruncate(this.fd, length || undefined), () => { + return map5(nodeTruncate(this.fd, length || undefined), () => { if (!this.append) { const len = BigInt(length ?? 0); if (this.position > len) { @@ -10816,7 +11040,7 @@ var makeFile = /* @__PURE__ */ (() => { write(buffer) { return suspend2(() => { const position = this.position; - return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map6(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { + return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map5(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { if (!this.append) { this.position = position + BigInt(bytesWritten); } @@ -10854,8 +11078,8 @@ var makeTempFileFactory = (method) => { const makeDirectory = makeTempDirectoryFactory(method); return fnUntraced2(function* (options) { const directory = yield* makeDirectory(options); - const random = Crypto3.randomBytes(6).toString("hex"); - const name = Path3.join(directory, options?.suffix ? `${random}${options.suffix}` : random); + const random = Crypto2.randomBytes(6).toString("hex"); + const name = Path2.join(directory, options?.suffix ? `${random}${options.suffix}` : random); yield* writeFile2(name, new Uint8Array(0)); return name; }); @@ -10864,7 +11088,7 @@ var makeTempFile = /* @__PURE__ */ makeTempFileFactory("makeTempFile"); var makeTempFileScoped = /* @__PURE__ */ (() => { const makeFile = /* @__PURE__ */ makeTempFileFactory("makeTempFileScoped"); const removeDirectory = /* @__PURE__ */ removeFactory("makeTempFileScoped"); - return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path3.dirname(file), { + return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path2.dirname(file), { recursive: true }))); })(); @@ -10937,7 +11161,7 @@ var utimes2 = /* @__PURE__ */ (() => { return (path, atime, mtime) => nodeUtimes(path, atime, mtime); })(); var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sync3(() => { - const directory = info.type === "Directory" ? path : Path3.dirname(path); + const directory = info.type === "Directory" ? path : Path2.dirname(path); const watcher = NFS.watch(path, { recursive: options?.recursive ?? false }, (event, path) => { @@ -10945,7 +11169,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy return; switch (event) { case "rename": { - runFork2(matchEffect3(stat2(Path3.resolve(directory, path)), { + runFork2(matchEffect3(stat2(Path2.resolve(directory, path)), { onSuccess: (_) => offer(queue, { _tag: "Create", path @@ -10967,7 +11191,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy } }); watcher.on("error", (error) => { - failCauseUnsafe(queue, fail5(systemError({ + failCauseUnsafe(queue, fail4(systemError({ module: "FileSystem", _tag: "Unknown", method: "watch", @@ -10980,7 +11204,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy }); return watcher; }), (watcher) => sync3(() => watcher.close()))); -var watch2 = (backend, path, options) => stat2(path).pipe(map6((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); +var watch2 = (backend, path, options) => stat2(path).pipe(map5((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); var writeFile2 = (path, data, options) => callback2((resume, signal) => { try { NFS.writeFile(path, data, { @@ -10998,7 +11222,7 @@ var writeFile2 = (path, data, options) => callback2((resume, signal) => { resume(fail6(handleBadArgument("writeFile")(err))); } }); -var makeFileSystem = /* @__PURE__ */ map6(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make12({ +var makeFileSystem = /* @__PURE__ */ map5(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make15({ access: access2, chmod: chmod2, chown: chown2, @@ -11057,18 +11281,18 @@ var fileUrlOps = (windows) => ({ }) }) }); -var layerPosix = /* @__PURE__ */ succeed5(Path2)({ - [TypeId24]: TypeId24, +var layerPosix = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.posix, .../* @__PURE__ */ fileUrlOps(false) }); -var layerWin32 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId24]: TypeId24, +var layerWin32 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.win32, .../* @__PURE__ */ fileUrlOps(true) }); -var layer7 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId24]: TypeId24, +var layer7 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath, .../* @__PURE__ */ fileUrlOps(undefined) }); @@ -11076,18 +11300,8 @@ var layer7 = /* @__PURE__ */ succeed5(Path2)({ // node_modules/@effect/platform-node/dist/NodePath.js var layer8 = layer7; -// node_modules/effect/dist/Stdio.js -var TypeId26 = "~effect/Stdio"; -var Stdio2 = /* @__PURE__ */ Service(TypeId26); -var make23 = (options) => ({ - [TypeId26]: TypeId26, - stdinIsTerminal: succeed6(false), - stdoutIsTerminal: succeed6(false), - ...options -}); - // node_modules/@effect/platform-node-shared/dist/NodeStdio.js -var layer9 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make23({ +var layer9 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make18({ args: /* @__PURE__ */ sync3(() => process.argv.slice(2)), stdinIsTerminal: /* @__PURE__ */ sync3(() => process.stdin.isTTY === true), stdoutIsTerminal: /* @__PURE__ */ sync3(() => process.stdout.isTTY === true), @@ -11126,24 +11340,9 @@ var layer9 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make23({ // node_modules/@effect/platform-node/dist/NodeStdio.js var layer10 = layer9; -// node_modules/effect/dist/Terminal.js -var TypeId27 = "~effect/Terminal"; -var QuitErrorTypeId = "~effect/Terminal/QuitError"; - -class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ - _tag: /* @__PURE__ */ tag3("QuitError") -})) { - [QuitErrorTypeId] = QuitErrorTypeId; -} -var Terminal2 = /* @__PURE__ */ Service("effect/Terminal"); -var make24 = (impl) => Terminal2.of({ - ...impl, - [TypeId27]: TypeId27 -}); - // node_modules/@effect/platform-node-shared/dist/NodeTerminal.js import * as readline from "node:readline"; -var make25 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { +var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { const stdin = process.stdin; const stdout = process.stdout; const lines = yield* make9(); @@ -11157,7 +11356,7 @@ var make25 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu }; stdin.once("end", onStdinEnd); yield* addFinalizer3(() => sync3(() => stdin.off("end", onStdinEnd))); - const rlRef = yield* make11({ + const rlRef = yield* make14({ acquire: acquireRelease2(sync3(() => { const rl = readline.createInterface({ input: stdin, @@ -11248,7 +11447,7 @@ var make25 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu cause: err })))); })); - return make24({ + return make19({ columns, rows, readInput, @@ -11256,7 +11455,7 @@ var make25 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu display }); }); -var layer11 = /* @__PURE__ */ effect(Terminal2, /* @__PURE__ */ make25(defaultShouldQuit)); +var layer11 = /* @__PURE__ */ effect(Terminal, /* @__PURE__ */ make24(defaultShouldQuit)); function defaultShouldQuit(input) { return input.key.ctrl && (input.key.name === "c" || input.key.name === "d"); } @@ -11311,7 +11510,7 @@ var layer14 = sync2(Service2, () => { class TestService extends Service()("@timmo001/workflows/Annotations/Test") { } var testLayer = effectContext(gen2(function* () { - const recorded = yield* make13([]); + const recorded = yield* make17([]); const write = (line) => update(recorded, (lines) => [...lines, line]); const service = TestService.of({ error: fn2("Annotations.Test.error")(function* (message, properties) { @@ -11333,7 +11532,7 @@ var testLayer = effectContext(gen2(function* () { return yield* get4(recorded); }) }); - return empty().pipe(add(Service2, service), add(TestService, service)); + return empty2().pipe(add(Service2, service), add(TestService, service)); })); class ActionFailure extends TaggedError3()("ActionFailure", { @@ -11357,7 +11556,7 @@ class Service3 extends Service()("@timmo001/workflows/CommandExecutor") { } var layer15 = effect(Service3, gen2(function* () { const spawner = yield* ChildProcessSpawner; - const make = (command, args, options) => make19(command, args, { + const make = (command, args, options) => make21(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true @@ -11396,7 +11595,7 @@ var layer15 = effect(Service3, gen2(function* () { const stream = fn2("CommandExecutor.stream")(function* (command, args, options) { const label = options?.label ?? `${command} ${args.join(" ")}`.trim(); return yield* scoped2(gen2(function* () { - const handle = yield* spawner.spawn(make19(command, args, { + const handle = yield* spawner.spawn(make21(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true, @@ -11472,7 +11671,7 @@ ${delimiter} }); // src/action/GitHubCommand.ts -var make26 = fn2("GitHubCommand.make")(function* (label) { +var make25 = fn2("GitHubCommand.make")(function* (label) { const gh = yield* Gh; let stderrTail = ""; const writeStderr = (text) => sync3(() => { @@ -11481,7 +11680,7 @@ var make26 = fn2("GitHubCommand.make")(function* (label) { }); const mapError = mapError2((error) => new ActionFailure({ title: "Command failed", - message: value2(error).pipe(tag2("GhCommandError", (error) => stderrTail.trim() || `Command failed with exit code ${error.exitCode}: ${label}`), tag2("GhTimeoutError", (error) => `Command timed out after ${error.timeoutMs}ms: ${label}`), tag2("GhPlatformError", "GhDecodeError", (error) => String(error.cause)), exhaustive2) + message: value2(error).pipe(tag3("GhCommandError", (error) => stderrTail.trim() || `Command failed with exit code ${error.exitCode}: ${label}`), tag3("GhTimeoutError", (error) => `Command timed out after ${error.timeoutMs}ms: ${label}`), tag3("GhPlatformError", "GhDecodeError", (error) => String(error.cause)), exhaustive2) })); const stream = fn2("GitHubCommand.stream")(function* (args, options = {}) { yield* gh.stream(args, options).pipe(runForEach2((chunk) => isTagged(chunk, "Stderr") ? writeStderr(chunk.text) : sync3(() => { @@ -11688,7 +11887,7 @@ var allocateVersion = fn2("ReleaseBunCli.allocateVersion")(function* (inputs) { var validateInputs = fn2("ReleaseBunCli.validateInputs")(function* (inputs) { yield* requireIdentity(inputs); }); -var compile = fn2("ReleaseBunCli.compile")(function* (inputs) { +var compile2 = fn2("ReleaseBunCli.compile")(function* (inputs) { const commands = yield* Service3; const identity = yield* requireIdentity(inputs); const architecture = yield* requireInput(inputs.architecture, "architecture"); @@ -11788,7 +11987,7 @@ var publishRelease = fn2("ReleaseBunCli.publishRelease")(function* (inputs) { const sourceSha = yield* requireInput(inputs.sourceSha, "source-sha"); const gh = yield* Gh; const label = "publish GitHub release"; - const github = yield* make26(label); + const github = yield* make25(label); const env = { ASSET_ROOT: assetRoot, EXISTING_RELEASE: inputs.existingRelease ?? "false", @@ -11799,7 +11998,7 @@ var publishRelease = fn2("ReleaseBunCli.publishRelease")(function* (inputs) { const assets = commands.run("bash", ["-c", `set -euo pipefail printf "%s\\0" "$ASSET_ROOT"/*`], { env - }).pipe(mapCommand, map6((stdout) => stdout.split("\x00").slice(0, -1))); + }).pipe(mapCommand, map5((stdout) => stdout.split("\x00").slice(0, -1))); if (env.EXISTING_RELEASE === "true") { yield* github.stream(["release", "view", releaseVersion], { env, @@ -11851,7 +12050,7 @@ var run3 = fn2("ReleaseBunCli.run")(function* (inputs) { case "validate-inputs": return yield* validateInputs(inputs); case "compile": - return yield* compile(inputs); + return yield* compile2(inputs); case "smoke-test": return yield* smokeTest(inputs); case "prepare-package": diff --git a/.github/actions/validate-agent-skills/dist/index.js b/.github/actions/validate-agent-skills/dist/index.js index 9f56f62b..7b1f53ea 100644 --- a/.github/actions/validate-agent-skills/dist/index.js +++ b/.github/actions/validate-agent-skills/dist/index.js @@ -490,6 +490,33 @@ function makeCompareSet(equivalence) { var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth); var isEqual = (u) => hasProperty(u, symbol2); +// node_modules/effect/dist/internal/array.js +var isArrayNonEmpty = (self) => self.length > 0; + +// node_modules/effect/dist/internal/count.js +var normalize = (n) => n > 0 ? Math.floor(n) : 0; + +// node_modules/effect/dist/internal/record.js +function assignProperty(self, key, value) { + if (key === "__proto__") { + Object.defineProperty(self, key, { + value, + writable: true, + enumerable: true, + configurable: true + }); + } else { + self[key] = value; + } +} +function assignProperties(self, source) { + for (const key of Reflect.ownKeys(source)) { + if (Object.prototype.propertyIsEnumerable.call(source, key)) { + assignProperty(self, key, source[key]); + } + } +} + // node_modules/effect/dist/Redactable.js var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Redactable"); var isRedactable = (u) => hasProperty(u, symbolRedactable); @@ -732,27 +759,6 @@ var pickInternalCall = () => { }; var internalCall = /* @__PURE__ */ pickInternalCall(); -// node_modules/effect/dist/internal/record.js -function assignProperty(self, key, value) { - if (key === "__proto__") { - Object.defineProperty(self, key, { - value, - writable: true, - enumerable: true, - configurable: true - }); - } else { - self[key] = value; - } -} -function assignProperties(self, source) { - for (const key of Reflect.ownKeys(source)) { - if (Object.prototype.propertyIsEnumerable.call(source, key)) { - assignProperty(self, key, source[key]); - } - } -} - // node_modules/effect/dist/internal/core.js var EffectTypeId = `~effect/Effect`; var ExitTypeId = `~effect/Exit`; @@ -1121,12 +1127,6 @@ var done = (value) => { return exitFail(Done(value)); }; -// node_modules/effect/dist/Effectable.js -var Prototype2 = (options) => makePrimitiveProto({ - op: options.label, - [evaluate]: options.evaluate -}); - // node_modules/effect/dist/internal/option.js var TypeId = "~effect/Option"; var CommonProto = { @@ -1288,9 +1288,40 @@ var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone var fromNullishOr = (a) => a == null ? none2() : some2(a); var fromUndefinedOr = (a) => a === undefined ? none2() : some2(a); var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined); -var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value))); var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value)); -var filter = /* @__PURE__ */ dual(2, (self, predicate) => isNone2(self) ? none2() : predicate(self.value) ? some2(self.value) : none2()); + +// node_modules/effect/dist/Result.js +var succeed2 = succeed; +var fail2 = fail; +var isFailure2 = isFailure; +var match2 = /* @__PURE__ */ dual(2, (self, { + onFailure, + onSuccess +}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); + +// node_modules/effect/dist/Array.js +var Array2 = globalThis.Array; +var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); +var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); +var isArray = Array2.isArray; +var isArrayNonEmpty2 = isArrayNonEmpty; +var isReadonlyArrayNonEmpty = isArrayNonEmpty; +var empty = () => []; +var of = (a) => [a]; +var map = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); +// node_modules/effect/dist/BigInt.js +var BigInt2 = globalThis.BigInt; +var toNumber = (b) => { + if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { + return none2(); + } + return some2(Number(b)); +}; +// node_modules/effect/dist/Effectable.js +var Prototype2 = (options) => makePrimitiveProto({ + op: options.label, + [evaluate]: options.evaluate +}); // node_modules/effect/dist/Context.js var ServiceTypeId = "~effect/Context/Service"; @@ -1431,7 +1462,7 @@ var Proto = { var hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot; var isContext = (u) => hasProperty(u, TypeId3); var isReference = (u) => !!u[ReferenceTypeId]; -var empty = () => emptyContext2; +var empty2 = () => emptyContext2; var emptyContext2 = /* @__PURE__ */ makeUnsafe(/* @__PURE__ */ new Map); var make2 = (key, service) => makeUnsafe(new Map([[key.key, service]])); var add = /* @__PURE__ */ dual(3, (self, key, service) => addUnsafe(self, key.key, service)); @@ -1505,33 +1536,7 @@ var mergeAll = (...ctxs) => { return makeUnsafe(map); }; var Reference = Service; -// node_modules/effect/dist/Data.js -var taggedEnum = () => new Proxy({}, { - get(_target, tag, _receiver) { - if (tag === "$is") { - return isTagged; - } else if (tag === "$match") { - return taggedMatch; - } - return (props) => ({ - ...props, - _tag: tag - }); - } -}); -function taggedMatch() { - if (arguments.length === 1) { - const cases = arguments[0]; - return function(value) { - return cases[value._tag](value); - }; - } - const value = arguments[0]; - const cases = arguments[1]; - return cases[value._tag](value); -} -var Error3 = Error2; -var TaggedError2 = TaggedError; + // node_modules/effect/dist/Duration.js var TypeId4 = "~effect/Duration"; var bigint0 = /* @__PURE__ */ BigInt(0); @@ -1755,7 +1760,7 @@ var minutes = (minutes) => make3(minutes * 60000); var hours = (hours) => make3(hours * 3600000); var days = (days) => make3(days * 86400000); var weeks = (weeks) => make3(weeks * 604800000); -var toMillis = (self) => match2(fromInputUnsafe(self), { +var toMillis = (self) => match3(fromInputUnsafe(self), { onMillis: identity, onNanos: (nanos) => Number(nanos) / 1e6, onInfinity: () => Infinity, @@ -1773,7 +1778,7 @@ var toNanosUnsafe = (input) => { return roundMillisToNanos(self.value.millis); } }; -var match2 = /* @__PURE__ */ dual(2, (self, options) => { +var match3 = /* @__PURE__ */ dual(2, (self, options) => { switch (self.value._tag) { case "Millis": return options.onMillis(self.value.millis); @@ -1801,32 +1806,6 @@ var Equivalence = (self, that) => matchPair(self, that, { }); var equals2 = /* @__PURE__ */ dual(2, (self, that) => Equivalence(self, that)); -// node_modules/effect/dist/internal/array.js -var isArrayNonEmpty = (self) => self.length > 0; - -// node_modules/effect/dist/internal/count.js -var normalize = (n) => n > 0 ? Math.floor(n) : 0; - -// node_modules/effect/dist/Result.js -var succeed2 = succeed; -var fail2 = fail; -var isFailure2 = isFailure; -var match3 = /* @__PURE__ */ dual(2, (self, { - onFailure, - onSuccess -}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); - -// node_modules/effect/dist/Array.js -var Array2 = globalThis.Array; -var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); -var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); -var isArray = Array2.isArray; -var isArrayNonEmpty2 = isArrayNonEmpty; -var isReadonlyArrayNonEmpty = isArrayNonEmpty; -var empty2 = () => []; -var of = (a) => [a]; -var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); - // node_modules/effect/dist/Scheduler.js var Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", { fiberCached: true, @@ -1944,6 +1923,34 @@ var PreventSchedulerYield = /* @__PURE__ */ Reference("effect/Scheduler/PreventS defaultValue: () => false }); +// node_modules/effect/dist/Data.js +var taggedEnum = () => new Proxy({}, { + get(_target, tag, _receiver) { + if (tag === "$is") { + return isTagged; + } else if (tag === "$match") { + return taggedMatch; + } + return (props) => ({ + ...props, + _tag: tag + }); + } +}); +function taggedMatch() { + if (arguments.length === 1) { + const cases = arguments[0]; + return function(value) { + return cases[value._tag](value); + }; + } + const value = arguments[0]; + const cases = arguments[1]; + return cases[value._tag](value); +} +var Error3 = Error2; +var TaggedError2 = TaggedError; + // node_modules/effect/dist/Encoding.js var EncodingErrorTypeId = "~effect/Encoding/EncodingError"; @@ -2569,7 +2576,7 @@ class FiberImpl { } this._stack.length = 0; this._children = undefined; - this.context = empty(); + this.context = empty2(); } runLoop(effect) { const prevFiber = globalThis[currentFiberTypeId]; @@ -2741,7 +2748,7 @@ var fiberInterruptAs = /* @__PURE__ */ dual((args) => hasProperty(args[0], Fiber })); var fiberInterruptAll = (fibers) => withFiber((parent) => { const annotations = fiberStackAnnotations(parent); - let fiberArr = empty2(); + let fiberArr = empty(); for (const fiber of fibers) { fiber.interruptUnsafe(parent.id, annotations); fiberArr.push(fiber); @@ -2765,7 +2772,7 @@ var suspend = /* @__PURE__ */ makePrimitive({ return this[args](); } }); -var fromResult = /* @__PURE__ */ match3({ +var fromResult = /* @__PURE__ */ match2({ onFailure: fail3, onSuccess: succeed3 }); @@ -3058,7 +3065,7 @@ var tapCont = function(value) { var tapEffectCont = function(value) { return new ContImpl(this.payload, returnPayload, exitSucceed(value)); }; -var asSome = (self) => map4(self, some2); +var asSome = (self) => map3(self, some2); var andThen = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? returnPayload : andThenCont, f)); var tap = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? tapEffectCont : tapCont, f)); var asVoid = (self) => new ContImpl(self, returnPayload, exitVoid); @@ -3100,8 +3107,8 @@ var flatMapEager = /* @__PURE__ */ dual(2, (self, f) => { } return flatMap2(self, f); }); -var map4 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); -var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map4(self, f)); +var map3 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); +var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map3(self, f)); var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError(self, f)); var exitInterrupt = (fiberId) => exitFailCause(causeInterrupt(fiberId)); var exitIsSuccess = (self) => self._tag === "Success"; @@ -3476,7 +3483,7 @@ var all = (arg, options) => { } return suspend(() => { const out = {}; - return as(forEach(Object.entries(arg), ([key, effect]) => map4(options?.mode === "result" ? result(effect) : effect, (value) => { + return as(forEach(Object.entries(arg), ([key, effect]) => map3(options?.mode === "result" ? result(effect) : effect, (value) => { assignProperty(out, key, value); }), { discard: true, @@ -3752,7 +3759,7 @@ var fiberRunIn = /* @__PURE__ */ dual(2, (self, scope) => { self.addObserver(() => scopeRemoveFinalizerUnsafe(scope, key)); return self; }); -var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty()); +var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty2()); var runSyncExitWith = (context) => { const runFork = runForkWith(context); return (effect) => { @@ -3766,7 +3773,7 @@ var runSyncExitWith = (context) => { return fiber._exit ?? exitDie(new AsyncFiberError(fiber)); }; }; -var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty()); +var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty2()); var succeedTrue = /* @__PURE__ */ succeed3(true); var succeedFalse = /* @__PURE__ */ succeed3(false); @@ -3887,7 +3894,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = noopSpan({ name, parent, - annotations: add(options?.annotations ?? empty(), DisablePropagation, true) + annotations: add(options?.annotations ?? empty2(), DisablePropagation, true) }); } else { const tracer = fiber.getRef(Tracer); @@ -3900,7 +3907,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = tracer.span({ name, parent, - annotations: options?.annotations ?? empty(), + annotations: options?.annotations ?? empty2(), links, startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : bigint02, kind: options?.kind ?? "internal", @@ -4186,10 +4193,23 @@ var tracerLogger = /* @__PURE__ */ loggerMake(({ span.event(toStringUnknown(Array.isArray(message) && message.length === 1 ? message[0] : message), clock.currentTimeNanosUnsafe(), attributes); }); +// node_modules/effect/dist/Cause.js +var isFailReason2 = isFailReason; +var fromReasons = causeFromReasons; +var fail4 = causeFail; +var die2 = causeDie; +var hasInterruptsOnly2 = hasInterruptsOnly; +var map4 = causeMap; +var squash = causeSquash; +var isDone2 = isDone; +var Done2 = Done; +var done2 = done; +var UnknownError2 = UnknownError; + // node_modules/effect/dist/Exit.js var succeed4 = exitSucceed; var failCause2 = exitFailCause; -var fail4 = exitFail; +var fail5 = exitFail; var void_2 = exitVoid; var isSuccess3 = exitIsSuccess; var isFailure3 = exitIsFailure; @@ -4226,8 +4246,8 @@ var _await = (self) => callback((resume) => { }); }); var completeWith = /* @__PURE__ */ dual(2, (self, effect) => sync(() => doneUnsafe(self, effect))); -var done2 = completeWith; -var isDone2 = (self) => sync(() => isDoneUnsafe(self)); +var done3 = completeWith; +var isDone3 = (self) => sync(() => isDoneUnsafe(self)); var isDoneUnsafe = (self) => self.effect !== undefined; var doneUnsafe = (self, effect) => { if (self.effect) @@ -4300,7 +4320,7 @@ var memoMapBuild = (memoMap, layer, scope, build) => { memoMap.map.set(layer, entry); return scopeAddFinalizerExit(scope, entry.finalizer).pipe(flatMap2(() => build(memoMap, layerScope)), onExit((exit) => { entry.effect = exit; - return done2(deferred, exit); + return done3(deferred, exit); })); }; @@ -4338,7 +4358,7 @@ class CurrentMemoMap extends (/* @__PURE__ */ Service()("effect/Layer/CurrentMem return current ? forkMemoMapUnsafe(current) : makeMemoMapUnsafe(); } } -var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map4(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); +var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map3(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); var buildWithScope = /* @__PURE__ */ dual(2, (self, scope) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope))); var succeed5 = function() { if (arguments.length === 1) { @@ -4360,31 +4380,19 @@ var effect = function() { } return effectImpl(arguments[0], arguments[1]); }; -var effectImpl = (service, effect) => effectContext(map4(effect, (value) => make2(service, value))); +var effectImpl = (service, effect) => effectContext(map3(effect, (value) => make2(service, value))); var effectContext = (effect) => fromBuildMemo((_, scope) => provide(effect, scope)); var mergeAllEffect = (layers, memoMap, scope) => { const parentScope = forkUnsafe2(scope, "parallel"); return forEach(layers, (layer) => layer.build(memoMap, forkUnsafe2(parentScope, "sequential")), { concurrency: layers.length - }).pipe(map4((context) => mergeAll(...context))); + }).pipe(map3((context) => mergeAll(...context))); }; var mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope)); -var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map4((merged) => f(merged, context))))); +var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map3((merged) => f(merged, context))))); var provide2 = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, identity)); var provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self))); -// node_modules/effect/dist/Cause.js -var isFailReason2 = isFailReason; -var fromReasons = causeFromReasons; -var fail5 = causeFail; -var hasInterruptsOnly2 = hasInterruptsOnly; -var map5 = causeMap; -var squash = causeSquash; -var isDone3 = isDone; -var Done2 = Done; -var done3 = done; -var UnknownError2 = UnknownError; - // node_modules/effect/dist/internal/random.js var nextBetween = (min, max, draw) => { const value = draw * (max - min) + min; @@ -4404,7 +4412,7 @@ var nextBetween = (min, max, draw) => { // node_modules/effect/dist/Pull.js var catchDone = /* @__PURE__ */ dual(2, (effect, f) => catchCauseFilter(effect, filterDoneLeftover, (l) => f(l))); var isDoneCause = (cause) => cause.reasons.some(isDoneFailure); -var isDoneFailure = (failure) => failure._tag === "Fail" && isDone3(failure.error); +var isDoneFailure = (failure) => failure._tag === "Fail" && isDone2(failure.error); var filterDone = (cause) => { let done; let hasFailure = false; @@ -4446,7 +4454,6 @@ var forEach2 = forEach; var whileLoop2 = whileLoop; var tryPromise2 = tryPromise; var succeed6 = succeed3; -var succeedNone2 = succeedNone; var suspend2 = suspend; var sync3 = sync; var void_3 = void_; @@ -4455,7 +4462,7 @@ var gen2 = gen; var fail6 = fail3; var failCause3 = failCause; var failCauseSync2 = failCauseSync; -var die2 = die; +var die3 = die; var try_2 = try_; var withFiber2 = withFiber; var fromResult2 = fromResult; @@ -4463,7 +4470,7 @@ var flatMap3 = flatMap2; var andThen2 = andThen; var tap2 = tap; var exit2 = exit; -var map6 = map4; +var map5 = map3; var as2 = as; var catch_2 = catch_; var catchTag2 = catchTag; @@ -4509,1358 +4516,203 @@ var effectify = (fn, onError, onSyncError) => (...args) => callback2((resume) => } }); } catch (err) { - resume(onSyncError ? fail6(onSyncError(err, args)) : die2(err)); + resume(onSyncError ? fail6(onSyncError(err, args)) : die3(err)); } }); var mapEager2 = mapEager; var mapErrorEager2 = mapErrorEager; var flatMapEager2 = flatMapEager; var fnUntracedEager2 = fnUntracedEager; -// node_modules/effect/dist/BigInt.js -var BigInt2 = globalThis.BigInt; -var toNumber = (b) => { - if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { - return none2(); + +// node_modules/effect/dist/internal/schema/annotations.js +function resolve(ast) { + return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; +} +var STRUCTURAL_ANNOTATION_KEY = "~structural"; +var SENTINELS_ANNOTATION_KEY = "~sentinels"; +var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; +var getExpected = /* @__PURE__ */ memoize((ast) => { + const identifier = resolve(ast)?.identifier; + if (typeof identifier === "string") + return identifier; + return ast.getExpected(getExpected); +}); + +// node_modules/effect/dist/internal/schema/parser.js +var missing = /* @__PURE__ */ Symbol(); +var succeed7 = succeed4; +var missingExit = /* @__PURE__ */ succeed7(missing); +var sameExit = /* @__PURE__ */ succeed7(missing); +var toOption = (value) => value === missing ? none2() : some2(value); +var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed7(option.value); + +// node_modules/effect/dist/SchemaIssue.js +var TypeId7 = "~effect/SchemaIssue/Issue"; +function isIssue(u) { + return hasProperty(u, TypeId7) && u[TypeId7] === TypeId7; +} +function hasInput(issue) { + return Object.hasOwn(issue, "input"); +} + +class IssueNodeImpl { + [TypeId7] = TypeId7; + constructor(input, options) { + if (options?.reportInput === true && input !== missing) { + this.input = input; + } + } +} +var Filter = class extends IssueNodeImpl { + _tag = "Filter"; + filter; + issue; + constructor(filter, issue, input, options) { + super(input, options); + this.filter = filter; + this.issue = issue; } - return some2(Number(b)); }; - -// node_modules/effect/dist/ByteSize.js -var bigint03 = /* @__PURE__ */ BigInt(0); -var bigint12 = /* @__PURE__ */ BigInt(1); -var decimalBase = /* @__PURE__ */ BigInt(1000); -var binaryBase = /* @__PURE__ */ BigInt(1024); -var decimalUnits = [{ - symbol: "B", - factor: bigint12, - names: ["B", "byte", "bytes"] -}, { - symbol: "kB", - factor: decimalBase, - names: ["kB", "kilobyte", "kilobytes"] -}, { - symbol: "MB", - factor: decimalBase ** /* @__PURE__ */ BigInt(2), - names: ["MB", "megabyte", "megabytes"] -}, { - symbol: "GB", - factor: decimalBase ** /* @__PURE__ */ BigInt(3), - names: ["GB", "gigabyte", "gigabytes"] -}, { - symbol: "TB", - factor: decimalBase ** /* @__PURE__ */ BigInt(4), - names: ["TB", "terabyte", "terabytes"] -}, { - symbol: "PB", - factor: decimalBase ** /* @__PURE__ */ BigInt(5), - names: ["PB", "petabyte", "petabytes"] -}, { - symbol: "EB", - factor: decimalBase ** /* @__PURE__ */ BigInt(6), - names: ["EB", "exabyte", "exabytes"] -}, { - symbol: "ZB", - factor: decimalBase ** /* @__PURE__ */ BigInt(7), - names: ["ZB", "zettabyte", "zettabytes"] -}, { - symbol: "YB", - factor: decimalBase ** /* @__PURE__ */ BigInt(8), - names: ["YB", "yottabyte", "yottabytes"] -}, { - symbol: "RB", - factor: decimalBase ** /* @__PURE__ */ BigInt(9), - names: ["RB", "ronnabyte", "ronnabytes"] -}, { - symbol: "QB", - factor: decimalBase ** /* @__PURE__ */ BigInt(10), - names: ["QB", "quettabyte", "quettabytes"] -}]; -var binaryUnits = [decimalUnits[0], { - symbol: "KiB", - factor: binaryBase, - names: ["KiB", "kibibyte", "kibibytes"] -}, { - symbol: "MiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(2), - names: ["MiB", "mebibyte", "mebibytes"] -}, { - symbol: "GiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(3), - names: ["GiB", "gibibyte", "gibibytes"] -}, { - symbol: "TiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(4), - names: ["TiB", "tebibyte", "tebibytes"] -}, { - symbol: "PiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(5), - names: ["PiB", "pebibyte", "pebibytes"] -}, { - symbol: "EiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(6), - names: ["EiB", "exbibyte", "exbibytes"] -}, { - symbol: "ZiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(7), - names: ["ZiB", "zebibyte", "zebibytes"] -}, { - symbol: "YiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(8), - names: ["YiB", "yobibyte", "yobibytes"] -}]; -var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; -var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); -var make5 = (value) => value; -var invalid2 = (message) => { - throw new Error(`Invalid ByteSize: ${message}`); +var Encoding = class extends IssueNodeImpl { + _tag = "Encoding"; + ast; + issue; + constructor(ast, issue, input, options) { + super(input, options); + this.ast = ast; + this.issue = issue; + } }; -var fromNumber = (input) => { - if (!Number.isSafeInteger(input) || input < 0) { - return invalid2(`expected a non-negative safe integer, received ${input}`); +var Pointer = class extends IssueNodeImpl { + _tag = "Pointer"; + path; + issue; + constructor(path, issue) { + super(); + this.path = path; + this.issue = issue; } - return make5(BigInt(input)); }; -var parse = (input) => { - const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); - if (match === null) - return invalid2(`unsupported syntax ${JSON.stringify(input)}`); - const unit = unitsByName.get(match[3]); - if (unit === undefined) - return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); - const fraction = match[2] ?? ""; - const scale = BigInt(10) ** BigInt(fraction.length); - const numerator = BigInt(match[1] + fraction) * unit.factor; - if (numerator % scale !== bigint03) { - return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); +var MissingKey = class extends IssueNodeImpl { + _tag = "MissingKey"; + annotations; + constructor(annotations) { + super(); + this.annotations = annotations; } - return make5(numerator / scale); }; -var fromInputUnsafe2 = (input) => { - switch (typeof input) { - case "bigint": - if (input < bigint03) - return invalid2(`expected a non-negative bigint, received ${input}`); - return make5(input); - case "number": - return fromNumber(input); - case "string": - return parse(input); +var UnexpectedKey = class extends IssueNodeImpl { + _tag = "UnexpectedKey"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; } - return invalid2(`unsupported input ${input}`); }; -var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); - -// node_modules/effect/dist/PlatformError.js -var TypeId7 = "~effect/PlatformError"; - -class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { - get message() { - return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; +var Composite = class extends IssueNodeImpl { + _tag = "Composite"; + ast; + issues; + constructor(ast, issues, input, options) { + super(input, options); + this.ast = ast; + this.issues = issues; + } +}; +var InvalidType = class extends IssueNodeImpl { + _tag = "InvalidType"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; + } +}; +var InvalidValue = class extends IssueNodeImpl { + _tag = "InvalidValue"; + annotations; + constructor(annotations, input, options) { + super(input, options); + this.annotations = annotations; + } +}; +var AnyOf = class extends IssueNodeImpl { + _tag = "AnyOf"; + ast; + issues; + constructor(ast, issues, input, options) { + super(input, options); + this.ast = ast; + this.issues = issues; + } +}; +var OneOf = class extends IssueNodeImpl { + _tag = "OneOf"; + ast; + successes; + constructor(ast, successes, input, options) { + super(input, options); + this.ast = ast; + this.successes = successes; + } +}; +function makeFilterIssue(entry, input, options) { + if (isIssue(entry)) { + return entry; + } + if (typeof entry === "string") { + return new InvalidValue({ + message: entry + }, input, options); } + const inner = typeof entry.issue === "string" ? new InvalidValue({ + message: entry.issue + }, input, options) : entry.issue; + return new Pointer(entry.path, inner); } - -class SystemError extends Error3 { - get message() { - return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; +function makeSingle(out, input, options) { + if (out === undefined) { + return; + } + if (typeof out === "boolean") { + return out ? undefined : new InvalidValue(undefined, input, options); } + return makeFilterIssue(out, input, options); } - -class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { - constructor(reason) { - if ("cause" in reason) { - super({ - reason, - cause: reason.cause - }); - } else { - super({ - reason - }); +function normalizeFilterOutput(ast, out, input, options) { + if (Array.isArray(out)) { + if (!isReadonlyArrayNonEmpty(out)) { + return; } + return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map(out, (entry) => makeFilterIssue(entry, input, options)), input, options); } - [TypeId7] = TypeId7; - get message() { - return this.reason.message; - } + return makeSingle(out, input, options); } -var systemError = (options) => new PlatformError(new SystemError(options)); -var badArgument = (options) => new PlatformError(new BadArgument(options)); - -// node_modules/effect/dist/Fiber.js -var interrupt3 = fiberInterrupt; -var runIn = fiberRunIn; - -// node_modules/effect/dist/Latch.js -var makeUnsafe4 = makeLatchUnsafe; - -// node_modules/effect/dist/MutableRef.js -var TypeId8 = "~effect/MutableRef"; -var MutableRefProto = { - [TypeId8]: TypeId8, - ...PipeInspectableProto, - toJSON() { - return { - _id: "MutableRef", - current: toJson(this.current) - }; - } -}; -var make6 = (value) => { - const ref = Object.create(MutableRefProto); - ref.current = value; - return ref; -}; - -// node_modules/effect/dist/MutableList.js -var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); -var make7 = () => ({ - head: undefined, - tail: undefined, - length: 0 -}); -var emptyBucket = () => ({ - array: [], - mutable: true, - offset: 0, - next: undefined -}); -var append2 = (self, message) => { - if (!self.tail) { - self.head = self.tail = emptyBucket(); - } else if (!self.tail.mutable) { - self.tail.next = emptyBucket(); - self.tail = self.tail.next; - } - self.tail.array.push(message); - self.length++; -}; -var clear = (self) => { - self.head = self.tail = undefined; - self.length = 0; -}; -var takeN = (self, n) => { - n = normalize(n); - if (n <= 0 || !self.head) - return []; - n = Math.min(n, self.length); - if (n === self.length && self.head?.offset === 0 && !self.head.next) { - const array = self.head.array; - clear(self); - return array; - } - const array = new Array(n); - let index = 0; - let chunk = self.head; - while (chunk) { - while (chunk.offset < chunk.array.length) { - array[index++] = chunk.array[chunk.offset]; - if (chunk.mutable) - chunk.array[chunk.offset] = undefined; - chunk.offset++; - if (index === n) { - self.head = chunk; - self.length -= n; - if (self.length === 0) - clear(self); - return array; - } - } - chunk = chunk.next; - } - clear(self); - return array; -}; -var take = (self) => { - if (!self.head) - return Empty; - const message = self.head.array[self.head.offset]; - if (self.head.mutable) - self.head.array[self.head.offset] = undefined; - self.head.offset++; - self.length--; - if (self.head.offset === self.head.array.length) { - if (self.head.next) { - self.head = self.head.next; - } else { - clear(self); - } - } - return message; -}; - -// node_modules/effect/dist/Queue.js -var TypeId9 = "~effect/Queue"; -var EnqueueTypeId = "~effect/Queue/Enqueue"; -var DequeueTypeId = "~effect/Queue/Dequeue"; -var variance = { - _A: identity, - _E: identity -}; -var QueueProto = { - [TypeId9]: variance, - [EnqueueTypeId]: variance, - [DequeueTypeId]: variance, - ...PipeInspectableProto, - toJSON() { - return { - _id: "effect/Queue", - state: this.state._tag, - size: sizeUnsafe(this) - }; - } -}; -var make8 = (options) => withFiber((fiber) => { - const self = Object.create(QueueProto); - self.dispatcher = fiber.currentDispatcher; - self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; - self.strategy = options?.strategy ?? "suspend"; - self.messages = make7(); - self.scheduleRunning = false; - self.state = { - _tag: "Open", - takers: new Set, - offers: new Set, - awaiters: new Set - }; - return succeed3(self); -}); -var bounded = (capacity) => make8({ - capacity -}); -var offer = (self, message) => suspend(() => { - if (self.state._tag !== "Open") { - return exitFalse; - } else if (self.messages.length >= self.capacity) { - switch (self.strategy) { - case "dropping": - return exitFalse; - case "suspend": - if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return exitTrue; - } - return offerRemainingSingle(self, message); - case "sliding": - take(self.messages); - append2(self.messages, message); - return exitTrue; - } - } - append2(self.messages, message); - scheduleReleaseTaker(self); - return exitTrue; -}); -var offerUnsafe = (self, message) => { - if (self.state._tag !== "Open") { - return false; - } else if (self.messages.length >= self.capacity) { - if (self.strategy === "sliding") { - take(self.messages); - append2(self.messages, message); - return true; - } else if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return true; - } - return false; - } - append2(self.messages, message); - scheduleReleaseTaker(self); - return true; -}; -var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); -var failCauseUnsafe = (self, cause) => { - if (self.state._tag !== "Open") { - return false; - } - const exit = exitFailCause(cause); - const fail = exitZipRight(exit, exitFailDone); - if (self.state.offers.size === 0 && self.messages.length === 0) { - finalize(self, fail); - return true; - } - self.state = { - ...self.state, - _tag: "Closing", - exit: fail - }; - return true; -}; -var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); -var shutdown = (self) => sync(() => { - if (self.state._tag === "Done") { - return true; - } - clear(self.messages); - const offers = self.state.offers; - finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); - if (offers.size > 0) { - for (const entry of offers) { - if (entry._tag === "Single") { - entry.resume(exitFalse); - } else { - entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); - } - } - offers.clear(); - } - return true; -}); -var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); -var takeBetween = (self, min, max) => { - min = normalize(min); - max = normalize(max); - return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); -}; -var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); -var poll = (self) => suspend(() => { - const result = takeUnsafe(self); - if (result === undefined) { - return succeed3(none2()); - } - if (result._tag === "Success") { - return succeed3(some2(result.value)); - } - return succeed3(none2()); -}); -var takeUnsafe = (self) => { - if (self.state._tag === "Done") { - return self.state.exit; - } - if (self.messages.length > 0) { - const message = take(self.messages); - releaseCapacity(self); - return exitSucceed(message); - } else if (self.capacity <= 0 && self.state.offers.size > 0) { - const message = takeOfferUnsafe(self.state.offers); - releaseCapacity(self); - return exitSucceed(message); - } - return; -}; -var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; -var exitFalse = /* @__PURE__ */ exitSucceed(false); -var exitTrue = /* @__PURE__ */ exitSucceed(true); -var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); -var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); -var releaseTakers = (self) => { - if (self.state._tag === "Done" || self.state.takers.size === 0) { - return; - } - for (const taker of self.state.takers) { - self.state.takers.delete(taker); - taker(exitVoid); - if (self.messages.length === 0) { - break; - } - } -}; -var scheduleReleaseTaker = (self) => { - if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { - return; - } - self.scheduleRunning = true; - self.dispatcher.scheduleTask(() => { - self.scheduleRunning = false; - releaseTakers(self); - }, 0); -}; -var takeBetweenUnsafe = (self, min, max) => { - if (self.state._tag === "Done") { - return self.state.exit; - } else if (max <= 0 || min <= 0) { - return exitSucceed([]); - } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { - const messages = [takeOfferUnsafe(self.state.offers)]; - releaseCapacity(self); - return exitSucceed(messages); - } - min = Math.min(min, self.capacity || 1); - if (min <= self.messages.length) { - const messages = takeN(self.messages, max); - releaseCapacity(self); - return exitSucceed(messages); - } -}; -var offerRemainingSingle = (self, message) => { - return callback((resume) => { - if (self.state._tag !== "Open") { - return resume(exitFalse); - } - const entry = { - _tag: "Single", - message, - resume - }; - self.state.offers.add(entry); - return sync(() => { - if (self.state._tag === "Open") { - self.state.offers.delete(entry); - } - }); - }); -}; -var takeOfferUnsafe = (offers) => { - const entry = offers.values().next().value; - if (entry._tag === "Single") { - offers.delete(entry); - entry.resume(exitTrue); - return entry.message; - } - const message = entry.remaining[entry.offset++]; - if (entry.offset === entry.remaining.length) { - offers.delete(entry); - entry.resume(exitSucceed([])); - } - return message; -}; -var releaseCapacity = (self) => { - if (self.state._tag === "Done") { - return isDoneCause(self.state.exit.cause); - } else if (self.state.offers.size === 0) { - if (self.state._tag === "Closing" && self.messages.length === 0) { - finalize(self, self.state.exit); - return isDoneCause(self.state.exit.cause); - } - return false; - } - for (const entry of self.state.offers) { - let n = self.capacity - self.messages.length; - if (n <= 0) - break; - else if (entry._tag === "Single") { - append2(self.messages, entry.message); - self.state.offers.delete(entry); - entry.resume(exitTrue); - } else { - for (;entry.offset < entry.remaining.length; entry.offset++) { - if (n === 0) - return false; - append2(self.messages, entry.remaining[entry.offset]); - n--; - } - self.state.offers.delete(entry); - entry.resume(exitSucceed([])); - } - } - return false; -}; -var awaitTake = (self) => callback((resume) => { - if (self.state._tag === "Done") { - return resume(self.state.exit); - } - self.state.takers.add(resume); - return sync(() => { - if (self.state._tag !== "Done") { - self.state.takers.delete(resume); - } - }); -}); -var finalize = (self, exit) => { - if (self.state._tag === "Done") { - return; - } - const openState = self.state; - self.state = { - _tag: "Done", - exit - }; - for (const taker of openState.takers) { - taker(exit); - } - openState.takers.clear(); - for (const awaiter of openState.awaiters) { - awaiter(exit); - } - openState.awaiters.clear(); -}; - -// node_modules/effect/dist/Semaphore.js -var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); -var waitForPermits = (self, n, effect) => callback((resume) => { - if (self.free >= n) - return resume(effect); - const observer = () => { - if (self.free < n) - return; - self.waiters.delete(observer); - resume(effect); - }; - self.waiters.add(observer); - return sync(() => { - self.waiters.delete(observer); - }); -}); - -class SemaphoreImpl { - waiters = /* @__PURE__ */ new Set; - taken = 0; - permits; - constructor(permits) { - this.permits = permits; - } - get free() { - return this.permits - this.taken; - } - take(n) { - const take = suspend(() => { - if (this.free < n) { - return waitForPermits(this, n, take); - } - this.taken += n; - return succeed3(n); - }); - return take; - } - takeIfAvailable(n) { - return suspend(() => { - if (this.free < n) - return succeed3(false); - this.taken += n; - return succeed3(true); - }); - } - releaseUnsafe(fiber, n) { - this.taken -= n; - if (this.waiters.size > 0) { - fiber.currentDispatcher.scheduleTask(() => { - for (const observer of this.waiters) { - if (this.free <= 0) - break; - observer(); - } - }, 0); - } - return this.free; - } - resize(permits) { - return withFiber((fiber) => { - this.permits = permits; - if (this.free < 0) - return void_; - this.releaseUnsafe(fiber, 0); - return void_; - }); - } - release(n) { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); - } - get releaseAll() { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); - } - withPermits(n) { - return (self) => uninterruptibleMask((restore) => { - const acquire = suspend(() => { - if (this.free < n) { - const wait = waitForPermits(this, n, void_); - return flatMap2(restore(wait), () => acquire); - } - this.taken += n; - return onExitPrimitive(restore(self), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); - return acquire; - }); - } - withPermit = /* @__PURE__ */ this.withPermits(1); - withPermitsIfAvailable(n) { - return (self) => uninterruptibleMask((restore) => { - if (this.free < n) - return succeedNone; - this.taken += n; - return onExitPrimitive(restore(asSome(self)), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); - } -} - -// node_modules/effect/dist/Channel.js -var TypeId10 = "~effect/Channel"; -var isChannel = (u) => hasProperty(u, TypeId10); -var ChannelProto = { - [TypeId10]: { - _Env: identity, - _InErr: identity, - _InElem: identity, - _OutErr: identity, - _OutElem: identity - }, - pipe() { - return pipeArguments(this, arguments); - } -}; -var fromTransform = (transform) => { - const self = Object.create(ChannelProto); - self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); - return self; -}; -var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); -var fromPull = (effect) => fromTransform((_, __) => effect); -var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { - const closableScope = forkUnsafe2(scope); - const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); - const pull = yield* onError2(f(upstream, scope, closableScope), onCause); - return onError2(pull, onCause); -})); -var toTransform = (channel) => channel.transform; -var asyncQueue = (scope, f, options) => make8({ - capacity: options?.bufferSize, - strategy: options?.strategy -}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); -var callbackArray = (f, options) => fromTransform((_, scope) => map6(asyncQueue(scope, f, options), takeAll2)); -var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); -var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done3())); -var map7 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { - let i = 0; - return map6(pull, (o) => f(o, i++)); -}))); -var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); -var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done3))))); -var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { - const strategy = options?.haltStrategy ?? "both"; - const queue = yield* bounded(0); - yield* addFinalizer2(forkedScope, shutdown(queue)); - let done = 0; - function onExit(side, cause) { - done++; - if (!isDoneCause(cause)) { - return failCause4(queue, cause); - } - switch (strategy) { - case "both": { - return done === 2 ? failCause4(queue, cause) : void_3; - } - case "left": - case "right": { - return side === strategy ? failCause4(queue, cause) : void_3; - } - case "either": { - return failCause4(queue, cause); - } - } - } - const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); - yield* runSide("left", left, forkUnsafe2(forkedScope)); - yield* runSide("right", right, forkUnsafe2(forkedScope)); - return take2(queue); -}))); -var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { - let stringBuilder = ""; - let midCRLF = false; - let done = none2(); - function splitLinesArray(chunk) { - const chunkBuilder = []; - function pushLine(segment) { - if (stringBuilder.length === 0) { - chunkBuilder.push(segment); - } else { - chunkBuilder.push(stringBuilder + segment); - stringBuilder = ""; - } - } - for (let i = 0;i < chunk.length; i++) { - const str = chunk[i]; - if (str.length !== 0) { - let from = 0; - let indexOfCR = str.indexOf("\r"); - let indexOfLF = str.indexOf(` -`); - if (midCRLF) { - if (indexOfLF === 0) { - from = 1; - indexOfLF = str.indexOf(` -`, from); - } - midCRLF = false; - } - while (indexOfCR !== -1 || indexOfLF !== -1) { - if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { - pushLine(str.substring(from, indexOfLF)); - from = indexOfLF + 1; - indexOfLF = str.indexOf(` -`, from); - } else { - pushLine(str.substring(from, indexOfCR)); - if (str.length === indexOfCR + 1) { - midCRLF = true; - from = str.length; - indexOfCR = -1; - } else { - from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); - indexOfCR = str.indexOf("\r", from); - indexOfLF = str.indexOf(` -`, from); - } - } - } - stringBuilder = stringBuilder + str.substring(from); - } - } - return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; - } - const pullOrFlush = suspend2(() => { - if (done._tag === "Some") { - return done3(done.value); - } - return matchEffect2(upstream, { - onSuccess: loop, - onFailure: failCause3, - onDone: (leftover) => { - done = some2(leftover); - if (stringBuilder.length > 0) { - const last = stringBuilder; - stringBuilder = ""; - midCRLF = false; - return succeed6([last]); - } - return done3(leftover); - } - }); - }); - function loop(chunk) { - const lines = splitLinesArray(chunk); - return lines !== null ? succeed6(lines) : pullOrFlush; - } - return pullOrFlush; -})); -var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); -var unwrap = (channel) => fromTransform((upstream, scope) => { - let pull; - return succeed6(suspend2(() => { - if (pull) - return pull; - return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); - })); -}); -var runWith = (self, f, onHalt) => suspend2(() => { - const scope = makeUnsafe3(); - const makePull = toTransform(self)(done3(), scope); - return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); -}); -var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { - disableYield: true -}))); -var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { - let state = initial(); - return runWith(self, (pull) => whileLoop2({ - while: constTrue, - body: () => pull, - step: (value) => { - state = f(state, value); - } - }), () => succeed6(state)); -})); -var toPullScoped = (self, scope) => toTransform(self)(done3(), scope); - -// node_modules/effect/dist/internal/stream.js -var TypeId11 = "~effect/Stream"; -var streamVariance = { - _R: identity, - _E: identity, - _A: identity -}; -var Stream = function(channel) { - this.channel = channel; -}; -Stream.prototype = { - [TypeId11]: streamVariance, - pipe() { - return pipeArguments(this, arguments); - } -}; -var fromChannel = (channel) => new Stream(channel); - -// node_modules/effect/dist/Sink.js -var TypeId12 = "~effect/Sink"; -var endVoid = /* @__PURE__ */ succeed6([undefined]); -var sinkVariance = { - _A: identity, - _In: identity, - _L: identity, - _E: identity, - _R: identity -}; -var SinkProto = { - [TypeId12]: sinkVariance, - pipe() { - return pipeArguments(this, arguments); - } -}; -var isSink = (u) => hasProperty(u, TypeId12); -var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ - disableYield: true -})), catchDone(succeed6))); -var fromTransform2 = (transform) => { - const self = Object.create(SinkProto); - self.transform = transform; - return self; -}; -var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done3))); -var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { - disableYield: true -}), () => endVoid)); -var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { - discard: true -})); -var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ - disableYield: true -}), catchDone(() => endVoid))); -var unwrap2 = (effect) => fromChannel2(unwrap(map6(effect, toChannel))); - -// node_modules/effect/dist/internal/rcRef.js -var TypeId13 = "~effect/RcRef"; -var stateEmpty = { - _tag: "Empty" -}; -var stateClosed = { - _tag: "Closed" -}; -var variance2 = { - _A: identity, - _E: identity -}; - -class RcRefImpl { - [TypeId13] = variance2; - pipe() { - return pipeArguments(this, arguments); - } - state = stateEmpty; - semaphore = /* @__PURE__ */ makeUnsafe5(1); - acquire; - context; - scope; - idleTimeToLive; - constructor(acquire, context, scope, idleTimeToLive) { - this.acquire = acquire; - this.context = context; - this.scope = scope; - this.idleTimeToLive = idleTimeToLive; - } -} -var make9 = (options) => withFiber2((fiber) => { - const context = fiber.context; - const scope = get(context, Scope); - const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive ? fromInputUnsafe(options.idleTimeToLive) : undefined); - return as2(addFinalizerExit(scope, () => { - const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; - ref.state = stateClosed; - return close2; - }), ref); -}); -var getState = (self) => uninterruptibleMask2(function loop(restore) { - switch (self.state._tag) { - case "Closed": { - return interrupt2; - } - case "Acquired": { - self.state.refCount++; - return self.state.fiber ? as2(interrupt3(self.state.fiber), self.state) : succeed6(self.state); - } - case "Empty": { - const scope = makeUnsafe3(); - return self.semaphore.withPermit(suspend2(() => { - if (self.state._tag !== "Empty") { - return loop(restore); - } - return restore(provideContext2(self.acquire, add(self.context, Scope, scope))).pipe(flatMap3((value) => { - if (self.state._tag === "Closed") { - return interrupt2; - } - const state = { - _tag: "Acquired", - value, - scope, - fiber: undefined, - refCount: 1, - invalidated: false - }; - self.state = state; - return succeed6(state); - }), onExit2((exit) => isFailure3(exit) ? close(scope, exit) : void_3)); - })); - } - } -}); -var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { - const self = self_; - const state = yield* getState(self); - const scope = yield* scope2; - const isFinite2 = self.idleTimeToLive !== undefined && isFinite(self.idleTimeToLive); - yield* addFinalizerExit(scope, () => { - state.refCount--; - if (state.refCount > 0) { - return void_3; - } - if (self.idleTimeToLive === undefined || state.invalidated) { - if (self.state === state) { - self.state = stateEmpty; - } - return close(state.scope, void_2); - } else if (!isFinite2) { - return void_3; - } - state.fiber = sleep2(self.idleTimeToLive).pipe(flatMap3(() => { - if (self.state === state && state.refCount === 0) { - self.state = stateEmpty; - return close(state.scope, void_2); - } - return void_3; - }), ensuring2(sync3(() => { - state.fiber = undefined; - })), runForkWith2(self.context), runIn(self.scope)); - return void_3; - }); - return state.value; -}); - -// node_modules/effect/dist/RcRef.js -var make10 = make9; -var get3 = get2; - -// node_modules/effect/dist/Stream.js -var TypeId14 = "~effect/Stream"; -var isStream = (u) => hasProperty(u, TypeId14); -var fromChannel3 = fromChannel; -var fromPull2 = (pull) => fromChannel3(fromPull(pull)); -var transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))); -var toChannel2 = (stream) => stream.channel; -var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); -var empty4 = /* @__PURE__ */ fromChannel3(empty3); -var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); -var unwrap3 = (effect) => fromChannel3(unwrap(map6(effect, toChannel2))); -var map8 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { - let i = 0; - return fromChannel3(map7(self.channel, map2((o) => f(o, i++)))); -})); -var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); -var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { - let done; - let leftover; - const upstreamWithLeftover = suspend2(() => { - if (leftover !== undefined) { - const chunk = leftover; - leftover = undefined; - return succeed6(chunk); - } - return upstream; - }).pipe(catch_2((error) => { - done = fail4(error); - return done3(); - })); - const pull = map6(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { - leftover = leftover_; - return of(value); - }); - return suspend2(() => done ? done : pull); -}))); -var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { - const decoder = new TextDecoder(options?.encoding); - return map8(self, (chunk) => decoder.decode(chunk, { - stream: true - })); -})); -var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); -var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map6(([a]) => a)))); -var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { - for (let i = 0;i < chunk.length; i++) { - acc.push(chunk[i]); - } - return acc; -}); -var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channel, initial, (acc, arr) => { - for (let i = 0;i < arr.length; i++) { - acc = f(acc, arr[i]); - } - return acc; -})); -var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => { - let i = 0; - return whileLoop2({ - while: () => i < arr.length, - body: () => f(arr[i++]), - step: constVoid - }); -})); -var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); - -// node_modules/effect/dist/FileSystem.js -var TypeId15 = "~effect/FileSystem"; -var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); -var make11 = (impl) => FileSystem.of({ - ...impl, - [TypeId15]: TypeId15, - exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), - readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ - try: () => new TextDecoder(encoding).decode(_), - catch: (cause) => badArgument({ - module: "FileSystem", - method: "readFileString", - description: "invalid encoding", - cause - }) - })), - stream: fnUntraced2(function* (path, options) { - const file = yield* impl.open(path, { - flag: "r" - }); - const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset); - if (offset) { - yield* file.seek(offset, "start"); - } - const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead); - let totalBytesRead = BigInt(0); - const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024)); - const readChunk = file.readAlloc(chunkSize); - return fromPull2(succeed6(flatMap3(suspend2(() => { - if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { - return done3(); - } - return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; - }), match({ - onNone: () => done3(), - onSome: (buf) => { - totalBytesRead += BigInt(buf.length); - return succeed6(of(buf)); - } - })))); - }, unwrap3), - sink: (path, options) => pipe(impl.open(path, { - ...options, - flag: options?.flag ?? "w" - }), map6((file) => forEach3((_) => file.writeAll(_))), unwrap2), - writeFileString: (path, data, options) => flatMap3(try_2({ - try: () => new TextEncoder().encode(data), - catch: (cause) => badArgument({ - module: "FileSystem", - method: "writeFileString", - description: "could not encode string", - cause - }) - }), (_) => impl.writeFile(path, _, options)) -}); -var FileTypeId = "~effect/FileSystem/File"; -class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBackend")) { -} -// node_modules/effect/dist/Ref.js -var TypeId16 = "~effect/Ref"; -var RefProto = { - [TypeId16]: { - _A: identity - }, - ...PipeInspectableProto, - toJSON() { - return { - _id: "Ref", - ref: this.ref - }; - } -}; -var makeUnsafe6 = (value) => { - const self = Object.create(RefProto); - self.ref = make6(value); - return self; -}; -var make12 = (value) => sync3(() => makeUnsafe6(value)); -var get4 = (self) => sync3(() => self.ref.current); -var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { - self.ref.current = f(self.ref.current); -})); -// node_modules/effect/dist/internal/schema/annotations.js -function resolve(ast) { - return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; -} -var STRUCTURAL_ANNOTATION_KEY = "~structural"; -var SENTINELS_ANNOTATION_KEY = "~sentinels"; -var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; -var getExpected = /* @__PURE__ */ memoize((ast) => { - const identifier = resolve(ast)?.identifier; - if (typeof identifier === "string") - return identifier; - return ast.getExpected(getExpected); -}); - -// node_modules/effect/dist/internal/schema/parser.js -var missing = /* @__PURE__ */ Symbol(); -var succeed8 = succeed4; -var missingExit = /* @__PURE__ */ succeed8(missing); -var sameExit = /* @__PURE__ */ succeed8(missing); -var toOption = (value) => value === missing ? none2() : some2(value); -var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed8(option.value); - -// node_modules/effect/dist/SchemaIssue.js -var TypeId17 = "~effect/SchemaIssue/Issue"; -function isIssue(u) { - return hasProperty(u, TypeId17) && u[TypeId17] === TypeId17; -} -function hasInput(issue) { - return Object.hasOwn(issue, "input"); -} - -class IssueNodeImpl { - [TypeId17] = TypeId17; - constructor(input, options) { - if (options?.reportInput === true && input !== missing) { - this.input = input; - } - } -} -var Filter = class extends IssueNodeImpl { - _tag = "Filter"; - filter; - issue; - constructor(filter, issue, input, options) { - super(input, options); - this.filter = filter; - this.issue = issue; - } -}; -var Encoding = class extends IssueNodeImpl { - _tag = "Encoding"; - ast; - issue; - constructor(ast, issue, input, options) { - super(input, options); - this.ast = ast; - this.issue = issue; - } -}; -var Pointer = class extends IssueNodeImpl { - _tag = "Pointer"; - path; - issue; - constructor(path, issue) { - super(); - this.path = path; - this.issue = issue; - } -}; -var MissingKey = class extends IssueNodeImpl { - _tag = "MissingKey"; - annotations; - constructor(annotations) { - super(); - this.annotations = annotations; - } -}; -var UnexpectedKey = class extends IssueNodeImpl { - _tag = "UnexpectedKey"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; - } -}; -var Composite = class extends IssueNodeImpl { - _tag = "Composite"; - ast; - issues; - constructor(ast, issues, input, options) { - super(input, options); - this.ast = ast; - this.issues = issues; - } -}; -var InvalidType = class extends IssueNodeImpl { - _tag = "InvalidType"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; - } -}; -var InvalidValue = class extends IssueNodeImpl { - _tag = "InvalidValue"; - annotations; - constructor(annotations, input, options) { - super(input, options); - this.annotations = annotations; - } -}; -var AnyOf = class extends IssueNodeImpl { - _tag = "AnyOf"; - ast; - issues; - constructor(ast, issues, input, options) { - super(input, options); - this.ast = ast; - this.issues = issues; - } -}; -var OneOf = class extends IssueNodeImpl { - _tag = "OneOf"; - ast; - successes; - constructor(ast, successes, input, options) { - super(input, options); - this.ast = ast; - this.successes = successes; - } -}; -function makeFilterIssue(entry, input, options) { - if (isIssue(entry)) { - return entry; - } - if (typeof entry === "string") { - return new InvalidValue({ - message: entry - }, input, options); - } - const inner = typeof entry.issue === "string" ? new InvalidValue({ - message: entry.issue - }, input, options) : entry.issue; - return new Pointer(entry.path, inner); -} -function makeSingle(out, input, options) { - if (out === undefined) { - return; - } - if (typeof out === "boolean") { - return out ? undefined : new InvalidValue(undefined, input, options); - } - return makeFilterIssue(out, input, options); -} -function normalizeFilterOutput(ast, out, input, options) { - if (Array.isArray(out)) { - if (!isReadonlyArrayNonEmpty(out)) { - return; - } - return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map2(out, (entry) => makeFilterIssue(entry, input, options)), input, options); - } - return makeSingle(out, input, options); -} -var defaultLeafHook = (issue) => { - const message = findMessage(issue); - if (message !== undefined) - return message; - switch (issue._tag) { - case "InvalidType": - return getExpectedMessage(getExpected(issue.ast), issue); - case "InvalidValue": { - const expected = findExpected(issue); - if (expected !== undefined) - return getExpectedMessage(expected, issue); - const input = formatInput(issue); - return input === undefined ? "Expected a valid value" : `Invalid data ${input}`; - } - case "MissingKey": - return "Missing key"; - case "UnexpectedKey": { - const input = formatInput(issue); - return input === undefined ? "Expected no excess property" : `Unexpected key with value ${input}`; - } - case "Forbidden": - return "Forbidden operation"; - case "OneOf": { - const input = formatInput(issue); - return input === undefined ? "Expected exactly one member to match" : `Expected exactly one member to match the input ${input}`; - } +var defaultLeafHook = (issue) => { + const message = findMessage(issue); + if (message !== undefined) + return message; + switch (issue._tag) { + case "InvalidType": + return getExpectedMessage(getExpected(issue.ast), issue); + case "InvalidValue": { + const expected = findExpected(issue); + if (expected !== undefined) + return getExpectedMessage(expected, issue); + const input = formatInput(issue); + return input === undefined ? "Expected a valid value" : `Invalid data ${input}`; + } + case "MissingKey": + return "Missing key"; + case "UnexpectedKey": { + const input = formatInput(issue); + return input === undefined ? "Expected no excess property" : `Unexpected key with value ${input}`; + } + case "Forbidden": + return "Forbidden operation"; + case "OneOf": { + const input = formatInput(issue); + return input === undefined ? "Expected exactly one member to match" : `Expected exactly one member to match the input ${input}`; + } } }; var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue); @@ -5959,48 +4811,23 @@ function getSchemaIssueOrThrow(cause, message) { } // node_modules/effect/dist/SchemaGetter.js -var Getter = class extends Class { - run; - constructor(run) { - super(); - this.run = run; - } - map(f) { - return new Getter((oe, options) => this.run(oe, options).pipe(mapEager2(map(f)))); - } - compose(other) { - if (isPassthrough(this)) { - return other; - } - if (isPassthrough(other)) { - return this; - } - return new Getter((oe, options) => this.run(oe, options).pipe(flatMapEager2((ot) => other.run(ot, options)))); - } -}; -var passthrough_ = /* @__PURE__ */ new Getter(succeed6); -function isPassthrough(getter) { - return getter.run === passthrough_.run; -} +var makeGetter = (fields) => Object.assign(Object.create(Prototype), fields); +var passthrough_ = /* @__PURE__ */ makeGetter({ + _tag: "Passthrough" +}); function passthrough() { return passthrough_; } -function onSome(f) { - return new Getter((oe, options) => isNone2(oe) ? succeedNone2 : f(oe.value, options)); -} function transform(f) { - return transformOptional(map(f)); + return makeGetter({ + _tag: "Transform", + transform: f + }); } function transformEffect(f) { - return onSome((e, options) => f(e, options).pipe(mapEager2(some2))); -} -function transformOptional(f) { - return new Getter((oe) => succeed6(f(oe))); -} -function withDefault(defaultValue) { - return new Getter((o) => { - const filtered = filter(o, isNotUndefined); - return isSome2(filtered) ? succeed6(filtered) : mapEager2(defaultValue, some2); + return makeGetter({ + _tag: "TransformEffect", + transform: f }); } function String2() { @@ -6018,28 +4845,151 @@ function decodeBase642() { }, input, options))); } +// node_modules/effect/dist/ByteSize.js +var bigint03 = /* @__PURE__ */ BigInt(0); +var bigint12 = /* @__PURE__ */ BigInt(1); +var decimalBase = /* @__PURE__ */ BigInt(1000); +var binaryBase = /* @__PURE__ */ BigInt(1024); +var decimalUnits = [{ + symbol: "B", + factor: bigint12, + names: ["B", "byte", "bytes"] +}, { + symbol: "kB", + factor: decimalBase, + names: ["kB", "kilobyte", "kilobytes"] +}, { + symbol: "MB", + factor: decimalBase ** /* @__PURE__ */ BigInt(2), + names: ["MB", "megabyte", "megabytes"] +}, { + symbol: "GB", + factor: decimalBase ** /* @__PURE__ */ BigInt(3), + names: ["GB", "gigabyte", "gigabytes"] +}, { + symbol: "TB", + factor: decimalBase ** /* @__PURE__ */ BigInt(4), + names: ["TB", "terabyte", "terabytes"] +}, { + symbol: "PB", + factor: decimalBase ** /* @__PURE__ */ BigInt(5), + names: ["PB", "petabyte", "petabytes"] +}, { + symbol: "EB", + factor: decimalBase ** /* @__PURE__ */ BigInt(6), + names: ["EB", "exabyte", "exabytes"] +}, { + symbol: "ZB", + factor: decimalBase ** /* @__PURE__ */ BigInt(7), + names: ["ZB", "zettabyte", "zettabytes"] +}, { + symbol: "YB", + factor: decimalBase ** /* @__PURE__ */ BigInt(8), + names: ["YB", "yottabyte", "yottabytes"] +}, { + symbol: "RB", + factor: decimalBase ** /* @__PURE__ */ BigInt(9), + names: ["RB", "ronnabyte", "ronnabytes"] +}, { + symbol: "QB", + factor: decimalBase ** /* @__PURE__ */ BigInt(10), + names: ["QB", "quettabyte", "quettabytes"] +}]; +var binaryUnits = [decimalUnits[0], { + symbol: "KiB", + factor: binaryBase, + names: ["KiB", "kibibyte", "kibibytes"] +}, { + symbol: "MiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(2), + names: ["MiB", "mebibyte", "mebibytes"] +}, { + symbol: "GiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(3), + names: ["GiB", "gibibyte", "gibibytes"] +}, { + symbol: "TiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(4), + names: ["TiB", "tebibyte", "tebibytes"] +}, { + symbol: "PiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(5), + names: ["PiB", "pebibyte", "pebibytes"] +}, { + symbol: "EiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(6), + names: ["EiB", "exbibyte", "exbibytes"] +}, { + symbol: "ZiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(7), + names: ["ZiB", "zebibyte", "zebibytes"] +}, { + symbol: "YiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(8), + names: ["YiB", "yobibyte", "yobibytes"] +}]; +var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; +var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); +var make5 = (value) => value; +var invalid2 = (message) => { + throw new Error(`Invalid ByteSize: ${message}`); +}; +var fromNumber = (input) => { + if (!Number.isSafeInteger(input) || input < 0) { + return invalid2(`expected a non-negative safe integer, received ${input}`); + } + return make5(BigInt(input)); +}; +var fromStringUnsafe = (input) => { + const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); + if (match === null) + return invalid2(`unsupported syntax ${JSON.stringify(input)}`); + const unit = unitsByName.get(match[3]); + if (unit === undefined) + return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); + const fraction = match[2] ?? ""; + const scale = BigInt(10) ** BigInt(fraction.length); + const numerator = BigInt(match[1] + fraction) * unit.factor; + if (numerator % scale !== bigint03) { + return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); + } + return make5(numerator / scale); +}; +var fromInputUnsafe2 = (input) => { + switch (typeof input) { + case "bigint": + if (input < bigint03) + return invalid2(`expected a non-negative bigint, received ${input}`); + return make5(input); + case "number": + return fromNumber(input); + case "string": + return fromStringUnsafe(input); + } + return invalid2(`unsupported input ${input}`); +}; +var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); + // node_modules/effect/dist/SchemaTransformation.js -var TypeId18 = "~effect/SchemaTransformation/Transformation"; -var Transformation = class { - [TypeId18] = TypeId18; +var TypeId8 = "~effect/SchemaTransformation/Transformation"; +var Transformation = class extends Class { + [TypeId8] = TypeId8; _tag = "Transformation"; decode; encode; constructor(decode, encode) { + super(); this.decode = decode; this.encode = encode; } flip() { return new Transformation(this.encode, this.decode); } - compose(other) { - return new Transformation(this.decode.compose(other.decode), other.encode.compose(this.encode)); - } }; function isTransformation(u) { - return hasProperty(u, TypeId18) && u[TypeId18] === TypeId18; + return hasProperty(u, TypeId8) && u[TypeId8] === TypeId8; } -var make13 = (options) => { +var makeTransformation = (options) => { if (isTransformation(options)) { return options; } @@ -6096,10 +5046,10 @@ var Context = class { this.annotations = annotations; } }; -var TypeId19 = "~effect/Schema"; +var TypeId9 = "~effect/Schema"; class ASTNodeImpl { - [TypeId19] = TypeId19; + [TypeId9] = TypeId9; annotations; checks; encoding; @@ -6264,1292 +5214,2231 @@ var Arrays = class extends ASTNodeImpl { } else if (hasOptional) { throw new Error("A required element cannot follow an optional element. ts(1257)"); } - } - if (hasOptional && rest.length > 1) { - throw new Error("A required element cannot follow an optional element. ts(1257)"); - } - for (let i = 1;i < rest.length; i++) { - if (isOptional(rest[i])) { - throw new Error("An optional element cannot follow a rest element. ts(1266)"); + } + if (hasOptional && rest.length > 1) { + throw new Error("A required element cannot follow an optional element. ts(1257)"); + } + for (let i = 1;i < rest.length; i++) { + if (isOptional(rest[i])) { + throw new Error("An optional element cannot follow a rest element. ts(1266)"); + } + } + } + getParser(compile, compileField = compile) { + const ast = this; + let elements; + let rest; + const elementLen = ast.elements.length; + const tailLen = Math.max(0, ast.rest.length - 1); + function getParser(tailThreshold, index) { + if (index < elementLen) { + return elements[index]; + } else if (index >= tailThreshold) { + return rest[index - tailThreshold + 1]; + } + return rest[0]; + } + return fnUntracedEager2(function* (input, options) { + if (input === missing) { + return missing; + } + if (!Array.isArray(input)) { + return yield* fail6(new InvalidType(ast, input, options)); + } + if (!elements) { + elements = ast.elements.map((ast) => ({ + ast, + parser: compileField(ast) + })); + rest = ast.rest.map((ast) => ({ + ast, + parser: compileField(ast) + })); + } + const len = input.length; + const state = { + ast, + getParser, + input, + len, + tailThreshold: Math.max(elementLen, len - tailLen), + output: new globalThis.Array(len), + issues: undefined, + options + }; + const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen); + const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); + const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, { + concurrency, + end + }); + if (eff) + yield* eff; + if (ast.rest.length === 0 && len > elementLen) { + for (let i = elementLen;i <= len - 1; i++) { + const unexpected = new UnexpectedKey(ast, input[i], options); + const issue = new Pointer([i], unexpected); + if (options.errors === "all") { + if (state.issues) + state.issues.push(issue); + else + state.issues = [issue]; + } else { + return yield* fail6(new Composite(ast, [issue], input, options)); + } + } + } + if (state.issues) { + return yield* fail6(new Composite(ast, state.issues, input, options)); + } + return state.output; + }); + } + _rebuild(recur, checks, encodingChecks) { + const elements = mapOrSame(this.elements, recur); + const rest = mapOrSame(this.rest, recur); + return elements === this.elements && rest === this.rest && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Arrays(this.isMutable, elements, rest, this.annotations, checks, undefined, this.context, encodingChecks); + } + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks); + } + getExpected() { + return "array"; + } +}; +function stepArray(s, item, exit, i) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, i, exit); + } + const value = exit === sameExit ? item : exit[args]; + if (value !== missing) { + s.output[i] = value; + } else { + const p = s.getParser(s.tailThreshold, i); + if (isOptional(p.ast)) + return; + const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); + } + } +} +var parseArrayOptions = { + onItem(s, item, i) { + const value = i < s.len ? item : missing; + return s.getParser(s.tailThreshold, i).parser(value, s.options); + }, + step: stepArray +}; +var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); +var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); +var wrapPropertyKeyIssue = (s, ast, key, exit) => { + if (exit.cause.reasons.length === 0) { + return exit; + } + const issue = getSchemaIssue(exit.cause); + if (issue === undefined) { + return failCause2(map4(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); + } + const pointer = new Pointer([key], issue); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(pointer); + else + s.issues = [pointer]; + } else { + return fail5(new Composite(ast, [pointer], s.input, s.options)); + } +}; +var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; +function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) { + let stringKeys; + let symbolKeys; + function go(parameter) { + switch (parameter._tag) { + case "String": + case "TemplateLiteral": + return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== undefined); + case "Number": + return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== undefined); + case "Symbol": + return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== undefined); + case "Union": + return [...new Set(parameter.types.flatMap(go))]; + default: + return []; + } + } + return go(parameterFromPropertyKey(toEncoded(parameter))); +} +var PropertySignature = class { + name; + type; + constructor(name, type) { + this.name = name; + this.type = type; + } +}; +function isIndexSignatureParameterSide(ast) { + switch (ast._tag) { + case "String": + case "Number": + case "Symbol": + case "TemplateLiteral": + return true; + case "Union": + return ast.types.every(isIndexSignatureParameterSide); + default: + return false; + } +} +function isIndexSignatureParameterEncodedSide(ast) { + const encoded = getLastEncoding(ast); + switch (encoded._tag) { + case "String": + case "Number": + case "Symbol": + case "TemplateLiteral": + return true; + case "Union": + return encoded.types.every(isIndexSignatureParameterEncodedSide); + default: + return false; + } +} +function isIndexSignatureParameter(ast) { + return isIndexSignatureParameterSide(ast) && isIndexSignatureParameterEncodedSide(ast); +} +var IndexSignature = class { + parameter; + type; + constructor(parameter, type) { + if (!isIndexSignatureParameter(parameter)) { + throw new Error(`Invalid index signature parameter ${parameter._tag}`); + } + this.parameter = parameter; + this.type = type; + if (isOptional(type) && !containsUndefined(type)) { + throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead."); + } + } +}; +var Objects = class extends ASTNodeImpl { + _tag = "Objects"; + propertySignatures; + indexSignatures; + encodingChecks; + constructor(propertySignatures, indexSignatures, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.propertySignatures = propertySignatures; + this.indexSignatures = indexSignatures; + this.encodingChecks = encodingChecks; + const seen = new Set; + const duplicates = []; + for (const propertySignature of propertySignatures) { + const name = propertySignature.name; + if (seen.has(name)) { + duplicates.push(name); + } else { + seen.add(name); + } + } + if (duplicates.length > 0) { + throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); + } + } + getParser(compile, compileField = compile) { + const ast = this; + const expectedKeys = []; + for (const ps of ast.propertySignatures) { + expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name); + } + const hasProperties = expectedKeys.length; + const indexCount = ast.indexSignatures.length; + let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : undefined; + if (!hasProperties && !indexCount) { + return fromRefinement(ast, isNotNullish); + } + let properties; + let indexes; + const finishIndex = (s, key, k2, inputValue, exitValue) => { + if (exitValue._tag === "Failure") { + return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_2; + } + const value = exitValue === sameExit ? inputValue : exitValue[args]; + if (k2 !== missing && value !== missing) { + if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) + return void_2; + assignProperty(s.out, k2, value); } - } - } - getParser(compile, compileConstructorDefault = compile) { - const ast = this; - let elements; - let rest; - const elementLen = ast.elements.length; - const tailLen = Math.max(0, ast.rest.length - 1); - function getParser(tailThreshold, index) { - if (index < elementLen) { - return elements[index]; - } else if (index >= tailThreshold) { - return rest[index - tailThreshold + 1]; + return void_2; + }; + const parseIndex = (s, key, index, exitKey) => { + if (!exitKey) { + const eff = index.parserKey(key, s.options); + if (!effectIsExit(eff)) { + return flatMap3(exit2(eff), (exit) => parseIndex(s, key, index, exit)); + } + exitKey = eff; } - return rest[0]; - } - return fnUntracedEager2(function* (input, options) { + if (exitKey._tag === "Failure") { + return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_2; + } + const k2 = exitKey === sameExit ? key : exitKey[args]; + const inputValue = s.input[key]; + const result = index.parserValue(inputValue, s.options); + return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, k2, inputValue, exit)); + }; + const parseStringIndex = (s, key, index) => { + const inputValue = s.input[key]; + const result = index.parserValue(inputValue, s.options); + return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, key, inputValue, exit)); + }; + const parseIndexes = indexCount ? iterateConcurrent()({ + onItem: (s, [key, index]) => index.is.parameter === string2 ? parseStringIndex(s, key, index) : parseIndex(s, key, index), + step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined + }) : undefined; + const compileMembers = () => { + if (!properties) { + properties = ast.propertySignatures.map((ps) => ({ + parser: compileField(ps.type), + name: ps.name, + type: ps.type + })); + indexes = indexCount ? ast.indexSignatures.map((is) => ({ + is, + parserKey: compile(parameterFromPropertyKey(is.parameter)), + parserValue: compileField(is.type) + })) : undefined; + } + return properties; + }; + const fallback = fnUntracedEager2(function* (input, options) { if (input === missing) { return missing; } - if (!Array.isArray(input)) { + if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { return yield* fail6(new InvalidType(ast, input, options)); } - if (!elements) { - elements = ast.elements.map((ast) => ({ - ast, - parser: compileConstructorDefault(ast) - })); - rest = ast.rest.map((ast) => ({ - ast, - parser: compileConstructorDefault(ast) - })); - } - const len = input.length; + compileMembers(); + const record = input; + const out = {}; const state = { ast, - getParser, - input, - len, - tailThreshold: Math.max(elementLen, len - tailLen), - output: new globalThis.Array(len), + input: record, + out, issues: undefined, options }; - const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen); + const errorsAllOption = options.errors === "all"; + const onExcessPropertyError = options.onExcessProperty === "error"; const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); - const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, { - concurrency, - end - }); - if (eff) - yield* eff; - if (ast.rest.length === 0 && len > elementLen) { - for (let i = elementLen;i <= len - 1; i++) { - const unexpected = new UnexpectedKey(ast, input[i], options); - const issue = new Pointer([i], unexpected); - if (options.errors === "all") { - if (state.issues) - state.issues.push(issue); - else - state.issues = [issue]; - } else { - return yield* fail6(new Composite(ast, [issue], input, options)); + const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : undefined; + if (onExcessPropertyError) { + expectedKeysSet ??= new Set(expectedKeys); + const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet; + if (indexKeys) { + for (const keys of indexKeys) { + for (const key of keys) + coveredKeys.add(key); + } + } + const inputKeys = Reflect.ownKeys(record); + for (let i = 0;i < inputKeys.length; i++) { + const key = inputKeys[i]; + if (!coveredKeys.has(key)) { + const unexpected = new UnexpectedKey(ast, record[key], options); + const issue = new Pointer([key], unexpected); + if (errorsAllOption) { + if (state.issues) { + state.issues.push(issue); + } else { + state.issues = [issue]; + } + continue; + } else { + return yield* fail6(new Composite(ast, [issue], input, options)); + } + } + } + } + if (hasProperties) { + const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { + concurrency + }); + if (eff) + yield* eff; + } + if (indexCount && concurrency === 1) { + for (let i = 0;i < indexCount; i++) { + const index = indexes[i]; + const parse = index.is.parameter === string2 ? parseStringIndex : parseIndex; + const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); + for (let j = 0;j < keys.length; j++) { + const eff = parse(state, keys[j], index); + if (!effectIsExit(eff)) + yield* eff; + else if (eff._tag === "Failure") + return yield* eff; + } + } + } else if (parseIndexes) { + const keyPairs = empty(); + for (let i = 0;i < indexCount; i++) { + const index = indexes[i]; + const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); + for (let j = 0;j < keys.length; j++) { + keyPairs.push([keys[j], index]); } } + const eff = parseIndexes(state, keyPairs, { + concurrency + }); + if (eff) + yield* eff; } if (state.issues) { return yield* fail6(new Composite(ast, state.issues, input, options)); } - return state.output; + return out; }); - } - _rebuild(recur, checks, encodingChecks) { - const elements = mapOrSame(this.elements, recur); - const rest = mapOrSame(this.rest, recur); - return elements === this.elements && rest === this.rest && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Arrays(this.isMutable, elements, rest, this.annotations, checks, undefined, this.context, encodingChecks); - } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks); - } - flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks); - } - getExpected() { - return "array"; - } -}; -var parseArrayOptions = { - onItem(s, item, i) { - const value = i < s.len ? item : missing; - return s.getParser(s.tailThreshold, i).parser(value, s.options); - }, - step(s, item, exit, i) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, i, exit); - } - const value = exit === sameExit ? item : exit[args]; - if (value !== missing) { - s.output[i] = value; - } else { - const p = s.getParser(s.tailThreshold, i); - if (isOptional(p.ast)) - return; - const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); + if (indexCount) + return fallback; + const resume = (state, index, pending) => { + const property = properties[index]; + return flatMap3(exit2(pending), (exit) => { + const terminal = stepProperty(state, property, exit); + if (terminal) + return terminal; + const done = () => succeed7(state.out); + const eff = parseProperties(state, properties.slice(index + 1)); + return eff ? flatMapEager2(eff, done) : done(); + }); + }; + return (input, options) => { + if (input === missing) + return missingExit; + if (options.errors === "all" || options.onExcessProperty !== undefined || options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1) { + return fallback(input, options); } - } + if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { + return fail6(new InvalidType(ast, input, options)); + } + const props = compileMembers(); + const record = input; + const out = {}; + const state = { + ast, + input: record, + out, + issues: undefined, + options + }; + try { + for (let index = 0;index < props.length; index++) { + const property = props[index]; + const name = property.name; + const hasKey = hasPropertySignature(record, name); + const value = hasKey ? record[name] : missing; + const exit = property.parser(value, options); + if (!effectIsExit(exit)) { + return resume(state, index, exit); + } + if (exit === sameExit) { + if (hasKey) + assignProperty(out, name, value); + continue; + } + const terminal = stepProperty(state, property, exit); + if (terminal) + return terminal; + } + } catch (error) { + return die3(error); + } + return succeed7(out); + }; + } + _rebuild(recur, recurParameter, checks, encodingChecks) { + const props = mapOrSame(this.propertySignatures, (ps) => { + const t = recur(ps.type); + return t === ps.type ? ps : new PropertySignature(ps.name, t); + }); + const indexes = mapOrSame(this.indexSignatures, (is) => { + const p = recurParameter(is.parameter); + const t = recur(is.type); + return p === is.parameter && t === is.type ? is : new IndexSignature(p, t); + }); + return props === this.propertySignatures && indexes === this.indexSignatures && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Objects(props, indexes, this.annotations, checks, undefined, this.context, encodingChecks); } -}; -var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); -var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); -var wrapPropertyKeyIssue = (s, ast, key, exit) => { - if (exit.cause.reasons.length === 0) { - return exit; + flip(recur) { + return this._rebuild(recur, recur, this.encodingChecks, this.checks); } - const issue = getSchemaIssue(exit.cause); - if (issue === undefined) { - return failCause2(map5(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); + recur(recur, recurParameter = recur) { + return this._rebuild(recur, recurParameter, this.checks, this.encodingChecks); } - const pointer = new Pointer([key], issue); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(pointer); - else - s.issues = [pointer]; - } else { - return fail4(new Composite(ast, [pointer], s.input, s.options)); + getExpected() { + if (this.propertySignatures.length === 0 && this.indexSignatures.length === 0) + return "object | array"; + return "object"; } }; -var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; -function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) { - let stringKeys; - let symbolKeys; - function go(parameter) { - switch (parameter._tag) { - case "String": - case "TemplateLiteral": - return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== undefined); - case "Number": - return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== undefined); - case "Symbol": - return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== undefined); - case "Union": - return [...new Set(parameter.types.flatMap(go))]; - default: - return []; +function stepProperty(s, p, exit) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, p.name, exit); + } + if (exit === sameExit) + return; + const value = exit[args]; + if (value !== missing) { + assignProperty(s.out, p.name, value); + return; + } + delete s.out[p.name]; + if (!isOptional(p.type)) { + const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + return; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); } } - return go(parameterFromPropertyKey(toEncoded(parameter))); } -var PropertySignature = class { - name; - type; - constructor(name, type) { - this.name = name; - this.type = type; - } +var parsePropertiesOptions = { + onItem(s, p) { + if (!hasPropertySignature(s.input, p.name)) { + return p.parser(missing, s.options); + } + const value = s.input[p.name]; + assignProperty(s.out, p.name, value); + return p.parser(value, s.options); + }, + step: stepProperty }; -function isIndexSignatureParameterSide(ast) { +var parseProperties = /* @__PURE__ */ iterateEager()(parsePropertiesOptions); +var parsePropertiesConcurrent = /* @__PURE__ */ iterateConcurrent()(parsePropertiesOptions); +function combineChecks(a, b) { + if (!a) + return b; + if (!b) + return a; + return [...a, ...b]; +} +function struct(fields, checks, annotations) { + return new Objects(Reflect.ownKeys(fields).map((key) => { + return new PropertySignature(key, fields[key].ast); + }), [], annotations, checks); +} +function getAST(self) { + return self.ast; +} +function tuple(elements, checks = undefined) { + return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks); +} +function union(members, options, checks) { + return new Union(members.map(getAST), options, undefined, checks); +} +var toCandidate = /* @__PURE__ */ memoizeIdempotent((ast) => { + while (true) { + if (isSuspend(ast)) + return unknown; + const encoding = ast.encoding; + if (!encoding) { + return ast.recur?.(toCandidate, identity) ?? ast; + } + if (encoding.some((link) => link.transformation._tag === "Middleware" && link.transformation.decode !== identity)) + return unknown; + ast = encoding[encoding.length - 1].to; + } +}); +function getCandidateTypes(ast) { switch (ast._tag) { + case "Null": + return ["null"]; + case "Undefined": + return ["undefined"]; case "String": - case "Number": - case "Symbol": case "TemplateLiteral": - return true; - case "Union": - return ast.types.every(isIndexSignatureParameterSide); - default: - return false; - } -} -function isIndexSignatureParameterEncodedSide(ast) { - const encoded = getLastEncoding(ast); - switch (encoded._tag) { - case "String": + return ["string"]; case "Number": + return ["number"]; + case "Boolean": + return ["boolean"]; case "Symbol": - case "TemplateLiteral": - return true; + case "UniqueSymbol": + return ["symbol"]; + case "BigInt": + return ["bigint"]; + case "Arrays": + return ["array"]; + case "ObjectKeyword": + return ["object", "array", "function"]; + case "Objects": + return ast.propertySignatures.length || ast.indexSignatures.length ? ["object"] : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; + case "Enum": + return Array.from(new Set(ast.enums.map(([, v]) => typeof v))); + case "Literal": + return [typeof ast.literal]; case "Union": - return encoded.types.every(isIndexSignatureParameterEncodedSide); + return Array.from(new Set(ast.types.flatMap(getCandidateTypes))); default: - return false; + return ["null", "undefined", "string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; } } -function isIndexSignatureParameter(ast) { - return isIndexSignatureParameterSide(ast) && isIndexSignatureParameterEncodedSide(ast); -} -var IndexSignature = class { - parameter; - type; - constructor(parameter, type) { - if (!isIndexSignatureParameter(parameter)) { - throw new Error(`Invalid index signature parameter ${parameter._tag}`); +function collectSentinels(ast) { + switch (ast._tag) { + default: + return []; + case "Declaration": { + const s = ast.annotations?.[SENTINELS_ANNOTATION_KEY]; + return Array.isArray(s) ? s : []; } - this.parameter = parameter; - this.type = type; - if (isOptional(type) && !containsUndefined(type)) { - throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead."); + case "Objects": + return ast.propertySignatures.flatMap((ps) => { + const type = ps.type; + if (!isOptional(type)) { + if (isLiteral(type)) { + return [{ + key: ps.name, + literal: type.literal + }]; + } + if (isUniqueSymbol(type)) { + return [{ + key: ps.name, + literal: type.symbol + }]; + } + } + return []; + }); + case "Arrays": + return ast.elements.flatMap((e, i) => { + if (!isOptional(e)) { + if (isLiteral(e)) { + return [{ + key: i, + literal: e.literal + }]; + } + if (isUniqueSymbol(e)) { + return [{ + key: i, + literal: e.symbol + }]; + } + } + return []; + }); + case "Union": { + if (ast.types.length === 0) + return []; + const members = ast.types.map((type) => collectSentinels(toCandidate(type))); + return members[0].filter((s) => members.every((sentinels) => sentinels.some((o) => o.key === s.key && o.literal === s.literal))); } + case "Suspend": + return collectSentinels(ast.thunk()); } -}; -var Objects = class extends ASTNodeImpl { - _tag = "Objects"; - propertySignatures; - indexSignatures; - encodingChecks; - constructor(propertySignatures, indexSignatures, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.propertySignatures = propertySignatures; - this.indexSignatures = indexSignatures; - this.encodingChecks = encodingChecks; - const seen = new Set; - const duplicates = []; - for (const propertySignature of propertySignatures) { - const name = propertySignature.name; - if (seen.has(name)) { - duplicates.push(name); +} +var candidateIndexCache = /* @__PURE__ */ new WeakMap; +var emptyCandidates = /* @__PURE__ */ Object.freeze([]); +var hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : (key in input); +function getIndex(types) { + let index = candidateIndexCache.get(types); + if (index) + return index; + let bySentinel; + let sentinelCandidateCount = 0; + let otherwise; + let literalCandidates; + let onlyLiterals = true; + for (let i = 0;i < types.length; i++) { + const a = types[i]; + const encoded = toCandidate(a); + if (isNever2(encoded)) + continue; + if (onlyLiterals) { + if (isLiteral(encoded) || isUniqueSymbol(encoded)) { + literalCandidates ??= new Map; + const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol; + let arr = literalCandidates.get(literal); + if (!arr) + literalCandidates.set(literal, arr = []); + arr.push(a); } else { - seen.add(name); + onlyLiterals = false; } } - if (duplicates.length > 0) { - throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); + const sentinels = collectSentinels(encoded); + if (sentinels.length) { + bySentinel ??= new Map; + sentinelCandidateCount++; + for (const { + key, + literal + } of sentinels) { + let entry = bySentinel.get(key); + if (!entry) + bySentinel.set(key, entry = [new Map, new Set]); + entry[1].add(i); + let indexes = entry[0].get(literal); + if (!indexes) + entry[0].set(literal, indexes = new Set); + indexes.add(i); + } + } else { + otherwise ??= {}; + const candidateTypes = getCandidateTypes(encoded); + for (const t of candidateTypes) + (otherwise[t] ??= []).push(i); } } - getParser(compile, compileConstructorDefault = compile) { - const ast = this; - const expectedKeys = []; - for (const ps of ast.propertySignatures) { - expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name); - } - const hasProperties = expectedKeys.length; - const indexCount = ast.indexSignatures.length; - let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : undefined; - if (!hasProperties && !indexCount) { - return fromRefinement(ast, isNotNullish); + if (onlyLiterals && literalCandidates) { + literalCandidates.forEach(Object.freeze); + index = (input) => literalCandidates.get(input) ?? emptyCandidates; + } else if (bySentinel?.size === 1 && !otherwise) { + const [key, [byValue]] = bySentinel.entries().next().value; + const candidates = byValue; + for (const [literal, indexes] of byValue) { + candidates.set(literal, Object.freeze(Array.from(indexes, (index) => types[index]))); } - let properties; - let indexes; - const finishIndex = (s, key, k2, inputValue, exitValue) => { - if (exitValue._tag === "Failure") { - return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_2; - } - const value = exitValue === sameExit ? inputValue : exitValue[args]; - if (k2 !== missing && value !== missing) { - if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) - return void_2; - assignProperty(s.out, k2, value); - } - return void_2; - }; - const parseIndex = (s, key, index, exitKey) => { - if (!exitKey) { - const eff = index.parserKey(key, s.options); - if (!effectIsExit(eff)) { - return flatMap3(exit2(eff), (exit) => parseIndex(s, key, index, exit)); - } - exitKey = eff; - } - if (exitKey._tag === "Failure") { - return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_2; - } - const k2 = exitKey === sameExit ? key : exitKey[args]; - const inputValue = s.input[key]; - const result = index.parserValue(inputValue, s.options); - return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, k2, inputValue, exit)); - }; - const parseStringIndex = (s, key, index) => { - const inputValue = s.input[key]; - const result = index.parserValue(inputValue, s.options); - return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, key, inputValue, exit)); - }; - const parseIndexes = indexCount ? iterateConcurrent()({ - onItem: (s, [key, index]) => index.is.parameter === string2 ? parseStringIndex(s, key, index) : parseIndex(s, key, index), - step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined - }) : undefined; - const compileMembers = () => { - if (!properties) { - properties = ast.propertySignatures.map((ps) => ({ - parser: compileConstructorDefault(ps.type), - name: ps.name, - type: ps.type - })); - indexes = indexCount ? ast.indexSignatures.map((is) => ({ - is, - parserKey: compile(parameterFromPropertyKey(is.parameter)), - parserValue: compileConstructorDefault(is.type) - })) : undefined; + index = (input, isConstructor) => { + if (isObjectKeyword(input)) { + const value = hasPropertySignature(input, key) ? input[key] : undefined; + if (value !== undefined) + return candidates.get(value) ?? emptyCandidates; + if (isConstructor) + return types; } - return properties; + return emptyCandidates; }; - const fallback = fnUntracedEager2(function* (input, options) { - if (input === missing) { - return missing; - } - if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { - return yield* fail6(new InvalidType(ast, input, options)); + } else if (bySentinel) { + let commonSentinel; + for (const entry of bySentinel) { + if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) { + commonSentinel = entry; } - compileMembers(); - const record = input; - const out = {}; - const state = { - ast, - input: record, - out, - issues: undefined, - options - }; - const errorsAllOption = options.errors === "all"; - const onExcessPropertyError = options.onExcessProperty === "error"; - const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); - const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : undefined; - if (onExcessPropertyError) { - expectedKeysSet ??= new Set(expectedKeys); - const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet; - if (indexKeys) { - for (const keys of indexKeys) { - for (const key of keys) - coveredKeys.add(key); - } - } - const inputKeys = Reflect.ownKeys(record); - for (let i = 0;i < inputKeys.length; i++) { - const key = inputKeys[i]; - if (!coveredKeys.has(key)) { - const unexpected = new UnexpectedKey(ast, record[key], options); - const issue = new Pointer([key], unexpected); - if (errorsAllOption) { - if (state.issues) { - state.issues.push(issue); - } else { - state.issues = [issue]; - } - continue; - } else { - return yield* fail6(new Composite(ast, [issue], input, options)); - } - } + } + index = (input, isConstructor) => { + const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; + const base = otherwise?.[runtimeType] ?? emptyCandidates; + if (!isObjectKeyword(input)) + return base.map((i) => types[i]); + const selected = new Set(base); + let directKey; + if (commonSentinel) { + const [key, [byValue]] = commonSentinel; + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + if (!match) + return base.map((i) => types[i]); + for (const i of match) + selected.add(i); + directKey = key; } } - if (hasProperties) { - const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { - concurrency - }); - if (eff) - yield* eff; - } - if (indexCount && concurrency === 1) { - for (let i = 0;i < indexCount; i++) { - const index = indexes[i]; - const parse = index.is.parameter === string2 ? parseStringIndex : parseIndex; - const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); - for (let j = 0;j < keys.length; j++) { - const eff = parse(state, keys[j], index); - if (!effectIsExit(eff)) - yield* eff; - else if (eff._tag === "Failure") - return yield* eff; - } - } - } else if (parseIndexes) { - const keyPairs = empty2(); - for (let i = 0;i < indexCount; i++) { - const index = indexes[i]; - const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); - for (let j = 0;j < keys.length; j++) { - keyPairs.push([keys[j], index]); + if (directKey === undefined) { + for (const [key, [byValue, all]] of bySentinel) { + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + if (match) { + for (const i of match) + selected.add(i); + } + } else if (isConstructor) { + for (const i of all) + selected.add(i); } } - const eff = parseIndexes(state, keyPairs, { - concurrency - }); - if (eff) - yield* eff; - } - if (state.issues) { - return yield* fail6(new Composite(ast, state.issues, input, options)); } - return out; - }); - if (indexCount) - return fallback; - const resume = (state, index, pending) => { - const property = properties[index]; - return flatMap3(exit2(pending), (exit) => { - const terminal = stepProperty(state, property, exit); - if (terminal) - return terminal; - const done = () => succeed8(state.out); - const eff = parseProperties(state, properties.slice(index + 1)); - return eff ? flatMapEager2(eff, done) : done(); - }); + for (const [key, [byValue, all]] of bySentinel) { + if (key === directKey) + continue; + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + for (const i of selected) { + if (all.has(i) && !match?.has(i)) + selected.delete(i); + } + } + } + return Array.from(selected).sort((a, b) => a - b).map((i) => types[i]); + }; + } else { + index = (input) => { + const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; + return (otherwise?.[runtimeType] ?? emptyCandidates).map((i) => types[i]).filter(filterLiterals(input)); }; + } + candidateIndexCache.set(types, index); + return index; +} +function filterLiterals(input) { + return (ast) => { + const encoded = toCandidate(ast); + return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true; + }; +} +function getCandidates(input, types, isConstructor = false) { + return getIndex(types)(input, isConstructor); +} +var Union = class extends ASTNodeImpl { + _tag = "Union"; + types; + options; + encodingChecks; + constructor(types, options, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.types = types; + this.options = options; + this.encodingChecks = encodingChecks; + } + getParser(compile, compileField) { + const ast = this; return (input, options) => { - if (input === missing) + if (input === missing) { return missingExit; - if (options.errors === "all" || options.onExcessProperty !== undefined || options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1) { - return fallback(input, options); } - if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { - return fail6(new InvalidType(ast, input, options)); + const candidates = getCandidates(input, ast.types, compileField !== undefined); + if (candidates.length === 0) { + return fail6(new AnyOf(ast, [], input, options)); + } + if (candidates.length === 1) { + const result = compile(candidates[0])(input, options); + if (result._tag === "Success") + return result; + return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchCause2(result, (cause) => failSingleUnionCandidate(ast, cause, input, options)); } - const props = compileMembers(); - const record = input; - const out = {}; const state = { ast, - input: record, - out, + compile, + input, + out: undefined, + successes: ast.options?.mode === "oneOf" ? [] : undefined, issues: undefined, options }; - try { - for (let index = 0;index < props.length; index++) { - const property = props[index]; - const name = property.name; - const hasKey = hasPropertySignature(record, name); - const value = hasKey ? record[name] : missing; - const exit = property.parser(value, options); - if (!effectIsExit(exit)) { - return resume(state, index, exit); + const eff = parseUnion(state, candidates); + if (!eff) { + if (state.out) + return state.out; + return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + } + return flatMapEager2(eff, (_) => { + if (state.out === sameExit) + return succeed6(input); + if (state.out) + return state.out; + return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + }); + }; + } + _rebuild(recur, checks, encodingChecks) { + const types = mapOrSame(this.types, recur); + return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks); + } + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks); + } + matchPart(s, options) { + for (const type of this.types) { + const out = type.matchPart(s, options); + if (out !== undefined) + return out; + } + return; + } + getExpected(getExpected) { + const expected = this.annotations?.expected; + if (typeof expected === "string") + return expected; + if (this.types.length === 0) + return "never"; + const types = this.types.map((type) => { + const encoded = toEncoded(type); + switch (encoded._tag) { + case "Arrays": { + const literals = encoded.elements.filter(isLiteral); + if (literals.length > 0) { + return `${formatIsMutable(encoded.isMutable)}[ ${literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ")}, ... ]`; } - if (exit === sameExit) { - if (hasKey) - assignProperty(out, name, value); - continue; + break; + } + case "Objects": { + const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)); + if (literals.length > 0) { + return `{ ${literals.map((ps) => `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${formatIsOptional(ps.type.context?.isOptional)}: ${getExpected(ps.type)}`).join(", ")}, ... }`; } - const terminal = stepProperty(state, property, exit); - if (terminal) - return terminal; + break; } - } catch (error) { - return die2(error); } - return succeed8(out); - }; - } - _rebuild(recur, recurParameter, checks, encodingChecks) { - const props = mapOrSame(this.propertySignatures, (ps) => { - const t = recur(ps.type); - return t === ps.type ? ps : new PropertySignature(ps.name, t); + return getExpected(encoded); }); - const indexes = mapOrSame(this.indexSignatures, (is) => { - const p = recurParameter(is.parameter); - const t = recur(is.type); - return p === is.parameter && t === is.type ? is : new IndexSignature(p, t); + return Array.from(new Set(types)).join(" | "); + } +}; +function failSingleUnionCandidate(ast, cause, input, options) { + const issue = getSchemaIssue(cause); + if (!issue) + return failCause2(cause); + return fail5(new AnyOf(ast, [issue], input, options)); +} +var parseUnion = /* @__PURE__ */ iterateEager()({ + onItem(s, ast) { + const parser = s.compile(ast); + return parser(s.input, s.options); + }, + step(s, candidate, exit) { + if (exit._tag === "Failure") { + const issue = getSchemaIssue(exit.cause); + if (issue === undefined) { + return exit; + } + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + if (s.out && s.successes) { + s.successes.push(candidate); + return fail5(new OneOf(s.ast, s.successes, s.input, s.options)); + } + s.out = exit; + if (s.successes) { + s.successes.push(candidate); + } else { + return void_2; + } + } + } +}); +var nonFiniteLiterals = /* @__PURE__ */ new Union([/* @__PURE__ */ new Literal("Infinity"), /* @__PURE__ */ new Literal("-Infinity"), /* @__PURE__ */ new Literal("NaN")]); +function formatIsMutable(isMutable) { + return isMutable ? "" : "readonly "; +} +function formatIsOptional(isOptional) { + return isOptional ? "?" : ""; +} +var Filter2 = class extends Class { + _tag = "Filter"; + run; + annotations; + aborted; + constructor(run, annotations = undefined, aborted = false) { + super(); + this.run = run; + this.annotations = annotations; + this.aborted = aborted; + } + annotate(annotations) { + return new Filter2(this.run, { + ...this.annotations, + ...annotations + }, this.aborted); + } + abort() { + return new Filter2(this.run, this.annotations, true); + } + and(other, annotations) { + return new FilterGroup([this, other], annotations); + } +}; +var FilterGroup = class extends Class { + _tag = "FilterGroup"; + checks; + annotations; + constructor(checks, annotations = undefined) { + super(); + this.checks = checks; + this.annotations = annotations; + } + annotate(annotations) { + return new FilterGroup(this.checks, { + ...this.annotations, + ...annotations }); - return props === this.propertySignatures && indexes === this.indexSignatures && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Objects(props, indexes, this.annotations, checks, undefined, this.context, encodingChecks); } - flip(recur) { - return this._rebuild(recur, recur, this.encodingChecks, this.checks); + and(other, annotations) { + return new FilterGroup([this, other], annotations); + } +}; +function makeFilter(filter, annotations, aborted = false) { + return new Filter2((input, ast, options) => normalizeFilterOutput(ast, filter(input, ast, options), input, options), annotations, aborted); +} +function isFinite2(annotations) { + return makeFilter((n) => globalThis.Number.isFinite(n), { + expected: "a finite number", + representation: { + id: "effect/schema/isFinite", + payload: null + }, + toJsonSchema: () => ({ + type: "number" + }), + toCode: () => ({ + runtime: "Schema.isFinite()" + }), + arbitraryConstraint: { + number: "finite" + }, + ...annotations + }); +} +var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]); +var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n)))); +function isPattern(regExp, annotations) { + const source = regExp.source; + const pattern = new globalThis.RegExp(source, regExp.flags); + return makeFilter((s) => { + pattern.lastIndex = 0; + return pattern.test(s); + }, { + expected: `a string matching the RegExp ${source}`, + representation: { + id: "effect/schema/isPattern", + payload: { + source, + flags: regExp.flags + } + }, + toJsonSchema: () => ({ + pattern: source + }), + arbitraryConstraint: { + patterns: [{ + source: regExp.source, + flags: regExp.flags + }] + }, + ...annotations + }); +} +function modifyOwnPropertyDescriptors(ast, f) { + const d = Object.getOwnPropertyDescriptors(ast); + f(d); + return Object.create(Object.getPrototypeOf(ast), d); +} +var contextOwners = /* @__PURE__ */ new WeakMap; +function getContextOwner(ast) { + return contextOwners.get(ast) ?? ast; +} +function replaceEncoding(ast, encoding) { + if (ast.encoding === encoding) { + return ast; + } + return modifyOwnPropertyDescriptors(ast, (d) => { + d.encoding.value = encoding; + }); +} +function replaceContext(ast, context) { + if (ast.context === context) { + return ast; } - recur(recur, recurParameter = recur) { - return this._rebuild(recur, recurParameter, this.checks, this.encodingChecks); + const owner = getContextOwner(ast); + if (owner.context === context) { + return owner; } - getExpected() { - if (this.propertySignatures.length === 0 && this.indexSignatures.length === 0) - return "object | array"; - return "object"; + const out = modifyOwnPropertyDescriptors(ast, (d) => { + d.context.value = context; + }); + contextOwners.set(out, owner); + return out; +} +function getLastEncoding(ast) { + return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast; +} +function annotate(ast, annotations) { + if (ast.checks) { + const last = ast.checks[ast.checks.length - 1]; + return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations))); } -}; -function stepProperty(s, p, exit) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, p.name, exit); + return modifyOwnPropertyDescriptors(ast, (d) => { + d.annotations.value = { + ...d.annotations.value, + ...annotations + }; + }); +} +function replaceChecks(ast, checks) { + if (ast._tag === "Suspend" && checks) { + throw new Error("Cannot add checks to Suspend"); } - if (exit === sameExit) - return; - const value = exit[args]; - if (value !== missing) { - assignProperty(s.out, p.name, value); - return; + if (ast.checks === checks) { + return ast; } - delete s.out[p.name]; - if (!isOptional(p.type)) { - const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - return; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); + return modifyOwnPropertyDescriptors(ast, (d) => { + d.checks.value = checks; + }); +} +function appendChecks(ast, checks) { + return replaceChecks(ast, combineChecks(ast.checks, checks)); +} +function mapLink(link, f) { + const to = f(link.to); + return to === link.to ? link : new Link(to, link.transformation); +} +function updateLastLink(encoding, f) { + const links = encoding; + const last = links[links.length - 1]; + const out = mapLink(last, f); + return out === last ? encoding : append(encoding.slice(0, encoding.length - 1), out); +} +function applyToLastLink(f) { + return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast; +} +function applyToSelfOrLastLinkEncodingIdempotent(f, options) { + function out(ast) { + if (ast.encoding) { + const last = ast.encoding[ast.encoding.length - 1]; + return options?.stopAt?.(last) ? ast : replaceEncoding(ast, updateLastLink(ast.encoding, out)); } + return f(ast); } + return memoizeIdempotent(out); } -var parsePropertiesOptions = { - onItem(s, p) { - if (!hasPropertySignature(s.input, p.name)) { - return p.parser(missing, s.options); +function appendTransformation(from, transformation, to) { + const link = new Link(from, transformation); + return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]); +} +function mapOrSame(as, f) { + let changed = false; + const out = new Array(as.length); + for (let i = 0;i < as.length; i++) { + const a = as[i]; + const fa = f(a); + if (fa !== a) { + changed = true; } - const value = s.input[p.name]; - assignProperty(s.out, p.name, value); - return p.parser(value, s.options); - }, - step: stepProperty -}; -var parseProperties = /* @__PURE__ */ iterateEager()(parsePropertiesOptions); -var parsePropertiesConcurrent = /* @__PURE__ */ iterateConcurrent()(parsePropertiesOptions); -function combineChecks(a, b) { - if (!a) - return b; - if (!b) - return a; - return [...a, ...b]; + out[i] = fa; + } + return changed ? out : as; } -function struct(fields, checks, annotations) { - return new Objects(Reflect.ownKeys(fields).map((key) => { - return new PropertySignature(key, fields[key].ast); - }), [], annotations, checks); +function annotateKey(ast, annotations) { + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, { + ...ast.context.annotations, + ...annotations + }) : new Context(false, false, undefined, annotations); + return replaceContext(ast, context); } -function getAST(self) { - return self.ast; +var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { + const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false); + return optionalKeyLastLink(replaceContext(ast, context)); +}); +var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); +function withConstructorDefault(ast, defaultValue) { + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue); + return replaceContext(ast, context); } -function tuple(elements, checks = undefined) { - return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks); +function decodeTo(from, to, transformation) { + return appendTransformation(from, transformation, to); } -function union(members, options, checks) { - return new Union(members.map(getAST), options, undefined, checks); +function isOptional(ast) { + return ast.context?.isOptional ?? false; } -var toCandidate = /* @__PURE__ */ memoizeIdempotent((ast) => { - while (true) { - if (isSuspend(ast)) - return unknown; - const encoding = ast.encoding; - if (!encoding) { - return ast.recur?.(toCandidate, identity) ?? ast; - } - if (encoding.some((link) => link.transformation._tag === "Middleware" && link.transformation.decode !== identity)) - return unknown; - ast = encoding[encoding.length - 1].to; +function isStructuralCheck(check) { + return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck); +} +function extractStructuralChecks(checks) { + function extract(check) { + if (isStructuralCheck(check)) + return [check]; + return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []; + } + const out = checks.flatMap(extract); + return isArrayNonEmpty2(out) ? out : undefined; +} +var toType = /* @__PURE__ */ memoizeIdempotent((ast) => { + if (ast.encoding) { + return toType(replaceEncoding(ast, undefined)); } + const out = ast; + const type = out.recur?.(toType) ?? out; + const encodingChecks = type.encodingChecks; + if (encodingChecks) { + const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : undefined; + return modifyOwnPropertyDescriptors(type, (d) => { + d.encodingChecks.value = undefined; + d.checks.value = combineChecks(type.checks, checks); + }); + } + return type; }); -function getCandidateTypes(ast) { - switch (ast._tag) { - case "Null": - return ["null"]; - case "Undefined": - return ["undefined"]; - case "String": - case "TemplateLiteral": - return ["string"]; - case "Number": - return ["number"]; - case "Boolean": - return ["boolean"]; - case "Symbol": - case "UniqueSymbol": - return ["symbol"]; - case "BigInt": - return ["bigint"]; - case "Arrays": - return ["array"]; - case "ObjectKeyword": - return ["object", "array", "function"]; - case "Objects": - return ast.propertySignatures.length || ast.indexSignatures.length ? ["object"] : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; - case "Enum": - return Array.from(new Set(ast.enums.map(([, v]) => typeof v))); - case "Literal": - return [typeof ast.literal]; +var toEncoded = /* @__PURE__ */ memoizeIdempotent((ast) => { + return toType(flip2(ast)); +}); +function flipEncoding(ast, encoding) { + const links = encoding; + const len = links.length; + const last = links[len - 1]; + const ls = [new Link(flip2(replaceEncoding(ast, undefined)), links[0].transformation.flip())]; + for (let i = 1;i < len; i++) { + ls.unshift(new Link(flip2(links[i - 1].to), links[i].transformation.flip())); + } + const to = flip2(last.to); + if (to.encoding) { + return replaceEncoding(to, [...to.encoding, ...ls]); + } else { + return replaceEncoding(to, ls); + } +} +var flip2 = /* @__PURE__ */ memoize((ast) => { + if (ast.encoding) { + return flipEncoding(ast, ast.encoding); + } + const out = ast; + return out.flip?.(flip2) ?? out.recur?.(flip2) ?? out; +}); +function containsUndefined(ast) { + switch (ast._tag) { + case "Undefined": + return true; case "Union": - return Array.from(new Set(ast.types.flatMap(getCandidateTypes))); + return ast.types.some(containsUndefined); default: - return ["null", "undefined", "string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; + return false; } } -function collectSentinels(ast) { +function fromConst(ast, value) { + const succeed = value === 0 ? sameExit : succeed7(value); + return (input, options) => { + if (input === missing) + return missingExit; + if (input === value) + return succeed; + return fail6(new InvalidType(ast, input, options)); + }; +} +function fromRefinement(ast, refinement) { + return (input, options) => { + if (input === missing) + return missingExit; + if (refinement(input)) + return sameExit; + return fail6(new InvalidType(ast, input, options)); + }; +} +var parameterFromPropertyKey = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => { switch (ast._tag) { default: - return []; - case "Declaration": { - const s = ast.annotations?.[SENTINELS_ANNOTATION_KEY]; - return Array.isArray(s) ? s : []; - } - case "Objects": - return ast.propertySignatures.flatMap((ps) => { - const type = ps.type; - if (!isOptional(type)) { - if (isLiteral(type)) { - return [{ - key: ps.name, - literal: type.literal - }]; - } - if (isUniqueSymbol(type)) { - return [{ - key: ps.name, - literal: type.symbol - }]; - } - } - return []; - }); - case "Arrays": - return ast.elements.flatMap((e, i) => { - if (!isOptional(e)) { - if (isLiteral(e)) { - return [{ - key: i, - literal: e.literal - }]; - } - if (isUniqueSymbol(e)) { - return [{ - key: i, - literal: e.symbol - }]; - } + return ast; + case "Number": + return ast.toCodecStringTree(); + case "Union": + return ast.recur(parameterFromPropertyKey); + } +}); +var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`); +var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`); +function isStringFinite(annotations) { + return isPattern(isStringFiniteRegExp, { + expected: "a string representing a finite number", + representation: { + id: "effect/schema/isStringFinite", + payload: null + }, + toJsonSchema: () => ({ + pattern: isStringFiniteRegExp.source + }), + ...annotations + }); +} +var finiteString = /* @__PURE__ */ appendChecks(string2, [/* @__PURE__ */ isStringFinite()]); +var finiteToString = /* @__PURE__ */ new Link(finiteString, numberFromString); +var numberToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finiteString, nonFiniteLiterals]), numberFromString); +var BIGINT_PATTERN = "-?\\d+"; +var isStringBigIntRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${BIGINT_PATTERN}$`); +var REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"; +var isStringSymbolRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${REGEXP_PATTERN}$`); +function collectIssues(checks, value, issues, ast, options) { + for (let i = 0;i < checks.length; i++) { + const check = checks[i]; + if (check._tag === "FilterGroup") { + issues = collectIssues(check.checks, value, issues, ast, options); + if (issues && (options.errors !== "all" || issues[issues.length - 1].filter.aborted)) { + return issues; + } + } else { + const issue = check.run(value, ast, options); + if (issue) { + const filter = new Filter(check, issue, value, options); + if (issues) + issues.push(filter); + else + issues = [filter]; + if (options.errors !== "all" || check.aborted) { + return issues; } - return []; - }); - case "Union": { - if (ast.types.length === 0) - return []; - const members = ast.types.map((type) => collectSentinels(toCandidate(type))); - return members[0].filter((s) => members.every((sentinels) => sentinels.some((o) => o.key === s.key && o.literal === s.literal))); + } } - case "Suspend": - return collectSentinels(ast.thunk()); } + return issues; } -var candidateIndexCache = /* @__PURE__ */ new WeakMap; -var emptyCandidates = /* @__PURE__ */ Object.freeze([]); -var hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : (key in input); -function getIndex(types) { - let index = candidateIndexCache.get(types); - if (index) - return index; - let bySentinel; - let sentinelCandidateCount = 0; - let otherwise; - let literalCandidates; - let onlyLiterals = true; - for (let i = 0;i < types.length; i++) { - const a = types[i]; - const encoded = toCandidate(a); - if (isNever2(encoded)) - continue; - if (onlyLiterals) { - if (isLiteral(encoded) || isUniqueSymbol(encoded)) { - literalCandidates ??= new Map; - const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol; - let arr = literalCandidates.get(literal); - if (!arr) - literalCandidates.set(literal, arr = []); - arr.push(a); - } else { - onlyLiterals = false; +function getConstructorDescriptor(ast) { + if (!isDeclaration(ast)) + return; + const getDescriptor = ast.annotations?.[CONSTRUCTOR_ANNOTATION_KEY]; + return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; +} + +// node_modules/effect/dist/Brand.js +function nominal() { + return Object.assign((input) => input, { + option: (input) => some2(input), + result: (input) => succeed2(input), + is: (_) => true + }); +} +// node_modules/effect/dist/Fiber.js +var interrupt3 = fiberInterrupt; +var runIn = fiberRunIn; + +// node_modules/effect/dist/Latch.js +var makeUnsafe4 = makeLatchUnsafe; + +// node_modules/effect/dist/MutableRef.js +var TypeId10 = "~effect/MutableRef"; +var MutableRefProto = { + [TypeId10]: TypeId10, + ...PipeInspectableProto, + toJSON() { + return { + _id: "MutableRef", + current: toJson(this.current) + }; + } +}; +var make6 = (value) => { + const ref = Object.create(MutableRefProto); + ref.current = value; + return ref; +}; + +// node_modules/effect/dist/MutableList.js +var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); +var make7 = () => ({ + head: undefined, + tail: undefined, + length: 0 +}); +var emptyBucket = () => ({ + array: [], + mutable: true, + offset: 0, + next: undefined +}); +var append2 = (self, message) => { + if (!self.tail) { + self.head = self.tail = emptyBucket(); + } else if (!self.tail.mutable) { + self.tail.next = emptyBucket(); + self.tail = self.tail.next; + } + self.tail.array.push(message); + self.length++; +}; +var clear = (self) => { + self.head = self.tail = undefined; + self.length = 0; +}; +var takeN = (self, n) => { + n = normalize(n); + if (n <= 0 || !self.head) + return []; + n = Math.min(n, self.length); + if (n === self.length && self.head?.offset === 0 && !self.head.next) { + const array = self.head.array; + clear(self); + return array; + } + const array = new Array(n); + let index = 0; + let chunk = self.head; + while (chunk) { + while (chunk.offset < chunk.array.length) { + array[index++] = chunk.array[chunk.offset]; + if (chunk.mutable) + chunk.array[chunk.offset] = undefined; + chunk.offset++; + if (index === n) { + self.head = chunk; + self.length -= n; + if (self.length === 0) + clear(self); + return array; } } - const sentinels = collectSentinels(encoded); - if (sentinels.length) { - bySentinel ??= new Map; - sentinelCandidateCount++; - for (const { - key, - literal - } of sentinels) { - let entry = bySentinel.get(key); - if (!entry) - bySentinel.set(key, entry = [new Map, new Set]); - entry[1].add(i); - let indexes = entry[0].get(literal); - if (!indexes) - entry[0].set(literal, indexes = new Set); - indexes.add(i); - } + chunk = chunk.next; + } + clear(self); + return array; +}; +var take = (self) => { + if (!self.head) + return Empty; + const message = self.head.array[self.head.offset]; + if (self.head.mutable) + self.head.array[self.head.offset] = undefined; + self.head.offset++; + self.length--; + if (self.head.offset === self.head.array.length) { + if (self.head.next) { + self.head = self.head.next; } else { - otherwise ??= {}; - const candidateTypes = getCandidateTypes(encoded); - for (const t of candidateTypes) - (otherwise[t] ??= []).push(i); + clear(self); } } - if (onlyLiterals && literalCandidates) { - literalCandidates.forEach(Object.freeze); - index = (input) => literalCandidates.get(input) ?? emptyCandidates; - } else if (bySentinel?.size === 1 && !otherwise) { - const [key, [byValue]] = bySentinel.entries().next().value; - const candidates = byValue; - for (const [literal, indexes] of byValue) { - candidates.set(literal, Object.freeze(Array.from(indexes, (index) => types[index]))); - } - index = (input, isConstructor) => { - if (isObjectKeyword(input)) { - const value = hasPropertySignature(input, key) ? input[key] : undefined; - if (value !== undefined) - return candidates.get(value) ?? emptyCandidates; - if (isConstructor) - return types; - } - return emptyCandidates; - }; - } else if (bySentinel) { - let commonSentinel; - for (const entry of bySentinel) { - if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) { - commonSentinel = entry; - } - } - index = (input, isConstructor) => { - const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; - const base = otherwise?.[runtimeType] ?? emptyCandidates; - if (!isObjectKeyword(input)) - return base.map((i) => types[i]); - const selected = new Set(base); - let directKey; - if (commonSentinel) { - const [key, [byValue]] = commonSentinel; - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - if (!match) - return base.map((i) => types[i]); - for (const i of match) - selected.add(i); - directKey = key; - } - } - if (directKey === undefined) { - for (const [key, [byValue, all]] of bySentinel) { - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - if (match) { - for (const i of match) - selected.add(i); - } - } else if (isConstructor) { - for (const i of all) - selected.add(i); - } - } - } - for (const [key, [byValue, all]] of bySentinel) { - if (key === directKey) - continue; - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - for (const i of selected) { - if (all.has(i) && !match?.has(i)) - selected.delete(i); - } - } - } - return Array.from(selected).sort((a, b) => a - b).map((i) => types[i]); - }; - } else { - index = (input) => { - const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; - return (otherwise?.[runtimeType] ?? emptyCandidates).map((i) => types[i]).filter(filterLiterals(input)); + return message; +}; + +// node_modules/effect/dist/Queue.js +var TypeId11 = "~effect/Queue"; +var EnqueueTypeId = "~effect/Queue/Enqueue"; +var DequeueTypeId = "~effect/Queue/Dequeue"; +var variance = { + _A: identity, + _E: identity +}; +var QueueProto = { + [TypeId11]: variance, + [EnqueueTypeId]: variance, + [DequeueTypeId]: variance, + ...PipeInspectableProto, + toJSON() { + return { + _id: "effect/Queue", + state: this.state._tag, + size: sizeUnsafe(this) }; } - candidateIndexCache.set(types, index); - return index; -} -function filterLiterals(input) { - return (ast) => { - const encoded = toCandidate(ast); - return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true; +}; +var make8 = (options) => withFiber((fiber) => { + const self = Object.create(QueueProto); + self.dispatcher = fiber.currentDispatcher; + self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; + self.strategy = options?.strategy ?? "suspend"; + self.messages = make7(); + self.scheduleRunning = false; + self.state = { + _tag: "Open", + takers: new Set, + offers: new Set, + awaiters: new Set }; -} -function getCandidates(input, types, isConstructor = false) { - return getIndex(types)(input, isConstructor); -} -var Union = class extends ASTNodeImpl { - _tag = "Union"; - types; - options; - encodingChecks; - constructor(types, options, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.types = types; - this.options = options; - this.encodingChecks = encodingChecks; + return succeed3(self); +}); +var bounded = (capacity) => make8({ + capacity +}); +var offer = (self, message) => suspend(() => { + if (self.state._tag !== "Open") { + return exitFalse; + } else if (self.messages.length >= self.capacity) { + switch (self.strategy) { + case "dropping": + return exitFalse; + case "suspend": + if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return exitTrue; + } + return offerRemainingSingle(self, message); + case "sliding": + take(self.messages); + append2(self.messages, message); + return exitTrue; + } } - getParser(compile, compileConstructorDefault) { - const ast = this; - return (input, options) => { - if (input === missing) { - return missingExit; - } - const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined); - if (candidates.length === 0) { - return fail6(new AnyOf(ast, [], input, options)); - } - if (candidates.length === 1) { - const result = compile(candidates[0])(input, options); - if (result._tag === "Success") - return result; - return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchCause2(result, (cause) => failSingleUnionCandidate(ast, cause, input, options)); - } - const state = { - ast, - compile, - input, - out: undefined, - successes: ast.options?.mode === "oneOf" ? [] : undefined, - issues: undefined, - options - }; - const eff = parseUnion(state, candidates); - if (!eff) { - if (state.out) - return state.out; - return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + append2(self.messages, message); + scheduleReleaseTaker(self); + return exitTrue; +}); +var offerUnsafe = (self, message) => { + if (self.state._tag !== "Open") { + return false; + } else if (self.messages.length >= self.capacity) { + if (self.strategy === "sliding") { + take(self.messages); + append2(self.messages, message); + return true; + } else if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return true; + } + return false; + } + append2(self.messages, message); + scheduleReleaseTaker(self); + return true; +}; +var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); +var failCauseUnsafe = (self, cause) => { + if (self.state._tag !== "Open") { + return false; + } + const exit = exitFailCause(cause); + const fail = exitZipRight(exit, exitFailDone); + if (self.state.offers.size === 0 && self.messages.length === 0) { + finalize(self, fail); + return true; + } + self.state = { + ...self.state, + _tag: "Closing", + exit: fail + }; + return true; +}; +var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); +var shutdown = (self) => sync(() => { + if (self.state._tag === "Done") { + return true; + } + clear(self.messages); + const offers = self.state.offers; + finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); + if (offers.size > 0) { + for (const entry of offers) { + if (entry._tag === "Single") { + entry.resume(exitFalse); + } else { + entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); } - return flatMapEager2(eff, (_) => { - if (state.out === sameExit) - return succeed6(input); - if (state.out) - return state.out; - return fail6(new AnyOf(ast, state.issues ?? [], input, options)); - }); - }; + } + offers.clear(); } - _rebuild(recur, checks, encodingChecks) { - const types = mapOrSame(this.types, recur); - return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks); + return true; +}); +var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); +var takeBetween = (self, min, max) => { + min = normalize(min); + max = normalize(max); + return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); +}; +var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); +var poll = (self) => suspend(() => { + const result = takeUnsafe(self); + if (result === undefined) { + return succeed3(none2()); } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks); + if (result._tag === "Success") { + return succeed3(some2(result.value)); } - flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks); + return succeed3(none2()); +}); +var takeUnsafe = (self) => { + if (self.state._tag === "Done") { + return self.state.exit; } - matchPart(s, options) { - for (const type of this.types) { - const out = type.matchPart(s, options); - if (out !== undefined) - return out; + if (self.messages.length > 0) { + const message = take(self.messages); + releaseCapacity(self); + return exitSucceed(message); + } else if (self.capacity <= 0 && self.state.offers.size > 0) { + const message = takeOfferUnsafe(self.state.offers); + releaseCapacity(self); + return exitSucceed(message); + } + return; +}; +var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; +var exitFalse = /* @__PURE__ */ exitSucceed(false); +var exitTrue = /* @__PURE__ */ exitSucceed(true); +var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); +var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); +var releaseTakers = (self) => { + if (self.state._tag === "Done" || self.state.takers.size === 0) { + return; + } + for (const taker of self.state.takers) { + self.state.takers.delete(taker); + taker(exitVoid); + if (self.messages.length === 0) { + break; } + } +}; +var scheduleReleaseTaker = (self) => { + if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { return; } - getExpected(getExpected) { - const expected = this.annotations?.expected; - if (typeof expected === "string") - return expected; - if (this.types.length === 0) - return "never"; - const types = this.types.map((type) => { - const encoded = toEncoded(type); - switch (encoded._tag) { - case "Arrays": { - const literals = encoded.elements.filter(isLiteral); - if (literals.length > 0) { - return `${formatIsMutable(encoded.isMutable)}[ ${literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ")}, ... ]`; - } - break; - } - case "Objects": { - const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)); - if (literals.length > 0) { - return `{ ${literals.map((ps) => `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${formatIsOptional(ps.type.context?.isOptional)}: ${getExpected(ps.type)}`).join(", ")}, ... }`; - } - break; - } - } - return getExpected(encoded); - }); - return Array.from(new Set(types)).join(" | "); + self.scheduleRunning = true; + self.dispatcher.scheduleTask(() => { + self.scheduleRunning = false; + releaseTakers(self); + }, 0); +}; +var takeBetweenUnsafe = (self, min, max) => { + if (self.state._tag === "Done") { + return self.state.exit; + } else if (max <= 0 || min <= 0) { + return exitSucceed([]); + } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { + const messages = [takeOfferUnsafe(self.state.offers)]; + releaseCapacity(self); + return exitSucceed(messages); + } + min = Math.min(min, self.capacity || 1); + if (min <= self.messages.length) { + const messages = takeN(self.messages, max); + releaseCapacity(self); + return exitSucceed(messages); } }; -function failSingleUnionCandidate(ast, cause, input, options) { - const issue = getSchemaIssue(cause); - if (!issue) - return failCause2(cause); - return fail4(new AnyOf(ast, [issue], input, options)); -} -var parseUnion = /* @__PURE__ */ iterateEager()({ - onItem(s, ast) { - const parser = s.compile(ast); - return parser(s.input, s.options); - }, - step(s, candidate, exit) { - if (exit._tag === "Failure") { - const issue = getSchemaIssue(exit.cause); - if (issue === undefined) { - return exit; - } - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - if (s.out && s.successes) { - s.successes.push(candidate); - return fail4(new OneOf(s.ast, s.successes, s.input, s.options)); - } - s.out = exit; - if (s.successes) { - s.successes.push(candidate); - } else { - return void_2; - } +var offerRemainingSingle = (self, message) => { + return callback((resume) => { + if (self.state._tag !== "Open") { + return resume(exitFalse); } + const entry = { + _tag: "Single", + message, + resume + }; + self.state.offers.add(entry); + return sync(() => { + if (self.state._tag === "Open") { + self.state.offers.delete(entry); + } + }); + }); +}; +var takeOfferUnsafe = (offers) => { + const entry = offers.values().next().value; + if (entry._tag === "Single") { + offers.delete(entry); + entry.resume(exitTrue); + return entry.message; } -}); -var nonFiniteLiterals = /* @__PURE__ */ new Union([/* @__PURE__ */ new Literal("Infinity"), /* @__PURE__ */ new Literal("-Infinity"), /* @__PURE__ */ new Literal("NaN")]); -function formatIsMutable(isMutable) { - return isMutable ? "" : "readonly "; -} -function formatIsOptional(isOptional) { - return isOptional ? "?" : ""; -} -var Filter2 = class extends Class { - _tag = "Filter"; - run; - annotations; - aborted; - constructor(run, annotations = undefined, aborted = false) { - super(); - this.run = run; - this.annotations = annotations; - this.aborted = aborted; - } - annotate(annotations) { - return new Filter2(this.run, { - ...this.annotations, - ...annotations - }, this.aborted); + const message = entry.remaining[entry.offset++]; + if (entry.offset === entry.remaining.length) { + offers.delete(entry); + entry.resume(exitSucceed([])); } - abort() { - return new Filter2(this.run, this.annotations, true); + return message; +}; +var releaseCapacity = (self) => { + if (self.state._tag === "Done") { + return isDoneCause(self.state.exit.cause); + } else if (self.state.offers.size === 0) { + if (self.state._tag === "Closing" && self.messages.length === 0) { + finalize(self, self.state.exit); + return isDoneCause(self.state.exit.cause); + } + return false; } - and(other, annotations) { - return new FilterGroup([this, other], annotations); + for (const entry of self.state.offers) { + let n = self.capacity - self.messages.length; + if (n <= 0) + break; + else if (entry._tag === "Single") { + append2(self.messages, entry.message); + self.state.offers.delete(entry); + entry.resume(exitTrue); + } else { + for (;entry.offset < entry.remaining.length; entry.offset++) { + if (n === 0) + return false; + append2(self.messages, entry.remaining[entry.offset]); + n--; + } + self.state.offers.delete(entry); + entry.resume(exitSucceed([])); + } } + return false; }; -var FilterGroup = class extends Class { - _tag = "FilterGroup"; - checks; - annotations; - constructor(checks, annotations = undefined) { - super(); - this.checks = checks; - this.annotations = annotations; +var awaitTake = (self) => callback((resume) => { + if (self.state._tag === "Done") { + return resume(self.state.exit); } - annotate(annotations) { - return new FilterGroup(this.checks, { - ...this.annotations, - ...annotations - }); + self.state.takers.add(resume); + return sync(() => { + if (self.state._tag !== "Done") { + self.state.takers.delete(resume); + } + }); +}); +var finalize = (self, exit) => { + if (self.state._tag === "Done") { + return; } - and(other, annotations) { - return new FilterGroup([this, other], annotations); + const openState = self.state; + self.state = { + _tag: "Done", + exit + }; + for (const taker of openState.takers) { + taker(exit); + } + openState.takers.clear(); + for (const awaiter of openState.awaiters) { + awaiter(exit); } + openState.awaiters.clear(); }; -function makeFilter(filter, annotations, aborted = false) { - return new Filter2((input, ast, options) => normalizeFilterOutput(ast, filter(input, ast, options), input, options), annotations, aborted); -} -function isFinite2(annotations) { - return makeFilter((n) => globalThis.Number.isFinite(n), { - expected: "a finite number", - representation: { - id: "effect/schema/isFinite", - payload: null - }, - toJsonSchema: () => ({ - type: "number" - }), - toCode: () => ({ - runtime: "Schema.isFinite()" - }), - arbitraryConstraint: { - number: "finite" - }, - ...annotations + +// node_modules/effect/dist/Semaphore.js +var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); +var waitForPermits = (self, n, effect) => callback((resume) => { + if (self.free >= n) + return resume(effect); + const observer = () => { + if (self.free < n) + return; + self.waiters.delete(observer); + resume(effect); + }; + self.waiters.add(observer); + return sync(() => { + self.waiters.delete(observer); }); -} -var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]); -var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n)))); -function isPattern(regExp, annotations) { - const source = regExp.source; - const pattern = new globalThis.RegExp(source, regExp.flags); - return makeFilter((s) => { - pattern.lastIndex = 0; - return pattern.test(s); - }, { - expected: `a string matching the RegExp ${source}`, - representation: { - id: "effect/schema/isPattern", - payload: { - source, - flags: regExp.flags +}); + +class SemaphoreImpl { + waiters = /* @__PURE__ */ new Set; + taken = 0; + permits; + constructor(permits) { + this.permits = permits; + } + get free() { + return this.permits - this.taken; + } + take(n) { + const take = suspend(() => { + if (this.free < n) { + return waitForPermits(this, n, take); } - }, - toJsonSchema: () => ({ - pattern: source - }), - arbitraryConstraint: { - patterns: [{ - source: regExp.source, - flags: regExp.flags - }] - }, - ...annotations - }); -} -function modifyOwnPropertyDescriptors(ast, f) { - const d = Object.getOwnPropertyDescriptors(ast); - f(d); - return Object.create(Object.getPrototypeOf(ast), d); -} -var contextOwners = /* @__PURE__ */ new WeakMap; -function getContextOwner(ast) { - return contextOwners.get(ast) ?? ast; -} -function replaceEncoding(ast, encoding) { - if (ast.encoding === encoding) { - return ast; + this.taken += n; + return succeed3(n); + }); + return take; } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.encoding.value = encoding; - }); -} -function replaceContext(ast, context) { - if (ast.context === context) { - return ast; + takeIfAvailable(n) { + return suspend(() => { + if (this.free < n) + return succeed3(false); + this.taken += n; + return succeed3(true); + }); } - const owner = getContextOwner(ast); - if (owner.context === context) { - return owner; + releaseUnsafe(fiber, n) { + this.taken -= n; + if (this.waiters.size > 0) { + fiber.currentDispatcher.scheduleTask(() => { + for (const observer of this.waiters) { + if (this.free <= 0) + break; + observer(); + } + }, 0); + } + return this.free; } - const out = modifyOwnPropertyDescriptors(ast, (d) => { - d.context.value = context; - }); - contextOwners.set(out, owner); - return out; -} -function getLastEncoding(ast) { - return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast; -} -function annotate(ast, annotations) { - if (ast.checks) { - const last = ast.checks[ast.checks.length - 1]; - return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations))); + resize(permits) { + return withFiber((fiber) => { + this.permits = permits; + if (this.free < 0) + return void_; + this.releaseUnsafe(fiber, 0); + return void_; + }); } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.annotations.value = { - ...d.annotations.value, - ...annotations - }; - }); -} -function replaceChecks(ast, checks) { - if (ast._tag === "Suspend" && checks) { - throw new Error("Cannot add checks to Suspend"); + release(n) { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); } - if (ast.checks === checks) { - return ast; + get releaseAll() { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.checks.value = checks; - }); -} -function appendChecks(ast, checks) { - return replaceChecks(ast, combineChecks(ast.checks, checks)); -} -function mapLink(link, f) { - const to = f(link.to); - return to === link.to ? link : new Link(to, link.transformation); -} -function updateLastLink(encoding, f) { - const links = encoding; - const last = links[links.length - 1]; - const out = mapLink(last, f); - return out === last ? encoding : append(encoding.slice(0, encoding.length - 1), out); -} -function applyToLastLink(f) { - return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast; -} -function applyToSelfOrLastLinkEncodingIdempotent(f, options) { - function out(ast) { - if (ast.encoding) { - const last = ast.encoding[ast.encoding.length - 1]; - return options?.stopAt?.(last) ? ast : replaceEncoding(ast, updateLastLink(ast.encoding, out)); - } - return f(ast); + withPermits(n) { + return (self) => uninterruptibleMask((restore) => { + const acquire = suspend(() => { + if (this.free < n) { + const wait = waitForPermits(this, n, void_); + return flatMap2(restore(wait), () => acquire); + } + this.taken += n; + return onExitPrimitive(restore(self), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); + return acquire; + }); + } + withPermit = /* @__PURE__ */ this.withPermits(1); + withPermitsIfAvailable(n) { + return (self) => uninterruptibleMask((restore) => { + if (this.free < n) + return succeedNone; + this.taken += n; + return onExitPrimitive(restore(asSome(self)), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); } - return memoizeIdempotent(out); -} -function appendTransformation(from, transformation, to) { - const link = new Link(from, transformation); - return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]); } -function mapOrSame(as, f) { - let changed = false; - const out = new Array(as.length); - for (let i = 0;i < as.length; i++) { - const a = as[i]; - const fa = f(a); - if (fa !== a) { - changed = true; - } - out[i] = fa; + +// node_modules/effect/dist/Channel.js +var TypeId12 = "~effect/Channel"; +var isChannel = (u) => hasProperty(u, TypeId12); +var ChannelProto = { + [TypeId12]: { + _Env: identity, + _InErr: identity, + _InElem: identity, + _OutErr: identity, + _OutElem: identity + }, + pipe() { + return pipeArguments(this, arguments); } - return changed ? out : as; -} -function annotateKey(ast, annotations) { - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, { - ...ast.context.annotations, - ...annotations - }) : new Context(false, false, undefined, annotations); - return replaceContext(ast, context); -} -var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { - const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false); - return optionalKeyLastLink(replaceContext(ast, context)); -}); -var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); -function withConstructorDefault(ast, defaultValue) { - const transformation = new Transformation(withDefault(defaultValue), passthrough()); - const constructorDefault = new Link(unknown, transformation); - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) : new Context(false, false, constructorDefault); - return replaceContext(ast, context); -} -function decodeTo(from, to, transformation) { - return appendTransformation(from, transformation, to); -} -function isOptional(ast) { - return ast.context?.isOptional ?? false; -} -function isStructuralCheck(check) { - return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck); -} -function extractStructuralChecks(checks) { - function extract(check) { - if (isStructuralCheck(check)) - return [check]; - return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []; +}; +var fromTransform = (transform) => { + const self = Object.create(ChannelProto); + self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); + return self; +}; +var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); +var fromPull = (effect) => fromTransform((_, __) => effect); +var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { + const closableScope = forkUnsafe2(scope); + const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); + const pull = yield* onError2(f(upstream, scope, closableScope), onCause); + return onError2(pull, onCause); +})); +var toTransform = (channel) => channel.transform; +var asyncQueue = (scope, f, options) => make8({ + capacity: options?.bufferSize, + strategy: options?.strategy +}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); +var callbackArray = (f, options) => fromTransform((_, scope) => map5(asyncQueue(scope, f, options), takeAll2)); +var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); +var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done2())); +var map6 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { + let i = 0; + return map5(pull, (o) => f(o, i++)); +}))); +var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); +var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done2))))); +var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { + const strategy = options?.haltStrategy ?? "both"; + const queue = yield* bounded(0); + yield* addFinalizer2(forkedScope, shutdown(queue)); + let done = 0; + function onExit(side, cause) { + done++; + if (!isDoneCause(cause)) { + return failCause4(queue, cause); + } + switch (strategy) { + case "both": { + return done === 2 ? failCause4(queue, cause) : void_3; + } + case "left": + case "right": { + return side === strategy ? failCause4(queue, cause) : void_3; + } + case "either": { + return failCause4(queue, cause); + } + } } - const out = checks.flatMap(extract); - return isArrayNonEmpty2(out) ? out : undefined; -} -var toType = /* @__PURE__ */ memoizeIdempotent((ast) => { - if (ast.encoding) { - return toType(replaceEncoding(ast, undefined)); + const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); + yield* runSide("left", left, forkUnsafe2(forkedScope)); + yield* runSide("right", right, forkUnsafe2(forkedScope)); + return take2(queue); +}))); +var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { + let stringBuilder = ""; + let midCRLF = false; + let done = none2(); + function splitLinesArray(chunk) { + const chunkBuilder = []; + function pushLine(segment) { + if (stringBuilder.length === 0) { + chunkBuilder.push(segment); + } else { + chunkBuilder.push(stringBuilder + segment); + stringBuilder = ""; + } + } + for (let i = 0;i < chunk.length; i++) { + const str = chunk[i]; + if (str.length !== 0) { + let from = 0; + let indexOfCR = str.indexOf("\r"); + let indexOfLF = str.indexOf(` +`); + if (midCRLF) { + if (indexOfLF === 0) { + from = 1; + indexOfLF = str.indexOf(` +`, from); + } + midCRLF = false; + } + while (indexOfCR !== -1 || indexOfLF !== -1) { + if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { + pushLine(str.substring(from, indexOfLF)); + from = indexOfLF + 1; + indexOfLF = str.indexOf(` +`, from); + } else { + pushLine(str.substring(from, indexOfCR)); + if (str.length === indexOfCR + 1) { + midCRLF = true; + from = str.length; + indexOfCR = -1; + } else { + from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); + indexOfCR = str.indexOf("\r", from); + indexOfLF = str.indexOf(` +`, from); + } + } + } + stringBuilder = stringBuilder + str.substring(from); + } + } + return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; } - const out = ast; - const type = out.recur?.(toType) ?? out; - const encodingChecks = type.encodingChecks; - if (encodingChecks) { - const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : undefined; - return modifyOwnPropertyDescriptors(type, (d) => { - d.encodingChecks.value = undefined; - d.checks.value = combineChecks(type.checks, checks); + const pullOrFlush = suspend2(() => { + if (done._tag === "Some") { + return done2(done.value); + } + return matchEffect2(upstream, { + onSuccess: loop, + onFailure: failCause3, + onDone: (leftover) => { + done = some2(leftover); + if (stringBuilder.length > 0) { + const last = stringBuilder; + stringBuilder = ""; + midCRLF = false; + return succeed6([last]); + } + return done2(leftover); + } }); + }); + function loop(chunk) { + const lines = splitLinesArray(chunk); + return lines !== null ? succeed6(lines) : pullOrFlush; } - return type; -}); -var toEncoded = /* @__PURE__ */ memoizeIdempotent((ast) => { - return toType(flip2(ast)); + return pullOrFlush; +})); +var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); +var unwrap = (channel) => fromTransform((upstream, scope) => { + let pull; + return succeed6(suspend2(() => { + if (pull) + return pull; + return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); + })); }); -function flipEncoding(ast, encoding) { - const links = encoding; - const len = links.length; - const last = links[len - 1]; - const ls = [new Link(flip2(replaceEncoding(ast, undefined)), links[0].transformation.flip())]; - for (let i = 1;i < len; i++) { - ls.unshift(new Link(flip2(links[i - 1].to), links[i].transformation.flip())); - } - const to = flip2(last.to); - if (to.encoding) { - return replaceEncoding(to, [...to.encoding, ...ls]); - } else { - return replaceEncoding(to, ls); - } -} -var flip2 = /* @__PURE__ */ memoize((ast) => { - if (ast.encoding) { - return flipEncoding(ast, ast.encoding); - } - const out = ast; - return out.flip?.(flip2) ?? out.recur?.(flip2) ?? out; +var runWith = (self, f, onHalt) => suspend2(() => { + const scope = makeUnsafe3(); + const makePull = toTransform(self)(done2(), scope); + return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); }); -function containsUndefined(ast) { - switch (ast._tag) { - case "Undefined": - return true; - case "Union": - return ast.types.some(containsUndefined); - default: - return false; +var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { + disableYield: true +}))); +var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { + let state = initial(); + return runWith(self, (pull) => whileLoop2({ + while: constTrue, + body: () => pull, + step: (value) => { + state = f(state, value); + } + }), () => succeed6(state)); +})); +var toPullScoped = (self, scope) => toTransform(self)(done2(), scope); +// node_modules/effect/dist/internal/schema/interpreter.js +var flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager2(result, f); +function compileTransformation(transformation) { + if (transformation._tag === "Middleware") { + return (result, current, options) => { + const transformed = result === sameExit ? transformation.decode(succeed7(toOption(current)), options) : transformation.decode(mapEager2(result, toOption), options); + return fromOptionalEffect(transformed); + }; + } + const getter = transformation.decode; + switch (getter._tag) { + case "Passthrough": + return (result, current) => result === sameExit ? succeed7(current) : result; + case "Transform": { + const transform = (value) => value === missing ? missingExit : succeed7(getter.transform(value)); + return (result, current) => flatMapTransformation(result, current, transform); + } + case "TransformOptional": { + const transform = (value) => fromOptionExit(getter.transform(toOption(value))); + return (result, current) => flatMapTransformation(result, current, transform); + } + case "TransformEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => value === missing ? missingExit : getter.transform(value, options)); + case "TransformOptionalEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => fromOptionalEffect(getter.transform(toOption(value), options))); } } -function fromConst(ast, value) { - const succeed = value === 0 ? sameExit : succeed8(value); +var fromOptionalEffect = (effect) => flatMapEager2(effect, fromOptionExit); +var wrapEncoding = (ast, input, options, effect) => catchCause2(effect, (cause) => failCauseSync2(() => map4(cause, (issue) => new Encoding(ast, issue, input, options)))); +function makeConstructorParser(descriptor, compile) { + const transform = compileTransformation(descriptor.link.transformation); + let sourceParser; return (input, options) => { if (input === missing) return missingExit; - if (input === value) - return succeed; - return fail6(new InvalidType(ast, input, options)); + if (descriptor.isConstructed(input)) + return sameExit; + const result = (sourceParser ??= compile(descriptor.link.to))(input, options); + return transform(result, input, options); }; } -function fromRefinement(ast, refinement) { +function withDefault(ast, parser) { + const defaultValue = ast.context.constructorDefault; return (input, options) => { - if (input === missing) - return missingExit; - if (refinement(input)) - return sameExit; - return fail6(new InvalidType(ast, input, options)); + if (input !== missing && input !== undefined) + return parser(input, options); + const result = defaultValue; + if (effectIsExit(result) && result._tag === "Success") { + const local = parser(result[args], options); + return local === sameExit ? result : local; + } + return flatMapEager2(wrapEncoding(ast, input, options, result), (value) => { + const local = parser(value, options); + return local === sameExit ? succeed7(value) : local; + }); }; } -var parameterFromPropertyKey = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => { - switch (ast._tag) { - default: - return ast; - case "Number": - return ast.toCodecStringTree(); - case "Union": - return ast.recur(parameterFromPropertyKey); - } -}); -var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`); -var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`); -function isStringFinite(annotations) { - return isPattern(isStringFiniteRegExp, { - expected: "a string representing a finite number", - representation: { - id: "effect/schema/isStringFinite", - payload: null - }, - toJsonSchema: () => ({ - pattern: isStringFiniteRegExp.source - }), - ...annotations - }); +function compileField(ast, compile) { + const parser = compile(ast); + return ast.context?.constructorDefault === undefined ? parser : withDefault(ast, parser); } -var finiteString = /* @__PURE__ */ appendChecks(string2, [/* @__PURE__ */ isStringFinite()]); -var finiteToString = /* @__PURE__ */ new Link(finiteString, numberFromString); -var numberToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finiteString, nonFiniteLiterals]), numberFromString); -var BIGINT_PATTERN = "-?\\d+"; -var isStringBigIntRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${BIGINT_PATTERN}$`); -var REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"; -var isStringSymbolRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${REGEXP_PATTERN}$`); -function collectIssues(checks, value, issues, ast, options) { - for (let i = 0;i < checks.length; i++) { - const check = checks[i]; - if (check._tag === "FilterGroup") { - issues = collectIssues(check.checks, value, issues, ast, options); - if (issues && (options.errors !== "all" || issues[issues.length - 1].filter.aborted)) { - return issues; +function compile(ast, compile, compileField, base, specialize) { + if (ast._tag === "Declaration") { + for (const parameter of ast.typeParameters) + compile(parameter); + } + const descriptor = compileField ? getConstructorDescriptor(ast) : undefined; + const parser = descriptor ? makeConstructorParser(descriptor, compile) : base ?? ast.getParser(compile, compileField); + const checks = ast.checks; + const links = ast.encoding; + const transformations = links?.map((link) => compileTransformation(link.transformation)); + const encodingChecks = ast.encodingChecks; + if (!links && !checks && !encodingChecks) { + return parser; + } + let encodingParsers; + const parseChecks = (input, options) => { + let result = parser(input, options); + if (encodingChecks && !options.disableChecks) { + if (effectIsExit(result)) { + if (result._tag === "Success") { + const output = result === sameExit ? input : result[args]; + if (input !== missing && output !== missing) { + const issues = collectIssues(encodingChecks, input, undefined, ast, options); + if (issues) { + result = fail6(new Composite(ast, issues, input, options)); + } + } + } + } else { + result = flatMap3(result, (value) => { + if (input !== missing && value !== missing) { + const issues = collectIssues(encodingChecks, input, undefined, ast, options); + if (issues) { + return fail6(new Composite(ast, issues, input, options)); + } + } + return succeed6(value); + }); } - } else { - const issue = check.run(value, ast, options); - if (issue) { - const filter = new Filter(check, issue, value, options); - if (issues) - issues.push(filter); - else - issues = [filter]; - if (options.errors !== "all" || check.aborted) { - return issues; + } + if (checks && !options.disableChecks) { + if (effectIsExit(result)) { + if (result._tag === "Success") { + const value = result === sameExit ? input : result[args]; + if (value === missing) + return result; + const issues = collectIssues(checks, value, undefined, ast, options); + if (issues) { + result = fail6(new Composite(ast, issues, value, options)); + } } + } else { + result = flatMap3(result, (value) => { + if (value !== missing) { + const issues = collectIssues(checks, value, undefined, ast, options); + if (issues) { + return fail6(new Composite(ast, issues, value, options)); + } + } + return succeed6(value); + }); } } + return result; + }; + const parseLocal = specialize === undefined ? parseChecks : specialize(parseChecks); + if (!links) { + return parseLocal; } - return issues; + return (input, options) => { + const parsers = encodingParsers ??= links.map((link) => compile(link.to)); + let current = input; + let result = parsers[parsers.length - 1](input, options); + for (let i = links.length - 1;i >= 0; i--) { + result = transformations[i](result, current, options); + if (i !== 0) { + const next = parsers[i - 1]; + if (result._tag === "Success") { + current = result[args]; + result = next(current, options); + } else { + result = flatMapEager2(result, (value) => { + const nextResult = next(value, options); + return nextResult === sameExit ? succeed7(value) : nextResult; + }); + } + } + } + if (result._tag === "Success") { + const value = result[args]; + const local = parseLocal(value, options); + return local === sameExit ? result : local; + } + result = wrapEncoding(ast, input, options, result); + return flatMapEager2(result, (value) => { + const local = parseLocal(value, options); + return local === sameExit ? succeed7(value) : local; + }); + }; } -function getConstructorDescriptor(ast) { - if (!isDeclaration(ast)) - return; - const getDescriptor = ast.annotations?.[CONSTRUCTOR_ANNOTATION_KEY]; - return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; + +// node_modules/effect/dist/internal/schema/compilerRegistry.js +var invalid3 = /* @__PURE__ */ Symbol(); +var cache = /* @__PURE__ */ new WeakMap; +var compiler; +var compilerAdaptersEnabled = false; +var decodeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "parser") : resolve2(ast).parser; +var makeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "makeEffect") : resolve2(ast).makeEffect; +var makeField = (ast) => compileField(ast, makeChild); + +class InterpretedEntry { + ast; + constructor(ast) { + this.ast = ast; + } + get decodeEffect() { + return this.cachedDecodeEffect ??= compile(this.ast, decodeChild); + } + get parser() { + return this.decodeEffect; + } + get makeEffect() { + return this.cachedMakeEffect ??= compile(this.ast, makeChild, makeField); + } +} + +class CompilerEntry extends InterpretedEntry { + compiled; + resolve; + constructor(ast, compiled, resolve) { + super(ast); + this.compiled = compiled; + this.resolve = resolve; + } + save(key, value) { + Object.defineProperty(this, key, { + value + }); + return value; + } + operation(key) { + const compiled = this.compiled; + return typeof compiled === "function" ? compiled(this.ast, this.resolve, key) : compiled?.[key]; + } + get is() { + return this.save("is", this.operation("is")); + } + get decode() { + return this.save("decode", this.operation("decode")); + } + get make() { + return this.save("make", this.operation("make")); + } + get decodeEffect() { + return this.save("decodeEffect", this.operation("decodeEffect") ?? compile(this.ast, (ast) => lazyParser(this.resolve, ast, "parser"))); + } + get parser() { + const decode = this.decode; + return decode === undefined ? this.decodeEffect : this.save("parser", withDecode(decode, () => this.decodeEffect)); + } + get makeEffect() { + const makeEffect = this.operation("makeEffect"); + if (makeEffect !== undefined) + return this.save("makeEffect", makeEffect); + const child = (ast) => lazyParser(this.resolve, ast, "makeEffect"); + return this.save("makeEffect", compile(this.ast, child, (ast) => compileField(ast, child))); + } +} +function withDecode(fastDecode, decodeEffect) { + let detailed; + return (input, options) => { + if (input !== missing) { + try { + const value = fastDecode(input, options); + if (value !== invalid3) + return value === input ? sameExit : succeed7(value); + } catch (error) { + return die3(error); + } + } + return (detailed ??= decodeEffect())(input, options); + }; +} +function lazyParser(resolve, ast, operation) { + const entry = resolve(ast); + if (entry.compiled === undefined || Object.hasOwn(entry, operation)) { + return entry[operation]; + } + let parser; + return (input, options) => (parser ??= entry[operation])(input, options); +} +function resolve2(ast) { + const cached = cache.get(ast); + if (cached !== undefined) + return cached; + const entry = compiler === undefined ? new InterpretedEntry(ast) : new CompilerEntry(ast, compiler(ast, resolve2), resolve2); + cache.set(ast, entry); + return entry; } // node_modules/effect/dist/SchemaParser.js @@ -7576,177 +7465,92 @@ function makeOption(schema) { return none2(); }; } -function make14(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return exit.value; - } - const issue = getSchemaIssueOrThrow(exit.cause, "Constructor adapter can only throw schema issues"); - throw new Error("Schema validation failed", { - cause: issue - }); - }; +function make9(schema) { + return makeConstructorSync(toType(schema.ast)); } function decodeUnknownEffect(schema, options) { - const parser = run2(schema.ast); + const parser = run(schema.ast); return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); } var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { ...options, ...overrideOptions } : options; -var getValue = (value) => { - if (value === missing) { - return fail6(new InvalidValue); - } - return succeed6(value); -}; -function run2(ast) { - return runWithCompiler(normalCompiler, ast); -} -function runWithCompiler(compiler, ast) { - let parser; - return (input, options) => { - const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); - if (result === sameExit) { - return succeed6(input); - } - if (!effectIsExit(result)) { - return flatMapEager2(result, getValue); - } - return result[args] === missing ? getValue(missing) : result; - }; -} -var normalCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, normalCompiler)); -var constructorCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault)); -var compileDefaulted = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault, ast.context?.constructorDefault)); -function compileConstructorDefault(ast) { - return ast.context?.constructorDefault ? compileDefaulted(ast) : constructorCompiler(ast); -} -function applyTransformation(result, current, transformation, options) { - let transformed; - if (effectIsExit(result) && result._tag === "Success") { - const optional = toOption(result === sameExit ? current : result[args]); - transformed = transformation._tag === "Transformation" ? transformation.decode.run(optional, options) : transformation.decode(succeed8(optional), options); - } else if (transformation._tag === "Transformation") { - transformed = flatMapEager2(result, (value) => transformation.decode.run(toOption(value), options)); - } else { - transformed = transformation.decode(mapEager2(result, toOption), options); - } - return effectIsExit(transformed) && transformed._tag === "Success" ? fromOptionExit(transformed[args]) : flatMapEager2(transformed, fromOptionExit); -} -function makeConstructorParser(descriptor, compile) { - let sourceParser; - return (input, options) => { - if (input === missing) - return missingExit; - if (descriptor.isConstructed(input)) - return sameExit; - const result = (sourceParser ??= compile(descriptor.link.to))(input, options); - return applyTransformation(result, input, descriptor.link.transformation, options); - }; -} -function makeParser(ast, compile, compileConstructorDefault, constructorDefault) { - const descriptor = compileConstructorDefault ? getConstructorDescriptor(ast) : undefined; - const parser = descriptor ? makeConstructorParser(descriptor, compile) : ast.getParser(compile, compileConstructorDefault); - const checks = ast.checks; - const links = constructorDefault ? ast.encoding ? [...ast.encoding, constructorDefault] : [constructorDefault] : ast.encoding; - const encodingChecks = ast.encodingChecks; - if (!links && !checks && !encodingChecks) { - return parser; - } - let encodingParsers; - const parseLocal = (input, options) => { - let result = parser(input, options); - if (encodingChecks && !options.disableChecks) { - if (effectIsExit(result)) { - if (result._tag === "Success") { - const output = result === sameExit ? input : result[args]; - if (input !== missing && output !== missing) { - const issues = collectIssues(encodingChecks, input, undefined, ast, options); - if (issues) { - result = fail6(new Composite(ast, issues, input, options)); - } - } - } - } else { - result = flatMap3(result, (value) => { - if (input !== missing && value !== missing) { - const issues = collectIssues(encodingChecks, input, undefined, ast, options); - if (issues) { - return fail6(new Composite(ast, issues, input, options)); - } - } - return succeed6(value); - }); - } +var getValue = (value) => { + if (value === missing) { + return fail6(new InvalidValue); + } + return succeed6(value); +}; +function run(ast) { + return runWithCompiler(normalCompiler, ast); +} +function parserResult(result, input) { + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; +} +function runWithCompiler(compiler, ast) { + let parser; + return (input, options) => { + const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); + if (result === sameExit) { + return succeed6(input); } - if (checks && !options.disableChecks) { - if (effectIsExit(result)) { - if (result._tag === "Success") { - const value = result === sameExit ? input : result[args]; - if (value === missing) - return result; - const issues = collectIssues(checks, value, undefined, ast, options); - if (issues) { - result = fail6(new Composite(ast, issues, value, options)); - } - } - } else { - result = flatMap3(result, (value) => { - if (value !== missing) { - const issues = collectIssues(checks, value, undefined, ast, options); - if (issues) { - return fail6(new Composite(ast, issues, value, options)); - } - } - return succeed6(value); - }); - } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); } - return result; + return result[args] === missing ? getValue(missing) : result; }; - if (!links) { - return parseLocal; +} +function runSync2(effect, message) { + const exit = runSyncExit2(effect); + if (isSuccess3(exit)) { + return exit.value; } + const issue = getSchemaIssueOrThrow(exit.cause, message); + throw new Error("Schema validation failed", { + cause: issue + }); +} +function makeConstructorSync(ast) { + let entry; + let parser; return (input, options) => { - const parsers = encodingParsers ??= links.map((link) => compile(link.to)); - let current = input; - let result = parsers[parsers.length - 1](input, options); - for (let i = links.length - 1;i >= 0; i--) { - result = applyTransformation(result, current, links[i].transformation, options); - if (i !== 0) { - const next = parsers[i - 1]; - if (result._tag === "Success") { - current = result[args]; - result = next(current, options); - } else { - result = flatMapEager2(result, (value) => { - const nextResult = next(value, options); - return nextResult === sameExit ? succeed8(value) : nextResult; - }); - } + entry ??= resolve2(ast); + const parseOptions = options?.disableChecks ? options.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions ?? defaultParseOptions; + const make = entry.make; + if (make !== undefined && input !== missing) { + let output; + try { + output = make(input, parseOptions); + } catch (error) { + getSchemaIssueOrThrow(die2(error), "Constructor adapter can only throw schema issues"); + throw error; } + if (output !== invalid3 && output !== missing) + return output; } - if (result._tag === "Success") { - const value = result[args]; - const local = parseLocal(value, options); - return local === sameExit ? result : local; - } - result = catchCause2(result, (cause) => failCauseSync2(() => map5(cause, (issue) => new Encoding(ast, issue, input, options)))); - return flatMapEager2(result, (value) => { - const local = parseLocal(value, options); - return local === sameExit ? succeed8(value) : local; - }); + const result = (parser ??= entry.makeEffect)(input, parseOptions); + return runSync2(parserResult(result, input), "Constructor adapter can only throw schema issues"); }; } +var normalCompiler = (ast) => resolve2(ast).parser; +var constructorCompiler = (ast) => resolve2(ast).makeEffect; // node_modules/effect/dist/internal/schema/make.js -var TypeId20 = "~effect/Schema/Schema"; +var TypeId13 = "~effect/Schema/Schema"; var SchemaProto = { - [TypeId20]: TypeId20, + [TypeId13]: TypeId13, pipe() { return pipeArguments(this, arguments); }, @@ -7760,7 +7564,7 @@ var SchemaProto = { return this.rebuild(appendChecks(this.ast, checks)); } }; -function make15(ast, options) { +function make10(ast, options) { function Schema() {} const self = Object.setPrototypeOf(Schema, SchemaProto); if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) { @@ -7771,9 +7575,9 @@ function make15(ast, options) { Object.assign(self, options); } self.ast = ast; - self.rebuild = (ast) => make15(ast, options); + self.rebuild = (ast) => make10(ast, options); self.makeEffect = makeEffect(self); - self.make = make14(self); + self.make = make9(self); self.makeOption = makeOption(self); return self; } @@ -7788,10 +7592,10 @@ function isSchemaError(u) { } // node_modules/effect/dist/Schema.js -var TypeId21 = TypeId20; +var TypeId14 = TypeId13; function declareConstructor() { return (typeParameters, run, annotations) => { - return make16(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make16(ast))), annotations)); + return make11(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make11(ast))), annotations)); }; } function declare(is, annotations) { @@ -7824,10 +7628,10 @@ function fromIssueEffect(self) { if (effectIsExit(self)) { return fromIssueExit(self); } - return catchCause2(self, (cause) => failCauseSync2(() => map5(cause, (issue) => new SchemaError(issue)))); + return catchCause2(self, (cause) => failCauseSync2(() => map4(cause, (issue) => new SchemaError(issue)))); } function fromIssueExit(exit) { - return isSuccess3(exit) ? exit : failCause2(map5(exit.cause, (issue) => new SchemaError(issue))); + return isSuccess3(exit) ? exit : failCause2(map4(exit.cause, (issue) => new SchemaError(issue))); } function decodeUnknownEffect2(schema, options) { const parser = decodeUnknownEffect(schema, options); @@ -7835,15 +7639,15 @@ function decodeUnknownEffect2(schema, options) { return fromIssueEffect(parser(input, options)); }; } -var make16 = make15; +var make11 = make10; function isSchema(u) { - return hasProperty(u, TypeId21) && u[TypeId21] === TypeId21; + return hasProperty(u, TypeId14) && u[TypeId14] === TypeId14; } -var optionalKey2 = /* @__PURE__ */ lambda((schema) => make16(optionalKey(schema.ast), { +var optionalKey2 = /* @__PURE__ */ lambda((schema) => make11(optionalKey(schema.ast), { schema })); function Literal2(literal) { - const out = make16(new Literal(literal), { + const out = make11(new Literal(literal), { literal, transform(to) { return out.pipe(decodeTo2(Literal2(to), { @@ -7854,10 +7658,10 @@ function Literal2(literal) { }); return out; } -var String4 = /* @__PURE__ */ make16(string2); -var Number5 = /* @__PURE__ */ make16(number2); +var String4 = /* @__PURE__ */ make11(string2); +var Number5 = /* @__PURE__ */ make11(number2); function makeStruct(ast, fields) { - return make16(ast, { + return make11(ast, { fields, mapFields(f, options) { const fields = f(this.fields); @@ -7869,7 +7673,7 @@ function Struct(fields) { return makeStruct(struct(fields, undefined), fields); } function makeTuple(ast, elements) { - return make16(ast, { + return make11(ast, { elements, mapElements(f, options) { const elements = f(this.elements); @@ -7880,11 +7684,11 @@ function makeTuple(ast, elements) { function Tuple(elements) { return makeTuple(tuple(elements), elements); } -var ArraySchema = /* @__PURE__ */ lambda((schema) => make16(new Arrays(false, [], [schema.ast]), { +var ArraySchema = /* @__PURE__ */ lambda((schema) => make11(new Arrays(false, [], [schema.ast]), { value: schema })); function makeUnion(ast, members) { - return make16(ast, { + return make11(ast, { members, mapMembers(f, options) { const members = f(this.members); @@ -7897,14 +7701,14 @@ function Union2(members, options) { } function decodeTo2(to, transformation) { return (from) => { - return make16(decodeTo(from.ast, to.ast, transformation ? make13(transformation) : passthrough2()), { + return make11(decodeTo(from.ast, to.ast, transformation ? makeTransformation(transformation) : passthrough2()), { from, to }); }; } function withConstructorDefault2(defaultValue) { - return (schema) => make16(withConstructorDefault(schema.ast, defaultValue), { + return (schema) => make11(withConstructorDefault(schema.ast, defaultValue), { schema }); } @@ -7922,7 +7726,7 @@ function instanceOf(constructor, annotations) { } function link() { return (encodeTo, transformation) => { - return new Link(encodeTo.ast, make13(transformation)); + return new Link(encodeTo.ast, makeTransformation(transformation)); }; } var makeFilter2 = makeFilter; @@ -8031,7 +7835,7 @@ var File = /* @__PURE__ */ instanceOf(globalThis.File, { name: String4, lastModified: Int }), transformEffect2({ - decode: (e, options) => match3(decodeBase64(e.data), { + decode: (e, options) => match2(decodeBase64(e.data), { onFailure: () => fail6(new InvalidValue({ expected: "a valid Base64 string" }, e.data, options)), @@ -8159,7 +7963,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { } }); } - static [TypeId21] = TypeId21; + static [TypeId14] = TypeId14; get [ClassTypeId]() { return ClassTypeId; } @@ -8176,7 +7980,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { return getClassSchema(this).rebuild(ast); } static make(input, options) { - return make14(getClassSchema(this))(input ?? {}, options); + return make9(getClassSchema(this))(input ?? {}, options); } static makeOption(input, options) { return makeOption(getClassSchema(this))(input ?? {}, options); @@ -8235,7 +8039,7 @@ function getClassSchemaFactory(from, identifier, annotations) { const ClassTypeId = getClassTypeId(identifier); const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId); const transformation = getClassTransformation(self); - const to = make16(new Declaration([from.ast], () => (input, ast, options) => { + const to = make11(new Declaration([from.ast], () => (input, ast, options) => { return isClassValue(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)); }, { identifier, @@ -8273,98 +8077,336 @@ var TaggedError3 = (identifier) => { return Error4(identifier ?? tagValue)(struct, annotations); }; }; -// src/action/ActionInputs.ts -var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; -var readRawInput = (name) => { - const value = process.env[inputEnvName(name)]; - return value === undefined || value === "" ? undefined : value; +// node_modules/effect/dist/PlatformError.js +var TypeId15 = "~effect/PlatformError"; + +class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { + get message() { + return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; + } +} + +class SystemError extends Error3 { + get message() { + return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; + } +} + +class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { + constructor(reason) { + if ("cause" in reason) { + super({ + reason, + cause: reason.cause + }); + } else { + super({ + reason + }); + } + } + [TypeId15] = TypeId15; + get message() { + return this.reason.message; + } +} +var systemError = (options) => new PlatformError(new SystemError(options)); +var badArgument = (options) => new PlatformError(new BadArgument(options)); + +// node_modules/effect/dist/internal/stream.js +var TypeId16 = "~effect/Stream"; +var streamVariance = { + _R: identity, + _E: identity, + _A: identity }; -var readInputs = (names) => { - const inputs = {}; - for (const name of names) { - const value = readRawInput(name); - if (value !== undefined) - inputs[name] = value; +var Stream = function(channel) { + this.channel = channel; +}; +Stream.prototype = { + [TypeId16]: streamVariance, + pipe() { + return pipeArguments(this, arguments); } - return inputs; }; -var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); -// node_modules/effect/dist/Runtime.js -var defaultTeardown = (exit, onExit) => { - if (isSuccess3(exit)) - return onExit(0); - if (hasInterruptsOnly2(exit.cause)) - return onExit(130); - return onExit(getErrorExitCode(squash(exit.cause))); +var fromChannel = (channel) => new Stream(channel); + +// node_modules/effect/dist/Sink.js +var TypeId17 = "~effect/Sink"; +var endVoid = /* @__PURE__ */ succeed6([undefined]); +var sinkVariance = { + _A: identity, + _In: identity, + _L: identity, + _E: identity, + _R: identity }; -var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { - const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { - if (hasInterruptsOnly2(cause)) +var SinkProto = { + [TypeId17]: sinkVariance, + pipe() { + return pipeArguments(this, arguments); + } +}; +var isSink = (u) => hasProperty(u, TypeId17); +var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ + disableYield: true +})), catchDone(succeed6))); +var fromTransform2 = (transform) => { + const self = Object.create(SinkProto); + self.transform = transform; + return self; +}; +var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done2))); +var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { + disableYield: true +}), () => endVoid)); +var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { + discard: true +})); +var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ + disableYield: true +}), catchDone(() => endVoid))); +var unwrap2 = (effect) => fromChannel2(unwrap(map5(effect, toChannel))); + +// node_modules/effect/dist/internal/rcRef.js +var TypeId18 = "~effect/RcRef"; +var stateEmpty = { + _tag: "Empty" +}; +var stateClosed = { + _tag: "Closed" +}; +var variance2 = { + _A: identity, + _E: identity +}; + +class RcRefImpl { + [TypeId18] = variance2; + pipe() { + return pipeArguments(this, arguments); + } + state = stateEmpty; + semaphore = /* @__PURE__ */ makeUnsafe5(1); + acquire; + context; + scope; + idleTimeToLive; + constructor(acquire, context, scope, idleTimeToLive) { + this.acquire = acquire; + this.context = context; + this.scope = scope; + this.idleTimeToLive = idleTimeToLive; + } +} +var make12 = (options) => withFiber2((fiber) => { + const context = fiber.context; + const scope = get(context, Scope); + const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== undefined ? fromInputUnsafe(options.idleTimeToLive) : undefined); + return as2(addFinalizerExit(scope, () => { + const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; + ref.state = stateClosed; + return close2; + }), ref); +}); +var getState = (self) => uninterruptibleMask2(function loop(restore) { + switch (self.state._tag) { + case "Closed": { + return interrupt2; + } + case "Acquired": { + self.state.refCount++; + return self.state.fiber ? as2(interrupt3(self.state.fiber), self.state) : succeed6(self.state); + } + case "Empty": { + const scope = makeUnsafe3(); + return self.semaphore.withPermit(suspend2(() => { + if (self.state._tag !== "Empty") { + return loop(restore); + } + return restore(provideContext2(self.acquire, add(self.context, Scope, scope))).pipe(flatMap3((value) => { + if (self.state._tag === "Closed") { + return interrupt2; + } + const state = { + _tag: "Acquired", + value, + scope, + fiber: undefined, + refCount: 1, + invalidated: false + }; + self.state = state; + return succeed6(state); + }), onExit2((exit) => isFailure3(exit) ? close(scope, exit) : void_3)); + })); + } + } +}); +var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { + const self = self_; + const state = yield* getState(self); + const scope = yield* scope2; + const isFinite2 = self.idleTimeToLive !== undefined && isFinite(self.idleTimeToLive); + yield* addFinalizerExit(scope, () => { + state.refCount--; + if (state.refCount > 0) { return void_3; - const isReported = getErrorReported(squash(cause)); - return isReported ? logError(cause) : void_3; - })); - try { - const keepAlive = globalThis.setInterval(constVoid, 2147483647); - fiber.addObserver(() => { - clearInterval(keepAlive); - }); - } catch {} - const teardown = options?.teardown ?? defaultTeardown; - return f({ - fiber, - teardown + } + if (self.idleTimeToLive === undefined || state.invalidated) { + if (self.state === state) { + self.state = stateEmpty; + } + return close(state.scope, void_2); + } else if (!isFinite2) { + return void_3; + } + state.fiber = sleep2(self.idleTimeToLive).pipe(flatMap3(() => { + if (self.state === state && state.refCount === 0) { + self.state = stateEmpty; + return close(state.scope, void_2); + } + return void_3; + }), ensuring2(sync3(() => { + state.fiber = undefined; + })), runForkWith2(self.context), runIn(self.scope)); + return void_3; }); + return state.value; }); -var errorExitCode = "~effect/Runtime/errorExitCode"; -var getErrorExitCode = (u) => { - if (typeof u === "object" && u !== null && errorExitCode in u) { - const code = u[errorExitCode]; - if (typeof code === "number") { - return code; + +// node_modules/effect/dist/RcRef.js +var make13 = make12; +var get3 = get2; + +// node_modules/effect/dist/Stream.js +var TypeId19 = "~effect/Stream"; +var isStream = (u) => hasProperty(u, TypeId19); +var fromChannel3 = fromChannel; +var fromPull2 = (pull) => fromChannel3(fromPull(pull)); +var transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))); +var toChannel2 = (stream) => stream.channel; +var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); +var empty4 = /* @__PURE__ */ fromChannel3(empty3); +var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); +var unwrap3 = (effect) => fromChannel3(unwrap(map5(effect, toChannel2))); +var map7 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { + let i = 0; + return fromChannel3(map6(self.channel, map((o) => f(o, i++)))); +})); +var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); +var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { + let done; + let leftover; + const upstreamWithLeftover = suspend2(() => { + if (leftover !== undefined) { + const chunk = leftover; + leftover = undefined; + return succeed6(chunk); } + return upstream; + }).pipe(catch_2((error) => { + done = fail5(error); + return done2(); + })); + const pull = map5(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { + leftover = leftover_; + return of(value); + }); + return suspend2(() => done ? done : pull); +}))); +var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { + const decoder = new TextDecoder(options?.encoding); + return map7(self, (chunk) => decoder.decode(chunk, { + stream: true + })); +})); +var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); +var run2 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map5(([a]) => a)))); +var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { + for (let i = 0;i < chunk.length; i++) { + acc.push(chunk[i]); } - return 1; -}; -var errorReported = "~effect/Runtime/errorReported"; -var getErrorReported = (u) => { - if (typeof u === "object" && u !== null && errorReported in u) { - const isReported = u[errorReported]; - if (typeof isReported === "boolean") { - return isReported; - } + return acc; +}); +var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channel, initial, (acc, arr) => { + for (let i = 0;i < arr.length; i++) { + acc = f(acc, arr[i]); } - return true; -}; + return acc; +})); +var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => { + let i = 0; + return whileLoop2({ + while: () => i < arr.length, + body: () => f(arr[i++]), + step: constVoid + }); +})); +var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); -// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js -var runMain = /* @__PURE__ */ makeRunMain(({ - fiber, - teardown -}) => { - let receivedSignal = false; - fiber.addObserver((exit) => { - process.removeListener("SIGINT", onSigint); - process.removeListener("SIGTERM", onSigint); - teardown(exit, (code) => { - if (receivedSignal || code !== 0) { - process.exit(code); - } +// node_modules/effect/dist/FileSystem.js +var TypeId20 = "~effect/FileSystem"; +var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); +var make14 = (impl) => FileSystem.of({ + ...impl, + [TypeId20]: TypeId20, + exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), + readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ + try: () => new TextDecoder(encoding).decode(_), + catch: (cause) => badArgument({ + module: "FileSystem", + method: "readFileString", + description: "invalid encoding", + cause + }) + })), + stream: fnUntraced2(function* (path, options) { + const file = yield* impl.open(path, { + flag: "r" }); - }); - function onSigint() { - receivedSignal = true; - fiber.interruptUnsafe(fiber.id); - } - process.on("SIGINT", onSigint); - process.on("SIGTERM", onSigint); + const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset); + if (offset) { + yield* file.seek(offset, "start"); + } + const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead); + let totalBytesRead = BigInt(0); + const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024)); + const readChunk = file.readAlloc(chunkSize); + return fromPull2(succeed6(flatMap3(suspend2(() => { + if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { + return done2(); + } + return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; + }), match({ + onNone: () => done2(), + onSome: (buf) => { + totalBytesRead += BigInt(buf.length); + return succeed6(of(buf)); + } + })))); + }, unwrap3), + sink: (path, options) => pipe(impl.open(path, { + ...options, + flag: options?.flag ?? "w" + }), map5((file) => forEach3((_) => file.writeAll(_))), unwrap2), + writeFileString: (path, data, options) => flatMap3(try_2({ + try: () => new TextEncoder().encode(data), + catch: (cause) => badArgument({ + module: "FileSystem", + method: "writeFileString", + description: "could not encode string", + cause + }) + }), (_) => impl.writeFile(path, _, options)) }); +var FileTypeId = "~effect/FileSystem/File"; +class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBackend")) { +} -// node_modules/@effect/platform-node/dist/NodeRuntime.js -var runMain2 = runMain; // node_modules/effect/dist/Path.js -var TypeId22 = "~effect/Path"; -var Path2 = /* @__PURE__ */ Service("effect/Path"); +var TypeId21 = "~effect/Path"; +var Path = /* @__PURE__ */ Service("effect/Path"); function normalizeStringPosix(path, allowAboveRoot) { let res = ""; let lastSegmentLength = 0; @@ -8470,7 +8512,7 @@ function fromFileUrl(url) { } return succeed6(decodeURIComponent(pathname)); } -var resolve2 = function resolve() { +var resolve3 = function resolve() { let resolvedPath = ""; let resolvedAbsolute = false; let cwd = undefined; @@ -8507,7 +8549,7 @@ var resolve2 = function resolve() { var CHAR_FORWARD_SLASH = 47; function toFileUrl(filepath) { const outURL = new URL("file://"); - let resolved = resolve2(filepath); + let resolved = resolve3(filepath); const filePathLast = filepath.charCodeAt(filepath.length - 1); if (filePathLast === CHAR_FORWARD_SLASH && resolved[resolved.length - 1] !== "/") { resolved += "/"; @@ -8539,9 +8581,9 @@ function encodePathChars(filepath) { } return filepath; } -var posixImpl = /* @__PURE__ */ Path2.of({ - [TypeId22]: TypeId22, - resolve: resolve2, +var posixImpl = /* @__PURE__ */ Path.of({ + [TypeId21]: TypeId21, + resolve: resolve3, normalize(path) { if (path.length === 0) return "."; @@ -8832,29 +8874,266 @@ var posixImpl = /* @__PURE__ */ Path2.of({ ret.name = path.slice(startPart, startDot); ret.base = path.slice(startPart, end); } - ret.ext = path.slice(startDot, end); - } - if (startPart > 0) - ret.dir = path.slice(0, startPart - 1); - else if (isAbsolute) - ret.dir = "/"; - return ret; + ret.ext = path.slice(startDot, end); + } + if (startPart > 0) + ret.dir = path.slice(0, startPart - 1); + else if (isAbsolute) + ret.dir = "/"; + return ret; + }, + sep: "/", + fromFileUrl, + toFileUrl, + toNamespacedPath: identity +}); +// node_modules/effect/dist/internal/ulid.js +var maxTimestamp = 2 ** 48 - 1; +var base32Chars = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; +var ulidString = (timestampMillis, bytes) => { + if (bytes.length !== 10) { + throw new Error(`ULID randomness must be exactly 10 bytes, received ${bytes.length}`); + } + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxTimestamp); + let out = ""; + for (let shift = 45;shift >= 0; shift -= 5) { + out += base32Chars[Math.floor(timestamp / 2 ** shift) & 31]; + } + let accumulator = 0; + let bits = 0; + for (const byte of bytes) { + accumulator = accumulator << 8 | byte; + bits += 8; + while (bits >= 5) { + bits -= 5; + out += base32Chars[accumulator >>> bits & 31]; + } + accumulator &= (1 << bits) - 1; + } + return out; +}; + +// node_modules/effect/dist/internal/uuid.js +var hex = (byte) => byte.toString(16).padStart(2, "0"); +var stringify = (bytes) => { + const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; + return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); +}; +var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); +function v4Bytes(bytes = randomBytes()) { + bytes[6] = bytes[6] & 15 | 64; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); +var maxV7Timestamp = 2 ** 48 - 1; +function v7Bytes(timestampMillis, bytes = randomBytes()) { + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); + bytes[0] = Math.floor(timestamp / 2 ** 40); + bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; + bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; + bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; + bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; + bytes[5] = timestamp & 255; + bytes[6] = bytes[6] & 15 | 112; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); + +// node_modules/effect/dist/Crypto.js +var TypeId22 = "~effect/Crypto"; +var Crypto = /* @__PURE__ */ Service("effect/Crypto"); +var make15 = (impl) => { + const randomBytesUnsafe = impl.randomBytes; + const randomBytes = (size) => map5(validateSize("randomBytes", size), randomBytesUnsafe); + const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; + const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; + const nextIntUnsafe = () => { + while (true) { + const bytes = randomBytesUnsafe(7); + const value = readUint53(bytes); + if ((bytes[0] & 32) === 0) { + return value + Number.MIN_SAFE_INTEGER; + } + if (value < Number.MAX_SAFE_INTEGER) { + return value + 1; + } + } + }; + return Crypto.of({ + [TypeId22]: TypeId22, + randomBytes, + nextDoubleUnsafe, + nextIntUnsafe, + digest: impl.digest, + random: sync3(() => nextDoubleUnsafe()), + randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), + randomInt: sync3(() => nextIntUnsafe()), + randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), + randomIntBetween(min, max, options) { + const extra = options?.halfOpen === true ? 0 : 1; + return sync3(() => { + const minInt = Math.ceil(min); + const maxInt = Math.floor(max); + return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; + }); + }, + randomShuffle: (elements) => sync3(() => { + const buffer = Array.from(elements); + for (let i = buffer.length - 1;i >= 1; i = i - 1) { + const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); + const value = buffer[i]; + buffer[i] = buffer[index]; + buffer[index] = value; + } + return buffer; + }), + randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), + randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))), + randomULID: clockWith2((clock) => succeed6(ulidString(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(10)))) + }); +}; +var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ + module: "Crypto", + method, + description: "size must be a non-negative safe integer" +})); +// node_modules/effect/dist/Ref.js +var TypeId23 = "~effect/Ref"; +var RefProto = { + [TypeId23]: { + _A: identity }, - sep: "/", - fromFileUrl, - toFileUrl, - toNamespacedPath: identity + ...PipeInspectableProto, + toJSON() { + return { + _id: "Ref", + ref: this.ref + }; + } +}; +var makeUnsafe6 = (value) => { + const self = Object.create(RefProto); + self.ref = make6(value); + return self; +}; +var make16 = (value) => sync3(() => makeUnsafe6(value)); +var get4 = (self) => sync3(() => self.ref.current); +var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { + self.ref.current = f(self.ref.current); +})); +// node_modules/effect/dist/Runtime.js +var defaultTeardown = (exit, onExit) => { + if (isSuccess3(exit)) + return onExit(0); + if (hasInterruptsOnly2(exit.cause)) + return onExit(130); + return onExit(getErrorExitCode(squash(exit.cause))); +}; +var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { + const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { + if (hasInterruptsOnly2(cause)) + return void_3; + const isReported = getErrorReported(squash(cause)); + return isReported ? logError(cause) : void_3; + })); + try { + const keepAlive = globalThis.setInterval(constVoid, 2147483647); + fiber.addObserver(() => { + clearInterval(keepAlive); + }); + } catch {} + const teardown = options?.teardown ?? defaultTeardown; + return f({ + fiber, + teardown + }); +}); +var errorExitCode = "~effect/Runtime/errorExitCode"; +var getErrorExitCode = (u) => { + if (typeof u === "object" && u !== null && errorExitCode in u) { + const code = u[errorExitCode]; + if (typeof code === "number") { + return code; + } + } + return 1; +}; +var errorReported = "~effect/Runtime/errorReported"; +var getErrorReported = (u) => { + if (typeof u === "object" && u !== null && errorReported in u) { + const isReported = u[errorReported]; + if (typeof isReported === "boolean") { + return isReported; + } + } + return true; +}; +// node_modules/effect/dist/Stdio.js +var TypeId24 = "~effect/Stdio"; +var Stdio = /* @__PURE__ */ Service(TypeId24); +var make17 = (options) => ({ + [TypeId24]: TypeId24, + stdinIsTerminal: succeed6(false), + stdoutIsTerminal: succeed6(false), + ...options }); +// node_modules/effect/dist/Terminal.js +var TypeId25 = "~effect/Terminal"; +var QuitErrorTypeId = "~effect/Terminal/QuitError"; -// node_modules/effect/dist/Brand.js -function nominal() { - return Object.assign((input) => input, { - option: (input) => some2(input), - result: (input) => succeed2(input), - is: (_) => true - }); +class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ + _tag: /* @__PURE__ */ tag("QuitError") +})) { + [QuitErrorTypeId] = QuitErrorTypeId; } +var Terminal = /* @__PURE__ */ Service("effect/Terminal"); +var make18 = (impl) => Terminal.of({ + ...impl, + [TypeId25]: TypeId25 +}); +// src/action/ActionInputs.ts +var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; +var readRawInput = (name) => { + const value = process.env[inputEnvName(name)]; + return value === undefined || value === "" ? undefined : value; +}; +var readInputs = (names) => { + const inputs = {}; + for (const name of names) { + const value = readRawInput(name); + if (value !== undefined) + inputs[name] = value; + } + return inputs; +}; +var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); +// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js +var runMain = /* @__PURE__ */ makeRunMain(({ + fiber, + teardown +}) => { + let receivedSignal = false; + fiber.addObserver((exit) => { + process.removeListener("SIGINT", onSigint); + process.removeListener("SIGTERM", onSigint); + teardown(exit, (code) => { + if (receivedSignal || code !== 0) { + process.exit(code); + } + }); + }); + function onSigint() { + receivedSignal = true; + fiber.interruptUnsafe(fiber.id); + } + process.on("SIGINT", onSigint); + process.on("SIGTERM", onSigint); +}); +// node_modules/@effect/platform-node/dist/NodeRuntime.js +var runMain2 = runMain; // node_modules/effect/dist/unstable/process/ChildProcessSpawner.js var ExitCode = /* @__PURE__ */ nominal(); var ProcessId = /* @__PURE__ */ nominal(); @@ -8872,8 +9151,8 @@ var HandleProto = { var makeHandle = (params) => Object.setPrototypeOf({ ...params }, HandleProto); -var make17 = (spawn) => { - const streamString = (command, options) => spawn(command).pipe(map6((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); +var make19 = (spawn) => { + const streamString = (command, options) => spawn(command).pipe(map5((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); const streamLines = (command, options) => splitLines2(streamString(command, options)); return ChildProcessSpawner.of({ spawn, @@ -8889,7 +9168,7 @@ class ChildProcessSpawner extends (/* @__PURE__ */ Service()("effect/process/Chi } // node_modules/effect/dist/unstable/process/ChildProcess.js -var TypeId23 = "~effect/process/ChildProcess"; +var TypeId26 = "~effect/process/ChildProcess"; var Proto2 = { .../* @__PURE__ */ Prototype2({ label: "Command", @@ -8897,7 +9176,7 @@ var Proto2 = { return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this); } }), - [TypeId23]: TypeId23 + [TypeId26]: TypeId26 }; var makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto2), { _tag: "StandardCommand", @@ -8905,7 +9184,7 @@ var makeStandardCommand = (command, args, options) => Object.assign(Object.creat args, options }); -var make18 = function make(...args) { +var make20 = function make(...args) { if (isTemplateString(args[0])) { const [templates, ...expressions] = args; const tokens = parseTemplates(templates, expressions); @@ -9111,10 +9390,10 @@ var pullIntoWritable = (options) => options.pull.pipe(flatMap3((chunk) => { disableYield: true }), options.endOnDone !== false ? catchDone((_) => { if ("closed" in options.writable && options.writable.closed) { - return done3(_); + return done2(_); } return callback2((resume) => { - const onFinish = () => resume(done3(_)); + const onFinish = () => resume(done2(_)); options.writable.once("finish", onFinish); options.writable.end(); return sync3(() => { @@ -9147,11 +9426,11 @@ var readableToPullUnsafe = (options) => { latch.openUnsafe(); } function onError(error) { - exit.current = fail4(options.onError(error)); + exit.current = fail5(options.onError(error)); latch.openUnsafe(); } function onEnd() { - exit.current = fail4(Done2()); + exit.current = fail5(Done2()); latch.openUnsafe(); } readable.on("readable", onReadable); @@ -9220,9 +9499,9 @@ var isProcessAlive = (childProcess, exitSignal) => { var taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { windowsHide: true }, onExit); -var make19 = /* @__PURE__ */ gen2(function* () { +var make21 = /* @__PURE__ */ gen2(function* () { const fs = yield* FileSystem; - const path = yield* Path2; + const path = yield* Path; const resolveWorkingDirectory = fnUntraced2(function* (options) { if (isUndefined(options.cwd)) return; @@ -9343,7 +9622,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { }); } if (config.stream) { - yield* forkScoped2(run(config.stream, sink)); + yield* forkScoped2(run2(config.stream, sink)); } inputSinks.set(fd, sink); break; @@ -9383,7 +9662,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { }); } if (isStream(config.stream)) { - return as2(forkScoped2(run(config.stream, sink)), sink); + return as2(forkScoped2(run2(config.stream, sink)), sink); } return succeed6(sink); }); @@ -9539,7 +9818,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { env, stdio }, process.platform)), fnUntraced2(function* ([childProcess, exitSignal]) { - const exited = yield* isDone2(exitSignal); + const exited = yield* isDone3(exitSignal); if (exited) { const [code] = yield* _await(exitSignal); if (code !== 0 && isNotNull(code)) { @@ -9581,7 +9860,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds); - const isRunning = map6(isDone2(exitSignal), (done) => !done); + const isRunning = map5(isDone3(exitSignal), (done) => !done); const exitCode = flatMap3(_await(exitSignal), ([code, signal]) => { if (isNotNull(code)) { return succeed6(ExitCode(code)); @@ -9618,7 +9897,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { const sourceStream = unwrap3(succeed6(getSourceStream(handles[handles.length - 1], options.from))); const toOption = options.to ?? "stdin"; if (toOption === "stdin") { - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -9630,7 +9909,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { if (isNotUndefined(fd)) { const fdName2 = fdName(fd); const existingFds = command.options.additionalFds ?? {}; - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, additionalFds: { ...existingFds, @@ -9641,7 +9920,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { } }))); } else { - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -9680,9 +9959,9 @@ var make19 = /* @__PURE__ */ gen2(function* () { } } }); - return make17(spawnCommand); + return make19(spawnCommand); }); -var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make19); +var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make21); var flattenCommand = (command) => { const commands = []; const pipeOptions = []; @@ -9712,92 +9991,6 @@ var flattenCommand = (command) => { }; }; -// node_modules/effect/dist/internal/uuid.js -var hex = (byte) => byte.toString(16).padStart(2, "0"); -var stringify = (bytes) => { - const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; - return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); -}; -var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); -function v4Bytes(bytes = randomBytes()) { - bytes[6] = bytes[6] & 15 | 64; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); -var maxV7Timestamp = 2 ** 48 - 1; -function v7Bytes(timestampMillis, bytes = randomBytes()) { - const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); - bytes[0] = Math.floor(timestamp / 2 ** 40); - bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; - bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; - bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; - bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; - bytes[5] = timestamp & 255; - bytes[6] = bytes[6] & 15 | 112; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); - -// node_modules/effect/dist/Crypto.js -var TypeId24 = "~effect/Crypto"; -var Crypto2 = /* @__PURE__ */ Service("effect/Crypto"); -var make20 = (impl) => { - const randomBytesUnsafe = impl.randomBytes; - const randomBytes = (size) => map6(validateSize("randomBytes", size), randomBytesUnsafe); - const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; - const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; - const nextIntUnsafe = () => { - while (true) { - const bytes = randomBytesUnsafe(7); - const value = readUint53(bytes); - if ((bytes[0] & 32) === 0) { - return value + Number.MIN_SAFE_INTEGER; - } - if (value < Number.MAX_SAFE_INTEGER) { - return value + 1; - } - } - }; - return Crypto2.of({ - [TypeId24]: TypeId24, - randomBytes, - nextDoubleUnsafe, - nextIntUnsafe, - digest: impl.digest, - random: sync3(() => nextDoubleUnsafe()), - randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), - randomInt: sync3(() => nextIntUnsafe()), - randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), - randomIntBetween(min, max, options) { - const extra = options?.halfOpen === true ? 0 : 1; - return sync3(() => { - const minInt = Math.ceil(min); - const maxInt = Math.floor(max); - return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; - }); - }, - randomShuffle: (elements) => sync3(() => { - const buffer = Array.from(elements); - for (let i = buffer.length - 1;i >= 1; i = i - 1) { - const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); - const value = buffer[i]; - buffer[i] = buffer[index]; - buffer[index] = value; - } - return buffer; - }), - randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), - randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))) - }); -}; -var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ - module: "Crypto", - method, - description: "size must be a non-negative safe integer" -})); - // node_modules/@effect/platform-node-shared/dist/NodeCrypto.js import * as NodeCrypto from "node:crypto"; var toHashAlgorithm = (algorithm) => { @@ -9822,20 +10015,20 @@ var digest = (algorithm, data) => try_2({ cause }) }); -var make21 = /* @__PURE__ */ make20({ +var make22 = /* @__PURE__ */ make15({ randomBytes: NodeCrypto.randomBytes, digest }); -var layer2 = /* @__PURE__ */ succeed5(Crypto2, make21); +var layer2 = /* @__PURE__ */ succeed5(Crypto, make22); // node_modules/@effect/platform-node/dist/NodeCrypto.js var layer3 = layer2; // node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js -import * as Crypto3 from "node:crypto"; +import * as Crypto2 from "node:crypto"; import * as NFS from "node:fs"; import * as OS from "node:os"; -import * as Path3 from "node:path"; +import * as Path2 from "node:path"; var handleBadArgument = (method) => (err) => badArgument({ module: "FileSystem", method, @@ -9908,8 +10101,8 @@ var makeTempDirectoryFactory = (method) => { const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException("FileSystem", method), handleBadArgument(method)); return (options) => suspend2(() => { const prefix = options?.prefix ?? ""; - const directory = typeof options?.directory === "string" ? Path3.join(options.directory, ".") : OS.tmpdir(); - return nodeMkdtemp(prefix ? Path3.join(directory, prefix) : directory + "/"); + const directory = typeof options?.directory === "string" ? Path2.join(options.directory, ".") : OS.tmpdir(); + return nodeMkdtemp(prefix ? Path2.join(directory, prefix) : directory + "/"); }); }; var makeTempDirectory = /* @__PURE__ */ makeTempDirectoryFactory("makeTempDirectory"); @@ -9931,7 +10124,7 @@ var makeTempDirectoryScoped = /* @__PURE__ */ (() => { var openFactory = (method) => { const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method)); const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method)); - return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map6((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); + return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map5((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); }; var open2 = /* @__PURE__ */ openFactory("open"); var makeFile = /* @__PURE__ */ (() => { @@ -9980,7 +10173,7 @@ var makeFile = /* @__PURE__ */ (() => { read(buffer) { return suspend2(() => { const position = this.position; - return map6(nodeRead(this.fd, { + return map5(nodeRead(this.fd, { buffer, position }), (bytesRead) => { @@ -9997,7 +10190,7 @@ var makeFile = /* @__PURE__ */ (() => { } const buffer = Buffer.allocUnsafeSlow(size); const position = this.position; - return map6(nodeReadAlloc(this.fd, { + return map5(nodeReadAlloc(this.fd, { buffer, position }), (bytesRead) => { @@ -10018,7 +10211,7 @@ var makeFile = /* @__PURE__ */ (() => { }); } truncate(length) { - return map6(nodeTruncate(this.fd, length || undefined), () => { + return map5(nodeTruncate(this.fd, length || undefined), () => { if (!this.append) { const len = BigInt(length ?? 0); if (this.position > len) { @@ -10030,7 +10223,7 @@ var makeFile = /* @__PURE__ */ (() => { write(buffer) { return suspend2(() => { const position = this.position; - return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map6(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { + return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map5(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { if (!this.append) { this.position = position + BigInt(bytesWritten); } @@ -10068,8 +10261,8 @@ var makeTempFileFactory = (method) => { const makeDirectory = makeTempDirectoryFactory(method); return fnUntraced2(function* (options) { const directory = yield* makeDirectory(options); - const random = Crypto3.randomBytes(6).toString("hex"); - const name = Path3.join(directory, options?.suffix ? `${random}${options.suffix}` : random); + const random = Crypto2.randomBytes(6).toString("hex"); + const name = Path2.join(directory, options?.suffix ? `${random}${options.suffix}` : random); yield* writeFile2(name, new Uint8Array(0)); return name; }); @@ -10078,7 +10271,7 @@ var makeTempFile = /* @__PURE__ */ makeTempFileFactory("makeTempFile"); var makeTempFileScoped = /* @__PURE__ */ (() => { const makeFile = /* @__PURE__ */ makeTempFileFactory("makeTempFileScoped"); const removeDirectory = /* @__PURE__ */ removeFactory("makeTempFileScoped"); - return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path3.dirname(file), { + return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path2.dirname(file), { recursive: true }))); })(); @@ -10151,7 +10344,7 @@ var utimes2 = /* @__PURE__ */ (() => { return (path, atime, mtime) => nodeUtimes(path, atime, mtime); })(); var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sync3(() => { - const directory = info.type === "Directory" ? path : Path3.dirname(path); + const directory = info.type === "Directory" ? path : Path2.dirname(path); const watcher = NFS.watch(path, { recursive: options?.recursive ?? false }, (event, path) => { @@ -10159,7 +10352,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy return; switch (event) { case "rename": { - runFork2(matchEffect3(stat2(Path3.resolve(directory, path)), { + runFork2(matchEffect3(stat2(Path2.resolve(directory, path)), { onSuccess: (_) => offer(queue, { _tag: "Create", path @@ -10181,7 +10374,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy } }); watcher.on("error", (error) => { - failCauseUnsafe(queue, fail5(systemError({ + failCauseUnsafe(queue, fail4(systemError({ module: "FileSystem", _tag: "Unknown", method: "watch", @@ -10194,7 +10387,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy }); return watcher; }), (watcher) => sync3(() => watcher.close()))); -var watch2 = (backend, path, options) => stat2(path).pipe(map6((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); +var watch2 = (backend, path, options) => stat2(path).pipe(map5((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); var writeFile2 = (path, data, options) => callback2((resume, signal) => { try { NFS.writeFile(path, data, { @@ -10212,7 +10405,7 @@ var writeFile2 = (path, data, options) => callback2((resume, signal) => { resume(fail6(handleBadArgument("writeFile")(err))); } }); -var makeFileSystem = /* @__PURE__ */ map6(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make11({ +var makeFileSystem = /* @__PURE__ */ map5(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make14({ access: access2, chmod: chmod2, chown: chown2, @@ -10271,18 +10464,18 @@ var fileUrlOps = (windows) => ({ }) }) }); -var layerPosix = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layerPosix = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.posix, .../* @__PURE__ */ fileUrlOps(false) }); -var layerWin32 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layerWin32 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.win32, .../* @__PURE__ */ fileUrlOps(true) }); -var layer6 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layer6 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath, .../* @__PURE__ */ fileUrlOps(undefined) }); @@ -10290,18 +10483,8 @@ var layer6 = /* @__PURE__ */ succeed5(Path2)({ // node_modules/@effect/platform-node/dist/NodePath.js var layer7 = layer6; -// node_modules/effect/dist/Stdio.js -var TypeId25 = "~effect/Stdio"; -var Stdio2 = /* @__PURE__ */ Service(TypeId25); -var make22 = (options) => ({ - [TypeId25]: TypeId25, - stdinIsTerminal: succeed6(false), - stdoutIsTerminal: succeed6(false), - ...options -}); - // node_modules/@effect/platform-node-shared/dist/NodeStdio.js -var layer8 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make22({ +var layer8 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make17({ args: /* @__PURE__ */ sync3(() => process.argv.slice(2)), stdinIsTerminal: /* @__PURE__ */ sync3(() => process.stdin.isTTY === true), stdoutIsTerminal: /* @__PURE__ */ sync3(() => process.stdout.isTTY === true), @@ -10340,24 +10523,9 @@ var layer8 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make22({ // node_modules/@effect/platform-node/dist/NodeStdio.js var layer9 = layer8; -// node_modules/effect/dist/Terminal.js -var TypeId26 = "~effect/Terminal"; -var QuitErrorTypeId = "~effect/Terminal/QuitError"; - -class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ - _tag: /* @__PURE__ */ tag("QuitError") -})) { - [QuitErrorTypeId] = QuitErrorTypeId; -} -var Terminal2 = /* @__PURE__ */ Service("effect/Terminal"); -var make23 = (impl) => Terminal2.of({ - ...impl, - [TypeId26]: TypeId26 -}); - // node_modules/@effect/platform-node-shared/dist/NodeTerminal.js import * as readline from "node:readline"; -var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { +var make23 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { const stdin = process.stdin; const stdout = process.stdout; const lines = yield* make8(); @@ -10371,7 +10539,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu }; stdin.once("end", onStdinEnd); yield* addFinalizer3(() => sync3(() => stdin.off("end", onStdinEnd))); - const rlRef = yield* make10({ + const rlRef = yield* make13({ acquire: acquireRelease2(sync3(() => { const rl = readline.createInterface({ input: stdin, @@ -10462,7 +10630,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu cause: err })))); })); - return make23({ + return make18({ columns, rows, readInput, @@ -10470,7 +10638,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu display }); }); -var layer10 = /* @__PURE__ */ effect(Terminal2, /* @__PURE__ */ make24(defaultShouldQuit)); +var layer10 = /* @__PURE__ */ effect(Terminal, /* @__PURE__ */ make23(defaultShouldQuit)); function defaultShouldQuit(input) { return input.key.ctrl && (input.key.name === "c" || input.key.name === "d"); } @@ -10525,7 +10693,7 @@ var layer13 = sync2(Service2, () => { class TestService extends Service()("@timmo001/workflows/Annotations/Test") { } var testLayer = effectContext(gen2(function* () { - const recorded = yield* make12([]); + const recorded = yield* make16([]); const write = (line) => update(recorded, (lines) => [...lines, line]); const service = TestService.of({ error: fn2("Annotations.Test.error")(function* (message, properties) { @@ -10547,7 +10715,7 @@ var testLayer = effectContext(gen2(function* () { return yield* get4(recorded); }) }); - return empty().pipe(add(Service2, service), add(TestService, service)); + return empty2().pipe(add(Service2, service), add(TestService, service)); })); class ActionFailure extends TaggedError3()("ActionFailure", { @@ -10570,7 +10738,7 @@ class Service3 extends Service()("@timmo001/workflows/CommandExecutor") { } var layer14 = effect(Service3, gen2(function* () { const spawner = yield* ChildProcessSpawner; - const make = (command, args, options) => make18(command, args, { + const make = (command, args, options) => make20(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true @@ -10609,7 +10777,7 @@ var layer14 = effect(Service3, gen2(function* () { const stream = fn2("CommandExecutor.stream")(function* (command, args, options) { const label = options?.label ?? `${command} ${args.join(" ")}`.trim(); return yield* scoped2(gen2(function* () { - const handle = yield* spawner.spawn(make18(command, args, { + const handle = yield* spawner.spawn(make20(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true, @@ -10671,11 +10839,11 @@ var ValidationResult = taggedEnum(); var parseSkillRoots = (value) => value.trim() === "" ? [] : value.trim().split(/\s+/); var isDirectory = fn2("ValidateAgentSkills.isDirectory")(function* (path) { const fs = yield* FileSystem; - return yield* fs.stat(path).pipe(map6((info) => info.type === "Directory"), catch_2(() => succeed6(false))); + return yield* fs.stat(path).pipe(map5((info) => info.type === "Directory"), catch_2(() => succeed6(false))); }); var isFile = fn2("ValidateAgentSkills.isFile")(function* (path) { const fs = yield* FileSystem; - return yield* fs.stat(path).pipe(map6((info) => info.type === "File"), catch_2(() => succeed6(false))); + return yield* fs.stat(path).pipe(map5((info) => info.type === "File"), catch_2(() => succeed6(false))); }); var discoverSkillDirectories = fn2("ValidateAgentSkills.discoverSkillDirectories")(function* (roots) { const fs = yield* FileSystem; diff --git a/.github/actions/validate-js-package/dist/index.js b/.github/actions/validate-js-package/dist/index.js index 483d7dea..ceb9ebfc 100644 --- a/.github/actions/validate-js-package/dist/index.js +++ b/.github/actions/validate-js-package/dist/index.js @@ -487,6 +487,33 @@ function makeCompareSet(equivalence) { var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth); var isEqual = (u) => hasProperty(u, symbol2); +// node_modules/effect/dist/internal/array.js +var isArrayNonEmpty = (self) => self.length > 0; + +// node_modules/effect/dist/internal/count.js +var normalize = (n) => n > 0 ? Math.floor(n) : 0; + +// node_modules/effect/dist/internal/record.js +function assignProperty(self, key, value) { + if (key === "__proto__") { + Object.defineProperty(self, key, { + value, + writable: true, + enumerable: true, + configurable: true + }); + } else { + self[key] = value; + } +} +function assignProperties(self, source) { + for (const key of Reflect.ownKeys(source)) { + if (Object.prototype.propertyIsEnumerable.call(source, key)) { + assignProperty(self, key, source[key]); + } + } +} + // node_modules/effect/dist/Redactable.js var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Redactable"); var isRedactable = (u) => hasProperty(u, symbolRedactable); @@ -729,27 +756,6 @@ var pickInternalCall = () => { }; var internalCall = /* @__PURE__ */ pickInternalCall(); -// node_modules/effect/dist/internal/record.js -function assignProperty(self, key, value) { - if (key === "__proto__") { - Object.defineProperty(self, key, { - value, - writable: true, - enumerable: true, - configurable: true - }); - } else { - self[key] = value; - } -} -function assignProperties(self, source) { - for (const key of Reflect.ownKeys(source)) { - if (Object.prototype.propertyIsEnumerable.call(source, key)) { - assignProperty(self, key, source[key]); - } - } -} - // node_modules/effect/dist/internal/core.js var EffectTypeId = `~effect/Effect`; var ExitTypeId = `~effect/Exit`; @@ -1118,12 +1124,6 @@ var done = (value) => { return exitFail(Done(value)); }; -// node_modules/effect/dist/Effectable.js -var Prototype2 = (options) => makePrimitiveProto({ - op: options.label, - [evaluate]: options.evaluate -}); - // node_modules/effect/dist/internal/option.js var TypeId = "~effect/Option"; var CommonProto = { @@ -1285,9 +1285,40 @@ var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone var fromNullishOr = (a) => a == null ? none2() : some2(a); var fromUndefinedOr = (a) => a === undefined ? none2() : some2(a); var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined); -var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value))); var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value)); -var filter = /* @__PURE__ */ dual(2, (self, predicate) => isNone2(self) ? none2() : predicate(self.value) ? some2(self.value) : none2()); + +// node_modules/effect/dist/Result.js +var succeed2 = succeed; +var fail2 = fail; +var isFailure2 = isFailure; +var match2 = /* @__PURE__ */ dual(2, (self, { + onFailure, + onSuccess +}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); + +// node_modules/effect/dist/Array.js +var Array2 = globalThis.Array; +var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); +var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); +var isArray = Array2.isArray; +var isArrayNonEmpty2 = isArrayNonEmpty; +var isReadonlyArrayNonEmpty = isArrayNonEmpty; +var empty = () => []; +var of = (a) => [a]; +var map = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); +// node_modules/effect/dist/BigInt.js +var BigInt2 = globalThis.BigInt; +var toNumber = (b) => { + if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { + return none2(); + } + return some2(Number(b)); +}; +// node_modules/effect/dist/Effectable.js +var Prototype2 = (options) => makePrimitiveProto({ + op: options.label, + [evaluate]: options.evaluate +}); // node_modules/effect/dist/Context.js var ServiceTypeId = "~effect/Context/Service"; @@ -1428,7 +1459,7 @@ var Proto = { var hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot; var isContext = (u) => hasProperty(u, TypeId3); var isReference = (u) => !!u[ReferenceTypeId]; -var empty = () => emptyContext2; +var empty2 = () => emptyContext2; var emptyContext2 = /* @__PURE__ */ makeUnsafe(/* @__PURE__ */ new Map); var make2 = (key, service) => makeUnsafe(new Map([[key.key, service]])); var add = /* @__PURE__ */ dual(3, (self, key, service) => addUnsafe(self, key.key, service)); @@ -1502,6 +1533,7 @@ var mergeAll = (...ctxs) => { return makeUnsafe(map); }; var Reference = Service; + // node_modules/effect/dist/Duration.js var TypeId4 = "~effect/Duration"; var bigint0 = /* @__PURE__ */ BigInt(0); @@ -1725,7 +1757,7 @@ var minutes = (minutes) => make3(minutes * 60000); var hours = (hours) => make3(hours * 3600000); var days = (days) => make3(days * 86400000); var weeks = (weeks) => make3(weeks * 604800000); -var toMillis = (self) => match2(fromInputUnsafe(self), { +var toMillis = (self) => match3(fromInputUnsafe(self), { onMillis: identity, onNanos: (nanos) => Number(nanos) / 1e6, onInfinity: () => Infinity, @@ -1743,7 +1775,7 @@ var toNanosUnsafe = (input) => { return roundMillisToNanos(self.value.millis); } }; -var match2 = /* @__PURE__ */ dual(2, (self, options) => { +var match3 = /* @__PURE__ */ dual(2, (self, options) => { switch (self.value._tag) { case "Millis": return options.onMillis(self.value.millis); @@ -1771,32 +1803,6 @@ var Equivalence = (self, that) => matchPair(self, that, { }); var equals2 = /* @__PURE__ */ dual(2, (self, that) => Equivalence(self, that)); -// node_modules/effect/dist/internal/array.js -var isArrayNonEmpty = (self) => self.length > 0; - -// node_modules/effect/dist/internal/count.js -var normalize = (n) => n > 0 ? Math.floor(n) : 0; - -// node_modules/effect/dist/Result.js -var succeed2 = succeed; -var fail2 = fail; -var isFailure2 = isFailure; -var match3 = /* @__PURE__ */ dual(2, (self, { - onFailure, - onSuccess -}) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success)); - -// node_modules/effect/dist/Array.js -var Array2 = globalThis.Array; -var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection); -var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]); -var isArray = Array2.isArray; -var isArrayNonEmpty2 = isArrayNonEmpty; -var isReadonlyArrayNonEmpty = isArrayNonEmpty; -var empty2 = () => []; -var of = (a) => [a]; -var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); - // node_modules/effect/dist/Scheduler.js var Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", { fiberCached: true, @@ -2543,7 +2549,7 @@ class FiberImpl { } this._stack.length = 0; this._children = undefined; - this.context = empty(); + this.context = empty2(); } runLoop(effect) { const prevFiber = globalThis[currentFiberTypeId]; @@ -2715,7 +2721,7 @@ var fiberInterruptAs = /* @__PURE__ */ dual((args) => hasProperty(args[0], Fiber })); var fiberInterruptAll = (fibers) => withFiber((parent) => { const annotations = fiberStackAnnotations(parent); - let fiberArr = empty2(); + let fiberArr = empty(); for (const fiber of fibers) { fiber.interruptUnsafe(parent.id, annotations); fiberArr.push(fiber); @@ -2739,7 +2745,7 @@ var suspend = /* @__PURE__ */ makePrimitive({ return this[args](); } }); -var fromResult = /* @__PURE__ */ match3({ +var fromResult = /* @__PURE__ */ match2({ onFailure: fail3, onSuccess: succeed3 }); @@ -3032,7 +3038,7 @@ var tapCont = function(value) { var tapEffectCont = function(value) { return new ContImpl(this.payload, returnPayload, exitSucceed(value)); }; -var asSome = (self) => map4(self, some2); +var asSome = (self) => map3(self, some2); var andThen = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? returnPayload : andThenCont, f)); var tap = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? tapEffectCont : tapCont, f)); var asVoid = (self) => new ContImpl(self, returnPayload, exitVoid); @@ -3074,8 +3080,8 @@ var flatMapEager = /* @__PURE__ */ dual(2, (self, f) => { } return flatMap2(self, f); }); -var map4 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); -var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map4(self, f)); +var map3 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); +var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map3(self, f)); var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError(self, f)); var exitInterrupt = (fiberId) => exitFailCause(causeInterrupt(fiberId)); var exitIsSuccess = (self) => self._tag === "Success"; @@ -3450,7 +3456,7 @@ var all = (arg, options) => { } return suspend(() => { const out = {}; - return as(forEach(Object.entries(arg), ([key, effect]) => map4(options?.mode === "result" ? result(effect) : effect, (value) => { + return as(forEach(Object.entries(arg), ([key, effect]) => map3(options?.mode === "result" ? result(effect) : effect, (value) => { assignProperty(out, key, value); }), { discard: true, @@ -3726,7 +3732,7 @@ var fiberRunIn = /* @__PURE__ */ dual(2, (self, scope) => { self.addObserver(() => scopeRemoveFinalizerUnsafe(scope, key)); return self; }); -var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty()); +var runFork = /* @__PURE__ */ runForkWith(/* @__PURE__ */ empty2()); var runSyncExitWith = (context) => { const runFork = runForkWith(context); return (effect) => { @@ -3740,7 +3746,7 @@ var runSyncExitWith = (context) => { return fiber._exit ?? exitDie(new AsyncFiberError(fiber)); }; }; -var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty()); +var runSyncExit = /* @__PURE__ */ runSyncExitWith(/* @__PURE__ */ empty2()); var succeedTrue = /* @__PURE__ */ succeed3(true); var succeedFalse = /* @__PURE__ */ succeed3(false); @@ -3861,7 +3867,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = noopSpan({ name, parent, - annotations: add(options?.annotations ?? empty(), DisablePropagation, true) + annotations: add(options?.annotations ?? empty2(), DisablePropagation, true) }); } else { const tracer = fiber.getRef(Tracer); @@ -3874,7 +3880,7 @@ var makeSpanUnsafe = (fiber, name, options) => { span = tracer.span({ name, parent, - annotations: options?.annotations ?? empty(), + annotations: options?.annotations ?? empty2(), links, startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : bigint02, kind: options?.kind ?? "internal", @@ -4160,10 +4166,23 @@ var tracerLogger = /* @__PURE__ */ loggerMake(({ span.event(toStringUnknown(Array.isArray(message) && message.length === 1 ? message[0] : message), clock.currentTimeNanosUnsafe(), attributes); }); +// node_modules/effect/dist/Cause.js +var isFailReason2 = isFailReason; +var fromReasons = causeFromReasons; +var fail4 = causeFail; +var die2 = causeDie; +var hasInterruptsOnly2 = hasInterruptsOnly; +var map4 = causeMap; +var squash = causeSquash; +var isDone2 = isDone; +var Done2 = Done; +var done2 = done; +var UnknownError2 = UnknownError; + // node_modules/effect/dist/Exit.js var succeed4 = exitSucceed; var failCause2 = exitFailCause; -var fail4 = exitFail; +var fail5 = exitFail; var void_2 = exitVoid; var isSuccess3 = exitIsSuccess; var isFailure3 = exitIsFailure; @@ -4200,8 +4219,8 @@ var _await = (self) => callback((resume) => { }); }); var completeWith = /* @__PURE__ */ dual(2, (self, effect) => sync(() => doneUnsafe(self, effect))); -var done2 = completeWith; -var isDone2 = (self) => sync(() => isDoneUnsafe(self)); +var done3 = completeWith; +var isDone3 = (self) => sync(() => isDoneUnsafe(self)); var isDoneUnsafe = (self) => self.effect !== undefined; var doneUnsafe = (self, effect) => { if (self.effect) @@ -4274,7 +4293,7 @@ var memoMapBuild = (memoMap, layer, scope, build) => { memoMap.map.set(layer, entry); return scopeAddFinalizerExit(scope, entry.finalizer).pipe(flatMap2(() => build(memoMap, layerScope)), onExit((exit) => { entry.effect = exit; - return done2(deferred, exit); + return done3(deferred, exit); })); }; @@ -4312,7 +4331,7 @@ class CurrentMemoMap extends (/* @__PURE__ */ Service()("effect/Layer/CurrentMem return current ? forkMemoMapUnsafe(current) : makeMemoMapUnsafe(); } } -var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map4(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); +var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map3(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); var buildWithScope = /* @__PURE__ */ dual(2, (self, scope) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope))); var succeed5 = function() { if (arguments.length === 1) { @@ -4334,31 +4353,19 @@ var effect = function() { } return effectImpl(arguments[0], arguments[1]); }; -var effectImpl = (service, effect) => effectContext(map4(effect, (value) => make2(service, value))); +var effectImpl = (service, effect) => effectContext(map3(effect, (value) => make2(service, value))); var effectContext = (effect) => fromBuildMemo((_, scope) => provide(effect, scope)); var mergeAllEffect = (layers, memoMap, scope) => { const parentScope = forkUnsafe2(scope, "parallel"); return forEach(layers, (layer) => layer.build(memoMap, forkUnsafe2(parentScope, "sequential")), { concurrency: layers.length - }).pipe(map4((context) => mergeAll(...context))); + }).pipe(map3((context) => mergeAll(...context))); }; var mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope)); -var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map4((merged) => f(merged, context))))); +var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map3((merged) => f(merged, context))))); var provide2 = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, identity)); var provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self))); -// node_modules/effect/dist/Cause.js -var isFailReason2 = isFailReason; -var fromReasons = causeFromReasons; -var fail5 = causeFail; -var hasInterruptsOnly2 = hasInterruptsOnly; -var map5 = causeMap; -var squash = causeSquash; -var isDone3 = isDone; -var Done2 = Done; -var done3 = done; -var UnknownError2 = UnknownError; - // node_modules/effect/dist/internal/random.js var nextBetween = (min, max, draw) => { const value = draw * (max - min) + min; @@ -4378,7 +4385,7 @@ var nextBetween = (min, max, draw) => { // node_modules/effect/dist/Pull.js var catchDone = /* @__PURE__ */ dual(2, (effect, f) => catchCauseFilter(effect, filterDoneLeftover, (l) => f(l))); var isDoneCause = (cause) => cause.reasons.some(isDoneFailure); -var isDoneFailure = (failure) => failure._tag === "Fail" && isDone3(failure.error); +var isDoneFailure = (failure) => failure._tag === "Fail" && isDone2(failure.error); var filterDone = (cause) => { let done; let hasFailure = false; @@ -4420,7 +4427,6 @@ var forEach2 = forEach; var whileLoop2 = whileLoop; var tryPromise2 = tryPromise; var succeed6 = succeed3; -var succeedNone2 = succeedNone; var suspend2 = suspend; var sync3 = sync; var void_3 = void_; @@ -4429,7 +4435,7 @@ var gen2 = gen; var fail6 = fail3; var failCause3 = failCause; var failCauseSync2 = failCauseSync; -var die2 = die; +var die3 = die; var try_2 = try_; var withFiber2 = withFiber; var fromResult2 = fromResult; @@ -4437,7 +4443,7 @@ var flatMap3 = flatMap2; var andThen2 = andThen; var tap2 = tap; var exit2 = exit; -var map6 = map4; +var map5 = map3; var as2 = as; var catch_2 = catch_; var catchTag2 = catchTag; @@ -4483,1442 +4489,287 @@ var effectify = (fn, onError, onSyncError) => (...args) => callback2((resume) => } }); } catch (err) { - resume(onSyncError ? fail6(onSyncError(err, args)) : die2(err)); + resume(onSyncError ? fail6(onSyncError(err, args)) : die3(err)); } }); var mapEager2 = mapEager; var mapErrorEager2 = mapErrorEager; var flatMapEager2 = flatMapEager; var fnUntracedEager2 = fnUntracedEager; -// node_modules/effect/dist/BigInt.js -var BigInt2 = globalThis.BigInt; -var toNumber = (b) => { - if (b > BigInt2(Number.MAX_SAFE_INTEGER) || b < BigInt2(Number.MIN_SAFE_INTEGER)) { - return none2(); - } - return some2(Number(b)); -}; -// node_modules/effect/dist/ByteSize.js -var bigint03 = /* @__PURE__ */ BigInt(0); -var bigint12 = /* @__PURE__ */ BigInt(1); -var decimalBase = /* @__PURE__ */ BigInt(1000); -var binaryBase = /* @__PURE__ */ BigInt(1024); -var decimalUnits = [{ - symbol: "B", - factor: bigint12, - names: ["B", "byte", "bytes"] -}, { - symbol: "kB", - factor: decimalBase, - names: ["kB", "kilobyte", "kilobytes"] -}, { - symbol: "MB", - factor: decimalBase ** /* @__PURE__ */ BigInt(2), - names: ["MB", "megabyte", "megabytes"] -}, { - symbol: "GB", - factor: decimalBase ** /* @__PURE__ */ BigInt(3), - names: ["GB", "gigabyte", "gigabytes"] -}, { - symbol: "TB", - factor: decimalBase ** /* @__PURE__ */ BigInt(4), - names: ["TB", "terabyte", "terabytes"] -}, { - symbol: "PB", - factor: decimalBase ** /* @__PURE__ */ BigInt(5), - names: ["PB", "petabyte", "petabytes"] -}, { - symbol: "EB", - factor: decimalBase ** /* @__PURE__ */ BigInt(6), - names: ["EB", "exabyte", "exabytes"] -}, { - symbol: "ZB", - factor: decimalBase ** /* @__PURE__ */ BigInt(7), - names: ["ZB", "zettabyte", "zettabytes"] -}, { - symbol: "YB", - factor: decimalBase ** /* @__PURE__ */ BigInt(8), - names: ["YB", "yottabyte", "yottabytes"] -}, { - symbol: "RB", - factor: decimalBase ** /* @__PURE__ */ BigInt(9), - names: ["RB", "ronnabyte", "ronnabytes"] -}, { - symbol: "QB", - factor: decimalBase ** /* @__PURE__ */ BigInt(10), - names: ["QB", "quettabyte", "quettabytes"] -}]; -var binaryUnits = [decimalUnits[0], { - symbol: "KiB", - factor: binaryBase, - names: ["KiB", "kibibyte", "kibibytes"] -}, { - symbol: "MiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(2), - names: ["MiB", "mebibyte", "mebibytes"] -}, { - symbol: "GiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(3), - names: ["GiB", "gibibyte", "gibibytes"] -}, { - symbol: "TiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(4), - names: ["TiB", "tebibyte", "tebibytes"] -}, { - symbol: "PiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(5), - names: ["PiB", "pebibyte", "pebibytes"] -}, { - symbol: "EiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(6), - names: ["EiB", "exbibyte", "exbibytes"] -}, { - symbol: "ZiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(7), - names: ["ZiB", "zebibyte", "zebibytes"] -}, { - symbol: "YiB", - factor: binaryBase ** /* @__PURE__ */ BigInt(8), - names: ["YiB", "yobibyte", "yobibytes"] -}]; -var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; -var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); -var make5 = (value) => value; -var invalid2 = (message) => { - throw new Error(`Invalid ByteSize: ${message}`); -}; -var fromNumber = (input) => { - if (!Number.isSafeInteger(input) || input < 0) { - return invalid2(`expected a non-negative safe integer, received ${input}`); +// node_modules/effect/dist/internal/schema/annotations.js +function resolve(ast) { + return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; +} +var STRUCTURAL_ANNOTATION_KEY = "~structural"; +var SENTINELS_ANNOTATION_KEY = "~sentinels"; +var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; +var getExpected = /* @__PURE__ */ memoize((ast) => { + const identifier = resolve(ast)?.identifier; + if (typeof identifier === "string") + return identifier; + return ast.getExpected(getExpected); +}); + +// node_modules/effect/dist/internal/schema/parser.js +var missing = /* @__PURE__ */ Symbol(); +var succeed7 = succeed4; +var missingExit = /* @__PURE__ */ succeed7(missing); +var sameExit = /* @__PURE__ */ succeed7(missing); +var toOption = (value) => value === missing ? none2() : some2(value); +var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed7(option.value); + +// node_modules/effect/dist/SchemaIssue.js +var TypeId7 = "~effect/SchemaIssue/Issue"; +function isIssue(u) { + return hasProperty(u, TypeId7) && u[TypeId7] === TypeId7; +} +function hasInput(issue) { + return Object.hasOwn(issue, "input"); +} + +class IssueNodeImpl { + [TypeId7] = TypeId7; + constructor(input, options) { + if (options?.reportInput === true && input !== missing) { + this.input = input; + } } - return make5(BigInt(input)); -}; -var parse = (input) => { - const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); - if (match === null) - return invalid2(`unsupported syntax ${JSON.stringify(input)}`); - const unit = unitsByName.get(match[3]); - if (unit === undefined) - return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); - const fraction = match[2] ?? ""; - const scale = BigInt(10) ** BigInt(fraction.length); - const numerator = BigInt(match[1] + fraction) * unit.factor; - if (numerator % scale !== bigint03) { - return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); +} +var Filter = class extends IssueNodeImpl { + _tag = "Filter"; + filter; + issue; + constructor(filter, issue, input, options) { + super(input, options); + this.filter = filter; + this.issue = issue; } - return make5(numerator / scale); }; -var fromInputUnsafe2 = (input) => { - switch (typeof input) { - case "bigint": - if (input < bigint03) - return invalid2(`expected a non-negative bigint, received ${input}`); - return make5(input); - case "number": - return fromNumber(input); - case "string": - return parse(input); +var Encoding = class extends IssueNodeImpl { + _tag = "Encoding"; + ast; + issue; + constructor(ast, issue, input, options) { + super(input, options); + this.ast = ast; + this.issue = issue; } - return invalid2(`unsupported input ${input}`); }; -var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); - -// node_modules/effect/dist/PlatformError.js -var TypeId7 = "~effect/PlatformError"; - -class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { - get message() { - return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; +var Pointer = class extends IssueNodeImpl { + _tag = "Pointer"; + path; + issue; + constructor(path, issue) { + super(); + this.path = path; + this.issue = issue; } -} - -class SystemError extends Error3 { - get message() { - return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; +}; +var MissingKey = class extends IssueNodeImpl { + _tag = "MissingKey"; + annotations; + constructor(annotations) { + super(); + this.annotations = annotations; } -} - -class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { - constructor(reason) { - if ("cause" in reason) { - super({ - reason, - cause: reason.cause - }); - } else { - super({ - reason - }); - } +}; +var UnexpectedKey = class extends IssueNodeImpl { + _tag = "UnexpectedKey"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; } - [TypeId7] = TypeId7; - get message() { - return this.reason.message; +}; +var Composite = class extends IssueNodeImpl { + _tag = "Composite"; + ast; + issues; + constructor(ast, issues, input, options) { + super(input, options); + this.ast = ast; + this.issues = issues; } -} -var systemError = (options) => new PlatformError(new SystemError(options)); -var badArgument = (options) => new PlatformError(new BadArgument(options)); - -// node_modules/effect/dist/Fiber.js -var interrupt3 = fiberInterrupt; -var runIn = fiberRunIn; - -// node_modules/effect/dist/Latch.js -var makeUnsafe4 = makeLatchUnsafe; - -// node_modules/effect/dist/MutableRef.js -var TypeId8 = "~effect/MutableRef"; -var MutableRefProto = { - [TypeId8]: TypeId8, - ...PipeInspectableProto, - toJSON() { - return { - _id: "MutableRef", - current: toJson(this.current) - }; +}; +var InvalidType = class extends IssueNodeImpl { + _tag = "InvalidType"; + ast; + constructor(ast, input, options) { + super(input, options); + this.ast = ast; } }; -var make6 = (value) => { - const ref = Object.create(MutableRefProto); - ref.current = value; - return ref; +var InvalidValue = class extends IssueNodeImpl { + _tag = "InvalidValue"; + annotations; + constructor(annotations, input, options) { + super(input, options); + this.annotations = annotations; + } }; - -// node_modules/effect/dist/MutableList.js -var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); -var make7 = () => ({ - head: undefined, - tail: undefined, - length: 0 -}); -var emptyBucket = () => ({ - array: [], - mutable: true, - offset: 0, - next: undefined -}); -var append2 = (self, message) => { - if (!self.tail) { - self.head = self.tail = emptyBucket(); - } else if (!self.tail.mutable) { - self.tail.next = emptyBucket(); - self.tail = self.tail.next; +var AnyOf = class extends IssueNodeImpl { + _tag = "AnyOf"; + ast; + issues; + constructor(ast, issues, input, options) { + super(input, options); + this.ast = ast; + this.issues = issues; } - self.tail.array.push(message); - self.length++; }; -var clear = (self) => { - self.head = self.tail = undefined; - self.length = 0; +var OneOf = class extends IssueNodeImpl { + _tag = "OneOf"; + ast; + successes; + constructor(ast, successes, input, options) { + super(input, options); + this.ast = ast; + this.successes = successes; + } }; -var takeN = (self, n) => { - n = normalize(n); - if (n <= 0 || !self.head) - return []; - n = Math.min(n, self.length); - if (n === self.length && self.head?.offset === 0 && !self.head.next) { - const array = self.head.array; - clear(self); - return array; +function makeFilterIssue(entry, input, options) { + if (isIssue(entry)) { + return entry; } - const array = new Array(n); - let index = 0; - let chunk = self.head; - while (chunk) { - while (chunk.offset < chunk.array.length) { - array[index++] = chunk.array[chunk.offset]; - if (chunk.mutable) - chunk.array[chunk.offset] = undefined; - chunk.offset++; - if (index === n) { - self.head = chunk; - self.length -= n; - if (self.length === 0) - clear(self); - return array; - } - } - chunk = chunk.next; + if (typeof entry === "string") { + return new InvalidValue({ + message: entry + }, input, options); } - clear(self); - return array; -}; -var take = (self) => { - if (!self.head) - return Empty; - const message = self.head.array[self.head.offset]; - if (self.head.mutable) - self.head.array[self.head.offset] = undefined; - self.head.offset++; - self.length--; - if (self.head.offset === self.head.array.length) { - if (self.head.next) { - self.head = self.head.next; - } else { - clear(self); + const inner = typeof entry.issue === "string" ? new InvalidValue({ + message: entry.issue + }, input, options) : entry.issue; + return new Pointer(entry.path, inner); +} +function makeSingle(out, input, options) { + if (out === undefined) { + return; + } + if (typeof out === "boolean") { + return out ? undefined : new InvalidValue(undefined, input, options); + } + return makeFilterIssue(out, input, options); +} +function normalizeFilterOutput(ast, out, input, options) { + if (Array.isArray(out)) { + if (!isReadonlyArrayNonEmpty(out)) { + return; } + return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map(out, (entry) => makeFilterIssue(entry, input, options)), input, options); } - return message; -}; - -// node_modules/effect/dist/Queue.js -var TypeId9 = "~effect/Queue"; -var EnqueueTypeId = "~effect/Queue/Enqueue"; -var DequeueTypeId = "~effect/Queue/Dequeue"; -var variance = { - _A: identity, - _E: identity -}; -var QueueProto = { - [TypeId9]: variance, - [EnqueueTypeId]: variance, - [DequeueTypeId]: variance, - ...PipeInspectableProto, - toJSON() { - return { - _id: "effect/Queue", - state: this.state._tag, - size: sizeUnsafe(this) - }; - } -}; -var make8 = (options) => withFiber((fiber) => { - const self = Object.create(QueueProto); - self.dispatcher = fiber.currentDispatcher; - self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; - self.strategy = options?.strategy ?? "suspend"; - self.messages = make7(); - self.scheduleRunning = false; - self.state = { - _tag: "Open", - takers: new Set, - offers: new Set, - awaiters: new Set - }; - return succeed3(self); -}); -var bounded = (capacity) => make8({ - capacity -}); -var offer = (self, message) => suspend(() => { - if (self.state._tag !== "Open") { - return exitFalse; - } else if (self.messages.length >= self.capacity) { - switch (self.strategy) { - case "dropping": - return exitFalse; - case "suspend": - if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return exitTrue; - } - return offerRemainingSingle(self, message); - case "sliding": - take(self.messages); - append2(self.messages, message); - return exitTrue; + return makeSingle(out, input, options); +} +var defaultLeafHook = (issue) => { + const message = findMessage(issue); + if (message !== undefined) + return message; + switch (issue._tag) { + case "InvalidType": + return getExpectedMessage(getExpected(issue.ast), issue); + case "InvalidValue": { + const expected = findExpected(issue); + if (expected !== undefined) + return getExpectedMessage(expected, issue); + const input = formatInput(issue); + return input === undefined ? "Expected a valid value" : `Invalid data ${input}`; } - } - append2(self.messages, message); - scheduleReleaseTaker(self); - return exitTrue; -}); -var offerUnsafe = (self, message) => { - if (self.state._tag !== "Open") { - return false; - } else if (self.messages.length >= self.capacity) { - if (self.strategy === "sliding") { - take(self.messages); - append2(self.messages, message); - return true; - } else if (self.capacity <= 0 && self.state.takers.size > 0) { - append2(self.messages, message); - releaseTakers(self); - return true; + case "MissingKey": + return "Missing key"; + case "UnexpectedKey": { + const input = formatInput(issue); + return input === undefined ? "Expected no excess property" : `Unexpected key with value ${input}`; + } + case "Forbidden": + return "Forbidden operation"; + case "OneOf": { + const input = formatInput(issue); + return input === undefined ? "Expected exactly one member to match" : `Expected exactly one member to match the input ${input}`; } - return false; - } - append2(self.messages, message); - scheduleReleaseTaker(self); - return true; -}; -var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); -var failCauseUnsafe = (self, cause) => { - if (self.state._tag !== "Open") { - return false; - } - const exit = exitFailCause(cause); - const fail = exitZipRight(exit, exitFailDone); - if (self.state.offers.size === 0 && self.messages.length === 0) { - finalize(self, fail); - return true; } - self.state = { - ...self.state, - _tag: "Closing", - exit: fail - }; - return true; }; -var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); -var shutdown = (self) => sync(() => { - if (self.state._tag === "Done") { - return true; +var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue); +function formatInput(issue) { + return hasInput(issue) ? format(issue.input) : undefined; +} +function findExpected(issue) { + const expected = issue.annotations?.expected; + return typeof expected === "string" ? expected : undefined; +} +function getExpectedMessage(expected, issue) { + const input = formatInput(issue); + return input === undefined ? `Expected ${expected}` : `Expected ${expected}, got ${input}`; +} +function formatCheck(check) { + const expected = check.annotations?.expected; + if (typeof expected === "string") + return expected; + switch (check._tag) { + case "Filter": + return ""; + case "FilterGroup": + return check.checks.map((check) => formatCheck(check)).join(" & "); } - clear(self.messages); - const offers = self.state.offers; - finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); - if (offers.size > 0) { - for (const entry of offers) { - if (entry._tag === "Single") { - entry.resume(exitFalse); +} +function makeFormatterDefault() { + return (issue) => formatIssue(issue, ""); +} +var defaultFormatter = /* @__PURE__ */ makeFormatterDefault(); +function formatIssue(issue, path) { + let message; + switch (issue._tag) { + case "Filter": { + const annotated = defaultCheckHook(issue); + if (annotated !== undefined) { + message = annotated; } else { - entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); + if (issue.issue._tag !== "InvalidValue") { + return formatIssue(issue.issue, path); + } + const expected = findExpected(issue.issue); + message = expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue); } + break; } - offers.clear(); - } - return true; -}); -var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); -var takeBetween = (self, min, max) => { - min = normalize(min); - max = normalize(max); - return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); -}; -var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); -var poll = (self) => suspend(() => { - const result = takeUnsafe(self); - if (result === undefined) { - return succeed3(none2()); - } - if (result._tag === "Success") { - return succeed3(some2(result.value)); - } - return succeed3(none2()); -}); -var takeUnsafe = (self) => { - if (self.state._tag === "Done") { - return self.state.exit; - } - if (self.messages.length > 0) { - const message = take(self.messages); - releaseCapacity(self); - return exitSucceed(message); - } else if (self.capacity <= 0 && self.state.offers.size > 0) { - const message = takeOfferUnsafe(self.state.offers); - releaseCapacity(self); - return exitSucceed(message); - } - return; -}; -var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; -var exitFalse = /* @__PURE__ */ exitSucceed(false); -var exitTrue = /* @__PURE__ */ exitSucceed(true); -var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); -var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); -var releaseTakers = (self) => { - if (self.state._tag === "Done" || self.state.takers.size === 0) { - return; - } - for (const taker of self.state.takers) { - self.state.takers.delete(taker); - taker(exitVoid); - if (self.messages.length === 0) { + case "Encoding": + return formatIssue(issue.issue, path); + case "Pointer": + return formatIssue(issue.issue, path + formatPath(issue.path)); + case "Composite": + case "AnyOf": { + if (issue._tag === "Composite" || issue.issues.length > 0) { + return issue.issues.map((issue) => formatIssue(issue, path)).join(` +`); + } + message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue); break; } + default: + message = defaultLeafHook(issue); + break; } -}; -var scheduleReleaseTaker = (self) => { - if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { + return path ? `${message} + at ${path}` : message; +} +function findMessage(issue) { + if (issue._tag === "Pointer") return; - } - self.scheduleRunning = true; - self.dispatcher.scheduleTask(() => { - self.scheduleRunning = false; - releaseTakers(self); - }, 0); -}; -var takeBetweenUnsafe = (self, min, max) => { - if (self.state._tag === "Done") { - return self.state.exit; - } else if (max <= 0 || min <= 0) { - return exitSucceed([]); - } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { - const messages = [takeOfferUnsafe(self.state.offers)]; - releaseCapacity(self); - return exitSucceed(messages); - } - min = Math.min(min, self.capacity || 1); - if (min <= self.messages.length) { - const messages = takeN(self.messages, max); - releaseCapacity(self); - return exitSucceed(messages); - } -}; -var offerRemainingSingle = (self, message) => { - return callback((resume) => { - if (self.state._tag !== "Open") { - return resume(exitFalse); - } - const entry = { - _tag: "Single", - message, - resume - }; - self.state.offers.add(entry); - return sync(() => { - if (self.state._tag === "Open") { - self.state.offers.delete(entry); - } - }); - }); -}; -var takeOfferUnsafe = (offers) => { - const entry = offers.values().next().value; - if (entry._tag === "Single") { - offers.delete(entry); - entry.resume(exitTrue); - return entry.message; - } - const message = entry.remaining[entry.offset++]; - if (entry.offset === entry.remaining.length) { - offers.delete(entry); - entry.resume(exitSucceed([])); - } - return message; -}; -var releaseCapacity = (self) => { - if (self.state._tag === "Done") { - return isDoneCause(self.state.exit.cause); - } else if (self.state.offers.size === 0) { - if (self.state._tag === "Closing" && self.messages.length === 0) { - finalize(self, self.state.exit); - return isDoneCause(self.state.exit.cause); - } - return false; - } - for (const entry of self.state.offers) { - let n = self.capacity - self.messages.length; - if (n <= 0) - break; - else if (entry._tag === "Single") { - append2(self.messages, entry.message); - self.state.offers.delete(entry); - entry.resume(exitTrue); - } else { - for (;entry.offset < entry.remaining.length; entry.offset++) { - if (n === 0) - return false; - append2(self.messages, entry.remaining[entry.offset]); - n--; - } - self.state.offers.delete(entry); - entry.resume(exitSucceed([])); - } - } - return false; -}; -var awaitTake = (self) => callback((resume) => { - if (self.state._tag === "Done") { - return resume(self.state.exit); - } - self.state.takers.add(resume); - return sync(() => { - if (self.state._tag !== "Done") { - self.state.takers.delete(resume); - } - }); -}); -var finalize = (self, exit) => { - if (self.state._tag === "Done") { - return; - } - const openState = self.state; - self.state = { - _tag: "Done", - exit - }; - for (const taker of openState.takers) { - taker(exit); - } - openState.takers.clear(); - for (const awaiter of openState.awaiters) { - awaiter(exit); - } - openState.awaiters.clear(); -}; - -// node_modules/effect/dist/Semaphore.js -var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); -var waitForPermits = (self, n, effect) => callback((resume) => { - if (self.free >= n) - return resume(effect); - const observer = () => { - if (self.free < n) - return; - self.waiters.delete(observer); - resume(effect); - }; - self.waiters.add(observer); - return sync(() => { - self.waiters.delete(observer); - }); -}); - -class SemaphoreImpl { - waiters = /* @__PURE__ */ new Set; - taken = 0; - permits; - constructor(permits) { - this.permits = permits; - } - get free() { - return this.permits - this.taken; - } - take(n) { - const take = suspend(() => { - if (this.free < n) { - return waitForPermits(this, n, take); - } - this.taken += n; - return succeed3(n); - }); - return take; - } - takeIfAvailable(n) { - return suspend(() => { - if (this.free < n) - return succeed3(false); - this.taken += n; - return succeed3(true); - }); - } - releaseUnsafe(fiber, n) { - this.taken -= n; - if (this.waiters.size > 0) { - fiber.currentDispatcher.scheduleTask(() => { - for (const observer of this.waiters) { - if (this.free <= 0) - break; - observer(); - } - }, 0); - } - return this.free; - } - resize(permits) { - return withFiber((fiber) => { - this.permits = permits; - if (this.free < 0) - return void_; - this.releaseUnsafe(fiber, 0); - return void_; - }); - } - release(n) { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); - } - get releaseAll() { - return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); - } - withPermits(n) { - return (self) => uninterruptibleMask((restore) => { - const acquire = suspend(() => { - if (this.free < n) { - const wait = waitForPermits(this, n, void_); - return flatMap2(restore(wait), () => acquire); - } - this.taken += n; - return onExitPrimitive(restore(self), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); - return acquire; - }); - } - withPermit = /* @__PURE__ */ this.withPermits(1); - withPermitsIfAvailable(n) { - return (self) => uninterruptibleMask((restore) => { - if (this.free < n) - return succeedNone; - this.taken += n; - return onExitPrimitive(restore(asSome(self)), () => { - this.releaseUnsafe(getCurrentFiber(), n); - return; - }, true); - }); - } -} - -// node_modules/effect/dist/Channel.js -var TypeId10 = "~effect/Channel"; -var isChannel = (u) => hasProperty(u, TypeId10); -var ChannelProto = { - [TypeId10]: { - _Env: identity, - _InErr: identity, - _InElem: identity, - _OutErr: identity, - _OutElem: identity - }, - pipe() { - return pipeArguments(this, arguments); - } -}; -var fromTransform = (transform) => { - const self = Object.create(ChannelProto); - self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); - return self; -}; -var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); -var fromPull = (effect) => fromTransform((_, __) => effect); -var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { - const closableScope = forkUnsafe2(scope); - const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); - const pull = yield* onError2(f(upstream, scope, closableScope), onCause); - return onError2(pull, onCause); -})); -var toTransform = (channel) => channel.transform; -var asyncQueue = (scope, f, options) => make8({ - capacity: options?.bufferSize, - strategy: options?.strategy -}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); -var callbackArray = (f, options) => fromTransform((_, scope) => map6(asyncQueue(scope, f, options), takeAll2)); -var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); -var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done3())); -var map7 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { - let i = 0; - return map6(pull, (o) => f(o, i++)); -}))); -var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); -var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done3))))); -var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { - const strategy = options?.haltStrategy ?? "both"; - const queue = yield* bounded(0); - yield* addFinalizer2(forkedScope, shutdown(queue)); - let done = 0; - function onExit(side, cause) { - done++; - if (!isDoneCause(cause)) { - return failCause4(queue, cause); - } - switch (strategy) { - case "both": { - return done === 2 ? failCause4(queue, cause) : void_3; - } - case "left": - case "right": { - return side === strategy ? failCause4(queue, cause) : void_3; - } - case "either": { - return failCause4(queue, cause); - } - } - } - const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); - yield* runSide("left", left, forkUnsafe2(forkedScope)); - yield* runSide("right", right, forkUnsafe2(forkedScope)); - return take2(queue); -}))); -var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { - let stringBuilder = ""; - let midCRLF = false; - let done = none2(); - function splitLinesArray(chunk) { - const chunkBuilder = []; - function pushLine(segment) { - if (stringBuilder.length === 0) { - chunkBuilder.push(segment); - } else { - chunkBuilder.push(stringBuilder + segment); - stringBuilder = ""; - } - } - for (let i = 0;i < chunk.length; i++) { - const str = chunk[i]; - if (str.length !== 0) { - let from = 0; - let indexOfCR = str.indexOf("\r"); - let indexOfLF = str.indexOf(` -`); - if (midCRLF) { - if (indexOfLF === 0) { - from = 1; - indexOfLF = str.indexOf(` -`, from); - } - midCRLF = false; - } - while (indexOfCR !== -1 || indexOfLF !== -1) { - if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { - pushLine(str.substring(from, indexOfLF)); - from = indexOfLF + 1; - indexOfLF = str.indexOf(` -`, from); - } else { - pushLine(str.substring(from, indexOfCR)); - if (str.length === indexOfCR + 1) { - midCRLF = true; - from = str.length; - indexOfCR = -1; - } else { - from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); - indexOfCR = str.indexOf("\r", from); - indexOfLF = str.indexOf(` -`, from); - } - } - } - stringBuilder = stringBuilder + str.substring(from); - } - } - return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; - } - const pullOrFlush = suspend2(() => { - if (done._tag === "Some") { - return done3(done.value); - } - return matchEffect2(upstream, { - onSuccess: loop, - onFailure: failCause3, - onDone: (leftover) => { - done = some2(leftover); - if (stringBuilder.length > 0) { - const last = stringBuilder; - stringBuilder = ""; - midCRLF = false; - return succeed6([last]); - } - return done3(leftover); - } - }); - }); - function loop(chunk) { - const lines = splitLinesArray(chunk); - return lines !== null ? succeed6(lines) : pullOrFlush; - } - return pullOrFlush; -})); -var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); -var unwrap = (channel) => fromTransform((upstream, scope) => { - let pull; - return succeed6(suspend2(() => { - if (pull) - return pull; - return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); - })); -}); -var runWith = (self, f, onHalt) => suspend2(() => { - const scope = makeUnsafe3(); - const makePull = toTransform(self)(done3(), scope); - return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); -}); -var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { - disableYield: true -}))); -var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { - let state = initial(); - return runWith(self, (pull) => whileLoop2({ - while: constTrue, - body: () => pull, - step: (value) => { - state = f(state, value); - } - }), () => succeed6(state)); -})); -var toPullScoped = (self, scope) => toTransform(self)(done3(), scope); - -// node_modules/effect/dist/internal/stream.js -var TypeId11 = "~effect/Stream"; -var streamVariance = { - _R: identity, - _E: identity, - _A: identity -}; -var Stream = function(channel) { - this.channel = channel; -}; -Stream.prototype = { - [TypeId11]: streamVariance, - pipe() { - return pipeArguments(this, arguments); - } -}; -var fromChannel = (channel) => new Stream(channel); - -// node_modules/effect/dist/Sink.js -var TypeId12 = "~effect/Sink"; -var endVoid = /* @__PURE__ */ succeed6([undefined]); -var sinkVariance = { - _A: identity, - _In: identity, - _L: identity, - _E: identity, - _R: identity -}; -var SinkProto = { - [TypeId12]: sinkVariance, - pipe() { - return pipeArguments(this, arguments); - } -}; -var isSink = (u) => hasProperty(u, TypeId12); -var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ - disableYield: true -})), catchDone(succeed6))); -var fromTransform2 = (transform) => { - const self = Object.create(SinkProto); - self.transform = transform; - return self; -}; -var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done3))); -var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { - disableYield: true -}), () => endVoid)); -var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { - discard: true -})); -var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ - disableYield: true -}), catchDone(() => endVoid))); -var unwrap2 = (effect) => fromChannel2(unwrap(map6(effect, toChannel))); - -// node_modules/effect/dist/internal/rcRef.js -var TypeId13 = "~effect/RcRef"; -var stateEmpty = { - _tag: "Empty" -}; -var stateClosed = { - _tag: "Closed" -}; -var variance2 = { - _A: identity, - _E: identity -}; - -class RcRefImpl { - [TypeId13] = variance2; - pipe() { - return pipeArguments(this, arguments); - } - state = stateEmpty; - semaphore = /* @__PURE__ */ makeUnsafe5(1); - acquire; - context; - scope; - idleTimeToLive; - constructor(acquire, context, scope, idleTimeToLive) { - this.acquire = acquire; - this.context = context; - this.scope = scope; - this.idleTimeToLive = idleTimeToLive; - } -} -var make9 = (options) => withFiber2((fiber) => { - const context = fiber.context; - const scope = get(context, Scope); - const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive ? fromInputUnsafe(options.idleTimeToLive) : undefined); - return as2(addFinalizerExit(scope, () => { - const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; - ref.state = stateClosed; - return close2; - }), ref); -}); -var getState = (self) => uninterruptibleMask2(function loop(restore) { - switch (self.state._tag) { - case "Closed": { - return interrupt2; - } - case "Acquired": { - self.state.refCount++; - return self.state.fiber ? as2(interrupt3(self.state.fiber), self.state) : succeed6(self.state); - } - case "Empty": { - const scope = makeUnsafe3(); - return self.semaphore.withPermit(suspend2(() => { - if (self.state._tag !== "Empty") { - return loop(restore); - } - return restore(provideContext2(self.acquire, add(self.context, Scope, scope))).pipe(flatMap3((value) => { - if (self.state._tag === "Closed") { - return interrupt2; - } - const state = { - _tag: "Acquired", - value, - scope, - fiber: undefined, - refCount: 1, - invalidated: false - }; - self.state = state; - return succeed6(state); - }), onExit2((exit) => isFailure3(exit) ? close(scope, exit) : void_3)); - })); - } - } -}); -var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { - const self = self_; - const state = yield* getState(self); - const scope = yield* scope2; - const isFinite2 = self.idleTimeToLive !== undefined && isFinite(self.idleTimeToLive); - yield* addFinalizerExit(scope, () => { - state.refCount--; - if (state.refCount > 0) { - return void_3; - } - if (self.idleTimeToLive === undefined || state.invalidated) { - if (self.state === state) { - self.state = stateEmpty; - } - return close(state.scope, void_2); - } else if (!isFinite2) { - return void_3; - } - state.fiber = sleep2(self.idleTimeToLive).pipe(flatMap3(() => { - if (self.state === state && state.refCount === 0) { - self.state = stateEmpty; - return close(state.scope, void_2); - } - return void_3; - }), ensuring2(sync3(() => { - state.fiber = undefined; - })), runForkWith2(self.context), runIn(self.scope)); - return void_3; - }); - return state.value; -}); - -// node_modules/effect/dist/RcRef.js -var make10 = make9; -var get3 = get2; - -// node_modules/effect/dist/Stream.js -var TypeId14 = "~effect/Stream"; -var isStream = (u) => hasProperty(u, TypeId14); -var fromChannel3 = fromChannel; -var fromPull2 = (pull) => fromChannel3(fromPull(pull)); -var transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))); -var toChannel2 = (stream) => stream.channel; -var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); -var empty4 = /* @__PURE__ */ fromChannel3(empty3); -var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); -var unwrap3 = (effect) => fromChannel3(unwrap(map6(effect, toChannel2))); -var map8 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { - let i = 0; - return fromChannel3(map7(self.channel, map2((o) => f(o, i++)))); -})); -var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); -var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { - let done; - let leftover; - const upstreamWithLeftover = suspend2(() => { - if (leftover !== undefined) { - const chunk = leftover; - leftover = undefined; - return succeed6(chunk); - } - return upstream; - }).pipe(catch_2((error) => { - done = fail4(error); - return done3(); - })); - const pull = map6(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { - leftover = leftover_; - return of(value); - }); - return suspend2(() => done ? done : pull); -}))); -var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { - const decoder = new TextDecoder(options?.encoding); - return map8(self, (chunk) => decoder.decode(chunk, { - stream: true - })); -})); -var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); -var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map6(([a]) => a)))); -var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { - for (let i = 0;i < chunk.length; i++) { - acc.push(chunk[i]); - } - return acc; -}); -var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channel, initial, (acc, arr) => { - for (let i = 0;i < arr.length; i++) { - acc = f(acc, arr[i]); - } - return acc; -})); -var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => { - let i = 0; - return whileLoop2({ - while: () => i < arr.length, - body: () => f(arr[i++]), - step: constVoid - }); -})); -var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); - -// node_modules/effect/dist/FileSystem.js -var TypeId15 = "~effect/FileSystem"; -var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); -var make11 = (impl) => FileSystem.of({ - ...impl, - [TypeId15]: TypeId15, - exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), - readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ - try: () => new TextDecoder(encoding).decode(_), - catch: (cause) => badArgument({ - module: "FileSystem", - method: "readFileString", - description: "invalid encoding", - cause - }) - })), - stream: fnUntraced2(function* (path, options) { - const file = yield* impl.open(path, { - flag: "r" - }); - const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset); - if (offset) { - yield* file.seek(offset, "start"); - } - const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead); - let totalBytesRead = BigInt(0); - const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024)); - const readChunk = file.readAlloc(chunkSize); - return fromPull2(succeed6(flatMap3(suspend2(() => { - if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { - return done3(); - } - return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; - }), match({ - onNone: () => done3(), - onSome: (buf) => { - totalBytesRead += BigInt(buf.length); - return succeed6(of(buf)); - } - })))); - }, unwrap3), - sink: (path, options) => pipe(impl.open(path, { - ...options, - flag: options?.flag ?? "w" - }), map6((file) => forEach3((_) => file.writeAll(_))), unwrap2), - writeFileString: (path, data, options) => flatMap3(try_2({ - try: () => new TextEncoder().encode(data), - catch: (cause) => badArgument({ - module: "FileSystem", - method: "writeFileString", - description: "could not encode string", - cause - }) - }), (_) => impl.writeFile(path, _, options)) -}); -var FileTypeId = "~effect/FileSystem/File"; -class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBackend")) { -} -// node_modules/effect/dist/Ref.js -var TypeId16 = "~effect/Ref"; -var RefProto = { - [TypeId16]: { - _A: identity - }, - ...PipeInspectableProto, - toJSON() { - return { - _id: "Ref", - ref: this.ref - }; - } -}; -var makeUnsafe6 = (value) => { - const self = Object.create(RefProto); - self.ref = make6(value); - return self; -}; -var make12 = (value) => sync3(() => makeUnsafe6(value)); -var get4 = (self) => sync3(() => self.ref.current); -var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { - self.ref.current = f(self.ref.current); -})); -// node_modules/effect/dist/internal/schema/annotations.js -function resolve(ast) { - return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations; -} -var STRUCTURAL_ANNOTATION_KEY = "~structural"; -var SENTINELS_ANNOTATION_KEY = "~sentinels"; -var CONSTRUCTOR_ANNOTATION_KEY = "~constructor"; -var getExpected = /* @__PURE__ */ memoize((ast) => { - const identifier = resolve(ast)?.identifier; - if (typeof identifier === "string") - return identifier; - return ast.getExpected(getExpected); -}); - -// node_modules/effect/dist/internal/schema/parser.js -var missing = /* @__PURE__ */ Symbol(); -var succeed8 = succeed4; -var missingExit = /* @__PURE__ */ succeed8(missing); -var sameExit = /* @__PURE__ */ succeed8(missing); -var toOption = (value) => value === missing ? none2() : some2(value); -var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed8(option.value); - -// node_modules/effect/dist/SchemaIssue.js -var TypeId17 = "~effect/SchemaIssue/Issue"; -function isIssue(u) { - return hasProperty(u, TypeId17) && u[TypeId17] === TypeId17; -} -function hasInput(issue) { - return Object.hasOwn(issue, "input"); -} - -class IssueNodeImpl { - [TypeId17] = TypeId17; - constructor(input, options) { - if (options?.reportInput === true && input !== missing) { - this.input = input; - } - } -} -var Filter = class extends IssueNodeImpl { - _tag = "Filter"; - filter; - issue; - constructor(filter, issue, input, options) { - super(input, options); - this.filter = filter; - this.issue = issue; - } -}; -var Encoding = class extends IssueNodeImpl { - _tag = "Encoding"; - ast; - issue; - constructor(ast, issue, input, options) { - super(input, options); - this.ast = ast; - this.issue = issue; - } -}; -var Pointer = class extends IssueNodeImpl { - _tag = "Pointer"; - path; - issue; - constructor(path, issue) { - super(); - this.path = path; - this.issue = issue; - } -}; -var MissingKey = class extends IssueNodeImpl { - _tag = "MissingKey"; - annotations; - constructor(annotations) { - super(); - this.annotations = annotations; - } -}; -var UnexpectedKey = class extends IssueNodeImpl { - _tag = "UnexpectedKey"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; - } -}; -var Composite = class extends IssueNodeImpl { - _tag = "Composite"; - ast; - issues; - constructor(ast, issues, input, options) { - super(input, options); - this.ast = ast; - this.issues = issues; - } -}; -var InvalidType = class extends IssueNodeImpl { - _tag = "InvalidType"; - ast; - constructor(ast, input, options) { - super(input, options); - this.ast = ast; - } -}; -var InvalidValue = class extends IssueNodeImpl { - _tag = "InvalidValue"; - annotations; - constructor(annotations, input, options) { - super(input, options); - this.annotations = annotations; - } -}; -var AnyOf = class extends IssueNodeImpl { - _tag = "AnyOf"; - ast; - issues; - constructor(ast, issues, input, options) { - super(input, options); - this.ast = ast; - this.issues = issues; - } -}; -var OneOf = class extends IssueNodeImpl { - _tag = "OneOf"; - ast; - successes; - constructor(ast, successes, input, options) { - super(input, options); - this.ast = ast; - this.successes = successes; - } -}; -function makeFilterIssue(entry, input, options) { - if (isIssue(entry)) { - return entry; - } - if (typeof entry === "string") { - return new InvalidValue({ - message: entry - }, input, options); - } - const inner = typeof entry.issue === "string" ? new InvalidValue({ - message: entry.issue - }, input, options) : entry.issue; - return new Pointer(entry.path, inner); -} -function makeSingle(out, input, options) { - if (out === undefined) { - return; - } - if (typeof out === "boolean") { - return out ? undefined : new InvalidValue(undefined, input, options); - } - return makeFilterIssue(out, input, options); -} -function normalizeFilterOutput(ast, out, input, options) { - if (Array.isArray(out)) { - if (!isReadonlyArrayNonEmpty(out)) { - return; - } - return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map2(out, (entry) => makeFilterIssue(entry, input, options)), input, options); - } - return makeSingle(out, input, options); -} -var defaultLeafHook = (issue) => { - const message = findMessage(issue); - if (message !== undefined) - return message; - switch (issue._tag) { - case "InvalidType": - return getExpectedMessage(getExpected(issue.ast), issue); - case "InvalidValue": { - const expected = findExpected(issue); - if (expected !== undefined) - return getExpectedMessage(expected, issue); - const input = formatInput(issue); - return input === undefined ? "Expected a valid value" : `Invalid data ${input}`; - } - case "MissingKey": - return "Missing key"; - case "UnexpectedKey": { - const input = formatInput(issue); - return input === undefined ? "Expected no excess property" : `Unexpected key with value ${input}`; - } - case "Forbidden": - return "Forbidden operation"; - case "OneOf": { - const input = formatInput(issue); - return input === undefined ? "Expected exactly one member to match" : `Expected exactly one member to match the input ${input}`; - } - } -}; -var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue); -function formatInput(issue) { - return hasInput(issue) ? format(issue.input) : undefined; -} -function findExpected(issue) { - const expected = issue.annotations?.expected; - return typeof expected === "string" ? expected : undefined; -} -function getExpectedMessage(expected, issue) { - const input = formatInput(issue); - return input === undefined ? `Expected ${expected}` : `Expected ${expected}, got ${input}`; -} -function formatCheck(check) { - const expected = check.annotations?.expected; - if (typeof expected === "string") - return expected; - switch (check._tag) { - case "Filter": - return ""; - case "FilterGroup": - return check.checks.map((check) => formatCheck(check)).join(" & "); - } -} -function makeFormatterDefault() { - return (issue) => formatIssue(issue, ""); -} -var defaultFormatter = /* @__PURE__ */ makeFormatterDefault(); -function formatIssue(issue, path) { - let message; - switch (issue._tag) { - case "Filter": { - const annotated = defaultCheckHook(issue); - if (annotated !== undefined) { - message = annotated; - } else { - if (issue.issue._tag !== "InvalidValue") { - return formatIssue(issue.issue, path); - } - const expected = findExpected(issue.issue); - message = expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue); - } - break; - } - case "Encoding": - return formatIssue(issue.issue, path); - case "Pointer": - return formatIssue(issue.issue, path + formatPath(issue.path)); - case "Composite": - case "AnyOf": { - if (issue._tag === "Composite" || issue.issues.length > 0) { - return issue.issues.map((issue) => formatIssue(issue, path)).join(` -`); - } - message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue); - break; - } - default: - message = defaultLeafHook(issue); - break; - } - return path ? `${message} - at ${path}` : message; -} -function findMessage(issue) { - if (issue._tag === "Pointer") - return; - if (issue._tag === "Encoding") - return findMessage(issue.issue); - const annotations = issue._tag === "Filter" ? issue.filter.annotations : ("annotations" in issue) ? issue.annotations : issue.ast.annotations; - const message = annotations?.[issue._tag === "MissingKey" ? "messageMissingKey" : issue._tag === "UnexpectedKey" ? "messageUnexpectedKey" : "message"]; - if (typeof message === "string") - return message; -} - -// node_modules/effect/dist/internal/schema/cause.js -function getSchemaIssue(cause) { - let issue; - for (const reason of cause.reasons) { - if (!isFailReason2(reason) || !isIssue(reason.error)) { - return; - } - issue ??= reason.error; + if (issue._tag === "Encoding") + return findMessage(issue.issue); + const annotations = issue._tag === "Filter" ? issue.filter.annotations : ("annotations" in issue) ? issue.annotations : issue.ast.annotations; + const message = annotations?.[issue._tag === "MissingKey" ? "messageMissingKey" : issue._tag === "UnexpectedKey" ? "messageUnexpectedKey" : "message"]; + if (typeof message === "string") + return message; +} + +// node_modules/effect/dist/internal/schema/cause.js +function getSchemaIssue(cause) { + let issue; + for (const reason of cause.reasons) { + if (!isFailReason2(reason) || !isIssue(reason.error)) { + return; + } + issue ??= reason.error; } return issue; } @@ -5933,48 +4784,23 @@ function getSchemaIssueOrThrow(cause, message) { } // node_modules/effect/dist/SchemaGetter.js -var Getter = class extends Class { - run; - constructor(run) { - super(); - this.run = run; - } - map(f) { - return new Getter((oe, options) => this.run(oe, options).pipe(mapEager2(map(f)))); - } - compose(other) { - if (isPassthrough(this)) { - return other; - } - if (isPassthrough(other)) { - return this; - } - return new Getter((oe, options) => this.run(oe, options).pipe(flatMapEager2((ot) => other.run(ot, options)))); - } -}; -var passthrough_ = /* @__PURE__ */ new Getter(succeed6); -function isPassthrough(getter) { - return getter.run === passthrough_.run; -} +var makeGetter = (fields) => Object.assign(Object.create(Prototype), fields); +var passthrough_ = /* @__PURE__ */ makeGetter({ + _tag: "Passthrough" +}); function passthrough() { return passthrough_; } -function onSome(f) { - return new Getter((oe, options) => isNone2(oe) ? succeedNone2 : f(oe.value, options)); -} function transform(f) { - return transformOptional(map(f)); + return makeGetter({ + _tag: "Transform", + transform: f + }); } function transformEffect(f) { - return onSome((e, options) => f(e, options).pipe(mapEager2(some2))); -} -function transformOptional(f) { - return new Getter((oe) => succeed6(f(oe))); -} -function withDefault(defaultValue) { - return new Getter((o) => { - const filtered = filter(o, isNotUndefined); - return isSome2(filtered) ? succeed6(filtered) : mapEager2(defaultValue, some2); + return makeGetter({ + _tag: "TransformEffect", + transform: f }); } function String2() { @@ -5984,21 +4810,21 @@ function Number3() { return transform(globalThis.Number); } function parseJson(options) { - return onSome((input, parseOptions) => try_2({ - try: () => some2(JSON.parse(input, options?.reviver)), + return transformEffect((input, parseOptions) => try_2({ + try: () => JSON.parse(input, options?.reviver), catch: () => new InvalidValue({ expected: "a valid JSON string" }, input, parseOptions) })); } function stringifyJson(options) { - return onSome((input, parseOptions) => try_2({ + return transformEffect((input, parseOptions) => try_2({ try: () => { const output = JSON.stringify(input, options?.replacer, options?.space); if (output === undefined) { throw new TypeError("Value cannot be represented as JSON"); } - return some2(output); + return output; }, catch: () => new InvalidValue({ expected: "a JSON-serializable value" @@ -6014,28 +4840,151 @@ function decodeBase642() { }, input, options))); } +// node_modules/effect/dist/ByteSize.js +var bigint03 = /* @__PURE__ */ BigInt(0); +var bigint12 = /* @__PURE__ */ BigInt(1); +var decimalBase = /* @__PURE__ */ BigInt(1000); +var binaryBase = /* @__PURE__ */ BigInt(1024); +var decimalUnits = [{ + symbol: "B", + factor: bigint12, + names: ["B", "byte", "bytes"] +}, { + symbol: "kB", + factor: decimalBase, + names: ["kB", "kilobyte", "kilobytes"] +}, { + symbol: "MB", + factor: decimalBase ** /* @__PURE__ */ BigInt(2), + names: ["MB", "megabyte", "megabytes"] +}, { + symbol: "GB", + factor: decimalBase ** /* @__PURE__ */ BigInt(3), + names: ["GB", "gigabyte", "gigabytes"] +}, { + symbol: "TB", + factor: decimalBase ** /* @__PURE__ */ BigInt(4), + names: ["TB", "terabyte", "terabytes"] +}, { + symbol: "PB", + factor: decimalBase ** /* @__PURE__ */ BigInt(5), + names: ["PB", "petabyte", "petabytes"] +}, { + symbol: "EB", + factor: decimalBase ** /* @__PURE__ */ BigInt(6), + names: ["EB", "exabyte", "exabytes"] +}, { + symbol: "ZB", + factor: decimalBase ** /* @__PURE__ */ BigInt(7), + names: ["ZB", "zettabyte", "zettabytes"] +}, { + symbol: "YB", + factor: decimalBase ** /* @__PURE__ */ BigInt(8), + names: ["YB", "yottabyte", "yottabytes"] +}, { + symbol: "RB", + factor: decimalBase ** /* @__PURE__ */ BigInt(9), + names: ["RB", "ronnabyte", "ronnabytes"] +}, { + symbol: "QB", + factor: decimalBase ** /* @__PURE__ */ BigInt(10), + names: ["QB", "quettabyte", "quettabytes"] +}]; +var binaryUnits = [decimalUnits[0], { + symbol: "KiB", + factor: binaryBase, + names: ["KiB", "kibibyte", "kibibytes"] +}, { + symbol: "MiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(2), + names: ["MiB", "mebibyte", "mebibytes"] +}, { + symbol: "GiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(3), + names: ["GiB", "gibibyte", "gibibytes"] +}, { + symbol: "TiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(4), + names: ["TiB", "tebibyte", "tebibytes"] +}, { + symbol: "PiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(5), + names: ["PiB", "pebibyte", "pebibytes"] +}, { + symbol: "EiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(6), + names: ["EiB", "exbibyte", "exbibytes"] +}, { + symbol: "ZiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(7), + names: ["ZiB", "zebibyte", "zebibytes"] +}, { + symbol: "YiB", + factor: binaryBase ** /* @__PURE__ */ BigInt(8), + names: ["YiB", "yobibyte", "yobibytes"] +}]; +var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)]; +var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit]))); +var make5 = (value) => value; +var invalid2 = (message) => { + throw new Error(`Invalid ByteSize: ${message}`); +}; +var fromNumber = (input) => { + if (!Number.isSafeInteger(input) || input < 0) { + return invalid2(`expected a non-negative safe integer, received ${input}`); + } + return make5(BigInt(input)); +}; +var fromStringUnsafe = (input) => { + const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); + if (match === null) + return invalid2(`unsupported syntax ${JSON.stringify(input)}`); + const unit = unitsByName.get(match[3]); + if (unit === undefined) + return invalid2(`unsupported unit ${JSON.stringify(match[3])}`); + const fraction = match[2] ?? ""; + const scale = BigInt(10) ** BigInt(fraction.length); + const numerator = BigInt(match[1] + fraction) * unit.factor; + if (numerator % scale !== bigint03) { + return invalid2(`${JSON.stringify(input)} does not represent an integral number of bytes`); + } + return make5(numerator / scale); +}; +var fromInputUnsafe2 = (input) => { + switch (typeof input) { + case "bigint": + if (input < bigint03) + return invalid2(`expected a non-negative bigint, received ${input}`); + return make5(input); + case "number": + return fromNumber(input); + case "string": + return fromStringUnsafe(input); + } + return invalid2(`unsupported input ${input}`); +}; +var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value); + // node_modules/effect/dist/SchemaTransformation.js -var TypeId18 = "~effect/SchemaTransformation/Transformation"; -var Transformation = class { - [TypeId18] = TypeId18; +var TypeId8 = "~effect/SchemaTransformation/Transformation"; +var Transformation = class extends Class { + [TypeId8] = TypeId8; _tag = "Transformation"; decode; encode; constructor(decode, encode) { + super(); this.decode = decode; this.encode = encode; } flip() { return new Transformation(this.encode, this.decode); } - compose(other) { - return new Transformation(this.decode.compose(other.decode), other.encode.compose(this.encode)); - } }; function isTransformation(u) { - return hasProperty(u, TypeId18) && u[TypeId18] === TypeId18; + return hasProperty(u, TypeId8) && u[TypeId8] === TypeId8; } -var make13 = (options) => { +var makeTransformation = (options) => { if (isTransformation(options)) { return options; } @@ -6095,10 +5044,10 @@ var Context = class { this.annotations = annotations; } }; -var TypeId19 = "~effect/Schema"; +var TypeId9 = "~effect/Schema"; class ASTNodeImpl { - [TypeId19] = TypeId19; + [TypeId9] = TypeId9; annotations; checks; encoding; @@ -6263,1292 +5212,2231 @@ var Arrays = class extends ASTNodeImpl { } else if (hasOptional) { throw new Error("A required element cannot follow an optional element. ts(1257)"); } - } - if (hasOptional && rest.length > 1) { - throw new Error("A required element cannot follow an optional element. ts(1257)"); - } - for (let i = 1;i < rest.length; i++) { - if (isOptional(rest[i])) { - throw new Error("An optional element cannot follow a rest element. ts(1266)"); + } + if (hasOptional && rest.length > 1) { + throw new Error("A required element cannot follow an optional element. ts(1257)"); + } + for (let i = 1;i < rest.length; i++) { + if (isOptional(rest[i])) { + throw new Error("An optional element cannot follow a rest element. ts(1266)"); + } + } + } + getParser(compile, compileField = compile) { + const ast = this; + let elements; + let rest; + const elementLen = ast.elements.length; + const tailLen = Math.max(0, ast.rest.length - 1); + function getParser(tailThreshold, index) { + if (index < elementLen) { + return elements[index]; + } else if (index >= tailThreshold) { + return rest[index - tailThreshold + 1]; + } + return rest[0]; + } + return fnUntracedEager2(function* (input, options) { + if (input === missing) { + return missing; + } + if (!Array.isArray(input)) { + return yield* fail6(new InvalidType(ast, input, options)); + } + if (!elements) { + elements = ast.elements.map((ast) => ({ + ast, + parser: compileField(ast) + })); + rest = ast.rest.map((ast) => ({ + ast, + parser: compileField(ast) + })); + } + const len = input.length; + const state = { + ast, + getParser, + input, + len, + tailThreshold: Math.max(elementLen, len - tailLen), + output: new globalThis.Array(len), + issues: undefined, + options + }; + const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen); + const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); + const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, { + concurrency, + end + }); + if (eff) + yield* eff; + if (ast.rest.length === 0 && len > elementLen) { + for (let i = elementLen;i <= len - 1; i++) { + const unexpected = new UnexpectedKey(ast, input[i], options); + const issue = new Pointer([i], unexpected); + if (options.errors === "all") { + if (state.issues) + state.issues.push(issue); + else + state.issues = [issue]; + } else { + return yield* fail6(new Composite(ast, [issue], input, options)); + } + } + } + if (state.issues) { + return yield* fail6(new Composite(ast, state.issues, input, options)); + } + return state.output; + }); + } + _rebuild(recur, checks, encodingChecks) { + const elements = mapOrSame(this.elements, recur); + const rest = mapOrSame(this.rest, recur); + return elements === this.elements && rest === this.rest && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Arrays(this.isMutable, elements, rest, this.annotations, checks, undefined, this.context, encodingChecks); + } + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks); + } + getExpected() { + return "array"; + } +}; +function stepArray(s, item, exit, i) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, i, exit); + } + const value = exit === sameExit ? item : exit[args]; + if (value !== missing) { + s.output[i] = value; + } else { + const p = s.getParser(s.tailThreshold, i); + if (isOptional(p.ast)) + return; + const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); + } + } +} +var parseArrayOptions = { + onItem(s, item, i) { + const value = i < s.len ? item : missing; + return s.getParser(s.tailThreshold, i).parser(value, s.options); + }, + step: stepArray +}; +var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); +var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); +var wrapPropertyKeyIssue = (s, ast, key, exit) => { + if (exit.cause.reasons.length === 0) { + return exit; + } + const issue = getSchemaIssue(exit.cause); + if (issue === undefined) { + return failCause2(map4(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); + } + const pointer = new Pointer([key], issue); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(pointer); + else + s.issues = [pointer]; + } else { + return fail5(new Composite(ast, [pointer], s.input, s.options)); + } +}; +var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; +function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) { + let stringKeys; + let symbolKeys; + function go(parameter) { + switch (parameter._tag) { + case "String": + case "TemplateLiteral": + return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== undefined); + case "Number": + return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== undefined); + case "Symbol": + return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== undefined); + case "Union": + return [...new Set(parameter.types.flatMap(go))]; + default: + return []; + } + } + return go(parameterFromPropertyKey(toEncoded(parameter))); +} +var PropertySignature = class { + name; + type; + constructor(name, type) { + this.name = name; + this.type = type; + } +}; +function isIndexSignatureParameterSide(ast) { + switch (ast._tag) { + case "String": + case "Number": + case "Symbol": + case "TemplateLiteral": + return true; + case "Union": + return ast.types.every(isIndexSignatureParameterSide); + default: + return false; + } +} +function isIndexSignatureParameterEncodedSide(ast) { + const encoded = getLastEncoding(ast); + switch (encoded._tag) { + case "String": + case "Number": + case "Symbol": + case "TemplateLiteral": + return true; + case "Union": + return encoded.types.every(isIndexSignatureParameterEncodedSide); + default: + return false; + } +} +function isIndexSignatureParameter(ast) { + return isIndexSignatureParameterSide(ast) && isIndexSignatureParameterEncodedSide(ast); +} +var IndexSignature = class { + parameter; + type; + constructor(parameter, type) { + if (!isIndexSignatureParameter(parameter)) { + throw new Error(`Invalid index signature parameter ${parameter._tag}`); + } + this.parameter = parameter; + this.type = type; + if (isOptional(type) && !containsUndefined(type)) { + throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead."); + } + } +}; +var Objects = class extends ASTNodeImpl { + _tag = "Objects"; + propertySignatures; + indexSignatures; + encodingChecks; + constructor(propertySignatures, indexSignatures, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.propertySignatures = propertySignatures; + this.indexSignatures = indexSignatures; + this.encodingChecks = encodingChecks; + const seen = new Set; + const duplicates = []; + for (const propertySignature of propertySignatures) { + const name = propertySignature.name; + if (seen.has(name)) { + duplicates.push(name); + } else { + seen.add(name); + } + } + if (duplicates.length > 0) { + throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); + } + } + getParser(compile, compileField = compile) { + const ast = this; + const expectedKeys = []; + for (const ps of ast.propertySignatures) { + expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name); + } + const hasProperties = expectedKeys.length; + const indexCount = ast.indexSignatures.length; + let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : undefined; + if (!hasProperties && !indexCount) { + return fromRefinement(ast, isNotNullish); + } + let properties; + let indexes; + const finishIndex = (s, key, k2, inputValue, exitValue) => { + if (exitValue._tag === "Failure") { + return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_2; + } + const value = exitValue === sameExit ? inputValue : exitValue[args]; + if (k2 !== missing && value !== missing) { + if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) + return void_2; + assignProperty(s.out, k2, value); } - } - } - getParser(compile, compileConstructorDefault = compile) { - const ast = this; - let elements; - let rest; - const elementLen = ast.elements.length; - const tailLen = Math.max(0, ast.rest.length - 1); - function getParser(tailThreshold, index) { - if (index < elementLen) { - return elements[index]; - } else if (index >= tailThreshold) { - return rest[index - tailThreshold + 1]; + return void_2; + }; + const parseIndex = (s, key, index, exitKey) => { + if (!exitKey) { + const eff = index.parserKey(key, s.options); + if (!effectIsExit(eff)) { + return flatMap3(exit2(eff), (exit) => parseIndex(s, key, index, exit)); + } + exitKey = eff; } - return rest[0]; - } - return fnUntracedEager2(function* (input, options) { + if (exitKey._tag === "Failure") { + return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_2; + } + const k2 = exitKey === sameExit ? key : exitKey[args]; + const inputValue = s.input[key]; + const result = index.parserValue(inputValue, s.options); + return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, k2, inputValue, exit)); + }; + const parseStringIndex = (s, key, index) => { + const inputValue = s.input[key]; + const result = index.parserValue(inputValue, s.options); + return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, key, inputValue, exit)); + }; + const parseIndexes = indexCount ? iterateConcurrent()({ + onItem: (s, [key, index]) => index.is.parameter === string2 ? parseStringIndex(s, key, index) : parseIndex(s, key, index), + step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined + }) : undefined; + const compileMembers = () => { + if (!properties) { + properties = ast.propertySignatures.map((ps) => ({ + parser: compileField(ps.type), + name: ps.name, + type: ps.type + })); + indexes = indexCount ? ast.indexSignatures.map((is) => ({ + is, + parserKey: compile(parameterFromPropertyKey(is.parameter)), + parserValue: compileField(is.type) + })) : undefined; + } + return properties; + }; + const fallback = fnUntracedEager2(function* (input, options) { if (input === missing) { return missing; } - if (!Array.isArray(input)) { + if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { return yield* fail6(new InvalidType(ast, input, options)); } - if (!elements) { - elements = ast.elements.map((ast) => ({ - ast, - parser: compileConstructorDefault(ast) - })); - rest = ast.rest.map((ast) => ({ - ast, - parser: compileConstructorDefault(ast) - })); - } - const len = input.length; + compileMembers(); + const record = input; + const out = {}; const state = { ast, - getParser, - input, - len, - tailThreshold: Math.max(elementLen, len - tailLen), - output: new globalThis.Array(len), + input: record, + out, issues: undefined, options }; - const end = ast.rest.length === 0 ? elementLen : Math.max(len, elementLen + tailLen); + const errorsAllOption = options.errors === "all"; + const onExcessPropertyError = options.onExcessProperty === "error"; const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); - const eff = concurrency === 1 ? parseArray(state, input, 0, end) : parseArrayConcurrent(state, input, { - concurrency, - end - }); - if (eff) - yield* eff; - if (ast.rest.length === 0 && len > elementLen) { - for (let i = elementLen;i <= len - 1; i++) { - const unexpected = new UnexpectedKey(ast, input[i], options); - const issue = new Pointer([i], unexpected); - if (options.errors === "all") { - if (state.issues) - state.issues.push(issue); - else - state.issues = [issue]; - } else { - return yield* fail6(new Composite(ast, [issue], input, options)); + const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : undefined; + if (onExcessPropertyError) { + expectedKeysSet ??= new Set(expectedKeys); + const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet; + if (indexKeys) { + for (const keys of indexKeys) { + for (const key of keys) + coveredKeys.add(key); + } + } + const inputKeys = Reflect.ownKeys(record); + for (let i = 0;i < inputKeys.length; i++) { + const key = inputKeys[i]; + if (!coveredKeys.has(key)) { + const unexpected = new UnexpectedKey(ast, record[key], options); + const issue = new Pointer([key], unexpected); + if (errorsAllOption) { + if (state.issues) { + state.issues.push(issue); + } else { + state.issues = [issue]; + } + continue; + } else { + return yield* fail6(new Composite(ast, [issue], input, options)); + } + } + } + } + if (hasProperties) { + const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { + concurrency + }); + if (eff) + yield* eff; + } + if (indexCount && concurrency === 1) { + for (let i = 0;i < indexCount; i++) { + const index = indexes[i]; + const parse = index.is.parameter === string2 ? parseStringIndex : parseIndex; + const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); + for (let j = 0;j < keys.length; j++) { + const eff = parse(state, keys[j], index); + if (!effectIsExit(eff)) + yield* eff; + else if (eff._tag === "Failure") + return yield* eff; + } + } + } else if (parseIndexes) { + const keyPairs = empty(); + for (let i = 0;i < indexCount; i++) { + const index = indexes[i]; + const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); + for (let j = 0;j < keys.length; j++) { + keyPairs.push([keys[j], index]); } } + const eff = parseIndexes(state, keyPairs, { + concurrency + }); + if (eff) + yield* eff; } if (state.issues) { return yield* fail6(new Composite(ast, state.issues, input, options)); } - return state.output; + return out; }); - } - _rebuild(recur, checks, encodingChecks) { - const elements = mapOrSame(this.elements, recur); - const rest = mapOrSame(this.rest, recur); - return elements === this.elements && rest === this.rest && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Arrays(this.isMutable, elements, rest, this.annotations, checks, undefined, this.context, encodingChecks); - } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks); - } - flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks); - } - getExpected() { - return "array"; - } -}; -var parseArrayOptions = { - onItem(s, item, i) { - const value = i < s.len ? item : missing; - return s.getParser(s.tailThreshold, i).parser(value, s.options); - }, - step(s, item, exit, i) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, i, exit); - } - const value = exit === sameExit ? item : exit[args]; - if (value !== missing) { - s.output[i] = value; - } else { - const p = s.getParser(s.tailThreshold, i); - if (isOptional(p.ast)) - return; - const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); + if (indexCount) + return fallback; + const resume = (state, index, pending) => { + const property = properties[index]; + return flatMap3(exit2(pending), (exit) => { + const terminal = stepProperty(state, property, exit); + if (terminal) + return terminal; + const done = () => succeed7(state.out); + const eff = parseProperties(state, properties.slice(index + 1)); + return eff ? flatMapEager2(eff, done) : done(); + }); + }; + return (input, options) => { + if (input === missing) + return missingExit; + if (options.errors === "all" || options.onExcessProperty !== undefined || options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1) { + return fallback(input, options); } - } + if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { + return fail6(new InvalidType(ast, input, options)); + } + const props = compileMembers(); + const record = input; + const out = {}; + const state = { + ast, + input: record, + out, + issues: undefined, + options + }; + try { + for (let index = 0;index < props.length; index++) { + const property = props[index]; + const name = property.name; + const hasKey = hasPropertySignature(record, name); + const value = hasKey ? record[name] : missing; + const exit = property.parser(value, options); + if (!effectIsExit(exit)) { + return resume(state, index, exit); + } + if (exit === sameExit) { + if (hasKey) + assignProperty(out, name, value); + continue; + } + const terminal = stepProperty(state, property, exit); + if (terminal) + return terminal; + } + } catch (error) { + return die3(error); + } + return succeed7(out); + }; + } + _rebuild(recur, recurParameter, checks, encodingChecks) { + const props = mapOrSame(this.propertySignatures, (ps) => { + const t = recur(ps.type); + return t === ps.type ? ps : new PropertySignature(ps.name, t); + }); + const indexes = mapOrSame(this.indexSignatures, (is) => { + const p = recurParameter(is.parameter); + const t = recur(is.type); + return p === is.parameter && t === is.type ? is : new IndexSignature(p, t); + }); + return props === this.propertySignatures && indexes === this.indexSignatures && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Objects(props, indexes, this.annotations, checks, undefined, this.context, encodingChecks); } -}; -var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); -var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); -var wrapPropertyKeyIssue = (s, ast, key, exit) => { - if (exit.cause.reasons.length === 0) { - return exit; + flip(recur) { + return this._rebuild(recur, recur, this.encodingChecks, this.checks); } - const issue = getSchemaIssue(exit.cause); - if (issue === undefined) { - return failCause2(map5(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); + recur(recur, recurParameter = recur) { + return this._rebuild(recur, recurParameter, this.checks, this.encodingChecks); } - const pointer = new Pointer([key], issue); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(pointer); - else - s.issues = [pointer]; - } else { - return fail4(new Composite(ast, [pointer], s.input, s.options)); + getExpected() { + if (this.propertySignatures.length === 0 && this.indexSignatures.length === 0) + return "object | array"; + return "object"; } }; -var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"; -function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) { - let stringKeys; - let symbolKeys; - function go(parameter) { - switch (parameter._tag) { - case "String": - case "TemplateLiteral": - return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== undefined); - case "Number": - return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== undefined); - case "Symbol": - return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== undefined); - case "Union": - return [...new Set(parameter.types.flatMap(go))]; - default: - return []; +function stepProperty(s, p, exit) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, p.name, exit); + } + if (exit === sameExit) + return; + const value = exit[args]; + if (value !== missing) { + assignProperty(s.out, p.name, value); + return; + } + delete s.out[p.name]; + if (!isOptional(p.type)) { + const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + return; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); } } - return go(parameterFromPropertyKey(toEncoded(parameter))); } -var PropertySignature = class { - name; - type; - constructor(name, type) { - this.name = name; - this.type = type; - } +var parsePropertiesOptions = { + onItem(s, p) { + if (!hasPropertySignature(s.input, p.name)) { + return p.parser(missing, s.options); + } + const value = s.input[p.name]; + assignProperty(s.out, p.name, value); + return p.parser(value, s.options); + }, + step: stepProperty }; -function isIndexSignatureParameterSide(ast) { +var parseProperties = /* @__PURE__ */ iterateEager()(parsePropertiesOptions); +var parsePropertiesConcurrent = /* @__PURE__ */ iterateConcurrent()(parsePropertiesOptions); +function combineChecks(a, b) { + if (!a) + return b; + if (!b) + return a; + return [...a, ...b]; +} +function struct(fields, checks, annotations) { + return new Objects(Reflect.ownKeys(fields).map((key) => { + return new PropertySignature(key, fields[key].ast); + }), [], annotations, checks); +} +function getAST(self) { + return self.ast; +} +function tuple(elements, checks = undefined) { + return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks); +} +function union(members, options, checks) { + return new Union(members.map(getAST), options, undefined, checks); +} +var toCandidate = /* @__PURE__ */ memoizeIdempotent((ast) => { + while (true) { + if (isSuspend(ast)) + return unknown; + const encoding = ast.encoding; + if (!encoding) { + return ast.recur?.(toCandidate, identity) ?? ast; + } + if (encoding.some((link) => link.transformation._tag === "Middleware" && link.transformation.decode !== identity)) + return unknown; + ast = encoding[encoding.length - 1].to; + } +}); +function getCandidateTypes(ast) { switch (ast._tag) { + case "Null": + return ["null"]; + case "Undefined": + return ["undefined"]; case "String": - case "Number": - case "Symbol": case "TemplateLiteral": - return true; - case "Union": - return ast.types.every(isIndexSignatureParameterSide); - default: - return false; - } -} -function isIndexSignatureParameterEncodedSide(ast) { - const encoded = getLastEncoding(ast); - switch (encoded._tag) { - case "String": + return ["string"]; case "Number": + return ["number"]; + case "Boolean": + return ["boolean"]; case "Symbol": - case "TemplateLiteral": - return true; + case "UniqueSymbol": + return ["symbol"]; + case "BigInt": + return ["bigint"]; + case "Arrays": + return ["array"]; + case "ObjectKeyword": + return ["object", "array", "function"]; + case "Objects": + return ast.propertySignatures.length || ast.indexSignatures.length ? ["object"] : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; + case "Enum": + return Array.from(new Set(ast.enums.map(([, v]) => typeof v))); + case "Literal": + return [typeof ast.literal]; case "Union": - return encoded.types.every(isIndexSignatureParameterEncodedSide); + return Array.from(new Set(ast.types.flatMap(getCandidateTypes))); default: - return false; + return ["null", "undefined", "string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; } } -function isIndexSignatureParameter(ast) { - return isIndexSignatureParameterSide(ast) && isIndexSignatureParameterEncodedSide(ast); -} -var IndexSignature = class { - parameter; - type; - constructor(parameter, type) { - if (!isIndexSignatureParameter(parameter)) { - throw new Error(`Invalid index signature parameter ${parameter._tag}`); +function collectSentinels(ast) { + switch (ast._tag) { + default: + return []; + case "Declaration": { + const s = ast.annotations?.[SENTINELS_ANNOTATION_KEY]; + return Array.isArray(s) ? s : []; } - this.parameter = parameter; - this.type = type; - if (isOptional(type) && !containsUndefined(type)) { - throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead."); + case "Objects": + return ast.propertySignatures.flatMap((ps) => { + const type = ps.type; + if (!isOptional(type)) { + if (isLiteral(type)) { + return [{ + key: ps.name, + literal: type.literal + }]; + } + if (isUniqueSymbol(type)) { + return [{ + key: ps.name, + literal: type.symbol + }]; + } + } + return []; + }); + case "Arrays": + return ast.elements.flatMap((e, i) => { + if (!isOptional(e)) { + if (isLiteral(e)) { + return [{ + key: i, + literal: e.literal + }]; + } + if (isUniqueSymbol(e)) { + return [{ + key: i, + literal: e.symbol + }]; + } + } + return []; + }); + case "Union": { + if (ast.types.length === 0) + return []; + const members = ast.types.map((type) => collectSentinels(toCandidate(type))); + return members[0].filter((s) => members.every((sentinels) => sentinels.some((o) => o.key === s.key && o.literal === s.literal))); } + case "Suspend": + return collectSentinels(ast.thunk()); } -}; -var Objects = class extends ASTNodeImpl { - _tag = "Objects"; - propertySignatures; - indexSignatures; - encodingChecks; - constructor(propertySignatures, indexSignatures, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.propertySignatures = propertySignatures; - this.indexSignatures = indexSignatures; - this.encodingChecks = encodingChecks; - const seen = new Set; - const duplicates = []; - for (const propertySignature of propertySignatures) { - const name = propertySignature.name; - if (seen.has(name)) { - duplicates.push(name); +} +var candidateIndexCache = /* @__PURE__ */ new WeakMap; +var emptyCandidates = /* @__PURE__ */ Object.freeze([]); +var hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : (key in input); +function getIndex(types) { + let index = candidateIndexCache.get(types); + if (index) + return index; + let bySentinel; + let sentinelCandidateCount = 0; + let otherwise; + let literalCandidates; + let onlyLiterals = true; + for (let i = 0;i < types.length; i++) { + const a = types[i]; + const encoded = toCandidate(a); + if (isNever2(encoded)) + continue; + if (onlyLiterals) { + if (isLiteral(encoded) || isUniqueSymbol(encoded)) { + literalCandidates ??= new Map; + const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol; + let arr = literalCandidates.get(literal); + if (!arr) + literalCandidates.set(literal, arr = []); + arr.push(a); } else { - seen.add(name); + onlyLiterals = false; } } - if (duplicates.length > 0) { - throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); + const sentinels = collectSentinels(encoded); + if (sentinels.length) { + bySentinel ??= new Map; + sentinelCandidateCount++; + for (const { + key, + literal + } of sentinels) { + let entry = bySentinel.get(key); + if (!entry) + bySentinel.set(key, entry = [new Map, new Set]); + entry[1].add(i); + let indexes = entry[0].get(literal); + if (!indexes) + entry[0].set(literal, indexes = new Set); + indexes.add(i); + } + } else { + otherwise ??= {}; + const candidateTypes = getCandidateTypes(encoded); + for (const t of candidateTypes) + (otherwise[t] ??= []).push(i); } } - getParser(compile, compileConstructorDefault = compile) { - const ast = this; - const expectedKeys = []; - for (const ps of ast.propertySignatures) { - expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name); - } - const hasProperties = expectedKeys.length; - const indexCount = ast.indexSignatures.length; - let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : undefined; - if (!hasProperties && !indexCount) { - return fromRefinement(ast, isNotNullish); + if (onlyLiterals && literalCandidates) { + literalCandidates.forEach(Object.freeze); + index = (input) => literalCandidates.get(input) ?? emptyCandidates; + } else if (bySentinel?.size === 1 && !otherwise) { + const [key, [byValue]] = bySentinel.entries().next().value; + const candidates = byValue; + for (const [literal, indexes] of byValue) { + candidates.set(literal, Object.freeze(Array.from(indexes, (index) => types[index]))); } - let properties; - let indexes; - const finishIndex = (s, key, k2, inputValue, exitValue) => { - if (exitValue._tag === "Failure") { - return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_2; - } - const value = exitValue === sameExit ? inputValue : exitValue[args]; - if (k2 !== missing && value !== missing) { - if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) - return void_2; - assignProperty(s.out, k2, value); - } - return void_2; - }; - const parseIndex = (s, key, index, exitKey) => { - if (!exitKey) { - const eff = index.parserKey(key, s.options); - if (!effectIsExit(eff)) { - return flatMap3(exit2(eff), (exit) => parseIndex(s, key, index, exit)); - } - exitKey = eff; - } - if (exitKey._tag === "Failure") { - return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_2; - } - const k2 = exitKey === sameExit ? key : exitKey[args]; - const inputValue = s.input[key]; - const result = index.parserValue(inputValue, s.options); - return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, k2, inputValue, exit)); - }; - const parseStringIndex = (s, key, index) => { - const inputValue = s.input[key]; - const result = index.parserValue(inputValue, s.options); - return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap3(exit2(result), (exit) => finishIndex(s, key, key, inputValue, exit)); - }; - const parseIndexes = indexCount ? iterateConcurrent()({ - onItem: (s, [key, index]) => index.is.parameter === string2 ? parseStringIndex(s, key, index) : parseIndex(s, key, index), - step: (_s, _item, exit) => exit._tag === "Failure" ? exit : undefined - }) : undefined; - const compileMembers = () => { - if (!properties) { - properties = ast.propertySignatures.map((ps) => ({ - parser: compileConstructorDefault(ps.type), - name: ps.name, - type: ps.type - })); - indexes = indexCount ? ast.indexSignatures.map((is) => ({ - is, - parserKey: compile(parameterFromPropertyKey(is.parameter)), - parserValue: compileConstructorDefault(is.type) - })) : undefined; + index = (input, isConstructor) => { + if (isObjectKeyword(input)) { + const value = hasPropertySignature(input, key) ? input[key] : undefined; + if (value !== undefined) + return candidates.get(value) ?? emptyCandidates; + if (isConstructor) + return types; } - return properties; + return emptyCandidates; }; - const fallback = fnUntracedEager2(function* (input, options) { - if (input === missing) { - return missing; - } - if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { - return yield* fail6(new InvalidType(ast, input, options)); + } else if (bySentinel) { + let commonSentinel; + for (const entry of bySentinel) { + if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) { + commonSentinel = entry; } - compileMembers(); - const record = input; - const out = {}; - const state = { - ast, - input: record, - out, - issues: undefined, - options - }; - const errorsAllOption = options.errors === "all"; - const onExcessPropertyError = options.onExcessProperty === "error"; - const concurrency = options.concurrency === undefined ? 1 : resolveConcurrency(options.concurrency); - const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : undefined; - if (onExcessPropertyError) { - expectedKeysSet ??= new Set(expectedKeys); - const coveredKeys = indexKeys ? new Set(expectedKeysSet) : expectedKeysSet; - if (indexKeys) { - for (const keys of indexKeys) { - for (const key of keys) - coveredKeys.add(key); - } - } - const inputKeys = Reflect.ownKeys(record); - for (let i = 0;i < inputKeys.length; i++) { - const key = inputKeys[i]; - if (!coveredKeys.has(key)) { - const unexpected = new UnexpectedKey(ast, record[key], options); - const issue = new Pointer([key], unexpected); - if (errorsAllOption) { - if (state.issues) { - state.issues.push(issue); - } else { - state.issues = [issue]; - } - continue; - } else { - return yield* fail6(new Composite(ast, [issue], input, options)); - } - } + } + index = (input, isConstructor) => { + const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; + const base = otherwise?.[runtimeType] ?? emptyCandidates; + if (!isObjectKeyword(input)) + return base.map((i) => types[i]); + const selected = new Set(base); + let directKey; + if (commonSentinel) { + const [key, [byValue]] = commonSentinel; + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + if (!match) + return base.map((i) => types[i]); + for (const i of match) + selected.add(i); + directKey = key; } } - if (hasProperties) { - const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { - concurrency - }); - if (eff) - yield* eff; - } - if (indexCount && concurrency === 1) { - for (let i = 0;i < indexCount; i++) { - const index = indexes[i]; - const parse = index.is.parameter === string2 ? parseStringIndex : parseIndex; - const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); - for (let j = 0;j < keys.length; j++) { - const eff = parse(state, keys[j], index); - if (!effectIsExit(eff)) - yield* eff; - else if (eff._tag === "Failure") - return yield* eff; - } - } - } else if (parseIndexes) { - const keyPairs = empty2(); - for (let i = 0;i < indexCount; i++) { - const index = indexes[i]; - const keys = indexKeys?.[i] ?? (index.is.parameter === string2 ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options)); - for (let j = 0;j < keys.length; j++) { - keyPairs.push([keys[j], index]); + if (directKey === undefined) { + for (const [key, [byValue, all]] of bySentinel) { + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + if (match) { + for (const i of match) + selected.add(i); + } + } else if (isConstructor) { + for (const i of all) + selected.add(i); } } - const eff = parseIndexes(state, keyPairs, { - concurrency - }); - if (eff) - yield* eff; - } - if (state.issues) { - return yield* fail6(new Composite(ast, state.issues, input, options)); } - return out; - }); - if (indexCount) - return fallback; - const resume = (state, index, pending) => { - const property = properties[index]; - return flatMap3(exit2(pending), (exit) => { - const terminal = stepProperty(state, property, exit); - if (terminal) - return terminal; - const done = () => succeed8(state.out); - const eff = parseProperties(state, properties.slice(index + 1)); - return eff ? flatMapEager2(eff, done) : done(); - }); + for (const [key, [byValue, all]] of bySentinel) { + if (key === directKey) + continue; + const hasKey = hasPropertySignature(input, key); + const value = hasKey ? input[key] : undefined; + if (hasKey && (!isConstructor || value !== undefined)) { + const match = byValue.get(value); + for (const i of selected) { + if (all.has(i) && !match?.has(i)) + selected.delete(i); + } + } + } + return Array.from(selected).sort((a, b) => a - b).map((i) => types[i]); + }; + } else { + index = (input) => { + const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; + return (otherwise?.[runtimeType] ?? emptyCandidates).map((i) => types[i]).filter(filterLiterals(input)); }; + } + candidateIndexCache.set(types, index); + return index; +} +function filterLiterals(input) { + return (ast) => { + const encoded = toCandidate(ast); + return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true; + }; +} +function getCandidates(input, types, isConstructor = false) { + return getIndex(types)(input, isConstructor); +} +var Union = class extends ASTNodeImpl { + _tag = "Union"; + types; + options; + encodingChecks; + constructor(types, options, annotations, checks, encoding, context, encodingChecks) { + super(annotations, checks, encoding, context); + this.types = types; + this.options = options; + this.encodingChecks = encodingChecks; + } + getParser(compile, compileField) { + const ast = this; return (input, options) => { - if (input === missing) + if (input === missing) { return missingExit; - if (options.errors === "all" || options.onExcessProperty !== undefined || options.concurrency !== undefined && resolveConcurrency(options.concurrency) !== 1) { - return fallback(input, options); } - if (!(typeof input === "object" && input !== null && !Array.isArray(input))) { - return fail6(new InvalidType(ast, input, options)); + const candidates = getCandidates(input, ast.types, compileField !== undefined); + if (candidates.length === 0) { + return fail6(new AnyOf(ast, [], input, options)); + } + if (candidates.length === 1) { + const result = compile(candidates[0])(input, options); + if (result._tag === "Success") + return result; + return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchCause2(result, (cause) => failSingleUnionCandidate(ast, cause, input, options)); } - const props = compileMembers(); - const record = input; - const out = {}; const state = { ast, - input: record, - out, + compile, + input, + out: undefined, + successes: ast.options?.mode === "oneOf" ? [] : undefined, issues: undefined, options }; - try { - for (let index = 0;index < props.length; index++) { - const property = props[index]; - const name = property.name; - const hasKey = hasPropertySignature(record, name); - const value = hasKey ? record[name] : missing; - const exit = property.parser(value, options); - if (!effectIsExit(exit)) { - return resume(state, index, exit); + const eff = parseUnion(state, candidates); + if (!eff) { + if (state.out) + return state.out; + return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + } + return flatMapEager2(eff, (_) => { + if (state.out === sameExit) + return succeed6(input); + if (state.out) + return state.out; + return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + }); + }; + } + _rebuild(recur, checks, encodingChecks) { + const types = mapOrSame(this.types, recur); + return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks); + } + recur(recur) { + return this._rebuild(recur, this.checks, this.encodingChecks); + } + flip(recur) { + return this._rebuild(recur, this.encodingChecks, this.checks); + } + matchPart(s, options) { + for (const type of this.types) { + const out = type.matchPart(s, options); + if (out !== undefined) + return out; + } + return; + } + getExpected(getExpected) { + const expected = this.annotations?.expected; + if (typeof expected === "string") + return expected; + if (this.types.length === 0) + return "never"; + const types = this.types.map((type) => { + const encoded = toEncoded(type); + switch (encoded._tag) { + case "Arrays": { + const literals = encoded.elements.filter(isLiteral); + if (literals.length > 0) { + return `${formatIsMutable(encoded.isMutable)}[ ${literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ")}, ... ]`; } - if (exit === sameExit) { - if (hasKey) - assignProperty(out, name, value); - continue; + break; + } + case "Objects": { + const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)); + if (literals.length > 0) { + return `{ ${literals.map((ps) => `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${formatIsOptional(ps.type.context?.isOptional)}: ${getExpected(ps.type)}`).join(", ")}, ... }`; } - const terminal = stepProperty(state, property, exit); - if (terminal) - return terminal; + break; } - } catch (error) { - return die2(error); } - return succeed8(out); - }; - } - _rebuild(recur, recurParameter, checks, encodingChecks) { - const props = mapOrSame(this.propertySignatures, (ps) => { - const t = recur(ps.type); - return t === ps.type ? ps : new PropertySignature(ps.name, t); + return getExpected(encoded); }); - const indexes = mapOrSame(this.indexSignatures, (is) => { - const p = recurParameter(is.parameter); - const t = recur(is.type); - return p === is.parameter && t === is.type ? is : new IndexSignature(p, t); + return Array.from(new Set(types)).join(" | "); + } +}; +function failSingleUnionCandidate(ast, cause, input, options) { + const issue = getSchemaIssue(cause); + if (!issue) + return failCause2(cause); + return fail5(new AnyOf(ast, [issue], input, options)); +} +var parseUnion = /* @__PURE__ */ iterateEager()({ + onItem(s, ast) { + const parser = s.compile(ast); + return parser(s.input, s.options); + }, + step(s, candidate, exit) { + if (exit._tag === "Failure") { + const issue = getSchemaIssue(exit.cause); + if (issue === undefined) { + return exit; + } + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + if (s.out && s.successes) { + s.successes.push(candidate); + return fail5(new OneOf(s.ast, s.successes, s.input, s.options)); + } + s.out = exit; + if (s.successes) { + s.successes.push(candidate); + } else { + return void_2; + } + } + } +}); +var nonFiniteLiterals = /* @__PURE__ */ new Union([/* @__PURE__ */ new Literal("Infinity"), /* @__PURE__ */ new Literal("-Infinity"), /* @__PURE__ */ new Literal("NaN")]); +function formatIsMutable(isMutable) { + return isMutable ? "" : "readonly "; +} +function formatIsOptional(isOptional) { + return isOptional ? "?" : ""; +} +var Filter2 = class extends Class { + _tag = "Filter"; + run; + annotations; + aborted; + constructor(run, annotations = undefined, aborted = false) { + super(); + this.run = run; + this.annotations = annotations; + this.aborted = aborted; + } + annotate(annotations) { + return new Filter2(this.run, { + ...this.annotations, + ...annotations + }, this.aborted); + } + abort() { + return new Filter2(this.run, this.annotations, true); + } + and(other, annotations) { + return new FilterGroup([this, other], annotations); + } +}; +var FilterGroup = class extends Class { + _tag = "FilterGroup"; + checks; + annotations; + constructor(checks, annotations = undefined) { + super(); + this.checks = checks; + this.annotations = annotations; + } + annotate(annotations) { + return new FilterGroup(this.checks, { + ...this.annotations, + ...annotations }); - return props === this.propertySignatures && indexes === this.indexSignatures && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Objects(props, indexes, this.annotations, checks, undefined, this.context, encodingChecks); } - flip(recur) { - return this._rebuild(recur, recur, this.encodingChecks, this.checks); + and(other, annotations) { + return new FilterGroup([this, other], annotations); + } +}; +function makeFilter(filter, annotations, aborted = false) { + return new Filter2((input, ast, options) => normalizeFilterOutput(ast, filter(input, ast, options), input, options), annotations, aborted); +} +function isFinite2(annotations) { + return makeFilter((n) => globalThis.Number.isFinite(n), { + expected: "a finite number", + representation: { + id: "effect/schema/isFinite", + payload: null + }, + toJsonSchema: () => ({ + type: "number" + }), + toCode: () => ({ + runtime: "Schema.isFinite()" + }), + arbitraryConstraint: { + number: "finite" + }, + ...annotations + }); +} +var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]); +var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n)))); +function isPattern(regExp, annotations) { + const source = regExp.source; + const pattern = new globalThis.RegExp(source, regExp.flags); + return makeFilter((s) => { + pattern.lastIndex = 0; + return pattern.test(s); + }, { + expected: `a string matching the RegExp ${source}`, + representation: { + id: "effect/schema/isPattern", + payload: { + source, + flags: regExp.flags + } + }, + toJsonSchema: () => ({ + pattern: source + }), + arbitraryConstraint: { + patterns: [{ + source: regExp.source, + flags: regExp.flags + }] + }, + ...annotations + }); +} +function modifyOwnPropertyDescriptors(ast, f) { + const d = Object.getOwnPropertyDescriptors(ast); + f(d); + return Object.create(Object.getPrototypeOf(ast), d); +} +var contextOwners = /* @__PURE__ */ new WeakMap; +function getContextOwner(ast) { + return contextOwners.get(ast) ?? ast; +} +function replaceEncoding(ast, encoding) { + if (ast.encoding === encoding) { + return ast; + } + return modifyOwnPropertyDescriptors(ast, (d) => { + d.encoding.value = encoding; + }); +} +function replaceContext(ast, context) { + if (ast.context === context) { + return ast; } - recur(recur, recurParameter = recur) { - return this._rebuild(recur, recurParameter, this.checks, this.encodingChecks); + const owner = getContextOwner(ast); + if (owner.context === context) { + return owner; } - getExpected() { - if (this.propertySignatures.length === 0 && this.indexSignatures.length === 0) - return "object | array"; - return "object"; + const out = modifyOwnPropertyDescriptors(ast, (d) => { + d.context.value = context; + }); + contextOwners.set(out, owner); + return out; +} +function getLastEncoding(ast) { + return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast; +} +function annotate(ast, annotations) { + if (ast.checks) { + const last = ast.checks[ast.checks.length - 1]; + return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations))); } -}; -function stepProperty(s, p, exit) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, p.name, exit); + return modifyOwnPropertyDescriptors(ast, (d) => { + d.annotations.value = { + ...d.annotations.value, + ...annotations + }; + }); +} +function replaceChecks(ast, checks) { + if (ast._tag === "Suspend" && checks) { + throw new Error("Cannot add checks to Suspend"); } - if (exit === sameExit) - return; - const value = exit[args]; - if (value !== missing) { - assignProperty(s.out, p.name, value); - return; + if (ast.checks === checks) { + return ast; } - delete s.out[p.name]; - if (!isOptional(p.type)) { - const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - return; - } else { - return fail4(new Composite(s.ast, [issue], s.input, s.options)); + return modifyOwnPropertyDescriptors(ast, (d) => { + d.checks.value = checks; + }); +} +function appendChecks(ast, checks) { + return replaceChecks(ast, combineChecks(ast.checks, checks)); +} +function mapLink(link, f) { + const to = f(link.to); + return to === link.to ? link : new Link(to, link.transformation); +} +function updateLastLink(encoding, f) { + const links = encoding; + const last = links[links.length - 1]; + const out = mapLink(last, f); + return out === last ? encoding : append(encoding.slice(0, encoding.length - 1), out); +} +function applyToLastLink(f) { + return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast; +} +function applyToSelfOrLastLinkEncodingIdempotent(f, options) { + function out(ast) { + if (ast.encoding) { + const last = ast.encoding[ast.encoding.length - 1]; + return options?.stopAt?.(last) ? ast : replaceEncoding(ast, updateLastLink(ast.encoding, out)); } + return f(ast); } + return memoizeIdempotent(out); } -var parsePropertiesOptions = { - onItem(s, p) { - if (!hasPropertySignature(s.input, p.name)) { - return p.parser(missing, s.options); +function appendTransformation(from, transformation, to) { + const link = new Link(from, transformation); + return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]); +} +function mapOrSame(as, f) { + let changed = false; + const out = new Array(as.length); + for (let i = 0;i < as.length; i++) { + const a = as[i]; + const fa = f(a); + if (fa !== a) { + changed = true; } - const value = s.input[p.name]; - assignProperty(s.out, p.name, value); - return p.parser(value, s.options); - }, - step: stepProperty -}; -var parseProperties = /* @__PURE__ */ iterateEager()(parsePropertiesOptions); -var parsePropertiesConcurrent = /* @__PURE__ */ iterateConcurrent()(parsePropertiesOptions); -function combineChecks(a, b) { - if (!a) - return b; - if (!b) - return a; - return [...a, ...b]; + out[i] = fa; + } + return changed ? out : as; } -function struct(fields, checks, annotations) { - return new Objects(Reflect.ownKeys(fields).map((key) => { - return new PropertySignature(key, fields[key].ast); - }), [], annotations, checks); +function annotateKey(ast, annotations) { + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, { + ...ast.context.annotations, + ...annotations + }) : new Context(false, false, undefined, annotations); + return replaceContext(ast, context); } -function getAST(self) { - return self.ast; +var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { + const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false); + return optionalKeyLastLink(replaceContext(ast, context)); +}); +var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); +function withConstructorDefault(ast, defaultValue) { + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue); + return replaceContext(ast, context); } -function tuple(elements, checks = undefined) { - return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks); +function decodeTo(from, to, transformation) { + return appendTransformation(from, transformation, to); } -function union(members, options, checks) { - return new Union(members.map(getAST), options, undefined, checks); +function isOptional(ast) { + return ast.context?.isOptional ?? false; } -var toCandidate = /* @__PURE__ */ memoizeIdempotent((ast) => { - while (true) { - if (isSuspend(ast)) - return unknown; - const encoding = ast.encoding; - if (!encoding) { - return ast.recur?.(toCandidate, identity) ?? ast; - } - if (encoding.some((link) => link.transformation._tag === "Middleware" && link.transformation.decode !== identity)) - return unknown; - ast = encoding[encoding.length - 1].to; +function isStructuralCheck(check) { + return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck); +} +function extractStructuralChecks(checks) { + function extract(check) { + if (isStructuralCheck(check)) + return [check]; + return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []; + } + const out = checks.flatMap(extract); + return isArrayNonEmpty2(out) ? out : undefined; +} +var toType = /* @__PURE__ */ memoizeIdempotent((ast) => { + if (ast.encoding) { + return toType(replaceEncoding(ast, undefined)); } + const out = ast; + const type = out.recur?.(toType) ?? out; + const encodingChecks = type.encodingChecks; + if (encodingChecks) { + const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : undefined; + return modifyOwnPropertyDescriptors(type, (d) => { + d.encodingChecks.value = undefined; + d.checks.value = combineChecks(type.checks, checks); + }); + } + return type; }); -function getCandidateTypes(ast) { - switch (ast._tag) { - case "Null": - return ["null"]; - case "Undefined": - return ["undefined"]; - case "String": - case "TemplateLiteral": - return ["string"]; - case "Number": - return ["number"]; - case "Boolean": - return ["boolean"]; - case "Symbol": - case "UniqueSymbol": - return ["symbol"]; - case "BigInt": - return ["bigint"]; - case "Arrays": - return ["array"]; - case "ObjectKeyword": - return ["object", "array", "function"]; - case "Objects": - return ast.propertySignatures.length || ast.indexSignatures.length ? ["object"] : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; - case "Enum": - return Array.from(new Set(ast.enums.map(([, v]) => typeof v))); - case "Literal": - return [typeof ast.literal]; +var toEncoded = /* @__PURE__ */ memoizeIdempotent((ast) => { + return toType(flip2(ast)); +}); +function flipEncoding(ast, encoding) { + const links = encoding; + const len = links.length; + const last = links[len - 1]; + const ls = [new Link(flip2(replaceEncoding(ast, undefined)), links[0].transformation.flip())]; + for (let i = 1;i < len; i++) { + ls.unshift(new Link(flip2(links[i - 1].to), links[i].transformation.flip())); + } + const to = flip2(last.to); + if (to.encoding) { + return replaceEncoding(to, [...to.encoding, ...ls]); + } else { + return replaceEncoding(to, ls); + } +} +var flip2 = /* @__PURE__ */ memoize((ast) => { + if (ast.encoding) { + return flipEncoding(ast, ast.encoding); + } + const out = ast; + return out.flip?.(flip2) ?? out.recur?.(flip2) ?? out; +}); +function containsUndefined(ast) { + switch (ast._tag) { + case "Undefined": + return true; case "Union": - return Array.from(new Set(ast.types.flatMap(getCandidateTypes))); + return ast.types.some(containsUndefined); default: - return ["null", "undefined", "string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]; + return false; } } -function collectSentinels(ast) { +function fromConst(ast, value) { + const succeed = value === 0 ? sameExit : succeed7(value); + return (input, options) => { + if (input === missing) + return missingExit; + if (input === value) + return succeed; + return fail6(new InvalidType(ast, input, options)); + }; +} +function fromRefinement(ast, refinement) { + return (input, options) => { + if (input === missing) + return missingExit; + if (refinement(input)) + return sameExit; + return fail6(new InvalidType(ast, input, options)); + }; +} +var parameterFromPropertyKey = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => { switch (ast._tag) { default: - return []; - case "Declaration": { - const s = ast.annotations?.[SENTINELS_ANNOTATION_KEY]; - return Array.isArray(s) ? s : []; - } - case "Objects": - return ast.propertySignatures.flatMap((ps) => { - const type = ps.type; - if (!isOptional(type)) { - if (isLiteral(type)) { - return [{ - key: ps.name, - literal: type.literal - }]; - } - if (isUniqueSymbol(type)) { - return [{ - key: ps.name, - literal: type.symbol - }]; - } - } - return []; - }); - case "Arrays": - return ast.elements.flatMap((e, i) => { - if (!isOptional(e)) { - if (isLiteral(e)) { - return [{ - key: i, - literal: e.literal - }]; - } - if (isUniqueSymbol(e)) { - return [{ - key: i, - literal: e.symbol - }]; - } + return ast; + case "Number": + return ast.toCodecStringTree(); + case "Union": + return ast.recur(parameterFromPropertyKey); + } +}); +var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`); +var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`); +function isStringFinite(annotations) { + return isPattern(isStringFiniteRegExp, { + expected: "a string representing a finite number", + representation: { + id: "effect/schema/isStringFinite", + payload: null + }, + toJsonSchema: () => ({ + pattern: isStringFiniteRegExp.source + }), + ...annotations + }); +} +var finiteString = /* @__PURE__ */ appendChecks(string2, [/* @__PURE__ */ isStringFinite()]); +var finiteToString = /* @__PURE__ */ new Link(finiteString, numberFromString); +var numberToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finiteString, nonFiniteLiterals]), numberFromString); +var BIGINT_PATTERN = "-?\\d+"; +var isStringBigIntRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${BIGINT_PATTERN}$`); +var REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"; +var isStringSymbolRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${REGEXP_PATTERN}$`); +function collectIssues(checks, value, issues, ast, options) { + for (let i = 0;i < checks.length; i++) { + const check = checks[i]; + if (check._tag === "FilterGroup") { + issues = collectIssues(check.checks, value, issues, ast, options); + if (issues && (options.errors !== "all" || issues[issues.length - 1].filter.aborted)) { + return issues; + } + } else { + const issue = check.run(value, ast, options); + if (issue) { + const filter = new Filter(check, issue, value, options); + if (issues) + issues.push(filter); + else + issues = [filter]; + if (options.errors !== "all" || check.aborted) { + return issues; } - return []; - }); - case "Union": { - if (ast.types.length === 0) - return []; - const members = ast.types.map((type) => collectSentinels(toCandidate(type))); - return members[0].filter((s) => members.every((sentinels) => sentinels.some((o) => o.key === s.key && o.literal === s.literal))); + } } - case "Suspend": - return collectSentinels(ast.thunk()); } + return issues; } -var candidateIndexCache = /* @__PURE__ */ new WeakMap; -var emptyCandidates = /* @__PURE__ */ Object.freeze([]); -var hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : (key in input); -function getIndex(types) { - let index = candidateIndexCache.get(types); - if (index) - return index; - let bySentinel; - let sentinelCandidateCount = 0; - let otherwise; - let literalCandidates; - let onlyLiterals = true; - for (let i = 0;i < types.length; i++) { - const a = types[i]; - const encoded = toCandidate(a); - if (isNever2(encoded)) - continue; - if (onlyLiterals) { - if (isLiteral(encoded) || isUniqueSymbol(encoded)) { - literalCandidates ??= new Map; - const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol; - let arr = literalCandidates.get(literal); - if (!arr) - literalCandidates.set(literal, arr = []); - arr.push(a); - } else { - onlyLiterals = false; +function getConstructorDescriptor(ast) { + if (!isDeclaration(ast)) + return; + const getDescriptor = ast.annotations?.[CONSTRUCTOR_ANNOTATION_KEY]; + return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; +} + +// node_modules/effect/dist/Brand.js +function nominal() { + return Object.assign((input) => input, { + option: (input) => some2(input), + result: (input) => succeed2(input), + is: (_) => true + }); +} +// node_modules/effect/dist/Fiber.js +var interrupt3 = fiberInterrupt; +var runIn = fiberRunIn; + +// node_modules/effect/dist/Latch.js +var makeUnsafe4 = makeLatchUnsafe; + +// node_modules/effect/dist/MutableRef.js +var TypeId10 = "~effect/MutableRef"; +var MutableRefProto = { + [TypeId10]: TypeId10, + ...PipeInspectableProto, + toJSON() { + return { + _id: "MutableRef", + current: toJson(this.current) + }; + } +}; +var make6 = (value) => { + const ref = Object.create(MutableRefProto); + ref.current = value; + return ref; +}; + +// node_modules/effect/dist/MutableList.js +var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty"); +var make7 = () => ({ + head: undefined, + tail: undefined, + length: 0 +}); +var emptyBucket = () => ({ + array: [], + mutable: true, + offset: 0, + next: undefined +}); +var append2 = (self, message) => { + if (!self.tail) { + self.head = self.tail = emptyBucket(); + } else if (!self.tail.mutable) { + self.tail.next = emptyBucket(); + self.tail = self.tail.next; + } + self.tail.array.push(message); + self.length++; +}; +var clear = (self) => { + self.head = self.tail = undefined; + self.length = 0; +}; +var takeN = (self, n) => { + n = normalize(n); + if (n <= 0 || !self.head) + return []; + n = Math.min(n, self.length); + if (n === self.length && self.head?.offset === 0 && !self.head.next) { + const array = self.head.array; + clear(self); + return array; + } + const array = new Array(n); + let index = 0; + let chunk = self.head; + while (chunk) { + while (chunk.offset < chunk.array.length) { + array[index++] = chunk.array[chunk.offset]; + if (chunk.mutable) + chunk.array[chunk.offset] = undefined; + chunk.offset++; + if (index === n) { + self.head = chunk; + self.length -= n; + if (self.length === 0) + clear(self); + return array; } } - const sentinels = collectSentinels(encoded); - if (sentinels.length) { - bySentinel ??= new Map; - sentinelCandidateCount++; - for (const { - key, - literal - } of sentinels) { - let entry = bySentinel.get(key); - if (!entry) - bySentinel.set(key, entry = [new Map, new Set]); - entry[1].add(i); - let indexes = entry[0].get(literal); - if (!indexes) - entry[0].set(literal, indexes = new Set); - indexes.add(i); - } + chunk = chunk.next; + } + clear(self); + return array; +}; +var take = (self) => { + if (!self.head) + return Empty; + const message = self.head.array[self.head.offset]; + if (self.head.mutable) + self.head.array[self.head.offset] = undefined; + self.head.offset++; + self.length--; + if (self.head.offset === self.head.array.length) { + if (self.head.next) { + self.head = self.head.next; } else { - otherwise ??= {}; - const candidateTypes = getCandidateTypes(encoded); - for (const t of candidateTypes) - (otherwise[t] ??= []).push(i); + clear(self); } } - if (onlyLiterals && literalCandidates) { - literalCandidates.forEach(Object.freeze); - index = (input) => literalCandidates.get(input) ?? emptyCandidates; - } else if (bySentinel?.size === 1 && !otherwise) { - const [key, [byValue]] = bySentinel.entries().next().value; - const candidates = byValue; - for (const [literal, indexes] of byValue) { - candidates.set(literal, Object.freeze(Array.from(indexes, (index) => types[index]))); - } - index = (input, isConstructor) => { - if (isObjectKeyword(input)) { - const value = hasPropertySignature(input, key) ? input[key] : undefined; - if (value !== undefined) - return candidates.get(value) ?? emptyCandidates; - if (isConstructor) - return types; - } - return emptyCandidates; - }; - } else if (bySentinel) { - let commonSentinel; - for (const entry of bySentinel) { - if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) { - commonSentinel = entry; - } - } - index = (input, isConstructor) => { - const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; - const base = otherwise?.[runtimeType] ?? emptyCandidates; - if (!isObjectKeyword(input)) - return base.map((i) => types[i]); - const selected = new Set(base); - let directKey; - if (commonSentinel) { - const [key, [byValue]] = commonSentinel; - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - if (!match) - return base.map((i) => types[i]); - for (const i of match) - selected.add(i); - directKey = key; - } - } - if (directKey === undefined) { - for (const [key, [byValue, all]] of bySentinel) { - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - if (match) { - for (const i of match) - selected.add(i); - } - } else if (isConstructor) { - for (const i of all) - selected.add(i); - } - } - } - for (const [key, [byValue, all]] of bySentinel) { - if (key === directKey) - continue; - const hasKey = hasPropertySignature(input, key); - const value = hasKey ? input[key] : undefined; - if (hasKey && (!isConstructor || value !== undefined)) { - const match = byValue.get(value); - for (const i of selected) { - if (all.has(i) && !match?.has(i)) - selected.delete(i); - } - } - } - return Array.from(selected).sort((a, b) => a - b).map((i) => types[i]); - }; - } else { - index = (input) => { - const runtimeType = input === null ? "null" : Array.isArray(input) ? "array" : typeof input; - return (otherwise?.[runtimeType] ?? emptyCandidates).map((i) => types[i]).filter(filterLiterals(input)); + return message; +}; + +// node_modules/effect/dist/Queue.js +var TypeId11 = "~effect/Queue"; +var EnqueueTypeId = "~effect/Queue/Enqueue"; +var DequeueTypeId = "~effect/Queue/Dequeue"; +var variance = { + _A: identity, + _E: identity +}; +var QueueProto = { + [TypeId11]: variance, + [EnqueueTypeId]: variance, + [DequeueTypeId]: variance, + ...PipeInspectableProto, + toJSON() { + return { + _id: "effect/Queue", + state: this.state._tag, + size: sizeUnsafe(this) }; } - candidateIndexCache.set(types, index); - return index; -} -function filterLiterals(input) { - return (ast) => { - const encoded = toCandidate(ast); - return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true; +}; +var make8 = (options) => withFiber((fiber) => { + const self = Object.create(QueueProto); + self.dispatcher = fiber.currentDispatcher; + self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY; + self.strategy = options?.strategy ?? "suspend"; + self.messages = make7(); + self.scheduleRunning = false; + self.state = { + _tag: "Open", + takers: new Set, + offers: new Set, + awaiters: new Set }; -} -function getCandidates(input, types, isConstructor = false) { - return getIndex(types)(input, isConstructor); -} -var Union = class extends ASTNodeImpl { - _tag = "Union"; - types; - options; - encodingChecks; - constructor(types, options, annotations, checks, encoding, context, encodingChecks) { - super(annotations, checks, encoding, context); - this.types = types; - this.options = options; - this.encodingChecks = encodingChecks; + return succeed3(self); +}); +var bounded = (capacity) => make8({ + capacity +}); +var offer = (self, message) => suspend(() => { + if (self.state._tag !== "Open") { + return exitFalse; + } else if (self.messages.length >= self.capacity) { + switch (self.strategy) { + case "dropping": + return exitFalse; + case "suspend": + if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return exitTrue; + } + return offerRemainingSingle(self, message); + case "sliding": + take(self.messages); + append2(self.messages, message); + return exitTrue; + } } - getParser(compile, compileConstructorDefault) { - const ast = this; - return (input, options) => { - if (input === missing) { - return missingExit; - } - const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined); - if (candidates.length === 0) { - return fail6(new AnyOf(ast, [], input, options)); - } - if (candidates.length === 1) { - const result = compile(candidates[0])(input, options); - if (result._tag === "Success") - return result; - return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchCause2(result, (cause) => failSingleUnionCandidate(ast, cause, input, options)); - } - const state = { - ast, - compile, - input, - out: undefined, - successes: ast.options?.mode === "oneOf" ? [] : undefined, - issues: undefined, - options - }; - const eff = parseUnion(state, candidates); - if (!eff) { - if (state.out) - return state.out; - return fail6(new AnyOf(ast, state.issues ?? [], input, options)); + append2(self.messages, message); + scheduleReleaseTaker(self); + return exitTrue; +}); +var offerUnsafe = (self, message) => { + if (self.state._tag !== "Open") { + return false; + } else if (self.messages.length >= self.capacity) { + if (self.strategy === "sliding") { + take(self.messages); + append2(self.messages, message); + return true; + } else if (self.capacity <= 0 && self.state.takers.size > 0) { + append2(self.messages, message); + releaseTakers(self); + return true; + } + return false; + } + append2(self.messages, message); + scheduleReleaseTaker(self); + return true; +}; +var failCause4 = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause))); +var failCauseUnsafe = (self, cause) => { + if (self.state._tag !== "Open") { + return false; + } + const exit = exitFailCause(cause); + const fail = exitZipRight(exit, exitFailDone); + if (self.state.offers.size === 0 && self.messages.length === 0) { + finalize(self, fail); + return true; + } + self.state = { + ...self.state, + _tag: "Closing", + exit: fail + }; + return true; +}; +var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done())); +var shutdown = (self) => sync(() => { + if (self.state._tag === "Done") { + return true; + } + clear(self.messages); + const offers = self.state.offers; + finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit); + if (offers.size > 0) { + for (const entry of offers) { + if (entry._tag === "Single") { + entry.resume(exitFalse); + } else { + entry.resume(exitSucceed(entry.remaining.slice(entry.offset))); } - return flatMapEager2(eff, (_) => { - if (state.out === sameExit) - return succeed6(input); - if (state.out) - return state.out; - return fail6(new AnyOf(ast, state.issues ?? [], input, options)); - }); - }; + } + offers.clear(); } - _rebuild(recur, checks, encodingChecks) { - const types = mapOrSame(this.types, recur); - return types === this.types && checks === this.checks && encodingChecks === this.encodingChecks ? this : new Union(types, this.options, this.annotations, checks, undefined, this.context, encodingChecks); + return true; +}); +var takeAll2 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY); +var takeBetween = (self, min, max) => { + min = normalize(min); + max = normalize(max); + return suspend(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self), takeBetween(self, 1, max))); +}; +var take2 = (self) => suspend(() => takeUnsafe(self) ?? andThen(awaitTake(self), take2(self))); +var poll = (self) => suspend(() => { + const result = takeUnsafe(self); + if (result === undefined) { + return succeed3(none2()); } - recur(recur) { - return this._rebuild(recur, this.checks, this.encodingChecks); + if (result._tag === "Success") { + return succeed3(some2(result.value)); } - flip(recur) { - return this._rebuild(recur, this.encodingChecks, this.checks); + return succeed3(none2()); +}); +var takeUnsafe = (self) => { + if (self.state._tag === "Done") { + return self.state.exit; } - matchPart(s, options) { - for (const type of this.types) { - const out = type.matchPart(s, options); - if (out !== undefined) - return out; + if (self.messages.length > 0) { + const message = take(self.messages); + releaseCapacity(self); + return exitSucceed(message); + } else if (self.capacity <= 0 && self.state.offers.size > 0) { + const message = takeOfferUnsafe(self.state.offers); + releaseCapacity(self); + return exitSucceed(message); + } + return; +}; +var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length; +var exitFalse = /* @__PURE__ */ exitSucceed(false); +var exitTrue = /* @__PURE__ */ exitSucceed(true); +var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done()); +var exitInterrupt2 = /* @__PURE__ */ exitInterrupt(); +var releaseTakers = (self) => { + if (self.state._tag === "Done" || self.state.takers.size === 0) { + return; + } + for (const taker of self.state.takers) { + self.state.takers.delete(taker); + taker(exitVoid); + if (self.messages.length === 0) { + break; } + } +}; +var scheduleReleaseTaker = (self) => { + if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) { return; } - getExpected(getExpected) { - const expected = this.annotations?.expected; - if (typeof expected === "string") - return expected; - if (this.types.length === 0) - return "never"; - const types = this.types.map((type) => { - const encoded = toEncoded(type); - switch (encoded._tag) { - case "Arrays": { - const literals = encoded.elements.filter(isLiteral); - if (literals.length > 0) { - return `${formatIsMutable(encoded.isMutable)}[ ${literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ")}, ... ]`; - } - break; - } - case "Objects": { - const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)); - if (literals.length > 0) { - return `{ ${literals.map((ps) => `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${formatIsOptional(ps.type.context?.isOptional)}: ${getExpected(ps.type)}`).join(", ")}, ... }`; - } - break; - } - } - return getExpected(encoded); - }); - return Array.from(new Set(types)).join(" | "); + self.scheduleRunning = true; + self.dispatcher.scheduleTask(() => { + self.scheduleRunning = false; + releaseTakers(self); + }, 0); +}; +var takeBetweenUnsafe = (self, min, max) => { + if (self.state._tag === "Done") { + return self.state.exit; + } else if (max <= 0 || min <= 0) { + return exitSucceed([]); + } else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) { + const messages = [takeOfferUnsafe(self.state.offers)]; + releaseCapacity(self); + return exitSucceed(messages); + } + min = Math.min(min, self.capacity || 1); + if (min <= self.messages.length) { + const messages = takeN(self.messages, max); + releaseCapacity(self); + return exitSucceed(messages); } }; -function failSingleUnionCandidate(ast, cause, input, options) { - const issue = getSchemaIssue(cause); - if (!issue) - return failCause2(cause); - return fail4(new AnyOf(ast, [issue], input, options)); -} -var parseUnion = /* @__PURE__ */ iterateEager()({ - onItem(s, ast) { - const parser = s.compile(ast); - return parser(s.input, s.options); - }, - step(s, candidate, exit) { - if (exit._tag === "Failure") { - const issue = getSchemaIssue(exit.cause); - if (issue === undefined) { - return exit; - } - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - if (s.out && s.successes) { - s.successes.push(candidate); - return fail4(new OneOf(s.ast, s.successes, s.input, s.options)); - } - s.out = exit; - if (s.successes) { - s.successes.push(candidate); - } else { - return void_2; - } +var offerRemainingSingle = (self, message) => { + return callback((resume) => { + if (self.state._tag !== "Open") { + return resume(exitFalse); } + const entry = { + _tag: "Single", + message, + resume + }; + self.state.offers.add(entry); + return sync(() => { + if (self.state._tag === "Open") { + self.state.offers.delete(entry); + } + }); + }); +}; +var takeOfferUnsafe = (offers) => { + const entry = offers.values().next().value; + if (entry._tag === "Single") { + offers.delete(entry); + entry.resume(exitTrue); + return entry.message; } -}); -var nonFiniteLiterals = /* @__PURE__ */ new Union([/* @__PURE__ */ new Literal("Infinity"), /* @__PURE__ */ new Literal("-Infinity"), /* @__PURE__ */ new Literal("NaN")]); -function formatIsMutable(isMutable) { - return isMutable ? "" : "readonly "; -} -function formatIsOptional(isOptional) { - return isOptional ? "?" : ""; -} -var Filter2 = class extends Class { - _tag = "Filter"; - run; - annotations; - aborted; - constructor(run, annotations = undefined, aborted = false) { - super(); - this.run = run; - this.annotations = annotations; - this.aborted = aborted; - } - annotate(annotations) { - return new Filter2(this.run, { - ...this.annotations, - ...annotations - }, this.aborted); + const message = entry.remaining[entry.offset++]; + if (entry.offset === entry.remaining.length) { + offers.delete(entry); + entry.resume(exitSucceed([])); } - abort() { - return new Filter2(this.run, this.annotations, true); + return message; +}; +var releaseCapacity = (self) => { + if (self.state._tag === "Done") { + return isDoneCause(self.state.exit.cause); + } else if (self.state.offers.size === 0) { + if (self.state._tag === "Closing" && self.messages.length === 0) { + finalize(self, self.state.exit); + return isDoneCause(self.state.exit.cause); + } + return false; } - and(other, annotations) { - return new FilterGroup([this, other], annotations); + for (const entry of self.state.offers) { + let n = self.capacity - self.messages.length; + if (n <= 0) + break; + else if (entry._tag === "Single") { + append2(self.messages, entry.message); + self.state.offers.delete(entry); + entry.resume(exitTrue); + } else { + for (;entry.offset < entry.remaining.length; entry.offset++) { + if (n === 0) + return false; + append2(self.messages, entry.remaining[entry.offset]); + n--; + } + self.state.offers.delete(entry); + entry.resume(exitSucceed([])); + } } + return false; }; -var FilterGroup = class extends Class { - _tag = "FilterGroup"; - checks; - annotations; - constructor(checks, annotations = undefined) { - super(); - this.checks = checks; - this.annotations = annotations; +var awaitTake = (self) => callback((resume) => { + if (self.state._tag === "Done") { + return resume(self.state.exit); } - annotate(annotations) { - return new FilterGroup(this.checks, { - ...this.annotations, - ...annotations - }); + self.state.takers.add(resume); + return sync(() => { + if (self.state._tag !== "Done") { + self.state.takers.delete(resume); + } + }); +}); +var finalize = (self, exit) => { + if (self.state._tag === "Done") { + return; } - and(other, annotations) { - return new FilterGroup([this, other], annotations); + const openState = self.state; + self.state = { + _tag: "Done", + exit + }; + for (const taker of openState.takers) { + taker(exit); + } + openState.takers.clear(); + for (const awaiter of openState.awaiters) { + awaiter(exit); } + openState.awaiters.clear(); }; -function makeFilter(filter, annotations, aborted = false) { - return new Filter2((input, ast, options) => normalizeFilterOutput(ast, filter(input, ast, options), input, options), annotations, aborted); -} -function isFinite2(annotations) { - return makeFilter((n) => globalThis.Number.isFinite(n), { - expected: "a finite number", - representation: { - id: "effect/schema/isFinite", - payload: null - }, - toJsonSchema: () => ({ - type: "number" - }), - toCode: () => ({ - runtime: "Schema.isFinite()" - }), - arbitraryConstraint: { - number: "finite" - }, - ...annotations + +// node_modules/effect/dist/Semaphore.js +var makeUnsafe5 = (permits) => new SemaphoreImpl(permits); +var waitForPermits = (self, n, effect) => callback((resume) => { + if (self.free >= n) + return resume(effect); + const observer = () => { + if (self.free < n) + return; + self.waiters.delete(observer); + resume(effect); + }; + self.waiters.add(observer); + return sync(() => { + self.waiters.delete(observer); }); -} -var finite = /* @__PURE__ */ appendChecks(number2, [/* @__PURE__ */ isFinite2()]); -var numberToJson = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finite, nonFiniteLiterals]), /* @__PURE__ */ new Transformation(/* @__PURE__ */ Number3(), /* @__PURE__ */ transform((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n)))); -function isPattern(regExp, annotations) { - const source = regExp.source; - const pattern = new globalThis.RegExp(source, regExp.flags); - return makeFilter((s) => { - pattern.lastIndex = 0; - return pattern.test(s); - }, { - expected: `a string matching the RegExp ${source}`, - representation: { - id: "effect/schema/isPattern", - payload: { - source, - flags: regExp.flags +}); + +class SemaphoreImpl { + waiters = /* @__PURE__ */ new Set; + taken = 0; + permits; + constructor(permits) { + this.permits = permits; + } + get free() { + return this.permits - this.taken; + } + take(n) { + const take = suspend(() => { + if (this.free < n) { + return waitForPermits(this, n, take); } - }, - toJsonSchema: () => ({ - pattern: source - }), - arbitraryConstraint: { - patterns: [{ - source: regExp.source, - flags: regExp.flags - }] - }, - ...annotations - }); -} -function modifyOwnPropertyDescriptors(ast, f) { - const d = Object.getOwnPropertyDescriptors(ast); - f(d); - return Object.create(Object.getPrototypeOf(ast), d); -} -var contextOwners = /* @__PURE__ */ new WeakMap; -function getContextOwner(ast) { - return contextOwners.get(ast) ?? ast; -} -function replaceEncoding(ast, encoding) { - if (ast.encoding === encoding) { - return ast; + this.taken += n; + return succeed3(n); + }); + return take; } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.encoding.value = encoding; - }); -} -function replaceContext(ast, context) { - if (ast.context === context) { - return ast; + takeIfAvailable(n) { + return suspend(() => { + if (this.free < n) + return succeed3(false); + this.taken += n; + return succeed3(true); + }); } - const owner = getContextOwner(ast); - if (owner.context === context) { - return owner; + releaseUnsafe(fiber, n) { + this.taken -= n; + if (this.waiters.size > 0) { + fiber.currentDispatcher.scheduleTask(() => { + for (const observer of this.waiters) { + if (this.free <= 0) + break; + observer(); + } + }, 0); + } + return this.free; } - const out = modifyOwnPropertyDescriptors(ast, (d) => { - d.context.value = context; - }); - contextOwners.set(out, owner); - return out; -} -function getLastEncoding(ast) { - return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast; -} -function annotate(ast, annotations) { - if (ast.checks) { - const last = ast.checks[ast.checks.length - 1]; - return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations))); + resize(permits) { + return withFiber((fiber) => { + this.permits = permits; + if (this.free < 0) + return void_; + this.releaseUnsafe(fiber, 0); + return void_; + }); } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.annotations.value = { - ...d.annotations.value, - ...annotations - }; - }); -} -function replaceChecks(ast, checks) { - if (ast._tag === "Suspend" && checks) { - throw new Error("Cannot add checks to Suspend"); + release(n) { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, n))); } - if (ast.checks === checks) { - return ast; + get releaseAll() { + return withFiber((fiber) => succeed3(this.releaseUnsafe(fiber, this.taken))); } - return modifyOwnPropertyDescriptors(ast, (d) => { - d.checks.value = checks; - }); -} -function appendChecks(ast, checks) { - return replaceChecks(ast, combineChecks(ast.checks, checks)); -} -function mapLink(link, f) { - const to = f(link.to); - return to === link.to ? link : new Link(to, link.transformation); -} -function updateLastLink(encoding, f) { - const links = encoding; - const last = links[links.length - 1]; - const out = mapLink(last, f); - return out === last ? encoding : append(encoding.slice(0, encoding.length - 1), out); -} -function applyToLastLink(f) { - return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast; -} -function applyToSelfOrLastLinkEncodingIdempotent(f, options) { - function out(ast) { - if (ast.encoding) { - const last = ast.encoding[ast.encoding.length - 1]; - return options?.stopAt?.(last) ? ast : replaceEncoding(ast, updateLastLink(ast.encoding, out)); - } - return f(ast); + withPermits(n) { + return (self) => uninterruptibleMask((restore) => { + const acquire = suspend(() => { + if (this.free < n) { + const wait = waitForPermits(this, n, void_); + return flatMap2(restore(wait), () => acquire); + } + this.taken += n; + return onExitPrimitive(restore(self), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); + return acquire; + }); + } + withPermit = /* @__PURE__ */ this.withPermits(1); + withPermitsIfAvailable(n) { + return (self) => uninterruptibleMask((restore) => { + if (this.free < n) + return succeedNone; + this.taken += n; + return onExitPrimitive(restore(asSome(self)), () => { + this.releaseUnsafe(getCurrentFiber(), n); + return; + }, true); + }); } - return memoizeIdempotent(out); -} -function appendTransformation(from, transformation, to) { - const link = new Link(from, transformation); - return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]); } -function mapOrSame(as, f) { - let changed = false; - const out = new Array(as.length); - for (let i = 0;i < as.length; i++) { - const a = as[i]; - const fa = f(a); - if (fa !== a) { - changed = true; - } - out[i] = fa; + +// node_modules/effect/dist/Channel.js +var TypeId12 = "~effect/Channel"; +var isChannel = (u) => hasProperty(u, TypeId12); +var ChannelProto = { + [TypeId12]: { + _Env: identity, + _InErr: identity, + _InElem: identity, + _OutErr: identity, + _OutElem: identity + }, + pipe() { + return pipeArguments(this, arguments); } - return changed ? out : as; -} -function annotateKey(ast, annotations) { - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, { - ...ast.context.annotations, - ...annotations - }) : new Context(false, false, undefined, annotations); - return replaceContext(ast, context); -} -var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { - const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false); - return optionalKeyLastLink(replaceContext(ast, context)); -}); -var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); -function withConstructorDefault(ast, defaultValue) { - const transformation = new Transformation(withDefault(defaultValue), passthrough()); - const constructorDefault = new Link(unknown, transformation); - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) : new Context(false, false, constructorDefault); - return replaceContext(ast, context); -} -function decodeTo(from, to, transformation) { - return appendTransformation(from, transformation, to); -} -function isOptional(ast) { - return ast.context?.isOptional ?? false; -} -function isStructuralCheck(check) { - return check.annotations?.[STRUCTURAL_ANNOTATION_KEY] === true || check._tag === "FilterGroup" && check.checks.every(isStructuralCheck); -} -function extractStructuralChecks(checks) { - function extract(check) { - if (isStructuralCheck(check)) - return [check]; - return check._tag === "FilterGroup" ? check.checks.flatMap(extract) : []; +}; +var fromTransform = (transform) => { + const self = Object.create(ChannelProto); + self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause))); + return self; +}; +var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope))); +var fromPull = (effect) => fromTransform((_, __) => effect); +var fromTransformBracket = (f) => fromTransform(fnUntraced2(function* (upstream, scope) { + const closableScope = forkUnsafe2(scope); + const onCause = (cause) => close(closableScope, doneExitFromCause(cause)); + const pull = yield* onError2(f(upstream, scope, closableScope), onCause); + return onError2(pull, onCause); +})); +var toTransform = (channel) => channel.transform; +var asyncQueue = (scope, f, options) => make8({ + capacity: options?.bufferSize, + strategy: options?.strategy +}).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); +var callbackArray = (f, options) => fromTransform((_, scope) => map5(asyncQueue(scope, f, options), takeAll2)); +var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); +var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done2())); +var map6 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { + let i = 0; + return map5(pull, (o) => f(o, i++)); +}))); +var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); +var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done2))))); +var merge2 = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) { + const strategy = options?.haltStrategy ?? "both"; + const queue = yield* bounded(0); + yield* addFinalizer2(forkedScope, shutdown(queue)); + let done = 0; + function onExit(side, cause) { + done++; + if (!isDoneCause(cause)) { + return failCause4(queue, cause); + } + switch (strategy) { + case "both": { + return done === 2 ? failCause4(queue, cause) : void_3; + } + case "left": + case "right": { + return side === strategy ? failCause4(queue, cause) : void_3; + } + case "either": { + return failCause4(queue, cause); + } + } } - const out = checks.flatMap(extract); - return isArrayNonEmpty2(out) ? out : undefined; -} -var toType = /* @__PURE__ */ memoizeIdempotent((ast) => { - if (ast.encoding) { - return toType(replaceEncoding(ast, undefined)); + const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever2)), onError2((cause) => andThen2(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn2(forkedScope)); + yield* runSide("left", left, forkUnsafe2(forkedScope)); + yield* runSide("right", right, forkUnsafe2(forkedScope)); + return take2(queue); +}))); +var splitLines = () => fromTransform((upstream, _scope) => sync3(() => { + let stringBuilder = ""; + let midCRLF = false; + let done = none2(); + function splitLinesArray(chunk) { + const chunkBuilder = []; + function pushLine(segment) { + if (stringBuilder.length === 0) { + chunkBuilder.push(segment); + } else { + chunkBuilder.push(stringBuilder + segment); + stringBuilder = ""; + } + } + for (let i = 0;i < chunk.length; i++) { + const str = chunk[i]; + if (str.length !== 0) { + let from = 0; + let indexOfCR = str.indexOf("\r"); + let indexOfLF = str.indexOf(` +`); + if (midCRLF) { + if (indexOfLF === 0) { + from = 1; + indexOfLF = str.indexOf(` +`, from); + } + midCRLF = false; + } + while (indexOfCR !== -1 || indexOfLF !== -1) { + if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) { + pushLine(str.substring(from, indexOfLF)); + from = indexOfLF + 1; + indexOfLF = str.indexOf(` +`, from); + } else { + pushLine(str.substring(from, indexOfCR)); + if (str.length === indexOfCR + 1) { + midCRLF = true; + from = str.length; + indexOfCR = -1; + } else { + from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1); + indexOfCR = str.indexOf("\r", from); + indexOfLF = str.indexOf(` +`, from); + } + } + } + stringBuilder = stringBuilder + str.substring(from); + } + } + return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null; } - const out = ast; - const type = out.recur?.(toType) ?? out; - const encodingChecks = type.encodingChecks; - if (encodingChecks) { - const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : undefined; - return modifyOwnPropertyDescriptors(type, (d) => { - d.encodingChecks.value = undefined; - d.checks.value = combineChecks(type.checks, checks); + const pullOrFlush = suspend2(() => { + if (done._tag === "Some") { + return done2(done.value); + } + return matchEffect2(upstream, { + onSuccess: loop, + onFailure: failCause3, + onDone: (leftover) => { + done = some2(leftover); + if (stringBuilder.length > 0) { + const last = stringBuilder; + stringBuilder = ""; + midCRLF = false; + return succeed6([last]); + } + return done2(leftover); + } }); + }); + function loop(chunk) { + const lines = splitLinesArray(chunk); + return lines !== null ? succeed6(lines) : pullOrFlush; } - return type; -}); -var toEncoded = /* @__PURE__ */ memoizeIdempotent((ast) => { - return toType(flip2(ast)); + return pullOrFlush; +})); +var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope)))); +var unwrap = (channel) => fromTransform((upstream, scope) => { + let pull; + return succeed6(suspend2(() => { + if (pull) + return pull; + return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_)); + })); }); -function flipEncoding(ast, encoding) { - const links = encoding; - const len = links.length; - const last = links[len - 1]; - const ls = [new Link(flip2(replaceEncoding(ast, undefined)), links[0].transformation.flip())]; - for (let i = 1;i < len; i++) { - ls.unshift(new Link(flip2(links[i - 1].to), links[i].transformation.flip())); - } - const to = flip2(last.to); - if (to.encoding) { - return replaceEncoding(to, [...to.encoding, ...ls]); - } else { - return replaceEncoding(to, ls); - } -} -var flip2 = /* @__PURE__ */ memoize((ast) => { - if (ast.encoding) { - return flipEncoding(ast, ast.encoding); - } - const out = ast; - return out.flip?.(flip2) ?? out.recur?.(flip2) ?? out; +var runWith = (self, f, onHalt) => suspend2(() => { + const scope = makeUnsafe3(); + const makePull = toTransform(self)(done2(), scope); + return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit2((exit) => close(scope, exit))); }); -function containsUndefined(ast) { - switch (ast._tag) { - case "Undefined": - return true; - case "Union": - return ast.types.some(containsUndefined); - default: - return false; +var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever2(flatMap3(pull, f), { + disableYield: true +}))); +var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() => { + let state = initial(); + return runWith(self, (pull) => whileLoop2({ + while: constTrue, + body: () => pull, + step: (value) => { + state = f(state, value); + } + }), () => succeed6(state)); +})); +var toPullScoped = (self, scope) => toTransform(self)(done2(), scope); +// node_modules/effect/dist/internal/schema/interpreter.js +var flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager2(result, f); +function compileTransformation(transformation) { + if (transformation._tag === "Middleware") { + return (result, current, options) => { + const transformed = result === sameExit ? transformation.decode(succeed7(toOption(current)), options) : transformation.decode(mapEager2(result, toOption), options); + return fromOptionalEffect(transformed); + }; + } + const getter = transformation.decode; + switch (getter._tag) { + case "Passthrough": + return (result, current) => result === sameExit ? succeed7(current) : result; + case "Transform": { + const transform = (value) => value === missing ? missingExit : succeed7(getter.transform(value)); + return (result, current) => flatMapTransformation(result, current, transform); + } + case "TransformOptional": { + const transform = (value) => fromOptionExit(getter.transform(toOption(value))); + return (result, current) => flatMapTransformation(result, current, transform); + } + case "TransformEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => value === missing ? missingExit : getter.transform(value, options)); + case "TransformOptionalEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => fromOptionalEffect(getter.transform(toOption(value), options))); } } -function fromConst(ast, value) { - const succeed = value === 0 ? sameExit : succeed8(value); +var fromOptionalEffect = (effect) => flatMapEager2(effect, fromOptionExit); +var wrapEncoding = (ast, input, options, effect) => catchCause2(effect, (cause) => failCauseSync2(() => map4(cause, (issue) => new Encoding(ast, issue, input, options)))); +function makeConstructorParser(descriptor, compile) { + const transform = compileTransformation(descriptor.link.transformation); + let sourceParser; return (input, options) => { if (input === missing) return missingExit; - if (input === value) - return succeed; - return fail6(new InvalidType(ast, input, options)); + if (descriptor.isConstructed(input)) + return sameExit; + const result = (sourceParser ??= compile(descriptor.link.to))(input, options); + return transform(result, input, options); }; } -function fromRefinement(ast, refinement) { +function withDefault(ast, parser) { + const defaultValue = ast.context.constructorDefault; return (input, options) => { - if (input === missing) - return missingExit; - if (refinement(input)) - return sameExit; - return fail6(new InvalidType(ast, input, options)); + if (input !== missing && input !== undefined) + return parser(input, options); + const result = defaultValue; + if (effectIsExit(result) && result._tag === "Success") { + const local = parser(result[args], options); + return local === sameExit ? result : local; + } + return flatMapEager2(wrapEncoding(ast, input, options, result), (value) => { + const local = parser(value, options); + return local === sameExit ? succeed7(value) : local; + }); }; } -var parameterFromPropertyKey = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => { - switch (ast._tag) { - default: - return ast; - case "Number": - return ast.toCodecStringTree(); - case "Union": - return ast.recur(parameterFromPropertyKey); - } -}); -var isStringFiniteRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${FINITE_PATTERN}$`); -var isStringNumberRegExp = /* @__PURE__ */ new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`); -function isStringFinite(annotations) { - return isPattern(isStringFiniteRegExp, { - expected: "a string representing a finite number", - representation: { - id: "effect/schema/isStringFinite", - payload: null - }, - toJsonSchema: () => ({ - pattern: isStringFiniteRegExp.source - }), - ...annotations - }); +function compileField(ast, compile) { + const parser = compile(ast); + return ast.context?.constructorDefault === undefined ? parser : withDefault(ast, parser); } -var finiteString = /* @__PURE__ */ appendChecks(string2, [/* @__PURE__ */ isStringFinite()]); -var finiteToString = /* @__PURE__ */ new Link(finiteString, numberFromString); -var numberToString = /* @__PURE__ */ new Link(/* @__PURE__ */ new Union([finiteString, nonFiniteLiterals]), numberFromString); -var BIGINT_PATTERN = "-?\\d+"; -var isStringBigIntRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${BIGINT_PATTERN}$`); -var REGEXP_PATTERN = "Symbol\\(([\\s\\S]*)\\)"; -var isStringSymbolRegExp = /* @__PURE__ */ new globalThis.RegExp(`^${REGEXP_PATTERN}$`); -function collectIssues(checks, value, issues, ast, options) { - for (let i = 0;i < checks.length; i++) { - const check = checks[i]; - if (check._tag === "FilterGroup") { - issues = collectIssues(check.checks, value, issues, ast, options); - if (issues && (options.errors !== "all" || issues[issues.length - 1].filter.aborted)) { - return issues; +function compile(ast, compile, compileField, base, specialize) { + if (ast._tag === "Declaration") { + for (const parameter of ast.typeParameters) + compile(parameter); + } + const descriptor = compileField ? getConstructorDescriptor(ast) : undefined; + const parser = descriptor ? makeConstructorParser(descriptor, compile) : base ?? ast.getParser(compile, compileField); + const checks = ast.checks; + const links = ast.encoding; + const transformations = links?.map((link) => compileTransformation(link.transformation)); + const encodingChecks = ast.encodingChecks; + if (!links && !checks && !encodingChecks) { + return parser; + } + let encodingParsers; + const parseChecks = (input, options) => { + let result = parser(input, options); + if (encodingChecks && !options.disableChecks) { + if (effectIsExit(result)) { + if (result._tag === "Success") { + const output = result === sameExit ? input : result[args]; + if (input !== missing && output !== missing) { + const issues = collectIssues(encodingChecks, input, undefined, ast, options); + if (issues) { + result = fail6(new Composite(ast, issues, input, options)); + } + } + } + } else { + result = flatMap3(result, (value) => { + if (input !== missing && value !== missing) { + const issues = collectIssues(encodingChecks, input, undefined, ast, options); + if (issues) { + return fail6(new Composite(ast, issues, input, options)); + } + } + return succeed6(value); + }); } - } else { - const issue = check.run(value, ast, options); - if (issue) { - const filter = new Filter(check, issue, value, options); - if (issues) - issues.push(filter); - else - issues = [filter]; - if (options.errors !== "all" || check.aborted) { - return issues; + } + if (checks && !options.disableChecks) { + if (effectIsExit(result)) { + if (result._tag === "Success") { + const value = result === sameExit ? input : result[args]; + if (value === missing) + return result; + const issues = collectIssues(checks, value, undefined, ast, options); + if (issues) { + result = fail6(new Composite(ast, issues, value, options)); + } } + } else { + result = flatMap3(result, (value) => { + if (value !== missing) { + const issues = collectIssues(checks, value, undefined, ast, options); + if (issues) { + return fail6(new Composite(ast, issues, value, options)); + } + } + return succeed6(value); + }); } } + return result; + }; + const parseLocal = specialize === undefined ? parseChecks : specialize(parseChecks); + if (!links) { + return parseLocal; } - return issues; + return (input, options) => { + const parsers = encodingParsers ??= links.map((link) => compile(link.to)); + let current = input; + let result = parsers[parsers.length - 1](input, options); + for (let i = links.length - 1;i >= 0; i--) { + result = transformations[i](result, current, options); + if (i !== 0) { + const next = parsers[i - 1]; + if (result._tag === "Success") { + current = result[args]; + result = next(current, options); + } else { + result = flatMapEager2(result, (value) => { + const nextResult = next(value, options); + return nextResult === sameExit ? succeed7(value) : nextResult; + }); + } + } + } + if (result._tag === "Success") { + const value = result[args]; + const local = parseLocal(value, options); + return local === sameExit ? result : local; + } + result = wrapEncoding(ast, input, options, result); + return flatMapEager2(result, (value) => { + const local = parseLocal(value, options); + return local === sameExit ? succeed7(value) : local; + }); + }; } -function getConstructorDescriptor(ast) { - if (!isDeclaration(ast)) - return; - const getDescriptor = ast.annotations?.[CONSTRUCTOR_ANNOTATION_KEY]; - return isFunction(getDescriptor) ? getDescriptor(ast.typeParameters) : undefined; + +// node_modules/effect/dist/internal/schema/compilerRegistry.js +var invalid3 = /* @__PURE__ */ Symbol(); +var cache = /* @__PURE__ */ new WeakMap; +var compiler; +var compilerAdaptersEnabled = false; +var decodeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "parser") : resolve2(ast).parser; +var makeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve2, ast, "makeEffect") : resolve2(ast).makeEffect; +var makeField = (ast) => compileField(ast, makeChild); + +class InterpretedEntry { + ast; + constructor(ast) { + this.ast = ast; + } + get decodeEffect() { + return this.cachedDecodeEffect ??= compile(this.ast, decodeChild); + } + get parser() { + return this.decodeEffect; + } + get makeEffect() { + return this.cachedMakeEffect ??= compile(this.ast, makeChild, makeField); + } +} + +class CompilerEntry extends InterpretedEntry { + compiled; + resolve; + constructor(ast, compiled, resolve) { + super(ast); + this.compiled = compiled; + this.resolve = resolve; + } + save(key, value) { + Object.defineProperty(this, key, { + value + }); + return value; + } + operation(key) { + const compiled = this.compiled; + return typeof compiled === "function" ? compiled(this.ast, this.resolve, key) : compiled?.[key]; + } + get is() { + return this.save("is", this.operation("is")); + } + get decode() { + return this.save("decode", this.operation("decode")); + } + get make() { + return this.save("make", this.operation("make")); + } + get decodeEffect() { + return this.save("decodeEffect", this.operation("decodeEffect") ?? compile(this.ast, (ast) => lazyParser(this.resolve, ast, "parser"))); + } + get parser() { + const decode = this.decode; + return decode === undefined ? this.decodeEffect : this.save("parser", withDecode(decode, () => this.decodeEffect)); + } + get makeEffect() { + const makeEffect = this.operation("makeEffect"); + if (makeEffect !== undefined) + return this.save("makeEffect", makeEffect); + const child = (ast) => lazyParser(this.resolve, ast, "makeEffect"); + return this.save("makeEffect", compile(this.ast, child, (ast) => compileField(ast, child))); + } +} +function withDecode(fastDecode, decodeEffect) { + let detailed; + return (input, options) => { + if (input !== missing) { + try { + const value = fastDecode(input, options); + if (value !== invalid3) + return value === input ? sameExit : succeed7(value); + } catch (error) { + return die3(error); + } + } + return (detailed ??= decodeEffect())(input, options); + }; +} +function lazyParser(resolve, ast, operation) { + const entry = resolve(ast); + if (entry.compiled === undefined || Object.hasOwn(entry, operation)) { + return entry[operation]; + } + let parser; + return (input, options) => (parser ??= entry[operation])(input, options); +} +function resolve2(ast) { + const cached = cache.get(ast); + if (cached !== undefined) + return cached; + const entry = compiler === undefined ? new InterpretedEntry(ast) : new CompilerEntry(ast, compiler(ast, resolve2), resolve2); + cache.set(ast, entry); + return entry; } // node_modules/effect/dist/SchemaParser.js @@ -7575,177 +7463,92 @@ function makeOption(schema) { return none2(); }; } -function make14(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return exit.value; - } - const issue = getSchemaIssueOrThrow(exit.cause, "Constructor adapter can only throw schema issues"); - throw new Error("Schema validation failed", { - cause: issue - }); - }; +function make9(schema) { + return makeConstructorSync(toType(schema.ast)); } function decodeUnknownEffect(schema, options) { - const parser = run2(schema.ast); + const parser = run(schema.ast); return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); } var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { ...options, ...overrideOptions } : options; -var getValue = (value) => { - if (value === missing) { - return fail6(new InvalidValue); - } - return succeed6(value); -}; -function run2(ast) { - return runWithCompiler(normalCompiler, ast); -} -function runWithCompiler(compiler, ast) { - let parser; - return (input, options) => { - const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); - if (result === sameExit) { - return succeed6(input); - } - if (!effectIsExit(result)) { - return flatMapEager2(result, getValue); - } - return result[args] === missing ? getValue(missing) : result; - }; -} -var normalCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, normalCompiler)); -var constructorCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault)); -var compileDefaulted = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault, ast.context?.constructorDefault)); -function compileConstructorDefault(ast) { - return ast.context?.constructorDefault ? compileDefaulted(ast) : constructorCompiler(ast); -} -function applyTransformation(result, current, transformation, options) { - let transformed; - if (effectIsExit(result) && result._tag === "Success") { - const optional = toOption(result === sameExit ? current : result[args]); - transformed = transformation._tag === "Transformation" ? transformation.decode.run(optional, options) : transformation.decode(succeed8(optional), options); - } else if (transformation._tag === "Transformation") { - transformed = flatMapEager2(result, (value) => transformation.decode.run(toOption(value), options)); - } else { - transformed = transformation.decode(mapEager2(result, toOption), options); - } - return effectIsExit(transformed) && transformed._tag === "Success" ? fromOptionExit(transformed[args]) : flatMapEager2(transformed, fromOptionExit); -} -function makeConstructorParser(descriptor, compile) { - let sourceParser; - return (input, options) => { - if (input === missing) - return missingExit; - if (descriptor.isConstructed(input)) - return sameExit; - const result = (sourceParser ??= compile(descriptor.link.to))(input, options); - return applyTransformation(result, input, descriptor.link.transformation, options); - }; -} -function makeParser(ast, compile, compileConstructorDefault, constructorDefault) { - const descriptor = compileConstructorDefault ? getConstructorDescriptor(ast) : undefined; - const parser = descriptor ? makeConstructorParser(descriptor, compile) : ast.getParser(compile, compileConstructorDefault); - const checks = ast.checks; - const links = constructorDefault ? ast.encoding ? [...ast.encoding, constructorDefault] : [constructorDefault] : ast.encoding; - const encodingChecks = ast.encodingChecks; - if (!links && !checks && !encodingChecks) { - return parser; - } - let encodingParsers; - const parseLocal = (input, options) => { - let result = parser(input, options); - if (encodingChecks && !options.disableChecks) { - if (effectIsExit(result)) { - if (result._tag === "Success") { - const output = result === sameExit ? input : result[args]; - if (input !== missing && output !== missing) { - const issues = collectIssues(encodingChecks, input, undefined, ast, options); - if (issues) { - result = fail6(new Composite(ast, issues, input, options)); - } - } - } - } else { - result = flatMap3(result, (value) => { - if (input !== missing && value !== missing) { - const issues = collectIssues(encodingChecks, input, undefined, ast, options); - if (issues) { - return fail6(new Composite(ast, issues, input, options)); - } - } - return succeed6(value); - }); - } +var getValue = (value) => { + if (value === missing) { + return fail6(new InvalidValue); + } + return succeed6(value); +}; +function run(ast) { + return runWithCompiler(normalCompiler, ast); +} +function parserResult(result, input) { + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; +} +function runWithCompiler(compiler, ast) { + let parser; + return (input, options) => { + const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); + if (result === sameExit) { + return succeed6(input); } - if (checks && !options.disableChecks) { - if (effectIsExit(result)) { - if (result._tag === "Success") { - const value = result === sameExit ? input : result[args]; - if (value === missing) - return result; - const issues = collectIssues(checks, value, undefined, ast, options); - if (issues) { - result = fail6(new Composite(ast, issues, value, options)); - } - } - } else { - result = flatMap3(result, (value) => { - if (value !== missing) { - const issues = collectIssues(checks, value, undefined, ast, options); - if (issues) { - return fail6(new Composite(ast, issues, value, options)); - } - } - return succeed6(value); - }); - } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); } - return result; + return result[args] === missing ? getValue(missing) : result; }; - if (!links) { - return parseLocal; +} +function runSync2(effect, message) { + const exit = runSyncExit2(effect); + if (isSuccess3(exit)) { + return exit.value; } + const issue = getSchemaIssueOrThrow(exit.cause, message); + throw new Error("Schema validation failed", { + cause: issue + }); +} +function makeConstructorSync(ast) { + let entry; + let parser; return (input, options) => { - const parsers = encodingParsers ??= links.map((link) => compile(link.to)); - let current = input; - let result = parsers[parsers.length - 1](input, options); - for (let i = links.length - 1;i >= 0; i--) { - result = applyTransformation(result, current, links[i].transformation, options); - if (i !== 0) { - const next = parsers[i - 1]; - if (result._tag === "Success") { - current = result[args]; - result = next(current, options); - } else { - result = flatMapEager2(result, (value) => { - const nextResult = next(value, options); - return nextResult === sameExit ? succeed8(value) : nextResult; - }); - } + entry ??= resolve2(ast); + const parseOptions = options?.disableChecks ? options.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions ?? defaultParseOptions; + const make = entry.make; + if (make !== undefined && input !== missing) { + let output; + try { + output = make(input, parseOptions); + } catch (error) { + getSchemaIssueOrThrow(die2(error), "Constructor adapter can only throw schema issues"); + throw error; } + if (output !== invalid3 && output !== missing) + return output; } - if (result._tag === "Success") { - const value = result[args]; - const local = parseLocal(value, options); - return local === sameExit ? result : local; - } - result = catchCause2(result, (cause) => failCauseSync2(() => map5(cause, (issue) => new Encoding(ast, issue, input, options)))); - return flatMapEager2(result, (value) => { - const local = parseLocal(value, options); - return local === sameExit ? succeed8(value) : local; - }); + const result = (parser ??= entry.makeEffect)(input, parseOptions); + return runSync2(parserResult(result, input), "Constructor adapter can only throw schema issues"); }; } +var normalCompiler = (ast) => resolve2(ast).parser; +var constructorCompiler = (ast) => resolve2(ast).makeEffect; // node_modules/effect/dist/internal/schema/make.js -var TypeId20 = "~effect/Schema/Schema"; +var TypeId13 = "~effect/Schema/Schema"; var SchemaProto = { - [TypeId20]: TypeId20, + [TypeId13]: TypeId13, pipe() { return pipeArguments(this, arguments); }, @@ -7759,7 +7562,7 @@ var SchemaProto = { return this.rebuild(appendChecks(this.ast, checks)); } }; -function make15(ast, options) { +function make10(ast, options) { function Schema() {} const self = Object.setPrototypeOf(Schema, SchemaProto); if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) { @@ -7770,9 +7573,9 @@ function make15(ast, options) { Object.assign(self, options); } self.ast = ast; - self.rebuild = (ast) => make15(ast, options); + self.rebuild = (ast) => make10(ast, options); self.makeEffect = makeEffect(self); - self.make = make14(self); + self.make = make9(self); self.makeOption = makeOption(self); return self; } @@ -7787,10 +7590,10 @@ function isSchemaError(u) { } // node_modules/effect/dist/Schema.js -var TypeId21 = TypeId20; +var TypeId14 = TypeId13; function declareConstructor() { return (typeParameters, run, annotations) => { - return make16(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make16(ast))), annotations)); + return make11(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make11(ast))), annotations)); }; } function declare(is, annotations) { @@ -7823,10 +7626,10 @@ function fromIssueEffect(self) { if (effectIsExit(self)) { return fromIssueExit(self); } - return catchCause2(self, (cause) => failCauseSync2(() => map5(cause, (issue) => new SchemaError(issue)))); + return catchCause2(self, (cause) => failCauseSync2(() => map4(cause, (issue) => new SchemaError(issue)))); } function fromIssueExit(exit) { - return isSuccess3(exit) ? exit : failCause2(map5(exit.cause, (issue) => new SchemaError(issue))); + return isSuccess3(exit) ? exit : failCause2(map4(exit.cause, (issue) => new SchemaError(issue))); } function decodeUnknownEffect2(schema, options) { const parser = decodeUnknownEffect(schema, options); @@ -7834,15 +7637,15 @@ function decodeUnknownEffect2(schema, options) { return fromIssueEffect(parser(input, options)); }; } -var make16 = make15; +var make11 = make10; function isSchema(u) { - return hasProperty(u, TypeId21) && u[TypeId21] === TypeId21; + return hasProperty(u, TypeId14) && u[TypeId14] === TypeId14; } -var optionalKey2 = /* @__PURE__ */ lambda((schema) => make16(optionalKey(schema.ast), { +var optionalKey2 = /* @__PURE__ */ lambda((schema) => make11(optionalKey(schema.ast), { schema })); function Literal2(literal) { - const out = make16(new Literal(literal), { + const out = make11(new Literal(literal), { literal, transform(to) { return out.pipe(decodeTo2(Literal2(to), { @@ -7853,10 +7656,10 @@ function Literal2(literal) { }); return out; } -var String4 = /* @__PURE__ */ make16(string2); -var Number5 = /* @__PURE__ */ make16(number2); +var String4 = /* @__PURE__ */ make11(string2); +var Number5 = /* @__PURE__ */ make11(number2); function makeStruct(ast, fields) { - return make16(ast, { + return make11(ast, { fields, mapFields(f, options) { const fields = f(this.fields); @@ -7868,7 +7671,7 @@ function Struct(fields) { return makeStruct(struct(fields, undefined), fields); } function makeTuple(ast, elements) { - return make16(ast, { + return make11(ast, { elements, mapElements(f, options) { const elements = f(this.elements); @@ -7879,11 +7682,11 @@ function makeTuple(ast, elements) { function Tuple(elements) { return makeTuple(tuple(elements), elements); } -var ArraySchema = /* @__PURE__ */ lambda((schema) => make16(new Arrays(false, [], [schema.ast]), { +var ArraySchema = /* @__PURE__ */ lambda((schema) => make11(new Arrays(false, [], [schema.ast]), { value: schema })); function makeUnion(ast, members) { - return make16(ast, { + return make11(ast, { members, mapMembers(f, options) { const members = f(this.members); @@ -7896,7 +7699,7 @@ function Union2(members, options) { } function Literals(literals) { const members = literals.map(Literal2); - return make16(union(members, undefined, undefined), { + return make11(union(members, undefined, undefined), { literals, members, mapMembers(f) { @@ -7912,14 +7715,14 @@ function Literals(literals) { } function decodeTo2(to, transformation) { return (from) => { - return make16(decodeTo(from.ast, to.ast, transformation ? make13(transformation) : passthrough2()), { + return make11(decodeTo(from.ast, to.ast, transformation ? makeTransformation(transformation) : passthrough2()), { from, to }); }; } function withConstructorDefault2(defaultValue) { - return (schema) => make16(withConstructorDefault(schema.ast, defaultValue), { + return (schema) => make11(withConstructorDefault(schema.ast, defaultValue), { schema }); } @@ -7937,7 +7740,7 @@ function instanceOf(constructor, annotations) { } function link() { return (encodeTo, transformation) => { - return new Link(encodeTo.ast, make13(transformation)); + return new Link(encodeTo.ast, makeTransformation(transformation)); }; } var makeFilter2 = makeFilter; @@ -8053,7 +7856,7 @@ var File = /* @__PURE__ */ instanceOf(globalThis.File, { name: String4, lastModified: Int }), transformEffect2({ - decode: (e, options) => match3(decodeBase64(e.data), { + decode: (e, options) => match2(decodeBase64(e.data), { onFailure: () => fail6(new InvalidValue({ expected: "a valid Base64 string" }, e.data, options)), @@ -8181,7 +7984,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { } }); } - static [TypeId21] = TypeId21; + static [TypeId14] = TypeId14; get [ClassTypeId]() { return ClassTypeId; } @@ -8198,7 +8001,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { return getClassSchema(this).rebuild(ast); } static make(input, options) { - return make14(getClassSchema(this))(input ?? {}, options); + return make9(getClassSchema(this))(input ?? {}, options); } static makeOption(input, options) { return makeOption(getClassSchema(this))(input ?? {}, options); @@ -8257,7 +8060,7 @@ function getClassSchemaFactory(from, identifier, annotations) { const ClassTypeId = getClassTypeId(identifier); const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId); const transformation = getClassTransformation(self); - const to = make16(new Declaration([from.ast], () => (input, ast, options) => { + const to = make11(new Declaration([from.ast], () => (input, ast, options) => { return isClassValue(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)); }, { identifier, @@ -8295,98 +8098,336 @@ var TaggedError3 = (identifier) => { return Error4(identifier ?? tagValue)(struct, annotations); }; }; -// src/action/ActionInputs.ts -var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; -var readRawInput = (name) => { - const value = process.env[inputEnvName(name)]; - return value === undefined || value === "" ? undefined : value; +// node_modules/effect/dist/PlatformError.js +var TypeId15 = "~effect/PlatformError"; + +class BadArgument extends (/* @__PURE__ */ TaggedError2("BadArgument")) { + get message() { + return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`; + } +} + +class SystemError extends Error3 { + get message() { + return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`; + } +} + +class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) { + constructor(reason) { + if ("cause" in reason) { + super({ + reason, + cause: reason.cause + }); + } else { + super({ + reason + }); + } + } + [TypeId15] = TypeId15; + get message() { + return this.reason.message; + } +} +var systemError = (options) => new PlatformError(new SystemError(options)); +var badArgument = (options) => new PlatformError(new BadArgument(options)); + +// node_modules/effect/dist/internal/stream.js +var TypeId16 = "~effect/Stream"; +var streamVariance = { + _R: identity, + _E: identity, + _A: identity }; -var readInputs = (names) => { - const inputs = {}; - for (const name of names) { - const value = readRawInput(name); - if (value !== undefined) - inputs[name] = value; +var Stream = function(channel) { + this.channel = channel; +}; +Stream.prototype = { + [TypeId16]: streamVariance, + pipe() { + return pipeArguments(this, arguments); } - return inputs; }; -var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); -// node_modules/effect/dist/Runtime.js -var defaultTeardown = (exit, onExit) => { - if (isSuccess3(exit)) - return onExit(0); - if (hasInterruptsOnly2(exit.cause)) - return onExit(130); - return onExit(getErrorExitCode(squash(exit.cause))); +var fromChannel = (channel) => new Stream(channel); + +// node_modules/effect/dist/Sink.js +var TypeId17 = "~effect/Sink"; +var endVoid = /* @__PURE__ */ succeed6([undefined]); +var sinkVariance = { + _A: identity, + _In: identity, + _L: identity, + _E: identity, + _R: identity }; -var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { - const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { - if (hasInterruptsOnly2(cause)) +var SinkProto = { + [TypeId17]: sinkVariance, + pipe() { + return pipeArguments(this, arguments); + } +}; +var isSink = (u) => hasProperty(u, TypeId17); +var fromChannel2 = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever2({ + disableYield: true +})), catchDone(succeed6))); +var fromTransform2 = (transform) => { + const self = Object.create(SinkProto); + self.transform = transform; + return self; +}; +var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done2))); +var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever2(upstream, { + disableYield: true +}), () => endVoid)); +var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { + discard: true +})); +var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ + disableYield: true +}), catchDone(() => endVoid))); +var unwrap2 = (effect) => fromChannel2(unwrap(map5(effect, toChannel))); + +// node_modules/effect/dist/internal/rcRef.js +var TypeId18 = "~effect/RcRef"; +var stateEmpty = { + _tag: "Empty" +}; +var stateClosed = { + _tag: "Closed" +}; +var variance2 = { + _A: identity, + _E: identity +}; + +class RcRefImpl { + [TypeId18] = variance2; + pipe() { + return pipeArguments(this, arguments); + } + state = stateEmpty; + semaphore = /* @__PURE__ */ makeUnsafe5(1); + acquire; + context; + scope; + idleTimeToLive; + constructor(acquire, context, scope, idleTimeToLive) { + this.acquire = acquire; + this.context = context; + this.scope = scope; + this.idleTimeToLive = idleTimeToLive; + } +} +var make12 = (options) => withFiber2((fiber) => { + const context = fiber.context; + const scope = get(context, Scope); + const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== undefined ? fromInputUnsafe(options.idleTimeToLive) : undefined); + return as2(addFinalizerExit(scope, () => { + const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; + ref.state = stateClosed; + return close2; + }), ref); +}); +var getState = (self) => uninterruptibleMask2(function loop(restore) { + switch (self.state._tag) { + case "Closed": { + return interrupt2; + } + case "Acquired": { + self.state.refCount++; + return self.state.fiber ? as2(interrupt3(self.state.fiber), self.state) : succeed6(self.state); + } + case "Empty": { + const scope = makeUnsafe3(); + return self.semaphore.withPermit(suspend2(() => { + if (self.state._tag !== "Empty") { + return loop(restore); + } + return restore(provideContext2(self.acquire, add(self.context, Scope, scope))).pipe(flatMap3((value) => { + if (self.state._tag === "Closed") { + return interrupt2; + } + const state = { + _tag: "Acquired", + value, + scope, + fiber: undefined, + refCount: 1, + invalidated: false + }; + self.state = state; + return succeed6(state); + }), onExit2((exit) => isFailure3(exit) ? close(scope, exit) : void_3)); + })); + } + } +}); +var get2 = /* @__PURE__ */ fnUntraced2(function* (self_) { + const self = self_; + const state = yield* getState(self); + const scope = yield* scope2; + const isFinite2 = self.idleTimeToLive !== undefined && isFinite(self.idleTimeToLive); + yield* addFinalizerExit(scope, () => { + state.refCount--; + if (state.refCount > 0) { return void_3; - const isReported = getErrorReported(squash(cause)); - return isReported ? logError(cause) : void_3; - })); - try { - const keepAlive = globalThis.setInterval(constVoid, 2147483647); - fiber.addObserver(() => { - clearInterval(keepAlive); - }); - } catch {} - const teardown = options?.teardown ?? defaultTeardown; - return f({ - fiber, - teardown + } + if (self.idleTimeToLive === undefined || state.invalidated) { + if (self.state === state) { + self.state = stateEmpty; + } + return close(state.scope, void_2); + } else if (!isFinite2) { + return void_3; + } + state.fiber = sleep2(self.idleTimeToLive).pipe(flatMap3(() => { + if (self.state === state && state.refCount === 0) { + self.state = stateEmpty; + return close(state.scope, void_2); + } + return void_3; + }), ensuring2(sync3(() => { + state.fiber = undefined; + })), runForkWith2(self.context), runIn(self.scope)); + return void_3; }); + return state.value; }); -var errorExitCode = "~effect/Runtime/errorExitCode"; -var getErrorExitCode = (u) => { - if (typeof u === "object" && u !== null && errorExitCode in u) { - const code = u[errorExitCode]; - if (typeof code === "number") { - return code; + +// node_modules/effect/dist/RcRef.js +var make13 = make12; +var get3 = get2; + +// node_modules/effect/dist/Stream.js +var TypeId19 = "~effect/Stream"; +var isStream = (u) => hasProperty(u, TypeId19); +var fromChannel3 = fromChannel; +var fromPull2 = (pull) => fromChannel3(fromPull(pull)); +var transformPull2 = (self, f) => fromChannel3(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope)))); +var toChannel2 = (stream) => stream.channel; +var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); +var empty4 = /* @__PURE__ */ fromChannel3(empty3); +var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); +var unwrap3 = (effect) => fromChannel3(unwrap(map5(effect, toChannel2))); +var map7 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { + let i = 0; + return fromChannel3(map6(self.channel, map((o) => f(o, i++)))); +})); +var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); +var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { + let done; + let leftover; + const upstreamWithLeftover = suspend2(() => { + if (leftover !== undefined) { + const chunk = leftover; + leftover = undefined; + return succeed6(chunk); } + return upstream; + }).pipe(catch_2((error) => { + done = fail5(error); + return done2(); + })); + const pull = map5(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { + leftover = leftover_; + return of(value); + }); + return suspend2(() => done ? done : pull); +}))); +var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { + const decoder = new TextDecoder(options?.encoding); + return map7(self, (chunk) => decoder.decode(chunk, { + stream: true + })); +})); +var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); +var run2 = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map5(([a]) => a)))); +var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { + for (let i = 0;i < chunk.length; i++) { + acc.push(chunk[i]); } - return 1; -}; -var errorReported = "~effect/Runtime/errorReported"; -var getErrorReported = (u) => { - if (typeof u === "object" && u !== null && errorReported in u) { - const isReported = u[errorReported]; - if (typeof isReported === "boolean") { - return isReported; - } + return acc; +}); +var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channel, initial, (acc, arr) => { + for (let i = 0;i < arr.length; i++) { + acc = f(acc, arr[i]); } - return true; -}; + return acc; +})); +var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => { + let i = 0; + return whileLoop2({ + while: () => i < arr.length, + body: () => f(arr[i++]), + step: constVoid + }); +})); +var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join("")); -// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js -var runMain = /* @__PURE__ */ makeRunMain(({ - fiber, - teardown -}) => { - let receivedSignal = false; - fiber.addObserver((exit) => { - process.removeListener("SIGINT", onSigint); - process.removeListener("SIGTERM", onSigint); - teardown(exit, (code) => { - if (receivedSignal || code !== 0) { - process.exit(code); - } +// node_modules/effect/dist/FileSystem.js +var TypeId20 = "~effect/FileSystem"; +var FileSystem = /* @__PURE__ */ Service("effect/FileSystem"); +var make14 = (impl) => FileSystem.of({ + ...impl, + [TypeId20]: TypeId20, + exists: (path) => pipe(impl.access(path), as2(true), catchTag2("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))), + readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({ + try: () => new TextDecoder(encoding).decode(_), + catch: (cause) => badArgument({ + module: "FileSystem", + method: "readFileString", + description: "invalid encoding", + cause + }) + })), + stream: fnUntraced2(function* (path, options) { + const file = yield* impl.open(path, { + flag: "r" }); - }); - function onSigint() { - receivedSignal = true; - fiber.interruptUnsafe(fiber.id); - } - process.on("SIGINT", onSigint); - process.on("SIGTERM", onSigint); + const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset); + if (offset) { + yield* file.seek(offset, "start"); + } + const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead); + let totalBytesRead = BigInt(0); + const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024)); + const readChunk = file.readAlloc(chunkSize); + return fromPull2(succeed6(flatMap3(suspend2(() => { + if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { + return done2(); + } + return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk; + }), match({ + onNone: () => done2(), + onSome: (buf) => { + totalBytesRead += BigInt(buf.length); + return succeed6(of(buf)); + } + })))); + }, unwrap3), + sink: (path, options) => pipe(impl.open(path, { + ...options, + flag: options?.flag ?? "w" + }), map5((file) => forEach3((_) => file.writeAll(_))), unwrap2), + writeFileString: (path, data, options) => flatMap3(try_2({ + try: () => new TextEncoder().encode(data), + catch: (cause) => badArgument({ + module: "FileSystem", + method: "writeFileString", + description: "could not encode string", + cause + }) + }), (_) => impl.writeFile(path, _, options)) }); +var FileTypeId = "~effect/FileSystem/File"; +class WatchBackend extends (/* @__PURE__ */ Service()("effect/FileSystem/WatchBackend")) { +} -// node_modules/@effect/platform-node/dist/NodeRuntime.js -var runMain2 = runMain; // node_modules/effect/dist/Path.js -var TypeId22 = "~effect/Path"; -var Path2 = /* @__PURE__ */ Service("effect/Path"); +var TypeId21 = "~effect/Path"; +var Path = /* @__PURE__ */ Service("effect/Path"); function normalizeStringPosix(path, allowAboveRoot) { let res = ""; let lastSegmentLength = 0; @@ -8492,7 +8533,7 @@ function fromFileUrl(url) { } return succeed6(decodeURIComponent(pathname)); } -var resolve2 = function resolve() { +var resolve3 = function resolve() { let resolvedPath = ""; let resolvedAbsolute = false; let cwd = undefined; @@ -8529,7 +8570,7 @@ var resolve2 = function resolve() { var CHAR_FORWARD_SLASH = 47; function toFileUrl(filepath) { const outURL = new URL("file://"); - let resolved = resolve2(filepath); + let resolved = resolve3(filepath); const filePathLast = filepath.charCodeAt(filepath.length - 1); if (filePathLast === CHAR_FORWARD_SLASH && resolved[resolved.length - 1] !== "/") { resolved += "/"; @@ -8561,9 +8602,9 @@ function encodePathChars(filepath) { } return filepath; } -var posixImpl = /* @__PURE__ */ Path2.of({ - [TypeId22]: TypeId22, - resolve: resolve2, +var posixImpl = /* @__PURE__ */ Path.of({ + [TypeId21]: TypeId21, + resolve: resolve3, normalize(path) { if (path.length === 0) return "."; @@ -8854,29 +8895,266 @@ var posixImpl = /* @__PURE__ */ Path2.of({ ret.name = path.slice(startPart, startDot); ret.base = path.slice(startPart, end); } - ret.ext = path.slice(startDot, end); - } - if (startPart > 0) - ret.dir = path.slice(0, startPart - 1); - else if (isAbsolute) - ret.dir = "/"; - return ret; + ret.ext = path.slice(startDot, end); + } + if (startPart > 0) + ret.dir = path.slice(0, startPart - 1); + else if (isAbsolute) + ret.dir = "/"; + return ret; + }, + sep: "/", + fromFileUrl, + toFileUrl, + toNamespacedPath: identity +}); +// node_modules/effect/dist/internal/ulid.js +var maxTimestamp = 2 ** 48 - 1; +var base32Chars = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; +var ulidString = (timestampMillis, bytes) => { + if (bytes.length !== 10) { + throw new Error(`ULID randomness must be exactly 10 bytes, received ${bytes.length}`); + } + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxTimestamp); + let out = ""; + for (let shift = 45;shift >= 0; shift -= 5) { + out += base32Chars[Math.floor(timestamp / 2 ** shift) & 31]; + } + let accumulator = 0; + let bits = 0; + for (const byte of bytes) { + accumulator = accumulator << 8 | byte; + bits += 8; + while (bits >= 5) { + bits -= 5; + out += base32Chars[accumulator >>> bits & 31]; + } + accumulator &= (1 << bits) - 1; + } + return out; +}; + +// node_modules/effect/dist/internal/uuid.js +var hex = (byte) => byte.toString(16).padStart(2, "0"); +var stringify = (bytes) => { + const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; + return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); +}; +var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); +function v4Bytes(bytes = randomBytes()) { + bytes[6] = bytes[6] & 15 | 64; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); +var maxV7Timestamp = 2 ** 48 - 1; +function v7Bytes(timestampMillis, bytes = randomBytes()) { + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); + bytes[0] = Math.floor(timestamp / 2 ** 40); + bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; + bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; + bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; + bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; + bytes[5] = timestamp & 255; + bytes[6] = bytes[6] & 15 | 112; + bytes[8] = bytes[8] & 63 | 128; + return bytes; +} +var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); + +// node_modules/effect/dist/Crypto.js +var TypeId22 = "~effect/Crypto"; +var Crypto = /* @__PURE__ */ Service("effect/Crypto"); +var make15 = (impl) => { + const randomBytesUnsafe = impl.randomBytes; + const randomBytes = (size) => map5(validateSize("randomBytes", size), randomBytesUnsafe); + const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; + const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; + const nextIntUnsafe = () => { + while (true) { + const bytes = randomBytesUnsafe(7); + const value = readUint53(bytes); + if ((bytes[0] & 32) === 0) { + return value + Number.MIN_SAFE_INTEGER; + } + if (value < Number.MAX_SAFE_INTEGER) { + return value + 1; + } + } + }; + return Crypto.of({ + [TypeId22]: TypeId22, + randomBytes, + nextDoubleUnsafe, + nextIntUnsafe, + digest: impl.digest, + random: sync3(() => nextDoubleUnsafe()), + randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), + randomInt: sync3(() => nextIntUnsafe()), + randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), + randomIntBetween(min, max, options) { + const extra = options?.halfOpen === true ? 0 : 1; + return sync3(() => { + const minInt = Math.ceil(min); + const maxInt = Math.floor(max); + return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; + }); + }, + randomShuffle: (elements) => sync3(() => { + const buffer = Array.from(elements); + for (let i = buffer.length - 1;i >= 1; i = i - 1) { + const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); + const value = buffer[i]; + buffer[i] = buffer[index]; + buffer[index] = value; + } + return buffer; + }), + randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), + randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))), + randomULID: clockWith2((clock) => succeed6(ulidString(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(10)))) + }); +}; +var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ + module: "Crypto", + method, + description: "size must be a non-negative safe integer" +})); +// node_modules/effect/dist/Ref.js +var TypeId23 = "~effect/Ref"; +var RefProto = { + [TypeId23]: { + _A: identity }, - sep: "/", - fromFileUrl, - toFileUrl, - toNamespacedPath: identity + ...PipeInspectableProto, + toJSON() { + return { + _id: "Ref", + ref: this.ref + }; + } +}; +var makeUnsafe6 = (value) => { + const self = Object.create(RefProto); + self.ref = make6(value); + return self; +}; +var make16 = (value) => sync3(() => makeUnsafe6(value)); +var get4 = (self) => sync3(() => self.ref.current); +var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { + self.ref.current = f(self.ref.current); +})); +// node_modules/effect/dist/Runtime.js +var defaultTeardown = (exit, onExit) => { + if (isSuccess3(exit)) + return onExit(0); + if (hasInterruptsOnly2(exit.cause)) + return onExit(130); + return onExit(getErrorExitCode(squash(exit.cause))); +}; +var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => { + const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => { + if (hasInterruptsOnly2(cause)) + return void_3; + const isReported = getErrorReported(squash(cause)); + return isReported ? logError(cause) : void_3; + })); + try { + const keepAlive = globalThis.setInterval(constVoid, 2147483647); + fiber.addObserver(() => { + clearInterval(keepAlive); + }); + } catch {} + const teardown = options?.teardown ?? defaultTeardown; + return f({ + fiber, + teardown + }); +}); +var errorExitCode = "~effect/Runtime/errorExitCode"; +var getErrorExitCode = (u) => { + if (typeof u === "object" && u !== null && errorExitCode in u) { + const code = u[errorExitCode]; + if (typeof code === "number") { + return code; + } + } + return 1; +}; +var errorReported = "~effect/Runtime/errorReported"; +var getErrorReported = (u) => { + if (typeof u === "object" && u !== null && errorReported in u) { + const isReported = u[errorReported]; + if (typeof isReported === "boolean") { + return isReported; + } + } + return true; +}; +// node_modules/effect/dist/Stdio.js +var TypeId24 = "~effect/Stdio"; +var Stdio = /* @__PURE__ */ Service(TypeId24); +var make17 = (options) => ({ + [TypeId24]: TypeId24, + stdinIsTerminal: succeed6(false), + stdoutIsTerminal: succeed6(false), + ...options }); +// node_modules/effect/dist/Terminal.js +var TypeId25 = "~effect/Terminal"; +var QuitErrorTypeId = "~effect/Terminal/QuitError"; -// node_modules/effect/dist/Brand.js -function nominal() { - return Object.assign((input) => input, { - option: (input) => some2(input), - result: (input) => succeed2(input), - is: (_) => true - }); +class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ + _tag: /* @__PURE__ */ tag("QuitError") +})) { + [QuitErrorTypeId] = QuitErrorTypeId; } +var Terminal = /* @__PURE__ */ Service("effect/Terminal"); +var make18 = (impl) => Terminal.of({ + ...impl, + [TypeId25]: TypeId25 +}); +// src/action/ActionInputs.ts +var inputEnvName = (name) => `INPUT_${name.replace(/ /g, "_").toUpperCase()}`; +var readRawInput = (name) => { + const value = process.env[inputEnvName(name)]; + return value === undefined || value === "" ? undefined : value; +}; +var readInputs = (names) => { + const inputs = {}; + for (const name of names) { + const value = readRawInput(name); + if (value !== undefined) + inputs[name] = value; + } + return inputs; +}; +var decodeInputs = (schema, names) => decodeUnknownEffect2(schema)(readInputs(names)); +// node_modules/@effect/platform-node-shared/dist/NodeRuntime.js +var runMain = /* @__PURE__ */ makeRunMain(({ + fiber, + teardown +}) => { + let receivedSignal = false; + fiber.addObserver((exit) => { + process.removeListener("SIGINT", onSigint); + process.removeListener("SIGTERM", onSigint); + teardown(exit, (code) => { + if (receivedSignal || code !== 0) { + process.exit(code); + } + }); + }); + function onSigint() { + receivedSignal = true; + fiber.interruptUnsafe(fiber.id); + } + process.on("SIGINT", onSigint); + process.on("SIGTERM", onSigint); +}); +// node_modules/@effect/platform-node/dist/NodeRuntime.js +var runMain2 = runMain; // node_modules/effect/dist/unstable/process/ChildProcessSpawner.js var ExitCode = /* @__PURE__ */ nominal(); var ProcessId = /* @__PURE__ */ nominal(); @@ -8894,8 +9172,8 @@ var HandleProto = { var makeHandle = (params) => Object.setPrototypeOf({ ...params }, HandleProto); -var make17 = (spawn) => { - const streamString = (command, options) => spawn(command).pipe(map6((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); +var make19 = (spawn) => { + const streamString = (command, options) => spawn(command).pipe(map5((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); const streamLines = (command, options) => splitLines2(streamString(command, options)); return ChildProcessSpawner.of({ spawn, @@ -8911,7 +9189,7 @@ class ChildProcessSpawner extends (/* @__PURE__ */ Service()("effect/process/Chi } // node_modules/effect/dist/unstable/process/ChildProcess.js -var TypeId23 = "~effect/process/ChildProcess"; +var TypeId26 = "~effect/process/ChildProcess"; var Proto2 = { .../* @__PURE__ */ Prototype2({ label: "Command", @@ -8919,7 +9197,7 @@ var Proto2 = { return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this); } }), - [TypeId23]: TypeId23 + [TypeId26]: TypeId26 }; var makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto2), { _tag: "StandardCommand", @@ -8927,7 +9205,7 @@ var makeStandardCommand = (command, args, options) => Object.assign(Object.creat args, options }); -var make18 = function make(...args) { +var make20 = function make(...args) { if (isTemplateString(args[0])) { const [templates, ...expressions] = args; const tokens = parseTemplates(templates, expressions); @@ -9133,10 +9411,10 @@ var pullIntoWritable = (options) => options.pull.pipe(flatMap3((chunk) => { disableYield: true }), options.endOnDone !== false ? catchDone((_) => { if ("closed" in options.writable && options.writable.closed) { - return done3(_); + return done2(_); } return callback2((resume) => { - const onFinish = () => resume(done3(_)); + const onFinish = () => resume(done2(_)); options.writable.once("finish", onFinish); options.writable.end(); return sync3(() => { @@ -9169,11 +9447,11 @@ var readableToPullUnsafe = (options) => { latch.openUnsafe(); } function onError(error) { - exit.current = fail4(options.onError(error)); + exit.current = fail5(options.onError(error)); latch.openUnsafe(); } function onEnd() { - exit.current = fail4(Done2()); + exit.current = fail5(Done2()); latch.openUnsafe(); } readable.on("readable", onReadable); @@ -9242,9 +9520,9 @@ var isProcessAlive = (childProcess, exitSignal) => { var taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { windowsHide: true }, onExit); -var make19 = /* @__PURE__ */ gen2(function* () { +var make21 = /* @__PURE__ */ gen2(function* () { const fs = yield* FileSystem; - const path = yield* Path2; + const path = yield* Path; const resolveWorkingDirectory = fnUntraced2(function* (options) { if (isUndefined(options.cwd)) return; @@ -9365,7 +9643,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { }); } if (config.stream) { - yield* forkScoped2(run(config.stream, sink)); + yield* forkScoped2(run2(config.stream, sink)); } inputSinks.set(fd, sink); break; @@ -9405,7 +9683,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { }); } if (isStream(config.stream)) { - return as2(forkScoped2(run(config.stream, sink)), sink); + return as2(forkScoped2(run2(config.stream, sink)), sink); } return succeed6(sink); }); @@ -9561,7 +9839,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { env, stdio }, process.platform)), fnUntraced2(function* ([childProcess, exitSignal]) { - const exited = yield* isDone2(exitSignal); + const exited = yield* isDone3(exitSignal); if (exited) { const [code] = yield* _await(exitSignal); if (code !== 0 && isNotNull(code)) { @@ -9603,7 +9881,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds); - const isRunning = map6(isDone2(exitSignal), (done) => !done); + const isRunning = map5(isDone3(exitSignal), (done) => !done); const exitCode = flatMap3(_await(exitSignal), ([code, signal]) => { if (isNotNull(code)) { return succeed6(ExitCode(code)); @@ -9640,7 +9918,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { const sourceStream = unwrap3(succeed6(getSourceStream(handles[handles.length - 1], options.from))); const toOption = options.to ?? "stdin"; if (toOption === "stdin") { - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -9652,7 +9930,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { if (isNotUndefined(fd)) { const fdName2 = fdName(fd); const existingFds = command.options.additionalFds ?? {}; - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, additionalFds: { ...existingFds, @@ -9663,7 +9941,7 @@ var make19 = /* @__PURE__ */ gen2(function* () { } }))); } else { - handles.push(yield* spawnCommand(make18(command.command, command.args, { + handles.push(yield* spawnCommand(make20(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -9702,9 +9980,9 @@ var make19 = /* @__PURE__ */ gen2(function* () { } } }); - return make17(spawnCommand); + return make19(spawnCommand); }); -var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make19); +var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make21); var flattenCommand = (command) => { const commands = []; const pipeOptions = []; @@ -9734,92 +10012,6 @@ var flattenCommand = (command) => { }; }; -// node_modules/effect/dist/internal/uuid.js -var hex = (byte) => byte.toString(16).padStart(2, "0"); -var stringify = (bytes) => { - const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)]; - return segments.map((segment) => Array.from(segment, hex).join("")).join("-"); -}; -var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16)); -function v4Bytes(bytes = randomBytes()) { - bytes[6] = bytes[6] & 15 | 64; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v4String = (bytes) => stringify(bytes === undefined ? v4Bytes() : v4Bytes(bytes)); -var maxV7Timestamp = 2 ** 48 - 1; -function v7Bytes(timestampMillis, bytes = randomBytes()) { - const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp); - bytes[0] = Math.floor(timestamp / 2 ** 40); - bytes[1] = Math.floor(timestamp / 2 ** 32) & 255; - bytes[2] = Math.floor(timestamp / 2 ** 24) & 255; - bytes[3] = Math.floor(timestamp / 2 ** 16) & 255; - bytes[4] = Math.floor(timestamp / 2 ** 8) & 255; - bytes[5] = timestamp & 255; - bytes[6] = bytes[6] & 15 | 112; - bytes[8] = bytes[8] & 63 | 128; - return bytes; -} -var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Bytes(timestampMillis) : v7Bytes(timestampMillis, bytes)); - -// node_modules/effect/dist/Crypto.js -var TypeId24 = "~effect/Crypto"; -var Crypto2 = /* @__PURE__ */ Service("effect/Crypto"); -var make20 = (impl) => { - const randomBytesUnsafe = impl.randomBytes; - const randomBytes = (size) => map6(validateSize("randomBytes", size), randomBytesUnsafe); - const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; - const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; - const nextIntUnsafe = () => { - while (true) { - const bytes = randomBytesUnsafe(7); - const value = readUint53(bytes); - if ((bytes[0] & 32) === 0) { - return value + Number.MIN_SAFE_INTEGER; - } - if (value < Number.MAX_SAFE_INTEGER) { - return value + 1; - } - } - }; - return Crypto2.of({ - [TypeId24]: TypeId24, - randomBytes, - nextDoubleUnsafe, - nextIntUnsafe, - digest: impl.digest, - random: sync3(() => nextDoubleUnsafe()), - randomBoolean: sync3(() => nextDoubleUnsafe() > 0.5), - randomInt: sync3(() => nextIntUnsafe()), - randomBetween: (min, max) => sync3(() => nextBetween(min, max, nextDoubleUnsafe())), - randomIntBetween(min, max, options) { - const extra = options?.halfOpen === true ? 0 : 1; - return sync3(() => { - const minInt = Math.ceil(min); - const maxInt = Math.floor(max); - return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt; - }); - }, - randomShuffle: (elements) => sync3(() => { - const buffer = Array.from(elements); - for (let i = buffer.length - 1;i >= 1; i = i - 1) { - const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1))); - const value = buffer[i]; - buffer[i] = buffer[index]; - buffer[index] = value; - } - return buffer; - }), - randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), - randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))) - }); -}; -var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ - module: "Crypto", - method, - description: "size must be a non-negative safe integer" -})); - // node_modules/@effect/platform-node-shared/dist/NodeCrypto.js import * as NodeCrypto from "node:crypto"; var toHashAlgorithm = (algorithm) => { @@ -9844,20 +10036,20 @@ var digest = (algorithm, data) => try_2({ cause }) }); -var make21 = /* @__PURE__ */ make20({ +var make22 = /* @__PURE__ */ make15({ randomBytes: NodeCrypto.randomBytes, digest }); -var layer2 = /* @__PURE__ */ succeed5(Crypto2, make21); +var layer2 = /* @__PURE__ */ succeed5(Crypto, make22); // node_modules/@effect/platform-node/dist/NodeCrypto.js var layer3 = layer2; // node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js -import * as Crypto3 from "node:crypto"; +import * as Crypto2 from "node:crypto"; import * as NFS from "node:fs"; import * as OS from "node:os"; -import * as Path3 from "node:path"; +import * as Path2 from "node:path"; var handleBadArgument = (method) => (err) => badArgument({ module: "FileSystem", method, @@ -9930,8 +10122,8 @@ var makeTempDirectoryFactory = (method) => { const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException("FileSystem", method), handleBadArgument(method)); return (options) => suspend2(() => { const prefix = options?.prefix ?? ""; - const directory = typeof options?.directory === "string" ? Path3.join(options.directory, ".") : OS.tmpdir(); - return nodeMkdtemp(prefix ? Path3.join(directory, prefix) : directory + "/"); + const directory = typeof options?.directory === "string" ? Path2.join(options.directory, ".") : OS.tmpdir(); + return nodeMkdtemp(prefix ? Path2.join(directory, prefix) : directory + "/"); }); }; var makeTempDirectory = /* @__PURE__ */ makeTempDirectoryFactory("makeTempDirectory"); @@ -9953,7 +10145,7 @@ var makeTempDirectoryScoped = /* @__PURE__ */ (() => { var openFactory = (method) => { const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method)); const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method)); - return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map6((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); + return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map5((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); }; var open2 = /* @__PURE__ */ openFactory("open"); var makeFile = /* @__PURE__ */ (() => { @@ -10002,7 +10194,7 @@ var makeFile = /* @__PURE__ */ (() => { read(buffer) { return suspend2(() => { const position = this.position; - return map6(nodeRead(this.fd, { + return map5(nodeRead(this.fd, { buffer, position }), (bytesRead) => { @@ -10019,7 +10211,7 @@ var makeFile = /* @__PURE__ */ (() => { } const buffer = Buffer.allocUnsafeSlow(size); const position = this.position; - return map6(nodeReadAlloc(this.fd, { + return map5(nodeReadAlloc(this.fd, { buffer, position }), (bytesRead) => { @@ -10040,7 +10232,7 @@ var makeFile = /* @__PURE__ */ (() => { }); } truncate(length) { - return map6(nodeTruncate(this.fd, length || undefined), () => { + return map5(nodeTruncate(this.fd, length || undefined), () => { if (!this.append) { const len = BigInt(length ?? 0); if (this.position > len) { @@ -10052,7 +10244,7 @@ var makeFile = /* @__PURE__ */ (() => { write(buffer) { return suspend2(() => { const position = this.position; - return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map6(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { + return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map5(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { if (!this.append) { this.position = position + BigInt(bytesWritten); } @@ -10090,8 +10282,8 @@ var makeTempFileFactory = (method) => { const makeDirectory = makeTempDirectoryFactory(method); return fnUntraced2(function* (options) { const directory = yield* makeDirectory(options); - const random = Crypto3.randomBytes(6).toString("hex"); - const name = Path3.join(directory, options?.suffix ? `${random}${options.suffix}` : random); + const random = Crypto2.randomBytes(6).toString("hex"); + const name = Path2.join(directory, options?.suffix ? `${random}${options.suffix}` : random); yield* writeFile2(name, new Uint8Array(0)); return name; }); @@ -10100,7 +10292,7 @@ var makeTempFile = /* @__PURE__ */ makeTempFileFactory("makeTempFile"); var makeTempFileScoped = /* @__PURE__ */ (() => { const makeFile = /* @__PURE__ */ makeTempFileFactory("makeTempFileScoped"); const removeDirectory = /* @__PURE__ */ removeFactory("makeTempFileScoped"); - return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path3.dirname(file), { + return (options) => acquireRelease2(makeFile(options), (file) => orDie2(removeDirectory(Path2.dirname(file), { recursive: true }))); })(); @@ -10173,7 +10365,7 @@ var utimes2 = /* @__PURE__ */ (() => { return (path, atime, mtime) => nodeUtimes(path, atime, mtime); })(); var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sync3(() => { - const directory = info.type === "Directory" ? path : Path3.dirname(path); + const directory = info.type === "Directory" ? path : Path2.dirname(path); const watcher = NFS.watch(path, { recursive: options?.recursive ?? false }, (event, path) => { @@ -10181,7 +10373,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy return; switch (event) { case "rename": { - runFork2(matchEffect3(stat2(Path3.resolve(directory, path)), { + runFork2(matchEffect3(stat2(Path2.resolve(directory, path)), { onSuccess: (_) => offer(queue, { _tag: "Create", path @@ -10203,7 +10395,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy } }); watcher.on("error", (error) => { - failCauseUnsafe(queue, fail5(systemError({ + failCauseUnsafe(queue, fail4(systemError({ module: "FileSystem", _tag: "Unknown", method: "watch", @@ -10216,7 +10408,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy }); return watcher; }), (watcher) => sync3(() => watcher.close()))); -var watch2 = (backend, path, options) => stat2(path).pipe(map6((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); +var watch2 = (backend, path, options) => stat2(path).pipe(map5((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); var writeFile2 = (path, data, options) => callback2((resume, signal) => { try { NFS.writeFile(path, data, { @@ -10234,7 +10426,7 @@ var writeFile2 = (path, data, options) => callback2((resume, signal) => { resume(fail6(handleBadArgument("writeFile")(err))); } }); -var makeFileSystem = /* @__PURE__ */ map6(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make11({ +var makeFileSystem = /* @__PURE__ */ map5(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make14({ access: access2, chmod: chmod2, chown: chown2, @@ -10293,18 +10485,18 @@ var fileUrlOps = (windows) => ({ }) }) }); -var layerPosix = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layerPosix = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.posix, .../* @__PURE__ */ fileUrlOps(false) }); -var layerWin32 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layerWin32 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath.win32, .../* @__PURE__ */ fileUrlOps(true) }); -var layer6 = /* @__PURE__ */ succeed5(Path2)({ - [TypeId22]: TypeId22, +var layer6 = /* @__PURE__ */ succeed5(Path)({ + [TypeId21]: TypeId21, ...NodePath, .../* @__PURE__ */ fileUrlOps(undefined) }); @@ -10312,18 +10504,8 @@ var layer6 = /* @__PURE__ */ succeed5(Path2)({ // node_modules/@effect/platform-node/dist/NodePath.js var layer7 = layer6; -// node_modules/effect/dist/Stdio.js -var TypeId25 = "~effect/Stdio"; -var Stdio2 = /* @__PURE__ */ Service(TypeId25); -var make22 = (options) => ({ - [TypeId25]: TypeId25, - stdinIsTerminal: succeed6(false), - stdoutIsTerminal: succeed6(false), - ...options -}); - // node_modules/@effect/platform-node-shared/dist/NodeStdio.js -var layer8 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make22({ +var layer8 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make17({ args: /* @__PURE__ */ sync3(() => process.argv.slice(2)), stdinIsTerminal: /* @__PURE__ */ sync3(() => process.stdin.isTTY === true), stdoutIsTerminal: /* @__PURE__ */ sync3(() => process.stdout.isTTY === true), @@ -10362,24 +10544,9 @@ var layer8 = /* @__PURE__ */ succeed5(Stdio2, /* @__PURE__ */ make22({ // node_modules/@effect/platform-node/dist/NodeStdio.js var layer9 = layer8; -// node_modules/effect/dist/Terminal.js -var TypeId26 = "~effect/Terminal"; -var QuitErrorTypeId = "~effect/Terminal/QuitError"; - -class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ - _tag: /* @__PURE__ */ tag("QuitError") -})) { - [QuitErrorTypeId] = QuitErrorTypeId; -} -var Terminal2 = /* @__PURE__ */ Service("effect/Terminal"); -var make23 = (impl) => Terminal2.of({ - ...impl, - [TypeId26]: TypeId26 -}); - // node_modules/@effect/platform-node-shared/dist/NodeTerminal.js import * as readline from "node:readline"; -var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { +var make23 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { const stdin = process.stdin; const stdout = process.stdout; const lines = yield* make8(); @@ -10393,7 +10560,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu }; stdin.once("end", onStdinEnd); yield* addFinalizer3(() => sync3(() => stdin.off("end", onStdinEnd))); - const rlRef = yield* make10({ + const rlRef = yield* make13({ acquire: acquireRelease2(sync3(() => { const rl = readline.createInterface({ input: stdin, @@ -10484,7 +10651,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu cause: err })))); })); - return make23({ + return make18({ columns, rows, readInput, @@ -10492,7 +10659,7 @@ var make24 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu display }); }); -var layer10 = /* @__PURE__ */ effect(Terminal2, /* @__PURE__ */ make24(defaultShouldQuit)); +var layer10 = /* @__PURE__ */ effect(Terminal, /* @__PURE__ */ make23(defaultShouldQuit)); function defaultShouldQuit(input) { return input.key.ctrl && (input.key.name === "c" || input.key.name === "d"); } @@ -10547,7 +10714,7 @@ var layer13 = sync2(Service2, () => { class TestService extends Service()("@timmo001/workflows/Annotations/Test") { } var testLayer = effectContext(gen2(function* () { - const recorded = yield* make12([]); + const recorded = yield* make16([]); const write = (line) => update(recorded, (lines) => [...lines, line]); const service = TestService.of({ error: fn2("Annotations.Test.error")(function* (message, properties) { @@ -10569,7 +10736,7 @@ var testLayer = effectContext(gen2(function* () { return yield* get4(recorded); }) }); - return empty().pipe(add(Service2, service), add(TestService, service)); + return empty2().pipe(add(Service2, service), add(TestService, service)); })); class ActionFailure extends TaggedError3()("ActionFailure", { @@ -10592,7 +10759,7 @@ class Service3 extends Service()("@timmo001/workflows/CommandExecutor") { } var layer14 = effect(Service3, gen2(function* () { const spawner = yield* ChildProcessSpawner; - const make = (command, args, options) => make18(command, args, { + const make = (command, args, options) => make20(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true @@ -10631,7 +10798,7 @@ var layer14 = effect(Service3, gen2(function* () { const stream = fn2("CommandExecutor.stream")(function* (command, args, options) { const label = options?.label ?? `${command} ${args.join(" ")}`.trim(); return yield* scoped2(gen2(function* () { - const handle = yield* spawner.spawn(make18(command, args, { + const handle = yield* spawner.spawn(make20(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true, diff --git a/.github/actions/validate-json/dist/index.js b/.github/actions/validate-json/dist/index.js index 64d12dc9..0b6d713f 100644 --- a/.github/actions/validate-json/dist/index.js +++ b/.github/actions/validate-json/dist/index.js @@ -1285,9 +1285,7 @@ var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone var fromNullishOr = (a) => a == null ? none2() : some2(a); var fromUndefinedOr = (a) => a === undefined ? none2() : some2(a); var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined); -var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value))); var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value)); -var filter = /* @__PURE__ */ dual(2, (self, predicate) => isNone2(self) ? none2() : predicate(self.value) ? some2(self.value) : none2()); // node_modules/effect/dist/Context.js var ServiceTypeId = "~effect/Context/Service"; @@ -1527,7 +1525,7 @@ var isArrayNonEmpty2 = isArrayNonEmpty; var isReadonlyArrayNonEmpty = isArrayNonEmpty; var empty2 = () => []; var of = (a) => [a]; -var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); +var map = /* @__PURE__ */ dual(2, (self, f) => self.map(f)); // node_modules/effect/dist/Duration.js var TypeId4 = "~effect/Duration"; @@ -3057,7 +3055,7 @@ var tapCont = function(value) { var tapEffectCont = function(value) { return new ContImpl(this.payload, returnPayload, exitSucceed(value)); }; -var asSome = (self) => map4(self, some2); +var asSome = (self) => map3(self, some2); var andThen = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? returnPayload : andThenCont, f)); var tap = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect(f) ? tapEffectCont : tapCont, f)); var asVoid = (self) => new ContImpl(self, returnPayload, exitVoid); @@ -3099,8 +3097,8 @@ var flatMapEager = /* @__PURE__ */ dual(2, (self, f) => { } return flatMap2(self, f); }); -var map4 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); -var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map4(self, f)); +var map3 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, mapCont, f)); +var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map3(self, f)); var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError(self, f)); var exitInterrupt = (fiberId) => exitFailCause(causeInterrupt(fiberId)); var exitIsSuccess = (self) => self._tag === "Success"; @@ -3475,7 +3473,7 @@ var all = (arg, options) => { } return suspend(() => { const out = {}; - return as(forEach(Object.entries(arg), ([key, effect]) => map4(options?.mode === "result" ? result(effect) : effect, (value) => { + return as(forEach(Object.entries(arg), ([key, effect]) => map3(options?.mode === "result" ? result(effect) : effect, (value) => { assignProperty(out, key, value); }), { discard: true, @@ -4189,8 +4187,9 @@ var tracerLogger = /* @__PURE__ */ loggerMake(({ var isFailReason2 = isFailReason; var fromReasons = causeFromReasons; var fail4 = causeFail; +var die2 = causeDie; var hasInterruptsOnly2 = hasInterruptsOnly; -var map5 = causeMap; +var map4 = causeMap; var squash = causeSquash; var isDone2 = isDone; var Done2 = Done; @@ -4349,7 +4348,7 @@ class CurrentMemoMap extends (/* @__PURE__ */ Service()("effect/Layer/CurrentMem return current ? forkMemoMapUnsafe(current) : makeMemoMapUnsafe(); } } -var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map4(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); +var buildWithMemoMap = /* @__PURE__ */ dual(3, (self, memoMap, scope) => provideService(map3(self.build(memoMap, scope), add(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap)); var buildWithScope = /* @__PURE__ */ dual(2, (self, scope) => withFiber((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope))); var succeed5 = function() { if (arguments.length === 1) { @@ -4371,16 +4370,16 @@ var effect = function() { } return effectImpl(arguments[0], arguments[1]); }; -var effectImpl = (service, effect) => effectContext(map4(effect, (value) => make2(service, value))); +var effectImpl = (service, effect) => effectContext(map3(effect, (value) => make2(service, value))); var effectContext = (effect) => fromBuildMemo((_, scope) => provide(effect, scope)); var mergeAllEffect = (layers, memoMap, scope) => { const parentScope = forkUnsafe2(scope, "parallel"); return forEach(layers, (layer) => layer.build(memoMap, forkUnsafe2(parentScope, "sequential")), { concurrency: layers.length - }).pipe(map4((context) => mergeAll(...context))); + }).pipe(map3((context) => mergeAll(...context))); }; var mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope)); -var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map4((merged) => f(merged, context))))); +var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map3((merged) => f(merged, context))))); var provide2 = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, identity)); var provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self))); @@ -4445,7 +4444,6 @@ var forEach2 = forEach; var whileLoop2 = whileLoop; var tryPromise2 = tryPromise; var succeed6 = succeed3; -var succeedNone2 = succeedNone; var suspend2 = suspend; var sync3 = sync; var void_3 = void_; @@ -4454,7 +4452,7 @@ var gen2 = gen; var fail6 = fail3; var failCause3 = failCause; var failCauseSync2 = failCauseSync; -var die2 = die; +var die3 = die; var try_2 = try_; var withFiber2 = withFiber; var fromResult2 = fromResult; @@ -4462,7 +4460,7 @@ var flatMap3 = flatMap2; var andThen2 = andThen; var tap2 = tap; var exit2 = exit; -var map6 = map4; +var map5 = map3; var as2 = as; var catch_2 = catch_; var catchTag2 = catchTag; @@ -4508,7 +4506,7 @@ var effectify = (fn, onError, onSyncError) => (...args) => callback2((resume) => } }); } catch (err) { - resume(onSyncError ? fail6(onSyncError(err, args)) : die2(err)); + resume(onSyncError ? fail6(onSyncError(err, args)) : die3(err)); } }); var mapEager2 = mapEager; @@ -4693,7 +4691,7 @@ var fromNumber = (input) => { } return make5(BigInt(input)); }; -var parse = (input) => { +var fromStringUnsafe = (input) => { const match = /^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(input); if (match === null) return invalid2(`unsupported syntax ${JSON.stringify(input)}`); @@ -4717,7 +4715,7 @@ var fromInputUnsafe2 = (input) => { case "number": return fromNumber(input); case "string": - return parse(input); + return fromStringUnsafe(input); } return invalid2(`unsupported input ${input}`); }; @@ -5286,12 +5284,12 @@ var asyncQueue = (scope, f, options) => make8({ capacity: options?.bufferSize, strategy: options?.strategy }).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => forkIn2(provide(f(queue), scope), scope))); -var callbackArray = (f, options) => fromTransform((_, scope) => map6(asyncQueue(scope, f, options), takeAll2)); +var callbackArray = (f, options) => fromTransform((_, scope) => map5(asyncQueue(scope, f, options), takeAll2)); var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope))); var empty3 = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done2())); -var map7 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { +var map6 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync3(() => { let i = 0; - return map6(pull, (o) => f(o, i++)); + return map5(pull, (o) => f(o, i++)); }))); var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o)))); var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done) => flatMap3(f(done), done2))))); @@ -5484,7 +5482,7 @@ var forEach3 = (f) => forEachArray(forEach2((_) => f(_), { var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever2({ disableYield: true }), catchDone(() => endVoid))); -var unwrap2 = (effect) => fromChannel2(unwrap(map6(effect, toChannel))); +var unwrap2 = (effect) => fromChannel2(unwrap(map5(effect, toChannel))); // node_modules/effect/dist/internal/rcRef.js var TypeId13 = "~effect/RcRef"; @@ -5520,7 +5518,7 @@ class RcRefImpl { var make9 = (options) => withFiber2((fiber) => { const context = fiber.context; const scope = get(context, Scope); - const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive ? fromInputUnsafe(options.idleTimeToLive) : undefined); + const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== undefined ? fromInputUnsafe(options.idleTimeToLive) : undefined); return as2(addFinalizerExit(scope, () => { const close2 = ref.state._tag === "Acquired" ? close(ref.state.scope, void_2) : void_3; ref.state = stateClosed; @@ -5607,10 +5605,10 @@ var toChannel2 = (stream) => stream.channel; var callback3 = (f, options) => fromChannel3(callbackArray(f, options)); var empty4 = /* @__PURE__ */ fromChannel3(empty3); var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel)); -var unwrap3 = (effect) => fromChannel3(unwrap(map6(effect, toChannel2))); -var map8 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { +var unwrap3 = (effect) => fromChannel3(unwrap(map5(effect, toChannel2))); +var map7 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => { let i = 0; - return fromChannel3(map7(self.channel, map2((o) => f(o, i++)))); + return fromChannel3(map6(self.channel, map((o) => f(o, i++)))); })); var merge3 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel3(merge2(toChannel2(self), toChannel2(that), options))); var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync3(() => { @@ -5627,7 +5625,7 @@ var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (up done = fail5(error); return done2(); })); - const pull = map6(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { + const pull = map5(suspend2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => { leftover = leftover_; return of(value); }); @@ -5635,12 +5633,12 @@ var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (up }))); var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => { const decoder = new TextDecoder(options?.encoding); - return map8(self, (chunk) => decoder.decode(chunk, { + return map7(self, (chunk) => decoder.decode(chunk, { stream: true })); })); var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3); -var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map6(([a]) => a)))); +var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => sink.transform(upstream, scope)), map5(([a]) => a)))); var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => { for (let i = 0;i < chunk.length; i++) { acc.push(chunk[i]); @@ -5707,7 +5705,7 @@ var make11 = (impl) => FileSystem.of({ sink: (path, options) => pipe(impl.open(path, { ...options, flag: options?.flag ?? "w" - }), map6((file) => forEach3((_) => file.writeAll(_))), unwrap2), + }), map5((file) => forEach3((_) => file.writeAll(_))), unwrap2), writeFileString: (path, data, options) => flatMap3(try_2({ try: () => new TextEncoder().encode(data), catch: (cause) => badArgument({ @@ -6365,7 +6363,7 @@ function normalizeFilterOutput(ast, out, input, options) { if (!isReadonlyArrayNonEmpty(out)) { return; } - return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map2(out, (entry) => makeFilterIssue(entry, input, options)), input, options); + return out.length === 1 ? makeFilterIssue(out[0], input, options) : new Composite(ast, map(out, (entry) => makeFilterIssue(entry, input, options)), input, options); } return makeSingle(out, input, options); } @@ -6493,48 +6491,23 @@ function getSchemaIssueOrThrow(cause, message) { } // node_modules/effect/dist/SchemaGetter.js -var Getter = class extends Class { - run; - constructor(run) { - super(); - this.run = run; - } - map(f) { - return new Getter((oe, options) => this.run(oe, options).pipe(mapEager2(map(f)))); - } - compose(other) { - if (isPassthrough(this)) { - return other; - } - if (isPassthrough(other)) { - return this; - } - return new Getter((oe, options) => this.run(oe, options).pipe(flatMapEager2((ot) => other.run(ot, options)))); - } -}; -var passthrough_ = /* @__PURE__ */ new Getter(succeed6); -function isPassthrough(getter) { - return getter.run === passthrough_.run; -} +var makeGetter = (fields) => Object.assign(Object.create(Prototype), fields); +var passthrough_ = /* @__PURE__ */ makeGetter({ + _tag: "Passthrough" +}); function passthrough() { return passthrough_; } -function onSome(f) { - return new Getter((oe, options) => isNone2(oe) ? succeedNone2 : f(oe.value, options)); -} function transform(f) { - return transformOptional(map(f)); + return makeGetter({ + _tag: "Transform", + transform: f + }); } function transformEffect(f) { - return onSome((e, options) => f(e, options).pipe(mapEager2(some2))); -} -function transformOptional(f) { - return new Getter((oe) => succeed6(f(oe))); -} -function withDefault(defaultValue) { - return new Getter((o) => { - const filtered = filter(o, isNotUndefined); - return isSome2(filtered) ? succeed6(filtered) : mapEager2(defaultValue, some2); + return makeGetter({ + _tag: "TransformEffect", + transform: f }); } function String2() { @@ -6544,21 +6517,21 @@ function Number3() { return transform(globalThis.Number); } function parseJson(options) { - return onSome((input, parseOptions) => try_2({ - try: () => some2(JSON.parse(input, options?.reviver)), + return transformEffect((input, parseOptions) => try_2({ + try: () => JSON.parse(input, options?.reviver), catch: () => new InvalidValue({ expected: "a valid JSON string" }, input, parseOptions) })); } function stringifyJson(options) { - return onSome((input, parseOptions) => try_2({ + return transformEffect((input, parseOptions) => try_2({ try: () => { const output = JSON.stringify(input, options?.replacer, options?.space); if (output === undefined) { throw new TypeError("Value cannot be represented as JSON"); } - return some2(output); + return output; }, catch: () => new InvalidValue({ expected: "a JSON-serializable value" @@ -6576,26 +6549,24 @@ function decodeBase642() { // node_modules/effect/dist/SchemaTransformation.js var TypeId18 = "~effect/SchemaTransformation/Transformation"; -var Transformation = class { +var Transformation = class extends Class { [TypeId18] = TypeId18; _tag = "Transformation"; decode; encode; constructor(decode, encode) { + super(); this.decode = decode; this.encode = encode; } flip() { return new Transformation(this.encode, this.decode); } - compose(other) { - return new Transformation(this.decode.compose(other.decode), other.encode.compose(this.encode)); - } }; function isTransformation(u) { return hasProperty(u, TypeId18) && u[TypeId18] === TypeId18; } -var make12 = (options) => { +var makeTransformation = (options) => { if (isTransformation(options)) { return options; } @@ -6833,7 +6804,7 @@ var Arrays = class extends ASTNodeImpl { } } } - getParser(compile, compileConstructorDefault = compile) { + getParser(compile, compileField = compile) { const ast = this; let elements; let rest; @@ -6857,11 +6828,11 @@ var Arrays = class extends ASTNodeImpl { if (!elements) { elements = ast.elements.map((ast) => ({ ast, - parser: compileConstructorDefault(ast) + parser: compileField(ast) })); rest = ast.rest.map((ast) => ({ ast, - parser: compileConstructorDefault(ast) + parser: compileField(ast) })); } const len = input.length; @@ -6918,33 +6889,34 @@ var Arrays = class extends ASTNodeImpl { return "array"; } }; +function stepArray(s, item, exit, i) { + if (exit._tag === "Failure") { + return wrapPropertyKeyIssue(s, s.ast, i, exit); + } + const value = exit === sameExit ? item : exit[args]; + if (value !== missing) { + s.output[i] = value; + } else { + const p = s.getParser(s.tailThreshold, i); + if (isOptional(p.ast)) + return; + const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); + if (s.options.errors === "all") { + if (s.issues) + s.issues.push(issue); + else + s.issues = [issue]; + } else { + return fail5(new Composite(s.ast, [issue], s.input, s.options)); + } + } +} var parseArrayOptions = { onItem(s, item, i) { const value = i < s.len ? item : missing; return s.getParser(s.tailThreshold, i).parser(value, s.options); }, - step(s, item, exit, i) { - if (exit._tag === "Failure") { - return wrapPropertyKeyIssue(s, s.ast, i, exit); - } - const value = exit === sameExit ? item : exit[args]; - if (value !== missing) { - s.output[i] = value; - } else { - const p = s.getParser(s.tailThreshold, i); - if (isOptional(p.ast)) - return; - const issue = new Pointer([i], new MissingKey(p.ast.context?.annotations)); - if (s.options.errors === "all") { - if (s.issues) - s.issues.push(issue); - else - s.issues = [issue]; - } else { - return fail5(new Composite(s.ast, [issue], s.input, s.options)); - } - } - } + step: stepArray }; var parseArray = /* @__PURE__ */ iterateEager()(parseArrayOptions); var parseArrayConcurrent = /* @__PURE__ */ iterateConcurrent()(parseArrayOptions); @@ -6954,7 +6926,7 @@ var wrapPropertyKeyIssue = (s, ast, key, exit) => { } const issue = getSchemaIssue(exit.cause); if (issue === undefined) { - return failCause2(map5(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); + return failCause2(map4(exit.cause, (issue) => new Composite(ast, [new Pointer([key], issue)], s.input, s.options))); } const pointer = new Pointer([key], issue); if (s.options.errors === "all") { @@ -7063,7 +7035,7 @@ var Objects = class extends ASTNodeImpl { throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`); } } - getParser(compile, compileConstructorDefault = compile) { + getParser(compile, compileField = compile) { const ast = this; const expectedKeys = []; for (const ps of ast.propertySignatures) { @@ -7117,14 +7089,14 @@ var Objects = class extends ASTNodeImpl { const compileMembers = () => { if (!properties) { properties = ast.propertySignatures.map((ps) => ({ - parser: compileConstructorDefault(ps.type), + parser: compileField(ps.type), name: ps.name, type: ps.type })); indexes = indexCount ? ast.indexSignatures.map((is) => ({ is, parserKey: compile(parameterFromPropertyKey(is.parameter)), - parserValue: compileConstructorDefault(is.type) + parserValue: compileField(is.type) })) : undefined; } return properties; @@ -7270,7 +7242,7 @@ var Objects = class extends ASTNodeImpl { return terminal; } } catch (error) { - return die2(error); + return die3(error); } return succeed8(out); }; @@ -7619,13 +7591,13 @@ var Union = class extends ASTNodeImpl { this.options = options; this.encodingChecks = encodingChecks; } - getParser(compile, compileConstructorDefault) { + getParser(compile, compileField) { const ast = this; return (input, options) => { if (input === missing) { return missingExit; } - const candidates = getCandidates(input, ast.types, compileConstructorDefault !== undefined); + const candidates = getCandidates(input, ast.types, compileField !== undefined); if (candidates.length === 0) { return fail6(new AnyOf(ast, [], input, options)); } @@ -7955,9 +7927,7 @@ var optionalKey = /* @__PURE__ */ memoizeIdempotent((ast) => { }); var optionalKeyLastLink = /* @__PURE__ */ applyToLastLink(optionalKey); function withConstructorDefault(ast, defaultValue) { - const transformation = new Transformation(withDefault(defaultValue), passthrough()); - const constructorDefault = new Link(unknown, transformation); - const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, constructorDefault, ast.context.annotations) : new Context(false, false, constructorDefault); + const context = ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue); return replaceContext(ast, context); } function decodeTo(from, to, transformation) { @@ -8137,8 +8107,8 @@ var HandleProto = { var makeHandle = (params) => Object.setPrototypeOf({ ...params }, HandleProto); -var make13 = (spawn) => { - const streamString = (command, options) => spawn(command).pipe(map6((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); +var make12 = (spawn) => { + const streamString = (command, options) => spawn(command).pipe(map5((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap3); const streamLines = (command, options) => splitLines2(streamString(command, options)); return ChildProcessSpawner.of({ spawn, @@ -8170,7 +8140,7 @@ var makeStandardCommand = (command, args, options) => Object.assign(Object.creat args, options }); -var make14 = function make(...args) { +var make13 = function make(...args) { if (isTemplateString(args[0])) { const [templates, ...expressions] = args; const tokens = parseTemplates(templates, expressions); @@ -8485,7 +8455,7 @@ var isProcessAlive = (childProcess, exitSignal) => { var taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { windowsHide: true }, onExit); -var make15 = /* @__PURE__ */ gen2(function* () { +var make14 = /* @__PURE__ */ gen2(function* () { const fs = yield* FileSystem; const path = yield* Path; const resolveWorkingDirectory = fnUntraced2(function* (options) { @@ -8846,7 +8816,7 @@ var make15 = /* @__PURE__ */ gen2(function* () { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds); - const isRunning = map6(isDone3(exitSignal), (done) => !done); + const isRunning = map5(isDone3(exitSignal), (done) => !done); const exitCode = flatMap3(_await(exitSignal), ([code, signal]) => { if (isNotNull(code)) { return succeed6(ExitCode(code)); @@ -8883,7 +8853,7 @@ var make15 = /* @__PURE__ */ gen2(function* () { const sourceStream = unwrap3(succeed6(getSourceStream(handles[handles.length - 1], options.from))); const toOption = options.to ?? "stdin"; if (toOption === "stdin") { - handles.push(yield* spawnCommand(make14(command.command, command.args, { + handles.push(yield* spawnCommand(make13(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -8895,7 +8865,7 @@ var make15 = /* @__PURE__ */ gen2(function* () { if (isNotUndefined(fd)) { const fdName2 = fdName(fd); const existingFds = command.options.additionalFds ?? {}; - handles.push(yield* spawnCommand(make14(command.command, command.args, { + handles.push(yield* spawnCommand(make13(command.command, command.args, { ...command.options, additionalFds: { ...existingFds, @@ -8906,7 +8876,7 @@ var make15 = /* @__PURE__ */ gen2(function* () { } }))); } else { - handles.push(yield* spawnCommand(make14(command.command, command.args, { + handles.push(yield* spawnCommand(make13(command.command, command.args, { ...command.options, stdin: { ...stdinConfig, @@ -8945,9 +8915,9 @@ var make15 = /* @__PURE__ */ gen2(function* () { } } }); - return make13(spawnCommand); + return make12(spawnCommand); }); -var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make15); +var layer = /* @__PURE__ */ effect(ChildProcessSpawner, make14); var flattenCommand = (command) => { const commands = []; const pipeOptions = []; @@ -8977,6 +8947,32 @@ var flattenCommand = (command) => { }; }; +// node_modules/effect/dist/internal/ulid.js +var maxTimestamp = 2 ** 48 - 1; +var base32Chars = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; +var ulidString = (timestampMillis, bytes) => { + if (bytes.length !== 10) { + throw new Error(`ULID randomness must be exactly 10 bytes, received ${bytes.length}`); + } + const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxTimestamp); + let out = ""; + for (let shift = 45;shift >= 0; shift -= 5) { + out += base32Chars[Math.floor(timestamp / 2 ** shift) & 31]; + } + let accumulator = 0; + let bits = 0; + for (const byte of bytes) { + accumulator = accumulator << 8 | byte; + bits += 8; + while (bits >= 5) { + bits -= 5; + out += base32Chars[accumulator >>> bits & 31]; + } + accumulator &= (1 << bits) - 1; + } + return out; +}; + // node_modules/effect/dist/internal/uuid.js var hex = (byte) => byte.toString(16).padStart(2, "0"); var stringify = (bytes) => { @@ -9008,9 +9004,9 @@ var v7String = (timestampMillis, bytes) => stringify(bytes === undefined ? v7Byt // node_modules/effect/dist/Crypto.js var TypeId21 = "~effect/Crypto"; var Crypto = /* @__PURE__ */ Service("effect/Crypto"); -var make16 = (impl) => { +var make15 = (impl) => { const randomBytesUnsafe = impl.randomBytes; - const randomBytes = (size) => map6(validateSize("randomBytes", size), randomBytesUnsafe); + const randomBytes = (size) => map5(validateSize("randomBytes", size), randomBytesUnsafe); const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6]; const nextDoubleUnsafe = () => readUint53(randomBytesUnsafe(7)) / 2 ** 53; const nextIntUnsafe = () => { @@ -9054,7 +9050,8 @@ var make16 = (impl) => { return buffer; }), randomUUIDv4: sync3(() => v4String(randomBytesUnsafe(16))), - randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))) + randomUUIDv7: clockWith2((clock) => succeed6(v7String(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16)))), + randomULID: clockWith2((clock) => succeed6(ulidString(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(10)))) }); }; var validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? succeed6(size) : fail6(badArgument({ @@ -9087,11 +9084,11 @@ var digest = (algorithm, data) => try_2({ cause }) }); -var make17 = /* @__PURE__ */ make16({ +var make16 = /* @__PURE__ */ make15({ randomBytes: NodeCrypto.randomBytes, digest }); -var layer2 = /* @__PURE__ */ succeed5(Crypto, make17); +var layer2 = /* @__PURE__ */ succeed5(Crypto, make16); // node_modules/@effect/platform-node/dist/NodeCrypto.js var layer3 = layer2; @@ -9196,7 +9193,7 @@ var makeTempDirectoryScoped = /* @__PURE__ */ (() => { var openFactory = (method) => { const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method)); const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method)); - return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map6((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); + return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie2(nodeClose(fd))), map5((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))); }; var open2 = /* @__PURE__ */ openFactory("open"); var makeFile = /* @__PURE__ */ (() => { @@ -9245,7 +9242,7 @@ var makeFile = /* @__PURE__ */ (() => { read(buffer) { return suspend2(() => { const position = this.position; - return map6(nodeRead(this.fd, { + return map5(nodeRead(this.fd, { buffer, position }), (bytesRead) => { @@ -9262,7 +9259,7 @@ var makeFile = /* @__PURE__ */ (() => { } const buffer = Buffer.allocUnsafeSlow(size); const position = this.position; - return map6(nodeReadAlloc(this.fd, { + return map5(nodeReadAlloc(this.fd, { buffer, position }), (bytesRead) => { @@ -9283,7 +9280,7 @@ var makeFile = /* @__PURE__ */ (() => { }); } truncate(length) { - return map6(nodeTruncate(this.fd, length || undefined), () => { + return map5(nodeTruncate(this.fd, length || undefined), () => { if (!this.append) { const len = BigInt(length ?? 0); if (this.position > len) { @@ -9295,7 +9292,7 @@ var makeFile = /* @__PURE__ */ (() => { write(buffer) { return suspend2(() => { const position = this.position; - return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map6(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { + return flatMap3(this.append ? succeed6(undefined) : positionToNumber(position, "write"), (nodePosition) => map5(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), (bytesWritten) => { if (!this.append) { this.position = position + BigInt(bytesWritten); } @@ -9459,7 +9456,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy }); return watcher; }), (watcher) => sync3(() => watcher.close()))); -var watch2 = (backend, path, options) => stat2(path).pipe(map6((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); +var watch2 = (backend, path, options) => stat2(path).pipe(map5((stat) => backend.pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap3); var writeFile2 = (path, data, options) => callback2((resume, signal) => { try { NFS.writeFile(path, data, { @@ -9477,7 +9474,7 @@ var writeFile2 = (path, data, options) => callback2((resume, signal) => { resume(fail6(handleBadArgument("writeFile")(err))); } }); -var makeFileSystem = /* @__PURE__ */ map6(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make11({ +var makeFileSystem = /* @__PURE__ */ map5(/* @__PURE__ */ serviceOption2(WatchBackend), (backend) => make11({ access: access2, chmod: chmod2, chown: chown2, @@ -9558,7 +9555,7 @@ var layer7 = layer6; // node_modules/effect/dist/Stdio.js var TypeId22 = "~effect/Stdio"; var Stdio = /* @__PURE__ */ Service(TypeId22); -var make18 = (options) => ({ +var make17 = (options) => ({ [TypeId22]: TypeId22, stdinIsTerminal: succeed6(false), stdoutIsTerminal: succeed6(false), @@ -9566,7 +9563,7 @@ var make18 = (options) => ({ }); // node_modules/@effect/platform-node-shared/dist/NodeStdio.js -var layer8 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make18({ +var layer8 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make17({ args: /* @__PURE__ */ sync3(() => process.argv.slice(2)), stdinIsTerminal: /* @__PURE__ */ sync3(() => process.stdin.isTTY === true), stdoutIsTerminal: /* @__PURE__ */ sync3(() => process.stdout.isTTY === true), @@ -9605,98 +9602,37 @@ var layer8 = /* @__PURE__ */ succeed5(Stdio, /* @__PURE__ */ make18({ // node_modules/@effect/platform-node/dist/NodeStdio.js var layer9 = layer8; -// node_modules/effect/dist/SchemaParser.js -function makeEffect(schema) { - const ast = schema.ast; - let parser; - return (input, options) => { - return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { - ...options.parseOptions, - disableChecks: true - } : { - disableChecks: true - } : options?.parseOptions); - }; -} -function makeOption(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return some2(exit.value); - } - getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); - return none2(); - }; -} -function make19(schema) { - const parser = makeEffect(schema); - return (input, options) => { - const exit = runSyncExit2(parser(input, options)); - if (isSuccess3(exit)) { - return exit.value; - } - const issue = getSchemaIssueOrThrow(exit.cause, "Constructor adapter can only throw schema issues"); - throw new Error("Schema validation failed", { - cause: issue - }); - }; -} -function decodeUnknownEffect(schema, options) { - const parser = run2(schema.ast); - return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); -} -function decodeUnknownExit(schema, options) { - return asExit(decodeUnknownEffect(schema, options)); -} -var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { - ...options, - ...overrideOptions -} : options; -var getValue = (value) => { - if (value === missing) { - return fail6(new InvalidValue); +// node_modules/effect/dist/internal/schema/interpreter.js +var flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager2(result, f); +function compileTransformation(transformation) { + if (transformation._tag === "Middleware") { + return (result, current, options) => { + const transformed = result === sameExit ? transformation.decode(succeed8(toOption(current)), options) : transformation.decode(mapEager2(result, toOption), options); + return fromOptionalEffect(transformed); + }; } - return succeed6(value); -}; -function run2(ast) { - return runWithCompiler(normalCompiler, ast); -} -function runWithCompiler(compiler, ast) { - let parser; - return (input, options) => { - const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); - if (result === sameExit) { - return succeed6(input); + const getter = transformation.decode; + switch (getter._tag) { + case "Passthrough": + return (result, current) => result === sameExit ? succeed8(current) : result; + case "Transform": { + const transform = (value) => value === missing ? missingExit : succeed8(getter.transform(value)); + return (result, current) => flatMapTransformation(result, current, transform); } - if (!effectIsExit(result)) { - return flatMapEager2(result, getValue); + case "TransformOptional": { + const transform = (value) => fromOptionExit(getter.transform(toOption(value))); + return (result, current) => flatMapTransformation(result, current, transform); } - return result[args] === missing ? getValue(missing) : result; - }; -} -function asExit(parser) { - return (input, options) => runSyncExit2(parser(input, options)); -} -var normalCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, normalCompiler)); -var constructorCompiler = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault)); -var compileDefaulted = /* @__PURE__ */ memoize((ast) => makeParser(ast, constructorCompiler, compileConstructorDefault, ast.context?.constructorDefault)); -function compileConstructorDefault(ast) { - return ast.context?.constructorDefault ? compileDefaulted(ast) : constructorCompiler(ast); -} -function applyTransformation(result, current, transformation, options) { - let transformed; - if (effectIsExit(result) && result._tag === "Success") { - const optional = toOption(result === sameExit ? current : result[args]); - transformed = transformation._tag === "Transformation" ? transformation.decode.run(optional, options) : transformation.decode(succeed8(optional), options); - } else if (transformation._tag === "Transformation") { - transformed = flatMapEager2(result, (value) => transformation.decode.run(toOption(value), options)); - } else { - transformed = transformation.decode(mapEager2(result, toOption), options); + case "TransformEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => value === missing ? missingExit : getter.transform(value, options)); + case "TransformOptionalEffect": + return (result, current, options) => flatMapTransformation(result, current, (value) => fromOptionalEffect(getter.transform(toOption(value), options))); } - return effectIsExit(transformed) && transformed._tag === "Success" ? fromOptionExit(transformed[args]) : flatMapEager2(transformed, fromOptionExit); } +var fromOptionalEffect = (effect) => flatMapEager2(effect, fromOptionExit); +var wrapEncoding = (ast, input, options, effect) => catchCause2(effect, (cause) => failCauseSync2(() => map4(cause, (issue) => new Encoding(ast, issue, input, options)))); function makeConstructorParser(descriptor, compile) { + const transform = compileTransformation(descriptor.link.transformation); let sourceParser; return (input, options) => { if (input === missing) @@ -9704,20 +9640,45 @@ function makeConstructorParser(descriptor, compile) { if (descriptor.isConstructed(input)) return sameExit; const result = (sourceParser ??= compile(descriptor.link.to))(input, options); - return applyTransformation(result, input, descriptor.link.transformation, options); + return transform(result, input, options); + }; +} +function withDefault(ast, parser) { + const defaultValue = ast.context.constructorDefault; + return (input, options) => { + if (input !== missing && input !== undefined) + return parser(input, options); + const result = defaultValue; + if (effectIsExit(result) && result._tag === "Success") { + const local = parser(result[args], options); + return local === sameExit ? result : local; + } + return flatMapEager2(wrapEncoding(ast, input, options, result), (value) => { + const local = parser(value, options); + return local === sameExit ? succeed8(value) : local; + }); }; } -function makeParser(ast, compile, compileConstructorDefault, constructorDefault) { - const descriptor = compileConstructorDefault ? getConstructorDescriptor(ast) : undefined; - const parser = descriptor ? makeConstructorParser(descriptor, compile) : ast.getParser(compile, compileConstructorDefault); +function compileField(ast, compile) { + const parser = compile(ast); + return ast.context?.constructorDefault === undefined ? parser : withDefault(ast, parser); +} +function compile(ast, compile, compileField, base, specialize) { + if (ast._tag === "Declaration") { + for (const parameter of ast.typeParameters) + compile(parameter); + } + const descriptor = compileField ? getConstructorDescriptor(ast) : undefined; + const parser = descriptor ? makeConstructorParser(descriptor, compile) : base ?? ast.getParser(compile, compileField); const checks = ast.checks; - const links = constructorDefault ? ast.encoding ? [...ast.encoding, constructorDefault] : [constructorDefault] : ast.encoding; + const links = ast.encoding; + const transformations = links?.map((link) => compileTransformation(link.transformation)); const encodingChecks = ast.encodingChecks; if (!links && !checks && !encodingChecks) { return parser; } let encodingParsers; - const parseLocal = (input, options) => { + const parseChecks = (input, options) => { let result = parser(input, options); if (encodingChecks && !options.disableChecks) { if (effectIsExit(result)) { @@ -9767,6 +9728,7 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) } return result; }; + const parseLocal = specialize === undefined ? parseChecks : specialize(parseChecks); if (!links) { return parseLocal; } @@ -9775,7 +9737,7 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) let current = input; let result = parsers[parsers.length - 1](input, options); for (let i = links.length - 1;i >= 0; i--) { - result = applyTransformation(result, current, links[i].transformation, options); + result = transformations[i](result, current, options); if (i !== 0) { const next = parsers[i - 1]; if (result._tag === "Success") { @@ -9794,7 +9756,7 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) const local = parseLocal(value, options); return local === sameExit ? result : local; } - result = catchCause2(result, (cause) => failCauseSync2(() => map5(cause, (issue) => new Encoding(ast, issue, input, options)))); + result = wrapEncoding(ast, input, options, result); return flatMapEager2(result, (value) => { const local = parseLocal(value, options); return local === sameExit ? succeed8(value) : local; @@ -9802,6 +9764,217 @@ function makeParser(ast, compile, compileConstructorDefault, constructorDefault) }; } +// node_modules/effect/dist/internal/schema/compilerRegistry.js +var invalid3 = /* @__PURE__ */ Symbol(); +var cache = /* @__PURE__ */ new WeakMap; +var compiler; +var compilerAdaptersEnabled = false; +var decodeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve4, ast, "parser") : resolve4(ast).parser; +var makeChild = (ast) => compilerAdaptersEnabled ? lazyParser(resolve4, ast, "makeEffect") : resolve4(ast).makeEffect; +var makeField = (ast) => compileField(ast, makeChild); + +class InterpretedEntry { + ast; + constructor(ast) { + this.ast = ast; + } + get decodeEffect() { + return this.cachedDecodeEffect ??= compile(this.ast, decodeChild); + } + get parser() { + return this.decodeEffect; + } + get makeEffect() { + return this.cachedMakeEffect ??= compile(this.ast, makeChild, makeField); + } +} + +class CompilerEntry extends InterpretedEntry { + compiled; + resolve; + constructor(ast, compiled, resolve) { + super(ast); + this.compiled = compiled; + this.resolve = resolve; + } + save(key, value) { + Object.defineProperty(this, key, { + value + }); + return value; + } + operation(key) { + const compiled = this.compiled; + return typeof compiled === "function" ? compiled(this.ast, this.resolve, key) : compiled?.[key]; + } + get is() { + return this.save("is", this.operation("is")); + } + get decode() { + return this.save("decode", this.operation("decode")); + } + get make() { + return this.save("make", this.operation("make")); + } + get decodeEffect() { + return this.save("decodeEffect", this.operation("decodeEffect") ?? compile(this.ast, (ast) => lazyParser(this.resolve, ast, "parser"))); + } + get parser() { + const decode = this.decode; + return decode === undefined ? this.decodeEffect : this.save("parser", withDecode(decode, () => this.decodeEffect)); + } + get makeEffect() { + const makeEffect = this.operation("makeEffect"); + if (makeEffect !== undefined) + return this.save("makeEffect", makeEffect); + const child = (ast) => lazyParser(this.resolve, ast, "makeEffect"); + return this.save("makeEffect", compile(this.ast, child, (ast) => compileField(ast, child))); + } +} +function withDecode(fastDecode, decodeEffect) { + let detailed; + return (input, options) => { + if (input !== missing) { + try { + const value = fastDecode(input, options); + if (value !== invalid3) + return value === input ? sameExit : succeed8(value); + } catch (error) { + return die3(error); + } + } + return (detailed ??= decodeEffect())(input, options); + }; +} +function lazyParser(resolve, ast, operation) { + const entry = resolve(ast); + if (entry.compiled === undefined || Object.hasOwn(entry, operation)) { + return entry[operation]; + } + let parser; + return (input, options) => (parser ??= entry[operation])(input, options); +} +function resolve4(ast) { + const cached = cache.get(ast); + if (cached !== undefined) + return cached; + const entry = compiler === undefined ? new InterpretedEntry(ast) : new CompilerEntry(ast, compiler(ast, resolve4), resolve4); + cache.set(ast, entry); + return entry; +} + +// node_modules/effect/dist/SchemaParser.js +function makeEffect(schema) { + const ast = schema.ast; + let parser; + return (input, options) => { + return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions); + }; +} +function makeOption(schema) { + const parser = makeEffect(schema); + return (input, options) => { + const exit = runSyncExit2(parser(input, options)); + if (isSuccess3(exit)) { + return some2(exit.value); + } + getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues"); + return none2(); + }; +} +function make18(schema) { + return makeConstructorSync(toType(schema.ast)); +} +function decodeUnknownEffect(schema, options) { + const parser = run2(schema.ast); + return options === undefined ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions)); +} +function decodeUnknownExit(schema, options) { + return asExit(decodeUnknownEffect(schema, options)); +} +var mergeParseOptions = (options, overrideOptions) => overrideOptions ? { + ...options, + ...overrideOptions +} : options; +var getValue = (value) => { + if (value === missing) { + return fail6(new InvalidValue); + } + return succeed6(value); +}; +function run2(ast) { + return runWithCompiler(normalCompiler, ast); +} +function parserResult(result, input) { + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; +} +function runWithCompiler(compiler, ast) { + let parser; + return (input, options) => { + const result = (parser ??= compiler(ast))(input, options ?? defaultParseOptions); + if (result === sameExit) { + return succeed6(input); + } + if (!effectIsExit(result)) { + return flatMapEager2(result, getValue); + } + return result[args] === missing ? getValue(missing) : result; + }; +} +function asExit(parser) { + return (input, options) => runSyncExit2(parser(input, options)); +} +function runSync2(effect, message) { + const exit = runSyncExit2(effect); + if (isSuccess3(exit)) { + return exit.value; + } + const issue = getSchemaIssueOrThrow(exit.cause, message); + throw new Error("Schema validation failed", { + cause: issue + }); +} +function makeConstructorSync(ast) { + let entry; + let parser; + return (input, options) => { + entry ??= resolve4(ast); + const parseOptions = options?.disableChecks ? options.parseOptions ? { + ...options.parseOptions, + disableChecks: true + } : { + disableChecks: true + } : options?.parseOptions ?? defaultParseOptions; + const make = entry.make; + if (make !== undefined && input !== missing) { + let output; + try { + output = make(input, parseOptions); + } catch (error) { + getSchemaIssueOrThrow(die2(error), "Constructor adapter can only throw schema issues"); + throw error; + } + if (output !== invalid3 && output !== missing) + return output; + } + const result = (parser ??= entry.makeEffect)(input, parseOptions); + return runSync2(parserResult(result, input), "Constructor adapter can only throw schema issues"); + }; +} +var normalCompiler = (ast) => resolve4(ast).parser; +var constructorCompiler = (ast) => resolve4(ast).makeEffect; + // node_modules/effect/dist/internal/schema/make.js var TypeId23 = "~effect/Schema/Schema"; var SchemaProto = { @@ -9819,7 +9992,7 @@ var SchemaProto = { return this.rebuild(appendChecks(this.ast, checks)); } }; -function make20(ast, options) { +function make19(ast, options) { function Schema() {} const self = Object.setPrototypeOf(Schema, SchemaProto); if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) { @@ -9830,9 +10003,9 @@ function make20(ast, options) { Object.assign(self, options); } self.ast = ast; - self.rebuild = (ast) => make20(ast, options); + self.rebuild = (ast) => make19(ast, options); self.makeEffect = makeEffect(self); - self.make = make19(self); + self.make = make18(self); self.makeOption = makeOption(self); return self; } @@ -9847,7 +10020,7 @@ var SchemaErrorTypeId = "~effect/Schema/SchemaError"; var TypeId24 = TypeId23; function declareConstructor() { return (typeParameters, run, annotations) => { - return make21(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make21(ast))), annotations)); + return make20(new Declaration(typeParameters.map(getAST), (typeParameters) => run(typeParameters.map((ast) => make20(ast))), annotations)); }; } function declare(is, annotations) { @@ -9874,7 +10047,7 @@ class SchemaError extends (/* @__PURE__ */ TaggedError2("SchemaError")) { } } function fromIssueExit(exit) { - return isSuccess3(exit) ? exit : failCause2(map5(exit.cause, (issue) => new SchemaError(issue))); + return isSuccess3(exit) ? exit : failCause2(map4(exit.cause, (issue) => new SchemaError(issue))); } function decodeUnknownExit2(schema, options) { const parser = decodeUnknownExit(schema, options); @@ -9882,15 +10055,15 @@ function decodeUnknownExit2(schema, options) { return fromIssueExit(parser(input, options)); }; } -var make21 = make20; +var make20 = make19; function isSchema(u) { return hasProperty(u, TypeId24) && u[TypeId24] === TypeId24; } -var optionalKey2 = /* @__PURE__ */ lambda((schema) => make21(optionalKey(schema.ast), { +var optionalKey2 = /* @__PURE__ */ lambda((schema) => make20(optionalKey(schema.ast), { schema })); function Literal2(literal) { - const out = make21(new Literal(literal), { + const out = make20(new Literal(literal), { literal, transform(to) { return out.pipe(decodeTo2(Literal2(to), { @@ -9901,11 +10074,11 @@ function Literal2(literal) { }); return out; } -var Unknown2 = /* @__PURE__ */ make21(unknown); -var String4 = /* @__PURE__ */ make21(string2); -var Number5 = /* @__PURE__ */ make21(number2); +var Unknown2 = /* @__PURE__ */ make20(unknown); +var String4 = /* @__PURE__ */ make20(string2); +var Number5 = /* @__PURE__ */ make20(number2); function makeStruct(ast, fields) { - return make21(ast, { + return make20(ast, { fields, mapFields(f, options) { const fields = f(this.fields); @@ -9917,7 +10090,7 @@ function Struct(fields) { return makeStruct(struct(fields, undefined), fields); } function makeTuple(ast, elements) { - return make21(ast, { + return make20(ast, { elements, mapElements(f, options) { const elements = f(this.elements); @@ -9928,11 +10101,11 @@ function makeTuple(ast, elements) { function Tuple(elements) { return makeTuple(tuple(elements), elements); } -var ArraySchema = /* @__PURE__ */ lambda((schema) => make21(new Arrays(false, [], [schema.ast]), { +var ArraySchema = /* @__PURE__ */ lambda((schema) => make20(new Arrays(false, [], [schema.ast]), { value: schema })); function makeUnion(ast, members) { - return make21(ast, { + return make20(ast, { members, mapMembers(f, options) { const members = f(this.members); @@ -9945,14 +10118,14 @@ function Union2(members, options) { } function decodeTo2(to, transformation) { return (from) => { - return make21(decodeTo(from.ast, to.ast, transformation ? make12(transformation) : passthrough2()), { + return make20(decodeTo(from.ast, to.ast, transformation ? makeTransformation(transformation) : passthrough2()), { from, to }); }; } function withConstructorDefault2(defaultValue) { - return (schema) => make21(withConstructorDefault(schema.ast, defaultValue), { + return (schema) => make20(withConstructorDefault(schema.ast, defaultValue), { schema }); } @@ -9970,7 +10143,7 @@ function instanceOf(constructor, annotations) { } function link3() { return (encodeTo, transformation) => { - return new Link(encodeTo.ast, make12(transformation)); + return new Link(encodeTo.ast, makeTransformation(transformation)); }; } var makeFilter2 = makeFilter; @@ -10224,7 +10397,7 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) { return getClassSchema(this).rebuild(ast); } static make(input, options) { - return make19(getClassSchema(this))(input ?? {}, options); + return make18(getClassSchema(this))(input ?? {}, options); } static makeOption(input, options) { return makeOption(getClassSchema(this))(input ?? {}, options); @@ -10283,7 +10456,7 @@ function getClassSchemaFactory(from, identifier, annotations) { const ClassTypeId = getClassTypeId(identifier); const isClassValue = (input) => input instanceof self || hasProperty(input, ClassTypeId); const transformation = getClassTransformation(self); - const to = make21(new Declaration([from.ast], () => (input, ast, options) => { + const to = make20(new Declaration([from.ast], () => (input, ast, options) => { return isClassValue(input) ? succeed6(input) : fail6(new InvalidType(ast, input, options)); }, { identifier, @@ -10332,14 +10505,14 @@ class QuitError extends (/* @__PURE__ */ Error4("QuitError")({ [QuitErrorTypeId] = QuitErrorTypeId; } var Terminal = /* @__PURE__ */ Service("effect/Terminal"); -var make22 = (impl) => Terminal.of({ +var make21 = (impl) => Terminal.of({ ...impl, [TypeId25]: TypeId25 }); // node_modules/@effect/platform-node-shared/dist/NodeTerminal.js import * as readline from "node:readline"; -var make23 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { +var make22 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQuit) { const stdin = process.stdin; const stdout = process.stdout; const lines = yield* make8(); @@ -10444,7 +10617,7 @@ var make23 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu cause: err })))); })); - return make22({ + return make21({ columns, rows, readInput, @@ -10452,7 +10625,7 @@ var make23 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu display }); }); -var layer10 = /* @__PURE__ */ effect(Terminal, /* @__PURE__ */ make23(defaultShouldQuit)); +var layer10 = /* @__PURE__ */ effect(Terminal, /* @__PURE__ */ make22(defaultShouldQuit)); function defaultShouldQuit(input) { return input.key.ctrl && (input.key.name === "c" || input.key.name === "d"); } @@ -10481,7 +10654,7 @@ var makeUnsafe6 = (value) => { self.ref = make6(value); return self; }; -var make24 = (value) => sync3(() => makeUnsafe6(value)); +var make23 = (value) => sync3(() => makeUnsafe6(value)); var get4 = (self) => sync3(() => self.ref.current); var update = /* @__PURE__ */ dual(2, (self, f) => sync3(() => { self.ref.current = f(self.ref.current); @@ -10531,7 +10704,7 @@ var layer13 = sync2(Service2, () => { class TestService extends Service()("@timmo001/workflows/Annotations/Test") { } var testLayer = effectContext(gen2(function* () { - const recorded = yield* make24([]); + const recorded = yield* make23([]); const write = (line) => update(recorded, (lines) => [...lines, line]); const service = TestService.of({ error: fn2("Annotations.Test.error")(function* (message, properties) { @@ -10576,7 +10749,7 @@ class Service3 extends Service()("@timmo001/workflows/CommandExecutor") { } var layer14 = effect(Service3, gen2(function* () { const spawner = yield* ChildProcessSpawner; - const make = (command, args, options) => make14(command, args, { + const make = (command, args, options) => make13(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true @@ -10615,7 +10788,7 @@ var layer14 = effect(Service3, gen2(function* () { const stream = fn2("CommandExecutor.stream")(function* (command, args, options) { const label = options?.label ?? `${command} ${args.join(" ")}`.trim(); return yield* scoped2(gen2(function* () { - const handle = yield* spawner.spawn(make14(command, args, { + const handle = yield* spawner.spawn(make13(command, args, { cwd: options?.cwd, env: options?.env, extendEnv: true, @@ -10710,7 +10883,7 @@ var discoverJsonFiles = fn2("ValidateJson.discoverJsonFiles")(function* (root) { }); var validateFile = fn2("ValidateJson.validateFile")(function* (file) { const fs = yield* FileSystem; - return yield* fs.readFileString(file).pipe(map6((source) => validateJsonSource(file, source)), catch_2((error) => succeed6(ValidationResult.Invalid({ + return yield* fs.readFileString(file).pipe(map5((source) => validateJsonSource(file, source)), catch_2((error) => succeed6(ValidationResult.Invalid({ file, message: `Unable to read JSON file: ${error}` })))); diff --git a/bun.lock b/bun.lock index 6df62a63..4184304c 100644 --- a/bun.lock +++ b/bun.lock @@ -7,7 +7,7 @@ "dependencies": { "@effect/platform-node": "4.0.0-rc.115", "@timmo001/effect-gh": "github:timmo001/effect-gh#57f461a6627f6ca601ad7a16c20f2fcb4562de86", - "effect": "4.0.0-rc.115", + "effect": "4.0.0-rc.116", }, "devDependencies": { "@effect/tsgo": "0.45.0", @@ -205,7 +205,7 @@ "detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="], - "effect": ["effect@4.0.0-rc.115", "", {}, "sha512-ogYulZ5ffeOzrJqQrG0XOkDO5lKn2s9KNHhoxJy/6wKUkF0i12dlVXWA9TgsgQ+zV/JzizyG0+XMPepZEQX6vw=="], + "effect": ["effect@4.0.0-rc.116", "", {}, "sha512-nawqJHSjHV8XIBRZNZ+D7cLZpN3kkSjzy6aiT9ofKENsl7xAMFKEoDa0itN5JFl3GUQ1PIN1T1HNlva5+xyO/A=="], "es-module-lexer": ["es-module-lexer@2.3.2", "", {}, "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw=="], diff --git a/package.json b/package.json index d0b2b4c9..12b0b9a8 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "dependencies": { "@effect/platform-node": "4.0.0-rc.115", "@timmo001/effect-gh": "github:timmo001/effect-gh#57f461a6627f6ca601ad7a16c20f2fcb4562de86", - "effect": "4.0.0-rc.115" + "effect": "4.0.0-rc.116" }, "devDependencies": { "@effect/tsgo": "0.45.0",