LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download

    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing
    • swap_horiz
      Codec
    • schema
      Standard Schema
    • data_object
      JSON Schema
    • format_quote
      String

    • error
      Stack

    • deployed_code
      Libraries

    • article
      Blog
Expand sidebarExpand sidebar
effect/Compiled (minified)Compiled (minified)
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
schemas/libraries/effect/download_compiled/minified.js
code_off
View RawView Raw
Copy to clipboardCopy to clipboard
const e = (e) => typeof e == `function`, t = function (e, t) { if (typeof e == `function`) return function () { return e(arguments) ? t.apply(this, arguments) : (e) => t(e, ...arguments); }; switch (e) { case 0: case 1: throw RangeError(`Invalid arity ${e}`); case 2: return function (e, n) { return arguments.length >= 2 ? t(e, n) : function (n) { return t(n, e); }; }; case 3: return function (e, n, r) { return arguments.length >= 3 ? t(e, n, r) : function (r) { return t(r, e, n); }; }; case 4: return function (e, n, r, i) { return arguments.length >= 4 ? t(e, n, r, i) : function (i) { return t(i, e, n, r); }; }; case 5: return function (e, n, r, i, a) { return arguments.length >= 5 ? t(e, n, r, i, a) : function (a) { return t(a, e, n, r, i); }; }; default: return function () { if (arguments.length >= e) return t.apply(this, arguments); let n = arguments; return function (e) { return t(e, ...n); }; }; } }, n = (e) => e, r = (e) => () => e, i = r(!0), a = r(!1), o = r(void 0), s = o; function c(e, t, n, r, i, a, o, s, c) { switch (arguments.length) { case 1: return e; case 2: return t(e); case 3: return n(t(e)); case 4: return r(n(t(e))); case 5: return i(r(n(t(e)))); case 6: return a(i(r(n(t(e))))); case 7: return o(a(i(r(n(t(e)))))); case 8: return s(o(a(i(r(n(t(e))))))); case 9: return c(s(o(a(i(r(n(t(e)))))))); default: { let e = arguments[0]; for (let t = 1; t < arguments.length; t++) e = arguments[t](e); return e; } } } const l = (e) => (t, n) => t === n || e(t, n), u = (e, t) => e === t, d = t(2, (e, t) => l((n, r) => e(t(n), t(r)))), f = d(u, (e) => e.getTime()), p = (e) => l((t, n) => { if (t.length !== n.length) return !1; for (let r = 0; r < t.length; r++) if (!e(t[r], n[r])) return !1; return !0; }), m = `effect/GlobalValue`; let h; const g = (e, t) => ( (h ||= ((globalThis[m] ??= new Map()), globalThis[m])), h.has(e) || h.set(e, t()), h.get(e) ), ee = (e) => !!e, _ = (e) => typeof e == `string`, te = (e) => typeof e == `number`, ne = (e) => typeof e == `boolean`, re = (e) => typeof e == `bigint`, ie = (e) => typeof e == `symbol`, ae = e, oe = (e) => e === void 0, se = (e) => !1, ce = (e) => typeof e == `object` && !!e, le = (e) => ce(e) || ae(e), v = t(2, (e, t) => le(e) && t in e), ue = t(2, (e, t) => v(e, `_tag`) && e._tag === t), de = (e) => e == null, fe = (e) => e != null, pe = (e) => e instanceof Uint8Array, me = (e) => e instanceof Date, he = (e) => typeof e == `string` || v(e, Symbol.iterator), ge = (e) => ce(e) && !Array.isArray(e), _e = (e) => v(e, `then`) && ae(e.then), ve = (e) => `BUG: ${e} - please report an issue at https://github.com/Effect-TS/effect/issues`; var ye = class e { self; called = !1; constructor(e) { this.self = e; } next(e) { return this.called ? { value: e, done: !0 } : ((this.called = !0), { value: this.self, done: !1 }); } return(e) { return { value: e, done: !0 }; } throw(e) { throw e; } [Symbol.iterator]() { return new e(this.self); } }, be = class { _state; constructor(e, t, n, r) { return ( de(t) && de(e) ? ((t = (Math.random() * 4294967295) >>> 0), (e = 0)) : de(t) && ((t = e), (e = 0)), de(r) && de(n) ? ((r = this._state ? this._state[3] : 4150755663), (n = this._state ? this._state[2] : 335903614)) : de(r) && ((r = n), (n = 0)), (this._state = new Int32Array([0, 0, n >>> 0, ((r || 0) | 1) >>> 0])), this._next(), Se(this._state, this._state[0], this._state[1], e >>> 0, t >>> 0), this._next(), this ); } getState() { return [this._state[0], this._state[1], this._state[2], this._state[3]]; } setState(e) { ((this._state[0] = e[0]), (this._state[1] = e[1]), (this._state[2] = e[2]), (this._state[3] = e[3] | 1)); } integer(e) { return Math.round(this.number() * (2 ** 53 - 1)) % e; } number() { let e = (this._next() & 67108863) * 1, t = (this._next() & 134217727) * 1; return (e * 134217728 + t) / 9007199254740992; } _next() { let e = this._state[0] >>> 0, t = this._state[1] >>> 0; (xe(this._state, e, t, 1481765933, 1284865837), Se(this._state, this._state[0], this._state[1], this._state[2], this._state[3])); let n = e >>> 18, r = ((t >>> 18) | (e << 14)) >>> 0; ((n = (n ^ e) >>> 0), (r = (r ^ t) >>> 0)); let i = ((r >>> 27) | (n << 5)) >>> 0, a = e >>> 27, o = ((-a >>> 0) & 31) >>> 0; return ((i >>> a) | (i << o)) >>> 0; } }; function xe(e, t, n, r, i) { let a = ((n >>> 16) * (i & 65535)) >>> 0, o = ((n & 65535) * (i >>> 16)) >>> 0, s = ((n & 65535) * (i & 65535)) >>> 0, c = ((n >>> 16) * (i >>> 16) + ((o >>> 16) + (a >>> 16))) >>> 0; ((o = (o << 16) >>> 0), (s = (s + o) >>> 0), s >>> 0 < o >>> 0 && (c = (c + 1) >>> 0), (a = (a << 16) >>> 0), (s = (s + a) >>> 0), s >>> 0 < a >>> 0 && (c = (c + 1) >>> 0), (c = (c + Math.imul(n, r)) >>> 0), (c = (c + Math.imul(t, i)) >>> 0), (e[0] = c), (e[1] = s)); } function Se(e, t, n, r, i) { let a = (t + r) >>> 0, o = (n + i) >>> 0; (o >>> 0 < n >>> 0 && (a = (a + 1) | 0), (e[0] = a), (e[1] = o)); } const Ce = Symbol.for(`effect/Utils/YieldWrap`); var we = class { #e; constructor(e) { this.#e = e; } [Ce]() { return this.#e; } }; function Te(e) { if (typeof e == `object` && e && Ce in e) return e[Ce](); throw Error(ve(`yieldWrapGet`)); } const Ee = g(`effect/Utils/isStructuralRegion`, () => ({ enabled: !1, tester: void 0 })), De = { effect_internal_function: (e) => e() }, Oe = De.effect_internal_function(() => Error().stack)?.includes(`effect_internal_function`) === !0 ? De.effect_internal_function : { effect_internal_function: (e) => { try { return e(); } finally { } }, }.effect_internal_function; (function* () {}).constructor; const ke = g(Symbol.for(`effect/Hash/randomHashCache`), () => new WeakMap()), y = Symbol.for(`effect/Hash`), b = (e) => { if (Ee.enabled === !0) return 0; switch (typeof e) { case `number`: return Ne(e); case `bigint`: return S(e.toString(10)); case `boolean`: return S(String(e)); case `symbol`: return S(String(e)); case `string`: return S(e); case `undefined`: return S(`undefined`); case `function`: case `object`: return e === null ? S(`null`) : e instanceof Date ? Number.isNaN(e.getTime()) ? S(`Invalid Date`) : b(e.toISOString()) : e instanceof URL ? b(e.href) : Me(e) ? e[y]() : Ae(e); default: throw Error( `BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`, ); } }, Ae = (e) => (ke.has(e) || ke.set(e, Ne(Math.floor(Math.random() * (2 ** 53 - 1)))), ke.get(e)), x = (e) => (t) => (t * 53) ^ e, je = (e) => (e & 3221225471) | ((e >>> 1) & 1073741824), Me = (e) => v(e, y), Ne = (e) => { if (e !== e || e === 1 / 0) return 0; let t = e | 0; for (t !== e && (t ^= e * 4294967295); e > 4294967295;) t ^= e /= 4294967295; return je(t); }, S = (e) => { let t = 5381, n = e.length; for (; n;) t = (t * 33) ^ e.charCodeAt(--n); return je(t); }, Pe = (e, t) => { let n = 12289; for (let r = 0; r < t.length; r++) n ^= c(S(t[r]), x(b(e[t[r]]))); return je(n); }, Fe = (e) => Pe(e, Object.keys(e)), Ie = (e) => { let t = 6151; for (let n = 0; n < e.length; n++) t = c(t, x(b(e[n]))); return je(t); }, C = function () { if (arguments.length === 1) { let e = arguments[0]; return function (t) { return ( Object.defineProperty(e, y, { value() { return t; }, enumerable: !1, }), t ); }; } let e = arguments[0], t = arguments[1]; return ( Object.defineProperty(e, y, { value() { return t; }, enumerable: !1, }), t ); }, w = Symbol.for(`effect/Equal`); function T() { return arguments.length === 1 ? (e) => Le(e, arguments[0]) : Le(arguments[0], arguments[1]); } function Le(e, t) { if (e === t) return !0; let n = typeof e; if (n !== typeof t) return !1; if (n === `object` || n === `function`) { if (e !== null && t !== null) { if (Re(e) && Re(t)) return b(e) === b(t) && e[w](t) ? !0 : Ee.enabled && Ee.tester ? Ee.tester(e, t) : !1; if (e instanceof Date && t instanceof Date) { let n = e.getTime(), r = t.getTime(); return n === r || (Number.isNaN(n) && Number.isNaN(r)); } else if (e instanceof URL && t instanceof URL) return e.href === t.href; } if (Ee.enabled) { if (e === null || t === null) return !1; if (Array.isArray(e) && Array.isArray(t)) return e.length === t.length && e.every((e, n) => Le(e, t[n])); if ( Object.getPrototypeOf(e) === Object.prototype && Object.getPrototypeOf(t) === Object.prototype ) { let n = Object.keys(e), r = Object.keys(t); if (n.length === r.length) { for (let r of n) if (!(r in t && Le(e[r], t[r]))) return Ee.tester ? Ee.tester(e, t) : !1; return !0; } } return Ee.tester ? Ee.tester(e, t) : !1; } } return Ee.enabled && Ee.tester ? Ee.tester(e, t) : !1; } const Re = (e) => v(e, w), ze = () => T, E = Symbol.for(`nodejs.util.inspect.custom`), D = (e) => { try { if (v(e, `toJSON`) && ae(e.toJSON) && e.toJSON.length === 0) return e.toJSON(); if (Array.isArray(e)) return e.map(D); } catch { return {}; } return Ze(e); }, Be = `[Circular]`; function Ve(e) { try { return e.toISOString(); } catch { return `Invalid Date`; } } function He(e) { try { let t = e.toString(); return typeof t == `string` ? t : String(t); } catch { return `[toString threw]`; } } function Ue(e) { return _(e) ? JSON.stringify(e) : String(e); } function We(e, t) { let n = t?.space ?? 0, r = new WeakSet(), i = n ? (te(n) ? ` `.repeat(n) : n) : ``, a = (e) => i.repeat(e), o = (e, t) => { let n = e?.constructor; return n && n !== Object.prototype.constructor && n.name ? `${n.name}(${t})` : t; }, s = (e) => { try { return Reflect.ownKeys(e); } catch { return [`[ownKeys threw]`]; } }; function c(e, n = 0) { if (Array.isArray(e)) { if (r.has(e)) return Be; if ((r.add(e), !i || e.length <= 1)) return `[${e.map((e) => c(e, n)).join(`,`)}]`; let t = e .map((e) => c(e, n + 1)) .join( `, ` + a(n + 1), ); return `[\n${a(n + 1)}${t}\n${a(n)}]`; } if (me(e)) return Ve(e); if ( !t?.ignoreToString && v(e, `toString`) && ae(e.toString) && e.toString !== Object.prototype.toString && e.toString !== Array.prototype.toString ) { let t = He(e); return e instanceof Error && e.cause ? `${t} (cause: ${c(e.cause, n)})` : t; } if (_(e)) return JSON.stringify(e); if (te(e) || e == null || ne(e) || ie(e)) return String(e); if (re(e)) return String(e) + `n`; if (e instanceof Set || e instanceof Map) return r.has(e) ? Be : (r.add(e), `${e.constructor.name}(${c(Array.from(e), n)})`); if (le(e)) { if (r.has(e)) return Be; r.add(e); let t = s(e); if (!i || t.length <= 1) { let r = `{${t.map((t) => `${Ue(t)}:${c(e[t], n)}`).join(`,`)}}`; return o(e, r); } let l = `{\n${t.map((t) => `${a(n + 1)}${Ue(t)}: ${c(e[t], n + 1)}`).join(`, `)}\n${a(n)}}`; return o(e, l); } return String(e); } return c(e, 0); } const O = (e) => JSON.stringify(e, null, 2), Ge = (e, t = 2) => { if (typeof e == `string`) return e; try { return typeof e == `object` ? Ke(e, t) : String(e); } catch { return String(e); } }, Ke = (e, t) => { let n = [], r = JSON.stringify( e, (e, t) => typeof t == `object` && t ? n.includes(t) ? void 0 : n.push(t) && (Ye.fiberRefs !== void 0 && Je(t) ? t[qe](Ye.fiberRefs) : t) : t, t, ); return ((n = void 0), r); }, qe = Symbol.for(`effect/Inspectable/Redactable`), Je = (e) => typeof e == `object` && !!e && qe in e, Ye = g(`effect/Inspectable/redactableState`, () => ({ fiberRefs: void 0 })), Xe = (e, t) => { let n = Ye.fiberRefs; Ye.fiberRefs = e; try { return t(); } finally { Ye.fiberRefs = n; } }, Ze = (e) => (Je(e) && Ye.fiberRefs !== void 0 ? e[qe](Ye.fiberRefs) : e), k = (e, t) => { switch (t.length) { case 0: return e; case 1: return t[0](e); case 2: return t[1](t[0](e)); case 3: return t[2](t[1](t[0](e))); case 4: return t[3](t[2](t[1](t[0](e)))); case 5: return t[4](t[3](t[2](t[1](t[0](e))))); case 6: return t[5](t[4](t[3](t[2](t[1](t[0](e)))))); case 7: return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))); case 8: return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))); case 9: return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))))); default: { let n = e; for (let e = 0, r = t.length; e < r; e++) n = t[e](n); return n; } } }, Qe = `Async`, $e = `Commit`, et = `Failure`, tt = `OnFailure`, nt = `OnSuccess`, rt = `OnSuccessAndFailure`, it = `Success`, at = `Sync`, ot = `UpdateRuntimeFlags`, st = `While`, ct = `Iterator`, lt = `WithRuntime`, ut = `Yield`, dt = `RevertFlags`, ft = () => `3.22.0`, pt = Symbol.for(`effect/Effect`), mt = Symbol.for(`effect/Stream`), ht = Symbol.for(`effect/Sink`), gt = Symbol.for(`effect/Channel`), _t = { _R: (e) => e, _E: (e) => e, _A: (e) => e, _V: ft() }, vt = { _A: (e) => e, _In: (e) => e, _L: (e) => e, _E: (e) => e, _R: (e) => e }, yt = { _Env: (e) => e, _InErr: (e) => e, _InElem: (e) => e, _InDone: (e) => e, _OutErr: (e) => e, _OutElem: (e) => e, _OutDone: (e) => e, }, bt = { [pt]: _t, [mt]: _t, [ht]: vt, [gt]: yt, [w](e) { return this === e; }, [y]() { return C(this, Ae(this)); }, [Symbol.iterator]() { return new ye(new we(this)); }, pipe() { return k(this, arguments); }, }, xt = { [y]() { return C(this, Fe(this)); }, [w](e) { let t = Object.keys(this), n = Object.keys(e); if (t.length !== n.length) return !1; for (let n of t) if (!(n in e && T(this[n], e[n]))) return !1; return !0; }, }, St = { ...bt, _op: $e }, Ct = { ...St, ...xt }, wt = (function () { function e() {} return ((e.prototype = St), e); })(), Tt = Symbol.for(`effect/Option`), Et = { ...bt, [Tt]: { _A: (e) => e }, [E]() { return this.toJSON(); }, toString() { return O(this.toJSON()); }, }, Dt = Object.assign(Object.create(Et), { _tag: `Some`, _op: `Some`, [w](e) { return At(e) && Mt(e) && T(this.value, e.value); }, [y]() { return C(this, x(b(this._tag))(b(this.value))); }, toJSON() { return { _id: `Option`, _tag: this._tag, value: D(this.value) }; }, }), Ot = b(`None`), kt = Object.assign(Object.create(Et), { _tag: `None`, _op: `None`, [w](e) { return At(e) && jt(e); }, [y]() { return Ot; }, toJSON() { return { _id: `Option`, _tag: this._tag }; }, }), At = (e) => v(e, Tt), jt = (e) => e._tag === `None`, Mt = (e) => e._tag === `Some`, Nt = Object.create(kt), Pt = (e) => { let t = Object.create(Dt); return ((t.value = e), t); }, Ft = Symbol.for(`effect/Either`), It = { ...bt, [Ft]: { _R: (e) => e }, [E]() { return this.toJSON(); }, toString() { return O(this.toJSON()); }, }, Lt = Object.assign(Object.create(It), { _tag: `Right`, _op: `Right`, [w](e) { return zt(e) && Vt(e) && T(this.right, e.right); }, [y]() { return x(b(this._tag))(b(this.right)); }, toJSON() { return { _id: `Either`, _tag: this._tag, right: D(this.right) }; }, }), Rt = Object.assign(Object.create(It), { _tag: `Left`, _op: `Left`, [w](e) { return zt(e) && Bt(e) && T(this.left, e.left); }, [y]() { return x(b(this._tag))(b(this.left)); }, toJSON() { return { _id: `Either`, _tag: this._tag, left: D(this.left) }; }, }), zt = (e) => v(e, Ft), Bt = (e) => e._tag === `Left`, Vt = (e) => e._tag === `Right`, Ht = (e) => { let t = Object.create(Rt); return ((t.left = e), t); }, Ut = (e) => { let t = Object.create(Lt); return ((t.right = e), t); }, Wt = t(2, (e, t) => (jt(e) ? Ht(t()) : Ut(e.value))), A = Ut, j = Ht, Gt = Wt, Kt = (e) => { if (ae(e)) try { return A(e()); } catch (e) { return j(e); } else try { return A(e.try()); } catch (t) { return j(e.catch(t)); } }, qt = zt, Jt = Bt, Yt = Vt, Xt = t(2, (e, { onLeft: t, onRight: n }) => (Jt(e) ? j(t(e.left)) : A(n(e.right)))), Zt = t(2, (e, t) => (Jt(e) ? j(t(e.left)) : A(e.right))), Qt = t(2, (e, t) => (Yt(e) ? A(t(e.right)) : j(e.left))), $t = t(2, (e, { onLeft: t, onRight: n }) => (Jt(e) ? t(e.left) : n(e.right))), en = $t({ onLeft: n, onRight: n }), tn = t(2, (e, t) => { if (Yt(e)) return e.right; throw t(e.left); }), nn = tn(() => Error(`getOrThrow called on a Left`)), rn = (e) => e.length > 0, an = (e) => (t, n) => (t === n ? 0 : e(t, n)), on = an((e, t) => (e < t ? -1 : 1)), sn = t(2, (e, t) => an((n, r) => e(t(n), t(r)))), cn = (e) => t(2, (t, n) => e(t, n) === 1), M = () => Nt, N = Pt, ln = At, P = jt, F = Mt, un = t(2, (e, { onNone: t, onSome: n }) => (P(e) ? t() : n(e.value))), I = t(2, (e, t) => (P(e) ? t() : e.value)), dn = t(2, (e, t) => (P(e) ? t() : e)), fn = t(2, (e, t) => (P(e) ? N(t()) : e)), pn = (e) => (e == null ? M() : N(e)), mn = I(o), hn = (e) => (...t) => { try { return N(e(...t)); } catch { return M(); } }, gn = t(2, (e, t) => { if (F(e)) return e.value; throw t(); }), _n = t(2, (e, t) => (P(e) ? M() : N(t(e.value)))), vn = t(2, (e, t) => (P(e) ? M() : t(e.value))), yn = t(2, (e, t) => (P(e) ? M() : pn(t(e.value)))), bn = vn, xn = t(2, (e, t) => bn(e, (e) => (t(e) ? Pt(e) : Nt))), Sn = (e) => l((t, n) => (P(t) ? P(n) : !P(n) && e(t.value, n.value))), Cn = ((e) => t(2, (t, n) => !P(t) && e(t.value, n)))(ze()), wn = t(2, (e, t) => !P(e) && t(e.value)), Tn = (...e) => e, En = (e) => Array(e), Dn = t(2, (e, t) => { let n = Math.max(1, Math.floor(e)), r = Array(n); for (let e = 0; e < n; e++) r[e] = t(e); return r; }), L = (e) => (Array.isArray(e) ? e : Array.from(e)), On = (e) => (Array.isArray(e) ? e : [e]), kn = t(2, (e, { onEmpty: t, onNonEmpty: n }) => (R(e) ? n(Vn(e), Wn(e)) : t())), An = t(2, (e, t) => [t, ...e]), jn = t(2, (e, t) => [...e, t]), Mn = t(2, (e, t) => L(e).concat(L(t))), Nn = Array.isArray, Pn = (e) => e.length === 0, Fn = rn, R = rn, In = (e, t) => e < 0 || e >= t.length, Ln = (e, t) => Math.floor(Math.min(Math.max(0, e), t.length)), Rn = t(2, (e, t) => { let n = Math.floor(t); return In(n, e) ? M() : N(e[n]); }), zn = t(2, (e, t) => { let n = Math.floor(t); if (In(n, e)) throw Error(`Index ${n} out of bounds`); return e[n]; }), Bn = Rn(0), Vn = zn(0), Hn = (e) => (R(e) ? N(Un(e)) : M()), Un = (e) => e[e.length - 1], Wn = (e) => e.slice(1), Gn = (e, t) => { let n = 0; for (let r of e) { if (!t(r, n)) break; n++; } return n; }, Kn = t(2, (e, t) => $n(e, Gn(e, t))), qn = t(2, (e, t) => { let n = L(e); return n.slice(Ln(t, n), n.length); }), Jn = (e) => Array.from(e).reverse(), Yn = t(2, (e, t) => { let n = Array.from(e); return (n.sort(t), n); }), Xn = t(2, (e, t) => Zn(e, t, Tn)), Zn = t(3, (e, t, n) => { let r = L(e), i = L(t); if (R(r) && R(i)) { let e = [n(Vn(r), Vn(i))], t = Math.min(r.length, i.length); for (let a = 1; a < t; a++) e[a] = n(r[a], i[a]); return e; } return []; }), Qn = ze(), $n = t(2, (e, t) => { let n = Array.from(e), r = Math.floor(t); return R(n) ? (r >= 1 ? er(n, r) : [[], n]) : [n, []]; }), er = t(2, (e, t) => { let n = Math.max(1, Math.floor(t)); return n >= e.length ? [tr(e), []] : [An(e.slice(1, n), Vn(e)), e.slice(n)]; }), tr = (e) => e.slice(), nr = t(3, (e, t, n) => { let r = L(e), i = L(t); return R(r) ? (R(i) ? pr(n)(Mn(r, i)) : r) : i; }), rr = t(2, (e, t) => nr(e, t, Qn)), ir = () => [], ar = (e) => [e], or = t(2, (e, t) => e.map(t)), sr = t(2, (e, t) => { if (Pn(e)) return []; let n = []; for (let r = 0; r < e.length; r++) { let i = t(e[r], r); for (let e = 0; e < i.length; e++) n.push(i[e]); } return n; }), cr = sr(n), lr = t(2, (e, t) => { let n = L(e), r = []; for (let e = 0; e < n.length; e++) { let i = t(n[e], e); F(i) && r.push(i.value); } return r; }), ur = t(3, (e, t, n) => L(e).reduce((e, t, r) => n(e, t, r), t)), dr = (e, t) => { let n = [], r = e, i; for (; F((i = t(r)));) { let [e, t] = i.value; (n.push(e), (r = t)); } return n; }, fr = p, pr = t(2, (e, t) => { let n = L(e); if (R(n)) { let e = [Vn(n)], r = Wn(n); for (let n of r) e.every((e) => !t(n, e)) && e.push(n); return e; } return []; }), mr = (e) => pr(e, ze()), hr = t(2, (e, t) => L(e).join(t)), gr = /^[+-]?\d+$/, _r = Symbol.for(`effect/BigDecimal`), vr = { [_r]: _r, [y]() { let e = Tr(this); return c(b(e.value), x(Ne(e.scale)), C(this)); }, [w](e) { return yr(e) && kr(this, e); }, toString() { return `BigDecimal(${Nr(this)})`; }, toJSON() { return { _id: `BigDecimal`, value: String(this.value), scale: this.scale }; }, [E]() { return this.toJSON(); }, pipe() { return k(this, arguments); }, }, yr = (e) => v(e, _r), br = (e, t) => { let n = Object.create(vr); return ((n.value = e), (n.scale = t), n); }, xr = (e, t) => { if (e !== Sr && e % Cr === Sr) throw RangeError(`Value must be normalized`); let n = br(e, t); return ((n.normalized = n), n); }, Sr = BigInt(0), Cr = BigInt(10), wr = xr(Sr, 0), Tr = (e) => { if (e.normalized === void 0) if (e.value === Sr) e.normalized = wr; else { let t = `${e.value}`, n = 0; for (let e = t.length - 1; e >= 0 && t[e] === `0`; e--) n++; n === 0 && (e.normalized = e); let r = BigInt(t.substring(0, t.length - n)), i = e.scale - n; e.normalized = xr(r, i); } return e.normalized; }, Er = t(2, (e, t) => t > e.scale ? br(e.value * Cr ** BigInt(t - e.scale), t) : t < e.scale ? br(e.value / Cr ** BigInt(e.scale - t), t) : e, ), Dr = (e) => (e.value < Sr ? br(-e.value, e.scale) : e), Or = l((e, t) => e.scale > t.scale ? Er(t, e.scale).value === e.value : e.scale < t.scale ? Er(e, t.scale).value === t.value : e.value === t.value, ), kr = t(2, (e, t) => Or(e, t)), Ar = (e) => gn(jr(e), () => RangeError(`Number must be finite, got ${e}`)), jr = (e) => { if (!Number.isFinite(e)) return M(); let t = `${e}`; if (t.includes(`e`)) return Mr(t); let [n, r = ``] = t.split(`.`); return N(br(BigInt(`${n}${r}`), r.length)); }, Mr = (e) => { if (e === ``) return N(wr); let t, n, r = e.search(/[eE]/); if (r !== -1) { let i = e.slice(r + 1); if ( ((t = e.slice(0, r)), (n = Number(i)), t === `` || !Number.isSafeInteger(n) || !gr.test(i)) ) return M(); } else ((t = e), (n = 0)); let i, a, o = t.search(/\./); if (o !== -1) { let e = t.slice(0, o), n = t.slice(o + 1); ((i = `${e}${n}`), (a = n.length)); } else ((i = t), (a = 0)); if (!gr.test(i)) return M(); let s = a - n; return Number.isSafeInteger(s) ? N(br(BigInt(i), s)) : M(); }, Nr = (e) => { let t = Tr(e); if (Math.abs(t.scale) >= 16) return Pr(t); let n = t.value < Sr, r = n ? `${t.value}`.substring(1) : `${t.value}`, i, a; if (t.scale >= r.length) ((i = `0`), (a = `0`.repeat(t.scale - r.length) + r)); else { let e = r.length - t.scale; if (e > r.length) { let t = e - r.length; ((i = `${r}${`0`.repeat(t)}`), (a = ``)); } else ((a = r.slice(e)), (i = r.slice(0, e))); } let o = a === `` ? i : `${i}.${a}`; return n ? `-${o}` : o; }, Pr = (e) => { if (Ir(e)) return `0e+0`; let t = Tr(e), n = `${Dr(t).value}`, r = n.slice(0, 1), i = n.slice(1), a = `${Lr(t) ? `-` : ``}${r}`; i !== `` && (a += `.${i}`); let o = i.length - t.scale; return `${a}e${o >= 0 ? `+` : ``}${o}`; }, Fr = (e) => Number(Nr(e)), Ir = (e) => e.value === Sr, Lr = (e) => e.value < Sr, Rr = (e) => (e > BigInt(2 ** 53 - 1) || e < BigInt(-(2 ** 53 - 1)) ? M() : N(Number(e))), zr = (e) => { try { return e.trim() === `` ? M() : N(BigInt(e)); } catch { return M(); } }, Br = (e) => { if (e > 2 ** 53 - 1 || e < -(2 ** 53 - 1)) return M(); try { return N(BigInt(e)); } catch { return M(); } }, Vr = (e) => !e, Hr = Symbol.for(`effect/Chunk`); function Ur(e, t, n, r, i) { for (let a = t; a < Math.min(e.length, t + i); a++) n[r + a - t] = e[a]; return n; } const Wr = [], Gr = ((e) => l((t, n) => t.length === n.length && ei(t).every((t, r) => e(t, ii(n, r)))))(T), Kr = { [Hr]: { _A: (e) => e }, toString() { return O(this.toJSON()); }, toJSON() { return { _id: `Chunk`, values: ei(this).map(D) }; }, [E]() { return this.toJSON(); }, [w](e) { return qr(e) && Gr(this, e); }, [y]() { return C(this, Ie(ei(this))); }, [Symbol.iterator]() { switch (this.backing._tag) { case `IArray`: return this.backing.array[Symbol.iterator](); case `IEmpty`: return Wr[Symbol.iterator](); default: return ei(this)[Symbol.iterator](); } }, pipe() { return k(this, arguments); }, }, z = (e) => { let t = Object.create(Kr); switch (((t.backing = e), e._tag)) { case `IEmpty`: ((t.length = 0), (t.depth = 0), (t.left = t), (t.right = t)); break; case `IConcat`: ((t.length = e.left.length + e.right.length), (t.depth = 1 + Math.max(e.left.depth, e.right.depth)), (t.left = e.left), (t.right = e.right)); break; case `IArray`: ((t.length = e.array.length), (t.depth = 0), (t.left = Jr), (t.right = Jr)); break; case `ISingleton`: ((t.length = 1), (t.depth = 0), (t.left = Jr), (t.right = Jr)); break; case `ISlice`: ((t.length = e.length), (t.depth = e.chunk.depth + 1), (t.left = Jr), (t.right = Jr)); break; } return t; }, qr = (e) => v(e, Hr), Jr = z({ _tag: `IEmpty` }), Yr = () => Jr, Xr = (...e) => ri(e), Zr = (e) => z({ _tag: `ISingleton`, a: e }), Qr = (e) => (qr(e) ? e : ni(L(e))), $r = (e, t, n) => { switch (e.backing._tag) { case `IArray`: Ur(e.backing.array, 0, t, n, e.length); break; case `IConcat`: ($r(e.left, t, n), $r(e.right, t, n + e.left.length)); break; case `ISingleton`: t[n] = e.backing.a; break; case `ISlice`: { let r = 0, i = n; for (; r < e.length;) ((t[i] = ii(e, r)), (r += 1), (i += 1)); break; } } }, ei = (e) => { switch (e.backing._tag) { case `IEmpty`: return Wr; case `IArray`: return e.backing.array; default: { let t = Array(e.length); return ( $r(e, t, 0), (e.backing = { _tag: `IArray`, array: t }), (e.left = Jr), (e.right = Jr), (e.depth = 0), t ); } } }, ti = (e) => { switch (e.backing._tag) { case `IEmpty`: case `ISingleton`: return e; case `IArray`: return z({ _tag: `IArray`, array: Jn(e.backing.array) }); case `IConcat`: return z({ _tag: `IConcat`, left: ti(e.backing.right), right: ti(e.backing.left) }); case `ISlice`: return ni(Jn(ei(e))); } }, ni = (e) => (e.length === 0 ? Yr() : e.length === 1 ? Zr(e[0]) : z({ _tag: `IArray`, array: e })), ri = (e) => ni(e), ii = t(2, (e, t) => { switch (e.backing._tag) { case `IEmpty`: throw Error(`Index out of bounds`); case `ISingleton`: if (t !== 0) throw Error(`Index out of bounds`); return e.backing.a; case `IArray`: if (t >= e.length || t < 0) throw Error(`Index out of bounds`); return e.backing.array[t]; case `IConcat`: return t < e.left.length ? ii(e.left, t) : ii(e.right, t - e.left.length); case `ISlice`: return ii(e.backing.chunk, t + e.backing.offset); } }), ai = t(2, (e, t) => ci(e, Zr(t))), oi = t(2, (e, t) => ci(Zr(t), e)), si = t(2, (e, t) => { if (t <= 0) return e; if (t >= e.length) return Jr; switch (e.backing._tag) { case `ISlice`: return z({ _tag: `ISlice`, chunk: e.backing.chunk, offset: e.backing.offset + t, length: e.backing.length - t, }); case `IConcat`: return t > e.left.length ? si(e.right, t - e.left.length) : z({ _tag: `IConcat`, left: si(e.left, t), right: e.right }); default: return z({ _tag: `ISlice`, chunk: e, offset: t, length: e.length - t }); } }), ci = t(2, (e, t) => { if (e.backing._tag === `IEmpty`) return t; if (t.backing._tag === `IEmpty`) return e; let n = t.depth - e.depth; if (Math.abs(n) <= 1) return z({ _tag: `IConcat`, left: e, right: t }); if (n < -1) if (e.left.depth >= e.right.depth) { let n = ci(e.right, t); return z({ _tag: `IConcat`, left: e.left, right: n }); } else { let n = ci(e.right.right, t); if (n.depth === e.depth - 3) { let t = z({ _tag: `IConcat`, left: e.right.left, right: n }); return z({ _tag: `IConcat`, left: e.left, right: t }); } else { let t = z({ _tag: `IConcat`, left: e.left, right: e.right.left }); return z({ _tag: `IConcat`, left: t, right: n }); } } else if (t.right.depth >= t.left.depth) { let n = ci(e, t.left); return z({ _tag: `IConcat`, left: n, right: t.right }); } else { let n = ci(e, t.left.left); if (n.depth === t.depth - 3) { let e = z({ _tag: `IConcat`, left: n, right: t.left.right }); return z({ _tag: `IConcat`, left: e, right: t.right }); } else { let e = z({ _tag: `IConcat`, left: t.left.right, right: t.right }); return z({ _tag: `IConcat`, left: n, right: e }); } } }), li = (e) => e.length === 0, ui = (e) => e.length > 0, di = (e) => ii(e, 0), fi = di, pi = (e) => si(e, 1); function mi(e) { return ( (e -= (e >> 1) & 1431655765), (e = (e & 858993459) + ((e >> 2) & 858993459)), (e = (e + (e >> 4)) & 252645135), (e += e >> 8), (e += e >> 16), e & 127 ); } function hi(e, t) { return (t >>> e) & 31; } function gi(e) { return 1 << e; } function _i(e, t) { return mi(e & (t - 1)); } const vi = (e, t) => ({ value: e, previous: t }); function yi(e, t, n, r) { let i = r; if (!e) { let e = r.length; i = Array(e); for (let t = 0; t < e; ++t) i[t] = r[t]; } return ((i[t] = n), i); } function bi(e, t, n) { let r = n.length - 1, i = 0, a = 0, o = n; if (e) i = a = t; else for (o = Array(r); i < t;) o[a++] = n[i++]; for (++i; i <= r;) o[a++] = n[i++]; return (e && (o.length = r), o); } function xi(e, t, n, r) { let i = r.length; if (e) { let e = i; for (; e >= t;) r[e--] = r[e]; return ((r[t] = n), r); } let a = 0, o = 0, s = Array(i + 1); for (; a < t;) s[o++] = r[a++]; for (s[t] = n; a < i;) s[++o] = r[a++]; return s; } var Si = class e { _tag = `EmptyNode`; modify(t, n, r, i, a, o) { let s = r(M()); return P(s) ? new e() : (++o.value, new Ei(t, i, a, s)); } }; function Ci(e) { return ue(e, `EmptyNode`); } function wi(e) { return Ci(e) || e._tag === `LeafNode` || e._tag === `CollisionNode`; } function Ti(e, t) { return !Ci(e) && t === e.edit; } var Ei = class e { edit; hash; key; value; _tag = `LeafNode`; constructor(e, t, n, r) { ((this.edit = e), (this.hash = t), (this.key = n), (this.value = r)); } modify(t, n, r, i, a, o) { if (T(a, this.key)) { let n = r(this.value); return n === this.value ? this : P(n) ? (--o.value, new Si()) : Ti(this, t) ? ((this.value = n), this) : new e(t, i, a, n); } let s = r(M()); return P(s) ? this : (++o.value, Ni(t, n, this.hash, this, i, new e(t, i, a, s))); } }, Di = class e { edit; hash; children; _tag = `CollisionNode`; constructor(e, t, n) { ((this.edit = e), (this.hash = t), (this.children = n)); } modify(t, n, r, i, a, o) { if (i === this.hash) { let n = Ti(this, t), i = this.updateCollisionList(n, t, this.hash, this.children, r, a, o); return i === this.children ? this : i.length > 1 ? new e(t, this.hash, i) : i[0]; } let s = r(M()); return P(s) ? this : (++o.value, Ni(t, n, this.hash, this, i, new Ei(t, i, a, s))); } updateCollisionList(e, t, n, r, i, a, o) { let s = r.length; for (let c = 0; c < s; ++c) { let s = r[c]; if (`key` in s && T(a, s.key)) { let l = s.value, u = i(l); return u === l ? r : P(u) ? (--o.value, bi(e, c, r)) : yi(e, c, new Ei(t, n, a, u), r); } } let c = i(M()); return P(c) ? r : (++o.value, yi(e, s, new Ei(t, n, a, c), r)); } }, Oi = class e { edit; mask; children; _tag = `IndexedNode`; constructor(e, t, n) { ((this.edit = e), (this.mask = t), (this.children = n)); } modify(t, n, r, i, a, o) { let s = this.mask, c = this.children, l = hi(n, i), u = gi(l), d = _i(s, u), f = s & u, p = Ti(this, t); if (!f) { let f = new Si().modify(t, n + 5, r, i, a, o); return f ? (c.length >= 16 ? ji(t, l, f, s, c) : new e(t, s | u, xi(p, d, f, c))) : this; } let m = c[d], h = m.modify(t, n + 5, r, i, a, o); if (m === h) return this; let g = s, ee; if (Ci(h)) { if (((g &= ~u), !g)) return new Si(); if (c.length <= 2 && wi(c[d ^ 1])) return c[d ^ 1]; ee = bi(p, d, c); } else ee = yi(p, d, h, c); return p ? ((this.mask = g), (this.children = ee), this) : new e(t, g, ee); } }, ki = class e { edit; size; children; _tag = `ArrayNode`; constructor(e, t, n) { ((this.edit = e), (this.size = t), (this.children = n)); } modify(t, n, r, i, a, o) { let s = this.size, c = this.children, l = hi(n, i), u = c[l], d = (u || new Si()).modify(t, n + 5, r, i, a, o); if (u === d) return this; let f = Ti(this, t), p; if (Ci(u) && !Ci(d)) (++s, (p = yi(f, l, d, c))); else if (!Ci(u) && Ci(d)) { if ((--s, s <= 8)) return Ai(t, s, l, c); p = yi(f, l, new Si(), c); } else p = yi(f, l, d, c); return f ? ((this.size = s), (this.children = p), this) : new e(t, s, p); } }; function Ai(e, t, n, r) { let i = Array(t - 1), a = 0, o = 0; for (let e = 0, t = r.length; e < t; ++e) if (e !== n) { let t = r[e]; t && !Ci(t) && ((i[a++] = t), (o |= 1 << e)); } return new Oi(e, o, i); } function ji(e, t, n, r, i) { let a = [], o = r, s = 0; for (let e = 0; o; ++e) (o & 1 && (a[e] = i[s++]), (o >>>= 1)); return ((a[t] = n), new ki(e, s + 1, a)); } function Mi(e, t, n, r, i, a) { if (n === i) return new Di(e, n, [a, r]); let o = hi(t, n), s = hi(t, i); if (o === s) return (t) => new Oi(e, gi(o) | gi(s), [t]); { let t = o < s ? [r, a] : [a, r]; return new Oi(e, gi(o) | gi(s), t); } } function Ni(e, t, n, r, i, a) { let o, s = t; for (;;) { let t = Mi(e, s, n, r, i, a); if (typeof t == `function`) ((o = vi(t, o)), (s += 5)); else { let e = t; for (; o != null;) ((e = o.value(e)), (o = o.previous)); return e; } } } const Pi = `effect/HashMap`, Fi = Symbol.for(Pi), Ii = { [Fi]: Fi, [Symbol.iterator]() { return new Ri(this, (e, t) => [e, t]); }, [y]() { let e = b(Pi); for (let t of this) e ^= c(b(t[0]), x(b(t[1]))); return C(this, e); }, [w](e) { if (Gi(e)) { if (e._size !== this._size) return !1; for (let t of this) { let n = c(e, Ji(t[0], b(t[0]))); if (P(n) || !T(t[1], n.value)) return !1; } return !0; } return !1; }, toString() { return O(this.toJSON()); }, toJSON() { return { _id: `HashMap`, values: Array.from(this).map(D) }; }, [E]() { return this.toJSON(); }, pipe() { return k(this, arguments); }, }, Li = (e, t, n, r) => { let i = Object.create(Ii); return ((i._editable = e), (i._edit = t), (i._root = n), (i._size = r), i); }; var Ri = class e { map; f; v; constructor(e, t) { ((this.map = e), (this.f = t), (this.v = Bi(this.map._root, this.f, void 0))); } next() { if (P(this.v)) return { done: !0, value: void 0 }; let e = this.v.value; return ((this.v = zi(e.cont)), { done: !1, value: e.value }); } [Symbol.iterator]() { return new e(this.map, this.f); } }; const zi = (e) => (e ? Vi(e[0], e[1], e[2], e[3], e[4]) : M()), Bi = (e, t, n = void 0) => { switch (e._tag) { case `LeafNode`: return F(e.value) ? N({ value: t(e.key, e.value.value), cont: n }) : zi(n); case `CollisionNode`: case `ArrayNode`: case `IndexedNode`: { let r = e.children; return Vi(r.length, r, 0, t, n); } default: return zi(n); } }, Vi = (e, t, n, r, i) => { for (; n < e;) { let a = t[n++]; if (a && !Ci(a)) return Bi(a, r, [e, t, n, r, i]); } return zi(i); }, Hi = Li(!1, 0, new Si(), 0), Ui = () => Hi, Wi = (e) => { let t = ea(Ui()); for (let n of e) Xi(t, n[0], n[1]); return ta(t); }, Gi = (e) => v(e, Fi), Ki = (e) => e && Ci(e._root), qi = t(2, (e, t) => Ji(e, t, b(t))), Ji = t(3, (e, t, n) => { let r = e._root, i = 0; for (;;) switch (r._tag) { case `LeafNode`: return T(t, r.key) ? r.value : M(); case `CollisionNode`: if (n === r.hash) { let e = r.children; for (let n = 0, r = e.length; n < r; ++n) { let r = e[n]; if (`key` in r && T(t, r.key)) return r.value; } } return M(); case `IndexedNode`: { let e = gi(hi(i, n)); if (r.mask & e) { ((r = r.children[_i(r.mask, e)]), (i += 5)); break; } return M(); } case `ArrayNode`: if (((r = r.children[hi(i, n)]), r)) { i += 5; break; } return M(); default: return M(); } }), Yi = t(2, (e, t) => F(Ji(e, t, b(t)))), Xi = t(3, (e, t, n) => na(e, t, () => N(n))), Zi = t(3, (e, t, n) => e._editable ? ((e._root = t), (e._size = n), e) : t === e._root ? e : Li(e._editable, e._edit, t, n), ), Qi = (e) => new Ri(e, (e) => e), $i = (e) => e._size, ea = (e) => Li(!0, e._edit + 1, e._root, e._size), ta = (e) => ((e._editable = !1), e), na = t(3, (e, t, n) => ra(e, t, b(t), n)), ra = t(4, (e, t, n, r) => { let i = { value: e._size }, a = e._root.modify(e._editable ? e._edit : NaN, 0, r, n, t, i); return c(e, Zi(a, i.value)); }), ia = t(2, (e, t) => na(e, t, M)), aa = t(2, (e, t) => sa(e, Ui(), (e, n, r) => Xi(e, r, t(n, r)))), oa = t(2, (e, t) => sa(e, void 0, (e, n, r) => t(n, r))), sa = t(3, (e, t, n) => { let r = e._root; if (r._tag === `LeafNode`) return F(r.value) ? n(t, r.value.value, r.key) : t; if (r._tag === `EmptyNode`) return t; let i = [r.children], a; for (; (a = i.pop());) for (let e = 0, r = a.length; e < r;) { let r = a[e++]; r && !Ci(r) && (r._tag === `LeafNode` ? F(r.value) && (t = n(t, r.value.value, r.key)) : i.push(r.children)); } return t; }), ca = `effect/HashSet`, la = Symbol.for(ca), ua = { [la]: la, [Symbol.iterator]() { return Qi(this._keyMap); }, [y]() { return C(this, x(b(this._keyMap))(b(ca))); }, [w](e) { return fa(e) ? $i(this._keyMap) === $i(e._keyMap) && T(this._keyMap, e._keyMap) : !1; }, toString() { return O(this.toJSON()); }, toJSON() { return { _id: `HashSet`, values: Array.from(this).map(D) }; }, [E]() { return this.toJSON(); }, pipe() { return k(this, arguments); }, }, da = (e) => { let t = Object.create(ua); return ((t._keyMap = e), t); }, fa = (e) => v(e, la), pa = da(Ui()), ma = () => pa, ha = (e) => { let t = ya(ma()); for (let n of e) Sa(t, n); return ba(t); }, ga = (...e) => { let t = ya(ma()); for (let n of e) Sa(t, n); return ba(t); }, _a = t(2, (e, t) => Yi(e._keyMap, t)), va = (e) => $i(e._keyMap), ya = (e) => da(ea(e._keyMap)), ba = (e) => ((e._keyMap._editable = !1), e), xa = t(2, (e, t) => { let n = ya(e); return (t(n), ba(n)); }), Sa = t(2, (e, t) => (e._keyMap._editable ? (Xi(t, !0)(e._keyMap), e) : da(Xi(t, !0)(e._keyMap)))), Ca = t(2, (e, t) => (e._keyMap._editable ? (ia(t)(e._keyMap), e) : da(ia(t)(e._keyMap)))), wa = t(2, (e, t) => xa(e, (e) => { for (let n of t) Ca(e, n); }), ), Ta = t(2, (e, t) => xa(ma(), (n) => { Ea(e, (e) => Sa(n, e)); for (let e of t) Sa(n, e); }), ), Ea = t(2, (e, t) => oa(e._keyMap, (e, n) => t(n))), Da = t(3, (e, t, n) => sa(e._keyMap, t, (e, t, r) => n(e, r))), Oa = ma, ka = ha, Aa = ga, ja = _a, Ma = va, Na = Sa, Pa = Ca, Fa = wa, Ia = Ta, La = Da, Ra = `Empty`, za = `Fail`, Ba = `Interrupt`, Va = `Parallel`, Ha = `Sequential`, Ua = `effect/Cause`, Wa = Symbol.for(Ua), Ga = { _E: (e) => e }, Ka = { [Wa]: Ga, [y]() { return c(b(Ua), x(b(ho(this))), C(this)); }, [w](e) { return $a(e) && mo(this, e); }, pipe() { return k(this, arguments); }, toJSON() { switch (this._tag) { case `Empty`: return { _id: `Cause`, _tag: this._tag }; case `Die`: return { _id: `Cause`, _tag: this._tag, defect: D(this.defect) }; case `Interrupt`: return { _id: `Cause`, _tag: this._tag, fiberId: this.fiberId.toJSON() }; case `Fail`: return { _id: `Cause`, _tag: this._tag, failure: D(this.error) }; case `Sequential`: case `Parallel`: return { _id: `Cause`, _tag: this._tag, left: D(this.left), right: D(this.right) }; } }, toString() { return To(this); }, [E]() { return this.toJSON(); }, }, qa = (() => { let e = Object.create(Ka); return ((e._tag = Ra), e); })(), Ja = (e) => { let t = Object.create(Ka); return ((t._tag = za), (t.error = e), t); }, Ya = (e) => { let t = Object.create(Ka); return ((t._tag = `Die`), (t.defect = e), t); }, Xa = (e) => { let t = Object.create(Ka); return ((t._tag = Ba), (t.fiberId = e), t); }, Za = (e, t) => { let n = Object.create(Ka); return ((n._tag = Va), (n.left = e), (n.right = t), n); }, Qa = (e, t) => { let n = Object.create(Ka); return ((n._tag = Ha), (n.left = e), (n.right = t), n); }, $a = (e) => v(e, Wa), eo = (e) => e._tag === Ra, to = (e) => e._tag === za, no = (e) => e._tag === `Empty` || Co(e, !0, (e, t) => { switch (t._tag) { case Ra: return N(e); case `Die`: case za: case Ba: return N(!1); default: return M(); } }), ro = (e) => F(uo(e)), io = (e) => wo(void 0, yo)(e), ao = (e) => ti(Co(e, Yr(), (e, t) => (t._tag === `Fail` ? N(c(e, oi(t.error))) : M()))), oo = (e) => ti(Co(e, Yr(), (e, t) => (t._tag === `Die` ? N(c(e, oi(t.defect))) : M()))), so = (e) => Co(e, Oa(), (e, t) => (t._tag === `Interrupt` ? N(c(e, Na(t.fiberId))) : M())), co = (e) => _o(e, (e) => (e._tag === `Fail` ? N(e.error) : M())), lo = (e) => { let t = co(e); switch (t._tag) { case `None`: return A(e); case `Some`: return j(t.value); } }, uo = (e) => _o(e, (e) => (e._tag === `Interrupt` ? N(e.fiberId) : M())), fo = (e) => So(e, { onEmpty: qa, onFail: () => qa, onDie: Ya, onInterrupt: Xa, onSequential: Qa, onParallel: Za, }), po = (e) => So(e, { onEmpty: qa, onFail: Ya, onDie: Ya, onInterrupt: Xa, onSequential: Qa, onParallel: Za, }), mo = (e, t) => { let n = Zr(e), r = Zr(t); for (; ui(n) && ui(r);) { let [e, t] = c( fi(n), Co([Oa(), Yr()], ([e, t], n) => { let [r, i] = vo(n); return N([c(e, Ia(r)), c(t, ci(i))]); }), ), [i, a] = c( fi(r), Co([Oa(), Yr()], ([e, t], n) => { let [r, i] = vo(n); return N([c(e, Ia(r)), c(t, ci(i))]); }), ); if (!T(e, i)) return !1; ((n = t), (r = a)); } return !0; }, ho = (e) => go(Zr(e), Yr()), go = (e, t) => { for (;;) { let [n, r] = c( e, ur([Oa(), Yr()], ([e, t], n) => { let [r, i] = vo(n); return [c(e, Ia(r)), c(t, ci(i))]; }), ), i = Ma(n) > 0 ? c(t, oi(n)) : t; if (li(r)) return ti(i); ((e = r), (t = i)); } throw Error(ve(`Cause.flattenCauseLoop`)); }, _o = t(2, (e, t) => { let n = [e]; for (; n.length > 0;) { let e = n.pop(), r = t(e); switch (r._tag) { case `None`: switch (e._tag) { case Ha: case Va: (n.push(e.right), n.push(e.left)); break; } break; case `Some`: return r; } } return M(); }), vo = (e) => { let t = e, n = [], r = Oa(), i = Yr(); for (; t !== void 0;) switch (t._tag) { case Ra: if (n.length === 0) return [r, i]; t = n.pop(); break; case za: if (((r = Na(r, Xr(t._tag, t.error))), n.length === 0)) return [r, i]; t = n.pop(); break; case `Die`: if (((r = Na(r, Xr(t._tag, t.defect))), n.length === 0)) return [r, i]; t = n.pop(); break; case Ba: if (((r = Na(r, Xr(t._tag, t.fiberId))), n.length === 0)) return [r, i]; t = n.pop(); break; case Ha: switch (t.left._tag) { case Ra: t = t.right; break; case Ha: t = Qa(t.left.left, Qa(t.left.right, t.right)); break; case Va: t = Za(Qa(t.left.left, t.right), Qa(t.left.right, t.right)); break; default: ((i = oi(i, t.right)), (t = t.left)); break; } break; case Va: (n.push(t.right), (t = t.left)); break; } throw Error(ve(`Cause.evaluateCauseLoop`)); }, yo = { emptyCase: i, failCase: a, dieCase: a, interruptCase: i, sequentialCase: (e, t, n) => t && n, parallelCase: (e, t, n) => t && n, }, bo = `SequentialCase`, xo = `ParallelCase`, So = t( 2, (e, { onDie: t, onEmpty: n, onFail: r, onInterrupt: i, onParallel: a, onSequential: o }) => wo(e, void 0, { emptyCase: () => n, failCase: (e, t) => r(t), dieCase: (e, n) => t(n), interruptCase: (e, t) => i(t), sequentialCase: (e, t, n) => o(t, n), parallelCase: (e, t, n) => a(t, n), }), ), Co = t(3, (e, t, n) => { let r = t, i = e, a = []; for (; i !== void 0;) { let e = n(r, i); switch (((r = F(e) ? e.value : r), i._tag)) { case Ha: (a.push(i.right), (i = i.left)); break; case Va: (a.push(i.right), (i = i.left)); break; default: i = void 0; break; } i === void 0 && a.length > 0 && (i = a.pop()); } return r; }), wo = t(3, (e, t, n) => { let r = [e], i = []; for (; r.length > 0;) { let e = r.pop(); switch (e._tag) { case Ra: i.push(A(n.emptyCase(t))); break; case za: i.push(A(n.failCase(t, e.error))); break; case `Die`: i.push(A(n.dieCase(t, e.defect))); break; case Ba: i.push(A(n.interruptCase(t, e.fiberId))); break; case Ha: (r.push(e.right), r.push(e.left), i.push(j({ _tag: bo }))); break; case Va: (r.push(e.right), r.push(e.left), i.push(j({ _tag: xo }))); break; } } let a = []; for (; i.length > 0;) { let e = i.pop(); switch (e._tag) { case `Left`: switch (e.left._tag) { case bo: { let e = a.pop(), r = a.pop(), i = n.sequentialCase(t, e, r); a.push(i); break; } case xo: { let e = a.pop(), r = a.pop(), i = n.parallelCase(t, e, r); a.push(i); break; } } break; case `Right`: a.push(e.right); break; } } if (a.length === 0) throw Error( `BUG: Cause.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues`, ); return a.pop(); }), To = (e, t) => io(e) ? `All fibers interrupted without errors.` : No(e).map(function (e) { return t?.renderErrorCause !== !0 || e.cause === void 0 ? e.stack : `${e.stack} {\n${Eo(e.cause, ` `)}\n}`; }).join(` `), Eo = (e, t) => { let n = e.stack.split(` `), r = `${t}[cause]: ${n[0]}`; for (let e = 1, i = n.length; e < i; e++) r += `\n${t}${n[e]}`; return (e.cause && (r += ` {\n${Eo(e.cause, `${t} `)}\n${t}}`), r); }, Do = (e) => { let t = typeof e == `object` && !!e, n = Error.stackTraceLimit; Error.stackTraceLimit = 1; let r = Error(Oo(e), t && `cause` in e && e.cause !== void 0 ? { cause: Do(e.cause) } : void 0); return ( (Error.stackTraceLimit = n), r.message === `` && (r.message = `An error has occurred`), (Error.stackTraceLimit = n), (r.name = e instanceof Error ? e.name : `Error`), t && (Mo in e && (r.span = e[Mo]), Object.keys(e).forEach((t) => { t in r || (r[t] = e[t]); })), (r.stack = jo( `${r.name}: ${r.message}`, e instanceof Error && e.stack ? e.stack : ``, r.span, )), r ); }, Oo = (e) => { if (typeof e == `string`) return e; if (typeof e == `object` && e && e instanceof Error) return e.message; try { if ( v(e, `toString`) && ae(e.toString) && e.toString !== Object.prototype.toString && e.toString !== globalThis.Array.prototype.toString ) return e.toString(); } catch {} return Ke(e); }, ko = /\((.*)\)/g, Ao = g(`effect/Tracer/spanToTrace`, () => new WeakMap()), jo = (e, t, n) => { let r = [e], i = t.startsWith(e) ? t.slice(e.length).split(` `) : t.split(` `); for (let e = 1; e < i.length; e++) { if (i[e].includes(` at new BaseEffectError`) || i[e].includes(` at new YieldableError`)) { e++; continue; } if (i[e].includes(`Generator.next`) || i[e].includes(`effect_internal_function`)) break; r.push( i[e] .replace(/at .*effect_instruction_i.*\((.*)\)/, `at $1`) .replace(/EffectPrimitive\.\w+/, `<anonymous>`), ); } if (n) { let e = n, t = 0; for (; e && e._tag === `Span` && t < 10;) { let n = Ao.get(e); if (typeof n == `function`) { let t = n(); if (typeof t == `string`) { let n = t.matchAll(ko), i = !1; for (let [, t] of n) ((i = !0), r.push(` at ${e.name} (${t})`)); i || r.push(` at ${e.name} (${t.replace(/^at /, ``)})`); } else r.push(` at ${e.name}`); } else r.push(` at ${e.name}`); ((e = mn(e.parent)), t++); } } return r.join(` `); }, Mo = Symbol.for(`effect/SpanAnnotation`), No = (e) => wo(e, void 0, { emptyCase: () => [], dieCase: (e, t) => [Do(t)], failCase: (e, t) => [Do(t)], interruptCase: () => [], parallelCase: (e, t, n) => [...t, ...n], sequentialCase: (e, t, n) => [...t, ...n], }), Po = Symbol.for(`effect/Context/Tag`), Fo = Symbol.for(`effect/Context/Reference`), Io = Symbol.for(`effect/STM`), Lo = { ...bt, _op: `Tag`, [Io]: _t, [Po]: { _Service: (e) => e, _Identifier: (e) => e }, toString() { return O(this.toJSON()); }, toJSON() { return { _id: `Tag`, key: this.key, stack: this.stack }; }, [E]() { return this.toJSON(); }, of(e) { return e; }, context(e) { return Xo(this, e); }, }, Ro = { ...Lo, [Fo]: Fo }, zo = (e) => { let t = Error.stackTraceLimit; Error.stackTraceLimit = 2; let n = Error(); Error.stackTraceLimit = t; let r = Object.create(Lo); return ( Object.defineProperty(r, "stack", { get() { return n.stack; }, }), (r.key = e), r ); }, Bo = (e) => () => { let t = Error.stackTraceLimit; Error.stackTraceLimit = 2; let n = Error(); Error.stackTraceLimit = t; function r() {} return ( Object.setPrototypeOf(r, Lo), (r.key = e), Object.defineProperty(r, "stack", { get() { return n.stack; }, }), r ); }, Vo = () => (e, t) => { let n = Error.stackTraceLimit; Error.stackTraceLimit = 2; let r = Error(); Error.stackTraceLimit = n; function i() {} return ( Object.setPrototypeOf(i, Ro), (i.key = e), (i.defaultValue = t.defaultValue), Object.defineProperty(i, "stack", { get() { return r.stack; }, }), i ); }, Ho = Symbol.for(`effect/Context`), Uo = { [Ho]: { _Services: (e) => e }, [w](e) { if (Ko(e) && this.unsafeMap.size === e.unsafeMap.size) { for (let t of this.unsafeMap.keys()) if (!e.unsafeMap.has(t) || !T(this.unsafeMap.get(t), e.unsafeMap.get(t))) return !1; return !0; } return !1; }, [y]() { return C(this, Ne(this.unsafeMap.size)); }, pipe() { return k(this, arguments); }, toString() { return O(this.toJSON()); }, toJSON() { return { _id: `Context`, services: Array.from(this.unsafeMap).map(D) }; }, [E]() { return this.toJSON(); }, }, Wo = (e) => { let t = Object.create(Uo); return ((t.unsafeMap = e), t); }, Go = (e) => { let t = Error(`Service not found${e.key ? `: ${String(e.key)}` : ``}`); if (e.stack) { let n = e.stack.split(` `); if (n.length > 2) { let e = n[2].match(/at (.*)/); e && (t.message += ` (defined at ${e[1]})`); } } if (t.stack) { let e = t.stack.split(` `); (e.splice(1, 3), (t.stack = e.join(` `))); } return t; }, Ko = (e) => v(e, Ho), qo = (e) => v(e, Fo), Jo = Wo(new Map()), Yo = () => Jo, Xo = (e, t) => Wo(new Map([[e.key, t]])), Zo = t(3, (e, t, n) => { let r = new Map(e.unsafeMap); return (r.set(t.key, n), Wo(r)); }), Qo = g(`effect/Context/defaultValueCache`, () => new Map()), $o = (e) => { if (Qo.has(e.key)) return Qo.get(e.key); let t = e.defaultValue(); return (Qo.set(e.key, t), t); }, es = (e, t) => (e.unsafeMap.has(t.key) ? e.unsafeMap.get(t.key) : $o(t)), ts = t(2, (e, t) => { if (!e.unsafeMap.has(t.key)) { if (Fo in t) return $o(t); throw Go(t); } return e.unsafeMap.get(t.key); }), ns = ts, rs = t(2, (e, t) => e.unsafeMap.has(t.key) ? Pt(e.unsafeMap.get(t.key)) : qo(t) ? Pt($o(t)) : Nt, ), is = t(2, (e, t) => { let n = new Map(e.unsafeMap); for (let [e, r] of t.unsafeMap) n.set(e, r); return Wo(n); }), as = zo, os = Yo, ss = Xo, cs = Zo, ls = ns, us = ts, ds = rs, fs = is, ps = Bo, ms = Vo, hs = Symbol.for(`effect/Duration`), gs = BigInt(0), _s = BigInt(24), vs = BigInt(60), ys = BigInt(1e3), bs = BigInt(1e6), xs = BigInt(1e9), Ss = /^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/, Cs = (e) => { if (Os(e)) return e; if (te(e)) return Fs(e); if (re(e)) return Ns(e); if (Array.isArray(e) && e.length === 2 && e.every(te)) return e[0] === -1 / 0 || e[1] === -1 / 0 || Number.isNaN(e[0]) || Number.isNaN(e[1]) ? js : e[0] === 1 / 0 || e[1] === 1 / 0 ? Ms : Ns(BigInt(Math.round(e[0] * 1e9)) + BigInt(Math.round(e[1]))); if (_(e)) { let t = Ss.exec(e); if (t) { let [e, n, r] = t, i = Number(n); switch (r) { case `nano`: case `nanos`: return Ns(BigInt(n)); case `micro`: case `micros`: return Ps(BigInt(n)); case `milli`: case `millis`: return Fs(i); case `second`: case `seconds`: return Is(i); case `minute`: case `minutes`: return Ls(i); case `hour`: case `hours`: return Rs(i); case `day`: case `days`: return zs(i); case `week`: case `weeks`: return Bs(i); } } } throw Error(`Invalid DurationInput`); }, ws = { _tag: `Millis`, millis: 0 }, Ts = { _tag: `Infinity` }, Es = { [hs]: hs, [y]() { return C(this, Fe(this.value)); }, [w](e) { return Os(e) && Xs(this, e); }, toString() { return `Duration(${Qs(this)})`; }, toJSON() { switch (this.value._tag) { case `Millis`: return { _id: `Duration`, _tag: `Millis`, millis: this.value.millis }; case `Nanos`: return { _id: `Duration`, _tag: `Nanos`, hrtime: Ws(this) }; case `Infinity`: return { _id: `Duration`, _tag: `Infinity` }; } }, [E]() { return this.toJSON(); }, pipe() { return k(this, arguments); }, }, Ds = (e) => { let t = Object.create(Es); return ( te(e) ? isNaN(e) || e <= 0 ? (t.value = ws) : Number.isFinite(e) ? Number.isInteger(e) ? (t.value = { _tag: `Millis`, millis: e }) : (t.value = { _tag: `Nanos`, nanos: BigInt(Math.round(e * 1e6)) }) : (t.value = Ts) : e <= gs ? (t.value = ws) : (t.value = { _tag: `Nanos`, nanos: e }), t ); }, Os = (e) => v(e, hs), ks = (e) => e.value._tag !== `Infinity`, As = (e) => { switch (e.value._tag) { case `Millis`: return e.value.millis === 0; case `Nanos`: return e.value.nanos === gs; case `Infinity`: return !1; } }, js = Ds(0), Ms = Ds(1 / 0), Ns = (e) => Ds(e), Ps = (e) => Ds(e * ys), Fs = (e) => Ds(e), Is = (e) => Ds(e * 1e3), Ls = (e) => Ds(e * 6e4), Rs = (e) => Ds(e * 36e5), zs = (e) => Ds(e * 864e5), Bs = (e) => Ds(e * 6048e5), Vs = (e) => Gs(e, { onMillis: (e) => e, onNanos: (e) => Number(e) / 1e6 }), Hs = (e) => { let t = Cs(e); switch (t.value._tag) { case `Infinity`: return M(); case `Nanos`: return N(t.value.nanos); case `Millis`: return N(BigInt(Math.round(t.value.millis * 1e6))); } }, Us = (e) => { let t = Cs(e); switch (t.value._tag) { case `Infinity`: throw Error(`Cannot convert infinite duration to nanos`); case `Nanos`: return t.value.nanos; case `Millis`: return BigInt(Math.round(t.value.millis * 1e6)); } }, Ws = (e) => { let t = Cs(e); switch (t.value._tag) { case `Infinity`: return [1 / 0, 0]; case `Nanos`: return [Number(t.value.nanos / xs), Number(t.value.nanos % xs)]; case `Millis`: return [Math.floor(t.value.millis / 1e3), Math.round((t.value.millis % 1e3) * 1e6)]; } }, Gs = t(2, (e, t) => { let n = Cs(e); switch (n.value._tag) { case `Nanos`: return t.onNanos(n.value.nanos); case `Infinity`: return t.onMillis(1 / 0); case `Millis`: return t.onMillis(n.value.millis); } }), Ks = t(3, (e, t, n) => { let r = Cs(e), i = Cs(t); if (r.value._tag === `Infinity` || i.value._tag === `Infinity`) return n.onMillis(Vs(r), Vs(i)); if (r.value._tag === `Nanos` || i.value._tag === `Nanos`) { let e = r.value._tag === `Nanos` ? r.value.nanos : BigInt(Math.round(r.value.millis * 1e6)), t = i.value._tag === `Nanos` ? i.value.nanos : BigInt(Math.round(i.value.millis * 1e6)); return n.onNanos(e, t); } return n.onMillis(r.value.millis, i.value.millis); }), qs = (e, t) => Ks(e, t, { onMillis: (e, t) => e === t, onNanos: (e, t) => e === t }), Js = t(2, (e, t) => Ks(e, t, { onMillis: (e, t) => e <= t, onNanos: (e, t) => e <= t })), Ys = t(2, (e, t) => Ks(e, t, { onMillis: (e, t) => e >= t, onNanos: (e, t) => e >= t })), Xs = t(2, (e, t) => qs(Cs(e), Cs(t))), Zs = (e) => { let t = Cs(e); if (t.value._tag === `Infinity`) return { days: 1 / 0, hours: 1 / 0, minutes: 1 / 0, seconds: 1 / 0, millis: 1 / 0, nanos: 1 / 0, }; let n = Us(t), r = n / bs, i = r / ys, a = i / vs, o = a / vs, s = o / _s; return { days: Number(s), hours: Number(o % _s), minutes: Number(a % vs), seconds: Number(i % vs), millis: Number(r % ys), nanos: Number(n % bs), }; }, Qs = (e) => { let t = Cs(e); if (t.value._tag === `Infinity`) return `Infinity`; if (As(t)) return `0`; let n = Zs(t), r = []; return ( n.days !== 0 && r.push(`${n.days}d`), n.hours !== 0 && r.push(`${n.hours}h`), n.minutes !== 0 && r.push(`${n.minutes}m`), n.seconds !== 0 && r.push(`${n.seconds}s`), n.millis !== 0 && r.push(`${n.millis}ms`), n.nanos !== 0 && r.push(`${n.nanos}ns`), r.join(` `) ); }, $s = Symbol.for(`effect/MutableRef`), ec = { [$s]: $s, toString() { return O(this.toJSON()); }, toJSON() { return { _id: `MutableRef`, current: D(this.current) }; }, [E]() { return this.toJSON(); }, pipe() { return k(this, arguments); }, }, tc = (e) => { let t = Object.create(ec); return ((t.current = e), t); }, nc = (e) => e.current, rc = t(2, (e, t) => ((e.current = t), e)), ic = `effect/FiberId`, ac = Symbol.for(ic), oc = `None`, sc = `Runtime`, cc = `Composite`, lc = S(`${ic}-${oc}`); var uc = class { [ac] = ac; _tag = oc; id = -1; startTimeMillis = -1; [y]() { return lc; } [w](e) { return gc(e) && e._tag === oc; } toString() { return O(this.toJSON()); } toJSON() { return { _id: `FiberId`, _tag: this._tag }; } [E]() { return this.toJSON(); } }, dc = class { id; startTimeMillis; [ac] = ac; _tag = sc; constructor(e, t) { ((this.id = e), (this.startTimeMillis = t)); } [y]() { return C(this, S(`${ic}-${this._tag}-${this.id}-${this.startTimeMillis}`)); } [w](e) { return ( gc(e) && e._tag === sc && this.id === e.id && this.startTimeMillis === e.startTimeMillis ); } toString() { return O(this.toJSON()); } toJSON() { return { _id: `FiberId`, _tag: this._tag, id: this.id, startTimeMillis: this.startTimeMillis, }; } [E]() { return this.toJSON(); } }, fc = class { left; right; [ac] = ac; _tag = cc; constructor(e, t) { ((this.left = e), (this.right = t)); } _hash; [y]() { return c(S(`${ic}-${this._tag}`), x(b(this.left)), x(b(this.right)), C(this)); } [w](e) { return gc(e) && e._tag === cc && T(this.left, e.left) && T(this.right, e.right); } toString() { return O(this.toJSON()); } toJSON() { return { _id: `FiberId`, _tag: this._tag, left: D(this.left), right: D(this.right) }; } [E]() { return this.toJSON(); } }; const pc = new uc(), mc = (e, t) => new dc(e, t), hc = (e, t) => new fc(e, t), gc = (e) => v(e, ac), _c = (e) => { switch (e._tag) { case oc: return Oa(); case sc: return Aa(e.id); case cc: return c(_c(e.left), Ia(_c(e.right))); } }, vc = g(Symbol.for(`effect/Fiber/Id/_fiberCounter`), () => tc(0)), yc = (e) => Array.from(_c(e)) .map((e) => `#${e}`) .join(`,`), bc = () => { let e = nc(vc); return (c(vc, rc(e + 1)), new dc(e, Date.now())); }, xc = pc, Sc = mc, Cc = hc, wc = gc, Tc = yc, Ec = bc, Dc = Ui, Oc = Wi, kc = Ki, Ac = qi, jc = Xi, Mc = Qi, Nc = na, Pc = aa, Fc = sa, Ic = Symbol.for(`effect/List`), Lc = (e) => L(e), Rc = ((e) => d(fr(e), Lc))(T), zc = { [Ic]: Ic, _tag: `Cons`, toString() { return O(this.toJSON()); }, toJSON() { return { _id: `List`, _tag: `Cons`, values: Lc(this).map(D) }; }, [E]() { return this.toJSON(); }, [w](e) { return Uc(e) && this._tag === e._tag && Rc(this, e); }, [y]() { return C(this, Ie(Lc(this))); }, [Symbol.iterator]() { let e = !1, t = this; return { next() { if (e) return this.return(); if (t._tag === `Nil`) return ((e = !0), this.return()); let n = t.head; return ((t = t.tail), { done: e, value: n }); }, return(t) { return ((e ||= !0), { done: !0, value: t }); }, }; }, pipe() { return k(this, arguments); }, }, Bc = (e, t) => { let n = Object.create(zc); return ((n.head = e), (n.tail = t), n); }, Vc = S(`Nil`), Hc = Object.create({ [Ic]: Ic, _tag: `Nil`, toString() { return O(this.toJSON()); }, toJSON() { return { _id: `List`, _tag: `Nil` }; }, [E]() { return this.toJSON(); }, [y]() { return Vc; }, [w](e) { return Uc(e) && this._tag === e._tag; }, [Symbol.iterator]() { return { next() { return { done: !0, value: void 0 }; }, }; }, pipe() { return k(this, arguments); }, }), Uc = (e) => v(e, Ic), Wc = (e) => e._tag === `Nil`, Gc = (e) => e._tag === `Cons`, Kc = () => Hc, qc = (e, t) => Bc(e, t), Jc = Kc, Yc = (e) => Bc(e, Hc), Xc = t(2, (e, t) => Qc(t, e)), Zc = t(2, (e, t) => qc(t, e)), Qc = t(2, (e, t) => { if (Wc(e)) return t; if (Wc(t)) return e; { let n = Bc(t.head, e), r = n, i = t.tail; for (; !Wc(i);) { let t = Bc(i.head, e); ((r.tail = t), (r = t), (i = i.tail)); } return n; } }), $c = t(3, (e, t, n) => { let r = t, i = e; for (; !Wc(i);) ((r = n(r, i.head)), (i = i.tail)); return r; }), el = (e) => { let t = Jc(), n = e; for (; !Wc(n);) ((t = Zc(t, n.head)), (n = n.tail)); return t; }; Array.prototype; const tl = (function () { function e(e) { e && Object.assign(this, e); } return ((e.prototype = xt), e); })(), nl = Symbol.for(`effect/DifferContextPatch`); function rl(e) { return e; } const il = { ...tl.prototype, [nl]: { _Value: rl, _Patch: rl } }, al = Object.create(Object.assign(Object.create(il), { _tag: `Empty` })), ol = () => al, sl = Object.assign(Object.create(il), { _tag: `AndThen` }), cl = (e, t) => { let n = Object.create(sl); return ((n.first = e), (n.second = t), n); }, ll = Object.assign(Object.create(il), { _tag: `AddService` }), ul = (e, t) => { let n = Object.create(ll); return ((n.key = e), (n.service = t), n); }, dl = Object.assign(Object.create(il), { _tag: `RemoveService` }), fl = (e) => { let t = Object.create(dl); return ((t.key = e), t); }, pl = Object.assign(Object.create(il), { _tag: `UpdateService` }), ml = (e, t) => { let n = Object.create(pl); return ((n.key = e), (n.update = t), n); }, hl = (e, t) => { let n = new Map(e.unsafeMap), r = ol(); for (let [e, i] of t.unsafeMap.entries()) if (n.has(e)) { let t = n.get(e); (n.delete(e), T(t, i) || (r = gl(ml(e, () => i))(r))); } else (n.delete(e), (r = gl(ul(e, i))(r))); for (let [e] of n.entries()) r = gl(fl(e))(r); return r; }, gl = t(2, (e, t) => cl(e, t)), _l = t(2, (e, t) => { if (e._tag === `Empty`) return t; let n = !1, r = Zr(e), i = new Map(t.unsafeMap); for (; ui(r);) { let e = fi(r), t = pi(r); switch (e._tag) { case `Empty`: r = t; break; case `AddService`: (i.set(e.key, e.service), (r = t)); break; case `AndThen`: r = oi(oi(t, e.second), e.first); break; case `RemoveService`: (i.delete(e.key), (r = t)); break; case `UpdateService`: (i.set(e.key, e.update(i.get(e.key))), (n = !0), (r = t)); break; } } if (!n) return Wo(i); let a = new Map(); for (let [e] of t.unsafeMap) i.has(e) && (a.set(e, i.get(e)), i.delete(e)); for (let [e, t] of i) a.set(e, t); return Wo(a); }), vl = Symbol.for(`effect/DifferHashSetPatch`); function yl(e) { return e; } const bl = { ...tl.prototype, [vl]: { _Value: yl, _Key: yl, _Patch: yl } }, xl = Object.create(Object.assign(Object.create(bl), { _tag: `Empty` })), Sl = () => xl, Cl = Object.assign(Object.create(bl), { _tag: `AndThen` }), wl = (e, t) => { let n = Object.create(Cl); return ((n.first = e), (n.second = t), n); }, Tl = Object.assign(Object.create(bl), { _tag: `Add` }), El = (e) => { let t = Object.create(Tl); return ((t.value = e), t); }, Dl = Object.assign(Object.create(bl), { _tag: `Remove` }), Ol = (e) => { let t = Object.create(Dl); return ((t.value = e), t); }, kl = (e, t) => { let [n, r] = La([e, Sl()], ([e, t], n) => (ja(n)(e) ? [Pa(n)(e), t] : [e, Al(El(n))(t)]))(t); return La(r, (e, t) => Al(Ol(t))(e))(n); }, Al = t(2, (e, t) => wl(e, t)), jl = t(2, (e, t) => { if (e._tag === `Empty`) return t; let n = t, r = Zr(e); for (; ui(r);) { let e = fi(r), t = pi(r); switch (e._tag) { case `Empty`: r = t; break; case `AndThen`: r = oi(e.first)(oi(e.second)(t)); break; case `Add`: ((n = Na(e.value)(n)), (r = t)); break; case `Remove`: ((n = Pa(e.value)(n)), (r = t)); } } return n; }), Ml = Symbol.for(`effect/DifferReadonlyArrayPatch`); function Nl(e) { return e; } const Pl = { ...tl.prototype, [Ml]: { _Value: Nl, _Patch: Nl } }, Fl = Object.create(Object.assign(Object.create(Pl), { _tag: `Empty` })), Il = () => Fl, Ll = Object.assign(Object.create(Pl), { _tag: `AndThen` }), Rl = (e, t) => { let n = Object.create(Ll); return ((n.first = e), (n.second = t), n); }, zl = Object.assign(Object.create(Pl), { _tag: `Append` }), Bl = (e) => { let t = Object.create(zl); return ((t.values = e), t); }, Vl = Object.assign(Object.create(Pl), { _tag: `Slice` }), Hl = (e, t) => { let n = Object.create(Vl); return ((n.from = e), (n.until = t), n); }, Ul = Object.assign(Object.create(Pl), { _tag: `Update` }), Wl = (e, t) => { let n = Object.create(Ul); return ((n.index = e), (n.patch = t), n); }, Gl = (e) => { let t = 0, n = Il(); for (; t < e.oldValue.length && t < e.newValue.length;) { let r = e.oldValue[t], i = e.newValue[t], a = e.differ.diff(r, i); (T(a, e.differ.empty) || (n = Kl(n, Wl(t, a))), (t += 1)); } return ( t < e.oldValue.length && (n = Kl(n, Hl(0, t))), t < e.newValue.length && (n = Kl(n, Bl(qn(t)(e.newValue)))), n ); }, Kl = t(2, (e, t) => Rl(e, t)), ql = t(3, (e, t, n) => { if (e._tag === `Empty`) return t; let r = t.slice(), i = ar(e); for (; Fn(i);) { let e = Vn(i), t = Wn(i); switch (e._tag) { case `Empty`: i = t; break; case `AndThen`: (t.unshift(e.first, e.second), (i = t)); break; case `Append`: for (let t of e.values) r.push(t); i = t; break; case `Slice`: ((r = r.slice(e.from, e.until)), (i = t)); break; case `Update`: ((r[e.index] = n.patch(e.patch, r[e.index])), (i = t)); break; } } return r; }), Jl = { [Symbol.for(`effect/Differ`)]: { _P: n, _V: n }, pipe() { return k(this, arguments); }, }, Yl = (e) => { let t = Object.create(Jl); return ( (t.empty = e.empty), (t.diff = e.diff), (t.combine = e.combine), (t.patch = e.patch), t ); }, Xl = () => Yl({ empty: ol(), combine: (e, t) => gl(t)(e), diff: (e, t) => hl(e, t), patch: (e, t) => _l(t)(e), }), Zl = () => Yl({ empty: Sl(), combine: (e, t) => Al(t)(e), diff: (e, t) => kl(e, t), patch: (e, t) => jl(t)(e), }), Ql = (e) => Yl({ empty: Il(), combine: (e, t) => Kl(e, t), diff: (t, n) => Gl({ oldValue: t, newValue: n, differ: e }), patch: (t, n) => ql(t, n, e), }), $l = () => eu((e, t) => t), eu = (e) => Yl({ empty: n, combine: (e, t) => (e === n ? t : t === n ? e : (n) => t(e(n))), diff: (e, t) => (T(e, t) ? n : r(t)), patch: (t, n) => e(n, t(n)), }), tu = (e) => e & 255, nu = (e) => (e >> 8) & 255, ru = (e, t) => (e & 255) + ((t & e & 255) << 8), iu = ru(0, 0), au = (e) => ru(e, e), ou = (e) => ru(e, 0), su = t(2, (e, t) => ru(tu(e) & ~t, nu(e))), cu = t(2, (e, t) => e | t), lu = (e) => (~e >>> 0) & 255, uu = (e) => mu(e, 32), du = t(2, (e, t) => e | t), fu = (e) => pu(e) && !vu(e), pu = (e) => mu(e, 1), mu = t(2, (e, t) => (e & t) !== 0), hu = (...e) => e.reduce((e, t) => e | t, 0), gu = hu(0), _u = (e) => mu(e, 4), vu = (e) => mu(e, 16), yu = t(2, (e, t) => ru(e ^ t, t)), bu = t(2, (e, t) => (e & (lu(tu(t)) | nu(t))) | (tu(t) & nu(t))), xu = Yl({ empty: iu, diff: (e, t) => yu(e, t), combine: (e, t) => cu(t)(e), patch: (e, t) => bu(t, e), }), Su = au, Cu = ou, wu = su, Tu = (e, t) => ({ _tag: `Par`, left: e, right: t }), Eu = (e, t) => ({ _tag: `Seq`, left: e, right: t }), Du = (e) => { let t = Yc(e), n = Jc(); for (;;) { let [e, r] = $c(t, [Nu(), Jc()], ([e, t], n) => { let [r, i] = Ou(n); return [Fu(e, r), Xc(t, i)]; }); if (((n = ku(n, e)), Wc(r))) return el(n); t = r; } throw Error( `BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues`, ); }, Ou = (e) => { let t = e, n = Nu(), r = Jc(), i = Jc(); for (;;) switch (t._tag) { case `Empty`: if (Wc(r)) return [n, i]; ((t = r.head), (r = r.tail)); break; case `Par`: ((r = qc(t.right, r)), (t = t.left)); break; case `Seq`: { let e = t.left, n = t.right; switch (e._tag) { case `Empty`: t = n; break; case `Par`: { let r = e.left, i = e.right; t = Tu(Eu(r, n), Eu(i, n)); break; } case `Seq`: { let r = e.left, i = e.right; t = Eu(r, Eu(i, n)); break; } case `Single`: ((t = e), (i = qc(n, i))); break; } break; } case `Single`: if (((n = Pu(n, t)), Wc(r))) return [n, i]; ((t = r.head), (r = r.tail)); break; } throw Error( `BUG: BlockedRequests.step - please report an issue at https://github.com/Effect-TS/effect/issues`, ); }, ku = (e, t) => { if (Wc(e)) return Yc(Ru(t)); if (Iu(t)) return e; let n = Wu(e.head), r = Lu(t); return n.length === 1 && r.length === 1 && T(n[0], r[0]) ? qc(Uu(e.head, Ru(t)), e.tail) : qc(Ru(t), e); }, Au = Symbol.for(`effect/RequestBlock/RequestBlockParallel`), ju = { _R: (e) => e }; var Mu = class { map; [Au] = ju; constructor(e) { this.map = e; } }; const Nu = () => new Mu(Dc()), Pu = (e, t) => new Mu( Nc(e.map, t.dataSource, (e) => fn(_n(e, ai(t.blockedRequest)), () => Zr(t.blockedRequest))), ), Fu = (e, t) => new Mu( Fc(e.map, t.map, (e, t, n) => jc(e, n, un(Ac(e, n), { onNone: () => t, onSome: (e) => ci(t, e) })), ), ), Iu = (e) => kc(e.map), Lu = (e) => Array.from(Mc(e.map)), Ru = (e) => Hu(Pc(e.map, (e) => Zr(e))), zu = Symbol.for(`effect/RequestBlock/RequestBlockSequential`), Bu = { _R: (e) => e }; var Vu = class { map; [zu] = Bu; constructor(e) { this.map = e; } }; const Hu = (e) => new Vu(e), Uu = (e, t) => new Vu( Fc(t.map, e.map, (e, t, n) => jc(e, n, un(Ac(e, n), { onNone: () => Yr(), onSome: (e) => ci(e, t) })), ), ), Wu = (e) => Array.from(Mc(e.map)), Gu = (e) => Array.from(e.map), Ku = `Pending`, qu = `Done`, Ju = Symbol.for(`effect/Deferred`), Yu = { _E: (e) => e, _A: (e) => e }, Xu = (e) => ({ _tag: Ku, joiners: e }), Zu = (e) => ({ _tag: qu, effect: e }); var Qu = class e { self; called = !1; constructor(e) { this.self = e; } next(e) { return this.called ? { value: e, done: !0 } : ((this.called = !0), { value: this.self, done: !1 }); } return(e) { return { value: e, done: !0 }; } throw(e) { throw e; } [Symbol.iterator]() { return new e(this.self); } }; const $u = (e, t) => { let n = new rd(`Blocked`); return ((n.effect_instruction_i0 = e), (n.effect_instruction_i1 = t), n); }, ed = (e) => { let t = new rd(`RunBlocked`); return ((t.effect_instruction_i0 = e), t); }, td = Symbol.for(`effect/Effect`); var nd = class { patch; op; _op = dt; constructor(e, t) { ((this.patch = e), (this.op = t)); } }, rd = class { _op; effect_instruction_i0 = void 0; effect_instruction_i1 = void 0; effect_instruction_i2 = void 0; trace = void 0; [td] = _t; constructor(e) { this._op = e; } [w](e) { return this === e; } [y]() { return C(this, Ae(this)); } pipe() { return k(this, arguments); } toJSON() { return { _id: `Effect`, _op: this._op, effect_instruction_i0: D(this.effect_instruction_i0), effect_instruction_i1: D(this.effect_instruction_i1), effect_instruction_i2: D(this.effect_instruction_i2), }; } toString() { return O(this.toJSON()); } [E]() { return this.toJSON(); } [Symbol.iterator]() { return new Qu(new we(this)); } }, id = class { _op; effect_instruction_i0 = void 0; effect_instruction_i1 = void 0; effect_instruction_i2 = void 0; trace = void 0; [td] = _t; constructor(e) { ((this._op = e), (this._tag = e)); } [w](e) { return $f(e) && e._op === `Failure` && T(this.effect_instruction_i0, e.effect_instruction_i0); } [y]() { return c(S(this._tag), x(b(this.effect_instruction_i0)), C(this)); } get cause() { return this.effect_instruction_i0; } pipe() { return k(this, arguments); } toJSON() { return { _id: `Exit`, _tag: this._op, cause: this.cause.toJSON() }; } toString() { return O(this.toJSON()); } [E]() { return this.toJSON(); } [Symbol.iterator]() { return new Qu(new we(this)); } }, ad = class { _op; effect_instruction_i0 = void 0; effect_instruction_i1 = void 0; effect_instruction_i2 = void 0; trace = void 0; [td] = _t; constructor(e) { ((this._op = e), (this._tag = e)); } [w](e) { return $f(e) && e._op === `Success` && T(this.effect_instruction_i0, e.effect_instruction_i0); } [y]() { return c(S(this._tag), x(b(this.effect_instruction_i0)), C(this)); } get value() { return this.effect_instruction_i0; } pipe() { return k(this, arguments); } toJSON() { return { _id: `Exit`, _tag: this._op, value: D(this.value) }; } toString() { return O(this.toJSON()); } [E]() { return this.toJSON(); } [Symbol.iterator]() { return new Qu(new we(this)); } }; const od = (e) => v(e, td), sd = (e) => { let t = new rd(lt); return ((t.effect_instruction_i0 = e), t); }, cd = t(3, (e, t, n) => Wd((r) => B(e, (e) => B(xd(H(() => r(t(e)))), (t) => H(() => n(e, t)).pipe( jd({ onFailure: (e) => { switch (t._tag) { case et: return wd(Qa(t.effect_instruction_i0, e)); case it: return wd(e); } }, onSuccess: () => t, }), ), ), ), ), ), ld = t(2, (e, t) => B(e, () => V(t))), ud = (e) => ld(e, void 0), dd = function () { let e = new rd($e); switch (arguments.length) { case 2: ((e.effect_instruction_i0 = arguments[0]), (e.commit = arguments[1])); break; case 3: ((e.effect_instruction_i0 = arguments[0]), (e.effect_instruction_i1 = arguments[1]), (e.commit = arguments[2])); break; case 4: ((e.effect_instruction_i0 = arguments[0]), (e.effect_instruction_i1 = arguments[1]), (e.effect_instruction_i2 = arguments[2]), (e.commit = arguments[3])); break; default: throw Error(ve(`you're not supposed to end up here`)); } return e; }, fd = (e, t = xc) => { let n = new rd(Qe), r; return ( (n.effect_instruction_i0 = (t) => { r = e(t); }), (n.effect_instruction_i1 = t), Bd(n, (e) => (od(r) ? r : Gd)) ); }, pd = (e, t = xc) => H(() => fd(e, t)), md = (e, t = xc) => dd(e, function () { let e, n; function r(t) { e ? e(t) : n === void 0 && (n = t); } let i = new rd(Qe); ((i.effect_instruction_i0 = (t) => { ((e = t), n && t(n)); }), (i.effect_instruction_i1 = t)); let a, o; return ( this.effect_instruction_i0.length === 1 ? (a = Oe(() => this.effect_instruction_i0(r))) : ((o = new AbortController()), (a = Oe(() => this.effect_instruction_i0(r, o.signal)))), a || o ? Bd(i, (e) => (o && o.abort(), a ?? Gd)) : i ); }), hd = t(2, (e, t) => Md(e, { onFailure: t, onSuccess: V })), gd = Symbol.for(`effect/OriginalAnnotation`), _d = (e, t) => F(t) ? new Proxy(e, { has(e, t) { return t === Mo || t === gd || t in e; }, get(n, r) { return r === Mo ? t.value : r === gd ? e : n[r]; }, }) : e, vd = (e) => (le(e) && !(Mo in e) ? sd((t) => wd(Ya(_d(e, xp(t))))) : wd(Ya(e))), yd = (e) => Td(() => Ya(new Wf(e))), bd = (e) => Md(e, { onFailure: (e) => V(j(e)), onSuccess: (e) => V(A(e)) }), xd = (e) => Ad(e, { onFailure: W, onSuccess: G }), Sd = (e) => (le(e) && !(Mo in e) ? sd((t) => wd(Ja(_d(e, xp(t))))) : wd(Ja(e))), Cd = (e) => B(U(e), Sd), wd = (e) => { let t = new id(et); return ((t.effect_instruction_i0 = e), t); }, Td = (e) => B(U(e), wd), Ed = sd((e) => V(e.id())), Dd = (e) => sd((t) => e(t.id())), B = t(2, (e, t) => { let n = new rd(nt); return ((n.effect_instruction_i0 = e), (n.effect_instruction_i1 = t), n); }), Od = (e) => { let t = new rd(`OnStep`); return ((t.effect_instruction_i0 = e), t); }, kd = (e) => B(e, n), Ad = t(2, (e, t) => jd(e, { onFailure: (e) => V(t.onFailure(e)), onSuccess: (e) => V(t.onSuccess(e)) }), ), jd = t(2, (e, t) => { let n = new rd(rt); return ( (n.effect_instruction_i0 = e), (n.effect_instruction_i1 = t.onFailure), (n.effect_instruction_i2 = t.onSuccess), n ); }), Md = t(2, (e, t) => jd(e, { onFailure: (e) => { if (oo(e).length > 0) return wd(po(e)); let n = ao(e); return n.length > 0 ? t.onFailure(di(n)) : wd(e); }, onSuccess: t.onSuccess, }), ), Nd = t(2, (e, t) => H(() => { let n = L(e), r = En(n.length), i = 0; return ld( qd({ while: () => i < n.length, body: () => t(n[i], i), step: (e) => { r[i++] = e; }, }), r, ); }), ), Pd = t(2, (e, t) => H(() => { let n = L(e), r = 0; return qd({ while: () => r < n.length, body: () => t(n[r], r), step: () => { r++; }, }); }), ), Fd = (e) => { let t = new rd(ot); return ((t.effect_instruction_i0 = Su(1)), (t.effect_instruction_i1 = () => e), t); }, Id = t(2, (e, t) => B(e, (e) => U(() => t(e)))), Ld = t(2, (e, t) => Md(e, { onFailure: (e) => Cd(() => t.onFailure(e)), onSuccess: (e) => U(() => t.onSuccess(e)), }), ), Rd = t(2, (e, t) => jd(e, { onFailure: (e) => { let n = lo(e); switch (n._tag) { case `Left`: return Cd(() => t(n.left)); case `Right`: return wd(n.right); } }, onSuccess: V, }), ), zd = t(2, (e, t) => Wd((n) => jd(n(e), { onFailure: (e) => { let n = W(e); return jd(t(n), { onFailure: (t) => W(Qa(e, t)), onSuccess: () => n }); }, onSuccess: (e) => { let n = G(e); return Zd(t(n), n); }, }), ), ), Bd = t(2, (e, t) => zd(e, cp({ onFailure: (e) => (io(e) ? ud(t(so(e))) : Gd), onSuccess: () => Gd })), ), V = (e) => { let t = new ad(it); return ((t.effect_instruction_i0 = e), t); }, H = (e) => { let t = new rd($e); return ((t.commit = e), t); }, U = (e) => { let t = new rd(at); return ((t.effect_instruction_i0 = e), t); }, Vd = t( (e) => e.length === 3 || (e.length === 2 && !(le(e[1]) && `onlyEffect` in e[1])), (e, t) => B(e, (e) => { let n = typeof t == `function` ? t(e) : t; return od(n) ? ld(n, e) : _e(n) ? fd((t) => { n.then( (n) => t(V(e)), (e) => t(Sd(new Qf(e, `An unknown error occurred in Effect.tap`))), ); }) : V(e); }), ), Hd = (e) => sd((t) => { let n = c( t.getFiberRef(Pf), I(() => t.scope()), ); return e(hf(Pf, N(n))); }), Ud = (e) => { let t = new rd(ot); return ((t.effect_instruction_i0 = Cu(1)), (t.effect_instruction_i1 = () => e), t); }, Wd = (e) => dd(e, function () { let e = new rd(ot); return ( (e.effect_instruction_i0 = Cu(1)), (e.effect_instruction_i1 = (e) => pu(e) ? Oe(() => this.effect_instruction_i0(Fd)) : Oe(() => this.effect_instruction_i0(Ud))), e ); }), Gd = V(void 0), Kd = (e) => { let t = new rd(ot); return ((t.effect_instruction_i0 = e), (t.effect_instruction_i1 = void 0), t); }, qd = (e) => { let t = new rd(st); return ( (t.effect_instruction_i0 = e.while), (t.effect_instruction_i1 = e.body), (t.effect_instruction_i2 = e.step), t ); }, Jd = (e) => { let t = new rd(ut); return e?.priority === void 0 ? t : Of(t, e.priority); }, Yd = t(2, (e, t) => B(e, (e) => Id(t, (t) => [e, t]))), Xd = t(2, (e, t) => B(e, (e) => ld(t, e))), Zd = t(2, (e, t) => B(e, () => t)), Qd = (e) => B(Ed, (t) => c(e, $d(t))), $d = t(2, (e, t) => B(e.interruptAsFork(t), () => e.await)), ef = { _tag: `All`, syslog: 0, label: `ALL`, ordinal: -(2 ** 53 - 1), pipe() { return k(this, arguments); }, }, tf = { _tag: `Fatal`, syslog: 2, label: `FATAL`, ordinal: 5e4, pipe() { return k(this, arguments); }, }, nf = { _tag: `Error`, syslog: 3, label: `ERROR`, ordinal: 4e4, pipe() { return k(this, arguments); }, }, rf = { _tag: `Warning`, syslog: 4, label: `WARN`, ordinal: 3e4, pipe() { return k(this, arguments); }, }, af = { _tag: `Info`, syslog: 6, label: `INFO`, ordinal: 2e4, pipe() { return k(this, arguments); }, }, of = { _tag: `Debug`, syslog: 7, label: `DEBUG`, ordinal: 1e4, pipe() { return k(this, arguments); }, }, sf = { _tag: `Trace`, syslog: 7, label: `TRACE`, ordinal: 0, pipe() { return k(this, arguments); }, }, cf = { _tag: `None`, syslog: 7, label: `OFF`, ordinal: 2 ** 53 - 1, pipe() { return k(this, arguments); }, }, lf = Symbol.for(`effect/FiberRef`), uf = { _A: (e) => e }, df = (e) => sd((t) => G(t.getFiberRef(e))), ff = t(2, (e, t) => B(df(e), t)), pf = t(2, (e, t) => mf(e, () => [void 0, t])), mf = t(2, (e, t) => sd((n) => { let [r, i] = t(n.getFiberRef(e)); return (n.setFiberRef(e, i), V(r)); }), ), hf = t(3, (e, t, n) => cd( Xd(df(t), pf(t, n)), () => e, (e) => pf(t, e), ), ), gf = (e, t) => bf(e, { differ: $l(), fork: t?.fork ?? n, join: t?.join }), _f = (e) => { let t = Zl(); return bf(e, { differ: t, fork: t.empty }); }, vf = (e) => { let t = Ql($l()); return bf(e, { differ: t, fork: t.empty }); }, yf = (e) => { let t = Xl(); return bf(e, { differ: t, fork: t.empty }); }, bf = (e, t) => ({ ...St, [lf]: uf, initial: e, commit() { return df(this); }, diff: (e, n) => t.differ.diff(e, n), combine: (e, n) => t.differ.combine(e, n), patch: (e) => (n) => t.differ.patch(e, n), fork: t.fork, join: t.join ?? ((e, t) => t), }), xf = (e) => bf(e, { differ: xu, fork: xu.empty }), Sf = g(Symbol.for(`effect/FiberRef/currentContext`), () => yf(os())), Cf = g(Symbol.for(`effect/FiberRef/currentSchedulingPriority`), () => gf(0)), wf = g(Symbol.for(`effect/FiberRef/currentMaxOpsBeforeYield`), () => gf(2048)), Tf = g(Symbol.for(`effect/FiberRef/currentLogAnnotation`), () => gf(Dc())), Ef = g(Symbol.for(`effect/FiberRef/currentLogLevel`), () => gf(af)), Df = g(Symbol.for(`effect/FiberRef/currentLogSpan`), () => gf(Jc())), Of = t(2, (e, t) => hf(e, Cf, t)), kf = g(Symbol.for(`effect/FiberRef/currentConcurrency`), () => gf(`unbounded`)), Af = g(Symbol.for(`effect/FiberRef/currentRequestBatching`), () => gf(!0)), jf = g(Symbol.for(`effect/FiberRef/currentUnhandledErrorLogLevel`), () => gf(N(of))), Mf = g(Symbol.for(`effect/FiberRef/versionMismatchErrorLogLevel`), () => gf(N(rf))), Nf = g(Symbol.for(`effect/FiberRef/currentMetricLabels`), () => vf(ir())), Pf = g(Symbol.for(`effect/FiberRef/currentForkScopeOverride`), () => gf(M(), { fork: () => M(), join: (e, t) => e }), ), Ff = g(Symbol.for(`effect/FiberRef/currentInterruptedCause`), () => gf(qa, { fork: () => qa, join: (e, t) => e }), ), If = Symbol.for(`effect/Scope`), Lf = Symbol.for(`effect/CloseableScope`), Rf = (e, t) => e.addFinalizer(() => ud(t)), zf = (e, t) => e.close(t), Bf = (e, t) => e.fork(t), Vf = (function () { class e extends globalThis.Error { commit() { return Sd(this); } toJSON() { let e = { ...this }; return ( this.message && (e.message = this.message), this.cause && (e.cause = this.cause), e ); } [E]() { return this.toString === globalThis.Error.prototype.toString ? `Bun` in globalThis ? To(Ja(this), { renderErrorCause: !0 }) : this : this.stack ? `${this.toString()}\n${this.stack .split(` `) .slice(1).join(` `)}` : this.toString(); } } return (Object.assign(e.prototype, Ct), e); })(), Hf = (e, t) => { class n extends Vf { _tag = t; } return (Object.assign(n.prototype, e), (n.prototype.name = t), n); }, Uf = Symbol.for(`effect/Cause/errors/RuntimeException`), Wf = Hf({ [Uf]: Uf }, `RuntimeException`), Gf = Symbol.for(`effect/Cause/errors/InterruptedException`), Kf = (e) => v(e, Gf), qf = Symbol.for(`effect/Cause/errors/IllegalArgument`), Jf = Hf({ [qf]: qf }, `IllegalArgumentException`), Yf = Symbol.for(`effect/Cause/errors/NoSuchElement`), Xf = Hf({ [Yf]: Yf }, `NoSuchElementException`), Zf = Symbol.for(`effect/Cause/errors/UnknownException`), Qf = (function () { class e extends Vf { _tag = `UnknownException`; error; constructor(e, t) { (super(t ?? `An unknown error occurred`, { cause: e }), (this.error = e)); } } return (Object.assign(e.prototype, { [Zf]: Zf, name: `UnknownException` }), e); })(), $f = (e) => od(e) && `_tag` in e && (e._tag === `Success` || e._tag === `Failure`), ep = (e) => e._tag === `Success`, tp = t(2, (e, t) => { switch (e._tag) { case et: return W(e.effect_instruction_i0); case it: return G(t); } }), np = (e) => tp(e, void 0), rp = (e, t) => dp(e, t?.parallel ? Za : Qa), ip = (e) => W(Ya(e)), ap = (e) => W(Ja(e)), W = (e) => { let t = new id(et); return ((t.effect_instruction_i0 = e), t); }, op = (e) => W(Xa(e)), sp = t(2, (e, t) => { switch (e._tag) { case et: return W(e.effect_instruction_i0); case it: return G(t(e.effect_instruction_i0)); } }), cp = t(2, (e, { onFailure: t, onSuccess: n }) => { switch (e._tag) { case et: return t(e.effect_instruction_i0); case it: return n(e.effect_instruction_i0); } }), G = (e) => { let t = new ad(it); return ((t.effect_instruction_i0 = e), t); }, lp = G(void 0), up = t(3, (e, t, { onFailure: n, onSuccess: r }) => { switch (e._tag) { case et: switch (t._tag) { case it: return W(e.effect_instruction_i0); case et: return W(n(e.effect_instruction_i0, t.effect_instruction_i0)); } case it: switch (t._tag) { case it: return G(r(e.effect_instruction_i0, t.effect_instruction_i0)); case et: return W(t.effect_instruction_i0); } } }), dp = (e, t) => { let n = Qr(e); return ui(n) ? c( pi(n), ur(c(fi(n), sp(Zr)), (e, n) => c(e, up(n, { onSuccess: (e, t) => c(e, oi(t)), onFailure: t })), ), sp(ti), sp((e) => ei(e)), N, ) : M(); }, fp = (e) => ({ ...St, [Ju]: Yu, state: tc(Xu([])), commit() { return pp(this); }, blockingOn: e, }), pp = (e) => pd((t) => { let n = nc(e.state); switch (n._tag) { case qu: return t(n.effect); case Ku: return (n.joiners.push(t), hp(e, t)); } }, e.blockingOn), mp = (e, t) => { let n = nc(e.state); if (n._tag === `Pending`) { rc(e.state, Zu(t)); for (let e = 0, r = n.joiners.length; e < r; e++) n.joiners[e](t); } }, hp = (e, t) => U(() => { let n = nc(e.state); if (n._tag === `Pending`) { let e = n.joiners.indexOf(t); e >= 0 && n.joiners.splice(e, 1); } }), gp = sd((e) => G(e.currentContext)), _p = () => gp, vp = (e) => B(_p(), e), yp = t(2, (e, t) => hf(Sf, t)(e)), bp = t(2, (e, t) => vp((n) => yp(e, t(n)))), xp = (e) => { let t = e.currentSpan; return t !== void 0 && t._tag === `Span` ? N(t) : M(); }, Sp = to, Cp = Jf, wp = To, Tp = `InvalidData`, Ep = `MissingData`, Dp = `SourceUnavailable`, Op = `Unsupported`, kp = Symbol.for(`effect/ConfigError`), Ap = { _tag: `ConfigError`, [kp]: kp }, jp = (e, t) => { let n = Object.create(Ap); return ( (n._op = `And`), (n.left = e), (n.right = t), Object.defineProperty(n, "toString", { enumerable: !1, value() { return `${this.left} and ${this.right}`; }, }), Object.defineProperty(n, "message", { enumerable: !1, get() { return this.toString(); }, }), n ); }, Mp = (e, t) => { let n = Object.create(Ap); return ( (n._op = `Or`), (n.left = e), (n.right = t), Object.defineProperty(n, "toString", { enumerable: !1, value() { return `${this.left} or ${this.right}`; }, }), Object.defineProperty(n, "message", { enumerable: !1, get() { return this.toString(); }, }), n ); }, Np = (e, t, n = { pathDelim: `.` }) => { let r = Object.create(Ap); return ( (r._op = Tp), (r.path = e), (r.message = t), Object.defineProperty(r, "toString", { enumerable: !1, value() { return `(Invalid data at ${c(this.path, hr(n.pathDelim))}: "${this.message}")`; }, }), r ); }, Pp = (e, t, n = { pathDelim: `.` }) => { let r = Object.create(Ap); return ( (r._op = Ep), (r.path = e), (r.message = t), Object.defineProperty(r, "toString", { enumerable: !1, value() { return `(Missing data at ${c(this.path, hr(n.pathDelim))}: "${this.message}")`; }, }), r ); }, Fp = (e, t, n, r = { pathDelim: `.` }) => { let i = Object.create(Ap); return ( (i._op = Dp), (i.path = e), (i.message = t), (i.cause = n), Object.defineProperty(i, "toString", { enumerable: !1, value() { return `(Source unavailable at ${c(this.path, hr(r.pathDelim))}: "${this.message}")`; }, }), i ); }, Ip = (e, t, n = { pathDelim: `.` }) => { let r = Object.create(Ap); return ( (r._op = Op), (r.path = e), (r.message = t), Object.defineProperty(r, "toString", { enumerable: !1, value() { return `(Unsupported operation at ${c(this.path, hr(n.pathDelim))}: "${this.message}")`; }, }), r ); }, Lp = t(2, (e, t) => { switch (e._op) { case `And`: return jp(Lp(e.left, t), Lp(e.right, t)); case `Or`: return Mp(Lp(e.left, t), Lp(e.right, t)); case Tp: return Np([...t, ...e.path], e.message); case Ep: return Pp([...t, ...e.path], e.message); case Dp: return Fp([...t, ...e.path], e.message, e.cause); case Op: return Ip([...t, ...e.path], e.message); } }), Rp = Symbol.for(`effect/Clock`), zp = as(`effect/Clock`), Bp = 2 ** 31 - 1, Vp = { unsafeSchedule(e, t) { let n = Vs(t); if (n > Bp) return a; let r = !1, i = setTimeout(() => { ((r = !0), e()); }, n); return () => (clearTimeout(i), !r); }, }, Hp = (function () { let e = BigInt(1e6); if (typeof performance > `u` || typeof performance.now != `function`) return () => BigInt(Date.now()) * e; let t; return () => ( t === void 0 && (t = BigInt(Date.now()) * e - BigInt(Math.round(performance.now() * 1e6))), t + BigInt(Math.round(performance.now() * 1e6)) ); })(), Up = (function () { let e = typeof process == `object` && `hrtime` in process && typeof process.hrtime.bigint == `function` ? process.hrtime : void 0; if (!e) return Hp; let t = Hp() - e.bigint(); return () => t + e.bigint(); })(); var Wp = class { [Rp] = Rp; unsafeCurrentTimeMillis() { return Date.now(); } unsafeCurrentTimeNanos() { return Up(); } currentTimeMillis = U(() => this.unsafeCurrentTimeMillis()); currentTimeNanos = U(() => this.unsafeCurrentTimeNanos()); scheduler() { return V(Vp); } sleep(e) { return md((t) => { let n = Vp.unsafeSchedule(() => t(Gd), e); return ud(U(n)); }); } }; const Gp = () => new Wp(), Kp = on, qp = (e) => { if (e === `NaN`) return Pt(NaN); if (e === `Infinity`) return Pt(1 / 0); if (e === `-Infinity`) return Pt(-1 / 0); if (e.trim() === ``) return Nt; let t = Number(e); return Number.isNaN(t) ? Nt : Pt(t); }, Jp = (e) => e.replace(/[/\\^$*+?.()|[\]{}]/g, `\\$&`), Yp = { _tag: `Empty` }, Xp = t(2, (e, t) => { let n = Yc(t), r = e; for (; Gc(n);) { let e = n.head; switch (e._tag) { case `Empty`: n = n.tail; break; case `AndThen`: n = qc(e.first, qc(e.second, n.tail)); break; case `MapName`: ((r = or(r, e.f)), (n = n.tail)); break; case `Nested`: ((r = An(r, e.name)), (n = n.tail)); break; case `Unnested`: if (c(Bn(r), Cn(e.name))) ((r = Wn(r)), (n = n.tail)); else return j(Pp(r, `Expected ${e.name} to be in path in ConfigProvider#unnested`)); break; } } return A(r); }), Zp = (e, t) => [...e, ...t], Qp = Symbol.for(`effect/ConfigProvider`), $p = as(`effect/ConfigProvider`), em = Symbol.for(`effect/ConfigProviderFlat`), tm = (e) => ({ [Qp]: Qp, pipe() { return k(this, arguments); }, ...e, }), nm = (e) => ({ [em]: em, patch: e.patch, load: (t, n, r = !0) => e.load(t, n, r), enumerateChildren: e.enumerateChildren, }), rm = (e) => tm({ load: (t) => B(sm(e, ir(), t, !1), (e) => un(Bn(e), { onNone: () => Sd(Pp(ir(), `Expected a single value having structure: ${t}`)), onSome: V, }), ), flattened: e, }), im = (e) => { let { pathDelim: t, seqDelim: n } = Object.assign({}, { pathDelim: `_`, seqDelim: `,` }, e), r = (e) => c(e, hr(t)), i = (e) => e.split(t), a = () => typeof process < `u` && `env` in process && typeof process.env == `object` ? process.env : {}; return rm( nm({ load: (e, t, i = !0) => { let o = r(e), s = a(); return c( o in s ? N(s[o]) : M(), Rd(() => Pp(e, `Expected ${o} to exist in the process context`)), B((r) => um(r, e, t, n, i)), ); }, enumerateChildren: (e) => U(() => { let t = a(), n = Object.keys(t) .map((e) => i(e.toUpperCase())) .filter((t) => { for (let n = 0; n < e.length; n++) { let r = c(e, zn(n)), i = t[n]; if (i === void 0 || r !== i) return !1; } return !0; }) .flatMap((t) => t.slice(e.length, e.length + 1)); return ka(n); }), patch: Yp, }), ); }, am = (e, t, n, r) => { let i = dr(n.length, (t) => (t >= r.length ? M() : N([e(t), t + 1]))), a = dr(r.length, (e) => (e >= n.length ? M() : N([t(e), e + 1]))); return [Zp(n, i), Zp(r, a)]; }, om = (e, t) => { let n = t; if (n._tag === `Nested`) { let t = e.slice(); for (; n._tag === `Nested`;) (t.push(n.name), (n = n.config)); return t; } return e; }, sm = (e, t, n, r) => { let i = n; switch (i._tag) { case `Constant`: return V(ar(i.value)); case `Described`: return H(() => sm(e, t, i.config, r)); case `Fail`: return Sd(Pp(t, i.message)); case `Fallback`: return c( H(() => sm(e, t, i.first, r)), hd((n) => i.condition(n) ? c( sm(e, t, i.second, r), hd((e) => Sd(Mp(n, e))), ) : Sd(n), ), ); case `Lazy`: return H(() => sm(e, t, i.config(), r)); case `MapOrFail`: return H(() => c(sm(e, t, i.original, r), B(Nd((e) => c(i.mapOrFail(e), Rd(Lp(om(t, i.original))))))), ); case `Nested`: return H(() => sm(e, Zp(t, ar(i.name)), i.config, r)); case `Primitive`: return c( Xp(t, e.patch), B((t) => c( e.load(t, i, r), B((e) => { if (e.length === 0) { let e = c( Hn(t), I(() => `<n/a>`), ); return Sd(Pp([], `Expected ${i.description} with name ${e}`)); } return V(e); }), ), ), ); case `Sequence`: return c( Xp(t, e.patch), B((n) => c( e.enumerateChildren(n), B(fm), B((n) => n.length === 0 ? H(() => Id(sm(e, t, i.config, !0), ar)) : c( Nd(n, (n) => sm(e, jn(t, `[${n}]`), i.config, !0)), Id((e) => { let t = cr(e); return t.length === 0 ? ar(ir()) : ar(t); }), ), ), ), ), ); case `HashMap`: return H(() => c( Xp(t, e.patch), B((t) => c( e.enumerateChildren(t), B((n) => c( n, Nd((n) => sm(e, Zp(t, ar(n)), i.valueConfig, r)), Id((e) => e.length === 0 ? ar(Dc()) : c( dm(e), or((e) => Oc(Xn(L(n), e))), ), ), ), ), ), ), ), ); case `ZipWith`: return H(() => c( sm(e, t, i.left, r), bd, B((n) => c( sm(e, t, i.right, r), bd, B((e) => { if (Jt(n) && Jt(e)) return Sd(jp(n.left, e.left)); if (Jt(n) && Yt(e)) return Sd(n.left); if (Yt(n) && Jt(e)) return Sd(e.left); if (Yt(n) && Yt(e)) { let r = c(t, hr(`.`)), a = cm(t, r), [o, s] = am(a, a, c(n.right, or(A)), c(e.right, or(A))); return c( o, Xn(s), Nd(([e, t]) => c( Yd(e, t), Id(([e, t]) => i.zip(e, t)), ), ), ); } throw Error( `BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues`, ); }), ), ), ), ); } }, cm = (e, t) => (n) => j(Pp(e, `The element at index ${n} in a sequence at path "${t}" was missing`)), lm = (e, t) => e.split(RegExp(`\\s*${Jp(t)}\\s*`)), um = (e, t, n, r, i) => i ? c( lm(e, r), Nd((e) => n.parse(e.trim())), Rd(Lp(t)), ) : c(n.parse(e), Ld({ onFailure: Lp(t), onSuccess: ar })), dm = (e) => Object.keys(e[0]).map((t) => e.map((e) => e[t])), fm = (e) => c(Nd(e, mm), Ld({ onFailure: () => ir(), onSuccess: Yn(Kp) }), bd, Id(en)), pm = /^(\[(\d+)\])$/, mm = (e) => { let t = e.match(pm); if (t !== null) { let e = t[2]; return c(e !== void 0 && e.length > 0 ? N(e) : M(), vn(hm)); } return M(); }, hm = (e) => { let t = Number.parseInt(e); return Number.isNaN(t) ? M() : N(t); }, gm = Symbol.for(`effect/Console`), _m = as(`effect/Console`), vm = { [gm]: gm, assert(e, ...t) { return U(() => { console.assert(e, ...t); }); }, clear: U(() => { console.clear(); }), count(e) { return U(() => { console.count(e); }); }, countReset(e) { return U(() => { console.countReset(e); }); }, debug(...e) { return U(() => { console.debug(...e); }); }, dir(e, t) { return U(() => { console.dir(e, t); }); }, dirxml(...e) { return U(() => { console.dirxml(...e); }); }, error(...e) { return U(() => { console.error(...e); }); }, group(e) { return e?.collapsed ? U(() => console.groupCollapsed(e?.label)) : U(() => console.group(e?.label)); }, groupEnd: U(() => { console.groupEnd(); }), info(...e) { return U(() => { console.info(...e); }); }, log(...e) { return U(() => { console.log(...e); }); }, table(e, t) { return U(() => { console.table(e, t); }); }, time(e) { return U(() => console.time(e)); }, timeEnd(e) { return U(() => console.timeEnd(e)); }, timeLog(e, ...t) { return U(() => { console.timeLog(e, ...t); }); }, trace(...e) { return U(() => { console.trace(...e); }); }, warn(...e) { return U(() => { console.warn(...e); }); }, unsafe: console, }, ym = Symbol.for(`effect/Random`), bm = as(`effect/Random`); var xm = class { seed; [ym] = ym; PRNG; constructor(e) { ((this.seed = e), (this.PRNG = new be(e))); } get next() { return U(() => this.PRNG.number()); } get nextBoolean() { return Id(this.next, (e) => e > 0.5); } get nextInt() { return U(() => this.PRNG.integer(2 ** 53 - 1)); } nextRange(e, t) { return Id(this.next, (n) => (t - e) * n + e); } nextIntBetween(e, t) { return U(() => this.PRNG.integer(t - e) + e); } shuffle(e) { return Sm(e, (e) => this.nextIntBetween(0, e)); } }; const Sm = (e, t) => H(() => c( U(() => Array.from(e)), B((e) => { let n = []; for (let t = e.length; t >= 2; --t) n.push(t); return c( n, Pd((n) => c( t(n), Id((t) => Cm(e, n - 1, t)), ), ), ld(Qr(e)), ); }), ), ), Cm = (e, t, n) => { let r = e[t]; return ((e[t] = e[n]), (e[n] = r), e); }, wm = (e) => new xm(b(e)), Tm = Symbol.for(`effect/Tracer`), Em = (e) => ({ [Tm]: Tm, ...e }), Dm = as(`effect/Tracer`), Om = as(`effect/ParentSpan`), km = (function () { return function (e) { let t = ``; for (let n = 0; n < e; n++) t += `abcdef0123456789`.charAt(Math.floor(Math.random() * 16)); return t; }; })(); var Am = class { name; parent; context; startTime; kind; _tag = `Span`; spanId; traceId = `native`; sampled = !0; status; attributes; events = []; links; constructor(e, t, n, r, i, a) { ((this.name = e), (this.parent = t), (this.context = n), (this.startTime = i), (this.kind = a), (this.status = { _tag: `Started`, startTime: i }), (this.attributes = new Map()), (this.traceId = t._tag === `Some` ? t.value.traceId : km(32)), (this.spanId = km(16)), (this.links = Array.from(r))); } end(e, t) { this.status = { _tag: `Ended`, endTime: e, exit: t, startTime: this.status.startTime }; } attribute(e, t) { this.attributes.set(e, t); } event(e, t, n) { this.events.push([e, t, n ?? {}]); } addLinks(e) { this.links.push(...e); } }; const jm = Em({ span: (e, t, n, r, i, a) => new Am(e, t, n, r, i, a), context: (e) => e() }), Mm = ms()(`effect/Tracer/DisablePropagation`, { defaultValue: a }), Nm = c(os(), cs(zp, Gp()), cs(_m, vm), cs(bm, wm(Math.random())), cs($p, im()), cs(Dm, jm)), Pm = g(Symbol.for(`effect/DefaultServices/currentServices`), () => yf(Nm)), Fm = (function () { let e = Symbol.for(`effect/Data/Error/plainArgs`); return { BaseEffectError: class extends Vf { constructor(t) { (super(t?.message, t?.cause ? { cause: t.cause } : void 0), t && (Object.assign(this, t), Object.defineProperty(this, e, { value: t, enumerable: !1 }))); } toJSON() { return { ...this[e], ...this }; } }, }.BaseEffectError; })(), Im = (e) => { let t = { BaseEffectError: class extends Fm { _tag = e; }, }; return ((t.BaseEffectError.prototype.name = e), t.BaseEffectError); }, Lm = bt, Rm = wt; var zm = class extends Rm {}; const Bm = `Sequential`, Vm = `Parallel`, Hm = { _tag: Bm }, Um = { _tag: Vm }, Wm = (e) => ({ _tag: `ParallelN`, parallelism: e }), Gm = (e) => e._tag === Bm, Km = (e) => e._tag === Vm, qm = Hm, Jm = Um, Ym = Wm; function Xm(e) { return new $m(e); } function Zm() { return Xm(new Map()); } const Qm = Symbol.for(`effect/FiberRefs`); var $m = class { locals; [Qm] = Qm; constructor(e) { this.locals = e; } pipe() { return k(this, arguments); } }; const eh = (e, t, n, r = !1) => { let i = e, a = t, o = n, s = r, c; for (; c === void 0;) if (R(a) && R(o)) { let e = Vn(a)[0], t = Wn(a), n = Vn(o)[0], r = Vn(o)[1], i = Wn(o); e.startTimeMillis < n.startTimeMillis ? ((o = i), (s = !0)) : e.startTimeMillis > n.startTimeMillis ? (a = t) : e.id < n.id ? ((o = i), (s = !0)) : e.id > n.id ? (a = t) : (c = [r, s]); } else c = [i.initial, !0]; return c; }, th = t(3, (e, t, n) => { let r = new Map(e.locals); return ( n.locals.forEach((e, n) => { let i = e[0][1]; if (!e[0][0][w](t)) { if (!r.has(n)) { if (T(i, n.initial)) return; r.set(n, [[t, n.join(n.initial, i)]]); return; } let a = r.get(n), [o, s] = eh(n, a, e); if (s) { let e = n.diff(o, i), s = a[0][1], c = n.join(s, n.patch(e)(s)); if (!T(s, c)) { let e, i = a[0][0]; ((e = i[w](t) ? [[i, c], ...a.slice(1)] : [[t, c], ...a]), r.set(n, e)); } } } }), new $m(r) ); }), nh = t(2, (e, t) => { let n = new Map(); return (rh(e, n, t), new $m(n)); }), rh = (e, t, n) => { e.locals.forEach((e, r) => { let i = e[0][1], a = r.patch(r.fork)(i); T(i, a) ? t.set(r, e) : t.set(r, [[n, a], ...e]); }); }, ih = t(2, (e, t) => { let n = new Map(e.locals); return (n.delete(t), new $m(n)); }), ah = t(2, (e, t) => (e.locals.has(t) ? N(Vn(e.locals.get(t))[1]) : M())), oh = t(2, (e, t) => c( ah(e, t), I(() => t.initial), ), ), sh = t(2, (e, { fiberId: t, fiberRef: n, value: r }) => { if (e.locals.size === 0) return new $m(new Map([[n, [[t, r]]]])); let i = new Map(e.locals); return (ch(i, t, n, r), new $m(i)); }), ch = (e, t, n, r) => { let i = e.get(n) ?? [], a; if (R(i)) { let [e, n] = Vn(i); if (e[w](t)) { if (T(n, r)) return; a = [[t, r], ...i.slice(1)]; } else a = [[t, r], ...i]; } else a = [[t, r]]; e.set(n, a); }, lh = t(2, (e, { entries: t, forkAs: n }) => { if (e.locals.size === 0) return new $m(new Map(t)); let r = new Map(e.locals); return ( n !== void 0 && rh(e, r, n), t.forEach(([e, t]) => { t.length === 1 ? ch(r, t[0][0], e, t[0][1]) : t.forEach(([t, n]) => { ch(r, t, e, n); }); }), new $m(r) ); }), uh = oh, dh = lh, fh = Zm, ph = `Empty`, mh = `Remove`, hh = `Update`, gh = `AndThen`, _h = { _tag: ph }, vh = (e, t) => { let n = new Map(e.locals), r = _h; for (let [e, i] of t.locals.entries()) { let t = Vn(i)[1], a = n.get(e); if (a !== void 0) { let n = Vn(a)[1]; T(n, t) || (r = yh({ _tag: hh, fiberRef: e, patch: e.diff(n, t) })(r)); } else r = yh({ _tag: `Add`, fiberRef: e, value: t })(r); n.delete(e); } for (let [e] of n.entries()) r = yh({ _tag: mh, fiberRef: e })(r); return r; }, yh = t(2, (e, t) => ({ _tag: gh, first: e, second: t })), bh = t(3, (e, t, n) => { let r = n, i = ar(e); for (; R(i);) { let e = Vn(i), n = Wn(i); switch (e._tag) { case ph: i = n; break; case `Add`: ((r = sh(r, { fiberId: t, fiberRef: e.fiberRef, value: e.value })), (i = n)); break; case mh: ((r = ih(r, e.fiberRef)), (i = n)); break; case hh: { let a = oh(r, e.fiberRef); ((r = sh(r, { fiberId: t, fiberRef: e.fiberRef, value: e.fiberRef.patch(e.patch)(a) })), (i = n)); break; } case gh: i = An(e.first)(An(e.second)(n)); break; } } return r; }), xh = vh, Sh = bh, Ch = `effect/FiberStatus`, wh = Symbol.for(Ch), Th = `Done`, Eh = S(`${Ch}-${Th}`); var Dh = class { [wh] = wh; _tag = Th; [y]() { return Eh; } [w](e) { return Nh(e) && e._tag === `Done`; } }, Oh = class { runtimeFlags; [wh] = wh; _tag = `Running`; constructor(e) { this.runtimeFlags = e; } [y]() { return c(b(Ch), x(b(this._tag)), x(b(this.runtimeFlags)), C(this)); } [w](e) { return Nh(e) && e._tag === `Running` && this.runtimeFlags === e.runtimeFlags; } }, kh = class { runtimeFlags; blockingOn; [wh] = wh; _tag = `Suspended`; constructor(e, t) { ((this.runtimeFlags = e), (this.blockingOn = t)); } [y]() { return c(b(Ch), x(b(this._tag)), x(b(this.runtimeFlags)), x(b(this.blockingOn)), C(this)); } [w](e) { return ( Nh(e) && e._tag === `Suspended` && this.runtimeFlags === e.runtimeFlags && T(this.blockingOn, e.blockingOn) ); } }; const Ah = new Dh(), jh = (e) => new Oh(e), Mh = (e, t) => new kh(e, t), Nh = (e) => v(e, wh), Ph = (e) => e._tag === Th, Fh = Ah, Ih = jh, Lh = Mh, Rh = Ph, zh = ef, Bh = tf, Vh = nf, Hh = rf, Uh = af, Wh = of, Gh = sf, Kh = cf, qh = cn( c( Kp, sn((e) => e.ordinal), ), ), Jh = (e) => { switch (e) { case `All`: return zh; case `Debug`: return Wh; case `Error`: return Vh; case `Fatal`: return Bh; case `Info`: return Uh; case `Trace`: return Gh; case `None`: return Kh; case `Warning`: return Hh; } }, Yh = Symbol.for(`effect/Micro`), Xh = Symbol.for(`effect/Micro/MicroExit`), Zh = Symbol.for(`effect/Micro/MicroCause`), Qh = { _E: n }; var $h = class extends globalThis.Error { _tag; traces; [Zh]; constructor(e, t, n) { let r = `MicroCause.${e}`, i, a, o; if (t instanceof globalThis.Error) { ((i = `(${r}) ${t.name}`), (a = t.message)); let e = a.split(` `).length; o = t.stack ? `(${r}) ${t.stack .split(` `) .slice(0, e + 3).join(` `)}` : `${i}: ${a}`; } else ((i = r), (a = Ge(t, 0)), (o = `${i}: ${a}`)); (n.length > 0 && (o += `\n ${n.join(` `)}`), super(a), (this._tag = e), (this.traces = n), (this[Zh] = Qh), (this.name = i), (this.stack = o)); } pipe() { return k(this, arguments); } toString() { return this.stack; } [E]() { return this.stack; } }, eg = class extends $h { error; constructor(e, t = []) { (super(`Fail`, e, t), (this.error = e)); } }; const tg = (e, t = []) => new eg(e, t); var ng = class extends $h { defect; constructor(e, t = []) { (super(`Die`, e, t), (this.defect = e)); } }; const rg = (e, t = []) => new ng(e, t); var ig = class extends $h { constructor(e = []) { super(`Interrupt`, `interrupted`, e); } }; const ag = (e = []) => new ig(e), og = (e) => e._tag === `Interrupt`, sg = Symbol.for(`effect/Micro/MicroFiber`), cg = { _A: n, _E: n }; var lg = class { context; interruptible; [sg]; _stack = []; _observers = []; _exit; _children; currentOpCount = 0; constructor(e, t = !0) { ((this.context = e), (this.interruptible = t), (this[sg] = cg)); } getRef(e) { return es(this.context, e); } addObserver(e) { return this._exit ? (e(this._exit), s) : (this._observers.push(e), () => { let t = this._observers.indexOf(e); t >= 0 && this._observers.splice(t, 1); }); } _interrupted = !1; unsafeInterrupt() { this._exit || ((this._interrupted = !0), this.interruptible && this.evaluate(Fg)); } unsafePoll() { return this._exit; } evaluate(e) { if (this._exit) return; if (this._yielded !== void 0) { let e = this._yielded; ((this._yielded = void 0), e()); } let t = this.runLoop(e); if (t === _g) return; let n = ug.interruptChildren && ug.interruptChildren(this); if (n !== void 0) return this.evaluate(Ag(n, () => t)); this._exit = t; for (let e = 0; e < this._observers.length; e++) this._observers[e](t); this._observers.length = 0; } runLoop(e) { let t = !1, n = e; this.currentOpCount = 0; try { for (;;) { if ((this.currentOpCount++, !t && this.getRef(Ug).shouldYield(this))) { t = !0; let e = n; n = Ag(Dg, () => e); } if (((n = n[pg](this)), n === _g)) { let e = this._yielded; return Xh in e ? ((this._yielded = void 0), e) : _g; } } } catch (e) { return v(n, pg) ? Ig(e) : Ig(`MicroFiber.runLoop: Not a valid effect: ${String(n)}`); } } getCont(e) { for (;;) { let t = this._stack.pop(); if (!t) return; let n = t[gg] && t[gg](this); if (n) return { [e]: n }; if (t[e]) return t; } } _yielded = void 0; yieldWith(e) { return ((this._yielded = e), _g); } children() { return (this._children ??= new Set()); } }; const ug = g(`effect/Micro/fiberMiddleware`, () => ({ interruptChildren: void 0 })), dg = Symbol.for(`effect/Micro/identifier`), fg = Symbol.for(`effect/Micro/args`), pg = Symbol.for(`effect/Micro/evaluate`), mg = Symbol.for(`effect/Micro/successCont`), hg = Symbol.for(`effect/Micro/failureCont`), gg = Symbol.for(`effect/Micro/ensureCont`), _g = Symbol.for(`effect/Micro/Yield`), vg = { _A: n, _E: n, _R: n }, yg = { ...Lm, _op: `Micro`, [Yh]: vg, pipe() { return k(this, arguments); }, [Symbol.iterator]() { return new ye(new we(this)); }, toJSON() { return { _id: `Micro`, op: this[dg], ...(fg in this ? { args: this[fg] } : void 0) }; }, toString() { return O(this); }, [E]() { return O(this); }, }; function bg(e) { return Ig(`Micro.evaluate: Not implemented`); } const xg = (e) => ({ ...yg, [dg]: e.op, [pg]: e.eval ?? bg, [mg]: e.contA, [hg]: e.contE, [gg]: e.ensure, }), Sg = (e) => { let t = xg(e); return function () { let n = Object.create(t); return ((n[fg] = e.single === !1 ? arguments : arguments[0]), n); }; }, Cg = (e) => { let t = { ...xg(e), [Xh]: Xh, _tag: e.op, get [e.prop]() { return this[fg]; }, toJSON() { return { _id: `MicroExit`, _tag: e.op, [e.prop]: this[fg] }; }, [w](t) { return Mg(t) && t._tag === e.op && T(this[fg], t[fg]); }, [y]() { return C(this, x(S(e.op))(b(this[fg]))); }, }; return function (e) { let n = Object.create(t); return ((n[fg] = e), (n[mg] = void 0), (n[hg] = void 0), (n[gg] = void 0), n); }; }, wg = Cg({ op: `Success`, prop: `value`, eval(e) { let t = e.getCont(mg); return t ? t[mg](this[fg], e) : e.yieldWith(this); }, }), Tg = Cg({ op: `Failure`, prop: `cause`, eval(e) { let t = e.getCont(hg); for (; og(this[fg]) && t && e.interruptible;) t = e.getCont(hg); return t ? t[hg](this[fg], e) : e.yieldWith(this); }, }), Eg = (e) => Tg(tg(e)), Dg = Sg({ op: `Yield`, eval(e) { let t = !1; return ( e.getRef(Ug).scheduleTask(() => { t || e.evaluate(Lg); }, this[fg] ?? 0), e.yieldWith(() => { t = !0; }) ); }, })(0), Og = wg(void 0), kg = Sg({ op: `WithMicroFiber`, eval(e) { return this[fg](e); }, }), Ag = t(2, (e, t) => { let n = Object.create(jg); return ((n[fg] = e), (n[mg] = t), n); }), jg = xg({ op: `OnSuccess`, eval(e) { return (e._stack.push(this), this[fg]); }, }), Mg = (e) => v(e, Xh), Ng = wg, Pg = Tg, Fg = Pg(ag()), Ig = (e) => Pg(rg(e)), Lg = Ng(void 0), Rg = `setImmediate` in globalThis ? globalThis.setImmediate : (e) => setTimeout(e, 0); var zg = class { tasks = []; running = !1; scheduleTask(e, t) { (this.tasks.push(e), this.running || ((this.running = !0), Rg(this.afterScheduled))); } afterScheduled = () => { ((this.running = !1), this.runTasks()); }; runTasks() { let e = this.tasks; this.tasks = []; for (let t = 0, n = e.length; t < n; t++) e[t](); } shouldYield(e) { return e.currentOpCount >= e.getRef(Hg); } flush() { for (; this.tasks.length > 0;) this.runTasks(); } }; const Bg = t(2, (e, t) => kg((n) => { let r = n.context; return ((n.context = t(r)), Kg(e, () => ((n.context = r), Og))); }), ), Vg = t(2, (e, t) => Bg(e, fs(t))); var Hg = class extends ms()(`effect/Micro/currentMaxOpsBeforeYield`, { defaultValue: () => 2048, }) {}; ms()(`effect/Micro/currentConcurrency`, { defaultValue: () => `unbounded` }); var Ug = class extends ms()(`effect/Micro/currentScheduler`, { defaultValue: () => new zg() }) {}; const Wg = t(2, (e, t) => { let n = Object.create(Gg); return ((n[fg] = e), (n[mg] = t.onSuccess), (n[hg] = t.onFailure), n); }), Gg = xg({ op: `OnSuccessAndFailure`, eval(e) { return (e._stack.push(this), this[fg]); }, }), Kg = t(2, (e, t) => Yg((n) => Wg(n(e), { onFailure: (e) => Ag(t(Pg(e)), () => Tg(e)), onSuccess: (e) => Ag(t(Ng(e)), () => wg(e)), }), ), ), qg = Sg({ op: `SetInterruptible`, ensure(e) { if (((e.interruptible = this[fg]), e._interrupted && e.interruptible)) return () => Fg; }, }), Jg = (e) => kg((t) => t.interruptible ? e : ((t.interruptible = !0), t._stack.push(qg(!1)), t._interrupted ? Fg : e), ), Yg = (e) => kg((t) => (t.interruptible ? ((t.interruptible = !1), t._stack.push(qg(!0)), e(Jg)) : e(n))), Xg = (e, t) => { let n = new lg(Ug.context(t?.scheduler ?? new zg())); if ((n.evaluate(e), t?.signal)) if (t.signal.aborted) n.unsafeInterrupt(); else { let e = () => n.unsafeInterrupt(); (t.signal.addEventListener(`abort`, e, { once: !0 }), n.addObserver(() => t.signal.removeEventListener(`abort`, e))); } return n; }, Zg = (function () { class e extends globalThis.Error {} return ( Object.assign(e.prototype, yg, xt, { [dg]: `Failure`, [pg]() { return Eg(this); }, toString() { return this.message ? `${this.name}: ${this.message}` : this.name; }, toJSON() { return { ...this }; }, [E]() { let e = this.stack; return e ? `${this.toString()}\n${e .split(` `) .slice(1).join(` `)}` : this.toString(); }, }), e ); })(), Qg = (function () { return class extends Zg { constructor(e) { (super(), e && Object.assign(this, e)); } }; })(), $g = (e) => { class t extends Qg { _tag = e; } return ((t.prototype.name = e), t); }; ($g(`NoSuchElementException`), $g(`TimeoutException`)); var e_ = class e { scheduleDrain; running = !1; tasks = new t_(); constructor(e) { this.scheduleDrain = e; } starveInternal = (e) => { let t = this.tasks.buckets; this.tasks.buckets = []; for (let [e, n] of t) for (let e = 0; e < n.length; e++) n[e](); this.tasks.buckets.length === 0 ? (this.running = !1) : this.starve(e); }; starve(e = 0) { this.scheduleDrain(e, this.starveInternal); } scheduleTask(e, t) { (this.tasks.scheduleTask(e, t), this.running || ((this.running = !0), this.starve())); } static cached(t) { let n = new e(t), r = new WeakMap(); return (i) => { if (i === void 0) return n; let a = r.get(i); return (a === void 0 && ((a = new e(t)), r.set(i, a)), a); }; } }, t_ = class { buckets = []; scheduleTask(e, t) { let n = this.buckets.length, r, i = 0; for (; i < n && this.buckets[i][0] <= t; i++) r = this.buckets[i]; r && r[0] === t ? r[1].push(e) : i === n ? this.buckets.push([t, [e]]) : this.buckets.splice(i, 0, [t, [e]]); } }, n_ = class { maxNextTickBeforeTimer; getRunner = e_.cached((e, t) => { e >= this.maxNextTickBeforeTimer ? setTimeout(() => t(0), 0) : Promise.resolve(void 0).then(() => t(e + 1)); }); constructor(e) { this.maxNextTickBeforeTimer = e; } shouldYield(e) { return e.currentOpCount > e.getFiberRef(wf) && e.getFiberRef(Cf); } scheduleTask(e, t, n) { this.getRunner(n).scheduleTask(e, t); } }; const r_ = g(Symbol.for(`effect/Scheduler/defaultScheduler`), () => new n_(2048)); var i_ = class { tasks = new t_(); deferred = !1; scheduleTask(e, t, n) { this.deferred ? r_.scheduleTask(e, t, n) : this.tasks.scheduleTask(e, t); } shouldYield(e) { return e.currentOpCount > e.getFiberRef(wf) && e.getFiberRef(Cf); } flush() { for (; this.tasks.buckets.length > 0;) { let e = this.tasks.buckets; this.tasks.buckets = []; for (let [t, n] of e) for (let e = 0; e < n.length; e++) n[e](); } this.deferred = !0; } }; const a_ = g(Symbol.for(`effect/FiberRef/currentScheduler`), () => gf(r_)), o_ = g(Symbol.for(`effect/FiberRef/currentRequestMap`), () => gf(new Map())), s_ = (e, t, n, r) => { switch (e) { case void 0: return t(); case `unbounded`: return n(); case `inherit`: return ff(kf, (e) => (e === `unbounded` ? n() : e > 1 ? r(e) : t())); default: return e > 1 ? r(e) : t(); } }, c_ = (e) => e.replace(/[\s="]/g, `_`), l_ = (e) => (t) => `${c_(t.label)}=${e - t.startTime}ms`, u_ = `effect/MetricLabel`, d_ = Symbol.for(u_); var f_ = class { key; value; [d_] = d_; _hash; constructor(e, t) { ((this.key = e), (this.value = t), (this._hash = S(u_ + this.key + this.value))); } [y]() { return this._hash; } [w](e) { return m_(e) && this.key === e.key && this.value === e.value; } pipe() { return k(this, arguments); } }; const p_ = (e, t) => new f_(e, t), m_ = (e) => v(e, d_), h_ = vn((e) => (ls(e.context, Mm) ? (e._tag === `Span` ? h_(e.parent) : M()) : N(e))), g_ = ep, __ = `InterruptSignal`, v_ = `Stateful`, y_ = `Resume`, b_ = `YieldNow`, x_ = (e) => ({ _tag: __, cause: e }), S_ = (e) => ({ _tag: v_, onFiber: e }), C_ = (e) => ({ _tag: y_, effect: e }), w_ = () => ({ _tag: b_ }), T_ = Symbol.for(`effect/FiberScope`); var E_ = class { [T_] = T_; fiberId = xc; roots = new Set(); add(e, t) { (this.roots.add(t), t.addObserver(() => { this.roots.delete(t); })); } }, D_ = class { fiberId; parent; [T_] = T_; constructor(e, t) { ((this.fiberId = e), (this.parent = t)); } add(e, t) { this.parent.tell( S_((e) => { (e.addChild(t), t.addObserver(() => { e.removeChild(t); })); }), ); } }; const O_ = (e) => new D_(e.id(), e), k_ = g(Symbol.for(`effect/FiberScope/Global`), () => new E_()), A_ = Symbol.for(`effect/Fiber`), j_ = { _E: (e) => e, _A: (e) => e }, M_ = { [A_]: j_, pipe() { return k(this, arguments); }, }, N_ = Symbol.for(`effect/Fiber`), P_ = (e) => Xd(kd(e.await), e.inheritAll); (({ ...St }), { ...M_ }); const F_ = `effect/FiberCurrent`, I_ = Symbol.for(`effect/Logger`), L_ = { _Message: (e) => e, _Output: (e) => e }, R_ = (e) => ({ [I_]: L_, log: e, pipe() { return k(this, arguments); }, }), z_ = /^[^\s"=]*$/, B_ = R_( ( (e, t) => ({ annotations: n, cause: r, date: i, fiberId: a, logLevel: o, message: s, spans: c }) => { let l = (t) => (t.match(z_) ? t : e(t)), u = (e, t) => `${c_(e)}=${l(t)}`, d = (e, t) => ` ` + u(e, t), f = u(`timestamp`, i.toISOString()); ((f += d(`level`, o.label)), (f += d(`fiber`, yc(a)))); let p = On(s); for (let e = 0; e < p.length; e++) f += d(`message`, Ge(p[e], t)); eo(r) || (f += d(`cause`, To(r, { renderErrorCause: !0 }))); for (let e of c) f += ` ` + l_(i.getTime())(e); for (let [e, r] of n) f += d(e, Ge(r, t)); return f; } )((e) => `"${e.replace(/\\([\s\S])|(")/g, `\\$1$2`)}"`), ), V_ = { bold: `1`, red: `31`, green: `32`, yellow: `33`, blue: `34`, cyan: `36`, white: `37`, gray: `90`, black: `30`, bgBrightRed: `101`, }; (V_.gray, V_.blue, V_.green, V_.yellow, V_.red, V_.bgBrightRed, V_.black); const H_ = typeof process == `object` && process !== null && typeof process.stdout == `object` && process.stdout !== null; (H_ && process.stdout.isTTY, H_ || `Deno` in globalThis); const U_ = `effect/MetricBoundaries`, W_ = Symbol.for(U_); var G_ = class { values; [W_] = W_; constructor(e) { ((this.values = e), (this._hash = c(S(U_), x(Ie(this.values))))); } _hash; [y]() { return this._hash; } [w](e) { return K_(e) && T(this.values, e.values); } pipe() { return k(this, arguments); } }; const K_ = (e) => v(e, W_), q_ = (e) => new G_(c(e, Mn(Zr(1 / 0)), mr)), J_ = (e) => c( Dn(e.count - 1, (t) => e.start * e.factor ** +t), ni, q_, ), Y_ = Symbol.for(`effect/MetricKeyType`), X_ = `effect/MetricKeyType/Counter`, Z_ = Symbol.for(X_), Q_ = Symbol.for(`effect/MetricKeyType/Frequency`), $_ = Symbol.for(`effect/MetricKeyType/Gauge`), ev = `effect/MetricKeyType/Histogram`, tv = Symbol.for(ev), nv = Symbol.for(`effect/MetricKeyType/Summary`), rv = { _In: (e) => e, _Out: (e) => e }; var iv = class { incremental; bigint; [Y_] = rv; [Z_] = Z_; constructor(e, t) { ((this.incremental = e), (this.bigint = t), (this._hash = S(X_))); } _hash; [y]() { return this._hash; } [w](e) { return cv(e); } pipe() { return k(this, arguments); } }, av = class { boundaries; [Y_] = rv; [tv] = tv; constructor(e) { ((this.boundaries = e), (this._hash = c(S(ev), x(b(this.boundaries))))); } _hash; [y]() { return this._hash; } [w](e) { return dv(e) && T(this.boundaries, e.boundaries); } pipe() { return k(this, arguments); } }; const ov = (e) => new iv(e?.incremental ?? !1, e?.bigint ?? !1), sv = (e) => new av(e), cv = (e) => v(e, Z_), lv = (e) => v(e, Q_), uv = (e) => v(e, $_), dv = (e) => v(e, tv), fv = (e) => v(e, nv), pv = Symbol.for(`effect/MetricKey`), mv = { _Type: (e) => e }, hv = fr(T); var gv = class { name; keyType; description; tags; [pv] = mv; constructor(e, t, n, r = []) { ((this.name = e), (this.keyType = t), (this.description = n), (this.tags = r), (this._hash = c(S(this.name + this.description), x(b(this.keyType)), x(Ie(this.tags))))); } _hash; [y]() { return this._hash; } [w](e) { return ( _v(e) && this.name === e.name && T(this.keyType, e.keyType) && T(this.description, e.description) && hv(this.tags, e.tags) ); } pipe() { return k(this, arguments); } }; const _v = (e) => v(e, pv), vv = (e, t) => new gv(e, ov(t), pn(t?.description)), yv = (e, t, n) => new gv(e, sv(t), pn(n)), bv = t(2, (e, t) => t.length === 0 ? e : new gv(e.name, e.keyType, e.description, rr(e.tags, t)), ), xv = Symbol.for(`effect/MutableHashMap`), Sv = { [xv]: xv, [Symbol.iterator]() { return new Cv(this); }, toString() { return O(this.toJSON()); }, toJSON() { return { _id: `MutableHashMap`, values: Array.from(this).map(D) }; }, [E]() { return this.toJSON(); }, pipe() { return k(this, arguments); }, }; var Cv = class e { self; referentialIterator; bucketIterator; constructor(e) { ((this.self = e), (this.referentialIterator = e.referential[Symbol.iterator]())); } next() { if (this.bucketIterator !== void 0) return this.bucketIterator.next(); let e = this.referentialIterator.next(); return e.done ? ((this.bucketIterator = new wv(this.self.buckets.values())), this.next()) : e; } [Symbol.iterator]() { return new e(this.self); } }, wv = class { backing; constructor(e) { this.backing = e; } currentBucket; next() { if (this.currentBucket === void 0) { let e = this.backing.next(); if (e.done) return e; this.currentBucket = e.value[Symbol.iterator](); } let e = this.currentBucket.next(); return e.done ? ((this.currentBucket = void 0), this.next()) : e; } }; const Tv = () => { let e = Object.create(Sv); return ((e.referential = new Map()), (e.buckets = new Map()), (e.bucketsSize = 0), e); }, Ev = t(2, (e, t) => { if (Re(t) === !1) return e.referential.has(t) ? N(e.referential.get(t)) : M(); let n = t[y](), r = e.buckets.get(n); return r === void 0 ? M() : Dv(e, r, t); }), Dv = (e, t, n, r = !1) => { for (let i = 0, a = t.length; i < a; i++) if (n[w](t[i][0])) { let n = t[i][1]; return (r && (t.splice(i, 1), e.bucketsSize--), N(n)); } return M(); }, Ov = t(2, (e, t) => F(Ev(e, t))), kv = t(3, (e, t, n) => { if (Re(t) === !1) return (e.referential.set(t, n), e); let r = t[y](), i = e.buckets.get(r); return i === void 0 ? (e.buckets.set(r, [[t, n]]), e.bucketsSize++, e) : (Av(e, i, t), i.push([t, n]), e.bucketsSize++, e); }), Av = (e, t, n) => { for (let r = 0, i = t.length; r < i; r++) if (n[w](t[r][0])) { (t.splice(r, 1), e.bucketsSize--); return; } }, jv = Symbol.for(`effect/MetricState`), Mv = `effect/MetricState/Counter`, Nv = Symbol.for(Mv), Pv = `effect/MetricState/Frequency`, Fv = Symbol.for(Pv), Iv = `effect/MetricState/Gauge`, Lv = Symbol.for(Iv), Rv = `effect/MetricState/Histogram`, zv = Symbol.for(Rv), Bv = `effect/MetricState/Summary`, Vv = Symbol.for(Bv), Hv = { _A: (e) => e }; var Uv = class { count; [jv] = Hv; [Nv] = Nv; constructor(e) { this.count = e; } [y]() { return c(b(Mv), x(b(this.count)), C(this)); } [w](e) { return ey(e) && this.count === e.count; } pipe() { return k(this, arguments); } }; const Wv = fr(T); var Gv = class { occurrences; [jv] = Hv; [Fv] = Fv; constructor(e) { this.occurrences = e; } _hash; [y]() { return c(S(Pv), x(Ie(L(this.occurrences.entries()))), C(this)); } [w](e) { return ty(e) && Wv(L(this.occurrences.entries()), L(e.occurrences.entries())); } pipe() { return k(this, arguments); } }, Kv = class { value; [jv] = Hv; [Lv] = Lv; constructor(e) { this.value = e; } [y]() { return c(b(Iv), x(b(this.value)), C(this)); } [w](e) { return ny(e) && this.value === e.value; } pipe() { return k(this, arguments); } }, qv = class { buckets; count; min; max; sum; [jv] = Hv; [zv] = zv; constructor(e, t, n, r, i) { ((this.buckets = e), (this.count = t), (this.min = n), (this.max = r), (this.sum = i)); } [y]() { return c( b(Rv), x(b(this.buckets)), x(b(this.count)), x(b(this.min)), x(b(this.max)), x(b(this.sum)), C(this), ); } [w](e) { return ( ry(e) && T(this.buckets, e.buckets) && this.count === e.count && this.min === e.min && this.max === e.max && this.sum === e.sum ); } pipe() { return k(this, arguments); } }, Jv = class { error; quantiles; count; min; max; sum; [jv] = Hv; [Vv] = Vv; constructor(e, t, n, r, i, a) { ((this.error = e), (this.quantiles = t), (this.count = n), (this.min = r), (this.max = i), (this.sum = a)); } [y]() { return c( b(Bv), x(b(this.error)), x(b(this.quantiles)), x(b(this.count)), x(b(this.min)), x(b(this.max)), x(b(this.sum)), C(this), ); } [w](e) { return ( iy(e) && this.error === e.error && T(this.quantiles, e.quantiles) && this.count === e.count && this.min === e.min && this.max === e.max && this.sum === e.sum ); } pipe() { return k(this, arguments); } }; const Yv = (e) => new Uv(e), Xv = (e) => new Gv(e), Zv = (e) => new Kv(e), Qv = (e) => new qv(e.buckets, e.count, e.min, e.max, e.sum), $v = (e) => new Jv(e.error, e.quantiles, e.count, e.min, e.max, e.sum), ey = (e) => v(e, Nv), ty = (e) => v(e, Fv), ny = (e) => v(e, Lv), ry = (e) => v(e, zv), iy = (e) => v(e, Vv), ay = Symbol.for(`effect/MetricHook`), oy = { _In: (e) => e, _Out: (e) => e }, sy = (e) => ({ [ay]: oy, pipe() { return k(this, arguments); }, ...e, }), cy = BigInt(0), ly = (e) => { let t = e.keyType.bigint ? cy : 0, n = e.keyType.incremental ? (e.keyType.bigint ? (e) => e >= cy : (e) => e >= 0) : (e) => !0, r = (e) => { n(e) && (t += e); }; return sy({ get: () => Yv(t), update: r, modify: r }); }, uy = (e) => { let t = new Map(); for (let n of e.keyType.preregisteredWords) t.set(n, 0); let n = (e) => { let n = t.get(e) ?? 0; t.set(e, n + 1); }; return sy({ get: () => Xv(t), update: n, modify: n }); }, dy = (e, t) => { let n = t; return sy({ get: () => Zv(n), update: (e) => { n = e; }, modify: (e) => { n += e; }, }); }, fy = (e) => { let t = e.keyType.boundaries.values, n = t.length, r = new Uint32Array(n + 1), i = new Float64Array(n), a = 0, o = 0, s = Number.MAX_VALUE, l = Number.MIN_VALUE; c( t, Yn(Kp), or((e, t) => { i[t] = e; }), ); let u = (e) => { let t = 0, c = n; for (; t !== c;) { let n = Math.floor(t + (c - t) / 2); (e <= i[n] ? (c = n) : (t = n), c === t + 1 && (e <= i[t] ? (c = t) : (t = c))); } ((r[t] = r[t] + 1), (a += 1), (o += e), e < s && (s = e), e > l && (l = e)); }, d = () => { let e = En(n), t = 0; for (let a = 0; a < n; a++) { let n = i[a], o = r[a]; ((t += o), (e[a] = [n, t])); } return e; }; return sy({ get: () => Qv({ buckets: d(), count: a, min: s, max: l, sum: o }), update: u, modify: u, }); }, py = (e) => { let { error: t, maxAge: n, maxSize: r, quantiles: i } = e.keyType, a = c(i, Yn(Kp)), o = En(r), s = 0, l = 0, u = 0, d = 0, f = 0, p = (e) => { let i = [], s = 0; for (; s !== r - 1;) { let t = o[s]; if (t != null) { let [r, a] = t, o = Fs(e - r); Ys(o, js) && Js(o, n) && i.push(a); } s += 1; } return my(t, a, Yn(i, Kp)); }, m = (e, t) => { if (r > 0) { s += 1; let n = s % r; o[n] = [t, e]; } ((d = l === 0 ? e : Math.min(d, e)), (f = l === 0 ? e : Math.max(f, e)), (l += 1), (u += e)); }; return sy({ get: () => $v({ error: t, quantiles: p(Date.now()), count: l, min: d, max: f, sum: u }), update: ([e, t]) => m(e, t), modify: ([e, t]) => m(e, t), }); }, my = (e, t, n) => { let r = n.length; if (!R(t)) return ir(); let i = t[0], a = t.slice(1), o = hy(e, r, M(), 0, i, n), s = ar(o); return ( a.forEach((t) => { s.push(hy(e, r, o.value, o.consumed, t, o.rest)); }), or(s, (e) => [e.quantile, e.value]) ); }, hy = (e, t, n, r, i, a) => { let o = e, s = t, c = n, l = r, u = i, d = a, f = e, p = t, m = n, h = r, g = i, ee = a; for (;;) { if (!R(d)) return { quantile: u, value: M(), consumed: l, rest: [] }; if (u === 1) return { quantile: u, value: N(Un(d)), consumed: l + d.length, rest: [] }; let e = Vn(d), t = Kn(d, (t) => t === e), n = u * s, r = (o / 2) * n, i = l + t[0].length, a = Math.abs(i - n); if (i < n - r) { ((f = o), (p = s), (m = Bn(d)), (h = i), (g = u), (ee = t[1]), (o = f), (s = p), (c = m), (l = h), (u = g), (d = ee)); continue; } if (i > n + r) { let t = P(c) ? N(e) : c; return { quantile: u, value: t, consumed: l, rest: d }; } switch (c._tag) { case `None`: ((f = o), (p = s), (m = Bn(d)), (h = i), (g = u), (ee = t[1]), (o = f), (s = p), (c = m), (l = h), (u = g), (d = ee)); continue; case `Some`: if (a < Math.abs(n - c.value)) { ((f = o), (p = s), (m = Bn(d)), (h = i), (g = u), (ee = t[1]), (o = f), (s = p), (c = m), (l = h), (u = g), (d = ee)); continue; } return { quantile: u, value: N(c.value), consumed: l, rest: d }; } } throw Error( `BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues`, ); }, gy = Symbol.for(`effect/MetricPair`), _y = { _Type: (e) => e }, vy = (e, t) => ({ [gy]: _y, metricKey: e, metricState: t, pipe() { return k(this, arguments); }, }), yy = Symbol.for(`effect/MetricRegistry`); var by = class { [yy] = yy; map = Tv(); snapshot() { let e = []; for (let [t, n] of this.map) e.push(vy(t, n.get())); return e; } get(e) { let t = c(this.map, Ev(e), mn); if (t == null) { if (cv(e.keyType)) return this.getCounter(e); if (uv(e.keyType)) return this.getGauge(e); if (lv(e.keyType)) return this.getFrequency(e); if (dv(e.keyType)) return this.getHistogram(e); if (fv(e.keyType)) return this.getSummary(e); throw Error( `BUG: MetricRegistry.get - unknown MetricKeyType - please report an issue at https://github.com/Effect-TS/effect/issues`, ); } else return t; } getCounter(e) { let t = c(this.map, Ev(e), mn); if (t == null) { let n = ly(e); (c(this.map, Ov(e)) || c(this.map, kv(e, n)), (t = n)); } return t; } getFrequency(e) { let t = c(this.map, Ev(e), mn); if (t == null) { let n = uy(e); (c(this.map, Ov(e)) || c(this.map, kv(e, n)), (t = n)); } return t; } getGauge(e) { let t = c(this.map, Ev(e), mn); if (t == null) { let n = dy(e, e.keyType.bigint ? BigInt(0) : 0); (c(this.map, Ov(e)) || c(this.map, kv(e, n)), (t = n)); } return t; } getHistogram(e) { let t = c(this.map, Ev(e), mn); if (t == null) { let n = fy(e); (c(this.map, Ov(e)) || c(this.map, kv(e, n)), (t = n)); } return t; } getSummary(e) { let t = c(this.map, Ev(e), mn); if (t == null) { let n = py(e); (c(this.map, Ov(e)) || c(this.map, kv(e, n)), (t = n)); } return t; } }; const xy = () => new by(), Sy = Symbol.for(`effect/Metric`), Cy = { _Type: (e) => e, _In: (e) => e, _Out: (e) => e }, wy = g(Symbol.for(`effect/Metric/globalMetricRegistry`), () => xy()), Ty = function (e, t, n, r) { let i = Object.assign((e) => Vd(e, (e) => jy(i, e)), { [Sy]: Cy, keyType: e, unsafeUpdate: t, unsafeValue: n, unsafeModify: r, register() { return (this.unsafeValue([]), this); }, pipe() { return k(this, arguments); }, }); return i; }, Ey = (e, t) => Dy(vv(e, t)), Dy = (e) => { let t, n = new WeakMap(), r = (r) => { if (r.length === 0) return (t === void 0 && (t = wy.get(e)), t); let i = n.get(r); return i === void 0 ? ((i = wy.get(bv(e, r))), n.set(r, i), i) : i; }; return Ty( e.keyType, (e, t) => r(t).update(e), (e) => r(e).get(), (e, t) => r(t).modify(e), ); }, Oy = (e, t, n) => Dy(yv(e, t, n)), ky = t(3, (e, t, n) => Ay(e, [p_(t, n)])), Ay = t(2, (e, t) => Ty( e.keyType, (n, r) => e.unsafeUpdate(n, rr(t, r)), (n) => e.unsafeValue(rr(t, n)), (n, r) => e.unsafeModify(n, rr(t, r)), ), ), jy = t(2, (e, t) => ff(Nf, (n) => U(() => e.unsafeUpdate(t, n)))); ({ ...xt }); const My = t(2, (e, t) => ff(o_, (n) => U(() => { if (n.has(e)) { let r = n.get(e); r.state.completed || ((r.state.completed = !0), mp(r.result, t)); } }), ), ), Ny = Symbol.for(`effect/Supervisor`), Py = { _T: (e) => e }; var Fy = class e { underlying; value0; [Ny] = Py; constructor(e, t) { ((this.underlying = e), (this.value0 = t)); } get value() { return this.value0; } onStart(e, t, n, r) { this.underlying.onStart(e, t, n, r); } onEnd(e, t) { this.underlying.onEnd(e, t); } onEffect(e, t) { this.underlying.onEffect(e, t); } onSuspend(e) { this.underlying.onSuspend(e); } onResume(e) { this.underlying.onResume(e); } map(t) { return new e(this, c(this.value, Id(t))); } zip(e) { return new Iy(this, e); } }, Iy = class e { left; right; _tag = `Zip`; [Ny] = Py; constructor(e, t) { ((this.left = e), (this.right = t)); } get value() { return Yd(this.left.value, this.right.value); } onStart(e, t, n, r) { (this.left.onStart(e, t, n, r), this.right.onStart(e, t, n, r)); } onEnd(e, t) { (this.left.onEnd(e, t), this.right.onEnd(e, t)); } onEffect(e, t) { (this.left.onEffect(e, t), this.right.onEffect(e, t)); } onSuspend(e) { (this.left.onSuspend(e), this.right.onSuspend(e)); } onResume(e) { (this.left.onResume(e), this.right.onResume(e)); } map(e) { return new Fy(this, c(this.value, Id(e))); } zip(t) { return new e(this, t); } }; const Ly = (e) => v(e, Ny) && ue(e, `Zip`); var Ry = class { effect; [Ny] = Py; constructor(e) { this.effect = e; } get value() { return this.effect; } onStart(e, t, n, r) {} onEnd(e, t) {} onEffect(e, t) {} onSuspend(e) {} onResume(e) {} map(e) { return new Fy(this, c(this.value, Id(e))); } zip(e) { return new Iy(this, e); } onRun(e, t) { return e(); } }; const zy = (e) => new Ry(e), By = g(`effect/Supervisor/none`, () => zy(Gd)), Vy = Yl, Hy = `Empty`, Uy = `AddSupervisor`, Wy = `RemoveSupervisor`, Gy = `AndThen`, Ky = { _tag: Hy }, qy = (e, t) => ({ _tag: Gy, first: e, second: t }), Jy = (e, t) => Yy(t, Zr(e)), Yy = (e, t) => { let n = e, r = t; for (; ui(r);) { let e = fi(r); switch (e._tag) { case Hy: r = pi(r); break; case Uy: ((n = n.zip(e.supervisor)), (r = pi(r))); break; case Wy: ((n = Xy(n, e.supervisor)), (r = pi(r))); break; case Gy: r = oi(e.first)(oi(e.second)(pi(r))); break; } } return n; }, Xy = (e, t) => (T(e, t) ? By : Ly(e) ? Xy(e.left, t).zip(Xy(e.right, t)) : e), Zy = (e) => (T(e, By) ? Oa() : Ly(e) ? c(Zy(e.left), Ia(Zy(e.right))) : Aa(e)), Qy = Vy({ empty: Ky, patch: Jy, combine: qy, diff: (e, t) => { if (T(e, t)) return Ky; let n = Zy(e), r = Zy(t), i = c( r, Fa(n), La(Ky, (e, t) => qy(e, { _tag: Uy, supervisor: t })), ), a = c( n, Fa(r), La(Ky, (e, t) => qy(e, { _tag: Wy, supervisor: t })), ); return qy(i, a); }, }), $y = Ey(`effect_fiber_started`, { incremental: !0 }), eb = Ey(`effect_fiber_active`), tb = Ey(`effect_fiber_successes`, { incremental: !0 }), nb = Ey(`effect_fiber_failures`, { incremental: !0 }), rb = ky( Oy(`effect_fiber_lifetimes`, J_({ start: 0.5, factor: 2, count: 35 })), `time_unit`, `milliseconds`, ), ib = `Continue`, ab = `Yield`, ob = { _E: (e) => e, _A: (e) => e }, sb = (e) => { throw Error( `BUG: FiberRuntime - ${Ge(e)} - please report an issue at https://github.com/Effect-TS/effect/issues`, ); }, cb = Symbol.for(`effect/internal/fiberRuntime/YieldedOp`), lb = g(`effect/internal/fiberRuntime/yieldedOpChannel`, () => ({ currentOp: null })), ub = { [nt]: (e, t, n) => Oe(() => t.effect_instruction_i1(n)), OnStep: (e, t, n) => G(G(n)), [rt]: (e, t, n) => Oe(() => t.effect_instruction_i2(n)), [dt]: (e, t, n) => ( e.patchRuntimeFlags(e.currentRuntimeFlags, t.patch), fu(e.currentRuntimeFlags) && e.isInterrupted() ? W(e.getInterruptedCause()) : G(n) ), [st]: (e, t, n) => ( Oe(() => t.effect_instruction_i2(n)), Oe(() => t.effect_instruction_i0()) ? (e.pushStack(t), Oe(() => t.effect_instruction_i1())) : Gd ), [ct]: (e, t, n) => { for (;;) { let r = Oe(() => t.effect_instruction_i0.next(n)); if (r.done) return G(r.value); let i = Te(r.value); if (!$f(i)) return (e.pushStack(t), i); if (i._tag === `Failure`) return i; n = i.value; } }, }, db = { [__]: (e, t, n, r) => (e.processNewInterruptSignal(r.cause), fu(t) ? W(r.cause) : n), [y_]: (e, t, n, r) => { throw Error(`It is illegal to have multiple concurrent run loops in a single fiber`); }, [v_]: (e, t, n, r) => (r.onFiber(e, Ih(t)), n), [b_]: (e, t, n, r) => B(Jd(), () => n), }, fb = (e) => Pd(Du(e), (e) => Sb( Gu(e), ([e, t]) => { let n = new Map(), r = []; for (let e of t) { r.push(ei(e)); for (let t of e) n.set(t.request, t); } let i = r.flat(); return hf( Hb(e.runAll(r), i, () => i.forEach((e) => { e.listeners.interrupted = !0; }), ), o_, n, ); }, !1, !1, ), ), pb = ft(); var mb = class extends zm { [A_] = j_; [N_] = ob; _fiberRefs; _fiberId; _queue = []; _children = null; _observers = []; _running = !1; _stack = []; _asyncInterruptor = null; _asyncBlockingOn = null; _exitValue = null; _steps = []; _isYielding = !1; currentRuntimeFlags; currentOpCount = 0; currentSupervisor; currentScheduler; currentTracer; currentSpan; currentContext; currentDefaultServices; constructor(e, t, n) { if ( (super(), (this.currentRuntimeFlags = n), (this._fiberId = e), (this._fiberRefs = t), _u(n)) ) { let e = this.getFiberRef(Nf); ($y.unsafeUpdate(1, e), eb.unsafeUpdate(1, e)); } this.refreshRefCache(); } commit() { return P_(this); } id() { return this._fiberId; } resume(e) { this.tell(C_(e)); } get status() { return this.ask((e, t) => t); } get runtimeFlags() { return this.ask((e, t) => (Rh(t) ? e.currentRuntimeFlags : t.runtimeFlags)); } scope() { return O_(this); } get children() { return this.ask((e) => Array.from(e.getChildren())); } getChildren() { return (this._children === null && (this._children = new Set()), this._children); } getInterruptedCause() { return this.getFiberRef(Ff); } fiberRefs() { return this.ask((e) => e.getFiberRefs()); } ask(e) { return H(() => { let t = fp(this._fiberId); return ( this.tell( S_((n, r) => { mp( t, U(() => e(n, r)), ); }), ), pp(t) ); }); } tell(e) { (this._queue.push(e), this._running || ((this._running = !0), this.drainQueueLaterOnExecutor())); } get await() { return md((e) => { let t = (t) => e(V(t)); if (this._exitValue !== null) { t(this._exitValue); return; } return ( this.tell( S_((e, n) => { e._exitValue === null ? e.addObserver(t) : t(this._exitValue); }), ), U(() => this.tell( S_((e, n) => { e.removeObserver(t); }), ), ) ); }, this.id()); } get inheritAll() { return sd((e, t) => { let n = e.id(), r = e.getFiberRefs(), i = t.runtimeFlags, a = this.getFiberRefs(), o = th(r, n, a); e.setFiberRefs(o); let s = e.getFiberRef(zb), l = c(yu(i, s), wu(1), wu(16)); return Kd(l); }); } get poll() { return U(() => pn(this._exitValue)); } unsafePoll() { return this._exitValue; } interruptAsFork(e) { return U(() => this.tell(x_(Xa(e)))); } unsafeInterruptAsFork(e) { this.tell(x_(Xa(e))); } addObserver(e) { this._exitValue === null ? this._observers.push(e) : e(this._exitValue); } removeObserver(e) { this._observers = this._observers.filter((t) => t !== e); } getFiberRefs() { return (this.setFiberRef(zb, this.currentRuntimeFlags), this._fiberRefs); } unsafeDeleteFiberRef(e) { this._fiberRefs = ih(this._fiberRefs, e); } getFiberRef(e) { return this._fiberRefs.locals.has(e) ? this._fiberRefs.locals.get(e)[0][1] : e.initial; } setFiberRef(e, t) { ((this._fiberRefs = sh(this._fiberRefs, { fiberId: this._fiberId, fiberRef: e, value: t })), this.refreshRefCache()); } refreshRefCache() { ((this.currentDefaultServices = this.getFiberRef(Pm)), (this.currentTracer = this.currentDefaultServices.unsafeMap.get(Dm.key)), (this.currentSupervisor = this.getFiberRef(Bb)), (this.currentScheduler = this.getFiberRef(a_)), (this.currentContext = this.getFiberRef(Sf)), (this.currentSpan = this.currentContext.unsafeMap.get(Om.key))); } setFiberRefs(e) { ((this._fiberRefs = e), this.refreshRefCache()); } addChild(e) { this.getChildren().add(e); } removeChild(e) { this.getChildren().delete(e); } transferChildren(e) { let t = this._children; if (((this._children = null), t !== null && t.size > 0)) for (let n of t) n._exitValue === null && e.add(this.currentRuntimeFlags, n); } drainQueueOnCurrentThread() { let e = !0; for (; e;) { let t = ib, n = globalThis[F_]; globalThis[F_] = this; try { for (; t === ib;) t = this._queue.length === 0 ? `Done` : this.evaluateMessageWhileSuspended(this._queue.splice(0, 1)[0]); } finally { ((this._running = !1), (globalThis[F_] = n)); } this._queue.length > 0 && !this._running ? ((this._running = !0), t === ab ? (this.drainQueueLaterOnExecutor(), (e = !1)) : (e = !0)) : (e = !1); } } drainQueueLaterOnExecutor() { this.currentScheduler.scheduleTask(this.run, this.getFiberRef(Cf), this); } drainQueueWhileRunning(e, t) { let n = t; for (; this._queue.length > 0;) { let t = this._queue.splice(0, 1)[0]; n = db[t._tag](this, e, n, t); } return n; } isInterrupted() { return !no(this.getFiberRef(Ff)); } addInterruptedCause(e) { let t = this.getFiberRef(Ff); this.setFiberRef(Ff, Qa(t, e)); } processNewInterruptSignal(e) { (this.addInterruptedCause(e), this.sendInterruptSignalToAllChildren()); } sendInterruptSignalToAllChildren() { if (this._children === null || this._children.size === 0) return !1; let e = !1; for (let t of this._children) (t.tell(x_(Xa(this.id()))), (e = !0)); return e; } interruptAllChildren() { if (this.sendInterruptSignalToAllChildren()) { let e = this._children.values(); this._children = null; let t = !1; return qd({ while: () => !t, body: () => { let n = e.next(); return n.done ? U(() => { t = !0; }) : ud(n.value.await); }, step: () => {}, }); } return null; } reportExitValue(e) { if (_u(this.currentRuntimeFlags)) { let t = this.getFiberRef(Nf), n = this.id().startTimeMillis, r = Date.now(); switch ((rb.unsafeUpdate(r - n, t), eb.unsafeUpdate(-1, t), e._tag)) { case it: tb.unsafeUpdate(1, t); break; case et: nb.unsafeUpdate(1, t); break; } } if (e._tag === `Failure`) { let t = this.getFiberRef(jf); !io(e.cause) && t._tag === `Some` && this.log(`Fiber terminated with an unhandled error`, e.cause, t); } } setExitValue(e) { ((this._exitValue = e), this.reportExitValue(e)); for (let t = this._observers.length - 1; t >= 0; t--) this._observers[t](e); this._observers = []; } getLoggers() { return this.getFiberRef(yb); } log(e, t, n) { let r = F(n) ? n.value : this.getFiberRef(Ef), i = this.getFiberRef(hb); if (qh(i, r)) return; let a = this.getFiberRef(Df), o = this.getFiberRef(Tf), s = this.getLoggers(), c = this.getFiberRefs(); if (Ma(s) > 0) { let n = ls(this.getFiberRef(Pm), zp), i = new Date(n.unsafeCurrentTimeMillis()); Xe(c, () => { for (let n of s) n.log({ fiberId: this.id(), logLevel: r, message: e, cause: t, context: c, spans: a, annotations: o, date: i, }); }); } } evaluateMessageWhileSuspended(e) { switch (e._tag) { case b_: return ab; case __: return ( this.processNewInterruptSignal(e.cause), this._asyncInterruptor !== null && (this._asyncInterruptor(W(e.cause)), (this._asyncInterruptor = null)), ib ); case y_: return ( (this._asyncInterruptor = null), (this._asyncBlockingOn = null), this.evaluateEffect(e.effect), ib ); case v_: return ( e.onFiber( this, this._exitValue === null ? Lh(this.currentRuntimeFlags, this._asyncBlockingOn) : Fh, ), ib ); default: return sb(e); } } evaluateEffect(e) { this.currentSupervisor.onResume(this); try { let t = fu(this.currentRuntimeFlags) && this.isInterrupted() ? W(this.getInterruptedCause()) : e; for (; t !== null;) { let e = t, n = this.runLoop(e); if (n === cb) { let e = lb.currentOp; ((lb.currentOp = null), e._op === `Yield` ? uu(this.currentRuntimeFlags) ? (this.tell(w_()), this.tell(C_(lp)), (t = null)) : (t = lp) : e._op === `Async` && (t = null)); } else { this.currentRuntimeFlags = c(this.currentRuntimeFlags, du(16)); let e = this.interruptAllChildren(); e === null ? (this._queue.length === 0 ? this.setExitValue(n) : this.tell(C_(n)), (t = null)) : (t = B(e, () => n)); } } } finally { this.currentSupervisor.onSuspend(this); } } start(e) { if (this._running) this.tell(C_(e)); else { this._running = !0; let t = globalThis[F_]; globalThis[F_] = this; try { this.evaluateEffect(e); } finally { ((this._running = !1), (globalThis[F_] = t), this._queue.length > 0 && this.drainQueueLaterOnExecutor()); } } } startFork(e) { this.tell(C_(e)); } patchRuntimeFlags(e, t) { let n = bu(e, t); return ((globalThis[F_] = this), (this.currentRuntimeFlags = n), n); } initiateAsync(e, t) { let n = !1, r = (e) => { n || ((n = !0), this.tell(C_(e))); }; fu(e) && (this._asyncInterruptor = r); try { t(r); } catch (e) { r(wd(Ya(e))); } } pushStack(e) { (this._stack.push(e), e._op === `OnStep` && this._steps.push({ refs: this.getFiberRefs(), flags: this.currentRuntimeFlags })); } popStack() { let e = this._stack.pop(); if (e) return (e._op === `OnStep` && this._steps.pop(), e); } getNextSuccessCont() { let e = this.popStack(); for (; e;) { if (e._op !== `OnFailure`) return e; e = this.popStack(); } } getNextFailCont() { let e = this.popStack(); for (; e;) { if (e._op !== `OnSuccess` && e._op !== `While` && e._op !== `Iterator`) return e; e = this.popStack(); } } Tag(e) { return U(() => us(this.currentContext, e)); } Left(e) { return Sd(e.left); } None(e) { return Sd(new Xf()); } Right(e) { return G(e.right); } Some(e) { return G(e.value); } Micro(e) { return fd((t) => { let n = t, r = Xg(Vg(e, this.currentContext)); return ( r.addObserver((e) => { if (e._tag === `Success`) return n(G(e.value)); switch (e.cause._tag) { case `Interrupt`: return n(W(Xa(xc))); case `Fail`: return n(Sd(e.cause.error)); case `Die`: return n(vd(e.cause.defect)); } }), fd((e) => { ((n = (t) => { e(Gd); }), r.unsafeInterrupt()); }) ); }); } [at](e) { let t = Oe(() => e.effect_instruction_i0()), n = this.getNextSuccessCont(); return n === void 0 ? ((lb.currentOp = G(t)), cb) : (n._op in ub || sb(n), ub[n._op](this, n, t)); } [it](e) { let t = e, n = this.getNextSuccessCont(); return n === void 0 ? ((lb.currentOp = t), cb) : (n._op in ub || sb(n), ub[n._op](this, n, t.effect_instruction_i0)); } [et](e) { let t = e.effect_instruction_i0, n = this.getNextFailCont(); if (n !== void 0) switch (n._op) { case tt: case rt: return fu(this.currentRuntimeFlags) && this.isInterrupted() ? W(fo(t)) : Oe(() => n.effect_instruction_i1(t)); case `OnStep`: return fu(this.currentRuntimeFlags) && this.isInterrupted() ? W(fo(t)) : G(W(t)); case dt: return ( this.patchRuntimeFlags(this.currentRuntimeFlags, n.patch), fu(this.currentRuntimeFlags) && this.isInterrupted() ? W(Qa(t, this.getInterruptedCause())) : W(t) ); default: sb(n); } else return ((lb.currentOp = W(t)), cb); } [lt](e) { return Oe(() => e.effect_instruction_i0(this, Ih(this.currentRuntimeFlags))); } Blocked(e) { let t = this.getFiberRefs(), n = this.currentRuntimeFlags; if (this._steps.length > 0) { let r = [], i = this._steps[this._steps.length - 1], a = this.popStack(); for (; a && a._op !== `OnStep`;) (r.push(a), (a = this.popStack())); (this.setFiberRefs(i.refs), (this.currentRuntimeFlags = i.flags)); let o = xh(i.refs, t), s = yu(i.flags, n); return G( $u( e.effect_instruction_i0, sd((t) => { for (; r.length > 0;) t.pushStack(r.pop()); return ( t.setFiberRefs(Sh(t.id(), t.getFiberRefs())(o)), (t.currentRuntimeFlags = bu(s)(t.currentRuntimeFlags)), e.effect_instruction_i1 ); }), ), ); } return Wd((t) => B(wb(ed(e.effect_instruction_i0)), () => t(e.effect_instruction_i1))); } RunBlocked(e) { return fb(e.effect_instruction_i0); } [ot](e) { let t = e.effect_instruction_i0, n = this.currentRuntimeFlags, r = bu(n, t); if (fu(r) && this.isInterrupted()) return W(this.getInterruptedCause()); if ((this.patchRuntimeFlags(this.currentRuntimeFlags, t), e.effect_instruction_i1)) { let t = yu(r, n); return (this.pushStack(new nd(t, e)), Oe(() => e.effect_instruction_i1(n))); } else return lp; } [nt](e) { return (this.pushStack(e), e.effect_instruction_i0); } OnStep(e) { return (this.pushStack(e), e.effect_instruction_i0); } [tt](e) { return (this.pushStack(e), e.effect_instruction_i0); } [rt](e) { return (this.pushStack(e), e.effect_instruction_i0); } [Qe](e) { return ( (this._asyncBlockingOn = e.effect_instruction_i1), this.initiateAsync(this.currentRuntimeFlags, e.effect_instruction_i0), (lb.currentOp = e), cb ); } [ut](e) { return ((this._isYielding = !1), (lb.currentOp = e), cb); } [st](e) { let t = e.effect_instruction_i0, n = e.effect_instruction_i1; return t() ? (this.pushStack(e), n()) : lp; } [ct](e) { return ub[ct](this, e, void 0); } [$e](e) { return Oe(() => e.commit()); } runLoop(e) { let t = e; for (this.currentOpCount = 0; ;) { if ( (this.currentRuntimeFlags & 2 && this.currentSupervisor.onEffect(this, t), this._queue.length > 0 && (t = this.drainQueueWhileRunning(this.currentRuntimeFlags, t)), !this._isYielding) ) { this.currentOpCount += 1; let e = this.currentScheduler.shouldYield(this); if (e !== !1) { ((this._isYielding = !0), (this.currentOpCount = 0)); let n = t; t = B(Jd({ priority: e }), () => n); } } try { if ( ((t = this.currentTracer.context(() => { if (pb !== t[td]._V) { let e = this.getFiberRef(Mf); if (e._tag === `Some`) { let n = t[td]._V; this.log( `Executing an Effect versioned ${n} with a Runtime of version ${ft()}, you may want to dedupe the effect dependencies, you can use the language service plugin to detect this at compile time: https://github.com/Effect-TS/language-service`, qa, e, ); } } return this[t._op](t); }, this)), t === cb) ) { let e = lb.currentOp; return e._op === `Yield` || e._op === `Async` ? cb : ((lb.currentOp = null), e._op === `Success` || e._op === `Failure` ? e : W(Ya(e))); } } catch (e) { t = (t !== cb && !v(t, `_op`)) || !(t._op in this) ? yd(`Not a valid effect: ${Ge(t)}`) : Kf(e) ? W(Qa(Ya(e), Xa(xc))) : vd(e); } } } run = () => { this.drainQueueOnCurrentThread(); }; }; const hb = g(`effect/FiberRef/currentMinimumLogLevel`, () => gf(Jh(`Info`))), gb = (e) => R_((t) => { let n = uh(t.context, Pm); ls(n, _m).unsafe.log(e.log(t)); }), _b = g(Symbol.for(`effect/Logger/defaultLogger`), () => gb(B_)), vb = g(Symbol.for(`effect/Logger/tracerLogger`), () => R_(({ annotations: e, cause: t, context: n, fiberId: r, logLevel: i, message: a }) => { let o = h_(ds(oh(n, Sf), Om)); if (o._tag === `None` || o.value._tag === `ExternalSpan`) return; let s = us(oh(n, Pm), zp), c = {}; for (let [t, n] of e) c[t] = n; ((c[`effect.fiberId`] = Tc(r)), (c[`effect.logLevel`] = i.label), t !== null && t._tag !== `Empty` && (c[`effect.cause`] = To(t, { renderErrorCause: !0 })), o.value.event( Ge(Array.isArray(a) && a.length === 1 ? a[0] : a), s.unsafeCurrentTimeNanos(), c, )); }), ), yb = g(Symbol.for(`effect/FiberRef/currentLoggers`), () => _f(Aa(_b, vb))), bb = t( (e) => he(e[0]), (e, t, n) => sd((r) => { let i = n?.batching === !0 || (n?.batching === `inherit` && r.getFiberRef(Af)); return n?.discard ? s_( n.concurrency, () => jb( qm, n?.concurrentFinalizers, )((n) => i ? Sb(e, (e, r) => n(t(e, r)), !0, !1, 1) : Pd(e, (e, r) => n(t(e, r))), ), () => jb(Jm, n?.concurrentFinalizers)((n) => Sb(e, (e, r) => n(t(e, r)), i, !1)), (r) => jb(Ym(r), n?.concurrentFinalizers)((n) => Sb(e, (e, r) => n(t(e, r)), i, !1, r)), ) : s_( n?.concurrency, () => jb( qm, n?.concurrentFinalizers, )((n) => (i ? Cb(e, 1, (e, r) => n(t(e, r)), !0) : Nd(e, (e, r) => n(t(e, r))))), () => jb(Jm, n?.concurrentFinalizers)((n) => xb(e, (e, r) => n(t(e, r)), i)), (r) => jb(Ym(r), n?.concurrentFinalizers)((n) => Cb(e, r, (e, r) => n(t(e, r)), i)), ); }), ), xb = (e, t, n) => H(() => { let r = L(e), i = Array(r.length); return Zd( Sb(r, (e, n) => B(t(e, n), (e) => U(() => (i[n] = e))), n, !1), V(i), ); }), Sb = (e, t, n, r, i) => Wd((a) => Hd((o) => sd((s) => { let c = Array.from(e).reverse(), l = c.length; if (l === 0) return Gd; let u = 0, d = !1, f = i ? Math.min(c.length, i) : c.length, p = new Set(), m = [], h = () => p.forEach((e) => { e.currentScheduler.scheduleTask( () => { e.unsafeInterruptAsFork(s.id()); }, 0, e, ); }), g = [], ee = [], _ = [], te = () => { let e = m .filter(({ exit: e }) => e._tag === `Failure`) .sort((e, t) => (e.index < t.index ? -1 : e.index === t.index ? 0 : 1)) .map(({ exit: e }) => e); return (e.length === 0 && e.push(lp), e); }, ne = (e, t = !1) => { let n = Ud(o(e)), r = Eb(n, s, s.currentRuntimeFlags, k_); return ( s.currentScheduler.scheduleTask( () => { (t && r.unsafeInterruptAsFork(s.id()), r.resume(n)); }, 0, r, ), r ); }, re = () => { (r || ((l -= c.length), (c = [])), (d = !0), h()); }, ie = n ? Od : xd, ae = ne( md((e) => { let r = (e, t) => { e._op === `Blocked` ? _.push(e) : (m.push({ index: t, exit: e }), e._op === `Failure` && !d && re()); }, o = () => { if (c.length > 0) { let f = c.pop(), h = u++, re = () => { let e = c.pop(); return ((h = u++), B(Jd(), () => B(ie(a(t(e, h))), ae))); }, ae = (e) => (c.length > 0 && (r(e, h), c.length > 0) ? re() : V(e)), oe = B(ie(a(t(f, h))), ae), se = ne(oe); (g.push(se), p.add(se), d && se.currentScheduler.scheduleTask( () => { se.unsafeInterruptAsFork(s.id()); }, 0, se, ), se.addObserver((t) => { let a; if ( ((a = t._op === `Failure` ? t : t.effect_instruction_i0), ee.push(se), p.delete(se), r(a, h), m.length === l) ) e(V(I(rp(te(), { parallel: !0 }), () => lp))); else if (_.length + m.length === l) { let t = te(), r = _.map((e) => e.effect_instruction_i0).reduce(Tu); e( V( $u( r, Sb( [ I(rp(t, { parallel: !0 }), () => lp), ..._.map((e) => e.effect_instruction_i1), ], (e) => e, n, !0, i, ), ), ), ); } else o(); })); } }; for (let e = 0; e < f; e++) o(); }), ); return ud( zd( kd(a(P_(ae))), cp({ onFailure: (e) => { re(); let t = _.length + 1, n = Math.min(typeof i == `number` ? i : _.length, _.length), r = Array.from(_); return md((i) => { let a = [], o = 0, s = 0, c = (n, s) => (c) => { ((a[n] = c), o++, o === t && i(G(W(e))), r.length > 0 && s && l()); }, l = () => { (ne(r.pop(), !0).addObserver(c(s, !0)), s++); }; (ae.addObserver(c(s, !1)), s++); for (let e = 0; e < n; e++) l(); }); }, onSuccess: () => Nd(ee, (e) => e.inheritAll), }), ), ); }), ), ), Cb = (e, t, n, r) => H(() => { let i = L(e), a = Array(i.length); return Zd( Sb(i, (e, t) => Id(n(e, t), (e) => (a[t] = e)), r, !1, t), V(a), ); }), wb = (e) => Ob(e, k_), Tb = (e, t, n, r = null) => { let i = Db(e, t, n, r); return (i.resume(e), i); }, Eb = (e, t, n, r = null) => Db(e, t, n, r), Db = (e, t, n, r = null) => { let i = Ec(), a = t.getFiberRefs(), o = nh(a, i), s = new mb(i, o, n), l = oh(o, Sf), u = s.currentSupervisor; return ( u.onStart(l, e, N(t), s), s.addObserver((e) => u.onEnd(e, s)), (r === null ? c( t.getFiberRef(Pf), I(() => t.scope()), ) : r ).add(n, s), s ); }, Ob = (e, t) => sd((n, r) => V(Tb(e, n, r.runtimeFlags, t))), kb = (e) => vp((t) => un(ds(t, Nb), { onNone: () => e, onSome: (t) => { switch (t.strategy._tag) { case `Parallel`: return e; case `Sequential`: case `ParallelN`: return B(Bf(t, Jm), (t) => Lb(e, t)); } }, }), ), Ab = (e) => (t) => vp((n) => un(ds(n, Nb), { onNone: () => t, onSome: (n) => n.strategy._tag === `ParallelN` && n.strategy.parallelism === e ? t : B(Bf(n, Ym(e)), (e) => Lb(t, e)), }), ), jb = (e, t) => (r) => vp((i) => un(ds(i, Nb), { onNone: () => r(n), onSome: (i) => { if (t === !0) { let t = e._tag === `Parallel` ? kb : e._tag === `Sequential` ? Mb : Ab(e.parallelism); switch (i.strategy._tag) { case `Parallel`: return t(r(kb)); case `Sequential`: return t(r(Mb)); case `ParallelN`: return t(r(Ab(i.strategy.parallelism))); } } else return r(n); }, }), ), Mb = (e) => vp((t) => un(ds(t, Nb), { onNone: () => e, onSome: (t) => { switch (t.strategy._tag) { case `Sequential`: return e; case `Parallel`: case `ParallelN`: return B(Bf(t, qm), (t) => Lb(e, t)); } }, }), ), Nb = as(`effect/Scope`), Pb = (e, t) => { e.state._tag === `Open` && e.state.finalizers.set({}, t); }, Fb = { [If]: If, [Lf]: Lf, pipe() { return k(this, arguments); }, fork(e) { return U(() => { let t = Ib(e); if (this.state._tag === `Closed`) return ((t.state = this.state), t); let n = {}; return ( this.state.finalizers.set(n, (e) => t.close(e)), Pb(t, (e) => U(() => { this.state._tag === `Open` && this.state.finalizers.delete(n); }), ), t ); }); }, close(e) { return H(() => { if (this.state._tag === `Closed`) return Gd; let t = Array.from(this.state.finalizers.values()).reverse(); return ( (this.state = { _tag: `Closed`, exit: e }), t.length === 0 ? Gd : Gm(this.strategy) ? c( Nd(t, (t) => xd(t(e))), B((e) => c( rp(e), _n(np), I(() => lp), ), ), ) : Km(this.strategy) ? c( xb(t, (t) => xd(t(e)), !1), B((e) => c( rp(e, { parallel: !0 }), _n(np), I(() => lp), ), ), ) : c( Cb(t, this.strategy.parallelism, (t) => xd(t(e)), !1), B((e) => c( rp(e, { parallel: !0 }), _n(np), I(() => lp), ), ), ) ); }); }, addFinalizer(e) { return H(() => this.state._tag === `Closed` ? e(this.state.exit) : (this.state.finalizers.set({}, e), Gd), ); }, }, Ib = (e = Hm) => { let t = Object.create(Fb); return ((t.strategy = e), (t.state = { _tag: `Open`, finalizers: new Map() }), t); }, Lb = t(2, (e, t) => bp(e, fs(ss(Nb, t)))), Rb = (e) => bf(e, { differ: Qy, fork: Ky }), zb = xf(gu), Bb = Rb(By), Vb = t(2, (e, t) => Wd((n) => jd(n(e), { onFailure: (e) => jd(t, { onFailure: (t) => wd(Qa(e, t)), onSuccess: () => wd(e) }), onSuccess: (e) => ld(t, e), }), ), ), Hb = (e, t, n) => Dd((r) => Vb( B(wb(Fd(e)), (e) => md((r) => { let i = t.map((e) => e.listeners.count), a = () => { i.every((e) => e === 0) && t.every( (e) => e.result.state.current._tag === `Pending` || !!( e.result.state.current._tag === `Done` && $f(e.result.state.current.effect) && e.result.state.current.effect._tag === `Failure` && ro(e.result.state.current.effect.cause) ), ) && (o.forEach((e) => e()), n?.(), r(Qd(e))); }; e.addObserver((e) => { (o.forEach((e) => e()), r(e)); }); let o = t.map((e, t) => { let n = (e) => { ((i[t] = e), a()); }; return (e.listeners.addObserver(n), () => e.listeners.removeObserver(n)); }); return ( a(), U(() => { o.forEach((e) => e()); }) ); }), ), H(() => { let e = t.flatMap((e) => (e.state.completed ? [] : [e])); return Pd(e, (e) => My(e.request, op(r))); }), ), ), Ub = zf, Wb = Bf, Gb = (e) => function () { if (arguments.length === 1) { let t = arguments[0]; return (n, ...r) => e(t, n, ...r); } return e.apply(this, arguments); }, Kb = Gb((e, t, n) => { let r = Ec(), i = [[Sf, [[r, e.context]]]]; n?.scheduler && i.push([a_, [[r, n.scheduler]]]); let a = dh(e.fiberRefs, { entries: i, forkAs: r }); n?.updateRefs && (a = n.updateRefs(a, r)); let o = new mb(r, a, e.runtimeFlags), s = t; n?.scope && (s = B(Wb(n.scope, Hm), (e) => Zd( Rf( e, Dd((e) => (T(e, o.id()) ? Gd : $d(o, e))), ), zd(t, (t) => Ub(e, t)), ), )); let c = o.currentSupervisor; return ( c !== By && (c.onStart(e.context, s, M(), o), o.addObserver((e) => c.onEnd(e, o))), k_.add(e.runtimeFlags, o), n?.immediate === !1 ? o.resume(s) : o.start(s), o ); }), qb = Gb((e, t) => { let n = tx(e)(t); if (n._tag === `Failure`) throw $b(n.effect_instruction_i0); return n.effect_instruction_i0; }); var Jb = class extends Error { fiber; _tag = `AsyncFiberException`; constructor(e) { (super( `Fiber #${e.id().id} cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work`, ), (this.fiber = e), (this.name = this._tag), (this.stack = this.message)); } }; const Yb = (e) => { let t = Error.stackTraceLimit; Error.stackTraceLimit = 0; let n = new Jb(e); return ((Error.stackTraceLimit = t), n); }, Xb = Symbol.for(`effect/Runtime/FiberFailure`), Zb = Symbol.for(`effect/Runtime/FiberFailure/Cause`); var Qb = class extends Error { [Xb]; [Zb]; constructor(e) { let t = No(e)[0]; (super(t?.message || `An error has occurred`), (this[Xb] = Xb), (this[Zb] = e), (this.name = t ? `(FiberFailure) ${t.name}` : `FiberFailure`), t?.stack && (this.stack = t.stack)); } toJSON() { return { _id: `FiberFailure`, cause: this[Zb].toJSON() }; } toString() { return `(FiberFailure) ` + To(this[Zb], { renderErrorCause: !0 }); } [E]() { return this.toString(); } }; const $b = (e) => { let t = Error.stackTraceLimit; Error.stackTraceLimit = 0; let n = new Qb(e); return ((Error.stackTraceLimit = t), n); }, ex = (e) => { let t = e; switch (t._op) { case `Failure`: case `Success`: return t; case `Left`: return ap(t.left); case `Right`: return G(t.right); case `Some`: return G(t.value); case `None`: return ap(new Xf()); } }, tx = Gb((e, t) => { let n = ex(t); if (n) return n; let r = new i_(), i = Kb(e)(t, { scheduler: r }); return (r.flush(), i.unsafePoll() || ip(_d(Yb(i), xp(i)))); }); var nx = class { context; runtimeFlags; fiberRefs; constructor(e, t, n) { ((this.context = e), (this.runtimeFlags = t), (this.fiberRefs = n)); } pipe() { return k(this, arguments); } }; const rx = ((e) => new nx(e.context, e.runtimeFlags, e.fiberRefs))({ context: os(), runtimeFlags: hu(1, 32, 4), fiberRefs: fh(), }), ix = Kb(rx), ax = qb(rx), ox = Symbol.for(`effect/DateTime`), sx = Symbol.for(`effect/DateTime/TimeZone`), cx = { [ox]: ox, pipe() { return k(this, arguments); }, [E]() { return this.toString(); }, toJSON() { return zx(this).toJSON(); }, }, lx = { ...cx, _tag: `Utc`, [y]() { return C(this, Ne(this.epochMillis)); }, [w](e) { return hx(e) && e._tag === `Utc` && this.epochMillis === e.epochMillis; }, toString() { return `DateTime.Utc(${zx(this).toJSON()})`; }, }, ux = { ...cx, _tag: `Zoned`, [y]() { return c(Ne(this.epochMillis), x(b(this.zone)), C(this)); }, [w](e) { return ( hx(e) && e._tag === `Zoned` && this.epochMillis === e.epochMillis && T(this.zone, e.zone) ); }, toString() { return `DateTime.Zoned(${$x(this)})`; }, }, dx = { [sx]: sx, [E]() { return this.toString(); }, }, fx = { ...dx, _tag: `Named`, [y]() { return C(this, S(`Named:${this.id}`)); }, [w](e) { return gx(e) && e._tag === `Named` && this.id === e.id; }, toString() { return `TimeZone.Named(${this.id})`; }, toJSON() { return { _id: `TimeZone`, _tag: `Named`, id: this.id }; }, }, px = { ...dx, _tag: `Offset`, [y]() { return C(this, S(`Offset:${this.offset}`)); }, [w](e) { return gx(e) && e._tag === `Offset` && this.offset === e.offset; }, toString() { return `TimeZone.Offset(${Hx(this.offset)})`; }, toJSON() { return { _id: `TimeZone`, _tag: `Offset`, offset: this.offset }; }, }, mx = (e, t, n) => { let r = Object.create(ux); return ( (r.epochMillis = e), (r.zone = t), Object.defineProperty(r, "partsUtc", { value: n, enumerable: !1, writable: !0 }), Object.defineProperty(r, "adjustedEpochMillis", { value: void 0, enumerable: !1, writable: !0, }), Object.defineProperty(r, "partsAdjusted", { value: void 0, enumerable: !1, writable: !0 }), r ); }, hx = (e) => v(e, ox), gx = (e) => v(e, sx), _x = (e) => gx(e) && e._tag === `Offset`, vx = (e) => gx(e) && e._tag === `Named`, yx = (e) => e._tag === `Utc`, bx = (e) => e._tag === `Zoned`, xx = l((e, t) => e.epochMillis === t.epochMillis), Sx = (e) => { let t = Object.create(lx); return ( (t.epochMillis = e), Object.defineProperty(t, "partsUtc", { value: void 0, enumerable: !1, writable: !0 }), t ); }, Cx = (e) => { let t = e.getTime(); if (Number.isNaN(t)) throw new Cp(`Invalid date`); return Sx(t); }, wx = (e) => { if (hx(e)) return e; if (e instanceof Date) return Cx(e); if (typeof e == `object`) { let t = new Date(0); return (Gx(t, e), Cx(t)); } else if (typeof e == `string` && !Tx(e)) return Cx(new Date(e + `Z`)); return Cx(new Date(e)); }, Tx = (e) => /Z|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e), Ex = (e, t) => { if (t?.timeZone === void 0 && hx(e) && bx(e)) return e; let n = wx(e); if (n.epochMillis < -86399999568e5 || n.epochMillis > 86399999496e5) throw RangeError(`Epoch millis out of range: ${n.epochMillis}`); let r; if (t?.timeZone === void 0) { let e = new Date(n.epochMillis).getTimezoneOffset() * -60 * 1e3; r = Px(e); } else if (gx(t?.timeZone)) r = t.timeZone; else if (typeof t?.timeZone == `number`) r = Px(t.timeZone); else { let e = Lx(t.timeZone); if (P(e)) throw new Cp(`Invalid time zone: ${t.timeZone}`); r = e.value; } return t?.adjustForTimeZone === !0 ? qx(n.epochMillis, r, t?.disambiguation ?? `compatible`) : mx(n.epochMillis, r, n.partsUtc); }, Dx = hn(Ex), Ox = /^(.{17,35})\[(.+)\]$/, kx = (e) => { let t = Ox.exec(e); if (t === null) { let t = Yx(e); return t === null ? M() : Dx(e, { timeZone: t }); } let [, n, r] = t; return Dx(n, { timeZone: r }); }, Ax = g(`effect/DateTime/validZoneCache`, () => new Map()), jx = { day: `numeric`, month: `numeric`, year: `numeric`, hour: `numeric`, minute: `numeric`, second: `numeric`, timeZoneName: `longOffset`, fractionalSecondDigits: 3, hourCycle: `h23`, }, Mx = (e) => { let t = e.resolvedOptions().timeZone; if (Ax.has(t)) return Ax.get(t); let n = Object.create(fx); return ((n.id = t), (n.format = e), Ax.set(t, n), n); }, Nx = (e) => { if (Ax.has(e)) return Ax.get(e); try { return Mx(new Intl.DateTimeFormat(`en-US`, { ...jx, timeZone: e })); } catch { throw new Cp(`Invalid time zone: ${e}`); } }, Px = (e) => { let t = Object.create(px); return ((t.offset = e), t); }, Fx = hn(Nx), Ix = /^(?:GMT|[+-])/, Lx = (e) => { if (Ix.test(e)) { let t = Yx(e); return t === null ? M() : N(Px(t)); } return Fx(e); }, Rx = (e) => (e._tag === `Offset` ? Hx(e.offset) : e.id), zx = (e) => new Date(e.epochMillis), Bx = (e) => { if (e._tag === `Utc`) return new Date(e.epochMillis); if (e.zone._tag === `Offset`) return new Date(e.epochMillis + e.zone.offset); if (e.adjustedEpochMillis !== void 0) return new Date(e.adjustedEpochMillis); let t = e.zone.format.formatToParts(e.epochMillis).filter((e) => e.type !== `literal`), n = new Date(0); return ( n.setUTCFullYear(Number(t[2].value), Number(t[0].value) - 1, Number(t[1].value)), n.setUTCHours(Number(t[3].value), Number(t[4].value), Number(t[5].value), Number(t[6].value)), (e.adjustedEpochMillis = n.getTime()), n ); }, Vx = (e) => Bx(e).getTime() - Wx(e), Hx = (e) => { let t = Math.abs(e), n = Math.floor(t / (3600 * 1e3)), r = Math.round((t % (3600 * 1e3)) / (60 * 1e3)); return ( r === 60 && ((n += 1), (r = 0)), `${e < 0 ? `-` : `+`}${String(n).padStart(2, `0`)}:${String(r).padStart(2, `0`)}` ); }, Ux = (e) => Hx(Vx(e)), Wx = (e) => e.epochMillis, Gx = (e, t) => { if ( (t.year !== void 0 && e.setUTCFullYear(t.year), t.month !== void 0 && e.setUTCMonth(t.month - 1), t.day !== void 0 && e.setUTCDate(t.day), t.weekDay !== void 0) ) { let n = t.weekDay - e.getUTCDay(); e.setUTCDate(e.getUTCDate() + n); } (t.hours !== void 0 && e.setUTCHours(t.hours), t.minutes !== void 0 && e.setUTCMinutes(t.minutes), t.seconds !== void 0 && e.setUTCSeconds(t.seconds), t.millis !== void 0 && e.setUTCMilliseconds(t.millis)); }, Kx = 1440 * 60 * 1e3, qx = (e, t, n) => { if (t._tag === `Offset`) return mx(e - t.offset, t); let r = Xx(e - Kx, e, t), i = Xx(e + Kx, e, t); if (r === i) return mx(e - r, t); let a = r < i, o = r - i; if (a) { if (Xx(e - i, e, t) === i) return mx(e - i, t); let a = mx(e - r, t); if (e !== Bx(a).getTime()) switch (n) { case `reject`: { let n = new Date(e).toISOString(); throw RangeError(`Gap time: ${n} does not exist in time zone ${t.id}`); } case `earlier`: return mx(e - i, t); case `compatible`: case `later`: return a; } return a; } if (Xx(e - r, e, t) === r) { if (n === `earlier` || n === `compatible` || Xx(e - r + o, e + o, t) === r) return mx(e - r, t); if (n === `reject`) { let n = new Date(e).toISOString(); throw RangeError(`Ambiguous time: ${n} occurs twice in time zone ${t.id}`); } } return mx(e - i, t); }, Jx = /([+-])(\d{2}):(\d{2})$/, Yx = (e) => { let t = Jx.exec(e); if (t === null) return null; let [, n, r, i] = t; return (n === `+` ? 1 : -1) * (Number(r) * 60 + Number(i)) * 60 * 1e3; }, Xx = (e, t, n) => { let r = n.format.formatToParts(e).find((e) => e.type === `timeZoneName`)?.value ?? ``; if (r === `GMT`) return 0; let i = Yx(r); return i === null ? Vx(mx(t, n)) : i; }, Zx = (e) => zx(e).toISOString(), Qx = (e) => { let t = Bx(e); return e._tag === `Utc` ? t.toISOString() : `${t.toISOString().slice(0, -1)}${Ux(e)}`; }, $x = (e) => (e.zone._tag === `Offset` ? Qx(e) : `${Qx(e)}[${e.zone.id}]`), eS = (e) => e.toUpperCase(), tS = (e) => e.toLowerCase(), nS = (e) => (e.length === 0 ? e : eS(e[0]) + e.slice(1)), rS = (e) => (e.length === 0 ? e : tS(e[0]) + e.slice(1)), iS = (e) => e.length > 0, aS = od, oS = bb, sS = H, cS = Gd, lS = hd, uS = Id, dS = Ld, fS = Rd, pS = bd, mS = B, hS = ix, gS = ax, _S = hx, vS = _x, yS = vx, bS = yx, xS = bx, SS = xx, CS = Cx, wS = wx, TS = Ex, ES = kx, DS = Nx, OS = Px, kS = Lx, AS = Rx, jS = zx, MS = Wx; ps(`effect/DateTime/CurrentTimeZone`)(); const NS = Zx, PS = $x, FS = (e, t) => { switch (t._tag) { case `StringKeyword`: case `TemplateLiteral`: return Object.keys(e); case `SymbolKeyword`: return Object.getOwnPropertySymbols(e); case `Refinement`: return FS(e, t.from); } }, IS = (e) => { let t = !1, n; return () => (t ? n : ((n = e()), (t = !0), n)); }, LS = (e) => Array.isArray(e), RS = (e) => !Array.isArray(e), zS = (e) => `[${Ue(e)}]`, BS = (e) => (LS(e) ? e.map(zS).join(``) : zS(e)), VS = (e, t, n, r) => { let i = e; return ( n && R(n) && (i += `\nat path: ${BS(n)}`), t !== void 0 && (i += `\ndetails: ${t}`), r && (i += `\nschema (${r._tag}): ${r}`), i ); }, HS = (e) => VS(`Unsupported key schema`, void 0, void 0, e), US = (e) => VS(`Unsupported literal`, `literal value: ${We(e)}`), WS = (e) => VS(`Duplicate index signature`, `${e} index signature`), GS = VS( `Unsupported index signature parameter`, "An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types", ), KS = VS(`Invalid element`, `A required element cannot follow an optional element. ts(1257)`), qS = (e) => VS(`Duplicate property signature transformation`, `Duplicate key ${We(e)}`), JS = (e) => VS(`Duplicate property signature`, `Duplicate key ${We(e)}`), YS = Symbol.for(`effect/SchemaId/DateFromSelf`), XS = Symbol.for(`effect/SchemaId/GreaterThan`), ZS = Symbol.for(`effect/SchemaId/GreaterThanOrEqualTo`), QS = Symbol.for(`effect/SchemaId/LessThan`), $S = Symbol.for(`effect/SchemaId/LessThanOrEqualTo`), eC = Symbol.for(`effect/SchemaId/Int`), tC = Symbol.for(`effect/SchemaId/NonNaN`), nC = Symbol.for(`effect/SchemaId/Finite`), rC = Symbol.for(`effect/SchemaId/JsonNumber`), iC = Symbol.for(`effect/SchemaId/Between`), aC = Symbol.for(`effect/SchemaId/GreaterThanOrEqualToBigint`), oC = Symbol.for(`effect/SchemaId/BetweenBigint`), sC = Symbol.for(`effect/SchemaId/MinLength`), cC = Symbol.for(`effect/SchemaId/MaxLength`), lC = Symbol.for(`effect/SchemaId/Length`), uC = Symbol.for(`effect/annotation/TypeConstructor`), dC = Symbol.for(`effect/annotation/Brand`), fC = Symbol.for(`effect/annotation/SchemaId`), pC = Symbol.for(`effect/annotation/Message`), mC = Symbol.for(`effect/annotation/MissingMessage`), hC = Symbol.for(`effect/annotation/Identifier`), gC = Symbol.for(`effect/annotation/Title`), _C = Symbol.for(`effect/annotation/AutoTitle`), vC = Symbol.for(`effect/annotation/Description`), yC = Symbol.for(`effect/annotation/Examples`), bC = Symbol.for(`effect/annotation/Default`), xC = Symbol.for(`effect/annotation/JSONSchema`), SC = Symbol.for(`effect/annotation/Arbitrary`), CC = Symbol.for(`effect/annotation/Pretty`), wC = Symbol.for(`effect/annotation/Equivalence`), TC = Symbol.for(`effect/annotation/Documentation`), EC = Symbol.for(`effect/annotation/Concurrency`), DC = Symbol.for(`effect/annotation/Batching`), OC = Symbol.for(`effect/annotation/ParseIssueTitle`), kC = Symbol.for(`effect/annotation/ParseOptions`), AC = Symbol.for(`effect/annotation/DecodingFallback`), jC = Symbol.for(`effect/annotation/Surrogate`), MC = Symbol.for(`effect/annotation/StableFilter`), NC = t(2, (e, t) => Object.prototype.hasOwnProperty.call(e.annotations, t) ? N(e.annotations[t]) : M(), ), PC = NC(dC), FC = NC(pC), IC = NC(mC), LC = NC(gC), RC = NC(_C), zC = NC(hC), BC = NC(vC), VC = NC(EC), HC = NC(DC), UC = NC(OC), WC = NC(kC), GC = NC(AC), KC = NC(jC), qC = NC(MC), JC = (e) => wn(qC(e), (e) => e === !0), YC = Symbol.for(`effect/annotation/JSONIdentifier`), XC = NC(YC), ZC = (e) => dn(XC(e), () => zC(e)); var QC = class { typeParameters; decodeUnknown; encodeUnknown; annotations; _tag = `Declaration`; constructor(e, t, n, r = {}) { ((this.typeParameters = e), (this.decodeUnknown = t), (this.encodeUnknown = n), (this.annotations = r)); } toString() { return I(oT(this), () => `<declaration schema>`); } toJSON() { return { _tag: this._tag, typeParameters: this.typeParameters.map((e) => e.toJSON()), annotations: K(this.annotations), }; } }; const $C = (e) => (t) => t._tag === e; var ew = class { literal; annotations; _tag = `Literal`; constructor(e, t = {}) { ((this.literal = e), (this.annotations = t)); } toString() { return I(oT(this), () => We(this.literal)); } toJSON() { return { _tag: this._tag, literal: re(this.literal) ? String(this.literal) : this.literal, annotations: K(this.annotations), }; } }; const tw = $C(`Literal`), nw = new ew(null); var rw = class { symbol; annotations; _tag = `UniqueSymbol`; constructor(e, t = {}) { ((this.symbol = e), (this.annotations = t)); } toString() { return I(oT(this), () => We(this.symbol)); } toJSON() { return { _tag: this._tag, symbol: String(this.symbol), annotations: K(this.annotations) }; } }; const iw = new (class { annotations; _tag = `NeverKeyword`; constructor(e = {}) { this.annotations = e; } toString() { return rT(this); } toJSON() { return { _tag: this._tag, annotations: K(this.annotations) }; } })({ [gC]: `never` }), aw = new (class { annotations; _tag = `UnknownKeyword`; constructor(e = {}) { this.annotations = e; } toString() { return rT(this); } toJSON() { return { _tag: this._tag, annotations: K(this.annotations) }; } })({ [gC]: `unknown` }), ow = new (class { annotations; _tag = `AnyKeyword`; constructor(e = {}) { this.annotations = e; } toString() { return rT(this); } toJSON() { return { _tag: this._tag, annotations: K(this.annotations) }; } })({ [gC]: `any` }), sw = new (class { annotations; _tag = `StringKeyword`; constructor(e = {}) { this.annotations = e; } toString() { return rT(this); } toJSON() { return { _tag: this._tag, annotations: K(this.annotations) }; } })({ [gC]: `string`, [vC]: `a string` }), cw = $C(`StringKeyword`), lw = new (class { annotations; _tag = `NumberKeyword`; constructor(e = {}) { this.annotations = e; } toString() { return rT(this); } toJSON() { return { _tag: this._tag, annotations: K(this.annotations) }; } })({ [gC]: `number`, [vC]: `a number` }), uw = new (class { annotations; _tag = `BooleanKeyword`; constructor(e = {}) { this.annotations = e; } toString() { return rT(this); } toJSON() { return { _tag: this._tag, annotations: K(this.annotations) }; } })({ [gC]: `boolean`, [vC]: `a boolean` }), dw = new (class { annotations; _tag = `BigIntKeyword`; constructor(e = {}) { this.annotations = e; } toString() { return rT(this); } toJSON() { return { _tag: this._tag, annotations: K(this.annotations) }; } })({ [gC]: `bigint`, [vC]: `a bigint` }), fw = new (class { annotations; _tag = `SymbolKeyword`; constructor(e = {}) { this.annotations = e; } toString() { return rT(this); } toJSON() { return { _tag: this._tag, annotations: K(this.annotations) }; } })({ [gC]: `symbol`, [vC]: `a symbol` }), pw = $C(`SymbolKeyword`); var mw = class { type; annotations; constructor(e, t = {}) { ((this.type = e), (this.annotations = t)); } toJSON() { return { type: this.type.toJSON(), annotations: K(this.annotations) }; } toString() { return String(this.type); } }, hw = class extends mw { isOptional; constructor(e, t, n = {}) { (super(e, n), (this.isOptional = t)); } toJSON() { return { type: this.type.toJSON(), isOptional: this.isOptional, annotations: K(this.annotations), }; } toString() { return String(this.type) + (this.isOptional ? `?` : ``); } }; const gw = (e) => e.map((e) => e.type); var _w = class { elements; rest; isReadonly; annotations; _tag = `TupleType`; constructor(e, t, n, r = {}) { ((this.elements = e), (this.rest = t), (this.isReadonly = n), (this.annotations = r)); let i = !1, a = !1; for (let t of e) if (t.isOptional) i = !0; else if (i) { a = !0; break; } if (a || (i && t.length > 1)) throw Error(KS); } toString() { return I(oT(this), () => vw(this)); } toJSON() { return { _tag: this._tag, elements: this.elements.map((e) => e.toJSON()), rest: this.rest.map((e) => e.toJSON()), isReadonly: this.isReadonly, annotations: K(this.annotations), }; } }; const vw = (e) => { let t = e.elements.map(String).join(`, `); return kn(e.rest, { onEmpty: () => `readonly [${t}]`, onNonEmpty: (n, r) => { let i = String(n), a = i.includes(` | `) ? `(${i})` : i; if (r.length > 0) { let n = r.map(String).join(`, `); return e.elements.length > 0 ? `readonly [${t}, ...${a}[], ${n}]` : `readonly [...${a}[], ${n}]`; } else if (e.elements.length > 0) return `readonly [${t}, ...${a}[]]`; else return `ReadonlyArray<${i}>`; }, }); }; var yw = class extends hw { name; isReadonly; constructor(e, t, n, r, i) { (super(t, n, i), (this.name = e), (this.isReadonly = r)); } toString() { return ( (this.isReadonly ? `readonly ` : ``) + String(this.name) + (this.isOptional ? `?` : ``) + `: ` + this.type ); } toJSON() { return { name: String(this.name), type: this.type.toJSON(), isOptional: this.isOptional, isReadonly: this.isReadonly, annotations: K(this.annotations), }; } }; const bw = (e) => { switch (e._tag) { case `StringKeyword`: case `SymbolKeyword`: case `TemplateLiteral`: return !0; case `Refinement`: return bw(e.from); } return !1; }; var xw = class { type; isReadonly; parameter; constructor(e, t, n) { if (((this.type = t), (this.isReadonly = n), bw(e))) this.parameter = e; else throw Error(GS); } toString() { return (this.isReadonly ? `readonly ` : ``) + `[x: ${this.parameter}]: ${this.type}`; } toJSON() { return { parameter: this.parameter.toJSON(), type: this.type.toJSON(), isReadonly: this.isReadonly, }; } }, Sw = class { annotations; _tag = `TypeLiteral`; propertySignatures; indexSignatures; constructor(e, t, n = {}) { this.annotations = n; let r = {}; for (let t = 0; t < e.length; t++) { let n = e[t].name; if (Object.prototype.hasOwnProperty.call(r, n)) throw Error(JS(n)); r[n] = null; } let i = { string: !1, symbol: !1 }; for (let e = 0; e < t.length; e++) { let n = nT(t[e].parameter); if (cw(n)) { if (i.string) throw Error(WS(`string`)); i.string = !0; } else if (pw(n)) { if (i.symbol) throw Error(WS(`symbol`)); i.symbol = !0; } } ((this.propertySignatures = e), (this.indexSignatures = t)); } toString() { return I(oT(this), () => ww(this)); } toJSON() { return { _tag: this._tag, propertySignatures: this.propertySignatures.map((e) => e.toJSON()), indexSignatures: this.indexSignatures.map((e) => e.toJSON()), annotations: K(this.annotations), }; } }; const Cw = (e) => e.map(String).join(`; `), ww = (e) => { if (e.propertySignatures.length > 0) { let t = e.propertySignatures.map(String).join(`; `); return e.indexSignatures.length > 0 ? `{ ${t}; ${Cw(e.indexSignatures)} }` : `{ ${t} }`; } else if (e.indexSignatures.length > 0) return `{ ${Cw(e.indexSignatures)} }`; else return `{}`; }, Tw = Yn( sn(Kp, (e) => { switch (e._tag) { case `AnyKeyword`: return 0; case `UnknownKeyword`: return 1; case `ObjectKeyword`: return 2; case `StringKeyword`: case `NumberKeyword`: case `BooleanKeyword`: case `BigIntKeyword`: case `SymbolKeyword`: return 3; } return 4; }), ), Ew = { string: `StringKeyword`, number: `NumberKeyword`, boolean: `BooleanKeyword`, bigint: `BigIntKeyword`, }, Dw = (e) => sr(e, (e) => (Mw(e) ? Dw(e.types) : [e])), Ow = (e) => { let t = Tw(e), n = [], r = {}, i = []; for (let e of t) switch (e._tag) { case `NeverKeyword`: break; case `AnyKeyword`: return [ow]; case `UnknownKeyword`: return [aw]; case `ObjectKeyword`: case `UndefinedKeyword`: case `VoidKeyword`: case `StringKeyword`: case `NumberKeyword`: case `BooleanKeyword`: case `BigIntKeyword`: case `SymbolKeyword`: r[e._tag] || ((r[e._tag] = e), n.push(e)); break; case `Literal`: { let t = typeof e.literal; switch (t) { case `string`: case `number`: case `bigint`: case `boolean`: !r[Ew[t]] && !i.includes(e.literal) && (i.push(e.literal), n.push(e)); break; case `object`: i.includes(e.literal) || (i.push(e.literal), n.push(e)); break; } break; } case `UniqueSymbol`: !r.SymbolKeyword && !i.includes(e.symbol) && (i.push(e.symbol), n.push(e)); break; case `TupleType`: r.ObjectKeyword || n.push(e); break; case `TypeLiteral`: e.propertySignatures.length === 0 && e.indexSignatures.length === 0 ? r[`{}`] || ((r[`{}`] = e), n.push(e)) : r.ObjectKeyword || n.push(e); break; default: n.push(e); } return n; }; var kw = class e { types; annotations; static make = (t, n) => (jw(t) ? new e(t, n) : t.length === 1 ? t[0] : iw); static unify = (t, n) => e.make(Ow(Dw(t)), n); _tag = `Union`; constructor(e, t = {}) { ((this.types = e), (this.annotations = t)); } toString() { return I(oT(this), () => this.types.map(String).join(` | `)); } toJSON() { return { _tag: this._tag, types: this.types.map((e) => e.toJSON()), annotations: K(this.annotations), }; } }; const Aw = (e, t) => e.map(t), jw = (e) => e.length > 1, Mw = $C(`Union`), Nw = g(Symbol.for(`effect/Schema/AST/toJSONMemoMap`), () => new WeakMap()); var Pw = class { f; annotations; _tag = `Suspend`; constructor(e, t = {}) { ((this.f = e), (this.annotations = t), (this.f = IS(e))); } toString() { return oT(this).pipe( dn(() => vn(hn(this.f)(), (e) => oT(e))), I(() => `<suspended schema>`), ); } toJSON() { let e = this.f(), t = Nw.get(e); return ( t || (Nw.set(e, { _tag: this._tag }), (t = { _tag: this._tag, ast: e.toJSON(), annotations: K(this.annotations) }), Nw.set(e, t), t) ); } }, Fw = class { from; filter; annotations; _tag = `Refinement`; constructor(e, t, n = {}) { ((this.from = e), (this.filter = t), (this.annotations = n)); } toString() { return zC(this).pipe( I(() => un(aT(this), { onNone: () => `{ ${this.from} | filter }`, onSome: (e) => (Iw(this.from) ? String(this.from) + ` & ` + e : e), }), ), ); } toJSON() { return { _tag: this._tag, from: this.from.toJSON(), annotations: K(this.annotations) }; } }; const Iw = $C(`Refinement`), Lw = {}; var Rw = class { from; to; transformation; annotations; _tag = `Transformation`; constructor(e, t, n, r = {}) { ((this.from = e), (this.to = t), (this.transformation = n), (this.annotations = r)); } toString() { return I(oT(this), () => `(${String(this.from)} <-> ${String(this.to)})`); } toJSON() { return { _tag: this._tag, from: this.from.toJSON(), to: this.to.toJSON(), annotations: K(this.annotations), }; } }, zw = class { decode; encode; _tag = `FinalTransformation`; constructor(e, t) { ((this.decode = e), (this.encode = t)); } }, Bw = class { from; to; decode; encode; constructor(e, t, n, r) { ((this.from = e), (this.to = t), (this.decode = n), (this.encode = r)); } }, Vw = class { propertySignatureTransformations; _tag = `TypeLiteralTransformation`; constructor(e) { this.propertySignatureTransformations = e; let t = {}, n = {}; for (let r of e) { let e = r.from; if (t[e]) throw Error(qS(e)); t[e] = !0; let i = r.to; if (n[i]) throw Error(qS(i)); n[i] = !0; } } }; const Hw = (e, t) => { let n = Object.getOwnPropertyDescriptors(e), r = { ...e.annotations }; delete r[hC]; let i = { ...r, ...t }, a = KC(e); return ( F(a) && (i[jC] = Hw(a.value, t)), (n.annotations.value = i), Object.create(Object.getPrototypeOf(e), n) ); }, Uw = (e, t) => { switch (e._tag) { case `Literal`: return Jp(String(e.literal)); case `StringKeyword`: return `[\\s\\S]*?`; case `NumberKeyword`: return `[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`; case `TemplateLiteral`: return Gw(e, t, !1); case `Union`: return e.types.map((e) => Uw(e, t)).join(`|`); } }, Ww = (e, t, n, r) => { if (Mw(e)) { if (n && !r) return `(?:${t})`; } else if (!n || !r) return t; return `(${t})`; }, Gw = (e, t, n) => { let r = ``; if (e.head !== ``) { let i = Jp(e.head); r += t && n ? `(${i})` : i; } for (let i of e.spans) { let e = Uw(i.type, t); if (((r += Ww(i.type, e, t, n)), i.literal !== ``)) { let e = Jp(i.literal); r += t && n ? `(${e})` : e; } } return r; }, Kw = (e) => RegExp(`^${Gw(e, !1, !0)}$`), qw = (e, t) => { let n = [], r = [], i = (e) => { switch (e._tag) { case `NeverKeyword`: break; case `StringKeyword`: case `SymbolKeyword`: case `TemplateLiteral`: case `Refinement`: r.push(new xw(e, t, !0)); break; case `Literal`: if (_(e.literal) || te(e.literal)) n.push(new yw(e.literal, t, !1, !0)); else throw Error(US(e.literal)); break; case `Enums`: for (let [r, i] of e.enums) n.push(new yw(i, t, !1, !0)); break; case `UniqueSymbol`: n.push(new yw(e.symbol, t, !1, !0)); break; case `Union`: e.types.forEach(i); break; default: throw Error(HS(e)); } }; return (i(e), { propertySignatures: n, indexSignatures: r }); }, Jw = (e) => { switch (e._tag) { case `TupleType`: return e.isReadonly === !1 ? e : new _w(e.elements, e.rest, !1, e.annotations); case `TypeLiteral`: { let t = Qw(e.propertySignatures, (e) => e.isReadonly === !1 ? e : new yw(e.name, e.type, e.isOptional, !1, e.annotations), ), n = Qw(e.indexSignatures, (e) => e.isReadonly === !1 ? e : new xw(e.parameter, e.type, !1), ); return t === e.propertySignatures && n === e.indexSignatures ? e : new Sw(t, n, e.annotations); } case `Union`: { let t = Qw(e.types, Jw); return t === e.types ? e : kw.make(t, e.annotations); } case `Suspend`: return new Pw(() => Jw(e.f()), e.annotations); case `Refinement`: { let t = Jw(e.from); return t === e.from ? e : new Fw(t, e.filter, e.annotations); } case `Transformation`: { let t = Jw(e.from), n = Jw(e.to); return t === e.from && n === e.to ? e : new Rw(t, n, e.transformation, e.annotations); } } return e; }, Yw = (e) => (t) => { let n; for (let r of e) Object.prototype.hasOwnProperty.call(t.annotations, r) && (n === void 0 && (n = {}), (n[r] = t.annotations[r])); return n; }, Xw = Yw([yC, bC, xC, SC, CC, wC]), Zw = (e) => { switch (e._tag) { case `Declaration`: { let t = Qw(e.typeParameters, Zw); return t === e.typeParameters ? e : new QC(t, e.decodeUnknown, e.encodeUnknown, e.annotations); } case `TupleType`: { let t = Qw(e.elements, (e) => { let t = Zw(e.type); return t === e.type ? e : new hw(t, e.isOptional); }), n = gw(e.rest), r = Qw(n, Zw); return t === e.elements && r === n ? e : new _w( t, r.map((e) => new mw(e)), e.isReadonly, e.annotations, ); } case `TypeLiteral`: { let t = Qw(e.propertySignatures, (e) => { let t = Zw(e.type); return t === e.type ? e : new yw(e.name, t, e.isOptional, e.isReadonly); }), n = Qw(e.indexSignatures, (e) => { let t = Zw(e.type); return t === e.type ? e : new xw(e.parameter, t, e.isReadonly); }); return t === e.propertySignatures && n === e.indexSignatures ? e : new Sw(t, n, e.annotations); } case `Union`: { let t = Qw(e.types, Zw); return t === e.types ? e : kw.make(t, e.annotations); } case `Suspend`: return new Pw(() => Zw(e.f()), e.annotations); case `Refinement`: { let t = Zw(e.from); return t === e.from ? e : new Fw(t, e.filter, e.annotations); } case `Transformation`: { let t = Xw(e); return Zw(t === void 0 ? e.to : Hw(e.to, t)); } } return e; }; function Qw(e, t) { let n = !1, r = En(e.length); for (let i = 0; i < e.length; i++) { let a = e[i], o = t(a); (o !== a && (n = !0), (r[i] = o)); } return n ? r : e; } const $w = (e) => { switch (e._tag) { case `Transformation`: return e.from; case `Refinement`: return $w(e.from); case `Suspend`: return $w(e.f()); } }, eT = (e, t) => { switch (e._tag) { case `Declaration`: { let n = Qw(e.typeParameters, (e) => eT(e, t)); return n === e.typeParameters ? e : new QC(n, e.decodeUnknown, e.encodeUnknown); } case `TupleType`: { let n = Qw(e.elements, (e) => { let n = eT(e.type, t); return n === e.type ? e : new hw(n, e.isOptional); }), r = gw(e.rest), i = Qw(r, (e) => eT(e, t)); return n === e.elements && i === r ? e : new _w( n, i.map((e) => new mw(e)), e.isReadonly, ); } case `TypeLiteral`: { let n = Qw(e.propertySignatures, (e) => { let n = eT(e.type, t); return n === e.type ? e : new yw(e.name, n, e.isOptional, e.isReadonly); }), r = Qw(e.indexSignatures, (e) => { let n = eT(e.type, t); return n === e.type ? e : new xw(e.parameter, n, e.isReadonly); }); return n === e.propertySignatures && r === e.indexSignatures ? e : new Sw(n, r); } case `Union`: { let n = Qw(e.types, (e) => eT(e, t)); return n === e.types ? e : kw.make(n); } case `Suspend`: { let n, r = ZC(e); if (F(r)) { let e = t ? `Bound` : ``; n = { [YC]: `${r.value}Encoded${e}` }; } return new Pw(() => eT(e.f(), t), n); } case `Refinement`: { let n = eT(e.from, t); return t ? n === e.from ? e : $w(e.from) === void 0 && JC(e) ? new Fw(n, e.filter, e.annotations) : n : n; } case `Transformation`: return eT(e.from, t); } return e; }, tT = (e) => eT(e, !1), K = (e) => { let t = {}; for (let n of Object.getOwnPropertySymbols(e)) t[String(n)] = e[n]; return t; }, nT = (e) => { switch (e._tag) { case `StringKeyword`: case `SymbolKeyword`: case `TemplateLiteral`: return e; case `Refinement`: return nT(e.from); } }, rT = (e) => I(oT(e), () => e._tag); function iT(e) { return un(PC(e), { onNone: () => ``, onSome: (e) => e.map((e) => ` & Brand<${We(e)}>`).join(``), }); } const aT = (e) => LC(e).pipe( dn(() => BC(e)), dn(() => RC(e)), _n((t) => t + iT(e)), ), oT = (e) => dn(zC(e), () => aT(e)); var sT = class { path; actual; issue; _tag = `Pointer`; constructor(e, t, n) { ((this.path = e), (this.actual = t), (this.issue = n)); } }, cT = class { actual; message; _tag = `Unexpected`; constructor(e, t) { ((this.actual = e), (this.message = t)); } }, lT = class { ast; message; _tag = `Missing`; actual = void 0; constructor(e, t) { ((this.ast = e), (this.message = t)); } }, q = class { ast; actual; issues; output; _tag = `Composite`; constructor(e, t, n, r) { ((this.ast = e), (this.actual = t), (this.issues = n), (this.output = r)); } }, uT = class { ast; actual; kind; issue; _tag = `Refinement`; constructor(e, t, n, r) { ((this.ast = e), (this.actual = t), (this.kind = n), (this.issue = r)); } }, dT = class { ast; actual; kind; issue; _tag = `Transformation`; constructor(e, t, n, r) { ((this.ast = e), (this.actual = t), (this.kind = n), (this.issue = r)); } }, J = class { ast; actual; message; _tag = `Type`; constructor(e, t, n) { ((this.ast = e), (this.actual = t), (this.message = n)); } }, fT = class { ast; actual; message; _tag = `Forbidden`; constructor(e, t, n) { ((this.ast = e), (this.actual = t), (this.message = n)); } }; const pT = Symbol.for(`effect/Schema/ParseErrorTypeId`); var mT = class extends Im(`ParseError`) { [pT] = pT; get message() { return this.toString(); } toString() { return JT.formatIssueSync(this.issue); } toJSON() { return { _id: `ParseError`, message: this.toString() }; } [E]() { return this.toJSON(); } }; const hT = (e) => new mT({ issue: e }), Y = A, gT = j, _T = Kt, vT = Gt, yT = qt, bT = t(2, (e, t) => (yT(e) ? $t(e, { onLeft: j, onRight: t }) : mS(e, t))), xT = t(2, (e, t) => (yT(e) ? Qt(e, t) : uS(e, t))), ST = t(2, (e, t) => (yT(e) ? Zt(e, t) : fS(e, t))), CT = t(2, (e, t) => (yT(e) ? Xt(e, { onLeft: t.onFailure, onRight: t.onSuccess }) : dS(e, t))), wT = t(2, (e, t) => (yT(e) ? $t(e, { onLeft: t, onRight: A }) : lS(e, t))), TT = (e, t) => (t === void 0 || te(t) ? e : e === void 0 ? t : { ...e, ...t }), ET = (e, t, n) => { let r = FT(e, t); return (e, t) => r(e, TT(n, t)); }, DT = (e, t, n) => { let r = ET(e, t, n); return (e, t) => tn(r(e, t), hT); }, OT = (e, t, n) => { let r = FT(e, t); return (e, t) => r(e, { ...TT(n, t), isEffectAllowed: !0 }); }, kT = (e, t) => ET(e.ast, !0, t), AT = (e, t) => OT(e.ast, !0, t), jT = (e, t) => OT(e.ast, !1, t), MT = (e, t) => DT(Zw(e.ast), !0, t), NT = g(Symbol.for(`effect/ParseResult/decodeMemoMap`), () => new WeakMap()), PT = g(Symbol.for(`effect/ParseResult/encodeMemoMap`), () => new WeakMap()), FT = (e, t) => { let n = t ? NT : PT, r = n.get(e); if (r) return r; let i = RT(e, t), a = WC(e), o = F(a) ? (e, t) => i(e, TT(t, a.value)) : i, s = GC(e), c = t && F(s) ? (t, n) => UT(wT(o(t, n), s.value), e, t, n) : o; return (n.set(e, c), c); }, IT = (e) => mn(VC(e)), LT = (e) => mn(HC(e)), RT = (e, t) => { switch (e._tag) { case `Refinement`: if (t) { let t = FT(e.from, !0); return (n, r) => { r ??= Lw; let i = r?.errors === `all`, a = bT( wT(t(n, r), (t) => { let a = new uT(e, n, `From`, t); return i && JC(e) && rE(t) ? un(e.filter(n, r, e), { onNone: () => j(a), onSome: (t) => j(new q(e, n, [a, new uT(e, n, `Predicate`, t)])), }) : j(a); }), (t) => un(e.filter(t, r, e), { onNone: () => A(t), onSome: (t) => j(new uT(e, n, `Predicate`, t)), }), ); return UT(a, e, n, r); }; } else { let t = FT(Zw(e), !0), n = FT(HT(e.from), !1); return (r, i) => UT( bT(t(r, i), (e) => n(e, i)), e, r, i, ); } case `Transformation`: { let n = KT(e.transformation, t), r = t ? FT(e.from, !0) : FT(e.to, !1), i = t ? FT(e.to, !0) : FT(e.from, !1); return (a, o) => UT( bT( ST(r(a, o), (n) => new dT(e, a, t ? `Encoded` : `Type`, n)), (r) => bT( ST(n(r, o ?? Lw, e, a), (t) => new dT(e, a, `Transformation`, t)), (n) => ST(i(n, o), (n) => new dT(e, a, t ? `Type` : `Encoded`, n)), ), ), e, a, o, ); } case `Declaration`: { let n = t ? e.decodeUnknown(...e.typeParameters) : e.encodeUnknown(...e.typeParameters); return (t, r) => UT(n(t, r ?? Lw, e), e, t, r); } case `Literal`: return zT(e, (t) => t === e.literal); case `UniqueSymbol`: return zT(e, (t) => t === e.symbol); case `UndefinedKeyword`: return zT(e, oe); case `NeverKeyword`: return zT(e, se); case `UnknownKeyword`: case `AnyKeyword`: case `VoidKeyword`: return A; case `StringKeyword`: return zT(e, _); case `NumberKeyword`: return zT(e, te); case `BooleanKeyword`: return zT(e, ne); case `BigIntKeyword`: return zT(e, re); case `SymbolKeyword`: return zT(e, ie); case `ObjectKeyword`: return zT(e, le); case `Enums`: return zT(e, (t) => e.enums.some(([e, n]) => n === t)); case `TemplateLiteral`: { let t = Kw(e); return zT(e, (e) => _(e) && t.test(e)); } case `TupleType`: { let n = e.elements.map((e) => FT(e.type, t)), r = e.rest.map((e) => FT(e.type, t)), i = e.elements.filter((e) => !e.isOptional); e.rest.length > 0 && (i = i.concat(e.rest.slice(1))); let a = i.length, o = e.elements.length > 0 ? e.elements.map((e, t) => t).join(` | `) : `never`, s = IT(e), c = LT(e); return (t, l) => { if (!Nn(t)) return j(new J(e, t)); let u = l?.errors === `all`, d = [], f = 0, p = [], m = t.length; for (let n = m; n <= a - 1; n++) { let r = new sT(n, t, new lT(i[n - m])); if (u) { d.push([f++, r]); continue; } else return j(new q(e, t, r, p)); } if (e.rest.length === 0) for (let n = e.elements.length; n <= m - 1; n++) { let r = new sT(n, t, new cT(t[n], `is unexpected, expected: ${o}`)); if (u) { d.push([f++, r]); continue; } else return j(new q(e, t, r, p)); } let h = 0, g; for (; h < n.length; h++) if (m < h + 1) { if (e.elements[h].isOptional) continue; } else { let r = n[h], i = r(t[h], l); if (yT(i)) { if (Jt(i)) { let n = new sT(h, t, i.left); if (u) { d.push([f++, n]); continue; } else return j(new q(e, t, n, GT(p))); } p.push([f++, i.right]); } else { let n = f++, r = h; ((g ||= []), g.push(({ es: a, output: o }) => mS(pS(i), (i) => { if (Jt(i)) { let s = new sT(r, t, i.left); return u ? (a.push([n, s]), cS) : j(new q(e, t, s, GT(o))); } return (o.push([n, i.right]), cS); }), )); } } if (R(r)) { let [n, ...i] = r; for (; h < m - i.length; h++) { let r = n(t[h], l); if (yT(r)) if (Jt(r)) { let n = new sT(h, t, r.left); if (u) { d.push([f++, n]); continue; } else return j(new q(e, t, n, GT(p))); } else p.push([f++, r.right]); else { let n = f++, i = h; ((g ||= []), g.push(({ es: a, output: o }) => mS(pS(r), (r) => { if (Jt(r)) { let s = new sT(i, t, r.left); return u ? (a.push([n, s]), cS) : j(new q(e, t, s, GT(o))); } else return (o.push([n, r.right]), cS); }), )); } } for (let n = 0; n < i.length; n++) { let r = h + n; if (!(m < r + 1)) { let a = i[n](t[r], l); if (yT(a)) { if (Jt(a)) { let n = new sT(r, t, a.left); if (u) { d.push([f++, n]); continue; } else return j(new q(e, t, n, GT(p))); } p.push([f++, a.right]); } else { let n = f++; ((g ||= []), g.push(({ es: i, output: o }) => mS(pS(a), (a) => { if (Jt(a)) { let s = new sT(r, t, a.left); return u ? (i.push([n, s]), cS) : j(new q(e, t, s, GT(o))); } return (o.push([n, a.right]), cS); }), )); } } } } let ee = ({ es: n, output: r }) => (Fn(n) ? j(new q(e, t, GT(n), GT(r))) : A(GT(r))); if (g && g.length > 0) { let e = g; return sS(() => { let t = { es: tr(d), output: tr(p) }; return mS( oS(e, (e) => e(t), { concurrency: s, batching: c, discard: !0 }), () => ee(t), ); }); } return ee({ output: p, es: d }); }; } case `TypeLiteral`: { if (e.propertySignatures.length === 0 && e.indexSignatures.length === 0) return zT(e, fe); let n = [], r = {}, i = []; for (let a of e.propertySignatures) (n.push([FT(a.type, t), a]), (r[a.name] = null), i.push(a.name)); let a = e.indexSignatures.map((e) => [FT(e.parameter, t), FT(e.type, t), e.parameter]), o = kw.make( e.indexSignatures .map((e) => e.parameter) .concat(i.map((e) => (ie(e) ? new rw(e) : new ew(e)))), ), s = FT(o, t), c = IT(e), l = LT(e); return (t, u) => { if (!ge(t)) return j(new J(e, t)); let d = u?.errors === `all`, f = [], p = 0, m = u?.onExcessProperty === `error`, h = u?.onExcessProperty === `preserve`, g = {}, ee; if (m || h) { ee = Reflect.ownKeys(t); for (let n of ee) { let r = s(n, u); if (yT(r) && Jt(r)) if (m) { let r = new sT(n, t, new cT(t[n], `is unexpected, expected: ${String(o)}`)); if (d) { f.push([p++, r]); continue; } else return j(new q(e, t, r, g)); } else g[n] = t[n]; } } let _, te = u?.exact === !0; for (let r = 0; r < n.length; r++) { let i = n[r][1], a = i.name, o = Object.prototype.hasOwnProperty.call(t, a); if (!o) { if (i.isOptional) continue; if (te) { let n = new sT(a, t, new lT(i)); if (d) { f.push([p++, n]); continue; } else return j(new q(e, t, n, g)); } } let s = n[r][0], c = s(t[a], u); if (yT(c)) { if (Jt(c)) { let n = new sT(a, t, o ? c.left : new lT(i)); if (d) { f.push([p++, n]); continue; } else return j(new q(e, t, n, g)); } g[a] = c.right; } else { let n = p++, r = a; ((_ ||= []), _.push(({ es: a, output: s }) => mS(pS(c), (c) => { if (Jt(c)) { let l = new sT(r, t, o ? c.left : new lT(i)); return d ? (a.push([n, l]), cS) : j(new q(e, t, l, s)); } return ((s[r] = c.right), cS); }), )); } } for (let n = 0; n < a.length; n++) { let i = a[n], o = i[0], s = i[1], c = FS(t, i[2]); for (let n of c) { let i = o(n, u); if (yT(i) && Yt(i)) { let i = s(t[n], u); if (yT(i)) if (Jt(i)) { let r = new sT(n, t, i.left); if (d) { f.push([p++, r]); continue; } else return j(new q(e, t, r, g)); } else Object.prototype.hasOwnProperty.call(r, n) || (g[n] = i.right); else { let a = p++, o = n; ((_ ||= []), _.push(({ es: s, output: c }) => mS(pS(i), (i) => { if (Jt(i)) { let n = new sT(o, t, i.left); return d ? (s.push([a, n]), cS) : j(new q(e, t, n, c)); } else return ( Object.prototype.hasOwnProperty.call(r, n) || (c[n] = i.right), cS ); }), )); } } } } let ne = ({ es: n, output: r }) => { if (Fn(n)) return j(new q(e, t, GT(n), r)); if (u?.propertyOrder === `original`) { let e = ee || Reflect.ownKeys(t); for (let t of i) e.indexOf(t) === -1 && e.push(t); let n = {}; for (let t of e) Object.prototype.hasOwnProperty.call(r, t) && (n[t] = r[t]); return A(n); } return A(r); }; if (_ && _.length > 0) { let e = _; return sS(() => { let t = { es: tr(f), output: Object.assign({}, g) }; return mS( oS(e, (e) => e(t), { concurrency: c, batching: l, discard: !0 }), () => ne(t), ); }); } return ne({ es: f, output: g }); }; } case `Union`: { let n = VT(e.types, t), r = Reflect.ownKeys(n.keys), i = r.length, a = e.types.length, o = new Map(); for (let n = 0; n < a; n++) o.set(e.types[n], FT(e.types[n], t)); let s = IT(e) ?? 1, c = LT(e); return (t, l) => { let u = [], d = 0, f = []; if (i > 0) if (ce(t)) for (let e = 0; e < i; e++) { let i = r[e], o = n.keys[i].buckets; if (Object.prototype.hasOwnProperty.call(t, i)) { let e = String(t[i]); if (Object.prototype.hasOwnProperty.call(o, e)) f = f.concat(o[e]); else { let { candidates: e, literals: r } = n.keys[i], o = kw.make(r), s = e.length === a ? new Sw([new yw(i, o, !1, !0)], []) : kw.make(e); u.push([d++, new q(s, t, new sT(i, t, new J(o, t[i])))]); } } else { let { candidates: e, literals: r } = n.keys[i], o = new yw(i, kw.make(r), !1, !0), s = e.length === a ? new Sw([o], []) : kw.make(e); u.push([d++, new q(s, t, new sT(i, t, new lT(o)))]); } } else { let r = n.candidates.length === a ? e : kw.make(n.candidates); u.push([d++, new J(r, t)]); } n.otherwise.length > 0 && (f = f.concat(n.otherwise)); let p; for (let e = 0; e < f.length; e++) { let n = f[e], r = o.get(n)(t, l); if (yT(r) && (!p || p.length === 0)) { if (Yt(r)) return r; u.push([d++, r.left]); } else { let e = d++; ((p ||= []), p.push((t) => sS(() => `finalResult` in t ? cS : mS( pS(r), (n) => (Yt(n) ? (t.finalResult = n) : t.es.push([e, n.left]), cS), ), ), )); } } let m = (n) => Fn(n) ? n.length === 1 && n[0][1]._tag === `Type` ? j(n[0][1]) : j(new q(e, t, GT(n))) : j(new J(e, t)); if (p && p.length > 0) { let e = p; return sS(() => { let t = { es: tr(u) }; return mS( oS(e, (e) => e(t), { concurrency: s, batching: c, discard: !0 }), () => (`finalResult` in t ? t.finalResult : m(t.es)), ); }); } return m(u); }; } case `Suspend`: { let n = IS(() => FT(e.f(), t)); return (e, t) => n()(e, t); } } }, zT = (e, t) => (n) => (t(n) ? A(n) : j(new J(e, n))), BT = (e, t) => { switch (e._tag) { case `Declaration`: { let n = KC(e); if (F(n)) return BT(n.value, t); break; } case `TypeLiteral`: { let n = []; for (let r = 0; r < e.propertySignatures.length; r++) { let i = e.propertySignatures[r], a = t ? tT(i.type) : Zw(i.type); tw(a) && !i.isOptional && n.push([i.name, a]); } return n; } case `TupleType`: { let n = []; for (let r = 0; r < e.elements.length; r++) { let i = e.elements[r], a = t ? tT(i.type) : Zw(i.type); tw(a) && !i.isOptional && n.push([r, a]); } return n; } case `Refinement`: return BT(e.from, t); case `Suspend`: return BT(e.f(), t); case `Transformation`: return BT(t ? e.from : e.to, t); } return []; }, VT = (e, t) => { let n = {}, r = [], i = []; for (let a = 0; a < e.length; a++) { let o = e[a], s = BT(o, t); if (s.length > 0) { i.push(o); for (let e = 0; e < s.length; e++) { let [t, r] = s[e], i = String(r.literal); n[t] = n[t] || { buckets: {}, literals: [], candidates: [] }; let a = n[t].buckets; if (Object.prototype.hasOwnProperty.call(a, i)) { if (e < s.length - 1) continue; (a[i].push(o), n[t].literals.push(r), n[t].candidates.push(o)); } else { ((a[i] = [o]), n[t].literals.push(r), n[t].candidates.push(o)); break; } } } else r.push(o); } return { keys: n, otherwise: r, candidates: i }; }, HT = (e) => (Iw(e) ? HT(e.from) : e), UT = (e, t, n, r) => { if (r?.isEffectAllowed === !0 || yT(e)) return e; let i = new i_(), a = hS(e, { scheduler: i }); i.flush(); let o = a.unsafePoll(); if (o) { if (g_(o)) return A(o.value); let e = o.cause; return Sp(e) ? j(e.error) : j(new fT(t, n, wp(e))); } return j( new fT( t, n, `cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work`, ), ); }, WT = ([e], [t]) => (e > t ? 1 : e < t ? -1 : 0); function GT(e) { return e.sort(WT).map((e) => e[1]); } const KT = (e, t) => { switch (e._tag) { case `FinalTransformation`: return t ? e.decode : e.encode; case `ComposeTransformation`: return A; case `TypeLiteralTransformation`: return (n) => { let r = A(n); for (let n of e.propertySignatureTransformations) { let [e, i] = t ? [n.from, n.to] : [n.to, n.from], a = t ? n.decode : n.encode; r = xT(r, (t) => { let n = a(Object.prototype.hasOwnProperty.call(t, e) ? N(t[e]) : M()); return (delete t[e], F(n) && (t[i] = n.value), t); }); } return r; }; } }, qT = (e, t = []) => ({ value: e, forest: t }), JT = { formatIssue: (e) => xT(hE(e), YT), formatIssueSync: (e) => { let t = JT.formatIssue(e); return yT(t) ? nn(t) : gS(t); }, formatError: (e) => JT.formatIssue(e.issue), formatErrorSync: (e) => JT.formatIssueSync(e.issue), }, YT = (e) => e.value + XT( ` `, e.forest, ), XT = (e, t) => { let n = ``, r = t.length, i; for (let a = 0; a < r; a++) { i = t[a]; let o = a === r - 1; ((n += e + (o ? `└` : `├`) + `─ ` + i.value), (n += XT(e + (r > 1 && !o ? `│ ` : ` `), i.forest))); } return n; }, ZT = (e) => { switch (e) { case `Encoded`: return `Encoded side transformation failure`; case `Transformation`: return `Transformation process failure`; case `Type`: return `Type side transformation failure`; } }, QT = (e) => { switch (e) { case `From`: return `From side refinement failure`; case `Predicate`: return `Predicate refinement failure`; } }, $T = (e) => (`ast` in e ? N(e.ast) : M()), eE = A(void 0), tE = (e) => $T(e).pipe( vn(FC), un({ onNone: () => eE, onSome: (t) => { let n = t(e); return _(n) ? A({ message: n, override: !1 }) : aS(n) ? uS(n, (e) => ({ message: e, override: !1 })) : _(n.message) ? A({ message: n.message, override: n.override }) : uS(n.message, (e) => ({ message: e, override: n.override })); }, }), ), nE = (e) => (t) => t._tag === e, rE = nE(`Composite`), iE = nE(`Refinement`), aE = nE(`Transformation`), oE = (e) => bT(tE(e), (t) => t === void 0 ? eE : !t.override && (rE(e) || (iE(e) && e.kind === `From`) || (aE(e) && e.kind !== `Transformation`)) ? aE(e) || iE(e) ? oE(e.issue) : eE : A(t.message), ), sE = (e) => $T(e).pipe( vn(UC), yn((t) => t(e)), mn, ); function cE(e) { return BC(e).pipe( dn(() => LC(e)), dn(() => RC(e)), dn(() => zC(e)), I(() => `{ ${e.from} | filter }`), ); } function lE(e) { return e.message === void 0 ? `Expected ${Iw(e.ast) ? cE(e.ast) : String(e.ast)}, actual ${We(e.actual)}` : e.message; } const uE = (e) => xT(oE(e), (t) => t ?? sE(e) ?? lE(e)), dE = (e) => sE(e) ?? String(e.ast), fE = (e) => e.message ?? `is forbidden`, pE = (e) => e.message ?? `is unexpected`, mE = (e) => { let t = IC(e.ast); if (F(t)) { let e = t.value(); return _(e) ? A(e) : e; } return A(e.message ?? `is missing`); }, hE = (e) => { switch (e._tag) { case `Type`: return xT(uE(e), qT); case `Forbidden`: return A(qT(dE(e), [qT(fE(e))])); case `Unexpected`: return A(qT(pE(e))); case `Missing`: return xT(mE(e), qT); case `Transformation`: return bT(oE(e), (t) => t === void 0 ? xT(hE(e.issue), (t) => qT(dE(e), [qT(ZT(e.kind), [t])])) : A(qT(t)), ); case `Refinement`: return bT(oE(e), (t) => t === void 0 ? xT(hE(e.issue), (t) => qT(dE(e), [qT(QT(e.kind), [t])])) : A(qT(t)), ); case `Pointer`: return xT(hE(e.issue), (t) => qT(BS(e.path), [t])); case `Composite`: return bT(oE(e), (t) => { if (t !== void 0) return A(qT(t)); let n = dE(e); return LS(e.issues) ? xT(oS(e.issues, hE), (e) => qT(n, e)) : xT(hE(e.issues), (e) => qT(n, [e])); }); } }, gE = t( (e) => le(e[0]), (e, ...t) => { let n = {}; for (let r of t) r in e && (n[r] = e[r]); return n; }, ), _E = t( (e) => le(e[0]), (e, ...t) => { let n = { ...e }; for (let e of t) delete n[e]; return n; }, ), vE = Symbol.for(`effect/Schema`); function X(e) { return class { [vE] = yE; static ast = e; static annotations(e) { return X(SE(this.ast, e)); } static pipe() { return k(this, arguments); } static toString() { return String(e); } static Type; static Encoded; static Context; static [vE] = yE; }; } const yE = { _A: (e) => e, _I: (e) => e, _R: (e) => e }, bE = { typeConstructor: uC, schemaId: fC, message: pC, missingMessage: mC, identifier: hC, title: gC, description: vC, examples: yC, default: bC, documentation: TC, jsonSchema: xC, arbitrary: SC, pretty: CC, equivalence: wC, concurrency: EC, batching: DC, parseIssueTitle: OC, parseOptions: kC, decodingFallback: AC, }, xE = (e) => { if (!e) return {}; let t = { ...e }; for (let n in bE) if (n in e) { let r = bE[n]; ((t[r] = e[n]), delete t[n]); } return t; }, SE = (e, t) => Hw(e, xE(t)), CE = (e) => String(e.ast), wE = (e, t) => { let n = kT(e, t); return (e, t) => Zt(n(e, t), hT); }, TE = (e) => v(e, vE) && le(e[vE]); function EE(e) { return jw(e) ? kw.make(Aw(e, (e) => new ew(e))) : new ew(e[0]); } function DE(e, t = EE(e)) { return class extends X(t) { static annotations(e) { return DE(this.literals, SE(this.ast, e)); } static literals = [...e]; }; } function OE(...e) { return R(e) ? DE(e) : IE; } const kE = (e, t, n) => jE( e, new QC( e.map((e) => e.ast), (...e) => t.decode(...e.map(X)), (...e) => t.encode(...e.map(X)), xE(n), ), ), AE = (e, t) => { let n = () => (t, n, r) => (e(t) ? Y(t) : gT(new J(r, t))); return jE([], new QC([], n, n, xE(t))); }; function jE(e, t) { return class extends X(t) { static annotations(e) { return jE(this.typeParameters, SE(this.ast, e)); } static typeParameters = [...e]; }; } const ME = function () { if (Array.isArray(arguments[0])) { let e = arguments[0], t = arguments[1], n = arguments[2]; return kE(e, t, n); } let e = arguments[0], t = arguments[1]; return AE(e, t); }, NE = Symbol.for(`effect/SchemaId/InstanceOf`), PE = (e, t) => ME((t) => t instanceof e, { title: e.name, description: `an instance of ${e.name}`, pretty: () => String, schemaId: NE, [NE]: { constructor: e }, ...t, }); var FE = class extends X(nw) {}, IE = class extends X(iw) {}, LE = class extends X(aw) {}, RE = class extends X(dw) {}, zE = class extends X(fw) {}, Z = class extends X(sw) {}, Q = class extends X(lw) {}, BE = class extends X(uw) {}; const VE = (e) => kw.make(e.map((e) => e.ast)); function HE(e, t = VE(e)) { return class extends X(t) { static annotations(e) { return HE(this.members, SE(this.ast, e)); } static members = [...e]; }; } function UE(...e) { return jw(e) ? HE(e) : R(e) ? e[0] : IE; } const WE = (e) => UE(e, FE), GE = (e) => new KE(new hw(e.ast, !1), e); var KE = class e { ast; from; [vE]; _Token; constructor(e, t) { ((this.ast = e), (this.from = t)); } annotations(t) { return new e( new hw(this.ast.type, this.ast.isOptional, { ...this.ast.annotations, ...xE(t) }), this.from, ); } toString() { return `${this.ast.type}${this.ast.isOptional ? `?` : ``}`; } }; const qE = (e, t) => new _w( e.map((e) => (TE(e) ? new hw(e.ast, !1) : e.ast)), t.map((e) => (TE(e) ? new mw(e.ast) : e.ast)), !0, ); function JE(e, t, n = qE(e, t)) { return class extends X(n) { static annotations(e) { return JE(this.elements, this.rest, SE(this.ast, e)); } static elements = [...e]; static rest = [...t]; }; } function YE(...e) { return Array.isArray(e[0]) ? JE(e[0], e.slice(1)) : JE(e, []); } function XE(e, t) { return class extends JE([], [e], t) { static annotations(e) { return XE(this.value, SE(this.ast, e)); } static value = e; }; } const ZE = (e) => XE(e), QE = (e) => (e ? `"?:"` : `":"`); var $E = class extends hw { isReadonly; defaultValue; _tag = `PropertySignatureDeclaration`; constructor(e, t, n, r, i) { (super(e, t, r), (this.isReadonly = n), (this.defaultValue = i)); } toString() { let e = QE(this.isOptional), t = String(this.type); return `PropertySignature<${e}, ${t}, never, ${e}, ${t}>`; } }; (class extends hw { isReadonly; fromKey; constructor(e, t, n, r, i) { (super(e, t, r), (this.isReadonly = n), (this.fromKey = i)); } }); var eD = class extends hw { isReadonly; defaultValue; constructor(e, t, n, r, i) { (super(e, t, r), (this.isReadonly = n), (this.defaultValue = i)); } }; const tD = (e) => (e === void 0 ? `never` : _(e) ? JSON.stringify(e) : String(e)); var nD = class { from; to; decode; encode; _tag = `PropertySignatureTransformation`; constructor(e, t, n, r) { ((this.from = e), (this.to = t), (this.decode = n), (this.encode = r)); } toString() { return `PropertySignature<${QE(this.to.isOptional)}, ${this.to.type}, ${tD(this.from.fromKey)}, ${QE(this.from.isOptional)}, ${this.from.type}>`; } }; const rD = (e, t) => { switch (e._tag) { case `PropertySignatureDeclaration`: return new $E( e.type, e.isOptional, e.isReadonly, { ...e.annotations, ...t }, e.defaultValue, ); case `PropertySignatureTransformation`: return new nD( e.from, new eD( e.to.type, e.to.isOptional, e.to.isReadonly, { ...e.to.annotations, ...t }, e.to.defaultValue, ), e.decode, e.encode, ); } }, iD = Symbol.for(`effect/PropertySignature`), aD = (e) => v(e, iD); var oD = class e { ast; [vE]; [iD] = null; _TypeToken; _Key; _EncodedToken; _HasDefault; constructor(e) { this.ast = e; } pipe() { return k(this, arguments); } annotations(t) { return new e(rD(this.ast, xE(t))); } toString() { return String(this.ast); } }; const sD = (e) => new oD(e); var cD = class e extends oD { from; constructor(e, t) { (super(e), (this.from = t)); } annotations(t) { return new e(rD(this.ast, xE(t)), this.from); } }; const lD = (e) => new cD(new $E(e.ast, !1, !0, {}, void 0), e), uD = t(2, (e, t) => { let n = e.ast; switch (n._tag) { case `PropertySignatureDeclaration`: return sD(new $E(n.type, n.isOptional, n.isReadonly, n.annotations, t)); case `PropertySignatureTransformation`: return sD( new nD( n.from, new eD(n.to.type, n.to.isOptional, n.to.isReadonly, n.to.annotations, t), n.decode, n.encode, ), ); } }), dD = Yw([mC]), fD = (e, t) => { let n = Reflect.ownKeys(e), r = []; if (n.length > 0) { let i = [], a = [], o = []; for (let t = 0; t < n.length; t++) { let s = n[t], c = e[s]; if (aD(c)) { let e = c.ast; switch (e._tag) { case `PropertySignatureDeclaration`: { let t = e.type, n = e.isOptional, o = e.annotations; (i.push(new yw(s, t, n, !0, dD(e))), a.push(new yw(s, Zw(t), n, !0, o)), r.push(new yw(s, t, n, !0, o))); break; } case `PropertySignatureTransformation`: { let t = e.from.fromKey ?? s; (i.push(new yw(t, e.from.type, e.from.isOptional, !0, e.from.annotations)), a.push(new yw(s, e.to.type, e.to.isOptional, !0, e.to.annotations)), o.push(new Bw(t, s, e.decode, e.encode))); break; } } } else (i.push(new yw(s, c.ast, !1, !0)), a.push(new yw(s, Zw(c.ast), !1, !0)), r.push(new yw(s, c.ast, !1, !0))); } if (R(o)) { let e = [], n = []; for (let r of t) { let { indexSignatures: t, propertySignatures: o } = qw(r.key.ast, r.value.ast); (o.forEach((e) => { (i.push(e), a.push(new yw(e.name, Zw(e.type), e.isOptional, e.isReadonly, e.annotations))); }), t.forEach((t) => { (e.push(t), n.push(new xw(t.parameter, Zw(t.type), t.isReadonly))); })); } return new Rw( new Sw(i, e, { [_C]: `Struct (Encoded side)` }), new Sw(a, n, { [_C]: `Struct (Type side)` }), new Vw(o), ); } } let i = []; for (let e of t) { let { indexSignatures: t, propertySignatures: n } = qw(e.key.ast, e.value.ast); (n.forEach((e) => r.push(e)), t.forEach((e) => i.push(e))); } return new Sw(r, i); }, pD = (e, t) => { let n = Reflect.ownKeys(e); for (let r of n) { let n = e[r]; if (t[r] === void 0 && aD(n)) { let e = n.ast, i = e._tag === `PropertySignatureDeclaration` ? e.defaultValue : e.to.defaultValue; i !== void 0 && (t[r] = i()); } } return t; }; function mD(e, t, n = fD(e, t)) { return class extends X(n) { static annotations(e) { return mD(this.fields, this.records, SE(this.ast, e)); } static fields = { ...e }; static records = [...t]; static make = (t, n) => { let r = pD(e, { ...t }); return mk(n) ? r : MT(this)(r); }; static pick(...t) { return hD(gE(e, ...t)); } static omit(...t) { return hD(_E(e, ...t)); } }; } function hD(e, ...t) { return mD(e, t); } const gD = (e) => OE(e).pipe( lD, uD(() => e), ), _D = (e, t) => hD({ _tag: gD(e), ...t }), vD = (e) => X(Jw(e.ast)), yD = (e) => X(new Pw(() => e().ast)), bD = Symbol.for(`effect/SchemaId/Refine`); function xD(e, t, n) { return class extends X(n) { static annotations(e) { return xD(this.from, this.filter, SE(this.ast, e)); } static [bD] = e; static from = e; static filter = t; static make = (e, t) => (mk(t) ? e : MT(this)(e)); }; } const SD = (e, t, n) => { if (ne(e)) return e ? M() : N(new J(t, n)); if (_(e)) return N(new J(t, n, e)); if (e !== void 0) { if (`_tag` in e) return N(e); let r = new J(t, n, e.message); return N(R(e.path) ? new sT(e.path, n, r) : r); } return M(); }, CD = (e, t, n) => { if (RS(e)) return SD(e, t, n); if (R(e)) { let r = lr(e, (e) => SD(e, t, n)); if (R(r)) return N(r.length === 1 ? r[0] : new q(t, n, r)); } return M(); }; function $(e, t) { return (n) => { function r(t, n, r) { return CD(e(t, n, r), r, t); } return xD(n, r, new Fw(n.ast, r, xE(t))); }; } function wD(e, t, n) { return class extends X(n) { static annotations(e) { return wD(this.from, this.to, SE(this.ast, e)); } static from = e; static to = t; }; } const TD = t( (e) => TE(e[0]) && TE(e[1]), (e, t, n) => wD(e, t, new Rw(e.ast, t.ast, new zw(n.decode, n.encode))), ), ED = t( (e) => TE(e[0]) && TE(e[1]), (e, t, n) => TD(e, t, { strict: !0, decode: (e, t, r, i) => Y(n.decode(e, i)), encode: (e, t, r, i) => Y(n.encode(e, i)), }), ), DD = Symbol.for(`effect/SchemaId/Trimmed`), OD = (e) => (t) => t.pipe( $((e) => e === e.trim(), { schemaId: DD, title: `trimmed`, description: `a string with no leading or trailing whitespace`, jsonSchema: { pattern: `^\\S[\\s\\S]*\\S$|^\\S$|^$` }, ...e, }), ), kD = cC, AD = (e, t) => (n) => n.pipe( $((t) => t.length <= e, { schemaId: kD, title: `maxLength(${e})`, description: `a string at most ${e} character(s) long`, jsonSchema: { maxLength: e }, ...t, }), ), jD = sC, MD = (e, t) => (n) => n.pipe( $((t) => t.length >= e, { schemaId: jD, title: `minLength(${e})`, description: `a string at least ${e} character(s) long`, jsonSchema: { minLength: e }, ...t, }), ), ND = lC, PD = (e, t) => (n) => { let r = le(e) ? Math.max(0, Math.floor(e.min)) : Math.max(0, Math.floor(e)), i = le(e) ? Math.max(r, Math.floor(e.max)) : r; return r === i ? n.pipe( $((e) => e.length === r, { schemaId: ND, title: `length(${r})`, description: r === 1 ? `a single character` : `a string ${r} character(s) long`, jsonSchema: { minLength: r, maxLength: r }, ...t, }), ) : n.pipe( $((e) => e.length >= r && e.length <= i, { schemaId: ND, title: `length({ min: ${r}, max: ${i})`, description: `a string at least ${r} character(s) and at most ${i} character(s) long`, jsonSchema: { minLength: r, maxLength: i }, ...t, }), ); }, FD = Symbol.for(`effect/SchemaId/Pattern`), ID = (e, t) => (n) => { let r = e.source; return n.pipe( $((t) => ((e.lastIndex = 0), e.test(t)), { schemaId: FD, [FD]: { regex: e }, description: `a string matching the pattern ${r}`, jsonSchema: { pattern: r }, ...t, }), ); }, LD = Symbol.for(`effect/SchemaId/Lowercased`), RD = (e) => (t) => t.pipe( $((e) => e === e.toLowerCase(), { schemaId: LD, title: `lowercased`, description: `a lowercase string`, jsonSchema: { pattern: `^[^A-Z]*$` }, ...e, }), ); var zD = class extends Z.pipe(RD({ identifier: `Lowercased` })) {}; const BD = Symbol.for(`effect/SchemaId/Uppercased`), VD = (e) => (t) => t.pipe( $((e) => e === e.toUpperCase(), { schemaId: BD, title: `uppercased`, description: `an uppercase string`, jsonSchema: { pattern: `^[^a-z]*$` }, ...e, }), ); var HD = class extends Z.pipe(VD({ identifier: `Uppercased` })) {}; const UD = Symbol.for(`effect/SchemaId/Capitalized`), WD = (e) => (t) => t.pipe( $((e) => e[0]?.toUpperCase() === e[0], { schemaId: UD, title: `capitalized`, description: `a capitalized string`, jsonSchema: { pattern: `^[^a-z]?.*$` }, ...e, }), ); var GD = class extends Z.pipe(WD({ identifier: `Capitalized` })) {}; const KD = Symbol.for(`effect/SchemaId/Uncapitalized`), qD = (e) => (t) => t.pipe( $((e) => e[0]?.toLowerCase() === e[0], { schemaId: KD, title: `uncapitalized`, description: `a uncapitalized string`, jsonSchema: { pattern: `^[^A-Z]?.*$` }, ...e, }), ); var JD = class extends Z.pipe(qD({ identifier: `Uncapitalized` })) {}; Z.pipe(PD(1, { identifier: `Char` })); const YD = (e) => MD(1, { title: `nonEmptyString`, description: `a non empty string`, ...e }); (ED(Z.annotations({ description: `a string that will be converted to lowercase` }), zD, { strict: !0, decode: (e) => e.toLowerCase(), encode: n, }).annotations({ identifier: `Lowercase` }), ED(Z.annotations({ description: `a string that will be converted to uppercase` }), HD, { strict: !0, decode: (e) => e.toUpperCase(), encode: n, }).annotations({ identifier: `Uppercase` }), ED( Z.annotations({ description: `a string that will be converted to a capitalized format` }), GD, { strict: !0, decode: (e) => nS(e), encode: n }, ).annotations({ identifier: `Capitalize` }), ED( Z.annotations({ description: `a string that will be converted to an uncapitalized format` }), JD, { strict: !0, decode: (e) => rS(e), encode: n }, ).annotations({ identifier: `Uncapitalize` })); var XD = class extends Z.pipe(OD({ identifier: `Trimmed` })) {}, ZD = class extends XD.pipe(YD({ identifier: `NonEmptyTrimmedString` })) {}; ED(Z.annotations({ description: `a string that will be trimmed` }), XD, { strict: !0, decode: (e) => e.trim(), encode: n, }).annotations({ identifier: `Trim` }); const QD = (e) => (e instanceof Error ? e.message : String(e)); Z.pipe(YD({ identifier: `NonEmptyString` })); const $D = Symbol.for(`effect/SchemaId/UUID`), eO = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i; Z.pipe( ID(eO, { schemaId: $D, identifier: `UUID`, jsonSchema: { format: `uuid`, pattern: eO.source }, description: `a Universally Unique Identifier`, arbitrary: () => (e) => e.uuid(), }), ); const tO = Symbol.for(`effect/SchemaId/ULID`); Z.pipe( ID(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i, { schemaId: tO, identifier: `ULID`, description: `a Universally Unique Lexicographically Sortable Identifier`, arbitrary: () => (e) => e.ulid(), }), ); var nO = class extends PE(URL, { typeConstructor: { _tag: `URL` }, identifier: `URLFromSelf`, arbitrary: () => (e) => e.webUrl().map((e) => new URL(e)), pretty: () => (e) => e.toString(), }) {}; TD(Z.annotations({ description: `a string to be decoded into a URL` }), nO, { strict: !0, decode: (e, t, n) => _T({ try: () => new URL(e), catch: (t) => new J(n, e, `Unable to decode ${JSON.stringify(e)} into a URL. ${QD(t)}`), }), encode: (e) => Y(e.toString()), }).annotations({ identifier: `URL`, pretty: () => (e) => e.toString() }); const rO = nC, iO = (e) => (t) => t.pipe( $(Number.isFinite, { schemaId: rO, title: `finite`, description: `a finite number`, jsonSchema: {}, ...e, }), ), aO = XS, oO = (e, t) => (n) => n.pipe( $((t) => t > e, { schemaId: aO, title: `greaterThan(${e})`, description: e === 0 ? `a positive number` : `a number greater than ${e}`, jsonSchema: { exclusiveMinimum: e }, ...t, }), ), sO = ZS, cO = (e, t) => (n) => n.pipe( $((t) => t >= e, { schemaId: sO, title: `greaterThanOrEqualTo(${e})`, description: e === 0 ? `a non-negative number` : `a number greater than or equal to ${e}`, jsonSchema: { minimum: e }, ...t, }), ), lO = eC, uO = (e) => (t) => t.pipe( $((e) => Number.isSafeInteger(e), { schemaId: lO, title: `int`, description: `an integer`, jsonSchema: { type: `integer` }, ...e, }), ), dO = QS, fO = (e, t) => (n) => n.pipe( $((t) => t < e, { schemaId: dO, title: `lessThan(${e})`, description: e === 0 ? `a negative number` : `a number less than ${e}`, jsonSchema: { exclusiveMaximum: e }, ...t, }), ), pO = $S, mO = (e, t) => (n) => n.pipe( $((t) => t <= e, { schemaId: pO, title: `lessThanOrEqualTo(${e})`, description: e === 0 ? `a non-positive number` : `a number less than or equal to ${e}`, jsonSchema: { maximum: e }, ...t, }), ), hO = iC, gO = (e, t, n) => (r) => r.pipe( $((n) => n >= e && n <= t, { schemaId: hO, title: `between(${e}, ${t})`, description: `a number between ${e} and ${t}`, jsonSchema: { minimum: e, maximum: t }, ...n, }), ), _O = tC, vO = (e) => (t) => t.pipe( $((e) => !Number.isNaN(e), { schemaId: _O, title: `nonNaN`, description: `a number excluding NaN`, ...e, }), ), yO = (e) => oO(0, { title: `positive`, ...e }), bO = (e) => fO(0, { title: `negative`, ...e }), xO = (e) => mO(0, { title: `nonPositive`, ...e }), SO = (e) => cO(0, { title: `nonNegative`, ...e }); function CO(e) { return TD(e, Q, { strict: !1, decode: (e, t, n) => vT(qp(e), () => new J(n, e, `Unable to decode ${JSON.stringify(e)} into a number`)), encode: (e) => Y(String(e)), }); } (CO(Z.annotations({ description: `a string to be decoded into a number` })).annotations({ identifier: `NumberFromString`, }), Q.pipe(iO({ identifier: `Finite` }))); var wO = class extends Q.pipe(uO({ identifier: `Int` })) {}; (Q.pipe(vO({ identifier: `NonNaN` })), Q.pipe(yO({ identifier: `Positive` })), Q.pipe(bO({ identifier: `Negative` })), Q.pipe(xO({ identifier: `NonPositive` }))); var TO = class extends Q.pipe(SO({ identifier: `NonNegative` })) {}; const EO = rC; (Q.pipe(iO({ schemaId: EO, identifier: `JsonNumber` })), ED(BE.annotations({ description: `a boolean that will be negated` }), BE, { strict: !0, decode: (e) => Vr(e), encode: (e) => Vr(e), })); const DO = (e, t) => { let n = Symbol.keyFor(e); return n === void 0 ? gT(new J(t, e, `Unable to encode a unique symbol ${String(e)} into a string`)) : Y(n); }, OO = (e) => Y(Symbol.for(e)); TD(Z.annotations({ description: `a string to be decoded into a globally shared symbol` }), zE, { strict: !1, decode: (e) => OO(e), encode: (e, t, n) => DO(e, n), }).annotations({ identifier: `Symbol` }); const kO = aC, AO = (e, t) => (n) => n.pipe( $((t) => t >= e, { schemaId: kO, [kO]: { min: e }, title: `greaterThanOrEqualToBigInt(${e})`, description: e === 0n ? `a non-negative bigint` : `a bigint greater than or equal to ${e}n`, ...t, }), ), jO = oC, MO = (e, t, n) => (r) => r.pipe( $((n) => n >= e && n <= t, { schemaId: jO, [jO]: { min: e, max: t }, title: `betweenBigInt(${e}, ${t})`, description: `a bigint between ${e}n and ${t}n`, ...n, }), ), NO = (e) => AO(0n, { title: `nonNegativeBigInt`, ...e }); var PO = class extends TD( Z.annotations({ description: `a string to be decoded into a bigint` }), RE, { strict: !0, decode: (e, t, n) => vT(zr(e), () => new J(n, e, `Unable to decode ${JSON.stringify(e)} into a bigint`)), encode: (e) => Y(String(e)), }, ).annotations({ identifier: `BigInt` }) {}; const FO = RE.pipe(NO({ identifier: `NonNegativeBigintFromSelf` })); TD( Q.annotations({ description: `a number to be decoded into a bigint` }), RE.pipe(MO(BigInt(-(2 ** 53 - 1)), BigInt(2 ** 53 - 1))), { strict: !0, decode: (e, t, n) => vT(Br(e), () => new J(n, e, `Unable to decode ${e} into a bigint`)), encode: (e, t, n) => vT(Rr(e), () => new J(n, e, `Unable to encode ${e}n into a number`)), }, ).annotations({ identifier: `BigIntFromNumber` }); const IO = (e, t, n, r) => CT(e, { onFailure: (e) => new q(n, r, e), onSuccess: t }); var LO = class extends ME(Os, { typeConstructor: { _tag: `effect/Duration` }, identifier: `DurationFromSelf`, pretty: () => String, arbitrary: () => (e) => e.oneof( e.constant(Ms), e.bigInt({ min: 0n }).map((e) => Ns(e)), e.maxSafeNat().map((e) => Fs(e)), ), equivalence: () => qs, }) {}; TD( FO.annotations({ description: `a bigint to be decoded into a Duration` }), LO.pipe($((e) => ks(e), { description: `a finite duration` })), { strict: !0, decode: (e) => Y(Ns(e)), encode: (e, t, n) => un(Hs(e), { onNone: () => gT(new J(n, e, `Unable to encode ${e} into a bigint`)), onSome: (e) => Y(e), }), }, ).annotations({ identifier: `DurationFromNanos` }); const RO = TO.pipe(uO()).annotations({ identifier: `NonNegativeInt` }); ED(TO.annotations({ description: `a non-negative number to be decoded into a Duration` }), LO, { strict: !0, decode: (e) => Fs(e), encode: (e) => Vs(e), }).annotations({ identifier: `DurationFromMillis` }); const zO = _D(`Millis`, { millis: RO }), BO = _D(`Nanos`, { nanos: PO }), VO = _D(`Infinity`, {}), HO = VO.make({}), UO = UE(zO, BO, VO).annotations({ identifier: `DurationValue`, description: `an JSON-compatible tagged union to be decoded into a Duration`, }), WO = UE( YE( GE(RO).annotations({ title: `seconds` }), GE(RO).annotations({ title: `nanos` }), ).annotations({ identifier: `FiniteHRTime` }), YE(OE(-1), OE(0)).annotations({ identifier: `InfiniteHRTime` }), ).annotations({ identifier: `HRTime`, description: `a tuple of seconds and nanos to be decoded into a Duration`, }), GO = (e) => typeof e == `object`; ED(UE(UO, WO), LO, { strict: !0, decode: (e) => { if (GO(e)) switch (e._tag) { case `Millis`: return Fs(e.millis); case `Nanos`: return Ns(e.nanos); case `Infinity`: return Ms; } let [t, n] = e; return t === -1 ? Ms : Ns(BigInt(t) * BigInt(1e9) + BigInt(n)); }, encode: (e) => { switch (e.value._tag) { case `Millis`: return zO.make({ millis: e.value.millis }); case `Nanos`: return BO.make({ nanos: e.value.nanos }); case `Infinity`: return HO; } }, }).annotations({ identifier: `Duration` }); var KO = class extends ME(pe, { typeConstructor: { _tag: `Uint8Array` }, identifier: `Uint8ArrayFromSelf`, pretty: () => (e) => `new Uint8Array(${JSON.stringify(Array.from(e))})`, arbitrary: () => (e) => e.uint8Array(), equivalence: () => fr(T), }) {}; ED( ZE( class extends Q.pipe( gO(0, 255, { identifier: `Uint8`, description: `a 8-bit unsigned integer` }), ) {}, ).annotations({ description: `an array of 8-bit unsigned integers to be decoded into a Uint8Array`, }), KO, { strict: !0, decode: (e) => Uint8Array.from(e), encode: (e) => Array.from(e) }, ).annotations({ identifier: `Uint8Array` }); const qO = Symbol.for(`effect/SchemaId/ValidDate`), JO = (e) => (t) => t.pipe( $((e) => !Number.isNaN(e.getTime()), { schemaId: qO, [qO]: { noInvalidDate: !0 }, title: `validDate`, description: `a valid Date`, ...e, }), ), YO = YS; var XO = class extends ME(me, { typeConstructor: { _tag: `Date` }, identifier: `DateFromSelf`, schemaId: YO, [YO]: { noInvalidDate: !1 }, description: `a potentially invalid Date instance`, pretty: () => (e) => `new Date(${JSON.stringify(e)})`, arbitrary: () => (e) => e.date({ noInvalidDate: !1 }), equivalence: () => f, }) {}; (XO.pipe(JO({ identifier: `ValidDateFromSelf`, description: `a valid Date instance` })), class extends ED(Z.annotations({ description: `a string to be decoded into a Date` }), XO, { strict: !0, decode: (e) => new Date(e), encode: (e) => Ve(e), }).annotations({ identifier: `DateFromString` }) {}.pipe(JO({ identifier: `Date` })), ED(Q.annotations({ description: `a number to be decoded into a Date` }), XO, { strict: !0, decode: (e) => new Date(e), encode: (e) => e.getTime(), }).annotations({ identifier: `DateFromNumber` })); var ZO = class extends ME((e) => _S(e) && bS(e), { typeConstructor: { _tag: `effect/DateTime.Utc` }, identifier: `DateTimeUtcFromSelf`, description: `a DateTime.Utc instance`, pretty: () => (e) => e.toString(), arbitrary: () => (e) => e.date({ noInvalidDate: !0 }).map((e) => CS(e)), equivalence: () => SS, }) {}; const QO = (e, t) => _T({ try: () => wS(e), catch: () => new J(t, e, `Unable to decode ${We(e)} into a DateTime.Utc`), }); (TD(Q.annotations({ description: `a number to be decoded into a DateTime.Utc` }), ZO, { strict: !0, decode: (e, t, n) => QO(e, n), encode: (e) => Y(MS(e)), }).annotations({ identifier: `DateTimeUtcFromNumber` }), TD(XO.annotations({ description: `a Date to be decoded into a DateTime.Utc` }), ZO, { strict: !0, decode: (e, t, n) => QO(e, n), encode: (e) => Y(jS(e)), }).annotations({ identifier: `DateTimeUtcFromDate` }), TD(Z.annotations({ description: `a string to be decoded into a DateTime.Utc` }), ZO, { strict: !0, decode: (e, t, n) => QO(e, n), encode: (e) => Y(NS(e)), }).annotations({ identifier: `DateTimeUtc` })); const $O = () => (e) => e.integer({ min: -720 * 60 * 1e3, max: 840 * 60 * 1e3 }).map(OS); var ek = class extends ME(vS, { typeConstructor: { _tag: `effect/DateTime.TimeZone.Offset` }, identifier: `TimeZoneOffsetFromSelf`, description: `a TimeZone.Offset instance`, pretty: () => (e) => e.toString(), arbitrary: $O, }) {}; ED(Q.annotations({ description: `a number to be decoded into a TimeZone.Offset` }), ek, { strict: !0, decode: (e) => OS(e), encode: (e) => e.offset, }).annotations({ identifier: `TimeZoneOffset` }); const tk = () => (e) => e.constantFrom(...Intl.supportedValuesOf(`timeZone`)).map(DS); var nk = class extends ME(yS, { typeConstructor: { _tag: `effect/DateTime.TimeZone.Named` }, identifier: `TimeZoneNamedFromSelf`, description: `a TimeZone.Named instance`, pretty: () => (e) => e.toString(), arbitrary: tk, }) {}; TD(Z.annotations({ description: `a string to be decoded into a TimeZone.Named` }), nk, { strict: !0, decode: (e, t, n) => _T({ try: () => DS(e), catch: () => new J(n, e, `Unable to decode ${JSON.stringify(e)} into a TimeZone.Named`), }), encode: (e) => Y(e.id), }).annotations({ identifier: `TimeZoneNamed` }); var rk = class extends UE(ek, nk) {}; TD(Z.annotations({ description: `a string to be decoded into a TimeZone` }), rk, { strict: !0, decode: (e, t, n) => un(kS(e), { onNone: () => gT(new J(n, e, `Unable to decode ${JSON.stringify(e)} into a TimeZone`)), onSome: Y, }), encode: (e) => Y(AS(e)), }).annotations({ identifier: `TimeZone` }); const ik = (e) => e.oneof($O()(e), tk()(e)); var ak = class extends ME((e) => _S(e) && xS(e), { typeConstructor: { _tag: `effect/DateTime.Zoned` }, identifier: `DateTimeZonedFromSelf`, description: `a DateTime.Zoned instance`, pretty: () => (e) => e.toString(), arbitrary: () => (e) => e .tuple(e.integer({ min: -31536e9, max: 31536e9 }), ik(e)) .map(([e, t]) => TS(e, { timeZone: t })), equivalence: () => SS, }) {}; TD(Z.annotations({ description: `a string to be decoded into a DateTime.Zoned` }), ak, { strict: !0, decode: (e, t, n) => un(ES(e), { onNone: () => gT(new J(n, e, `Unable to decode ${JSON.stringify(e)} into a DateTime.Zoned`)), onSome: Y, }), encode: (e) => Y(PS(e)), }).annotations({ identifier: `DateTimeZoned` }); const ok = (e) => (e._tag === `None` ? M() : N(e.value)), sk = (e, t) => (n) => n .oneof( t, n.record({ _tag: n.constant(`None`) }), n.record({ _tag: n.constant(`Some`), value: e(n) }), ) .map(ok), ck = (e) => un({ onNone: () => `none()`, onSome: (t) => `some(${e(t)})` }), lk = (e) => (t, n, r) => (ln(t) ? (P(t) ? Y(M()) : IO(e(t.value, n), N, r, t)) : gT(new J(r, t))), uk = (e) => ME( [e], { decode: (e) => lk(AT(e)), encode: (e) => lk(jT(e)) }, { typeConstructor: { _tag: `effect/Option` }, pretty: ck, arbitrary: sk, equivalence: Sn }, ); ED(Z, ((e) => uk(e).annotations({ description: `Option<${CE(e)}>` }))(ZD), { strict: !0, decode: (e) => xn(N(e.trim()), iS), encode: (e) => I(e, () => ``), }); const dk = () => (e) => `BigDecimal(${Nr(Tr(e))})`, fk = () => (e) => e.tuple(e.bigInt(), e.integer({ min: -18, max: 18 })).map(([e, t]) => br(e, t)); var pk = class extends ME(yr, { typeConstructor: { _tag: `effect/BigDecimal` }, identifier: `BigDecimalFromSelf`, pretty: dk, arbitrary: fk, equivalence: () => Or, }) {}; (TD(Z.annotations({ description: `a string to be decoded into a BigDecimal` }), pk, { strict: !0, decode: (e, t, n) => Mr(e).pipe( un({ onNone: () => gT(new J(n, e, `Unable to decode ${JSON.stringify(e)} into a BigDecimal`)), onSome: (e) => Y(Tr(e)), }), ), encode: (e) => Y(Nr(Tr(e))), }).annotations({ identifier: `BigDecimal` }), ED(Q.annotations({ description: `a number to be decoded into a BigDecimal` }), pk, { strict: !0, decode: (e) => Ar(e), encode: (e) => Fr(e), }).annotations({ identifier: `BigDecimalFromNumber` })); function mk(e) { return ne(e) ? e : (e?.disableValidation ?? !1); } const hk = UE( hD({ _tag: OE(`None`) }).annotations({ identifier: `FiberIdNoneEncoded` }), hD({ _tag: OE(`Runtime`), id: wO, startTimeMillis: wO }).annotations({ identifier: `FiberIdRuntimeEncoded`, }), hD({ _tag: OE(`Composite`), left: yD(() => hk), right: yD(() => hk) }).annotations({ identifier: `FiberIdCompositeEncoded`, }), ).annotations({ identifier: `FiberIdEncoded` }), gk = (e) => e .letrec((t) => ({ None: e.record({ _tag: e.constant(`None`) }), Runtime: e.record({ _tag: e.constant(`Runtime`), id: e.integer(), startTimeMillis: e.integer(), }), Composite: e.record({ _tag: e.constant(`Composite`), left: t(`FiberId`), right: t(`FiberId`), }), FiberId: e.oneof(t(`None`), t(`Runtime`), t(`Composite`)), })) .FiberId.map(yk), _k = (e) => { switch (e._tag) { case `None`: return `FiberId.none`; case `Runtime`: return `FiberId.runtime(${e.id}, ${e.startTimeMillis})`; case `Composite`: return `FiberId.composite(${_k(e.right)}, ${_k(e.left)})`; } }; var vk = class extends ME(wc, { typeConstructor: { _tag: `effect/FiberId` }, identifier: `FiberIdFromSelf`, pretty: () => _k, arbitrary: () => gk, }) {}; const yk = (e) => { switch (e._tag) { case `None`: return xc; case `Runtime`: return Sc(e.id, e.startTimeMillis); case `Composite`: return Cc(yk(e.left), yk(e.right)); } }, bk = (e) => { switch (e._tag) { case `None`: return { _tag: `None` }; case `Runtime`: return { _tag: `Runtime`, id: e.id, startTimeMillis: e.startTimeMillis }; case `Composite`: return { _tag: `Composite`, left: bk(e.left), right: bk(e.right) }; } }; (ED(hk, vk, { strict: !0, decode: (e) => yk(e), encode: (e) => bk(e) }).annotations({ identifier: `FiberId`, }), ED(LE, LE, { strict: !0, decode: (e) => { if (le(e) && `message` in e && typeof e.message == `string`) { let t = Error(e.message, { cause: e }); return ( `name` in e && typeof e.name == `string` && (t.name = e.name), (t.stack = `stack` in e && typeof e.stack == `string` ? e.stack : ``), t ); } return Oo(e); }, encode: (e) => (e instanceof Error ? { name: e.name, message: e.message } : Oo(e)), }).annotations({ identifier: `Defect` }), ED(LE, BE, { strict: !0, decode: (e) => ee(e), encode: n }).annotations({ identifier: `BooleanFromUnknown`, }), ED( OE(`true`, `false`).annotations({ description: `a string to be decoded into a boolean` }), BE, { strict: !0, decode: (e) => e === `true`, encode: (e) => (e ? `true` : `false`) }, ).annotations({ identifier: `BooleanFromString` })); const xk = _D(`symbol`, { key: Z }).annotations({ description: `an object to be decoded into a globally shared symbol`, }), Sk = TD(xk, zE, { strict: !0, decode: (e) => OO(e.key), encode: (e, t, n) => xT(DO(e, n), (e) => xk.make({ key: e })), }); var Ck = class extends UE(Z, Q, Sk).annotations({ identifier: `PropertyKey` }) {}; hD({ _tag: lD( OE( `Pointer`, `Unexpected`, `Missing`, `Composite`, `Refinement`, `Transformation`, `Type`, `Forbidden`, ), ).annotations({ description: `The tag identifying the type of parse issue` }), path: lD(ZE(Ck)).annotations({ description: `The path to the property where the issue occurred`, }), message: lD(Z).annotations({ description: `A descriptive message explaining the issue` }), }).annotations({ identifier: `ArrayFormatterIssue`, description: `Represents an issue returned by the ArrayFormatter formatter`, }); const wk = hD({ id: Q, created: PE(Date), title: Z.pipe(MD(1), AD(100)), type: OE(`jpg`, `png`), size: Q, url: Z.pipe($((e) => URL.canParse(e))), }), Tk = hD({ id: Q, stars: Q.pipe(cO(0), mO(5)), title: Z.pipe(MD(1), AD(100)), text: Z.pipe(MD(1), AD(1e3)), images: vD(ZE(wk)), }); wE( hD({ id: Q, created: PE(Date), title: Z.pipe(MD(1), AD(100)), brand: Z.pipe(MD(1), AD(30)), description: Z.pipe(MD(1), AD(500)), price: Q.pipe(cO(1), mO(1e4)), discount: WE(Q.pipe(cO(1), mO(100))), quantity: Q.pipe(cO(1), mO(10)), tags: vD(ZE(Z.pipe(MD(1), AD(30)))), images: vD(ZE(wk)), ratings: vD(ZE(Tk)), }), )({});
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures