@deslop/auth 0.1.1249 → 0.1.1250

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ var e=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:retu
11
11
  `)},Hs=e=>Ps(e).map(Us).join(`
12
12
  `),Us=e=>e.cause?`${e.stack} {\n${Ws(e.cause,` `)}\n}`:e.stack,Ws=(e,t)=>{let n=e.stack.split(`
13
13
  `),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${Ws(e.cause,`${t} `)}\n${t}}`),r},Gs=`~effect/Fiber`,Ks={_A:i,_E:i},qs={id:0},Js=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),Ys=()=>Js===void 0?void 0:new Js(`effect/Fiber`),Xs=()=>globalThis[gt],Zs=class{constructor(e,t=!0){this.setContext(e),this.id=++qs.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[Gs](){return Ks}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return O(this.context,e)}addObserver(e){return this._exit?(e(this._exit),l):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let n=ys(e);this.cache.stackFrame&&(n=gn(n,da(wn,this.cache.stackFrame))),t&&(n=gn(n,t)),this._interruptedCause=this._interruptedCause?dn(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(M(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._asyncContext!==void 0){let t=this._asyncContext;this._asyncContext=void 0;try{return t.runInAsyncScope(this.evaluate,this,e)}finally{t.emitDestroy()}}else if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===qt){this._asyncContext=Ys();return}let n=tc.interruptChildren&&tc.interruptChildren(this);if(n!==void 0)return this.evaluate(I(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=la();let r=this.cache;(r.span!==void 0||r.stackFrame!==void 0)&&(this.cache={...r,span:void 0,stackFrame:void 0})}runLoop(e){let t=globalThis[gt];globalThis[gt]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,i=M(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=I(pc,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[Ut](this),i===qt){let e=this._yielded;if(`~effect/Exit`in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return qt}}catch(e){if(!v(i,`~effect/Effect/evaluate`))return On(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=On(e)}}finally{this._running=n,globalThis[gt]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,$s;for(;;){let t=this._stack.pop();if(!t)return;let n=t[Kt];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}succeedWith(e){if(!(++this.currentOpCount&ec-1))return C(e);let t=this.getCont(Wt);return t?t[Wt](e,this):this.yieldWith(C(e))}yieldWith(e){return this._yielded=e,qt}children(){return this._children??=new Set}pipe(){return e(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&oa(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=Qs(e);this.cache?.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}},Qs=e=>{let t=ha(e,es);return{scheduler:O(e,ko),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:O(e,os),span:ha(e,Jo),logLevel:O(e,ds),minimumLogLevel:O(e,fs),stackFrame:O(e,as),runtimeMetrics:ha(e,is),maxOpsBeforeYield:O(e,Io),preventYield:O(e,Lo)}},$s={[Wt](e,t){return M(t._interruptedCause)},[Gt](e,t){return M(t._interruptedCause)}},ec=32,tc={interruptChildren:void 0},nc=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Tn.key,e.cache.stackFrame),ia(t)},rc=e=>{if(e._children!==void 0&&e._children.size!==0)return uc(e._children)},ic=e=>{let t=e;return t._exit?j(t._exit):Sc(n=>t._exit?n(j(t._exit)):N(e.addObserver(e=>n(j(e)))))},ac=e=>Sc(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;)if(e.value._exit)r.push(e.value._exit),e=n.next();else{i=e.value.addObserver(e=>{r.push(e),a()});return}t(j(r))}return a(),N(()=>i?.())}),oc=e=>{let t=e;return t._exit?t._exit:Sc(n=>t._exit?n(t._exit):N(e.addObserver(n)))},sc=e=>Sc(t=>{let n=Array.from(e);if(n.length===0)return t(j(ji()));let r=Array(n.length),i=ji(),a=()=>{for(let e=0;e<i.length;e++)n[e].removeObserver(i[e])},o=0,s=!1;for(let e=0;e<n.length&&!s;e++){let c=i=>{if(o++,i._tag===`Failure`)return s=!0,a(),t(i);r[e]=i.value,o===n.length&&t(j(r))};i.push(c),n[e].addObserver(c)}return N(()=>{s=!0,a()})}),cc=e=>w(t=>lc(e,t.id)),lc=r(e=>v(e[0],Gs),(e,t,n)=>w(r=>{let i=nc(r);return i=i&&n?xa(i,n):i??n,e.interruptUnsafe(t,i),Gc(ic(e))})),uc=e=>w(t=>{let n=nc(t),r=ji();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return Gc(ac(r))}),j=C,M=En,dc=Dn,N=Sn({op:`Sync`,[Ut](e){let t=this[S],n=t(),r=e.getCont(Wt);return r?r[Wt](n,e):e.yieldWith(C(n))}}),P=Sn({op:`Suspend`,[Ut](e){let t=this[S];return t()}}),fc=Gr({onFailure:dc,onSuccess:j}),pc=Sn({op:`Yield`,[Ut](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(cl)},this[`~effect/Effect/args`]??0),e.yieldWith(()=>{t=!0})}})(0),mc=j(T()),hc=e=>P(()=>M(e())),gc=e=>On(e),F=j(void 0),_c=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new rf(e,`An error occurred in Effect.try`):e.catch;return P(()=>{try{return j(t())}catch(e){return dc(n(e))}})},vc=e=>bc(function(t,n){e(n).then(e=>t(j(e)),e=>t(gc(e)))},e.length!==0),yc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new rf(e,`An error occurred in Effect.tryPromise`):e.catch;return bc(function(e,r){let i=e=>P(()=>{try{return dc(Rt(()=>n(e)))}catch(e){return gc(e)}});try{t(r).then(t=>e(j(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},bc=function(){let e=xn({op:`Async`,[Ut](e){let t=!1,n=!1,r=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,r=>{t||(t=!0,n?e.evaluate(r):n=r)},r?.signal);return n===!1?(n=!0,e.yieldWith(()=>{t=!0}),r===void 0&&i===void 0||e._stack.push(xc(()=>(t=!0,r?.abort(),i??cl))),qt):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),xc=Sn({op:`AsyncFinalizer`,[Kt](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Hu))},[Gt](e,t){return Es(e)?I(du(En(e),this[S]()),()=>M(e)):M(e)}}),Sc=e=>bc(e,e.length>=2),Cc=Sc(l),wc=(...e)=>{if(e.length===1){let t=e[0];return P(()=>Ac(t()))}let[t,n]=e;return P(()=>Ac(n.call(t.self)))},Tc=(e,t)=>typeof e==`function`?e:t.shift().bind(e.self),Ec=(e,...t)=>{let n=Tc(e,t),r=t.length===0?function(){return P(()=>Ac(n.apply(this,arguments)))}:function(){let e=P(()=>Ac(n.apply(this,arguments)));for(let n=0;n<t.length;n++)e=t[n](e,...arguments);return e};return Dc(n.length,r)},Dc=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),Oc=(e,...t)=>{let n=Tc(e,t);return Dc(n.length,t.length===0?function(){return kc(()=>n.apply(this,arguments))}:function(){let e=kc(()=>n.apply(this,arguments));for(let n of t)e=n(e,...arguments);return e})},kc=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return j(r.value);let i=r.value;if(i&&i._tag===`Success`)n=i.value;else{if(i&&i._tag===`Failure`)return r.value;{let n=!0;return P(()=>n?(n=!1,I(r.value,e=>Ac(t,e))):P(()=>Ac(e())))}}}}catch(e){return gc(e)}},Ac=function(){let e=xn({op:`Iterator`,[Wt](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return j(r.value);if(!L(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[Ut](e){return this[Wt](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),jc=r(2,(e,t)=>new Pc(e,Fc,j(t))),Mc=function(e){return e._stack.push(this),this[S]},Nc=xn({op:`OnSuccess`,[Ut]:Mc}),Pc=function(e,t,n){this[S]=e,this[Wt]=t,this.payload=n};Pc.prototype=Nc;var Fc=function(){return this.payload},Ic=function(e,t){return t.succeedWith(this.payload)},Lc=(()=>{let e=Ft();if(e===0)return!1;let t=`~effect/Effect/stackProbe`,n={[t]:function(){return Error()}};It(1);let r=n[t]();return It(e),r.stack?.includes(`[as `+t+`]`)===!0})(),Rc=function(e,t){let n=this.payload;return t.succeedWith(Lc?n(e):Rt(()=>n(e)))},zc=function(e){let t=this.payload;return t(e)},Bc=function(e){let t=this.payload;return new Pc(t(e),Ic,e)},Vc=function(e){return new Pc(this.payload,Ic,e)},Hc=e=>Qc(e,E),Uc=r(2,(e,t)=>new Pc(e,Xt(t)?Fc:zc,t)),Wc=r(2,(e,t)=>new Pc(e,Xt(t)?Vc:Bc,t)),Gc=e=>new Pc(e,Fc,cl),Kc=(e,t)=>w(n=>{let r=new Set;return ku(n,()=>r.size===0?void 0:uc(r)),Sc(i=>{let a=ui(e),o=a.length,s=0,c=!1,l=[],u=(e,r,a)=>{if(s++,e._tag===`Failure`){l.push(...e.cause.reasons),s>=o&&i(M(ws(cn(l))));return}let u=!c;c=!0,i(e),u&&t?.onWinner&&t.onWinner({fiber:r,index:a,parentFiber:n})};for(let e=0;e<o;e++){let t=id(n,a[e],!0,!0,!1);if(r.add(t),t.addObserver(n=>{r.delete(t),u(n,t,e)}),c)break}})}),qc=(e,t)=>w(n=>{let r=new Set;return ku(n,()=>r.size===0?void 0:uc(r)),Sc(i=>{let a=!1,o=0;for(let s of e){if(a)break;let e=o++,c=id(n,s,!0,!0,!1);r.add(c),c.addObserver(o=>{r.delete(c);let s=!a;a=!0,i(o),s&&t?.onWinner&&t.onWinner({fiber:c,index:e,parentFiber:n})})}})}),Jc=r(e=>Xt(e[1]),(e,t,n)=>Kc([e,t],n)),Yc=r(e=>Xt(e[1]),(e,t,n)=>qc([e,t],n)),I=r(2,(e,t)=>new Pc(e,zc,t)),L=e=>e[Bt]!==void 0,Xc=r(2,(e,t)=>L(e)?e._tag===`Success`?t(e.value):e:I(e,t)),Zc=e=>I(e,i),Qc=r(2,(e,t)=>new Pc(e,Rc,t)),$c=r(2,(e,t)=>L(e)?ll(e,t):Qc(e,t)),el=r(2,(e,t)=>L(e)?ul(e,t):Il(e,t)),tl=r(2,(e,t)=>L(e)?dl(e,t):Ll(e,t)),nl=r(2,(e,t)=>{if(L(e)){if(e._tag===`Success`)return e;let n=Ts(e.cause);return D(n)?En(n.failure):t(n.success)}return Al(e,t)}),rl=e=>En(ys(e)),il=e=>e._tag===`Success`,al=e=>e._tag===`Failure`,ol=e=>e._tag===`Failure`?Lr(e.cause):Rr(e),sl=e=>e._tag===`Failure`&&Es(e.cause),cl=C(void 0),ll=r(2,(e,t)=>e._tag===`Success`?C(t(e.value)):e),ul=r(2,(e,t)=>e._tag===`Success`?e:En(Ms(e.cause,t))),dl=r(2,(e,t)=>e._tag===`Success`?C(t.onSuccess(e.value)):En(Ms(e.cause,t.onFailure))),fl=r(2,(e,t)=>il(e)?t:e),pl=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?cl:En(cn(t))},ml=e=>w(t=>j(ba(t.context,e))),hl=r(2,(e,t)=>w(n=>{let r=n.context,i=t(r);return r===i||(n.setContext(i),ku(n,()=>{n.setContext(r)})),e})),gl=r(3,(e,t,n)=>hl(e,e=>{let r=ga(e,t),i=n(r);return r===i?e:fa(e,t,i)})),_l=()=>vl,vl=w(e=>j(e.context)),yl=e=>w(t=>e(t.context)),bl=r(2,(e,t)=>L(e)?e:hl(e,xa(t))),xl=function(){return arguments.length===1?r(2,(e,t)=>Sl(e,arguments[0],t)):r(3,(e,t,n)=>Sl(e,t,n)).apply(this,arguments)},Sl=(e,t,n)=>hl(e,fa(t,n)),Cl=r(2,(e,t)=>I(t,t=>t?Hc(e):mc)),wl=r(e=>Xt(e[0]),(e,t)=>Yu({while:o,body:a(t?.disableYield?e:I(e,e=>pc)),step:l})),Tl=r(2,(e,t)=>new Dl(e,t.length===1?t:e=>t(e))),El=xn({op:`OnFailure`,[Ut]:Mc}),Dl=function(e,t){this[S]=e,this[Gt]=t};Dl.prototype=El;var Ol=r(3,(e,t,n)=>Tl(e,e=>t(e)?n(e):M(e))),kl=r(3,(e,t,n)=>Tl(e,e=>{let r=t(e);return D(r)?M(r.failure):n(r.success,e)})),Al=r(2,(e,t)=>kl(e,Ts,e=>t(e))),jl=r(2,(e,t)=>Tl(e,e=>Uc(t(e),M(e)))),Ml=r(3,(e,t,n)=>Tl(e,e=>{let r=t(e);return D(r)?M(e):Uc(n(r.success,e),M(e))})),Nl=r(2,(e,t)=>Ml(e,xs,e=>t(e))),Pl=r(e=>Xt(e[0]),(e,t,n,r)=>Tl(e,e=>{let i=Ts(e);return D(i)?M(i.failure):t(i.success)?n(i.success):r?r(i.success):M(e)})),Fl=r(e=>Xt(e[0]),(e,t,n,r)=>Pl(e,Array.isArray(t)?e=>v(e,`_tag`)&&t.includes(e._tag):_e(t),n,r)),Il=r(2,(e,t)=>Tl(e,e=>M(Ms(e,t)))),Ll=r(2,(e,t)=>Wl(e,{onFailure:e=>M(Ms(e,t.onFailure)),onSuccess:e=>N(()=>t.onSuccess(e))})),Rl=e=>Al(e,gc),zl=e=>e===`Unhandled`?(...e)=>w(t=>{let n=t.getRef(ps);return n===void 0?F:pf(n)(...e)}):pf(e===!0?void 0:e),Bl=r(e=>Xt(e[0]),(e,t)=>{if(!t?.log)return Yl(e,{onFailure:e=>F,onSuccess:e=>F});let n=zl(t.log);return Wl(e,{onFailure(e){let r=Ts(e);return D(r)?M(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>F})}),Vl=r(e=>Xt(e[0]),(e,t)=>{if(!t?.log)return Wl(e,{onFailure:e=>F,onSuccess:e=>F});let n=zl(t.log);return Wl(e,{onFailure:e=>t.message===void 0?n(e):n(t.message,e),onSuccess:e=>F})}),Hl=e=>Xl(e,{onFailure:T,onSuccess:E}),Ul=e=>Zl(e,{onFailure:Rr,onSuccess:Lr}),Wl=r(2,(e,t)=>new Kl(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),Gl=xn({op:`OnSuccessAndFailure`,[Ut]:Mc}),Kl=function(e,t,n){this[S]=e,this[Wt]=t,this[Gt]=n};Kl.prototype=Gl;var ql=function(e,t){let n=this.payload;return t.succeedWith(Lc?n.onSuccess(e):Rt(()=>n.onSuccess(e)))},Jl=((e,t)=>{let n=xn({op:e,[Ut]:Mc,[Wt]:ql,[Gt]:t}),r=function(e,t){this[S]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=Ts(e);if(D(n))return M(n.failure);let r=this.payload;return t.succeedWith(Lc?r.onFailure(n.success):Rt(()=>r.onFailure(n.success)))}),Yl=r(2,(e,t)=>Wl(e,{onFailure:e=>{let n=Ts(e);return D(n)?M(n.failure):t.onFailure(n.success)},onSuccess:t.onSuccess})),Xl=r(2,(e,t)=>new Jl(e,t)),Zl=r(2,(e,t)=>{if(L(e)){if(e._tag===`Success`)return C(t.onSuccess(e.value));let n=Ts(e.cause);return D(n)?En(n.failure):C(t.onFailure(n.success))}return Xl(e,t)}),Ql=e=>L(e)?C(e):$l(e),$l=Sn({op:`Exit`,[Ut](e){return e._stack.push(this),this[S]},[Wt](e,t,n){return t.succeedWith(n??C(e))},[Gt](e,t,n){return t.succeedWith(n??En(e))}}),eu=r(2,(e,t)=>Uc(Kd(t),e)),tu=r(2,(e,t)=>I(iu(e,t.duration),e=>yr(e)?t.orElse():j(e.value))),nu=e=>new Zd(`Operation timed out after '${wo(e)}'`),ru=r(2,(e,t)=>{let n=Ga(t);return tu(e,{duration:n,orElse:()=>dc(nu(n))})}),iu=r(2,(e,t)=>Yc(Hc(e),jc(Kd(t),T()))),au=`~effect/Scope`,ou=`~effect/Scope/Closeable`,su=Ki(`effect/Scope`),cu=(e,t)=>w(n=>(Gu(n),lu(e,t)??F)),lu=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&_u(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return uu(n.finalizer,t);let r=n.finalizers;return r.size===1?uu(r.values().next().value,t):fu(e,r,t)},uu=(e,t)=>{try{return e(t)}catch(e){return On(e)}},du=(e,t)=>il(e)?t:Tl(t,t=>M(ws(un(e.cause,t)))),fu=Ec(function*(e,t,n){let r=[],i=[],a=Array.from(t),o=Xs();for(let t=a.length-1;t>=0;t--){let[s,c]=a[t];e.strategy===`sequential`?r.push(yield*Ql(uu(c,n))):s!==o&&i.push(id(o,uu(c,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*ac(i)),yield*pl(r)}),pu=(e,t)=>{let n=yu(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(gu(e,n,e=>cu(n,e)),n)},mu=(e,t)=>P(()=>e.state._tag===`Closed`?t(e.state.exit):(gu(e,{},t),F)),hu=(e,t)=>mu(e,a(t)),gu=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0||(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0),r.finalizers.set(t,n)}},_u=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=bu:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=bu))},vu=e=>yu(e,void 0),yu=(e=`sequential`,t)=>({[ou]:ou,[au]:au,strategy:e,parent:t,state:bu}),bu={_tag:`Empty`},xu=su,Su=xl(su),Cu=e=>w(t=>{let n=t.context,r=vu();return t.setContext(fa(t.context,su,r)),ku(t,e=>(t.setContext(n),lu(r,e))),e}),wu=e=>P(()=>{let t=vu();return Au(e(t),e=>P(()=>lu(t,e)??F))}),Tu=(e,t,n)=>yl(r=>qu(i=>I(xu,a=>Wc(n?.interruptible?i(e):e,e=>mu(a,n=>bl(t(e,n),r)))))),Eu=e=>I(xu,t=>yl(n=>mu(t,t=>bl(e(t),n)))),Du=function(){let e=xn({op:`OnExit`,[Ut](e){return e._stack.push(this),this.effect},[Kt](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(Hu),e.interruptible=!1)},[Wt](e,t,n){n??=C(e);let r;try{r=this.onExit(n)}catch(e){r=On(e)}return r?I(r,e=>n):n},[Gt](e,t,n){n??=En(e);let r;try{r=this.onExit(n)}catch(e){r=On(e)}return r?I(du(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),Ou=(e,t,n)=>new Du(e,t,n),ku=(e,t)=>{e._stack.push(new Du(void 0,t,void 0))},Au=r(2,Ou),ju=r(2,(e,t)=>Au(e,e=>t)),Mu=r(3,(e,t,n)=>Au(e,e=>{let r=t(e);return D(r)?F:n(r.success,e)})),Nu=r(2,(e,t)=>Mu(e,ol,t)),Pu=r(3,(e,t,n)=>Au(e,e=>{if(e._tag!==`Failure`)return F;let r=t(e.cause);return D(r)?F:n(r.success,e.cause)})),Fu=r(2,(e,t)=>Pu(Ds,t)(e)),Iu=a(1/0),Lu=(e,t)=>{let n=0,r,i,a=(e,t)=>(t.awaiters++,ku(e,()=>{if(!(--t.awaiters>0||t.done))return i===t&&(i=void 0),cc(t.fiber)}),oc(t.fiber));return[w(o=>{if(i!==void 0)return o===i.fiber?oc(i.fiber):a(o,i);if(r!==void 0&&(n===1/0||o.getRef(zd).currentTimeMillisUnsafe()<n))return r;r=void 0;let s=o.getRef(zd),c={fiber:new Zs(o.context),awaiters:0,done:!1};i=c;let l=a(o,c);return c.fiber.evaluate(Ou(e,e=>{if(c.done=!0,i!==c||(i=void 0,sl(e)))return;let a=t(e);n=a===1/0?1/0:s.currentTimeMillisUnsafe()+a,r=e})),c.fiber._exit??l}),N(()=>{i=void 0,r=void 0})]},Ru=e=>N(()=>Lu(e,Iu)[0]),zu=w(e=>M(ys(e.id))),Bu=e=>w(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(Hu)),e)),Vu=Sn({op:`SetInterruptible`,[Kt](e){if(e.interruptible=this[S],e._interruptedCause&&e.interruptible)return()=>M(e._interruptedCause)}}),Hu=Vu(!0),Uu=Vu(!1),Wu=e=>{if(e.interruptible=!0,e._stack.push(Uu),e._interruptedCause)return M(e._interruptedCause)},Gu=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(Hu))},Ku=e=>w(t=>t.interruptible?e:Wu(t)??e),qu=e=>w(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Hu),e(Ku)):e(i)),Ju=(e,t)=>ye(e)?t?.mode===`result`?Xu(e,Ul,t):Xu(e,i,t):t?.discard?t.mode===`result`?Xu(Object.values(e),Ul,t):Xu(Object.values(e),i,t):P(()=>Qc(Xu(Object.entries(e),([e,n])=>Qc(t?.mode===`result`?Ul(n):n,t=>[e,t]),{concurrency:t?.concurrency}),Object.fromEntries)),Yu=Sn({op:`While`,[Wt](e,t){return this[S].step(e),this[`~effect/Effect/args`].while()?(t._stack.push(this),this[S].body()):cl},[Ut](e){return this[`~effect/Effect/args`].while()?(e._stack.push(this),this[S].body()):cl}}),Xu=r(e=>typeof e[1]==`function`,(e,t,n)=>P(()=>{let r=Qu(n?.concurrency);if(r===1)return Zu(e,t,n);let i=ui(e),a=i.length;if(a===0)return n?.discard?F:j([]);let o=n?.discard?void 0:Array(a),s=nd({f:t,out:o},i,{concurrency:r});return s?jc(s,o):j(o)})),Zu=(e,t,n)=>P(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return jc(Yu({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Qu=e=>e===`unbounded`?1/0:Math.max(1,e??1),$u=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>I(Ql(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??F),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!L(c))return r(e,i,a,o,c);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return i},ed=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f,p,m=e=>{let t=On(e);return f=t,c=!0,u&&u.size>0?I(Bu(uc(Array.from(u))),()=>f??t):t},h=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],g=p??t(e,o,a);if(L(g)){if(f=n(e,o,g,a),f)break}else if(l){p=void 0;let t=id(l,g,!0,!0,`inherit`);if(t._exit){if(f=n(e,o,t._exit,a),f)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(f){if(a._tag===`Failure`){let e=a.cause.reasons.filter(e=>e._tag!==`Interrupt`);if(e.length>0){let t=cn(e);f=En(f._tag===`Failure`?ws(un(f.cause,t)):t)}}}else{let t=n(e,o,a,r);t&&(f=t,h())}if(i){let e=h();e&&d(e)}else c&&u.size===0&&d(f??F)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return Sc(e=>{l=Xs(),u=new Set,p=g,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):P(()=>(f??=cl,I(u?uc(u):F,()=>f?._tag===`Failure`?f:F)))})}if(c=!0,f){if(u&&u.size>0){let e=nc(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||f._tag===`Failure`)return f}else if(d){if(u)u.size===0&&d(F);else return cl}};return h()}},td=()=>e=>ed(e),nd=ed({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),rd=r(e=>Xt(e[0]),(e,t)=>w(n=>(vf(),j(id(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),id=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Zs(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=Ys(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},ad=r(e=>Xt(e[0]),(e,t)=>w(n=>j(id(n,e,t?.startImmediately,!0,t?.uninterruptible)))),od=e=>()=>w(t=>t===e?F:cc(e)),sd=r(e=>Xt(e[0]),(e,t,n)=>w(r=>{let i=t.state._tag===`Closed`?new Zs(r.context):id(r,e,n?.startImmediately,!0,n?.uninterruptible);return i._exit||(t.state._tag===`Closed`?i.interruptUnsafe(r.id,nc(r)):(gu(t,i,od(i)),i.addObserver(()=>_u(t,i)))),j(i)})),cd=r(e=>Xt(e[0]),(e,t)=>I(xu,n=>sd(e,n,t))),ld=e=>(t,n)=>{let r=new Zs(n?.scheduler?fa(e,ko,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},ud=r(2,(e,t)=>e._exit?e:t.state._tag===`Closed`?(e.interruptUnsafe(e.id),e):(_u(t,e),gu(t,e,od(e)),e.addObserver(()=>_u(t,e)),e)),dd=ld(la()),fd=e=>{let t=ld(e);return(e,n)=>{let r=t(e,n);return n?.onExit&&r.addObserver(n.onExit),e=>r.interruptUnsafe(e)}},pd=fd(la()),md=e=>{let t=ld(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},hd=md(la()),gd=(e=>{let t=md(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw Ns(e.cause);return e.value})})(la()),_d=e=>{let t=ld(e);return e=>{if(L(e))return e;let n=new Po(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??On(new tf(r))}},vd=_d(la()),yd=e=>{let t=_d(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw Ns(n.cause);return n.value}},bd=yd(la()),xd=j(!0),Sd=j(!1),Cd=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return xd;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],xd}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](cl)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](cl)}open=w(e=>this._isOpen?Sd:(this._isOpen=!0,this.scheduleUnsafe(e)));release=w(e=>this._isOpen?Sd:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=Sc(e=>this._isOpen?e(F):(this.waiters.push(e),N(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=N(()=>this.closeUnsafe());whenOpen=e=>I(this.await,()=>e);isOpen(){return this._isOpen}},wd=e=>new Cd(e??!1),Td=e=>N(()=>wd(e)),Ed=xl(os),Dd=BigInt(0),Od={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:Dd,endTime:Dd,exit:cl},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},kd=e=>Object.assign(Object.create(Od),e),Ad=e=>e?O(e.annotations,Zo)?e._tag===`Span`?Ad(Dr(e.parent)):T():E(e):T(),jd=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&O(n.annotations,Zo),i=n?.parent===void 0?n?.root?T():Ad(e.cache.span):E(n.parent),a;if(r)a=kd({name:t,parent:i,annotations:fa(n?.annotations??la(),Zo,!0)});else{let r=e.cache.tracer??ns,o=e.getRef(zd),s=e.getRef(ss),c=e.getRef(cs),l=e.getRef(ls),u=n?.level??e.getRef(Qo),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??la(),links:d,startTime:s?o.currentTimeNanosUnsafe():Dd,kind:n?.kind??`internal`,root:n?.root??!1,sampled:n?.sampled??(br(i)&&i.value.sampled===!1?!1:!of(e.getRef($o),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},Md=(e,t)=>Bu(w(n=>{let r=ga(n.context,su),i=jd(n,e,t??{}),a=n.getRef(zd),o=n.getRef(ss);return jc(mu(r,e=>Pd(i,e,a,o)),i)})),Nd=(e,t)=>(t=typeof t==`function`?t:c,gl(as,n=>({name:e,stack:t,parent:n}))),Pd=(e,t,n,r)=>N(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():Dd,t)}),Fd=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return w(t=>{let i=jd(t,e,n),a=t.getRef(zd),o=t.getRef(ss);return ku(t,e=>Pd(i,e,a,o)),r(i)})},Id=xl(Yo),Ld=function(){let e=Xt(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=i;return t._tag===`Span`&&(n=hs(n),r=Nd(t.name,n?.captureStackTrace)),e?Id(r(arguments[0]),t):e=>Id(r(e),t)},Rd=function(){let e=typeof arguments[0]!=`string`,t=e?arguments[1]:arguments[0],n=hs(arguments[2]);if(e){let e=arguments[0];return Fd(t,arguments[2],t=>Ld(e,t,n))}let r=typeof arguments[1]==`function`?arguments[1]:void 0,i=r?void 0:arguments[1];return(e,...a)=>Fd(t,r?r(...a):i,t=>Ld(e,t,n))},zd=k(`effect/Clock`,{defaultValue:()=>new Vd}),Bd=2**31-1,Vd=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=N(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return Wd()}currentTimeNanos=N(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return Ud()}monotonicTimeNanos=N(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(fo(e))}sleepMillis(e){return e<=0?pc:Number.isFinite(e)?Sc(t=>{let n=e>Bd?this.sleepMillis(e-Bd):F,r=setTimeout(()=>t(n),Math.min(e,Bd));return N(()=>clearTimeout(r))}):Cc}},Hd=BigInt(1e6),Ud=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*Hd;return e>t&&(t=e),t}}(),Wd=function(){let e=BigInt(1e9),t;return()=>{let n=Ud(),r=BigInt(Date.now())*Hd;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),Gd=e=>w(t=>e(t.getRef(zd))),Kd=e=>Gd(t=>t.sleep(Ga(e))),qd=Gd(e=>e.currentTimeMillis),Jd=Gd(e=>e.currentTimeNanos),Yd=`~effect/Cause/TimeoutError`,Xd=e=>v(e,Yd),Zd=class extends jn(`TimeoutError`){[Yd]=Yd;constructor(e){super({message:e})}},Qd=`~effect/Cause/IllegalArgumentError`,$d=class extends jn(`IllegalArgumentError`){[Qd]=Qd;constructor(e){super({message:e})}},ef=`~effect/Cause/AsyncFiberError`,tf=class extends jn(`AsyncFiberError`){[ef]=ef;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},nf=`~effect/Cause/UnknownError`,rf=class extends jn(`UnknownError`){[nf]=nf;constructor(e,t){super({message:t,cause:e})}},af=k(`effect/Console`,{defaultValue:()=>globalThis.console}),of=hr(mr(dr,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),sf=k(`effect/Logger/CurrentLoggers`,{defaultValue:()=>new Set([gf,_f])}),cf=k(`effect/Logger/LogToStderr`,{defaultValue:s}),lf={"~effect/Logger":{_Message:i,_Output:i},pipe(){return e(this,arguments)}},uf=e=>{let t=Object.create(lf);return t.log=e,t},df=e=>e.replace(/[\s="]/g,`_`),ff=(e,t)=>`${df(e[0])}=${t-e[1]}ms`,pf=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];en(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?cn(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=fn),w(r=>{let i=e??r.cache.logLevel;if(of(r.cache.minimumLogLevel,i))return F;let a=r.getRef(zd),o=r.getRef(sf);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return F})},mf={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};mf.gray,mf.blue,mf.green,mf.yellow,mf.red,mf.bgBrightRed,mf.black;var hf=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,gf=uf(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(Hs(e));let o=t.getTime(),s=n.getRef(ms),c=``;for(let e of s)c+=` ${ff(e,o)}`;let l=n.getRef(us);Object.keys(l).length>0&&a.push(l);let u=n.getRef(af);(n.getRef(cf)?u.error:u.log)(`[${hf(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),_f=uf(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(zd),a=t.getRef(us),o=t.cache.span;if(o===void 0||o._tag===`ExternalSpan`||o.status._tag===`Ended`)return;let s={};for(let[e,t]of Object.entries(a))b(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=Hs(e)),o.event(jt(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)});function vf(){tc.interruptChildren??=rc}var yf=j(void 0),bf=en,xf=tn,Sf=_n,Cf=vn,wf=yn,Tf=cn,Ef=pn,Df=hn,Of=ys,kf=e=>new sn(e),Af=e=>new mn(e),jf=vs,Mf=As,Nf=Ms,Pf=Ns,Ff=xs,If=Ss,Lf=Es,Rf=Os,zf=Ds,Bf=Ps,Vf=Nn,Hf=Fn,Uf=zn,Wf=Xd,Gf=$d,Kf=js,qf=zd,Jf=qd,Yf=Jd,Xf=Zt,Zf=C,Qf=En,$f=Dn,ep=On,tp=rl,np=cl,rp=il,ip=al,ap=pl,op={"~effect/Deferred":{_A:i,_E:i},pipe(){return e(this,arguments)}},sp=function(){this.resumes=void 0,this.effect=void 0};sp.prototype=op;var cp=()=>new sp,lp=()=>N(()=>cp()),up=e=>Sc(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),N(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),dp=r(2,(e,t)=>N(()=>vp(e,t))),fp=r(2,(e,t)=>dp(e,Dn(t))),pp=r(2,(e,t)=>dp(e,En(t))),mp=r(2,(e,t)=>pp(e,ys(t))),hp=e=>e.effect!==void 0;function gp(e){return N(()=>Tr(e.effect))}var _p=r(2,(e,t)=>dp(e,C(t))),vp=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},yp=r(2,(e,t)=>qu(n=>I(Ql(n(e)),e=>dp(t,e)))),bp=us,xp=ms,Sp=ss,Cp=su,wp=vu,Tp=Su,Ep=mu,Dp=hu,Op=pu,kp=cu,Ap=lu,jp=`~effect/Layer`,Mp=`~effect/Layer/MemoMap`,Np=(e,t)=>{let n={observers:0,deferred:cp(),scope:wp(),finalizer:r=>P(()=>--n.observers>0?F:(e.map.delete(t),kp(n.scope,r)))};return n},Pp=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,gu(t,{},e.finalizer),!0),Fp={[jp]:{_ROut:i,_E:i,_RIn:i},pipe(){return e(this,arguments)}},Ip=e=>{let t=Object.create(Fp);return t.build=e,t},Lp=e=>Ip((t,n)=>{let r=Op(n);return Au(e(t,r),e=>e._tag===`Failure`?kp(r,e):F)}),Rp=e=>{let t=Lp((n,r)=>n.getOrElseMemoize(t,r,e));return t},zp=class{get[Mp](){return Mp}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(Pp(n,t),n.deferred.effect??up(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return P(()=>{let r;return Ou(P(()=>{let i=this.get(e,t);if(i)return i;let a=Np(this,e);return Pp(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&vp(r,e)})})}},Bp=()=>new zp,Vp=e=>new zp(e),Hp=class e extends Ki()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=ma(t,e);return n?Vp(n):Bp()}},Up=r(3,(e,t,n)=>xl(Qc(P(()=>e.build(t,n)),fa(Hp,t)),Hp,t)),Wp=r(2,(e,t)=>w(n=>Up(e,Hp.forkOrCreate(n.context),t))),Gp=function(){return arguments.length===1?e=>Kp(da(arguments[0],e)):Kp(da(arguments[0],arguments[1]))},Kp=e=>Ip(a(j(e))),qp=Kp(la()),Jp=function(){return arguments.length===1?e=>Yp(()=>da(arguments[0],e())):Yp(()=>da(arguments[0],arguments[1]()))},Yp=e=>Rp(a(N(e))),Xp=function(){return arguments.length===1?e=>Zp(arguments[0],e):Zp(arguments[0],arguments[1])},Zp=(e,t)=>Qp(Qc(t,t=>da(e,t))),Qp=e=>Rp((t,n)=>Tp(e,n)),$p=e=>Qp(jc(e,la())),em=Ki(`effect/Layer/unwrap`),tm=e=>sm(Xp(em)(e),O(em)),nm=(e,t,n)=>{let r=Op(n,`parallel`);return Xu(e,e=>e.build(t,Op(r,`sequential`)),{concurrency:e.length}).pipe(Qc(e=>Sa(...e)))},rm=(...e)=>Rp((t,n)=>nm(e,t,n)),im=(e,t,n)=>Rp((r,i)=>I(Array.isArray(t)?nm(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(bl(t),Qc(e=>n(e,t))))),am=r(2,(e,t)=>im(e,t,i)),om=r(2,(e,t)=>im(e,t,(e,t)=>xa(t,e))),sm=r(2,(e,t)=>Lp((n,r)=>I(e.build(n,r),e=>t(e).build(n,r)))),cm=r(2,(e,t)=>Lp((n,r)=>I(e.build(n,r),e=>Tp(jc(t(e),e),r)))),lm=e=>Ip((t,n)=>Rl(e.build(t,n))),um=r(2,(e,t)=>Ip((n,r)=>Tl(e.build(n,r),e=>t(e).build(n,r)))),dm=`~effect/DateTime`,fm=`~effect/DateTime/TimeZone`,pm={[dm]:dm,pipe(){return e(this,arguments)},[kt](){return this.toString()},toJSON(){return Wm(this).toJSON()}},mm={...pm,_tag:`Utc`,[xe](){return Oe(this.epochMilliseconds)},[Be](e){return wm(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Wm(this).toJSON()})`}},hm={...pm,_tag:`Zoned`,[xe](){return we(Oe(this.epochMilliseconds))(y(this.zone))},[Be](e){return wm(e)&&e._tag===`Zoned`&&this.epochMilliseconds===e.epochMilliseconds&&Ve(this.zone,e.zone)},toString(){return`DateTime.Zoned(${ih(this)})`}},gm={[fm]:fm,[kt](){return this.toString()}},_m={...gm,_tag:`Named`,[xe](){return ke(`Named:${this.id}`)},[Be](e){return Em(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},vm={...gm,_tag:`Offset`,[xe](){return ke(`Offset:${this.offset}`)},[Be](e){return Em(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${qm(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},ym={value:void 0,enumerable:!1,writable:!0},bm=new WeakMap,xm=(e,t)=>({get(){return Object.isExtensible(this)?void 0:bm.get(this)?.[e]},set(n){if(Object.isExtensible(this)){for(let e of t)Object.defineProperty(this,e,ym);this[e]=n}else{let t=bm.get(this);t===void 0&&(t={},bm.set(this,t)),t[e]=n}}}),Sm=[`partsUtc`,`adjustedEpochMilliseconds`,`partsAdjusted`];Object.defineProperty(mm,"partsUtc",xm(`partsUtc`,[`partsUtc`])),Object.defineProperties(hm,{partsUtc:xm(`partsUtc`,Sm),adjustedEpochMilliseconds:xm(`adjustedEpochMilliseconds`,Sm),partsAdjusted:xm(`partsAdjusted`,Sm)});var Cm=(e,t,n)=>{let r=Object.create(hm);return r.epochMilliseconds=e,r.zone=t,n!==void 0&&(r.partsUtc=n),r},wm=e=>v(e,dm),Tm=e=>wm(e[0]),Em=e=>v(e,fm),Dm=e=>e._tag===`Zoned`,Om=e=>{let t=Object.create(mm);return t.epochMilliseconds=e,t},km=e=>{let t=e.getTime();if(Number.isNaN(t))throw new Gf(`Invalid date`);return Om(t)},Am=e=>{if(wm(e))return e;if(e instanceof Date)return km(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return km(new Date(e.epochMilliseconds));let t=new Date(0);return Xm(t,e),km(t)}return typeof e==`string`&&!jm(e)?km(new Date(e+`Z`)):km(new Date(e))},jm=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e)||/z$|gmt$/i.test(e),Mm=-864e13+432e5,Nm=864e13-504e5,Pm=(e,t)=>{let n=t?.timeZone;if(n===void 0&&wm(e)&&Dm(e))return e;let r=Am(e);if(r.epochMilliseconds<Mm||r.epochMilliseconds>Nm)throw RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);n===void 0&&typeof e==`object`&&`timeZoneId`in e&&(n=e.timeZoneId);let i;if(n===void 0)i=zm(new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1e3);else if(Em(n))i=n;else if(typeof n==`number`)i=zm(n);else{let e=Hm(n);if(yr(e))throw new Gf(`Invalid time zone: ${n}`);i=e.value}return t?.adjustForTimeZone===!0?Qm(r.epochMilliseconds,i,t?.disambiguation??`compatible`):Cm(r.epochMilliseconds,i,r.partsUtc)},Fm=new Map,Im={day:`numeric`,month:`numeric`,year:`numeric`,era:`short`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},Lm=e=>{let t=e.resolvedOptions().timeZone,n=Fm.get(t);if(n!==void 0)return n;let r=Object.create(_m);return r.id=t,r.format=e,Fm.set(t,r),r},Rm=e=>{let t=Fm.get(e);if(t!==void 0)return t;try{let t=Lm(new Intl.DateTimeFormat(`en-US`,{...Im,timeZone:e}));return Fm.set(e,t),t}catch{throw new Gf(`Invalid time zone: ${e}`)}},zm=e=>{let t=Object.create(vm);return t.offset=e,t},Bm=Or(Rm),Vm=/^(?:GMT)?[+-]/,Hm=e=>{if(Vm.test(e)){let t=eh(e);return t===null?T():E(zm(t))}return Bm(e)},Um=r(2,(e,t)=>lo(Ym(t)-Ym(e))),Wm=e=>new Date(e.epochMilliseconds),Gm=e=>{if(e._tag===`Utc`)return new Date(e.epochMilliseconds);if(e.zone._tag===`Offset`)return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=!1,n=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>e.type===`era`?(t=e.value===`BC`,!1):e.type!==`literal`),r=Number(n[2].value),i=new Date(0);return i.setUTCFullYear(t?1-r:r,Number(n[0].value)-1,Number(n[1].value)),i.setUTCHours(Number(n[3].value),Number(n[4].value),Number(n[5].value),n[6]?.type===`fractionalSecond`?Number(n[6].value):(e.epochMilliseconds%1e3+1e3)%1e3),e.adjustedEpochMilliseconds=i.getTime(),i},Km=e=>Gm(e).getTime()-Ym(e),qm=e=>{let t=Math.abs(e),n=Math.floor(t/36e5),r=Math.round(t%36e5/6e4);return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},Jm=e=>qm(Km(e)),Ym=e=>e.epochMilliseconds,Xm=(e,t)=>{if((t.year!==void 0||t.month!==void 0||t.day!==void 0)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),t.month===void 0?e.getUTCMonth():t.month-1,t.day??e.getUTCDate()),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)},Zm=864e5,Qm=(e,t,n)=>{if(t._tag===`Offset`)return Cm(e-t.offset,t);let r=th(e-Zm,e,t),i=th(e+Zm,e,t);if(r===i)return Cm(e-r,t);let a=r<i,o=r-i;if(a){if(th(e-i,e,t)===i)return Cm(e-i,t);let a=Cm(e-r,t);if(e!==Gm(a).getTime())switch(n){case`reject`:{let n=new Date(e).toISOString();throw RangeError(`Gap time: ${n} does not exist in time zone ${t.id}`)}case`earlier`:return Cm(e-i,t);case`compatible`:case`later`:return a}return a}if(th(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||th(e-r+o,e+o,t)===r)return Cm(e-r,t);if(n===`reject`){let n=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${n} occurs twice in time zone ${t.id}`)}}return Cm(e-i,t)},$m=/([+-])(\d{2}):?(\d{2})$/,eh=e=>{let t=$m.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},th=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=eh(r);return i===null?Km(Cm(t,n)):i},nh=r(Tm,(e,t)=>new Intl.DateTimeFormat(t?.locale,t).format(e.epochMilliseconds)),rh=e=>{let t=Gm(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${Jm(e)}`},ih=e=>e.zone._tag===`Offset`?rh(e):`${rh(e)}[${e.zone.id}]`,ah=globalThis.Number,oh=_r(dr),sh=e=>{if(e===`NaN`)return E(NaN);if(e===`Infinity`)return E(1/0);if(e===`-Infinity`)return E(-1/0);if(e.trim()===``)return T();let t=ah(e);return ah.isNaN(t)?T():E(t)};globalThis.String;var ch=re,lh=ur,uh=e=>e.toUpperCase(),dh=e=>e.toLowerCase(),fh=(e,t)=>n=>n.replace(e,t),ph=(e,t)=>n=>n.slice(e,t),mh=e=>e.length===0,hh=e=>e.length>0,gh=e=>e.length,_h=r(2,(e,t)=>{let n=e.split(t);return ct(n)?n:[e]}),vh=(e,t)=>n=>n.startsWith(e,t),yh=(e,t)=>n=>n.endsWith(e,t),bh=e=>t=>Er(t.match(e)),xh=(e,t)=>n=>n.padStart(e,t),Sh=(e,t)=>n=>n.replaceAll(e,t),Ch=r(2,(e,t)=>kl(e,Dh,e=>t(e))),wh=e=>e.reasons.some(Th),Th=e=>e._tag===`Fail`&&Hf(e.error),Eh=e=>{let t,n=!1;for(let r of e.reasons)Th(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Rr(e):n?Rr(Tf(e.reasons.filter(e=>!Th(e)))):Lr(t)},Dh=e=>{let t=Eh(e);return D(t)?t:Lr(t.success.value)},Oh=e=>{let t=Eh(e);return D(t)?Qf(t.failure):Zf(t.success.value)},kh=r(2,(e,t)=>Wl(e,{onSuccess:t.onSuccess,onFailure:e=>{let n=Eh(e);return D(n)?t.onFailure(n.failure):t.onDone(n.success.value)}})),Ah=`~effect/Schedule`,jh=k(`effect/Schedule/CurrentMetadata`,{defaultValue:a({input:void 0,output:void 0,duration:ao,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),Mh={[Ah]:{_Out:i,_In:i,_Env:i},pipe(){return e(this,arguments)}},Nh=e=>v(e,Ah),Ph=e=>{let t=Object.create(Mh);return t.step=e,t},Fh=()=>{let e=0,t,n;return(r,i)=>{n===void 0&&(n=r);let a=r-n,o=t===void 0?0:r-t;return t=r,{input:i,attempt:++e,start:n,now:r,elapsed:a,elapsedSincePrevious:o}}},Ih=e=>Ph(Qc(e,e=>{let t=Fh();return(n,r)=>e(t(n,r))})),Lh=e=>Tl(e.step,e=>j(()=>M(e))),Rh=e=>Gd(t=>Qc(Lh(e),e=>{let n=Fh();return r=>P(()=>{let i=t.currentTimeMillisUnsafe();return I(e(i,r),([e,t])=>{let a=n(i,r);return a.output=e,a.duration=t,jc(Kd(t),a)})})})),zh=r(2,(e,t)=>Uh(e,e=>Qc(t(e),t=>xo(Ga(t),e.duration)))),Bh=e=>Ph(Qc(Ju(e.map(Lh)),e=>(t,n)=>I(Xu(e,e=>kh(e(t,n),{onSuccess:e=>j(e[1]),onDone:()=>yf,onFailure:M})),e=>{let t=Vh(e);return t===void 0?Uf(ao):j([t,t])}))),Vh=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t=t===void 0?r:yo(t,r))}return t},Hh=(e,t=2)=>{let n=fo(Ga(e));return Ih(j(e=>{let r=lo(n*t**(e.attempt-1));return j([r,r])}))},Uh=r(2,(e,t)=>Ph(Qc(Lh(e),e=>{let n=Fh();return(r,i)=>I(e(r,i),([e,a])=>Qc(t({...n(r,i),output:e,duration:a}),t=>[e,Ga(t)]))}))),Wh=e=>Ph(Qc(Lh(e),e=>(t,n)=>kh(e(t,n),{onSuccess:e=>j([n,e[1]]),onFailure:M,onDone:()=>Uf(n)}))),Gh=e=>{let t=Ga(e);return Ih(j(e=>j([e.attempt-1,t])))},Kh=r(2,(e,t)=>Ph(Qc(Lh(e),e=>{let n=Fh();return(r,i)=>I(e(r,i),e=>{let[a,o]=e,s=t({...n(r,i),output:a,duration:o});return I(Xt(s)?s:j(s),t=>t?j(e):Uf(a))})}))),qh=Gh(ao),Jh=(e,t,n)=>wu(r=>I(n?.local?Up(t,Bp(),r):Wp(t,r),t=>bl(e,t))),Yh=r(e=>Xt(e[0]),(e,t,n)=>sa(t)?bl(e,t):Jh(e,Array.isArray(t)?rm(...t):t,n)),Xh=r(3,(e,t,n)=>I(Rh(t),t=>{let r=jh.defaultValue(),i=n=>kh(t(n),{onSuccess(t){return r=t,I(xl(e,jh,r),i)},onFailure:M,onDone:j});return kl(I(xl(e,jh,r),i),Ts,e=>n(e,r.attempt===0?T():E(r)))})),Zh=r(3,(e,t,n)=>I(Rh(t),t=>{let r=jh.defaultValue(),i,a=kl(P(()=>xl(e,jh,r)),Ts,e=>(i=e,I(t(e),e=>(r=e,a))));return Ch(a,e=>Rt(()=>n(i,e)))})),Qh=r(2,(e,t)=>Xh(e,typeof t==`function`?t(i):Nh(t)?t:tg(t),dc)),$h=r(2,(e,t)=>Zh(e,typeof t==`function`?t(i):Nh(t)?t:tg(t),dc)),eg=Wh(qh),tg=e=>{let t=e.schedule?Wh(e.schedule):eg;return e.while&&(t=Kh(t,({input:t})=>{let n=e.while(t);return Xt(n)?n:j(n)})),e.until&&(t=Kh(t,({input:t})=>{let n=e.until(t);return Xt(n)?Qc(n,e=>!e):j(!n)})),e.times!==void 0&&(t=Kh(t,({attempt:t})=>j(t<=e.times))),t},ng=`~effect/MutableHashMap`,rg={[ng]:ng,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${x(Array.from(this))})`},toJSON(){return{_id:`MutableHashMap`,values:At(Array.from(this))}},[kt](){return this.toJSON()},pipe(){return e(this,arguments)}},ig=()=>{let e=Object.create(rg);return e.backing=new Map,e.buckets=new Map,e},ag=r(2,(e,t)=>{if(e.backing.has(t))return E(e.backing.get(t));if(og(t))return T();let n=y(t),r=e.buckets.get(n);return r===void 0?T():sg(e,r,t)}),og=e=>typeof e!=`object`&&typeof e!=`function`,sg=(e,t,n)=>{for(let r=0,i=t.length;r<i;r++)if(Ve(n,t[r])){let n=t[r];return E(e.backing.get(n))}return T()},cg=r(3,(e,t,n)=>{if(e.backing.has(t)||og(t))return e.backing.set(t,n),e;let r=y(t),i=e.buckets.get(r);if(i===void 0)return e.buckets.set(r,[t]),e.backing.set(t,n),e;let a=lg(i,t);return a===void 0&&(i.push(t),a=t),e.backing.set(a,n),e}),lg=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(Ve(t,e[n]))return e[n]},ug=r(2,(e,t)=>{if(og(t))return e.backing.delete(t),e;let n=y(t),r=e.buckets.get(n);if(r===void 0)return e;for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i===t||Ve(t,i)){e.backing.delete(i),r.splice(n,1);break}}return r.length===0&&e.buckets.delete(n),e}),dg=Xt,fg=Ju,pg=Xu,mg=Yu,hg=vc,gg=yc,R=j,_g=mc,z=P,B=N,V=F,vg=Sc,yg=Cc,bg=wc,H=dc,xg=M,Sg=hc,Cg=gc,wg=_c,Tg=pc,Eg=w,Dg=fc,U=I,Og=Zc,kg=Uc,Ag=Wc,jg=Hl,Mg=Ql,W=Qc,Ng=jc,Pg=Gc,Fg=Fl,Ig=Tl,Lg=Pl,Rg=Ol,zg=Il,Bg=Rl,Vg=Nl,Hg=jl,Ug=$h,Wg=Zh,Gg=Bl,Kg=Vl,qg=ru,Jg=iu,Yg=tu,Xg=eu,Zg=Kd,Qg=Jc,$g=Yc,e_=Cl,t_=Wl,n_=_l,r_=yl,i_=Yh,a_=bl,o_=ml,s_=hl,c_=xl,l_=xu,u_=Cu,d_=wu,f_=Tu,p_=Eu,m_=ju,h_=Nu,g_=Ou,__=Au,v_=Ru,y_=zu,b_=Ku,x_=Fu,S_=Bu,C_=qu,w_=wl,T_=Qh,E_=Ed,D_=Md,O_=Fd,k_=Rd,A_=Ld,j_=rd,M_=sd,N_=cd,P_=ad,F_=dd,I_=ld,L_=fd,R_=pd,z_=gd,B_=hd,V_=bd,H_=yd,U_=vd,W_=Ec,G_=pf(`Warn`),K_=pf(`Error`),q_=pf(`Debug`),J_=r(e=>dg(e[0]),(e,...t)=>gl(e,bp,e=>{let n=t.length===1?{...e,...t[0]}:{...e};return t.length===1||b(n,t[0],t[1]),n})),Y_=$c,X_=el,Z_=tl,Q_=Xc,$_=nl,ev=Oc,tv=ic,nv=oc,rv=sc,iv=cc,av=uc,ov=Xs,sv=ud,cv=`~effect/Chunk`;function lv(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}var uv=[],dv=(e=>rt((t,n)=>{if(t.length!==n.length)return!1;let r=_v(t),i=_v(n);for(let t=0;t<r.length;t++)if(!e(r[t],i[t]))return!1;return!0}))(Ve),fv={[cv]:{_A:e=>e},toString(){return`Chunk(${x(_v(this))})`},toJSON(){return{_id:`Chunk`,values:At(_v(this))}},[kt](){return this.toJSON()},[Be](e){return mv(e)&&dv(this,e)},[xe](){return Ne(_v(this))},[Symbol.iterator](){switch(this.backing._tag){case`IArray`:return this.backing.array[Symbol.iterator]();case`IEmpty`:return uv[Symbol.iterator]();default:return _v(this)[Symbol.iterator]()}},pipe(){return e(this,arguments)}},pv=e=>{let t=Object.create(fv);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=hv,t.right=hv;break;case`ISingleton`:t.length=1,t.depth=0,t.left=hv,t.right=hv;break;case`ISlice`:t.length=e.length,t.depth=0,t.left=hv,t.right=hv}return t},mv=e=>v(e,cv),hv=pv({_tag:`IEmpty`}),gv=(e,t,n)=>{switch(e.backing._tag){case`IArray`:lv(e.backing.array,0,t,n,e.length);break;case`IConcat`:gv(e.left,t,n),gv(e.right,t,n+e.left.length);break;case`ISingleton`:t[n]=e.backing.a;break;case`ISlice`:lv(_v(e.backing.chunk),e.backing.offset,t,n,e.length)}},_v=e=>{switch(e.backing._tag){case`IEmpty`:return uv;case`IArray`:return e.backing.array;default:{let t=Array(e.length);return gv(e,t,0),e.backing={_tag:`IArray`,array:t},e.left=hv,e.right=hv,e.depth=0,t}}},vv=wd,yv=Td,bv=`~effect/MutableRef`,xv={[bv]:bv,...Jt,toJSON(){return{_id:`MutableRef`,current:At(this.current)}}},Sv=e=>{let t=Object.create(xv);return t.current=e,t},Cv=e=>e.current,wv=r(2,(e,t)=>(e.current=t,e)),Tv=r(2,(e,t)=>wv(e,t(Cv(e)))),Ev=Symbol.for(`effect/MutableList/Empty`),Dv=()=>({head:void 0,tail:void 0,length:0}),Ov=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},kv=()=>({array:[],mutable:!0,offset:0,next:void 0}),Av=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=kv(),e.tail=e.tail.next):e.head=e.tail=kv(),e.tail.array.push(t),e.length++},jv=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||=e.head,e.length++},Mv=(e,t)=>Nv(e,Array.from(t),!0),Nv=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};return e.head?e.tail=e.tail.next=r:e.head=e.tail=r,e.length+=t.length,t.length},Pv=e=>{e.head=e.tail=void 0,e.length=0},Fv=(e,t)=>{if(t=lt(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return Pv(e),t}let n=Array(t),r=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(n[r++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,r===t)return e.head=i.offset===i.array.length&&i.next?i.next:i,e.length-=t,e.length===0?Pv(e):Ov(e),n;i=i.next}return Pv(e),n},Iv=e=>Fv(e,e.length),Lv=e=>{if(!e.head)return Ev;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:Pv(e):Ov(e),t},Rv=(e,t)=>{let n=[],r=e.head,i=0;for(;r;){for(let e=r.offset;e<r.array.length;e++)t(r.array[e],i++)&&n.push(r.array[e]);r=r.next}n.length===0?Pv(e):(e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length)},zv=(e,t)=>Rv(e,e=>e!==t),Bv=`~effect/PubSub`,Vv=`~effect/PubSub/Subscription`,Hv=e=>B(()=>sy(e.atomicPubSub(),new Map,wp(),vv(!1),Sv(!1),e.strategy(),Sv(T()))),Uv=e=>Hv({atomicPubSub:()=>Wv(e),strategy:()=>new cy}),Wv=e=>{let t=e?.replay;return new ry(t&&t>0?new dy(Math.ceil(t)):void 0)},Gv=e=>S_(Eg(t=>(wv(e.shutdownFlag,!0),kp(e.scope,tp(t.id)).pipe(kg(e.strategy.shutdown),e_(e.shutdownHook.open),Pg)))),Kv=r(2,(e,t)=>z(()=>e.shutdownFlag.current||br(e.ended.current)?R(!1):e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),R(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag,e.ended))),qv=r(2,(e,t)=>e.shutdownFlag.current||br(e.ended.current)?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),Jv=e=>S_(r_(t=>{let n=O(t,Cp),r=Op(e.scope),i=ny(e.pubsub,e.subscribers,e.strategy,e.ended);return Dp(r,Yv(i)).pipe(kg(Ep(n,e=>kp(r,e))),Ng(i))})),Yv=e=>S_(Eg(t=>(wv(e.shutdownFlag,!0),pg(Iv(e.pollers),e=>mp(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(Ag(()=>B(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),e_(e.shutdownHook.open),Pg)))),Xv=e=>z(()=>{if(e.shutdownFlag.current)return y_;if(e.replayWindow.remaining>0)return R(e.replayWindow.take());let t=e.pollers.length===0?e.subscription.poll():Ev;return t===Ev?Qv(e):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),R(t))}),Zv=e=>z(function t(n){if(e.shutdownFlag.current)return y_;let r=e.pollers.length===0?e.subscription.pollUpTo(1/0):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?R(e.replayWindow.takeAll().concat(r)):gi(r)?R(r):U(Qv(e),e=>t([e]))}),Qv=e=>vg(t=>{if(e.shutdownFlag.current)return t(y_);if(br(e.ended.current)){let n=e.pollers.length===0?e.subscription.poll():Ev;return n===Ev?t(R(e.ended.current.value)):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),t(R(n)))}let n=cp(),r=e.subscribers.get(e.subscription);return r||(r=new Set,e.subscribers.set(e.subscription,r)),r.add(e.pollers),Av(e.pollers,n),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),n.effect?t(n.effect):(n.resumes=[t],B(()=>zv(e.pollers,n)))}),$v=Symbol.for(`effect/PubSub/AbsentValue`),ey=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)},ty=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.delete(n),r.size===0&&e.delete(t)},ny=(e,t,n,r)=>new ay(e,t,e.subscribe(),Dv(),vv(!1),Sv(!1),n,e.replayWindow(),r),ry=class{publisherHead={value:$v,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=2**53-1;replayBuffer;constructor(e){this.replayBuffer=e}replayWindow(){return this.replayBuffer?new fy(this.replayBuffer):py}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(e){let t=this.replayBuffer?.offer(e),n=this.publisherTail.subscribers;if(n!==0){let r={value:e,replayIndex:t,subscribers:n,next:null};this.publisherTail.next=r,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(e){if(this.publisherTail.subscribers!==0)for(let t of e)this.publish(t);else this.replayBuffer&&this.replayBuffer.offerAll(e);return[]}slide(){if(this.publisherHead!==this.publisherTail){let e=this.publisherHead.next,t=e.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=$v,this.subscribersIndex+=1,this.replayBuffer?.slide(t,e.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new iy(this,this.publisherTail,this.publisherIndex,!1)}},iy=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(e,t,n,r){this.self=e,this.subscriberHead=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){if(this.unsubscribed)return!0;let e=!0,t=!0;for(;t;)this.subscriberHead===this.self.publisherTail?t=!1:this.subscriberHead.next.value===$v?(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1):(e=!1,t=!1);return e}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Ev;let e=!0,t=Ev;for(;e;)if(this.subscriberHead===this.self.publisherTail)e=!1;else{let n=this.subscriberHead.next.value;n!==$v&&(t=n,--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=$v,this.self.subscribersIndex+=1),e=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return t}pollUpTo(e){e=lt(e);let t=[],n=0;for(;n!==e;){let r=this.poll();r===Ev?n=e:(t.push(r),n+=1)}return t}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,--this.self.publisherTail.subscribers;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==$v&&(--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=$v,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},ay=class{[Vv]={_A:i};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;ended;constructor(e,t,n,r,i,a,o,s,c){this.pubsub=e,this.subscribers=t,this.subscription=n,this.pollers=r,this.shutdownHook=i,this.shutdownFlag=a,this.strategy=o,this.replayWindow=s,this.ended=c}pipe(){return e(this,arguments)}},oy=class{[Bv]={_A:i};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;ended;constructor(e,t,n,r,i,a,o){this.pubsub=e,this.subscribers=t,this.scope=n,this.shutdownHook=r,this.shutdownFlag=i,this.strategy=a,this.ended=o}pipe(){return e(this,arguments)}},sy=(e,t,n,r,i,a,o)=>new oy(e,t,n,r,i,a,o),cy=class{get shutdown(){return V}handleSurplus(e,t,n,r){return R(!1)}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return ly(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return uy(this,e,t)}},ly=(e,t,n,r,i)=>{let a=!0;for(;a&&!r.isEmpty();){let o=Lv(i);if(o===Ev)ty(n,r,i),i.length===0?a=!1:ey(n,r,i);else{let a=r.poll();a===Ev?jv(i,o):(vp(o,Zf(a)),e.onPubSubEmptySpaceUnsafe(t,n))}}},uy=(e,t,n)=>{for(let[r,i]of n)for(let a of i)e.completePollersUnsafe(t,n,r,a)},dy=class{capacity;head={value:$v,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(e){this.capacity=e}slide(e,t){this.slideValues[this.index%this.capacity]={value:e,index:t},this.index++}offer(e){let t=this.publisherIndex++;if(this.tail.value=e,this.tail.index=t,this.tail.next={value:$v,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity){let e=this.head;this.head=e.next,e.next=null,e.value=$v}else this.size+=1;return t}offerAll(e){for(let t of e)this.offer(t)}},fy=class{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(e){this.buffer=e,this.remaining=e.size,this.slideIndex=e.index,this.values=Array(this.remaining);let t=e.head;for(let e=0;e<this.remaining;e++)this.values[e]=t.value,this.newestIndex=t.index,t=t.next}close(){this.values.length=0,this.remaining=0}sync(){let e=this.buffer.index-this.slideIndex;if(e===0||this.remaining===0)return;let t=Math.min(e,this.buffer.capacity),n=this.buffer.index-t;for(let e=0;e<t;e++){let t=this.buffer.slideValues[(n+e)%this.buffer.capacity];t.index>this.newestIndex&&(this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=t.value,this.newestIndex=t.index)}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let e=this.values[this.index];return this.values[this.index]=$v,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),e}takeN(e){e=lt(e);let t=Math.min(e,this.remaining),n=Array(t);for(let e=0;e<t;e++)n[e]=this.take();return n}takeAll(){return this.takeN(this.remaining)}},py={remaining:0,take:()=>void 0,takeN:()=>[],takeAll:()=>[],close:()=>void 0},my=`~effect/Queue`,hy=`~effect/Queue/Enqueue`,gy=`~effect/Queue/Dequeue`,_y={_A:i,_E:i},vy={[my]:_y,[hy]:_y,[gy]:_y,...Jt,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:Py(this)}}},yy=e=>w(t=>{let n=Object.create(vy);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=Dv(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},j(n)}),by=e=>yy({capacity:e}),xy=r(2,(e,t)=>P(()=>Sy(e,t)?Iy:e.state._tag===`Open`&&e.strategy===`suspend`?Gy(e,t):Fy)),Sy=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(Lv(e.messages),Av(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(Av(e.messages,t),zy(e),!0):(Av(e.messages,t),By(e),!0):!1,Cy=r(2,(e,t)=>Sc(n=>{let r=wy(e,t);return r.length===0||e.strategy===`dropping`?n(C(r)):Ky(e,{_tag:`Array`,remaining:r,offset:0,resume:n})})),wy=(e,t)=>{if(e.state._tag!==`Open`)return ui(t);if(e.capacity===1/0||e.strategy===`sliding`)return Mv(e.messages,t),e.strategy===`sliding`&&Fv(e.messages,e.messages.length-e.capacity),By(e),[];let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return ui(t);let r=[],i=0;for(let a of t)i<n?Av(e.messages,a):r.push(a),i++;return By(e),r},Ty=r(2,(e,t)=>N(()=>Ey(e,t))),Ey=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=fl(En(t),Ly);return e.state.offers.size===0&&e.messages.length===0?(Xy(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},By(e),!0)},Dy=e=>Ty(e,pn(Ln())),Oy=e=>N(()=>ky(e)),ky=e=>{if(e.state._tag===`Done`)return!1;Pv(e.messages);let t=e.state.offers;Xy(e,e.state._tag===`Open`?Ry:e.state.exit);for(let e of t)qy(e);return!0},Ay=e=>jy(e,1,1/0),jy=r(3,(e,t,n)=>(t=lt(t),n=lt(n),Hy(()=>Vy(e,t,n)??Uc(Wy(e,()=>Uy(e,t)),jy(e,t,n))))),My=e=>Hy(()=>Ny(e)??Uc(Wy(e,()=>Uy(e,1)),My(e))),Ny=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=Lv(e.messages);return Yy(e),C(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=Jy(e.state.offers);return Yy(e),C(t)}},Py=e=>e.state._tag===`Done`?0:e.messages.length,Fy=C(!1),Iy=C(!0),Ly=Dn(Ln()),Ry=rl(),zy=e=>{if(e.state._tag!==`Done`&&e.state.takers.size!==0){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(cl),e.messages.length===0))break}},By=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,zy(e)},0))},Vy=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return C([]);if(!Uy(e,t))return;let r=e.messages.length>0?Fv(e.messages,n):[Jy(e.state.offers)];return Yy(e),C(r)},Hy=Sn({op:`QueueTake`,[Ut](e){let t=this[S]();return Zt(t)?t[Ut](e):t}}),Uy=(e,t)=>e.messages.length>=(e.state._tag===`Closing`?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!==`Done`&&e.state.offers.size>0,Wy=(e,t)=>Sc(n=>{if(e.state._tag===`Done`)return n(e.state.exit);if(t())return n(cl);let r={ready:t,resume:n};return e.state.takers.add(r),N(()=>{e.state._tag!==`Done`&&e.state.takers.delete(r)})}),Gy=(e,t)=>Sc(n=>Sy(e,t)?n(Iy):Ky(e,{_tag:`Single`,message:t,resume:n})),Ky=(e,t)=>{if(e.state._tag!==`Open`)return qy(t);let n=e.state.offers;return n.add(t),N(()=>{e.state._tag!==`Done`&&(n.delete(t),e.state._tag===`Closing`&&n.size===0&&e.messages.length===0&&Xy(e,e.state.exit))})},qy=e=>e._tag===`Single`?e.resume(Fy):e.resume(C(e.remaining.slice(e.offset))),Jy=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume(Iy),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(C([]))),n},Yy=e=>{if(e.state._tag===`Done`)return wh(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0&&(Xy(e,e.state.exit),wh(e.state.exit.cause));for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;if(t._tag===`Single`)Av(e.messages,t.message),e.state.offers.delete(t),t.resume(Iy);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;Av(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(C([]))}let r=e.state;if(r._tag===`Done`)return wh(r.exit.cause)}return!1},Xy=(e,t)=>{if(e.state._tag===`Done`)return;let n=e.state;e.state={_tag:`Done`,exit:t};for(let e of n.takers)e.resume(t);n.takers.clear();for(let e of n.awaiters)e(t);n.awaiters.clear()},Zy=e=>new eb(e),Qy=e=>{for(let t of e.waiters)if(t.permits<=e.free)return t},$y=(e,t,n,r=i)=>w(i=>{if(e.free>=t&&Qy(e)===void 0)return e.taken+=t,n();let a={permits:t,resume:void 0},o=()=>{e.waiters.delete(a)&&e.releaseUnsafe(i,0)};e.waiters.add(a),ku(i,o);let s=I(r(Sc(t=>{Qy(e)===a?t(F):a.resume=t})),()=>Qy(e)===a?(e.taken+=t,o(),n()):s);return s}),eb=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){return $y(this,e,()=>j(e))}takeScoped(e){return qu(t=>I(xu,n=>$y(this,e,()=>hu(n,this.release(e)),t)))}takeIfAvailable(e){return P(()=>this.free<e?j(!1):(this.taken+=e,j(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.free;for(let t of Array.from(this.waiters)){if(!this.waiters.has(t)||t.permits>e)continue;e-=t.permits;let n=t.resume;t.resume=void 0,n?.(F)}},0),this.free}resize(e){return w(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),F))}release(e){return w(t=>j(this.releaseUnsafe(t,e)))}get releaseAll(){return w(e=>j(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>qu(n=>$y(this,e,()=>Ou(n(t),()=>{this.releaseUnsafe(Xs(),e)},!0),n))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>qu(n=>this.free<e?mc:(this.taken+=e,Ou(n(Hc(t)),()=>{this.releaseUnsafe(Xs(),e)},!0)))}},tb=e=>Xf(e)?rp(e)?Uf(e.value):e:R(e),nb=`~effect/Channel`,rb=e=>v(e,nb),ib={[nb]:{_Env:i,_InErr:i,_InElem:i,_OutErr:i,_OutElem:i},pipe(){return e(this,arguments)}},ab=e=>{let t=Object.create(ib);return t.transform=(t,n)=>Ig(e(t,n),e=>R(xg(e))),t},ob=(e,t)=>ab((n,r)=>U(lb(e)(n,r),e=>t(e,r))),sb=e=>ab((t,n)=>e),cb=e=>ab(W_(function*(t,n){let r=Op(n),i=e=>kp(r,Oh(e));return h_(yield*h_(e(t,n,r),i),i)})),lb=e=>e.transform,ub=(e,t,n)=>yy({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(Ag(t=>Dp(e,Oy(t))),Ag(n=>Tp(t(n),e).pipe(Ig(e=>Ty(n,e)),M_(e,{startImmediately:!0})))),db=(e,t)=>ab((n,r)=>W(ub(r,e,t),Ay)),fb=e=>ab((t,n)=>z(()=>lb(e())(t,n))),pb=e=>sb(B(()=>{let t=e();return z(()=>{let e=t.next();return e.done?Uf(e.value):R(e.value)})})),mb=e=>bb(R(e)),hb=sb(R(Uf())),gb=sb(R(yg)),_b=e=>sb(R(H(e))),vb=e=>sb(xg(e)),yb=e=>vb(Df(e)),bb=e=>sb(B(()=>{let t=!1;return z(()=>t?Uf():(t=!0,e))})),xb=e=>sb(R(U(e,tb))),Sb=e=>sb(R(Ay(e))),Cb=e=>sb(R(x_(Zv(e),()=>Uf()))),wb=e=>Kb(W(Jv(e),Cb)),Tb=e=>ab((t,n)=>Eb({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Eb=e=>{let t=e.readable.getReader(),n=e.exit??Sv(void 0),r=z(()=>n.current?n.current:t_(gg({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??xg(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?Uf():R(Mi(t))}));return Ng(Dp(e.scope,e.releaseLockOnEnd?B(()=>t.releaseLock()):hg(()=>t.cancel().catch(e=>t.closed.then(()=>Promise.reject(e),l))).pipe(m_(B(()=>t.releaseLock())))),r)},Db=r(2,(e,t)=>ob(e,e=>B(()=>{let n=0;return W(e,e=>t(e,n++))}))),Ob=e=>e===void 0||e!==`unbounded`&&e<=1,kb=r(e=>rb(e[0]),(e,t,n)=>Ob(n?.concurrency)?Ab(e,t):jb(e,t,n)),Ab=(e,t)=>ab((n,r)=>{let i=0;return W(lb(e)(n,r),U(e=>t(e,i++)))}),jb=(e,t,n)=>cb(W_(function*(r,i,o){let s=0,c=yield*lb(e)(r,i),l=n.concurrency===`unbounded`?2**53-1:Math.min(n.concurrency,2**53-1),u=yield*by(0);yield*Dp(o,Oy(u));let d=I_(yield*n_()),f=sv(o);if(n.unordered){let e=Zy(l),n=a(e.release(1)),r=t_({onFailure:e=>U(Ty(u,e),n),onSuccess:e=>U(xy(u,e),n)});yield*e.take(1).pipe(U(()=>c),U(e=>{let n=s++;return f(d(r(z(()=>t(e,n))))),V}),w_({disableYield:!0}),Ig(t=>e.withPermits(l-1)(Ty(u,t))),M_(o))}else{let e=yield*by(l-2);yield*Dp(o,Oy(e)),yield*My(e).pipe(Og,U(e=>xy(u,e)),w_({disableYield:!0}),Ig(e=>Ty(u,e)),M_(o));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,Ey(u,e.cause))};yield*c.pipe(U(i=>{if(n)return xg(n);let a=s++,o=d(z(()=>t(i,a)));return f(o),o.addObserver(r),xy(e,nv(o))}),w_({disableYield:!0}),Ig(t=>xy(e,Qf(t)).pipe(kg(Ty(e,t)))),M_(o))}return My(u)})),Mb=r(e=>rb(e[0]),(e,t,n)=>Ob(n?.concurrency)?Nb(e,t):Pb(e,t,n)),Nb=(e,t)=>ab((n,r)=>W(lb(e)(n,r),e=>{let i,a,o=U(e,e=>(a??=Op(r),Q_(lb(t(e))(n,a),e=>(i=s(e),i)))),s=Ch(e=>{if(i=void 0,a.state._tag===`Empty`)return o;let t=kp(a,np);return a=void 0,U(t,()=>o)});return z(()=>i??o)})),Pb=(e,t,n)=>e.pipe(Db(t),Wb(n)),Fb=e=>Mb(e,i),Ib=e=>ob(e,e=>{let t,n=0;return R(z(function r(){if(t===void 0)return U(e,e=>{switch(e.length){case 0:return r();case 1:return R(e[0]);default:return t=e,R(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),R(i)}))}),Lb=(e,t)=>ab((n,r)=>B(()=>{let i,a=()=>{let o=Op(r);return U(lb(e)(n,o),e=>(i=Ig(e,e=>{let n=Oh(e);return kp(o,n).pipe(U(()=>t(n,r)),U(a))}),i))};return z(()=>i??a())})),Rb=r(2,(e,t)=>ob(e,e=>R(U(e,function n(r){let i=[];for(let e=0;e<r.length;e++)t(r[e])&&i.push(r[e]);return _i(i)?R(i):U(e,n)})))),zb=r(2,(e,t)=>ab((n,r)=>{let i=Op(r);return W(lb(e)(n,i),e=>{let a=e.pipe(Ig(e=>{if(wh(e))return xg(e);let o=i;return i=Op(r),kp(o,Qf(e)).pipe(kg(lb(t(e))(n,i)),U(e=>(a=e,e)))}));return z(()=>a)})})),Bb=r(3,(e,t,n)=>zb(e,e=>{let r=t(e);return D(r)?vb(r.failure):n(r.success,e)})),Vb=r(2,(e,t)=>Bb(e,Ts,e=>t(e))),Hb=r(e=>rb(e[0]),(e,t,n,r)=>Vb(e,e=>t(e)?n(e):r?r(e):_b(e))),Ub=r(2,(e,t)=>fb(()=>{let n,r=jh.defaultValue(),a=Xb(nx(e,jh,B(()=>r)),()=>(n=void 0,V)),o=typeof t==`function`?t(i):t;return Lb(a,(e,t)=>{if(rp(e))return Uf(e.value);let i=Ts(e.cause);return D(i)?xg(i.failure):bg(function*(){n||=yield*Rh(o),r=yield*n(i.success)}).pipe(Ch(()=>H(i.success)),Tp(t))})})),Wb=r(2,(e,{bufferSize:t=16,concurrency:n,switch:r=!1})=>cb(W_(function*(i,a,o){let s=n===`unbounded`?2**53-1:Math.max(1,n),c=r?void 0:Zy(s),l=yield*yv(!0),u=new Map,d=yield*by(t);yield*Dp(o,Oy(d));let f=yield*lb(e)(i,a);return yield*bg(function*(){for(;;){let e;c&&(u.size<s?yield*c.take(1):(e=yield*j_(f),yield*$g(c.take(1),kg(nv(e),yg))));let t=e===void 0?yield*f:yield*nv(e),n=Op(o),r=yield*lb(t)(i,n);for(;u.size>=s;){let[e,t]=qr(u);u.delete(e),u.size===0&&(yield*l.open),yield*iv(e),yield*Kg(kp(t,tp()))}let a=yield*r.pipe(Ag(()=>Tg),U(e=>xy(d,e)),w_({disableYield:!0}),h_(W_(function*(e){let t=Oh(e),r=yield*Mg(kp(n,t));if(!u.has(a))return;let i=ap([t,r]);ip(i)&&(yield*Ty(d,i.cause)),u.delete(a),c&&(yield*c.release(1)),u.size===0&&(yield*l.open)})),j_);l.closeUnsafe(),u.set(a,n)}}).pipe(Ig(e=>Vr(Eh(e))?l.whenOpen(Ty(d,e)):Ty(d,e)),M_(o)),My(d)}))),Gb=r(e=>rb(e[0])&&rb(e[1]),(e,t,n)=>cb(W_(function*(r,i,a){let o=n?.haltStrategy??`both`,s=yield*by(0);yield*Dp(a,Oy(s));let c=0;function l(e,t){if(c++,!wh(t))return Ty(s,t);switch(o){case`both`:return c===2?Ty(s,t):V;case`left`:case`right`:return e===o?Ty(s,t):V;case`either`:return Ty(s,t)}}let u=(e,t,n)=>lb(t)(r,n).pipe(U(e=>e.pipe(U(e=>xy(s,e)),w_)),h_(t=>g_(Oh(t),e=>kp(n,e)).pipe(t_({onFailure:t=>l(e,t),onSuccess:()=>l(e,t)}))),M_(a));return yield*u(`left`,e,Op(a)),yield*u(`right`,t,Op(a)),My(s)}))),Kb=e=>ab((t,n)=>{let r;return R(z(()=>r||e.pipe(Tp(n),U(e=>lb(e)(t,n)),U(e=>r=e))))}),qb=r(2,(e,t)=>Gb(e,sb(R(U(t,Uf))),{haltStrategy:`either`})),Jb=r(2,(e,t)=>cb((n,r,i)=>Ep(i,t).pipe(kg(lb(e)(n,r))))),Yb=r(2,(e,t)=>Kb(Ng(t,e))),Xb=r(2,(e,t)=>ob(e,e=>B(()=>{let n=!0,r=Ag(e,e=>(n=!1,t(e)));return z(()=>n?r:e)}))),Zb=r(2,(e,t)=>ob(e,e=>R(Ch(e,e=>U(t,()=>Uf(e)))))),Qb=r(2,(e,t)=>Jb(e,e=>t)),$b=(e,t,n)=>z(()=>{let r=wp();return Ch(U(lb(e)(Uf(),r),t),n||R).pipe(__(e=>kp(r,e)))}),ex=r(2,(e,t)=>ab((n,r)=>W(a_(lb(e)(n,r),t),a_(t)))),tx=r(3,(e,t,n)=>ab((r,i)=>W(c_(lb(e)(r,i),t,n),c_(t,n)))),nx=r(3,(e,t,n)=>ab((r,i)=>U(n,n=>lb(tx(e,t,n))(r,i)))),rx=r(2,(e,t)=>$b(e,e=>w_(U(e,t),{disableYield:!0}))),ix=e=>W(ax(e,()=>({bytes:0,arrays:[]}),(e,t)=>{for(let n=0;n<t.length;n++)e.bytes+=t[n].length,e.arrays.push(t[n]);return e}),({arrays:e,bytes:t})=>{let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}),ax=r(3,(e,t,n)=>z(()=>{let r=t();return $b(e,e=>mg({while:o,body:()=>e,step:e=>{r=n(r,e)}}),()=>R(r))})),ox=W_(function*(e){let t=Zy(1),n=yield*n_(),r=O(n,Cp);return(yield*lb(e)(Uf(),r)).pipe(a_(n),t.withPermits(1))},Ig(e=>R(xg(e)))),sx=(e,t)=>lb(e)(Uf(),t),cx=`~effect/Stream`,lx={_R:i,_E:i,_A:i},ux=function(e){this.channel=e};ux.prototype={[cx]:lx,pipe(){return e(this,arguments)}};var dx=e=>new ux(e),fx=`~effect/Stream`,px=e=>v(e,fx),G=dx,mx=e=>hx(B(()=>{let t=!0,n=R(Mi(void 0)),r=Xg(n,e);return z(()=>t?(t=!1,n):r)})),hx=e=>G(sb(e)),gx=e=>e.channel,_x=(e,t)=>G(db(e,t)),vx=G(hb),yx=e=>G(mb(Mi(e))),bx=(...e)=>Tx(e),xx=e=>{let t=G(fb(()=>e().channel));return Sx.set(t,e),t},Sx=new WeakMap,Cx=e=>G(_b(e)),wx=e=>G(yb(e)),Tx=e=>_i(e)?G(mb(e)):vx,Ex=e=>G(Sb(e)),Dx=e=>G(wb(e)),Ox=e=>G(Tb(e)),kx=G(gb),Ax=e=>G(Kb(W(e,gx))),jx=r(2,(e,t)=>xx(()=>{let n=0;return G(Db(e.channel,Ni(e=>t(e,n++))))})),Mx=r(e=>px(e[0]),(e,t,n)=>e.channel.pipe(Ib,kb(t,n),Db(Mi),G)),Nx=r(e=>px(e[0]),(e,t,n)=>Mx(e,e=>Ng(t(e),e),n)),Px=r(2,(e,t)=>{let n=G(Fb(pb(()=>Ix(e,t))));return Fx.set(n,[e,t]),n}),Fx=new WeakMap;function*Ix(e,t){let n=[t,e];for(;n.length>0;){let e=n.pop(),t=Fx.get(e);if(t!==void 0){n.push(t[1],t[0]);continue}let r=Sx.get(e);if(r===void 0)yield e.channel;else{try{n.push(r())}catch(e){n.push(wx(e))}yield hb}}}var Lx=r(2,(e,t)=>G(Rb(gx(e),t))),Rx=r(e=>px(e[0]),(e,t,n,r)=>G(Hb(gx(e),t,e=>n(e).channel,r&&(e=>r(e).channel)))),zx=r(e=>px(e[0]),(e,t,n,r)=>Rx(e,Array.isArray(t)?e=>v(e,`_tag`)&&t.includes(e._tag):_e(t),n,r)),Bx=r(2,(e,t)=>G(Ub(e.channel,t))),Vx=r(2,(e,t)=>G(qb(e.channel,t))),Hx=r(2,(e,t)=>G(Yb(e.channel,t))),Ux=r(2,(e,t)=>G(Zb(e.channel,t))),Wx=r(2,(e,t)=>G(Qb(e.channel,t))),Gx=r(2,(e,t)=>G(ex(e.channel,t))),Kx=r(2,(e,t)=>rx(e.channel,e=>{let n=0;return mg({while:()=>n<e.length,body:()=>t(e[n++]),step:l})})),qx=r(2,(e,t)=>rx(e.channel,t)),Jx=e=>ox(e.channel),Yx=e=>W(ix(e.channel),e=>e.buffer),Xx=r(e=>px(e[0]),(e,t,n)=>{let r,i,a=!1,o=vv(!1),s=n?.signal,c=()=>i.interruptUnsafe();return new ReadableStream({start(n){i=F_(a_(rx(ob(e.channel,e=>R(o.whenOpen(e))),e=>B(()=>{o.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0})),t)),i.addObserver(e=>{s?.removeEventListener(`abort`,c),a||(e._tag===`Failure`&&s?.aborted!==!0?n.error(Pf(e.cause)):n.close())}),s!==void 0&&i.pollUnsafe()===void 0&&(s.aborted?c():s.addEventListener(`abort`,c,{once:!0}))},pull(){return new Promise(e=>{r=e,o.openUnsafe()})},cancel(){if(i)return a=!0,z_(Pg(iv(i)))}},n?.strategy)}),Zx=r(e=>px(e[0]),(e,t)=>Xx(e,la(),t)),Qx=r(e=>px(e[0]),(e,t)=>W(n_(),n=>Xx(e,n,t)));function $x(e){return{_tag:`Value`,value:e}}function eS(e,t){return{_tag:`Record`,keys:e,value:t}}function tS(e,t){return{_tag:`Array`,length:e,value:t}}var nS=k(`effect/ConfigProvider`,{defaultValue:()=>uS()}),rS={...Jt,toJSON(){return{_id:`ConfigProvider`}}},iS=e=>e;function aS(e,t){let n=Object.create(rS);return n.load=e,n.mapInput=t,n}function oS(e,t){return aS(n=>e(t(n)),n=>oS(e,e=>n(t(e))))}function sS(e){return oS(e,iS)}function cS(e,t){return e===``&&!t?void 0:e}function lS(e,t){let n=t?.preserveEmptyStrings===!0,r=dS(e);return sS(t=>R(fS(r,e,t,n)))}function uS(e){return lS(e?.env??{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`},{preserveEmptyStrings:e?.preserveEmptyStrings})}function dS(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e){let e=i.children??=Object.create(null);i=e[t]??={}}}return t}function fS(e,t,n,r){let i=n.map(String).join(`_`),a=cS(Object.hasOwn(t,i)?t[i]:void 0,r),o=pS(e,n),s=o?.children?Object.keys(o.children):[];return s.length===0?a===void 0?void 0:$x(a):s.every(vi)?tS(Math.max(...s.map(e=>parseInt(e,10)))+1,a):eS(new Set(s),a)}function pS(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var mS=`~effect/BigDecimal`,hS={[mS]:mS,[xe](){let e=CS(this);return we(ke(String(e.value)),Oe(e.scale))},[Be](e){return gS(e)&&kS(this,e)===0},toString(){return`BigDecimal(${jS(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[kt](){return this.toJSON()},pipe(){return e(this,arguments)}},gS=e=>v(e,mS),_S=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(hS);return n.value=e,n.scale=t,n},vS=(e,t)=>{let n=_S(e,t);return n.normalized=n,n},yS=BigInt(0),bS=BigInt(1),xS=BigInt(10),SS=vS(yS,0),CS=e=>{if(e.normalized===void 0){if(e.value===yS)e.normalized=SS;else{let t=`${e.value}`,n=wS(t);e.normalized=vS(BigInt(t.slice(0,t.length-n)),e.scale-n)}}return e.normalized},wS=e=>{let t=e.length;for(;e[t-1]===`0`;)t--;return e.length-t},TS=100,ES=[bS],DS=(e,t)=>e===t?0:e<t?-1:1,OS=(e,t)=>{let n=`${e.value<yS?-e.value:e.value}`,r=`${t.value<yS?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==yS)return i<yS?-1:1;let a=Math.max(n.length,r.length);return ur(n.padEnd(a,`0`),r.padEnd(a,`0`))},kS=(e,t)=>{if(e.scale===t.scale)return DS(e.value,t.value);let n=AS(e),r=AS(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>TS)return n===-1?OS(t,e):OS(e,t);let o=ES[a]??=xS**BigInt(a);return i>0?DS(e.value,t.value*o):DS(e.value*o,t.value)},AS=e=>e.value===yS?0:e.value<yS?-1:1,jS=e=>{let t=CS(e);if(Math.abs(t.scale)>=16)return MS(t);let n=t.value<yS,r=`${n?-t.value:t.value}`,i=t.scale>0?r.padStart(t.scale+1,`0`):r.padEnd(r.length-t.scale,`0`),a=i.length-t.scale,o=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return n?`-${o}`:o},MS=e=>{if(NS(e))return`0e+0`;let t=CS(e),n=`${t.value}`,r=t.value<yS?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},NS=e=>e.value===yS,PS=e=>IS(typeof e==`string`?zS.encode(e):e),FS=e=>{let t=VS(e),n=t.length;if(n%4!=0)return Rr(new Ho({kind:`Decode`,module:`Base64`,input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf(`=`);if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!==`=`))return Rr(new Ho({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));try{let e=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(n/4*3-e);for(let e=0,i=0;e<n;e+=4,i+=3){let n=KS(t.charCodeAt(e))<<18|KS(t.charCodeAt(e+1))<<12|KS(t.charCodeAt(e+2))<<6|KS(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return Lr(r)}catch(e){return Rr(new Ho({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},IS=e=>{let t=e.length,n=Uint8Array.prototype.toBase64;return t>=32&&typeof n==`function`?n.call(e):t<128?LS(e):RS(e)},LS=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=HS[e[r-2]>>2],n+=HS[(e[r-2]&3)<<4|e[r-1]>>4],n+=HS[(e[r-1]&15)<<2|e[r]>>6],n+=HS[e[r]&63];return r===t+1&&(n+=HS[e[r-2]>>2],n+=HS[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=HS[e[r-2]>>2],n+=HS[(e[r-2]&3)<<4|e[r-1]>>4],n+=HS[(e[r-1]&15)<<2],n+=`=`),n},RS=e=>{let t=e.length,n=new Uint8Array(Math.ceil(t/3)*4),r,i=0;for(r=2;r<t;r+=3,i+=4)n[i]=US[e[r-2]>>2],n[i+1]=US[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=US[(e[r-1]&15)<<2|e[r]>>6],n[i+3]=US[e[r]&63];return r===t+1&&(n[i]=US[e[r-2]>>2],n[i+1]=US[(e[r-2]&3)<<4],n[i+2]=WS,n[i+3]=WS),r===t&&(n[i]=US[e[r-2]>>2],n[i+1]=US[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=US[(e[r-1]&15)<<2],n[i+3]=WS),BS.decode(n)},zS=new TextEncoder,BS=new TextDecoder,VS=e=>e.replace(/[\n\r]/g,``),HS=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,US=zS.encode(HS),WS=61,GS=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)GS[HS.charCodeAt(e)]=e;GS[61]=0;var KS=e=>{if(e>=GS.length||GS[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return GS[e]},qS=wm,JS=Am,YS=Pm,XS=Um,ZS=Ym,QS=nh,$S=`~effect/HashMap`,eC=e=>v(e,$S),tC=`~effect/HashSet`,nC=e=>v(e,tC),rC=`~effect/http/Cookies`,iC=`~effect/http/Cookies/Cookie`,aC={[rC]:rC,...Mt,toJSON(){return{_id:`effect/Cookies`,cookies:ni(this.cookies,e=>e.toJSON())}},pipe(){return e(this,arguments)}},oC=e=>{let t=Object.create(aC);return t.cookies=e,t},sC=e=>{let t={};for(let n of e)b(t,n.name,n);return oC(t)},cC=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=lC(e.trim());t&&n.push(t)}return sC(n)};function lC(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n).replace(dC,``);if(!uC.test(r))return;let i=t[0].slice(n+1).replace(dC,``),a=mC(i);if(t.length===1)return Object.assign(Object.create(pC),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:if(a===void 0||!fC.test(a))break;o.maxAge=uo(parseInt(a,10));break;case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`}}}return Object.assign(Object.create(pC),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var uC=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,dC=/^[\t ]+|[\t ]+$/g,fC=/^-?[0-9]+$/,pC={[iC]:iC,...Mt,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},mC=e=>{try{return decodeURIComponent(e)}catch{return e}},hC=new WeakMap,gC=e=>{if(hC.has(e))return hC.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},_C=`~effect/Redacted`,vC=e=>v(e,_C),yC=(e,t)=>{let n=Object.create(bC);return t?.label&&(n.label=t.label),hC.set(n,e),n},bC={[_C]:{_A:e=>e},label:void 0,...Jt,toJSON(){return this.toString()},toString(){return`<redacted${re(this.label)?`:`+this.label:``}>`},[xe](){return y(hC.get(this))},[Be](e){return vC(e)&&Ve(hC.get(this),hC.get(e))}},xC=gC,SC=Symbol.for(`~effect/http/Headers`),CC=Object.defineProperties(Object.create(null),{[SC]:{value:SC},[ft]:{value(e){return NC(this,O(e,FC))}},toJSON:{value(){return mt(this)}},[Be]:{value(e){return TC(this,e)}},[xe]:{value(){return je(this)}},toString:{value:Mt.toString},[kt]:{value:Mt[kt]}}),wC=e=>Object.assign(Object.create(CC),e),TC=oi(at()),EC=Object.create(CC),DC=e=>{if(e===void 0)return EC;if(Symbol.iterator in e){let t=Object.create(CC);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(CC);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},OC=e=>Object.setPrototypeOf(e,CC),kC=r(3,(e,t,n)=>{let r=wC(e);return r[t.toLowerCase()]=n,r}),AC=r(2,(e,t)=>wC({...e,...DC(t)})),jC=r(2,(e,t)=>{let n=wC(e);return Object.assign(n,t),n}),MC=r(2,(e,t)=>{let n=wC(e);return delete n[t.toLowerCase()],n}),NC=r(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=yC(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=yC(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),PC=(e,t)=>{let n=e.toLowerCase();for(let r=0;r<t.length;r++){let i=t[r];if(typeof i==`string`){if(i.toLowerCase()===n)return!0}else if(e.search(i)!==-1)return!0}return!1},FC=k(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),IC=`~effect/http/Headers/HeaderParseError`,LC=class extends zo{},RC=class e extends Bo(`HeaderParseError`){static fromReason(t,n){return new e({reason:new LC({_tag:t,input:n})})}[IC]=IC;get message(){return`${this.reason._tag}: ${JSON.stringify(this.reason.input)}`}},zC=[`jan`,`feb`,`mar`,`apr`,`may`,`jun`,`jul`,`aug`,`sep`,`oct`,`nov`,`dec`],BC=[/^(?:mon|tue|wed|thu|fri|sat|sun), (?<day>\d{2}) (?<month>[a-z]{3}) (?<year>\d{4}) (?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}) gmt$/i,/^(?:monday|tuesday|wednesday|thursday|friday|saturday|sunday), (?<day>\d{2})-(?<month>[a-z]{3})-(?<year>\d{2}) (?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}) gmt$/i,/^(?:mon|tue|wed|thu|fri|sat|sun) (?<month>[a-z]{3}) (?<day> \d|\d{2}) (?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}) (?<year>\d{4})$/i],VC=e=>{for(let t of BC){let n=t.exec(e)?.groups;if(n===void 0)continue;let r=zC.indexOf(n.month.toLowerCase()),i=Number(n.hour),a=Number(n.minute),o=Number(n.second);if(r===-1||i>23||a>59||o>60)return;let s=Number(n.year);n.year.length===2&&(s+=s<70?2e3:1900);let c=Number(n.day),l=new Date(0);return l.setUTCFullYear(s,r,c),l.getUTCFullYear()!==s||l.getUTCMonth()!==r||l.getUTCDate()!==c?void 0:l.getTime()+((i*60+a)*60+o)*1e3}},HC=e=>({_tag:`DateTime`,dateTime:e}),UC=/^\d+$/,WC=BigInt(1e9),GC=e=>{let t=e.trim();if(UC.test(t)){let e=Number(t);return Lr({_tag:`Duration`,duration:Number.isSafeInteger(e*1e3)?uo(e):co(BigInt(t)*WC)})}let n=VC(t);return n===void 0?Rr(RC.fromReason(`InvalidRetryAfter`,e)):Lr(HC(JS(n)))},KC=(e,t)=>e._tag===`Duration`?e.duration:lo(Math.max(0,ZS(e.dateTime)-t)),qC=e=>typeof e==`string`?e:xC(e),JC=new TextDecoder(`utf-8`,{ignoreBOM:!0}),YC=e=>new URLSearchParams(JC.decode(e).replace(/^\?/,`%3F`)),XC=`~effect/http/UrlParams`,ZC=e=>v(e,XC),QC={...Jt,[XC]:XC,[Symbol.iterator](){return this.params[Symbol.iterator]()},[ft](e){return{_id:`UrlParams`,params:Object.fromEntries(sw(this,O(e,_w)))}},toJSON(){return mt(this)},[Be](e){return rw(this,e)},[xe](){return Ne(this.params.flat())}},$C=e=>{let t=Object.create(QC);return t.params=e,t},ew=e=>{if(ZC(e))return e;let t=tw(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return $C(n)},tw=e=>{let t=typeof e[Symbol.iterator]==`function`?ui(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,nw(r[t])]);else if(typeof r==`object`&&r&&!vC(r)){let t=tw(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,nw(r)]);return n},nw=e=>vC(e)?e:String(e),rw=rt((e,t)=>iw(e.params,t.params)),iw=zi(Kr([at(),nt()])),aw=$C([]),ow=r(2,(e,t)=>{let n=ew(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return $C(n)}),sw=r(2,(e,t)=>{let n=Array.isArray(t)?t:[t];return e.params.map(([e,t])=>[e,typeof t==`string`&&cw(e,n)?yC(t):t])}),cw=PC,lw=(e,t=gw())=>{e.includes(`@`)&&(e=pw(e));let n=e.indexOf(`?`);if(n===-1||t.length===0)return e;let r=e.indexOf(`#`);if(r!==-1&&r<n)return e;let i=r===-1?e.length:r;return e.slice(0,n+1)+mw(e.slice(n+1,i),t)+e.slice(i)},uw=/^(?:(https?|ftp|wss?):[/\\]*|[a-z][a-z\d+.-]*:\/\/|[/\\]{2,})/i,dw=/[/\\?#]/,fw=/[/?#]/,pw=e=>{let t=``,n=[];for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i===9||i===10||i===13||t===``&&i<=32||(t+=e[r],n.push(r))}let r=uw.exec(t);if(r===null)return e;let i=r[0].length,a=r[1]!==void 0||!r[0].includes(`:`),o=t.slice(i),s=o.search(a?dw:fw),c=(s===-1?o:o.slice(0,s)).lastIndexOf(`@`);return c===-1?e:e.slice(0,n[i])+`REDACTED:REDACTED`+e.slice(n[i+c])},mw=(e,t)=>e.split(`&`).map(e=>{let n=e.indexOf(`=`);return n!==-1&&cw(hw(e.slice(0,n)),t)?e.slice(0,n+1)+`REDACTED`:e}).join(`&`),hw=e=>{if(!e.includes(`%`)&&!e.includes(`+`))return e;try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}},gw=()=>O(globalThis[`~effect/Fiber/currentFiber`]?.context??la(),_w),_w=k(`effect/http/UrlParams/CurrentRedactedNames`,{defaultValue:()=>[`X-Amz-Signature`,`X-Amz-Credential`,`X-Amz-Security-Token`,`AWSAccessKeyId`,`Signature`,`sig`,`X-Goog-Signature`]});function vw(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var yw=`~structural`,bw=`~sentinels`,xw=`~constructor`,Sw=f(e=>{let t=vw(e)?.identifier;return typeof t==`string`?t:e.getExpected(Sw)}),K=Symbol(),Cw=Zf,ww=Cw(K),q=Cw(K),Tw=e=>e===K?T():E(e),Ew=e=>e._tag===`None`?ww:Cw(e.value),Dw=`~effect/SchemaIssue/Issue`;function Ow(e){return v(e,Dw)&&e[Dw]===Dw}function kw(e){return Object.hasOwn(e,`input`)}var Aw=class{[Dw]=Dw;constructor(e,t){t?.reportInput===!0&&e!==K&&(this.input=e)}},jw=class extends Aw{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},Mw=class extends Aw{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},Nw=class extends Aw{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},Pw=class extends Aw{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},Fw=class extends Aw{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Iw=class extends Aw{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Lw=class extends Aw{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Rw=class extends Aw{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function zw(e,t,n,r,i){return new Iw(e,[new Nw([t],n)],r,i)}var Bw=class extends Aw{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Vw=class extends Aw{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function Hw(e,t,n){if(Ow(e))return e;if(typeof e==`string`)return new Rw({message:e},t,n);let r=typeof e.issue==`string`?new Rw({message:e.issue},t,n):e.issue;return new Nw(e.path,r)}function Uw(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new Rw(void 0,t,n):Hw(e,t,n)}function Ww(e,t,n,r){return Array.isArray(t)?_i(t)?t.length===1?Hw(t[0],n,r):new Iw(e,Ni(t,e=>Hw(e,n,r)),n,r):void 0:Uw(t,n,r)}var Gw=e=>{let t=tT(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return Yw(Sw(e.ast),e);case`InvalidValue`:{let t=Jw(e);if(t!==void 0)return Yw(t,e);let n=qw(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=qw(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=qw(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},Kw=e=>tT(e)??tT(e.issue);function qw(e){return kw(e)?x(e.input):void 0}function Jw(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function Yw(e,t){let n=qw(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function Xw(e,t){let n=t(e);if(n!==void 0||e.issue._tag!==`InvalidValue`)return n;let r=Jw(e.issue);return r===void 0?Yw(Zw(e.filter),e):Yw(r,e.issue)}function Zw(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>Zw(e)).join(` & `)}}function Qw(){return e=>eT(e,``)}var $w=Qw();function eT(e,t,n){let r;switch(e._tag){case`Filter`:return eT(e.issue,t,n??Xw(e,Kw));case`Encoding`:return eT(e.issue,t,n);case`Pointer`:return eT(e.issue,t+xt(e.path),n);case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>eT(e,t,n)).join(`
14
- `);r=n??tT(e)??Yw(Sw(e.ast),e);break;default:r=n??Gw(e)}return t?`${r}\n at ${t}`:r}function tT(e){if(e._tag===`Pointer`||e._tag===`Composite`)return;if(e._tag===`Encoding`)return tT(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function nT(e){let t;for(let n of e.reasons){if(!Sf(n)||!Ow(n.error))return;t??=n.error}return t}function rT(e,t){let n=nT(e);if(n===void 0)throw Error(t,{cause:e});return n}var iT=(e,t,n)=>{switch(e._tag){case`Passthrough`:return R(t);case`Transform`:return R(Ar(t,e.transform));case`TransformOptional`:return R(e.transform(t));case`TransformEffect`:return yr(t)?_g:Y_(e.transform(t.value,n),E);case`TransformOptionalEffect`:return e.transform(t,n)}},aT=e=>Object.assign(Object.create(t),e),oT=(e,t)=>pT((n,r)=>Q_(iT(e,n,r),e=>iT(t,e,r))),sT=r(2,(e,t)=>{if(e._tag===`Passthrough`)return t;if(t._tag===`Passthrough`)return e;switch(e._tag){case`Transform`:switch(t._tag){case`Transform`:return uT(n=>t.transform(e.transform(n)));case`TransformOptional`:return fT(n=>t.transform(Ar(n,e.transform)));case`TransformEffect`:return dT((n,r)=>t.transform(e.transform(n),r));case`TransformOptionalEffect`:return oT(e,t)}case`TransformOptional`:switch(t._tag){case`Transform`:return fT(n=>Ar(e.transform(n),t.transform));case`TransformOptional`:return fT(n=>t.transform(e.transform(n)));case`TransformEffect`:case`TransformOptionalEffect`:return oT(e,t)}case`TransformEffect`:switch(t._tag){case`Transform`:return dT((n,r)=>Y_(e.transform(n,r),t.transform));case`TransformOptional`:case`TransformOptionalEffect`:return oT(e,t);case`TransformEffect`:return dT((n,r)=>Q_(e.transform(n,r),e=>t.transform(e,r)))}case`TransformOptionalEffect`:return oT(e,t)}}),cT=aT({_tag:`Passthrough`});function lT(){return cT}function uT(e){return aT({_tag:`Transform`,transform:e})}function dT(e){return aT({_tag:`TransformEffect`,transform:e})}function fT(e){return aT({_tag:`TransformOptional`,transform:e})}function pT(e){return aT({_tag:`TransformOptionalEffect`,transform:e})}function mT(){return fT(()=>T())}function hT(e){return pT(t=>{let n=Pr(t,le);return br(n)?R(n):Y_(e,E)})}function gT(){return uT(globalThis.String)}function _T(){return uT(globalThis.Number)}function vT(e){return dT((t,n)=>wg({try:()=>JSON.parse(t,e?.reviver),catch:()=>new Rw({expected:`a valid JSON string`},t,n)}))}function yT(e){return dT((t,n)=>wg({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new Rw({expected:`a JSON-serializable value`},t,n)}))}function bT(e){let t=e?.separator??`,`,n=e?.keyValueSeparator??`=`,r=e?.trim??!1,i=e?.keepEmptyValues??!1;return uT(e=>e.split(t).reduce((e,t)=>{let a,o;if(n===``)a=t.slice(0,1),o=t.slice(1,2);else{let r=t.indexOf(n);if(r===-1)return e;a=t.slice(0,r),o=t.slice(r+n.length)}return r&&(a=a.trim(),o=o.trim()),a===``||o===``&&!i||b(e,a,o),e},{}))}function xT(e){let t=e?.separator??`,`,n=e?.keyValueSeparator??`=`;return uT(e=>Object.entries(e).map(([e,t])=>`${e}${n}${t}`).join(t))}function ST(e){let t=e?.separator??`,`;return uT(e=>e===``?[]:e.split(t))}function CT(){return uT(PS)}function wT(){return dT((e,t)=>X_(Dg(FS(e)),()=>new Rw({expected:`a valid Base64 string`},e,t)))}function TT(){return uT(encodeURIComponent)}function ET(){return dT((e,t)=>{try{return R(globalThis.decodeURIComponent(e))}catch{return H(new Rw({expected:`a valid URI component`},e,t))}})}var DT=Symbol.for(`~effect/Schema/content`);function OT(e,t){return Object.defineProperty(e,DT,{value:t}),e}var kT=class extends n{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new kT(this.encode,this.decode)}},AT=`~effect/SchemaTransformation/Transformation`,jT=class extends n{[AT]=AT;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new jT(this.encode,this.decode)}};function MT(e){return v(e,AT)&&e[AT]===AT}var NT=e=>MT(e)?e:new jT(e.decode,e.encode);function PT(e){return new jT(dT(e.decode),dT(e.encode))}function FT(e){return new jT(uT(e.decode),uT(e.encode))}function IT(e){return new jT(bT(e),xT(e))}var LT=new jT(lT(),lT());function RT(){return LT}var zT=new jT(_T(),gT()),BT=e=>he(e)&&typeof e.message==`string`,VT=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:GT(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},HT=e=>{try{let t=Tt(e);return t===void 0?x(e):JSON.parse(t)}catch{return x(e)}},UT=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},WT=e=>{let t=new WeakSet,n=r=>{if(ve(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=UT(r,e,n);return t.delete(r),i}return HT(r)};return n},GT=e=>BT(e)?VT(e):e,KT=e=>FT({decode:GT,encode:WT(e)}),qT=new jT(wT(),CT()),JT=new jT(ET(),TT());function YT(e){return new jT(vT(e??{}),OT(yT(e),{mediaType:`application/json`,preserveSchema:e?.reviver===void 0&&e?.replacer===void 0}))}function XT(e){return t=>t._tag===e}var ZT=XT(`Declaration`),QT=XT(`Never`),$T=XT(`String`),eE=XT(`Number`),tE=XT(`Symbol`),nE=XT(`Literal`),rE=XT(`UniqueSymbol`),iE=XT(`Enum`),aE=XT(`TemplateLiteral`),oE=XT(`Arrays`),sE=XT(`Objects`),cE=XT(`Union`),lE=XT(`Suspend`),uE=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},dE={},fE=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},pE=`~effect/Schema`,mE=class{[pE]=pE;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},hE=class extends mE{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>{if(t===K)return ww;e??=this.run(this.typeParameters);try{return e(t,this,n)}catch(e){return Cg(e)}}}_rebuild(e,t,n,r,i){let a=BD(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new hE(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},gE=new class extends mE{_tag=`Null`;getParser(){return rO(this,null)}getExpected(){return`null`}},_E=class extends mE{_tag=`Undefined`;getParser(){return rO(this,void 0)}toCodecJson(){return DD(this,[vE])}getExpected(){return`undefined`}},vE=new uE(gE,new jT(uT(()=>void 0),uT(()=>null))),yE=new _E,bE=new class extends mE{_tag=`Void`;getParser(){let e=Cw(void 0);return t=>t===K?ww:e}toCodecJson(){return DD(this,[vE])}getExpected(){return`void`}},xE=new class extends mE{_tag=`Never`;getParser(){return iO(this,fe)}getExpected(){return`never`}},SE=new class extends mE{_tag=`Unknown`;getParser(){return iO(this,pe)}getExpected(){return`unknown`}},CE=class extends mE{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${x(e)}`);this.literal=e}getParser(){return rO(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?wE(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:wE(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function wE(e){let t=globalThis.String(e.literal);return DD(e,[new uE(new CE(t),new jT(uT(()=>e.literal),uT(()=>t)))])}var TE=new class extends mE{_tag=`String`;getParser(){return iO(this,re)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&pO(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},EE=class extends mE{_tag=`Number`;getParser(){return iO(this,ie)}matchKey(e,t){return this._match(cO,e,t)}matchPart(e,t){return this._match(sO,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:pO(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(DE(this.checks,`effect/schema/isFinite`)||DE(this.checks,`effect/schema/isInt`))?this:DD(this,[SD])}toCodecStringTree(){return this.toCodecJson()===this?DD(this,[dO]):DD(this,[fO])}getExpected(){return`number`}};function DE(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&DE(e.checks,t))}var OE=new EE,kE=new class extends mE{_tag=`Boolean`;getParser(){return iO(this,ae)}getExpected(){return`boolean`}},AE=class extends mE{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(YD(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(YD(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new Fw(n,t[o],i),a=new Nw([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return H(new Iw(n,[a],t,i))}return e.issues?H(new Iw(n,e.issues,t,i)):Cw(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:[],issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:Qu(t.concurrency),f=d===1?NE(i,e,0,u):PE(i,e,{concurrency:d,end:u});if(!f)return c(i);if(L(f))return Q_(f,()=>c(i));let p=!0;return z(()=>p?(p=!1,U(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===K)return ww;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):H(new Lw(n,e,a))}catch(e){return Cg(e)}}}_rebuild(e,t,n){let r=BD(this.elements,e),i=BD(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new AE(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function jE(e,t,n,r){if(n._tag===`Failure`)return FE(e,e.ast,r,n);let i=n===q?t:n[S];if(i!==K)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(YD(t.ast))return;let n=new Nw([r],new Pw(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return $f(new Iw(e.ast,[n],e.input,e.options))}}var ME={onItem(e,t,n){let r=n<e.len?t:K;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:jE},NE=$u()(ME),PE=td()(ME),FE=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=nT(r.cause);if(i===void 0)return Qf(Nf(r.cause,r=>new Iw(t,[new Nw([n],r)],e.input,e.options)));let a=new Nw([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return $f(new Iw(t,[a],e.input,e.options))},IE=`[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?`;function LE(e,t,n=dE){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(aO(eO(t)))}var RE=class{name;type;constructor(e,t){this.name=e,this.type=t}};function zE(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(zE);default:return!1}}function BE(e){let t=kD(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(BE);default:return!1}}function VE(e){return zE(e)&&BE(e)}var HE=class{parameter;type;constructor(e,t){if(!VE(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,YD(t)||t.encoding!==void 0&&YD(eO(t)))throw Error("Cannot use `Schema.optionalKey` or `Schema.optional` with index signatures. Index signatures already allow keys to be absent; use `Schema.UndefinedOr` to allow `undefined` values.")}},UE=class extends mE{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return iO(n,de);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(aO(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return FE(t,n,i,s)??np;let c=s===q?o:s[S];if(a!==K&&c!==K){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return np;b(t.out,a,c)}return np},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!L(t))return U(Mg(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return FE(e,n,r,a)??np;let o=a===q?r:a[S],s=e.input[r],l=i.parserValue(s,e.options);return L(l)?t(e,r,o,s,l):U(Mg(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return L(a)?t(e,n,n,i,a):U(Mg(a),r=>t(e,n,n,i,r))},u=i?td()({onItem:(e,[t,n])=>n.is.parameter===TE?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return ev(function*(t,d){if(t===K)return K;if(typeof t!=`object`||!t||Array.isArray(t))return yield*H(new Lw(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,g=d.onExcessProperty===`error`,ee=d.concurrency===void 0?1:Qu(d.concurrency),_=i&&g?n.indexSignatures.map(e=>LE(f,e.parameter,d)):void 0;if(g){let r=_?new Set(e):e;if(_)for(let e of _)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new Fw(n,f[a],d),r=new Nw([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*H(new Iw(n,[r],t,d))}}}if(r){let e=ee===1?KE(m,a):qE(m,a,{concurrency:ee});e&&(yield*e)}if(i&&ee===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===TE?l:c,r=_?.[e]??(t.is.parameter===TE?Object.keys(f):LE(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!L(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=ji();for(let t=0;t<i;t++){let n=o[t],r=_?.[t]??(n.is.parameter===TE?Object.keys(f):LE(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:ee});t&&(yield*t)}return m.issues?yield*H(new Iw(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return U(Mg(n),n=>{let i={...e,out:{...e.out}},o=WE(i,r,n);if(o)return o;let s=()=>Cw(i.out),c=KE(i,a.slice(t+1));return c?Q_(c,s):s()})};return(e,t)=>{if(e===K)return ww;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&Qu(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return H(new Lw(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=oD(i,s),l=c?i[s]:K,d=n.parser(l,t);if(!L(d))return u(o,e,d);if(d===q){c&&b(a,s,l);continue}let f=WE(o,n,d);if(f)return f}}catch(e){return Cg(e)}return Cw(a)}}_rebuild(e,t,n,r){let i=BD(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new RE(t.name,n)}),a=BD(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new HE(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new UE(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function WE(e,t,n){if(n._tag===`Failure`)return FE(e,e.ast,t.name,n);if(n===q)return;let r=n[S];if(r!==K)b(e.out,t.name,r);else if(delete e.out[t.name],!YD(t.type)){let n=new Nw([t.name],new Pw(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return $f(new Iw(e.ast,[n],e.input,e.options))}}var GE={onItem(e,t){if(!oD(e.input,t.name))return t.parser(K,e.options);let n=e.input[t.name];return b(e.out,t.name,n),t.parser(n,e.options)},step:WE},KE=$u()(GE),qE=td()(GE);function JE(e,t){return e?t?[...e,...t]:e:t}function YE(e,t,n){return new UE(Reflect.ownKeys(e).map(t=>new RE(t,e[t].ast)),[],n,t)}function XE(e){return e.ast}function ZE(e,t=void 0){return new AE(!1,e.map(e=>e.ast),[],void 0,t)}function QE(e,t,n){return new cD(e.map(XE),t,void 0,n)}function $E(e){if(e.encoding)throw Error(`mutable does not support encodings`);return new AE(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var eD=p(e=>{for(;;){if(lE(e))return SE;let t=e.encoding;if(!t)return e.recur?.(eD,i)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==i))return SE;e=t[t.length-1].to}});function tD(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(tD)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function nD(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[bw];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!YD(t)){if(nE(t))return[{key:e.name,literal:t.literal}];if(rE(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!YD(e)){if(nE(e))return[{key:t,literal:e.literal}];if(rE(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>nD(eD(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return nD(e.thunk())}}var rD=new WeakMap,iD=Object.freeze([]),aD=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,oD=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function sD(e){let t=rD.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=eD(c);if(QT(l))continue;if(nE(l)||rE(l)){a??=new Map;let e=nE(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=nD(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=tD(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??iD);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??iD;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(ge(e)){let n=oD(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??iD;if(t)return o}return iD}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=aD(t);if(!ge(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=oD(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=oD(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=oD(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(aD(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return rD.set(e,t),t}var cD=class extends mE{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===K)return ww;let i=(o??=sD(n.types))(e,r);if(i.length===0)return H(new Bw(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:L(r)?lD(n,r.cause,e,t):uD(n,r,e,t)}return dD(n,a,i,e,t)}}_rebuild(e,t,n){let r=BD(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new cD(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=eO(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(nE);if(t.length>0)return`${hD(n.isMutable)}[ ${t.map(t=>e(t)+gD(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>nE(e.type));if(t.length>0)return`{ ${t.map(t=>`${hD(t.type.context?.isMutable)}${bt(t.name)}${gD(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function lD(e,t,n,r){let i=nT(t);return i?$f(new Bw(e,[i],n,r)):Qf(t)}function uD(e,t,n,r){return Ig(t,t=>lD(e,t,n,r))}function dD(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=pD(a,n);if(!o)return a.out?a.out:H(new Bw(e,a.issues??[],r,i));if(L(o))return fD(o,a);let s=!0;return z(()=>s?(s=!1,fD(o,a)):dD(e,t,n,r,i))}function fD(e,t){return Q_(e,e=>t.out===q?R(t.input):t.out?t.out:H(new Bw(t.ast,t.issues??[],t.input,t.options)))}var pD=$u()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=nT(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),$f(new Vw(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return np}}}),mD=new cD([new CE(`Infinity`),new CE(`-Infinity`),new CE(`NaN`)]);function hD(e){return e?``:`readonly `}function gD(e){return e?`?`:``}var _D=class extends n{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new _D(this.run,{...this.annotations,...e},this.aborted)}abort(){return new _D(this.run,this.annotations,!0)}and(e,t){return new vD([this,e],t)}},vD=class extends n{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new vD(this.checks,{...this.annotations,...e})}and(e,t){return new vD([this,e],t)}};function yD(e,t,n=!1){return new _D((t,n,r)=>Ww(n,e(t,n,r),t,r),t,n)}function bD(e){return yD(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var xD=MD(OE,[bD()]),SD=new uE(new cD([xD,mD]),new jT(_T(),uT(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function CD(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return yD(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var wD=new WeakMap;function TD(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&wD.set(n,ED(e)),n}function ED(e){let t=wD.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return wD.set(e,n),n}function DD(e,t){return e.encoding===t?e:TD(e,{encoding:t})}function OD(e,t){if(e.context===t)return e;let n=ED(e);return n.context===t&&n.encoding===e.encoding?n:TD(e,{context:t})}function kD(e){return e.encoding?kD(e.encoding[e.encoding.length-1].to):e}function AD(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return jD(e,pi(e.checks.slice(0,-1),n.annotate(t)))}return TD(e,{annotations:{...e.annotations,...t}})}function jD(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:TD(e,{checks:t})}function MD(e,t){return jD(e,JE(e.checks,t))}function ND(e,t){let n=t(e.to);return n===e.to?e:new uE(n,e.transformation)}function PD(e,t){let n=e,r=n[n.length-1],i=ND(r,t);return i===r?e:pi(e.slice(0,e.length-1),i)}function FD(e){return t=>t.encoding?DD(t,PD(t.encoding,e)):t}function ID(e,t){return FD(e=>OD(e,t))(e)}function LD(e){function t(n){return n.encoding?DD(n,PD(n.encoding,t)):e(n)}return f(t)}function RD(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:DD(r,PD(r.encoding,n))}return e(r)}return p(n)}function zD(e,t,n){let r=new uE(e,t);return DD(n,n.encoding?[...n.encoding,r]:[r])}function BD(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function VD(e,t){return OD(e,e.context?new fE(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new fE(!1,!1,void 0,t))}var HD=p(e=>UD(OD(e,e.context?e.context.isOptional===!1?new fE(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new fE(!0,!1)))),UD=FD(HD),WD=f(e=>HD(new cD([e,yE])));function GD(e,t){return OD(e,e.context?new fE(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new fE(!1,!1,t))}function KD(e,t,n){return zD(e,n,t)}function qD(e){let t=[],n=[];function r(e){t.includes(e)||t.push(e)}function i(e){switch(e._tag){case`Literal`:se(e.literal)&&r(e.literal);return;case`UniqueSymbol`:r(e.symbol);return;case`Enum`:for(let[,t]of e.enums)r(t);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)i(e.types[t]);return;default:n.push(e)}}return i(e),{literals:t,parameters:n}}function JD(e,t){let{literals:n,parameters:r}=qD(e);return new UE(n.map(e=>new RE(e,t)),r.map(e=>new HE(e,t)))}function YD(e){return e.context?.isOptional??!1}function XD(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(XD)}function ZD(e){function t(e){return XD(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return gi(n)?n:void 0}function QD(e){let t=!0;function n(e){return t=t&&!e.encoding&&!lE(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var $D=p(e=>{let t=ED(e);if(t!==e){let n=$D(t);return n===t&&e.encoding===void 0?e:OD(n,e.context)}let n=`recur`in e?e.recur($D):e;if(`encodingChecks`in n&&n.encodingChecks){let t=QD(e)?n.encodingChecks:oE(n)||sE(n)||ZT(n)&&n.typeParameters.length>0?ZD(n.encodingChecks):void 0;return TD(n,{encodingChecks:void 0,checks:JE(n.checks,t)})}return n}),eO=p(e=>$D(nO(e)));function tO(e,t){let n=t,r=n.length,i=n[r-1],a=[new uE(nO(DD(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new uE(nO(n[e-1].to),n[e].transformation.flip()));let o=nO(i.to);return o.encoding?DD(o,[...o.encoding,...a]):DD(o,a)}var nO=f(e=>{if(e.encoding)return tO(e,e.encoding);let t=ED(e);if(t!==e){let n=nO(t);return n===t?e:OD(n,e.context)}return`flip`in e?e.flip(nO):`recur`in e?e.recur(nO):e});function rO(e,t){let n=t===0?q:Cw(t);return(r,i)=>r===K?ww:r===t?n:H(new Lw(e,r,i))}function iO(e,t){return(n,r)=>n===K?ww:t(n)?q:H(new Lw(e,n,r))}var aO=RD(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(aO)}}),oO=RD(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(oO)}}),sO=new globalThis.RegExp(`^${IE}$`),cO=new globalThis.RegExp(`^(?:${IE}|Infinity|-Infinity|NaN)$`);function lO(e){return CD(sO,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:sO.source}),...e})}var uO=MD(TE,[lO()]),dO=new uE(uO,zT),fO=new uE(new cD([uO,mD]),zT);function pO(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=pO(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new jw(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function mO(e){if(!ZT(e))return;let t=e.annotations?.[xw];return ce(t)?t(e.typeParameters):void 0}function hO(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function gO(e){return e===void 0||typeof e==`string`}function _O(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function vO(e){return _O(e,hO)}var yO=new hE([],()=>(e,t,n)=>vO(e)?q:H(new Lw(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>CO}),bO=new uE(yO,RT()),xO=new uE(new cD([new AE(!1,[],[yO]),new UE([],[new HE(TE,yO)])]),RT());function SO(e){return _O(e,gO)}var CO=new uE(new hE([],()=>(e,t,n)=>SO(e)?q:H(new Lw(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),RT()),wO=(e,t,n)=>e===q?n(t):Q_(e,n);function TO(e){let t=EO(e);return(e,n,r)=>{try{return t(e,n,r)}catch(e){return Cg(e)}}}function EO(e){if(e._tag===`Middleware`)return(t,n,r)=>DO(t===q?e.decode(Cw(Tw(n)),r):e.decode(Y_(t,Tw),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===q?Cw(t):e;case`Transform`:{let e=e=>e===K?ww:Cw(t.transform(e));return(t,n)=>wO(t,n,e)}case`TransformOptional`:{let e=e=>Ew(t.transform(Tw(e)));return(t,n)=>wO(t,n,e)}case`TransformEffect`:return(e,n,r)=>wO(e,n,e=>e===K?ww:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>wO(e,n,e=>DO(t.transform(Tw(e),r)))}}var DO=e=>Q_(e,Ew),OO=(e,t,n,r)=>Ig(r,r=>Sg(()=>Nf(r,r=>new Mw(e,r,t,n))));function kO(e,t){let n=TO(e.link.transformation),r;return(i,a)=>{if(i===K)return ww;if(e.isConstructed(i))return q;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function AO(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==K&&r!==void 0)return t(r,i);let a=n;if(L(a)&&a._tag===`Success`){let e=t(a[S],i);return e===q?a:e}return Q_(OO(e,r,i,a),e=>{let n=t(e,i);return n===q?Cw(e):n})}}function jO(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:AO(e,n)}function MO(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?mO(e):void 0,o=a?kO(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>TO(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);try{if(u&&!n.disableChecks){if(L(r)){if(r._tag===`Success`){let i=r===q?t:r[S];if(t!==K&&i!==K){let i=pO(u,t,void 0,e,n);i&&(r=H(new Iw(e,i,t,n)))}}}else r=U(r,r=>{if(t!==K&&r!==K){let r=pO(u,t,void 0,e,n);if(r)return H(new Iw(e,r,t,n))}return R(r)})}if(s&&!n.disableChecks){if(L(r)){if(r._tag===`Success`){let i=r===q?t:r[S];if(i===K)return r;let a=pO(s,i,void 0,e,n);a&&(r=H(new Iw(e,a,i,n)))}}else r=U(r,t=>{if(t!==K){let r=pO(s,t,void 0,e,n);if(r)return H(new Iw(e,r,t,n))}return R(t)})}return r}catch(e){return Cg(e)}},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[S],o=t(a,r)):o=Q_(o,e=>{let n=t(e,r);return n===q?Cw(e):n})}if(o._tag===`Success`){let e=o[S],t=p(e,r);return t===q?o:t}return o=OO(e,n,r,o),Q_(o,e=>{let t=p(e,r);return t===q?Cw(e):t})}:p}var NO=Symbol(),PO=new WeakMap,FO=e=>zO(e).parser,IO=e=>zO(e).makeEffect,LO=e=>jO(e,IO),RO=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=MO(this.ast,FO)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=MO(this.ast,IO,LO)}};function zO(e){let t=PO.get(e);if(t!==void 0)return t;let n=new RO(e);return PO.set(e,n),n}function BO(e){let t=e.ast,n;return(e,r)=>(n??=$O(lk,$D(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function VO(e){let t=BO(e);return(e,n)=>{let r=U_(t(e,n));return rp(r)?E(r.value):(rT(r.cause,`Option adapter can only return none for schema issues`),T())}}function HO(e){return ak($D(e.ast))}function UO(e){return GO(e.ast)}function WO(e){{let t=ek(ZO(e));return e=>{let n=t(e,dE);return rp(n)?!0:(rT(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function GO(e){let t=$D(e),n=e=>(n=WO(t),n(e));return e=>n(e)}function KO(e,t){let n=ZO(e.ast);return t===void 0?n:(e,r)=>n(e,YO(t,r))}function qO(e,t){return tk(KO(e,t))}function JO(e,t){let n=ZO(nO(e.ast));return t===void 0?n:(e,r)=>n(e,YO(t,r))}var YO=(e,t)=>t?{...e,...t}:e,XO=e=>e===K?H(new Rw):R(e);function ZO(e){return $O(ck,e)}function QO(e,t){return e===q?R(t):L(e)?e[`~effect/Effect/args`]===K?XO(K):e:Q_(e,XO)}function $O(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??dE);return a===q?R(r):L(a)?a[`~effect/Effect/args`]===K?XO(K):a:Q_(a,XO)}}function ek(e){return(t,n)=>U_(e(t,n))}function tk(e){let t=ek(e);return(e,n)=>{let r=t(e,n);return rp(r)?Lr(r.value):Rr(rT(r.cause,`Result adapter can only return schema issues`))}}function nk(e,t){let n=U_(e);if(rp(n))return n.value;let r=rT(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}var rk=`Constructor adapter can only throw schema issues`;function ik(e){throw Error(rk,{cause:Df(e)})}function ak(e){let t;return(n,r)=>ok(t??=zO(e),n,r)}function ok(e,t,n){let r=n?.disableChecks?n.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions??dE,i=e.make;if(i!==void 0&&t!==K){let e;try{e=i(t,r)}catch(e){ik(e)}if(e!==NO&&e!==K)return e}return nk(QO(e.makeEffect(t,r),t),rk)}function sk(e,t,n,r){let i=zO(e),a=mO(e);if(a===void 0||i.make!==void 0||i.compiledMakeEffect!==void 0)return ok(i,t,n);if(a.isConstructed(t))return t;let o=ok((i.resolve??zO)(a.link.to),t,n);try{return r(o)}catch(e){ik(e)}}var ck=e=>zO(e).parser,lk=e=>zO(e).makeEffect,uk=`~effect/Schema/Schema`,dk=Symbol(),fk={[uk]:uk,get make(){let e=HO(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=BO(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=VO(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return e(this,arguments)},annotate(e){return this.rebuild(AD(this.ast,e))},annotateKey(e){return this.rebuild(VD(this.ast,e))},check(...e){return this.rebuild(MD(this.ast,e))},rebuild(e){return pk(e,this[dk])}};function pk(e,t){function n(){}let r=Object.setPrototypeOf(n,fk);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[dk]=t,r.ast=e,r}function mk(e){return pk(hk(e.ast),{schema:e})}var hk=gk(xk);function gk(e,t){let n=f(t=>{let n=OD(t,void 0),i=e(n,r);return i===n?null:i}),r=RD(e=>{let t=n(ED(e));if(t===null)return e;let r=OD(t,e.context);return e.context===void 0?r:ID(r,_k(e.context))},t);return r}function _k(e){return e.constructorDefault===void 0?e:new fE(e.isOptional,e.isMutable,void 0,e.annotations)}function vk(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function yk(e){return t=>{let n=[...t].sort((t,n)=>e(eO(t))-e(eO(n)));return n.some((e,n)=>e!==t[n])?n:t}}var bk=yk(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function xk(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!ce(n))return DD(e,[bO]);let r=n(e.typeParameters.map(e=>pk(eO(e))));return r===void 0?e:DD(e,[ND(r,t)])}case`Unknown`:return DD(e,[bO]);case`ObjectKeyword`:return DD(e,[xO]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return vk(e),e.recur(t,oO);case`Union`:{let n=bk(e.types);return n===e.types?e.recur(t):new cD(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}function Sk(e){return pk(Ok(e.ast),{schema:e})}var Ck=yk(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function wk(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>pk(t(eO(e)))),i=e.annotations?.toCodecStringTree;if(ce(i)){let n=i(r);return n===void 0?e:DD(e,[ND(n,t)])}let a=e.annotations?.toCodecJson,o=ce(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(ce(s)?s(r):void 0);return c===void 0?n(e):DD(e,[ND(c,t)])}case`Null`:return DD(e,[Tk]);case`Boolean`:return DD(e,[Ek]);case`Unknown`:case`ObjectKeyword`:return DD(e,[CO]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return vk(e),e.recur(t,oO);case`Union`:{let n=Ck(e.types);return n===e.types?e.recur(t):new cD(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var Tk=new uE(new CE(`null`),new jT(uT(()=>null),uT(()=>`null`))),Ek=new uE(new cD([new CE(`true`),new CE(`false`)]),new jT(uT(e=>e===`true`),gT())),Dk=new jT(uT(e=>typeof e==`string`?[e]:e),lT()),Ok=gk((e,t)=>wk(e,t,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})}),{stopAt:e=>e.transformation===Dk}),kk=e=>e,Ak=`~effect/Schema/SchemaError`;function jk(e){return v(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var Mk=e=>{let t=0;for(let n=0;n<e.length;n++)t+=e[n].length;let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++)n.set(e[t],r),r+=e[t].length;return n},Nk=lr((e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return e.length<t.length?-1:+(e.length>t.length)});({...Mt}),{...Mt},{...Mt},{...Mt},{...Mt},{...Mt},{...Mt},{...Mt};var Pk=uk;function Fk(){return(e,t,n)=>J(new hE(e.map(XE),e=>t(e.map(e=>J(e))),n))}function Ik(e,t){return Fk()([],()=>(t,n,r)=>e(t)?R(t):H(new Lw(n,t,r)),t)}var Lk=class extends Bo(`SchemaError`){[Ak]=Ak;constructor(e){let t=Ft();It(0);try{super({issue:e})}finally{It(t)}}get message(){return $w(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[kt](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function Rk(e){return jk(e)}function zk(e){return L(e)?Bk(e):Ig(e,e=>Sg(()=>Nf(e,e=>new Lk(e))))}function Bk(e){return rp(e)?e:Qf(Nf(e.cause,e=>new Lk(e)))}function Vk(e,t){let n;for(let r of e.reasons){if(!Sf(r)||!Rk(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function Hk(e){let t=U_(e);if(rp(t))return t.value;throw Vk(t.cause,`Sync adapter can only throw schema errors`)}var Uk=UO;function Wk(e,t){let n=KO(e,t);return(e,t)=>zk(n(e,t))}var Gk=Wk;function Kk(e,t){let n=qO(e,t);return(e,t)=>Ur(n(e,t),e=>new Lk(e))}function qk(e,t){let n=Wk(e,t);return(e,t)=>Hk(n(e,t))}var Jk=qk;function Yk(e,t){let n=JO(e,t);return(e,t)=>zk(n(e,t))}var Xk=Yk;function Zk(e,t){let n=Yk(e,t);return(e,t)=>Hk(n(e,t))}var Qk=Zk,J=pk;function $k(e){return v(e,Pk)&&e[Pk]===Pk}var eA=kk(e=>J(HD(e.ast),{schema:e})),tA=kk(e=>{let t=EA(e);return J(WD(e.ast),{schema:t})}),nA=kk(e=>J($D(e.ast),{schema:e})),rA=kk(e=>J(eO(e.ast),{schema:e}));function iA(e){let t=J(new CE(e),{literal:e,transform(n){return t.pipe(DA(iA(n),{decode:uT(()=>n),encode:uT(()=>e)}))}});return t}var aA=J(xE),oA=J(SE),sA=J(gE),cA=J(yE),lA=J(TE),uA=J(OE),dA=J(kE),fA=J(bE);function pA(e,t){return J(e,{fields:t,mapFields(e,t){let n=e(this.fields);return pA(YE(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function mA(e){return pA(YE(e,void 0),e)}function hA(e,t){return J(JD(e.ast,t.ast),{key:e,value:t})}function gA(e,t){return J(e,{elements:t,mapElements(e,t){let n=e(this.elements);return gA(ZE(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function _A(e){return gA(ZE(e),e)}var vA=kk(e=>J(new AE(!1,[],[e.ast]),{value:e})),yA=kk(e=>J(new AE(!1,[e.ast],[e.ast]),{value:e}));function bA(e){let t=vA(e),n=vA(nA(e));return J(CA([DA(_A([oA]),FT({decode:e=>[e],encode:([e])=>e}))(e),t]).pipe(DA(n)).ast,{from:CA([e,t]),to:n})}var xA=kk(e=>J($E(e.ast),{schema:e}));function SA(e,t){return J(e,{members:t,mapMembers(e,t){let n=e(this.members);return SA(QE(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function CA(e,t){return SA(QE(e,t,void 0),e)}function wA(e){let t=e.map(iA);return J(QE(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return CA(e(this.members))},pick(e){return wA(e)},transform(e){return CA(t.map((t,n)=>t.transform(e[n])))}})}var TA=kk(e=>CA([e,sA])),EA=kk(e=>CA([e,cA]));function DA(e,t){return n=>J(KD(n.ast,e.ast,t?NT(t):RT()),{from:n,to:e})}function OA(e){return t=>J(GD(t.ast,e),{schema:t})}function kA(e){return L(e)&&e._tag===`Success`?e:Ig(e,e=>Sg(()=>Nf(e,e=>e.issue)))}function AA(e,t){let n=t?.encodingStrategy===`omit`?mT():lT();return t=>eA(rA(t)).pipe(DA(t,{decode:hT(kA(e)),encode:n}))}function jA(e){return iA(e).pipe(OA(R(e)))}function MA(e,t){return mA({_tag:jA(e),...t})}function NA(e){return t=>{let n={},r=[],i=new Set,a={};return o(t),Object.assign(t,{tag:e,cases:n,discriminants:r,isAnyOf:t=>n=>t.includes(n[e]),guards:a,match:s,matchOrElse:c});function o(t){let s=t.ast;if(cE(s)&&`members`in t&&globalThis.Array.isArray(t.members)&&t.members.every($k))return t.members.forEach(o);let c=nD(s);if(c.length>0){let o=c.find(t=>t.key===e)?.literal;if(se(o)){let e=typeof o==`number`?globalThis.String(o):o;if(i.has(e))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(o)}`);i.add(e),r.push(o),b(n,o,t),b(a,o,UO(nA(t)));return}}throw new globalThis.Error(`No literal or unique symbol found`)}function s(){if(arguments.length===1){let t=arguments[0];return function(n){let r=n[e];return(Object.hasOwn(t,r)?t[r]:void 0)(n)}}let t=arguments[0],n=arguments[1],r=t[e];return(Object.hasOwn(n,r)?n[r]:void 0)(t)}function c(){if(arguments.length===2){let t=arguments[0],n=arguments[1];return function(r){let i=r[e];return(Object.hasOwn(t,i)?t[i]??n:n)(r)}}let t=arguments[0],n=arguments[1],r=arguments[2],i=t[e];return(Object.hasOwn(n,i)?n[i]??r:r)(t)}}}function PA(e){let t={},n=[];for(let r of Object.keys(e)){let i=MA(r,e[r]);b(t,r,i),n.push(i)}let r=CA(n),{tag:i,guards:a,isAnyOf:o,match:s,matchOrElse:c}=NA(`_tag`)(r);return J(r.ast,{tag:i,cases:t,isAnyOf:o,guards:a,match:s,matchOrElse:c})}function FA(e,t){return Ik(t=>t instanceof e,t)}function IA(){return(e,t)=>new uE(e.ast,NT(t))}var LA=yD;function RA(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new globalThis.RegExp(${x(n)})`:`new globalThis.RegExp(${x(n)}, ${x(r)})`;return CD(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var zA=J(xD);function BA(e){return LA(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`,minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}var VA=uA.check(BA());function HA(e,t){return e=KA(e),UA(e,Math.ceil(e/2),t)}function UA(e,t,n){return LA(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:n})=>n===`string`?e<=1?{minLength:t}:[{minLength:t},!0]:n===`array`?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[yw]:!0,arbitraryConstraint:{minLength:e},...n})}function WA(e){return UA(1,1,e)}function GA(e,t){return e=KA(e),LA(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`string`?e===0?{maxLength:e}:[{maxLength:e},!0]:t===`array`?{maxItems:e}:t===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[yw]:!0,arbitraryConstraint:{maxLength:e},...t})}function KA(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var qA=lA.check(WA()),JA=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),YA=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},XA=[];function ZA(e){let t=JA(e),n=XA[t];if(n!==void 0)return n;let r=bj.pipe(DA(oA,KT(YA(t))));return XA[t]=r,r}globalThis.RegExp,globalThis.URL;var QA=lA.annotate({expected:`a string that will be decoded as JSON`});function $A(e,t){return QA.pipe(DA(e,YT(t)))}globalThis.File,globalThis.URLSearchParams;var ej=lA.annotate({expected:`a URI component encoded string that will be decoded as a UTF-8 string`}).pipe(DA(lA,JT)),tj=lA.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),nj=FA(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>IA()(tj,qT)});function rj(e,t){return J(Fk()([e,t],([e,t])=>(n,r,i)=>{if(!xf(n))return H(new Lw(r,n,i));switch(n._tag){case`Fail`:return Z_(KO(e)(n.error,i),{onSuccess:kf,onFailure:e=>zw(r,`error`,e,n,i)});case`Die`:return Z_(KO(t)(n.defect,i),{onSuccess:Af,onFailure:e=>zw(r,`defect`,e,n,i)});case`Interrupt`:return R(n)}},{representation:{id:`effect/schema/CauseReason`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.CauseReason(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Failure<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause.Failure`,toCodec:([e,t])=>IA()(CA([mA({_tag:iA(`Fail`),error:e}),mA({_tag:iA(`Die`),defect:t}),mA({_tag:iA(`Interrupt`),fiberId:EA(zA)})]),FT({decode:e=>{switch(e._tag){case`Fail`:return kf(e.error);case`Die`:return Af(e.defect);case`Interrupt`:return jf(e.fiberId)}},encode:e=>{switch(e._tag){case`Fail`:return{_tag:`Fail`,error:e.error};case`Die`:return{_tag:`Die`,defect:e.defect};case`Interrupt`:return{_tag:`Interrupt`,fiberId:e.fiberId}}}}))}).ast,{error:e,defect:t})}function ij(e,t){return J(Fk()([e,t],([e,t])=>{let n=vA(rj(e,t));return(e,t,r)=>bf(e)?Z_(KO(n)(e.reasons,r),{onSuccess:Tf,onFailure:n=>zw(t,`reasons`,n,e,r)}):H(new Lw(t,e,r))},{representation:{id:`effect/schema/Cause`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Cause(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Cause<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause`,toCodec:([e,t])=>IA()(vA(rj(e,t)),FT({decode:Tf,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}function aj(e,t,n){return J(Fk()([e,t,n],([e,t,n])=>{let r=ij(t,n);return(t,n,i)=>{if(!Xf(t))return H(new Lw(n,t,i));switch(t._tag){case`Success`:return Z_(KO(e)(t.value,i),{onSuccess:Zf,onFailure:e=>zw(n,`value`,e,t,i)});case`Failure`:return Z_(KO(r)(t.cause,i),{onSuccess:Qf,onFailure:e=>zw(n,`cause`,e,t,i)})}}},{representation:{id:`effect/schema/Exit`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Exit(${e[0].runtime}, ${e[1].runtime}, ${e[2].runtime})`,Type:`Exit.Exit<${e[0].Type}, ${e[1].Type}, ${e[2].Type}>`,importDeclarations:[`import * as Exit from "effect/Exit"`]}),expected:`Exit`,toCodec:([e,t,n])=>IA()(CA([mA({_tag:iA(`Success`),value:e}),mA({_tag:iA(`Failure`),cause:ij(t,n)})]),FT({decode:e=>e._tag===`Success`?Zf(e.value):Qf(e.cause),encode:e=>rp(e)?{_tag:`Success`,value:e.value}:{_tag:`Failure`,cause:e.cause}}))}).ast,{value:e,error:t,defect:n})}function oj(e){return J(Fk()([e],([e])=>(t,n,r)=>vr(t)?yr(t)?_g:Z_(KO(e)(t.value,r),{onSuccess:E,onFailure:e=>zw(n,`value`,e,t,r)}):H(new Lw(n,t,r)),{representation:{id:`effect/schema/Option`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Option(${e[0].runtime})`,Type:`Option.Option<${e[0].Type}>`,importDeclarations:[`import * as Option from "effect/Option"`]}),expected:`Option`,toCodec:([e])=>IA()(CA([mA({_tag:iA(`Some`),value:e}),mA({_tag:iA(`None`)})]),FT({decode:e=>e._tag===`None`?T():E(e.value),encode:e=>br(e)?{_tag:`Some`,value:e.value}:{_tag:`None`}}))}).ast,{value:e})}var sj=globalThis.Symbol.for(`immer-draftable`),cj={};function lj(t,n,r,i,a){let o=pj(r,n,i),s=fj(n),c=class extends t{constructor(...[e,t]){let n=t?.[`~payload`],i=n?.token===cj?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:cj,value:i}})}static[Pk]=Pk;get[s](){return s}static[sj]=!0;static identifier=n;static fields=r.fields;static get ast(){return o(this).ast}static pipe(){return e(this,arguments)}static rebuild(e){return o(this).rebuild(e)}static make(e,t){return sk($D(o(this).ast),e??{},t,e=>uj(this,e))}static makeOption(e,t){return VO(o(this))(e??{},t)}static makeEffect(e,t){return o(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(AD(this.ast,e))}static annotateKey(e){return this.rebuild(VD(this.ast,e))}static check(...e){return this.rebuild(MD(this.ast,e))}static extend(e){return(t,n)=>{let i=mj(t)?t:mA(t),o={...r.fields,...i.fields},s=YE(o,r.ast.checks,{identifier:e});return lj(this,e,pA(MD(s,i.ast.checks),o),n,a)}}static mapFields(e,t){return r.mapFields(e,t)}};return a!==void 0&&Object.assign(c.prototype,a(n)),c}function uj(e,t){return new e(t,{"~payload":{token:cj,value:t}})}function dj(e){return new jT(uT(t=>uj(e,t)),lT())}function fj(e){return`~effect/Schema/Class/${e}`}function pj(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=fj(t),o=e=>e instanceof i||v(e,a),s=dj(i);return r=DA(J(new hE([e.ast],()=>(e,t,n)=>o(e)?R(e):H(new Lw(t,e,n)),{identifier:t,[xw]:([e])=>({isConstructed:o,link:new uE(e,s)}),toCodec:([e])=>new uE(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[bw]:nD(e.ast),...n})),s)(e)}}function mj(e){return $k(e)}var hj=e=>(t,n)=>lj(Ro,e,mj(t)?t:mA(t),n,e=>({toString(){return`${e}(${x({...this})})`}})),gj=e=>(t,n)=>lj(An,e,mj(t)?t:mA(t),n,e=>({name:e})),_j=e=>(t,n,r)=>{let i=mj(n)?n.mapFields(e=>({_tag:jA(t),...e}),{unsafePreserveChecks:!0}):MA(t,n);return gj(e??t)(i,r)},vj=mk,yj=Sk,bj=J(AD(yO,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})}));function xj(e){return vw(e.ast)}var Sj=`~effect/Config`,Cj=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},wj={...Wi({label:`Config`,evaluate(e){return this.parse(e.getRef(nS))}}),[Sj]:Sj,toJSON(){return{_id:`Config`}}};function Tj(e){let t=Object.create(wj);return t.evaluator=e,t.parse=t=>Q_(e(t,[]),Dg),t}var Ej=(e,t,n)=>e.evaluator(t,n),Dj=r(2,(e,t)=>Tj((n,r)=>W(Ej(e,n,r),Wr(t)))),Oj=r(2,(e,t)=>Tj((n,r)=>Y_(Ej(e,n,r),e=>D(e)?Lr(t):e))),kj=e=>e.pipe(Dj(E),Oj(T())),Aj=e=>_e(e,`SourceError`),jj=()=>`<configuration>`,Mj=e=>t=>Ig(t,t=>xg(Tf(t.reasons.map(e)))),Nj=(e,t)=>e.load(t).pipe(Mj(e=>Sf(e)?Af(e.error).annotate(Kf(e)):e),Y_(n=>({provider:e,path:t,node:n,toString:jj}))),Pj=(e,t)=>Nj(e.provider,[...e.path,t]),Fj=(e,t)=>KD(SE,e,new jT(dT(e=>t(e)),lT())),Ij=e=>{switch(e._tag){case`Union`:return e.types.every(Ij);case`Objects`:case`Arrays`:case`Suspend`:return!1;default:return!0}},Lj=(e,t)=>{switch(e._tag){case`Objects`:return t?._tag===`Record`;case`Arrays`:return t?._tag===`Array`;case`Union`:return e.types.some(e=>Lj(e,t));case`Suspend`:return Lj(e.thunk(),t);default:return t?.value!==void 0}},Rj=f(e=>{let t=new WeakSet,n=LD(e=>{switch(t.add(e),e._tag){case`Objects`:{let t=W_(function*(t){if(t.node?._tag!==`Record`)return;let n=t.node,r=new Set;for(let t of e.propertySignatures)typeof t.name==`string`&&r.add(t.name);if(e.indexSignatures.length>0){let t={};for(let e of n.keys)b(t,e,void 0);for(let n of e.indexSignatures)for(let e of LE(t,n.parameter))typeof e==`string`&&r.add(e)}let i={};for(let e of r){let n=yield*Pj(t,e);n.node!==void 0&&b(i,e,n)}return i});return Fj(e.recur(n,e=>e),t)}case`Arrays`:{let t=W_(function*(e){if(e.node?._tag!==`Array`)return;let t=[];for(let n=0;n<e.node.length;n++)t.push(yield*Pj(e,n));return t});return Fj(e.recur(n),t)}case`Union`:for(let t of e.types)n(t);if(!Ij(e))return e.recur(n);break;case`Suspend`:{let r=e.thunk();return t.has(r)||n(r),e.recur(n)}case`Declaration`:case`Any`:throw new globalThis.Error(`Config.schema does not support opaque StringTree encodings`,{cause:e})}return Fj(e,e=>R(e.node?.value))});return n(e)});function zj(e,t){let n=yj(e),r=eO(n.ast),i=KO(J(Rj(n.ast))),a=typeof t==`string`?[t]:t??[];return Tj((e,t)=>{let n=[...t,...a];return Nj(e,n).pipe(Q_(e=>i(e).pipe(Y_(Lr),$_(t=>{let i=new Cj(new Lk(n.length>0?new Nw(n,t):t));return Lj(r,e.node)?H(i):R(Rr(i))}))),Mj(e=>Cf(e)&&Aj(e.defect)?kf(new Cj(e.defect)).annotate(Kf(e)):e))})}var Bj=e=>re(e)||globalThis.Array.isArray(e);function Vj(e){return zj(lA,e)}function Hj(e,t,n){let r=Bj(t),i=r?n:t,a=vA(e),o=i?.separator??`,`;return zj(CA([lA.pipe(DA(yj(a),{decode:ST(i),encode:sT(lT({strict:!1}),uT(e=>e.join(o)))})),a]),r?t:void 0)}function Uj(e,t,n,r){let i=Bj(n),a=hA(e,t),o=IT(i?r:n);return zj(CA([a,lA.pipe(DA(yj(a),{decode:o.decode,encode:sT(lT({strict:!1}),o.encode)}))]),i?n:void 0)}var Wj={"~effect/Match/Matcher":{_input:i,_filters:i,_result:i,_return:i,_flavor:i},_tag:`ValueMatcher`,add(e){return Vr(this.value)?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?Gj(this.provided,Lr(e.evaluate(this.provided))):this},pipe(){return e(this,arguments)}};function Gj(e,t){let n=Object.create(Wj);return n.provided=e,n.value=t,n}var Kj=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),qj=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(qj),n=t.length;return e=>{if(!Array.isArray(e)||e.length<n)return!1;for(let r=0;r<n;r++)if(t[r](e[r])===!1)return!1;return!0}}if(typeof e==`object`&&e){let t=Reflect.ownKeys(e).map(t=>[t,qj(e[t])]),n=t.length;return e=>{if(typeof e!=`object`||!e)return!1;for(let r=0;r<n;r++){let[n,i]=t[r];if(!(n in e)||i(e[n])===!1)return!1}return!0}}return t=>t===e},Jj=e=>Gj(e,Rr(e)),Yj=(e,t)=>n=>n.add(Kj(qj(e),t)),Xj=e=>(...t)=>{let n=t[t.length-1],r=t.slice(0,-1),i=r.length===1?t=>t!=null&&t[e]===r[0]:t=>t!=null&&r.includes(t[e]);return e=>e.add(Kj(i,n))},Zj=e=>t=>{let n=Kj(n=>n!=null&&Object.hasOwn(t,n[e]),n=>t[n[e]](n));return e=>e.add(n)},Qj=e=>t=>{let n=Zj(e)(t);return e=>iM(n(e))},$j=Xj(`_tag`),eM=Qj(`_tag`),tM=e=>t=>{let n=nM(t);return Br(n)?n._tag===`Success`?n.success:e(n.failure):(...t)=>{let r=n(...t);return Vr(r)?r.success:e(r.failure,...t)}},nM=e=>{if(e._tag===`ValueMatcher`)return e.value;let t=e.cases.length;if(t===1){let t=e.cases[0];return(...n)=>{let r=e.select(...n);return t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1?Lr(t.evaluate(r,...n)):Rr(r)}}return(...n)=>{let r=e.select(...n);for(let i=0;i<t;i++){let t=e.cases[i];if(t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1)return Lr(t.evaluate(r,...n))}return Rr(r)}},rM=`effect/match/Match/exhaustive: absurd`,iM=e=>{let t=nM(e);if(Br(t)){if(Vr(t))return t.success;throw Error(rM)}return(...e)=>{let n=t(...e);if(Vr(n))return n.success;throw Error(rM)}},aM=Jj,oM=Yj,sM=$j,cM=eM,lM=tM,uM={"~effect/Ref":{_A:i},...Jt,toJSON(){return{_id:`Ref`,ref:this.ref}}},dM=e=>{let t=Object.create(uM);return t.ref=Sv(e),t},fM=r(2,(e,t)=>B(()=>{let[n,r]=t(e.ref.current);return e.ref.current=r,n})),pM=r(2,(e,t)=>B(()=>e.ref.current=t(e.ref.current))),mM=`~effect/http/HttpBody`,hM=`~effect/http/HttpBody/HttpBodyError`,gM=class extends Bo(`HttpBodyError`){[hM]=hM},_M=class{[mM];constructor(){this[mM]=mM}[kt](){return this.toJSON()}toString(){return x(this,{ignoreToString:!0})}},vM=new class extends _M{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},yM=class extends _M{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=CM(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},bM=(e,t)=>new yM(e,t??`application/octet-stream`,e.length),xM=new TextEncoder,SM=globalThis.Buffer,CM=SM===void 0?e=>xM.encode(e):e=>SM.from(e,`utf8`),wM=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),SM!==void 0)return new yM(void 0,t??`text/plain`,SM.byteLength(e,`utf8`),e);let n=xM.encode(e);return new yM(n,t??`text/plain`,n.length,e)},TM=(e,t)=>wg({try:()=>wM(JSON.stringify(e),t??`application/json`),catch:e=>new gM({reason:{_tag:`JsonError`},cause:e})}),EM=(e,t)=>{let n=JO(vj(e));return(e,r)=>n(e,t).pipe(zg(e=>new gM({reason:{_tag:`SchemaError`,issue:e},cause:e})),U(e=>TM(e,r)))},DM=class extends _M{_tag=`Stream`;stream;contentType;contentLength;constructor(e,t,n){super(),this.stream=e,this.contentType=t,this.contentLength=n}toJSON(){return{_id:`effect/HttpBody`,_tag:`Stream`,contentType:this.contentType,contentLength:this.contentLength}}},OM=(e,t,n)=>new DM(e,t??`application/octet-stream`,n),kM=`~effect/http/HttpClientError`,AM=e=>v(e,kM),jM=class extends Bo(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[kM]=kM;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},MM=e=>e.endsWith(`Error`)?e.slice(0,-5):e,NM=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,PM=e=>`${e.method} ${lw(e.url)}`,FM=(e,t)=>({...t,request:{_id:`HttpClientRequest`,method:e.request.method,url:lw(e.request.url)},...`response`in e?{response:{_id:`HttpClientResponse`,status:e.response.status}}:void 0}),IM=class extends Bo(`TransportError`){get methodAndUrl(){return PM(this.request)}get message(){return NM(MM(this._tag),this.description,this.methodAndUrl)}toJSON(){return FM(this,super.toJSON())}},LM=class extends Bo(`EncodeError`){get methodAndUrl(){return PM(this.request)}get message(){return NM(MM(this._tag),this.description,this.methodAndUrl)}toJSON(){return FM(this,super.toJSON())}},RM=class extends Bo(`InvalidUrlError`){get methodAndUrl(){return PM(this.request)}get message(){return NM(MM(this._tag),this.description,this.methodAndUrl)}toJSON(){return FM(this,super.toJSON())}},zM=class extends Bo(`StatusCodeError`){get methodAndUrl(){return PM(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return NM(MM(this._tag),this.description,e)}toJSON(){return FM(this,super.toJSON())}},BM=class extends Bo(`DecodeError`){get methodAndUrl(){return PM(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return NM(MM(this._tag),this.description,e)}toJSON(){return FM(this,super.toJSON())}},VM=class extends Bo(`EmptyBodyError`){get methodAndUrl(){return PM(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return NM(MM(this._tag),this.description,e)}toJSON(){return FM(this,super.toJSON())}},HM=class e extends gj(kM)({_tag:jA(`HttpError`),kind:wA([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:tA(ZA())}){static fromHttpClientError(t){return new e({_tag:`HttpError`,kind:t.reason._tag,cause:t.reason})}},UM=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],WM=e=>t=>t.pipeThrough(new CompressionStream(e)),GM=e=>new ReadableStream({start(t){t.enqueue(e),t.close()}}),KM=(e,t,n)=>e._tag!==`Uint8Array`&&e._tag!==`Stream`||e.contentLength!==void 0&&e.contentLength<(n?.minSize??1024)?R(e):e._tag===`Uint8Array`?W(hg(()=>new globalThis.Response(WM(t)(GM(e.body))).arrayBuffer()),t=>bM(new Uint8Array(t),e.contentType)):R(OM(Ox({evaluate:()=>WM(t)(Zx(e.stream)),onError:i}),e.contentType)),qM=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?MC(MC(e,`content-type`),`content-length`):(e=t.contentType===void 0?MC(e,`content-type`):kC(e,`content-type`,t.contentType),JM(e,t)),JM=(e,t)=>{let n=t._tag===`Empty`||t._tag===`FormData`?void 0:t.contentLength;return n===void 0?MC(e,`content-length`):kC(e,`content-length`,n.toString())},YM=class extends Bo(`UrlError`){},XM=(e,t,n)=>zr({try:()=>{let r=new URL(e,ZM());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,qC(i))}return n!==void 0&&(r.hash=n),r},catch:e=>new YM({cause:e})}),ZM=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0){let e=location.origin+location.pathname;try{return new URL(e).href}catch{return}}},QM=(e,t)=>zr({try:()=>new URL(e,t),catch:()=>new Gf(`Invalid URL: "${e}"${t===void 0?``:` with base "${t}"`}`)}),$M=`~effect/http/HttpClientRequest`,eN=e=>v(e,$M),tN={[$M]:$M,...Mt,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:lw(this.url),urlParams:this.urlParams,hash:this.hash,headers:mt(this.headers),body:this.body.toJSON()}},pipe(){return e(this,arguments)}};function nN(e,t,n,r,i,a){let o=Object.create(tN);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var rN=nN(`GET`,``,aw,T(),EC,vM),iN=e=>(t,n)=>oN(rN,{method:e,url:t,...n??void 0}),aN=iN(`POST`),oN=r(2,(e,t)=>{let n=e;return t.method&&(n=sN(n,t.method)),t.url&&(n=fN(n,t.url)),t.headers&&(n=lN(n,t.headers)),t.urlParams&&(n=pN(n,t.urlParams)),t.hash&&(n=mN(n,t.hash)),t.body&&(n=hN(n,t.body)),t.accept&&(n=uN(n,t.accept)),t.acceptJson&&(n=dN(n)),n}),sN=r(2,(e,t)=>nN(t,e.url,e.urlParams,e.hash,e.headers,e.body)),cN=r(3,(e,t,n)=>nN(e.method,e.url,e.urlParams,e.hash,kC(e.headers,t,n),e.body)),lN=r(2,(e,t)=>nN(e.method,e.url,e.urlParams,e.hash,AC(e.headers,t),e.body)),uN=r(2,(e,t)=>cN(e,`Accept`,t)),dN=uN(`application/json`),fN=r(2,(e,t)=>{if(typeof t==`string`)return nN(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=ew(n.searchParams),i=wr(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,nN(e.method,n.toString(),r,i,e.headers,e.body)}),pN=r(2,(e,t)=>nN(e.method,e.url,ow(e.urlParams,t),e.hash,e.headers,e.body)),mN=r(2,(e,t)=>nN(e.method,e.url,e.urlParams,E(t),e.headers,e.body)),hN=r(2,(e,t)=>nN(e.method,e.url,e.urlParams,e.hash,qM(e.headers,t),t)),gN=r(e=>eN(e[0]),(e,t,n)=>e.headers[`content-encoding`]===void 0?W(KM(e.body,t,n),n=>n===e.body?e:nN(e.method,e.url,e.urlParams,e.hash,kC(JM(e.headers,n),`content-encoding`,t),n)):R(e)),_N=(e,t)=>{let n=EM(e,t);return r(2,(e,t)=>W(n(t),t=>hN(e,t)))};function vN(e){let t=XM(e.url,e.urlParams,Dr(e.hash));return Vr(t)?E(t.success):T()}var yN=`~effect/http/HttpIncomingMessage`,bN=(e,t)=>{let n=Gk(vj(e)),r=t?.reviver===void 0?void 0:Gk($A(vj(e),t));return e=>r===void 0?U(e.json,e=>n(e,t)):U(e.text,i=>i===``?U(e.json,e=>n(e,t)):r(i,t))},xN=(e,t)=>({...t,headers:mt(e.headers),remoteAddress:e.remoteAddress}),SN=`~effect/http/HttpClientResponse/WebSource`,CN=e=>e[SN]?.(),wN=`~effect/http/HttpClientResponse`,TN=(e,t)=>new DN(e,t),EN=e=>e.status>=200&&e.status<300?R(e):H(new jM({reason:new zM({response:e,request:e.request,description:`non 2xx status code`})})),DN=class extends Nt{[yN];[wN];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[yN]=yN,this[wN]=wN}toJSON(){return xN(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=vN(this.request);return yr(e)?``:(e.value.hash=``,e.value.href)}get headers(){return DC(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=cC(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return T()}[SN](){return this.source}get stream(){return this.source.body?Ox({evaluate:()=>this.source.body,onError:e=>new jM({reason:new BM({request:this.request,response:this,cause:e})})}):Cx(new jM({reason:new VM({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return U(this.text,e=>wg({try:()=>e===``?null:JSON.parse(e),catch:e=>new jM({reason:new BM({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=W(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return U(this.arrayBuffer,e=>wg({try:()=>ew(YC(e)),catch:e=>new jM({reason:new BM({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=gg({try:()=>this.source.formData(),catch:e=>new jM({reason:new BM({request:this.request,response:this,cause:e})})}).pipe(v_,V_)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=gg({try:()=>this.source.arrayBuffer(),catch:e=>new jM({reason:new BM({request:this.request,response:this,cause:e})})}).pipe(v_,V_),this.arrayBufferBody}get upgrade(){return H(new jM({reason:new zM({request:this.request,response:this,description:`fetch cannot hand over the connection of an HTTP upgrade`})}))}pipe(){return e(this,arguments)}},ON=e=>OC({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${xr(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId.padStart(32,`0`)}-${e.spanId}-${e.sampled?`01`:`00`}`}),kN={"http:":80,"https:":443,"ws:":80,"wss:":443},AN=(e,t,n)=>{let r=lw(t.search,n).slice(1);if(e.attribute(`url.full`,lw(t.href,n)),e.attribute(`url.path`,t.pathname),r!==``&&e.attribute(`url.query`,r),e.attribute(`url.scheme`,t.protocol.slice(0,-1)),t.hostname!==``){e.attribute(`server.address`,t.hostname.startsWith(`[`)?t.hostname.slice(1,-1):t.hostname);let n=t.port===``?kN[t.protocol]:Number(t.port);n!==void 0&&e.attribute(`server.port`,n)}},jN=(e,t)=>{let n=e.params.filter(([,e])=>typeof e!=`string`).map(([e])=>e);return n.length===0?t:[...t,...new URLSearchParams(n.map(e=>[e,``])).keys()]},MN=(e,t,n,r,i)=>{for(let a in n)r(a,t)&&e.attribute(`http.${t}.header.${a}`,PC(a,i)?`<redacted>`:n[a])},NN=`~effect/http/HttpClient`,PN=Ki(`effect/HttpClient`),FN=(e=>(...t)=>U(PN,n=>n[e](...t)))(`get`),IN=r(2,(e,t)=>RN(n=>t(e.postprocess(n)),e.preprocess)),LN=IN(U(EN)),RN=(e,t)=>{let n=Object.create(zN);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},zN={[NN]:NN,pipe(){return e(this,arguments)},...Mt,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(UM.map(([e,t])=>[t,function(t,n){return this.execute(iN(e)(t,n))}]))},BN=e=>RN(t=>U(t,t=>Eg(n=>{let r=QN.get(t),i=r??new AbortController,a=XM(t.url,t.urlParams,Dr(t.hash));if(D(a))return H(new jM({reason:new RM({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(Zo)||n.getRef(KN)(t)){let a=e(t,o,i.signal,n);return r?W(a,e=>eP(e,i,!0)):C_(e=>t_(e(a),{onSuccess(e){return R(eP(e,i,!1))},onFailure(e){return Lf(e)&&i.abort(),xg(e)}}))}return O_(n.getRef(YN)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method);let s=n.getRef(FC);AN(a,o,jN(t.urlParams,n.getRef(_w)));let c=n.getRef(qN);return MN(a,`request`,t.headers,c,s),t=n.getRef(JN)?lN(t,ON(a)):t,C_(l=>l(e(t,o,i.signal,n)).pipe(A_(a,{captureStackTrace:!1}),t_({onSuccess:e=>(a.attribute(`http.response.status_code`,e.status),MN(a,`response`,e.headers,c,s),e.status>=400&&e.status<600&&(a.attribute(`error.type`,String(e.status)),VN(n,a,t,e)),R(eP(e,i,r!==void 0))),onFailure(e){return!r&&Lf(e)&&i.abort(),xg(e)}})))})})),R),VN=(e,t,n,r)=>{let i=Ft();It(0);let a;try{a=$f(new jM({reason:new zM({request:n,response:r})}))}finally{It(i)}t.end(e.getRef(Sp)?e.getRef(qf).currentTimeNanosUnsafe():BigInt(0),a)},HN=r(2,(e,t)=>{let n=Nh(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,a=aP(n?t:t.schedule??qh),o=n?void 0:t.times;return IN(e,d(r===`errors-only`?i:T_({schedule:a,times:o,while:oP}),r===`response-only`?i:Ug({while:n||t.while===void 0?nP:be(nP,t.while),schedule:a,times:o})))}),UN=(e,t)=>{if(t===void 0)return;let n=GC(t);return Vr(n)?bo(KC(n.success,e),lo(1)):void 0},WN=r(2,(e,t)=>IN(e,Ag(t))),GN=r(2,(e,t)=>IN(e,Vg(t))),KN=k(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>s}),qN=k(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>s}),JN=k(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:o}),YN=k(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>e.method}),XN=e=>Xp(PN)(r_(t=>W(e,e=>IN(e,s_(e=>xa(t,e)))))),ZN=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{try{e.abort()}catch{}});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new WeakMap;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),QN=new WeakMap,$N=new WeakMap,eP=(e,t,n)=>(n||(ZN.register(e,t),e=new tP(e,t)),$N.set(e,t),e),tP=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[wN]=wN;[yN]=yN;applyInterrupt(e){return z(()=>(ZN.unregister(this.original),x_(e,()=>B(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get upgrade(){return this.applyInterrupt(this.original.upgrade)}[SN](){let e=CN(this.original);return e!==void 0&&ZN.unregister(this.original),e}get stream(){return xx(()=>(ZN.unregister(this.original),Wx(this.original.stream,B(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[kt](){return this.original[kt]()}pipe(){return e(this,arguments)}},nP=e=>Wf(e)||rP(e),rP=e=>AM(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&oP(e.reason.response)),iP=(e,t)=>UN(t,(AM(e)?e.response:v(e,`~effect/http/HttpClientResponse`)?e:void 0)?.headers[`retry-after`]),aP=e=>Ph(W(Lh(e),e=>(t,n)=>{let r=iP(n,t);return r===void 0?e(t,n):W(e(t,n),([e,t])=>[e,bo(t,r)])})),oP=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,sP=k(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),cP=k(`effect/http/FetchHttpClient/StreamBodyFallback`,{defaultValue:()=>`error`}),lP=class extends Ki()(`effect/http/FetchHttpClient/RequestInit`){},uP,dP=()=>{try{let e=!1,t=new ReadableStream,n=new Request(`https://example.com`,{method:`POST`,body:t,get duplex(){return e=!0,`half`}});return(e||n.body===t)&&!n.headers.has(`Content-Type`)}catch{return!1}},fP=XN(R(BN((e,t,n,r)=>{if(e.headers.upgrade!==void 0)return H(new jM({reason:new IM({request:e,description:`fetch cannot send an HTTP upgrade request`})}));let i=r.getRef(sP),a=ma(r.context,lP)??{},o=a.headers?jC(DC(a.headers),e.headers):e.headers;o[`content-length`]&&(o=MC(o,`content-length`));let s,c=B(()=>s?.abort()),l=r=>W(gg({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:s?AbortSignal.any([n,s.signal]):n}),catch:t=>new jM({reason:new IM({request:e,cause:t})})}),t=>{let n=TN(e,t);return s?(t.body===null&&s.abort(),Object.create(n,{...Object.fromEntries([`arrayBuffer`,`text`,`json`,`formData`,`urlParamsBody`].map(e=>[e,{get:()=>m_(n[e],c)}])),stream:{get:()=>Wx(n.stream,c)}})):n}).pipe(h_(()=>c));switch(e.body._tag){case`Raw`:case`Uint8Array`:return l(e.body.body);case`FormData`:return l(e.body.formData);case`Stream`:if(uP??=dP(),uP){s=new AbortController;let t=AbortSignal.any([n,s.signal]),r=vg(e=>{let n=()=>e(y_);if(t.aborted)n();else return t.addEventListener(`abort`,n,{once:!0}),B(()=>t.removeEventListener(`abort`,n))});return U(Qx(Vx(e.body.stream,r)),l)}return r.getRef(cP)===`error`?H(new jM({reason:new LM({request:e,description:`Streaming request bodies are not supported in this runtime`})})):Yx(e.body.stream).pipe(zg(t=>new jM({reason:new LM({request:e,cause:t})})),U(l))}return l(void 0)}))),pP=`~effect/FiberSet`,mP=e=>v(e,pP),hP={[pP]:pP,[Symbol.iterator](){return this.state._tag===`Closed`?Zr():this.state.backing[Symbol.iterator]()},...Jt,toJSON(){return{_id:`FiberSet`,state:this.state}}},gP=(e,t)=>{let n=Object.create(hP);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},_P=()=>f_(B(()=>gP(new Set,cp())),e=>z(()=>{let t=e.state;if(t._tag===`Closed`)return V;e.state={_tag:`Closed`};let n=t.backing;return av(n).pipe(yp(e.deferred))})),vP=-1,yP=To(Do(zf,Eo(vP))),bP=r(e=>mP(e[0]),(e,t,n)=>{e.state._tag===`Closed`?t.interruptUnsafe(vP):e.state.backing.has(t)||(e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),ip(r)&&(n?.propagateInterruption===!0?!yP(r.cause):!Mf(r.cause))&&vp(e.deferred,r))}))}),xP=function(){let e;return()=>(e===void 0&&(e=F_(y_)),e)}(),SP=function(){let e=arguments[0];if(!dg(arguments[1])){let t=arguments[1];return n=>CP(e,n,t)}return CP(e,arguments[1],arguments[2])},CP=(e,t,n)=>Eg(r=>{if(e.state._tag===`Closed`)return B(xP);let i=id(r,t,n?.startImmediately??!0,!0);return bP(e,i,n),R(i)}),wP=e=>()=>W(n_(),t=>{let n=I_(t);return(t,r)=>{if(e.state._tag===`Closed`)return xP();let i=n(t,r);return bP(e,i,r),i}}),TP=e=>mg({while:()=>e.state._tag===`Open`&&e.state.backing.size>0,body:()=>tv(qr(e)),step:l}),EP=`4.1.2`,DP=()=>EP,OP=e=>{let t=e===void 0?void 0:GC(e);return t===void 0||D(t)?R(uo(5)):W(qf,e=>KC(t.success,e.currentTimeMillisUnsafe()))},kP=qh.pipe(Wh,zh(({output:e})=>AM(e)&&e.reason._tag===`StatusCodeError`&&e.reason.response.status===429?OP(e.reason.response.headers[`retry-after`]):R(uo(1)))),AP=class extends Ki()(`effect/observability/OtlpExporter/Flusher`){},jP=Jp(AP,()=>{let e=new Set;return{flush:z(()=>e.size===0?V:pg(e,i,{concurrency:`unbounded`,discard:!0})),register:t=>U(Cp,n=>(e.add(t),Dp(n,B(()=>e.delete(t)))))}}),MP=W_(function*(e){let t=yield*n_(),n=O(t,qf),r=O(t,Cp),i=bo(Ga(e.exportInterval),ao),a=O(t,PN).pipe(WN(e=>Gg(e.arrayBuffer)),GN(e=>e.response?Gg(e.response.arrayBuffer):V),LN,IN(c_(JN,!1)),HN({schedule:kP,times:3})),o=`OTel-OTLP-Exporter-JavaScript-Effect-${e.label}/${DP()}`,s=DC(e.headers),c=s[`user-agent`],l=kC(s,`user-agent`,c?`${c} ${o}`:o),u=aN(e.url,{headers:l}),d=e.maxBatchSize===`disabled`&&e.exportEmpty===!0,f=[],p,m=()=>p===void 0?!1:n.currentTimeMillisUnsafe()<p||(p=void 0,!1),h=z(()=>{if(m()||f.length===0&&!d)return V;let t=f;f=[];let[n,r]=e.body(t),i=hN(u,n);return(e.compression===`gzip`?gN(i,`gzip`).pipe(U(a.execute)):a.execute(i)).pipe(kg(r),Pg,E_(!1))}).pipe(Ig(e=>p===void 0?(p=n.currentTimeMillisUnsafe()+6e4,f=[],q_(`Disabling exporter for 60 seconds`,e)):V),J_({package:`@effect/opentelemetry`,module:e.label})),g=yield*_P(),ee=yield*wP(g)();yield*Dp(r,z(()=>p===void 0?(ee(h),TP(g)):V).pipe(Gg,b_,Jg(e.shutdownTimeout)));let _=yield*yv(d),te=yield*yv(),ne=B(()=>{d||f.length>0||!_.closeUnsafe()||te.openUnsafe()});yield*bg(function*(){for(;;)te.closeUnsafe(),yield*_.await,yield*Qg(Zg(i),te.await),yield*tv(yield*SP(g,h)),yield*ne}).pipe(M_(r));let re=kg(h,ne);return yield*(yield*AP).register(re),{push(t){m()||(f.push(t),e.maxBatchSize!==`disabled`&&f.length>=e.maxBatchSize?ee(re):_.openUnsafe())}}}),NP=sf,PP=uf,FP=(e,t)=>Xp(NP,w(Ec(function*(n){let r=new Set(t?.mergeWithExisting===!0?n.getRef(sf):[]);for(let t of e)r.add(Xt(t)?yield*t:t);return r}))),IP=`window`in globalThis||`importScripts`in globalThis,LP=e=>({attributes:zP(Object.entries({"telemetry.sdk.name":`effect`,"telemetry.sdk.language":IP?`webjs`:`nodejs`,"telemetry.sdk.version":DP(),...e.attributes,...e.serviceName?{"service.name":e.serviceName}:void 0,...e.serviceVersion?{"service.version":e.serviceVersion}:void 0})),droppedAttributesCount:0}),RP=W_(function*(e){let t=yield*Uj(ej,ej,`OTEL_RESOURCE_ATTRIBUTES`,{trim:!0,keepEmptyValues:!0}).pipe(Oj(void 0)),n=e?.serviceName??e?.attributes?.[`service.name`]??(yield*zj(EA(lA),`OTEL_SERVICE_NAME`))??t?.[`service.name`]??(yield*Vj(`OTEL_SERVICE_NAME`)),r=e?.serviceVersion??e?.attributes?.[`service.version`]??(yield*zj(EA(lA),`OTEL_SERVICE_VERSION`))??t?.[`service.version`],i={...t,...e?.attributes};return delete i[`service.name`],delete i[`service.version`],LP({serviceName:n,serviceVersion:r,attributes:i})},Bg),zP=e=>{let t=[];for(let[n,r]of e)t.push({key:n,value:VP(r)});return t},BP=2**63,VP=e=>{if(Array.isArray(e))return{arrayValue:{values:e.map(VP)}};switch(typeof e){case`string`:return{stringValue:e};case`bigint`:return BigInt.asIntN(64,e)===e?{intValue:String(e)}:{stringValue:String(e)};case`number`:return Number.isInteger(e)&&e>=-BP&&e<BP?{intValue:Number.isSafeInteger(e)?e:String(BigInt(e))}:{doubleValue:e};case`boolean`:return{boolValue:e};default:return{stringValue:x(e)}}},HP=class extends Ki()(`effect/observability/OtlpSerialization`){};function UP(e,t){return typeof t==`number`&&!Number.isFinite(t)?String(t):e===`bytesValue`&&this[e]instanceof Uint8Array?PS(this[e]):t}var WP=e=>{let t=JSON.stringify(e);return wM(t.includes(`null`)||t.includes(`"bytesValue":`)?JSON.stringify(e,UP):t,`application/json`)},GP=Gp(HP,{traces:e=>WP(e),metrics:e=>WP(e),logs:e=>WP(e)}),KP=W_(function*(e){let t=yield*HP,n=yield*RP(e.resource),r={name:`effect`,version:DP()},i=yield*MP({label:`OtlpLogger`,url:e.url,headers:e.headers,compression:e.compression,maxBatchSize:e.maxBatchSize??1e3,exportInterval:e.exportInterval??uo(1),body:e=>[t.logs({resourceLogs:[{resource:n,scopeLogs:[{scope:r,logRecords:e}]}]}),V],shutdownTimeout:e.shutdownTimeout??uo(3)}),a={excludeLogSpans:e.excludeLogSpans??!1,clock:yield*qf};return PP(e=>{i.push(YP(e,a))})}),qP=e=>FP([KP(e)],{mergeWithExisting:e.mergeWithExisting??!0}).pipe(om(jP)),JP=BigInt(1e6),YP=(e,t)=>{let n=t.clock.currentTimeNanosUnsafe().toString(),r=e.date.getTime(),i=(BigInt(r)*JP).toString(),a={...e.fiber.getRef(bp)};if(a[`effect.fiberId`]=e.fiber.id,!t.excludeLogSpans)for(let[t,n]of e.fiber.getRef(xp))a[`effect.log_span.${t}`]=r-n;let o=Bf(e.cause,{includeCauseInStack:!0});o.length>0&&(a[`exception.type`]=o[0].name,a[`exception.message`]=o[0].message,a[`exception.stacktrace`]=o.map(e=>e.stack).join(`
15
- `));let s=di(e.message),c={severityNumber:XP(e.logLevel),severityText:e.logLevel,timeUnixNano:i,observedTimeUnixNano:n,attributes:zP(Object.entries(a)),body:VP(s.length===1?s[0]:s),droppedAttributesCount:0};return e.fiber.cache.span&&(c.traceId=e.fiber.cache.span.traceId.padStart(32,`0`),c.spanId=e.fiber.cache.span.spanId),c},XP=e=>{switch(e){case`Trace`:return ZP.SEVERITY_NUMBER_TRACE;case`Debug`:return ZP.SEVERITY_NUMBER_DEBUG;case`Info`:return ZP.SEVERITY_NUMBER_INFO;case`Warn`:return ZP.SEVERITY_NUMBER_WARN;case`Error`:return ZP.SEVERITY_NUMBER_ERROR;case`Fatal`:return ZP.SEVERITY_NUMBER_FATAL;default:return ZP.SEVERITY_NUMBER_UNSPECIFIED}},ZP={SEVERITY_NUMBER_UNSPECIFIED:0,SEVERITY_NUMBER_TRACE:1,SEVERITY_NUMBER_TRACE2:2,SEVERITY_NUMBER_TRACE3:3,SEVERITY_NUMBER_TRACE4:4,SEVERITY_NUMBER_DEBUG:5,SEVERITY_NUMBER_DEBUG2:6,SEVERITY_NUMBER_DEBUG3:7,SEVERITY_NUMBER_DEBUG4:8,SEVERITY_NUMBER_INFO:9,SEVERITY_NUMBER_INFO2:10,SEVERITY_NUMBER_INFO3:11,SEVERITY_NUMBER_INFO4:12,SEVERITY_NUMBER_WARN:13,SEVERITY_NUMBER_WARN2:14,SEVERITY_NUMBER_WARN3:15,SEVERITY_NUMBER_WARN4:16,SEVERITY_NUMBER_ERROR:17,SEVERITY_NUMBER_ERROR2:18,SEVERITY_NUMBER_ERROR3:19,SEVERITY_NUMBER_ERROR4:20,SEVERITY_NUMBER_FATAL:21,SEVERITY_NUMBER_FATAL2:22,SEVERITY_NUMBER_FATAL3:23,SEVERITY_NUMBER_FATAL4:24},QP=d(W_(function*(e){let t=yield*RP(e.resource),n=yield*HP,r={name:`effect`,version:DP()},i=yield*MP({label:`OtlpTracer`,url:e.url,headers:e.headers,compression:e.compression,exportInterval:e.exportInterval??uo(5),maxBatchSize:e.maxBatchSize??1e3,body(e){let i={resourceSpans:[{resource:t,scopeSpans:[{scope:r,spans:e}]}]};return[n.traces(i),V]},shutdownTimeout:e.shutdownTimeout??uo(3)});function a(e){e.sampled&&i.push(eF(e))}return Xo({span(e){return new $P(e,a)},context:e.context?function(t,n){return n.cache.span===void 0?t[`~effect/Effect/evaluate`](n):e.context(t,n.cache.span)}:void 0})}),Xp(ts),om(jP)),$P=class{_tag=`Span`;name;parent;annotations;links;kind;sampled;export;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e,t){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.kind=e.kind,this.sampled=e.sampled,this.export=t,this.status={_tag:`Started`,startTime:e.startTime}}get traceId(){return this._traceId??=br(this.parent)?this.parent.value.traceId:Uo(32)}get spanId(){return this._spanId??=Uo(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){this.status._tag!==`Ended`&&(this.status={_tag:`Ended`,startTime:this.status.startTime,endTime:e,exit:t},this.export(this))}attribute(e,t){this.status._tag!==`Ended`&&this.attributes.set(e,t)}event(e,t,n){this.status._tag!==`Ended`&&this.events.push([e,t,n])}addLinks(e){this.status._tag!==`Ended`&&this.links.push(...e)}},eF=e=>{let t=e.status,n=e._attributes===void 0?[]:zP(e._attributes),r=[];if(e._events!==void 0)for(let t=0;t<e._events.length;t++){let[n,i,a]=e._events[t];r.push({name:n,timeUnixNano:String(i),attributes:a?zP(Object.entries(a)):[],droppedAttributesCount:0})}let i;if(t.exit._tag===`Success`)i={code:tF.Ok};else if(Mf(t.exit.cause))i={code:tF.Unset},n.push({key:`effect.fiber.interrupted`,value:{boolValue:!0}});else{let e=Bf(t.exit.cause,{includeCauseInStack:!0});i=e.length>0?{code:tF.Error,message:e[0].message}:{code:tF.Ok};for(let n of e)r.push({name:`exception`,timeUnixNano:String(t.endTime),droppedAttributesCount:0,attributes:[{key:`exception.type`,value:{stringValue:n.name}},{key:`exception.message`,value:{stringValue:n.message}},{key:`exception.stacktrace`,value:{stringValue:n.stack??`No stack trace available`}}]})}let a=[];for(let t=0;t<e.links.length;t++){let n=e.links[t];a.push({traceId:n.span.traceId.padStart(32,`0`),spanId:n.span.spanId,attributes:zP(Object.entries(n.attributes)),droppedAttributesCount:0})}return{traceId:e.traceId.padStart(32,`0`),spanId:e.spanId,parentSpanId:br(e.parent)?e.parent.value.spanId:void 0,name:e.name,kind:nF[e.kind],startTimeUnixNano:String(t.startTime),endTimeUnixNano:String(t.endTime),attributes:n,droppedAttributesCount:0,events:r,droppedEventsCount:0,status:i,links:a,droppedLinksCount:0}},tF={Unset:0,Ok:1,Error:2},nF={unspecified:0,internal:1,server:2,client:3,producer:4,consumer:5},rF=`~effect/reactivity/AsyncResult`,iF=e=>v(e,rF),aF={[rF]:{E:i,A:i},pipe(){return e(this,arguments)},[Be](e){if(!iF(e)||this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case`Initial`:return!0;case`Success`:return Ve(this.value,e.value);case`Failure`:return Ve(this.cause,e.cause)}},[xe](){let e=ke(`${this._tag}:${this.waiting}`);return this._tag===`Initial`?e:we(e)(this._tag===`Success`?y(this.value):y(this.cause))}},oF=e=>e.waiting,sF=e=>e._tag===`Success`?mF(e.value):gF(e.cause),cF=(e,t)=>e._tag===`Success`?mF(e.value):_F(e.cause,{previous:t}),lF=e=>e._tag===`None`?fF(!0):yF(e.value),uF=e=>e._tag===`Initial`,dF=e=>e._tag!==`Initial`,fF=(e=!1)=>{let t=Object.create(aF);return t._tag=`Initial`,t.waiting=e,t},pF=e=>e._tag===`Success`,mF=(e,t)=>{let n=Object.create(aF);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},hF=e=>e._tag===`Failure`,gF=(e,t)=>{let n=Object.create(aF);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??T(),n.waiting=t?.waiting??!1,n},_F=(e,t)=>gF(e,{previousSuccess:jr(t.previous,e=>pF(e)?E(e):hF(e)?e.previousSuccess:T()),waiting:t.waiting}),vF=(e,t)=>_F(Ef(e),t),yF=r(e=>iF(e[0]),(e,t)=>{if(e.waiting)return t?.touch?bF(e):e;let n=Object.assign(Object.create(aF),e);return n.waiting=!0,t?.touch&&pF(n)&&(n.timestamp=Date.now()),n}),bF=e=>pF(e)?mF(e.value,{waiting:e.waiting}):e,xF=r(2,(e,t)=>e._tag===`Failure`?_F(e.cause,{previous:t,waiting:e.waiting}):e),SF=e=>e._tag===`Success`?E(e.value):e._tag===`Failure`?Ar(e.previousSuccess,e=>e.value):T(),CF=r(2,(e,t)=>Sr(SF(e),t)),wF=e=>kr(SF(e),()=>new Vf(`AsyncResult.getOrThrow: no value found`)),TF=e=>e._tag===`Failure`?If(e.cause):T(),EF=e=>{switch(e._tag){case`Success`:return Zf(e.value);case`Failure`:return Qf(e.cause);default:return $f(new Vf)}},DF=r(2,(e,t)=>{switch(e._tag){case`Initial`:return e;case`Failure`:return gF(e.cause,{previousSuccess:Ar(e.previousSuccess,e=>mF(t(e.value),e)),waiting:e.waiting});case`Success`:return mF(t(e.value),e)}}),OF=e=>{let t=ye(e),n=t?Array.from(e,(e,t)=>[t,e]):Object.entries(e),r=t?[]:{},i=!1;for(let e=0;e<n.length;e++){let[a,o]=n[e];if(!iF(o))b(r,a,o);else{if(hF(o))return gF(o.cause,{previousSuccess:kF(n,t),waiting:o.waiting});if(!pF(o))return o;b(r,a,o.value),o.waiting&&(i=!0)}}return mF(r,{waiting:i})},kF=(e,t)=>{let n=t?[]:{};for(let t=0;t<e.length;t++){let[r,i]=e[t];if(!iF(i)){b(n,r,i);continue}let a=SF(i);if(yr(a))return T();b(n,r,a.value)}return E(mF(n))},AF=e=>{let t=e.success??aA,n=e.error??aA,r=Fk()([t,ij(n,ZA())],([e,t])=>(n,r,i)=>{if(!iF(n))return H(new Lw(r,n,i));switch(n._tag){case`Initial`:return R(n);case`Success`:return Z_(KO(e)(n.value,i),{onSuccess:e=>mF(e,n),onFailure:e=>zw(r,`value`,e,n,i)});case`Failure`:{let a=n.previousSuccess.pipe(Ar(t=>Z_(KO(e)(t.value,i),{onSuccess:e=>E(mF(e,t)),onFailure:e=>new Iw(r,[new Nw([`previousSuccess`,`value`],e)],n,i)})),Sr(()=>_g)),o=X_(KO(t)(n.cause,i),e=>zw(r,`cause`,e,n,i));return Q_(a,e=>Y_(o,t=>gF(t,{previousSuccess:e,waiting:n.waiting})))}}},{expected:`AsyncResult`,toCodec([e,t]){let n=MA(`Success`,{value:e,waiting:dA,timestamp:VA});return IA()(CA([MA(`Initial`,{waiting:dA}),n,MA(`Failure`,{cause:t,previousSuccess:oj(n),waiting:dA})]),FT({decode:e=>{switch(e._tag){case`Initial`:return fF(e.waiting);case`Success`:return mF(e.value,{waiting:e.waiting,timestamp:e.timestamp});case`Failure`:return gF(e.cause,{previousSuccess:Ar(e.previousSuccess,e=>mF(e.value,e)),waiting:e.waiting})}},encode(e){switch(e._tag){case`Initial`:return{_tag:`Initial`,waiting:e.waiting};case`Success`:return{_tag:`Success`,value:e.value,waiting:e.waiting,timestamp:e.timestamp};case`Failure`:return{_tag:`Failure`,cause:e.cause,previousSuccess:e.previousSuccess,waiting:e.waiting}}}}))},toEquivalence:nt,toFormatter:([e,t])=>n=>{switch(n._tag){case`Success`:return`AsyncResult.Success(${e(n.value)}, ${n.waiting}, ${n.timestamp})`;case`Failure`:return`AsyncResult.Failure(${t(n.cause)}, ${n.waiting})`;case`Initial`:return`AsyncResult.Initial(${n.waiting}, ${n.waiting})`}}});return Object.assign(r,{success:t,error:n})},jF=`~effect/reactivity/Reactivity`,MF=Ki(`effect/reactivity/Reactivity`),NF=B(()=>{let e=new Map,t=t=>{let n=new Set;for(let r of t)e.get(r)?.forEach(e=>{n.has(e)||(n.add(e),e())})},n=e=>{let n=new Set;zF(e,e=>n.add(e)),t(n)},r=e=>r_(t=>{let r=ma(t,PF);return r?zF(e,e=>{r.add(e)}):n(e),V}),i=(e,t)=>Ag(t,r(e)),a=(t,n)=>{let r=[];return zF(t,t=>{r.push(t);let i=e.get(t);i===void 0&&(i=new Set,e.set(t,i)),i.add(n)}),()=>{for(let t=0;t<r.length;t++){let i=e.get(r[t]);i!==void 0&&(i.delete(n),i.size===0&&e.delete(r[t]))}}},o=(e,t)=>bg(function*(){let n=yield*n_(),r=O(n,Cp),i=yield*yy(),o=d(I_(n),sv(r)),s=!1,c=!1,l=!1,u=e=>{e._tag===`Failure`?(l=!0,c=!1,s=!1,p(),Ey(i,e.cause)):(Sy(i,e.value),c?(c=!1,o(t).addObserver(u)):s=!1)};function f(){l||(s?c=!0:(s=!0,o(t).addObserver(u)))}let p=a(e,f);return yield*Dp(r,B(p)),f(),i}),s=(e,t)=>o(e,t).pipe(W(Ex),Ax),c=e=>z(()=>{let n=new Set;return e.pipe(c_(PF,n),__(e=>B(()=>t(n))))});return MF.of({[jF]:jF,mutation:i,query:o,stream:s,invalidateUnsafe:n,invalidate:r,registerUnsafe:a,withBatch:c})}),PF=class extends Ki()(`effect/reactivity/Reactivity/PendingInvalidation`){},FF=r(2,(e,t)=>MF.use(n=>n.mutation(t,e))),IF=e=>MF.use(t=>t.invalidate(e)),LF=Xp(MF)(NF);function RF(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return y(e)}}var zF=(e,t)=>{if(Array.isArray(e))for(let n=0;n<e.length;n++)t(RF(e[n]));else for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${RF(r[e])}`)}},BF=`~effect/SubscriptionRef`,VF=e=>v(e,BF);({...Jt});var HF=e=>Dx(e.pubsub),UF=e=>B(()=>e.value),WF=(e,t)=>{e.value=t,qv(e.pubsub,t)},GF=r(2,(e,t)=>e.semaphore.withPermit(B(()=>WF(e,t)))),KF=(e,t)=>!iF(e)||!iF(t)?!0:uF(t)?uF(e):pF(e)&&pF(t)?t.timestamp>=e.timestamp:!0,qF=`~effect/reactivity/AtomRegistry`,JF=e=>v(e,qF),YF=e=>new iI(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),XF=Ki(qF),ZF=r(e=>JF(e[0]),(e,t,n)=>{let r=n?.suspendOnWaiting??!1;return vg(n=>{let i=e.get(t);if(i._tag!==`Initial`&&!(r&&i.waiting))return n(EF(i));let a=e.subscribe(t,e=>{e._tag!==`Initial`&&!(r&&e.waiting)&&(n(EF(e)),a())});return B(a)})}),QF={immediate:!0},$F=e=>{e()},eI={};function tI(e,t){let n=eI;for(let r of e)try{t(r)}catch(e){n===eI&&(n=e)}if(n!==eI)throw n}var nI=`~effect-atom/atom/Atom/Serializable`,rI=e=>nI in e?e[nI].key:e,iI=class{[qF];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(e,t,n,r){if(this[qF]=qF,this.scheduler=new Po(`sync`,t),this.schedulerAsync=new Po(`async`,t),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=r,this.timeoutResolution=n===void 0&&r!==void 0?Math.round(r/2):n??1e3,e!==void 0)for(let[t,n,r]of e){let e=t;for(;e.initialValueTarget;)e=e.initialValueTarget;this.ensureNode(e).setInitialValue(n,r?.skipInitialRun)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(e){return this.ensureNode(e).value()}set(e,t){e.write(this.ensureNode(e).writeContext,t)}setSerializable(e,t){this.preloadedSerializable.set(e,t)}modify(e,t){let n=this.ensureNode(e),r=t(n.value());return e.write(n.writeContext,r[1]),r[0]}update(e,t){let n=this.ensureNode(e);e.write(n.writeContext,t(n.value()))}refresh=e=>{e.refresh===void 0?this.invalidateAtom(e):e.refresh(this.refresh)};subscribe(e,t,n){let r=this.ensureNode(e);if(n?.immediate)t(r.value());else try{r.value()}catch(e){if((r.state&aI.waitingForValue)===0)throw e}let i=r.subscribe(function(){t(r._value)});return()=>{i(),r.canBeRemoved&&this.scheduleNodeRemoval(r)}}mount(e){return this.subscribe(e,l,QF)}atomHasTtl(e){return!e.keepAlive&&e.idleTTL!==0&&(e.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(e){let t=rI(e),n=this.nodes.get(t);if(n===void 0?(n=this.createNode(e),this.nodes.set(t,n),this.onNodeAdded?.(n)):this.atomHasTtl(e)&&this.removeNodeTimeout(n),typeof t==`string`&&this.preloadedSerializable.has(t)){let r=this.preloadedSerializable.get(t);this.preloadedSerializable.delete(t);let i=e[nI],a;try{a=i.decode(r)}catch(e){if(Rk(e))return n;throw e}let o=e;for(;o.initialValueTarget;)o=o.initialValueTarget;let s=o===e?n:this.ensureNode(o);KF(s._value,a)&&s.setInitialValue(a,i.skipInitialRun)}return n}createNode(e){if(this.disposed)throw Error(`Cannot access Atom ${e}: registry is disposed`);return e.keepAlive||this.scheduleAtomRemoval(e),new sI(this,e)}invalidateAtom=e=>{let t=this.ensureNode(e);t.skipInitialRun=!1,t.invalidate()};scheduleAtomRemoval(e){this.dispatcher.scheduleTask(()=>{let t=this.nodes.get(rI(e));t!==void 0&&t.canBeRemoved&&this.removeNode(t)},0)}scheduleNodeRemoval(e){this.dispatcher.scheduleTask(()=>{e.canBeRemoved&&this.removeNode(e)},0)}removeNode(e){this.atomHasTtl(e.atom)?this.setNodeTimeout(e):(this.nodes.delete(rI(e.atom)),e.remove(),this.onNodeRemoved?.(e))}setNodeTimeout(e){if(this.nodeTimeoutBucket.has(e))return;let t=e.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(t-=this.#e,t<=0)){this.nodes.delete(rI(e.atom)),e.remove(),this.onNodeRemoved?.(e);return}let n=Math.ceil(t/this.timeoutResolution)*this.timeoutResolution,r=Date.now()+n,i=r-r%this.timeoutResolution+this.timeoutResolution,a=this.timeoutBuckets.get(i);a===void 0&&(a=[new Set,setTimeout(()=>this.sweepBucket(i),i-Date.now())],this.timeoutBuckets.set(i,a)),a[0].add(e),this.nodeTimeoutBucket.set(e,i)}removeNodeTimeout(e){let t=this.nodeTimeoutBucket.get(e);if(t===void 0)return;this.nodeTimeoutBucket.delete(e),this.scheduleNodeRemoval(e);let[n,r]=this.timeoutBuckets.get(t);n.delete(e),n.size===0&&(clearTimeout(r),this.timeoutBuckets.delete(t))}#e=null;sweepBucket(e){let t=this.timeoutBuckets.get(e)[0];this.timeoutBuckets.delete(e),tI(t,this.removeIdleNode)}removeIdleNode=e=>{if(this.nodeTimeoutBucket.delete(e),e.canBeRemoved){this.nodes.delete(rI(e.atom)),this.onNodeRemoved?.(e),this.#e=e.atom.idleTTL??this.defaultIdleTTL;try{e.remove()}finally{this.#e=null}}};reset(){this.timeoutBuckets.forEach(([,e])=>clearTimeout(e)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear();let e=Array.from(this.nodes.values());this.nodes.clear();for(let t of e)t.state=oI.removed;tI(e,this.destroyNode)}destroyNode=e=>{e.remove(),this.onNodeRemoved?.(e)};dispose(){this.disposed=!0,this.reset()}},aI={alive:1,initialized:2,waitingForValue:4},oI={uninitialized:aI.alive|aI.waitingForValue,stale:aI.alive|aI.initialized|aI.waitingForValue,valid:aI.alive|aI.initialized,removed:0},sI=class{constructor(e,t){this.registry=e,this.atom=t,this.writeContext=new dI(e,this)}registry;atom;state=oI.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;skipInitialRun=!1;keptParents;invalidatedDuringBuild=!1;failed=!1;parents=new Set;children=new Set;listeners=new Set;observedChildren=0;currentState(){switch(this.state){case oI.uninitialized:return`uninitialized`;case oI.stale:return`stale`;case oI.valid:return`valid`;default:return`removed`}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.size===0&&this.state!==0}get building(){return this.lifetime!==void 0&&this.lifetime.reads!==void 0}get isObserved(){return!this.atom.lazy||this.listeners.size>0||this.observedChildren>0}childObserved(e){let t=this.isObserved;this.observedChildren+=e,t!==this.isObserved&&this.observedChanged(e)}observedChanged(e){for(let t of this.parents)t.childObserved(e)}_value=void 0;value(){for(;(this.state&aI.waitingForValue)!==0;)this.build();return this._value}build(){let e=uI(this);try{this.disposeLifetime()}catch(t){e.failure=t}this.invalidatedDuringBuild=!1,this.lifetime=e;let t,n=!1;try{t=this.atom.read(e),n=!0}finally{let t=e.reads;e.reads=void 0,this.lifetime===e&&(this.dropUnread(t),n||this.fail())}if(this.lifetime===e&&(this.state&aI.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.skipInitialRun&&(this.keptParents=Array.from(this.parents,e=>[e,e.lifetime])),this.failed=!1,this.state=oI.valid):this.setValue(t)),e.failure!==eI)throw e.failure}fail(){this.failed=!0;try{this.invalidateChildren()}catch{}}readTracked(e,t){let n=this.registry.ensureNode(e);this.parents.has(n)||(this.parents.add(n),n.children.add(this),this.isObserved&&n.childObserved(1));try{return n.value()}catch(e){if(t.reads===void 0||n.state!==oI.valid)throw e;return t.failure===eI&&(t.failure=e),n._value}finally{t.reads!==void 0&&!t.disposed&&t.reads.add(n)}}dropUnread(e){if(e.size===this.parents.size)return;let t=this.isObserved;for(let n of this.parents)e.has(n)||(this.parents.delete(n),n.children.delete(this),t&&n.childObserved(-1),n.canBeRemoved&&this.registry.scheduleNodeRemoval(n))}valueOption(){return(this.state&aI.initialized)===0?T():E(this._value)}setInitialValue(e,t=!1){(this.state&aI.initialized)===0?(this.preserveInitialValueOnBuild=!0,this.skipInitialRun=t,this.state=oI.stale,this._value=e,this.listeners.size>0&&this.announce()):this.setValue(e)}setValue(e){let t=this.failed;this.failed=!1;let n=(this.state&aI.initialized)!==0;if(this.state=oI.valid,n&&this.atom.equals(this._value,e)){t&&this.invalidateChildren();return}this._value=e;let r=eI;try{(n||t)&&this.invalidateChildren()}catch(e){r=e}if(this.listeners.size>0)try{this.announce()}catch(e){r===eI&&(r=e)}if(r!==eI)throw r}announce(){pI.phase===fI.collect?pI.notify.add(this):this.notify()}invalidate(){if(this.state===oI.valid){this.state=oI.stale;try{this.disposeLifetime()}finally{this.propagate()}}else this.building&&pI.phase!==fI.collect?this.build():this.propagate()}propagate(){pI.phase===fI.collect?(this.building&&(this.invalidatedDuringBuild=!0),pI.stale.push(this)):this.isObserved?this.value():this.invalidateChildren()}invalidateChildren(){if(this.children.size===0)return;let e=eI;for(let t of Array.from(this.children))if(t.affectedBy(this))try{t.invalidate()}catch(t){e===eI&&(e=t)}if(e!==eI)throw e}affectedBy(e){if(this.state===oI.valid)return!0;let t=this.lifetime?.reads;return t===void 0?this.isObserved&&e.state===oI.valid:t.has(e)}notify(){pI.phase===fI.commit&&pI.notify.delete(this),tI(this.listeners,$F)}disposeLifetime(){let e=this.lifetime;e!==void 0&&(this.lifetime=void 0,e.dispose())}remove(){let e=this.isObserved;this.state=oI.removed,this.listeners.clear();try{this.disposeLifetime()}finally{let t=Array.from(this.parents);this.parents.clear(),tI(t,t=>{t.children.delete(this),e&&t.childObserved(-1),t.canBeRemoved&&this.registry.removeNode(t)})}}subscribe(e){let t=this.isObserved;return this.listeners.add(e),t||this.observedChanged(1),()=>{this.listeners.delete(e)&&!this.isObserved&&this.observedChanged(-1)}}},cI=e=>{let t=e,n=t.node;if(!n.skipInitialRun)return!1;let r=n.keptParents;return n.skipInitialRun=!1,n.keptParents=void 0,!t.isFn&&!uF(n._value)&&(r===void 0||r.every(([e,t])=>e.lifetime===t))},lI={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){return this.disposed?this.node.registry.get(e):this.node.readTracked(e,this)},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let n=this.get(e);if(t?.suspendOnWaiting&&n.waiting)return yg;switch(n._tag){case`Initial`:return yg;case`Failure`:return Qf(n.cause);case`Success`:return R(n.value)}},resultOnce(e,t){return vg(n=>{let r=this.once(e);if(r._tag!==`Initial`&&!(t?.suspendOnWaiting&&r.waiting))return n(EF(r));let i=this.node.registry.subscribe(e,e=>{e._tag===`Initial`||t?.suspendOnWaiting&&e.waiting||(i(),n(EF(e)))},{immediate:!1});return B(i)})},setResult(e,t){return this.disposed?yg:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag===`None`?yg:R(t.value)},someOnce(e){return vg(t=>{let n=this.once(e);if(br(n))return t(R(n.value));let r=this.node.registry.subscribe(e,e=>{yr(e)||(r(),t(R(e.value)))},{immediate:!1});return B(r)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?T():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,n){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,n))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?vx:_x(n=>B(()=>{this.subscribe(e,e=>Sy(n,e),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(Lx(dF),Mx(e=>e._tag===`Success`?R(e.value):xg(e.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0,tI(e.reverse(),$F)}},uI=e=>{function t(n){return t.disposed||t.isFn?e.registry.get(n):e.readTracked(n,t)}return Object.setPrototypeOf(t,lI),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t.reads=new Set,t.failure=eI,t},dI=class{constructor(e,t){this.registry=e,this.node=t}registry;node;get(e){return this.registry.get(e)}set(e,t){return this.registry.set(e,t)}setSelf(e){return this.node.setValue(e)}refreshSelf(){return this.node.invalidate()}},fI={disabled:0,collect:1,commit:2},pI={phase:fI.disabled,depth:0,stale:[],notify:new Set};function mI(e){let t=pI.phase;pI.phase=fI.collect,pI.depth++;let n=eI;try{e()}catch(e){n=e}if(pI.depth===1){let{notify:e,stale:t}=pI,r=0;do{for(pI.phase=fI.collect;r<t.length;r++)try{hI(t[r])}catch(e){n===eI&&(n=e)}pI.phase=fI.commit;for(let t of e)try{t.notify()}catch(e){n===eI&&(n=e)}}while(r<t.length);pI.stale=[],e.clear()}if(pI.depth--,pI.phase=t,n!==eI)throw n}function hI(e){if(e.state===oI.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=oI.stale,e.disposeLifetime()}e.value()}var gI=`~effect/reactivity/Atom`,_I=e=>v(e,gI),vI=`~effect/reactivity/Atom/Writable`,yI=r(2,(e,t)=>{let n=Ga(t),r=to(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?fo(n):void 0})}),bI=yI(0),xI={[gI]:gI,equals:Object.is,...Jt,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},SI={...xI,atom(e,t){let n=AI(e,t);return EI(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):xF(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>CI(this,e,t):CI(this,e,t)},pull(e,t){let n=bI(NI(0));return XI(n,EI(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?FI(r,YI(r,n,e,t),fF(!0),a.value):xF(a,i)}))},subscriptionRef(e){return UI(bI(EI(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return xF(r,n);let i=typeof e==`function`?e(t):e;return VF(i)?i:FI(t,i,fF(!0),r.value)})),(e,t)=>HI(e,t,wF(e(this))))}},CI=(e,t,n)=>{let[r,i,a]=JI(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return dg(i)?FF(i,n.reactivityKeys):Ux(i,IF(n.reactivityKeys))}:t,n);return DI(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):xF(i,n)},i)},wI={...xI,[vI]:vI},TI=e=>vI in e,EI=(e,t)=>{let n=Object.create(xI);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},DI=(e,t,n)=>{let r=Object.create(wI);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function OI(e,t){e.setSelf(t)}var kI=(e,t)=>{let n=AI(e,t);return`~effect/reactivity/Atom`in n?n:EI(n)},AI=(e,t)=>{if(typeof e==`function`&&!dg(e)&&!px(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:jI in i?PI(e,i,t,r):MI in i?BI(e,i,t,r):i;default:return i}}}return dg(e)?function(n,r){return PI(n,e,t,r)}:px(e)?function(n,r){return BI(n,e,t,r)}:NI(e)},jI=`~effect/Effect`,MI=`~effect/Stream`,NI=e=>DI(function(t){return e},OI),PI=(e,t,n,r)=>FI(e,t,n?.initialValue===void 0?fF():mF(n.initialValue),r,n?.uninterruptible);function FI(e,t,n,r=la(),i=!1){let o=e.self();if(o._tag===`Some`&&cI(e))return o.value;let s=typeof r==`function`?r:a(r),c=wp();e.addFinalizer(()=>{I_(s())(II(c))});let l,u=!1,d=LI(s().pipe(fa(Cp,c),fa(XF,e.registry),fa(ko,e.registry.scheduler)),t,function(t){u?e.setSelf(cF(t,e.self())):l=cF(t,o)},i);return u=!0,d!==void 0&&e.addFinalizer(d),l===void 0?o._tag===`Some`?lF(o):yF(n):l}var II=e=>Ig(kp(e,np),e=>Mf(e)?V:Kg(xg(e),{log:`Unhandled`,message:`Unhandled error in atom finalizer`}));function LI(e,t,n,r=!1){if(Xf(t)){n(t);return}let i=I_(e)(t);i.currentDispatcher?.flush();let a=i.pollUnsafe();if(a){n(a);return}let o=i.addObserver(n);function s(){o(),r||i.interruptUnsafe()}return s}function RI(e){let t=e?.memoMap??bI(kI(()=>Bp())),n=e=>_I(t)?e(t):t,r=LF;function i(e){let t=Object.create(SI);t.keepAlive=!1,t.lazy=!0,t.refresh=void 0,t.factory=i;let a=QI(EI(typeof e==`function`?e:()=>e));return t.layer=a,t.read=function(e){let t=om(e(a),r),i=la();return FI(e,U(l_,r=>W(Up(t,n(e),r),e=>(i=e,e))),fF(),()=>i,!0)},t}i.memoMap=t,i.addGlobalLayer=e=>{r=om(r,am(e,LF))};let a=bI(kI(e=>r_(t=>Up(LF,n(e),O(t,Cp))).pipe(W(O(MF)))));return i.withReactivity=e=>t=>tL(t,n=>{let r=wF(n(a));return n.addFinalizer(r.registerUnsafe(e,()=>{n.refresh(t)})),n.subscribe(t,e=>n.setSelf(e)),n.once(t)},{initialValueTarget:t}),i}var zI=RI();zI.withReactivity;var BI=(e,t,n,r)=>VI(e,t,n?.initialValue===void 0?fF():mF(n.initialValue),r);function VI(e,t,n,r=la()){let i=e.self();if(i._tag===`Some`&&cI(e))return i.value;r=fa(r,XF,e.registry);let a=d_(n=>U(sx(t.channel,n),t=>mg({while:o,body:()=>t,step(t){e.setSelf(mF(Si(t),{waiting:!0}))}}))).pipe(Ig(t=>(wh(t)?u(e.self(),jr(SF),xr({onNone:()=>e.setSelf(vF(new Vf,{previous:e.self()})),onSome:t=>e.setSelf(mF(t))})):e.setSelf(_F(t,{previous:e.self()})),V))),s=LI(r.pipe(fa(XF,e.registry),fa(ko,e.registry.scheduler)),a,l,!1);return s!==void 0&&e.addFinalizer(s),i._tag===`Some`?lF(i):yF(n)}var HI=(e,t,n=la())=>VF(t)?(e.addFinalizer(HF(t).pipe(qx(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return V}),L_(n))),H_(n)(UF(t))):t._tag===`Success`?VI(e,HF(t.value),fF(!0),n):t,UI=(e,t)=>{function n(t,n){let r=t.get(e);VF(r)?V_(GF(r,n)):pF(r)&&V_(GF(r.value,n))}return DI(n=>{let r=n(e);return VF(r)||pF(r)?t(n,r):r},n)},WI=Symbol.for(`effect/reactivity/atom/Atom/Reset`),GI=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`),KI=function(...e){return e.length===0?qI:qI(...e)},qI=(e,t)=>{let[n,r]=JI(e,t);return DI(n,r)};function JI(e,t){let n=bI(NI([0,void 0])),r=t?.initialValue===void 0?fF():mF(t.initialValue),i=t?.concurrent?bI(EI(e=>{let t=new Set;return e.addFinalizer(()=>t.forEach(e=>e.interruptUnsafe())),t})):void 0;function a(t,a){let o=i?t(i):void 0;t.isFn=!0;let[s,c]=t.get(n);if(s===0)return r;if(c===GI)return _F(Of(),{previous:t.self()});let l=e(c,t);return jI in l?(o&&(l=U(P_(l,{startImmediately:!0}),e=>{o.add(e);let t=Array.from(o);return e.addObserver(()=>o.delete(e)),W(rv(t),e=>e[0])})),FI(t,l,r,a,!1)):VI(t,l,r,a)}function o(e,t){aL(()=>{t===WI?e.set(n,[0,void 0]):t===GI?e.set(n,[e.get(n)[0]+1,GI]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,o,n]}var YI=(e,t,n,r)=>U(Jx(typeof n==`function`?n(e):n),n=>{let i=ov().context,a=ji(),o=t_(n,{onFailure(e){return wh(e)?_i(a)?R({done:!0,items:a}):H(new Vf(`Atom.pull: no items`)):xg(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=mi(a,e),a=t),R({done:!1,items:t})}}),s=new Set;return e.addFinalizer(()=>{for(let e of s)e()}),e.once(t),e.subscribe(t,()=>{e.setSelf(lF(e.self()));let t;t=LI(i,o,n=>{t&&s.delete(t);let r=cF(n,e.self()),i=s.size>0;e.setSelf(i?yF(r):r)}),t&&s.add(t)}),o}),XI=(e,t)=>DI(t.read,function(t,n){t.set(e,t.get(e)+1)}),ZI=typeof WeakRef>`u`||typeof FinalizationRegistry>`u`?e=>{let t=ig();return function(n){let r=ag(t,n);if(r._tag===`Some`)return r.value;let i=e(n);return cg(t,n,i),i}}:e=>{let t=ig(),n=new FinalizationRegistry(e=>{let n=ag(t,e);n._tag===`Some`&&n.value.deref()===void 0&&ug(t,e)});return function(r){let i=ag(t,r).pipe(Mr(e=>e.deref()));if(i._tag===`Some`)return i.value;let a=e(r);return cg(t,r,new WeakRef(a)),n.register(a,r),a}},QI=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),$I=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,equals:t})),eL=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:[t,Ft()===0?``:Error().stack?.split(`
16
- `)[5]??``]})),tL=r(e=>_I(e[0]),(e,t,n)=>{let r=bI(TI(e)?DI(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):EI(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=nL(n.initialValueTarget)),r}),nL=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},rL=r(2,(e,t)=>tL(e,n=>t(n(e)))),iL=r(2,(e,t)=>rL(e,DF(t))),aL=mI,oL=`~effect-atom/atom/Atom/Serializable`,sL=r(2,(e,t)=>{let n=vj(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,Ft()===0?``:Error().stack?.split(`
17
- `)[5]??``],[oL]:{key:t.key,encode:Qk(n),decode:Jk(n),skipInitialRun:t.skipInitialRun}})}),cL=`~effect-atom/atom/Atom/ServerValue`,lL=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,[cL]:t})),uL=e=>lL(e,a(fF(!0))),dL=r(2,(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[cL](e=>t.get(e)):t.get(e)),fL=`~effect/socket/Socket`,pL=Ki(`effect/socket/Socket`),mL=e=>pL.of({[fL]:fL,reader:e.reader,writer:e.writer}),hL=new TextEncoder,gL=`~effect/socket/Socket/CloseEvent`,_L=e=>v(e,gL),vL=`~effect/socket/Socket/SocketError`,yL=e=>v(e,vL),bL=class extends gj(`effect/socket/Socket/SocketReadError`)({_tag:jA(`SocketReadError`),cause:ZA()}){message=`An error occurred during Read`},xL=class extends gj(`effect/socket/Socket/SocketWriteError`)({_tag:jA(`SocketWriteError`),cause:ZA()}){message=`An error occurred during Write`},SL=class extends gj(`effect/socket/Socket/SocketOpenError`)({_tag:jA(`SocketOpenError`),kind:wA([`Unknown`,`Timeout`]),cause:ZA()}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},CL=class e extends gj(`effect/socket/Socket/SocketUpgradeError`)({_tag:jA(`SocketUpgradeError`),cause:tA(ZA())}){static unsupported=()=>H(new EL({reason:new e({})}));get message(){return this.cause===void 0?`Socket does not support TLS upgrade`:`An error occurred during TLS upgrade`}},wL=class extends gj(`effect/socket/Socket/SocketCloseError`)({_tag:jA(`SocketCloseError`),code:VA,closeReason:tA(lA)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},TL=CA([bL,xL,SL,CL,wL]),EL=class extends _j(vL)(`SocketError`,{_tag:jA(`SocketError`),reason:TL}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[vL]=vL;static is(e){return yL(e)}message=this.reason.message},DL=(e,t)=>new EL({reason:new wL({code:e,closeReason:t})}),OL=class extends Ki()(`@effect/platform/Socket/WebSocketConstructor`){},kL=Gp(OL)((e,t)=>{if(t!==void 0&&typeof t!=`string`&&!Array.isArray(t))throw TypeError(`WebSocket client options are not supported by the global WebSocket constructor`);return new globalThis.WebSocket(e,t)}),AL=(e,t)=>OL.use(n=>ML(f_((typeof e==`string`?R(e):e).pipe(W(e=>n(e,t?.headers===void 0?t?.protocols:{protocols:t.protocols,headers:t.headers}))),e=>B(()=>e.close(1e3))),t)),jL=e=>`pause`in e&&typeof e.pause==`function`,ML=(e,t)=>Eg(n=>{let r,i=vv(!1),a=n.context,o=bg(function*(){let n=yield*l_,a=yield*Tp(e,n);`binaryType`in a&&(a.binaryType=`arraybuffer`);let o=jL(a),s=t?.highWaterMark??(o?NL:void 0),c=a.readyState===1,u=o&&`isPaused`in a&&a.isPaused===!0,d=[],f=0,p,m,h;function g(){o&&!u&&(a.pause(),u=!0)}function ee(){o&&u&&(a.resume(),u=!1)}function _(){let e=d;return d=[],f=0,p===void 0&&ee(),e}function te(){if(m===void 0||d.length===0)return;let e=m;m=void 0,e(R(_()))}function ne(e){d.push(e),s!==void 0&&(f+=typeof e==`string`?hL.encode(e).byteLength:e.byteLength),m!==void 0&&te(),o&&f>=s?g():!o&&!m&&s!==void 0&&f>s&&re(new EL({reason:new bL({cause:Error(`Socket highWaterMark of ${s} bytes exceeded`)})}))}function re(e){if(p===void 0&&(p=e),h!==void 0){let{cleanup:e,resume:t}=h;h=void 0,e(),t(H(p))}if(m!==void 0){let e=m;m=void 0,e(d.length>0?R(_()):H(p))}}function ie(e){let t=e.data;typeof Blob<`u`&&t instanceof Blob?t.arrayBuffer().then(e=>ne(new Uint8Array(e)),e=>{re(new EL({reason:new bL({cause:e})}))}):ne(t instanceof ArrayBuffer?new Uint8Array(t):t)}function ae(e){re(new EL({reason:c?new bL({cause:e}):new SL({kind:`Unknown`,cause:e})}))}function oe(e){re(DL(typeof e.code==`number`?e.code:1006,e.reason))}return a.addEventListener(`message`,ie),a.addEventListener(`error`,ae,{once:!0}),a.addEventListener(`close`,oe,{once:!0}),yield*Dp(n,B(()=>{if(re(DL(1006)),a.removeEventListener(`message`,ie),a.addEventListener(`error`,l),a.removeEventListener(`error`,ae),a.removeEventListener(`close`,oe),o)try{ee()}catch{}i.closeUnsafe(),r=void 0})),a.readyState>=2?yield*H(p??DL(1006)):(c||=(yield*vg(e=>{let t=()=>{h?.resume===e&&(h=void 0,a.removeEventListener(`open`,t),e(V))},n=()=>a.removeEventListener(`open`,t);return h={resume:e,cleanup:n},a.addEventListener(`open`,t,{once:!0}),B(()=>{h?.resume===e&&(h=void 0),n()})}).pipe(Yg({duration:t?.openTimeout??1e4,orElse:()=>H(new EL({reason:new SL({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))})),!0),p===void 0&&f<s&&ee(),r=a,i.openUnsafe(),{pull:vg(e=>d.length>0?e(R(_())):p===void 0?(m=e,B(()=>{m===e&&(m=void 0)})):e(H(p))),upgrade:CL.unsupported})}).pipe(s_(e=>xa(a,e))),s=e=>z(()=>{let t=r;if(t===void 0)return i.whenOpen(s(e));try{return _L(e)?t.close(e.code,e.reason):t.send(e),V}catch(e){return H(new EL({reason:new xL({cause:e})}))}}),c=e=>z(()=>{let t=r;if(t===void 0)return i.whenOpen(c(e));try{for(let n=0;n<e.length;n++)t.send(e[n]);return V}catch(e){return H(new EL({reason:new xL({cause:e})}))}});return R(mL({reader:o,writer:R({write:s,writeAll:c})}))}),NL=65536,PL=d(AL,Xp(pL)),FL=class extends Ki()(`effect/workers/Transferable/Collector`){},IL=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return FL.of({addAllUnsafe:t,addAll:e=>B(()=>t(e)),readUnsafe:n,read:B(n),clearUnsafe:r,clear:B(r)})},LL=CA([class extends gj(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:jA(`WorkerSpawnError`),message:lA,cause:tA(ZA())}){},class extends gj(`effect/workers/WorkerError/WorkerSendError`)({_tag:jA(`WorkerSendError`),message:lA,cause:tA(ZA())}){},class extends gj(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:jA(`WorkerReceiveError`),message:lA,cause:tA(ZA())}){},class extends gj(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:jA(`WorkerUnknownError`),message:lA,cause:tA(ZA())}){}]),RL=(e,t)=>e===void 0?t:`${e}.${t}`,zL=(e,t)=>({"rpc.system.name":`effect_rpc`,"rpc.method":e,...t}),BL=`~effect/PrimaryKey`,VL=`~effect/rpc/RpcSchema/StreamSchema`;function HL(e){return v(e,VL)}function UL(e){return HL(e)?E({success:e.success,error:e.error}):T()}var WL=Ik(px);function GL(e,t){return J(WL.ast,{[VL]:VL,success:e,error:t})}var KL=`~effect/rpc/Rpc`,qL={[KL]:KL,pipe(){return e(this,arguments)},setSuccess(e){return JL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return JL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return JL({_tag:this._tag,payloadSchema:$k(e)?e:mA(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return JL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return JL({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return JL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:fa(this.annotations,e,t)})},annotateMerge(e){return JL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:xa(this.annotations,e)})}},JL=e=>{function t(){}return Object.setPrototypeOf(t,qL),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},YL=(e,t)=>{let n=t?.success??fA,r=t?.error??aA,i=t?.defect??ZA(),a;return a=t?.primaryKey?class extends hj(`effect/rpc/Rpc/${e}`)(t.payload){[BL](){return t.primaryKey(this)}}:$k(t?.payload)?t?.payload:t?.payload?mA(t?.payload):fA,JL({_tag:e,payloadSchema:a,successSchema:t?.stream?GL(n,r):n,errorSchema:t?.stream?aA:r,defectSchema:i,annotations:la(),middlewares:new Set})},XL=new WeakMap,ZL=e=>{if(XL.has(e))return XL.get(e);let t=e,n=new Set([t.errorSchema]),r=UL(t.successSchema);br(r)&&n.add(r.value.error);for(let e of t.middlewares)n.add(e.error);let i=aj(br(r)?fA:t.successSchema,CA([...n]),t.defectSchema);return XL.set(e,i),i},QL=k(`effect/rpc/Rpc/ParseOptions`,{defaultValue:()=>dE}),$L=`~effect/rpc/Rpc/Wrapper`,eR=e=>$L in e,tR=`~effect/rpc/RpcClientError`,nR=class extends gj(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:jA(`RpcClientDefect`),message:lA,cause:ZA()}){},rR=class extends gj(tR)({_tag:jA(`RpcClientError`),reason:CA([LL,TL,HM,nR])}){[tR]=tR;get message(){return`${this.reason._tag}: ${this.reason.message}`}},iR=e=>e,aR={_tag:`Ping`},oR=CA([lA,uA]),sR=CA([mA({_tag:jA(`Request`),id:oR,tag:lA,payload:nj,headers:vA(_A([lA,lA])),isNotification:tA(iA(!0)),discard:tA(iA(!0)),traceId:tA(lA),spanId:tA(lA),sampled:tA(dA)}),mA({_tag:jA(`Ack`),requestId:oR}),mA({_tag:jA(`Interrupt`),requestId:oR}),mA({_tag:jA(`Ping`)}),mA({_tag:jA(`Eof`)}),mA({_tag:jA(`Chunk`),requestId:oR,values:nj}),mA({_tag:jA(`Exit`),requestId:oR,exit:nj}),mA({_tag:jA(`Defect`),defect:nj}),mA({_tag:jA(`Pong`)})]),cR=new WeakMap,lR=new WeakMap,uR=new WeakMap,dR=new WeakMap;function fR(e,t){let n=t?.fingerprint===!0?lR:cR,r=n.get(e);if(r!==void 0)return r;let{exact:i,layout:a,recursive:o,target:s}=hH(e),c=pH(a,t?.fingerprint),l=i?{value:void 0}:void 0,u=mR(l===void 0?s:yH(s,l,!o),a,c,l);return n.set(e,u),u}function pR(e,t){let n=t?.fingerprint===!0?dR:uR,r=n.get(e);if(r!==void 0)return r;let{exact:i,exitSuccess:a,layout:o,target:s}=hH(e);if(!i){if(!a)return fR(e,t);let r={value:void 0},i=mR(xH(s,r),o,pH(o,t?.fingerprint),r,!0);return n.set(e,i),i}let c=mR(SH(s),o,pH(o,t?.fingerprint),void 0);return n.set(e,c),c}function mR(e,t,n,r,i=!1){return nj.pipe(DA(e,dH(t,n,r,i)))}function hR(e,t){let{exact:n,exitSuccess:r,layout:i}=hH(e),a=pH(i,t?.fingerprint),o=t??dE;if(!n||o.onExcessProperty===`error`){let n=Zk(fR(e,t),t);return!r||o.onExcessProperty===`error`?n:e=>{if(!kV(e))return n(e);try{return OV(i,e,o,a)}catch(e){throw e instanceof xz?new Lk(e.issue):e}}}return e=>{try{return OV(i,e,o,a)}catch(e){throw e instanceof xz?new Lk(e.issue):e}}}function gR(e,t){let{exact:n,layout:r}=hH(e),i=t??dE;if(!n||i.onExcessProperty===`error`){let n=hR(e,t);return e=>_R(e.map(n))}let a=pH(r,t?.fingerprint);return e=>{try{return DV(r,e,i,a)}catch(e){throw e instanceof xz?new Lk(e.issue):e}}}function _R(e){return e.length===1?e[0]:Mk(e)}function vR(e,t){let{exact:n,exitSuccess:r,layout:i,target:a}=hH(e),o=t??dE,s=n?void 0:qk(a,o),c=s!==void 0&&r?e=>kV(e)?e:s(e):s;return xR(i,pH(i,t?.fingerprint),o,t?.maxFrameSize,c,yR(n,t))}function yR(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw Error(`Binary layout: dictionary needs a schema the binary layer validates on its own`);return!0}function bR(e,t){let{exact:n,layout:r,target:i}=hH(e),a=yR(n,t),o=hR(e,t),s=gR(e,t);if(!a)return{encode:o,encodeMany:s};let c=pH(r,t?.fingerprint),l=t??dE,u=l.onExcessProperty===`error`?Zk(i,t):void 0,d=nV(),f=e=>{try{return e()}catch(e){throw e instanceof xz?new Lk(e.issue):e}};return{encode:e=>f(()=>OV(r,u===void 0?e:u(e),l,c,d)),encodeMany:e=>f(()=>DV(r,u===void 0?e:e.map(u),l,c,d))}}function xR(e,t,n,r,i,a){let o=a?[]:void 0,s=new Uint8Array,c=0,l=0,u,d=!1,f=new Vz,p=new Lz(n,kz),m=()=>{f.release(),p.clear(),s=zz,c=l=0},h=(e,t)=>{throw new Lk(new Rw({expected:e},t,n))},g=()=>{let e=u;throw u=void 0,e},ee=(e,t)=>{let n=e.length-t;n>s.length&&(s=new Uint8Array(Math.max(256,n))),s.set(t===0?e:e.subarray(t),0),c=0,l=n},_={feedSync(a){if(u!==void 0)return g();if(d)return h(`parser is spent`);let _=l===c,te,ne,re;if(_)te=a,ne=0,re=a.length;else{if(a.length>0){let e=l-c,t=e+a.length;if(t>s.length){let n=new Uint8Array(Math.max(256,s.length*2,t));n.set(s.subarray(c,l)),s=n,c=0,l=e}else c>0&&(s.copyWithin(0,c,l),c=0,l=e);s.set(a,l),l+=a.length}te=s,ne=c,re=l}let ie=[],ae=()=>(_?ne<re&&ee(a,ne):(c=ne,c===l&&(c=l=0)),ie),oe=(e,t)=>{d=!0;let r=new Lk(new Rw({expected:e},t,n));if(m(),ie.length===0)throw r;return u=r,ie};for(;;){let a=0,s=-1,c=re-ne,l=1;for(let e=0;e<Math.min(6,c);e++){let t=te[ne+e];if(a+=(t&127)*l,!(t&128)){s=e+1;break}l*=128}if(s===-1){if(c<6)return ae();let e=BigInt(a);for(let t=6;t<Math.min(10,c);t++){let n=te[ne+t];if(e|=BigInt(n&127)<<BigInt(t*7),!(n&128)){if(s=t+1,e>AR)return oe(`safe integer length`,e);a=Number(e);break}}if(s===-1)return c>=10?oe(`uvarint`,te.subarray(ne,ne+10)):ae()}if(a===0)return oe(`nonzero frame length`,a);if(r!==void 0&&a>r)return oe(`frame within maxFrameSize`,a);if(s+a>c)return ae();let h=Q;try{Q=0;let r=ne+s;p.beginFrame(),f.reset(te,r,r+a,n,p,t,o);let c=cH(e,f,t);ie.push(i===void 0?c:i(c))}catch(e){d=!0,m();let t=e instanceof xz?new Lk(e.issue):Rk(e)?e:(()=>{throw e})();if(ie.length===0)throw t;return u=t,ie}finally{Q=h}ne+=s+a}},endSync(){if(u!==void 0)return g();if(d)return h(`parser is spent`);d=!0;let e=c<l?s.subarray(c,l):void 0;if(m(),e!==void 0)return h(`complete value`,e)},feed:e=>z(()=>{try{return R(_.feedSync(e))}catch(e){if(Rk(e))return H(e);throw e}}),end:z(()=>{try{return _.endSync(),V}catch(e){if(Rk(e))return H(e);throw e}})};return _}var SR=`~effect/encoding/SchemaBinary/fieldId`,CR=`~effect/encoding/SchemaBinary/fixedWidth`,wR=BigInt(`-9223372036854775808`),TR=BigInt(`9223372036854775807`),ER=BigInt(`18446744073709551615`);function DR(e){let t=e.checks;if(t!==void 0)for(let e of t){let t=e.annotations?.[CR];if(t!==void 0)return t}}var OR=32,kR=33,AR=BigInt(2**53-1),jR=BigInt(0),MR=BigInt(1),NR=BigInt(2),PR=BigInt(7),FR=BigInt(127),IR=BigInt(1e6),LR=BigInt(255),RR=BigInt(4294967295),zR=BigInt(32),BR=new TextEncoder,VR=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),HR=7,UR=0xffffffffffff,WR=0xfffffffffffff,GR=0,KR=1,qR=2,JR=512,YR=1048576,XR=4194304,ZR=0,QR=1,$R=2,ez=3,tz=4,nz=5,rz=6,iz=7,az=8;function oz(e){return typeof e==`number`&&Number.isInteger(e)&&e>=-0xffffffffffff&&e<=UR}var sz=8,cz=2199023255551,lz=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function uz(e){for(let t=1;t<=sz;t++){let n=Math.round(e*lz[t]);if(!(n>=-2199023255551&&n<=cz))return 0;if(n/lz[t]===e)return t}return 0}function dz(e){let t=Math.floor(e/2);return e%2==1?-t:t}var Y={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function fz(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}var pz=BigInt(`14695981039346656037`),mz=BigInt(`1099511628211`),hz=BigInt(`18446744073709551615`);function gz(e){let t=pz;for(let n=0;n<e.length;n++)t=(t^BigInt(e[n]))*mz&hz;return t}function _z(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function vz(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function yz(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function bz(e,t){for(let n=0;n<8;n++)e.push(Number(t>>BigInt(n*8)&LR))}var xz=class extends Error{issue;constructor(e){super(`SchemaBinary failure`),this.issue=e}};function X(e,t,n){throw Sz(new Rw({expected:e},t,n))}var Z=[],Q=0;function Sz(e){return new xz(Q===0?e:new Nw(Z.slice(0,Q),e))}function Cz(e){let t=new Uint8Array(wz(e)),n=0;for(;e>127;)t[n++]=e&127|128,e=Math.floor(e/128);return t[n]=e,t}function wz(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var Tz=32;function Ez(e,t,n,r){let i=n-t;if(i===0)return``;if(i<=Tz){let r=Dz(e,t,n);if(r!==void 0)return r}try{return VR.decode(e.subarray(t,n))}catch{X(`utf-8`,void 0,r)}}function Dz(e,t,n){let r=``,i=t;for(;i+16<=n;i+=16){let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5],l=e[i+6],u=e[i+7],d=e[i+8],f=e[i+9],p=e[i+10],m=e[i+11],h=e[i+12],g=e[i+13],ee=e[i+14],_=e[i+15];if((t|n|a|o|s|c|l|u|d|f|p|m|h|g|ee|_)>127)return;r+=String.fromCharCode(t,n,a,o,s,c,l,u,d,f,p,m,h,g,ee,_)}if(i+8<=n){let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5],l=e[i+6],u=e[i+7];if((t|n|a|o|s|c|l|u)>127)return;r+=String.fromCharCode(t,n,a,o,s,c,l,u),i+=8}switch(n-i){case 0:return r;case 1:{let t=e[i];return t>127?void 0:r+String.fromCharCode(t)}case 2:{let t=e[i],n=e[i+1];return(t|n)>127?void 0:r+String.fromCharCode(t,n)}case 3:{let t=e[i],n=e[i+1],a=e[i+2];return(t|n|a)>127?void 0:r+String.fromCharCode(t,n,a)}case 4:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3];return(t|n|a|o)>127?void 0:r+String.fromCharCode(t,n,a,o)}case 5:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4];return(t|n|a|o|s)>127?void 0:r+String.fromCharCode(t,n,a,o,s)}case 6:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5];return(t|n|a|o|s|c)>127?void 0:r+String.fromCharCode(t,n,a,o,s,c)}default:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5],l=e[i+6];return(t|n|a|o|s|c|l)>127?void 0:r+String.fromCharCode(t,n,a,o,s,c,l)}}}var Oz=65536,kz=256,Az=512,jz=16384;function Mz(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Nz=Mz(Oz),Pz=class{buf=new Uint8Array;view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let e=Nz;(e.writing||e.offset>=e.buf.length)&&(e=Nz=Mz(Oz)),e.writing=!0,this.arena=e,this.buf=e.buf,this.view=e.view,this.start=e.offset,this.limit=e.buf.length-e.offset,this.len=0}ensure(e){if(this.len+e>this.limit){let t=this.arena,n=this.len+e,r=Oz;for(;r<n;)r*=2;let i=Mz(r);i.writing=!0,i.buf.set(this.buf.subarray(this.start,this.start+this.len)),t.writing=!1,this.arena=Nz=i,this.buf=i.buf,this.view=i.view,this.start=0,this.limit=i.buf.length}}byte(e){this.ensure(1),this.buf[this.start+this.len++]=e}bytes(e){this.ensure(e.length),this.buf.set(e,this.start+this.len),this.len+=e.length}uvarint(e){this.ensure(10);let t=this.buf,n=this.start+this.len;if(e<128)t[n++]=e;else if(t[n++]=e&127|128,e<16384)t[n++]=e>>>7;else{for(t[n++]=e>>>7&127|128,e=Math.floor(e/16384);e>127;)t[n++]=e&127|128,e=Math.floor(e/128);t[n++]=e}this.len=n-this.start}uvarintBig(e){for(;e>FR;)this.byte(Number(e&FR)|128),e>>=PR;this.byte(Number(e))}zigzag(e){this.uvarintBig(e>=jR?e<<MR:(-e<<MR)-MR)}numberVarint(e){let t=e<0||e===0&&1/e<0,n=t?-e:e;n<=WR?this.uvarint(n*2+ +!!t):this.uvarintBig(BigInt(n)*NR+(t?MR:jR))}f64(e){this.ensure(8),this.view.setFloat64(this.start+this.len,e,!0),this.len+=8}i64(e){this.ensure(8),this.view.setBigInt64(this.start+this.len,e,!0),this.len+=8}u64(e){this.ensure(8),this.view.setBigUint64(this.start+this.len,e,!0),this.len+=8}u32le(e){this.ensure(4),this.view.setUint32(this.start+this.len,e>>>0,!0),this.len+=4}i32le(e){this.ensure(4),this.view.setInt32(this.start+this.len,e|0,!0),this.len+=4}idAndMark(e){let t=e.length;this.ensure(t+1);let n=this.buf,r=this.start+this.len;for(let i=0;i<t;i++)n[r++]=e[i];let i=r-this.start;return this.len=i+1,i}beginSized(){return this.ensure(1),this.len++}endSized(e){let t=this.len-e-1;t<128?this.buf[this.start+e]=t:this.growSized(e,t)}endSizedRun(e){let t=(this.len-e-1)*2;t<128?this.buf[this.start+e]=t:this.growSized(e,t)}growSized(e,t){let n=wz(t),r=n-1;this.ensure(r);let i=this.start+e;this.buf.copyWithin(i+n,i+1,this.start+this.len),this.len+=r;let a=t,o=i;for(;a>127;)this.buf[o++]=a&127|128,a=Math.floor(a/128);this.buf[o]=a}string(e){let t=e.length;if(t===0)return;this.ensure(t*3);let n=this.buf,r=this.start+this.len,i=0;for(;i+4<=t;i+=4){let t=e.charCodeAt(i),a=e.charCodeAt(i+1),o=e.charCodeAt(i+2),s=e.charCodeAt(i+3);if((t|a|o|s)>127){this.len+=BR.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=t,n[r++]=a,n[r++]=o,n[r++]=s}for(;i<t;i++){let t=e.charCodeAt(i);if(t>127){this.len+=BR.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=t}this.len=r-this.start}out(){let e=this.arena,t=new Uint8Array(e.buf.buffer,this.start,this.len);return e===Nz&&(e.offset=this.start+this.len),e.writing=!1,this.arena=void 0,t}abort(){let e=this.arena;e!==void 0&&(e===Nz&&(e.offset=this.start),e.writing=!1,this.arena=void 0)}};function Fz(e){let t=eO(e);return t._tag===`String`&&t.checks===void 0}function Iz(e,t,n){return e.extra.find(e=>LE({[t]:null},e.parameter,n).length>0)}var Lz=class{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(e,t){this.options=e,this.orderLayouts=t===void 0?void 0:Array(t),this.orderKeys=t===void 0?void 0:Array(t)}beginFrame(){this.replace=!0}find(e,t){let n=this.entries.get(e);if(n===void 0&&(n=new Map,this.entries.set(e,n)),n.has(t))return n.get(t);let r=Iz(e,t,this.options),i=this.orderLayouts;if(i===void 0)return n.set(t,r),r;let a=this.orderKeys;if(this.size<i.length)i[this.size]=e,a[this.size]=t,this.size++,n.set(t,r);else if(this.replace){this.replace=!1;let o=i[this.next];(o===e?n:this.entries.get(o))?.delete(a[this.next]),i[this.next]=e,a[this.next]=t,this.next=(this.next+1)%i.length,n.set(t,r)}return r}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}},Rz=new ArrayBuffer(0),zz=new Uint8Array(Rz),Bz=new DataView(Rz),Vz=class{pos=0;nesting=0;buf=zz;view;viewCache=Bz;viewBuffer=Rz;viewOffset=0;viewLength=0;end=0;options=dE;indexSignatures;positional=!1;rejectUnknownFields=!1;intern;dict;reset(e,t,n,r,i,a,o){this.nesting=0,this.view=void 0,this.buf=e,this.pos=t,this.end=n,this.options=r,this.indexSignatures=i,this.positional=a.positional,this.rejectUnknownFields=a.rejectUnknownFields,this.intern=void 0,this.dict=o}release(){this.pos=this.end=this.nesting=0,this.buf=zz,this.view=void 0,this.viewCache=Bz,this.viewBuffer=Rz,this.viewOffset=this.viewLength=0,this.options=dE,this.indexSignatures=void 0,this.positional=!1,this.rejectUnknownFields=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let e=this.buf;return(e.buffer!==this.viewBuffer||e.byteOffset!==this.viewOffset||e.byteLength!==this.viewLength)&&(this.viewBuffer=e.buffer,this.viewOffset=e.byteOffset,this.viewLength=e.byteLength,this.viewCache=new DataView(e.buffer,e.byteOffset,e.byteLength)),this.view=this.viewCache}byte(){return this.pos>=this.end&&X(`complete value`,void 0,this.options),this.buf[this.pos++]}take(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.buf.subarray(this.pos,this.pos+e);return this.pos+=e,t}takeCopy(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t}enter(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.end;return this.end=this.pos+e,t}exit(e){this.pos=this.end,this.end=e}readUtf8(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.pos;return this.pos+=e,Ez(this.buf,t,t+e,this.options)}uvarint(){let e=this.buf,t=this.end,n=this.pos;n>=t&&X(`complete value`,void 0,this.options);let r=e[n++];if(r<128)return this.pos=n,r;let i=r&127;if(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<7,r<128||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<14,r<128)||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<21,r<128))return this.pos=n,i;let a=268435456;for(let o=4;o<10;o++){n>=t&&(this.pos=n,X(`complete value`,void 0,this.options)),r=e[n++];let o=(r&127)*a;if(o>2**53-1-i&&(this.pos=n,X(`safe integer length`,void 0,this.options)),i+=o,r<128)return this.pos=n,i;a*=128}this.pos=n,X(`uvarint`,void 0,this.options)}fieldTag(){let e=this.buf,t=this.end,n=this.pos;n>=t&&X(`complete value`,void 0,this.options);let r=e[n++];if(r<128)return this.pos=n,r;let i=r&127;return n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<7,r<128||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<14,r<128)||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<21,r<128)?(this.pos=n,i):(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],this.pos=n,r>=128&&X(`uvarint`,void 0,this.options),i+r*268435456)}uvarintBig(){let e=jR,t=jR;for(;;){let n=this.byte();if(e|=BigInt(n&127)<<t,!(n&128))return e;t+=PR}}numberVarint(){let e=this.buf,t=this.end,n=this.pos,r=0,i=1;for(let a=0;a<HR;a++){n>=t&&(this.pos=n,X(`complete value`,void 0,this.options));let a=e[n++];if(r+=(a&127)*i,a<128)return this.pos=n,dz(r);i*=128}let a=this.uvarintBig(),o=Number(a>>MR);return Number.isFinite(o)||X(`safe integer length`,void 0,this.options),(a&MR)===MR?-o:o}zigzag(){let e=this.uvarintBig();return(e&MR)===MR?-(e+MR>>MR):e>>MR}f64(){this.pos+8>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,e}i64(){this.pos+8>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,e}u64(){this.pos+8>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getBigUint64(this.pos,!0);return this.pos+=8,e}u32le(){this.pos+4>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,e}i32le(){this.pos+4>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,e}};function Hz(e,t){return{_:`literal`,leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function Uz(e,t){let n=e.values;return e.valueSet===void 0?n.length===1?t===n[0]:n.includes(t):e.valueSet.has(t)}function Wz(e){return e.values.map(e=>typeof e==`string`?JSON.stringify(e):String(e)).join(` | `)}var Gz=0,Kz=1,qz=2,Jz=3,Yz=30,Xz=1<<Yz;function Zz(e){return e._===`literal`?Zz(e.leaf):e._===`int`}function Qz(e){switch(e._){case`literal`:return Qz(e.leaf);case`bool`:return 1;case`i32`:case`u32`:return 4;case`int64`:case`i64`:case`u64`:return 8;default:return}}function $z(e){return Qz(e)!==void 0||Zz(e)||e._===`null`||e._===`undefined`}function eB(e){return e._===`literal`?eB(e.leaf):e._===`null`||e._===`undefined`}var tB={"effect/schema/Date":{kind:Y.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:Y.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:Y.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:Y.duration,exact:!0},"effect/schema/BigDecimal":{kind:Y.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:Y.bytes,exact:!0},"effect/schema/Option":{kind:Y.option,exact:`parameters`},"effect/schema/Result":{kind:Y.result,exact:`parameters`},"effect/schema/Exit":{kind:Y.exit,exact:`parameters`},"effect/schema/Cause":{kind:Y.cause,exact:`parameters`},"effect/schema/CauseReason":{kind:Y.causeReason,exact:`parameters`}};function nB(e){let t=e.annotations?.representation;return he(t)&&typeof t.id==`string`?t.id:void 0}var rB=RD(e=>{let t=iB(e),n=e.context;return t===e||n===void 0?t:ID(t,new fE(n.isOptional,n.isMutable,void 0,n.annotations))});function iB(e){switch(e._tag){case`Declaration`:{let t=nB(e);if(t!==void 0&&(t in tB||t===`effect/schema/Json`||t===`effect/schema/MutableJson`))return e.recur(rB);let n=e.annotations?.toCodecJson,r=e.annotations?.toCodec;if(!ce(n)&&!ce(r))return e;let i=e.typeParameters.map(e=>J(eO(e))),a=(ce(n)?n(i):void 0)??(ce(r)?r(i):void 0);return a===void 0?e:DD(e,[ND(a,rB)])}case`Arrays`:case`Objects`:case`Union`:case`Suspend`:return e.recur(rB);default:return e}}function aB(e){let t=[...e].sort((e,t)=>{let n=typeof e.key==`number`;return n===(typeof t.key==`number`)?n?e.key-t.key:Nk(BR.encode(e.key),BR.encode(t.key)):n?-1:1}),n=[];for(let e of t){let t=BR.encode(String(e.key));n.push(typeof e.key==`number`?0:1),yz(n,t.length),_z(n,t);let r=e.literal,i=BR.encode(sB(r));n.push(oB(r)),yz(n,i.length),_z(n,i)}return fz(n)}function oB(e){switch(typeof e){case`string`:return 1;case`number`:return 2;case`boolean`:return 3;case`bigint`:return 4;default:return 5}}function sB(e){if(typeof e==`symbol`){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw Error(`Binary layout: unregistered unique symbol (Symbol.keyFor)`);return t}return String(e)}function cB(e){switch(e._tag){case`Symbol`:return!0;case`Union`:return e.types.some(cB);default:return!1}}function lB(e){let t=nB(e);return t===`effect/schema/Json`||t===`effect/schema/MutableJson`||ce(e.annotations?.toCodecJson)}function uB(e){let t=e.checks;if(t===void 0)return!1;let n=e=>e.annotations?.representation?.id===`effect/schema/isInt`||e._tag===`FilterGroup`&&e.checks.some(n);return t.some(n)}function dB(e){for(;e._tag===`Suspend`;)e=e.thunk();return e}function fB(e){return new cD(e.enums.map(e=>new CE(e[1],{title:e[0]})))}function pB(e){let t=[],n=new Set,r=e=>{let i=dB(e);if(!n.has(i))switch(n.add(i),i._tag){case`Never`:return;case`Union`:i.types.forEach(r);return;case`Enum`:fB(i).types.forEach(r);return;default:t.push(i)}};return e.types.forEach(r),t}function mB(e){switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`bool`;default:return`bigint`}}function hB(e){switch(e._tag){case`String`:case`TemplateLiteral`:case`Symbol`:return Y.string;case`UniqueSymbol`:if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw Error(`Binary layout: unregistered unique symbol (Symbol.keyFor)`);return Y.string;case`Boolean`:return Y.bool;case`Null`:return Y.null;case`Undefined`:case`Void`:return Y.undefined;case`Number`:return Y.number;case`BigInt`:return Y.bigint;case`Literal`:switch(typeof e.literal){case`string`:return Y.string;case`number`:return Y.number;case`boolean`:return Y.bool;default:return Y.bigint}case`Unknown`:case`Any`:case`ObjectKeyword`:return Y.json;case`Objects`:return Y.struct;case`Arrays`:return Y.array;case`Declaration`:{let t=nB(e);if(t!==void 0&&t in tB)return tB[t].kind;if(lB(e))return Y.json;throw Error(`Binary layout: declaration ${t??`<anonymous>`} has no toCodecJson or toCodec`)}case`Suspend`:return hB(dB(e));default:throw Error(`Binary layout: union members are not uniquely identifiable`)}}function gB(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function _B(e){let t=vB(e),n=!t&&bB(e);e=eO(e);let r=new Map,i=!1,a=0,o=e=>({_:e,slot:e===`string`?a++:0});function s(e){let t=r.get(e);if(t!==void 0)return t;let n=c(e);return r.set(e,n),n}function c(e){switch(e._tag){case`String`:case`TemplateLiteral`:return o(`string`);case`Symbol`:case`UniqueSymbol`:return o(`symbol`);case`Boolean`:return o(`bool`);case`Null`:return o(`null`);case`Undefined`:case`Void`:return o(`undefined`);case`Number`:{let t=DR(e);return o(t===`i32`||t===`u32`?t:uB(e)?`int`:`number`)}case`BigInt`:{let t=DR(e);return o(t===`i64`||t===`u64`?t:`bigint`)}case`Literal`:return Hz(o(mB(e.literal)),[e.literal]);case`Unknown`:case`Any`:case`ObjectKeyword`:return o(`json`);case`Never`:return{_:`never`,ast:e};case`Enum`:return f(e,pB(fB(e)));case`Suspend`:{i=!0;let t=s(e.thunk());return r.set(e,t),t}case`Objects`:return l(e);case`Arrays`:return u(e);case`Union`:return f(e,pB(e));case`Declaration`:return d(e)}}function l(e){let t=[],n=[],i=new Map;for(let r of e.propertySignatures){if(typeof r.name==`symbol`)throw Error(`Binary layout: symbol property names are illegal`);let e=String(r.name),a=r.type.context?.annotations,o=a?.[SR],s=typeof o==`number`?o:fz(BR.encode(e));if(!Number.isInteger(s)||s<0||s>4294967295)throw Error(`Binary layout: illegal field id for ${e}`);let c=i.get(s);c===void 0?i.set(s,[e]):c.push(e),t.push({name:e,id:s,tagBytes:Cz(s*az+ZR),index:0,optional:r.type.context?.isOptional===!0,annotations:a,layout:void 0,wireMask:0,inline:!1}),n.push(r.type)}for(let[e,t]of i)if(e===0||t.length>1)throw Error(`Binary layout field id collision: ${e} (${t.join(`, `)})`);let a=[];for(let t of e.indexSignatures){if(cB(t.parameter))throw Error(`Binary layout: symbol property names are illegal`);a.push({parameter:t.parameter,layout:void 0,wireMask:0})}let o={_:`struct`,ast:e,fields:t,byId:new Map,extra:a,extraAll:a.length===1&&Fz(a[0].parameter)?a[0]:void 0,names:new Set(t.map(e=>e.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};r.set(e,o);for(let e=0;e<t.length;e++){let r=t[e];r.layout=s(n[e]),r.wireMask=HV(r.layout),r.inline=$z(r.layout),r.optional&&o.optionalCount++,o.byId.set(r.id,r)}t.sort((e,t)=>e.id-t.id);for(let e=0;e<t.length;e++)t[e].index=e;gB(o);for(let t=0;t<a.length;t++)a[t].layout=s(e.indexSignatures[t].type),a[t].wireMask=HV(a[t].layout);return o}function u(e){let t={_:`array`,ast:e,elements:[],rest:[],hasCount:e.rest.length>0||e.elements.some(e=>e.context?.isOptional===!0),minCount:e.elements.filter(e=>e.context?.isOptional!==!0).length+Math.max(0,e.rest.length-1),uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};r.set(e,t);for(let n of e.elements)t.elements.push({optional:n.context?.isOptional===!0,layout:s(n)});for(let n of e.rest)t.rest.push(s(n));if(t.elements.length===0&&t.rest.length===1){let e=t.rest[0];t.uniform=e,t.uniformPacked=Qz(e),t.uniformNumbers=e._===`number`,t.uniformInline=$z(e)}return t}function d(e){let t=nB(e);switch(t){case`effect/schema/Date`:return{_:`int64`,flavor:`date`};case`effect/schema/DateTimeUtc`:return{_:`int64`,flavor:`utc`};case`effect/schema/DateTimeZoned`:return o(`dateTimeZoned`);case`effect/schema/Duration`:return o(`duration`);case`effect/schema/BigDecimal`:return o(`bigDecimal`);case`effect/schema/Uint8Array`:return o(`bytes`)}let n=e.typeParameters;switch(t){case`effect/schema/Option`:{let t={_:`option`,value:void 0};return r.set(e,t),t.value=s(n[0]),t}case`effect/schema/Result`:{let t={_:`result`,success:void 0,failure:void 0};return r.set(e,t),t.success=s(n[0]),t.failure=s(n[1]),t}case`effect/schema/Exit`:{let t={_:`cause`,error:void 0,defect:void 0},i={_:`exit`,value:void 0,cause:t};return r.set(e,i),i.value=s(n[0]),t.error=s(n[1]),t.defect=s(n[2]),i}case`effect/schema/Cause`:case`effect/schema/CauseReason`:{let i={_:t===`effect/schema/Cause`?`cause`:`causeReason`,error:void 0,defect:void 0};return r.set(e,i),i.error=s(n[0]),i.defect=s(n[1]),i}}if(t!==void 0&&t in tB)throw Error(`Binary layout: native declaration ${t} has no layout constructor`);if(lB(e))return o(`json`);throw Error(`Binary layout: declaration ${t??`<anonymous>`} has no toCodecJson or toCodec`)}function f(e,t){if(t.length===0)return{_:`never`,ast:e};let n=[],i=[],a=new Map,c=new Map,l=(e,t)=>{let n=a.get(e);if(n!==void 0&&n._!==t._)throw Error(`Binary layout: union members are not uniquely identifiable`);a.set(e,t)};for(let e of t)if(e._tag===`Literal`){let t=hB(e),n=c.get(t);n===void 0?c.set(t,[e.literal]):n.includes(e.literal)||n.push(e.literal)}else if(e._tag===`UniqueSymbol`)hB(e),l(Y.string,o(`symbol`));else{if(e._tag===`Objects`||e._tag===`Arrays`){let t=nD(e);if(t!==void 0&&t.length>0){for(let e of t)if(typeof e.key==`symbol`)throw Error(`Binary layout: symbol property names are illegal`);n.push({member:e,sentinels:t});continue}}i.push({member:e,kind:hB(e)})}for(let[e,t]of c)l(e,Hz(o(mB(t[0])),t));if(n.length===0&&i.length===0&&a.size===1)return a.values().next().value;let u=new Set(a.keys());for(let{kind:e}of i){if(u.has(e))throw Error(`Binary layout: union members are not uniquely identifiable`);u.add(e)}if(n.length===0&&a.size===0&&i.length===1){let t=s(i[0].member);return r.set(e,t),t}let d=new Map,f=[];for(let{sentinels:e}of n){let t=aB(e);if(d.has(t))throw Error(`Binary layout sentinel collision: ${t}`);d.set(t,e),f.push(t)}let p={_:`union`,ast:e,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};r.set(e,p);for(let e=0;e<n.length;e++){let{member:t,sentinels:r}=n[e],i=f[e],a=s(t),o,c;if(t._tag===`Objects`){let e=a,t=new Set(r.map(e=>String(e.key))),n=e.fields.filter(e=>!t.has(e.name)),i={_:`struct`,ast:e.ast,fields:n,byId:new Map(n.map(e=>[e.id,e])),extra:e.extra,extraAll:e.extraAll,names:e.names,extraShape:void 0,optionalCount:n.reduce((e,t)=>t.optional?e+1:e,0),requiredMask:0,requiredWide:!1};gB(i),o=i,c=!1}else o=a,c=!0;let l={tag:i,sentinels:r,tuple:c,payload:o,position:0};p.variants.push(l),p.byTag.set(i,l)}for(let[e,t]of a)p.others.push({kind:e,layout:t,position:0}),p.byKind.set(e,t);for(let{kind:e,member:t}of i){let n=s(t);p.others.push({kind:e,layout:n,position:0}),p.byKind.set(e,n)}for(let e of[...p.variants].sort((e,t)=>e.tag-t.tag))e.position=p.byPos.length,p.byPos.push({variant:e,layout:e.payload});for(let e of[...p.others].sort((e,t)=>e.kind-t.kind))e.position=p.byPos.length,p.byPos.push({variant:void 0,layout:e.layout});return p.others.sort((e,t)=>EB(e.layout)-EB(t.layout)),p.discriminator=vV(p.variants),p}return{layout:s(e),recursive:i,exact:t,exitSuccess:n}}function vB(e){let t=new Map,n=e=>{if(e.encoding!==void 0||e.checks!==void 0&&!yB(e)||e.encodingChecks!==void 0)return!1;switch(e._tag){case`String`:case`Symbol`:case`Boolean`:case`Null`:case`Undefined`:case`Void`:case`Number`:case`BigInt`:case`Literal`:return!0;case`Never`:return!0;case`Unknown`:case`Any`:return!0;case`Arrays`:return e.elements.every(n)&&e.rest.every(n);case`Objects`:return e.propertySignatures.every(e=>n(e.type))&&e.indexSignatures.every(e=>e.parameter._tag===`String`&&n(e.parameter)&&n(e.type));case`Union`:return(e.options?.mode??`anyOf`)===`anyOf`&&e.types.every(n);case`Suspend`:{let r=t.get(e);if(r!==void 0)return r;t.set(e,!0);let i=n(e.thunk());return t.set(e,i),i}case`Declaration`:{let t=nB(e),r=t===void 0?void 0:tB[t];return r===void 0?!1:r.exact===!0||e.typeParameters.every(n)}default:return!1}};return n(e)}function yB(e){return(e._tag===`Number`||e._tag===`BigInt`)&&e.checks?.length===1&&DR(e)!==void 0}function bB(e){return e._tag===`Declaration`&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&nB(e)===`effect/schema/Exit`&&vB(e.typeParameters[0])}var xB={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25,i32:26,u32:27,i64:28,u64:29};function SB(e){let t=new Map,n=[],r=2**53-1;function i(e){let i=n.lastIndexOf(e);if(i>=0){i<r&&(r=i);let e=[xB.backEdge];return vz(e,n.length-i),gz(e)}let o=t.get(e);if(o!==void 0)return o;let s=n.length,c=r;r=2**53-1,n.push(e);let l=gz(a(e));n.pop();let u=r>=s;return u&&t.set(e,l),r=u?c:Math.min(c,r),l}function a(e){let t=[];switch(e._){case`bool`:case`null`:case`undefined`:case`number`:case`int`:case`string`:case`symbol`:case`bytes`:case`bigint`:case`i32`:case`u32`:case`i64`:case`u64`:case`json`:case`duration`:case`bigDecimal`:case`dateTimeZoned`:return t.push(xB[e._]),t;case`literal`:{t.push(xB.literal),_z(t,a(e.leaf)),vz(t,e.values.length);let n=e.values.map(e=>[oB(e),sB(e)]).sort((e,t)=>e[1]<t[1]?-1:e[1]>t[1]?1:e[0]-t[0]);for(let[e,r]of n){t.push(e);let n=BR.encode(r);vz(t,n.length),_z(t,n)}return t}case`int64`:return t.push(e.flavor===`date`?xB.date:xB.dateTimeUtc),t;case`never`:return t.push(xB.never),t;case`struct`:t.push(xB.struct),vz(t,e.fields.length);for(let n of e.fields)yz(t,n.id),t.push(+!!n.optional),bz(t,i(n.layout));vz(t,e.extra.length);for(let n of e.extra)bz(t,i(n.layout));return t;case`array`:t.push(xB.array),vz(t,e.elements.length);for(let n of e.elements)t.push(+!!n.optional),bz(t,i(n.layout));vz(t,e.rest.length);for(let n of e.rest)bz(t,i(n));return t;case`union`:t.push(xB.union),vz(t,e.byPos.length);for(let n of e.byPos){let e=n.variant;e===void 0?t.push(0):(t.push(1,+!!e.tuple),yz(t,e.tag)),bz(t,i(n.layout))}return t;case`option`:return t.push(xB.option),bz(t,i(e.value)),t;case`result`:return t.push(xB.result),bz(t,i(e.success)),bz(t,i(e.failure)),t;case`exit`:return t.push(xB.exit),bz(t,i(e.value)),bz(t,i(e.cause.error)),bz(t,i(e.cause.defect)),t;case`cause`:case`causeReason`:return t.push(e._===`cause`?xB.cause:xB.causeReason),bz(t,i(e.error)),bz(t,i(e.defect)),t}}return i(e)}function CB(e,t){let n=new Uint8Array(8);for(let r=0;r<4;r++)n[r]=e>>>r*8&255,n[r+4]=t>>>r*8&255;return n}var wB={positional:!1,rejectUnknownFields:!1,envelope:OR,expectedEnvelope:`version 2 envelope, flags 0`,fingerprint:new Uint8Array(8)};({...wB});function TB(e){let t=SB(e);return{positional:!0,rejectUnknownFields:!1,envelope:kR,expectedEnvelope:`version 2 envelope, flags 1`,fingerprint:CB(Number(t&RR),Number(t>>zR&RR))}}function EB(e){switch(e._){case`json`:return 2;case`struct`:return 1;default:return 0}}function DB(e,t){switch(e._){case`literal`:return Uz(e,t);case`bool`:return typeof t==`boolean`;case`null`:return t===null;case`undefined`:return t===void 0;case`number`:case`int`:case`i32`:case`u32`:return typeof t==`number`;case`string`:return typeof t==`string`;case`symbol`:return typeof t==`symbol`;case`bigint`:case`i64`:case`u64`:return typeof t==`bigint`;case`bytes`:return t instanceof Uint8Array;case`int64`:return e.flavor===`date`?t instanceof Date:qS(t)&&t._tag===`Utc`;case`dateTimeZoned`:return qS(t)&&t._tag===`Zoned`;case`duration`:return eo(t);case`bigDecimal`:return gS(t);case`option`:return vr(t);case`result`:return Br(t);case`exit`:return Xf(t);case`cause`:return bf(t);case`causeReason`:return xf(t);case`array`:return Array.isArray(t);case`struct`:return he(t)&&!Array.isArray(t);case`json`:return!0;case`union`:case`never`:return!1}}function $(e,t,n){throw Sz(new Rw({expected:e},t,n))}function OB(e,t=new Set){if(!me(e))return!1;let n=Array.isArray(e),r=Object.getPrototypeOf(e);if(n||r===Object.prototype||r===null){if(t.has(e))return!0;t.add(e);try{if(n){for(let n=0;n<e.length;n++)if(OB(e[n],t))return!0}else for(let n of Object.keys(e))if(OB(e[n],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||qS(e)||eo(e)||gS(e))return!1;if(t.has(e))return!0;t.add(e);try{if(vr(e))return br(e)&&OB(e.value,t);if(Br(e))return OB(Vr(e)?e.success:e.failure,t);if(Xf(e))return OB(rp(e)?e.value:e.cause,t);if(bf(e))return e.reasons.some(e=>OB(e,t));if(xf(e))switch(e._tag){case`Fail`:return OB(e.error,t);case`Die`:return OB(e.defect,t);case`Interrupt`:return!1}if(mv(e)){for(let n of e)if(OB(n,t))return!0;return!1}if(eC(e)){for(let[n,r]of e)if(OB(n,t)||OB(r,t))return!0;return!1}if(nC(e)){for(let n of e)if(OB(n,t))return!0;return!1}if(vC(e))return OB(xC(e),t);for(let n of Object.keys(e))if(OB(e[n],t))return!0}finally{t.delete(e)}return!1}function kB(e,t,n,r){let i=r.beginSized();CV(e,t,n,r),r.endSized(i)}function AB(e,t,n){let r=globalThis.Symbol.keyFor(t);r===void 0&&$(`registered symbol`,t,e.options),n.string(r)}function jB(e,t,n,r){let i=n;switch(i._tag){case`Fail`:r.byte(0),CV(e,t.error,i.error,r);return;case`Die`:r.byte(1),CV(e,t.defect,i.defect,r);return;case`Interrupt`:i.fiberId===void 0?r.byte(2):(r.byte(3),r.f64(i.fiberId))}}function MB(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function NB(e,t,n){if(e.layout!==t||e.keys.length!==n.length)return!1;for(let t=0;t<n.length;t++)if(e.keys[t]!==n[t])return!1;return!0}function PB(e,t){if(e.extraAll===void 0||t.length>Az)return!1;let n=0;for(let e=0;e<t.length;e++)if(n+=t[e].length,n>jz)return!1;return!0}function FB(e,t,n){let r=Object.keys(n),i=t.extraShape;if(i!==void 0&&NB(i,t,r))return i.pairs;let a=PB(t,r),o=a?void 0:e.extraShape;if(o!==void 0&&NB(o,t,r))return o.pairs;let s=t.names,c=t.extraAll,l=[],u=!0;for(let n of r){if(s.has(n))continue;let r=c??(e.indexSignatures??=new Lz(e.options)).find(t,n);r!==void 0&&(u&&!MB(n)&&(u=!1),l.push([n,r,void 0]))}if(u)l.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0]));else{for(let e of l)e[2]=BR.encode(e[0]);l.sort((e,t)=>Nk(e[2],t[2]))}if(a)for(let e of l)e[2]??=BR.encode(e[0]);let d={layout:t,keys:r,pairs:l};return a?t.extraShape=d:e.extraShape=d,l}function IB(e,t,n,r,i){for(let[a,o,s]of t){let t=s===void 0?a.length:s.length,c=n[a],l=LB(o.layout,c,e.options),u=l%az;if(i===void 0)r.uvarint(t*az+u);else{if(!i.disabled){let t=YB(i,a);if(t!==void 0){r.uvarint(t*16+u*2+1),Z[Q++]=a,RB(e,o.layout,c,l,r),Q--;continue}XB(i,a)}r.uvarint(t*16+u*2)}s===void 0?r.string(a):r.bytes(s),Z[Q++]=a,RB(e,o.layout,c,l,r),Q--}}function LB(e,t,n){if(e._===`literal`)return Uz(e,t)||$(Wz(e),t,n),LB(e.leaf,t,n);switch(e._){case`bool`:return typeof t!=`boolean`&&$(`a boolean`,t,n),t?tz:ez;case`number`:if(typeof t!=`number`&&$(`a number`,t,n),oz(t))return QR;{let e=uz(t);return e===0?$R:e*az+nz}case`int`:return Number.isSafeInteger(t)||$(`an integer`,t,n),QR;case`i32`:case`u32`:return rz;default:return ZR}}function RB(e,t,n,r,i){switch(r%az){case ez:case tz:return;case QR:i.numberVarint(n);return;case $R:i.f64(n);return;case rz:CV(e,t,n,i);return;case nz:{let e=Math.floor(r/az);i.numberVarint(Math.round(n*lz[e])),i.uvarint(e);return}default:kB(e,t,n,i)}}function zB(e,t,n,r){let i=LB(t.layout,n,e.options),a=i%az;if(a===ZR){let i=r.idAndMark(t.tagBytes);CV(e,t.layout,n,r),r.endSized(i)}else r.uvarint(t.id*az+a),RB(e,t.layout,n,i,r)}function BB(e,t){let n=e.byName;if(n===void 0)return;let r=Object.getOwnPropertyNames(t),i=0;for(let e=0;e<r.length;e++){let t=n.get(r[e]);t!==void 0&&(i|=1<<t)}let a=e.struct;if((i&a.requiredMask)!==a.requiredMask){let e=a.fields;for(let t=0;t<e.length;t++){let n=e[t];if(!n.optional&&!(i&1<<t))throw Z[Q++]=n.name,Sz(new Pw(n.annotations))}}return i}function VB(e,t,n,r){let i=n;if(t.extra.length>0){let n=e.intern;e.intern=void 0;let a=FB(e,t,i);if(a.length>0){r.uvarint(0);let t=r.beginSized();IB(e,a,i,r,n),r.endSized(t)}}let a=t.fields;for(let t=0;t<a.length;t++){let n=a[t],o=n.name;if(!Object.hasOwn(i,o)){if(n.optional)continue;throw Z[Q++]=o,Sz(new Pw(n.annotations))}Z[Q++]=o,zB(e,n,i[o],r),Q--}}function HB(e,t,n,r){let i=n,a=e.intern;e.intern=void 0;let o=t.optionalCount+7>>3,s=0;if(o>0){s=r.len;for(let e=0;e<o;e++)r.byte(0)}let c=t.fields,l=0;for(let t=0;t<c.length;t++){let n=c[t],a=n.name,o=Object.hasOwn(i,a);if(n.optional){if(o&&(r.buf[r.start+s+(l>>3)]|=1<<(l&7)),l++,!o)continue}else if(!o)throw Z[Q++]=a,Sz(new Pw(n.annotations));Z[Q++]=a,n.inline?CV(e,n.layout,i[a],r):kB(e,n.layout,i[a],r),Q--}if(t.extra.length>0){let n=FB(e,t,i);r.uvarint(n.length),IB(e,n,i,r,a)}}function UB(e){switch(e._){case`string`:return Kz;case`array`:return e.uniform?._===`string`?qz:Gz;case`struct`:return e.extra.length>0?Jz:Gz;default:return Gz}}function WB(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let n of e.elements)if(n.optional||n.layout!==t)return}return t._===`struct`?t:void 0}function GB(e){let t=e.run;if(t!==void 0)return t;let n=WB(e);if(n===void 0)return e.run=t=null,t;let r=n.fields.map(e=>UB(e.layout)),i=n.fields.length<=Yz;return t={struct:n,intern:r,shapes:i,byName:i&&n.extra.length===0?new Map(n.fields.map((e,t)=>[e.name,t])):void 0},e.run=t,t}var KB=16,qB=64;function JB(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function YB(e,t){let n=e.refs;if(n!==void 0){let r=n.get(t);return r!==void 0&&e.hits++,r}let r=e.values;for(let n=0;n<r.length;n++)if(r[n]===t)return e.hits++,n}function XB(e,t){let n=e.values;if(e.refs!==void 0){if(e.hits===0&&n.length>=qB){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,n.length)}else if(n.length>=KB){let r=e.refs=new Map;for(let e=0;e<n.length;e++)r.set(n[e],e);r.set(t,n.length)}n.push(t)}var ZB=0,QB=1,$B=2,eV=64,tV=512;function nV(){return{slots:[],marks:[],frame:0}}function rV(e,t){return e[t]??={values:[],refs:new Map,state:ZB,stamp:-1}}function iV(e,t){e.refs.has(t)?e.state=QB:(e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=eV&&(e.state=$B))}function aV(e,t){let n=e.values;n.length>=tV||(e.refs.set(t,n.length),n.push(t))}function oV(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function sV(e){e.marks.length=0,e.frame++}function cV(e){let t=e.marks;for(let e=t.length-1;e>=0;e--){let{length:n,slot:r,state:i}=t[e],a=r.values;for(let e=n;e<a.length;e++)r.refs.delete(a[e]);a.length=n,r.state=i}t.length=0,e.frame++}function lV(e,t,n,r){let i=rV(e.slots,t.slot),a=i.state;if(a===$B){r.string(n);return}if(oV(e,i),a===ZB){r.string(n),iV(i,n);return}let o=i.refs.get(n);o===void 0?(r.byte(0),aV(i,n),r.string(n)):r.uvarint(o*2+1)}function uV(e,t,n){let r=rV(e,t.slot),i=r.state;if(i===$B)return n.readUtf8(n.end-n.pos);if(i===ZB){let e=n.readUtf8(n.end-n.pos);return iV(r,e),e}let a=n.uvarint();if((a&1)==1){let e=(a-1)/2,t=r.values;return e>=t.length&&X(`a dictionary reference`,a,n.options),t[e]}a!==0&&X(`a dictionary marker`,a,n.options);let o=n.readUtf8(n.end-n.pos);return aV(r,o),o}function dV(e,t,n,r,i){if(!e.disabled){let t=YB(e,r);if(t!==void 0){i.uvarint(t*2+1);return}XB(e,r)}let a=i.beginSized();CV(t,n,r,i),i.endSizedRun(a)}function fV(e,t,n,r,i){let a=[],o=[];for(let s=0;s<r;s++){Z[Q++]=s;let r=i.beginSized();pV(e,t,a,o,n[s],i),i.endSized(r),Q--}}function pV(e,t,n,r,i,a){let o=t.struct,s=i,c=o.fields,l;if(o.extra.length>0){let t=FB(e,o,s);t.length>0&&(l=t)}let u=!t.shapes,d=l===void 0?0:Xz,f=BB(t,s);if(f!==void 0)d=f;else for(let e=0;e<c.length;e++){let t=c[e];if(Object.hasOwn(s,t.name))u||(d|=1<<e);else if(!t.optional)throw Z[Q++]=t.name,Sz(new Pw(t.annotations))}let p=-1;for(let e=0;e<n.length;e++)if(n[e]===d){p=e;break}p>=0?a.uvarint(p+1):(a.uvarint(0),u||n.push(d));let m=p<0,h=e.positional&&!u;if(m&&h&&a.uvarint(d),l!==void 0){m&&!h&&a.uvarint(0);let t=a.beginSized();IB(e,l,s,a),a.endSizedRun(t)}for(let n=0;n<c.length;n++){let i=c[n];if(u?!Object.hasOwn(s,i.name):!(d&1<<n))continue;m&&!h&&a.uvarint(i.id),Z[Q++]=i.name;let o=t.intern[n];if(o===Kz)dV(JB(r,n),e,i.layout,s[i.name],a);else{o!==Gz&&(e.intern=JB(r,n));let t=a.beginSized();CV(e,i.layout,s[i.name],a),a.endSizedRun(t),e.intern=void 0}Q--}}function mV(e,t,n){let r=e.elements.length;if(t<r)return e.elements[t].layout;let i=Math.max(0,e.rest.length-1),a=Math.max(r,n-i);return t>=a?e.rest[t-a+1]:e.rest[0]}function hV(e,t,n,r){let i=n.length;if(t.rest.length===0&&i>t.elements.length)throw Z[Q++]=t.elements.length,Sz(new Fw(t.ast,n[t.elements.length],e.options));if(i<t.minCount)throw Z[Q++]=i,Sz(new Pw(void 0));if(t.hasCount&&r.uvarint(i),i>0){let a=GB(t);if(a!==null){fV(e,a,n,i,r);return}}let a=t.uniform;if(a!==void 0){if(t.uniformNumbers){_V(e,n,i,r);return}let o=e.intern;if(e.intern=void 0,o!==void 0){for(let t=0;t<i;t++)Z[Q++]=t,dV(o,e,a,n[t],r),Q--;return}let s=t.uniformInline;for(let t=0;t<i;t++)Z[Q++]=t,s?CV(e,a,n[t],r):kB(e,a,n[t],r),Q--}else for(let a=0;a<i;a++){let o=mV(t,a,i);Z[Q++]=a,$z(o)?CV(e,o,n[a],r):kB(e,o,n[a],r),Q--}}var gV=[];function _V(e,t,n,r){let i=!0,a=!0;for(let r=0;r<n;r++){let n=t[r];if(typeof n!=`number`&&(Z[Q++]=r,$(`a number`,n,e.options)),oz(n))(n<0?-n:n)>cz&&(a=!1);else{i=!1;let e=uz(n);e===0?a=!1:gV[r]=e}if(!i&&!a)break}if(i){r.byte(KR);for(let e=0;e<n;e++)r.numberVarint(t[e])}else if(a){r.byte(qR);for(let e=0;e<n;e++){let n=t[e],i=Number.isInteger(n)?0:gV[e],a=i===0?n:Math.round(n*lz[i]),o=a<0||a===0&&1/a<0,s=o?-a:a;r.uvarint((s*2+ +!!o)*16+i)}}else{r.byte(GR);for(let e=0;e<n;e++)r.f64(t[e])}}function vV(e){if(!(e.length<2||e.some(e=>e.tuple)))for(let t of e[0].sentinels){let n=new Map;for(let r of e){let e=r.sentinels.find(e=>e.key===t.key);if(e===void 0||n.has(e.literal)||Number.isNaN(e.literal))break;n.set(e.literal,r)}if(n.size===e.length)return{key:t.key,rows:n}}}function yV(e,t){let n=e.sentinels;for(let e=0;e<n.length;e++){let{key:r,literal:i}=n[e];if(t[r]!==i||!Object.hasOwn(t,r))return!1}return!0}function bV(e,t){return e.tuple?Array.isArray(t)&&yV(e,t):he(t)&&!Array.isArray(t)&&yV(e,t)}function xV(e,t,n,r){e.positional?r.uvarint(t.position):(r.byte(Y.variant),r.u32le(t.tag)),CV(e,t.payload,n,r)}function SV(e,t,n,r){let i=t.discriminator;if(i!==void 0){if(he(n)&&!Array.isArray(n)){let t=n,a=i.rows.get(t[i.key]);if(a!==void 0&&yV(a,t)){xV(e,a,n,r);return}}}else for(let i of t.variants)if(bV(i,n)){xV(e,i,n,r);return}for(let i of t.others)if(DB(i.layout,n)){e.positional?r.uvarint(i.position):r.byte(i.kind),CV(e,i.layout,n,r);return}throw Sz(new Lw(t.ast,n,e.options))}function CV(e,t,n,r){switch(t._){case`literal`:Uz(t,n)||$(Wz(t),n,e.options),CV(e,t.leaf,n,r);return;case`bool`:typeof n!=`boolean`&&$(`a boolean`,n,e.options),r.byte(+(n===!0));return;case`null`:n!==null&&$(`null`,n,e.options);return;case`undefined`:n!==void 0&&$(`undefined`,n,e.options);return;case`number`:{if(typeof n!=`number`&&$(`a number`,n,e.options),oz(n)){r.numberVarint(n);return}let t=uz(n);t>0?(r.numberVarint(Math.round(n*lz[t])),r.byte(t)):r.f64(n);return}case`int`:Number.isSafeInteger(n)||$(`an integer`,n,e.options),r.numberVarint(n);return;case`string`:{typeof n!=`string`&&$(`a string`,n,e.options);let i=e.dict;i===void 0?r.string(n):lV(i,t,n,r);return}case`symbol`:typeof n!=`symbol`&&$(`a symbol`,n,e.options),AB(e,n,r);return;case`bytes`:n instanceof Uint8Array||$(`a Uint8Array`,n,e.options),r.bytes(n);return;case`bigint`:typeof n!=`bigint`&&$(`a bigint`,n,e.options),r.zigzag(n);return;case`i32`:(typeof n!=`number`||(n|0)!==n)&&$(`a 32-bit integer`,n,e.options),r.i32le(n);return;case`u32`:(typeof n!=`number`||n>>>0!==n)&&$(`a 32-bit unsigned integer`,n,e.options),r.u32le(n);return;case`i64`:(typeof n!=`bigint`||n<wR||n>TR)&&$(`a 64-bit integer`,n,e.options),r.i64(n);return;case`u64`:(typeof n!=`bigint`||n<jR||n>ER)&&$(`a 64-bit unsigned integer`,n,e.options),r.u64(n);return;case`int64`:{DB(t,n)||$(t.flavor===`date`?`a Date`:`a DateTime.Utc`,n,e.options);let i=t.flavor===`date`?n.getTime():n.epochMilliseconds;Number.isNaN(i)&&$(`a valid Date`,n,e.options),r.i64(BigInt(i));return}case`dateTimeZoned`:{DB(t,n)||$(`a DateTime.Zoned`,n,e.options);let i=n;r.i64(BigInt(i.epochMilliseconds)),i.zone._tag===`Offset`?(r.byte(0),r.i32le(i.zone.offset)):(r.byte(1),r.string(i.zone.id));return}case`duration`:{eo(n)||$(`a Duration`,n,e.options);let t=n.value;switch(t._tag){case`Infinity`:r.byte(1);return;case`NegativeInfinity`:r.byte(2);return;case`Nanos`:r.byte(0),r.zigzag(t.nanos);return;case`Millis`:r.byte(0),r.zigzag(BigInt(t.millis)*IR);return}}case`bigDecimal`:{gS(n)||$(`a BigDecimal`,n,e.options);let t=CS(n);r.zigzag(t.value),r.zigzag(BigInt(t.scale));return}case`json`:{let t;try{t=JSON.stringify(n)}catch{t=void 0}t===void 0&&(OB(n)&&$(`acyclic value`,n,e.options),$(`a JSON-serializable value`,n,e.options)),r.string(t);return}case`option`:{vr(n)||$(`an Option`,n,e.options);let i=n;i._tag===`None`?r.byte(0):(r.byte(1),CV(e,t.value,i.value,r));return}case`result`:{Br(n)||$(`a Result`,n,e.options);let i=n;i._tag===`Success`?(r.byte(0),CV(e,t.success,i.success,r)):(r.byte(1),CV(e,t.failure,i.failure,r));return}case`exit`:{Xf(n)||$(`an Exit`,n,e.options);let i=n;i._tag===`Success`?(r.byte(0),CV(e,t.value,i.value,r)):(r.byte(1),CV(e,t.cause,i.cause,r));return}case`cause`:{bf(n)||$(`a Cause`,n,e.options);let i=n.reasons;r.uvarint(i.length);for(let n of i){let i=r.beginSized();jB(e,t,n,r),r.endSized(i)}return}case`causeReason`:xf(n)||$(`a Cause.Reason`,n,e.options),jB(e,t,n,r);return;case`struct`:(!he(n)||Array.isArray(n))&&$(`an object`,n,e.options),e.positional?HB(e,t,n,r):VB(e,t,n,r);return;case`array`:Array.isArray(n)||$(`an array`,n,e.options),hV(e,t,n,r);return;case`union`:SV(e,t,n,r);return;case`never`:throw Sz(new Lw(t.ast,n,e.options))}}var wV=new Pz;function TV(e,t,n,r,i){let a=i.beginSized();i.byte(r.envelope),r.positional&&i.bytes(r.fingerprint),CV(e,t,n,i),i.endSized(a)}function EV(e,t,n,r,i,a){let o={options:r,positional:i.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:a},s=wV??new Pz,c=s===wV;c&&(wV=void 0),s.reset();let l=Q,u=!1;try{if(n===void 0)Q=0,TV(o,e,t,i,s);else for(let t=0;t<n.length;t++)Q=0,TV(o,e,n[t],i,s);let r=s.out();return u=!0,r}finally{a!==void 0&&(u?sV(a):cV(a)),s.abort(),Q=l,c&&(wV=s)}}function DV(e,t,n,r,i){return EV(e,void 0,t,n,r,i)}function OV(e,t,n,r,i){return EV(e,t,void 0,n,r,i)}function kV(e){return Xf(e)&&rp(e)}var AV=globalThis.Symbol.for(`~effect/encoding/SchemaBinary/absent`);function jV(e,t){let n=oH(e,t);return n!==AV&&t.pos!==t.end&&X(`no leftover bytes`,void 0,t.options),n}function MV(e,t){let n=t.enter(t.uvarint()),r=jV(e,t);return t.exit(n),r}function NV(e,t){if(Zz(e))return oH(e,t);let n=Qz(e),r=t.enter(n===void 0?e._===`null`||e._===`undefined`?0:t.uvarint():n),i=jV(e,t);return t.exit(r),i}var PV=8;function FV(e,t){let n=e.set;if(n!==void 0)return n.has(t)?!0:(n.add(t),!1);let r=e.list;if(r.includes(t))return!0;if(r.length>=PV){let n=e.set=new Set;for(let e=0;e<r.length;e++)n.add(r[e]);n.add(t)}else r.push(t);return!1}function IV(e,t,n,r,i){let a=t.uvarint(),o=Math.floor(i===void 0?a/az:a/16),s=i===void 0?a-o*az:Math.floor((a-o*16)/2),c=i===void 0?t.readUtf8(o):LV(i,a,o,t);e.names.has(c)&&X(`an extra key distinct from declared fields`,c,t.options),FV(r,c)&&X(`unique extra keys`,void 0,t.options);let l=e.extraAll??(t.indexSignatures??=new Lz(t.options)).find(e,c);if(l===void 0){t.rejectUnknownFields&&X(`a key matching an index signature`,c,t.options),VV(s,t);return}Z[Q++]=c;let u=WV(l.layout,l.wireMask,s,t);Q--,u!==AV&&b(n,c,u)}function LV(e,t,n,r){if((t&1)==1)return n>=e.length&&X(`a known back-reference`,void 0,r.options),e[n];let i=r.readUtf8(n);return e.push(i),i}function RV(e){return new Nw([e.name],new Pw(e.annotations))}function zV(e,t){throw Sz(new Iw(e.ast,t))}function BV(e){for(;e.byte()&128;);}function VV(e,t){switch(e){case ZR:t.take(t.uvarint());return;case QR:BV(t);return;case $R:t.take(8);return;case ez:case tz:case iz:return;case nz:BV(t),BV(t);return;case rz:t.take(4);return}}function HV(e){if(e._===`literal`)return HV(e.leaf);switch(e._){case`bool`:return 24;case`number`:return 38;case`int`:return 2;case`i32`:case`u32`:return 64;default:return 1}}function UV(e,t){switch(e){case ez:return!1;case tz:return!0;case QR:return t.numberVarint();case $R:return t.f64();case nz:{let e=t.numberVarint(),n=t.uvarint();return(n===0||n>sz)&&X(`a decimal scale in [1, 8]`,n,t.options),e/lz[n]}}return X(`matching field wire kind`,void 0,t.options)}function WV(e,t,n,r){if(!(t&1<<n))return r.rejectUnknownFields&&X(`matching field wire kind`,n,r.options),VV(n,r),AV;if(n===rz)return e._===`u32`?r.u32le():r.i32le();if(n!==ZR){let t=UV(n,r);return e._===`literal`&&!Uz(e,t)&&X(Wz(e),t,r.options),t}let i=r.enter(r.uvarint()),a=jV(e,r);return r.exit(i),a}function GV(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},i=0,a=0,o,s,c,l=!1,u=e.fields,d=0;for(;t.pos<t.end;){let f=t.fieldTag(),p=Math.floor(f/az),m=f-p*az;if(p===0){l&&X(`unique field ids`,void 0,t.options),l=!0,m!==ZR&&X(`extra field map`,void 0,t.options);let i=t.enter(t.uvarint());JV(e,t,r,n),t.exit(i);continue}let h;if(d<u.length&&u[d].id===p?(h=u[d],d++):(h=e.byId.get(p),h!==void 0&&(d=h.index+1)),h===void 0){t.rejectUnknownFields&&X(`a known field id`,p,t.options),c===void 0?c=new Set:c.has(p)&&X(`unique field ids`,void 0,t.options),c.add(p),VV(m,t);continue}let g=h.index;if(g<32){let e=1<<g;(i&e)!==0&&X(`unique field ids`,void 0,t.options),i|=e}else o===void 0?o=new Set([g]):(o.has(g)&&X(`unique field ids`,void 0,t.options),o.add(g));Z[Q++]=h.name;let ee=WV(h.layout,h.wireMask,m,t);Q--,ee!==AV&&(b(r,h.name,ee),g<32?a|=1<<g:(s??=new Set).add(g))}return KV(e,a,s,t),r}function KV(e,t,n,r){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let i=e.fields,a;for(let e=0;e<i.length;e++){let o=i[e],s=o.index,c=s<32?!!(t&1<<s):n?.has(s)===!0;if(!o.optional&&!c&&((a??=[]).push(RV(o)),r.options.errors!==`all`))break}a!==void 0&&zV(e,a)}function qV(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},i=e.optionalCount+7>>3,a=0;i>0&&(t.pos+i>t.end&&X(`complete value`,void 0,t.options),a=t.pos,t.pos+=i);let o=t.buf,s=e.fields,c=0,l;for(let e=0;e<s.length;e++){let n=s[e];if(n.optional){let e=!!(o[a+(c>>3)]&1<<(c&7));if(c++,!e)continue}Z[Q++]=n.name;let i=n.inline?NV(n.layout,t):MV(n.layout,t);if(Q--,i!==AV)b(r,n.name,i);else if(!n.optional&&((l??=[]).push(RV(n)),t.options.errors!==`all`))break}if(l!==void 0&&zV(e,l),e.extra.length>0){let i=t.uvarint();if(i>t.remaining&&X(`complete value`,void 0,t.options),i>0){let a={list:[],set:void 0};for(let o=0;o<i;o++)IV(e,t,r,a,n)}}return r}function JV(e,t,n,r){let i={list:[],set:void 0};for(;t.pos<t.end;)IV(e,t,n,i,r)}function YV(e,t,n){let r=n.uvarint();if((r&1)==1){let t=(r-1)/2;return t>=e.length&&X(`a known back-reference`,void 0,n.options),e[t]}if(t._===`string`){if(n.dict!==void 0){let i=n.enter(r/2),a=jV(t,n);return n.exit(i),e.push(a),a}let i=n.readUtf8(r/2);return e.push(i),i}let i=n.enter(r/2),a=jV(t,n);return n.exit(i),e.push(a),a}function XV(e,t,n){let r=Array(t),i=[],a=[];for(let o=0;o<t;o++){Z[Q++]=o;let t=n.enter(n.uvarint());r[o]=QV(e,i,a,n),n.exit(t),Q--}return r}function ZV(e,t){let n=t.uvarint(),r=e.fields,i=n&-1073741825;(n>Xz*2-1||i>>>r.length)&&X(`a known row shape`,void 0,t.options);let a=[];(n&Xz)!==0&&a.push(null);for(let e=0;e<r.length;e++)i&1<<e&&a.push(r[e]);return a}function QV(e,t,n,r){let i=e.struct,a={},o=0,s,c=r.uvarint(),l;if(c===0?r.positional&&e.shapes&&(l=ZV(i,r),t.push(l)):(l=t[c-1],l===void 0&&X(`a known row shape`,void 0,r.options)),l!==void 0){for(let t=0;t<l.length;t++){let i=$V(e,n,l[t],a,r);i>=0&&(i<32?o|=1<<i:(s??=new Set).add(i))}r.pos!==r.end&&X(`no leftover bytes`,void 0,r.options)}else{let c=e.shapes?[]:void 0,l=0,u,d,f=!1;for(;r.pos<r.end;){let t=r.uvarint(),p;t===0?(f&&X(`unique field ids`,void 0,r.options),f=!0,p=null):(p=i.byId.get(t),p===void 0?(r.rejectUnknownFields&&X(`a known field id`,t,r.options),d===void 0?d=new Set([t]):d.has(t)?X(`unique field ids`,void 0,r.options):d.add(t)):p.index<32?(l&1<<p.index&&X(`unique field ids`,void 0,r.options),l|=1<<p.index):u===void 0?u=new Set([p.index]):(u.has(p.index)&&X(`unique field ids`,void 0,r.options),u.add(p.index))),c?.push(p);let m=$V(e,n,p,a,r);m>=0&&(m<32?o|=1<<m:(s??=new Set).add(m))}c!==void 0&&t.push(c)}return KV(i,o,s,r),a}function $V(e,t,n,r,i){let a=i.uvarint();if((a&1)==1){if(n==null)return-1;let e=t[n.index],o=(a-1)/2;(e===void 0||o>=e.length)&&X(`a known back-reference`,void 0,i.options);let s=e[o];return s===AV?-1:(b(r,n.name,s),n.index)}let o=i.enter(a/2);if(n===null)return JV(e.struct,i,r),i.exit(o),-1;if(n===void 0)return i.exit(o),-1;let s=e.intern[n.index];(s===qz||s===Jz)&&(i.intern=t[n.index]??=[]),Z[Q++]=n.name;let c=jV(n.layout,i);return Q--,i.intern=void 0,i.exit(o),s===Kz&&(t[n.index]??=[]).push(c),c===AV?-1:(b(r,n.name,c),n.index)}function eH(e,t){let n=e.elements.length,r=e.hasCount?t.uvarint():n;if(e.rest.length===0&&r>n)throw Z[Q++]=n,Sz(new Fw(e.ast,void 0,t.options));if(r<e.minCount)throw Z[Q++]=r,Sz(new Pw(void 0));if(e.hasCount&&r>(e.rest.length>0&&eB(e.rest[0])?XR:t.remaining+YR)&&X(`array count within allocation limit`,r,t.options),r>0){let n=GB(e);if(n!==null)return XV(n,r,t)}let i=Array(r),a=e.uniform;if(a!==void 0){if(e.uniformNumbers)return tH(i,r,t);let n=t.intern;if(t.intern=void 0,n!==void 0){for(let e=0;e<r;e++){Z[Q++]=e;let r=YV(n,a,t);if(r===AV)throw Sz(new Pw(void 0));Q--,i[e]=r}return i}if(Zz(a)){for(let e=0;e<r;e++)Z[Q++]=e,i[e]=oH(a,t),Q--;return i}if(a._===`string`){for(let e=0;e<r;e++)Z[Q++]=e,i[e]=t.dict===void 0?t.readUtf8(t.uvarint()):MV(a,t),Q--;return i}let o=e.uniformPacked,s=e.uniformInline;for(let e=0;e<r;e++){Z[Q++]=e;let n=t.enter(s?o??0:t.uvarint()),r=jV(a,t);if(t.exit(n),r===AV)throw Sz(new Pw(void 0));Q--,i[e]=r}return i}for(let a=0;a<r;a++){let o=mV(e,a,r),s=a<n&&e.elements[a].optional;if(!e.hasCount&&t.remaining===0&&!s&&o._!==`null`&&o._!==`undefined`)throw Z[Q++]=a,Sz(new Pw(void 0));Z[Q++]=a;let c=NV(o,t);if(c===AV)throw s&&X(`known union member`,void 0,t.options),Sz(new Pw(void 0));Q--,i[a]=c}if(!e.hasCount&&t.pos<t.end)throw Z[Q++]=n,Sz(new Fw(e.ast,void 0,t.options));return i}function tH(e,t,n){let r=n.byte();if(r===GR){n.remaining!==t*8&&X(`f64`,void 0,n.options);for(let r=0;r<t;r++)e[r]=n.f64();return e}if(r===qR){for(let r=0;r<t;r++){Z[Q++]=r;let t=n.uvarint(),i=t%16;i>sz&&X(`decimal`,void 0,n.options);let a=dz((t-i)/16);e[r]=i===0?a:a/lz[i],Q--}return e}r!==KR&&X(`f64`,void 0,n.options);for(let r=0;r<t;r++)Z[Q++]=r,e[r]=n.numberVarint(),Q--;return e}function nH(e,t){let n=t.byte();if(n===Y.variant){let n=t.u32le(),r=e.byTag.get(n);if(r===void 0)return t.rejectUnknownFields&&X(`known union member`,n,t.options),t.take(t.remaining),AV;let i=jV(r.payload,t);if(i===AV)return AV;if(!r.tuple)for(let e of r.sentinels)b(i,e.key,e.literal);return i}let r=e.byKind.get(n);return r===void 0?(t.rejectUnknownFields&&X(`known union member`,n,t.options),t.take(t.remaining),AV):jV(r,t)}function rH(e,t){let n=e.byPos[t.uvarint()];n===void 0&&X(`known union member`,void 0,t.options);let r=jV(n.layout,t),i=n.variant;if(i!==void 0&&!i.tuple&&r!==AV)for(let e of i.sentinels)b(r,e.key,e.literal);return r}function iH(e,t){switch(t.byte()){case 0:return kf(aH(jV(e.error,t)));case 1:return Af(aH(jV(e.defect,t)));case 2:return t.remaining!==0&&X(`empty`,void 0,t.options),jf();case 3:return t.remaining!==8&&X(`f64`,void 0,t.options),jf(t.f64());default:return t.take(t.remaining),AV}}function aH(e){if(e===AV)throw Sz(new Pw(void 0));return e}function oH(e,t){t.nesting>=JR&&X(`nesting depth at most ${JR}`,t.nesting+1,t.options),t.nesting++;try{return sH(e,t)}finally{t.nesting--}}function sH(e,t){switch(e._){case`literal`:{let n=oH(e.leaf,t);return Uz(e,n)||X(Wz(e),n,t.options),n}case`bool`:{t.remaining!==1&&X(`bool`,void 0,t.options);let e=t.byte();return e>1&&X(`bool`,void 0,t.options),e===1}case`null`:return t.remaining!==0&&X(`empty`,void 0,t.options),null;case`undefined`:t.remaining!==0&&X(`empty`,void 0,t.options);return;case`number`:{let e=t.remaining;if(e===8)return t.f64();(e===0||e>HR)&&X(`f64`,void 0,t.options);let n=t.numberVarint();if(t.remaining===0)return n;let r=t.byte();return(t.remaining!==0||r===0||r>sz)&&X(`decimal`,void 0,t.options),n/lz[r]}case`int`:return t.numberVarint();case`string`:{let n=t.dict;return n===void 0?t.readUtf8(t.end-t.pos):uV(n,e,t)}case`symbol`:return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case`bytes`:return t.takeCopy(t.end-t.pos);case`bigint`:return t.zigzag();case`i32`:return t.remaining!==4&&X(`a 32-bit integer`,void 0,t.options),t.i32le();case`u32`:return t.remaining!==4&&X(`a 32-bit unsigned integer`,void 0,t.options),t.u32le();case`i64`:return t.remaining!==8&&X(`a 64-bit integer`,void 0,t.options),t.i64();case`u64`:return t.remaining!==8&&X(`a 64-bit unsigned integer`,void 0,t.options),t.u64();case`int64`:{t.remaining!==8&&X(`int64`,void 0,t.options);let n=Number(t.i64()),r=new Date(n);return Number.isNaN(r.getTime())&&X(e.flavor===`date`?`a valid Date`:`a valid DateTime`,n,t.options),e.flavor===`date`?r:JS(n)}case`dateTimeZoned`:{let e=Number(t.i64()),n=t.byte(),r;if(n===0)t.remaining!==4&&X(`time zone`,void 0,t.options),r=t.i32le();else if(n===1)r=t.readUtf8(t.end-t.pos);else return X(`time zone`,void 0,t.options);try{return YS(e,{timeZone:r})}catch{return X(`time zone`,void 0,t.options)}}case`duration`:switch(t.byte()){case 0:return co(t.zigzag());case 1:return oo;case 2:return so;default:return X(`duration`,void 0,t.options)}case`bigDecimal`:{let e=t.zigzag(),n=t.zigzag();return(n>AR||-n>AR)&&X(`safe integer length`,void 0,t.options),_S(e,Number(n))}case`json`:{let e=t.readUtf8(t.end-t.pos);try{return JSON.parse(e)}catch{return X(`json`,void 0,t.options)}}case`option`:{let n=t.byte();return n===0?(t.remaining!==0&&X(`empty`,void 0,t.options),T()):(n!==1&&X(`bool`,void 0,t.options),E(aH(jV(e.value,t))))}case`result`:{let n=t.byte();return n===0?Lr(aH(jV(e.success,t))):(n!==1&&X(`bool`,void 0,t.options),Rr(aH(jV(e.failure,t))))}case`exit`:{let n=t.byte();return n===0?Zf(aH(jV(e.value,t))):(n!==1&&X(`bool`,void 0,t.options),Qf(oH(e.cause,t)))}case`cause`:{let n=t.uvarint(),r=[];for(let i=0;i<n;i++){Z[Q++]=i;let n=t.enter(t.uvarint()),a=iH(e,t);t.exit(n),Q--,a!==AV&&r.push(a)}return t.pos!==t.end&&X(`no leftover bytes`,void 0,t.options),Tf(r)}case`causeReason`:return iH(e,t);case`struct`:return t.positional?qV(e,t):GV(e,t);case`array`:return eH(e,t);case`union`:return t.positional?rH(e,t):nH(e,t);case`never`:throw Sz(new Lw(e.ast,void 0,t.options))}}function cH(e,t,n){let r=t.byte();if(r!==n.envelope&&X(n.expectedEnvelope,r,t.options),n.positional){t.remaining<8&&X(`complete value`,void 0,t.options);let e=t.buf,r=n.fingerprint,i=t.pos;for(let n=0;n<8;n++)e[i+n]!==r[n]&&X(`matching layout fingerprint`,void 0,t.options);t.pos=i+8}let i=jV(e,t);if(i===AV)throw Sz(new Pw(void 0));return i}var lH=new Vz;function uH(e,t,n,r){let i=lH??new Vz,a=i===lH;a&&(lH=void 0),i.reset(t,0,t.length,n,void 0,r,void 0);let o=Q;Q=0;try{let a=i.uvarint();a===0&&X(`nonzero frame length`,void 0,n);let o=i.enter(a),s=cH(e,i,r);return i.exit(o),i.pos!==t.length&&X(`no leftover bytes`,void 0,n),s}finally{Q=o,i.release(),a&&(lH=i)}}function dH(e,t,n,r=!1){return PT({decode:(i,a)=>{try{let o=uH(e,i,a,t);return n!==void 0&&me(o)&&(!r||kV(o))&&(n.value=o),R(o)}catch(e){return e instanceof xz?H(e.issue):Cg(e)}},encode:(n,r)=>{try{return R(OV(e,n,r,t))}catch(e){return e instanceof xz?H(e.issue):Cg(e)}}})}var fH=f(TB);function pH(e,t){return t===!0?fH(e):wB}var mH=f(e=>{let t=J(rB(e)),{exact:n,exitSuccess:r,layout:i,recursive:a}=_B(t.ast);return{target:a?CH(t):t,layout:i,exact:n,exitSuccess:r,recursive:a}});function hH(e){return mH(e.ast)}function gH(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function _H(e,t,n){let r=J($D(e.ast)),i=KO(r),a=e=>()=>(t,n,r)=>e(t,r)?q:i(t,r);return J(new hE([r.ast],a(t),{identifier:`binary value`},void 0,void 0,void 0,void 0,a(n)))}function vH(e,t){return t.onExcessProperty!==`error`}function yH(e,t,n){return _H(e,e=>gH(t,e),n?vH:bH)}function bH(){return!1}function xH(e,t){return Fk()([e],([e])=>{let n=KO(e);return(e,r,i)=>gH(t,e)||kV(e)&&i.onExcessProperty!==`error`?R(e):n(e,i)},{identifier:`binary exit value`})}function SH(e){return _H(e,vH,vH)}function CH(e){let t=J($D(e.ast)),n=new WeakSet;return DA(Fk()([t],([e])=>(t,r,i)=>me(t)&&n.delete(t)?R(t):OB(t)?H(new Lw(r,t,i)):KO(e)(t,i),{identifier:`acyclic value`}),FT({decode:e=>(me(e)&&n.add(e),e),encode:e=>e}))(e)}var wH=class extends Ki()(`effect/rpc/RpcSerialization`){},TH=16777216,EH=new TextEncoder,DH=e=>{let t=e?.maxFrameSize===`unbounded`?void 0:e?.maxFrameSize??TH,n=e?.fingerprintPayloads===!0?e=>pR(e,{fingerprint:!0}):pR,r={fingerprint:!0};return wH.of({contentType:`application/vnd.effect.rpc+schema-binary`,includesFraming:!0,codecFor:n,makeUnsafe:()=>{let e=vR(sR,{...r,maxFrameSize:t}),n=bR(sR,r);return{decode:t=>e.feedSync(typeof t==`string`?EH.encode(t):t),encode:e=>{if(!Array.isArray(e))return n.encode(e);if(e.length!==0)return n.encodeMany(e)}}}})},OH=e=>Jp(wH)(()=>DH(e)),kH=e=>z(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>r_(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),V});return W(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return bg(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*a_(z(()=>i(e)),t)}return yield*__(yg,()=>(t.delete(e),r.delete(e),V))})}}))}),AH=0,jH=W_(function*(e,t){let n=t.spanPrefix,r=t?.supportsAck??!0,a=t?.disableTracing??!1,o=t?.generateRequestId??(()=>AH++),s=yield*n_(),c=O(s,Cp),l=new Map,u=!1;yield*Dp(c,Eg(e=>(u=!0,d(tp(e.id)))));let d=W_(function*(e){let t=Array.from(l.values());l.clear();for(let n of t)n._tag===`Queue`?yield*e._tag===`Success`?Dy(n.queue):Ty(n.queue,e.cause):n.resume(e)},S_),f=e=>{let r=HL(e.successSchema),i=h(e);return(o,s)=>{let c=s?.headers?DC(s.headers):EC,l=s?.context??la();if(!r){let r=t=>p(e,i,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return a?r(void 0):O_(RL(n,e._tag),{kind:`client`,attributes:zL(e._tag,t.spanAttributes)},r)}let u=m(e,i,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:Ax(W(u,Ex))}},p=(e,n,r,a,s,c,d)=>Eg(f=>{if(u)return y_;let p=o(),m=n(e=>t.onFromClient({message:e,context:c}),{_tag:`Request`,id:p,tag:e._tag,payload:a,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:jC(f.getRef(FH),s),...d?{discard:!0}:{}}),h;return x_(vg(t=>{let n=!1,a={_tag:`Effect`,rpc:e,context:c,resume(e){d&&e._tag===`Success`?(n=!0,h?.pollUnsafe()&&t(np)):(t(e),h&&!h.pollUnsafe()&&f.currentDispatcher.scheduleTask(()=>{h.interruptUnsafe(f.id)},0))}};l.set(p,a),h=m.pipe(r?A_(r,{captureStackTrace:!1}):i,I_(f.context)),h.addObserver(e=>{if(e._tag===`Failure`)return l.delete(p),t(e);if(n)return t(np)})}),e=>(l.delete(p),kg(iv(h),g(p,Array.from(e),c))))}),m=W_(function*(e,r,s,c,d,f){if(u)return yield*y_;let p=a?void 0:yield*D_(RL(n,e._tag),{kind:`client`,attributes:zL(e._tag,t.spanAttributes)}),m=ov(),h=o(),ee=ga(m.context,Cp),_=yield*by(d);return yield*Ep(ee,e=>(ky(_),l.has(h)?(l.delete(h),g(h,ip(e)?Array.from(Rf(e.cause)):[],f)):V)),l.set(h,{_tag:`Queue`,rpc:e,queue:_,scope:ee,context:f}),yield*r(e=>t.onFromClient({message:e,context:f}),{_tag:`Request`,id:h,tag:e._tag,payload:s,...p?{traceId:p.traceId,spanId:p.spanId,sampled:p.sampled}:{},headers:jC(m.getRef(FH),c)}).pipe(p?A_(p,{captureStackTrace:!1}):i,h_(e=>(Mf(e)||l.delete(h),Ty(_,e))),b_,M_(ee,{startImmediately:!0})),_}),h=e=>{let t=[];for(let n of e.middlewares.values()){let e=ha(s,`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},g=(e,n,r)=>vg(i=>{let a=ov();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r}).pipe(qg(1e3),I_(a.context)).addObserver(()=>{i(V)})}),ee=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,a=l.get(n);return!a||a._tag!==`Queue`?V:Cy(a.queue,e.values).pipe(r?U(n=>n.length>0?V:t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:a.context})):i,Ig(e=>Ty(a.queue,e)))}case`Exit`:{let t=e.requestId,n=l.get(t);return n?(l.delete(t),n._tag===`Effect`?(n.resume(e.exit),V):e.exit._tag===`Success`?Dy(n.queue):Ty(n.queue,e.exit.cause)):V}case`Defect`:return d(ep(e.defect));case`ClientEnd`:return V}},_;if(t.flatten){let t=new Map;_=function(n,r,i){let a=t.get(n);return a||(a=f(e.requests.get(n)),t.set(n,a)),a(r,i)}}else _={},e.requests.forEach(e=>{b(_,e._tag,f(e))});return{client:_,write:ee}}),MH=0,NH=W_(function*(e,t){let n=MH++,{codecFor:r,run:i,send:a,supportsAck:o,supportsTransferables:s}=yield*IH,c=PH(r),l=Jk(r(ZA())),u=new Map,d=cp(),f=e=>u.has(e)?(u.delete(e),a(n,{_tag:`Interrupt`,requestId:e})):V,{client:p,write:m}=yield*jH(e,{...t,supportsAck:o,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),i=s?IL():void 0,o=ov(),l={rpc:r,context:i?fa(o.context,FL,i):o.context,schemas:c(r),discard:t.discard===!0};return u.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(a_(l.context),Bg,U(e=>hp(d)?(u.delete(t.id),y_):a(n,{...t,id:t.id,payload:e,headers:Object.entries(t.headers)},i&&i.readUnsafe())),h_(e=>Mf(e)?V:B(()=>u.delete(t.id))))}case`Ack`:return u.get(t.requestId)?a(n,{_tag:`Ack`,requestId:t.requestId}):V;case`Interrupt`:return f(t.requestId);case`Eof`:return V}}});return yield*i(n,e=>{switch(e._tag){case`Chunk`:{let t=iR(e.requestId),n=u.get(t);if(!n||yr(n.schemas.decodeChunk))return V;let r=n.schemas.decodeChunk.value;return C_(i=>i(r(e.values).pipe(a_(n.context),Bg,U(e=>m({_tag:`Chunk`,clientId:0,requestId:t,values:e})))).pipe(h_(e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:Qf(e)}).pipe(kg(Lf(e)?V:$g(Gg(f(t)),up(d))))),Rg(e=>!Lf(e),()=>V)))}case`Exit`:{let t=iR(e.requestId),n=u.get(t);return n?(u.delete(t),n.discard&&e.exit._tag===`Success`?m({_tag:`Exit`,clientId:0,requestId:t,exit:np}):(n.discard?n.schemas.decodeDiscardExit:n.schemas.decodeExit)(e.exit).pipe(a_(n.context),Bg,t_({onSuccess:e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:Qf(e)})}))):V}case`Defect`:return u.clear(),m({_tag:`Defect`,clientId:0,defect:l(e.defect)});case`ClientProtocolError`:{let t=$f(e.error),n=e.requestIds===void 0?Array.from(u.keys()):e.requestIds.map(iR).filter(e=>u.has(e));for(let e of n)u.delete(e);return pg(n,e=>m({_tag:`Exit`,clientId:0,requestId:e,exit:t})).pipe(S_)}default:return V}}).pipe(Ig(K_),b_,N_),yield*p_(()=>_p(d,void 0)),p}),PH=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=UL(n.successSchema),a=O(n.annotations,QL),o=ZL(n),s;return r={decodeChunk:Ar(i,t=>Wk(e(yA(t.success)),a)),encodePayload:Xk(e(n.payloadSchema),a),decodeExit:Wk(e(o),a),decodeDiscardExit:t=>(s??=Wk(e(aj(fA,o.error,o.defect)),a))(t)},t.set(n,r),r}},FH=k(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>EC}),IH=class extends Ki()(`effect/rpc/RpcClient/Protocol`){static make=kH},LH=e=>IH.make(W_(function*(t,n){let r=yield*pL,a=yield*wH,o=yield*o_(VH),s=new Map,c=yield*r.writer,u=a.makeUnsafe(),d=yield*zH(z(()=>c.write(u.encode(aR))),e),f=Kg(e?.onPingTimeout??V,{log:!0,message:`RpcClient onPingTimeout hook failed`}),p,m=e=>{let r=pg(Array.from(n),n=>t(n,e));return e._tag!==`Defect`&&e._tag!==`ClientProtocolError`?r:(s.clear(),S_(r))},h=e=>(p=e,m({_tag:`ClientProtocolError`,error:e})),g=e=>{try{let n=u.decode(e);if(n.length===0)return V;d.onFrame();let r=0;return mg({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return V;if(Object.hasOwn(e,`requestId`)){let n=e.requestId,r=s.get(n);if(r!==void 0)return e._tag===`Exit`&&s.delete(n),t(r,e)}return m(e)},step:l})}catch(e){return m({_tag:`ClientProtocolError`,error:new rR({reason:new nR({message:`Error decoding message`,cause:e})})})}};yield*z(()=>{u=a.makeUnsafe(),d.reset();let e=!1;return bg(function*(){let{pull:t}=yield*r.reader;for(p=void 0,e=!0,br(o)&&(yield*o.value.onConnect);;){let e=yield*t;for(let t=0;t<e.length;t++)yield*g(e[t])}}).pipe(u_,$g(d.timeout),kg(()=>e?f:V),kg(()=>H(new EL({reason:new bL({cause:Error(`ping timeout`)})}))))}).pipe(br(o)?m_(o.value.onDisconnect):i,Hg(t=>{let n=Ff(t),r=Vr(n),i=new rR({reason:r?n.success.reason:new nR({message:`Unknown socket error`,cause:Pf(t)})});return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?(e.onTransientError?.(i)??V).pipe(Kg({log:!0,message:`RpcClient onTransientError hook failed`})):h(i)}),Wg(e?.retryPolicy??RH,e=>h(new rR({reason:e.reason}))),J_({module:`RpcClient`,method:`makeProtocolSocket`}),N_);let ee=e=>z(()=>{let t=u.encode(e);return t===void 0?V:Bg(c.write(t))});return{send(e,t){return p?H(p):(t._tag===`Interrupt`&&s.delete(t.requestId),t._tag===`Request`?(s.set(t.id,e),h_(ee(t),()=>B(()=>s.delete(t.id)))):ee(t))},supportsAck:!0,supportsTransferables:!1,codecFor:a.codecFor}})),RH=Bh([Hh(500,1.5),Gh(5e3)]),zH=W_(function*(e,t){let n=yield*qf,r=t?.pingInterval??`5 seconds`,i=fo(t?.pingTimeout??r),a=n.currentTimeMillisUnsafe(),o=!1,s=vv(),c=()=>{a=n.currentTimeMillisUnsafe(),o=!1};return yield*z(()=>o&&n.currentTimeMillisUnsafe()-a>i?s.open:(o=!0,e)).pipe(Xg(r),Gg,w_,b_,N_),{timeout:s.await,reset:()=>{c(),s.closeUnsafe()},onFrame:c}}),BH=e=>Xp(IH)(LH(e)),VH=class extends Ki()(`effect/rpc/RpcClient/ConnectionHooks`){},HH=()=>(e,t)=>{let n=Ki()(e),r=Xp(n,t.makeEffect??NH(t.group,{...t,flatten:!0}));n.runtime=(t.runtime??zI)(typeof t.protocol==`function`?e=>am(r,lm(t.protocol(e))):am(r,lm(t.protocol))),n.mutation=ZI(r=>{let i=t.group.requests.get(r);return n.runtime.fn()(W_(function*({headers:e,payload:t,reactivityKeys:i}){let a=(yield*n)(r,t,{headers:e});return yield*i?FF(a,i):a})).pipe(sL({key:`AtomRpc:mutation:${JSON.stringify([e,r])}`,schema:AF({success:i.successSchema,error:UH(i)})}))});let i=ZI(e=>{let{headers:r,payload:i,reactivityKeys:a,tag:o,timeToLive:s}=e,c=t.group.requests.get(o),l=HL(c.successSchema),u=l?n.runtime.pull(Ax(n.use(e=>R(e(o,i,{headers:r}))))):n.runtime.atom(n.use(e=>e(o,i,{headers:r})));return a&&(u=n.runtime.factory.withReactivity(a)(u)),!l&&e.serializationKey&&(u=sL(u,{key:`AtomRpc:${e.tag}:${e.serializationKey}`,schema:AF({success:c.successSchema,error:UH(c)})})),s&&(u=to(s)?yI(u,s):QI(u)),u});return n.query=(e,t,n)=>{let r={tag:e,payload:t,headers:n?.headers?DC(n.headers):void 0,reactivityKeys:n?.reactivityKeys,timeToLive:n?.timeToLive===void 0?void 0:Ga(n.timeToLive),serializationKey:n?.serializationKey};return i(r)},n},UH=e=>CA([e.errorSchema,...Array.from(e.middlewares,e=>e.error),rR]),WH={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return GH({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[e,n]of r.requests)t.set(e,n);for(let[e,t]of r.annotations.mapUnsafe)n.set(e,t)}return GH({requests:t,annotations:ia(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return GH({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return GH({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return bg(function*(){let n=yield*n_(),r=dg(e)?yield*e:e,i=new Map;return t.requests.forEach((e,t)=>{i.set(e.key,{tag:e._tag,handler:r[t],context:n})}),ia(i)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return GH({requests:t,annotations:this.annotations})},toLayer(e){return Qp(this.toHandlers(e))},of:i,toLayerHandler(e,t){let n=this;return Qp(bg(function*(){let r=yield*n_(),i=dg(t)?yield*t:t,a=new Map,o=n.requests.get(e);return a.set(o.key,{handler:i,context:r}),ia(a)}))},accessHandler(e){return r_(t=>{let n=this.requests.get(e),{handler:r,context:i}=ha(t,n.key);return R((e,t)=>{t.rpc=n;let a=r(e,t),o=eR(a)?a.value:a;return dg(o)?i_(o,i):Gx(o,i)})})},annotate(e,t){return GH({requests:this.requests,annotations:fa(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(da(e,t))},annotateMerge(e){return GH({requests:this.requests,annotations:xa(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(xa(e,r.annotations)));return GH({requests:t,annotations:this.annotations})}},GH=e=>Object.assign(function(){},WH,{requests:e.requests,annotations:e.annotations}),KH=(...e)=>GH({requests:new Map(e.map(e=>[e._tag,e])),annotations:la()}),qH=`~effect/rpc/RpcMiddleware`,JH=()=>(e,t)=>{let n=Ft(),r;n!==0&&(It(2),r=new globalThis.Error,It(n));function i(){}let a=i;return Object.setPrototypeOf(i,Object.getPrototypeOf(Ki(e))),i.key=e,Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[qH]=qH,a.error=t?.error??aA,a.requiredForClient=t?.requiredForClient??!1,i},YH=`~effect/SynchronizedRef`,XH={...Jt,[YH]:YH,toJSON(){return{_id:`SynchronizedRef`,value:this.backing.ref.current}}},ZH=e=>{let t=Object.create(XH);return t.semaphore=Zy(1),t.backing=dM(e),t},QH=e=>B(()=>ZH(e)),$H=e=>e.backing.ref.current,eU=e=>B(()=>$H(e)),tU=r(2,(e,t)=>e.semaphore.withPermit(fM(e.backing,t))),nU=r(2,(e,t)=>e.semaphore.withPermit(z(()=>W(t($H(e)),([t,n])=>(e.backing.ref.current=n,t))))),rU=r(2,(e,t)=>e.semaphore.withPermit(pM(e.backing,t)));export{bN as $,pr as $a,Nf as $i,Lg as $n,yh as $r,eE as $t,YF as A,ti as Aa,dp as Ai,mx as An,u_ as Ar,_j as At,oF as B,Sr as Ba,ip as Bi,Cv as Bn,S_ as Br,$k as Bt,tL as C,Ni as Ca,tm as Ci,Mx as Cn,c_ as Cr,qA as Ct,uL as D,Ri as Da,wp as Di,Kx as Dn,V_ as Dr,Lk as Dt,lL as E,Ii as Ea,Ap as Ei,Bx as En,B_ as Er,hA as Et,CF as F,Ir as Fa,cp as Fi,qv as Fn,Ag as Fr,Kk as Ft,qP as G,Ar as Ga,Yf as Gi,f_ as Gn,Tg as Gr,eA as Gt,mF as H,yr as Ha,Zf as Hi,wv as Hn,V as Hr,LA as Ht,fF as I,Pr as Ia,gp as Ii,Gv as In,Vg as Ir,Uk as It,fP as J,Cr as Ja,If as Ji,Ng as Jn,ug as Jr,nA as Jt,GP as K,xr as Ka,Df as Ki,fg as Kn,ig as Kr,xj as Kt,hF as L,jr as La,_p as Li,Jv as Ln,qg as Lr,GA as Lt,TF as M,Hr as Ma,fp as Mi,xb as Mn,R as Mr,PA as Mt,_F as N,D as Na,pp as Ni,ab as Nn,z as Nr,CA as Nt,DI as O,Di as Oa,Tp as Oi,yx as On,U_ as Or,lA as Ot,sF as P,Gr as Pa,lp as Pi,Kv as Pn,B as Pr,Wk as Pt,EN as Q,dr as Qa,wf as Qi,Ig as Qn,lh as Qr,nE as Qt,uF as R,wr as Ra,Qf as Ri,Xv as Rn,gg as Rr,HA as Rt,zI as S,xi as Sa,cm as Si,jx as Sn,a_ as Sr,yA as St,eL as T,li as Ta,Dp as Ti,Hx as Tn,F_ as Tr,oj as Tt,yF as U,br as Ua,np as Ui,Tv as Un,Eg as Ur,xA as Ut,DF as V,Dr as Va,rp as Vi,Sv as Vn,C_ as Vr,Rk as Vt,QP as W,Fr as Wa,Jf as Wi,iv as Wn,k_ as Wr,tA as Wt,LN as X,Nr as Xa,Cf as Xi,v_ as Xn,Gh as Xr,ZT as Xt,PN as Y,E as Ya,Lf as Yi,Pg as Yn,cg as Yr,AA as Yt,FN as Z,fr as Za,Sf as Zi,vg as Zn,Kh as Zr,iE as Zt,dL as _,ki as _a,qp as _i,Lx as _n,W as _r,zA as _t,rU as a,ba as aa,xh as ai,aE as an,he as ao,H as ar,cM as at,iL as b,_i as ba,om as bi,px as bn,__ as br,iA as bt,HH as c,Hi as ca,ph as ci,$D as cn,u as co,W_ as cr,Hj as ct,YL as d,Li as da,dh as di,QS as dn,P_ as dr,kj as dt,Pf as ea,mh as ei,sE as en,mr as eo,Fg as er,aN as et,PL as f,Fi as fa,uh as fi,JS as fn,bg as fr,Oj as ft,KI as g,ui as ga,$p as gi,Wx as gn,G_ as gr,ZA as gt,ZI as h,Pi as ha,um as hi,vx as hn,K_ as hr,dA as ht,nU as i,fa as ia,bh as ii,tE as in,ue as io,Mg as ir,sM as it,OF as j,ii as ja,vp as ji,Ax as jn,Zg as jr,MA as jt,ZF as k,Qr as ka,up as ki,Nx as kn,l_ as kr,mA as kt,BH as l,Bi as la,_h as li,_w as ln,t as lo,pg as lr,Vj as lt,cL as m,Ei as ma,sh as mi,Px as mn,dg as mr,vA as mt,QH as n,po as na,ch as ni,$T as nn,Ve as no,Cg as nr,QM as nt,JH as o,Ui as oa,fh as oi,cE as on,me as oo,xg as or,aM as ot,kL as p,Ti as pa,oh as pi,zx as pn,y_ as pr,bA as pt,AP as q,T as qa,Ef as qi,kg as qn,ag as qr,NA as qt,tU as r,Ki as ra,gh as ri,lE as rn,v as ro,m_ as rr,lM as rt,KH as s,Oi as sa,Sh as si,rE as sn,r as so,U as sr,oM as st,eU as t,Bo as ta,hh as ti,YD as tn,Mt as to,n_ as tr,_N as tt,OH as u,wi as ua,vh as ui,XS as un,j_ as ur,Dj as ut,QI as v,bi as va,rm as vi,G as vn,zg as vr,VA as vt,$I as w,fi as wa,Cp as wi,kx as wn,R_ as wr,TA as wt,EI as x,Vi as xa,Gp as xi,bx as xn,jg as xr,wA as xt,kI as y,hi as ya,am as yi,Dx as yn,yg as yr,bj as yt,pF as z,Tr as za,tp as zi,Uv as zn,wg as zr,RA as zt};
14
+ `);r=n??tT(e)??Yw(Sw(e.ast),e);break;default:r=n??Gw(e)}return t?`${r}\n at ${t}`:r}function tT(e){if(e._tag===`Pointer`||e._tag===`Composite`)return;if(e._tag===`Encoding`)return tT(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function nT(e){let t;for(let n of e.reasons){if(!Sf(n)||!Ow(n.error))return;t??=n.error}return t}function rT(e,t){let n=nT(e);if(n===void 0)throw Error(t,{cause:e});return n}var iT=(e,t,n)=>{switch(e._tag){case`Passthrough`:return R(t);case`Transform`:return R(Ar(t,e.transform));case`TransformOptional`:return R(e.transform(t));case`TransformEffect`:return yr(t)?_g:Y_(e.transform(t.value,n),E);case`TransformOptionalEffect`:return e.transform(t,n)}},aT=e=>Object.assign(Object.create(t),e),oT=(e,t)=>pT((n,r)=>Q_(iT(e,n,r),e=>iT(t,e,r))),sT=r(2,(e,t)=>{if(e._tag===`Passthrough`)return t;if(t._tag===`Passthrough`)return e;switch(e._tag){case`Transform`:switch(t._tag){case`Transform`:return uT(n=>t.transform(e.transform(n)));case`TransformOptional`:return fT(n=>t.transform(Ar(n,e.transform)));case`TransformEffect`:return dT((n,r)=>t.transform(e.transform(n),r));case`TransformOptionalEffect`:return oT(e,t)}case`TransformOptional`:switch(t._tag){case`Transform`:return fT(n=>Ar(e.transform(n),t.transform));case`TransformOptional`:return fT(n=>t.transform(e.transform(n)));case`TransformEffect`:case`TransformOptionalEffect`:return oT(e,t)}case`TransformEffect`:switch(t._tag){case`Transform`:return dT((n,r)=>Y_(e.transform(n,r),t.transform));case`TransformOptional`:case`TransformOptionalEffect`:return oT(e,t);case`TransformEffect`:return dT((n,r)=>Q_(e.transform(n,r),e=>t.transform(e,r)))}case`TransformOptionalEffect`:return oT(e,t)}}),cT=aT({_tag:`Passthrough`});function lT(){return cT}function uT(e){return aT({_tag:`Transform`,transform:e})}function dT(e){return aT({_tag:`TransformEffect`,transform:e})}function fT(e){return aT({_tag:`TransformOptional`,transform:e})}function pT(e){return aT({_tag:`TransformOptionalEffect`,transform:e})}function mT(){return fT(()=>T())}function hT(e){return pT(t=>{let n=Pr(t,le);return br(n)?R(n):Y_(e,E)})}function gT(){return uT(globalThis.String)}function _T(){return uT(globalThis.Number)}function vT(e){return dT((t,n)=>wg({try:()=>JSON.parse(t,e?.reviver),catch:()=>new Rw({expected:`a valid JSON string`},t,n)}))}function yT(e){return dT((t,n)=>wg({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new Rw({expected:`a JSON-serializable value`},t,n)}))}function bT(e){let t=e?.separator??`,`,n=e?.keyValueSeparator??`=`,r=e?.trim??!1,i=e?.keepEmptyValues??!1;return uT(e=>e.split(t).reduce((e,t)=>{let a,o;if(n===``)a=t.slice(0,1),o=t.slice(1,2);else{let r=t.indexOf(n);if(r===-1)return e;a=t.slice(0,r),o=t.slice(r+n.length)}return r&&(a=a.trim(),o=o.trim()),a===``||o===``&&!i||b(e,a,o),e},{}))}function xT(e){let t=e?.separator??`,`,n=e?.keyValueSeparator??`=`;return uT(e=>Object.entries(e).map(([e,t])=>`${e}${n}${t}`).join(t))}function ST(e){let t=e?.separator??`,`;return uT(e=>e===``?[]:e.split(t))}function CT(){return uT(PS)}function wT(){return dT((e,t)=>X_(Dg(FS(e)),()=>new Rw({expected:`a valid Base64 string`},e,t)))}function TT(){return uT(encodeURIComponent)}function ET(){return dT((e,t)=>{try{return R(globalThis.decodeURIComponent(e))}catch{return H(new Rw({expected:`a valid URI component`},e,t))}})}var DT=Symbol.for(`~effect/Schema/content`);function OT(e,t){return Object.defineProperty(e,DT,{value:t}),e}var kT=class extends n{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new kT(this.encode,this.decode)}},AT=`~effect/SchemaTransformation/Transformation`,jT=class extends n{[AT]=AT;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new jT(this.encode,this.decode)}};function MT(e){return v(e,AT)&&e[AT]===AT}var NT=e=>MT(e)?e:new jT(e.decode,e.encode);function PT(e){return new jT(dT(e.decode),dT(e.encode))}function FT(e){return new jT(uT(e.decode),uT(e.encode))}function IT(e){return new jT(bT(e),xT(e))}var LT=new jT(lT(),lT());function RT(){return LT}var zT=new jT(_T(),gT()),BT=e=>he(e)&&typeof e.message==`string`,VT=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:GT(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},HT=e=>{try{let t=Tt(e);return t===void 0?x(e):JSON.parse(t)}catch{return x(e)}},UT=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},WT=e=>{let t=new WeakSet,n=r=>{if(ve(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=UT(r,e,n);return t.delete(r),i}return HT(r)};return n},GT=e=>BT(e)?VT(e):e,KT=e=>FT({decode:GT,encode:WT(e)}),qT=new jT(wT(),CT()),JT=new jT(ET(),TT());function YT(e){return new jT(vT(e??{}),OT(yT(e),{mediaType:`application/json`,preserveSchema:e?.reviver===void 0&&e?.replacer===void 0}))}function XT(e){return t=>t._tag===e}var ZT=XT(`Declaration`),QT=XT(`Never`),$T=XT(`String`),eE=XT(`Number`),tE=XT(`Symbol`),nE=XT(`Literal`),rE=XT(`UniqueSymbol`),iE=XT(`Enum`),aE=XT(`TemplateLiteral`),oE=XT(`Arrays`),sE=XT(`Objects`),cE=XT(`Union`),lE=XT(`Suspend`),uE=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},dE={},fE=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},pE=`~effect/Schema`,mE=class{[pE]=pE;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},hE=class extends mE{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>{if(t===K)return ww;e??=this.run(this.typeParameters);try{return e(t,this,n)}catch(e){return Cg(e)}}}_rebuild(e,t,n,r,i){let a=BD(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new hE(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},gE=new class extends mE{_tag=`Null`;getParser(){return rO(this,null)}getExpected(){return`null`}},_E=class extends mE{_tag=`Undefined`;getParser(){return rO(this,void 0)}toCodecJson(){return DD(this,[vE])}getExpected(){return`undefined`}},vE=new uE(gE,new jT(uT(()=>void 0),uT(()=>null))),yE=new _E,bE=new class extends mE{_tag=`Void`;getParser(){let e=Cw(void 0);return t=>t===K?ww:e}toCodecJson(){return DD(this,[vE])}getExpected(){return`void`}},xE=new class extends mE{_tag=`Never`;getParser(){return iO(this,fe)}getExpected(){return`never`}},SE=new class extends mE{_tag=`Unknown`;getParser(){return iO(this,pe)}getExpected(){return`unknown`}},CE=class extends mE{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${x(e)}`);this.literal=e}getParser(){return rO(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?wE(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:wE(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function wE(e){let t=globalThis.String(e.literal);return DD(e,[new uE(new CE(t),new jT(uT(()=>e.literal),uT(()=>t)))])}var TE=new class extends mE{_tag=`String`;getParser(){return iO(this,re)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&pO(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},EE=class extends mE{_tag=`Number`;getParser(){return iO(this,ie)}matchKey(e,t){return this._match(cO,e,t)}matchPart(e,t){return this._match(sO,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:pO(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(DE(this.checks,`effect/schema/isFinite`)||DE(this.checks,`effect/schema/isInt`))?this:DD(this,[SD])}toCodecStringTree(){return this.toCodecJson()===this?DD(this,[dO]):DD(this,[fO])}getExpected(){return`number`}};function DE(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&DE(e.checks,t))}var OE=new EE,kE=new class extends mE{_tag=`Boolean`;getParser(){return iO(this,ae)}getExpected(){return`boolean`}},AE=class extends mE{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(YD(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(YD(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new Fw(n,t[o],i),a=new Nw([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return H(new Iw(n,[a],t,i))}return e.issues?H(new Iw(n,e.issues,t,i)):Cw(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:[],issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:Qu(t.concurrency),f=d===1?NE(i,e,0,u):PE(i,e,{concurrency:d,end:u});if(!f)return c(i);if(L(f))return Q_(f,()=>c(i));let p=!0;return z(()=>p?(p=!1,U(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===K)return ww;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):H(new Lw(n,e,a))}catch(e){return Cg(e)}}}_rebuild(e,t,n){let r=BD(this.elements,e),i=BD(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new AE(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function jE(e,t,n,r){if(n._tag===`Failure`)return FE(e,e.ast,r,n);let i=n===q?t:n[S];if(i!==K)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(YD(t.ast))return;let n=new Nw([r],new Pw(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return $f(new Iw(e.ast,[n],e.input,e.options))}}var ME={onItem(e,t,n){let r=n<e.len?t:K;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:jE},NE=$u()(ME),PE=td()(ME),FE=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=nT(r.cause);if(i===void 0)return Qf(Nf(r.cause,r=>new Iw(t,[new Nw([n],r)],e.input,e.options)));let a=new Nw([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return $f(new Iw(t,[a],e.input,e.options))},IE=`[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?`;function LE(e,t,n=dE){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(aO(eO(t)))}var RE=class{name;type;constructor(e,t){this.name=e,this.type=t}};function zE(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(zE);default:return!1}}function BE(e){let t=kD(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(BE);default:return!1}}function VE(e){return zE(e)&&BE(e)}var HE=class{parameter;type;constructor(e,t){if(!VE(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,YD(t)||t.encoding!==void 0&&YD(eO(t)))throw Error("Cannot use `Schema.optionalKey` or `Schema.optional` with index signatures. Index signatures already allow keys to be absent; use `Schema.UndefinedOr` to allow `undefined` values.")}},UE=class extends mE{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return iO(n,de);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(aO(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return FE(t,n,i,s)??np;let c=s===q?o:s[S];if(a!==K&&c!==K){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return np;b(t.out,a,c)}return np},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!L(t))return U(Mg(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return FE(e,n,r,a)??np;let o=a===q?r:a[S],s=e.input[r],l=i.parserValue(s,e.options);return L(l)?t(e,r,o,s,l):U(Mg(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return L(a)?t(e,n,n,i,a):U(Mg(a),r=>t(e,n,n,i,r))},u=i?td()({onItem:(e,[t,n])=>n.is.parameter===TE?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return ev(function*(t,d){if(t===K)return K;if(typeof t!=`object`||!t||Array.isArray(t))return yield*H(new Lw(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,g=d.onExcessProperty===`error`,ee=d.concurrency===void 0?1:Qu(d.concurrency),_=i&&g?n.indexSignatures.map(e=>LE(f,e.parameter,d)):void 0;if(g){let r=_?new Set(e):e;if(_)for(let e of _)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new Fw(n,f[a],d),r=new Nw([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*H(new Iw(n,[r],t,d))}}}if(r){let e=ee===1?KE(m,a):qE(m,a,{concurrency:ee});e&&(yield*e)}if(i&&ee===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===TE?l:c,r=_?.[e]??(t.is.parameter===TE?Object.keys(f):LE(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!L(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=ji();for(let t=0;t<i;t++){let n=o[t],r=_?.[t]??(n.is.parameter===TE?Object.keys(f):LE(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:ee});t&&(yield*t)}return m.issues?yield*H(new Iw(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return U(Mg(n),n=>{let i={...e,out:{...e.out}},o=WE(i,r,n);if(o)return o;let s=()=>Cw(i.out),c=KE(i,a.slice(t+1));return c?Q_(c,s):s()})};return(e,t)=>{if(e===K)return ww;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&Qu(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return H(new Lw(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=oD(i,s),l=c?i[s]:K,d=n.parser(l,t);if(!L(d))return u(o,e,d);if(d===q){c&&b(a,s,l);continue}let f=WE(o,n,d);if(f)return f}}catch(e){return Cg(e)}return Cw(a)}}_rebuild(e,t,n,r){let i=BD(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new RE(t.name,n)}),a=BD(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new HE(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new UE(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function WE(e,t,n){if(n._tag===`Failure`)return FE(e,e.ast,t.name,n);if(n===q)return;let r=n[S];if(r!==K)b(e.out,t.name,r);else if(delete e.out[t.name],!YD(t.type)){let n=new Nw([t.name],new Pw(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return $f(new Iw(e.ast,[n],e.input,e.options))}}var GE={onItem(e,t){if(!oD(e.input,t.name))return t.parser(K,e.options);let n=e.input[t.name];return b(e.out,t.name,n),t.parser(n,e.options)},step:WE},KE=$u()(GE),qE=td()(GE);function JE(e,t){return e?t?[...e,...t]:e:t}function YE(e,t,n){return new UE(Reflect.ownKeys(e).map(t=>new RE(t,e[t].ast)),[],n,t)}function XE(e){return e.ast}function ZE(e,t=void 0){return new AE(!1,e.map(e=>e.ast),[],void 0,t)}function QE(e,t,n){return new cD(e.map(XE),t,void 0,n)}function $E(e){if(e.encoding)throw Error(`mutable does not support encodings`);return new AE(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var eD=p(e=>{for(;;){if(lE(e))return SE;let t=e.encoding;if(!t)return e.recur?.(eD,i)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==i))return SE;e=t[t.length-1].to}});function tD(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(tD)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function nD(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[bw];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!YD(t)){if(nE(t))return[{key:e.name,literal:t.literal}];if(rE(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!YD(e)){if(nE(e))return[{key:t,literal:e.literal}];if(rE(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>nD(eD(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return nD(e.thunk())}}var rD=new WeakMap,iD=Object.freeze([]),aD=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,oD=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function sD(e){let t=rD.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=eD(c);if(QT(l))continue;if(nE(l)||rE(l)){a??=new Map;let e=nE(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=nD(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=tD(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??iD);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??iD;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(ge(e)){let n=oD(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??iD;if(t)return o}return iD}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=aD(t);if(!ge(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=oD(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=oD(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=oD(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(aD(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return rD.set(e,t),t}var cD=class extends mE{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===K)return ww;let i=(o??=sD(n.types))(e,r);if(i.length===0)return H(new Bw(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:L(r)?lD(n,r.cause,e,t):uD(n,r,e,t)}return dD(n,a,i,e,t)}}_rebuild(e,t,n){let r=BD(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new cD(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=eO(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(nE);if(t.length>0)return`${hD(n.isMutable)}[ ${t.map(t=>e(t)+gD(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>nE(e.type));if(t.length>0)return`{ ${t.map(t=>`${hD(t.type.context?.isMutable)}${bt(t.name)}${gD(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function lD(e,t,n,r){let i=nT(t);return i?$f(new Bw(e,[i],n,r)):Qf(t)}function uD(e,t,n,r){return Ig(t,t=>lD(e,t,n,r))}function dD(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=pD(a,n);if(!o)return a.out?a.out:H(new Bw(e,a.issues??[],r,i));if(L(o))return fD(o,a);let s=!0;return z(()=>s?(s=!1,fD(o,a)):dD(e,t,n,r,i))}function fD(e,t){return Q_(e,e=>t.out===q?R(t.input):t.out?t.out:H(new Bw(t.ast,t.issues??[],t.input,t.options)))}var pD=$u()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=nT(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),$f(new Vw(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return np}}}),mD=new cD([new CE(`Infinity`),new CE(`-Infinity`),new CE(`NaN`)]);function hD(e){return e?``:`readonly `}function gD(e){return e?`?`:``}var _D=class extends n{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new _D(this.run,{...this.annotations,...e},this.aborted)}abort(){return new _D(this.run,this.annotations,!0)}and(e,t){return new vD([this,e],t)}},vD=class extends n{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new vD(this.checks,{...this.annotations,...e})}and(e,t){return new vD([this,e],t)}};function yD(e,t,n=!1){return new _D((t,n,r)=>Ww(n,e(t,n,r),t,r),t,n)}function bD(e){return yD(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var xD=MD(OE,[bD()]),SD=new uE(new cD([xD,mD]),new jT(_T(),uT(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function CD(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return yD(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var wD=new WeakMap;function TD(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&wD.set(n,ED(e)),n}function ED(e){let t=wD.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return wD.set(e,n),n}function DD(e,t){return e.encoding===t?e:TD(e,{encoding:t})}function OD(e,t){if(e.context===t)return e;let n=ED(e);return n.context===t&&n.encoding===e.encoding?n:TD(e,{context:t})}function kD(e){return e.encoding?kD(e.encoding[e.encoding.length-1].to):e}function AD(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return jD(e,pi(e.checks.slice(0,-1),n.annotate(t)))}return TD(e,{annotations:{...e.annotations,...t}})}function jD(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:TD(e,{checks:t})}function MD(e,t){return jD(e,JE(e.checks,t))}function ND(e,t){let n=t(e.to);return n===e.to?e:new uE(n,e.transformation)}function PD(e,t){let n=e,r=n[n.length-1],i=ND(r,t);return i===r?e:pi(e.slice(0,e.length-1),i)}function FD(e){return t=>t.encoding?DD(t,PD(t.encoding,e)):t}function ID(e,t){return FD(e=>OD(e,t))(e)}function LD(e){function t(n){return n.encoding?DD(n,PD(n.encoding,t)):e(n)}return f(t)}function RD(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:DD(r,PD(r.encoding,n))}return e(r)}return p(n)}function zD(e,t,n){let r=new uE(e,t);return DD(n,n.encoding?[...n.encoding,r]:[r])}function BD(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function VD(e,t){return OD(e,e.context?new fE(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new fE(!1,!1,void 0,t))}var HD=p(e=>UD(OD(e,e.context?e.context.isOptional===!1?new fE(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new fE(!0,!1)))),UD=FD(HD),WD=f(e=>HD(new cD([e,yE])));function GD(e,t){return OD(e,e.context?new fE(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new fE(!1,!1,t))}function KD(e,t,n){return zD(e,n,t)}function qD(e){let t=[],n=[];function r(e){t.includes(e)||t.push(e)}function i(e){switch(e._tag){case`Literal`:se(e.literal)&&r(e.literal);return;case`UniqueSymbol`:r(e.symbol);return;case`Enum`:for(let[,t]of e.enums)r(t);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)i(e.types[t]);return;default:n.push(e)}}return i(e),{literals:t,parameters:n}}function JD(e,t){let{literals:n,parameters:r}=qD(e);return new UE(n.map(e=>new RE(e,t)),r.map(e=>new HE(e,t)))}function YD(e){return e.context?.isOptional??!1}function XD(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(XD)}function ZD(e){function t(e){return XD(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return gi(n)?n:void 0}function QD(e){let t=!0;function n(e){return t=t&&!e.encoding&&!lE(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var $D=p(e=>{let t=ED(e);if(t!==e){let n=$D(t);return n===t&&e.encoding===void 0?e:OD(n,e.context)}let n=`recur`in e?e.recur($D):e;if(`encodingChecks`in n&&n.encodingChecks){let t=QD(e)?n.encodingChecks:oE(n)||sE(n)||ZT(n)&&n.typeParameters.length>0?ZD(n.encodingChecks):void 0;return TD(n,{encodingChecks:void 0,checks:JE(n.checks,t)})}return n}),eO=p(e=>$D(nO(e)));function tO(e,t){let n=t,r=n.length,i=n[r-1],a=[new uE(nO(DD(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new uE(nO(n[e-1].to),n[e].transformation.flip()));let o=nO(i.to);return o.encoding?DD(o,[...o.encoding,...a]):DD(o,a)}var nO=f(e=>{if(e.encoding)return tO(e,e.encoding);let t=ED(e);if(t!==e){let n=nO(t);return n===t?e:OD(n,e.context)}return`flip`in e?e.flip(nO):`recur`in e?e.recur(nO):e});function rO(e,t){let n=t===0?q:Cw(t);return(r,i)=>r===K?ww:r===t?n:H(new Lw(e,r,i))}function iO(e,t){return(n,r)=>n===K?ww:t(n)?q:H(new Lw(e,n,r))}var aO=RD(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(aO)}}),oO=RD(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(oO)}}),sO=new globalThis.RegExp(`^${IE}$`),cO=new globalThis.RegExp(`^(?:${IE}|Infinity|-Infinity|NaN)$`);function lO(e){return CD(sO,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:sO.source}),...e})}var uO=MD(TE,[lO()]),dO=new uE(uO,zT),fO=new uE(new cD([uO,mD]),zT);function pO(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=pO(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new jw(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function mO(e){if(!ZT(e))return;let t=e.annotations?.[xw];return ce(t)?t(e.typeParameters):void 0}function hO(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function gO(e){return e===void 0||typeof e==`string`}function _O(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function vO(e){return _O(e,hO)}var yO=new hE([],()=>(e,t,n)=>vO(e)?q:H(new Lw(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>CO}),bO=new uE(yO,RT()),xO=new uE(new cD([new AE(!1,[],[yO]),new UE([],[new HE(TE,yO)])]),RT());function SO(e){return _O(e,gO)}var CO=new uE(new hE([],()=>(e,t,n)=>SO(e)?q:H(new Lw(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),RT()),wO=(e,t,n)=>e===q?n(t):Q_(e,n);function TO(e){let t=EO(e);return(e,n,r)=>{try{return t(e,n,r)}catch(e){return Cg(e)}}}function EO(e){if(e._tag===`Middleware`)return(t,n,r)=>DO(t===q?e.decode(Cw(Tw(n)),r):e.decode(Y_(t,Tw),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===q?Cw(t):e;case`Transform`:{let e=e=>e===K?ww:Cw(t.transform(e));return(t,n)=>wO(t,n,e)}case`TransformOptional`:{let e=e=>Ew(t.transform(Tw(e)));return(t,n)=>wO(t,n,e)}case`TransformEffect`:return(e,n,r)=>wO(e,n,e=>e===K?ww:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>wO(e,n,e=>DO(t.transform(Tw(e),r)))}}var DO=e=>Q_(e,Ew),OO=(e,t,n,r)=>Ig(r,r=>Sg(()=>Nf(r,r=>new Mw(e,r,t,n))));function kO(e,t){let n=TO(e.link.transformation),r;return(i,a)=>{if(i===K)return ww;if(e.isConstructed(i))return q;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function AO(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==K&&r!==void 0)return t(r,i);let a=n;if(L(a)&&a._tag===`Success`){let e=t(a[S],i);return e===q?a:e}return Q_(OO(e,r,i,a),e=>{let n=t(e,i);return n===q?Cw(e):n})}}function jO(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:AO(e,n)}function MO(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?mO(e):void 0,o=a?kO(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>TO(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);try{if(u&&!n.disableChecks){if(L(r)){if(r._tag===`Success`){let i=r===q?t:r[S];if(t!==K&&i!==K){let i=pO(u,t,void 0,e,n);i&&(r=H(new Iw(e,i,t,n)))}}}else r=U(r,r=>{if(t!==K&&r!==K){let r=pO(u,t,void 0,e,n);if(r)return H(new Iw(e,r,t,n))}return R(r)})}if(s&&!n.disableChecks){if(L(r)){if(r._tag===`Success`){let i=r===q?t:r[S];if(i===K)return r;let a=pO(s,i,void 0,e,n);a&&(r=H(new Iw(e,a,i,n)))}}else r=U(r,t=>{if(t!==K){let r=pO(s,t,void 0,e,n);if(r)return H(new Iw(e,r,t,n))}return R(t)})}return r}catch(e){return Cg(e)}},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[S],o=t(a,r)):o=Q_(o,e=>{let n=t(e,r);return n===q?Cw(e):n})}if(o._tag===`Success`){let e=o[S],t=p(e,r);return t===q?o:t}return o=OO(e,n,r,o),Q_(o,e=>{let t=p(e,r);return t===q?Cw(e):t})}:p}var NO=Symbol(),PO=new WeakMap,FO=e=>zO(e).parser,IO=e=>zO(e).makeEffect,LO=e=>jO(e,IO),RO=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=MO(this.ast,FO)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=MO(this.ast,IO,LO)}};function zO(e){let t=PO.get(e);if(t!==void 0)return t;let n=new RO(e);return PO.set(e,n),n}function BO(e){let t=e.ast,n;return(e,r)=>(n??=tk(fk,$D(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function VO(e){let t=BO(e);return(e,n)=>{let r=U_(t(e,n));return rp(r)?E(r.value):(rT(r.cause,`Option adapter can only return none for schema issues`),T())}}function HO(e){return ck($D(e.ast))}function UO(e){return GO(e.ast)}function WO(e){{let t=nk($O(e));return e=>{let n=t(e,dE);return rp(n)?!0:(rT(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function GO(e){let t=$D(e),n=e=>(n=WO(t),n(e));return e=>n(e)}function KO(e,t){let n=$O(e.ast);return t===void 0?n:(e,r)=>n(e,ZO(t,r))}function qO(e,t){return rk(KO(e,t))}var JO=qO;function YO(e,t){return ik(KO(e,t))}function XO(e,t){let n=$O(nO(e.ast));return t===void 0?n:(e,r)=>n(e,ZO(t,r))}var ZO=(e,t)=>t?{...e,...t}:e,QO=e=>e===K?H(new Rw):R(e);function $O(e){return tk(dk,e)}function ek(e,t){return e===q?R(t):L(e)?e[`~effect/Effect/args`]===K?QO(K):e:Q_(e,QO)}function tk(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??dE);return a===q?R(r):L(a)?a[`~effect/Effect/args`]===K?QO(K):a:Q_(a,QO)}}function nk(e){return(t,n)=>U_(e(t,n))}function rk(e){let t=nk(e);return(e,n)=>{let r=t(e,n);return rp(r)?E(r.value):(rT(r.cause,`Option adapter can only return none for schema issues`),T())}}function ik(e){let t=nk(e);return(e,n)=>{let r=t(e,n);return rp(r)?Lr(r.value):Rr(rT(r.cause,`Result adapter can only return schema issues`))}}function ak(e,t){let n=U_(e);if(rp(n))return n.value;let r=rT(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}var ok=`Constructor adapter can only throw schema issues`;function sk(e){throw Error(ok,{cause:Df(e)})}function ck(e){let t;return(n,r)=>lk(t??=zO(e),n,r)}function lk(e,t,n){let r=n?.disableChecks?n.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions??dE,i=e.make;if(i!==void 0&&t!==K){let e;try{e=i(t,r)}catch(e){sk(e)}if(e!==NO&&e!==K)return e}return ak(ek(e.makeEffect(t,r),t),ok)}function uk(e,t,n,r){let i=zO(e),a=mO(e);if(a===void 0||i.make!==void 0||i.compiledMakeEffect!==void 0)return lk(i,t,n);if(a.isConstructed(t))return t;let o=lk((i.resolve??zO)(a.link.to),t,n);try{return r(o)}catch(e){sk(e)}}var dk=e=>zO(e).parser,fk=e=>zO(e).makeEffect,pk=`~effect/Schema/Schema`,mk=Symbol(),hk={[pk]:pk,get make(){let e=HO(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=BO(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=VO(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return e(this,arguments)},annotate(e){return this.rebuild(AD(this.ast,e))},annotateKey(e){return this.rebuild(VD(this.ast,e))},check(...e){return this.rebuild(MD(this.ast,e))},rebuild(e){return gk(e,this[mk])}};function gk(e,t){function n(){}let r=Object.setPrototypeOf(n,hk);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[mk]=t,r.ast=e,r}function _k(e){return gk(vk(e.ast),{schema:e})}var vk=yk(wk);function yk(e,t){let n=f(t=>{let n=OD(t,void 0),i=e(n,r);return i===n?null:i}),r=RD(e=>{let t=n(ED(e));if(t===null)return e;let r=OD(t,e.context);return e.context===void 0?r:ID(r,bk(e.context))},t);return r}function bk(e){return e.constructorDefault===void 0?e:new fE(e.isOptional,e.isMutable,void 0,e.annotations)}function xk(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function Sk(e){return t=>{let n=[...t].sort((t,n)=>e(eO(t))-e(eO(n)));return n.some((e,n)=>e!==t[n])?n:t}}var Ck=Sk(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function wk(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!ce(n))return DD(e,[bO]);let r=n(e.typeParameters.map(e=>gk(eO(e))));return r===void 0?e:DD(e,[ND(r,t)])}case`Unknown`:return DD(e,[bO]);case`ObjectKeyword`:return DD(e,[xO]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return xk(e),e.recur(t,oO);case`Union`:{let n=Ck(e.types);return n===e.types?e.recur(t):new cD(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}function Tk(e){return gk(jk(e.ast),{schema:e})}var Ek=Sk(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function Dk(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>gk(t(eO(e)))),i=e.annotations?.toCodecStringTree;if(ce(i)){let n=i(r);return n===void 0?e:DD(e,[ND(n,t)])}let a=e.annotations?.toCodecJson,o=ce(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(ce(s)?s(r):void 0);return c===void 0?n(e):DD(e,[ND(c,t)])}case`Null`:return DD(e,[Ok]);case`Boolean`:return DD(e,[kk]);case`Unknown`:case`ObjectKeyword`:return DD(e,[CO]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return xk(e),e.recur(t,oO);case`Union`:{let n=Ek(e.types);return n===e.types?e.recur(t):new cD(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var Ok=new uE(new CE(`null`),new jT(uT(()=>null),uT(()=>`null`))),kk=new uE(new cD([new CE(`true`),new CE(`false`)]),new jT(uT(e=>e===`true`),gT())),Ak=new jT(uT(e=>typeof e==`string`?[e]:e),lT()),jk=yk((e,t)=>Dk(e,t,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})}),{stopAt:e=>e.transformation===Ak}),Mk=e=>e,Nk=`~effect/Schema/SchemaError`;function Pk(e){return v(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var Fk=e=>{let t=0;for(let n=0;n<e.length;n++)t+=e[n].length;let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++)n.set(e[t],r),r+=e[t].length;return n},Ik=lr((e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return e.length<t.length?-1:+(e.length>t.length)});({...Mt}),{...Mt},{...Mt},{...Mt},{...Mt},{...Mt},{...Mt},{...Mt};var Lk=pk;function Rk(){return(e,t,n)=>J(new hE(e.map(XE),e=>t(e.map(e=>J(e))),n))}function zk(e,t){return Rk()([],()=>(t,n,r)=>e(t)?R(t):H(new Lw(n,t,r)),t)}var Bk=class extends Bo(`SchemaError`){[Nk]=Nk;constructor(e){let t=Ft();It(0);try{super({issue:e})}finally{It(t)}}get message(){return $w(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[kt](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function Vk(e){return Pk(e)}function Hk(e){return L(e)?Uk(e):Ig(e,e=>Sg(()=>Nf(e,e=>new Bk(e))))}function Uk(e){return rp(e)?e:Qf(Nf(e.cause,e=>new Bk(e)))}function Wk(e,t){let n;for(let r of e.reasons){if(!Sf(r)||!Vk(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function Gk(e){let t=U_(e);if(rp(t))return t.value;throw Wk(t.cause,`Sync adapter can only throw schema errors`)}var Kk=UO;function qk(e,t){let n=KO(e,t);return(e,t)=>Hk(n(e,t))}var Jk=qk,Yk=JO;function Xk(e,t){let n=YO(e,t);return(e,t)=>Ur(n(e,t),e=>new Bk(e))}function Zk(e,t){let n=qk(e,t);return(e,t)=>Gk(n(e,t))}var Qk=Zk;function $k(e,t){let n=XO(e,t);return(e,t)=>Hk(n(e,t))}var eA=$k;function tA(e,t){let n=$k(e,t);return(e,t)=>Gk(n(e,t))}var nA=tA,J=gk;function rA(e){return v(e,Lk)&&e[Lk]===Lk}var iA=Mk(e=>J(HD(e.ast),{schema:e})),aA=Mk(e=>{let t=AA(e);return J(WD(e.ast),{schema:t})}),oA=Mk(e=>J($D(e.ast),{schema:e})),sA=Mk(e=>J(eO(e.ast),{schema:e}));function cA(e){let t=J(new CE(e),{literal:e,transform(n){return t.pipe(jA(cA(n),{decode:uT(()=>n),encode:uT(()=>e)}))}});return t}var lA=J(xE),uA=J(SE),dA=J(gE),fA=J(yE),pA=J(TE),mA=J(OE),hA=J(kE),gA=J(bE);function _A(e,t){return J(e,{fields:t,mapFields(e,t){let n=e(this.fields);return _A(YE(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function vA(e){return _A(YE(e,void 0),e)}function yA(e,t){return J(JD(e.ast,t.ast),{key:e,value:t})}function bA(e,t){return J(e,{elements:t,mapElements(e,t){let n=e(this.elements);return bA(ZE(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function xA(e){return bA(ZE(e),e)}var SA=Mk(e=>J(new AE(!1,[],[e.ast]),{value:e})),CA=Mk(e=>J(new AE(!1,[e.ast],[e.ast]),{value:e}));function wA(e){let t=SA(e),n=SA(oA(e));return J(DA([jA(xA([uA]),FT({decode:e=>[e],encode:([e])=>e}))(e),t]).pipe(jA(n)).ast,{from:DA([e,t]),to:n})}var TA=Mk(e=>J($E(e.ast),{schema:e}));function EA(e,t){return J(e,{members:t,mapMembers(e,t){let n=e(this.members);return EA(QE(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function DA(e,t){return EA(QE(e,t,void 0),e)}function OA(e){let t=e.map(cA);return J(QE(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return DA(e(this.members))},pick(e){return OA(e)},transform(e){return DA(t.map((t,n)=>t.transform(e[n])))}})}var kA=Mk(e=>DA([e,dA])),AA=Mk(e=>DA([e,fA]));function jA(e,t){return n=>J(KD(n.ast,e.ast,t?NT(t):RT()),{from:n,to:e})}function MA(e){return t=>J(GD(t.ast,e),{schema:t})}function NA(e){return L(e)&&e._tag===`Success`?e:Ig(e,e=>Sg(()=>Nf(e,e=>e.issue)))}function PA(e,t){let n=t?.encodingStrategy===`omit`?mT():lT();return t=>iA(sA(t)).pipe(jA(t,{decode:hT(NA(e)),encode:n}))}function FA(e){return cA(e).pipe(MA(R(e)))}function IA(e,t){return vA({_tag:FA(e),...t})}function LA(e){return t=>{let n={},r=[],i=new Set,a={};return o(t),Object.assign(t,{tag:e,cases:n,discriminants:r,isAnyOf:t=>n=>t.includes(n[e]),guards:a,match:s,matchOrElse:c});function o(t){let s=t.ast;if(cE(s)&&`members`in t&&globalThis.Array.isArray(t.members)&&t.members.every(rA))return t.members.forEach(o);let c=nD(s);if(c.length>0){let o=c.find(t=>t.key===e)?.literal;if(se(o)){let e=typeof o==`number`?globalThis.String(o):o;if(i.has(e))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(o)}`);i.add(e),r.push(o),b(n,o,t),b(a,o,UO(oA(t)));return}}throw new globalThis.Error(`No literal or unique symbol found`)}function s(){if(arguments.length===1){let t=arguments[0];return function(n){let r=n[e];return(Object.hasOwn(t,r)?t[r]:void 0)(n)}}let t=arguments[0],n=arguments[1],r=t[e];return(Object.hasOwn(n,r)?n[r]:void 0)(t)}function c(){if(arguments.length===2){let t=arguments[0],n=arguments[1];return function(r){let i=r[e];return(Object.hasOwn(t,i)?t[i]??n:n)(r)}}let t=arguments[0],n=arguments[1],r=arguments[2],i=t[e];return(Object.hasOwn(n,i)?n[i]??r:r)(t)}}}function RA(e){let t={},n=[];for(let r of Object.keys(e)){let i=IA(r,e[r]);b(t,r,i),n.push(i)}let r=DA(n),{tag:i,guards:a,isAnyOf:o,match:s,matchOrElse:c}=LA(`_tag`)(r);return J(r.ast,{tag:i,cases:t,isAnyOf:o,guards:a,match:s,matchOrElse:c})}function zA(e,t){return zk(t=>t instanceof e,t)}function BA(){return(e,t)=>new uE(e.ast,NT(t))}var VA=yD;function HA(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new globalThis.RegExp(${x(n)})`:`new globalThis.RegExp(${x(n)}, ${x(r)})`;return CD(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var UA=J(xD);function WA(e){return VA(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`,minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}var GA=mA.check(WA());function KA(e,t){return e=XA(e),qA(e,Math.ceil(e/2),t)}function qA(e,t,n){return VA(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:n})=>n===`string`?e<=1?{minLength:t}:[{minLength:t},!0]:n===`array`?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[yw]:!0,arbitraryConstraint:{minLength:e},...n})}function JA(e){return qA(1,1,e)}function YA(e,t){return e=XA(e),VA(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`string`?e===0?{maxLength:e}:[{maxLength:e},!0]:t===`array`?{maxItems:e}:t===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[yw]:!0,arbitraryConstraint:{maxLength:e},...t})}function XA(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var ZA=pA.check(JA()),QA=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),$A=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},ej=[];function tj(e){let t=QA(e),n=ej[t];if(n!==void 0)return n;let r=wj.pipe(jA(uA,KT($A(t))));return ej[t]=r,r}globalThis.RegExp,globalThis.URL;var nj=pA.annotate({expected:`a string that will be decoded as JSON`});function rj(e,t){return nj.pipe(jA(e,YT(t)))}globalThis.File,globalThis.URLSearchParams;var ij=pA.annotate({expected:`a URI component encoded string that will be decoded as a UTF-8 string`}).pipe(jA(pA,JT)),aj=pA.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),oj=zA(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>BA()(aj,qT)});function sj(e,t){return J(Rk()([e,t],([e,t])=>(n,r,i)=>{if(!xf(n))return H(new Lw(r,n,i));switch(n._tag){case`Fail`:return Z_(KO(e)(n.error,i),{onSuccess:kf,onFailure:e=>zw(r,`error`,e,n,i)});case`Die`:return Z_(KO(t)(n.defect,i),{onSuccess:Af,onFailure:e=>zw(r,`defect`,e,n,i)});case`Interrupt`:return R(n)}},{representation:{id:`effect/schema/CauseReason`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.CauseReason(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Failure<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause.Failure`,toCodec:([e,t])=>BA()(DA([vA({_tag:cA(`Fail`),error:e}),vA({_tag:cA(`Die`),defect:t}),vA({_tag:cA(`Interrupt`),fiberId:AA(UA)})]),FT({decode:e=>{switch(e._tag){case`Fail`:return kf(e.error);case`Die`:return Af(e.defect);case`Interrupt`:return jf(e.fiberId)}},encode:e=>{switch(e._tag){case`Fail`:return{_tag:`Fail`,error:e.error};case`Die`:return{_tag:`Die`,defect:e.defect};case`Interrupt`:return{_tag:`Interrupt`,fiberId:e.fiberId}}}}))}).ast,{error:e,defect:t})}function cj(e,t){return J(Rk()([e,t],([e,t])=>{let n=SA(sj(e,t));return(e,t,r)=>bf(e)?Z_(KO(n)(e.reasons,r),{onSuccess:Tf,onFailure:n=>zw(t,`reasons`,n,e,r)}):H(new Lw(t,e,r))},{representation:{id:`effect/schema/Cause`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Cause(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Cause<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause`,toCodec:([e,t])=>BA()(SA(sj(e,t)),FT({decode:Tf,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}function lj(e,t,n){return J(Rk()([e,t,n],([e,t,n])=>{let r=cj(t,n);return(t,n,i)=>{if(!Xf(t))return H(new Lw(n,t,i));switch(t._tag){case`Success`:return Z_(KO(e)(t.value,i),{onSuccess:Zf,onFailure:e=>zw(n,`value`,e,t,i)});case`Failure`:return Z_(KO(r)(t.cause,i),{onSuccess:Qf,onFailure:e=>zw(n,`cause`,e,t,i)})}}},{representation:{id:`effect/schema/Exit`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Exit(${e[0].runtime}, ${e[1].runtime}, ${e[2].runtime})`,Type:`Exit.Exit<${e[0].Type}, ${e[1].Type}, ${e[2].Type}>`,importDeclarations:[`import * as Exit from "effect/Exit"`]}),expected:`Exit`,toCodec:([e,t,n])=>BA()(DA([vA({_tag:cA(`Success`),value:e}),vA({_tag:cA(`Failure`),cause:cj(t,n)})]),FT({decode:e=>e._tag===`Success`?Zf(e.value):Qf(e.cause),encode:e=>rp(e)?{_tag:`Success`,value:e.value}:{_tag:`Failure`,cause:e.cause}}))}).ast,{value:e,error:t,defect:n})}function uj(e){return J(Rk()([e],([e])=>(t,n,r)=>vr(t)?yr(t)?_g:Z_(KO(e)(t.value,r),{onSuccess:E,onFailure:e=>zw(n,`value`,e,t,r)}):H(new Lw(n,t,r)),{representation:{id:`effect/schema/Option`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Option(${e[0].runtime})`,Type:`Option.Option<${e[0].Type}>`,importDeclarations:[`import * as Option from "effect/Option"`]}),expected:`Option`,toCodec:([e])=>BA()(DA([vA({_tag:cA(`Some`),value:e}),vA({_tag:cA(`None`)})]),FT({decode:e=>e._tag===`None`?T():E(e.value),encode:e=>br(e)?{_tag:`Some`,value:e.value}:{_tag:`None`}}))}).ast,{value:e})}var dj=globalThis.Symbol.for(`immer-draftable`),fj={};function pj(t,n,r,i,a){let o=_j(r,n,i),s=gj(n),c=class extends t{constructor(...[e,t]){let n=t?.[`~payload`],i=n?.token===fj?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:fj,value:i}})}static[Lk]=Lk;get[s](){return s}static[dj]=!0;static identifier=n;static fields=r.fields;static get ast(){return o(this).ast}static pipe(){return e(this,arguments)}static rebuild(e){return o(this).rebuild(e)}static make(e,t){return uk($D(o(this).ast),e??{},t,e=>mj(this,e))}static makeOption(e,t){return VO(o(this))(e??{},t)}static makeEffect(e,t){return o(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(AD(this.ast,e))}static annotateKey(e){return this.rebuild(VD(this.ast,e))}static check(...e){return this.rebuild(MD(this.ast,e))}static extend(e){return(t,n)=>{let i=vj(t)?t:vA(t),o={...r.fields,...i.fields},s=YE(o,r.ast.checks,{identifier:e});return pj(this,e,_A(MD(s,i.ast.checks),o),n,a)}}static mapFields(e,t){return r.mapFields(e,t)}};return a!==void 0&&Object.assign(c.prototype,a(n)),c}function mj(e,t){return new e(t,{"~payload":{token:fj,value:t}})}function hj(e){return new jT(uT(t=>mj(e,t)),lT())}function gj(e){return`~effect/Schema/Class/${e}`}function _j(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=gj(t),o=e=>e instanceof i||v(e,a),s=hj(i);return r=jA(J(new hE([e.ast],()=>(e,t,n)=>o(e)?R(e):H(new Lw(t,e,n)),{identifier:t,[xw]:([e])=>({isConstructed:o,link:new uE(e,s)}),toCodec:([e])=>new uE(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[bw]:nD(e.ast),...n})),s)(e)}}function vj(e){return rA(e)}var yj=e=>(t,n)=>pj(Ro,e,vj(t)?t:vA(t),n,e=>({toString(){return`${e}(${x({...this})})`}})),bj=e=>(t,n)=>pj(An,e,vj(t)?t:vA(t),n,e=>({name:e})),xj=e=>(t,n,r)=>{let i=vj(n)?n.mapFields(e=>({_tag:FA(t),...e}),{unsafePreserveChecks:!0}):IA(t,n);return bj(e??t)(i,r)},Sj=_k,Cj=Tk,wj=J(AD(yO,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})}));function Tj(e){return vw(e.ast)}var Ej=`~effect/Config`,Dj=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Oj={...Wi({label:`Config`,evaluate(e){return this.parse(e.getRef(nS))}}),[Ej]:Ej,toJSON(){return{_id:`Config`}}};function kj(e){let t=Object.create(Oj);return t.evaluator=e,t.parse=t=>Q_(e(t,[]),Dg),t}var Aj=(e,t,n)=>e.evaluator(t,n),jj=r(2,(e,t)=>kj((n,r)=>W(Aj(e,n,r),Wr(t)))),Mj=r(2,(e,t)=>kj((n,r)=>Y_(Aj(e,n,r),e=>D(e)?Lr(t):e))),Nj=e=>e.pipe(jj(E),Mj(T())),Pj=e=>_e(e,`SourceError`),Fj=()=>`<configuration>`,Ij=e=>t=>Ig(t,t=>xg(Tf(t.reasons.map(e)))),Lj=(e,t)=>e.load(t).pipe(Ij(e=>Sf(e)?Af(e.error).annotate(Kf(e)):e),Y_(n=>({provider:e,path:t,node:n,toString:Fj}))),Rj=(e,t)=>Lj(e.provider,[...e.path,t]),zj=(e,t)=>KD(SE,e,new jT(dT(e=>t(e)),lT())),Bj=e=>{switch(e._tag){case`Union`:return e.types.every(Bj);case`Objects`:case`Arrays`:case`Suspend`:return!1;default:return!0}},Vj=(e,t)=>{switch(e._tag){case`Objects`:return t?._tag===`Record`;case`Arrays`:return t?._tag===`Array`;case`Union`:return e.types.some(e=>Vj(e,t));case`Suspend`:return Vj(e.thunk(),t);default:return t?.value!==void 0}},Hj=f(e=>{let t=new WeakSet,n=LD(e=>{switch(t.add(e),e._tag){case`Objects`:{let t=W_(function*(t){if(t.node?._tag!==`Record`)return;let n=t.node,r=new Set;for(let t of e.propertySignatures)typeof t.name==`string`&&r.add(t.name);if(e.indexSignatures.length>0){let t={};for(let e of n.keys)b(t,e,void 0);for(let n of e.indexSignatures)for(let e of LE(t,n.parameter))typeof e==`string`&&r.add(e)}let i={};for(let e of r){let n=yield*Rj(t,e);n.node!==void 0&&b(i,e,n)}return i});return zj(e.recur(n,e=>e),t)}case`Arrays`:{let t=W_(function*(e){if(e.node?._tag!==`Array`)return;let t=[];for(let n=0;n<e.node.length;n++)t.push(yield*Rj(e,n));return t});return zj(e.recur(n),t)}case`Union`:for(let t of e.types)n(t);if(!Bj(e))return e.recur(n);break;case`Suspend`:{let r=e.thunk();return t.has(r)||n(r),e.recur(n)}case`Declaration`:case`Any`:throw new globalThis.Error(`Config.schema does not support opaque StringTree encodings`,{cause:e})}return zj(e,e=>R(e.node?.value))});return n(e)});function Uj(e,t){let n=Cj(e),r=eO(n.ast),i=KO(J(Hj(n.ast))),a=typeof t==`string`?[t]:t??[];return kj((e,t)=>{let n=[...t,...a];return Lj(e,n).pipe(Q_(e=>i(e).pipe(Y_(Lr),$_(t=>{let i=new Dj(new Bk(n.length>0?new Nw(n,t):t));return Vj(r,e.node)?H(i):R(Rr(i))}))),Ij(e=>Cf(e)&&Pj(e.defect)?kf(new Dj(e.defect)).annotate(Kf(e)):e))})}var Wj=e=>re(e)||globalThis.Array.isArray(e);function Gj(e){return Uj(pA,e)}function Kj(e,t,n){let r=Wj(t),i=r?n:t,a=SA(e),o=i?.separator??`,`;return Uj(DA([pA.pipe(jA(Cj(a),{decode:ST(i),encode:sT(lT({strict:!1}),uT(e=>e.join(o)))})),a]),r?t:void 0)}function qj(e,t,n,r){let i=Wj(n),a=yA(e,t),o=IT(i?r:n);return Uj(DA([a,pA.pipe(jA(Cj(a),{decode:o.decode,encode:sT(lT({strict:!1}),o.encode)}))]),i?n:void 0)}var Jj={"~effect/Match/Matcher":{_input:i,_filters:i,_result:i,_return:i,_flavor:i},_tag:`ValueMatcher`,add(e){return Vr(this.value)?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?Yj(this.provided,Lr(e.evaluate(this.provided))):this},pipe(){return e(this,arguments)}};function Yj(e,t){let n=Object.create(Jj);return n.provided=e,n.value=t,n}var Xj=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),Zj=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(Zj),n=t.length;return e=>{if(!Array.isArray(e)||e.length<n)return!1;for(let r=0;r<n;r++)if(t[r](e[r])===!1)return!1;return!0}}if(typeof e==`object`&&e){let t=Reflect.ownKeys(e).map(t=>[t,Zj(e[t])]),n=t.length;return e=>{if(typeof e!=`object`||!e)return!1;for(let r=0;r<n;r++){let[n,i]=t[r];if(!(n in e)||i(e[n])===!1)return!1}return!0}}return t=>t===e},Qj=e=>Yj(e,Rr(e)),$j=(e,t)=>n=>n.add(Xj(Zj(e),t)),eM=e=>(...t)=>{let n=t[t.length-1],r=t.slice(0,-1),i=r.length===1?t=>t!=null&&t[e]===r[0]:t=>t!=null&&r.includes(t[e]);return e=>e.add(Xj(i,n))},tM=e=>t=>{let n=Xj(n=>n!=null&&Object.hasOwn(t,n[e]),n=>t[n[e]](n));return e=>e.add(n)},nM=e=>t=>{let n=tM(e)(t);return e=>cM(n(e))},rM=eM(`_tag`),iM=nM(`_tag`),aM=e=>t=>{let n=oM(t);return Br(n)?n._tag===`Success`?n.success:e(n.failure):(...t)=>{let r=n(...t);return Vr(r)?r.success:e(r.failure,...t)}},oM=e=>{if(e._tag===`ValueMatcher`)return e.value;let t=e.cases.length;if(t===1){let t=e.cases[0];return(...n)=>{let r=e.select(...n);return t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1?Lr(t.evaluate(r,...n)):Rr(r)}}return(...n)=>{let r=e.select(...n);for(let i=0;i<t;i++){let t=e.cases[i];if(t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1)return Lr(t.evaluate(r,...n))}return Rr(r)}},sM=`effect/match/Match/exhaustive: absurd`,cM=e=>{let t=oM(e);if(Br(t)){if(Vr(t))return t.success;throw Error(sM)}return(...e)=>{let n=t(...e);if(Vr(n))return n.success;throw Error(sM)}},lM=Qj,uM=$j,dM=rM,fM=iM,pM=aM,mM={"~effect/Ref":{_A:i},...Jt,toJSON(){return{_id:`Ref`,ref:this.ref}}},hM=e=>{let t=Object.create(mM);return t.ref=Sv(e),t},gM=r(2,(e,t)=>B(()=>{let[n,r]=t(e.ref.current);return e.ref.current=r,n})),_M=r(2,(e,t)=>B(()=>e.ref.current=t(e.ref.current))),vM=`~effect/http/HttpBody`,yM=`~effect/http/HttpBody/HttpBodyError`,bM=class extends Bo(`HttpBodyError`){[yM]=yM},xM=class{[vM];constructor(){this[vM]=vM}[kt](){return this.toJSON()}toString(){return x(this,{ignoreToString:!0})}},SM=new class extends xM{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},CM=class extends xM{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=DM(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},wM=(e,t)=>new CM(e,t??`application/octet-stream`,e.length),TM=new TextEncoder,EM=globalThis.Buffer,DM=EM===void 0?e=>TM.encode(e):e=>EM.from(e,`utf8`),OM=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),EM!==void 0)return new CM(void 0,t??`text/plain`,EM.byteLength(e,`utf8`),e);let n=TM.encode(e);return new CM(n,t??`text/plain`,n.length,e)},kM=(e,t)=>wg({try:()=>OM(JSON.stringify(e),t??`application/json`),catch:e=>new bM({reason:{_tag:`JsonError`},cause:e})}),AM=(e,t)=>{let n=XO(Sj(e));return(e,r)=>n(e,t).pipe(zg(e=>new bM({reason:{_tag:`SchemaError`,issue:e},cause:e})),U(e=>kM(e,r)))},jM=class extends xM{_tag=`Stream`;stream;contentType;contentLength;constructor(e,t,n){super(),this.stream=e,this.contentType=t,this.contentLength=n}toJSON(){return{_id:`effect/HttpBody`,_tag:`Stream`,contentType:this.contentType,contentLength:this.contentLength}}},MM=(e,t,n)=>new jM(e,t??`application/octet-stream`,n),NM=`~effect/http/HttpClientError`,PM=e=>v(e,NM),FM=class extends Bo(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[NM]=NM;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},IM=e=>e.endsWith(`Error`)?e.slice(0,-5):e,LM=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,RM=e=>`${e.method} ${lw(e.url)}`,zM=(e,t)=>({...t,request:{_id:`HttpClientRequest`,method:e.request.method,url:lw(e.request.url)},...`response`in e?{response:{_id:`HttpClientResponse`,status:e.response.status}}:void 0}),BM=class extends Bo(`TransportError`){get methodAndUrl(){return RM(this.request)}get message(){return LM(IM(this._tag),this.description,this.methodAndUrl)}toJSON(){return zM(this,super.toJSON())}},VM=class extends Bo(`EncodeError`){get methodAndUrl(){return RM(this.request)}get message(){return LM(IM(this._tag),this.description,this.methodAndUrl)}toJSON(){return zM(this,super.toJSON())}},HM=class extends Bo(`InvalidUrlError`){get methodAndUrl(){return RM(this.request)}get message(){return LM(IM(this._tag),this.description,this.methodAndUrl)}toJSON(){return zM(this,super.toJSON())}},UM=class extends Bo(`StatusCodeError`){get methodAndUrl(){return RM(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return LM(IM(this._tag),this.description,e)}toJSON(){return zM(this,super.toJSON())}},WM=class extends Bo(`DecodeError`){get methodAndUrl(){return RM(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return LM(IM(this._tag),this.description,e)}toJSON(){return zM(this,super.toJSON())}},GM=class extends Bo(`EmptyBodyError`){get methodAndUrl(){return RM(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return LM(IM(this._tag),this.description,e)}toJSON(){return zM(this,super.toJSON())}},KM=class e extends bj(NM)({_tag:FA(`HttpError`),kind:OA([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:aA(tj())}){static fromHttpClientError(t){return new e({_tag:`HttpError`,kind:t.reason._tag,cause:t.reason})}},qM=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],JM=e=>t=>t.pipeThrough(new CompressionStream(e)),YM=e=>new ReadableStream({start(t){t.enqueue(e),t.close()}}),XM=(e,t,n)=>e._tag!==`Uint8Array`&&e._tag!==`Stream`||e.contentLength!==void 0&&e.contentLength<(n?.minSize??1024)?R(e):e._tag===`Uint8Array`?W(hg(()=>new globalThis.Response(JM(t)(YM(e.body))).arrayBuffer()),t=>wM(new Uint8Array(t),e.contentType)):R(MM(Ox({evaluate:()=>JM(t)(Zx(e.stream)),onError:i}),e.contentType)),ZM=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?MC(MC(e,`content-type`),`content-length`):(e=t.contentType===void 0?MC(e,`content-type`):kC(e,`content-type`,t.contentType),QM(e,t)),QM=(e,t)=>{let n=t._tag===`Empty`||t._tag===`FormData`?void 0:t.contentLength;return n===void 0?MC(e,`content-length`):kC(e,`content-length`,n.toString())},$M=class extends Bo(`UrlError`){},eN=(e,t,n)=>zr({try:()=>{let r=new URL(e,tN());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,qC(i))}return n!==void 0&&(r.hash=n),r},catch:e=>new $M({cause:e})}),tN=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0){let e=location.origin+location.pathname;try{return new URL(e).href}catch{return}}},nN=(e,t)=>zr({try:()=>new URL(e,t),catch:()=>new Gf(`Invalid URL: "${e}"${t===void 0?``:` with base "${t}"`}`)}),rN=`~effect/http/HttpClientRequest`,iN=e=>v(e,rN),aN={[rN]:rN,...Mt,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:lw(this.url),urlParams:this.urlParams,hash:this.hash,headers:mt(this.headers),body:this.body.toJSON()}},pipe(){return e(this,arguments)}};function oN(e,t,n,r,i,a){let o=Object.create(aN);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var sN=oN(`GET`,``,aw,T(),EC,SM),cN=e=>(t,n)=>uN(sN,{method:e,url:t,...n??void 0}),lN=cN(`POST`),uN=r(2,(e,t)=>{let n=e;return t.method&&(n=dN(n,t.method)),t.url&&(n=gN(n,t.url)),t.headers&&(n=pN(n,t.headers)),t.urlParams&&(n=_N(n,t.urlParams)),t.hash&&(n=vN(n,t.hash)),t.body&&(n=yN(n,t.body)),t.accept&&(n=mN(n,t.accept)),t.acceptJson&&(n=hN(n)),n}),dN=r(2,(e,t)=>oN(t,e.url,e.urlParams,e.hash,e.headers,e.body)),fN=r(3,(e,t,n)=>oN(e.method,e.url,e.urlParams,e.hash,kC(e.headers,t,n),e.body)),pN=r(2,(e,t)=>oN(e.method,e.url,e.urlParams,e.hash,AC(e.headers,t),e.body)),mN=r(2,(e,t)=>fN(e,`Accept`,t)),hN=mN(`application/json`),gN=r(2,(e,t)=>{if(typeof t==`string`)return oN(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=ew(n.searchParams),i=wr(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,oN(e.method,n.toString(),r,i,e.headers,e.body)}),_N=r(2,(e,t)=>oN(e.method,e.url,ow(e.urlParams,t),e.hash,e.headers,e.body)),vN=r(2,(e,t)=>oN(e.method,e.url,e.urlParams,E(t),e.headers,e.body)),yN=r(2,(e,t)=>oN(e.method,e.url,e.urlParams,e.hash,ZM(e.headers,t),t)),bN=r(e=>iN(e[0]),(e,t,n)=>e.headers[`content-encoding`]===void 0?W(XM(e.body,t,n),n=>n===e.body?e:oN(e.method,e.url,e.urlParams,e.hash,kC(QM(e.headers,n),`content-encoding`,t),n)):R(e)),xN=(e,t)=>{let n=AM(e,t);return r(2,(e,t)=>W(n(t),t=>yN(e,t)))};function SN(e){let t=eN(e.url,e.urlParams,Dr(e.hash));return Vr(t)?E(t.success):T()}var CN=`~effect/http/HttpIncomingMessage`,wN=(e,t)=>{let n=Jk(Sj(e)),r=t?.reviver===void 0?void 0:Jk(rj(Sj(e),t));return e=>r===void 0?U(e.json,e=>n(e,t)):U(e.text,i=>i===``?U(e.json,e=>n(e,t)):r(i,t))},TN=(e,t)=>({...t,headers:mt(e.headers),remoteAddress:e.remoteAddress}),EN=`~effect/http/HttpClientResponse/WebSource`,DN=e=>e[EN]?.(),ON=`~effect/http/HttpClientResponse`,kN=(e,t)=>new jN(e,t),AN=e=>e.status>=200&&e.status<300?R(e):H(new FM({reason:new UM({response:e,request:e.request,description:`non 2xx status code`})})),jN=class extends Nt{[CN];[ON];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[CN]=CN,this[ON]=ON}toJSON(){return TN(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=SN(this.request);return yr(e)?``:(e.value.hash=``,e.value.href)}get headers(){return DC(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=cC(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return T()}[EN](){return this.source}get stream(){return this.source.body?Ox({evaluate:()=>this.source.body,onError:e=>new FM({reason:new WM({request:this.request,response:this,cause:e})})}):Cx(new FM({reason:new GM({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return U(this.text,e=>wg({try:()=>e===``?null:JSON.parse(e),catch:e=>new FM({reason:new WM({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=W(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return U(this.arrayBuffer,e=>wg({try:()=>ew(YC(e)),catch:e=>new FM({reason:new WM({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=gg({try:()=>this.source.formData(),catch:e=>new FM({reason:new WM({request:this.request,response:this,cause:e})})}).pipe(v_,V_)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=gg({try:()=>this.source.arrayBuffer(),catch:e=>new FM({reason:new WM({request:this.request,response:this,cause:e})})}).pipe(v_,V_),this.arrayBufferBody}get upgrade(){return H(new FM({reason:new UM({request:this.request,response:this,description:`fetch cannot hand over the connection of an HTTP upgrade`})}))}pipe(){return e(this,arguments)}},MN=e=>OC({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${xr(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId.padStart(32,`0`)}-${e.spanId}-${e.sampled?`01`:`00`}`}),NN={"http:":80,"https:":443,"ws:":80,"wss:":443},PN=(e,t,n)=>{let r=lw(t.search,n).slice(1);if(e.attribute(`url.full`,lw(t.href,n)),e.attribute(`url.path`,t.pathname),r!==``&&e.attribute(`url.query`,r),e.attribute(`url.scheme`,t.protocol.slice(0,-1)),t.hostname!==``){e.attribute(`server.address`,t.hostname.startsWith(`[`)?t.hostname.slice(1,-1):t.hostname);let n=t.port===``?NN[t.protocol]:Number(t.port);n!==void 0&&e.attribute(`server.port`,n)}},FN=(e,t)=>{let n=e.params.filter(([,e])=>typeof e!=`string`).map(([e])=>e);return n.length===0?t:[...t,...new URLSearchParams(n.map(e=>[e,``])).keys()]},IN=(e,t,n,r,i)=>{for(let a in n)r(a,t)&&e.attribute(`http.${t}.header.${a}`,PC(a,i)?`<redacted>`:n[a])},LN=`~effect/http/HttpClient`,RN=Ki(`effect/HttpClient`),zN=(e=>(...t)=>U(RN,n=>n[e](...t)))(`get`),BN=r(2,(e,t)=>HN(n=>t(e.postprocess(n)),e.preprocess)),VN=BN(U(AN)),HN=(e,t)=>{let n=Object.create(UN);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},UN={[LN]:LN,pipe(){return e(this,arguments)},...Mt,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(qM.map(([e,t])=>[t,function(t,n){return this.execute(cN(e)(t,n))}]))},WN=e=>HN(t=>U(t,t=>Eg(n=>{let r=nP.get(t),i=r??new AbortController,a=eN(t.url,t.urlParams,Dr(t.hash));if(D(a))return H(new FM({reason:new HM({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(Zo)||n.getRef(XN)(t)){let a=e(t,o,i.signal,n);return r?W(a,e=>iP(e,i,!0)):C_(e=>t_(e(a),{onSuccess(e){return R(iP(e,i,!1))},onFailure(e){return Lf(e)&&i.abort(),xg(e)}}))}return O_(n.getRef($N)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method);let s=n.getRef(FC);PN(a,o,FN(t.urlParams,n.getRef(_w)));let c=n.getRef(ZN);return IN(a,`request`,t.headers,c,s),t=n.getRef(QN)?pN(t,MN(a)):t,C_(l=>l(e(t,o,i.signal,n)).pipe(A_(a,{captureStackTrace:!1}),t_({onSuccess:e=>(a.attribute(`http.response.status_code`,e.status),IN(a,`response`,e.headers,c,s),e.status>=400&&e.status<600&&(a.attribute(`error.type`,String(e.status)),GN(n,a,t,e)),R(iP(e,i,r!==void 0))),onFailure(e){return!r&&Lf(e)&&i.abort(),xg(e)}})))})})),R),GN=(e,t,n,r)=>{let i=Ft();It(0);let a;try{a=$f(new FM({reason:new UM({request:n,response:r})}))}finally{It(i)}t.end(e.getRef(Sp)?e.getRef(qf).currentTimeNanosUnsafe():BigInt(0),a)},KN=r(2,(e,t)=>{let n=Nh(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,a=lP(n?t:t.schedule??qh),o=n?void 0:t.times;return BN(e,d(r===`errors-only`?i:T_({schedule:a,times:o,while:uP}),r===`response-only`?i:Ug({while:n||t.while===void 0?oP:be(oP,t.while),schedule:a,times:o})))}),qN=(e,t)=>{if(t===void 0)return;let n=GC(t);return Vr(n)?bo(KC(n.success,e),lo(1)):void 0},JN=r(2,(e,t)=>BN(e,Ag(t))),YN=r(2,(e,t)=>BN(e,Vg(t))),XN=k(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>s}),ZN=k(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>s}),QN=k(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:o}),$N=k(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>e.method}),eP=e=>Xp(RN)(r_(t=>W(e,e=>BN(e,s_(e=>xa(t,e)))))),tP=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{try{e.abort()}catch{}});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new WeakMap;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),nP=new WeakMap,rP=new WeakMap,iP=(e,t,n)=>(n||(tP.register(e,t),e=new aP(e,t)),rP.set(e,t),e),aP=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[ON]=ON;[CN]=CN;applyInterrupt(e){return z(()=>(tP.unregister(this.original),x_(e,()=>B(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get upgrade(){return this.applyInterrupt(this.original.upgrade)}[EN](){let e=DN(this.original);return e!==void 0&&tP.unregister(this.original),e}get stream(){return xx(()=>(tP.unregister(this.original),Wx(this.original.stream,B(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[kt](){return this.original[kt]()}pipe(){return e(this,arguments)}},oP=e=>Wf(e)||sP(e),sP=e=>PM(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&uP(e.reason.response)),cP=(e,t)=>qN(t,(PM(e)?e.response:v(e,`~effect/http/HttpClientResponse`)?e:void 0)?.headers[`retry-after`]),lP=e=>Ph(W(Lh(e),e=>(t,n)=>{let r=cP(n,t);return r===void 0?e(t,n):W(e(t,n),([e,t])=>[e,bo(t,r)])})),uP=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,dP=k(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),fP=k(`effect/http/FetchHttpClient/StreamBodyFallback`,{defaultValue:()=>`error`}),pP=class extends Ki()(`effect/http/FetchHttpClient/RequestInit`){},mP,hP=()=>{try{let e=!1,t=new ReadableStream,n=new Request(`https://example.com`,{method:`POST`,body:t,get duplex(){return e=!0,`half`}});return(e||n.body===t)&&!n.headers.has(`Content-Type`)}catch{return!1}},gP=eP(R(WN((e,t,n,r)=>{if(e.headers.upgrade!==void 0)return H(new FM({reason:new BM({request:e,description:`fetch cannot send an HTTP upgrade request`})}));let i=r.getRef(dP),a=ma(r.context,pP)??{},o=a.headers?jC(DC(a.headers),e.headers):e.headers;o[`content-length`]&&(o=MC(o,`content-length`));let s,c=B(()=>s?.abort()),l=r=>W(gg({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:s?AbortSignal.any([n,s.signal]):n}),catch:t=>new FM({reason:new BM({request:e,cause:t})})}),t=>{let n=kN(e,t);return s?(t.body===null&&s.abort(),Object.create(n,{...Object.fromEntries([`arrayBuffer`,`text`,`json`,`formData`,`urlParamsBody`].map(e=>[e,{get:()=>m_(n[e],c)}])),stream:{get:()=>Wx(n.stream,c)}})):n}).pipe(h_(()=>c));switch(e.body._tag){case`Raw`:case`Uint8Array`:return l(e.body.body);case`FormData`:return l(e.body.formData);case`Stream`:if(mP??=hP(),mP){s=new AbortController;let t=AbortSignal.any([n,s.signal]),r=vg(e=>{let n=()=>e(y_);if(t.aborted)n();else return t.addEventListener(`abort`,n,{once:!0}),B(()=>t.removeEventListener(`abort`,n))});return U(Qx(Vx(e.body.stream,r)),l)}return r.getRef(fP)===`error`?H(new FM({reason:new VM({request:e,description:`Streaming request bodies are not supported in this runtime`})})):Yx(e.body.stream).pipe(zg(t=>new FM({reason:new VM({request:e,cause:t})})),U(l))}return l(void 0)}))),_P=`~effect/FiberSet`,vP=e=>v(e,_P),yP={[_P]:_P,[Symbol.iterator](){return this.state._tag===`Closed`?Zr():this.state.backing[Symbol.iterator]()},...Jt,toJSON(){return{_id:`FiberSet`,state:this.state}}},bP=(e,t)=>{let n=Object.create(yP);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},xP=()=>f_(B(()=>bP(new Set,cp())),e=>z(()=>{let t=e.state;if(t._tag===`Closed`)return V;e.state={_tag:`Closed`};let n=t.backing;return av(n).pipe(yp(e.deferred))})),SP=-1,CP=To(Do(zf,Eo(SP))),wP=r(e=>vP(e[0]),(e,t,n)=>{e.state._tag===`Closed`?t.interruptUnsafe(SP):e.state.backing.has(t)||(e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),ip(r)&&(n?.propagateInterruption===!0?!CP(r.cause):!Mf(r.cause))&&vp(e.deferred,r))}))}),TP=function(){let e;return()=>(e===void 0&&(e=F_(y_)),e)}(),EP=function(){let e=arguments[0];if(!dg(arguments[1])){let t=arguments[1];return n=>DP(e,n,t)}return DP(e,arguments[1],arguments[2])},DP=(e,t,n)=>Eg(r=>{if(e.state._tag===`Closed`)return B(TP);let i=id(r,t,n?.startImmediately??!0,!0);return wP(e,i,n),R(i)}),OP=e=>()=>W(n_(),t=>{let n=I_(t);return(t,r)=>{if(e.state._tag===`Closed`)return TP();let i=n(t,r);return wP(e,i,r),i}}),kP=e=>mg({while:()=>e.state._tag===`Open`&&e.state.backing.size>0,body:()=>tv(qr(e)),step:l}),AP=`4.1.2`,jP=()=>AP,MP=e=>{let t=e===void 0?void 0:GC(e);return t===void 0||D(t)?R(uo(5)):W(qf,e=>KC(t.success,e.currentTimeMillisUnsafe()))},NP=qh.pipe(Wh,zh(({output:e})=>PM(e)&&e.reason._tag===`StatusCodeError`&&e.reason.response.status===429?MP(e.reason.response.headers[`retry-after`]):R(uo(1)))),PP=class extends Ki()(`effect/observability/OtlpExporter/Flusher`){},FP=Jp(PP,()=>{let e=new Set;return{flush:z(()=>e.size===0?V:pg(e,i,{concurrency:`unbounded`,discard:!0})),register:t=>U(Cp,n=>(e.add(t),Dp(n,B(()=>e.delete(t)))))}}),IP=W_(function*(e){let t=yield*n_(),n=O(t,qf),r=O(t,Cp),i=bo(Ga(e.exportInterval),ao),a=O(t,RN).pipe(JN(e=>Gg(e.arrayBuffer)),YN(e=>e.response?Gg(e.response.arrayBuffer):V),VN,BN(c_(QN,!1)),KN({schedule:NP,times:3})),o=`OTel-OTLP-Exporter-JavaScript-Effect-${e.label}/${jP()}`,s=DC(e.headers),c=s[`user-agent`],l=kC(s,`user-agent`,c?`${c} ${o}`:o),u=lN(e.url,{headers:l}),d=e.maxBatchSize===`disabled`&&e.exportEmpty===!0,f=[],p,m=()=>p===void 0?!1:n.currentTimeMillisUnsafe()<p||(p=void 0,!1),h=z(()=>{if(m()||f.length===0&&!d)return V;let t=f;f=[];let[n,r]=e.body(t),i=yN(u,n);return(e.compression===`gzip`?bN(i,`gzip`).pipe(U(a.execute)):a.execute(i)).pipe(kg(r),Pg,E_(!1))}).pipe(Ig(e=>p===void 0?(p=n.currentTimeMillisUnsafe()+6e4,f=[],q_(`Disabling exporter for 60 seconds`,e)):V),J_({package:`@effect/opentelemetry`,module:e.label})),g=yield*xP(),ee=yield*OP(g)();yield*Dp(r,z(()=>p===void 0?(ee(h),kP(g)):V).pipe(Gg,b_,Jg(e.shutdownTimeout)));let _=yield*yv(d),te=yield*yv(),ne=B(()=>{d||f.length>0||!_.closeUnsafe()||te.openUnsafe()});yield*bg(function*(){for(;;)te.closeUnsafe(),yield*_.await,yield*Qg(Zg(i),te.await),yield*tv(yield*EP(g,h)),yield*ne}).pipe(M_(r));let re=kg(h,ne);return yield*(yield*PP).register(re),{push(t){m()||(f.push(t),e.maxBatchSize!==`disabled`&&f.length>=e.maxBatchSize?ee(re):_.openUnsafe())}}}),LP=sf,RP=uf,zP=(e,t)=>Xp(LP,w(Ec(function*(n){let r=new Set(t?.mergeWithExisting===!0?n.getRef(sf):[]);for(let t of e)r.add(Xt(t)?yield*t:t);return r}))),BP=`window`in globalThis||`importScripts`in globalThis,VP=e=>({attributes:UP(Object.entries({"telemetry.sdk.name":`effect`,"telemetry.sdk.language":BP?`webjs`:`nodejs`,"telemetry.sdk.version":jP(),...e.attributes,...e.serviceName?{"service.name":e.serviceName}:void 0,...e.serviceVersion?{"service.version":e.serviceVersion}:void 0})),droppedAttributesCount:0}),HP=W_(function*(e){let t=yield*qj(ij,ij,`OTEL_RESOURCE_ATTRIBUTES`,{trim:!0,keepEmptyValues:!0}).pipe(Mj(void 0)),n=e?.serviceName??e?.attributes?.[`service.name`]??(yield*Uj(AA(pA),`OTEL_SERVICE_NAME`))??t?.[`service.name`]??(yield*Gj(`OTEL_SERVICE_NAME`)),r=e?.serviceVersion??e?.attributes?.[`service.version`]??(yield*Uj(AA(pA),`OTEL_SERVICE_VERSION`))??t?.[`service.version`],i={...t,...e?.attributes};return delete i[`service.name`],delete i[`service.version`],VP({serviceName:n,serviceVersion:r,attributes:i})},Bg),UP=e=>{let t=[];for(let[n,r]of e)t.push({key:n,value:GP(r)});return t},WP=2**63,GP=e=>{if(Array.isArray(e))return{arrayValue:{values:e.map(GP)}};switch(typeof e){case`string`:return{stringValue:e};case`bigint`:return BigInt.asIntN(64,e)===e?{intValue:String(e)}:{stringValue:String(e)};case`number`:return Number.isInteger(e)&&e>=-WP&&e<WP?{intValue:Number.isSafeInteger(e)?e:String(BigInt(e))}:{doubleValue:e};case`boolean`:return{boolValue:e};default:return{stringValue:x(e)}}},KP=class extends Ki()(`effect/observability/OtlpSerialization`){};function qP(e,t){return typeof t==`number`&&!Number.isFinite(t)?String(t):e===`bytesValue`&&this[e]instanceof Uint8Array?PS(this[e]):t}var JP=e=>{let t=JSON.stringify(e);return OM(t.includes(`null`)||t.includes(`"bytesValue":`)?JSON.stringify(e,qP):t,`application/json`)},YP=Gp(KP,{traces:e=>JP(e),metrics:e=>JP(e),logs:e=>JP(e)}),XP=W_(function*(e){let t=yield*KP,n=yield*HP(e.resource),r={name:`effect`,version:jP()},i=yield*IP({label:`OtlpLogger`,url:e.url,headers:e.headers,compression:e.compression,maxBatchSize:e.maxBatchSize??1e3,exportInterval:e.exportInterval??uo(1),body:e=>[t.logs({resourceLogs:[{resource:n,scopeLogs:[{scope:r,logRecords:e}]}]}),V],shutdownTimeout:e.shutdownTimeout??uo(3)}),a={excludeLogSpans:e.excludeLogSpans??!1,clock:yield*qf};return RP(e=>{i.push($P(e,a))})}),ZP=e=>zP([XP(e)],{mergeWithExisting:e.mergeWithExisting??!0}).pipe(om(FP)),QP=BigInt(1e6),$P=(e,t)=>{let n=t.clock.currentTimeNanosUnsafe().toString(),r=e.date.getTime(),i=(BigInt(r)*QP).toString(),a={...e.fiber.getRef(bp)};if(a[`effect.fiberId`]=e.fiber.id,!t.excludeLogSpans)for(let[t,n]of e.fiber.getRef(xp))a[`effect.log_span.${t}`]=r-n;let o=Bf(e.cause,{includeCauseInStack:!0});o.length>0&&(a[`exception.type`]=o[0].name,a[`exception.message`]=o[0].message,a[`exception.stacktrace`]=o.map(e=>e.stack).join(`
15
+ `));let s=di(e.message),c={severityNumber:eF(e.logLevel),severityText:e.logLevel,timeUnixNano:i,observedTimeUnixNano:n,attributes:UP(Object.entries(a)),body:GP(s.length===1?s[0]:s),droppedAttributesCount:0};return e.fiber.cache.span&&(c.traceId=e.fiber.cache.span.traceId.padStart(32,`0`),c.spanId=e.fiber.cache.span.spanId),c},eF=e=>{switch(e){case`Trace`:return tF.SEVERITY_NUMBER_TRACE;case`Debug`:return tF.SEVERITY_NUMBER_DEBUG;case`Info`:return tF.SEVERITY_NUMBER_INFO;case`Warn`:return tF.SEVERITY_NUMBER_WARN;case`Error`:return tF.SEVERITY_NUMBER_ERROR;case`Fatal`:return tF.SEVERITY_NUMBER_FATAL;default:return tF.SEVERITY_NUMBER_UNSPECIFIED}},tF={SEVERITY_NUMBER_UNSPECIFIED:0,SEVERITY_NUMBER_TRACE:1,SEVERITY_NUMBER_TRACE2:2,SEVERITY_NUMBER_TRACE3:3,SEVERITY_NUMBER_TRACE4:4,SEVERITY_NUMBER_DEBUG:5,SEVERITY_NUMBER_DEBUG2:6,SEVERITY_NUMBER_DEBUG3:7,SEVERITY_NUMBER_DEBUG4:8,SEVERITY_NUMBER_INFO:9,SEVERITY_NUMBER_INFO2:10,SEVERITY_NUMBER_INFO3:11,SEVERITY_NUMBER_INFO4:12,SEVERITY_NUMBER_WARN:13,SEVERITY_NUMBER_WARN2:14,SEVERITY_NUMBER_WARN3:15,SEVERITY_NUMBER_WARN4:16,SEVERITY_NUMBER_ERROR:17,SEVERITY_NUMBER_ERROR2:18,SEVERITY_NUMBER_ERROR3:19,SEVERITY_NUMBER_ERROR4:20,SEVERITY_NUMBER_FATAL:21,SEVERITY_NUMBER_FATAL2:22,SEVERITY_NUMBER_FATAL3:23,SEVERITY_NUMBER_FATAL4:24},nF=d(W_(function*(e){let t=yield*HP(e.resource),n=yield*KP,r={name:`effect`,version:jP()},i=yield*IP({label:`OtlpTracer`,url:e.url,headers:e.headers,compression:e.compression,exportInterval:e.exportInterval??uo(5),maxBatchSize:e.maxBatchSize??1e3,body(e){let i={resourceSpans:[{resource:t,scopeSpans:[{scope:r,spans:e}]}]};return[n.traces(i),V]},shutdownTimeout:e.shutdownTimeout??uo(3)});function a(e){e.sampled&&i.push(iF(e))}return Xo({span(e){return new rF(e,a)},context:e.context?function(t,n){return n.cache.span===void 0?t[`~effect/Effect/evaluate`](n):e.context(t,n.cache.span)}:void 0})}),Xp(ts),om(FP)),rF=class{_tag=`Span`;name;parent;annotations;links;kind;sampled;export;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e,t){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.kind=e.kind,this.sampled=e.sampled,this.export=t,this.status={_tag:`Started`,startTime:e.startTime}}get traceId(){return this._traceId??=br(this.parent)?this.parent.value.traceId:Uo(32)}get spanId(){return this._spanId??=Uo(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){this.status._tag!==`Ended`&&(this.status={_tag:`Ended`,startTime:this.status.startTime,endTime:e,exit:t},this.export(this))}attribute(e,t){this.status._tag!==`Ended`&&this.attributes.set(e,t)}event(e,t,n){this.status._tag!==`Ended`&&this.events.push([e,t,n])}addLinks(e){this.status._tag!==`Ended`&&this.links.push(...e)}},iF=e=>{let t=e.status,n=e._attributes===void 0?[]:UP(e._attributes),r=[];if(e._events!==void 0)for(let t=0;t<e._events.length;t++){let[n,i,a]=e._events[t];r.push({name:n,timeUnixNano:String(i),attributes:a?UP(Object.entries(a)):[],droppedAttributesCount:0})}let i;if(t.exit._tag===`Success`)i={code:aF.Ok};else if(Mf(t.exit.cause))i={code:aF.Unset},n.push({key:`effect.fiber.interrupted`,value:{boolValue:!0}});else{let e=Bf(t.exit.cause,{includeCauseInStack:!0});i=e.length>0?{code:aF.Error,message:e[0].message}:{code:aF.Ok};for(let n of e)r.push({name:`exception`,timeUnixNano:String(t.endTime),droppedAttributesCount:0,attributes:[{key:`exception.type`,value:{stringValue:n.name}},{key:`exception.message`,value:{stringValue:n.message}},{key:`exception.stacktrace`,value:{stringValue:n.stack??`No stack trace available`}}]})}let a=[];for(let t=0;t<e.links.length;t++){let n=e.links[t];a.push({traceId:n.span.traceId.padStart(32,`0`),spanId:n.span.spanId,attributes:UP(Object.entries(n.attributes)),droppedAttributesCount:0})}return{traceId:e.traceId.padStart(32,`0`),spanId:e.spanId,parentSpanId:br(e.parent)?e.parent.value.spanId:void 0,name:e.name,kind:oF[e.kind],startTimeUnixNano:String(t.startTime),endTimeUnixNano:String(t.endTime),attributes:n,droppedAttributesCount:0,events:r,droppedEventsCount:0,status:i,links:a,droppedLinksCount:0}},aF={Unset:0,Ok:1,Error:2},oF={unspecified:0,internal:1,server:2,client:3,producer:4,consumer:5},sF=`~effect/reactivity/AsyncResult`,cF=e=>v(e,sF),lF={[sF]:{E:i,A:i},pipe(){return e(this,arguments)},[Be](e){if(!cF(e)||this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case`Initial`:return!0;case`Success`:return Ve(this.value,e.value);case`Failure`:return Ve(this.cause,e.cause)}},[xe](){let e=ke(`${this._tag}:${this.waiting}`);return this._tag===`Initial`?e:we(e)(this._tag===`Success`?y(this.value):y(this.cause))}},uF=e=>e.waiting,dF=e=>e._tag===`Success`?vF(e.value):bF(e.cause),fF=(e,t)=>e._tag===`Success`?vF(e.value):xF(e.cause,{previous:t}),pF=e=>e._tag===`None`?gF(!0):CF(e.value),mF=e=>e._tag===`Initial`,hF=e=>e._tag!==`Initial`,gF=(e=!1)=>{let t=Object.create(lF);return t._tag=`Initial`,t.waiting=e,t},_F=e=>e._tag===`Success`,vF=(e,t)=>{let n=Object.create(lF);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},yF=e=>e._tag===`Failure`,bF=(e,t)=>{let n=Object.create(lF);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??T(),n.waiting=t?.waiting??!1,n},xF=(e,t)=>bF(e,{previousSuccess:jr(t.previous,e=>_F(e)?E(e):yF(e)?e.previousSuccess:T()),waiting:t.waiting}),SF=(e,t)=>xF(Ef(e),t),CF=r(e=>cF(e[0]),(e,t)=>{if(e.waiting)return t?.touch?wF(e):e;let n=Object.assign(Object.create(lF),e);return n.waiting=!0,t?.touch&&_F(n)&&(n.timestamp=Date.now()),n}),wF=e=>_F(e)?vF(e.value,{waiting:e.waiting}):e,TF=r(2,(e,t)=>e._tag===`Failure`?xF(e.cause,{previous:t,waiting:e.waiting}):e),EF=e=>e._tag===`Success`?E(e.value):e._tag===`Failure`?Ar(e.previousSuccess,e=>e.value):T(),DF=r(2,(e,t)=>Sr(EF(e),t)),OF=e=>kr(EF(e),()=>new Vf(`AsyncResult.getOrThrow: no value found`)),kF=e=>e._tag===`Failure`?If(e.cause):T(),AF=e=>{switch(e._tag){case`Success`:return Zf(e.value);case`Failure`:return Qf(e.cause);default:return $f(new Vf)}},jF=r(2,(e,t)=>{switch(e._tag){case`Initial`:return e;case`Failure`:return bF(e.cause,{previousSuccess:Ar(e.previousSuccess,e=>vF(t(e.value),e)),waiting:e.waiting});case`Success`:return vF(t(e.value),e)}}),MF=e=>{let t=ye(e),n=t?Array.from(e,(e,t)=>[t,e]):Object.entries(e),r=t?[]:{},i=!1;for(let e=0;e<n.length;e++){let[a,o]=n[e];if(!cF(o))b(r,a,o);else{if(yF(o))return bF(o.cause,{previousSuccess:NF(n,t),waiting:o.waiting});if(!_F(o))return o;b(r,a,o.value),o.waiting&&(i=!0)}}return vF(r,{waiting:i})},NF=(e,t)=>{let n=t?[]:{};for(let t=0;t<e.length;t++){let[r,i]=e[t];if(!cF(i)){b(n,r,i);continue}let a=EF(i);if(yr(a))return T();b(n,r,a.value)}return E(vF(n))},PF=e=>{let t=e.success??lA,n=e.error??lA,r=Rk()([t,cj(n,tj())],([e,t])=>(n,r,i)=>{if(!cF(n))return H(new Lw(r,n,i));switch(n._tag){case`Initial`:return R(n);case`Success`:return Z_(KO(e)(n.value,i),{onSuccess:e=>vF(e,n),onFailure:e=>zw(r,`value`,e,n,i)});case`Failure`:{let a=n.previousSuccess.pipe(Ar(t=>Z_(KO(e)(t.value,i),{onSuccess:e=>E(vF(e,t)),onFailure:e=>new Iw(r,[new Nw([`previousSuccess`,`value`],e)],n,i)})),Sr(()=>_g)),o=X_(KO(t)(n.cause,i),e=>zw(r,`cause`,e,n,i));return Q_(a,e=>Y_(o,t=>bF(t,{previousSuccess:e,waiting:n.waiting})))}}},{expected:`AsyncResult`,toCodec([e,t]){let n=IA(`Success`,{value:e,waiting:hA,timestamp:GA});return BA()(DA([IA(`Initial`,{waiting:hA}),n,IA(`Failure`,{cause:t,previousSuccess:uj(n),waiting:hA})]),FT({decode:e=>{switch(e._tag){case`Initial`:return gF(e.waiting);case`Success`:return vF(e.value,{waiting:e.waiting,timestamp:e.timestamp});case`Failure`:return bF(e.cause,{previousSuccess:Ar(e.previousSuccess,e=>vF(e.value,e)),waiting:e.waiting})}},encode(e){switch(e._tag){case`Initial`:return{_tag:`Initial`,waiting:e.waiting};case`Success`:return{_tag:`Success`,value:e.value,waiting:e.waiting,timestamp:e.timestamp};case`Failure`:return{_tag:`Failure`,cause:e.cause,previousSuccess:e.previousSuccess,waiting:e.waiting}}}}))},toEquivalence:nt,toFormatter:([e,t])=>n=>{switch(n._tag){case`Success`:return`AsyncResult.Success(${e(n.value)}, ${n.waiting}, ${n.timestamp})`;case`Failure`:return`AsyncResult.Failure(${t(n.cause)}, ${n.waiting})`;case`Initial`:return`AsyncResult.Initial(${n.waiting}, ${n.waiting})`}}});return Object.assign(r,{success:t,error:n})},FF=`~effect/reactivity/Reactivity`,IF=Ki(`effect/reactivity/Reactivity`),LF=B(()=>{let e=new Map,t=t=>{let n=new Set;for(let r of t)e.get(r)?.forEach(e=>{n.has(e)||(n.add(e),e())})},n=e=>{let n=new Set;UF(e,e=>n.add(e)),t(n)},r=e=>r_(t=>{let r=ma(t,RF);return r?UF(e,e=>{r.add(e)}):n(e),V}),i=(e,t)=>Ag(t,r(e)),a=(t,n)=>{let r=[];return UF(t,t=>{r.push(t);let i=e.get(t);i===void 0&&(i=new Set,e.set(t,i)),i.add(n)}),()=>{for(let t=0;t<r.length;t++){let i=e.get(r[t]);i!==void 0&&(i.delete(n),i.size===0&&e.delete(r[t]))}}},o=(e,t)=>bg(function*(){let n=yield*n_(),r=O(n,Cp),i=yield*yy(),o=d(I_(n),sv(r)),s=!1,c=!1,l=!1,u=e=>{e._tag===`Failure`?(l=!0,c=!1,s=!1,p(),Ey(i,e.cause)):(Sy(i,e.value),c?(c=!1,o(t).addObserver(u)):s=!1)};function f(){l||(s?c=!0:(s=!0,o(t).addObserver(u)))}let p=a(e,f);return yield*Dp(r,B(p)),f(),i}),s=(e,t)=>o(e,t).pipe(W(Ex),Ax),c=e=>z(()=>{let n=new Set;return e.pipe(c_(RF,n),__(e=>B(()=>t(n))))});return IF.of({[FF]:FF,mutation:i,query:o,stream:s,invalidateUnsafe:n,invalidate:r,registerUnsafe:a,withBatch:c})}),RF=class extends Ki()(`effect/reactivity/Reactivity/PendingInvalidation`){},zF=r(2,(e,t)=>IF.use(n=>n.mutation(t,e))),BF=e=>IF.use(t=>t.invalidate(e)),VF=Xp(IF)(LF);function HF(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return y(e)}}var UF=(e,t)=>{if(Array.isArray(e))for(let n=0;n<e.length;n++)t(HF(e[n]));else for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${HF(r[e])}`)}},WF=`~effect/SubscriptionRef`,GF=e=>v(e,WF);({...Jt});var KF=e=>Dx(e.pubsub),qF=e=>B(()=>e.value),JF=(e,t)=>{e.value=t,qv(e.pubsub,t)},YF=r(2,(e,t)=>e.semaphore.withPermit(B(()=>JF(e,t)))),XF=(e,t)=>!cF(e)||!cF(t)?!0:mF(t)?mF(e):_F(e)&&_F(t)?t.timestamp>=e.timestamp:!0,ZF=`~effect/reactivity/AtomRegistry`,QF=e=>v(e,ZF),$F=e=>new cI(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),eI=Ki(ZF),tI=r(e=>QF(e[0]),(e,t,n)=>{let r=n?.suspendOnWaiting??!1;return vg(n=>{let i=e.get(t);if(i._tag!==`Initial`&&!(r&&i.waiting))return n(AF(i));let a=e.subscribe(t,e=>{e._tag!==`Initial`&&!(r&&e.waiting)&&(n(AF(e)),a())});return B(a)})}),nI={immediate:!0},rI=e=>{e()},iI={};function aI(e,t){let n=iI;for(let r of e)try{t(r)}catch(e){n===iI&&(n=e)}if(n!==iI)throw n}var oI=`~effect-atom/atom/Atom/Serializable`,sI=e=>oI in e?e[oI].key:e,cI=class{[ZF];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(e,t,n,r){if(this[ZF]=ZF,this.scheduler=new Po(`sync`,t),this.schedulerAsync=new Po(`async`,t),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=r,this.timeoutResolution=n===void 0&&r!==void 0?Math.round(r/2):n??1e3,e!==void 0)for(let[t,n,r]of e){let e=t;for(;e.initialValueTarget;)e=e.initialValueTarget;this.ensureNode(e).setInitialValue(n,r?.skipInitialRun)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(e){return this.ensureNode(e).value()}set(e,t){e.write(this.ensureNode(e).writeContext,t)}setSerializable(e,t){this.preloadedSerializable.set(e,t)}modify(e,t){let n=this.ensureNode(e),r=t(n.value());return e.write(n.writeContext,r[1]),r[0]}update(e,t){let n=this.ensureNode(e);e.write(n.writeContext,t(n.value()))}refresh=e=>{e.refresh===void 0?this.invalidateAtom(e):e.refresh(this.refresh)};subscribe(e,t,n){let r=this.ensureNode(e);if(n?.immediate)t(r.value());else try{r.value()}catch(e){if((r.state&lI.waitingForValue)===0)throw e}let i=r.subscribe(function(){t(r._value)});return()=>{i(),r.canBeRemoved&&this.scheduleNodeRemoval(r)}}mount(e){return this.subscribe(e,l,nI)}atomHasTtl(e){return!e.keepAlive&&e.idleTTL!==0&&(e.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(e){let t=sI(e),n=this.nodes.get(t);if(n===void 0?(n=this.createNode(e),this.nodes.set(t,n),this.onNodeAdded?.(n)):this.atomHasTtl(e)&&this.removeNodeTimeout(n),typeof t==`string`&&this.preloadedSerializable.has(t)){let r=this.preloadedSerializable.get(t);this.preloadedSerializable.delete(t);let i=e[oI],a;try{a=i.decode(r)}catch(e){if(Vk(e))return n;throw e}let o=e;for(;o.initialValueTarget;)o=o.initialValueTarget;let s=o===e?n:this.ensureNode(o);XF(s._value,a)&&s.setInitialValue(a,i.skipInitialRun)}return n}createNode(e){if(this.disposed)throw Error(`Cannot access Atom ${e}: registry is disposed`);return e.keepAlive||this.scheduleAtomRemoval(e),new dI(this,e)}invalidateAtom=e=>{let t=this.ensureNode(e);t.skipInitialRun=!1,t.invalidate()};scheduleAtomRemoval(e){this.dispatcher.scheduleTask(()=>{let t=this.nodes.get(sI(e));t!==void 0&&t.canBeRemoved&&this.removeNode(t)},0)}scheduleNodeRemoval(e){this.dispatcher.scheduleTask(()=>{e.canBeRemoved&&this.removeNode(e)},0)}removeNode(e){this.atomHasTtl(e.atom)?this.setNodeTimeout(e):(this.nodes.delete(sI(e.atom)),e.remove(),this.onNodeRemoved?.(e))}setNodeTimeout(e){if(this.nodeTimeoutBucket.has(e))return;let t=e.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(t-=this.#e,t<=0)){this.nodes.delete(sI(e.atom)),e.remove(),this.onNodeRemoved?.(e);return}let n=Math.ceil(t/this.timeoutResolution)*this.timeoutResolution,r=Date.now()+n,i=r-r%this.timeoutResolution+this.timeoutResolution,a=this.timeoutBuckets.get(i);a===void 0&&(a=[new Set,setTimeout(()=>this.sweepBucket(i),i-Date.now())],this.timeoutBuckets.set(i,a)),a[0].add(e),this.nodeTimeoutBucket.set(e,i)}removeNodeTimeout(e){let t=this.nodeTimeoutBucket.get(e);if(t===void 0)return;this.nodeTimeoutBucket.delete(e),this.scheduleNodeRemoval(e);let[n,r]=this.timeoutBuckets.get(t);n.delete(e),n.size===0&&(clearTimeout(r),this.timeoutBuckets.delete(t))}#e=null;sweepBucket(e){let t=this.timeoutBuckets.get(e)[0];this.timeoutBuckets.delete(e),aI(t,this.removeIdleNode)}removeIdleNode=e=>{if(this.nodeTimeoutBucket.delete(e),e.canBeRemoved){this.nodes.delete(sI(e.atom)),this.onNodeRemoved?.(e),this.#e=e.atom.idleTTL??this.defaultIdleTTL;try{e.remove()}finally{this.#e=null}}};reset(){this.timeoutBuckets.forEach(([,e])=>clearTimeout(e)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear();let e=Array.from(this.nodes.values());this.nodes.clear();for(let t of e)t.state=uI.removed;aI(e,this.destroyNode)}destroyNode=e=>{e.remove(),this.onNodeRemoved?.(e)};dispose(){this.disposed=!0,this.reset()}},lI={alive:1,initialized:2,waitingForValue:4},uI={uninitialized:lI.alive|lI.waitingForValue,stale:lI.alive|lI.initialized|lI.waitingForValue,valid:lI.alive|lI.initialized,removed:0},dI=class{constructor(e,t){this.registry=e,this.atom=t,this.writeContext=new hI(e,this)}registry;atom;state=uI.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;skipInitialRun=!1;keptParents;invalidatedDuringBuild=!1;failed=!1;parents=new Set;children=new Set;listeners=new Set;observedChildren=0;currentState(){switch(this.state){case uI.uninitialized:return`uninitialized`;case uI.stale:return`stale`;case uI.valid:return`valid`;default:return`removed`}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.size===0&&this.state!==0}get building(){return this.lifetime!==void 0&&this.lifetime.reads!==void 0}get isObserved(){return!this.atom.lazy||this.listeners.size>0||this.observedChildren>0}childObserved(e){let t=this.isObserved;this.observedChildren+=e,t!==this.isObserved&&this.observedChanged(e)}observedChanged(e){for(let t of this.parents)t.childObserved(e)}_value=void 0;value(){for(;(this.state&lI.waitingForValue)!==0;)this.build();return this._value}build(){let e=mI(this);try{this.disposeLifetime()}catch(t){e.failure=t}this.invalidatedDuringBuild=!1,this.lifetime=e;let t,n=!1;try{t=this.atom.read(e),n=!0}finally{let t=e.reads;e.reads=void 0,this.lifetime===e&&(this.dropUnread(t),n||this.fail())}if(this.lifetime===e&&(this.state&lI.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.skipInitialRun&&(this.keptParents=Array.from(this.parents,e=>[e,e.lifetime])),this.failed=!1,this.state=uI.valid):this.setValue(t)),e.failure!==iI)throw e.failure}fail(){this.failed=!0;try{this.invalidateChildren()}catch{}}readTracked(e,t){let n=this.registry.ensureNode(e);this.parents.has(n)||(this.parents.add(n),n.children.add(this),this.isObserved&&n.childObserved(1));try{return n.value()}catch(e){if(t.reads===void 0||n.state!==uI.valid)throw e;return t.failure===iI&&(t.failure=e),n._value}finally{t.reads!==void 0&&!t.disposed&&t.reads.add(n)}}dropUnread(e){if(e.size===this.parents.size)return;let t=this.isObserved;for(let n of this.parents)e.has(n)||(this.parents.delete(n),n.children.delete(this),t&&n.childObserved(-1),n.canBeRemoved&&this.registry.scheduleNodeRemoval(n))}valueOption(){return(this.state&lI.initialized)===0?T():E(this._value)}setInitialValue(e,t=!1){(this.state&lI.initialized)===0?(this.preserveInitialValueOnBuild=!0,this.skipInitialRun=t,this.state=uI.stale,this._value=e,this.listeners.size>0&&this.announce()):this.setValue(e)}setValue(e){let t=this.failed;this.failed=!1;let n=(this.state&lI.initialized)!==0;if(this.state=uI.valid,n&&this.atom.equals(this._value,e)){t&&this.invalidateChildren();return}this._value=e;let r=iI;try{(n||t)&&this.invalidateChildren()}catch(e){r=e}if(this.listeners.size>0)try{this.announce()}catch(e){r===iI&&(r=e)}if(r!==iI)throw r}announce(){_I.phase===gI.collect?_I.notify.add(this):this.notify()}invalidate(){if(this.state===uI.valid){this.state=uI.stale;try{this.disposeLifetime()}finally{this.propagate()}}else this.building&&_I.phase!==gI.collect?this.build():this.propagate()}propagate(){_I.phase===gI.collect?(this.building&&(this.invalidatedDuringBuild=!0),_I.stale.push(this)):this.isObserved?this.value():this.invalidateChildren()}invalidateChildren(){if(this.children.size===0)return;let e=iI;for(let t of Array.from(this.children))if(t.affectedBy(this))try{t.invalidate()}catch(t){e===iI&&(e=t)}if(e!==iI)throw e}affectedBy(e){if(this.state===uI.valid)return!0;let t=this.lifetime?.reads;return t===void 0?this.isObserved&&e.state===uI.valid:t.has(e)}notify(){_I.phase===gI.commit&&_I.notify.delete(this),aI(this.listeners,rI)}disposeLifetime(){let e=this.lifetime;e!==void 0&&(this.lifetime=void 0,e.dispose())}remove(){let e=this.isObserved;this.state=uI.removed,this.listeners.clear();try{this.disposeLifetime()}finally{let t=Array.from(this.parents);this.parents.clear(),aI(t,t=>{t.children.delete(this),e&&t.childObserved(-1),t.canBeRemoved&&this.registry.removeNode(t)})}}subscribe(e){let t=this.isObserved;return this.listeners.add(e),t||this.observedChanged(1),()=>{this.listeners.delete(e)&&!this.isObserved&&this.observedChanged(-1)}}},fI=e=>{let t=e,n=t.node;if(!n.skipInitialRun)return!1;let r=n.keptParents;return n.skipInitialRun=!1,n.keptParents=void 0,!t.isFn&&!mF(n._value)&&(r===void 0||r.every(([e,t])=>e.lifetime===t))},pI={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){return this.disposed?this.node.registry.get(e):this.node.readTracked(e,this)},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let n=this.get(e);if(t?.suspendOnWaiting&&n.waiting)return yg;switch(n._tag){case`Initial`:return yg;case`Failure`:return Qf(n.cause);case`Success`:return R(n.value)}},resultOnce(e,t){return vg(n=>{let r=this.once(e);if(r._tag!==`Initial`&&!(t?.suspendOnWaiting&&r.waiting))return n(AF(r));let i=this.node.registry.subscribe(e,e=>{e._tag===`Initial`||t?.suspendOnWaiting&&e.waiting||(i(),n(AF(e)))},{immediate:!1});return B(i)})},setResult(e,t){return this.disposed?yg:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag===`None`?yg:R(t.value)},someOnce(e){return vg(t=>{let n=this.once(e);if(br(n))return t(R(n.value));let r=this.node.registry.subscribe(e,e=>{yr(e)||(r(),t(R(e.value)))},{immediate:!1});return B(r)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?T():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,n){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,n))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?vx:_x(n=>B(()=>{this.subscribe(e,e=>Sy(n,e),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(Lx(hF),Mx(e=>e._tag===`Success`?R(e.value):xg(e.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0,aI(e.reverse(),rI)}},mI=e=>{function t(n){return t.disposed||t.isFn?e.registry.get(n):e.readTracked(n,t)}return Object.setPrototypeOf(t,pI),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t.reads=new Set,t.failure=iI,t},hI=class{constructor(e,t){this.registry=e,this.node=t}registry;node;get(e){return this.registry.get(e)}set(e,t){return this.registry.set(e,t)}setSelf(e){return this.node.setValue(e)}refreshSelf(){return this.node.invalidate()}},gI={disabled:0,collect:1,commit:2},_I={phase:gI.disabled,depth:0,stale:[],notify:new Set};function vI(e){let t=_I.phase;_I.phase=gI.collect,_I.depth++;let n=iI;try{e()}catch(e){n=e}if(_I.depth===1){let{notify:e,stale:t}=_I,r=0;do{for(_I.phase=gI.collect;r<t.length;r++)try{yI(t[r])}catch(e){n===iI&&(n=e)}_I.phase=gI.commit;for(let t of e)try{t.notify()}catch(e){n===iI&&(n=e)}}while(r<t.length);_I.stale=[],e.clear()}if(_I.depth--,_I.phase=t,n!==iI)throw n}function yI(e){if(e.state===uI.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=uI.stale,e.disposeLifetime()}e.value()}var bI=`~effect/reactivity/Atom`,xI=e=>v(e,bI),SI=`~effect/reactivity/Atom/Writable`,CI=r(2,(e,t)=>{let n=Ga(t),r=to(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?fo(n):void 0})}),wI=CI(0),TI={[bI]:bI,equals:Object.is,...Jt,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},EI={...TI,atom(e,t){let n=PI(e,t);return AI(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):TF(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>DI(this,e,t):DI(this,e,t)},pull(e,t){let n=wI(LI(0));return eL(n,AI(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?zI(r,$I(r,n,e,t),gF(!0),a.value):TF(a,i)}))},subscriptionRef(e){return qI(wI(AI(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return TF(r,n);let i=typeof e==`function`?e(t):e;return GF(i)?i:zI(t,i,gF(!0),r.value)})),(e,t)=>KI(e,t,OF(e(this))))}},DI=(e,t,n)=>{let[r,i,a]=QI(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return dg(i)?zF(i,n.reactivityKeys):Ux(i,BF(n.reactivityKeys))}:t,n);return jI(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):TF(i,n)},i)},OI={...TI,[SI]:SI},kI=e=>SI in e,AI=(e,t)=>{let n=Object.create(TI);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},jI=(e,t,n)=>{let r=Object.create(OI);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function MI(e,t){e.setSelf(t)}var NI=(e,t)=>{let n=PI(e,t);return`~effect/reactivity/Atom`in n?n:AI(n)},PI=(e,t)=>{if(typeof e==`function`&&!dg(e)&&!px(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:FI in i?RI(e,i,t,r):II in i?WI(e,i,t,r):i;default:return i}}}return dg(e)?function(n,r){return RI(n,e,t,r)}:px(e)?function(n,r){return WI(n,e,t,r)}:LI(e)},FI=`~effect/Effect`,II=`~effect/Stream`,LI=e=>jI(function(t){return e},MI),RI=(e,t,n,r)=>zI(e,t,n?.initialValue===void 0?gF():vF(n.initialValue),r,n?.uninterruptible);function zI(e,t,n,r=la(),i=!1){let o=e.self();if(o._tag===`Some`&&fI(e))return o.value;let s=typeof r==`function`?r:a(r),c=wp();e.addFinalizer(()=>{I_(s())(BI(c))});let l,u=!1,d=VI(s().pipe(fa(Cp,c),fa(eI,e.registry),fa(ko,e.registry.scheduler)),t,function(t){u?e.setSelf(fF(t,e.self())):l=fF(t,o)},i);return u=!0,d!==void 0&&e.addFinalizer(d),l===void 0?o._tag===`Some`?pF(o):CF(n):l}var BI=e=>Ig(kp(e,np),e=>Mf(e)?V:Kg(xg(e),{log:`Unhandled`,message:`Unhandled error in atom finalizer`}));function VI(e,t,n,r=!1){if(Xf(t)){n(t);return}let i=I_(e)(t);i.currentDispatcher?.flush();let a=i.pollUnsafe();if(a){n(a);return}let o=i.addObserver(n);function s(){o(),r||i.interruptUnsafe()}return s}function HI(e){let t=e?.memoMap??wI(NI(()=>Bp())),n=e=>xI(t)?e(t):t,r=VF;function i(e){let t=Object.create(EI);t.keepAlive=!1,t.lazy=!0,t.refresh=void 0,t.factory=i;let a=nL(AI(typeof e==`function`?e:()=>e));return t.layer=a,t.read=function(e){let t=om(e(a),r),i=la();return zI(e,U(l_,r=>W(Up(t,n(e),r),e=>(i=e,e))),gF(),()=>i,!0)},t}i.memoMap=t,i.addGlobalLayer=e=>{r=om(r,am(e,VF))};let a=wI(NI(e=>r_(t=>Up(VF,n(e),O(t,Cp))).pipe(W(O(IF)))));return i.withReactivity=e=>t=>aL(t,n=>{let r=OF(n(a));return n.addFinalizer(r.registerUnsafe(e,()=>{n.refresh(t)})),n.subscribe(t,e=>n.setSelf(e)),n.once(t)},{initialValueTarget:t}),i}var UI=HI();UI.withReactivity;var WI=(e,t,n,r)=>GI(e,t,n?.initialValue===void 0?gF():vF(n.initialValue),r);function GI(e,t,n,r=la()){let i=e.self();if(i._tag===`Some`&&fI(e))return i.value;r=fa(r,eI,e.registry);let a=d_(n=>U(sx(t.channel,n),t=>mg({while:o,body:()=>t,step(t){e.setSelf(vF(Si(t),{waiting:!0}))}}))).pipe(Ig(t=>(wh(t)?u(e.self(),jr(EF),xr({onNone:()=>e.setSelf(SF(new Vf,{previous:e.self()})),onSome:t=>e.setSelf(vF(t))})):e.setSelf(xF(t,{previous:e.self()})),V))),s=VI(r.pipe(fa(eI,e.registry),fa(ko,e.registry.scheduler)),a,l,!1);return s!==void 0&&e.addFinalizer(s),i._tag===`Some`?pF(i):CF(n)}var KI=(e,t,n=la())=>GF(t)?(e.addFinalizer(KF(t).pipe(qx(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return V}),L_(n))),H_(n)(qF(t))):t._tag===`Success`?GI(e,KF(t.value),gF(!0),n):t,qI=(e,t)=>{function n(t,n){let r=t.get(e);GF(r)?V_(YF(r,n)):_F(r)&&V_(YF(r.value,n))}return jI(n=>{let r=n(e);return GF(r)||_F(r)?t(n,r):r},n)},JI=Symbol.for(`effect/reactivity/atom/Atom/Reset`),YI=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`),XI=function(...e){return e.length===0?ZI:ZI(...e)},ZI=(e,t)=>{let[n,r]=QI(e,t);return jI(n,r)};function QI(e,t){let n=wI(LI([0,void 0])),r=t?.initialValue===void 0?gF():vF(t.initialValue),i=t?.concurrent?wI(AI(e=>{let t=new Set;return e.addFinalizer(()=>t.forEach(e=>e.interruptUnsafe())),t})):void 0;function a(t,a){let o=i?t(i):void 0;t.isFn=!0;let[s,c]=t.get(n);if(s===0)return r;if(c===YI)return xF(Of(),{previous:t.self()});let l=e(c,t);return FI in l?(o&&(l=U(P_(l,{startImmediately:!0}),e=>{o.add(e);let t=Array.from(o);return e.addObserver(()=>o.delete(e)),W(rv(t),e=>e[0])})),zI(t,l,r,a,!1)):GI(t,l,r,a)}function o(e,t){lL(()=>{t===JI?e.set(n,[0,void 0]):t===YI?e.set(n,[e.get(n)[0]+1,YI]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,o,n]}var $I=(e,t,n,r)=>U(Jx(typeof n==`function`?n(e):n),n=>{let i=ov().context,a=ji(),o=t_(n,{onFailure(e){return wh(e)?_i(a)?R({done:!0,items:a}):H(new Vf(`Atom.pull: no items`)):xg(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=mi(a,e),a=t),R({done:!1,items:t})}}),s=new Set;return e.addFinalizer(()=>{for(let e of s)e()}),e.once(t),e.subscribe(t,()=>{e.setSelf(pF(e.self()));let t;t=VI(i,o,n=>{t&&s.delete(t);let r=fF(n,e.self()),i=s.size>0;e.setSelf(i?CF(r):r)}),t&&s.add(t)}),o}),eL=(e,t)=>jI(t.read,function(t,n){t.set(e,t.get(e)+1)}),tL=typeof WeakRef>`u`||typeof FinalizationRegistry>`u`?e=>{let t=ig();return function(n){let r=ag(t,n);if(r._tag===`Some`)return r.value;let i=e(n);return cg(t,n,i),i}}:e=>{let t=ig(),n=new FinalizationRegistry(e=>{let n=ag(t,e);n._tag===`Some`&&n.value.deref()===void 0&&ug(t,e)});return function(r){let i=ag(t,r).pipe(Mr(e=>e.deref()));if(i._tag===`Some`)return i.value;let a=e(r);return cg(t,r,new WeakRef(a)),n.register(a,r),a}},nL=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),rL=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,equals:t})),iL=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:[t,Ft()===0?``:Error().stack?.split(`
16
+ `)[5]??``]})),aL=r(e=>xI(e[0]),(e,t,n)=>{let r=wI(kI(e)?jI(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):AI(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=oL(n.initialValueTarget)),r}),oL=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},sL=r(2,(e,t)=>aL(e,n=>t(n(e)))),cL=r(2,(e,t)=>sL(e,jF(t))),lL=vI,uL=`~effect-atom/atom/Atom/Serializable`,dL=r(2,(e,t)=>{let n=Sj(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,Ft()===0?``:Error().stack?.split(`
17
+ `)[5]??``],[uL]:{key:t.key,encode:nA(n),decode:Qk(n),skipInitialRun:t.skipInitialRun}})}),fL=`~effect-atom/atom/Atom/ServerValue`,pL=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,[fL]:t})),mL=e=>pL(e,a(gF(!0))),hL=r(2,(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[fL](e=>t.get(e)):t.get(e)),gL=`~effect/socket/Socket`,_L=Ki(`effect/socket/Socket`),vL=e=>_L.of({[gL]:gL,reader:e.reader,writer:e.writer}),yL=new TextEncoder,bL=`~effect/socket/Socket/CloseEvent`,xL=e=>v(e,bL),SL=`~effect/socket/Socket/SocketError`,CL=e=>v(e,SL),wL=class extends bj(`effect/socket/Socket/SocketReadError`)({_tag:FA(`SocketReadError`),cause:tj()}){message=`An error occurred during Read`},TL=class extends bj(`effect/socket/Socket/SocketWriteError`)({_tag:FA(`SocketWriteError`),cause:tj()}){message=`An error occurred during Write`},EL=class extends bj(`effect/socket/Socket/SocketOpenError`)({_tag:FA(`SocketOpenError`),kind:OA([`Unknown`,`Timeout`]),cause:tj()}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},DL=class e extends bj(`effect/socket/Socket/SocketUpgradeError`)({_tag:FA(`SocketUpgradeError`),cause:aA(tj())}){static unsupported=()=>H(new AL({reason:new e({})}));get message(){return this.cause===void 0?`Socket does not support TLS upgrade`:`An error occurred during TLS upgrade`}},OL=class extends bj(`effect/socket/Socket/SocketCloseError`)({_tag:FA(`SocketCloseError`),code:GA,closeReason:aA(pA)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},kL=DA([wL,TL,EL,DL,OL]),AL=class extends xj(SL)(`SocketError`,{_tag:FA(`SocketError`),reason:kL}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[SL]=SL;static is(e){return CL(e)}message=this.reason.message},jL=(e,t)=>new AL({reason:new OL({code:e,closeReason:t})}),ML=class extends Ki()(`@effect/platform/Socket/WebSocketConstructor`){},NL=Gp(ML)((e,t)=>{if(t!==void 0&&typeof t!=`string`&&!Array.isArray(t))throw TypeError(`WebSocket client options are not supported by the global WebSocket constructor`);return new globalThis.WebSocket(e,t)}),PL=(e,t)=>ML.use(n=>IL(f_((typeof e==`string`?R(e):e).pipe(W(e=>n(e,t?.headers===void 0?t?.protocols:{protocols:t.protocols,headers:t.headers}))),e=>B(()=>e.close(1e3))),t)),FL=e=>`pause`in e&&typeof e.pause==`function`,IL=(e,t)=>Eg(n=>{let r,i=vv(!1),a=n.context,o=bg(function*(){let n=yield*l_,a=yield*Tp(e,n);`binaryType`in a&&(a.binaryType=`arraybuffer`);let o=FL(a),s=t?.highWaterMark??(o?LL:void 0),c=a.readyState===1,u=o&&`isPaused`in a&&a.isPaused===!0,d=[],f=0,p,m,h;function g(){o&&!u&&(a.pause(),u=!0)}function ee(){o&&u&&(a.resume(),u=!1)}function _(){let e=d;return d=[],f=0,p===void 0&&ee(),e}function te(){if(m===void 0||d.length===0)return;let e=m;m=void 0,e(R(_()))}function ne(e){d.push(e),s!==void 0&&(f+=typeof e==`string`?yL.encode(e).byteLength:e.byteLength),m!==void 0&&te(),o&&f>=s?g():!o&&!m&&s!==void 0&&f>s&&re(new AL({reason:new wL({cause:Error(`Socket highWaterMark of ${s} bytes exceeded`)})}))}function re(e){if(p===void 0&&(p=e),h!==void 0){let{cleanup:e,resume:t}=h;h=void 0,e(),t(H(p))}if(m!==void 0){let e=m;m=void 0,e(d.length>0?R(_()):H(p))}}function ie(e){let t=e.data;typeof Blob<`u`&&t instanceof Blob?t.arrayBuffer().then(e=>ne(new Uint8Array(e)),e=>{re(new AL({reason:new wL({cause:e})}))}):ne(t instanceof ArrayBuffer?new Uint8Array(t):t)}function ae(e){re(new AL({reason:c?new wL({cause:e}):new EL({kind:`Unknown`,cause:e})}))}function oe(e){re(jL(typeof e.code==`number`?e.code:1006,e.reason))}return a.addEventListener(`message`,ie),a.addEventListener(`error`,ae,{once:!0}),a.addEventListener(`close`,oe,{once:!0}),yield*Dp(n,B(()=>{if(re(jL(1006)),a.removeEventListener(`message`,ie),a.addEventListener(`error`,l),a.removeEventListener(`error`,ae),a.removeEventListener(`close`,oe),o)try{ee()}catch{}i.closeUnsafe(),r=void 0})),a.readyState>=2?yield*H(p??jL(1006)):(c||=(yield*vg(e=>{let t=()=>{h?.resume===e&&(h=void 0,a.removeEventListener(`open`,t),e(V))},n=()=>a.removeEventListener(`open`,t);return h={resume:e,cleanup:n},a.addEventListener(`open`,t,{once:!0}),B(()=>{h?.resume===e&&(h=void 0),n()})}).pipe(Yg({duration:t?.openTimeout??1e4,orElse:()=>H(new AL({reason:new EL({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))})),!0),p===void 0&&f<s&&ee(),r=a,i.openUnsafe(),{pull:vg(e=>d.length>0?e(R(_())):p===void 0?(m=e,B(()=>{m===e&&(m=void 0)})):e(H(p))),upgrade:DL.unsupported})}).pipe(s_(e=>xa(a,e))),s=e=>z(()=>{let t=r;if(t===void 0)return i.whenOpen(s(e));try{return xL(e)?t.close(e.code,e.reason):t.send(e),V}catch(e){return H(new AL({reason:new TL({cause:e})}))}}),c=e=>z(()=>{let t=r;if(t===void 0)return i.whenOpen(c(e));try{for(let n=0;n<e.length;n++)t.send(e[n]);return V}catch(e){return H(new AL({reason:new TL({cause:e})}))}});return R(vL({reader:o,writer:R({write:s,writeAll:c})}))}),LL=65536,RL=d(PL,Xp(_L)),zL=class extends Ki()(`effect/workers/Transferable/Collector`){},BL=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return zL.of({addAllUnsafe:t,addAll:e=>B(()=>t(e)),readUnsafe:n,read:B(n),clearUnsafe:r,clear:B(r)})},VL=DA([class extends bj(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:FA(`WorkerSpawnError`),message:pA,cause:aA(tj())}){},class extends bj(`effect/workers/WorkerError/WorkerSendError`)({_tag:FA(`WorkerSendError`),message:pA,cause:aA(tj())}){},class extends bj(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:FA(`WorkerReceiveError`),message:pA,cause:aA(tj())}){},class extends bj(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:FA(`WorkerUnknownError`),message:pA,cause:aA(tj())}){}]),HL=(e,t)=>e===void 0?t:`${e}.${t}`,UL=(e,t)=>({"rpc.system.name":`effect_rpc`,"rpc.method":e,...t}),WL=`~effect/PrimaryKey`,GL=`~effect/rpc/RpcSchema/StreamSchema`;function KL(e){return v(e,GL)}function qL(e){return KL(e)?E({success:e.success,error:e.error}):T()}var JL=zk(px);function YL(e,t){return J(JL.ast,{[GL]:GL,success:e,error:t})}var XL=`~effect/rpc/Rpc`,ZL={[XL]:XL,pipe(){return e(this,arguments)},setSuccess(e){return QL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return QL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return QL({_tag:this._tag,payloadSchema:rA(e)?e:vA(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return QL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return QL({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return QL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:fa(this.annotations,e,t)})},annotateMerge(e){return QL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:xa(this.annotations,e)})}},QL=e=>{function t(){}return Object.setPrototypeOf(t,ZL),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},$L=(e,t)=>{let n=t?.success??gA,r=t?.error??lA,i=t?.defect??tj(),a;return a=t?.primaryKey?class extends yj(`effect/rpc/Rpc/${e}`)(t.payload){[WL](){return t.primaryKey(this)}}:rA(t?.payload)?t?.payload:t?.payload?vA(t?.payload):gA,QL({_tag:e,payloadSchema:a,successSchema:t?.stream?YL(n,r):n,errorSchema:t?.stream?lA:r,defectSchema:i,annotations:la(),middlewares:new Set})},eR=new WeakMap,tR=e=>{if(eR.has(e))return eR.get(e);let t=e,n=new Set([t.errorSchema]),r=qL(t.successSchema);br(r)&&n.add(r.value.error);for(let e of t.middlewares)n.add(e.error);let i=lj(br(r)?gA:t.successSchema,DA([...n]),t.defectSchema);return eR.set(e,i),i},nR=k(`effect/rpc/Rpc/ParseOptions`,{defaultValue:()=>dE}),rR=`~effect/rpc/Rpc/Wrapper`,iR=e=>rR in e,aR=`~effect/rpc/RpcClientError`,oR=class extends bj(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:FA(`RpcClientDefect`),message:pA,cause:tj()}){},sR=class extends bj(aR)({_tag:FA(`RpcClientError`),reason:DA([VL,kL,KM,oR])}){[aR]=aR;get message(){return`${this.reason._tag}: ${this.reason.message}`}},cR=e=>e,lR={_tag:`Ping`},uR=DA([pA,mA]),dR=DA([vA({_tag:FA(`Request`),id:uR,tag:pA,payload:oj,headers:SA(xA([pA,pA])),isNotification:aA(cA(!0)),discard:aA(cA(!0)),traceId:aA(pA),spanId:aA(pA),sampled:aA(hA)}),vA({_tag:FA(`Ack`),requestId:uR}),vA({_tag:FA(`Interrupt`),requestId:uR}),vA({_tag:FA(`Ping`)}),vA({_tag:FA(`Eof`)}),vA({_tag:FA(`Chunk`),requestId:uR,values:oj}),vA({_tag:FA(`Exit`),requestId:uR,exit:oj}),vA({_tag:FA(`Defect`),defect:oj}),vA({_tag:FA(`Pong`)})]),fR=new WeakMap,pR=new WeakMap,mR=new WeakMap,hR=new WeakMap;function gR(e,t){let n=t?.fingerprint===!0?pR:fR,r=n.get(e);if(r!==void 0)return r;let{exact:i,layout:a,recursive:o,target:s}=yH(e),c=_H(a,t?.fingerprint),l=i?{value:void 0}:void 0,u=vR(l===void 0?s:CH(s,l,!o),a,c,l);return n.set(e,u),u}function _R(e,t){let n=t?.fingerprint===!0?hR:mR,r=n.get(e);if(r!==void 0)return r;let{exact:i,exitSuccess:a,layout:o,target:s}=yH(e);if(!i){if(!a)return gR(e,t);let r={value:void 0},i=vR(TH(s,r),o,_H(o,t?.fingerprint),r,!0);return n.set(e,i),i}let c=vR(EH(s),o,_H(o,t?.fingerprint),void 0);return n.set(e,c),c}function vR(e,t,n,r,i=!1){return oj.pipe(jA(e,hH(t,n,r,i)))}function yR(e,t){let{exact:n,exitSuccess:r,layout:i}=yH(e),a=_H(i,t?.fingerprint),o=t??dE;if(!n||o.onExcessProperty===`error`){let n=tA(gR(e,t),t);return!r||o.onExcessProperty===`error`?n:e=>{if(!NV(e))return n(e);try{return MV(i,e,o,a)}catch(e){throw e instanceof Tz?new Bk(e.issue):e}}}return e=>{try{return MV(i,e,o,a)}catch(e){throw e instanceof Tz?new Bk(e.issue):e}}}function bR(e,t){let{exact:n,layout:r}=yH(e),i=t??dE;if(!n||i.onExcessProperty===`error`){let n=yR(e,t);return e=>xR(e.map(n))}let a=_H(r,t?.fingerprint);return e=>{try{return jV(r,e,i,a)}catch(e){throw e instanceof Tz?new Bk(e.issue):e}}}function xR(e){return e.length===1?e[0]:Fk(e)}function SR(e,t){let{exact:n,exitSuccess:r,layout:i,target:a}=yH(e),o=t??dE,s=n?void 0:Zk(a,o),c=s!==void 0&&r?e=>NV(e)?e:s(e):s;return TR(i,_H(i,t?.fingerprint),o,t?.maxFrameSize,c,CR(n,t))}function CR(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw Error(`Binary layout: dictionary needs a schema the binary layer validates on its own`);return!0}function wR(e,t){let{exact:n,layout:r,target:i}=yH(e),a=CR(n,t),o=yR(e,t),s=bR(e,t);if(!a)return{encode:o,encodeMany:s};let c=_H(r,t?.fingerprint),l=t??dE,u=l.onExcessProperty===`error`?tA(i,t):void 0,d=oV(),f=e=>{try{return e()}catch(e){throw e instanceof Tz?new Bk(e.issue):e}};return{encode:e=>f(()=>MV(r,u===void 0?e:u(e),l,c,d)),encodeMany:e=>f(()=>jV(r,u===void 0?e:e.map(u),l,c,d))}}function TR(e,t,n,r,i,a){let o=a?[]:void 0,s=new Uint8Array,c=0,l=0,u,d=!1,f=new Gz,p=new Vz(n,Nz),m=()=>{f.release(),p.clear(),s=Uz,c=l=0},h=(e,t)=>{throw new Bk(new Rw({expected:e},t,n))},g=()=>{let e=u;throw u=void 0,e},ee=(e,t)=>{let n=e.length-t;n>s.length&&(s=new Uint8Array(Math.max(256,n))),s.set(t===0?e:e.subarray(t),0),c=0,l=n},_={feedSync(a){if(u!==void 0)return g();if(d)return h(`parser is spent`);let _=l===c,te,ne,re;if(_)te=a,ne=0,re=a.length;else{if(a.length>0){let e=l-c,t=e+a.length;if(t>s.length){let n=new Uint8Array(Math.max(256,s.length*2,t));n.set(s.subarray(c,l)),s=n,c=0,l=e}else c>0&&(s.copyWithin(0,c,l),c=0,l=e);s.set(a,l),l+=a.length}te=s,ne=c,re=l}let ie=[],ae=()=>(_?ne<re&&ee(a,ne):(c=ne,c===l&&(c=l=0)),ie),oe=(e,t)=>{d=!0;let r=new Bk(new Rw({expected:e},t,n));if(m(),ie.length===0)throw r;return u=r,ie};for(;;){let a=0,s=-1,c=re-ne,l=1;for(let e=0;e<Math.min(6,c);e++){let t=te[ne+e];if(a+=(t&127)*l,!(t&128)){s=e+1;break}l*=128}if(s===-1){if(c<6)return ae();let e=BigInt(a);for(let t=6;t<Math.min(10,c);t++){let n=te[ne+t];if(e|=BigInt(n&127)<<BigInt(t*7),!(n&128)){if(s=t+1,e>PR)return oe(`safe integer length`,e);a=Number(e);break}}if(s===-1)return c>=10?oe(`uvarint`,te.subarray(ne,ne+10)):ae()}if(a===0)return oe(`nonzero frame length`,a);if(r!==void 0&&a>r)return oe(`frame within maxFrameSize`,a);if(s+a>c)return ae();let h=Q;try{Q=0;let r=ne+s;p.beginFrame(),f.reset(te,r,r+a,n,p,t,o);let c=fH(e,f,t);ie.push(i===void 0?c:i(c))}catch(e){d=!0,m();let t=e instanceof Tz?new Bk(e.issue):Vk(e)?e:(()=>{throw e})();if(ie.length===0)throw t;return u=t,ie}finally{Q=h}ne+=s+a}},endSync(){if(u!==void 0)return g();if(d)return h(`parser is spent`);d=!0;let e=c<l?s.subarray(c,l):void 0;if(m(),e!==void 0)return h(`complete value`,e)},feed:e=>z(()=>{try{return R(_.feedSync(e))}catch(e){if(Vk(e))return H(e);throw e}}),end:z(()=>{try{return _.endSync(),V}catch(e){if(Vk(e))return H(e);throw e}})};return _}var ER=`~effect/encoding/SchemaBinary/fieldId`,DR=`~effect/encoding/SchemaBinary/fixedWidth`,OR=BigInt(`-9223372036854775808`),kR=BigInt(`9223372036854775807`),AR=BigInt(`18446744073709551615`);function jR(e){let t=e.checks;if(t!==void 0)for(let e of t){let t=e.annotations?.[DR];if(t!==void 0)return t}}var MR=32,NR=33,PR=BigInt(2**53-1),FR=BigInt(0),IR=BigInt(1),LR=BigInt(2),RR=BigInt(7),zR=BigInt(127),BR=BigInt(1e6),VR=BigInt(255),HR=BigInt(4294967295),UR=BigInt(32),WR=new TextEncoder,GR=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),KR=7,qR=0xffffffffffff,JR=0xfffffffffffff,YR=0,XR=1,ZR=2,QR=512,$R=1048576,ez=4194304,tz=0,nz=1,rz=2,iz=3,az=4,oz=5,sz=6,cz=7,lz=8;function uz(e){return typeof e==`number`&&Number.isInteger(e)&&e>=-0xffffffffffff&&e<=qR}var dz=8,fz=2199023255551,pz=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function mz(e){for(let t=1;t<=dz;t++){let n=Math.round(e*pz[t]);if(!(n>=-2199023255551&&n<=fz))return 0;if(n/pz[t]===e)return t}return 0}function hz(e){let t=Math.floor(e/2);return e%2==1?-t:t}var Y={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function gz(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}var _z=BigInt(`14695981039346656037`),vz=BigInt(`1099511628211`),yz=BigInt(`18446744073709551615`);function bz(e){let t=_z;for(let n=0;n<e.length;n++)t=(t^BigInt(e[n]))*vz&yz;return t}function xz(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function Sz(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function Cz(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function wz(e,t){for(let n=0;n<8;n++)e.push(Number(t>>BigInt(n*8)&VR))}var Tz=class extends Error{issue;constructor(e){super(`SchemaBinary failure`),this.issue=e}};function X(e,t,n){throw Ez(new Rw({expected:e},t,n))}var Z=[],Q=0;function Ez(e){return new Tz(Q===0?e:new Nw(Z.slice(0,Q),e))}function Dz(e){let t=new Uint8Array(Oz(e)),n=0;for(;e>127;)t[n++]=e&127|128,e=Math.floor(e/128);return t[n]=e,t}function Oz(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var kz=32;function Az(e,t,n,r){let i=n-t;if(i===0)return``;if(i<=kz){let r=jz(e,t,n);if(r!==void 0)return r}try{return GR.decode(e.subarray(t,n))}catch{X(`utf-8`,void 0,r)}}function jz(e,t,n){let r=``,i=t;for(;i+16<=n;i+=16){let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5],l=e[i+6],u=e[i+7],d=e[i+8],f=e[i+9],p=e[i+10],m=e[i+11],h=e[i+12],g=e[i+13],ee=e[i+14],_=e[i+15];if((t|n|a|o|s|c|l|u|d|f|p|m|h|g|ee|_)>127)return;r+=String.fromCharCode(t,n,a,o,s,c,l,u,d,f,p,m,h,g,ee,_)}if(i+8<=n){let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5],l=e[i+6],u=e[i+7];if((t|n|a|o|s|c|l|u)>127)return;r+=String.fromCharCode(t,n,a,o,s,c,l,u),i+=8}switch(n-i){case 0:return r;case 1:{let t=e[i];return t>127?void 0:r+String.fromCharCode(t)}case 2:{let t=e[i],n=e[i+1];return(t|n)>127?void 0:r+String.fromCharCode(t,n)}case 3:{let t=e[i],n=e[i+1],a=e[i+2];return(t|n|a)>127?void 0:r+String.fromCharCode(t,n,a)}case 4:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3];return(t|n|a|o)>127?void 0:r+String.fromCharCode(t,n,a,o)}case 5:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4];return(t|n|a|o|s)>127?void 0:r+String.fromCharCode(t,n,a,o,s)}case 6:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5];return(t|n|a|o|s|c)>127?void 0:r+String.fromCharCode(t,n,a,o,s,c)}default:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5],l=e[i+6];return(t|n|a|o|s|c|l)>127?void 0:r+String.fromCharCode(t,n,a,o,s,c,l)}}}var Mz=65536,Nz=256,Pz=512,Fz=16384;function Iz(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Lz=Iz(Mz),Rz=class{buf=new Uint8Array;view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let e=Lz;(e.writing||e.offset>=e.buf.length)&&(e=Lz=Iz(Mz)),e.writing=!0,this.arena=e,this.buf=e.buf,this.view=e.view,this.start=e.offset,this.limit=e.buf.length-e.offset,this.len=0}ensure(e){if(this.len+e>this.limit){let t=this.arena,n=this.len+e,r=Mz;for(;r<n;)r*=2;let i=Iz(r);i.writing=!0,i.buf.set(this.buf.subarray(this.start,this.start+this.len)),t.writing=!1,this.arena=Lz=i,this.buf=i.buf,this.view=i.view,this.start=0,this.limit=i.buf.length}}byte(e){this.ensure(1),this.buf[this.start+this.len++]=e}bytes(e){this.ensure(e.length),this.buf.set(e,this.start+this.len),this.len+=e.length}uvarint(e){this.ensure(10);let t=this.buf,n=this.start+this.len;if(e<128)t[n++]=e;else if(t[n++]=e&127|128,e<16384)t[n++]=e>>>7;else{for(t[n++]=e>>>7&127|128,e=Math.floor(e/16384);e>127;)t[n++]=e&127|128,e=Math.floor(e/128);t[n++]=e}this.len=n-this.start}uvarintBig(e){for(;e>zR;)this.byte(Number(e&zR)|128),e>>=RR;this.byte(Number(e))}zigzag(e){this.uvarintBig(e>=FR?e<<IR:(-e<<IR)-IR)}numberVarint(e){let t=e<0||e===0&&1/e<0,n=t?-e:e;n<=JR?this.uvarint(n*2+ +!!t):this.uvarintBig(BigInt(n)*LR+(t?IR:FR))}f64(e){this.ensure(8),this.view.setFloat64(this.start+this.len,e,!0),this.len+=8}i64(e){this.ensure(8),this.view.setBigInt64(this.start+this.len,e,!0),this.len+=8}u64(e){this.ensure(8),this.view.setBigUint64(this.start+this.len,e,!0),this.len+=8}u32le(e){this.ensure(4),this.view.setUint32(this.start+this.len,e>>>0,!0),this.len+=4}i32le(e){this.ensure(4),this.view.setInt32(this.start+this.len,e|0,!0),this.len+=4}idAndMark(e){let t=e.length;this.ensure(t+1);let n=this.buf,r=this.start+this.len;for(let i=0;i<t;i++)n[r++]=e[i];let i=r-this.start;return this.len=i+1,i}beginSized(){return this.ensure(1),this.len++}endSized(e){let t=this.len-e-1;t<128?this.buf[this.start+e]=t:this.growSized(e,t)}endSizedRun(e){let t=(this.len-e-1)*2;t<128?this.buf[this.start+e]=t:this.growSized(e,t)}growSized(e,t){let n=Oz(t),r=n-1;this.ensure(r);let i=this.start+e;this.buf.copyWithin(i+n,i+1,this.start+this.len),this.len+=r;let a=t,o=i;for(;a>127;)this.buf[o++]=a&127|128,a=Math.floor(a/128);this.buf[o]=a}string(e){let t=e.length;if(t===0)return;this.ensure(t*3);let n=this.buf,r=this.start+this.len,i=0;for(;i+4<=t;i+=4){let t=e.charCodeAt(i),a=e.charCodeAt(i+1),o=e.charCodeAt(i+2),s=e.charCodeAt(i+3);if((t|a|o|s)>127){this.len+=WR.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=t,n[r++]=a,n[r++]=o,n[r++]=s}for(;i<t;i++){let t=e.charCodeAt(i);if(t>127){this.len+=WR.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=t}this.len=r-this.start}out(){let e=this.arena,t=new Uint8Array(e.buf.buffer,this.start,this.len);return e===Lz&&(e.offset=this.start+this.len),e.writing=!1,this.arena=void 0,t}abort(){let e=this.arena;e!==void 0&&(e===Lz&&(e.offset=this.start),e.writing=!1,this.arena=void 0)}};function zz(e){let t=eO(e);return t._tag===`String`&&t.checks===void 0}function Bz(e,t,n){return e.extra.find(e=>LE({[t]:null},e.parameter,n).length>0)}var Vz=class{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(e,t){this.options=e,this.orderLayouts=t===void 0?void 0:Array(t),this.orderKeys=t===void 0?void 0:Array(t)}beginFrame(){this.replace=!0}find(e,t){let n=this.entries.get(e);if(n===void 0&&(n=new Map,this.entries.set(e,n)),n.has(t))return n.get(t);let r=Bz(e,t,this.options),i=this.orderLayouts;if(i===void 0)return n.set(t,r),r;let a=this.orderKeys;if(this.size<i.length)i[this.size]=e,a[this.size]=t,this.size++,n.set(t,r);else if(this.replace){this.replace=!1;let o=i[this.next];(o===e?n:this.entries.get(o))?.delete(a[this.next]),i[this.next]=e,a[this.next]=t,this.next=(this.next+1)%i.length,n.set(t,r)}return r}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}},Hz=new ArrayBuffer(0),Uz=new Uint8Array(Hz),Wz=new DataView(Hz),Gz=class{pos=0;nesting=0;buf=Uz;view;viewCache=Wz;viewBuffer=Hz;viewOffset=0;viewLength=0;end=0;options=dE;indexSignatures;positional=!1;rejectUnknownFields=!1;intern;dict;reset(e,t,n,r,i,a,o){this.nesting=0,this.view=void 0,this.buf=e,this.pos=t,this.end=n,this.options=r,this.indexSignatures=i,this.positional=a.positional,this.rejectUnknownFields=a.rejectUnknownFields,this.intern=void 0,this.dict=o}release(){this.pos=this.end=this.nesting=0,this.buf=Uz,this.view=void 0,this.viewCache=Wz,this.viewBuffer=Hz,this.viewOffset=this.viewLength=0,this.options=dE,this.indexSignatures=void 0,this.positional=!1,this.rejectUnknownFields=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let e=this.buf;return(e.buffer!==this.viewBuffer||e.byteOffset!==this.viewOffset||e.byteLength!==this.viewLength)&&(this.viewBuffer=e.buffer,this.viewOffset=e.byteOffset,this.viewLength=e.byteLength,this.viewCache=new DataView(e.buffer,e.byteOffset,e.byteLength)),this.view=this.viewCache}byte(){return this.pos>=this.end&&X(`complete value`,void 0,this.options),this.buf[this.pos++]}take(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.buf.subarray(this.pos,this.pos+e);return this.pos+=e,t}takeCopy(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t}enter(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.end;return this.end=this.pos+e,t}exit(e){this.pos=this.end,this.end=e}readUtf8(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.pos;return this.pos+=e,Az(this.buf,t,t+e,this.options)}uvarint(){let e=this.buf,t=this.end,n=this.pos;n>=t&&X(`complete value`,void 0,this.options);let r=e[n++];if(r<128)return this.pos=n,r;let i=r&127;if(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<7,r<128||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<14,r<128)||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<21,r<128))return this.pos=n,i;let a=268435456;for(let o=4;o<10;o++){n>=t&&(this.pos=n,X(`complete value`,void 0,this.options)),r=e[n++];let o=(r&127)*a;if(o>2**53-1-i&&(this.pos=n,X(`safe integer length`,void 0,this.options)),i+=o,r<128)return this.pos=n,i;a*=128}this.pos=n,X(`uvarint`,void 0,this.options)}fieldTag(){let e=this.buf,t=this.end,n=this.pos;n>=t&&X(`complete value`,void 0,this.options);let r=e[n++];if(r<128)return this.pos=n,r;let i=r&127;return n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<7,r<128||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<14,r<128)||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<21,r<128)?(this.pos=n,i):(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],this.pos=n,r>=128&&X(`uvarint`,void 0,this.options),i+r*268435456)}uvarintBig(){let e=FR,t=FR;for(;;){let n=this.byte();if(e|=BigInt(n&127)<<t,!(n&128))return e;t+=RR}}numberVarint(){let e=this.buf,t=this.end,n=this.pos,r=0,i=1;for(let a=0;a<KR;a++){n>=t&&(this.pos=n,X(`complete value`,void 0,this.options));let a=e[n++];if(r+=(a&127)*i,a<128)return this.pos=n,hz(r);i*=128}let a=this.uvarintBig(),o=Number(a>>IR);return Number.isFinite(o)||X(`safe integer length`,void 0,this.options),(a&IR)===IR?-o:o}zigzag(){let e=this.uvarintBig();return(e&IR)===IR?-(e+IR>>IR):e>>IR}f64(){this.pos+8>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,e}i64(){this.pos+8>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,e}u64(){this.pos+8>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getBigUint64(this.pos,!0);return this.pos+=8,e}u32le(){this.pos+4>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,e}i32le(){this.pos+4>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,e}};function Kz(e,t){return{_:`literal`,leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function qz(e,t){let n=e.values;return e.valueSet===void 0?n.length===1?t===n[0]:n.includes(t):e.valueSet.has(t)}function Jz(e){return e.values.map(e=>typeof e==`string`?JSON.stringify(e):String(e)).join(` | `)}var Yz=0,Xz=1,Zz=2,Qz=3,$z=30,eB=1<<$z;function tB(e){return e._===`literal`?tB(e.leaf):e._===`int`}function nB(e){switch(e._){case`literal`:return nB(e.leaf);case`bool`:return 1;case`i32`:case`u32`:return 4;case`int64`:case`i64`:case`u64`:return 8;default:return}}function rB(e){return nB(e)!==void 0||tB(e)||e._===`null`||e._===`undefined`}function iB(e){return e._===`literal`?iB(e.leaf):e._===`null`||e._===`undefined`}var aB={"effect/schema/Date":{kind:Y.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:Y.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:Y.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:Y.duration,exact:!0},"effect/schema/BigDecimal":{kind:Y.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:Y.bytes,exact:!0},"effect/schema/Option":{kind:Y.option,exact:`parameters`},"effect/schema/Result":{kind:Y.result,exact:`parameters`},"effect/schema/Exit":{kind:Y.exit,exact:`parameters`},"effect/schema/Cause":{kind:Y.cause,exact:`parameters`},"effect/schema/CauseReason":{kind:Y.causeReason,exact:`parameters`}};function oB(e){let t=e.annotations?.representation;return he(t)&&typeof t.id==`string`?t.id:void 0}var sB=RD(e=>{let t=cB(e),n=e.context;return t===e||n===void 0?t:ID(t,new fE(n.isOptional,n.isMutable,void 0,n.annotations))});function cB(e){switch(e._tag){case`Declaration`:{let t=oB(e);if(t!==void 0&&(t in aB||t===`effect/schema/Json`||t===`effect/schema/MutableJson`))return e.recur(sB);let n=e.annotations?.toCodecJson,r=e.annotations?.toCodec;if(!ce(n)&&!ce(r))return e;let i=e.typeParameters.map(e=>J(eO(e))),a=(ce(n)?n(i):void 0)??(ce(r)?r(i):void 0);return a===void 0?e:DD(e,[ND(a,sB)])}case`Arrays`:case`Objects`:case`Union`:case`Suspend`:return e.recur(sB);default:return e}}function lB(e){let t=[...e].sort((e,t)=>{let n=typeof e.key==`number`;return n===(typeof t.key==`number`)?n?e.key-t.key:Ik(WR.encode(e.key),WR.encode(t.key)):n?-1:1}),n=[];for(let e of t){let t=WR.encode(String(e.key));n.push(typeof e.key==`number`?0:1),Cz(n,t.length),xz(n,t);let r=e.literal,i=WR.encode(dB(r));n.push(uB(r)),Cz(n,i.length),xz(n,i)}return gz(n)}function uB(e){switch(typeof e){case`string`:return 1;case`number`:return 2;case`boolean`:return 3;case`bigint`:return 4;default:return 5}}function dB(e){if(typeof e==`symbol`){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw Error(`Binary layout: unregistered unique symbol (Symbol.keyFor)`);return t}return String(e)}function fB(e){switch(e._tag){case`Symbol`:return!0;case`Union`:return e.types.some(fB);default:return!1}}function pB(e){let t=oB(e);return t===`effect/schema/Json`||t===`effect/schema/MutableJson`||ce(e.annotations?.toCodecJson)}function mB(e){let t=e.checks;if(t===void 0)return!1;let n=e=>e.annotations?.representation?.id===`effect/schema/isInt`||e._tag===`FilterGroup`&&e.checks.some(n);return t.some(n)}function hB(e){for(;e._tag===`Suspend`;)e=e.thunk();return e}function gB(e){return new cD(e.enums.map(e=>new CE(e[1],{title:e[0]})))}function _B(e){let t=[],n=new Set,r=e=>{let i=hB(e);if(!n.has(i))switch(n.add(i),i._tag){case`Never`:return;case`Union`:i.types.forEach(r);return;case`Enum`:gB(i).types.forEach(r);return;default:t.push(i)}};return e.types.forEach(r),t}function vB(e){switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`bool`;default:return`bigint`}}function yB(e){switch(e._tag){case`String`:case`TemplateLiteral`:case`Symbol`:return Y.string;case`UniqueSymbol`:if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw Error(`Binary layout: unregistered unique symbol (Symbol.keyFor)`);return Y.string;case`Boolean`:return Y.bool;case`Null`:return Y.null;case`Undefined`:case`Void`:return Y.undefined;case`Number`:return Y.number;case`BigInt`:return Y.bigint;case`Literal`:switch(typeof e.literal){case`string`:return Y.string;case`number`:return Y.number;case`boolean`:return Y.bool;default:return Y.bigint}case`Unknown`:case`Any`:case`ObjectKeyword`:return Y.json;case`Objects`:return Y.struct;case`Arrays`:return Y.array;case`Declaration`:{let t=oB(e);if(t!==void 0&&t in aB)return aB[t].kind;if(pB(e))return Y.json;throw Error(`Binary layout: declaration ${t??`<anonymous>`} has no toCodecJson or toCodec`)}case`Suspend`:return yB(hB(e));default:throw Error(`Binary layout: union members are not uniquely identifiable`)}}function bB(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function xB(e){let t=SB(e),n=!t&&wB(e);e=eO(e);let r=new Map,i=!1,a=0,o=e=>({_:e,slot:e===`string`?a++:0});function s(e){let t=r.get(e);if(t!==void 0)return t;let n=c(e);return r.set(e,n),n}function c(e){switch(e._tag){case`String`:case`TemplateLiteral`:return o(`string`);case`Symbol`:case`UniqueSymbol`:return o(`symbol`);case`Boolean`:return o(`bool`);case`Null`:return o(`null`);case`Undefined`:case`Void`:return o(`undefined`);case`Number`:{let t=jR(e);return o(t===`i32`||t===`u32`?t:mB(e)?`int`:`number`)}case`BigInt`:{let t=jR(e);return o(t===`i64`||t===`u64`?t:`bigint`)}case`Literal`:return Kz(o(vB(e.literal)),[e.literal]);case`Unknown`:case`Any`:case`ObjectKeyword`:return o(`json`);case`Never`:return{_:`never`,ast:e};case`Enum`:return f(e,_B(gB(e)));case`Suspend`:{i=!0;let t=s(e.thunk());return r.set(e,t),t}case`Objects`:return l(e);case`Arrays`:return u(e);case`Union`:return f(e,_B(e));case`Declaration`:return d(e)}}function l(e){let t=[],n=[],i=new Map;for(let r of e.propertySignatures){if(typeof r.name==`symbol`)throw Error(`Binary layout: symbol property names are illegal`);let e=String(r.name),a=r.type.context?.annotations,o=a?.[ER],s=typeof o==`number`?o:gz(WR.encode(e));if(!Number.isInteger(s)||s<0||s>4294967295)throw Error(`Binary layout: illegal field id for ${e}`);let c=i.get(s);c===void 0?i.set(s,[e]):c.push(e),t.push({name:e,id:s,tagBytes:Dz(s*lz+tz),index:0,optional:r.type.context?.isOptional===!0,annotations:a,layout:void 0,wireMask:0,inline:!1}),n.push(r.type)}for(let[e,t]of i)if(e===0||t.length>1)throw Error(`Binary layout field id collision: ${e} (${t.join(`, `)})`);let a=[];for(let t of e.indexSignatures){if(fB(t.parameter))throw Error(`Binary layout: symbol property names are illegal`);a.push({parameter:t.parameter,layout:void 0,wireMask:0})}let o={_:`struct`,ast:e,fields:t,byId:new Map,extra:a,extraAll:a.length===1&&zz(a[0].parameter)?a[0]:void 0,names:new Set(t.map(e=>e.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};r.set(e,o);for(let e=0;e<t.length;e++){let r=t[e];r.layout=s(n[e]),r.wireMask=KV(r.layout),r.inline=rB(r.layout),r.optional&&o.optionalCount++,o.byId.set(r.id,r)}t.sort((e,t)=>e.id-t.id);for(let e=0;e<t.length;e++)t[e].index=e;bB(o);for(let t=0;t<a.length;t++)a[t].layout=s(e.indexSignatures[t].type),a[t].wireMask=KV(a[t].layout);return o}function u(e){let t={_:`array`,ast:e,elements:[],rest:[],hasCount:e.rest.length>0||e.elements.some(e=>e.context?.isOptional===!0),minCount:e.elements.filter(e=>e.context?.isOptional!==!0).length+Math.max(0,e.rest.length-1),uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};r.set(e,t);for(let n of e.elements)t.elements.push({optional:n.context?.isOptional===!0,layout:s(n)});for(let n of e.rest)t.rest.push(s(n));if(t.elements.length===0&&t.rest.length===1){let e=t.rest[0];t.uniform=e,t.uniformPacked=nB(e),t.uniformNumbers=e._===`number`,t.uniformInline=rB(e)}return t}function d(e){let t=oB(e);switch(t){case`effect/schema/Date`:return{_:`int64`,flavor:`date`};case`effect/schema/DateTimeUtc`:return{_:`int64`,flavor:`utc`};case`effect/schema/DateTimeZoned`:return o(`dateTimeZoned`);case`effect/schema/Duration`:return o(`duration`);case`effect/schema/BigDecimal`:return o(`bigDecimal`);case`effect/schema/Uint8Array`:return o(`bytes`)}let n=e.typeParameters;switch(t){case`effect/schema/Option`:{let t={_:`option`,value:void 0};return r.set(e,t),t.value=s(n[0]),t}case`effect/schema/Result`:{let t={_:`result`,success:void 0,failure:void 0};return r.set(e,t),t.success=s(n[0]),t.failure=s(n[1]),t}case`effect/schema/Exit`:{let t={_:`cause`,error:void 0,defect:void 0},i={_:`exit`,value:void 0,cause:t};return r.set(e,i),i.value=s(n[0]),t.error=s(n[1]),t.defect=s(n[2]),i}case`effect/schema/Cause`:case`effect/schema/CauseReason`:{let i={_:t===`effect/schema/Cause`?`cause`:`causeReason`,error:void 0,defect:void 0};return r.set(e,i),i.error=s(n[0]),i.defect=s(n[1]),i}}if(t!==void 0&&t in aB)throw Error(`Binary layout: native declaration ${t} has no layout constructor`);if(pB(e))return o(`json`);throw Error(`Binary layout: declaration ${t??`<anonymous>`} has no toCodecJson or toCodec`)}function f(e,t){if(t.length===0)return{_:`never`,ast:e};let n=[],i=[],a=new Map,c=new Map,l=(e,t)=>{let n=a.get(e);if(n!==void 0&&n._!==t._)throw Error(`Binary layout: union members are not uniquely identifiable`);a.set(e,t)};for(let e of t)if(e._tag===`Literal`){let t=yB(e),n=c.get(t);n===void 0?c.set(t,[e.literal]):n.includes(e.literal)||n.push(e.literal)}else if(e._tag===`UniqueSymbol`)yB(e),l(Y.string,o(`symbol`));else{if(e._tag===`Objects`||e._tag===`Arrays`){let t=nD(e);if(t!==void 0&&t.length>0){for(let e of t)if(typeof e.key==`symbol`)throw Error(`Binary layout: symbol property names are illegal`);n.push({member:e,sentinels:t});continue}}i.push({member:e,kind:yB(e)})}for(let[e,t]of c)l(e,Kz(o(vB(t[0])),t));if(n.length===0&&i.length===0&&a.size===1)return a.values().next().value;let u=new Set(a.keys());for(let{kind:e}of i){if(u.has(e))throw Error(`Binary layout: union members are not uniquely identifiable`);u.add(e)}if(n.length===0&&a.size===0&&i.length===1){let t=s(i[0].member);return r.set(e,t),t}let d=new Map,f=[];for(let{sentinels:e}of n){let t=lB(e);if(d.has(t))throw Error(`Binary layout sentinel collision: ${t}`);d.set(t,e),f.push(t)}let p={_:`union`,ast:e,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};r.set(e,p);for(let e=0;e<n.length;e++){let{member:t,sentinels:r}=n[e],i=f[e],a=s(t),o,c;if(t._tag===`Objects`){let e=a,t=new Set(r.map(e=>String(e.key))),n=e.fields.filter(e=>!t.has(e.name)),i={_:`struct`,ast:e.ast,fields:n,byId:new Map(n.map(e=>[e.id,e])),extra:e.extra,extraAll:e.extraAll,names:e.names,extraShape:void 0,optionalCount:n.reduce((e,t)=>t.optional?e+1:e,0),requiredMask:0,requiredWide:!1};bB(i),o=i,c=!1}else o=a,c=!0;let l={tag:i,sentinels:r,tuple:c,payload:o,position:0};p.variants.push(l),p.byTag.set(i,l)}for(let[e,t]of a)p.others.push({kind:e,layout:t,position:0}),p.byKind.set(e,t);for(let{kind:e,member:t}of i){let n=s(t);p.others.push({kind:e,layout:n,position:0}),p.byKind.set(e,n)}for(let e of[...p.variants].sort((e,t)=>e.tag-t.tag))e.position=p.byPos.length,p.byPos.push({variant:e,layout:e.payload});for(let e of[...p.others].sort((e,t)=>e.kind-t.kind))e.position=p.byPos.length,p.byPos.push({variant:void 0,layout:e.layout});return p.others.sort((e,t)=>AB(e.layout)-AB(t.layout)),p.discriminator=SV(p.variants),p}return{layout:s(e),recursive:i,exact:t,exitSuccess:n}}function SB(e){let t=new Map,n=e=>{if(e.encoding!==void 0||e.checks!==void 0&&!CB(e)||e.encodingChecks!==void 0)return!1;switch(e._tag){case`String`:case`Symbol`:case`Boolean`:case`Null`:case`Undefined`:case`Void`:case`Number`:case`BigInt`:case`Literal`:return!0;case`Never`:return!0;case`Unknown`:case`Any`:return!0;case`Arrays`:return e.elements.every(n)&&e.rest.every(n);case`Objects`:return e.propertySignatures.every(e=>n(e.type))&&e.indexSignatures.every(e=>e.parameter._tag===`String`&&n(e.parameter)&&n(e.type));case`Union`:return(e.options?.mode??`anyOf`)===`anyOf`&&e.types.every(n);case`Suspend`:{let r=t.get(e);if(r!==void 0)return r;t.set(e,!0);let i=n(e.thunk());return t.set(e,i),i}case`Declaration`:{let t=oB(e),r=t===void 0?void 0:aB[t];return r===void 0?!1:r.exact===!0||e.typeParameters.every(n)}default:return!1}};return n(e)}function CB(e){return(e._tag===`Number`||e._tag===`BigInt`)&&e.checks?.length===1&&jR(e)!==void 0}function wB(e){return e._tag===`Declaration`&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&oB(e)===`effect/schema/Exit`&&SB(e.typeParameters[0])}var TB={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25,i32:26,u32:27,i64:28,u64:29};function EB(e){let t=new Map,n=[],r=2**53-1;function i(e){let i=n.lastIndexOf(e);if(i>=0){i<r&&(r=i);let e=[TB.backEdge];return Sz(e,n.length-i),bz(e)}let o=t.get(e);if(o!==void 0)return o;let s=n.length,c=r;r=2**53-1,n.push(e);let l=bz(a(e));n.pop();let u=r>=s;return u&&t.set(e,l),r=u?c:Math.min(c,r),l}function a(e){let t=[];switch(e._){case`bool`:case`null`:case`undefined`:case`number`:case`int`:case`string`:case`symbol`:case`bytes`:case`bigint`:case`i32`:case`u32`:case`i64`:case`u64`:case`json`:case`duration`:case`bigDecimal`:case`dateTimeZoned`:return t.push(TB[e._]),t;case`literal`:{t.push(TB.literal),xz(t,a(e.leaf)),Sz(t,e.values.length);let n=e.values.map(e=>[uB(e),dB(e)]).sort((e,t)=>e[1]<t[1]?-1:e[1]>t[1]?1:e[0]-t[0]);for(let[e,r]of n){t.push(e);let n=WR.encode(r);Sz(t,n.length),xz(t,n)}return t}case`int64`:return t.push(e.flavor===`date`?TB.date:TB.dateTimeUtc),t;case`never`:return t.push(TB.never),t;case`struct`:t.push(TB.struct),Sz(t,e.fields.length);for(let n of e.fields)Cz(t,n.id),t.push(+!!n.optional),wz(t,i(n.layout));Sz(t,e.extra.length);for(let n of e.extra)wz(t,i(n.layout));return t;case`array`:t.push(TB.array),Sz(t,e.elements.length);for(let n of e.elements)t.push(+!!n.optional),wz(t,i(n.layout));Sz(t,e.rest.length);for(let n of e.rest)wz(t,i(n));return t;case`union`:t.push(TB.union),Sz(t,e.byPos.length);for(let n of e.byPos){let e=n.variant;e===void 0?t.push(0):(t.push(1,+!!e.tuple),Cz(t,e.tag)),wz(t,i(n.layout))}return t;case`option`:return t.push(TB.option),wz(t,i(e.value)),t;case`result`:return t.push(TB.result),wz(t,i(e.success)),wz(t,i(e.failure)),t;case`exit`:return t.push(TB.exit),wz(t,i(e.value)),wz(t,i(e.cause.error)),wz(t,i(e.cause.defect)),t;case`cause`:case`causeReason`:return t.push(e._===`cause`?TB.cause:TB.causeReason),wz(t,i(e.error)),wz(t,i(e.defect)),t}}return i(e)}function DB(e,t){let n=new Uint8Array(8);for(let r=0;r<4;r++)n[r]=e>>>r*8&255,n[r+4]=t>>>r*8&255;return n}var OB={positional:!1,rejectUnknownFields:!1,envelope:MR,expectedEnvelope:`version 2 envelope, flags 0`,fingerprint:new Uint8Array(8)};({...OB});function kB(e){let t=EB(e);return{positional:!0,rejectUnknownFields:!1,envelope:NR,expectedEnvelope:`version 2 envelope, flags 1`,fingerprint:DB(Number(t&HR),Number(t>>UR&HR))}}function AB(e){switch(e._){case`json`:return 2;case`struct`:return 1;default:return 0}}function jB(e,t){switch(e._){case`literal`:return qz(e,t);case`bool`:return typeof t==`boolean`;case`null`:return t===null;case`undefined`:return t===void 0;case`number`:case`int`:case`i32`:case`u32`:return typeof t==`number`;case`string`:return typeof t==`string`;case`symbol`:return typeof t==`symbol`;case`bigint`:case`i64`:case`u64`:return typeof t==`bigint`;case`bytes`:return t instanceof Uint8Array;case`int64`:return e.flavor===`date`?t instanceof Date:qS(t)&&t._tag===`Utc`;case`dateTimeZoned`:return qS(t)&&t._tag===`Zoned`;case`duration`:return eo(t);case`bigDecimal`:return gS(t);case`option`:return vr(t);case`result`:return Br(t);case`exit`:return Xf(t);case`cause`:return bf(t);case`causeReason`:return xf(t);case`array`:return Array.isArray(t);case`struct`:return he(t)&&!Array.isArray(t);case`json`:return!0;case`union`:case`never`:return!1}}function $(e,t,n){throw Ez(new Rw({expected:e},t,n))}function MB(e,t=new Set){if(!me(e))return!1;let n=Array.isArray(e),r=Object.getPrototypeOf(e);if(n||r===Object.prototype||r===null){if(t.has(e))return!0;t.add(e);try{if(n){for(let n=0;n<e.length;n++)if(MB(e[n],t))return!0}else for(let n of Object.keys(e))if(MB(e[n],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||qS(e)||eo(e)||gS(e))return!1;if(t.has(e))return!0;t.add(e);try{if(vr(e))return br(e)&&MB(e.value,t);if(Br(e))return MB(Vr(e)?e.success:e.failure,t);if(Xf(e))return MB(rp(e)?e.value:e.cause,t);if(bf(e))return e.reasons.some(e=>MB(e,t));if(xf(e))switch(e._tag){case`Fail`:return MB(e.error,t);case`Die`:return MB(e.defect,t);case`Interrupt`:return!1}if(mv(e)){for(let n of e)if(MB(n,t))return!0;return!1}if(eC(e)){for(let[n,r]of e)if(MB(n,t)||MB(r,t))return!0;return!1}if(nC(e)){for(let n of e)if(MB(n,t))return!0;return!1}if(vC(e))return MB(xC(e),t);for(let n of Object.keys(e))if(MB(e[n],t))return!0}finally{t.delete(e)}return!1}function NB(e,t,n,r){let i=r.beginSized();DV(e,t,n,r),r.endSized(i)}function PB(e,t,n){let r=globalThis.Symbol.keyFor(t);r===void 0&&$(`registered symbol`,t,e.options),n.string(r)}function FB(e,t,n,r){let i=n;switch(i._tag){case`Fail`:r.byte(0),DV(e,t.error,i.error,r);return;case`Die`:r.byte(1),DV(e,t.defect,i.defect,r);return;case`Interrupt`:i.fiberId===void 0?r.byte(2):(r.byte(3),r.f64(i.fiberId))}}function IB(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function LB(e,t,n){if(e.layout!==t||e.keys.length!==n.length)return!1;for(let t=0;t<n.length;t++)if(e.keys[t]!==n[t])return!1;return!0}function RB(e,t){if(e.extraAll===void 0||t.length>Pz)return!1;let n=0;for(let e=0;e<t.length;e++)if(n+=t[e].length,n>Fz)return!1;return!0}function zB(e,t,n){let r=Object.keys(n),i=t.extraShape;if(i!==void 0&&LB(i,t,r))return i.pairs;let a=RB(t,r),o=a?void 0:e.extraShape;if(o!==void 0&&LB(o,t,r))return o.pairs;let s=t.names,c=t.extraAll,l=[],u=!0;for(let n of r){if(s.has(n))continue;let r=c??(e.indexSignatures??=new Vz(e.options)).find(t,n);r!==void 0&&(u&&!IB(n)&&(u=!1),l.push([n,r,void 0]))}if(u)l.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0]));else{for(let e of l)e[2]=WR.encode(e[0]);l.sort((e,t)=>Ik(e[2],t[2]))}if(a)for(let e of l)e[2]??=WR.encode(e[0]);let d={layout:t,keys:r,pairs:l};return a?t.extraShape=d:e.extraShape=d,l}function BB(e,t,n,r,i){for(let[a,o,s]of t){let t=s===void 0?a.length:s.length,c=n[a],l=VB(o.layout,c,e.options),u=l%lz;if(i===void 0)r.uvarint(t*lz+u);else{if(!i.disabled){let t=$B(i,a);if(t!==void 0){r.uvarint(t*16+u*2+1),Z[Q++]=a,HB(e,o.layout,c,l,r),Q--;continue}eV(i,a)}r.uvarint(t*16+u*2)}s===void 0?r.string(a):r.bytes(s),Z[Q++]=a,HB(e,o.layout,c,l,r),Q--}}function VB(e,t,n){if(e._===`literal`)return qz(e,t)||$(Jz(e),t,n),VB(e.leaf,t,n);switch(e._){case`bool`:return typeof t!=`boolean`&&$(`a boolean`,t,n),t?az:iz;case`number`:if(typeof t!=`number`&&$(`a number`,t,n),uz(t))return nz;{let e=mz(t);return e===0?rz:e*lz+oz}case`int`:return Number.isSafeInteger(t)||$(`an integer`,t,n),nz;case`i32`:case`u32`:return sz;default:return tz}}function HB(e,t,n,r,i){switch(r%lz){case iz:case az:return;case nz:i.numberVarint(n);return;case rz:i.f64(n);return;case sz:DV(e,t,n,i);return;case oz:{let e=Math.floor(r/lz);i.numberVarint(Math.round(n*pz[e])),i.uvarint(e);return}default:NB(e,t,n,i)}}function UB(e,t,n,r){let i=VB(t.layout,n,e.options),a=i%lz;if(a===tz){let i=r.idAndMark(t.tagBytes);DV(e,t.layout,n,r),r.endSized(i)}else r.uvarint(t.id*lz+a),HB(e,t.layout,n,i,r)}function WB(e,t){let n=e.byName;if(n===void 0)return;let r=Object.getOwnPropertyNames(t),i=0;for(let e=0;e<r.length;e++){let t=n.get(r[e]);t!==void 0&&(i|=1<<t)}let a=e.struct;if((i&a.requiredMask)!==a.requiredMask){let e=a.fields;for(let t=0;t<e.length;t++){let n=e[t];if(!n.optional&&!(i&1<<t))throw Z[Q++]=n.name,Ez(new Pw(n.annotations))}}return i}function GB(e,t,n,r){let i=n;if(t.extra.length>0){let n=e.intern;e.intern=void 0;let a=zB(e,t,i);if(a.length>0){r.uvarint(0);let t=r.beginSized();BB(e,a,i,r,n),r.endSized(t)}}let a=t.fields;for(let t=0;t<a.length;t++){let n=a[t],o=n.name;if(!Object.hasOwn(i,o)){if(n.optional)continue;throw Z[Q++]=o,Ez(new Pw(n.annotations))}Z[Q++]=o,UB(e,n,i[o],r),Q--}}function KB(e,t,n,r){let i=n,a=e.intern;e.intern=void 0;let o=t.optionalCount+7>>3,s=0;if(o>0){s=r.len;for(let e=0;e<o;e++)r.byte(0)}let c=t.fields,l=0;for(let t=0;t<c.length;t++){let n=c[t],a=n.name,o=Object.hasOwn(i,a);if(n.optional){if(o&&(r.buf[r.start+s+(l>>3)]|=1<<(l&7)),l++,!o)continue}else if(!o)throw Z[Q++]=a,Ez(new Pw(n.annotations));Z[Q++]=a,n.inline?DV(e,n.layout,i[a],r):NB(e,n.layout,i[a],r),Q--}if(t.extra.length>0){let n=zB(e,t,i);r.uvarint(n.length),BB(e,n,i,r,a)}}function qB(e){switch(e._){case`string`:return Xz;case`array`:return e.uniform?._===`string`?Zz:Yz;case`struct`:return e.extra.length>0?Qz:Yz;default:return Yz}}function JB(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let n of e.elements)if(n.optional||n.layout!==t)return}return t._===`struct`?t:void 0}function YB(e){let t=e.run;if(t!==void 0)return t;let n=JB(e);if(n===void 0)return e.run=t=null,t;let r=n.fields.map(e=>qB(e.layout)),i=n.fields.length<=$z;return t={struct:n,intern:r,shapes:i,byName:i&&n.extra.length===0?new Map(n.fields.map((e,t)=>[e.name,t])):void 0},e.run=t,t}var XB=16,ZB=64;function QB(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function $B(e,t){let n=e.refs;if(n!==void 0){let r=n.get(t);return r!==void 0&&e.hits++,r}let r=e.values;for(let n=0;n<r.length;n++)if(r[n]===t)return e.hits++,n}function eV(e,t){let n=e.values;if(e.refs!==void 0){if(e.hits===0&&n.length>=ZB){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,n.length)}else if(n.length>=XB){let r=e.refs=new Map;for(let e=0;e<n.length;e++)r.set(n[e],e);r.set(t,n.length)}n.push(t)}var tV=0,nV=1,rV=2,iV=64,aV=512;function oV(){return{slots:[],marks:[],frame:0}}function sV(e,t){return e[t]??={values:[],refs:new Map,state:tV,stamp:-1}}function cV(e,t){e.refs.has(t)?e.state=nV:(e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=iV&&(e.state=rV))}function lV(e,t){let n=e.values;n.length>=aV||(e.refs.set(t,n.length),n.push(t))}function uV(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function dV(e){e.marks.length=0,e.frame++}function fV(e){let t=e.marks;for(let e=t.length-1;e>=0;e--){let{length:n,slot:r,state:i}=t[e],a=r.values;for(let e=n;e<a.length;e++)r.refs.delete(a[e]);a.length=n,r.state=i}t.length=0,e.frame++}function pV(e,t,n,r){let i=sV(e.slots,t.slot),a=i.state;if(a===rV){r.string(n);return}if(uV(e,i),a===tV){r.string(n),cV(i,n);return}let o=i.refs.get(n);o===void 0?(r.byte(0),lV(i,n),r.string(n)):r.uvarint(o*2+1)}function mV(e,t,n){let r=sV(e,t.slot),i=r.state;if(i===rV)return n.readUtf8(n.end-n.pos);if(i===tV){let e=n.readUtf8(n.end-n.pos);return cV(r,e),e}let a=n.uvarint();if((a&1)==1){let e=(a-1)/2,t=r.values;return e>=t.length&&X(`a dictionary reference`,a,n.options),t[e]}a!==0&&X(`a dictionary marker`,a,n.options);let o=n.readUtf8(n.end-n.pos);return lV(r,o),o}function hV(e,t,n,r,i){if(!e.disabled){let t=$B(e,r);if(t!==void 0){i.uvarint(t*2+1);return}eV(e,r)}let a=i.beginSized();DV(t,n,r,i),i.endSizedRun(a)}function gV(e,t,n,r,i){let a=[],o=[];for(let s=0;s<r;s++){Z[Q++]=s;let r=i.beginSized();_V(e,t,a,o,n[s],i),i.endSized(r),Q--}}function _V(e,t,n,r,i,a){let o=t.struct,s=i,c=o.fields,l;if(o.extra.length>0){let t=zB(e,o,s);t.length>0&&(l=t)}let u=!t.shapes,d=l===void 0?0:eB,f=WB(t,s);if(f!==void 0)d=f;else for(let e=0;e<c.length;e++){let t=c[e];if(Object.hasOwn(s,t.name))u||(d|=1<<e);else if(!t.optional)throw Z[Q++]=t.name,Ez(new Pw(t.annotations))}let p=-1;for(let e=0;e<n.length;e++)if(n[e]===d){p=e;break}p>=0?a.uvarint(p+1):(a.uvarint(0),u||n.push(d));let m=p<0,h=e.positional&&!u;if(m&&h&&a.uvarint(d),l!==void 0){m&&!h&&a.uvarint(0);let t=a.beginSized();BB(e,l,s,a),a.endSizedRun(t)}for(let n=0;n<c.length;n++){let i=c[n];if(u?!Object.hasOwn(s,i.name):!(d&1<<n))continue;m&&!h&&a.uvarint(i.id),Z[Q++]=i.name;let o=t.intern[n];if(o===Xz)hV(QB(r,n),e,i.layout,s[i.name],a);else{o!==Yz&&(e.intern=QB(r,n));let t=a.beginSized();DV(e,i.layout,s[i.name],a),a.endSizedRun(t),e.intern=void 0}Q--}}function vV(e,t,n){let r=e.elements.length;if(t<r)return e.elements[t].layout;let i=Math.max(0,e.rest.length-1),a=Math.max(r,n-i);return t>=a?e.rest[t-a+1]:e.rest[0]}function yV(e,t,n,r){let i=n.length;if(t.rest.length===0&&i>t.elements.length)throw Z[Q++]=t.elements.length,Ez(new Fw(t.ast,n[t.elements.length],e.options));if(i<t.minCount)throw Z[Q++]=i,Ez(new Pw(void 0));if(t.hasCount&&r.uvarint(i),i>0){let a=YB(t);if(a!==null){gV(e,a,n,i,r);return}}let a=t.uniform;if(a!==void 0){if(t.uniformNumbers){xV(e,n,i,r);return}let o=e.intern;if(e.intern=void 0,o!==void 0){for(let t=0;t<i;t++)Z[Q++]=t,hV(o,e,a,n[t],r),Q--;return}let s=t.uniformInline;for(let t=0;t<i;t++)Z[Q++]=t,s?DV(e,a,n[t],r):NB(e,a,n[t],r),Q--}else for(let a=0;a<i;a++){let o=vV(t,a,i);Z[Q++]=a,rB(o)?DV(e,o,n[a],r):NB(e,o,n[a],r),Q--}}var bV=[];function xV(e,t,n,r){let i=!0,a=!0;for(let r=0;r<n;r++){let n=t[r];if(typeof n!=`number`&&(Z[Q++]=r,$(`a number`,n,e.options)),uz(n))(n<0?-n:n)>fz&&(a=!1);else{i=!1;let e=mz(n);e===0?a=!1:bV[r]=e}if(!i&&!a)break}if(i){r.byte(XR);for(let e=0;e<n;e++)r.numberVarint(t[e])}else if(a){r.byte(ZR);for(let e=0;e<n;e++){let n=t[e],i=Number.isInteger(n)?0:bV[e],a=i===0?n:Math.round(n*pz[i]),o=a<0||a===0&&1/a<0,s=o?-a:a;r.uvarint((s*2+ +!!o)*16+i)}}else{r.byte(YR);for(let e=0;e<n;e++)r.f64(t[e])}}function SV(e){if(!(e.length<2||e.some(e=>e.tuple)))for(let t of e[0].sentinels){let n=new Map;for(let r of e){let e=r.sentinels.find(e=>e.key===t.key);if(e===void 0||n.has(e.literal)||Number.isNaN(e.literal))break;n.set(e.literal,r)}if(n.size===e.length)return{key:t.key,rows:n}}}function CV(e,t){let n=e.sentinels;for(let e=0;e<n.length;e++){let{key:r,literal:i}=n[e];if(t[r]!==i||!Object.hasOwn(t,r))return!1}return!0}function wV(e,t){return e.tuple?Array.isArray(t)&&CV(e,t):he(t)&&!Array.isArray(t)&&CV(e,t)}function TV(e,t,n,r){e.positional?r.uvarint(t.position):(r.byte(Y.variant),r.u32le(t.tag)),DV(e,t.payload,n,r)}function EV(e,t,n,r){let i=t.discriminator;if(i!==void 0){if(he(n)&&!Array.isArray(n)){let t=n,a=i.rows.get(t[i.key]);if(a!==void 0&&CV(a,t)){TV(e,a,n,r);return}}}else for(let i of t.variants)if(wV(i,n)){TV(e,i,n,r);return}for(let i of t.others)if(jB(i.layout,n)){e.positional?r.uvarint(i.position):r.byte(i.kind),DV(e,i.layout,n,r);return}throw Ez(new Lw(t.ast,n,e.options))}function DV(e,t,n,r){switch(t._){case`literal`:qz(t,n)||$(Jz(t),n,e.options),DV(e,t.leaf,n,r);return;case`bool`:typeof n!=`boolean`&&$(`a boolean`,n,e.options),r.byte(+(n===!0));return;case`null`:n!==null&&$(`null`,n,e.options);return;case`undefined`:n!==void 0&&$(`undefined`,n,e.options);return;case`number`:{if(typeof n!=`number`&&$(`a number`,n,e.options),uz(n)){r.numberVarint(n);return}let t=mz(n);t>0?(r.numberVarint(Math.round(n*pz[t])),r.byte(t)):r.f64(n);return}case`int`:Number.isSafeInteger(n)||$(`an integer`,n,e.options),r.numberVarint(n);return;case`string`:{typeof n!=`string`&&$(`a string`,n,e.options);let i=e.dict;i===void 0?r.string(n):pV(i,t,n,r);return}case`symbol`:typeof n!=`symbol`&&$(`a symbol`,n,e.options),PB(e,n,r);return;case`bytes`:n instanceof Uint8Array||$(`a Uint8Array`,n,e.options),r.bytes(n);return;case`bigint`:typeof n!=`bigint`&&$(`a bigint`,n,e.options),r.zigzag(n);return;case`i32`:(typeof n!=`number`||(n|0)!==n)&&$(`a 32-bit integer`,n,e.options),r.i32le(n);return;case`u32`:(typeof n!=`number`||n>>>0!==n)&&$(`a 32-bit unsigned integer`,n,e.options),r.u32le(n);return;case`i64`:(typeof n!=`bigint`||n<OR||n>kR)&&$(`a 64-bit integer`,n,e.options),r.i64(n);return;case`u64`:(typeof n!=`bigint`||n<FR||n>AR)&&$(`a 64-bit unsigned integer`,n,e.options),r.u64(n);return;case`int64`:{jB(t,n)||$(t.flavor===`date`?`a Date`:`a DateTime.Utc`,n,e.options);let i=t.flavor===`date`?n.getTime():n.epochMilliseconds;Number.isNaN(i)&&$(`a valid Date`,n,e.options),r.i64(BigInt(i));return}case`dateTimeZoned`:{jB(t,n)||$(`a DateTime.Zoned`,n,e.options);let i=n;r.i64(BigInt(i.epochMilliseconds)),i.zone._tag===`Offset`?(r.byte(0),r.i32le(i.zone.offset)):(r.byte(1),r.string(i.zone.id));return}case`duration`:{eo(n)||$(`a Duration`,n,e.options);let t=n.value;switch(t._tag){case`Infinity`:r.byte(1);return;case`NegativeInfinity`:r.byte(2);return;case`Nanos`:r.byte(0),r.zigzag(t.nanos);return;case`Millis`:r.byte(0),r.zigzag(BigInt(t.millis)*BR);return}}case`bigDecimal`:{gS(n)||$(`a BigDecimal`,n,e.options);let t=CS(n);r.zigzag(t.value),r.zigzag(BigInt(t.scale));return}case`json`:{let t;try{t=JSON.stringify(n)}catch{t=void 0}t===void 0&&(MB(n)&&$(`acyclic value`,n,e.options),$(`a JSON-serializable value`,n,e.options)),r.string(t);return}case`option`:{vr(n)||$(`an Option`,n,e.options);let i=n;i._tag===`None`?r.byte(0):(r.byte(1),DV(e,t.value,i.value,r));return}case`result`:{Br(n)||$(`a Result`,n,e.options);let i=n;i._tag===`Success`?(r.byte(0),DV(e,t.success,i.success,r)):(r.byte(1),DV(e,t.failure,i.failure,r));return}case`exit`:{Xf(n)||$(`an Exit`,n,e.options);let i=n;i._tag===`Success`?(r.byte(0),DV(e,t.value,i.value,r)):(r.byte(1),DV(e,t.cause,i.cause,r));return}case`cause`:{bf(n)||$(`a Cause`,n,e.options);let i=n.reasons;r.uvarint(i.length);for(let n of i){let i=r.beginSized();FB(e,t,n,r),r.endSized(i)}return}case`causeReason`:xf(n)||$(`a Cause.Reason`,n,e.options),FB(e,t,n,r);return;case`struct`:(!he(n)||Array.isArray(n))&&$(`an object`,n,e.options),e.positional?KB(e,t,n,r):GB(e,t,n,r);return;case`array`:Array.isArray(n)||$(`an array`,n,e.options),yV(e,t,n,r);return;case`union`:EV(e,t,n,r);return;case`never`:throw Ez(new Lw(t.ast,n,e.options))}}var OV=new Rz;function kV(e,t,n,r,i){let a=i.beginSized();i.byte(r.envelope),r.positional&&i.bytes(r.fingerprint),DV(e,t,n,i),i.endSized(a)}function AV(e,t,n,r,i,a){let o={options:r,positional:i.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:a},s=OV??new Rz,c=s===OV;c&&(OV=void 0),s.reset();let l=Q,u=!1;try{if(n===void 0)Q=0,kV(o,e,t,i,s);else for(let t=0;t<n.length;t++)Q=0,kV(o,e,n[t],i,s);let r=s.out();return u=!0,r}finally{a!==void 0&&(u?dV(a):fV(a)),s.abort(),Q=l,c&&(OV=s)}}function jV(e,t,n,r,i){return AV(e,void 0,t,n,r,i)}function MV(e,t,n,r,i){return AV(e,t,void 0,n,r,i)}function NV(e){return Xf(e)&&rp(e)}var PV=globalThis.Symbol.for(`~effect/encoding/SchemaBinary/absent`);function FV(e,t){let n=uH(e,t);return n!==PV&&t.pos!==t.end&&X(`no leftover bytes`,void 0,t.options),n}function IV(e,t){let n=t.enter(t.uvarint()),r=FV(e,t);return t.exit(n),r}function LV(e,t){if(tB(e))return uH(e,t);let n=nB(e),r=t.enter(n===void 0?e._===`null`||e._===`undefined`?0:t.uvarint():n),i=FV(e,t);return t.exit(r),i}var RV=8;function zV(e,t){let n=e.set;if(n!==void 0)return n.has(t)?!0:(n.add(t),!1);let r=e.list;if(r.includes(t))return!0;if(r.length>=RV){let n=e.set=new Set;for(let e=0;e<r.length;e++)n.add(r[e]);n.add(t)}else r.push(t);return!1}function BV(e,t,n,r,i){let a=t.uvarint(),o=Math.floor(i===void 0?a/lz:a/16),s=i===void 0?a-o*lz:Math.floor((a-o*16)/2),c=i===void 0?t.readUtf8(o):VV(i,a,o,t);e.names.has(c)&&X(`an extra key distinct from declared fields`,c,t.options),zV(r,c)&&X(`unique extra keys`,void 0,t.options);let l=e.extraAll??(t.indexSignatures??=new Vz(t.options)).find(e,c);if(l===void 0){t.rejectUnknownFields&&X(`a key matching an index signature`,c,t.options),GV(s,t);return}Z[Q++]=c;let u=JV(l.layout,l.wireMask,s,t);Q--,u!==PV&&b(n,c,u)}function VV(e,t,n,r){if((t&1)==1)return n>=e.length&&X(`a known back-reference`,void 0,r.options),e[n];let i=r.readUtf8(n);return e.push(i),i}function HV(e){return new Nw([e.name],new Pw(e.annotations))}function UV(e,t){throw Ez(new Iw(e.ast,t))}function WV(e){for(;e.byte()&128;);}function GV(e,t){switch(e){case tz:t.take(t.uvarint());return;case nz:WV(t);return;case rz:t.take(8);return;case iz:case az:case cz:return;case oz:WV(t),WV(t);return;case sz:t.take(4);return}}function KV(e){if(e._===`literal`)return KV(e.leaf);switch(e._){case`bool`:return 24;case`number`:return 38;case`int`:return 2;case`i32`:case`u32`:return 64;default:return 1}}function qV(e,t){switch(e){case iz:return!1;case az:return!0;case nz:return t.numberVarint();case rz:return t.f64();case oz:{let e=t.numberVarint(),n=t.uvarint();return(n===0||n>dz)&&X(`a decimal scale in [1, 8]`,n,t.options),e/pz[n]}}return X(`matching field wire kind`,void 0,t.options)}function JV(e,t,n,r){if(!(t&1<<n))return r.rejectUnknownFields&&X(`matching field wire kind`,n,r.options),GV(n,r),PV;if(n===sz)return e._===`u32`?r.u32le():r.i32le();if(n!==tz){let t=qV(n,r);return e._===`literal`&&!qz(e,t)&&X(Jz(e),t,r.options),t}let i=r.enter(r.uvarint()),a=FV(e,r);return r.exit(i),a}function YV(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},i=0,a=0,o,s,c,l=!1,u=e.fields,d=0;for(;t.pos<t.end;){let f=t.fieldTag(),p=Math.floor(f/lz),m=f-p*lz;if(p===0){l&&X(`unique field ids`,void 0,t.options),l=!0,m!==tz&&X(`extra field map`,void 0,t.options);let i=t.enter(t.uvarint());QV(e,t,r,n),t.exit(i);continue}let h;if(d<u.length&&u[d].id===p?(h=u[d],d++):(h=e.byId.get(p),h!==void 0&&(d=h.index+1)),h===void 0){t.rejectUnknownFields&&X(`a known field id`,p,t.options),c===void 0?c=new Set:c.has(p)&&X(`unique field ids`,void 0,t.options),c.add(p),GV(m,t);continue}let g=h.index;if(g<32){let e=1<<g;(i&e)!==0&&X(`unique field ids`,void 0,t.options),i|=e}else o===void 0?o=new Set([g]):(o.has(g)&&X(`unique field ids`,void 0,t.options),o.add(g));Z[Q++]=h.name;let ee=JV(h.layout,h.wireMask,m,t);Q--,ee!==PV&&(b(r,h.name,ee),g<32?a|=1<<g:(s??=new Set).add(g))}return XV(e,a,s,t),r}function XV(e,t,n,r){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let i=e.fields,a;for(let e=0;e<i.length;e++){let o=i[e],s=o.index,c=s<32?!!(t&1<<s):n?.has(s)===!0;if(!o.optional&&!c&&((a??=[]).push(HV(o)),r.options.errors!==`all`))break}a!==void 0&&UV(e,a)}function ZV(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},i=e.optionalCount+7>>3,a=0;i>0&&(t.pos+i>t.end&&X(`complete value`,void 0,t.options),a=t.pos,t.pos+=i);let o=t.buf,s=e.fields,c=0,l;for(let e=0;e<s.length;e++){let n=s[e];if(n.optional){let e=!!(o[a+(c>>3)]&1<<(c&7));if(c++,!e)continue}Z[Q++]=n.name;let i=n.inline?LV(n.layout,t):IV(n.layout,t);if(Q--,i!==PV)b(r,n.name,i);else if(!n.optional&&((l??=[]).push(HV(n)),t.options.errors!==`all`))break}if(l!==void 0&&UV(e,l),e.extra.length>0){let i=t.uvarint();if(i>t.remaining&&X(`complete value`,void 0,t.options),i>0){let a={list:[],set:void 0};for(let o=0;o<i;o++)BV(e,t,r,a,n)}}return r}function QV(e,t,n,r){let i={list:[],set:void 0};for(;t.pos<t.end;)BV(e,t,n,i,r)}function $V(e,t,n){let r=n.uvarint();if((r&1)==1){let t=(r-1)/2;return t>=e.length&&X(`a known back-reference`,void 0,n.options),e[t]}if(t._===`string`){if(n.dict!==void 0){let i=n.enter(r/2),a=FV(t,n);return n.exit(i),e.push(a),a}let i=n.readUtf8(r/2);return e.push(i),i}let i=n.enter(r/2),a=FV(t,n);return n.exit(i),e.push(a),a}function eH(e,t,n){let r=Array(t),i=[],a=[];for(let o=0;o<t;o++){Z[Q++]=o;let t=n.enter(n.uvarint());r[o]=nH(e,i,a,n),n.exit(t),Q--}return r}function tH(e,t){let n=t.uvarint(),r=e.fields,i=n&-1073741825;(n>eB*2-1||i>>>r.length)&&X(`a known row shape`,void 0,t.options);let a=[];(n&eB)!==0&&a.push(null);for(let e=0;e<r.length;e++)i&1<<e&&a.push(r[e]);return a}function nH(e,t,n,r){let i=e.struct,a={},o=0,s,c=r.uvarint(),l;if(c===0?r.positional&&e.shapes&&(l=tH(i,r),t.push(l)):(l=t[c-1],l===void 0&&X(`a known row shape`,void 0,r.options)),l!==void 0){for(let t=0;t<l.length;t++){let i=rH(e,n,l[t],a,r);i>=0&&(i<32?o|=1<<i:(s??=new Set).add(i))}r.pos!==r.end&&X(`no leftover bytes`,void 0,r.options)}else{let c=e.shapes?[]:void 0,l=0,u,d,f=!1;for(;r.pos<r.end;){let t=r.uvarint(),p;t===0?(f&&X(`unique field ids`,void 0,r.options),f=!0,p=null):(p=i.byId.get(t),p===void 0?(r.rejectUnknownFields&&X(`a known field id`,t,r.options),d===void 0?d=new Set([t]):d.has(t)?X(`unique field ids`,void 0,r.options):d.add(t)):p.index<32?(l&1<<p.index&&X(`unique field ids`,void 0,r.options),l|=1<<p.index):u===void 0?u=new Set([p.index]):(u.has(p.index)&&X(`unique field ids`,void 0,r.options),u.add(p.index))),c?.push(p);let m=rH(e,n,p,a,r);m>=0&&(m<32?o|=1<<m:(s??=new Set).add(m))}c!==void 0&&t.push(c)}return XV(i,o,s,r),a}function rH(e,t,n,r,i){let a=i.uvarint();if((a&1)==1){if(n==null)return-1;let e=t[n.index],o=(a-1)/2;(e===void 0||o>=e.length)&&X(`a known back-reference`,void 0,i.options);let s=e[o];return s===PV?-1:(b(r,n.name,s),n.index)}let o=i.enter(a/2);if(n===null)return QV(e.struct,i,r),i.exit(o),-1;if(n===void 0)return i.exit(o),-1;let s=e.intern[n.index];(s===Zz||s===Qz)&&(i.intern=t[n.index]??=[]),Z[Q++]=n.name;let c=FV(n.layout,i);return Q--,i.intern=void 0,i.exit(o),s===Xz&&(t[n.index]??=[]).push(c),c===PV?-1:(b(r,n.name,c),n.index)}function iH(e,t){let n=e.elements.length,r=e.hasCount?t.uvarint():n;if(e.rest.length===0&&r>n)throw Z[Q++]=n,Ez(new Fw(e.ast,void 0,t.options));if(r<e.minCount)throw Z[Q++]=r,Ez(new Pw(void 0));if(e.hasCount&&r>(e.rest.length>0&&iB(e.rest[0])?ez:t.remaining+$R)&&X(`array count within allocation limit`,r,t.options),r>0){let n=YB(e);if(n!==null)return eH(n,r,t)}let i=Array(r),a=e.uniform;if(a!==void 0){if(e.uniformNumbers)return aH(i,r,t);let n=t.intern;if(t.intern=void 0,n!==void 0){for(let e=0;e<r;e++){Z[Q++]=e;let r=$V(n,a,t);if(r===PV)throw Ez(new Pw(void 0));Q--,i[e]=r}return i}if(tB(a)){for(let e=0;e<r;e++)Z[Q++]=e,i[e]=uH(a,t),Q--;return i}if(a._===`string`){for(let e=0;e<r;e++)Z[Q++]=e,i[e]=t.dict===void 0?t.readUtf8(t.uvarint()):IV(a,t),Q--;return i}let o=e.uniformPacked,s=e.uniformInline;for(let e=0;e<r;e++){Z[Q++]=e;let n=t.enter(s?o??0:t.uvarint()),r=FV(a,t);if(t.exit(n),r===PV)throw Ez(new Pw(void 0));Q--,i[e]=r}return i}for(let a=0;a<r;a++){let o=vV(e,a,r),s=a<n&&e.elements[a].optional;if(!e.hasCount&&t.remaining===0&&!s&&o._!==`null`&&o._!==`undefined`)throw Z[Q++]=a,Ez(new Pw(void 0));Z[Q++]=a;let c=LV(o,t);if(c===PV)throw s&&X(`known union member`,void 0,t.options),Ez(new Pw(void 0));Q--,i[a]=c}if(!e.hasCount&&t.pos<t.end)throw Z[Q++]=n,Ez(new Fw(e.ast,void 0,t.options));return i}function aH(e,t,n){let r=n.byte();if(r===YR){n.remaining!==t*8&&X(`f64`,void 0,n.options);for(let r=0;r<t;r++)e[r]=n.f64();return e}if(r===ZR){for(let r=0;r<t;r++){Z[Q++]=r;let t=n.uvarint(),i=t%16;i>dz&&X(`decimal`,void 0,n.options);let a=hz((t-i)/16);e[r]=i===0?a:a/pz[i],Q--}return e}r!==XR&&X(`f64`,void 0,n.options);for(let r=0;r<t;r++)Z[Q++]=r,e[r]=n.numberVarint(),Q--;return e}function oH(e,t){let n=t.byte();if(n===Y.variant){let n=t.u32le(),r=e.byTag.get(n);if(r===void 0)return t.rejectUnknownFields&&X(`known union member`,n,t.options),t.take(t.remaining),PV;let i=FV(r.payload,t);if(i===PV)return PV;if(!r.tuple)for(let e of r.sentinels)b(i,e.key,e.literal);return i}let r=e.byKind.get(n);return r===void 0?(t.rejectUnknownFields&&X(`known union member`,n,t.options),t.take(t.remaining),PV):FV(r,t)}function sH(e,t){let n=e.byPos[t.uvarint()];n===void 0&&X(`known union member`,void 0,t.options);let r=FV(n.layout,t),i=n.variant;if(i!==void 0&&!i.tuple&&r!==PV)for(let e of i.sentinels)b(r,e.key,e.literal);return r}function cH(e,t){switch(t.byte()){case 0:return kf(lH(FV(e.error,t)));case 1:return Af(lH(FV(e.defect,t)));case 2:return t.remaining!==0&&X(`empty`,void 0,t.options),jf();case 3:return t.remaining!==8&&X(`f64`,void 0,t.options),jf(t.f64());default:return t.take(t.remaining),PV}}function lH(e){if(e===PV)throw Ez(new Pw(void 0));return e}function uH(e,t){t.nesting>=QR&&X(`nesting depth at most ${QR}`,t.nesting+1,t.options),t.nesting++;try{return dH(e,t)}finally{t.nesting--}}function dH(e,t){switch(e._){case`literal`:{let n=uH(e.leaf,t);return qz(e,n)||X(Jz(e),n,t.options),n}case`bool`:{t.remaining!==1&&X(`bool`,void 0,t.options);let e=t.byte();return e>1&&X(`bool`,void 0,t.options),e===1}case`null`:return t.remaining!==0&&X(`empty`,void 0,t.options),null;case`undefined`:t.remaining!==0&&X(`empty`,void 0,t.options);return;case`number`:{let e=t.remaining;if(e===8)return t.f64();(e===0||e>KR)&&X(`f64`,void 0,t.options);let n=t.numberVarint();if(t.remaining===0)return n;let r=t.byte();return(t.remaining!==0||r===0||r>dz)&&X(`decimal`,void 0,t.options),n/pz[r]}case`int`:return t.numberVarint();case`string`:{let n=t.dict;return n===void 0?t.readUtf8(t.end-t.pos):mV(n,e,t)}case`symbol`:return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case`bytes`:return t.takeCopy(t.end-t.pos);case`bigint`:return t.zigzag();case`i32`:return t.remaining!==4&&X(`a 32-bit integer`,void 0,t.options),t.i32le();case`u32`:return t.remaining!==4&&X(`a 32-bit unsigned integer`,void 0,t.options),t.u32le();case`i64`:return t.remaining!==8&&X(`a 64-bit integer`,void 0,t.options),t.i64();case`u64`:return t.remaining!==8&&X(`a 64-bit unsigned integer`,void 0,t.options),t.u64();case`int64`:{t.remaining!==8&&X(`int64`,void 0,t.options);let n=Number(t.i64()),r=new Date(n);return Number.isNaN(r.getTime())&&X(e.flavor===`date`?`a valid Date`:`a valid DateTime`,n,t.options),e.flavor===`date`?r:JS(n)}case`dateTimeZoned`:{let e=Number(t.i64()),n=t.byte(),r;if(n===0)t.remaining!==4&&X(`time zone`,void 0,t.options),r=t.i32le();else if(n===1)r=t.readUtf8(t.end-t.pos);else return X(`time zone`,void 0,t.options);try{return YS(e,{timeZone:r})}catch{return X(`time zone`,void 0,t.options)}}case`duration`:switch(t.byte()){case 0:return co(t.zigzag());case 1:return oo;case 2:return so;default:return X(`duration`,void 0,t.options)}case`bigDecimal`:{let e=t.zigzag(),n=t.zigzag();return(n>PR||-n>PR)&&X(`safe integer length`,void 0,t.options),_S(e,Number(n))}case`json`:{let e=t.readUtf8(t.end-t.pos);try{return JSON.parse(e)}catch{return X(`json`,void 0,t.options)}}case`option`:{let n=t.byte();return n===0?(t.remaining!==0&&X(`empty`,void 0,t.options),T()):(n!==1&&X(`bool`,void 0,t.options),E(lH(FV(e.value,t))))}case`result`:{let n=t.byte();return n===0?Lr(lH(FV(e.success,t))):(n!==1&&X(`bool`,void 0,t.options),Rr(lH(FV(e.failure,t))))}case`exit`:{let n=t.byte();return n===0?Zf(lH(FV(e.value,t))):(n!==1&&X(`bool`,void 0,t.options),Qf(uH(e.cause,t)))}case`cause`:{let n=t.uvarint(),r=[];for(let i=0;i<n;i++){Z[Q++]=i;let n=t.enter(t.uvarint()),a=cH(e,t);t.exit(n),Q--,a!==PV&&r.push(a)}return t.pos!==t.end&&X(`no leftover bytes`,void 0,t.options),Tf(r)}case`causeReason`:return cH(e,t);case`struct`:return t.positional?ZV(e,t):YV(e,t);case`array`:return iH(e,t);case`union`:return t.positional?sH(e,t):oH(e,t);case`never`:throw Ez(new Lw(e.ast,void 0,t.options))}}function fH(e,t,n){let r=t.byte();if(r!==n.envelope&&X(n.expectedEnvelope,r,t.options),n.positional){t.remaining<8&&X(`complete value`,void 0,t.options);let e=t.buf,r=n.fingerprint,i=t.pos;for(let n=0;n<8;n++)e[i+n]!==r[n]&&X(`matching layout fingerprint`,void 0,t.options);t.pos=i+8}let i=FV(e,t);if(i===PV)throw Ez(new Pw(void 0));return i}var pH=new Gz;function mH(e,t,n,r){let i=pH??new Gz,a=i===pH;a&&(pH=void 0),i.reset(t,0,t.length,n,void 0,r,void 0);let o=Q;Q=0;try{let a=i.uvarint();a===0&&X(`nonzero frame length`,void 0,n);let o=i.enter(a),s=fH(e,i,r);return i.exit(o),i.pos!==t.length&&X(`no leftover bytes`,void 0,n),s}finally{Q=o,i.release(),a&&(pH=i)}}function hH(e,t,n,r=!1){return PT({decode:(i,a)=>{try{let o=mH(e,i,a,t);return n!==void 0&&me(o)&&(!r||NV(o))&&(n.value=o),R(o)}catch(e){return e instanceof Tz?H(e.issue):Cg(e)}},encode:(n,r)=>{try{return R(MV(e,n,r,t))}catch(e){return e instanceof Tz?H(e.issue):Cg(e)}}})}var gH=f(kB);function _H(e,t){return t===!0?gH(e):OB}var vH=f(e=>{let t=J(sB(e)),{exact:n,exitSuccess:r,layout:i,recursive:a}=xB(t.ast);return{target:a?DH(t):t,layout:i,exact:n,exitSuccess:r,recursive:a}});function yH(e){return vH(e.ast)}function bH(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function xH(e,t,n){let r=J($D(e.ast)),i=KO(r),a=e=>()=>(t,n,r)=>e(t,r)?q:i(t,r);return J(new hE([r.ast],a(t),{identifier:`binary value`},void 0,void 0,void 0,void 0,a(n)))}function SH(e,t){return t.onExcessProperty!==`error`}function CH(e,t,n){return xH(e,e=>bH(t,e),n?SH:wH)}function wH(){return!1}function TH(e,t){return Rk()([e],([e])=>{let n=KO(e);return(e,r,i)=>bH(t,e)||NV(e)&&i.onExcessProperty!==`error`?R(e):n(e,i)},{identifier:`binary exit value`})}function EH(e){return xH(e,SH,SH)}function DH(e){let t=J($D(e.ast)),n=new WeakSet;return jA(Rk()([t],([e])=>(t,r,i)=>me(t)&&n.delete(t)?R(t):MB(t)?H(new Lw(r,t,i)):KO(e)(t,i),{identifier:`acyclic value`}),FT({decode:e=>(me(e)&&n.add(e),e),encode:e=>e}))(e)}var OH=class extends Ki()(`effect/rpc/RpcSerialization`){},kH=16777216,AH=new TextEncoder,jH=e=>{let t=e?.maxFrameSize===`unbounded`?void 0:e?.maxFrameSize??kH,n=e?.fingerprintPayloads===!0?e=>_R(e,{fingerprint:!0}):_R,r={fingerprint:!0};return OH.of({contentType:`application/vnd.effect.rpc+schema-binary`,includesFraming:!0,codecFor:n,makeUnsafe:()=>{let e=SR(dR,{...r,maxFrameSize:t}),n=wR(dR,r);return{decode:t=>e.feedSync(typeof t==`string`?AH.encode(t):t),encode:e=>{if(!Array.isArray(e))return n.encode(e);if(e.length!==0)return n.encodeMany(e)}}}})},MH=e=>Jp(OH)(()=>jH(e)),NH=e=>z(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>r_(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),V});return W(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return bg(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*a_(z(()=>i(e)),t)}return yield*__(yg,()=>(t.delete(e),r.delete(e),V))})}}))}),PH=0,FH=W_(function*(e,t){let n=t.spanPrefix,r=t?.supportsAck??!0,a=t?.disableTracing??!1,o=t?.generateRequestId??(()=>PH++),s=yield*n_(),c=O(s,Cp),l=new Map,u=!1;yield*Dp(c,Eg(e=>(u=!0,d(tp(e.id)))));let d=W_(function*(e){let t=Array.from(l.values());l.clear();for(let n of t)n._tag===`Queue`?yield*e._tag===`Success`?Dy(n.queue):Ty(n.queue,e.cause):n.resume(e)},S_),f=e=>{let r=KL(e.successSchema),i=h(e);return(o,s)=>{let c=s?.headers?DC(s.headers):EC,l=s?.context??la();if(!r){let r=t=>p(e,i,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return a?r(void 0):O_(HL(n,e._tag),{kind:`client`,attributes:UL(e._tag,t.spanAttributes)},r)}let u=m(e,i,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:Ax(W(u,Ex))}},p=(e,n,r,a,s,c,d)=>Eg(f=>{if(u)return y_;let p=o(),m=n(e=>t.onFromClient({message:e,context:c}),{_tag:`Request`,id:p,tag:e._tag,payload:a,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:jC(f.getRef(zH),s),...d?{discard:!0}:{}}),h;return x_(vg(t=>{let n=!1,a={_tag:`Effect`,rpc:e,context:c,resume(e){d&&e._tag===`Success`?(n=!0,h?.pollUnsafe()&&t(np)):(t(e),h&&!h.pollUnsafe()&&f.currentDispatcher.scheduleTask(()=>{h.interruptUnsafe(f.id)},0))}};l.set(p,a),h=m.pipe(r?A_(r,{captureStackTrace:!1}):i,I_(f.context)),h.addObserver(e=>{if(e._tag===`Failure`)return l.delete(p),t(e);if(n)return t(np)})}),e=>(l.delete(p),kg(iv(h),g(p,Array.from(e),c))))}),m=W_(function*(e,r,s,c,d,f){if(u)return yield*y_;let p=a?void 0:yield*D_(HL(n,e._tag),{kind:`client`,attributes:UL(e._tag,t.spanAttributes)}),m=ov(),h=o(),ee=ga(m.context,Cp),_=yield*by(d);return yield*Ep(ee,e=>(ky(_),l.has(h)?(l.delete(h),g(h,ip(e)?Array.from(Rf(e.cause)):[],f)):V)),l.set(h,{_tag:`Queue`,rpc:e,queue:_,scope:ee,context:f}),yield*r(e=>t.onFromClient({message:e,context:f}),{_tag:`Request`,id:h,tag:e._tag,payload:s,...p?{traceId:p.traceId,spanId:p.spanId,sampled:p.sampled}:{},headers:jC(m.getRef(zH),c)}).pipe(p?A_(p,{captureStackTrace:!1}):i,h_(e=>(Mf(e)||l.delete(h),Ty(_,e))),b_,M_(ee,{startImmediately:!0})),_}),h=e=>{let t=[];for(let n of e.middlewares.values()){let e=ha(s,`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},g=(e,n,r)=>vg(i=>{let a=ov();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r}).pipe(qg(1e3),I_(a.context)).addObserver(()=>{i(V)})}),ee=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,a=l.get(n);return!a||a._tag!==`Queue`?V:Cy(a.queue,e.values).pipe(r?U(n=>n.length>0?V:t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:a.context})):i,Ig(e=>Ty(a.queue,e)))}case`Exit`:{let t=e.requestId,n=l.get(t);return n?(l.delete(t),n._tag===`Effect`?(n.resume(e.exit),V):e.exit._tag===`Success`?Dy(n.queue):Ty(n.queue,e.exit.cause)):V}case`Defect`:return d(ep(e.defect));case`ClientEnd`:return V}},_;if(t.flatten){let t=new Map;_=function(n,r,i){let a=t.get(n);return a||(a=f(e.requests.get(n)),t.set(n,a)),a(r,i)}}else _={},e.requests.forEach(e=>{b(_,e._tag,f(e))});return{client:_,write:ee}}),IH=0,LH=W_(function*(e,t){let n=IH++,{codecFor:r,run:i,send:a,supportsAck:o,supportsTransferables:s}=yield*BH,c=RH(r),l=Qk(r(tj())),u=new Map,d=cp(),f=e=>u.has(e)?(u.delete(e),a(n,{_tag:`Interrupt`,requestId:e})):V,{client:p,write:m}=yield*FH(e,{...t,supportsAck:o,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),i=s?BL():void 0,o=ov(),l={rpc:r,context:i?fa(o.context,zL,i):o.context,schemas:c(r),discard:t.discard===!0};return u.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(a_(l.context),Bg,U(e=>hp(d)?(u.delete(t.id),y_):a(n,{...t,id:t.id,payload:e,headers:Object.entries(t.headers)},i&&i.readUnsafe())),h_(e=>Mf(e)?V:B(()=>u.delete(t.id))))}case`Ack`:return u.get(t.requestId)?a(n,{_tag:`Ack`,requestId:t.requestId}):V;case`Interrupt`:return f(t.requestId);case`Eof`:return V}}});return yield*i(n,e=>{switch(e._tag){case`Chunk`:{let t=cR(e.requestId),n=u.get(t);if(!n||yr(n.schemas.decodeChunk))return V;let r=n.schemas.decodeChunk.value;return C_(i=>i(r(e.values).pipe(a_(n.context),Bg,U(e=>m({_tag:`Chunk`,clientId:0,requestId:t,values:e})))).pipe(h_(e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:Qf(e)}).pipe(kg(Lf(e)?V:$g(Gg(f(t)),up(d))))),Rg(e=>!Lf(e),()=>V)))}case`Exit`:{let t=cR(e.requestId),n=u.get(t);return n?(u.delete(t),n.discard&&e.exit._tag===`Success`?m({_tag:`Exit`,clientId:0,requestId:t,exit:np}):(n.discard?n.schemas.decodeDiscardExit:n.schemas.decodeExit)(e.exit).pipe(a_(n.context),Bg,t_({onSuccess:e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:Qf(e)})}))):V}case`Defect`:return u.clear(),m({_tag:`Defect`,clientId:0,defect:l(e.defect)});case`ClientProtocolError`:{let t=$f(e.error),n=e.requestIds===void 0?Array.from(u.keys()):e.requestIds.map(cR).filter(e=>u.has(e));for(let e of n)u.delete(e);return pg(n,e=>m({_tag:`Exit`,clientId:0,requestId:e,exit:t})).pipe(S_)}default:return V}}).pipe(Ig(K_),b_,N_),yield*p_(()=>_p(d,void 0)),p}),RH=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=qL(n.successSchema),a=O(n.annotations,nR),o=tR(n),s;return r={decodeChunk:Ar(i,t=>qk(e(CA(t.success)),a)),encodePayload:eA(e(n.payloadSchema),a),decodeExit:qk(e(o),a),decodeDiscardExit:t=>(s??=qk(e(lj(gA,o.error,o.defect)),a))(t)},t.set(n,r),r}},zH=k(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>EC}),BH=class extends Ki()(`effect/rpc/RpcClient/Protocol`){static make=NH},VH=e=>BH.make(W_(function*(t,n){let r=yield*_L,a=yield*OH,o=yield*o_(GH),s=new Map,c=yield*r.writer,u=a.makeUnsafe(),d=yield*UH(z(()=>c.write(u.encode(lR))),e),f=Kg(e?.onPingTimeout??V,{log:!0,message:`RpcClient onPingTimeout hook failed`}),p,m=e=>{let r=pg(Array.from(n),n=>t(n,e));return e._tag!==`Defect`&&e._tag!==`ClientProtocolError`?r:(s.clear(),S_(r))},h=e=>(p=e,m({_tag:`ClientProtocolError`,error:e})),g=e=>{try{let n=u.decode(e);if(n.length===0)return V;d.onFrame();let r=0;return mg({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return V;if(Object.hasOwn(e,`requestId`)){let n=e.requestId,r=s.get(n);if(r!==void 0)return e._tag===`Exit`&&s.delete(n),t(r,e)}return m(e)},step:l})}catch(e){return m({_tag:`ClientProtocolError`,error:new sR({reason:new oR({message:`Error decoding message`,cause:e})})})}};yield*z(()=>{u=a.makeUnsafe(),d.reset();let e=!1;return bg(function*(){let{pull:t}=yield*r.reader;for(p=void 0,e=!0,br(o)&&(yield*o.value.onConnect);;){let e=yield*t;for(let t=0;t<e.length;t++)yield*g(e[t])}}).pipe(u_,$g(d.timeout),kg(()=>e?f:V),kg(()=>H(new AL({reason:new wL({cause:Error(`ping timeout`)})}))))}).pipe(br(o)?m_(o.value.onDisconnect):i,Hg(t=>{let n=Ff(t),r=Vr(n),i=new sR({reason:r?n.success.reason:new oR({message:`Unknown socket error`,cause:Pf(t)})});return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?(e.onTransientError?.(i)??V).pipe(Kg({log:!0,message:`RpcClient onTransientError hook failed`})):h(i)}),Wg(e?.retryPolicy??HH,e=>h(new sR({reason:e.reason}))),J_({module:`RpcClient`,method:`makeProtocolSocket`}),N_);let ee=e=>z(()=>{let t=u.encode(e);return t===void 0?V:Bg(c.write(t))});return{send(e,t){return p?H(p):(t._tag===`Interrupt`&&s.delete(t.requestId),t._tag===`Request`?(s.set(t.id,e),h_(ee(t),()=>B(()=>s.delete(t.id)))):ee(t))},supportsAck:!0,supportsTransferables:!1,codecFor:a.codecFor}})),HH=Bh([Hh(500,1.5),Gh(5e3)]),UH=W_(function*(e,t){let n=yield*qf,r=t?.pingInterval??`5 seconds`,i=fo(t?.pingTimeout??r),a=n.currentTimeMillisUnsafe(),o=!1,s=vv(),c=()=>{a=n.currentTimeMillisUnsafe(),o=!1};return yield*z(()=>o&&n.currentTimeMillisUnsafe()-a>i?s.open:(o=!0,e)).pipe(Xg(r),Gg,w_,b_,N_),{timeout:s.await,reset:()=>{c(),s.closeUnsafe()},onFrame:c}}),WH=e=>Xp(BH)(VH(e)),GH=class extends Ki()(`effect/rpc/RpcClient/ConnectionHooks`){},KH=()=>(e,t)=>{let n=Ki()(e),r=Xp(n,t.makeEffect??LH(t.group,{...t,flatten:!0}));n.runtime=(t.runtime??UI)(typeof t.protocol==`function`?e=>am(r,lm(t.protocol(e))):am(r,lm(t.protocol))),n.mutation=tL(r=>{let i=t.group.requests.get(r);return n.runtime.fn()(W_(function*({headers:e,payload:t,reactivityKeys:i}){let a=(yield*n)(r,t,{headers:e});return yield*i?zF(a,i):a})).pipe(dL({key:`AtomRpc:mutation:${JSON.stringify([e,r])}`,schema:PF({success:i.successSchema,error:qH(i)})}))});let i=tL(e=>{let{headers:r,payload:i,reactivityKeys:a,tag:o,timeToLive:s}=e,c=t.group.requests.get(o),l=KL(c.successSchema),u=l?n.runtime.pull(Ax(n.use(e=>R(e(o,i,{headers:r}))))):n.runtime.atom(n.use(e=>e(o,i,{headers:r})));return a&&(u=n.runtime.factory.withReactivity(a)(u)),!l&&e.serializationKey&&(u=dL(u,{key:`AtomRpc:${e.tag}:${e.serializationKey}`,schema:PF({success:c.successSchema,error:qH(c)})})),s&&(u=to(s)?CI(u,s):nL(u)),u});return n.query=(e,t,n)=>{let r={tag:e,payload:t,headers:n?.headers?DC(n.headers):void 0,reactivityKeys:n?.reactivityKeys,timeToLive:n?.timeToLive===void 0?void 0:Ga(n.timeToLive),serializationKey:n?.serializationKey};return i(r)},n},qH=e=>DA([e.errorSchema,...Array.from(e.middlewares,e=>e.error),sR]),JH={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return YH({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[e,n]of r.requests)t.set(e,n);for(let[e,t]of r.annotations.mapUnsafe)n.set(e,t)}return YH({requests:t,annotations:ia(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return YH({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return YH({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return bg(function*(){let n=yield*n_(),r=dg(e)?yield*e:e,i=new Map;return t.requests.forEach((e,t)=>{i.set(e.key,{tag:e._tag,handler:r[t],context:n})}),ia(i)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return YH({requests:t,annotations:this.annotations})},toLayer(e){return Qp(this.toHandlers(e))},of:i,toLayerHandler(e,t){let n=this;return Qp(bg(function*(){let r=yield*n_(),i=dg(t)?yield*t:t,a=new Map,o=n.requests.get(e);return a.set(o.key,{handler:i,context:r}),ia(a)}))},accessHandler(e){return r_(t=>{let n=this.requests.get(e),{handler:r,context:i}=ha(t,n.key);return R((e,t)=>{t.rpc=n;let a=r(e,t),o=iR(a)?a.value:a;return dg(o)?i_(o,i):Gx(o,i)})})},annotate(e,t){return YH({requests:this.requests,annotations:fa(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(da(e,t))},annotateMerge(e){return YH({requests:this.requests,annotations:xa(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(xa(e,r.annotations)));return YH({requests:t,annotations:this.annotations})}},YH=e=>Object.assign(function(){},JH,{requests:e.requests,annotations:e.annotations}),XH=(...e)=>YH({requests:new Map(e.map(e=>[e._tag,e])),annotations:la()}),ZH=`~effect/rpc/RpcMiddleware`,QH=()=>(e,t)=>{let n=Ft(),r;n!==0&&(It(2),r=new globalThis.Error,It(n));function i(){}let a=i;return Object.setPrototypeOf(i,Object.getPrototypeOf(Ki(e))),i.key=e,Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[ZH]=ZH,a.error=t?.error??lA,a.requiredForClient=t?.requiredForClient??!1,i},$H=`~effect/SynchronizedRef`,eU={...Jt,[$H]:$H,toJSON(){return{_id:`SynchronizedRef`,value:this.backing.ref.current}}},tU=e=>{let t=Object.create(eU);return t.semaphore=Zy(1),t.backing=hM(e),t},nU=e=>B(()=>tU(e)),rU=e=>e.backing.ref.current,iU=e=>B(()=>rU(e)),aU=r(2,(e,t)=>e.semaphore.withPermit(gM(e.backing,t))),oU=r(2,(e,t)=>e.semaphore.withPermit(z(()=>W(t(rU(e)),([t,n])=>(e.backing.ref.current=n,t))))),sU=r(2,(e,t)=>e.semaphore.withPermit(_M(e.backing,t)));export{wN as $,fr as $a,Sf as $i,vg as $n,Kh as $r,iE as $t,$F as A,Di as Aa,Tp as Ai,yx as An,U_ as Ar,xj as At,uF as B,wr as Ba,Qf as Bi,Xv as Bn,gg as Br,KA as Bt,aL as C,Vi as Ca,Gp as Ci,bx as Cn,jg as Cr,ZA as Ct,mL as D,li as Da,Dp as Di,Hx as Dn,F_ as Dr,Bk as Dt,pL as E,fi as Ea,Cp as Ei,kx as En,R_ as Er,yA as Et,DF as F,D as Fa,pp as Fi,ab as Fn,z as Fr,Qk as Ft,ZP as G,br as Ga,np as Gi,Tv as Gn,Eg as Gr,TA as Gt,vF as H,Sr as Ha,ip as Hi,Cv as Hn,S_ as Hr,rA as Ht,gF as I,Gr as Ia,lp as Ii,Kv as In,B as Ir,qk as It,gP as J,xr as Ja,Df as Ji,fg as Jn,ig as Jr,Tj as Jt,YP as K,Fr as Ka,Jf as Ki,iv as Kn,k_ as Kr,aA as Kt,yF as L,Ir as La,cp as Li,qv as Ln,Ag as Lr,Xk as Lt,kF as M,ti as Ma,dp as Mi,mx as Mn,u_ as Mr,RA as Mt,xF as N,ii as Na,vp as Ni,Ax as Nn,Zg as Nr,DA as Nt,jI as O,Ii as Oa,Ap as Oi,Bx as On,B_ as Or,pA as Ot,dF as P,Hr as Pa,fp as Pi,xb as Pn,R as Pr,Yk as Pt,AN as Q,Nr as Qa,Cf as Qi,v_ as Qn,Gh as Qr,ZT as Qt,mF as R,Pr as Ra,gp as Ri,Gv as Rn,Vg as Rr,Kk as Rt,UI as S,_i as Sa,om as Si,px as Sn,__ as Sr,CA as St,iL as T,Ni as Ta,tm as Ti,Mx as Tn,c_ as Tr,uj as Tt,CF as U,Dr as Ua,rp as Ui,Sv as Un,C_ as Ur,Vk as Ut,jF as V,Tr as Va,tp as Vi,Uv as Vn,wg as Vr,HA as Vt,nF as W,yr as Wa,Zf as Wi,wv as Wn,V as Wr,VA as Wt,VN as X,Cr as Xa,If as Xi,Ng as Xn,ug as Xr,oA as Xt,RN as Y,T as Ya,Ef as Yi,kg as Yn,ag as Yr,LA as Yt,zN as Z,E as Za,Lf as Zi,Pg as Zn,cg as Zr,PA as Zt,hL as _,Pi as _a,um as _i,vx as _n,K_ as _r,UA as _t,sU as a,Ki as aa,gh as ai,lE as an,v as ao,m_ as ar,fM as at,cL as b,bi as ba,rm as bi,G as bn,zg as br,cA as bt,KH as c,Ui as ca,fh as ci,cE as cn,me as co,xg as cr,Kj as ct,$L as d,Bi as da,_h as di,_w as dn,t as do,pg as dr,Nj as dt,wf as ea,lh as ei,nE as en,dr as eo,Ig as er,lN as et,RL as f,wi as fa,vh as fi,XS as fn,j_ as fr,Mj as ft,XI as g,Ei as ga,sh as gi,Px as gn,dg as gr,tj as gt,tL as h,Ti as ha,oh as hi,zx as hn,y_ as hr,hA as ht,oU as i,po as ia,ch as ii,$T as in,Ve as io,Cg as ir,dM as it,MF as j,Qr as ja,up as ji,Nx as jn,l_ as jr,IA as jt,tI as k,Ri as ka,wp as ki,Kx as kn,V_ as kr,vA as kt,WH as l,Oi as la,Sh as li,rE as ln,r as lo,U as lr,Gj as lt,fL as m,Fi as ma,uh as mi,JS as mn,bg as mr,SA as mt,nU as n,Pf as na,mh as ni,sE as nn,mr as no,Fg as nr,nN as nt,QH as o,fa as oa,bh as oi,tE as on,ue as oo,Mg as or,lM as ot,NL as p,Li as pa,dh as pi,QS as pn,P_ as pr,wA as pt,PP as q,Ar as qa,Yf as qi,f_ as qn,Tg as qr,iA as qt,aU as r,Bo as ra,hh as ri,YD as rn,Mt as ro,n_ as rr,pM as rt,XH as s,ba as sa,xh as si,aE as sn,he as so,H as sr,uM as st,iU as t,Nf as ta,yh as ti,eE as tn,pr as to,Lg as tr,xN as tt,MH as u,Hi as ua,ph as ui,$D as un,u as uo,W_ as ur,jj as ut,nL as v,ui as va,$p as vi,Wx as vn,G_ as vr,GA as vt,rL as w,xi as wa,cm as wi,jx as wn,a_ as wr,kA as wt,AI as x,hi as xa,am as xi,Dx as xn,yg as xr,OA as xt,NI as y,ki as ya,qp as yi,Lx as yn,W as yr,wj as yt,_F as z,jr as za,_p as zi,Jv as zn,qg as zr,YA as zt};