@deslop/auth 0.1.1268 → 0.1.1270

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.
@@ -1,17 +0,0 @@
1
- var e=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},t={pipe(){return e(this,arguments)}},n=function(){function e(){}return e.prototype=t,e}(),r=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},i=e=>e,a=e=>()=>e,o=a(!0),s=a(!1),c=a(void 0),l=c;function u(t,...n){return e(t,n)}function d(e,t,n,r,i,a,o,s,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return a(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return o(a(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return s(o(a(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(s(o(a(i(r(n(t(e.apply(this,arguments)))))))))}}}function f(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i}}function p(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i!==n&&t.set(i,i),i}}var m=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},h=new WeakSet,g=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),ee=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,_=e=>{try{return new Uint8Array(e)}catch{return}},te=0,ne=()=>{te++};function re(e){return typeof e==`string`}function ie(e){return typeof e==`number`}function ae(e){return typeof e==`boolean`}function oe(e){return typeof e==`symbol`}function se(e){return re(e)||ie(e)||oe(e)}function ce(e){return typeof e==`function`}function le(e){return e!==void 0}function ue(e){return e===null}function de(e){return e!=null}function fe(e){return!1}function pe(e){return!0}function me(e){return typeof e==`object`&&!!e}function he(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ge(e){return typeof e==`object`&&!!e||ce(e)}var v=r(2,(e,t)=>ge(e)&&t in e),_e=r(2,(e,t)=>v(e,`_tag`)&&e._tag===t);function ve(e){return e instanceof Error}function ye(e){return v(e,Symbol.iterator)||re(e)}var be=r(2,(e,t)=>n=>e(n)||t(n)),xe=`~effect/Hash`,y=e=>{switch(typeof e){case`number`:return Oe(e);case`bigint`:return ke(e.toString(10));case`string`:return ke(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?ke(`Invalid Date`):ke(e.toISOString());if(e instanceof RegExp)return ke(e.toString());{if(h.has(e))return Se(e);let t=Re.get(e);if(t!==void 0)return t;if(ze.has(e))return ne(),ke(`[Circular]`);ze.add(e);let n=te,r;try{if(Ee(e))r=e[xe]();else if(typeof e==`function`)r=Se(e);else if(ee(e)){let t=_(e);r=t===void 0?Se(e):Ne(t)}else r=e instanceof DataView?Ne(g(e)):Array.isArray(e)||ArrayBuffer.isView(e)?Ne(e):e instanceof Map?Pe(e):e instanceof Set?Ie(e):je(e)}finally{ze.delete(e)}return n===te&&Re.set(e,r),r}}return Te(Ce(ke(String(e))))},Se=e=>(Le.has(e)||Le.set(e,Te(Math.random()*4294967296|0)),Le.get(e)),Ce=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),we=r(2,(e,t)=>Ce(Math.imul(e,2654435761)+Math.imul(t,2246822507))),Te=e=>e&3221225471|e>>>1&1073741824,Ee=e=>v(e,`~effect/Hash`)&&typeof e[`~effect/Hash`]==`function`,De=new DataView(new ArrayBuffer(8)),Oe=e=>{let t=e|0;return t===e?Te(t):(De.setFloat64(0,e===e?e:NaN),Te(we(De.getInt32(0),De.getInt32(4))))},ke=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Te(t)},Ae=(e,t)=>{let n=12289;for(let r of t)n^=we(y(r),y(e[r]));return Te(n)},je=e=>Ae(e,m(e)),Me=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return Te(r)},Ne=e=>{let t=6151;for(let n of e)t=we(t,y(n));return Te(t)},Pe=Me(ke(`Map`),([e,t])=>we(y(e),y(t))),Fe=ke(`Set`),Ie=Me(Fe,e=>we(Fe,y(e))),Le=new WeakMap,Re=new WeakMap,ze=new WeakSet,Be=`~effect/Equal`;function Ve(){return arguments.length===1?e=>He(e,arguments[0]):He(arguments[0],arguments[1])}function He(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||h.has(e)||h.has(t)?!1:Ue(e,t):!1}function Ue(e,t){let n=Ge.length;for(let r=n;r-->0;)if(Ge[r]===e&&Ke[r]===t)return!0;if(n)return We(e,t);let r=qe.get(e);r||qe.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=We(e,t)),i}function We(e,t){Ge.push(e),Ke.push(t);try{return Je(e,t)}finally{Ge.pop(),Ke.pop()}}var Ge=[],Ke=[],qe=new WeakMap;function Je(e,t){if(y(e)!==y(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),r=t.getTime();return n===r||Number.isNaN(n)&&Number.isNaN(r)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let n=tt(e);if(n!==tt(t)||typeof e==`function`&&!n)return!1;if(n)return e[Be](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:Ye(e,t);if(ee(e)){if(!ee(t)||e instanceof ArrayBuffer!=t instanceof ArrayBuffer)return!1;let n=_(e),r=_(t);return n!==void 0&&r!==void 0&&Xe(n,r)}if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?Xe(g(e),g(t)):Xe(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:Qe(e,t,$e,et):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:Qe(e,t,y,He):Ze(e,t)}function Ye(e,t){for(let n=0;n<e.length;n++)if(!He(e[n],t[n]))return!1;return!0}function Xe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ze(e,t){let n=m(e),r=m(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!He(e[i],t[i]))return!1;return!0}function Qe(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop(),a--;continue outer}}return!1}return a===0}var $e=e=>y(e[0]),et=(e,t)=>He(e[0],t[0])&&He(e[1],t[1]),tt=e=>v(e,`~effect/Equal`)&&typeof e[`~effect/Equal`]==`function`,nt=()=>Ve,rt=e=>(t,n)=>t===n||e(t,n),it=(e,t)=>e===t,at=()=>it;function ot(e){return rt((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e[r](t[r],n[r]))return!1;return!0})}function st(e){return rt((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var ct=e=>e.length>0,lt=e=>e>0?Math.floor(e):0,ut=e=>Math.max(1,lt(e));function b(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function dt(e,t){if(!Object.hasOwn(t,`__proto__`))Object.assign(e,t);else for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&b(e,n,t[n])}var ft=Symbol.for(`~effect/Redactable`),pt=e=>v(e,ft);function mt(e){return pt(e)?ht(e):e}function ht(e){return e[ft](globalThis[`~effect/Fiber/currentFiber`]?.context??vt)}var gt=`~effect/Fiber/currentFiber`,_t=new Map,vt={"~effect/Context":{},base:_t,depth:0,mapUnsafe:_t,pipe(){return e(this,arguments)}};function x(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(e,n=0){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return yt;r.add(e);let l;if(ft in e)l=c(ht(e),n);else if(Array.isArray(e))l=!i||e.length<=1?`[${e.map(e=>c(e,n)).join(`,`)}]`:`[\n${a(n+1)}${e.map(e=>c(e,n+1)).join(`,
2
- `+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=St(e);else if(!t?.ignoreToString&&v(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=Ct(e);l=e instanceof Error&&e.cause!==void 0?`${t} (cause: ${c(e.cause,n)})`:t}else if(Symbol.iterator in e)l=`${e.constructor.name}(${c(Array.from(e),n)})`;else{let t=s(e);if(!i||t.length<=1){let r=`{${t.map(t=>`${bt(t)}:${c(wt(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${bt(t)}: ${c(wt(e,t),n+1)}`).join(`,
3
- `)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}var yt=`[Circular]`;function bt(e){return typeof e==`string`?JSON.stringify(e):String(e)}function xt(e){return e.map(e=>`[${bt(e)}]`).join(``)}function St(e){try{return e.toISOString()}catch{return`Invalid Date`}}function Ct(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function wt(e,t){try{return e[t]}catch{return`[property access threw]`}}function Tt(e,t){let n=[],r=new WeakMap;return JSON.stringify(e,function(e,t){let i=Object.getOwnPropertyDescriptor(r.get(this)??this,e)?.value,a=v(i,ft)?mt(i):mt(t);if(typeof a==`bigint`)return x(a);if(typeof a!=`object`||!a)return a;let o=a instanceof Error&&!v(a,`toJSON`)?{...a,name:a.name,message:a.message}:a;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(a))return;if(n.push(a),o!==a&&n.push(o),!Et(o)||Ot(o))return o;let s=Dt(o);return r.set(s,o),n.push(s),s},t?.space)??`null`}function Et(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function Dt(e){let t=Array.isArray(e)?[]:{},n=Array.isArray(e)?Array.from({length:e.length},(e,t)=>String(t)):Object.keys(e);for(let r of n)Object.defineProperty(t,r,{enumerable:!0,get:()=>{let t=Reflect.get(e,r);return Object.getOwnPropertyDescriptor(e,r)?.get===void 0?t:mt(t)}});return t}function Ot(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}var kt=Symbol.for(`nodejs.util.inspect.custom`),At=e=>{try{return e=mt(e),v(e,`toJSON`)&&ce(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(At):e}catch{return`[toJSON threw]`}},jt=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?Tt(e,{space:t}):x(e,{space:t})}catch{return String(e)}},Mt={toJSON(){return At(this)},[kt](){return this.toJSON()},toString(){return x(this.toJSON())}},Nt=class{[kt](){return this.toJSON()}toString(){return x(this.toJSON())}},Pt=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),Ft=()=>Error.stackTraceLimit,It=e=>{Pt&&(Error.stackTraceLimit=e)},Lt=class{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}},Rt=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}},r=Ft();if(r===0)return n[e];It(2);let i=t[e](()=>Error());return It(r),i.stack?.includes(e)===!0?t[e]:n[e]})(),zt=`~effect/Effect`,Bt=`~effect/Exit`,Vt={_A:i,_E:i,_R:i},Ht=`${zt}/identifier`,S=`${zt}/args`,Ut=`${zt}/evaluate`,Wt=`${zt}/successCont`,Gt=`${zt}/failureCont`,Kt=`${zt}/ensureCont`,qt=Symbol.for(`effect/Effect/Yield`),Jt={pipe(){return e(this,arguments)},toJSON(){return{...this}},toString(){return x(this.toJSON(),{ignoreToString:!0,space:2})},[kt](){return this.toJSON()}},Yt={[zt]:Vt,...Jt,[Symbol.iterator](){return new Lt(this)},toJSON(){return{_id:`Effect`,op:this[Ht],...`~effect/Effect/args`in this?{args:this[S]}:void 0}}},Xt=e=>v(e,zt),Zt=e=>v(e,Bt),Qt=`~effect/Cause`,$t=`~effect/Cause/Reason`,en=e=>v(e,Qt),tn=e=>v(e,$t),nn=class{constructor(e){this[Qt]=Qt,this.reasons=e}pipe(){return e(this,arguments)}toJSON(){return{_id:`Cause`,reasons:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${x(this.reasons)})`}[kt](){return this.toJSON()}[Be](e){return en(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>Ve(t,e.reasons[n]))}[xe](){return Ne(this.reasons)}},rn=new WeakMap,an=class{[$t];annotations;_tag;constructor(e,t,n){if(this[$t]=$t,this._tag=e,t!==on&&typeof n==`object`&&n&&t.size>0){let e=rn.get(n);e&&(t=new Map([...e,...t])),rn.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);if(e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)}),t?.overwrite!==!0&&n.size===this.annotations.size)return this;let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return e(this,arguments)}toString(){return x(this)}[kt](){return this.toString()}},on=new Map,sn=class extends an{constructor(e,t=on){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${x(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[Be](e){return _n(e)&&Ve(this.error,e.error)&&Ve(this.annotations,e.annotations)}[xe](){return we(ke(this._tag))(we(y(this.error))(y(this.annotations)))}},cn=e=>new nn(e),ln=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=y(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>Ve(e,i)))continue;else t.push(i);r.push(i)}return r},un=r(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new nn(ln(e.reasons,t.reasons));return Ve(e,n)?e:n}),dn=(e,t)=>{let n=e.reasons.slice();for(let e of t.reasons)yn(e)&&!n.some(t=>yn(t)&&t.fiberId===e.fiberId&&t.annotations===e.annotations)&&n.push(e);return n.length===e.reasons.length?e:new nn(n)},fn=new nn([]),pn=e=>new nn([new sn(e)]),mn=class extends an{constructor(e,t=on){super(`Die`,t,e),this.defect=e}toString(){return`Die(${x(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[Be](e){return vn(e)&&Ve(this.defect,e.defect)&&Ve(this.annotations,e.annotations)}[xe](){return we(ke(this._tag))(we(y(this.defect))(y(this.annotations)))}},hn=e=>new nn([new mn(e)]),gn=r(e=>en(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new nn(e.reasons.map(e=>e.annotate(t,n)))),_n=e=>e._tag===`Fail`,vn=e=>e._tag===`Die`,yn=e=>e._tag===`Interrupt`;function bn(e){return On(`Effect.evaluate: Not implemented`)}var xn=e=>({...Yt,[Ht]:e.op,[Ut]:e[`~effect/Effect/evaluate`]??bn,[Wt]:e[Wt],[Gt]:e[Gt],[Kt]:e[Kt]}),Sn=e=>{let t=xn(e),n=function(e){this[S]=e};return n.prototype=t,function(e){return new n(e)}},Cn=e=>{let t={[Bt]:Bt,_tag:e.op,get[e.prop](){return this[S]},...xn(e),toString(){return`${e.op}(${x(this[S])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[S]}},[Be](e){return Zt(e)&&e._tag===this._tag&&Ve(this[`~effect/Effect/args`],e[`~effect/Effect/args`])},[xe](){return we(ke(e.op),y(this[S]))}},n=function(e){this[S]=e};return n.prototype=t,function(e){return new n(e)}},C=Cn({op:`Success`,prop:`value`,[Ut](e){let t=e.getCont(Wt);return t?t[Wt](this[S],e,this):e.yieldWith(this)}}),wn={key:`effect/Cause/StackTrace`},Tn={key:`effect/Cause/InterruptorStackTrace`},En=Cn({op:`Failure`,prop:`cause`,[Ut](e){let t=this[S],n=!1;e.cache.stackFrame&&(t=gn(t,{mapUnsafe:new Map([[wn.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(Gt),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;r&&e.interruptible;)a||=Ht in r,r=e.getCont(Gt);a&&(t=cn(t.reasons.filter(e=>e._tag!==`Fail`))),t=dn(t,i),n=!0}return r?r[Gt](t,e,n?void 0:this):e.yieldWith(n?En(t):this)}}),Dn=e=>En(pn(e)),On=e=>En(hn(e)),w=Sn({op:`WithFiber`,[Ut](e){return this[S](e)}}),kn=function(){class e extends globalThis.Error{}let t=xn({op:`YieldableError`,[Ut](){return Dn(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),An=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends kn{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(dt(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),jn=e=>{class t extends An{_tag=e}return t.prototype.name=e,t},Mn=`~effect/Cause/NoSuchElementError`,Nn=class extends jn(`NoSuchElementError`){[Mn]=Mn;constructor(e){super({message:e})}},Pn=`~effect/Cause/Done`,Fn=e=>v(e,Pn),In={[Pn]:Pn,_tag:`Done`,value:void 0},Ln=e=>e===void 0?In:{[Pn]:Pn,_tag:`Done`,value:e},Rn=Dn(In),zn=e=>e===void 0?Rn:Dn(Ln(e)),Bn=`~effect/Option`,Vn={[Bn]:{_A:e=>e},...Jt,[Symbol.iterator](){return new Lt(this)}},Hn=Object.defineProperty(Object.assign(Object.create(Vn),{_tag:`Some`,_op:`Some`,[Be](e){return Gn(e)&&qn(e)&&Ve(this.value,e.value)},[xe](){return we(y(this._tag))(y(this.value))},toString(){return`some(${x(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:At(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),Un=y(`None`),Wn=Object.assign(Object.create(Vn),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[Be](e){return Gn(e)&&Kn(e)},[xe](){return Un},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),Gn=e=>v(e,Bn),Kn=e=>e._tag===`None`,qn=e=>e._tag===`Some`,Jn=Object.create(Wn),Yn=function(e){this.value=e};Yn.prototype=Hn;var Xn=e=>new Yn(e),Zn=`~effect/Result`,Qn={[Zn]:{_A:e=>e,_E:e=>e},...Jt,[Symbol.iterator](){return new Lt(this)}},$n=Object.assign(Object.create(Qn),{_tag:`Success`,_op:`Success`,[Be](e){return tr(e)&&rr(e)&&Ve(this.success,e.success)},[xe](){return we(y(this._tag))(y(this.success))},toString(){return`success(${x(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:At(this.success)}}}),er=Object.assign(Object.create(Qn),{_tag:`Failure`,_op:`Failure`,[Be](e){return tr(e)&&nr(e)&&Ve(this.failure,e.failure)},[xe](){return we(y(this._tag))(y(this.failure))},toString(){return`failure(${x(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:At(this.failure)}}}),tr=e=>v(e,Zn),nr=e=>e._tag===`Failure`,rr=e=>e._tag===`Success`,ir=function(e){this.failure=e};ir.prototype=er;var ar=e=>new ir(e),or=function(e){this.success=e};or.prototype=$n;var sr=e=>new or(e),cr=e=>nr(e)?Jn:Xn(e.success);function lr(e){return(t,n)=>t===n?0:e(t,n)}var ur=lr((e,t)=>e<t?-1:1),dr=lr((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),fr=lr((e,t)=>e<t?-1:1);function pr(e){return lr((t,n)=>e(n,t))}var mr=r(2,(e,t)=>lr((n,r)=>e(t(n),t(r)))),hr=e=>r(2,(t,n)=>e(t,n)===1),gr=e=>r(2,(t,n)=>t===n||e(t,n)<1?t:n),_r=e=>r(2,(t,n)=>t===n||e(t,n)>-1?t:n),T=()=>Jn,E=Xn,vr=Gn,yr=Kn,br=qn,xr=r(2,(e,{onNone:t,onSome:n})=>yr(e)?t():n(e.value)),Sr=r(2,(e,t)=>yr(e)?t():e.value),Cr=r(2,(e,t)=>yr(e)?t():e),wr=e=>e==null?T():E(e),Tr=e=>e===void 0?T():E(e),Er=e=>e===null?T():E(e),Dr=Sr(c),Or=e=>(...t)=>{try{return E(e(...t))}catch{return T()}},kr=r(2,(e,t)=>{if(br(e))return e.value;throw t()}),Ar=r(2,(e,t)=>yr(e)?T():E(t(e.value))),jr=r(2,(e,t)=>yr(e)?T():t(e.value)),Mr=r(2,(e,t)=>yr(e)?T():wr(t(e.value))),Nr=jr(i),Pr=e=>yr(e)?[]:[e.value],Fr=r(2,(e,t)=>yr(e)?T():t(e.value)?E(e.value):T()),Ir=r(2,(e,t)=>t(e)?E(e):T()),Lr=(e=>r(2,(t,n)=>!yr(t)&&e(t.value,n)))(nt()),Rr=r(2,(e,t)=>!yr(e)&&t(e.value)),zr=sr,Br=ar,Vr=e=>{if(ce(e))try{return zr(e())}catch(e){return Br(e)}try{return zr(e.try())}catch(t){return Br(e.catch(t))}},Hr=tr,D=nr,Ur=rr,Wr=cr,Gr=r(2,(e,t)=>D(e)?Br(t(e.failure)):e),Kr=r(2,(e,t)=>Ur(e)?zr(t(e.success)):e),qr=r(2,(e,{onFailure:t,onSuccess:n})=>D(e)?t(e.failure):n(e.success)),Jr=ot,Yr=e=>{let t=e[Symbol.iterator]().next();if(t.done)throw Error(`headUnsafe: empty iterable`);return t.value},Xr=r(2,(e,t)=>{let n=0;for(let r of e){let e=t(r,n);if(ae(e)){if(e)return E(r)}else if(br(e))return e;n++}return T()}),Zr={[Symbol.iterator](){return Qr}},Qr={next(){return{done:!0,value:void 0}}},$r=()=>Zr,ei=r(2,(e,t)=>{let n=[];for(let r of ii(e))n.push(t(r,e[r]));return n}),ti=r(2,(e,t)=>Object.hasOwn(e,t)),ni=r(2,(e,t)=>Object.hasOwn(e,t)?E(e[t]):T()),ri=r(2,(e,t)=>{let n={...e};for(let r of ii(e))b(n,r,t(e[r],r));return n}),ii=e=>Object.keys(e),ai=e=>ei(e,(e,t)=>t),oi=e=>r(2,(t,n)=>{for(let r of ii(t))if(!ti(n,r)||!e(t[r],n[r]))return!1;return!0}),si=e=>{let t=oi(e);return(e,n)=>t(e,n)&&t(n,e)},ci=globalThis.Array,li=r(2,(e,t)=>{let n=ut(e),r=new ci(n);for(let e=0;e<n;e++)r[e]=t(e);return r}),ui=(e,t)=>e<=t?li(t-e+1,t=>e+t):[e],di=e=>ci.isArray(e)?e:ci.from(e),fi=e=>ci.isArray(e)?e:[e],pi=r(2,(e,{onEmpty:t,onNonEmpty:n})=>vi(e)?n(e):t()),mi=r(2,(e,t)=>[...e,t]),hi=r(2,(e,t)=>di(e).concat(di(t)));ci.isArray;var gi=e=>e.length===0,_i=ct,vi=ct;function yi(e){let t=Number(e);return String(t)===e&&Number.isInteger(t)&&t>=0&&t<2**32-1}function bi(e,t){return!Number.isFinite(e)||e<0||e>=t.length}var xi=r(2,(e,t)=>{let n=Math.floor(t);return bi(n,e)?T():E(e[n])})(0),Si=e=>vi(e)?E(Ci(e)):T(),Ci=e=>e[e.length-1],wi=Xr,Ti=r(2,(e,t)=>{let n=di(e);for(let e=n.length-1;e>=0;e--){let r=n[e],i=t(r,e);if(typeof i==`boolean`){if(i)return E(r)}else if(br(i))return i}return T()}),Ei=r(2,(e,t)=>{let n=ci.from(e);return n.sort(t),n}),Di=(e=>r(2,(t,n)=>{for(let r of t)if(e(n,r))return!0;return!1}))(nt()),Oi=r(2,(e,t)=>{let n={};for(let r of e){let e=t(r);Object.hasOwn(n,e)?n[e].push(r):b(n,e,[r])}return n}),ki=()=>[],Ai=e=>[e],ji=r(2,(e,t)=>e.map(t)),Mi=r(2,(e,t)=>{if(gi(e))return[];let n=[];for(let r=0;r<e.length;r++){let i=t(e[r],r);for(let e=0;e<i.length;e++)n.push(i[e])}return n}),Ni=r(2,(e,t)=>{let n=di(e),r=[];for(let e=0;e<n.length;e++)t(n[e],e)&&r.push(n[e]);return r}),Pi=r(3,(e,t,n)=>di(e).reduce((e,t,r)=>n(e,t,r),t)),Fi=r(2,(e,t)=>e.every(t)),Ii=st,Li=r(2,(e,t)=>di(e).join(t));globalThis.Boolean;var Ri=r(2,(e,t)=>e?t.onTrue():t.onFalse()),zi=e=>xn({op:e.label,[Ut]:e.evaluate}),Bi=`~effect/Context/Service`,Vi=function(){function e(){}let t=e;Object.setPrototypeOf(t,Hi);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[Wi]=Wi,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&Ui.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},Hi={[Bi]:Bi,...zi({label:`Service`,evaluate(e){return C(O(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return oa(this,e)},use(e){return w(t=>e(O(t.context,this)))},useSync(e){return w(t=>C(e(O(t.context,this))))}},Ui=new Set,Wi=`~effect/Context/Reference`,Gi=`~effect/Context`,Ki=8,qi=(e,t,n,r,i)=>{let a=Object.create(ea);return a.cacheRoot=e??a,a.base=t,a.overlay=n,a.depth=r,a._flat=void 0,a.baseHits=0,a.maxDepth=i,a},Ji=(e,t)=>{t&&(Ji(e,t.parent),e.set(t.key,t.value))},Yi=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return Ji(t,e.overlay),e._flat=t},Xi=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),qi(void 0,n,void 0,0,e.maxDepth)},Zi=Symbol(),Qi=(e,t)=>{let n=e;for(let e=n.overlay;e;e=e.parent)if(e.key===t)return e.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Zi:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=Ki&&(n.base=Yi(n),n.overlay=void 0,n.depth=0),r)},$i=(e,t)=>{let n=t?.maxDepth;return qi(void 0,e,void 0,0,Number.isInteger(n)&&n>=0?n:8)},ea={get mapUnsafe(){return Yi(this)},...Jt,[Gi]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[Be](e){if(!na(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[e,r]of t)if(!n.has(e)||!Ve(r,n.get(e)))return!1;return!0},[xe](){return Oe(this.mapUnsafe.size)}},ta=(e,t)=>e.cacheRoot===t.cacheRoot,na=e=>v(e,Gi),ra=e=>!!e[Wi],ia=()=>aa,aa=$i(new Map),oa=(e,t)=>$i(new Map([[e.key,t]])),sa=r(3,(e,t,n)=>ca(e,t.key,n)),ca=(e,t,n)=>{let r=e,i=Ui.has(t)?void 0:r.cacheRoot;if(r.depth>=r.maxDepth){let e=new Map(r._flat??r.base);return r._flat||Ji(e,r.overlay),e.set(t,n),qi(i,e,void 0,0,r.maxDepth)}return qi(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1,r.maxDepth)},la=r(2,(e,t)=>ua(e,t.key)),ua=(e,t)=>{let n=Qi(e,t);return n===Zi?void 0:n},da=r(2,(e,t)=>{let n=Qi(e,t.key);if(n===Zi){if(ra(t))return pa(t);throw ma(t)}return n}),O=da,fa=`~effect/Context/defaultValue`,pa=e=>fa in e?e[fa]:e[fa]=e.defaultValue(),ma=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
4
- `);e.splice(1,3),t.stack=e.join(`
5
- `)}return t},ha=r(2,(e,t)=>{let n=Qi(e,t.key);return n===Zi?ra(t)?E(pa(t)):T():E(n)}),ga=r(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:Xi(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),_a=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return $i(t)},k=Vi,va=`~effect/Duration`,ya=BigInt(0),ba=BigInt(1),xa=BigInt(2),Sa=BigInt(10),Ca=BigInt(24),wa=BigInt(60),Ta=BigInt(1e3),Ea=BigInt(1e6),Da=BigInt(1e9),Oa=BigInt(6e10),ka=BigInt(36e11),Aa=BigInt(864e11),ja=BigInt(6048e11),Ma=e=>BigInt(Math.sign(e)*Math.round(Math.abs(e))),Na=e=>Number.isInteger(e)?BigInt(e)*Ea:Ma(e*1e6),Pa=e=>Ja(Number.isFinite(e)?Ma(e):e),Fa=(e,t)=>{let n=Number(e);if(Number.isFinite(n))return n/t;let r=BigInt(t);return Number(e/r)+Number(e%r)/t},Ia=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=Sa**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t;return La(r?-o:o,a)},La=(e,t)=>{let n=e<ya?-e:e,r=n/t+(n%t*xa>=t?ba:ya);return e<ya?-r:r},Ra=(e,t)=>{let n=Number(e)*t;if(!Number.isFinite(n))return Ja(n);let r=Ia(e,BigInt(t)*Ea);return Ja(Number.isInteger(n)&&BigInt(n)*Ea===r?n:r)},za=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,Ba=e=>{switch(typeof e){case`number`:return io(e);case`bigint`:return ro(e);case`string`:{if(e===`Infinity`)return to;if(e===`-Infinity`)return no;let t=za.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return ro(Ia(r,ba));if(i===`micro`||i===`micros`)return ro(Ia(r,Ta));switch(i){case`milli`:case`millis`:return Ra(r,1);case`second`:case`seconds`:return Ra(r,1e3);case`minute`:case`minutes`:return Ra(r,6e4);case`hour`:case`hours`:return Ra(r,36e5);case`day`:case`days`:return Ra(r,864e5);case`week`:case`weeks`:return Ra(r,6048e5)}break}case`object`:{if(e===null)break;if(va in e)return e;if(Array.isArray(e)){if(e.length!==2||!e.every(ie))return Ua(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return eo;if(e[0]===-1/0||e[1]===-1/0)return no;if(e[0]===1/0||e[1]===1/0)return to;let t=e[0]*1e9+e[1];return Number.isFinite(t)&&Number.isInteger(e[0])&&Number.isInteger(e[1])?Ja(BigInt(e[0])*Da+BigInt(e[1])):Pa(t)}let t=e,n=0;if(t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds){if(!Number.isFinite(n))return Ja(n);let e=Ha(t);return e===void 0||BigInt(n)*Ea===e?Ja(n):Ja(e)}let r=n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0),i=Number.isFinite(r)?Ha(t):void 0;return i===void 0?Pa(r):Ja(i)}}return Ua(e)},Va=e=>!e||Number.isInteger(e),Ha=e=>{if(!Va(e.weeks)||!Va(e.days)||!Va(e.hours)||!Va(e.minutes)||!Va(e.seconds)||!Va(e.milliseconds)||!Va(e.microseconds)||!Va(e.nanoseconds))return;let t=ya;return e.weeks&&(t+=BigInt(e.weeks)*ja),e.days&&(t+=BigInt(e.days)*Aa),e.hours&&(t+=BigInt(e.hours)*ka),e.minutes&&(t+=BigInt(e.minutes)*Oa),e.seconds&&(t+=BigInt(e.seconds)*Da),e.milliseconds&&(t+=BigInt(e.milliseconds)*Ea),e.microseconds&&(t+=BigInt(e.microseconds)*Ta),e.nanoseconds&&(t+=BigInt(e.nanoseconds)),t},Ua=e=>{throw Error(`Invalid Input: ${e}`)},Wa={_tag:`Millis`,millis:0},Ga={_tag:`Infinity`},Ka={_tag:`NegativeInfinity`},qa={[va]:va,[xe](){switch(this.value._tag){case`Millis`:return y(Na(this.value.millis));case`Nanos`:return y(this.value.nanos);default:return je(this.value)}},[Be](e){return Ya(e)&&_o(this,e)},toString(){switch(this.value._tag){case`Infinity`:return`Infinity`;case`NegativeInfinity`:return`-Infinity`;case`Nanos`:return`${this.value.nanos} nanos`;case`Millis`:return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,nanos:String(this.value.nanos)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`};case`NegativeInfinity`:return{_id:`Duration`,_tag:`NegativeInfinity`}}},[kt](){return this.toJSON()},pipe(){return e(this,arguments)}},Ja=e=>{let t=Object.create(qa);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?Wa:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:Na(e)}:e>0?Ga:Ka:e===ya?Wa:{_tag:`Nanos`,nanos:e},t},Ya=e=>v(e,va),Xa=e=>e.value._tag!==`Infinity`&&e.value._tag!==`NegativeInfinity`,Za=e=>{switch(e.value._tag){case`Millis`:return e.value.millis===0;case`Nanos`:return e.value.nanos===ya;case`Infinity`:case`NegativeInfinity`:return!1}},Qa=e=>{switch(e.value._tag){case`Millis`:return e.value.millis<0;case`Nanos`:return e.value.nanos<ya;case`NegativeInfinity`:return!0;case`Infinity`:return!1}},$a=e=>{switch(e.value._tag){case`Infinity`:case`NegativeInfinity`:return to;case`Millis`:return e.value.millis<0?Ja(-e.value.millis):e;case`Nanos`:return e.value.nanos<ya?Ja(-e.value.nanos):e}},eo=Ja(0),to=Ja(1/0),no=Ja(-1/0),ro=e=>Ja(e),io=e=>Ja(e),ao=e=>Ja(e*1e3),oo=e=>lo(Ba(e),{onMillis:i,onNanos:e=>Fa(e,1e6),onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),so=e=>lo(Ba(e),{onMillis:e=>e/6e4,onNanos:e=>Fa(e,6e10),onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),co=e=>{let t=Ba(e);switch(t.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return Na(t.value.millis)}},lo=r(2,(e,t)=>{switch(e.value._tag){case`Millis`:return t.onMillis(e.value.millis);case`Nanos`:return t.onNanos(e.value.nanos);case`Infinity`:return t.onInfinity();case`NegativeInfinity`:return(t.onNegativeInfinity??t.onInfinity)()}}),uo=r(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(co(e),t.value.nanos):n.onNanos(e.value.nanos,co(t))),fo=lr((e,t)=>uo(e,t,{onMillis:(e,t)=>e<t?-1:+(e>t),onNanos:(e,t)=>e<t?-1:+(e>t),onInfinity:(e,t)=>e.value._tag===t.value._tag?0:e.value._tag===`Infinity`?1:e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`?-1:1})),po=(e,t)=>uo(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),mo=gr(fo),ho=_r(fo),go=r(2,(e,t)=>uo(e,t,{onMillis:(e,t)=>Ja(e+t),onNanos:(e,t)=>Ja(e+t),onInfinity:(e,t)=>{let n=e.value._tag,r=t.value._tag;return n===`Infinity`&&r===`NegativeInfinity`||n===`NegativeInfinity`&&r===`Infinity`?eo:n===`Infinity`||r===`Infinity`?to:n===`NegativeInfinity`||r===`NegativeInfinity`?no:eo}})),_o=r(2,(e,t)=>po(e,t)),vo=e=>{if(e.value._tag===`Infinity`)return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};if(e.value._tag===`NegativeInfinity`)return{days:-1/0,hours:-1/0,minutes:-1/0,seconds:-1/0,millis:-1/0,nanos:-1/0};let t=co(e),n=t<ya,r=n?-t:t,i=r/Ea,a=i/Ta,o=a/wa,s=o/wa,c=s/Ca,l=n?-1:1;return{days:l*Number(c),hours:l*Number(s%Ca),minutes:l*Number(o%wa),seconds:l*Number(a%wa),millis:l*Number(i%Ta),nanos:l*Number(r%Ea)}},yo=e=>{if(e.value._tag===`Infinity`)return`Infinity`;if(e.value._tag===`NegativeInfinity`)return`-Infinity`;if(Za(e))return`0`;if(Qa(e))return`-`+yo($a(e));let t=vo(e),n=[];return t.days!==0&&n.push(`${t.days}d`),t.hours!==0&&n.push(`${t.hours}h`),t.minutes!==0&&n.push(`${t.minutes}m`),t.seconds!==0&&n.push(`${t.seconds}s`),t.millis!==0&&n.push(`${t.millis}ms`),t.nanos!==0&&n.push(`${t.nanos}ns`),n.join(` `)},bo=e=>t=>!D(e(t)),xo=e=>t=>t.has(e)?zr(t):Br(t),So=r(2,(e,t)=>n=>{let r=e(n);return D(r)?r:t(r.success)}),Co=e=>t=>{let n=e(t);return D(n)?T():E(n.success)},wo=k(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new ko}),To=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},Eo=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},Do=e=>{try{return Eo(e)}catch{return To(e)}},Oo=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},ko=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?To:Do)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new Ao(this.setImmediate)}},Ao=class{tasks=new Oo;running=void 0;setImmediate;constructor(e=Do){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},jo=k(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),Mo=k(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),No=class extends n{constructor(e){super(),e&&dt(this,e)}},Po=An,Fo=jn,Io=`~effect/encoding/EncodingError`,Lo=class extends Fo(`EncodingError`){[Io]=Io},Ro=e=>{switch(e){case 16:return Vo();case 32:return Ho();default:{let t=``;for(let n=e>>>3;n>0;n--)t+=Bo();return t}}},A=Uint8Array.from(`0123456789abcdef`,e=>e.charCodeAt(0)),zo=()=>Math.random()*4294967296>>>0,Bo=()=>{let e=zo();return String.fromCharCode(A[e>>>28],A[e>>>24&15],A[e>>>20&15],A[e>>>16&15],A[e>>>12&15],A[e>>>8&15],A[e>>>4&15],A[e&15])},Vo=()=>{let e=zo(),t=zo();return String.fromCharCode(A[e>>>28],A[e>>>24&15],A[e>>>20&15],A[e>>>16&15],A[e>>>12&15],A[e>>>8&15],A[e>>>4&15],A[e&15],A[t>>>28],A[t>>>24&15],A[t>>>20&15],A[t>>>16&15],A[t>>>12&15],A[t>>>8&15],A[t>>>4&15],A[t&15])},Ho=()=>{let e=zo(),t=zo(),n=zo(),r=zo();return String.fromCharCode(A[e>>>28],A[e>>>24&15],A[e>>>20&15],A[e>>>16&15],A[e>>>12&15],A[e>>>8&15],A[e>>>4&15],A[e&15],A[t>>>28],A[t>>>24&15],A[t>>>20&15],A[t>>>16&15],A[t>>>12&15],A[t>>>8&15],A[t>>>4&15],A[t&15],A[n>>>28],A[n>>>24&15],A[n>>>20&15],A[n>>>16&15],A[n>>>12&15],A[n>>>8&15],A[n>>>4&15],A[n&15],A[r>>>28],A[r>>>24&15],A[r>>>20&15],A[r>>>16&15],A[r>>>12&15],A[r>>>8&15],A[r>>>4&15],A[r&15])},Uo=`effect/Tracer/ParentSpan`,Wo=class extends Vi()(Uo,{fiberCached:!0}){},Go=e=>e,Ko=k(`effect/Tracer/DisablePropagation`,{defaultValue:s}),qo=k(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),Jo=k(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),Yo=`effect/Tracer`,Xo=k(Yo,{fiberCached:!0,defaultValue:()=>Zo}),Zo=Go({span:e=>new Qo(e)}),Qo=class{_tag=`Span`;sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:`Started`,startTime:e.startTime}}get traceId(){return this._traceId??=Dr(this.parent)?.traceId??Ro(32)}get spanId(){return this._spanId??=Ro(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){this.status._tag!==`Ended`&&(this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime})}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)}},$o=`effect/Metric/FiberRuntimeMetrics`,es=k(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:c}),ts=k(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:o}),ns=k(`effect/References/TracerTimingEnabled`,{defaultValue:o}),rs=k(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),is=k(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),as=k(`effect/References/CurrentLogAnnotations`,{defaultValue:()=>({})}),os=k(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),ss=k(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),cs=k(`effect/References/UnhandledLogLevel`,{defaultValue:()=>`Error`}),ls=k(`effect/References/CurrentLogSpans`,{defaultValue:()=>[]}),us=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=Ft();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};It(3);let n=Error();return It(t),{...e,captureStackTrace:ds(()=>n.stack)}},ds=(e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
6
- `);if(i[e]!==void 0)return n=i[e].trim(),n}})(3),fs=class extends an{constructor(e,t=on){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[Be](e){return yn(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[xe](){return ke(`${this._tag}:${this.fiberId}`)}},ps=e=>new fs(e),ms=e=>new nn([new fs(e)]),hs=e=>e.reasons.some(_n),gs=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return zr(n.error)}return Br(e)},_s=Co(gs),vs=e=>e.reasons.some(vn),ys=e=>vs(e)&&hs(e)?cn(e.reasons.map(e=>e._tag===`Fail`&&!Fn(e.error)?new mn(e.error,e.annotations):e)):e,bs=e=>vs(e)?Br(ys(e)):gs(e),xs=e=>e.reasons.some(yn),Ss=e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag===`Interrupt`&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?zr(t):Br(e)},Cs=e=>{let t=Ss(e);return D(t)?ws:t.success},ws=new Set,Ts=e=>e.reasons.length>0&&e.reasons.every(yn),Es=e=>$i(e.annotations),Ds=r(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>_n(e)?(n=!0,new sn(t(e.error),e.annotations)):e);return n?cn(r):e}),Os=e=>{let t;for(let n of e.reasons){if(n._tag===`Fail`)return n.error;n._tag===`Die`&&(t??=n)}return t===void 0?e.reasons.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`):t.defect},ks=(e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let i=Ft();i!==0&&It(1);try{for(let i of e.reasons)i._tag===`Interrupt`?r.push(i):n.push(As(i._tag===`Die`?i.defect:i.error,i.annotations,t));if(n.length===0){let e=Error(`The fiber was interrupted by:`);e.name=`InterruptCause`,e.stack=Fs(e,r);let i=new globalThis.Error(`All fibers interrupted without error`,{cause:e});i.name=`InterruptError`,i.stack=`${i.name}: ${i.message}`,n.push(As(i,r[0].annotations,t))}}finally{i!==0&&It(i)}return n},As=(e,t,n,r=new Set)=>{let i=typeof e,a;if(e&&i===`object`){r.add(e);let i=e.cause;if(a=new globalThis.Error(js(e),{cause:i!==void 0&&!r.has(i)?As(i,void 0,void 0,r):void 0}),typeof e.name==`string`&&(a.name=e.name),typeof e.stack==`string`)a.stack=Ns(e.stack,a,t);else{let e=`${a.name}: ${a.message}`;a.stack=t?Ps(e,t):e}n?.includeCauseInStack&&(a.stack=Rs(a));for(let t of Object.keys(e))t in a||(a[t]=e[t])}else{a=new globalThis.Error(e?i===`string`?e:Tt(e):`Unknown error: ${e}`);let n=`${a.name}: ${a.message}`;a.stack=t?Ps(n,t):n}return a},js=e=>{if(typeof e.message==`string`)return e.message;if(typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return Tt(e)},Ms=/\((.*)\)/g,Ns=(e,t,n)=>{let r=`${t.name}: ${t.message}`,i=(e.startsWith(r)?e.slice(r.length):e).split(`
7
- `),a=[r];for(let e=1;e<i.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(i[e]);e++)a.push(i[e]);return n?Ps(a.join(`
8
- `),n):a.join(`
9
- `)},Ps=(e,t)=>{let n=t?.get(wn.key);return n&&(e=`${e}\n${Is(n)}`),e},Fs=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let e of t){let t=e.fiberId===void 0?`unknown`:`#${e.fiberId}`,r=e.annotations.get(Tn.key);n.push(` at fiber (${t})`),r&&n.push(Is(r))}return n.join(`
10
- `)},Is=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(Ms),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
11
- `)},Ls=e=>ks(e).map(Rs).join(`
12
- `),Rs=e=>e.cause?`${e.stack} {\n${zs(e.cause,` `)}\n}`:e.stack,zs=(e,t)=>{let n=e.stack.split(`
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${zs(e.cause,`${t} `)}\n${t}}`),r},Bs=`~effect/Fiber`,Vs={_A:i,_E:i},Hs={id:0},Us=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),Ws=()=>Us===void 0?void 0:new Us(`effect/Fiber`),Gs=()=>globalThis[gt],Ks=class{constructor(e,t=!0){this.setContext(e),this.id=++Hs.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[Bs](){return Vs}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=ms(e);this.cache.stackFrame&&(n=gn(n,oa(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=Ws();return}let n=Xs.interruptChildren&&Xs.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=ia();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(cc,()=>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,Js;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&Ys-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&&ta(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=ua(e,Yo);return{scheduler:O(e,wo),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:O(e,ts),span:ua(e,Uo),logLevel:O(e,os),minimumLogLevel:O(e,ss),stackFrame:O(e,es),runtimeMetrics:ua(e,$o),maxOpsBeforeYield:O(e,jo),preventYield:O(e,Mo)}},Js={[Wt](e,t){return M(t._interruptedCause)},[Gt](e,t){return M(t._interruptedCause)}},Ys=32,Xs={interruptChildren:void 0},Zs=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Tn.key,e.cache.stackFrame),$i(t)},Qs=e=>{if(e._children!==void 0&&e._children.size!==0)return ac(e._children)},$s=e=>{let t=e;return t._exit?j(t._exit):_c(n=>t._exit?n(j(t._exit)):N(e.addObserver(e=>n(j(e)))))},ec=e=>_c(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?.())}),tc=e=>{let t=e;return t._exit?t._exit:_c(n=>t._exit?n(t._exit):N(e.addObserver(n)))},nc=e=>_c(t=>{let n=Array.from(e);if(n.length===0)return t(j(ki()));let r=Array(n.length),i=ki(),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()})}),rc=e=>w(t=>ic(e,t.id)),ic=r(e=>v(e[0],Bs),(e,t,n)=>w(r=>{let i=Zs(r);return i=i&&n?ga(i,n):i??n,e.interruptUnsafe(t,i),Bc($s(e))})),ac=e=>w(t=>{let n=Zs(t),r=ki();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return Bc(ec(r))}),j=C,M=En,oc=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()}}),sc=qr({onFailure:oc,onSuccess:j}),cc=Sn({op:`Yield`,[Ut](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(rl)},this[`~effect/Effect/args`]??0),e.yieldWith(()=>{t=!0})}})(0),lc=j(T()),uc=e=>P(()=>M(e())),dc=e=>On(e),F=j(void 0),fc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Qd(e,`An error occurred in Effect.try`):e.catch;return P(()=>{try{return j(t())}catch(e){return oc(n(e))}})},pc=e=>hc(function(t,n){e(n).then(e=>t(j(e)),e=>t(dc(e)))},e.length!==0),mc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Qd(e,`An error occurred in Effect.tryPromise`):e.catch;return hc(function(e,r){let i=e=>P(()=>{try{return oc(Rt(()=>n(e)))}catch(e){return dc(e)}});try{t(r).then(t=>e(j(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},hc=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(gc(()=>(t=!0,r?.abort(),i??rl))),qt):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),gc=Sn({op:`AsyncFinalizer`,[Kt](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Lu))},[Gt](e,t){return xs(e)?I(ou(En(e),this[S]()),()=>M(e)):M(e)}}),_c=e=>hc(e,e.length>=2),vc=_c(l),yc=(...e)=>{if(e.length===1){let t=e[0];return P(()=>Tc(t()))}let[t,n]=e;return P(()=>Tc(n.call(t.self)))},bc=(e,t)=>typeof e==`function`?e:t.shift().bind(e.self),xc=(e,...t)=>{let n=bc(e,t),r=t.length===0?function(){return P(()=>Tc(n.apply(this,arguments)))}:function(){let e=P(()=>Tc(n.apply(this,arguments)));for(let n=0;n<t.length;n++)e=t[n](e,...arguments);return e};return Sc(n.length,r)},Sc=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),Cc=(e,...t)=>{let n=bc(e,t);return Sc(n.length,t.length===0?function(){return wc(()=>n.apply(this,arguments))}:function(){let e=wc(()=>n.apply(this,arguments));for(let n of t)e=n(e,...arguments);return e})},wc=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=>Tc(t,e))):P(()=>Tc(e())))}}}}catch(e){return dc(e)}},Tc=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)}}(),Ec=r(2,(e,t)=>new kc(e,Ac,j(t))),Dc=function(e){return e._stack.push(this),this[S]},Oc=xn({op:`OnSuccess`,[Ut]:Dc}),kc=function(e,t,n){this[S]=e,this[Wt]=t,this.payload=n};kc.prototype=Oc;var Ac=function(){return this.payload},jc=function(e,t){return t.succeedWith(this.payload)},Mc=(()=>{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})(),Nc=function(e,t){let n=this.payload;return t.succeedWith(Mc?n(e):Rt(()=>n(e)))},Pc=function(e){let t=this.payload;return t(e)},Fc=function(e){let t=this.payload;return new kc(t(e),jc,e)},Ic=function(e){return new kc(this.payload,jc,e)},Lc=e=>qc(e,E),Rc=r(2,(e,t)=>new kc(e,Xt(t)?Ac:Pc,t)),zc=r(2,(e,t)=>new kc(e,Xt(t)?Ic:Fc,t)),Bc=e=>new kc(e,Ac,rl),Vc=(e,t)=>w(n=>{let r=new Set;return wu(n,()=>r.size===0?void 0:ac(r)),_c(i=>{let a=di(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(ys(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=$u(n,a[e],!0,!0,!1);if(r.add(t),t.addObserver(n=>{r.delete(t),u(n,t,e)}),c)break}})}),Hc=(e,t)=>w(n=>{let r=new Set;return wu(n,()=>r.size===0?void 0:ac(r)),_c(i=>{let a=!1,o=0;for(let s of e){if(a)break;let e=o++,c=$u(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})})}})}),Uc=r(e=>Xt(e[1]),(e,t,n)=>Vc([e,t],n)),Wc=r(e=>Xt(e[1]),(e,t,n)=>Hc([e,t],n)),I=r(2,(e,t)=>new kc(e,Pc,t)),L=e=>e[Bt]!==void 0,Gc=r(2,(e,t)=>L(e)?e._tag===`Success`?t(e.value):e:I(e,t)),Kc=e=>I(e,i),qc=r(2,(e,t)=>new kc(e,Nc,t)),Jc=r(2,(e,t)=>L(e)?il(e,t):qc(e,t)),Yc=r(2,(e,t)=>L(e)?al(e,t):jl(e,t)),Xc=r(2,(e,t)=>L(e)?ol(e,t):Ml(e,t)),Zc=r(2,(e,t)=>{if(L(e)){if(e._tag===`Success`)return e;let n=bs(e.cause);return D(n)?En(n.failure):t(n.success)}return Tl(e,t)}),Qc=e=>En(ms(e)),$c=e=>e._tag===`Success`,el=e=>e._tag===`Failure`,tl=e=>e._tag===`Failure`?zr(e.cause):Br(e),nl=e=>e._tag===`Failure`&&xs(e.cause),rl=C(void 0),il=r(2,(e,t)=>e._tag===`Success`?C(t(e.value)):e),al=r(2,(e,t)=>e._tag===`Success`?e:En(Ds(e.cause,t))),ol=r(2,(e,t)=>e._tag===`Success`?C(t.onSuccess(e.value)):En(Ds(e.cause,t.onFailure))),sl=r(2,(e,t)=>$c(e)?t:e),cl=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?rl:En(cn(t))},ll=e=>w(t=>j(ha(t.context,e))),ul=r(2,(e,t)=>w(n=>{let r=n.context,i=t(r);return r===i||(n.setContext(i),wu(n,()=>{n.setContext(r)})),e})),dl=r(3,(e,t,n)=>ul(e,e=>{let r=da(e,t),i=n(r);return r===i?e:sa(e,t,i)})),fl=()=>pl,pl=w(e=>j(e.context)),ml=e=>w(t=>e(t.context)),hl=r(2,(e,t)=>L(e)?e:ul(e,ga(t))),gl=function(){return arguments.length===1?r(2,(e,t)=>_l(e,arguments[0],t)):r(3,(e,t,n)=>_l(e,t,n)).apply(this,arguments)},_l=(e,t,n)=>ul(e,sa(t,n)),vl=r(2,(e,t)=>I(t,t=>t?Lc(e):lc)),yl=r(e=>Xt(e[0]),(e,t)=>Wu({while:o,body:a(t?.disableYield?e:I(e,e=>cc)),step:l})),bl=r(2,(e,t)=>new Sl(e,t.length===1?t:e=>t(e))),xl=xn({op:`OnFailure`,[Ut]:Dc}),Sl=function(e,t){this[S]=e,this[Gt]=t};Sl.prototype=xl;var Cl=r(3,(e,t,n)=>bl(e,e=>t(e)?n(e):M(e))),wl=r(3,(e,t,n)=>bl(e,e=>{let r=t(e);return D(r)?M(r.failure):n(r.success,e)})),Tl=r(2,(e,t)=>wl(e,bs,e=>t(e))),El=r(2,(e,t)=>bl(e,e=>Rc(t(e),M(e)))),Dl=r(3,(e,t,n)=>bl(e,e=>{let r=t(e);return D(r)?M(e):Rc(n(r.success,e),M(e))})),Ol=r(2,(e,t)=>Dl(e,gs,e=>t(e))),kl=r(e=>Xt(e[0]),(e,t,n,r)=>bl(e,e=>{let i=bs(e);return D(i)?M(i.failure):t(i.success)?n(i.success):r?r(i.success):M(e)})),Al=r(e=>Xt(e[0]),(e,t,n,r)=>kl(e,Array.isArray(t)?e=>v(e,`_tag`)&&t.includes(e._tag):_e(t),n,r)),jl=r(2,(e,t)=>bl(e,e=>M(Ds(e,t)))),Ml=r(2,(e,t)=>zl(e,{onFailure:e=>M(Ds(e,t.onFailure)),onSuccess:e=>N(()=>t.onSuccess(e))})),Nl=e=>Tl(e,dc),Pl=e=>e===`Unhandled`?(...e)=>w(t=>{let n=t.getRef(cs);return n===void 0?F:cf(n)(...e)}):cf(e===!0?void 0:e),Fl=r(e=>Xt(e[0]),(e,t)=>{if(!t?.log)return Wl(e,{onFailure:e=>F,onSuccess:e=>F});let n=Pl(t.log);return zl(e,{onFailure(e){let r=bs(e);return D(r)?M(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>F})}),Il=r(e=>Xt(e[0]),(e,t)=>{if(!t?.log)return zl(e,{onFailure:e=>F,onSuccess:e=>F});let n=Pl(t.log);return zl(e,{onFailure:e=>t.message===void 0?n(e):n(t.message,e),onSuccess:e=>F})}),Ll=e=>Gl(e,{onFailure:T,onSuccess:E}),Rl=e=>Kl(e,{onFailure:Br,onSuccess:zr}),zl=r(2,(e,t)=>new Vl(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),Bl=xn({op:`OnSuccessAndFailure`,[Ut]:Dc}),Vl=function(e,t,n){this[S]=e,this[Wt]=t,this[Gt]=n};Vl.prototype=Bl;var Hl=function(e,t){let n=this.payload;return t.succeedWith(Mc?n.onSuccess(e):Rt(()=>n.onSuccess(e)))},Ul=((e,t)=>{let n=xn({op:e,[Ut]:Dc,[Wt]:Hl,[Gt]:t}),r=function(e,t){this[S]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=bs(e);if(D(n))return M(n.failure);let r=this.payload;return t.succeedWith(Mc?r.onFailure(n.success):Rt(()=>r.onFailure(n.success)))}),Wl=r(2,(e,t)=>zl(e,{onFailure:e=>{let n=bs(e);return D(n)?M(n.failure):t.onFailure(n.success)},onSuccess:t.onSuccess})),Gl=r(2,(e,t)=>new Ul(e,t)),Kl=r(2,(e,t)=>{if(L(e)){if(e._tag===`Success`)return C(t.onSuccess(e.value));let n=bs(e.cause);return D(n)?En(n.failure):C(t.onFailure(n.success))}return Gl(e,t)}),ql=e=>L(e)?C(e):Jl(e),Jl=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))}}),Yl=r(2,(e,t)=>Rc(Vd(t),e)),Xl=r(2,(e,t)=>I($l(e,t.duration),e=>yr(e)?t.orElse():j(e.value))),Zl=e=>new Kd(`Operation timed out after '${yo(e)}'`),Ql=r(2,(e,t)=>{let n=Ba(t);return Xl(e,{duration:n,orElse:()=>oc(Zl(n))})}),$l=r(2,(e,t)=>Wc(Lc(e),Ec(Vd(t),T()))),eu=`~effect/Scope`,tu=`~effect/Scope/Closeable`,nu=Vi(`effect/Scope`),ru=(e,t)=>w(n=>(Bu(n),iu(e,t)??F)),iu=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&fu(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return au(n.finalizer,t);let r=n.finalizers;return r.size===1?au(r.values().next().value,t):su(e,r,t)},au=(e,t)=>{try{return e(t)}catch(e){return On(e)}},ou=(e,t)=>$c(e)?t:bl(t,t=>M(ys(un(e.cause,t)))),su=xc(function*(e,t,n){let r=[],i=[],a=Array.from(t),o=Gs();for(let t=a.length-1;t>=0;t--){let[s,c]=a[t];e.strategy===`sequential`?r.push(yield*ql(au(c,n))):s!==o&&i.push($u(o,au(c,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*ec(i)),yield*cl(r)}),cu=(e,t)=>{let n=mu(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(du(e,n,e=>ru(n,e)),n)},lu=(e,t)=>P(()=>e.state._tag===`Closed`?t(e.state.exit):(du(e,{},t),F)),uu=(e,t)=>lu(e,a(t)),du=(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)}},fu=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=hu:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=hu))},pu=e=>mu(e,void 0),mu=(e=`sequential`,t)=>({[tu]:tu,[eu]:eu,strategy:e,parent:t,state:hu}),hu={_tag:`Empty`},gu=nu,_u=gl(nu),vu=e=>w(t=>{let n=t.context,r=pu();return t.setContext(sa(t.context,nu,r)),wu(t,e=>(t.setContext(n),iu(r,e))),e}),yu=e=>P(()=>{let t=pu();return Tu(e(t),e=>P(()=>iu(t,e)??F))}),bu=(e,t,n)=>ml(r=>Hu(i=>I(gu,a=>zc(n?.interruptible?i(e):e,e=>lu(a,n=>hl(t(e,n),r)))))),xu=e=>I(gu,t=>ml(n=>lu(t,t=>hl(e(t),n)))),Su=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(Lu),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(ou(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),Cu=(e,t,n)=>new Su(e,t,n),wu=(e,t)=>{e._stack.push(new Su(void 0,t,void 0))},Tu=r(2,Cu),Eu=r(2,(e,t)=>Tu(e,e=>t)),Du=r(3,(e,t,n)=>Tu(e,e=>{let r=t(e);return D(r)?F:n(r.success,e)})),Ou=r(2,(e,t)=>Du(e,tl,t)),ku=r(3,(e,t,n)=>Tu(e,e=>{if(e._tag!==`Failure`)return F;let r=t(e.cause);return D(r)?F:n(r.success,e.cause)})),Au=r(2,(e,t)=>ku(Ss,t)(e)),ju=a(1/0),Mu=(e,t)=>{let n=0,r,i,a=(e,t)=>(t.awaiters++,wu(e,()=>{if(!(--t.awaiters>0||t.done))return i===t&&(i=void 0),rc(t.fiber)}),tc(t.fiber));return[w(o=>{if(i!==void 0)return o===i.fiber?tc(i.fiber):a(o,i);if(r!==void 0&&(n===1/0||o.getRef(Pd).currentTimeMillisUnsafe()<n))return r;r=void 0;let s=o.getRef(Pd),c={fiber:new Ks(o.context),awaiters:0,done:!1};i=c;let l=a(o,c);return c.fiber.evaluate(Cu(e,e=>{if(c.done=!0,i!==c||(i=void 0,nl(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})]},Nu=e=>N(()=>Mu(e,ju)[0]),Pu=w(e=>M(ms(e.id))),Fu=e=>w(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(Lu)),e)),Iu=Sn({op:`SetInterruptible`,[Kt](e){if(e.interruptible=this[S],e._interruptedCause&&e.interruptible)return()=>M(e._interruptedCause)}}),Lu=Iu(!0),Ru=Iu(!1),zu=e=>{if(e.interruptible=!0,e._stack.push(Ru),e._interruptedCause)return M(e._interruptedCause)},Bu=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(Lu))},Vu=e=>w(t=>t.interruptible?e:zu(t)??e),Hu=e=>w(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Lu),e(Vu)):e(i)),Uu=(e,t)=>ye(e)?t?.mode===`result`?Gu(e,Rl,t):Gu(e,i,t):t?.discard?t.mode===`result`?Gu(Object.values(e),Rl,t):Gu(Object.values(e),i,t):P(()=>qc(Gu(Object.entries(e),([e,n])=>qc(t?.mode===`result`?Rl(n):n,t=>[e,t]),{concurrency:t?.concurrency}),Object.fromEntries)),Wu=Sn({op:`While`,[Wt](e,t){return this[S].step(e),this[`~effect/Effect/args`].while()?(t._stack.push(this),this[S].body()):rl},[Ut](e){return this[`~effect/Effect/args`].while()?(e._stack.push(this),this[S].body()):rl}}),Gu=r(e=>typeof e[1]==`function`,(e,t,n)=>P(()=>{let r=qu(n?.concurrency);if(r===1)return Ku(e,t,n);let i=di(e),a=i.length;if(a===0)return n?.discard?F:j([]);let o=n?.discard?void 0:Array(a),s=Zu({f:t,out:o},i,{concurrency:r});return s?Ec(s,o):j(o)})),Ku=(e,t,n)=>P(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return Ec(Wu({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),Ju=()=>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},Yu=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(Fu(ac(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=$u(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`?ys(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 _c(e=>{l=Gs(),u=new Set,p=g,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):P(()=>(f??=rl,I(u?ac(u):F,()=>f?._tag===`Failure`?f:F)))})}if(c=!0,f){if(u&&u.size>0){let e=Zs(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 rl}};return h()}},Xu=()=>e=>Yu(e),Zu=Yu({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)}}),Qu=r(e=>Xt(e[0]),(e,t)=>w(n=>(pf(),j($u(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),$u=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Ks(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=Ws(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},ed=r(e=>Xt(e[0]),(e,t)=>w(n=>j($u(n,e,t?.startImmediately,!0,t?.uninterruptible)))),td=e=>()=>w(t=>t===e?F:rc(e)),nd=r(e=>Xt(e[0]),(e,t,n)=>w(r=>{let i=t.state._tag===`Closed`?new Ks(r.context):$u(r,e,n?.startImmediately,!0,n?.uninterruptible);return i._exit||(t.state._tag===`Closed`?i.interruptUnsafe(r.id,Zs(r)):(du(t,i,td(i)),i.addObserver(()=>fu(t,i)))),j(i)})),rd=r(e=>Xt(e[0]),(e,t)=>I(gu,n=>nd(e,n,t))),id=e=>(t,n)=>{let r=new Ks(n?.scheduler?sa(e,wo,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},ad=r(2,(e,t)=>e._exit?e:t.state._tag===`Closed`?(e.interruptUnsafe(e.id),e):(fu(t,e),du(t,e,td(e)),e.addObserver(()=>fu(t,e)),e)),od=id(ia()),sd=e=>{let t=id(e);return(e,n)=>{let r=t(e,n);return n?.onExit&&r.addObserver(n.onExit),e=>r.interruptUnsafe(e)}},cd=sd(ia()),ld=e=>{let t=id(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},ud=ld(ia()),dd=(e=>{let t=ld(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw Os(e.cause);return e.value})})(ia()),fd=e=>{let t=id(e);return e=>{if(L(e))return e;let n=new ko(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??On(new Xd(r))}},pd=fd(ia()),md=e=>{let t=fd(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw Os(n.cause);return n.value}},hd=md(ia()),gd=j(!0),_d=j(!1),vd=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return gd;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=[],gd}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](rl)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](rl)}open=w(e=>this._isOpen?_d:(this._isOpen=!0,this.scheduleUnsafe(e)));release=w(e=>this._isOpen?_d:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=_c(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}},yd=e=>new vd(e??!1),bd=e=>N(()=>yd(e)),xd=gl(ts),Sd=BigInt(0),Cd={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:Sd,endTime:Sd,exit:rl},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},wd=e=>Object.assign(Object.create(Cd),e),Td=e=>e?O(e.annotations,Ko)?e._tag===`Span`?Td(Dr(e.parent)):T():E(e):T(),Ed=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&O(n.annotations,Ko),i=n?.parent===void 0?n?.root?T():Td(e.cache.span):E(n.parent),a;if(r)a=wd({name:t,parent:i,annotations:sa(n?.annotations??ia(),Ko,!0)});else{let r=e.cache.tracer??Zo,o=e.getRef(Pd),s=e.getRef(ns),c=e.getRef(rs),l=e.getRef(is),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??ia(),links:d,startTime:s?o.currentTimeNanosUnsafe():Sd,kind:n?.kind??`internal`,root:n?.root??!1,sampled:n?.sampled??(br(i)&&i.value.sampled===!1?!1:!ef(e.getRef(Jo),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},Dd=(e,t)=>Fu(w(n=>{let r=da(n.context,nu),i=Ed(n,e,t??{}),a=n.getRef(Pd),o=n.getRef(ns);return Ec(lu(r,e=>kd(i,e,a,o)),i)})),Od=(e,t)=>(t=typeof t==`function`?t:c,dl(es,n=>({name:e,stack:t,parent:n}))),kd=(e,t,n,r)=>N(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():Sd,t)}),Ad=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return w(t=>{let i=Ed(t,e,n),a=t.getRef(Pd),o=t.getRef(ns);return wu(t,e=>kd(i,e,a,o)),r(i)})},jd=gl(Wo),Md=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=us(n),r=Od(t.name,n?.captureStackTrace)),e?jd(r(arguments[0]),t):e=>jd(r(e),t)},Nd=function(){let e=typeof arguments[0]!=`string`,t=e?arguments[1]:arguments[0],n=us(arguments[2]);if(e){let e=arguments[0];return Ad(t,arguments[2],t=>Md(e,t,n))}let r=typeof arguments[1]==`function`?arguments[1]:void 0,i=r?void 0:arguments[1];return(e,...a)=>Ad(t,r?r(...a):i,t=>Md(e,t,n))},Pd=k(`effect/Clock`,{defaultValue:()=>new Id}),Fd=2**31-1,Id=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=N(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return zd()}currentTimeNanos=N(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return Rd()}monotonicTimeNanos=N(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(oo(e))}sleepMillis(e){return e<=0?cc:Number.isFinite(e)?_c(t=>{let n=e>Fd?this.sleepMillis(e-Fd):F,r=setTimeout(()=>t(n),Math.min(e,Fd));return N(()=>clearTimeout(r))}):vc}},Ld=BigInt(1e6),Rd=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())*Ld;return e>t&&(t=e),t}}(),zd=function(){let e=BigInt(1e9),t;return()=>{let n=Rd(),r=BigInt(Date.now())*Ld;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}}(),Bd=e=>w(t=>e(t.getRef(Pd))),Vd=e=>Bd(t=>t.sleep(Ba(e))),Hd=Bd(e=>e.currentTimeMillis),Ud=Bd(e=>e.currentTimeNanos),Wd=`~effect/Cause/TimeoutError`,Gd=e=>v(e,Wd),Kd=class extends jn(`TimeoutError`){[Wd]=Wd;constructor(e){super({message:e})}},qd=`~effect/Cause/IllegalArgumentError`,Jd=class extends jn(`IllegalArgumentError`){[qd]=qd;constructor(e){super({message:e})}},Yd=`~effect/Cause/AsyncFiberError`,Xd=class extends jn(`AsyncFiberError`){[Yd]=Yd;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Zd=`~effect/Cause/UnknownError`,Qd=class extends jn(`UnknownError`){[Zd]=Zd;constructor(e,t){super({message:t,cause:e})}},$d=k(`effect/Console`,{defaultValue:()=>globalThis.console}),ef=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}})),tf=k(`effect/Logger/CurrentLoggers`,{defaultValue:()=>new Set([df,ff])}),nf=k(`effect/Logger/LogToStderr`,{defaultValue:s}),rf={"~effect/Logger":{_Message:i,_Output:i},pipe(){return e(this,arguments)}},af=e=>{let t=Object.create(rf);return t.log=e,t},of=e=>e.replace(/[\s="]/g,`_`),sf=(e,t)=>`${of(e[0])}=${t-e[1]}ms`,cf=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(ef(r.cache.minimumLogLevel,i))return F;let a=r.getRef(Pd),o=r.getRef(tf);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})},lf={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};lf.gray,lf.blue,lf.green,lf.yellow,lf.red,lf.bgBrightRed,lf.black;var uf=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`)}`,df=af(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(Ls(e));let o=t.getTime(),s=n.getRef(ls),c=``;for(let e of s)c+=` ${sf(e,o)}`;let l=n.getRef(as);Object.keys(l).length>0&&a.push(l);let u=n.getRef($d);(n.getRef(nf)?u.error:u.log)(`[${uf(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),ff=af(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(Pd),a=t.getRef(as),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`]=Ls(e)),o.event(jt(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)});function pf(){Xs.interruptChildren??=Qs}var mf=j(void 0),hf=en,gf=tn,_f=_n,vf=vn,yf=yn,bf=cn,xf=pn,Sf=hn,Cf=ms,wf=e=>new sn(e),Tf=e=>new mn(e),Ef=ps,Df=Ts,Of=Ds,kf=Os,Af=gs,jf=_s,Mf=xs,Nf=Cs,Pf=Ss,Ff=ks,If=Nn,Lf=Fn,Rf=zn,zf=Gd,Bf=Jd,Vf=Es,Hf=Pd,Uf=Hd,Wf=Ud,Gf=Zt,Kf=C,qf=En,Jf=Dn,Yf=On,Xf=Qc,Zf=rl,Qf=$c,$f=el,ep=cl,tp={"~effect/Deferred":{_A:i,_E:i},pipe(){return e(this,arguments)}},np=function(){this.resumes=void 0,this.effect=void 0};np.prototype=tp;var rp=()=>new np,ip=()=>N(()=>rp()),ap=e=>_c(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)}))),op=r(2,(e,t)=>N(()=>pp(e,t))),sp=r(2,(e,t)=>op(e,Dn(t))),cp=r(2,(e,t)=>op(e,En(t))),lp=r(2,(e,t)=>cp(e,ms(t))),up=e=>e.effect!==void 0;function dp(e){return N(()=>Tr(e.effect))}var fp=r(2,(e,t)=>op(e,C(t))),pp=(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},mp=r(2,(e,t)=>Hu(n=>I(ql(n(e)),e=>op(t,e)))),hp=as,gp=ls,_p=ns,vp=nu,yp=pu,bp=_u,xp=lu,Sp=uu,Cp=cu,wp=ru,Tp=iu,Ep=`~effect/Layer`,Dp=`~effect/Layer/MemoMap`,Op=(e,t)=>{let n={observers:0,deferred:rp(),scope:yp(),finalizer:r=>P(()=>--n.observers>0?F:(e.map.delete(t),wp(n.scope,r)))};return n},kp=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,du(t,{},e.finalizer),!0),Ap={[Ep]:{_ROut:i,_E:i,_RIn:i},pipe(){return e(this,arguments)}},jp=e=>{let t=Object.create(Ap);return t.build=e,t},Mp=e=>jp((t,n)=>{let r=Cp(n);return Tu(e(t,r),e=>e._tag===`Failure`?wp(r,e):F)}),Np=e=>{let t=Mp((n,r)=>n.getOrElseMemoize(t,r,e));return t},Pp=class{get[Dp](){return Dp}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(kp(n,t),n.deferred.effect??ap(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return P(()=>{let r;return Cu(P(()=>{let i=this.get(e,t);if(i)return i;let a=Op(this,e);return kp(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&pp(r,e)})})}},Fp=()=>new Pp,Ip=e=>new Pp(e),Lp=class e extends Vi()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=la(t,e);return n?Ip(n):Fp()}},Rp=r(3,(e,t,n)=>gl(qc(P(()=>e.build(t,n)),sa(Lp,t)),Lp,t)),zp=r(2,(e,t)=>w(n=>Rp(e,Lp.forkOrCreate(n.context),t))),Bp=function(){return arguments.length===1?e=>Vp(oa(arguments[0],e)):Vp(oa(arguments[0],arguments[1]))},Vp=e=>jp(a(j(e))),Hp=Vp(ia()),Up=function(){return arguments.length===1?e=>Wp(()=>oa(arguments[0],e())):Wp(()=>oa(arguments[0],arguments[1]()))},Wp=e=>Np(a(N(e))),Gp=function(){return arguments.length===1?e=>Kp(arguments[0],e):Kp(arguments[0],arguments[1])},Kp=(e,t)=>qp(qc(t,t=>oa(e,t))),qp=e=>Np((t,n)=>bp(e,n)),Jp=e=>qp(Ec(e,ia())),Yp=Vi(`effect/Layer/unwrap`),Xp=e=>nm(Gp(Yp)(e),O(Yp)),Zp=(e,t,n)=>{let r=Cp(n,`parallel`);return Gu(e,e=>e.build(t,Cp(r,`sequential`)),{concurrency:e.length}).pipe(qc(e=>_a(...e)))},Qp=(...e)=>Np((t,n)=>Zp(e,t,n)),$p=(e,t,n)=>Np((r,i)=>I(Array.isArray(t)?Zp(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(hl(t),qc(e=>n(e,t))))),em=r(2,(e,t)=>$p(e,t,i)),tm=r(2,(e,t)=>$p(e,t,(e,t)=>ga(t,e))),nm=r(2,(e,t)=>Mp((n,r)=>I(e.build(n,r),e=>t(e).build(n,r)))),rm=r(2,(e,t)=>Mp((n,r)=>I(e.build(n,r),e=>bp(Ec(t(e),e),r)))),im=e=>jp((t,n)=>Nl(e.build(t,n))),am=r(2,(e,t)=>jp((n,r)=>bl(e.build(n,r),e=>t(e).build(n,r)))),om=`~effect/DateTime`,sm=`~effect/DateTime/TimeZone`,cm={[om]:om,pipe(){return e(this,arguments)},[kt](){return this.toString()},toJSON(){return Bm(this).toJSON()}},lm={...cm,_tag:`Utc`,[xe](){return Oe(this.epochMilliseconds)},[Be](e){return ym(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Bm(this).toJSON()})`}},um={...cm,_tag:`Zoned`,[xe](){return we(Oe(this.epochMilliseconds))(y(this.zone))},[Be](e){return ym(e)&&e._tag===`Zoned`&&this.epochMilliseconds===e.epochMilliseconds&&Ve(this.zone,e.zone)},toString(){return`DateTime.Zoned(${eh(this)})`}},dm={[sm]:sm,[kt](){return this.toString()}},fm={...dm,_tag:`Named`,[xe](){return ke(`Named:${this.id}`)},[Be](e){return xm(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},pm={...dm,_tag:`Offset`,[xe](){return ke(`Offset:${this.offset}`)},[Be](e){return xm(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${Um(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},mm={value:void 0,enumerable:!1,writable:!0},hm=new WeakMap,gm=(e,t)=>({get(){return Object.isExtensible(this)?void 0:hm.get(this)?.[e]},set(n){if(Object.isExtensible(this)){for(let e of t)Object.defineProperty(this,e,mm);this[e]=n}else{let t=hm.get(this);t===void 0&&(t={},hm.set(this,t)),t[e]=n}}}),_m=[`partsUtc`,`adjustedEpochMilliseconds`,`partsAdjusted`];Object.defineProperty(lm,"partsUtc",gm(`partsUtc`,[`partsUtc`])),Object.defineProperties(um,{partsUtc:gm(`partsUtc`,_m),adjustedEpochMilliseconds:gm(`adjustedEpochMilliseconds`,_m),partsAdjusted:gm(`partsAdjusted`,_m)});var vm=(e,t,n)=>{let r=Object.create(um);return r.epochMilliseconds=e,r.zone=t,n!==void 0&&(r.partsUtc=n),r},ym=e=>v(e,om),bm=e=>ym(e[0]),xm=e=>v(e,sm),Sm=e=>e._tag===`Zoned`,Cm=e=>{let t=Object.create(lm);return t.epochMilliseconds=e,t},wm=e=>{let t=e.getTime();if(Number.isNaN(t))throw new Bf(`Invalid date`);return Cm(t)},Tm=e=>{if(ym(e))return e;if(e instanceof Date)return wm(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return wm(new Date(e.epochMilliseconds));let t=new Date(0);return Km(t,e),wm(t)}return typeof e==`string`&&!Em(e)?wm(new Date(e+`Z`)):wm(new Date(e))},Em=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e)||/z$|gmt$/i.test(e),Dm=-864e13+432e5,Om=864e13-504e5,km=(e,t)=>{let n=t?.timeZone;if(n===void 0&&ym(e)&&Sm(e))return e;let r=Tm(e);if(r.epochMilliseconds<Dm||r.epochMilliseconds>Om)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=Fm(new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1e3);else if(xm(n))i=n;else if(typeof n==`number`)i=Fm(n);else{let e=Rm(n);if(yr(e))throw new Bf(`Invalid time zone: ${n}`);i=e.value}return t?.adjustForTimeZone===!0?Jm(r.epochMilliseconds,i,t?.disambiguation??`compatible`):vm(r.epochMilliseconds,i,r.partsUtc)},Am=()=>Cm(Date.now()),jm=new Map,Mm={day:`numeric`,month:`numeric`,year:`numeric`,era:`short`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},Nm=e=>{let t=e.resolvedOptions().timeZone,n=jm.get(t);if(n!==void 0)return n;let r=Object.create(fm);return r.id=t,r.format=e,jm.set(t,r),r},Pm=e=>{let t=jm.get(e);if(t!==void 0)return t;try{let t=Nm(new Intl.DateTimeFormat(`en-US`,{...Mm,timeZone:e}));return jm.set(e,t),t}catch{throw new Bf(`Invalid time zone: ${e}`)}},Fm=e=>{let t=Object.create(pm);return t.offset=e,t},Im=Or(Pm),Lm=/^(?:GMT)?[+-]/,Rm=e=>{if(Lm.test(e)){let t=Xm(e);return t===null?T():E(Fm(t))}return Im(e)},zm=r(2,(e,t)=>io(Gm(t)-Gm(e))),Bm=e=>new Date(e.epochMilliseconds),Vm=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},Hm=e=>Vm(e).getTime()-Gm(e),Um=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`)}`},Wm=e=>Um(Hm(e)),Gm=e=>e.epochMilliseconds,Km=(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)},qm=864e5,Jm=(e,t,n)=>{if(t._tag===`Offset`)return vm(e-t.offset,t);let r=Zm(e-qm,e,t),i=Zm(e+qm,e,t);if(r===i)return vm(e-r,t);let a=r<i,o=r-i;if(a){if(Zm(e-i,e,t)===i)return vm(e-i,t);let a=vm(e-r,t);if(e!==Vm(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 vm(e-i,t);case`compatible`:case`later`:return a}return a}if(Zm(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||Zm(e-r+o,e+o,t)===r)return vm(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 vm(e-i,t)},Ym=/([+-])(\d{2}):?(\d{2})$/,Xm=e=>{let t=Ym.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},Zm=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=Xm(r);return i===null?Hm(vm(t,n)):i},Qm=r(bm,(e,t)=>new Intl.DateTimeFormat(t?.locale,t).format(e.epochMilliseconds)),$m=e=>{let t=Vm(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${Wm(e)}`},eh=e=>e.zone._tag===`Offset`?$m(e):`${$m(e)}[${e.zone.id}]`,th=globalThis.Number,nh=dr,rh=gr(nh),ih=_r(nh),ah=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=th(e);return th.isNaN(t)?T():E(t)};globalThis.String;var oh=re,sh=e=>e.toUpperCase(),ch=e=>e.toLowerCase(),lh=(e,t)=>n=>n.replace(e,t),uh=(e,t)=>n=>n.slice(e,t),dh=e=>e.length===0,fh=e=>e.length>0,ph=e=>e.length,mh=r(2,(e,t)=>{let n=e.split(t);return ct(n)?n:[e]}),hh=(e,t)=>n=>n.endsWith(e,t),gh=e=>t=>Er(t.match(e)),_h=(e,t)=>n=>n.padStart(e,t),vh=(e,t)=>n=>n.replaceAll(e,t),yh=r(2,(e,t)=>wl(e,Ch,e=>t(e))),bh=e=>e.reasons.some(xh),xh=e=>e._tag===`Fail`&&Lf(e.error),Sh=e=>{let t,n=!1;for(let r of e.reasons)xh(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Br(e):n?Br(bf(e.reasons.filter(e=>!xh(e)))):zr(t)},Ch=e=>{let t=Sh(e);return D(t)?t:zr(t.success.value)},wh=e=>{let t=Sh(e);return D(t)?qf(t.failure):Kf(t.success.value)},Th=r(2,(e,t)=>zl(e,{onSuccess:t.onSuccess,onFailure:e=>{let n=Sh(e);return D(n)?t.onFailure(n.failure):t.onDone(n.success.value)}})),Eh=`~effect/Schedule`,Dh=k(`effect/Schedule/CurrentMetadata`,{defaultValue:a({input:void 0,output:void 0,duration:eo,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),Oh={[Eh]:{_Out:i,_In:i,_Env:i},pipe(){return e(this,arguments)}},kh=e=>v(e,Eh),Ah=e=>{let t=Object.create(Oh);return t.step=e,t},jh=()=>{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}}},Mh=e=>Ah(qc(e,e=>{let t=jh();return(n,r)=>e(t(n,r))})),Nh=e=>bl(e.step,e=>j(()=>M(e))),Ph=e=>Bd(t=>qc(Nh(e),e=>{let n=jh();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,Ec(Vd(t),a)})})})),Fh=r(2,(e,t)=>zh(e,e=>qc(t(e),t=>go(Ba(t),e.duration)))),Ih=e=>Ah(qc(Uu(e.map(Nh)),e=>(t,n)=>I(Gu(e,e=>Th(e(t,n),{onSuccess:e=>j(e[1]),onDone:()=>mf,onFailure:M})),e=>{let t=Lh(e);return t===void 0?Rf(eo):j([t,t])}))),Lh=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t=t===void 0?r:mo(t,r))}return t},Rh=(e,t=2)=>{let n=oo(Ba(e));return Mh(j(e=>{let r=io(n*t**(e.attempt-1));return j([r,r])}))},zh=r(2,(e,t)=>Ah(qc(Nh(e),e=>{let n=jh();return(r,i)=>I(e(r,i),([e,a])=>qc(t({...n(r,i),output:e,duration:a}),t=>[e,Ba(t)]))}))),Bh=e=>Ah(qc(Nh(e),e=>(t,n)=>Th(e(t,n),{onSuccess:e=>j([n,e[1]]),onFailure:M,onDone:()=>Rf(n)}))),Vh=e=>{let t=Ba(e);return Mh(j(e=>j([e.attempt-1,t])))},Hh=r(2,(e,t)=>Ah(qc(Nh(e),e=>{let n=jh();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):Rf(a))})}))),Uh=Vh(eo),Wh=(e,t,n)=>yu(r=>I(n?.local?Rp(t,Fp(),r):zp(t,r),t=>hl(e,t))),Gh=r(e=>Xt(e[0]),(e,t,n)=>na(t)?hl(e,t):Wh(e,Array.isArray(t)?Qp(...t):t,n)),Kh=r(3,(e,t,n)=>I(Ph(t),t=>{let r=Dh.defaultValue(),i=n=>Th(t(n),{onSuccess(t){return r=t,I(gl(e,Dh,r),i)},onFailure:M,onDone:j});return wl(I(gl(e,Dh,r),i),bs,e=>n(e,r.attempt===0?T():E(r)))})),qh=r(3,(e,t,n)=>I(Ph(t),t=>{let r=Dh.defaultValue(),i,a=wl(P(()=>gl(e,Dh,r)),bs,e=>(i=e,I(t(e),e=>(r=e,a))));return yh(a,e=>Rt(()=>n(i,e)))})),Jh=r(2,(e,t)=>Kh(e,typeof t==`function`?t(i):kh(t)?t:Zh(t),oc)),Yh=r(2,(e,t)=>qh(e,typeof t==`function`?t(i):kh(t)?t:Zh(t),oc)),Xh=Bh(Uh),Zh=e=>{let t=e.schedule?Bh(e.schedule):Xh;return e.while&&(t=Hh(t,({input:t})=>{let n=e.while(t);return Xt(n)?n:j(n)})),e.until&&(t=Hh(t,({input:t})=>{let n=e.until(t);return Xt(n)?qc(n,e=>!e):j(!n)})),e.times!==void 0&&(t=Hh(t,({attempt:t})=>j(t<=e.times))),t},Qh=`~effect/MutableHashMap`,$h={[Qh]:Qh,[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)}},eg=()=>{let e=Object.create($h);return e.backing=new Map,e.buckets=new Map,e},tg=r(2,(e,t)=>{if(e.backing.has(t))return E(e.backing.get(t));if(ng(t))return T();let n=y(t),r=e.buckets.get(n);return r===void 0?T():rg(e,r,t)}),ng=e=>typeof e!=`object`&&typeof e!=`function`,rg=(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()},ig=r(3,(e,t,n)=>{if(e.backing.has(t)||ng(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=ag(i,t);return a===void 0&&(i.push(t),a=t),e.backing.set(a,n),e}),ag=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(Ve(t,e[n]))return e[n]},og=r(2,(e,t)=>{if(ng(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}),sg=Xt,cg=Uu,lg=Gu,ug=Wu,dg=pc,fg=mc,R=j,pg=lc,z=P,B=N,V=F,mg=_c,hg=vc,gg=yc,H=oc,_g=M,vg=uc,yg=dc,bg=fc,xg=cc,Sg=w,Cg=sc,U=I,wg=Kc,Tg=Rc,Eg=zc,Dg=Ll,Og=ql,W=qc,kg=Ec,Ag=Bc,jg=Al,Mg=bl,Ng=kl,Pg=Cl,Fg=jl,Ig=Nl,Lg=Ol,Rg=El,zg=Yh,Bg=qh,Vg=Fl,Hg=Il,Ug=Ql,Wg=$l,Gg=Xl,Kg=Yl,qg=Vd,Jg=Uc,Yg=Wc,Xg=vl,Zg=zl,Qg=fl,$g=ml,e_=Gh,t_=hl,n_=ll,r_=ul,i_=gl,a_=gu,o_=vu,s_=yu,c_=bu,l_=xu,u_=Eu,d_=Ou,f_=Cu,p_=Tu,m_=Nu,h_=Pu,g_=Vu,__=Au,v_=Fu,y_=Hu,b_=yl,x_=Jh,S_=xd,C_=Dd,w_=Ad,T_=Nd,E_=Md,D_=Qu,O_=nd,k_=rd,A_=ed,j_=od,M_=id,N_=sd,P_=cd,F_=dd,I_=ud,L_=hd,R_=md,z_=pd,B_=xc,V_=cf(`Warn`),H_=cf(`Error`),U_=cf(`Debug`),W_=r(e=>sg(e[0]),(e,...t)=>dl(e,hp,e=>{let n=t.length===1?{...e,...t[0]}:{...e};return t.length===1||b(n,t[0],t[1]),n})),G_=Jc,K_=Yc,q_=Xc,J_=Gc,Y_=Zc,X_=Cc,Z_=$s,Q_=tc,$_=nc,ev=rc,tv=ac,nv=Gs,rv=ad,iv=`~effect/Chunk`;function av(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 ov=[],sv=(e=>rt((t,n)=>{if(t.length!==n.length)return!1;let r=pv(t),i=pv(n);for(let t=0;t<r.length;t++)if(!e(r[t],i[t]))return!1;return!0}))(Ve),cv={[iv]:{_A:e=>e},toString(){return`Chunk(${x(pv(this))})`},toJSON(){return{_id:`Chunk`,values:At(pv(this))}},[kt](){return this.toJSON()},[Be](e){return uv(e)&&sv(this,e)},[xe](){return Ne(pv(this))},[Symbol.iterator](){switch(this.backing._tag){case`IArray`:return this.backing.array[Symbol.iterator]();case`IEmpty`:return ov[Symbol.iterator]();default:return pv(this)[Symbol.iterator]()}},pipe(){return e(this,arguments)}},lv=e=>{let t=Object.create(cv);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=dv,t.right=dv;break;case`ISingleton`:t.length=1,t.depth=0,t.left=dv,t.right=dv;break;case`ISlice`:t.length=e.length,t.depth=0,t.left=dv,t.right=dv}return t},uv=e=>v(e,iv),dv=lv({_tag:`IEmpty`}),fv=(e,t,n)=>{switch(e.backing._tag){case`IArray`:av(e.backing.array,0,t,n,e.length);break;case`IConcat`:fv(e.left,t,n),fv(e.right,t,n+e.left.length);break;case`ISingleton`:t[n]=e.backing.a;break;case`ISlice`:av(pv(e.backing.chunk),e.backing.offset,t,n,e.length)}},pv=e=>{switch(e.backing._tag){case`IEmpty`:return ov;case`IArray`:return e.backing.array;default:{let t=Array(e.length);return fv(e,t,0),e.backing={_tag:`IArray`,array:t},e.left=dv,e.right=dv,e.depth=0,t}}},mv=yd,hv=bd,gv=`~effect/MutableRef`,_v={[gv]:gv,...Jt,toJSON(){return{_id:`MutableRef`,current:At(this.current)}}},vv=e=>{let t=Object.create(_v);return t.current=e,t},yv=e=>e.current,bv=r(2,(e,t)=>(e.current=t,e)),xv=r(2,(e,t)=>bv(e,t(yv(e)))),Sv=Symbol.for(`effect/MutableList/Empty`),Cv=()=>({head:void 0,tail:void 0,length:0}),wv=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})},Tv=()=>({array:[],mutable:!0,offset:0,next:void 0}),Ev=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=Tv(),e.tail=e.tail.next):e.head=e.tail=Tv(),e.tail.array.push(t),e.length++},Dv=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||=e.head,e.length++},Ov=(e,t)=>kv(e,Array.from(t),!0),kv=(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},Av=e=>{e.head=e.tail=void 0,e.length=0},jv=(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 Av(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?Av(e):wv(e),n;i=i.next}return Av(e),n},Mv=e=>jv(e,e.length),Nv=e=>{if(!e.head)return Sv;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:Av(e):wv(e),t},Pv=(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?Av(e):(e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length)},Fv=(e,t)=>Pv(e,e=>e!==t),Iv=`~effect/PubSub`,Lv=`~effect/PubSub/Subscription`,Rv=e=>B(()=>ry(e.atomicPubSub(),new Map,yp(),mv(!1),vv(!1),e.strategy(),vv(T()))),zv=e=>Rv({atomicPubSub:()=>Bv(e),strategy:()=>new iy}),Bv=e=>{let t=e?.replay;return new $v(t&&t>0?new sy(Math.ceil(t)):void 0)},Vv=e=>v_(Sg(t=>(bv(e.shutdownFlag,!0),wp(e.scope,Xf(t.id)).pipe(Tg(e.strategy.shutdown),Xg(e.shutdownHook.open),Ag)))),Hv=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))),Uv=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),Wv=e=>v_($g(t=>{let n=O(t,vp),r=Cp(e.scope),i=Qv(e.pubsub,e.subscribers,e.strategy,e.ended);return Sp(r,Gv(i)).pipe(Tg(xp(n,e=>wp(r,e))),kg(i))})),Gv=e=>v_(Sg(t=>(bv(e.shutdownFlag,!0),lg(Mv(e.pollers),e=>lp(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(Eg(()=>B(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),Xg(e.shutdownHook.open),Ag)))),Kv=e=>z(()=>{if(e.shutdownFlag.current)return h_;if(e.replayWindow.remaining>0)return R(e.replayWindow.take());let t=e.pollers.length===0?e.subscription.poll():Sv;return t===Sv?Jv(e):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),R(t))}),qv=e=>z(function t(n){if(e.shutdownFlag.current)return h_;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)):_i(r)?R(r):U(Jv(e),e=>t([e]))}),Jv=e=>mg(t=>{if(e.shutdownFlag.current)return t(h_);if(br(e.ended.current)){let n=e.pollers.length===0?e.subscription.poll():Sv;return n===Sv?t(R(e.ended.current.value)):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),t(R(n)))}let n=rp(),r=e.subscribers.get(e.subscription);return r||(r=new Set,e.subscribers.set(e.subscription,r)),r.add(e.pollers),Ev(e.pollers,n),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),n.effect?t(n.effect):(n.resumes=[t],B(()=>Fv(e.pollers,n)))}),Yv=Symbol.for(`effect/PubSub/AbsentValue`),Xv=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)},Zv=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.delete(n),r.size===0&&e.delete(t)},Qv=(e,t,n,r)=>new ty(e,t,e.subscribe(),Cv(),mv(!1),vv(!1),n,e.replayWindow(),r),$v=class{publisherHead={value:Yv,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 cy(this.replayBuffer):ly}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=Yv,this.subscribersIndex+=1,this.replayBuffer?.slide(t,e.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new ey(this,this.publisherTail,this.publisherIndex,!1)}},ey=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===Yv?(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 Sv;let e=!0,t=Sv;for(;e;)if(this.subscriberHead===this.self.publisherTail)e=!1;else{let n=this.subscriberHead.next.value;n!==Yv&&(t=n,--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=Yv,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===Sv?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!==Yv&&(--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=Yv,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},ty=class{[Lv]={_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)}},ny=class{[Iv]={_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)}},ry=(e,t,n,r,i,a,o)=>new ny(e,t,n,r,i,a,o),iy=class{get shutdown(){return V}handleSurplus(e,t,n,r){return R(!1)}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return ay(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return oy(this,e,t)}},ay=(e,t,n,r,i)=>{let a=!0;for(;a&&!r.isEmpty();){let o=Nv(i);if(o===Sv)Zv(n,r,i),i.length===0?a=!1:Xv(n,r,i);else{let a=r.poll();a===Sv?Dv(i,o):(pp(o,Kf(a)),e.onPubSubEmptySpaceUnsafe(t,n))}}},oy=(e,t,n)=>{for(let[r,i]of n)for(let a of i)e.completePollersUnsafe(t,n,r,a)},sy=class{capacity;head={value:Yv,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:Yv,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=Yv}else this.size+=1;return t}offerAll(e){for(let t of e)this.offer(t)}},cy=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]=Yv,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)}},ly={remaining:0,take:()=>void 0,takeN:()=>[],takeAll:()=>[],close:()=>void 0},uy=`~effect/Queue`,dy=`~effect/Queue/Enqueue`,fy=`~effect/Queue/Dequeue`,py={_A:i,_E:i},my={[uy]:py,[dy]:py,[fy]:py,...Jt,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:Ay(this)}}},hy=e=>w(t=>{let n=Object.create(my);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=Cv(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},j(n)}),gy=e=>hy({capacity:e}),_y=r(2,(e,t)=>P(()=>vy(e,t)?My:e.state._tag===`Open`&&e.strategy===`suspend`?Vy(e,t):jy)),vy=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(Nv(e.messages),Ev(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(Ev(e.messages,t),Fy(e),!0):(Ev(e.messages,t),Iy(e),!0):!1,yy=r(2,(e,t)=>_c(n=>{let r=by(e,t);return r.length===0||e.strategy===`dropping`?n(C(r)):Hy(e,{_tag:`Array`,remaining:r,offset:0,resume:n})})),by=(e,t)=>{if(e.state._tag!==`Open`)return di(t);if(e.capacity===1/0||e.strategy===`sliding`)return Ov(e.messages,t),e.strategy===`sliding`&&jv(e.messages,e.messages.length-e.capacity),Iy(e),[];let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return di(t);let r=[],i=0;for(let a of t)i<n?Ev(e.messages,a):r.push(a),i++;return Iy(e),r},xy=r(2,(e,t)=>N(()=>Sy(e,t))),Sy=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=sl(En(t),Ny);return e.state.offers.size===0&&e.messages.length===0?(Ky(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},Iy(e),!0)},Cy=e=>xy(e,pn(Ln())),wy=e=>N(()=>Ty(e)),Ty=e=>{if(e.state._tag===`Done`)return!1;Av(e.messages);let t=e.state.offers;Ky(e,e.state._tag===`Open`?Py:e.state.exit);for(let e of t)Uy(e);return!0},Ey=e=>Dy(e,1,1/0),Dy=r(3,(e,t,n)=>(t=lt(t),n=lt(n),Ry(()=>Ly(e,t,n)??Rc(By(e,()=>zy(e,t)),Dy(e,t,n))))),Oy=e=>Ry(()=>ky(e)??Rc(By(e,()=>zy(e,1)),Oy(e))),ky=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=Nv(e.messages);return Gy(e),C(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=Wy(e.state.offers);return Gy(e),C(t)}},Ay=e=>e.state._tag===`Done`?0:e.messages.length,jy=C(!1),My=C(!0),Ny=Dn(Ln()),Py=Qc(),Fy=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(rl),e.messages.length===0))break}},Iy=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,Fy(e)},0))},Ly=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return C([]);if(!zy(e,t))return;let r=e.messages.length>0?jv(e.messages,n):[Wy(e.state.offers)];return Gy(e),C(r)},Ry=Sn({op:`QueueTake`,[Ut](e){let t=this[S]();return Zt(t)?t[Ut](e):t}}),zy=(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,By=(e,t)=>_c(n=>{if(e.state._tag===`Done`)return n(e.state.exit);if(t())return n(rl);let r={ready:t,resume:n};return e.state.takers.add(r),N(()=>{e.state._tag!==`Done`&&e.state.takers.delete(r)})}),Vy=(e,t)=>_c(n=>vy(e,t)?n(My):Hy(e,{_tag:`Single`,message:t,resume:n})),Hy=(e,t)=>{if(e.state._tag!==`Open`)return Uy(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&&Ky(e,e.state.exit))})},Uy=e=>e._tag===`Single`?e.resume(jy):e.resume(C(e.remaining.slice(e.offset))),Wy=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume(My),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(C([]))),n},Gy=e=>{if(e.state._tag===`Done`)return bh(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0&&(Ky(e,e.state.exit),bh(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`)Ev(e.messages,t.message),e.state.offers.delete(t),t.resume(My);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;Ev(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(C([]))}let r=e.state;if(r._tag===`Done`)return bh(r.exit.cause)}return!1},Ky=(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()},qy=e=>new Xy(e),Jy=e=>{for(let t of e.waiters)if(t.permits<=e.free)return t},Yy=(e,t,n,r=i)=>w(i=>{if(e.free>=t&&Jy(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),wu(i,o);let s=I(r(_c(t=>{Jy(e)===a?t(F):a.resume=t})),()=>Jy(e)===a?(e.taken+=t,o(),n()):s);return s}),Xy=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){return Yy(this,e,()=>j(e))}takeScoped(e){return Hu(t=>I(gu,n=>Yy(this,e,()=>uu(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=>Hu(n=>Yy(this,e,()=>Cu(n(t),()=>{this.releaseUnsafe(Gs(),e)},!0),n))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>Hu(n=>this.free<e?lc:(this.taken+=e,Cu(n(Lc(t)),()=>{this.releaseUnsafe(Gs(),e)},!0)))}},Zy=e=>Gf(e)?Qf(e)?Rf(e.value):e:R(e),Qy=`~effect/Channel`,$y=e=>v(e,Qy),eb={[Qy]:{_Env:i,_InErr:i,_InElem:i,_OutErr:i,_OutElem:i},pipe(){return e(this,arguments)}},tb=e=>{let t=Object.create(eb);return t.transform=(t,n)=>Mg(e(t,n),e=>R(_g(e))),t},nb=(e,t)=>tb((n,r)=>U(ab(e)(n,r),e=>t(e,r))),rb=e=>tb((t,n)=>e),ib=e=>tb(B_(function*(t,n){let r=Cp(n),i=e=>wp(r,wh(e));return d_(yield*d_(e(t,n,r),i),i)})),ab=e=>e.transform,ob=(e,t,n)=>hy({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(Eg(t=>Sp(e,wy(t))),Eg(n=>bp(t(n),e).pipe(Mg(e=>xy(n,e)),O_(e,{startImmediately:!0})))),sb=(e,t)=>tb((n,r)=>W(ob(r,e,t),Ey)),cb=e=>tb((t,n)=>z(()=>ab(e())(t,n))),lb=e=>rb(B(()=>{let t=e();return z(()=>{let e=t.next();return e.done?Rf(e.value):R(e.value)})})),ub=e=>gb(R(e)),db=rb(R(Rf())),fb=rb(R(hg)),pb=e=>rb(R(H(e))),mb=e=>rb(_g(e)),hb=e=>mb(Sf(e)),gb=e=>rb(B(()=>{let t=!1;return z(()=>t?Rf():(t=!0,e))})),_b=e=>rb(R(U(e,Zy))),vb=e=>rb(R(Ey(e))),yb=e=>rb(R(__(qv(e),()=>Rf()))),bb=e=>Hb(W(Wv(e),yb)),xb=e=>tb((t,n)=>Sb({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Sb=e=>{let t=e.readable.getReader(),n=e.exit??vv(void 0),r=z(()=>n.current?n.current:Zg(fg({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??_g(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?Rf():R(Ai(t))}));return kg(Sp(e.scope,e.releaseLockOnEnd?B(()=>t.releaseLock()):dg(()=>t.cancel().catch(e=>t.closed.then(()=>Promise.reject(e),l))).pipe(u_(B(()=>t.releaseLock())))),r)},Cb=r(2,(e,t)=>nb(e,e=>B(()=>{let n=0;return W(e,e=>t(e,n++))}))),wb=e=>e===void 0||e!==`unbounded`&&e<=1,Tb=r(e=>$y(e[0]),(e,t,n)=>wb(n?.concurrency)?Eb(e,t):Db(e,t,n)),Eb=(e,t)=>tb((n,r)=>{let i=0;return W(ab(e)(n,r),U(e=>t(e,i++)))}),Db=(e,t,n)=>ib(B_(function*(r,i,o){let s=0,c=yield*ab(e)(r,i),l=n.concurrency===`unbounded`?2**53-1:Math.min(n.concurrency,2**53-1),u=yield*gy(0);yield*Sp(o,wy(u));let d=M_(yield*Qg()),f=rv(o);if(n.unordered){let e=qy(l),n=a(e.release(1)),r=Zg({onFailure:e=>U(xy(u,e),n),onSuccess:e=>U(_y(u,e),n)});yield*e.take(1).pipe(U(()=>c),U(e=>{let n=s++;return f(d(r(z(()=>t(e,n))))),V}),b_({disableYield:!0}),Mg(t=>e.withPermits(l-1)(xy(u,t))),O_(o))}else{let e=yield*gy(l-2);yield*Sp(o,wy(e)),yield*Oy(e).pipe(wg,U(e=>_y(u,e)),b_({disableYield:!0}),Mg(e=>xy(u,e)),O_(o));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,Sy(u,e.cause))};yield*c.pipe(U(i=>{if(n)return _g(n);let a=s++,o=d(z(()=>t(i,a)));return f(o),o.addObserver(r),_y(e,Q_(o))}),b_({disableYield:!0}),Mg(t=>_y(e,qf(t)).pipe(Tg(xy(e,t)))),O_(o))}return Oy(u)})),Ob=r(e=>$y(e[0]),(e,t,n)=>wb(n?.concurrency)?kb(e,t):Ab(e,t,n)),kb=(e,t)=>tb((n,r)=>W(ab(e)(n,r),e=>{let i,a,o=U(e,e=>(a??=Cp(r),J_(ab(t(e))(n,a),e=>(i=s(e),i)))),s=yh(e=>{if(i=void 0,a.state._tag===`Empty`)return o;let t=wp(a,Zf);return a=void 0,U(t,()=>o)});return z(()=>i??o)})),Ab=(e,t,n)=>e.pipe(Cb(t),Bb(n)),jb=e=>Ob(e,i),Mb=e=>nb(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)}))}),Nb=(e,t)=>tb((n,r)=>B(()=>{let i,a=()=>{let o=Cp(r);return U(ab(e)(n,o),e=>(i=Mg(e,e=>{let n=wh(e);return wp(o,n).pipe(U(()=>t(n,r)),U(a))}),i))};return z(()=>i??a())})),Pb=r(2,(e,t)=>nb(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 vi(i)?R(i):U(e,n)})))),Fb=r(2,(e,t)=>tb((n,r)=>{let i=Cp(r);return W(ab(e)(n,i),e=>{let a=e.pipe(Mg(e=>{if(bh(e))return _g(e);let o=i;return i=Cp(r),wp(o,qf(e)).pipe(Tg(ab(t(e))(n,i)),U(e=>(a=e,e)))}));return z(()=>a)})})),Ib=r(3,(e,t,n)=>Fb(e,e=>{let r=t(e);return D(r)?mb(r.failure):n(r.success,e)})),Lb=r(2,(e,t)=>Ib(e,bs,e=>t(e))),Rb=r(e=>$y(e[0]),(e,t,n,r)=>Lb(e,e=>t(e)?n(e):r?r(e):pb(e))),zb=r(2,(e,t)=>cb(()=>{let n,r=Dh.defaultValue(),a=Kb(Qb(e,Dh,B(()=>r)),()=>(n=void 0,V)),o=typeof t==`function`?t(i):t;return Nb(a,(e,t)=>{if(Qf(e))return Rf(e.value);let i=bs(e.cause);return D(i)?_g(i.failure):gg(function*(){n||=yield*Ph(o),r=yield*n(i.success)}).pipe(yh(()=>H(i.success)),bp(t))})})),Bb=r(2,(e,{bufferSize:t=16,concurrency:n,switch:r=!1})=>ib(B_(function*(i,a,o){let s=n===`unbounded`?2**53-1:Math.max(1,n),c=r?void 0:qy(s),l=yield*hv(!0),u=new Map,d=yield*gy(t);yield*Sp(o,wy(d));let f=yield*ab(e)(i,a);return yield*gg(function*(){for(;;){let e;c&&(u.size<s?yield*c.take(1):(e=yield*D_(f),yield*Yg(c.take(1),Tg(Q_(e),hg))));let t=e===void 0?yield*f:yield*Q_(e),n=Cp(o),r=yield*ab(t)(i,n);for(;u.size>=s;){let[e,t]=Yr(u);u.delete(e),u.size===0&&(yield*l.open),yield*ev(e),yield*Hg(wp(t,Xf()))}let a=yield*r.pipe(Eg(()=>xg),U(e=>_y(d,e)),b_({disableYield:!0}),d_(B_(function*(e){let t=wh(e),r=yield*Og(wp(n,t));if(!u.has(a))return;let i=ep([t,r]);$f(i)&&(yield*xy(d,i.cause)),u.delete(a),c&&(yield*c.release(1)),u.size===0&&(yield*l.open)})),D_);l.closeUnsafe(),u.set(a,n)}}).pipe(Mg(e=>Ur(Sh(e))?l.whenOpen(xy(d,e)):xy(d,e)),O_(o)),Oy(d)}))),Vb=r(e=>$y(e[0])&&$y(e[1]),(e,t,n)=>ib(B_(function*(r,i,a){let o=n?.haltStrategy??`both`,s=yield*gy(0);yield*Sp(a,wy(s));let c=0;function l(e,t){if(c++,!bh(t))return xy(s,t);switch(o){case`both`:return c===2?xy(s,t):V;case`left`:case`right`:return e===o?xy(s,t):V;case`either`:return xy(s,t)}}let u=(e,t,n)=>ab(t)(r,n).pipe(U(e=>e.pipe(U(e=>_y(s,e)),b_)),d_(t=>f_(wh(t),e=>wp(n,e)).pipe(Zg({onFailure:t=>l(e,t),onSuccess:()=>l(e,t)}))),O_(a));return yield*u(`left`,e,Cp(a)),yield*u(`right`,t,Cp(a)),Oy(s)}))),Hb=e=>tb((t,n)=>{let r;return R(z(()=>r||e.pipe(bp(n),U(e=>ab(e)(t,n)),U(e=>r=e))))}),Ub=r(2,(e,t)=>Vb(e,rb(R(U(t,Rf))),{haltStrategy:`either`})),Wb=r(2,(e,t)=>ib((n,r,i)=>xp(i,t).pipe(Tg(ab(e)(n,r))))),Gb=r(2,(e,t)=>Hb(kg(t,e))),Kb=r(2,(e,t)=>nb(e,e=>B(()=>{let n=!0,r=Eg(e,e=>(n=!1,t(e)));return z(()=>n?r:e)}))),qb=r(2,(e,t)=>nb(e,e=>R(yh(e,e=>U(t,()=>Rf(e)))))),Jb=r(2,(e,t)=>Wb(e,e=>t)),Yb=(e,t,n)=>z(()=>{let r=yp();return yh(U(ab(e)(Rf(),r),t),n||R).pipe(p_(e=>wp(r,e)))}),Xb=r(2,(e,t)=>tb((n,r)=>W(t_(ab(e)(n,r),t),t_(t)))),Zb=r(3,(e,t,n)=>tb((r,i)=>W(i_(ab(e)(r,i),t,n),i_(t,n)))),Qb=r(3,(e,t,n)=>tb((r,i)=>U(n,n=>ab(Zb(e,t,n))(r,i)))),$b=r(2,(e,t)=>Yb(e,e=>b_(U(e,t),{disableYield:!0}))),ex=e=>W(tx(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}),tx=r(3,(e,t,n)=>z(()=>{let r=t();return Yb(e,e=>ug({while:o,body:()=>e,step:e=>{r=n(r,e)}}),()=>R(r))})),nx=B_(function*(e){let t=qy(1),n=yield*Qg(),r=O(n,vp);return(yield*ab(e)(Rf(),r)).pipe(t_(n),t.withPermits(1))},Mg(e=>R(_g(e)))),rx=(e,t)=>ab(e)(Rf(),t),ix=`~effect/Stream`,ax={_R:i,_E:i,_A:i},ox=function(e){this.channel=e};ox.prototype={[ix]:ax,pipe(){return e(this,arguments)}};var sx=e=>new ox(e),cx=`~effect/Stream`,lx=e=>v(e,cx),G=sx,ux=e=>dx(B(()=>{let t=!0,n=R(Ai(void 0)),r=Kg(n,e);return z(()=>t?(t=!1,n):r)})),dx=e=>G(rb(e)),fx=e=>e.channel,px=(e,t)=>G(sb(e,t)),mx=G(db),hx=e=>G(ub(Ai(e))),gx=(...e)=>xx(e),_x=e=>{let t=G(cb(()=>e().channel));return vx.set(t,e),t},vx=new WeakMap,yx=e=>G(pb(e)),bx=e=>G(hb(e)),xx=e=>vi(e)?G(ub(e)):mx,Sx=e=>G(vb(e)),Cx=e=>G(bb(e)),wx=e=>G(xb(e)),Tx=G(fb),Ex=e=>G(Hb(W(e,fx))),Dx=r(2,(e,t)=>_x(()=>{let n=0;return G(Cb(e.channel,ji(e=>t(e,n++))))})),Ox=r(e=>lx(e[0]),(e,t,n)=>e.channel.pipe(Mb,Tb(t,n),Cb(Ai),G)),kx=r(e=>lx(e[0]),(e,t,n)=>Ox(e,e=>kg(t(e),e),n)),Ax=r(2,(e,t)=>{let n=G(jb(lb(()=>Mx(e,t))));return jx.set(n,[e,t]),n}),jx=new WeakMap;function*Mx(e,t){let n=[t,e];for(;n.length>0;){let e=n.pop(),t=jx.get(e);if(t!==void 0){n.push(t[1],t[0]);continue}let r=vx.get(e);if(r===void 0)yield e.channel;else{try{n.push(r())}catch(e){n.push(bx(e))}yield db}}}var Nx=r(2,(e,t)=>G(Pb(fx(e),t))),Px=r(e=>lx(e[0]),(e,t,n,r)=>G(Rb(fx(e),t,e=>n(e).channel,r&&(e=>r(e).channel)))),Fx=r(e=>lx(e[0]),(e,t,n,r)=>Px(e,Array.isArray(t)?e=>v(e,`_tag`)&&t.includes(e._tag):_e(t),n,r)),Ix=r(2,(e,t)=>G(zb(e.channel,t))),Lx=r(2,(e,t)=>G(Ub(e.channel,t))),Rx=r(2,(e,t)=>G(Gb(e.channel,t))),zx=r(2,(e,t)=>G(qb(e.channel,t))),Bx=r(2,(e,t)=>G(Jb(e.channel,t))),Vx=r(2,(e,t)=>G(Xb(e.channel,t))),Hx=r(2,(e,t)=>$b(e.channel,e=>{let n=0;return ug({while:()=>n<e.length,body:()=>t(e[n++]),step:l})})),Ux=r(2,(e,t)=>$b(e.channel,t)),Wx=e=>nx(e.channel),Gx=e=>W(ex(e.channel),e=>e.buffer),Kx=r(e=>lx(e[0]),(e,t,n)=>{let r,i,a=!1,o=mv(!1),s=n?.signal,c=()=>i.interruptUnsafe();return new ReadableStream({start(n){i=j_(t_($b(nb(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(kf(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,F_(Ag(ev(i)))}},n?.strategy)}),qx=r(e=>lx(e[0]),(e,t)=>Kx(e,ia(),t)),Jx=r(e=>lx(e[0]),(e,t)=>W(Qg(),n=>Kx(e,n,t)));function Yx(e){return{_tag:`Value`,value:e}}function Xx(e,t){return{_tag:`Record`,keys:e,value:t}}function Zx(e,t){return{_tag:`Array`,length:e,value:t}}var Qx=k(`effect/ConfigProvider`,{defaultValue:()=>oS()}),$x={...Jt,toJSON(){return{_id:`ConfigProvider`}}},eS=e=>e;function tS(e,t){let n=Object.create($x);return n.load=e,n.mapInput=t,n}function nS(e,t){return tS(n=>e(t(n)),n=>nS(e,e=>n(t(e))))}function rS(e){return nS(e,eS)}function iS(e,t){return e===``&&!t?void 0:e}function aS(e,t){let n=t?.preserveEmptyStrings===!0,r=sS(e);return rS(t=>R(cS(r,e,t,n)))}function oS(e){return aS(e?.env??{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`},{preserveEmptyStrings:e?.preserveEmptyStrings})}function sS(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 cS(e,t,n,r){let i=n.map(String).join(`_`),a=iS(Object.hasOwn(t,i)?t[i]:void 0,r),o=lS(e,n),s=o?.children?Object.keys(o.children):[];return s.length===0?a===void 0?void 0:Yx(a):s.every(yi)?Zx(Math.max(...s.map(e=>parseInt(e,10)))+1,a):Xx(new Set(s),a)}function lS(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 uS=`~effect/BigDecimal`,dS={[uS]:uS,[xe](){let e=yS(this);return we(ke(String(e.value)),Oe(e.scale))},[Be](e){return fS(e)&&TS(this,e)===0},toString(){return`BigDecimal(${DS(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[kt](){return this.toJSON()},pipe(){return e(this,arguments)}},fS=e=>v(e,uS),pS=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(dS);return n.value=e,n.scale=t,n},mS=(e,t)=>{let n=pS(e,t);return n.normalized=n,n},hS=BigInt(0),gS=BigInt(1),_S=BigInt(10),vS=mS(hS,0),yS=e=>{if(e.normalized===void 0){if(e.value===hS)e.normalized=vS;else{let t=`${e.value}`,n=bS(t);e.normalized=mS(BigInt(t.slice(0,t.length-n)),e.scale-n)}}return e.normalized},bS=e=>{let t=e.length;for(;e[t-1]===`0`;)t--;return e.length-t},xS=100,SS=[gS],CS=(e,t)=>e===t?0:e<t?-1:1,wS=(e,t)=>{let n=`${e.value<hS?-e.value:e.value}`,r=`${t.value<hS?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==hS)return i<hS?-1:1;let a=Math.max(n.length,r.length);return ur(n.padEnd(a,`0`),r.padEnd(a,`0`))},TS=(e,t)=>{if(e.scale===t.scale)return CS(e.value,t.value);let n=ES(e),r=ES(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>xS)return n===-1?wS(t,e):wS(e,t);let o=SS[a]??=_S**BigInt(a);return i>0?CS(e.value,t.value*o):CS(e.value*o,t.value)},ES=e=>e.value===hS?0:e.value<hS?-1:1,DS=e=>{let t=yS(e);if(Math.abs(t.scale)>=16)return OS(t);let n=t.value<hS,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},OS=e=>{if(kS(e))return`0e+0`;let t=yS(e),n=`${t.value}`,r=t.value<hS?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},kS=e=>e.value===hS,AS=e=>MS(typeof e==`string`?FS.encode(e):e),jS=e=>{let t=LS(e),n=t.length;if(n%4!=0)return Br(new Lo({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 Br(new Lo({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=HS(t.charCodeAt(e))<<18|HS(t.charCodeAt(e+1))<<12|HS(t.charCodeAt(e+2))<<6|HS(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return zr(r)}catch(e){return Br(new Lo({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},MS=e=>{let t=e.length,n=Uint8Array.prototype.toBase64;return t>=32&&typeof n==`function`?n.call(e):t<128?NS(e):PS(e)},NS=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=RS[e[r-2]>>2],n+=RS[(e[r-2]&3)<<4|e[r-1]>>4],n+=RS[(e[r-1]&15)<<2|e[r]>>6],n+=RS[e[r]&63];return r===t+1&&(n+=RS[e[r-2]>>2],n+=RS[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=RS[e[r-2]>>2],n+=RS[(e[r-2]&3)<<4|e[r-1]>>4],n+=RS[(e[r-1]&15)<<2],n+=`=`),n},PS=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]=zS[e[r-2]>>2],n[i+1]=zS[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=zS[(e[r-1]&15)<<2|e[r]>>6],n[i+3]=zS[e[r]&63];return r===t+1&&(n[i]=zS[e[r-2]>>2],n[i+1]=zS[(e[r-2]&3)<<4],n[i+2]=BS,n[i+3]=BS),r===t&&(n[i]=zS[e[r-2]>>2],n[i+1]=zS[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=zS[(e[r-1]&15)<<2],n[i+3]=BS),IS.decode(n)},FS=new TextEncoder,IS=new TextDecoder,LS=e=>e.replace(/[\n\r]/g,``),RS=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,zS=FS.encode(RS),BS=61,VS=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)VS[RS.charCodeAt(e)]=e;VS[61]=0;var HS=e=>{if(e>=VS.length||VS[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return VS[e]},US=ym,WS=Tm,GS=km,KS=Am,qS=zm,JS=Gm,YS=Qm,XS=`~effect/HashMap`,ZS=e=>v(e,XS),QS=`~effect/HashSet`,$S=e=>v(e,QS),eC=`~effect/http/Cookies`,tC=`~effect/http/Cookies/Cookie`,nC={[eC]:eC,...Mt,toJSON(){return{_id:`effect/Cookies`,cookies:ri(this.cookies,e=>e.toJSON())}},pipe(){return e(this,arguments)}},rC=e=>{let t=Object.create(nC);return t.cookies=e,t},iC=e=>{let t={};for(let n of e)b(t,n.name,n);return rC(t)},aC=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=oC(e.trim());t&&n.push(t)}return iC(n)};function oC(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(cC,``);if(!sC.test(r))return;let i=t[0].slice(n+1).replace(cC,``),a=dC(i);if(t.length===1)return Object.assign(Object.create(uC),{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||!lC.test(a))break;o.maxAge=ao(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(uC),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var sC=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,cC=/^[\t ]+|[\t ]+$/g,lC=/^-?[0-9]+$/,uC={[tC]:tC,...Mt,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},dC=e=>{try{return decodeURIComponent(e)}catch{return e}},fC=new WeakMap,pC=e=>{if(fC.has(e))return fC.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},mC=`~effect/Redacted`,hC=e=>v(e,mC),gC=(e,t)=>{let n=Object.create(_C);return t?.label&&(n.label=t.label),fC.set(n,e),n},_C={[mC]:{_A:e=>e},label:void 0,...Jt,toJSON(){return this.toString()},toString(){return`<redacted${re(this.label)?`:`+this.label:``}>`},[xe](){return y(fC.get(this))},[Be](e){return hC(e)&&Ve(fC.get(this),fC.get(e))}},vC=pC,yC=Symbol.for(`~effect/http/Headers`),bC=Object.defineProperties(Object.create(null),{[yC]:{value:yC},[ft]:{value(e){return AC(this,O(e,MC))}},toJSON:{value(){return mt(this)}},[Be]:{value(e){return SC(this,e)}},[xe]:{value(){return je(this)}},toString:{value:Mt.toString},[kt]:{value:Mt[kt]}}),xC=e=>Object.assign(Object.create(bC),e),SC=si(at()),CC=Object.create(bC),wC=e=>{if(e===void 0)return CC;if(Symbol.iterator in e){let t=Object.create(bC);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(bC);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},TC=e=>Object.setPrototypeOf(e,bC),EC=r(3,(e,t,n)=>{let r=xC(e);return r[t.toLowerCase()]=n,r}),DC=r(2,(e,t)=>xC({...e,...wC(t)})),OC=r(2,(e,t)=>{let n=xC(e);return Object.assign(n,t),n}),kC=r(2,(e,t)=>{let n=xC(e);return delete n[t.toLowerCase()],n}),AC=r(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=gC(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=gC(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),jC=(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},MC=k(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),NC=`~effect/http/Headers/HeaderParseError`,PC=class extends Po{},FC=class e extends Fo(`HeaderParseError`){static fromReason(t,n){return new e({reason:new PC({_tag:t,input:n})})}[NC]=NC;get message(){return`${this.reason._tag}: ${JSON.stringify(this.reason.input)}`}},IC=[`jan`,`feb`,`mar`,`apr`,`may`,`jun`,`jul`,`aug`,`sep`,`oct`,`nov`,`dec`],LC=[/^(?: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],RC=e=>{for(let t of LC){let n=t.exec(e)?.groups;if(n===void 0)continue;let r=IC.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}},zC=e=>({_tag:`DateTime`,dateTime:e}),BC=/^\d+$/,VC=BigInt(1e9),HC=e=>{let t=e.trim();if(BC.test(t)){let e=Number(t);return zr({_tag:`Duration`,duration:Number.isSafeInteger(e*1e3)?ao(e):ro(BigInt(t)*VC)})}let n=RC(t);return n===void 0?Br(FC.fromReason(`InvalidRetryAfter`,e)):zr(zC(WS(n)))},UC=(e,t)=>e._tag===`Duration`?e.duration:io(Math.max(0,JS(e.dateTime)-t)),WC=e=>typeof e==`string`?e:vC(e),GC=new TextDecoder(`utf-8`,{ignoreBOM:!0}),KC=e=>new URLSearchParams(GC.decode(e).replace(/^\?/,`%3F`)),qC=`~effect/http/UrlParams`,JC=e=>v(e,qC),YC={...Jt,[qC]:qC,[Symbol.iterator](){return this.params[Symbol.iterator]()},[ft](e){return{_id:`UrlParams`,params:Object.fromEntries(iw(this,O(e,mw)))}},toJSON(){return mt(this)},[Be](e){return ew(this,e)},[xe](){return Ne(this.params.flat())}},XC=e=>{let t=Object.create(YC);return t.params=e,t},ZC=e=>{if(JC(e))return e;let t=QC(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 XC(n)},QC=e=>{let t=typeof e[Symbol.iterator]==`function`?di(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,$C(r[t])]);else if(typeof r==`object`&&r&&!hC(r)){let t=QC(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,$C(r)]);return n},$C=e=>hC(e)?e:String(e),ew=rt((e,t)=>tw(e.params,t.params)),tw=Ii(Jr([at(),nt()])),nw=XC([]),rw=r(2,(e,t)=>{let n=ZC(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 XC(n)}),iw=r(2,(e,t)=>{let n=Array.isArray(t)?t:[t];return e.params.map(([e,t])=>[e,typeof t==`string`&&aw(e,n)?gC(t):t])}),aw=jC,ow=(e,t=pw())=>{e.includes(`@`)&&(e=uw(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)+dw(e.slice(n+1,i),t)+e.slice(i)},sw=/^(?:(https?|ftp|wss?):[/\\]*|[a-z][a-z\d+.-]*:\/\/|[/\\]{2,})/i,cw=/[/\\?#]/,lw=/[/?#]/,uw=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=sw.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?cw:lw),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])},dw=(e,t)=>e.split(`&`).map(e=>{let n=e.indexOf(`=`);return n!==-1&&aw(fw(e.slice(0,n)),t)?e.slice(0,n+1)+`REDACTED`:e}).join(`&`),fw=e=>{if(!e.includes(`%`)&&!e.includes(`+`))return e;try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}},pw=()=>O(globalThis[`~effect/Fiber/currentFiber`]?.context??ia(),mw),mw=k(`effect/http/UrlParams/CurrentRedactedNames`,{defaultValue:()=>[`X-Amz-Signature`,`X-Amz-Credential`,`X-Amz-Security-Token`,`AWSAccessKeyId`,`Signature`,`sig`,`X-Goog-Signature`]});function hw(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var gw=`~structural`,_w=`~sentinels`,vw=`~constructor`,yw=f(e=>{let t=hw(e)?.identifier;return typeof t==`string`?t:e.getExpected(yw)}),K=Symbol(),bw=Kf,xw=bw(K),q=bw(K),Sw=e=>e===K?T():E(e),Cw=e=>e._tag===`None`?xw:bw(e.value),ww=`~effect/SchemaIssue/Issue`;function Tw(e){return v(e,ww)&&e[ww]===ww}function Ew(e){return Object.hasOwn(e,`input`)}var Dw=class{[ww]=ww;constructor(e,t){t?.reportInput===!0&&e!==K&&(this.input=e)}},Ow=class extends Dw{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},kw=class extends Dw{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},Aw=class extends Dw{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},jw=class extends Dw{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},Mw=class extends Dw{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Nw=class extends Dw{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Pw=class extends Dw{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Fw=class extends Dw{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function Iw(e,t,n,r,i){return new Nw(e,[new Aw([t],n)],r,i)}var Lw=class extends Dw{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Rw=class extends Dw{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function zw(e,t,n){if(Tw(e))return e;if(typeof e==`string`)return new Fw({message:e},t,n);let r=typeof e.issue==`string`?new Fw({message:e.issue},t,n):e.issue;return new Aw(e.path,r)}function Bw(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new Fw(void 0,t,n):zw(e,t,n)}function Vw(e,t,n,r){return Array.isArray(t)?vi(t)?t.length===1?zw(t[0],n,r):new Nw(e,ji(t,e=>zw(e,n,r)),n,r):void 0:Bw(t,n,r)}var Hw=e=>{let t=Qw(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return Kw(yw(e.ast),e);case`InvalidValue`:{let t=Gw(e);if(t!==void 0)return Kw(t,e);let n=Ww(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=Ww(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=Ww(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},Uw=e=>Qw(e)??Qw(e.issue);function Ww(e){return Ew(e)?x(e.input):void 0}function Gw(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function Kw(e,t){let n=Ww(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function qw(e,t){let n=t(e);if(n!==void 0||e.issue._tag!==`InvalidValue`)return n;let r=Gw(e.issue);return r===void 0?Kw(Jw(e.filter),e):Kw(r,e.issue)}function Jw(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=>Jw(e)).join(` & `)}}function Yw(){return e=>Zw(e,``)}var Xw=Yw();function Zw(e,t,n){let r;switch(e._tag){case`Filter`:return Zw(e.issue,t,n??qw(e,Uw));case`Encoding`:return Zw(e.issue,t,n);case`Pointer`:return Zw(e.issue,t+xt(e.path),n);case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>Zw(e,t,n)).join(`
14
- `);r=n??Qw(e)??Kw(yw(e.ast),e);break;default:r=n??Hw(e)}return t?`${r}\n at ${t}`:r}function Qw(e){if(e._tag===`Pointer`||e._tag===`Composite`)return;if(e._tag===`Encoding`)return Qw(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 $w(e){let t;for(let n of e.reasons){if(!_f(n)||!Tw(n.error))return;t??=n.error}return t}function eT(e,t){let n=$w(e);if(n===void 0)throw Error(t,{cause:e});return n}var tT=(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)?pg:G_(e.transform(t.value,n),E);case`TransformOptionalEffect`:return e.transform(t,n)}},nT=e=>Object.assign(Object.create(t),e),rT=(e,t)=>uT((n,r)=>J_(tT(e,n,r),e=>tT(t,e,r))),iT=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 sT(n=>t.transform(e.transform(n)));case`TransformOptional`:return lT(n=>t.transform(Ar(n,e.transform)));case`TransformEffect`:return cT((n,r)=>t.transform(e.transform(n),r));case`TransformOptionalEffect`:return rT(e,t)}case`TransformOptional`:switch(t._tag){case`Transform`:return lT(n=>Ar(e.transform(n),t.transform));case`TransformOptional`:return lT(n=>t.transform(e.transform(n)));case`TransformEffect`:case`TransformOptionalEffect`:return rT(e,t)}case`TransformEffect`:switch(t._tag){case`Transform`:return cT((n,r)=>G_(e.transform(n,r),t.transform));case`TransformOptional`:case`TransformOptionalEffect`:return rT(e,t);case`TransformEffect`:return cT((n,r)=>J_(e.transform(n,r),e=>t.transform(e,r)))}case`TransformOptionalEffect`:return rT(e,t)}}),aT=nT({_tag:`Passthrough`});function oT(){return aT}function sT(e){return nT({_tag:`Transform`,transform:e})}function cT(e){return nT({_tag:`TransformEffect`,transform:e})}function lT(e){return nT({_tag:`TransformOptional`,transform:e})}function uT(e){return nT({_tag:`TransformOptionalEffect`,transform:e})}function dT(){return lT(()=>T())}function fT(e){return uT(t=>{let n=Fr(t,le);return br(n)?R(n):G_(e,E)})}function pT(){return sT(globalThis.String)}function mT(){return sT(globalThis.Number)}function hT(e){return cT((t,n)=>bg({try:()=>JSON.parse(t,e?.reviver),catch:()=>new Fw({expected:`a valid JSON string`},t,n)}))}function gT(e){return cT((t,n)=>bg({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 Fw({expected:`a JSON-serializable value`},t,n)}))}function _T(e){let t=e?.separator??`,`,n=e?.keyValueSeparator??`=`,r=e?.trim??!1,i=e?.keepEmptyValues??!1;return sT(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 vT(e){let t=e?.separator??`,`,n=e?.keyValueSeparator??`=`;return sT(e=>Object.entries(e).map(([e,t])=>`${e}${n}${t}`).join(t))}function yT(e){let t=e?.separator??`,`;return sT(e=>e===``?[]:e.split(t))}function bT(){return sT(AS)}function xT(){return cT((e,t)=>K_(Cg(jS(e)),()=>new Fw({expected:`a valid Base64 string`},e,t)))}function ST(){return sT(encodeURIComponent)}function CT(){return cT((e,t)=>{try{return R(globalThis.decodeURIComponent(e))}catch{return H(new Fw({expected:`a valid URI component`},e,t))}})}var wT=Symbol.for(`~effect/Schema/content`);function TT(e,t){return Object.defineProperty(e,wT,{value:t}),e}var ET=class extends n{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new ET(this.encode,this.decode)}},DT=`~effect/SchemaTransformation/Transformation`,OT=class extends n{[DT]=DT;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new OT(this.encode,this.decode)}};function kT(e){return v(e,DT)&&e[DT]===DT}var AT=e=>kT(e)?e:new OT(e.decode,e.encode);function jT(e){return new OT(cT(e.decode),cT(e.encode))}function MT(e){return new OT(sT(e.decode),sT(e.encode))}function NT(e){return new OT(_T(e),vT(e))}var PT=new OT(oT(),oT());function FT(){return PT}var IT=new OT(mT(),pT()),LT=e=>he(e)&&typeof e.message==`string`,RT=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:HT(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},zT=e=>{try{let t=Tt(e);return t===void 0?x(e):JSON.parse(t)}catch{return x(e)}},BT=(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},VT=e=>{let t=new WeakSet,n=r=>{if(ve(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=BT(r,e,n);return t.delete(r),i}return zT(r)};return n},HT=e=>LT(e)?RT(e):e,UT=e=>MT({decode:HT,encode:VT(e)}),WT=new OT(xT(),bT()),GT=new OT(CT(),ST());function KT(e){return new OT(hT(e??{}),TT(gT(e),{mediaType:`application/json`,preserveSchema:e?.reviver===void 0&&e?.replacer===void 0}))}function qT(e){return t=>t._tag===e}var JT=qT(`Declaration`),YT=qT(`Never`),XT=qT(`String`),ZT=qT(`Number`),QT=qT(`Symbol`),$T=qT(`Literal`),eE=qT(`UniqueSymbol`),tE=qT(`Enum`),nE=qT(`TemplateLiteral`),rE=qT(`Arrays`),iE=qT(`Objects`),aE=qT(`Union`),oE=qT(`Suspend`),sE=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},cE={},lE=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}},uE=`~effect/Schema`,dE=class{[uE]=uE;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}>`}},fE=class extends dE{_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 xw;e??=this.run(this.typeParameters);try{return e(t,this,n)}catch(e){return yg(e)}}}_rebuild(e,t,n,r,i){let a=LD(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new fE(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>`}},pE=new class extends dE{_tag=`Null`;getParser(){return eO(this,null)}getExpected(){return`null`}},mE=class extends dE{_tag=`Undefined`;getParser(){return eO(this,void 0)}toCodecJson(){return wD(this,[hE])}getExpected(){return`undefined`}},hE=new sE(pE,new OT(sT(()=>void 0),sT(()=>null))),gE=new mE,_E=new class extends dE{_tag=`Void`;getParser(){let e=bw(void 0);return t=>t===K?xw:e}toCodecJson(){return wD(this,[hE])}getExpected(){return`void`}},vE=new class extends dE{_tag=`Never`;getParser(){return tO(this,fe)}getExpected(){return`never`}},yE=new class extends dE{_tag=`Unknown`;getParser(){return tO(this,pe)}getExpected(){return`unknown`}},bE=class extends dE{_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 eO(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?xE(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:xE(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function xE(e){let t=globalThis.String(e.literal);return wD(e,[new sE(new bE(t),new OT(sT(()=>e.literal),sT(()=>t)))])}var SE=new class extends dE{_tag=`String`;getParser(){return tO(this,re)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&uO(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},CE=class extends dE{_tag=`Number`;getParser(){return tO(this,ie)}matchKey(e,t){return this._match(aO,e,t)}matchPart(e,t){return this._match(iO,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:uO(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(wE(this.checks,`effect/schema/isFinite`)||wE(this.checks,`effect/schema/isInt`))?this:wD(this,[yD])}toCodecStringTree(){return this.toCodecJson()===this?wD(this,[cO]):wD(this,[lO])}getExpected(){return`number`}};function wE(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&wE(e.checks,t))}var TE=new CE,EE=new class extends dE{_tag=`Boolean`;getParser(){return tO(this,ae)}getExpected(){return`boolean`}},DE=class extends dE{_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(KD(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(KD(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 Mw(n,t[o],i),a=new Aw([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return H(new Nw(n,[a],t,i))}return e.issues?H(new Nw(n,e.issues,t,i)):bw(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?AE(i,e,0,u):jE(i,e,{concurrency:d,end:u});if(!f)return c(i);if(L(f))return J_(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 xw;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 Pw(n,e,a))}catch(e){return yg(e)}}}_rebuild(e,t,n){let r=LD(this.elements,e),i=LD(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new DE(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 OE(e,t,n,r){if(n._tag===`Failure`)return ME(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(KD(t.ast))return;let n=new Aw([r],new jw(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return Jf(new Nw(e.ast,[n],e.input,e.options))}}var kE={onItem(e,t,n){let r=n<e.len?t:K;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:OE},AE=Ju()(kE),jE=Xu()(kE),ME=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=$w(r.cause);if(i===void 0)return qf(Of(r.cause,r=>new Nw(t,[new Aw([n],r)],e.input,e.options)));let a=new Aw([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return Jf(new Nw(t,[a],e.input,e.options))},NE=`[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?`;function PE(e,t,n=cE){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(nO(ZD(t)))}var FE=class{name;type;constructor(e,t){this.name=e,this.type=t}};function IE(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(IE);default:return!1}}function LE(e){let t=ED(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(LE);default:return!1}}function RE(e){return IE(e)&&LE(e)}var zE=class{parameter;type;constructor(e,t){if(!RE(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,KD(t)||t.encoding!==void 0&&KD(ZD(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.")}},BE=class extends dE{_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 tO(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(nO(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 ME(t,n,i,s)??Zf;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 Zf;b(t.out,a,c)}return Zf},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!L(t))return U(Og(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return ME(e,n,r,a)??Zf;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(Og(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(Og(a),r=>t(e,n,n,i,r))},u=i?Xu()({onItem:(e,[t,n])=>n.is.parameter===SE?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return X_(function*(t,d){if(t===K)return K;if(typeof t!=`object`||!t||Array.isArray(t))return yield*H(new Pw(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=>PE(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 Mw(n,f[a],d),r=new Aw([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*H(new Nw(n,[r],t,d))}}}if(r){let e=ee===1?UE(m,a):WE(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===SE?l:c,r=_?.[e]??(t.is.parameter===SE?Object.keys(f):PE(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=ki();for(let t=0;t<i;t++){let n=o[t],r=_?.[t]??(n.is.parameter===SE?Object.keys(f):PE(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 Nw(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return U(Og(n),n=>{let i={...e,out:{...e.out}},o=VE(i,r,n);if(o)return o;let s=()=>bw(i.out),c=UE(i,a.slice(t+1));return c?J_(c,s):s()})};return(e,t)=>{if(e===K)return xw;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 Pw(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=rD(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=VE(o,n,d);if(f)return f}}catch(e){return yg(e)}return bw(a)}}_rebuild(e,t,n,r){let i=LD(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new FE(t.name,n)}),a=LD(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new zE(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new BE(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 VE(e,t,n){if(n._tag===`Failure`)return ME(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],!KD(t.type)){let n=new Aw([t.name],new jw(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return Jf(new Nw(e.ast,[n],e.input,e.options))}}var HE={onItem(e,t){if(!rD(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:VE},UE=Ju()(HE),WE=Xu()(HE);function GE(e,t){return e?t?[...e,...t]:e:t}function KE(e,t,n){return new BE(Reflect.ownKeys(e).map(t=>new FE(t,e[t].ast)),[],n,t)}function qE(e){return e.ast}function JE(e,t=void 0){return new DE(!1,e.map(e=>e.ast),[],void 0,t)}function YE(e,t,n){return new aD(e.map(qE),t,void 0,n)}function XE(e){if(e.encoding)throw Error(`mutable does not support encodings`);return new DE(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var ZE=p(e=>{for(;;){if(oE(e))return yE;let t=e.encoding;if(!t)return e.recur?.(ZE,i)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==i))return yE;e=t[t.length-1].to}});function QE(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(QE)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function $E(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[_w];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!KD(t)){if($T(t))return[{key:e.name,literal:t.literal}];if(eE(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!KD(e)){if($T(e))return[{key:t,literal:e.literal}];if(eE(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>$E(ZE(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return $E(e.thunk())}}var eD=new WeakMap,tD=Object.freeze([]),nD=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,rD=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function iD(e){let t=eD.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=ZE(c);if(YT(l))continue;if($T(l)||eE(l)){a??=new Map;let e=$T(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=$E(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=QE(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??tD);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??tD;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=rD(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??tD;if(t)return o}return tD}}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=nD(t);if(!ge(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=rD(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=rD(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=rD(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(nD(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return eD.set(e,t),t}var aD=class extends dE{_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 xw;let i=(o??=iD(n.types))(e,r);if(i.length===0)return H(new Lw(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:L(r)?oD(n,r.cause,e,t):sD(n,r,e,t)}return cD(n,a,i,e,t)}}_rebuild(e,t,n){let r=LD(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new aD(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=ZD(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter($T);if(t.length>0)return`${fD(n.isMutable)}[ ${t.map(t=>e(t)+pD(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>$T(e.type));if(t.length>0)return`{ ${t.map(t=>`${fD(t.type.context?.isMutable)}${bt(t.name)}${pD(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function oD(e,t,n,r){let i=$w(t);return i?Jf(new Lw(e,[i],n,r)):qf(t)}function sD(e,t,n,r){return Mg(t,t=>oD(e,t,n,r))}function cD(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=uD(a,n);if(!o)return a.out?a.out:H(new Lw(e,a.issues??[],r,i));if(L(o))return lD(o,a);let s=!0;return z(()=>s?(s=!1,lD(o,a)):cD(e,t,n,r,i))}function lD(e,t){return J_(e,e=>t.out===q?R(t.input):t.out?t.out:H(new Lw(t.ast,t.issues??[],t.input,t.options)))}var uD=Ju()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=$w(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]),Jf(new Rw(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return Zf}}}),dD=new aD([new bE(`Infinity`),new bE(`-Infinity`),new bE(`NaN`)]);function fD(e){return e?``:`readonly `}function pD(e){return e?`?`:``}var mD=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 mD(this.run,{...this.annotations,...e},this.aborted)}abort(){return new mD(this.run,this.annotations,!0)}and(e,t){return new hD([this,e],t)}},hD=class extends n{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new hD(this.checks,{...this.annotations,...e})}and(e,t){return new hD([this,e],t)}};function gD(e,t,n=!1){return new mD((t,n,r)=>Vw(n,e(t,n,r),t,r),t,n)}function _D(e){return gD(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 vD=kD(TE,[_D()]),yD=new sE(new aD([vD,dD]),new OT(mT(),sT(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function bD(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return gD(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 xD=new WeakMap;function SD(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&xD.set(n,CD(e)),n}function CD(e){let t=xD.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 xD.set(e,n),n}function wD(e,t){return e.encoding===t?e:SD(e,{encoding:t})}function TD(e,t){if(e.context===t)return e;let n=CD(e);return n.context===t&&n.encoding===e.encoding?n:SD(e,{context:t})}function ED(e){return e.encoding?ED(e.encoding[e.encoding.length-1].to):e}function DD(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return OD(e,mi(e.checks.slice(0,-1),n.annotate(t)))}return SD(e,{annotations:{...e.annotations,...t}})}function OD(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:SD(e,{checks:t})}function kD(e,t){return OD(e,GE(e.checks,t))}function AD(e,t){let n=t(e.to);return n===e.to?e:new sE(n,e.transformation)}function jD(e,t){let n=e,r=n[n.length-1],i=AD(r,t);return i===r?e:mi(e.slice(0,e.length-1),i)}function MD(e){return t=>t.encoding?wD(t,jD(t.encoding,e)):t}function ND(e,t){return MD(e=>TD(e,t))(e)}function PD(e){function t(n){return n.encoding?wD(n,jD(n.encoding,t)):e(n)}return f(t)}function FD(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:wD(r,jD(r.encoding,n))}return e(r)}return p(n)}function ID(e,t,n){let r=new sE(e,t);return wD(n,n.encoding?[...n.encoding,r]:[r])}function LD(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 RD(e,t){return TD(e,e.context?new lE(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new lE(!1,!1,void 0,t))}var zD=p(e=>BD(TD(e,e.context?e.context.isOptional===!1?new lE(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new lE(!0,!1)))),BD=MD(zD),VD=f(e=>zD(new aD([e,gE])));function HD(e,t){return TD(e,e.context?new lE(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new lE(!1,!1,t))}function UD(e,t,n){return ID(e,n,t)}function WD(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 GD(e,t){let{literals:n,parameters:r}=WD(e);return new BE(n.map(e=>new FE(e,t)),r.map(e=>new zE(e,t)))}function KD(e){return e.context?.isOptional??!1}function qD(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(qD)}function JD(e){function t(e){return qD(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return _i(n)?n:void 0}function YD(e){let t=!0;function n(e){return t=t&&!e.encoding&&!oE(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var XD=p(e=>{let t=CD(e);if(t!==e){let n=XD(t);return n===t&&e.encoding===void 0?e:TD(n,e.context)}let n=`recur`in e?e.recur(XD):e;if(`encodingChecks`in n&&n.encodingChecks){let t=YD(e)?n.encodingChecks:rE(n)||iE(n)||JT(n)&&n.typeParameters.length>0?JD(n.encodingChecks):void 0;return SD(n,{encodingChecks:void 0,checks:GE(n.checks,t)})}return n}),ZD=p(e=>XD($D(e)));function QD(e,t){let n=t,r=n.length,i=n[r-1],a=[new sE($D(wD(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new sE($D(n[e-1].to),n[e].transformation.flip()));let o=$D(i.to);return o.encoding?wD(o,[...o.encoding,...a]):wD(o,a)}var $D=f(e=>{if(e.encoding)return QD(e,e.encoding);let t=CD(e);if(t!==e){let n=$D(t);return n===t?e:TD(n,e.context)}return`flip`in e?e.flip($D):`recur`in e?e.recur($D):e});function eO(e,t){let n=t===0?q:bw(t);return(r,i)=>r===K?xw:r===t?n:H(new Pw(e,r,i))}function tO(e,t){return(n,r)=>n===K?xw:t(n)?q:H(new Pw(e,n,r))}var nO=FD(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(nO)}}),rO=FD(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(rO)}}),iO=new globalThis.RegExp(`^${NE}$`),aO=new globalThis.RegExp(`^(?:${NE}|Infinity|-Infinity|NaN)$`);function oO(e){return bD(iO,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:iO.source}),...e})}var sO=kD(SE,[oO()]),cO=new sE(sO,IT),lO=new sE(new aD([sO,dD]),IT);function uO(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=uO(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 Ow(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function dO(e){if(!JT(e))return;let t=e.annotations?.[vw];return ce(t)?t(e.typeParameters):void 0}function fO(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function pO(e){return e===void 0||typeof e==`string`}function mO(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 hO(e){return mO(e,fO)}var gO=new fE([],()=>(e,t,n)=>hO(e)?q:H(new Pw(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>bO}),_O=new sE(gO,FT()),vO=new sE(new aD([new DE(!1,[],[gO]),new BE([],[new zE(SE,gO)])]),FT());function yO(e){return mO(e,pO)}var bO=new sE(new fE([],()=>(e,t,n)=>yO(e)?q:H(new Pw(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),FT()),xO=(e,t,n)=>e===q?n(t):J_(e,n);function SO(e){let t=CO(e);return(e,n,r)=>{try{return t(e,n,r)}catch(e){return yg(e)}}}function CO(e){if(e._tag===`Middleware`)return(t,n,r)=>wO(t===q?e.decode(bw(Sw(n)),r):e.decode(G_(t,Sw),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===q?bw(t):e;case`Transform`:{let e=e=>e===K?xw:bw(t.transform(e));return(t,n)=>xO(t,n,e)}case`TransformOptional`:{let e=e=>Cw(t.transform(Sw(e)));return(t,n)=>xO(t,n,e)}case`TransformEffect`:return(e,n,r)=>xO(e,n,e=>e===K?xw:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>xO(e,n,e=>wO(t.transform(Sw(e),r)))}}var wO=e=>J_(e,Cw),TO=(e,t,n,r)=>Mg(r,r=>vg(()=>Of(r,r=>new kw(e,r,t,n))));function EO(e,t){let n=SO(e.link.transformation),r;return(i,a)=>{if(i===K)return xw;if(e.isConstructed(i))return q;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function DO(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 J_(TO(e,r,i,a),e=>{let n=t(e,i);return n===q?bw(e):n})}}function OO(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:DO(e,n)}function kO(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?dO(e):void 0,o=a?EO(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>SO(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=uO(u,t,void 0,e,n);i&&(r=H(new Nw(e,i,t,n)))}}}else r=U(r,r=>{if(t!==K&&r!==K){let r=uO(u,t,void 0,e,n);if(r)return H(new Nw(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=uO(s,i,void 0,e,n);a&&(r=H(new Nw(e,a,i,n)))}}else r=U(r,t=>{if(t!==K){let r=uO(s,t,void 0,e,n);if(r)return H(new Nw(e,r,t,n))}return R(t)})}return r}catch(e){return yg(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=J_(o,e=>{let n=t(e,r);return n===q?bw(e):n})}if(o._tag===`Success`){let e=o[S],t=p(e,r);return t===q?o:t}return o=TO(e,n,r,o),J_(o,e=>{let t=p(e,r);return t===q?bw(e):t})}:p}var AO=Symbol(),jO=new WeakMap,MO=e=>IO(e).parser,NO=e=>IO(e).makeEffect,PO=e=>OO(e,NO),FO=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=kO(this.ast,MO)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=kO(this.ast,NO,PO)}};function IO(e){let t=jO.get(e);if(t!==void 0)return t;let n=new FO(e);return jO.set(e,n),n}function LO(e){let t=e.ast,n;return(e,r)=>(n??=QO(lk,XD(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function RO(e){let t=LO(e);return(e,n)=>{let r=z_(t(e,n));return Qf(r)?E(r.value):(eT(r.cause,`Option adapter can only return none for schema issues`),T())}}function zO(e){return ak(XD(e.ast))}function BO(e){return HO(e.ast)}function VO(e){{let t=$O(XO(e));return e=>{let n=t(e,cE);return Qf(n)?!0:(eT(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function HO(e){let t=XD(e),n=e=>(n=VO(t),n(e));return e=>n(e)}function UO(e,t){let n=XO(e.ast);return t===void 0?n:(e,r)=>n(e,JO(t,r))}function WO(e,t){return ek(UO(e,t))}var GO=WO;function KO(e,t){return tk(UO(e,t))}function qO(e,t){let n=XO($D(e.ast));return t===void 0?n:(e,r)=>n(e,JO(t,r))}var JO=(e,t)=>t?{...e,...t}:e,YO=e=>e===K?H(new Fw):R(e);function XO(e){return QO(ck,e)}function ZO(e,t){return e===q?R(t):L(e)?e[`~effect/Effect/args`]===K?YO(K):e:J_(e,YO)}function QO(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??cE);return a===q?R(r):L(a)?a[`~effect/Effect/args`]===K?YO(K):a:J_(a,YO)}}function $O(e){return(t,n)=>z_(e(t,n))}function ek(e){let t=$O(e);return(e,n)=>{let r=t(e,n);return Qf(r)?E(r.value):(eT(r.cause,`Option adapter can only return none for schema issues`),T())}}function tk(e){let t=$O(e);return(e,n)=>{let r=t(e,n);return Qf(r)?zr(r.value):Br(eT(r.cause,`Result adapter can only return schema issues`))}}function nk(e,t){let n=z_(e);if(Qf(n))return n.value;let r=eT(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:Sf(e)})}function ak(e){let t;return(n,r)=>ok(t??=IO(e),n,r)}function ok(e,t,n){let r=n?.disableChecks?n.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions??cE,i=e.make;if(i!==void 0&&t!==K){let e;try{e=i(t,r)}catch(e){ik(e)}if(e!==AO&&e!==K)return e}return nk(ZO(e.makeEffect(t,r),t),rk)}function sk(e,t,n,r){let i=IO(e),a=dO(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??IO)(a.link.to),t,n);try{return r(o)}catch(e){ik(e)}}var ck=e=>IO(e).parser,lk=e=>IO(e).makeEffect,uk=`~effect/Schema/Schema`,dk=Symbol(),fk={[uk]:uk,get make(){let e=zO(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=LO(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=RO(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return e(this,arguments)},annotate(e){return this.rebuild(DD(this.ast,e))},annotateKey(e){return this.rebuild(RD(this.ast,e))},check(...e){return this.rebuild(kD(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=TD(t,void 0),i=e(n,r);return i===n?null:i}),r=FD(e=>{let t=n(CD(e));if(t===null)return e;let r=TD(t,e.context);return e.context===void 0?r:ND(r,_k(e.context))},t);return r}function _k(e){return e.constructorDefault===void 0?e:new lE(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(ZD(t))-e(ZD(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 wD(e,[_O]);let r=n(e.typeParameters.map(e=>pk(ZD(e))));return r===void 0?e:wD(e,[AD(r,t)])}case`Unknown`:return wD(e,[_O]);case`ObjectKeyword`:return wD(e,[vO]);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,rO);case`Union`:{let n=bk(e.types);return n===e.types?e.recur(t):new aD(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(ZD(e)))),i=e.annotations?.toCodecStringTree;if(ce(i)){let n=i(r);return n===void 0?e:wD(e,[AD(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):wD(e,[AD(c,t)])}case`Null`:return wD(e,[Tk]);case`Boolean`:return wD(e,[Ek]);case`Unknown`:case`ObjectKeyword`:return wD(e,[bO]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return vk(e),e.recur(t,rO);case`Union`:{let n=Ck(e.types);return n===e.types?e.recur(t):new aD(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 sE(new bE(`null`),new OT(sT(()=>null),sT(()=>`null`))),Ek=new sE(new aD([new bE(`true`),new bE(`false`)]),new OT(sT(e=>e===`true`),pT())),Dk=new OT(sT(e=>typeof e==`string`?[e]:e),oT()),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=r(2,(e,t)=>Nk(e,(e,n)=>Mk(t,e)?[e,n]:void 0)),Ak=r(2,(e,t)=>Nk(e,(e,n)=>Mk(t,e)?void 0:[e,n])),jk=e=>e;function Mk(e,t){return e.some(e=>e===t||typeof e==`number`&&String(e)===t)}function Nk(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let i=t(r,e[r]);if(i){let[e,t]=i;b(n,e,t)}}return n}var Pk=`~effect/Schema/SchemaError`;function Fk(e){return v(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var Ik=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},Lk=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 Rk=uk;function zk(){return(e,t,n)=>J(new fE(e.map(qE),e=>t(e.map(e=>J(e))),n))}function Bk(e,t){return zk()([],()=>(t,n,r)=>e(t)?R(t):H(new Pw(n,t,r)),t)}var Vk=class extends Fo(`SchemaError`){[Pk]=Pk;constructor(e){let t=Ft();It(0);try{super({issue:e})}finally{It(t)}}get message(){return Xw(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[kt](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function Hk(e){return Fk(e)}function Uk(e){return L(e)?Wk(e):Mg(e,e=>vg(()=>Of(e,e=>new Vk(e))))}function Wk(e){return Qf(e)?e:qf(Of(e.cause,e=>new Vk(e)))}function Gk(e,t){let n;for(let r of e.reasons){if(!_f(r)||!Hk(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 Kk(e){let t=z_(e);if(Qf(t))return t.value;throw Gk(t.cause,`Sync adapter can only throw schema errors`)}var qk=BO;function Jk(e,t){let n=UO(e,t);return(e,t)=>Uk(n(e,t))}var Yk=Jk,Xk=GO;function Zk(e,t){let n=KO(e,t);return(e,t)=>Gr(n(e,t),e=>new Vk(e))}function Qk(e,t){let n=Jk(e,t);return(e,t)=>Kk(n(e,t))}var $k=Qk;function eA(e,t){let n=qO(e,t);return(e,t)=>Uk(n(e,t))}var tA=eA;function nA(e,t){let n=eA(e,t);return(e,t)=>Kk(n(e,t))}var rA=nA,J=pk;function iA(e){return v(e,Rk)&&e[Rk]===Rk}var aA=jk(e=>J(zD(e.ast),{schema:e})),oA=jk(e=>{let t=AA(e);return J(VD(e.ast),{schema:t})}),sA=jk(e=>J(XD(e.ast),{schema:e})),cA=jk(e=>J(ZD(e.ast),{schema:e}));function lA(e){let t=J(new bE(e),{literal:e,transform(n){return t.pipe(jA(lA(n),{decode:sT(()=>n),encode:sT(()=>e)}))}});return t}var uA=J(vE),dA=J(yE),fA=J(pE),pA=J(gE),mA=J(SE),hA=J(TE),gA=J(EE),_A=J(_E);function vA(e,t){return J(e,{fields:t,mapFields(e,t){let n=e(this.fields);return vA(KE(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function yA(e){return vA(KE(e,void 0),e)}function bA(e,t){return J(GD(e.ast,t.ast),{key:e,value:t})}function xA(e,t){return J(e,{elements:t,mapElements(e,t){let n=e(this.elements);return xA(JE(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function SA(e){return xA(JE(e),e)}var CA=jk(e=>J(new DE(!1,[],[e.ast]),{value:e})),wA=jk(e=>J(new DE(!1,[e.ast],[e.ast]),{value:e})),TA=jk(e=>J(XE(e.ast),{schema:e}));function EA(e,t){return J(e,{members:t,mapMembers(e,t){let n=e(this.members);return EA(YE(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function DA(e,t){return EA(YE(e,t,void 0),e)}function OA(e){let t=e.map(lA);return J(YE(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=jk(e=>DA([e,fA])),AA=jk(e=>DA([e,pA]));function jA(e,t){return n=>J(UD(n.ast,e.ast,t?AT(t):FT()),{from:n,to:e})}function MA(e){return t=>J(HD(t.ast,e),{schema:t})}function NA(e){return L(e)&&e._tag===`Success`?e:Mg(e,e=>vg(()=>Of(e,e=>e.issue)))}function PA(e,t){let n=t?.encodingStrategy===`omit`?dT():oT();return t=>aA(cA(t)).pipe(jA(t,{decode:fT(NA(e)),encode:n}))}function FA(e){return lA(e).pipe(MA(R(e)))}function IA(e,t){return yA({_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(aE(s)&&`members`in t&&globalThis.Array.isArray(t.members)&&t.members.every(iA))return t.members.forEach(o);let c=$E(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,BO(sA(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 Bk(t=>t instanceof e,t)}function BA(){return(e,t)=>new sE(e.ast,AT(t))}var VA=gD;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 bD(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var UA=J(vD);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=hA.check(WA());function KA(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})`}),[gw]:!0,arbitraryConstraint:{minLength:e},...n})}function qA(e){return KA(1,1,e)}function JA(e,t){return e=YA(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})`}),[gw]:!0,arbitraryConstraint:{maxLength:e},...t})}function YA(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var XA=mA.check(qA()),ZA=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),QA=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},$A=[];function ej(e){let t=ZA(e),n=$A[t];if(n!==void 0)return n;let r=Cj.pipe(jA(dA,UT(QA(t))));return $A[t]=r,r}globalThis.RegExp,globalThis.URL;var tj=mA.annotate({expected:`a string that will be decoded as JSON`});function nj(e,t){return tj.pipe(jA(e,KT(t)))}globalThis.File,globalThis.URLSearchParams;var rj=mA.annotate({expected:`a URI component encoded string that will be decoded as a UTF-8 string`}).pipe(jA(mA,GT)),ij=mA.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),aj=zA(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>BA()(ij,WT)});function oj(e,t){return J(zk()([e,t],([e,t])=>(n,r,i)=>{if(!gf(n))return H(new Pw(r,n,i));switch(n._tag){case`Fail`:return q_(UO(e)(n.error,i),{onSuccess:wf,onFailure:e=>Iw(r,`error`,e,n,i)});case`Die`:return q_(UO(t)(n.defect,i),{onSuccess:Tf,onFailure:e=>Iw(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([yA({_tag:lA(`Fail`),error:e}),yA({_tag:lA(`Die`),defect:t}),yA({_tag:lA(`Interrupt`),fiberId:AA(UA)})]),MT({decode:e=>{switch(e._tag){case`Fail`:return wf(e.error);case`Die`:return Tf(e.defect);case`Interrupt`:return Ef(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 sj(e,t){return J(zk()([e,t],([e,t])=>{let n=CA(oj(e,t));return(e,t,r)=>hf(e)?q_(UO(n)(e.reasons,r),{onSuccess:bf,onFailure:n=>Iw(t,`reasons`,n,e,r)}):H(new Pw(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()(CA(oj(e,t)),MT({decode:bf,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}function cj(e,t,n){return J(zk()([e,t,n],([e,t,n])=>{let r=sj(t,n);return(t,n,i)=>{if(!Gf(t))return H(new Pw(n,t,i));switch(t._tag){case`Success`:return q_(UO(e)(t.value,i),{onSuccess:Kf,onFailure:e=>Iw(n,`value`,e,t,i)});case`Failure`:return q_(UO(r)(t.cause,i),{onSuccess:qf,onFailure:e=>Iw(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([yA({_tag:lA(`Success`),value:e}),yA({_tag:lA(`Failure`),cause:sj(t,n)})]),MT({decode:e=>e._tag===`Success`?Kf(e.value):qf(e.cause),encode:e=>Qf(e)?{_tag:`Success`,value:e.value}:{_tag:`Failure`,cause:e.cause}}))}).ast,{value:e,error:t,defect:n})}function lj(e){return J(zk()([e],([e])=>(t,n,r)=>vr(t)?yr(t)?pg:q_(UO(e)(t.value,r),{onSuccess:E,onFailure:e=>Iw(n,`value`,e,t,r)}):H(new Pw(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([yA({_tag:lA(`Some`),value:e}),yA({_tag:lA(`None`)})]),MT({decode:e=>e._tag===`None`?T():E(e.value),encode:e=>br(e)?{_tag:`Some`,value:e.value}:{_tag:`None`}}))}).ast,{value:e})}var uj=globalThis.Symbol.for(`immer-draftable`),dj={};function fj(t,n,r,i,a){let o=gj(r,n,i),s=hj(n),c=class extends t{constructor(...[e,t]){let n=t?.[`~payload`],i=n?.token===dj?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:dj,value:i}})}static[Rk]=Rk;get[s](){return s}static[uj]=!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(XD(o(this).ast),e??{},t,e=>pj(this,e))}static makeOption(e,t){return RO(o(this))(e??{},t)}static makeEffect(e,t){return o(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(DD(this.ast,e))}static annotateKey(e){return this.rebuild(RD(this.ast,e))}static check(...e){return this.rebuild(kD(this.ast,e))}static extend(e){return(t,n)=>{let i=_j(t)?t:yA(t),o={...r.fields,...i.fields},s=KE(o,r.ast.checks,{identifier:e});return fj(this,e,vA(kD(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 pj(e,t){return new e(t,{"~payload":{token:dj,value:t}})}function mj(e){return new OT(sT(t=>pj(e,t)),oT())}function hj(e){return`~effect/Schema/Class/${e}`}function gj(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=hj(t),o=e=>e instanceof i||v(e,a),s=mj(i);return r=jA(J(new fE([e.ast],()=>(e,t,n)=>o(e)?R(e):H(new Pw(t,e,n)),{identifier:t,[vw]:([e])=>({isConstructed:o,link:new sE(e,s)}),toCodec:([e])=>new sE(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[_w]:$E(e.ast),...n})),s)(e)}}function _j(e){return iA(e)}var vj=e=>(t,n)=>fj(No,e,_j(t)?t:yA(t),n,e=>({toString(){return`${e}(${x({...this})})`}})),yj=e=>(t,n)=>fj(An,e,_j(t)?t:yA(t),n,e=>({name:e})),bj=e=>(t,n,r)=>{let i=_j(n)?n.mapFields(e=>({_tag:FA(t),...e}),{unsafePreserveChecks:!0}):IA(t,n);return yj(e??t)(i,r)},xj=mk,Sj=Sk,Cj=J(DD(gO,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})}));function wj(e){return hw(e.ast)}var Tj=`~effect/Config`,Ej=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Dj={...zi({label:`Config`,evaluate(e){return this.parse(e.getRef(Qx))}}),[Tj]:Tj,toJSON(){return{_id:`Config`}}};function Oj(e){let t=Object.create(Dj);return t.evaluator=e,t.parse=t=>J_(e(t,[]),Cg),t}var kj=(e,t,n)=>e.evaluator(t,n),Aj=r(2,(e,t)=>Oj((n,r)=>W(kj(e,n,r),Kr(t)))),jj=r(2,(e,t)=>Oj((n,r)=>G_(kj(e,n,r),e=>D(e)?zr(t):e))),Mj=e=>e.pipe(Aj(E),jj(T())),Nj=e=>_e(e,`SourceError`),Pj=()=>`<configuration>`,Fj=e=>t=>Mg(t,t=>_g(bf(t.reasons.map(e)))),Ij=(e,t)=>e.load(t).pipe(Fj(e=>_f(e)?Tf(e.error).annotate(Vf(e)):e),G_(n=>({provider:e,path:t,node:n,toString:Pj}))),Lj=(e,t)=>Ij(e.provider,[...e.path,t]),Rj=(e,t)=>UD(yE,e,new OT(cT(e=>t(e)),oT())),zj=e=>{switch(e._tag){case`Union`:return e.types.every(zj);case`Objects`:case`Arrays`:case`Suspend`:return!1;default:return!0}},Bj=(e,t)=>{switch(e._tag){case`Objects`:return t?._tag===`Record`;case`Arrays`:return t?._tag===`Array`;case`Union`:return e.types.some(e=>Bj(e,t));case`Suspend`:return Bj(e.thunk(),t);default:return t?.value!==void 0}},Vj=f(e=>{let t=new WeakSet,n=PD(e=>{switch(t.add(e),e._tag){case`Objects`:{let t=B_(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 PE(t,n.parameter))typeof e==`string`&&r.add(e)}let i={};for(let e of r){let n=yield*Lj(t,e);n.node!==void 0&&b(i,e,n)}return i});return Rj(e.recur(n,e=>e),t)}case`Arrays`:{let t=B_(function*(e){if(e.node?._tag!==`Array`)return;let t=[];for(let n=0;n<e.node.length;n++)t.push(yield*Lj(e,n));return t});return Rj(e.recur(n),t)}case`Union`:for(let t of e.types)n(t);if(!zj(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 Rj(e,e=>R(e.node?.value))});return n(e)});function Hj(e,t){let n=Sj(e),r=ZD(n.ast),i=UO(J(Vj(n.ast))),a=typeof t==`string`?[t]:t??[];return Oj((e,t)=>{let n=[...t,...a];return Ij(e,n).pipe(J_(e=>i(e).pipe(G_(zr),Y_(t=>{let i=new Ej(new Vk(n.length>0?new Aw(n,t):t));return Bj(r,e.node)?H(i):R(Br(i))}))),Fj(e=>vf(e)&&Nj(e.defect)?wf(new Ej(e.defect)).annotate(Vf(e)):e))})}var Uj=e=>re(e)||globalThis.Array.isArray(e);function Wj(e){return Hj(mA,e)}function Gj(e,t,n){let r=Uj(t),i=r?n:t,a=CA(e),o=i?.separator??`,`;return Hj(DA([mA.pipe(jA(Sj(a),{decode:yT(i),encode:iT(oT({strict:!1}),sT(e=>e.join(o)))})),a]),r?t:void 0)}function Kj(e,t,n,r){let i=Uj(n),a=bA(e,t),o=NT(i?r:n);return Hj(DA([a,mA.pipe(jA(Sj(a),{decode:o.decode,encode:iT(oT({strict:!1}),o.encode)}))]),i?n:void 0)}var qj={"~effect/Match/Matcher":{_input:i,_filters:i,_result:i,_return:i,_flavor:i},_tag:`ValueMatcher`,add(e){return Ur(this.value)?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?Jj(this.provided,zr(e.evaluate(this.provided))):this},pipe(){return e(this,arguments)}};function Jj(e,t){let n=Object.create(qj);return n.provided=e,n.value=t,n}var Yj=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),Xj=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(Xj),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,Xj(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},Zj=e=>Jj(e,Br(e)),Qj=(e,t)=>n=>n.add(Yj(Xj(e),t)),$j=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(Yj(i,n))},eM=e=>t=>{let n=Yj(n=>n!=null&&Object.hasOwn(t,n[e]),n=>t[n[e]](n));return e=>e.add(n)},tM=e=>t=>{let n=eM(e)(t);return e=>sM(n(e))},nM=$j(`_tag`),rM=tM(`_tag`),iM=e=>t=>{let n=aM(t);return Hr(n)?n._tag===`Success`?n.success:e(n.failure):(...t)=>{let r=n(...t);return Ur(r)?r.success:e(r.failure,...t)}},aM=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?zr(t.evaluate(r,...n)):Br(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 zr(t.evaluate(r,...n))}return Br(r)}},oM=`effect/match/Match/exhaustive: absurd`,sM=e=>{let t=aM(e);if(Hr(t)){if(Ur(t))return t.success;throw Error(oM)}return(...e)=>{let n=t(...e);if(Ur(n))return n.success;throw Error(oM)}},cM=Zj,lM=Qj,uM=nM,dM=rM,fM=iM,pM={"~effect/Ref":{_A:i},...Jt,toJSON(){return{_id:`Ref`,ref:this.ref}}},mM=e=>{let t=Object.create(pM);return t.ref=vv(e),t},hM=r(2,(e,t)=>B(()=>{let[n,r]=t(e.ref.current);return e.ref.current=r,n})),gM=r(2,(e,t)=>B(()=>e.ref.current=t(e.ref.current))),_M=`~effect/http/HttpBody`,vM=`~effect/http/HttpBody/HttpBodyError`,yM=class extends Fo(`HttpBodyError`){[vM]=vM},bM=class{[_M];constructor(){this[_M]=_M}[kt](){return this.toJSON()}toString(){return x(this,{ignoreToString:!0})}},xM=new class extends bM{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},SM=class extends bM{_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??=EM(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}}},CM=(e,t)=>new SM(e,t??`application/octet-stream`,e.length),wM=new TextEncoder,TM=globalThis.Buffer,EM=TM===void 0?e=>wM.encode(e):e=>TM.from(e,`utf8`),DM=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),TM!==void 0)return new SM(void 0,t??`text/plain`,TM.byteLength(e,`utf8`),e);let n=wM.encode(e);return new SM(n,t??`text/plain`,n.length,e)},OM=(e,t)=>bg({try:()=>DM(JSON.stringify(e),t??`application/json`),catch:e=>new yM({reason:{_tag:`JsonError`},cause:e})}),kM=(e,t)=>{let n=qO(xj(e));return(e,r)=>n(e,t).pipe(Fg(e=>new yM({reason:{_tag:`SchemaError`,issue:e},cause:e})),U(e=>OM(e,r)))},AM=class extends bM{_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}}},jM=(e,t,n)=>new AM(e,t??`application/octet-stream`,n),MM=`~effect/http/HttpClientError`,NM=e=>v(e,MM),PM=class extends Fo(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[MM]=MM;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},FM=e=>e.endsWith(`Error`)?e.slice(0,-5):e,IM=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,LM=e=>`${e.method} ${ow(e.url)}`,RM=(e,t)=>({...t,request:{_id:`HttpClientRequest`,method:e.request.method,url:ow(e.request.url)},...`response`in e?{response:{_id:`HttpClientResponse`,status:e.response.status}}:void 0}),zM=class extends Fo(`TransportError`){get methodAndUrl(){return LM(this.request)}get message(){return IM(FM(this._tag),this.description,this.methodAndUrl)}toJSON(){return RM(this,super.toJSON())}},BM=class extends Fo(`EncodeError`){get methodAndUrl(){return LM(this.request)}get message(){return IM(FM(this._tag),this.description,this.methodAndUrl)}toJSON(){return RM(this,super.toJSON())}},VM=class extends Fo(`InvalidUrlError`){get methodAndUrl(){return LM(this.request)}get message(){return IM(FM(this._tag),this.description,this.methodAndUrl)}toJSON(){return RM(this,super.toJSON())}},HM=class extends Fo(`StatusCodeError`){get methodAndUrl(){return LM(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return IM(FM(this._tag),this.description,e)}toJSON(){return RM(this,super.toJSON())}},UM=class extends Fo(`DecodeError`){get methodAndUrl(){return LM(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return IM(FM(this._tag),this.description,e)}toJSON(){return RM(this,super.toJSON())}},WM=class extends Fo(`EmptyBodyError`){get methodAndUrl(){return LM(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return IM(FM(this._tag),this.description,e)}toJSON(){return RM(this,super.toJSON())}},GM=class e extends yj(MM)({_tag:FA(`HttpError`),kind:OA([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:oA(ej())}){static fromHttpClientError(t){return new e({_tag:`HttpError`,kind:t.reason._tag,cause:t.reason})}},KM=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],qM=e=>t=>t.pipeThrough(new CompressionStream(e)),JM=e=>new ReadableStream({start(t){t.enqueue(e),t.close()}}),YM=(e,t,n)=>e._tag!==`Uint8Array`&&e._tag!==`Stream`||e.contentLength!==void 0&&e.contentLength<(n?.minSize??1024)?R(e):e._tag===`Uint8Array`?W(dg(()=>new globalThis.Response(qM(t)(JM(e.body))).arrayBuffer()),t=>CM(new Uint8Array(t),e.contentType)):R(jM(wx({evaluate:()=>qM(t)(qx(e.stream)),onError:i}),e.contentType)),XM=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?kC(kC(e,`content-type`),`content-length`):(e=t.contentType===void 0?kC(e,`content-type`):EC(e,`content-type`,t.contentType),ZM(e,t)),ZM=(e,t)=>{let n=t._tag===`Empty`||t._tag===`FormData`?void 0:t.contentLength;return n===void 0?kC(e,`content-length`):EC(e,`content-length`,n.toString())},QM=class extends Fo(`UrlError`){},$M=(e,t,n)=>Vr({try:()=>{let r=new URL(e,eN());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,WC(i))}return n!==void 0&&(r.hash=n),r},catch:e=>new QM({cause:e})}),eN=()=>{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}}},tN=(e,t)=>Vr({try:()=>new URL(e,t),catch:()=>new Bf(`Invalid URL: "${e}"${t===void 0?``:` with base "${t}"`}`)}),nN=`~effect/http/HttpClientRequest`,rN=e=>v(e,nN),iN={[nN]:nN,...Mt,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:ow(this.url),urlParams:this.urlParams,hash:this.hash,headers:mt(this.headers),body:this.body.toJSON()}},pipe(){return e(this,arguments)}};function aN(e,t,n,r,i,a){let o=Object.create(iN);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var oN=aN(`GET`,``,nw,T(),CC,xM),sN=e=>(t,n)=>lN(oN,{method:e,url:t,...n??void 0}),cN=sN(`POST`),lN=r(2,(e,t)=>{let n=e;return t.method&&(n=uN(n,t.method)),t.url&&(n=hN(n,t.url)),t.headers&&(n=fN(n,t.headers)),t.urlParams&&(n=gN(n,t.urlParams)),t.hash&&(n=_N(n,t.hash)),t.body&&(n=vN(n,t.body)),t.accept&&(n=pN(n,t.accept)),t.acceptJson&&(n=mN(n)),n}),uN=r(2,(e,t)=>aN(t,e.url,e.urlParams,e.hash,e.headers,e.body)),dN=r(3,(e,t,n)=>aN(e.method,e.url,e.urlParams,e.hash,EC(e.headers,t,n),e.body)),fN=r(2,(e,t)=>aN(e.method,e.url,e.urlParams,e.hash,DC(e.headers,t),e.body)),pN=r(2,(e,t)=>dN(e,`Accept`,t)),mN=pN(`application/json`),hN=r(2,(e,t)=>{if(typeof t==`string`)return aN(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=ZC(n.searchParams),i=wr(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,aN(e.method,n.toString(),r,i,e.headers,e.body)}),gN=r(2,(e,t)=>aN(e.method,e.url,rw(e.urlParams,t),e.hash,e.headers,e.body)),_N=r(2,(e,t)=>aN(e.method,e.url,e.urlParams,E(t),e.headers,e.body)),vN=r(2,(e,t)=>aN(e.method,e.url,e.urlParams,e.hash,XM(e.headers,t),t)),yN=r(e=>rN(e[0]),(e,t,n)=>e.headers[`content-encoding`]===void 0?W(YM(e.body,t,n),n=>n===e.body?e:aN(e.method,e.url,e.urlParams,e.hash,EC(ZM(e.headers,n),`content-encoding`,t),n)):R(e)),bN=(e,t)=>{let n=kM(e,t);return r(2,(e,t)=>W(n(t),t=>vN(e,t)))};function xN(e){let t=$M(e.url,e.urlParams,Dr(e.hash));return Ur(t)?E(t.success):T()}var SN=`~effect/http/HttpIncomingMessage`,CN=(e,t)=>{let n=Yk(xj(e)),r=t?.reviver===void 0?void 0:Yk(nj(xj(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))},wN=(e,t)=>({...t,headers:mt(e.headers),remoteAddress:e.remoteAddress}),TN=`~effect/http/HttpClientResponse/WebSource`,EN=e=>e[TN]?.(),DN=`~effect/http/HttpClientResponse`,ON=(e,t)=>new AN(e,t),kN=e=>e.status>=200&&e.status<300?R(e):H(new PM({reason:new HM({response:e,request:e.request,description:`non 2xx status code`})})),AN=class extends Nt{[SN];[DN];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[SN]=SN,this[DN]=DN}toJSON(){return wN(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=xN(this.request);return yr(e)?``:(e.value.hash=``,e.value.href)}get headers(){return wC(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=aC(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return T()}[TN](){return this.source}get stream(){return this.source.body?wx({evaluate:()=>this.source.body,onError:e=>new PM({reason:new UM({request:this.request,response:this,cause:e})})}):yx(new PM({reason:new WM({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return U(this.text,e=>bg({try:()=>e===``?null:JSON.parse(e),catch:e=>new PM({reason:new UM({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=>bg({try:()=>ZC(KC(e)),catch:e=>new PM({reason:new UM({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=fg({try:()=>this.source.formData(),catch:e=>new PM({reason:new UM({request:this.request,response:this,cause:e})})}).pipe(m_,L_)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=fg({try:()=>this.source.arrayBuffer(),catch:e=>new PM({reason:new UM({request:this.request,response:this,cause:e})})}).pipe(m_,L_),this.arrayBufferBody}get upgrade(){return H(new PM({reason:new HM({request:this.request,response:this,description:`fetch cannot hand over the connection of an HTTP upgrade`})}))}pipe(){return e(this,arguments)}},jN=e=>TC({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`}`}),MN={"http:":80,"https:":443,"ws:":80,"wss:":443},NN=(e,t,n)=>{let r=ow(t.search,n).slice(1);if(e.attribute(`url.full`,ow(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===``?MN[t.protocol]:Number(t.port);n!==void 0&&e.attribute(`server.port`,n)}},PN=(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()]},FN=(e,t,n,r,i)=>{for(let a in n)r(a,t)&&e.attribute(`http.${t}.header.${a}`,jC(a,i)?`<redacted>`:n[a])},IN=`~effect/http/HttpClient`,LN=Vi(`effect/HttpClient`),RN=(e=>(...t)=>U(LN,n=>n[e](...t)))(`get`),zN=r(2,(e,t)=>VN(n=>t(e.postprocess(n)),e.preprocess)),BN=zN(U(kN)),VN=(e,t)=>{let n=Object.create(HN);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},HN={[IN]:IN,pipe(){return e(this,arguments)},...Mt,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(KM.map(([e,t])=>[t,function(t,n){return this.execute(sN(e)(t,n))}]))},UN=e=>VN(t=>U(t,t=>Sg(n=>{let r=tP.get(t),i=r??new AbortController,a=$M(t.url,t.urlParams,Dr(t.hash));if(D(a))return H(new PM({reason:new VM({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(Ko)||n.getRef(YN)(t)){let a=e(t,o,i.signal,n);return r?W(a,e=>rP(e,i,!0)):y_(e=>Zg(e(a),{onSuccess(e){return R(rP(e,i,!1))},onFailure(e){return Mf(e)&&i.abort(),_g(e)}}))}return w_(n.getRef(QN)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method);let s=n.getRef(MC);NN(a,o,PN(t.urlParams,n.getRef(mw)));let c=n.getRef(XN);return FN(a,`request`,t.headers,c,s),t=n.getRef(ZN)?fN(t,jN(a)):t,y_(l=>l(e(t,o,i.signal,n)).pipe(E_(a,{captureStackTrace:!1}),Zg({onSuccess:e=>(a.attribute(`http.response.status_code`,e.status),FN(a,`response`,e.headers,c,s),e.status>=400&&e.status<600&&(a.attribute(`error.type`,String(e.status)),WN(n,a,t,e)),R(rP(e,i,r!==void 0))),onFailure(e){return!r&&Mf(e)&&i.abort(),_g(e)}})))})})),R),WN=(e,t,n,r)=>{let i=Ft();It(0);let a;try{a=Jf(new PM({reason:new HM({request:n,response:r})}))}finally{It(i)}t.end(e.getRef(_p)?e.getRef(Hf).currentTimeNanosUnsafe():BigInt(0),a)},GN=r(2,(e,t)=>{let n=kh(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,a=cP(n?t:t.schedule??Uh),o=n?void 0:t.times;return zN(e,d(r===`errors-only`?i:x_({schedule:a,times:o,while:lP}),r===`response-only`?i:zg({while:n||t.while===void 0?aP:be(aP,t.while),schedule:a,times:o})))}),KN=(e,t)=>{if(t===void 0)return;let n=HC(t);return Ur(n)?ho(UC(n.success,e),io(1)):void 0},qN=r(2,(e,t)=>zN(e,Eg(t))),JN=r(2,(e,t)=>zN(e,Lg(t))),YN=k(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>s}),XN=k(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>s}),ZN=k(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:o}),QN=k(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>e.method}),$N=e=>Gp(LN)($g(t=>W(e,e=>zN(e,r_(e=>ga(t,e)))))),eP=(()=>{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))}}})(),tP=new WeakMap,nP=new WeakMap,rP=(e,t,n)=>(n||(eP.register(e,t),e=new iP(e,t)),nP.set(e,t),e),iP=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[DN]=DN;[SN]=SN;applyInterrupt(e){return z(()=>(eP.unregister(this.original),__(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)}[TN](){let e=EN(this.original);return e!==void 0&&eP.unregister(this.original),e}get stream(){return _x(()=>(eP.unregister(this.original),Bx(this.original.stream,B(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[kt](){return this.original[kt]()}pipe(){return e(this,arguments)}},aP=e=>zf(e)||oP(e),oP=e=>NM(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&lP(e.reason.response)),sP=(e,t)=>KN(t,(NM(e)?e.response:v(e,`~effect/http/HttpClientResponse`)?e:void 0)?.headers[`retry-after`]),cP=e=>Ah(W(Nh(e),e=>(t,n)=>{let r=sP(n,t);return r===void 0?e(t,n):W(e(t,n),([e,t])=>[e,ho(t,r)])})),lP=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,uP=k(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),dP=k(`effect/http/FetchHttpClient/StreamBodyFallback`,{defaultValue:()=>`error`}),fP=class extends Vi()(`effect/http/FetchHttpClient/RequestInit`){},pP,mP=()=>{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}},hP=$N(R(UN((e,t,n,r)=>{if(e.headers.upgrade!==void 0)return H(new PM({reason:new zM({request:e,description:`fetch cannot send an HTTP upgrade request`})}));let i=r.getRef(uP),a=la(r.context,fP)??{},o=a.headers?OC(wC(a.headers),e.headers):e.headers;o[`content-length`]&&(o=kC(o,`content-length`));let s,c=B(()=>s?.abort()),l=r=>W(fg({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 PM({reason:new zM({request:e,cause:t})})}),t=>{let n=ON(e,t);return s?(t.body===null&&s.abort(),Object.create(n,{...Object.fromEntries([`arrayBuffer`,`text`,`json`,`formData`,`urlParamsBody`].map(e=>[e,{get:()=>u_(n[e],c)}])),stream:{get:()=>Bx(n.stream,c)}})):n}).pipe(d_(()=>c));switch(e.body._tag){case`Raw`:case`Uint8Array`:return l(e.body.body);case`FormData`:return l(e.body.formData);case`Stream`:if(pP??=mP(),pP){s=new AbortController;let t=AbortSignal.any([n,s.signal]),r=mg(e=>{let n=()=>e(h_);if(t.aborted)n();else return t.addEventListener(`abort`,n,{once:!0}),B(()=>t.removeEventListener(`abort`,n))});return U(Jx(Lx(e.body.stream,r)),l)}return r.getRef(dP)===`error`?H(new PM({reason:new BM({request:e,description:`Streaming request bodies are not supported in this runtime`})})):Gx(e.body.stream).pipe(Fg(t=>new PM({reason:new BM({request:e,cause:t})})),U(l))}return l(void 0)}))),gP=`~effect/FiberSet`,_P=e=>v(e,gP),vP={[gP]:gP,[Symbol.iterator](){return this.state._tag===`Closed`?$r():this.state.backing[Symbol.iterator]()},...Jt,toJSON(){return{_id:`FiberSet`,state:this.state}}},yP=(e,t)=>{let n=Object.create(vP);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},bP=()=>c_(B(()=>yP(new Set,rp())),e=>z(()=>{let t=e.state;if(t._tag===`Closed`)return V;e.state={_tag:`Closed`};let n=t.backing;return tv(n).pipe(mp(e.deferred))})),xP=-1,SP=bo(So(Pf,xo(xP))),CP=r(e=>_P(e[0]),(e,t,n)=>{e.state._tag===`Closed`?t.interruptUnsafe(xP):e.state.backing.has(t)||(e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),$f(r)&&(n?.propagateInterruption===!0?!SP(r.cause):!Df(r.cause))&&pp(e.deferred,r))}))}),wP=function(){let e;return()=>(e===void 0&&(e=j_(h_)),e)}(),TP=function(){let e=arguments[0];if(!sg(arguments[1])){let t=arguments[1];return n=>EP(e,n,t)}return EP(e,arguments[1],arguments[2])},EP=(e,t,n)=>Sg(r=>{if(e.state._tag===`Closed`)return B(wP);let i=$u(r,t,n?.startImmediately??!0,!0);return CP(e,i,n),R(i)}),DP=e=>()=>W(Qg(),t=>{let n=M_(t);return(t,r)=>{if(e.state._tag===`Closed`)return wP();let i=n(t,r);return CP(e,i,r),i}}),OP=e=>ug({while:()=>e.state._tag===`Open`&&e.state.backing.size>0,body:()=>Z_(Yr(e)),step:l}),kP=`4.1.2`,AP=()=>kP,jP=e=>{let t=e===void 0?void 0:HC(e);return t===void 0||D(t)?R(ao(5)):W(Hf,e=>UC(t.success,e.currentTimeMillisUnsafe()))},MP=Uh.pipe(Bh,Fh(({output:e})=>NM(e)&&e.reason._tag===`StatusCodeError`&&e.reason.response.status===429?jP(e.reason.response.headers[`retry-after`]):R(ao(1)))),NP=class extends Vi()(`effect/observability/OtlpExporter/Flusher`){},PP=Up(NP,()=>{let e=new Set;return{flush:z(()=>e.size===0?V:lg(e,i,{concurrency:`unbounded`,discard:!0})),register:t=>U(vp,n=>(e.add(t),Sp(n,B(()=>e.delete(t)))))}}),FP=B_(function*(e){let t=yield*Qg(),n=O(t,Hf),r=O(t,vp),i=ho(Ba(e.exportInterval),eo),a=O(t,LN).pipe(qN(e=>Vg(e.arrayBuffer)),JN(e=>e.response?Vg(e.response.arrayBuffer):V),BN,zN(i_(ZN,!1)),GN({schedule:MP,times:3})),o=`OTel-OTLP-Exporter-JavaScript-Effect-${e.label}/${AP()}`,s=wC(e.headers),c=s[`user-agent`],l=EC(s,`user-agent`,c?`${c} ${o}`:o),u=cN(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=vN(u,n);return(e.compression===`gzip`?yN(i,`gzip`).pipe(U(a.execute)):a.execute(i)).pipe(Tg(r),Ag,S_(!1))}).pipe(Mg(e=>p===void 0?(p=n.currentTimeMillisUnsafe()+6e4,f=[],U_(`Disabling exporter for 60 seconds`,e)):V),W_({package:`@effect/opentelemetry`,module:e.label})),g=yield*bP(),ee=yield*DP(g)();yield*Sp(r,z(()=>p===void 0?(ee(h),OP(g)):V).pipe(Vg,g_,Wg(e.shutdownTimeout)));let _=yield*hv(d),te=yield*hv(),ne=B(()=>{d||f.length>0||!_.closeUnsafe()||te.openUnsafe()});yield*gg(function*(){for(;;)te.closeUnsafe(),yield*_.await,yield*Jg(qg(i),te.await),yield*Z_(yield*TP(g,h)),yield*ne}).pipe(O_(r));let re=Tg(h,ne);return yield*(yield*NP).register(re),{push(t){m()||(f.push(t),e.maxBatchSize!==`disabled`&&f.length>=e.maxBatchSize?ee(re):_.openUnsafe())}}}),IP=tf,LP=af,RP=(e,t)=>Gp(IP,w(xc(function*(n){let r=new Set(t?.mergeWithExisting===!0?n.getRef(tf):[]);for(let t of e)r.add(Xt(t)?yield*t:t);return r}))),zP=`window`in globalThis||`importScripts`in globalThis,BP=e=>({attributes:HP(Object.entries({"telemetry.sdk.name":`effect`,"telemetry.sdk.language":zP?`webjs`:`nodejs`,"telemetry.sdk.version":AP(),...e.attributes,...e.serviceName?{"service.name":e.serviceName}:void 0,...e.serviceVersion?{"service.version":e.serviceVersion}:void 0})),droppedAttributesCount:0}),VP=B_(function*(e){let t=yield*Kj(rj,rj,`OTEL_RESOURCE_ATTRIBUTES`,{trim:!0,keepEmptyValues:!0}).pipe(jj(void 0)),n=e?.serviceName??e?.attributes?.[`service.name`]??(yield*Hj(AA(mA),`OTEL_SERVICE_NAME`))??t?.[`service.name`]??(yield*Wj(`OTEL_SERVICE_NAME`)),r=e?.serviceVersion??e?.attributes?.[`service.version`]??(yield*Hj(AA(mA),`OTEL_SERVICE_VERSION`))??t?.[`service.version`],i={...t,...e?.attributes};return delete i[`service.name`],delete i[`service.version`],BP({serviceName:n,serviceVersion:r,attributes:i})},Ig),HP=e=>{let t=[];for(let[n,r]of e)t.push({key:n,value:WP(r)});return t},UP=2**63,WP=e=>{if(Array.isArray(e))return{arrayValue:{values:e.map(WP)}};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>=-UP&&e<UP?{intValue:Number.isSafeInteger(e)?e:String(BigInt(e))}:{doubleValue:e};case`boolean`:return{boolValue:e};default:return{stringValue:x(e)}}},GP=class extends Vi()(`effect/observability/OtlpSerialization`){};function KP(e,t){return typeof t==`number`&&!Number.isFinite(t)?String(t):e===`bytesValue`&&this[e]instanceof Uint8Array?AS(this[e]):t}var qP=e=>{let t=JSON.stringify(e);return DM(t.includes(`null`)||t.includes(`"bytesValue":`)?JSON.stringify(e,KP):t,`application/json`)},JP=Bp(GP,{traces:e=>qP(e),metrics:e=>qP(e),logs:e=>qP(e)}),YP=B_(function*(e){let t=yield*GP,n=yield*VP(e.resource),r={name:`effect`,version:AP()},i=yield*FP({label:`OtlpLogger`,url:e.url,headers:e.headers,compression:e.compression,maxBatchSize:e.maxBatchSize??1e3,exportInterval:e.exportInterval??ao(1),body:e=>[t.logs({resourceLogs:[{resource:n,scopeLogs:[{scope:r,logRecords:e}]}]}),V],shutdownTimeout:e.shutdownTimeout??ao(3)}),a={excludeLogSpans:e.excludeLogSpans??!1,clock:yield*Hf};return LP(e=>{i.push(QP(e,a))})}),XP=e=>RP([YP(e)],{mergeWithExisting:e.mergeWithExisting??!0}).pipe(tm(PP)),ZP=BigInt(1e6),QP=(e,t)=>{let n=t.clock.currentTimeNanosUnsafe().toString(),r=e.date.getTime(),i=(BigInt(r)*ZP).toString(),a={...e.fiber.getRef(hp)};if(a[`effect.fiberId`]=e.fiber.id,!t.excludeLogSpans)for(let[t,n]of e.fiber.getRef(gp))a[`effect.log_span.${t}`]=r-n;let o=Ff(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=fi(e.message),c={severityNumber:$P(e.logLevel),severityText:e.logLevel,timeUnixNano:i,observedTimeUnixNano:n,attributes:HP(Object.entries(a)),body:WP(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},$P=e=>{switch(e){case`Trace`:return eF.SEVERITY_NUMBER_TRACE;case`Debug`:return eF.SEVERITY_NUMBER_DEBUG;case`Info`:return eF.SEVERITY_NUMBER_INFO;case`Warn`:return eF.SEVERITY_NUMBER_WARN;case`Error`:return eF.SEVERITY_NUMBER_ERROR;case`Fatal`:return eF.SEVERITY_NUMBER_FATAL;default:return eF.SEVERITY_NUMBER_UNSPECIFIED}},eF={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},tF=d(B_(function*(e){let t=yield*VP(e.resource),n=yield*GP,r={name:`effect`,version:AP()},i=yield*FP({label:`OtlpTracer`,url:e.url,headers:e.headers,compression:e.compression,exportInterval:e.exportInterval??ao(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??ao(3)});function a(e){e.sampled&&i.push(rF(e))}return Go({span(e){return new nF(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})}),Gp(Xo),tm(PP)),nF=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:Ro(32)}get spanId(){return this._spanId??=Ro(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)}},rF=e=>{let t=e.status,n=e._attributes===void 0?[]:HP(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?HP(Object.entries(a)):[],droppedAttributesCount:0})}let i;if(t.exit._tag===`Success`)i={code:iF.Ok};else if(Df(t.exit.cause))i={code:iF.Unset},n.push({key:`effect.fiber.interrupted`,value:{boolValue:!0}});else{let e=Ff(t.exit.cause,{includeCauseInStack:!0});i=e.length>0?{code:iF.Error,message:e[0].message}:{code:iF.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:HP(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:aF[e.kind],startTimeUnixNano:String(t.startTime),endTimeUnixNano:String(t.endTime),attributes:n,droppedAttributesCount:0,events:r,droppedEventsCount:0,status:i,links:a,droppedLinksCount:0}},iF={Unset:0,Ok:1,Error:2},aF={unspecified:0,internal:1,server:2,client:3,producer:4,consumer:5},oF=`~effect/reactivity/AsyncResult`,sF=e=>v(e,oF),cF={[oF]:{E:i,A:i},pipe(){return e(this,arguments)},[Be](e){if(!sF(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))}},lF=e=>e.waiting,uF=e=>e._tag===`Success`?_F(e.value):yF(e.cause),dF=(e,t)=>e._tag===`Success`?_F(e.value):bF(e.cause,{previous:t}),fF=e=>e._tag===`None`?hF(!0):SF(e.value),pF=e=>e._tag===`Initial`,mF=e=>e._tag!==`Initial`,hF=(e=!1)=>{let t=Object.create(cF);return t._tag=`Initial`,t.waiting=e,t},gF=e=>e._tag===`Success`,_F=(e,t)=>{let n=Object.create(cF);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},vF=e=>e._tag===`Failure`,yF=(e,t)=>{let n=Object.create(cF);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??T(),n.waiting=t?.waiting??!1,n},bF=(e,t)=>yF(e,{previousSuccess:jr(t.previous,e=>gF(e)?E(e):vF(e)?e.previousSuccess:T()),waiting:t.waiting}),xF=(e,t)=>bF(xf(e),t),SF=r(e=>sF(e[0]),(e,t)=>{if(e.waiting)return t?.touch?CF(e):e;let n=Object.assign(Object.create(cF),e);return n.waiting=!0,t?.touch&&gF(n)&&(n.timestamp=Date.now()),n}),CF=e=>gF(e)?_F(e.value,{waiting:e.waiting}):e,wF=r(2,(e,t)=>e._tag===`Failure`?bF(e.cause,{previous:t,waiting:e.waiting}):e),TF=e=>e._tag===`Success`?E(e.value):e._tag===`Failure`?Ar(e.previousSuccess,e=>e.value):T(),EF=r(2,(e,t)=>Sr(TF(e),t)),DF=e=>kr(TF(e),()=>new If(`AsyncResult.getOrThrow: no value found`)),OF=e=>e._tag===`Failure`?jf(e.cause):T(),kF=e=>{switch(e._tag){case`Success`:return Kf(e.value);case`Failure`:return qf(e.cause);default:return Jf(new If)}},AF=r(2,(e,t)=>{switch(e._tag){case`Initial`:return e;case`Failure`:return yF(e.cause,{previousSuccess:Ar(e.previousSuccess,e=>_F(t(e.value),e)),waiting:e.waiting});case`Success`:return _F(t(e.value),e)}}),jF=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(!sF(o))b(r,a,o);else{if(vF(o))return yF(o.cause,{previousSuccess:MF(n,t),waiting:o.waiting});if(!gF(o))return o;b(r,a,o.value),o.waiting&&(i=!0)}}return _F(r,{waiting:i})},MF=(e,t)=>{let n=t?[]:{};for(let t=0;t<e.length;t++){let[r,i]=e[t];if(!sF(i)){b(n,r,i);continue}let a=TF(i);if(yr(a))return T();b(n,r,a.value)}return E(_F(n))},NF=e=>{let t=e.success??uA,n=e.error??uA,r=zk()([t,sj(n,ej())],([e,t])=>(n,r,i)=>{if(!sF(n))return H(new Pw(r,n,i));switch(n._tag){case`Initial`:return R(n);case`Success`:return q_(UO(e)(n.value,i),{onSuccess:e=>_F(e,n),onFailure:e=>Iw(r,`value`,e,n,i)});case`Failure`:{let a=n.previousSuccess.pipe(Ar(t=>q_(UO(e)(t.value,i),{onSuccess:e=>E(_F(e,t)),onFailure:e=>new Nw(r,[new Aw([`previousSuccess`,`value`],e)],n,i)})),Sr(()=>pg)),o=K_(UO(t)(n.cause,i),e=>Iw(r,`cause`,e,n,i));return J_(a,e=>G_(o,t=>yF(t,{previousSuccess:e,waiting:n.waiting})))}}},{expected:`AsyncResult`,toCodec([e,t]){let n=IA(`Success`,{value:e,waiting:gA,timestamp:GA});return BA()(DA([IA(`Initial`,{waiting:gA}),n,IA(`Failure`,{cause:t,previousSuccess:lj(n),waiting:gA})]),MT({decode:e=>{switch(e._tag){case`Initial`:return hF(e.waiting);case`Success`:return _F(e.value,{waiting:e.waiting,timestamp:e.timestamp});case`Failure`:return yF(e.cause,{previousSuccess:Ar(e.previousSuccess,e=>_F(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})},PF=`~effect/reactivity/Reactivity`,FF=Vi(`effect/reactivity/Reactivity`),IF=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;HF(e,e=>n.add(e)),t(n)},r=e=>$g(t=>{let r=la(t,LF);return r?HF(e,e=>{r.add(e)}):n(e),V}),i=(e,t)=>Eg(t,r(e)),a=(t,n)=>{let r=[];return HF(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)=>gg(function*(){let n=yield*Qg(),r=O(n,vp),i=yield*hy(),o=d(M_(n),rv(r)),s=!1,c=!1,l=!1,u=e=>{e._tag===`Failure`?(l=!0,c=!1,s=!1,p(),Sy(i,e.cause)):(vy(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*Sp(r,B(p)),f(),i}),s=(e,t)=>o(e,t).pipe(W(Sx),Ex),c=e=>z(()=>{let n=new Set;return e.pipe(i_(LF,n),p_(e=>B(()=>t(n))))});return FF.of({[PF]:PF,mutation:i,query:o,stream:s,invalidateUnsafe:n,invalidate:r,registerUnsafe:a,withBatch:c})}),LF=class extends Vi()(`effect/reactivity/Reactivity/PendingInvalidation`){},RF=r(2,(e,t)=>FF.use(n=>n.mutation(t,e))),zF=e=>FF.use(t=>t.invalidate(e)),BF=Gp(FF)(IF);function VF(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return y(e)}}var HF=(e,t)=>{if(Array.isArray(e))for(let n=0;n<e.length;n++)t(VF(e[n]));else for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${VF(r[e])}`)}},UF=`~effect/SubscriptionRef`,WF=e=>v(e,UF);({...Jt});var GF=e=>Cx(e.pubsub),KF=e=>B(()=>e.value),qF=(e,t)=>{e.value=t,Uv(e.pubsub,t)},JF=r(2,(e,t)=>e.semaphore.withPermit(B(()=>qF(e,t)))),YF=(e,t)=>!sF(e)||!sF(t)?!0:pF(t)?pF(e):gF(e)&&gF(t)?t.timestamp>=e.timestamp:!0,XF=`~effect/reactivity/AtomRegistry`,ZF=e=>v(e,XF),QF=e=>new sI(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),$F=Vi(XF),eI=r(e=>ZF(e[0]),(e,t,n)=>{let r=n?.suspendOnWaiting??!1;return mg(n=>{let i=e.get(t);if(i._tag!==`Initial`&&!(r&&i.waiting))return n(kF(i));let a=e.subscribe(t,e=>{e._tag!==`Initial`&&!(r&&e.waiting)&&(n(kF(e)),a())});return B(a)})}),tI={immediate:!0},nI=e=>{e()},rI={};function iI(e,t){let n=rI;for(let r of e)try{t(r)}catch(e){n===rI&&(n=e)}if(n!==rI)throw n}var aI=`~effect-atom/atom/Atom/Serializable`,oI=e=>aI in e?e[aI].key:e,sI=class{[XF];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(e,t,n,r){if(this[XF]=XF,this.scheduler=new ko(`sync`,t),this.schedulerAsync=new ko(`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&cI.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,tI)}atomHasTtl(e){return!e.keepAlive&&e.idleTTL!==0&&(e.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(e){let t=oI(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[aI],a;try{a=i.decode(r)}catch(e){if(Hk(e))return n;throw e}let o=e;for(;o.initialValueTarget;)o=o.initialValueTarget;let s=o===e?n:this.ensureNode(o);YF(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 uI(this,e)}invalidateAtom=e=>{let t=this.ensureNode(e);t.skipInitialRun=!1,t.invalidate()};scheduleAtomRemoval(e){this.dispatcher.scheduleTask(()=>{let t=this.nodes.get(oI(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(oI(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(oI(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),iI(t,this.removeIdleNode)}removeIdleNode=e=>{if(this.nodeTimeoutBucket.delete(e),e.canBeRemoved){this.nodes.delete(oI(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=lI.removed;iI(e,this.destroyNode)}destroyNode=e=>{e.remove(),this.onNodeRemoved?.(e)};dispose(){this.disposed=!0,this.reset()}},cI={alive:1,initialized:2,waitingForValue:4},lI={uninitialized:cI.alive|cI.waitingForValue,stale:cI.alive|cI.initialized|cI.waitingForValue,valid:cI.alive|cI.initialized,removed:0},uI=class{constructor(e,t){this.registry=e,this.atom=t,this.writeContext=new mI(e,this)}registry;atom;state=lI.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 lI.uninitialized:return`uninitialized`;case lI.stale:return`stale`;case lI.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&cI.waitingForValue)!==0;)this.build();return this._value}build(){let e=pI(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&cI.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.skipInitialRun&&(this.keptParents=Array.from(this.parents,e=>[e,e.lifetime])),this.failed=!1,this.state=lI.valid):this.setValue(t)),e.failure!==rI)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!==lI.valid)throw e;return t.failure===rI&&(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&cI.initialized)===0?T():E(this._value)}setInitialValue(e,t=!1){(this.state&cI.initialized)===0?(this.preserveInitialValueOnBuild=!0,this.skipInitialRun=t,this.state=lI.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&cI.initialized)!==0;if(this.state=lI.valid,n&&this.atom.equals(this._value,e)){t&&this.invalidateChildren();return}this._value=e;let r=rI;try{(n||t)&&this.invalidateChildren()}catch(e){r=e}if(this.listeners.size>0)try{this.announce()}catch(e){r===rI&&(r=e)}if(r!==rI)throw r}announce(){gI.phase===hI.collect?gI.notify.add(this):this.notify()}invalidate(){if(this.state===lI.valid){this.state=lI.stale;try{this.disposeLifetime()}finally{this.propagate()}}else this.building&&gI.phase!==hI.collect?this.build():this.propagate()}propagate(){gI.phase===hI.collect?(this.building&&(this.invalidatedDuringBuild=!0),gI.stale.push(this)):this.isObserved?this.value():this.invalidateChildren()}invalidateChildren(){if(this.children.size===0)return;let e=rI;for(let t of Array.from(this.children))if(t.affectedBy(this))try{t.invalidate()}catch(t){e===rI&&(e=t)}if(e!==rI)throw e}affectedBy(e){if(this.state===lI.valid)return!0;let t=this.lifetime?.reads;return t===void 0?this.isObserved&&e.state===lI.valid:t.has(e)}notify(){gI.phase===hI.commit&&gI.notify.delete(this),iI(this.listeners,nI)}disposeLifetime(){let e=this.lifetime;e!==void 0&&(this.lifetime=void 0,e.dispose())}remove(){let e=this.isObserved;this.state=lI.removed,this.listeners.clear();try{this.disposeLifetime()}finally{let t=Array.from(this.parents);this.parents.clear(),iI(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)}}},dI=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&&!pF(n._value)&&(r===void 0||r.every(([e,t])=>e.lifetime===t))},fI={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 hg;switch(n._tag){case`Initial`:return hg;case`Failure`:return qf(n.cause);case`Success`:return R(n.value)}},resultOnce(e,t){return mg(n=>{let r=this.once(e);if(r._tag!==`Initial`&&!(t?.suspendOnWaiting&&r.waiting))return n(kF(r));let i=this.node.registry.subscribe(e,e=>{e._tag===`Initial`||t?.suspendOnWaiting&&e.waiting||(i(),n(kF(e)))},{immediate:!1});return B(i)})},setResult(e,t){return this.disposed?hg:(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`?hg:R(t.value)},someOnce(e){return mg(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?mx:px(n=>B(()=>{this.subscribe(e,e=>vy(n,e),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(Nx(mF),Ox(e=>e._tag===`Success`?R(e.value):_g(e.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0,iI(e.reverse(),nI)}},pI=e=>{function t(n){return t.disposed||t.isFn?e.registry.get(n):e.readTracked(n,t)}return Object.setPrototypeOf(t,fI),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t.reads=new Set,t.failure=rI,t},mI=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()}},hI={disabled:0,collect:1,commit:2},gI={phase:hI.disabled,depth:0,stale:[],notify:new Set};function _I(e){let t=gI.phase;gI.phase=hI.collect,gI.depth++;let n=rI;try{e()}catch(e){n=e}if(gI.depth===1){let{notify:e,stale:t}=gI,r=0;do{for(gI.phase=hI.collect;r<t.length;r++)try{vI(t[r])}catch(e){n===rI&&(n=e)}gI.phase=hI.commit;for(let t of e)try{t.notify()}catch(e){n===rI&&(n=e)}}while(r<t.length);gI.stale=[],e.clear()}if(gI.depth--,gI.phase=t,n!==rI)throw n}function vI(e){if(e.state===lI.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=lI.stale,e.disposeLifetime()}e.value()}var yI=`~effect/reactivity/Atom`,bI=e=>v(e,yI),xI=`~effect/reactivity/Atom/Writable`,SI=r(2,(e,t)=>{let n=Ba(t),r=Xa(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?oo(n):void 0})}),CI=SI(0),wI={[yI]:yI,equals:Object.is,...Jt,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},TI={...wI,atom(e,t){let n=NI(e,t);return kI(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):wF(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>EI(this,e,t):EI(this,e,t)},pull(e,t){let n=CI(II(0));return $I(n,kI(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?RI(r,QI(r,n,e,t),hF(!0),a.value):wF(a,i)}))},subscriptionRef(e){return KI(CI(kI(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return wF(r,n);let i=typeof e==`function`?e(t):e;return WF(i)?i:RI(t,i,hF(!0),r.value)})),(e,t)=>GI(e,t,DF(e(this))))}},EI=(e,t,n)=>{let[r,i,a]=ZI(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return sg(i)?RF(i,n.reactivityKeys):zx(i,zF(n.reactivityKeys))}:t,n);return AI(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):wF(i,n)},i)},DI={...wI,[xI]:xI},OI=e=>xI in e,kI=(e,t)=>{let n=Object.create(wI);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},AI=(e,t,n)=>{let r=Object.create(DI);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function jI(e,t){e.setSelf(t)}var MI=(e,t)=>{let n=NI(e,t);return`~effect/reactivity/Atom`in n?n:kI(n)},NI=(e,t)=>{if(typeof e==`function`&&!sg(e)&&!lx(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:PI in i?LI(e,i,t,r):FI in i?UI(e,i,t,r):i;default:return i}}}return sg(e)?function(n,r){return LI(n,e,t,r)}:lx(e)?function(n,r){return UI(n,e,t,r)}:II(e)},PI=`~effect/Effect`,FI=`~effect/Stream`,II=e=>AI(function(t){return e},jI),LI=(e,t,n,r)=>RI(e,t,n?.initialValue===void 0?hF():_F(n.initialValue),r,n?.uninterruptible);function RI(e,t,n,r=ia(),i=!1){let o=e.self();if(o._tag===`Some`&&dI(e))return o.value;let s=typeof r==`function`?r:a(r),c=yp();e.addFinalizer(()=>{M_(s())(zI(c))});let l,u=!1,d=BI(s().pipe(sa(vp,c),sa($F,e.registry),sa(wo,e.registry.scheduler)),t,function(t){u?e.setSelf(dF(t,e.self())):l=dF(t,o)},i);return u=!0,d!==void 0&&e.addFinalizer(d),l===void 0?o._tag===`Some`?fF(o):SF(n):l}var zI=e=>Mg(wp(e,Zf),e=>Df(e)?V:Hg(_g(e),{log:`Unhandled`,message:`Unhandled error in atom finalizer`}));function BI(e,t,n,r=!1){if(Gf(t)){n(t);return}let i=M_(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 VI(e){let t=e?.memoMap??CI(MI(()=>Fp())),n=e=>bI(t)?e(t):t,r=BF;function i(e){let t=Object.create(TI);t.keepAlive=!1,t.lazy=!0,t.refresh=void 0,t.factory=i;let a=tL(kI(typeof e==`function`?e:()=>e));return t.layer=a,t.read=function(e){let t=tm(e(a),r),i=ia();return RI(e,U(a_,r=>W(Rp(t,n(e),r),e=>(i=e,e))),hF(),()=>i,!0)},t}i.memoMap=t,i.addGlobalLayer=e=>{r=tm(r,em(e,BF))};let a=CI(MI(e=>$g(t=>Rp(BF,n(e),O(t,vp))).pipe(W(O(FF)))));return i.withReactivity=e=>t=>iL(t,n=>{let r=DF(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 HI=VI();HI.withReactivity;var UI=(e,t,n,r)=>WI(e,t,n?.initialValue===void 0?hF():_F(n.initialValue),r);function WI(e,t,n,r=ia()){let i=e.self();if(i._tag===`Some`&&dI(e))return i.value;r=sa(r,$F,e.registry);let a=s_(n=>U(rx(t.channel,n),t=>ug({while:o,body:()=>t,step(t){e.setSelf(_F(Ci(t),{waiting:!0}))}}))).pipe(Mg(t=>(bh(t)?u(e.self(),jr(TF),xr({onNone:()=>e.setSelf(xF(new If,{previous:e.self()})),onSome:t=>e.setSelf(_F(t))})):e.setSelf(bF(t,{previous:e.self()})),V))),s=BI(r.pipe(sa($F,e.registry),sa(wo,e.registry.scheduler)),a,l,!1);return s!==void 0&&e.addFinalizer(s),i._tag===`Some`?fF(i):SF(n)}var GI=(e,t,n=ia())=>WF(t)?(e.addFinalizer(GF(t).pipe(Ux(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return V}),N_(n))),R_(n)(KF(t))):t._tag===`Success`?WI(e,GF(t.value),hF(!0),n):t,KI=(e,t)=>{function n(t,n){let r=t.get(e);WF(r)?L_(JF(r,n)):gF(r)&&L_(JF(r.value,n))}return AI(n=>{let r=n(e);return WF(r)||gF(r)?t(n,r):r},n)},qI=Symbol.for(`effect/reactivity/atom/Atom/Reset`),JI=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`),YI=function(...e){return e.length===0?XI:XI(...e)},XI=(e,t)=>{let[n,r]=ZI(e,t);return AI(n,r)};function ZI(e,t){let n=CI(II([0,void 0])),r=t?.initialValue===void 0?hF():_F(t.initialValue),i=t?.concurrent?CI(kI(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===JI)return bF(Cf(),{previous:t.self()});let l=e(c,t);return PI in l?(o&&(l=U(A_(l,{startImmediately:!0}),e=>{o.add(e);let t=Array.from(o);return e.addObserver(()=>o.delete(e)),W($_(t),e=>e[0])})),RI(t,l,r,a,!1)):WI(t,l,r,a)}function o(e,t){cL(()=>{t===qI?e.set(n,[0,void 0]):t===JI?e.set(n,[e.get(n)[0]+1,JI]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,o,n]}var QI=(e,t,n,r)=>U(Wx(typeof n==`function`?n(e):n),n=>{let i=nv().context,a=ki(),o=Zg(n,{onFailure(e){return bh(e)?vi(a)?R({done:!0,items:a}):H(new If(`Atom.pull: no items`)):_g(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=hi(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(fF(e.self()));let t;t=BI(i,o,n=>{t&&s.delete(t);let r=dF(n,e.self()),i=s.size>0;e.setSelf(i?SF(r):r)}),t&&s.add(t)}),o}),$I=(e,t)=>AI(t.read,function(t,n){t.set(e,t.get(e)+1)}),eL=typeof WeakRef>`u`||typeof FinalizationRegistry>`u`?e=>{let t=eg();return function(n){let r=tg(t,n);if(r._tag===`Some`)return r.value;let i=e(n);return ig(t,n,i),i}}:e=>{let t=eg(),n=new FinalizationRegistry(e=>{let n=tg(t,e);n._tag===`Some`&&n.value.deref()===void 0&&og(t,e)});return function(r){let i=tg(t,r).pipe(Mr(e=>e.deref()));if(i._tag===`Some`)return i.value;let a=e(r);return ig(t,r,new WeakRef(a)),n.register(a,r),a}},tL=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),nL=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,equals:t})),rL=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:[t,Ft()===0?``:Error().stack?.split(`
16
- `)[5]??``]})),iL=r(e=>bI(e[0]),(e,t,n)=>{let r=CI(OI(e)?AI(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):kI(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=aL(n.initialValueTarget)),r}),aL=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},oL=r(2,(e,t)=>iL(e,n=>t(n(e)))),sL=r(2,(e,t)=>oL(e,AF(t))),cL=_I,lL=`~effect-atom/atom/Atom/Serializable`,uL=r(2,(e,t)=>{let n=xj(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,Ft()===0?``:Error().stack?.split(`
17
- `)[5]??``],[lL]:{key:t.key,encode:rA(n),decode:$k(n),skipInitialRun:t.skipInitialRun}})}),dL=`~effect-atom/atom/Atom/ServerValue`,fL=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,[dL]:t})),pL=e=>fL(e,a(hF(!0))),mL=r(2,(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[dL](e=>t.get(e)):t.get(e)),hL=`~effect/socket/Socket`,gL=Vi(`effect/socket/Socket`),_L=e=>gL.of({[hL]:hL,reader:e.reader,writer:e.writer}),vL=new TextEncoder,yL=`~effect/socket/Socket/CloseEvent`,bL=e=>v(e,yL),xL=`~effect/socket/Socket/SocketError`,SL=e=>v(e,xL),CL=class extends yj(`effect/socket/Socket/SocketReadError`)({_tag:FA(`SocketReadError`),cause:ej()}){message=`An error occurred during Read`},wL=class extends yj(`effect/socket/Socket/SocketWriteError`)({_tag:FA(`SocketWriteError`),cause:ej()}){message=`An error occurred during Write`},TL=class extends yj(`effect/socket/Socket/SocketOpenError`)({_tag:FA(`SocketOpenError`),kind:OA([`Unknown`,`Timeout`]),cause:ej()}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},EL=class e extends yj(`effect/socket/Socket/SocketUpgradeError`)({_tag:FA(`SocketUpgradeError`),cause:oA(ej())}){static unsupported=()=>H(new kL({reason:new e({})}));get message(){return this.cause===void 0?`Socket does not support TLS upgrade`:`An error occurred during TLS upgrade`}},DL=class extends yj(`effect/socket/Socket/SocketCloseError`)({_tag:FA(`SocketCloseError`),code:GA,closeReason:oA(mA)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},OL=DA([CL,wL,TL,EL,DL]),kL=class extends bj(xL)(`SocketError`,{_tag:FA(`SocketError`),reason:OL}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[xL]=xL;static is(e){return SL(e)}message=this.reason.message},AL=(e,t)=>new kL({reason:new DL({code:e,closeReason:t})}),jL=class extends Vi()(`@effect/platform/Socket/WebSocketConstructor`){},ML=Bp(jL)((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)}),NL=(e,t)=>jL.use(n=>FL(c_((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)),PL=e=>`pause`in e&&typeof e.pause==`function`,FL=(e,t)=>Sg(n=>{let r,i=mv(!1),a=n.context,o=gg(function*(){let n=yield*a_,a=yield*bp(e,n);`binaryType`in a&&(a.binaryType=`arraybuffer`);let o=PL(a),s=t?.highWaterMark??(o?IL: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`?vL.encode(e).byteLength:e.byteLength),m!==void 0&&te(),o&&f>=s?g():!o&&!m&&s!==void 0&&f>s&&re(new kL({reason:new CL({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 kL({reason:new CL({cause:e})}))}):ne(t instanceof ArrayBuffer?new Uint8Array(t):t)}function ae(e){re(new kL({reason:c?new CL({cause:e}):new TL({kind:`Unknown`,cause:e})}))}function oe(e){re(AL(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*Sp(n,B(()=>{if(re(AL(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??AL(1006)):(c||=(yield*mg(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(Gg({duration:t?.openTimeout??1e4,orElse:()=>H(new kL({reason:new TL({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))})),!0),p===void 0&&f<s&&ee(),r=a,i.openUnsafe(),{pull:mg(e=>d.length>0?e(R(_())):p===void 0?(m=e,B(()=>{m===e&&(m=void 0)})):e(H(p))),upgrade:EL.unsupported})}).pipe(r_(e=>ga(a,e))),s=e=>z(()=>{let t=r;if(t===void 0)return i.whenOpen(s(e));try{return bL(e)?t.close(e.code,e.reason):t.send(e),V}catch(e){return H(new kL({reason:new wL({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 kL({reason:new wL({cause:e})}))}});return R(_L({reader:o,writer:R({write:s,writeAll:c})}))}),IL=65536,LL=d(NL,Gp(gL)),RL=class extends Vi()(`effect/workers/Transferable/Collector`){},zL=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return RL.of({addAllUnsafe:t,addAll:e=>B(()=>t(e)),readUnsafe:n,read:B(n),clearUnsafe:r,clear:B(r)})},BL=DA([class extends yj(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:FA(`WorkerSpawnError`),message:mA,cause:oA(ej())}){},class extends yj(`effect/workers/WorkerError/WorkerSendError`)({_tag:FA(`WorkerSendError`),message:mA,cause:oA(ej())}){},class extends yj(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:FA(`WorkerReceiveError`),message:mA,cause:oA(ej())}){},class extends yj(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:FA(`WorkerUnknownError`),message:mA,cause:oA(ej())}){}]),VL=(e,t)=>e===void 0?t:`${e}.${t}`,HL=(e,t)=>({"rpc.system.name":`effect_rpc`,"rpc.method":e,...t}),UL=`~effect/PrimaryKey`,WL=`~effect/rpc/RpcSchema/StreamSchema`;function GL(e){return v(e,WL)}function KL(e){return GL(e)?E({success:e.success,error:e.error}):T()}var qL=Bk(lx);function JL(e,t){return J(qL.ast,{[WL]:WL,success:e,error:t})}var YL=`~effect/rpc/Rpc`,XL={[YL]:YL,pipe(){return e(this,arguments)},setSuccess(e){return ZL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return ZL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return ZL({_tag:this._tag,payloadSchema:iA(e)?e:yA(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return ZL({_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 ZL({_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 ZL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:sa(this.annotations,e,t)})},annotateMerge(e){return ZL({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:ga(this.annotations,e)})}},ZL=e=>{function t(){}return Object.setPrototypeOf(t,XL),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},QL=(e,t)=>{let n=t?.success??_A,r=t?.error??uA,i=t?.defect??ej(),a;return a=t?.primaryKey?class extends vj(`effect/rpc/Rpc/${e}`)(t.payload){[UL](){return t.primaryKey(this)}}:iA(t?.payload)?t?.payload:t?.payload?yA(t?.payload):_A,ZL({_tag:e,payloadSchema:a,successSchema:t?.stream?JL(n,r):n,errorSchema:t?.stream?uA:r,defectSchema:i,annotations:ia(),middlewares:new Set})},$L=new WeakMap,eR=e=>{if($L.has(e))return $L.get(e);let t=e,n=new Set([t.errorSchema]),r=KL(t.successSchema);br(r)&&n.add(r.value.error);for(let e of t.middlewares)n.add(e.error);let i=cj(br(r)?_A:t.successSchema,DA([...n]),t.defectSchema);return $L.set(e,i),i},tR=k(`effect/rpc/Rpc/ParseOptions`,{defaultValue:()=>cE}),nR=`~effect/rpc/Rpc/Wrapper`,rR=e=>nR in e,iR=`~effect/rpc/RpcClientError`,aR=class extends yj(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:FA(`RpcClientDefect`),message:mA,cause:ej()}){},oR=class extends yj(iR)({_tag:FA(`RpcClientError`),reason:DA([BL,OL,GM,aR])}){[iR]=iR;get message(){return`${this.reason._tag}: ${this.reason.message}`}},sR=e=>e,cR={_tag:`Ping`},lR=DA([mA,hA]),uR=DA([yA({_tag:FA(`Request`),id:lR,tag:mA,payload:aj,headers:CA(SA([mA,mA])),isNotification:oA(lA(!0)),discard:oA(lA(!0)),traceId:oA(mA),spanId:oA(mA),sampled:oA(gA)}),yA({_tag:FA(`Ack`),requestId:lR}),yA({_tag:FA(`Interrupt`),requestId:lR}),yA({_tag:FA(`Ping`)}),yA({_tag:FA(`Eof`)}),yA({_tag:FA(`Chunk`),requestId:lR,values:aj}),yA({_tag:FA(`Exit`),requestId:lR,exit:aj}),yA({_tag:FA(`Defect`),defect:aj}),yA({_tag:FA(`Pong`)})]),dR=new WeakMap,fR=new WeakMap,pR=new WeakMap,mR=new WeakMap;function hR(e,t){let n=t?.fingerprint===!0?fR:dR,r=n.get(e);if(r!==void 0)return r;let{exact:i,layout:a,recursive:o,target:s}=vH(e),c=gH(a,t?.fingerprint),l=i?{value:void 0}:void 0,u=_R(l===void 0?s:SH(s,l,!o),a,c,l);return n.set(e,u),u}function gR(e,t){let n=t?.fingerprint===!0?mR:pR,r=n.get(e);if(r!==void 0)return r;let{exact:i,exitSuccess:a,layout:o,target:s}=vH(e);if(!i){if(!a)return hR(e,t);let r={value:void 0},i=_R(wH(s,r),o,gH(o,t?.fingerprint),r,!0);return n.set(e,i),i}let c=_R(TH(s),o,gH(o,t?.fingerprint),void 0);return n.set(e,c),c}function _R(e,t,n,r,i=!1){return aj.pipe(jA(e,mH(t,n,r,i)))}function vR(e,t){let{exact:n,exitSuccess:r,layout:i}=vH(e),a=gH(i,t?.fingerprint),o=t??cE;if(!n||o.onExcessProperty===`error`){let n=nA(hR(e,t),t);return!r||o.onExcessProperty===`error`?n:e=>{if(!MV(e))return n(e);try{return jV(i,e,o,a)}catch(e){throw e instanceof wz?new Vk(e.issue):e}}}return e=>{try{return jV(i,e,o,a)}catch(e){throw e instanceof wz?new Vk(e.issue):e}}}function yR(e,t){let{exact:n,layout:r}=vH(e),i=t??cE;if(!n||i.onExcessProperty===`error`){let n=vR(e,t);return e=>bR(e.map(n))}let a=gH(r,t?.fingerprint);return e=>{try{return AV(r,e,i,a)}catch(e){throw e instanceof wz?new Vk(e.issue):e}}}function bR(e){return e.length===1?e[0]:Ik(e)}function xR(e,t){let{exact:n,exitSuccess:r,layout:i,target:a}=vH(e),o=t??cE,s=n?void 0:Qk(a,o),c=s!==void 0&&r?e=>MV(e)?e:s(e):s;return wR(i,gH(i,t?.fingerprint),o,t?.maxFrameSize,c,SR(n,t))}function SR(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 CR(e,t){let{exact:n,layout:r,target:i}=vH(e),a=SR(n,t),o=vR(e,t),s=yR(e,t);if(!a)return{encode:o,encodeMany:s};let c=gH(r,t?.fingerprint),l=t??cE,u=l.onExcessProperty===`error`?nA(i,t):void 0,d=aV(),f=e=>{try{return e()}catch(e){throw e instanceof wz?new Vk(e.issue):e}};return{encode:e=>f(()=>jV(r,u===void 0?e:u(e),l,c,d)),encodeMany:e=>f(()=>AV(r,u===void 0?e:e.map(u),l,c,d))}}function wR(e,t,n,r,i,a){let o=a?[]:void 0,s=new Uint8Array,c=0,l=0,u,d=!1,f=new Wz,p=new Bz(n,Mz),m=()=>{f.release(),p.clear(),s=Hz,c=l=0},h=(e,t)=>{throw new Vk(new Fw({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 Vk(new Fw({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>NR)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=dH(e,f,t);ie.push(i===void 0?c:i(c))}catch(e){d=!0,m();let t=e instanceof wz?new Vk(e.issue):Hk(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(Hk(e))return H(e);throw e}}),end:z(()=>{try{return _.endSync(),V}catch(e){if(Hk(e))return H(e);throw e}})};return _}var TR=`~effect/encoding/SchemaBinary/fieldId`,ER=`~effect/encoding/SchemaBinary/fixedWidth`,DR=BigInt(`-9223372036854775808`),OR=BigInt(`9223372036854775807`),kR=BigInt(`18446744073709551615`);function AR(e){let t=e.checks;if(t!==void 0)for(let e of t){let t=e.annotations?.[ER];if(t!==void 0)return t}}var jR=32,MR=33,NR=BigInt(2**53-1),PR=BigInt(0),FR=BigInt(1),IR=BigInt(2),LR=BigInt(7),RR=BigInt(127),zR=BigInt(1e6),BR=BigInt(255),VR=BigInt(4294967295),HR=BigInt(32),UR=new TextEncoder,WR=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),GR=7,KR=0xffffffffffff,qR=0xfffffffffffff,JR=0,YR=1,XR=2,ZR=512,QR=1048576,$R=4194304,ez=0,tz=1,nz=2,rz=3,iz=4,az=5,oz=6,sz=7,cz=8;function lz(e){return typeof e==`number`&&Number.isInteger(e)&&e>=-0xffffffffffff&&e<=KR}var uz=8,dz=2199023255551,fz=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function pz(e){for(let t=1;t<=uz;t++){let n=Math.round(e*fz[t]);if(!(n>=-2199023255551&&n<=dz))return 0;if(n/fz[t]===e)return t}return 0}function mz(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 hz(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}var gz=BigInt(`14695981039346656037`),_z=BigInt(`1099511628211`),vz=BigInt(`18446744073709551615`);function yz(e){let t=gz;for(let n=0;n<e.length;n++)t=(t^BigInt(e[n]))*_z&vz;return t}function bz(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function xz(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function Sz(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function Cz(e,t){for(let n=0;n<8;n++)e.push(Number(t>>BigInt(n*8)&BR))}var wz=class extends Error{issue;constructor(e){super(`SchemaBinary failure`),this.issue=e}};function X(e,t,n){throw Tz(new Fw({expected:e},t,n))}var Z=[],Q=0;function Tz(e){return new wz(Q===0?e:new Aw(Z.slice(0,Q),e))}function Ez(e){let t=new Uint8Array(Dz(e)),n=0;for(;e>127;)t[n++]=e&127|128,e=Math.floor(e/128);return t[n]=e,t}function Dz(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var Oz=32;function kz(e,t,n,r){let i=n-t;if(i===0)return``;if(i<=Oz){let r=Az(e,t,n);if(r!==void 0)return r}try{return WR.decode(e.subarray(t,n))}catch{X(`utf-8`,void 0,r)}}function Az(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 jz=65536,Mz=256,Nz=512,Pz=16384;function Fz(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Iz=Fz(jz),Lz=class{buf=new Uint8Array;view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let e=Iz;(e.writing||e.offset>=e.buf.length)&&(e=Iz=Fz(jz)),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=jz;for(;r<n;)r*=2;let i=Fz(r);i.writing=!0,i.buf.set(this.buf.subarray(this.start,this.start+this.len)),t.writing=!1,this.arena=Iz=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>RR;)this.byte(Number(e&RR)|128),e>>=LR;this.byte(Number(e))}zigzag(e){this.uvarintBig(e>=PR?e<<FR:(-e<<FR)-FR)}numberVarint(e){let t=e<0||e===0&&1/e<0,n=t?-e:e;n<=qR?this.uvarint(n*2+ +!!t):this.uvarintBig(BigInt(n)*IR+(t?FR:PR))}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=Dz(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+=UR.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+=UR.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===Iz&&(e.offset=this.start+this.len),e.writing=!1,this.arena=void 0,t}abort(){let e=this.arena;e!==void 0&&(e===Iz&&(e.offset=this.start),e.writing=!1,this.arena=void 0)}};function Rz(e){let t=ZD(e);return t._tag===`String`&&t.checks===void 0}function zz(e,t,n){return e.extra.find(e=>PE({[t]:null},e.parameter,n).length>0)}var Bz=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=zz(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}},Vz=new ArrayBuffer(0),Hz=new Uint8Array(Vz),Uz=new DataView(Vz),Wz=class{pos=0;nesting=0;buf=Hz;view;viewCache=Uz;viewBuffer=Vz;viewOffset=0;viewLength=0;end=0;options=cE;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=Hz,this.view=void 0,this.viewCache=Uz,this.viewBuffer=Vz,this.viewOffset=this.viewLength=0,this.options=cE,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,kz(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=PR,t=PR;for(;;){let n=this.byte();if(e|=BigInt(n&127)<<t,!(n&128))return e;t+=LR}}numberVarint(){let e=this.buf,t=this.end,n=this.pos,r=0,i=1;for(let a=0;a<GR;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,mz(r);i*=128}let a=this.uvarintBig(),o=Number(a>>FR);return Number.isFinite(o)||X(`safe integer length`,void 0,this.options),(a&FR)===FR?-o:o}zigzag(){let e=this.uvarintBig();return(e&FR)===FR?-(e+FR>>FR):e>>FR}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 Gz(e,t){return{_:`literal`,leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function Kz(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 qz(e){return e.values.map(e=>typeof e==`string`?JSON.stringify(e):String(e)).join(` | `)}var Jz=0,Yz=1,Xz=2,Zz=3,Qz=30,$z=1<<Qz;function eB(e){return e._===`literal`?eB(e.leaf):e._===`int`}function tB(e){switch(e._){case`literal`:return tB(e.leaf);case`bool`:return 1;case`i32`:case`u32`:return 4;case`int64`:case`i64`:case`u64`:return 8;default:return}}function nB(e){return tB(e)!==void 0||eB(e)||e._===`null`||e._===`undefined`}function rB(e){return e._===`literal`?rB(e.leaf):e._===`null`||e._===`undefined`}var iB={"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 aB(e){let t=e.annotations?.representation;return he(t)&&typeof t.id==`string`?t.id:void 0}var oB=FD(e=>{let t=sB(e),n=e.context;return t===e||n===void 0?t:ND(t,new lE(n.isOptional,n.isMutable,void 0,n.annotations))});function sB(e){switch(e._tag){case`Declaration`:{let t=aB(e);if(t!==void 0&&(t in iB||t===`effect/schema/Json`||t===`effect/schema/MutableJson`))return e.recur(oB);let n=e.annotations?.toCodecJson,r=e.annotations?.toCodec;if(!ce(n)&&!ce(r))return e;let i=e.typeParameters.map(e=>J(ZD(e))),a=(ce(n)?n(i):void 0)??(ce(r)?r(i):void 0);return a===void 0?e:wD(e,[AD(a,oB)])}case`Arrays`:case`Objects`:case`Union`:case`Suspend`:return e.recur(oB);default:return e}}function cB(e){let t=[...e].sort((e,t)=>{let n=typeof e.key==`number`;return n===(typeof t.key==`number`)?n?e.key-t.key:Lk(UR.encode(e.key),UR.encode(t.key)):n?-1:1}),n=[];for(let e of t){let t=UR.encode(String(e.key));n.push(typeof e.key==`number`?0:1),Sz(n,t.length),bz(n,t);let r=e.literal,i=UR.encode(uB(r));n.push(lB(r)),Sz(n,i.length),bz(n,i)}return hz(n)}function lB(e){switch(typeof e){case`string`:return 1;case`number`:return 2;case`boolean`:return 3;case`bigint`:return 4;default:return 5}}function uB(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 dB(e){switch(e._tag){case`Symbol`:return!0;case`Union`:return e.types.some(dB);default:return!1}}function fB(e){let t=aB(e);return t===`effect/schema/Json`||t===`effect/schema/MutableJson`||ce(e.annotations?.toCodecJson)}function pB(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 mB(e){for(;e._tag===`Suspend`;)e=e.thunk();return e}function hB(e){return new aD(e.enums.map(e=>new bE(e[1],{title:e[0]})))}function gB(e){let t=[],n=new Set,r=e=>{let i=mB(e);if(!n.has(i))switch(n.add(i),i._tag){case`Never`:return;case`Union`:i.types.forEach(r);return;case`Enum`:hB(i).types.forEach(r);return;default:t.push(i)}};return e.types.forEach(r),t}function _B(e){switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`bool`;default:return`bigint`}}function vB(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=aB(e);if(t!==void 0&&t in iB)return iB[t].kind;if(fB(e))return Y.json;throw Error(`Binary layout: declaration ${t??`<anonymous>`} has no toCodecJson or toCodec`)}case`Suspend`:return vB(mB(e));default:throw Error(`Binary layout: union members are not uniquely identifiable`)}}function yB(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function bB(e){let t=xB(e),n=!t&&CB(e);e=ZD(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=AR(e);return o(t===`i32`||t===`u32`?t:pB(e)?`int`:`number`)}case`BigInt`:{let t=AR(e);return o(t===`i64`||t===`u64`?t:`bigint`)}case`Literal`:return Gz(o(_B(e.literal)),[e.literal]);case`Unknown`:case`Any`:case`ObjectKeyword`:return o(`json`);case`Never`:return{_:`never`,ast:e};case`Enum`:return f(e,gB(hB(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,gB(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?.[TR],s=typeof o==`number`?o:hz(UR.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:Ez(s*cz+ez),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(dB(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&&Rz(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=GV(r.layout),r.inline=nB(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;yB(o);for(let t=0;t<a.length;t++)a[t].layout=s(e.indexSignatures[t].type),a[t].wireMask=GV(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=tB(e),t.uniformNumbers=e._===`number`,t.uniformInline=nB(e)}return t}function d(e){let t=aB(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 iB)throw Error(`Binary layout: native declaration ${t} has no layout constructor`);if(fB(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=vB(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`)vB(e),l(Y.string,o(`symbol`));else{if(e._tag===`Objects`||e._tag===`Arrays`){let t=$E(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:vB(e)})}for(let[e,t]of c)l(e,Gz(o(_B(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=cB(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};yB(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)=>kB(e.layout)-kB(t.layout)),p.discriminator=xV(p.variants),p}return{layout:s(e),recursive:i,exact:t,exitSuccess:n}}function xB(e){let t=new Map,n=e=>{if(e.encoding!==void 0||e.checks!==void 0&&!SB(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=aB(e),r=t===void 0?void 0:iB[t];return r===void 0?!1:r.exact===!0||e.typeParameters.every(n)}default:return!1}};return n(e)}function SB(e){return(e._tag===`Number`||e._tag===`BigInt`)&&e.checks?.length===1&&AR(e)!==void 0}function CB(e){return e._tag===`Declaration`&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&aB(e)===`effect/schema/Exit`&&xB(e.typeParameters[0])}var wB={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 TB(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=[wB.backEdge];return xz(e,n.length-i),yz(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=yz(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(wB[e._]),t;case`literal`:{t.push(wB.literal),bz(t,a(e.leaf)),xz(t,e.values.length);let n=e.values.map(e=>[lB(e),uB(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=UR.encode(r);xz(t,n.length),bz(t,n)}return t}case`int64`:return t.push(e.flavor===`date`?wB.date:wB.dateTimeUtc),t;case`never`:return t.push(wB.never),t;case`struct`:t.push(wB.struct),xz(t,e.fields.length);for(let n of e.fields)Sz(t,n.id),t.push(+!!n.optional),Cz(t,i(n.layout));xz(t,e.extra.length);for(let n of e.extra)Cz(t,i(n.layout));return t;case`array`:t.push(wB.array),xz(t,e.elements.length);for(let n of e.elements)t.push(+!!n.optional),Cz(t,i(n.layout));xz(t,e.rest.length);for(let n of e.rest)Cz(t,i(n));return t;case`union`:t.push(wB.union),xz(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),Sz(t,e.tag)),Cz(t,i(n.layout))}return t;case`option`:return t.push(wB.option),Cz(t,i(e.value)),t;case`result`:return t.push(wB.result),Cz(t,i(e.success)),Cz(t,i(e.failure)),t;case`exit`:return t.push(wB.exit),Cz(t,i(e.value)),Cz(t,i(e.cause.error)),Cz(t,i(e.cause.defect)),t;case`cause`:case`causeReason`:return t.push(e._===`cause`?wB.cause:wB.causeReason),Cz(t,i(e.error)),Cz(t,i(e.defect)),t}}return i(e)}function EB(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 DB={positional:!1,rejectUnknownFields:!1,envelope:jR,expectedEnvelope:`version 2 envelope, flags 0`,fingerprint:new Uint8Array(8)};({...DB});function OB(e){let t=TB(e);return{positional:!0,rejectUnknownFields:!1,envelope:MR,expectedEnvelope:`version 2 envelope, flags 1`,fingerprint:EB(Number(t&VR),Number(t>>HR&VR))}}function kB(e){switch(e._){case`json`:return 2;case`struct`:return 1;default:return 0}}function AB(e,t){switch(e._){case`literal`:return Kz(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:US(t)&&t._tag===`Utc`;case`dateTimeZoned`:return US(t)&&t._tag===`Zoned`;case`duration`:return Ya(t);case`bigDecimal`:return fS(t);case`option`:return vr(t);case`result`:return Hr(t);case`exit`:return Gf(t);case`cause`:return hf(t);case`causeReason`:return gf(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 Tz(new Fw({expected:e},t,n))}function jB(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(jB(e[n],t))return!0}else for(let n of Object.keys(e))if(jB(e[n],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||US(e)||Ya(e)||fS(e))return!1;if(t.has(e))return!0;t.add(e);try{if(vr(e))return br(e)&&jB(e.value,t);if(Hr(e))return jB(Ur(e)?e.success:e.failure,t);if(Gf(e))return jB(Qf(e)?e.value:e.cause,t);if(hf(e))return e.reasons.some(e=>jB(e,t));if(gf(e))switch(e._tag){case`Fail`:return jB(e.error,t);case`Die`:return jB(e.defect,t);case`Interrupt`:return!1}if(uv(e)){for(let n of e)if(jB(n,t))return!0;return!1}if(ZS(e)){for(let[n,r]of e)if(jB(n,t)||jB(r,t))return!0;return!1}if($S(e)){for(let n of e)if(jB(n,t))return!0;return!1}if(hC(e))return jB(vC(e),t);for(let n of Object.keys(e))if(jB(e[n],t))return!0}finally{t.delete(e)}return!1}function MB(e,t,n,r){let i=r.beginSized();EV(e,t,n,r),r.endSized(i)}function NB(e,t,n){let r=globalThis.Symbol.keyFor(t);r===void 0&&$(`registered symbol`,t,e.options),n.string(r)}function PB(e,t,n,r){let i=n;switch(i._tag){case`Fail`:r.byte(0),EV(e,t.error,i.error,r);return;case`Die`:r.byte(1),EV(e,t.defect,i.defect,r);return;case`Interrupt`:i.fiberId===void 0?r.byte(2):(r.byte(3),r.f64(i.fiberId))}}function FB(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function IB(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 LB(e,t){if(e.extraAll===void 0||t.length>Nz)return!1;let n=0;for(let e=0;e<t.length;e++)if(n+=t[e].length,n>Pz)return!1;return!0}function RB(e,t,n){let r=Object.keys(n),i=t.extraShape;if(i!==void 0&&IB(i,t,r))return i.pairs;let a=LB(t,r),o=a?void 0:e.extraShape;if(o!==void 0&&IB(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 Bz(e.options)).find(t,n);r!==void 0&&(u&&!FB(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]=UR.encode(e[0]);l.sort((e,t)=>Lk(e[2],t[2]))}if(a)for(let e of l)e[2]??=UR.encode(e[0]);let d={layout:t,keys:r,pairs:l};return a?t.extraShape=d:e.extraShape=d,l}function zB(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=BB(o.layout,c,e.options),u=l%cz;if(i===void 0)r.uvarint(t*cz+u);else{if(!i.disabled){let t=QB(i,a);if(t!==void 0){r.uvarint(t*16+u*2+1),Z[Q++]=a,VB(e,o.layout,c,l,r),Q--;continue}$B(i,a)}r.uvarint(t*16+u*2)}s===void 0?r.string(a):r.bytes(s),Z[Q++]=a,VB(e,o.layout,c,l,r),Q--}}function BB(e,t,n){if(e._===`literal`)return Kz(e,t)||$(qz(e),t,n),BB(e.leaf,t,n);switch(e._){case`bool`:return typeof t!=`boolean`&&$(`a boolean`,t,n),t?iz:rz;case`number`:if(typeof t!=`number`&&$(`a number`,t,n),lz(t))return tz;{let e=pz(t);return e===0?nz:e*cz+az}case`int`:return Number.isSafeInteger(t)||$(`an integer`,t,n),tz;case`i32`:case`u32`:return oz;default:return ez}}function VB(e,t,n,r,i){switch(r%cz){case rz:case iz:return;case tz:i.numberVarint(n);return;case nz:i.f64(n);return;case oz:EV(e,t,n,i);return;case az:{let e=Math.floor(r/cz);i.numberVarint(Math.round(n*fz[e])),i.uvarint(e);return}default:MB(e,t,n,i)}}function HB(e,t,n,r){let i=BB(t.layout,n,e.options),a=i%cz;if(a===ez){let i=r.idAndMark(t.tagBytes);EV(e,t.layout,n,r),r.endSized(i)}else r.uvarint(t.id*cz+a),VB(e,t.layout,n,i,r)}function UB(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,Tz(new jw(n.annotations))}}return i}function WB(e,t,n,r){let i=n;if(t.extra.length>0){let n=e.intern;e.intern=void 0;let a=RB(e,t,i);if(a.length>0){r.uvarint(0);let t=r.beginSized();zB(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,Tz(new jw(n.annotations))}Z[Q++]=o,HB(e,n,i[o],r),Q--}}function GB(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,Tz(new jw(n.annotations));Z[Q++]=a,n.inline?EV(e,n.layout,i[a],r):MB(e,n.layout,i[a],r),Q--}if(t.extra.length>0){let n=RB(e,t,i);r.uvarint(n.length),zB(e,n,i,r,a)}}function KB(e){switch(e._){case`string`:return Yz;case`array`:return e.uniform?._===`string`?Xz:Jz;case`struct`:return e.extra.length>0?Zz:Jz;default:return Jz}}function qB(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 JB(e){let t=e.run;if(t!==void 0)return t;let n=qB(e);if(n===void 0)return e.run=t=null,t;let r=n.fields.map(e=>KB(e.layout)),i=n.fields.length<=Qz;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 YB=16,XB=64;function ZB(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function QB(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 $B(e,t){let n=e.values;if(e.refs!==void 0){if(e.hits===0&&n.length>=XB){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,n.length)}else if(n.length>=YB){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 eV=0,tV=1,nV=2,rV=64,iV=512;function aV(){return{slots:[],marks:[],frame:0}}function oV(e,t){return e[t]??={values:[],refs:new Map,state:eV,stamp:-1}}function sV(e,t){e.refs.has(t)?e.state=tV:(e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=rV&&(e.state=nV))}function cV(e,t){let n=e.values;n.length>=iV||(e.refs.set(t,n.length),n.push(t))}function lV(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function uV(e){e.marks.length=0,e.frame++}function dV(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 fV(e,t,n,r){let i=oV(e.slots,t.slot),a=i.state;if(a===nV){r.string(n);return}if(lV(e,i),a===eV){r.string(n),sV(i,n);return}let o=i.refs.get(n);o===void 0?(r.byte(0),cV(i,n),r.string(n)):r.uvarint(o*2+1)}function pV(e,t,n){let r=oV(e,t.slot),i=r.state;if(i===nV)return n.readUtf8(n.end-n.pos);if(i===eV){let e=n.readUtf8(n.end-n.pos);return sV(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 cV(r,o),o}function mV(e,t,n,r,i){if(!e.disabled){let t=QB(e,r);if(t!==void 0){i.uvarint(t*2+1);return}$B(e,r)}let a=i.beginSized();EV(t,n,r,i),i.endSizedRun(a)}function hV(e,t,n,r,i){let a=[],o=[];for(let s=0;s<r;s++){Z[Q++]=s;let r=i.beginSized();gV(e,t,a,o,n[s],i),i.endSized(r),Q--}}function gV(e,t,n,r,i,a){let o=t.struct,s=i,c=o.fields,l;if(o.extra.length>0){let t=RB(e,o,s);t.length>0&&(l=t)}let u=!t.shapes,d=l===void 0?0:$z,f=UB(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,Tz(new jw(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();zB(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===Yz)mV(ZB(r,n),e,i.layout,s[i.name],a);else{o!==Jz&&(e.intern=ZB(r,n));let t=a.beginSized();EV(e,i.layout,s[i.name],a),a.endSizedRun(t),e.intern=void 0}Q--}}function _V(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 vV(e,t,n,r){let i=n.length;if(t.rest.length===0&&i>t.elements.length)throw Z[Q++]=t.elements.length,Tz(new Mw(t.ast,n[t.elements.length],e.options));if(i<t.minCount)throw Z[Q++]=i,Tz(new jw(void 0));if(t.hasCount&&r.uvarint(i),i>0){let a=JB(t);if(a!==null){hV(e,a,n,i,r);return}}let a=t.uniform;if(a!==void 0){if(t.uniformNumbers){bV(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,mV(o,e,a,n[t],r),Q--;return}let s=t.uniformInline;for(let t=0;t<i;t++)Z[Q++]=t,s?EV(e,a,n[t],r):MB(e,a,n[t],r),Q--}else for(let a=0;a<i;a++){let o=_V(t,a,i);Z[Q++]=a,nB(o)?EV(e,o,n[a],r):MB(e,o,n[a],r),Q--}}var yV=[];function bV(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)),lz(n))(n<0?-n:n)>dz&&(a=!1);else{i=!1;let e=pz(n);e===0?a=!1:yV[r]=e}if(!i&&!a)break}if(i){r.byte(YR);for(let e=0;e<n;e++)r.numberVarint(t[e])}else if(a){r.byte(XR);for(let e=0;e<n;e++){let n=t[e],i=Number.isInteger(n)?0:yV[e],a=i===0?n:Math.round(n*fz[i]),o=a<0||a===0&&1/a<0,s=o?-a:a;r.uvarint((s*2+ +!!o)*16+i)}}else{r.byte(JR);for(let e=0;e<n;e++)r.f64(t[e])}}function xV(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 SV(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 CV(e,t){return e.tuple?Array.isArray(t)&&SV(e,t):he(t)&&!Array.isArray(t)&&SV(e,t)}function wV(e,t,n,r){e.positional?r.uvarint(t.position):(r.byte(Y.variant),r.u32le(t.tag)),EV(e,t.payload,n,r)}function TV(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&&SV(a,t)){wV(e,a,n,r);return}}}else for(let i of t.variants)if(CV(i,n)){wV(e,i,n,r);return}for(let i of t.others)if(AB(i.layout,n)){e.positional?r.uvarint(i.position):r.byte(i.kind),EV(e,i.layout,n,r);return}throw Tz(new Pw(t.ast,n,e.options))}function EV(e,t,n,r){switch(t._){case`literal`:Kz(t,n)||$(qz(t),n,e.options),EV(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),lz(n)){r.numberVarint(n);return}let t=pz(n);t>0?(r.numberVarint(Math.round(n*fz[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):fV(i,t,n,r);return}case`symbol`:typeof n!=`symbol`&&$(`a symbol`,n,e.options),NB(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<DR||n>OR)&&$(`a 64-bit integer`,n,e.options),r.i64(n);return;case`u64`:(typeof n!=`bigint`||n<PR||n>kR)&&$(`a 64-bit unsigned integer`,n,e.options),r.u64(n);return;case`int64`:{AB(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`:{AB(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`:{Ya(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)*zR);return}}case`bigDecimal`:{fS(n)||$(`a BigDecimal`,n,e.options);let t=yS(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&&(jB(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),EV(e,t.value,i.value,r));return}case`result`:{Hr(n)||$(`a Result`,n,e.options);let i=n;i._tag===`Success`?(r.byte(0),EV(e,t.success,i.success,r)):(r.byte(1),EV(e,t.failure,i.failure,r));return}case`exit`:{Gf(n)||$(`an Exit`,n,e.options);let i=n;i._tag===`Success`?(r.byte(0),EV(e,t.value,i.value,r)):(r.byte(1),EV(e,t.cause,i.cause,r));return}case`cause`:{hf(n)||$(`a Cause`,n,e.options);let i=n.reasons;r.uvarint(i.length);for(let n of i){let i=r.beginSized();PB(e,t,n,r),r.endSized(i)}return}case`causeReason`:gf(n)||$(`a Cause.Reason`,n,e.options),PB(e,t,n,r);return;case`struct`:(!he(n)||Array.isArray(n))&&$(`an object`,n,e.options),e.positional?GB(e,t,n,r):WB(e,t,n,r);return;case`array`:Array.isArray(n)||$(`an array`,n,e.options),vV(e,t,n,r);return;case`union`:TV(e,t,n,r);return;case`never`:throw Tz(new Pw(t.ast,n,e.options))}}var DV=new Lz;function OV(e,t,n,r,i){let a=i.beginSized();i.byte(r.envelope),r.positional&&i.bytes(r.fingerprint),EV(e,t,n,i),i.endSized(a)}function kV(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=DV??new Lz,c=s===DV;c&&(DV=void 0),s.reset();let l=Q,u=!1;try{if(n===void 0)Q=0,OV(o,e,t,i,s);else for(let t=0;t<n.length;t++)Q=0,OV(o,e,n[t],i,s);let r=s.out();return u=!0,r}finally{a!==void 0&&(u?uV(a):dV(a)),s.abort(),Q=l,c&&(DV=s)}}function AV(e,t,n,r,i){return kV(e,void 0,t,n,r,i)}function jV(e,t,n,r,i){return kV(e,t,void 0,n,r,i)}function MV(e){return Gf(e)&&Qf(e)}var NV=globalThis.Symbol.for(`~effect/encoding/SchemaBinary/absent`);function PV(e,t){let n=lH(e,t);return n!==NV&&t.pos!==t.end&&X(`no leftover bytes`,void 0,t.options),n}function FV(e,t){let n=t.enter(t.uvarint()),r=PV(e,t);return t.exit(n),r}function IV(e,t){if(eB(e))return lH(e,t);let n=tB(e),r=t.enter(n===void 0?e._===`null`||e._===`undefined`?0:t.uvarint():n),i=PV(e,t);return t.exit(r),i}var LV=8;function RV(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>=LV){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 zV(e,t,n,r,i){let a=t.uvarint(),o=Math.floor(i===void 0?a/cz:a/16),s=i===void 0?a-o*cz:Math.floor((a-o*16)/2),c=i===void 0?t.readUtf8(o):BV(i,a,o,t);e.names.has(c)&&X(`an extra key distinct from declared fields`,c,t.options),RV(r,c)&&X(`unique extra keys`,void 0,t.options);let l=e.extraAll??(t.indexSignatures??=new Bz(t.options)).find(e,c);if(l===void 0){t.rejectUnknownFields&&X(`a key matching an index signature`,c,t.options),WV(s,t);return}Z[Q++]=c;let u=qV(l.layout,l.wireMask,s,t);Q--,u!==NV&&b(n,c,u)}function BV(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 VV(e){return new Aw([e.name],new jw(e.annotations))}function HV(e,t){throw Tz(new Nw(e.ast,t))}function UV(e){for(;e.byte()&128;);}function WV(e,t){switch(e){case ez:t.take(t.uvarint());return;case tz:UV(t);return;case nz:t.take(8);return;case rz:case iz:case sz:return;case az:UV(t),UV(t);return;case oz:t.take(4);return}}function GV(e){if(e._===`literal`)return GV(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 KV(e,t){switch(e){case rz:return!1;case iz:return!0;case tz:return t.numberVarint();case nz:return t.f64();case az:{let e=t.numberVarint(),n=t.uvarint();return(n===0||n>uz)&&X(`a decimal scale in [1, 8]`,n,t.options),e/fz[n]}}return X(`matching field wire kind`,void 0,t.options)}function qV(e,t,n,r){if(!(t&1<<n))return r.rejectUnknownFields&&X(`matching field wire kind`,n,r.options),WV(n,r),NV;if(n===oz)return e._===`u32`?r.u32le():r.i32le();if(n!==ez){let t=KV(n,r);return e._===`literal`&&!Kz(e,t)&&X(qz(e),t,r.options),t}let i=r.enter(r.uvarint()),a=PV(e,r);return r.exit(i),a}function JV(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/cz),m=f-p*cz;if(p===0){l&&X(`unique field ids`,void 0,t.options),l=!0,m!==ez&&X(`extra field map`,void 0,t.options);let i=t.enter(t.uvarint());ZV(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),WV(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=qV(h.layout,h.wireMask,m,t);Q--,ee!==NV&&(b(r,h.name,ee),g<32?a|=1<<g:(s??=new Set).add(g))}return YV(e,a,s,t),r}function YV(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(VV(o)),r.options.errors!==`all`))break}a!==void 0&&HV(e,a)}function XV(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?IV(n.layout,t):FV(n.layout,t);if(Q--,i!==NV)b(r,n.name,i);else if(!n.optional&&((l??=[]).push(VV(n)),t.options.errors!==`all`))break}if(l!==void 0&&HV(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++)zV(e,t,r,a,n)}}return r}function ZV(e,t,n,r){let i={list:[],set:void 0};for(;t.pos<t.end;)zV(e,t,n,i,r)}function QV(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=PV(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=PV(t,n);return n.exit(i),e.push(a),a}function $V(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]=tH(e,i,a,n),n.exit(t),Q--}return r}function eH(e,t){let n=t.uvarint(),r=e.fields,i=n&-1073741825;(n>$z*2-1||i>>>r.length)&&X(`a known row shape`,void 0,t.options);let a=[];(n&$z)!==0&&a.push(null);for(let e=0;e<r.length;e++)i&1<<e&&a.push(r[e]);return a}function tH(e,t,n,r){let i=e.struct,a={},o=0,s,c=r.uvarint(),l;if(c===0?r.positional&&e.shapes&&(l=eH(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=nH(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=nH(e,n,p,a,r);m>=0&&(m<32?o|=1<<m:(s??=new Set).add(m))}c!==void 0&&t.push(c)}return YV(i,o,s,r),a}function nH(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===NV?-1:(b(r,n.name,s),n.index)}let o=i.enter(a/2);if(n===null)return ZV(e.struct,i,r),i.exit(o),-1;if(n===void 0)return i.exit(o),-1;let s=e.intern[n.index];(s===Xz||s===Zz)&&(i.intern=t[n.index]??=[]),Z[Q++]=n.name;let c=PV(n.layout,i);return Q--,i.intern=void 0,i.exit(o),s===Yz&&(t[n.index]??=[]).push(c),c===NV?-1:(b(r,n.name,c),n.index)}function rH(e,t){let n=e.elements.length,r=e.hasCount?t.uvarint():n;if(e.rest.length===0&&r>n)throw Z[Q++]=n,Tz(new Mw(e.ast,void 0,t.options));if(r<e.minCount)throw Z[Q++]=r,Tz(new jw(void 0));if(e.hasCount&&r>(e.rest.length>0&&rB(e.rest[0])?$R:t.remaining+QR)&&X(`array count within allocation limit`,r,t.options),r>0){let n=JB(e);if(n!==null)return $V(n,r,t)}let i=Array(r),a=e.uniform;if(a!==void 0){if(e.uniformNumbers)return iH(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=QV(n,a,t);if(r===NV)throw Tz(new jw(void 0));Q--,i[e]=r}return i}if(eB(a)){for(let e=0;e<r;e++)Z[Q++]=e,i[e]=lH(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()):FV(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=PV(a,t);if(t.exit(n),r===NV)throw Tz(new jw(void 0));Q--,i[e]=r}return i}for(let a=0;a<r;a++){let o=_V(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,Tz(new jw(void 0));Z[Q++]=a;let c=IV(o,t);if(c===NV)throw s&&X(`known union member`,void 0,t.options),Tz(new jw(void 0));Q--,i[a]=c}if(!e.hasCount&&t.pos<t.end)throw Z[Q++]=n,Tz(new Mw(e.ast,void 0,t.options));return i}function iH(e,t,n){let r=n.byte();if(r===JR){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===XR){for(let r=0;r<t;r++){Z[Q++]=r;let t=n.uvarint(),i=t%16;i>uz&&X(`decimal`,void 0,n.options);let a=mz((t-i)/16);e[r]=i===0?a:a/fz[i],Q--}return e}r!==YR&&X(`f64`,void 0,n.options);for(let r=0;r<t;r++)Z[Q++]=r,e[r]=n.numberVarint(),Q--;return e}function aH(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),NV;let i=PV(r.payload,t);if(i===NV)return NV;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),NV):PV(r,t)}function oH(e,t){let n=e.byPos[t.uvarint()];n===void 0&&X(`known union member`,void 0,t.options);let r=PV(n.layout,t),i=n.variant;if(i!==void 0&&!i.tuple&&r!==NV)for(let e of i.sentinels)b(r,e.key,e.literal);return r}function sH(e,t){switch(t.byte()){case 0:return wf(cH(PV(e.error,t)));case 1:return Tf(cH(PV(e.defect,t)));case 2:return t.remaining!==0&&X(`empty`,void 0,t.options),Ef();case 3:return t.remaining!==8&&X(`f64`,void 0,t.options),Ef(t.f64());default:return t.take(t.remaining),NV}}function cH(e){if(e===NV)throw Tz(new jw(void 0));return e}function lH(e,t){t.nesting>=ZR&&X(`nesting depth at most ${ZR}`,t.nesting+1,t.options),t.nesting++;try{return uH(e,t)}finally{t.nesting--}}function uH(e,t){switch(e._){case`literal`:{let n=lH(e.leaf,t);return Kz(e,n)||X(qz(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>GR)&&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>uz)&&X(`decimal`,void 0,t.options),n/fz[r]}case`int`:return t.numberVarint();case`string`:{let n=t.dict;return n===void 0?t.readUtf8(t.end-t.pos):pV(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:WS(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 GS(e,{timeZone:r})}catch{return X(`time zone`,void 0,t.options)}}case`duration`:switch(t.byte()){case 0:return ro(t.zigzag());case 1:return to;case 2:return no;default:return X(`duration`,void 0,t.options)}case`bigDecimal`:{let e=t.zigzag(),n=t.zigzag();return(n>NR||-n>NR)&&X(`safe integer length`,void 0,t.options),pS(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(cH(PV(e.value,t))))}case`result`:{let n=t.byte();return n===0?zr(cH(PV(e.success,t))):(n!==1&&X(`bool`,void 0,t.options),Br(cH(PV(e.failure,t))))}case`exit`:{let n=t.byte();return n===0?Kf(cH(PV(e.value,t))):(n!==1&&X(`bool`,void 0,t.options),qf(lH(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=sH(e,t);t.exit(n),Q--,a!==NV&&r.push(a)}return t.pos!==t.end&&X(`no leftover bytes`,void 0,t.options),bf(r)}case`causeReason`:return sH(e,t);case`struct`:return t.positional?XV(e,t):JV(e,t);case`array`:return rH(e,t);case`union`:return t.positional?oH(e,t):aH(e,t);case`never`:throw Tz(new Pw(e.ast,void 0,t.options))}}function dH(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=PV(e,t);if(i===NV)throw Tz(new jw(void 0));return i}var fH=new Wz;function pH(e,t,n,r){let i=fH??new Wz,a=i===fH;a&&(fH=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=dH(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&&(fH=i)}}function mH(e,t,n,r=!1){return jT({decode:(i,a)=>{try{let o=pH(e,i,a,t);return n!==void 0&&me(o)&&(!r||MV(o))&&(n.value=o),R(o)}catch(e){return e instanceof wz?H(e.issue):yg(e)}},encode:(n,r)=>{try{return R(jV(e,n,r,t))}catch(e){return e instanceof wz?H(e.issue):yg(e)}}})}var hH=f(OB);function gH(e,t){return t===!0?hH(e):DB}var _H=f(e=>{let t=J(oB(e)),{exact:n,exitSuccess:r,layout:i,recursive:a}=bB(t.ast);return{target:a?EH(t):t,layout:i,exact:n,exitSuccess:r,recursive:a}});function vH(e){return _H(e.ast)}function yH(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function bH(e,t,n){let r=J(XD(e.ast)),i=UO(r),a=e=>()=>(t,n,r)=>e(t,r)?q:i(t,r);return J(new fE([r.ast],a(t),{identifier:`binary value`},void 0,void 0,void 0,void 0,a(n)))}function xH(e,t){return t.onExcessProperty!==`error`}function SH(e,t,n){return bH(e,e=>yH(t,e),n?xH:CH)}function CH(){return!1}function wH(e,t){return zk()([e],([e])=>{let n=UO(e);return(e,r,i)=>yH(t,e)||MV(e)&&i.onExcessProperty!==`error`?R(e):n(e,i)},{identifier:`binary exit value`})}function TH(e){return bH(e,xH,xH)}function EH(e){let t=J(XD(e.ast)),n=new WeakSet;return jA(zk()([t],([e])=>(t,r,i)=>me(t)&&n.delete(t)?R(t):jB(t)?H(new Pw(r,t,i)):UO(e)(t,i),{identifier:`acyclic value`}),MT({decode:e=>(me(e)&&n.add(e),e),encode:e=>e}))(e)}var DH=class extends Vi()(`effect/rpc/RpcSerialization`){},OH=16777216,kH=new TextEncoder,AH=e=>{let t=e?.maxFrameSize===`unbounded`?void 0:e?.maxFrameSize??OH,n=e?.fingerprintPayloads===!0?e=>gR(e,{fingerprint:!0}):gR,r={fingerprint:!0};return DH.of({contentType:`application/vnd.effect.rpc+schema-binary`,includesFraming:!0,codecFor:n,makeUnsafe:()=>{let e=xR(uR,{...r,maxFrameSize:t}),n=CR(uR,r);return{decode:t=>e.feedSync(typeof t==`string`?kH.encode(t):t),encode:e=>{if(!Array.isArray(e))return n.encode(e);if(e.length!==0)return n.encodeMany(e)}}}})},jH=e=>Up(DH)(()=>AH(e)),MH=e=>z(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>$g(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 gg(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*t_(z(()=>i(e)),t)}return yield*p_(hg,()=>(t.delete(e),r.delete(e),V))})}}))}),NH=0,PH=B_(function*(e,t){let n=t.spanPrefix,r=t?.supportsAck??!0,a=t?.disableTracing??!1,o=t?.generateRequestId??(()=>NH++),s=yield*Qg(),c=O(s,vp),l=new Map,u=!1;yield*Sp(c,Sg(e=>(u=!0,d(Xf(e.id)))));let d=B_(function*(e){let t=Array.from(l.values());l.clear();for(let n of t)n._tag===`Queue`?yield*e._tag===`Success`?Cy(n.queue):xy(n.queue,e.cause):n.resume(e)},v_),f=e=>{let r=GL(e.successSchema),i=h(e);return(o,s)=>{let c=s?.headers?wC(s.headers):CC,l=s?.context??ia();if(!r){let r=t=>p(e,i,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return a?r(void 0):w_(VL(n,e._tag),{kind:`client`,attributes:HL(e._tag,t.spanAttributes)},r)}let u=m(e,i,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:Ex(W(u,Sx))}},p=(e,n,r,a,s,c,d)=>Sg(f=>{if(u)return h_;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:OC(f.getRef(RH),s),...d?{discard:!0}:{}}),h;return __(mg(t=>{let n=!1,a={_tag:`Effect`,rpc:e,context:c,resume(e){d&&e._tag===`Success`?(n=!0,h?.pollUnsafe()&&t(Zf)):(t(e),h&&!h.pollUnsafe()&&f.currentDispatcher.scheduleTask(()=>{h.interruptUnsafe(f.id)},0))}};l.set(p,a),h=m.pipe(r?E_(r,{captureStackTrace:!1}):i,M_(f.context)),h.addObserver(e=>{if(e._tag===`Failure`)return l.delete(p),t(e);if(n)return t(Zf)})}),e=>(l.delete(p),Tg(ev(h),g(p,Array.from(e),c))))}),m=B_(function*(e,r,s,c,d,f){if(u)return yield*h_;let p=a?void 0:yield*C_(VL(n,e._tag),{kind:`client`,attributes:HL(e._tag,t.spanAttributes)}),m=nv(),h=o(),ee=da(m.context,vp),_=yield*gy(d);return yield*xp(ee,e=>(Ty(_),l.has(h)?(l.delete(h),g(h,$f(e)?Array.from(Nf(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:OC(m.getRef(RH),c)}).pipe(p?E_(p,{captureStackTrace:!1}):i,d_(e=>(Df(e)||l.delete(h),xy(_,e))),g_,O_(ee,{startImmediately:!0})),_}),h=e=>{let t=[];for(let n of e.middlewares.values()){let e=ua(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)=>mg(i=>{let a=nv();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r}).pipe(Ug(1e3),M_(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:yy(a.queue,e.values).pipe(r?U(n=>n.length>0?V:t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:a.context})):i,Mg(e=>xy(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`?Cy(n.queue):xy(n.queue,e.exit.cause)):V}case`Defect`:return d(Yf(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}}),FH=0,IH=B_(function*(e,t){let n=FH++,{codecFor:r,run:i,send:a,supportsAck:o,supportsTransferables:s}=yield*zH,c=LH(r),l=$k(r(ej())),u=new Map,d=rp(),f=e=>u.has(e)?(u.delete(e),a(n,{_tag:`Interrupt`,requestId:e})):V,{client:p,write:m}=yield*PH(e,{...t,supportsAck:o,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),i=s?zL():void 0,o=nv(),l={rpc:r,context:i?sa(o.context,RL,i):o.context,schemas:c(r),discard:t.discard===!0};return u.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(t_(l.context),Ig,U(e=>up(d)?(u.delete(t.id),h_):a(n,{...t,id:t.id,payload:e,headers:Object.entries(t.headers)},i&&i.readUnsafe())),d_(e=>Df(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=sR(e.requestId),n=u.get(t);if(!n||yr(n.schemas.decodeChunk))return V;let r=n.schemas.decodeChunk.value;return y_(i=>i(r(e.values).pipe(t_(n.context),Ig,U(e=>m({_tag:`Chunk`,clientId:0,requestId:t,values:e})))).pipe(d_(e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:qf(e)}).pipe(Tg(Mf(e)?V:Yg(Vg(f(t)),ap(d))))),Pg(e=>!Mf(e),()=>V)))}case`Exit`:{let t=sR(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:Zf}):(n.discard?n.schemas.decodeDiscardExit:n.schemas.decodeExit)(e.exit).pipe(t_(n.context),Ig,Zg({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=Jf(e.error),n=e.requestIds===void 0?Array.from(u.keys()):e.requestIds.map(sR).filter(e=>u.has(e));for(let e of n)u.delete(e);return lg(n,e=>m({_tag:`Exit`,clientId:0,requestId:e,exit:t})).pipe(v_)}default:return V}}).pipe(Mg(H_),g_,k_),yield*l_(()=>fp(d,void 0)),p}),LH=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=KL(n.successSchema),a=O(n.annotations,tR),o=eR(n),s;return r={decodeChunk:Ar(i,t=>Jk(e(wA(t.success)),a)),encodePayload:tA(e(n.payloadSchema),a),decodeExit:Jk(e(o),a),decodeDiscardExit:t=>(s??=Jk(e(cj(_A,o.error,o.defect)),a))(t)},t.set(n,r),r}},RH=k(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>CC}),zH=class extends Vi()(`effect/rpc/RpcClient/Protocol`){static make=MH},BH=e=>zH.make(B_(function*(t,n){let r=yield*gL,a=yield*DH,o=yield*n_(WH),s=new Map,c=yield*r.writer,u=a.makeUnsafe(),d=yield*HH(z(()=>c.write(u.encode(cR))),e),f=Hg(e?.onPingTimeout??V,{log:!0,message:`RpcClient onPingTimeout hook failed`}),p,m=e=>{let r=lg(Array.from(n),n=>t(n,e));return e._tag!==`Defect`&&e._tag!==`ClientProtocolError`?r:(s.clear(),v_(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 ug({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 oR({reason:new aR({message:`Error decoding message`,cause:e})})})}};yield*z(()=>{u=a.makeUnsafe(),d.reset();let e=!1;return gg(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(o_,Yg(d.timeout),Tg(()=>e?f:V),Tg(()=>H(new kL({reason:new CL({cause:Error(`ping timeout`)})}))))}).pipe(br(o)?u_(o.value.onDisconnect):i,Rg(t=>{let n=Af(t),r=Ur(n),i=new oR({reason:r?n.success.reason:new aR({message:`Unknown socket error`,cause:kf(t)})});return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?(e.onTransientError?.(i)??V).pipe(Hg({log:!0,message:`RpcClient onTransientError hook failed`})):h(i)}),Bg(e?.retryPolicy??VH,e=>h(new oR({reason:e.reason}))),W_({module:`RpcClient`,method:`makeProtocolSocket`}),k_);let ee=e=>z(()=>{let t=u.encode(e);return t===void 0?V:Ig(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),d_(ee(t),()=>B(()=>s.delete(t.id)))):ee(t))},supportsAck:!0,supportsTransferables:!1,codecFor:a.codecFor}})),VH=Ih([Rh(500,1.5),Vh(5e3)]),HH=B_(function*(e,t){let n=yield*Hf,r=t?.pingInterval??`5 seconds`,i=oo(t?.pingTimeout??r),a=n.currentTimeMillisUnsafe(),o=!1,s=mv(),c=()=>{a=n.currentTimeMillisUnsafe(),o=!1};return yield*z(()=>o&&n.currentTimeMillisUnsafe()-a>i?s.open:(o=!0,e)).pipe(Kg(r),Vg,b_,g_,k_),{timeout:s.await,reset:()=>{c(),s.closeUnsafe()},onFrame:c}}),UH=e=>Gp(zH)(BH(e)),WH=class extends Vi()(`effect/rpc/RpcClient/ConnectionHooks`){},GH=()=>(e,t)=>{let n=Vi()(e),r=Gp(n,t.makeEffect??IH(t.group,{...t,flatten:!0}));n.runtime=(t.runtime??HI)(typeof t.protocol==`function`?e=>em(r,im(t.protocol(e))):em(r,im(t.protocol))),n.mutation=eL(r=>{let i=t.group.requests.get(r);return n.runtime.fn()(B_(function*({headers:e,payload:t,reactivityKeys:i}){let a=(yield*n)(r,t,{headers:e});return yield*i?RF(a,i):a})).pipe(uL({key:`AtomRpc:mutation:${JSON.stringify([e,r])}`,schema:NF({success:i.successSchema,error:KH(i)})}))});let i=eL(e=>{let{headers:r,payload:i,reactivityKeys:a,tag:o,timeToLive:s}=e,c=t.group.requests.get(o),l=GL(c.successSchema),u=l?n.runtime.pull(Ex(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=uL(u,{key:`AtomRpc:${e.tag}:${e.serializationKey}`,schema:NF({success:c.successSchema,error:KH(c)})})),s&&(u=Xa(s)?SI(u,s):tL(u)),u});return n.query=(e,t,n)=>{let r={tag:e,payload:t,headers:n?.headers?wC(n.headers):void 0,reactivityKeys:n?.reactivityKeys,timeToLive:n?.timeToLive===void 0?void 0:Ba(n.timeToLive),serializationKey:n?.serializationKey};return i(r)},n},KH=e=>DA([e.errorSchema,...Array.from(e.middlewares,e=>e.error),oR]),qH={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return JH({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 JH({requests:t,annotations:$i(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return JH({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 JH({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return gg(function*(){let n=yield*Qg(),r=sg(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})}),$i(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 JH({requests:t,annotations:this.annotations})},toLayer(e){return qp(this.toHandlers(e))},of:i,toLayerHandler(e,t){let n=this;return qp(gg(function*(){let r=yield*Qg(),i=sg(t)?yield*t:t,a=new Map,o=n.requests.get(e);return a.set(o.key,{handler:i,context:r}),$i(a)}))},accessHandler(e){return $g(t=>{let n=this.requests.get(e),{handler:r,context:i}=ua(t,n.key);return R((e,t)=>{t.rpc=n;let a=r(e,t),o=rR(a)?a.value:a;return sg(o)?e_(o,i):Vx(o,i)})})},annotate(e,t){return JH({requests:this.requests,annotations:sa(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(oa(e,t))},annotateMerge(e){return JH({requests:this.requests,annotations:ga(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(ga(e,r.annotations)));return JH({requests:t,annotations:this.annotations})}},JH=e=>Object.assign(function(){},qH,{requests:e.requests,annotations:e.annotations}),YH=(...e)=>JH({requests:new Map(e.map(e=>[e._tag,e])),annotations:ia()}),XH=`~effect/rpc/RpcMiddleware`,ZH=()=>(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(Vi(e))),i.key=e,Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[XH]=XH,a.error=t?.error??uA,a.requiredForClient=t?.requiredForClient??!1,i},QH=`~effect/SynchronizedRef`,$H={...Jt,[QH]:QH,toJSON(){return{_id:`SynchronizedRef`,value:this.backing.ref.current}}},eU=e=>{let t=Object.create($H);return t.semaphore=qy(1),t.backing=mM(e),t},tU=e=>B(()=>eU(e)),nU=e=>e.backing.ref.current,rU=e=>B(()=>nU(e)),iU=r(2,(e,t)=>e.semaphore.withPermit(hM(e.backing,t))),aU=r(2,(e,t)=>e.semaphore.withPermit(z(()=>W(t(nU(e)),([t,n])=>(e.backing.ref.current=n,t))))),oU=r(2,(e,t)=>e.semaphore.withPermit(gM(e.backing,t)));export{kN as $,dr as $a,Mf as $i,kg as $n,og as $r,JT as $t,QF as A,ai as Aa,Tp as Ai,Rx as An,j_ as Ar,bj as At,lF as B,Tr as Ba,dp as Bi,Uv as Bn,Eg as Br,HA as Bt,iL as C,Si as Ca,em as Ci,G as Cn,Fg as Cr,XA as Ct,pL as D,Pi as Da,Xp as Di,Dx as Dn,t_ as Dr,Vk as Dt,fL as E,ui as Ea,rm as Ei,gx as En,Dg as Er,bA as Et,EF as F,Rr as Fa,pp as Fi,ux as Fn,o_ as Fr,$k as Ft,tF as G,Ir as Ga,Qf as Gi,yv as Gn,v_ as Gr,oA as Gt,_F as H,Dr as Ha,qf as Hi,Wv as Hn,Ug as Hr,Hk as Ht,hF as I,Fr as Ia,sp as Ii,Ex as In,qg as Ir,Jk as It,NP as J,T as Ja,Uf as Ji,xv as Jn,Sg as Jr,LA as Jt,XP as K,Ar as Ka,Kf as Ki,vv as Kn,y_ as Kr,aA as Kt,vF as L,jr as La,cp as Li,_b as Ln,R as Lr,Zk as Lt,OF as M,D as Ma,bp as Mi,Hx as Mn,L_ as Mr,RA as Mt,bF as N,qr as Na,ap as Ni,hx as Nn,z_ as Nr,DA as Nt,AI as O,Ei as Oa,vp as Oi,Ox as On,i_ as Or,mA as Ot,uF as P,Lr as Pa,op as Pi,kx as Pn,a_ as Pr,Xk as Pt,RN as Q,fr as Qa,jf as Qi,Tg as Qn,tg as Qr,kk as Qt,pF as R,Nr as Ra,ip as Ri,tb as Rn,z as Rr,qk as Rt,HI as S,Li as Sa,Qp as Si,Nx as Sn,W as Sr,wA as St,rL as T,pi as Ta,Bp as Ti,lx as Tn,p_ as Tr,lj as Tt,TF as U,yr as Ua,Xf as Ui,Kv as Un,fg as Ur,VA as Ut,AF as V,Sr as Va,fp as Vi,Vv as Vn,Lg as Vr,iA as Vt,SF as W,br as Wa,$f as Wi,zv as Wn,bg as Wr,TA as Wt,LN as X,E as Xa,Sf as Xi,c_ as Xn,xg as Xr,PA as Xt,hP as Y,Cr as Ya,Wf as Yi,ev as Yn,T_ as Yr,sA as Yt,BN as Z,Pr as Za,xf as Zi,cg as Zn,eg as Zr,Ak as Zt,mL as _,di as _a,rh as _i,JS as _n,gg as _r,UA as _t,oU as a,Fo as aa,fh as ai,XT as an,v as ao,jg as ar,uM as at,sL as b,gi as ba,Jp as bi,mx as bn,H_ as br,lA as bt,GH as c,sa as ca,gh as ci,nE as cn,he as co,u_ as cr,lM as ct,QL as d,Di as da,vh as di,XD as dn,u as do,_g as dr,Aj as dt,vf as ea,ig as ei,tE as en,pr as eo,Ag as er,CN as et,LL as f,Fi as fa,uh as fi,mw as fn,t as fo,U as fr,Mj as ft,YI as g,Mi as ga,ih as gi,KS as gn,A_ as gr,ej as gt,eL as h,Ti as ha,sh as hi,WS as hn,D_ as hr,gA as ht,aU as i,kf as ia,dh as ii,KD as in,Ve as io,Ng as ir,fM as it,jF as j,Wr as ja,yp as ji,Ix as jn,I_ as jr,IA as jt,eI as k,ni as ka,Sp as ki,Tx as kn,P_ as kr,yA as kt,UH as l,ha as la,_h as li,aE as ln,me as lo,Og as lr,Gj as lt,dL as m,wi as ma,ch as mi,YS as mn,lg as mr,CA as mt,tU as n,yf as na,Hh as ni,ZT as nn,_r as no,mg as nr,bN as nt,ZH as o,so as oa,oh as oi,oE as on,ue as oo,Qg as or,dM as ot,ML as p,Ni as pa,mh as pi,qS as pn,B_ as pr,jj as pt,JP as q,xr as qa,Zf as qi,bv as qn,V as qr,wj as qt,iU as r,Of as ra,hh as ri,iE as rn,Mt as ro,Mg as rr,tN as rt,YH as s,Vi as sa,ph as si,QT as sn,ie as so,yg as sr,cM as st,rU as t,_f as ta,Vh as ti,$T as tn,mr as to,m_ as tr,cN as tt,jH as u,Ri as ua,lh as ui,eE as un,r as uo,H as ur,Wj as ut,tL as v,Oi as va,ah as vi,Fx as vn,h_ as vr,GA as vt,nL as w,ji as wa,tm as wi,Cx as wn,hg as wr,kA as wt,kI as x,vi as xa,Hp as xi,Bx as xn,V_ as xr,OA as xt,MI as y,xi as ya,am as yi,Ax as yn,sg as yr,Cj as yt,gF as z,wr as za,rp as zi,Hv as zn,B as zr,JA as zt};