@systemfsoftware/omp-agent-discipline 1.2.0 → 1.3.0
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.
- package/dist/dist-DIH94u3_.js +16 -0
- package/dist/{helpers-CFlfJJ3L.js → helpers-BDT6qmPQ.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{no-skill-delegation.executor-iMV67QsE.js → no-skill-delegation.executor-DSGbU60f.js} +1 -1
- package/dist/{runtime-BtPJWHh7.js → runtime-Dydy4g09.js} +1 -1
- package/package.json +5 -4
- package/skills/task-decomposition/SKILL.md +198 -0
- package/skills/task-decomposition/references/dispatch-contract.md +53 -0
- package/skills/task-decomposition/references/research-grounding.md +77 -0
- package/skills/task-decomposition/references/sizing-gate.md +38 -0
- package/dist/dist-h-6akqyn.js +0 -16
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{$c as e,$o as t,$s as n,Ao as r,As as i,Bc as a,Bs as o,Cc as s,Cr as c,Dc as l,Dn as u,Do as d,Ds as f,Ec as p,Es as m,Fc as h,Fi as g,Fo as ee,Fs as _,Gs as te,Hi as ne,Hs as re,Ic as ie,Io as ae,Is as v,Jc as oe,Ji as se,Jr as ce,Js as le,Ko as ue,Ks as y,Lc as de,Lr as fe,Ls as pe,Mi as me,Nc as he,Ni as ge,Nr as _e,Ns as ve,Oo as ye,Os as be,Pi as xe,Pr as Se,Ps as Ce,Qi as we,Qo as Te,Qs as b,Rc as Ee,Sc as De,So as Oe,Ss as ke,Tc as Ae,To as je,Tr as Me,Ts as Ne,Ui as Pe,Uo as Fe,Us as Ie,Vi as Le,Vo as Re,Vs as ze,Wi as Be,Wo as Ve,Ws as He,Xc as Ue,Xn as We,Xs as Ge,Yc as Ke,Yi as qe,Ys as Je,Zi as Ye,Zo as Xe,_l as x,aa as Ze,al as Qe,as as $e,b as et,bo as tt,bs as nt,ci as rt,cl as it,cr as at,ct as ot,dl as st,dt as ct,ea as lt,el as ut,fl as dt,fs as ft,ft as pt,gl as mt,go as ht,il as gt,in as _t,jc as vt,ji as yt,js as bt,k as xt,ko as St,kr as Ct,ks as wt,li as Tt,ll as Et,nl as Dt,no as Ot,oc as kt,ol as At,pl as jt,pt as Mt,qc as Nt,qi as Pt,qo as Ft,qs as It,ra as Lt,rl as Rt,rt as zt,ta as Bt,tl as Vt,ul as Ht,us as Ut,ut as Wt,vl as S,vn as Gt,vo as Kt,w as qt,wr as Jt,ws as Yt,xo as Xt,xs as Zt,yl as C,yo as Qt,ys as $t,zc as en,zo as tn,zs as w}from"./core-CwsVf2Ey.js";import{$ as nn,$t as rn,A as an,At as on,C as sn,Cn as cn,Ct as ln,D as un,Dn as dn,Dt as fn,E as pn,En as mn,Et as hn,F as gn,Ft as _n,G as vn,Gt as yn,I as bn,It as xn,J as Sn,K as Cn,L as wn,M as Tn,Mt as En,N as Dn,Nt as On,O as kn,Ot as T,P as E,Pt as An,Qt as jn,R as Mn,S as Nn,St as Pn,T as Fn,Tn as In,Tt as Ln,U as Rn,V as zn,W as Bn,X as Vn,Y as Hn,Z as Un,Zt as Wn,_ as Gn,_n as Kn,_t as qn,a as Jn,an as Yn,at as Xn,b as D,bn as Zn,bt as Qn,cn as $n,ct as er,d as tr,dn as nr,en as rr,f as ir,fn as ar,ft as or,g as O,gn as sr,gt as k,h as cr,hn as lr,ht as ur,i as dr,in as fr,it as pr,j as mr,jt as hr,k as gr,kt as _r,l as vr,ln as yr,lt as br,m as xr,mn as Sr,mt as Cr,n as A,nt as j,o as wr,on as Tr,ot as Er,p as Dr,pn as Or,pt as kr,q as Ar,r as jr,rn as Mr,rt as Nr,s as Pr,sn as Fr,tn as Ir,tt as M,u as Lr,ut as Rr,v as zr,vn as Br,vt as Vr,w as Hr,wn as Ur,wt as Wr,x as Gr,xn as Kr,xt as qr,y as Jr,yn as Yr,yt as Xr,z as Zr}from"./Effect-BcYkmFCx.js";import{a as Qr,c as $r,d as ei,f as ti,i as ni,l as ri,n as ii,o as ai,p as oi,r as si,s as ci,u as li}from"./Cause-CTmrUQgG.js";import{a as ui,c as di,d as fi,f as pi,h as mi,i as hi,l as gi,m as _i,n as vi,p as yi,r as bi,s as xi,u as Si}from"./Exit-Dq5mS6lc.js";import Ci from"node:os";const wi=Tt,Ti=e=>t=>{let n=t===void 0?Object.create(kt):wi(t);return n._tag=e,n},Ei=rt,Di=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return{BaseEffectError:class extends et{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(Object.assign(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}.BaseEffectError}(),Oi=e=>{let t={BaseEffectError:class extends Di{_tag=e}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError},ki=Symbol.for(`effect/DateTime`),Ai=Symbol.for(`effect/DateTime/TimeZone`),ji={[ki]:ki,pipe(){return De(this,arguments)},[s](){return this.toString()},toJSON(){return ca(this).toJSON()}},Mi={...ji,_tag:`Utc`,[a](){return h(this,Ee(this.epochMillis))},[he](e){return Ri(e)&&e._tag===`Utc`&&this.epochMillis===e.epochMillis},toString(){return`DateTime.Utc(${ca(this).toJSON()})`}},Ni={...ji,_tag:`Zoned`,[a](){return C(Ee(this.epochMillis),ie(de(this.zone)),h(this))},[he](e){return Ri(e)&&e._tag===`Zoned`&&this.epochMillis===e.epochMillis&&vt(this.zone,e.zone)},toString(){return`DateTime.Zoned(${Sa(this)})`}},Pi={[Ai]:Ai,[s](){return this.toString()}},Fi={...Pi,_tag:`Named`,[a](){return h(this,en(`Named:${this.id}`))},[he](e){return zi(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},Ii={...Pi,_tag:`Offset`,[a](){return h(this,en(`Offset:${this.offset}`))},[he](e){return zi(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${da(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},Li=(e,t,n)=>{let r=Object.create(Ni);return r.epochMillis=e,r.zone=t,Object.defineProperty(r,"partsUtc",{value:n,enumerable:!1,writable:!0}),Object.defineProperty(r,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(r,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),r},Ri=e=>Nt(e,ki),zi=e=>Nt(e,Ai),Bi=e=>zi(e)&&e._tag===`Offset`,Vi=e=>zi(e)&&e._tag===`Named`,Hi=e=>e._tag===`Utc`,Ui=e=>e._tag===`Zoned`,Wi=jt((e,t)=>e.epochMillis===t.epochMillis),Gi=e=>{let t=Object.create(Mi);return t.epochMillis=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},Ki=e=>{let t=e.getTime();if(Number.isNaN(t))throw new ii(`Invalid date`);return Gi(t)},qi=e=>{if(Ri(e))return e;if(e instanceof Date)return Ki(e);if(typeof e==`object`){let t=new Date(0);return ma(t,e),Ki(t)}else if(typeof e==`string`&&!Ji(e))return Ki(new Date(e+`Z`));return Ki(new Date(e))},Ji=e=>/Z|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),Yi=(e,t)=>{if(t?.timeZone===void 0&&Ri(e)&&Ui(e))return e;let n=qi(e);if(n.epochMillis<-86399999568e5||n.epochMillis>86399999496e5)throw RangeError(`Epoch millis out of range: ${n.epochMillis}`);let r;if(t?.timeZone===void 0){let e=new Date(n.epochMillis).getTimezoneOffset()*-60*1e3;r=ra(e)}else if(zi(t?.timeZone))r=t.timeZone;else if(typeof t?.timeZone==`number`)r=ra(t.timeZone);else{let e=oa(t.timeZone);if(wt(e))throw new ii(`Invalid time zone: ${t.timeZone}`);r=e.value}return t?.adjustForTimeZone===!0?ga(n.epochMillis,r,t?.disambiguation??`compatible`):Li(n.epochMillis,r,n.partsUtc)},Xi=ve(Yi),Zi=/^(.{17,35})\[(.+)\]$/,Qi=e=>{let t=Zi.exec(e);if(t===null){let t=va(e);return t===null?v():Xi(e,{timeZone:t})}let[,n,r]=t;return Xi(n,{timeZone:r})},$i=st(`effect/DateTime/validZoneCache`,()=>new Map),ea={day:`numeric`,month:`numeric`,year:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},ta=e=>{let t=e.resolvedOptions().timeZone;if($i.has(t))return $i.get(t);let n=Object.create(Fi);return n.id=t,n.format=e,$i.set(t,n),n},na=e=>{if($i.has(e))return $i.get(e);try{return ta(new Intl.DateTimeFormat(`en-US`,{...ea,timeZone:e}))}catch{throw new ii(`Invalid time zone: ${e}`)}},ra=e=>{let t=Object.create(Ii);return t.offset=e,t},ia=ve(na),aa=/^(?:GMT|[+-])/,oa=e=>{if(aa.test(e)){let t=va(e);return t===null?v():w(ra(t))}return ia(e)},sa=e=>e._tag===`Offset`?da(e.offset):e.id,ca=e=>new Date(e.epochMillis),la=e=>{if(e._tag===`Utc`)return new Date(e.epochMillis);if(e.zone._tag===`Offset`)return new Date(e.epochMillis+e.zone.offset);if(e.adjustedEpochMillis!==void 0)return new Date(e.adjustedEpochMillis);let t=e.zone.format.formatToParts(e.epochMillis).filter(e=>e.type!==`literal`),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMillis=n.getTime(),n},ua=e=>la(e).getTime()-pa(e),da=e=>{let t=Math.abs(e),n=Math.floor(t/(3600*1e3)),r=Math.round(t%(3600*1e3)/(60*1e3));return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},fa=e=>da(ua(e)),pa=e=>e.epochMillis,ma=(e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hours!==void 0&&e.setUTCHours(t.hours),t.minutes!==void 0&&e.setUTCMinutes(t.minutes),t.seconds!==void 0&&e.setUTCSeconds(t.seconds),t.millis!==void 0&&e.setUTCMilliseconds(t.millis)},ha=1440*60*1e3,ga=(e,t,n)=>{if(t._tag===`Offset`)return Li(e-t.offset,t);let r=ya(e-ha,e,t),i=ya(e+ha,e,t);if(r===i)return Li(e-r,t);let a=r<i,o=r-i;if(a){if(ya(e-i,e,t)===i)return Li(e-i,t);let a=Li(e-r,t);if(e!==la(a).getTime())switch(n){case`reject`:{let n=new Date(e).toISOString();throw RangeError(`Gap time: ${n} does not exist in time zone ${t.id}`)}case`earlier`:return Li(e-i,t);case`compatible`:case`later`:return a}return a}if(ya(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||ya(e-r+o,e+o,t)===r)return Li(e-r,t);if(n===`reject`){let n=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${n} occurs twice in time zone ${t.id}`)}}return Li(e-i,t)},_a=/([+-])(\d{2}):(\d{2})$/,va=e=>{let t=_a.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},ya=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=va(r);return i===null?ua(Li(t,n)):i},ba=e=>ca(e).toISOString(),xa=e=>{let t=la(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${fa(e)}`},Sa=e=>e.zone._tag===`Offset`?xa(e):`${xa(e)}[${e.zone.id}]`,Ca=e=>e.toUpperCase(),wa=e=>e.toLowerCase(),Ta=e=>e.length===0?e:Ca(e[0])+e.slice(1),Ea=e=>e.length===0?e:wa(e[0])+e.slice(1),Da=e=>e.length>0,Oa=(e,t)=>{switch(t._tag){case`StringKeyword`:case`TemplateLiteral`:return Object.keys(e);case`SymbolKeyword`:return Object.getOwnPropertySymbols(e);case`Refinement`:return Oa(e,t.from)}},ka=e=>{let t=!1,n;return()=>t?n:(n=e(),t=!0,n)},Aa=e=>Array.isArray(e),ja=e=>!Array.isArray(e),Ma=e=>`[${p(e)}]`,Na=e=>Aa(e)?e.map(Ma).join(``):Ma(e),Pa=(e,n,r,i)=>{let a=e;return r&&t(r)&&(a+=`\nat path: ${Na(r)}`),n!==void 0&&(a+=`\ndetails: ${n}`),i&&(a+=`\nschema (${i._tag}): ${i}`),a},Fa=e=>Pa(`Invalid Argument`,e),Ia=(e,t,n)=>Pa(`Unsupported schema or overlapping types`,`cannot extend ${e} with ${t}`,n),La=e=>Pa(`Unsupported key schema`,void 0,void 0,e),Ra=e=>Pa(`Unsupported literal`,`literal value: ${l(e)}`),za=e=>Pa(`Duplicate index signature`,`${e} index signature`),Ba=Pa(`Unsupported index signature parameter`,"An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),Va=Pa(`Invalid element`,`A required element cannot follow an optional element. ts(1257)`),Ha=e=>Pa(`Duplicate property signature transformation`,`Duplicate key ${l(e)}`),Ua=e=>Pa(`Duplicate property signature`,`Duplicate key ${l(e)}`),Wa=Symbol.for(`effect/SchemaId/DateFromSelf`),Ga=Symbol.for(`effect/SchemaId/GreaterThan`),Ka=Symbol.for(`effect/SchemaId/GreaterThanOrEqualTo`),qa=Symbol.for(`effect/SchemaId/LessThan`),Ja=Symbol.for(`effect/SchemaId/LessThanOrEqualTo`),Ya=Symbol.for(`effect/SchemaId/Int`),Xa=Symbol.for(`effect/SchemaId/NonNaN`),Za=Symbol.for(`effect/SchemaId/Finite`),Qa=Symbol.for(`effect/SchemaId/JsonNumber`),$a=Symbol.for(`effect/SchemaId/Between`),eo=Symbol.for(`effect/SchemaId/GreaterThanOrEqualToBigint`),to=Symbol.for(`effect/SchemaId/BetweenBigint`),no=Symbol.for(`effect/SchemaId/MinLength`),ro=Symbol.for(`effect/SchemaId/Length`),io=Symbol.for(`effect/SchemaId/MinItems`),ao=Symbol.for(`effect/annotation/TypeConstructor`),oo=Symbol.for(`effect/annotation/Brand`),so=Symbol.for(`effect/annotation/SchemaId`),co=Symbol.for(`effect/annotation/Message`),lo=Symbol.for(`effect/annotation/MissingMessage`),uo=Symbol.for(`effect/annotation/Identifier`),fo=Symbol.for(`effect/annotation/Title`),po=Symbol.for(`effect/annotation/AutoTitle`),mo=Symbol.for(`effect/annotation/Description`),ho=Symbol.for(`effect/annotation/Examples`),go=Symbol.for(`effect/annotation/Default`),_o=Symbol.for(`effect/annotation/JSONSchema`),vo=Symbol.for(`effect/annotation/Arbitrary`),yo=Symbol.for(`effect/annotation/Pretty`),bo=Symbol.for(`effect/annotation/Equivalence`),xo=Symbol.for(`effect/annotation/Documentation`),So=Symbol.for(`effect/annotation/Concurrency`),Co=Symbol.for(`effect/annotation/Batching`),wo=Symbol.for(`effect/annotation/ParseIssueTitle`),To=Symbol.for(`effect/annotation/ParseOptions`),Eo=Symbol.for(`effect/annotation/DecodingFallback`),Do=Symbol.for(`effect/annotation/Surrogate`),Oo=Symbol.for(`effect/annotation/StableFilter`),N=x(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?w(e.annotations[t]):v()),ko=N(oo),Ao=N(co),jo=N(lo),Mo=N(fo),No=N(po),Po=N(uo),Fo=N(mo),Io=N(So),Lo=N(Co),Ro=N(wo),zo=N(To),Bo=N(Eo),Vo=N(Do),Ho=N(Oo),Uo=e=>$t(Ho(e),e=>e===!0),Wo=Symbol.for(`effect/annotation/JSONIdentifier`),Go=N(Wo),Ko=e=>pe(Go(e),()=>Po(e));var qo=class{typeParameters;decodeUnknown;encodeUnknown;annotations;_tag=`Declaration`;constructor(e,t,n,r={}){this.typeParameters=e,this.decodeUnknown=t,this.encodeUnknown=n,this.annotations=r}toString(){return Ne(oc(this),()=>`<declaration schema>`)}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map(e=>e.toJSON()),annotations:I(this.annotations)}}};const Jo=e=>t=>t._tag===e;var Yo=class{literal;annotations;_tag=`Literal`;constructor(e,t={}){this.literal=e,this.annotations=t}toString(){return Ne(oc(this),()=>l(this.literal))}toJSON(){return{_tag:this._tag,literal:oe(this.literal)?String(this.literal):this.literal,annotations:I(this.annotations)}}};const Xo=Jo(`Literal`);var Zo=class{symbol;annotations;_tag=`UniqueSymbol`;constructor(e,t={}){this.symbol=e,this.annotations=t}toString(){return Ne(oc(this),()=>l(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:I(this.annotations)}}};const Qo=new class{annotations;_tag=`UndefinedKeyword`;constructor(e={}){this.annotations=e}toString(){return rc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[fo]:`undefined`}),$o=new class{annotations;_tag=`NeverKeyword`;constructor(e={}){this.annotations=e}toString(){return rc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[fo]:`never`}),es=new class{annotations;_tag=`UnknownKeyword`;constructor(e={}){this.annotations=e}toString(){return rc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[fo]:`unknown`}),ts=new class{annotations;_tag=`AnyKeyword`;constructor(e={}){this.annotations=e}toString(){return rc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[fo]:`any`}),ns=new class{annotations;_tag=`StringKeyword`;constructor(e={}){this.annotations=e}toString(){return rc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[fo]:`string`,[mo]:`a string`}),rs=Jo(`StringKeyword`),is=new class{annotations;_tag=`NumberKeyword`;constructor(e={}){this.annotations=e}toString(){return rc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[fo]:`number`,[mo]:`a number`}),as=Jo(`NumberKeyword`),os=new class{annotations;_tag=`BooleanKeyword`;constructor(e={}){this.annotations=e}toString(){return rc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[fo]:`boolean`,[mo]:`a boolean`}),ss=Jo(`BooleanKeyword`),cs=new class{annotations;_tag=`BigIntKeyword`;constructor(e={}){this.annotations=e}toString(){return rc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[fo]:`bigint`,[mo]:`a bigint`}),ls=new class{annotations;_tag=`SymbolKeyword`;constructor(e={}){this.annotations=e}toString(){return rc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[fo]:`symbol`,[mo]:`a symbol`}),us=Jo(`SymbolKeyword`);var ds=class{type;annotations;constructor(e,t={}){this.type=e,this.annotations=t}toJSON(){return{type:this.type.toJSON(),annotations:I(this.annotations)}}toString(){return String(this.type)}},fs=class extends ds{isOptional;constructor(e,t,n={}){super(e,n),this.isOptional=t}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:I(this.annotations)}}toString(){return String(this.type)+(this.isOptional?`?`:``)}};const ps=e=>e.map(e=>e.type);var ms=class{elements;rest;isReadonly;annotations;_tag=`TupleType`;constructor(e,t,n,r={}){this.elements=e,this.rest=t,this.isReadonly=n,this.annotations=r;let i=!1,a=!1;for(let t of e)if(t.isOptional)i=!0;else if(i){a=!0;break}if(a||i&&t.length>1)throw Error(Va)}toString(){return Ne(oc(this),()=>hs(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map(e=>e.toJSON()),rest:this.rest.map(e=>e.toJSON()),isReadonly:this.isReadonly,annotations:I(this.annotations)}}};const hs=e=>{let t=e.elements.map(String).join(`, `);return $e(e.rest,{onEmpty:()=>`readonly [${t}]`,onNonEmpty:(n,r)=>{let i=String(n),a=i.includes(` | `)?`(${i})`:i;if(r.length>0){let n=r.map(String).join(`, `);return e.elements.length>0?`readonly [${t}, ...${a}[], ${n}]`:`readonly [...${a}[], ${n}]`}else if(e.elements.length>0)return`readonly [${t}, ...${a}[]]`;else return`ReadonlyArray<${i}>`}})};var P=class extends fs{name;isReadonly;constructor(e,t,n,r,i){super(t,n,i),this.name=e,this.isReadonly=r}toString(){return(this.isReadonly?`readonly `:``)+String(this.name)+(this.isOptional?`?`:``)+`: `+this.type}toJSON(){return{name:String(this.name),type:this.type.toJSON(),isOptional:this.isOptional,isReadonly:this.isReadonly,annotations:I(this.annotations)}}};const gs=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return!0;case`Refinement`:return gs(e.from)}return!1};var _s=class{type;isReadonly;parameter;constructor(e,t,n){if(this.type=t,this.isReadonly=n,gs(e))this.parameter=e;else throw Error(Ba)}toString(){return(this.isReadonly?`readonly `:``)+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}},vs=class{annotations;_tag=`TypeLiteral`;propertySignatures;indexSignatures;constructor(e,t,n={}){this.annotations=n;let r={};for(let t=0;t<e.length;t++){let n=e[t].name;if(Object.prototype.hasOwnProperty.call(r,n))throw Error(Ua(n));r[n]=null}let i={string:!1,symbol:!1};for(let e=0;e<t.length;e++){let n=nc(t[e].parameter);if(rs(n)){if(i.string)throw Error(za(`string`));i.string=!0}else if(us(n)){if(i.symbol)throw Error(za(`symbol`));i.symbol=!0}}this.propertySignatures=e,this.indexSignatures=t}toString(){return Ne(oc(this),()=>bs(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map(e=>e.toJSON()),indexSignatures:this.indexSignatures.map(e=>e.toJSON()),annotations:I(this.annotations)}}};const ys=e=>e.map(String).join(`; `),bs=e=>{if(e.propertySignatures.length>0){let t=e.propertySignatures.map(String).join(`; `);return e.indexSignatures.length>0?`{ ${t}; ${ys(e.indexSignatures)} }`:`{ ${t} }`}else if(e.indexSignatures.length>0)return`{ ${ys(e.indexSignatures)} }`;else return`{}`},xs=Jo(`TypeLiteral`),Ss=Ut(dn(In,e=>{switch(e._tag){case`AnyKeyword`:return 0;case`UnknownKeyword`:return 1;case`ObjectKeyword`:return 2;case`StringKeyword`:case`NumberKeyword`:case`BooleanKeyword`:case`BigIntKeyword`:case`SymbolKeyword`:return 3}return 4})),Cs={string:`StringKeyword`,number:`NumberKeyword`,boolean:`BooleanKeyword`,bigint:`BigIntKeyword`},ws=e=>Ve(e,e=>ks(e)?ws(e.types):[e]),Ts=e=>{let t=Ss(e),n=[],r={},i=[];for(let e of t)switch(e._tag){case`NeverKeyword`:break;case`AnyKeyword`:return[ts];case`UnknownKeyword`:return[es];case`ObjectKeyword`:case`UndefinedKeyword`:case`VoidKeyword`:case`StringKeyword`:case`NumberKeyword`:case`BooleanKeyword`:case`BigIntKeyword`:case`SymbolKeyword`:r[e._tag]||(r[e._tag]=e,n.push(e));break;case`Literal`:{let t=typeof e.literal;switch(t){case`string`:case`number`:case`bigint`:case`boolean`:!r[Cs[t]]&&!i.includes(e.literal)&&(i.push(e.literal),n.push(e));break;case`object`:i.includes(e.literal)||(i.push(e.literal),n.push(e));break}break}case`UniqueSymbol`:!r.SymbolKeyword&&!i.includes(e.symbol)&&(i.push(e.symbol),n.push(e));break;case`TupleType`:r.ObjectKeyword||n.push(e);break;case`TypeLiteral`:e.propertySignatures.length===0&&e.indexSignatures.length===0?r[`{}`]||(r[`{}`]=e,n.push(e)):r.ObjectKeyword||n.push(e);break;default:n.push(e)}return n};var Es=class e{types;annotations;static make=(t,n)=>Os(t)?new e(t,n):t.length===1?t[0]:$o;static unify=(t,n)=>e.make(Ts(ws(t)),n);_tag=`Union`;constructor(e,t={}){this.types=e,this.annotations=t}toString(){return Ne(oc(this),()=>this.types.map(String).join(` | `))}toJSON(){return{_tag:this._tag,types:this.types.map(e=>e.toJSON()),annotations:I(this.annotations)}}};const Ds=(e,t)=>e.map(t),Os=e=>e.length>1,ks=Jo(`Union`),As=st(Symbol.for(`effect/Schema/AST/toJSONMemoMap`),()=>new WeakMap);var js=class{f;annotations;_tag=`Suspend`;constructor(e,t={}){this.f=e,this.annotations=t,this.f=ka(e)}toString(){return oc(this).pipe(pe(()=>Zt(ve(this.f)(),e=>oc(e))),Ne(()=>`<suspended schema>`))}toJSON(){let e=this.f(),t=As.get(e);return t||(As.set(e,{_tag:this._tag}),t={_tag:this._tag,ast:e.toJSON(),annotations:I(this.annotations)},As.set(e,t),t)}},Ms=class{from;filter;annotations;_tag=`Refinement`;constructor(e,t,n={}){this.from=e,this.filter=t,this.annotations=n}toString(){return Po(this).pipe(Ne(()=>_(ac(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:e=>Ns(this.from)?String(this.from)+` & `+e:e})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:I(this.annotations)}}};const Ns=Jo(`Refinement`),Ps={};var Fs=class{from;to;transformation;annotations;_tag=`Transformation`;constructor(e,t,n,r={}){this.from=e,this.to=t,this.transformation=n,this.annotations=r}toString(){return Ne(oc(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:I(this.annotations)}}};const Is=Jo(`Transformation`);var Ls=class{decode;encode;_tag=`FinalTransformation`;constructor(e,t){this.decode=e,this.encode=t}};const Rs=e=>t=>t._tag===e,zs=new class{_tag=`ComposeTransformation`};var Bs=class{from;to;decode;encode;constructor(e,t,n,r){this.from=e,this.to=t,this.decode=n,this.encode=r}},Vs=class{propertySignatureTransformations;_tag=`TypeLiteralTransformation`;constructor(e){this.propertySignatureTransformations=e;let t={},n={};for(let r of e){let e=r.from;if(t[e])throw Error(Ha(e));t[e]=!0;let i=r.to;if(n[i])throw Error(Ha(i));n[i]=!0}}};const Hs=Rs(`TypeLiteralTransformation`),Us=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={...e.annotations};delete r[uo];let i={...r,...t},a=Vo(e);return bt(a)&&(i[Do]=Us(a.value,t)),n.annotations.value=i,Object.create(Object.getPrototypeOf(e),n)},Ws=(e,t)=>{switch(e._tag){case`Literal`:return Ur(String(e.literal));case`StringKeyword`:return`[\\s\\S]*?`;case`NumberKeyword`:return`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;case`TemplateLiteral`:return Ks(e,t,!1);case`Union`:return e.types.map(e=>Ws(e,t)).join(`|`)}},Gs=(e,t,n,r)=>{if(ks(e)){if(n&&!r)return`(?:${t})`}else if(!n||!r)return t;return`(${t})`},Ks=(e,t,n)=>{let r=``;if(e.head!==``){let i=Ur(e.head);r+=t&&n?`(${i})`:i}for(let i of e.spans){let e=Ws(i.type,t);if(r+=Gs(i.type,e,t,n),i.literal!==``){let e=Ur(i.literal);r+=t&&n?`(${e})`:e}}return r},qs=e=>RegExp(`^${Ks(e,!1,!0)}$`),Js=(e,t)=>{let n=[],r=[],i=e=>{switch(e._tag){case`NeverKeyword`:break;case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:case`Refinement`:r.push(new _s(e,t,!0));break;case`Literal`:if(Qe(e.literal)||Vt(e.literal))n.push(new P(e.literal,t,!1,!0));else throw Error(Ra(e.literal));break;case`Enums`:for(let[r,i]of e.enums)n.push(new P(i,t,!1,!0));break;case`UniqueSymbol`:n.push(new P(e.symbol,t,!1,!0));break;case`Union`:e.types.forEach(i);break;default:throw Error(La(e))}};return i(e),{propertySignatures:n,indexSignatures:r}},Ys=e=>t=>{let n;for(let r of e)Object.prototype.hasOwnProperty.call(t.annotations,r)&&(n===void 0&&(n={}),n[r]=t.annotations[r]);return n},Xs=e=>t=>{let n={...t.annotations};for(let t of e)delete n[t];return n},Zs=Ys([ho,go,_o,vo,yo,bo]),F=e=>{switch(e._tag){case`Declaration`:{let t=Qs(e.typeParameters,F);return t===e.typeParameters?e:new qo(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case`TupleType`:{let t=Qs(e.elements,e=>{let t=F(e.type);return t===e.type?e:new fs(t,e.isOptional)}),n=ps(e.rest),r=Qs(n,F);return t===e.elements&&r===n?e:new ms(t,r.map(e=>new ds(e)),e.isReadonly,e.annotations)}case`TypeLiteral`:{let t=Qs(e.propertySignatures,e=>{let t=F(e.type);return t===e.type?e:new P(e.name,t,e.isOptional,e.isReadonly)}),n=Qs(e.indexSignatures,e=>{let t=F(e.type);return t===e.type?e:new _s(e.parameter,t,e.isReadonly)});return t===e.propertySignatures&&n===e.indexSignatures?e:new vs(t,n,e.annotations)}case`Union`:{let t=Qs(e.types,F);return t===e.types?e:Es.make(t,e.annotations)}case`Suspend`:return new js(()=>F(e.f()),e.annotations);case`Refinement`:{let t=F(e.from);return t===e.from?e:new Ms(t,e.filter,e.annotations)}case`Transformation`:{let t=Zs(e);return F(t===void 0?e.to:Us(e.to,t))}}return e};function Qs(e,t){let n=!1,r=ae(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}const $s=e=>{switch(e._tag){case`Transformation`:return e.from;case`Refinement`:return $s(e.from);case`Suspend`:return $s(e.f())}},ec=(e,t)=>{switch(e._tag){case`Declaration`:{let n=Qs(e.typeParameters,e=>ec(e,t));return n===e.typeParameters?e:new qo(n,e.decodeUnknown,e.encodeUnknown)}case`TupleType`:{let n=Qs(e.elements,e=>{let n=ec(e.type,t);return n===e.type?e:new fs(n,e.isOptional)}),r=ps(e.rest),i=Qs(r,e=>ec(e,t));return n===e.elements&&i===r?e:new ms(n,i.map(e=>new ds(e)),e.isReadonly)}case`TypeLiteral`:{let n=Qs(e.propertySignatures,e=>{let n=ec(e.type,t);return n===e.type?e:new P(e.name,n,e.isOptional,e.isReadonly)}),r=Qs(e.indexSignatures,e=>{let n=ec(e.type,t);return n===e.type?e:new _s(e.parameter,n,e.isReadonly)});return n===e.propertySignatures&&r===e.indexSignatures?e:new vs(n,r)}case`Union`:{let n=Qs(e.types,e=>ec(e,t));return n===e.types?e:Es.make(n)}case`Suspend`:{let n,r=Ko(e);if(bt(r)){let e=t?`Bound`:``;n={[Wo]:`${r.value}Encoded${e}`}}return new js(()=>ec(e.f(),t),n)}case`Refinement`:{let n=ec(e.from,t);return t?n===e.from?e:$s(e.from)===void 0&&Uo(e)?new Ms(n,e.filter,e.annotations):n:n}case`Transformation`:return ec(e.from,t)}return e},tc=e=>ec(e,!1),I=e=>{let t={};for(let n of Object.getOwnPropertySymbols(e))t[String(n)]=e[n];return t},nc=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return e;case`Refinement`:return nc(e.from)}},rc=e=>Ne(oc(e),()=>e._tag);function ic(e){return _(ko(e),{onNone:()=>``,onSome:e=>e.map(e=>` & Brand<${l(e)}>`).join(``)})}const ac=e=>Mo(e).pipe(pe(()=>Fo(e)),pe(()=>No(e)),Ce(t=>t+ic(e))),oc=e=>pe(Po(e),()=>ac(e)),sc=/^[+-]?\d+$/,cc=Symbol.for(`effect/BigDecimal`),lc={[cc]:cc,[a](){let e=gc(this);return C(de(e.value),ie(Ee(e.scale)),h(this))},[he](e){return uc(e)&&bc(this,e)},toString(){return`BigDecimal(${wc(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[s](){return this.toJSON()},pipe(){return De(this,arguments)}},uc=e=>Nt(e,cc),dc=(e,t)=>{let n=Object.create(lc);return n.value=e,n.scale=t,n},fc=(e,t)=>{if(e!==pc&&e%mc===pc)throw RangeError(`Value must be normalized`);let n=dc(e,t);return n.normalized=n,n},pc=BigInt(0),mc=BigInt(10),hc=fc(pc,0),gc=e=>{if(e.normalized===void 0)if(e.value===pc)e.normalized=hc;else{let t=`${e.value}`,n=0;for(let e=t.length-1;e>=0&&t[e]===`0`;e--)n++;n===0&&(e.normalized=e);let r=BigInt(t.substring(0,t.length-n)),i=e.scale-n;e.normalized=fc(r,i)}return e.normalized},_c=x(2,(e,t)=>t>e.scale?dc(e.value*mc**BigInt(t-e.scale),t):t<e.scale?dc(e.value/mc**BigInt(e.scale-t),t):e),vc=e=>e.value<pc?dc(-e.value,e.scale):e,yc=jt((e,t)=>e.scale>t.scale?_c(t,e.scale).value===e.value:e.scale<t.scale?_c(e,t.scale).value===t.value:e.value===t.value),bc=x(2,(e,t)=>yc(e,t)),xc=e=>m(Sc(e),()=>RangeError(`Number must be finite, got ${e}`)),Sc=e=>{if(!Number.isFinite(e))return v();let t=`${e}`;if(t.includes(`e`))return Cc(t);let[n,r=``]=t.split(`.`);return w(dc(BigInt(`${n}${r}`),r.length))},Cc=e=>{if(e===``)return w(hc);let t,n,r=e.search(/[eE]/);if(r!==-1){let i=e.slice(r+1);if(t=e.slice(0,r),n=Number(i),t===``||!Number.isSafeInteger(n)||!sc.test(i))return v()}else t=e,n=0;let i,a,o=t.search(/\./);if(o!==-1){let e=t.slice(0,o),n=t.slice(o+1);i=`${e}${n}`,a=n.length}else i=t,a=0;if(!sc.test(i))return v();let s=a-n;return Number.isSafeInteger(s)?w(dc(BigInt(i),s)):v()},wc=e=>{let t=gc(e);if(Math.abs(t.scale)>=16)return Tc(t);let n=t.value<pc,r=n?`${t.value}`.substring(1):`${t.value}`,i,a;if(t.scale>=r.length)i=`0`,a=`0`.repeat(t.scale-r.length)+r;else{let e=r.length-t.scale;if(e>r.length){let t=e-r.length;i=`${r}${`0`.repeat(t)}`,a=``}else a=r.slice(e),i=r.slice(0,e)}let o=a===``?i:`${i}.${a}`;return n?`-${o}`:o},Tc=e=>{if(Dc(e))return`0e+0`;let t=gc(e),n=`${vc(t).value}`,r=n.slice(0,1),i=n.slice(1),a=`${Oc(t)?`-`:``}${r}`;i!==``&&(a+=`.${i}`);let o=i.length-t.scale;return`${a}e${o>=0?`+`:``}${o}`},Ec=e=>Number(wc(e)),Dc=e=>e.value===pc,Oc=e=>e.value<pc,kc=e=>e>BigInt(2**53-1)||e<BigInt(-(2**53-1))?v():w(Number(e)),Ac=e=>{try{return e.trim()===``?v():w(BigInt(e))}catch{return v()}},jc=e=>{if(e>2**53-1||e<-(2**53-1))return v();try{return w(BigInt(e))}catch{return v()}},Mc=Symbol.for(`effect/Brand/Refined`),Nc=()=>Object.assign(e=>e,{[Mc]:Mc,option:e=>w(e),either:e=>b(e),is:e=>!0}),Pc=On,Fc=An,Ic=xn,Lc=_n,Rc=Symbol.for(`effect/QueueEnqueue`),zc=Symbol.for(`effect/QueueDequeue`),Bc=Symbol.for(`effect/QueueStrategy`),Vc=Symbol.for(`effect/BackingQueue`),Hc={_A:e=>e},Uc={_A:e=>e},Wc={_In:e=>e},Gc={_Out:e=>e};var Kc=class extends Kr{queue;takers;shutdownHook;shutdownFlag;strategy;[Rc]=Wc;[zc]=Gc;constructor(e,t,n,r,i){super(),this.queue=e,this.takers=t,this.shutdownHook=n,this.shutdownFlag=r,this.strategy=i}pipe(){return De(this,arguments)}commit(){return this.take}capacity(){return this.queue.capacity()}get size(){return Jt(()=>xt(this.unsafeSize(),()=>u))}unsafeSize(){return Le(this.shutdownFlag)?v():w(this.queue.length()-Pn(this.takers)+this.strategy.surplusSize())}get isEmpty(){return We(this.size,e=>e<=0)}get isFull(){return We(this.size,e=>e>=this.capacity())}get shutdown(){return Ct(fe(e=>(C(this.shutdownFlag,Pe(!0)),C(yr(hl(this.takers),t=>ot(t,e.id()),!1,!1),ce(this.strategy.shutdown),Se(ct(this.shutdownHook,void 0)),qt))))}get isShutdown(){return Me(()=>Le(this.shutdownFlag))}get awaitShutdown(){return zt(this.shutdownHook)}isActive(){return!Le(this.shutdownFlag)}unsafeOffer(e){if(Le(this.shutdownFlag))return!1;let t;if(this.queue.length()===0){let n=C(this.takers,Ln(Vr));n===Vr?t=!1:(pl(n,e),t=!0)}else t=!1;if(t)return!0;let n=this.queue.offer(e);return vl(this.strategy,this.queue,this.takers),n}offer(e){return Jt(()=>{if(Le(this.shutdownFlag))return u;let t;if(this.queue.length()===0){let n=C(this.takers,Ln(Vr));n===Vr?t=!1:(pl(n,e),t=!0)}else t=!1;if(t)return c(!0);let n=this.queue.offer(e);return vl(this.strategy,this.queue,this.takers),n?c(!0):this.strategy.handleSurplus([e],this.queue,this.takers,this.shutdownFlag)})}offerAll(e){return Jt(()=>{if(Le(this.shutdownFlag))return u;let t=ue(e),n=this.queue.length()===0?ue(gl(this.takers,t.length)):Re,[r,i]=C(t,ft(n.length));for(let e=0;e<n.length;e++){let t=n[e],i=r[e];pl(t,i)}if(i.length===0)return c(!0);let a=this.queue.offerAll(i);return vl(this.strategy,this.queue,this.takers),je(a)?c(!0):this.strategy.handleSurplus(a,this.queue,this.takers,this.shutdownFlag)})}get take(){return fe(e=>{if(Le(this.shutdownFlag))return u;let t=this.queue.poll(Vr);if(t!==Vr)return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),c(t);{let t=Mt(e.id());return C(Jt(()=>(C(this.takers,ln(t)),vl(this.strategy,this.queue,this.takers),Le(this.shutdownFlag)?u:zt(t))),at(()=>Me(()=>_l(this.takers,t))))}})}get takeAll(){return Jt(()=>Le(this.shutdownFlag)?u:Me(()=>{let e=this.queue.pollUpTo(1/0);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Oe(e)}))}takeUpTo(e){return Jt(()=>Le(this.shutdownFlag)?u:Me(()=>{let t=this.queue.pollUpTo(e);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Oe(t)}))}takeBetween(e,t){return Jt(()=>qc(this,e,t,tt()))}};const qc=(e,t,n,r)=>n<t?c(r):C(ol(e,n),Gt(i=>{let a=t-i.length;return a===1?C(al(e),We(e=>C(r,Qt(i),Kt(e)))):a>1?C(al(e),Gt(t=>qc(e,a-1,n-i.length-1,C(r,Qt(i),Kt(t))))):c(C(r,Qt(i)))})),Jc=e=>C(Me(()=>Xr(e)),Gt(e=>$c(tl(e),sl()))),Yc=e=>C(Me(()=>Xr(e)),Gt(e=>$c(tl(e),cl()))),Xc=e=>C(Me(()=>Xr(e)),Gt(e=>$c(tl(e),ll()))),Zc=()=>C(Me(()=>fn()),Gt(e=>$c(tl(e),cl()))),Qc=(e,t,n,r,i)=>new Kc(e,t,n,r,i),$c=(e,t)=>C(Wt(),We(n=>Qc(e,fn(),n,ne(!1),t)));var el=class{mutable;[Vc]=Uc;constructor(e){this.mutable=e}poll(e){return Ln(this.mutable,e)}pollUpTo(e){return hn(this.mutable,e)}offerAll(e){return Wr(this.mutable,e)}offer(e){return ln(this.mutable,e)}capacity(){return Qn(this.mutable)}length(){return Pn(this.mutable)}};const tl=e=>new el(e),nl=e=>e.size,rl=e=>e.shutdown,il=x(2,(e,t)=>e.offer(t)),al=e=>e.take,ol=x(2,(e,t)=>e.takeUpTo(t)),sl=()=>new ul,cl=()=>new dl,ll=()=>new fl;var ul=class{[Bc]=Hc;putters=fn();surplusSize(){return Pn(this.putters)}onCompleteTakersWithEmptyQueue(e){for(;!qr(this.putters)&&!qr(e);){let t=Ln(e,void 0),n=Ln(this.putters,void 0);n[2]&&pl(n[1],!0),pl(t,n[0])}}get shutdown(){return C(_t,Gt(e=>C(Me(()=>hl(this.putters)),Gt(t=>yr(t,([t,n,r])=>r?C(ot(n,e),qt):_e,!1,!1)))))}handleSurplus(e,t,n,r){return fe(i=>{let a=Mt(i.id());return C(Jt(()=>(this.unsafeOffer(e,a),this.unsafeOnQueueEmptySpace(t,n),vl(this,t,n),Le(r)?u:zt(a))),at(()=>Me(()=>this.unsafeRemove(a))))})}unsafeOnQueueEmptySpace(e,t){let n=!0;for(;n&&(e.capacity()===1/0||e.length()<e.capacity());){let r=C(this.putters,Ln(Vr));if(r===Vr)n=!1;else{let n=e.offer(r[0]);n&&r[2]?pl(r[1],!0):n||ml(this.putters,C(hl(this.putters),St(r))),vl(this,e,t)}}}unsafeOffer(e,t){let n=ue(e);for(let e=0;e<n.length;e++){let r=n[e];e===n.length-1?C(this.putters,ln([r,t,!0])):C(this.putters,ln([r,t,!1]))}}unsafeRemove(e){ml(this.putters,C(hl(this.putters),Xt(([,t])=>t!==e)))}},dl=class{[Bc]=Hc;surplusSize(){return 0}get shutdown(){return _e}onCompleteTakersWithEmptyQueue(){}handleSurplus(e,t,n,r){return c(!1)}unsafeOnQueueEmptySpace(e,t){}},fl=class{[Bc]=Hc;surplusSize(){return 0}get shutdown(){return _e}onCompleteTakersWithEmptyQueue(){}handleSurplus(e,t,n,r){return Me(()=>(this.unsafeOffer(t,e),vl(this,t,n),!0))}unsafeOnQueueEmptySpace(e,t){}unsafeOffer(e,t){let n=t[Symbol.iterator](),r,i=!0;for(;!(r=n.next()).done&&i;){if(e.capacity()===0)return;e.poll(Vr),i=e.offer(r.value)}}};const pl=(e,t)=>pt(e,c(t)),ml=(e,t)=>C(e,Wr(t)),hl=e=>C(e,hn(1/0)),gl=(e,t)=>C(e,hn(t)),_l=(e,t)=>{ml(e,C(hl(e),Xt(e=>t!==e)))},vl=(e,t,n)=>{let r=!0;for(;r&&t.length()!==0;){let i=C(n,Ln(Vr));if(i!==Vr){let a=t.poll(Vr);a===Vr?ml(n,C(hl(n),St(i))):(pl(i,a),e.unsafeOnQueueEmptySpace(t,n)),r=!0}else r=!1}r&&t.length()===0&&!qr(n)&&e.onCompleteTakersWithEmptyQueue(n)},yl=Jc,bl=Yc,xl=Xc,Sl=Zc,Cl=nl,wl=rl,Tl=il,El=al,Dl=`Continue`,Ol=Symbol.for(`effect/ChannelChildExecutorDecision`),kl={[Ol]:Ol},Al=e=>{let t=Object.create(kl);return t._tag=Dl,t},jl=Symbol.for(`effect/ChannelContinuation`),Ml={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutDone:e=>e,_OutErr2:e=>e,_OutElem:e=>e,_OutDone2:e=>e};var Nl=class{onSuccess;onHalt;_tag=`ContinuationK`;[jl]=Ml;constructor(e,t){this.onSuccess=e,this.onHalt=t}onExit(e){return xi(e)?this.onHalt(e.cause):this.onSuccess(e.value)}},Pl=class{finalizer;_tag=`ContinuationFinalizer`;[jl]=Ml;constructor(e){this.finalizer=e}};const Fl=`PullAfterNext`,Il=Symbol.for(`effect/ChannelUpstreamPullStrategy`),Ll={_A:e=>e},Rl={[Il]:Ll},zl=e=>{let t=Object.create(Rl);return t._tag=Fl,t.emitSeparator=e,t},Bl=`BracketOut`,Vl=`Bridge`,Hl=`ConcatAll`,Ul=`Emit`,Wl=`Ensuring`,Gl=`Fail`,Kl=`Fold`,ql=`FromEffect`,Jl=`PipeTo`,Yl=`Read`,Xl=`Succeed`,Zl=`SucceedNow`,Ql=`Suspend`,$l=Symbol.for(`effect/Channel`),eu={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},tu={[$l]:eu,pipe(){return De(this,arguments)}},nu=e=>Nt(e,$l)||Tn(e),ru=x(2,(e,t)=>{let n=Object.create(tu);return n._tag=Bl,n.acquire=()=>e,n.finalizer=t,n}),iu=(e,t,n)=>{let r=Object.create(tu);return r._tag=Hl,r.combineInners=t,r.combineAll=n,r.onPull=()=>zl(v()),r.onEmit=()=>Al,r.value=()=>e,r.k=S,r},au=x(4,(e,t,n,r)=>{let i=Object.create(tu);return i._tag=Hl,i.combineInners=n,i.combineAll=r,i.onPull=()=>zl(v()),i.onEmit=()=>Al,i.value=()=>e,i.k=t,i}),ou=x(2,(e,t)=>{let n=Object.create(tu);return n._tag=Vl,n.input=t,n.channel=e,n}),su=x(2,(e,t)=>{let n=Object.create(tu);return n._tag=Wl,n.channel=e,n.finalizer=t,n}),cu=e=>lu(ni(e)),lu=e=>uu(()=>e),uu=e=>{let t=Object.create(tu);return t._tag=Gl,t.error=e,t},L=x(2,(e,t)=>{let n=Object.create(tu);return n._tag=Kl,n.channel=e,n.k=new Nl(t,lu),n}),R=e=>{let t=Object.create(tu);return t._tag=ql,t.effect=()=>e,t},du=x(2,(e,t)=>{let n=Object.create(tu);return n._tag=Jl,n.left=()=>e,n.right=()=>t,n}),fu=e=>pu({onInput:e.onInput,onFailure:t=>Ge(Qr(t),{onLeft:e.onFailure,onRight:lu}),onDone:e.onDone}),pu=e=>{let t=Object.create(tu);return t._tag=Yl,t.more=e.onInput,t.done=new Nl(e.onDone,e.onFailure),t},mu=e=>_u(()=>e),hu=e=>{let t=Object.create(tu);return t._tag=Zl,t.terminal=e,t},gu=e=>{let t=Object.create(tu);return t._tag=Ql,t.channel=e,t},_u=e=>{let t=Object.create(tu);return t._tag=Xl,t.evaluate=e,t},vu=hu(void 0),z=e=>{let t=Object.create(tu);return t._tag=Ul,t.out=e,t},yu=`Done`,bu=`Emit`,xu=`FromEffect`,Su=`Read`,Cu=Symbol.for(`effect/ChannelState`),wu={_E:e=>e,_R:e=>e},Tu={[Cu]:wu},Eu=()=>{let e=Object.create(Tu);return e._tag=yu,e},Du=()=>{let e=Object.create(Tu);return e._tag=bu,e},Ou=e=>{let t=Object.create(Tu);return t._tag=xu,t.effect=e,t},ku=(e,t,n,r)=>{let i=Object.create(Tu);return i._tag=Su,i.upstream=e,i.onEffect=t,i.onEmit=n,i.onDone=r,i},Au=e=>e._tag===xu,ju=e=>Au(e)?e.effect:A,Mu=e=>Au(e)?kn(e.effect):void 0,Nu=`PullFromChild`,Pu=`PullFromUpstream`,Fu=`DrainChildExecutors`,Iu=`Emit`;var Lu=class{childExecutor;parentSubexecutor;onEmit;_tag=Nu;constructor(e,t,n){this.childExecutor=e,this.parentSubexecutor=t,this.onEmit=n}close(e){let t=this.childExecutor.close(e),n=this.parentSubexecutor.close(e);if(t!==void 0&&n!==void 0)return qn(O(t),O(n),(e,t)=>C(e,mi(t)));if(t!==void 0)return t;if(n!==void 0)return n}enqueuePullFromChild(e){return this}},Ru=class e{upstreamExecutor;createChild;lastDone;activeChildExecutors;combineChildResults;combineWithChildResult;onPull;onEmit;_tag=Pu;constructor(e,t,n,r,i,a,o,s){this.upstreamExecutor=e,this.createChild=t,this.lastDone=n,this.activeChildExecutors=r,this.combineChildResults=i,this.combineWithChildResult=a,this.onPull=o,this.onEmit=s}close(e){let t=this.upstreamExecutor.close(e);return[...this.activeChildExecutors.map(t=>t===void 0?void 0:t.childExecutor.close(e)),t].reduce((e,t)=>{if(e!==void 0&&t!==void 0)return qn(e,O(t),(e,t)=>mi(e,t));if(e!==void 0)return e;if(t!==void 0)return O(t)},void 0)}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.createChild,this.lastDone,[...this.activeChildExecutors,t],this.combineChildResults,this.combineWithChildResult,this.onPull,this.onEmit)}},zu=class e{upstreamExecutor;lastDone;activeChildExecutors;upstreamDone;combineChildResults;combineWithChildResult;onPull;_tag=Fu;constructor(e,t,n,r,i,a,o){this.upstreamExecutor=e,this.lastDone=t,this.activeChildExecutors=n,this.upstreamDone=r,this.combineChildResults=i,this.combineWithChildResult=a,this.onPull=o}close(e){let t=this.upstreamExecutor.close(e);return[...this.activeChildExecutors.map(t=>t===void 0?void 0:t.childExecutor.close(e)),t].reduce((e,t)=>{if(e!==void 0&&t!==void 0)return qn(e,O(t),(e,t)=>mi(e,t));if(e!==void 0)return e;if(t!==void 0)return O(t)},void 0)}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.lastDone,[...this.activeChildExecutors,t],this.upstreamDone,this.combineChildResults,this.combineWithChildResult,this.onPull)}},Bu=class{value;next;_tag=Iu;constructor(e,t){this.value=e,this.next=t}close(e){return this.next.close(e)}enqueuePullFromChild(e){return this}};const Vu=Symbol.for(`effect/ChannelUpstreamPullRequest`),Hu={_A:e=>e},Uu={[Vu]:Hu},Wu=e=>{let t=Object.create(Uu);return t._tag=`Pulled`,t.value=e,t},Gu=e=>{let t=Object.create(Uu);return t._tag=`NoUpstream`,t.activeDownstreamCount=e,t};var Ku=class e{_activeSubexecutor=void 0;_cancelled=void 0;_closeLastSubstream=void 0;_currentChannel;_done=void 0;_doneStack=[];_emitted=void 0;_executeCloseLastSubstream;_input=void 0;_inProgressFinalizer=void 0;_providedEnv;constructor(e,t,n){this._currentChannel=e,this._executeCloseLastSubstream=n,this._providedEnv=t}run(){let t;for(;t===void 0;)if(this._cancelled!==void 0)t=this.processCancellation();else if(this._activeSubexecutor!==void 0)t=this.runSubexecutor();else try{if(this._currentChannel===void 0)t=Eu();else switch(Tn(this._currentChannel)&&(this._currentChannel=R(this._currentChannel)),this._currentChannel._tag){case Bl:t=this.runBracketOut(this._currentChannel);break;case Vl:{let e=this._currentChannel.input;if(this._currentChannel=this._currentChannel.channel,this._input!==void 0){let n=this._input;this._input=void 0;let r=()=>D(e.awaitRead(),()=>j(()=>{let t=n.run();switch(t._tag){case yu:return fi(n.getDone(),{onFailure:t=>e.error(t),onSuccess:t=>e.done(t)});case bu:return D(e.emit(n.getEmit()),()=>r());case xu:return Zr(t.effect,{onFailure:t=>e.error(t),onSuccess:()=>r()});case Su:return Yu(t,()=>r(),t=>e.error(t))}}));t=Ou(D(Hr(an(r())),e=>Nr(()=>this.addFinalizer(t=>D(rn(e),()=>j(()=>{let e=this.restorePipe(t,n);return e===void 0?A:e}))))))}break}case Hl:{let t=new e(this._currentChannel.value(),this._providedEnv,e=>Nr(()=>{let t=this._closeLastSubstream===void 0?A:this._closeLastSubstream;this._closeLastSubstream=C(t,k(e))}));t._input=this._input;let n=this._currentChannel;this._activeSubexecutor=new Ru(t,e=>n.k(e),void 0,[],(e,t)=>n.combineInners(e,t),(e,t)=>n.combineAll(e,t),e=>n.onPull(e),e=>n.onEmit(e)),this._closeLastSubstream=void 0,this._currentChannel=void 0;break}case Ul:this._emitted=this._currentChannel.out,this._currentChannel=this._activeSubexecutor===void 0?vu:void 0,t=Du();break;case Wl:this.runEnsuring(this._currentChannel);break;case Gl:t=this.doneHalt(this._currentChannel.error());break;case Kl:this._doneStack.push(this._currentChannel.k),this._currentChannel=this._currentChannel.channel;break;case ql:{let e=this._providedEnv===void 0?this._currentChannel.effect():C(this._currentChannel.effect(),Rn(this._providedEnv));t=Ou(Zr(e,{onFailure:e=>{let t=this.doneHalt(e);return t!==void 0&&Au(t)?t.effect:A},onSuccess:e=>{let t=this.doneSucceed(e);return t!==void 0&&Au(t)?t.effect:A}}));break}case Jl:{let t=this._input,n=new e(this._currentChannel.left(),this._providedEnv,e=>this._executeCloseLastSubstream(e));n._input=t,this._input=n,this.addFinalizer(e=>{let n=this.restorePipe(e,t);return n===void 0?A:n}),this._currentChannel=this._currentChannel.right();break}case`Provide`:{let e=this._providedEnv;this._providedEnv=this._currentChannel.context(),this._currentChannel=this._currentChannel.inner,this.addFinalizer(()=>Nr(()=>{this._providedEnv=e}));break}case Yl:{let e=this._currentChannel;t=ku(this._input,S,t=>{try{this._currentChannel=e.more(t)}catch(t){this._currentChannel=e.done.onExit(bi(t))}},t=>{let n=t=>e.done.onExit(t);this._currentChannel=n(t)});break}case Xl:t=this.doneSucceed(this._currentChannel.evaluate());break;case Zl:t=this.doneSucceed(this._currentChannel.terminal);break;case Ql:this._currentChannel=this._currentChannel.channel();break}}catch(e){this._currentChannel=lu(si(e))}return t}getDone(){return this._done}getEmit(){return this._emitted}cancelWith(e){this._cancelled=e}clearInProgressFinalizer(){this._inProgressFinalizer=void 0}storeInProgressFinalizer(e){this._inProgressFinalizer=e}popAllFinalizers(e){let t=[],n=this._doneStack.pop();for(;n;)n._tag===`ContinuationFinalizer`&&t.push(n.finalizer),n=this._doneStack.pop();let r=t.length===0?A:Ju(t,e);return this.storeInProgressFinalizer(r),r}popNextFinalizers(){let e=[];for(;this._doneStack.length!==0;){let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`)return e;e.push(t),this._doneStack.pop()}return e}restorePipe(e,t){let n=this._input;return this._input=t,n===void 0?A:n.close(e)}close(e){let t,n=this._inProgressFinalizer;n!==void 0&&(t=C(n,cr(Nr(()=>this.clearInProgressFinalizer()))));let r,i=this.popAllFinalizers(e);i!==void 0&&(r=C(i,cr(Nr(()=>this.clearInProgressFinalizer()))));let a=this._activeSubexecutor===void 0?void 0:this._activeSubexecutor.close(e);if(a!==void 0||t!==void 0||r!==void 0)return C(O(qu(a)),Cr(O(qu(t))),Cr(O(qu(r))),E(([[e,t],n])=>C(e,mi(t),mi(n))),br,D(e=>j(()=>e)))}doneSucceed(e){if(this._doneStack.length===0)return this._done=pi(e),this._currentChannel=void 0,Eu();let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`){this._doneStack.pop(),this._currentChannel=t.onSuccess(e);return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=pi(e),this._currentChannel=void 0,Eu();let r=Ju(n.map(e=>e.finalizer),pi(e));this.storeInProgressFinalizer(r);let i=C(r,cr(Nr(()=>this.clearInProgressFinalizer())),br,D(()=>Nr(()=>this.doneSucceed(e))));return Ou(i)}doneHalt(e){if(this._doneStack.length===0)return this._done=ui(e),this._currentChannel=void 0,Eu();let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`){this._doneStack.pop();try{this._currentChannel=t.onHalt(e)}catch(e){this._currentChannel=lu(si(e))}return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=ui(e),this._currentChannel=void 0,Eu();let r=Ju(n.map(e=>e.finalizer),ui(e));this.storeInProgressFinalizer(r);let i=C(r,cr(Nr(()=>this.clearInProgressFinalizer())),br,D(()=>Nr(()=>this.doneHalt(e))));return Ou(i)}processCancellation(){return this._currentChannel=void 0,this._done=this._cancelled,this._cancelled=void 0,Eu()}runBracketOut(e){let t=br(Zr(this.provide(e.acquire()),{onFailure:e=>Nr(()=>{this._currentChannel=lu(e)}),onSuccess:t=>Nr(()=>{this.addFinalizer(n=>this.provide(e.finalizer(t,n))),this._currentChannel=z(t)})}));return Ou(t)}provide(e){return this._providedEnv===void 0?e:C(e,Rn(this._providedEnv))}runEnsuring(e){this.addFinalizer(e.finalizer),this._currentChannel=e.channel}addFinalizer(e){this._doneStack.push(new Pl(e))}runSubexecutor(){let e=this._activeSubexecutor;switch(e._tag){case Nu:return this.pullFromChild(e.childExecutor,e.parentSubexecutor,e.onEmit,e);case Pu:return this.pullFromUpstream(e);case Fu:return this.drainChildExecutors(e);case Iu:return this._emitted=e.value,this._activeSubexecutor=e.next,Du()}}replaceSubexecutor(e){this._currentChannel=void 0,this._activeSubexecutor=e}finishWithExit(e){let t=fi(e,{onFailure:e=>this.doneHalt(e),onSuccess:e=>this.doneSucceed(e)});return this._activeSubexecutor=void 0,t===void 0?A:ju(t)}finishSubexecutorWithCloseEffect(e,...t){this.addFinalizer(()=>C(t,sn(t=>C(Nr(()=>t(e)),D(e=>e===void 0?A:e)),{discard:!0})));let n=C(e,fi({onFailure:e=>this.doneHalt(e),onSuccess:e=>this.doneSucceed(e)}));return this._activeSubexecutor=void 0,n}applyUpstreamPullStrategy(e,t,n){switch(n._tag){case Fl:{let r=!e||t.some(e=>e!==void 0);return[n.emitSeparator,r?[void 0,...t]:t]}case`PullAfterAllEnqueued`:{let r=!e||t.some(e=>e!==void 0);return[n.emitSeparator,r?[...t,void 0]:t]}}}pullFromChild(e,t,n,r){return ku(e,S,i=>{let a=n(i);switch(a._tag){case Dl:break;case`Close`:this.finishWithDoneValue(e,t,a.value);break;case`Yield`:{let e=t.enqueuePullFromChild(r);this.replaceSubexecutor(e);break}}this._activeSubexecutor=new Bu(i,this._activeSubexecutor)},fi({onFailure:n=>{let r=this.handleSubexecutorFailure(e,t,n);return r===void 0?void 0:Mu(r)},onSuccess:n=>{this.finishWithDoneValue(e,t,n)}}))}finishWithDoneValue(e,t,n){let r=t;switch(r._tag){case Pu:{let t=new Ru(r.upstreamExecutor,r.createChild,r.lastDone===void 0?n:r.combineChildResults(r.lastDone,n),r.activeChildExecutors,r.combineChildResults,r.combineWithChildResult,r.onPull,r.onEmit);this._closeLastSubstream=e.close(pi(n)),this.replaceSubexecutor(t);break}case Fu:{let t=new zu(r.upstreamExecutor,r.lastDone===void 0?n:r.combineChildResults(r.lastDone,n),r.activeChildExecutors,r.upstreamDone,r.combineChildResults,r.combineWithChildResult,r.onPull);this._closeLastSubstream=e.close(pi(n)),this.replaceSubexecutor(t);break}default:break}}handleSubexecutorFailure(e,t,n){return this.finishSubexecutorWithCloseEffect(ui(n),e=>t.close(e),t=>e.close(t))}pullFromUpstream(e){if(e.activeChildExecutors.length===0)return this.performPullFromUpstream(e);let t=e.activeChildExecutors[0],n=new Ru(e.upstreamExecutor,e.createChild,e.lastDone,e.activeChildExecutors.slice(1),e.combineChildResults,e.combineWithChildResult,e.onPull,e.onEmit);if(t===void 0)return this.performPullFromUpstream(n);this.replaceSubexecutor(new Lu(t.childExecutor,n,t.onEmit))}performPullFromUpstream(t){return ku(t.upstreamExecutor,e=>{let t=this._closeLastSubstream===void 0?A:this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(t),k(e))},n=>{if(this._closeLastSubstream!==void 0){let r=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(r),E(()=>{let r=new e(t.createChild(n),this._providedEnv,this._executeCloseLastSubstream);r._input=this._input;let[i,a]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(Wu(n)));this._activeSubexecutor=new Lu(r,new Ru(t.upstreamExecutor,t.createChild,t.lastDone,a,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),bt(i)&&(this._activeSubexecutor=new Bu(i.value,this._activeSubexecutor))}))}let r=new e(t.createChild(n),this._providedEnv,this._executeCloseLastSubstream);r._input=this._input;let[i,a]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(Wu(n)));this._activeSubexecutor=new Lu(r,new Ru(t.upstreamExecutor,t.createChild,t.lastDone,a,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),bt(i)&&(this._activeSubexecutor=new Bu(i.value,this._activeSubexecutor))},e=>{if(t.activeChildExecutors.some(e=>e!==void 0)){let e=new zu(t.upstreamExecutor,t.lastDone,[void 0,...t.activeChildExecutors],t.upstreamExecutor.getDone(),t.combineChildResults,t.combineWithChildResult,t.onPull);if(this._closeLastSubstream!==void 0){let t=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(t),E(()=>this.replaceSubexecutor(e)))}this.replaceSubexecutor(e);return}let n=this._closeLastSubstream,r=this.finishSubexecutorWithCloseEffect(C(e,gi(e=>t.combineWithChildResult(t.lastDone,e))),()=>n,e=>t.upstreamExecutor.close(e));return r===void 0?void 0:Mu(r)})}drainChildExecutors(e){if(e.activeChildExecutors.length===0){let t=this._closeLastSubstream;return t!==void 0&&this.addFinalizer(()=>M(t)),this.finishSubexecutorWithCloseEffect(e.upstreamDone,()=>t,t=>e.upstreamExecutor.close(t))}let t=e.activeChildExecutors[0],n=e.activeChildExecutors.slice(1);if(t===void 0){let[t,r]=this.applyUpstreamPullStrategy(!0,n,e.onPull(Gu(n.reduce((e,t)=>t===void 0?e:e+1,0))));return this.replaceSubexecutor(new zu(e.upstreamExecutor,e.lastDone,r,e.upstreamDone,e.combineChildResults,e.combineWithChildResult,e.onPull)),bt(t)?(this._emitted=t.value,Du()):void 0}let r=new zu(e.upstreamExecutor,e.lastDone,n,e.upstreamDone,e.combineChildResults,e.combineWithChildResult,e.onPull);this.replaceSubexecutor(new Lu(t.childExecutor,r,t.onEmit))}};const qu=e=>e===void 0?A:e,Ju=(e,t)=>C(sn(e,e=>O(e(t))),E(e=>C(vi(e),Ne(()=>yi))),D(e=>j(()=>e))),Yu=(e,t,n)=>{let r=[e],i=()=>{let e=r.pop();if(e===void 0||e.upstream===void 0)return Dr(`Unexpected end of input for channel execution`);let a=e.upstream.run();switch(a._tag){case bu:{let a=e.onEmit(e.upstream.getEmit());return r.length===0?a===void 0?j(t):C(a,Zr({onFailure:n,onSuccess:t})):a===void 0?j(()=>i()):C(a,Zr({onFailure:n,onSuccess:()=>i()}))}case yu:{let a=e.onDone(e.upstream.getDone());return r.length===0?a===void 0?j(t):C(a,Zr({onFailure:n,onSuccess:t})):a===void 0?j(()=>i()):C(a,Zr({onFailure:n,onSuccess:()=>i()}))}case xu:return r.push(e),C(e.onEffect(a.effect),Lr(t=>j(()=>{let n=e.onDone(ui(t));return n===void 0?A:n})),Zr({onFailure:n,onSuccess:()=>i()}));case Su:return r.push(e),r.push(a),j(()=>i())}};return i()},Xu=x(2,(e,t)=>{let n=(t,n,r)=>dr(Nr(()=>new Ku(e,void 0,S)),e=>j(()=>Zu(e.run(),e).pipe(mr(t),k(T(t)),ur(T(n)))),(e,t)=>{let n=e.close(t);return n===void 0?A:Xn(n,e=>Mr(r,zr(e)))});return Rr(e=>Jn([Fr(t,Zn),hr(),hr()]).pipe(D(([r,i,a])=>e(n(i,a,r)).pipe(Fn(t),D(n=>t.addFinalizer(e=>{let t=xi(e)?$r(e.cause):void 0;return on(i).pipe(D(e=>e?En(a,void 0).pipe(k(Wn(n)),k(jn(n))):En(a,void 0).pipe(k(t&&ht(t)>0?rr(n,yt(t)):rn(n)),k(jn(n)))))}).pipe(k(e(T(i)))))))))}),Zu=(e,t)=>{let n=e;switch(n._tag){case xu:return C(n.effect,D(()=>Zu(t.run(),t)));case bu:return Zu(t.run(),t);case yu:return j(()=>t.getDone());case Su:return Yu(n,()=>Zu(t.run(),t),zr)}},Qu={[Symbol.for(`effect/ChannelMergeDecision`)]:{_R:e=>e,_E0:e=>e,_Z0:e=>e,_E:e=>e,_Z:e=>e}},$u=e=>{let t=Object.create(Qu);return t._tag=`Await`,t.f=e,t},ed=`BothRunning`,td=`LeftDone`,nd=`RightDone`,rd=Symbol.for(`effect/ChannelMergeState`),id={[rd]:rd},ad=(e,t)=>{let n=Object.create(id);return n._tag=ed,n.left=e,n.right=t,n},od=e=>{let t=Object.create(id);return t._tag=td,t.f=e,t},sd=e=>{let t=Object.create(id);return t._tag=nd,t.f=e,t},cd=`BackPressure`,ld=`BufferSliding`,ud=Symbol.for(`effect/ChannelMergeStrategy`),dd={[ud]:ud},fd=e=>{let t=Object.create(dd);return t._tag=cd,t},pd=e=>{let t=Object.create(dd);return t._tag=ld,t},md=x(2,(e,{onBackPressure:t,onBufferSliding:n})=>{switch(e._tag){case cd:return t();case ld:return n()}}),hd=`Empty`,gd=`Emit`,_d=`Error`,vd=`Done`,yd=e=>({_tag:hd,notifyProducer:e}),bd=e=>({_tag:gd,notifyConsumers:e}),xd=e=>({_tag:_d,cause:e}),Sd=e=>({_tag:vd,done:e});var Cd=class{ref;constructor(e){this.ref=e}awaitRead(){return Gr(Kn(this.ref,e=>e._tag===hd?[T(e.notifyProducer),e]:[A,e]))}get close(){return Jr(e=>this.error(ci(e)))}done(e){return Gr(Kn(this.ref,t=>{switch(t._tag){case hd:return[T(t.notifyProducer),t];case gd:return[sn(t.notifyConsumers,t=>En(t,y(e)),{discard:!0}),Sd(e)];case _d:return[gr,t];case vd:return[gr,t]}}))}emit(e){return D(hr(),t=>Gr(Kn(this.ref,n=>{switch(n._tag){case hd:return[T(n.notifyProducer),n];case gd:{let r=n.notifyConsumers[0],i=n.notifyConsumers.slice(1);if(r!==void 0)return[En(r,b(e)),i.length===0?yd(t):bd(i)];throw Error(`Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues`)}case _d:return[gr,n];case vd:return[gr,n]}})))}error(e){return Gr(Kn(this.ref,t=>{switch(t._tag){case hd:return[T(t.notifyProducer),t];case gd:return[sn(t.notifyConsumers,t=>_r(t,e),{discard:!0}),xd(e)];case _d:return[gr,t];case vd:return[gr,t]}}))}get take(){return this.takeWith(e=>ui(ei(e,y)),e=>pi(e),e=>hi(b(e)))}takeWith(e,t,n){return D(hr(),r=>Gr(Kn(this.ref,i=>{switch(i._tag){case hd:return[k(En(i.notifyProducer,void 0),Mn(T(r),{onFailure:e,onSuccess:Ge({onLeft:n,onRight:t})})),bd([r])];case gd:return[Mn(T(r),{onFailure:e,onSuccess:Ge({onLeft:n,onRight:t})}),bd([...i.notifyConsumers,r])];case _d:return[M(e(i.cause)),i];case vd:return[M(n(i.done)),i]}})))}};const wd=()=>C(hr(),D(e=>sr(yd(e))),E(e=>new Cd(e))),Td=x(2,(e,t)=>au(e,t,()=>void 0,()=>void 0)),Ed=e=>{let t=pu({onInput:()=>t,onFailure:lu,onDone:mu});return du(e,t)},Dd=x(2,(e,t)=>su(e,()=>t)),Od=e=>L(e,S),kd=e=>Hd(e.takeWith(lu,t=>L(z(t),()=>kd(e)),mu)),Ad=x(2,(e,t)=>L(e,e=>_u(()=>t(e)))),jd=x(2,(e,t)=>{let n=fu({onInput:e=>L(z(t(e)),()=>n),onFailure:cu,onDone:hu});return du(e,n)}),Md=x(2,(e,t)=>{let n=pu({onInput:e=>C(R(t(e)),L(z),L(()=>n)),onFailure:lu,onDone:hu});return du(e,n)}),Nd=e=>t=>Pd(e)(t,mt),Pd=({bufferSize:e=16,concurrency:t,mergeStrategy:n=fd()})=>(r,i)=>Wd(a=>un(function*(){let o=t===`unbounded`?2**53-1:t,s=yield*wd(),c=kd(s),l=yield*yl(e);yield*Mr(a,wl(l));let u=yield*Sl();yield*Mr(a,wl(u));let d=yield*sr(v()),f=yield*hr(),p=(yield*Dn(o)).withPermits,m=yield*Bd(du(c,r),a);function h(e){return e.pipe(D(Ge({onLeft:e=>M(w(e)),onRight:e=>wr(Tl(l,M(b(e))),v())})),Cn({until:e=>bt(e)}),D(e=>Yr(d,_({onNone:()=>w(e.value),onSome:t=>w(i(t,e.value))}))),Lr(e=>li(e)?zr(e):Tl(l,zr(e)).pipe(k(En(f,void 0)),Pr)))}yield*m.pipe(Zr({onFailure:e=>Tl(l,zr(e)).pipe(k(M(!1))),onSuccess:Ge({onLeft:e=>vn(an(T(f)),an(p(o)(A)),{onSelfDone:(e,t)=>wr(rn(t),!1),onOtherDone:(t,n)=>k(rn(n),lr(d).pipe(D(_({onNone:()=>Tl(l,M(y(e))),onSome:t=>Tl(l,M(y(i(t,e))))})),wr(!1)))}),onRight:e=>md(n,{onBackPressure:()=>un(function*(){let t=yield*hr(),n=nn(t=>Bd(du(c,e),t).pipe(D(e=>Bn(O(h(e)),O(an(T(f))))),D(S)));return yield*En(t,void 0).pipe(k(n),p(1),Fn(a)),yield*T(t),!(yield*on(f))}),onBufferSliding:()=>un(function*(){let t=yield*hr(),n=yield*hr(),r=yield*Cl(u);yield*El(u).pipe(D(e=>En(e,void 0)),or(()=>r>=o)),yield*Tl(u,t);let i=nn(n=>Bd(du(c,e),n).pipe(D(e=>O(h(e)).pipe(Bn(O(an(T(f)))),Bn(O(an(T(t)))))),D(S)));return yield*En(n,void 0).pipe(k(i),p(1),Fn(a)),yield*T(n),!(yield*on(f))})})})}),Cn({while:e=>e}),Fn(a));let g=C(El(l),Gr,Mn({onFailure:lu,onSuccess:Ge({onLeft:hu,onRight:e=>L(z(e),()=>g)})}),Hd);return ou(g,s)})),Fd=x(3,(e,t,n)=>Nd(n)(jd(e,t))),Id=x(2,(e,t)=>{function n(n){return un(function*(){let r=yield*wd(),i=kd(r),a=yield*Bd(du(i,e),n),o=yield*Bd(du(i,t.other),n);function s(e,t,r){return(i,a,o)=>{function s(e){let n=e;return n._tag===`Done`?M(R(k(rn(t),n.effect))):E(Wn(t),fi({onFailure:e=>R(n.f(ui(e))),onSuccess:Ge({onLeft:e=>R(n.f(pi(e))),onRight:e=>Jd(z(e),c(o(n.f)))})}))}return fi(e,{onFailure:e=>s(i(ui(e))),onSuccess:Ge({onLeft:e=>s(i(pi(e))),onRight:e=>M(L(z(e),()=>L(R(Fn(an(r),n)),e=>c(a(e,t)))))})})}}function c(e){switch(e._tag){case ed:{let n=an(Ir(e.left)),r=an(Ir(e.right));return Hd(vn(n,r,{onSelfDone:(n,r)=>k(rn(r),s(n,e.right,a)(t.onSelfDone,ad,e=>od(e))),onOtherDone:(n,r)=>k(rn(r),s(n,e.left,o)(t.onOtherDone,(e,t)=>ad(t,e),e=>sd(e)))}))}case td:return Hd(E(O(o),fi({onFailure:t=>R(e.f(ui(t))),onSuccess:Ge({onLeft:t=>R(e.f(pi(t))),onRight:t=>L(z(t),()=>c(od(e.f)))})})));case nd:return Hd(E(O(a),fi({onFailure:t=>R(e.f(ui(t))),onSuccess:Ge({onLeft:t=>R(e.f(pi(t))),onRight:t=>L(z(t),()=>c(sd(e.f)))})})))}}return R(kr(e=>{let t=kr(t=>(t.transferChildren(e.scope()),A));return qn(an(a).pipe(cr(t),Fn(n)),an(o).pipe(cr(t),Fn(n)),(e,t)=>ad(e,t))})).pipe(L(c),ou(r))})}return Wd(n)}),Ld=e=>Un(t=>Xu(e,t)),Rd=e=>Hd(Rr(t=>E($n(),n=>ru(Xn(t(Tr(e,n)),e=>Yn(n,ui(e))),(e,t)=>Yn(n,t))))),zd=e=>Ud(E(Vn,t=>L(R(e(t)),z))),Bd=x(2,(e,t)=>Cr(Nr(()=>new Ku(e,void 0,S)),Hn()).pipe(pr(([e,n])=>fr(t,t=>{let r=e.close(t);return r===void 0?A:Rn(r,n)})),br,E(([e])=>j(()=>Vd(e.run(),e))))),Vd=(e,t)=>{let n=e;switch(n._tag){case yu:return fi(t.getDone(),{onFailure:zr,onSuccess:e=>M(y(e))});case bu:return M(b(t.getEmit()));case xu:return C(n.effect,D(()=>Vd(t.run(),t)));case Su:return Yu(n,()=>Vd(t.run(),t),e=>zr(e))}},Hd=e=>Od(R(e)),Ud=e=>iu(Rd(e),(e,t)=>e,(e,t)=>e),Wd=e=>iu(zd(e),(e,t)=>e,(e,t)=>e),Gd=e=>Kd(0,e.length,e),Kd=(e,t,n)=>e===t?vu:C(z(C(n,ee(e))),L(()=>Kd(e+1,t,n))),qd=x(e=>nu(e[1]),(e,t,n)=>n?.concurrent?Id(e,{other:t,onSelfDone:e=>$u(t=>j(()=>_i(e,t))),onOtherDone:e=>$u(t=>j(()=>_i(t,e)))}):L(e,e=>Ad(t,t=>[e,t]))),Jd=x(e=>nu(e[1]),(e,t,n)=>n?.concurrent?Ad(qd(e,t,{concurrent:!0}),e=>e[1]):L(e,()=>t)),Yd=Symbol.for(`effect/Sink`),Xd={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e};var Zd=class{channel;[Yd]=Xd;constructor(e){this.channel=e}pipe(){return De(this,arguments)}};const Qd=e=>{let t=pu({onInput:n=>C(R(sn(n,t=>e(t),{discard:!0})),L(()=>t)),onFailure:lu,onDone:()=>vu});return new Zd(t)},$d=e=>new Zd(R(e)),ef=e=>Tn(e)?ef($d(e)):e.channel,tf=e=>new Zd(Ud(e.pipe(E(e=>ef(e))))),nf=yn,rf=e=>Object.assign(e,{chunk(e){return this(M(e))},die(e){return this(ir(e))},dieMessage(e){return this(Dr(e))},done(e){return this(j(()=>Si(e,{onFailure:w,onSuccess:ye})))},end(){return this(Gn(v()))},fail(e){return this(Gn(w(e)))},fromEffect(e){return this(gn(e,{onFailure:w,onSuccess:ye}))},fromEffectChunk(e){return this(C(e,bn(w)))},halt(e){return this(zr(C(e,ei(w))))},single(e){return this(M(ye(e)))}}),af=Symbol.for(`effect/Take`),of={_A:e=>e,_E:e=>e};var sf=class{exit;[af]=of;constructor(e){this.exit=e}pipe(){return De(this,arguments)}};const cf=e=>new sf(pi(e)),lf=e=>j(()=>e.exit),uf=new sf(hi(v())),df=e=>new sf(ui(C(e,ei(w)))),ff=e=>Mn(e,{onFailure:e=>_(ai(e),{onNone:()=>uf,onSome:df}),onSuccess:cf}),pf=x(2,(e,{onEnd:t,onFailure:n,onSuccess:r})=>fi(e.exit,{onFailure:e=>_(ai(e),{onNone:t,onSome:n}),onSuccess:r})),mf=()=>Gn(v()),hf=Symbol.for(`effect/Stream`),gf={_R:e=>e,_E:e=>e,_A:e=>e};var _f=class{channel;[hf]=gf;constructor(e){this.channel=e}pipe(){return De(this,arguments)}};const vf=e=>Nt(e,hf)||Tn(e),yf=e=>{if(e===`unbounded`)return Sl();if(typeof e==`number`||e===void 0)return yl(e??16);switch(e.strategy){case`dropping`:return bl(e.bufferSize??16);case`sliding`:return xl(e.bufferSize??16);default:return yl(e.bufferSize??16)}},bf=(e,t)=>C(jr(yf(t),e=>wl(e)),D(t=>C(Hn(),D(n=>C(e(rf(e=>C(ff(e),D(e=>Tl(t,e)),Pr,nf(n)).then(e=>{if(xi(e)&&!li(e.cause))throw oi(e.cause)}))),k(sr(!1)),D(e=>C(lr(e),E(n=>n?mf():C(El(t),D(lf),zn(()=>C(Br(e,!0),k(wl(t)))))))))))),Ff,Tf(Nf)),xf=x(2,(e,t)=>{if(t.strategy===`dropping`)return Sf(e,t.capacity);if(t.strategy===`sliding`)return Cf(e,t.capacity);let n=Lf(e,t);return new _f(Ud(E(n,e=>{let t=C(R(El(e)),L(pf({onEnd:()=>vu,onFailure:lu,onSuccess:e=>C(z(e),L(()=>t))})));return t})))}),Sf=x(2,(e,t)=>{let n=jr(bl(t),e=>wl(e));return new _f(wf(n,Af(e)))}),Cf=x(2,(e,t)=>{let n=jr(xl(t),e=>wl(e));return new _f(wf(n,Af(e)))}),wf=(e,t)=>{let n=(e,t)=>{let r=n=>C(lr(t),pr(T),k(hr()),D(r=>C(Tl(e,[n,r]),k(Br(t,r)),k(T(r)))),Pr,R);return pu({onInput:r=>C(hr(),D(n=>C(Tl(e,[cf(r),n]),D(e=>C(Br(t,n),or(()=>e))))),Pr,R,L(()=>n(e,t))),onFailure:e=>r(df(e)),onDone:()=>r(uf)})},r=e=>{let t=C(R(El(e)),L(([e,n])=>Jd(R(En(n,void 0)),pf(e,{onEnd:()=>vu,onFailure:lu,onSuccess:e=>C(z(e),L(()=>t))}))));return t};return Ud(C(e,D(e=>C(hr(),pr(e=>En(e,void 0)),D(i=>C(sr(i),D(r=>C(t,du(n(e,r)),Ld,pn)),wr(r(e))))))))},Tf=x(e=>vf(e[0]),(e,t,n)=>{let i=n?.bufferSize??16;return n?.switch?Ef(n?.concurrency,()=>Df(e,1,i,t),n=>Df(e,n,i,t)):Ef(n?.concurrency,()=>new _f(Td(Af(e),e=>C(e,d(e=>Af(t(e))),r(vu,(e,t)=>C(e,Jd(t)))))),r=>new _f(C(Af(e),Td(Gd),Fd(e=>Af(t(e)),n))))}),Ef=(e,t,n)=>{switch(e){case void 0:return t();case`unbounded`:return n(2**53-1);default:return e>1?n(e):t()}},Df=x(4,(e,t,n,r)=>new _f(C(Af(e),Td(Gd),Fd(e=>Af(r(e)),{concurrency:t,mergeStrategy:pd(),bufferSize:n})))),Of=x(e=>vf(e[0]),(e,t)=>Tf(e,S,t)),kf=e=>new _f(e),Af=e=>{if(`channel`in e)return e.channel;if(Tn(e))return Af(jf(e));throw TypeError(`Expected a Stream.`)},jf=e=>C(e,bn(w),Mf),Mf=e=>new _f(Hd(wn(e,{onFailure:_({onNone:()=>vu,onSome:cu}),onSuccess:e=>z(ye(e))}))),Nf=e=>Rf(e,e=>C(E(e,t=>w([t,e])),vr(_({onNone:()=>M(v()),onSome:Gn})))),Pf=x(2,(e,t)=>{let n=pu({onInput:e=>L(z(cf(e)),()=>n),onFailure:e=>z(df(e)),onDone:()=>z(uf)});return C(du(Af(e),n),Md(e=>Tl(t,e)),Ed,Ld,Pr)}),Ff=e=>new _f(Dd(Rd(C(e,E(ye))),A)),If=e=>new _f(gu(()=>Af(e()))),Lf=x(e=>vf(e[0]),(e,t)=>pr(jr(t?.strategy===`unbounded`?Sl():t?.strategy===`dropping`?bl(t.capacity??2):t?.strategy===`sliding`?xl(t.capacity??2):yl(t?.capacity??2),e=>wl(e)),t=>pn(Pf(e,t)))),Rf=(e,t)=>If(()=>{let n=e=>Hd(E(t(e),_({onNone:()=>vu,onSome:([e,t])=>L(z(e),()=>n(t))})));return new _f(n(e))}),zf=e=>Of(jf(e)),Bf=e=>Of(Ff(e)),Vf=L,Hf=vu,Uf=z,Wf=Ri,Gf=Bi,Kf=Vi,qf=Hi,Jf=Ui,Yf=Wi,Xf=Ki,Zf=qi,Qf=Yi,$f=Qi,ep=na,tp=ra,np=oa,rp=sa,ip=ca,ap=pa;Ze(`effect/DateTime/CurrentTimeZone`)();const op=ba,sp=Sa;var B=class{path;actual;issue;_tag=`Pointer`;constructor(e,t,n){this.path=e,this.actual=t,this.issue=n}},cp=class{actual;message;_tag=`Unexpected`;constructor(e,t){this.actual=e,this.message=t}},lp=class{ast;message;_tag=`Missing`;actual=void 0;constructor(e,t){this.ast=e,this.message=t}},V=class{ast;actual;issues;output;_tag=`Composite`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.issues=n,this.output=r}},up=class{ast;actual;kind;issue;_tag=`Refinement`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},dp=class{ast;actual;kind;issue;_tag=`Transformation`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},H=class{ast;actual;message;_tag=`Type`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}},fp=class{ast;actual;message;_tag=`Forbidden`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}};const pp=Symbol.for(`effect/Schema/ParseErrorTypeId`);var mp=class extends Oi(`ParseError`){[pp]=pp;get message(){return this.toString()}toString(){return Zp.formatIssueSync(this.issue)}toJSON(){return{_id:`ParseError`,message:this.toString()}}[s](){return this.toJSON()}};const hp=e=>new mp({issue:e}),U=b,gp=y,_p=n,vp=o,yp=Ie,bp=x(2,(e,t)=>yp(e)?Ge(e,{onLeft:y,onRight:t}):D(e,t)),xp=x(2,(e,t)=>yp(e)?It(e,t):E(e,t)),Sp=x(2,(e,t)=>yp(e)?Je(e,t):bn(e,t)),Cp=x(2,(e,t)=>yp(e)?le(e,{onLeft:t.onFailure,onRight:t.onSuccess}):gn(e,t)),wp=x(2,(e,t)=>yp(e)?Ge(e,{onLeft:t,onRight:b}):vr(e,t)),Tp=(e,t)=>t===void 0||Vt(t)?e:e===void 0?t:{...e,...t},Ep=(e,t,n)=>{let r=W(e,t);return(e,t)=>r(e,Tp(n,t))},Dp=(e,t,n)=>{let r=Ep(e,t,n);return(e,t)=>re(r(e,t),hp)},Op=(e,t,n)=>{let r=Ep(e,t,n);return(e,t)=>be(r(e,t))},kp=(e,t,n)=>{let r=W(e,t);return(e,t)=>r(e,{...Tp(n,t),isEffectAllowed:!0})},Ap=(e,t)=>Dp(e.ast,!0,t),jp=(e,t)=>Op(e.ast,!0,t),Mp=(e,t)=>kp(e.ast,!0,t),Np=(e,t)=>kp(e.ast,!1,t),Pp=Ap,Fp=(e,t)=>Dp(F(e.ast),!0,t),Ip=(e,t)=>{let n=W(F(e.ast),!0);return(e,r)=>te(n(e,{exact:!0,...Tp(t,r)}))},Lp=st(Symbol.for(`effect/ParseResult/decodeMemoMap`),()=>new WeakMap),Rp=st(Symbol.for(`effect/ParseResult/encodeMemoMap`),()=>new WeakMap),W=(e,t)=>{let n=t?Lp:Rp,r=n.get(e);if(r)return r;let i=Vp(e,t),a=zo(e),o=bt(a)?(e,t)=>i(e,Tp(t,a.value)):i,s=Bo(e),c=t&&bt(s)?(t,n)=>Kp(wp(o(t,n),s.value),e,t,n):o;return n.set(e,c),c},zp=e=>f(Io(e)),Bp=e=>f(Lo(e)),Vp=(n,r)=>{switch(n._tag){case`Refinement`:if(r){let e=W(n.from,!0);return(t,r)=>{r??=Ps;let i=r?.errors===`all`,a=bp(wp(e(t,r),e=>{let a=new up(n,t,`From`,e);return i&&Uo(n)&&om(e)?_(n.filter(t,r,n),{onNone:()=>y(a),onSome:e=>y(new V(n,t,[a,new up(n,t,`Predicate`,e)]))}):y(a)}),e=>_(n.filter(e,r,n),{onNone:()=>b(e),onSome:e=>y(new up(n,t,`Predicate`,e))}));return Kp(a,n,t,r)}}else{let e=W(F(n),!0),t=W(Gp(n.from),!1);return(r,i)=>Kp(bp(e(r,i),e=>t(e,i)),n,r,i)}case`Transformation`:{let e=Yp(n.transformation,r),t=r?W(n.from,!0):W(n.to,!1),i=r?W(n.to,!0):W(n.from,!1);return(a,o)=>Kp(bp(Sp(t(a,o),e=>new dp(n,a,r?`Encoded`:`Type`,e)),t=>bp(Sp(e(t,o??Ps,n,a),e=>new dp(n,a,`Transformation`,e)),e=>Sp(i(e,o),e=>new dp(n,a,r?`Type`:`Encoded`,e)))),n,a,o)}case`Declaration`:{let e=r?n.decodeUnknown(...n.typeParameters):n.encodeUnknown(...n.typeParameters);return(t,r)=>Kp(e(t,r??Ps,n),n,t,r)}case`Literal`:return Hp(n,e=>e===n.literal);case`UniqueSymbol`:return Hp(n,e=>e===n.symbol);case`UndefinedKeyword`:return Hp(n,Ht);case`NeverKeyword`:return Hp(n,e);case`UnknownKeyword`:case`AnyKeyword`:case`VoidKeyword`:return b;case`StringKeyword`:return Hp(n,Qe);case`NumberKeyword`:return Hp(n,Vt);case`BooleanKeyword`:return Hp(n,Ke);case`BigIntKeyword`:return Hp(n,oe);case`SymbolKeyword`:return Hp(n,At);case`ObjectKeyword`:return Hp(n,Dt);case`Enums`:return Hp(n,e=>n.enums.some(([t,n])=>n===e));case`TemplateLiteral`:{let e=qs(n);return Hp(n,t=>Qe(t)&&e.test(t))}case`TupleType`:{let e=n.elements.map(e=>W(e.type,r)),i=n.rest.map(e=>W(e.type,r)),a=n.elements.filter(e=>!e.isOptional);n.rest.length>0&&(a=a.concat(n.rest.slice(1)));let o=a.length,s=n.elements.length>0?n.elements.map((e,t)=>t).join(` | `):`never`,c=zp(n),l=Bp(n);return(r,u)=>{if(!Xe(r))return y(new H(n,r));let d=u?.errors===`all`,f=[],p=0,m=[],h=r.length;for(let e=h;e<=o-1;e++){let t=new B(e,r,new lp(a[e-h]));if(d){f.push([p++,t]);continue}else return y(new V(n,r,t,m))}if(n.rest.length===0)for(let e=n.elements.length;e<=h-1;e++){let t=new B(e,r,new cp(r[e],`is unexpected, expected: ${s}`));if(d){f.push([p++,t]);continue}else return y(new V(n,r,t,m))}let g=0,ee;for(;g<e.length;g++)if(h<g+1){if(n.elements[g].isOptional)continue}else{let t=e[g],i=t(r[g],u);if(yp(i)){if(He(i)){let e=new B(g,r,i.left);if(d){f.push([p++,e]);continue}else return y(new V(n,r,e,Jp(m)))}m.push([p++,i.right])}else{let e=p++,t=g;ee||=[],ee.push(({es:a,output:o})=>D(xr(i),i=>{if(He(i)){let s=new B(t,r,i.left);return d?(a.push([e,s]),A):y(new V(n,r,s,Jp(o)))}return o.push([e,i.right]),A}))}}if(t(i)){let[e,...t]=i;for(;g<h-t.length;g++){let t=e(r[g],u);if(yp(t))if(He(t)){let e=new B(g,r,t.left);if(d){f.push([p++,e]);continue}else return y(new V(n,r,e,Jp(m)))}else m.push([p++,t.right]);else{let e=p++,i=g;ee||=[],ee.push(({es:a,output:o})=>D(xr(t),t=>{if(He(t)){let s=new B(i,r,t.left);return d?(a.push([e,s]),A):y(new V(n,r,s,Jp(o)))}else return o.push([e,t.right]),A}))}}for(let e=0;e<t.length;e++){let i=g+e;if(!(h<i+1)){let a=t[e](r[i],u);if(yp(a)){if(He(a)){let e=new B(i,r,a.left);if(d){f.push([p++,e]);continue}else return y(new V(n,r,e,Jp(m)))}m.push([p++,a.right])}else{let e=p++;ee||=[],ee.push(({es:t,output:o})=>D(xr(a),a=>{if(He(a)){let s=new B(i,r,a.left);return d?(t.push([e,s]),A):y(new V(n,r,s,Jp(o)))}return o.push([e,a.right]),A}))}}}}let _=({es:e,output:t})=>Te(e)?y(new V(n,r,Jp(e),Jp(t))):b(Jp(t));if(ee&&ee.length>0){let e=ee;return j(()=>{let t={es:tn(f),output:tn(m)};return D(sn(e,e=>e(t),{concurrency:c,batching:l,discard:!0}),()=>_(t))})}return _({output:m,es:f})}}case`TypeLiteral`:{if(n.propertySignatures.length===0&&n.indexSignatures.length===0)return Hp(n,ut);let e=[],t={},i=[];for(let a of n.propertySignatures)e.push([W(a.type,r),a]),t[a.name]=null,i.push(a.name);let a=n.indexSignatures.map(e=>[W(e.parameter,r),W(e.type,r),e.parameter]),o=Es.make(n.indexSignatures.map(e=>e.parameter).concat(i.map(e=>At(e)?new Zo(e):new Yo(e)))),s=W(o,r),c=zp(n),l=Bp(n);return(r,u)=>{if(!Rt(r))return y(new H(n,r));let d=u?.errors===`all`,f=[],p=0,m=u?.onExcessProperty===`error`,h=u?.onExcessProperty===`preserve`,g={},ee;if(m||h){ee=Reflect.ownKeys(r);for(let e of ee){let t=s(e,u);if(yp(t)&&He(t))if(m){let t=new B(e,r,new cp(r[e],`is unexpected, expected: ${String(o)}`));if(d){f.push([p++,t]);continue}else return y(new V(n,r,t,g))}else g[e]=r[e]}}let _,ne=u?.exact===!0;for(let t=0;t<e.length;t++){let i=e[t][1],a=i.name,o=Object.prototype.hasOwnProperty.call(r,a);if(!o){if(i.isOptional)continue;if(ne){let e=new B(a,r,new lp(i));if(d){f.push([p++,e]);continue}else return y(new V(n,r,e,g))}}let s=e[t][0],c=s(r[a],u);if(yp(c)){if(He(c)){let e=new B(a,r,o?c.left:new lp(i));if(d){f.push([p++,e]);continue}else return y(new V(n,r,e,g))}g[a]=c.right}else{let e=p++,t=a;_||=[],_.push(({es:a,output:s})=>D(xr(c),c=>{if(He(c)){let l=new B(t,r,o?c.left:new lp(i));return d?(a.push([e,l]),A):y(new V(n,r,l,s))}return s[t]=c.right,A}))}}for(let e=0;e<a.length;e++){let i=a[e],o=i[0],s=i[1],c=Oa(r,i[2]);for(let e of c){let i=o(e,u);if(yp(i)&&te(i)){let i=s(r[e],u);if(yp(i))if(He(i)){let t=new B(e,r,i.left);if(d){f.push([p++,t]);continue}else return y(new V(n,r,t,g))}else Object.prototype.hasOwnProperty.call(t,e)||(g[e]=i.right);else{let a=p++,o=e;_||=[],_.push(({es:s,output:c})=>D(xr(i),i=>{if(He(i)){let e=new B(o,r,i.left);return d?(s.push([a,e]),A):y(new V(n,r,e,c))}else return Object.prototype.hasOwnProperty.call(t,e)||(c[e]=i.right),A}))}}}}let re=({es:e,output:t})=>{if(Te(e))return y(new V(n,r,Jp(e),t));if(u?.propertyOrder===`original`){let e=ee||Reflect.ownKeys(r);for(let t of i)e.indexOf(t)===-1&&e.push(t);let n={};for(let r of e)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return b(n)}return b(t)};if(_&&_.length>0){let e=_;return j(()=>{let t={es:tn(f),output:Object.assign({},g)};return D(sn(e,e=>e(t),{concurrency:c,batching:l,discard:!0}),()=>re(t))})}return re({es:f,output:g})}}case`Union`:{let e=Wp(n.types,r),t=Reflect.ownKeys(e.keys),i=t.length,a=n.types.length,o=new Map;for(let e=0;e<a;e++)o.set(n.types[e],W(n.types[e],r));let s=zp(n)??1,c=Bp(n);return(r,l)=>{let u=[],d=0,f=[];if(i>0)if(gt(r))for(let n=0;n<i;n++){let i=t[n],o=e.keys[i].buckets;if(Object.prototype.hasOwnProperty.call(r,i)){let t=String(r[i]);if(Object.prototype.hasOwnProperty.call(o,t))f=f.concat(o[t]);else{let{candidates:t,literals:n}=e.keys[i],o=Es.make(n),s=t.length===a?new vs([new P(i,o,!1,!0)],[]):Es.make(t);u.push([d++,new V(s,r,new B(i,r,new H(o,r[i])))])}}else{let{candidates:t,literals:n}=e.keys[i],o=new P(i,Es.make(n),!1,!0),s=t.length===a?new vs([o],[]):Es.make(t);u.push([d++,new V(s,r,new B(i,r,new lp(o)))])}}else{let t=e.candidates.length===a?n:Es.make(e.candidates);u.push([d++,new H(t,r)])}e.otherwise.length>0&&(f=f.concat(e.otherwise));let p;for(let e=0;e<f.length;e++){let t=f[e],n=o.get(t)(r,l);if(yp(n)&&(!p||p.length===0)){if(te(n))return n;u.push([d++,n.left])}else{let e=d++;p||=[],p.push(t=>j(()=>`finalResult`in t?A:D(xr(n),n=>(te(n)?t.finalResult=n:t.es.push([e,n.left]),A))))}}let m=e=>Te(e)?e.length===1&&e[0][1]._tag===`Type`?y(e[0][1]):y(new V(n,r,Jp(e))):y(new H(n,r));if(p&&p.length>0){let e=p;return j(()=>{let t={es:tn(u)};return D(sn(e,e=>e(t),{concurrency:s,batching:c,discard:!0}),()=>`finalResult`in t?t.finalResult:m(t.es))})}return m(u)}}case`Suspend`:{let e=ka(()=>W(n.f(),r));return(t,n)=>e()(t,n)}}},Hp=(e,t)=>n=>t(n)?b(n):y(new H(e,n)),Up=(e,t)=>{switch(e._tag){case`Declaration`:{let n=Vo(e);if(bt(n))return Up(n.value,t);break}case`TypeLiteral`:{let n=[];for(let r=0;r<e.propertySignatures.length;r++){let i=e.propertySignatures[r],a=t?tc(i.type):F(i.type);Xo(a)&&!i.isOptional&&n.push([i.name,a])}return n}case`TupleType`:{let n=[];for(let r=0;r<e.elements.length;r++){let i=e.elements[r],a=t?tc(i.type):F(i.type);Xo(a)&&!i.isOptional&&n.push([r,a])}return n}case`Refinement`:return Up(e.from,t);case`Suspend`:return Up(e.f(),t);case`Transformation`:return Up(t?e.from:e.to,t)}return[]},Wp=(e,t)=>{let n={},r=[],i=[];for(let a=0;a<e.length;a++){let o=e[a],s=Up(o,t);if(s.length>0){i.push(o);for(let e=0;e<s.length;e++){let[t,r]=s[e],i=String(r.literal);n[t]=n[t]||{buckets:{},literals:[],candidates:[]};let a=n[t].buckets;if(Object.prototype.hasOwnProperty.call(a,i)){if(e<s.length-1)continue;a[i].push(o),n[t].literals.push(r),n[t].candidates.push(o)}else{a[i]=[o],n[t].literals.push(r),n[t].candidates.push(o);break}}}else r.push(o)}return{keys:n,otherwise:r,candidates:i}},Gp=e=>Ns(e)?Gp(e.from):e,Kp=(e,t,n,r)=>{if(r?.isEffectAllowed===!0||yp(e))return e;let i=new Sr,a=Ar(e,{scheduler:i});i.flush();let o=a.unsafePoll();if(o){if(di(o))return b(o.value);let e=o.cause;return ri(e)?y(e.error):y(new fp(t,n,ti(e)))}return y(new fp(t,n,`cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work`))},qp=([e],[t])=>e>t?1:e<t?-1:0;function Jp(e){return e.sort(qp).map(e=>e[1])}const Yp=(e,t)=>{switch(e._tag){case`FinalTransformation`:return t?e.decode:e.encode;case`ComposeTransformation`:return b;case`TypeLiteralTransformation`:return n=>{let r=b(n);for(let n of e.propertySignatureTransformations){let[e,i]=t?[n.from,n.to]:[n.to,n.from],a=t?n.decode:n.encode;r=xp(r,t=>{let n=a(Object.prototype.hasOwnProperty.call(t,e)?w(t[e]):v());return delete t[e],bt(n)&&(t[i]=n.value),t})}return r}}},Xp=(e,t=[])=>({value:e,forest:t}),Zp={formatIssue:e=>xp(vm(e),Qp),formatIssueSync:e=>{let t=Zp.formatIssue(e);return yp(t)?ze(t):Sn(t)},formatError:e=>Zp.formatIssue(e.issue),formatErrorSync:e=>Zp.formatIssueSync(e.issue)},Qp=e=>e.value+$p(`
|
|
2
|
+
`,e.forest),$p=(e,t)=>{let n=``,r=t.length,i;for(let a=0;a<r;a++){i=t[a];let o=a===r-1;n+=e+(o?`└`:`├`)+`─ `+i.value,n+=$p(e+(r>1&&!o?`│ `:` `),i.forest)}return n},em=e=>{switch(e){case`Encoded`:return`Encoded side transformation failure`;case`Transformation`:return`Transformation process failure`;case`Type`:return`Type side transformation failure`}},tm=e=>{switch(e){case`From`:return`From side refinement failure`;case`Predicate`:return`Predicate refinement failure`}},nm=e=>`ast`in e?w(e.ast):v(),rm=b(void 0),im=e=>nm(e).pipe(Zt(Ao),_({onNone:()=>rm,onSome:t=>{let n=t(e);return Qe(n)?b({message:n,override:!1}):Tn(n)?E(n,e=>({message:e,override:!1})):Qe(n.message)?b({message:n.message,override:n.override}):E(n.message,e=>({message:e,override:n.override}))}})),am=e=>t=>t._tag===e,om=am(`Composite`),sm=am(`Refinement`),cm=am(`Transformation`),lm=e=>bp(im(e),t=>t===void 0?rm:!t.override&&(om(e)||sm(e)&&e.kind===`From`||cm(e)&&e.kind!==`Transformation`)?cm(e)||sm(e)?lm(e.issue):rm:b(t.message)),um=e=>nm(e).pipe(Zt(Ro),ke(t=>t(e)),f);function dm(e){return Fo(e).pipe(pe(()=>Mo(e)),pe(()=>No(e)),pe(()=>Po(e)),Ne(()=>`{ ${e.from} | filter }`))}function fm(e){return e.message===void 0?`Expected ${Ns(e.ast)?dm(e.ast):String(e.ast)}, actual ${l(e.actual)}`:e.message}const pm=e=>xp(lm(e),t=>t??um(e)??fm(e)),mm=e=>um(e)??String(e.ast),hm=e=>e.message??`is forbidden`,gm=e=>e.message??`is unexpected`,_m=e=>{let t=jo(e.ast);if(bt(t)){let e=t.value();return Qe(e)?b(e):e}return b(e.message??`is missing`)},vm=e=>{switch(e._tag){case`Type`:return xp(pm(e),Xp);case`Forbidden`:return b(Xp(mm(e),[Xp(hm(e))]));case`Unexpected`:return b(Xp(gm(e)));case`Missing`:return xp(_m(e),Xp);case`Transformation`:return bp(lm(e),t=>t===void 0?xp(vm(e.issue),t=>Xp(mm(e),[Xp(em(e.kind),[t])])):b(Xp(t)));case`Refinement`:return bp(lm(e),t=>t===void 0?xp(vm(e.issue),t=>Xp(mm(e),[Xp(tm(e.kind),[t])])):b(Xp(t)));case`Pointer`:return xp(vm(e.issue),t=>Xp(Na(e.path),[t]));case`Composite`:return bp(lm(e),t=>{if(t!==void 0)return b(Xp(t));let n=mm(e);return Aa(e.issues)?xp(sn(e.issues,vm),e=>Xp(n,e)):xp(vm(e.issues),e=>Xp(n,[e]))})}},ym=x(e=>Dt(e[0]),(e,...t)=>{let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}),bm=x(e=>Dt(e[0]),(e,...t)=>{let n={...e};for(let e of t)delete n[e];return n}),xm=Symbol.for(`effect/Schema`);function G(e){return class{[xm]=Sm;static ast=e;static annotations(e){return G(Tm(this.ast,e))}static pipe(){return De(this,arguments)}static toString(){return String(e)}static Type;static Encoded;static Context;static[xm]=Sm}}const Sm={_A:e=>e,_I:e=>e,_R:e=>e},Cm={typeConstructor:ao,schemaId:so,message:co,missingMessage:lo,identifier:uo,title:fo,description:mo,examples:ho,default:go,documentation:xo,jsonSchema:_o,arbitrary:vo,pretty:yo,equivalence:bo,concurrency:So,batching:Co,parseIssueTitle:wo,parseOptions:To,decodingFallback:Eo},wm=e=>{if(!e)return{};let t={...e};for(let n in Cm)if(n in e){let r=Cm[n];t[r]=e[n],delete t[n]}return t},Tm=(e,t)=>Us(e,wm(t)),Em=e=>String(e.ast),Dm=e=>G(tc(e.ast)),Om=e=>G(F(e.ast)),km=(e,t)=>{let n=Mp(e,t);return(e,t)=>Sp(n(e,t),hp)},Am=e=>Nt(e,xm)&&Dt(e[xm]);function jm(e){return Os(e)?Es.make(Ds(e,e=>new Yo(e))):new Yo(e[0])}function Mm(e,t=jm(e)){return class extends G(t){static annotations(e){return Mm(this.literals,Tm(this.ast,e))}static literals=[...e]}}function Nm(...e){return t(e)?Mm(e):Vm}const Pm=(e,t,n)=>Im(e,new qo(e.map(e=>e.ast),(...e)=>t.decode(...e.map(G)),(...e)=>t.encode(...e.map(G)),wm(n))),Fm=(e,t)=>{let n=()=>(t,n,r)=>e(t)?U(t):gp(new H(r,t));return Im([],new qo([],n,n,wm(t)))};function Im(e,t){return class extends G(t){static annotations(e){return Im(this.typeParameters,Tm(this.ast,e))}static typeParameters=[...e]}}const Lm=function(){if(Array.isArray(arguments[0])){let e=arguments[0],t=arguments[1],n=arguments[2];return Pm(e,t,n)}let e=arguments[0],t=arguments[1];return Fm(e,t)},Rm=Symbol.for(`effect/SchemaId/InstanceOf`),zm=(e,t)=>Lm(t=>t instanceof e,{title:e.name,description:`an instance of ${e.name}`,pretty:()=>String,schemaId:Rm,[Rm]:{constructor:e},...t});var Bm=class extends G(Qo){},Vm=class extends G($o){},Hm=class extends G(es){},Um=class extends G(cs){},Wm=class extends G(ls){},K=class extends G(ns){},q=class extends G(is){},Gm=class extends G(os){};const Km=e=>Es.make(e.map(e=>e.ast));function qm(e,t=Km(e)){return class extends G(t){static annotations(e){return qm(this.members,Tm(this.ast,e))}static members=[...e]}}function Jm(...e){return Os(e)?qm(e):t(e)?e[0]:Vm}const Ym=e=>Jm(e,Bm),Xm=e=>new Zm(new fs(e.ast,!1),e);var Zm=class e{ast;from;[xm];_Token;constructor(e,t){this.ast=e,this.from=t}annotations(t){return new e(new fs(this.ast.type,this.ast.isOptional,{...this.ast.annotations,...wm(t)}),this.from)}toString(){return`${this.ast.type}${this.ast.isOptional?`?`:``}`}};const Qm=(e,t)=>new ms(e.map(e=>Am(e)?new fs(e.ast,!1):e.ast),t.map(e=>Am(e)?new ds(e.ast):e.ast),!0);function $m(e,t,n=Qm(e,t)){return class extends G(n){static annotations(e){return $m(this.elements,this.rest,Tm(this.ast,e))}static elements=[...e];static rest=[...t]}}function eh(...e){return Array.isArray(e[0])?$m(e[0],e.slice(1)):$m(e,[])}function th(e,t){return class extends $m([],[e],t){static annotations(e){return th(this.value,Tm(this.ast,e))}static value=e}}const nh=e=>th(e),rh=e=>e?`"?:"`:`":"`;var ih=class extends fs{isReadonly;defaultValue;_tag=`PropertySignatureDeclaration`;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.defaultValue=i}toString(){let e=rh(this.isOptional),t=String(this.type);return`PropertySignature<${e}, ${t}, never, ${e}, ${t}>`}};(class extends fs{isReadonly;fromKey;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.fromKey=i}});var ah=class extends fs{isReadonly;defaultValue;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.defaultValue=i}};const oh=e=>e===void 0?`never`:Qe(e)?JSON.stringify(e):String(e);var sh=class{from;to;decode;encode;_tag=`PropertySignatureTransformation`;constructor(e,t,n,r){this.from=e,this.to=t,this.decode=n,this.encode=r}toString(){return`PropertySignature<${rh(this.to.isOptional)}, ${this.to.type}, ${oh(this.from.fromKey)}, ${rh(this.from.isOptional)}, ${this.from.type}>`}};const ch=(e,t)=>{switch(e._tag){case`PropertySignatureDeclaration`:return new ih(e.type,e.isOptional,e.isReadonly,{...e.annotations,...t},e.defaultValue);case`PropertySignatureTransformation`:return new sh(e.from,new ah(e.to.type,e.to.isOptional,e.to.isReadonly,{...e.to.annotations,...t},e.to.defaultValue),e.decode,e.encode)}},lh=Symbol.for(`effect/PropertySignature`),uh=e=>Nt(e,lh);var dh=class e{ast;[xm];[lh]=null;_TypeToken;_Key;_EncodedToken;_HasDefault;constructor(e){this.ast=e}pipe(){return De(this,arguments)}annotations(t){return new e(ch(this.ast,wm(t)))}toString(){return String(this.ast)}};const fh=e=>new dh(e);var ph=class e extends dh{from;constructor(e,t){super(e),this.from=t}annotations(t){return new e(ch(this.ast,wm(t)),this.from)}};const mh=e=>new ph(new ih(e.ast,!1,!0,{},void 0),e),hh=x(2,(e,t)=>{let n=e.ast;switch(n._tag){case`PropertySignatureDeclaration`:return fh(new ih(n.type,n.isOptional,n.isReadonly,n.annotations,t));case`PropertySignatureTransformation`:return fh(new sh(n.from,new ah(n.to.type,n.to.isOptional,n.to.isReadonly,n.to.annotations,t),n.decode,n.encode))}}),gh=e=>new ph(new ih(e.ast===Qo||e.ast===$o?Qo:Ym(e).ast,!0,!0,{},void 0),e),_h=Ys([lo]),vh=(e,n)=>{let r=Reflect.ownKeys(e),i=[];if(r.length>0){let a=[],o=[],s=[];for(let t=0;t<r.length;t++){let n=r[t],c=e[n];if(uh(c)){let e=c.ast;switch(e._tag){case`PropertySignatureDeclaration`:{let t=e.type,r=e.isOptional,s=e.annotations;a.push(new P(n,t,r,!0,_h(e))),o.push(new P(n,F(t),r,!0,s)),i.push(new P(n,t,r,!0,s));break}case`PropertySignatureTransformation`:{let t=e.from.fromKey??n;a.push(new P(t,e.from.type,e.from.isOptional,!0,e.from.annotations)),o.push(new P(n,e.to.type,e.to.isOptional,!0,e.to.annotations)),s.push(new Bs(t,n,e.decode,e.encode));break}}}else a.push(new P(n,c.ast,!1,!0)),o.push(new P(n,F(c.ast),!1,!0)),i.push(new P(n,c.ast,!1,!0))}if(t(s)){let e=[],t=[];for(let r of n){let{indexSignatures:n,propertySignatures:i}=Js(r.key.ast,r.value.ast);i.forEach(e=>{a.push(e),o.push(new P(e.name,F(e.type),e.isOptional,e.isReadonly,e.annotations))}),n.forEach(n=>{e.push(n),t.push(new _s(n.parameter,F(n.type),n.isReadonly))})}return new Fs(new vs(a,e,{[po]:`Struct (Encoded side)`}),new vs(o,t,{[po]:`Struct (Type side)`}),new Vs(s))}}let a=[];for(let e of n){let{indexSignatures:t,propertySignatures:n}=Js(e.key.ast,e.value.ast);n.forEach(e=>i.push(e)),t.forEach(e=>a.push(e))}return new vs(i,a)},yh=(e,t)=>{let n=Reflect.ownKeys(e);for(let r of n){let n=e[r];if(t[r]===void 0&&uh(n)){let e=n.ast,i=e._tag===`PropertySignatureDeclaration`?e.defaultValue:e.to.defaultValue;i!==void 0&&(t[r]=i())}}return t};function bh(e,t,n=vh(e,t)){return class extends G(n){static annotations(e){return bh(this.fields,this.records,Tm(this.ast,e))}static fields={...e};static records=[...t];static make=(t,n)=>{let r=yh(e,{...t});return L_(n)?r:Fp(this)(r)};static pick(...t){return J(ym(e,...t))}static omit(...t){return J(bm(e,...t))}}}function J(e,...t){return bh(e,t)}const xh=e=>Nm(e).pipe(mh,hh(()=>e)),Sh=(e,t)=>J({_tag:xh(e),...t});function Ch(e,t,n){return class extends bh({},[{key:e,value:t}],n){static annotations(n){return Ch(e,t,Tm(this.ast,n))}static key=e;static value=t}}const wh=e=>Ch(e.key,e.value);function Th(e,t){return class extends G(t){static annotations(e){return Th(this.from,Tm(this.ast,e))}static make=(e,t)=>L_(t)?e:Fp(this)(e);static from=e}}const Eh=(e,t)=>n=>{let r=_(ko(n.ast),{onNone:()=>[e],onSome:t=>[...t,e]});return Th(n,Us(n.ast,wm({[oo]:r,...t})))},Dh=(e,t,n)=>{if(xs(e)&&xs(t)){let r=[...e.propertySignatures];for(let e of t.propertySignatures){let t=e.name,i=r.findIndex(e=>e.name===t);if(i===-1)r.push(e);else{let{isOptional:a,type:o}=r[i];r[i]=new P(t,Ah(o,e.type,n.concat(t)),a,!0)}}return new vs(r,e.indexSignatures.concat(t.indexSignatures))}throw Error(Ia(e,t,n))},Oh=Xs([uo]),kh=(e,t)=>t.map(t=>new Ms(t,e.filter,Oh(e))),Ah=(e,t,n)=>Es.make(Mh([e],[t],n)),jh=e=>ks(e)?e.types:[e],Mh=(e,t,n)=>Ve(e,e=>Ve(t,t=>{switch(t._tag){case`Literal`:if(Qe(t.literal)&&rs(e)||Vt(t.literal)&&as(e)||Ke(t.literal)&&ss(e))return[t];break;case`StringKeyword`:if(t===ns){if(rs(e)||Xo(e)&&Qe(e.literal))return[e];if(Ns(e))return kh(e,Mh(jh(e.from),[t],n))}else if(e===ns)return[t];break;case`NumberKeyword`:if(t===is){if(as(e)||Xo(e)&&Vt(e.literal))return[e];if(Ns(e))return kh(e,Mh(jh(e.from),[t],n))}else if(e===is)return[t];break;case`BooleanKeyword`:if(t===os){if(ss(e)||Xo(e)&&Ke(e.literal))return[e];if(Ns(e))return kh(e,Mh(jh(e.from),[t],n))}else if(e===os)return[t];break;case`Union`:return Mh(jh(e),t.types,n);case`Suspend`:return[new js(()=>Ah(e,t.f(),n))];case`Refinement`:return kh(t,Mh(jh(e),jh(t.from),n));case`TypeLiteral`:switch(e._tag){case`Union`:return Mh(e.types,[t],n);case`Suspend`:return[new js(()=>Ah(e.f(),t,n))];case`Refinement`:return kh(e,Mh(jh(e.from),[t],n));case`TypeLiteral`:return[Dh(e,t,n)];case`Transformation`:{let r=e.transformation,i=Dh(e.from,t,n),a=Dh(e.to,F(t),n);switch(r._tag){case`TypeLiteralTransformation`:return[new Fs(i,a,new Vs(r.propertySignatureTransformations))];case`ComposeTransformation`:return[new Fs(i,a,zs)];case`FinalTransformation`:return[new Fs(i,a,new Ls((e,t,n,i)=>xp(r.decode(e,t,n,i),t=>({...e,...t})),(e,t,n,i)=>xp(r.encode(e,t,n,i),t=>({...e,...t}))))]}}}break;case`Transformation`:if(Is(e)){if(Hs(t.transformation)&&Hs(e.transformation))return[new Fs(Dh(e.from,t.from,n),Dh(e.to,t.to,n),new Vs(t.transformation.propertySignatureTransformations.concat(e.transformation.propertySignatureTransformations)))]}else return Mh([t],[e],n);break}throw Error(Ia(e,t,n))})),Nh=x(2,(e,t)=>G(Ah(e.ast,t.ast,[]))),Ph=e=>G(new js(()=>e().ast)),Fh=Symbol.for(`effect/SchemaId/Refine`);function Ih(e,t,n){return class extends G(n){static annotations(e){return Ih(this.from,this.filter,Tm(this.ast,e))}static[Fh]=e;static from=e;static filter=t;static make=(e,t)=>L_(t)?e:Fp(this)(e)}}const Lh=(e,n,r)=>{if(Ke(e))return e?v():w(new H(n,r));if(Qe(e))return w(new H(n,r,e));if(e!==void 0){if(`_tag`in e)return w(e);let i=new H(n,r,e.message);return w(t(e.path)?new B(e.path,r,i):i)}return v()},Rh=(e,n,r)=>{if(ja(e))return Lh(e,n,r);if(t(e)){let i=Fe(e,e=>Lh(e,n,r));if(t(i))return w(i.length===1?i[0]:new V(n,r,i))}return v()};function Y(e,t){return n=>{function r(t,n,r){return Rh(e(t,n,r),r,t)}return Ih(n,r,new Ms(n.ast,r,wm(t)))}}function zh(e,t,n){return class extends G(n){static annotations(e){return zh(this.from,this.to,Tm(this.ast,e))}static from=e;static to=t}}const X=x(e=>Am(e[0])&&Am(e[1]),(e,t,n)=>zh(e,t,new Fs(e.ast,t.ast,new Ls(n.decode,n.encode)))),Z=x(e=>Am(e[0])&&Am(e[1]),(e,t,n)=>X(e,t,{strict:!0,decode:(e,t,r,i)=>U(n.decode(e,i)),encode:(e,t,r,i)=>U(n.encode(e,i))})),Bh=x(2,(e,t)=>e.annotations(t)),Vh=Symbol.for(`effect/SchemaId/Trimmed`),Hh=e=>t=>t.pipe(Y(e=>e===e.trim(),{schemaId:Vh,title:`trimmed`,description:`a string with no leading or trailing whitespace`,jsonSchema:{pattern:`^\\S[\\s\\S]*\\S$|^\\S$|^$`},...e})),Uh=no,Wh=(e,t)=>n=>n.pipe(Y(t=>t.length>=e,{schemaId:Uh,title:`minLength(${e})`,description:`a string at least ${e} character(s) long`,jsonSchema:{minLength:e},...t})),Gh=ro,Kh=(e,t)=>n=>{let r=Dt(e)?Math.max(0,Math.floor(e.min)):Math.max(0,Math.floor(e)),i=Dt(e)?Math.max(r,Math.floor(e.max)):r;return r===i?n.pipe(Y(e=>e.length===r,{schemaId:Gh,title:`length(${r})`,description:r===1?`a single character`:`a string ${r} character(s) long`,jsonSchema:{minLength:r,maxLength:r},...t})):n.pipe(Y(e=>e.length>=r&&e.length<=i,{schemaId:Gh,title:`length({ min: ${r}, max: ${i})`,description:`a string at least ${r} character(s) and at most ${i} character(s) long`,jsonSchema:{minLength:r,maxLength:i},...t}))},qh=Symbol.for(`effect/SchemaId/Pattern`),Jh=(e,t)=>n=>{let r=e.source;return n.pipe(Y(t=>(e.lastIndex=0,e.test(t)),{schemaId:qh,[qh]:{regex:e},description:`a string matching the pattern ${r}`,jsonSchema:{pattern:r},...t}))},Yh=Symbol.for(`effect/SchemaId/Lowercased`),Xh=e=>t=>t.pipe(Y(e=>e===e.toLowerCase(),{schemaId:Yh,title:`lowercased`,description:`a lowercase string`,jsonSchema:{pattern:`^[^A-Z]*$`},...e}));var Zh=class extends K.pipe(Xh({identifier:`Lowercased`})){};const Qh=Symbol.for(`effect/SchemaId/Uppercased`),$h=e=>t=>t.pipe(Y(e=>e===e.toUpperCase(),{schemaId:Qh,title:`uppercased`,description:`an uppercase string`,jsonSchema:{pattern:`^[^a-z]*$`},...e}));var eg=class extends K.pipe($h({identifier:`Uppercased`})){};const tg=Symbol.for(`effect/SchemaId/Capitalized`),ng=e=>t=>t.pipe(Y(e=>e[0]?.toUpperCase()===e[0],{schemaId:tg,title:`capitalized`,description:`a capitalized string`,jsonSchema:{pattern:`^[^a-z]?.*$`},...e}));var rg=class extends K.pipe(ng({identifier:`Capitalized`})){};const ig=Symbol.for(`effect/SchemaId/Uncapitalized`),ag=e=>t=>t.pipe(Y(e=>e[0]?.toLowerCase()===e[0],{schemaId:ig,title:`uncapitalized`,description:`a uncapitalized string`,jsonSchema:{pattern:`^[^A-Z]?.*$`},...e}));var og=class extends K.pipe(ag({identifier:`Uncapitalized`})){};K.pipe(Kh(1,{identifier:`Char`}));const sg=e=>Wh(1,{title:`nonEmptyString`,description:`a non empty string`,...e});Z(K.annotations({description:`a string that will be converted to lowercase`}),Zh,{strict:!0,decode:e=>e.toLowerCase(),encode:S}).annotations({identifier:`Lowercase`}),Z(K.annotations({description:`a string that will be converted to uppercase`}),eg,{strict:!0,decode:e=>e.toUpperCase(),encode:S}).annotations({identifier:`Uppercase`}),Z(K.annotations({description:`a string that will be converted to a capitalized format`}),rg,{strict:!0,decode:e=>Ta(e),encode:S}).annotations({identifier:`Capitalize`}),Z(K.annotations({description:`a string that will be converted to an uncapitalized format`}),og,{strict:!0,decode:e=>Ea(e),encode:S}).annotations({identifier:`Uncapitalize`});var cg=class extends K.pipe(Hh({identifier:`Trimmed`})){},lg=class extends cg.pipe(sg({identifier:`NonEmptyTrimmedString`})){};Z(K.annotations({description:`a string that will be trimmed`}),cg,{strict:!0,decode:e=>e.trim(),encode:S}).annotations({identifier:`Trim`});const ug=e=>e instanceof Error?e.message:String(e);K.pipe(sg({identifier:`NonEmptyString`}));const dg=Symbol.for(`effect/SchemaId/UUID`),fg=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i;K.pipe(Jh(fg,{schemaId:dg,identifier:`UUID`,jsonSchema:{format:`uuid`,pattern:fg.source},description:`a Universally Unique Identifier`,arbitrary:()=>e=>e.uuid()}));const pg=Symbol.for(`effect/SchemaId/ULID`);K.pipe(Jh(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i,{schemaId:pg,identifier:`ULID`,description:`a Universally Unique Lexicographically Sortable Identifier`,arbitrary:()=>e=>e.ulid()}));var mg=class extends zm(URL,{typeConstructor:{_tag:`URL`},identifier:`URLFromSelf`,arbitrary:()=>e=>e.webUrl().map(e=>new URL(e)),pretty:()=>e=>e.toString()}){};X(K.annotations({description:`a string to be decoded into a URL`}),mg,{strict:!0,decode:(e,t,n)=>_p({try:()=>new URL(e),catch:t=>new H(n,e,`Unable to decode ${JSON.stringify(e)} into a URL. ${ug(t)}`)}),encode:e=>U(e.toString())}).annotations({identifier:`URL`,pretty:()=>e=>e.toString()});const hg=Za,gg=e=>t=>t.pipe(Y(Number.isFinite,{schemaId:hg,title:`finite`,description:`a finite number`,jsonSchema:{},...e})),_g=Ga,vg=(e,t)=>n=>n.pipe(Y(t=>t>e,{schemaId:_g,title:`greaterThan(${e})`,description:e===0?`a positive number`:`a number greater than ${e}`,jsonSchema:{exclusiveMinimum:e},...t})),yg=Ka,bg=(e,t)=>n=>n.pipe(Y(t=>t>=e,{schemaId:yg,title:`greaterThanOrEqualTo(${e})`,description:e===0?`a non-negative number`:`a number greater than or equal to ${e}`,jsonSchema:{minimum:e},...t})),xg=Ya,Sg=e=>t=>t.pipe(Y(e=>Number.isSafeInteger(e),{schemaId:xg,title:`int`,description:`an integer`,jsonSchema:{type:`integer`},...e})),Cg=qa,wg=(e,t)=>n=>n.pipe(Y(t=>t<e,{schemaId:Cg,title:`lessThan(${e})`,description:e===0?`a negative number`:`a number less than ${e}`,jsonSchema:{exclusiveMaximum:e},...t})),Tg=Ja,Eg=(e,t)=>n=>n.pipe(Y(t=>t<=e,{schemaId:Tg,title:`lessThanOrEqualTo(${e})`,description:e===0?`a non-positive number`:`a number less than or equal to ${e}`,jsonSchema:{maximum:e},...t})),Dg=$a,Og=(e,t,n)=>r=>r.pipe(Y(n=>n>=e&&n<=t,{schemaId:Dg,title:`between(${e}, ${t})`,description:`a number between ${e} and ${t}`,jsonSchema:{minimum:e,maximum:t},...n})),kg=Xa,Ag=e=>t=>t.pipe(Y(e=>!Number.isNaN(e),{schemaId:kg,title:`nonNaN`,description:`a number excluding NaN`,...e})),jg=e=>vg(0,{title:`positive`,...e}),Mg=e=>wg(0,{title:`negative`,...e}),Ng=e=>Eg(0,{title:`nonPositive`,...e}),Pg=e=>bg(0,{title:`nonNegative`,...e});function Fg(e){return X(e,q,{strict:!1,decode:(e,t,n)=>vp(mn(e),()=>new H(n,e,`Unable to decode ${JSON.stringify(e)} into a number`)),encode:e=>U(String(e))})}Fg(K.annotations({description:`a string to be decoded into a number`})).annotations({identifier:`NumberFromString`}),q.pipe(gg({identifier:`Finite`}));var Ig=class extends q.pipe(Sg({identifier:`Int`})){};q.pipe(Ag({identifier:`NonNaN`})),q.pipe(jg({identifier:`Positive`})),q.pipe(Mg({identifier:`Negative`})),q.pipe(Ng({identifier:`NonPositive`}));var Lg=class extends q.pipe(Pg({identifier:`NonNegative`})){};const Rg=Qa;q.pipe(gg({schemaId:Rg,identifier:`JsonNumber`})),Z(Gm.annotations({description:`a boolean that will be negated`}),Gm,{strict:!0,decode:e=>cn(e),encode:e=>cn(e)});const zg=(e,t)=>{let n=Symbol.keyFor(e);return n===void 0?gp(new H(t,e,`Unable to encode a unique symbol ${String(e)} into a string`)):U(n)},Bg=e=>U(Symbol.for(e));X(K.annotations({description:`a string to be decoded into a globally shared symbol`}),Wm,{strict:!1,decode:e=>Bg(e),encode:(e,t,n)=>zg(e,n)}).annotations({identifier:`Symbol`});const Vg=eo,Hg=(e,t)=>n=>n.pipe(Y(t=>t>=e,{schemaId:Vg,[Vg]:{min:e},title:`greaterThanOrEqualToBigInt(${e})`,description:e===0n?`a non-negative bigint`:`a bigint greater than or equal to ${e}n`,...t})),Ug=to,Wg=(e,t,n)=>r=>r.pipe(Y(n=>n>=e&&n<=t,{schemaId:Ug,[Ug]:{min:e,max:t},title:`betweenBigInt(${e}, ${t})`,description:`a bigint between ${e}n and ${t}n`,...n})),Gg=e=>Hg(0n,{title:`nonNegativeBigInt`,...e});var Kg=class extends X(K.annotations({description:`a string to be decoded into a bigint`}),Um,{strict:!0,decode:(e,t,n)=>vp(Ac(e),()=>new H(n,e,`Unable to decode ${JSON.stringify(e)} into a bigint`)),encode:e=>U(String(e))}).annotations({identifier:`BigInt`}){};const qg=Um.pipe(Gg({identifier:`NonNegativeBigintFromSelf`}));X(q.annotations({description:`a number to be decoded into a bigint`}),Um.pipe(Wg(BigInt(-(2**53-1)),BigInt(2**53-1))),{strict:!0,decode:(e,t,n)=>vp(jc(e),()=>new H(n,e,`Unable to decode ${e} into a bigint`)),encode:(e,t,n)=>vp(kc(e),()=>new H(n,e,`Unable to encode ${e}n into a number`))}).annotations({identifier:`BigIntFromNumber`});const Jg=(e,t,n,r)=>Cp(e,{onFailure:e=>new V(n,r,e),onSuccess:t});var Yg=class extends Lm(se,{typeConstructor:{_tag:`effect/Duration`},identifier:`DurationFromSelf`,pretty:()=>String,arbitrary:()=>e=>e.oneof(e.constant(Pt),e.bigInt({min:0n}).map(e=>we(e)),e.maxSafeNat().map(e=>Ye(e))),equivalence:()=>Be}){};X(qg.annotations({description:`a bigint to be decoded into a Duration`}),Yg.pipe(Y(e=>qe(e),{description:`a finite duration`})),{strict:!0,decode:e=>U(we(e)),encode:(e,t,n)=>_(Bt(e),{onNone:()=>gp(new H(n,e,`Unable to encode ${e} into a bigint`)),onSome:e=>U(e)})}).annotations({identifier:`DurationFromNanos`});const Xg=Lg.pipe(Sg()).annotations({identifier:`NonNegativeInt`});Z(Lg.annotations({description:`a non-negative number to be decoded into a Duration`}),Yg,{strict:!0,decode:e=>Ye(e),encode:e=>lt(e)}).annotations({identifier:`DurationFromMillis`});const Zg=Sh(`Millis`,{millis:Xg}),Qg=Sh(`Nanos`,{nanos:Kg}),$g=Sh(`Infinity`,{}),e_=$g.make({}),t_=Jm(Zg,Qg,$g).annotations({identifier:`DurationValue`,description:`an JSON-compatible tagged union to be decoded into a Duration`}),n_=Jm(eh(Xm(Xg).annotations({title:`seconds`}),Xm(Xg).annotations({title:`nanos`})).annotations({identifier:`FiniteHRTime`}),eh(Nm(-1),Nm(0)).annotations({identifier:`InfiniteHRTime`})).annotations({identifier:`HRTime`,description:`a tuple of seconds and nanos to be decoded into a Duration`}),r_=e=>typeof e==`object`;Z(Jm(t_,n_),Yg,{strict:!0,decode:e=>{if(r_(e))switch(e._tag){case`Millis`:return Ye(e.millis);case`Nanos`:return we(e.nanos);case`Infinity`:return Pt}let[t,n]=e;return t===-1?Pt:we(BigInt(t)*BigInt(1e9)+BigInt(n))},encode:e=>{switch(e.value._tag){case`Millis`:return Zg.make({millis:e.value.millis});case`Nanos`:return Qg.make({nanos:e.value.nanos});case`Infinity`:return e_}}}).annotations({identifier:`Duration`});var i_=class extends Lm(Et,{typeConstructor:{_tag:`Uint8Array`},identifier:`Uint8ArrayFromSelf`,pretty:()=>e=>`new Uint8Array(${JSON.stringify(Array.from(e))})`,arbitrary:()=>e=>e.uint8Array(),equivalence:()=>Ft(vt)}){};Z(nh(class extends q.pipe(Og(0,255,{identifier:`Uint8`,description:`a 8-bit unsigned integer`})){}).annotations({description:`an array of 8-bit unsigned integers to be decoded into a Uint8Array`}),i_,{strict:!0,decode:e=>Uint8Array.from(e),encode:e=>Array.from(e)}).annotations({identifier:`Uint8Array`});const a_=io,o_=(e,t)=>n=>{let r=Math.floor(e);if(r<1)throw Error(Fa(`Expected an integer greater than or equal to 1, actual ${e}`));return n.pipe(Y(e=>e.length>=r,{schemaId:a_,title:`minItems(${r})`,description:`an array of at least ${r} item(s)`,jsonSchema:{minItems:r},[Oo]:!0,...t}))},s_=Symbol.for(`effect/SchemaId/ValidDate`),c_=e=>t=>t.pipe(Y(e=>!Number.isNaN(e.getTime()),{schemaId:s_,[s_]:{noInvalidDate:!0},title:`validDate`,description:`a valid Date`,...e})),l_=Wa;var u_=class extends Lm(Ue,{typeConstructor:{_tag:`Date`},identifier:`DateFromSelf`,schemaId:l_,[l_]:{noInvalidDate:!1},description:`a potentially invalid Date instance`,pretty:()=>e=>`new Date(${JSON.stringify(e)})`,arbitrary:()=>e=>e.date({noInvalidDate:!1}),equivalence:()=>dt}){};u_.pipe(c_({identifier:`ValidDateFromSelf`,description:`a valid Date instance`})),class extends Z(K.annotations({description:`a string to be decoded into a Date`}),u_,{strict:!0,decode:e=>new Date(e),encode:e=>Ae(e)}).annotations({identifier:`DateFromString`}){}.pipe(c_({identifier:`Date`})),Z(q.annotations({description:`a number to be decoded into a Date`}),u_,{strict:!0,decode:e=>new Date(e),encode:e=>e.getTime()}).annotations({identifier:`DateFromNumber`});var d_=class extends Lm(e=>Wf(e)&&qf(e),{typeConstructor:{_tag:`effect/DateTime.Utc`},identifier:`DateTimeUtcFromSelf`,description:`a DateTime.Utc instance`,pretty:()=>e=>e.toString(),arbitrary:()=>e=>e.date({noInvalidDate:!0}).map(e=>Xf(e)),equivalence:()=>Yf}){};const f_=(e,t)=>_p({try:()=>Zf(e),catch:()=>new H(t,e,`Unable to decode ${l(e)} into a DateTime.Utc`)});X(q.annotations({description:`a number to be decoded into a DateTime.Utc`}),d_,{strict:!0,decode:(e,t,n)=>f_(e,n),encode:e=>U(ap(e))}).annotations({identifier:`DateTimeUtcFromNumber`}),X(u_.annotations({description:`a Date to be decoded into a DateTime.Utc`}),d_,{strict:!0,decode:(e,t,n)=>f_(e,n),encode:e=>U(ip(e))}).annotations({identifier:`DateTimeUtcFromDate`}),X(K.annotations({description:`a string to be decoded into a DateTime.Utc`}),d_,{strict:!0,decode:(e,t,n)=>f_(e,n),encode:e=>U(op(e))}).annotations({identifier:`DateTimeUtc`});const p_=()=>e=>e.integer({min:-720*60*1e3,max:840*60*1e3}).map(tp);var m_=class extends Lm(Gf,{typeConstructor:{_tag:`effect/DateTime.TimeZone.Offset`},identifier:`TimeZoneOffsetFromSelf`,description:`a TimeZone.Offset instance`,pretty:()=>e=>e.toString(),arbitrary:p_}){};Z(q.annotations({description:`a number to be decoded into a TimeZone.Offset`}),m_,{strict:!0,decode:e=>tp(e),encode:e=>e.offset}).annotations({identifier:`TimeZoneOffset`});const h_=()=>e=>e.constantFrom(...Intl.supportedValuesOf(`timeZone`)).map(ep);var g_=class extends Lm(Kf,{typeConstructor:{_tag:`effect/DateTime.TimeZone.Named`},identifier:`TimeZoneNamedFromSelf`,description:`a TimeZone.Named instance`,pretty:()=>e=>e.toString(),arbitrary:h_}){};X(K.annotations({description:`a string to be decoded into a TimeZone.Named`}),g_,{strict:!0,decode:(e,t,n)=>_p({try:()=>ep(e),catch:()=>new H(n,e,`Unable to decode ${JSON.stringify(e)} into a TimeZone.Named`)}),encode:e=>U(e.id)}).annotations({identifier:`TimeZoneNamed`});var __=class extends Jm(m_,g_){};X(K.annotations({description:`a string to be decoded into a TimeZone`}),__,{strict:!0,decode:(e,t,n)=>_(np(e),{onNone:()=>gp(new H(n,e,`Unable to decode ${JSON.stringify(e)} into a TimeZone`)),onSome:U}),encode:e=>U(rp(e))}).annotations({identifier:`TimeZone`});const v_=e=>e.oneof(p_()(e),h_()(e));var y_=class extends Lm(e=>Wf(e)&&Jf(e),{typeConstructor:{_tag:`effect/DateTime.Zoned`},identifier:`DateTimeZonedFromSelf`,description:`a DateTime.Zoned instance`,pretty:()=>e=>e.toString(),arbitrary:()=>e=>e.tuple(e.integer({min:-31536e9,max:31536e9}),v_(e)).map(([e,t])=>Qf(e,{timeZone:t})),equivalence:()=>Yf}){};X(K.annotations({description:`a string to be decoded into a DateTime.Zoned`}),y_,{strict:!0,decode:(e,t,n)=>_($f(e),{onNone:()=>gp(new H(n,e,`Unable to decode ${JSON.stringify(e)} into a DateTime.Zoned`)),onSome:U}),encode:e=>U(sp(e))}).annotations({identifier:`DateTimeZoned`});const b_=e=>e._tag===`None`?v():w(e.value),x_=(e,t)=>n=>n.oneof(t,n.record({_tag:n.constant(`None`)}),n.record({_tag:n.constant(`Some`),value:e(n)})).map(b_),S_=e=>_({onNone:()=>`none()`,onSome:t=>`some(${e(t)})`}),C_=e=>(t,n,r)=>i(t)?wt(t)?U(v()):Jg(e(t.value,n),w,r,t):gp(new H(r,t)),w_=e=>Lm([e],{decode:e=>C_(Mp(e)),encode:e=>C_(Np(e))},{typeConstructor:{_tag:`effect/Option`},pretty:S_,arbitrary:x_,equivalence:Yt});Z(K,(e=>w_(e).annotations({description:`Option<${Em(e)}>`}))(lg),{strict:!0,decode:e=>nt(w(e.trim()),Da),encode:e=>Ne(e,()=>``)});const T_=()=>e=>`BigDecimal(${wc(gc(e))})`,E_=()=>e=>e.tuple(e.bigInt(),e.integer({min:-18,max:18})).map(([e,t])=>dc(e,t));var D_=class extends Lm(uc,{typeConstructor:{_tag:`effect/BigDecimal`},identifier:`BigDecimalFromSelf`,pretty:T_,arbitrary:E_,equivalence:()=>yc}){};X(K.annotations({description:`a string to be decoded into a BigDecimal`}),D_,{strict:!0,decode:(e,t,n)=>Cc(e).pipe(_({onNone:()=>gp(new H(n,e,`Unable to decode ${JSON.stringify(e)} into a BigDecimal`)),onSome:e=>U(gc(e))})),encode:e=>U(wc(gc(e)))}).annotations({identifier:`BigDecimal`}),Z(q.annotations({description:`a number to be decoded into a BigDecimal`}),D_,{strict:!0,decode:e=>xc(e),encode:e=>Ec(e)}).annotations({identifier:`BigDecimalFromNumber`});const O_=e=>Am(e)||uh(e),k_=e=>Reflect.ownKeys(e).every(t=>O_(e[t])),A_=e=>`fields`in e?e.fields:A_(e[Fh]),j_=e=>k_(e)?J(e):Am(e)?e:J(A_(e)),M_=e=>k_(e)?e:A_(e),N_=e=>hh(mh(Nm(e)),()=>e),P_=e=>(t,n,r)=>{let i=M_(n),a=j_(n),o={_tag:N_(t)},s=I_(o,i);return class extends B_({kind:`TaggedClass`,identifier:e??t,schema:Nh(a,J(o)),fields:s,Base:Ei,annotations:r}){static _tag=t}},F_=e=>(t,n,r)=>{class i extends Di{}i.prototype.name=t;let a=M_(n),o=j_(n),s={_tag:N_(t)},c=I_(s,a),u=`message`in c;class d extends B_({kind:`TaggedError`,identifier:e??t,schema:Nh(o,J(s)),fields:c,Base:i,annotations:r,disableToString:!0}){static _tag=t}return u||Object.defineProperty(d.prototype,"message",{get(){return`{ ${Reflect.ownKeys(a).map(e=>`${p(e)}: ${l(this[e])}`).join(`, `)} }`},enumerable:!1,configurable:!0}),d},I_=(e,t)=>{let n={...e};for(let r of Reflect.ownKeys(t)){if(r in e)throw Error(Ua(r));n[r]=t[r]}return n};function L_(e){return Ke(e)?e:e?.disableValidation??!1}const R_=st(`effect/Schema/astCache`,()=>new WeakMap),z_=e=>e===void 0?[]:Array.isArray(e)?e:[e],B_=({Base:e,annotations:t,disableToString:n,fields:r,identifier:i,kind:a,schema:o})=>{let s=Symbol.for(`effect/Schema/${a}/${i}`),[c,u,d]=z_(t),f=Om(o),m=f.annotations({identifier:i,...c}),h=f.annotations({[po]:`${i} (Type side)`,...c}),g=o.annotations({[po]:`${i} (Constructor)`,...c}),ee=o.annotations({[po]:`${i} (Encoded side)`,...d}),_=o.annotations({...d,...c,...u}),te=e=>Nt(e,s)&&Ip(h)(e),ne=class extends e{constructor(e={},t=!1){e={...e},a!==`Class`&&delete e._tag,e=yh(r,e),L_(t)||(e=Fp(g)(e)),super(e,!0)}static[xm]=Sm;static get ast(){let e=R_.get(this);if(e)return e;let t=Lm([o],{decode:()=>(e,t,n)=>e instanceof this||te(e)?U(e):gp(new H(n,e)),encode:()=>(e,t)=>e instanceof this?U(e):xp(Np(h)(e,t),e=>new this(e,!0))},{identifier:i,pretty:e=>t=>`${i}(${e(t)})`,arbitrary:e=>t=>e(t).map(e=>new this(e)),equivalence:S,[Do]:m.ast,...c});return e=Z(ee,t,{strict:!0,decode:e=>new this(e,!0),encode:S}).annotations({[Do]:_.ast,...u}).ast,R_.set(this,e),e}static pipe(){return De(this,arguments)}static annotations(e){return G(this.ast).annotations(e)}static toString(){return`(${String(ee)} <-> ${i})`}static make(...e){return new this(...e)}static fields={...r};static identifier=i;static extend(e){return(t,n)=>{let i=M_(t),s=j_(t),c=I_(r,i);return B_({kind:a,identifier:e,schema:Nh(o,s),fields:c,Base:this,annotations:n})}}static transformOrFail(e){return(t,n,i)=>{let s=I_(r,t);return B_({kind:a,identifier:e,schema:X(o,Om(J(s)),n),fields:s,Base:this,annotations:i})}}static transformOrFailFrom(e){return(t,n,i)=>{let s=I_(r,t);return B_({kind:a,identifier:e,schema:X(Dm(o),J(s),n),fields:s,Base:this,annotations:i})}}get[s](){return s}};return n!==!0&&Object.defineProperty(ne.prototype,"toString",{value(){return`${i}({ ${Reflect.ownKeys(r).map(e=>`${p(e)}: ${l(this[e])}`).join(`, `)} })`},configurable:!0,writable:!0}),ne},V_=Jm(J({_tag:Nm(`None`)}).annotations({identifier:`FiberIdNoneEncoded`}),J({_tag:Nm(`Runtime`),id:Ig,startTimeMillis:Ig}).annotations({identifier:`FiberIdRuntimeEncoded`}),J({_tag:Nm(`Composite`),left:Ph(()=>V_),right:Ph(()=>V_)}).annotations({identifier:`FiberIdCompositeEncoded`})).annotations({identifier:`FiberIdEncoded`}),H_=e=>e.letrec(t=>({None:e.record({_tag:e.constant(`None`)}),Runtime:e.record({_tag:e.constant(`Runtime`),id:e.integer(),startTimeMillis:e.integer()}),Composite:e.record({_tag:e.constant(`Composite`),left:t(`FiberId`),right:t(`FiberId`)}),FiberId:e.oneof(t(`None`),t(`Runtime`),t(`Composite`))})).FiberId.map(G_),U_=e=>{switch(e._tag){case`None`:return`FiberId.none`;case`Runtime`:return`FiberId.runtime(${e.id}, ${e.startTimeMillis})`;case`Composite`:return`FiberId.composite(${U_(e.right)}, ${U_(e.left)})`}};var W_=class extends Lm(ge,{typeConstructor:{_tag:`effect/FiberId`},identifier:`FiberIdFromSelf`,pretty:()=>U_,arbitrary:()=>H_}){};const G_=e=>{switch(e._tag){case`None`:return xe;case`Runtime`:return g(e.id,e.startTimeMillis);case`Composite`:return me(G_(e.left),G_(e.right))}},K_=e=>{switch(e._tag){case`None`:return{_tag:`None`};case`Runtime`:return{_tag:`Runtime`,id:e.id,startTimeMillis:e.startTimeMillis};case`Composite`:return{_tag:`Composite`,left:K_(e.left),right:K_(e.right)}}};Z(V_,W_,{strict:!0,decode:e=>G_(e),encode:e=>K_(e)}).annotations({identifier:`FiberId`});var q_=class extends Z(Hm,Hm,{strict:!0,decode:e=>{if(Dt(e)&&`message`in e&&typeof e.message==`string`){let t=Error(e.message,{cause:e});return`name`in e&&typeof e.name==`string`&&(t.name=e.name),t.stack=`stack`in e&&typeof e.stack==`string`?e.stack:``,t}return Ot(e)},encode:e=>e instanceof Error?{name:e.name,message:e.message}:Ot(e)}).annotations({identifier:`Defect`}){};Z(Hm,Gm,{strict:!0,decode:e=>it(e),encode:S}).annotations({identifier:`BooleanFromUnknown`}),Z(Nm(`true`,`false`).annotations({description:`a string to be decoded into a boolean`}),Gm,{strict:!0,decode:e=>e===`true`,encode:e=>e?`true`:`false`}).annotations({identifier:`BooleanFromString`});const J_=Sh(`symbol`,{key:K}).annotations({description:`an object to be decoded into a globally shared symbol`}),Y_=X(J_,Wm,{strict:!0,decode:e=>Bg(e.key),encode:(e,t,n)=>xp(zg(e,n),e=>J_.make({key:e}))});var X_=class extends Jm(K,q,Y_).annotations({identifier:`PropertyKey`}){};J({_tag:mh(Nm(`Pointer`,`Unexpected`,`Missing`,`Composite`,`Refinement`,`Transformation`,`Type`,`Forbidden`)).annotations({description:`The tag identifying the type of parse issue`}),path:mh(nh(X_)).annotations({description:`The path to the property where the issue occurred`}),message:mh(K).annotations({description:`A descriptive message explaining the issue`})}).annotations({identifier:`ArrayFormatterIssue`,description:`Represents an issue returned by the ArrayFormatter formatter`});const Z_=Qd,Q_=tf,$_=bf,ev=xf,tv=kf,nv=zf,rv=Bf,iv={arrays:`merge`,sets:`merge`,maps:`merge`};function av(e,t,n){return ov(e,t,new Set,n??iv)}function ov(e,t,n,r){let i={},a=new Set([...dv(e),...dv(t)]);for(let o of a){if(o===`__proto__`)continue;let a=e[o];if(!Object.hasOwn(t,o)){i[o]=a;continue}let s=t[o];if(uv(a)&&uv(s)&&!n.has(a)&&!n.has(s)){n.add(a),n.add(s),i[o]=sv(a,s,n,r);continue}i[o]=s}return i}function sv(e,t,n,r){if(cv(e)&&cv(t))return ov(e,t,n,r);if(lv(e)&&lv(t)){if(Array.isArray(e)&&Array.isArray(t))return r.arrays===`merge`?e.concat(t):t;if(e instanceof Map&&t instanceof Map){if(r.maps===`merge`){let n=new Map(e);for(let[e,r]of t)n.set(e,r);return n}return t}if(e instanceof Set&&t instanceof Set){if(r.sets===`merge`){let n=new Set(e);for(let e of t)n.add(e);return n}return t}}return t}function cv(e){return Object.getPrototypeOf(e)===Object.prototype}function lv(e){return typeof e[Symbol.iterator]==`function`}function uv(e){return typeof e==`object`&&!!e}function dv(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n)Object.prototype.propertyIsEnumerable.call(e,r)&&t.push(r);return t}function fv(e){return e%4==0&&e%100!=0||e%400==0}var pv=class{#e=/[ \t]/;#t=0;#n;constructor(e){this.#n=e}get position(){return this.#t}get source(){return this.#n}char(e=0){return this.#n[this.#t+e]??``}slice(e,t){return this.#n.slice(this.#t+e,this.#t+t)}next(e=1){this.#t+=e}skipWhitespaces(){for(;this.#e.test(this.char())&&!this.eof();)this.next();if(!this.isCurrentCharEOL()&&/\s/.test(this.char())){let e=`\\u`+this.char().charCodeAt(0).toString(16),t=this.#t;throw SyntaxError(`Cannot parse the TOML: It contains invalid whitespace at position '${t}': \`${e}\``)}}nextUntilChar(e={skipComments:!0}){for(;!this.eof();){let t=this.char();if(this.#e.test(t)||this.isCurrentCharEOL())this.next();else if(e.skipComments&&this.char()===`#`)for(;!this.isCurrentCharEOL()&&!this.eof();)this.next();else break}}eof(){return this.#t>=this.#n.length}isCurrentCharEOL(){return this.char()===`
|
|
3
|
+
`||this.startsWith(`\r
|
|
4
|
+
`)}startsWith(e){return this.#n.startsWith(e,this.#t)}match(e){if(!e.sticky)throw Error(`RegExp ${e} does not have a sticky 'y' flag`);return e.lastIndex=this.#t,this.#n.match(e)}};function Q(e){return{ok:!0,body:e}}function $(){return{ok:!1}}function mv(e,t={__proto__:null}){return e.reduceRight((e,t)=>({[t]:e}),t)}function hv(e){return typeof e==`object`&&!!e}function gv(e,t){let n=t[0];if(!n)throw Error(`Cannot parse the TOML: key length is not a positive number`);return e[n]}function _v(e,t){let{keys:n,type:r,value:i}=t,a=gv(e,n);if(a===void 0)return Object.assign(e,mv(n,i));if(Array.isArray(a))return yv(a.at(-1),{type:r,keys:n.slice(1),value:i}),e;if(hv(a))return yv(a,{type:r,keys:n.slice(1),value:i}),e;throw Error(`Unexpected assign`)}function vv(e,t){let{type:n,keys:r,value:i}=t,a=gv(e,r);if(a===void 0)return Object.assign(e,mv(r,[i]));if(Array.isArray(a))return t.keys.length===1?a.push(i):yv(a.at(-1),{type:t.type,keys:t.keys.slice(1),value:t.value}),e;if(hv(a))return yv(a,{type:n,keys:r.slice(1),value:i}),e;throw Error(`Unexpected assign`)}function yv(e,t){switch(t.type){case`Block`:return av(e,t.value);case`Table`:return _v(e,t);case`TableArray`:return vv(e,t)}}function bv(e){return t=>{for(let n of e){let e=n(t);if(e.ok)return e}return $()}}function xv(e,t){let n=Dv(t);return r=>{let i=[],a=e(r);if(!a.ok)return Q(i);for(i.push(a.body);!r.eof()&&n(r).ok;){let n=e(r);if(!n.ok)throw SyntaxError(`Invalid token after "${t}"`);i.push(n.body)}return Q(i)}}function Sv(e,t){let n=Dv(t);return r=>{let i=e(r);if(!i.ok)return $();let a=[i.body];for(;!r.eof()&&n(r).ok;){let n=e(r);if(!n.ok)throw SyntaxError(`Invalid token after "${t}"`);a.push(n.body)}return Q(a)}}function Cv(e,t,n){let r=Dv(t);return i=>{let a=i.position,o=e(i);if(!o.ok)return $();if(!r(i).ok)throw SyntaxError(`key/value pair doesn't have "${t}"`);let s=n(i);if(!s.ok){let e=i.source.indexOf(`
|
|
5
|
+
`,i.position),t=e>0?e:i.source.length,n=i.source.slice(a,t);throw SyntaxError(`Cannot parse value on line '${n}'`)}return Q(mv(o.body,s.body))}}function wv(e){return t=>{let n=e(t);if(!n.ok)return $();let r={__proto__:null};for(let e of n.body)typeof e==`object`&&e&&(r=av(r,e));return Q(r)}}function Tv(e){return t=>{let n=[];for(;!t.eof();){let r=e(t);if(!r.ok)break;n.push(r.body),t.nextUntilChar()}return n.length===0?$():Q(n)}}function Ev(e,t,n){let r=Dv(e),i=Dv(n);return a=>{if(!r(a).ok)return $();let o=t(a);if(!o.ok)throw SyntaxError(`Invalid token after "${e}"`);if(!i(a).ok)throw SyntaxError(`Not closed by "${n}" after started with "${e}"`);return Q(o.body)}}function Dv(e){return t=>(t.skipWhitespaces(),t.startsWith(e)?(t.next(e.length),t.skipWhitespaces(),Q(void 0)):$())}const Ov=/[A-Za-z0-9_-]+/y;function kv(e){e.skipWhitespaces();let t=e.match(Ov)?.[0];return t?(e.next(t.length),Q(t)):$()}function Av(e){if(e.char()!==`\\`)return $();switch(e.next(),e.char()){case`b`:return e.next(),Q(`\b`);case`t`:return e.next(),Q(` `);case`n`:return e.next(),Q(`
|
|
6
|
+
`);case`f`:return e.next(),Q(`\f`);case`r`:return e.next(),Q(`\r`);case`u`:case`U`:{let t=e.char()===`u`?4:6,n=parseInt(`0x`+e.slice(1,1+t),16),r=String.fromCodePoint(n);return e.next(t+1),Q(r)}case`"`:return e.next(),Q(`"`);case`\\`:return e.next(),Q(`\\`);default:throw SyntaxError(`Invalid escape sequence: \\${e.char()}`)}}function jv(e){if(e.skipWhitespaces(),e.char()!==`"`)return $();e.next();let t=[];for(;e.char()!==`"`&&!e.eof();){if(e.char()===`
|
|
7
|
+
`)throw SyntaxError(`Single-line string cannot contain EOL`);let n=Av(e);n.ok?t.push(n.body):(t.push(e.char()),e.next())}if(e.eof())throw SyntaxError(`Single-line string is not closed:\n${t.join(``)}`);return e.next(),Q(t.join(``))}function Mv(e){if(e.skipWhitespaces(),e.char()!==`'`)return $();e.next();let t=[];for(;e.char()!==`'`&&!e.eof();){if(e.char()===`
|
|
8
|
+
`)throw SyntaxError(`Single-line string cannot contain EOL`);t.push(e.char()),e.next()}if(e.eof())throw SyntaxError(`Single-line string is not closed:\n${t.join(``)}`);return e.next(),Q(t.join(``))}function Nv(e){if(e.skipWhitespaces(),!e.startsWith(`"""`))return $();e.next(3),e.char()===`
|
|
9
|
+
`?e.next():e.startsWith(`\r
|
|
10
|
+
`)&&e.next(2);let t=[];for(;!e.startsWith(`"""`)&&!e.eof();){if(e.startsWith(`\\
|
|
11
|
+
`)){e.next(),e.nextUntilChar({skipComments:!1});continue}else if(e.startsWith(`\\\r
|
|
12
|
+
`)){e.next(),e.nextUntilChar({skipComments:!1});continue}let n=Av(e);n.ok?t.push(n.body):(t.push(e.char()),e.next())}if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`"`&&(t.push(`"`),e.next()),e.next(3),Q(t.join(``))}function Pv(e){if(e.skipWhitespaces(),!e.startsWith(`'''`))return $();e.next(3),e.char()===`
|
|
13
|
+
`?e.next():e.startsWith(`\r
|
|
14
|
+
`)&&e.next(2);let t=[];for(;!e.startsWith(`'''`)&&!e.eof();)t.push(e.char()),e.next();if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`'`&&(t.push(`'`),e.next()),e.next(3),Q(t.join(``))}const Fv=/(?:true|false)\b/y;function Iv(e){e.skipWhitespaces();let t=e.match(Fv);if(!t)return $();let n=t[0];return e.next(n.length),Q(n===`true`)}const Lv=new Map([[`inf`,1/0],[`+inf`,1/0],[`-inf`,-1/0]]),Rv=/[+-]?inf\b/y;function zv(e){e.skipWhitespaces();let t=e.match(Rv);if(!t)return $();let n=t[0];return e.next(n.length),Q(Lv.get(n))}const Bv=/[+-]?nan\b/y;function Vv(e){e.skipWhitespaces();let t=e.match(Bv);if(!t)return $();let n=t[0];return e.next(n.length),Q(NaN)}const Hv=Sv(bv([kv,jv,Mv]),`.`),Uv=/0b[01]+(?:_[01]+)*\b/y;function Wv(e){e.skipWhitespaces();let t=e.match(Uv)?.[0];if(!t)return $();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,2);return isNaN(r)?$():Q(r)}const Gv=/0o[0-7]+(?:_[0-7]+)*\b/y;function Kv(e){e.skipWhitespaces();let t=e.match(Gv)?.[0];if(!t)return $();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,8);return isNaN(r)?$():Q(r)}const qv=/0x[0-9a-f]+(?:_[0-9a-f]+)*\b/iy;function Jv(e){e.skipWhitespaces();let t=e.match(qv)?.[0];if(!t)return $();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,16);return isNaN(r)?$():Q(r)}const Yv=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)\b/y;function Xv(e){e.skipWhitespaces();let t=e.match(Yv)?.[0];if(!t)return $();e.next(t.length);let n=t.replaceAll(`_`,``);return Q(parseInt(n,10))}const Zv=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)(?:\.[0-9]+(?:_[0-9]+)*)?(?:e[+-]?[0-9]+(?:_[0-9]+)*)?\b/iy;function Qv(e){e.skipWhitespaces();let t=e.match(Zv)?.[0];if(!t)return $();e.next(t.length);let n=t.replaceAll(`_`,``),r=parseFloat(n);return isNaN(r)?$():Q(r)}const $v=/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})(?:[ 0-9TZ.:+-]+)?\b/y;function ey(e){e.skipWhitespaces();let t=e.match($v);if(!t)return $();let n=t[0];e.next(n.length);let r=t.groups;if(r.month==`02`){let e=parseInt(r.day);if(e>29)throw SyntaxError(`Invalid date string "${t}"`);let n=parseInt(r.year);if(e>28&&!fv(n))throw SyntaxError(`Invalid date string "${t}"`)}let i=new Date(n.trim());if(isNaN(i.getTime()))throw SyntaxError(`Invalid date string "${t}"`);return Q(i)}const ty=/(\d{2}):(\d{2}):(\d{2})(?:\.[0-9]+)?\b/y;function ny(e){e.skipWhitespaces();let t=e.match(ty)?.[0];return t?(e.next(t.length),Q(t)):$()}function ry(e){if(e.skipWhitespaces(),e.char()!==`[`)return $();e.next();let t=[];for(;!e.eof();){e.nextUntilChar();let n=ay(e);if(!n.ok||(t.push(n.body),e.skipWhitespaces(),e.char()!==`,`))break;e.next()}if(e.nextUntilChar(),e.char()!==`]`)throw SyntaxError(`Array is not closed`);return e.next(),Q(t)}function iy(e){if(e.nextUntilChar(),e.char(1)===`}`)return e.next(2),Q({__proto__:null});let t=Ev(`{`,xv(oy,`,`),`}`)(e);if(!t.ok)return $();let n={__proto__:null};for(let e of t.body)n=av(n,e);return Q(n)}const ay=bv([Nv,Pv,jv,Mv,Iv,zv,Vv,ey,ny,Wv,Kv,Jv,Qv,Xv,ry,iy]),oy=Cv(Hv,`=`,ay);function sy(e){e.nextUntilChar();let t=wv(Tv(oy))(e);return t.ok?Q({type:`Block`,value:t.body}):$()}const cy=Ev(`[`,Hv,`]`);function ly(e){e.nextUntilChar();let t=cy(e);if(!t.ok)return $();e.nextUntilChar();let n=sy(e);return Q({type:`Table`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}const uy=Ev(`[[`,Hv,`]]`);function dy(e){e.nextUntilChar();let t=uy(e);if(!t.ok)return $();e.nextUntilChar();let n=sy(e);return Q({type:`TableArray`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}function fy(e){let t=Tv(bv([sy,dy,ly]))(e);return t.ok?Q(t.body.reduce(yv,{__proto__:null})):Q({__proto__:null})}function py(e,t){let n=e.source.slice(0,e.position).split(`
|
|
15
|
+
`);return`Parse error on line ${n.length}, column ${n.at(-1)?.length??0}: ${t}`}function my(e){return t=>{let n=new pv(t);try{let t=e(n);if(t.ok&&n.eof())return t.body;let r=`Unexpected character: "${n.char()}"`;throw SyntaxError(py(n,r))}catch(e){throw e instanceof Error?SyntaxError(py(n,e.message)):SyntaxError(py(n,`Invalid error type caught`))}}}function hy(e){return my(fy)(e)}const gy=Symbol.for(`@effect/platform/Error`),_y=Nm(`Clipboard`,`Command`,`FileSystem`,`KeyValueStore`,`Path`,`Stream`,`Terminal`);var vy=class extends F_(`@effect/platform/Error/BadArgument`)(`BadArgument`,{module:_y,method:K,description:gh(K),cause:gh(q_)}){[gy]=gy;get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:``}`}};const yy=Nm(`AlreadyExists`,`BadResource`,`Busy`,`InvalidData`,`NotFound`,`PermissionDenied`,`TimedOut`,`UnexpectedEof`,`Unknown`,`WouldBlock`,`WriteZero`);var by=class extends F_(`@effect/platform/Error/SystemError`)(`SystemError`,{reason:yy,module:_y,method:K,description:gh(K),syscall:gh(K),pathOrDescriptor:gh(Jm(K,q)),cause:gh(q_)}){[gy]=gy;get message(){return`${this.reason}: ${this.module}.${this.method}${this.pathOrDescriptor===void 0?``:` (${this.pathOrDescriptor})`}${this.description?`: ${this.description}`:``}`}};const xy=Lt(`@effect/platform/FileSystem`),Sy=e=>typeof e==`bigint`?e:BigInt(e),Cy=BigInt(1024);Cy*Cy*Cy*Cy*Cy;const wy=e=>xy.of({...e,exists:t=>C(e.access(t),wr(!0),tr(`SystemError`,e=>e.reason===`NotFound`?M(!1):Gn(e))),readFileString:(t,n)=>Er(e.readFile(t),{try:e=>new TextDecoder(n).decode(e),catch:e=>new vy({module:`FileSystem`,method:`readFileString`,description:`invalid encoding`,cause:e})}),stream:(t,n)=>C(e.open(t,{flag:`r`}),n?.offset?pr(e=>e.seek(n.offset,`start`)):S,E(e=>Ty(e,n)),rv),sink:(t,n)=>C(e.open(t,{flag:`w`,...n}),E(e=>Z_(t=>e.writeAll(t))),Q_),writeFileString:(t,n,r)=>D(er({try:()=>new TextEncoder().encode(n),catch:e=>new vy({module:`FileSystem`,method:`writeFileString`,description:`could not encode string`,cause:e})}),n=>e.writeFile(t,n,r))}),Ty=(e,{bufferSize:t=16,bytesToRead:n,chunkSize:r=Sy(64*1024)}={})=>{let i=n===void 0?void 0:Sy(n),a=Sy(r);function o(t){if(i!==void 0&&i<=t)return Hf;let n=i!==void 0&&i-t<a?i-t:a;return Vf(e.readAlloc(n),_({onNone:()=>Hf,onSome:e=>Vf(Uf(ye(e)),n=>o(t+BigInt(e.length)))}))}return ev(tv(o(BigInt(0))),{capacity:t})},Ey=Sy,Dy=xy,Oy=wy,ky=Symbol.for(`@effect/platform/FileSystem/File`),Ay=Nc(),jy=Ti(`Create`),My=Ti(`Update`),Ny=Ti(`Remove`);var Py=class extends Ze(`@effect/platform/FileSystem/WatchBackend`)(){};const Fy=Symbol.for(`@effect/platform/Path`),Iy=Lt(`@effect/platform/Path`);function Ly(e,t){let n=``,r=0,i=-1,a=0,o;for(let s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(i!==s-1&&a!==1)if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let e=n.lastIndexOf(`/`);if(e!==n.length-1){e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}function Ry(e,t){let n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+e+r:r}function zy(e){if(e.protocol!==`file:`)return Gn(new vy({module:`Path`,method:`fromFileUrl`,description:`URL must be of scheme file`}));if(e.hostname!==``)return Gn(new vy({module:`Path`,method:`fromFileUrl`,description:`Invalid file URL host`}));let t=e.pathname;for(let e=0;e<t.length;e++)if(t[e]===`%`){let n=t.codePointAt(e+2)|32;if(t[e+1]===`2`&&n===102)return Gn(new vy({module:`Path`,method:`fromFileUrl`,description:`must not include encoded / characters`}))}return M(decodeURIComponent(t))}const By=function(){let e=``,t=!1,n;for(let r=arguments.length-1;r>=-1&&!t;r--){let i;if(r>=0)i=arguments[r];else{let e=globalThis.process;n===void 0&&`process`in globalThis&&typeof e==`object`&&e&&typeof e.cwd==`function`&&(n=e.cwd()),i=n}i.length!==0&&(e=i+`/`+e,t=i.charCodeAt(0)===47)}return e=Ly(e,!t),t?e.length>0?`/`+e:`/`:e.length>0?e:`.`};function Vy(e){let t=new URL(`file://`),n=By(e);return e.charCodeAt(e.length-1)===47&&n[n.length-1]!==`/`&&(n+=`/`),t.pathname=qy(n),M(t)}const Hy=/%/g,Uy=/\\/g,Wy=/\n/g,Gy=/\r/g,Ky=/\t/g;function qy(e){return e.includes(`%`)&&(e=e.replace(Hy,`%25`)),e.includes(`\\`)&&(e=e.replace(Uy,`%5C`)),e.includes(`
|
|
16
|
+
`)&&(e=e.replace(Wy,`%0A`)),e.includes(`\r`)&&(e=e.replace(Gy,`%0D`)),e.includes(` `)&&(e=e.replace(Ky,`%09`)),e}const Jy=Iy.of({[Fy]:Fy,resolve:By,normalize(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=Ly(e,!t),e.length===0&&!t&&(e=`.`),e.length>0&&n&&(e+=`/`),t?`/`+e:e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return`.`;let e;for(let t=0;t<arguments.length;++t){let n=arguments[t];n.length>0&&(e===void 0?e=n:e+=`/`+n)}return e===void 0?`.`:Jy.normalize(e)},relative(e,t){if(e===t||(e=Jy.resolve(e),t=Jy.resolve(t),e===t))return``;let n=1;for(;n<e.length&&e.charCodeAt(n)===47;++n);let r=e.length,i=r-n,a=1;for(;a<t.length&&t.charCodeAt(a)===47;++a);let o=t.length-a,s=i<o?i:o,c=-1,l=0;for(;l<=s;++l){if(l===s){if(o>s){if(t.charCodeAt(a+l)===47)return t.slice(a+l+1);if(l===0)return t.slice(a+l)}else i>s&&(e.charCodeAt(n+l)===47?c=l:l===0&&(c=0));break}let r=e.charCodeAt(n+l);if(r!==t.charCodeAt(a+l))break;r===47&&(c=l)}let u=``;for(l=n+c+1;l<=r;++l)(l===r||e.charCodeAt(l)===47)&&(u.length===0?u+=`..`:u+=`/..`);return u.length>0?u+t.slice(a+c):(a+=c,t.charCodeAt(a)===47&&++a,t.slice(a))},dirname(e){if(e.length===0)return`.`;let t=e.charCodeAt(0),n=t===47,r=-1,i=!0;for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:`.`:n&&r===1?`//`:e.slice(0,r)},basename(e,t){let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)}},extname(e){let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return Ry(`/`,e)},parse(e){let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0),r=n===47,i;r?(t.root=`/`,i=1):i=0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),o>0?t.dir=e.slice(0,o-1):r&&(t.dir=`/`),t},sep:`/`,fromFileUrl:zy,toFileUrl:Vy,toNamespacedPath:S}),Yy=Ic(Iy,Jy),Xy=Iy,Zy=Yy,Qy=wh({key:K,value:nh(K)}).pipe(Eh(`TomlConfig`)),$y=X(K,Om(Qy),{strict:!0,decode:e=>_p({try:()=>hy(e),catch:e=>new cp(e,`TOML parse error`)}).pipe(bp(e=>Mp(Qy)(e))),encode:(e,t,n)=>gp(new fp(n,e,`TomlConfigFromText is decode-only`))}),eb=e=>{let t={};for(let n of e)for(let[e,r]of Object.entries(n))t[e]=r;return t},tb=`systemfsoftware.toml`,nb=Pp(Qy)({}),rb=(e,t,n)=>e.exists(n).pipe(D(t=>t?e.readFileString(n).pipe(D(km($y)),vr(()=>M(nb))):M(nb)));var ib=class extends Ze(`TomlLoader`)(){};const ab=(e=>Pc(ib,un(function*(){let t=yield*sr(nr()),n=yield*Dy,r=yield*Xy,i=r.join(e,`.omp`,tb);return ib.of({load:Nn(`TomlLoader.load`)(function*(e){let a=ar(yield*lr(t),e);if(bt(a))return a.value;let o=r.join(e,tb),s=r.join(e,`systemfsoftware.local.toml`),c=yield*rb(n,r,i),l=yield*rb(n,r,o),u=yield*rb(n,r,s),d=Pp(Qy)(eb([c,l,u]));return yield*Yr(t,t=>(Or(t,e,d),t)),d})})})))(Ci.homedir());Ip(nh(J({old_text:gh(Hm),new_text:gh(Hm)}).pipe(Y(e=>`old_text`in e||`new_text`in e))).pipe(o_(1))),Ip(nh(J({old_string:gh(Hm),new_string:gh(Hm)}).pipe(Y(e=>`old_string`in e||`new_string`in e)))),jp(wh({key:K,value:Hm}));export{Jm as C,Lc as D,Fc as E,P_ as S,Pc as T,nh as _,Dy as a,K as b,Py as c,My as d,Oy as f,nv as g,$_ as h,Ay as i,jy as l,by as m,ab as n,ky as o,vy as p,Zy as r,Ey as s,ib as t,Ny as u,Nm as v,Bh as w,J as x,wh as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=async e=>{let[t,n,r,i]=await Promise.all([import(`./runtime-
|
|
1
|
+
const e=async e=>{let[t,n,r,i]=await Promise.all([import(`./runtime-Dydy4g09.js`).then(e=>e.default),import(`./Cause-CTmrUQgG.js`).then(e=>e.t),import(`./Effect-BcYkmFCx.js`).then(e=>e.t),import(`./Exit-Dq5mS6lc.js`).then(e=>e.t)]),a=e.pipe(r.exit),o=await t.runPromise(a);if(i.isFailure(o))throw n.squash(o.cause);return o.value};export{e as runSafe};
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const e=(e,t)=>{e(e=>{e.setTimeout(()=>{t()},0)});let n=()=>{t().then(({default:e})=>e.dispose())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n)};function t(e,...t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}return``}function n(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}const r=e=>{e.on(`tool_call`,async(e,r)=>{let{runSafe:i}=await import(`./helpers-
|
|
1
|
+
const e=(e,t)=>{e(e=>{e.setTimeout(()=>{t()},0)});let n=()=>{t().then(({default:e})=>e.dispose())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n)};function t(e,...t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}return``}function n(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}const r=e=>{e.on(`tool_call`,async(e,r)=>{let{runSafe:i}=await import(`./helpers-BDT6qmPQ.js`),{runNoSkillDelegation:a}=await import(`./no-skill-delegation.executor-DSGbU60f.js`),{Effect:o}=await import(`./esm-CHBBXVaA.js`).then(e=>e.t);return i(o.gen(function*(){let i=n(e.input),o=t(i,`subagent_type`,`agent`),s=t(i,`prompt`,`task`,`description`);return yield*a(r.cwd,e.toolName,o,s)}))})},i=/Tool ([A-Za-z0-9_:-]+) not found/i,a=new Map;function o(e){return typeof e==`object`&&!!e&&`text`in e&&typeof e.text==`string`}function s(e){if(typeof e!=`object`||!e||!(`content`in e))return``;let t=e.content;return Array.isArray(t)?t.filter(o).map(e=>e.text).join(`
|
|
2
2
|
`):``}function c(e){return[``,`---`,`### ⚠️ Unresolved Tool Calls`,``,"The following xd:// tools were not found but have NOT yet been retried via `write` to `xd://`:",``,...e.map((e,t)=>`${t+1}. **\`${e.tool}\`** — failed ${e.failures} time${e.failures>1?`s`:``}. Your first attempt to use \`${e.tool}\` returned \`Tool not found\`. Write to \`xd://${e.tool}\` (JSON args) to retry — do NOT concede the tool is unavailable.`),``,"Each unresolved entry will repeat here until you retry by writing to the `xd://` device.",`---`].join(`
|
|
3
|
-
`)}const l=e=>{e.on(`tool_execution_end`,(e,t)=>{if(!e.isError)return;let n=i.exec(s(e.result));if(!n)return;let r=n[1];if(r===void 0)return;let o=a.get(r);if(o)o.failures+=1;else{if(a.size>=50){let e=a.keys().next().value;e!==void 0&&a.delete(e)}a.set(r,{tool:r,failures:1,remindedAtFailure:0})}}),e.on(`tool_execution_start`,(e,t)=>{if(e.toolName!==`write`||typeof e.args!=`object`||e.args===null||!(`path`in e.args))return;let n=e.args.path;if(typeof n!=`string`||!n.startsWith(`xd://`))return;let r=n.slice(5).split(/[/?#]/)[0];r!==void 0&&r.length!==0&&a.delete(r)}),e.on(`context`,e=>{if(a.size===0)return;let t=[...a.values()].filter(e=>e.failures>e.remindedAtFailure);if(t.length===0)return;let n=c(t);for(let e of t)e.remindedAtFailure=e.failures;return{messages:[...e.messages,{role:`user`,content:[{type:`text`,text:n}],timestamp:Date.now()}]}})};function u(t){r(t),l(t),e(e=>t.on(`session_start`,(t,n)=>e(n)),()=>import(`./runtime-
|
|
3
|
+
`)}const l=e=>{e.on(`tool_execution_end`,(e,t)=>{if(!e.isError)return;let n=i.exec(s(e.result));if(!n)return;let r=n[1];if(r===void 0)return;let o=a.get(r);if(o)o.failures+=1;else{if(a.size>=50){let e=a.keys().next().value;e!==void 0&&a.delete(e)}a.set(r,{tool:r,failures:1,remindedAtFailure:0})}}),e.on(`tool_execution_start`,(e,t)=>{if(e.toolName!==`write`||typeof e.args!=`object`||e.args===null||!(`path`in e.args))return;let n=e.args.path;if(typeof n!=`string`||!n.startsWith(`xd://`))return;let r=n.slice(5).split(/[/?#]/)[0];r!==void 0&&r.length!==0&&a.delete(r)}),e.on(`context`,e=>{if(a.size===0)return;let t=[...a.values()].filter(e=>e.failures>e.remindedAtFailure);if(t.length===0)return;let n=c(t);for(let e of t)e.remindedAtFailure=e.failures;return{messages:[...e.messages,{role:`user`,content:[{type:`text`,text:n}],timestamp:Date.now()}]}})};function u(t){r(t),l(t),e(e=>t.on(`session_start`,(t,n)=>e(n)),()=>import(`./runtime-Dydy4g09.js`))}export{u as default};
|
package/dist/{no-skill-delegation.executor-iMV67QsE.js → no-skill-delegation.executor-DSGbU60f.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Cs as e,Ks as t,Ms as n,Ps as r,Qs as i,Sc as a,Us as o,vl as s}from"./core-CwsVf2Ey.js";import{D as c}from"./Effect-BcYkmFCx.js";import{C as l,S as u,_ as d,b as f,t as p,v as m,w as h,x as g,y as _}from"./dist-
|
|
1
|
+
import{Cs as e,Ks as t,Ms as n,Ps as r,Qs as i,Sc as a,Us as o,vl as s}from"./core-CwsVf2Ey.js";import{D as c}from"./Effect-BcYkmFCx.js";import{C as l,S as u,_ as d,b as f,t as p,v as m,w as h,x as g,y as _}from"./dist-DIH94u3_.js";const ee={[Symbol.for(`@effect/matcher/Matcher`)]:{_input:s,_filters:s,_remaining:s,_result:s,_provided:s,_return:s},_tag:`ValueMatcher`,add(e){return this.value._tag===`Right`?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?v(this.provided,i(e.evaluate(this.provided))):this},pipe(){return a(this,arguments)}};function v(e,t){let n=Object.create(ee);return n.provided=e,n.value=t,n}const y=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),b=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(b),n=t.length;return e=>{if(!Array.isArray(e))return!1;for(let r=0;r<n;r++)if(t[r](e[r])===!1)return!1;return!0}}else if(typeof e==`object`&&e){let t=Object.entries(e).map(([e,t])=>[e,b(t)]),n=t.length;return e=>{if(typeof e!=`object`||!e)return!1;for(let r=0;r<n;r++){let[n,i]=t[r];if(!(n in e)||i(e[n])===!1)return!1}return!0}}return t=>t===e},x=e=>v(e,t(e)),S=(e,t)=>n=>n.add(y(b(e),t)),C=(e=>(...t)=>{let n=t[t.length-1],r=t.slice(0,-1),i=r.length===1?t=>t!=null&&t[e]===r[0]:t=>t!=null&&r.includes(t[e]);return e=>e.add(y(i,n))})(`_tag`),w=e=>t=>{let n=T(t);return o(n)?n._tag===`Right`?n.right:e(n.left):t=>{let r=n(t);return r._tag===`Right`?r.right:e(r.left)}},T=e=>{if(e._tag===`ValueMatcher`)return e.value;let n=e.cases.length;if(n===1){let n=e.cases[0];return e=>n._tag===`When`&&n.guard(e)===!0||n._tag===`Not`&&n.guard(e)===!1?i(n.evaluate(e)):t(e)}return r=>{for(let t=0;t<n;t++){let n=e.cases[t];if(n._tag===`When`&&n.guard(r)===!0||n._tag===`Not`&&n.guard(r)===!1)return i(n.evaluate(r))}return t(r)}},E=`effect/Match/exhaustive: absurd`,D=e=>{let t=T(e);if(o(t)){if(t._tag===`Right`)return t.right;throw Error(E)}return e=>{let n=t(e);if(n._tag===`Right`)return n.right;throw Error(E)}},O=x,k=S,A=C,j=w,M=D,N=m(`subagent_type`,`prompt`),P=Symbol.for(`@systemfsoftware/omp-agent-discipline/DelegationVerdict`);var F=class extends u()(`Allow`,{}){[P]=P},I=class extends u()(`Block`,{reason:f,how:N,skill:f}){[P]=P};l(F,I);const L=g({protectedSkills:d(f),delegationVerbs:d(f),referenceVerbs:d(f),mentionPatterns:_({key:f,value:f})}).pipe(h({arbitrary:()=>e=>e.constant({protectedSkills:[`ce-work`],delegationVerbs:["\\binvoke\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bdispatch\\s+(?:to\\s+)?(?:the\\s+)?[`/]?ce-work\\b","\\buse\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bspawn\\s+(?:a\\s+)?(?:task|agent|subagent|worker)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bcall\\s+(?:the\\s+)?[`/]?ce-work\\b","\\brun\\s+(?:the\\s+)?[`/]?ce-work\\b"],referenceVerbs:["\\bsee\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bread\\s+(?:the\\s+)?[`/]?ce-work\\b"],mentionPatterns:{"ce-work":'(?:^|[\\s/.`"])ce-work(?=$|[\\s/.`"]|\\b)'}})})),R=l(L,m(null)),z=Symbol.for(`@systemfsoftware/omp-agent-discipline/CheckDelegationCommand`);var te=class extends u()(`CheckDelegationCommand`,{toolName:f,subagentType:f,prompt:f,guard:R}){[z]=z};const B=Symbol.for(`@systemfsoftware/omp-agent-discipline/ClassifiedInput`);var V=class extends u()(`NoGuard`,{}){[B]=B},H=class extends u()(`NonDelegatedTool`,{}){[B]=B},U=class extends u()(`ProtectedSubagent`,{skill:f}){[B]=B},W=class extends u()(`EmptyPrompt`,{}){[B]=B},G=class extends u()(`Prompted`,{guard:L,prompt:f}){[B]=B};l(V,H,U,W,G);const K=Symbol.for(`@systemfsoftware/omp-agent-discipline/PromptAnalysis`);var q=class extends u()(`Delegated`,{skill:f,excerpt:f}){[K]=K},J=class extends u()(`Referenced`,{}){[K]=K},Y=class extends u()(`NoDelegation`,{}){[K]=K};l(q,J,Y);function X(e,t,n){return[`⛔ BLOCKED: "`+e+`" must not be delegated to a subagent.`,`Detected in `+t+`: `+n,``,`REQUIRED: invoke `+e+` directly in THIS session via the host Skill / Tool call,`,`then pass its return envelope to the next step. Do NOT wrap it in a task / Agent dispatch.`,``,`WHY: a subagent reproduces the shape but loses the skill protocol — plan-path gate,`,`headless review contract, and pipeline-vs-chat mode. The contract does not survive the hop.`,``,`RULE: root AGENTS.md §"Skill invocations" (SK1/SK2).`].join(`
|
|
2
2
|
`)}function Z(e,t){return new RegExp(e,`i`).test(t)}function ne(e,t){return e.map(e=>new RegExp(e,`i`).exec(t)).find(e=>e!==null)??null}const re=e=>n(e=>e!==``)(e),ie=(e,t)=>O(re(e.prompt)).pipe(A(`Some`,({value:e})=>new G({guard:t,prompt:e})),A(`None`,()=>new W),M),ae=(e,t)=>n(e=>e!==``&&t.protectedSkills.includes(e))(e.subagentType),oe=(e,t)=>O(ae(e,t)).pipe(A(`Some`,({value:e})=>new U({skill:e})),A(`None`,()=>ie(e,t)),M),se=t=>e(t.guard),Q=(e,t)=>n(e=>e===`task`||e===`agent`)(e.toolName.toLowerCase()).pipe(r(()=>oe(e,t))),ce=e=>O(se(e)).pipe(A(`None`,()=>new V),A(`Some`,({value:t})=>O(Q(e,t)).pipe(A(`None`,()=>new H),A(`Some`,({value:e})=>e),M)),M),le=(e,t)=>{let r=Object.entries(e.mentionPatterns).filter(([,e])=>Z(e,t)).map(([e])=>e);return n(e=>e.length>0)(r)},ue=(e,t)=>O(le(e,t)).pipe(A(`None`,()=>new Y),A(`Some`,({value:n})=>{let r=n[0],i=e.referenceVerbs.some(e=>Z(e,t)),a=e.delegationVerbs.some(e=>Z(e,t));return O({hasReference:i,hasDelegation:a}).pipe(k({hasReference:!0},()=>new J),k({hasDelegation:!1},()=>new Y),j(()=>{let n=ne(e.delegationVerbs,t),i=n===null?t.slice(0,120):n[0];return new q({skill:r,excerpt:i})}))}),M),de=e=>O(ce(e)).pipe(A(`NoGuard`,()=>new F),A(`NonDelegatedTool`,()=>new F),A(`ProtectedSubagent`,({skill:e})=>new I({reason:X(e,`subagent_type`,e),how:`subagent_type`,skill:e})),A(`EmptyPrompt`,()=>new F),A(`Prompted`,({guard:e,prompt:t})=>O(ue(e,t)).pipe(A(`Delegated`,({skill:e,excerpt:t})=>new I({reason:X(e,`prompt`,t),how:`prompt`,skill:e})),A(`Referenced`,()=>new F),A(`NoDelegation`,()=>new F),M)),M);function $(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function fe(e){if(e.length===0)return null;let t=`(?:`+e.map($).join(`|`)+`)`;return{protectedSkills:e.slice(),delegationVerbs:["\\binvoke\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bdispatch\\s+(?:to\\s+)?(?:the\\s+)?[`/]?"+t+`\\b`,"\\bwrap\\s+(?:the\\s+)?[`/]?"+t+`\\s+in\\s+(?:a\\s+)?(?:task|agent|subagent)\\b`,"\\bdelegate\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\brun\\s+(?:the\\s+)?[`/]?"+t+`\\s+(?:via|in)\\s+(?:a\\s+)?(?:subagent|task|agent)\\b`,"\\b(?:run|execute|launch)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bskill:\\s*[`/]?"+t+`\\b`,`\\bskill:\\/\\/`+t+`\\b`,`(?:^|\\W)/`+t+`(?=$|\\b|\\W)`,"\\buse\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bload\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bspawn\\s+(?:a\\s+)?(?:task|agent|subagent|worker)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bcall\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bsend\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bcreate\\s+(?:a\\s+)?(?:task|agent|subagent)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bstart\\s+(?:the\\s+)?[`/]?"+t+`\\b`],referenceVerbs:["\\bsee\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bper\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bread\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\baccording\\s+to\\s+(?:the\\s+)?[`/]?"+t+`\\b`],mentionPatterns:Object.fromEntries(e.map(e=>[e,'(?:^|[\\s/.`"])'+$(e)+'(?=$|[\\s/.`"]|\\b)']))}}function pe(e){return O(e).pipe(A(`Block`,e=>({block:!0,reason:e.reason,how:e.how,skill:e.skill})),A(`Allow`,()=>void 0),M)}function me(e){return c(function*(){return fe((yield*(yield*p).load(e)).no_delegate_skills??[])})}function he(e,t,n,r){return c(function*(){return pe(de(new te({toolName:t,subagentType:n,prompt:r,guard:yield*me(e)})))})}export{he as runNoSkillDelegation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Cs as e,Er as t,Is as n,Kt as r,Lr as i,Sc as a,Ts as o,mr as s,mt as c,vn as l,wr as u,xs as ee,yl as d,yn as te,zs as f}from"./core-CwsVf2Ey.js";import{B as ne,Bt as re,Gt as p,H as m,Ht as h,Jt as g,Kt as ie,Lt as ae,P as _,Q as oe,Rt as se,Sn as v,Ut as y,Vt as b,Wt as x,Xt as ce,Yt as le,_ as S,an as ue,b as C,c as w,dt as de,et as fe,f as pe,it as me,mn as he,mt as ge,n as T,nn as E,nt as D,on as _e,qt as ve,r as O,rt as k,st as A,tt as j,un as M,zt as N}from"./Effect-BcYkmFCx.js";import{D as P,E as F,T as ye,a as be,c as xe,d as Se,f as Ce,g as we,h as Te,i as Ee,l as De,m as I,n as Oe,o as L,p as ke,r as R,s as z,u as Ae}from"./dist-
|
|
1
|
+
import{Cs as e,Er as t,Is as n,Kt as r,Lr as i,Sc as a,Ts as o,mr as s,mt as c,vn as l,wr as u,xs as ee,yl as d,yn as te,zs as f}from"./core-CwsVf2Ey.js";import{B as ne,Bt as re,Gt as p,H as m,Ht as h,Jt as g,Kt as ie,Lt as ae,P as _,Q as oe,Rt as se,Sn as v,Ut as y,Vt as b,Wt as x,Xt as ce,Yt as le,_ as S,an as ue,b as C,c as w,dt as de,et as fe,f as pe,it as me,mn as he,mt as ge,n as T,nn as E,nt as D,on as _e,qt as ve,r as O,rt as k,st as A,tt as j,un as M,zt as N}from"./Effect-BcYkmFCx.js";import{D as P,E as F,T as ye,a as be,c as xe,d as Se,f as Ce,g as we,h as Te,i as Ee,l as De,m as I,n as Oe,o as L,p as ke,r as R,s as z,u as Ae}from"./dist-DIH94u3_.js";import*as je from"node:os";import*as Me from"node:crypto";import*as B from"node:path";import*as V from"node:fs";function H(e,t){return l(e.runtimeEffect,e=>i(n=>(n.setFiberRefs(e.fiberRefs),n.currentRuntimeFlags=e.runtimeFlags,s(t,e.context))))}const Ne={...v,[E]:E,pipe(){return a(this,arguments)},commit(){return this.runtimeEffect}},Pe=(e,n)=>{n??=se();let i=g(M()),a,o=u(()=>{if(!a){let r=new he;a=b(t(_e(ae(e,n),i),e=>{s.cachedRuntime=e}),{scope:i,scheduler:r}),r.flush()}return te(a.await)}),s=Object.assign(Object.create(Ne),{memoMap:n,scope:i,runtimeEffect:o,cachedRuntime:void 0,runtime(){return s.cachedRuntime===void 0?x(s.runtimeEffect):Promise.resolve(s.cachedRuntime)},dispose(){return x(s.disposeEffect)},disposeEffect:u(()=>(s.runtimeEffect=c(`ManagedRuntime disposed`),s.cachedRuntime=void 0,ue(s.scope,r))),runFork(e,t){return s.cachedRuntime===void 0?b(H(s,e),t):re(s.cachedRuntime)(e,t)},runSyncExit(e){return s.cachedRuntime===void 0?ce(H(s,e)):le(s.cachedRuntime)(e)},runSync(e){return s.cachedRuntime===void 0?g(H(s,e)):ve(s.cachedRuntime)(e)},runPromiseExit(e,t){return s.cachedRuntime===void 0?ie(H(s,e),t):p(s.cachedRuntime)(e,t)},runCallback(e,t){return s.cachedRuntime===void 0?h(N)(H(s,e),t):h(s.cachedRuntime)(e,t)},runPromise(e,t){return s.cachedRuntime===void 0?x(H(s,e),t):y(s.cachedRuntime)(e,t)}});return s},U=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`;break}return new I({reason:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,description:n.message,cause:n})},W=(e,t,n)=>(...r)=>w(i=>{try{e(...r,(e,n)=>{i(e?S(t?t(e,r):e):j(n))})}catch(e){i(n?S(n(e,r)):pe(e))}}),G=e=>t=>new ke({module:`FileSystem`,method:e,cause:t}),Fe=(()=>{let e=W(V.access,U(`FileSystem`,`access`),G(`access`));return(t,n)=>{let r=V.constants.F_OK;return n?.readable&&(r|=V.constants.R_OK),n?.writable&&(r|=V.constants.W_OK),e(t,r)}})(),Ie=(()=>{let e=W(V.cp,U(`FileSystem`,`copy`),G(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),Le=(()=>{let e=W(V.copyFile,U(`FileSystem`,`copyFile`),G(`copyFile`));return(t,n)=>e(t,n)})(),Re=(()=>{let e=W(V.chmod,U(`FileSystem`,`chmod`),G(`chmod`));return(t,n)=>e(t,n)})(),ze=(()=>{let e=W(V.chown,U(`FileSystem`,`chown`),G(`chown`));return(t,n,r)=>e(t,n,r)})(),Be=(()=>{let e=W(V.link,U(`FileSystem`,`link`),G(`link`));return(t,n)=>e(t,n)})(),Ve=(()=>{let e=W(V.mkdir,U(`FileSystem`,`makeDirectory`),G(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),K=e=>{let t=W(V.mkdtemp,U(`FileSystem`,e),G(e));return e=>D(()=>{let n=e?.prefix??``,r=typeof e?.directory==`string`?B.join(e.directory,`.`):je.tmpdir();return t(n?B.join(r,n):r+`/`)})},He=K(`makeTempDirectory`),q=e=>{let t=W(V.rm,U(`FileSystem`,e),G(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},Ue=q(`remove`),We=(()=>{let e=K(`makeTempDirectoryScoped`),t=q(`makeTempDirectoryScoped`);return n=>O(e(n),e=>m(t(e,{recursive:!0})))})(),J=e=>{let t=W(V.open,U(`FileSystem`,e),G(e)),n=W(V.close,U(`FileSystem`,e),G(e));return(e,r)=>d(O(t(e,r?.flag??`r`,r?.mode),e=>m(n(e))),_(e=>Ke(Ee(e),r?.flag?.startsWith(`a`)??!1)))},Ge=J(`open`),Ke=(()=>{let e=e=>W(V.read,U(`FileSystem`,e),G(e)),t=e(`read`),r=e(`readAlloc`),i=W(V.fstat,U(`FileSystem`,`stat`),G(`stat`)),a=W(V.ftruncate,U(`FileSystem`,`truncate`),G(`truncate`)),o=W(V.fsync,U(`FileSystem`,`sync`),G(`sync`)),s=e=>W(V.write,U(`FileSystem`,e),G(e)),c=s(`write`),l=s(`writeAll`);class u{fd;append;[L];semaphore=de(1);position=0n;constructor(e,t){this.fd=e,this.append=t,this[L]=L}get stat(){return _(i(this.fd),Z)}get sync(){return o(this.fd)}seek(e,t){let n=z(e);return this.semaphore.withPermits(1)(k(()=>(t===`start`?this.position=n:t===`current`&&(this.position+=n),this.position)))}read(e){return this.semaphore.withPermits(1)(_(D(()=>t(this.fd,{buffer:e,position:this.position})),e=>{let t=z(e);return this.position+=t,t}))}readAlloc(e){let t=Number(e);return this.semaphore.withPermits(1)(C(k(()=>Buffer.allocUnsafeSlow(t)),e=>_(r(this.fd,{buffer:e,position:this.position}),r=>{if(r===0)return n();if(this.position+=BigInt(r),r===t)return f(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),f(i)})))}truncate(e){return this.semaphore.withPermits(1)(_(a(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}}))}write(e){return this.semaphore.withPermits(1)(_(D(()=>c(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),e=>{let t=z(e);return this.append||(this.position+=t),t}))}writeAllChunk(e){return C(D(()=>l(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),t=>t===0?S(new I({module:`FileSystem`,method:`writeAll`,reason:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position+=BigInt(t)),t<e.length?this.writeAllChunk(e.subarray(t)):T))}writeAll(e){return this.semaphore.withPermits(1)(this.writeAllChunk(e))}}return(e,t)=>new u(e,t)})(),Y=e=>{let t=K(e),n=J(e),r=e=>k(()=>Me.randomBytes(e).toString(`hex`));return e=>d(ge(t(e),r(6)),_(([t,n])=>B.join(t,n+(e?.suffix??``))),me(e=>oe(n(e,{flag:`w+`}))))},qe=Y(`makeTempFile`),Je=(()=>{let e=Y(`makeTempFileScoped`),t=q(`makeTempFileScoped`);return n=>O(e(n),e=>m(t(B.dirname(e),{recursive:!0})))})(),Ye=(e,t)=>A({try:()=>V.promises.readdir(e,t),catch:t=>U(`FileSystem`,`readDirectory`)(t,[e])}),Xe=e=>w((t,n)=>{try{V.readFile(e,{signal:n},(n,r)=>{t(n?S(U(`FileSystem`,`readFile`)(n,[e])):j(r))})}catch(e){t(S(G(`readFile`)(e)))}}),Ze=(()=>{let e=W(V.readlink,U(`FileSystem`,`readLink`),G(`readLink`));return t=>e(t)})(),X=(()=>{let e=W(V.realpath,U(`FileSystem`,`realPath`),G(`realPath`));return t=>e(t)})(),Qe=(()=>{let e=W(V.rename,U(`FileSystem`,`rename`),G(`rename`));return(t,n)=>e(t,n)})(),Z=t=>({type:t.isFile()?`File`:t.isDirectory()?`Directory`:t.isSymbolicLink()?`SymbolicLink`:t.isBlockDevice()?`BlockDevice`:t.isCharacterDevice()?`CharacterDevice`:t.isFIFO()?`FIFO`:t.isSocket()?`Socket`:`Unknown`,mtime:e(t.mtime),atime:e(t.atime),birthtime:e(t.birthtime),dev:t.dev,rdev:e(t.rdev),ino:e(t.ino),mode:t.mode,nlink:e(t.nlink),uid:e(t.uid),gid:e(t.gid),size:z(t.size),blksize:e(z(t.blksize)),blocks:e(t.blocks)}),Q=(()=>{let e=W(V.stat,U(`FileSystem`,`stat`),G(`stat`));return t=>_(e(t),Z)})(),$e=(()=>{let e=W(V.symlink,U(`FileSystem`,`symlink`),G(`symlink`));return(t,n)=>e(t,n)})(),et=(()=>{let e=W(V.truncate,U(`FileSystem`,`truncate`),G(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),tt=(()=>{let e=W(V.utimes,U(`FileSystem`,`utime`),G(`utime`));return(t,n,r)=>e(t,n,r)})(),nt=(e,t)=>Te(n=>O(k(()=>{let r=V.watch(e,{recursive:t?.recursive},(e,t)=>{if(t)switch(e){case`rename`:n.fromEffect(ne(Q(t),{onSuccess:e=>j(De({path:t})),onFailure:e=>e._tag===`SystemError`&&e.reason===`NotFound`?j(Ae({path:t})):S(e)}));return;case`change`:n.single(Se({path:t}));return}});return r.on(`error`,t=>{n.fail(new I({module:`FileSystem`,reason:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t}))}),r.on(`close`,()=>{n.end()}),r}),e=>k(()=>e.close()))),rt=(e,t,n)=>Q(t).pipe(_(r=>e.pipe(ee(e=>e.register(t,r,n)),o(()=>nt(t,n)))),we),it=(e,t,n)=>w((r,i)=>{try{V.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?S(U(`FileSystem`,`writeFile`)(t,[e])):T)})}catch(e){r(S(G(`writeFile`)(e)))}}),$=ye(be,_(fe(xe),e=>Ce({access:Fe,chmod:Re,chown:ze,copy:Ie,copyFile:Le,link:Be,makeDirectory:Ve,makeTempDirectory:He,makeTempDirectoryScoped:We,makeTempFile:qe,makeTempFileScoped:Je,open:Ge,readDirectory:Ye,readFile:Xe,readLink:Ze,realPath:X,remove:Ue,rename:Qe,stat:Q,symlink:$e,truncate:et,utimes:tt,watch(t,n){return rt(e,t,n)},writeFile:it}))),at=Pe(F($,R,Oe.pipe(P($),P(R))));export{at as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/omp-agent-discipline",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
6
|
"description": "OMP agent discipline: mechanical enforcement of rules prose can't hold (xd:// retry guard, ...)",
|
|
7
7
|
"type": "module",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"./package.json": "./package.json"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"dist"
|
|
13
|
+
"dist",
|
|
14
|
+
"skills"
|
|
14
15
|
],
|
|
15
16
|
"peerDependencies": {
|
|
16
17
|
"@effect/platform": "^0.97.0",
|
|
@@ -30,10 +31,10 @@
|
|
|
30
31
|
"typescript": "^7",
|
|
31
32
|
"vitest": "^4",
|
|
32
33
|
"@systemfsoftware/effect-gherkin-spec": "^0.4.1",
|
|
33
|
-
"@systemfsoftware/omp-utils": "^0.0.0",
|
|
34
34
|
"@systemfsoftware/oxlint-config": "^0.1.0",
|
|
35
35
|
"@systemfsoftware/tsconfig": "^1.2.6",
|
|
36
|
-
"@systemfsoftware/effect-memfs": "^1.0.8"
|
|
36
|
+
"@systemfsoftware/effect-memfs": "^1.0.8",
|
|
37
|
+
"@systemfsoftware/omp-utils": "^0.0.0"
|
|
37
38
|
},
|
|
38
39
|
"omp": {
|
|
39
40
|
"extensions": [
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: task-decomposition
|
|
3
|
+
description: >-
|
|
4
|
+
Decompose work into bounded, verifiable units before delegating to
|
|
5
|
+
subagents; refuse monolithic dispatches. Use when fanning out subagents,
|
|
6
|
+
parallelizing work, sizing loop work units, or when a worker runs too
|
|
7
|
+
long or its output takes too long to verify. Triggers: 'split into
|
|
8
|
+
subagents', 'fan out', 'parallelize', 'decompose the task'. Do not use
|
|
9
|
+
for one-shot single-agent tasks.
|
|
10
|
+
license: MIT
|
|
11
|
+
metadata:
|
|
12
|
+
version: "1.2.0"
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Task Decomposition
|
|
16
|
+
|
|
17
|
+
A subagent handed one massive task fails twice: it runs too long, and its output is too large to verify. Both are specification failures, preventable before dispatch — never after. This skill is the pre-dispatch discipline: size the unit, specify it completely, then dispatch or refuse.
|
|
18
|
+
|
|
19
|
+
Applies to any orchestrator that spawns workers: interactive fan-out, loop work-unit design, multi-agent topology planning.
|
|
20
|
+
|
|
21
|
+
<!-- BEGIN DOCTRINE KERNEL -->
|
|
22
|
+
|
|
23
|
+
Refuse monolithic dispatches: size the unit, specify it completely, then dispatch — or do the work inline.
|
|
24
|
+
|
|
25
|
+
rules:
|
|
26
|
+
|
|
27
|
+
- GATE: decomposition is mandatory when ANY hold — multi-subsystem; exceeds one focused session for the worker's model class; irreversible side effects; verification longer than the work; incompatible reasoning modes. Dispatching monolithically anyway is an invalid dispatch: split, or do it yourself.
|
|
28
|
+
- SPEC: every dispatched unit carries objective, write_scope, verify_commands, acceptance, size_estimate, context_paths, rollback, dependencies — written before work starts. Missing any field is undispatchable.
|
|
29
|
+
- CHECK: verifier is not the maker. Run each unit's verify commands fresh in your own context; never accept a worker's reported output or completeness claims. A verify failure rejects the unit: record the failure, re-dispatch with the evidence.
|
|
30
|
+
- FENCE: parallel units need disjoint write scopes, confirmed by comparing write_scope declarations literally — never inferred from topic. Overlap forces serialization.
|
|
31
|
+
|
|
32
|
+
Full doctrine: skill://task-decomposition — sizing calibration, the dispatch contract, rejection rules, repair-retry. Refuse monolithic dispatches: size, specify, then dispatch or refuse.
|
|
33
|
+
|
|
34
|
+
<!-- END DOCTRINE KERNEL -->
|
|
35
|
+
|
|
36
|
+
Core rules as a machine-parseable block:
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
rules:
|
|
40
|
+
- id: GATE
|
|
41
|
+
title: Sizing gate mandatory before dispatch
|
|
42
|
+
do: apply the sizing gate (multi-subsystem, exceeds one session, irreversible side effects, verification longer than work) before every subagent dispatch
|
|
43
|
+
dont: skip the gate for async or background workers — the same failure modes apply
|
|
44
|
+
harm: monolithic dispatches run too long, fail more often, and produce unverifiable outputs that waste the orchestrator's verification budget
|
|
45
|
+
check: every dispatch is preceded by a sizing decision (decomposed vs. single-unit) recorded in the unit spec
|
|
46
|
+
|
|
47
|
+
- id: SPEC
|
|
48
|
+
title: Complete unit spec required for every dispatch
|
|
49
|
+
do: write every dispatched unit with objective, write_scope, verify_commands, acceptance, size_estimate, context_paths, rollback, dependencies before the worker starts
|
|
50
|
+
dont: dispatch incomplete or vague specs — "implement auth" is not a dispatch
|
|
51
|
+
harm: a worker without a bounded scope produces unbounded output; verification becomes impossible
|
|
52
|
+
check: every dispatch bundle has all eight fields before spawning the worker
|
|
53
|
+
|
|
54
|
+
- id: CHECK
|
|
55
|
+
title: Verifier is not the maker
|
|
56
|
+
do: run per-unit verification in a fresh context on a different model lineage than the worker
|
|
57
|
+
dont: accept the worker's own claims about completeness or quality
|
|
58
|
+
harm: self-verified work compounds errors; the failure the worker missed drives the next unit off a wrong baseline
|
|
59
|
+
check: every verify command is run in the orchestrator's context (or a dedicated verifier), never by the maker
|
|
60
|
+
|
|
61
|
+
- id: FENCE
|
|
62
|
+
title: Write scopes must be disjoint for parallel units
|
|
63
|
+
do: verify that parallel units touch no overlapping files before dispatching; overlap forces serialization
|
|
64
|
+
dont: infer disjointness from topic — confirm it by comparing write_scope declarations
|
|
65
|
+
harm: parallel writers on overlapping files produce merge conflicts and lost work
|
|
66
|
+
check: every parallel batch has a cross-write-scope comparison recorded
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## When to Activate
|
|
70
|
+
|
|
71
|
+
- Before spawning a subagent/worker whose task exceeds one focused work session
|
|
72
|
+
- When designing loop work units or delegation policy
|
|
73
|
+
- After observing: worker runtime approaching the whole task budget, verification longer than the work, a wandering worker
|
|
74
|
+
|
|
75
|
+
Do not activate for: work one agent finishes in one sitting, deterministic pipelines, narrow read-only lookups.
|
|
76
|
+
|
|
77
|
+
For deep research problems that require comprehensive multi-source analysis with adversarial review, route by capability: a deep-research pipeline that performs tier-adaptive multi-source analysis with adversarial audit (triggers: 'deep research', 'comprehensive analysis', 'literature review'). Decomposition of a research query into atomic items is step 1 of that pipeline; this skill covers the sizing and specification of coding-task units.
|
|
78
|
+
|
|
79
|
+
## The Sizing Gate
|
|
80
|
+
|
|
81
|
+
Decomposition is mandatory when ANY hold:
|
|
82
|
+
|
|
83
|
+
1. **Multi-subsystem** — the task touches more than one architectural layer or package boundary
|
|
84
|
+
2. **Exceeds one session** — it cannot be completed in one focused work session for the assigned worker's model class
|
|
85
|
+
3. **Irreversible side effects** — migrations, deletions, external API writes that cannot be rolled back atomically
|
|
86
|
+
4. **Verification longer than work** — reviewing the whole result would take longer than producing it
|
|
87
|
+
5. **Reasoning-mode conflict** — the task requires multiple incompatible reasoning modes (abductive exploration, counterfactual analysis, meta-inductive rule extraction, corrective debugging) that pull a shared context in conflicting directions
|
|
88
|
+
|
|
89
|
+
Gate fires and you dispatch monolithically anyway → invalid dispatch. Split, or do the work yourself sequentially. Budgets are model-relative — a cheap small-context worker gets smaller units than a frontier worker.
|
|
90
|
+
|
|
91
|
+
Model-relative budgets, full criteria, and the calibration procedure: read `references/sizing-gate.md`; if it is not loaded, stop and load it before sizing units.
|
|
92
|
+
|
|
93
|
+
## The Unit Spec — no dispatch without it
|
|
94
|
+
|
|
95
|
+
Every dispatched unit carries, written before work starts:
|
|
96
|
+
|
|
97
|
+
| Field | Purpose |
|
|
98
|
+
| ----------------- | ------------------------------------------------------------------------------ |
|
|
99
|
+
| `objective` | One sentence: what exists after this unit that did not exist before |
|
|
100
|
+
| `write_scope` | Explicit file/glob ownership; worker modifies nothing outside it |
|
|
101
|
+
| `verify_commands` | Exact runnable checks for this unit, scoped to the increment |
|
|
102
|
+
| `acceptance` | Observable behavior a reviewer can confirm on this increment alone |
|
|
103
|
+
| `size_estimate` | Expected files and verify minutes; must fit the assigned worker's class budget |
|
|
104
|
+
| `context_paths` | The exact files the worker must read first |
|
|
105
|
+
| `rollback` | Recovery path if the unit leaves a partial state |
|
|
106
|
+
| `dependencies` | Units that must complete first |
|
|
107
|
+
|
|
108
|
+
Missing any field → undispatchable. If a field is unfillable, the task is not decomposed enough.
|
|
109
|
+
|
|
110
|
+
## Surface Classification
|
|
111
|
+
|
|
112
|
+
Before decomposing, classify what each unit can touch:
|
|
113
|
+
|
|
114
|
+
| Surface | Rule | Example |
|
|
115
|
+
| ---------------- | --------------------------------------------------- | ------------------------------------------------------------ |
|
|
116
|
+
| Locked | Never modified by a worker; orchestrator-only | CI configs, deploy manifests, shared schemas, root AGENTS.md |
|
|
117
|
+
| Editable | Declared in write_scope; worker owns it until merge | A package's source files, a feature's test files |
|
|
118
|
+
| Append-only | Workers append but never overwrite | Logs, changelogs, durable action records |
|
|
119
|
+
| Human-controlled | Worker prepares but never submits | PRs, deploys, releases, database migrations, credentials |
|
|
120
|
+
|
|
121
|
+
The `write_scope` field in every unit spec declares the editable surfaces the worker may touch. Fence breaches (touching undeclared surfaces) are rejection grounds per the dispatch contract.
|
|
122
|
+
|
|
123
|
+
## The Dispatch Contract
|
|
124
|
+
|
|
125
|
+
- Vague delegation ("implement auth", "review this phase") is invalid — decompose further or do it inline.
|
|
126
|
+
- Hand off a file, not a chat message; pass the path.
|
|
127
|
+
- Parallel writers need disjoint write scopes; overlap → serialize.
|
|
128
|
+
- Sequential units verify green before the next starts; never implement-all-then-test.
|
|
129
|
+
- One maker per unit; verifier is not the maker (fresh context, different lineage where affordable).
|
|
130
|
+
|
|
131
|
+
Rejection rules, acceptance protocol, and repair-retry: read `references/dispatch-contract.md`; if it is not loaded, stop and load it before accepting any worker result.
|
|
132
|
+
|
|
133
|
+
## Context and Gate Discipline
|
|
134
|
+
|
|
135
|
+
Two structural innovations from the latest SOTA research that refine how units are dispatched and verified:
|
|
136
|
+
|
|
137
|
+
### Context window isolation
|
|
138
|
+
|
|
139
|
+
Each unit operates in a **clean context window**. The orchestrator never passes accumulated history from prior units into a new worker — context coupling degrades edit reliability and inflates cost. On completion, the unit folds its state (summarises what it learned and what changed) for the orchestrator, then the worker's context is evicted entirely.
|
|
140
|
+
|
|
141
|
+
Implementation: the unit spec's `context_paths` field lists only the files the worker MUST read first. The orchestrator launches each worker with only those files plus the unit spec. No prior unit's conversation, no accumulated tool output, no stale state.
|
|
142
|
+
|
|
143
|
+
Measured effect (SWE-Edit, 2026): +2.1 pp resolve rate, -17.9% inference cost on SWE-Bench Verified by decomposing Viewer from Editor into isolated contexts.
|
|
144
|
+
|
|
145
|
+
### Verifiable acceptance gates
|
|
146
|
+
|
|
147
|
+
A "done" claim from a worker is not evidence. The only valid signal is a **falsifiable gate that the orchestrator itself runs** — a verify command that could fail, checked before accepting the result.
|
|
148
|
+
|
|
149
|
+
Principle (Goal-Autopilot, 2026): under gate soundness, floor enforcement, and plan coverage, termination implies the goal holds. The structural failure mode is an honest stall (gate didn't pass → don't claim done), never a fabricated success (claim done without running the gate).
|
|
150
|
+
|
|
151
|
+
Implementation:
|
|
152
|
+
|
|
153
|
+
- Every unit spec's `verify_commands` MUST be runnable by the orchestrator in its own context, not by the worker.
|
|
154
|
+
- The orchestrator runs the verify commands FRESH — never accepts the worker's reported output.
|
|
155
|
+
- If a verify command fails, the unit is rejected. The correct response is honest-stall: record the failure, re-dispatch with the failure evidence.
|
|
156
|
+
- A unit whose verify commands cannot be run independently of the worker's context is structurally undispatchable — decompose further.
|
|
157
|
+
|
|
158
|
+
Measured effect (Goal-Autopilot, 2026): 0.67% fabrication on SWE-bench Lite vs 33.7% (StateFlow baseline) — paired difference -33.07 pp [95% CI -36.53, -29.73].
|
|
159
|
+
|
|
160
|
+
## Examples
|
|
161
|
+
|
|
162
|
+
**Good unit spec** (single subsystem, bounded verify):
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
objective: "Add POST /api/checkout endpoint with Stripe session creation"
|
|
166
|
+
write_scope: ["apps/api/src/routes/checkout.ts", "apps/api/src/routes/checkout.test.ts"]
|
|
167
|
+
verify_commands:
|
|
168
|
+
- "pnpm --filter api test -- tests/routes/checkout.test.ts"
|
|
169
|
+
- "curl -s -X POST http://localhost:3000/api/checkout -d '{}' | grep -c sessionId"
|
|
170
|
+
acceptance: "POST /api/checkout returns 201 with a Stripe session ID for a valid cart"
|
|
171
|
+
size_estimate: { files: 3, verify_minutes: 2 }
|
|
172
|
+
rollback: "git checkout HEAD -- apps/api/src/routes/checkout.ts"
|
|
173
|
+
dependencies: []
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Bad unit spec** — multi-subsystem, unverifiable, no bounded scope:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
"implement Stripe billing"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Why bad**: no filesystem boundary (UI + API + DB + webhooks), no verify commands, no acceptance criteria, no size estimate. The worker produces output spanning the entire app; verification is impossible. Correct decomposition: split into UI checkout / API session creation / webhook handling / subscription state — four units, each with its own complete spec.
|
|
183
|
+
|
|
184
|
+
## Integration
|
|
185
|
+
|
|
186
|
+
- **Loop kits**: the sizing gate lives in the kit's delegation block and requirement inventory, enforced at seal time and at dispatch time. Architect units once; every fresh iteration inherits them pre-sized.
|
|
187
|
+
- **Interactive fan-out**: apply the gate before each spawn; write each unit spec to a scratch file; pass paths.
|
|
188
|
+
- **Topology last**: decide agent count and roles only after the units exist — a swarm sized before the units produces coordinated noise.
|
|
189
|
+
- **Hierarchy placement**: this skill is the how (loaded on trigger); the must (mandatory gate before delegation) lives in the CLAUDE.md or AGENTS.md always-in-context rules. The harness provides the mandate; this skill provides the procedure.
|
|
190
|
+
- **Capability-aligned decomposition**: decompose by capability boundary, not by topic. A "checkout" unit that writes frontend + API + DB touches three capabilities — split further. Each unit aligns with one capability boundary: tool authority, data domain, verification design. Verification design is a first-class dimension of the unit, not a post-hoc addition. Research basis: CEAD reference architecture ([arXiv:2605.08258](https://arxiv.org/abs/2605.08258)).
|
|
191
|
+
|
|
192
|
+
Research basis for every rule (specification/verification failure taxonomy, front-loaded instruction effects, per-step verification, attention degradation, heterogeneous model routing, context coupling and clean-context decomposition, verifiable anti-fabrication gates, reasoning-mode decomposition, capability-aligned verification design, multi-stage tool-augmented decomposition, verifiable task synthesis at scale): read `references/research-grounding.md` — consult when justifying or calibrating a rule, not for routine dispatches.
|
|
193
|
+
|
|
194
|
+
## Resources
|
|
195
|
+
|
|
196
|
+
- `references/sizing-gate.md` — gate criteria, model-relative budgets, calibration, edge cases
|
|
197
|
+
- `references/dispatch-contract.md` — bundle fields, rejection rules, repair-retry, action records
|
|
198
|
+
- `references/research-grounding.md` — peer-reviewed basis and its limits
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# The Dispatch Contract — bundle completeness, output rejection, repair-retry
|
|
2
|
+
|
|
3
|
+
Load this when PREPARING a dispatch or ACCEPTING/REJECTING a worker's result.
|
|
4
|
+
|
|
5
|
+
## The dispatch bundle — all fields required
|
|
6
|
+
|
|
7
|
+
A dispatch is a file, not a chat message. Write it to disk; pass the path. Required fields:
|
|
8
|
+
|
|
9
|
+
1. `objective` — one sentence: what exists after this unit that did not exist before
|
|
10
|
+
2. `write_scope` — explicit file/glob ownership; the worker modifies nothing outside it
|
|
11
|
+
3. `verify_commands` — exact runnable checks for this unit (argv, cwd, timeout), scoped to the increment
|
|
12
|
+
4. `acceptance` — observable behavior a reviewer can confirm on this increment alone
|
|
13
|
+
5. `size_estimate` — expected files / verify minutes; must fit the assigned worker's class budget
|
|
14
|
+
6. `context_paths` — the exact files the worker must read first (upstream specs, relevant source)
|
|
15
|
+
7. `rollback` — recovery path if the unit leaves a partial state
|
|
16
|
+
8. `dependencies` — units that must complete first; absent means parallel-eligible ONLY if write scopes are disjoint
|
|
17
|
+
9. `worker_class` — the model class assigned to this unit, derived from `size_estimate.files` against `delegation.unit_budgets`. One of `frontier` | `cheap_agentic` | `small_local`. Operators may override; the runner defaults to the cheapest class that fits.
|
|
18
|
+
|
|
19
|
+
If any field is unfillable, the task is not decomposed enough. Do NOT dispatch and "let the worker figure it out" — that is the monolithic-dispatch failure wearing a smaller costume.
|
|
20
|
+
|
|
21
|
+
## Vague dispatch is invalid
|
|
22
|
+
|
|
23
|
+
These are not dispatches: "implement auth", "review this phase", "fix the tests", "handle the backend". Each lacks verifiable acceptance and a bounded scope. The correct move when you catch yourself writing one: decompose further, or do the work yourself sequentially. An orchestrator doing a small unit inline is cheaper than a worker doing a big unit badly.
|
|
24
|
+
|
|
25
|
+
## Output rejection rules — reject when ANY hold
|
|
26
|
+
|
|
27
|
+
- No explicit verdict / completion claim
|
|
28
|
+
- Claims files changed but doesn't list them, or the list doesn't match the actual diff
|
|
29
|
+
- Doesn't cite which spec/context files it read
|
|
30
|
+
- Ran no verify commands, or ran different ones than specified, or can't show output
|
|
31
|
+
- Generic praise of its own work ("everything looks good") with no grounded findings
|
|
32
|
+
- Touched files outside the declared write scope (fence breach — also a severity escalation)
|
|
33
|
+
- Output can't be checked without trusting the worker's reasoning — the check must be against reality (diff, files, command output), never against the worker's narrative
|
|
34
|
+
|
|
35
|
+
## Acceptance protocol
|
|
36
|
+
|
|
37
|
+
1. Diff the write scope: every claimed file appears in the actual diff; nothing outside scope changed.
|
|
38
|
+
2. Run the unit's verify commands FRESH — not the worker's reported output, your own run.
|
|
39
|
+
3. Check acceptance behavior on this increment alone.
|
|
40
|
+
4. Only then mark the unit complete and allow dependent units to start.
|
|
41
|
+
|
|
42
|
+
## Repair-retry protocol
|
|
43
|
+
|
|
44
|
+
When a unit fails:
|
|
45
|
+
|
|
46
|
+
1. Record the failure evidence (which verify command, what output).
|
|
47
|
+
2. Re-dispatch the SAME unit to a fresh worker with the exact failure named and the corrected spec. Do not patch worker output yourself and mark it done — that hides the failure rate you need for calibration and breaks maker/checker separation.
|
|
48
|
+
3. A re-dispatch with an IDENTICAL spec after an identical failure is no-progress: change the mechanism (smaller unit, different model class, clarified acceptance) or escalate to the operator.
|
|
49
|
+
4. Three failures of the same unit under materially different mechanisms → park the unit for a human; the spec itself is likely wrong.
|
|
50
|
+
|
|
51
|
+
## Durable action records
|
|
52
|
+
|
|
53
|
+
Every dispatched unit leaves a record: bundle path, worker identity/model, claimed changes, verify output paths, verdict, acceptance decision. Chat logs are not records — they compact away. The record is what lets a fresh agent audit the delegation chain later without trusting anyone's summary.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Research Grounding — why each rule exists
|
|
2
|
+
|
|
3
|
+
Every rule in this skill traces to peer-reviewed or primary-source evidence. Load this when you need to justify, calibrate, or push back on a rule — not for routine dispatches.
|
|
4
|
+
|
|
5
|
+
## Decomposition beats monolithic execution
|
|
6
|
+
|
|
7
|
+
- **Zhou et al., "Least-to-Most Prompting Enables Complex Reasoning in Large Language Models"** (ICLR 2023, [arXiv:2205.10625](https://arxiv.org/abs/2205.10625)). Decompose-then-solve-sequentially beats monolithic chain-of-thought, with the gap WIDENING as problems get harder than anything in the model's context (SCAN length-generalization: ~99% vs ~16%). Implication: the monolithic worker doesn't just run long — it fails more, and retries are what consume wall-clock.
|
|
8
|
+
- **Wang et al., "TDAG: A Multi-Agent Framework based on Dynamic Task Decomposition and Agent Generation"** (2024, [arXiv:2402.10178](https://arxiv.org/abs/2402.10178)). One purpose-built subagent per bounded subtask outperforms fixed agents with sprawling briefs. Basis for "one maker per unit."
|
|
9
|
+
|
|
10
|
+
## Specification and verification are the dominant failure categories
|
|
11
|
+
|
|
12
|
+
- **Cemri et al., "Why Do Multi-Agent LLM Systems Fail?" (MAST)** (NeurIPS 2025, [arXiv:2503.13657](https://arxiv.org/abs/2503.13657)). 14 failure modes over 150+ execution traces across 5 frameworks, in three categories: specification failures, inter-agent misalignment, verification/termination failures. The monolithic rammed-in task is a specification failure; the unverifiable giant output is a verification failure. Their demonstrated mitigations — better specification, multi-level verification — are structural, not prompt-level. Also: more agents is NOT inherently better (coordination failures are their own category) — basis for "one maker by default; decompose on evidence."
|
|
13
|
+
|
|
14
|
+
## Per-unit verification beats end-of-run verification
|
|
15
|
+
|
|
16
|
+
- **Lightman et al., "Let's Verify Step by Step"** (ICLR 2024, [paper](https://proceedings.iclr.cc/paper_files/paper/2024/file/aca97732e30bcf1303bc22ac3924fd16-Paper-Conference.pdf)). Process supervision significantly outperforms outcome supervision (78.2% vs 72.4% on MATH). End-of-run verification of a giant diff is the hardest and weakest check; per-unit checks are smaller, earlier, more accurate. Caveat: Jia et al., "Do We Need to Verify Step by Step?" (2025, [arXiv:2502.10581](https://arxiv.org/abs/2502.10581)) complicates the RL-supervision story — per-unit verification here earns its keep through SCOPING (bounded diff, fresh context), which their critique doesn't touch.
|
|
17
|
+
|
|
18
|
+
## Front-loaded, fully-specified instructions
|
|
19
|
+
|
|
20
|
+
- **Laban et al., "LLMs Get Lost in Multi-Turn Conversation"** (2025, [arXiv:2505.06120](https://arxiv.org/abs/2505.06120)). Average 39% performance drop when instructions unfold over turns vs. one fully-specified prompt; wrong early turns are unrecoverable. Basis for: complete unit spec at dispatch, in a file, never negotiated in chat; fresh agent + complete spec per unit.
|
|
21
|
+
|
|
22
|
+
## Context growth degrades attention
|
|
23
|
+
|
|
24
|
+
- **Liu et al., "Lost in the Middle: How Language Models Use Long Contexts"** (TACL 2024, [arXiv:2307.03172](https://arxiv.org/abs/2307.03172)). U-shaped attention: reliable at context edges, substantial degradation mid-context, worsening with length even below nominal limits. A long-running worker's own brief and verify commands rot mid-context. Basis for small units and brief-at-the-edges.
|
|
25
|
+
|
|
26
|
+
## Structured handoffs beat dialogue
|
|
27
|
+
|
|
28
|
+
- **Hong et al., "MetaGPT: Meta Programming for a Multi-Agent Collaborative Framework"** (ICLR 2024, [arXiv:2308.00352](https://arxiv.org/abs/2308.00352)). Structured documents instead of dialogue for inter-agent handoff measurably reduce cascading hallucination. Basis for the dispatch-bundle-as-file rule.
|
|
29
|
+
- **Qian et al., "ChatDev: Communicative Agents for Software Development"** (ACL 2024, [paper](https://aclanthology.org/2024.acl-long.810.pdf)). Phase-chain decomposition with explicit per-phase instruction reduces coding hallucination. Basis for sequential unit execution with green-before-next gates.
|
|
30
|
+
|
|
31
|
+
## Cheap agentic models and heterogeneous assignment
|
|
32
|
+
|
|
33
|
+
- **Belcak et al. (NVIDIA), "Small Language Models are the Future of Agentic AI"** (2025, [arXiv:2506.02153](https://arxiv.org/abs/2506.02153)). Most agentic sub-invocations are repetitive, scoped, format-bound — small models suffice for the majority; frontier models only for open-ended reasoning. Position paper (vendor interest noted), but directionally corroborated by RouteLLM. Basis for heterogeneous model assignment: frontier orchestrator, cheap workers.
|
|
34
|
+
- **Ong et al., "RouteLLM: Learning to Route LLMs with Preference Data"** (ICLR 2025, [arXiv:2406.18665](https://arxiv.org/abs/2406.18665)). Routing between strong/weak models cuts cost up to 85% at ~95% quality — IF calls are classifiable. A sealed unit spec with bounded scope and fixed verify commands is an "easy call" by construction; monolithic dispatches are unclassifiable. Basis for why decomposition ENABLES cheap-worker routing.
|
|
35
|
+
- **MiniMax M3** (released 2026-06-01; [GitHub](https://github.com/MiniMax-AI/MiniMax-M3), [HF](https://huggingface.co/MiniMaxAI/MiniMax-M3)). 428B MoE, ~23B active, 1M context, open-weight; SWE-Bench Pro ~59 (frontier-adjacent) at roughly 8–15x under frontier pricing. Sparse attention ([arXiv:2606.13392](https://arxiv.org/abs/2606.13392)) improves long-context THROUGHPUT, not attention reliability over reasoning content — cheap workers make the sizing gate more mandatory, not less. Treat vendor-adjacent benchmark numbers as provisional.
|
|
36
|
+
|
|
37
|
+
## What the literature does NOT tell us
|
|
38
|
+
|
|
39
|
+
- No published benchmark measures agentic unit-size vs. model class directly — the budgets in `sizing-gate.md` are engineering defaults to calibrate, not literature values.
|
|
40
|
+
- These papers study single-task benchmarks, not multi-day autonomous loops. Effect directions transfer; magnitudes don't.
|
|
41
|
+
|
|
42
|
+
## Context window isolation per unit — clean context beats shared history
|
|
43
|
+
|
|
44
|
+
- **Zhang et al., "SWE-Edit: Rethinking Code Editing for Efficient SWE-Agent"** (2026, [arXiv:2604.26102](https://arxiv.org/abs/2604.26102)). Identifies the "context coupling problem": conflating code inspection, modification planning, and edit execution within a single context window forces agents to interleave exploration with formatted generation — irrelevant context accumulates and edit reliability degrades. SWE-Edit decomposes the interface into Viewer + Editor subagents, each with a clean context window. Result: +2.1 pp resolve rate, -17.9% inference cost on SWE-Bench Verified, consistent across multiple reasoning-model families. Implications for this skill: (1) each decomposed unit must operate in its own clean context — never share accumulated history between units; (2) the Viewer/Editor split is a worked example of capability-aligned decomposition.
|
|
45
|
+
- **Diao et al., "HIPIF: Hierarchical Planning and Information Folding for Long-Horizon LLM Agent Learning"** (2026, [arXiv:2606.10507](https://arxiv.org/abs/2606.10507)). Directly addresses long-context interference in multi-turn agentic tasks: continuously growing histories weaken the agent's ability to track global state. HIPIF trains agents to organise execution around explicit subgoals while **folding** completed subgoal histories — summarising and evicting them to maintain constant per-step context cost. Implications: the unit spec must describe what state is folded on completion; the orchestrator must evict the worker's context after each unit, not accumulate it.
|
|
46
|
+
|
|
47
|
+
## Verifiable gates prevent fabricated success — a structural firewall
|
|
48
|
+
|
|
49
|
+
- **"Goal-Autopilot: A Verifiable Anti-Fabrication Firewall for Unattended Long-Horizon Agents"** (2026, [arXiv:2606.11688](https://arxiv.org/abs/2606.11688)). The critical finding: long-horizon LLM agents cannot be trusted to self-report success. The paper proves a No-False-Success theorem — under gate soundness, floor enforcement, and plan coverage, termination implies the goal holds. The mechanism: a gated finite-state machine where a hard floor forbids any terminal "done" claim whose falsifiable gate did not actually execute and pass. Worst case degrades to an honest stall, never a fabricated success. Empirical results: 0.67% fabrication on SWE-bench Lite vs 33.7% (StateFlow), paired difference -33.07 pp [95% CI -36.53, -29.73]. Implications: (1) every dispatch unit's verify commands must be runnable by the orchestrator, not the worker; (2) a failed verify is an honest stall, never a reason to mark the unit done.
|
|
50
|
+
|
|
51
|
+
## Reasoning-mode decomposition — separate reasoning modes need separate context
|
|
52
|
+
|
|
53
|
+
- **"R-APS: Compositional Reasoning and In-Context Meta-Learning for Constrained Design via Reflective Adversarial Pareto Search"** (2026, [arXiv:2606.04823](https://arxiv.org/abs/2606.04823)). Identifies a root cause of agent failure: abductive, counterfactual, meta-inductive, corrective, and inductive reasoning pull a shared context in incompatible directions. The fix: reasoning-mode decomposition — allocate each reasoning mode its own context, orchestrate across three timescales (staged compositional reasoning, counterfactual stress-testing, meta-inductive rule extraction). Small 4B reasoning-specialised models prove competitive with general-purpose 70B backbones inside the protocol, suggesting structured protocols partially offset model scale. Implications: when a unit requires multiple reasoning modes, decompose further — one mode per unit, clean context per mode.
|
|
54
|
+
|
|
55
|
+
## Capability-aligned decomposition — decompose by capability boundary, not topic
|
|
56
|
+
|
|
57
|
+
- **"Designing Intelligent Enterprise Agents: A Capability-Aligned Multi-Agent Architecture (CEAD)"** (2026, [arXiv:2605.08258](https://arxiv.org/abs/2605.08258)). Revises the enterprise architecture thesis: governance cannot be the primary organising abstraction — agent design must be. Specifically: decompose by capability boundaries, autonomy allocation, interaction protocols, tool and data authority, state and memory design, **verification design**, and human interaction design. Verification is a first-class architectural dimension, not a post-hoc check. Implications: the unit spec's `write_scope` defines a capability boundary; each unit aligns with one capability; verification design is part of the unit spec from the start, not after the fact.
|
|
58
|
+
|
|
59
|
+
## Verifiable task synthesis at scale
|
|
60
|
+
|
|
61
|
+
- **Lv et al., "SCALECUA: Scaling Computer Use Agents with Verifiable Task Synthesis and Efficient Online RL"** (2026, [arXiv:2607.11185](https://arxiv.org/abs/2607.11185)). VeriGen framework: end-to-end generation of verifiable RL tasks through iterative docker interactions and a multi-agent feedback loop, producing 24K+ verifiable tasks at 100+ concurrent workers. Also introduces Visual Context Segmentation — a sliding window over recent context that yields 2.83x training speedup over step-wise decomposition. Implications: (1) verification can and should be automated at scale — a verify command is a falsifiable test; (2) sliding-window context management is a valid alternative to full context isolation for bounded-horizon units.
|
|
62
|
+
|
|
63
|
+
## Coordination complexity — a formal measure of when parallel agents conflict
|
|
64
|
+
|
|
65
|
+
- **"Tensor-Coord: Algebraic Decomposition of Joint Plan Tensors for Conflict-Free Multi-Agent LLM Planning"** (2026, [arXiv:2606.16478](https://arxiv.org/abs/2606.16478)). Represents joint plans as a third-order tensor over agents, timesteps, and actions. Defines a computable coordination complexity measure CC(Pi) = (R* - N) / N where R* is the minimal approximate CP rank. Proves R* = N is necessary and sufficient for plan independence. The residual defines a conflict score over agent pairs, timesteps, and actions — localising coordination failures without domain-specific rules. Implications: parallel dispatch is safe when write scopes are disjoint AND formal plan coordination complexity is minimal. Cross-write-scope comparison is table-stakes; the formal measure catches dynamic (runtime) conflicts that static scope comparison misses — an open problem this skill should flag as active research.
|
|
66
|
+
|
|
67
|
+
## Multi-stage tool-augmented decomposition
|
|
68
|
+
|
|
69
|
+
- **Zhang et al., "ReProAgent: Tool-Augmented Multi-Stage Agentic Generation of Bug Reproduction Tests from Issue Reports"** (2026, [arXiv:2607.09123](https://arxiv.org/abs/2607.09123)). Decomposes a complex SE task into four agent stages: bug localization, root cause analysis, test planning, and test generation. Each stage gets task-specific tools for decomposition and reflection — not a one-size-fits-all toolset. Results: 58.43%/70.30% on SWT-bench, exceeding OpenHands by 20.43/7.90 pp at $0.14/instance. Implications: each decomposed unit should be assigned task-specific tools aligned to its reasoning need — a "code search" unit gets different tools than a "test generation" unit. The dispatcher specifies which tools each unit may use.
|
|
70
|
+
|
|
71
|
+
## What the literature does NOT tell us
|
|
72
|
+
|
|
73
|
+
- No published benchmark measures agentic unit-size vs. model class directly — the budgets in `sizing-gate.md` are engineering defaults to calibrate, not literature values.
|
|
74
|
+
- These papers study single-task benchmarks, not multi-day autonomous loops. Effect directions transfer; magnitudes don't.
|
|
75
|
+
- The formal coordination complexity measure (Tensor-Coord) is promising but unvalidated outside contrived domains.
|
|
76
|
+
- Goal-Autopilot's gated state machine trades coverage for honesty — the correct characterization for unattended work, but the coverage loss must be tracked.
|
|
77
|
+
- All SOTA results are sensitive to backbone model. The decomposition rules in this skill are model-class-relative, a property the literature does not study directly.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# The Sizing Gate — when decomposition is mandatory and how small a unit must be
|
|
2
|
+
|
|
3
|
+
Load this when deciding WHETHER to decompose and HOW SMALL units must be.
|
|
4
|
+
|
|
5
|
+
## Gate criteria — any one fires, decomposition is mandatory
|
|
6
|
+
|
|
7
|
+
1. **Multi-subsystem** — the change touches more than one architectural layer (UI + state + persistence + backend). Each subsystem boundary crossed is coordination surface a single worker must hold in context at once.
|
|
8
|
+
2. **Exceeds one focused session** — the work cannot be completed by one worker in a single focused sitting for its model class. This is the primary "takes too long to run" trigger: a worker that must compact its context mid-task starts making decisions on rotted context.
|
|
9
|
+
3. **Irreversible side effects** — migrations, deletions, external API writes. Smaller units bound the blast radius of each irreversible step and put a verification gate between them.
|
|
10
|
+
4. **Verification longer than the work** — if reviewing the whole result would take longer than producing it, the unit is too big by definition. Verification cost scales with the diff surface; outcome-only verification is the weakest signal available.
|
|
11
|
+
|
|
12
|
+
If NONE fire, decomposing is usually wrong: more units = more coordination, more handoffs, more chances for inter-agent misalignment. One maker by default; decompose on evidence, not on vibes.
|
|
13
|
+
|
|
14
|
+
## Model-relative budgets
|
|
15
|
+
|
|
16
|
+
The same task is a different-sized unit for different workers. Attention reliability over long contexts degrades more sharply in smaller models, so a cheap-agentic worker's unit must be smaller than a frontier worker's:
|
|
17
|
+
|
|
18
|
+
| Worker class | Examples | max files | max verify minutes | Notes |
|
|
19
|
+
| ------------- | ----------------------------------------------- | --------- | ------------------ | ----------------------------------------------- |
|
|
20
|
+
| frontier | top-tier proprietary models | ~12 | ~15 | still bounded — frontier models rot too |
|
|
21
|
+
| cheap_agentic | M3-class MoE (~23B active), strong open-weights | ~5 | ~6 | economics only pay off inside the reliable zone |
|
|
22
|
+
| small_local | 7–13B local models | ~2 | ~3 | narrow specialists only; keep scopes tiny |
|
|
23
|
+
|
|
24
|
+
These are STARTING DEFAULTS, not measured truths — no published benchmark measures agentic unit-size vs. model class directly. Calibrate per host (below) and record the calibrated values where the orchestrator reads them (loop kit delegation block, project config).
|
|
25
|
+
|
|
26
|
+
## Calibration procedure
|
|
27
|
+
|
|
28
|
+
1. Pick 5–10 real past tasks and their actual diffs (files touched, verify runtime).
|
|
29
|
+
2. Run them as single units with the target worker class; record where failures correlate with size (typically: instruction drift, scope creep, verify commands skipped).
|
|
30
|
+
3. Set max_files at the point below which failures were NOT size-correlated; set max_verify_minutes so the per-unit check finishes in a fraction of the unit's work time (target ≤ 25%).
|
|
31
|
+
4. Revisit when the worker model changes — class assignment is per-model, not per-run.
|
|
32
|
+
|
|
33
|
+
## Edge cases
|
|
34
|
+
|
|
35
|
+
- **The unit that can't shrink**: some changes are atomic (a schema migration touching 40 call sites). Decompose by PHASE instead: one unit writes the migration + adapter, follow-up units migrate call-site clusters. The write scope is still bounded per unit even though the change is logically one.
|
|
36
|
+
- **Unknown size upfront**: when the scope fence can't be drawn until exploration happens, dispatch a read-only scout unit first (tiny scope, report-only), then size the write units from its map. Never convert a scout into a writer mid-task — its context is optimized for breadth, not depth.
|
|
37
|
+
- **Sequential dependency chains**: units with blocking dependencies serialize by definition. State the dependency in the unit spec so the scheduler doesn't fan them out.
|
|
38
|
+
- **Re-dispatch after failure**: a failed unit re-dispatched with a corrected spec is a NEW unit — its spec must name the prior failure and what changed. A re-dispatch with the identical spec is a no-progress signal, not work.
|
package/dist/dist-h-6akqyn.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{$c as e,$o as t,$s as n,Ao as r,As as i,Bc as a,Bs as o,Cc as s,Cr as c,Dc as l,Dn as u,Do as d,Ds as f,Ec as p,Es as m,Fc as h,Fi as g,Fo as ee,Fs as _,Gs as te,Hi as ne,Hs as re,Ic as ie,Io as ae,Is as v,Jc as oe,Ji as se,Jr as ce,Js as le,Ko as ue,Ks as y,Lc as de,Lr as fe,Ls as pe,Mi as me,Nc as he,Ni as ge,Nr as _e,Ns as ve,Oo as ye,Os as be,Pi as xe,Pr as Se,Ps as Ce,Qi as we,Qo as Te,Qs as b,Rc as Ee,Sc as De,So as Oe,Ss as ke,Tc as Ae,To as je,Tr as Me,Ts as Ne,Ui as Pe,Uo as Fe,Us as Ie,Vi as Le,Vo as Re,Vs as ze,Wi as Be,Wo as Ve,Ws as He,Xc as Ue,Xn as We,Xs as Ge,Yc as Ke,Yi as qe,Ys as Je,Zi as Ye,Zo as Xe,_l as x,aa as Ze,al as Qe,as as $e,b as et,bo as tt,bs as nt,ci as rt,cl as it,cr as at,ct as ot,dl as st,dt as ct,ea as lt,el as ut,fl as dt,fs as ft,ft as pt,gl as mt,go as ht,il as gt,in as _t,jc as vt,ji as yt,js as bt,k as xt,ko as St,kr as Ct,ks as wt,li as Tt,ll as Et,nl as Dt,no as Ot,oc as kt,ol as At,pl as jt,pt as Mt,qc as Nt,qi as Pt,qo as Ft,qs as It,ra as Lt,rl as Rt,rt as zt,ta as Bt,tl as Vt,ul as Ht,us as Ut,ut as Wt,vl as S,vn as Gt,vo as Kt,w as qt,wr as Jt,ws as Yt,xo as Xt,xs as Zt,yl as C,yo as Qt,ys as $t,zc as en,zo as tn,zs as w}from"./core-CwsVf2Ey.js";import{$ as nn,$t as rn,A as an,At as on,C as sn,Cn as cn,Ct as ln,D as un,Dn as dn,Dt as fn,E as pn,En as mn,Et as hn,F as gn,Ft as _n,G as vn,Gt as yn,I as bn,It as xn,J as Sn,K as Cn,L as wn,M as Tn,Mt as En,N as Dn,Nt as On,O as kn,Ot as T,P as E,Pt as An,Qt as jn,R as Mn,S as Nn,St as Pn,T as Fn,Tn as In,Tt as Ln,U as Rn,V as zn,W as Bn,X as Vn,Y as Hn,Z as Un,Zt as Wn,_ as Gn,_n as Kn,_t as qn,a as Jn,an as Yn,at as Xn,b as D,bn as Zn,bt as Qn,cn as $n,ct as er,d as tr,dn as nr,en as rr,f as ir,fn as ar,ft as or,g as O,gn as sr,gt as k,h as cr,hn as lr,ht as ur,i as dr,in as fr,it as pr,j as mr,jt as hr,k as gr,kt as _r,l as vr,ln as yr,lt as br,m as xr,mn as Sr,mt as Cr,n as A,nt as j,o as wr,on as Tr,ot as Er,p as Dr,pn as Or,pt as kr,q as Ar,r as jr,rn as Mr,rt as Nr,s as Pr,sn as Fr,tn as Ir,tt as M,u as Lr,ut as Rr,v as zr,vn as Br,vt as Vr,w as Hr,wn as Ur,wt as Wr,x as Gr,xn as Kr,xt as qr,y as Jr,yn as Yr,yt as Xr,z as Zr}from"./Effect-BcYkmFCx.js";import{a as Qr,c as $r,d as ei,f as ti,i as ni,l as ri,n as ii,o as ai,p as oi,r as si,s as ci,u as li}from"./Cause-CTmrUQgG.js";import{a as ui,c as di,d as fi,f as pi,h as mi,i as hi,l as gi,m as _i,n as vi,p as yi,r as bi,s as xi,u as Si}from"./Exit-Dq5mS6lc.js";const Ci=Tt,wi=e=>t=>{let n=t===void 0?Object.create(kt):Ci(t);return n._tag=e,n},Ti=rt,Ei=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return{BaseEffectError:class extends et{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(Object.assign(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}.BaseEffectError}(),Di=e=>{let t={BaseEffectError:class extends Ei{_tag=e}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError},Oi=Symbol.for(`effect/DateTime`),ki=Symbol.for(`effect/DateTime/TimeZone`),Ai={[Oi]:Oi,pipe(){return De(this,arguments)},[s](){return this.toString()},toJSON(){return sa(this).toJSON()}},ji={...Ai,_tag:`Utc`,[a](){return h(this,Ee(this.epochMillis))},[he](e){return Li(e)&&e._tag===`Utc`&&this.epochMillis===e.epochMillis},toString(){return`DateTime.Utc(${sa(this).toJSON()})`}},Mi={...Ai,_tag:`Zoned`,[a](){return C(Ee(this.epochMillis),ie(de(this.zone)),h(this))},[he](e){return Li(e)&&e._tag===`Zoned`&&this.epochMillis===e.epochMillis&&vt(this.zone,e.zone)},toString(){return`DateTime.Zoned(${xa(this)})`}},Ni={[ki]:ki,[s](){return this.toString()}},Pi={...Ni,_tag:`Named`,[a](){return h(this,en(`Named:${this.id}`))},[he](e){return Ri(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},Fi={...Ni,_tag:`Offset`,[a](){return h(this,en(`Offset:${this.offset}`))},[he](e){return Ri(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${ua(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},Ii=(e,t,n)=>{let r=Object.create(Mi);return r.epochMillis=e,r.zone=t,Object.defineProperty(r,"partsUtc",{value:n,enumerable:!1,writable:!0}),Object.defineProperty(r,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(r,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),r},Li=e=>Nt(e,Oi),Ri=e=>Nt(e,ki),zi=e=>Ri(e)&&e._tag===`Offset`,Bi=e=>Ri(e)&&e._tag===`Named`,Vi=e=>e._tag===`Utc`,Hi=e=>e._tag===`Zoned`,Ui=jt((e,t)=>e.epochMillis===t.epochMillis),Wi=e=>{let t=Object.create(ji);return t.epochMillis=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},Gi=e=>{let t=e.getTime();if(Number.isNaN(t))throw new ii(`Invalid date`);return Wi(t)},Ki=e=>{if(Li(e))return e;if(e instanceof Date)return Gi(e);if(typeof e==`object`){let t=new Date(0);return pa(t,e),Gi(t)}else if(typeof e==`string`&&!qi(e))return Gi(new Date(e+`Z`));return Gi(new Date(e))},qi=e=>/Z|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),Ji=(e,t)=>{if(t?.timeZone===void 0&&Li(e)&&Hi(e))return e;let n=Ki(e);if(n.epochMillis<-86399999568e5||n.epochMillis>86399999496e5)throw RangeError(`Epoch millis out of range: ${n.epochMillis}`);let r;if(t?.timeZone===void 0){let e=new Date(n.epochMillis).getTimezoneOffset()*-60*1e3;r=na(e)}else if(Ri(t?.timeZone))r=t.timeZone;else if(typeof t?.timeZone==`number`)r=na(t.timeZone);else{let e=aa(t.timeZone);if(wt(e))throw new ii(`Invalid time zone: ${t.timeZone}`);r=e.value}return t?.adjustForTimeZone===!0?ha(n.epochMillis,r,t?.disambiguation??`compatible`):Ii(n.epochMillis,r,n.partsUtc)},Yi=ve(Ji),Xi=/^(.{17,35})\[(.+)\]$/,Zi=e=>{let t=Xi.exec(e);if(t===null){let t=_a(e);return t===null?v():Yi(e,{timeZone:t})}let[,n,r]=t;return Yi(n,{timeZone:r})},Qi=st(`effect/DateTime/validZoneCache`,()=>new Map),$i={day:`numeric`,month:`numeric`,year:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},ea=e=>{let t=e.resolvedOptions().timeZone;if(Qi.has(t))return Qi.get(t);let n=Object.create(Pi);return n.id=t,n.format=e,Qi.set(t,n),n},ta=e=>{if(Qi.has(e))return Qi.get(e);try{return ea(new Intl.DateTimeFormat(`en-US`,{...$i,timeZone:e}))}catch{throw new ii(`Invalid time zone: ${e}`)}},na=e=>{let t=Object.create(Fi);return t.offset=e,t},ra=ve(ta),ia=/^(?:GMT|[+-])/,aa=e=>{if(ia.test(e)){let t=_a(e);return t===null?v():w(na(t))}return ra(e)},oa=e=>e._tag===`Offset`?ua(e.offset):e.id,sa=e=>new Date(e.epochMillis),ca=e=>{if(e._tag===`Utc`)return new Date(e.epochMillis);if(e.zone._tag===`Offset`)return new Date(e.epochMillis+e.zone.offset);if(e.adjustedEpochMillis!==void 0)return new Date(e.adjustedEpochMillis);let t=e.zone.format.formatToParts(e.epochMillis).filter(e=>e.type!==`literal`),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMillis=n.getTime(),n},la=e=>ca(e).getTime()-fa(e),ua=e=>{let t=Math.abs(e),n=Math.floor(t/(3600*1e3)),r=Math.round(t%(3600*1e3)/(60*1e3));return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},da=e=>ua(la(e)),fa=e=>e.epochMillis,pa=(e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hours!==void 0&&e.setUTCHours(t.hours),t.minutes!==void 0&&e.setUTCMinutes(t.minutes),t.seconds!==void 0&&e.setUTCSeconds(t.seconds),t.millis!==void 0&&e.setUTCMilliseconds(t.millis)},ma=1440*60*1e3,ha=(e,t,n)=>{if(t._tag===`Offset`)return Ii(e-t.offset,t);let r=va(e-ma,e,t),i=va(e+ma,e,t);if(r===i)return Ii(e-r,t);let a=r<i,o=r-i;if(a){if(va(e-i,e,t)===i)return Ii(e-i,t);let a=Ii(e-r,t);if(e!==ca(a).getTime())switch(n){case`reject`:{let n=new Date(e).toISOString();throw RangeError(`Gap time: ${n} does not exist in time zone ${t.id}`)}case`earlier`:return Ii(e-i,t);case`compatible`:case`later`:return a}return a}if(va(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||va(e-r+o,e+o,t)===r)return Ii(e-r,t);if(n===`reject`){let n=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${n} occurs twice in time zone ${t.id}`)}}return Ii(e-i,t)},ga=/([+-])(\d{2}):(\d{2})$/,_a=e=>{let t=ga.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},va=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=_a(r);return i===null?la(Ii(t,n)):i},ya=e=>sa(e).toISOString(),ba=e=>{let t=ca(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${da(e)}`},xa=e=>e.zone._tag===`Offset`?ba(e):`${ba(e)}[${e.zone.id}]`,Sa=e=>e.toUpperCase(),Ca=e=>e.toLowerCase(),wa=e=>e.length===0?e:Sa(e[0])+e.slice(1),Ta=e=>e.length===0?e:Ca(e[0])+e.slice(1),Ea=e=>e.length>0,Da=(e,t)=>{switch(t._tag){case`StringKeyword`:case`TemplateLiteral`:return Object.keys(e);case`SymbolKeyword`:return Object.getOwnPropertySymbols(e);case`Refinement`:return Da(e,t.from)}},Oa=e=>{let t=!1,n;return()=>t?n:(n=e(),t=!0,n)},ka=e=>Array.isArray(e),Aa=e=>!Array.isArray(e),ja=e=>`[${p(e)}]`,Ma=e=>ka(e)?e.map(ja).join(``):ja(e),Na=(e,n,r,i)=>{let a=e;return r&&t(r)&&(a+=`\nat path: ${Ma(r)}`),n!==void 0&&(a+=`\ndetails: ${n}`),i&&(a+=`\nschema (${i._tag}): ${i}`),a},Pa=e=>Na(`Invalid Argument`,e),Fa=(e,t,n)=>Na(`Unsupported schema or overlapping types`,`cannot extend ${e} with ${t}`,n),Ia=e=>Na(`Unsupported key schema`,void 0,void 0,e),La=e=>Na(`Unsupported literal`,`literal value: ${l(e)}`),Ra=e=>Na(`Duplicate index signature`,`${e} index signature`),za=Na(`Unsupported index signature parameter`,"An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),Ba=Na(`Invalid element`,`A required element cannot follow an optional element. ts(1257)`),Va=e=>Na(`Duplicate property signature transformation`,`Duplicate key ${l(e)}`),Ha=e=>Na(`Duplicate property signature`,`Duplicate key ${l(e)}`),Ua=Symbol.for(`effect/SchemaId/DateFromSelf`),Wa=Symbol.for(`effect/SchemaId/GreaterThan`),Ga=Symbol.for(`effect/SchemaId/GreaterThanOrEqualTo`),Ka=Symbol.for(`effect/SchemaId/LessThan`),qa=Symbol.for(`effect/SchemaId/LessThanOrEqualTo`),Ja=Symbol.for(`effect/SchemaId/Int`),Ya=Symbol.for(`effect/SchemaId/NonNaN`),Xa=Symbol.for(`effect/SchemaId/Finite`),Za=Symbol.for(`effect/SchemaId/JsonNumber`),Qa=Symbol.for(`effect/SchemaId/Between`),$a=Symbol.for(`effect/SchemaId/GreaterThanOrEqualToBigint`),eo=Symbol.for(`effect/SchemaId/BetweenBigint`),to=Symbol.for(`effect/SchemaId/MinLength`),no=Symbol.for(`effect/SchemaId/Length`),ro=Symbol.for(`effect/SchemaId/MinItems`),io=Symbol.for(`effect/annotation/TypeConstructor`),ao=Symbol.for(`effect/annotation/Brand`),oo=Symbol.for(`effect/annotation/SchemaId`),so=Symbol.for(`effect/annotation/Message`),co=Symbol.for(`effect/annotation/MissingMessage`),lo=Symbol.for(`effect/annotation/Identifier`),uo=Symbol.for(`effect/annotation/Title`),fo=Symbol.for(`effect/annotation/AutoTitle`),po=Symbol.for(`effect/annotation/Description`),mo=Symbol.for(`effect/annotation/Examples`),ho=Symbol.for(`effect/annotation/Default`),go=Symbol.for(`effect/annotation/JSONSchema`),_o=Symbol.for(`effect/annotation/Arbitrary`),vo=Symbol.for(`effect/annotation/Pretty`),yo=Symbol.for(`effect/annotation/Equivalence`),bo=Symbol.for(`effect/annotation/Documentation`),xo=Symbol.for(`effect/annotation/Concurrency`),So=Symbol.for(`effect/annotation/Batching`),Co=Symbol.for(`effect/annotation/ParseIssueTitle`),wo=Symbol.for(`effect/annotation/ParseOptions`),To=Symbol.for(`effect/annotation/DecodingFallback`),Eo=Symbol.for(`effect/annotation/Surrogate`),Do=Symbol.for(`effect/annotation/StableFilter`),N=x(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?w(e.annotations[t]):v()),Oo=N(ao),ko=N(so),Ao=N(co),jo=N(uo),Mo=N(fo),No=N(lo),Po=N(po),Fo=N(xo),Io=N(So),Lo=N(Co),Ro=N(wo),zo=N(To),Bo=N(Eo),Vo=N(Do),Ho=e=>$t(Vo(e),e=>e===!0),Uo=Symbol.for(`effect/annotation/JSONIdentifier`),Wo=N(Uo),Go=e=>pe(Wo(e),()=>No(e));var Ko=class{typeParameters;decodeUnknown;encodeUnknown;annotations;_tag=`Declaration`;constructor(e,t,n,r={}){this.typeParameters=e,this.decodeUnknown=t,this.encodeUnknown=n,this.annotations=r}toString(){return Ne(ac(this),()=>`<declaration schema>`)}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map(e=>e.toJSON()),annotations:I(this.annotations)}}};const qo=e=>t=>t._tag===e;var Jo=class{literal;annotations;_tag=`Literal`;constructor(e,t={}){this.literal=e,this.annotations=t}toString(){return Ne(ac(this),()=>l(this.literal))}toJSON(){return{_tag:this._tag,literal:oe(this.literal)?String(this.literal):this.literal,annotations:I(this.annotations)}}};const Yo=qo(`Literal`);var Xo=class{symbol;annotations;_tag=`UniqueSymbol`;constructor(e,t={}){this.symbol=e,this.annotations=t}toString(){return Ne(ac(this),()=>l(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:I(this.annotations)}}};const Zo=new class{annotations;_tag=`UndefinedKeyword`;constructor(e={}){this.annotations=e}toString(){return nc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[uo]:`undefined`}),Qo=new class{annotations;_tag=`NeverKeyword`;constructor(e={}){this.annotations=e}toString(){return nc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[uo]:`never`}),$o=new class{annotations;_tag=`UnknownKeyword`;constructor(e={}){this.annotations=e}toString(){return nc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[uo]:`unknown`}),es=new class{annotations;_tag=`AnyKeyword`;constructor(e={}){this.annotations=e}toString(){return nc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[uo]:`any`}),ts=new class{annotations;_tag=`StringKeyword`;constructor(e={}){this.annotations=e}toString(){return nc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[uo]:`string`,[po]:`a string`}),ns=qo(`StringKeyword`),rs=new class{annotations;_tag=`NumberKeyword`;constructor(e={}){this.annotations=e}toString(){return nc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[uo]:`number`,[po]:`a number`}),is=qo(`NumberKeyword`),as=new class{annotations;_tag=`BooleanKeyword`;constructor(e={}){this.annotations=e}toString(){return nc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[uo]:`boolean`,[po]:`a boolean`}),os=qo(`BooleanKeyword`),ss=new class{annotations;_tag=`BigIntKeyword`;constructor(e={}){this.annotations=e}toString(){return nc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[uo]:`bigint`,[po]:`a bigint`}),cs=new class{annotations;_tag=`SymbolKeyword`;constructor(e={}){this.annotations=e}toString(){return nc(this)}toJSON(){return{_tag:this._tag,annotations:I(this.annotations)}}}({[uo]:`symbol`,[po]:`a symbol`}),ls=qo(`SymbolKeyword`);var us=class{type;annotations;constructor(e,t={}){this.type=e,this.annotations=t}toJSON(){return{type:this.type.toJSON(),annotations:I(this.annotations)}}toString(){return String(this.type)}},ds=class extends us{isOptional;constructor(e,t,n={}){super(e,n),this.isOptional=t}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:I(this.annotations)}}toString(){return String(this.type)+(this.isOptional?`?`:``)}};const fs=e=>e.map(e=>e.type);var ps=class{elements;rest;isReadonly;annotations;_tag=`TupleType`;constructor(e,t,n,r={}){this.elements=e,this.rest=t,this.isReadonly=n,this.annotations=r;let i=!1,a=!1;for(let t of e)if(t.isOptional)i=!0;else if(i){a=!0;break}if(a||i&&t.length>1)throw Error(Ba)}toString(){return Ne(ac(this),()=>ms(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map(e=>e.toJSON()),rest:this.rest.map(e=>e.toJSON()),isReadonly:this.isReadonly,annotations:I(this.annotations)}}};const ms=e=>{let t=e.elements.map(String).join(`, `);return $e(e.rest,{onEmpty:()=>`readonly [${t}]`,onNonEmpty:(n,r)=>{let i=String(n),a=i.includes(` | `)?`(${i})`:i;if(r.length>0){let n=r.map(String).join(`, `);return e.elements.length>0?`readonly [${t}, ...${a}[], ${n}]`:`readonly [...${a}[], ${n}]`}else if(e.elements.length>0)return`readonly [${t}, ...${a}[]]`;else return`ReadonlyArray<${i}>`}})};var P=class extends ds{name;isReadonly;constructor(e,t,n,r,i){super(t,n,i),this.name=e,this.isReadonly=r}toString(){return(this.isReadonly?`readonly `:``)+String(this.name)+(this.isOptional?`?`:``)+`: `+this.type}toJSON(){return{name:String(this.name),type:this.type.toJSON(),isOptional:this.isOptional,isReadonly:this.isReadonly,annotations:I(this.annotations)}}};const hs=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return!0;case`Refinement`:return hs(e.from)}return!1};var gs=class{type;isReadonly;parameter;constructor(e,t,n){if(this.type=t,this.isReadonly=n,hs(e))this.parameter=e;else throw Error(za)}toString(){return(this.isReadonly?`readonly `:``)+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}},_s=class{annotations;_tag=`TypeLiteral`;propertySignatures;indexSignatures;constructor(e,t,n={}){this.annotations=n;let r={};for(let t=0;t<e.length;t++){let n=e[t].name;if(Object.prototype.hasOwnProperty.call(r,n))throw Error(Ha(n));r[n]=null}let i={string:!1,symbol:!1};for(let e=0;e<t.length;e++){let n=tc(t[e].parameter);if(ns(n)){if(i.string)throw Error(Ra(`string`));i.string=!0}else if(ls(n)){if(i.symbol)throw Error(Ra(`symbol`));i.symbol=!0}}this.propertySignatures=e,this.indexSignatures=t}toString(){return Ne(ac(this),()=>ys(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map(e=>e.toJSON()),indexSignatures:this.indexSignatures.map(e=>e.toJSON()),annotations:I(this.annotations)}}};const vs=e=>e.map(String).join(`; `),ys=e=>{if(e.propertySignatures.length>0){let t=e.propertySignatures.map(String).join(`; `);return e.indexSignatures.length>0?`{ ${t}; ${vs(e.indexSignatures)} }`:`{ ${t} }`}else if(e.indexSignatures.length>0)return`{ ${vs(e.indexSignatures)} }`;else return`{}`},bs=qo(`TypeLiteral`),xs=Ut(dn(In,e=>{switch(e._tag){case`AnyKeyword`:return 0;case`UnknownKeyword`:return 1;case`ObjectKeyword`:return 2;case`StringKeyword`:case`NumberKeyword`:case`BooleanKeyword`:case`BigIntKeyword`:case`SymbolKeyword`:return 3}return 4})),Ss={string:`StringKeyword`,number:`NumberKeyword`,boolean:`BooleanKeyword`,bigint:`BigIntKeyword`},Cs=e=>Ve(e,e=>Os(e)?Cs(e.types):[e]),ws=e=>{let t=xs(e),n=[],r={},i=[];for(let e of t)switch(e._tag){case`NeverKeyword`:break;case`AnyKeyword`:return[es];case`UnknownKeyword`:return[$o];case`ObjectKeyword`:case`UndefinedKeyword`:case`VoidKeyword`:case`StringKeyword`:case`NumberKeyword`:case`BooleanKeyword`:case`BigIntKeyword`:case`SymbolKeyword`:r[e._tag]||(r[e._tag]=e,n.push(e));break;case`Literal`:{let t=typeof e.literal;switch(t){case`string`:case`number`:case`bigint`:case`boolean`:!r[Ss[t]]&&!i.includes(e.literal)&&(i.push(e.literal),n.push(e));break;case`object`:i.includes(e.literal)||(i.push(e.literal),n.push(e));break}break}case`UniqueSymbol`:!r.SymbolKeyword&&!i.includes(e.symbol)&&(i.push(e.symbol),n.push(e));break;case`TupleType`:r.ObjectKeyword||n.push(e);break;case`TypeLiteral`:e.propertySignatures.length===0&&e.indexSignatures.length===0?r[`{}`]||(r[`{}`]=e,n.push(e)):r.ObjectKeyword||n.push(e);break;default:n.push(e)}return n};var Ts=class e{types;annotations;static make=(t,n)=>Ds(t)?new e(t,n):t.length===1?t[0]:Qo;static unify=(t,n)=>e.make(ws(Cs(t)),n);_tag=`Union`;constructor(e,t={}){this.types=e,this.annotations=t}toString(){return Ne(ac(this),()=>this.types.map(String).join(` | `))}toJSON(){return{_tag:this._tag,types:this.types.map(e=>e.toJSON()),annotations:I(this.annotations)}}};const Es=(e,t)=>e.map(t),Ds=e=>e.length>1,Os=qo(`Union`),ks=st(Symbol.for(`effect/Schema/AST/toJSONMemoMap`),()=>new WeakMap);var As=class{f;annotations;_tag=`Suspend`;constructor(e,t={}){this.f=e,this.annotations=t,this.f=Oa(e)}toString(){return ac(this).pipe(pe(()=>Zt(ve(this.f)(),e=>ac(e))),Ne(()=>`<suspended schema>`))}toJSON(){let e=this.f(),t=ks.get(e);return t||(ks.set(e,{_tag:this._tag}),t={_tag:this._tag,ast:e.toJSON(),annotations:I(this.annotations)},ks.set(e,t),t)}},js=class{from;filter;annotations;_tag=`Refinement`;constructor(e,t,n={}){this.from=e,this.filter=t,this.annotations=n}toString(){return No(this).pipe(Ne(()=>_(ic(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:e=>Ms(this.from)?String(this.from)+` & `+e:e})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:I(this.annotations)}}};const Ms=qo(`Refinement`),Ns={};var Ps=class{from;to;transformation;annotations;_tag=`Transformation`;constructor(e,t,n,r={}){this.from=e,this.to=t,this.transformation=n,this.annotations=r}toString(){return Ne(ac(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:I(this.annotations)}}};const Fs=qo(`Transformation`);var Is=class{decode;encode;_tag=`FinalTransformation`;constructor(e,t){this.decode=e,this.encode=t}};const Ls=e=>t=>t._tag===e,Rs=new class{_tag=`ComposeTransformation`};var zs=class{from;to;decode;encode;constructor(e,t,n,r){this.from=e,this.to=t,this.decode=n,this.encode=r}},Bs=class{propertySignatureTransformations;_tag=`TypeLiteralTransformation`;constructor(e){this.propertySignatureTransformations=e;let t={},n={};for(let r of e){let e=r.from;if(t[e])throw Error(Va(e));t[e]=!0;let i=r.to;if(n[i])throw Error(Va(i));n[i]=!0}}};const Vs=Ls(`TypeLiteralTransformation`),Hs=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={...e.annotations};delete r[lo];let i={...r,...t},a=Bo(e);return bt(a)&&(i[Eo]=Hs(a.value,t)),n.annotations.value=i,Object.create(Object.getPrototypeOf(e),n)},Us=(e,t)=>{switch(e._tag){case`Literal`:return Ur(String(e.literal));case`StringKeyword`:return`[\\s\\S]*?`;case`NumberKeyword`:return`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;case`TemplateLiteral`:return Gs(e,t,!1);case`Union`:return e.types.map(e=>Us(e,t)).join(`|`)}},Ws=(e,t,n,r)=>{if(Os(e)){if(n&&!r)return`(?:${t})`}else if(!n||!r)return t;return`(${t})`},Gs=(e,t,n)=>{let r=``;if(e.head!==``){let i=Ur(e.head);r+=t&&n?`(${i})`:i}for(let i of e.spans){let e=Us(i.type,t);if(r+=Ws(i.type,e,t,n),i.literal!==``){let e=Ur(i.literal);r+=t&&n?`(${e})`:e}}return r},Ks=e=>RegExp(`^${Gs(e,!1,!0)}$`),qs=(e,t)=>{let n=[],r=[],i=e=>{switch(e._tag){case`NeverKeyword`:break;case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:case`Refinement`:r.push(new gs(e,t,!0));break;case`Literal`:if(Qe(e.literal)||Vt(e.literal))n.push(new P(e.literal,t,!1,!0));else throw Error(La(e.literal));break;case`Enums`:for(let[r,i]of e.enums)n.push(new P(i,t,!1,!0));break;case`UniqueSymbol`:n.push(new P(e.symbol,t,!1,!0));break;case`Union`:e.types.forEach(i);break;default:throw Error(Ia(e))}};return i(e),{propertySignatures:n,indexSignatures:r}},Js=e=>t=>{let n;for(let r of e)Object.prototype.hasOwnProperty.call(t.annotations,r)&&(n===void 0&&(n={}),n[r]=t.annotations[r]);return n},Ys=e=>t=>{let n={...t.annotations};for(let t of e)delete n[t];return n},Xs=Js([mo,ho,go,_o,vo,yo]),F=e=>{switch(e._tag){case`Declaration`:{let t=Zs(e.typeParameters,F);return t===e.typeParameters?e:new Ko(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case`TupleType`:{let t=Zs(e.elements,e=>{let t=F(e.type);return t===e.type?e:new ds(t,e.isOptional)}),n=fs(e.rest),r=Zs(n,F);return t===e.elements&&r===n?e:new ps(t,r.map(e=>new us(e)),e.isReadonly,e.annotations)}case`TypeLiteral`:{let t=Zs(e.propertySignatures,e=>{let t=F(e.type);return t===e.type?e:new P(e.name,t,e.isOptional,e.isReadonly)}),n=Zs(e.indexSignatures,e=>{let t=F(e.type);return t===e.type?e:new gs(e.parameter,t,e.isReadonly)});return t===e.propertySignatures&&n===e.indexSignatures?e:new _s(t,n,e.annotations)}case`Union`:{let t=Zs(e.types,F);return t===e.types?e:Ts.make(t,e.annotations)}case`Suspend`:return new As(()=>F(e.f()),e.annotations);case`Refinement`:{let t=F(e.from);return t===e.from?e:new js(t,e.filter,e.annotations)}case`Transformation`:{let t=Xs(e);return F(t===void 0?e.to:Hs(e.to,t))}}return e};function Zs(e,t){let n=!1,r=ae(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}const Qs=e=>{switch(e._tag){case`Transformation`:return e.from;case`Refinement`:return Qs(e.from);case`Suspend`:return Qs(e.f())}},$s=(e,t)=>{switch(e._tag){case`Declaration`:{let n=Zs(e.typeParameters,e=>$s(e,t));return n===e.typeParameters?e:new Ko(n,e.decodeUnknown,e.encodeUnknown)}case`TupleType`:{let n=Zs(e.elements,e=>{let n=$s(e.type,t);return n===e.type?e:new ds(n,e.isOptional)}),r=fs(e.rest),i=Zs(r,e=>$s(e,t));return n===e.elements&&i===r?e:new ps(n,i.map(e=>new us(e)),e.isReadonly)}case`TypeLiteral`:{let n=Zs(e.propertySignatures,e=>{let n=$s(e.type,t);return n===e.type?e:new P(e.name,n,e.isOptional,e.isReadonly)}),r=Zs(e.indexSignatures,e=>{let n=$s(e.type,t);return n===e.type?e:new gs(e.parameter,n,e.isReadonly)});return n===e.propertySignatures&&r===e.indexSignatures?e:new _s(n,r)}case`Union`:{let n=Zs(e.types,e=>$s(e,t));return n===e.types?e:Ts.make(n)}case`Suspend`:{let n,r=Go(e);if(bt(r)){let e=t?`Bound`:``;n={[Uo]:`${r.value}Encoded${e}`}}return new As(()=>$s(e.f(),t),n)}case`Refinement`:{let n=$s(e.from,t);return t?n===e.from?e:Qs(e.from)===void 0&&Ho(e)?new js(n,e.filter,e.annotations):n:n}case`Transformation`:return $s(e.from,t)}return e},ec=e=>$s(e,!1),I=e=>{let t={};for(let n of Object.getOwnPropertySymbols(e))t[String(n)]=e[n];return t},tc=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return e;case`Refinement`:return tc(e.from)}},nc=e=>Ne(ac(e),()=>e._tag);function rc(e){return _(Oo(e),{onNone:()=>``,onSome:e=>e.map(e=>` & Brand<${l(e)}>`).join(``)})}const ic=e=>jo(e).pipe(pe(()=>Po(e)),pe(()=>Mo(e)),Ce(t=>t+rc(e))),ac=e=>pe(No(e),()=>ic(e)),oc=/^[+-]?\d+$/,sc=Symbol.for(`effect/BigDecimal`),cc={[sc]:sc,[a](){let e=hc(this);return C(de(e.value),ie(Ee(e.scale)),h(this))},[he](e){return lc(e)&&yc(this,e)},toString(){return`BigDecimal(${Cc(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[s](){return this.toJSON()},pipe(){return De(this,arguments)}},lc=e=>Nt(e,sc),uc=(e,t)=>{let n=Object.create(cc);return n.value=e,n.scale=t,n},dc=(e,t)=>{if(e!==fc&&e%pc===fc)throw RangeError(`Value must be normalized`);let n=uc(e,t);return n.normalized=n,n},fc=BigInt(0),pc=BigInt(10),mc=dc(fc,0),hc=e=>{if(e.normalized===void 0)if(e.value===fc)e.normalized=mc;else{let t=`${e.value}`,n=0;for(let e=t.length-1;e>=0&&t[e]===`0`;e--)n++;n===0&&(e.normalized=e);let r=BigInt(t.substring(0,t.length-n)),i=e.scale-n;e.normalized=dc(r,i)}return e.normalized},gc=x(2,(e,t)=>t>e.scale?uc(e.value*pc**BigInt(t-e.scale),t):t<e.scale?uc(e.value/pc**BigInt(e.scale-t),t):e),_c=e=>e.value<fc?uc(-e.value,e.scale):e,vc=jt((e,t)=>e.scale>t.scale?gc(t,e.scale).value===e.value:e.scale<t.scale?gc(e,t.scale).value===t.value:e.value===t.value),yc=x(2,(e,t)=>vc(e,t)),bc=e=>m(xc(e),()=>RangeError(`Number must be finite, got ${e}`)),xc=e=>{if(!Number.isFinite(e))return v();let t=`${e}`;if(t.includes(`e`))return Sc(t);let[n,r=``]=t.split(`.`);return w(uc(BigInt(`${n}${r}`),r.length))},Sc=e=>{if(e===``)return w(mc);let t,n,r=e.search(/[eE]/);if(r!==-1){let i=e.slice(r+1);if(t=e.slice(0,r),n=Number(i),t===``||!Number.isSafeInteger(n)||!oc.test(i))return v()}else t=e,n=0;let i,a,o=t.search(/\./);if(o!==-1){let e=t.slice(0,o),n=t.slice(o+1);i=`${e}${n}`,a=n.length}else i=t,a=0;if(!oc.test(i))return v();let s=a-n;return Number.isSafeInteger(s)?w(uc(BigInt(i),s)):v()},Cc=e=>{let t=hc(e);if(Math.abs(t.scale)>=16)return wc(t);let n=t.value<fc,r=n?`${t.value}`.substring(1):`${t.value}`,i,a;if(t.scale>=r.length)i=`0`,a=`0`.repeat(t.scale-r.length)+r;else{let e=r.length-t.scale;if(e>r.length){let t=e-r.length;i=`${r}${`0`.repeat(t)}`,a=``}else a=r.slice(e),i=r.slice(0,e)}let o=a===``?i:`${i}.${a}`;return n?`-${o}`:o},wc=e=>{if(Ec(e))return`0e+0`;let t=hc(e),n=`${_c(t).value}`,r=n.slice(0,1),i=n.slice(1),a=`${Dc(t)?`-`:``}${r}`;i!==``&&(a+=`.${i}`);let o=i.length-t.scale;return`${a}e${o>=0?`+`:``}${o}`},Tc=e=>Number(Cc(e)),Ec=e=>e.value===fc,Dc=e=>e.value<fc,Oc=e=>e>BigInt(2**53-1)||e<BigInt(-(2**53-1))?v():w(Number(e)),kc=e=>{try{return e.trim()===``?v():w(BigInt(e))}catch{return v()}},Ac=e=>{if(e>2**53-1||e<-(2**53-1))return v();try{return w(BigInt(e))}catch{return v()}},jc=Symbol.for(`effect/Brand/Refined`),Mc=()=>Object.assign(e=>e,{[jc]:jc,option:e=>w(e),either:e=>b(e),is:e=>!0}),Nc=On,Pc=An,Fc=xn,Ic=_n,Lc=Symbol.for(`effect/QueueEnqueue`),Rc=Symbol.for(`effect/QueueDequeue`),zc=Symbol.for(`effect/QueueStrategy`),Bc=Symbol.for(`effect/BackingQueue`),Vc={_A:e=>e},Hc={_A:e=>e},Uc={_In:e=>e},Wc={_Out:e=>e};var Gc=class extends Kr{queue;takers;shutdownHook;shutdownFlag;strategy;[Lc]=Uc;[Rc]=Wc;constructor(e,t,n,r,i){super(),this.queue=e,this.takers=t,this.shutdownHook=n,this.shutdownFlag=r,this.strategy=i}pipe(){return De(this,arguments)}commit(){return this.take}capacity(){return this.queue.capacity()}get size(){return Jt(()=>xt(this.unsafeSize(),()=>u))}unsafeSize(){return Le(this.shutdownFlag)?v():w(this.queue.length()-Pn(this.takers)+this.strategy.surplusSize())}get isEmpty(){return We(this.size,e=>e<=0)}get isFull(){return We(this.size,e=>e>=this.capacity())}get shutdown(){return Ct(fe(e=>(C(this.shutdownFlag,Pe(!0)),C(yr(ml(this.takers),t=>ot(t,e.id()),!1,!1),ce(this.strategy.shutdown),Se(ct(this.shutdownHook,void 0)),qt))))}get isShutdown(){return Me(()=>Le(this.shutdownFlag))}get awaitShutdown(){return zt(this.shutdownHook)}isActive(){return!Le(this.shutdownFlag)}unsafeOffer(e){if(Le(this.shutdownFlag))return!1;let t;if(this.queue.length()===0){let n=C(this.takers,Ln(Vr));n===Vr?t=!1:(fl(n,e),t=!0)}else t=!1;if(t)return!0;let n=this.queue.offer(e);return _l(this.strategy,this.queue,this.takers),n}offer(e){return Jt(()=>{if(Le(this.shutdownFlag))return u;let t;if(this.queue.length()===0){let n=C(this.takers,Ln(Vr));n===Vr?t=!1:(fl(n,e),t=!0)}else t=!1;if(t)return c(!0);let n=this.queue.offer(e);return _l(this.strategy,this.queue,this.takers),n?c(!0):this.strategy.handleSurplus([e],this.queue,this.takers,this.shutdownFlag)})}offerAll(e){return Jt(()=>{if(Le(this.shutdownFlag))return u;let t=ue(e),n=this.queue.length()===0?ue(hl(this.takers,t.length)):Re,[r,i]=C(t,ft(n.length));for(let e=0;e<n.length;e++){let t=n[e],i=r[e];fl(t,i)}if(i.length===0)return c(!0);let a=this.queue.offerAll(i);return _l(this.strategy,this.queue,this.takers),je(a)?c(!0):this.strategy.handleSurplus(a,this.queue,this.takers,this.shutdownFlag)})}get take(){return fe(e=>{if(Le(this.shutdownFlag))return u;let t=this.queue.poll(Vr);if(t!==Vr)return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),c(t);{let t=Mt(e.id());return C(Jt(()=>(C(this.takers,ln(t)),_l(this.strategy,this.queue,this.takers),Le(this.shutdownFlag)?u:zt(t))),at(()=>Me(()=>gl(this.takers,t))))}})}get takeAll(){return Jt(()=>Le(this.shutdownFlag)?u:Me(()=>{let e=this.queue.pollUpTo(1/0);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Oe(e)}))}takeUpTo(e){return Jt(()=>Le(this.shutdownFlag)?u:Me(()=>{let t=this.queue.pollUpTo(e);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Oe(t)}))}takeBetween(e,t){return Jt(()=>Kc(this,e,t,tt()))}};const Kc=(e,t,n,r)=>n<t?c(r):C(al(e,n),Gt(i=>{let a=t-i.length;return a===1?C(il(e),We(e=>C(r,Qt(i),Kt(e)))):a>1?C(il(e),Gt(t=>Kc(e,a-1,n-i.length-1,C(r,Qt(i),Kt(t))))):c(C(r,Qt(i)))})),qc=e=>C(Me(()=>Xr(e)),Gt(e=>Qc(el(e),ol()))),Jc=e=>C(Me(()=>Xr(e)),Gt(e=>Qc(el(e),sl()))),Yc=e=>C(Me(()=>Xr(e)),Gt(e=>Qc(el(e),cl()))),Xc=()=>C(Me(()=>fn()),Gt(e=>Qc(el(e),sl()))),Zc=(e,t,n,r,i)=>new Gc(e,t,n,r,i),Qc=(e,t)=>C(Wt(),We(n=>Zc(e,fn(),n,ne(!1),t)));var $c=class{mutable;[Bc]=Hc;constructor(e){this.mutable=e}poll(e){return Ln(this.mutable,e)}pollUpTo(e){return hn(this.mutable,e)}offerAll(e){return Wr(this.mutable,e)}offer(e){return ln(this.mutable,e)}capacity(){return Qn(this.mutable)}length(){return Pn(this.mutable)}};const el=e=>new $c(e),tl=e=>e.size,nl=e=>e.shutdown,rl=x(2,(e,t)=>e.offer(t)),il=e=>e.take,al=x(2,(e,t)=>e.takeUpTo(t)),ol=()=>new ll,sl=()=>new ul,cl=()=>new dl;var ll=class{[zc]=Vc;putters=fn();surplusSize(){return Pn(this.putters)}onCompleteTakersWithEmptyQueue(e){for(;!qr(this.putters)&&!qr(e);){let t=Ln(e,void 0),n=Ln(this.putters,void 0);n[2]&&fl(n[1],!0),fl(t,n[0])}}get shutdown(){return C(_t,Gt(e=>C(Me(()=>ml(this.putters)),Gt(t=>yr(t,([t,n,r])=>r?C(ot(n,e),qt):_e,!1,!1)))))}handleSurplus(e,t,n,r){return fe(i=>{let a=Mt(i.id());return C(Jt(()=>(this.unsafeOffer(e,a),this.unsafeOnQueueEmptySpace(t,n),_l(this,t,n),Le(r)?u:zt(a))),at(()=>Me(()=>this.unsafeRemove(a))))})}unsafeOnQueueEmptySpace(e,t){let n=!0;for(;n&&(e.capacity()===1/0||e.length()<e.capacity());){let r=C(this.putters,Ln(Vr));if(r===Vr)n=!1;else{let n=e.offer(r[0]);n&&r[2]?fl(r[1],!0):n||pl(this.putters,C(ml(this.putters),St(r))),_l(this,e,t)}}}unsafeOffer(e,t){let n=ue(e);for(let e=0;e<n.length;e++){let r=n[e];e===n.length-1?C(this.putters,ln([r,t,!0])):C(this.putters,ln([r,t,!1]))}}unsafeRemove(e){pl(this.putters,C(ml(this.putters),Xt(([,t])=>t!==e)))}},ul=class{[zc]=Vc;surplusSize(){return 0}get shutdown(){return _e}onCompleteTakersWithEmptyQueue(){}handleSurplus(e,t,n,r){return c(!1)}unsafeOnQueueEmptySpace(e,t){}},dl=class{[zc]=Vc;surplusSize(){return 0}get shutdown(){return _e}onCompleteTakersWithEmptyQueue(){}handleSurplus(e,t,n,r){return Me(()=>(this.unsafeOffer(t,e),_l(this,t,n),!0))}unsafeOnQueueEmptySpace(e,t){}unsafeOffer(e,t){let n=t[Symbol.iterator](),r,i=!0;for(;!(r=n.next()).done&&i;){if(e.capacity()===0)return;e.poll(Vr),i=e.offer(r.value)}}};const fl=(e,t)=>pt(e,c(t)),pl=(e,t)=>C(e,Wr(t)),ml=e=>C(e,hn(1/0)),hl=(e,t)=>C(e,hn(t)),gl=(e,t)=>{pl(e,C(ml(e),Xt(e=>t!==e)))},_l=(e,t,n)=>{let r=!0;for(;r&&t.length()!==0;){let i=C(n,Ln(Vr));if(i!==Vr){let a=t.poll(Vr);a===Vr?pl(n,C(ml(n),St(i))):(fl(i,a),e.unsafeOnQueueEmptySpace(t,n)),r=!0}else r=!1}r&&t.length()===0&&!qr(n)&&e.onCompleteTakersWithEmptyQueue(n)},vl=qc,yl=Jc,bl=Yc,xl=Xc,Sl=tl,Cl=nl,wl=rl,Tl=il,El=`Continue`,Dl=Symbol.for(`effect/ChannelChildExecutorDecision`),Ol={[Dl]:Dl},kl=e=>{let t=Object.create(Ol);return t._tag=El,t},Al=Symbol.for(`effect/ChannelContinuation`),jl={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutDone:e=>e,_OutErr2:e=>e,_OutElem:e=>e,_OutDone2:e=>e};var Ml=class{onSuccess;onHalt;_tag=`ContinuationK`;[Al]=jl;constructor(e,t){this.onSuccess=e,this.onHalt=t}onExit(e){return xi(e)?this.onHalt(e.cause):this.onSuccess(e.value)}},Nl=class{finalizer;_tag=`ContinuationFinalizer`;[Al]=jl;constructor(e){this.finalizer=e}};const Pl=`PullAfterNext`,Fl=Symbol.for(`effect/ChannelUpstreamPullStrategy`),Il={_A:e=>e},Ll={[Fl]:Il},Rl=e=>{let t=Object.create(Ll);return t._tag=Pl,t.emitSeparator=e,t},zl=`BracketOut`,Bl=`Bridge`,Vl=`ConcatAll`,Hl=`Emit`,Ul=`Ensuring`,Wl=`Fail`,Gl=`Fold`,Kl=`FromEffect`,ql=`PipeTo`,Jl=`Read`,Yl=`Succeed`,Xl=`SucceedNow`,Zl=`Suspend`,Ql=Symbol.for(`effect/Channel`),$l={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},eu={[Ql]:$l,pipe(){return De(this,arguments)}},tu=e=>Nt(e,Ql)||Tn(e),nu=x(2,(e,t)=>{let n=Object.create(eu);return n._tag=zl,n.acquire=()=>e,n.finalizer=t,n}),ru=(e,t,n)=>{let r=Object.create(eu);return r._tag=Vl,r.combineInners=t,r.combineAll=n,r.onPull=()=>Rl(v()),r.onEmit=()=>kl,r.value=()=>e,r.k=S,r},iu=x(4,(e,t,n,r)=>{let i=Object.create(eu);return i._tag=Vl,i.combineInners=n,i.combineAll=r,i.onPull=()=>Rl(v()),i.onEmit=()=>kl,i.value=()=>e,i.k=t,i}),au=x(2,(e,t)=>{let n=Object.create(eu);return n._tag=Bl,n.input=t,n.channel=e,n}),ou=x(2,(e,t)=>{let n=Object.create(eu);return n._tag=Ul,n.channel=e,n.finalizer=t,n}),su=e=>cu(ni(e)),cu=e=>lu(()=>e),lu=e=>{let t=Object.create(eu);return t._tag=Wl,t.error=e,t},L=x(2,(e,t)=>{let n=Object.create(eu);return n._tag=Gl,n.channel=e,n.k=new Ml(t,cu),n}),R=e=>{let t=Object.create(eu);return t._tag=Kl,t.effect=()=>e,t},uu=x(2,(e,t)=>{let n=Object.create(eu);return n._tag=ql,n.left=()=>e,n.right=()=>t,n}),du=e=>fu({onInput:e.onInput,onFailure:t=>Ge(Qr(t),{onLeft:e.onFailure,onRight:cu}),onDone:e.onDone}),fu=e=>{let t=Object.create(eu);return t._tag=Jl,t.more=e.onInput,t.done=new Ml(e.onDone,e.onFailure),t},pu=e=>gu(()=>e),mu=e=>{let t=Object.create(eu);return t._tag=Xl,t.terminal=e,t},hu=e=>{let t=Object.create(eu);return t._tag=Zl,t.channel=e,t},gu=e=>{let t=Object.create(eu);return t._tag=Yl,t.evaluate=e,t},_u=mu(void 0),z=e=>{let t=Object.create(eu);return t._tag=Hl,t.out=e,t},vu=`Done`,yu=`Emit`,bu=`FromEffect`,xu=`Read`,Su=Symbol.for(`effect/ChannelState`),Cu={_E:e=>e,_R:e=>e},wu={[Su]:Cu},Tu=()=>{let e=Object.create(wu);return e._tag=vu,e},Eu=()=>{let e=Object.create(wu);return e._tag=yu,e},Du=e=>{let t=Object.create(wu);return t._tag=bu,t.effect=e,t},Ou=(e,t,n,r)=>{let i=Object.create(wu);return i._tag=xu,i.upstream=e,i.onEffect=t,i.onEmit=n,i.onDone=r,i},ku=e=>e._tag===bu,Au=e=>ku(e)?e.effect:A,ju=e=>ku(e)?kn(e.effect):void 0,Mu=`PullFromChild`,Nu=`PullFromUpstream`,Pu=`DrainChildExecutors`,Fu=`Emit`;var Iu=class{childExecutor;parentSubexecutor;onEmit;_tag=Mu;constructor(e,t,n){this.childExecutor=e,this.parentSubexecutor=t,this.onEmit=n}close(e){let t=this.childExecutor.close(e),n=this.parentSubexecutor.close(e);if(t!==void 0&&n!==void 0)return qn(O(t),O(n),(e,t)=>C(e,mi(t)));if(t!==void 0)return t;if(n!==void 0)return n}enqueuePullFromChild(e){return this}},Lu=class e{upstreamExecutor;createChild;lastDone;activeChildExecutors;combineChildResults;combineWithChildResult;onPull;onEmit;_tag=Nu;constructor(e,t,n,r,i,a,o,s){this.upstreamExecutor=e,this.createChild=t,this.lastDone=n,this.activeChildExecutors=r,this.combineChildResults=i,this.combineWithChildResult=a,this.onPull=o,this.onEmit=s}close(e){let t=this.upstreamExecutor.close(e);return[...this.activeChildExecutors.map(t=>t===void 0?void 0:t.childExecutor.close(e)),t].reduce((e,t)=>{if(e!==void 0&&t!==void 0)return qn(e,O(t),(e,t)=>mi(e,t));if(e!==void 0)return e;if(t!==void 0)return O(t)},void 0)}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.createChild,this.lastDone,[...this.activeChildExecutors,t],this.combineChildResults,this.combineWithChildResult,this.onPull,this.onEmit)}},Ru=class e{upstreamExecutor;lastDone;activeChildExecutors;upstreamDone;combineChildResults;combineWithChildResult;onPull;_tag=Pu;constructor(e,t,n,r,i,a,o){this.upstreamExecutor=e,this.lastDone=t,this.activeChildExecutors=n,this.upstreamDone=r,this.combineChildResults=i,this.combineWithChildResult=a,this.onPull=o}close(e){let t=this.upstreamExecutor.close(e);return[...this.activeChildExecutors.map(t=>t===void 0?void 0:t.childExecutor.close(e)),t].reduce((e,t)=>{if(e!==void 0&&t!==void 0)return qn(e,O(t),(e,t)=>mi(e,t));if(e!==void 0)return e;if(t!==void 0)return O(t)},void 0)}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.lastDone,[...this.activeChildExecutors,t],this.upstreamDone,this.combineChildResults,this.combineWithChildResult,this.onPull)}},zu=class{value;next;_tag=Fu;constructor(e,t){this.value=e,this.next=t}close(e){return this.next.close(e)}enqueuePullFromChild(e){return this}};const Bu=Symbol.for(`effect/ChannelUpstreamPullRequest`),Vu={_A:e=>e},Hu={[Bu]:Vu},Uu=e=>{let t=Object.create(Hu);return t._tag=`Pulled`,t.value=e,t},Wu=e=>{let t=Object.create(Hu);return t._tag=`NoUpstream`,t.activeDownstreamCount=e,t};var Gu=class e{_activeSubexecutor=void 0;_cancelled=void 0;_closeLastSubstream=void 0;_currentChannel;_done=void 0;_doneStack=[];_emitted=void 0;_executeCloseLastSubstream;_input=void 0;_inProgressFinalizer=void 0;_providedEnv;constructor(e,t,n){this._currentChannel=e,this._executeCloseLastSubstream=n,this._providedEnv=t}run(){let t;for(;t===void 0;)if(this._cancelled!==void 0)t=this.processCancellation();else if(this._activeSubexecutor!==void 0)t=this.runSubexecutor();else try{if(this._currentChannel===void 0)t=Tu();else switch(Tn(this._currentChannel)&&(this._currentChannel=R(this._currentChannel)),this._currentChannel._tag){case zl:t=this.runBracketOut(this._currentChannel);break;case Bl:{let e=this._currentChannel.input;if(this._currentChannel=this._currentChannel.channel,this._input!==void 0){let n=this._input;this._input=void 0;let r=()=>D(e.awaitRead(),()=>j(()=>{let t=n.run();switch(t._tag){case vu:return fi(n.getDone(),{onFailure:t=>e.error(t),onSuccess:t=>e.done(t)});case yu:return D(e.emit(n.getEmit()),()=>r());case bu:return Zr(t.effect,{onFailure:t=>e.error(t),onSuccess:()=>r()});case xu:return Ju(t,()=>r(),t=>e.error(t))}}));t=Du(D(Hr(an(r())),e=>Nr(()=>this.addFinalizer(t=>D(rn(e),()=>j(()=>{let e=this.restorePipe(t,n);return e===void 0?A:e}))))))}break}case Vl:{let t=new e(this._currentChannel.value(),this._providedEnv,e=>Nr(()=>{let t=this._closeLastSubstream===void 0?A:this._closeLastSubstream;this._closeLastSubstream=C(t,k(e))}));t._input=this._input;let n=this._currentChannel;this._activeSubexecutor=new Lu(t,e=>n.k(e),void 0,[],(e,t)=>n.combineInners(e,t),(e,t)=>n.combineAll(e,t),e=>n.onPull(e),e=>n.onEmit(e)),this._closeLastSubstream=void 0,this._currentChannel=void 0;break}case Hl:this._emitted=this._currentChannel.out,this._currentChannel=this._activeSubexecutor===void 0?_u:void 0,t=Eu();break;case Ul:this.runEnsuring(this._currentChannel);break;case Wl:t=this.doneHalt(this._currentChannel.error());break;case Gl:this._doneStack.push(this._currentChannel.k),this._currentChannel=this._currentChannel.channel;break;case Kl:{let e=this._providedEnv===void 0?this._currentChannel.effect():C(this._currentChannel.effect(),Rn(this._providedEnv));t=Du(Zr(e,{onFailure:e=>{let t=this.doneHalt(e);return t!==void 0&&ku(t)?t.effect:A},onSuccess:e=>{let t=this.doneSucceed(e);return t!==void 0&&ku(t)?t.effect:A}}));break}case ql:{let t=this._input,n=new e(this._currentChannel.left(),this._providedEnv,e=>this._executeCloseLastSubstream(e));n._input=t,this._input=n,this.addFinalizer(e=>{let n=this.restorePipe(e,t);return n===void 0?A:n}),this._currentChannel=this._currentChannel.right();break}case`Provide`:{let e=this._providedEnv;this._providedEnv=this._currentChannel.context(),this._currentChannel=this._currentChannel.inner,this.addFinalizer(()=>Nr(()=>{this._providedEnv=e}));break}case Jl:{let e=this._currentChannel;t=Ou(this._input,S,t=>{try{this._currentChannel=e.more(t)}catch(t){this._currentChannel=e.done.onExit(bi(t))}},t=>{let n=t=>e.done.onExit(t);this._currentChannel=n(t)});break}case Yl:t=this.doneSucceed(this._currentChannel.evaluate());break;case Xl:t=this.doneSucceed(this._currentChannel.terminal);break;case Zl:this._currentChannel=this._currentChannel.channel();break}}catch(e){this._currentChannel=cu(si(e))}return t}getDone(){return this._done}getEmit(){return this._emitted}cancelWith(e){this._cancelled=e}clearInProgressFinalizer(){this._inProgressFinalizer=void 0}storeInProgressFinalizer(e){this._inProgressFinalizer=e}popAllFinalizers(e){let t=[],n=this._doneStack.pop();for(;n;)n._tag===`ContinuationFinalizer`&&t.push(n.finalizer),n=this._doneStack.pop();let r=t.length===0?A:qu(t,e);return this.storeInProgressFinalizer(r),r}popNextFinalizers(){let e=[];for(;this._doneStack.length!==0;){let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`)return e;e.push(t),this._doneStack.pop()}return e}restorePipe(e,t){let n=this._input;return this._input=t,n===void 0?A:n.close(e)}close(e){let t,n=this._inProgressFinalizer;n!==void 0&&(t=C(n,cr(Nr(()=>this.clearInProgressFinalizer()))));let r,i=this.popAllFinalizers(e);i!==void 0&&(r=C(i,cr(Nr(()=>this.clearInProgressFinalizer()))));let a=this._activeSubexecutor===void 0?void 0:this._activeSubexecutor.close(e);if(a!==void 0||t!==void 0||r!==void 0)return C(O(Ku(a)),Cr(O(Ku(t))),Cr(O(Ku(r))),E(([[e,t],n])=>C(e,mi(t),mi(n))),br,D(e=>j(()=>e)))}doneSucceed(e){if(this._doneStack.length===0)return this._done=pi(e),this._currentChannel=void 0,Tu();let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`){this._doneStack.pop(),this._currentChannel=t.onSuccess(e);return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=pi(e),this._currentChannel=void 0,Tu();let r=qu(n.map(e=>e.finalizer),pi(e));this.storeInProgressFinalizer(r);let i=C(r,cr(Nr(()=>this.clearInProgressFinalizer())),br,D(()=>Nr(()=>this.doneSucceed(e))));return Du(i)}doneHalt(e){if(this._doneStack.length===0)return this._done=ui(e),this._currentChannel=void 0,Tu();let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`){this._doneStack.pop();try{this._currentChannel=t.onHalt(e)}catch(e){this._currentChannel=cu(si(e))}return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=ui(e),this._currentChannel=void 0,Tu();let r=qu(n.map(e=>e.finalizer),ui(e));this.storeInProgressFinalizer(r);let i=C(r,cr(Nr(()=>this.clearInProgressFinalizer())),br,D(()=>Nr(()=>this.doneHalt(e))));return Du(i)}processCancellation(){return this._currentChannel=void 0,this._done=this._cancelled,this._cancelled=void 0,Tu()}runBracketOut(e){let t=br(Zr(this.provide(e.acquire()),{onFailure:e=>Nr(()=>{this._currentChannel=cu(e)}),onSuccess:t=>Nr(()=>{this.addFinalizer(n=>this.provide(e.finalizer(t,n))),this._currentChannel=z(t)})}));return Du(t)}provide(e){return this._providedEnv===void 0?e:C(e,Rn(this._providedEnv))}runEnsuring(e){this.addFinalizer(e.finalizer),this._currentChannel=e.channel}addFinalizer(e){this._doneStack.push(new Nl(e))}runSubexecutor(){let e=this._activeSubexecutor;switch(e._tag){case Mu:return this.pullFromChild(e.childExecutor,e.parentSubexecutor,e.onEmit,e);case Nu:return this.pullFromUpstream(e);case Pu:return this.drainChildExecutors(e);case Fu:return this._emitted=e.value,this._activeSubexecutor=e.next,Eu()}}replaceSubexecutor(e){this._currentChannel=void 0,this._activeSubexecutor=e}finishWithExit(e){let t=fi(e,{onFailure:e=>this.doneHalt(e),onSuccess:e=>this.doneSucceed(e)});return this._activeSubexecutor=void 0,t===void 0?A:Au(t)}finishSubexecutorWithCloseEffect(e,...t){this.addFinalizer(()=>C(t,sn(t=>C(Nr(()=>t(e)),D(e=>e===void 0?A:e)),{discard:!0})));let n=C(e,fi({onFailure:e=>this.doneHalt(e),onSuccess:e=>this.doneSucceed(e)}));return this._activeSubexecutor=void 0,n}applyUpstreamPullStrategy(e,t,n){switch(n._tag){case Pl:{let r=!e||t.some(e=>e!==void 0);return[n.emitSeparator,r?[void 0,...t]:t]}case`PullAfterAllEnqueued`:{let r=!e||t.some(e=>e!==void 0);return[n.emitSeparator,r?[...t,void 0]:t]}}}pullFromChild(e,t,n,r){return Ou(e,S,i=>{let a=n(i);switch(a._tag){case El:break;case`Close`:this.finishWithDoneValue(e,t,a.value);break;case`Yield`:{let e=t.enqueuePullFromChild(r);this.replaceSubexecutor(e);break}}this._activeSubexecutor=new zu(i,this._activeSubexecutor)},fi({onFailure:n=>{let r=this.handleSubexecutorFailure(e,t,n);return r===void 0?void 0:ju(r)},onSuccess:n=>{this.finishWithDoneValue(e,t,n)}}))}finishWithDoneValue(e,t,n){let r=t;switch(r._tag){case Nu:{let t=new Lu(r.upstreamExecutor,r.createChild,r.lastDone===void 0?n:r.combineChildResults(r.lastDone,n),r.activeChildExecutors,r.combineChildResults,r.combineWithChildResult,r.onPull,r.onEmit);this._closeLastSubstream=e.close(pi(n)),this.replaceSubexecutor(t);break}case Pu:{let t=new Ru(r.upstreamExecutor,r.lastDone===void 0?n:r.combineChildResults(r.lastDone,n),r.activeChildExecutors,r.upstreamDone,r.combineChildResults,r.combineWithChildResult,r.onPull);this._closeLastSubstream=e.close(pi(n)),this.replaceSubexecutor(t);break}default:break}}handleSubexecutorFailure(e,t,n){return this.finishSubexecutorWithCloseEffect(ui(n),e=>t.close(e),t=>e.close(t))}pullFromUpstream(e){if(e.activeChildExecutors.length===0)return this.performPullFromUpstream(e);let t=e.activeChildExecutors[0],n=new Lu(e.upstreamExecutor,e.createChild,e.lastDone,e.activeChildExecutors.slice(1),e.combineChildResults,e.combineWithChildResult,e.onPull,e.onEmit);if(t===void 0)return this.performPullFromUpstream(n);this.replaceSubexecutor(new Iu(t.childExecutor,n,t.onEmit))}performPullFromUpstream(t){return Ou(t.upstreamExecutor,e=>{let t=this._closeLastSubstream===void 0?A:this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(t),k(e))},n=>{if(this._closeLastSubstream!==void 0){let r=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(r),E(()=>{let r=new e(t.createChild(n),this._providedEnv,this._executeCloseLastSubstream);r._input=this._input;let[i,a]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(Uu(n)));this._activeSubexecutor=new Iu(r,new Lu(t.upstreamExecutor,t.createChild,t.lastDone,a,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),bt(i)&&(this._activeSubexecutor=new zu(i.value,this._activeSubexecutor))}))}let r=new e(t.createChild(n),this._providedEnv,this._executeCloseLastSubstream);r._input=this._input;let[i,a]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(Uu(n)));this._activeSubexecutor=new Iu(r,new Lu(t.upstreamExecutor,t.createChild,t.lastDone,a,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),bt(i)&&(this._activeSubexecutor=new zu(i.value,this._activeSubexecutor))},e=>{if(t.activeChildExecutors.some(e=>e!==void 0)){let e=new Ru(t.upstreamExecutor,t.lastDone,[void 0,...t.activeChildExecutors],t.upstreamExecutor.getDone(),t.combineChildResults,t.combineWithChildResult,t.onPull);if(this._closeLastSubstream!==void 0){let t=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(t),E(()=>this.replaceSubexecutor(e)))}this.replaceSubexecutor(e);return}let n=this._closeLastSubstream,r=this.finishSubexecutorWithCloseEffect(C(e,gi(e=>t.combineWithChildResult(t.lastDone,e))),()=>n,e=>t.upstreamExecutor.close(e));return r===void 0?void 0:ju(r)})}drainChildExecutors(e){if(e.activeChildExecutors.length===0){let t=this._closeLastSubstream;return t!==void 0&&this.addFinalizer(()=>M(t)),this.finishSubexecutorWithCloseEffect(e.upstreamDone,()=>t,t=>e.upstreamExecutor.close(t))}let t=e.activeChildExecutors[0],n=e.activeChildExecutors.slice(1);if(t===void 0){let[t,r]=this.applyUpstreamPullStrategy(!0,n,e.onPull(Wu(n.reduce((e,t)=>t===void 0?e:e+1,0))));return this.replaceSubexecutor(new Ru(e.upstreamExecutor,e.lastDone,r,e.upstreamDone,e.combineChildResults,e.combineWithChildResult,e.onPull)),bt(t)?(this._emitted=t.value,Eu()):void 0}let r=new Ru(e.upstreamExecutor,e.lastDone,n,e.upstreamDone,e.combineChildResults,e.combineWithChildResult,e.onPull);this.replaceSubexecutor(new Iu(t.childExecutor,r,t.onEmit))}};const Ku=e=>e===void 0?A:e,qu=(e,t)=>C(sn(e,e=>O(e(t))),E(e=>C(vi(e),Ne(()=>yi))),D(e=>j(()=>e))),Ju=(e,t,n)=>{let r=[e],i=()=>{let e=r.pop();if(e===void 0||e.upstream===void 0)return Dr(`Unexpected end of input for channel execution`);let a=e.upstream.run();switch(a._tag){case yu:{let a=e.onEmit(e.upstream.getEmit());return r.length===0?a===void 0?j(t):C(a,Zr({onFailure:n,onSuccess:t})):a===void 0?j(()=>i()):C(a,Zr({onFailure:n,onSuccess:()=>i()}))}case vu:{let a=e.onDone(e.upstream.getDone());return r.length===0?a===void 0?j(t):C(a,Zr({onFailure:n,onSuccess:t})):a===void 0?j(()=>i()):C(a,Zr({onFailure:n,onSuccess:()=>i()}))}case bu:return r.push(e),C(e.onEffect(a.effect),Lr(t=>j(()=>{let n=e.onDone(ui(t));return n===void 0?A:n})),Zr({onFailure:n,onSuccess:()=>i()}));case xu:return r.push(e),r.push(a),j(()=>i())}};return i()},Yu=x(2,(e,t)=>{let n=(t,n,r)=>dr(Nr(()=>new Gu(e,void 0,S)),e=>j(()=>Xu(e.run(),e).pipe(mr(t),k(T(t)),ur(T(n)))),(e,t)=>{let n=e.close(t);return n===void 0?A:Xn(n,e=>Mr(r,zr(e)))});return Rr(e=>Jn([Fr(t,Zn),hr(),hr()]).pipe(D(([r,i,a])=>e(n(i,a,r)).pipe(Fn(t),D(n=>t.addFinalizer(e=>{let t=xi(e)?$r(e.cause):void 0;return on(i).pipe(D(e=>e?En(a,void 0).pipe(k(Wn(n)),k(jn(n))):En(a,void 0).pipe(k(t&&ht(t)>0?rr(n,yt(t)):rn(n)),k(jn(n)))))}).pipe(k(e(T(i)))))))))}),Xu=(e,t)=>{let n=e;switch(n._tag){case bu:return C(n.effect,D(()=>Xu(t.run(),t)));case yu:return Xu(t.run(),t);case vu:return j(()=>t.getDone());case xu:return Ju(n,()=>Xu(t.run(),t),zr)}},Zu={[Symbol.for(`effect/ChannelMergeDecision`)]:{_R:e=>e,_E0:e=>e,_Z0:e=>e,_E:e=>e,_Z:e=>e}},Qu=e=>{let t=Object.create(Zu);return t._tag=`Await`,t.f=e,t},$u=`BothRunning`,ed=`LeftDone`,td=`RightDone`,nd=Symbol.for(`effect/ChannelMergeState`),rd={[nd]:nd},id=(e,t)=>{let n=Object.create(rd);return n._tag=$u,n.left=e,n.right=t,n},ad=e=>{let t=Object.create(rd);return t._tag=ed,t.f=e,t},od=e=>{let t=Object.create(rd);return t._tag=td,t.f=e,t},sd=`BackPressure`,cd=`BufferSliding`,ld=Symbol.for(`effect/ChannelMergeStrategy`),ud={[ld]:ld},dd=e=>{let t=Object.create(ud);return t._tag=sd,t},fd=e=>{let t=Object.create(ud);return t._tag=cd,t},pd=x(2,(e,{onBackPressure:t,onBufferSliding:n})=>{switch(e._tag){case sd:return t();case cd:return n()}}),md=`Empty`,hd=`Emit`,gd=`Error`,_d=`Done`,vd=e=>({_tag:md,notifyProducer:e}),yd=e=>({_tag:hd,notifyConsumers:e}),bd=e=>({_tag:gd,cause:e}),xd=e=>({_tag:_d,done:e});var Sd=class{ref;constructor(e){this.ref=e}awaitRead(){return Gr(Kn(this.ref,e=>e._tag===md?[T(e.notifyProducer),e]:[A,e]))}get close(){return Jr(e=>this.error(ci(e)))}done(e){return Gr(Kn(this.ref,t=>{switch(t._tag){case md:return[T(t.notifyProducer),t];case hd:return[sn(t.notifyConsumers,t=>En(t,y(e)),{discard:!0}),xd(e)];case gd:return[gr,t];case _d:return[gr,t]}}))}emit(e){return D(hr(),t=>Gr(Kn(this.ref,n=>{switch(n._tag){case md:return[T(n.notifyProducer),n];case hd:{let r=n.notifyConsumers[0],i=n.notifyConsumers.slice(1);if(r!==void 0)return[En(r,b(e)),i.length===0?vd(t):yd(i)];throw Error(`Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues`)}case gd:return[gr,n];case _d:return[gr,n]}})))}error(e){return Gr(Kn(this.ref,t=>{switch(t._tag){case md:return[T(t.notifyProducer),t];case hd:return[sn(t.notifyConsumers,t=>_r(t,e),{discard:!0}),bd(e)];case gd:return[gr,t];case _d:return[gr,t]}}))}get take(){return this.takeWith(e=>ui(ei(e,y)),e=>pi(e),e=>hi(b(e)))}takeWith(e,t,n){return D(hr(),r=>Gr(Kn(this.ref,i=>{switch(i._tag){case md:return[k(En(i.notifyProducer,void 0),Mn(T(r),{onFailure:e,onSuccess:Ge({onLeft:n,onRight:t})})),yd([r])];case hd:return[Mn(T(r),{onFailure:e,onSuccess:Ge({onLeft:n,onRight:t})}),yd([...i.notifyConsumers,r])];case gd:return[M(e(i.cause)),i];case _d:return[M(n(i.done)),i]}})))}};const Cd=()=>C(hr(),D(e=>sr(vd(e))),E(e=>new Sd(e))),wd=x(2,(e,t)=>iu(e,t,()=>void 0,()=>void 0)),Td=e=>{let t=fu({onInput:()=>t,onFailure:cu,onDone:pu});return uu(e,t)},Ed=x(2,(e,t)=>ou(e,()=>t)),Dd=e=>L(e,S),Od=e=>Vd(e.takeWith(cu,t=>L(z(t),()=>Od(e)),pu)),kd=x(2,(e,t)=>L(e,e=>gu(()=>t(e)))),Ad=x(2,(e,t)=>{let n=du({onInput:e=>L(z(t(e)),()=>n),onFailure:su,onDone:mu});return uu(e,n)}),jd=x(2,(e,t)=>{let n=fu({onInput:e=>C(R(t(e)),L(z),L(()=>n)),onFailure:cu,onDone:mu});return uu(e,n)}),Md=e=>t=>Nd(e)(t,mt),Nd=({bufferSize:e=16,concurrency:t,mergeStrategy:n=dd()})=>(r,i)=>Ud(a=>un(function*(){let o=t===`unbounded`?2**53-1:t,s=yield*Cd(),c=Od(s),l=yield*vl(e);yield*Mr(a,Cl(l));let u=yield*xl();yield*Mr(a,Cl(u));let d=yield*sr(v()),f=yield*hr(),p=(yield*Dn(o)).withPermits,m=yield*zd(uu(c,r),a);function h(e){return e.pipe(D(Ge({onLeft:e=>M(w(e)),onRight:e=>wr(wl(l,M(b(e))),v())})),Cn({until:e=>bt(e)}),D(e=>Yr(d,_({onNone:()=>w(e.value),onSome:t=>w(i(t,e.value))}))),Lr(e=>li(e)?zr(e):wl(l,zr(e)).pipe(k(En(f,void 0)),Pr)))}yield*m.pipe(Zr({onFailure:e=>wl(l,zr(e)).pipe(k(M(!1))),onSuccess:Ge({onLeft:e=>vn(an(T(f)),an(p(o)(A)),{onSelfDone:(e,t)=>wr(rn(t),!1),onOtherDone:(t,n)=>k(rn(n),lr(d).pipe(D(_({onNone:()=>wl(l,M(y(e))),onSome:t=>wl(l,M(y(i(t,e))))})),wr(!1)))}),onRight:e=>pd(n,{onBackPressure:()=>un(function*(){let t=yield*hr(),n=nn(t=>zd(uu(c,e),t).pipe(D(e=>Bn(O(h(e)),O(an(T(f))))),D(S)));return yield*En(t,void 0).pipe(k(n),p(1),Fn(a)),yield*T(t),!(yield*on(f))}),onBufferSliding:()=>un(function*(){let t=yield*hr(),n=yield*hr(),r=yield*Sl(u);yield*Tl(u).pipe(D(e=>En(e,void 0)),or(()=>r>=o)),yield*wl(u,t);let i=nn(n=>zd(uu(c,e),n).pipe(D(e=>O(h(e)).pipe(Bn(O(an(T(f)))),Bn(O(an(T(t)))))),D(S)));return yield*En(n,void 0).pipe(k(i),p(1),Fn(a)),yield*T(n),!(yield*on(f))})})})}),Cn({while:e=>e}),Fn(a));let g=C(Tl(l),Gr,Mn({onFailure:cu,onSuccess:Ge({onLeft:mu,onRight:e=>L(z(e),()=>g)})}),Vd);return au(g,s)})),Pd=x(3,(e,t,n)=>Md(n)(Ad(e,t))),Fd=x(2,(e,t)=>{function n(n){return un(function*(){let r=yield*Cd(),i=Od(r),a=yield*zd(uu(i,e),n),o=yield*zd(uu(i,t.other),n);function s(e,t,r){return(i,a,o)=>{function s(e){let n=e;return n._tag===`Done`?M(R(k(rn(t),n.effect))):E(Wn(t),fi({onFailure:e=>R(n.f(ui(e))),onSuccess:Ge({onLeft:e=>R(n.f(pi(e))),onRight:e=>qd(z(e),c(o(n.f)))})}))}return fi(e,{onFailure:e=>s(i(ui(e))),onSuccess:Ge({onLeft:e=>s(i(pi(e))),onRight:e=>M(L(z(e),()=>L(R(Fn(an(r),n)),e=>c(a(e,t)))))})})}}function c(e){switch(e._tag){case $u:{let n=an(Ir(e.left)),r=an(Ir(e.right));return Vd(vn(n,r,{onSelfDone:(n,r)=>k(rn(r),s(n,e.right,a)(t.onSelfDone,id,e=>ad(e))),onOtherDone:(n,r)=>k(rn(r),s(n,e.left,o)(t.onOtherDone,(e,t)=>id(t,e),e=>od(e)))}))}case ed:return Vd(E(O(o),fi({onFailure:t=>R(e.f(ui(t))),onSuccess:Ge({onLeft:t=>R(e.f(pi(t))),onRight:t=>L(z(t),()=>c(ad(e.f)))})})));case td:return Vd(E(O(a),fi({onFailure:t=>R(e.f(ui(t))),onSuccess:Ge({onLeft:t=>R(e.f(pi(t))),onRight:t=>L(z(t),()=>c(od(e.f)))})})))}}return R(kr(e=>{let t=kr(t=>(t.transferChildren(e.scope()),A));return qn(an(a).pipe(cr(t),Fn(n)),an(o).pipe(cr(t),Fn(n)),(e,t)=>id(e,t))})).pipe(L(c),au(r))})}return Ud(n)}),Id=e=>Un(t=>Yu(e,t)),Ld=e=>Vd(Rr(t=>E($n(),n=>nu(Xn(t(Tr(e,n)),e=>Yn(n,ui(e))),(e,t)=>Yn(n,t))))),Rd=e=>Hd(E(Vn,t=>L(R(e(t)),z))),zd=x(2,(e,t)=>Cr(Nr(()=>new Gu(e,void 0,S)),Hn()).pipe(pr(([e,n])=>fr(t,t=>{let r=e.close(t);return r===void 0?A:Rn(r,n)})),br,E(([e])=>j(()=>Bd(e.run(),e))))),Bd=(e,t)=>{let n=e;switch(n._tag){case vu:return fi(t.getDone(),{onFailure:zr,onSuccess:e=>M(y(e))});case yu:return M(b(t.getEmit()));case bu:return C(n.effect,D(()=>Bd(t.run(),t)));case xu:return Ju(n,()=>Bd(t.run(),t),e=>zr(e))}},Vd=e=>Dd(R(e)),Hd=e=>ru(Ld(e),(e,t)=>e,(e,t)=>e),Ud=e=>ru(Rd(e),(e,t)=>e,(e,t)=>e),Wd=e=>Gd(0,e.length,e),Gd=(e,t,n)=>e===t?_u:C(z(C(n,ee(e))),L(()=>Gd(e+1,t,n))),Kd=x(e=>tu(e[1]),(e,t,n)=>n?.concurrent?Fd(e,{other:t,onSelfDone:e=>Qu(t=>j(()=>_i(e,t))),onOtherDone:e=>Qu(t=>j(()=>_i(t,e)))}):L(e,e=>kd(t,t=>[e,t]))),qd=x(e=>tu(e[1]),(e,t,n)=>n?.concurrent?kd(Kd(e,t,{concurrent:!0}),e=>e[1]):L(e,()=>t)),Jd=Symbol.for(`effect/Sink`),Yd={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e};var Xd=class{channel;[Jd]=Yd;constructor(e){this.channel=e}pipe(){return De(this,arguments)}};const Zd=e=>{let t=fu({onInput:n=>C(R(sn(n,t=>e(t),{discard:!0})),L(()=>t)),onFailure:cu,onDone:()=>_u});return new Xd(t)},Qd=e=>new Xd(R(e)),$d=e=>Tn(e)?$d(Qd(e)):e.channel,ef=e=>new Xd(Hd(e.pipe(E(e=>$d(e))))),tf=yn,nf=e=>Object.assign(e,{chunk(e){return this(M(e))},die(e){return this(ir(e))},dieMessage(e){return this(Dr(e))},done(e){return this(j(()=>Si(e,{onFailure:w,onSuccess:ye})))},end(){return this(Gn(v()))},fail(e){return this(Gn(w(e)))},fromEffect(e){return this(gn(e,{onFailure:w,onSuccess:ye}))},fromEffectChunk(e){return this(C(e,bn(w)))},halt(e){return this(zr(C(e,ei(w))))},single(e){return this(M(ye(e)))}}),rf=Symbol.for(`effect/Take`),af={_A:e=>e,_E:e=>e};var of=class{exit;[rf]=af;constructor(e){this.exit=e}pipe(){return De(this,arguments)}};const sf=e=>new of(pi(e)),cf=e=>j(()=>e.exit),lf=new of(hi(v())),uf=e=>new of(ui(C(e,ei(w)))),df=e=>Mn(e,{onFailure:e=>_(ai(e),{onNone:()=>lf,onSome:uf}),onSuccess:sf}),ff=x(2,(e,{onEnd:t,onFailure:n,onSuccess:r})=>fi(e.exit,{onFailure:e=>_(ai(e),{onNone:t,onSome:n}),onSuccess:r})),pf=()=>Gn(v()),mf=Symbol.for(`effect/Stream`),hf={_R:e=>e,_E:e=>e,_A:e=>e};var gf=class{channel;[mf]=hf;constructor(e){this.channel=e}pipe(){return De(this,arguments)}};const _f=e=>Nt(e,mf)||Tn(e),vf=e=>{if(e===`unbounded`)return xl();if(typeof e==`number`||e===void 0)return vl(e??16);switch(e.strategy){case`dropping`:return yl(e.bufferSize??16);case`sliding`:return bl(e.bufferSize??16);default:return vl(e.bufferSize??16)}},yf=(e,t)=>C(jr(vf(t),e=>Cl(e)),D(t=>C(Hn(),D(n=>C(e(nf(e=>C(df(e),D(e=>wl(t,e)),Pr,tf(n)).then(e=>{if(xi(e)&&!li(e.cause))throw oi(e.cause)}))),k(sr(!1)),D(e=>C(lr(e),E(n=>n?pf():C(Tl(t),D(cf),zn(()=>C(Br(e,!0),k(Cl(t)))))))))))),Pf,wf(Mf)),bf=x(2,(e,t)=>{if(t.strategy===`dropping`)return xf(e,t.capacity);if(t.strategy===`sliding`)return Sf(e,t.capacity);let n=If(e,t);return new gf(Hd(E(n,e=>{let t=C(R(Tl(e)),L(ff({onEnd:()=>_u,onFailure:cu,onSuccess:e=>C(z(e),L(()=>t))})));return t})))}),xf=x(2,(e,t)=>{let n=jr(yl(t),e=>Cl(e));return new gf(Cf(n,kf(e)))}),Sf=x(2,(e,t)=>{let n=jr(bl(t),e=>Cl(e));return new gf(Cf(n,kf(e)))}),Cf=(e,t)=>{let n=(e,t)=>{let r=n=>C(lr(t),pr(T),k(hr()),D(r=>C(wl(e,[n,r]),k(Br(t,r)),k(T(r)))),Pr,R);return fu({onInput:r=>C(hr(),D(n=>C(wl(e,[sf(r),n]),D(e=>C(Br(t,n),or(()=>e))))),Pr,R,L(()=>n(e,t))),onFailure:e=>r(uf(e)),onDone:()=>r(lf)})},r=e=>{let t=C(R(Tl(e)),L(([e,n])=>qd(R(En(n,void 0)),ff(e,{onEnd:()=>_u,onFailure:cu,onSuccess:e=>C(z(e),L(()=>t))}))));return t};return Hd(C(e,D(e=>C(hr(),pr(e=>En(e,void 0)),D(i=>C(sr(i),D(r=>C(t,uu(n(e,r)),Id,pn)),wr(r(e))))))))},wf=x(e=>_f(e[0]),(e,t,n)=>{let i=n?.bufferSize??16;return n?.switch?Tf(n?.concurrency,()=>Ef(e,1,i,t),n=>Ef(e,n,i,t)):Tf(n?.concurrency,()=>new gf(wd(kf(e),e=>C(e,d(e=>kf(t(e))),r(_u,(e,t)=>C(e,qd(t)))))),r=>new gf(C(kf(e),wd(Wd),Pd(e=>kf(t(e)),n))))}),Tf=(e,t,n)=>{switch(e){case void 0:return t();case`unbounded`:return n(2**53-1);default:return e>1?n(e):t()}},Ef=x(4,(e,t,n,r)=>new gf(C(kf(e),wd(Wd),Pd(e=>kf(r(e)),{concurrency:t,mergeStrategy:fd(),bufferSize:n})))),Df=x(e=>_f(e[0]),(e,t)=>wf(e,S,t)),Of=e=>new gf(e),kf=e=>{if(`channel`in e)return e.channel;if(Tn(e))return kf(Af(e));throw TypeError(`Expected a Stream.`)},Af=e=>C(e,bn(w),jf),jf=e=>new gf(Vd(wn(e,{onFailure:_({onNone:()=>_u,onSome:su}),onSuccess:e=>z(ye(e))}))),Mf=e=>Lf(e,e=>C(E(e,t=>w([t,e])),vr(_({onNone:()=>M(v()),onSome:Gn})))),Nf=x(2,(e,t)=>{let n=fu({onInput:e=>L(z(sf(e)),()=>n),onFailure:e=>z(uf(e)),onDone:()=>z(lf)});return C(uu(kf(e),n),jd(e=>wl(t,e)),Td,Id,Pr)}),Pf=e=>new gf(Ed(Ld(C(e,E(ye))),A)),Ff=e=>new gf(hu(()=>kf(e()))),If=x(e=>_f(e[0]),(e,t)=>pr(jr(t?.strategy===`unbounded`?xl():t?.strategy===`dropping`?yl(t.capacity??2):t?.strategy===`sliding`?bl(t.capacity??2):vl(t?.capacity??2),e=>Cl(e)),t=>pn(Nf(e,t)))),Lf=(e,t)=>Ff(()=>{let n=e=>Vd(E(t(e),_({onNone:()=>_u,onSome:([e,t])=>L(z(e),()=>n(t))})));return new gf(n(e))}),Rf=e=>Df(Af(e)),zf=e=>Df(Pf(e)),Bf=L,Vf=_u,Hf=z,Uf=Li,Wf=zi,Gf=Bi,Kf=Vi,qf=Hi,Jf=Ui,Yf=Gi,Xf=Ki,Zf=Ji,Qf=Zi,$f=ta,ep=na,tp=aa,np=oa,rp=sa,ip=fa;Ze(`effect/DateTime/CurrentTimeZone`)();const ap=ya,op=xa;var B=class{path;actual;issue;_tag=`Pointer`;constructor(e,t,n){this.path=e,this.actual=t,this.issue=n}},sp=class{actual;message;_tag=`Unexpected`;constructor(e,t){this.actual=e,this.message=t}},cp=class{ast;message;_tag=`Missing`;actual=void 0;constructor(e,t){this.ast=e,this.message=t}},V=class{ast;actual;issues;output;_tag=`Composite`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.issues=n,this.output=r}},lp=class{ast;actual;kind;issue;_tag=`Refinement`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},up=class{ast;actual;kind;issue;_tag=`Transformation`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},H=class{ast;actual;message;_tag=`Type`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}},dp=class{ast;actual;message;_tag=`Forbidden`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}};const fp=Symbol.for(`effect/Schema/ParseErrorTypeId`);var pp=class extends Di(`ParseError`){[fp]=fp;get message(){return this.toString()}toString(){return Xp.formatIssueSync(this.issue)}toJSON(){return{_id:`ParseError`,message:this.toString()}}[s](){return this.toJSON()}};const mp=e=>new pp({issue:e}),U=b,hp=y,gp=n,_p=o,vp=Ie,yp=x(2,(e,t)=>vp(e)?Ge(e,{onLeft:y,onRight:t}):D(e,t)),bp=x(2,(e,t)=>vp(e)?It(e,t):E(e,t)),xp=x(2,(e,t)=>vp(e)?Je(e,t):bn(e,t)),Sp=x(2,(e,t)=>vp(e)?le(e,{onLeft:t.onFailure,onRight:t.onSuccess}):gn(e,t)),Cp=x(2,(e,t)=>vp(e)?Ge(e,{onLeft:t,onRight:b}):vr(e,t)),wp=(e,t)=>t===void 0||Vt(t)?e:e===void 0?t:{...e,...t},Tp=(e,t,n)=>{let r=W(e,t);return(e,t)=>r(e,wp(n,t))},Ep=(e,t,n)=>{let r=Tp(e,t,n);return(e,t)=>re(r(e,t),mp)},Dp=(e,t,n)=>{let r=Tp(e,t,n);return(e,t)=>be(r(e,t))},Op=(e,t,n)=>{let r=W(e,t);return(e,t)=>r(e,{...wp(n,t),isEffectAllowed:!0})},kp=(e,t)=>Ep(e.ast,!0,t),Ap=(e,t)=>Dp(e.ast,!0,t),jp=(e,t)=>Op(e.ast,!0,t),Mp=(e,t)=>Op(e.ast,!1,t),Np=kp,Pp=(e,t)=>Ep(F(e.ast),!0,t),Fp=(e,t)=>{let n=W(F(e.ast),!0);return(e,r)=>te(n(e,{exact:!0,...wp(t,r)}))},Ip=st(Symbol.for(`effect/ParseResult/decodeMemoMap`),()=>new WeakMap),Lp=st(Symbol.for(`effect/ParseResult/encodeMemoMap`),()=>new WeakMap),W=(e,t)=>{let n=t?Ip:Lp,r=n.get(e);if(r)return r;let i=Bp(e,t),a=Ro(e),o=bt(a)?(e,t)=>i(e,wp(t,a.value)):i,s=zo(e),c=t&&bt(s)?(t,n)=>Gp(Cp(o(t,n),s.value),e,t,n):o;return n.set(e,c),c},Rp=e=>f(Fo(e)),zp=e=>f(Io(e)),Bp=(n,r)=>{switch(n._tag){case`Refinement`:if(r){let e=W(n.from,!0);return(t,r)=>{r??=Ns;let i=r?.errors===`all`,a=yp(Cp(e(t,r),e=>{let a=new lp(n,t,`From`,e);return i&&Ho(n)&&am(e)?_(n.filter(t,r,n),{onNone:()=>y(a),onSome:e=>y(new V(n,t,[a,new lp(n,t,`Predicate`,e)]))}):y(a)}),e=>_(n.filter(e,r,n),{onNone:()=>b(e),onSome:e=>y(new lp(n,t,`Predicate`,e))}));return Gp(a,n,t,r)}}else{let e=W(F(n),!0),t=W(Wp(n.from),!1);return(r,i)=>Gp(yp(e(r,i),e=>t(e,i)),n,r,i)}case`Transformation`:{let e=Jp(n.transformation,r),t=r?W(n.from,!0):W(n.to,!1),i=r?W(n.to,!0):W(n.from,!1);return(a,o)=>Gp(yp(xp(t(a,o),e=>new up(n,a,r?`Encoded`:`Type`,e)),t=>yp(xp(e(t,o??Ns,n,a),e=>new up(n,a,`Transformation`,e)),e=>xp(i(e,o),e=>new up(n,a,r?`Type`:`Encoded`,e)))),n,a,o)}case`Declaration`:{let e=r?n.decodeUnknown(...n.typeParameters):n.encodeUnknown(...n.typeParameters);return(t,r)=>Gp(e(t,r??Ns,n),n,t,r)}case`Literal`:return Vp(n,e=>e===n.literal);case`UniqueSymbol`:return Vp(n,e=>e===n.symbol);case`UndefinedKeyword`:return Vp(n,Ht);case`NeverKeyword`:return Vp(n,e);case`UnknownKeyword`:case`AnyKeyword`:case`VoidKeyword`:return b;case`StringKeyword`:return Vp(n,Qe);case`NumberKeyword`:return Vp(n,Vt);case`BooleanKeyword`:return Vp(n,Ke);case`BigIntKeyword`:return Vp(n,oe);case`SymbolKeyword`:return Vp(n,At);case`ObjectKeyword`:return Vp(n,Dt);case`Enums`:return Vp(n,e=>n.enums.some(([t,n])=>n===e));case`TemplateLiteral`:{let e=Ks(n);return Vp(n,t=>Qe(t)&&e.test(t))}case`TupleType`:{let e=n.elements.map(e=>W(e.type,r)),i=n.rest.map(e=>W(e.type,r)),a=n.elements.filter(e=>!e.isOptional);n.rest.length>0&&(a=a.concat(n.rest.slice(1)));let o=a.length,s=n.elements.length>0?n.elements.map((e,t)=>t).join(` | `):`never`,c=Rp(n),l=zp(n);return(r,u)=>{if(!Xe(r))return y(new H(n,r));let d=u?.errors===`all`,f=[],p=0,m=[],h=r.length;for(let e=h;e<=o-1;e++){let t=new B(e,r,new cp(a[e-h]));if(d){f.push([p++,t]);continue}else return y(new V(n,r,t,m))}if(n.rest.length===0)for(let e=n.elements.length;e<=h-1;e++){let t=new B(e,r,new sp(r[e],`is unexpected, expected: ${s}`));if(d){f.push([p++,t]);continue}else return y(new V(n,r,t,m))}let g=0,ee;for(;g<e.length;g++)if(h<g+1){if(n.elements[g].isOptional)continue}else{let t=e[g],i=t(r[g],u);if(vp(i)){if(He(i)){let e=new B(g,r,i.left);if(d){f.push([p++,e]);continue}else return y(new V(n,r,e,qp(m)))}m.push([p++,i.right])}else{let e=p++,t=g;ee||=[],ee.push(({es:a,output:o})=>D(xr(i),i=>{if(He(i)){let s=new B(t,r,i.left);return d?(a.push([e,s]),A):y(new V(n,r,s,qp(o)))}return o.push([e,i.right]),A}))}}if(t(i)){let[e,...t]=i;for(;g<h-t.length;g++){let t=e(r[g],u);if(vp(t))if(He(t)){let e=new B(g,r,t.left);if(d){f.push([p++,e]);continue}else return y(new V(n,r,e,qp(m)))}else m.push([p++,t.right]);else{let e=p++,i=g;ee||=[],ee.push(({es:a,output:o})=>D(xr(t),t=>{if(He(t)){let s=new B(i,r,t.left);return d?(a.push([e,s]),A):y(new V(n,r,s,qp(o)))}else return o.push([e,t.right]),A}))}}for(let e=0;e<t.length;e++){let i=g+e;if(!(h<i+1)){let a=t[e](r[i],u);if(vp(a)){if(He(a)){let e=new B(i,r,a.left);if(d){f.push([p++,e]);continue}else return y(new V(n,r,e,qp(m)))}m.push([p++,a.right])}else{let e=p++;ee||=[],ee.push(({es:t,output:o})=>D(xr(a),a=>{if(He(a)){let s=new B(i,r,a.left);return d?(t.push([e,s]),A):y(new V(n,r,s,qp(o)))}return o.push([e,a.right]),A}))}}}}let _=({es:e,output:t})=>Te(e)?y(new V(n,r,qp(e),qp(t))):b(qp(t));if(ee&&ee.length>0){let e=ee;return j(()=>{let t={es:tn(f),output:tn(m)};return D(sn(e,e=>e(t),{concurrency:c,batching:l,discard:!0}),()=>_(t))})}return _({output:m,es:f})}}case`TypeLiteral`:{if(n.propertySignatures.length===0&&n.indexSignatures.length===0)return Vp(n,ut);let e=[],t={},i=[];for(let a of n.propertySignatures)e.push([W(a.type,r),a]),t[a.name]=null,i.push(a.name);let a=n.indexSignatures.map(e=>[W(e.parameter,r),W(e.type,r),e.parameter]),o=Ts.make(n.indexSignatures.map(e=>e.parameter).concat(i.map(e=>At(e)?new Xo(e):new Jo(e)))),s=W(o,r),c=Rp(n),l=zp(n);return(r,u)=>{if(!Rt(r))return y(new H(n,r));let d=u?.errors===`all`,f=[],p=0,m=u?.onExcessProperty===`error`,h=u?.onExcessProperty===`preserve`,g={},ee;if(m||h){ee=Reflect.ownKeys(r);for(let e of ee){let t=s(e,u);if(vp(t)&&He(t))if(m){let t=new B(e,r,new sp(r[e],`is unexpected, expected: ${String(o)}`));if(d){f.push([p++,t]);continue}else return y(new V(n,r,t,g))}else g[e]=r[e]}}let _,ne=u?.exact===!0;for(let t=0;t<e.length;t++){let i=e[t][1],a=i.name,o=Object.prototype.hasOwnProperty.call(r,a);if(!o){if(i.isOptional)continue;if(ne){let e=new B(a,r,new cp(i));if(d){f.push([p++,e]);continue}else return y(new V(n,r,e,g))}}let s=e[t][0],c=s(r[a],u);if(vp(c)){if(He(c)){let e=new B(a,r,o?c.left:new cp(i));if(d){f.push([p++,e]);continue}else return y(new V(n,r,e,g))}g[a]=c.right}else{let e=p++,t=a;_||=[],_.push(({es:a,output:s})=>D(xr(c),c=>{if(He(c)){let l=new B(t,r,o?c.left:new cp(i));return d?(a.push([e,l]),A):y(new V(n,r,l,s))}return s[t]=c.right,A}))}}for(let e=0;e<a.length;e++){let i=a[e],o=i[0],s=i[1],c=Da(r,i[2]);for(let e of c){let i=o(e,u);if(vp(i)&&te(i)){let i=s(r[e],u);if(vp(i))if(He(i)){let t=new B(e,r,i.left);if(d){f.push([p++,t]);continue}else return y(new V(n,r,t,g))}else Object.prototype.hasOwnProperty.call(t,e)||(g[e]=i.right);else{let a=p++,o=e;_||=[],_.push(({es:s,output:c})=>D(xr(i),i=>{if(He(i)){let e=new B(o,r,i.left);return d?(s.push([a,e]),A):y(new V(n,r,e,c))}else return Object.prototype.hasOwnProperty.call(t,e)||(c[e]=i.right),A}))}}}}let re=({es:e,output:t})=>{if(Te(e))return y(new V(n,r,qp(e),t));if(u?.propertyOrder===`original`){let e=ee||Reflect.ownKeys(r);for(let t of i)e.indexOf(t)===-1&&e.push(t);let n={};for(let r of e)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return b(n)}return b(t)};if(_&&_.length>0){let e=_;return j(()=>{let t={es:tn(f),output:Object.assign({},g)};return D(sn(e,e=>e(t),{concurrency:c,batching:l,discard:!0}),()=>re(t))})}return re({es:f,output:g})}}case`Union`:{let e=Up(n.types,r),t=Reflect.ownKeys(e.keys),i=t.length,a=n.types.length,o=new Map;for(let e=0;e<a;e++)o.set(n.types[e],W(n.types[e],r));let s=Rp(n)??1,c=zp(n);return(r,l)=>{let u=[],d=0,f=[];if(i>0)if(gt(r))for(let n=0;n<i;n++){let i=t[n],o=e.keys[i].buckets;if(Object.prototype.hasOwnProperty.call(r,i)){let t=String(r[i]);if(Object.prototype.hasOwnProperty.call(o,t))f=f.concat(o[t]);else{let{candidates:t,literals:n}=e.keys[i],o=Ts.make(n),s=t.length===a?new _s([new P(i,o,!1,!0)],[]):Ts.make(t);u.push([d++,new V(s,r,new B(i,r,new H(o,r[i])))])}}else{let{candidates:t,literals:n}=e.keys[i],o=new P(i,Ts.make(n),!1,!0),s=t.length===a?new _s([o],[]):Ts.make(t);u.push([d++,new V(s,r,new B(i,r,new cp(o)))])}}else{let t=e.candidates.length===a?n:Ts.make(e.candidates);u.push([d++,new H(t,r)])}e.otherwise.length>0&&(f=f.concat(e.otherwise));let p;for(let e=0;e<f.length;e++){let t=f[e],n=o.get(t)(r,l);if(vp(n)&&(!p||p.length===0)){if(te(n))return n;u.push([d++,n.left])}else{let e=d++;p||=[],p.push(t=>j(()=>`finalResult`in t?A:D(xr(n),n=>(te(n)?t.finalResult=n:t.es.push([e,n.left]),A))))}}let m=e=>Te(e)?e.length===1&&e[0][1]._tag===`Type`?y(e[0][1]):y(new V(n,r,qp(e))):y(new H(n,r));if(p&&p.length>0){let e=p;return j(()=>{let t={es:tn(u)};return D(sn(e,e=>e(t),{concurrency:s,batching:c,discard:!0}),()=>`finalResult`in t?t.finalResult:m(t.es))})}return m(u)}}case`Suspend`:{let e=Oa(()=>W(n.f(),r));return(t,n)=>e()(t,n)}}},Vp=(e,t)=>n=>t(n)?b(n):y(new H(e,n)),Hp=(e,t)=>{switch(e._tag){case`Declaration`:{let n=Bo(e);if(bt(n))return Hp(n.value,t);break}case`TypeLiteral`:{let n=[];for(let r=0;r<e.propertySignatures.length;r++){let i=e.propertySignatures[r],a=t?ec(i.type):F(i.type);Yo(a)&&!i.isOptional&&n.push([i.name,a])}return n}case`TupleType`:{let n=[];for(let r=0;r<e.elements.length;r++){let i=e.elements[r],a=t?ec(i.type):F(i.type);Yo(a)&&!i.isOptional&&n.push([r,a])}return n}case`Refinement`:return Hp(e.from,t);case`Suspend`:return Hp(e.f(),t);case`Transformation`:return Hp(t?e.from:e.to,t)}return[]},Up=(e,t)=>{let n={},r=[],i=[];for(let a=0;a<e.length;a++){let o=e[a],s=Hp(o,t);if(s.length>0){i.push(o);for(let e=0;e<s.length;e++){let[t,r]=s[e],i=String(r.literal);n[t]=n[t]||{buckets:{},literals:[],candidates:[]};let a=n[t].buckets;if(Object.prototype.hasOwnProperty.call(a,i)){if(e<s.length-1)continue;a[i].push(o),n[t].literals.push(r),n[t].candidates.push(o)}else{a[i]=[o],n[t].literals.push(r),n[t].candidates.push(o);break}}}else r.push(o)}return{keys:n,otherwise:r,candidates:i}},Wp=e=>Ms(e)?Wp(e.from):e,Gp=(e,t,n,r)=>{if(r?.isEffectAllowed===!0||vp(e))return e;let i=new Sr,a=Ar(e,{scheduler:i});i.flush();let o=a.unsafePoll();if(o){if(di(o))return b(o.value);let e=o.cause;return ri(e)?y(e.error):y(new dp(t,n,ti(e)))}return y(new dp(t,n,`cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work`))},Kp=([e],[t])=>e>t?1:e<t?-1:0;function qp(e){return e.sort(Kp).map(e=>e[1])}const Jp=(e,t)=>{switch(e._tag){case`FinalTransformation`:return t?e.decode:e.encode;case`ComposeTransformation`:return b;case`TypeLiteralTransformation`:return n=>{let r=b(n);for(let n of e.propertySignatureTransformations){let[e,i]=t?[n.from,n.to]:[n.to,n.from],a=t?n.decode:n.encode;r=bp(r,t=>{let n=a(Object.prototype.hasOwnProperty.call(t,e)?w(t[e]):v());return delete t[e],bt(n)&&(t[i]=n.value),t})}return r}}},Yp=(e,t=[])=>({value:e,forest:t}),Xp={formatIssue:e=>bp(_m(e),Zp),formatIssueSync:e=>{let t=Xp.formatIssue(e);return vp(t)?ze(t):Sn(t)},formatError:e=>Xp.formatIssue(e.issue),formatErrorSync:e=>Xp.formatIssueSync(e.issue)},Zp=e=>e.value+Qp(`
|
|
2
|
-
`,e.forest),Qp=(e,t)=>{let n=``,r=t.length,i;for(let a=0;a<r;a++){i=t[a];let o=a===r-1;n+=e+(o?`└`:`├`)+`─ `+i.value,n+=Qp(e+(r>1&&!o?`│ `:` `),i.forest)}return n},$p=e=>{switch(e){case`Encoded`:return`Encoded side transformation failure`;case`Transformation`:return`Transformation process failure`;case`Type`:return`Type side transformation failure`}},em=e=>{switch(e){case`From`:return`From side refinement failure`;case`Predicate`:return`Predicate refinement failure`}},tm=e=>`ast`in e?w(e.ast):v(),nm=b(void 0),rm=e=>tm(e).pipe(Zt(ko),_({onNone:()=>nm,onSome:t=>{let n=t(e);return Qe(n)?b({message:n,override:!1}):Tn(n)?E(n,e=>({message:e,override:!1})):Qe(n.message)?b({message:n.message,override:n.override}):E(n.message,e=>({message:e,override:n.override}))}})),im=e=>t=>t._tag===e,am=im(`Composite`),om=im(`Refinement`),sm=im(`Transformation`),cm=e=>yp(rm(e),t=>t===void 0?nm:!t.override&&(am(e)||om(e)&&e.kind===`From`||sm(e)&&e.kind!==`Transformation`)?sm(e)||om(e)?cm(e.issue):nm:b(t.message)),lm=e=>tm(e).pipe(Zt(Lo),ke(t=>t(e)),f);function um(e){return Po(e).pipe(pe(()=>jo(e)),pe(()=>Mo(e)),pe(()=>No(e)),Ne(()=>`{ ${e.from} | filter }`))}function dm(e){return e.message===void 0?`Expected ${Ms(e.ast)?um(e.ast):String(e.ast)}, actual ${l(e.actual)}`:e.message}const fm=e=>bp(cm(e),t=>t??lm(e)??dm(e)),pm=e=>lm(e)??String(e.ast),mm=e=>e.message??`is forbidden`,hm=e=>e.message??`is unexpected`,gm=e=>{let t=Ao(e.ast);if(bt(t)){let e=t.value();return Qe(e)?b(e):e}return b(e.message??`is missing`)},_m=e=>{switch(e._tag){case`Type`:return bp(fm(e),Yp);case`Forbidden`:return b(Yp(pm(e),[Yp(mm(e))]));case`Unexpected`:return b(Yp(hm(e)));case`Missing`:return bp(gm(e),Yp);case`Transformation`:return yp(cm(e),t=>t===void 0?bp(_m(e.issue),t=>Yp(pm(e),[Yp($p(e.kind),[t])])):b(Yp(t)));case`Refinement`:return yp(cm(e),t=>t===void 0?bp(_m(e.issue),t=>Yp(pm(e),[Yp(em(e.kind),[t])])):b(Yp(t)));case`Pointer`:return bp(_m(e.issue),t=>Yp(Ma(e.path),[t]));case`Composite`:return yp(cm(e),t=>{if(t!==void 0)return b(Yp(t));let n=pm(e);return ka(e.issues)?bp(sn(e.issues,_m),e=>Yp(n,e)):bp(_m(e.issues),e=>Yp(n,[e]))})}},vm=x(e=>Dt(e[0]),(e,...t)=>{let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}),ym=x(e=>Dt(e[0]),(e,...t)=>{let n={...e};for(let e of t)delete n[e];return n}),bm=Symbol.for(`effect/Schema`);function G(e){return class{[bm]=xm;static ast=e;static annotations(e){return G(wm(this.ast,e))}static pipe(){return De(this,arguments)}static toString(){return String(e)}static Type;static Encoded;static Context;static[bm]=xm}}const xm={_A:e=>e,_I:e=>e,_R:e=>e},Sm={typeConstructor:io,schemaId:oo,message:so,missingMessage:co,identifier:lo,title:uo,description:po,examples:mo,default:ho,documentation:bo,jsonSchema:go,arbitrary:_o,pretty:vo,equivalence:yo,concurrency:xo,batching:So,parseIssueTitle:Co,parseOptions:wo,decodingFallback:To},Cm=e=>{if(!e)return{};let t={...e};for(let n in Sm)if(n in e){let r=Sm[n];t[r]=e[n],delete t[n]}return t},wm=(e,t)=>Hs(e,Cm(t)),Tm=e=>String(e.ast),Em=e=>G(ec(e.ast)),Dm=e=>G(F(e.ast)),Om=(e,t)=>{let n=jp(e,t);return(e,t)=>xp(n(e,t),mp)},km=e=>Nt(e,bm)&&Dt(e[bm]);function Am(e){return Ds(e)?Ts.make(Es(e,e=>new Jo(e))):new Jo(e[0])}function jm(e,t=Am(e)){return class extends G(t){static annotations(e){return jm(this.literals,wm(this.ast,e))}static literals=[...e]}}function Mm(...e){return t(e)?jm(e):Bm}const Nm=(e,t,n)=>Fm(e,new Ko(e.map(e=>e.ast),(...e)=>t.decode(...e.map(G)),(...e)=>t.encode(...e.map(G)),Cm(n))),Pm=(e,t)=>{let n=()=>(t,n,r)=>e(t)?U(t):hp(new H(r,t));return Fm([],new Ko([],n,n,Cm(t)))};function Fm(e,t){return class extends G(t){static annotations(e){return Fm(this.typeParameters,wm(this.ast,e))}static typeParameters=[...e]}}const Im=function(){if(Array.isArray(arguments[0])){let e=arguments[0],t=arguments[1],n=arguments[2];return Nm(e,t,n)}let e=arguments[0],t=arguments[1];return Pm(e,t)},Lm=Symbol.for(`effect/SchemaId/InstanceOf`),Rm=(e,t)=>Im(t=>t instanceof e,{title:e.name,description:`an instance of ${e.name}`,pretty:()=>String,schemaId:Lm,[Lm]:{constructor:e},...t});var zm=class extends G(Zo){},Bm=class extends G(Qo){},Vm=class extends G($o){},Hm=class extends G(ss){},Um=class extends G(cs){},K=class extends G(ts){},q=class extends G(rs){},Wm=class extends G(as){};const Gm=e=>Ts.make(e.map(e=>e.ast));function Km(e,t=Gm(e)){return class extends G(t){static annotations(e){return Km(this.members,wm(this.ast,e))}static members=[...e]}}function qm(...e){return Ds(e)?Km(e):t(e)?e[0]:Bm}const Jm=e=>qm(e,zm),Ym=e=>new Xm(new ds(e.ast,!1),e);var Xm=class e{ast;from;[bm];_Token;constructor(e,t){this.ast=e,this.from=t}annotations(t){return new e(new ds(this.ast.type,this.ast.isOptional,{...this.ast.annotations,...Cm(t)}),this.from)}toString(){return`${this.ast.type}${this.ast.isOptional?`?`:``}`}};const Zm=(e,t)=>new ps(e.map(e=>km(e)?new ds(e.ast,!1):e.ast),t.map(e=>km(e)?new us(e.ast):e.ast),!0);function Qm(e,t,n=Zm(e,t)){return class extends G(n){static annotations(e){return Qm(this.elements,this.rest,wm(this.ast,e))}static elements=[...e];static rest=[...t]}}function $m(...e){return Array.isArray(e[0])?Qm(e[0],e.slice(1)):Qm(e,[])}function eh(e,t){return class extends Qm([],[e],t){static annotations(e){return eh(this.value,wm(this.ast,e))}static value=e}}const th=e=>eh(e),nh=e=>e?`"?:"`:`":"`;var rh=class extends ds{isReadonly;defaultValue;_tag=`PropertySignatureDeclaration`;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.defaultValue=i}toString(){let e=nh(this.isOptional),t=String(this.type);return`PropertySignature<${e}, ${t}, never, ${e}, ${t}>`}};(class extends ds{isReadonly;fromKey;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.fromKey=i}});var ih=class extends ds{isReadonly;defaultValue;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.defaultValue=i}};const ah=e=>e===void 0?`never`:Qe(e)?JSON.stringify(e):String(e);var oh=class{from;to;decode;encode;_tag=`PropertySignatureTransformation`;constructor(e,t,n,r){this.from=e,this.to=t,this.decode=n,this.encode=r}toString(){return`PropertySignature<${nh(this.to.isOptional)}, ${this.to.type}, ${ah(this.from.fromKey)}, ${nh(this.from.isOptional)}, ${this.from.type}>`}};const sh=(e,t)=>{switch(e._tag){case`PropertySignatureDeclaration`:return new rh(e.type,e.isOptional,e.isReadonly,{...e.annotations,...t},e.defaultValue);case`PropertySignatureTransformation`:return new oh(e.from,new ih(e.to.type,e.to.isOptional,e.to.isReadonly,{...e.to.annotations,...t},e.to.defaultValue),e.decode,e.encode)}},ch=Symbol.for(`effect/PropertySignature`),lh=e=>Nt(e,ch);var uh=class e{ast;[bm];[ch]=null;_TypeToken;_Key;_EncodedToken;_HasDefault;constructor(e){this.ast=e}pipe(){return De(this,arguments)}annotations(t){return new e(sh(this.ast,Cm(t)))}toString(){return String(this.ast)}};const dh=e=>new uh(e);var fh=class e extends uh{from;constructor(e,t){super(e),this.from=t}annotations(t){return new e(sh(this.ast,Cm(t)),this.from)}};const ph=e=>new fh(new rh(e.ast,!1,!0,{},void 0),e),mh=x(2,(e,t)=>{let n=e.ast;switch(n._tag){case`PropertySignatureDeclaration`:return dh(new rh(n.type,n.isOptional,n.isReadonly,n.annotations,t));case`PropertySignatureTransformation`:return dh(new oh(n.from,new ih(n.to.type,n.to.isOptional,n.to.isReadonly,n.to.annotations,t),n.decode,n.encode))}}),hh=e=>new fh(new rh(e.ast===Zo||e.ast===Qo?Zo:Jm(e).ast,!0,!0,{},void 0),e),gh=Js([co]),_h=(e,n)=>{let r=Reflect.ownKeys(e),i=[];if(r.length>0){let a=[],o=[],s=[];for(let t=0;t<r.length;t++){let n=r[t],c=e[n];if(lh(c)){let e=c.ast;switch(e._tag){case`PropertySignatureDeclaration`:{let t=e.type,r=e.isOptional,s=e.annotations;a.push(new P(n,t,r,!0,gh(e))),o.push(new P(n,F(t),r,!0,s)),i.push(new P(n,t,r,!0,s));break}case`PropertySignatureTransformation`:{let t=e.from.fromKey??n;a.push(new P(t,e.from.type,e.from.isOptional,!0,e.from.annotations)),o.push(new P(n,e.to.type,e.to.isOptional,!0,e.to.annotations)),s.push(new zs(t,n,e.decode,e.encode));break}}}else a.push(new P(n,c.ast,!1,!0)),o.push(new P(n,F(c.ast),!1,!0)),i.push(new P(n,c.ast,!1,!0))}if(t(s)){let e=[],t=[];for(let r of n){let{indexSignatures:n,propertySignatures:i}=qs(r.key.ast,r.value.ast);i.forEach(e=>{a.push(e),o.push(new P(e.name,F(e.type),e.isOptional,e.isReadonly,e.annotations))}),n.forEach(n=>{e.push(n),t.push(new gs(n.parameter,F(n.type),n.isReadonly))})}return new Ps(new _s(a,e,{[fo]:`Struct (Encoded side)`}),new _s(o,t,{[fo]:`Struct (Type side)`}),new Bs(s))}}let a=[];for(let e of n){let{indexSignatures:t,propertySignatures:n}=qs(e.key.ast,e.value.ast);n.forEach(e=>i.push(e)),t.forEach(e=>a.push(e))}return new _s(i,a)},vh=(e,t)=>{let n=Reflect.ownKeys(e);for(let r of n){let n=e[r];if(t[r]===void 0&&lh(n)){let e=n.ast,i=e._tag===`PropertySignatureDeclaration`?e.defaultValue:e.to.defaultValue;i!==void 0&&(t[r]=i())}}return t};function yh(e,t,n=_h(e,t)){return class extends G(n){static annotations(e){return yh(this.fields,this.records,wm(this.ast,e))}static fields={...e};static records=[...t];static make=(t,n)=>{let r=vh(e,{...t});return I_(n)?r:Pp(this)(r)};static pick(...t){return J(vm(e,...t))}static omit(...t){return J(ym(e,...t))}}}function J(e,...t){return yh(e,t)}const bh=e=>Mm(e).pipe(ph,mh(()=>e)),xh=(e,t)=>J({_tag:bh(e),...t});function Sh(e,t,n){return class extends yh({},[{key:e,value:t}],n){static annotations(n){return Sh(e,t,wm(this.ast,n))}static key=e;static value=t}}const Ch=e=>Sh(e.key,e.value);function wh(e,t){return class extends G(t){static annotations(e){return wh(this.from,wm(this.ast,e))}static make=(e,t)=>I_(t)?e:Pp(this)(e);static from=e}}const Th=(e,t)=>n=>{let r=_(Oo(n.ast),{onNone:()=>[e],onSome:t=>[...t,e]});return wh(n,Hs(n.ast,Cm({[ao]:r,...t})))},Eh=(e,t,n)=>{if(bs(e)&&bs(t)){let r=[...e.propertySignatures];for(let e of t.propertySignatures){let t=e.name,i=r.findIndex(e=>e.name===t);if(i===-1)r.push(e);else{let{isOptional:a,type:o}=r[i];r[i]=new P(t,kh(o,e.type,n.concat(t)),a,!0)}}return new _s(r,e.indexSignatures.concat(t.indexSignatures))}throw Error(Fa(e,t,n))},Dh=Ys([lo]),Oh=(e,t)=>t.map(t=>new js(t,e.filter,Dh(e))),kh=(e,t,n)=>Ts.make(jh([e],[t],n)),Ah=e=>Os(e)?e.types:[e],jh=(e,t,n)=>Ve(e,e=>Ve(t,t=>{switch(t._tag){case`Literal`:if(Qe(t.literal)&&ns(e)||Vt(t.literal)&&is(e)||Ke(t.literal)&&os(e))return[t];break;case`StringKeyword`:if(t===ts){if(ns(e)||Yo(e)&&Qe(e.literal))return[e];if(Ms(e))return Oh(e,jh(Ah(e.from),[t],n))}else if(e===ts)return[t];break;case`NumberKeyword`:if(t===rs){if(is(e)||Yo(e)&&Vt(e.literal))return[e];if(Ms(e))return Oh(e,jh(Ah(e.from),[t],n))}else if(e===rs)return[t];break;case`BooleanKeyword`:if(t===as){if(os(e)||Yo(e)&&Ke(e.literal))return[e];if(Ms(e))return Oh(e,jh(Ah(e.from),[t],n))}else if(e===as)return[t];break;case`Union`:return jh(Ah(e),t.types,n);case`Suspend`:return[new As(()=>kh(e,t.f(),n))];case`Refinement`:return Oh(t,jh(Ah(e),Ah(t.from),n));case`TypeLiteral`:switch(e._tag){case`Union`:return jh(e.types,[t],n);case`Suspend`:return[new As(()=>kh(e.f(),t,n))];case`Refinement`:return Oh(e,jh(Ah(e.from),[t],n));case`TypeLiteral`:return[Eh(e,t,n)];case`Transformation`:{let r=e.transformation,i=Eh(e.from,t,n),a=Eh(e.to,F(t),n);switch(r._tag){case`TypeLiteralTransformation`:return[new Ps(i,a,new Bs(r.propertySignatureTransformations))];case`ComposeTransformation`:return[new Ps(i,a,Rs)];case`FinalTransformation`:return[new Ps(i,a,new Is((e,t,n,i)=>bp(r.decode(e,t,n,i),t=>({...e,...t})),(e,t,n,i)=>bp(r.encode(e,t,n,i),t=>({...e,...t}))))]}}}break;case`Transformation`:if(Fs(e)){if(Vs(t.transformation)&&Vs(e.transformation))return[new Ps(Eh(e.from,t.from,n),Eh(e.to,t.to,n),new Bs(t.transformation.propertySignatureTransformations.concat(e.transformation.propertySignatureTransformations)))]}else return jh([t],[e],n);break}throw Error(Fa(e,t,n))})),Mh=x(2,(e,t)=>G(kh(e.ast,t.ast,[]))),Nh=e=>G(new As(()=>e().ast)),Ph=Symbol.for(`effect/SchemaId/Refine`);function Fh(e,t,n){return class extends G(n){static annotations(e){return Fh(this.from,this.filter,wm(this.ast,e))}static[Ph]=e;static from=e;static filter=t;static make=(e,t)=>I_(t)?e:Pp(this)(e)}}const Ih=(e,n,r)=>{if(Ke(e))return e?v():w(new H(n,r));if(Qe(e))return w(new H(n,r,e));if(e!==void 0){if(`_tag`in e)return w(e);let i=new H(n,r,e.message);return w(t(e.path)?new B(e.path,r,i):i)}return v()},Lh=(e,n,r)=>{if(Aa(e))return Ih(e,n,r);if(t(e)){let i=Fe(e,e=>Ih(e,n,r));if(t(i))return w(i.length===1?i[0]:new V(n,r,i))}return v()};function Y(e,t){return n=>{function r(t,n,r){return Lh(e(t,n,r),r,t)}return Fh(n,r,new js(n.ast,r,Cm(t)))}}function Rh(e,t,n){return class extends G(n){static annotations(e){return Rh(this.from,this.to,wm(this.ast,e))}static from=e;static to=t}}const X=x(e=>km(e[0])&&km(e[1]),(e,t,n)=>Rh(e,t,new Ps(e.ast,t.ast,new Is(n.decode,n.encode)))),Z=x(e=>km(e[0])&&km(e[1]),(e,t,n)=>X(e,t,{strict:!0,decode:(e,t,r,i)=>U(n.decode(e,i)),encode:(e,t,r,i)=>U(n.encode(e,i))})),zh=x(2,(e,t)=>e.annotations(t)),Bh=Symbol.for(`effect/SchemaId/Trimmed`),Vh=e=>t=>t.pipe(Y(e=>e===e.trim(),{schemaId:Bh,title:`trimmed`,description:`a string with no leading or trailing whitespace`,jsonSchema:{pattern:`^\\S[\\s\\S]*\\S$|^\\S$|^$`},...e})),Hh=to,Uh=(e,t)=>n=>n.pipe(Y(t=>t.length>=e,{schemaId:Hh,title:`minLength(${e})`,description:`a string at least ${e} character(s) long`,jsonSchema:{minLength:e},...t})),Wh=no,Gh=(e,t)=>n=>{let r=Dt(e)?Math.max(0,Math.floor(e.min)):Math.max(0,Math.floor(e)),i=Dt(e)?Math.max(r,Math.floor(e.max)):r;return r===i?n.pipe(Y(e=>e.length===r,{schemaId:Wh,title:`length(${r})`,description:r===1?`a single character`:`a string ${r} character(s) long`,jsonSchema:{minLength:r,maxLength:r},...t})):n.pipe(Y(e=>e.length>=r&&e.length<=i,{schemaId:Wh,title:`length({ min: ${r}, max: ${i})`,description:`a string at least ${r} character(s) and at most ${i} character(s) long`,jsonSchema:{minLength:r,maxLength:i},...t}))},Kh=Symbol.for(`effect/SchemaId/Pattern`),qh=(e,t)=>n=>{let r=e.source;return n.pipe(Y(t=>(e.lastIndex=0,e.test(t)),{schemaId:Kh,[Kh]:{regex:e},description:`a string matching the pattern ${r}`,jsonSchema:{pattern:r},...t}))},Jh=Symbol.for(`effect/SchemaId/Lowercased`),Yh=e=>t=>t.pipe(Y(e=>e===e.toLowerCase(),{schemaId:Jh,title:`lowercased`,description:`a lowercase string`,jsonSchema:{pattern:`^[^A-Z]*$`},...e}));var Xh=class extends K.pipe(Yh({identifier:`Lowercased`})){};const Zh=Symbol.for(`effect/SchemaId/Uppercased`),Qh=e=>t=>t.pipe(Y(e=>e===e.toUpperCase(),{schemaId:Zh,title:`uppercased`,description:`an uppercase string`,jsonSchema:{pattern:`^[^a-z]*$`},...e}));var $h=class extends K.pipe(Qh({identifier:`Uppercased`})){};const eg=Symbol.for(`effect/SchemaId/Capitalized`),tg=e=>t=>t.pipe(Y(e=>e[0]?.toUpperCase()===e[0],{schemaId:eg,title:`capitalized`,description:`a capitalized string`,jsonSchema:{pattern:`^[^a-z]?.*$`},...e}));var ng=class extends K.pipe(tg({identifier:`Capitalized`})){};const rg=Symbol.for(`effect/SchemaId/Uncapitalized`),ig=e=>t=>t.pipe(Y(e=>e[0]?.toLowerCase()===e[0],{schemaId:rg,title:`uncapitalized`,description:`a uncapitalized string`,jsonSchema:{pattern:`^[^A-Z]?.*$`},...e}));var ag=class extends K.pipe(ig({identifier:`Uncapitalized`})){};K.pipe(Gh(1,{identifier:`Char`}));const og=e=>Uh(1,{title:`nonEmptyString`,description:`a non empty string`,...e});Z(K.annotations({description:`a string that will be converted to lowercase`}),Xh,{strict:!0,decode:e=>e.toLowerCase(),encode:S}).annotations({identifier:`Lowercase`}),Z(K.annotations({description:`a string that will be converted to uppercase`}),$h,{strict:!0,decode:e=>e.toUpperCase(),encode:S}).annotations({identifier:`Uppercase`}),Z(K.annotations({description:`a string that will be converted to a capitalized format`}),ng,{strict:!0,decode:e=>wa(e),encode:S}).annotations({identifier:`Capitalize`}),Z(K.annotations({description:`a string that will be converted to an uncapitalized format`}),ag,{strict:!0,decode:e=>Ta(e),encode:S}).annotations({identifier:`Uncapitalize`});var sg=class extends K.pipe(Vh({identifier:`Trimmed`})){},cg=class extends sg.pipe(og({identifier:`NonEmptyTrimmedString`})){};Z(K.annotations({description:`a string that will be trimmed`}),sg,{strict:!0,decode:e=>e.trim(),encode:S}).annotations({identifier:`Trim`});const lg=e=>e instanceof Error?e.message:String(e);K.pipe(og({identifier:`NonEmptyString`}));const ug=Symbol.for(`effect/SchemaId/UUID`),dg=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i;K.pipe(qh(dg,{schemaId:ug,identifier:`UUID`,jsonSchema:{format:`uuid`,pattern:dg.source},description:`a Universally Unique Identifier`,arbitrary:()=>e=>e.uuid()}));const fg=Symbol.for(`effect/SchemaId/ULID`);K.pipe(qh(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i,{schemaId:fg,identifier:`ULID`,description:`a Universally Unique Lexicographically Sortable Identifier`,arbitrary:()=>e=>e.ulid()}));var pg=class extends Rm(URL,{typeConstructor:{_tag:`URL`},identifier:`URLFromSelf`,arbitrary:()=>e=>e.webUrl().map(e=>new URL(e)),pretty:()=>e=>e.toString()}){};X(K.annotations({description:`a string to be decoded into a URL`}),pg,{strict:!0,decode:(e,t,n)=>gp({try:()=>new URL(e),catch:t=>new H(n,e,`Unable to decode ${JSON.stringify(e)} into a URL. ${lg(t)}`)}),encode:e=>U(e.toString())}).annotations({identifier:`URL`,pretty:()=>e=>e.toString()});const mg=Xa,hg=e=>t=>t.pipe(Y(Number.isFinite,{schemaId:mg,title:`finite`,description:`a finite number`,jsonSchema:{},...e})),gg=Wa,_g=(e,t)=>n=>n.pipe(Y(t=>t>e,{schemaId:gg,title:`greaterThan(${e})`,description:e===0?`a positive number`:`a number greater than ${e}`,jsonSchema:{exclusiveMinimum:e},...t})),vg=Ga,yg=(e,t)=>n=>n.pipe(Y(t=>t>=e,{schemaId:vg,title:`greaterThanOrEqualTo(${e})`,description:e===0?`a non-negative number`:`a number greater than or equal to ${e}`,jsonSchema:{minimum:e},...t})),bg=Ja,xg=e=>t=>t.pipe(Y(e=>Number.isSafeInteger(e),{schemaId:bg,title:`int`,description:`an integer`,jsonSchema:{type:`integer`},...e})),Sg=Ka,Cg=(e,t)=>n=>n.pipe(Y(t=>t<e,{schemaId:Sg,title:`lessThan(${e})`,description:e===0?`a negative number`:`a number less than ${e}`,jsonSchema:{exclusiveMaximum:e},...t})),wg=qa,Tg=(e,t)=>n=>n.pipe(Y(t=>t<=e,{schemaId:wg,title:`lessThanOrEqualTo(${e})`,description:e===0?`a non-positive number`:`a number less than or equal to ${e}`,jsonSchema:{maximum:e},...t})),Eg=Qa,Dg=(e,t,n)=>r=>r.pipe(Y(n=>n>=e&&n<=t,{schemaId:Eg,title:`between(${e}, ${t})`,description:`a number between ${e} and ${t}`,jsonSchema:{minimum:e,maximum:t},...n})),Og=Ya,kg=e=>t=>t.pipe(Y(e=>!Number.isNaN(e),{schemaId:Og,title:`nonNaN`,description:`a number excluding NaN`,...e})),Ag=e=>_g(0,{title:`positive`,...e}),jg=e=>Cg(0,{title:`negative`,...e}),Mg=e=>Tg(0,{title:`nonPositive`,...e}),Ng=e=>yg(0,{title:`nonNegative`,...e});function Pg(e){return X(e,q,{strict:!1,decode:(e,t,n)=>_p(mn(e),()=>new H(n,e,`Unable to decode ${JSON.stringify(e)} into a number`)),encode:e=>U(String(e))})}Pg(K.annotations({description:`a string to be decoded into a number`})).annotations({identifier:`NumberFromString`}),q.pipe(hg({identifier:`Finite`}));var Fg=class extends q.pipe(xg({identifier:`Int`})){};q.pipe(kg({identifier:`NonNaN`})),q.pipe(Ag({identifier:`Positive`})),q.pipe(jg({identifier:`Negative`})),q.pipe(Mg({identifier:`NonPositive`}));var Ig=class extends q.pipe(Ng({identifier:`NonNegative`})){};const Lg=Za;q.pipe(hg({schemaId:Lg,identifier:`JsonNumber`})),Z(Wm.annotations({description:`a boolean that will be negated`}),Wm,{strict:!0,decode:e=>cn(e),encode:e=>cn(e)});const Rg=(e,t)=>{let n=Symbol.keyFor(e);return n===void 0?hp(new H(t,e,`Unable to encode a unique symbol ${String(e)} into a string`)):U(n)},zg=e=>U(Symbol.for(e));X(K.annotations({description:`a string to be decoded into a globally shared symbol`}),Um,{strict:!1,decode:e=>zg(e),encode:(e,t,n)=>Rg(e,n)}).annotations({identifier:`Symbol`});const Bg=$a,Vg=(e,t)=>n=>n.pipe(Y(t=>t>=e,{schemaId:Bg,[Bg]:{min:e},title:`greaterThanOrEqualToBigInt(${e})`,description:e===0n?`a non-negative bigint`:`a bigint greater than or equal to ${e}n`,...t})),Hg=eo,Ug=(e,t,n)=>r=>r.pipe(Y(n=>n>=e&&n<=t,{schemaId:Hg,[Hg]:{min:e,max:t},title:`betweenBigInt(${e}, ${t})`,description:`a bigint between ${e}n and ${t}n`,...n})),Wg=e=>Vg(0n,{title:`nonNegativeBigInt`,...e});var Gg=class extends X(K.annotations({description:`a string to be decoded into a bigint`}),Hm,{strict:!0,decode:(e,t,n)=>_p(kc(e),()=>new H(n,e,`Unable to decode ${JSON.stringify(e)} into a bigint`)),encode:e=>U(String(e))}).annotations({identifier:`BigInt`}){};const Kg=Hm.pipe(Wg({identifier:`NonNegativeBigintFromSelf`}));X(q.annotations({description:`a number to be decoded into a bigint`}),Hm.pipe(Ug(BigInt(-(2**53-1)),BigInt(2**53-1))),{strict:!0,decode:(e,t,n)=>_p(Ac(e),()=>new H(n,e,`Unable to decode ${e} into a bigint`)),encode:(e,t,n)=>_p(Oc(e),()=>new H(n,e,`Unable to encode ${e}n into a number`))}).annotations({identifier:`BigIntFromNumber`});const qg=(e,t,n,r)=>Sp(e,{onFailure:e=>new V(n,r,e),onSuccess:t});var Jg=class extends Im(se,{typeConstructor:{_tag:`effect/Duration`},identifier:`DurationFromSelf`,pretty:()=>String,arbitrary:()=>e=>e.oneof(e.constant(Pt),e.bigInt({min:0n}).map(e=>we(e)),e.maxSafeNat().map(e=>Ye(e))),equivalence:()=>Be}){};X(Kg.annotations({description:`a bigint to be decoded into a Duration`}),Jg.pipe(Y(e=>qe(e),{description:`a finite duration`})),{strict:!0,decode:e=>U(we(e)),encode:(e,t,n)=>_(Bt(e),{onNone:()=>hp(new H(n,e,`Unable to encode ${e} into a bigint`)),onSome:e=>U(e)})}).annotations({identifier:`DurationFromNanos`});const Yg=Ig.pipe(xg()).annotations({identifier:`NonNegativeInt`});Z(Ig.annotations({description:`a non-negative number to be decoded into a Duration`}),Jg,{strict:!0,decode:e=>Ye(e),encode:e=>lt(e)}).annotations({identifier:`DurationFromMillis`});const Xg=xh(`Millis`,{millis:Yg}),Zg=xh(`Nanos`,{nanos:Gg}),Qg=xh(`Infinity`,{}),$g=Qg.make({}),e_=qm(Xg,Zg,Qg).annotations({identifier:`DurationValue`,description:`an JSON-compatible tagged union to be decoded into a Duration`}),t_=qm($m(Ym(Yg).annotations({title:`seconds`}),Ym(Yg).annotations({title:`nanos`})).annotations({identifier:`FiniteHRTime`}),$m(Mm(-1),Mm(0)).annotations({identifier:`InfiniteHRTime`})).annotations({identifier:`HRTime`,description:`a tuple of seconds and nanos to be decoded into a Duration`}),n_=e=>typeof e==`object`;Z(qm(e_,t_),Jg,{strict:!0,decode:e=>{if(n_(e))switch(e._tag){case`Millis`:return Ye(e.millis);case`Nanos`:return we(e.nanos);case`Infinity`:return Pt}let[t,n]=e;return t===-1?Pt:we(BigInt(t)*BigInt(1e9)+BigInt(n))},encode:e=>{switch(e.value._tag){case`Millis`:return Xg.make({millis:e.value.millis});case`Nanos`:return Zg.make({nanos:e.value.nanos});case`Infinity`:return $g}}}).annotations({identifier:`Duration`});var r_=class extends Im(Et,{typeConstructor:{_tag:`Uint8Array`},identifier:`Uint8ArrayFromSelf`,pretty:()=>e=>`new Uint8Array(${JSON.stringify(Array.from(e))})`,arbitrary:()=>e=>e.uint8Array(),equivalence:()=>Ft(vt)}){};Z(th(class extends q.pipe(Dg(0,255,{identifier:`Uint8`,description:`a 8-bit unsigned integer`})){}).annotations({description:`an array of 8-bit unsigned integers to be decoded into a Uint8Array`}),r_,{strict:!0,decode:e=>Uint8Array.from(e),encode:e=>Array.from(e)}).annotations({identifier:`Uint8Array`});const i_=ro,a_=(e,t)=>n=>{let r=Math.floor(e);if(r<1)throw Error(Pa(`Expected an integer greater than or equal to 1, actual ${e}`));return n.pipe(Y(e=>e.length>=r,{schemaId:i_,title:`minItems(${r})`,description:`an array of at least ${r} item(s)`,jsonSchema:{minItems:r},[Do]:!0,...t}))},o_=Symbol.for(`effect/SchemaId/ValidDate`),s_=e=>t=>t.pipe(Y(e=>!Number.isNaN(e.getTime()),{schemaId:o_,[o_]:{noInvalidDate:!0},title:`validDate`,description:`a valid Date`,...e})),c_=Ua;var l_=class extends Im(Ue,{typeConstructor:{_tag:`Date`},identifier:`DateFromSelf`,schemaId:c_,[c_]:{noInvalidDate:!1},description:`a potentially invalid Date instance`,pretty:()=>e=>`new Date(${JSON.stringify(e)})`,arbitrary:()=>e=>e.date({noInvalidDate:!1}),equivalence:()=>dt}){};l_.pipe(s_({identifier:`ValidDateFromSelf`,description:`a valid Date instance`})),class extends Z(K.annotations({description:`a string to be decoded into a Date`}),l_,{strict:!0,decode:e=>new Date(e),encode:e=>Ae(e)}).annotations({identifier:`DateFromString`}){}.pipe(s_({identifier:`Date`})),Z(q.annotations({description:`a number to be decoded into a Date`}),l_,{strict:!0,decode:e=>new Date(e),encode:e=>e.getTime()}).annotations({identifier:`DateFromNumber`});var u_=class extends Im(e=>Uf(e)&&Kf(e),{typeConstructor:{_tag:`effect/DateTime.Utc`},identifier:`DateTimeUtcFromSelf`,description:`a DateTime.Utc instance`,pretty:()=>e=>e.toString(),arbitrary:()=>e=>e.date({noInvalidDate:!0}).map(e=>Yf(e)),equivalence:()=>Jf}){};const d_=(e,t)=>gp({try:()=>Xf(e),catch:()=>new H(t,e,`Unable to decode ${l(e)} into a DateTime.Utc`)});X(q.annotations({description:`a number to be decoded into a DateTime.Utc`}),u_,{strict:!0,decode:(e,t,n)=>d_(e,n),encode:e=>U(ip(e))}).annotations({identifier:`DateTimeUtcFromNumber`}),X(l_.annotations({description:`a Date to be decoded into a DateTime.Utc`}),u_,{strict:!0,decode:(e,t,n)=>d_(e,n),encode:e=>U(rp(e))}).annotations({identifier:`DateTimeUtcFromDate`}),X(K.annotations({description:`a string to be decoded into a DateTime.Utc`}),u_,{strict:!0,decode:(e,t,n)=>d_(e,n),encode:e=>U(ap(e))}).annotations({identifier:`DateTimeUtc`});const f_=()=>e=>e.integer({min:-720*60*1e3,max:840*60*1e3}).map(ep);var p_=class extends Im(Wf,{typeConstructor:{_tag:`effect/DateTime.TimeZone.Offset`},identifier:`TimeZoneOffsetFromSelf`,description:`a TimeZone.Offset instance`,pretty:()=>e=>e.toString(),arbitrary:f_}){};Z(q.annotations({description:`a number to be decoded into a TimeZone.Offset`}),p_,{strict:!0,decode:e=>ep(e),encode:e=>e.offset}).annotations({identifier:`TimeZoneOffset`});const m_=()=>e=>e.constantFrom(...Intl.supportedValuesOf(`timeZone`)).map($f);var h_=class extends Im(Gf,{typeConstructor:{_tag:`effect/DateTime.TimeZone.Named`},identifier:`TimeZoneNamedFromSelf`,description:`a TimeZone.Named instance`,pretty:()=>e=>e.toString(),arbitrary:m_}){};X(K.annotations({description:`a string to be decoded into a TimeZone.Named`}),h_,{strict:!0,decode:(e,t,n)=>gp({try:()=>$f(e),catch:()=>new H(n,e,`Unable to decode ${JSON.stringify(e)} into a TimeZone.Named`)}),encode:e=>U(e.id)}).annotations({identifier:`TimeZoneNamed`});var g_=class extends qm(p_,h_){};X(K.annotations({description:`a string to be decoded into a TimeZone`}),g_,{strict:!0,decode:(e,t,n)=>_(tp(e),{onNone:()=>hp(new H(n,e,`Unable to decode ${JSON.stringify(e)} into a TimeZone`)),onSome:U}),encode:e=>U(np(e))}).annotations({identifier:`TimeZone`});const __=e=>e.oneof(f_()(e),m_()(e));var v_=class extends Im(e=>Uf(e)&&qf(e),{typeConstructor:{_tag:`effect/DateTime.Zoned`},identifier:`DateTimeZonedFromSelf`,description:`a DateTime.Zoned instance`,pretty:()=>e=>e.toString(),arbitrary:()=>e=>e.tuple(e.integer({min:-31536e9,max:31536e9}),__(e)).map(([e,t])=>Zf(e,{timeZone:t})),equivalence:()=>Jf}){};X(K.annotations({description:`a string to be decoded into a DateTime.Zoned`}),v_,{strict:!0,decode:(e,t,n)=>_(Qf(e),{onNone:()=>hp(new H(n,e,`Unable to decode ${JSON.stringify(e)} into a DateTime.Zoned`)),onSome:U}),encode:e=>U(op(e))}).annotations({identifier:`DateTimeZoned`});const y_=e=>e._tag===`None`?v():w(e.value),b_=(e,t)=>n=>n.oneof(t,n.record({_tag:n.constant(`None`)}),n.record({_tag:n.constant(`Some`),value:e(n)})).map(y_),x_=e=>_({onNone:()=>`none()`,onSome:t=>`some(${e(t)})`}),S_=e=>(t,n,r)=>i(t)?wt(t)?U(v()):qg(e(t.value,n),w,r,t):hp(new H(r,t)),C_=e=>Im([e],{decode:e=>S_(jp(e)),encode:e=>S_(Mp(e))},{typeConstructor:{_tag:`effect/Option`},pretty:x_,arbitrary:b_,equivalence:Yt});Z(K,(e=>C_(e).annotations({description:`Option<${Tm(e)}>`}))(cg),{strict:!0,decode:e=>nt(w(e.trim()),Ea),encode:e=>Ne(e,()=>``)});const w_=()=>e=>`BigDecimal(${Cc(hc(e))})`,T_=()=>e=>e.tuple(e.bigInt(),e.integer({min:-18,max:18})).map(([e,t])=>uc(e,t));var E_=class extends Im(lc,{typeConstructor:{_tag:`effect/BigDecimal`},identifier:`BigDecimalFromSelf`,pretty:w_,arbitrary:T_,equivalence:()=>vc}){};X(K.annotations({description:`a string to be decoded into a BigDecimal`}),E_,{strict:!0,decode:(e,t,n)=>Sc(e).pipe(_({onNone:()=>hp(new H(n,e,`Unable to decode ${JSON.stringify(e)} into a BigDecimal`)),onSome:e=>U(hc(e))})),encode:e=>U(Cc(hc(e)))}).annotations({identifier:`BigDecimal`}),Z(q.annotations({description:`a number to be decoded into a BigDecimal`}),E_,{strict:!0,decode:e=>bc(e),encode:e=>Tc(e)}).annotations({identifier:`BigDecimalFromNumber`});const D_=e=>km(e)||lh(e),O_=e=>Reflect.ownKeys(e).every(t=>D_(e[t])),k_=e=>`fields`in e?e.fields:k_(e[Ph]),A_=e=>O_(e)?J(e):km(e)?e:J(k_(e)),j_=e=>O_(e)?e:k_(e),M_=e=>mh(ph(Mm(e)),()=>e),N_=e=>(t,n,r)=>{let i=j_(n),a=A_(n),o={_tag:M_(t)},s=F_(o,i);return class extends z_({kind:`TaggedClass`,identifier:e??t,schema:Mh(a,J(o)),fields:s,Base:Ti,annotations:r}){static _tag=t}},P_=e=>(t,n,r)=>{class i extends Ei{}i.prototype.name=t;let a=j_(n),o=A_(n),s={_tag:M_(t)},c=F_(s,a),u=`message`in c;class d extends z_({kind:`TaggedError`,identifier:e??t,schema:Mh(o,J(s)),fields:c,Base:i,annotations:r,disableToString:!0}){static _tag=t}return u||Object.defineProperty(d.prototype,"message",{get(){return`{ ${Reflect.ownKeys(a).map(e=>`${p(e)}: ${l(this[e])}`).join(`, `)} }`},enumerable:!1,configurable:!0}),d},F_=(e,t)=>{let n={...e};for(let r of Reflect.ownKeys(t)){if(r in e)throw Error(Ha(r));n[r]=t[r]}return n};function I_(e){return Ke(e)?e:e?.disableValidation??!1}const L_=st(`effect/Schema/astCache`,()=>new WeakMap),R_=e=>e===void 0?[]:Array.isArray(e)?e:[e],z_=({Base:e,annotations:t,disableToString:n,fields:r,identifier:i,kind:a,schema:o})=>{let s=Symbol.for(`effect/Schema/${a}/${i}`),[c,u,d]=R_(t),f=Dm(o),m=f.annotations({identifier:i,...c}),h=f.annotations({[fo]:`${i} (Type side)`,...c}),g=o.annotations({[fo]:`${i} (Constructor)`,...c}),ee=o.annotations({[fo]:`${i} (Encoded side)`,...d}),_=o.annotations({...d,...c,...u}),te=e=>Nt(e,s)&&Fp(h)(e),ne=class extends e{constructor(e={},t=!1){e={...e},a!==`Class`&&delete e._tag,e=vh(r,e),I_(t)||(e=Pp(g)(e)),super(e,!0)}static[bm]=xm;static get ast(){let e=L_.get(this);if(e)return e;let t=Im([o],{decode:()=>(e,t,n)=>e instanceof this||te(e)?U(e):hp(new H(n,e)),encode:()=>(e,t)=>e instanceof this?U(e):bp(Mp(h)(e,t),e=>new this(e,!0))},{identifier:i,pretty:e=>t=>`${i}(${e(t)})`,arbitrary:e=>t=>e(t).map(e=>new this(e)),equivalence:S,[Eo]:m.ast,...c});return e=Z(ee,t,{strict:!0,decode:e=>new this(e,!0),encode:S}).annotations({[Eo]:_.ast,...u}).ast,L_.set(this,e),e}static pipe(){return De(this,arguments)}static annotations(e){return G(this.ast).annotations(e)}static toString(){return`(${String(ee)} <-> ${i})`}static make(...e){return new this(...e)}static fields={...r};static identifier=i;static extend(e){return(t,n)=>{let i=j_(t),s=A_(t),c=F_(r,i);return z_({kind:a,identifier:e,schema:Mh(o,s),fields:c,Base:this,annotations:n})}}static transformOrFail(e){return(t,n,i)=>{let s=F_(r,t);return z_({kind:a,identifier:e,schema:X(o,Dm(J(s)),n),fields:s,Base:this,annotations:i})}}static transformOrFailFrom(e){return(t,n,i)=>{let s=F_(r,t);return z_({kind:a,identifier:e,schema:X(Em(o),J(s),n),fields:s,Base:this,annotations:i})}}get[s](){return s}};return n!==!0&&Object.defineProperty(ne.prototype,"toString",{value(){return`${i}({ ${Reflect.ownKeys(r).map(e=>`${p(e)}: ${l(this[e])}`).join(`, `)} })`},configurable:!0,writable:!0}),ne},B_=qm(J({_tag:Mm(`None`)}).annotations({identifier:`FiberIdNoneEncoded`}),J({_tag:Mm(`Runtime`),id:Fg,startTimeMillis:Fg}).annotations({identifier:`FiberIdRuntimeEncoded`}),J({_tag:Mm(`Composite`),left:Nh(()=>B_),right:Nh(()=>B_)}).annotations({identifier:`FiberIdCompositeEncoded`})).annotations({identifier:`FiberIdEncoded`}),V_=e=>e.letrec(t=>({None:e.record({_tag:e.constant(`None`)}),Runtime:e.record({_tag:e.constant(`Runtime`),id:e.integer(),startTimeMillis:e.integer()}),Composite:e.record({_tag:e.constant(`Composite`),left:t(`FiberId`),right:t(`FiberId`)}),FiberId:e.oneof(t(`None`),t(`Runtime`),t(`Composite`))})).FiberId.map(W_),H_=e=>{switch(e._tag){case`None`:return`FiberId.none`;case`Runtime`:return`FiberId.runtime(${e.id}, ${e.startTimeMillis})`;case`Composite`:return`FiberId.composite(${H_(e.right)}, ${H_(e.left)})`}};var U_=class extends Im(ge,{typeConstructor:{_tag:`effect/FiberId`},identifier:`FiberIdFromSelf`,pretty:()=>H_,arbitrary:()=>V_}){};const W_=e=>{switch(e._tag){case`None`:return xe;case`Runtime`:return g(e.id,e.startTimeMillis);case`Composite`:return me(W_(e.left),W_(e.right))}},G_=e=>{switch(e._tag){case`None`:return{_tag:`None`};case`Runtime`:return{_tag:`Runtime`,id:e.id,startTimeMillis:e.startTimeMillis};case`Composite`:return{_tag:`Composite`,left:G_(e.left),right:G_(e.right)}}};Z(B_,U_,{strict:!0,decode:e=>W_(e),encode:e=>G_(e)}).annotations({identifier:`FiberId`});var K_=class extends Z(Vm,Vm,{strict:!0,decode:e=>{if(Dt(e)&&`message`in e&&typeof e.message==`string`){let t=Error(e.message,{cause:e});return`name`in e&&typeof e.name==`string`&&(t.name=e.name),t.stack=`stack`in e&&typeof e.stack==`string`?e.stack:``,t}return Ot(e)},encode:e=>e instanceof Error?{name:e.name,message:e.message}:Ot(e)}).annotations({identifier:`Defect`}){};Z(Vm,Wm,{strict:!0,decode:e=>it(e),encode:S}).annotations({identifier:`BooleanFromUnknown`}),Z(Mm(`true`,`false`).annotations({description:`a string to be decoded into a boolean`}),Wm,{strict:!0,decode:e=>e===`true`,encode:e=>e?`true`:`false`}).annotations({identifier:`BooleanFromString`});const q_=xh(`symbol`,{key:K}).annotations({description:`an object to be decoded into a globally shared symbol`}),J_=X(q_,Um,{strict:!0,decode:e=>zg(e.key),encode:(e,t,n)=>bp(Rg(e,n),e=>q_.make({key:e}))});var Y_=class extends qm(K,q,J_).annotations({identifier:`PropertyKey`}){};J({_tag:ph(Mm(`Pointer`,`Unexpected`,`Missing`,`Composite`,`Refinement`,`Transformation`,`Type`,`Forbidden`)).annotations({description:`The tag identifying the type of parse issue`}),path:ph(th(Y_)).annotations({description:`The path to the property where the issue occurred`}),message:ph(K).annotations({description:`A descriptive message explaining the issue`})}).annotations({identifier:`ArrayFormatterIssue`,description:`Represents an issue returned by the ArrayFormatter formatter`});const X_=Zd,Z_=ef,Q_=yf,$_=bf,ev=Of,tv=Rf,nv=zf,rv={arrays:`merge`,sets:`merge`,maps:`merge`};function iv(e,t,n){return av(e,t,new Set,n??rv)}function av(e,t,n,r){let i={},a=new Set([...uv(e),...uv(t)]);for(let o of a){if(o===`__proto__`)continue;let a=e[o];if(!Object.hasOwn(t,o)){i[o]=a;continue}let s=t[o];if(lv(a)&&lv(s)&&!n.has(a)&&!n.has(s)){n.add(a),n.add(s),i[o]=ov(a,s,n,r);continue}i[o]=s}return i}function ov(e,t,n,r){if(sv(e)&&sv(t))return av(e,t,n,r);if(cv(e)&&cv(t)){if(Array.isArray(e)&&Array.isArray(t))return r.arrays===`merge`?e.concat(t):t;if(e instanceof Map&&t instanceof Map){if(r.maps===`merge`){let n=new Map(e);for(let[e,r]of t)n.set(e,r);return n}return t}if(e instanceof Set&&t instanceof Set){if(r.sets===`merge`){let n=new Set(e);for(let e of t)n.add(e);return n}return t}}return t}function sv(e){return Object.getPrototypeOf(e)===Object.prototype}function cv(e){return typeof e[Symbol.iterator]==`function`}function lv(e){return typeof e==`object`&&!!e}function uv(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n)Object.prototype.propertyIsEnumerable.call(e,r)&&t.push(r);return t}function dv(e){return e%4==0&&e%100!=0||e%400==0}var fv=class{#e=/[ \t]/;#t=0;#n;constructor(e){this.#n=e}get position(){return this.#t}get source(){return this.#n}char(e=0){return this.#n[this.#t+e]??``}slice(e,t){return this.#n.slice(this.#t+e,this.#t+t)}next(e=1){this.#t+=e}skipWhitespaces(){for(;this.#e.test(this.char())&&!this.eof();)this.next();if(!this.isCurrentCharEOL()&&/\s/.test(this.char())){let e=`\\u`+this.char().charCodeAt(0).toString(16),t=this.#t;throw SyntaxError(`Cannot parse the TOML: It contains invalid whitespace at position '${t}': \`${e}\``)}}nextUntilChar(e={skipComments:!0}){for(;!this.eof();){let t=this.char();if(this.#e.test(t)||this.isCurrentCharEOL())this.next();else if(e.skipComments&&this.char()===`#`)for(;!this.isCurrentCharEOL()&&!this.eof();)this.next();else break}}eof(){return this.#t>=this.#n.length}isCurrentCharEOL(){return this.char()===`
|
|
3
|
-
`||this.startsWith(`\r
|
|
4
|
-
`)}startsWith(e){return this.#n.startsWith(e,this.#t)}match(e){if(!e.sticky)throw Error(`RegExp ${e} does not have a sticky 'y' flag`);return e.lastIndex=this.#t,this.#n.match(e)}};function Q(e){return{ok:!0,body:e}}function $(){return{ok:!1}}function pv(e,t={__proto__:null}){return e.reduceRight((e,t)=>({[t]:e}),t)}function mv(e){return typeof e==`object`&&!!e}function hv(e,t){let n=t[0];if(!n)throw Error(`Cannot parse the TOML: key length is not a positive number`);return e[n]}function gv(e,t){let{keys:n,type:r,value:i}=t,a=hv(e,n);if(a===void 0)return Object.assign(e,pv(n,i));if(Array.isArray(a))return vv(a.at(-1),{type:r,keys:n.slice(1),value:i}),e;if(mv(a))return vv(a,{type:r,keys:n.slice(1),value:i}),e;throw Error(`Unexpected assign`)}function _v(e,t){let{type:n,keys:r,value:i}=t,a=hv(e,r);if(a===void 0)return Object.assign(e,pv(r,[i]));if(Array.isArray(a))return t.keys.length===1?a.push(i):vv(a.at(-1),{type:t.type,keys:t.keys.slice(1),value:t.value}),e;if(mv(a))return vv(a,{type:n,keys:r.slice(1),value:i}),e;throw Error(`Unexpected assign`)}function vv(e,t){switch(t.type){case`Block`:return iv(e,t.value);case`Table`:return gv(e,t);case`TableArray`:return _v(e,t)}}function yv(e){return t=>{for(let n of e){let e=n(t);if(e.ok)return e}return $()}}function bv(e,t){let n=Ev(t);return r=>{let i=[],a=e(r);if(!a.ok)return Q(i);for(i.push(a.body);!r.eof()&&n(r).ok;){let n=e(r);if(!n.ok)throw SyntaxError(`Invalid token after "${t}"`);i.push(n.body)}return Q(i)}}function xv(e,t){let n=Ev(t);return r=>{let i=e(r);if(!i.ok)return $();let a=[i.body];for(;!r.eof()&&n(r).ok;){let n=e(r);if(!n.ok)throw SyntaxError(`Invalid token after "${t}"`);a.push(n.body)}return Q(a)}}function Sv(e,t,n){let r=Ev(t);return i=>{let a=i.position,o=e(i);if(!o.ok)return $();if(!r(i).ok)throw SyntaxError(`key/value pair doesn't have "${t}"`);let s=n(i);if(!s.ok){let e=i.source.indexOf(`
|
|
5
|
-
`,i.position),t=e>0?e:i.source.length,n=i.source.slice(a,t);throw SyntaxError(`Cannot parse value on line '${n}'`)}return Q(pv(o.body,s.body))}}function Cv(e){return t=>{let n=e(t);if(!n.ok)return $();let r={__proto__:null};for(let e of n.body)typeof e==`object`&&e&&(r=iv(r,e));return Q(r)}}function wv(e){return t=>{let n=[];for(;!t.eof();){let r=e(t);if(!r.ok)break;n.push(r.body),t.nextUntilChar()}return n.length===0?$():Q(n)}}function Tv(e,t,n){let r=Ev(e),i=Ev(n);return a=>{if(!r(a).ok)return $();let o=t(a);if(!o.ok)throw SyntaxError(`Invalid token after "${e}"`);if(!i(a).ok)throw SyntaxError(`Not closed by "${n}" after started with "${e}"`);return Q(o.body)}}function Ev(e){return t=>(t.skipWhitespaces(),t.startsWith(e)?(t.next(e.length),t.skipWhitespaces(),Q(void 0)):$())}const Dv=/[A-Za-z0-9_-]+/y;function Ov(e){e.skipWhitespaces();let t=e.match(Dv)?.[0];return t?(e.next(t.length),Q(t)):$()}function kv(e){if(e.char()!==`\\`)return $();switch(e.next(),e.char()){case`b`:return e.next(),Q(`\b`);case`t`:return e.next(),Q(` `);case`n`:return e.next(),Q(`
|
|
6
|
-
`);case`f`:return e.next(),Q(`\f`);case`r`:return e.next(),Q(`\r`);case`u`:case`U`:{let t=e.char()===`u`?4:6,n=parseInt(`0x`+e.slice(1,1+t),16),r=String.fromCodePoint(n);return e.next(t+1),Q(r)}case`"`:return e.next(),Q(`"`);case`\\`:return e.next(),Q(`\\`);default:throw SyntaxError(`Invalid escape sequence: \\${e.char()}`)}}function Av(e){if(e.skipWhitespaces(),e.char()!==`"`)return $();e.next();let t=[];for(;e.char()!==`"`&&!e.eof();){if(e.char()===`
|
|
7
|
-
`)throw SyntaxError(`Single-line string cannot contain EOL`);let n=kv(e);n.ok?t.push(n.body):(t.push(e.char()),e.next())}if(e.eof())throw SyntaxError(`Single-line string is not closed:\n${t.join(``)}`);return e.next(),Q(t.join(``))}function jv(e){if(e.skipWhitespaces(),e.char()!==`'`)return $();e.next();let t=[];for(;e.char()!==`'`&&!e.eof();){if(e.char()===`
|
|
8
|
-
`)throw SyntaxError(`Single-line string cannot contain EOL`);t.push(e.char()),e.next()}if(e.eof())throw SyntaxError(`Single-line string is not closed:\n${t.join(``)}`);return e.next(),Q(t.join(``))}function Mv(e){if(e.skipWhitespaces(),!e.startsWith(`"""`))return $();e.next(3),e.char()===`
|
|
9
|
-
`?e.next():e.startsWith(`\r
|
|
10
|
-
`)&&e.next(2);let t=[];for(;!e.startsWith(`"""`)&&!e.eof();){if(e.startsWith(`\\
|
|
11
|
-
`)){e.next(),e.nextUntilChar({skipComments:!1});continue}else if(e.startsWith(`\\\r
|
|
12
|
-
`)){e.next(),e.nextUntilChar({skipComments:!1});continue}let n=kv(e);n.ok?t.push(n.body):(t.push(e.char()),e.next())}if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`"`&&(t.push(`"`),e.next()),e.next(3),Q(t.join(``))}function Nv(e){if(e.skipWhitespaces(),!e.startsWith(`'''`))return $();e.next(3),e.char()===`
|
|
13
|
-
`?e.next():e.startsWith(`\r
|
|
14
|
-
`)&&e.next(2);let t=[];for(;!e.startsWith(`'''`)&&!e.eof();)t.push(e.char()),e.next();if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`'`&&(t.push(`'`),e.next()),e.next(3),Q(t.join(``))}const Pv=/(?:true|false)\b/y;function Fv(e){e.skipWhitespaces();let t=e.match(Pv);if(!t)return $();let n=t[0];return e.next(n.length),Q(n===`true`)}const Iv=new Map([[`inf`,1/0],[`+inf`,1/0],[`-inf`,-1/0]]),Lv=/[+-]?inf\b/y;function Rv(e){e.skipWhitespaces();let t=e.match(Lv);if(!t)return $();let n=t[0];return e.next(n.length),Q(Iv.get(n))}const zv=/[+-]?nan\b/y;function Bv(e){e.skipWhitespaces();let t=e.match(zv);if(!t)return $();let n=t[0];return e.next(n.length),Q(NaN)}const Vv=xv(yv([Ov,Av,jv]),`.`),Hv=/0b[01]+(?:_[01]+)*\b/y;function Uv(e){e.skipWhitespaces();let t=e.match(Hv)?.[0];if(!t)return $();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,2);return isNaN(r)?$():Q(r)}const Wv=/0o[0-7]+(?:_[0-7]+)*\b/y;function Gv(e){e.skipWhitespaces();let t=e.match(Wv)?.[0];if(!t)return $();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,8);return isNaN(r)?$():Q(r)}const Kv=/0x[0-9a-f]+(?:_[0-9a-f]+)*\b/iy;function qv(e){e.skipWhitespaces();let t=e.match(Kv)?.[0];if(!t)return $();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,16);return isNaN(r)?$():Q(r)}const Jv=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)\b/y;function Yv(e){e.skipWhitespaces();let t=e.match(Jv)?.[0];if(!t)return $();e.next(t.length);let n=t.replaceAll(`_`,``);return Q(parseInt(n,10))}const Xv=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)(?:\.[0-9]+(?:_[0-9]+)*)?(?:e[+-]?[0-9]+(?:_[0-9]+)*)?\b/iy;function Zv(e){e.skipWhitespaces();let t=e.match(Xv)?.[0];if(!t)return $();e.next(t.length);let n=t.replaceAll(`_`,``),r=parseFloat(n);return isNaN(r)?$():Q(r)}const Qv=/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})(?:[ 0-9TZ.:+-]+)?\b/y;function $v(e){e.skipWhitespaces();let t=e.match(Qv);if(!t)return $();let n=t[0];e.next(n.length);let r=t.groups;if(r.month==`02`){let e=parseInt(r.day);if(e>29)throw SyntaxError(`Invalid date string "${t}"`);let n=parseInt(r.year);if(e>28&&!dv(n))throw SyntaxError(`Invalid date string "${t}"`)}let i=new Date(n.trim());if(isNaN(i.getTime()))throw SyntaxError(`Invalid date string "${t}"`);return Q(i)}const ey=/(\d{2}):(\d{2}):(\d{2})(?:\.[0-9]+)?\b/y;function ty(e){e.skipWhitespaces();let t=e.match(ey)?.[0];return t?(e.next(t.length),Q(t)):$()}function ny(e){if(e.skipWhitespaces(),e.char()!==`[`)return $();e.next();let t=[];for(;!e.eof();){e.nextUntilChar();let n=iy(e);if(!n.ok||(t.push(n.body),e.skipWhitespaces(),e.char()!==`,`))break;e.next()}if(e.nextUntilChar(),e.char()!==`]`)throw SyntaxError(`Array is not closed`);return e.next(),Q(t)}function ry(e){if(e.nextUntilChar(),e.char(1)===`}`)return e.next(2),Q({__proto__:null});let t=Tv(`{`,bv(ay,`,`),`}`)(e);if(!t.ok)return $();let n={__proto__:null};for(let e of t.body)n=iv(n,e);return Q(n)}const iy=yv([Mv,Nv,Av,jv,Fv,Rv,Bv,$v,ty,Uv,Gv,qv,Zv,Yv,ny,ry]),ay=Sv(Vv,`=`,iy);function oy(e){e.nextUntilChar();let t=Cv(wv(ay))(e);return t.ok?Q({type:`Block`,value:t.body}):$()}const sy=Tv(`[`,Vv,`]`);function cy(e){e.nextUntilChar();let t=sy(e);if(!t.ok)return $();e.nextUntilChar();let n=oy(e);return Q({type:`Table`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}const ly=Tv(`[[`,Vv,`]]`);function uy(e){e.nextUntilChar();let t=ly(e);if(!t.ok)return $();e.nextUntilChar();let n=oy(e);return Q({type:`TableArray`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}function dy(e){let t=wv(yv([oy,uy,cy]))(e);return t.ok?Q(t.body.reduce(vv,{__proto__:null})):Q({__proto__:null})}function fy(e,t){let n=e.source.slice(0,e.position).split(`
|
|
15
|
-
`);return`Parse error on line ${n.length}, column ${n.at(-1)?.length??0}: ${t}`}function py(e){return t=>{let n=new fv(t);try{let t=e(n);if(t.ok&&n.eof())return t.body;let r=`Unexpected character: "${n.char()}"`;throw SyntaxError(fy(n,r))}catch(e){throw e instanceof Error?SyntaxError(fy(n,e.message)):SyntaxError(fy(n,`Invalid error type caught`))}}}function my(e){return py(dy)(e)}const hy=Symbol.for(`@effect/platform/Error`),gy=Mm(`Clipboard`,`Command`,`FileSystem`,`KeyValueStore`,`Path`,`Stream`,`Terminal`);var _y=class extends P_(`@effect/platform/Error/BadArgument`)(`BadArgument`,{module:gy,method:K,description:hh(K),cause:hh(K_)}){[hy]=hy;get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:``}`}};const vy=Mm(`AlreadyExists`,`BadResource`,`Busy`,`InvalidData`,`NotFound`,`PermissionDenied`,`TimedOut`,`UnexpectedEof`,`Unknown`,`WouldBlock`,`WriteZero`);var yy=class extends P_(`@effect/platform/Error/SystemError`)(`SystemError`,{reason:vy,module:gy,method:K,description:hh(K),syscall:hh(K),pathOrDescriptor:hh(qm(K,q)),cause:hh(K_)}){[hy]=hy;get message(){return`${this.reason}: ${this.module}.${this.method}${this.pathOrDescriptor===void 0?``:` (${this.pathOrDescriptor})`}${this.description?`: ${this.description}`:``}`}};const by=Lt(`@effect/platform/FileSystem`),xy=e=>typeof e==`bigint`?e:BigInt(e),Sy=BigInt(1024);Sy*Sy*Sy*Sy*Sy;const Cy=e=>by.of({...e,exists:t=>C(e.access(t),wr(!0),tr(`SystemError`,e=>e.reason===`NotFound`?M(!1):Gn(e))),readFileString:(t,n)=>Er(e.readFile(t),{try:e=>new TextDecoder(n).decode(e),catch:e=>new _y({module:`FileSystem`,method:`readFileString`,description:`invalid encoding`,cause:e})}),stream:(t,n)=>C(e.open(t,{flag:`r`}),n?.offset?pr(e=>e.seek(n.offset,`start`)):S,E(e=>wy(e,n)),nv),sink:(t,n)=>C(e.open(t,{flag:`w`,...n}),E(e=>X_(t=>e.writeAll(t))),Z_),writeFileString:(t,n,r)=>D(er({try:()=>new TextEncoder().encode(n),catch:e=>new _y({module:`FileSystem`,method:`writeFileString`,description:`could not encode string`,cause:e})}),n=>e.writeFile(t,n,r))}),wy=(e,{bufferSize:t=16,bytesToRead:n,chunkSize:r=xy(64*1024)}={})=>{let i=n===void 0?void 0:xy(n),a=xy(r);function o(t){if(i!==void 0&&i<=t)return Vf;let n=i!==void 0&&i-t<a?i-t:a;return Bf(e.readAlloc(n),_({onNone:()=>Vf,onSome:e=>Bf(Hf(ye(e)),n=>o(t+BigInt(e.length)))}))}return $_(ev(o(BigInt(0))),{capacity:t})},Ty=xy,Ey=by,Dy=Cy,Oy=Symbol.for(`@effect/platform/FileSystem/File`),ky=Mc(),Ay=wi(`Create`),jy=wi(`Update`),My=wi(`Remove`);var Ny=class extends Ze(`@effect/platform/FileSystem/WatchBackend`)(){};const Py=Symbol.for(`@effect/platform/Path`),Fy=Lt(`@effect/platform/Path`);function Iy(e,t){let n=``,r=0,i=-1,a=0,o;for(let s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(i!==s-1&&a!==1)if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let e=n.lastIndexOf(`/`);if(e!==n.length-1){e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}function Ly(e,t){let n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+e+r:r}function Ry(e){if(e.protocol!==`file:`)return Gn(new _y({module:`Path`,method:`fromFileUrl`,description:`URL must be of scheme file`}));if(e.hostname!==``)return Gn(new _y({module:`Path`,method:`fromFileUrl`,description:`Invalid file URL host`}));let t=e.pathname;for(let e=0;e<t.length;e++)if(t[e]===`%`){let n=t.codePointAt(e+2)|32;if(t[e+1]===`2`&&n===102)return Gn(new _y({module:`Path`,method:`fromFileUrl`,description:`must not include encoded / characters`}))}return M(decodeURIComponent(t))}const zy=function(){let e=``,t=!1,n;for(let r=arguments.length-1;r>=-1&&!t;r--){let i;if(r>=0)i=arguments[r];else{let e=globalThis.process;n===void 0&&`process`in globalThis&&typeof e==`object`&&e&&typeof e.cwd==`function`&&(n=e.cwd()),i=n}i.length!==0&&(e=i+`/`+e,t=i.charCodeAt(0)===47)}return e=Iy(e,!t),t?e.length>0?`/`+e:`/`:e.length>0?e:`.`};function By(e){let t=new URL(`file://`),n=zy(e);return e.charCodeAt(e.length-1)===47&&n[n.length-1]!==`/`&&(n+=`/`),t.pathname=Ky(n),M(t)}const Vy=/%/g,Hy=/\\/g,Uy=/\n/g,Wy=/\r/g,Gy=/\t/g;function Ky(e){return e.includes(`%`)&&(e=e.replace(Vy,`%25`)),e.includes(`\\`)&&(e=e.replace(Hy,`%5C`)),e.includes(`
|
|
16
|
-
`)&&(e=e.replace(Uy,`%0A`)),e.includes(`\r`)&&(e=e.replace(Wy,`%0D`)),e.includes(` `)&&(e=e.replace(Gy,`%09`)),e}const qy=Fy.of({[Py]:Py,resolve:zy,normalize(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=Iy(e,!t),e.length===0&&!t&&(e=`.`),e.length>0&&n&&(e+=`/`),t?`/`+e:e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return`.`;let e;for(let t=0;t<arguments.length;++t){let n=arguments[t];n.length>0&&(e===void 0?e=n:e+=`/`+n)}return e===void 0?`.`:qy.normalize(e)},relative(e,t){if(e===t||(e=qy.resolve(e),t=qy.resolve(t),e===t))return``;let n=1;for(;n<e.length&&e.charCodeAt(n)===47;++n);let r=e.length,i=r-n,a=1;for(;a<t.length&&t.charCodeAt(a)===47;++a);let o=t.length-a,s=i<o?i:o,c=-1,l=0;for(;l<=s;++l){if(l===s){if(o>s){if(t.charCodeAt(a+l)===47)return t.slice(a+l+1);if(l===0)return t.slice(a+l)}else i>s&&(e.charCodeAt(n+l)===47?c=l:l===0&&(c=0));break}let r=e.charCodeAt(n+l);if(r!==t.charCodeAt(a+l))break;r===47&&(c=l)}let u=``;for(l=n+c+1;l<=r;++l)(l===r||e.charCodeAt(l)===47)&&(u.length===0?u+=`..`:u+=`/..`);return u.length>0?u+t.slice(a+c):(a+=c,t.charCodeAt(a)===47&&++a,t.slice(a))},dirname(e){if(e.length===0)return`.`;let t=e.charCodeAt(0),n=t===47,r=-1,i=!0;for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:`.`:n&&r===1?`//`:e.slice(0,r)},basename(e,t){let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)}},extname(e){let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return Ly(`/`,e)},parse(e){let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0),r=n===47,i;r?(t.root=`/`,i=1):i=0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),o>0?t.dir=e.slice(0,o-1):r&&(t.dir=`/`),t},sep:`/`,fromFileUrl:Ry,toFileUrl:By,toNamespacedPath:S}),Jy=Fc(Fy,qy),Yy=Fy,Xy=Jy,Zy=Ch({key:K,value:th(K)}).pipe(Th(`TomlConfig`)),Qy=X(K,Dm(Zy),{strict:!0,decode:e=>gp({try:()=>my(e),catch:e=>new sp(e,`TOML parse error`)}).pipe(yp(e=>jp(Zy)(e))),encode:(e,t,n)=>hp(new dp(n,e,`TomlConfigFromText is decode-only`))}),$y=Np(Zy)({});var eb=class extends Ze(`TomlLoader`)(){};const tb=Nc(eb,un(function*(){let e=yield*sr(nr()),t=yield*Ey,n=yield*Yy;return eb.of({load:Nn(`TomlLoader.load`)(function*(r){let i=ar(yield*lr(e),r);if(bt(i))return i.value;let a=n.join(r,`systemfsoftware.toml`);if(!(yield*t.exists(a)))return yield*Yr(e,e=>(Or(e,r,$y),e)),$y;let o=yield*t.readFileString(a).pipe(D(Om(Qy)),vr(()=>M($y)));return yield*Yr(e,e=>(Or(e,r,o),e)),o})})}));Fp(th(J({old_text:hh(Vm),new_text:hh(Vm)}).pipe(Y(e=>`old_text`in e||`new_text`in e))).pipe(a_(1))),Fp(th(J({old_string:hh(Vm),new_string:hh(Vm)}).pipe(Y(e=>`old_string`in e||`new_string`in e)))),Ap(Ch({key:K,value:Vm}));export{qm as C,Ic as D,Pc as E,N_ as S,Nc as T,th as _,Ey as a,K as b,Ny as c,jy as d,Dy as f,tv as g,Q_ as h,ky as i,Ay as l,yy as m,tb as n,Oy as o,_y as p,Xy as r,Ty as s,eb as t,My as u,Mm as v,zh as w,J as x,Ch as y};
|