@deslop/auth 0.1.1304 → 0.1.1310

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.
@@ -14,4 +14,4 @@ var e=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:retu
14
14
  `)===-1&&e.indexOf(`\r`)===-1?e:e.replace(/[\n\r]/g,``),cb=e=>ub(typeof e==`string`?pb.encode(e):e),lb=e=>{let t=sb(e),n=t.length;if(n%4!=0)return Jr(new $o({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 Jr(new $o({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));let i=t.endsWith(`==`)?2:+!!t.endsWith(`=`),a=n/4*3-i,o=ob(t,a,void 0);if(o)return qr(o);if(o===null){let e=vb.exec(t);if(e!==null)return Jr(new $o({kind:`Decode`,module:`Base64`,input:t,message:`Invalid character ${e[0]}`}))}try{let e=new Uint8Array(a);for(let r=0,i=0;r<n;r+=4,i+=3){let n=bb(t.charCodeAt(r))<<18|bb(t.charCodeAt(r+1))<<12|bb(t.charCodeAt(r+2))<<6|bb(t.charCodeAt(r+3));e[i]=n>>16,e[i+1]=n>>8&255,e[i+2]=n&255}return qr(e)}catch(e){return Jr(new $o({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},ub=e=>{let t=e.length,n=Uint8Array.prototype.toBase64;return t>=32&&typeof n==`function`?n.call(e):t<128?db(e):fb(e)},db=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=hb[e[r-2]>>2],n+=hb[(e[r-2]&3)<<4|e[r-1]>>4],n+=hb[(e[r-1]&15)<<2|e[r]>>6],n+=hb[e[r]&63];return r===t+1&&(n+=hb[e[r-2]>>2],n+=hb[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=hb[e[r-2]>>2],n+=hb[(e[r-2]&3)<<4|e[r-1]>>4],n+=hb[(e[r-1]&15)<<2],n+=`=`),n},fb=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]=gb[e[r-2]>>2],n[i+1]=gb[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=gb[(e[r-1]&15)<<2|e[r]>>6],n[i+3]=gb[e[r]&63];return r===t+1&&(n[i]=gb[e[r-2]>>2],n[i+1]=gb[(e[r-2]&3)<<4],n[i+2]=_b,n[i+3]=_b),r===t&&(n[i]=gb[e[r-2]>>2],n[i+1]=gb[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=gb[(e[r-1]&15)<<2],n[i+3]=_b),mb.decode(n)},pb=new TextEncoder,mb=new TextDecoder(`utf-8`,{ignoreBOM:!0}),hb=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,gb=pb.encode(hb),_b=61,vb=/[^A-Za-z0-9+/=]/,yb=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)yb[hb.charCodeAt(e)]=e;yb[61]=0;var bb=e=>{if(e>=yb.length||yb[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return yb[e]},xb=`~effect/HashMap`,Sb=e=>v(e,xb),Cb=`~effect/HashSet`,wb=e=>v(e,Cb),Tb=`~effect/http/Cookies`,Eb=`~effect/http/Cookies/Cookie`,Db={[Tb]:Tb,...Lt,toJSON(){return{_id:`effect/Cookies`,cookies:fi(this.cookies,e=>e.toJSON())}},pipe(){return e(this,arguments)}},Ob=e=>{let t=Object.create(Db);return t.cookies=e,t},kb=e=>{let t={};for(let n of e)b(t,n.name,n);return Ob(t)},Ab=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=jb(e.trim());t&&n.push(t)}return kb(n)};function jb(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(Nb,``);if(!Mb.test(r))return;let i=t[0].slice(n+1).replace(Nb,``),a=Ib(i);if(t.length===1)return Object.assign(Object.create(Fb),{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||!Pb.test(a))break;o.maxAge=yo(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(Fb),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var Mb=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Nb=/^[\t ]+|[\t ]+$/g,Pb=/^-?[0-9]+$/,Fb={[Eb]:Eb,...Lt,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},Ib=e=>{try{return decodeURIComponent(e)}catch{return e}},Lb=new WeakMap,Rb=e=>{if(Lb.has(e))return Lb.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},zb=`~effect/Redacted`,Bb=e=>v(e,zb),Vb=(e,t)=>{let n=Object.create(Hb);return t?.label&&(n.label=t.label),Lb.set(n,e),n},Hb={[zb]:{_A:e=>e},label:void 0,...$t,toJSON(){return this.toString()},toString(){return`<redacted${ae(this.label)?`:`+this.label:``}>`},[Ee](){return y(Lb.get(this))},[Ge](e){return Bb(e)&&Ke(Lb.get(this),Lb.get(e))}},Ub=Rb,Wb=e=>ct((t,n)=>e(Ub(t),Ub(n))),Gb=Symbol.for(`~effect/http/Headers`),Kb=Object.defineProperties(Object.create(null),{[Gb]:{value:Gb},[_t]:{value(e){return nx(this,D(e,ix))}},toJSON:{value(){return yt(this)}},[Ge]:{value(e){return Jb(this,e)}},[Ee]:{value(){return Ie(this)}},toString:{value:Lt.toString},[Pt]:{value:Lt[Pt]}}),qb=e=>Object.assign(Object.create(Kb),e),Jb=_i(ut()),Yb=Object.create(Kb),Xb=e=>{if(e===void 0)return Yb;if(Symbol.iterator in e){let t=Object.create(Kb);for(let[n,r]of e){let e=n.toLowerCase();t[e]=e in t?`${t[e]}, ${r}`:r}return t}let t=Object.create(Kb);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},Zb=e=>Object.setPrototypeOf(e,Kb),Qb=r(3,(e,t,n)=>{let r=qb(e);return r[t.toLowerCase()]=n,r}),$b=r(2,(e,t)=>qb({...e,...Xb(t)})),ex=r(2,(e,t)=>{let n=qb(e);return Object.assign(n,t),n}),tx=r(2,(e,t)=>{let n=qb(e);return delete n[t.toLowerCase()],n}),nx=r(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=Vb(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=Vb(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),rx=(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},ix=O(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),ax=`~effect/http/Headers/HeaderParseError`,ox=class extends Xo{},sx=class e extends Zo(`HeaderParseError`){static fromReason(t,n){return new e({reason:new ox({_tag:t,input:n})})}[ax]=ax;get message(){return`${this.reason._tag}: ${JSON.stringify(this.reason.input)}`}},cx=[`jan`,`feb`,`mar`,`apr`,`may`,`jun`,`jul`,`aug`,`sep`,`oct`,`nov`,`dec`],lx=[/^(?: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],ux=e=>{for(let t of lx){let n=t.exec(e)?.groups;if(n===void 0)continue;let r=cx.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}},dx=e=>({_tag:`DateTime`,dateTime:e}),fx=/^\d+$/,px=BigInt(1e9),mx=e=>{let t=e.trim();if(fx.test(t)){let e=Number(t);return qr({_tag:`Duration`,duration:Number.isSafeInteger(e*1e3)?yo(e):_o(BigInt(t)*px)})}let n=ux(t);return n===void 0?Jr(sx.fromReason(`InvalidRetryAfter`,e)):qr(dx(zv(n)))},hx=(e,t)=>e._tag===`Duration`?e.duration:vo(Math.max(0,Jv(e.dateTime)-t)),gx=e=>typeof e==`string`?e:Ub(e),_x=new TextDecoder(`utf-8`,{ignoreBOM:!0}),vx=e=>new URLSearchParams(_x.decode(e).replace(/^\?/,`%3F`)),yx=`~effect/http/UrlParams`,bx=e=>v(e,yx),xx={...$t,[yx]:yx,[Symbol.iterator](){return this.params[Symbol.iterator]()},[_t](e){return{_id:`UrlParams`,params:Object.fromEntries(Ax(this,D(e,Bx)))}},toJSON(){return yt(this)},[Ge](e){return Ex(this,e)},[Ee](){return Re(this.params.flat())}},Sx=e=>{let t=Object.create(xx);return t.params=e,t},Cx=e=>{if(bx(e))return e;let t=wx(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 Sx(n)},wx=e=>{let t=typeof e[Symbol.iterator]==`function`?xi(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,Tx(r[t])]);else if(typeof r==`object`&&r&&!Bb(r)){let t=wx(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,Tx(r)]);return n},Tx=e=>Bb(e)?e:String(e),Ex=ct((e,t)=>Dx(e.params,t.params)),Dx=qi(ni([ut(),st()])),Ox=Sx([]),kx=r(2,(e,t)=>{let n=Cx(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 Sx(n)}),Ax=r(2,(e,t)=>{let n=Array.isArray(t)?t:[t];return e.params.map(([e,t])=>[e,typeof t==`string`&&jx(e,n)?Vb(t):t])}),jx=rx,Mx=(e,t=zx())=>{e.includes(`@`)&&(e=Ix(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)+Lx(e.slice(n+1,i),t)+e.slice(i)},Nx=/^(?:(https?|ftp|wss?):[/\\]*|[a-z][a-z\d+.-]*:\/\/|[/\\]{2,})/i,Px=/[/\\?#]/,Fx=/[/?#]/,Ix=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=Nx.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?Px:Fx),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])},Lx=(e,t)=>e.split(`&`).map(e=>{let n=e.indexOf(`=`);return n!==-1&&jx(Rx(e.slice(0,n)),t)?e.slice(0,n+1)+`REDACTED`:e}).join(`&`),Rx=e=>{if(!e.includes(`%`)&&!e.includes(`+`))return e;try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}},zx=()=>D(globalThis[`~effect/Fiber/currentFiber`]?.context??ga(),Bx),Bx=O(`effect/http/UrlParams/CurrentRedactedNames`,{defaultValue:()=>[`X-Amz-Signature`,`X-Amz-Credential`,`X-Amz-Security-Token`,`AWSAccessKeyId`,`Signature`,`sig`,`X-Goog-Signature`]});function Vx(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var Hx=`~structural`,Ux=`~sentinels`,Wx=`~constructor`,Gx=p(e=>{let t=Vx(e)?.identifier;return typeof t==`string`?t:e.getExpected(Gx)}),U=Symbol.for(`effect/schema/parser/missing`),Kx=hp,qx=Kx(U),Jx=Object.assign(Kx(U),{[U]:!0}),Yx=e=>e[U]===!0,Xx=e=>e===U?T():E(e),Zx=e=>e._tag===`None`?qx:Kx(e.value),Qx=`~effect/SchemaIssue/Issue`;function $x(e){return v(e,Qx)&&e[Qx]===Qx}function eS(e){return Object.hasOwn(e,`input`)}var tS=class{[Qx]=Qx;constructor(e,t){t?.reportInput===!0&&e!==U&&(this.input=e)}},nS=class extends tS{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},rS=class extends tS{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},iS=class extends tS{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},aS=class extends tS{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},oS=class extends tS{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},sS=class extends tS{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},cS=class extends tS{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},lS=class extends tS{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function uS(e,t,n,r,i){return new sS(e,[new iS([t],n)],r,i)}var dS=class extends tS{_tag=`Forbidden`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},fS=class extends tS{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},pS=class extends tS{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function mS(e,t,n){if($x(e))return e;if(typeof e==`string`)return new lS({message:e},t,n);let r=typeof e.issue==`string`?new lS({message:e.issue},t,n):e.issue;return new iS(e.path,r)}function hS(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new lS(void 0,t,n):mS(e,t,n)}function gS(e,t,n,r){return Array.isArray(t)?ki(t)?t.length===1?mS(t[0],n,r):new sS(e,Bi(t,e=>mS(e,n,r)),n,r):void 0:hS(t,n,r)}var _S=e=>{let t=kS(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return SS(Gx(e.ast),e);case`InvalidValue`:{let t=xS(e);if(t!==void 0)return SS(t,e);let n=bS(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=bS(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=bS(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},vS=e=>kS(e)??kS(e.issue);function yS(e){return t=>({issues:wS(t,[],e?.leafHook??_S,e?.checkHook??vS)})}function bS(e){return eS(e)?x(e.input):void 0}function xS(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function SS(e,t){let n=bS(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function CS(e,t){let n=t(e);if(n!==void 0||e.issue._tag!==`InvalidValue`)return n;let r=xS(e.issue);return r===void 0?SS(TS(e.filter),e):SS(r,e.issue)}function wS(e,t,n,r,i){switch(e._tag){case`Filter`:return wS(e.issue,t,n,r,i??CS(e,r));case`Encoding`:return wS(e.issue,t,n,r,i);case`Pointer`:return wS(e.issue,[...t,...e.path],n,r,i);case`Composite`:case`AnyOf`:return e._tag===`Composite`||e.issues.length>0?e.issues.flatMap(e=>wS(e,t,n,r,i)):[{path:t,message:i??kS(e)??SS(Gx(e.ast),e)}];default:return[{path:t,message:i??n(e)}]}}function TS(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=>TS(e)).join(` & `)}}function ES(){return e=>OS(e,``)}var DS=ES();function OS(e,t,n){let r;switch(e._tag){case`Filter`:return OS(e.issue,t,n??CS(e,vS));case`Encoding`:return OS(e.issue,t,n);case`Pointer`:return OS(e.issue,t+Et(e.path),n);case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>OS(e,t,n)).join(`
15
15
  `);r=n??kS(e)??SS(Gx(e.ast),e);break;default:r=n??_S(e)}return t?`${r}\n at ${t}`:r}function kS(e){if(e._tag===`Pointer`||e._tag===`Composite`)return;if(e._tag===`Encoding`)return kS(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 AS(e){let t;for(let n of e.reasons){if(!zf(n)||!$x(n.error))return;t??=n.error}return t}function jS(e,t){let n=AS(e);if(n===void 0)throw Error(t,{cause:e});return n}var MS=(e,t,n)=>{switch(e._tag){case`Passthrough`:return I(t);case`Transform`:return I(Rr(t,e.transform));case`TransformOptional`:return I(e.transform(t));case`TransformEffect`:return Er(t)?qg:Ov(e.transform(t.value,n),E);case`TransformOptionalEffect`:return e.transform(t,n)}},NS=e=>Object.assign(Object.create(t),e),PS=(e,t)=>US((n,r)=>jv(MS(e,n,r),e=>MS(t,e,r))),FS=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 W(n=>t.transform(e.transform(n)));case`TransformOptional`:return HS(n=>t.transform(Rr(n,e.transform)));case`TransformEffect`:return VS((n,r)=>t.transform(e.transform(n),r));case`TransformOptionalEffect`:return PS(e,t)}case`TransformOptional`:switch(t._tag){case`Transform`:return HS(n=>Rr(e.transform(n),t.transform));case`TransformOptional`:return HS(n=>t.transform(e.transform(n)));case`TransformEffect`:case`TransformOptionalEffect`:return PS(e,t)}case`TransformEffect`:switch(t._tag){case`Transform`:return VS((n,r)=>Ov(e.transform(n,r),t.transform));case`TransformOptional`:case`TransformOptionalEffect`:return PS(e,t);case`TransformEffect`:return VS((n,r)=>jv(e.transform(n,r),e=>t.transform(e,r)))}case`TransformOptionalEffect`:return PS(e,t)}});function IS(e){return US((t,n)=>B(e(t,n)))}function LS(e){return IS((t,n)=>{let r={message:e(t)};return Dr(t)?new dS(r,t.value,n):new dS(r)})}var RS=LS(()=>`Encoding is not supported`),zS=NS({_tag:`Passthrough`});function BS(){return zS}function W(e){return NS({_tag:`Transform`,transform:e})}function VS(e){return NS({_tag:`TransformEffect`,transform:e})}function HS(e){return NS({_tag:`TransformOptional`,transform:e})}function US(e){return NS({_tag:`TransformOptionalEffect`,transform:e})}function WS(){return W(globalThis.String)}function GS(){return W(globalThis.Number)}function KS(){return VS((e,t)=>{try{return I(globalThis.BigInt(e))}catch{return B(new lS({expected:`a value that can be converted to a bigint`},e,t))}})}function qS(e){return VS((t,n)=>e_({try:()=>JSON.parse(t,e?.reviver),catch:()=>new lS({expected:`a valid JSON string`},t,n)}))}function JS(e){return VS((t,n)=>e_({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 lS({expected:`a JSON-serializable value`},t,n)}))}function YS(e){let t=e?.separator??`,`,n=e?.keyValueSeparator??`=`,r=e?.trim??!1,i=e?.keepEmptyValues??!1;return W(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 XS(e){let t=e?.separator??`,`,n=e?.keyValueSeparator??`=`;return W(e=>Object.entries(e).map(([e,t])=>`${e}${n}${t}`).join(t))}function ZS(){return W(cb)}function QS(){return VS((e,t)=>kv(r_(lb(e)),()=>new lS({expected:`a valid Base64 string`},e,t)))}function $S(){return W(encodeURIComponent)}function eC(){return VS((e,t)=>{try{return I(globalThis.decodeURIComponent(e))}catch{return B(new lS({expected:`a valid URI component`},e,t))}})}var tC=Symbol.for(`~effect/Schema/content`);function nC(e,t){return Object.defineProperty(e,tC,{value:t}),e}var rC=class extends n{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new rC(this.encode,this.decode)}},iC=`~effect/SchemaTransformation/Transformation`,aC=class extends n{[iC]=iC;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new aC(this.encode,this.decode)}};function oC(e){return v(e,iC)&&e[iC]===iC}var sC=e=>oC(e)?e:new aC(e.decode,e.encode);function cC(e){return new aC(VS(e.decode),VS(e.encode))}function lC(e){return new aC(W(e.decode),W(e.encode))}function uC(e){return new aC(HS(e.decode),HS(e.encode))}function dC(e){return new aC(YS(e),XS(e))}var fC=new aC(BS(),BS());function pC(){return fC}var mC=new aC(GS(),WS()),hC=new aC(KS(),WS()),gC=e=>be(e)&&typeof e.message==`string`,_C=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:xC(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},vC=e=>{try{let t=At(e);return t===void 0?x(e):JSON.parse(t)}catch{return x(e)}},yC=(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},bC=e=>{let t=new WeakSet,n=r=>{if(Ce(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=yC(r,e,n);return t.delete(r),i}return vC(r)};return n},xC=e=>gC(e)?_C(e):e,SC=e=>lC({decode:xC,encode:bC(e)});function CC(){return lC({decode:Nr,encode:Pr})}function wC(){return uC({decode:E,encode:Vr})}function TC(){return uC({decode:e=>e.pipe(Ur(fe),E),encode:Vr})}var EC=new aC(QS(),ZS()),DC=new aC(eC(),$S());function OC(e){return new aC(qS(e??{}),nC(JS(e),{mediaType:`application/json`,preserveSchema:e?.reviver===void 0&&e?.replacer===void 0}))}function kC(e){return t=>t._tag===e}var AC=kC(`Declaration`),jC=kC(`Never`),MC=kC(`String`),NC=kC(`Number`),PC=kC(`Symbol`),FC=kC(`Literal`),IC=kC(`UniqueSymbol`),LC=kC(`Enum`),RC=kC(`TemplateLiteral`),zC=kC(`Arrays`),BC=kC(`Objects`),VC=kC(`Union`),HC=kC(`Suspend`),UC=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},WC={},GC=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}},KC=`~effect/Schema`,qC=class{[KC]=KC;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}>`}},JC=class extends qC{_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===U)return qx;e??=this.run(this.typeParameters);try{return e(t,this,n)}catch(e){return $g(e)}}}_rebuild(e,t,n,r,i){let a=ST(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new JC(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>`}},YC=new class extends qC{_tag=`Null`;getParser(){return zT(this,null)}getExpected(){return`null`}},XC=class extends qC{_tag=`Undefined`;getParser(){return zT(this,void 0)}toCodecJson(){return lT(this,[ZC])}getExpected(){return`undefined`}},ZC=new UC(YC,new aC(W(()=>void 0),W(()=>null))),QC=new XC,$C=new class extends qC{_tag=`Void`;getParser(){let e=Kx(void 0);return t=>t===U?qx:e}toCodecJson(){return lT(this,[ZC])}getExpected(){return`void`}},ew=new class extends qC{_tag=`Never`;getParser(){return BT(this,_e)}getExpected(){return`never`}},tw=new class extends qC{_tag=`Unknown`;getParser(){return BT(this,ve)}getExpected(){return`unknown`}},nw=class extends qC{_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 zT(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?rw(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:rw(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function rw(e){let t=globalThis.String(e.literal);return lT(e,[new UC(new nw(t),new aC(W(()=>e.literal),W(()=>t)))])}var iw=new class extends qC{_tag=`String`;getParser(){return BT(this,ae)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&QT(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},aw=class extends qC{_tag=`Number`;getParser(){return BT(this,oe)}matchKey(e,t){return this._match(WT,e,t)}matchPart(e,t){return this._match(UT,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:QT(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(ow(this.checks,`effect/schema/isFinite`)||ow(this.checks,`effect/schema/isInt`))?this:lT(this,[iT])}toCodecStringTree(){return this.toCodecJson()===this?lT(this,[qT]):lT(this,[JT])}getExpected(){return`number`}};function ow(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&ow(e.checks,t))}var sw=new aw,cw=new class extends qC{_tag=`Boolean`;getParser(){return BT(this,se)}getExpected(){return`boolean`}},lw=new class extends qC{_tag=`BigInt`;getParser(){return BT(this,ce)}matchPart(e,t){if(!YT.test(e))return;let n=globalThis.BigInt(e);return t.disableChecks||!this.checks?n:QT(this.checks,n,void 0,this,t)?void 0:n}toCodecStringTree(){return lT(this,[ZT])}getExpected(){return`bigint`}},uw=class extends qC{_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(jT(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(jT(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 oS(n,t[o],i),a=new iS([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return B(new sS(n,[a],t,i))}return e.issues?B(new sS(n,e.issues,t,i)):Kx(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:md(t.concurrency),f=d===1?pw(i,e,0,u):mw(i,e,{concurrency:d,end:u});if(!f)return c(i);if(F(f))return jv(f,()=>c(i));let p=!0;return L(()=>p?(p=!1,V(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===U)return qx;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)):B(new cS(n,e,a))}catch(e){return $g(e)}}}_rebuild(e,t,n){let r=ST(this.elements,e),i=ST(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new uw(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 dw(e,t,n,r){if(n._tag===`Failure`)return hw(e,e.ast,r,n);let i=Yx(n)?t:n[S];if(i!==U)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(jT(t.ast))return;let n=new iS([r],new aS(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return _p(new sS(e.ast,[n],e.input,e.options))}}var fw={onItem(e,t,n){let r=n<e.len?t:U;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:dw},pw=hd()(fw),mw=_d()(fw),hw=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=AS(r.cause);if(i===void 0)return gp(Xf(r.cause,r=>new sS(t,[new iS([n],r)],e.input,e.options)));let a=new iS([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return _p(new sS(t,[a],e.input,e.options))},gw=`[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?`;function _w(e,t,n=WC){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(VT(IT(t)))}var vw=class{name;type;constructor(e,t){this.name=e,this.type=t}};function yw(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(yw);default:return!1}}function bw(e){let t=dT(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(bw);default:return!1}}function xw(e){return yw(e)&&bw(e)}var Sw=class{parameter;type;constructor(e,t){if(!xw(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,jT(t)||t.encoding!==void 0&&jT(IT(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.")}},Cw=class extends qC{_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 BT(n,ge);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type,ownOnly:Vw(e.name)})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(VT(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 hw(t,n,i,s)??bp;let c=Yx(s)?o:s[S];if(a!==U&&c!==U){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return bp;b(t.out,a,c)}return bp},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!F(t))return V(l_(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return hw(e,n,r,a)??bp;let o=Yx(a)?r:a[S],s=e.input[r],l=i.parserValue(s,e.options);return F(l)?t(e,r,o,s,l):V(l_(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return F(a)?t(e,n,n,i,a):V(l_(a),r=>t(e,n,n,i,r))},u=i?_d()({onItem:(e,[t,n])=>n.is.parameter===iw?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return Nv(function*(t,d){if(t===U)return U;if(typeof t!=`object`||!t||Array.isArray(t))return yield*B(new cS(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:md(d.concurrency),_=i&&g?n.indexSignatures.map(e=>_w(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 oS(n,f[a],d),r=new iS([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*B(new sS(n,[r],t,d))}}}if(r){let e=ee===1?Ew(m,a):Dw(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===iw?l:c,r=_?.[e]??(t.is.parameter===iw?Object.keys(f):_w(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!F(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=Ri();for(let t=0;t<i;t++){let n=o[t],r=_?.[t]??(n.is.parameter===iw?Object.keys(f):_w(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*B(new sS(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return V(l_(n),n=>{let i={...e,out:{...e.out}},o=ww(i,r,n);if(o)return o;let s=()=>Kx(i.out),c=Ew(i,a.slice(t+1));return c?jv(c,s):s()})};return(e,t)=>{if(e===U)return qx;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&md(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return B(new cS(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=n.ownOnly?Object.hasOwn(i,s):s in i,l=c?i[s]:U,d=n.parser(l,t);if(!F(d))return u(o,e,d);if(Yx(d)){c&&b(a,s,l);continue}let f=ww(o,n,d);if(f)return f}}catch(e){return $g(e)}return Kx(a)}}_rebuild(e,t,n,r){let i=ST(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new vw(t.name,n)}),a=ST(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new Sw(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Cw(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 ww(e,t,n){if(n._tag===`Failure`)return hw(e,e.ast,t.name,n);if(Yx(n))return;let r=n[S];if(r!==U)b(e.out,t.name,r);else if(delete e.out[t.name],!jT(t.type)){let n=new iS([t.name],new aS(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return _p(new sS(e.ast,[n],e.input,e.options))}}var Tw={onItem(e,t){if(!(t.ownOnly?Object.hasOwn(e.input,t.name):t.name in e.input))return t.parser(U,e.options);let n=e.input[t.name];return b(e.out,t.name,n),t.parser(n,e.options)},step:ww},Ew=hd()(Tw),Dw=_d()(Tw);function Ow(e,t){return e?t?[...e,...t]:e:t}function kw(e,t,n){return new Cw(Reflect.ownKeys(e).map(t=>new vw(t,e[t].ast)),[],n,t)}function Aw(e){return e.ast}function jw(e,t=void 0){return new uw(!1,e.map(e=>e.ast),[],void 0,t)}function Mw(e,t,n){return new Ww(e.map(Aw),t,void 0,n)}function Nw(e){if(e.encoding)throw Error(`mutable does not support encodings`);return new uw(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var Pw=m(e=>{for(;;){if(HC(e))return tw;let t=e.encoding;if(!t)return e.recur?.(Pw,i)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==i))return tw;e=t[t.length-1].to}});function Fw(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(Fw)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function Iw(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Ux];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!jT(t)){if(FC(t))return[{key:e.name,literal:t.literal}];if(IC(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!jT(e)){if(FC(e))return[{key:t,literal:e.literal}];if(IC(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>Iw(Pw(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return Iw(e.thunk())}}var Lw=new WeakMap,Rw=Object.freeze([]),zw=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,Bw=new Set(Reflect.ownKeys(Object.prototype)).add(`__proto__`),Vw=e=>Bw.has(typeof e==`number`?globalThis.String(e):e),Hw=(e,t)=>Object.hasOwn(e,t)||t in e&&!Vw(t);function Uw(e){let t=Lw.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=Pw(c);if(jC(l))continue;if(FC(l)||IC(l)){a??=new Map;let e=FC(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=Iw(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=Fw(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??Rw);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??Rw;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(xe(e)){let n=Hw(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??Rw;if(t)return o}return Rw}}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=zw(t);if(!xe(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=Hw(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=Hw(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=Hw(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(zw(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return Lw.set(e,t),t}var Ww=class extends qC{_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===U)return qx;let i=(o??=Uw(n.types))(e,r);if(i.length===0)return B(new fS(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:F(r)?Gw(n,r.cause,e,t):Kw(n,r,e,t)}return qw(n,a,i,e,t)}}_rebuild(e,t,n){let r=ST(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new Ww(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=IT(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(FC);if(t.length>0)return`${Zw(n.isMutable)}[ ${t.map(t=>e(t)+Qw(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>FC(e.type));if(t.length>0)return`{ ${t.map(t=>`${Zw(t.type.context?.isMutable)}${Tt(t.name)}${Qw(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function Gw(e,t,n,r){let i=AS(t);return i?_p(new fS(e,[i],n,r)):gp(t)}function Kw(e,t,n,r){return p_(t,t=>Gw(e,t,n,r))}function qw(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=Yw(a,n);if(!o)return a.out?a.out:B(new fS(e,a.issues??[],r,i));if(F(o))return Jw(o,a);let s=!0;return L(()=>s?(s=!1,Jw(o,a)):qw(e,t,n,r,i))}function Jw(e,t){return jv(e,e=>t.out?Yx(t.out)?I(t.input):t.out:B(new fS(t.ast,t.issues??[],t.input,t.options)))}var Yw=hd()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=AS(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]),_p(new pS(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return bp}}}),Xw=new Ww([new nw(`Infinity`),new nw(`-Infinity`),new nw(`NaN`)]);function Zw(e){return e?``:`readonly `}function Qw(e){return e?`?`:``}var $w=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 $w(this.run,{...this.annotations,...e},this.aborted)}abort(){return new $w(this.run,this.annotations,!0)}and(e,t){return new eT([this,e],t)}},eT=class extends n{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new eT(this.checks,{...this.annotations,...e})}and(e,t){return new eT([this,e],t)}};function tT(e,t,n=!1){return new $w((t,n,r)=>gS(n,e(t,n,r),t,r),t,n)}function nT(e){return tT(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 rT=mT(sw,[nT()]),iT=new UC(new Ww([rT,Xw]),new aC(GS(),W(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function aT(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return tT(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 oT=new WeakMap;function sT(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&oT.set(n,cT(e)),n}function cT(e){let t=oT.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 oT.set(e,n),n}function lT(e,t){return e.encoding===t?e:sT(e,{encoding:t})}function uT(e,t){if(e.context===t)return e;let n=cT(e);return n.context===t&&n.encoding===e.encoding?n:sT(e,{context:t})}function dT(e){return e.encoding?dT(e.encoding[e.encoding.length-1].to):e}function fT(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return pT(e,wi(e.checks.slice(0,-1),n.annotate(t)))}return sT(e,{annotations:{...e.annotations,...t}})}function pT(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:sT(e,{checks:t})}function mT(e,t){return pT(e,Ow(e.checks,t))}function hT(e,t){let n=t(e.to);return n===e.to?e:new UC(n,e.transformation)}function gT(e,t){let n=e,r=n[n.length-1],i=hT(r,t);return i===r?e:wi(e.slice(0,e.length-1),i)}function _T(e){return t=>t.encoding?lT(t,gT(t.encoding,e)):t}function vT(e,t){return _T(e=>uT(e,t))(e)}function yT(e){function t(n){return n.encoding?lT(n,gT(n.encoding,t)):e(n)}return p(t)}function bT(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:lT(r,gT(r.encoding,n))}return e(r)}return m(n)}function xT(e,t,n){let r=new UC(e,t);return lT(n,n.encoding?[...n.encoding,r]:[r])}function ST(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 CT(e,t){return uT(e,e.context?new GC(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new GC(!1,!1,void 0,t))}var wT=m(e=>TT(uT(e,e.context?e.context.isOptional===!1?new GC(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new GC(!0,!1)))),TT=_T(wT),ET=p(e=>wT(new Ww([e,QC])));function DT(e,t){return uT(e,e.context?new GC(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new GC(!1,!1,t))}function OT(e,t,n){return xT(e,n,t)}function kT(e){let t=[],n=[];function r(e){t.includes(e)||t.push(e)}function i(e){switch(e._tag){case`Literal`:ue(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 AT(e,t){let{literals:n,parameters:r}=kT(e);return new Cw(n.map(e=>new vw(e,t)),r.map(e=>new Sw(e,t)))}function jT(e){return e.context?.isOptional??!1}function MT(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(MT)}function NT(e){function t(e){return MT(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Oi(n)?n:void 0}function PT(e){let t=!0;function n(e){return t=t&&!e.encoding&&!HC(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var FT=m(e=>{let t=cT(e);if(t!==e){let n=FT(t);return n===t&&e.encoding===void 0?e:uT(n,e.context)}let n=`recur`in e?e.recur(FT):e;return`encodingChecks`in n&&n.encodingChecks?sT(n,{encodingChecks:void 0,checks:Ow(PT(e)?n.encodingChecks:zC(n)||BC(n)||AC(n)&&n.typeParameters.length>0?NT(n.encodingChecks):void 0,n.checks)}):n}),IT=m(e=>FT(RT(e)));function LT(e,t){let n=t,r=n.length,i=n[r-1],a=[new UC(RT(lT(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new UC(RT(n[e-1].to),n[e].transformation.flip()));let o=RT(i.to);return o.encoding?lT(o,[...o.encoding,...a]):lT(o,a)}var RT=p(e=>{if(e.encoding)return LT(e,e.encoding);let t=cT(e);if(t!==e){let n=RT(t);return n===t?e:uT(n,e.context)}return`flip`in e?e.flip(RT):`recur`in e?e.recur(RT):e});function zT(e,t){let n=t===0?Jx:Kx(t);return(r,i)=>r===U?qx:r===t?n:B(new cS(e,r,i))}function BT(e,t){return(n,r)=>n===U?qx:t(n)?Jx:B(new cS(e,n,r))}var VT=bT(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(VT)}}),HT=bT(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(HT)}}),UT=new globalThis.RegExp(`^${gw}$`),WT=new globalThis.RegExp(`^(?:${gw}|Infinity|-Infinity|NaN)$`);function GT(e){return aT(UT,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:UT.source}),...e})}var KT=mT(iw,[GT()]),qT=new UC(KT,mC),JT=new UC(new Ww([KT,Xw]),mC),YT=new globalThis.RegExp(`^-?\\d+$`);function XT(e){return aT(YT,{expected:`a string representing a bigint`,representation:{id:`effect/schema/isStringBigInt`,payload:null},toJsonSchema:()=>({pattern:YT.source}),...e})}var ZT=new UC(mT(iw,[XT({expected:`a string representing a bigint`})]),hC);function QT(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=QT(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 nS(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function $T(e){if(!AC(e))return;let t=e.annotations?.[Wx];return de(t)?t(e.typeParameters):void 0}function eE(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function tE(e){return e===void 0||typeof e==`string`}function nE(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 rE(e){return nE(e,eE)}var iE=new JC([],()=>(e,t,n)=>rE(e)?Jx:B(new cS(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>cE}),aE=new UC(iE,pC()),oE=new UC(new Ww([new uw(!1,[],[iE]),new Cw([],[new Sw(iw,iE)])]),pC());function sE(e){return nE(e,tE)}var cE=new UC(new JC([],()=>(e,t,n)=>sE(e)?Jx:B(new cS(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),pC()),lE=(e,t,n)=>Yx(e)?n(t):jv(e,n);function uE(e){let t=dE(e);return(e,n,r)=>{try{return t(e,n,r)}catch(e){return $g(e)}}}function dE(e){if(e._tag===`Middleware`)return(t,n,r)=>fE(Yx(t)?e.decode(Kx(Xx(n)),r):e.decode(Ov(t,Xx),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>Yx(e)?Kx(t):e;case`Transform`:{let e=e=>e===U?qx:Kx(t.transform(e));return(t,n)=>lE(t,n,e)}case`TransformOptional`:{let e=e=>Zx(t.transform(Xx(e)));return(t,n)=>lE(t,n,e)}case`TransformEffect`:return(e,n,r)=>lE(e,n,e=>e===U?qx:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>lE(e,n,e=>fE(t.transform(Xx(e),r)))}}var fE=e=>jv(e,Zx),pE=(e,t,n,r)=>p_(r,r=>Qg(()=>Xf(r,r=>new rS(e,r,t,n))));function mE(e,t){let n=uE(e.link.transformation),r;return(i,a)=>{if(i===U)return qx;if(e.isConstructed(i))return Jx;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function hE(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==U&&r!==void 0)return t(r,i);let a=n;if(F(a)&&a._tag===`Success`){let e=t(a[S],i);return Yx(e)?a:e}return jv(pE(e,r,i,a),e=>{let n=t(e,i);return Yx(n)?Kx(e):n})}}function gE(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:hE(e,n)}function _E(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?$T(e):void 0,o=a?mE(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>uE(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(F(r)){if(r._tag===`Success`){let i=Yx(r)?t:r[S];if(t!==U&&i!==U){let i=QT(u,t,void 0,e,n);i&&(r=B(new sS(e,i,t,n)))}}}else r=V(r,r=>{if(t!==U&&r!==U){let r=QT(u,t,void 0,e,n);if(r)return B(new sS(e,r,t,n))}return I(r)})}if(s&&!n.disableChecks){if(F(r)){if(r._tag===`Success`){let i=Yx(r)?t:r[S];if(i===U)return r;let a=QT(s,i,void 0,e,n);a&&(r=B(new sS(e,a,i,n)))}}else r=V(r,t=>{if(t!==U){let r=QT(s,t,void 0,e,n);if(r)return B(new sS(e,r,t,n))}return I(t)})}return r}catch(e){return $g(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=jv(o,e=>{let n=t(e,r);return Yx(n)?Kx(e):n})}if(o._tag===`Success`){let e=o[S],t=p(e,r);return Yx(t)?o:t}return o=pE(e,n,r,o),jv(o,e=>{let t=p(e,r);return Yx(t)?Kx(e):t})}:p}var vE=Symbol(),yE=new WeakMap,bE=e=>wE(e).parser,xE=e=>wE(e).makeEffect,SE=e=>gE(e,xE),CE=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=_E(this.ast,bE)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=_E(this.ast,xE,SE)}};function wE(e){let t=yE.get(e);if(t!==void 0)return t;let n=new CE(e);return yE.set(e,n),n}function TE(e){let t=e.ast,n;return(e,r)=>(n??=RE(JE,FT(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function EE(e){let t=TE(e);return(e,n)=>{let r=Sv(t(e,n));return xp(r)?E(r.value):(jS(r.cause,`Option adapter can only return none for schema issues`),T())}}function DE(e){return WE(FT(e.ast))}function OE(e){return AE(e.ast)}function kE(e){{let t=zE(IE(e));return e=>{let n=t(e,WC);return xp(n)?!0:(jS(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function AE(e){let t=FT(e),n=e=>(n=kE(t),n(e));return e=>n(e)}function jE(e,t){let n=IE(e.ast);return t===void 0?n:(e,r)=>n(e,PE(t,r))}function ME(e,t){return BE(jE(e,t))}function NE(e,t){let n=IE(RT(e.ast));return t===void 0?n:(e,r)=>n(e,PE(t,r))}var PE=(e,t)=>t?{...e,...t}:e,FE=e=>e===U?B(new lS):I(e);function IE(e){return RE(qE,e)}function LE(e,t){return Yx(e)?I(t):F(e)?e[`~effect/Effect/args`]===U?FE(U):e:jv(e,FE)}function RE(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??WC);return Yx(a)?I(r):F(a)?a[`~effect/Effect/args`]===U?FE(U):a:jv(a,FE)}}function zE(e){return(t,n)=>Sv(e(t,n))}function BE(e){let t=zE(e);return(e,n)=>{let r=t(e,n);return xp(r)?qr(r.value):Jr(jS(r.cause,`Result adapter can only return schema issues`))}}function VE(e,t){let n=Sv(e);if(xp(n))return n.value;let r=jS(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}var HE=`Constructor adapter can only throw schema issues`;function UE(e){throw Error(HE,{cause:Wf(e)})}function WE(e){let t;return(n,r)=>GE(t??=wE(e),n,r)}function GE(e,t,n){let r=n?.disableChecks?n.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions??WC,i=e.make;if(i!==void 0&&t!==U){let e;try{e=i(t,r)}catch(e){UE(e)}if(e!==vE&&e!==U)return e}return VE(LE(e.makeEffect(t,r),t),HE)}function KE(e,t,n,r){let i=wE(e),a=$T(e);if(a===void 0||i.make!==void 0||i.compiledMakeEffect!==void 0)return GE(i,t,n);if(a.isConstructed(t))return t;let o=GE((i.resolve??wE)(a.link.to),t,n);try{return r(o)}catch(e){UE(e)}}var qE=e=>wE(e).parser,JE=e=>wE(e).makeEffect,YE=`~effect/Schema/Schema`,XE=Symbol(),ZE={[YE]:YE,get make(){let e=DE(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=TE(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=EE(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return e(this,arguments)},annotate(e){return this.rebuild(fT(this.ast,e))},annotateKey(e){return this.rebuild(CT(this.ast,e))},check(...e){return this.rebuild(mT(this.ast,e))},rebuild(e){return QE(e,this[XE])}};function QE(e,t){function n(){}let r=Object.setPrototypeOf(n,ZE);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[XE]=t,r.ast=e,r}function $E(e){return QE(eD(e.ast),{schema:e})}var eD=tD(oD);function tD(e,t){let n=p(t=>{let n=uT(t,void 0),i=e(n,r);return i===n?null:i}),r=bT(e=>{let t=n(cT(e));if(t===null)return e;let r=uT(t,e.context);return e.context===void 0?r:vT(r,nD(e.context))},t);return r}function nD(e){return e.constructorDefault===void 0?e:new GC(e.isOptional,e.isMutable,void 0,e.annotations)}function rD(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function iD(e){return t=>{let n=[...t].sort((t,n)=>e(IT(t))-e(IT(n)));return n.some((e,n)=>e!==t[n])?n:t}}var aD=iD(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function oD(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!de(n))return lT(e,[aE]);let r=n(e.typeParameters.map(e=>QE(IT(e))));return r===void 0?e:lT(e,[hT(r,t)])}case`Unknown`:return lT(e,[aE]);case`ObjectKeyword`:return lT(e,[oE]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return rD(e),e.recur(t,HT);case`Union`:{let n=aD(e.types);return n===e.types?e.recur(t):new Ww(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 sD(e){return QE(pD(e.ast),{schema:e})}var cD=iD(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function lD(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>QE(t(IT(e)))),i=e.annotations?.toCodecStringTree;if(de(i)){let n=i(r);return n===void 0?e:lT(e,[hT(n,t)])}let a=e.annotations?.toCodecJson,o=de(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(de(s)?s(r):void 0);return c===void 0?n(e):lT(e,[hT(c,t)])}case`Null`:return lT(e,[uD]);case`Boolean`:return lT(e,[dD]);case`Unknown`:case`ObjectKeyword`:return lT(e,[cE]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return rD(e),e.recur(t,HT);case`Union`:{let n=cD(e.types);return n===e.types?e.recur(t):new Ww(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 uD=new UC(new nw(`null`),new aC(W(()=>null),W(()=>`null`))),dD=new UC(new Ww([new nw(`true`),new nw(`false`)]),new aC(W(e=>e===`true`),WS())),fD=new aC(W(e=>typeof e==`string`?[e]:e),BS()),pD=tD((e,t)=>lD(e,t,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})}),{stopAt:e=>e.transformation===fD});function mD(e){return xp(e)?e.value:{issues:[{message:ip(e.cause)}]}}function hD(e,t){let n=jE(e),r={errors:`all`,...t?.parseOptions},i=yS(t);return gD(e,{validate:e=>{let t=new Go(`sync`),a=mv(M_(n(e,r),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});a.currentDispatcher?.flush();let o=a.pollUnsafe();return o?mD(o):new Promise(e=>{a.addObserver(t=>{e(mD(t))})})}})}function gD(e,t){let n={version:1,vendor:`effect`,...Object.hasOwn(e,`~standard`)?e[`~standard`]:void 0,...t},r=typeof e==`function`?Function.prototype.bind.call(e,void 0):Object.create(Object.getPrototypeOf(e));return Object.defineProperties(r,{...Object.getOwnPropertyDescriptors(e),ast:{value:e.ast,enumerable:!0,configurable:!0},"~standard":{value:n,writable:!0,enumerable:!0,configurable:!0}})}var _D=r(2,(e,t)=>xD(e,(e,n)=>bD(t,e)?[e,n]:void 0)),vD=r(2,(e,t)=>xD(e,(e,n)=>[e,Object.hasOwn(t,e)?t[e](n):n])),yD=e=>e;function bD(e,t){return e.some(e=>e===t||typeof e==`number`&&String(e)===t)}function xD(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 SD=`~effect/Schema/SchemaError`;function CD(e){return v(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var wD=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},TD=mr((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)});({...Lt}),{...Lt},{...Lt},{...Lt},{...Lt},{...Lt},{...Lt},{...Lt};var ED=YE;function DD(){return(e,t,n)=>G(new JC(e.map(Aw),e=>t(e.map(e=>G(e))),n))}function OD(e,t){return DD()([],()=>(t,n,r)=>e(t)?I(t):B(new cS(n,t,r)),t)}var kD=class extends Zo(`SchemaError`){[SD]=SD;constructor(e){let t=Bt();Vt(0);try{super({issue:e})}finally{Vt(t)}}get message(){return DS(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Pt](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function AD(e){return CD(e)}function jD(e){return F(e)?MD(e):p_(e,e=>Qg(()=>Xf(e,e=>new kD(e))))}function MD(e){return xp(e)?e:gp(Xf(e.cause,e=>new kD(e)))}function ND(e,t){let n;for(let r of e.reasons){if(!zf(r)||!AD(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 PD(e){let t=Sv(e);if(xp(t))return t.value;throw ND(t.cause,`Sync adapter can only throw schema errors`)}function FD(e,t){return hD(e,t)}var ID=OE;function LD(e,t){let n=jE(e,t);return(e,t)=>jD(n(e,t))}var RD=LD;function zD(e,t){let n=ME(e,t);return(e,t)=>ei(n(e,t),e=>new kD(e))}function BD(e,t){let n=LD(e,t);return(e,t)=>PD(n(e,t))}var VD=BD;function HD(e,t){let n=NE(e,t);return(e,t)=>jD(n(e,t))}var UD=HD;function WD(e,t){let n=HD(e,t);return(e,t)=>PD(n(e,t))}var GD=WD,G=QE;function KD(e){return v(e,ED)&&e[ED]===ED}var qD=yD(e=>G(wT(e.ast),{schema:e})),JD=yD(e=>{let t=gO(e);return G(ET(e.ast),{schema:t})}),YD=yD(e=>G(FT(e.ast),{schema:e}));function XD(e){let t=G(new nw(e),{literal:e,transform(n){return t.pipe(vO(XD(n),{decode:W(()=>n),encode:W(()=>e)}))}});return t}var ZD=G(ew),QD=G(tw),$D=G(YC),eO=G(QC),K=G(iw),tO=G(sw),nO=G(cw),rO=G(lw),iO=G($C);function aO(e,t){return G(e,{fields:t,mapFields(e,t){let n=e(this.fields);return aO(kw(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function q(e){return aO(kw(e,void 0),e)}function oO(e,t){return G(AT(e.ast,t.ast),{key:e,value:t})}function sO(e,t){return G(e,{elements:t,mapElements(e,t){let n=e(this.elements);return sO(jw(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function cO(e){return sO(jw(e),e)}var lO=yD(e=>G(new uw(!1,[],[e.ast]),{value:e})),uO=yD(e=>G(new uw(!1,[e.ast],[e.ast]),{value:e})),dO=yD(e=>G(Nw(e.ast),{schema:e}));function fO(e,t){return G(e,{members:t,mapMembers(e,t){let n=e(this.members);return fO(Mw(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function pO(e,t){return fO(Mw(e,t,void 0),e)}function mO(e){let t=e.map(XD);return G(Mw(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return pO(e(this.members))},pick(e){return mO(e)},transform(e){return pO(t.map((t,n)=>t.transform(e[n])))}})}var hO=yD(e=>pO([e,$D])),gO=yD(e=>pO([e,eO]));function _O(e){return t=>G(t.ast,{schema:t,identifier:e})}function vO(e,t){return n=>G(OT(n.ast,e.ast,t?sC(t):pC()),{from:n,to:e})}function yO(){return(e,t)=>EO()(e,{decode:t,encode:RS})}function bO(e){return t=>G(DT(t.ast,e),{schema:t})}function xO(e){return XD(e).pipe(bO(I(e)))}function SO(e,t){return q({_tag:xO(e),...t})}function CO(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(VC(s)&&`members`in t&&globalThis.Array.isArray(t.members)&&t.members.every(KD))return t.members.forEach(o);let c=Iw(s);if(c.length>0){let o=c.find(t=>t.key===e)?.literal;if(ue(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,OE(YD(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 wO(e){let t={},n=[];for(let r of Object.keys(e)){let i=SO(r,e[r]);b(t,r,i),n.push(i)}let r=pO(n),{tag:i,guards:a,isAnyOf:o,match:s,matchOrElse:c}=CO(`_tag`)(r);return G(r.ast,{tag:i,cases:t,isAnyOf:o,guards:a,match:s,matchOrElse:c})}function TO(e,t){return OD(t=>t instanceof e,t)}function EO(){return(e,t)=>new UC(e.ast,sC(t))}var DO=tT;function OO(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 aT(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var kO=G(rT);function AO(e){let t=Sr(e.order),n=br(e.order),r=xr(e.order),i=yr(e.order),a=e.formatter??x;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return DO(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function jO(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${x(e)}`);return e}var MO=AO({order:gr,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:jO(e.minimum),maximum:jO(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${x(e.minimum)}, maximum: ${x(e.maximum)}, exclusiveMinimum: ${x(t)}, exclusiveMaximum: ${x(n)} })`})}}});function NO(e){return DO(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 PO=tO.check(NO());function FO(e,t,n){return DO(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})`}),[Hx]:!0,arbitraryConstraint:{minLength:e},...n})}function IO(e){return FO(1,1,e)}function LO(e,t){return e=RO(e),DO(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})`}),[Hx]:!0,arbitraryConstraint:{maxLength:e},...t})}function RO(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var zO=K.check(IO()),BO=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),VO=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},HO=[];function UO(e){let t=BO(e),n=HO[t];if(n!==void 0)return n;let r=jk.pipe(vO(QD,SC(VO(t))));return HO[t]=r,r}globalThis.RegExp,globalThis.URL;var WO=K.annotate({expected:`a string that will be decoded as JSON`});function GO(e,t){return WO.pipe(vO(e,OC(t)))}globalThis.File,globalThis.URLSearchParams;var KO=K.annotate({expected:`a string that will be decoded as a finite number`}).pipe(vO(kO,mC)),qO=K.annotate({expected:`a URI component encoded string that will be decoded as a UTF-8 string`}).pipe(vO(K,DC)),JO=mO([0,1]).pipe(vO(nO,lC({decode:e=>e===1,encode:e=>+!!e}))),YO=K.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),XO=TO(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>EO()(YO,EC)});function ZO(e,t){return G(DD()([e,t],([e,t])=>(n,r,i)=>{if(!Rf(n))return B(new cS(r,n,i));switch(n._tag){case`Fail`:return Av(jE(e)(n.error,i),{onSuccess:Kf,onFailure:e=>uS(r,`error`,e,n,i)});case`Die`:return Av(jE(t)(n.defect,i),{onSuccess:qf,onFailure:e=>uS(r,`defect`,e,n,i)});case`Interrupt`:return I(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])=>EO()(pO([q({_tag:XD(`Fail`),error:e}),q({_tag:XD(`Die`),defect:t}),q({_tag:XD(`Interrupt`),fiberId:gO(kO)})]),lC({decode:e=>{switch(e._tag){case`Fail`:return Kf(e.error);case`Die`:return qf(e.defect);case`Interrupt`:return Jf(e.fiberId)}},encode:e=>{switch(e._tag){case`Fail`:return{_tag:`Fail`,error:e.error};case`Die`:return{_tag:`Die`,defect:e.defect};case`Interrupt`:return{_tag:`Interrupt`,fiberId:e.fiberId}}}}))}).ast,{error:e,defect:t})}function QO(e,t){return G(DD()([e,t],([e,t])=>{let n=lO(ZO(e,t));return(e,t,r)=>Lf(e)?Av(jE(n)(e.reasons,r),{onSuccess:Hf,onFailure:n=>uS(t,`reasons`,n,e,r)}):B(new cS(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])=>EO()(lO(ZO(e,t)),lC({decode:Hf,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}function $O(){return VS((e,t)=>Or(Vv(e),{onNone:()=>B(new lS({message:`Invalid DateTime input`},e,t)),onSome:e=>I(Wv(e))}))}var ek=cC({decode:(e,t)=>Or(Vv(e),{onNone:()=>B(new lS({expected:`a valid UTC DateTime string`},e,t)),onSome:e=>I(Wv(e))}),encode:e=>I(ey(e))}),tk=-864e13,nk=864e13;function rk(e,t,n){let r=Math.max(t,e?.minimum===void 0?t:e.minimum.epochMilliseconds+ +(e.exclusiveMinimum===!0)),i=Math.min(n,e?.maximum===void 0?n:e.maximum.epochMilliseconds-+(e.exclusiveMaximum===!0));return r<=i?[r,i]:[t,n]}function ik(e,t){return PO.check(MO({minimum:e,maximum:t}))}var ak=OD(e=>Pv(e)&&Fv(e),{representation:{id:`effect/schema/DateTimeUtc`,payload:null},toCode:()=>({runtime:`Schema.DateTimeUtc`,Type:`DateTime.Utc`,importDeclarations:[`import * as DateTime from "effect/DateTime"`]}),expected:`DateTime.Utc`,toCodecArbitrary:({constraint:e})=>{let[t,n]=rk(e,tk,nk);return yO()(ik(t,n),W(zv))},toCodecJson:()=>EO()(K,ek),toFormatter:()=>e=>e.toString()}),ok=PO.pipe(vO(ak,{decode:$O(),encode:W(Jv)})),sk=lC({decode:e=>vo(e),encode:e=>So(e)}),ck=OD(co,{representation:{id:`effect/schema/Duration`,payload:null},toCode:()=>({runtime:`Schema.Duration`,Type:`Duration.Duration`,importDeclarations:[`import * as Duration from "effect/Duration"`]}),expected:`Duration`,toCodecJson:()=>EO()(pO([q({_tag:XD(`Infinity`)}),q({_tag:XD(`NegativeInfinity`)}),q({_tag:XD(`Nanos`),value:rO}),q({_tag:XD(`Millis`),value:PO})]),lC({decode:e=>{switch(e._tag){case`Infinity`:return ho;case`NegativeInfinity`:return go;case`Nanos`:return _o(e.value);case`Millis`:return vo(e.value)}},encode:e=>{switch(e.value._tag){case`Infinity`:return{_tag:`Infinity`};case`NegativeInfinity`:return{_tag:`NegativeInfinity`};case`Nanos`:return{_tag:`Nanos`,value:e.value.nanos};case`Millis`:return{_tag:`Millis`,value:e.value.millis}}}}))}),lk=tO.pipe(vO(ck,sk));function uk(e,t,n){return G(DD()([e,t,n],([e,t,n])=>{let r=QO(t,n);return(t,n,i)=>{if(!mp(t))return B(new cS(n,t,i));switch(t._tag){case`Success`:return Av(jE(e)(t.value,i),{onSuccess:hp,onFailure:e=>uS(n,`value`,e,t,i)});case`Failure`:return Av(jE(r)(t.cause,i),{onSuccess:gp,onFailure:e=>uS(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])=>EO()(pO([q({_tag:XD(`Success`),value:e}),q({_tag:XD(`Failure`),cause:QO(t,n)})]),lC({decode:e=>e._tag===`Success`?hp(e.value):gp(e.cause),encode:e=>xp(e)?{_tag:`Success`,value:e.value}:{_tag:`Failure`,cause:e.cause}}))}).ast,{value:e,error:t,defect:n})}function dk(e){return G(DD()([e],([e])=>(t,n,r)=>Tr(t)?Er(t)?qg:Av(jE(e)(t.value,r),{onSuccess:E,onFailure:e=>uS(n,`value`,e,t,r)}):B(new cS(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])=>EO()(pO([q({_tag:XD(`Some`),value:e}),q({_tag:XD(`None`)})]),lC({decode:e=>e._tag===`None`?T():E(e.value),encode:e=>Dr(e)?{_tag:`Some`,value:e.value}:{_tag:`None`}}))}).ast,{value:e})}function fk(e){return hO(e).pipe(vO(dk(YD(e)),CC()))}function pk(e){return qD(e).pipe(vO(dk(YD(e)),wC()))}function mk(e){return JD(e).pipe(vO(dk(YD(e)),TC()))}function hk(e,t){let n=t===void 0?`omit`:t.onNoneEncoding,r=n===null?null:void 0;return JD(hO(e)).pipe(vO(dk(YD(e)),uC({decode:e=>e.pipe(Ur(ge),E),encode:n===`omit`?Vr:e=>E(kr(Vr(e),()=>r))})))}function gk(e,t){let n=typeof t?.label==`string`?t.label:void 0,r=t?.disallowJsonEncode===!0,i=n===void 0?r?{disallowJsonEncode:!0}:void 0:r?{label:n,disallowJsonEncode:!0}:{label:n},a=n===void 0?void 0:jE(XD(n));return G(DD()([e],([e])=>(t,n,r)=>Bb(t)?jv(a===void 0?z:kv(a(t.label,r),e=>new iS([`label`],e)),()=>Av(jE(e)(Ub(t),r),{onSuccess:e=>Vb(e,{label:t.label}),onFailure:()=>new sS(n,[new iS([`value`],new lS(void 0,t,r))],t,r)})):B(new cS(n,t,r)),{representation:{id:`effect/schema/Redacted`,payload:i??null},toCode:({typeParameters:e})=>({runtime:i===void 0?`Schema.Redacted(${e[0].runtime})`:`Schema.Redacted(${e[0].runtime}, ${x(i)})`,Type:`Redacted.Redacted<${e[0].Type}>`,importDeclarations:[`import * as Redacted from "effect/Redacted"`]}),expected:`Redacted`,toCodecJson:([e])=>EO()(e,{decode:W(e=>Vb(e,{label:n})),encode:r?LS(e=>`Cannot serialize Redacted`+(Dr(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):W(Ub)}),toEquivalence:([e])=>Wb(e)}).ast,{value:e})}function _k(e,t){return vO(gk(YD(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:W(e=>Vb(e,{label:t?.label})),encode:t?.disallowEncode?LS(e=>`Cannot encode Redacted`+(Dr(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):W(Ub)})(e)}var vk=globalThis.Symbol.for(`immer-draftable`),yk={};function bk(t,n,r,i,a){let o=wk(r,n,i),s=Ck(n),c=class extends t{constructor(...[e,t]){let n=t?.[`~payload`],i=n?.token===yk?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:yk,value:i}})}static[ED]=ED;get[s](){return s}static[vk]=!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 KE(FT(o(this).ast),e??{},t,e=>xk(this,e))}static makeOption(e,t){return EE(o(this))(e??{},t)}static makeEffect(e,t){return o(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(fT(this.ast,e))}static annotateKey(e){return this.rebuild(CT(this.ast,e))}static check(...e){return this.rebuild(mT(this.ast,e))}static extend(e){return(t,n)=>{let i=Tk(t)?t:q(t),o={...r.fields,...i.fields},s=kw(o,r.ast.checks,{identifier:e});return bk(this,e,aO(mT(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 xk(e,t){return new e(t,{"~payload":{token:yk,value:t}})}function Sk(e){return new aC(W(t=>xk(e,t)),BS())}function Ck(e){return`~effect/Schema/Class/${e}`}function wk(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=Ck(t),o=e=>e instanceof i||v(e,a),s=Sk(i);return r=vO(G(new JC([e.ast],()=>(e,t,n)=>o(e)?I(e):B(new cS(t,e,n)),{identifier:t,[Wx]:([e])=>({isConstructed:o,link:new UC(e,s)}),toCodec:([e])=>new UC(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Ux]:Iw(e.ast),...n})),s)(e)}}function Tk(e){return KD(e)}var Ek=e=>(t,n)=>bk(Yo,e,Tk(t)?t:q(t),n,e=>({toString(){return`${e}(${x({...this})})`}})),Dk=e=>(t,n)=>bk(Fn,e,Tk(t)?t:q(t),n,e=>({name:e})),Ok=e=>(t,n,r)=>{let i=Tk(n)?n.mapFields(e=>({_tag:xO(t),...e}),{unsafePreserveChecks:!0}):SO(t,n);return Dk(e??t)(i,r)},kk=$E,Ak=sD,jk=G(fT(iE,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})}));function Mk(e){return Vx(e.ast)}var Nk=gc,Pk=vc,Fk=yc,Ik=bc,Lk=Sc,Rk=cc,zk=Ed,Bk=Bd,Vk=Vd,Hk=Symbol.for(`effect/MutableList/Empty`),Uk=()=>({head:void 0,tail:void 0,length:0}),Wk=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})},Gk=()=>({array:[],mutable:!0,offset:0,next:void 0}),Kk=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=Gk(),e.tail=e.tail.next):e.head=e.tail=Gk(),e.tail.array.push(t),e.length++},qk=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||=e.head,e.length++},Jk=(e,t)=>Yk(e,Array.from(t),!0),Yk=(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},Xk=e=>{e.head=e.tail=void 0,e.length=0},Zk=(e,t)=>{if(t=mt(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 Xk(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?Xk(e):Wk(e),n;i=i.next}return Xk(e),n},Qk=(e,t)=>{if(t=mt(t),t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){Xk(e);return}let n=0,r=e.head;for(;r;){let i=r.array.length-r.offset;if(n+i>t){r.offset+=t-n,e.head=r,e.length-=t,Wk(e);return}n+=i,r=r.next}Xk(e)},$k=e=>Zk(e,e.length),eA=e=>{if(!e.head)return Hk;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:Xk(e):Wk(e),t},tA=(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?Xk(e):(e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length)},nA=(e,t)=>tA(e,e=>e!==t),rA=`~effect/PubSub`,iA=`~effect/PubSub/Subscription`,aA=e=>R(()=>wA(e.atomicPubSub(),new Map,Hp(),Bk(!1),Cy(!1),e.strategy(),Cy(T()))),oA=e=>aA({atomicPubSub:()=>sA(e),strategy:()=>new TA}),sA=e=>{let t=e?.replay;return new bA(t&&t>0?new OA(Math.ceil(t)):void 0)},cA=e=>ev(n_(t=>(Ey(e.shutdownFlag,!0),qp(e.scope,yp(t.id)).pipe(o_(e.strategy.shutdown),j_(e.shutdownHook.open),d_)))),lA=r(2,(e,t)=>L(()=>e.shutdownFlag.current||Dr(e.ended.current)?I(!1):e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),I(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag,e.ended))),uA=r(2,(e,t)=>e.shutdownFlag.current||Dr(e.ended.current)?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),dA=e=>ev(F_(t=>{let n=D(t,Vp),r=Kp(e.scope),i=yA(e.pubsub,e.subscribers,e.strategy,e.ended);return Gp(r,fA(i)).pipe(o_(Wp(n,e=>qp(r,e))),u_(i))})),fA=e=>ev(n_(t=>(Ey(e.shutdownFlag,!0),Ug($k(e.pollers),e=>Mp(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(s_(()=>R(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),j_(e.shutdownHook.open),d_)))),pA=e=>L(()=>{if(e.shutdownFlag.current)return Z_;if(e.replayWindow.remaining>0)return I(e.replayWindow.take());let t=e.pollers.length===0?e.subscription.poll():Hk;return t===Hk?hA(e):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),I(t))}),mA=e=>L(function t(n){if(e.shutdownFlag.current)return Z_;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?I(e.replayWindow.takeAll().concat(r)):Oi(r)?I(r):V(hA(e),e=>t([e]))}),hA=e=>Jg(t=>{if(e.shutdownFlag.current)return t(Z_);if(Dr(e.ended.current)){let n=e.pollers.length===0?e.subscription.poll():Hk;return n===Hk?t(I(e.ended.current.value)):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),t(I(n)))}let n=Ep(),r=e.subscribers.get(e.subscription);return r||(r=new Set,e.subscribers.set(e.subscription,r)),r.add(e.pollers),Kk(e.pollers,n),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),n.effect?t(n.effect):(n.resumes=[t],R(()=>nA(e.pollers,n)))}),gA=Symbol.for(`effect/PubSub/AbsentValue`),_A=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)},vA=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.delete(n),r.size===0&&e.delete(t)},yA=(e,t,n,r)=>new SA(e,t,e.subscribe(),Uk(),Bk(!1),Cy(!1),n,e.replayWindow(),r),bA=class{publisherHead={value:gA,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 kA(this.replayBuffer):AA}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=gA,this.subscribersIndex+=1,this.replayBuffer?.slide(t,e.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new xA(this,this.publisherTail,this.publisherIndex,!1)}},xA=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===gA?(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 Hk;let e=!0,t=Hk;for(;e;)if(this.subscriberHead===this.self.publisherTail)e=!1;else{let n=this.subscriberHead.next.value;n!==gA&&(t=n,--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=gA,this.self.subscribersIndex+=1),e=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return t}pollUpTo(e){e=mt(e);let t=[],n=0;for(;n!==e;){let r=this.poll();r===Hk?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!==gA&&(--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=gA,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},SA=class{[iA]={_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)}},CA=class{[rA]={_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)}},wA=(e,t,n,r,i,a,o)=>new CA(e,t,n,r,i,a,o),TA=class{get shutdown(){return z}handleSurplus(e,t,n,r){return I(!1)}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return EA(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return DA(this,e,t)}},EA=(e,t,n,r,i)=>{let a=!0;for(;a&&!r.isEmpty();){let o=eA(i);if(o===Hk)vA(n,r,i),i.length===0?a=!1:_A(n,r,i);else{let a=r.poll();a===Hk?qk(i,o):(Ip(o,hp(a)),e.onPubSubEmptySpaceUnsafe(t,n))}}},DA=(e,t,n)=>{for(let[r,i]of n)for(let a of i)e.completePollersUnsafe(t,n,r,a)},OA=class{capacity;head={value:gA,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:gA,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=gA}else this.size+=1;return t}offerAll(e){for(let t of e)this.offer(t)}},kA=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]=gA,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),e}takeN(e){e=mt(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)}},AA={remaining:0,take:()=>void 0,takeN:()=>[],takeAll:()=>[],close:()=>void 0},jA=`~effect/Queue`,MA=`~effect/Queue/Enqueue`,NA=`~effect/Queue/Dequeue`,PA={_A:i,_E:i},FA={[jA]:PA,[MA]:PA,[NA]:PA,...$t,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:ZA(this)}}},IA=e=>w(t=>{let n=Object.create(FA);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=Uk(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},A(n)}),LA=e=>IA({capacity:e}),RA=r(2,(e,t)=>M(()=>zA(e,t)?$A:e.state._tag===`Open`&&e.strategy===`suspend`?cj(e,t):QA)),zA=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.capacity<=0&&e.state.takers.size>(e.strategy===`sliding`?0:e.messages.length)?(Kk(e.messages,t),e.strategy===`sliding`&&Qk(e.messages,e.messages.length-e.state.takers.size),nj(e),!0):e.strategy===`sliding`&&(e.capacity>0&&(eA(e.messages),Kk(e.messages,t)),!0):(Kk(e.messages,t),rj(e),!0):!1,BA=r(2,(e,t)=>Lc(n=>{let r=VA(e,t);return r.length===0||e.strategy===`dropping`?n(C(r)):lj(e,{_tag:`Array`,remaining:r,offset:0,resume:n})})),VA=(e,t)=>{if(e.state._tag!==`Open`)return xi(t);if(e.capacity===1/0||e.strategy===`sliding`){if(Jk(e.messages,t),e.strategy===`sliding`){let t=e.capacity<=0?e.state.takers.size:e.capacity;Qk(e.messages,e.messages.length-t)}return rj(e),[]}let n=(e.capacity<=0?e.state.takers.size:e.capacity)-e.messages.length;if(n<=0)return xi(t);let r=[],i=0;for(let a of t)i<n?Kk(e.messages,a):r.push(a),i++;return rj(e),r},HA=r(2,(e,t)=>wc(()=>UA(e,t))),UA=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=Ol(jn(t),ej);return e.state.offers.size===0&&e.messages.length===0?(pj(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},rj(e),!0)},WA=e=>HA(e,vn(Hn())),GA=e=>wc(()=>KA(e)),KA=e=>{if(e.state._tag===`Done`)return!1;Xk(e.messages);let t=e.state.offers;pj(e,e.state._tag===`Open`?tj:e.state.exit);for(let e of t)uj(e);return!0},qA=e=>JA(e,1,1/0),JA=r(3,(e,t,n)=>(t=mt(t),n=mt(n),aj(()=>ij(e,t,n)??il(sj(e,()=>oj(e,t)),JA(e,t,n))))),YA=e=>aj(()=>XA(e)??il(sj(e,()=>oj(e,1)),YA(e))),XA=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=eA(e.messages);return fj(e),C(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=dj(e.state.offers);return fj(e),C(t)}},ZA=e=>e.state._tag===`Done`?0:e.messages.length,QA=C(!1),$A=C(!0),ej=Mn(Hn()),tj=yl(),nj=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(wl),e.messages.length===0))break}},rj=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,nj(e)},0))},ij=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return C([]);if(!oj(e,t))return;let r=e.messages.length>0?Zk(e.messages,n):[dj(e.state.offers)];return fj(e),C(r)},aj=Dn({op:`QueueTake`,[Jt](e){let t=this[S]();return nn(t)?t[Jt](e):t}}),oj=(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,sj=(e,t)=>Lc(n=>{if(e.state._tag===`Done`)return n(e.state.exit);if(t())return n(wl);let r={ready:t,resume:n};return e.state.takers.add(r),wc(()=>{e.state._tag!==`Done`&&e.state.takers.delete(r)})}),cj=(e,t)=>Lc(n=>zA(e,t)?n($A):lj(e,{_tag:`Single`,message:t,resume:n})),lj=(e,t)=>{if(e.state._tag!==`Open`)return uj(t);let n=e.state.offers;return n.add(t),wc(()=>{e.state._tag!==`Done`&&(n.delete(t),e.state._tag===`Closing`&&n.size===0&&e.messages.length===0&&pj(e,e.state.exit))})},uj=e=>e._tag===`Single`?e.resume(QA):e.resume(C(e.remaining.slice(e.offset))),dj=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume($A),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(C([]))),n},fj=e=>{if(e.state._tag===`Done`)return eg(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0&&(pj(e,e.state.exit),eg(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`)Kk(e.messages,t.message),e.state.offers.delete(t),t.resume($A);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;Kk(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(C([]))}let r=e.state;if(r._tag===`Done`)return eg(r.exit.cause)}return!1},pj=(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()},mj=e=>new _j(e),hj=e=>{for(let t of e.waiters)if(t.permits<=e.free)return t},gj=(e,t,n,r=i)=>w(i=>{if(e.free>=t&&hj(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),Gu(i,o);let s=P(r(Lc(t=>{hj(e)===a?t(N):a.resume=t})),()=>hj(e)===a?(e.taken+=t,o(),n()):s);return s}),_j=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){return gj(this,e,()=>A(e))}takeScoped(e){return ld(t=>P(Lu,n=>gj(this,e,()=>ju(n,this.release(e)),t)))}takeIfAvailable(e){return M(()=>this.free<e?A(!1):(this.taken+=e,A(!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?.(N)}},0),this.free}resize(e){return w(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),N))}release(e){return w(t=>A(this.releaseUnsafe(t,e)))}get releaseAll(){return w(e=>A(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>ld(n=>gj(this,e,()=>Wu(n(t),()=>{this.releaseUnsafe(cc(),e)},!0),n))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>ld(n=>this.free<e?Oc:(this.taken+=e,Wu(n(rl(t)),()=>{this.releaseUnsafe(cc(),e)},!0)))}},vj=e=>mp(e)?xp(e)?sp(e.value):e:I(e),yj=`~effect/Channel`,bj=e=>v(e,yj),xj={[yj]:{_Env:i,_InErr:i,_InElem:i,_OutErr:i,_OutElem:i},pipe(){return e(this,arguments)}},Sj=e=>{let t=Object.create(xj);return t.transform=(t,n)=>p_(e(t,n),e=>I(Zg(e))),t},Cj=(e,t)=>Sj((n,r)=>V(Ej(e)(n,r),e=>t(e,r))),wj=e=>Sj((t,n)=>e),Tj=e=>Sj(Cv(function*(t,n){let r=Kp(n),i=e=>qp(r,ig(e));return q_(yield*q_(e(t,n,r),i),i)})),Ej=e=>e.transform,Dj=(e,t,n)=>IA({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(s_(t=>Gp(e,GA(t))),s_(n=>Up(t(n),e).pipe(p_(e=>HA(n,e)),dv(e,{startImmediately:!0})))),Oj=(e,t)=>Sj((n,r)=>H(Dj(r,e,t),qA)),kj=e=>Sj((t,n)=>L(()=>Ej(e())(t,n))),Aj=e=>wj(R(()=>{let t=e();return L(()=>{let e=t.next();return e.done?sp(e.value):I(e.value)})})),jj=e=>Lj(I(e)),Mj=wj(I(sp())),Nj=wj(I(Yg)),Pj=e=>wj(I(B(e))),Fj=e=>wj(Zg(e)),Ij=e=>Fj(Wf(e)),Lj=e=>wj(R(()=>{let t=!1;return L(()=>t?sp():(t=!0,e))})),Rj=e=>wj(V(e,()=>sp())),zj=e=>wj(I(V(e,vj))),Bj=e=>wj(I(qA(e))),Vj=e=>wj(I($_(mA(e),()=>sp()))),Hj=e=>dM(H(dA(e),Vj)),Uj=e=>Sj((t,n)=>Wj({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Wj=e=>{let t=e.readable.getReader(),n=e.exit??Cy(void 0),r=L(()=>n.current?n.current:N_(Kg({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??Zg(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?sp():I(zi(t))}));return u_(Gp(e.scope,e.releaseLockOnEnd?R(()=>t.releaseLock()):Gg(()=>t.cancel().catch(e=>t.closed.then(()=>Promise.reject(e),u))).pipe(K_(R(()=>t.releaseLock())))),r)},Gj=r(2,(e,t)=>Cj(e,e=>R(()=>{let n=0;return H(e,e=>t(e,n++))}))),Kj=e=>e===void 0||e!==`unbounded`&&e<=1,qj=r(e=>bj(e[0]),(e,t,n)=>Kj(n?.concurrency)?Jj(e,t):Yj(e,t,n)),Jj=(e,t)=>Sj((n,r)=>{let i=0;return H(Ej(e)(n,r),V(e=>t(e,i++)))}),Yj=(e,t,n)=>Tj(Cv(function*(r,i,o){let s=0,c=yield*Ej(e)(r,i),l=n.concurrency===`unbounded`?2**53-1:Math.min(n.concurrency,2**53-1),u=yield*LA(0);yield*Gp(o,GA(u));let d=hv(yield*P_()),f=zk(o);if(n.unordered){let e=mj(l),n=a(e.release(1)),r=N_({onFailure:e=>V(HA(u,e),n),onSuccess:e=>V(RA(u,e),n)});yield*e.take(1).pipe(V(()=>c),V(e=>{let n=s++;return f(d(r(L(()=>t(e,n))))),z}),nv({disableYield:!0}),p_(t=>e.withPermits(l-1)(HA(u,t))),dv(o))}else{let e=yield*LA(l-2);yield*Gp(o,GA(e)),yield*YA(e).pipe(a_,V(e=>RA(u,e)),nv({disableYield:!0}),p_(e=>HA(u,e)),dv(o));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,UA(u,e.cause))};yield*c.pipe(V(i=>{if(n)return Zg(n);let a=s++,o=d(L(()=>t(i,a)));return f(o),o.addObserver(r),RA(e,Pk(o))}),nv({disableYield:!0}),p_(t=>RA(e,gp(t)).pipe(o_(HA(e,t)))),dv(o))}return YA(u)})),Xj=r(e=>bj(e[0]),(e,t,n)=>Kj(n?.concurrency)?Zj(e,t):Qj(e,t,n)),Zj=(e,t)=>Sj((n,r)=>H(Ej(e)(n,r),e=>{let i,a,o=V(e,e=>(a??=Kp(r),jv(Ej(t(e))(n,a),e=>(i=s(e),i)))),s=$h(e=>{if(i=void 0,a.state._tag===`Empty`)return o;let t=qp(a,bp);return a=void 0,V(t,()=>o)});return L(()=>i??o)})),Qj=(e,t,n)=>e.pipe(Gj(t),lM(n)),$j=e=>Xj(e,i),eM=e=>Cj(e,e=>{let t,n=0;return I(L(function r(){if(t===void 0)return V(e,e=>{switch(e.length){case 0:return r();case 1:return I(e[0]);default:return t=e,I(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),I(i)}))}),tM=(e,t)=>Sj((n,r)=>R(()=>{let i,a=()=>{let o=Kp(r);return V(Ej(e)(n,o),e=>(i=p_(e,e=>{let n=ig(e);return qp(o,n).pipe(V(()=>t(n,r)),V(a))}),i))};return L(()=>i??a())})),nM=r(2,(e,t)=>Cj(e,e=>I(V(e,function n(r){let i=[];for(let e=0;e<r.length;e++)t(r[e])&&i.push(r[e]);return ki(i)?I(i):V(e,n)})))),rM=r(2,(e,t)=>Sj((n,r)=>{let i=Kp(r);return H(Ej(e)(n,i),e=>{let a=e.pipe(p_(e=>{if(eg(e))return Zg(e);let o=i;return i=Kp(r),qp(o,gp(e)).pipe(o_(Ej(t(e))(n,i)),V(e=>(a=e,e)))}));return L(()=>a)})})),iM=r(2,(e,t)=>rM(e,e=>Rj(V(t(e),t=>Zg(e))))),aM=r(3,(e,t,n)=>rM(e,e=>{let r=t(e);return Zr(r)?Fj(r.failure):n(r.success,e)})),oM=r(2,(e,t)=>aM(e,Ls,e=>t(e))),sM=r(e=>bj(e[0]),(e,t,n,r)=>oM(e,e=>t(e)?n(e):r?r(e):Pj(e))),cM=r(2,(e,t)=>kj(()=>{let n,r=sg.defaultValue(),a=hM(xM(e,sg,R(()=>r)),()=>(n=void 0,z)),o=typeof t==`function`?t(i):t;return tM(a,(e,t)=>{if(xp(e))return sp(e.value);let i=Ls(e.cause);return Zr(i)?Zg(i.failure):Xg(function*(){n||=yield*mg(o),r=yield*n(i.success)}).pipe($h(()=>B(i.success)),Up(t))})})),lM=r(2,(e,{bufferSize:t=16,concurrency:n,switch:r=!1})=>Tj(Cv(function*(i,a,o){let s=n===`unbounded`?2**53-1:Math.max(1,n),c=r?void 0:mj(s),l=yield*Vk(!0),u=new Map,d=yield*LA(t);yield*Gp(o,GA(d));let f=yield*Ej(e)(i,a);return yield*Xg(function*(){for(;;){let e;c&&(u.size<s?yield*c.take(1):(e=yield*uv(f),yield*A_(c.take(1),o_(Pk(e),Yg))));let t=e===void 0?yield*f:yield*Pk(e),n=Kp(o),r=yield*Ej(t)(i,n);for(;u.size>=s;){let[e,t]=ri(u);u.delete(e),u.size===0&&(yield*l.open),yield*Ik(e),yield*C_(qp(t,yp()))}let a=yield*r.pipe(s_(()=>t_),V(e=>RA(d,e)),nv({disableYield:!0}),q_(Cv(function*(e){let t=ig(e),r=yield*l_(qp(n,t));if(!u.has(a))return;let i=Cp([t,r]);Sp(i)&&(yield*HA(d,i.cause)),u.delete(a),c&&(yield*c.release(1)),u.size===0&&(yield*l.open)})),uv);l.closeUnsafe(),u.set(a,n)}}).pipe(p_(e=>Qr(ng(e))?l.whenOpen(HA(d,e)):HA(d,e)),dv(o)),YA(d)}))),uM=r(e=>bj(e[0])&&bj(e[1]),(e,t,n)=>Tj(Cv(function*(r,i,a){let o=n?.haltStrategy??`both`,s=yield*LA(0);yield*Gp(a,GA(s));let c=0;function l(e,t){if(c++,!eg(t))return HA(s,t);switch(o){case`both`:return c===2?HA(s,t):z;case`left`:case`right`:return e===o?HA(s,t):z;case`either`:return HA(s,t)}}let u=(e,t,n)=>Ej(t)(r,n).pipe(V(e=>e.pipe(V(e=>RA(s,e)),nv)),q_(t=>J_(ig(t),e=>qp(n,e)).pipe(N_({onFailure:t=>l(e,t),onSuccess:()=>l(e,t)}))),dv(a));return yield*u(`left`,e,Kp(a)),yield*u(`right`,t,Kp(a)),YA(s)}))),dM=e=>Sj((t,n)=>{let r;return I(L(()=>r||e.pipe(Up(n),V(e=>Ej(e)(t,n)),V(e=>r=e))))}),fM=r(2,(e,t)=>uM(e,wj(I(V(t,sp))),{haltStrategy:`either`})),pM=r(2,(e,t)=>Tj((n,r,i)=>Wp(i,t).pipe(o_(Ej(e)(n,r))))),mM=r(2,(e,t)=>dM(u_(t,e))),hM=r(2,(e,t)=>Cj(e,e=>R(()=>{let n=!0,r=s_(e,e=>(n=!1,t(e)));return L(()=>n?r:e)}))),gM=r(2,(e,t)=>Cj(e,e=>I($h(e,e=>V(t,()=>sp(e)))))),_M=r(2,(e,t)=>pM(e,e=>t)),vM=(e,t,n)=>L(()=>{let r=Hp();return $h(V(Ej(e)(sp(),r),t),n||I).pipe(Y_(e=>qp(r,e)))}),yM=r(2,(e,t)=>Sj((n,r)=>H(L_(Ej(e)(n,r),t),L_(t)))),bM=r(3,(e,t,n)=>Sj((r,i)=>H(B_(Ej(e)(r,i),t,n),B_(t,n)))),xM=r(3,(e,t,n)=>Sj((r,i)=>V(n,n=>Ej(bM(e,t,n))(r,i)))),SM=r(2,(e,t)=>vM(e,e=>nv(V(e,t),{disableYield:!0}))),CM=e=>H(wM(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}),wM=r(3,(e,t,n)=>L(()=>{let r=t();return vM(e,e=>Wg({while:o,body:()=>e,step:e=>{r=n(r,e)}}),()=>I(r))})),TM=Cv(function*(e){let t=mj(1),n=yield*P_(),r=D(n,Vp);return(yield*Ej(e)(sp(),r)).pipe(L_(n),t.withPermits(1))},p_(e=>I(Zg(e)))),EM=(e,t)=>Ej(e)(sp(),t),DM=`~effect/Stream`,OM={_R:i,_E:i,_A:i},kM=function(e){this.channel=e};kM.prototype={[DM]:OM,pipe(){return e(this,arguments)}};var AM=e=>new kM(e),jM=`~effect/Stream`,MM=e=>v(e,jM),J=AM,NM=e=>J(Lj(H(e,zi))),PM=e=>FM(R(()=>{let t=!0,n=I(zi(void 0)),r=D_(n,e);return L(()=>t?(t=!1,n):r)})),FM=e=>J(wj(e)),IM=e=>e.channel,LM=(e,t)=>J(Oj(e,t)),RM=J(Mj),zM=e=>J(jj(zi(e))),BM=(...e)=>KM(e),VM=e=>{let t=J(kj(()=>e().channel));return HM.set(t,e),t},HM=new WeakMap,UM=e=>J(Pj(e)),WM=e=>J(Fj(e)),GM=e=>J(Ij(e)),KM=e=>ki(e)?J(jj(e)):RM,qM=e=>J(Bj(e)),JM=e=>J(Hj(e)),YM=e=>J(Uj(e)),XM=J(Nj),ZM=e=>J(dM(H(e,IM))),QM=r(2,(e,t)=>VM(()=>{let n=0;return J(Gj(e.channel,Bi(e=>t(e,n++))))})),$M=r(e=>MM(e[0]),(e,t,n)=>e.channel.pipe(eM,qj(t,n),Gj(zi),J)),eN=r(e=>MM(e[0]),(e,t,n)=>$M(e,e=>u_(t(e),e),n)),tN=r(2,(e,t)=>{let n=J($j(Aj(()=>rN(e,t))));return nN.set(n,[e,t]),n}),nN=new WeakMap;function*rN(e,t){let n=[t,e];for(;n.length>0;){let e=n.pop(),t=nN.get(e);if(t!==void 0){n.push(t[1],t[0]);continue}let r=HM.get(e);if(r===void 0)yield e.channel;else{try{n.push(r())}catch(e){n.push(GM(e))}yield Mj}}}var iN=r(2,(e,t)=>J(nM(IM(e),t))),aN=r(2,(e,t)=>e.channel.pipe(rM(e=>t(e).channel),J)),oN=r(2,(e,t)=>e.channel.pipe(iM(t),J)),sN=r(e=>MM(e[0]),(e,t,n,r)=>J(sM(IM(e),t,e=>n(e).channel,r&&(e=>r(e).channel)))),cN=r(e=>MM(e[0]),(e,t,n,r)=>sN(e,Array.isArray(t)?e=>v(e,`_tag`)&&t.includes(e._tag):Se(t),n,r)),lN=r(2,(e,t)=>J(cM(e.channel,t))),uN=r(2,(e,t)=>J(fM(e.channel,t))),dN=r(2,(e,t)=>J(mM(e.channel,t))),fN=r(2,(e,t)=>J(gM(e.channel,t))),pN=r(2,(e,t)=>J(_M(e.channel,t))),mN=r(2,(e,t)=>J(yM(e.channel,t))),hN=r(2,(e,t)=>SM(e.channel,e=>{let n=0;return Wg({while:()=>n<e.length,body:()=>t(e[n++]),step:u})})),gN=r(2,(e,t)=>SM(e.channel,t)),_N=e=>TM(e.channel),vN=e=>H(CM(e.channel),e=>e.buffer),yN=r(e=>MM(e[0]),(e,t,n)=>{let r,i,a=!1,o=Bk(!1),s=n?.signal,c=()=>i.interruptUnsafe();return new ReadableStream({start(n){i=mv(L_(SM(Cj(e.channel,e=>I(o.whenOpen(e))),e=>R(()=>{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(Zf(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,vv(d_(Ik(i)))}},n?.strategy)}),bN=r(e=>MM(e[0]),(e,t)=>yN(e,ga(),t)),xN=r(e=>MM(e[0]),(e,t)=>H(P_(),n=>yN(e,n,t))),SN=`~effect/reactivity/AsyncResult`,CN=e=>v(e,SN),wN={[SN]:{E:i,A:i},pipe(){return e(this,arguments)},[Ge](e){if(!CN(e)||this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case`Initial`:return!0;case`Success`:return Ke(this.value,e.value);case`Failure`:return Ke(this.cause,e.cause)}},[Ee](){let e=Pe(`${this._tag}:${this.waiting}`);return this._tag===`Initial`?e:ke(e)(this._tag===`Success`?y(this.value):y(this.cause))}},TN=e=>e.waiting,EN=e=>e._tag===`Success`?NN(e.value):FN(e.cause),DN=(e,t)=>e._tag===`Success`?NN(e.value):IN(e.cause,{previous:t}),ON=e=>e._tag===`None`?jN(!0):RN(e.value),kN=e=>e._tag===`Initial`,AN=e=>e._tag!==`Initial`,jN=(e=!1)=>{let t=Object.create(wN);return t._tag=`Initial`,t.waiting=e,t},MN=e=>e._tag===`Success`,NN=(e,t)=>{let n=Object.create(wN);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},PN=e=>e._tag===`Failure`,FN=(e,t)=>{let n=Object.create(wN);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??T(),n.waiting=t?.waiting??!1,n},IN=(e,t)=>FN(e,{previousSuccess:zr(t.previous,e=>MN(e)?E(e):PN(e)?e.previousSuccess:T()),waiting:t.waiting}),LN=(e,t)=>IN(Uf(e),t),RN=r(e=>CN(e[0]),(e,t)=>{if(e.waiting)return t?.touch?zN(e):e;let n=Object.assign(Object.create(wN),e);return n.waiting=!0,t?.touch&&MN(n)&&(n.timestamp=Date.now()),n}),zN=e=>MN(e)?NN(e.value,{waiting:e.waiting}):e,BN=r(2,(e,t)=>e._tag===`Failure`?IN(e.cause,{previous:t,waiting:e.waiting}):e),VN=e=>e._tag===`Success`?E(e.value):e._tag===`Failure`?Rr(e.previousSuccess,e=>e.value):T(),HN=r(2,(e,t)=>kr(VN(e),t)),UN=e=>Lr(VN(e),()=>new ap(`AsyncResult.getOrThrow: no value found`)),WN=e=>e._tag===`Failure`?$f(e.cause):T(),GN=e=>{switch(e._tag){case`Success`:return hp(e.value);case`Failure`:return gp(e.cause);default:return _p(new ap)}},KN=r(2,(e,t)=>{switch(e._tag){case`Initial`:return e;case`Failure`:return FN(e.cause,{previousSuccess:Rr(e.previousSuccess,e=>NN(t(e.value),e)),waiting:e.waiting});case`Success`:return NN(t(e.value),e)}}),qN=e=>{let t=we(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(!CN(o))b(r,a,o);else{if(PN(o))return FN(o.cause,{previousSuccess:JN(n,t),waiting:o.waiting});if(!MN(o))return o;b(r,a,o.value),o.waiting&&(i=!0)}}return NN(r,{waiting:i})},JN=(e,t)=>{let n=t?[]:{};for(let t=0;t<e.length;t++){let[r,i]=e[t];if(!CN(i)){b(n,r,i);continue}let a=VN(i);if(Er(a))return T();b(n,r,a.value)}return E(NN(n))},YN=e=>{let t=e.success??ZD,n=e.error??ZD,r=DD()([t,QO(n,UO())],([e,t])=>(n,r,i)=>{if(!CN(n))return B(new cS(r,n,i));switch(n._tag){case`Initial`:return I(n);case`Success`:return Av(jE(e)(n.value,i),{onSuccess:e=>NN(e,n),onFailure:e=>uS(r,`value`,e,n,i)});case`Failure`:{let a=n.previousSuccess.pipe(Rr(t=>Av(jE(e)(t.value,i),{onSuccess:e=>E(NN(e,t)),onFailure:e=>new sS(r,[new iS([`previousSuccess`,`value`],e)],n,i)})),kr(()=>qg)),o=kv(jE(t)(n.cause,i),e=>uS(r,`cause`,e,n,i));return jv(a,e=>Ov(o,t=>FN(t,{previousSuccess:e,waiting:n.waiting})))}}},{expected:`AsyncResult`,toCodec([e,t]){let n=SO(`Success`,{value:e,waiting:nO,timestamp:PO});return EO()(pO([SO(`Initial`,{waiting:nO}),n,SO(`Failure`,{cause:t,previousSuccess:dk(n),waiting:nO})]),lC({decode:e=>{switch(e._tag){case`Initial`:return jN(e.waiting);case`Success`:return NN(e.value,{waiting:e.waiting,timestamp:e.timestamp});case`Failure`:return FN(e.cause,{previousSuccess:Rr(e.previousSuccess,e=>NN(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:st,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})},XN=`~effect/reactivity/Reactivity`,ZN=$i(`effect/reactivity/Reactivity`),QN=R(()=>{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;iP(e,e=>n.add(e)),t(n)},r=e=>F_(t=>{let r=xa(t,$N);return r?iP(e,e=>{r.add(e)}):n(e),z}),i=(e,t)=>s_(t,r(e)),a=(t,n)=>{let r=[];return iP(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)=>Xg(function*(){let n=yield*P_(),r=D(n,Vp),i=yield*IA(),o=f(hv(n),zk(r)),s=!1,c=!1,l=!1,u=e=>{e._tag===`Failure`?(l=!0,c=!1,s=!1,p(),UA(i,e.cause)):(zA(i,e.value),c?(c=!1,o(t).addObserver(u)):s=!1)};function d(){l||(s?c=!0:(s=!0,o(t).addObserver(u)))}let p=a(e,d);return yield*Gp(r,R(p)),d(),i}),s=(e,t)=>o(e,t).pipe(H(qM),ZM),c=e=>L(()=>{let n=new Set;return e.pipe(B_($N,n),Y_(e=>R(()=>t(n))))});return ZN.of({[XN]:XN,mutation:i,query:o,stream:s,invalidateUnsafe:n,invalidate:r,registerUnsafe:a,withBatch:c})}),$N=class extends $i()(`effect/reactivity/Reactivity/PendingInvalidation`){},eP=r(2,(e,t)=>ZN.use(n=>n.mutation(t,e))),tP=e=>ZN.use(t=>t.invalidate(e)),nP=mm(ZN)(QN);function rP(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return y(e)}}var iP=(e,t)=>{if(Array.isArray(e))for(let n=0;n<e.length;n++)t(rP(e[n]));else for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${rP(r[e])}`)}},aP=r(2,(e,t)=>e===void 0?void 0:t(e)),oP=`~effect/SubscriptionRef`,sP=e=>v(e,oP);({...$t});var cP=e=>JM(e.pubsub),lP=e=>R(()=>e.value),uP=(e,t)=>{e.value=t,uA(e.pubsub,t)},dP=r(2,(e,t)=>e.semaphore.withPermit(R(()=>uP(e,t)))),fP=(e,t)=>!CN(e)||!CN(t)?!0:kN(t)?kN(e):MN(e)&&MN(t)?t.timestamp>=e.timestamp:!0,pP=`~effect/reactivity/AtomRegistry`,mP=e=>v(e,pP),hP=e=>new wP(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),gP=$i(pP),_P=r(e=>mP(e[0]),(e,t,n)=>{let r=n?.suspendOnWaiting??!1;return Jg(n=>{let i=e.get(t);if(i._tag!==`Initial`&&!(r&&i.waiting))return n(GN(i));let a=e.subscribe(t,e=>{e._tag!==`Initial`&&!(r&&e.waiting)&&(n(GN(e)),a())});return R(a)})}),vP={immediate:!0},yP=e=>{e()},bP={};function xP(e,t){let n=bP;for(let r of e)try{t(r)}catch(e){n===bP&&(n=e)}if(n!==bP)throw n}var SP=`~effect-atom/atom/Atom/Serializable`,CP=e=>SP in e?e[SP].key:e,wP=class{[pP];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(e,t,n,r){if(this[pP]=pP,this.scheduler=new Go(`sync`,t),this.schedulerAsync=new Go(`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&TP.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,u,vP)}atomHasTtl(e){return!e.keepAlive&&e.idleTTL!==0&&(e.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(e){let t=CP(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[SP],a;try{a=i.decode(r)}catch(e){if(AD(e))return n;throw e}let o=e;for(;o.initialValueTarget;)o=o.initialValueTarget;let s=o===e?n:this.ensureNode(o);fP(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 DP(this,e)}invalidateAtom=e=>{let t=this.ensureNode(e);t.skipInitialRun=!1,t.invalidate()};scheduleAtomRemoval(e){this.dispatcher.scheduleTask(()=>{let t=this.nodes.get(CP(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(CP(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(CP(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),xP(t,this.removeIdleNode)}removeIdleNode=e=>{if(this.nodeTimeoutBucket.delete(e),e.canBeRemoved){this.nodes.delete(CP(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=EP.removed;xP(e,this.destroyNode)}destroyNode=e=>{e.remove(),this.onNodeRemoved?.(e)};dispose(){this.disposed=!0,this.reset()}},TP={alive:1,initialized:2,waitingForValue:4},EP={uninitialized:TP.alive|TP.waitingForValue,stale:TP.alive|TP.initialized|TP.waitingForValue,valid:TP.alive|TP.initialized,removed:0},DP=class{constructor(e,t){this.registry=e,this.atom=t,this.writeContext=new jP(e,this)}registry;atom;state=EP.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 EP.uninitialized:return`uninitialized`;case EP.stale:return`stale`;case EP.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&TP.waitingForValue)!==0;)this.build();return this._value}build(){let e=AP(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&TP.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.skipInitialRun&&(this.keptParents=Array.from(this.parents,e=>[e,e.lifetime])),this.failed=!1,this.state=EP.valid):this.setValue(t)),e.failure!==bP)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!==EP.valid)throw e;return t.failure===bP&&(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&TP.initialized)===0?T():E(this._value)}setInitialValue(e,t=!1){(this.state&TP.initialized)===0?(this.preserveInitialValueOnBuild=!0,this.skipInitialRun=t,this.state=EP.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&TP.initialized)!==0;if(this.state=EP.valid,n&&this.atom.equals(this._value,e)){t&&this.invalidateChildren();return}this._value=e;let r=bP;try{(n||t)&&this.invalidateChildren()}catch(e){r=e}if(this.listeners.size>0)try{this.announce()}catch(e){r===bP&&(r=e)}if(r!==bP)throw r}announce(){NP.phase===MP.collect?NP.notify.add(this):this.notify()}invalidate(){if(this.state===EP.valid){this.state=EP.stale;try{this.disposeLifetime()}finally{this.propagate()}}else this.building&&NP.phase!==MP.collect?this.build():this.propagate()}propagate(){NP.phase===MP.collect?(this.building&&(this.invalidatedDuringBuild=!0),NP.stale.push(this)):this.isObserved?this.value():this.invalidateChildren()}invalidateChildren(){if(this.children.size===0)return;let e=bP;for(let t of Array.from(this.children))if(t.affectedBy(this))try{t.invalidate()}catch(t){e===bP&&(e=t)}if(e!==bP)throw e}affectedBy(e){if(this.state===EP.valid)return!0;let t=this.lifetime?.reads;return t===void 0?this.isObserved&&e.state===EP.valid:t.has(e)}notify(){NP.phase===MP.commit&&NP.notify.delete(this),xP(this.listeners,yP)}disposeLifetime(){let e=this.lifetime;e!==void 0&&(this.lifetime=void 0,e.dispose())}remove(){let e=this.isObserved;this.state=EP.removed,this.listeners.clear();try{this.disposeLifetime()}finally{let t=Array.from(this.parents);this.parents.clear(),xP(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)}}},OP=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&&!kN(n._value)&&(r===void 0||r.every(([e,t])=>e.lifetime===t))},kP={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){return this.disposed?this.node.registry.get(e):this.node.readTracked(e,this)},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let n=this.get(e);if(t?.suspendOnWaiting&&n.waiting)return Yg;switch(n._tag){case`Initial`:return Yg;case`Failure`:return gp(n.cause);case`Success`:return I(n.value)}},resultOnce(e,t){return Jg(n=>{let r=this.once(e);if(r._tag!==`Initial`&&!(t?.suspendOnWaiting&&r.waiting))return n(GN(r));let i=this.node.registry.subscribe(e,e=>{e._tag===`Initial`||t?.suspendOnWaiting&&e.waiting||(i(),n(GN(e)))},{immediate:!1});return R(i)})},setResult(e,t){return this.disposed?Yg:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag===`None`?Yg:I(t.value)},someOnce(e){return Jg(t=>{let n=this.once(e);if(Dr(n))return t(I(n.value));let r=this.node.registry.subscribe(e,e=>{Er(e)||(r(),t(I(e.value)))},{immediate:!1});return R(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?RM:LM(n=>R(()=>{this.subscribe(e,e=>zA(n,e),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(iN(AN),$M(e=>e._tag===`Success`?I(e.value):Zg(e.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0,xP(e.reverse(),yP)}},AP=e=>{function t(n){return t.disposed||t.isFn?e.registry.get(n):e.readTracked(n,t)}return Object.setPrototypeOf(t,kP),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t.reads=new Set,t.failure=bP,t},jP=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()}},MP={disabled:0,collect:1,commit:2},NP={phase:MP.disabled,depth:0,stale:[],notify:new Set};function PP(e){let t=NP.phase;NP.phase=MP.collect,NP.depth++;let n=bP;try{e()}catch(e){n=e}if(NP.depth===1){let{notify:e,stale:t}=NP,r=0;do{for(NP.phase=MP.collect;r<t.length;r++)try{FP(t[r])}catch(e){n===bP&&(n=e)}NP.phase=MP.commit;for(let t of e)try{t.notify()}catch(e){n===bP&&(n=e)}}while(r<t.length);NP.stale=[],e.clear()}if(NP.depth--,NP.phase=t,n!==bP)throw n}function FP(e){if(e.state===EP.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=EP.stale,e.disposeLifetime()}e.value()}var IP=`~effect/reactivity/Atom`,LP=e=>v(e,IP),RP=`~effect/reactivity/Atom/Writable`,zP=r(2,(e,t)=>{let n=$a(t),r=lo(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?So(n):void 0})}),BP=zP(0),VP={[IP]:IP,equals:Object.is,...$t,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label&&[this.label[0],this.label[1]]}}},HP={...VP,atom(e,t){let n=XP(e,t);return KP(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):BN(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>UP(this,e,t):UP(this,e,t)},pull(e,t){let n=BP($P(0));return gF(n,KP(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?tF(r,hF(r,n,e,t),jN(!0),a.value):BN(a,i)}))},subscriptionRef(e){return lF(BP(KP(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return BN(r,n);let i=typeof e==`function`?e(t):e;return sP(i)?i:tF(t,i,jN(!0),r.value)})),(e,t)=>cF(e,t,UN(e(this))))}},UP=(e,t,n)=>{let[r,i,a]=mF(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return Vg(i)?eP(i,n.reactivityKeys):fN(i,tP(n.reactivityKeys))}:t,n);return qP(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):BN(i,n)},i)},WP={...VP,[RP]:RP},GP=e=>RP in e,KP=(e,t)=>{let n=Object.create(VP);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},qP=(e,t,n)=>{let r=Object.create(WP);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function JP(e,t){e.setSelf(t)}var YP=(e,t)=>{let n=XP(e,t);return`~effect/reactivity/Atom`in n?n:KP(n)},XP=(e,t)=>{if(typeof e==`function`&&!Vg(e)&&!MM(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:ZP in i?eF(e,i,t,r):QP in i?oF(e,i,t,r):i;default:return i}}}return Vg(e)?function(n,r){return eF(n,e,t,r)}:MM(e)?function(n,r){return oF(n,e,t,r)}:$P(e)},ZP=`~effect/Effect`,QP=`~effect/Stream`,$P=e=>qP(function(t){return e},JP),eF=(e,t,n,r)=>tF(e,t,n?.initialValue===void 0?jN():NN(n.initialValue),r,n?.uninterruptible);function tF(e,t,n,r=ga(),i=!1){let o=e.self();if(o._tag===`Some`&&OP(e))return o.value;let s=typeof r==`function`?r:a(r),c=Hp();e.addFinalizer(()=>{hv(s())(nF(c))});let l,u=!1,d=rF(s().pipe(ya(Vp,c),ya(gP,e.registry),ya(Bo,e.registry.scheduler)),t,function(t){u?e.setSelf(DN(t,e.self())):l=DN(t,o)},i);return u=!0,d!==void 0&&e.addFinalizer(d),l===void 0?o._tag===`Some`?ON(o):RN(n):l}var nF=e=>p_(qp(e,bp),e=>Yf(e)?z:C_(Zg(e),{log:`Unhandled`,message:`Unhandled error in atom finalizer`}));function rF(e,t,n,r=!1){if(mp(t)){n(t);return}let i=hv(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 iF(e){let t=e?.memoMap??BP(YP(()=>im())),n=e=>LP(t)?e(t):t,r=nP;function i(e){let t=Object.create(HP);t.keepAlive=!1,t.lazy=!0,t.refresh=void 0,t.factory=i;let a=vF(KP(typeof e==`function`?e:()=>e));return t.layer=a,t.read=function(e){let t=wm(e(a),r),i=ga();return tF(e,V(V_,r=>H(sm(t,n(e),r),e=>(i=e,e))),jN(),()=>i,!0)},t}i.memoMap=t,i.addGlobalLayer=e=>{r=wm(r,Cm(e,nP))};let a=BP(YP(e=>F_(t=>sm(nP,n(e),D(t,Vp))).pipe(H(D(ZN)))));return i.withReactivity=e=>t=>SF(t,n=>{let r=UN(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 aF=iF();aF.withReactivity;var oF=(e,t,n,r)=>sF(e,t,n?.initialValue===void 0?jN():NN(n.initialValue),r);function sF(e,t,n,r=ga()){let i=e.self();if(i._tag===`Some`&&OP(e))return i.value;r=ya(r,gP,e.registry);let a=U_(n=>V(EM(t.channel,n),t=>Wg({while:o,body:()=>t,step(t){e.setSelf(NN(Mi(t),{waiting:!0}))}}))).pipe(p_(t=>(eg(t)?d(e.self(),zr(VN),Or({onNone:()=>e.setSelf(LN(new ap,{previous:e.self()})),onSome:t=>e.setSelf(NN(t))})):e.setSelf(IN(t,{previous:e.self()})),z))),s=rF(r.pipe(ya(gP,e.registry),ya(Bo,e.registry.scheduler)),a,u,!1);return s!==void 0&&e.addFinalizer(s),i._tag===`Some`?ON(i):RN(n)}var cF=(e,t,n=ga())=>sP(t)?(e.addFinalizer(cP(t).pipe(gN(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return z}),gv(n))),xv(n)(lP(t))):t._tag===`Success`?sF(e,cP(t.value),jN(!0),n):t,lF=(e,t)=>{function n(t,n){let r=t.get(e);sP(r)?bv(dP(r,n)):MN(r)&&bv(dP(r.value,n))}return qP(n=>{let r=n(e);return sP(r)||MN(r)?t(n,r):r},n)},uF=Symbol.for(`effect/reactivity/atom/Atom/Reset`),dF=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`),fF=function(...e){return e.length===0?pF:pF(...e)},pF=(e,t)=>{let[n,r]=mF(e,t);return qP(n,r)};function mF(e,t){let n=BP($P([0,void 0])),r=t?.initialValue===void 0?jN():NN(t.initialValue),i=t?.concurrent?BP(KP(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===dF)return IN(Gf(),{previous:t.self()});let l=e(c,t);return ZP in l?(o&&(l=V(pv(l,{startImmediately:!0}),e=>{o.add(e);let t=Array.from(o);return e.addObserver(()=>o.delete(e)),H(Fk(t),e=>e[0])})),tF(t,l,r,a,!1)):sF(t,l,r,a)}function o(e,t){EF(()=>{t===uF?e.set(n,[0,void 0]):t===dF?e.set(n,[e.get(n)[0]+1,dF]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,o,n]}var hF=(e,t,n,r)=>V(_N(typeof n==`function`?n(e):n),n=>{let i=Rk().context,a=Ri(),o=N_(n,{onFailure(e){return eg(e)?ki(a)?I({done:!0,items:a}):B(new ap(`Atom.pull: no items`)):Zg(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=Ti(a,e),a=t),I({done:!1,items:t})}}),s=new Set;return e.addFinalizer(()=>{for(let e of s)e()}),e.once(t),e.subscribe(t,()=>{e.setSelf(ON(e.self()));let t;t=rF(i,o,n=>{t&&s.delete(t);let r=DN(n,e.self()),i=s.size>0;e.setSelf(i?RN(r):r)}),t&&s.add(t)}),o}),gF=(e,t)=>qP(t.read,function(t,n){t.set(e,t.get(e)+1)}),_F=typeof WeakRef>`u`||typeof FinalizationRegistry>`u`?e=>{let t=Pg();return function(n){let r=Fg(t,n);if(r._tag===`Some`)return r.value;let i=e(n);return Rg(t,n,i),i}}:e=>{let t=Pg(),n=new FinalizationRegistry(e=>{let n=Fg(t,e);n._tag===`Some`&&n.value.deref()===void 0&&Bg(t,e)});return function(r){let i=Fg(t,r).pipe(Br(e=>e.deref()));if(i._tag===`Some`)return i.value;let a=e(r);return Rg(t,r,new WeakRef(a)),n.register(a,r),a}},vF=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),yF=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,equals:t})),bF=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:xF(t,Bt()===0?void 0:Error())}));function xF(e,t){let n=[e,``];if(t===void 0)return n;let r=``;return Object.defineProperty(n,1,{configurable:!0,enumerable:!0,get:()=>(t!==void 0&&(r=t.stack?.split(`
16
16
  `)[5]??``,t=void 0),r)}),n}var SF=r(e=>LP(e[0]),(e,t,n)=>{let r=BP(GP(e)?qP(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):KP(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=CF(n.initialValueTarget)),r}),CF=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},wF=r(2,(e,t)=>SF(e,n=>t(n(e)))),TF=r(2,(e,t)=>wF(e,KN(t))),EF=PP,DF=`~effect-atom/atom/Atom/Serializable`,OF=r(2,(e,t)=>{let n=kk(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??xF(t.key,Bt()===0?void 0:Error()),[DF]:{key:t.key,encode:GD(n),decode:VD(n),skipInitialRun:t.skipInitialRun}})}),kF=`~effect-atom/atom/Atom/ServerValue`,AF=r(2,(e,t)=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,[kF]:t})),jF=e=>AF(e,a(jN(!0))),MF=r(2,(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[kF](e=>t.get(e)):t.get(e)),NF=`~effect/http/HttpBody`,PF=`~effect/http/HttpBody/HttpBodyError`,FF=class extends Zo(`HttpBodyError`){[PF]=PF},IF=class{[NF];constructor(){this[NF]=NF}[Pt](){return this.toJSON()}toString(){return x(this,{ignoreToString:!0})}},LF=new class extends IF{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},RF=class extends IF{_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??=HF(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}}},zF=(e,t)=>new RF(e,t??`application/octet-stream`,e.length),BF=new TextEncoder,VF=globalThis.Buffer,HF=VF===void 0?e=>BF.encode(e):e=>VF.from(e,`utf8`),UF=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),VF!==void 0)return new RF(void 0,t??`text/plain`,VF.byteLength(e,`utf8`),e);let n=BF.encode(e);return new RF(n,t??`text/plain`,n.length,e)},WF=(e,t)=>e_({try:()=>UF(JSON.stringify(e),t??`application/json`),catch:e=>new FF({reason:{_tag:`JsonError`},cause:e})}),GF=(e,t)=>{let n=NE(kk(e));return(e,r)=>n(e,t).pipe(g_(e=>new FF({reason:{_tag:`SchemaError`,issue:e},cause:e})),V(e=>WF(e,r)))},KF=class extends IF{_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}}},qF=(e,t,n)=>new KF(e,t??`application/octet-stream`,n),JF={"~effect/Ref":{_A:i},...$t,toJSON(){return{_id:`Ref`,ref:this.ref}}},YF=e=>{let t=Object.create(JF);return t.ref=Cy(e),t},XF=r(2,(e,t)=>R(()=>{let[n,r]=t(e.ref.current);return e.ref.current=r,n})),ZF=r(2,(e,t)=>R(()=>e.ref.current=t(e.ref.current))),QF=`~effect/http/HttpClientError`,$F=e=>v(e,QF),eI=class extends Zo(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[QF]=QF;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},tI=e=>e.endsWith(`Error`)?e.slice(0,-5):e,nI=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,rI=new WeakMap,iI=new WeakMap,aI=(e,t)=>{let n=iI.get(e);n!==void 0&&t!==void 0&&iI.set(e,Mx(n,t))},oI=(e,t)=>{let n=rI.get(e);rI.set(e,n===void 0?t:[...n,...t])},sI=(e,t)=>{for(let n of e.reasons)zf(n)&&$F(n.error)&&aI(n.error.reason,t)},cI=e=>{class t extends Zo(e){constructor(e){super(e),iI.set(this,Mx(e.request.url)),e.response!==void 0&&aI(this,rI.get(e.response))}}return t},lI=e=>Mx(iI.get(e)??e.request.url),uI=e=>`${e.request.method} ${lI(e)}`,dI=(e,t)=>({...t,request:{_id:`HttpClientRequest`,method:e.request.method,url:lI(e)},...`response`in e?{response:{_id:`HttpClientResponse`,status:e.response.status}}:void 0}),fI=class extends cI(`TransportError`){get methodAndUrl(){return uI(this)}get message(){return nI(tI(this._tag),this.description,this.methodAndUrl)}toJSON(){return dI(this,super.toJSON())}},pI=class extends cI(`EncodeError`){get methodAndUrl(){return uI(this)}get message(){return nI(tI(this._tag),this.description,this.methodAndUrl)}toJSON(){return dI(this,super.toJSON())}},mI=class extends cI(`InvalidUrlError`){get methodAndUrl(){return uI(this)}get message(){return nI(tI(this._tag),this.description,this.methodAndUrl)}toJSON(){return dI(this,super.toJSON())}},hI=class extends cI(`StatusCodeError`){get methodAndUrl(){return uI(this)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return nI(tI(this._tag),this.description,e)}toJSON(){return dI(this,super.toJSON())}},gI=class extends cI(`DecodeError`){get methodAndUrl(){return uI(this)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return nI(tI(this._tag),this.description,e)}toJSON(){return dI(this,super.toJSON())}},_I=class extends cI(`EmptyBodyError`){get methodAndUrl(){return uI(this)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return nI(tI(this._tag),this.description,e)}toJSON(){return dI(this,super.toJSON())}},vI=class e extends Dk(QF)({_tag:xO(`HttpError`),kind:mO([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:JD(UO())}){static fromHttpClientError(t){return new e({_tag:`HttpError`,kind:t.reason._tag,cause:t.reason})}get message(){let e=v(this.cause,`message`)?this.cause.message:void 0;return typeof e==`string`&&e!==``?e:this.kind}},yI=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],bI=e=>t=>t.pipeThrough(new CompressionStream(e)),xI=e=>new ReadableStream({start(t){t.enqueue(e),t.close()}}),SI=(e,t,n)=>e._tag!==`Uint8Array`&&e._tag!==`Stream`||e.contentLength!==void 0&&e.contentLength<(n?.minSize??1024)?I(e):e._tag===`Uint8Array`?H(Gg(()=>new globalThis.Response(bI(t)(xI(e.body))).arrayBuffer()),t=>zF(new Uint8Array(t),e.contentType)):I(qF(YM({evaluate:()=>bI(t)(bN(e.stream)),onError:i}),e.contentType)),CI=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?tx(tx(e,`content-type`),`content-length`):(e=t.contentType===void 0?tx(e,`content-type`):Qb(e,`content-type`,t.contentType),wI(e,t)),wI=(e,t)=>{let n=t._tag===`Empty`||t._tag===`FormData`?void 0:t.contentLength;return n===void 0?tx(e,`content-length`):Qb(e,`content-length`,n.toString())},TI=class extends Zo(`UrlError`){},EI=(e,t,n)=>Yr({try:()=>{let r=new URL(e,DI());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,gx(i))}return n!==void 0&&(r.hash=n),r},catch:e=>new TI({cause:e})}),DI=()=>{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}}},OI=(e,t)=>Yr({try:()=>new URL(e,t),catch:()=>new lp(`Invalid URL: "${e}"${t===void 0?``:` with base "${t}"`}`)}),kI=`~effect/http/HttpClientRequest`,AI=e=>v(e,kI),jI={[kI]:kI,...Lt,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:Mx(this.url),urlParams:this.urlParams,hash:this.hash,headers:yt(this.headers),body:this.body.toJSON()}},pipe(){return e(this,arguments)}};function MI(e,t,n,r,i,a){let o=Object.create(jI);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var NI=MI(`GET`,``,Ox,T(),Yb,LF),PI=e=>(t,n)=>II(NI,{method:e,url:t,...n??void 0}),FI=PI(`POST`),II=r(2,(e,t)=>{let n=e;return t.method&&(n=LI(n,t.method)),t.url&&(n=HI(n,t.url)),t.headers&&(n=zI(n,t.headers)),t.urlParams&&(n=UI(n,t.urlParams)),t.hash&&(n=WI(n,t.hash)),t.body&&(n=GI(n,t.body)),t.accept&&(n=BI(n,t.accept)),t.acceptJson&&(n=VI(n)),n}),LI=r(2,(e,t)=>MI(t,e.url,e.urlParams,e.hash,e.headers,e.body)),RI=r(3,(e,t,n)=>MI(e.method,e.url,e.urlParams,e.hash,Qb(e.headers,t,n),e.body)),zI=r(2,(e,t)=>MI(e.method,e.url,e.urlParams,e.hash,$b(e.headers,t),e.body)),BI=r(2,(e,t)=>RI(e,`Accept`,t)),VI=BI(`application/json`),HI=r(2,(e,t)=>{if(typeof t==`string`)return MI(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Cx(n.searchParams),i=jr(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,MI(e.method,n.toString(),r,i,e.headers,e.body)}),UI=r(2,(e,t)=>MI(e.method,e.url,kx(e.urlParams,t),e.hash,e.headers,e.body)),WI=r(2,(e,t)=>MI(e.method,e.url,e.urlParams,E(t),e.headers,e.body)),GI=r(2,(e,t)=>MI(e.method,e.url,e.urlParams,e.hash,CI(e.headers,t),t)),KI=r(e=>AI(e[0]),(e,t,n)=>e.headers[`content-encoding`]===void 0?H(SI(e.body,t,n),n=>n===e.body?e:MI(e.method,e.url,e.urlParams,e.hash,Qb(wI(e.headers,n),`content-encoding`,t),n)):I(e)),qI=(e,t)=>{let n=GF(e,t);return r(2,(e,t)=>H(n(t),t=>GI(e,t)))};function JI(e){let t=EI(e.url,e.urlParams,Fr(e.hash));return Qr(t)?E(t.success):T()}var YI=`~effect/http/HttpIncomingMessage`,XI=(e,t)=>{let n=RD(kk(e)),r=t?.reviver===void 0?void 0:RD(GO(kk(e),t));return e=>r===void 0?V(e.json,e=>n(e,t)):V(e.text,i=>i===``?V(e.json,e=>n(e,t)):r(i,t))},ZI=(e,t)=>({...t,headers:yt(e.headers),remoteAddress:e.remoteAddress}),QI=`~effect/http/HttpClientResponse/WebSource`,$I=e=>e[QI]?.(),eL=`~effect/http/HttpClientResponse`,tL=(e,t)=>new rL(e,t),nL=e=>e.status>=200&&e.status<300?I(e):B(new eI({reason:new hI({response:e,request:e.request,description:`non 2xx status code`})})),rL=class extends Rt{[YI];[eL];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[YI]=YI,this[eL]=eL}toJSON(){return ZI(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=JI(this.request);return Er(e)?``:(e.value.hash=``,e.value.href)}get headers(){return Xb(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=Ab(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return T()}[QI](){return this.source}get stream(){return this.source.body?YM({evaluate:()=>this.source.body,onError:e=>new eI({reason:new gI({request:this.request,response:this,cause:e})})}):UM(new eI({reason:new _I({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return V(this.text,e=>e_({try:()=>e===``?null:JSON.parse(e),catch:e=>new eI({reason:new gI({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=H(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return V(this.arrayBuffer,e=>e_({try:()=>Cx(vx(e)),catch:e=>new eI({reason:new gI({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=Kg({try:()=>this.source.formData(),catch:e=>new eI({reason:new gI({request:this.request,response:this,cause:e})})}).pipe(X_,bv)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=Kg({try:()=>this.source.arrayBuffer(),catch:e=>new eI({reason:new gI({request:this.request,response:this,cause:e})})}).pipe(X_,bv),this.arrayBufferBody}get upgrade(){return B(new eI({reason:new hI({request:this.request,response:this,description:`fetch cannot hand over the connection of an HTTP upgrade`})}))}pipe(){return e(this,arguments)}},iL=e=>Zb({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${Or(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId.padStart(32,`0`)}-${e.spanId}-${e.sampled?`01`:`00`}`}),aL={"http:":80,"https:":443,"ws:":80,"wss:":443},oL=(e,t,n)=>{let r=Mx(t.search,n).slice(1);if(e.attribute(`url.full`,Mx(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===``?aL[t.protocol]:Number(t.port);n!==void 0&&e.attribute(`server.port`,n)}},sL=(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()]},cL=(e,t,n,r,i)=>{for(let a in n)r(a,t)&&e.attribute(`http.${t}.header.${a}`,rx(a,i)?`<redacted>`:n[a])},lL=`~effect/http/HttpClient`,uL=$i(`effect/HttpClient`),dL=(e=>(...t)=>V(uL,n=>n[e](...t)))(`get`),fL=r(2,(e,t)=>mL(n=>t(e.postprocess(n)),e.preprocess)),pL=fL(V(nL)),mL=(e,t)=>{let n=Object.create(hL);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},hL={[lL]:lL,pipe(){return e(this,arguments)},...Lt,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(yI.map(([e,t])=>[t,function(t,n){return this.execute(PI(e)(t,n))}]))},gL=e=>mL(t=>V(t,t=>n_(n=>{let r=n.getRef(OL),i=new AbortController,a=n.getRef(Bx),o=EI(t.url,t.urlParams,Fr(t.hash));if(Zr(o))return B(new eI({reason:new mI({request:t,cause:o.failure})}));let s=o.success,c=t=>r===void 0?e(t,s,i.signal,n):V(Gp(r,R(()=>i.abort())),()=>e(t,s,i.signal,n)),l=(e,t)=>tv(n=>N_(n(c(e)),{onSuccess:e=>(e=AL(e,i,r!==void 0,a),t?.(e),I(e)),onFailure:e=>(ep(e)&&i.abort(),sI(e,a),Zg(e))}));return n.getRef(ls)||n.getRef(SL)(t)?l(t):sv(n.getRef(TL)(t),{kind:`client`},e=>{e.attribute(`http.request.method`,t.method);let r=n.getRef(ix);oL(e,s,sL(t.urlParams,a));let i=n.getRef(CL);return cL(e,`request`,t.headers,i,r),t=n.getRef(wL)?zI(t,iL(e)):t,lv(l(t,a=>{e.attribute(`http.response.status_code`,a.status),cL(e,`response`,a.headers,i,r),a.status>=400&&a.status<600&&(e.attribute(`error.type`,String(a.status)),_L(n,e,t,a))}),e,{captureStackTrace:!1})})})),I),_L=(e,t,n,r)=>{let i=Bt();Vt(0);let a;try{a=_p(new eI({reason:new hI({request:n,response:r})}))}finally{Vt(i)}t.end(e.getRef(Bp)?e.getRef(dp).currentTimeNanosUnsafe():BigInt(0),a)},vL=r(2,(e,t)=>{let n=lg(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,a=FL(n?t:t.schedule??Cg),o=n?void 0:t.times;return fL(e,f(r===`errors-only`?i:rv({schedule:a,times:o,while:IL}),r===`response-only`?i:b_({while:n||t.while===void 0?ML:Te(ML,t.while),schedule:a,times:o})))}),yL=(e,t)=>{if(t===void 0)return;let n=mx(t);return Qr(n)?jo(hx(n.success,e),vo(1)):void 0},bL=r(2,(e,t)=>fL(e,s_(t))),xL=r(2,(e,t)=>fL(e,v_(t))),SL=O(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>s}),CL=O(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>s}),wL=O(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:o}),TL=O(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>e.method}),EL=e=>mm(uL)(F_(t=>H(e,e=>fL(e,z_(e=>Oa(t,e)))))),DL=(()=>{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))}}})(),OL=O(`effect/http/HttpClient/RequestScope`,{defaultValue:()=>void 0}),kL=new WeakMap,AL=(e,t,n,r)=>(oI(e,r),n||(DL.register(e,t),e=new jL(e,t),oI(e,r)),kL.set(e,t),e),jL=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[eL]=eL;[YI]=YI;applyInterrupt(e){return L(()=>(DL.unregister(this.original),$_(e,()=>R(()=>{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)}[QI](){let e=$I(this.original);return e!==void 0&&DL.unregister(this.original),e}get stream(){return VM(()=>(DL.unregister(this.original),pN(this.original.stream,R(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Pt](){return this.original[Pt]()}pipe(){return e(this,arguments)}},ML=e=>cp(e)||NL(e),NL=e=>$F(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&IL(e.reason.response)),PL=(e,t)=>yL(t,($F(e)?e.response:v(e,`~effect/http/HttpClientResponse`)?e:void 0)?.headers[`retry-after`]),FL=e=>ug(H(pg(e),e=>(t,n)=>{let r=PL(n,t);return r===void 0?e(t,n):H(e(t,n),([e,t])=>[e,jo(t,r)])})),IL=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,LL=`~effect/socket/Socket`,RL=$i(`effect/socket/Socket`),zL=e=>RL.of({[LL]:LL,reader:e.reader,writer:e.writer}),BL=new TextEncoder,VL=`~effect/socket/Socket/CloseEvent`,HL=e=>v(e,VL),UL=`~effect/socket/Socket/SocketError`,WL=e=>v(e,UL),GL=class extends Dk(`effect/socket/Socket/SocketReadError`)({_tag:xO(`SocketReadError`),cause:UO()}){message=`An error occurred during Read`},KL=class extends Dk(`effect/socket/Socket/SocketWriteError`)({_tag:xO(`SocketWriteError`),cause:UO()}){message=`An error occurred during Write`},qL=class extends Dk(`effect/socket/Socket/SocketOpenError`)({_tag:xO(`SocketOpenError`),kind:mO([`Unknown`,`Timeout`]),cause:UO()}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},JL=class e extends Dk(`effect/socket/Socket/SocketUpgradeError`)({_tag:xO(`SocketUpgradeError`),cause:JD(UO())}){static unsupported=()=>B(new ZL({reason:new e({})}));get message(){return this.cause===void 0?`Socket does not support TLS upgrade`:`An error occurred during TLS upgrade`}},YL=class extends Dk(`effect/socket/Socket/SocketCloseError`)({_tag:xO(`SocketCloseError`),code:PO,closeReason:JD(K)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},XL=pO([GL,KL,qL,JL,YL]),ZL=class extends Ok(UL)(`SocketError`,{_tag:xO(`SocketError`),reason:XL}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[UL]=UL;static is(e){return WL(e)}message=this.reason.message},QL=(e,t)=>new ZL({reason:new YL({code:e,closeReason:t})}),$L=class extends $i()(`@effect/platform/Socket/WebSocketConstructor`){},eR=lm($L)((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)}),tR=(e,t)=>$L.use(n=>rR(W_((typeof e==`string`?I(e):e).pipe(H(e=>n(e,t?.headers===void 0?t?.protocols:{protocols:t.protocols,headers:t.headers}))),e=>R(()=>e.close(1e3))),t)),nR=e=>`pause`in e&&typeof e.pause==`function`,rR=(e,t)=>n_(n=>{let r,i=Bk(!1),a=n.context,o=Xg(function*(){let n=yield*V_,a=yield*Up(e,n);`binaryType`in a&&(a.binaryType=`arraybuffer`);let o=nR(a),s=t?.highWaterMark??(o?iR:void 0),c=a.readyState===1,l=o&&`isPaused`in a&&a.isPaused===!0,d=[],f=0,p,m,h;function g(){o&&!l&&(a.pause(),l=!0)}function ee(){o&&l&&(a.resume(),l=!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(I(_()))}function ne(e){d.push(e),s!==void 0&&(f+=typeof e==`string`?BL.encode(e).byteLength:e.byteLength),m!==void 0&&te(),o&&f>=s?g():!o&&!m&&s!==void 0&&f>s&&re(new ZL({reason:new GL({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(B(p))}if(m!==void 0){let e=m;m=void 0,e(d.length>0?I(_()):B(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 ZL({reason:new GL({cause:e})}))}):ne(t instanceof ArrayBuffer?new Uint8Array(t):t)}function ae(e){re(new ZL({reason:c?new GL({cause:e}):new qL({kind:`Unknown`,cause:e})}))}function oe(e){re(QL(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*Gp(n,R(()=>{if(re(QL(1006)),a.removeEventListener(`message`,ie),a.addEventListener(`error`,u),a.removeEventListener(`error`,ae),a.removeEventListener(`close`,oe),o)try{ee()}catch{}i.closeUnsafe(),r=void 0})),a.readyState>=2?yield*B(p??QL(1006)):(c||=(yield*Jg(e=>{let t=()=>{h?.resume===e&&(h=void 0,a.removeEventListener(`open`,t),e(z))},n=()=>a.removeEventListener(`open`,t);return h={resume:e,cleanup:n},a.addEventListener(`open`,t,{once:!0}),R(()=>{h?.resume===e&&(h=void 0),n()})}).pipe(E_({duration:t?.openTimeout??1e4,orElse:()=>B(new ZL({reason:new qL({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))})),!0),p===void 0&&f<s&&ee(),r=a,i.openUnsafe(),{pull:Jg(e=>d.length>0?e(I(_())):p===void 0?(m=e,R(()=>{m===e&&(m=void 0)})):e(B(p))),upgrade:JL.unsupported})}).pipe(z_(e=>Oa(a,e))),s=e=>L(()=>{let t=r;if(t===void 0)return i.whenOpen(s(e));try{return HL(e)?t.close(e.code,e.reason):t.send(e),z}catch(e){return B(new ZL({reason:new KL({cause:e})}))}}),c=e=>L(()=>{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 z}catch(e){return B(new ZL({reason:new KL({cause:e})}))}});return I(zL({reader:o,writer:I({write:s,writeAll:c})}))}),iR=65536,aR=f(tR,mm(RL)),oR=class extends $i()(`effect/workers/Transferable/Collector`){},sR=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return oR.of({addAllUnsafe:t,addAll:e=>R(()=>t(e)),readUnsafe:n,read:R(n),clearUnsafe:r,clear:R(r)})},cR=`~effect/FiberSet`,lR=e=>v(e,cR),uR={[cR]:cR,[Symbol.iterator](){return this.state._tag===`Closed`?si():this.state.backing[Symbol.iterator]()},...$t,toJSON(){return{_id:`FiberSet`,state:this.state}}},dR=(e,t)=>{let n=Object.create(uR);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},fR=()=>W_(R(()=>dR(new Set,Ep())),e=>L(()=>{let t=e.state;if(t._tag===`Closed`)return z;e.state={_tag:`Closed`};let n=t.backing;return Lk(n).pipe(Lp(e.deferred))})),pR=-1,mR=Io(Ro(np,Lo(pR))),hR=r(e=>lR(e[0]),(e,t,n)=>{e.state._tag===`Closed`?t.interruptUnsafe(pR):e.state.backing.has(t)||(e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),Sp(r)&&(n?.propagateInterruption===!0?!mR(r.cause):!Yf(r.cause))&&Ip(e.deferred,r))}))}),gR=function(){let e;return()=>(e===void 0&&(e=mv(Z_)),e)}(),_R=function(){let e=arguments[0];if(!Vg(arguments[1])){let t=arguments[1];return n=>vR(e,n,t)}return vR(e,arguments[1],arguments[2])},vR=(e,t,n)=>n_(r=>{if(e.state._tag===`Closed`)return R(gR);let i=bd(r,t,n?.startImmediately??!0,!0);return hR(e,i,n),I(i)}),yR=e=>()=>H(P_(),t=>{let n=hv(t);return(t,r)=>{if(e.state._tag===`Closed`)return gR();let i=n(t,r);return hR(e,i,r),i}}),bR=e=>Wg({while:()=>e.state._tag===`Open`&&e.state.backing.size>0,body:()=>Nk(ri(e)),step:u}),xR=pO([class extends Dk(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:xO(`WorkerSpawnError`),message:K,cause:JD(UO())}){},class extends Dk(`effect/workers/WorkerError/WorkerSendError`)({_tag:xO(`WorkerSendError`),message:K,cause:JD(UO())}){},class extends Dk(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:xO(`WorkerReceiveError`),message:K,cause:JD(UO())}){},class extends Dk(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:xO(`WorkerUnknownError`),message:K,cause:JD(UO())}){}]),SR=(e,t)=>e===void 0?t:`${e}.${t}`,CR=(e,t)=>({"rpc.system.name":`effect_rpc`,"rpc.method":e,...t}),wR=`~effect/PrimaryKey`,TR=`~effect/rpc/RpcSchema/StreamSchema`;function ER(e){return v(e,TR)}function DR(e){return ER(e)?E({success:e.success,error:e.error}):T()}var OR=OD(MM);function kR(e,t){return G(OR.ast,{[TR]:TR,success:e,error:t})}var AR=`~effect/rpc/Rpc`,jR={[AR]:AR,pipe(){return e(this,arguments)},setSuccess(e){return MR({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return MR({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return MR({_tag:this._tag,payloadSchema:KD(e)?e:q(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return MR({_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 MR({_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 MR({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:ya(this.annotations,e,t)})},annotateMerge(e){return MR({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Oa(this.annotations,e)})}},MR=e=>{function t(){}return Object.setPrototypeOf(t,jR),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},NR=(e,t)=>{let n=t?.success??iO,r=t?.error??ZD,i=t?.defect??UO(),a;return a=t?.primaryKey?class extends Ek(`effect/rpc/Rpc/${e}`)(t.payload){[wR](){return t.primaryKey(this)}}:KD(t?.payload)?t?.payload:t?.payload?q(t?.payload):iO,MR({_tag:e,payloadSchema:a,successSchema:t?.stream?kR(n,r):n,errorSchema:t?.stream?ZD:r,defectSchema:i,annotations:ga(),middlewares:new Set})},PR=new WeakMap,FR=e=>{if(PR.has(e))return PR.get(e);let t=e,n=new Set([t.errorSchema]),r=DR(t.successSchema);Dr(r)&&n.add(r.value.error);for(let e of t.middlewares)n.add(e.error);let i=uk(Dr(r)?iO:t.successSchema,pO([...n]),t.defectSchema);return PR.set(e,i),i},IR=O(`effect/rpc/Rpc/ParseOptions`,{defaultValue:()=>WC}),LR=`~effect/rpc/Rpc/Wrapper`,RR=e=>LR in e,zR=`~effect/rpc/RpcClientError`,BR=class extends Dk(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:xO(`RpcClientDefect`),message:K,cause:UO()}){},VR=class extends Dk(zR)({_tag:xO(`RpcClientError`),reason:pO([xR,XL,vI,BR])}){[zR]=zR;get message(){return`${this.reason._tag}: ${this.reason.message}`}},HR=e=>e,UR={_tag:`Ping`},WR=pO([K,tO]),GR=pO([q({_tag:xO(`Request`),id:WR,tag:K,payload:XO,headers:lO(cO([K,K])),isNotification:JD(XD(!0)),discard:JD(XD(!0)),traceId:JD(K),spanId:JD(K),sampled:JD(nO)}),q({_tag:xO(`Ack`),requestId:WR}),q({_tag:xO(`Interrupt`),requestId:WR}),q({_tag:xO(`Ping`)}),q({_tag:xO(`Eof`)}),q({_tag:xO(`Chunk`),requestId:WR,values:XO}),q({_tag:xO(`Exit`),requestId:WR,exit:XO}),q({_tag:xO(`Defect`),defect:XO}),q({_tag:xO(`Pong`)})]),KR=new WeakMap,qR=new WeakMap,JR=new WeakMap,YR=new WeakMap;function XR(e,t){let n=t?.fingerprint===!0?qR:KR,r=n.get(e);if(r!==void 0)return r;let{exact:i,layout:a,recursive:o,target:s}=eU(e),c=QH(a,t?.fingerprint),l=i?{value:void 0}:void 0,u=QR(l===void 0?s:iU(s,l,!o),a,c,l);return n.set(e,u),u}function ZR(e,t){let n=t?.fingerprint===!0?YR:JR,r=n.get(e);if(r!==void 0)return r;let{exact:i,exitSuccess:a,layout:o,target:s}=eU(e);if(!i){if(!a)return XR(e,t);let r={value:void 0},i=QR(oU(s,r),o,QH(o,t?.fingerprint),r,!0);return n.set(e,i),i}let c=QR(sU(s),o,QH(o,t?.fingerprint),void 0);return n.set(e,c),c}function QR(e,t,n,r,i=!1){return XO.pipe(vO(e,XH(t,n,r,i)))}function $R(e,t){let{exact:n,exitSuccess:r,layout:i}=eU(e),a=QH(i,t?.fingerprint),o=t??WC;if(!n||o.onExcessProperty===`error`){let n=WD(XR(e,t),t);return!r||o.onExcessProperty===`error`?n:e=>{if(!mH(e))return n(e);try{return pH(i,e,o,a)}catch(e){throw e instanceof aB?new kD(e.issue):e}}}return e=>{try{return pH(i,e,o,a)}catch(e){throw e instanceof aB?new kD(e.issue):e}}}function ez(e,t){let{exact:n,layout:r}=eU(e),i=t??WC;if(!n||i.onExcessProperty===`error`){let n=$R(e,t);return e=>tz(e.map(n))}let a=QH(r,t?.fingerprint);return e=>{try{return fH(r,e,i,a)}catch(e){throw e instanceof aB?new kD(e.issue):e}}}function tz(e){return e.length===1?e[0]:wD(e)}function nz(e,t){let{exact:n,exitSuccess:r,layout:i,target:a}=eU(e),o=t??WC,s=n?void 0:BD(a,o),c=s!==void 0&&r?e=>mH(e)?e:s(e):s;return az(i,QH(i,t?.fingerprint),o,t?.maxFrameSize,c,rz(n,t))}function rz(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 iz(e,t){let{exact:n,layout:r,target:i}=eU(e),a=rz(n,t),o=$R(e,t),s=ez(e,t);if(!a)return{encode:o,encodeMany:s};let c=QH(r,t?.fingerprint),l=t??WC,u=l.onExcessProperty===`error`?WD(i,t):void 0,d=VV(),f=e=>{try{return e()}catch(e){throw e instanceof aB?new kD(e.issue):e}};return{encode:e=>f(()=>pH(r,u===void 0?e:u(e),l,c,d)),encodeMany:e=>f(()=>fH(r,u===void 0?e:e.map(u),l,c,d))}}function az(e,t,n,r,i,a){let o=a?[]:void 0,s=new Uint8Array,c=0,l=0,u,d=!1,f=new EB,p=new SB(n,mB),m=()=>{f.release(),p.clear(),s=wB,c=l=0},h=(e,t)=>{throw new kD(new lS({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 kD(new lS({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>mz)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=qH(e,f,t);ie.push(i===void 0?c:i(c))}catch(e){d=!0,m();let t=e instanceof aB?new kD(e.issue):AD(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=>L(()=>{try{return I(_.feedSync(e))}catch(e){if(AD(e))return B(e);throw e}}),end:L(()=>{try{return _.endSync(),z}catch(e){if(AD(e))return B(e);throw e}})};return _}var oz=`~effect/encoding/SchemaBinary/fieldId`,sz=`~effect/encoding/SchemaBinary/fixedWidth`,cz=BigInt(`-9223372036854775808`),lz=BigInt(`9223372036854775807`),uz=BigInt(`18446744073709551615`);function dz(e){let t=e.checks;if(t!==void 0)for(let e of t){let t=e.annotations?.[sz];if(t!==void 0)return t}}var fz=32,pz=33,mz=BigInt(2**53-1),hz=BigInt(0),gz=BigInt(1),_z=BigInt(2),vz=BigInt(7),yz=BigInt(127),bz=BigInt(1e6),xz=BigInt(255),Sz=BigInt(4294967295),Cz=BigInt(32),wz=new TextEncoder,Tz=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),Ez=7,Dz=0xffffffffffff,Oz=0xfffffffffffff,kz=0,Az=1,jz=2,Mz=512,Nz=1048576,Pz=4194304,Fz=0,Iz=1,Lz=2,Rz=3,zz=4,Bz=5,Vz=6,Hz=7,Uz=8;function Wz(e){return typeof e==`number`&&Number.isInteger(e)&&e>=-0xffffffffffff&&e<=Dz}var Gz=8,Kz=2199023255551,qz=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function Jz(e){for(let t=1;t<=Gz;t++){let n=Math.round(e*qz[t]);if(!(n>=-2199023255551&&n<=Kz))return 0;if(n/qz[t]===e)return t}return 0}function Yz(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 Xz(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}var Zz=BigInt(`14695981039346656037`),Qz=BigInt(`1099511628211`),$z=BigInt(`18446744073709551615`);function eB(e){let t=Zz;for(let n=0;n<e.length;n++)t=(t^BigInt(e[n]))*Qz&$z;return t}function tB(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function nB(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function rB(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function iB(e,t){for(let n=0;n<8;n++)e.push(Number(t>>BigInt(n*8)&xz))}var aB=class extends Error{issue;constructor(e){super(`SchemaBinary failure`),this.issue=e}};function X(e,t,n){throw oB(new lS({expected:e},t,n))}var Z=[],Q=0;function oB(e){return new aB(Q===0?e:new iS(Z.slice(0,Q),e))}function sB(e){let t=new Uint8Array(cB(e)),n=0;for(;e>127;)t[n++]=e&127|128,e=Math.floor(e/128);return t[n]=e,t}function cB(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var lB=32;function uB(e,t,n,r){let i=n-t;if(i===0)return``;if(i<=lB){let r=dB(e,t,n);if(r!==void 0)return r}try{return Tz.decode(e.subarray(t,n))}catch{X(`utf-8`,void 0,r)}}function dB(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 fB=65536,pB=16384,mB=256,hB=512,gB=16384;function _B(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var vB=_B(fB),yB=class{buf=new Uint8Array;view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;deferred=[];reset(){let e=vB;(e.writing||e.offset>=e.buf.length)&&(e=vB=_B(fB)),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=fB;for(;r<n;)r*=2;let i=_B(r);i.writing=!0,i.buf.set(this.buf.subarray(this.start,this.start+this.len)),t.writing=!1,this.arena=vB=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){e.length>=pB?this.deferred.push({bytes:e,length:e.length,at:this.len}):(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>yz;)this.byte(Number(e&yz)|128),e>>=vz;this.byte(Number(e))}zigzag(e){this.uvarintBig(e>=hz?e<<gz:(-e<<gz)-gz)}numberVarint(e){let t=e<0||e===0&&1/e<0,n=t?-e:e;n<=Oz?this.uvarint(n*2+ +!!t):this.uvarintBig(BigInt(n)*_z+(t?gz:hz))}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.sizeAfter(e);t<128?this.buf[this.start+e]=t:this.growSized(e,t)}endSizedRun(e){let t=this.sizeAfter(e)*2;t<128?this.buf[this.start+e]=t:this.growSized(e,t)}sizeAfter(e){let t=this.len-e-1,n=this.deferred;for(let r=n.length-1;r>=0&&n[r].at>e;r--)t+=n[r].length;return t}growSized(e,t){let n=cB(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=this.deferred;for(let t=a.length-1;t>=0&&a[t].at>e;t--)a[t].at+=r;let o=t,s=i;for(;o>127;)this.buf[s++]=o&127|128,o=Math.floor(o/128);this.buf[s]=o}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+=wz.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+=wz.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=t}this.len=r-this.start}out(){if(this.deferred.length>0){let e=this.assemble();return this.abort(),e}let e=this.arena,t=new Uint8Array(e.buf.buffer,this.start,this.len);return e===vB&&(e.offset=this.start+this.len),e.writing=!1,this.arena=void 0,t}assemble(){let e=this.deferred,t=this.len;for(let n=0;n<e.length;n++){let{bytes:r,length:i}=e[n];r.length!==i&&X(`Uint8Array whose length does not change during encoding`),t+=i}let n=new Uint8Array(t),r=this.buf,i=this.start,a=0,o=0;for(let t=0;t<e.length;t++){let{at:s,bytes:c,length:l}=e[t];n.set(r.subarray(i+a,i+s),o),o+=s-a,n.set(c,o),o+=l,a=s}return n.set(r.subarray(i+a,i+this.len),o),n}abort(){this.deferred.length>0&&(this.deferred.length=0);let e=this.arena;e!==void 0&&(e===vB&&(e.offset=this.start),e.writing=!1,this.arena=void 0)}};function bB(e){let t=IT(e);return t._tag===`String`&&t.checks===void 0}function xB(e,t,n){return e.extra.find(e=>_w({[t]:null},e.parameter,n).length>0)}var SB=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=xB(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}},CB=new ArrayBuffer(0),wB=new Uint8Array(CB),TB=new DataView(CB),EB=class{pos=0;nesting=0;buf=wB;view;viewCache=TB;viewBuffer=CB;viewOffset=0;viewLength=0;end=0;options=WC;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=wB,this.view=void 0,this.viewCache=TB,this.viewBuffer=CB,this.viewOffset=this.viewLength=0,this.options=WC,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,uB(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=hz,t=hz;for(;;){let n=this.byte();if(e|=BigInt(n&127)<<t,!(n&128))return e;t+=vz}}numberVarint(){let e=this.buf,t=this.end,n=this.pos,r=0,i=1;for(let a=0;a<Ez;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,Yz(r);i*=128}let a=this.uvarintBig(),o=Number(a>>gz);return Number.isFinite(o)||X(`safe integer length`,void 0,this.options),(a&gz)===gz?-o:o}zigzag(){let e=this.uvarintBig();return(e&gz)===gz?-(e+gz>>gz):e>>gz}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 DB(e,t){return{_:`literal`,leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function OB(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 kB(e){return e.values.map(e=>typeof e==`string`?JSON.stringify(e):String(e)).join(` | `)}var AB=0,jB=1,MB=2,NB=3,PB=30,FB=1<<PB;function IB(e){return e._===`literal`?IB(e.leaf):e._===`int`}function LB(e){switch(e._){case`literal`:return LB(e.leaf);case`bool`:return 1;case`i32`:case`u32`:return 4;case`int64`:case`i64`:case`u64`:return 8;default:return}}function RB(e){return LB(e)!==void 0||IB(e)||e._===`null`||e._===`undefined`}function zB(e){return e._===`literal`?zB(e.leaf):e._===`null`||e._===`undefined`}var BB={"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 VB(e){let t=e.annotations?.representation;return be(t)&&typeof t.id==`string`?t.id:void 0}var HB=bT(e=>{let t=UB(e),n=e.context;return t===e||n===void 0?t:vT(t,new GC(n.isOptional,n.isMutable,void 0,n.annotations))});function UB(e){switch(e._tag){case`Declaration`:{let t=VB(e);if(t!==void 0&&(t in BB||t===`effect/schema/Json`||t===`effect/schema/MutableJson`))return e.recur(HB);let n=e.annotations?.toCodecJson,r=e.annotations?.toCodec;if(!de(n)&&!de(r))return e;let i=e.typeParameters.map(e=>G(IT(e))),a=(de(n)?n(i):void 0)??(de(r)?r(i):void 0);return a===void 0?e:lT(e,[hT(a,HB)])}case`Arrays`:case`Objects`:case`Union`:case`Suspend`:return e.recur(HB);default:return e}}function WB(e){let t=[...e].sort((e,t)=>{let n=typeof e.key==`number`;return n===(typeof t.key==`number`)?n?e.key-t.key:TD(wz.encode(e.key),wz.encode(t.key)):n?-1:1}),n=[];for(let e of t){let t=wz.encode(String(e.key));n.push(typeof e.key==`number`?0:1),rB(n,t.length),tB(n,t);let r=e.literal,i=wz.encode(KB(r));n.push(GB(r)),rB(n,i.length),tB(n,i)}return Xz(n)}function GB(e){switch(typeof e){case`string`:return 1;case`number`:return 2;case`boolean`:return 3;case`bigint`:return 4;default:return 5}}function KB(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 qB(e){switch(e._tag){case`Symbol`:return!0;case`Union`:return e.types.some(qB);default:return!1}}function JB(e){let t=VB(e);return t===`effect/schema/Json`||t===`effect/schema/MutableJson`||de(e.annotations?.toCodecJson)}function YB(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 XB(e){for(;e._tag===`Suspend`;)e=e.thunk();return e}function ZB(e){return new Ww(e.enums.map(e=>new nw(e[1],{title:e[0]})))}function QB(e){let t=[],n=new Set,r=e=>{let i=XB(e);if(!n.has(i))switch(n.add(i),i._tag){case`Never`:return;case`Union`:i.types.forEach(r);return;case`Enum`:ZB(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 eV(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=VB(e);if(t!==void 0&&t in BB)return BB[t].kind;if(JB(e))return Y.json;throw Error(`Binary layout: declaration ${t??`<anonymous>`} has no toCodecJson or toCodec`)}case`Suspend`:return eV(XB(e));default:throw Error(`Binary layout: union members are not uniquely identifiable`)}}function tV(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function nV(e){let t=rV(e),n=!t&&aV(e);e=IT(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=dz(e);return o(t===`i32`||t===`u32`?t:YB(e)?`int`:`number`)}case`BigInt`:{let t=dz(e);return o(t===`i64`||t===`u64`?t:`bigint`)}case`Literal`:return DB(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,QB(ZB(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,QB(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?.[oz],s=typeof o==`number`?o:Xz(wz.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:sB(s*Uz+Fz),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(qB(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&&bB(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=DH(r.layout),r.inline=RB(r.layout),r.optional&&o.optionalCount++,o.byId.set(r.id,r)}t.sort((e,t)=>e.id-t.id);for(let e=0;e<t.length;e++)t[e].index=e;tV(o);for(let t=0;t<a.length;t++)a[t].layout=s(e.indexSignatures[t].type),a[t].wireMask=DH(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=LB(e),t.uniformNumbers=e._===`number`,t.uniformInline=RB(e)}return t}function d(e){let t=VB(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 BB)throw Error(`Binary layout: native declaration ${t} has no layout constructor`);if(JB(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=eV(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`)eV(e),l(Y.string,o(`symbol`));else{if(e._tag===`Objects`||e._tag===`Arrays`){let t=Iw(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:eV(e)})}for(let[e,t]of c)l(e,DB(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=WB(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};tV(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)=>dV(e.layout)-dV(t.layout)),p.discriminator=rH(p.variants),p}return{layout:s(e),recursive:i,exact:t,exitSuccess:n}}function rV(e){let t=new Map,n=e=>{if(e.encoding!==void 0||e.checks!==void 0&&!iV(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=VB(e),r=t===void 0?void 0:BB[t];return r===void 0?!1:r.exact===!0||e.typeParameters.every(n)}default:return!1}};return n(e)}function iV(e){return(e._tag===`Number`||e._tag===`BigInt`)&&e.checks?.length===1&&dz(e)!==void 0}function aV(e){return e._tag===`Declaration`&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&VB(e)===`effect/schema/Exit`&&rV(e.typeParameters[0])}var oV={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 sV(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=[oV.backEdge];return nB(e,n.length-i),eB(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=eB(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(oV[e._]),t;case`literal`:{t.push(oV.literal),tB(t,a(e.leaf)),nB(t,e.values.length);let n=e.values.map(e=>[GB(e),KB(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=wz.encode(r);nB(t,n.length),tB(t,n)}return t}case`int64`:return t.push(e.flavor===`date`?oV.date:oV.dateTimeUtc),t;case`never`:return t.push(oV.never),t;case`struct`:t.push(oV.struct),nB(t,e.fields.length);for(let n of e.fields)rB(t,n.id),t.push(+!!n.optional),iB(t,i(n.layout));nB(t,e.extra.length);for(let n of e.extra)iB(t,i(n.layout));return t;case`array`:t.push(oV.array),nB(t,e.elements.length);for(let n of e.elements)t.push(+!!n.optional),iB(t,i(n.layout));nB(t,e.rest.length);for(let n of e.rest)iB(t,i(n));return t;case`union`:t.push(oV.union),nB(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),rB(t,e.tag)),iB(t,i(n.layout))}return t;case`option`:return t.push(oV.option),iB(t,i(e.value)),t;case`result`:return t.push(oV.result),iB(t,i(e.success)),iB(t,i(e.failure)),t;case`exit`:return t.push(oV.exit),iB(t,i(e.value)),iB(t,i(e.cause.error)),iB(t,i(e.cause.defect)),t;case`cause`:case`causeReason`:return t.push(e._===`cause`?oV.cause:oV.causeReason),iB(t,i(e.error)),iB(t,i(e.defect)),t}}return i(e)}function cV(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 lV={positional:!1,rejectUnknownFields:!1,envelope:fz,expectedEnvelope:`version 2 envelope, flags 0`,fingerprint:new Uint8Array(8)};({...lV});function uV(e){let t=sV(e);return{positional:!0,rejectUnknownFields:!1,envelope:pz,expectedEnvelope:`version 2 envelope, flags 1`,fingerprint:cV(Number(t&Sz),Number(t>>Cz&Sz))}}function dV(e){switch(e._){case`json`:return 2;case`struct`:return 1;default:return 0}}function fV(e,t){switch(e._){case`literal`:return OB(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:Pv(t)&&t._tag===`Utc`;case`dateTimeZoned`:return Pv(t)&&t._tag===`Zoned`;case`duration`:return co(t);case`bigDecimal`:return My(t);case`option`:return Tr(t);case`result`:return Xr(t);case`exit`:return mp(t);case`cause`:return Lf(t);case`causeReason`:return Rf(t);case`array`:return Array.isArray(t);case`struct`:return be(t)&&!Array.isArray(t);case`json`:return!0;case`union`:case`never`:return!1}}function $(e,t,n){throw oB(new lS({expected:e},t,n))}function pV(e,t=new Set){if(!ye(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(pV(e[n],t))return!0}else for(let n of Object.keys(e))if(pV(e[n],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||Pv(e)||co(e)||My(e))return!1;if(t.has(e))return!0;t.add(e);try{if(Tr(e))return Dr(e)&&pV(e.value,t);if(Xr(e))return pV(Qr(e)?e.success:e.failure,t);if(mp(e))return pV(xp(e)?e.value:e.cause,t);if(Lf(e))return e.reasons.some(e=>pV(e,t));if(Rf(e))switch(e._tag){case`Fail`:return pV(e.error,t);case`Die`:return pV(e.defect,t);case`Interrupt`:return!1}if(nb(e)){for(let n of e)if(pV(n,t))return!0;return!1}if(Sb(e)){for(let[n,r]of e)if(pV(n,t)||pV(r,t))return!0;return!1}if(wb(e)){for(let n of e)if(pV(n,t))return!0;return!1}if(Bb(e))return pV(Ub(e),t);for(let n of Object.keys(e))if(pV(e[n],t))return!0}finally{t.delete(e)}return!1}function mV(e,t,n,r){let i=r.beginSized();cH(e,t,n,r),r.endSized(i)}function hV(e,t,n){let r=globalThis.Symbol.keyFor(t);r===void 0&&$(`registered symbol`,t,e.options),n.string(r)}function gV(e,t,n,r){let i=n;switch(i._tag){case`Fail`:r.byte(0),cH(e,t.error,i.error,r);return;case`Die`:r.byte(1),cH(e,t.defect,i.defect,r);return;case`Interrupt`:i.fiberId===void 0?r.byte(2):(r.byte(3),r.f64(i.fiberId))}}function _V(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function vV(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 yV(e,t){if(e.extraAll===void 0||t.length>hB)return!1;let n=0;for(let e=0;e<t.length;e++)if(n+=t[e].length,n>gB)return!1;return!0}function bV(e,t,n){let r=Object.keys(n),i=t.extraShape;if(i!==void 0&&vV(i,t,r))return i.pairs;let a=yV(t,r),o=a?void 0:e.extraShape;if(o!==void 0&&vV(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 SB(e.options)).find(t,n);r!==void 0&&(u&&!_V(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]=wz.encode(e[0]);l.sort((e,t)=>TD(e[2],t[2]))}if(a)for(let e of l)e[2]??=wz.encode(e[0]);let d={layout:t,keys:r,pairs:l};return a?t.extraShape=d:e.extraShape=d,l}function xV(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=SV(o.layout,c,e.options),u=l%Uz;if(i===void 0)r.uvarint(t*Uz+u);else{if(!i.disabled){let t=PV(i,a);if(t!==void 0){r.uvarint(t*16+u*2+1),Z[Q++]=a,CV(e,o.layout,c,l,r),Q--;continue}FV(i,a)}r.uvarint(t*16+u*2)}s===void 0?r.string(a):r.bytes(s),Z[Q++]=a,CV(e,o.layout,c,l,r),Q--}}function SV(e,t,n){if(e._===`literal`)return OB(e,t)||$(kB(e),t,n),SV(e.leaf,t,n);switch(e._){case`bool`:return typeof t!=`boolean`&&$(`a boolean`,t,n),t?zz:Rz;case`number`:if(typeof t!=`number`&&$(`a number`,t,n),Wz(t))return Iz;{let e=Jz(t);return e===0?Lz:e*Uz+Bz}case`int`:return Number.isSafeInteger(t)||$(`an integer`,t,n),Iz;case`i32`:case`u32`:return Vz;default:return Fz}}function CV(e,t,n,r,i){switch(r%Uz){case Rz:case zz:return;case Iz:i.numberVarint(n);return;case Lz:i.f64(n);return;case Vz:cH(e,t,n,i);return;case Bz:{let e=Math.floor(r/Uz);i.numberVarint(Math.round(n*qz[e])),i.uvarint(e);return}default:mV(e,t,n,i)}}function wV(e,t,n,r){let i=SV(t.layout,n,e.options),a=i%Uz;if(a===Fz){let i=r.idAndMark(t.tagBytes);cH(e,t.layout,n,r),r.endSized(i)}else r.uvarint(t.id*Uz+a),CV(e,t.layout,n,i,r)}function TV(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,oB(new aS(n.annotations))}}return i}function EV(e,t,n,r){let i=n;if(t.extra.length>0){let n=e.intern;e.intern=void 0;let a=bV(e,t,i);if(a.length>0){r.uvarint(0);let t=r.beginSized();xV(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,oB(new aS(n.annotations))}Z[Q++]=o,wV(e,n,i[o],r),Q--}}function DV(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,oB(new aS(n.annotations));Z[Q++]=a,n.inline?cH(e,n.layout,i[a],r):mV(e,n.layout,i[a],r),Q--}if(t.extra.length>0){let n=bV(e,t,i);r.uvarint(n.length),xV(e,n,i,r,a)}}function OV(e){switch(e._){case`string`:return jB;case`array`:return e.uniform?._===`string`?MB:AB;case`struct`:return e.extra.length>0?NB:AB;default:return AB}}function kV(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 AV(e){let t=e.run;if(t!==void 0)return t;let n=kV(e);if(n===void 0)return e.run=t=null,t;let r=n.fields.map(e=>OV(e.layout)),i=n.fields.length<=PB;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 jV=16,MV=64;function NV(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function PV(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 FV(e,t){let n=e.values;if(e.refs!==void 0){if(e.hits===0&&n.length>=MV){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,n.length)}else if(n.length>=jV){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 IV=0,LV=1,RV=2,zV=64,BV=512;function VV(){return{slots:[],marks:[],frame:0}}function HV(e,t){return e[t]??={values:[],refs:new Map,state:IV,stamp:-1}}function UV(e,t){e.refs.has(t)?e.state=LV:(e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=zV&&(e.state=RV))}function WV(e,t){let n=e.values;n.length>=BV||(e.refs.set(t,n.length),n.push(t))}function GV(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function KV(e){e.marks.length=0,e.frame++}function qV(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 JV(e,t,n,r){let i=HV(e.slots,t.slot),a=i.state;if(a===RV){r.string(n);return}if(GV(e,i),a===IV){r.string(n),UV(i,n);return}let o=i.refs.get(n);o===void 0?(r.byte(0),WV(i,n),r.string(n)):r.uvarint(o*2+1)}function YV(e,t,n){let r=HV(e,t.slot),i=r.state;if(i===RV)return n.readUtf8(n.end-n.pos);if(i===IV){let e=n.readUtf8(n.end-n.pos);return UV(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 WV(r,o),o}function XV(e,t,n,r,i){if(!e.disabled){let t=PV(e,r);if(t!==void 0){i.uvarint(t*2+1);return}FV(e,r)}let a=i.beginSized();cH(t,n,r,i),i.endSizedRun(a)}function ZV(e,t,n,r,i){let a=[],o=[];for(let s=0;s<r;s++){Z[Q++]=s;let r=i.beginSized();QV(e,t,a,o,n[s],i),i.endSized(r),Q--}}function QV(e,t,n,r,i,a){let o=t.struct,s=i,c=o.fields,l;if(o.extra.length>0){let t=bV(e,o,s);t.length>0&&(l=t)}let u=!t.shapes,d=l===void 0?0:FB,f=TV(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,oB(new aS(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();xV(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===jB)XV(NV(r,n),e,i.layout,s[i.name],a);else{o!==AB&&(e.intern=NV(r,n));let t=a.beginSized();cH(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 eH(e,t,n,r){let i=n.length;if(t.rest.length===0&&i>t.elements.length)throw Z[Q++]=t.elements.length,oB(new oS(t.ast,n[t.elements.length],e.options));if(i<t.minCount)throw Z[Q++]=i,oB(new aS(void 0));if(t.hasCount&&r.uvarint(i),i>0){let a=AV(t);if(a!==null){ZV(e,a,n,i,r);return}}let a=t.uniform;if(a!==void 0){if(t.uniformNumbers){nH(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,XV(o,e,a,n[t],r),Q--;return}let s=t.uniformInline;for(let t=0;t<i;t++)Z[Q++]=t,s?cH(e,a,n[t],r):mV(e,a,n[t],r),Q--}else for(let a=0;a<i;a++){let o=$V(t,a,i);Z[Q++]=a,RB(o)?cH(e,o,n[a],r):mV(e,o,n[a],r),Q--}}var tH=[];function nH(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)),i||a){if(Wz(n))(n<0?-n:n)>Kz&&(a=!1);else{i=!1;let e=Jz(n);e===0?a=!1:tH[r]=e}}}if(i){r.byte(Az);for(let e=0;e<n;e++)r.numberVarint(t[e])}else if(a){r.byte(jz);for(let e=0;e<n;e++){let n=t[e],i=Number.isInteger(n)?0:tH[e],a=i===0?n:Math.round(n*qz[i]),o=a<0||a===0&&1/a<0,s=o?-a:a;r.uvarint((s*2+ +!!o)*16+i)}}else{r.byte(kz);for(let e=0;e<n;e++)r.f64(t[e])}}function rH(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 iH(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 aH(e,t){return e.tuple?Array.isArray(t)&&iH(e,t):be(t)&&!Array.isArray(t)&&iH(e,t)}function oH(e,t,n,r){e.positional?r.uvarint(t.position):(r.byte(Y.variant),r.u32le(t.tag)),cH(e,t.payload,n,r)}function sH(e,t,n,r){let i=t.discriminator;if(i!==void 0){if(be(n)&&!Array.isArray(n)){let t=n,a=i.rows.get(t[i.key]);if(a!==void 0&&iH(a,t)){oH(e,a,n,r);return}}}else for(let i of t.variants)if(aH(i,n)){oH(e,i,n,r);return}for(let i of t.others)if(fV(i.layout,n)){e.positional?r.uvarint(i.position):r.byte(i.kind),cH(e,i.layout,n,r);return}throw oB(new cS(t.ast,n,e.options))}function cH(e,t,n,r){switch(t._){case`literal`:OB(t,n)||$(kB(t),n,e.options),cH(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),Wz(n)){r.numberVarint(n);return}let t=Jz(n);t>0?(r.numberVarint(Math.round(n*qz[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):JV(i,t,n,r);return}case`symbol`:typeof n!=`symbol`&&$(`a symbol`,n,e.options),hV(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<cz||n>lz)&&$(`a 64-bit integer`,n,e.options),r.i64(n);return;case`u64`:(typeof n!=`bigint`||n<hz||n>uz)&&$(`a 64-bit unsigned integer`,n,e.options),r.u64(n);return;case`int64`:{fV(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`:{fV(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`:{co(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)*bz);return}}case`bigDecimal`:{My(n)||$(`a BigDecimal`,n,e.options);let t=zy(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&&(pV(n)&&$(`acyclic value`,n,e.options),$(`a JSON-serializable value`,n,e.options)),r.string(t);return}case`option`:{Tr(n)||$(`an Option`,n,e.options);let i=n;i._tag===`None`?r.byte(0):(r.byte(1),cH(e,t.value,i.value,r));return}case`result`:{Xr(n)||$(`a Result`,n,e.options);let i=n;i._tag===`Success`?(r.byte(0),cH(e,t.success,i.success,r)):(r.byte(1),cH(e,t.failure,i.failure,r));return}case`exit`:{mp(n)||$(`an Exit`,n,e.options);let i=n;i._tag===`Success`?(r.byte(0),cH(e,t.value,i.value,r)):(r.byte(1),cH(e,t.cause,i.cause,r));return}case`cause`:{Lf(n)||$(`a Cause`,n,e.options);let i=n.reasons;r.uvarint(i.length);for(let n of i){let i=r.beginSized();gV(e,t,n,r),r.endSized(i)}return}case`causeReason`:Rf(n)||$(`a Cause.Reason`,n,e.options),gV(e,t,n,r);return;case`struct`:(!be(n)||Array.isArray(n))&&$(`an object`,n,e.options),e.positional?DV(e,t,n,r):EV(e,t,n,r);return;case`array`:Array.isArray(n)||$(`an array`,n,e.options),eH(e,t,n,r);return;case`union`:sH(e,t,n,r);return;case`never`:throw oB(new cS(t.ast,n,e.options))}}var lH=new yB;function uH(e,t,n,r,i){let a=i.beginSized();i.byte(r.envelope),r.positional&&i.bytes(r.fingerprint),cH(e,t,n,i),i.endSized(a)}function dH(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=lH??new yB,c=s===lH;c&&(lH=void 0),s.reset();let l=Q,u=!1;try{if(n===void 0)Q=0,uH(o,e,t,i,s);else for(let t=0;t<n.length;t++)Q=0,uH(o,e,n[t],i,s);let r=s.out();return u=!0,r}finally{a!==void 0&&(u?KV(a):qV(a)),s.abort(),Q=l,c&&(lH=s)}}function fH(e,t,n,r,i){return dH(e,void 0,t,n,r,i)}function pH(e,t,n,r,i){return dH(e,t,void 0,n,r,i)}function mH(e){return mp(e)&&xp(e)}var hH=globalThis.Symbol.for(`~effect/encoding/SchemaBinary/absent`);function gH(e,t){let n=GH(e,t);return n!==hH&&t.pos!==t.end&&X(`no leftover bytes`,void 0,t.options),n}function _H(e,t){let n=t.enter(t.uvarint()),r=gH(e,t);return t.exit(n),r}function vH(e,t){if(IB(e))return GH(e,t);let n=LB(e),r=t.enter(n===void 0?e._===`null`||e._===`undefined`?0:t.uvarint():n),i=gH(e,t);return t.exit(r),i}var yH=8;function bH(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>=yH){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 xH(e,t,n,r,i){let a=t.uvarint(),o=Math.floor(i===void 0?a/Uz:a/16),s=i===void 0?a-o*Uz:Math.floor((a-o*16)/2),c=i===void 0?t.readUtf8(o):SH(i,a,o,t);e.names.has(c)&&X(`an extra key distinct from declared fields`,c,t.options),bH(r,c)&&X(`unique extra keys`,void 0,t.options);let l=e.extraAll??(t.indexSignatures??=new SB(t.options)).find(e,c);if(l===void 0){t.rejectUnknownFields&&X(`a key matching an index signature`,c,t.options),EH(s,t);return}Z[Q++]=c;let u=kH(l.layout,l.wireMask,s,t);Q--,u!==hH&&b(n,c,u)}function SH(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 CH(e){return new iS([e.name],new aS(e.annotations))}function wH(e,t){throw oB(new sS(e.ast,t))}function TH(e){for(;e.byte()&128;);}function EH(e,t){switch(e){case Fz:t.take(t.uvarint());return;case Iz:TH(t);return;case Lz:t.take(8);return;case Rz:case zz:case Hz:return;case Bz:TH(t),TH(t);return;case Vz:t.take(4);return}}function DH(e){if(e._===`literal`)return DH(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 OH(e,t){switch(e){case Rz:return!1;case zz:return!0;case Iz:return t.numberVarint();case Lz:return t.f64();case Bz:{let e=t.numberVarint(),n=t.uvarint();return(n===0||n>Gz)&&X(`a decimal scale in [1, 8]`,n,t.options),e/qz[n]}}return X(`matching field wire kind`,void 0,t.options)}function kH(e,t,n,r){if(!(t&1<<n))return r.rejectUnknownFields&&X(`matching field wire kind`,n,r.options),EH(n,r),hH;if(n===Vz)return e._===`u32`?r.u32le():r.i32le();if(n!==Fz){let t=OH(n,r);return e._===`literal`&&!OB(e,t)&&X(kB(e),t,r.options),t}let i=r.enter(r.uvarint()),a=gH(e,r);return r.exit(i),a}function AH(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/Uz),m=f-p*Uz;if(p===0){l&&X(`unique field ids`,void 0,t.options),l=!0,m!==Fz&&X(`extra field map`,void 0,t.options);let i=t.enter(t.uvarint());NH(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),EH(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=kH(h.layout,h.wireMask,m,t);Q--,ee!==hH&&(b(r,h.name,ee),g<32?a|=1<<g:(s??=new Set).add(g))}return jH(e,a,s,t),r}function jH(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(CH(o)),r.options.errors!==`all`))break}a!==void 0&&wH(e,a)}function MH(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?vH(n.layout,t):_H(n.layout,t);if(Q--,i!==hH)b(r,n.name,i);else if(!n.optional&&((l??=[]).push(CH(n)),t.options.errors!==`all`))break}if(l!==void 0&&wH(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++)xH(e,t,r,a,n)}}return r}function NH(e,t,n,r){let i={list:[],set:void 0};for(;t.pos<t.end;)xH(e,t,n,i,r)}function PH(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=gH(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=gH(t,n);return n.exit(i),e.push(a),a}function FH(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]=LH(e,i,a,n),n.exit(t),Q--}return r}function IH(e,t){let n=t.uvarint(),r=e.fields,i=n&-1073741825;(n>FB*2-1||i>>>r.length)&&X(`a known row shape`,void 0,t.options);let a=[];(n&FB)!==0&&a.push(null);for(let e=0;e<r.length;e++)i&1<<e&&a.push(r[e]);return a}function LH(e,t,n,r){let i=e.struct,a={},o=0,s,c=r.uvarint(),l;if(c===0?r.positional&&e.shapes&&(l=IH(i,r),t.push(l)):(l=t[c-1],l===void 0&&X(`a known row shape`,void 0,r.options)),l!==void 0){for(let t=0;t<l.length;t++){let i=RH(e,n,l[t],a,r);i>=0&&(i<32?o|=1<<i:(s??=new Set).add(i))}r.pos!==r.end&&X(`no leftover bytes`,void 0,r.options)}else{let c=e.shapes?[]:void 0,l=0,u,d,f=!1;for(;r.pos<r.end;){let t=r.uvarint(),p;t===0?(f&&X(`unique field ids`,void 0,r.options),f=!0,p=null):(p=i.byId.get(t),p===void 0?(r.rejectUnknownFields&&X(`a known field id`,t,r.options),d===void 0?d=new Set([t]):d.has(t)?X(`unique field ids`,void 0,r.options):d.add(t)):p.index<32?(l&1<<p.index&&X(`unique field ids`,void 0,r.options),l|=1<<p.index):u===void 0?u=new Set([p.index]):(u.has(p.index)&&X(`unique field ids`,void 0,r.options),u.add(p.index))),c?.push(p);let m=RH(e,n,p,a,r);m>=0&&(m<32?o|=1<<m:(s??=new Set).add(m))}c!==void 0&&t.push(c)}return jH(i,o,s,r),a}function RH(e,t,n,r,i){let a=i.uvarint();if((a&1)==1){if(n==null)return-1;let e=t[n.index],o=(a-1)/2;(e===void 0||o>=e.length)&&X(`a known back-reference`,void 0,i.options);let s=e[o];return s===hH?-1:(b(r,n.name,s),n.index)}let o=i.enter(a/2);if(n===null)return NH(e.struct,i,r),i.exit(o),-1;if(n===void 0)return i.exit(o),-1;let s=e.intern[n.index];(s===MB||s===NB)&&(i.intern=t[n.index]??=[]),Z[Q++]=n.name;let c=gH(n.layout,i);return Q--,i.intern=void 0,i.exit(o),s===jB&&(t[n.index]??=[]).push(c),c===hH?-1:(b(r,n.name,c),n.index)}function zH(e,t){let n=e.elements.length,r=e.hasCount?t.uvarint():n;if(e.rest.length===0&&r>n)throw Z[Q++]=n,oB(new oS(e.ast,void 0,t.options));if(r<e.minCount)throw Z[Q++]=r,oB(new aS(void 0));if(e.hasCount&&r>(e.rest.length>0&&zB(e.rest[0])?Pz:t.remaining+Nz)&&X(`array count within allocation limit`,r,t.options),r>0){let n=AV(e);if(n!==null)return FH(n,r,t)}let i=Array(r),a=e.uniform;if(a!==void 0){if(e.uniformNumbers)return BH(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=PH(n,a,t);if(r===hH)throw oB(new aS(void 0));Q--,i[e]=r}return i}if(IB(a)){for(let e=0;e<r;e++)Z[Q++]=e,i[e]=GH(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()):_H(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=gH(a,t);if(t.exit(n),r===hH)throw oB(new aS(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,oB(new aS(void 0));Z[Q++]=a;let c=vH(o,t);if(c===hH)throw s&&X(`known union member`,void 0,t.options),oB(new aS(void 0));Q--,i[a]=c}if(!e.hasCount&&t.pos<t.end)throw Z[Q++]=n,oB(new oS(e.ast,void 0,t.options));return i}function BH(e,t,n){let r=n.byte();if(r===kz){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===jz){for(let r=0;r<t;r++){Z[Q++]=r;let t=n.uvarint(),i=t%16;i>Gz&&X(`decimal`,void 0,n.options);let a=Yz((t-i)/16);e[r]=i===0?a:a/qz[i],Q--}return e}r!==Az&&X(`f64`,void 0,n.options);for(let r=0;r<t;r++)Z[Q++]=r,e[r]=n.numberVarint(),Q--;return e}function VH(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),hH;let i=gH(r.payload,t);if(i===hH)return hH;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),hH):gH(r,t)}function HH(e,t){let n=e.byPos[t.uvarint()];n===void 0&&X(`known union member`,void 0,t.options);let r=gH(n.layout,t),i=n.variant;if(i!==void 0&&!i.tuple&&r!==hH)for(let e of i.sentinels)b(r,e.key,e.literal);return r}function UH(e,t){switch(t.byte()){case 0:return Kf(WH(gH(e.error,t)));case 1:return qf(WH(gH(e.defect,t)));case 2:return t.remaining!==0&&X(`empty`,void 0,t.options),Jf();case 3:return t.remaining!==8&&X(`f64`,void 0,t.options),Jf(t.f64());default:return t.take(t.remaining),hH}}function WH(e){if(e===hH)throw oB(new aS(void 0));return e}function GH(e,t){t.nesting>=Mz&&X(`nesting depth at most ${Mz}`,t.nesting+1,t.options),t.nesting++;try{return KH(e,t)}finally{t.nesting--}}function KH(e,t){switch(e._){case`literal`:{let n=GH(e.leaf,t);return OB(e,n)||X(kB(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>Ez)&&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>Gz)&&X(`decimal`,void 0,t.options),n/qz[r]}case`int`:return t.numberVarint();case`string`:{let n=t.dict;return n===void 0?t.readUtf8(t.end-t.pos):YV(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:zv(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 Bv(e,{timeZone:r})}catch{return X(`time zone`,void 0,t.options)}}case`duration`:switch(t.byte()){case 0:return _o(t.zigzag());case 1:return ho;case 2:return go;default:return X(`duration`,void 0,t.options)}case`bigDecimal`:{let e=t.zigzag(),n=t.zigzag();return(n>mz||-n>mz)&&X(`safe integer length`,void 0,t.options),Ny(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(WH(gH(e.value,t))))}case`result`:{let n=t.byte();return n===0?qr(WH(gH(e.success,t))):(n!==1&&X(`bool`,void 0,t.options),Jr(WH(gH(e.failure,t))))}case`exit`:{let n=t.byte();return n===0?hp(WH(gH(e.value,t))):(n!==1&&X(`bool`,void 0,t.options),gp(GH(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=UH(e,t);t.exit(n),Q--,a!==hH&&r.push(a)}return t.pos!==t.end&&X(`no leftover bytes`,void 0,t.options),Hf(r)}case`causeReason`:return UH(e,t);case`struct`:return t.positional?MH(e,t):AH(e,t);case`array`:return zH(e,t);case`union`:return t.positional?HH(e,t):VH(e,t);case`never`:throw oB(new cS(e.ast,void 0,t.options))}}function qH(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=gH(e,t);if(i===hH)throw oB(new aS(void 0));return i}var JH=new EB;function YH(e,t,n,r){let i=JH??new EB,a=i===JH;a&&(JH=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=qH(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&&(JH=i)}}function XH(e,t,n,r=!1){return cC({decode:(i,a)=>{try{let o=YH(e,i,a,t);return n!==void 0&&ye(o)&&(!r||mH(o))&&(n.value=o),I(o)}catch(e){return e instanceof aB?B(e.issue):$g(e)}},encode:(n,r)=>{try{return I(pH(e,n,r,t))}catch(e){return e instanceof aB?B(e.issue):$g(e)}}})}var ZH=p(uV);function QH(e,t){return t===!0?ZH(e):lV}var $H=p(e=>{let t=G(HB(e)),{exact:n,exitSuccess:r,layout:i,recursive:a}=nV(t.ast);return{target:a?cU(t):t,layout:i,exact:n,exitSuccess:r,recursive:a}});function eU(e){return $H(e.ast)}function tU(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function nU(e,t,n){let r=G(FT(e.ast)),i=jE(r),a=e=>()=>(t,n,r)=>e(t,r)?Jx:i(t,r);return G(new JC([r.ast],a(t),{identifier:`binary value`},void 0,void 0,void 0,void 0,a(n)))}function rU(e,t){return t.onExcessProperty!==`error`}function iU(e,t,n){return nU(e,e=>tU(t,e),n?rU:aU)}function aU(){return!1}function oU(e,t){return DD()([e],([e])=>{let n=jE(e);return(e,r,i)=>tU(t,e)||mH(e)&&i.onExcessProperty!==`error`?I(e):n(e,i)},{identifier:`binary exit value`})}function sU(e){return nU(e,rU,rU)}function cU(e){let t=G(FT(e.ast)),n=new WeakSet;return vO(DD()([t],([e])=>(t,r,i)=>ye(t)&&n.delete(t)?I(t):pV(t)?B(new cS(r,t,i)):jE(e)(t,i),{identifier:`acyclic value`}),lC({decode:e=>(ye(e)&&n.add(e),e),encode:e=>e}))(e)}var lU=class extends $i()(`effect/rpc/RpcSerialization`){},uU=16777216,dU=new TextEncoder,fU=e=>{let t=e?.maxFrameSize===`unbounded`?void 0:e?.maxFrameSize??uU,n=e?.fingerprintPayloads===!0?e=>ZR(e,{fingerprint:!0}):ZR,r={fingerprint:!0};return lU.of({contentType:`application/vnd.effect.rpc+schema-binary`,includesFraming:!0,codecFor:n,makeUnsafe:()=>{let e=nz(GR,{...r,maxFrameSize:t}),n=iz(GR,r);return{decode:t=>e.feedSync(typeof t==`string`?dU.encode(t):t),encode:e=>{if(!Array.isArray(e))return n.encode(e);if(e.length!==0)return n.encodeMany(e)}}}})},pU=e=>fm(lU)(()=>fU(e)),mU=e=>L(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>F_(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),z});return H(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return Xg(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*L_(L(()=>i(e)),t)}return yield*Y_(Yg,()=>(t.delete(e),r.delete(e),z))})}}))}),hU=0,gU=Cv(function*(e,t){let n=t.spanPrefix,r=t?.supportsAck??!0,a=t?.disableTracing??!1,o=t?.generateRequestId??(()=>hU++),s=yield*P_(),c=D(s,Vp),l=new Map,u=!1;yield*Gp(c,n_(e=>(u=!0,d(yp(e.id)))));let d=Cv(function*(e){let t=Array.from(l.values());l.clear();for(let n of t)n._tag===`Queue`?yield*e._tag===`Success`?WA(n.queue):HA(n.queue,e.cause):n.resume(e)},ev),f=e=>{let r=ER(e.successSchema),i=h(e);return(o,s)=>{let c=s?.headers?Xb(s.headers):Yb,l=s?.context??ga();if(!r){let r=t=>p(e,i,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return a?r(void 0):sv(SR(n,e._tag),{kind:`client`,attributes:CR(e._tag,t.spanAttributes)},r)}let u=m(e,i,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:ZM(H(u,qM))}},p=(e,n,r,a,s,c,d)=>n_(f=>{if(u)return Z_;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:ex(f.getRef(bU),s),...d?{discard:!0}:{}}),h;return $_(Jg(t=>{let n=!1,a={_tag:`Effect`,rpc:e,context:c,resume(e){d&&e._tag===`Success`?(n=!0,h?.pollUnsafe()&&t(bp)):(t(e),h&&!h.pollUnsafe()&&f.currentDispatcher.scheduleTask(()=>{h.interruptUnsafe(f.id)},0))}};l.set(p,a),h=m.pipe(r?lv(r,{captureStackTrace:!1}):i,hv(f.context)),h.addObserver(e=>{if(e._tag===`Failure`)return l.delete(p),t(e);if(n)return t(bp)})}),e=>(l.delete(p),o_(Ik(h),g(p,Array.from(e),c))))}),m=Cv(function*(e,r,s,c,d,f){if(u)return yield*Z_;let p=a?void 0:yield*ov(SR(n,e._tag),{kind:`client`,attributes:CR(e._tag,t.spanAttributes)}),m=Rk(),h=o(),ee=Ca(m.context,Vp),_=yield*LA(d);return yield*Wp(ee,e=>(KA(_),l.has(h)?(l.delete(h),g(h,Sp(e)?Array.from(tp(e.cause)):[],f)):z)),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:ex(m.getRef(bU),c)}).pipe(p?lv(p,{captureStackTrace:!1}):i,q_(e=>(Yf(e)||l.delete(h),HA(_,e))),Q_,dv(ee,{startImmediately:!0})),_}),h=e=>{let t=[];for(let n of e.middlewares.values()){let e=Sa(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)=>Jg(i=>{let a=Rk();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r}).pipe(w_(1e3),hv(a.context)).addObserver(()=>{i(z)})}),ee=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,a=l.get(n);return!a||a._tag!==`Queue`?z:BA(a.queue,e.values).pipe(r?V(n=>n.length>0?z:t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:a.context})):i,p_(e=>HA(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),z):e.exit._tag===`Success`?WA(n.queue):HA(n.queue,e.exit.cause)):z}case`Defect`:return d(vp(e.defect));case`ClientEnd`:return z}},_;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}}),_U=0,vU=Cv(function*(e,t){let n=_U++,{codecFor:r,run:i,send:a,supportsAck:o,supportsTransferables:s}=yield*xU,c=yU(r),l=VD(r(UO())),u=new Map,d=Ep(),f=e=>u.has(e)?(u.delete(e),a(n,{_tag:`Interrupt`,requestId:e})):z,{client:p,write:m}=yield*gU(e,{...t,supportsAck:o,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),i=s?sR():void 0,o=Rk(),l={rpc:r,context:i?ya(o.context,oR,i):o.context,schemas:c(r),discard:t.discard===!0};return u.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(L_(l.context),__,V(e=>Np(d)?(u.delete(t.id),Z_):a(n,{...t,id:t.id,payload:e,headers:Object.entries(t.headers)},i&&i.readUnsafe())),q_(e=>Yf(e)?z:R(()=>u.delete(t.id))))}case`Ack`:return u.get(t.requestId)?a(n,{_tag:`Ack`,requestId:t.requestId}):z;case`Interrupt`:return f(t.requestId);case`Eof`:return z}}});return yield*i(n,e=>{switch(e._tag){case`Chunk`:{let t=HR(e.requestId),n=u.get(t);if(!n||Er(n.schemas.decodeChunk))return z;let r=n.schemas.decodeChunk.value;return tv(i=>i(r(e.values).pipe(L_(n.context),__,V(e=>m({_tag:`Chunk`,clientId:0,requestId:t,values:e})))).pipe(q_(e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:gp(e)}).pipe(o_(ep(e)?z:A_(S_(f(t)),Op(d))))),h_(e=>!ep(e),()=>z)))}case`Exit`:{let t=HR(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:bp}):(n.discard?n.schemas.decodeDiscardExit:n.schemas.decodeExit)(e.exit).pipe(L_(n.context),__,N_({onSuccess:e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:gp(e)})}))):z}case`Defect`:return u.clear(),m({_tag:`Defect`,clientId:0,defect:l(e.defect)});case`ClientProtocolError`:{let t=_p(e.error),n=e.requestIds===void 0?Array.from(u.keys()):e.requestIds.map(HR).filter(e=>u.has(e));for(let e of n)u.delete(e);return Ug(n,e=>m({_tag:`Exit`,clientId:0,requestId:e,exit:t})).pipe(ev)}default:return z}}).pipe(p_(Tv),Q_,fv),yield*G_(()=>Fp(d,void 0)),p}),yU=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=DR(n.successSchema),a=D(n.annotations,IR),o=FR(n),s;return r={decodeChunk:Rr(i,t=>LD(e(uO(t.success)),a)),encodePayload:UD(e(n.payloadSchema),a),decodeExit:LD(e(o),a),decodeDiscardExit:t=>(s??=LD(e(uk(iO,o.error,o.defect)),a))(t)},t.set(n,r),r}},bU=O(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>Yb}),xU=class extends $i()(`effect/rpc/RpcClient/Protocol`){static make=mU},SU=e=>xU.make(Cv(function*(t,n){let r=yield*RL,a=yield*lU,o=yield*R_(EU),s=new Map,c=yield*r.writer,l=a.makeUnsafe(),d=yield*wU(L(()=>c.write(l.encode(UR))),e),f=C_(e?.onPingTimeout??z,{log:!0,message:`RpcClient onPingTimeout hook failed`}),p,m=e=>{let r=Ug(Array.from(n),n=>t(n,e));return e._tag!==`Defect`&&e._tag!==`ClientProtocolError`?r:(s.clear(),ev(r))},h=e=>(p=e,m({_tag:`ClientProtocolError`,error:e})),g=e=>{try{let n=l.decode(e);if(n.length===0)return z;d.onFrame();let r=0;return Wg({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return z;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:u})}catch(e){return m({_tag:`ClientProtocolError`,error:new VR({reason:new BR({message:`Error decoding message`,cause:e})})})}};yield*L(()=>{l=a.makeUnsafe(),d.reset();let e=!1;return Xg(function*(){let{pull:t}=yield*r.reader;for(p=void 0,e=!0,Dr(o)&&(yield*o.value.onConnect);;){let e=yield*t;for(let t=0;t<e.length;t++)yield*g(e[t])}}).pipe(H_,A_(d.timeout),o_(()=>e?f:z),o_(()=>B(new ZL({reason:new GL({cause:Error(`ping timeout`)})}))))}).pipe(Dr(o)?K_(o.value.onDisconnect):i,y_(t=>{let n=Qf(t),r=Qr(n),i=new VR({reason:r?n.success.reason:new BR({message:`Unknown socket error`,cause:Zf(t)})});return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?(e.onTransientError?.(i)??z).pipe(C_({log:!0,message:`RpcClient onTransientError hook failed`})):h(i)}),x_(e?.retryPolicy??CU,e=>h(new VR({reason:e.reason}))),Dv({module:`RpcClient`,method:`makeProtocolSocket`}),fv);let ee=e=>L(()=>{let t=l.encode(e);return t===void 0?z:__(c.write(t))});return{send(e,t){return p?B(p):(t._tag===`Interrupt`&&s.delete(t.requestId),t._tag===`Request`?(s.set(t.id,e),q_(ee(t),()=>R(()=>s.delete(t.id)))):ee(t))},supportsAck:!0,supportsTransferables:!1,codecFor:a.codecFor}})),CU=gg([vg(500,1.5),xg(5e3)]),wU=Cv(function*(e,t){let n=yield*dp,r=t?.pingInterval??`5 seconds`,i=So(t?.pingTimeout??r),a=n.currentTimeMillisUnsafe(),o=!1,s=Bk(),c=()=>{a=n.currentTimeMillisUnsafe(),o=!1};return yield*L(()=>o&&n.currentTimeMillisUnsafe()-a>i?s.open:(o=!0,e)).pipe(D_(r),S_,nv,Q_,fv),{timeout:s.await,reset:()=>{c(),s.closeUnsafe()},onFrame:c}}),TU=e=>mm(xU)(SU(e)),EU=class extends $i()(`effect/rpc/RpcClient/ConnectionHooks`){},DU=()=>(e,t)=>{let n=$i()(e),r=mm(n,t.makeEffect??vU(t.group,{...t,flatten:!0}));n.runtime=(t.runtime??aF)(typeof t.protocol==`function`?e=>Cm(r,Dm(t.protocol(e))):Cm(r,Dm(t.protocol))),n.mutation=_F(r=>{let i=t.group.requests.get(r);return n.runtime.fn()(Cv(function*({headers:e,payload:t,reactivityKeys:i}){let a=(yield*n)(r,t,{headers:e});return yield*i?eP(a,i):a})).pipe(OF({key:`AtomRpc:mutation:${JSON.stringify([e,r])}`,schema:YN({success:i.successSchema,error:OU(i)})}))});let i=_F(e=>{let{headers:r,payload:i,reactivityKeys:a,tag:o,timeToLive:s}=e,c=t.group.requests.get(o),l=ER(c.successSchema),u=l?n.runtime.pull(ZM(n.use(e=>I(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=OF(u,{key:`AtomRpc:${e.tag}:${e.serializationKey}`,schema:YN({success:c.successSchema,error:OU(c)})})),s&&(u=lo(s)?zP(u,s):vF(u)),u});return n.query=(e,t,n)=>{let r={tag:e,payload:t,headers:n?.headers?Xb(n.headers):void 0,reactivityKeys:n?.reactivityKeys,timeToLive:n?.timeToLive===void 0?void 0:$a(n.timeToLive),serializationKey:n?.serializationKey};return i(r)},n},OU=e=>pO([e.errorSchema,...Array.from(e.middlewares,e=>e.error),VR]),kU=O(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),AU=O(`effect/http/FetchHttpClient/StreamBodyFallback`,{defaultValue:()=>`error`}),jU=class extends $i()(`effect/http/FetchHttpClient/RequestInit`){},MU,NU=()=>{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}},PU=EL(I(gL((e,t,n,r)=>{if(e.headers.upgrade!==void 0)return B(new eI({reason:new fI({request:e,description:`fetch cannot send an HTTP upgrade request`})}));let i=r.getRef(kU),a=xa(r.context,jU)??{},o=a.headers?ex(Xb(a.headers),e.headers):e.headers;o[`content-length`]&&(o=tx(o,`content-length`));let s,c=R(()=>s?.abort()),l=r=>H(Kg({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 eI({reason:new fI({request:e,cause:t})})}),t=>{let n=tL(e,t);return s?(t.body===null&&s.abort(),Object.create(n,{...Object.fromEntries([`arrayBuffer`,`text`,`json`,`formData`,`urlParamsBody`].map(e=>[e,{get:()=>K_(n[e],c)}])),stream:{get:()=>pN(n.stream,c)}})):n}).pipe(q_(()=>c));switch(e.body._tag){case`Raw`:case`Uint8Array`:return l(e.body.body);case`FormData`:return l(e.body.formData);case`Stream`:if(MU??=NU(),MU){s=new AbortController;let t=AbortSignal.any([n,s.signal]),r=Jg(e=>{let n=()=>e(Z_);if(t.aborted)n();else return t.addEventListener(`abort`,n,{once:!0}),R(()=>t.removeEventListener(`abort`,n))});return V(xN(uN(e.body.stream,r)),l)}return r.getRef(AU)===`error`?B(new eI({reason:new pI({request:e,description:`Streaming request bodies are not supported in this runtime`})})):vN(e.body.stream).pipe(g_(t=>new eI({reason:new pI({request:e,cause:t})})),V(l))}return l(void 0)}))),FU=`4.1.4`,IU=()=>FU,LU=e=>{let t=e===void 0?void 0:mx(e);return t===void 0||Zr(t)?I(yo(5)):H(dp,e=>hx(t.success,e.currentTimeMillisUnsafe()))},RU=Cg.pipe(bg,hg(({output:e})=>$F(e)&&e.reason._tag===`StatusCodeError`&&e.reason.response.status===429?LU(e.reason.response.headers[`retry-after`]):I(yo(1)))),zU=class extends $i()(`effect/observability/OtlpExporter/Flusher`){},BU=fm(zU,()=>{let e=new Set;return{flush:L(()=>e.size===0?z:Ug(e,i,{concurrency:`unbounded`,discard:!0})),register:t=>V(Vp,n=>(e.add(t),Gp(n,R(()=>e.delete(t)))))}}),VU=Cv(function*(e){let t=yield*P_(),n=D(t,dp),r=D(t,Vp),i=jo($a(e.exportInterval),mo),a=D(t,uL).pipe(bL(e=>S_(e.arrayBuffer)),xL(e=>e.response?S_(e.response.arrayBuffer):z),pL,fL(B_(wL,!1)),vL({schedule:RU,times:3})),o=`OTel-OTLP-Exporter-JavaScript-Effect-${e.label}/${IU()}`,s=Xb(e.headers),c=s[`user-agent`],l=Qb(s,`user-agent`,c?`${c} ${o}`:o),u=FI(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=L(()=>{if(m()||f.length===0&&!d)return z;let t=f;f=[];let[n,r]=e.body(t),i=GI(u,n);return(e.compression===`gzip`?KI(i,`gzip`).pipe(V(a.execute)):a.execute(i)).pipe(o_(r),d_,iv(!1))}).pipe(p_(e=>p===void 0?(p=n.currentTimeMillisUnsafe()+6e4,f=[],Ev(`Disabling exporter for 60 seconds`,e)):z),Dv({package:`@effect/opentelemetry`,module:e.label})),g=yield*fR(),ee=yield*yR(g)();yield*Gp(r,L(()=>p===void 0?(ee(h),bR(g)):z).pipe(S_,Q_,T_(e.shutdownTimeout)));let _=yield*Vk(d),te=yield*Vk(),ne=R(()=>{d||f.length>0||!_.closeUnsafe()||te.openUnsafe()});yield*Xg(function*(){for(;;)te.closeUnsafe(),yield*_.await,yield*k_(O_(i),te.await),yield*Nk(yield*_R(g,h)),yield*ne}).pipe(dv(r));let re=o_(h,ne);return yield*(yield*zU).register(re),{push(t){m()||(f.push(t),e.maxBatchSize!==`disabled`&&f.length>=e.maxBatchSize?ee(re):_.openUnsafe())}}});function HU(e){return{_tag:`Value`,value:e}}function UU(e,t){return{_tag:`Record`,keys:e,value:t}}function WU(e,t){return{_tag:`Array`,length:e,value:t}}var GU=O(`effect/ConfigProvider`,{defaultValue:()=>$U()}),KU={...$t,toJSON(){return{_id:`ConfigProvider`}}},qU=e=>e;function JU(e,t){let n=Object.create(KU);return n.load=e,n.mapInput=t,n}function YU(e,t){return JU(n=>e(t(n)),n=>YU(e,e=>n(t(e))))}function XU(e){return YU(e,qU)}function ZU(e,t){return e===``&&!t?void 0:e}function QU(e,t){let n=t?.preserveEmptyStrings===!0,r=eW(e);return XU(t=>I(tW(r,e,t,n)))}function $U(e){return QU(e?.env??{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`},{preserveEmptyStrings:e?.preserveEmptyStrings})}function eW(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 tW(e,t,n,r){let i=n.map(String).join(`_`),a=ZU(Object.hasOwn(t,i)?t[i]:void 0,r),o=nW(e,n),s=o?.children?Object.keys(o.children):[];return s.length===0?a===void 0?void 0:HU(a):s.every(Ai)?WU(Math.max(...s.map(e=>parseInt(e,10)))+1,a):UU(new Set(s),a)}function nW(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 rW=`~effect/Config`,iW=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},aW={...Zi({label:`Config`,evaluate(e){return this.parse(e.getRef(GU))}}),[rW]:rW,toJSON(){return{_id:`Config`}}};function oW(e){let t=Object.create(aW);return t.evaluator=e,t.parse=t=>jv(e(t,[]),r_),t}var sW=(e,t,n)=>e.evaluator(t,n),cW=r(2,(e,t)=>oW((n,r)=>Ov(sW(e,n,r),e=>Zr(e)?qr(t):e))),lW=e=>Se(e,`SourceError`),uW=()=>`<configuration>`,dW=e=>t=>p_(t,t=>Zg(Hf(t.reasons.map(e)))),fW=(e,t)=>e.load(t).pipe(dW(e=>zf(e)?qf(e.error).annotate(up(e)):e),Ov(n=>({provider:e,path:t,node:n,toString:uW}))),pW=(e,t)=>fW(e.provider,[...e.path,t]),mW=(e,t)=>OT(tw,e,new aC(VS(e=>t(e)),BS())),hW=e=>{switch(e._tag){case`Union`:return e.types.every(hW);case`Objects`:case`Arrays`:case`Suspend`:return!1;default:return!0}},gW=(e,t)=>{switch(e._tag){case`Objects`:return t?._tag===`Record`;case`Arrays`:return t?._tag===`Array`;case`Union`:return e.types.some(e=>gW(e,t));case`Suspend`:return gW(e.thunk(),t);default:return t?.value!==void 0}},_W=p(e=>{let t=new WeakSet,n=yT(e=>{switch(t.add(e),e._tag){case`Objects`:{let t=Cv(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 _w(t,n.parameter))typeof e==`string`&&r.add(e)}let i={};for(let e of r){let n=yield*pW(t,e);n.node!==void 0&&b(i,e,n)}return i});return mW(e.recur(n,e=>e),t)}case`Arrays`:{let t=Cv(function*(e){if(e.node?._tag!==`Array`)return;let t=[];for(let n=0;n<e.node.length;n++)t.push(yield*pW(e,n));return t});return mW(e.recur(n),t)}case`Union`:for(let t of e.types)n(t);if(!hW(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 mW(e,e=>I(e.node?.value))});return n(e)});function vW(e,t){let n=Ak(e),r=IT(n.ast),i=jE(G(_W(n.ast))),a=typeof t==`string`?[t]:t??[];return oW((e,t)=>{let n=[...t,...a];return fW(e,n).pipe(jv(e=>i(e).pipe(Ov(qr),Mv(t=>{let i=new iW(new kD(n.length>0?new iS(n,t):t));return gW(r,e.node)?B(i):I(Jr(i))}))),dW(e=>Bf(e)&&lW(e.defect)?Kf(new iW(e.defect)).annotate(up(e)):e))})}var yW=e=>ae(e)||globalThis.Array.isArray(e);function bW(e){return vW(K,e)}function xW(e,t,n,r){let i=yW(n),a=oO(e,t),o=dC(i?r:n);return vW(pO([a,K.pipe(vO(Ak(a),{decode:o.decode,encode:FS(BS({strict:!1}),o.encode)}))]),i?n:void 0)}var SW=wf,CW=Df,wW=(e,t)=>mm(SW,w(Vc(function*(n){let r=new Set(t?.mergeWithExisting===!0?n.getRef(wf):[]);for(let t of e)r.add(tn(t)?yield*t:t);return r}))),TW=`window`in globalThis||`importScripts`in globalThis,EW=e=>({attributes:OW(Object.entries({"telemetry.sdk.name":`effect`,"telemetry.sdk.language":TW?`webjs`:`nodejs`,"telemetry.sdk.version":IU(),...e.attributes,...e.serviceName?{"service.name":e.serviceName}:void 0,...e.serviceVersion?{"service.version":e.serviceVersion}:void 0})),droppedAttributesCount:0}),DW=Cv(function*(e){let t=yield*xW(qO,qO,`OTEL_RESOURCE_ATTRIBUTES`,{trim:!0,keepEmptyValues:!0}).pipe(cW(void 0)),n=e?.serviceName??e?.attributes?.[`service.name`]??(yield*vW(gO(K),`OTEL_SERVICE_NAME`))??t?.[`service.name`]??(yield*bW(`OTEL_SERVICE_NAME`)),r=e?.serviceVersion??e?.attributes?.[`service.version`]??(yield*vW(gO(K),`OTEL_SERVICE_VERSION`))??t?.[`service.version`],i={...t,...e?.attributes};return delete i[`service.name`],delete i[`service.version`],EW({serviceName:n,serviceVersion:r,attributes:i})},__),OW=e=>{let t=[];for(let[n,r]of e)t.push({key:n,value:AW(r)});return t},kW=2**63,AW=e=>{if(Array.isArray(e))return{arrayValue:{values:e.map(AW)}};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>=-kW&&e<kW?{intValue:Number.isSafeInteger(e)?e:String(BigInt(e))}:{doubleValue:e};case`boolean`:return{boolValue:e};default:return{stringValue:x(e)}}},jW=class extends $i()(`effect/observability/OtlpSerialization`){};function MW(e,t){return typeof t==`number`&&!Number.isFinite(t)?String(t):e===`bytesValue`&&this[e]instanceof Uint8Array?cb(this[e]):t}var NW=e=>{let t=JSON.stringify(e);return UF(t.includes(`null`)||t.includes(`"bytesValue":`)?JSON.stringify(e,MW):t,`application/json`)},PW=lm(jW,{traces:e=>NW(e),metrics:e=>NW(e),logs:e=>NW(e)}),FW=Cv(function*(e){let t=yield*jW,n=yield*DW(e.resource),r={name:`effect`,version:IU()},i=yield*VU({label:`OtlpLogger`,url:e.url,headers:e.headers,compression:e.compression,maxBatchSize:e.maxBatchSize??1e3,exportInterval:e.exportInterval??yo(1),body:e=>[t.logs({resourceLogs:[{resource:n,scopeLogs:[{scope:r,logRecords:e}]}]}),z],shutdownTimeout:e.shutdownTimeout??yo(3)}),a={excludeLogSpans:e.excludeLogSpans??!1,clock:yield*dp};return CW(e=>{i.push(RW(e,a))})}),IW=e=>wW([FW(e)],{mergeWithExisting:e.mergeWithExisting??!0}).pipe(wm(BU)),LW=BigInt(1e6),RW=(e,t)=>{let n=t.clock.currentTimeNanosUnsafe().toString(),r=e.date.getTime(),i=(BigInt(r)*LW).toString(),a={...e.fiber.getRef(Rp)};if(a[`effect.fiberId`]=e.fiber.id,!t.excludeLogSpans)for(let[t,n]of e.fiber.getRef(zp))a[`effect.log_span.${t}`]=r-n;let o=rp(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(`
17
- `));let s=Si(e.message),c={severityNumber:zW(e.logLevel),severityText:e.logLevel,timeUnixNano:i,observedTimeUnixNano:n,attributes:OW(Object.entries(a)),body:AW(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},zW=e=>{switch(e){case`Trace`:return BW.SEVERITY_NUMBER_TRACE;case`Debug`:return BW.SEVERITY_NUMBER_DEBUG;case`Info`:return BW.SEVERITY_NUMBER_INFO;case`Warn`:return BW.SEVERITY_NUMBER_WARN;case`Error`:return BW.SEVERITY_NUMBER_ERROR;case`Fatal`:return BW.SEVERITY_NUMBER_FATAL;default:return BW.SEVERITY_NUMBER_UNSPECIFIED}},BW={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},VW=f(Cv(function*(e){let t=yield*DW(e.resource),n=yield*jW,r={name:`effect`,version:IU()},i=yield*VU({label:`OtlpTracer`,url:e.url,headers:e.headers,compression:e.compression,exportInterval:e.exportInterval??yo(5),maxBatchSize:e.maxBatchSize??1e3,body(e){let i={resourceSpans:[{resource:t,scopeSpans:[{scope:r,spans:e}]}]};return[n.traces(i),z]},shutdownTimeout:e.shutdownTimeout??yo(3)});function a(e){e.sampled&&i.push(UW(e))}return cs({span(e){return new HW(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})}),mm(ps),wm(BU)),HW=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??=Dr(this.parent)?this.parent.value.traceId:es(32)}get spanId(){return this._spanId??=es(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)}},UW=e=>{let t=e.status,n=e._attributes===void 0?[]:OW(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?OW(Object.entries(a)):[],droppedAttributesCount:0})}let i;if(t.exit._tag===`Success`)i={code:WW.Unset};else if(Yf(t.exit.cause))i={code:WW.Unset},n.push({key:`effect.fiber.interrupted`,value:{boolValue:!0}});else{let e=rp(t.exit.cause,{includeCauseInStack:!0});i=e.length>0?{code:WW.Error,message:e[0].message}:{code:WW.Unset};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:OW(Object.entries(n.attributes)),droppedAttributesCount:0})}return{traceId:e.traceId.padStart(32,`0`),spanId:e.spanId,parentSpanId:Dr(e.parent)?e.parent.value.spanId:void 0,name:e.name,kind:GW[e.kind],startTimeUnixNano:String(t.startTime),endTimeUnixNano:String(t.endTime),attributes:n,droppedAttributesCount:0,events:r,droppedEventsCount:0,status:i,links:a,droppedLinksCount:0}},WW={Unset:0,Ok:1,Error:2},GW={unspecified:0,internal:1,server:2,client:3,producer:4,consumer:5},KW={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return qW({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 qW({requests:t,annotations:da(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return qW({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 qW({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return Xg(function*(){let n=yield*P_(),r=Vg(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})}),da(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 qW({requests:t,annotations:this.annotations})},toLayer(e){return gm(this.toHandlers(e))},of:i,toLayerHandler(e,t){let n=this;return gm(Xg(function*(){let r=yield*P_(),i=Vg(t)?yield*t:t,a=new Map,o=n.requests.get(e);return a.set(o.key,{handler:i,context:r}),da(a)}))},accessHandler(e){return F_(t=>{let n=this.requests.get(e),{handler:r,context:i}=Sa(t,n.key);return I((e,t)=>{t.rpc=n;let a=r(e,t),o=RR(a)?a.value:a;return Vg(o)?I_(o,i):mN(o,i)})})},annotate(e,t){return qW({requests:this.requests,annotations:ya(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(va(e,t))},annotateMerge(e){return qW({requests:this.requests,annotations:Oa(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(Oa(e,r.annotations)));return qW({requests:t,annotations:this.annotations})}},qW=e=>Object.assign(function(){},KW,{requests:e.requests,annotations:e.annotations}),JW=(...e)=>qW({requests:new Map(e.map(e=>[e._tag,e])),annotations:ga()}),YW=`~effect/rpc/RpcMiddleware`,XW=()=>(e,t)=>{let n=Bt(),r;n!==0&&(Vt(2),r=new globalThis.Error,Vt(n));function i(){}let a=i;return Object.setPrototypeOf(i,Object.getPrototypeOf($i(e))),i.key=e,Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[YW]=YW,a.error=t?.error??ZD,a.requiredForClient=t?.requiredForClient??!1,i},ZW=(e,t)=>gm(Xg(function*(){let n=(yield*P_()).pipe(Aa(Vp)),r=Vg(t)?yield*t:t;return da(new Map([[`${e.key}/Client`,e=>z_(r(e),e=>Oa(n,e))]]))})),QW=`~effect/SynchronizedRef`,$W={...$t,[QW]:QW,toJSON(){return{_id:`SynchronizedRef`,value:this.backing.ref.current}}},eG=e=>{let t=Object.create($W);return t.semaphore=mj(1),t.backing=YF(e),t},tG=e=>R(()=>eG(e)),nG=e=>e.backing.ref.current,rG=e=>R(()=>nG(e)),iG=r(2,(e,t)=>e.semaphore.withPermit(XF(e.backing,t))),aG=r(2,(e,t)=>e.semaphore.withPermit(L(()=>H(t(nG(e)),([t,n])=>(e.backing.ref.current=n,t))))),oG=r(2,(e,t)=>e.semaphore.withPermit(ZF(e.backing,t))),sG=`~effect/schema/VariantSchema`,cG=Symbol.for(`${sG}/cache`),lG=Symbol.for(`${sG}/defaultCache`),uG=e=>v(e,sG),dG=`~effect/schema/VariantSchema/Field`,fG=e=>v(e,dG),pG=r(e=>uG(e[0]),(e,t,n)=>{if(n?.isDefault===!0&&KD(e))return e;let r=n?.isDefault===!0?lG:cG,i=Object.hasOwn(e,r)?e[r]:e[r]=Object.create(null);if(Object.hasOwn(i,t))return i[t];let a={};for(let r of Object.keys(e[sG])){let i=e[sG][r];if(i!==void 0){if(`~effect/schema/VariantSchema`in i)n?.isDefault===!0&&KD(i)?b(a,r,i):b(a,r,pG(i,t));else if(dG in i){if(Object.hasOwn(i.schemas,t)){let e=i.schemas[t];e!==void 0&&b(a,r,e)}}else b(a,r,i)}}let o=q(a);return i[t]=o,o}),mG=e=>e[sG],hG=e=>{function t(e){return function(t,r){return n(t,t=>Ek(e)(t,r))}}function n(t,r){let i=_G(t),a=r(pG(i,e.defaultVariant,{isDefault:!0}).fields);class o extends a{static[sG]=t;static extend(e){let r=super.extend(e);return(e,i)=>KD(e)?n({...t,...e.fields},()=>r(e,i)):n({...t,...e},e=>r(e,i))}}for(let t of e.variants)Object.defineProperty(o,t,{value:pG(i,t).annotate({id:`${a.identifier}.${t}`,title:`${a.identifier}.${t}`})});return o}function i(e){return function(t){let n={};for(let r of e)b(n,r,t);return yG(n)}}function a(t){return function(n){let r={};for(let i of e.variants)t.includes(i)||b(r,i,n);return yG(r)}}function o(t){return bG(t,e.defaultVariant,e.variants)}return{Struct:_G,Field:yG,FieldOnly:i,FieldExcept:a,Class:t,Union:o,fieldEvolve:r(2,(t,n)=>yG(vD((fG(t)?t:yG(Object.fromEntries(e.variants.map(e=>[e,t])))).schemas,n))),extract:r(2,(t,n)=>pG(t,n,{isDefault:n===e.defaultVariant}))}},gG={pipe(){return e(this,arguments)}},_G=e=>{let t=Object.create(gG);return t[sG]=e,t},vG={[dG]:dG,pipe(){return e(this,arguments)}},yG=e=>{let t=Object.create(vG);return t.schemas=e,t},bG=(e,t,n)=>{let r=pO(e.map(e=>KD(e)?e:pG(e,t,{isDefault:!0})));for(let t of n)Object.defineProperty(r,t,{value:pO(e.map(e=>pG(e,t)))});return r},{Class:xG,Field:SG,FieldExcept:CG,FieldOnly:wG,Struct:TG,Union:EG,extract:DG,fieldEvolve:OG}=hG({variants:[`select`,`insert`,`update`,`json`,`jsonCreate`,`jsonUpdate`],defaultVariant:`select`}),kG=mG,AG=e=>SG({select:e,insert:e,update:e}),jG=e=>qD(hO(e)).pipe(vO(dk(YD(e)),uC({decode:e=>e.pipe(Ur(me),E),encode:Vr}))),MG=OG({select:aP(fk),insert:aP(fk),update:aP(fk),json:aP(jG),jsonCreate:aP(jG),jsonUpdate:aP(jG)}),NG=SG({select:JO,insert:JO,update:JO,json:nO,jsonCreate:nO,jsonUpdate:nO}),PG={d:qD(ZD),p:qD(ZD),q:qD(ZD),dp:qD(ZD),dq:qD(ZD),qi:qD(ZD),oth:qD(ZD),k:qD(ZD)},FG=e=>{if(/[^A-Za-z0-9_-]/.test(e))return!1;let t=e.length%4,n=e.charAt(e.length-1);return t===0||(t===2?`AQgw`.includes(n):t===3&&`AEIMQUYcgkosw048`.includes(n))},IG={kid:qD(K),alg:qD(K),use:qD(K),key_ops:qD(lO(K))},LG=K.check(DO(FG,{expected:`a canonical base64url encoded string`})),RG={...IG,kty:XD(`RSA`),n:LG,e:LG},zG={...IG,kty:XD(`EC`),crv:mO([`P-256`,`P-384`,`P-521`]),x:LG,y:LG},BG={...IG,kty:XD(`OKP`),crv:XD(`Ed25519`),x:LG};({...RG,...PG}),{...zG,...PG},{...BG,...PG};var VG=pO([q({...RG,d:LG,p:LG,q:LG,dp:LG,dq:LG,qi:LG,oth:qD(ZD)}),q({...zG,d:LG}),q({...BG,d:LG})]);({...IG});export{hP as $,Ri as $a,Hh as $i,PC as $n,ye as $o,pv as $r,ck as $t,dL as A,bp as Aa,ev as Ai,ID as An,zr as Ao,Jv as Ar,dN as At,vF as B,Xf as Ba,xg as Bi,Mk as Bn,Or as Bo,p_ as Br,Sj as Bt,VR as C,Pp as Ca,L as Ci,RD as Cn,hi as Co,qv as Cr,NM as Ct,eR as D,Sp as Da,w_ as Di,UD as Dn,Gr as Do,Kv as Dr,QM as Dt,aR as E,yp as Ea,v_ as Ei,zD as En,ti as Eo,Xv as Er,BM as Et,OI as F,Hf as Fa,t_ as Fi,AD as Fn,Fr as Fo,av as Fr,eN as Ft,aF as G,yo as Ga,Vh as Gi,AC as Gn,_r as Go,K_ as Gr,pA as Gt,wF as H,Zo as Ha,Yh as Hi,CO as Hn,Ar as Ho,f_ as Hr,uA as Ht,kF as I,ep as Ia,Pg as Ii,DO as In,Er as Io,u_ as Ir,oN as It,bF as J,$i as Ja,Zh as Ji,NC as Jn,Ke as Jo,Zg as Jr,lO as Jt,SF as K,wo as Ka,qh as Ki,LC as Kn,vr as Ko,l_ as Kr,oA as Kt,_F as L,Bf as La,Fg as Li,dO as Ln,Dr as Lo,d_ as Lr,PM as Lt,XI as M,Wf as Ma,z as Mi,IO as Mn,jr as Mo,W_ as Mr,hN as Mt,FI as N,Uf as Na,n_ as Ni,OO as Nn,Mr as No,Hg as Nr,zM as Nt,uL as O,xp as Oa,Kg as Oi,GD as On,Kr as Oo,Hv as Or,$M as Ot,qI as P,$f as Pa,cv as Pi,KD as Pn,kr as Po,o_ as Pr,VM as Pt,_P as Q,Ii as Qa,Jh as Qi,HC as Qn,be as Qo,uv as Qr,UO as Qt,fF as R,zf as Ra,Bg as Ri,JD as Rn,Wr as Ro,X_ as Rr,ZM as Rt,pU as S,Ep as Sa,I as Si,_O as Sn,ui as So,Pv as Sr,J as St,ER as T,gp as Ta,s_ as Ti,LD as Tn,Zr as To,zv as Tr,MM as Tt,TF as U,xo as Ua,Gh as Ui,YD as Un,E as Uo,P_ as Ur,cA as Ut,YP as V,Zf as Va,Sg as Vi,FD as Vn,T as Vo,m_ as Vr,lA as Vt,KP as W,bo as Wa,Kh as Wi,_D as Wn,Hr as Wo,$g as Wr,dA as Wt,jF as X,Da as Xa,Qh as Xi,jT as Xn,pe as Xo,Cv as Xr,ak as Xt,AF as Y,ya as Ya,Uh as Yi,BC as Yn,v as Yo,V as Yr,nO as Yt,qP as Z,Xi as Za,Wh as Zi,MC as Zn,he as Zo,Ug as Zr,ok as Zt,PW as _,kp as _a,bv as _i,q as _n,Ui as _o,Rv as _r,tN as _t,AG as a,xm as aa,wv as ai,XD as an,Ji as ao,Bx as ar,HN as at,DU as b,jp as ba,H_ as bi,wO as bn,pi as bo,Qv as br,WM as bt,tG as c,lm as ca,Yg as ci,zO as cn,Ei as co,Cy as cr,kN as ct,oG as d,Vp as da,Gg as di,pk as dn,Yi as do,by as dr,KN as dt,zh as ea,i_ as ei,lk as en,Wi as eo,RC as er,r as es,qN as et,XW as f,Gp as fa,L_ as fi,hk as fn,ji as fo,vy as fr,NN as ft,IW as g,Op as ga,yv as gi,K as gn,bi as go,Lv as gr,cN as gt,VW as h,Up as ha,mv as hi,kD as hn,Ki as ho,_y as hr,aN as ht,MG as i,dm as ia,Tv as ii,jk as in,Vi as io,W as ir,EN as it,nL as j,pp as ja,tv as ji,LO as jn,Vr as jo,Yv as jr,lN as jt,pL as k,hp as ka,e_ as ki,GO as kn,Ur as ko,Uv as kr,XM as kt,iG as l,Em as la,Y_ as li,dk as ln,Di as lo,Ey as lr,MN as lt,JW as m,Hp as ma,_v as mi,_k as mn,Ci as mo,gy as mr,RN as mt,NG as n,Om as na,Z_ as ni,KO as nn,Ni as no,IC as nr,d as ns,FN as nt,kG as o,Cm as oa,H as oi,mO as on,xi as oo,wy as or,jN as ot,ZW as p,Jp as pa,B_ as pi,oO as pn,Bi as po,yy as pr,VN as pt,yF as q,Co as qa,Xh as qi,FC as qn,Lt as qo,B as qr,Ik as qt,xG as r,_m as ra,Vg as ri,PO as rn,Pi as ro,FT as rr,t as rs,IN as rt,rG as s,wm as sa,g_ as si,uO as sn,Li as so,Ty as sr,PN as st,VG as t,Bh as ta,Xg as ti,kO as tn,Hi as to,VC as tr,i as ts,WN as tt,aG as u,ym as ua,c_ as ui,mk as un,ki as uo,Oy as ur,TN as ut,zU as v,Ip as va,Sv as vi,Ok as vn,Gi as vo,Zv as vr,RM as vt,NR as w,Fp as wa,R as wi,vO as wn,$r as wo,Iv as wr,JM as wt,TU as x,Dp as xa,O_ as xi,pO as xn,di as xo,$v as xr,iN as xt,PU as y,Ap as ya,V_ as yi,SO as yn,Fi as yo,Gv as yr,pN as yt,MF as z,Vf as za,Rg as zi,qD as zn,Rr as zo,Jg as zr,zj as zt};
17
+ `));let s=Si(e.message),c={severityNumber:zW(e.logLevel),severityText:e.logLevel,timeUnixNano:i,observedTimeUnixNano:n,attributes:OW(Object.entries(a)),body:AW(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},zW=e=>{switch(e){case`Trace`:return BW.SEVERITY_NUMBER_TRACE;case`Debug`:return BW.SEVERITY_NUMBER_DEBUG;case`Info`:return BW.SEVERITY_NUMBER_INFO;case`Warn`:return BW.SEVERITY_NUMBER_WARN;case`Error`:return BW.SEVERITY_NUMBER_ERROR;case`Fatal`:return BW.SEVERITY_NUMBER_FATAL;default:return BW.SEVERITY_NUMBER_UNSPECIFIED}},BW={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},VW=f(Cv(function*(e){let t=yield*DW(e.resource),n=yield*jW,r={name:`effect`,version:IU()},i=yield*VU({label:`OtlpTracer`,url:e.url,headers:e.headers,compression:e.compression,exportInterval:e.exportInterval??yo(5),maxBatchSize:e.maxBatchSize??1e3,body(e){let i={resourceSpans:[{resource:t,scopeSpans:[{scope:r,spans:e}]}]};return[n.traces(i),z]},shutdownTimeout:e.shutdownTimeout??yo(3)});function a(e){e.sampled&&i.push(UW(e))}return cs({span(e){return new HW(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})}),mm(ps),wm(BU)),HW=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??=Dr(this.parent)?this.parent.value.traceId:es(32)}get spanId(){return this._spanId??=es(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)}},UW=e=>{let t=e.status,n=e._attributes===void 0?[]:OW(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?OW(Object.entries(a)):[],droppedAttributesCount:0})}let i;if(t.exit._tag===`Success`)i={code:WW.Unset};else if(Yf(t.exit.cause))i={code:WW.Unset},n.push({key:`effect.fiber.interrupted`,value:{boolValue:!0}});else{let e=rp(t.exit.cause,{includeCauseInStack:!0});i=e.length>0?{code:WW.Error,message:e[0].message}:{code:WW.Unset};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:OW(Object.entries(n.attributes)),droppedAttributesCount:0})}return{traceId:e.traceId.padStart(32,`0`),spanId:e.spanId,parentSpanId:Dr(e.parent)?e.parent.value.spanId:void 0,name:e.name,kind:GW[e.kind],startTimeUnixNano:String(t.startTime),endTimeUnixNano:String(t.endTime),attributes:n,droppedAttributesCount:0,events:r,droppedEventsCount:0,status:i,links:a,droppedLinksCount:0}},WW={Unset:0,Ok:1,Error:2},GW={unspecified:0,internal:1,server:2,client:3,producer:4,consumer:5},KW={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return qW({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 qW({requests:t,annotations:da(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return qW({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 qW({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return Xg(function*(){let n=yield*P_(),r=Vg(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})}),da(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 qW({requests:t,annotations:this.annotations})},toLayer(e){return gm(this.toHandlers(e))},of:i,toLayerHandler(e,t){let n=this;return gm(Xg(function*(){let r=yield*P_(),i=Vg(t)?yield*t:t,a=new Map,o=n.requests.get(e);return a.set(o.key,{handler:i,context:r}),da(a)}))},accessHandler(e){return F_(t=>{let n=this.requests.get(e),{handler:r,context:i}=Sa(t,n.key);return I((e,t)=>{t.rpc=n;let a=r(e,t),o=RR(a)?a.value:a;return Vg(o)?I_(o,i):mN(o,i)})})},annotate(e,t){return qW({requests:this.requests,annotations:ya(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(va(e,t))},annotateMerge(e){return qW({requests:this.requests,annotations:Oa(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(Oa(e,r.annotations)));return qW({requests:t,annotations:this.annotations})}},qW=e=>Object.assign(function(){},KW,{requests:e.requests,annotations:e.annotations}),JW=(...e)=>qW({requests:new Map(e.map(e=>[e._tag,e])),annotations:ga()}),YW=`~effect/rpc/RpcMiddleware`,XW=()=>(e,t)=>{let n=Bt(),r;n!==0&&(Vt(2),r=new globalThis.Error,Vt(n));function i(){}let a=i;return Object.setPrototypeOf(i,Object.getPrototypeOf($i(e))),i.key=e,Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[YW]=YW,a.error=t?.error??ZD,a.requiredForClient=t?.requiredForClient??!1,i},ZW=(e,t)=>gm(Xg(function*(){let n=(yield*P_()).pipe(Aa(Vp)),r=Vg(t)?yield*t:t;return da(new Map([[`${e.key}/Client`,e=>z_(r(e),e=>Oa(n,e))]]))})),QW=`~effect/SynchronizedRef`,$W={...$t,[QW]:QW,toJSON(){return{_id:`SynchronizedRef`,value:this.backing.ref.current}}},eG=e=>{let t=Object.create($W);return t.semaphore=mj(1),t.backing=YF(e),t},tG=e=>R(()=>eG(e)),nG=e=>e.backing.ref.current,rG=e=>R(()=>nG(e)),iG=r(2,(e,t)=>e.semaphore.withPermit(XF(e.backing,t))),aG=r(2,(e,t)=>e.semaphore.withPermit(L(()=>H(t(nG(e)),([t,n])=>(e.backing.ref.current=n,t))))),oG=r(2,(e,t)=>e.semaphore.withPermit(ZF(e.backing,t))),sG=`~effect/schema/VariantSchema`,cG=Symbol.for(`${sG}/cache`),lG=Symbol.for(`${sG}/defaultCache`),uG=e=>v(e,sG),dG=`~effect/schema/VariantSchema/Field`,fG=e=>v(e,dG),pG=r(e=>uG(e[0]),(e,t,n)=>{if(n?.isDefault===!0&&KD(e))return e;let r=n?.isDefault===!0?lG:cG,i=Object.hasOwn(e,r)?e[r]:e[r]=Object.create(null);if(Object.hasOwn(i,t))return i[t];let a={};for(let r of Object.keys(e[sG])){let i=e[sG][r];if(i!==void 0){if(`~effect/schema/VariantSchema`in i)n?.isDefault===!0&&KD(i)?b(a,r,i):b(a,r,pG(i,t));else if(dG in i){if(Object.hasOwn(i.schemas,t)){let e=i.schemas[t];e!==void 0&&b(a,r,e)}}else b(a,r,i)}}let o=q(a);return i[t]=o,o}),mG=e=>e[sG],hG=e=>{function t(e){return function(t,r){return n(t,t=>Ek(e)(t,r))}}function n(t,r){let i=_G(t),a=r(pG(i,e.defaultVariant,{isDefault:!0}).fields);class o extends a{static[sG]=t;static extend(e){let r=super.extend(e);return(e,i)=>KD(e)?n({...t,...e.fields},()=>r(e,i)):n({...t,...e},e=>r(e,i))}}for(let t of e.variants)Object.defineProperty(o,t,{value:pG(i,t).annotate({id:`${a.identifier}.${t}`,title:`${a.identifier}.${t}`})});return o}function i(e){return function(t){let n={};for(let r of e)b(n,r,t);return yG(n)}}function a(t){return function(n){let r={};for(let i of e.variants)t.includes(i)||b(r,i,n);return yG(r)}}function o(t){return bG(t,e.defaultVariant,e.variants)}return{Struct:_G,Field:yG,FieldOnly:i,FieldExcept:a,Class:t,Union:o,fieldEvolve:r(2,(t,n)=>yG(vD((fG(t)?t:yG(Object.fromEntries(e.variants.map(e=>[e,t])))).schemas,n))),extract:r(2,(t,n)=>pG(t,n,{isDefault:n===e.defaultVariant}))}},gG={pipe(){return e(this,arguments)}},_G=e=>{let t=Object.create(gG);return t[sG]=e,t},vG={[dG]:dG,pipe(){return e(this,arguments)}},yG=e=>{let t=Object.create(vG);return t.schemas=e,t},bG=(e,t,n)=>{let r=pO(e.map(e=>KD(e)?e:pG(e,t,{isDefault:!0})));for(let t of n)Object.defineProperty(r,t,{value:pO(e.map(e=>pG(e,t)))});return r},{Class:xG,Field:SG,FieldExcept:CG,FieldOnly:wG,Struct:TG,Union:EG,extract:DG,fieldEvolve:OG}=hG({variants:[`select`,`insert`,`update`,`json`,`jsonCreate`,`jsonUpdate`],defaultVariant:`select`}),kG=mG,AG=e=>SG({select:e,insert:e,update:e}),jG=e=>qD(hO(e)).pipe(vO(dk(YD(e)),uC({decode:e=>e.pipe(Ur(me),E),encode:Vr}))),MG=OG({select:aP(fk),insert:aP(fk),update:aP(fk),json:aP(jG),jsonCreate:aP(jG),jsonUpdate:aP(jG)}),NG=SG({select:JO,insert:JO,update:JO,json:nO,jsonCreate:nO,jsonUpdate:nO}),PG={d:qD(ZD),p:qD(ZD),q:qD(ZD),dp:qD(ZD),dq:qD(ZD),qi:qD(ZD),oth:qD(ZD),k:qD(ZD)},FG=e=>{if(/[^A-Za-z0-9_-]/.test(e))return!1;let t=e.length%4,n=e.charAt(e.length-1);return t===0||(t===2?`AQgw`.includes(n):t===3&&`AEIMQUYcgkosw048`.includes(n))},IG={kid:qD(K),alg:qD(K),use:qD(K),key_ops:qD(lO(K))},LG=K.check(DO(FG,{expected:`a canonical base64url encoded string`})),RG={...IG,kty:XD(`RSA`),n:LG,e:LG},zG={...IG,kty:XD(`EC`),crv:mO([`P-256`,`P-384`,`P-521`]),x:LG,y:LG},BG={...IG,kty:XD(`OKP`),crv:XD(`Ed25519`),x:LG};({...RG,...PG}),{...zG,...PG},{...BG,...PG};var VG=pO([q({...RG,d:LG,p:LG,q:LG,dp:LG,dq:LG,qi:LG,oth:qD(ZD)}),q({...zG,d:LG}),q({...BG,d:LG})]);({...IG});export{hP as $,Ri as $a,Hh as $i,PC as $n,s as $o,pv as $r,ck as $t,dL as A,bp as Aa,ev as Ai,ID as An,zr as Ao,Jv as Ar,dN as At,vF as B,Xf as Ba,xg as Bi,Mk as Bn,Or as Bo,p_ as Br,Sj as Bt,VR as C,Pp as Ca,L as Ci,RD as Cn,hi as Co,qv as Cr,NM as Ct,eR as D,Sp as Da,w_ as Di,UD as Dn,Gr as Do,Kv as Dr,QM as Dt,aR as E,yp as Ea,v_ as Ei,zD as En,ti as Eo,Xv as Er,BM as Et,OI as F,Hf as Fa,t_ as Fi,AD as Fn,Fr as Fo,av as Fr,eN as Ft,aF as G,yo as Ga,Vh as Gi,AC as Gn,_r as Go,K_ as Gr,pA as Gt,wF as H,Zo as Ha,Yh as Hi,CO as Hn,Ar as Ho,f_ as Hr,uA as Ht,kF as I,ep as Ia,Pg as Ii,DO as In,Er as Io,u_ as Ir,oN as It,bF as J,$i as Ja,Zh as Ji,NC as Jn,Ke as Jo,Zg as Jr,lO as Jt,SF as K,wo as Ka,qh as Ki,LC as Kn,vr as Ko,l_ as Kr,oA as Kt,_F as L,Bf as La,Fg as Li,dO as Ln,Dr as Lo,d_ as Lr,PM as Lt,XI as M,Wf as Ma,z as Mi,IO as Mn,jr as Mo,W_ as Mr,hN as Mt,FI as N,Uf as Na,n_ as Ni,OO as Nn,Mr as No,Hg as Nr,zM as Nt,uL as O,xp as Oa,Kg as Oi,GD as On,Kr as Oo,Hv as Or,$M as Ot,qI as P,$f as Pa,cv as Pi,KD as Pn,kr as Po,o_ as Pr,VM as Pt,_P as Q,Ii as Qa,Jh as Qi,HC as Qn,ye as Qo,uv as Qr,UO as Qt,fF as R,zf as Ra,Bg as Ri,JD as Rn,Wr as Ro,X_ as Rr,ZM as Rt,pU as S,Ep as Sa,I as Si,_O as Sn,ui as So,Pv as Sr,J as St,ER as T,gp as Ta,s_ as Ti,LD as Tn,Zr as To,zv as Tr,MM as Tt,TF as U,xo as Ua,Gh as Ui,YD as Un,E as Uo,P_ as Ur,cA as Ut,YP as V,Zf as Va,Sg as Vi,FD as Vn,T as Vo,m_ as Vr,lA as Vt,KP as W,bo as Wa,Kh as Wi,_D as Wn,Hr as Wo,$g as Wr,dA as Wt,jF as X,Da as Xa,Qh as Xi,jT as Xn,pe as Xo,Cv as Xr,ak as Xt,AF as Y,ya as Ya,Uh as Yi,BC as Yn,v as Yo,V as Yr,nO as Yt,qP as Z,Xi as Za,Wh as Zi,MC as Zn,he as Zo,Ug as Zr,ok as Zt,PW as _,kp as _a,bv as _i,q as _n,Ui as _o,Rv as _r,tN as _t,AG as a,xm as aa,wv as ai,XD as an,Ji as ao,Bx as ar,t as as,HN as at,DU as b,jp as ba,H_ as bi,wO as bn,pi as bo,Qv as br,WM as bt,tG as c,lm as ca,Yg as ci,zO as cn,Ei as co,Cy as cr,kN as ct,oG as d,Vp as da,Gg as di,pk as dn,Yi as do,by as dr,KN as dt,zh as ea,i_ as ei,lk as en,Wi as eo,RC as er,c as es,qN as et,XW as f,Gp as fa,L_ as fi,hk as fn,ji as fo,vy as fr,NN as ft,IW as g,Op as ga,yv as gi,K as gn,bi as go,Lv as gr,cN as gt,VW as h,Up as ha,mv as hi,kD as hn,Ki as ho,_y as hr,aN as ht,MG as i,dm as ia,Tv as ii,jk as in,Vi as io,W as ir,d as is,EN as it,nL as j,pp as ja,tv as ji,LO as jn,Vr as jo,Yv as jr,lN as jt,pL as k,hp as ka,e_ as ki,GO as kn,Ur as ko,Uv as kr,XM as kt,iG as l,Em as la,Y_ as li,dk as ln,Di as lo,Ey as lr,MN as lt,JW as m,Hp as ma,_v as mi,_k as mn,Ci as mo,gy as mr,RN as mt,NG as n,Om as na,Z_ as ni,KO as nn,Ni as no,IC as nr,r as ns,FN as nt,kG as o,Cm as oa,H as oi,mO as on,xi as oo,wy as or,jN as ot,ZW as p,Jp as pa,B_ as pi,oO as pn,Bi as po,yy as pr,VN as pt,yF as q,Co as qa,Xh as qi,FC as qn,Lt as qo,B as qr,Ik as qt,xG as r,_m as ra,Vg as ri,PO as rn,Pi as ro,FT as rr,i as rs,IN as rt,rG as s,wm as sa,g_ as si,uO as sn,Li as so,Ty as sr,PN as st,VG as t,Bh as ta,Xg as ti,kO as tn,Hi as to,VC as tr,l as ts,WN as tt,aG as u,ym as ua,c_ as ui,mk as un,ki as uo,Oy as ur,TN as ut,zU as v,Ip as va,Sv as vi,Ok as vn,Gi as vo,Zv as vr,RM as vt,NR as w,Fp as wa,R as wi,vO as wn,$r as wo,Iv as wr,JM as wt,TU as x,Dp as xa,O_ as xi,pO as xn,di as xo,$v as xr,iN as xt,PU as y,Ap as ya,V_ as yi,SO as yn,Fi as yo,Gv as yr,pN as yt,MF as z,Vf as za,Rg as zi,qD as zn,Rr as zo,Jg as zr,zj as zt};