LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download
    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing

    • article
      Blog
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
Expand sidebarExpand sidebar
effect/Compiled (minified)Compiled (minified)
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
github
GitHubGitHub
schemas/libraries/effect/download_compiled/minified.js
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=t(2,(e,t)=>l((n,r)=>e(t(n),t(r)))),d=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}),f=`effect/GlobalValue`;let p;const m=(e,t)=>(p||=(globalThis[f]??=new Map,globalThis[f]),p.has(e)||p.set(e,t()),p.get(e)),h=e=>typeof e==`string`,g=e=>typeof e==`number`,_=e=>typeof e==`boolean`,v=e=>typeof e==`bigint`,ee=e=>typeof e==`symbol`,te=e,ne=e=>e===void 0,re=e=>!1,ie=e=>typeof e==`object`&&!!e,ae=e=>ie(e)||te(e),y=t(2,(e,t)=>ae(e)&&t in e),oe=t(2,(e,t)=>y(e,`_tag`)&&e._tag===t),se=e=>e==null,ce=e=>e!=null,le=e=>e instanceof Uint8Array,ue=e=>e instanceof Date,de=e=>typeof e==`string`||y(e,Symbol.iterator),fe=e=>ie(e)&&!Array.isArray(e),pe=e=>y(e,`then`)&&te(e.then),me=e=>`BUG: ${e} - please report an issue at https://github.com/Effect-TS/effect/issues`;Symbol.iterator;var he=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)}},ge=class{_state;constructor(e,t,n,r){return se(t)&&se(e)?(t=Math.random()*4294967295>>>0,e=0):se(t)&&(t=e,e=0),se(r)&&se(n)?(r=this._state?this._state[3]:4150755663,n=this._state?this._state[2]:335903614):se(r)&&(r=n,n=0),this._state=new Int32Array([0,0,n>>>0,((r||0)|1)>>>0]),this._next(),ve(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;_e(this._state,e,t,1481765933,1284865837),ve(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 _e(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 ve(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 ye=Symbol.for(`effect/Utils/YieldWrap`);var be=class{#e;constructor(e){this.#e=e}[ye](){return this.#e}};function xe(e){if(typeof e==`object`&&e&&ye in e)return e[ye]();throw Error(me(`yieldWrapGet`))}const Se=m(`effect/Utils/isStructuralRegion`,()=>({enabled:!1,tester:void 0})),Ce={effect_internal_function:e=>e()},we=Ce.effect_internal_function(()=>Error().stack)?.includes(`effect_internal_function`)===!0?Ce.effect_internal_function:{effect_internal_function:e=>{try{return e()}finally{}}}.effect_internal_function;(function*(){}).constructor;const Te=m(Symbol.for(`effect/Hash/randomHashCache`),()=>new WeakMap),b=Symbol.for(`effect/Hash`),x=e=>{if(Se.enabled===!0)return 0;switch(typeof e){case`number`:return ke(e);case`bigint`:return C(e.toString(10));case`boolean`:return C(String(e));case`symbol`:return C(String(e));case`string`:return C(e);case`undefined`:return C(`undefined`);case`function`:case`object`:return e===null?C(`null`):e instanceof Date?Number.isNaN(e.getTime())?C(`Invalid Date`):x(e.toISOString()):e instanceof URL?x(e.href):Oe(e)?e[b]():Ee(e);default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Ee=e=>(Te.has(e)||Te.set(e,ke(Math.floor(Math.random()*(2**53-1)))),Te.get(e)),S=e=>t=>t*53^e,De=e=>e&3221225471|e>>>1&1073741824,Oe=e=>y(e,b),ke=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 De(t)},C=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return De(t)},Ae=(e,t)=>{let n=12289;for(let r=0;r<t.length;r++)n^=c(C(t[r]),S(x(e[t[r]])));return De(n)},je=e=>Ae(e,Object.keys(e)),Me=e=>{let t=6151;for(let n=0;n<e.length;n++)t=c(t,S(x(e[n])));return De(t)},w=function(){if(arguments.length===1){let e=arguments[0];return function(t){return Object.defineProperty(e,b,{value(){return t},enumerable:!1}),t}}let e=arguments[0],t=arguments[1];return Object.defineProperty(e,b,{value(){return t},enumerable:!1}),t},T=Symbol.for(`effect/Equal`);function E(){return arguments.length===1?e=>Ne(e,arguments[0]):Ne(arguments[0],arguments[1])}function Ne(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(Pe(e)&&Pe(t))return x(e)===x(t)&&e[T](t)?!0:Se.enabled&&Se.tester?Se.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(Se.enabled){if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>Ne(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&&Ne(e[r],t[r])))return Se.tester?Se.tester(e,t):!1;return!0}}return Se.tester?Se.tester(e,t):!1}}return Se.enabled&&Se.tester?Se.tester(e,t):!1}const Pe=e=>y(e,T),Fe=()=>E,D=Symbol.for(`nodejs.util.inspect.custom`),O=e=>{try{if(y(e,`toJSON`)&&te(e.toJSON)&&e.toJSON.length===0)return e.toJSON();if(Array.isArray(e))return e.map(O)}catch{return{}}return qe(e)},Ie=`[Circular]`;function Le(e){try{return e.toISOString()}catch{return`Invalid Date`}}function Re(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function ze(e){return h(e)?JSON.stringify(e):String(e)}function Be(e,t){let n=t?.space??0,r=new WeakSet,i=n?g(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 Ie;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(ue(e))return Le(e);if(!t?.ignoreToString&&y(e,`toString`)&&te(e.toString)&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=Re(e);return e instanceof Error&&e.cause?`${t} (cause: ${c(e.cause,n)})`:t}if(h(e))return JSON.stringify(e);if(g(e)||e==null||_(e)||ee(e))return String(e);if(v(e))return String(e)+`n`;if(e instanceof Set||e instanceof Map)return r.has(e)?Ie:(r.add(e),`${e.constructor.name}(${c(Array.from(e),n)})`);if(ae(e)){if(r.has(e))return Ie;r.add(e);let t=s(e);return!i||t.length<=1?o(e,`{${t.map(t=>`${ze(t)}:${c(e[t],n)}`).join(`,`)}}`):o(e,`{\n${t.map(t=>`${a(n+1)}${ze(t)}: ${c(e[t],n+1)}`).join(`, `)}\n${a(n)}}`)}return String(e)}return c(e,0)}const k=e=>JSON.stringify(e,null,2),Ve=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?He(e,t):String(e)}catch{return String(e)}},He=(e,t)=>{let n=[],r=JSON.stringify(e,(e,t)=>typeof t==`object`&&t?n.includes(t)?void 0:n.push(t)&&(Ge.fiberRefs!==void 0&&We(t)?t[Ue](Ge.fiberRefs):t):t,t);return n=void 0,r},Ue=Symbol.for(`effect/Inspectable/Redactable`),We=e=>typeof e==`object`&&!!e&&Ue in e,Ge=m(`effect/Inspectable/redactableState`,()=>({fiberRefs:void 0})),Ke=(e,t)=>{let n=Ge.fiberRefs;Ge.fiberRefs=e;try{return t()}finally{Ge.fiberRefs=n}},qe=e=>We(e)&&Ge.fiberRefs!==void 0?e[Ue](Ge.fiberRefs):e,A=(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}}},Je=`Async`,Ye=`Commit`,Xe=`Failure`,Ze=`OnFailure`,Qe=`OnSuccess`,$e=`OnSuccessAndFailure`,et=`Success`,tt=`Sync`,nt=`UpdateRuntimeFlags`,rt=`While`,it=`Iterator`,at=`WithRuntime`,ot=`Yield`,st=`RevertFlags`,ct=()=>`3.19.17`,lt=Symbol.for(`effect/Effect`),ut=Symbol.for(`effect/Stream`),dt=Symbol.for(`effect/Sink`),ft=Symbol.for(`effect/Channel`),pt={_R:e=>e,_E:e=>e,_A:e=>e,_V:ct()},mt={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e},ht={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},gt={[lt]:pt,[ut]:pt,[dt]:mt,[ft]:ht,[T](e){return this===e},[b](){return w(this,Ee(this))},[Symbol.iterator](){return new he(new be(this))},pipe(){return A(this,arguments)}},_t={[b](){return w(this,je(this))},[T](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&&E(this[n],e[n])))return!1;return!0}},vt={...gt,_op:Ye},yt={...vt,..._t},bt=function(){function e(){}return e.prototype=vt,e}(),xt=Symbol.for(`effect/Option`),St={...gt,[xt]:{_A:e=>e},[D](){return this.toJSON()},toString(){return k(this.toJSON())}},Ct=Object.assign(Object.create(St),{_tag:`Some`,_op:`Some`,[T](e){return Et(e)&&Ot(e)&&E(this.value,e.value)},[b](){return w(this,S(x(this._tag))(x(this.value)))},toJSON(){return{_id:`Option`,_tag:this._tag,value:O(this.value)}}}),wt=x(`None`),Tt=Object.assign(Object.create(St),{_tag:`None`,_op:`None`,[T](e){return Et(e)&&Dt(e)},[b](){return wt},toJSON(){return{_id:`Option`,_tag:this._tag}}}),Et=e=>y(e,xt),Dt=e=>e._tag===`None`,Ot=e=>e._tag===`Some`,kt=Object.create(Tt),At=e=>{let t=Object.create(Ct);return t.value=e,t},jt=Symbol.for(`effect/Either`),Mt={...gt,[jt]:{_R:e=>e},[D](){return this.toJSON()},toString(){return k(this.toJSON())}},Nt=Object.assign(Object.create(Mt),{_tag:`Right`,_op:`Right`,[T](e){return Ft(e)&&Lt(e)&&E(this.right,e.right)},[b](){return S(x(this._tag))(x(this.right))},toJSON(){return{_id:`Either`,_tag:this._tag,right:O(this.right)}}}),Pt=Object.assign(Object.create(Mt),{_tag:`Left`,_op:`Left`,[T](e){return Ft(e)&&It(e)&&E(this.left,e.left)},[b](){return S(x(this._tag))(x(this.left))},toJSON(){return{_id:`Either`,_tag:this._tag,left:O(this.left)}}}),Ft=e=>y(e,jt),It=e=>e._tag===`Left`,Lt=e=>e._tag===`Right`,Rt=e=>{let t=Object.create(Pt);return t.left=e,t},j=e=>{let t=Object.create(Nt);return t.right=e,t},M=Rt,zt=Ft,N=It,Bt=Lt,Vt=t(2,(e,t)=>N(e)?M(t(e.left)):j(e.right)),Ht=t(2,(e,t)=>Bt(e)?j(t(e.right)):M(e.left)),Ut=t(2,(e,{onLeft:t,onRight:n})=>N(e)?t(e.left):n(e.right)),Wt=Ut({onLeft:n,onRight:n}),Gt=t(2,(e,t)=>{if(Bt(e))return e.right;throw t(e.left)}),Kt=Gt(()=>Error(`getOrThrow called on a Left`)),qt=e=>e.length>0,Jt=e=>(t,n)=>t===n?0:e(t,n),Yt=Jt((e,t)=>e<t?-1:1),Xt=t(2,(e,t)=>Jt((n,r)=>e(t(n),t(r)))),Zt=e=>t(2,(t,n)=>e(t,n)===1),P=()=>kt,F=At,I=Dt,L=Ot,Qt=t(2,(e,{onNone:t,onSome:n})=>I(e)?t():n(e.value)),R=t(2,(e,t)=>I(e)?t():e.value),$t=t(2,(e,t)=>I(e)?t():e),en=t(2,(e,t)=>I(e)?F(t()):e),tn=e=>e==null?P():F(e),nn=R(o),rn=e=>(...t)=>{try{return F(e(...t))}catch{return P()}},an=t(2,(e,t)=>{if(L(e))return e.value;throw t()})(()=>Error(`getOrThrow called on a None`)),on=t(2,(e,t)=>I(e)?P():F(t(e.value))),sn=t(2,(e,t)=>I(e)?P():t(e.value)),cn=t(2,(e,t)=>I(e)?P():tn(t(e.value))),ln=(e=>t(2,(t,n)=>I(t)?!1:e(t.value,n)))(Fe()),un=t(2,(e,t)=>I(e)?!1:t(e.value)),dn=e=>(t,n)=>I(t)?n:I(n)?t:F(e(t.value,n.value)),fn=(...e)=>e,pn=e=>Array(e),mn=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}),z=e=>Array.isArray(e)?e:Array.from(e),hn=e=>Array.isArray(e)?e:[e],gn=t(2,(e,{onEmpty:t,onNonEmpty:n})=>B(e)?n(On(e),jn(e)):t()),_n=t(2,(e,t)=>[t,...e]),vn=t(2,(e,t)=>[...e,t]),yn=t(2,(e,t)=>z(e).concat(z(t))),bn=Array.isArray,xn=e=>e.length===0,Sn=qt,B=qt,Cn=(e,t)=>e<0||e>=t.length,wn=(e,t)=>Math.floor(Math.min(Math.max(0,e),t.length)),Tn=t(2,(e,t)=>{let n=Math.floor(t);return Cn(n,e)?P():F(e[n])}),En=t(2,(e,t)=>{let n=Math.floor(t);if(Cn(n,e))throw Error(`Index ${n} out of bounds`);return e[n]}),Dn=Tn(0),On=En(0),kn=e=>B(e)?F(An(e)):P(),An=e=>e[e.length-1],jn=e=>e.slice(1),Mn=(e,t)=>{let n=0;for(let r of e){if(!t(r,n))break;n++}return n},Nn=t(2,(e,t)=>Bn(e,Mn(e,t))),Pn=t(2,(e,t)=>{let n=z(e);return n.slice(wn(t,n),n.length)}),Fn=e=>Array.from(e).reverse(),In=t(2,(e,t)=>{let n=Array.from(e);return n.sort(t),n}),Ln=t(2,(e,t)=>Rn(e,t,fn)),Rn=t(3,(e,t,n)=>{let r=z(e),i=z(t);if(B(r)&&B(i)){let e=[n(On(r),On(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[]}),zn=Fe(),Bn=t(2,(e,t)=>{let n=Array.from(e),r=Math.floor(t);return B(n)?r>=1?Vn(n,r):[[],n]:[n,[]]}),Vn=t(2,(e,t)=>{let n=Math.max(1,Math.floor(t));return n>=e.length?[Hn(e),[]]:[_n(e.slice(1,n),On(e)),e.slice(n)]}),Hn=e=>e.slice(),Un=t(3,(e,t,n)=>{let r=z(e),i=z(t);return B(r)?B(i)?er(n)(yn(r,i)):r:i}),Wn=t(2,(e,t)=>Un(e,t,zn)),Gn=()=>[],Kn=e=>[e],qn=t(2,(e,t)=>e.map(t)),Jn=t(2,(e,t)=>{if(xn(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}),Yn=Jn(n),Xn=t(2,(e,t)=>{let n=z(e),r=[];for(let e=0;e<n.length;e++){let i=t(n[e],e);L(i)&&r.push(i.value)}return r}),Zn=t(3,(e,t,n)=>z(e).reduce((e,t,r)=>n(e,t,r),t)),Qn=(e,t)=>{let n=[],r=e,i;for(;L(i=t(r));){let[e,t]=i.value;n.push(e),r=t}return n},$n=d,er=t(2,(e,t)=>{let n=z(e);if(B(n)){let e=[On(n)],r=jn(n);for(let n of r)e.every(e=>!t(n,e))&&e.push(n);return e}return[]}),tr=e=>er(e,Fe()),nr=t(2,(e,t)=>z(e).join(t)),rr=Symbol.for(`effect/Chunk`);function ir(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 ar=[],or=(e=>l((t,n)=>t.length===n.length&&hr(t).every((t,r)=>e(t,br(n,r)))))(E),sr={[rr]:{_A:e=>e},toString(){return k(this.toJSON())},toJSON(){return{_id:`Chunk`,values:hr(this).map(O)}},[D](){return this.toJSON()},[T](e){return cr(e)&&or(this,e)},[b](){return w(this,Me(hr(this)))},[Symbol.iterator](){switch(this.backing._tag){case`IArray`:return this.backing.array[Symbol.iterator]();case`IEmpty`:return ar[Symbol.iterator]();default:return hr(this)[Symbol.iterator]()}},pipe(){return A(this,arguments)}},V=e=>{let t=Object.create(sr);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=lr,t.right=lr;break;case`ISingleton`:t.length=1,t.depth=0,t.left=lr,t.right=lr;break;case`ISlice`:t.length=e.length,t.depth=e.chunk.depth+1,t.left=lr,t.right=lr;break}return t},cr=e=>y(e,rr),lr=V({_tag:`IEmpty`}),ur=()=>lr,dr=(...e)=>yr(e),fr=e=>V({_tag:`ISingleton`,a:e}),pr=e=>cr(e)?e:vr(z(e)),mr=(e,t,n)=>{switch(e.backing._tag){case`IArray`:ir(e.backing.array,0,t,n,e.length);break;case`IConcat`:mr(e.left,t,n),mr(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]=br(e,r),r+=1,i+=1;break}}},hr=e=>{switch(e.backing._tag){case`IEmpty`:return ar;case`IArray`:return e.backing.array;default:{let t=Array(e.length);return mr(e,t,0),e.backing={_tag:`IArray`,array:t},e.left=lr,e.right=lr,e.depth=0,t}}},gr=e=>{switch(e.backing._tag){case`IEmpty`:case`ISingleton`:return e;case`IArray`:return V({_tag:`IArray`,array:Fn(e.backing.array)});case`IConcat`:return V({_tag:`IConcat`,left:gr(e.backing.right),right:gr(e.backing.left)});case`ISlice`:return vr(Fn(hr(e)))}},_r=t(2,(e,t)=>t<0||t>=e.length?P():F(br(e,t))),vr=e=>e.length===0?ur():e.length===1?fr(e[0]):V({_tag:`IArray`,array:e}),yr=e=>vr(e),br=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?br(e.left,t):br(e.right,t-e.left.length);case`ISlice`:return br(e.backing.chunk,t+e.backing.offset)}}),xr=t(2,(e,t)=>wr(e,fr(t))),Sr=t(2,(e,t)=>wr(fr(t),e)),Cr=t(2,(e,t)=>{if(t<=0)return e;if(t>=e.length)return lr;switch(e.backing._tag){case`ISlice`:return V({_tag:`ISlice`,chunk:e.backing.chunk,offset:e.backing.offset+t,length:e.backing.length-t});case`IConcat`:return t>e.left.length?Cr(e.right,t-e.left.length):V({_tag:`IConcat`,left:Cr(e.left,t),right:e.right});default:return V({_tag:`ISlice`,chunk:e,offset:t,length:e.length-t})}}),wr=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 V({_tag:`IConcat`,left:e,right:t});if(n<-1)if(e.left.depth>=e.right.depth){let n=wr(e.right,t);return V({_tag:`IConcat`,left:e.left,right:n})}else{let n=wr(e.right.right,t);if(n.depth===e.depth-3){let t=V({_tag:`IConcat`,left:e.right.left,right:n});return V({_tag:`IConcat`,left:e.left,right:t})}else return V({_tag:`IConcat`,left:V({_tag:`IConcat`,left:e.left,right:e.right.left}),right:n})}else if(t.right.depth>=t.left.depth)return V({_tag:`IConcat`,left:wr(e,t.left),right:t.right});else{let n=wr(e,t.left.left);return n.depth===t.depth-3?V({_tag:`IConcat`,left:V({_tag:`IConcat`,left:n,right:t.left.right}),right:t.right}):V({_tag:`IConcat`,left:n,right:V({_tag:`IConcat`,left:t.left.right,right:t.right})})}}),Tr=e=>e.length===0,Er=e=>e.length>0,Dr=_r(0),Or=e=>br(e,0),kr=Or,Ar=e=>Cr(e,1);function jr(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 Mr(e,t){return t>>>e&31}function Nr(e){return 1<<e}function Pr(e,t){return jr(e&t-1)}const Fr=(e,t)=>({value:e,previous:t});function Ir(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 Lr(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 Rr(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 zr=class e{_tag=`EmptyNode`;modify(t,n,r,i,a,o){let s=r(P());return I(s)?new e:(++o.value,new Ur(t,i,a,s))}};function Br(e){return oe(e,`EmptyNode`)}function Vr(e){return Br(e)||e._tag===`LeafNode`||e._tag===`CollisionNode`}function Hr(e,t){return Br(e)?!1:t===e.edit}var Ur=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(E(a,this.key)){let n=r(this.value);return n===this.value?this:I(n)?(--o.value,new zr):Hr(this,t)?(this.value=n,this):new e(t,i,a,n)}let s=r(P());return I(s)?this:(++o.value,Xr(t,n,this.hash,this,i,new e(t,i,a,s)))}},Wr=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=Hr(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(P());return I(s)?this:(++o.value,Xr(t,n,this.hash,this,i,new Ur(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&&E(a,s.key)){let l=s.value,u=i(l);return u===l?r:I(u)?(--o.value,Lr(e,c,r)):Ir(e,c,new Ur(t,n,a,u),r)}}let c=i(P());return I(c)?r:(++o.value,Ir(e,s,new Ur(t,n,a,c),r))}},Gr=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=Mr(n,i),u=Nr(l),d=Pr(s,u),f=s&u,p=Hr(this,t);if(!f){let f=new zr().modify(t,n+5,r,i,a,o);return f?c.length>=16?Jr(t,l,f,s,c):new e(t,s|u,Rr(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,_;if(Br(h)){if(g&=~u,!g)return new zr;if(c.length<=2&&Vr(c[d^1]))return c[d^1];_=Lr(p,d,c)}else _=Ir(p,d,h,c);return p?(this.mask=g,this.children=_,this):new e(t,g,_)}},Kr=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=Mr(n,i),u=c[l],d=(u||new zr).modify(t,n+5,r,i,a,o);if(u===d)return this;let f=Hr(this,t),p;if(Br(u)&&!Br(d))++s,p=Ir(f,l,d,c);else if(!Br(u)&&Br(d)){if(--s,s<=8)return qr(t,s,l,c);p=Ir(f,l,new zr,c)}else p=Ir(f,l,d,c);return f?(this.size=s,this.children=p,this):new e(t,s,p)}};function qr(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&&!Br(t)&&(i[a++]=t,o|=1<<e)}return new Gr(e,o,i)}function Jr(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 Kr(e,s+1,a)}function Yr(e,t,n,r,i,a){if(n===i)return new Wr(e,n,[a,r]);let o=Mr(t,n),s=Mr(t,i);if(o===s)return t=>new Gr(e,Nr(o)|Nr(s),[t]);{let t=o<s?[r,a]:[a,r];return new Gr(e,Nr(o)|Nr(s),t)}}function Xr(e,t,n,r,i,a){let o,s=t;for(;;){let t=Yr(e,s,n,r,i,a);if(typeof t==`function`)o=Fr(t,o),s+=5;else{let e=t;for(;o!=null;)e=o.value(e),o=o.previous;return e}}}const Zr=`effect/HashMap`,Qr=Symbol.for(Zr),$r={[Qr]:Qr,[Symbol.iterator](){return new ti(this,(e,t)=>[e,t])},[b](){let e=x(Zr);for(let t of this)e^=c(x(t[0]),S(x(t[1])));return w(this,e)},[T](e){if(ci(e)){if(e._size!==this._size)return!1;for(let t of this){let n=c(e,di(t[0],x(t[0])));if(I(n)||!E(t[1],n.value))return!1}return!0}return!1},toString(){return k(this.toJSON())},toJSON(){return{_id:`HashMap`,values:Array.from(this).map(O)}},[D](){return this.toJSON()},pipe(){return A(this,arguments)}},ei=(e,t,n,r)=>{let i=Object.create($r);return i._editable=e,i._edit=t,i._root=n,i._size=r,i};var ti=class e{map;f;v;constructor(e,t){this.map=e,this.f=t,this.v=ri(this.map._root,this.f,void 0)}next(){if(I(this.v))return{done:!0,value:void 0};let e=this.v.value;return this.v=ni(e.cont),{done:!1,value:e.value}}[Symbol.iterator](){return new e(this.map,this.f)}};const ni=e=>e?ii(e[0],e[1],e[2],e[3],e[4]):P(),ri=(e,t,n=void 0)=>{switch(e._tag){case`LeafNode`:return L(e.value)?F({value:t(e.key,e.value.value),cont:n}):ni(n);case`CollisionNode`:case`ArrayNode`:case`IndexedNode`:{let r=e.children;return ii(r.length,r,0,t,n)}default:return ni(n)}},ii=(e,t,n,r,i)=>{for(;n<e;){let a=t[n++];if(a&&!Br(a))return ri(a,r,[e,t,n,r,i])}return ni(i)},ai=ei(!1,0,new zr,0),oi=()=>ai,si=e=>{let t=_i(oi());for(let n of e)pi(t,n[0],n[1]);return vi(t)},ci=e=>y(e,Qr),li=e=>e&&Br(e._root),ui=t(2,(e,t)=>di(e,t,x(t))),di=t(3,(e,t,n)=>{let r=e._root,i=0;for(;;)switch(r._tag){case`LeafNode`:return E(t,r.key)?r.value:P();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&&E(t,r.key))return r.value}}return P();case`IndexedNode`:{let e=Nr(Mr(i,n));if(r.mask&e){r=r.children[Pr(r.mask,e)],i+=5;break}return P()}case`ArrayNode`:if(r=r.children[Mr(i,n)],r){i+=5;break}return P();default:return P()}}),fi=t(2,(e,t)=>L(di(e,t,x(t)))),pi=t(3,(e,t,n)=>yi(e,t,()=>F(n))),mi=t(3,(e,t,n)=>e._editable?(e._root=t,e._size=n,e):t===e._root?e:ei(e._editable,e._edit,t,n)),hi=e=>new ti(e,e=>e),gi=e=>e._size,_i=e=>ei(!0,e._edit+1,e._root,e._size),vi=e=>(e._editable=!1,e),yi=t(3,(e,t,n)=>bi(e,t,x(t),n)),bi=t(4,(e,t,n,r)=>{let i={value:e._size};return c(e,mi(e._root.modify(e._editable?e._edit:NaN,0,r,n,t,i),i.value))}),xi=t(2,(e,t)=>yi(e,t,P)),Si=t(2,(e,t)=>wi(e,oi(),(e,n,r)=>pi(e,r,t(n,r)))),Ci=t(2,(e,t)=>wi(e,void 0,(e,n,r)=>t(n,r))),wi=t(3,(e,t,n)=>{let r=e._root;if(r._tag===`LeafNode`)return L(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&&!Br(r)&&(r._tag===`LeafNode`?L(r.value)&&(t=n(t,r.value.value,r.key)):i.push(r.children))}return t}),Ti=`effect/HashSet`,Ei=Symbol.for(Ti),Di={[Ei]:Ei,[Symbol.iterator](){return hi(this._keyMap)},[b](){return w(this,S(x(this._keyMap))(x(Ti)))},[T](e){return ki(e)?gi(this._keyMap)===gi(e._keyMap)&&E(this._keyMap,e._keyMap):!1},toString(){return k(this.toJSON())},toJSON(){return{_id:`HashSet`,values:Array.from(this).map(O)}},[D](){return this.toJSON()},pipe(){return A(this,arguments)}},Oi=e=>{let t=Object.create(Di);return t._keyMap=e,t},ki=e=>y(e,Ei),Ai=Oi(oi()),ji=()=>Ai,Mi=e=>{let t=Ri(ji());for(let n of e)Vi(t,n);return zi(t)},Ni=(...e)=>{let t=Ri(ji());for(let n of e)Vi(t,n);return zi(t)},Pi=t(2,(e,t)=>fi(e._keyMap,t)),Fi=t(2,(e,t)=>{let n=!1;for(let r of e)if(n=t(r),n)break;return n}),Ii=t(2,(e,t)=>!Fi(e,e=>!t(e))),Li=e=>gi(e._keyMap),Ri=e=>Oi(_i(e._keyMap)),zi=e=>(e._keyMap._editable=!1,e),Bi=t(2,(e,t)=>{let n=Ri(e);return t(n),zi(n)}),Vi=t(2,(e,t)=>e._keyMap._editable?(pi(t,!0)(e._keyMap),e):Oi(pi(t,!0)(e._keyMap))),Hi=t(2,(e,t)=>e._keyMap._editable?(xi(t)(e._keyMap),e):Oi(xi(t)(e._keyMap))),Ui=t(2,(e,t)=>Bi(e,e=>{for(let n of t)Hi(e,n)})),Wi=t(2,(e,t)=>Bi(ji(),n=>{Gi(e,e=>Vi(n,e));for(let e of t)Vi(n,e)})),Gi=t(2,(e,t)=>Ci(e._keyMap,(e,n)=>t(n))),Ki=t(3,(e,t,n)=>wi(e._keyMap,t,(e,t,r)=>n(e,r))),qi=ji,Ji=Mi,Yi=Ni,Xi=Pi,Zi=Ii,Qi=Li,$i=Vi,ea=Hi,ta=Ui,na=Wi,ra=Ki,ia=`Empty`,aa=`Fail`,oa=`Interrupt`,sa=`Parallel`,ca=`Sequential`,la=`effect/Cause`,ua=Symbol.for(la),da={_E:e=>e},fa={[ua]:da,[b](){return c(x(la),S(x(Fa(this))),w(this))},[T](e){return ya(e)&&Pa(this,e)},pipe(){return A(this,arguments)},toJSON(){switch(this._tag){case`Empty`:return{_id:`Cause`,_tag:this._tag};case`Die`:return{_id:`Cause`,_tag:this._tag,defect:O(this.defect)};case`Interrupt`:return{_id:`Cause`,_tag:this._tag,fiberId:this.fiberId.toJSON()};case`Fail`:return{_id:`Cause`,_tag:this._tag,failure:O(this.error)};case`Sequential`:case`Parallel`:return{_id:`Cause`,_tag:this._tag,left:O(this.left),right:O(this.right)}}},toString(){return Ga(this)},[D](){return this.toJSON()}},pa=(()=>{let e=Object.create(fa);return e._tag=ia,e})(),ma=e=>{let t=Object.create(fa);return t._tag=aa,t.error=e,t},ha=e=>{let t=Object.create(fa);return t._tag=`Die`,t.defect=e,t},ga=e=>{let t=Object.create(fa);return t._tag=oa,t.fiberId=e,t},_a=(e,t)=>{let n=Object.create(fa);return n._tag=sa,n.left=e,n.right=t,n},va=(e,t)=>{let n=Object.create(fa);return n._tag=ca,n.left=e,n.right=t,n},ya=e=>y(e,ua),ba=e=>e._tag===ia,xa=e=>e._tag===aa,Sa=e=>e._tag===ia?!0:Ua(e,!0,(e,t)=>{switch(t._tag){case ia:return F(e);case`Die`:case aa:case oa:return F(!1);default:return P()}}),Ca=e=>L(Aa(e)),wa=e=>Wa(void 0,za)(e),Ta=e=>gr(Ua(e,ur(),(e,t)=>t._tag===aa?F(c(e,Sr(t.error))):P())),Ea=e=>gr(Ua(e,ur(),(e,t)=>t._tag===`Die`?F(c(e,Sr(t.defect))):P())),Da=e=>Ua(e,qi(),(e,t)=>t._tag===oa?F(c(e,$i(t.fiberId))):P()),Oa=e=>La(e,e=>e._tag===aa?F(e.error):P()),ka=e=>{let t=Oa(e);switch(t._tag){case`None`:return j(e);case`Some`:return M(t.value)}},Aa=e=>La(e,e=>e._tag===oa?F(e.fiberId):P()),ja=e=>Ha(e,{onEmpty:P(),onFail:e=>F(ha(e)),onDie:e=>F(ha(e)),onInterrupt:()=>P(),onSequential:dn(va),onParallel:dn(_a)}),Ma=e=>Ha(e,{onEmpty:pa,onFail:()=>pa,onDie:ha,onInterrupt:ga,onSequential:va,onParallel:_a}),Na=e=>Ha(e,{onEmpty:pa,onFail:ha,onDie:ha,onInterrupt:ga,onSequential:va,onParallel:_a}),Pa=(e,t)=>{let n=fr(e),r=fr(t);for(;Er(n)&&Er(r);){let[e,t]=c(kr(n),Ua([qi(),ur()],([e,t],n)=>{let[r,i]=Ra(n);return F([c(e,na(r)),c(t,wr(i))])})),[i,a]=c(kr(r),Ua([qi(),ur()],([e,t],n)=>{let[r,i]=Ra(n);return F([c(e,na(r)),c(t,wr(i))])}));if(!E(e,i))return!1;n=t,r=a}return!0},Fa=e=>Ia(fr(e),ur()),Ia=(e,t)=>{for(;;){let[n,r]=c(e,Zn([qi(),ur()],([e,t],n)=>{let[r,i]=Ra(n);return[c(e,na(r)),c(t,wr(i))]})),i=Qi(n)>0?c(t,Sr(n)):t;if(Tr(r))return gr(i);e=r,t=i}throw Error(me(`Cause.flattenCauseLoop`))},La=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 ca:case sa:n.push(e.right),n.push(e.left);break}break;case`Some`:return r}}return P()}),Ra=e=>{let t=e,n=[],r=qi(),i=ur();for(;t!==void 0;)switch(t._tag){case ia:if(n.length===0)return[r,i];t=n.pop();break;case aa:if(r=$i(r,dr(t._tag,t.error)),n.length===0)return[r,i];t=n.pop();break;case`Die`:if(r=$i(r,dr(t._tag,t.defect)),n.length===0)return[r,i];t=n.pop();break;case oa:if(r=$i(r,dr(t._tag,t.fiberId)),n.length===0)return[r,i];t=n.pop();break;case ca:switch(t.left._tag){case ia:t=t.right;break;case ca:t=va(t.left.left,va(t.left.right,t.right));break;case sa:t=_a(va(t.left.left,t.right),va(t.left.right,t.right));break;default:i=Sr(i,t.right),t=t.left;break}break;case sa:n.push(t.right),t=t.left;break}throw Error(me(`Cause.evaluateCauseLoop`))},za={emptyCase:i,failCase:a,dieCase:a,interruptCase:i,sequentialCase:(e,t,n)=>t&&n,parallelCase:(e,t,n)=>t&&n},Ba=`SequentialCase`,Va=`ParallelCase`,Ha=t(2,(e,{onDie:t,onEmpty:n,onFail:r,onInterrupt:i,onParallel:a,onSequential:o})=>Wa(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)})),Ua=t(3,(e,t,n)=>{let r=t,i=e,a=[];for(;i!==void 0;){let e=n(r,i);switch(r=L(e)?e.value:r,i._tag){case ca:a.push(i.right),i=i.left;break;case sa:a.push(i.right),i=i.left;break;default:i=void 0;break}i===void 0&&a.length>0&&(i=a.pop())}return r}),Wa=t(3,(e,t,n)=>{let r=[e],i=[];for(;r.length>0;){let e=r.pop();switch(e._tag){case ia:i.push(j(n.emptyCase(t)));break;case aa:i.push(j(n.failCase(t,e.error)));break;case`Die`:i.push(j(n.dieCase(t,e.defect)));break;case oa:i.push(j(n.interruptCase(t,e.fiberId)));break;case ca:r.push(e.right),r.push(e.left),i.push(M({_tag:Ba}));break;case sa:r.push(e.right),r.push(e.left),i.push(M({_tag:Va}));break}}let a=[];for(;i.length>0;){let e=i.pop();switch(e._tag){case`Left`:switch(e.left._tag){case Ba:{let e=a.pop(),r=a.pop(),i=n.sequentialCase(t,e,r);a.push(i);break}case Va:{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()}),Ga=(e,t)=>wa(e)?`All fibers interrupted without errors.`:$a(e).map(function(e){return t?.renderErrorCause!==!0||e.cause===void 0?e.stack:`${e.stack} {\n${Ka(e.cause,` `)}\n}`}).join(` `),Ka=(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${Ka(e.cause,`${t} `)}\n${t}}`),r};var qa=class e extends globalThis.Error{span=void 0;constructor(t){let n=typeof t==`object`&&!!t,r=Error.stackTraceLimit;Error.stackTraceLimit=1,super(Ja(t),n&&`cause`in t&&t.cause!==void 0?{cause:new e(t.cause)}:void 0),this.message===``&&(this.message=`An error has occurred`),Error.stackTraceLimit=r,this.name=t instanceof Error?t.name:`Error`,n&&(Qa in t&&(this.span=t[Qa]),Object.keys(t).forEach(e=>{e in this||(this[e]=t[e])})),this.stack=Za(`${this.name}: ${this.message}`,t instanceof Error&&t.stack?t.stack:``,this.span)}};const Ja=e=>{if(typeof e==`string`)return e;if(typeof e==`object`&&e&&e instanceof Error)return e.message;try{if(y(e,`toString`)&&te(e.toString)&&e.toString!==Object.prototype.toString&&e.toString!==globalThis.Array.prototype.toString)return e.toString()}catch{}return He(e)},Ya=/\((.*)\)/g,Xa=m(`effect/Tracer/spanToTrace`,()=>new WeakMap),Za=(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=Xa.get(e);if(typeof n==`function`){let t=n();if(typeof t==`string`){let n=t.matchAll(Ya),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=nn(e.parent),t++}}return r.join(` `)},Qa=Symbol.for(`effect/SpanAnnotation`),$a=e=>Wa(e,void 0,{emptyCase:()=>[],dieCase:(e,t)=>[new qa(t)],failCase:(e,t)=>[new qa(t)],interruptCase:()=>[],parallelCase:(e,t,n)=>[...t,...n],sequentialCase:(e,t,n)=>[...t,...n]}),eo=Symbol.for(`effect/Context/Tag`),to=Symbol.for(`effect/Context/Reference`),no=Symbol.for(`effect/STM`),ro={...gt,_op:`Tag`,[no]:pt,[eo]:{_Service:e=>e,_Identifier:e=>e},toString(){return k(this.toJSON())},toJSON(){return{_id:`Tag`,key:this.key,stack:this.stack}},[D](){return this.toJSON()},of(e){return e},context(e){return go(this,e)}},io={...ro,[to]:to},ao=e=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=2;let n=Error();Error.stackTraceLimit=t;let r=Object.create(ro);return Object.defineProperty(r,`stack`,{get(){return n.stack}}),r.key=e,r},oo=()=>(e,t)=>{let n=Error.stackTraceLimit;Error.stackTraceLimit=2;let r=Error();Error.stackTraceLimit=n;function i(){}return Object.setPrototypeOf(i,io),i.key=e,i.defaultValue=t.defaultValue,Object.defineProperty(i,`stack`,{get(){return r.stack}}),i},so=Symbol.for(`effect/Context`),co={[so]:{_Services:e=>e},[T](e){if(fo(e)&&this.unsafeMap.size===e.unsafeMap.size){for(let t of this.unsafeMap.keys())if(!e.unsafeMap.has(t)||!E(this.unsafeMap.get(t),e.unsafeMap.get(t)))return!1;return!0}return!1},[b](){return w(this,ke(this.unsafeMap.size))},pipe(){return A(this,arguments)},toString(){return k(this.toJSON())},toJSON(){return{_id:`Context`,services:Array.from(this.unsafeMap).map(O)}},[D](){return this.toJSON()}},lo=e=>{let t=Object.create(co);return t.unsafeMap=e,t},uo=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},fo=e=>y(e,so),po=e=>y(e,to),mo=lo(new Map),ho=()=>mo,go=(e,t)=>lo(new Map([[e.key,t]])),_o=t(3,(e,t,n)=>{let r=new Map(e.unsafeMap);return r.set(t.key,n),lo(r)}),vo=m(`effect/Context/defaultValueCache`,()=>new Map),yo=e=>{if(vo.has(e.key))return vo.get(e.key);let t=e.defaultValue();return vo.set(e.key,t),t},bo=(e,t)=>e.unsafeMap.has(t.key)?e.unsafeMap.get(t.key):yo(t),xo=t(2,(e,t)=>{if(!e.unsafeMap.has(t.key)){if(to in t)return yo(t);throw uo(t)}return e.unsafeMap.get(t.key)}),So=xo,Co=t(2,(e,t)=>e.unsafeMap.has(t.key)?At(e.unsafeMap.get(t.key)):po(t)?At(yo(t)):kt),wo=t(2,(e,t)=>{let n=new Map(e.unsafeMap);for(let[e,r]of t.unsafeMap)n.set(e,r);return lo(n)}),To=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].unsafeMap.forEach((e,n)=>{t.set(n,e)});return lo(t)},Eo=ao,Do=ho,Oo=go,ko=_o,Ao=So,jo=xo,Mo=Co,No=wo,Po=To,Fo=oo,Io=Symbol.for(`effect/Duration`),Lo=BigInt(0),Ro=BigInt(24),zo=BigInt(60),Bo=BigInt(1e3),Vo=BigInt(1e6),Ho=BigInt(1e9),Uo=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,Wo=e=>{if(Yo(e))return e;if(g(e))return ts(e);if(v(e))return $o(e);if(Array.isArray(e)&&e.length===2&&e.every(g))return e[0]===-1/0||e[1]===-1/0||Number.isNaN(e[0])||Number.isNaN(e[1])?Zo:e[0]===1/0||e[1]===1/0?Qo:$o(BigInt(Math.round(e[0]*1e9))+BigInt(Math.round(e[1])));if(h(e)){let t=Uo.exec(e);if(t){let[e,n,r]=t,i=Number(n);switch(r){case`nano`:case`nanos`:return $o(BigInt(n));case`micro`:case`micros`:return es(BigInt(n));case`milli`:case`millis`:return ts(i);case`second`:case`seconds`:return ns(i);case`minute`:case`minutes`:return rs(i);case`hour`:case`hours`:return is(i);case`day`:case`days`:return as(i);case`week`:case`weeks`:return os(i)}}}throw Error(`Invalid DurationInput`)},Go={_tag:`Millis`,millis:0},Ko={_tag:`Infinity`},qo={[Io]:Io,[b](){return w(this,je(this.value))},[T](e){return Yo(e)&&hs(this,e)},toString(){return`Duration(${_s(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:ls(this)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`}}},[D](){return this.toJSON()},pipe(){return A(this,arguments)}},Jo=e=>{let t=Object.create(qo);return g(e)?isNaN(e)||e<=0?t.value=Go:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:`Millis`,millis:e}:t.value={_tag:`Nanos`,nanos:BigInt(Math.round(e*1e6))}:t.value=Ko:e<=Lo?t.value=Go:t.value={_tag:`Nanos`,nanos:e},t},Yo=e=>y(e,Io),Xo=e=>{switch(e.value._tag){case`Millis`:return e.value.millis===0;case`Nanos`:return e.value.nanos===Lo;case`Infinity`:return!1}},Zo=Jo(0),Qo=Jo(1/0),$o=e=>Jo(e),es=e=>Jo(e*Bo),ts=e=>Jo(e),ns=e=>Jo(e*1e3),rs=e=>Jo(e*6e4),is=e=>Jo(e*36e5),as=e=>Jo(e*864e5),os=e=>Jo(e*6048e5),ss=e=>us(e,{onMillis:e=>e,onNanos:e=>Number(e)/1e6}),cs=e=>{let t=Wo(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))}},ls=e=>{let t=Wo(e);switch(t.value._tag){case`Infinity`:return[1/0,0];case`Nanos`:return[Number(t.value.nanos/Ho),Number(t.value.nanos%Ho)];case`Millis`:return[Math.floor(t.value.millis/1e3),Math.round(t.value.millis%1e3*1e6)]}},us=t(2,(e,t)=>{let n=Wo(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)}}),ds=t(3,(e,t,n)=>{let r=Wo(e),i=Wo(t);if(r.value._tag===`Infinity`||i.value._tag===`Infinity`)return n.onMillis(ss(r),ss(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)}),fs=(e,t)=>ds(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t}),ps=t(2,(e,t)=>ds(e,t,{onMillis:(e,t)=>e<=t,onNanos:(e,t)=>e<=t})),ms=t(2,(e,t)=>ds(e,t,{onMillis:(e,t)=>e>=t,onNanos:(e,t)=>e>=t})),hs=t(2,(e,t)=>fs(Wo(e),Wo(t))),gs=e=>{let t=Wo(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=cs(t),r=n/Vo,i=r/Bo,a=i/zo,o=a/zo,s=o/Ro;return{days:Number(s),hours:Number(o%Ro),minutes:Number(a%zo),seconds:Number(i%zo),millis:Number(r%Bo),nanos:Number(n%Vo)}},_s=e=>{let t=Wo(e);if(t.value._tag===`Infinity`)return`Infinity`;if(Xo(t))return`0`;let n=gs(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(` `)},vs=Symbol.for(`effect/MutableRef`),ys={[vs]:vs,toString(){return k(this.toJSON())},toJSON(){return{_id:`MutableRef`,current:O(this.current)}},[D](){return this.toJSON()},pipe(){return A(this,arguments)}},bs=e=>{let t=Object.create(ys);return t.current=e,t},xs=e=>e.current,Ss=t(2,(e,t)=>(e.current=t,e)),Cs=`effect/FiberId`,ws=Symbol.for(Cs),Ts=`None`,Es=`Runtime`,Ds=`Composite`,Os=C(`${Cs}-${Ts}`);var ks=class{[ws]=ws;_tag=Ts;id=-1;startTimeMillis=-1;[b](){return Os}[T](e){return Ms(e)&&e._tag===Ts}toString(){return k(this.toJSON())}toJSON(){return{_id:`FiberId`,_tag:this._tag}}[D](){return this.toJSON()}},As=class{id;startTimeMillis;[ws]=ws;_tag=Es;constructor(e,t){this.id=e,this.startTimeMillis=t}[b](){return w(this,C(`${Cs}-${this._tag}-${this.id}-${this.startTimeMillis}`))}[T](e){return Ms(e)&&e._tag===Es&&this.id===e.id&&this.startTimeMillis===e.startTimeMillis}toString(){return k(this.toJSON())}toJSON(){return{_id:`FiberId`,_tag:this._tag,id:this.id,startTimeMillis:this.startTimeMillis}}[D](){return this.toJSON()}};const js=new ks,Ms=e=>y(e,ws),Ns=e=>e._tag===Ts||c(Ls(e),Zi(e=>Ns(e))),Ps=e=>{switch(e._tag){case Ts:return qi();case Es:return Yi(e.id);case Ds:return c(Ps(e.left),na(Ps(e.right)))}},Fs=m(Symbol.for(`effect/Fiber/Id/_fiberCounter`),()=>bs(0)),Is=e=>Array.from(Ps(e)).map(e=>`#${e}`).join(`,`),Ls=e=>{switch(e._tag){case Ts:return qi();case Es:return Yi(e);case Ds:return c(Ls(e.left),na(Ls(e.right)))}},Rs=()=>{let e=xs(Fs);return c(Fs,Ss(e+1)),new As(e,Date.now())},zs=js,Bs=Is,Vs=Rs,Hs=oi,Us=si,Ws=li,Gs=ui,Ks=pi,qs=hi,Js=yi,Ys=Si,Xs=wi,Zs=Symbol.for(`effect/List`),Qs=e=>z(e),$s=(e=>u($n(e),Qs))(E),ec={[Zs]:Zs,_tag:`Cons`,toString(){return k(this.toJSON())},toJSON(){return{_id:`List`,_tag:`Cons`,values:Qs(this).map(O)}},[D](){return this.toJSON()},[T](e){return ac(e)&&this._tag===e._tag&&$s(this,e)},[b](){return w(this,Me(Qs(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 A(this,arguments)}},tc=(e,t)=>{let n=Object.create(ec);return n.head=e,n.tail=t,n},nc=C(`Nil`),rc={[Zs]:Zs,_tag:`Nil`,toString(){return k(this.toJSON())},toJSON(){return{_id:`List`,_tag:`Nil`}},[D](){return this.toJSON()},[b](){return nc},[T](e){return ac(e)&&this._tag===e._tag},[Symbol.iterator](){return{next(){return{done:!0,value:void 0}}}},pipe(){return A(this,arguments)}},ic=Object.create(rc),ac=e=>y(e,Zs),oc=e=>e._tag===`Nil`,sc=e=>e._tag===`Cons`,cc=()=>ic,lc=(e,t)=>tc(e,t),uc=cc,dc=e=>tc(e,ic),fc=t(2,(e,t)=>mc(t,e)),pc=t(2,(e,t)=>lc(t,e)),mc=t(2,(e,t)=>{if(oc(e))return t;if(oc(t))return e;{let n=tc(t.head,e),r=n,i=t.tail;for(;!oc(i);){let t=tc(i.head,e);r.tail=t,r=t,i=i.tail}return n}}),hc=t(3,(e,t,n)=>{let r=t,i=e;for(;!oc(i);)r=n(r,i.head),i=i.tail;return r}),gc=e=>{let t=uc(),n=e;for(;!oc(n);)t=pc(t,n.head),n=n.tail;return t};Array.prototype;const _c=function(){function e(e){e&&Object.assign(this,e)}return e.prototype=_t,e}();({..._c.prototype});const vc=Symbol.for(`effect/DifferContextPatch`);function yc(e){return e}const bc={..._c.prototype,[vc]:{_Value:yc,_Patch:yc}},xc=Object.assign(Object.create(bc),{_tag:`Empty`}),Sc=Object.create(xc),Cc=()=>Sc,wc=Object.assign(Object.create(bc),{_tag:`AndThen`}),Tc=(e,t)=>{let n=Object.create(wc);return n.first=e,n.second=t,n},Ec=Object.assign(Object.create(bc),{_tag:`AddService`}),Dc=(e,t)=>{let n=Object.create(Ec);return n.key=e,n.service=t,n},Oc=Object.assign(Object.create(bc),{_tag:`RemoveService`}),kc=e=>{let t=Object.create(Oc);return t.key=e,t},Ac=Object.assign(Object.create(bc),{_tag:`UpdateService`}),jc=(e,t)=>{let n=Object.create(Ac);return n.key=e,n.update=t,n},Mc=(e,t)=>{let n=new Map(e.unsafeMap),r=Cc();for(let[e,i]of t.unsafeMap.entries())if(n.has(e)){let t=n.get(e);n.delete(e),E(t,i)||(r=Nc(jc(e,()=>i))(r))}else n.delete(e),r=Nc(Dc(e,i))(r);for(let[e]of n.entries())r=Nc(kc(e))(r);return r},Nc=t(2,(e,t)=>Tc(e,t)),Pc=t(2,(e,t)=>{if(e._tag===`Empty`)return t;let n=!1,r=fr(e),i=new Map(t.unsafeMap);for(;Er(r);){let e=kr(r),t=Ar(r);switch(e._tag){case`Empty`:r=t;break;case`AddService`:i.set(e.key,e.service),r=t;break;case`AndThen`:r=Sr(Sr(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 lo(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 lo(a)});({..._c.prototype});const Fc=Symbol.for(`effect/DifferHashSetPatch`);function Ic(e){return e}const Lc={..._c.prototype,[Fc]:{_Value:Ic,_Key:Ic,_Patch:Ic}},Rc=Object.assign(Object.create(Lc),{_tag:`Empty`}),zc=Object.create(Rc),Bc=()=>zc,Vc=Object.assign(Object.create(Lc),{_tag:`AndThen`}),Hc=(e,t)=>{let n=Object.create(Vc);return n.first=e,n.second=t,n},Uc=Object.assign(Object.create(Lc),{_tag:`Add`}),Wc=e=>{let t=Object.create(Uc);return t.value=e,t},Gc=Object.assign(Object.create(Lc),{_tag:`Remove`}),Kc=e=>{let t=Object.create(Gc);return t.value=e,t},qc=(e,t)=>{let[n,r]=ra([e,Bc()],([e,t],n)=>Xi(n)(e)?[ea(n)(e),t]:[e,Jc(Wc(n))(t)])(t);return ra(r,(e,t)=>Jc(Kc(t))(e))(n)},Jc=t(2,(e,t)=>Hc(e,t)),Yc=t(2,(e,t)=>{if(e._tag===`Empty`)return t;let n=t,r=fr(e);for(;Er(r);){let e=kr(r),t=Ar(r);switch(e._tag){case`Empty`:r=t;break;case`AndThen`:r=Sr(e.first)(Sr(e.second)(t));break;case`Add`:n=$i(e.value)(n),r=t;break;case`Remove`:n=ea(e.value)(n),r=t}}return n});({..._c.prototype});const Xc=Symbol.for(`effect/DifferReadonlyArrayPatch`);function Zc(e){return e}const Qc={..._c.prototype,[Xc]:{_Value:Zc,_Patch:Zc}},$c=Object.assign(Object.create(Qc),{_tag:`Empty`}),el=Object.create($c),tl=()=>el,nl=Object.assign(Object.create(Qc),{_tag:`AndThen`}),rl=(e,t)=>{let n=Object.create(nl);return n.first=e,n.second=t,n},il=Object.assign(Object.create(Qc),{_tag:`Append`}),al=e=>{let t=Object.create(il);return t.values=e,t},ol=Object.assign(Object.create(Qc),{_tag:`Slice`}),sl=(e,t)=>{let n=Object.create(ol);return n.from=e,n.until=t,n},cl=Object.assign(Object.create(Qc),{_tag:`Update`}),ll=(e,t)=>{let n=Object.create(cl);return n.index=e,n.patch=t,n},ul=e=>{let t=0,n=tl();for(;t<e.oldValue.length&&t<e.newValue.length;){let r=e.oldValue[t],i=e.newValue[t],a=e.differ.diff(r,i);E(a,e.differ.empty)||(n=dl(n,ll(t,a))),t+=1}return t<e.oldValue.length&&(n=dl(n,sl(0,t))),t<e.newValue.length&&(n=dl(n,al(Pn(t)(e.newValue)))),n},dl=t(2,(e,t)=>rl(e,t)),fl=t(3,(e,t,n)=>{if(e._tag===`Empty`)return t;let r=t.slice(),i=Kn(e);for(;Sn(i);){let e=On(i),t=jn(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}),pl={[Symbol.for(`effect/Differ`)]:{_P:n,_V:n},pipe(){return A(this,arguments)}},ml=e=>{let t=Object.create(pl);return t.empty=e.empty,t.diff=e.diff,t.combine=e.combine,t.patch=e.patch,t},hl=()=>ml({empty:Cc(),combine:(e,t)=>Nc(t)(e),diff:(e,t)=>Mc(e,t),patch:(e,t)=>Pc(t)(e)}),gl=()=>ml({empty:Bc(),combine:(e,t)=>Jc(t)(e),diff:(e,t)=>qc(e,t),patch:(e,t)=>Yc(t)(e)}),_l=e=>ml({empty:tl(),combine:(e,t)=>dl(e,t),diff:(t,n)=>ul({oldValue:t,newValue:n,differ:e}),patch:(t,n)=>fl(t,n,e)}),vl=()=>yl((e,t)=>t),yl=e=>ml({empty:n,combine:(e,t)=>e===n?t:t===n?e:n=>t(e(n)),diff:(e,t)=>E(e,t)?n:r(t),patch:(t,n)=>e(n,t(n))}),bl=e=>e&255,xl=e=>e>>8&255,Sl=(e,t)=>(e&255)+((t&e&255)<<8),Cl=Sl(0,0),wl=e=>Sl(e,e),Tl=e=>Sl(e,0),El=t(2,(e,t)=>Sl(bl(e)&~t,xl(e))),Dl=t(2,(e,t)=>e|t),Ol=e=>~e>>>0&255,kl=e=>Nl(e,32),Al=t(2,(e,t)=>e|t),jl=e=>Ml(e)&&!Ll(e),Ml=e=>Nl(e,1),Nl=t(2,(e,t)=>(e&t)!==0),Pl=(...e)=>e.reduce((e,t)=>e|t,0),Fl=Pl(0),Il=e=>Nl(e,4),Ll=e=>Nl(e,16),Rl=t(2,(e,t)=>Sl(e^t,t)),zl=t(2,(e,t)=>e&(Ol(bl(t))|xl(t))|bl(t)&xl(t)),Bl=ml({empty:Cl,diff:(e,t)=>Rl(e,t),combine:(e,t)=>Dl(t)(e),patch:(e,t)=>zl(t,e)}),Vl=wl,Hl=Tl,Ul=El,Wl=(e,t)=>({_tag:`Par`,left:e,right:t}),Gl=(e,t)=>({_tag:`Seq`,left:e,right:t}),Kl=e=>{let t=dc(e),n=uc();for(;;){let[e,r]=hc(t,[Ql(),uc()],([e,t],n)=>{let[r,i]=ql(n);return[eu(e,r),fc(t,i)]});if(n=Jl(n,e),oc(r))return gc(n);t=r}throw Error(`BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues`)},ql=e=>{let t=e,n=Ql(),r=uc(),i=uc();for(;;)switch(t._tag){case`Empty`:if(oc(r))return[n,i];t=r.head,r=r.tail;break;case`Par`:r=lc(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=Wl(Gl(r,n),Gl(i,n));break}case`Seq`:{let r=e.left,i=e.right;t=Gl(r,Gl(i,n));break}case`Single`:t=e,i=lc(n,i);break}break}case`Single`:if(n=$l(n,t),oc(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`)},Jl=(e,t)=>{if(oc(e))return dc(ru(t));if(tu(t))return e;let n=lu(e.head),r=nu(t);return n.length===1&&r.length===1&&E(n[0],r[0])?lc(cu(e.head,ru(t)),e.tail):lc(ru(t),e)},Yl=Symbol.for(`effect/RequestBlock/RequestBlockParallel`),Xl={_R:e=>e};var Zl=class{map;[Yl]=Xl;constructor(e){this.map=e}};const Ql=()=>new Zl(Hs()),$l=(e,t)=>new Zl(Js(e.map,t.dataSource,e=>en(on(e,xr(t.blockedRequest)),()=>fr(t.blockedRequest)))),eu=(e,t)=>new Zl(Xs(e.map,t.map,(e,t,n)=>Ks(e,n,Qt(Gs(e,n),{onNone:()=>t,onSome:e=>wr(t,e)})))),tu=e=>Ws(e.map),nu=e=>Array.from(qs(e.map)),ru=e=>su(Ys(e.map,e=>fr(e))),iu=Symbol.for(`effect/RequestBlock/RequestBlockSequential`),au={_R:e=>e};var ou=class{map;[iu]=au;constructor(e){this.map=e}};const su=e=>new ou(e),cu=(e,t)=>new ou(Xs(t.map,e.map,(e,t,n)=>Ks(e,n,Qt(Gs(e,n),{onNone:()=>ur(),onSome:e=>wr(e,t)})))),lu=e=>Array.from(qs(e.map)),uu=e=>Array.from(e.map),du=`Pending`,fu=`Done`,pu=Symbol.for(`effect/Deferred`),mu={_E:e=>e,_A:e=>e},hu=e=>({_tag:du,joiners:e}),gu=e=>({_tag:fu,effect:e});var _u=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 vu=(e,t)=>{let n=new H(`Blocked`);return n.effect_instruction_i0=e,n.effect_instruction_i1=t,n},yu=e=>{let t=new H(`RunBlocked`);return t.effect_instruction_i0=e,t},bu=Symbol.for(`effect/Effect`);var xu=class{patch;op;_op=st;constructor(e,t){this.patch=e,this.op=t}},H=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[bu]=pt;constructor(e){this._op=e}[T](e){return this===e}[b](){return w(this,Ee(this))}pipe(){return A(this,arguments)}toJSON(){return{_id:`Effect`,_op:this._op,effect_instruction_i0:O(this.effect_instruction_i0),effect_instruction_i1:O(this.effect_instruction_i1),effect_instruction_i2:O(this.effect_instruction_i2)}}toString(){return k(this.toJSON())}[D](){return this.toJSON()}[Symbol.iterator](){return new _u(new be(this))}},Su=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[bu]=pt;constructor(e){this._op=e,this._tag=e}[T](e){return Sf(e)&&e._op===`Failure`&&E(this.effect_instruction_i0,e.effect_instruction_i0)}[b](){return c(C(this._tag),S(x(this.effect_instruction_i0)),w(this))}get cause(){return this.effect_instruction_i0}pipe(){return A(this,arguments)}toJSON(){return{_id:`Exit`,_tag:this._op,cause:this.cause.toJSON()}}toString(){return k(this.toJSON())}[D](){return this.toJSON()}[Symbol.iterator](){return new _u(new be(this))}},Cu=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[bu]=pt;constructor(e){this._op=e,this._tag=e}[T](e){return Sf(e)&&e._op===`Success`&&E(this.effect_instruction_i0,e.effect_instruction_i0)}[b](){return c(C(this._tag),S(x(this.effect_instruction_i0)),w(this))}get value(){return this.effect_instruction_i0}pipe(){return A(this,arguments)}toJSON(){return{_id:`Exit`,_tag:this._op,value:O(this.value)}}toString(){return k(this.toJSON())}[D](){return this.toJSON()}[Symbol.iterator](){return new _u(new be(this))}};const wu=e=>y(e,bu),U=e=>{let t=new H(at);return t.effect_instruction_i0=e,t},Tu=t(3,(e,t,n)=>ud(r=>W(e,e=>W(Ru(q(()=>r(t(e)))),t=>q(()=>n(e,t)).pipe(Ju({onFailure:e=>{switch(t._tag){case Xe:return Vu(va(t.effect_instruction_i0,e));case et:return Vu(e)}},onSuccess:()=>t})))))),Eu=t(2,(e,t)=>W(e,()=>K(t))),Du=e=>Eu(e,void 0),Ou=function(){let e=new H(Ye);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(me(`you're not supposed to end up here`))}return e},ku=(e,t=zs)=>{let n=new H(Je),r;return n.effect_instruction_i0=t=>{r=e(t)},n.effect_instruction_i1=t,nd(n,e=>wu(r)?r:Y)},Au=(e,t=zs)=>q(()=>ku(e,t)),ju=(e,t=zs)=>Ou(e,function(){let e,n;function r(t){e?e(t):n===void 0&&(n=t)}let i=new H(Je);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=we(()=>this.effect_instruction_i0(r)):(o=new AbortController,a=we(()=>this.effect_instruction_i0(r,o.signal))),a||o?nd(i,e=>(o&&o.abort(),a??Y)):i}),Mu=t(2,(e,t)=>Yu(e,{onFailure:t,onSuccess:K})),Nu=Symbol.for(`effect/OriginalAnnotation`),Pu=(e,t)=>L(t)?new Proxy(e,{has(e,t){return t===Qa||t===Nu||t in e},get(n,r){return r===Qa?t.value:r===Nu?e:n[r]}}):e,Fu=e=>ae(e)&&!(Qa in e)?U(t=>Vu(ha(Pu(e,Qf(t))))):Vu(ha(e)),Iu=e=>Hu(()=>ha(new hf(e))),Lu=e=>Yu(e,{onFailure:e=>K(M(e)),onSuccess:e=>K(j(e))}),Ru=e=>qu(e,{onFailure:X,onSuccess:Z}),zu=e=>ae(e)&&!(Qa in e)?U(t=>Vu(ma(Pu(e,Qf(t))))):Vu(ma(e)),Bu=e=>W(J(e),zu),Vu=e=>{let t=new Su(Xe);return t.effect_instruction_i0=e,t},Hu=e=>W(J(e),Vu),Uu=U(e=>K(e.id())),Wu=e=>U(t=>e(t.id())),W=t(2,(e,t)=>{let n=new H(Qe);return n.effect_instruction_i0=e,n.effect_instruction_i1=t,n}),Gu=e=>{let t=new H(`OnStep`);return t.effect_instruction_i0=e,t},Ku=e=>W(e,n),qu=t(2,(e,t)=>Ju(e,{onFailure:e=>K(t.onFailure(e)),onSuccess:e=>K(t.onSuccess(e))})),Ju=t(2,(e,t)=>{let n=new H($e);return n.effect_instruction_i0=e,n.effect_instruction_i1=t.onFailure,n.effect_instruction_i2=t.onSuccess,n}),Yu=t(2,(e,t)=>Ju(e,{onFailure:e=>{if(Ea(e).length>0)return Vu(Na(e));let n=Ta(e);return n.length>0?t.onFailure(Or(n)):Vu(e)},onSuccess:t.onSuccess})),Xu=t(2,(e,t)=>q(()=>{let n=z(e),r=pn(n.length),i=0;return Eu(pd({while:()=>i<n.length,body:()=>t(n[i],i),step:e=>{r[i++]=e}}),r)})),Zu=t(2,(e,t)=>q(()=>{let n=z(e),r=0;return pd({while:()=>r<n.length,body:()=>t(n[r],r),step:()=>{r++}})})),Qu=e=>{let t=new H(nt);return t.effect_instruction_i0=Vl(1),t.effect_instruction_i1=()=>e,t},G=t(2,(e,t)=>W(e,e=>J(()=>t(e)))),$u=t(2,(e,t)=>Yu(e,{onFailure:e=>Bu(()=>t.onFailure(e)),onSuccess:e=>J(()=>t.onSuccess(e))})),ed=t(2,(e,t)=>Ju(e,{onFailure:e=>{let n=ka(e);switch(n._tag){case`Left`:return Bu(()=>t(n.left));case`Right`:return Vu(n.right)}},onSuccess:K})),td=t(2,(e,t)=>ud(n=>Ju(n(e),{onFailure:e=>{let n=X(e);return Ju(t(n),{onFailure:t=>X(va(e,t)),onSuccess:()=>n})},onSuccess:e=>{let n=Z(e);return bd(t(n),n)}}))),nd=t(2,(e,t)=>td(e,Nf({onFailure:e=>wa(e)?Du(t(Da(e))):Y,onSuccess:()=>Y}))),rd=t(2,(e,t)=>cd(e,t,K)),id=e=>ad(e,n),ad=t(2,(e,t)=>Yu(e,{onFailure:e=>Fu(t(e)),onSuccess:K})),K=e=>{let t=new Cu(et);return t.effect_instruction_i0=e,t},q=e=>{let t=new H(Ye);return t.commit=e,t},J=e=>{let t=new H(tt);return t.effect_instruction_i0=e,t},od=t(e=>e.length===3||e.length===2&&!(ae(e[1])&&`onlyEffect`in e[1]),(e,t)=>W(e,e=>{let n=typeof t==`function`?t(e):t;return wu(n)?Eu(n,e):pe(n)?ku(t=>{n.then(n=>t(K(e)),e=>t(zu(new xf(e,`An unknown error occurred in Effect.tap`))))}):K(e)})),sd=e=>U(t=>e(Rd(rf,F(c(t.getFiberRef(rf),R(()=>t.scope())))))),cd=t(3,(e,t,n)=>Ju(e,{onFailure:e=>Ea(e).length>0?Vu(an(ja(e))):t(),onSuccess:n})),ld=e=>{let t=new H(nt);return t.effect_instruction_i0=Hl(1),t.effect_instruction_i1=()=>e,t},ud=e=>Ou(e,function(){let e=new H(nt);return e.effect_instruction_i0=Hl(1),e.effect_instruction_i1=e=>Ml(e)?we(()=>this.effect_instruction_i0(Qu)):we(()=>this.effect_instruction_i0(ld)),e}),Y=K(void 0),dd=e=>{let t=new H(nt);return t.effect_instruction_i0=e,t.effect_instruction_i1=void 0,t},fd=t(2,(e,t)=>W(t,t=>t?c(e,G(F)):K(P()))),pd=e=>{let t=new H(rt);return t.effect_instruction_i0=e.while,t.effect_instruction_i1=e.body,t.effect_instruction_i2=e.step,t},md=e=>q(()=>{let t=new H(it);return t.effect_instruction_i0=e(),t}),hd=function(){let e=arguments.length===1?arguments[0]:arguments[1].bind(arguments[0]);return md(()=>e(c))},gd=(e,...t)=>Object.defineProperty(t.length===0?function(...t){return md(()=>e.apply(this,t))}:function(...n){let r=md(()=>e.apply(this,n));for(let e of t)r=e(r,...n);return r},`length`,{value:e.length,configurable:!0}),_d=e=>{let t=new H(ot);return e?.priority===void 0?t:Zd(t,e.priority)},vd=t(2,(e,t)=>W(e,e=>G(t,t=>[e,t]))),yd=t(2,(e,t)=>W(e,e=>Eu(t,e))),bd=t(2,(e,t)=>W(e,()=>t)),xd=t(3,(e,t,n)=>W(e,e=>G(t,t=>n(e,t)))),Sd=e=>W(Uu,t=>c(e,Cd(t))),Cd=t(2,(e,t)=>W(e.interruptAsFork(t),()=>e.await)),wd={_tag:`All`,syslog:0,label:`ALL`,ordinal:-(2**53-1),pipe(){return A(this,arguments)}},Td={_tag:`Fatal`,syslog:2,label:`FATAL`,ordinal:5e4,pipe(){return A(this,arguments)}},Ed={_tag:`Error`,syslog:3,label:`ERROR`,ordinal:4e4,pipe(){return A(this,arguments)}},Dd={_tag:`Warning`,syslog:4,label:`WARN`,ordinal:3e4,pipe(){return A(this,arguments)}},Od={_tag:`Info`,syslog:6,label:`INFO`,ordinal:2e4,pipe(){return A(this,arguments)}},kd={_tag:`Debug`,syslog:7,label:`DEBUG`,ordinal:1e4,pipe(){return A(this,arguments)}},Ad={_tag:`Trace`,syslog:7,label:`TRACE`,ordinal:0,pipe(){return A(this,arguments)}},jd={_tag:`None`,syslog:7,label:`OFF`,ordinal:2**53-1,pipe(){return A(this,arguments)}},Md=Symbol.for(`effect/FiberRef`),Nd={_A:e=>e},Pd=e=>U(t=>Z(t.getFiberRef(e))),Fd=t(2,(e,t)=>W(Pd(e),t)),Id=t(2,(e,t)=>Ld(e,()=>[void 0,t])),Ld=t(2,(e,t)=>U(n=>{let[r,i]=t(n.getFiberRef(e));return n.setFiberRef(e,i),K(r)})),Rd=t(3,(e,t,n)=>Tu(yd(Pd(t),Id(t,n)),()=>e,e=>Id(t,e))),zd=(e,t)=>Ud(e,{differ:vl(),fork:t?.fork??n,join:t?.join}),Bd=e=>{let t=gl();return Ud(e,{differ:t,fork:t.empty})},Vd=e=>{let t=_l(vl());return Ud(e,{differ:t,fork:t.empty})},Hd=e=>{let t=hl();return Ud(e,{differ:t,fork:t.empty})},Ud=(e,t)=>({...vt,[Md]:Nd,initial:e,commit(){return Pd(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)}),Wd=e=>Ud(e,{differ:Bl,fork:Bl.empty}),Gd=m(Symbol.for(`effect/FiberRef/currentContext`),()=>Hd(Do())),Kd=m(Symbol.for(`effect/FiberRef/currentSchedulingPriority`),()=>zd(0)),qd=m(Symbol.for(`effect/FiberRef/currentMaxOpsBeforeYield`),()=>zd(2048)),Jd=m(Symbol.for(`effect/FiberRef/currentLogAnnotation`),()=>zd(Hs())),Yd=m(Symbol.for(`effect/FiberRef/currentLogLevel`),()=>zd(Od)),Xd=m(Symbol.for(`effect/FiberRef/currentLogSpan`),()=>zd(uc())),Zd=t(2,(e,t)=>Rd(e,Kd,t)),Qd=m(Symbol.for(`effect/FiberRef/currentConcurrency`),()=>zd(`unbounded`)),$d=m(Symbol.for(`effect/FiberRef/currentRequestBatching`),()=>zd(!0)),ef=m(Symbol.for(`effect/FiberRef/currentUnhandledErrorLogLevel`),()=>zd(F(kd))),tf=m(Symbol.for(`effect/FiberRef/versionMismatchErrorLogLevel`),()=>zd(F(Dd))),nf=m(Symbol.for(`effect/FiberRef/currentMetricLabels`),()=>Vd(Gn())),rf=m(Symbol.for(`effect/FiberRef/currentForkScopeOverride`),()=>zd(P(),{fork:()=>P(),join:(e,t)=>e})),af=m(Symbol.for(`effect/FiberRef/currentInterruptedCause`),()=>zd(pa,{fork:()=>pa,join:(e,t)=>e})),of=Symbol.for(`effect/Scope`),sf=Symbol.for(`effect/CloseableScope`),cf=(e,t)=>e.addFinalizer(()=>Du(t)),lf=(e,t)=>e.addFinalizer(t),uf=(e,t)=>e.close(t),df=(e,t)=>e.fork(t),ff=function(){class e extends globalThis.Error{commit(){return zu(this)}toJSON(){let e={...this};return this.message&&(e.message=this.message),this.cause&&(e.cause=this.cause),e}[D](){return this.toString===globalThis.Error.prototype.toString?`Bun`in globalThis?Ga(ma(this),{renderErrorCause:!0}):this:this.stack?`${this.toString()}\n${this.stack.split(` `).slice(1).join(` `)}`:this.toString()}}return Object.assign(e.prototype,yt),e}(),pf=(e,t)=>{class n extends ff{_tag=t}return Object.assign(n.prototype,e),n.prototype.name=t,n},mf=Symbol.for(`effect/Cause/errors/RuntimeException`),hf=pf({[mf]:mf},`RuntimeException`),gf=Symbol.for(`effect/Cause/errors/InterruptedException`),_f=e=>y(e,gf),vf=Symbol.for(`effect/Cause/errors/NoSuchElement`),yf=pf({[vf]:vf},`NoSuchElementException`),bf=Symbol.for(`effect/Cause/errors/UnknownException`),xf=function(){class e extends ff{_tag=`UnknownException`;error;constructor(e,t){super(t??`An unknown error occurred`,{cause:e}),this.error=e}}return Object.assign(e.prototype,{[bf]:bf,name:`UnknownException`}),e}(),Sf=e=>wu(e)&&`_tag`in e&&(e._tag===`Success`||e._tag===`Failure`),Cf=e=>e._tag===`Success`,wf=t(2,(e,t)=>{switch(e._tag){case Xe:return X(e.effect_instruction_i0);case et:return Z(t)}}),Tf=e=>wf(e,void 0),Ef=(e,t)=>Lf(e,t?.parallel?_a:va),Df=e=>X(ha(e)),Of=e=>X(ma(e)),X=e=>{let t=new Su(Xe);return t.effect_instruction_i0=e,t},kf=t(2,(e,t)=>{switch(e._tag){case Xe:return X(e.effect_instruction_i0);case et:return t(e.effect_instruction_i0)}}),Af=e=>c(e,kf(n)),jf=e=>X(ga(e)),Mf=t(2,(e,t)=>{switch(e._tag){case Xe:return X(e.effect_instruction_i0);case et:return Z(t(e.effect_instruction_i0))}}),Nf=t(2,(e,{onFailure:t,onSuccess:n})=>{switch(e._tag){case Xe:return t(e.effect_instruction_i0);case et:return n(e.effect_instruction_i0)}}),Pf=t(2,(e,{onFailure:t,onSuccess:n})=>{switch(e._tag){case Xe:return t(e.effect_instruction_i0);case et:return n(e.effect_instruction_i0)}}),Z=e=>{let t=new Cu(et);return t.effect_instruction_i0=e,t},Ff=Z(void 0),If=t(3,(e,t,{onFailure:n,onSuccess:r})=>{switch(e._tag){case Xe:switch(t._tag){case et:return X(e.effect_instruction_i0);case Xe:return X(n(e.effect_instruction_i0,t.effect_instruction_i0))}case et:switch(t._tag){case et:return Z(r(e.effect_instruction_i0,t.effect_instruction_i0));case Xe:return X(t.effect_instruction_i0)}}}),Lf=(e,t)=>{let n=pr(e);return Er(n)?c(Ar(n),Zn(c(kr(n),Mf(fr)),(e,n)=>c(e,If(n,{onSuccess:(e,t)=>c(e,Sr(t)),onFailure:t}))),Mf(gr),Mf(e=>hr(e)),F):P()},Rf=e=>({...vt,[pu]:mu,state:bs(hu([])),commit(){return Vf(this)},blockingOn:e}),zf=()=>W(Uu,e=>Bf(e)),Bf=e=>J(()=>Rf(e)),Vf=e=>Au(t=>{let n=xs(e.state);switch(n._tag){case fu:return t(n.effect);case du:return n.joiners.push(t),Kf(e,t)}},e.blockingOn),Hf=t(2,(e,t)=>J(()=>{let n=xs(e.state);switch(n._tag){case fu:return!1;case du:Ss(e.state,gu(t));for(let e=0,r=n.joiners.length;e<r;e++)n.joiners[e](t);return!0}})),Uf=t(2,(e,t)=>Hf(e,Vu(t))),Wf=t(2,(e,t)=>Hf(e,K(t))),Gf=(e,t)=>{let n=xs(e.state);if(n._tag===du){Ss(e.state,gu(t));for(let e=0,r=n.joiners.length;e<r;e++)n.joiners[e](t)}},Kf=(e,t)=>J(()=>{let n=xs(e.state);if(n._tag===du){let e=n.joiners.indexOf(t);e>=0&&n.joiners.splice(e,1)}}),qf=U(e=>Z(e.currentContext)),Jf=()=>qf,Yf=e=>W(Jf(),e),Xf=t(2,(e,t)=>Rd(Gd,t)(e)),Zf=t(2,(e,t)=>Yf(n=>Xf(e,t(n)))),Qf=e=>{let t=e.currentSpan;return t!==void 0&&t._tag===`Span`?F(t):P()},$f=xa,ep=Ga,tp=`InvalidData`,np=`MissingData`,rp=`SourceUnavailable`,ip=`Unsupported`,ap=Symbol.for(`effect/ConfigError`),op={_tag:`ConfigError`,[ap]:ap},sp=(e,t)=>{let n=Object.create(op);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},cp=(e,t)=>{let n=Object.create(op);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},lp=(e,t,n={pathDelim:`.`})=>{let r=Object.create(op);return r._op=tp,r.path=e,r.message=t,Object.defineProperty(r,`toString`,{enumerable:!1,value(){return`(Invalid data at ${c(this.path,nr(n.pathDelim))}: "${this.message}")`}}),r},up=(e,t,n={pathDelim:`.`})=>{let r=Object.create(op);return r._op=np,r.path=e,r.message=t,Object.defineProperty(r,`toString`,{enumerable:!1,value(){return`(Missing data at ${c(this.path,nr(n.pathDelim))}: "${this.message}")`}}),r},dp=(e,t,n,r={pathDelim:`.`})=>{let i=Object.create(op);return i._op=rp,i.path=e,i.message=t,i.cause=n,Object.defineProperty(i,`toString`,{enumerable:!1,value(){return`(Source unavailable at ${c(this.path,nr(r.pathDelim))}: "${this.message}")`}}),i},fp=(e,t,n={pathDelim:`.`})=>{let r=Object.create(op);return r._op=ip,r.path=e,r.message=t,Object.defineProperty(r,`toString`,{enumerable:!1,value(){return`(Unsupported operation at ${c(this.path,nr(n.pathDelim))}: "${this.message}")`}}),r},pp=t(2,(e,t)=>{switch(e._op){case`And`:return sp(pp(e.left,t),pp(e.right,t));case`Or`:return cp(pp(e.left,t),pp(e.right,t));case tp:return lp([...t,...e.path],e.message);case np:return up([...t,...e.path],e.message);case rp:return dp([...t,...e.path],e.message,e.cause);case ip:return fp([...t,...e.path],e.message)}}),mp=Symbol.for(`effect/Clock`),hp=Eo(`effect/Clock`),gp=2**31-1,_p={unsafeSchedule(e,t){let n=ss(t);if(n>gp)return a;let r=!1,i=setTimeout(()=>{r=!0,e()},n);return()=>(clearTimeout(i),!r)}},vp=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)))}(),yp=function(){let e=typeof process==`object`&&`hrtime`in process&&typeof process.hrtime.bigint==`function`?process.hrtime:void 0;if(!e)return vp;let t=vp()-e.bigint();return()=>t+e.bigint()}();var bp=class{[mp]=mp;unsafeCurrentTimeMillis(){return Date.now()}unsafeCurrentTimeNanos(){return yp()}currentTimeMillis=J(()=>this.unsafeCurrentTimeMillis());currentTimeNanos=J(()=>this.unsafeCurrentTimeNanos());scheduler(){return K(_p)}sleep(e){return ju(t=>Du(J(_p.unsafeSchedule(()=>t(Y),e))))}};const xp=()=>new bp,Sp=Yt,Cp=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,`\\$&`),wp={_tag:`Empty`},Tp=t(2,(e,t)=>{let n=dc(t),r=e;for(;sc(n);){let e=n.head;switch(e._tag){case`Empty`:n=n.tail;break;case`AndThen`:n=lc(e.first,lc(e.second,n.tail));break;case`MapName`:r=qn(r,e.f),n=n.tail;break;case`Nested`:r=_n(r,e.name),n=n.tail;break;case`Unnested`:if(c(Dn(r),ln(e.name)))r=jn(r),n=n.tail;else return M(up(r,`Expected ${e.name} to be in path in ConfigProvider#unnested`));break}}return j(r)}),Ep=(e,t)=>[...e,...t],Dp=Symbol.for(`effect/ConfigProvider`),Op=Eo(`effect/ConfigProvider`),kp=Symbol.for(`effect/ConfigProviderFlat`),Ap=e=>({[Dp]:Dp,pipe(){return A(this,arguments)},...e}),jp=e=>({[kp]:kp,patch:e.patch,load:(t,n,r=!0)=>e.load(t,n,r),enumerateChildren:e.enumerateChildren}),Mp=e=>Ap({load:t=>W(Ip(e,Gn(),t,!1),e=>Qt(Dn(e),{onNone:()=>zu(up(Gn(),`Expected a single value having structure: ${t}`)),onSome:K})),flattened:e}),Np=e=>{let{pathDelim:t,seqDelim:n}=Object.assign({},{pathDelim:`_`,seqDelim:`,`},e),r=e=>c(e,nr(t)),i=e=>e.split(t),a=()=>typeof process<`u`&&`env`in process&&typeof process.env==`object`?process.env:{};return Mp(jp({load:(e,t,i=!0)=>{let o=r(e),s=a();return c(o in s?F(s[o]):P(),ed(()=>up(e,`Expected ${o} to exist in the process context`)),W(r=>zp(r,e,t,n,i)))},enumerateChildren:e=>J(()=>{let t=a();return Ji(Object.keys(t).map(e=>i(e.toUpperCase())).filter(t=>{for(let n=0;n<e.length;n++){let r=c(e,En(n)),i=t[n];if(i===void 0||r!==i)return!1}return!0}).flatMap(t=>t.slice(e.length,e.length+1)))}),patch:wp}))},Pp=(e,t,n,r)=>{let i=Qn(n.length,t=>t>=r.length?P():F([e(t),t+1])),a=Qn(r.length,e=>e>=n.length?P():F([t(e),e+1]));return[Ep(n,i),Ep(r,a)]},Fp=(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},Ip=(e,t,n,r)=>{let i=n;switch(i._tag){case`Constant`:return K(Kn(i.value));case`Described`:return q(()=>Ip(e,t,i.config,r));case`Fail`:return zu(up(t,i.message));case`Fallback`:return c(q(()=>Ip(e,t,i.first,r)),Mu(n=>i.condition(n)?c(Ip(e,t,i.second,r),Mu(e=>zu(cp(n,e)))):zu(n)));case`Lazy`:return q(()=>Ip(e,t,i.config(),r));case`MapOrFail`:return q(()=>c(Ip(e,t,i.original,r),W(Xu(e=>c(i.mapOrFail(e),ed(pp(Fp(t,i.original))))))));case`Nested`:return q(()=>Ip(e,Ep(t,Kn(i.name)),i.config,r));case`Primitive`:return c(Tp(t,e.patch),W(t=>c(e.load(t,i,r),W(e=>{if(e.length===0){let e=c(kn(t),R(()=>`<n/a>`));return zu(up([],`Expected ${i.description} with name ${e}`))}return K(e)}))));case`Sequence`:return c(Tp(t,e.patch),W(n=>c(e.enumerateChildren(n),W(Vp),W(n=>n.length===0?q(()=>G(Ip(e,t,i.config,!0),Kn)):c(Xu(n,n=>Ip(e,vn(t,`[${n}]`),i.config,!0)),G(e=>{let t=Yn(e);return t.length===0?Kn(Gn()):Kn(t)}))))));case`HashMap`:return q(()=>c(Tp(t,e.patch),W(t=>c(e.enumerateChildren(t),W(n=>c(n,Xu(n=>Ip(e,Ep(t,Kn(n)),i.valueConfig,r)),G(e=>e.length===0?Kn(Hs()):c(Bp(e),qn(e=>Us(Ln(z(n),e)))))))))));case`ZipWith`:return q(()=>c(Ip(e,t,i.left,r),Lu,W(n=>c(Ip(e,t,i.right,r),Lu,W(e=>{if(N(n)&&N(e))return zu(sp(n.left,e.left));if(N(n)&&Bt(e))return zu(n.left);if(Bt(n)&&N(e))return zu(e.left);if(Bt(n)&&Bt(e)){let r=Lp(t,c(t,nr(`.`))),[a,o]=Pp(r,r,c(n.right,qn(j)),c(e.right,qn(j)));return c(a,Ln(o),Xu(([e,t])=>c(vd(e,t),G(([e,t])=>i.zip(e,t)))))}throw Error(`BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues`)})))))}},Lp=(e,t)=>n=>M(up(e,`The element at index ${n} in a sequence at path "${t}" was missing`)),Rp=(e,t)=>e.split(RegExp(`\\s*${Cp(t)}\\s*`)),zp=(e,t,n,r,i)=>i?c(Rp(e,r),Xu(e=>n.parse(e.trim())),ed(pp(t))):c(n.parse(e),$u({onFailure:pp(t),onSuccess:Kn})),Bp=e=>Object.keys(e[0]).map(t=>e.map(e=>e[t])),Vp=e=>c(Xu(e,Up),$u({onFailure:()=>Gn(),onSuccess:In(Sp)}),Lu,G(Wt)),Hp=/^(\[(\d+)\])$/,Up=e=>{let t=e.match(Hp);if(t!==null){let e=t[2];return c(e!==void 0&&e.length>0?F(e):P(),sn(Wp))}return P()},Wp=e=>{let t=Number.parseInt(e);return Number.isNaN(t)?P():F(t)},Gp=Symbol.for(`effect/Console`),Kp=Eo(`effect/Console`),qp={[Gp]:Gp,assert(e,...t){return J(()=>{console.assert(e,...t)})},clear:J(()=>{console.clear()}),count(e){return J(()=>{console.count(e)})},countReset(e){return J(()=>{console.countReset(e)})},debug(...e){return J(()=>{console.debug(...e)})},dir(e,t){return J(()=>{console.dir(e,t)})},dirxml(...e){return J(()=>{console.dirxml(...e)})},error(...e){return J(()=>{console.error(...e)})},group(e){return e?.collapsed?J(()=>console.groupCollapsed(e?.label)):J(()=>console.group(e?.label))},groupEnd:J(()=>{console.groupEnd()}),info(...e){return J(()=>{console.info(...e)})},log(...e){return J(()=>{console.log(...e)})},table(e,t){return J(()=>{console.table(e,t)})},time(e){return J(()=>console.time(e))},timeEnd(e){return J(()=>console.timeEnd(e))},timeLog(e,...t){return J(()=>{console.timeLog(e,...t)})},trace(...e){return J(()=>{console.trace(...e)})},warn(...e){return J(()=>{console.warn(...e)})},unsafe:console},Jp=Symbol.for(`effect/Random`),Yp=Eo(`effect/Random`);var Xp=class{seed;[Jp]=Jp;PRNG;constructor(e){this.seed=e,this.PRNG=new ge(e)}get next(){return J(()=>this.PRNG.number())}get nextBoolean(){return G(this.next,e=>e>.5)}get nextInt(){return J(()=>this.PRNG.integer(2**53-1))}nextRange(e,t){return G(this.next,n=>(t-e)*n+e)}nextIntBetween(e,t){return J(()=>this.PRNG.integer(t-e)+e)}shuffle(e){return Zp(e,e=>this.nextIntBetween(0,e))}};const Zp=(e,t)=>q(()=>c(J(()=>Array.from(e)),W(e=>{let n=[];for(let t=e.length;t>=2;--t)n.push(t);return c(n,Zu(n=>c(t(n),G(t=>Qp(e,n-1,t)))),Eu(pr(e)))}))),Qp=(e,t,n)=>{let r=e[t];return e[t]=e[n],e[n]=r,e},$p=e=>new Xp(x(e)),em=Symbol.for(`effect/Tracer`),tm=e=>({[em]:em,...e}),nm=Eo(`effect/Tracer`),rm=Eo(`effect/ParentSpan`),im=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:im(32),this.spanId=im(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 om=tm({span:(e,t,n,r,i,a)=>new am(e,t,n,r,i,a),context:e=>e()}),sm=Fo()(`effect/Tracer/DisablePropagation`,{defaultValue:a}),cm=c(Do(),ko(hp,xp()),ko(Kp,qp),ko(Yp,$p(Math.random())),ko(Op,Np()),ko(nm,om)),lm=m(Symbol.for(`effect/DefaultServices/currentServices`),()=>Hd(cm)),um=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return{BaseEffectError:class extends ff{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}(),dm=e=>{let t={BaseEffectError:class extends um{_tag=e}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError},fm=gt,pm=bt;var mm=class extends pm{};const hm=`Sequential`,gm=`Parallel`,_m={_tag:hm},vm={_tag:gm},ym=e=>({_tag:`ParallelN`,parallelism:e}),bm=e=>e._tag===hm,xm=e=>e._tag===gm,Sm=_m,Cm=vm,wm=ym;function Tm(e){return new Om(e)}function Em(){return Tm(new Map)}const Dm=Symbol.for(`effect/FiberRefs`);var Om=class{locals;[Dm]=Dm;constructor(e){this.locals=e}pipe(){return A(this,arguments)}};const km=(e,t,n,r=!1)=>{let i=e,a=t,o=n,s=r,c;for(;c===void 0;)if(B(a)&&B(o)){let e=On(a)[0],t=jn(a),n=On(o)[0],r=On(o)[1],i=jn(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},Am=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][T](t)){if(!r.has(n)){if(E(i,n.initial))return;r.set(n,[[t,n.join(n.initial,i)]]);return}let a=r.get(n),[o,s]=km(n,a,e);if(s){let e=n.diff(o,i),s=a[0][1],c=n.join(s,n.patch(e)(s));if(!E(s,c)){let e,i=a[0][0];e=i[T](t)?[[i,c],...a.slice(1)]:[[t,c],...a],r.set(n,e)}}}}),new Om(r)}),jm=t(2,(e,t)=>{let n=new Map;return Mm(e,n,t),new Om(n)}),Mm=(e,t,n)=>{e.locals.forEach((e,r)=>{let i=e[0][1],a=r.patch(r.fork)(i);E(i,a)?t.set(r,e):t.set(r,[[n,a],...e])})},Nm=t(2,(e,t)=>{let n=new Map(e.locals);return n.delete(t),new Om(n)}),Pm=t(2,(e,t)=>e.locals.has(t)?F(On(e.locals.get(t))[1]):P()),Fm=t(2,(e,t)=>c(Pm(e,t),R(()=>t.initial))),Im=t(2,(e,{fiberId:t,fiberRef:n,value:r})=>{if(e.locals.size===0)return new Om(new Map([[n,[[t,r]]]]));let i=new Map(e.locals);return Lm(i,t,n,r),new Om(i)}),Lm=(e,t,n,r)=>{let i=e.get(n)??[],a;if(B(i)){let[e,n]=On(i);if(e[T](t)){if(E(n,r))return;a=[[t,r],...i.slice(1)]}else a=[[t,r],...i]}else a=[[t,r]];e.set(n,a)},Rm=t(2,(e,{entries:t,forkAs:n})=>{if(e.locals.size===0)return new Om(new Map(t));let r=new Map(e.locals);return n!==void 0&&Mm(e,r,n),t.forEach(([e,t])=>{t.length===1?Lm(r,t[0][0],e,t[0][1]):t.forEach(([t,n])=>{Lm(r,t,e,n)})}),new Om(r)}),zm=Fm,Bm=Rm,Vm=Em,Hm=`Empty`,Um=`Remove`,Wm=`Update`,Gm=`AndThen`,Km={_tag:Hm},qm=(e,t)=>{let n=new Map(e.locals),r=Km;for(let[e,i]of t.locals.entries()){let t=On(i)[1],a=n.get(e);if(a!==void 0){let n=On(a)[1];E(n,t)||(r=Jm({_tag:Wm,fiberRef:e,patch:e.diff(n,t)})(r))}else r=Jm({_tag:`Add`,fiberRef:e,value:t})(r);n.delete(e)}for(let[e]of n.entries())r=Jm({_tag:Um,fiberRef:e})(r);return r},Jm=t(2,(e,t)=>({_tag:Gm,first:e,second:t})),Ym=t(3,(e,t,n)=>{let r=n,i=Kn(e);for(;B(i);){let e=On(i),n=jn(i);switch(e._tag){case Hm:i=n;break;case`Add`:r=Im(r,{fiberId:t,fiberRef:e.fiberRef,value:e.value}),i=n;break;case Um:r=Nm(r,e.fiberRef),i=n;break;case Wm:{let a=Fm(r,e.fiberRef);r=Im(r,{fiberId:t,fiberRef:e.fiberRef,value:e.fiberRef.patch(e.patch)(a)}),i=n;break}case Gm:i=_n(e.first)(_n(e.second)(n));break}}return r}),Xm=qm,Zm=Ym,Qm=`effect/FiberStatus`,$m=Symbol.for(Qm),eh=`Done`,th=`Running`,nh=`Suspended`,rh=C(`${Qm}-${eh}`);var ih=class{[$m]=$m;_tag=eh;[b](){return rh}[T](e){return uh(e)&&e._tag===eh}},ah=class{runtimeFlags;[$m]=$m;_tag=th;constructor(e){this.runtimeFlags=e}[b](){return c(x(Qm),S(x(this._tag)),S(x(this.runtimeFlags)),w(this))}[T](e){return uh(e)&&e._tag===th&&this.runtimeFlags===e.runtimeFlags}},oh=class{runtimeFlags;blockingOn;[$m]=$m;_tag=nh;constructor(e,t){this.runtimeFlags=e,this.blockingOn=t}[b](){return c(x(Qm),S(x(this._tag)),S(x(this.runtimeFlags)),S(x(this.blockingOn)),w(this))}[T](e){return uh(e)&&e._tag===nh&&this.runtimeFlags===e.runtimeFlags&&E(this.blockingOn,e.blockingOn)}};const sh=new ih,ch=e=>new ah(e),lh=(e,t)=>new oh(e,t),uh=e=>y(e,$m),dh=e=>e._tag===eh,fh=sh,ph=ch,mh=lh,hh=dh,gh=wd,_h=Td,vh=Ed,yh=Dd,bh=Od,xh=kd,Sh=Ad,Ch=jd,wh=Zt(c(Sp,Xt(e=>e.ordinal))),Th=e=>{switch(e){case`All`:return gh;case`Debug`:return xh;case`Error`:return vh;case`Fatal`:return _h;case`Info`:return bh;case`Trace`:return Sh;case`None`:return Ch;case`Warning`:return yh}},Eh=Symbol.for(`effect/Micro`),Dh=Symbol.for(`effect/Micro/MicroExit`),Oh=Symbol.for(`effect/Micro/MicroCause`),kh={_E:n};var Ah=class extends globalThis.Error{_tag;traces;[Oh];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=Ve(t,0),o=`${i}: ${a}`;n.length>0&&(o+=`\n ${n.join(` `)}`),super(a),this._tag=e,this.traces=n,this[Oh]=kh,this.name=i,this.stack=o}pipe(){return A(this,arguments)}toString(){return this.stack}[D](){return this.stack}},jh=class extends Ah{defect;constructor(e,t=[]){super(`Die`,e,t),this.defect=e}};const Mh=(e,t=[])=>new jh(e,t);var Nh=class extends Ah{constructor(e=[]){super(`Interrupt`,`interrupted`,e)}};const Ph=(e=[])=>new Nh(e),Fh=e=>e._tag===`Interrupt`,Ih=Symbol.for(`effect/Micro/MicroFiber`),Lh={_A:n,_E:n};var Rh=class{context;interruptible;[Ih];_stack=[];_observers=[];_exit;_children;currentOpCount=0;constructor(e,t=!0){this.context=e,this.interruptible=t,this[Ih]=Lh}getRef(e){return bo(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(cg))}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===Gh)return;let n=zh.interruptChildren&&zh.interruptChildren(this);if(n!==void 0)return this.evaluate(rg(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(gg).shouldYield(this)){t=!0;let e=n;n=rg(eg,()=>e)}if(n=n[Vh](this),n===Gh){let e=this._yielded;return Dh in e?(this._yielded=void 0,e):Gh}}}catch(e){return y(n,Vh)?lg(e):lg(`MicroFiber.runLoop: Not a valid effect: ${String(n)}`)}}getCont(e){for(;;){let t=this._stack.pop();if(!t)return;let n=t[Wh]&&t[Wh](this);if(n)return{[e]:n};if(t[e])return t}}_yielded=void 0;yieldWith(e){return this._yielded=e,Gh}children(){return this._children??=new Set}};const zh=m(`effect/Micro/fiberMiddleware`,()=>({interruptChildren:void 0})),Bh=Symbol.for(`effect/Micro/identifier`),Q=Symbol.for(`effect/Micro/args`),Vh=Symbol.for(`effect/Micro/evaluate`),Hh=Symbol.for(`effect/Micro/successCont`),Uh=Symbol.for(`effect/Micro/failureCont`),Wh=Symbol.for(`effect/Micro/ensureCont`),Gh=Symbol.for(`effect/Micro/Yield`),Kh={_A:n,_E:n,_R:n},qh={...fm,_op:`Micro`,[Eh]:Kh,pipe(){return A(this,arguments)},[Symbol.iterator](){return new he(new be(this))},toJSON(){return{_id:`Micro`,op:this[Bh],...Q in this?{args:this[Q]}:void 0}},toString(){return k(this)},[D](){return k(this)}};function Jh(e){return lg(`Micro.evaluate: Not implemented`)}const Yh=e=>({...qh,[Bh]:e.op,[Vh]:e.eval??Jh,[Hh]:e.contA,[Uh]:e.contE,[Wh]:e.ensure}),Xh=e=>{let t=Yh(e);return function(){let n=Object.create(t);return n[Q]=e.single===!1?arguments:arguments[0],n}},Zh=e=>{let t={...Yh(e),[Dh]:Dh,_tag:e.op,get[e.prop](){return this[Q]},toJSON(){return{_id:`MicroExit`,_tag:e.op,[e.prop]:this[Q]}},[T](t){return ag(t)&&t._tag===e.op&&E(this[Q],t[Q])},[b](){return w(this,S(C(e.op))(x(this[Q])))}};return function(e){let n=Object.create(t);return n[Q]=e,n[Hh]=void 0,n[Uh]=void 0,n[Wh]=void 0,n}},Qh=Zh({op:`Success`,prop:`value`,eval(e){let t=e.getCont(Hh);return t?t[Hh](this[Q],e):e.yieldWith(this)}}),$h=Zh({op:`Failure`,prop:`cause`,eval(e){let t=e.getCont(Uh);for(;Fh(this[Q])&&t&&e.interruptible;)t=e.getCont(Uh);return t?t[Uh](this[Q],e):e.yieldWith(this)}}),eg=Xh({op:`Yield`,eval(e){let t=!1;return e.getRef(gg).scheduleTask(()=>{t||e.evaluate(ug)},this[Q]??0),e.yieldWith(()=>{t=!0})}})(0),tg=Qh(void 0),ng=Xh({op:`WithMicroFiber`,eval(e){return this[Q](e)}}),rg=t(2,(e,t)=>{let n=Object.create(ig);return n[Q]=e,n[Hh]=t,n}),ig=Yh({op:`OnSuccess`,eval(e){return e._stack.push(this),this[Q]}}),ag=e=>y(e,Dh),og=Qh,sg=$h,cg=sg(Ph()),lg=e=>sg(Mh(e)),ug=og(void 0),dg=`setImmediate`in globalThis?globalThis.setImmediate:e=>setTimeout(e,0);var fg=class{tasks=[];running=!1;scheduleTask(e,t){this.tasks.push(e),this.running||(this.running=!0,dg(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 pg=t(2,(e,t)=>ng(n=>{let r=n.context;return n.context=t(r),yg(e,()=>(n.context=r,tg))})),mg=t(2,(e,t)=>pg(e,No(t)));var hg=class extends Fo()(`effect/Micro/currentMaxOpsBeforeYield`,{defaultValue:()=>2048}){};Fo()(`effect/Micro/currentConcurrency`,{defaultValue:()=>`unbounded`});var gg=class extends Fo()(`effect/Micro/currentScheduler`,{defaultValue:()=>new fg}){};const _g=t(2,(e,t)=>{let n=Object.create(vg);return n[Q]=e,n[Hh]=t.onSuccess,n[Uh]=t.onFailure,n}),vg=Yh({op:`OnSuccessAndFailure`,eval(e){return e._stack.push(this),this[Q]}}),yg=t(2,(e,t)=>Sg(n=>_g(n(e),{onFailure:e=>rg(t(sg(e)),()=>$h(e)),onSuccess:e=>rg(t(og(e)),()=>Qh(e))}))),bg=Xh({op:`SetInterruptible`,ensure(e){if(e.interruptible=this[Q],e._interrupted&&e.interruptible)return()=>cg}}),xg=e=>ng(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(bg(!1)),t._interrupted?cg:e)),Sg=e=>ng(t=>t.interruptible?(t.interruptible=!1,t._stack.push(bg(!0)),e(xg)):e(n)),Cg=(e,t)=>{let n=new Rh(gg.context(t?.scheduler??new fg));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},wg=Symbol.for(`effect/Readable`),Tg=Symbol.for(`effect/Ref`),Eg={_A:e=>e};var Dg=class extends mm{ref;commit(){return this.get}[Tg]=Eg;[wg]=wg;constructor(e){super(),this.ref=e,this.get=J(()=>xs(this.ref))}get;modify(e){return J(()=>{let t=xs(this.ref),[n,r]=e(t);return t!==r&&Ss(r)(this.ref),n})}};const Og=e=>new Dg(bs(e)),kg=e=>J(()=>Og(e)),Ag=e=>e.get,jg=t(2,(e,t)=>e.modify(()=>[void 0,t])),Mg=t(2,(e,t)=>e.modify(t)),Ng=t(2,(e,t)=>e.modify(e=>[void 0,t(e)]));var Pg=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]])}},Fg=class{maxNextTickBeforeTimer;running=!1;tasks=new Pg;constructor(e){this.maxNextTickBeforeTimer=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){e>=this.maxNextTickBeforeTimer?setTimeout(()=>this.starveInternal(0),0):Promise.resolve(void 0).then(()=>this.starveInternal(e+1))}shouldYield(e){return e.currentOpCount>e.getFiberRef(qd)?e.getFiberRef(Kd):!1}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running||(this.running=!0,this.starve())}};const Ig=m(Symbol.for(`effect/Scheduler/defaultScheduler`),()=>new Fg(2048));var Lg=class{tasks=new Pg;deferred=!1;scheduleTask(e,t){this.deferred?Ig.scheduleTask(e,t):this.tasks.scheduleTask(e,t)}shouldYield(e){return e.currentOpCount>e.getFiberRef(qd)?e.getFiberRef(Kd):!1}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 Rg=m(Symbol.for(`effect/FiberRef/currentScheduler`),()=>zd(Ig)),zg=m(Symbol.for(`effect/FiberRef/currentRequestMap`),()=>zd(new Map)),Bg=(e,t,n,r)=>{switch(e){case void 0:return t();case`unbounded`:return n();case`inherit`:return Fd(Qd,e=>e===`unbounded`?n():e>1?r(e):t());default:return e>1?r(e):t()}},Vg=e=>e.replace(/[\s="]/g,`_`),Hg=e=>t=>`${Vg(t.label)}=${e-t.startTime}ms`,Ug=`effect/MetricLabel`,Wg=Symbol.for(Ug);var Gg=class{key;value;[Wg]=Wg;_hash;constructor(e,t){this.key=e,this.value=t,this._hash=C(Ug+this.key+this.value)}[b](){return this._hash}[T](e){return qg(e)&&this.key===e.key&&this.value===e.value}pipe(){return A(this,arguments)}};const Kg=(e,t)=>new Gg(e,t),qg=e=>y(e,Wg),Jg=e=>G(e,F),Yg=e=>c_(e,$g,qm),Xg=e=>rd(e,()=>W(_d(),()=>Xg(e))),Zg=(e,t,n,r)=>W(n(r,t),i=>{if(i)return K(F(r));let a=e.next();return a.done?K(P()):Zg(e,t+1,n,a.value)}),Qg=(e,t,n)=>{let r=e.next();return r.done?K(!0):W(n(r.value,t),r=>r?Qg(e,t+1,n):K(r))},$g=U(e=>K(e.getFiberRefs())),e_=(e,t)=>q(()=>t.while(e)?W(t.body(e),e=>e_(e,t)):K(e)),t_=(e,t,n,r)=>q(()=>t(e)?W(r(e),i=>G(t_(n(e),t,n,r),pc(i))):J(()=>uc())),n_=(e,t,n,r)=>q(()=>t(e)?W(r(e),()=>n_(n(e),t,n,r)):Y),r_=e=>l_((t,n)=>c(e,Ym(t,n))),i_=t(3,(e,t,n)=>Yf(r=>Xf(e,ko(r,t,n)))),a_=(e,t,n,r,i)=>{let a=e.next();return!a.done&&r(n)?W(i(n,a.value,t),n=>a_(e,t+1,n,r,i)):K(n)},o_=(e,t)=>W(e,n=>t<=0?K(n):bd(_d(),o_(e,t-1))),s_=K(P()),c_=t(3,(e,t,n)=>W(t,r=>W(e,e=>G(t,t=>[n(r,t),e])))),l_=e=>U(t=>(t.setFiberRefs(e(t.id(),t.getFiberRefs())),Y)),u_=sn(e=>Ao(e.context,sm)?e._tag===`Span`?u_(e.parent):P():F(e)),d_=Cf,f_=Af,p_=`InterruptSignal`,m_=`Stateful`,h_=`Resume`,g_=`YieldNow`,__=e=>({_tag:p_,cause:e}),v_=e=>({_tag:m_,onFiber:e}),y_=e=>({_tag:h_,effect:e}),b_=()=>({_tag:g_}),x_=Symbol.for(`effect/FiberScope`);var S_=class{[x_]=x_;fiberId=zs;roots=new Set;add(e,t){this.roots.add(t),t.addObserver(()=>{this.roots.delete(t)})}},C_=class{fiberId;parent;[x_]=x_;constructor(e,t){this.fiberId=e,this.parent=t}add(e,t){this.parent.tell(v_(e=>{e.addChild(t),t.addObserver(()=>{e.removeChild(t)})}))}};const w_=e=>new C_(e.id(),e),T_=m(Symbol.for(`effect/FiberScope/Global`),()=>new S_),E_=Symbol.for(`effect/Fiber`),D_={_E:e=>e,_A:e=>e},O_={[E_]:D_,pipe(){return A(this,arguments)}},k_=Symbol.for(`effect/Fiber`),A_=e=>yd(Ku(e.await),e.inheritAll);({...vt}),{...O_};const j_=`effect/FiberCurrent`,M_=Symbol.for(`effect/Logger`),N_={_Message:e=>e,_Output:e=>e},P_=e=>({[M_]:N_,log:e,pipe(){return A(this,arguments)}}),F_=/^[^\s"=]*$/,I_=P_(((e,t)=>({annotations:n,cause:r,date:i,fiberId:a,logLevel:o,message:s,spans:c})=>{let l=t=>t.match(F_)?t:e(t),u=(e,t)=>`${Vg(e)}=${l(t)}`,d=(e,t)=>` `+u(e,t),f=u(`timestamp`,i.toISOString());f+=d(`level`,o.label),f+=d(`fiber`,Is(a));let p=hn(s);for(let e=0;e<p.length;e++)f+=d(`message`,Ve(p[e],t));ba(r)||(f+=d(`cause`,Ga(r,{renderErrorCause:!0})));for(let e of c)f+=` `+Hg(i.getTime())(e);for(let[e,r]of n)f+=d(e,Ve(r,t));return f})(e=>`"${e.replace(/\\([\s\S])|(")/g,`\\$1$2`)}"`)),L_={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};L_.gray,L_.blue,L_.green,L_.yellow,L_.red,L_.bgBrightRed,L_.black;const R_=typeof process==`object`&&process!==null&&typeof process.stdout==`object`&&process.stdout!==null;R_&&process.stdout.isTTY,R_||`Deno`in globalThis;const z_=`effect/MetricBoundaries`,B_=Symbol.for(z_);var V_=class{values;[B_]=B_;constructor(e){this.values=e,this._hash=c(C(z_),S(Me(this.values)))}_hash;[b](){return this._hash}[T](e){return H_(e)&&E(this.values,e.values)}pipe(){return A(this,arguments)}};const H_=e=>y(e,B_),U_=e=>new V_(c(e,yn(fr(1/0)),tr)),W_=e=>c(mn(e.count-1,t=>e.start*e.factor**+t),vr,U_),G_=Symbol.for(`effect/MetricKeyType`),K_=`effect/MetricKeyType/Counter`,q_=Symbol.for(K_),J_=Symbol.for(`effect/MetricKeyType/Frequency`),Y_=Symbol.for(`effect/MetricKeyType/Gauge`),X_=`effect/MetricKeyType/Histogram`,Z_=Symbol.for(X_),Q_=Symbol.for(`effect/MetricKeyType/Summary`),$_={_In:e=>e,_Out:e=>e};var ev=class{incremental;bigint;[G_]=$_;[q_]=q_;constructor(e,t){this.incremental=e,this.bigint=t,this._hash=C(K_)}_hash;[b](){return this._hash}[T](e){return iv(e)}pipe(){return A(this,arguments)}},tv=class{boundaries;[G_]=$_;[Z_]=Z_;constructor(e){this.boundaries=e,this._hash=c(C(X_),S(x(this.boundaries)))}_hash;[b](){return this._hash}[T](e){return sv(e)&&E(this.boundaries,e.boundaries)}pipe(){return A(this,arguments)}};const nv=e=>new ev(e?.incremental??!1,e?.bigint??!1),rv=e=>new tv(e),iv=e=>y(e,q_),av=e=>y(e,J_),ov=e=>y(e,Y_),sv=e=>y(e,Z_),cv=e=>y(e,Q_),lv=Symbol.for(`effect/MetricKey`),uv={_Type:e=>e},dv=$n(E);var fv=class{name;keyType;description;tags;[lv]=uv;constructor(e,t,n,r=[]){this.name=e,this.keyType=t,this.description=n,this.tags=r,this._hash=c(C(this.name+this.description),S(x(this.keyType)),S(Me(this.tags)))}_hash;[b](){return this._hash}[T](e){return pv(e)&&this.name===e.name&&E(this.keyType,e.keyType)&&E(this.description,e.description)&&dv(this.tags,e.tags)}pipe(){return A(this,arguments)}};const pv=e=>y(e,lv),mv=(e,t)=>new fv(e,nv(t),tn(t?.description)),hv=(e,t,n)=>new fv(e,rv(t),tn(n)),gv=t(2,(e,t)=>t.length===0?e:new fv(e.name,e.keyType,e.description,Wn(e.tags,t))),_v=Symbol.for(`effect/MutableHashMap`),vv={[_v]:_v,[Symbol.iterator](){return new yv(this)},toString(){return k(this.toJSON())},toJSON(){return{_id:`MutableHashMap`,values:Array.from(this).map(O)}},[D](){return this.toJSON()},pipe(){return A(this,arguments)}};var yv=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 bv(this.self.buckets.values()),this.next()):e}[Symbol.iterator](){return new e(this.self)}},bv=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 xv=()=>{let e=Object.create(vv);return e.referential=new Map,e.buckets=new Map,e.bucketsSize=0,e},Sv=t(2,(e,t)=>{if(Pe(t)===!1)return e.referential.has(t)?F(e.referential.get(t)):P();let n=t[b](),r=e.buckets.get(n);return r===void 0?P():Cv(e,r,t)}),Cv=(e,t,n,r=!1)=>{for(let i=0,a=t.length;i<a;i++)if(n[T](t[i][0])){let n=t[i][1];return r&&(t.splice(i,1),e.bucketsSize--),F(n)}return P()},wv=t(2,(e,t)=>L(Sv(e,t))),Tv=t(3,(e,t,n)=>{if(Pe(t)===!1)return e.referential.set(t,n),e;let r=t[b](),i=e.buckets.get(r);return i===void 0?(e.buckets.set(r,[[t,n]]),e.bucketsSize++,e):(Ev(e,i,t),i.push([t,n]),e.bucketsSize++,e)}),Ev=(e,t,n)=>{for(let r=0,i=t.length;r<i;r++)if(n[T](t[r][0])){t.splice(r,1),e.bucketsSize--;return}},Dv=Symbol.for(`effect/MetricState`),Ov=`effect/MetricState/Counter`,kv=Symbol.for(Ov),Av=`effect/MetricState/Frequency`,jv=Symbol.for(Av),Mv=`effect/MetricState/Gauge`,Nv=Symbol.for(Mv),Pv=`effect/MetricState/Histogram`,Fv=Symbol.for(Pv),Iv=`effect/MetricState/Summary`,Lv=Symbol.for(Iv),Rv={_A:e=>e};var zv=class{count;[Dv]=Rv;[kv]=kv;constructor(e){this.count=e}[b](){return c(x(Ov),S(x(this.count)),w(this))}[T](e){return Xv(e)&&this.count===e.count}pipe(){return A(this,arguments)}};const Bv=$n(E);var Vv=class{occurrences;[Dv]=Rv;[jv]=jv;constructor(e){this.occurrences=e}_hash;[b](){return c(C(Av),S(Me(z(this.occurrences.entries()))),w(this))}[T](e){return Zv(e)&&Bv(z(this.occurrences.entries()),z(e.occurrences.entries()))}pipe(){return A(this,arguments)}},Hv=class{value;[Dv]=Rv;[Nv]=Nv;constructor(e){this.value=e}[b](){return c(x(Mv),S(x(this.value)),w(this))}[T](e){return Qv(e)&&this.value===e.value}pipe(){return A(this,arguments)}},Uv=class{buckets;count;min;max;sum;[Dv]=Rv;[Fv]=Fv;constructor(e,t,n,r,i){this.buckets=e,this.count=t,this.min=n,this.max=r,this.sum=i}[b](){return c(x(Pv),S(x(this.buckets)),S(x(this.count)),S(x(this.min)),S(x(this.max)),S(x(this.sum)),w(this))}[T](e){return $v(e)&&E(this.buckets,e.buckets)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return A(this,arguments)}},Wv=class{error;quantiles;count;min;max;sum;[Dv]=Rv;[Lv]=Lv;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}[b](){return c(x(Iv),S(x(this.error)),S(x(this.quantiles)),S(x(this.count)),S(x(this.min)),S(x(this.max)),S(x(this.sum)),w(this))}[T](e){return ey(e)&&this.error===e.error&&E(this.quantiles,e.quantiles)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return A(this,arguments)}};const Gv=e=>new zv(e),Kv=e=>new Vv(e),qv=e=>new Hv(e),Jv=e=>new Uv(e.buckets,e.count,e.min,e.max,e.sum),Yv=e=>new Wv(e.error,e.quantiles,e.count,e.min,e.max,e.sum),Xv=e=>y(e,kv),Zv=e=>y(e,jv),Qv=e=>y(e,Nv),$v=e=>y(e,Fv),ey=e=>y(e,Lv),ty=Symbol.for(`effect/MetricHook`),ny={_In:e=>e,_Out:e=>e},ry=e=>({[ty]:ny,pipe(){return A(this,arguments)},...e}),iy=BigInt(0),ay=e=>{let t=e.keyType.bigint?iy:0,n=e.keyType.incremental?e.keyType.bigint?e=>e>=iy:e=>e>=0:e=>!0,r=e=>{n(e)&&(t+=e)};return ry({get:()=>Gv(t),update:r,modify:r})},oy=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 ry({get:()=>Kv(t),update:n,modify:n})},sy=(e,t)=>{let n=t;return ry({get:()=>qv(n),update:e=>{n=e},modify:e=>{n+=e}})},cy=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,In(Sp),qn((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=pn(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 ry({get:()=>Jv({buckets:d(),count:a,min:s,max:l,sum:o}),update:u,modify:u})},ly=e=>{let{error:t,maxAge:n,maxSize:r,quantiles:i}=e.keyType,a=c(i,In(Sp)),o=pn(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=ts(e-r);ms(o,Zo)&&ps(o,n)&&i.push(a)}s+=1}return uy(t,a,In(i,Sp))},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 ry({get:()=>Yv({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)})},uy=(e,t,n)=>{let r=n.length;if(!B(t))return Gn();let i=t[0],a=t.slice(1),o=dy(e,r,P(),0,i,n),s=Kn(o);return a.forEach(t=>{s.push(dy(e,r,o.value,o.consumed,t,o.rest))}),qn(s,e=>[e.quantile,e.value])},dy=(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,_=a;for(;;){if(!B(d))return{quantile:u,value:P(),consumed:l,rest:[]};if(u===1)return{quantile:u,value:F(An(d)),consumed:l+d.length,rest:[]};let e=On(d),t=Nn(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=Dn(d),h=i,g=u,_=t[1],o=f,s=p,c=m,l=h,u=g,d=_;continue}if(i>n+r){let t=I(c)?F(e):c;return{quantile:u,value:t,consumed:l,rest:d}}switch(c._tag){case`None`:f=o,p=s,m=Dn(d),h=i,g=u,_=t[1],o=f,s=p,c=m,l=h,u=g,d=_;continue;case`Some`:if(a<Math.abs(n-c.value)){f=o,p=s,m=Dn(d),h=i,g=u,_=t[1],o=f,s=p,c=m,l=h,u=g,d=_;continue}return{quantile:u,value:F(c.value),consumed:l,rest:d}}}throw Error(`BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues`)},fy=Symbol.for(`effect/MetricPair`),py={_Type:e=>e},my=(e,t)=>({[fy]:py,metricKey:e,metricState:t,pipe(){return A(this,arguments)}}),hy=Symbol.for(`effect/MetricRegistry`);var gy=class{[hy]=hy;map=xv();snapshot(){let e=[];for(let[t,n]of this.map)e.push(my(t,n.get()));return e}get(e){let t=c(this.map,Sv(e),nn);if(t==null){if(iv(e.keyType))return this.getCounter(e);if(ov(e.keyType))return this.getGauge(e);if(av(e.keyType))return this.getFrequency(e);if(sv(e.keyType))return this.getHistogram(e);if(cv(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,Sv(e),nn);if(t==null){let n=ay(e);c(this.map,wv(e))||c(this.map,Tv(e,n)),t=n}return t}getFrequency(e){let t=c(this.map,Sv(e),nn);if(t==null){let n=oy(e);c(this.map,wv(e))||c(this.map,Tv(e,n)),t=n}return t}getGauge(e){let t=c(this.map,Sv(e),nn);if(t==null){let n=sy(e,e.keyType.bigint?BigInt(0):0);c(this.map,wv(e))||c(this.map,Tv(e,n)),t=n}return t}getHistogram(e){let t=c(this.map,Sv(e),nn);if(t==null){let n=cy(e);c(this.map,wv(e))||c(this.map,Tv(e,n)),t=n}return t}getSummary(e){let t=c(this.map,Sv(e),nn);if(t==null){let n=ly(e);c(this.map,wv(e))||c(this.map,Tv(e,n)),t=n}return t}};const _y=()=>new gy,vy=Symbol.for(`effect/Metric`),yy={_Type:e=>e,_In:e=>e,_Out:e=>e},by=m(Symbol.for(`effect/Metric/globalMetricRegistry`),()=>_y()),xy=function(e,t,n,r){let i=Object.assign(e=>od(e,e=>Dy(i,e)),{[vy]:yy,keyType:e,unsafeUpdate:t,unsafeValue:n,unsafeModify:r,register(){return this.unsafeValue([]),this},pipe(){return A(this,arguments)}});return i},Sy=(e,t)=>Cy(mv(e,t)),Cy=e=>{let t,n=new WeakMap,r=r=>{if(r.length===0)return t===void 0&&(t=by.get(e)),t;let i=n.get(r);return i===void 0?(i=by.get(gv(e,r)),n.set(r,i),i):i};return xy(e.keyType,(e,t)=>r(t).update(e),e=>r(e).get(),(e,t)=>r(t).modify(e))},wy=(e,t,n)=>Cy(hv(e,t,n)),Ty=t(3,(e,t,n)=>Ey(e,[Kg(t,n)])),Ey=t(2,(e,t)=>xy(e.keyType,(n,r)=>e.unsafeUpdate(n,Wn(t,r)),n=>e.unsafeValue(Wn(t,n)),(n,r)=>e.unsafeModify(n,Wn(t,r)))),Dy=t(2,(e,t)=>Fd(nf,n=>J(()=>e.unsafeUpdate(t,n))));({..._t});const Oy=t(2,(e,t)=>Fd(zg,n=>J(()=>{if(n.has(e)){let r=n.get(e);r.state.completed||(r.state.completed=!0,Gf(r.result,t))}}))),ky={Forward:0,Backward:1};Symbol.iterator;const Ay=(e,t)=>{let n=e[Symbol.iterator](),r=0;return{[Symbol.iterator]:()=>Ay(e,t),next:()=>{r++;let e=n.key;switch(t===ky.Forward?n.moveNext():n.movePrev(),e._tag){case`None`:return{done:!0,value:r};case`Some`:return{done:!1,value:e.value}}}}},jy=(e,t)=>{let n=e[Symbol.iterator](),r=0;return{[Symbol.iterator]:()=>jy(e,t),next:()=>{r++;let e=n.value;switch(t===ky.Forward?n.moveNext():n.movePrev(),e._tag){case`None`:return{done:!0,value:r};case`Some`:return{done:!1,value:e.value}}}}};Symbol.iterator;const My=Symbol.for(`effect/Supervisor`),Ny={_T:e=>e};var Py=class e{underlying;value0;[My]=Ny;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,G(t)))}zip(e){return new Fy(this,e)}},Fy=class e{left;right;_tag=`Zip`;[My]=Ny;constructor(e,t){this.left=e,this.right=t}get value(){return vd(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 Py(this,c(this.value,G(e)))}zip(t){return new e(this,t)}};const Iy=e=>y(e,My)&&oe(e,`Zip`);var Ly=class{effect;[My]=Ny;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 Py(this,c(this.value,G(e)))}zip(e){return new Fy(this,e)}onRun(e,t){return e()}};const Ry=e=>new Ly(e),zy=m(`effect/Supervisor/none`,()=>Ry(Y)),By=ml,Vy=`Empty`,Hy=`AddSupervisor`,Uy=`RemoveSupervisor`,Wy=`AndThen`,Gy={_tag:Vy},Ky=(e,t)=>({_tag:Wy,first:e,second:t}),qy=(e,t)=>Jy(t,fr(e)),Jy=(e,t)=>{let n=e,r=t;for(;Er(r);){let e=kr(r);switch(e._tag){case Vy:r=Ar(r);break;case Hy:n=n.zip(e.supervisor),r=Ar(r);break;case Uy:n=Yy(n,e.supervisor),r=Ar(r);break;case Wy:r=Sr(e.first)(Sr(e.second)(Ar(r)));break}}return n},Yy=(e,t)=>E(e,t)?zy:Iy(e)?Yy(e.left,t).zip(Yy(e.right,t)):e,Xy=e=>E(e,zy)?qi():Iy(e)?c(Xy(e.left),na(Xy(e.right))):Yi(e),Zy=By({empty:Gy,patch:qy,combine:Ky,diff:(e,t)=>{if(E(e,t))return Gy;let n=Xy(e),r=Xy(t);return Ky(c(r,ta(n),ra(Gy,(e,t)=>Ky(e,{_tag:Hy,supervisor:t}))),c(n,ta(r),ra(Gy,(e,t)=>Ky(e,{_tag:Uy,supervisor:t}))))}}),Qy=Sy(`effect_fiber_started`,{incremental:!0}),$y=Sy(`effect_fiber_active`),eb=Sy(`effect_fiber_successes`,{incremental:!0}),tb=Sy(`effect_fiber_failures`,{incremental:!0}),nb=Ty(wy(`effect_fiber_lifetimes`,W_({start:.5,factor:2,count:35})),`time_unit`,`milliseconds`),rb=`Continue`,ib=`Yield`,ab={_E:e=>e,_A:e=>e},ob=e=>{throw Error(`BUG: FiberRuntime - ${Ve(e)} - please report an issue at https://github.com/Effect-TS/effect/issues`)},sb=Symbol.for(`effect/internal/fiberRuntime/YieldedOp`),cb=m(`effect/internal/fiberRuntime/yieldedOpChannel`,()=>({currentOp:null})),lb={[Qe]:(e,t,n)=>we(()=>t.effect_instruction_i1(n)),OnStep:(e,t,n)=>Z(Z(n)),[$e]:(e,t,n)=>we(()=>t.effect_instruction_i2(n)),[st]:(e,t,n)=>(e.patchRuntimeFlags(e.currentRuntimeFlags,t.patch),jl(e.currentRuntimeFlags)&&e.isInterrupted()?X(e.getInterruptedCause()):Z(n)),[rt]:(e,t,n)=>(we(()=>t.effect_instruction_i2(n)),we(()=>t.effect_instruction_i0())?(e.pushStack(t),we(()=>t.effect_instruction_i1())):Y),[it]:(e,t,n)=>{for(;;){let r=we(()=>t.effect_instruction_i0.next(n));if(r.done)return Z(r.value);let i=xe(r.value);if(!Sf(i))return e.pushStack(t),i;if(i._tag===`Failure`)return i;n=i.value}}},ub={[p_]:(e,t,n,r)=>(e.processNewInterruptSignal(r.cause),jl(t)?X(r.cause):n),[h_]:(e,t,n,r)=>{throw Error(`It is illegal to have multiple concurrent run loops in a single fiber`)},[m_]:(e,t,n,r)=>(r.onFiber(e,ph(t)),n),[g_]:(e,t,n,r)=>W(_d(),()=>n)},db=e=>Zu(Kl(e),e=>Eb(uu(e),([e,t])=>{let n=new Map,r=[];for(let e of t){r.push(hr(e));for(let t of e)n.set(t.request,t)}let i=r.flat();return Rd(Yb(e.runAll(r),i,()=>i.forEach(e=>{e.listeners.interrupted=!0})),zg,n)},!1,!1)),fb=ct();var pb=class extends mm{[E_]=D_;[k_]=ab;_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,Il(n)){let e=this.getFiberRef(nf);Qy.unsafeUpdate(1,e),$y.unsafeUpdate(1,e)}this.refreshRefCache()}commit(){return A_(this)}id(){return this._fiberId}resume(e){this.tell(y_(e))}get status(){return this.ask((e,t)=>t)}get runtimeFlags(){return this.ask((e,t)=>hh(t)?e.currentRuntimeFlags:t.runtimeFlags)}scope(){return w_(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(af)}fiberRefs(){return this.ask(e=>e.getFiberRefs())}ask(e){return q(()=>{let t=Rf(this._fiberId);return this.tell(v_((n,r)=>{Gf(t,J(()=>e(n,r)))})),Vf(t)})}tell(e){this._queue.push(e),this._running||(this._running=!0,this.drainQueueLaterOnExecutor())}get await(){return ju(e=>{let t=t=>e(K(t));return this.tell(v_((e,n)=>{e._exitValue===null?e.addObserver(t):t(this._exitValue)})),J(()=>this.tell(v_((e,n)=>{e.removeObserver(t)})))},this.id())}get inheritAll(){return U((e,t)=>{let n=e.id(),r=e.getFiberRefs(),i=t.runtimeFlags,a=Am(r,n,this.getFiberRefs());return e.setFiberRefs(a),dd(c(Rl(i,e.getFiberRef(Kb)),Ul(1),Ul(16)))})}get poll(){return J(()=>tn(this._exitValue))}unsafePoll(){return this._exitValue}interruptAsFork(e){return J(()=>this.tell(__(ga(e))))}unsafeInterruptAsFork(e){this.tell(__(ga(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(Kb,this.currentRuntimeFlags),this._fiberRefs}unsafeDeleteFiberRef(e){this._fiberRefs=Nm(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=Im(this._fiberRefs,{fiberId:this._fiberId,fiberRef:e,value:t}),this.refreshRefCache()}refreshRefCache(){this.currentDefaultServices=this.getFiberRef(lm),this.currentTracer=this.currentDefaultServices.unsafeMap.get(nm.key),this.currentSupervisor=this.getFiberRef(qb),this.currentScheduler=this.getFiberRef(Rg),this.currentContext=this.getFiberRef(Gd),this.currentSpan=this.currentContext.unsafeMap.get(rm.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=rb,n=globalThis[j_];globalThis[j_]=this;try{for(;t===rb;)t=this._queue.length===0?`Done`:this.evaluateMessageWhileSuspended(this._queue.splice(0,1)[0])}finally{this._running=!1,globalThis[j_]=n}this._queue.length>0&&!this._running?(this._running=!0,t===ib?(this.drainQueueLaterOnExecutor(),e=!1):e=!0):e=!1}}drainQueueLaterOnExecutor(){this.currentScheduler.scheduleTask(this.run,this.getFiberRef(Kd))}drainQueueWhileRunning(e,t){let n=t;for(;this._queue.length>0;){let t=this._queue.splice(0,1)[0];n=ub[t._tag](this,e,n,t)}return n}isInterrupted(){return!Sa(this.getFiberRef(af))}addInterruptedCause(e){let t=this.getFiberRef(af);this.setFiberRef(af,va(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(__(ga(this.id()))),e=!0;return e}interruptAllChildren(){if(this.sendInterruptSignalToAllChildren()){let e=this._children.values();this._children=null;let t=!1;return pd({while:()=>!t,body:()=>{let n=e.next();return n.done?J(()=>{t=!0}):Du(n.value.await)},step:()=>{}})}return null}reportExitValue(e){if(Il(this.currentRuntimeFlags)){let t=this.getFiberRef(nf),n=this.id().startTimeMillis,r=Date.now();switch(nb.unsafeUpdate(r-n,t),$y.unsafeUpdate(-1,t),e._tag){case et:eb.unsafeUpdate(1,t);break;case Xe:tb.unsafeUpdate(1,t);break}}if(e._tag===`Failure`){let t=this.getFiberRef(ef);!wa(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(vb)}log(e,t,n){let r=L(n)?n.value:this.getFiberRef(Yd);if(wh(this.getFiberRef(mb),r))return;let i=this.getFiberRef(Xd),a=this.getFiberRef(Jd),o=this.getLoggers(),s=this.getFiberRefs();if(Qi(o)>0){let n=Ao(this.getFiberRef(lm),hp),c=new Date(n.unsafeCurrentTimeMillis());Ke(s,()=>{for(let n of o)n.log({fiberId:this.id(),logLevel:r,message:e,cause:t,context:s,spans:i,annotations:a,date:c})})}}evaluateMessageWhileSuspended(e){switch(e._tag){case g_:return ib;case p_:return this.processNewInterruptSignal(e.cause),this._asyncInterruptor!==null&&(this._asyncInterruptor(X(e.cause)),this._asyncInterruptor=null),rb;case h_:return this._asyncInterruptor=null,this._asyncBlockingOn=null,this.evaluateEffect(e.effect),rb;case m_:return e.onFiber(this,this._exitValue===null?mh(this.currentRuntimeFlags,this._asyncBlockingOn):fh),rb;default:return ob(e)}}evaluateEffect(e){this.currentSupervisor.onResume(this);try{let t=jl(this.currentRuntimeFlags)&&this.isInterrupted()?X(this.getInterruptedCause()):e;for(;t!==null;){let e=t,n=this.runLoop(e);if(n===sb){let e=cb.currentOp;cb.currentOp=null,e._op===ot?kl(this.currentRuntimeFlags)?(this.tell(b_()),this.tell(y_(Ff)),t=null):t=Ff:e._op===Je&&(t=null)}else{this.currentRuntimeFlags=c(this.currentRuntimeFlags,Al(16));let e=this.interruptAllChildren();e===null?(this._queue.length===0?this.setExitValue(n):this.tell(y_(n)),t=null):t=W(e,()=>n)}}}finally{this.currentSupervisor.onSuspend(this)}}start(e){if(this._running)this.tell(y_(e));else{this._running=!0;let t=globalThis[j_];globalThis[j_]=this;try{this.evaluateEffect(e)}finally{this._running=!1,globalThis[j_]=t,this._queue.length>0&&this.drainQueueLaterOnExecutor()}}}startFork(e){this.tell(y_(e))}patchRuntimeFlags(e,t){let n=zl(e,t);return globalThis[j_]=this,this.currentRuntimeFlags=n,n}initiateAsync(e,t){let n=!1,r=e=>{n||(n=!0,this.tell(y_(e)))};jl(e)&&(this._asyncInterruptor=r);try{t(r)}catch(e){r(Vu(ha(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!==Ze)return e;e=this.popStack()}}getNextFailCont(){let e=this.popStack();for(;e;){if(e._op!==Qe&&e._op!==rt&&e._op!==it)return e;e=this.popStack()}}Tag(e){return J(()=>jo(this.currentContext,e))}Left(e){return zu(e.left)}None(e){return zu(new yf)}Right(e){return Z(e.right)}Some(e){return Z(e.value)}Micro(e){return ku(t=>{let n=t,r=Cg(mg(e,this.currentContext));return r.addObserver(e=>{if(e._tag===`Success`)return n(Z(e.value));switch(e.cause._tag){case`Interrupt`:return n(X(ga(zs)));case`Fail`:return n(zu(e.cause.error));case`Die`:return n(Fu(e.cause.defect))}}),ku(e=>{n=t=>{e(Y)},r.unsafeInterrupt()})})}[tt](e){let t=we(()=>e.effect_instruction_i0()),n=this.getNextSuccessCont();return n===void 0?(cb.currentOp=Z(t),sb):(n._op in lb||ob(n),lb[n._op](this,n,t))}[et](e){let t=e,n=this.getNextSuccessCont();return n===void 0?(cb.currentOp=t,sb):(n._op in lb||ob(n),lb[n._op](this,n,t.effect_instruction_i0))}[Xe](e){let t=e.effect_instruction_i0,n=this.getNextFailCont();if(n!==void 0)switch(n._op){case Ze:case $e:return jl(this.currentRuntimeFlags)&&this.isInterrupted()?X(Ma(t)):we(()=>n.effect_instruction_i1(t));case`OnStep`:return jl(this.currentRuntimeFlags)&&this.isInterrupted()?X(Ma(t)):Z(X(t));case st:return this.patchRuntimeFlags(this.currentRuntimeFlags,n.patch),jl(this.currentRuntimeFlags)&&this.isInterrupted()?X(va(t,this.getInterruptedCause())):X(t);default:ob(n)}else return cb.currentOp=X(t),sb}[at](e){return we(()=>e.effect_instruction_i0(this,ph(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=Xm(i.refs,t),s=Rl(i.flags,n);return Z(vu(e.effect_instruction_i0,U(t=>{for(;r.length>0;)t.pushStack(r.pop());return t.setFiberRefs(Zm(t.id(),t.getFiberRefs())(o)),t.currentRuntimeFlags=zl(s)(t.currentRuntimeFlags),e.effect_instruction_i1})))}return ud(t=>W(Ob(yu(e.effect_instruction_i0)),()=>t(e.effect_instruction_i1)))}RunBlocked(e){return db(e.effect_instruction_i0)}[nt](e){let t=e.effect_instruction_i0,n=this.currentRuntimeFlags,r=zl(n,t);if(jl(r)&&this.isInterrupted())return X(this.getInterruptedCause());if(this.patchRuntimeFlags(this.currentRuntimeFlags,t),e.effect_instruction_i1){let t=Rl(r,n);return this.pushStack(new xu(t,e)),we(()=>e.effect_instruction_i1(n))}else return Ff}[Qe](e){return this.pushStack(e),e.effect_instruction_i0}OnStep(e){return this.pushStack(e),e.effect_instruction_i0}[Ze](e){return this.pushStack(e),e.effect_instruction_i0}[$e](e){return this.pushStack(e),e.effect_instruction_i0}[Je](e){return this._asyncBlockingOn=e.effect_instruction_i1,this.initiateAsync(this.currentRuntimeFlags,e.effect_instruction_i0),cb.currentOp=e,sb}[ot](e){return this._isYielding=!1,cb.currentOp=e,sb}[rt](e){let t=e.effect_instruction_i0,n=e.effect_instruction_i1;return t()?(this.pushStack(e),n()):Ff}[it](e){return lb[it](this,e,void 0)}[Ye](e){return we(()=>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=W(_d({priority:e}),()=>n)}}try{if(t=this.currentTracer.context(()=>{if(fb!==t[bu]._V){let e=this.getFiberRef(tf);if(e._tag===`Some`){let n=t[bu]._V;this.log(`Executing an Effect versioned ${n} with a Runtime of version ${ct()}, 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`,pa,e)}}return this[t._op](t)},this),t===sb){let e=cb.currentOp;return e._op===ot||e._op===Je?sb:(cb.currentOp=null,e._op===et||e._op===Xe?e:X(ha(e)))}}catch(e){t=t!==sb&&!y(t,`_op`)||!(t._op in this)?Iu(`Not a valid effect: ${Ve(t)}`):_f(e)?X(va(ha(e),ga(zs))):Fu(e)}}}run=()=>{this.drainQueueOnCurrentThread()}};const mb=m(`effect/FiberRef/currentMinimumLogLevel`,()=>zd(Th(`Info`))),hb=e=>P_(t=>{Ao(zm(t.context,lm),Kp).unsafe.log(e.log(t))}),gb=m(Symbol.for(`effect/Logger/defaultLogger`),()=>hb(I_)),_b=m(Symbol.for(`effect/Logger/tracerLogger`),()=>P_(({annotations:e,cause:t,context:n,fiberId:r,logLevel:i,message:a})=>{let o=Mo(Fm(n,Gd),rm);if(o._tag===`None`||o.value._tag===`ExternalSpan`)return;let s=jo(Fm(n,lm),hp),c={};for(let[t,n]of e)c[t]=n;c[`effect.fiberId`]=Bs(r),c[`effect.logLevel`]=i.label,t!==null&&t._tag!==`Empty`&&(c[`effect.cause`]=Ga(t,{renderErrorCause:!0})),o.value.event(Ve(Array.isArray(a)&&a.length===1?a[0]:a),s.unsafeCurrentTimeNanos(),c)})),vb=m(Symbol.for(`effect/FiberRef/currentLoggers`),()=>Bd(Yi(gb,_b))),yb=(e,t,n)=>{let r=e.next();return r.done?K(!1):W(n(r.value,t),r=>r?K(r):yb(e,t+1,n))},bb=e=>{if(Array.isArray(e)||de(e))return[e,P()];let t=Object.keys(e),n=t.length;return[t.map(t=>e[t]),F(e=>{let r={};for(let i=0;i<n;i++)r[t[i]]=e[i];return r})]},xb=(e,t,r)=>{let i=[];for(let t of e)i.push(Lu(t));return W(wb(i,n,{concurrency:r?.concurrency,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),e=>{let n=P(),i=e.length,a=Array(i),o=Array(i),s=!1;for(let t=0;t<i;t++){let r=e[t];r._tag===`Left`?(a[t]=F(r.left),s=!0):(o[t]=r.right,a[t]=n)}return s?t._tag===`Some`?zu(t.value(a)):zu(a):r?.discard?Y:t._tag===`Some`?K(t.value(o)):K(o)})},Sb=(e,t,r)=>{let i=[];for(let t of e)i.push(Lu(t));return r?.discard?wb(i,n,{concurrency:r?.concurrency,batching:r?.batching,discard:!0,concurrentFinalizers:r?.concurrentFinalizers}):G(wb(i,n,{concurrency:r?.concurrency,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),e=>t._tag===`Some`?t.value(e):e)},Cb=(e,t)=>{let[r,i]=bb(e);return t?.mode===`validate`?xb(r,i,t):t?.mode===`either`?Sb(r,i,t):t?.discard!==!0&&i._tag===`Some`?G(wb(r,n,t),i.value):wb(r,n,t)},wb=t(e=>de(e[0]),(e,t,n)=>U(r=>{let i=n?.batching===!0||n?.batching===`inherit`&&r.getFiberRef($d);return n?.discard?Bg(n.concurrency,()=>Fb(Sm,n?.concurrentFinalizers)(n=>i?Eb(e,(e,r)=>n(t(e,r)),!0,!1,1):Zu(e,(e,r)=>n(t(e,r)))),()=>Fb(Cm,n?.concurrentFinalizers)(n=>Eb(e,(e,r)=>n(t(e,r)),i,!1)),r=>Fb(wm(r),n?.concurrentFinalizers)(n=>Eb(e,(e,r)=>n(t(e,r)),i,!1,r))):Bg(n?.concurrency,()=>Fb(Sm,n?.concurrentFinalizers)(n=>i?Db(e,1,(e,r)=>n(t(e,r)),!0):Xu(e,(e,r)=>n(t(e,r)))),()=>Fb(Cm,n?.concurrentFinalizers)(n=>Tb(e,(e,r)=>n(t(e,r)),i)),r=>Fb(wm(r),n?.concurrentFinalizers)(n=>Db(e,r,(e,r)=>n(t(e,r)),i)))})),Tb=(e,t,n)=>q(()=>{let r=z(e),i=Array(r.length);return bd(Eb(r,(e,n)=>W(t(e,n),e=>J(()=>i[n]=e)),n,!1),K(i))}),Eb=(e,t,n,r,i)=>ud(a=>sd(o=>U(s=>{let c=Array.from(e).reverse(),l=c.length;if(l===0)return Y;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)}),g=[],_=[],v=[],ee=()=>{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(Ff),e},te=(e,t=!1)=>{let n=ld(o(e)),r=Ab(n,s,s.currentRuntimeFlags,T_);return s.currentScheduler.scheduleTask(()=>{t&&r.unsafeInterruptAsFork(s.id()),r.resume(n)},0),r},ne=()=>{r||(l-=c.length,c=[]),d=!0,h()},re=n?Gu:Ru,ie=te(ju(e=>{let r=(e,t)=>{e._op===`Blocked`?v.push(e):(m.push({index:t,exit:e}),e._op===`Failure`&&!d&&ne())},o=()=>{if(c.length>0){let f=c.pop(),h=u++,ne=()=>{let e=c.pop();return h=u++,W(_d(),()=>W(re(a(t(e,h))),ie))},ie=e=>c.length>0&&(r(e,h),c.length>0)?ne():K(e),ae=te(W(re(a(t(f,h))),ie));g.push(ae),p.add(ae),d&&ae.currentScheduler.scheduleTask(()=>{ae.unsafeInterruptAsFork(s.id())},0),ae.addObserver(t=>{let a;if(a=t._op===`Failure`?t:t.effect_instruction_i0,_.push(ae),p.delete(ae),r(a,h),m.length===l)e(K(R(Ef(ee(),{parallel:!0}),()=>Ff)));else if(v.length+m.length===l){let t=ee();e(K(vu(v.map(e=>e.effect_instruction_i0).reduce(Wl),Eb([R(Ef(t,{parallel:!0}),()=>Ff),...v.map(e=>e.effect_instruction_i1)],e=>e,n,!0,i))))}else o()})}};for(let e=0;e<f;e++)o()}));return Du(td(Ku(a(A_(ie))),Nf({onFailure:e=>{ne();let t=v.length+1,n=Math.min(typeof i==`number`?i:v.length,v.length),r=Array.from(v);return ju(i=>{let a=[],o=0,s=0,c=(n,s)=>c=>{a[n]=c,o++,o===t&&i(Z(X(e))),r.length>0&&s&&l()},l=()=>{te(r.pop(),!0).addObserver(c(s,!0)),s++};ie.addObserver(c(s,!1)),s++;for(let e=0;e<n;e++)l()})},onSuccess:()=>Xu(_,e=>e.inheritAll)})))}))),Db=(e,t,n,r)=>q(()=>{let i=z(e),a=Array(i.length);return bd(Eb(i,(e,t)=>G(n(e,t),e=>a[t]=e),r,!1,t),K(a))}),Ob=e=>Mb(e,T_),kb=(e,t,n,r=null)=>{let i=jb(e,t,n,r);return i.resume(e),i},Ab=(e,t,n,r=null)=>jb(e,t,n,r),jb=(e,t,n,r=null)=>{let i=Vs(),a=jm(t.getFiberRefs(),i),o=new pb(i,a,n),s=Fm(a,Gd),l=o.currentSupervisor;return l.onStart(s,e,F(t),o),o.addObserver(e=>l.onEnd(e,o)),(r===null?c(t.getFiberRef(rf),R(()=>t.scope())):r).add(n,o),o},Mb=(e,t)=>U((n,r)=>K(kb(e,n,r.runtimeFlags,t))),Nb=e=>Yf(t=>Qt(Mo(t,zb),{onNone:()=>e,onSome:t=>{switch(t.strategy._tag){case`Parallel`:return e;case`Sequential`:case`ParallelN`:return W(df(t,Cm),t=>Wb(e,t))}}})),Pb=e=>t=>Yf(n=>Qt(Mo(n,zb),{onNone:()=>t,onSome:n=>n.strategy._tag===`ParallelN`&&n.strategy.parallelism===e?t:W(df(n,wm(e)),e=>Wb(t,e))})),Fb=(e,t)=>r=>Yf(i=>Qt(Mo(i,zb),{onNone:()=>r(n),onSome:i=>{if(t===!0){let t=e._tag===`Parallel`?Nb:e._tag===`Sequential`?Lb:Pb(e.parallelism);switch(i.strategy._tag){case`Parallel`:return t(r(Nb));case`Sequential`:return t(r(Lb));case`ParallelN`:return t(r(Pb(i.strategy.parallelism)))}}else return r(n)}})),Ib=e=>W(zb,e),Lb=e=>Yf(t=>Qt(Mo(t,zb),{onNone:()=>e,onSome:t=>{switch(t.strategy._tag){case`Sequential`:return e;case`Parallel`:case`ParallelN`:return W(df(t,Sm),t=>Wb(e,t))}}})),Rb=t(e=>wu(e[1]),(e,t,n,r)=>G(Cb([e,t],{concurrency:r?.concurrent?2:1,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),([e,t])=>n(e,t))),zb=Eo(`effect/Scope`),Bb=(e,t)=>{e.state._tag===`Open`&&e.state.finalizers.set({},t)},Vb={[of]:of,[sf]:sf,pipe(){return A(this,arguments)},fork(e){return J(()=>{let t=Hb(e);if(this.state._tag===`Closed`)return t.state=this.state,t;let n={};return this.state.finalizers.set(n,e=>t.close(e)),Bb(t,e=>J(()=>{this.state._tag===`Open`&&this.state.finalizers.delete(n)})),t})},close(e){return q(()=>{if(this.state._tag===`Closed`)return Y;let t=Array.from(this.state.finalizers.values()).reverse();return this.state={_tag:`Closed`,exit:e},t.length===0?Y:bm(this.strategy)?c(Xu(t,t=>Ru(t(e))),W(e=>c(Ef(e),on(Tf),R(()=>Ff)))):xm(this.strategy)?c(Tb(t,t=>Ru(t(e)),!1),W(e=>c(Ef(e,{parallel:!0}),on(Tf),R(()=>Ff)))):c(Db(t,this.strategy.parallelism,t=>Ru(t(e)),!1),W(e=>c(Ef(e,{parallel:!0}),on(Tf),R(()=>Ff))))})},addFinalizer(e){return q(()=>this.state._tag===`Closed`?e(this.state.exit):(this.state.finalizers.set({},e),Y))}},Hb=(e=_m)=>{let t=Object.create(Vb);return t.strategy=e,t.state={_tag:`Open`,finalizers:new Map},t},Ub=(e=_m)=>J(()=>Hb(e)),Wb=t(2,(e,t)=>Zf(e,No(Oo(zb,t)))),Gb=e=>Ud(e,{differ:Zy,fork:Gy}),Kb=Wd(Fl),qb=Gb(zy),Jb=t(2,(e,t)=>ud(n=>Ju(n(e),{onFailure:e=>Ju(t,{onFailure:t=>Vu(va(e,t)),onSuccess:()=>Vu(e)}),onSuccess:e=>Eu(t,e)}))),Yb=(e,t,n)=>Wu(r=>W(W(Ob(Qu(e)),e=>ju(r=>{let i=t.map(e=>e.listeners.count),a=()=>{i.every(e=>e===0)&&t.every(e=>e.result.state.current._tag===`Pending`?!0:!!(e.result.state.current._tag===`Done`&&Sf(e.result.state.current.effect)&&e.result.state.current.effect._tag===`Failure`&&Ca(e.result.state.current.effect.cause)))&&(o.forEach(e=>e()),n?.(),r(Sd(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(),J(()=>{o.forEach(e=>e())})})),()=>q(()=>Zu(t.flatMap(e=>e.state.completed?[]:[e]),e=>Oy(e.request,jf(r)))))),Xb=Symbol.for(`effect/ScheduleInterval`),Zb={[Xb]:Xb,startMillis:0,endMillis:0},Qb=e=>c(e.intervals,Dr,R(()=>Zb)).startMillis,$b=e=>c(e.intervals,Dr,R(()=>Zb)).endMillis,ex=t(2,(e,t)=>Qb(e)<Qb(t)),tx=e=>Er(e.intervals),nx=$b,rx=ex,ix=tx,ax=`Done`,ox=e=>({_tag:`Continue`,intervals:e}),sx={_tag:ax},cx=e=>e._tag===ax,lx=ox,ux=sx,dx=cx,fx=uf,px=df;var mx=class{permits;waiters=new Set;taken=0;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take=e=>Au(t=>{if(this.free<e){let n=()=>{this.free<e||(this.waiters.delete(n),this.taken+=e,t(K(e)))};return this.waiters.add(n),J(()=>{this.waiters.delete(n)})}return this.taken+=e,t(K(e))});updateTakenUnsafe(e,t){return this.taken=t(this.taken),this.waiters.size>0&&e.getFiberRef(Rg).scheduleTask(()=>{let e=this.waiters.values(),t=e.next();for(;t.done===!1&&this.free>0;)t.value(),t=e.next()},e.getFiberRef(Kd)),K(this.free)}updateTaken(e){return U(t=>this.updateTakenUnsafe(t,e))}resize=e=>Du(U(t=>(this.permits=e,this.free<0?Y:this.updateTakenUnsafe(t,e=>e))));release=e=>this.updateTaken(t=>t-e);releaseAll=this.updateTaken(e=>0);withPermits=e=>t=>ud(n=>W(n(this.take(e)),e=>Jb(n(t),this.release(e))));withPermitsIfAvailable=e=>t=>ud(n=>q(()=>this.free<e?s_:(this.taken+=e,Jb(n(Jg(t)),this.release(e)))))};const hx=e=>new mx(e),gx=Symbol.for(`effect/Ref/SynchronizedRef`),_x={_A:e=>e};var vx=class extends mm{ref;withLock;[gx]=_x;[Tg]=Eg;[wg]=wg;constructor(e,t){super(),this.ref=e,this.withLock=t,this.get=Ag(this.ref)}get;commit(){return this.get}modify(e){return this.modifyEffect(t=>K(e(t)))}modifyEffect(e){return this.withLock(c(W(Ag(this.ref),e),W(([e,t])=>Eu(jg(this.ref,t),e))))}};const yx=e=>J(()=>bx(e)),bx=e=>new vx(Og(e),hx(1).withPermits(1)),xx=Cd,Sx=e=>function(){if(arguments.length===1){let t=arguments[0];return(n,...r)=>e(t,n,...r)}return e.apply(this,arguments)},Cx=Sx((e,t,n)=>{let r=Vs(),i=[[Gd,[[r,e.context]]]];n?.scheduler&&i.push([Rg,[[r,n.scheduler]]]);let a=Bm(e.fiberRefs,{entries:i,forkAs:r});n?.updateRefs&&(a=n.updateRefs(a,r));let o=new pb(r,a,e.runtimeFlags),s=t;n?.scope&&(s=W(px(n.scope,_m),e=>bd(cf(e,Wu(e=>E(e,o.id())?Y:Cd(o,e))),td(t,t=>fx(e,t)))));let c=o.currentSupervisor;return c!==zy&&(c.onStart(e.context,s,P(),o),o.addObserver(e=>c.onEnd(e,o))),T_.add(e.runtimeFlags,o),n?.immediate===!1?o.resume(s):o.start(s),o}),wx=Sx((e,t,n={})=>{let r=Cx(e,t,n);return n.onExit&&r.addObserver(e=>{n.onExit(e)}),(t,n)=>wx(e)(c(r,xx(t??zs)),{...n,onExit:n?.onExit?e=>n.onExit(f_(e)):void 0})}),Tx=Sx((e,t)=>{let n=Nx(e)(t);if(n._tag===`Failure`)throw jx(n.effect_instruction_i0);return n.effect_instruction_i0});var Ex=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 Dx=e=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let n=new Ex(e);return Error.stackTraceLimit=t,n},Ox=Symbol.for(`effect/Runtime/FiberFailure`),kx=Symbol.for(`effect/Runtime/FiberFailure/Cause`);var Ax=class extends Error{[Ox];[kx];constructor(e){let t=$a(e)[0];super(t?.message||`An error has occurred`),this[Ox]=Ox,this[kx]=e,this.name=t?`(FiberFailure) ${t.name}`:`FiberFailure`,t?.stack&&(this.stack=t.stack)}toJSON(){return{_id:`FiberFailure`,cause:this[kx].toJSON()}}toString(){return`(FiberFailure) `+Ga(this[kx],{renderErrorCause:!0})}[D](){return this.toString()}};const jx=e=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let n=new Ax(e);return Error.stackTraceLimit=t,n},Mx=e=>{let t=e;switch(t._op){case`Failure`:case`Success`:return t;case`Left`:return Of(t.left);case`Right`:return Z(t.right);case`Some`:return Z(t.value);case`None`:return Of(new yf)}},Nx=Sx((e,t)=>{let n=Mx(t);if(n)return n;let r=new Lg,i=Cx(e)(t,{scheduler:r});return r.flush(),i.unsafePoll()||Df(Pu(Dx(i),Qf(i)))});var Px=class{context;runtimeFlags;fiberRefs;constructor(e,t,n){this.context=e,this.runtimeFlags=t,this.fiberRefs=n}pipe(){return A(this,arguments)}};const Fx=(e=>new Px(e.context,e.runtimeFlags,e.fiberRefs))({context:Do(),runtimeFlags:Pl(1,32,4),fiberRefs:Vm()}),Ix=Cx(Fx),Lx=Tx(Fx),Rx=t(2,(e,t)=>e.modifyEffect(t)),zx=Symbol.for(`effect/Layer/MemoMap`),Bx=Fo()(`effect/Layer/CurrentMemoMap`,{defaultValue:()=>Wx()}),Vx=e=>e._op_layer===`Fresh`;var Hx=class{ref;[zx];constructor(e){this.ref=e,this[zx]=zx}getOrElseMemoize(e,t){return c(Rx(this.ref,n=>{let r=n.get(e);if(r!==void 0){let[e,i]=r;return K([c(e,W(([e,t])=>c(r_(e),Eu(t))),td(Nf({onFailure:()=>Y,onSuccess:()=>lf(t,i)}))),n])}return c(kg(0),W(r=>c(zf(),W(i=>c(kg(()=>Y),G(a=>{let o=ud(o=>c(Ub(),W(s=>c(o(W(qx(e,s,!0),e=>Yg(e(this)))),Ru,W(o=>{switch(o._tag){case Xe:return c(Uf(i,o.effect_instruction_i0),bd(uf(s,o)),bd(Vu(o.effect_instruction_i0)));case et:return c(jg(a,e=>c(uf(s,e),fd(Mg(r,e=>[e===1,e-1])),Du)),bd(Ng(r,e=>e+1)),bd(lf(t,t=>c(J(()=>n.delete(e)),bd(Ag(a)),W(e=>e(t))))),bd(Wf(i,o.effect_instruction_i0)),Eu(o.effect_instruction_i0[1]))}}))))),s=[c(Vf(i),td(Pf({onFailure:()=>Y,onSuccess:()=>Ng(r,e=>e+1)}))),e=>c(Ag(a),W(t=>t(e)))];return[o,Vx(e)?n:n.set(e,s)]}))))))}),Ku)}};const Ux=q(()=>G(yx(new Map),e=>new Hx(e))),Wx=()=>new Hx(bx(new Map)),Gx=t(2,(e,t)=>W(Ux,n=>Kx(e,n,t))),Kx=t(3,(e,t,n)=>W(qx(e,n),e=>i_(e(t),Bx,t))),qx=(e,t,n=!1)=>{let r=e;switch(r._op_layer){case`Locally`:return J(()=>e=>r.f(e.getOrElseMemoize(r.self,t)));case`ExtendScope`:return J(()=>e=>Ib(t=>e.getOrElseMemoize(r.layer,t)));case`Fold`:return J(()=>e=>c(e.getOrElseMemoize(r.layer,t),Ju({onFailure:n=>e.getOrElseMemoize(r.failureK(n),t),onSuccess:n=>e.getOrElseMemoize(r.successK(n),t)})));case`Fresh`:return J(()=>e=>c(r.layer,Gx(t)));case`FromEffect`:return J(n?()=>e=>r.effect:()=>n=>n.getOrElseMemoize(e,t));case`Provide`:return J(()=>e=>c(e.getOrElseMemoize(r.first,t),W(n=>c(e.getOrElseMemoize(r.second,t),Xf(n)))));case`Scoped`:return J(n?()=>e=>Wb(r.effect,t):()=>n=>n.getOrElseMemoize(e,t));case`Suspend`:return J(()=>e=>e.getOrElseMemoize(r.evaluate(),t));case`ProvideMerge`:return J(()=>e=>c(e.getOrElseMemoize(r.first,t),xd(e.getOrElseMemoize(r.second,t),r.zipK)));case`ZipWith`:return hd(function*(){let e=yield*df(t,vm),n=yield*df(e,_m),i=yield*df(e,_m);return e=>c(e.getOrElseMemoize(r.first,n),Rb(e.getOrElseMemoize(r.second,i),r.zipK,{concurrent:!0}))});case`MergeAll`:{let e=r.layers;return G(df(t,vm),t=>n=>{let r=Array(e.length);return G(Eb(e,gd(function*(e,i){let a=yield*df(t,_m);r[i]=yield*n.getOrElseMemoize(e,a)}),!1,!1),()=>Po(...r))})}}},Jx=(e,t,n,r,i,a,o,s,l,u)=>{let d=u(a,l);return ix(d)?K([[r,o],[i,s],lx(d)]):c(a,rx(l))?W(e.step(nx(a),n,r),([r,i,a])=>dx(a)?K([[r,o],[i,s],ux]):Jx(e,t,n,r,i,a.intervals,o,s,l,u)):W(t.step(nx(l),n,o),([o,s,c])=>dx(c)?K([[r,o],[i,s],ux]):Jx(e,t,n,r,i,a,o,s,c.intervals,u))},Yx=(e,t,n,r)=>Yu(t.next(r),{onFailure:()=>id(t.last),onSuccess:r=>Yu(e,{onFailure:e=>n(e,F(r)),onSuccess:r=>Yx(e,t,n,r)})}),Xx=(e,t,n)=>Mu(e,r=>Yu(t.next(r),{onFailure:()=>c(t.last,id,W(e=>n(r,e))),onSuccess:()=>Xx(e,t,n)})),Zx=(e,t,n)=>Yu(n.next(t),{onFailure:()=>id(n.last),onSuccess:()=>W(e,t=>Zx(e,t,n))});Symbol.iterator,Symbol.iterator;const Qx=wu,$x=wb,eS=q,tS=Y,nS=Mu,rS=G,iS=ed,aS=Lu,oS=W,sS=Ix,cS=Lx,lS=(e,t)=>{switch(t._tag){case`StringKeyword`:case`TemplateLiteral`:return Object.keys(e);case`SymbolKeyword`:return Object.getOwnPropertySymbols(e);case`Refinement`:return lS(e,t.from)}},uS=e=>{let t=!1,n;return()=>t?n:(n=e(),t=!0,n)},dS=e=>Array.isArray(e),fS=e=>!Array.isArray(e),pS=e=>`[${ze(e)}]`,mS=e=>dS(e)?e.map(pS).join(``):pS(e),hS=(e,t,n,r)=>{let i=e;return n&&B(n)&&(i+=`\nat path: ${mS(n)}`),t!==void 0&&(i+=`\ndetails: ${t}`),r&&(i+=`\nschema (${r._tag}): ${r}`),i},gS=e=>hS(`Unsupported key schema`,void 0,void 0,e),_S=e=>hS(`Unsupported literal`,`literal value: ${Be(e)}`),vS=e=>hS(`Duplicate index signature`,`${e} index signature`),yS=hS(`Unsupported index signature parameter`,"An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),bS=hS(`Invalid element`,`A required element cannot follow an optional element. ts(1257)`),xS=e=>hS(`Duplicate property signature transformation`,`Duplicate key ${Be(e)}`),SS=e=>hS(`Duplicate property signature`,`Duplicate key ${Be(e)}`),CS=Symbol.for(`effect/SchemaId/GreaterThanOrEqualTo`),wS=Symbol.for(`effect/SchemaId/LessThanOrEqualTo`),TS=Symbol.for(`effect/SchemaId/MinLength`),ES=Symbol.for(`effect/SchemaId/MaxLength`),DS=Symbol.for(`effect/annotation/TypeConstructor`),OS=Symbol.for(`effect/annotation/Brand`),kS=Symbol.for(`effect/annotation/SchemaId`),AS=Symbol.for(`effect/annotation/Message`),jS=Symbol.for(`effect/annotation/MissingMessage`),MS=Symbol.for(`effect/annotation/Identifier`),NS=Symbol.for(`effect/annotation/Title`),PS=Symbol.for(`effect/annotation/AutoTitle`),FS=Symbol.for(`effect/annotation/Description`),IS=Symbol.for(`effect/annotation/Examples`),LS=Symbol.for(`effect/annotation/Default`),RS=Symbol.for(`effect/annotation/JSONSchema`),zS=Symbol.for(`effect/annotation/Arbitrary`),BS=Symbol.for(`effect/annotation/Pretty`),VS=Symbol.for(`effect/annotation/Equivalence`),HS=Symbol.for(`effect/annotation/Documentation`),US=Symbol.for(`effect/annotation/Concurrency`),WS=Symbol.for(`effect/annotation/Batching`),GS=Symbol.for(`effect/annotation/ParseIssueTitle`),KS=Symbol.for(`effect/annotation/ParseOptions`),qS=Symbol.for(`effect/annotation/DecodingFallback`),JS=Symbol.for(`effect/annotation/Surrogate`),YS=Symbol.for(`effect/annotation/StableFilter`),XS=t(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?F(e.annotations[t]):P()),ZS=XS(OS),QS=XS(AS),$S=XS(jS),eC=XS(NS),tC=XS(PS),nC=XS(MS),rC=XS(FS),iC=XS(US),aC=XS(WS),oC=XS(GS),sC=XS(KS),cC=XS(qS),lC=XS(JS),uC=XS(YS),dC=e=>un(uC(e),e=>e===!0),fC=Symbol.for(`effect/annotation/JSONIdentifier`),pC=XS(fC),mC=e=>$t(pC(e),()=>nC(e));var hC=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 R(bw(this),()=>`<declaration schema>`)}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map(e=>e.toJSON()),annotations:hw(this.annotations)}}};const gC=e=>t=>t._tag===e;var _C=class{literal;annotations;_tag=`Literal`;constructor(e,t={}){this.literal=e,this.annotations=t}toString(){return R(bw(this),()=>Be(this.literal))}toJSON(){return{_tag:this._tag,literal:v(this.literal)?String(this.literal):this.literal,annotations:hw(this.annotations)}}};const vC=gC(`Literal`),yC=new _C(null);var bC=class{symbol;annotations;_tag=`UniqueSymbol`;constructor(e,t={}){this.symbol=e,this.annotations=t}toString(){return R(bw(this),()=>Be(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:hw(this.annotations)}}};const xC=new class{annotations;_tag=`NeverKeyword`;constructor(e={}){this.annotations=e}toString(){return _w(this)}toJSON(){return{_tag:this._tag,annotations:hw(this.annotations)}}}({[NS]:`never`}),SC=new class{annotations;_tag=`UnknownKeyword`;constructor(e={}){this.annotations=e}toString(){return _w(this)}toJSON(){return{_tag:this._tag,annotations:hw(this.annotations)}}}({[NS]:`unknown`}),CC=new class{annotations;_tag=`AnyKeyword`;constructor(e={}){this.annotations=e}toString(){return _w(this)}toJSON(){return{_tag:this._tag,annotations:hw(this.annotations)}}}({[NS]:`any`}),wC=new class{annotations;_tag=`StringKeyword`;constructor(e={}){this.annotations=e}toString(){return _w(this)}toJSON(){return{_tag:this._tag,annotations:hw(this.annotations)}}}({[NS]:`string`,[FS]:`a string`}),TC=gC(`StringKeyword`),EC=new class{annotations;_tag=`NumberKeyword`;constructor(e={}){this.annotations=e}toString(){return _w(this)}toJSON(){return{_tag:this._tag,annotations:hw(this.annotations)}}}({[NS]:`number`,[FS]:`a number`}),DC=gC(`SymbolKeyword`);var OC=class{type;annotations;constructor(e,t={}){this.type=e,this.annotations=t}toJSON(){return{type:this.type.toJSON(),annotations:hw(this.annotations)}}toString(){return String(this.type)}},kC=class extends OC{isOptional;constructor(e,t,n={}){super(e,n),this.isOptional=t}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:hw(this.annotations)}}toString(){return String(this.type)+(this.isOptional?`?`:``)}};const AC=e=>e.map(e=>e.type);var jC=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(bS)}toString(){return R(bw(this),()=>MC(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map(e=>e.toJSON()),rest:this.rest.map(e=>e.toJSON()),isReadonly:this.isReadonly,annotations:hw(this.annotations)}}};const MC=e=>{let t=e.elements.map(String).join(`, `);return gn(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 NC=class extends kC{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:hw(this.annotations)}}};const PC=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return!0;case`Refinement`:return PC(e.from)}return!1};var FC=class{type;isReadonly;parameter;constructor(e,t,n){if(this.type=t,this.isReadonly=n,PC(e))this.parameter=e;else throw Error(yS)}toString(){return(this.isReadonly?`readonly `:``)+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}},IC=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(SS(n));r[n]=null}let i={string:!1,symbol:!1};for(let e=0;e<t.length;e++){let n=gw(t[e].parameter);if(TC(n)){if(i.string)throw Error(vS(`string`));i.string=!0}else if(DC(n)){if(i.symbol)throw Error(vS(`symbol`));i.symbol=!0}}this.propertySignatures=e,this.indexSignatures=t}toString(){return R(bw(this),()=>RC(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map(e=>e.toJSON()),indexSignatures:this.indexSignatures.map(e=>e.toJSON()),annotations:hw(this.annotations)}}};const LC=e=>e.map(String).join(`; `),RC=e=>{if(e.propertySignatures.length>0){let t=e.propertySignatures.map(String).join(`; `);return e.indexSignatures.length>0?`{ ${t}; ${LC(e.indexSignatures)} }`:`{ ${t} }`}else if(e.indexSignatures.length>0)return`{ ${LC(e.indexSignatures)} }`;else return`{}`},zC=In(Xt(Sp,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})),BC={string:`StringKeyword`,number:`NumberKeyword`,boolean:`BooleanKeyword`,bigint:`BigIntKeyword`},VC=e=>Jn(e,e=>KC(e)?VC(e.types):[e]),HC=e=>{let t=zC(e),n=[],r={},i=[];for(let e of t)switch(e._tag){case`NeverKeyword`:break;case`AnyKeyword`:return[CC];case`UnknownKeyword`:return[SC];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[BC[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 UC=class e{types;annotations;static make=(t,n)=>GC(t)?new e(t,n):t.length===1?t[0]:xC;static unify=(t,n)=>e.make(HC(VC(t)),n);_tag=`Union`;constructor(e,t={}){this.types=e,this.annotations=t}toString(){return R(bw(this),()=>this.types.map(String).join(` | `))}toJSON(){return{_tag:this._tag,types:this.types.map(e=>e.toJSON()),annotations:hw(this.annotations)}}};const WC=(e,t)=>e.map(t),GC=e=>e.length>1,KC=gC(`Union`),qC=m(Symbol.for(`effect/Schema/AST/toJSONMemoMap`),()=>new WeakMap);var JC=class{f;annotations;_tag=`Suspend`;constructor(e,t={}){this.f=e,this.annotations=t,this.f=uS(e)}toString(){return bw(this).pipe($t(()=>sn(rn(this.f)(),e=>bw(e))),R(()=>`<suspended schema>`))}toJSON(){let e=this.f(),t=qC.get(e);return t||(qC.set(e,{_tag:this._tag}),t={_tag:this._tag,ast:e.toJSON(),annotations:hw(this.annotations)},qC.set(e,t),t)}},YC=class{from;filter;annotations;_tag=`Refinement`;constructor(e,t,n={}){this.from=e,this.filter=t,this.annotations=n}toString(){return nC(this).pipe(R(()=>Qt(yw(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:e=>XC(this.from)?String(this.from)+` & `+e:e})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:hw(this.annotations)}}};const XC=gC(`Refinement`),ZC={};var QC=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 R(bw(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:hw(this.annotations)}}},$C=class{from;to;decode;encode;constructor(e,t,n,r){this.from=e,this.to=t,this.decode=n,this.encode=r}},ew=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(xS(e));t[e]=!0;let i=r.to;if(n[i])throw Error(xS(i));n[i]=!0}}};const tw=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={...e.annotations};delete r[MS];let i={...r,...t},a=lC(e);return L(a)&&(i[JS]=tw(a.value,t)),n.annotations.value=i,Object.create(Object.getPrototypeOf(e),n)},nw=(e,t)=>{switch(e._tag){case`Literal`:return Cp(String(e.literal));case`StringKeyword`:return`[\\s\\S]*?`;case`NumberKeyword`:return`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;case`TemplateLiteral`:return iw(e,t,!1);case`Union`:return e.types.map(e=>nw(e,t)).join(`|`)}},rw=(e,t,n,r)=>{if(KC(e)){if(n&&!r)return`(?:${t})`}else if(!n||!r)return t;return`(${t})`},iw=(e,t,n)=>{let r=``;if(e.head!==``){let i=Cp(e.head);r+=t&&n?`(${i})`:i}for(let i of e.spans){let e=nw(i.type,t);if(r+=rw(i.type,e,t,n),i.literal!==``){let e=Cp(i.literal);r+=t&&n?`(${e})`:e}}return r},aw=e=>RegExp(`^${iw(e,!1,!0)}$`),ow=(e,t)=>{let n=[],r=[],i=e=>{switch(e._tag){case`NeverKeyword`:break;case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:case`Refinement`:r.push(new FC(e,t,!0));break;case`Literal`:if(h(e.literal)||g(e.literal))n.push(new NC(e.literal,t,!1,!0));else throw Error(_S(e.literal));break;case`Enums`:for(let[r,i]of e.enums)n.push(new NC(i,t,!1,!0));break;case`UniqueSymbol`:n.push(new NC(e.symbol,t,!1,!0));break;case`Union`:e.types.forEach(i);break;default:throw Error(gS(e))}};return i(e),{propertySignatures:n,indexSignatures:r}},sw=e=>{switch(e._tag){case`TupleType`:return e.isReadonly===!1?e:new jC(e.elements,e.rest,!1,e.annotations);case`TypeLiteral`:{let t=dw(e.propertySignatures,e=>e.isReadonly===!1?e:new NC(e.name,e.type,e.isOptional,!1,e.annotations)),n=dw(e.indexSignatures,e=>e.isReadonly===!1?e:new FC(e.parameter,e.type,!1));return t===e.propertySignatures&&n===e.indexSignatures?e:new IC(t,n,e.annotations)}case`Union`:{let t=dw(e.types,sw);return t===e.types?e:UC.make(t,e.annotations)}case`Suspend`:return new JC(()=>sw(e.f()),e.annotations);case`Refinement`:{let t=sw(e.from);return t===e.from?e:new YC(t,e.filter,e.annotations)}case`Transformation`:{let t=sw(e.from),n=sw(e.to);return t===e.from&&n===e.to?e:new QC(t,n,e.transformation,e.annotations)}}return e},cw=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},lw=cw([IS,LS,RS,zS,BS,VS]),uw=e=>{switch(e._tag){case`Declaration`:{let t=dw(e.typeParameters,uw);return t===e.typeParameters?e:new hC(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case`TupleType`:{let t=dw(e.elements,e=>{let t=uw(e.type);return t===e.type?e:new kC(t,e.isOptional)}),n=AC(e.rest),r=dw(n,uw);return t===e.elements&&r===n?e:new jC(t,r.map(e=>new OC(e)),e.isReadonly,e.annotations)}case`TypeLiteral`:{let t=dw(e.propertySignatures,e=>{let t=uw(e.type);return t===e.type?e:new NC(e.name,t,e.isOptional,e.isReadonly)}),n=dw(e.indexSignatures,e=>{let t=uw(e.type);return t===e.type?e:new FC(e.parameter,t,e.isReadonly)});return t===e.propertySignatures&&n===e.indexSignatures?e:new IC(t,n,e.annotations)}case`Union`:{let t=dw(e.types,uw);return t===e.types?e:UC.make(t,e.annotations)}case`Suspend`:return new JC(()=>uw(e.f()),e.annotations);case`Refinement`:{let t=uw(e.from);return t===e.from?e:new YC(t,e.filter,e.annotations)}case`Transformation`:{let t=lw(e);return uw(t===void 0?e.to:tw(e.to,t))}}return e};function dw(e,t){let n=!1,r=pn(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 fw=e=>{switch(e._tag){case`Transformation`:return e.from;case`Refinement`:return fw(e.from);case`Suspend`:return fw(e.f())}},pw=(e,t)=>{switch(e._tag){case`Declaration`:{let n=dw(e.typeParameters,e=>pw(e,t));return n===e.typeParameters?e:new hC(n,e.decodeUnknown,e.encodeUnknown)}case`TupleType`:{let n=dw(e.elements,e=>{let n=pw(e.type,t);return n===e.type?e:new kC(n,e.isOptional)}),r=AC(e.rest),i=dw(r,e=>pw(e,t));return n===e.elements&&i===r?e:new jC(n,i.map(e=>new OC(e)),e.isReadonly)}case`TypeLiteral`:{let n=dw(e.propertySignatures,e=>{let n=pw(e.type,t);return n===e.type?e:new NC(e.name,n,e.isOptional,e.isReadonly)}),r=dw(e.indexSignatures,e=>{let n=pw(e.type,t);return n===e.type?e:new FC(e.parameter,n,e.isReadonly)});return n===e.propertySignatures&&r===e.indexSignatures?e:new IC(n,r)}case`Union`:{let n=dw(e.types,e=>pw(e,t));return n===e.types?e:UC.make(n)}case`Suspend`:{let n,r=mC(e);if(L(r)){let e=t?`Bound`:``;n={[fC]:`${r.value}Encoded${e}`}}return new JC(()=>pw(e.f(),t),n)}case`Refinement`:{let n=pw(e.from,t);return t?n===e.from?e:fw(e.from)===void 0&&dC(e)?new YC(n,e.filter,e.annotations):n:n}case`Transformation`:return pw(e.from,t)}return e},mw=e=>pw(e,!1),hw=e=>{let t={};for(let n of Object.getOwnPropertySymbols(e))t[String(n)]=e[n];return t},gw=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return e;case`Refinement`:return gw(e.from)}},_w=e=>R(bw(e),()=>e._tag);function vw(e){return Qt(ZS(e),{onNone:()=>``,onSome:e=>e.map(e=>` & Brand<${Be(e)}>`).join(``)})}const yw=e=>eC(e).pipe($t(()=>rC(e)),$t(()=>tC(e)),on(t=>t+vw(e))),bw=e=>$t(nC(e),()=>yw(e));var xw=class{path;actual;issue;_tag=`Pointer`;constructor(e,t,n){this.path=e,this.actual=t,this.issue=n}},Sw=class{actual;message;_tag=`Unexpected`;constructor(e,t){this.actual=e,this.message=t}},Cw=class{ast;message;_tag=`Missing`;actual=void 0;constructor(e,t){this.ast=e,this.message=t}},$=class{ast;actual;issues;output;_tag=`Composite`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.issues=n,this.output=r}},ww=class{ast;actual;kind;issue;_tag=`Refinement`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},Tw=class{ast;actual;kind;issue;_tag=`Transformation`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},Ew=class{ast;actual;message;_tag=`Type`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}},Dw=class{ast;actual;message;_tag=`Forbidden`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}};const Ow=Symbol.for(`effect/Schema/ParseErrorTypeId`);var kw=class extends dm(`ParseError`){[Ow]=Ow;get message(){return this.toString()}toString(){return iT.formatIssueSync(this.issue)}toJSON(){return{_id:`ParseError`,message:this.toString()}}[D](){return this.toJSON()}};const Aw=e=>new kw({issue:e}),jw=j,Mw=M,Nw=zt,Pw=t(2,(e,t)=>Nw(e)?Ut(e,{onLeft:M,onRight:t}):oS(e,t)),Fw=t(2,(e,t)=>Nw(e)?Ht(e,t):rS(e,t)),Iw=t(2,(e,t)=>Nw(e)?Vt(e,t):iS(e,t)),Lw=t(2,(e,t)=>Nw(e)?Ut(e,{onLeft:t,onRight:j}):nS(e,t)),Rw=(e,t)=>t===void 0||g(t)?e:e===void 0?t:{...e,...t},zw=(e,t,n)=>{let r=Gw(e,t);return(e,t)=>r(e,Rw(n,t))},Bw=(e,t,n)=>{let r=zw(e,t,n);return(e,t)=>Gt(r(e,t),Aw)},Vw=(e,t)=>zw(e.ast,!0,t),Hw=(e,t)=>Bw(uw(e.ast),!0,t),Uw=m(Symbol.for(`effect/ParseResult/decodeMemoMap`),()=>new WeakMap),Ww=m(Symbol.for(`effect/ParseResult/encodeMemoMap`),()=>new WeakMap),Gw=(e,t)=>{let n=t?Uw:Ww,r=n.get(e);if(r)return r;let i=Jw(e,t),a=sC(e),o=L(a)?(e,t)=>i(e,Rw(t,a.value)):i,s=cC(e),c=t&&L(s)?(t,n)=>$w(Lw(o(t,n),s.value),e,t,n):o;return n.set(e,c),c},Kw=e=>nn(iC(e)),qw=e=>nn(aC(e)),Jw=(e,t)=>{switch(e._tag){case`Refinement`:if(t){let t=Gw(e.from,!0);return(n,r)=>{r??=ZC;let i=r?.errors===`all`;return $w(Pw(Lw(t(n,r),t=>{let a=new ww(e,n,`From`,t);return i&&dC(e)&&pT(t)?Qt(e.filter(n,r,e),{onNone:()=>M(a),onSome:t=>M(new $(e,n,[a,new ww(e,n,`Predicate`,t)]))}):M(a)}),t=>Qt(e.filter(t,r,e),{onNone:()=>j(t),onSome:t=>M(new ww(e,n,`Predicate`,t))})),e,n,r)}}else{let t=Gw(uw(e),!0),n=Gw(Qw(e.from),!1);return(r,i)=>$w(Pw(t(r,i),e=>n(e,i)),e,r,i)}case`Transformation`:{let n=nT(e.transformation,t),r=t?Gw(e.from,!0):Gw(e.to,!1),i=t?Gw(e.to,!0):Gw(e.from,!1);return(a,o)=>$w(Pw(Iw(r(a,o),n=>new Tw(e,a,t?`Encoded`:`Type`,n)),r=>Pw(Iw(n(r,o??ZC,e,a),t=>new Tw(e,a,`Transformation`,t)),n=>Iw(i(n,o),n=>new Tw(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)=>$w(n(t,r??ZC,e),e,t,r)}case`Literal`:return Yw(e,t=>t===e.literal);case`UniqueSymbol`:return Yw(e,t=>t===e.symbol);case`UndefinedKeyword`:return Yw(e,ne);case`NeverKeyword`:return Yw(e,re);case`UnknownKeyword`:case`AnyKeyword`:case`VoidKeyword`:return j;case`StringKeyword`:return Yw(e,h);case`NumberKeyword`:return Yw(e,g);case`BooleanKeyword`:return Yw(e,_);case`BigIntKeyword`:return Yw(e,v);case`SymbolKeyword`:return Yw(e,ee);case`ObjectKeyword`:return Yw(e,ae);case`Enums`:return Yw(e,t=>e.enums.some(([e,n])=>n===t));case`TemplateLiteral`:{let t=aw(e);return Yw(e,e=>h(e)&&t.test(e))}case`TupleType`:{let n=e.elements.map(e=>Gw(e.type,t)),r=e.rest.map(e=>Gw(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=Kw(e),c=qw(e);return(t,l)=>{if(!bn(t))return M(new Ew(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 xw(n,t,new Cw(i[n-m]));if(u){d.push([f++,r]);continue}else return M(new $(e,t,r,p))}if(e.rest.length===0)for(let n=e.elements.length;n<=m-1;n++){let r=new xw(n,t,new Sw(t[n],`is unexpected, expected: ${o}`));if(u){d.push([f++,r]);continue}else return M(new $(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(Nw(i)){if(N(i)){let n=new xw(h,t,i.left);if(u){d.push([f++,n]);continue}else return M(new $(e,t,n,tT(p)))}p.push([f++,i.right])}else{let n=f++,r=h;g||=[],g.push(({es:a,output:o})=>oS(aS(i),i=>{if(N(i)){let s=new xw(r,t,i.left);return u?(a.push([n,s]),tS):M(new $(e,t,s,tT(o)))}return o.push([n,i.right]),tS}))}}if(B(r)){let[n,...i]=r;for(;h<m-i.length;h++){let r=n(t[h],l);if(Nw(r))if(N(r)){let n=new xw(h,t,r.left);if(u){d.push([f++,n]);continue}else return M(new $(e,t,n,tT(p)))}else p.push([f++,r.right]);else{let n=f++,i=h;g||=[],g.push(({es:a,output:o})=>oS(aS(r),r=>{if(N(r)){let s=new xw(i,t,r.left);return u?(a.push([n,s]),tS):M(new $(e,t,s,tT(o)))}else return o.push([n,r.right]),tS}))}}for(let n=0;n<i.length;n++)if(h+=n,!(m<h+1)){let r=i[n](t[h],l);if(Nw(r)){if(N(r)){let n=new xw(h,t,r.left);if(u){d.push([f++,n]);continue}else return M(new $(e,t,n,tT(p)))}p.push([f++,r.right])}else{let n=f++,i=h;g||=[],g.push(({es:a,output:o})=>oS(aS(r),r=>{if(N(r)){let s=new xw(i,t,r.left);return u?(a.push([n,s]),tS):M(new $(e,t,s,tT(o)))}return o.push([n,r.right]),tS}))}}}let _=({es:n,output:r})=>Sn(n)?M(new $(e,t,tT(n),tT(r))):j(tT(r));if(g&&g.length>0){let e=g;return eS(()=>{let t={es:Hn(d),output:Hn(p)};return oS($x(e,e=>e(t),{concurrency:s,batching:c,discard:!0}),()=>_(t))})}return _({output:p,es:d})}}case`TypeLiteral`:{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return Yw(e,ce);let n=[],r={},i=[];for(let a of e.propertySignatures)n.push([Gw(a.type,t),a]),r[a.name]=null,i.push(a.name);let a=e.indexSignatures.map(e=>[Gw(e.parameter,t),Gw(e.type,t),e.parameter]),o=UC.make(e.indexSignatures.map(e=>e.parameter).concat(i.map(e=>ee(e)?new bC(e):new _C(e)))),s=Gw(o,t),c=Kw(e),l=qw(e);return(t,u)=>{if(!fe(t))return M(new Ew(e,t));let d=u?.errors===`all`,f=[],p=0,m=u?.onExcessProperty===`error`,h=u?.onExcessProperty===`preserve`,g={},_;if(m||h){_=Reflect.ownKeys(t);for(let n of _){let r=s(n,u);if(Nw(r)&&N(r))if(m){let r=new xw(n,t,new Sw(t[n],`is unexpected, expected: ${String(o)}`));if(d){f.push([p++,r]);continue}else return M(new $(e,t,r,g))}else g[n]=t[n]}}let v,ee=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(ee){let n=new xw(a,t,new Cw(i));if(d){f.push([p++,n]);continue}else return M(new $(e,t,n,g))}}let s=n[r][0],c=s(t[a],u);if(Nw(c)){if(N(c)){let n=new xw(a,t,o?c.left:new Cw(i));if(d){f.push([p++,n]);continue}else return M(new $(e,t,n,g))}g[a]=c.right}else{let n=p++,r=a;v||=[],v.push(({es:a,output:s})=>oS(aS(c),c=>{if(N(c)){let l=new xw(r,t,o?c.left:new Cw(i));return d?(a.push([n,l]),tS):M(new $(e,t,l,s))}return s[r]=c.right,tS}))}}for(let n=0;n<a.length;n++){let i=a[n],o=i[0],s=i[1],c=lS(t,i[2]);for(let n of c){let i=o(n,u);if(Nw(i)&&Bt(i)){let i=s(t[n],u);if(Nw(i))if(N(i)){let r=new xw(n,t,i.left);if(d){f.push([p++,r]);continue}else return M(new $(e,t,r,g))}else Object.prototype.hasOwnProperty.call(r,n)||(g[n]=i.right);else{let a=p++,o=n;v||=[],v.push(({es:s,output:c})=>oS(aS(i),i=>{if(N(i)){let n=new xw(o,t,i.left);return d?(s.push([a,n]),tS):M(new $(e,t,n,c))}else return Object.prototype.hasOwnProperty.call(r,n)||(c[n]=i.right),tS}))}}}}let te=({es:n,output:r})=>{if(Sn(n))return M(new $(e,t,tT(n),r));if(u?.propertyOrder===`original`){let e=_||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 j(n)}return j(r)};if(v&&v.length>0){let e=v;return eS(()=>{let t={es:Hn(f),output:Object.assign({},g)};return oS($x(e,e=>e(t),{concurrency:c,batching:l,discard:!0}),()=>te(t))})}return te({es:f,output:g})}}case`Union`:{let n=Zw(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],Gw(e.types[n],t));let s=Kw(e)??1,c=qw(e);return(t,l)=>{let u=[],d=0,f=[];if(i>0)if(ie(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=UC.make(r),s=e.length===a?new IC([new NC(i,o,!1,!0)],[]):UC.make(e);u.push([d++,new $(s,t,new xw(i,t,new Ew(o,t[i])))])}}else{let{candidates:e,literals:r}=n.keys[i],o=new NC(i,UC.make(r),!1,!0),s=e.length===a?new IC([o],[]):UC.make(e);u.push([d++,new $(s,t,new xw(i,t,new Cw(o)))])}}else{let r=n.candidates.length===a?e:UC.make(n.candidates);u.push([d++,new Ew(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(Nw(r)&&(!p||p.length===0)){if(Bt(r))return r;u.push([d++,r.left])}else{let e=d++;p||=[],p.push(t=>eS(()=>`finalResult`in t?tS:oS(aS(r),n=>(Bt(n)?t.finalResult=n:t.es.push([e,n.left]),tS))))}}let m=n=>Sn(n)?n.length===1&&n[0][1]._tag===`Type`?M(n[0][1]):M(new $(e,t,tT(n))):M(new Ew(e,t));if(p&&p.length>0){let e=p;return eS(()=>{let t={es:Hn(u)};return oS($x(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=uS(()=>Gw(e.f(),t));return(e,t)=>n()(e,t)}}},Yw=(e,t)=>n=>t(n)?j(n):M(new Ew(e,n)),Xw=(e,t)=>{switch(e._tag){case`Declaration`:{let n=lC(e);if(L(n))return Xw(n.value,t);break}case`TypeLiteral`:{let n=[];for(let r=0;r<e.propertySignatures.length;r++){let i=e.propertySignatures[r],a=t?mw(i.type):uw(i.type);vC(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?mw(i.type):uw(i.type);vC(a)&&!i.isOptional&&n.push([r,a])}return n}case`Refinement`:return Xw(e.from,t);case`Suspend`:return Xw(e.f(),t);case`Transformation`:return Xw(t?e.from:e.to,t)}return[]},Zw=(e,t)=>{let n={},r=[],i=[];for(let a=0;a<e.length;a++){let o=e[a],s=Xw(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}},Qw=e=>XC(e)?Qw(e.from):e,$w=(e,t,n,r)=>{if(r?.isEffectAllowed===!0||Nw(e))return e;let i=new Lg,a=sS(e,{scheduler:i});i.flush();let o=a.unsafePoll();if(o){if(d_(o))return j(o.value);let e=o.cause;return $f(e)?M(e.error):M(new Dw(t,n,ep(e)))}return M(new Dw(t,n,`cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work`))},eT=([e],[t])=>e>t?1:e<t?-1:0;function tT(e){return e.sort(eT).map(e=>e[1])}const nT=(e,t)=>{switch(e._tag){case`FinalTransformation`:return t?e.decode:e.encode;case`ComposeTransformation`:return j;case`TypeLiteralTransformation`:return n=>{let r=j(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=Fw(r,t=>{let n=a(Object.prototype.hasOwnProperty.call(t,e)?F(t[e]):P());return delete t[e],L(n)&&(t[i]=n.value),t})}return r}}},rT=(e,t=[])=>({value:e,forest:t}),iT={formatIssue:e=>Fw(TT(e),aT),formatIssueSync:e=>{let t=iT.formatIssue(e);return Nw(t)?Kt(t):cS(t)},formatError:e=>iT.formatIssue(e.issue),formatErrorSync:e=>iT.formatIssueSync(e.issue)},aT=e=>e.value+oT(` `,e.forest),oT=(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+=oT(e+(r>1&&!o?`│ `:` `),i.forest)}return n},sT=e=>{switch(e){case`Encoded`:return`Encoded side transformation failure`;case`Transformation`:return`Transformation process failure`;case`Type`:return`Type side transformation failure`}},cT=e=>{switch(e){case`From`:return`From side refinement failure`;case`Predicate`:return`Predicate refinement failure`}},lT=e=>`ast`in e?F(e.ast):P(),uT=j(void 0),dT=e=>lT(e).pipe(sn(QS),Qt({onNone:()=>uT,onSome:t=>{let n=t(e);return h(n)?j({message:n,override:!1}):Qx(n)?rS(n,e=>({message:e,override:!1})):h(n.message)?j({message:n.message,override:n.override}):rS(n.message,e=>({message:e,override:n.override}))}})),fT=e=>t=>t._tag===e,pT=fT(`Composite`),mT=fT(`Refinement`),hT=fT(`Transformation`),gT=e=>Pw(dT(e),t=>t===void 0?uT:!t.override&&(pT(e)||mT(e)&&e.kind===`From`||hT(e)&&e.kind!==`Transformation`)?hT(e)||mT(e)?gT(e.issue):uT:j(t.message)),_T=e=>lT(e).pipe(sn(oC),cn(t=>t(e)),nn);function vT(e){return rC(e).pipe($t(()=>eC(e)),$t(()=>tC(e)),$t(()=>nC(e)),R(()=>`{ ${e.from} | filter }`))}function yT(e){return e.message===void 0?`Expected ${XC(e.ast)?vT(e.ast):String(e.ast)}, actual ${Be(e.actual)}`:e.message}const bT=e=>Fw(gT(e),t=>t??_T(e)??yT(e)),xT=e=>_T(e)??String(e.ast),ST=e=>e.message??`is forbidden`,CT=e=>e.message??`is unexpected`,wT=e=>{let t=$S(e.ast);if(L(t)){let e=t.value();return h(e)?j(e):e}return j(e.message??`is missing`)},TT=e=>{switch(e._tag){case`Type`:return Fw(bT(e),rT);case`Forbidden`:return j(rT(xT(e),[rT(ST(e))]));case`Unexpected`:return j(rT(CT(e)));case`Missing`:return Fw(wT(e),rT);case`Transformation`:return Pw(gT(e),t=>t===void 0?Fw(TT(e.issue),t=>rT(xT(e),[rT(sT(e.kind),[t])])):j(rT(t)));case`Refinement`:return Pw(gT(e),t=>t===void 0?Fw(TT(e.issue),t=>rT(xT(e),[rT(cT(e.kind),[t])])):j(rT(t)));case`Pointer`:return Fw(TT(e.issue),t=>rT(mS(e.path),[t]));case`Composite`:return Pw(gT(e),t=>{if(t!==void 0)return j(rT(t));let n=xT(e);return dS(e.issues)?Fw($x(e.issues,TT),e=>rT(n,e)):Fw(TT(e.issues),e=>rT(n,[e]))})}},ET=t(e=>ae(e[0]),(e,...t)=>{let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}),DT=t(e=>ae(e[0]),(e,...t)=>{let n={...e};for(let e of t)delete n[e];return n}),OT=Symbol.for(`effect/Schema`);function kT(e){return class{[OT]=AT;static ast=e;static annotations(e){return kT(NT(this.ast,e))}static pipe(){return A(this,arguments)}static toString(){return String(e)}static Type;static Encoded;static Context;static[OT]=AT}}const AT={_A:e=>e,_I:e=>e,_R:e=>e},jT={typeConstructor:DS,schemaId:kS,message:AS,missingMessage:jS,identifier:MS,title:NS,description:FS,examples:IS,default:LS,documentation:HS,jsonSchema:RS,arbitrary:zS,pretty:BS,equivalence:VS,concurrency:US,batching:WS,parseIssueTitle:GS,parseOptions:KS,decodingFallback:qS},MT=e=>{if(!e)return{};let t={...e};for(let n in jT)if(n in e){let r=jT[n];t[r]=e[n],delete t[n]}return t},NT=(e,t)=>tw(e,MT(t)),PT=(e,t)=>{let n=Vw(e,t);return(e,t)=>Vt(n(e,t),Aw)},FT=e=>y(e,OT)&&ae(e[OT]);function IT(e){return GC(e)?UC.make(WC(e,e=>new _C(e))):new _C(e[0])}function LT(e,t=IT(e)){return class extends kT(t){static annotations(e){return LT(this.literals,NT(this.ast,e))}static literals=[...e]}}function RT(...e){return B(e)?LT(e):KT}const zT=(e,t,n)=>VT(e,new hC(e.map(e=>e.ast),(...e)=>t.decode(...e.map(kT)),(...e)=>t.encode(...e.map(kT)),MT(n))),BT=(e,t)=>{let n=()=>(t,n,r)=>e(t)?jw(t):Mw(new Ew(r,t));return VT([],new hC([],n,n,MT(t)))};function VT(e,t){return class extends kT(t){static annotations(e){return VT(this.typeParameters,NT(this.ast,e))}static typeParameters=[...e]}}const HT=function(){if(Array.isArray(arguments[0])){let e=arguments[0],t=arguments[1],n=arguments[2];return zT(e,t,n)}let e=arguments[0],t=arguments[1];return BT(e,t)},UT=Symbol.for(`effect/SchemaId/InstanceOf`),WT=(e,t)=>HT(t=>t instanceof e,{title:e.name,description:`an instance of ${e.name}`,pretty:()=>String,schemaId:UT,[UT]:{constructor:e},...t});var GT=class extends kT(yC){},KT=class extends kT(xC){},qT=class extends kT(wC){},JT=class extends kT(EC){};const YT=e=>UC.make(e.map(e=>e.ast));function XT(e,t=YT(e)){return class extends kT(t){static annotations(e){return XT(this.members,NT(this.ast,e))}static members=[...e]}}function ZT(...e){return GC(e)?XT(e):B(e)?e[0]:KT}const QT=e=>ZT(e,GT),$T=(e,t)=>new jC(e.map(e=>FT(e)?new kC(e.ast,!1):e.ast),t.map(e=>FT(e)?new OC(e.ast):e.ast),!0);function eE(e,t,n=$T(e,t)){return class extends kT(n){static annotations(e){return eE(this.elements,this.rest,NT(this.ast,e))}static elements=[...e];static rest=[...t]}}function tE(e,t){return class extends eE([],[e],t){static annotations(e){return tE(this.value,NT(this.ast,e))}static value=e}}const nE=e=>tE(e),rE=Symbol.for(`effect/PropertySignature`),iE=e=>y(e,rE),aE=cw([jS]),oE=(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(iE(c)){let e=c.ast;switch(e._tag){case`PropertySignatureDeclaration`:{let t=e.type,n=e.isOptional,o=e.annotations;i.push(new NC(s,t,n,!0,aE(e))),a.push(new NC(s,uw(t),n,!0,o)),r.push(new NC(s,t,n,!0,o));break}case`PropertySignatureTransformation`:{let t=e.from.fromKey??s;i.push(new NC(t,e.from.type,e.from.isOptional,!0,e.from.annotations)),a.push(new NC(s,e.to.type,e.to.isOptional,!0,e.to.annotations)),o.push(new $C(t,s,e.decode,e.encode));break}}}else i.push(new NC(s,c.ast,!1,!0)),a.push(new NC(s,uw(c.ast),!1,!0)),r.push(new NC(s,c.ast,!1,!0))}if(B(o)){let e=[],n=[];for(let r of t){let{indexSignatures:t,propertySignatures:o}=ow(r.key.ast,r.value.ast);o.forEach(e=>{i.push(e),a.push(new NC(e.name,uw(e.type),e.isOptional,e.isReadonly,e.annotations))}),t.forEach(t=>{e.push(t),n.push(new FC(t.parameter,uw(t.type),t.isReadonly))})}return new QC(new IC(i,e,{[PS]:`Struct (Encoded side)`}),new IC(a,n,{[PS]:`Struct (Type side)`}),new ew(o))}}let i=[];for(let e of t){let{indexSignatures:t,propertySignatures:n}=ow(e.key.ast,e.value.ast);n.forEach(e=>r.push(e)),t.forEach(e=>i.push(e))}return new IC(r,i)},sE=(e,t)=>{let n=Reflect.ownKeys(e);for(let r of n){let n=e[r];if(t[r]===void 0&&iE(n)){let e=n.ast,i=e._tag===`PropertySignatureDeclaration`?e.defaultValue:e.to.defaultValue;i!==void 0&&(t[r]=i())}}return t};function cE(e,t,n=oE(e,t)){return class extends kT(n){static annotations(e){return cE(this.fields,this.records,NT(this.ast,e))}static fields={...e};static records=[...t];static make=(t,n)=>{let r=sE(e,{...t});return TE(n)?r:Hw(this)(r)};static pick(...t){return lE(ET(e,...t))}static omit(...t){return lE(DT(e,...t))}}}function lE(e,...t){return cE(e,t)}const uE=e=>kT(sw(e.ast)),dE=Symbol.for(`effect/SchemaId/Refine`);function fE(e,t,n){return class extends kT(n){static annotations(e){return fE(this.from,this.filter,NT(this.ast,e))}static[dE]=e;static from=e;static filter=t;static make=(e,t)=>TE(t)?e:Hw(this)(e)}}const pE=(e,t,n)=>{if(_(e))return e?P():F(new Ew(t,n));if(h(e))return F(new Ew(t,n,e));if(e!==void 0){if(`_tag`in e)return F(e);let r=new Ew(t,n,e.message);return F(B(e.path)?new xw(e.path,n,r):r)}return P()},mE=(e,t,n)=>{if(fS(e))return pE(e,t,n);if(B(e)){let r=Xn(e,e=>pE(e,t,n));if(B(r))return F(r.length===1?r[0]:new $(t,n,r))}return P()};function hE(e,t){return n=>{function r(t,n,r){return mE(e(t,n,r),r,t)}return fE(n,r,new YC(n.ast,r,MT(t)))}}function gE(e,t,n){return class extends kT(n){static annotations(e){return gE(this.from,this.to,NT(this.ast,e))}static from=e;static to=t}}const _E=ES,vE=(e,t)=>n=>n.pipe(hE(t=>t.length<=e,{schemaId:_E,title:`maxLength(${e})`,description:`a string at most ${e} character(s) long`,jsonSchema:{maxLength:e},...t})),yE=TS,bE=(e,t)=>n=>n.pipe(hE(t=>t.length>=e,{schemaId:yE,title:`minLength(${e})`,description:`a string at least ${e} character(s) long`,jsonSchema:{minLength:e},...t})),xE=CS,SE=(e,t)=>n=>n.pipe(hE(t=>t>=e,{schemaId:xE,title:`greaterThanOrEqualTo(${e})`,description:e===0?`a non-negative number`:`a number greater than or equal to ${e}`,jsonSchema:{minimum:e},...t})),CE=wS,wE=(e,t)=>n=>n.pipe(hE(t=>t<=e,{schemaId:CE,title:`lessThanOrEqualTo(${e})`,description:e===0?`a non-positive number`:`a number less than or equal to ${e}`,jsonSchema:{maximum:e},...t}));HT(le,{typeConstructor:{_tag:`Uint8Array`},identifier:`Uint8ArrayFromSelf`,pretty:()=>e=>`new Uint8Array(${JSON.stringify(Array.from(e))})`,arbitrary:()=>e=>e.uint8Array(),equivalence:()=>$n(E)});function TE(e){return _(e)?e:e?.disableValidation??!1}const EE=lE({id:JT,created:WT(Date),title:qT.pipe(bE(1),vE(100)),type:RT(`jpg`,`png`),size:JT,url:qT.pipe(hE(e=>{try{return new URL(e),!0}catch{return!1}}))}),DE=lE({id:JT,stars:JT.pipe(SE(0),wE(5)),title:qT.pipe(bE(1),vE(100)),text:qT.pipe(bE(1),vE(1e3)),images:uE(nE(EE))});PT(lE({id:JT,created:WT(Date),title:qT.pipe(bE(1),vE(100)),brand:qT.pipe(bE(1),vE(30)),description:qT.pipe(bE(1),vE(500)),price:JT.pipe(SE(1),wE(1e4)),discount:QT(JT.pipe(SE(1),wE(100))),quantity:JT.pipe(SE(1),wE(10)),tags:uE(nE(qT.pipe(bE(1),vE(30)))),images:uE(nE(EE)),ratings:uE(nE(DE))}))({});
Created by eskimojo for Open Circle