holycodex 0.16.3-dev.66.1 → 0.16.4-dev.73.1
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/README.md +18 -5
- package/dist/agent.js +128 -0
- package/dist/assets/plugin/plugin.json +2 -2
- package/dist/assets/plugin/skills/code-review/SKILL.md +15 -3
- package/dist/assets/plugin/skills/code-review/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/commit/SKILL.md +29 -7
- package/dist/assets/plugin/skills/commit/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/compress/SKILL.md +12 -3
- package/dist/assets/plugin/skills/compress/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/debugging/SKILL.md +10 -5
- package/dist/assets/plugin/skills/debugging/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/handoff/SKILL.md +13 -5
- package/dist/assets/plugin/skills/handoff/agents/openai.yaml +2 -2
- package/dist/assets/plugin/skills/operations/SKILL.md +31 -0
- package/dist/assets/plugin/skills/operations/agents/openai.yaml +6 -0
- package/dist/assets/plugin/skills/plan/SKILL.md +15 -3
- package/dist/assets/plugin/skills/plan/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/plan-review/SKILL.md +14 -2
- package/dist/assets/plugin/skills/plan-review/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/programming/SKILL.md +17 -6
- package/dist/assets/plugin/skills/programming/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/refactor/SKILL.md +17 -6
- package/dist/assets/plugin/skills/refactor/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/rules/SKILL.md +12 -3
- package/dist/assets/plugin/skills/rules/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/stop-slop/SKILL.md +10 -2
- package/dist/assets/plugin/skills/stop-slop/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/writing-for-agents/SKILL.md +18 -3
- package/dist/assets/plugin/skills/writing-for-agents/agents/openai.yaml +1 -1
- package/dist/index.js +87 -57
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -1,35 +1,68 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`)}\n${a(n)}}`;return o(e,l)}return String(e)}return c(e,0)}var N,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt=v((()=>{Ie(),T(),N=Symbol.for(`nodejs.util.inspect.custom`),Bt=e=>{try{if(w(e,`toJSON`)&&Ue(e.toJSON)&&e.toJSON.length===0)return e.toJSON();if(Array.isArray(e))return e.map(Bt)}catch{return{}}return Yt(e)},Vt=`[Circular]`,Ht=e=>JSON.stringify(e,null,2),Ut=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?Wt(e,t):String(e)}catch{return String(e)}},Wt=(e,t)=>{let n=[],r=JSON.stringify(e,(e,t)=>typeof t==`object`&&t?n.includes(t)?void 0:n.push(t)&&(qt.fiberRefs!==void 0&&Kt(t)?t[Gt](qt.fiberRefs):t):t,t);return n=void 0,r},Gt=Symbol.for(`effect/Inspectable/Redactable`),Kt=e=>typeof e==`object`&&!!e&&Gt in e,qt=C(`effect/Inspectable/redactableState`,()=>({fiberRefs:void 0})),Jt=(e,t)=>{let n=qt.fiberRefs;qt.fiberRefs=e;try{return t()}finally{qt.fiberRefs=n}},Yt=e=>Kt(e)&&qt.fiberRefs!==void 0?e[Gt](qt.fiberRefs):e})),P,F=v((()=>{P=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}}})),Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn,fn=v((()=>{Zt=`Async`,Qt=`Commit`,$t=`Failure`,en=`OnFailure`,tn=`OnSuccess`,nn=`OnSuccessAndFailure`,rn=`Success`,an=`Sync`,on=`UpdateRuntimeFlags`,sn=`While`,cn=`Iterator`,ln=`WithRuntime`,un=`Yield`,dn=`RevertFlags`})),pn,mn,hn=v((()=>{pn=`3.22.1`,mn=()=>pn})),gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On=v((()=>{M(),Mt(),F(),St(),fn(),hn(),gn=Symbol.for(`effect/Effect`),_n=Symbol.for(`effect/Stream`),vn=Symbol.for(`effect/Sink`),yn=Symbol.for(`effect/Channel`),bn={_R:e=>e,_E:e=>e,_A:e=>e,_V:mn()},xn={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e},Sn={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},Cn={[gn]:bn,[_n]:bn,[vn]:xn,[yn]:Sn,[j](e){return this===e},[E](){return k(this,wt(this))},[Symbol.iterator](){return new st(new gt(this))},pipe(){return P(this,arguments)}},wn={[E](){return k(this,At(this))},[j](e){let t=Object.keys(this),n=Object.keys(e);if(t.length!==n.length)return!1;for(let n of t)if(!(n in e&&A(this[n],e[n])))return!1;return!0}},Tn={...Cn,_op:Qt},En={...Tn,...wn},Dn=function(){function e(){}return e.prototype=Tn,e}()})),kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn=v((()=>{M(),Mt(),Xt(),T(),On(),kn=Symbol.for(`effect/Option`),An={...Cn,[kn]:{_A:e=>e},[N](){return this.toJSON()},toString(){return Ht(this.toJSON())}},jn=Object.assign(Object.create(An),{_tag:`Some`,_op:`Some`,[j](e){return Pn(e)&&In(e)&&A(this.value,e.value)},[E](){return k(this,O(D(this._tag))(D(this.value)))},toJSON(){return{_id:`Option`,_tag:this._tag,value:Bt(this.value)}}}),Mn=D(`None`),Nn=Object.assign(Object.create(An),{_tag:`None`,_op:`None`,[j](e){return Pn(e)&&Fn(e)},[E](){return Mn},toJSON(){return{_id:`Option`,_tag:this._tag}}}),Pn=e=>w(e,kn),Fn=e=>e._tag===`None`,In=e=>e._tag===`Some`,Ln=Object.create(Nn),Rn=e=>{let t=Object.create(jn);return t.value=e,t}})),Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn=v((()=>{M(),S(),Mt(),Xt(),T(),On(),zn(),Bn=Symbol.for(`effect/Either`),Vn={...Cn,[Bn]:{_R:e=>e},[N](){return this.toJSON()},toString(){return Ht(this.toJSON())}},Hn=Object.assign(Object.create(Vn),{_tag:`Right`,_op:`Right`,[j](e){return Wn(e)&&Kn(e)&&A(this.right,e.right)},[E](){return O(D(this._tag))(D(this.right))},toJSON(){return{_id:`Either`,_tag:this._tag,right:Bt(this.right)}}}),Un=Object.assign(Object.create(Vn),{_tag:`Left`,_op:`Left`,[j](e){return Wn(e)&&Gn(e)&&A(this.left,e.left)},[E](){return O(D(this._tag))(D(this.left))},toJSON(){return{_id:`Either`,_tag:this._tag,left:Bt(this.left)}}}),Wn=e=>w(e,Bn),Gn=e=>e._tag===`Left`,Kn=e=>e._tag===`Right`,qn=e=>{let t=Object.create(Un);return t.left=e,t},Jn=e=>{let t=Object.create(Hn);return t.right=e,t},Yn=x(2,(e,t)=>Fn(e)?qn(t()):Jn(e.value))})),I,L,Zn,Qn,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr=v((()=>{S(),Xn(),T(),I=Jn,L=qn,Zn=Yn,Qn=e=>{if(Ue(e))try{return I(e())}catch(e){return L(e)}try{return I(e.try())}catch(t){return L(e.catch(t))}},$n=Wn,er=Gn,tr=Kn,nr=x(2,(e,{onLeft:t,onRight:n})=>er(e)?L(t(e.left)):I(n(e.right))),rr=x(2,(e,t)=>er(e)?L(t(e.left)):I(e.right)),ir=x(2,(e,t)=>tr(e)?I(t(e.right)):L(e.left)),ar=x(2,(e,{onLeft:t,onRight:n})=>er(e)?t(e.left):n(e.right)),or=ar({onLeft:be,onRight:be}),sr=x(2,(e,t)=>{if(tr(e))return e.right;throw t(e.left)}),cr=sr(()=>Error(`getOrThrow called on a Left`))})),ur,dr=v((()=>{ur=e=>e.length>0})),fr,pr,mr,hr,gr=v((()=>{S(),fr=e=>(t,n)=>t===n?0:e(t,n),pr=fr((e,t)=>e<t?-1:1),mr=x(2,(e,t)=>fr((n,r)=>e(t(n),t(r)))),hr=e=>x(2,(t,n)=>e(t,n)===1)})),R,z,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr=v((()=>{M(),Ne(),S(),zn(),R=()=>Ln,z=Rn,_r=Pn,vr=Fn,yr=In,br=x(2,(e,{onNone:t,onSome:n})=>vr(e)?t():n(e.value)),xr=x(2,(e,t)=>vr(e)?t():e.value),Sr=x(2,(e,t)=>vr(e)?t():e),Cr=x(2,(e,t)=>vr(e)?z(t()):e),wr=e=>e==null?R():z(e),Tr=xr(we),Er=e=>(...t)=>{try{return z(e(...t))}catch{return R()}},Dr=x(2,(e,t)=>{if(yr(e))return e.value;throw t()}),Or=x(2,(e,t)=>vr(e)?R():z(t(e.value))),kr=x(2,(e,t)=>vr(e)?R():t(e.value)),Ar=x(2,(e,t)=>vr(e)?R():wr(t(e.value))),jr=kr,Mr=x(2,(e,t)=>jr(e,e=>t(e)?Rn(e):Ln)),Nr=e=>Ee((t,n)=>vr(t)?vr(n):!vr(n)&&e(t.value,n.value)),Pr=e=>x(2,(t,n)=>!vr(t)&&e(t.value,n)),Fr=Ft(),Ir=Pr(Fr),Lr=x(2,(e,t)=>!vr(e)&&t(e.value))})),zr,Br=v((()=>{T(),zr=(...e)=>e})),Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si,ci,li,ui,di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi=v((()=>{M(),Ne(),S(),dr(),Rr(),Br(),Vr=e=>Array(e),Hr=x(2,(e,t)=>{let n=Math.max(1,Math.floor(e)),r=Array(n);for(let e=0;e<n;e++)r[e]=t(e);return r}),Ur=e=>Array.isArray(e)?e:Array.from(e),Wr=e=>Array.isArray(e)?e:[e],Gr=x(2,(e,{onEmpty:t,onNonEmpty:n})=>$r(e)?n(ai(e),ci(e)):t()),Kr=x(2,(e,t)=>[t,...e]),qr=x(2,(e,t)=>[...e,t]),Jr=x(2,(e,t)=>Ur(e).concat(Ur(t))),Yr=Array.isArray,Xr=e=>e.length===0,Zr=Xr,Qr=ur,$r=ur,ei=(e,t)=>e<0||e>=t.length,ti=(e,t)=>Math.floor(Math.min(Math.max(0,e),t.length)),ni=x(2,(e,t)=>{let n=Math.floor(t);return ei(n,e)?R():z(e[n])}),ri=x(2,(e,t)=>{let n=Math.floor(t);if(ei(n,e))throw Error(`Index ${n} out of bounds`);return e[n]}),ii=ni(0),ai=ri(0),oi=e=>$r(e)?z(si(e)):R(),si=e=>e[e.length-1],ci=e=>e.slice(1),li=(e,t)=>{let n=0;for(let r of e){if(!t(r,n))break;n++}return n},ui=x(2,(e,t)=>_i(e,li(e,t))),di=x(2,(e,t)=>{let n=Ur(e);return n.slice(ti(t,n),n.length)}),fi=e=>Array.from(e).reverse(),pi=x(2,(e,t)=>{let n=Array.from(e);return n.sort(t),n}),mi=x(2,(e,t)=>hi(e,t,zr)),hi=x(3,(e,t,n)=>{let r=Ur(e),i=Ur(t);if($r(r)&&$r(i)){let e=[n(ai(r),ai(i))],t=Math.min(r.length,i.length);for(let a=1;a<t;a++)e[a]=n(r[a],i[a]);return e}return[]}),gi=Ft(),_i=x(2,(e,t)=>{let n=Array.from(e),r=Math.floor(t);return $r(n)?r>=1?vi(n,r):[[],n]:[n,[]]}),vi=x(2,(e,t)=>{let n=Math.max(1,Math.floor(t));return n>=e.length?[yi(e),[]]:[Kr(e.slice(1,n),ai(e)),e.slice(n)]}),yi=e=>e.slice(),bi=x(3,(e,t,n)=>{let r=Ur(e),i=Ur(t);return $r(r)?$r(i)?ji(n)(Jr(r,i)):r:i}),xi=x(2,(e,t)=>bi(e,t,gi)),Si=()=>[],Ci=e=>[e],wi=x(2,(e,t)=>e.map(t)),Ti=x(2,(e,t)=>{if(Zr(e))return[];let n=[];for(let r=0;r<e.length;r++){let i=t(e[r],r);for(let e=0;e<i.length;e++)n.push(i[e])}return n}),Ei=Ti(be),Di=x(2,(e,t)=>{let n=Ur(e),r=[];for(let e=0;e<n.length;e++){let i=t(n[e],e);yr(i)&&r.push(i.value)}return r}),Oi=x(3,(e,t,n)=>Ur(e).reduce((e,t,r)=>n(e,t,r),t)),ki=(e,t)=>{let n=[],r=e,i;for(;yr(i=t(r));){let[e,t]=i.value;n.push(e),r=t}return n},Ai=Me,ji=x(2,(e,t)=>{let n=Ur(e);if($r(n)){let e=[ai(n)],r=ci(n);for(let n of r)e.every(e=>!t(n,e))&&e.push(n);return e}return[]}),Mi=e=>ji(e,Ft()),Ni=x(2,(e,t)=>Ur(e).join(t))})),Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra=v((()=>{M(),Ne(),S(),Mt(),Xt(),Rr(),F(),T(),Fi=/^[+-]?\d+$/,Ii=Symbol.for(`effect/BigDecimal`),Li={[Ii]:Ii,[E](){let e=Wi(this);return b(D(e.value),O(Dt(e.scale)),k(this))},[j](e){return Ri(e)&&Ji(this,e)},toString(){return`BigDecimal(${Qi(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[N](){return this.toJSON()},pipe(){return P(this,arguments)}},Ri=e=>w(e,Ii),zi=(e,t)=>{let n=Object.create(Li);return n.value=e,n.scale=t,n},Bi=(e,t)=>{if(e!==Vi&&e%Hi===Vi)throw RangeError(`Value must be normalized`);let n=zi(e,t);return n.normalized=n,n},Vi=BigInt(0),Hi=BigInt(10),Ui=Bi(Vi,0),Wi=e=>{if(e.normalized===void 0){if(e.value===Vi)e.normalized=Ui;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=Bi(r,i)}}return e.normalized},Gi=x(2,(e,t)=>t>e.scale?zi(e.value*Hi**BigInt(t-e.scale),t):t<e.scale?zi(e.value/Hi**BigInt(e.scale-t),t):e),Ki=e=>e.value<Vi?zi(-e.value,e.scale):e,qi=Ee((e,t)=>e.scale>t.scale?Gi(t,e.scale).value===e.value:e.scale<t.scale?Gi(e,t.scale).value===t.value:e.value===t.value),Ji=x(2,(e,t)=>qi(e,t)),Yi=e=>Dr(Xi(e),()=>RangeError(`Number must be finite, got ${e}`)),Xi=e=>{if(!Number.isFinite(e))return R();let t=`${e}`;if(t.includes(`e`))return Zi(t);let[n,r=``]=t.split(`.`);return z(zi(BigInt(`${n}${r}`),r.length))},Zi=e=>{if(e===``)return z(Ui);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)||!Fi.test(i))return R()}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(!Fi.test(i))return R();let s=a-n;return Number.isSafeInteger(s)?z(zi(BigInt(i),s)):R()},Qi=e=>{let t=Wi(e);if(Math.abs(t.scale)>=16)return $i(t);let n=t.value<Vi,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},$i=e=>{if(ta(e))return`0e+0`;let t=Wi(e),n=`${Ki(t).value}`,r=n.slice(0,1),i=n.slice(1),a=`${na(t)?`-`:``}${r}`;i!==``&&(a+=`.${i}`);let o=i.length-t.scale;return`${a}e${o>=0?`+`:``}${o}`},ea=e=>Number(Qi(e)),ta=e=>e.value===Vi,na=e=>e.value<Vi})),ia,aa,oa,sa=v((()=>{Rr(),ia=e=>e>BigInt(2**53-1)||e<BigInt(-(2**53-1))?R():z(Number(e)),aa=e=>{try{return e.trim()===``?R():z(BigInt(e))}catch{return R()}},oa=e=>{if(e>2**53-1||e<-(2**53-1))return R();try{return z(BigInt(e))}catch{return R()}}})),ca,la=v((()=>{ca=e=>!e}));function ua(e,t,n,r,i){for(let a=t;a<Math.min(e.length,t+i);a++)n[r+a-t]=e[a];return n}var da,fa,pa,ma,ha,ga,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba=v((()=>{Pi(),M(),Ne(),S(),Mt(),Xt(),F(),T(),da=Symbol.for(`effect/Chunk`),fa=[],pa=e=>Ee((t,n)=>t.length===n.length&&Ta(t).every((t,r)=>e(t,Aa(n,r)))),ma=pa(A),ha={[da]:{_A:e=>e},toString(){return Ht(this.toJSON())},toJSON(){return{_id:`Chunk`,values:Ta(this).map(Bt)}},[N](){return this.toJSON()},[j](e){return _a(e)&&ma(this,e)},[E](){return k(this,jt(Ta(this)))},[Symbol.iterator](){switch(this.backing._tag){case`IArray`:return this.backing.array[Symbol.iterator]();case`IEmpty`:return fa[Symbol.iterator]();default:return Ta(this)[Symbol.iterator]()}},pipe(){return P(this,arguments)}},ga=e=>{let t=Object.create(ha);switch(t.backing=e,e._tag){case`IEmpty`:t.length=0,t.depth=0,t.left=t,t.right=t;break;case`IConcat`:t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break;case`IArray`:t.length=e.array.length,t.depth=0,t.left=va,t.right=va;break;case`ISingleton`:t.length=1,t.depth=0,t.left=va,t.right=va;break;case`ISlice`:t.length=e.length,t.depth=e.chunk.depth+1,t.left=va,t.right=va}return t},_a=e=>w(e,da),va=ga({_tag:`IEmpty`}),ya=()=>va,ba=(...e)=>ka(e),xa=e=>ga({_tag:`ISingleton`,a:e}),Sa=e=>_a(e)?e:Oa(Ur(e)),Ca=(e,t,n)=>{switch(e.backing._tag){case`IArray`:ua(e.backing.array,0,t,n,e.length);break;case`IConcat`:Ca(e.left,t,n),Ca(e.right,t,n+e.left.length);break;case`ISingleton`:t[n]=e.backing.a;break;case`ISlice`:{let r=0,i=n;for(;r<e.length;)t[i]=Aa(e,r),r+=1,i+=1;break}}},wa=e=>{switch(e.backing._tag){case`IEmpty`:return fa;case`IArray`:return e.backing.array;default:{let t=Array(e.length);return Ca(e,t,0),e.backing={_tag:`IArray`,array:t},e.left=va,e.right=va,e.depth=0,t}}},Ta=wa,Ea=e=>{switch(e.backing._tag){case`IEmpty`:case`ISingleton`:return e;case`IArray`:return ga({_tag:`IArray`,array:fi(e.backing.array)});case`IConcat`:return ga({_tag:`IConcat`,left:Da(e.backing.right),right:Da(e.backing.left)});case`ISlice`:return Oa(fi(Ta(e)))}},Da=Ea,Oa=e=>e.length===0?ya():e.length===1?xa(e[0]):ga({_tag:`IArray`,array:e}),ka=e=>Oa(e),Aa=x(2,(e,t)=>{switch(e.backing._tag){case`IEmpty`:throw Error(`Index out of bounds`);case`ISingleton`:if(t!==0)throw Error(`Index out of bounds`);return e.backing.a;case`IArray`:if(t>=e.length||t<0)throw Error(`Index out of bounds`);return e.backing.array[t];case`IConcat`:return t<e.left.length?Aa(e.left,t):Aa(e.right,t-e.left.length);case`ISlice`:return Aa(e.backing.chunk,t+e.backing.offset)}}),ja=x(2,(e,t)=>Pa(e,xa(t))),Ma=x(2,(e,t)=>Pa(xa(t),e)),Na=x(2,(e,t)=>{if(t<=0)return e;if(t>=e.length)return va;switch(e.backing._tag){case`ISlice`:return ga({_tag:`ISlice`,chunk:e.backing.chunk,offset:e.backing.offset+t,length:e.backing.length-t});case`IConcat`:return t>e.left.length?Na(e.right,t-e.left.length):ga({_tag:`IConcat`,left:Na(e.left,t),right:e.right});default:return ga({_tag:`ISlice`,chunk:e,offset:t,length:e.length-t})}}),Pa=x(2,(e,t)=>{if(e.backing._tag===`IEmpty`)return t;if(t.backing._tag===`IEmpty`)return e;let n=t.depth-e.depth;if(Math.abs(n)<=1)return ga({_tag:`IConcat`,left:e,right:t});if(n<-1){if(e.left.depth>=e.right.depth){let n=Pa(e.right,t);return ga({_tag:`IConcat`,left:e.left,right:n})}{let n=Pa(e.right.right,t);if(n.depth===e.depth-3){let t=ga({_tag:`IConcat`,left:e.right.left,right:n});return ga({_tag:`IConcat`,left:e.left,right:t})}{let t=ga({_tag:`IConcat`,left:e.left,right:e.right.left});return ga({_tag:`IConcat`,left:t,right:n})}}}if(t.right.depth>=t.left.depth){let n=Pa(e,t.left);return ga({_tag:`IConcat`,left:n,right:t.right})}{let n=Pa(e,t.left.left);if(n.depth===t.depth-3){let e=ga({_tag:`IConcat`,left:n,right:t.left.right});return ga({_tag:`IConcat`,left:e,right:t.right})}{let e=ga({_tag:`IConcat`,left:t.left.right,right:t.right});return ga({_tag:`IConcat`,left:n,right:e})}}}),Fa=e=>e.length===0,Ia=e=>e.length>0,La=e=>Aa(e,0),Ra=La,za=e=>Na(e,1)})),Va,Ha,Ua,Wa,Ga=v((()=>{Va=32,Ha=Va-1,Ua=Va/2,Wa=Va/4}));function Ka(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,e+=e>>16,e&127}function qa(e,t){return t>>>e&Ha}function Ja(e){return 1<<e}function Ya(e,t){return Ka(e&t-1)}var Xa=v((()=>{Ga()})),Za,Qa=v((()=>{Za=(e,t)=>({value:e,previous:t})}));function $a(e,t,n,r){let i=r;if(!e){let e=r.length;i=Array(e);for(let t=0;t<e;++t)i[t]=r[t]}return i[t]=n,i}function eo(e,t,n){let r=n.length-1,i=0,a=0,o=n;if(e)i=a=t;else for(o=Array(r);i<t;)o[a++]=n[i++];for(++i;i<=r;)o[a++]=n[i++];return e&&(o.length=r),o}function to(e,t,n,r){let i=r.length;if(e){let e=i;for(;e>=t;)r[e--]=r[e];return r[t]=n,r}let a=0,o=0,s=Array(i+1);for(;a<t;)s[o++]=r[a++];for(s[t]=n;a<i;)s[++o]=r[a++];return s}var no=v((()=>{}));function ro(e){return Je(e,`EmptyNode`)}function io(e){return ro(e)||e._tag===`LeafNode`||e._tag===`CollisionNode`}function ao(e,t){return!ro(e)&&t===e.edit}function oo(e,t,n,r){let i=Array(t-1),a=0,o=0;for(let e=0,t=r.length;e<t;++e)if(e!==n){let t=r[e];t&&!ro(t)&&(i[a++]=t,o|=1<<e)}return new mo(e,o,i)}function so(e,t,n,r,i){let a=[],o=r,s=0;for(let e=0;o;++e)o&1&&(a[e]=i[s++]),o>>>=1;return a[t]=n,new ho(e,s+1,a)}function co(e,t,n,r,i,a){if(n===i)return new po(e,n,[a,r]);let o=qa(t,n),s=qa(t,i);if(o===s)return t=>new mo(e,Ja(o)|Ja(s),[t]);{let t=o<s?[r,a]:[a,r];return new mo(e,Ja(o)|Ja(s),t)}}function lo(e,t,n,r,i,a){let o,s=t;for(;;){let t=co(e,s,n,r,i,a);if(typeof t==`function`)o=Za(t,o),s+=5;else{let e=t;for(;o!=null;)e=o.value(e),o=o.previous;return e}}}var uo,fo,po,mo,ho,go=v((()=>{M(),Rr(),T(),Qa(),no(),Xa(),Ga(),uo=class e{_tag=`EmptyNode`;modify(t,n,r,i,a,o){let s=r(R());return vr(s)?new e:(++o.value,new fo(t,i,a,s))}},fo=class e{edit;hash;key;value;_tag=`LeafNode`;constructor(e,t,n,r){this.edit=e,this.hash=t,this.key=n,this.value=r}modify(t,n,r,i,a,o){if(A(a,this.key)){let n=r(this.value);return n===this.value?this:vr(n)?(--o.value,new uo):ao(this,t)?(this.value=n,this):new e(t,i,a,n)}let s=r(R());return vr(s)?this:(++o.value,lo(t,n,this.hash,this,i,new e(t,i,a,s)))}},po=class e{edit;hash;children;_tag=`CollisionNode`;constructor(e,t,n){this.edit=e,this.hash=t,this.children=n}modify(t,n,r,i,a,o){if(i===this.hash){let n=ao(this,t),i=this.updateCollisionList(n,t,this.hash,this.children,r,a,o);return i===this.children?this:i.length>1?new e(t,this.hash,i):i[0]}let s=r(R());return vr(s)?this:(++o.value,lo(t,n,this.hash,this,i,new fo(t,i,a,s)))}updateCollisionList(e,t,n,r,i,a,o){let s=r.length;for(let c=0;c<s;++c){let s=r[c];if(`key`in s&&A(a,s.key)){let l=s.value,u=i(l);return u===l?r:vr(u)?(--o.value,eo(e,c,r)):$a(e,c,new fo(t,n,a,u),r)}}let c=i(R());return vr(c)?r:(++o.value,$a(e,s,new fo(t,n,a,c),r))}},mo=class e{edit;mask;children;_tag=`IndexedNode`;constructor(e,t,n){this.edit=e,this.mask=t,this.children=n}modify(t,n,r,i,a,o){let s=this.mask,c=this.children,l=qa(n,i),u=Ja(l),d=Ya(s,u),f=s&u,p=ao(this,t);if(!f){let f=new uo().modify(t,n+5,r,i,a,o);return f?c.length>=Ua?so(t,l,f,s,c):new e(t,s|u,to(p,d,f,c)):this}let m=c[d],h=m.modify(t,n+5,r,i,a,o);if(m===h)return this;let g=s,_;if(ro(h)){if(g&=~u,!g)return new uo;if(c.length<=2&&io(c[d^1]))return c[d^1];_=eo(p,d,c)}else _=$a(p,d,h,c);return p?(this.mask=g,this.children=_,this):new e(t,g,_)}},ho=class e{edit;size;children;_tag=`ArrayNode`;constructor(e,t,n){this.edit=e,this.size=t,this.children=n}modify(t,n,r,i,a,o){let s=this.size,c=this.children,l=qa(n,i),u=c[l],d=(u||new uo).modify(t,n+5,r,i,a,o);if(u===d)return this;let f=ao(this,t),p;if(ro(u)&&!ro(d))++s,p=$a(f,l,d,c);else if(!ro(u)&&ro(d)){if(--s,s<=Wa)return oo(t,s,l,c);p=$a(f,l,new uo,c)}else p=$a(f,l,d,c);return f?(this.size=s,this.children=p,this):new e(t,s,p)}}})),_o,vo,yo,bo,xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro,zo,Bo,Vo,Ho,Uo,Wo,Go=v((()=>{M(),S(),Mt(),Xt(),Rr(),F(),T(),Xa(),Ga(),go(),_o=`effect/HashMap`,vo=Symbol.for(_o),yo={[vo]:vo,[Symbol.iterator](){return new xo(this,(e,t)=>[e,t])},[E](){let e=D(_o);for(let t of this)e^=b(D(t[0]),O(D(t[1])));return k(this,e)},[j](e){if(Oo(e)){if(e._size!==this._size)return!1;for(let t of this){let n=b(e,jo(t[0],D(t[0])));if(vr(n)||!A(t[1],n.value))return!1}return!0}return!1},toString(){return Ht(this.toJSON())},toJSON(){return{_id:`HashMap`,values:Array.from(this).map(Bt)}},[N](){return this.toJSON()},pipe(){return P(this,arguments)}},bo=(e,t,n,r)=>{let i=Object.create(yo);return i._editable=e,i._edit=t,i._root=n,i._size=r,i},xo=class e{map;f;v;constructor(e,t){this.map=e,this.f=t,this.v=Co(this.map._root,this.f,void 0)}next(){if(vr(this.v))return{done:!0,value:void 0};let e=this.v.value;return this.v=So(e.cont),{done:!1,value:e.value}}[Symbol.iterator](){return new e(this.map,this.f)}},So=e=>e?wo(e[0],e[1],e[2],e[3],e[4]):R(),Co=(e,t,n=void 0)=>{switch(e._tag){case`LeafNode`:return yr(e.value)?z({value:t(e.key,e.value.value),cont:n}):So(n);case`CollisionNode`:case`ArrayNode`:case`IndexedNode`:{let r=e.children;return wo(r.length,r,0,t,n)}default:return So(n)}},wo=(e,t,n,r,i)=>{for(;n<e;){let a=t[n++];if(a&&!ro(a))return Co(a,r,[e,t,n,r,i])}return So(i)},To=bo(!1,0,new uo,0),Eo=()=>To,Do=e=>{let t=Lo(Eo());for(let n of e)No(t,n[0],n[1]);return Ro(t)},Oo=e=>w(e,vo),ko=e=>e&&ro(e._root),Ao=x(2,(e,t)=>jo(e,t,D(t))),jo=x(3,(e,t,n)=>{let r=e._root,i=0;for(;;)switch(r._tag){case`LeafNode`:return A(t,r.key)?r.value:R();case`CollisionNode`:if(n===r.hash){let e=r.children;for(let n=0,r=e.length;n<r;++n){let r=e[n];if(`key`in r&&A(t,r.key))return r.value}}return R();case`IndexedNode`:{let e=Ja(qa(i,n));if(r.mask&e){r=r.children[Ya(r.mask,e)],i+=5;break}return R()}case`ArrayNode`:if(r=r.children[qa(i,n)],r){i+=5;break}return R();default:return R()}}),Mo=x(2,(e,t)=>yr(jo(e,t,D(t)))),No=x(3,(e,t,n)=>zo(e,t,()=>z(n))),Po=x(3,(e,t,n)=>e._editable?(e._root=t,e._size=n,e):t===e._root?e:bo(e._editable,e._edit,t,n)),Fo=e=>new xo(e,e=>e),Io=e=>e._size,Lo=e=>bo(!0,e._edit+1,e._root,e._size),Ro=e=>(e._editable=!1,e),zo=x(3,(e,t,n)=>Bo(e,t,D(t),n)),Bo=x(4,(e,t,n,r)=>{let i={value:e._size},a=e._root.modify(e._editable?e._edit:NaN,0,r,n,t,i);return b(e,Po(a,i.value))}),Vo=x(2,(e,t)=>zo(e,t,R)),Ho=x(2,(e,t)=>Wo(e,Eo(),(e,n,r)=>No(e,r,t(n,r)))),Uo=x(2,(e,t)=>Wo(e,void 0,(e,n,r)=>t(n,r))),Wo=x(3,(e,t,n)=>{let r=e._root;if(r._tag===`LeafNode`)return yr(r.value)?n(t,r.value.value,r.key):t;if(r._tag===`EmptyNode`)return t;let i=[r.children],a;for(;a=i.pop();)for(let e=0,r=a.length;e<r;){let r=a[e++];r&&!ro(r)&&(r._tag===`LeafNode`?yr(r.value)&&(t=n(t,r.value.value,r.key)):i.push(r.children))}return t})})),Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs,is,as,os,ss,cs,ls,us,ds,fs=v((()=>{M(),S(),Mt(),Xt(),F(),T(),Go(),Ko=`effect/HashSet`,qo=Symbol.for(Ko),Jo={[qo]:qo,[Symbol.iterator](){return Fo(this._keyMap)},[E](){return k(this,O(D(this._keyMap))(D(Ko)))},[j](e){return Xo(e)?Io(this._keyMap)===Io(e._keyMap)&&A(this._keyMap,e._keyMap):!1},toString(){return Ht(this.toJSON())},toJSON(){return{_id:`HashSet`,values:Array.from(this).map(Bt)}},[N](){return this.toJSON()},pipe(){return P(this,arguments)}},Yo=e=>{let t=Object.create(Jo);return t._keyMap=e,t},Xo=e=>w(e,qo),Zo=Yo(Eo()),Qo=()=>Zo,$o=e=>{let t=rs(Qo());for(let n of e)os(t,n);return is(t)},es=(...e)=>{let t=rs(Qo());for(let n of e)os(t,n);return is(t)},ts=x(2,(e,t)=>Mo(e._keyMap,t)),ns=e=>Io(e._keyMap),rs=e=>Yo(Lo(e._keyMap)),is=e=>(e._keyMap._editable=!1,e),as=x(2,(e,t)=>{let n=rs(e);return t(n),is(n)}),os=x(2,(e,t)=>e._keyMap._editable?(No(t,!0)(e._keyMap),e):Yo(No(t,!0)(e._keyMap))),ss=x(2,(e,t)=>e._keyMap._editable?(Vo(t)(e._keyMap),e):Yo(Vo(t)(e._keyMap))),cs=x(2,(e,t)=>as(e,e=>{for(let n of t)ss(e,n)})),ls=x(2,(e,t)=>as(Qo(),n=>{us(e,e=>os(n,e));for(let e of t)os(n,e)})),us=x(2,(e,t)=>Uo(e._keyMap,(e,n)=>t(n))),ds=x(3,(e,t,n)=>Wo(e._keyMap,t,(e,t,r)=>n(e,r)))})),ps,ms,hs,gs,_s,vs,ys,bs,xs,Ss,Cs=v((()=>{fs(),ps=Qo,ms=$o,hs=es,gs=ts,_s=ns,vs=os,ys=ss,bs=cs,xs=ls,Ss=ds})),ws,Ts,Es,Ds,Os,ks=v((()=>{ws=`Empty`,Ts=`Fail`,Es=`Interrupt`,Ds=`Parallel`,Os=`Sequential`})),As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s,ec,tc,nc,rc,ic,ac,oc,sc,cc,lc,uc,dc,fc,pc,mc,hc,gc,_c,vc,yc,bc=v((()=>{Pi(),Ba(),lr(),M(),S(),Ie(),Mt(),Cs(),Xt(),Rr(),F(),T(),rt(),ks(),As=`effect/Cause`,js=Symbol.for(As),Ms={_E:e=>e},Ns={[js]:Ms,[E](){return b(D(As),O(D(tc(this))),k(this))},[j](e){return Bs(e)&&ec(this,e)},pipe(){return P(this,arguments)},toJSON(){switch(this._tag){case`Empty`:return{_id:`Cause`,_tag:this._tag};case`Die`:return{_id:`Cause`,_tag:this._tag,defect:Bt(this.defect)};case`Interrupt`:return{_id:`Cause`,_tag:this._tag,fiberId:this.fiberId.toJSON()};case`Fail`:return{_id:`Cause`,_tag:this._tag,failure:Bt(this.error)};case`Sequential`:case`Parallel`:return{_id:`Cause`,_tag:this._tag,left:Bt(this.left),right:Bt(this.right)}}},toString(){return dc(this)},[N](){return this.toJSON()}},Ps=(()=>{let e=Object.create(Ns);return e._tag=ws,e})(),Fs=e=>{let t=Object.create(Ns);return t._tag=Ts,t.error=e,t},Is=e=>{let t=Object.create(Ns);return t._tag=`Die`,t.defect=e,t},Ls=e=>{let t=Object.create(Ns);return t._tag=Es,t.fiberId=e,t},Rs=(e,t)=>{let n=Object.create(Ns);return n._tag=Ds,n.left=e,n.right=t,n},zs=(e,t)=>{let n=Object.create(Ns);return n._tag=Os,n.left=e,n.right=t,n},Bs=e=>w(e,js),Vs=e=>e._tag===ws,Hs=e=>e._tag===Ts,Us=e=>e._tag===`Empty`||lc(e,!0,(e,t)=>{switch(t._tag){case ws:return z(e);case`Die`:case Ts:case Es:return z(!1);default:return R()}}),Ws=e=>yr(Zs(e)),Gs=e=>uc(void 0,ac)(e),Ks=e=>Da(lc(e,ya(),(e,t)=>t._tag===`Fail`?z(b(e,Ma(t.error))):R())),qs=e=>Da(lc(e,ya(),(e,t)=>t._tag===`Die`?z(b(e,Ma(t.defect))):R())),Js=e=>lc(e,ps(),(e,t)=>t._tag===`Interrupt`?z(b(e,vs(t.fiberId))):R()),Ys=e=>rc(e,e=>e._tag===`Fail`?z(e.error):R()),Xs=e=>{let t=Ys(e);switch(t._tag){case`None`:return I(e);case`Some`:return L(t.value)}},Zs=e=>rc(e,e=>e._tag===`Interrupt`?z(e.fiberId):R()),Qs=e=>cc(e,{onEmpty:Ps,onFail:()=>Ps,onDie:Is,onInterrupt:Ls,onSequential:zs,onParallel:Rs}),$s=e=>cc(e,{onEmpty:Ps,onFail:Is,onDie:Is,onInterrupt:Ls,onSequential:zs,onParallel:Rs}),ec=(e,t)=>{let n=xa(e),r=xa(t);for(;Ia(n)&&Ia(r);){let[e,t]=b(Ra(n),lc([ps(),ya()],([e,t],n)=>{let[r,i]=ic(n);return z([b(e,xs(r)),b(t,Pa(i))])})),[i,a]=b(Ra(r),lc([ps(),ya()],([e,t],n)=>{let[r,i]=ic(n);return z([b(e,xs(r)),b(t,Pa(i))])}));if(!A(e,i))return!1;n=t,r=a}return!0},tc=e=>nc(xa(e),ya()),nc=(e,t)=>{for(;;){let[n,r]=b(e,Oi([ps(),ya()],([e,t],n)=>{let[r,i]=ic(n);return[b(e,xs(r)),b(t,Pa(i))]})),i=_s(n)>0?b(t,Ma(n)):t;if(Fa(r))return Da(i);e=r,t=i}throw Error(nt(`Cause.flattenCauseLoop`))},rc=x(2,(e,t)=>{let n=[e];for(;n.length>0;){let e=n.pop(),r=t(e);switch(r._tag){case`None`:switch(e._tag){case Os:case Ds:n.push(e.right),n.push(e.left)}break;case`Some`:return r}}return R()}),ic=e=>{let t=e,n=[],r=ps(),i=ya();for(;t!==void 0;)switch(t._tag){case ws:if(n.length===0)return[r,i];t=n.pop();break;case Ts:if(r=vs(r,ba(t._tag,t.error)),n.length===0)return[r,i];t=n.pop();break;case`Die`:if(r=vs(r,ba(t._tag,t.defect)),n.length===0)return[r,i];t=n.pop();break;case Es:if(r=vs(r,ba(t._tag,t.fiberId)),n.length===0)return[r,i];t=n.pop();break;case Os:switch(t.left._tag){case ws:t=t.right;break;case Os:t=zs(t.left.left,zs(t.left.right,t.right));break;case Ds:t=Rs(zs(t.left.left,t.right),zs(t.left.right,t.right));break;default:i=Ma(i,t.right),t=t.left}break;case Ds:n.push(t.right),t=t.left}throw Error(nt(`Cause.evaluateCauseLoop`))},ac={emptyCase:Se,failCase:Ce,dieCase:Ce,interruptCase:Se,sequentialCase:(e,t,n)=>t&&n,parallelCase:(e,t,n)=>t&&n},oc=`SequentialCase`,sc=`ParallelCase`,cc=x(2,(e,{onDie:t,onEmpty:n,onFail:r,onInterrupt:i,onParallel:a,onSequential:o})=>uc(e,void 0,{emptyCase:()=>n,failCase:(e,t)=>r(t),dieCase:(e,n)=>t(n),interruptCase:(e,t)=>i(t),sequentialCase:(e,t,n)=>o(t,n),parallelCase:(e,t,n)=>a(t,n)})),lc=x(3,(e,t,n)=>{let r=t,i=e,a=[];for(;i!==void 0;){let e=n(r,i);switch(r=yr(e)?e.value:r,i._tag){case Os:a.push(i.right),i=i.left;break;case Ds:a.push(i.right),i=i.left;break;default:i=void 0}i===void 0&&a.length>0&&(i=a.pop())}return r}),uc=x(3,(e,t,n)=>{let r=[e],i=[];for(;r.length>0;){let e=r.pop();switch(e._tag){case ws:i.push(I(n.emptyCase(t)));break;case Ts:i.push(I(n.failCase(t,e.error)));break;case`Die`:i.push(I(n.dieCase(t,e.defect)));break;case Es:i.push(I(n.interruptCase(t,e.fiberId)));break;case Os:r.push(e.right),r.push(e.left),i.push(L({_tag:oc}));break;case Ds:r.push(e.right),r.push(e.left),i.push(L({_tag:sc}))}}let a=[];for(;i.length>0;){let e=i.pop();switch(e._tag){case`Left`:switch(e.left._tag){case oc:{let e=a.pop(),r=a.pop(),i=n.sequentialCase(t,e,r);a.push(i);break}case sc:{let e=a.pop(),r=a.pop(),i=n.parallelCase(t,e,r);a.push(i);break}}break;case`Right`:a.push(e.right)}}if(a.length===0)throw Error(`BUG: Cause.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues`);return a.pop()}),dc=(e,t)=>Gs(e)?`All fibers interrupted without errors.`:yc(e).map(function(e){return t?.renderErrorCause!==!0||e.cause===void 0?e.stack:`${e.stack} {\n${fc(e.cause,` `)}\n}`}).join(`
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
// @bun
|
|
3
|
+
var x=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};function zr(e,t=new WeakSet){if(t.has(e))return;t.add(e);for(let r of Reflect.ownKeys(e)){let n=Object.getOwnPropertyDescriptor(e,r);if(n&&"value"in n&&qf(n.value))zr(n.value,t)}Object.freeze(e)}function qf(e){return typeof e==="object"&&e!==null}var xn="0.15",Tr="state-0.16";var Lb=()=>{};function Ki(e){return{ok:!0,value:e}}function Ko(e){return{ok:!1,error:e}}function ps(e,t){return new Je("invalid_input",`Invalid ${e}.`,{field:e},t===void 0?void 0:{cause:t})}var Je;var Wi=x(()=>{Je=class Je extends Error{code;details;constructor(e,t,r={},n){super(t,n);this.name="CoreError",this.code=e,this.details=r,zr(this.details),Object.freeze(this)}}});function g(e,t,r,n,o,i,a,s,c){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return r(t(e));case 4:return n(r(t(e)));case 5:return o(n(r(t(e))));case 6:return i(o(n(r(t(e)))));case 7:return a(i(o(n(r(t(e))))));case 8:return s(a(i(o(n(r(t(e)))))));case 9:return c(s(a(i(o(n(r(t(e))))))));default:{let l=arguments[0];for(let u=1;u<arguments.length;u++)l=arguments[u](l);return l}}}var Uf=(e)=>typeof e==="function",d=function(e,t){if(typeof e==="function")return function(){if(e(arguments))return t.apply(this,arguments);return(r)=>t(r,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(r,n){if(arguments.length>=2)return t(r,n);return function(o){return t(o,r)}};case 3:return function(r,n,o){if(arguments.length>=3)return t(r,n,o);return function(i){return t(i,r,n)}};case 4:return function(r,n,o,i){if(arguments.length>=4)return t(r,n,o,i);return function(a){return t(a,r,n,o)}};case 5:return function(r,n,o,i,a){if(arguments.length>=5)return t(r,n,o,i,a);return function(s){return t(s,r,n,o,i)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(n){return t(n,...r)}}}},ce=(e)=>e,ds=(e)=>()=>e,fs,Qn,Dl,ms;var H=x(()=>{fs=ds(!0),Qn=ds(!1),Dl=ds(void 0),ms=Dl});var gs=(e)=>(t,r)=>t===r||e(t,r),HI=(e,t)=>e===t,$I=()=>HI,jI,Hf,Db,qb=(e)=>gs((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e(t[n],r[n]))return!1;return!0});var ys=x(()=>{H();jI=$I(),Hf=d(2,(e,t)=>gs((r,n)=>e(t(r),t(n)))),Db=Hf(jI,(e)=>e.getTime())});var xs,j=(e,t)=>{if(!xs)globalThis["effect/GlobalValue"]??=new Map,xs=globalThis["effect/GlobalValue"];if(!xs.has(e))xs.set(e,t());return xs.get(e)};var xt=(e)=>typeof e==="string",Xt=(e)=>typeof e==="number",Wo=(e)=>typeof e==="boolean",eo=(e)=>typeof e==="bigint",Jo=(e)=>typeof e==="symbol",to,Ub=(e)=>e===void 0,Hb=(e)=>!1,Ss=(e)=>typeof e==="object"&&e!==null,Dt=(e)=>Ss(e)||to(e),k,bs,Go=(e)=>e===null||e===void 0,$b=(e)=>e!==null&&e!==void 0,Ul=(e)=>e instanceof Date,$f=(e)=>typeof e==="string"||k(e,Symbol.iterator),jf=(e)=>Ss(e)&&!Array.isArray(e),jb=(e)=>k(e,"then")&&to(e.then);var ge=x(()=>{H();to=Uf,k=d(2,(e,t)=>Dt(e)&&(t in e)),bs=d(2,(e,t)=>k(e,"_tag")&&e._tag===t)});var Yo=(e)=>`BUG: ${e} - please report an issue at https://github.com/Effect-TS/effect/issues`;class Vf{_state;constructor(e,t,r,n){if(Go(t)&&Go(e))t=Math.random()*4294967295>>>0,e=0;else if(Go(t))t=e,e=0;if(Go(n)&&Go(r))n=this._state?this._state[3]:VI,r=this._state?this._state[2]:BI;else if(Go(n))n=r,r=0;return this._state=new Int32Array([0,0,r>>>0,((n||0)|1)>>>0]),this._next(),Bb(this._state,this._state[0],this._state[1],e>>>0,t>>>0),this._next(),this}getState(){return[this._state[0],this._state[1],this._state[2],this._state[3]]}setState(e){this._state[0]=e[0],this._state[1]=e[1],this._state[2]=e[2],this._state[3]=e[3]|1}integer(e){return Math.round(this.number()*Number.MAX_SAFE_INTEGER)%e}number(){let e=(this._next()&67108863)*1,t=(this._next()&134217727)*1;return(e*JI+t)/WI}_next(){let e=this._state[0]>>>0,t=this._state[1]>>>0;GI(this._state,e,t,zI,KI),Bb(this._state,this._state[0],this._state[1],this._state[2],this._state[3]);let r=e>>>18,n=(t>>>18|e<<14)>>>0;r=(r^e)>>>0,n=(n^t)>>>0;let o=(n>>>27|r<<5)>>>0,i=e>>>27,a=(-i>>>0&31)>>>0;return(o>>>i|o<<a)>>>0}}function GI(e,t,r,n,o){let i=(r>>>16)*(o&65535)>>>0,a=(r&65535)*(o>>>16)>>>0,s=(r&65535)*(o&65535)>>>0,c=(r>>>16)*(o>>>16)+((a>>>16)+(i>>>16))>>>0;if(a=a<<16>>>0,s=s+a>>>0,s>>>0<a>>>0)c=c+1>>>0;if(i=i<<16>>>0,s=s+i>>>0,s>>>0<i>>>0)c=c+1>>>0;c=c+Math.imul(r,n)>>>0,c=c+Math.imul(t,o)>>>0,e[0]=c,e[1]=s}function Bb(e,t,r,n,o){let i=t+n>>>0,a=r+o>>>0;if(a>>>0<r>>>0)i=i+1|0;e[0]=i,e[1]=a}function zf(e){if(typeof e==="object"&&e!==null&&Bf in e)return e[Bf]();throw Error(Yo("yieldWrapGet"))}var Gi,BI=335903614,VI=4150755663,zI=1481765933,KI=1284865837,WI=9007199254740992,JI=134217728,Bf,Sn,Ht,Vb,YI,ZI,St,a1;var ro=x(()=>{ge();Gi=class Gi{self;called=!1;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(e){return{value:e,done:!0}}throw(e){throw e}[Symbol.iterator](){return new Gi(this.self)}};Bf=Symbol.for("effect/Utils/YieldWrap");Sn=class Sn{#e;constructor(e){this.#e=e}[Bf](){return this.#e}};Ht=j("effect/Utils/isStructuralRegion",()=>({enabled:!1,tester:void 0})),Vb={effect_internal_function:(e)=>e()},YI={effect_internal_function:(e)=>{try{return e()}finally{}}},ZI=Vb.effect_internal_function(()=>Error().stack)?.includes("effect_internal_function")===!0,St=ZI?Vb.effect_internal_function:YI.effect_internal_function,a1=function*(){}.constructor});var Kf,M,v=(e)=>{if(Ht.enabled===!0)return 0;switch(typeof e){case"number":return $l(e);case"bigint":return me(e.toString(10));case"boolean":return me(String(e));case"symbol":return me(String(e));case"string":return me(e);case"undefined":return me("undefined");case"function":case"object":if(e===null)return me("null");else if(e instanceof Date){if(Number.isNaN(e.getTime()))return me("Invalid Date");return v(e.toISOString())}else if(e instanceof URL)return v(e.href);else if(QI(e))return e[M]();else return _s(e);default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},_s=(e)=>{if(!Kf.has(e))Kf.set(e,$l(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)));return Kf.get(e)},J=(e)=>(t)=>t*53^e,Hl=(e)=>e&3221225471|e>>>1&1073741824,QI=(e)=>k(e,M),$l=(e)=>{if(e!==e||e===1/0)return 0;let t=e|0;if(t!==e)t^=e*4294967295;while(e>4294967295)t^=e/=4294967295;return Hl(t)},me=(e)=>{let t=5381,r=e.length;while(r)t=t*33^e.charCodeAt(--r);return Hl(t)},eM=(e,t)=>{let r=12289;for(let n=0;n<t.length;n++)r^=g(me(t[n]),J(v(e[t[n]])));return Hl(r)},jl=(e)=>eM(e,Object.keys(e)),Qt=(e)=>{let t=6151;for(let r=0;r<e.length;r++)t=g(t,J(v(e[r])));return Hl(t)},oe=function(){if(arguments.length===1){let r=arguments[0];return function(n){return Object.defineProperty(r,M,{value(){return n},enumerable:!1}),n}}let e=arguments[0],t=arguments[1];return Object.defineProperty(e,M,{value(){return t},enumerable:!1}),t};var Me=x(()=>{H();ge();ro();Kf=j(Symbol.for("effect/Hash/randomHashCache"),()=>new WeakMap),M=Symbol.for("effect/Hash")});function O(){if(arguments.length===1)return(e)=>Bl(e,arguments[0]);return Bl(arguments[0],arguments[1])}function Bl(e,t){if(e===t)return!0;let r=typeof e;if(r!==typeof t)return!1;if(r==="object"||r==="function"){if(e!==null&&t!==null){if(ws(e)&&ws(t))if(v(e)===v(t)&&e[I](t))return!0;else return Ht.enabled&&Ht.tester?Ht.tester(e,t):!1;else if(e instanceof Date&&t instanceof Date){let n=e.getTime(),o=t.getTime();return n===o||Number.isNaN(n)&&Number.isNaN(o)}else if(e instanceof URL&&t instanceof URL)return e.href===t.href}if(Ht.enabled){if(e===null||t===null)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,o)=>Bl(n,t[o]));if(Object.getPrototypeOf(e)===Object.prototype&&Object.getPrototypeOf(t)===Object.prototype){let n=Object.keys(e),o=Object.keys(t);if(n.length===o.length){for(let i of n)if(!((i in t)&&Bl(e[i],t[i])))return Ht.tester?Ht.tester(e,t):!1;return!0}}return Ht.tester?Ht.tester(e,t):!1}}return Ht.enabled&&Ht.tester?Ht.tester(e,t):!1}var I,ws=(e)=>k(e,I),Ts=()=>O;var le=x(()=>{Me();ge();ro();I=Symbol.for("effect/Equal")});function tM(e){try{return e.toISOString()}catch{return"Invalid Date"}}function rM(e){try{let t=e.toString();return typeof t==="string"?t:String(t)}catch{return"[toString threw]"}}function Es(e){return xt(e)?JSON.stringify(e):String(e)}function Kr(e,t){let r=t?.space??0,n=new WeakSet,o=!r?"":Xt(r)?" ".repeat(r):r,i=(l)=>o.repeat(l),a=(l,u)=>{let p=l?.constructor;return p&&p!==Object.prototype.constructor&&p.name?`${p.name}(${u})`:u},s=(l)=>{try{return Reflect.ownKeys(l)}catch{return["[ownKeys threw]"]}};function c(l,u=0){if(Array.isArray(l)){if(n.has(l))return Wf;if(n.add(l),!o||l.length<=1)return`[${l.map((f)=>c(f,u)).join(",")}]`;let p=l.map((f)=>c(f,u+1)).join(`,
|
|
4
|
+
`+i(u+1));return`[
|
|
5
|
+
${i(u+1)}${p}
|
|
6
|
+
${i(u)}]`}if(Ul(l))return tM(l);if(!t?.ignoreToString&&k(l,"toString")&&to(l.toString)&&l.toString!==Object.prototype.toString&&l.toString!==Array.prototype.toString){let p=rM(l);if(l instanceof Error&&l.cause)return`${p} (cause: ${c(l.cause,u)})`;return p}if(xt(l))return JSON.stringify(l);if(Xt(l)||l==null||Wo(l)||Jo(l))return String(l);if(eo(l))return String(l)+"n";if(l instanceof Set||l instanceof Map){if(n.has(l))return Wf;return n.add(l),`${l.constructor.name}(${c(Array.from(l),u)})`}if(Dt(l)){if(n.has(l))return Wf;n.add(l);let p=s(l);if(!o||p.length<=1){let h=`{${p.map((m)=>`${Es(m)}:${c(l[m],u)}`).join(",")}}`;return a(l,h)}let f=`{
|
|
7
|
+
${p.map((h)=>`${i(u+1)}${Es(h)}: ${c(l[h],u+1)}`).join(`,
|
|
8
|
+
`)}
|
|
9
|
+
${i(u)}}`;return a(l,f)}return String(l)}return c(e,0)}var re,ue=(e)=>{try{if(k(e,"toJSON")&&to(e.toJSON)&&e.toJSON.length===0)return e.toJSON();else if(Array.isArray(e))return e.map(ue)}catch{return{}}return Wb(e)},Wf="[Circular]",he=(e)=>JSON.stringify(e,null,2),m1,bn=(e,t=2)=>{if(typeof e==="string")return e;try{return typeof e==="object"?Vl(e,t):String(e)}catch{return String(e)}},Vl=(e,t)=>{let r=[],n=JSON.stringify(e,(o,i)=>typeof i==="object"&&i!==null?r.includes(i)?void 0:r.push(i)&&(Zo.fiberRefs!==void 0&&zb(i)?i[Jf](Zo.fiberRefs):i):i,t);return r=void 0,n},Jf,zb=(e)=>typeof e==="object"&&e!==null&&(Jf in e),Zo,Kb=(e,t)=>{let r=Zo.fiberRefs;Zo.fiberRefs=e;try{return t()}finally{Zo.fiberRefs=r}},Wb=(e)=>{if(zb(e)&&Zo.fiberRefs!==void 0)return e[Jf](Zo.fiberRefs);return e};var Be=x(()=>{ge();re=Symbol.for("nodejs.util.inspect.custom");m1={toJSON(){return ue(this)},[re](){return this.toJSON()},toString(){return he(this.toJSON())}},Jf=Symbol.for("effect/Inspectable/Redactable"),Zo=j("effect/Inspectable/redactableState",()=>({fiberRefs:void 0}))});var E=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let r=e;for(let n=0,o=t.length;n<o;n++)r=t[n](r);return r}}};var _e=()=>{};var Qo="Async",ei="Commit",$t="Failure",vs="OnFailure",Yi="OnSuccess",Zi="OnSuccessAndFailure",jt="Success",zl="Sync",Jb="Tag",ti="UpdateRuntimeFlags",Xi="While",Qi="Iterator",Kl="WithRuntime",ea="Yield",Os="RevertFlags";var nM="3.22.1",Rs=()=>nM;var Yb,Zb,Xb,Qb,no,oM,iM,_n,ks,oo,Yf,e_;var wn=x(()=>{le();Me();_e();ro();Yb=Symbol.for("effect/Effect"),Zb=Symbol.for("effect/Stream"),Xb=Symbol.for("effect/Sink"),Qb=Symbol.for("effect/Channel"),no={_R:(e)=>e,_E:(e)=>e,_A:(e)=>e,_V:Rs()},oM={_A:(e)=>e,_In:(e)=>e,_L:(e)=>e,_E:(e)=>e,_R:(e)=>e},iM={_Env:(e)=>e,_InErr:(e)=>e,_InElem:(e)=>e,_InDone:(e)=>e,_OutErr:(e)=>e,_OutElem:(e)=>e,_OutDone:(e)=>e},_n={[Yb]:no,[Zb]:no,[Xb]:oM,[Qb]:iM,[I](e){return this===e},[M](){return oe(this,_s(this))},[Symbol.iterator](){return new Gi(new Sn(this))},pipe(){return E(this,arguments)}},ks={[M](){return oe(this,jl(this))},[I](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n of t)if(!((n in e)&&O(this[n],e[n])))return!1;return!0}},oo={..._n,_op:ei},Yf={...oo,...ks},e_=function(){function e(){}return e.prototype=oo,e}()});var r_,n_,aM,sM,cM,Zf=(e)=>k(e,r_),Xf=(e)=>e._tag==="None",Qf=(e)=>e._tag==="Some",Wl,Cs=(e)=>{let t=Object.create(aM);return t.value=e,t};var em=x(()=>{le();Me();Be();ge();wn();r_=Symbol.for("effect/Option"),n_={..._n,[r_]:{_A:(e)=>e},[re](){return this.toJSON()},toString(){return he(this.toJSON())}},aM=Object.assign(Object.create(n_),{_tag:"Some",_op:"Some",[I](e){return Zf(e)&&Qf(e)&&O(this.value,e.value)},[M](){return oe(this,J(v(this._tag))(v(this.value)))},toJSON(){return{_id:"Option",_tag:this._tag,value:ue(this.value)}}}),sM=v("None"),cM=Object.assign(Object.create(n_),{_tag:"None",_op:"None",[I](e){return Zf(e)&&Xf(e)},[M](){return sM},toJSON(){return{_id:"Option",_tag:this._tag}}}),Wl=Object.create(cM)});var tm,i_,lM,uM,Jl=(e)=>k(e,tm),rm=(e)=>e._tag==="Left",nm=(e)=>e._tag==="Right",a_=(e)=>{let t=Object.create(uM);return t.left=e,t},s_=(e)=>{let t=Object.create(lM);return t.right=e,t};var c_=x(()=>{le();Me();Be();ge();wn();tm=Symbol.for("effect/Either"),i_={..._n,[tm]:{_R:(e)=>e},[re](){return this.toJSON()},toString(){return he(this.toJSON())}},lM=Object.assign(Object.create(i_),{_tag:"Right",_op:"Right",[I](e){return Jl(e)&&nm(e)&&O(this.right,e.right)},[M](){return J(v(this._tag))(v(this.right))},toJSON(){return{_id:"Either",_tag:this._tag,right:ue(this.right)}}}),uM=Object.assign(Object.create(i_),{_tag:"Left",_op:"Left",[I](e){return Jl(e)&&rm(e)&&O(this.left,e.left)},[M](){return J(v(this._tag))(v(this.left))},toJSON(){return{_id:"Either",_tag:this._tag,left:ue(this.left)}}})});var Z,K,om,Ee,Rt,Gl,l_,As,u_,im,p_;var er=x(()=>{H();c_();Z=s_,K=a_,om=Jl,Ee=rm,Rt=nm,Gl=d(2,(e,t)=>Ee(e)?K(t(e.left)):Z(e.right)),l_=d(2,(e,t)=>Rt(e)?Z(t(e.right)):K(e.left)),As=d(2,(e,{onLeft:t,onRight:r})=>Ee(e)?t(e.left):r(e.right)),u_=As({onLeft:ce,onRight:ce}),im=d(2,(e,t)=>{if(Rt(e))return e.right;throw t(e.left)}),p_=im(()=>Error("getOrThrow called on a Left"))});var am=(e)=>e.length>0;var d_=(e)=>(t,r)=>t===r?0:e(t,r),f_,Yl,sm=(e)=>d(2,(t,r)=>e(t,r)===1);var Zl=x(()=>{H();f_=d_((e,t)=>e<t?-1:1),Yl=d(2,(e,t)=>d_((r,n)=>e(t(r),t(n))))});var C=()=>Wl,N,Ne,Re,Ge,ve,Er,m_,Tn=(e)=>e==null?C():N(e),Bt,h_=(e)=>(...t)=>{try{return N(e(...t))}catch{return C()}},vr,Or,g_,mM=(e)=>d(2,(t,r)=>Ne(t)?!1:e(t.value,r)),hM,y_,x_;var Ye=x(()=>{le();H();em();N=Cs,Ne=Xf,Re=Qf,Ge=d(2,(e,{onNone:t,onSome:r})=>Ne(e)?t():r(e.value)),ve=d(2,(e,t)=>Ne(e)?t():e.value),Er=d(2,(e,t)=>Ne(e)?t():e),m_=d(2,(e,t)=>Ne(e)?N(t()):e),Bt=ve(Dl),vr=d(2,(e,t)=>Ne(e)?C():N(t(e.value))),Or=d(2,(e,t)=>Ne(e)?C():t(e.value)),g_=d(2,(e,t)=>Ne(e)?C():Tn(t(e.value))),hM=Ts(),y_=mM(hM),x_=d(2,(e,t)=>Ne(e)?!1:t(e.value))});var S_=(...e)=>e;var b_=()=>{};var ri=(e)=>Array(e),lm,ke=(e)=>Array.isArray(e)?e:Array.from(e),um=(e)=>Array.isArray(e)?e:[e],__,ta,w_,pm,dm,yM=(e)=>e.length===0,T_,io,we,E_=(e,t)=>e<0||e>=t.length,xM=(e,t)=>Math.floor(Math.min(Math.max(0,e),t.length)),SM,fm,En,tt,v_=(e)=>we(e)?N(mm(e)):C(),mm=(e)=>e[e.length-1],Rr=(e)=>e.slice(1),bM=(e,t)=>{let r=0;for(let n of e){if(!t(n,r))break;r++}return r},O_,R_,hm=(e)=>Array.from(e).reverse(),vn,gm,k_,_M,wM,TM,ra=(e)=>e.slice(),EM,ao,On=()=>[],kt=(e)=>[e],kr,Ps,Xl,Ql,na,ym=(e,t)=>{let r=[],n=e,o;while(Re(o=t(n))){let[i,a]=o.value;r.push(i),n=a}return r},so,C_,xm=(e)=>C_(e,Ts()),Rn;var Ve=x(()=>{le();ys();H();Ye();b_();lm=d(2,(e,t)=>{let r=Math.max(1,Math.floor(e)),n=Array(r);for(let o=0;o<r;o++)n[o]=t(o);return n}),__=d(2,(e,{onEmpty:t,onNonEmpty:r})=>we(e)?r(tt(e),Rr(e)):t()),ta=d(2,(e,t)=>[t,...e]),w_=d(2,(e,t)=>[...e,t]),pm=d(2,(e,t)=>ke(e).concat(ke(t))),dm=Array.isArray,T_=yM,io=am,we=am,SM=d(2,(e,t)=>{let r=Math.floor(t);return E_(r,e)?C():N(e[r])}),fm=d(2,(e,t)=>{let r=Math.floor(t);if(E_(r,e))throw Error(`Index ${r} out of bounds`);return e[r]}),En=SM(0),tt=fm(0),O_=d(2,(e,t)=>wM(e,bM(e,t))),R_=d(2,(e,t)=>{let r=ke(e);return r.slice(xM(t,r),r.length)}),vn=d(2,(e,t)=>{let r=Array.from(e);return r.sort(t),r}),gm=d(2,(e,t)=>k_(e,t,S_)),k_=d(3,(e,t,r)=>{let n=ke(e),o=ke(t);if(we(n)&&we(o)){let i=[r(tt(n),tt(o))],a=Math.min(n.length,o.length);for(let s=1;s<a;s++)i[s]=r(n[s],o[s]);return i}return[]}),_M=Ts(),wM=d(2,(e,t)=>{let r=Array.from(e),n=Math.floor(t);if(we(r)){if(n>=1)return TM(r,n);return[[],r]}return[r,[]]}),TM=d(2,(e,t)=>{let r=Math.max(1,Math.floor(t));return r>=e.length?[ra(e),[]]:[ta(e.slice(1,r),tt(e)),e.slice(r)]}),EM=d(3,(e,t,r)=>{let n=ke(e),o=ke(t);if(we(n)){if(we(o))return C_(r)(pm(n,o));return n}return o}),ao=d(2,(e,t)=>EM(e,t,_M)),kr=d(2,(e,t)=>e.map(t)),Ps=d(2,(e,t)=>{if(T_(e))return[];let r=[];for(let n=0;n<e.length;n++){let o=t(e[n],n);for(let i=0;i<o.length;i++)r.push(o[i])}return r}),Xl=Ps(ce),Ql=d(2,(e,t)=>{let r=ke(e),n=[];for(let o=0;o<r.length;o++){let i=t(r[o],o);if(Re(i))n.push(i.value)}return n}),na=d(3,(e,t,r)=>ke(e).reduce((n,o,i)=>r(n,o,i),t)),so=qb,C_=d(2,(e,t)=>{let r=ke(e);if(we(r)){let n=[tt(r)],o=Rr(r);for(let i of o)if(n.every((a)=>!t(i,a)))n.push(i);return n}return[]}),Rn=d(2,(e,t)=>ke(e).join(t))});function kM(e,t,r,n,o){for(let i=t;i<Math.min(e.length,t+o);i++)r[n+i-t]=e[i];return r}var P_,I_,CM=(e)=>gs((t,r)=>t.length===r.length&&kn(t).every((n,o)=>e(n,oa(r,o)))),AM,PM,it=(e)=>{let t=Object.create(PM);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=Wr,t.right=Wr;break}case"ISingleton":{t.length=1,t.depth=0,t.left=Wr,t.right=Wr;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=Wr,t.right=Wr;break}}return t},M_=(e)=>k(e,P_),Wr,pr=()=>Wr,Is=(...e)=>NM(e),rt=(e)=>it({_tag:"ISingleton",a:e}),eu=(e)=>M_(e)?e:Ms(ke(e)),Sm=(e,t,r)=>{switch(e.backing._tag){case"IArray":{kM(e.backing.array,0,t,r,e.length);break}case"IConcat":{Sm(e.left,t,r),Sm(e.right,t,r+e.left.length);break}case"ISingleton":{t[r]=e.backing.a;break}case"ISlice":{let n=0,o=r;while(n<e.length)t[o]=oa(e,n),n+=1,o+=1;break}}},IM=(e)=>{switch(e.backing._tag){case"IEmpty":return I_;case"IArray":return e.backing.array;default:{let t=Array(e.length);return Sm(e,t,0),e.backing={_tag:"IArray",array:t},e.left=Wr,e.right=Wr,e.depth=0,t}}},kn,MM=(e)=>{switch(e.backing._tag){case"IEmpty":case"ISingleton":return e;case"IArray":return it({_tag:"IArray",array:hm(e.backing.array)});case"IConcat":return it({_tag:"IConcat",left:co(e.backing.right),right:co(e.backing.left)});case"ISlice":return Ms(hm(kn(e)))}},co,Ms=(e)=>e.length===0?pr():e.length===1?rt(e[0]):it({_tag:"IArray",array:e}),NM=(e)=>Ms(e),oa,N_,Ct,bm,tr,F_=(e)=>e.length===0,Cr=(e)=>e.length>0,_m=(e)=>oa(e,0),Ar,Pr=(e)=>bm(e,1);var Jr=x(()=>{Ve();le();ys();H();Me();Be();_e();ge();P_=Symbol.for("effect/Chunk");I_=[],AM=CM(O),PM={[P_]:{_A:(e)=>e},toString(){return he(this.toJSON())},toJSON(){return{_id:"Chunk",values:kn(this).map(ue)}},[re](){return this.toJSON()},[I](e){return M_(e)&&AM(this,e)},[M](){return oe(this,Qt(kn(this)))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return I_[Symbol.iterator]();default:return kn(this)[Symbol.iterator]()}},pipe(){return E(this,arguments)}},Wr=it({_tag:"IEmpty"}),kn=IM,co=MM,oa=d(2,(e,t)=>{switch(e.backing._tag){case"IEmpty":throw Error("Index out of bounds");case"ISingleton":{if(t!==0)throw Error("Index out of bounds");return e.backing.a}case"IArray":{if(t>=e.length||t<0)throw Error("Index out of bounds");return e.backing.array[t]}case"IConcat":return t<e.left.length?oa(e.left,t):oa(e.right,t-e.left.length);case"ISlice":return oa(e.backing.chunk,t+e.backing.offset)}}),N_=d(2,(e,t)=>tr(e,rt(t))),Ct=d(2,(e,t)=>tr(rt(t),e)),bm=d(2,(e,t)=>{if(t<=0)return e;else if(t>=e.length)return Wr;else switch(e.backing._tag){case"ISlice":return it({_tag:"ISlice",chunk:e.backing.chunk,offset:e.backing.offset+t,length:e.backing.length-t});case"IConcat":{if(t>e.left.length)return bm(e.right,t-e.left.length);return it({_tag:"IConcat",left:bm(e.left,t),right:e.right})}default:return it({_tag:"ISlice",chunk:e,offset:t,length:e.length-t})}}),tr=d(2,(e,t)=>{if(e.backing._tag==="IEmpty")return t;if(t.backing._tag==="IEmpty")return e;let r=t.depth-e.depth;if(Math.abs(r)<=1)return it({_tag:"IConcat",left:e,right:t});else if(r<-1)if(e.left.depth>=e.right.depth){let n=tr(e.right,t);return it({_tag:"IConcat",left:e.left,right:n})}else{let n=tr(e.right.right,t);if(n.depth===e.depth-3){let o=it({_tag:"IConcat",left:e.right.left,right:n});return it({_tag:"IConcat",left:e.left,right:o})}else{let o=it({_tag:"IConcat",left:e.left,right:e.right.left});return it({_tag:"IConcat",left:o,right:n})}}else if(t.right.depth>=t.left.depth){let n=tr(e,t.left);return it({_tag:"IConcat",left:n,right:t.right})}else{let n=tr(e,t.left.left);if(n.depth===t.depth-3){let o=it({_tag:"IConcat",left:n,right:t.left.right});return it({_tag:"IConcat",left:o,right:t.right})}else{let o=it({_tag:"IConcat",left:t.left.right,right:t.right});return it({_tag:"IConcat",left:n,right:o})}}}),Ar=_m});var lo=5,wm,L_,D_,q_;var tu=x(()=>{wm=Math.pow(2,5),L_=wm-1,D_=wm/2,q_=wm/4});function FM(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,e+=e>>16,e&127}function uo(e,t){return t>>>e&L_}function po(e){return 1<<e}function ru(e,t){return FM(e&t-1)}var Tm=x(()=>{tu()});var U_=(e,t)=>({value:e,previous:t});function ni(e,t,r,n){let o=n;if(!e){let i=n.length;o=Array(i);for(let a=0;a<i;++a)o[a]=n[a]}return o[t]=r,o}function Em(e,t,r){let n=r.length-1,o=0,i=0,a=r;if(e)o=i=t;else{a=Array(n);while(o<t)a[i++]=r[o++]}++o;while(o<=n)a[i++]=r[o++];if(e)a.length=n;return a}function H_(e,t,r,n){let o=n.length;if(e){let c=o;while(c>=t)n[c--]=n[c];return n[t]=r,n}let i=0,a=0,s=Array(o+1);while(i<t)s[a++]=n[i++];s[t]=r;while(i<o)s[++a]=n[i++];return s}class An{_tag="EmptyNode";modify(e,t,r,n,o,i){let a=r(C());if(Ne(a))return new An;return++i.value,new oi(e,n,o,a)}}function dr(e){return bs(e,"EmptyNode")}function DM(e){return dr(e)||e._tag==="LeafNode"||e._tag==="CollisionNode"}function nu(e,t){return dr(e)?!1:t===e.edit}class oi{edit;hash;key;value;_tag="LeafNode";constructor(e,t,r,n){this.edit=e,this.hash=t,this.key=r,this.value=n}modify(e,t,r,n,o,i){if(O(o,this.key)){let s=r(this.value);if(s===this.value)return this;else if(Ne(s))return--i.value,new An;if(nu(this,e))return this.value=s,this;return new oi(e,n,o,s)}let a=r(C());if(Ne(a))return this;return++i.value,$_(e,t,this.hash,this,n,new oi(e,n,o,a))}}class vm{edit;hash;children;_tag="CollisionNode";constructor(e,t,r){this.edit=e,this.hash=t,this.children=r}modify(e,t,r,n,o,i){if(n===this.hash){let s=nu(this,e),c=this.updateCollisionList(s,e,this.hash,this.children,r,o,i);if(c===this.children)return this;return c.length>1?new vm(e,this.hash,c):c[0]}let a=r(C());if(Ne(a))return this;return++i.value,$_(e,t,this.hash,this,n,new oi(e,n,o,a))}updateCollisionList(e,t,r,n,o,i,a){let s=n.length;for(let l=0;l<s;++l){let u=n[l];if("key"in u&&O(i,u.key)){let p=u.value,f=o(p);if(f===p)return n;if(Ne(f))return--a.value,Em(e,l,n);return ni(e,l,new oi(t,r,i,f),n)}}let c=o(C());if(Ne(c))return n;return++a.value,ni(e,s,new oi(t,r,i,c),n)}}class ia{edit;mask;children;_tag="IndexedNode";constructor(e,t,r){this.edit=e,this.mask=t,this.children=r}modify(e,t,r,n,o,i){let a=this.mask,s=this.children,c=uo(t,n),l=po(c),u=ru(a,l),p=a&l,f=nu(this,e);if(!p){let y=new An().modify(e,t+lo,r,n,o,i);if(!y)return this;return s.length>=D_?UM(e,c,y,a,s):new ia(e,a|l,H_(f,u,y,s))}let h=s[u],m=h.modify(e,t+lo,r,n,o,i);if(h===m)return this;let w=a,S;if(dr(m)){if(w&=~l,!w)return new An;if(s.length<=2&&DM(s[u^1]))return s[u^1];S=Em(f,u,s)}else S=ni(f,u,m,s);if(f)return this.mask=w,this.children=S,this;return new ia(e,w,S)}}class Om{edit;size;children;_tag="ArrayNode";constructor(e,t,r){this.edit=e,this.size=t,this.children=r}modify(e,t,r,n,o,i){let a=this.size,s=this.children,c=uo(t,n),l=s[c],u=(l||new An).modify(e,t+lo,r,n,o,i);if(l===u)return this;let p=nu(this,e),f;if(dr(l)&&!dr(u))++a,f=ni(p,c,u,s);else if(!dr(l)&&dr(u)){if(--a,a<=q_)return qM(e,a,c,s);f=ni(p,c,new An,s)}else f=ni(p,c,u,s);if(p)return this.size=a,this.children=f,this;return new Om(e,a,f)}}function qM(e,t,r,n){let o=Array(t-1),i=0,a=0;for(let s=0,c=n.length;s<c;++s)if(s!==r){let l=n[s];if(l&&!dr(l))o[i++]=l,a|=1<<s}return new ia(e,a,o)}function UM(e,t,r,n,o){let i=[],a=n,s=0;for(let c=0;a;++c){if(a&1)i[c]=o[s++];a>>>=1}return i[t]=r,new Om(e,s+1,i)}function HM(e,t,r,n,o,i){if(r===o)return new vm(e,r,[i,n]);let a=uo(t,r),s=uo(t,o);if(a===s)return(c)=>new ia(e,po(a)|po(s),[c]);else{let c=a<s?[n,i]:[i,n];return new ia(e,po(a)|po(s),c)}}function $_(e,t,r,n,o,i){let a=void 0,s=t;while(!0){let c=HM(e,s,r,n,o,i);if(typeof c==="function")a=U_(c,a),s=s+lo;else{let l=c;while(a!=null)l=a.value(l),a=a.previous;return l}}}var j_=x(()=>{le();Ye();ge();Tm();tu()});var B_="effect/HashMap",ou,jM,Rm=(e,t,r,n)=>{let o=Object.create(jM);return o._editable=e,o._edit=t,o._root=r,o._size=n,o},au,iu=(e)=>e?z_(e[0],e[1],e[2],e[3],e[4]):C(),V_=(e,t,r=void 0)=>{switch(e._tag){case"LeafNode":{if(Re(e.value))return N({value:t(e.key,e.value.value),cont:r});return iu(r)}case"CollisionNode":case"ArrayNode":case"IndexedNode":{let n=e.children;return z_(n.length,n,0,t,r)}default:return iu(r)}},z_=(e,t,r,n,o)=>{while(r<e){let i=t[r++];if(i&&!dr(i))return V_(i,n,[e,t,r,n,o])}return iu(o)},BM,aa=()=>BM,K_=(e)=>{let t=lu(aa());for(let r of e)ii(t,r[0],r[1]);return Y_(t)},W_=(e)=>k(e,ou),J_=(e)=>e&&dr(e._root),G_,su,km,ii,VM,cu=(e)=>new au(e,(t)=>t),Ns=(e)=>e._size,lu=(e)=>Rm(!0,e._edit+1,e._root,e._size),Y_=(e)=>(e._editable=!1,e),uu,Z_,pu,X_,Cm,sa;var Am=x(()=>{le();H();H();Me();Be();Ye();_e();ge();Tm();tu();j_();ou=Symbol.for(B_),jM={[ou]:ou,[Symbol.iterator](){return new au(this,(e,t)=>[e,t])},[M](){let e=v(B_);for(let t of this)e^=g(v(t[0]),J(v(t[1])));return oe(this,e)},[I](e){if(W_(e)){if(e._size!==this._size)return!1;for(let t of this){let r=g(e,su(t[0],v(t[0])));if(Ne(r))return!1;else if(!O(t[1],r.value))return!1}return!0}return!1},toString(){return he(this.toJSON())},toJSON(){return{_id:"HashMap",values:Array.from(this).map(ue)}},[re](){return this.toJSON()},pipe(){return E(this,arguments)}};au=class au{map;f;v;constructor(e,t){this.map=e,this.f=t,this.v=V_(this.map._root,this.f,void 0)}next(){if(Ne(this.v))return{done:!0,value:void 0};let e=this.v.value;return this.v=iu(e.cont),{done:!1,value:e.value}}[Symbol.iterator](){return new au(this.map,this.f)}};BM=Rm(!1,0,new An,0),G_=d(2,(e,t)=>su(e,t,v(t))),su=d(3,(e,t,r)=>{let n=e._root,o=0;while(!0)switch(n._tag){case"LeafNode":return O(t,n.key)?n.value:C();case"CollisionNode":{if(r===n.hash){let i=n.children;for(let a=0,s=i.length;a<s;++a){let c=i[a];if("key"in c&&O(t,c.key))return c.value}}return C()}case"IndexedNode":{let i=uo(o,r),a=po(i);if(n.mask&a){n=n.children[ru(n.mask,a)],o+=lo;break}return C()}case"ArrayNode":{if(n=n.children[uo(o,r)],n){o+=lo;break}return C()}default:return C()}}),km=d(2,(e,t)=>Re(su(e,t,v(t)))),ii=d(3,(e,t,r)=>uu(e,t,()=>N(r))),VM=d(3,(e,t,r)=>{if(e._editable)return e._root=t,e._size=r,e;return t===e._root?e:Rm(e._editable,e._edit,t,r)}),uu=d(3,(e,t,r)=>Z_(e,t,v(t),r)),Z_=d(4,(e,t,r,n)=>{let o={value:e._size},i=e._root.modify(e._editable?e._edit:NaN,0,n,r,t,o);return g(e,VM(i,o.value))}),pu=d(2,(e,t)=>uu(e,t,C)),X_=d(2,(e,t)=>sa(e,aa(),(r,n,o)=>ii(r,o,t(n,o)))),Cm=d(2,(e,t)=>sa(e,void 0,(r,n,o)=>t(n,o))),sa=d(3,(e,t,r)=>{let n=e._root;if(n._tag==="LeafNode")return Re(n.value)?r(t,n.value.value,n.key):t;if(n._tag==="EmptyNode")return t;let o=[n.children],i;while(i=o.pop())for(let a=0,s=i.length;a<s;){let c=i[a++];if(c&&!dr(c))if(c._tag==="LeafNode"){if(Re(c.value))t=r(t,c.value.value,c.key)}else o.push(c.children)}return t})});var ew="effect/HashSet",du,zM,fu=(e)=>{let t=Object.create(zM);return t._keyMap=e,t},tw=(e)=>k(e,du),KM,Fs=()=>KM,rw=(e)=>{let t=mu(Fs());for(let r of e)ca(t,r);return hu(t)},nw=(...e)=>{let t=mu(Fs());for(let r of e)ca(t,r);return hu(t)},ow,iw=(e)=>Ns(e._keyMap),mu=(e)=>fu(lu(e._keyMap)),hu=(e)=>(e._keyMap._editable=!1,e),Pm,ca,Im,aw,sw,cw,lw;var uw=x(()=>{le();H();Me();Be();_e();ge();Am();du=Symbol.for(ew),zM={[du]:du,[Symbol.iterator](){return cu(this._keyMap)},[M](){return oe(this,J(v(this._keyMap))(v(ew)))},[I](e){if(tw(e))return Ns(this._keyMap)===Ns(e._keyMap)&&O(this._keyMap,e._keyMap);return!1},toString(){return he(this.toJSON())},toJSON(){return{_id:"HashSet",values:Array.from(this).map(ue)}},[re](){return this.toJSON()},pipe(){return E(this,arguments)}},KM=fu(aa()),ow=d(2,(e,t)=>km(e._keyMap,t)),Pm=d(2,(e,t)=>{let r=mu(e);return t(r),hu(r)}),ca=d(2,(e,t)=>e._keyMap._editable?(ii(t,!0)(e._keyMap),e):fu(ii(t,!0)(e._keyMap))),Im=d(2,(e,t)=>e._keyMap._editable?(pu(t)(e._keyMap),e):fu(pu(t)(e._keyMap))),aw=d(2,(e,t)=>Pm(e,(r)=>{for(let n of t)Im(r,n)})),sw=d(2,(e,t)=>Pm(Fs(),(r)=>{cw(e,(n)=>ca(r,n));for(let n of t)ca(r,n)})),cw=d(2,(e,t)=>Cm(e._keyMap,(r,n)=>t(n))),lw=d(3,(e,t,r)=>sa(e._keyMap,t,(n,o,i)=>r(n,i)))});var Gr,pw,ai,dw,Ls,si,Mm,Nm,Pn,ci;var li=x(()=>{uw();Gr=Fs,pw=rw,ai=nw,dw=ow,Ls=iw,si=ca,Mm=Im,Nm=aw,Pn=sw,ci=lw});var ua="Die",fo="Empty",mo="Fail",ui="Interrupt",pi="Parallel",di="Sequential";var hw="effect/Cause",Dm,GM,pa,In,da=(e)=>{let t=Object.create(pa);return t._tag=mo,t.error=e,t},rr=(e)=>{let t=Object.create(pa);return t._tag=ua,t.defect=e,t},Ir=(e)=>{let t=Object.create(pa);return t._tag=ui,t.fiberId=e,t},hi=(e,t)=>{let r=Object.create(pa);return r._tag=pi,r.left=e,r.right=t,r},At=(e,t)=>{let r=Object.create(pa);return r._tag=di,r.left=e,r.right=t,r},gw=(e)=>k(e,Dm),qm=(e)=>e._tag===fo,yw=(e)=>e._tag===mo,gu=(e)=>{if(e._tag===fo)return!0;return fi(e,!0,(t,r)=>{switch(r._tag){case fo:return N(t);case ua:case mo:case ui:return N(!1);default:return C()}})},yu=(e)=>Re(xw(e)),fa=(e)=>bu(void 0,QM)(e),Um=(e)=>co(fi(e,pr(),(t,r)=>r._tag===mo?N(g(t,Ct(r.error))):C())),Hm=(e)=>co(fi(e,pr(),(t,r)=>r._tag===ua?N(g(t,Ct(r.defect))):C())),$m=(e)=>fi(e,Gr(),(t,r)=>r._tag===ui?N(g(t,si(r.fiberId))):C()),jm=(e)=>Bm(e,(t)=>t._tag===mo?N(t.error):C()),xu=(e)=>{let t=jm(e);switch(t._tag){case"None":return Z(e);case"Some":return K(t.value)}},xw=(e)=>Bm(e,(t)=>t._tag===ui?N(t.fiberId):C()),Su=(e)=>Vm(e,{onEmpty:In,onFail:()=>In,onDie:rr,onInterrupt:Ir,onSequential:At,onParallel:hi}),Sw=(e)=>Vm(e,{onEmpty:In,onFail:rr,onDie:rr,onInterrupt:Ir,onSequential:At,onParallel:hi}),YM=(e,t)=>{let r=rt(e),n=rt(t);while(Cr(r)&&Cr(n)){let[o,i]=g(Ar(r),fi([Gr(),pr()],([c,l],u)=>{let[p,f]=Fm(u);return N([g(c,Pn(p)),g(l,tr(f))])})),[a,s]=g(Ar(n),fi([Gr(),pr()],([c,l],u)=>{let[p,f]=Fm(u);return N([g(c,Pn(p)),g(l,tr(f))])}));if(!O(o,a))return!1;r=i,n=s}return!0},ZM=(e)=>XM(rt(e),pr()),XM=(e,t)=>{while(!0){let[r,n]=g(e,na([Gr(),pr()],([i,a],s)=>{let[c,l]=Fm(s);return[g(i,Pn(c)),g(a,tr(l))]})),o=Ls(r)>0?g(t,Ct(r)):t;if(F_(n))return co(o);e=n,t=o}throw Error(Yo("Cause.flattenCauseLoop"))},Bm,Fm=(e)=>{let t=e,r=[],n=Gr(),o=pr();while(t!==void 0)switch(t._tag){case fo:{if(r.length===0)return[n,o];t=r.pop();break}case mo:{if(n=si(n,Is(t._tag,t.error)),r.length===0)return[n,o];t=r.pop();break}case ua:{if(n=si(n,Is(t._tag,t.defect)),r.length===0)return[n,o];t=r.pop();break}case ui:{if(n=si(n,Is(t._tag,t.fiberId)),r.length===0)return[n,o];t=r.pop();break}case di:{switch(t.left._tag){case fo:{t=t.right;break}case di:{t=At(t.left.left,At(t.left.right,t.right));break}case pi:{t=hi(At(t.left.left,t.right),At(t.left.right,t.right));break}default:{o=Ct(o,t.right),t=t.left;break}}break}case pi:{r.push(t.right),t=t.left;break}}throw Error(Yo("Cause.evaluateCauseLoop"))},QM,fw="SequentialCase",mw="ParallelCase",Vm,fi,bu,Mr=(e,t)=>{if(fa(e))return"All fibers interrupted without errors.";return Ds(e).map(function(r){if(t?.renderErrorCause!==!0||r.cause===void 0)return r.stack;return`${r.stack} {
|
|
10
|
+
${bw(r.cause," ")}
|
|
11
|
+
}`}).join(`
|
|
12
|
+
`)},bw=(e,t)=>{let r=e.stack.split(`
|
|
13
|
+
`),n=`${t}[cause]: ${r[0]}`;for(let o=1,i=r.length;o<i;o++)n+=`
|
|
14
|
+
${t}${r[o]}`;if(e.cause)n+=` {
|
|
15
|
+
${bw(e.cause,`${t} `)}
|
|
16
|
+
${t}}`;return n},Lm=(e)=>{let t=typeof e==="object"&&e!==null,r=Error.stackTraceLimit;Error.stackTraceLimit=1;let n=Error(eN(e),t&&"cause"in e&&typeof e.cause<"u"?{cause:Lm(e.cause)}:void 0);if(Error.stackTraceLimit=r,n.message==="")n.message="An error has occurred";if(Error.stackTraceLimit=r,n.name=e instanceof Error?e.name:"Error",t){if(mi in e)n.span=e[mi];Object.keys(e).forEach((o)=>{if(!(o in n))n[o]=e[o]})}return n.stack=nN(`${n.name}: ${n.message}`,e instanceof Error&&e.stack?e.stack:"",n.span),n},eN=(e)=>{if(typeof e==="string")return e;if(typeof e==="object"&&e!==null&&e instanceof Error)return e.message;try{if(k(e,"toString")&&to(e.toString)&&e.toString!==Object.prototype.toString&&e.toString!==globalThis.Array.prototype.toString)return e.toString()}catch{}return Vl(e)},tN,rN,nN=(e,t,r)=>{let n=[e],o=t.startsWith(e)?t.slice(e.length).split(`
|
|
7
17
|
`):t.split(`
|
|
8
|
-
`);for(let
|
|
9
|
-
`)},
|
|
10
|
-
`);if(
|
|
11
|
-
`);
|
|
12
|
-
`)}return t},Pc=e=>w(e,Ac),Fc=e=>w(e,Sc),Ic=Mc(new Map),Lc=()=>Ic,Rc=(e,t)=>Mc(new Map([[e.key,t]])),zc=x(3,(e,t,n)=>{let r=new Map(e.unsafeMap);return r.set(t.key,n),Mc(r)}),Bc=C(`effect/Context/defaultValueCache`,()=>new Map),Vc=e=>{if(Bc.has(e.key))return Bc.get(e.key);let t=e.defaultValue();return Bc.set(e.key,t),t},Hc=(e,t)=>e.unsafeMap.has(t.key)?e.unsafeMap.get(t.key):Vc(t),Uc=x(2,(e,t)=>{if(!e.unsafeMap.has(t.key)){if(Sc in t)return Vc(t);throw Nc(t)}return e.unsafeMap.get(t.key)}),Wc=Uc,Gc=x(2,(e,t)=>e.unsafeMap.has(t.key)?Rn(e.unsafeMap.get(t.key)):Fc(t)?Rn(Vc(t)):Ln),Kc=x(2,(e,t)=>{let n=new Map(e.unsafeMap);for(let[e,r]of t.unsafeMap)n.set(e,r);return Mc(n)})})),Jc,Yc,Xc,Zc,Qc,$c,el,tl,nl,rl,il=v((()=>{qc(),Jc=Dc,Yc=Lc,Xc=Rc,Zc=zc,Qc=Wc,$c=Uc,el=Gc,tl=Kc,nl=Oc,rl=kc})),al,ol,sl,cl,ll,ul,dl,fl,pl,ml,hl,gl,_l,vl,yl,bl,xl,Sl,Cl,wl,Tl,El,Dl,Ol,kl,Al,jl,Ml,Nl,Pl,Fl,Il,Ll,Rl,zl,Bl,Vl,Hl,Ul=v((()=>{M(),S(),Mt(),Xt(),Rr(),F(),T(),al=Symbol.for(`effect/Duration`),ol=BigInt(0),sl=BigInt(24),cl=BigInt(60),ll=BigInt(1e3),ul=BigInt(1e6),dl=BigInt(1e9),fl=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,pl=e=>{if(vl(e))return e;if(ze(e))return Tl(e);if(Ve(e))return Cl(e);if(Array.isArray(e)&&e.length===2&&e.every(ze))return e[0]===-1/0||e[1]===-1/0||Number.isNaN(e[0])||Number.isNaN(e[1])?xl:e[0]===1/0||e[1]===1/0?Sl:Cl(BigInt(Math.round(e[0]*1e9))+BigInt(Math.round(e[1])));if(Re(e)){let t=fl.exec(e);if(t){let[e,n,r]=t,i=Number(n);switch(r){case`nano`:case`nanos`:return Cl(BigInt(n));case`micro`:case`micros`:return wl(BigInt(n));case`milli`:case`millis`:return Tl(i);case`second`:case`seconds`:return El(i);case`minute`:case`minutes`:return Dl(i);case`hour`:case`hours`:return Ol(i);case`day`:case`days`:return kl(i);case`week`:case`weeks`:return Al(i)}}}throw Error(`Invalid DurationInput`)},ml={_tag:`Millis`,millis:0},hl={_tag:`Infinity`},gl={[al]:al,[E](){return k(this,At(this.value))},[j](e){return vl(e)&&Bl(this,e)},toString(){return`Duration(${Hl(this)})`},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,hrtime:Pl(this)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`}}},[N](){return this.toJSON()},pipe(){return P(this,arguments)}},_l=e=>{let t=Object.create(gl);return t.value=ze(e)?isNaN(e)||e<=0?ml:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:BigInt(Math.round(e*1e6))}:hl:e<=ol?ml:{_tag:`Nanos`,nanos:e},t},vl=e=>w(e,al),yl=e=>e.value._tag!==`Infinity`,bl=e=>{switch(e.value._tag){case`Millis`:return e.value.millis===0;case`Nanos`:return e.value.nanos===ol;case`Infinity`:return!1}},xl=_l(0),Sl=_l(1/0),Cl=e=>_l(e),wl=e=>_l(e*ll),Tl=e=>_l(e),El=e=>_l(e*1e3),Dl=e=>_l(e*6e4),Ol=e=>_l(e*36e5),kl=e=>_l(e*864e5),Al=e=>_l(e*6048e5),jl=e=>Fl(e,{onMillis:e=>e,onNanos:e=>Number(e)/1e6}),Ml=e=>{let t=pl(e);switch(t.value._tag){case`Infinity`:return R();case`Nanos`:return z(t.value.nanos);case`Millis`:return z(BigInt(Math.round(t.value.millis*1e6)))}},Nl=e=>{let t=pl(e);switch(t.value._tag){case`Infinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return BigInt(Math.round(t.value.millis*1e6))}},Pl=e=>{let t=pl(e);switch(t.value._tag){case`Infinity`:return[1/0,0];case`Nanos`:return[Number(t.value.nanos/dl),Number(t.value.nanos%dl)];case`Millis`:return[Math.floor(t.value.millis/1e3),Math.round(t.value.millis%1e3*1e6)]}},Fl=x(2,(e,t)=>{let n=pl(e);switch(n.value._tag){case`Nanos`:return t.onNanos(n.value.nanos);case`Infinity`:return t.onMillis(1/0);case`Millis`:return t.onMillis(n.value.millis)}}),Il=x(3,(e,t,n)=>{let r=pl(e),i=pl(t);if(r.value._tag===`Infinity`||i.value._tag===`Infinity`)return n.onMillis(jl(r),jl(i));if(r.value._tag===`Nanos`||i.value._tag===`Nanos`){let e=r.value._tag===`Nanos`?r.value.nanos:BigInt(Math.round(r.value.millis*1e6)),t=i.value._tag===`Nanos`?i.value.nanos:BigInt(Math.round(i.value.millis*1e6));return n.onNanos(e,t)}return n.onMillis(r.value.millis,i.value.millis)}),Ll=(e,t)=>Il(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t}),Rl=x(2,(e,t)=>Il(e,t,{onMillis:(e,t)=>e<=t,onNanos:(e,t)=>e<=t})),zl=x(2,(e,t)=>Il(e,t,{onMillis:(e,t)=>e>=t,onNanos:(e,t)=>e>=t})),Bl=x(2,(e,t)=>Ll(pl(e),pl(t))),Vl=e=>{let t=pl(e);if(t.value._tag===`Infinity`)return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};let n=Nl(t),r=n/ul,i=r/ll,a=i/cl,o=a/cl,s=o/sl;return{days:Number(s),hours:Number(o%sl),minutes:Number(a%cl),seconds:Number(i%cl),millis:Number(r%ll),nanos:Number(n%ul)}},Hl=e=>{let t=pl(e);if(t.value._tag===`Infinity`)return`Infinity`;if(bl(t))return`0`;let n=Vl(t),r=[];return n.days!==0&&r.push(`${n.days}d`),n.hours!==0&&r.push(`${n.hours}h`),n.minutes!==0&&r.push(`${n.minutes}m`),n.seconds!==0&&r.push(`${n.seconds}s`),n.millis!==0&&r.push(`${n.millis}ms`),n.nanos!==0&&r.push(`${n.nanos}ns`),r.join(` `)}})),Wl,Gl,Kl,ql,Jl,Yl=v((()=>{S(),Xt(),F(),Wl=Symbol.for(`effect/MutableRef`),Gl={[Wl]:Wl,toString(){return Ht(this.toJSON())},toJSON(){return{_id:`MutableRef`,current:Bt(this.current)}},[N](){return this.toJSON()},pipe(){return P(this,arguments)}},Kl=e=>{let t=Object.create(Gl);return t.current=e,t},ql=e=>e.current,Jl=x(2,(e,t)=>(e.current=t,e))})),Xl,Zl,Ql,$l,eu,tu,nu,ru,iu,au,ou,su,cu,lu,uu,du,fu,pu=v((()=>{M(),S(),Ie(),Mt(),Cs(),Xt(),Yl(),T(),Xl=`effect/FiberId`,Zl=Symbol.for(Xl),Ql=`None`,$l=`Runtime`,eu=`Composite`,tu=Ot(`${Xl}-${Ql}`),nu=class{[Zl]=Zl;_tag=Ql;id=-1;startTimeMillis=-1;[E](){return tu}[j](e){return cu(e)&&e._tag===Ql}toString(){return Ht(this.toJSON())}toJSON(){return{_id:`FiberId`,_tag:this._tag}}[N](){return this.toJSON()}},ru=class{id;startTimeMillis;[Zl]=Zl;_tag=$l;constructor(e,t){this.id=e,this.startTimeMillis=t}[E](){return k(this,Ot(`${Xl}-${this._tag}-${this.id}-${this.startTimeMillis}`))}[j](e){return cu(e)&&e._tag===$l&&this.id===e.id&&this.startTimeMillis===e.startTimeMillis}toString(){return Ht(this.toJSON())}toJSON(){return{_id:`FiberId`,_tag:this._tag,id:this.id,startTimeMillis:this.startTimeMillis}}[N](){return this.toJSON()}},iu=class{left;right;[Zl]=Zl;_tag=eu;constructor(e,t){this.left=e,this.right=t}_hash;[E](){return b(Ot(`${Xl}-${this._tag}`),O(D(this.left)),O(D(this.right)),k(this))}[j](e){return cu(e)&&e._tag===eu&&A(this.left,e.left)&&A(this.right,e.right)}toString(){return Ht(this.toJSON())}toJSON(){return{_id:`FiberId`,_tag:this._tag,left:Bt(this.left),right:Bt(this.right)}}[N](){return this.toJSON()}},au=new nu,ou=(e,t)=>new ru(e,t),su=(e,t)=>new iu(e,t),cu=e=>w(e,Zl),lu=e=>{switch(e._tag){case Ql:return ps();case $l:return hs(e.id);case eu:return b(lu(e.left),xs(lu(e.right)))}},uu=C(Symbol.for(`effect/Fiber/Id/_fiberCounter`),()=>Kl(0)),du=e=>Array.from(lu(e)).map(e=>`#${e}`).join(`,`),fu=()=>{let e=ql(uu);return b(uu,Jl(e+1)),new ru(e,Date.now())}})),mu,hu,gu,_u,vu,yu,bu=v((()=>{pu(),mu=au,hu=ou,gu=su,_u=cu,vu=du,yu=fu})),xu,Su,Cu,wu,Tu,Eu,Du,Ou,ku,Au=v((()=>{Go(),xu=Eo,Su=Do,Cu=ko,wu=Ao,Tu=No,Eu=Fo,Du=zo,Ou=Ho,ku=Wo})),ju,Mu,Nu,Pu,Fu,Iu,Lu,Ru,zu,Bu,Vu,Hu,Uu,Wu,Gu,Ku,qu,Ju,Yu,Xu,Zu,Qu=v((()=>{Pi(),M(),Ne(),S(),Mt(),Xt(),F(),T(),ju=Symbol.for(`effect/List`),Mu=e=>Ur(e),Nu=e=>Ae(Ai(e),Mu),Pu=Nu(A),Fu={[ju]:ju,_tag:`Cons`,toString(){return Ht(this.toJSON())},toJSON(){return{_id:`List`,_tag:`Cons`,values:Mu(this).map(Bt)}},[N](){return this.toJSON()},[j](e){return Bu(e)&&this._tag===e._tag&&Pu(this,e)},[E](){return k(this,jt(Mu(this)))},[Symbol.iterator](){let e=!1,t=this;return{next(){if(e)return this.return();if(t._tag===`Nil`)return e=!0,this.return();let n=t.head;return t=t.tail,{done:e,value:n}},return(t){return e||=!0,{done:!0,value:t}}}},pipe(){return P(this,arguments)}},Iu=(e,t)=>{let n=Object.create(Fu);return n.head=e,n.tail=t,n},Lu=Ot(`Nil`),Ru={[ju]:ju,_tag:`Nil`,toString(){return Ht(this.toJSON())},toJSON(){return{_id:`List`,_tag:`Nil`}},[N](){return this.toJSON()},[E](){return Lu},[j](e){return Bu(e)&&this._tag===e._tag},[Symbol.iterator](){return{next(){return{done:!0,value:void 0}}}},pipe(){return P(this,arguments)}},zu=Object.create(Ru),Bu=e=>w(e,ju),Vu=e=>e._tag===`Nil`,Hu=e=>e._tag===`Cons`,Uu=()=>zu,Wu=(e,t)=>Iu(e,t),Gu=Uu,Ku=e=>Iu(e,zu),qu=x(2,(e,t)=>Yu(t,e)),Ju=x(2,(e,t)=>Wu(t,e)),Yu=x(2,(e,t)=>{if(Vu(e))return t;if(Vu(t))return e;{let n=Iu(t.head,e),r=n,i=t.tail;for(;!Vu(i);){let t=Iu(i.head,e);r.tail=t,r=t,i=i.tail}return n}}),Xu=x(3,(e,t,n)=>{let r=t,i=e;for(;!Vu(i);)r=n(r,i.head),i=i.tail;return r}),Zu=e=>{let t=Gu(),n=e;for(;!Vu(n);)t=Ju(t,n.head),n=n.tail;return t}})),$u,ed=v((()=>{M(),Mt(),On(),Array.prototype,$u=function(){function e(e){e&&Object.assign(this,e)}return e.prototype=wn,e}()}));function td(e){return e}var nd,rd,id,ad,od,sd,cd,ld,ud,dd,fd,pd,md,hd,gd,_d=v((()=>{Ba(),M(),S(),qc(),ed(),nd=Symbol.for(`effect/DifferContextPatch`),rd={...$u.prototype,[nd]:{_Value:td,_Patch:td}},id=Object.create(Object.assign(Object.create(rd),{_tag:`Empty`})),ad=()=>id,od=Object.assign(Object.create(rd),{_tag:`AndThen`}),sd=(e,t)=>{let n=Object.create(od);return n.first=e,n.second=t,n},cd=Object.assign(Object.create(rd),{_tag:`AddService`}),ld=(e,t)=>{let n=Object.create(cd);return n.key=e,n.service=t,n},ud=Object.assign(Object.create(rd),{_tag:`RemoveService`}),dd=e=>{let t=Object.create(ud);return t.key=e,t},fd=Object.assign(Object.create(rd),{_tag:`UpdateService`}),pd=(e,t)=>{let n=Object.create(fd);return n.key=e,n.update=t,n},md=(e,t)=>{let n=new Map(e.unsafeMap),r=ad();for(let[e,i]of t.unsafeMap.entries())if(n.has(e)){let t=n.get(e);n.delete(e),A(t,i)||(r=hd(pd(e,()=>i))(r))}else n.delete(e),r=hd(ld(e,i))(r);for(let[e]of n.entries())r=hd(dd(e))(r);return r},hd=x(2,(e,t)=>sd(e,t)),gd=x(2,(e,t)=>{if(e._tag===`Empty`)return t;let n=!1,r=xa(e),i=new Map(t.unsafeMap);for(;Ia(r);){let e=Ra(r),t=za(r);switch(e._tag){case`Empty`:r=t;break;case`AddService`:i.set(e.key,e.service),r=t;break;case`AndThen`:r=Ma(Ma(t,e.second),e.first);break;case`RemoveService`:i.delete(e.key),r=t;break;case`UpdateService`:i.set(e.key,e.update(i.get(e.key))),n=!0,r=t}}if(!n)return Mc(i);let a=new Map;for(let[e]of t.unsafeMap)i.has(e)&&(a.set(e,i.get(e)),i.delete(e));for(let[e,t]of i)a.set(e,t);return Mc(a)})}));function vd(e){return e}var yd,bd,xd,Sd,Cd,wd,Td,Ed,Dd,Od,kd,Ad,jd,Md=v((()=>{Ba(),S(),Cs(),ed(),yd=Symbol.for(`effect/DifferHashSetPatch`),bd={...$u.prototype,[yd]:{_Value:vd,_Key:vd,_Patch:vd}},xd=Object.create(Object.assign(Object.create(bd),{_tag:`Empty`})),Sd=()=>xd,Cd=Object.assign(Object.create(bd),{_tag:`AndThen`}),wd=(e,t)=>{let n=Object.create(Cd);return n.first=e,n.second=t,n},Td=Object.assign(Object.create(bd),{_tag:`Add`}),Ed=e=>{let t=Object.create(Td);return t.value=e,t},Dd=Object.assign(Object.create(bd),{_tag:`Remove`}),Od=e=>{let t=Object.create(Dd);return t.value=e,t},kd=(e,t)=>{let[n,r]=Ss([e,Sd()],([e,t],n)=>gs(n)(e)?[ys(n)(e),t]:[e,Ad(Ed(n))(t)])(t);return Ss(r,(e,t)=>Ad(Od(t))(e))(n)},Ad=x(2,(e,t)=>wd(e,t)),jd=x(2,(e,t)=>{if(e._tag===`Empty`)return t;let n=t,r=xa(e);for(;Ia(r);){let e=Ra(r),t=za(r);switch(e._tag){case`Empty`:r=t;break;case`AndThen`:r=Ma(e.first)(Ma(e.second)(t));break;case`Add`:n=vs(e.value)(n),r=t;break;case`Remove`:n=ys(e.value)(n),r=t}}return n})}));function Nd(e){return e}var Pd,Fd,Id,Ld,Rd,zd,Bd,Vd,Hd,Ud,Wd,Gd,Kd,qd,Jd,Yd=v((()=>{Pi(),M(),S(),ed(),Pd=Symbol.for(`effect/DifferReadonlyArrayPatch`),Fd={...$u.prototype,[Pd]:{_Value:Nd,_Patch:Nd}},Id=Object.create(Object.assign(Object.create(Fd),{_tag:`Empty`})),Ld=()=>Id,Rd=Object.assign(Object.create(Fd),{_tag:`AndThen`}),zd=(e,t)=>{let n=Object.create(Rd);return n.first=e,n.second=t,n},Bd=Object.assign(Object.create(Fd),{_tag:`Append`}),Vd=e=>{let t=Object.create(Bd);return t.values=e,t},Hd=Object.assign(Object.create(Fd),{_tag:`Slice`}),Ud=(e,t)=>{let n=Object.create(Hd);return n.from=e,n.until=t,n},Wd=Object.assign(Object.create(Fd),{_tag:`Update`}),Gd=(e,t)=>{let n=Object.create(Wd);return n.index=e,n.patch=t,n},Kd=e=>{let t=0,n=Ld();for(;t<e.oldValue.length&&t<e.newValue.length;){let r=e.oldValue[t],i=e.newValue[t],a=e.differ.diff(r,i);A(a,e.differ.empty)||(n=qd(n,Gd(t,a))),t+=1}return t<e.oldValue.length&&(n=qd(n,Ud(0,t))),t<e.newValue.length&&(n=qd(n,Vd(di(t)(e.newValue)))),n},qd=x(2,(e,t)=>zd(e,t)),Jd=x(3,(e,t,n)=>{if(e._tag===`Empty`)return t;let r=t.slice(),i=Ci(e);for(;Qr(i);){let e=ai(i),t=ci(i);switch(e._tag){case`Empty`:i=t;break;case`AndThen`:t.unshift(e.first,e.second),i=t;break;case`Append`:for(let t of e.values)r.push(t);i=t;break;case`Slice`:r=r.slice(e.from,e.until),i=t;break;case`Update`:r[e.index]=n.patch(e.patch,r[e.index]),i=t}}return r})})),Xd,Zd,Qd,$d,ef,tf,nf,rf,af=v((()=>{M(),S(),F(),_d(),Md(),Yd(),Xd=Symbol.for(`effect/Differ`),Zd={[Xd]:{_P:be,_V:be},pipe(){return P(this,arguments)}},Qd=e=>{let t=Object.create(Zd);return t.empty=e.empty,t.diff=e.diff,t.combine=e.combine,t.patch=e.patch,t},$d=()=>Qd({empty:ad(),combine:(e,t)=>hd(t)(e),diff:(e,t)=>md(e,t),patch:(e,t)=>gd(t)(e)}),ef=()=>Qd({empty:Sd(),combine:(e,t)=>Ad(t)(e),diff:(e,t)=>kd(e,t),patch:(e,t)=>jd(t)(e)}),tf=e=>Qd({empty:Ld(),combine:(e,t)=>qd(e,t),diff:(t,n)=>Kd({oldValue:t,newValue:n,differ:e}),patch:(t,n)=>Jd(t,n,e)}),nf=()=>rf((e,t)=>t),rf=e=>Qd({empty:be,combine:(e,t)=>e===be?t:t===be?e:n=>t(e(n)),diff:(e,t)=>A(e,t)?be:xe(t),patch:(t,n)=>e(n,t(n))})})),of,sf,cf,lf,uf,df,ff,pf,mf,hf,gf,_f=v((()=>{S(),of=255,sf=8,cf=e=>e&of,lf=e=>e>>sf&of,uf=(e,t)=>(e&of)+((t&e&of)<<sf),df=uf(0,0),ff=e=>uf(e,e),pf=e=>uf(e,0),mf=x(2,(e,t)=>uf(cf(e)&~t,lf(e))),hf=x(2,(e,t)=>e|t),gf=e=>~e>>>0&of})),vf,yf,bf,xf,Sf,Cf,wf,Tf,Ef,Df,Of,kf,Af=v((()=>{S(),af(),_f(),vf=e=>Sf(e,32),yf=x(2,(e,t)=>e|t),bf=e=>xf(e)&&!Ef(e),xf=e=>Sf(e,1),Sf=x(2,(e,t)=>(e&t)!==0),Cf=(...e)=>e.reduce((e,t)=>e|t,0),wf=Cf(0),Tf=e=>Sf(e,4),Ef=e=>Sf(e,16),Df=x(2,(e,t)=>uf(e^t,t)),Of=x(2,(e,t)=>e&(gf(cf(t))|lf(t))|cf(t)&lf(t)),kf=Qd({empty:df,diff:(e,t)=>Df(e,t),combine:(e,t)=>hf(t)(e),patch:(e,t)=>Of(t,e)})})),jf,Mf,Nf,Pf=v((()=>{_f(),jf=ff,Mf=pf,Nf=mf})),Ff,If,Lf,Rf,zf,Bf,Vf,Hf,Uf,Wf,Gf,Kf,qf,Jf,Yf,Xf,Zf,Qf,$f,ep,tp,np=v((()=>{Ba(),M(),Au(),Qu(),Rr(),Ff=(e,t)=>({_tag:`Par`,left:e,right:t}),If=(e,t)=>({_tag:`Seq`,left:e,right:t}),Lf=e=>{let t=Ku(e),n=Gu();for(;;){let[e,r]=Xu(t,[Uf(),Gu()],([e,t],n)=>{let[r,i]=Rf(n);return[Gf(e,r),qu(t,i)]});if(n=zf(n,e),Vu(r))return Zu(n);t=r}throw Error(`BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues`)},Rf=e=>{let t=e,n=Uf(),r=Gu(),i=Gu();for(;;)switch(t._tag){case`Empty`:if(Vu(r))return[n,i];t=r.head,r=r.tail;break;case`Par`:r=Wu(t.right,r),t=t.left;break;case`Seq`:{let e=t.left,n=t.right;switch(e._tag){case`Empty`:t=n;break;case`Par`:{let r=e.left,i=e.right;t=Ff(If(r,n),If(i,n));break}case`Seq`:{let r=e.left,i=e.right;t=If(r,If(i,n));break}case`Single`:t=e,i=Wu(n,i)}break}case`Single`:if(n=Wf(n,t),Vu(r))return[n,i];t=r.head,r=r.tail}throw Error(`BUG: BlockedRequests.step - please report an issue at https://github.com/Effect-TS/effect/issues`)},zf=(e,t)=>{if(Vu(e))return Ku(Jf(t));if(Kf(t))return e;let n=ep(e.head),r=qf(t);return n.length===1&&r.length===1&&A(n[0],r[0])?Wu($f(e.head,Jf(t)),e.tail):Wu(Jf(t),e)},Bf=Symbol.for(`effect/RequestBlock/RequestBlockParallel`),Vf={_R:e=>e},Hf=class{map;[Bf]=Vf;constructor(e){this.map=e}},Uf=()=>new Hf(xu()),Wf=(e,t)=>new Hf(Du(e.map,t.dataSource,e=>Cr(Or(e,ja(t.blockedRequest)),()=>xa(t.blockedRequest)))),Gf=(e,t)=>new Hf(ku(e.map,t.map,(e,t,n)=>Tu(e,n,br(wu(e,n),{onNone:()=>t,onSome:e=>Pa(t,e)})))),Kf=e=>Cu(e.map),qf=e=>Array.from(Eu(e.map)),Jf=e=>Qf(Ou(e.map,e=>xa(e))),Yf=Symbol.for(`effect/RequestBlock/RequestBlockSequential`),Xf={_R:e=>e},Zf=class{map;[Yf]=Xf;constructor(e){this.map=e}},Qf=e=>new Zf(e),$f=(e,t)=>new Zf(ku(t.map,e.map,(e,t,n)=>Tu(e,n,br(wu(e,n),{onNone:()=>ya(),onSome:e=>Pa(e,t)})))),ep=e=>Array.from(Eu(e.map)),tp=e=>Array.from(e.map)})),rp,ip,ap=v((()=>{rp=`Pending`,ip=`Done`})),op,sp,cp,lp,up,dp=v((()=>{ap(),op=`effect/Deferred`,sp=Symbol.for(op),cp={_E:e=>e,_A:e=>e},lp=e=>({_tag:rp,joiners:e}),up=e=>({_tag:ip,effect:e})})),fp,pp=v((()=>{fp=class e{self;called=!1;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(e){return{value:e,done:!0}}throw(e){throw e}[Symbol.iterator](){return new e(this.self)}}})),mp,hp,gp,_p,vp,yp,bp,xp,Sp,Cp,wp,Tp,Ep,Dp,Op,kp,Ap,jp,Mp,Np,Pp,Fp,Ip,Lp,Rp,zp,Bp,Vp,Hp,B,Up,Wp,Gp,Kp,qp,Jp,Yp,Xp,Zp,Qp,$p,em,tm,nm,rm,V,im,am,om,sm,cm,lm,um,dm,fm,pm,mm,hm,gm,_m,vm,ym,bm,xm,Sm,Cm,wm,Tm,Em,Dm,Om,km,Am,jm,Mm,Nm,Pm,Fm,Im,Lm,Rm,zm,Bm,Vm,Hm,Um,Wm,Gm,Km,qm,Jm,Ym,Xm,Zm,Qm,$m,eh,th,nh,rh,ih,ah,oh,sh,ch,lh,uh,dh,fh,ph,mh,hh,gh,_h,vh,yh,bh,xh,Sh,Ch,wh,Th,Eh,Dh,Oh,kh,Ah,jh,Mh,Nh,Ph,Fh,Ih,Lh,Rh,zh,Bh,Vh=v((()=>{Pi(),Ba(),il(),lr(),M(),bu(),S(),Ie(),Mt(),Au(),Xt(),Qu(),Yl(),Rr(),F(),T(),Pf(),St(),bc(),dp(),af(),On(),rt(),ap(),fn(),Af(),pp(),mp=(e,t)=>{let n=new vp(`Blocked`);return n.effect_instruction_i0=e,n.effect_instruction_i1=t,n},hp=e=>{let t=new vp(`RunBlocked`);return t.effect_instruction_i0=e,t},gp=Symbol.for(`effect/Effect`),_p=class{patch;op;_op=dn;constructor(e,t){this.patch=e,this.op=t}},vp=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[gp]=bn;constructor(e){this._op=e}[j](e){return this===e}[E](){return k(this,wt(this))}pipe(){return P(this,arguments)}toJSON(){return{_id:`Effect`,_op:this._op,effect_instruction_i0:Bt(this.effect_instruction_i0),effect_instruction_i1:Bt(this.effect_instruction_i1),effect_instruction_i2:Bt(this.effect_instruction_i2)}}toString(){return Ht(this.toJSON())}[N](){return this.toJSON()}[Symbol.iterator](){return new fp(new gt(this))}},yp=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[gp]=bn;constructor(e){this._op=e,this._tag=e}[j](e){return gh(e)&&e._op===`Failure`&&A(this.effect_instruction_i0,e.effect_instruction_i0)}[E](){return b(Ot(this._tag),O(D(this.effect_instruction_i0)),k(this))}get cause(){return this.effect_instruction_i0}pipe(){return P(this,arguments)}toJSON(){return{_id:`Exit`,_tag:this._op,cause:this.cause.toJSON()}}toString(){return Ht(this.toJSON())}[N](){return this.toJSON()}[Symbol.iterator](){return new fp(new gt(this))}},bp=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[gp]=bn;constructor(e){this._op=e,this._tag=e}[j](e){return gh(e)&&e._op===`Success`&&A(this.effect_instruction_i0,e.effect_instruction_i0)}[E](){return b(Ot(this._tag),O(D(this.effect_instruction_i0)),k(this))}get value(){return this.effect_instruction_i0}pipe(){return P(this,arguments)}toJSON(){return{_id:`Exit`,_tag:this._op,value:Bt(this.value)}}toString(){return Ht(this.toJSON())}[N](){return this.toJSON()}[Symbol.iterator](){return new fp(new gt(this))}},xp=e=>w(e,gp),Sp=e=>{let t=new vp(ln);return t.effect_instruction_i0=e,t},Cp=x(3,(e,t,n)=>sm(r=>B(e,e=>B(Ip(rm(()=>r(t(e)))),t=>rm(()=>n(e,t)).pipe(Kp({onFailure:e=>{switch(t._tag){case $t:return zp(zs(t.effect_instruction_i0,e));case rn:return zp(e)}},onSuccess:()=>t})))))),wp=x(2,(e,t)=>B(e,()=>nm(t))),Tp=e=>wp(e,void 0),Ep=function(){let e=new vp(Qt);switch(arguments.length){case 2:e.effect_instruction_i0=arguments[0],e.commit=arguments[1];break;case 3:e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.commit=arguments[2];break;case 4:e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.effect_instruction_i2=arguments[2],e.commit=arguments[3];break;default:throw Error(nt(`you're not supposed to end up here`))}return e},Dp=(e,t=mu)=>{let n=new vp(Zt),r;return n.effect_instruction_i0=t=>{r=e(t)},n.effect_instruction_i1=t,tm(n,e=>xp(r)?r:cm)},Op=(e,t=mu)=>rm(()=>Dp(e,t)),kp=(e,t=mu)=>Ep(e,function(){let e,n;function r(t){e?e(t):n===void 0&&(n=t)}let i=new vp(Zt);i.effect_instruction_i0=t=>{e=t,n&&t(n)},i.effect_instruction_i1=t;let a,o;return this.effect_instruction_i0.length===1?a=xt(()=>this.effect_instruction_i0(r)):(o=new AbortController,a=xt(()=>this.effect_instruction_i0(r,o.signal))),a||o?tm(i,e=>(o&&o.abort(),a??cm)):i}),Ap=x(2,(e,t)=>qp(e,{onFailure:t,onSuccess:nm})),jp=Symbol.for(`effect/OriginalAnnotation`),Mp=(e,t)=>yr(t)?new Proxy(e,{has(e,t){return t===vc||t===jp||t in e},get(n,r){return r===vc?t.value:r===jp?e:n[r]}}):e,Np=e=>qe(e)&&!(vc in e)?Sp(t=>zp(Is(Mp(e,Bh(t))))):zp(Is(e)),Pp=e=>Bp(()=>Is(new sh(e))),Fp=e=>qp(e,{onFailure:e=>nm(L(e)),onSuccess:e=>nm(I(e))}),Ip=e=>Gp(e,{onFailure:Ch,onSuccess:Dh}),Lp=e=>qe(e)&&!(vc in e)?Sp(t=>zp(Fs(Mp(e,Bh(t))))):zp(Fs(e)),Rp=e=>B(V(e),Lp),zp=e=>{let t=new yp($t);return t.effect_instruction_i0=e,t},Bp=e=>B(V(e),zp),Vp=Sp(e=>nm(e.id())),Hp=e=>Sp(t=>e(t.id())),B=x(2,(e,t)=>{let n=new vp(tn);return n.effect_instruction_i0=e,n.effect_instruction_i1=t,n}),Up=e=>{let t=new vp(`OnStep`);return t.effect_instruction_i0=e,t},Wp=e=>B(e,be),Gp=x(2,(e,t)=>Kp(e,{onFailure:e=>nm(t.onFailure(e)),onSuccess:e=>nm(t.onSuccess(e))})),Kp=x(2,(e,t)=>{let n=new vp(nn);return n.effect_instruction_i0=e,n.effect_instruction_i1=t.onFailure,n.effect_instruction_i2=t.onSuccess,n}),qp=x(2,(e,t)=>Kp(e,{onFailure:e=>{if(qs(e).length>0)return zp($s(e));let n=Ks(e);return n.length>0?t.onFailure(La(n)):zp(e)},onSuccess:t.onSuccess})),Jp=x(2,(e,t)=>rm(()=>{let n=Ur(e),r=Vr(n.length),i=0;return wp(um({while:()=>i<n.length,body:()=>t(n[i],i),step:e=>{r[i++]=e}}),r)})),Yp=x(2,(e,t)=>rm(()=>{let n=Ur(e),r=0;return um({while:()=>r<n.length,body:()=>t(n[r],r),step:()=>{r++}})})),Xp=e=>{let t=new vp(on);return t.effect_instruction_i0=jf(1),t.effect_instruction_i1=()=>e,t},Zp=x(2,(e,t)=>B(e,e=>V(()=>t(e)))),Qp=x(2,(e,t)=>qp(e,{onFailure:e=>Rp(()=>t.onFailure(e)),onSuccess:e=>V(()=>t.onSuccess(e))})),$p=x(2,(e,t)=>Kp(e,{onFailure:e=>{let n=Xs(e);switch(n._tag){case`Left`:return Rp(()=>t(n.left));case`Right`:return zp(n.right)}},onSuccess:nm})),em=x(2,(e,t)=>sm(n=>Kp(n(e),{onFailure:e=>{let n=Ch(e);return Kp(t(n),{onFailure:t=>Ch(zs(e,t)),onSuccess:()=>n})},onSuccess:e=>{let n=Dh(e);return mm(t(n),n)}}))),tm=x(2,(e,t)=>em(e,Eh({onFailure:e=>Gs(e)?Tp(t(Js(e))):cm,onSuccess:()=>cm}))),nm=e=>{let t=new bp(rn);return t.effect_instruction_i0=e,t},rm=e=>{let t=new vp(Qt);return t.commit=e,t},V=e=>{let t=new vp(an);return t.effect_instruction_i0=e,t},im=x(e=>e.length===3||e.length===2&&!(qe(e[1])&&`onlyEffect`in e[1]),(e,t)=>B(e,e=>{let n=typeof t==`function`?t(e):t;return xp(n)?wp(n,e):tt(n)?Dp(t=>{n.then(n=>t(nm(e)),e=>t(Lp(new hh(e,`An unknown error occurred in Effect.tap`))))}):nm(e)})),am=e=>Sp(t=>{let n=b(t.getFiberRef(Zm),xr(()=>t.scope()));return e(Mm(Zm,z(n)))}),om=e=>{let t=new vp(on);return t.effect_instruction_i0=Mf(1),t.effect_instruction_i1=()=>e,t},sm=e=>Ep(e,function(){let e=new vp(on);return e.effect_instruction_i0=Mf(1),e.effect_instruction_i1=e=>xf(e)?xt(()=>this.effect_instruction_i0(Xp)):xt(()=>this.effect_instruction_i0(om)),e}),cm=nm(void 0),lm=e=>{let t=new vp(on);return t.effect_instruction_i0=e,t.effect_instruction_i1=void 0,t},um=e=>{let t=new vp(sn);return t.effect_instruction_i0=e.while,t.effect_instruction_i1=e.body,t.effect_instruction_i2=e.step,t},dm=e=>{let t=new vp(un);return e?.priority===void 0?t:Gm(t,e.priority)},fm=x(2,(e,t)=>B(e,e=>Zp(t,t=>[e,t]))),pm=x(2,(e,t)=>B(e,e=>wp(t,e))),mm=x(2,(e,t)=>B(e,()=>t)),hm=e=>B(Vp,t=>b(e,gm(t))),gm=x(2,(e,t)=>B(e.interruptAsFork(t),()=>e.await)),_m={_tag:`All`,syslog:0,label:`ALL`,ordinal:-(2**53-1),pipe(){return P(this,arguments)}},vm={_tag:`Fatal`,syslog:2,label:`FATAL`,ordinal:5e4,pipe(){return P(this,arguments)}},ym={_tag:`Error`,syslog:3,label:`ERROR`,ordinal:4e4,pipe(){return P(this,arguments)}},bm={_tag:`Warning`,syslog:4,label:`WARN`,ordinal:3e4,pipe(){return P(this,arguments)}},xm={_tag:`Info`,syslog:6,label:`INFO`,ordinal:2e4,pipe(){return P(this,arguments)}},Sm={_tag:`Debug`,syslog:7,label:`DEBUG`,ordinal:1e4,pipe(){return P(this,arguments)}},Cm={_tag:`Trace`,syslog:7,label:`TRACE`,ordinal:0,pipe(){return P(this,arguments)}},wm={_tag:`None`,syslog:7,label:`OFF`,ordinal:2**53-1,pipe(){return P(this,arguments)}},Tm=`effect/FiberRef`,Em=Symbol.for(Tm),Dm={_A:e=>e},Om=e=>Sp(t=>Dh(t.getFiberRef(e))),km=x(2,(e,t)=>B(Om(e),t)),Am=x(2,(e,t)=>jm(e,()=>[void 0,t])),jm=x(2,(e,t)=>Sp(n=>{let[r,i]=t(n.getFiberRef(e));return n.setFiberRef(e,i),nm(r)})),Mm=x(3,(e,t,n)=>Cp(pm(Om(t),Am(t,n)),()=>e,e=>Am(t,e))),Nm=(e,t)=>Lm(e,{differ:nf(),fork:t?.fork??be,join:t?.join}),Pm=e=>{let t=ef();return Lm(e,{differ:t,fork:t.empty})},Fm=e=>{let t=tf(nf());return Lm(e,{differ:t,fork:t.empty})},Im=e=>{let t=$d();return Lm(e,{differ:t,fork:t.empty})},Lm=(e,t)=>({...Tn,[Em]:Dm,initial:e,commit(){return Om(this)},diff:(e,n)=>t.differ.diff(e,n),combine:(e,n)=>t.differ.combine(e,n),patch:e=>n=>t.differ.patch(e,n),fork:t.fork,join:t.join??((e,t)=>t)}),Rm=e=>Lm(e,{differ:kf,fork:kf.empty}),zm=C(Symbol.for(`effect/FiberRef/currentContext`),()=>Im(Yc())),Bm=C(Symbol.for(`effect/FiberRef/currentSchedulingPriority`),()=>Nm(0)),Vm=C(Symbol.for(`effect/FiberRef/currentMaxOpsBeforeYield`),()=>Nm(2048)),Hm=C(Symbol.for(`effect/FiberRef/currentLogAnnotation`),()=>Nm(xu())),Um=C(Symbol.for(`effect/FiberRef/currentLogLevel`),()=>Nm(xm)),Wm=C(Symbol.for(`effect/FiberRef/currentLogSpan`),()=>Nm(Gu())),Gm=x(2,(e,t)=>Mm(e,Bm,t)),Km=C(Symbol.for(`effect/FiberRef/currentConcurrency`),()=>Nm(`unbounded`)),qm=C(Symbol.for(`effect/FiberRef/currentRequestBatching`),()=>Nm(!0)),Jm=C(Symbol.for(`effect/FiberRef/currentUnhandledErrorLogLevel`),()=>Nm(z(Sm))),Ym=C(Symbol.for(`effect/FiberRef/versionMismatchErrorLogLevel`),()=>Nm(z(bm))),Xm=C(Symbol.for(`effect/FiberRef/currentMetricLabels`),()=>Fm(Si())),Zm=C(Symbol.for(`effect/FiberRef/currentForkScopeOverride`),()=>Nm(R(),{fork:()=>R(),join:(e,t)=>e})),Qm=C(Symbol.for(`effect/FiberRef/currentInterruptedCause`),()=>Nm(Ps,{fork:()=>Ps,join:(e,t)=>e})),$m=Symbol.for(`effect/Scope`),eh=Symbol.for(`effect/CloseableScope`),th=(e,t)=>e.addFinalizer(()=>Tp(t)),nh=(e,t)=>e.close(t),rh=(e,t)=>e.fork(t),ih=function(){class e extends globalThis.Error{commit(){return Lp(this)}toJSON(){let e={...this};return this.message&&(e.message=this.message),this.cause&&(e.cause=this.cause),e}[N](){return this.toString===globalThis.Error.prototype.toString?`Bun`in globalThis?dc(Fs(this),{renderErrorCause:!0}):this:this.stack?`${this.toString()}\n${this.stack.split(`
|
|
13
|
-
|
|
14
|
-
`)}`:this.toString()}}return Object.assign(e.prototype,En),e}(),ah=(e,t)=>{class n extends ih{_tag=t}return Object.assign(n.prototype,e),n.prototype.name=t,n},oh=Symbol.for(`effect/Cause/errors/RuntimeException`),sh=ah({[oh]:oh},`RuntimeException`),ch=Symbol.for(`effect/Cause/errors/InterruptedException`),lh=e=>w(e,ch),uh=Symbol.for(`effect/Cause/errors/IllegalArgument`),dh=ah({[uh]:uh},`IllegalArgumentException`),fh=Symbol.for(`effect/Cause/errors/NoSuchElement`),ph=ah({[fh]:fh},`NoSuchElementException`),mh=Symbol.for(`effect/Cause/errors/UnknownException`),hh=function(){class e extends ih{_tag=`UnknownException`;error;constructor(e,t){super(t??`An unknown error occurred`,{cause:e}),this.error=e}}return Object.assign(e.prototype,{[mh]:mh,name:`UnknownException`}),e}(),gh=e=>xp(e)&&`_tag`in e&&(e._tag===`Success`||e._tag===`Failure`),_h=e=>e._tag===`Success`,vh=x(2,(e,t)=>{switch(e._tag){case $t:return Ch(e.effect_instruction_i0);case rn:return Dh(t)}}),yh=e=>vh(e,void 0),bh=(e,t)=>Ah(e,t?.parallel?Rs:zs),xh=e=>Ch(Is(e)),Sh=e=>Ch(Fs(e)),Ch=e=>{let t=new yp($t);return t.effect_instruction_i0=e,t},wh=e=>Ch(Ls(e)),Th=x(2,(e,t)=>{switch(e._tag){case $t:return Ch(e.effect_instruction_i0);case rn:return Dh(t(e.effect_instruction_i0))}}),Eh=x(2,(e,{onFailure:t,onSuccess:n})=>{switch(e._tag){case $t:return t(e.effect_instruction_i0);case rn:return n(e.effect_instruction_i0)}}),Dh=e=>{let t=new bp(rn);return t.effect_instruction_i0=e,t},Oh=Dh(void 0),kh=x(3,(e,t,{onFailure:n,onSuccess:r})=>{switch(e._tag){case $t:switch(t._tag){case rn:return Ch(e.effect_instruction_i0);case $t:return Ch(n(e.effect_instruction_i0,t.effect_instruction_i0))}case rn:switch(t._tag){case rn:return Dh(r(e.effect_instruction_i0,t.effect_instruction_i0));case $t:return Ch(t.effect_instruction_i0)}}}),Ah=(e,t)=>{let n=Sa(e);return Ia(n)?b(za(n),Oi(b(Ra(n),Th(xa)),(e,n)=>b(e,kh(n,{onSuccess:(e,t)=>b(e,Ma(t)),onFailure:t}))),Th(Da),Th(e=>Ta(e)),z):R()},jh=e=>({...Tn,[sp]:cp,state:Kl(lp([])),commit(){return Mh(this)},blockingOn:e}),Mh=e=>Op(t=>{let n=ql(e.state);switch(n._tag){case ip:return t(n.effect);case rp:return n.joiners.push(t),Ph(e,t)}},e.blockingOn),Nh=(e,t)=>{let n=ql(e.state);if(n._tag===`Pending`){Jl(e.state,up(t));for(let e=0,r=n.joiners.length;e<r;e++)n.joiners[e](t)}},Ph=(e,t)=>V(()=>{let n=ql(e.state);if(n._tag===`Pending`){let e=n.joiners.indexOf(t);e>=0&&n.joiners.splice(e,1)}}),Fh=Sp(e=>Dh(e.currentContext)),Ih=()=>Fh,Lh=e=>B(Ih(),e),Rh=x(2,(e,t)=>Mm(zm,t)(e)),zh=x(2,(e,t)=>Lh(n=>Rh(e,t(n)))),Bh=e=>{let t=e.currentSpan;return t!==void 0&&t._tag===`Span`?z(t):R()}})),Hh,Uh,Wh,Gh=v((()=>{bc(),Vh(),Hh=Hs,Uh=dh,Wh=dc})),Kh,qh,Jh,Yh,Xh=v((()=>{Kh=`InvalidData`,qh=`MissingData`,Jh=`SourceUnavailable`,Yh=`Unsupported`})),Zh,Qh,$h,eg,tg,ng,rg,ig,ag,og,sg,cg=v((()=>{Pi(),lr(),S(),Xh(),Zh=`effect/ConfigError`,Qh=Symbol.for(Zh),$h={_tag:`ConfigError`,[Qh]:Qh},eg=(e,t)=>{let n=Object.create($h);return n._op=`And`,n.left=e,n.right=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`${this.left} and ${this.right}`}}),Object.defineProperty(n,"message",{enumerable:!1,get(){return this.toString()}}),n},tg=(e,t)=>{let n=Object.create($h);return n._op=`Or`,n.left=e,n.right=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`${this.left} or ${this.right}`}}),Object.defineProperty(n,"message",{enumerable:!1,get(){return this.toString()}}),n},ng=(e,t,n={pathDelim:`.`})=>{let r=Object.create($h);return r._op=Kh,r.path=e,r.message=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`(Invalid data at ${b(this.path,Ni(n.pathDelim))}: "${this.message}")`}}),r},rg=(e,t,n={pathDelim:`.`})=>{let r=Object.create($h);return r._op=qh,r.path=e,r.message=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`(Missing data at ${b(this.path,Ni(n.pathDelim))}: "${this.message}")`}}),r},ig=(e,t,n,r={pathDelim:`.`})=>{let i=Object.create($h);return i._op=Jh,i.path=e,i.message=t,i.cause=n,Object.defineProperty(i,"toString",{enumerable:!1,value(){return`(Source unavailable at ${b(this.path,Ni(r.pathDelim))}: "${this.message}")`}}),i},ag=(e,t,n={pathDelim:`.`})=>{let r=Object.create($h);return r._op=Yh,r.path=e,r.message=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`(Unsupported operation at ${b(this.path,Ni(n.pathDelim))}: "${this.message}")`}}),r},og=x(2,(e,t)=>{switch(e._op){case`And`:return eg(og(e.left,t),og(e.right,t));case`Or`:return tg(og(e.left,t),og(e.right,t));case Kh:return ng([...t,...e.path],e.message);case qh:return rg([...t,...e.path],e.message);case Jh:return ig([...t,...e.path],e.message,e.cause);case Yh:return ag([...t,...e.path],e.message)}}),sg=x(3,(e,t,n)=>{let r=[e],i=[];for(;r.length>0;){let e=r.pop();switch(e._op){case`And`:r.push(e.right),r.push(e.left),i.push(L({_op:`AndCase`}));break;case`Or`:r.push(e.right),r.push(e.left),i.push(L({_op:`OrCase`}));break;case Kh:i.push(I(n.invalidDataCase(t,e.path,e.message)));break;case qh:i.push(I(n.missingDataCase(t,e.path,e.message)));break;case Jh:i.push(I(n.sourceUnavailableCase(t,e.path,e.message,e.cause)));break;case Yh:i.push(I(n.unsupportedCase(t,e.path,e.message)))}}let a=[];for(;i.length>0;){let e=i.pop();switch(e._op){case`Left`:switch(e.left._op){case`AndCase`:{let e=a.pop(),r=a.pop(),i=n.andCase(t,e,r);a.push(i);break}case`OrCase`:{let e=a.pop(),r=a.pop(),i=n.orCase(t,e,r);a.push(i);break}}break;case`Right`:a.push(e.right)}}if(a.length===0)throw Error(`BUG: ConfigError.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues`);return a.pop()})})),lg,ug,dg,fg,pg,mg,hg,gg,_g,vg=v((()=>{il(),Ul(),S(),Vh(),lg=`effect/Clock`,ug=Symbol.for(lg),dg=Jc(`effect/Clock`),fg=2**31-1,pg={unsafeSchedule(e,t){let n=jl(t);if(n>fg)return Ce;let r=!1,i=setTimeout(()=>{r=!0,e()},n);return()=>(clearTimeout(i),!r)}},mg=function(){let e=BigInt(1e6);if(typeof performance>`u`||typeof performance.now!=`function`)return()=>BigInt(Date.now())*e;let t;return()=>(t===void 0&&(t=BigInt(Date.now())*e-BigInt(Math.round(performance.now()*1e6))),t+BigInt(Math.round(performance.now()*1e6)))}(),hg=function(){let e=typeof process==`object`&&`hrtime`in process&&typeof process.hrtime.bigint==`function`?process.hrtime:void 0;if(!e)return mg;let t=mg()-e.bigint();return()=>t+e.bigint()}(),gg=class{[ug]=ug;unsafeCurrentTimeMillis(){return Date.now()}unsafeCurrentTimeNanos(){return hg()}currentTimeMillis=V(()=>this.unsafeCurrentTimeMillis());currentTimeNanos=V(()=>this.unsafeCurrentTimeNanos());scheduler(){return nm(pg)}sleep(e){return kp(t=>{let n=pg.unsafeSchedule(()=>t(cm),e);return Tp(V(n))})}},_g=()=>new gg})),yg,bg,xg=v((()=>{zn(),gr(),yg=pr,bg=e=>{if(e===`NaN`)return Rn(NaN);if(e===`Infinity`)return Rn(1/0);if(e===`-Infinity`)return Rn(-1/0);if(e.trim()===``)return Ln;let t=Number(e);return Number.isNaN(t)?Ln:Rn(t)}})),Sg,Cg=v((()=>{Sg=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,`\\$&`)})),wg,Tg,Eg=v((()=>{Pi(),lr(),S(),Qu(),Rr(),cg(),wg={_tag:`Empty`},Tg=x(2,(e,t)=>{let n=Ku(t),r=e;for(;Hu(n);){let e=n.head;switch(e._tag){case`Empty`:n=n.tail;break;case`AndThen`:n=Wu(e.first,Wu(e.second,n.tail));break;case`MapName`:r=wi(r,e.f),n=n.tail;break;case`Nested`:r=Kr(r,e.name),n=n.tail;break;case`Unnested`:if(b(ii(r),Ir(e.name)))r=ci(r),n=n.tail;else return L(rg(r,`Expected ${e.name} to be in path in ConfigProvider#unnested`))}}return I(r)})})),Dg,Og,kg,Ag,jg,Mg,Ng,Pg,Fg,Ig,Lg,Rg,zg=v((()=>{Dg=`Constant`,Og=`Fail`,kg=`Fallback`,Ag=`Described`,jg=`Lazy`,Mg=`MapOrFail`,Ng=`Nested`,Pg=`Primitive`,Fg=`Redacted`,Ig=`Sequence`,Lg=`HashMap`,Rg=`ZipWith`})),Bg,Vg,Hg,Ug,Wg,Gg,Kg,qg,Jg,Yg,Xg,Zg,Qg,$g,e_,t_,n_,r_,i_,a_,o_,s_,c_,l_=v((()=>{Pi(),il(),lr(),S(),Au(),Cs(),xg(),Rr(),F(),Cg(),cg(),Eg(),Vh(),zg(),Bg=(e,t)=>[...e,...t],Vg=`effect/ConfigProvider`,Hg=Symbol.for(Vg),Ug=Jc(`effect/ConfigProvider`),Wg=`effect/ConfigProviderFlat`,Gg=Symbol.for(Wg),Kg=e=>({[Hg]:Hg,pipe(){return P(this,arguments)},...e}),qg=e=>({[Gg]:Gg,patch:e.patch,load:(t,n,r=!0)=>e.load(t,n,r),enumerateChildren:e.enumerateChildren}),Jg=e=>Kg({load:t=>B(e_(e,Si(),t,!1),e=>br(ii(e),{onNone:()=>Lp(rg(Si(),`Expected a single value having structure: ${t}`)),onSome:nm})),flattened:e}),Yg=e=>{let{pathDelim:t,seqDelim:n}=Object.assign({},{pathDelim:`_`,seqDelim:`,`},e),r=e=>b(e,Ni(t)),i=e=>e.split(t),a=()=>typeof process<`u`&&`env`in process&&typeof process.env==`object`?process.env:{};return Jg(qg({load:(e,t,i=!0)=>{let o=r(e),s=a();return b(o in s?z(s[o]):R(),$p(()=>rg(e,`Expected ${o} to exist in the process context`)),B(r=>r_(r,e,t,n,i)))},enumerateChildren:e=>V(()=>{let t=a(),n=Object.keys(t).map(e=>i(e.toUpperCase())).filter(t=>{for(let n=0;n<e.length;n++){let r=b(e,ri(n)),i=t[n];if(i===void 0||r!==i)return!1}return!0}).flatMap(t=>t.slice(e.length,e.length+1));return ms(n)}),patch:wg}))},Xg=(e,t,n,r)=>{let i=ki(n.length,t=>t>=r.length?R():z([e(t),t+1])),a=ki(r.length,e=>e>=n.length?R():z([t(e),e+1]));return[Bg(n,i),Bg(r,a)]},Zg=(e,t)=>{let n=t;if(n._tag===`Nested`){let t=e.slice();for(;n._tag===`Nested`;)t.push(n.name),n=n.config;return t}return e},Qg={andCase:(e,t,n)=>eg(t,n),orCase:(e,t,n)=>tg(t,n),invalidDataCase:(e,t)=>ng(t,`<redacted>`),missingDataCase:(e,t)=>rg(t,`<redacted>`),sourceUnavailableCase:(e,t,n,r)=>ig(t,`<redacted>`,r),unsupportedCase:(e,t)=>ag(t,`<redacted>`)},$g=e=>sg(e,void 0,Qg),e_=(e,t,n,r)=>{let i=n;switch(i._tag){case Dg:return nm(Ci(i.value));case Ag:return rm(()=>e_(e,t,i.config,r));case Og:return Lp(rg(t,i.message));case kg:return b(rm(()=>e_(e,t,i.first,r)),Ap(n=>i.condition(n)?b(e_(e,t,i.second,r),Ap(e=>Lp(tg(n,e)))):Lp(n)));case jg:return rm(()=>e_(e,t,i.config(),r));case Mg:return rm(()=>b(e_(e,t,i.original,r),B(Jp(e=>b(i.mapOrFail(e),$p(og(Zg(t,i.original))))))));case Ng:return rm(()=>e_(e,Bg(t,Ci(i.name)),i.config,r));case Pg:return b(Tg(t,e.patch),B(t=>b(e.load(t,i,r),B(e=>{if(e.length===0){let e=b(oi(t),xr(()=>`<n/a>`));return Lp(rg([],`Expected ${i.description} with name ${e}`))}return nm(e)}))));case Fg:return rm(()=>b(e_(e,t,i.original,r),$p($g),Zp(wi(i.redact))));case Ig:return b(Tg(t,e.patch),B(n=>b(e.enumerateChildren(n),B(a_),B(n=>n.length===0?rm(()=>Zp(e_(e,t,i.config,!0),Ci)):b(Jp(n,n=>e_(e,qr(t,`[${n}]`),i.config,!0)),Zp(e=>{let t=Ei(e);return t.length===0?Ci(Si()):Ci(t)}))))));case Lg:return rm(()=>b(Tg(t,e.patch),B(t=>b(e.enumerateChildren(t),B(n=>b(n,Jp(n=>e_(e,Bg(t,Ci(n)),i.valueConfig,r)),Zp(e=>e.length===0?Ci(xu()):b(i_(e),wi(e=>Su(mi(Ur(n),e)))))))))));case Rg:return rm(()=>b(e_(e,t,i.left,r),Fp,B(n=>b(e_(e,t,i.right,r),Fp,B(e=>{if(er(n)&&er(e))return Lp(eg(n.left,e.left));if(er(n)&&tr(e))return Lp(n.left);if(tr(n)&&er(e))return Lp(e.left);if(tr(n)&&tr(e)){let r=b(t,Ni(`.`)),a=t_(t,r),[o,s]=Xg(a,a,b(n.right,wi(I)),b(e.right,wi(I)));return b(o,mi(s),Jp(([e,t])=>b(fm(e,t),Zp(([e,t])=>i.zip(e,t)))))}throw Error(`BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues`)})))))}},t_=(e,t)=>n=>L(rg(e,`The element at index ${n} in a sequence at path "${t}" was missing`)),n_=(e,t)=>e.split(RegExp(`\\s*${Sg(t)}\\s*`)),r_=(e,t,n,r,i)=>i?b(n_(e,r),Jp(e=>n.parse(e.trim())),$p(og(t))):b(n.parse(e),Qp({onFailure:og(t),onSuccess:Ci})),i_=e=>Object.keys(e[0]).map(t=>e.map(e=>e[t])),a_=e=>b(Jp(e,s_),Qp({onFailure:()=>Si(),onSuccess:pi(yg)}),Fp,Zp(or)),o_=/^(\[(\d+)\])$/,s_=e=>{let t=e.match(o_);if(t!==null){let e=t[2];return b(e!==void 0&&e.length>0?z(e):R(),kr(c_))}return R()},c_=e=>{let t=Number.parseInt(e);return Number.isNaN(t)?R():z(t)}})),u_,d_,f_,p_=v((()=>{il(),Vh(),u_=Symbol.for(`effect/Console`),d_=Jc(`effect/Console`),f_={[u_]:u_,assert(e,...t){return V(()=>{console.assert(e,...t)})},clear:V(()=>{console.clear()}),count(e){return V(()=>{console.count(e)})},countReset(e){return V(()=>{console.countReset(e)})},debug(...e){return V(()=>{console.debug(...e)})},dir(e,t){return V(()=>{console.dir(e,t)})},dirxml(...e){return V(()=>{console.dirxml(...e)})},error(...e){return V(()=>{console.error(...e)})},group(e){return e?.collapsed?V(()=>console.groupCollapsed(e?.label)):V(()=>console.group(e?.label))},groupEnd:V(()=>{console.groupEnd()}),info(...e){return V(()=>{console.info(...e)})},log(...e){return V(()=>{console.log(...e)})},table(e,t){return V(()=>{console.table(e,t)})},time(e){return V(()=>console.time(e))},timeEnd(e){return V(()=>console.timeEnd(e))},timeLog(e,...t){return V(()=>{console.timeLog(e,...t)})},trace(...e){return V(()=>{console.trace(...e)})},warn(...e){return V(()=>{console.warn(...e)})},unsafe:console}})),m_,h_,g_,__,v_,y_,b_,x_=v((()=>{Ba(),il(),S(),Mt(),St(),Vh(),m_=`effect/Random`,h_=Symbol.for(m_),g_=Jc(`effect/Random`),__=class{seed;[h_]=h_;PRNG;constructor(e){this.seed=e,this.PRNG=new mt(e)}get next(){return V(()=>this.PRNG.number())}get nextBoolean(){return Zp(this.next,e=>e>.5)}get nextInt(){return V(()=>this.PRNG.integer(2**53-1))}nextRange(e,t){return Zp(this.next,n=>(t-e)*n+e)}nextIntBetween(e,t){return V(()=>this.PRNG.integer(t-e)+e)}shuffle(e){return v_(e,e=>this.nextIntBetween(0,e))}},v_=(e,t)=>rm(()=>b(V(()=>Array.from(e)),B(e=>{let n=[];for(let t=e.length;t>=2;--t)n.push(t);return b(n,Yp(n=>b(t(n),Zp(t=>y_(e,n-1,t)))),wp(Sa(e)))}))),y_=(e,t,n)=>{let r=e[t];return e[t]=e[n],e[n]=r,e},b_=e=>new __(D(e))})),S_,C_,w_,T_,E_,D_,O_,k_,A_=v((()=>{il(),S(),S_=Symbol.for(`effect/Tracer`),C_=e=>({[S_]:S_,...e}),w_=Jc(`effect/Tracer`),T_=Jc(`effect/ParentSpan`),E_=function(){return function(e){let t=``;for(let n=0;n<e;n++)t+=`abcdef0123456789`.charAt(Math.floor(Math.random()*16));return t}}(),D_=class{name;parent;context;startTime;kind;_tag=`Span`;spanId;traceId=`native`;sampled=!0;status;attributes;events=[];links;constructor(e,t,n,r,i,a){this.name=e,this.parent=t,this.context=n,this.startTime=i,this.kind=a,this.status={_tag:`Started`,startTime:i},this.attributes=new Map,this.traceId=t._tag===`Some`?t.value.traceId:E_(32),this.spanId=E_(16),this.links=Array.from(r)}end(e,t){this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,n){this.events.push([e,t,n??{}])}addLinks(e){this.links.push(...e)}},O_=C_({span:(e,t,n,r,i,a)=>new D_(e,t,n,r,i,a),context:e=>e()}),k_=rl()(`effect/Tracer/DisablePropagation`,{defaultValue:Ce})})),j_,M_,N_=v((()=>{il(),S(),Ie(),vg(),l_(),Vh(),p_(),x_(),A_(),j_=b(Yc(),Zc(dg,_g()),Zc(d_,f_),Zc(g_,b_(Math.random())),Zc(Ug,Yg()),Zc(w_,O_)),M_=C(Symbol.for(`effect/DefaultServices/currentServices`),()=>Im(j_))})),P_,F_,I_=v((()=>{Vh(),P_=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return{BaseEffectError:class extends ih{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}(),F_=e=>{let t={BaseEffectError:class extends P_{_tag=e}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError}})),L_,R_,z_,B_=v((()=>{On(),L_=Cn,R_=Dn,z_=class extends R_{}})),V_,H_,U_,W_,G_,K_,q_,J_,Y_=v((()=>{V_=`Sequential`,H_=`Parallel`,U_=`ParallelN`,W_={_tag:V_},G_={_tag:H_},K_=e=>({_tag:U_,parallelism:e}),q_=e=>e._tag===V_,J_=e=>e._tag===H_})),X_,Z_,Q_,$_=v((()=>{Y_(),X_=W_,Z_=G_,Q_=K_}));function ev(e){return new rv(e)}function tv(){return ev(new Map)}var nv,rv,iv,av,ov,sv,cv,lv,uv,dv,fv,pv,mv=v((()=>{Pi(),M(),S(),Rr(),F(),nv=Symbol.for(`effect/FiberRefs`),rv=class{locals;[nv]=nv;constructor(e){this.locals=e}pipe(){return P(this,arguments)}},iv=(e,t,n,r=!1)=>{let i=e,a=t,o=n,s=r,c;for(;c===void 0;)if($r(a)&&$r(o)){let e=ai(a)[0],t=ci(a),n=ai(o)[0],r=ai(o)[1],i=ci(o);e.startTimeMillis<n.startTimeMillis?(o=i,s=!0):e.startTimeMillis>n.startTimeMillis?a=t:e.id<n.id?(o=i,s=!0):e.id>n.id?a=t:c=[r,s]}else c=[i.initial,!0];return c},av=x(3,(e,t,n)=>{let r=new Map(e.locals);return n.locals.forEach((e,n)=>{let i=e[0][1];if(!e[0][0][j](t)){if(!r.has(n)){if(A(i,n.initial))return;r.set(n,[[t,n.join(n.initial,i)]]);return}let a=r.get(n),[o,s]=iv(n,a,e);if(s){let e=n.diff(o,i),s=a[0][1],c=n.join(s,n.patch(e)(s));if(!A(s,c)){let e,i=a[0][0];e=i[j](t)?[[i,c],...a.slice(1)]:[[t,c],...a],r.set(n,e)}}}}),new rv(r)}),ov=x(2,(e,t)=>{let n=new Map;return sv(e,n,t),new rv(n)}),sv=(e,t,n)=>{e.locals.forEach((e,r)=>{let i=e[0][1],a=r.patch(r.fork)(i);A(i,a)?t.set(r,e):t.set(r,[[n,a],...e])})},cv=x(2,(e,t)=>{let n=new Map(e.locals);return n.delete(t),new rv(n)}),lv=x(2,(e,t)=>e.locals.has(t)?z(ai(e.locals.get(t))[1]):R()),uv=x(2,(e,t)=>b(lv(e,t),xr(()=>t.initial))),dv=x(2,(e,{fiberId:t,fiberRef:n,value:r})=>{if(e.locals.size===0)return new rv(new Map([[n,[[t,r]]]]));let i=new Map(e.locals);return fv(i,t,n,r),new rv(i)}),fv=(e,t,n,r)=>{let i=e.get(n)??[],a;if($r(i)){let[e,n]=ai(i);if(e[j](t)){if(A(n,r))return;a=[[t,r],...i.slice(1)]}else a=[[t,r],...i]}else a=[[t,r]];e.set(n,a)},pv=x(2,(e,{entries:t,forkAs:n})=>{if(e.locals.size===0)return new rv(new Map(t));let r=new Map(e.locals);return n!==void 0&&sv(e,r,n),t.forEach(([e,t])=>{t.length===1?fv(r,t[0][0],e,t[0][1]):t.forEach(([t,n])=>{fv(r,t,e,n)})}),new rv(r)})})),hv,gv,_v,vv=v((()=>{mv(),hv=uv,gv=pv,_v=tv})),yv,bv,xv,Sv,Cv,wv,Tv,Ev,Dv=v((()=>{Pi(),M(),S(),mv(),yv=`Empty`,bv=`Remove`,xv=`Update`,Sv=`AndThen`,Cv={_tag:yv},wv=(e,t)=>{let n=new Map(e.locals),r=Cv;for(let[e,i]of t.locals.entries()){let t=ai(i)[1],a=n.get(e);if(a!==void 0){let n=ai(a)[1];A(n,t)||(r=Tv({_tag:xv,fiberRef:e,patch:e.diff(n,t)})(r))}else r=Tv({_tag:`Add`,fiberRef:e,value:t})(r);n.delete(e)}for(let[e]of n.entries())r=Tv({_tag:bv,fiberRef:e})(r);return r},Tv=x(2,(e,t)=>({_tag:Sv,first:e,second:t})),Ev=x(3,(e,t,n)=>{let r=n,i=Ci(e);for(;$r(i);){let e=ai(i),n=ci(i);switch(e._tag){case yv:i=n;break;case`Add`:r=dv(r,{fiberId:t,fiberRef:e.fiberRef,value:e.value}),i=n;break;case bv:r=cv(r,e.fiberRef),i=n;break;case xv:{let a=uv(r,e.fiberRef);r=dv(r,{fiberId:t,fiberRef:e.fiberRef,value:e.fiberRef.patch(e.patch)(a)}),i=n;break}case Sv:i=Kr(e.first)(Kr(e.second)(n))}}return r})})),Ov,kv,Av=v((()=>{Dv(),Ov=wv,kv=Ev})),jv,Mv,Nv,Pv,Fv,Iv,Lv,Rv,zv,Bv,Vv,Hv,Uv,Wv,Gv=v((()=>{M(),S(),Mt(),T(),jv=`effect/FiberStatus`,Mv=Symbol.for(jv),Nv=`Done`,Pv=`Running`,Fv=`Suspended`,Iv=Ot(`${jv}-${Nv}`),Lv=class{[Mv]=Mv;_tag=Nv;[E](){return Iv}[j](e){return Uv(e)&&e._tag===`Done`}},Rv=class{runtimeFlags;[Mv]=Mv;_tag=Pv;constructor(e){this.runtimeFlags=e}[E](){return b(D(jv),O(D(this._tag)),O(D(this.runtimeFlags)),k(this))}[j](e){return Uv(e)&&e._tag===`Running`&&this.runtimeFlags===e.runtimeFlags}},zv=class{runtimeFlags;blockingOn;[Mv]=Mv;_tag=Fv;constructor(e,t){this.runtimeFlags=e,this.blockingOn=t}[E](){return b(D(jv),O(D(this._tag)),O(D(this.runtimeFlags)),O(D(this.blockingOn)),k(this))}[j](e){return Uv(e)&&e._tag===`Suspended`&&this.runtimeFlags===e.runtimeFlags&&A(this.blockingOn,e.blockingOn)}},Bv=new Lv,Vv=e=>new Rv(e),Hv=(e,t)=>new zv(e,t),Uv=e=>w(e,Mv),Wv=e=>e._tag===Nv})),Kv,qv,Jv,Yv,Xv=v((()=>{Gv(),Kv=Bv,qv=Vv,Jv=Hv,Yv=Wv})),Zv,Qv,$v,ey,ty,ny,ry,iy,ay,oy,sy,cy=v((()=>{S(),Vh(),xg(),gr(),Zv=_m,Qv=vm,$v=ym,ey=bm,ty=xm,ny=Sm,ry=Cm,iy=wm,ay=b(yg,mr(e=>e.ordinal)),oy=hr(ay),sy=e=>{switch(e){case`All`:return Zv;case`Debug`:return ny;case`Error`:return $v;case`Fatal`:return Qv;case`Info`:return ty;case`Trace`:return ry;case`None`:return iy;case`Warning`:return ey}}}));function ly(e){return Zy(`Micro.evaluate: Not implemented`)}var uy,dy,fy,py,my,hy,gy,_y,vy,yy,by,xy,Sy,Cy,wy,Ty,Ey,Dy,Oy,ky,Ay,jy,My,Ny,Py,Fy,Iy,Ly,Ry,zy,By,Vy,Hy,Uy,Wy,Gy,Ky,qy,Jy,Yy,Xy,Zy,Qy,$y,eb,tb,nb,rb,ib,ab,ob,sb,cb,lb,ub,db,fb,pb,mb,hb=v((()=>{il(),B_(),M(),S(),Ie(),Mt(),Xt(),qc(),On(),F(),T(),St(),uy=Symbol.for(`effect/Micro`),dy=Symbol.for(`effect/Micro/MicroExit`),fy=Symbol.for(`effect/Micro/MicroCause`),py={_E:be},my=class extends globalThis.Error{_tag;traces;[fy];constructor(e,t,n){let r=`MicroCause.${e}`,i,a,o;if(t instanceof globalThis.Error){i=`(${r}) ${t.name}`,a=t.message;let e=a.split(`
|
|
15
|
-
`).length;o=t.stack?`(${r}) ${t.stack.split(`
|
|
16
|
-
`).slice(0,e+3).join(`
|
|
17
|
-
`)}`:`${i}: ${a}`}else i=r,a=Ut(t,0),o=`${i}: ${a}`;n.length>0&&(o+=`\n ${n.join(`
|
|
18
|
-
`)}`),super(a),this._tag=e,this.traces=n,this[fy]=py,this.name=i,this.stack=o}pipe(){return P(this,arguments)}toString(){return this.stack}[N](){return this.stack}},hy=class extends my{error;constructor(e,t=[]){super(`Fail`,e,t),this.error=e}},gy=(e,t=[])=>new hy(e,t),_y=class extends my{defect;constructor(e,t=[]){super(`Die`,e,t),this.defect=e}},vy=(e,t=[])=>new _y(e,t),yy=class extends my{constructor(e=[]){super(`Interrupt`,`interrupted`,e)}},by=(e=[])=>new yy(e),xy=e=>e._tag===`Interrupt`,Sy=Symbol.for(`effect/Micro/MicroFiber`),Cy={_A:be,_E:be},wy=class{context;interruptible;[Sy];_stack=[];_observers=[];_exit;_children;currentOpCount=0;constructor(e,t=!0){this.context=e,this.interruptible=t,this[Sy]=Cy}getRef(e){return Hc(this.context,e)}addObserver(e){return this._exit?(e(this._exit),Te):(this._observers.push(e),()=>{let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}_interrupted=!1;unsafeInterrupt(){this._exit||(this._interrupted=!0,this.interruptible&&this.evaluate(Xy))}unsafePoll(){return this._exit}evaluate(e){if(this._exit)return;if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===My)return;let n=Ty.interruptChildren&&Ty.interruptChildren(this);if(n!==void 0)return this.evaluate(Gy(n,()=>t));this._exit=t;for(let e=0;e<this._observers.length;e++)this._observers[e](t);this._observers.length=0}runLoop(e){let t=!1,n=e;this.currentOpCount=0;try{for(;;){if(this.currentOpCount++,!t&&this.getRef(ib).shouldYield(this)){t=!0;let e=n;n=Gy(Hy,()=>e)}if(n=n[Oy](this),n===My){let e=this._yielded;return dy in e?(this._yielded=void 0,e):My}}}catch(e){return w(n,Oy)?Zy(e):Zy(`MicroFiber.runLoop: Not a valid effect: ${String(n)}`)}}getCont(e){for(;;){let t=this._stack.pop();if(!t)return;let n=t[jy]&&t[jy](this);if(n)return{[e]:n};if(t[e])return t}}_yielded=void 0;yieldWith(e){return this._yielded=e,My}children(){return this._children??=new Set}},Ty=C(`effect/Micro/fiberMiddleware`,()=>({interruptChildren:void 0})),Ey=Symbol.for(`effect/Micro/identifier`),Dy=Symbol.for(`effect/Micro/args`),Oy=Symbol.for(`effect/Micro/evaluate`),ky=Symbol.for(`effect/Micro/successCont`),Ay=Symbol.for(`effect/Micro/failureCont`),jy=Symbol.for(`effect/Micro/ensureCont`),My=Symbol.for(`effect/Micro/Yield`),Ny={_A:be,_E:be,_R:be},Py={...L_,_op:`Micro`,[uy]:Ny,pipe(){return P(this,arguments)},[Symbol.iterator](){return new st(new gt(this))},toJSON(){return{_id:`Micro`,op:this[Ey],...Dy in this?{args:this[Dy]}:void 0}},toString(){return Ht(this)},[N](){return Ht(this)}},Fy=e=>({...Py,[Ey]:e.op,[Oy]:e.eval??ly,[ky]:e.contA,[Ay]:e.contE,[jy]:e.ensure}),Iy=e=>{let t=Fy(e);return function(){let n=Object.create(t);return n[Dy]=e.single===!1?arguments:arguments[0],n}},Ly=e=>{let t={...Fy(e),[dy]:dy,_tag:e.op,get[e.prop](){return this[Dy]},toJSON(){return{_id:`MicroExit`,_tag:e.op,[e.prop]:this[Dy]}},[j](t){return qy(t)&&t._tag===e.op&&A(this[Dy],t[Dy])},[E](){return k(this,O(Ot(e.op))(D(this[Dy])))}};return function(e){let n=Object.create(t);return n[Dy]=e,n[ky]=void 0,n[Ay]=void 0,n[jy]=void 0,n}},Ry=Ly({op:`Success`,prop:`value`,eval(e){let t=e.getCont(ky);return t?t[ky](this[Dy],e):e.yieldWith(this)}}),zy=Ly({op:`Failure`,prop:`cause`,eval(e){let t=e.getCont(Ay);for(;xy(this[Dy])&&t&&e.interruptible;)t=e.getCont(Ay);return t?t[Ay](this[Dy],e):e.yieldWith(this)}}),By=e=>zy(gy(e)),Vy=Iy({op:`Yield`,eval(e){let t=!1;return e.getRef(ib).scheduleTask(()=>{t||e.evaluate(Qy)},this[Dy]??0),e.yieldWith(()=>{t=!0})}}),Hy=Vy(0),Uy=Ry(void 0),Wy=Iy({op:`WithMicroFiber`,eval(e){return this[Dy](e)}}),Gy=x(2,(e,t)=>{let n=Object.create(Ky);return n[Dy]=e,n[ky]=t,n}),Ky=Fy({op:`OnSuccess`,eval(e){return e._stack.push(this),this[Dy]}}),qy=e=>w(e,dy),Jy=Ry,Yy=zy,Xy=Yy(by()),Zy=e=>Yy(vy(e)),Qy=Jy(void 0),$y=`setImmediate`in globalThis?globalThis.setImmediate:e=>setTimeout(e,0),eb=class{tasks=[];running=!1;scheduleTask(e,t){this.tasks.push(e),this.running||(this.running=!0,$y(this.afterScheduled))}afterScheduled=()=>{this.running=!1,this.runTasks()};runTasks(){let e=this.tasks;this.tasks=[];for(let t=0,n=e.length;t<n;t++)e[t]()}shouldYield(e){return e.currentOpCount>=e.getRef(rb)}flush(){for(;this.tasks.length>0;)this.runTasks()}},tb=x(2,(e,t)=>Wy(n=>{let r=n.context;return n.context=t(r),sb(e,()=>(n.context=r,Uy))})),nb=x(2,(e,t)=>tb(e,tl(t))),rb=class extends rl()(`effect/Micro/currentMaxOpsBeforeYield`,{defaultValue:()=>2048}){},rl()(`effect/Micro/currentConcurrency`,{defaultValue:()=>`unbounded`}),ib=class extends rl()(`effect/Micro/currentScheduler`,{defaultValue:()=>new eb}){},ab=x(2,(e,t)=>{let n=Object.create(ob);return n[Dy]=e,n[ky]=t.onSuccess,n[Ay]=t.onFailure,n}),ob=Fy({op:`OnSuccessAndFailure`,eval(e){return e._stack.push(this),this[Dy]}}),sb=x(2,(e,t)=>ub(n=>ab(n(e),{onFailure:e=>Gy(t(Yy(e)),()=>zy(e)),onSuccess:e=>Gy(t(Jy(e)),()=>Ry(e))}))),cb=Iy({op:`SetInterruptible`,ensure(e){if(e.interruptible=this[Dy],e._interrupted&&e.interruptible)return()=>Xy}}),lb=e=>Wy(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(cb(!1)),t._interrupted?Xy:e)),ub=e=>Wy(t=>t.interruptible?(t.interruptible=!1,t._stack.push(cb(!0)),e(lb)):e(be)),db=(e,t)=>{let n=new wy(ib.context(t?.scheduler??new eb));if(n.evaluate(e),t?.signal){if(t.signal.aborted)n.unsafeInterrupt();else{let e=()=>n.unsafeInterrupt();t.signal.addEventListener(`abort`,e,{once:!0}),n.addObserver(()=>t.signal.removeEventListener(`abort`,e))}}return n},fb=function(){class e extends globalThis.Error{}return Object.assign(e.prototype,Py,wn,{[Ey]:`Failure`,[Oy](){return By(this)},toString(){return this.message?`${this.name}: ${this.message}`:this.name},toJSON(){return{...this}},[N](){let e=this.stack;return e?`${this.toString()}\n${e.split(`
|
|
18
|
+
`);for(let i=1;i<o.length;i++){if(o[i].includes(" at new BaseEffectError")||o[i].includes(" at new YieldableError")){i++;continue}if(o[i].includes("Generator.next"))break;if(o[i].includes("effect_internal_function"))break;n.push(o[i].replace(/at .*effect_instruction_i.*\((.*)\)/,"at $1").replace(/EffectPrimitive\.\w+/,"<anonymous>"))}if(r){let i=r,a=0;while(i&&i._tag==="Span"&&a<10){let s=rN.get(i);if(typeof s==="function"){let c=s();if(typeof c==="string"){let l=c.matchAll(tN),u=!1;for(let[,p]of l)u=!0,n.push(` at ${i.name} (${p})`);if(!u)n.push(` at ${i.name} (${c.replace(/^at /,"")})`)}else n.push(` at ${i.name}`)}else n.push(` at ${i.name}`);i=Bt(i.parent),a++}}return n.join(`
|
|
19
|
+
`)},mi,Ds=(e)=>bu(e,void 0,{emptyCase:()=>[],dieCase:(t,r)=>[Lm(r)],failCase:(t,r)=>[Lm(r)],interruptCase:()=>[],parallelCase:(t,r,n)=>[...r,...n],sequentialCase:(t,r,n)=>[...r,...n]});var ma=x(()=>{Ve();Jr();er();le();H();Me();li();Be();Ye();_e();ge();Dm=Symbol.for(hw),GM={_E:(e)=>e},pa={[Dm]:GM,[M](){return g(v(hw),J(v(ZM(this))),oe(this))},[I](e){return gw(e)&&YM(this,e)},pipe(){return E(this,arguments)},toJSON(){switch(this._tag){case"Empty":return{_id:"Cause",_tag:this._tag};case"Die":return{_id:"Cause",_tag:this._tag,defect:ue(this.defect)};case"Interrupt":return{_id:"Cause",_tag:this._tag,fiberId:this.fiberId.toJSON()};case"Fail":return{_id:"Cause",_tag:this._tag,failure:ue(this.error)};case"Sequential":case"Parallel":return{_id:"Cause",_tag:this._tag,left:ue(this.left),right:ue(this.right)}}},toString(){return Mr(this)},[re](){return this.toJSON()}},In=(()=>{let e=Object.create(pa);return e._tag=fo,e})(),Bm=d(2,(e,t)=>{let r=[e];while(r.length>0){let n=r.pop(),o=t(n);switch(o._tag){case"None":{switch(n._tag){case di:case pi:{r.push(n.right),r.push(n.left);break}}break}case"Some":return o}}return C()}),QM={emptyCase:fs,failCase:Qn,dieCase:Qn,interruptCase:fs,sequentialCase:(e,t,r)=>t&&r,parallelCase:(e,t,r)=>t&&r},Vm=d(2,(e,{onDie:t,onEmpty:r,onFail:n,onInterrupt:o,onParallel:i,onSequential:a})=>bu(e,void 0,{emptyCase:()=>r,failCase:(s,c)=>n(c),dieCase:(s,c)=>t(c),interruptCase:(s,c)=>o(c),sequentialCase:(s,c,l)=>a(c,l),parallelCase:(s,c,l)=>i(c,l)})),fi=d(3,(e,t,r)=>{let n=t,o=e,i=[];while(o!==void 0){let a=r(n,o);switch(n=Re(a)?a.value:n,o._tag){case di:{i.push(o.right),o=o.left;break}case pi:{i.push(o.right),o=o.left;break}default:{o=void 0;break}}if(o===void 0&&i.length>0)o=i.pop()}return n}),bu=d(3,(e,t,r)=>{let n=[e],o=[];while(n.length>0){let a=n.pop();switch(a._tag){case fo:{o.push(Z(r.emptyCase(t)));break}case mo:{o.push(Z(r.failCase(t,a.error)));break}case ua:{o.push(Z(r.dieCase(t,a.defect)));break}case ui:{o.push(Z(r.interruptCase(t,a.fiberId)));break}case di:{n.push(a.right),n.push(a.left),o.push(K({_tag:fw}));break}case pi:{n.push(a.right),n.push(a.left),o.push(K({_tag:mw}));break}}}let i=[];while(o.length>0){let a=o.pop();switch(a._tag){case"Left":{switch(a.left._tag){case fw:{let s=i.pop(),c=i.pop(),l=r.sequentialCase(t,s,c);i.push(l);break}case mw:{let s=i.pop(),c=i.pop(),l=r.parallelCase(t,s,c);i.push(l);break}}break}case"Right":{i.push(a.right);break}}}if(i.length===0)throw Error("BUG: Cause.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");return i.pop()}),tN=/\((.*)\)/g,rN=j("effect/Tracer/spanToTrace",()=>new WeakMap),mi=Symbol.for("effect/SpanAnnotation")});var _w,Us,oN="effect/STM",iN,ww,aN,Tw=(e)=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=2;let r=Error();Error.stackTraceLimit=t;let n=Object.create(ww);return Object.defineProperty(n,"stack",{get(){return r.stack}}),n.key=e,n},Ew=()=>(e,t)=>{let r=Error.stackTraceLimit;Error.stackTraceLimit=2;let n=Error();Error.stackTraceLimit=r;function o(){}return Object.setPrototypeOf(o,aN),o.key=e,o.defaultValue=t.defaultValue,Object.defineProperty(o,"stack",{get(){return n.stack}}),o},Km,sN,ho=(e)=>{let t=Object.create(sN);return t.unsafeMap=e,t},cN=(e)=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(e.stack){let r=e.stack.split(`
|
|
20
|
+
`);if(r.length>2){let n=r[2].match(/at (.*)/);if(n)t.message=t.message+` (defined at ${n[1]})`}}if(t.stack){let r=t.stack.split(`
|
|
21
|
+
`);r.splice(1,3),t.stack=r.join(`
|
|
22
|
+
`)}return t},vw=(e)=>k(e,Km),Ow=(e)=>k(e,Us),lN,Rw=()=>lN,Wm=(e,t)=>ho(new Map([[e.key,t]])),kw,zm,Jm=(e)=>{if(zm.has(e.key))return zm.get(e.key);let t=e.defaultValue();return zm.set(e.key,t),t},Cw=(e,t)=>e.unsafeMap.has(t.key)?e.unsafeMap.get(t.key):Jm(t),Gm,Aw,Pw,Iw;var _u=x(()=>{le();H();Me();Be();_e();ge();wn();em();_w=Symbol.for("effect/Context/Tag"),Us=Symbol.for("effect/Context/Reference"),iN=Symbol.for(oN),ww={..._n,_op:"Tag",[iN]:no,[_w]:{_Service:(e)=>e,_Identifier:(e)=>e},toString(){return he(this.toJSON())},toJSON(){return{_id:"Tag",key:this.key,stack:this.stack}},[re](){return this.toJSON()},of(e){return e},context(e){return Wm(this,e)}},aN={...ww,[Us]:Us},Km=Symbol.for("effect/Context"),sN={[Km]:{_Services:(e)=>e},[I](e){if(vw(e)){if(this.unsafeMap.size===e.unsafeMap.size){for(let t of this.unsafeMap.keys())if(!e.unsafeMap.has(t)||!O(this.unsafeMap.get(t),e.unsafeMap.get(t)))return!1;return!0}}return!1},[M](){return oe(this,$l(this.unsafeMap.size))},pipe(){return E(this,arguments)},toString(){return he(this.toJSON())},toJSON(){return{_id:"Context",services:Array.from(this.unsafeMap).map(ue)}},[re](){return this.toJSON()}},lN=ho(new Map),kw=d(3,(e,t,r)=>{let n=new Map(e.unsafeMap);return n.set(t.key,r),ho(n)}),zm=j("effect/Context/defaultValueCache",()=>new Map),Gm=d(2,(e,t)=>{if(!e.unsafeMap.has(t.key)){if(Us in t)return Jm(t);throw cN(t)}return e.unsafeMap.get(t.key)}),Aw=Gm,Pw=d(2,(e,t)=>{if(!e.unsafeMap.has(t.key))return Ow(t)?Cs(Jm(t)):Wl;return Cs(e.unsafeMap.get(t.key))}),Iw=d(2,(e,t)=>{let r=new Map(e.unsafeMap);for(let[n,o]of t.unsafeMap)r.set(n,o);return ho(r)})});var Vt,go,Nw,Yr,Hs,$s,yo,js,Bs;var fr=x(()=>{_u();Vt=Tw,go=Rw,Nw=Wm,Yr=kw,Hs=Aw,$s=Gm,yo=Pw,js=Iw,Bs=Ew});var Zm,Uw,Fw,wu,Xm,Lw,Dw,uN,Mn=(e)=>{if(Hw(e))return e;else if(Xt(e))return Tu(e);else if(eo(e))return Ym(e);else if(Array.isArray(e)&&e.length===2&&e.every(Xt)){if(e[0]===-1/0||e[1]===-1/0||Number.isNaN(e[0])||Number.isNaN(e[1]))return Qm;if(e[0]===1/0||e[1]===1/0)return mN;return Ym(BigInt(Math.round(e[0]*1e9))+BigInt(Math.round(e[1])))}else if(xt(e)){let t=uN.exec(e);if(t){let[r,n,o]=t,i=Number(n);switch(o){case"nano":case"nanos":return Ym(BigInt(n));case"micro":case"micros":return hN(BigInt(n));case"milli":case"millis":return Tu(i);case"second":case"seconds":return gN(i);case"minute":case"minutes":return yN(i);case"hour":case"hours":return xN(i);case"day":case"days":return SN(i);case"week":case"weeks":return bN(i)}}}throw Error("Invalid DurationInput")},qw,pN,dN,Zr=(e)=>{let t=Object.create(dN);if(Xt(e))if(isNaN(e)||e<=0)t.value=qw;else if(!Number.isFinite(e))t.value=pN;else if(!Number.isInteger(e))t.value={_tag:"Nanos",nanos:BigInt(Math.round(e*1e6))};else t.value={_tag:"Millis",millis:e};else if(e<=Uw)t.value=qw;else t.value={_tag:"Nanos",nanos:e};return t},Hw=(e)=>k(e,Zm),fN=(e)=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===Uw;case"Infinity":return!1}},Qm,mN,Ym=(e)=>Zr(e),hN=(e)=>Zr(e*Xm),Tu=(e)=>Zr(e),gN=(e)=>Zr(e*1000),yN=(e)=>Zr(e*60000),xN=(e)=>Zr(e*3600000),SN=(e)=>Zr(e*86400000),bN=(e)=>Zr(e*604800000),Eu=(e)=>TN(e,{onMillis:(t)=>t,onNanos:(t)=>Number(t)/1e6}),_N=(e)=>{let t=Mn(e);switch(t.value._tag){case"Infinity":throw Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return BigInt(Math.round(t.value.millis*1e6))}},wN=(e)=>{let t=Mn(e);switch(t.value._tag){case"Infinity":return[1/0,0];case"Nanos":return[Number(t.value.nanos/Dw),Number(t.value.nanos%Dw)];case"Millis":return[Math.floor(t.value.millis/1000),Math.round(t.value.millis%1000*1e6)]}},TN,eh,EN=(e,t)=>eh(e,t,{onMillis:(r,n)=>r===n,onNanos:(r,n)=>r===n}),$w,jw,vN,ON=(e)=>{let t=Mn(e);if(t.value._tag==="Infinity")return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};let r=_N(t),n=r/Lw,o=n/Xm,i=o/wu,a=i/wu,s=a/Fw;return{days:Number(s),hours:Number(a%Fw),minutes:Number(i%wu),seconds:Number(o%wu),millis:Number(n%Xm),nanos:Number(r%Lw)}},RN=(e)=>{let t=Mn(e);if(t.value._tag==="Infinity")return"Infinity";if(fN(t))return"0";let r=ON(t),n=[];if(r.days!==0)n.push(`${r.days}d`);if(r.hours!==0)n.push(`${r.hours}h`);if(r.minutes!==0)n.push(`${r.minutes}m`);if(r.seconds!==0)n.push(`${r.seconds}s`);if(r.millis!==0)n.push(`${r.millis}ms`);if(r.nanos!==0)n.push(`${r.nanos}ns`);return n.join(" ")};var th=x(()=>{le();H();Me();Be();_e();ge();Zm=Symbol.for("effect/Duration"),Uw=BigInt(0),Fw=BigInt(24),wu=BigInt(60),Xm=BigInt(1000),Lw=BigInt(1e6),Dw=BigInt(1e9),uN=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,qw={_tag:"Millis",millis:0},pN={_tag:"Infinity"},dN={[Zm]:Zm,[M](){return oe(this,jl(this.value))},[I](e){return Hw(e)&&vN(this,e)},toString(){return`Duration(${RN(this)})`},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",hrtime:wN(this)};case"Infinity":return{_id:"Duration",_tag:"Infinity"}}},[re](){return this.toJSON()},pipe(){return E(this,arguments)}},Qm=Zr(0),mN=Zr(1/0),TN=d(2,(e,t)=>{let r=Mn(e);switch(r.value._tag){case"Nanos":return t.onNanos(r.value.nanos);case"Infinity":return t.onMillis(1/0);case"Millis":return t.onMillis(r.value.millis)}}),eh=d(3,(e,t,r)=>{let n=Mn(e),o=Mn(t);if(n.value._tag==="Infinity"||o.value._tag==="Infinity")return r.onMillis(Eu(n),Eu(o));else if(n.value._tag==="Nanos"||o.value._tag==="Nanos"){let i=n.value._tag==="Nanos"?n.value.nanos:BigInt(Math.round(n.value.millis*1e6)),a=o.value._tag==="Nanos"?o.value.nanos:BigInt(Math.round(o.value.millis*1e6));return r.onNanos(i,a)}return r.onMillis(n.value.millis,o.value.millis)}),$w=d(2,(e,t)=>eh(e,t,{onMillis:(r,n)=>r<=n,onNanos:(r,n)=>r<=n})),jw=d(2,(e,t)=>eh(e,t,{onMillis:(r,n)=>r>=n,onNanos:(r,n)=>r>=n})),vN=d(2,(e,t)=>EN(Mn(e),Mn(t)))});var Vw,kN,vu=(e)=>{let t=Object.create(kN);return t.current=e,t},ha=(e)=>e.current,Ou;var rh=x(()=>{H();Be();_e();Vw=Symbol.for("effect/MutableRef"),kN={[Vw]:Vw,toString(){return he(this.toJSON())},toJSON(){return{_id:"MutableRef",current:ue(this.current)}},[re](){return this.toJSON()},pipe(){return E(this,arguments)}},Ou=d(2,(e,t)=>(e.current=t,e))});var oh="effect/FiberId",ga,Ru="None",nh="Runtime",CN="Composite",AN,Ww,Jw,Gw,ih=(e)=>k(e,ga),ku=(e)=>{switch(e._tag){case Ru:return Gr();case nh:return ai(e.id);case CN:return g(ku(e.left),Pn(ku(e.right)))}},Kw,Cu=(e)=>Array.from(ku(e)).map((r)=>`#${r}`).join(","),Yw=()=>{let e=ha(Kw);return g(Kw,Ou(e+1)),new Jw(e,Date.now())};var ah=x(()=>{le();H();Me();li();Be();rh();ge();ga=Symbol.for(oh),AN=me(`${oh}-${Ru}`);Ww=class Ww{[ga]=ga;_tag=Ru;id=-1;startTimeMillis=-1;[M](){return AN}[I](e){return ih(e)&&e._tag===Ru}toString(){return he(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag}}[re](){return this.toJSON()}};Jw=class Jw{id;startTimeMillis;[ga]=ga;_tag=nh;constructor(e,t){this.id=e,this.startTimeMillis=t}[M](){return oe(this,me(`${oh}-${this._tag}-${this.id}-${this.startTimeMillis}`))}[I](e){return ih(e)&&e._tag===nh&&this.id===e.id&&this.startTimeMillis===e.startTimeMillis}toString(){return he(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag,id:this.id,startTimeMillis:this.startTimeMillis}}[re](){return this.toJSON()}};Gw=new Ww,Kw=j(Symbol.for("effect/Fiber/Id/_fiberCounter"),()=>vu(0))});var mr,Xw,Au;var ya=x(()=>{ah();mr=Gw,Xw=Cu,Au=Yw});var xa,Qw,eT,sh,ch,lh,tT,rT,uh;var Pu=x(()=>{Am();xa=aa,Qw=K_,eT=J_,sh=G_,ch=ii,lh=cu,tT=uu,rT=X_,uh=sa});var zs,dh=(e)=>ke(e),PN=(e)=>Hf(so(e),dh),IN,MN,Iu=(e,t)=>{let r=Object.create(MN);return r.head=e,r.tail=t,r},NN,FN,nT,oT=(e)=>k(e,zs),Xr=(e)=>e._tag==="Nil",fh=(e)=>e._tag==="Cons",LN=()=>nT,Nn=(e,t)=>Iu(e,t),xo,Ks=(e)=>Iu(e,nT),iT,DN,qN,aT,sT=(e)=>{let t=xo(),r=e;while(!Xr(r))t=DN(t,r.head),r=r.tail;return t};var Mu=x(()=>{Ve();le();ys();H();Me();Be();_e();ge();zs=Symbol.for("effect/List"),IN=PN(O),MN={[zs]:zs,_tag:"Cons",toString(){return he(this.toJSON())},toJSON(){return{_id:"List",_tag:"Cons",values:dh(this).map(ue)}},[re](){return this.toJSON()},[I](e){return oT(e)&&this._tag===e._tag&&IN(this,e)},[M](){return oe(this,Qt(dh(this)))},[Symbol.iterator](){let e=!1,t=this;return{next(){if(e)return this.return();if(t._tag==="Nil")return e=!0,this.return();let r=t.head;return t=t.tail,{done:e,value:r}},return(r){if(!e)e=!0;return{done:!0,value:r}}}},pipe(){return E(this,arguments)}},NN=me("Nil"),FN={[zs]:zs,_tag:"Nil",toString(){return he(this.toJSON())},toJSON(){return{_id:"List",_tag:"Nil"}},[re](){return this.toJSON()},[M](){return NN},[I](e){return oT(e)&&this._tag===e._tag},[Symbol.iterator](){return{next(){return{done:!0,value:void 0}}}},pipe(){return E(this,arguments)}},nT=Object.create(FN),xo=LN,iT=d(2,(e,t)=>qN(t,e)),DN=d(2,(e,t)=>Nn(t,e)),qN=d(2,(e,t)=>{if(Xr(e))return t;else if(Xr(t))return e;else{let r=Iu(t.head,e),n=r,o=t.tail;while(!Xr(o)){let i=Iu(o.head,e);n.tail=i,n=i,o=o.tail}return r}}),aT=d(3,(e,t,r)=>{let n=t,o=e;while(!Xr(o))n=r(n,o.head),o=o.tail;return n})});var HV,Sa;var Nu=x(()=>{le();Me();wn();HV=Object.assign(Object.create(Array.prototype),{[M](){return oe(this,Qt(this))},[I](e){if(Array.isArray(e)&&this.length===e.length)return this.every((t,r)=>O(t,e[r]));else return!1}}),Sa=function(){function e(t){if(t)Object.assign(this,t)}return e.prototype=ks,e}()});function cT(e){return e}var HN,Js,$N,jN,hh=()=>jN,BN,VN=(e,t)=>{let r=Object.create(BN);return r.first=e,r.second=t,r},zN,KN=(e,t)=>{let r=Object.create(zN);return r.key=e,r.service=t,r},WN,JN=(e)=>{let t=Object.create(WN);return t.key=e,t},GN,YN=(e,t)=>{let r=Object.create(GN);return r.key=e,r.update=t,r},lT=(e,t)=>{let r=new Map(e.unsafeMap),n=hh();for(let[o,i]of t.unsafeMap.entries())if(r.has(o)){let a=r.get(o);if(r.delete(o),!O(a,i))n=Ws(YN(o,()=>i))(n)}else r.delete(o),n=Ws(KN(o,i))(n);for(let[o]of r.entries())n=Ws(JN(o))(n);return n},Ws,uT;var pT=x(()=>{Jr();le();H();_u();Nu();HN=Symbol.for("effect/DifferContextPatch");Js={...Sa.prototype,[HN]:{_Value:cT,_Patch:cT}},$N=Object.assign(Object.create(Js),{_tag:"Empty"}),jN=Object.create($N),BN=Object.assign(Object.create(Js),{_tag:"AndThen"}),zN=Object.assign(Object.create(Js),{_tag:"AddService"}),WN=Object.assign(Object.create(Js),{_tag:"RemoveService"}),GN=Object.assign(Object.create(Js),{_tag:"UpdateService"}),Ws=d(2,(e,t)=>VN(e,t)),uT=d(2,(e,t)=>{if(e._tag==="Empty")return t;let r=!1,n=rt(e),o=new Map(t.unsafeMap);while(Cr(n)){let a=Ar(n),s=Pr(n);switch(a._tag){case"Empty":{n=s;break}case"AddService":{o.set(a.key,a.service),n=s;break}case"AndThen":{n=Ct(Ct(s,a.second),a.first);break}case"RemoveService":{o.delete(a.key),n=s;break}case"UpdateService":{o.set(a.key,a.update(o.get(a.key))),r=!0,n=s;break}}}if(!r)return ho(o);let i=new Map;for(let[a]of t.unsafeMap)if(o.has(a))i.set(a,o.get(a)),o.delete(a);for(let[a,s]of o)i.set(a,s);return ho(i)})});function gh(e){return e}var XN,Lu,QN,e0,yh=()=>e0,t0,r0=(e,t)=>{let r=Object.create(t0);return r.first=e,r.second=t,r},n0,o0=(e)=>{let t=Object.create(n0);return t.value=e,t},i0,a0=(e)=>{let t=Object.create(i0);return t.value=e,t},dT=(e,t)=>{let[r,n]=ci([e,yh()],([o,i],a)=>{if(dw(a)(o))return[Mm(a)(o),i];return[o,Fu(o0(a))(i)]})(t);return ci(n,(o,i)=>Fu(a0(i))(o))(r)},Fu,fT;var mT=x(()=>{Jr();H();li();Nu();XN=Symbol.for("effect/DifferHashSetPatch");Lu={...Sa.prototype,[XN]:{_Value:gh,_Key:gh,_Patch:gh}},QN=Object.assign(Object.create(Lu),{_tag:"Empty"}),e0=Object.create(QN),t0=Object.assign(Object.create(Lu),{_tag:"AndThen"}),n0=Object.assign(Object.create(Lu),{_tag:"Add"}),i0=Object.assign(Object.create(Lu),{_tag:"Remove"}),Fu=d(2,(e,t)=>r0(e,t)),fT=d(2,(e,t)=>{if(e._tag==="Empty")return t;let r=t,n=rt(e);while(Cr(n)){let o=Ar(n),i=Pr(n);switch(o._tag){case"Empty":{n=i;break}case"AndThen":{n=Ct(o.first)(Ct(o.second)(i));break}case"Add":{r=si(o.value)(r),n=i;break}case"Remove":r=Mm(o.value)(r),n=i}}return r})});function hT(e){return e}var c0,Ys,l0,u0,xh=()=>u0,p0,d0=(e,t)=>{let r=Object.create(p0);return r.first=e,r.second=t,r},f0,m0=(e)=>{let t=Object.create(f0);return t.values=e,t},h0,g0=(e,t)=>{let r=Object.create(h0);return r.from=e,r.until=t,r},y0,x0=(e,t)=>{let r=Object.create(y0);return r.index=e,r.patch=t,r},gT=(e)=>{let t=0,r=xh();while(t<e.oldValue.length&&t<e.newValue.length){let n=e.oldValue[t],o=e.newValue[t],i=e.differ.diff(n,o);if(!O(i,e.differ.empty))r=Gs(r,x0(t,i));t=t+1}if(t<e.oldValue.length)r=Gs(r,g0(0,t));if(t<e.newValue.length)r=Gs(r,m0(R_(t)(e.newValue)));return r},Gs,yT;var xT=x(()=>{Ve();le();H();Nu();c0=Symbol.for("effect/DifferReadonlyArrayPatch");Ys={...Sa.prototype,[c0]:{_Value:hT,_Patch:hT}},l0=Object.assign(Object.create(Ys),{_tag:"Empty"}),u0=Object.create(l0),p0=Object.assign(Object.create(Ys),{_tag:"AndThen"}),f0=Object.assign(Object.create(Ys),{_tag:"Append"}),h0=Object.assign(Object.create(Ys),{_tag:"Slice"}),y0=Object.assign(Object.create(Ys),{_tag:"Update"}),Gs=d(2,(e,t)=>d0(e,t)),yT=d(3,(e,t,r)=>{if(e._tag==="Empty")return t;let n=t.slice(),o=kt(e);while(io(o)){let i=tt(o),a=Rr(o);switch(i._tag){case"Empty":{o=a;break}case"AndThen":{a.unshift(i.first,i.second),o=a;break}case"Append":{for(let s of i.values)n.push(s);o=a;break}case"Slice":{n=n.slice(i.from,i.until),o=a;break}case"Update":{n[i.index]=r.patch(i.patch,n[i.index]),o=a;break}}}return n})});var ST,b0,So=(e)=>{let t=Object.create(b0);return t.empty=e.empty,t.diff=e.diff,t.combine=e.combine,t.patch=e.patch,t},Sh=()=>So({empty:hh(),combine:(e,t)=>Ws(t)(e),diff:(e,t)=>lT(e,t),patch:(e,t)=>uT(t)(e)}),bh=()=>So({empty:yh(),combine:(e,t)=>Fu(t)(e),diff:(e,t)=>dT(e,t),patch:(e,t)=>fT(t)(e)}),_h=(e)=>So({empty:xh(),combine:(t,r)=>Gs(t,r),diff:(t,r)=>gT({oldValue:t,newValue:r,differ:e}),patch:(t,r)=>yT(t,r,e)}),Du=()=>bT((e,t)=>t),bT=(e)=>So({empty:ce,combine:(t,r)=>{if(t===ce)return r;if(r===ce)return t;return(n)=>r(t(n))},diff:(t,r)=>{if(O(t,r))return ce;return ds(r)},patch:(t,r)=>e(r,t(r))});var qu=x(()=>{le();H();_e();pT();mT();xT();ST=Symbol.for("effect/Differ"),b0={[ST]:{_P:ce,_V:ce},pipe(){return E(this,arguments)}}});var Zs=255,_T=8,Uu=(e)=>e&Zs,Hu=(e)=>e>>_T&Zs,gi=(e,t)=>(e&Zs)+((t&e&Zs)<<_T),Th,wT=(e)=>gi(e,e),TT=(e)=>gi(e,0),ET,Eh,vT=(e)=>~e>>>0&Zs;var vh=x(()=>{H();Th=gi(0,0),ET=d(2,(e,t)=>gi(Uu(e)&~t,Hu(e))),Eh=d(2,(e,t)=>e|t)});var _0=0,Fn=1,RT=2,Oh=4,$u=16,Rh=32,kT=(e)=>ju(e,Rh),kh,Ln=(e)=>Ch(e)&&!w0(e),Ch=(e)=>ju(e,Fn),ju,Ah=(...e)=>e.reduce((t,r)=>t|r,0),CT,Ph=(e)=>ju(e,Oh),w0=(e)=>ju(e,$u),Xs,Qs,Ih;var ec=x(()=>{H();qu();vh();kh=d(2,(e,t)=>e|t),ju=d(2,(e,t)=>(e&t)!==0),CT=Ah(_0),Xs=d(2,(e,t)=>gi(e^t,t)),Qs=d(2,(e,t)=>e&(vT(Uu(t))|Hu(t))|Uu(t)&Hu(t)),Ih=So({empty:Th,diff:(e,t)=>Xs(e,t),combine:(e,t)=>Eh(t)(e),patch:(e,t)=>Qs(t,e)})});var AT,Nh,Fh;var Lh=x(()=>{vh();AT=wT,Nh=TT,Fh=ET});var qh=(e,t)=>({_tag:"Par",left:e,right:t}),Bu=(e,t)=>({_tag:"Seq",left:e,right:t}),IT=(e)=>{let t=Ks(e),r=xo();while(!0){let[n,o]=aT(t,[MT(),xo()],([i,a],s)=>{let[c,l]=T0(s);return[k0(i,c),iT(a,l)]});if(r=E0(r,n),Xr(o))return sT(r);t=o}throw Error("BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues")},T0=(e)=>{let t=e,r=MT(),n=xo(),o=xo();while(!0)switch(t._tag){case"Empty":{if(Xr(n))return[r,o];t=n.head,n=n.tail;break}case"Par":{n=Nn(t.right,n),t=t.left;break}case"Seq":{let i=t.left,a=t.right;switch(i._tag){case"Empty":{t=a;break}case"Par":{let{left:s,right:c}=i;t=qh(Bu(s,a),Bu(c,a));break}case"Seq":{let{left:s,right:c}=i;t=Bu(s,Bu(c,a));break}case"Single":{t=i,o=Nn(a,o);break}}break}case"Single":{if(r=R0(r,t),Xr(n))return[r,o];t=n.head,n=n.tail;break}}throw Error("BUG: BlockedRequests.step - please report an issue at https://github.com/Effect-TS/effect/issues")},E0=(e,t)=>{if(Xr(e))return Ks(Dh(t));if(C0(t))return e;let r=F0(e.head),n=A0(t);if(r.length===1&&n.length===1&&O(r[0],n[0]))return Nn(N0(e.head,Dh(t)),e.tail);return Nn(Dh(t),e)},v0,O0,Vu,MT=()=>new Vu(xa()),R0=(e,t)=>new Vu(tT(e.map,t.dataSource,(r)=>m_(vr(r,N_(t.blockedRequest)),()=>rt(t.blockedRequest)))),k0=(e,t)=>new Vu(uh(e.map,t.map,(r,n,o)=>ch(r,o,Ge(sh(r,o),{onNone:()=>n,onSome:(i)=>tr(n,i)})))),C0=(e)=>eT(e.map),A0=(e)=>Array.from(lh(e.map)),Dh=(e)=>M0(rT(e.map,(t)=>rt(t))),P0,I0,Uh,M0=(e)=>new Uh(e),N0=(e,t)=>new Uh(uh(t.map,e.map,(r,n,o)=>ch(r,o,Ge(sh(r,o),{onNone:()=>pr(),onSome:(i)=>tr(i,n)})))),F0=(e)=>Array.from(lh(e.map)),NT=(e)=>Array.from(e.map);var FT=x(()=>{Jr();le();Pu();Mu();Ye();v0=Symbol.for("effect/RequestBlock/RequestBlockParallel"),O0={_R:(e)=>e};Vu=class Vu{map;[v0]=O0;constructor(e){this.map=e}};P0=Symbol.for("effect/RequestBlock/RequestBlockSequential"),I0={_R:(e)=>e};Uh=class Uh{map;[P0]=I0;constructor(e){this.map=e}}});var ba="Pending",zu="Done";var D0="effect/Deferred",DT,qT,UT=(e)=>({_tag:ba,joiners:e}),HT=(e)=>({_tag:zu,effect:e});var $T=x(()=>{DT=Symbol.for(D0),qT={_E:(e)=>e,_A:(e)=>e}});var _a;var jT=x(()=>{_a=class _a{self;called=!1;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(e){return{value:e,done:!0}}throw(e){throw e}[Symbol.iterator](){return new _a(this.self)}}});class Bh{patch;op;_op=Os;constructor(e,t){this.patch=e,this.op=t}}var Ju=(e,t)=>{let r=new dt("Blocked");return r.effect_instruction_i0=e,r.effect_instruction_i1=t,r},jh=(e)=>{let t=new dt("RunBlocked");return t.effect_instruction_i0=e,t},bo,dt,Vh,zh,wa=(e)=>k(e,bo),bt=(e)=>{let t=new dt(Kl);return t.effect_instruction_i0=e,t},ZT,Dn,qn=(e)=>Dn(e,void 0),Kh=function(){let e=new dt(ei);switch(arguments.length){case 2:{e.effect_instruction_i0=arguments[0],e.commit=arguments[1];break}case 3:{e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.commit=arguments[2];break}case 4:{e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.effect_instruction_i2=arguments[2],e.commit=arguments[3];break}default:throw Error(Yo("you're not supposed to end up here"))}return e},tc=(e,t=mr)=>{let r=new dt(Qo),n=void 0;return r.effect_instruction_i0=(o)=>{n=e(o)},r.effect_instruction_i1=t,ic(r,(o)=>wa(n)?n:nt)},XT=(e,t=mr)=>Ce(()=>tc(e,t)),_o=(e,t=mr)=>Kh(e,function(){let r=void 0,n=void 0;function o(c){if(r)r(c);else if(n===void 0)n=c}let i=new dt(Qo);i.effect_instruction_i0=(c)=>{if(r=c,n)c(n)},i.effect_instruction_i1=t;let a=void 0,s=void 0;if(this.effect_instruction_i0.length!==1)s=new AbortController,a=St(()=>this.effect_instruction_i0(o,s.signal));else a=St(()=>this.effect_instruction_i0(o));return a||s?ic(i,(c)=>{if(s)s.abort();return a??nt}):i}),rc,BT,Gu=(e,t)=>{if(Re(t))return new Proxy(e,{has(r,n){return n===mi||n===BT||n in r},get(r,n){if(n===mi)return t.value;if(n===BT)return e;return r[n]}});return e},Yu=(e)=>Dt(e)&&!(mi in e)?bt((t)=>Pt(rr(Gu(e,dp(t))))):Pt(rr(e)),Wh=(e)=>QT(()=>rr(new K0(e))),yi=(e)=>Ta(e,{onFailure:(t)=>pe(K(t)),onSuccess:(t)=>pe(Z(t))}),wo=(e)=>eE(e,{onFailure:Te,onSuccess:Ie}),ft=(e)=>Dt(e)&&!(mi in e)?bt((t)=>Pt(da(Gu(e,dp(t))))):Pt(da(e)),Jh=(e)=>B(L(e),ft),Pt=(e)=>{let t=new Vh($t);return t.effect_instruction_i0=e,t},QT=(e)=>B(L(e),Pt),Gh,nc=(e)=>bt((t)=>e(t.id())),B,Yh=(e)=>{let t=new dt("OnStep");return t.effect_instruction_i0=e,t},oc=(e)=>B(e,ce),eE,hr,Ta,gr,xi,Zu=(e)=>{let t=new dt(ti);return t.effect_instruction_i0=AT(Fn),t.effect_instruction_i1=()=>e,t},ze,Xu,Si,Ea,ic,pe=(e)=>{let t=new zh(jt);return t.effect_instruction_i0=e,t},Ce=(e)=>{let t=new dt(ei);return t.commit=e,t},L=(e)=>{let t=new dt(zl);return t.effect_instruction_i0=e,t},Qu,Zh=(e)=>bt((t)=>{let r=t.getFiberRef(Wu),n=g(r,ve(()=>t.scope()));return e(vo(Wu,N(n)))}),ep=(e)=>{let t=new dt(ti);return t.effect_instruction_i0=Nh(Fn),t.effect_instruction_i1=()=>e,t},To=(e)=>Kh(e,function(){let t=new dt(ti);return t.effect_instruction_i0=Nh(Fn),t.effect_instruction_i1=(r)=>Ch(r)?St(()=>this.effect_instruction_i0(Zu)):St(()=>this.effect_instruction_i0(ep)),t}),nt,Xh=(e)=>{let t=new dt(ti);return t.effect_instruction_i0=e,t.effect_instruction_i1=void 0,t},ac=(e)=>{let t=new dt(Xi);return t.effect_instruction_i0=e.while,t.effect_instruction_i1=e.body,t.effect_instruction_i2=e.step,t},sc=(e)=>{let t=new dt(ea);return typeof e?.priority<"u"?pE(t,e.priority):t},tp,rp,Eo,cc,tE=(e)=>B(Gh,(t)=>g(e,lc(t))),lc,rE,nE,oE,Qh,eg,tg,iE,aE,$0="effect/FiberRef",j0,B0,np=(e)=>bt((t)=>Ie(t.getFiberRef(e))),bi,Hh,V0,vo,_t=(e,t)=>_i(e,{differ:Du(),fork:t?.fork??ce,join:t?.join}),sE=(e)=>{let t=bh();return _i(e,{differ:t,fork:t.empty})},z0=(e)=>{let t=_h(Du());return _i(e,{differ:t,fork:t.empty})},op=(e)=>{let t=Sh();return _i(e,{differ:t,fork:t.empty})},_i=(e,t)=>({...oo,[j0]:B0,initial:e,commit(){return np(this)},diff:(n,o)=>t.differ.diff(n,o),combine:(n,o)=>t.differ.combine(n,o),patch:(n)=>(o)=>t.differ.patch(n,o),fork:t.fork,join:t.join??((n,o)=>o)}),cE=(e)=>_i(e,{differ:Ih,fork:Ih.empty}),wi,va,rg,lE,ng,uE,pE,dE,fE,mE,hE,uc,Wu,pc,ip,ap,sp=(e,t)=>e.addFinalizer(()=>qn(t)),og=(e,t)=>e.close(t),Oa=(e,t)=>e.fork(t),cp,Ti=(e,t)=>{class r extends cp{_tag=t}return Object.assign(r.prototype,e),r.prototype.name=t,r},VT,K0,$h,yz,gE=(e)=>k(e,$h),zT,W0,KT,dc,WT,xz,JT,Sz,GT,bz,YT,J0,Ra=(e)=>wa(e)&&("_tag"in e)&&(e._tag==="Success"||e._tag==="Failure"),ig=(e)=>e._tag==="Success",yE,fc=(e)=>yE(e,void 0),Ei=(e,t)=>G0(e,t?.parallel?hi:At),ag=(e)=>Te(rr(e)),mc=(e)=>Te(da(e)),Te=(e)=>{let t=new Vh($t);return t.effect_instruction_i0=e,t},sg=(e)=>Te(Ir(e)),Ku,lp,Ie=(e)=>{let t=new zh(jt);return t.effect_instruction_i0=e,t},yr,cg,G0=(e,t)=>{let r=eu(e);if(!Cr(r))return C();return g(Pr(r),na(g(Ar(r),Ku(rt)),(n,o)=>g(n,cg(o,{onSuccess:(i,a)=>g(i,Ct(a)),onFailure:t}))),Ku(co),Ku((n)=>kn(n)),N)},xE=(e)=>({...oo,[DT]:qT,state:vu(UT([])),commit(){return up(this)},blockingOn:e}),up=(e)=>XT((t)=>{let r=ha(e.state);switch(r._tag){case zu:return t(r.effect);case ba:return r.joiners.push(t),Y0(e,t)}},e.blockingOn),pp=(e,t)=>{let r=ha(e.state);if(r._tag===ba){Ou(e.state,HT(t));for(let n=0,o=r.joiners.length;n<o;n++)r.joiners[n](t)}},Y0=(e,t)=>L(()=>{let r=ha(e.state);if(r._tag===ba){let n=r.joiners.indexOf(t);if(n>=0)r.joiners.splice(n,1)}}),Z0,SE=()=>Z0,vi=(e)=>B(SE(),e),X0,lg,dp=(e)=>{let t=e.currentSpan;return t!==void 0&&t._tag==="Span"?N(t):C()};var ot=x(()=>{Ve();Jr();fr();er();le();ya();H();Me();Pu();Be();Mu();rh();Ye();_e();ge();Lh();ro();ma();$T();qu();wn();ec();jT();bo=Symbol.for("effect/Effect");dt=class dt{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[bo]=no;constructor(e){this._op=e}[I](e){return this===e}[M](){return oe(this,_s(this))}pipe(){return E(this,arguments)}toJSON(){return{_id:"Effect",_op:this._op,effect_instruction_i0:ue(this.effect_instruction_i0),effect_instruction_i1:ue(this.effect_instruction_i1),effect_instruction_i2:ue(this.effect_instruction_i2)}}toString(){return he(this.toJSON())}[re](){return this.toJSON()}[Symbol.iterator](){return new _a(new Sn(this))}};Vh=class Vh{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[bo]=no;constructor(e){this._op=e,this._tag=e}[I](e){return Ra(e)&&e._op==="Failure"&&O(this.effect_instruction_i0,e.effect_instruction_i0)}[M](){return g(me(this._tag),J(v(this.effect_instruction_i0)),oe(this))}get cause(){return this.effect_instruction_i0}pipe(){return E(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,cause:this.cause.toJSON()}}toString(){return he(this.toJSON())}[re](){return this.toJSON()}[Symbol.iterator](){return new _a(new Sn(this))}};zh=class zh{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[bo]=no;constructor(e){this._op=e,this._tag=e}[I](e){return Ra(e)&&e._op==="Success"&&O(this.effect_instruction_i0,e.effect_instruction_i0)}[M](){return g(me(this._tag),J(v(this.effect_instruction_i0)),oe(this))}get value(){return this.effect_instruction_i0}pipe(){return E(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,value:ue(this.value)}}toString(){return he(this.toJSON())}[re](){return this.toJSON()}[Symbol.iterator](){return new _a(new Sn(this))}};ZT=d(3,(e,t,r)=>To((n)=>B(e,(o)=>B(wo(Ce(()=>n(t(o)))),(i)=>Ce(()=>r(o,i)).pipe(hr({onFailure:(a)=>{switch(i._tag){case $t:return Pt(At(i.effect_instruction_i0,a));case jt:return Pt(a)}},onSuccess:()=>i})))))),Dn=d(2,(e,t)=>B(e,()=>pe(t))),rc=d(2,(e,t)=>Ta(e,{onFailure:t,onSuccess:pe})),BT=Symbol.for("effect/OriginalAnnotation"),Gh=bt((e)=>pe(e.id())),B=d(2,(e,t)=>{let r=new dt(Yi);return r.effect_instruction_i0=e,r.effect_instruction_i1=t,r}),eE=d(2,(e,t)=>hr(e,{onFailure:(r)=>pe(t.onFailure(r)),onSuccess:(r)=>pe(t.onSuccess(r))})),hr=d(2,(e,t)=>{let r=new dt(Zi);return r.effect_instruction_i0=e,r.effect_instruction_i1=t.onFailure,r.effect_instruction_i2=t.onSuccess,r}),Ta=d(2,(e,t)=>hr(e,{onFailure:(r)=>{if(Hm(r).length>0)return Pt(Sw(r));let o=Um(r);if(o.length>0)return t.onFailure(_m(o));return Pt(r)},onSuccess:t.onSuccess})),gr=d(2,(e,t)=>Ce(()=>{let r=ke(e),n=ri(r.length),o=0;return Dn(ac({while:()=>o<r.length,body:()=>t(r[o],o),step:(i)=>{n[o++]=i}}),n)})),xi=d(2,(e,t)=>Ce(()=>{let r=ke(e),n=0;return ac({while:()=>n<r.length,body:()=>t(r[n],n),step:()=>{n++}})})),ze=d(2,(e,t)=>B(e,(r)=>L(()=>t(r)))),Xu=d(2,(e,t)=>Ta(e,{onFailure:(r)=>Jh(()=>t.onFailure(r)),onSuccess:(r)=>L(()=>t.onSuccess(r))})),Si=d(2,(e,t)=>hr(e,{onFailure:(r)=>{let n=xu(r);switch(n._tag){case"Left":return Jh(()=>t(n.left));case"Right":return Pt(n.right)}},onSuccess:pe})),Ea=d(2,(e,t)=>To((r)=>hr(r(e),{onFailure:(n)=>{let o=Te(n);return hr(t(o),{onFailure:(i)=>Te(At(n,i)),onSuccess:()=>o})},onSuccess:(n)=>{let o=Ie(n);return Eo(t(o),o)}}))),ic=d(2,(e,t)=>Ea(e,lp({onFailure:(r)=>fa(r)?qn(t($m(r))):nt,onSuccess:()=>nt}))),Qu=d((e)=>e.length===3||e.length===2&&!(Dt(e[1])&&("onlyEffect"in e[1])),(e,t)=>B(e,(r)=>{let n=typeof t==="function"?t(r):t;if(wa(n))return Dn(n,r);else if(jb(n))return tc((o)=>{n.then((i)=>o(pe(r)),(i)=>o(ft(new J0(i,"An unknown error occurred in Effect.tap"))))});return pe(r)})),nt=pe(void 0),tp=d(2,(e,t)=>B(e,(r)=>ze(t,(n)=>[r,n]))),rp=d(2,(e,t)=>B(e,(r)=>Dn(t,r))),Eo=d(2,(e,t)=>B(e,()=>t)),cc=XT(()=>{let e=setInterval(()=>{},2147483647);return L(()=>clearInterval(e))}),lc=d(2,(e,t)=>B(e.interruptAsFork(t),()=>e.await)),rE={_tag:"All",syslog:0,label:"ALL",ordinal:Number.MIN_SAFE_INTEGER,pipe(){return E(this,arguments)}},nE={_tag:"Fatal",syslog:2,label:"FATAL",ordinal:50000,pipe(){return E(this,arguments)}},oE={_tag:"Error",syslog:3,label:"ERROR",ordinal:40000,pipe(){return E(this,arguments)}},Qh={_tag:"Warning",syslog:4,label:"WARN",ordinal:30000,pipe(){return E(this,arguments)}},eg={_tag:"Info",syslog:6,label:"INFO",ordinal:20000,pipe(){return E(this,arguments)}},tg={_tag:"Debug",syslog:7,label:"DEBUG",ordinal:1e4,pipe(){return E(this,arguments)}},iE={_tag:"Trace",syslog:7,label:"TRACE",ordinal:0,pipe(){return E(this,arguments)}},aE={_tag:"None",syslog:7,label:"OFF",ordinal:Number.MAX_SAFE_INTEGER,pipe(){return E(this,arguments)}},j0=Symbol.for($0),B0={_A:(e)=>e},bi=d(2,(e,t)=>B(np(e),t)),Hh=d(2,(e,t)=>V0(e,()=>[void 0,t])),V0=d(2,(e,t)=>bt((r)=>{let[n,o]=t(r.getFiberRef(e));return r.setFiberRef(e,o),pe(n)})),vo=d(3,(e,t,r)=>ZT(rp(np(t),Hh(t,r)),()=>e,(n)=>Hh(t,n))),wi=j(Symbol.for("effect/FiberRef/currentContext"),()=>op(go())),va=j(Symbol.for("effect/FiberRef/currentSchedulingPriority"),()=>_t(0)),rg=j(Symbol.for("effect/FiberRef/currentMaxOpsBeforeYield"),()=>_t(2048)),lE=j(Symbol.for("effect/FiberRef/currentLogAnnotation"),()=>_t(xa())),ng=j(Symbol.for("effect/FiberRef/currentLogLevel"),()=>_t(eg)),uE=j(Symbol.for("effect/FiberRef/currentLogSpan"),()=>_t(xo())),pE=d(2,(e,t)=>vo(e,va,t)),dE=j(Symbol.for("effect/FiberRef/currentConcurrency"),()=>_t("unbounded")),fE=j(Symbol.for("effect/FiberRef/currentRequestBatching"),()=>_t(!0)),mE=j(Symbol.for("effect/FiberRef/currentUnhandledErrorLogLevel"),()=>_t(N(tg))),hE=j(Symbol.for("effect/FiberRef/versionMismatchErrorLogLevel"),()=>_t(N(Qh))),uc=j(Symbol.for("effect/FiberRef/currentMetricLabels"),()=>z0(On())),Wu=j(Symbol.for("effect/FiberRef/currentForkScopeOverride"),()=>_t(C(),{fork:()=>C(),join:(e,t)=>e})),pc=j(Symbol.for("effect/FiberRef/currentInterruptedCause"),()=>_t(In,{fork:()=>In,join:(e,t)=>e})),ip=Symbol.for("effect/Scope"),ap=Symbol.for("effect/CloseableScope"),cp=function(){class e extends globalThis.Error{commit(){return ft(this)}toJSON(){let t={...this};if(this.message)t.message=this.message;if(this.cause)t.cause=this.cause;return t}[re](){if(this.toString!==globalThis.Error.prototype.toString)return this.stack?`${this.toString()}
|
|
23
|
+
${this.stack.split(`
|
|
19
24
|
`).slice(1).join(`
|
|
20
|
-
`)}`:this.toString()}}),e}(),pb=function(){return class extends fb{constructor(e){super(),e&&Object.assign(this,e)}}}(),mb=e=>{class t extends pb{_tag=e}return t.prototype.name=e,t},mb(`NoSuchElementException`),mb(`TimeoutException`)})),gb,_b,vb,yb,bb,xb,Sb=v((()=>{Ie(),Vh(),gb=class e{scheduleDrain;running=!1;tasks=new _b;constructor(e){this.scheduleDrain=e}starveInternal=e=>{let t=this.tasks.buckets;this.tasks.buckets=[];for(let[e,n]of t)for(let e=0;e<n.length;e++)n[e]();this.tasks.buckets.length===0?this.running=!1:this.starve(e)};starve(e=0){this.scheduleDrain(e,this.starveInternal)}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running||(this.running=!0,this.starve())}static cached(t){let n=new e(t),r=new WeakMap;return i=>{if(i===void 0)return n;let a=r.get(i);return a===void 0&&(a=new e(t),r.set(i,a)),a}}},_b=class{buckets=[];scheduleTask(e,t){let n=this.buckets.length,r,i=0;for(;i<n&&this.buckets[i][0]<=t;i++)r=this.buckets[i];r&&r[0]===t?r[1].push(e):i===n?this.buckets.push([t,[e]]):this.buckets.splice(i,0,[t,[e]])}},vb=class{maxNextTickBeforeTimer;getRunner=gb.cached((e,t)=>{e>=this.maxNextTickBeforeTimer?setTimeout(()=>t(0),0):Promise.resolve(void 0).then(()=>t(e+1))});constructor(e){this.maxNextTickBeforeTimer=e}shouldYield(e){return e.currentOpCount>e.getFiberRef(Vm)&&e.getFiberRef(Bm)}scheduleTask(e,t,n){this.getRunner(n).scheduleTask(e,t)}},yb=C(Symbol.for(`effect/Scheduler/defaultScheduler`),()=>new vb(2048)),bb=class{tasks=new _b;deferred=!1;scheduleTask(e,t,n){this.deferred?yb.scheduleTask(e,t,n):this.tasks.scheduleTask(e,t)}shouldYield(e){return e.currentOpCount>e.getFiberRef(Vm)&&e.getFiberRef(Bm)}flush(){for(;this.tasks.buckets.length>0;){let e=this.tasks.buckets;this.tasks.buckets=[];for(let[t,n]of e)for(let e=0;e<n.length;e++)n[e]()}this.deferred=!0}},xb=C(Symbol.for(`effect/FiberRef/currentScheduler`),()=>Nm(yb))})),Cb,wb=v((()=>{Ie(),Vh(),Cb=C(Symbol.for(`effect/FiberRef/currentRequestMap`),()=>Nm(new Map))})),Tb,Eb=v((()=>{Vh(),Tb=(e,t,n,r)=>{switch(e){case void 0:return t();case`unbounded`:return n();case`inherit`:return km(Km,e=>e===`unbounded`?n():e>1?r(e):t());default:return e>1?r(e):t()}}})),Db,Ob,kb=v((()=>{Db=e=>e.replace(/[\s="]/g,`_`),Ob=e=>t=>`${Db(t.label)}=${e-t.startTime}ms`})),Ab,jb,Mb,Nb,Pb,Fb=v((()=>{M(),Mt(),F(),T(),Ab=`effect/MetricLabel`,jb=Symbol.for(Ab),Mb=class{key;value;[jb]=jb;_hash;constructor(e,t){this.key=e,this.value=t,this._hash=Ot(Ab+this.key+this.value)}[E](){return this._hash}[j](e){return Pb(e)&&this.key===e.key&&this.value===e.value}pipe(){return P(this,arguments)}},Nb=(e,t)=>new Mb(e,t),Pb=e=>w(e,jb)})),Ib,Lb=v((()=>{il(),Rr(),A_(),Ib=kr(e=>Qc(e.context,k_)?e._tag===`Span`?Ib(e.parent):R():z(e))})),Rb,zb=v((()=>{Vh(),Rb=_h})),Bb,Vb,Hb,Ub,Wb,Gb,Kb,qb,Jb=v((()=>{Bb=`InterruptSignal`,Vb=`Stateful`,Hb=`Resume`,Ub=`YieldNow`,Wb=e=>({_tag:Bb,cause:e}),Gb=e=>({_tag:Vb,onFiber:e}),Kb=e=>({_tag:Hb,effect:e}),qb=()=>({_tag:Ub})})),Yb,Xb,Zb,Qb,$b,ex,tx=v((()=>{bu(),Ie(),Jb(),Yb=`effect/FiberScope`,Xb=Symbol.for(Yb),Zb=class{[Xb]=Xb;fiberId=mu;roots=new Set;add(e,t){this.roots.add(t),t.addObserver(()=>{this.roots.delete(t)})}},Qb=class{fiberId;parent;[Xb]=Xb;constructor(e,t){this.fiberId=e,this.parent=t}add(e,t){this.parent.tell(Gb(e=>{e.addChild(t),t.addObserver(()=>{e.removeChild(t)})}))}},$b=e=>new Qb(e.id(),e),ex=C(Symbol.for(`effect/FiberScope/Global`),()=>new Zb)})),nx,rx,ix,ax,ox,sx,cx,lx,ux=v((()=>{bu(),Rr(),F(),Vh(),On(),nx=`effect/Fiber`,rx=Symbol.for(nx),ix={_E:e=>e,_A:e=>e},ax={[rx]:ix,pipe(){return P(this,arguments)}},ox=`effect/Fiber`,sx=Symbol.for(ox),cx=e=>pm(Wp(e.await),e.inheritAll),{...Tn},{...ax},lx=`effect/FiberCurrent`})),dx,fx,px,mx,hx,gx,_x,vx,yx,bx,xx=v((()=>{Pi(),Xt(),F(),bc(),pu(),kb(),dx=`effect/Logger`,fx=Symbol.for(dx),px={_Message:e=>e,_Output:e=>e},mx=e=>({[fx]:px,log:e,pipe(){return P(this,arguments)}}),hx=/^[^\s"=]*$/,gx=(e,t)=>({annotations:n,cause:r,date:i,fiberId:a,logLevel:o,message:s,spans:c})=>{let l=t=>t.match(hx)?t:e(t),u=(e,t)=>`${Db(e)}=${l(t)}`,d=(e,t)=>` `+u(e,t),f=u(`timestamp`,i.toISOString());f+=d(`level`,o.label),f+=d(`fiber`,du(a));let p=Wr(s);for(let e=0;e<p.length;e++)f+=d(`message`,Ut(p[e],t));Vs(r)||(f+=d(`cause`,dc(r,{renderErrorCause:!0})));for(let e of c)f+=` `+Ob(i.getTime())(e);for(let[e,r]of n)f+=d(e,Ut(r,t));return f},_x=e=>`"${e.replace(/\\([\s\S])|(")/g,`\\$1$2`)}"`,vx=mx(gx(_x)),yx={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`},yx.gray,yx.blue,yx.green,yx.yellow,yx.red,yx.bgBrightRed,yx.black,bx=typeof process==`object`&&process!==null&&typeof process.stdout==`object`&&process.stdout!==null,bx&&process.stdout.isTTY,bx||`Deno`in globalThis})),Sx,Cx,wx,Tx,Ex,Dx,Ox=v((()=>{Pi(),Ba(),M(),S(),Mt(),F(),T(),Sx=`effect/MetricBoundaries`,Cx=Symbol.for(Sx),wx=class{values;[Cx]=Cx;constructor(e){this.values=e,this._hash=b(Ot(Sx),O(jt(this.values)))}_hash;[E](){return this._hash}[j](e){return Tx(e)&&A(this.values,e.values)}pipe(){return P(this,arguments)}},Tx=e=>w(e,Cx),Ex=e=>{let t=b(e,Jr(xa(1/0)),Mi);return new wx(t)},Dx=e=>b(Hr(e.count-1,t=>e.start*e.factor**+t),Oa,Ex)})),kx,Ax,jx,Mx,Nx,Px,Fx,Ix,Lx,Rx,zx,Bx,Vx,Hx,Ux,Wx,Gx,Kx,qx,Jx,Yx,Xx,Zx=v((()=>{M(),S(),Mt(),F(),T(),kx=`effect/MetricKeyType`,Ax=Symbol.for(kx),jx=`effect/MetricKeyType/Counter`,Mx=Symbol.for(jx),Nx=`effect/MetricKeyType/Frequency`,Px=Symbol.for(Nx),Fx=`effect/MetricKeyType/Gauge`,Ix=Symbol.for(Fx),Lx=`effect/MetricKeyType/Histogram`,Rx=Symbol.for(Lx),zx=`effect/MetricKeyType/Summary`,Bx=Symbol.for(zx),Vx={_In:e=>e,_Out:e=>e},Hx=class{incremental;bigint;[Ax]=Vx;[Mx]=Mx;constructor(e,t){this.incremental=e,this.bigint=t,this._hash=Ot(jx)}_hash;[E](){return this._hash}[j](e){return Kx(e)}pipe(){return P(this,arguments)}},Ux=class{boundaries;[Ax]=Vx;[Rx]=Rx;constructor(e){this.boundaries=e,this._hash=b(Ot(Lx),O(D(this.boundaries)))}_hash;[E](){return this._hash}[j](e){return Yx(e)&&A(this.boundaries,e.boundaries)}pipe(){return P(this,arguments)}},Wx=e=>new Hx(e?.incremental??!1,e?.bigint??!1),Gx=e=>new Ux(e),Kx=e=>w(e,Mx),qx=e=>w(e,Px),Jx=e=>w(e,Ix),Yx=e=>w(e,Rx),Xx=e=>w(e,Bx)})),Qx,$x,eS,tS,nS,rS,iS,aS,oS,sS=v((()=>{Pi(),M(),S(),Mt(),Rr(),F(),T(),Zx(),Qx=`effect/MetricKey`,$x=Symbol.for(Qx),eS={_Type:e=>e},tS=Ai(A),nS=class{name;keyType;description;tags;[$x]=eS;constructor(e,t,n,r=[]){this.name=e,this.keyType=t,this.description=n,this.tags=r,this._hash=b(Ot(this.name+this.description),O(D(this.keyType)),O(jt(this.tags)))}_hash;[E](){return this._hash}[j](e){return rS(e)&&this.name===e.name&&A(this.keyType,e.keyType)&&A(this.description,e.description)&&tS(this.tags,e.tags)}pipe(){return P(this,arguments)}},rS=e=>w(e,$x),iS=(e,t)=>new nS(e,Wx(t),wr(t?.description)),aS=(e,t,n)=>new nS(e,Gx(t),wr(n)),oS=x(2,(e,t)=>t.length===0?e:new nS(e.name,e.keyType,e.description,xi(e.tags,t)))})),cS,lS,uS,dS,fS,pS,mS,hS,gS,_S,vS=v((()=>{M(),S(),Mt(),Xt(),Rr(),F(),cS=Symbol.for(`effect/MutableHashMap`),lS={[cS]:cS,[Symbol.iterator](){return new uS(this)},toString(){return Ht(this.toJSON())},toJSON(){return{_id:`MutableHashMap`,values:Array.from(this).map(Bt)}},[N](){return this.toJSON()},pipe(){return P(this,arguments)}},uS=class e{self;referentialIterator;bucketIterator;constructor(e){this.self=e,this.referentialIterator=e.referential[Symbol.iterator]()}next(){if(this.bucketIterator!==void 0)return this.bucketIterator.next();let e=this.referentialIterator.next();return e.done?(this.bucketIterator=new dS(this.self.buckets.values()),this.next()):e}[Symbol.iterator](){return new e(this.self)}},dS=class{backing;constructor(e){this.backing=e}currentBucket;next(){if(this.currentBucket===void 0){let e=this.backing.next();if(e.done)return e;this.currentBucket=e.value[Symbol.iterator]()}let e=this.currentBucket.next();return e.done?(this.currentBucket=void 0,this.next()):e}},fS=()=>{let e=Object.create(lS);return e.referential=new Map,e.buckets=new Map,e.bucketsSize=0,e},pS=x(2,(e,t)=>{if(Pt(t)===!1)return e.referential.has(t)?z(e.referential.get(t)):R();let n=t[E](),r=e.buckets.get(n);return r===void 0?R():mS(e,r,t)}),mS=(e,t,n,r=!1)=>{for(let i=0,a=t.length;i<a;i++)if(n[j](t[i][0])){let n=t[i][1];return r&&(t.splice(i,1),e.bucketsSize--),z(n)}return R()},hS=x(2,(e,t)=>yr(pS(e,t))),gS=x(3,(e,t,n)=>{if(Pt(t)===!1)return e.referential.set(t,n),e;let r=t[E](),i=e.buckets.get(r);return i===void 0?(e.buckets.set(r,[[t,n]]),e.bucketsSize++,e):(_S(e,i,t),i.push([t,n]),e.bucketsSize++,e)}),_S=(e,t,n)=>{for(let r=0,i=t.length;r<i;r++)if(n[j](t[r][0])){t.splice(r,1),e.bucketsSize--;return}}})),yS,bS,xS,SS,CS,wS,TS,ES,DS,OS,kS,AS,jS,MS,NS,PS,FS,IS,LS,RS,zS,BS,VS,HS,US,WS,GS,KS,qS,JS=v((()=>{Pi(),M(),S(),Mt(),F(),T(),yS=`effect/MetricState`,bS=Symbol.for(yS),xS=`effect/MetricState/Counter`,SS=Symbol.for(xS),CS=`effect/MetricState/Frequency`,wS=Symbol.for(CS),TS=`effect/MetricState/Gauge`,ES=Symbol.for(TS),DS=`effect/MetricState/Histogram`,OS=Symbol.for(DS),kS=`effect/MetricState/Summary`,AS=Symbol.for(kS),jS={_A:e=>e},MS=class{count;[bS]=jS;[SS]=SS;constructor(e){this.count=e}[E](){return b(D(xS),O(D(this.count)),k(this))}[j](e){return US(e)&&this.count===e.count}pipe(){return P(this,arguments)}},NS=Ai(A),PS=class{occurrences;[bS]=jS;[wS]=wS;constructor(e){this.occurrences=e}_hash;[E](){return b(Ot(CS),O(jt(Ur(this.occurrences.entries()))),k(this))}[j](e){return WS(e)&&NS(Ur(this.occurrences.entries()),Ur(e.occurrences.entries()))}pipe(){return P(this,arguments)}},FS=class{value;[bS]=jS;[ES]=ES;constructor(e){this.value=e}[E](){return b(D(TS),O(D(this.value)),k(this))}[j](e){return GS(e)&&this.value===e.value}pipe(){return P(this,arguments)}},IS=class{buckets;count;min;max;sum;[bS]=jS;[OS]=OS;constructor(e,t,n,r,i){this.buckets=e,this.count=t,this.min=n,this.max=r,this.sum=i}[E](){return b(D(DS),O(D(this.buckets)),O(D(this.count)),O(D(this.min)),O(D(this.max)),O(D(this.sum)),k(this))}[j](e){return KS(e)&&A(this.buckets,e.buckets)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return P(this,arguments)}},LS=class{error;quantiles;count;min;max;sum;[bS]=jS;[AS]=AS;constructor(e,t,n,r,i,a){this.error=e,this.quantiles=t,this.count=n,this.min=r,this.max=i,this.sum=a}[E](){return b(D(kS),O(D(this.error)),O(D(this.quantiles)),O(D(this.count)),O(D(this.min)),O(D(this.max)),O(D(this.sum)),k(this))}[j](e){return qS(e)&&this.error===e.error&&A(this.quantiles,e.quantiles)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return P(this,arguments)}},RS=e=>new MS(e),zS=e=>new PS(e),BS=e=>new FS(e),VS=e=>new IS(e.buckets,e.count,e.min,e.max,e.sum),HS=e=>new LS(e.error,e.quantiles,e.count,e.min,e.max,e.sum),US=e=>w(e,SS),WS=e=>w(e,wS),GS=e=>w(e,ES),KS=e=>w(e,OS),qS=e=>w(e,AS)})),YS,XS,ZS,QS,$S,eC,tC,nC,rC,iC,aC,oC,sC=v((()=>{Pi(),Ul(),S(),xg(),Rr(),F(),JS(),YS=`effect/MetricHook`,XS=Symbol.for(YS),ZS={_In:e=>e,_Out:e=>e},QS=e=>({[XS]:ZS,pipe(){return P(this,arguments)},...e}),$S=BigInt(0),eC=e=>{let t=e.keyType.bigint?$S:0,n=e.keyType.incremental?e.keyType.bigint?e=>e>=$S:e=>e>=0:e=>!0,r=e=>{n(e)&&(t+=e)};return QS({get:()=>RS(t),update:r,modify:r})},tC=e=>{let t=new Map;for(let n of e.keyType.preregisteredWords)t.set(n,0);let n=e=>{let n=t.get(e)??0;t.set(e,n+1)};return QS({get:()=>zS(t),update:n,modify:n})},nC=(e,t)=>{let n=t;return QS({get:()=>BS(n),update:e=>{n=e},modify:e=>{n+=e}})},rC=e=>{let t=e.keyType.boundaries.values,n=t.length,r=new Uint32Array(n+1),i=new Float64Array(n),a=0,o=0,s=Number.MAX_VALUE,c=Number.MIN_VALUE;b(t,pi(yg),wi((e,t)=>{i[t]=e}));let l=e=>{let t=0,l=n;for(;t!==l;){let n=Math.floor(t+(l-t)/2);e<=i[n]?l=n:t=n,l===t+1&&(e<=i[t]?l=t:t=l)}r[t]=r[t]+1,a+=1,o+=e,e<s&&(s=e),e>c&&(c=e)},u=()=>{let e=Vr(n),t=0;for(let a=0;a<n;a++){let n=i[a],o=r[a];t+=o,e[a]=[n,t]}return e};return QS({get:()=>VS({buckets:u(),count:a,min:s,max:c,sum:o}),update:l,modify:l})},iC=e=>{let{error:t,maxAge:n,maxSize:r,quantiles:i}=e.keyType,a=b(i,pi(yg)),o=Vr(r),s=0,c=0,l=0,u=0,d=0,f=e=>{let i=[],s=0;for(;s!==r-1;){let t=o[s];if(t!=null){let[r,a]=t,o=Tl(e-r);zl(o,xl)&&Rl(o,n)&&i.push(a)}s+=1}return aC(t,a,pi(i,yg))},p=(e,t)=>{if(r>0){s+=1;let n=s%r;o[n]=[t,e]}u=c===0?e:Math.min(u,e),d=c===0?e:Math.max(d,e),c+=1,l+=e};return QS({get:()=>HS({error:t,quantiles:f(Date.now()),count:c,min:u,max:d,sum:l}),update:([e,t])=>p(e,t),modify:([e,t])=>p(e,t)})},aC=(e,t,n)=>{let r=n.length;if(!$r(t))return Si();let i=t[0],a=t.slice(1),o=oC(e,r,R(),0,i,n),s=Ci(o);return a.forEach(t=>{s.push(oC(e,r,o.value,o.consumed,t,o.rest))}),wi(s,e=>[e.quantile,e.value])},oC=(e,t,n,r,i,a)=>{let o=e,s=t,c=n,l=r,u=i,d=a,f=e,p=t,m=n,h=r,g=i,_=a;for(;;){if(!$r(d))return{quantile:u,value:R(),consumed:l,rest:[]};if(u===1)return{quantile:u,value:z(si(d)),consumed:l+d.length,rest:[]};let e=ai(d),t=ui(d,t=>t===e),n=u*s,r=o/2*n,i=l+t[0].length,a=Math.abs(i-n);if(i<n-r){f=o,p=s,m=ii(d),h=i,g=u,_=t[1],o=f,s=p,c=m,l=h,u=g,d=_;continue}if(i>n+r){let t=vr(c)?z(e):c;return{quantile:u,value:t,consumed:l,rest:d}}switch(c._tag){case`None`:f=o,p=s,m=ii(d),h=i,g=u,_=t[1],o=f,s=p,c=m,l=h,u=g,d=_;continue;case`Some`:if(a<Math.abs(n-c.value)){f=o,p=s,m=ii(d),h=i,g=u,_=t[1],o=f,s=p,c=m,l=h,u=g,d=_;continue}return{quantile:u,value:z(c.value),consumed:l,rest:d}}}throw Error(`BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues`)}})),cC,lC,uC,dC,fC=v((()=>{F(),cC=`effect/MetricPair`,lC=Symbol.for(cC),uC={_Type:e=>e},dC=(e,t)=>({[lC]:uC,metricKey:e,metricState:t,pipe(){return P(this,arguments)}})})),pC,mC,hC,gC,_C=v((()=>{S(),vS(),Rr(),sC(),Zx(),fC(),pC=`effect/MetricRegistry`,mC=Symbol.for(pC),hC=class{[mC]=mC;map=fS();snapshot(){let e=[];for(let[t,n]of this.map)e.push(dC(t,n.get()));return e}get(e){let t=b(this.map,pS(e),Tr);if(t==null){if(Kx(e.keyType))return this.getCounter(e);if(Jx(e.keyType))return this.getGauge(e);if(qx(e.keyType))return this.getFrequency(e);if(Yx(e.keyType))return this.getHistogram(e);if(Xx(e.keyType))return this.getSummary(e);throw Error(`BUG: MetricRegistry.get - unknown MetricKeyType - please report an issue at https://github.com/Effect-TS/effect/issues`)}return t}getCounter(e){let t=b(this.map,pS(e),Tr);if(t==null){let n=eC(e);b(this.map,hS(e))||b(this.map,gS(e,n)),t=n}return t}getFrequency(e){let t=b(this.map,pS(e),Tr);if(t==null){let n=tC(e);b(this.map,hS(e))||b(this.map,gS(e,n)),t=n}return t}getGauge(e){let t=b(this.map,pS(e),Tr);if(t==null){let n=nC(e,e.keyType.bigint?BigInt(0):0);b(this.map,hS(e))||b(this.map,gS(e,n)),t=n}return t}getHistogram(e){let t=b(this.map,pS(e),Tr);if(t==null){let n=rC(e);b(this.map,hS(e))||b(this.map,gS(e,n)),t=n}return t}getSummary(e){let t=b(this.map,pS(e),Tr);if(t==null){let n=iC(e);b(this.map,hS(e))||b(this.map,gS(e,n)),t=n}return t}},gC=()=>new hC})),vC,yC,bC,xC,SC,CC,wC,TC,EC,DC,OC,kC=v((()=>{Pi(),S(),Ie(),F(),Vh(),sS(),Fb(),_C(),vC=`effect/Metric`,yC=Symbol.for(vC),bC={_Type:e=>e,_In:e=>e,_Out:e=>e},xC=C(Symbol.for(`effect/Metric/globalMetricRegistry`),()=>gC()),SC=function(e,t,n,r){let i=Object.assign(e=>im(e,e=>OC(i,e)),{[yC]:bC,keyType:e,unsafeUpdate:t,unsafeValue:n,unsafeModify:r,register(){return this.unsafeValue([]),this},pipe(){return P(this,arguments)}});return i},CC=(e,t)=>wC(iS(e,t)),wC=e=>{let t,n=new WeakMap,r=r=>{if(r.length===0)return t===void 0&&(t=xC.get(e)),t;let i=n.get(r);return i===void 0?(i=xC.get(oS(e,r)),n.set(r,i),i):i};return SC(e.keyType,(e,t)=>r(t).update(e),e=>r(e).get(),(e,t)=>r(t).modify(e))},TC=(e,t,n)=>wC(aS(e,t,n)),EC=x(3,(e,t,n)=>DC(e,[Nb(t,n)])),DC=x(2,(e,t)=>SC(e.keyType,(n,r)=>e.unsafeUpdate(n,xi(t,r)),n=>e.unsafeValue(xi(t,n)),(n,r)=>e.unsafeModify(n,xi(t,r)))),OC=x(2,(e,t)=>km(Xm,n=>V(()=>e.unsafeUpdate(t,n))))})),AC,jC=v((()=>{S(),wb(),Vh(),On(),{...wn},AC=x(2,(e,t)=>km(Cb,n=>V(()=>{if(n.has(e)){let r=n.get(e);r.state.completed||(r.state.completed=!0,Nh(r.result,t))}})))})),MC,NC,PC,FC,IC,LC,RC,zC,BC,VC=v((()=>{S(),Ie(),T(),Vh(),MC=`effect/Supervisor`,NC=Symbol.for(MC),PC={_T:e=>e},FC=class e{underlying;value0;[NC]=PC;constructor(e,t){this.underlying=e,this.value0=t}get value(){return this.value0}onStart(e,t,n,r){this.underlying.onStart(e,t,n,r)}onEnd(e,t){this.underlying.onEnd(e,t)}onEffect(e,t){this.underlying.onEffect(e,t)}onSuspend(e){this.underlying.onSuspend(e)}onResume(e){this.underlying.onResume(e)}map(t){return new e(this,b(this.value,Zp(t)))}zip(e){return new IC(this,e)}},IC=class e{left;right;_tag=`Zip`;[NC]=PC;constructor(e,t){this.left=e,this.right=t}get value(){return fm(this.left.value,this.right.value)}onStart(e,t,n,r){this.left.onStart(e,t,n,r),this.right.onStart(e,t,n,r)}onEnd(e,t){this.left.onEnd(e,t),this.right.onEnd(e,t)}onEffect(e,t){this.left.onEffect(e,t),this.right.onEffect(e,t)}onSuspend(e){this.left.onSuspend(e),this.right.onSuspend(e)}onResume(e){this.left.onResume(e),this.right.onResume(e)}map(e){return new FC(this,b(this.value,Zp(e)))}zip(t){return new e(this,t)}},LC=e=>w(e,NC)&&Je(e,`Zip`),RC=class{effect;[NC]=PC;constructor(e){this.effect=e}get value(){return this.effect}onStart(e,t,n,r){}onEnd(e,t){}onEffect(e,t){}onSuspend(e){}onResume(e){}map(e){return new FC(this,b(this.value,Zp(e)))}zip(e){return new IC(this,e)}onRun(e,t){return e()}},zC=e=>new RC(e),BC=C(`effect/Supervisor/none`,()=>zC(cm))})),HC,UC=v((()=>{af(),HC=Qd})),WC,GC,KC,qC,JC,YC,XC,ZC,QC,$C,ew,tw,nw=v((()=>{Ba(),UC(),M(),S(),Cs(),VC(),WC=`Empty`,GC=`AddSupervisor`,KC=`RemoveSupervisor`,qC=`AndThen`,JC={_tag:WC},YC=(e,t)=>({_tag:qC,first:e,second:t}),XC=(e,t)=>ZC(t,xa(e)),ZC=(e,t)=>{let n=e,r=t;for(;Ia(r);){let e=Ra(r);switch(e._tag){case WC:r=za(r);break;case GC:n=n.zip(e.supervisor),r=za(r);break;case KC:n=QC(n,e.supervisor),r=za(r);break;case qC:r=Ma(e.first)(Ma(e.second)(za(r)))}}return n},QC=(e,t)=>A(e,t)?BC:LC(e)?QC(e.left,t).zip(QC(e.right,t)):e,$C=e=>A(e,BC)?ps():LC(e)?b($C(e.left),xs($C(e.right))):hs(e),ew=(e,t)=>{if(A(e,t))return JC;let n=$C(e),r=$C(t),i=b(r,bs(n),Ss(JC,(e,t)=>YC(e,{_tag:GC,supervisor:t}))),a=b(n,bs(r),Ss(JC,(e,t)=>YC(e,{_tag:KC,supervisor:t})));return YC(i,a)},tw=HC({empty:JC,patch:XC,combine:YC,diff:ew})})),rw,iw,aw,ow,sw,cw,lw,uw,dw,fw,pw,mw,hw,gw,_w,vw,yw,bw,xw,Sw,Cw,ww,Tw,Ew,Dw,Ow,kw,Aw,jw,Mw,Nw,Pw,Fw,Iw,Lw,Rw,zw,Bw,Vw,Hw,Uw,Ww,Gw,Kw,qw,Jw=v((()=>{Pi(),Ba(),il(),B_(),$_(),bu(),vv(),Av(),Xv(),S(),Ie(),Cs(),Xt(),cy(),hb(),Rr(),F(),T(),Pf(),Sb(),St(),np(),bc(),vg(),wb(),Eb(),Lb(),Vh(),N_(),p_(),Y_(),ux(),Jb(),mv(),tx(),xx(),kC(),Ox(),fn(),jC(),Af(),VC(),nw(),A_(),hn(),rw=CC(`effect_fiber_started`,{incremental:!0}),iw=CC(`effect_fiber_active`),aw=CC(`effect_fiber_successes`,{incremental:!0}),ow=CC(`effect_fiber_failures`,{incremental:!0}),sw=EC(TC(`effect_fiber_lifetimes`,Dx({start:.5,factor:2,count:35})),`time_unit`,`milliseconds`),cw=`Continue`,lw=`Done`,uw=`Yield`,dw={_E:e=>e,_A:e=>e},fw=e=>{throw Error(`BUG: FiberRuntime - ${Ut(e)} - please report an issue at https://github.com/Effect-TS/effect/issues`)},pw=Symbol.for(`effect/internal/fiberRuntime/YieldedOp`),mw=C(`effect/internal/fiberRuntime/yieldedOpChannel`,()=>({currentOp:null})),hw={[tn]:(e,t,n)=>xt(()=>t.effect_instruction_i1(n)),OnStep:(e,t,n)=>Dh(Dh(n)),[nn]:(e,t,n)=>xt(()=>t.effect_instruction_i2(n)),[dn]:(e,t,n)=>(e.patchRuntimeFlags(e.currentRuntimeFlags,t.patch),bf(e.currentRuntimeFlags)&&e.isInterrupted()?Ch(e.getInterruptedCause()):Dh(n)),[sn]:(e,t,n)=>(xt(()=>t.effect_instruction_i2(n)),xt(()=>t.effect_instruction_i0())?(e.pushStack(t),xt(()=>t.effect_instruction_i1())):cm),[cn]:(e,t,n)=>{for(;;){let r=xt(()=>t.effect_instruction_i0.next(n));if(r.done)return Dh(r.value);let i=ot(r.value);if(!gh(i))return e.pushStack(t),i;if(i._tag===`Failure`)return i;n=i.value}}},gw={[Bb]:(e,t,n,r)=>(e.processNewInterruptSignal(r.cause),bf(t)?Ch(r.cause):n),[Hb]:(e,t,n,r)=>{throw Error(`It is illegal to have multiple concurrent run loops in a single fiber`)},[Vb]:(e,t,n,r)=>(r.onFiber(e,qv(t)),n),[Ub]:(e,t,n,r)=>B(dm(),()=>n)},_w=e=>Yp(Lf(e),e=>Dw(tp(e),([e,t])=>{let n=new Map,r=[];for(let e of t){r.push(Ta(e));for(let t of e)n.set(t.request,t)}let i=r.flat();return Mm(qw(e.runAll(r),i,()=>i.forEach(e=>{e.listeners.interrupted=!0})),Cb,n)},!1,!1)),vw=mn(),yw=class extends z_{[rx]=ix;[sx]=dw;_fiberRefs;_fiberId;_queue=[];_children=null;_observers=[];_running=!1;_stack=[];_asyncInterruptor=null;_asyncBlockingOn=null;_exitValue=null;_steps=[];_isYielding=!1;currentRuntimeFlags;currentOpCount=0;currentSupervisor;currentScheduler;currentTracer;currentSpan;currentContext;currentDefaultServices;constructor(e,t,n){if(super(),this.currentRuntimeFlags=n,this._fiberId=e,this._fiberRefs=t,Tf(n)){let e=this.getFiberRef(Xm);rw.unsafeUpdate(1,e),iw.unsafeUpdate(1,e)}this.refreshRefCache()}commit(){return cx(this)}id(){return this._fiberId}resume(e){this.tell(Kb(e))}get status(){return this.ask((e,t)=>t)}get runtimeFlags(){return this.ask((e,t)=>Yv(t)?e.currentRuntimeFlags:t.runtimeFlags)}scope(){return $b(this)}get children(){return this.ask(e=>Array.from(e.getChildren()))}getChildren(){return this._children===null&&(this._children=new Set),this._children}getInterruptedCause(){return this.getFiberRef(Qm)}fiberRefs(){return this.ask(e=>e.getFiberRefs())}ask(e){return rm(()=>{let t=jh(this._fiberId);return this.tell(Gb((n,r)=>{Nh(t,V(()=>e(n,r)))})),Mh(t)})}tell(e){this._queue.push(e),this._running||(this._running=!0,this.drainQueueLaterOnExecutor())}get await(){return kp(e=>{let t=t=>e(nm(t));if(this._exitValue!==null){t(this._exitValue);return}return this.tell(Gb((e,n)=>{e._exitValue===null?e.addObserver(t):t(this._exitValue)})),V(()=>this.tell(Gb((e,n)=>{e.removeObserver(t)})))},this.id())}get inheritAll(){return Sp((e,t)=>{let n=e.id(),r=e.getFiberRefs(),i=t.runtimeFlags,a=this.getFiberRefs(),o=av(r,n,a);e.setFiberRefs(o);let s=e.getFiberRef(Ww),c=b(Df(i,s),Nf(1),Nf(16));return lm(c)})}get poll(){return V(()=>wr(this._exitValue))}unsafePoll(){return this._exitValue}interruptAsFork(e){return V(()=>this.tell(Wb(Ls(e))))}unsafeInterruptAsFork(e){this.tell(Wb(Ls(e)))}addObserver(e){this._exitValue===null?this._observers.push(e):e(this._exitValue)}removeObserver(e){this._observers=this._observers.filter(t=>t!==e)}getFiberRefs(){return this.setFiberRef(Ww,this.currentRuntimeFlags),this._fiberRefs}unsafeDeleteFiberRef(e){this._fiberRefs=cv(this._fiberRefs,e)}getFiberRef(e){return this._fiberRefs.locals.has(e)?this._fiberRefs.locals.get(e)[0][1]:e.initial}setFiberRef(e,t){this._fiberRefs=dv(this._fiberRefs,{fiberId:this._fiberId,fiberRef:e,value:t}),this.refreshRefCache()}refreshRefCache(){this.currentDefaultServices=this.getFiberRef(M_),this.currentTracer=this.currentDefaultServices.unsafeMap.get(w_.key),this.currentSupervisor=this.getFiberRef(Gw),this.currentScheduler=this.getFiberRef(xb),this.currentContext=this.getFiberRef(zm),this.currentSpan=this.currentContext.unsafeMap.get(T_.key)}setFiberRefs(e){this._fiberRefs=e,this.refreshRefCache()}addChild(e){this.getChildren().add(e)}removeChild(e){this.getChildren().delete(e)}transferChildren(e){let t=this._children;if(this._children=null,t!==null&&t.size>0)for(let n of t)n._exitValue===null&&e.add(this.currentRuntimeFlags,n)}drainQueueOnCurrentThread(){let e=!0;for(;e;){let t=cw,n=globalThis[lx];globalThis[lx]=this;try{for(;t===cw;)t=this._queue.length===0?lw:this.evaluateMessageWhileSuspended(this._queue.splice(0,1)[0])}finally{this._running=!1,globalThis[lx]=n}this._queue.length>0&&!this._running?(this._running=!0,t===uw?(this.drainQueueLaterOnExecutor(),e=!1):e=!0):e=!1}}drainQueueLaterOnExecutor(){this.currentScheduler.scheduleTask(this.run,this.getFiberRef(Bm),this)}drainQueueWhileRunning(e,t){let n=t;for(;this._queue.length>0;){let t=this._queue.splice(0,1)[0];n=gw[t._tag](this,e,n,t)}return n}isInterrupted(){return!Us(this.getFiberRef(Qm))}addInterruptedCause(e){let t=this.getFiberRef(Qm);this.setFiberRef(Qm,zs(t,e))}processNewInterruptSignal(e){this.addInterruptedCause(e),this.sendInterruptSignalToAllChildren()}sendInterruptSignalToAllChildren(){if(this._children===null||this._children.size===0)return!1;let e=!1;for(let t of this._children)t.tell(Wb(Ls(this.id()))),e=!0;return e}interruptAllChildren(){if(this.sendInterruptSignalToAllChildren()){let e=this._children.values();this._children=null;let t=!1;return um({while:()=>!t,body:()=>{let n=e.next();return n.done?V(()=>{t=!0}):Tp(n.value.await)},step:()=>{}})}return null}reportExitValue(e){if(Tf(this.currentRuntimeFlags)){let t=this.getFiberRef(Xm),n=this.id().startTimeMillis,r=Date.now();switch(sw.unsafeUpdate(r-n,t),iw.unsafeUpdate(-1,t),e._tag){case rn:aw.unsafeUpdate(1,t);break;case $t:ow.unsafeUpdate(1,t)}}if(e._tag===`Failure`){let t=this.getFiberRef(Jm);!Gs(e.cause)&&t._tag===`Some`&&this.log(`Fiber terminated with an unhandled error`,e.cause,t)}}setExitValue(e){this._exitValue=e,this.reportExitValue(e);for(let t=this._observers.length-1;t>=0;t--)this._observers[t](e);this._observers=[]}getLoggers(){return this.getFiberRef(ww)}log(e,t,n){let r=yr(n)?n.value:this.getFiberRef(Um),i=this.getFiberRef(bw);if(oy(i,r))return;let a=this.getFiberRef(Wm),o=this.getFiberRef(Hm),s=this.getLoggers(),c=this.getFiberRefs();if(_s(s)>0){let n=Qc(this.getFiberRef(M_),dg),i=new Date(n.unsafeCurrentTimeMillis());Jt(c,()=>{for(let n of s)n.log({fiberId:this.id(),logLevel:r,message:e,cause:t,context:c,spans:a,annotations:o,date:i})})}}evaluateMessageWhileSuspended(e){switch(e._tag){case Ub:return uw;case Bb:return this.processNewInterruptSignal(e.cause),this._asyncInterruptor!==null&&(this._asyncInterruptor(Ch(e.cause)),this._asyncInterruptor=null),cw;case Hb:return this._asyncInterruptor=null,this._asyncBlockingOn=null,this.evaluateEffect(e.effect),cw;case Vb:return e.onFiber(this,this._exitValue===null?Jv(this.currentRuntimeFlags,this._asyncBlockingOn):Kv),cw;default:return fw(e)}}evaluateEffect(e){this.currentSupervisor.onResume(this);try{let t=bf(this.currentRuntimeFlags)&&this.isInterrupted()?Ch(this.getInterruptedCause()):e;for(;t!==null;){let e=t,n=this.runLoop(e);if(n===pw){let e=mw.currentOp;mw.currentOp=null,e._op===`Yield`?vf(this.currentRuntimeFlags)?(this.tell(qb()),this.tell(Kb(Oh)),t=null):t=Oh:e._op===`Async`&&(t=null)}else{this.currentRuntimeFlags=b(this.currentRuntimeFlags,yf(16));let e=this.interruptAllChildren();e===null?(this._queue.length===0?this.setExitValue(n):this.tell(Kb(n)),t=null):t=B(e,()=>n)}}}finally{this.currentSupervisor.onSuspend(this)}}start(e){if(this._running)this.tell(Kb(e));else{this._running=!0;let t=globalThis[lx];globalThis[lx]=this;try{this.evaluateEffect(e)}finally{this._running=!1,globalThis[lx]=t,this._queue.length>0&&this.drainQueueLaterOnExecutor()}}}startFork(e){this.tell(Kb(e))}patchRuntimeFlags(e,t){let n=Of(e,t);return globalThis[lx]=this,this.currentRuntimeFlags=n,n}initiateAsync(e,t){let n=!1,r=e=>{n||(n=!0,this.tell(Kb(e)))};bf(e)&&(this._asyncInterruptor=r);try{t(r)}catch(e){r(zp(Is(e)))}}pushStack(e){this._stack.push(e),e._op===`OnStep`&&this._steps.push({refs:this.getFiberRefs(),flags:this.currentRuntimeFlags})}popStack(){let e=this._stack.pop();if(e)return e._op===`OnStep`&&this._steps.pop(),e}getNextSuccessCont(){let e=this.popStack();for(;e;){if(e._op!==`OnFailure`)return e;e=this.popStack()}}getNextFailCont(){let e=this.popStack();for(;e;){if(e._op!==`OnSuccess`&&e._op!==`While`&&e._op!==`Iterator`)return e;e=this.popStack()}}Tag(e){return V(()=>$c(this.currentContext,e))}Left(e){return Lp(e.left)}None(e){return Lp(new ph)}Right(e){return Dh(e.right)}Some(e){return Dh(e.value)}Micro(e){return Dp(t=>{let n=t,r=db(nb(e,this.currentContext));return r.addObserver(e=>{if(e._tag===`Success`)return n(Dh(e.value));switch(e.cause._tag){case`Interrupt`:return n(Ch(Ls(mu)));case`Fail`:return n(Lp(e.cause.error));case`Die`:return n(Np(e.cause.defect))}}),Dp(e=>{n=t=>{e(cm)},r.unsafeInterrupt()})})}[an](e){let t=xt(()=>e.effect_instruction_i0()),n=this.getNextSuccessCont();return n===void 0?(mw.currentOp=Dh(t),pw):(n._op in hw||fw(n),hw[n._op](this,n,t))}[rn](e){let t=e,n=this.getNextSuccessCont();return n===void 0?(mw.currentOp=t,pw):(n._op in hw||fw(n),hw[n._op](this,n,t.effect_instruction_i0))}[$t](e){let t=e.effect_instruction_i0,n=this.getNextFailCont();if(n!==void 0)switch(n._op){case en:case nn:return bf(this.currentRuntimeFlags)&&this.isInterrupted()?Ch(Qs(t)):xt(()=>n.effect_instruction_i1(t));case`OnStep`:return bf(this.currentRuntimeFlags)&&this.isInterrupted()?Ch(Qs(t)):Dh(Ch(t));case dn:return this.patchRuntimeFlags(this.currentRuntimeFlags,n.patch),bf(this.currentRuntimeFlags)&&this.isInterrupted()?Ch(zs(t,this.getInterruptedCause())):Ch(t);default:fw(n)}else return mw.currentOp=Ch(t),pw}[ln](e){return xt(()=>e.effect_instruction_i0(this,qv(this.currentRuntimeFlags)))}Blocked(e){let t=this.getFiberRefs(),n=this.currentRuntimeFlags;if(this._steps.length>0){let r=[],i=this._steps[this._steps.length-1],a=this.popStack();for(;a&&a._op!==`OnStep`;)r.push(a),a=this.popStack();this.setFiberRefs(i.refs),this.currentRuntimeFlags=i.flags;let o=Ov(i.refs,t),s=Df(i.flags,n);return Dh(mp(e.effect_instruction_i0,Sp(t=>{for(;r.length>0;)t.pushStack(r.pop());return t.setFiberRefs(kv(t.id(),t.getFiberRefs())(o)),t.currentRuntimeFlags=Of(s)(t.currentRuntimeFlags),e.effect_instruction_i1})))}return sm(t=>B(kw(hp(e.effect_instruction_i0)),()=>t(e.effect_instruction_i1)))}RunBlocked(e){return _w(e.effect_instruction_i0)}[on](e){let t=e.effect_instruction_i0,n=this.currentRuntimeFlags,r=Of(n,t);if(bf(r)&&this.isInterrupted())return Ch(this.getInterruptedCause());if(this.patchRuntimeFlags(this.currentRuntimeFlags,t),e.effect_instruction_i1){let t=Df(r,n);return this.pushStack(new _p(t,e)),xt(()=>e.effect_instruction_i1(n))}return Oh}[tn](e){return this.pushStack(e),e.effect_instruction_i0}OnStep(e){return this.pushStack(e),e.effect_instruction_i0}[en](e){return this.pushStack(e),e.effect_instruction_i0}[nn](e){return this.pushStack(e),e.effect_instruction_i0}[Zt](e){return this._asyncBlockingOn=e.effect_instruction_i1,this.initiateAsync(this.currentRuntimeFlags,e.effect_instruction_i0),mw.currentOp=e,pw}[un](e){return this._isYielding=!1,mw.currentOp=e,pw}[sn](e){let t=e.effect_instruction_i0,n=e.effect_instruction_i1;return t()?(this.pushStack(e),n()):Oh}[cn](e){return hw[cn](this,e,void 0)}[Qt](e){return xt(()=>e.commit())}runLoop(e){let t=e;for(this.currentOpCount=0;;){if(this.currentRuntimeFlags&2&&this.currentSupervisor.onEffect(this,t),this._queue.length>0&&(t=this.drainQueueWhileRunning(this.currentRuntimeFlags,t)),!this._isYielding){this.currentOpCount+=1;let e=this.currentScheduler.shouldYield(this);if(e!==!1){this._isYielding=!0,this.currentOpCount=0;let n=t;t=B(dm({priority:e}),()=>n)}}try{if(t=this.currentTracer.context(()=>{if(vw!==t[gp]._V){let e=this.getFiberRef(Ym);if(e._tag===`Some`){let n=t[gp]._V;this.log(`Executing an Effect versioned ${n} with a Runtime of version ${mn()}, you may want to dedupe the effect dependencies, you can use the language service plugin to detect this at compile time: https://github.com/Effect-TS/language-service`,Ps,e)}}return this[t._op](t)},this),t===pw){let e=mw.currentOp;return e._op===`Yield`||e._op===`Async`?pw:(mw.currentOp=null,e._op===`Success`||e._op===`Failure`?e:Ch(Is(e)))}}catch(e){t=t!==pw&&!w(t,`_op`)||!(t._op in this)?Pp(`Not a valid effect: ${Ut(t)}`):lh(e)?Ch(zs(Is(e),Ls(mu))):Np(e)}}}run=()=>{this.drainQueueOnCurrentThread()}},bw=C(`effect/FiberRef/currentMinimumLogLevel`,()=>Nm(sy(`Info`))),xw=e=>mx(t=>{let n=hv(t.context,M_);Qc(n,d_).unsafe.log(e.log(t))}),Sw=C(Symbol.for(`effect/Logger/defaultLogger`),()=>xw(vx)),Cw=C(Symbol.for(`effect/Logger/tracerLogger`),()=>mx(({annotations:e,cause:t,context:n,fiberId:r,logLevel:i,message:a})=>{let o=Ib(el(uv(n,zm),T_));if(o._tag===`None`||o.value._tag===`ExternalSpan`)return;let s=$c(uv(n,M_),dg),c={};for(let[t,n]of e)c[t]=n;c[`effect.fiberId`]=vu(r),c[`effect.logLevel`]=i.label,t!==null&&t._tag!==`Empty`&&(c[`effect.cause`]=dc(t,{renderErrorCause:!0})),o.value.event(Ut(Array.isArray(a)&&a.length===1?a[0]:a),s.unsafeCurrentTimeNanos(),c)})),ww=C(Symbol.for(`effect/FiberRef/currentLoggers`),()=>Pm(hs(Sw,Cw))),Tw=x(e=>$e(e[0]),(e,t,n)=>Sp(r=>{let i=n?.batching===!0||n?.batching===`inherit`&&r.getFiberRef(qm);return n?.discard?Tb(n.concurrency,()=>Iw(X_,n?.concurrentFinalizers)(n=>i?Dw(e,(e,r)=>n(t(e,r)),!0,!1,1):Yp(e,(e,r)=>n(t(e,r)))),()=>Iw(Z_,n?.concurrentFinalizers)(n=>Dw(e,(e,r)=>n(t(e,r)),i,!1)),r=>Iw(Q_(r),n?.concurrentFinalizers)(n=>Dw(e,(e,r)=>n(t(e,r)),i,!1,r))):Tb(n?.concurrency,()=>Iw(X_,n?.concurrentFinalizers)(n=>i?Ow(e,1,(e,r)=>n(t(e,r)),!0):Jp(e,(e,r)=>n(t(e,r)))),()=>Iw(Z_,n?.concurrentFinalizers)(n=>Ew(e,(e,r)=>n(t(e,r)),i)),r=>Iw(Q_(r),n?.concurrentFinalizers)(n=>Ow(e,r,(e,r)=>n(t(e,r)),i)))})),Ew=(e,t,n)=>rm(()=>{let r=Ur(e),i=Array(r.length);return mm(Dw(r,(e,n)=>B(t(e,n),e=>V(()=>i[n]=e)),n,!1),nm(i))}),Dw=(e,t,n,r,i)=>sm(a=>am(o=>Sp(s=>{let c=Array.from(e).reverse(),l=c.length;if(l===0)return cm;let u=0,d=!1,f=i?Math.min(c.length,i):c.length,p=new Set,m=[],h=()=>p.forEach(e=>{e.currentScheduler.scheduleTask(()=>{e.unsafeInterruptAsFork(s.id())},0,e)}),g=[],_=[],ee=[],te=()=>{let e=m.filter(({exit:e})=>e._tag===`Failure`).sort((e,t)=>e.index<t.index?-1:e.index===t.index?0:1).map(({exit:e})=>e);return e.length===0&&e.push(Oh),e},ne=(e,t=!1)=>{let n=om(o(e)),r=jw(n,s,s.currentRuntimeFlags,ex);return s.currentScheduler.scheduleTask(()=>{t&&r.unsafeInterruptAsFork(s.id()),r.resume(n)},0,r),r},re=()=>{r||(l-=c.length,c=[]),d=!0,h()},ie=n?Up:Ip,ae=ne(kp(e=>{let r=(e,t)=>{e._op===`Blocked`?ee.push(e):(m.push({index:t,exit:e}),e._op===`Failure`&&!d&&re())},o=()=>{if(c.length>0){let f=c.pop(),h=u++,re=()=>{let e=c.pop();return h=u++,B(dm(),()=>B(ie(a(t(e,h))),ae))},ae=e=>c.length>0&&(r(e,h),c.length>0)?re():nm(e),oe=B(ie(a(t(f,h))),ae),se=ne(oe);g.push(se),p.add(se),d&&se.currentScheduler.scheduleTask(()=>{se.unsafeInterruptAsFork(s.id())},0,se),se.addObserver(t=>{let a;if(a=t._op===`Failure`?t:t.effect_instruction_i0,_.push(se),p.delete(se),r(a,h),m.length===l)e(nm(xr(bh(te(),{parallel:!0}),()=>Oh)));else if(ee.length+m.length===l){let t=te(),r=ee.map(e=>e.effect_instruction_i0).reduce(Ff);e(nm(mp(r,Dw([xr(bh(t,{parallel:!0}),()=>Oh),...ee.map(e=>e.effect_instruction_i1)],e=>e,n,!0,i))))}else o()})}};for(let e=0;e<f;e++)o()}));return Tp(em(Wp(a(cx(ae))),Eh({onFailure:e=>{re();let t=ee.length+1,n=Math.min(typeof i==`number`?i:ee.length,ee.length),r=Array.from(ee);return kp(i=>{let a=[],o=0,s=0,c=(n,s)=>c=>{a[n]=c,o++,o===t&&i(Dh(Ch(e))),r.length>0&&s&&l()},l=()=>{ne(r.pop(),!0).addObserver(c(s,!0)),s++};ae.addObserver(c(s,!1)),s++;for(let e=0;e<n;e++)l()})},onSuccess:()=>Jp(_,e=>e.inheritAll)})))}))),Ow=(e,t,n,r)=>rm(()=>{let i=Ur(e),a=Array(i.length);return mm(Dw(i,(e,t)=>Zp(n(e,t),e=>a[t]=e),r,!1,t),nm(a))}),kw=e=>Nw(e,ex),Aw=(e,t,n,r=null)=>{let i=Mw(e,t,n,r);return i.resume(e),i},jw=(e,t,n,r=null)=>Mw(e,t,n,r),Mw=(e,t,n,r=null)=>{let i=yu(),a=t.getFiberRefs(),o=ov(a,i),s=new yw(i,o,n),c=uv(o,zm),l=s.currentSupervisor;return l.onStart(c,e,z(t),s),s.addObserver(e=>l.onEnd(e,s)),(r===null?b(t.getFiberRef(Zm),xr(()=>t.scope())):r).add(n,s),s},Nw=(e,t)=>Sp((n,r)=>nm(Aw(e,n,r.runtimeFlags,t))),Pw=e=>Lh(t=>br(el(t,Rw),{onNone:()=>e,onSome:t=>{switch(t.strategy._tag){case`Parallel`:return e;case`Sequential`:case`ParallelN`:return B(rh(t,Z_),t=>Hw(e,t))}}})),Fw=e=>t=>Lh(n=>br(el(n,Rw),{onNone:()=>t,onSome:n=>n.strategy._tag===`ParallelN`&&n.strategy.parallelism===e?t:B(rh(n,Q_(e)),e=>Hw(t,e))})),Iw=(e,t)=>n=>Lh(r=>br(el(r,Rw),{onNone:()=>n(be),onSome:r=>{if(t===!0){let t=e._tag===`Parallel`?Pw:e._tag===`Sequential`?Lw:Fw(e.parallelism);switch(r.strategy._tag){case`Parallel`:return t(n(Pw));case`Sequential`:return t(n(Lw));case`ParallelN`:return t(n(Fw(r.strategy.parallelism)))}}else return n(be)}})),Lw=e=>Lh(t=>br(el(t,Rw),{onNone:()=>e,onSome:t=>{switch(t.strategy._tag){case`Sequential`:return e;case`Parallel`:case`ParallelN`:return B(rh(t,X_),t=>Hw(e,t))}}})),Rw=Jc(`effect/Scope`),zw=(e,t)=>{e.state._tag===`Open`&&e.state.finalizers.set({},t)},Bw={[$m]:$m,[eh]:eh,pipe(){return P(this,arguments)},fork(e){return V(()=>{let t=Vw(e);if(this.state._tag===`Closed`)return t.state=this.state,t;let n={};return this.state.finalizers.set(n,e=>t.close(e)),zw(t,e=>V(()=>{this.state._tag===`Open`&&this.state.finalizers.delete(n)})),t})},close(e){return rm(()=>{if(this.state._tag===`Closed`)return cm;let t=Array.from(this.state.finalizers.values()).reverse();return this.state={_tag:`Closed`,exit:e},t.length===0?cm:q_(this.strategy)?b(Jp(t,t=>Ip(t(e))),B(e=>b(bh(e),Or(yh),xr(()=>Oh)))):J_(this.strategy)?b(Ew(t,t=>Ip(t(e)),!1),B(e=>b(bh(e,{parallel:!0}),Or(yh),xr(()=>Oh)))):b(Ow(t,this.strategy.parallelism,t=>Ip(t(e)),!1),B(e=>b(bh(e,{parallel:!0}),Or(yh),xr(()=>Oh))))})},addFinalizer(e){return rm(()=>this.state._tag===`Closed`?e(this.state.exit):(this.state.finalizers.set({},e),cm))}},Vw=(e=W_)=>{let t=Object.create(Bw);return t.strategy=e,t.state={_tag:`Open`,finalizers:new Map},t},Hw=x(2,(e,t)=>zh(e,tl(Xc(Rw,t)))),Uw=e=>Lm(e,{differ:tw,fork:JC}),Ww=Rm(wf),Gw=Uw(BC),Kw=x(2,(e,t)=>sm(n=>Kp(n(e),{onFailure:e=>Kp(t,{onFailure:t=>zp(zs(e,t)),onSuccess:()=>zp(e)}),onSuccess:e=>wp(t,e)}))),qw=(e,t,n)=>Hp(r=>Kw(B(kw(Xp(e)),e=>kp(r=>{let i=t.map(e=>e.listeners.count),a=()=>{i.every(e=>e===0)&&t.every(e=>e.result.state.current._tag===`Pending`||!!(e.result.state.current._tag===`Done`&&gh(e.result.state.current.effect)&&e.result.state.current.effect._tag===`Failure`&&Ws(e.result.state.current.effect.cause)))&&(o.forEach(e=>e()),n?.(),r(hm(e)))};e.addObserver(e=>{o.forEach(e=>e()),r(e)});let o=t.map((e,t)=>{let n=e=>{i[t]=e,a()};return e.listeners.addObserver(n),()=>e.listeners.removeObserver(n)});return a(),V(()=>{o.forEach(e=>e())})})),rm(()=>{let e=t.flatMap(e=>e.state.completed?[]:[e]);return Yp(e,e=>AC(e.request,wh(r)))})))})),Yw,Xw,Zw=v((()=>{Vh(),Yw=nh,Xw=rh})),Qw,$w,eT,tT,nT,rT,iT,aT,oT,sT,cT,lT,uT,dT,fT,pT,mT,hT=v((()=>{il(),M(),bu(),vv(),Xt(),Rr(),F(),Sb(),Zw(),bc(),Vh(),Y_(),Jw(),tx(),Af(),VC(),Qw=e=>function(){if(arguments.length===1){let t=arguments[0];return(n,...r)=>e(t,n,...r)}return e.apply(this,arguments)},$w=Qw((e,t,n)=>{let r=yu(),i=[[zm,[[r,e.context]]]];n?.scheduler&&i.push([xb,[[r,n.scheduler]]]);let a=gv(e.fiberRefs,{entries:i,forkAs:r});n?.updateRefs&&(a=n.updateRefs(a,r));let o=new yw(r,a,e.runtimeFlags),s=t;n?.scope&&(s=B(Xw(n.scope,W_),e=>mm(th(e,Hp(e=>A(e,o.id())?cm:gm(o,e))),em(t,t=>Yw(e,t)))));let c=o.currentSupervisor;return c!==BC&&(c.onStart(e.context,s,R(),o),o.addObserver(e=>c.onEnd(e,o))),ex.add(e.runtimeFlags,o),n?.immediate===!1?o.resume(s):o.start(s),o}),eT=Qw((e,t)=>{let n=cT(e)(t);if(n._tag===`Failure`)throw oT(n.effect_instruction_i0);return n.effect_instruction_i0}),tT=class extends Error{fiber;_tag=`AsyncFiberException`;constructor(e){super(`Fiber #${e.id().id} cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work`),this.fiber=e,this.name=this._tag,this.stack=this.message}},nT=e=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let n=new tT(e);return Error.stackTraceLimit=t,n},rT=Symbol.for(`effect/Runtime/FiberFailure`),iT=Symbol.for(`effect/Runtime/FiberFailure/Cause`),aT=class extends Error{[rT];[iT];constructor(e){let t=yc(e)[0];super(t?.message||`An error has occurred`),this[rT]=rT,this[iT]=e,this.name=t?`(FiberFailure) ${t.name}`:`FiberFailure`,t?.stack&&(this.stack=t.stack)}toJSON(){return{_id:`FiberFailure`,cause:this[iT].toJSON()}}toString(){return`(FiberFailure) `+dc(this[iT],{renderErrorCause:!0})}[N](){return this.toString()}},oT=e=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let n=new aT(e);return Error.stackTraceLimit=t,n},sT=e=>{let t=e;switch(t._op){case`Failure`:case`Success`:return t;case`Left`:return Sh(t.left);case`Right`:return Dh(t.right);case`Some`:return Dh(t.value);case`None`:return Sh(new ph)}},cT=Qw((e,t)=>{let n=sT(t);if(n)return n;let r=new bb,i=$w(e)(t,{scheduler:r});return r.flush(),i.unsafePoll()||xh(Mp(nT(i),Bh(i)))}),lT=class{context;runtimeFlags;fiberRefs;constructor(e,t,n){this.context=e,this.runtimeFlags=t,this.fiberRefs=n}pipe(){return P(this,arguments)}},uT=e=>new lT(e.context,e.runtimeFlags,e.fiberRefs),dT=Cf(1,32,4),fT=uT({context:Yc(),runtimeFlags:dT,fiberRefs:_v()}),pT=$w(fT),mT=eT(fT)})),gT,_T,vT,yT,bT,xT,ST,CT,wT,TT,ET,DT,OT,kT,AT,jT,MT,NT,PT,FT,IT,LT,RT,zT,BT,VT,HT,UT,WT,GT,KT,qT,JT,YT,XT,ZT,QT,$T,eE,tE,nE,rE,iE,aE,oE,sE,cE,lE,uE,dE,fE=v((()=>{Gh(),M(),Ne(),S(),Ie(),Mt(),Xt(),Rr(),F(),T(),gT=Symbol.for(`effect/DateTime`),_T=Symbol.for(`effect/DateTime/TimeZone`),vT={[gT]:gT,pipe(){return P(this,arguments)},[N](){return this.toString()},toJSON(){return ZT(this).toJSON()}},yT={...vT,_tag:`Utc`,[E](){return k(this,Dt(this.epochMillis))},[j](e){return TT(e)&&e._tag===`Utc`&&this.epochMillis===e.epochMillis},toString(){return`DateTime.Utc(${ZT(this).toJSON()})`}},bT={...vT,_tag:`Zoned`,[E](){return b(Dt(this.epochMillis),O(D(this.zone)),k(this))},[j](e){return TT(e)&&e._tag===`Zoned`&&this.epochMillis===e.epochMillis&&A(this.zone,e.zone)},toString(){return`DateTime.Zoned(${dE(this)})`}},xT={[_T]:_T,[N](){return this.toString()}},ST={...xT,_tag:`Named`,[E](){return k(this,Ot(`Named:${this.id}`))},[j](e){return ET(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},CT={...xT,_tag:`Offset`,[E](){return k(this,Ot(`Offset:${this.offset}`))},[j](e){return ET(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${eE(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},wT=(e,t,n)=>{let r=Object.create(bT);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},TT=e=>w(e,gT),ET=e=>w(e,_T),DT=e=>ET(e)&&e._tag===`Offset`,OT=e=>ET(e)&&e._tag===`Named`,kT=e=>e._tag===`Utc`,AT=e=>e._tag===`Zoned`,jT=Ee((e,t)=>e.epochMillis===t.epochMillis),MT=e=>{let t=Object.create(yT);return t.epochMillis=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},NT=e=>{let t=e.getTime();if(Number.isNaN(t))throw new Uh(`Invalid date`);return MT(t)},PT=e=>{if(TT(e))return e;if(e instanceof Date)return NT(e);if(typeof e==`object`){let t=new Date(0);return rE(t,e),NT(t)}return typeof e==`string`&&!FT(e)?NT(new Date(e+`Z`)):NT(new Date(e))},FT=e=>/Z|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),IT=-864e13+432e5,LT=864e13-504e5,RT=(e,t)=>{if(t?.timeZone===void 0&&TT(e)&&AT(e))return e;let n=PT(e);if(n.epochMillis<IT||n.epochMillis>LT)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=KT(e)}else if(ET(t?.timeZone))r=t.timeZone;else if(typeof t?.timeZone==`number`)r=KT(t.timeZone);else{let e=YT(t.timeZone);if(vr(e))throw new Uh(`Invalid time zone: ${t.timeZone}`);r=e.value}return t?.adjustForTimeZone===!0?aE(n.epochMillis,r,t?.disambiguation??`compatible`):wT(n.epochMillis,r,n.partsUtc)},zT=Er(RT),BT=/^(.{17,35})\[(.+)\]$/,VT=e=>{let t=BT.exec(e);if(t===null){let t=sE(e);return t===null?R():zT(e,{timeZone:t})}let[,n,r]=t;return zT(n,{timeZone:r})},HT=C(`effect/DateTime/validZoneCache`,()=>new Map),UT={day:`numeric`,month:`numeric`,year:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},WT=e=>{let t=e.resolvedOptions().timeZone;if(HT.has(t))return HT.get(t);let n=Object.create(ST);return n.id=t,n.format=e,HT.set(t,n),n},GT=e=>{if(HT.has(e))return HT.get(e);try{return WT(new Intl.DateTimeFormat(`en-US`,{...UT,timeZone:e}))}catch{throw new Uh(`Invalid time zone: ${e}`)}},KT=e=>{let t=Object.create(CT);return t.offset=e,t},qT=Er(GT),JT=/^(?:GMT|[+-])/,YT=e=>{if(JT.test(e)){let t=sE(e);return t===null?R():z(KT(t))}return qT(e)},XT=e=>e._tag===`Offset`?eE(e.offset):e.id,ZT=e=>new Date(e.epochMillis),QT=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},$T=e=>QT(e).getTime()-nE(e),eE=e=>{let t=Math.abs(e),n=Math.floor(t/36e5),r=Math.round(t%36e5/6e4);return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},tE=e=>eE($T(e)),nE=e=>e.epochMillis,rE=(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)},iE=864e5,aE=(e,t,n)=>{if(t._tag===`Offset`)return wT(e-t.offset,t);let r=cE(e-iE,e,t),i=cE(e+iE,e,t);if(r===i)return wT(e-r,t);let a=r<i,o=r-i;if(a){if(cE(e-i,e,t)===i)return wT(e-i,t);let a=wT(e-r,t);if(e!==QT(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 wT(e-i,t);case`compatible`:case`later`:return a}return a}if(cE(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||cE(e-r+o,e+o,t)===r)return wT(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 wT(e-i,t)},oE=/([+-])(\d{2}):(\d{2})$/,sE=e=>{let t=oE.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},cE=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=sE(r);return i===null?$T(wT(t,n)):i},lE=e=>ZT(e).toISOString(),uE=e=>{let t=QT(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${tE(e)}`},dE=e=>e.zone._tag===`Offset`?uE(e):`${uE(e)}[${e.zone.id}]`})),pE,mE,hE,gE,_E,vE=v((()=>{pE=e=>e.toUpperCase(),mE=e=>e.toLowerCase(),hE=e=>e.length===0?e:pE(e[0])+e.slice(1),gE=e=>e.length===0?e:mE(e[0])+e.slice(1),_E=e=>e.length>0})),yE,bE,xE,SE,CE,wE,TE,EE,DE,OE,kE,AE,jE=v((()=>{Vh(),Jw(),hT(),yE=xp,bE=Tw,xE=rm,SE=cm,CE=Ap,wE=Zp,TE=Qp,EE=$p,DE=Fp,OE=B,kE=pT,AE=mT})),ME,NE,PE,FE,IE,LE,RE,zE,BE,VE,HE,UE,WE,GE,KE,qE,JE,YE,XE=v((()=>{il(),fE(),ME=TT,NE=DT,PE=OT,FE=kT,IE=AT,LE=jT,RE=NT,zE=PT,BE=RT,VE=VT,HE=GT,UE=KT,WE=YT,GE=XT,KE=ZT,qE=nE,nl(`effect/DateTime/CurrentTimeZone`)(),JE=lE,YE=dE})),ZE,QE,$E,eD,tD,nD,rD=v((()=>{Xt(),ZE=(e,t)=>{switch(t._tag){case`StringKeyword`:case`TemplateLiteral`:return Object.keys(e);case`SymbolKeyword`:return Object.getOwnPropertySymbols(e);case`Refinement`:return ZE(e,t.from)}},QE=e=>{let t=!1,n;return()=>t?n:(n=e(),t=!0,n)},$E=e=>Array.isArray(e),eD=e=>!Array.isArray(e),tD=e=>`[${Rt(e)}]`,nD=e=>$E(e)?e.map(tD).join(``):tD(e)})),iD,aD,oD,sD,cD,lD,uD,dD,fD=v((()=>{Pi(),Xt(),rD(),iD=(e,t,n,r)=>{let i=e;return n&&$r(n)&&(i+=`\nat path: ${nD(n)}`),t!==void 0&&(i+=`\ndetails: ${t}`),r&&(i+=`\nschema (${r._tag}): ${r}`),i},aD=e=>iD(`Unsupported key schema`,void 0,void 0,e),oD=e=>iD(`Unsupported literal`,`literal value: ${zt(e)}`),sD=e=>iD(`Duplicate index signature`,`${e} index signature`),cD=iD(`Unsupported index signature parameter`,"An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),lD=iD(`Invalid element`,`A required element cannot follow an optional element. ts(1257)`),uD=e=>iD(`Duplicate property signature transformation`,`Duplicate key ${zt(e)}`),dD=e=>iD(`Duplicate property signature`,`Duplicate key ${zt(e)}`)})),pD,mD,hD,gD,_D,vD,yD,bD,xD,SD,CD,wD,TD,ED,DD,OD=v((()=>{pD=Symbol.for(`effect/SchemaId/DateFromSelf`),mD=Symbol.for(`effect/SchemaId/GreaterThan`),hD=Symbol.for(`effect/SchemaId/GreaterThanOrEqualTo`),gD=Symbol.for(`effect/SchemaId/LessThan`),_D=Symbol.for(`effect/SchemaId/LessThanOrEqualTo`),vD=Symbol.for(`effect/SchemaId/Int`),yD=Symbol.for(`effect/SchemaId/NonNaN`),bD=Symbol.for(`effect/SchemaId/Finite`),xD=Symbol.for(`effect/SchemaId/JsonNumber`),SD=Symbol.for(`effect/SchemaId/Between`),CD=Symbol.for(`effect/SchemaId/GreaterThanOrEqualToBigint`),wD=Symbol.for(`effect/SchemaId/BetweenBigint`),TD=Symbol.for(`effect/SchemaId/MinLength`),ED=Symbol.for(`effect/SchemaId/MaxLength`),DD=Symbol.for(`effect/SchemaId/Length`)}));function kD(e,t){let n=!1,r=Vr(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}function AD(e){return br(tO(e),{onNone:()=>``,onSome:e=>e.map(e=>` & Brand<${zt(e)}>`).join(``)})}var jD,MD,ND,PD,FD,ID,LD,RD,zD,BD,VD,HD,UD,WD,GD,KD,qD,JD,YD,XD,ZD,QD,$D,eO,tO,nO,rO,iO,aO,oO,sO,cO,lO,uO,dO,fO,pO,mO,hO,gO,_O,vO,yO,bO,xO,SO,CO,wO,TO,EO,DO,OO,kO,AO,jO,MO,NO,PO,FO,IO,LO,RO,zO,BO,VO,HO,UO,WO,GO,KO,qO,JO,YO,XO,ZO,QO,$O,ek,tk,nk,rk,ik,ak,ok,sk,ck,lk,uk,dk,fk,pk,mk,hk,gk,_k,vk,yk,bk,xk,Sk,Ck,wk,Tk,Ek,Dk,Ok,kk,Ak,jk,Mk,Nk,Pk,Fk,Ik,Lk,Rk=v((()=>{Pi(),S(),Ie(),Xt(),fD(),rD(),xg(),Rr(),gr(),T(),Cg(),jD=Symbol.for(`effect/annotation/TypeConstructor`),MD=Symbol.for(`effect/annotation/Brand`),ND=Symbol.for(`effect/annotation/SchemaId`),PD=Symbol.for(`effect/annotation/Message`),FD=Symbol.for(`effect/annotation/MissingMessage`),ID=Symbol.for(`effect/annotation/Identifier`),LD=Symbol.for(`effect/annotation/Title`),RD=Symbol.for(`effect/annotation/AutoTitle`),zD=Symbol.for(`effect/annotation/Description`),BD=Symbol.for(`effect/annotation/Examples`),VD=Symbol.for(`effect/annotation/Default`),HD=Symbol.for(`effect/annotation/JSONSchema`),UD=Symbol.for(`effect/annotation/Arbitrary`),WD=Symbol.for(`effect/annotation/Pretty`),GD=Symbol.for(`effect/annotation/Equivalence`),KD=Symbol.for(`effect/annotation/Documentation`),qD=Symbol.for(`effect/annotation/Concurrency`),JD=Symbol.for(`effect/annotation/Batching`),YD=Symbol.for(`effect/annotation/ParseIssueTitle`),XD=Symbol.for(`effect/annotation/ParseOptions`),ZD=Symbol.for(`effect/annotation/DecodingFallback`),QD=Symbol.for(`effect/annotation/Surrogate`),$D=Symbol.for(`effect/annotation/StableFilter`),eO=x(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?z(e.annotations[t]):R()),tO=eO(MD),nO=eO(PD),rO=eO(FD),iO=eO(LD),aO=eO(RD),oO=eO(ID),sO=eO(zD),cO=eO(qD),lO=eO(JD),uO=eO(YD),dO=eO(XD),fO=eO(ZD),pO=eO(QD),mO=eO($D),hO=e=>Lr(mO(e),e=>e===!0),gO=Symbol.for(`effect/annotation/JSONIdentifier`),_O=eO(gO),vO=e=>Sr(_O(e),()=>oO(e)),yO=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 xr(Lk(this),()=>`<declaration schema>`)}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map(e=>e.toJSON()),annotations:Nk(this.annotations)}}},bO=e=>t=>t._tag===e,xO=class{literal;annotations;_tag=`Literal`;constructor(e,t={}){this.literal=e,this.annotations=t}toString(){return xr(Lk(this),()=>zt(this.literal))}toJSON(){return{_tag:this._tag,literal:Ve(this.literal)?String(this.literal):this.literal,annotations:Nk(this.annotations)}}},SO=bO(`Literal`),CO=new xO(null),wO=class{symbol;annotations;_tag=`UniqueSymbol`;constructor(e,t={}){this.symbol=e,this.annotations=t}toString(){return xr(Lk(this),()=>zt(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:Nk(this.annotations)}}},TO=class{annotations;_tag=`UndefinedKeyword`;constructor(e={}){this.annotations=e}toString(){return Fk(this)}toJSON(){return{_tag:this._tag,annotations:Nk(this.annotations)}}},EO=new TO({[LD]:`undefined`}),DO=class{annotations;_tag=`NeverKeyword`;constructor(e={}){this.annotations=e}toString(){return Fk(this)}toJSON(){return{_tag:this._tag,annotations:Nk(this.annotations)}}},OO=new DO({[LD]:`never`}),kO=class{annotations;_tag=`UnknownKeyword`;constructor(e={}){this.annotations=e}toString(){return Fk(this)}toJSON(){return{_tag:this._tag,annotations:Nk(this.annotations)}}},AO=new kO({[LD]:`unknown`}),jO=class{annotations;_tag=`AnyKeyword`;constructor(e={}){this.annotations=e}toString(){return Fk(this)}toJSON(){return{_tag:this._tag,annotations:Nk(this.annotations)}}},MO=new jO({[LD]:`any`}),NO=class{annotations;_tag=`StringKeyword`;constructor(e={}){this.annotations=e}toString(){return Fk(this)}toJSON(){return{_tag:this._tag,annotations:Nk(this.annotations)}}},PO=new NO({[LD]:`string`,[zD]:`a string`}),FO=bO(`StringKeyword`),IO=class{annotations;_tag=`NumberKeyword`;constructor(e={}){this.annotations=e}toString(){return Fk(this)}toJSON(){return{_tag:this._tag,annotations:Nk(this.annotations)}}},LO=new IO({[LD]:`number`,[zD]:`a number`}),RO=class{annotations;_tag=`BooleanKeyword`;constructor(e={}){this.annotations=e}toString(){return Fk(this)}toJSON(){return{_tag:this._tag,annotations:Nk(this.annotations)}}},zO=new RO({[LD]:`boolean`,[zD]:`a boolean`}),BO=class{annotations;_tag=`BigIntKeyword`;constructor(e={}){this.annotations=e}toString(){return Fk(this)}toJSON(){return{_tag:this._tag,annotations:Nk(this.annotations)}}},VO=new BO({[LD]:`bigint`,[zD]:`a bigint`}),HO=class{annotations;_tag=`SymbolKeyword`;constructor(e={}){this.annotations=e}toString(){return Fk(this)}toJSON(){return{_tag:this._tag,annotations:Nk(this.annotations)}}},UO=new HO({[LD]:`symbol`,[zD]:`a symbol`}),WO=bO(`SymbolKeyword`),GO=class{type;annotations;constructor(e,t={}){this.type=e,this.annotations=t}toJSON(){return{type:this.type.toJSON(),annotations:Nk(this.annotations)}}toString(){return String(this.type)}},KO=class extends GO{isOptional;constructor(e,t,n={}){super(e,n),this.isOptional=t}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:Nk(this.annotations)}}toString(){return String(this.type)+(this.isOptional?`?`:``)}},qO=e=>e.map(e=>e.type),JO=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(lD)}toString(){return xr(Lk(this),()=>YO(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map(e=>e.toJSON()),rest:this.rest.map(e=>e.toJSON()),isReadonly:this.isReadonly,annotations:Nk(this.annotations)}}},YO=e=>{let t=e.elements.map(String).join(`, `);return Gr(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}]`}return e.elements.length>0?`readonly [${t}, ...${a}[]]`:`ReadonlyArray<${i}>`}})},XO=class extends KO{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:Nk(this.annotations)}}},ZO=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return!0;case`Refinement`:return ZO(e.from)}return!1},QO=class{type;isReadonly;parameter;constructor(e,t,n){if(this.type=t,this.isReadonly=n,ZO(e))this.parameter=e;else throw Error(cD)}toString(){return(this.isReadonly?`readonly `:``)+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}},$O=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(dD(n));r[n]=null}let i={string:!1,symbol:!1};for(let e=0;e<t.length;e++){let n=Pk(t[e].parameter);if(FO(n)){if(i.string)throw Error(sD(`string`));i.string=!0}else if(WO(n)){if(i.symbol)throw Error(sD(`symbol`));i.symbol=!0}}this.propertySignatures=e,this.indexSignatures=t}toString(){return xr(Lk(this),()=>tk(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map(e=>e.toJSON()),indexSignatures:this.indexSignatures.map(e=>e.toJSON()),annotations:Nk(this.annotations)}}},ek=e=>e.map(String).join(`; `),tk=e=>{if(e.propertySignatures.length>0){let t=e.propertySignatures.map(String).join(`; `);return e.indexSignatures.length>0?`{ ${t}; ${ek(e.indexSignatures)} }`:`{ ${t} }`}return e.indexSignatures.length>0?`{ ${ek(e.indexSignatures)} }`:`{}`},nk=pi(mr(yg,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})),rk={string:`StringKeyword`,number:`NumberKeyword`,boolean:`BooleanKeyword`,bigint:`BigIntKeyword`},ik=e=>Ti(e,e=>lk(e)?ik(e.types):[e]),ak=e=>{let t=nk(e),n=[],r={},i=[];for(let e of t)switch(e._tag){case`NeverKeyword`:break;case`AnyKeyword`:return[MO];case`UnknownKeyword`:return[AO];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[rk[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}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},ok=class e{types;annotations;static make=(t,n)=>ck(t)?new e(t,n):t.length===1?t[0]:OO;static unify=(t,n)=>e.make(ak(ik(t)),n);_tag=`Union`;constructor(e,t={}){this.types=e,this.annotations=t}toString(){return xr(Lk(this),()=>this.types.map(String).join(` | `))}toJSON(){return{_tag:this._tag,types:this.types.map(e=>e.toJSON()),annotations:Nk(this.annotations)}}},sk=(e,t)=>e.map(t),ck=e=>e.length>1,lk=bO(`Union`),uk=C(Symbol.for(`effect/Schema/AST/toJSONMemoMap`),()=>new WeakMap),dk=class{f;annotations;_tag=`Suspend`;constructor(e,t={}){this.f=e,this.annotations=t,this.f=QE(e)}toString(){return Lk(this).pipe(Sr(()=>kr(Er(this.f)(),e=>Lk(e))),xr(()=>`<suspended schema>`))}toJSON(){let e=this.f(),t=uk.get(e);return t||(uk.set(e,{_tag:this._tag}),t={_tag:this._tag,ast:e.toJSON(),annotations:Nk(this.annotations)},uk.set(e,t),t)}},fk=class{from;filter;annotations;_tag=`Refinement`;constructor(e,t,n={}){this.from=e,this.filter=t,this.annotations=n}toString(){return oO(this).pipe(xr(()=>br(Ik(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:e=>pk(this.from)?String(this.from)+` & `+e:e})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:Nk(this.annotations)}}},pk=bO(`Refinement`),mk={},hk=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 xr(Lk(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:Nk(this.annotations)}}},gk=class{decode;encode;_tag=`FinalTransformation`;constructor(e,t){this.decode=e,this.encode=t}},_k=class{from;to;decode;encode;constructor(e,t,n,r){this.from=e,this.to=t,this.decode=n,this.encode=r}},vk=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(uD(e));t[e]=!0;let i=r.to;if(n[i])throw Error(uD(i));n[i]=!0}}},yk=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={...e.annotations};delete r[ID];let i={...r,...t},a=pO(e);return yr(a)&&(i[QD]=yk(a.value,t)),n.annotations.value=i,Object.create(Object.getPrototypeOf(e),n)},bk=`[\\s\\S]*?`,xk=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`,Sk=(e,t)=>{switch(e._tag){case`Literal`:return Sg(String(e.literal));case`StringKeyword`:return bk;case`NumberKeyword`:return xk;case`TemplateLiteral`:return wk(e,t,!1);case`Union`:return e.types.map(e=>Sk(e,t)).join(`|`)}},Ck=(e,t,n,r)=>{if(lk(e)){if(n&&!r)return`(?:${t})`}else if(!n||!r)return t;return`(${t})`},wk=(e,t,n)=>{let r=``;if(e.head!==``){let i=Sg(e.head);r+=t&&n?`(${i})`:i}for(let i of e.spans){let e=Sk(i.type,t);if(r+=Ck(i.type,e,t,n),i.literal!==``){let e=Sg(i.literal);r+=t&&n?`(${e})`:e}}return r},Tk=e=>RegExp(`^${wk(e,!1,!0)}$`),Ek=(e,t)=>{let n=[],r=[],i=e=>{switch(e._tag){case`NeverKeyword`:break;case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:case`Refinement`:r.push(new QO(e,t,!0));break;case`Literal`:if(Re(e.literal)||ze(e.literal))n.push(new XO(e.literal,t,!1,!0));else throw Error(oD(e.literal));break;case`Enums`:for(let[r,i]of e.enums)n.push(new XO(i,t,!1,!0));break;case`UniqueSymbol`:n.push(new XO(e.symbol,t,!1,!0));break;case`Union`:e.types.forEach(i);break;default:throw Error(aD(e))}};return i(e),{propertySignatures:n,indexSignatures:r}},Dk=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},Ok=Dk([BD,VD,HD,UD,WD,GD]),kk=e=>{switch(e._tag){case`Declaration`:{let t=kD(e.typeParameters,kk);return t===e.typeParameters?e:new yO(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case`TupleType`:{let t=kD(e.elements,e=>{let t=kk(e.type);return t===e.type?e:new KO(t,e.isOptional)}),n=qO(e.rest),r=kD(n,kk);return t===e.elements&&r===n?e:new JO(t,r.map(e=>new GO(e)),e.isReadonly,e.annotations)}case`TypeLiteral`:{let t=kD(e.propertySignatures,e=>{let t=kk(e.type);return t===e.type?e:new XO(e.name,t,e.isOptional,e.isReadonly)}),n=kD(e.indexSignatures,e=>{let t=kk(e.type);return t===e.type?e:new QO(e.parameter,t,e.isReadonly)});return t===e.propertySignatures&&n===e.indexSignatures?e:new $O(t,n,e.annotations)}case`Union`:{let t=kD(e.types,kk);return t===e.types?e:ok.make(t,e.annotations)}case`Suspend`:return new dk(()=>kk(e.f()),e.annotations);case`Refinement`:{let t=kk(e.from);return t===e.from?e:new fk(t,e.filter,e.annotations)}case`Transformation`:{let t=Ok(e);return kk(t===void 0?e.to:yk(e.to,t))}}return e},Ak=e=>{switch(e._tag){case`Transformation`:return e.from;case`Refinement`:return Ak(e.from);case`Suspend`:return Ak(e.f())}},jk=(e,t)=>{switch(e._tag){case`Declaration`:{let n=kD(e.typeParameters,e=>jk(e,t));return n===e.typeParameters?e:new yO(n,e.decodeUnknown,e.encodeUnknown)}case`TupleType`:{let n=kD(e.elements,e=>{let n=jk(e.type,t);return n===e.type?e:new KO(n,e.isOptional)}),r=qO(e.rest),i=kD(r,e=>jk(e,t));return n===e.elements&&i===r?e:new JO(n,i.map(e=>new GO(e)),e.isReadonly)}case`TypeLiteral`:{let n=kD(e.propertySignatures,e=>{let n=jk(e.type,t);return n===e.type?e:new XO(e.name,n,e.isOptional,e.isReadonly)}),r=kD(e.indexSignatures,e=>{let n=jk(e.type,t);return n===e.type?e:new QO(e.parameter,n,e.isReadonly)});return n===e.propertySignatures&&r===e.indexSignatures?e:new $O(n,r)}case`Union`:{let n=kD(e.types,e=>jk(e,t));return n===e.types?e:ok.make(n)}case`Suspend`:{let n,r=vO(e);if(yr(r)){let e=t?`Bound`:``;n={[gO]:`${r.value}Encoded${e}`}}return new dk(()=>jk(e.f(),t),n)}case`Refinement`:{let n=jk(e.from,t);return t?n===e.from?e:Ak(e.from)===void 0&&hO(e)?new fk(n,e.filter,e.annotations):n:n}case`Transformation`:return jk(e.from,t)}return e},Mk=e=>jk(e,!1),Nk=e=>{let t={};for(let n of Object.getOwnPropertySymbols(e))t[String(n)]=e[n];return t},Pk=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return e;case`Refinement`:return Pk(e.from)}},Fk=e=>xr(Lk(e),()=>e._tag),Ik=e=>iO(e).pipe(Sr(()=>sO(e)),Sr(()=>aO(e)),Or(t=>t+AD(e))),Lk=e=>Sr(oO(e),()=>Ik(e))}));function zk(e){return e.sort(OA).map(e=>e[1])}function Bk(e){return sO(e).pipe(Sr(()=>iO(e)),Sr(()=>aO(e)),Sr(()=>oO(e)),xr(()=>`{ ${e.from} | filter }`))}function Vk(e){return e.message===void 0?`Expected ${pk(e.ast)?Bk(e.ast):String(e.ast)}, actual ${zt(e.actual)}`:e.message}var Hk,Uk,Wk,Gk,Kk,qk,Jk,Yk,Xk,Zk,Qk,$k,eA,tA,nA,rA,iA,aA,oA,sA,cA,lA,uA,dA,fA,pA,mA,hA,gA,_A,vA,yA,bA,xA,SA,CA,wA,TA,EA,DA,OA,kA,AA,jA,MA,NA,PA,FA,IA,LA,RA,zA,BA,VA,HA,UA,WA,GA,KA,qA,JA,YA,XA,ZA=v((()=>{Pi(),Gh(),I_(),jE(),lr(),zb(),S(),Ie(),Xt(),rD(),Rr(),T(),Sb(),Rk(),Hk=class{path;actual;issue;_tag=`Pointer`;constructor(e,t,n){this.path=e,this.actual=t,this.issue=n}},Uk=class{actual;message;_tag=`Unexpected`;constructor(e,t){this.actual=e,this.message=t}},Wk=class{ast;message;_tag=`Missing`;actual=void 0;constructor(e,t){this.ast=e,this.message=t}},Gk=class{ast;actual;issues;output;_tag=`Composite`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.issues=n,this.output=r}},Kk=class{ast;actual;kind;issue;_tag=`Refinement`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},qk=class{ast;actual;kind;issue;_tag=`Transformation`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},Jk=class{ast;actual;message;_tag=`Type`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}},Yk=class{ast;actual;message;_tag=`Forbidden`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}},Xk=Symbol.for(`effect/Schema/ParseErrorTypeId`),Zk=class extends F_(`ParseError`){[Xk]=Xk;get message(){return this.toString()}toString(){return jA.formatIssueSync(this.issue)}toJSON(){return{_id:`ParseError`,message:this.toString()}}[N](){return this.toJSON()}},Qk=e=>new Zk({issue:e}),$k=I,eA=L,tA=Qn,nA=Zn,rA=$n,iA=x(2,(e,t)=>rA(e)?ar(e,{onLeft:L,onRight:t}):OE(e,t)),aA=x(2,(e,t)=>rA(e)?ir(e,t):wE(e,t)),oA=x(2,(e,t)=>rA(e)?rr(e,t):EE(e,t)),sA=x(2,(e,t)=>rA(e)?nr(e,{onLeft:t.onFailure,onRight:t.onSuccess}):TE(e,t)),cA=x(2,(e,t)=>rA(e)?ar(e,{onLeft:t,onRight:I}):CE(e,t)),lA=(e,t)=>t===void 0||ze(t)?e:e===void 0?t:{...e,...t},uA=(e,t,n)=>{let r=yA(e,t);return(e,t)=>r(e,lA(n,t))},dA=(e,t,n)=>{let r=uA(e,t,n);return(e,t)=>sr(r(e,t),Qk)},fA=(e,t,n)=>{let r=yA(e,t);return(e,t)=>r(e,{...lA(n,t),isEffectAllowed:!0})},pA=(e,t)=>uA(e.ast,!0,t),mA=(e,t)=>fA(e.ast,!0,t),hA=(e,t)=>fA(e.ast,!1,t),gA=(e,t)=>dA(kk(e.ast),!0,t),_A=C(Symbol.for(`effect/ParseResult/decodeMemoMap`),()=>new WeakMap),vA=C(Symbol.for(`effect/ParseResult/encodeMemoMap`),()=>new WeakMap),yA=(e,t)=>{let n=t?_A:vA,r=n.get(e);if(r)return r;let i=SA(e,t),a=dO(e),o=yr(a)?(e,t)=>i(e,lA(t,a.value)):i,s=fO(e),c=t&&yr(s)?(t,n)=>DA(cA(o(t,n),s.value),e,t,n):o;return n.set(e,c),c},bA=e=>Tr(cO(e)),xA=e=>Tr(lO(e)),SA=(e,t)=>{switch(e._tag){case`Refinement`:if(t){let t=yA(e.from,!0);return(n,r)=>{r??=mk;let i=r?.errors===`all`,a=iA(cA(t(n,r),t=>{let a=new Kk(e,n,`From`,t);return i&&hO(e)&&BA(t)?br(e.filter(n,r,e),{onNone:()=>L(a),onSome:t=>L(new Gk(e,n,[a,new Kk(e,n,`Predicate`,t)]))}):L(a)}),t=>br(e.filter(t,r,e),{onNone:()=>I(t),onSome:t=>L(new Kk(e,n,`Predicate`,t))}));return DA(a,e,n,r)}}{let t=yA(kk(e),!0),n=yA(EA(e.from),!1);return(r,i)=>DA(iA(t(r,i),e=>n(e,i)),e,r,i)}case`Transformation`:{let n=kA(e.transformation,t),r=t?yA(e.from,!0):yA(e.to,!1),i=t?yA(e.to,!0):yA(e.from,!1);return(a,o)=>DA(iA(oA(r(a,o),n=>new qk(e,a,t?`Encoded`:`Type`,n)),r=>iA(oA(n(r,o??mk,e,a),t=>new qk(e,a,`Transformation`,t)),n=>oA(i(n,o),n=>new qk(e,a,t?`Type`:`Encoded`,n)))),e,a,o)}case`Declaration`:{let n=t?e.decodeUnknown(...e.typeParameters):e.encodeUnknown(...e.typeParameters);return(t,r)=>DA(n(t,r??mk,e),e,t,r)}case`Literal`:return CA(e,t=>t===e.literal);case`UniqueSymbol`:return CA(e,t=>t===e.symbol);case`UndefinedKeyword`:return CA(e,We);case`NeverKeyword`:return CA(e,Ge);case`UnknownKeyword`:case`AnyKeyword`:case`VoidKeyword`:return I;case`StringKeyword`:return CA(e,Re);case`NumberKeyword`:return CA(e,ze);case`BooleanKeyword`:return CA(e,Be);case`BigIntKeyword`:return CA(e,Ve);case`SymbolKeyword`:return CA(e,He);case`ObjectKeyword`:return CA(e,qe);case`Enums`:return CA(e,t=>e.enums.some(([e,n])=>n===t));case`TemplateLiteral`:{if(e.spans.every(e=>FO(e.type)))return CA(e,t=>{if(!Re(t)||!t.startsWith(e.head))return!1;let n=e.head.length;for(let r=0;r<e.spans.length-1;r++){let i=e.spans[r].literal,a=t.indexOf(i,n);if(a===-1)return!1;n=a+i.length}let r=e.spans[e.spans.length-1].literal;return t.endsWith(r)&&t.length-r.length>=n});let t=Tk(e);return CA(e,e=>Re(e)&&t.test(e))}case`TupleType`:{let n=e.elements.map(e=>yA(e.type,t)),r=e.rest.map(e=>yA(e.type,t)),i=e.elements.filter(e=>!e.isOptional);e.rest.length>0&&(i=i.concat(e.rest.slice(1)));let a=i.length,o=e.elements.length>0?e.elements.map((e,t)=>t).join(` | `):`never`,s=bA(e),c=xA(e);return(t,l)=>{if(!Yr(t))return L(new Jk(e,t));let u=l?.errors===`all`,d=[],f=0,p=[],m=t.length;for(let n=m;n<=a-1;n++){let r=new Hk(n,t,new Wk(i[n-m]));if(u){d.push([f++,r]);continue}return L(new Gk(e,t,r,p))}if(e.rest.length===0)for(let n=e.elements.length;n<=m-1;n++){let r=new Hk(n,t,new Uk(t[n],`is unexpected, expected: ${o}`));if(u){d.push([f++,r]);continue}return L(new Gk(e,t,r,p))}let h=0,g;for(;h<n.length;h++)if(m<h+1){if(e.elements[h].isOptional)continue}else{let r=n[h],i=r(t[h],l);if(rA(i)){if(er(i)){let n=new Hk(h,t,i.left);if(u){d.push([f++,n]);continue}return L(new Gk(e,t,n,zk(p)))}p.push([f++,i.right])}else{let n=f++,r=h;g||=[],g.push(({es:a,output:o})=>OE(DE(i),i=>{if(er(i)){let s=new Hk(r,t,i.left);return u?(a.push([n,s]),SE):L(new Gk(e,t,s,zk(o)))}return o.push([n,i.right]),SE}))}}if($r(r)){let[n,...i]=r;for(;h<m-i.length;h++){let r=n(t[h],l);if(rA(r)){if(er(r)){let n=new Hk(h,t,r.left);if(u){d.push([f++,n]);continue}return L(new Gk(e,t,n,zk(p)))}p.push([f++,r.right])}else{let n=f++,i=h;g||=[],g.push(({es:a,output:o})=>OE(DE(r),r=>{if(er(r)){let s=new Hk(i,t,r.left);return u?(a.push([n,s]),SE):L(new Gk(e,t,s,zk(o)))}return o.push([n,r.right]),SE}))}}for(let n=0;n<i.length;n++){let r=h+n;if(!(m<r+1)){let a=i[n](t[r],l);if(rA(a)){if(er(a)){let n=new Hk(r,t,a.left);if(u){d.push([f++,n]);continue}return L(new Gk(e,t,n,zk(p)))}p.push([f++,a.right])}else{let n=f++;g||=[],g.push(({es:i,output:o})=>OE(DE(a),a=>{if(er(a)){let s=new Hk(r,t,a.left);return u?(i.push([n,s]),SE):L(new Gk(e,t,s,zk(o)))}return o.push([n,a.right]),SE}))}}}}let _=({es:n,output:r})=>Qr(n)?L(new Gk(e,t,zk(n),zk(r))):I(zk(r));if(g&&g.length>0){let e=g;return xE(()=>{let t={es:yi(d),output:yi(p)};return OE(bE(e,e=>e(t),{concurrency:s,batching:c,discard:!0}),()=>_(t))})}return _({output:p,es:d})}}case`TypeLiteral`:{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return CA(e,Xe);let n=[],r={},i=[];for(let a of e.propertySignatures)n.push([yA(a.type,t),a]),r[a.name]=null,i.push(a.name);let a=e.indexSignatures.map(e=>[yA(e.parameter,t),yA(e.type,t),e.parameter]),o=ok.make(e.indexSignatures.map(e=>e.parameter).concat(i.map(e=>He(e)?new wO(e):new xO(e)))),s=yA(o,t),c=bA(e),l=xA(e);return(t,u)=>{if(!et(t))return L(new Jk(e,t));let d=u?.errors===`all`,f=[],p=0,m=u?.onExcessProperty===`error`,h=u?.onExcessProperty===`preserve`,g={},_;if(m||h){_=Reflect.ownKeys(t);for(let n of _){let r=s(n,u);if(rA(r)&&er(r)){if(m){let r=new Hk(n,t,new Uk(t[n],`is unexpected, expected: ${String(o)}`));if(d){f.push([p++,r]);continue}return L(new Gk(e,t,r,g))}g[n]=t[n]}}}let ee,te=u?.exact===!0;for(let r=0;r<n.length;r++){let i=n[r][1],a=i.name,o=Object.prototype.hasOwnProperty.call(t,a);if(!o){if(i.isOptional)continue;if(te){let n=new Hk(a,t,new Wk(i));if(d){f.push([p++,n]);continue}return L(new Gk(e,t,n,g))}}let s=n[r][0],c=s(t[a],u);if(rA(c)){if(er(c)){let n=new Hk(a,t,o?c.left:new Wk(i));if(d){f.push([p++,n]);continue}return L(new Gk(e,t,n,g))}g[a]=c.right}else{let n=p++,r=a;ee||=[],ee.push(({es:a,output:s})=>OE(DE(c),c=>{if(er(c)){let l=new Hk(r,t,o?c.left:new Wk(i));return d?(a.push([n,l]),SE):L(new Gk(e,t,l,s))}return s[r]=c.right,SE}))}}for(let n=0;n<a.length;n++){let i=a[n],o=i[0],s=i[1],c=ZE(t,i[2]);for(let n of c){let i=o(n,u);if(rA(i)&&tr(i)){let i=s(t[n],u);if(rA(i)){if(er(i)){let r=new Hk(n,t,i.left);if(d){f.push([p++,r]);continue}return L(new Gk(e,t,r,g))}Object.prototype.hasOwnProperty.call(r,n)||(g[n]=i.right)}else{let a=p++,o=n;ee||=[],ee.push(({es:s,output:c})=>OE(DE(i),i=>{if(er(i)){let n=new Hk(o,t,i.left);return d?(s.push([a,n]),SE):L(new Gk(e,t,n,c))}return Object.prototype.hasOwnProperty.call(r,n)||(c[n]=i.right),SE}))}}}}let ne=({es:n,output:r})=>{if(Qr(n))return L(new Gk(e,t,zk(n),r));if(u?.propertyOrder===`original`){let e=_||Reflect.ownKeys(t);for(let t of i)e.indexOf(t)===-1&&e.push(t);let n={};for(let t of e)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t]);return I(n)}return I(r)};if(ee&&ee.length>0){let e=ee;return xE(()=>{let t={es:yi(f),output:Object.assign({},g)};return OE(bE(e,e=>e(t),{concurrency:c,batching:l,discard:!0}),()=>ne(t))})}return ne({es:f,output:g})}}case`Union`:{let n=TA(e.types,t),r=Reflect.ownKeys(n.keys),i=r.length,a=e.types.length,o=new Map;for(let n=0;n<a;n++)o.set(e.types[n],yA(e.types[n],t));let s=bA(e)??1,c=xA(e);return(t,l)=>{let u=[],d=0,f=[];if(i>0){if(Ke(t))for(let e=0;e<i;e++){let i=r[e],o=n.keys[i].buckets;if(Object.prototype.hasOwnProperty.call(t,i)){let e=String(t[i]);if(Object.prototype.hasOwnProperty.call(o,e))f=f.concat(o[e]);else{let{candidates:e,literals:r}=n.keys[i],o=ok.make(r),s=e.length===a?new $O([new XO(i,o,!1,!0)],[]):ok.make(e);u.push([d++,new Gk(s,t,new Hk(i,t,new Jk(o,t[i])))])}}else{let{candidates:e,literals:r}=n.keys[i],o=new XO(i,ok.make(r),!1,!0),s=e.length===a?new $O([o],[]):ok.make(e);u.push([d++,new Gk(s,t,new Hk(i,t,new Wk(o)))])}}else{let r=n.candidates.length===a?e:ok.make(n.candidates);u.push([d++,new Jk(r,t)])}}n.otherwise.length>0&&(f=f.concat(n.otherwise));let p;for(let e=0;e<f.length;e++){let n=f[e],r=o.get(n)(t,l);if(rA(r)&&(!p||p.length===0)){if(tr(r))return r;u.push([d++,r.left])}else{let e=d++;p||=[],p.push(t=>xE(()=>`finalResult`in t?SE:OE(DE(r),n=>(tr(n)?t.finalResult=n:t.es.push([e,n.left]),SE))))}}let m=n=>Qr(n)?n.length===1&&n[0][1]._tag===`Type`?L(n[0][1]):L(new Gk(e,t,zk(n))):L(new Jk(e,t));if(p&&p.length>0){let e=p;return xE(()=>{let t={es:yi(u)};return OE(bE(e,e=>e(t),{concurrency:s,batching:c,discard:!0}),()=>`finalResult`in t?t.finalResult:m(t.es))})}return m(u)}}case`Suspend`:{let n=QE(()=>yA(e.f(),t));return(e,t)=>n()(e,t)}}},CA=(e,t)=>n=>t(n)?I(n):L(new Jk(e,n)),wA=(e,t)=>{switch(e._tag){case`Declaration`:{let n=pO(e);if(yr(n))return wA(n.value,t);break}case`TypeLiteral`:{let n=[];for(let r=0;r<e.propertySignatures.length;r++){let i=e.propertySignatures[r],a=t?Mk(i.type):kk(i.type);SO(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?Mk(i.type):kk(i.type);SO(a)&&!i.isOptional&&n.push([r,a])}return n}case`Refinement`:return wA(e.from,t);case`Suspend`:return wA(e.f(),t);case`Transformation`:return wA(t?e.from:e.to,t)}return[]},TA=(e,t)=>{let n={},r=[],i=[];for(let a=0;a<e.length;a++){let o=e[a],s=wA(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}},EA=e=>pk(e)?EA(e.from):e,DA=(e,t,n,r)=>{if(r?.isEffectAllowed===!0||rA(e))return e;let i=new bb,a=kE(e,{scheduler:i});i.flush();let o=a.unsafePoll();if(o){if(Rb(o))return I(o.value);let e=o.cause;return Hh(e)?L(e.error):L(new Yk(t,n,Wh(e)))}return L(new Yk(t,n,`cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work`))},OA=([e],[t])=>e>t?1:e<t?-1:0,kA=(e,t)=>{switch(e._tag){case`FinalTransformation`:return t?e.decode:e.encode;case`ComposeTransformation`:return I;case`TypeLiteralTransformation`:return n=>{let r=I(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=aA(r,t=>{let n=a(Object.prototype.hasOwnProperty.call(t,e)?z(t[e]):R());return delete t[e],yr(n)&&(t[i]=n.value),t})}return r}}},AA=(e,t=[])=>({value:e,forest:t}),jA={formatIssue:e=>aA(XA(e),MA),formatIssueSync:e=>{let t=jA.formatIssue(e);return rA(t)?cr(t):AE(t)},formatError:e=>jA.formatIssue(e.issue),formatErrorSync:e=>jA.formatIssueSync(e.issue)},MA=e=>e.value+NA(`
|
|
21
|
-
`,e.forest),NA=(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+=NA(e+(r>1&&!o?`│ `:` `),i.forest)}return n},PA=e=>{switch(e){case`Encoded`:return`Encoded side transformation failure`;case`Transformation`:return`Transformation process failure`;case`Type`:return`Type side transformation failure`}},FA=e=>{switch(e){case`From`:return`From side refinement failure`;case`Predicate`:return`Predicate refinement failure`}},IA=e=>`ast`in e?z(e.ast):R(),LA=I(void 0),RA=e=>IA(e).pipe(kr(nO),br({onNone:()=>LA,onSome:t=>{let n=t(e);return Re(n)?I({message:n,override:!1}):yE(n)?wE(n,e=>({message:e,override:!1})):Re(n.message)?I({message:n.message,override:n.override}):wE(n.message,e=>({message:e,override:n.override}))}})),zA=e=>t=>t._tag===e,BA=zA(`Composite`),VA=zA(`Refinement`),HA=zA(`Transformation`),UA=e=>iA(RA(e),t=>t===void 0?LA:!t.override&&(BA(e)||VA(e)&&e.kind===`From`||HA(e)&&e.kind!==`Transformation`)?HA(e)||VA(e)?UA(e.issue):LA:I(t.message)),WA=e=>IA(e).pipe(kr(uO),Ar(t=>t(e)),Tr),GA=e=>aA(UA(e),t=>t??WA(e)??Vk(e)),KA=e=>WA(e)??String(e.ast),qA=e=>e.message??`is forbidden`,JA=e=>e.message??`is unexpected`,YA=e=>{let t=rO(e.ast);if(yr(t)){let e=t.value();return Re(e)?I(e):e}return I(e.message??`is missing`)},XA=e=>{switch(e._tag){case`Type`:return aA(GA(e),AA);case`Forbidden`:return I(AA(KA(e),[AA(qA(e))]));case`Unexpected`:return I(AA(JA(e)));case`Missing`:return aA(YA(e),AA);case`Transformation`:return iA(UA(e),t=>t===void 0?aA(XA(e.issue),t=>AA(KA(e),[AA(PA(e.kind),[t])])):I(AA(t)));case`Refinement`:return iA(UA(e),t=>t===void 0?aA(XA(e.issue),t=>AA(KA(e),[AA(FA(e.kind),[t])])):I(AA(t)));case`Pointer`:return aA(XA(e.issue),t=>AA(nD(e.path),[t]));case`Composite`:return iA(UA(e),t=>{if(t!==void 0)return I(AA(t));let n=KA(e);return $E(e.issues)?aA(bE(e.issues,XA),e=>AA(n,e)):aA(XA(e.issues),e=>AA(n,[e]))})}}})),QA,$A,ej=v((()=>{S(),T(),QA=x(e=>qe(e[0]),(e,...t)=>{let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}),$A=x(e=>qe(e[0]),(e,...t)=>{let n={...e};for(let e of t)delete n[e];return n})}));function tj(e){return class{[_j]=vj;static ast=e;static annotations(e){return tj(xj(this.ast,e))}static pipe(){return P(this,arguments)}static toString(){return String(e)}static Type;static Encoded;static Context;static[_j]=vj}}function nj(e){return ck(e)?ok.make(sk(e,e=>new xO(e))):new xO(e[0])}function rj(e,t=nj(e)){return class extends tj(t){static annotations(e){return rj(this.literals,xj(this.ast,e))}static literals=[...e]}}function H(...e){return $r(e)?rj(e):jj}function ij(e,t){return class extends tj(t){static annotations(e){return ij(this.typeParameters,xj(this.ast,e))}static typeParameters=[...e]}}function aj(e,t=Ij(e)){return class extends tj(t){static annotations(e){return aj(this.members,xj(this.ast,e))}static members=[...e]}}function U(...e){return ck(e)?aj(e):$r(e)?e[0]:jj}function oj(e,t,n=Bj(e,t)){return class extends tj(n){static annotations(e){return oj(this.elements,this.rest,xj(this.ast,e))}static elements=[...e];static rest=[...t]}}function sj(...e){return Array.isArray(e[0])?oj(e[0],e.slice(1)):oj(e,[])}function cj(e,t){return class extends oj([],[e],t){static annotations(e){return cj(this.value,xj(this.ast,e))}static value=e}}function lj(e,t,n=nM(e,t)){return class extends tj(n){static annotations(e){return lj(this.fields,this.records,xj(this.ast,e))}static fields={...e};static records=[...t];static make=(t,n)=>{let r=rM(e,{...t});return gj(n)?r:gA(this)(r)};static pick(...t){return W(QA(e,...t))}static omit(...t){return W($A(e,...t))}}}function W(e,...t){return lj(e,t)}function uj(e,t,n){return class extends lj({},[{key:e,value:t}],n){static annotations(n){return uj(e,t,xj(this.ast,n))}static key=e;static value=t}}function dj(e,t){return class extends tj(t){static annotations(e){return dj(this.from,xj(this.ast,e))}static make=(e,t)=>gj(t)?e:gA(this)(e);static from=e}}function fj(e,t,n){return class extends tj(n){static annotations(e){return fj(this.from,this.filter,xj(this.ast,e))}static[lM]=e;static from=e;static filter=t;static make=(e,t)=>gj(t)?e:gA(this)(e)}}function pj(e,t){return n=>{function r(t,n,r){return dM(e(t,n,r),r,t)}return fj(n,r,new fk(n.ast,r,bj(t)))}}function mj(e,t,n){return class extends tj(n){static annotations(e){return mj(this.from,this.to,xj(this.ast,e))}static from=e;static to=t}}function hj(e){return fM(e,Fj,{strict:!1,decode:(e,t,n)=>nA(bg(e),()=>new Jk(n,e,`Unable to decode ${JSON.stringify(e)} into a number`)),encode:e=>$k(String(e))})}function gj(e){return Be(e)?e:e?.disableValidation??!1}var _j,vj,yj,bj,xj,Sj,Cj,wj,Tj,Ej,G,Dj,Oj,kj,Aj,jj,Mj,Nj,Pj,K,Fj,q,Ij,Lj,Rj,zj,Bj,Vj,Hj,Uj,Wj,Gj,Kj,qj,Jj,Yj,Xj,Zj,Qj,$j,eM,J,tM,nM,rM,iM,aM,oM,sM,cM,lM,uM,dM,fM,pM,mM,hM,gM,_M,vM,yM,bM,xM,SM,CM,wM,TM,EM,DM,OM,kM,AM,jM,MM,NM,PM,FM,IM,LM,RM,zM,BM,VM,HM,UM,WM,GM,KM,qM,JM,YM,XM,ZM,QM,$M,eN,tN,nN,rN,iN,aN,oN,sN,cN,lN,uN,dN,fN,pN,mN,hN,gN,_N,vN,yN,bN,xN,SN,CN,wN,TN,EN,DN,ON,kN,AN,jN,MN,NN,PN,FN,IN,LN,RN,zN,BN,VN,HN,UN,WN,GN,KN,qN,JN,YN,XN,ZN,QN,$N,eP,tP,nP,rP,iP,aP,oP,sP,cP,lP,uP,dP,fP,pP=v((()=>{Pi(),ra(),sa(),la(),XE(),Ul(),lr(),M(),Ne(),bu(),S(),Xt(),bc(),OD(),rD(),xg(),Rr(),ZA(),F(),T(),Rk(),vE(),ej(),_j=Symbol.for(`effect/Schema`),vj={_A:e=>e,_I:e=>e,_R:e=>e},yj={typeConstructor:jD,schemaId:ND,message:PD,missingMessage:FD,identifier:ID,title:LD,description:zD,examples:BD,default:VD,documentation:KD,jsonSchema:HD,arbitrary:UD,pretty:WD,equivalence:GD,concurrency:qD,batching:JD,parseIssueTitle:YD,parseOptions:XD,decodingFallback:ZD},bj=e=>{if(!e)return{};let t={...e};for(let n in yj)if(n in e){let r=yj[n];t[r]=e[n],delete t[n]}return t},xj=(e,t)=>yk(e,bj(t)),Sj=e=>String(e.ast),Cj=(e,t)=>{let n=pA(e,t);return(e,t)=>rr(n(e,t),Qk)},wj=e=>w(e,_j)&&qe(e[_j]),Tj=(e,t,n)=>ij(e,new yO(e.map(e=>e.ast),(...e)=>t.decode(...e.map(tj)),(...e)=>t.encode(...e.map(tj)),bj(n))),Ej=(e,t)=>{let n=()=>(t,n,r)=>e(t)?$k(t):eA(new Jk(r,t));return ij([],new yO([],n,n,bj(t)))},G=function(){if(Array.isArray(arguments[0])){let e=arguments[0],t=arguments[1],n=arguments[2];return Tj(e,t,n)}let e=arguments[0],t=arguments[1];return Ej(e,t)},Dj=Symbol.for(`effect/SchemaId/InstanceOf`),Oj=(e,t)=>G(t=>t instanceof e,{title:e.name,description:`an instance of ${e.name}`,pretty:()=>String,schemaId:Dj,[Dj]:{constructor:e},...t}),kj=class extends tj(EO){},Aj=class extends tj(CO){},jj=class extends tj(OO){},Mj=class extends tj(AO){},Nj=class extends tj(VO){},Pj=class extends tj(UO){},K=class extends tj(PO){},Fj=class extends tj(LO){},q=class extends tj(zO){},Ij=e=>ok.make(e.map(e=>e.ast)),Lj=e=>U(e,kj),Rj=e=>new zj(new KO(e.ast,!1),e),zj=class e{ast;from;[_j];_Token;constructor(e,t){this.ast=e,this.from=t}annotations(t){return new e(new KO(this.ast.type,this.ast.isOptional,{...this.ast.annotations,...bj(t)}),this.from)}toString(){return`${this.ast.type}${this.ast.isOptional?`?`:``}`}},Bj=(e,t)=>new JO(e.map(e=>wj(e)?new KO(e.ast,!1):e.ast),t.map(e=>wj(e)?new GO(e.ast):e.ast),!0),Vj=e=>cj(e),Hj=e=>e?`"?:"`:`":"`,Uj=class extends KO{isReadonly;defaultValue;_tag=`PropertySignatureDeclaration`;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.defaultValue=i}toString(){let e=Hj(this.isOptional),t=String(this.type);return`PropertySignature<${e}, ${t}, never, ${e}, ${t}>`}},Wj=class extends KO{isReadonly;defaultValue;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.defaultValue=i}},Gj=e=>e===void 0?`never`:Re(e)?JSON.stringify(e):String(e),Kj=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<${Hj(this.to.isOptional)}, ${this.to.type}, ${Gj(this.from.fromKey)}, ${Hj(this.from.isOptional)}, ${this.from.type}>`}},qj=(e,t)=>{switch(e._tag){case`PropertySignatureDeclaration`:return new Uj(e.type,e.isOptional,e.isReadonly,{...e.annotations,...t},e.defaultValue);case`PropertySignatureTransformation`:return new Kj(e.from,new Wj(e.to.type,e.to.isOptional,e.to.isReadonly,{...e.to.annotations,...t},e.to.defaultValue),e.decode,e.encode)}},Jj=Symbol.for(`effect/PropertySignature`),Yj=e=>w(e,Jj),Xj=class e{ast;[_j];[Jj]=null;_TypeToken;_Key;_EncodedToken;_HasDefault;constructor(e){this.ast=e}pipe(){return P(this,arguments)}annotations(t){return new e(qj(this.ast,bj(t)))}toString(){return String(this.ast)}},Zj=e=>new Xj(e),Qj=class e extends Xj{from;constructor(e,t){super(e),this.from=t}annotations(t){return new e(qj(this.ast,bj(t)),this.from)}},$j=e=>new Qj(new Uj(e.ast,!1,!0,{},void 0),e),eM=x(2,(e,t)=>{let n=e.ast;switch(n._tag){case`PropertySignatureDeclaration`:return Zj(new Uj(n.type,n.isOptional,n.isReadonly,n.annotations,t));case`PropertySignatureTransformation`:return Zj(new Kj(n.from,new Wj(n.to.type,n.to.isOptional,n.to.isReadonly,n.to.annotations,t),n.decode,n.encode))}}),J=e=>{let t=e.ast===EO||e.ast===OO?EO:Lj(e).ast;return new Qj(new Uj(t,!0,!0,{},void 0),e)},tM=Dk([FD]),nM=(e,t)=>{let n=Reflect.ownKeys(e),r=[];if(n.length>0){let i=[],a=[],o=[];for(let t=0;t<n.length;t++){let s=n[t],c=e[s];if(Yj(c)){let e=c.ast;switch(e._tag){case`PropertySignatureDeclaration`:{let t=e.type,n=e.isOptional,o=e.annotations;i.push(new XO(s,t,n,!0,tM(e))),a.push(new XO(s,kk(t),n,!0,o)),r.push(new XO(s,t,n,!0,o));break}case`PropertySignatureTransformation`:{let t=e.from.fromKey??s;i.push(new XO(t,e.from.type,e.from.isOptional,!0,e.from.annotations)),a.push(new XO(s,e.to.type,e.to.isOptional,!0,e.to.annotations)),o.push(new _k(t,s,e.decode,e.encode));break}}}else i.push(new XO(s,c.ast,!1,!0)),a.push(new XO(s,kk(c.ast),!1,!0)),r.push(new XO(s,c.ast,!1,!0))}if($r(o)){let e=[],n=[];for(let r of t){let{indexSignatures:t,propertySignatures:o}=Ek(r.key.ast,r.value.ast);o.forEach(e=>{i.push(e),a.push(new XO(e.name,kk(e.type),e.isOptional,e.isReadonly,e.annotations))}),t.forEach(t=>{e.push(t),n.push(new QO(t.parameter,kk(t.type),t.isReadonly))})}return new hk(new $O(i,e,{[RD]:`Struct (Encoded side)`}),new $O(a,n,{[RD]:`Struct (Type side)`}),new vk(o))}}let i=[];for(let e of t){let{indexSignatures:t,propertySignatures:n}=Ek(e.key.ast,e.value.ast);n.forEach(e=>r.push(e)),t.forEach(e=>i.push(e))}return new $O(r,i)},rM=(e,t)=>{let n=Reflect.ownKeys(e);for(let r of n){let n=e[r];if(t[r]===void 0&&Yj(n)){let e=n.ast,i=e._tag===`PropertySignatureDeclaration`?e.defaultValue:e.to.defaultValue;i!==void 0&&(t[r]=i())}}return t},iM=e=>H(e).pipe($j,eM(()=>e)),aM=(e,t)=>W({_tag:iM(e),...t}),oM=e=>uj(e.key,e.value),sM=(e,t)=>n=>{let r=br(tO(n.ast),{onNone:()=>[e],onSome:t=>[...t,e]});return dj(n,yk(n.ast,bj({[MD]:r,...t})))},cM=e=>tj(new dk(()=>e().ast)),lM=Symbol.for(`effect/SchemaId/Refine`),uM=(e,t,n)=>{if(Be(e))return e?R():z(new Jk(t,n));if(Re(e))return z(new Jk(t,n,e));if(e!==void 0){if(`_tag`in e)return z(e);let r=new Jk(t,n,e.message);return z($r(e.path)?new Hk(e.path,n,r):r)}return R()},dM=(e,t,n)=>{if(eD(e))return uM(e,t,n);if($r(e)){let r=Di(e,e=>uM(e,t,n));if($r(r))return z(r.length===1?r[0]:new Gk(t,n,r))}return R()},fM=x(e=>wj(e[0])&&wj(e[1]),(e,t,n)=>mj(e,t,new hk(e.ast,t.ast,new gk(n.decode,n.encode)))),pM=x(e=>wj(e[0])&&wj(e[1]),(e,t,n)=>fM(e,t,{strict:!0,decode:(e,t,r,i)=>$k(n.decode(e,i)),encode:(e,t,r,i)=>$k(n.encode(e,i))})),mM=Symbol.for(`effect/SchemaId/Trimmed`),hM=e=>t=>t.pipe(pj(e=>e===e.trim(),{schemaId:mM,title:`trimmed`,description:`a string with no leading or trailing whitespace`,jsonSchema:{pattern:`^\\S[\\s\\S]*\\S$|^\\S$|^$`},...e})),gM=ED,_M=(e,t)=>n=>n.pipe(pj(t=>t.length<=e,{schemaId:gM,title:`maxLength(${e})`,description:`a string at most ${e} character(s) long`,jsonSchema:{maxLength:e},...t})),vM=TD,yM=(e,t)=>n=>n.pipe(pj(t=>t.length>=e,{schemaId:vM,title:`minLength(${e})`,description:`a string at least ${e} character(s) long`,jsonSchema:{minLength:e},...t})),bM=DD,xM=(e,t)=>n=>{let r=qe(e)?Math.max(0,Math.floor(e.min)):Math.max(0,Math.floor(e)),i=qe(e)?Math.max(r,Math.floor(e.max)):r;return r===i?n.pipe(pj(e=>e.length===r,{schemaId:bM,title:`length(${r})`,description:r===1?`a single character`:`a string ${r} character(s) long`,jsonSchema:{minLength:r,maxLength:r},...t})):n.pipe(pj(e=>e.length>=r&&e.length<=i,{schemaId:bM,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}))},SM=Symbol.for(`effect/SchemaId/Pattern`),CM=(e,t)=>n=>{let r=e.source;return n.pipe(pj(t=>(e.lastIndex=0,e.test(t)),{schemaId:SM,[SM]:{regex:e},description:`a string matching the pattern ${r}`,jsonSchema:{pattern:r},...t}))},wM=Symbol.for(`effect/SchemaId/Lowercased`),TM=e=>t=>t.pipe(pj(e=>e===e.toLowerCase(),{schemaId:wM,title:`lowercased`,description:`a lowercase string`,jsonSchema:{pattern:`^[^A-Z]*$`},...e})),EM=class extends K.pipe(TM({identifier:`Lowercased`})){},DM=Symbol.for(`effect/SchemaId/Uppercased`),OM=e=>t=>t.pipe(pj(e=>e===e.toUpperCase(),{schemaId:DM,title:`uppercased`,description:`an uppercase string`,jsonSchema:{pattern:`^[^a-z]*$`},...e})),kM=class extends K.pipe(OM({identifier:`Uppercased`})){},AM=Symbol.for(`effect/SchemaId/Capitalized`),jM=e=>t=>t.pipe(pj(e=>e[0]?.toUpperCase()===e[0],{schemaId:AM,title:`capitalized`,description:`a capitalized string`,jsonSchema:{pattern:`^[^a-z]?.*$`},...e})),MM=class extends K.pipe(jM({identifier:`Capitalized`})){},NM=Symbol.for(`effect/SchemaId/Uncapitalized`),PM=e=>t=>t.pipe(pj(e=>e[0]?.toLowerCase()===e[0],{schemaId:NM,title:`uncapitalized`,description:`a uncapitalized string`,jsonSchema:{pattern:`^[^A-Z]?.*$`},...e})),FM=class extends K.pipe(PM({identifier:`Uncapitalized`})){},K.pipe(xM(1,{identifier:`Char`})),IM=e=>yM(1,{title:`nonEmptyString`,description:`a non empty string`,...e}),pM(K.annotations({description:`a string that will be converted to lowercase`}),EM,{strict:!0,decode:e=>e.toLowerCase(),encode:be}).annotations({identifier:`Lowercase`}),pM(K.annotations({description:`a string that will be converted to uppercase`}),kM,{strict:!0,decode:e=>e.toUpperCase(),encode:be}).annotations({identifier:`Uppercase`}),pM(K.annotations({description:`a string that will be converted to a capitalized format`}),MM,{strict:!0,decode:e=>hE(e),encode:be}).annotations({identifier:`Capitalize`}),pM(K.annotations({description:`a string that will be converted to an uncapitalized format`}),FM,{strict:!0,decode:e=>gE(e),encode:be}).annotations({identifier:`Uncapitalize`}),LM=class extends K.pipe(hM({identifier:`Trimmed`})){},RM=class extends LM.pipe(IM({identifier:`NonEmptyTrimmedString`})){},pM(K.annotations({description:`a string that will be trimmed`}),LM,{strict:!0,decode:e=>e.trim(),encode:be}).annotations({identifier:`Trim`}),zM=e=>e instanceof Error?e.message:String(e),K.pipe(IM({identifier:`NonEmptyString`})),BM=Symbol.for(`effect/SchemaId/UUID`),VM=/^[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(CM(VM,{schemaId:BM,identifier:`UUID`,jsonSchema:{format:`uuid`,pattern:VM.source},description:`a Universally Unique Identifier`,arbitrary:()=>e=>e.uuid()})),HM=Symbol.for(`effect/SchemaId/ULID`),UM=/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i,K.pipe(CM(UM,{schemaId:HM,identifier:`ULID`,description:`a Universally Unique Lexicographically Sortable Identifier`,arbitrary:()=>e=>e.ulid()})),WM=class extends Oj(URL,{typeConstructor:{_tag:`URL`},identifier:`URLFromSelf`,arbitrary:()=>e=>e.webUrl().map(e=>new URL(e)),pretty:()=>e=>e.toString()}){},fM(K.annotations({description:`a string to be decoded into a URL`}),WM,{strict:!0,decode:(e,t,n)=>tA({try:()=>new URL(e),catch:t=>new Jk(n,e,`Unable to decode ${JSON.stringify(e)} into a URL. ${zM(t)}`)}),encode:e=>$k(e.toString())}).annotations({identifier:`URL`,pretty:()=>e=>e.toString()}),GM=bD,KM=e=>t=>t.pipe(pj(Number.isFinite,{schemaId:GM,title:`finite`,description:`a finite number`,jsonSchema:{},...e})),qM=mD,JM=(e,t)=>n=>n.pipe(pj(t=>t>e,{schemaId:qM,title:`greaterThan(${e})`,description:e===0?`a positive number`:`a number greater than ${e}`,jsonSchema:{exclusiveMinimum:e},...t})),YM=hD,XM=(e,t)=>n=>n.pipe(pj(t=>t>=e,{schemaId:YM,title:`greaterThanOrEqualTo(${e})`,description:e===0?`a non-negative number`:`a number greater than or equal to ${e}`,jsonSchema:{minimum:e},...t})),ZM=vD,QM=e=>t=>t.pipe(pj(e=>Number.isSafeInteger(e),{schemaId:ZM,title:`int`,description:`an integer`,jsonSchema:{type:`integer`},...e})),$M=gD,eN=(e,t)=>n=>n.pipe(pj(t=>t<e,{schemaId:$M,title:`lessThan(${e})`,description:e===0?`a negative number`:`a number less than ${e}`,jsonSchema:{exclusiveMaximum:e},...t})),tN=_D,nN=(e,t)=>n=>n.pipe(pj(t=>t<=e,{schemaId:tN,title:`lessThanOrEqualTo(${e})`,description:e===0?`a non-positive number`:`a number less than or equal to ${e}`,jsonSchema:{maximum:e},...t})),rN=SD,iN=(e,t,n)=>r=>r.pipe(pj(n=>n>=e&&n<=t,{schemaId:rN,title:`between(${e}, ${t})`,description:`a number between ${e} and ${t}`,jsonSchema:{minimum:e,maximum:t},...n})),aN=yD,oN=e=>t=>t.pipe(pj(e=>!Number.isNaN(e),{schemaId:aN,title:`nonNaN`,description:`a number excluding NaN`,...e})),sN=e=>JM(0,{title:`positive`,...e}),cN=e=>eN(0,{title:`negative`,...e}),lN=e=>nN(0,{title:`nonPositive`,...e}),uN=e=>XM(0,{title:`nonNegative`,...e}),hj(K.annotations({description:`a string to be decoded into a number`})).annotations({identifier:`NumberFromString`}),Fj.pipe(KM({identifier:`Finite`})),dN=class extends Fj.pipe(QM({identifier:`Int`})){},Fj.pipe(oN({identifier:`NonNaN`})),Fj.pipe(sN({identifier:`Positive`})),Fj.pipe(cN({identifier:`Negative`})),Fj.pipe(lN({identifier:`NonPositive`})),fN=class extends Fj.pipe(uN({identifier:`NonNegative`})){},pN=xD,Fj.pipe(KM({schemaId:pN,identifier:`JsonNumber`})),pM(q.annotations({description:`a boolean that will be negated`}),q,{strict:!0,decode:e=>ca(e),encode:e=>ca(e)}),mN=(e,t)=>{let n=Symbol.keyFor(e);return n===void 0?eA(new Jk(t,e,`Unable to encode a unique symbol ${String(e)} into a string`)):$k(n)},hN=e=>$k(Symbol.for(e)),fM(K.annotations({description:`a string to be decoded into a globally shared symbol`}),Pj,{strict:!1,decode:e=>hN(e),encode:(e,t,n)=>mN(e,n)}).annotations({identifier:`Symbol`}),gN=CD,_N=(e,t)=>n=>n.pipe(pj(t=>t>=e,{schemaId:gN,[gN]:{min:e},title:`greaterThanOrEqualToBigInt(${e})`,description:e===0n?`a non-negative bigint`:`a bigint greater than or equal to ${e}n`,...t})),vN=wD,yN=(e,t,n)=>r=>r.pipe(pj(n=>n>=e&&n<=t,{schemaId:vN,[vN]:{min:e,max:t},title:`betweenBigInt(${e}, ${t})`,description:`a bigint between ${e}n and ${t}n`,...n})),bN=e=>_N(0n,{title:`nonNegativeBigInt`,...e}),xN=class extends fM(K.annotations({description:`a string to be decoded into a bigint`}),Nj,{strict:!0,decode:(e,t,n)=>nA(aa(e),()=>new Jk(n,e,`Unable to decode ${JSON.stringify(e)} into a bigint`)),encode:e=>$k(String(e))}).annotations({identifier:`BigInt`}){},SN=Nj.pipe(bN({identifier:`NonNegativeBigintFromSelf`})),fM(Fj.annotations({description:`a number to be decoded into a bigint`}),Nj.pipe(yN(BigInt(-(2**53-1)),BigInt(2**53-1))),{strict:!0,decode:(e,t,n)=>nA(oa(e),()=>new Jk(n,e,`Unable to decode ${e} into a bigint`)),encode:(e,t,n)=>nA(ia(e),()=>new Jk(n,e,`Unable to encode ${e}n into a number`))}).annotations({identifier:`BigIntFromNumber`}),CN=(e,t,n,r)=>sA(e,{onFailure:e=>new Gk(n,r,e),onSuccess:t}),wN=class extends G(vl,{typeConstructor:{_tag:`effect/Duration`},identifier:`DurationFromSelf`,pretty:()=>String,arbitrary:()=>e=>e.oneof(e.constant(Sl),e.bigInt({min:0n}).map(e=>Cl(e)),e.maxSafeNat().map(e=>Tl(e))),equivalence:()=>Ll}){},fM(SN.annotations({description:`a bigint to be decoded into a Duration`}),wN.pipe(pj(e=>yl(e),{description:`a finite duration`})),{strict:!0,decode:e=>$k(Cl(e)),encode:(e,t,n)=>br(Ml(e),{onNone:()=>eA(new Jk(n,e,`Unable to encode ${e} into a bigint`)),onSome:e=>$k(e)})}).annotations({identifier:`DurationFromNanos`}),TN=fN.pipe(QM()).annotations({identifier:`NonNegativeInt`}),pM(fN.annotations({description:`a non-negative number to be decoded into a Duration`}),wN,{strict:!0,decode:e=>Tl(e),encode:e=>jl(e)}).annotations({identifier:`DurationFromMillis`}),EN=aM(`Millis`,{millis:TN}),DN=aM(`Nanos`,{nanos:xN}),ON=aM(`Infinity`,{}),kN=ON.make({}),AN=U(EN,DN,ON).annotations({identifier:`DurationValue`,description:`an JSON-compatible tagged union to be decoded into a Duration`}),jN=U(sj(Rj(TN).annotations({title:`seconds`}),Rj(TN).annotations({title:`nanos`})).annotations({identifier:`FiniteHRTime`}),sj(H(-1),H(0)).annotations({identifier:`InfiniteHRTime`})).annotations({identifier:`HRTime`,description:`a tuple of seconds and nanos to be decoded into a Duration`}),MN=e=>typeof e==`object`,pM(U(AN,jN),wN,{strict:!0,decode:e=>{if(MN(e))switch(e._tag){case`Millis`:return Tl(e.millis);case`Nanos`:return Cl(e.nanos);case`Infinity`:return Sl}let[t,n]=e;return t===-1?Sl:Cl(BigInt(t)*BigInt(1e9)+BigInt(n))},encode:e=>{switch(e.value._tag){case`Millis`:return EN.make({millis:e.value.millis});case`Nanos`:return DN.make({nanos:e.value.nanos});case`Infinity`:return kN}}}).annotations({identifier:`Duration`}),NN=class extends G(Ze,{typeConstructor:{_tag:`Uint8Array`},identifier:`Uint8ArrayFromSelf`,pretty:()=>e=>`new Uint8Array(${JSON.stringify(Array.from(e))})`,arbitrary:()=>e=>e.uint8Array(),equivalence:()=>Ai(A)}){},PN=class extends Fj.pipe(iN(0,255,{identifier:`Uint8`,description:`a 8-bit unsigned integer`})){},pM(Vj(PN).annotations({description:`an array of 8-bit unsigned integers to be decoded into a Uint8Array`}),NN,{strict:!0,decode:e=>Uint8Array.from(e),encode:e=>Array.from(e)}).annotations({identifier:`Uint8Array`}),FN=Symbol.for(`effect/SchemaId/ValidDate`),IN=e=>t=>t.pipe(pj(e=>!Number.isNaN(e.getTime()),{schemaId:FN,[FN]:{noInvalidDate:!0},title:`validDate`,description:`a valid Date`,...e})),LN=pD,RN=class extends G(Qe,{typeConstructor:{_tag:`Date`},identifier:`DateFromSelf`,schemaId:LN,[LN]:{noInvalidDate:!1},description:`a potentially invalid Date instance`,pretty:()=>e=>`new Date(${JSON.stringify(e)})`,arbitrary:()=>e=>e.date({noInvalidDate:!1}),equivalence:()=>je}){},RN.pipe(IN({identifier:`ValidDateFromSelf`,description:`a valid Date instance`})),zN=class extends pM(K.annotations({description:`a string to be decoded into a Date`}),RN,{strict:!0,decode:e=>new Date(e),encode:e=>It(e)}).annotations({identifier:`DateFromString`}){},zN.pipe(IN({identifier:`Date`})),pM(Fj.annotations({description:`a number to be decoded into a Date`}),RN,{strict:!0,decode:e=>new Date(e),encode:e=>e.getTime()}).annotations({identifier:`DateFromNumber`}),BN=class extends G(e=>ME(e)&&FE(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=>RE(e)),equivalence:()=>LE}){},VN=(e,t)=>tA({try:()=>zE(e),catch:()=>new Jk(t,e,`Unable to decode ${zt(e)} into a DateTime.Utc`)}),fM(Fj.annotations({description:`a number to be decoded into a DateTime.Utc`}),BN,{strict:!0,decode:(e,t,n)=>VN(e,n),encode:e=>$k(qE(e))}).annotations({identifier:`DateTimeUtcFromNumber`}),fM(RN.annotations({description:`a Date to be decoded into a DateTime.Utc`}),BN,{strict:!0,decode:(e,t,n)=>VN(e,n),encode:e=>$k(KE(e))}).annotations({identifier:`DateTimeUtcFromDate`}),fM(K.annotations({description:`a string to be decoded into a DateTime.Utc`}),BN,{strict:!0,decode:(e,t,n)=>VN(e,n),encode:e=>$k(JE(e))}).annotations({identifier:`DateTimeUtc`}),HN=()=>e=>e.integer({min:-432e5,max:504e5}).map(UE),UN=class extends G(NE,{typeConstructor:{_tag:`effect/DateTime.TimeZone.Offset`},identifier:`TimeZoneOffsetFromSelf`,description:`a TimeZone.Offset instance`,pretty:()=>e=>e.toString(),arbitrary:HN}){},pM(Fj.annotations({description:`a number to be decoded into a TimeZone.Offset`}),UN,{strict:!0,decode:e=>UE(e),encode:e=>e.offset}).annotations({identifier:`TimeZoneOffset`}),WN=()=>e=>e.constantFrom(...Intl.supportedValuesOf(`timeZone`)).map(HE),GN=class extends G(PE,{typeConstructor:{_tag:`effect/DateTime.TimeZone.Named`},identifier:`TimeZoneNamedFromSelf`,description:`a TimeZone.Named instance`,pretty:()=>e=>e.toString(),arbitrary:WN}){},fM(K.annotations({description:`a string to be decoded into a TimeZone.Named`}),GN,{strict:!0,decode:(e,t,n)=>tA({try:()=>HE(e),catch:()=>new Jk(n,e,`Unable to decode ${JSON.stringify(e)} into a TimeZone.Named`)}),encode:e=>$k(e.id)}).annotations({identifier:`TimeZoneNamed`}),KN=class extends U(UN,GN){},fM(K.annotations({description:`a string to be decoded into a TimeZone`}),KN,{strict:!0,decode:(e,t,n)=>br(WE(e),{onNone:()=>eA(new Jk(n,e,`Unable to decode ${JSON.stringify(e)} into a TimeZone`)),onSome:$k}),encode:e=>$k(GE(e))}).annotations({identifier:`TimeZone`}),qN=e=>e.oneof(HN()(e),WN()(e)),JN=class extends G(e=>ME(e)&&IE(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}),qN(e)).map(([e,t])=>BE(e,{timeZone:t})),equivalence:()=>LE}){},fM(K.annotations({description:`a string to be decoded into a DateTime.Zoned`}),JN,{strict:!0,decode:(e,t,n)=>br(VE(e),{onNone:()=>eA(new Jk(n,e,`Unable to decode ${JSON.stringify(e)} into a DateTime.Zoned`)),onSome:$k}),encode:e=>$k(YE(e))}).annotations({identifier:`DateTimeZoned`}),YN=e=>e._tag===`None`?R():z(e.value),XN=(e,t)=>n=>n.oneof(t,n.record({_tag:n.constant(`None`)}),n.record({_tag:n.constant(`Some`),value:e(n)})).map(YN),ZN=e=>br({onNone:()=>`none()`,onSome:t=>`some(${e(t)})`}),QN=e=>(t,n,r)=>_r(t)?vr(t)?$k(R()):CN(e(t.value,n),z,r,t):eA(new Jk(r,t)),$N=e=>G([e],{decode:e=>QN(mA(e)),encode:e=>QN(hA(e))},{typeConstructor:{_tag:`effect/Option`},pretty:ZN,arbitrary:XN,equivalence:Nr}),eP=e=>$N(e).annotations({description:`Option<${Sj(e)}>`}),pM(K,eP(RM),{strict:!0,decode:e=>Mr(z(e.trim()),_E),encode:e=>xr(e,()=>``)}),tP=()=>e=>`BigDecimal(${Qi(Wi(e))})`,nP=()=>e=>e.tuple(e.bigInt(),e.integer({min:-18,max:18})).map(([e,t])=>zi(e,t)),rP=class extends G(Ri,{typeConstructor:{_tag:`effect/BigDecimal`},identifier:`BigDecimalFromSelf`,pretty:tP,arbitrary:nP,equivalence:()=>qi}){},fM(K.annotations({description:`a string to be decoded into a BigDecimal`}),rP,{strict:!0,decode:(e,t,n)=>Zi(e).pipe(br({onNone:()=>eA(new Jk(n,e,`Unable to decode ${JSON.stringify(e)} into a BigDecimal`)),onSome:e=>$k(Wi(e))})),encode:e=>$k(Qi(Wi(e)))}).annotations({identifier:`BigDecimal`}),pM(Fj.annotations({description:`a number to be decoded into a BigDecimal`}),rP,{strict:!0,decode:e=>Yi(e),encode:e=>ea(e)}).annotations({identifier:`BigDecimalFromNumber`}),iP=U(W({_tag:H(`None`)}).annotations({identifier:`FiberIdNoneEncoded`}),W({_tag:H(`Runtime`),id:dN,startTimeMillis:dN}).annotations({identifier:`FiberIdRuntimeEncoded`}),W({_tag:H(`Composite`),left:cM(()=>iP),right:cM(()=>iP)}).annotations({identifier:`FiberIdCompositeEncoded`})).annotations({identifier:`FiberIdEncoded`}),aP=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(cP),oP=e=>{switch(e._tag){case`None`:return`FiberId.none`;case`Runtime`:return`FiberId.runtime(${e.id}, ${e.startTimeMillis})`;case`Composite`:return`FiberId.composite(${oP(e.right)}, ${oP(e.left)})`}},sP=class extends G(_u,{typeConstructor:{_tag:`effect/FiberId`},identifier:`FiberIdFromSelf`,pretty:()=>oP,arbitrary:()=>aP}){},cP=e=>{switch(e._tag){case`None`:return mu;case`Runtime`:return hu(e.id,e.startTimeMillis);case`Composite`:return gu(cP(e.left),cP(e.right))}},lP=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:lP(e.left),right:lP(e.right)}}},pM(iP,sP,{strict:!0,decode:e=>cP(e),encode:e=>lP(e)}).annotations({identifier:`FiberId`}),pM(Mj,Mj,{strict:!0,decode:e=>{if(qe(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 mc(e)},encode:e=>e instanceof Error?{name:e.name,message:e.message}:mc(e)}).annotations({identifier:`Defect`}),pM(Mj,q,{strict:!0,decode:e=>Le(e),encode:be}).annotations({identifier:`BooleanFromUnknown`}),pM(H(`true`,`false`).annotations({description:`a string to be decoded into a boolean`}),q,{strict:!0,decode:e=>e===`true`,encode:e=>e?`true`:`false`}).annotations({identifier:`BooleanFromString`}),uP=aM(`symbol`,{key:K}).annotations({description:`an object to be decoded into a globally shared symbol`}),dP=fM(uP,Pj,{strict:!0,decode:e=>hN(e.key),encode:(e,t,n)=>aA(mN(e,n),e=>uP.make({key:e}))}),fP=class extends U(K,Fj,dP).annotations({identifier:`PropertyKey`}){},W({_tag:$j(H(`Pointer`,`Unexpected`,`Missing`,`Composite`,`Refinement`,`Transformation`,`Type`,`Forbidden`)).annotations({description:`The tag identifying the type of parse issue`}),path:$j(Vj(fP)).annotations({description:`The path to the property where the issue occurred`}),message:$j(K).annotations({description:`A descriptive message explaining the issue`})}).annotations({identifier:`ArrayFormatterIssue`,description:`Represents an issue returned by the ArrayFormatter formatter`})}));function mP(e,t){return Cj(e,hP)(t)}var hP,gP=v((()=>{pP(),hP={onExcessProperty:`error`}}));function _P(e,t){if(typeof t!=`string`)return;let n=e.lastIndexOf(`@`);if(n<=0)return;let r=e.slice(0,n),i=e.slice(n+1);if(!(!bP(r)||!yP(i)||t!==i))return{pluginName:r,marketplaceName:i,canonicalPluginId:`${r}@openai-curated`}}function vP(e){let t=e.lastIndexOf(`@`);if(t<=0)return;let n=e.slice(0,t),r=e.slice(t+1);return bP(n)&&yP(r)?`${n}@openai-curated`:void 0}function yP(e){return wP.includes(e)}function bP(e){return TP.includes(e)}function xP(e,t){let n=t??AP;return{computer_use:e?.computer_use??n.computer_use,work:e?.work??n.work,frontend:e?.frontend??n.frontend,security:e?.security??n.security}}function SP(e,t=[]){let n=[],r=new Set;for(let t of kP)if(e[t])for(let e of OP[t].pluginIds)r.has(e)||(r.add(e),n.push(e));for(let e of t)r.has(e)||(r.add(e),n.push(e));return n}var CP,wP,TP,EP,DP,OP,kP,AP,jP=v((()=>{pP(),CP=H(`computer_use`,`work`,`frontend`,`security`),H(`computer_use`,`work`,`frontend`,`security`),H(`installed`,`disabled`,`missing`,`uncertain`),H(`healthy`,`missing`,`disabled`,`uncertain`),wP=Object.freeze([`openai-curated`,`openai-curated-remote`]),TP=Object.freeze([`build-web-apps`,`codex-security`]),EP=Object.freeze({coding:!0,computer_use:!1,work:!1,frontend:!0,security:!0}),DP={work:{name:`work`,pluginIds:[`documents@openai-primary-runtime`,`pdf@openai-primary-runtime`,`presentations@openai-primary-runtime`,`spreadsheets@openai-primary-runtime`,`template-creator@openai-primary-runtime`],defaultSelected:EP.work,migrationKey:`work`,semanticSkillIds:[`documents:documents`,`pdf:pdf`,`presentations:Presentations`,`spreadsheets:Spreadsheets`,`template-creator:template-creator`],ownership:`shared-preserve`},frontend:{name:`frontend`,pluginIds:[`build-web-apps@openai-curated`],defaultSelected:EP.frontend,migrationKey:`frontend`,semanticSkillIds:[`build-web-apps:frontend-app-builder`,`build-web-apps:frontend-testing-debugging`,`build-web-apps:react-best-practices`],ownership:`shared-preserve`},security:{name:`security`,pluginIds:[`codex-security@openai-curated`],defaultSelected:EP.security,migrationKey:`security`,semanticSkillIds:[`codex-security:security-scan`,`codex-security:security-diff-scan`,`codex-security:threat-model`],ownership:`shared-preserve`},computer_use:{name:`computer_use`,pluginIds:[`computer-use@openai-bundled`],defaultSelected:EP.computer_use,migrationKey:`computer_use`,semanticSkillIds:[`computer-use:computer-use`],ownership:`shared-preserve`}},OP=Object.freeze(DP),kP=Object.freeze([`computer_use`,`work`,`frontend`,`security`]),AP=Object.freeze({computer_use:EP.computer_use,work:EP.work,frontend:EP.frontend,security:EP.security})}));function MP(e){return W({identifier:H(e),label:K,requiresRootApproval:q})}function NP(e){let t=e.map(e=>e.label),n=t.at(-1);return n===void 0?``:t.length===1?n:`${t.slice(0,-1).join(`, `)}, and ${n}`}function PP(e){return e.length===0?e:`${e[0]?.toUpperCase()??``}${e.slice(1)}`}var FP,IP,LP,RP,zP,BP=v((()=>{pP(),me(),FP=H(`local.repository.edit`,`local.repository.check`,`local.repository.lint`,`local.repository.format`,`local.repository.commit`,`external.read`,`specialist.dispatch`,`vcs.server.mutation`,`vcs.server.ci-trigger`,`unknown.effect`),W({identifier:FP,label:K,requiresRootApproval:q}),W({localRepositoryEdit:MP(`local.repository.edit`),localRepositoryCheck:MP(`local.repository.check`),localRepositoryLint:MP(`local.repository.lint`),localRepositoryFormat:MP(`local.repository.format`),localRepositoryCommit:MP(`local.repository.commit`),externalRead:MP(`external.read`),specialistDispatch:MP(`specialist.dispatch`),versionControlServerMutation:MP(`vcs.server.mutation`),versionControlServerCiTrigger:MP(`vcs.server.ci-trigger`),unknownEffect:MP(`unknown.effect`)}),IP={localRepositoryEdit:{identifier:`local.repository.edit`,label:`local repository edit`,requiresRootApproval:!1},localRepositoryCheck:{identifier:`local.repository.check`,label:`local repository check`,requiresRootApproval:!1},localRepositoryLint:{identifier:`local.repository.lint`,label:`local repository lint`,requiresRootApproval:!1},localRepositoryFormat:{identifier:`local.repository.format`,label:`local repository format`,requiresRootApproval:!1},localRepositoryCommit:{identifier:`local.repository.commit`,label:`local repository commit`,requiresRootApproval:!1},externalRead:{identifier:`external.read`,label:`external read`,requiresRootApproval:!1},specialistDispatch:{identifier:`specialist.dispatch`,label:`specialist dispatch`,requiresRootApproval:!1},versionControlServerMutation:{identifier:`vcs.server.mutation`,label:`version-control-server mutation`,requiresRootApproval:!0},versionControlServerCiTrigger:{identifier:`vcs.server.ci-trigger`,label:`version-control-server CI triggering`,requiresRootApproval:!0},unknownEffect:{identifier:`unknown.effect`,label:`unclassified effect`,requiresRootApproval:!0}},ue(IP),H(`never`,`root`),LP=Object.values(IP),RP=LP.filter(e=>!e.requiresRootApproval),zP=LP.filter(e=>e.requiresRootApproval),Object.freeze({noRootApproval:`${PP(NP(RP))} actions do not require Root approval.`,rootApproval:`${PP(NP(zP))} require Root approval.`})}));function VP(e){let t=mP(WP,e);return er(t)?ge(_e(`sha256 digest`,t.left)):he(t.right)}var HP,UP,WP,GP=v((()=>{lr(),pP(),ve(),gP(),HP=K.pipe(CM(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u)),UP=K.pipe(CM(/^[0-9a-f]{64}$/u)),HP.pipe(sM(`RunId`)),HP.pipe(sM(`ProjectId`)),HP.pipe(sM(`TrustId`)),WP=UP.pipe(sM(`Sha256Digest`)),W({run_id:HP,objective_lineage:HP,parent_run_id:J(U(HP,Aj))}),W({project_id:HP,trust_id:HP,trust_digest:UP}),W({project_id:HP,project_digest:UP}),K.pipe(CM(/^state-[0-9]+\.[0-9]+$/u))}));function KP(e){return e===`Go`?`go`:e}function qP(e){return typeof e==`string`&&aF.has(e)}function JP(e){if(typeof e!=`object`||!e||!(`role`in e)||!(`task`in e))return!1;let t=e.role,n=e.task;return!qP(t)||typeof n!=`string`?!1:iF.get(t)?.tasks.some(e=>e.name===n)===!0}function YP(e,t){return typeof t==`string`&&iF.get(e)?.tasks.some(e=>e.name===t)===!0}function XP(e){return typeof e==`string`&&sF.has(e)}function ZP(e){let t=`${e.role}.${e.task}`;if(!lF.has(t))throw Error(`Unknown native specialist agent type.`);return t}function QP(e){let t=iF.get(e.role)?.tasks.find(t=>t.name===e.task);if(t===void 0)throw Error(`Unknown specialist task policy.`);return t.instruction}function $P(e){let t=iF.get(e.role)?.tasks.find(t=>t.name===e.task);if(t===void 0)throw Error(`Unknown specialist task policy.`);return t.description}var eF,tF,nF,rF,iF,aF,oF,sF,cF,lF,uF,dF,fF,pF,mF=v((()=>{pP(),me(),eF=H(`go`,`plus-low`,`plus`,`plus-high`,`pro-5x`,`pro-20x`),tF=H(`Go`),U(eF,tF),nF=H(`standard`,`fast`,`fast-all`),H(`low`,`medium`,`high`,`xhigh`,`max`),rF=[{role:`Explorer`,tasks:[{name:`lookup`,description:`Use when Root needs one exact repository fact; locate it and return the exact path, symbol, or value.`,instruction:`Locate the exact requested repository fact.`},{name:`trace`,description:`Use when Root needs a complete in-scope execution or reference path; trace every relevant caller and constraint, then return the path and evidence.`,instruction:`Trace the complete in-scope execution or reference path.`}],capability:`repository-read`,authority:`Read only the assigned repository scope; Git/VCS and decisions remain Root-only.`,evidence:`Return exact paths, symbols, callers, tests, and constraints.`,completion:`Account for every in-scope caller and constraint.`,permissions:{network:!1,write:!1}},{role:`Librarian`,tasks:[{name:`lookup`,description:`Use when Root needs one exact current external fact; locate it in the assigned authoritative source and return the citation.`,instruction:`Locate the exact requested authoritative external fact.`},{name:`research`,description:`Use when Root needs a sourced current synthesis; combine the assigned authoritative sources with citations and return the evidence and uncertainty.`,instruction:`Synthesize the assigned current sources with citations.`}],capability:`current-research`,authority:`Research only the assigned current sources without repository mutation; Git/VCS and decisions remain Root-only.`,evidence:`Return sourced facts, dates, and explicit uncertainty.`,completion:`Resolve the assigned external fact or report the exact evidence gap.`,permissions:{network:!0,write:!1}},{role:`Worker`,tasks:[{name:`mechanical`,description:`Use when Root has decided deterministic edits; apply only those edits, verify the result, and return changed paths and evidence.`,instruction:`Apply only deterministic, already-decided edits.`},{name:`implementation`,description:`Use when Root has decided a bounded behavior seam; implement and verify that seam, then return changed paths and evidence.`,instruction:`Implement and verify the bounded behavior seam.`},{name:`integration`,description:`Use when Root has decided seams that must be combined; integrate and verify them together, then return the result and residual risk.`,instruction:`Integrate the decided seams and verify them together.`},{name:`operations`,description:`Use after Root approves an exact ref or SHA; observe required CI and release state to terminal evidence and return it, never treating pending as success.`,instruction:`After Root approves an exact ref or SHA, observe required CI and release state through terminal evidence; pending or running state is never success.`}],capability:`bounded-write`,authority:`Change only the assigned seam; Git/VCS and material choices remain Root-only.`,evidence:`Return changed files, verification results, and remaining risk.`,completion:`Finish the assigned seam with proportional proof or an exact blocker.`,permissions:{network:!1,write:!0}},{role:`Reviewer`,tasks:[{name:`plan`,description:`Use when Root needs a complete plan adversarially checked; review it to a fixed point and return findings, proof, and residual risk.`,instruction:`Review the complete plan to a fixed point.`},{name:`code`,description:`Use when Root needs implemented code adversarially checked; review and repair it to a fixed point, returning findings, proof, and residual risk.`,instruction:`Review and repair the implemented code to a fixed point.`},{name:`artifact`,description:`Use when Root needs a produced artifact inspected; review and repair it to a fixed point, returning findings, proof, and residual risk.`,instruction:`Review and repair the produced artifact to a fixed point.`}],capability:`bounded-review`,authority:`Inspect and repair only reviewer-owned defects; Git/VCS and material choices remain Root-only.`,evidence:`Return findings, repaired paths, verification, and residual risk.`,completion:`Reach a fixed point or report each reproducible blocker.`,permissions:{network:!1,write:!0}}],ue(rF),iF=new Map(rF.map(e=>[e.role,e])),aF=new Set(rF.map(e=>e.role)),oF=rF.flatMap(e=>e.tasks.map(t=>`${e.role}:${t.name}`)),sF=new Set(oF),cF=oF.map(e=>e.replace(`:`,`.`)),lF=new Set(cF),uF=G(qP),G(e=>YP(`Explorer`,e)),G(e=>YP(`Librarian`,e)),G(e=>YP(`Worker`,e)),G(e=>YP(`Reviewer`,e)),dF=G(JP),fF=Object.freeze(oF.filter(e=>XP(e))),G(XP),pF=Object.freeze(cF.filter(e=>lF.has(e))),G(e=>typeof e==`string`&&lF.has(e)),W({plan:eF,service_tier:J(nF)})}));function hF(e,t){return new y(`invalid_canonical_value`,`Cannot canonicalize ${e}: ${t}.`,{path:e,reason:t})}function gF(e,t,n){if(e===null)return`null`;switch(typeof e){case`string`:{let n=JSON.stringify(e);if(n===void 0)throw hF(t,`invalid string`);return n}case`boolean`:return e?`true`:`false`;case`number`:{if(!Number.isFinite(e))throw hF(t,`non-finite number`);let n=JSON.stringify(e);if(n===void 0)throw hF(t,`invalid number`);return n}case`undefined`:throw hF(t,`undefined is not JSON`);case`bigint`:throw hF(t,`bigint is not JSON`);case`function`:throw hF(t,`function is not JSON`);case`symbol`:throw hF(t,`symbol is not JSON`)}if(n.has(e))throw hF(t,`cyclic value`);n.add(e);try{if(Array.isArray(e)){for(let n of Object.getOwnPropertySymbols(e))throw hF(t,`symbol property ${String(n)}`);let r=e,i=[];for(let e=0;e<r.length;e+=1){let a=Object.getOwnPropertyDescriptor(r,String(e));if(!a||!a.enumerable||!(`value`in a))throw hF(`${t}[${e}]`,`sparse or accessor array item`);i.push(gF(a.value,`${t}[${e}]`,n))}for(let e of Object.getOwnPropertyNames(r)){if(e===`length`)continue;let n=Number(e);if(!Number.isInteger(n)||n<0||n>=r.length||String(n)!==e)throw hF(t,`non-index array property ${e}`);let i=Object.getOwnPropertyDescriptor(r,e);if(!i||!i.enumerable||!(`value`in i))throw hF(`${t}[${n}]`,`non-enumerable or accessor array item`)}return`[${i.join(`,`)}]`}let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw hF(t,`only plain objects are supported`);for(let n of Object.getOwnPropertySymbols(e))throw hF(t,`symbol property ${String(n)}`);for(let n of Object.getOwnPropertyNames(e)){let r=Object.getOwnPropertyDescriptor(e,n);if(!r||!r.enumerable||!(`value`in r))throw hF(`${t}.${n}`,`non-enumerable or accessor property`)}let i=[];for(let r of Object.keys(e).sort()){let a=Object.getOwnPropertyDescriptor(e,r);if(!a||!(`value`in a))throw hF(`${t}.${r}`,`accessor property`);i.push(`${JSON.stringify(r)}:${gF(a.value,`${t}.${r}`,n)}`)}return`{${i.join(`,`)}}`}finally{n.delete(e)}}function _F(e){return gF(e,`$`,new Set)}function vF(e){return new TextEncoder().encode(_F(e))}function yF(e,t){if(e.length===0||e.includes(`\0`))throw new y(`invalid_digest_domain`,`Digest domains must be non-empty and NUL-free.`,{field:`domain`});let n=new TextEncoder().encode(`holycodex-sha256\0`),r=new TextEncoder().encode(e),i=n.byteLength+8+r.byteLength;for(let e of t){if(e.byteLength>4294967295||i>4294967291-e.byteLength)throw new y(`invalid_digest_domain`,`Digest input is too large.`);i+=4+e.byteLength}let a=new Uint8Array(i),o=new DataView(a.buffer);a.set(n,0);let s=n.byteLength;o.setUint32(s,r.byteLength,!1),s+=4,a.set(r,s),s+=r.byteLength,o.setUint32(s,t.length,!1),s+=4;for(let e of t)o.setUint32(s,e.byteLength,!1),s+=4,a.set(e,s),s+=e.byteLength;return a}function bF(e){let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return t}async function xF(e,t){let n=globalThis.crypto?.subtle;if(!n)throw new y(`crypto_unavailable`,`The standards-based crypto API is unavailable.`);let r=await n.digest(`SHA-256`,SF(yF(e,t)));return bF(new Uint8Array(r))}function SF(e){let t=new Uint8Array(e.byteLength);return t.set(e),t}var CF=v((()=>{ve(),GP()}));function wF(e){try{return _F(e)!==void 0}catch{return!1}}function TF(e){let t=mP(JF,e);return er(t)?ge(_e(`CLI envelope`,t.left)):he(t.right)}var EF,DF,OF,kF,AF,jF,MF,NF,PF,FF,IF,LF,RF,zF,BF,VF,HF,UF,WF,GF,KF,qF,JF,YF=v((()=>{lr(),pP(),CF(),jP(),me(),ve(),GP(),mF(),gP(),EF=H(`blocked`,`completed`,`failed`,`partial`),DF=U(H(`high`,`max`,`xhigh`),Aj),OF=G(e=>wF(e)),kF=G(e=>de(e)&&!Array.isArray(e)&&wF(e)),W({blocked:q,changed_files:Vj(K),confidence:Fj,context_owner:U(K,Aj),material_findings:Vj(K),needs_more_context:q,needs_root_decision:q,needs_verification:q,relevant_files:Vj(K),remaining_risk:Vj(K),reuse_recommended:q,status:EF,suggested_followup:U(K,Aj),suggested_luna_effort:DF,suggested_specialist:U(uF,Aj),verification:Vj(K),verification_passed:q}),AF=`holycodex-specialist-outcome-2`,jF=K.pipe(yM(1)),MF={protocol_version:H(AF),route:dF,evidence:Vj(jF)},W(MF),NF=W({...MF,status:H(`completed`),summary:jF}),PF=W({...MF,status:H(`blocked`),reason:jF,needs_root_decision:q}),FF=W({...MF,status:H(`partial`),summary:jF,completed:Vj(jF),remaining:Vj(jF),needs_root_decision:q}),IF=W({...MF,status:H(`failed`),error:jF}),U(NF,PF,FF,IF),LF={protocol_version:H(AF),capability:CP,route:U(dF,Aj),evidence:Vj(jF),data:OF},RF=W({...LF,status:H(`completed`),summary:jF}),zF=W({...LF,status:H(`blocked`),reason:jF,needs_root_decision:q}),BF=W({...LF,status:H(`partial`),summary:jF,completed:Vj(jF),remaining:Vj(jF),needs_root_decision:q}),VF=W({...LF,status:H(`failed`),error:jF}),U(RF,zF,BF,VF),HF=Vj(K),UF=K.pipe(CM(/^[a-z][a-z0-9-]*(?: [a-z][a-z0-9-]*)*$/u)),WF=H(fe),GF=W({code:HP,message:K,details:kF}),KF=W({schema_version:WF,ok:H(!0),command:UF,data:OF,warnings:HF}),qF=W({schema_version:WF,ok:H(!1),command:UF,error:GF,warnings:HF}),JF=U(KF,qF)}));function XF(e,t,n){return{key:`${e}:${t}`,role:e,task:t,model:`Luna`,effort:n}}function ZF(e){let t=iI.get(e);if(t===void 0)throw new y(`catalog_invalid`,`A specialist plan has no route effort policy.`,{plan:e});return rF.flatMap(n=>n.tasks.map(r=>{let i=`${n.role}:${r.name}`,a=t.efforts[i];if(a===void 0)throw new y(`catalog_invalid`,`A route effort policy is incomplete.`,{plan:e,route:i});return XF(n.role,r.name,a)}))}function QF(e){return{...e,specialistModel:`Luna`,defaultServiceTier:`standard`,routes:ZF(e.name)}}function $F(e){let t=[`go`,`plus-low`,`plus`,`plus-high`,`pro-5x`,`pro-20x`];if(e.length!==t.length)throw new y(`catalog_invalid`,`The plan catalog has an invalid size.`);for(let n=0;n<t.length;n+=1){let r=e[n],i=t[n];if(!r||r.name!==i)throw new y(`catalog_invalid`,`The plan catalog order is invalid.`,{index:n});let a=r.name===`go`?{model:`Terra`,effort:`high`}:r.name===`plus-low`?{model:`Sol`,effort:`low`}:r.name===`plus`?{model:`Sol`,effort:`medium`}:r.name===`pro-20x`?{model:`Sol`,effort:`xhigh`}:{model:`Sol`,effort:`high`};if(r.root.model!==a.model||r.root.effort!==a.effort)throw new y(`catalog_invalid`,`A plan has an invalid Root route.`,{plan:r.name});if(r.specialistModel!==`Luna`||r.defaultServiceTier!==`standard`)throw new y(`catalog_invalid`,`A plan has an invalid specialist policy.`,{plan:r.name});if(r.routes.length!==fF.length)throw new y(`catalog_invalid`,`A specialist plan is incomplete.`,{plan:r.name});let o=new Set;for(let e of r.routes){if(o.has(e.key)||!tI.has(e.key)||e.model!==`Luna`||`${e.role}:${e.task}`!==e.key)throw new y(`catalog_invalid`,`A plan contains an invalid route.`,{plan:r.name});o.add(e.key)}if(o.size!==fF.length)throw new y(`catalog_invalid`,`A plan is missing a specialist route.`,{plan:r.name})}let n=e[0]?.routes,r=e[1]?.routes;if(!n||!r||n.length!==r.length||n.some((e,t)=>e.key!==r[t]?.key||e.model!==r[t]?.model||e.effort!==r[t]?.effort))throw new y(`catalog_invalid`,`go must use the plus-low specialist route matrix.`);let i=e;for(let e=0;e<fF.length;e+=1){let t=-1;for(let n of i){let r=n.routes[e];if(!r||nI[r.effort]<t)throw new y(`catalog_invalid`,`Plan route effort is not monotonic.`,{route:fF[e]??`unknown`});t=nI[r.effort]}}}function eI(e){let t=mP(eF,e);if(er(t))return ge(new y(`invalid_plan`,`Unknown plan selection.`,{field:`plan`},{cause:t.left}));let n=sI.get(t.right);return n?he(n):ge(new y(`invalid_plan`,`Unknown plan selection.`,{plan:t.right}))}var tI,nI,rI,iI,aI,oI,sI,cI,lI=v((()=>{lr(),me(),ve(),mF(),gP(),tI=new Set(fF),nI={low:0,medium:1,high:2,xhigh:3,max:4},rI=[{plan:`plus-low`,rationale:`Preserve the approved plus-low route effort policy.`,efforts:{"Explorer:lookup":`medium`,"Explorer:trace":`high`,"Librarian:lookup":`medium`,"Librarian:research":`high`,"Worker:mechanical":`high`,"Worker:implementation":`high`,"Worker:integration":`xhigh`,"Worker:operations":`high`,"Reviewer:plan":`high`,"Reviewer:code":`xhigh`,"Reviewer:artifact":`high`}},{plan:`plus`,rationale:`Preserve the approved plus route effort policy.`,efforts:{"Explorer:lookup":`medium`,"Explorer:trace":`high`,"Librarian:lookup":`medium`,"Librarian:research":`high`,"Worker:mechanical":`high`,"Worker:implementation":`xhigh`,"Worker:integration":`xhigh`,"Worker:operations":`high`,"Reviewer:plan":`high`,"Reviewer:code":`xhigh`,"Reviewer:artifact":`high`}},{plan:`plus-high`,rationale:`Preserve the approved plus-high route effort policy.`,efforts:{"Explorer:lookup":`medium`,"Explorer:trace":`xhigh`,"Librarian:lookup":`medium`,"Librarian:research":`xhigh`,"Worker:mechanical":`high`,"Worker:implementation":`xhigh`,"Worker:integration":`max`,"Worker:operations":`xhigh`,"Reviewer:plan":`xhigh`,"Reviewer:code":`max`,"Reviewer:artifact":`xhigh`}},{plan:`pro-5x`,rationale:`Preserve the approved pro-5x route effort policy.`,efforts:{"Explorer:lookup":`high`,"Explorer:trace":`xhigh`,"Librarian:lookup":`high`,"Librarian:research":`xhigh`,"Worker:mechanical":`high`,"Worker:implementation":`max`,"Worker:integration":`max`,"Worker:operations":`xhigh`,"Reviewer:plan":`xhigh`,"Reviewer:code":`max`,"Reviewer:artifact":`xhigh`}},{plan:`pro-20x`,rationale:`Preserve the approved pro-20x route effort policy.`,efforts:{"Explorer:lookup":`high`,"Explorer:trace":`xhigh`,"Librarian:lookup":`high`,"Librarian:research":`max`,"Worker:mechanical":`xhigh`,"Worker:implementation":`max`,"Worker:integration":`max`,"Worker:operations":`xhigh`,"Reviewer:plan":`max`,"Reviewer:code":`max`,"Reviewer:artifact":`max`}}],ue(rI),iI=new Map(rI.map(e=>[e.plan,e])),aI=[{name:`go`,root:{model:`Terra`,effort:`high`},specialistModel:`Luna`,defaultServiceTier:`standard`,routes:ZF(`plus-low`)},QF({name:`plus-low`,root:{model:`Sol`,effort:`low`}}),QF({name:`plus`,root:{model:`Sol`,effort:`medium`}}),QF({name:`plus-high`,root:{model:`Sol`,effort:`high`}}),QF({name:`pro-5x`,root:{model:`Sol`,effort:`high`}}),QF({name:`pro-20x`,root:{model:`Sol`,effort:`xhigh`}})],$F(aI),ue(aI),oI=aI,sI=new Map,cI=new Map;for(let e of oI){sI.set(e.name,e);let t=new Map;for(let n of e.routes)t.set(n.key,n);cI.set(e.name,t)}})),uI=v((()=>{me(),ve(),gP(),jP(),BP(),GP(),mF(),YF(),lI(),CF()}));uI();const dI=Object.freeze([{name:`yes`,kind:`boolean`,usage:`--yes`,description:`Confirm installation.`},{name:`plan`,kind:`value`,usage:`--plan <go|plus-low|plus|plus-high|pro-5x|pro-20x>`,description:`Select routing (default: plus).`},{name:`tier`,kind:`value`,usage:`--tier <standard|fast|fast-all>`,description:`Select service handling (default: standard).`},{name:`work`,kind:`boolean`,usage:`--work / --no-work`,description:`Work plugins (default: false).`},{name:`frontend`,kind:`boolean`,usage:`--frontend / --no-frontend`,description:`Frontend plugins via build-web-apps (default: true).`},{name:`security`,kind:`boolean`,usage:`--security / --no-security`,description:`Security plugins (default: true).`},{name:`computer-use`,kind:`boolean`,usage:`--computer-use / --no-computer-use`,description:`Computer Use plugins (default: false).`},{name:`add-plugin`,kind:`value`,usage:`--add-plugin <id>`,description:`Add a Codex plugin; repeatable.`},{name:`json`,kind:`boolean`,usage:`--json`,description:`Emit one JSON envelope.`}]),fI=new Set([`codex-home`,`plan`,`tier`,`add-plugin`]),pI=new Set([`yes`,`json`,`verbose`,`dry-run`,`computer-use`,`no-computer-use`,`work`,`no-work`,`frontend`,`no-frontend`,`security`,`no-security`]);var mI=class extends Error{code;details;constructor(e,t,n={}){super(t),this.name=`ArgumentError`,this.code=e,this.details=n}};function hI(e){if(e.length===0)throw new mI(`unknown_command`,`A command is required.`);if(e.includes(`-h`)||e.includes(`--help`)||e.includes(`--help=true`))return{command:`help`,positionals:[],options:{}};if(e[0]===`help`)return{command:`help`,positionals:e.slice(1),options:{}};if(e[0]===`-v`||e[0]===`--version`||e[0]===`--version=true`)return hI([`version`,...e.slice(1)]);let t=e[0];if(t!==`install`&&t!==`doctor`&&t!==`remove`&&t!==`version`)throw new mI(`unknown_command`,`Unknown command.`,{command:t??``});let n=[],r={};for(let t=1;t<e.length;t+=1){let i=e[t];if(i===void 0)continue;if(i===`-`||!i.startsWith(`-`)){n.push(i);continue}if(!i.startsWith(`--`)||i===`--`)throw new mI(`invalid_argument`,`Short options are not supported.`,{option:i});let a=i.slice(2),o=a.indexOf(`=`),s=o>=0?a.slice(0,o):a,c=o>=0?a.slice(o+1):void 0,l=s.replaceAll(`_`,`-`);if(!fI.has(l)&&!pI.has(l))throw new mI(`invalid_argument`,`Unknown option.`,{option:`--${s}`});if(fI.has(l)){let n=c??e[t+1];if(n===void 0||n.length===0||n.startsWith(`-`))throw new mI(`invalid_argument`,`Option --${s} requires a value.`,{option:`--${s}`});if(c===void 0&&(t+=1),l===`add-plugin`){let e=r[l];r[l]=Array.isArray(e)?[...e,n]:[n]}else{if(r[l]!==void 0)throw new mI(`invalid_argument`,`Option --${s} may only be supplied once.`,{option:`--${s}`});r[l]=n}continue}if(c!==void 0&&c!==`true`&&c!==`false`)throw new mI(`invalid_argument`,`Option --${s} is boolean.`,{option:`--${s}`});if(r[l]!==void 0)throw new mI(`invalid_argument`,`Option --${s} may only be supplied once.`,{option:`--${s}`});r[l]=c!==`false`}return gI(t,n,r),{command:t,positionals:n,options:r}}function gI(e,t,n){let r=_I(e);for(let t of Object.keys(n))if(!r.has(t))throw new mI(`invalid_argument`,`Option --${t} is not valid for ${e}.`,{option:`--${t}`});let i=e===`version`?{min:0,max:1}:{min:0,max:0};if(t.length<i.min||t.length>i.max)throw new mI(`invalid_argument`,`Invalid positional arguments for ${e}.`);let a=n.plan;if(typeof a==`string`&&!eI(a).ok)throw new mI(`invalid_argument`,`The plan is not supported.`,{plan:a});let o=n.tier;if(typeof o==`string`&&o!==`standard`&&o!==`fast`&&o!==`fast-all`)throw new mI(`invalid_argument`,`The tier is not supported.`,{tier:o});for(let[e,t]of[[`computer-use`,`no-computer-use`],[`work`,`no-work`],[`frontend`,`no-frontend`],[`security`,`no-security`]])if(n[e]!==void 0&&n[t]!==void 0)throw new mI(`invalid_argument`,`Conflicting --${e} and --${t} options.`);if(e===`install`&&n.yes===!1)throw new mI(`invalid_argument`,`--yes cannot be false.`);if(e!==`install`&&Object.keys(n).some(e=>[`plan`,`tier`,`work`,`no-work`,`frontend`,`no-frontend`,`security`,`no-security`,`computer-use`,`no-computer-use`,`add-plugin`].includes(e)))throw new mI(`invalid_argument`,`Installation options are not valid for ${e}.`)}function _I(e){switch(e){case`install`:return new Set([...dI.map(e=>e.name),`no-work`,`no-frontend`,`no-security`,`no-computer-use`,`codex-home`,`verbose`]);case`doctor`:return new Set([`json`,`verbose`,`codex-home`]);case`remove`:return new Set([`yes`,`json`,`verbose`,`codex-home`]);case`version`:return new Set([`json`,`verbose`,`dry-run`]);default:return new Set}}const vI=`Install HolyCodex through Codex native plugin management.
|
|
25
|
+
`)}`:this.toString();else if("Bun"in globalThis)return Mr(da(this),{renderErrorCause:!0});return this}}return Object.assign(e.prototype,Yf),e}(),VT=Symbol.for("effect/Cause/errors/RuntimeException"),K0=Ti({[VT]:VT},"RuntimeException"),$h=Symbol.for("effect/Cause/errors/InterruptedException"),yz=Ti({[$h]:$h},"InterruptedException"),zT=Symbol.for("effect/Cause/errors/IllegalArgument"),W0=Ti({[zT]:zT},"IllegalArgumentException"),KT=Symbol.for("effect/Cause/errors/NoSuchElement"),dc=Ti({[KT]:KT},"NoSuchElementException"),WT=Symbol.for("effect/Cause/errors/InvalidPubSubCapacityException"),xz=Ti({[WT]:WT},"InvalidPubSubCapacityException"),JT=Symbol.for("effect/Cause/errors/ExceededCapacityException"),Sz=Ti({[JT]:JT},"ExceededCapacityException"),GT=Symbol.for("effect/Cause/errors/Timeout"),bz=Ti({[GT]:GT},"TimeoutException"),YT=Symbol.for("effect/Cause/errors/UnknownException"),J0=function(){class e extends cp{_tag="UnknownException";error;constructor(t,r){super(r??"An unknown error occurred",{cause:t});this.error=t}}return Object.assign(e.prototype,{[YT]:YT,name:"UnknownException"}),e}(),yE=d(2,(e,t)=>{switch(e._tag){case $t:return Te(e.effect_instruction_i0);case jt:return Ie(t)}}),Ku=d(2,(e,t)=>{switch(e._tag){case $t:return Te(e.effect_instruction_i0);case jt:return Ie(t(e.effect_instruction_i0))}}),lp=d(2,(e,{onFailure:t,onSuccess:r})=>{switch(e._tag){case $t:return t(e.effect_instruction_i0);case jt:return r(e.effect_instruction_i0)}}),yr=Ie(void 0),cg=d(3,(e,t,{onFailure:r,onSuccess:n})=>{switch(e._tag){case $t:switch(t._tag){case jt:return Te(e.effect_instruction_i0);case $t:return Te(r(e.effect_instruction_i0,t.effect_instruction_i0))}case jt:switch(t._tag){case jt:return Ie(n(e.effect_instruction_i0,t.effect_instruction_i0));case $t:return Te(t.effect_instruction_i0)}}}),Z0=bt((e)=>Ie(e.currentContext)),X0=d(2,(e,t)=>vo(wi,t)(e)),lg=d(2,(e,t)=>vi((r)=>X0(e,t(r))))});var bE,_E;var wE=x(()=>{ma();bE=yw,_E=Mr});var fp="And",mp="Or",hp="InvalidData",gp="MissingData",yp="SourceUnavailable",xp="Unsupported";var tF="effect/ConfigError",TE,ka,Sp=(e,t)=>{let r=Object.create(ka);return r._op=fp,r.left=e,r.right=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`${this.left} and ${this.right}`}}),Object.defineProperty(r,"message",{enumerable:!1,get(){return this.toString()}}),r},bp=(e,t)=>{let r=Object.create(ka);return r._op=mp,r.left=e,r.right=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`${this.left} or ${this.right}`}}),Object.defineProperty(r,"message",{enumerable:!1,get(){return this.toString()}}),r},ug=(e,t,r={pathDelim:"."})=>{let n=Object.create(ka);return n._op=hp,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Invalid data at ${g(this.path,Rn(r.pathDelim))}: "${this.message}")`}}),n},Qr=(e,t,r={pathDelim:"."})=>{let n=Object.create(ka);return n._op=gp,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Missing data at ${g(this.path,Rn(r.pathDelim))}: "${this.message}")`}}),n},pg=(e,t,r,n={pathDelim:"."})=>{let o=Object.create(ka);return o._op=yp,o.path=e,o.message=t,o.cause=r,Object.defineProperty(o,"toString",{enumerable:!1,value(){return`(Source unavailable at ${g(this.path,Rn(n.pathDelim))}: "${this.message}")`}}),o},dg=(e,t,r={pathDelim:"."})=>{let n=Object.create(ka);return n._op=xp,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Unsupported operation at ${g(this.path,Rn(r.pathDelim))}: "${this.message}")`}}),n},Oo,EE;var fg=x(()=>{Ve();er();H();TE=Symbol.for(tF),ka={_tag:"ConfigError",[TE]:TE},Oo=d(2,(e,t)=>{switch(e._op){case fp:return Sp(Oo(e.left,t),Oo(e.right,t));case mp:return bp(Oo(e.left,t),Oo(e.right,t));case hp:return ug([...t,...e.path],e.message);case gp:return Qr([...t,...e.path],e.message);case yp:return pg([...t,...e.path],e.message,e.cause);case xp:return dg([...t,...e.path],e.message)}}),EE=d(3,(e,t,r)=>{let n=[e],o=[];while(n.length>0){let a=n.pop();switch(a._op){case fp:{n.push(a.right),n.push(a.left),o.push(K({_op:"AndCase"}));break}case mp:{n.push(a.right),n.push(a.left),o.push(K({_op:"OrCase"}));break}case hp:{o.push(Z(r.invalidDataCase(t,a.path,a.message)));break}case gp:{o.push(Z(r.missingDataCase(t,a.path,a.message)));break}case yp:{o.push(Z(r.sourceUnavailableCase(t,a.path,a.message,a.cause)));break}case xp:{o.push(Z(r.unsupportedCase(t,a.path,a.message)));break}}}let i=[];while(o.length>0){let a=o.pop();switch(a._op){case"Left":{switch(a.left._op){case"AndCase":{let s=i.pop(),c=i.pop(),l=r.andCase(t,s,c);i.push(l);break}case"OrCase":{let s=i.pop(),c=i.pop(),l=r.orCase(t,s,c);i.push(l);break}}break}case"Right":{i.push(a.right);break}}}if(i.length===0)throw Error("BUG: ConfigError.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");return i.pop()})});var rF="effect/Clock",OE,hc,nF=2147483647,RE,kE,oF,CE,AE=()=>new CE;var mg=x(()=>{fr();th();H();ot();OE=Symbol.for(rF),hc=Vt("effect/Clock"),RE={unsafeSchedule(e,t){let r=Eu(t);if(r>nF)return Qn;let n=!1,o=setTimeout(()=>{n=!0,e()},r);return()=>(clearTimeout(o),!n)}},kE=function(){let e=BigInt(1e6);if(typeof performance>"u"||typeof performance.now!=="function")return()=>BigInt(Date.now())*e;let t;return()=>{if(t===void 0)t=BigInt(Date.now())*e-BigInt(Math.round(performance.now()*1e6));return t+BigInt(Math.round(performance.now()*1e6))}}(),oF=function(){let e=typeof process==="object"&&"hrtime"in process&&typeof process.hrtime.bigint==="function"?process.hrtime:void 0;if(!e)return kE;let t=kE()-e.bigint();return()=>t+e.bigint()}();CE=class CE{[OE]=OE;unsafeCurrentTimeMillis(){return Date.now()}unsafeCurrentTimeNanos(){return oF()}currentTimeMillis=L(()=>this.unsafeCurrentTimeMillis());currentTimeNanos=L(()=>this.unsafeCurrentTimeNanos());scheduler(){return pe(RE)}sleep(e){return _o((t)=>{let r=RE.unsafeSchedule(()=>t(nt),e);return qn(L(r))})}}});var en;var gc=x(()=>{Zl();en=f_});var Ca=(e)=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");var hg=()=>{};var ME,wp;var NE=x(()=>{Ve();er();H();Mu();Ye();fg();ME={_tag:"Empty"},wp=d(2,(e,t)=>{let r=Ks(t),n=e;while(fh(r)){let o=r.head;switch(o._tag){case"Empty":{r=r.tail;break}case"AndThen":{r=Nn(o.first,Nn(o.second,r.tail));break}case"MapName":{n=kr(n,o.f),r=r.tail;break}case"Nested":{n=ta(n,o.name),r=r.tail;break}case"Unnested":{if(g(En(n),y_(o.name)))n=Rr(n),r=r.tail;else return K(Qr(n,`Expected ${o.name} to be in path in ConfigProvider#unnested`));break}}}return Z(n)})});var FE="Constant",LE="Fail",DE="Fallback",qE="Described",UE="Lazy",HE="MapOrFail",$E="Nested",jE="Primitive",BE="Redacted",VE="Sequence",zE="HashMap",KE="ZipWith";var Tp=(e,t)=>[...e,...t],pF="effect/ConfigProvider",WE,GE,dF="effect/ConfigProviderFlat",JE,fF=(e)=>({[WE]:WE,pipe(){return E(this,arguments)},...e}),mF=(e)=>({[JE]:JE,patch:e.patch,load:(t,r,n=!0)=>e.load(t,r,n),enumerateChildren:e.enumerateChildren}),hF=(e)=>fF({load:(t)=>B(nr(e,On(),t,!1),(r)=>Ge(En(r),{onNone:()=>ft(Qr(On(),`Expected a single value having structure: ${t}`)),onSome:pe})),flattened:e}),YE=(e)=>{let{pathDelim:t,seqDelim:r}=Object.assign({},{pathDelim:"_",seqDelim:","},e),n=(c)=>g(c,Rn(t)),o=(c)=>c.split(t),i=()=>typeof process<"u"&&("env"in process)&&typeof process.env==="object"?process.env:{};return hF(mF({load:(c,l,u=!0)=>{let p=n(c),f=i(),h=p in f?N(f[p]):C();return g(h,Si(()=>Qr(c,`Expected ${p} to exist in the process context`)),B((m)=>wF(m,c,l,r,u)))},enumerateChildren:(c)=>L(()=>{let l=i(),f=Object.keys(l).map((h)=>o(h.toUpperCase())).filter((h)=>{for(let m=0;m<c.length;m++){let w=g(c,fm(m)),S=h[m];if(S===void 0||w!==S)return!1}return!0}).flatMap((h)=>h.slice(c.length,c.length+1));return pw(f)}),patch:ME}))},gF=(e,t,r,n)=>{let o=ym(r.length,(c)=>c>=n.length?C():N([e(c),c+1])),i=ym(n.length,(c)=>c>=r.length?C():N([t(c),c+1])),a=Tp(r,o),s=Tp(n,i);return[a,s]},yF=(e,t)=>{let r=t;if(r._tag==="Nested"){let n=e.slice();while(r._tag==="Nested")n.push(r.name),r=r.config;return n}return e},xF,SF=(e)=>EE(e,void 0,xF),nr=(e,t,r,n)=>{let o=r;switch(o._tag){case FE:return pe(kt(o.value));case qE:return Ce(()=>nr(e,t,o.config,n));case LE:return ft(Qr(t,o.message));case DE:return g(Ce(()=>nr(e,t,o.first,n)),rc((i)=>{if(o.condition(i))return g(nr(e,t,o.second,n),rc((a)=>ft(bp(i,a))));return ft(i)}));case UE:return Ce(()=>nr(e,t,o.config(),n));case HE:return Ce(()=>g(nr(e,t,o.original,n),B(gr((i)=>g(o.mapOrFail(i),Si(Oo(yF(t,o.original))))))));case $E:return Ce(()=>nr(e,Tp(t,kt(o.name)),o.config,n));case jE:return g(wp(t,e.patch),B((i)=>g(e.load(i,o,n),B((a)=>{if(a.length===0){let s=g(v_(i),ve(()=>"<n/a>"));return ft(Qr([],`Expected ${o.description} with name ${s}`))}return pe(a)}))));case BE:return Ce(()=>g(nr(e,t,o.original,n),Si(SF),ze(kr(o.redact))));case VE:return g(wp(t,e.patch),B((i)=>g(e.enumerateChildren(i),B(EF),B((a)=>{if(a.length===0)return Ce(()=>ze(nr(e,t,o.config,!0),kt));return g(gr(a,(s)=>nr(e,w_(t,`[${s}]`),o.config,!0)),ze((s)=>{let c=Xl(s);if(c.length===0)return kt(On());return kt(c)}))}))));case zE:return Ce(()=>g(wp(t,e.patch),B((i)=>g(e.enumerateChildren(i),B((a)=>g(a,gr((s)=>nr(e,Tp(i,kt(s)),o.valueConfig,n)),ze((s)=>{if(s.length===0)return kt(xa());return g(TF(s),kr((c)=>Qw(gm(ke(a),c))))})))))));case KE:return Ce(()=>g(nr(e,t,o.left,n),yi,B((i)=>g(nr(e,t,o.right,n),yi,B((a)=>{if(Ee(i)&&Ee(a))return ft(Sp(i.left,a.left));if(Ee(i)&&Rt(a))return ft(i.left);if(Rt(i)&&Ee(a))return ft(a.left);if(Rt(i)&&Rt(a)){let s=g(t,Rn(".")),c=bF(t,s),[l,u]=gF(c,c,g(i.right,kr(Z)),g(a.right,kr(Z)));return g(l,gm(u),gr(([p,f])=>g(tp(p,f),ze(([h,m])=>o.zip(h,m)))))}throw Error("BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues")})))))}},bF=(e,t)=>(r)=>K(Qr(e,`The element at index ${r} in a sequence at path "${t}" was missing`)),_F=(e,t)=>e.split(new RegExp(`\\s*${Ca(t)}\\s*`)),wF=(e,t,r,n,o)=>{if(!o)return g(r.parse(e),Xu({onFailure:Oo(t),onSuccess:kt}));return g(_F(e,n),gr((i)=>r.parse(i.trim())),Si(Oo(t)))},TF=(e)=>Object.keys(e[0]).map((t)=>e.map((r)=>r[t])),EF=(e)=>g(gr(e,OF),Xu({onFailure:()=>On(),onSuccess:vn(en)}),yi,ze(u_)),vF,OF=(e)=>{let t=e.match(vF);if(t!==null){let r=t[2];return g(r!==void 0&&r.length>0?N(r):C(),Or(RF))}return C()},RF=(e)=>{let t=Number.parseInt(e);return Number.isNaN(t)?C():N(t)};var ZE=x(()=>{Ve();fr();er();H();Pu();li();gc();Ye();_e();hg();fg();NE();ot();WE=Symbol.for(pF),GE=Vt("effect/ConfigProvider"),JE=Symbol.for(dF),xF={andCase:(e,t,r)=>Sp(t,r),orCase:(e,t,r)=>bp(t,r),invalidDataCase:(e,t)=>ug(t,"<redacted>"),missingDataCase:(e,t)=>Qr(t,"<redacted>"),sourceUnavailableCase:(e,t,r,n)=>pg(t,"<redacted>",n),unsupportedCase:(e,t)=>dg(t,"<redacted>")},vF=/^(\[(\d+)\])$/});var XE,Ep,QE;var gg=x(()=>{fr();ot();XE=Symbol.for("effect/Console"),Ep=Vt("effect/Console"),QE={[XE]:XE,assert(e,...t){return L(()=>{console.assert(e,...t)})},clear:L(()=>{console.clear()}),count(e){return L(()=>{console.count(e)})},countReset(e){return L(()=>{console.countReset(e)})},debug(...e){return L(()=>{console.debug(...e)})},dir(e,t){return L(()=>{console.dir(e,t)})},dirxml(...e){return L(()=>{console.dirxml(...e)})},error(...e){return L(()=>{console.error(...e)})},group(e){return e?.collapsed?L(()=>console.groupCollapsed(e?.label)):L(()=>console.group(e?.label))},groupEnd:L(()=>{console.groupEnd()}),info(...e){return L(()=>{console.info(...e)})},log(...e){return L(()=>{console.log(...e)})},table(e,t){return L(()=>{console.table(e,t)})},time(e){return L(()=>console.time(e))},timeEnd(e){return L(()=>console.timeEnd(e))},timeLog(e,...t){return L(()=>{console.timeLog(e,...t)})},trace(...e){return L(()=>{console.trace(...e)})},warn(...e){return L(()=>{console.warn(...e)})},unsafe:console}});var AF="effect/Random",ev,tv,rv,PF=(e,t)=>Ce(()=>g(L(()=>Array.from(e)),B((r)=>{let n=[];for(let o=r.length;o>=2;o=o-1)n.push(o);return g(n,xi((o)=>g(t(o),ze((i)=>IF(r,o-1,i)))),Dn(eu(r)))}))),IF=(e,t,r)=>{let n=e[t];return e[t]=e[r],e[r]=n,e},nv=(e)=>new rv(v(e));var ov=x(()=>{Jr();fr();H();Me();ro();ot();ev=Symbol.for(AF),tv=Vt("effect/Random");rv=class rv{seed;[ev]=ev;PRNG;constructor(e){this.seed=e,this.PRNG=new Vf(e)}get next(){return L(()=>this.PRNG.number())}get nextBoolean(){return ze(this.next,(e)=>e>0.5)}get nextInt(){return L(()=>this.PRNG.integer(Number.MAX_SAFE_INTEGER))}nextRange(e,t){return ze(this.next,(r)=>(t-e)*r+e)}nextIntBetween(e,t){return L(()=>this.PRNG.integer(t-e)+e)}shuffle(e){return PF(e,(t)=>this.nextIntBetween(0,t))}}});class sv{name;parent;context;startTime;kind;_tag="Span";spanId;traceId="native";sampled=!0;status;attributes;events=[];links;constructor(e,t,r,n,o,i){this.name=e,this.parent=t,this.context=r,this.startTime=o,this.kind=i,this.status={_tag:"Started",startTime:o},this.attributes=new Map,this.traceId=t._tag==="Some"?t.value.traceId:av(32),this.spanId=av(16),this.links=Array.from(n)}end(e,t){this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,r){this.events.push([e,t,r??{}])}addLinks(e){this.links.push(...e)}}var iv,NF=(e)=>({[iv]:iv,...e}),yc,vp,av,cv,lv;var Op=x(()=>{fr();H();iv=Symbol.for("effect/Tracer"),yc=Vt("effect/Tracer"),vp=Vt("effect/ParentSpan"),av=function(){return function(r){let n="";for(let o=0;o<r;o++)n+="abcdef0123456789".charAt(Math.floor(Math.random()*16));return n}}();cv=NF({span:(e,t,r,n,o,i)=>new sv(e,t,r,n,o,i),context:(e)=>e()}),lv=Bs()("effect/Tracer/DisablePropagation",{defaultValue:Qn})});var DF,xc;var uv=x(()=>{fr();H();mg();ZE();ot();gg();ov();Op();DF=g(go(),Yr(hc,AE()),Yr(Ep,QE),Yr(tv,nv(Math.random())),Yr(GE,YE()),Yr(yc,cv)),xc=j(Symbol.for("effect/DefaultServices/currentServices"),()=>op(DF))});var UF,pv=(e)=>{let t={BaseEffectError:class extends UF{_tag=e}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError};var dv=x(()=>{ot();UF=function(){let e=Symbol.for("effect/Data/Error/plainArgs");return{BaseEffectError:class extends cp{constructor(r){super(r?.message,r?.cause?{cause:r.cause}:void 0);if(r)Object.assign(this,r),Object.defineProperty(this,e,{value:r,enumerable:!1})}toJSON(){return{...this[e],...this}}}}.BaseEffectError}()});var fv,HF,xg;var Sg=x(()=>{wn();fv=_n,HF=e_;xg=class xg extends HF{}});var hv="Sequential",gv="Parallel",$F="ParallelN",Aa,yv,xv=(e)=>({_tag:$F,parallelism:e}),bg=(e)=>e._tag===hv,_g=(e)=>e._tag===gv;var Rp=x(()=>{Aa={_tag:hv},yv={_tag:gv}});var kp,Cp,Ap;var Sv=x(()=>{Rp();kp=Aa,Cp=yv,Ap=xv});function bv(e){return new Un(e)}function _v(){return bv(new Map)}var Tg,Un,BF=(e,t,r,n=!1)=>{let o=e,i=t,a=r,s=n,c=void 0;while(c===void 0)if(we(i)&&we(a)){let l=tt(i)[0],u=Rr(i),p=tt(a)[0],f=tt(a)[1],h=Rr(a);if(l.startTimeMillis<p.startTimeMillis)a=h,s=!0;else if(l.startTimeMillis>p.startTimeMillis)i=u;else if(l.id<p.id)a=h,s=!0;else if(l.id>p.id)i=u;else c=[f,s]}else c=[o.initial,!0];return c},vg,Og,wv=(e,t,r)=>{e.locals.forEach((n,o)=>{let i=n[0][1],a=o.patch(o.fork)(i);if(O(i,a))t.set(o,n);else t.set(o,[[r,a],...n])})},Sc,Rg,Ro,Pa,Eg=(e,t,r,n)=>{let o=e.get(r)??[],i;if(we(o)){let[a,s]=tt(o);if(a[I](t))if(O(s,n))return;else i=[[t,n],...o.slice(1)];else i=[[t,n],...o]}else i=[[t,n]];e.set(r,i)},Tv;var Pp=x(()=>{Ve();le();H();Ye();_e();Tg=Symbol.for("effect/FiberRefs");Un=class Un{locals;[Tg]=Tg;constructor(e){this.locals=e}pipe(){return E(this,arguments)}};vg=d(3,(e,t,r)=>{let n=new Map(e.locals);return r.locals.forEach((o,i)=>{let a=o[0][1];if(!o[0][0][I](t)){if(!n.has(i)){if(O(a,i.initial))return;n.set(i,[[t,i.join(i.initial,a)]]);return}let s=n.get(i),[c,l]=BF(i,s,o);if(l){let u=i.diff(c,a),p=s[0][1],f=i.join(p,i.patch(u)(p));if(!O(p,f)){let h,m=s[0][0];if(m[I](t))h=[[m,f],...s.slice(1)];else h=[[t,f],...s];n.set(i,h)}}}}),new Un(n)}),Og=d(2,(e,t)=>{let r=new Map;return wv(e,r,t),new Un(r)}),Sc=d(2,(e,t)=>{let r=new Map(e.locals);return r.delete(t),new Un(r)}),Rg=d(2,(e,t)=>{if(!e.locals.has(t))return C();return N(tt(e.locals.get(t))[1])}),Ro=d(2,(e,t)=>g(Rg(e,t),ve(()=>t.initial))),Pa=d(2,(e,{fiberId:t,fiberRef:r,value:n})=>{if(e.locals.size===0)return new Un(new Map([[r,[[t,n]]]]));let o=new Map(e.locals);return Eg(o,t,r,n),new Un(o)}),Tv=d(2,(e,{entries:t,forkAs:r})=>{if(e.locals.size===0)return new Un(new Map(t));let n=new Map(e.locals);if(r!==void 0)wv(e,n,r);return t.forEach(([o,i])=>{if(i.length===1)Eg(n,i[0][0],o,i[0][1]);else i.forEach(([a,s])=>{Eg(n,a,o,s)})}),new Un(n)})});var Ev,vv,Ov;var Cg=x(()=>{Pp();Ev=Ro,vv=Tv,Ov=_v});var kv="Empty",Cv="Add",Av="Remove",Pv="Update",Iv="AndThen",Mv,Nv=(e,t)=>{let r=new Map(e.locals),n=Mv;for(let[o,i]of t.locals.entries()){let a=tt(i)[1],s=r.get(o);if(s!==void 0){let c=tt(s)[1];if(!O(c,a))n=Ip({_tag:Pv,fiberRef:o,patch:o.diff(c,a)})(n)}else n=Ip({_tag:Cv,fiberRef:o,value:a})(n);r.delete(o)}for(let[o]of r.entries())n=Ip({_tag:Av,fiberRef:o})(n);return n},Ip,Fv;var Lv=x(()=>{Ve();le();H();Pp();Mv={_tag:kv},Ip=d(2,(e,t)=>({_tag:Iv,first:e,second:t})),Fv=d(3,(e,t,r)=>{let n=r,o=kt(e);while(we(o)){let i=tt(o),a=Rr(o);switch(i._tag){case kv:{o=a;break}case Cv:{n=Pa(n,{fiberId:t,fiberRef:i.fiberRef,value:i.value}),o=a;break}case Av:{n=Sc(n,i.fiberRef),o=a;break}case Pv:{let s=Ro(n,i.fiberRef);n=Pa(n,{fiberId:t,fiberRef:i.fiberRef,value:i.fiberRef.patch(i.patch)(s)}),o=a;break}case Iv:{o=ta(i.first)(ta(i.second)(a));break}}}return n})});var Dv,qv;var Uv=x(()=>{Lv();Dv=Nv,qv=Fv});var Np="effect/FiberStatus",ko,Mp="Done",Hv="Running",$v="Suspended",KF,jv,Bv,Vv,zv,Kv=(e)=>new Bv(e),Wv=(e,t)=>new Vv(e,t),Fp=(e)=>k(e,ko),Jv=(e)=>e._tag===Mp;var Gv=x(()=>{le();H();Me();ge();ko=Symbol.for(Np),KF=me(`${Np}-${Mp}`);jv=class jv{[ko]=ko;_tag=Mp;[M](){return KF}[I](e){return Fp(e)&&e._tag===Mp}};Bv=class Bv{runtimeFlags;[ko]=ko;_tag=Hv;constructor(e){this.runtimeFlags=e}[M](){return g(v(Np),J(v(this._tag)),J(v(this.runtimeFlags)),oe(this))}[I](e){return Fp(e)&&e._tag===Hv&&this.runtimeFlags===e.runtimeFlags}};Vv=class Vv{runtimeFlags;blockingOn;[ko]=ko;_tag=$v;constructor(e,t){this.runtimeFlags=e,this.blockingOn=t}[M](){return g(v(Np),J(v(this._tag)),J(v(this.runtimeFlags)),J(v(this.blockingOn)),oe(this))}[I](e){return Fp(e)&&e._tag===$v&&this.runtimeFlags===e.runtimeFlags&&O(this.blockingOn,e.blockingOn)}};zv=new jv});var Yv,Ag,Zv,Xv;var Qv=x(()=>{Gv();Yv=zv,Ag=Kv,Zv=Wv,Xv=Jv});var GF,YF,ZF,XF,QF,eL,tL,rL,nL,eO,tO=(e)=>{switch(e){case"All":return GF;case"Debug":return eL;case"Error":return ZF;case"Fatal":return YF;case"Info":return QF;case"Trace":return tL;case"None":return rL;case"Warning":return XF}};var rO=x(()=>{H();ot();gc();Zl();GF=rE,YF=nE,ZF=oE,XF=Qh,QF=eg,eL=tg,tL=iE,rL=aE,nL=g(en,Yl((e)=>e.ordinal)),eO=sm(nL)});function fL(e){return Ig("Micro.evaluate: Not implemented")}class Ug{tasks=[];running=!1;scheduleTask(e,t){if(this.tasks.push(e),!this.running)this.running=!0,bL(this.afterScheduled)}afterScheduled=()=>{this.running=!1,this.runTasks()};runTasks(){let e=this.tasks;this.tasks=[];for(let t=0,r=e.length;t<r;t++)e[t]()}shouldYield(e){return e.currentOpCount>=e.getRef(mO)}flush(){while(this.tasks.length>0)this.runTasks()}}var iL,Dp,nO,aL,Mg,aO,sL=(e,t=[])=>new aO(e,t),sO,cL=(e=[])=>new sO(e),lL=(e)=>e._tag==="Interrupt",oO,uL,cO,iO,lO,at,Pg,Ma,Ia,qp,Lp,pL,dL,Hp=(e)=>({...dL,[lO]:e.op,[Pg]:e.eval??fL,[Ma]:e.contA,[Ia]:e.contE,[qp]:e.ensure}),Ng=(e)=>{let t=Hp(e);return function(){let r=Object.create(t);return r[at]=e.single===!1?arguments:arguments[0],r}},uO=(e)=>{let t={...Hp(e),[Dp]:Dp,_tag:e.op,get[e.prop](){return this[at]},toJSON(){return{_id:"MicroExit",_tag:e.op,[e.prop]:this[at]}},[I](r){return xL(r)&&r._tag===e.op&&O(this[at],r[at])},[M](){return oe(this,J(me(e.op))(v(this[at])))}};return function(r){let n=Object.create(t);return n[at]=r,n[Ma]=void 0,n[Ia]=void 0,n[qp]=void 0,n}},Fg,pO,mL,hL,gL,Lg,Up,yL,xL=(e)=>k(e,Dp),dO,Dg,qg,Ig=(e)=>Dg(sL(e)),SL,bL,_L,fO,mO,$p,wL,TL,EL,hO,vL=(e)=>Lg((t)=>{if(t.interruptible)return e;if(t.interruptible=!0,t._stack.push(hO(!1)),t._interrupted)return qg;return e}),OL=(e)=>Lg((t)=>{if(!t.interruptible)return e(ce);return t.interruptible=!1,t._stack.push(hO(!0)),e(vL)}),gO=(e,t)=>{let r=new cO($p.context(t?.scheduler??new Ug));if(r.evaluate(e),t?.signal)if(t.signal.aborted)r.unsafeInterrupt();else{let n=()=>r.unsafeInterrupt();t.signal.addEventListener("abort",n,{once:!0}),r.addObserver(()=>t.signal.removeEventListener("abort",n))}return r};var yO=x(()=>{fr();Sg();le();H();Me();Be();_u();_e();ge();ro();iL=Symbol.for("effect/Micro"),Dp=Symbol.for("effect/Micro/MicroExit"),nO=Symbol.for("effect/Micro/MicroCause"),aL={_E:ce};Mg=class Mg extends globalThis.Error{_tag;traces;[nO];constructor(e,t,r){let n=`MicroCause.${e}`,o,i,a;if(t instanceof globalThis.Error){o=`(${n}) ${t.name}`,i=t.message;let s=i.split(`
|
|
26
|
+
`).length;a=t.stack?`(${n}) ${t.stack.split(`
|
|
27
|
+
`).slice(0,s+3).join(`
|
|
28
|
+
`)}`:`${o}: ${i}`}else o=n,i=bn(t,0),a=`${o}: ${i}`;if(r.length>0)a+=`
|
|
29
|
+
${r.join(`
|
|
30
|
+
`)}`;super(i);this._tag=e,this.traces=r,this[nO]=aL,this.name=o,this.stack=a}pipe(){return E(this,arguments)}toString(){return this.stack}[re](){return this.stack}};aO=class aO extends Mg{defect;constructor(e,t=[]){super("Die",e,t);this.defect=e}};sO=class sO extends Mg{constructor(e=[]){super("Interrupt","interrupted",e)}};oO=Symbol.for("effect/Micro/MicroFiber"),uL={_A:ce,_E:ce};cO=class cO{context;interruptible;[oO];_stack=[];_observers=[];_exit;_children;currentOpCount=0;constructor(e,t=!0){this.context=e,this.interruptible=t,this[oO]=uL}getRef(e){return Cw(this.context,e)}addObserver(e){if(this._exit)return e(this._exit),ms;return this._observers.push(e),()=>{let t=this._observers.indexOf(e);if(t>=0)this._observers.splice(t,1)}}_interrupted=!1;unsafeInterrupt(){if(this._exit)return;if(this._interrupted=!0,this.interruptible)this.evaluate(qg)}unsafePoll(){return this._exit}evaluate(e){if(this._exit)return;else if(this._yielded!==void 0){let n=this._yielded;this._yielded=void 0,n()}let t=this.runLoop(e);if(t===Lp)return;let r=iO.interruptChildren&&iO.interruptChildren(this);if(r!==void 0)return this.evaluate(Up(r,()=>t));this._exit=t;for(let n=0;n<this._observers.length;n++)this._observers[n](t);this._observers.length=0}runLoop(e){let t=!1,r=e;this.currentOpCount=0;try{while(!0){if(this.currentOpCount++,!t&&this.getRef($p).shouldYield(this)){t=!0;let n=r;r=Up(hL,()=>n)}if(r=r[Pg](this),r===Lp){let n=this._yielded;if(Dp in n)return this._yielded=void 0,n;return Lp}}}catch(n){if(!k(r,Pg))return Ig(`MicroFiber.runLoop: Not a valid effect: ${String(r)}`);return Ig(n)}}getCont(e){while(!0){let t=this._stack.pop();if(!t)return;let r=t[qp]&&t[qp](this);if(r)return{[e]:r};if(t[e])return t}}_yielded=void 0;yieldWith(e){return this._yielded=e,Lp}children(){return this._children??=new Set}};iO=j("effect/Micro/fiberMiddleware",()=>({interruptChildren:void 0})),lO=Symbol.for("effect/Micro/identifier"),at=Symbol.for("effect/Micro/args"),Pg=Symbol.for("effect/Micro/evaluate"),Ma=Symbol.for("effect/Micro/successCont"),Ia=Symbol.for("effect/Micro/failureCont"),qp=Symbol.for("effect/Micro/ensureCont"),Lp=Symbol.for("effect/Micro/Yield"),pL={_A:ce,_E:ce,_R:ce},dL={...fv,_op:"Micro",[iL]:pL,pipe(){return E(this,arguments)},[Symbol.iterator](){return new Gi(new Sn(this))},toJSON(){return{_id:"Micro",op:this[lO],...at in this?{args:this[at]}:void 0}},toString(){return he(this)},[re](){return he(this)}};Fg=uO({op:"Success",prop:"value",eval(e){let t=e.getCont(Ma);return t?t[Ma](this[at],e):e.yieldWith(this)}}),pO=uO({op:"Failure",prop:"cause",eval(e){let t=e.getCont(Ia);while(lL(this[at])&&t&&e.interruptible)t=e.getCont(Ia);return t?t[Ia](this[at],e):e.yieldWith(this)}}),mL=Ng({op:"Yield",eval(e){let t=!1;return e.getRef($p).scheduleTask(()=>{if(t)return;e.evaluate(SL)},this[at]??0),e.yieldWith(()=>{t=!0})}}),hL=mL(0),gL=Fg(void 0),Lg=Ng({op:"WithMicroFiber",eval(e){return this[at](e)}}),Up=d(2,(e,t)=>{let r=Object.create(yL);return r[at]=e,r[Ma]=t,r}),yL=Hp({op:"OnSuccess",eval(e){return e._stack.push(this),this[at]}}),dO=Fg,Dg=pO,qg=Dg(cL()),SL=dO(void 0),bL="setImmediate"in globalThis?globalThis.setImmediate:(e)=>setTimeout(e,0);_L=d(2,(e,t)=>Lg((r)=>{let n=r.context;return r.context=t(n),EL(e,()=>(r.context=n,gL))})),fO=d(2,(e,t)=>_L(e,js(t)));mO=class mO extends Bs()("effect/Micro/currentMaxOpsBeforeYield",{defaultValue:()=>2048}){};$p=class $p extends Bs()("effect/Micro/currentScheduler",{defaultValue:()=>new Ug}){};wL=d(2,(e,t)=>{let r=Object.create(TL);return r[at]=e,r[Ma]=t.onSuccess,r[Ia]=t.onFailure,r}),TL=Hp({op:"OnSuccessAndFailure",eval(e){return e._stack.push(this),this[at]}}),EL=d(2,(e,t)=>OL((r)=>wL(r(e),{onFailure:(n)=>Up(t(Dg(n)),()=>pO(n)),onSuccess:(n)=>Up(t(dO(n)),()=>Fg(n))}))),hO=Ng({op:"SetInterruptible",ensure(e){if(e.interruptible=this[at],e._interrupted&&e.interruptible)return()=>qg}})});class jp{scheduleDrain;running=!1;tasks=new Hg;constructor(e){this.scheduleDrain=e}starveInternal=(e)=>{let t=this.tasks.buckets;this.tasks.buckets=[];for(let[r,n]of t)for(let o=0;o<n.length;o++)n[o]();if(this.tasks.buckets.length===0)this.running=!1;else this.starve(e)};starve(e=0){this.scheduleDrain(e,this.starveInternal)}scheduleTask(e,t){if(this.tasks.scheduleTask(e,t),!this.running)this.running=!0,this.starve()}static cached(e){let t=new jp(e),r=new WeakMap;return(n)=>{if(n===void 0)return t;let o=r.get(n);if(o===void 0)o=new jp(e),r.set(n,o);return o}}}class Hg{buckets=[];scheduleTask(e,t){let r=this.buckets.length,n=void 0,o=0;for(;o<r;o++)if(this.buckets[o][0]<=t)n=this.buckets[o];else break;if(n&&n[0]===t)n[1].push(e);else if(o===r)this.buckets.push([t,[e]]);else this.buckets.splice(o,0,[t,[e]])}}class xO{maxNextTickBeforeTimer;getRunner=jp.cached((e,t)=>{if(e>=this.maxNextTickBeforeTimer)setTimeout(()=>t(0),0);else Promise.resolve(void 0).then(()=>t(e+1))});constructor(e){this.maxNextTickBeforeTimer=e}shouldYield(e){return e.currentOpCount>e.getFiberRef(rg)?e.getFiberRef(va):!1}scheduleTask(e,t,r){this.getRunner(r).scheduleTask(e,t)}}class bc{tasks=new Hg;deferred=!1;scheduleTask(e,t,r){if(this.deferred)SO.scheduleTask(e,t,r);else this.tasks.scheduleTask(e,t)}shouldYield(e){return e.currentOpCount>e.getFiberRef(rg)?e.getFiberRef(va):!1}flush(){while(this.tasks.buckets.length>0){let e=this.tasks.buckets;this.tasks.buckets=[];for(let[t,r]of e)for(let n=0;n<r.length;n++)r[n]()}this.deferred=!0}}var SO,Bp;var Vp=x(()=>{ot();SO=j(Symbol.for("effect/Scheduler/defaultScheduler"),()=>new xO(2048));Bp=j(Symbol.for("effect/FiberRef/currentScheduler"),()=>_t(SO))});var zp;var $g=x(()=>{ot();zp=j(Symbol.for("effect/FiberRef/currentRequestMap"),()=>_t(new Map))});var jg=(e,t,r,n)=>{switch(e){case void 0:return t();case"unbounded":return r();case"inherit":return bi(dE,(o)=>o==="unbounded"?r():o>1?n(o):t());default:return e>1?n(e):t()}};var _O=x(()=>{ot()});var Bg=(e)=>e.replace(/[\s="]/g,"_"),wO=(e)=>(t)=>`${Bg(t.label)}=${e-t.startTime}ms`;var TO="effect/MetricLabel",Vg,EO,vO=(e,t)=>new EO(e,t),PL=(e)=>k(e,Vg);var OO=x(()=>{le();Me();_e();ge();Vg=Symbol.for(TO);EO=class EO{key;value;[Vg]=Vg;_hash;constructor(e,t){this.key=e,this.value=t,this._hash=me(TO+this.key+this.value)}[M](){return this._hash}[I](e){return PL(e)&&this.key===e.key&&this.value===e.value}pipe(){return E(this,arguments)}}});var zg;var RO=x(()=>{fr();Ye();Op();zg=Or((e)=>Hs(e.context,lv)?e._tag==="Span"?zg(e.parent):C():N(e))});var kO;var CO=x(()=>{ot();kO=ig});var Kg="InterruptSignal",Wg="Stateful",Jg="Resume",Gg="YieldNow",Kp=(e)=>({_tag:"InterruptSignal",cause:e}),Na=(e)=>({_tag:"Stateful",onFiber:e}),Oi=(e)=>({_tag:"Resume",effect:e}),AO=()=>({_tag:"YieldNow"});var DL="effect/FiberScope",Wp,IO,MO,NO=(e)=>new MO(e.id(),e),_c;var Yg=x(()=>{ya();Wp=Symbol.for(DL);IO=class IO{[Wp]=Wp;fiberId=mr;roots=new Set;add(e,t){this.roots.add(t),t.addObserver(()=>{this.roots.delete(t)})}};MO=class MO{fiberId;parent;[Wp]=Wp;constructor(e,t){this.fiberId=e,this.parent=t}add(e,t){this.parent.tell(Na((r)=>{r.addChild(t),t.addObserver(()=>{r.removeChild(t)})}))}};_c=j(Symbol.for("effect/FiberScope/Global"),()=>new IO)});var HL="effect/Fiber",Zg,Xg,$L,jL="effect/Fiber",LO,Jp=(e)=>rp(oc(e.await),e.inheritAll),tW,Co="effect/FiberCurrent";var DO=x(()=>{ya();Ye();_e();ot();wn();Zg=Symbol.for(HL),Xg={_E:(e)=>e,_A:(e)=>e},$L={[Zg]:Xg,pipe(){return E(this,arguments)}},LO=Symbol.for(jL),tW={...oo,commit(){return Jp(this)},...$L,id:()=>mr,await:cc,children:pe([]),inheritAll:cc,poll:pe(C()),interruptAsFork:()=>cc}});var VL="effect/Logger",qO,UO,Gp=(e)=>({[qO]:UO,log:e,pipe(){return E(this,arguments)}}),oW,zL,KL=(e,t)=>({annotations:r,cause:n,date:o,fiberId:i,logLevel:a,message:s,spans:c})=>{let l=(m)=>m.match(zL)?m:e(m),u=(m,w)=>`${Bg(m)}=${l(w)}`,p=(m,w)=>" "+u(m,w),f=u("timestamp",o.toISOString());f+=p("level",a.label),f+=p("fiber",Cu(i));let h=um(s);for(let m=0;m<h.length;m++)f+=p("message",bn(h[m],t));if(!qm(n))f+=p("cause",Mr(n,{renderErrorCause:!0}));for(let m of c)f+=" "+wO(o.getTime())(m);for(let[m,w]of r)f+=p(m,bn(w,t));return f},WL=(e)=>`"${e.replace(/\\([\s\S])|(")/g,"\\$1$2")}"`,HO,Ri,iW,$O,aW,sW;var jO=x(()=>{Ve();H();Be();_e();ma();ah();qO=Symbol.for(VL),UO={_Message:(e)=>e,_Output:(e)=>e},oW={[qO]:UO,log:ms,pipe(){return E(this,arguments)}},zL=/^[^\s"=]*$/,HO=Gp(KL(WL)),Ri={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},iW={None:[],All:[],Trace:[Ri.gray],Debug:[Ri.blue],Info:[Ri.green],Warning:[Ri.yellow],Error:[Ri.red],Fatal:[Ri.bgBrightRed,Ri.black]},$O=typeof process==="object"&&process!==null&&typeof process.stdout==="object"&&process.stdout!==null,aW=$O&&process.stdout.isTTY===!0,sW=$O||"Deno"in globalThis});var BO="effect/MetricBoundaries",Qg,VO,GL=(e)=>k(e,Qg),YL=(e)=>{let t=g(e,pm(rt(Number.POSITIVE_INFINITY)),xm);return new VO(t)},zO=(e)=>g(lm(e.count-1,(t)=>e.start*Math.pow(e.factor,t)),Ms,YL);var KO=x(()=>{Ve();Jr();le();H();Me();_e();ge();Qg=Symbol.for(BO);VO=class VO{values;[Qg]=Qg;constructor(e){this.values=e,this._hash=g(me(BO),J(Qt(this.values)))}_hash;[M](){return this._hash}[I](e){return GL(e)&&O(this.values,e.values)}pipe(){return E(this,arguments)}}});var XL="effect/MetricKeyType",WO,JO="effect/MetricKeyType/Counter",ey,QL="effect/MetricKeyType/Frequency",eD,tD="effect/MetricKeyType/Gauge",rD,GO="effect/MetricKeyType/Histogram",ty,nD="effect/MetricKeyType/Summary",oD,YO,ZO,XO,QO=(e)=>new ZO(e?.incremental??!1,e?.bigint??!1),eR=(e)=>new XO(e),ry=(e)=>k(e,ey),tR=(e)=>k(e,eD),rR=(e)=>k(e,rD),ny=(e)=>k(e,ty),nR=(e)=>k(e,oD);var oy=x(()=>{le();H();Me();_e();ge();WO=Symbol.for(XL),ey=Symbol.for(JO),eD=Symbol.for(QL),rD=Symbol.for(tD),ty=Symbol.for(GO),oD=Symbol.for(nD),YO={_In:(e)=>e,_Out:(e)=>e};ZO=class ZO{incremental;bigint;[WO]=YO;[ey]=ey;constructor(e,t){this.incremental=e,this.bigint=t,this._hash=me(JO)}_hash;[M](){return this._hash}[I](e){return ry(e)}pipe(){return E(this,arguments)}};XO=class XO{boundaries;[WO]=YO;[ty]=ty;constructor(e){this.boundaries=e,this._hash=g(me(GO),J(v(this.boundaries)))}_hash;[M](){return this._hash}[I](e){return ny(e)&&O(this.boundaries,e.boundaries)}pipe(){return E(this,arguments)}}});var iD="effect/MetricKey",iR,aD,sD,Yp,cD=(e)=>k(e,iR),aR=(e,t)=>new Yp(e,QO(t),Tn(t?.description)),sR=(e,t,r)=>new Yp(e,eR(t),Tn(r)),cR;var lR=x(()=>{Ve();le();H();Me();Ye();_e();ge();oy();iR=Symbol.for(iD),aD={_Type:(e)=>e},sD=so(O);Yp=class Yp{name;keyType;description;tags;[iR]=aD;constructor(e,t,r,n=[]){this.name=e,this.keyType=t,this.description=r,this.tags=n,this._hash=g(me(this.name+this.description),J(v(this.keyType)),J(Qt(this.tags)))}_hash;[M](){return this._hash}[I](e){return cD(e)&&this.name===e.name&&O(this.keyType,e.keyType)&&O(this.description,e.description)&&sD(this.tags,e.tags)}pipe(){return E(this,arguments)}};cR=d(2,(e,t)=>t.length===0?e:new Yp(e.name,e.keyType,e.description,ao(e.tags,t)))});class pR{backing;constructor(e){this.backing=e}currentBucket;next(){if(this.currentBucket===void 0){let t=this.backing.next();if(t.done)return t;this.currentBucket=t.value[Symbol.iterator]()}let e=this.currentBucket.next();if(e.done)return this.currentBucket=void 0,this.next();return e}}var uR,uD,iy,dR=()=>{let e=Object.create(uD);return e.referential=new Map,e.buckets=new Map,e.bucketsSize=0,e},Ao,pD=(e,t,r,n=!1)=>{for(let o=0,i=t.length;o<i;o++)if(r[I](t[o][0])){let a=t[o][1];if(n)t.splice(o,1),e.bucketsSize--;return N(a)}return C()},Fa,La,dD=(e,t,r)=>{for(let n=0,o=t.length;n<o;n++)if(r[I](t[n][0])){t.splice(n,1),e.bucketsSize--;return}};var fR=x(()=>{le();H();Me();Be();Ye();_e();uR=Symbol.for("effect/MutableHashMap"),uD={[uR]:uR,[Symbol.iterator](){return new iy(this)},toString(){return he(this.toJSON())},toJSON(){return{_id:"MutableHashMap",values:Array.from(this).map(ue)}},[re](){return this.toJSON()},pipe(){return E(this,arguments)}};iy=class iy{self;referentialIterator;bucketIterator;constructor(e){this.self=e,this.referentialIterator=e.referential[Symbol.iterator]()}next(){if(this.bucketIterator!==void 0)return this.bucketIterator.next();let e=this.referentialIterator.next();if(e.done)return this.bucketIterator=new pR(this.self.buckets.values()),this.next();return e}[Symbol.iterator](){return new iy(this.self)}};Ao=d(2,(e,t)=>{if(ws(t)===!1)return e.referential.has(t)?N(e.referential.get(t)):C();let r=t[M](),n=e.buckets.get(r);if(n===void 0)return C();return pD(e,n,t)}),Fa=d(2,(e,t)=>Re(Ao(e,t))),La=d(3,(e,t,r)=>{if(ws(t)===!1)return e.referential.set(t,r),e;let n=t[M](),o=e.buckets.get(n);if(o===void 0)return e.buckets.set(n,[[t,r]]),e.bucketsSize++,e;return dD(e,o,t),o.push([t,r]),e.bucketsSize++,e})});var mD="effect/MetricState",wc,mR="effect/MetricState/Counter",ay,hR="effect/MetricState/Frequency",sy,gR="effect/MetricState/Gauge",cy,yR="effect/MetricState/Histogram",ly,xR="effect/MetricState/Summary",uy,Tc,SR,hD,bR,_R,wR,TR,ER=(e)=>new SR(e),vR=(e)=>new bR(e),OR=(e)=>new _R(e),RR=(e)=>new wR(e.buckets,e.count,e.min,e.max,e.sum),kR=(e)=>new TR(e.error,e.quantiles,e.count,e.min,e.max,e.sum),gD=(e)=>k(e,ay),yD=(e)=>k(e,sy),xD=(e)=>k(e,cy),SD=(e)=>k(e,ly),bD=(e)=>k(e,uy);var CR=x(()=>{Ve();le();H();Me();_e();ge();wc=Symbol.for(mD),ay=Symbol.for(mR),sy=Symbol.for(hR),cy=Symbol.for(gR),ly=Symbol.for(yR),uy=Symbol.for(xR),Tc={_A:(e)=>e};SR=class SR{count;[wc]=Tc;[ay]=ay;constructor(e){this.count=e}[M](){return g(v(mR),J(v(this.count)),oe(this))}[I](e){return gD(e)&&this.count===e.count}pipe(){return E(this,arguments)}};hD=so(O);bR=class bR{occurrences;[wc]=Tc;[sy]=sy;constructor(e){this.occurrences=e}_hash;[M](){return g(me(hR),J(Qt(ke(this.occurrences.entries()))),oe(this))}[I](e){return yD(e)&&hD(ke(this.occurrences.entries()),ke(e.occurrences.entries()))}pipe(){return E(this,arguments)}};_R=class _R{value;[wc]=Tc;[cy]=cy;constructor(e){this.value=e}[M](){return g(v(gR),J(v(this.value)),oe(this))}[I](e){return xD(e)&&this.value===e.value}pipe(){return E(this,arguments)}};wR=class wR{buckets;count;min;max;sum;[wc]=Tc;[ly]=ly;constructor(e,t,r,n,o){this.buckets=e,this.count=t,this.min=r,this.max=n,this.sum=o}[M](){return g(v(yR),J(v(this.buckets)),J(v(this.count)),J(v(this.min)),J(v(this.max)),J(v(this.sum)),oe(this))}[I](e){return SD(e)&&O(this.buckets,e.buckets)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return E(this,arguments)}};TR=class TR{error;quantiles;count;min;max;sum;[wc]=Tc;[uy]=uy;constructor(e,t,r,n,o,i){this.error=e,this.quantiles=t,this.count=r,this.min=n,this.max=o,this.sum=i}[M](){return g(v(xR),J(v(this.error)),J(v(this.quantiles)),J(v(this.count)),J(v(this.min)),J(v(this.max)),J(v(this.sum)),oe(this))}[I](e){return bD(e)&&this.error===e.error&&O(this.quantiles,e.quantiles)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return E(this,arguments)}}});var wD="effect/MetricHook",TD,ED,Ec=(e)=>({[TD]:ED,pipe(){return E(this,arguments)},...e}),AR,IR=(e)=>{let t=e.keyType.bigint?AR:0,r=e.keyType.incremental?e.keyType.bigint?(o)=>o>=AR:(o)=>o>=0:(o)=>!0,n=(o)=>{if(r(o))t=t+o};return Ec({get:()=>ER(t),update:n,modify:n})},MR=(e)=>{let t=new Map;for(let n of e.keyType.preregisteredWords)t.set(n,0);let r=(n)=>{let o=t.get(n)??0;t.set(n,o+1)};return Ec({get:()=>vR(t),update:r,modify:r})},NR=(e,t)=>{let r=t;return Ec({get:()=>OR(r),update:(n)=>{r=n},modify:(n)=>{r=r+n}})},FR=(e)=>{let t=e.keyType.boundaries.values,r=t.length,n=new Uint32Array(r+1),o=new Float64Array(r),i=0,a=0,{MAX_VALUE:s,MIN_VALUE:c}=Number;g(t,vn(en),kr((p,f)=>{o[f]=p}));let l=(p)=>{let f=0,h=r;while(f!==h){let m=Math.floor(f+(h-f)/2),w=o[m];if(p<=w)h=m;else f=m;if(h===f+1)if(p<=o[f])h=f;else f=h}if(n[f]=n[f]+1,i=i+1,a=a+p,p<s)s=p;if(p>c)c=p},u=()=>{let p=ri(r),f=0;for(let h=0;h<r;h++){let m=o[h],w=n[h];f=f+w,p[h]=[m,f]}return p};return Ec({get:()=>RR({buckets:u(),count:i,min:s,max:c,sum:a}),update:l,modify:l})},LR=(e)=>{let{error:t,maxAge:r,maxSize:n,quantiles:o}=e.keyType,i=g(o,vn(en)),a=ri(n),s=0,c=0,l=0,u=0,p=0,f=(m)=>{let w=[],S=0;while(S!==n-1){let y=a[S];if(y!=null){let[R,P]=y,z=Tu(m-R);if(jw(z,Qm)&&$w(z,r))w.push(P)}S=S+1}return vD(t,i,vn(w,en))},h=(m,w)=>{if(n>0){s=s+1;let S=s%n;a[S]=[w,m]}u=c===0?m:Math.min(u,m),p=c===0?m:Math.max(p,m),c=c+1,l=l+m};return Ec({get:()=>kR({error:t,quantiles:f(Date.now()),count:c,min:u,max:p,sum:l}),update:([m,w])=>h(m,w),modify:([m,w])=>h(m,w)})},vD=(e,t,r)=>{let n=r.length;if(!we(t))return On();let o=t[0],i=t.slice(1),a=PR(e,n,C(),0,o,r),s=kt(a);return i.forEach((c)=>{s.push(PR(e,n,a.value,a.consumed,c,a.rest))}),kr(s,(c)=>[c.quantile,c.value])},PR=(e,t,r,n,o,i)=>{let a=e,s=t,c=r,l=n,u=o,p=i,f=e,h=t,m=r,w=n,S=o,y=i;while(!0){if(!we(p))return{quantile:u,value:C(),consumed:l,rest:[]};if(u===1)return{quantile:u,value:N(mm(p)),consumed:l+p.length,rest:[]};let R=tt(p),P=O_(p,(F)=>F===R),z=u*s,Y=a/2*z,D=l+P[0].length,te=Math.abs(D-z);if(D<z-Y){f=a,h=s,m=En(p),w=D,S=u,y=P[1],a=f,s=h,c=m,l=w,u=S,p=y;continue}if(D>z+Y){let F=Ne(c)?N(R):c;return{quantile:u,value:F,consumed:l,rest:p}}switch(c._tag){case"None":{f=a,h=s,m=En(p),w=D,S=u,y=P[1],a=f,s=h,c=m,l=w,u=S,p=y;continue}case"Some":{let F=Math.abs(z-c.value);if(te<F){f=a,h=s,m=En(p),w=D,S=u,y=P[1],a=f,s=h,c=m,l=w,u=S,p=y;continue}return{quantile:u,value:N(c.value),consumed:l,rest:p}}}}throw Error("BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues")};var DR=x(()=>{Ve();th();H();gc();Ye();_e();CR();TD=Symbol.for(wD),ED={_In:(e)=>e,_Out:(e)=>e},AR=BigInt(0)});var RD="effect/MetricPair",kD,CD,qR=(e,t)=>({[kD]:CD,metricKey:e,metricState:t,pipe(){return E(this,arguments)}});var UR=x(()=>{_e();kD=Symbol.for(RD),CD={_Type:(e)=>e}});var PD="effect/MetricRegistry",HR,$R,jR=()=>new $R;var BR=x(()=>{H();fR();Ye();DR();oy();UR();HR=Symbol.for(PD);$R=class $R{[HR]=HR;map=dR();snapshot(){let e=[];for(let[t,r]of this.map)e.push(qR(t,r.get()));return e}get(e){let t=g(this.map,Ao(e),Bt);if(t==null){if(ry(e.keyType))return this.getCounter(e);if(rR(e.keyType))return this.getGauge(e);if(tR(e.keyType))return this.getFrequency(e);if(ny(e.keyType))return this.getHistogram(e);if(nR(e.keyType))return this.getSummary(e);throw Error("BUG: MetricRegistry.get - unknown MetricKeyType - please report an issue at https://github.com/Effect-TS/effect/issues")}else return t}getCounter(e){let t=g(this.map,Ao(e),Bt);if(t==null){let r=IR(e);if(!g(this.map,Fa(e)))g(this.map,La(e,r));t=r}return t}getFrequency(e){let t=g(this.map,Ao(e),Bt);if(t==null){let r=MR(e);if(!g(this.map,Fa(e)))g(this.map,La(e,r));t=r}return t}getGauge(e){let t=g(this.map,Ao(e),Bt);if(t==null){let r=NR(e,e.keyType.bigint?BigInt(0):0);if(!g(this.map,Fa(e)))g(this.map,La(e,r));t=r}return t}getHistogram(e){let t=g(this.map,Ao(e),Bt);if(t==null){let r=FR(e);if(!g(this.map,Fa(e)))g(this.map,La(e,r));t=r}return t}getSummary(e){let t=g(this.map,Ao(e),Bt);if(t==null){let r=LR(e);if(!g(this.map,Fa(e)))g(this.map,La(e,r));t=r}return t}}});var MD="effect/Metric",ND,FD,VR,zR=function(e,t,r,n){let o=Object.assign((i)=>Qu(i,(a)=>DD(o,a)),{[ND]:FD,keyType:e,unsafeUpdate:t,unsafeValue:r,unsafeModify:n,register(){return this.unsafeValue([]),this},pipe(){return E(this,arguments)}});return o},vc=(e,t)=>KR(aR(e,t)),KR=(e)=>{let t,r=new WeakMap,n=(o)=>{if(o.length===0){if(t!==void 0)return t;return t=VR.get(e),t}let i=r.get(o);if(i!==void 0)return i;return i=VR.get(cR(e,o)),r.set(o,i),i};return zR(e.keyType,(o,i)=>n(i).update(o),(o)=>n(o).get(),(o,i)=>n(i).modify(o))},WR=(e,t,r)=>KR(sR(e,t,r)),JR,LD,DD;var GR=x(()=>{Ve();H();_e();ot();lR();OO();BR();ND=Symbol.for(MD),FD={_Type:(e)=>e,_In:(e)=>e,_Out:(e)=>e},VR=j(Symbol.for("effect/Metric/globalMetricRegistry"),()=>jR()),JR=d(3,(e,t,r)=>LD(e,[vO(t,r)])),LD=d(2,(e,t)=>zR(e.keyType,(r,n)=>e.unsafeUpdate(r,ao(t,n)),(r)=>e.unsafeValue(ao(t,r)),(r,n)=>e.unsafeModify(r,ao(t,n)))),DD=d(2,(e,t)=>bi(uc,(r)=>L(()=>e.unsafeUpdate(t,r))))});var UD="effect/Request",HD,$D,qW,YR;var ZR=x(()=>{H();$g();ot();wn();HD=Symbol.for(UD),$D={_E:(e)=>e,_A:(e)=>e},qW={...ks,[HD]:$D},YR=d(2,(e,t)=>bi(zp,(r)=>L(()=>{if(r.has(e)){let n=r.get(e);if(!n.state.completed)n.state.completed=!0,pp(n.result,t)}})))});var jD="effect/Supervisor",Zp,py,Xp,Qp,dy=(e)=>k(e,Zp)&&bs(e,"Zip"),XR,BD=(e)=>new XR(e),ki;var ed=x(()=>{H();ge();ot();Zp=Symbol.for(jD),py={_T:(e)=>e};Xp=class Xp{underlying;value0;[Zp]=py;constructor(e,t){this.underlying=e,this.value0=t}get value(){return this.value0}onStart(e,t,r,n){this.underlying.onStart(e,t,r,n)}onEnd(e,t){this.underlying.onEnd(e,t)}onEffect(e,t){this.underlying.onEffect(e,t)}onSuspend(e){this.underlying.onSuspend(e)}onResume(e){this.underlying.onResume(e)}map(e){return new Xp(this,g(this.value,ze(e)))}zip(e){return new Qp(this,e)}};Qp=class Qp{left;right;_tag="Zip";[Zp]=py;constructor(e,t){this.left=e,this.right=t}get value(){return tp(this.left.value,this.right.value)}onStart(e,t,r,n){this.left.onStart(e,t,r,n),this.right.onStart(e,t,r,n)}onEnd(e,t){this.left.onEnd(e,t),this.right.onEnd(e,t)}onEffect(e,t){this.left.onEffect(e,t),this.right.onEffect(e,t)}onSuspend(e){this.left.onSuspend(e),this.right.onSuspend(e)}onResume(e){this.left.onResume(e),this.right.onResume(e)}map(e){return new Xp(this,g(this.value,ze(e)))}zip(e){return new Qp(this,e)}};XR=class XR{effect;[Zp]=py;constructor(e){this.effect=e}get value(){return this.effect}onStart(e,t,r,n){}onEnd(e,t){}onEffect(e,t){}onSuspend(e){}onResume(e){}map(e){return new Xp(this,g(this.value,ze(e)))}zip(e){return new Qp(this,e)}onRun(e,t){return e()}};ki=j("effect/Supervisor/none",()=>BD(nt))});var QR;var ek=x(()=>{qu();QR=So});var tk="Empty",rk="AddSupervisor",nk="RemoveSupervisor",ok="AndThen",Da,td=(e,t)=>({_tag:ok,first:e,second:t}),zD=(e,t)=>KD(t,rt(e)),KD=(e,t)=>{let r=e,n=t;while(Cr(n)){let o=Ar(n);switch(o._tag){case tk:{n=Pr(n);break}case rk:{r=r.zip(o.supervisor),n=Pr(n);break}case nk:{r=my(r,o.supervisor),n=Pr(n);break}case ok:{n=Ct(o.first)(Ct(o.second)(Pr(n)));break}}}return r},my=(e,t)=>{if(O(e,t))return ki;else if(dy(e))return my(e.left,t).zip(my(e.right,t));else return e},rd=(e)=>{if(O(e,ki))return Gr();else if(dy(e))return g(rd(e.left),Pn(rd(e.right)));else return ai(e)},WD=(e,t)=>{if(O(e,t))return Da;let r=rd(e),n=rd(t),o=g(n,Nm(r),ci(Da,(a,s)=>td(a,{_tag:rk,supervisor:s}))),i=g(r,Nm(n),ci(Da,(a,s)=>td(a,{_tag:nk,supervisor:s})));return td(o,i)},ik;var ak=x(()=>{Jr();ek();le();H();li();ed();Da={_tag:tk},ik=QR({empty:Da,patch:zD,combine:td,diff:WD})});var nq,sk,oq,iq,aq,Oc="Continue",sq="Done",ck="Yield",cq,nd=(e)=>{throw Error(`BUG: FiberRuntime - ${bn(e)} - please report an issue at https://github.com/Effect-TS/effect/issues`)},Hn,$n,Rc,lq,uq=(e)=>xi(IT(e),(t)=>Ci(NT(t),([r,n])=>{let o=new Map,i=[];for(let s of n){i.push(kn(s));for(let c of s)o.set(c.request,c)}let a=i.flat();return vo(vq(r.runAll(i),a,()=>a.forEach((s)=>{s.listeners.interrupted=!0})),zp,o)},!1,!1)),pq,od,dq,fq=(e)=>Gp((t)=>{let r=Ev(t.context,xc);Hs(r,Ep).unsafe.log(e.log(t))}),mq,hq,gq,pk,dk=(e,t,r)=>Ce(()=>{let n=ke(e),o=Array(n.length);return Eo(Ci(n,(a,s)=>B(t(a,s),(c)=>L(()=>o[s]=c)),r,!1),pe(o))}),Ci=(e,t,r,n,o)=>To((i)=>Zh((a)=>bt((s)=>{let c=Array.from(e).reverse(),l=c.length;if(l===0)return nt;let u=0,p=!1,f=o?Math.min(c.length,o):c.length,h=new Set,m=[],w=()=>h.forEach((F)=>{F.currentScheduler.scheduleTask(()=>{F.unsafeInterruptAsFork(s.id())},0,F)}),S=[],y=[],R=[],P=()=>{let F=m.filter(({exit:ie})=>ie._tag==="Failure").sort((ie,ae)=>ie.index<ae.index?-1:ie.index===ae.index?0:1).map(({exit:ie})=>ie);if(F.length===0)F.push(yr);return F},z=(F,ie=!1)=>{let ae=ep(a(F)),ee=xq(ae,s,s.currentRuntimeFlags,_c);return s.currentScheduler.scheduleTask(()=>{if(ie)ee.unsafeInterruptAsFork(s.id());ee.resume(ae)},0,ee),ee},Y=()=>{if(!n)l-=c.length,c=[];p=!0,w()},D=r?Yh:wo,te=z(_o((F)=>{let ie=(ee,Oe)=>{if(ee._op==="Blocked")R.push(ee);else if(m.push({index:Oe,exit:ee}),ee._op==="Failure"&&!p)Y()},ae=()=>{if(c.length>0){let ee=c.pop(),Oe=u++,yt=()=>{let We=c.pop();return Oe=u++,B(sc(),()=>B(D(i(t(We,Oe))),vt))},vt=(We)=>{if(c.length>0){if(ie(We,Oe),c.length>0)return yt()}return pe(We)},Ot=B(D(i(t(ee,Oe))),vt),$e=z(Ot);if(S.push($e),h.add($e),p)$e.currentScheduler.scheduleTask(()=>{$e.unsafeInterruptAsFork(s.id())},0,$e);$e.addObserver((We)=>{let je;if(We._op==="Failure")je=We;else je=We.effect_instruction_i0;if(y.push($e),h.delete($e),ie(je,Oe),m.length===l)F(pe(ve(Ei(P(),{parallel:!0}),()=>yr)));else if(R.length+m.length===l){let yn=P(),zi=R.map((lr)=>lr.effect_instruction_i0).reduce(qh);F(pe(Ju(zi,Ci([ve(Ei(yn,{parallel:!0}),()=>yr),...R.map((lr)=>lr.effect_instruction_i1)],(lr)=>lr,r,!0,o))))}else ae()})}};for(let ee=0;ee<f;ee++)ae()}));return qn(Ea(oc(i(Jp(te))),lp({onFailure:(F)=>{Y();let ie=R.length+1,ae=Math.min(typeof o==="number"?o:R.length,R.length),ee=Array.from(R);return _o((Oe)=>{let yt=[],vt=0,Ot=0,$e=(je,yn)=>(zi)=>{if(yt[je]=zi,vt++,vt===ie)Oe(Ie(Te(F)));if(ee.length>0&&yn)We()},We=()=>{z(ee.pop(),!0).addObserver($e(Ot,!0)),Ot++};te.addObserver($e(Ot,!1)),Ot++;for(let je=0;je<ae;je++)We()})},onSuccess:()=>gr(y,(F)=>F.inheritAll)})))}))),hy=(e,t,r,n)=>Ce(()=>{let o=ke(e),i=Array(o.length);return Eo(Ci(o,(s,c)=>ze(r(s,c),(l)=>i[c]=l),n,!1,t),pe(i))}),xy=(e)=>Sq(e,_c),yq=(e,t,r,n=null)=>{let o=fk(e,t,r,n);return o.resume(e),o},xq=(e,t,r,n=null)=>fk(e,t,r,n),fk=(e,t,r,n=null)=>{let o=Au(),i=t.getFiberRefs(),a=Og(i,o),s=new od(o,a,r),c=Ro(a,wi),l=s.currentSupervisor;return l.onStart(c,e,N(t),s),s.addObserver((p)=>l.onEnd(p,s)),(n!==null?n:g(t.getFiberRef(Wu),ve(()=>t.scope()))).add(r,s),s},Sq=(e,t)=>bt((r,n)=>pe(yq(e,r,n.runtimeFlags,t))),gy=(e)=>vi((t)=>Ge(yo(t,kc),{onNone:()=>e,onSome:(r)=>{switch(r.strategy._tag){case"Parallel":return e;case"Sequential":case"ParallelN":return B(Oa(r,Cp),(n)=>Sy(e,n))}}})),lk=(e)=>(t)=>vi((r)=>Ge(yo(r,kc),{onNone:()=>t,onSome:(n)=>{if(n.strategy._tag==="ParallelN"&&n.strategy.parallelism===e)return t;return B(Oa(n,Ap(e)),(o)=>Sy(t,o))}})),qa=(e,t)=>(r)=>vi((n)=>Ge(yo(n,kc),{onNone:()=>r(ce),onSome:(o)=>{if(t===!0){let i=e._tag==="Parallel"?gy:e._tag==="Sequential"?yy:lk(e.parallelism);switch(o.strategy._tag){case"Parallel":return i(r(gy));case"Sequential":return i(r(yy));case"ParallelN":return i(r(lk(o.strategy.parallelism)))}}else return r(ce)}})),yy=(e)=>vi((t)=>Ge(yo(t,kc),{onNone:()=>e,onSome:(r)=>{switch(r.strategy._tag){case"Sequential":return e;case"Parallel":case"ParallelN":return B(Oa(r,kp),(n)=>Sy(e,n))}}})),kc,bq=(e,t)=>{if(e.state._tag==="Open")e.state.finalizers.set({},t)},_q,wq=(e=Aa)=>{let t=Object.create(_q);return t.strategy=e,t.state={_tag:"Open",finalizers:new Map},t},Sy,Tq=(e)=>_i(e,{differ:ik,fork:Da}),uk,Eq,mk,vq=(e,t,r)=>nc((n)=>mk(B(xy(Zu(e)),(o)=>_o((i)=>{let a=t.map((l)=>l.listeners.count),s=()=>{if(a.every((l)=>l===0)){if(t.every((l)=>{if(l.result.state.current._tag==="Pending")return!0;else if(l.result.state.current._tag==="Done"&&Ra(l.result.state.current.effect)&&l.result.state.current.effect._tag==="Failure"&&yu(l.result.state.current.effect.cause))return!0;else return!1}))c.forEach((l)=>l()),r?.(),i(tE(o))}};o.addObserver((l)=>{c.forEach((u)=>u()),i(l)});let c=t.map((l,u)=>{let p=(f)=>{a[u]=f,s()};return l.listeners.addObserver(p),()=>l.listeners.removeObserver(p)});return s(),L(()=>{c.forEach((l)=>l())})})),Ce(()=>{let o=t.flatMap((i)=>{if(!i.state.completed)return[i];return[]});return xi(o,(i)=>YR(i.request,sg(n)))})));var by=x(()=>{Ve();Jr();fr();Sg();Sv();ya();Cg();Uv();Qv();H();li();Be();rO();yO();Ye();_e();ge();Lh();Vp();ro();FT();ma();mg();$g();_O();RO();ot();uv();gg();Rp();DO();Pp();Yg();jO();GR();KO();ZR();ec();ec();ed();ak();Op();nq=vc("effect_fiber_started",{incremental:!0}),sk=vc("effect_fiber_active"),oq=vc("effect_fiber_successes",{incremental:!0}),iq=vc("effect_fiber_failures",{incremental:!0}),aq=JR(WR("effect_fiber_lifetimes",zO({start:0.5,factor:2,count:35})),"time_unit","milliseconds"),cq={_E:(e)=>e,_A:(e)=>e},Hn=Symbol.for("effect/internal/fiberRuntime/YieldedOp"),$n=j("effect/internal/fiberRuntime/yieldedOpChannel",()=>({currentOp:null})),Rc={[Yi]:(e,t,r)=>St(()=>t.effect_instruction_i1(r)),["OnStep"]:(e,t,r)=>Ie(Ie(r)),[Zi]:(e,t,r)=>St(()=>t.effect_instruction_i2(r)),[Os]:(e,t,r)=>{if(e.patchRuntimeFlags(e.currentRuntimeFlags,t.patch),Ln(e.currentRuntimeFlags)&&e.isInterrupted())return Te(e.getInterruptedCause());else return Ie(r)},[Xi]:(e,t,r)=>{if(St(()=>t.effect_instruction_i2(r)),St(()=>t.effect_instruction_i0()))return e.pushStack(t),St(()=>t.effect_instruction_i1());else return nt},[Qi]:(e,t,r)=>{while(!0){let n=St(()=>t.effect_instruction_i0.next(r));if(n.done)return Ie(n.value);let o=zf(n.value);if(!Ra(o))return e.pushStack(t),o;else if(o._tag==="Failure")return o;r=o.value}}},lq={[Kg]:(e,t,r,n)=>(e.processNewInterruptSignal(n.cause),Ln(t)?Te(n.cause):r),[Jg]:(e,t,r,n)=>{throw Error("It is illegal to have multiple concurrent run loops in a single fiber")},[Wg]:(e,t,r,n)=>(n.onFiber(e,Ag(t)),r),[Gg]:(e,t,r,n)=>B(sc(),()=>r)},pq=Rs();od=class od extends xg{[Zg]=Xg;[LO]=cq;_fiberRefs;_fiberId;_queue=[];_children=null;_observers=[];_running=!1;_stack=[];_asyncInterruptor=null;_asyncBlockingOn=null;_exitValue=null;_steps=[];_isYielding=!1;currentRuntimeFlags;currentOpCount=0;currentSupervisor;currentScheduler;currentTracer;currentSpan;currentContext;currentDefaultServices;constructor(e,t,r){super();if(this.currentRuntimeFlags=r,this._fiberId=e,this._fiberRefs=t,Ph(r)){let n=this.getFiberRef(uc);nq.unsafeUpdate(1,n),sk.unsafeUpdate(1,n)}this.refreshRefCache()}commit(){return Jp(this)}id(){return this._fiberId}resume(e){this.tell(Oi(e))}get status(){return this.ask((e,t)=>t)}get runtimeFlags(){return this.ask((e,t)=>{if(Xv(t))return e.currentRuntimeFlags;return t.runtimeFlags})}scope(){return NO(this)}get children(){return this.ask((e)=>Array.from(e.getChildren()))}getChildren(){if(this._children===null)this._children=new Set;return this._children}getInterruptedCause(){return this.getFiberRef(pc)}fiberRefs(){return this.ask((e)=>e.getFiberRefs())}ask(e){return Ce(()=>{let t=xE(this._fiberId);return this.tell(Na((r,n)=>{pp(t,L(()=>e(r,n)))})),up(t)})}tell(e){if(this._queue.push(e),!this._running)this._running=!0,this.drainQueueLaterOnExecutor()}get await(){return _o((e)=>{let t=(r)=>e(pe(r));if(this._exitValue!==null){t(this._exitValue);return}return this.tell(Na((r,n)=>{if(r._exitValue!==null)t(this._exitValue);else r.addObserver(t)})),L(()=>this.tell(Na((r,n)=>{r.removeObserver(t)})))},this.id())}get inheritAll(){return bt((e,t)=>{let r=e.id(),n=e.getFiberRefs(),o=t.runtimeFlags,i=this.getFiberRefs(),a=vg(n,r,i);e.setFiberRefs(a);let s=e.getFiberRef(uk),c=g(Xs(o,s),Fh(Fn),Fh($u));return Xh(c)})}get poll(){return L(()=>Tn(this._exitValue))}unsafePoll(){return this._exitValue}interruptAsFork(e){return L(()=>this.tell(Kp(Ir(e))))}unsafeInterruptAsFork(e){this.tell(Kp(Ir(e)))}addObserver(e){if(this._exitValue!==null)e(this._exitValue);else this._observers.push(e)}removeObserver(e){this._observers=this._observers.filter((t)=>t!==e)}getFiberRefs(){return this.setFiberRef(uk,this.currentRuntimeFlags),this._fiberRefs}unsafeDeleteFiberRef(e){this._fiberRefs=Sc(this._fiberRefs,e)}getFiberRef(e){if(this._fiberRefs.locals.has(e))return this._fiberRefs.locals.get(e)[0][1];return e.initial}setFiberRef(e,t){this._fiberRefs=Pa(this._fiberRefs,{fiberId:this._fiberId,fiberRef:e,value:t}),this.refreshRefCache()}refreshRefCache(){this.currentDefaultServices=this.getFiberRef(xc),this.currentTracer=this.currentDefaultServices.unsafeMap.get(yc.key),this.currentSupervisor=this.getFiberRef(Eq),this.currentScheduler=this.getFiberRef(Bp),this.currentContext=this.getFiberRef(wi),this.currentSpan=this.currentContext.unsafeMap.get(vp.key)}setFiberRefs(e){this._fiberRefs=e,this.refreshRefCache()}addChild(e){this.getChildren().add(e)}removeChild(e){this.getChildren().delete(e)}transferChildren(e){let t=this._children;if(this._children=null,t!==null&&t.size>0){for(let r of t)if(r._exitValue===null)e.add(this.currentRuntimeFlags,r)}}drainQueueOnCurrentThread(){let e=!0;while(e){let t=Oc,r=globalThis[Co];globalThis[Co]=this;try{while(t===Oc)t=this._queue.length===0?sq:this.evaluateMessageWhileSuspended(this._queue.splice(0,1)[0])}finally{this._running=!1,globalThis[Co]=r}if(this._queue.length>0&&!this._running)if(this._running=!0,t===ck)this.drainQueueLaterOnExecutor(),e=!1;else e=!0;else e=!1}}drainQueueLaterOnExecutor(){this.currentScheduler.scheduleTask(this.run,this.getFiberRef(va),this)}drainQueueWhileRunning(e,t){let r=t;while(this._queue.length>0){let n=this._queue.splice(0,1)[0];r=lq[n._tag](this,e,r,n)}return r}isInterrupted(){return!gu(this.getFiberRef(pc))}addInterruptedCause(e){let t=this.getFiberRef(pc);this.setFiberRef(pc,At(t,e))}processNewInterruptSignal(e){this.addInterruptedCause(e),this.sendInterruptSignalToAllChildren()}sendInterruptSignalToAllChildren(){if(this._children===null||this._children.size===0)return!1;let e=!1;for(let t of this._children)t.tell(Kp(Ir(this.id()))),e=!0;return e}interruptAllChildren(){if(this.sendInterruptSignalToAllChildren()){let e=this._children.values();this._children=null;let t=!1;return ac({while:()=>!t,body:()=>{let n=e.next();if(!n.done)return qn(n.value.await);else return L(()=>{t=!0})},step:()=>{}})}return null}reportExitValue(e){if(Ph(this.currentRuntimeFlags)){let t=this.getFiberRef(uc),r=this.id().startTimeMillis,n=Date.now();switch(aq.unsafeUpdate(n-r,t),sk.unsafeUpdate(-1,t),e._tag){case jt:{oq.unsafeUpdate(1,t);break}case $t:{iq.unsafeUpdate(1,t);break}}}if(e._tag==="Failure"){let t=this.getFiberRef(mE);if(!fa(e.cause)&&t._tag==="Some")this.log("Fiber terminated with an unhandled error",e.cause,t)}}setExitValue(e){this._exitValue=e,this.reportExitValue(e);for(let t=this._observers.length-1;t>=0;t--)this._observers[t](e);this._observers=[]}getLoggers(){return this.getFiberRef(gq)}log(e,t,r){let n=Re(r)?r.value:this.getFiberRef(ng),o=this.getFiberRef(dq);if(eO(o,n))return;let i=this.getFiberRef(uE),a=this.getFiberRef(lE),s=this.getLoggers(),c=this.getFiberRefs();if(Ls(s)>0){let l=Hs(this.getFiberRef(xc),hc),u=new Date(l.unsafeCurrentTimeMillis());Kb(c,()=>{for(let p of s)p.log({fiberId:this.id(),logLevel:n,message:e,cause:t,context:c,spans:i,annotations:a,date:u})})}}evaluateMessageWhileSuspended(e){switch(e._tag){case Gg:return ck;case Kg:{if(this.processNewInterruptSignal(e.cause),this._asyncInterruptor!==null)this._asyncInterruptor(Te(e.cause)),this._asyncInterruptor=null;return Oc}case Jg:return this._asyncInterruptor=null,this._asyncBlockingOn=null,this.evaluateEffect(e.effect),Oc;case Wg:return e.onFiber(this,this._exitValue!==null?Yv:Zv(this.currentRuntimeFlags,this._asyncBlockingOn)),Oc;default:return nd(e)}}evaluateEffect(e){this.currentSupervisor.onResume(this);try{let t=Ln(this.currentRuntimeFlags)&&this.isInterrupted()?Te(this.getInterruptedCause()):e;while(t!==null){let r=t,n=this.runLoop(r);if(n===Hn){let o=$n.currentOp;if($n.currentOp=null,o._op===ea)if(kT(this.currentRuntimeFlags))this.tell(AO()),this.tell(Oi(yr)),t=null;else t=yr;else if(o._op===Qo)t=null}else{this.currentRuntimeFlags=g(this.currentRuntimeFlags,kh($u));let o=this.interruptAllChildren();if(o!==null)t=B(o,()=>n);else{if(this._queue.length===0)this.setExitValue(n);else this.tell(Oi(n));t=null}}}}finally{this.currentSupervisor.onSuspend(this)}}start(e){if(!this._running){this._running=!0;let t=globalThis[Co];globalThis[Co]=this;try{this.evaluateEffect(e)}finally{if(this._running=!1,globalThis[Co]=t,this._queue.length>0)this.drainQueueLaterOnExecutor()}}else this.tell(Oi(e))}startFork(e){this.tell(Oi(e))}patchRuntimeFlags(e,t){let r=Qs(e,t);return globalThis[Co]=this,this.currentRuntimeFlags=r,r}initiateAsync(e,t){let r=!1,n=(o)=>{if(!r)r=!0,this.tell(Oi(o))};if(Ln(e))this._asyncInterruptor=n;try{t(n)}catch(o){n(Pt(rr(o)))}}pushStack(e){if(this._stack.push(e),e._op==="OnStep")this._steps.push({refs:this.getFiberRefs(),flags:this.currentRuntimeFlags})}popStack(){let e=this._stack.pop();if(e){if(e._op==="OnStep")this._steps.pop();return e}return}getNextSuccessCont(){let e=this.popStack();while(e){if(e._op!==vs)return e;e=this.popStack()}}getNextFailCont(){let e=this.popStack();while(e){if(e._op!==Yi&&e._op!==Xi&&e._op!==Qi)return e;e=this.popStack()}}[Jb](e){return L(()=>$s(this.currentContext,e))}["Left"](e){return ft(e.left)}["None"](e){return ft(new dc)}["Right"](e){return Ie(e.right)}["Some"](e){return Ie(e.value)}["Micro"](e){return tc((t)=>{let r=t,n=gO(fO(e,this.currentContext));return n.addObserver((o)=>{if(o._tag==="Success")return r(Ie(o.value));switch(o.cause._tag){case"Interrupt":return r(Te(Ir(mr)));case"Fail":return r(ft(o.cause.error));case"Die":return r(Yu(o.cause.defect))}}),tc((o)=>{r=(i)=>{o(nt)},n.unsafeInterrupt()})})}[zl](e){let t=St(()=>e.effect_instruction_i0()),r=this.getNextSuccessCont();if(r!==void 0){if(!(r._op in Rc))nd(r);return Rc[r._op](this,r,t)}else return $n.currentOp=Ie(t),Hn}[jt](e){let t=e,r=this.getNextSuccessCont();if(r!==void 0){if(!(r._op in Rc))nd(r);return Rc[r._op](this,r,t.effect_instruction_i0)}else return $n.currentOp=t,Hn}[$t](e){let t=e.effect_instruction_i0,r=this.getNextFailCont();if(r!==void 0)switch(r._op){case vs:case Zi:if(!(Ln(this.currentRuntimeFlags)&&this.isInterrupted()))return St(()=>r.effect_instruction_i1(t));else return Te(Su(t));case"OnStep":if(!(Ln(this.currentRuntimeFlags)&&this.isInterrupted()))return Ie(Te(t));else return Te(Su(t));case Os:if(this.patchRuntimeFlags(this.currentRuntimeFlags,r.patch),Ln(this.currentRuntimeFlags)&&this.isInterrupted())return Te(At(t,this.getInterruptedCause()));else return Te(t);default:nd(r)}else return $n.currentOp=Te(t),Hn}[Kl](e){return St(()=>e.effect_instruction_i0(this,Ag(this.currentRuntimeFlags)))}["Blocked"](e){let t=this.getFiberRefs(),r=this.currentRuntimeFlags;if(this._steps.length>0){let n=[],o=this._steps[this._steps.length-1],i=this.popStack();while(i&&i._op!=="OnStep")n.push(i),i=this.popStack();this.setFiberRefs(o.refs),this.currentRuntimeFlags=o.flags;let a=Dv(o.refs,t),s=Xs(o.flags,r);return Ie(Ju(e.effect_instruction_i0,bt((c)=>{while(n.length>0)c.pushStack(n.pop());return c.setFiberRefs(qv(c.id(),c.getFiberRefs())(a)),c.currentRuntimeFlags=Qs(s)(c.currentRuntimeFlags),e.effect_instruction_i1})))}return To((n)=>B(xy(jh(e.effect_instruction_i0)),()=>n(e.effect_instruction_i1)))}["RunBlocked"](e){return uq(e.effect_instruction_i0)}[ti](e){let t=e.effect_instruction_i0,r=this.currentRuntimeFlags,n=Qs(r,t);if(Ln(n)&&this.isInterrupted())return Te(this.getInterruptedCause());else if(this.patchRuntimeFlags(this.currentRuntimeFlags,t),e.effect_instruction_i1){let o=Xs(n,r);return this.pushStack(new Bh(o,e)),St(()=>e.effect_instruction_i1(r))}else return yr}[Yi](e){return this.pushStack(e),e.effect_instruction_i0}["OnStep"](e){return this.pushStack(e),e.effect_instruction_i0}[vs](e){return this.pushStack(e),e.effect_instruction_i0}[Zi](e){return this.pushStack(e),e.effect_instruction_i0}[Qo](e){return this._asyncBlockingOn=e.effect_instruction_i1,this.initiateAsync(this.currentRuntimeFlags,e.effect_instruction_i0),$n.currentOp=e,Hn}[ea](e){return this._isYielding=!1,$n.currentOp=e,Hn}[Xi](e){let{effect_instruction_i0:t,effect_instruction_i1:r}=e;if(t())return this.pushStack(e),r();else return yr}[Qi](e){return Rc[Qi](this,e,void 0)}[ei](e){return St(()=>e.commit())}runLoop(e){let t=e;this.currentOpCount=0;while(!0){if((this.currentRuntimeFlags&RT)!==0)this.currentSupervisor.onEffect(this,t);if(this._queue.length>0)t=this.drainQueueWhileRunning(this.currentRuntimeFlags,t);if(!this._isYielding){this.currentOpCount+=1;let r=this.currentScheduler.shouldYield(this);if(r!==!1){this._isYielding=!0,this.currentOpCount=0;let n=t;t=B(sc({priority:r}),()=>n)}}try{if(t=this.currentTracer.context(()=>{if(pq!==t[bo]._V){let r=this.getFiberRef(hE);if(r._tag==="Some"){let n=t[bo]._V;this.log(`Executing an Effect versioned ${n} with a Runtime of version ${Rs()}, you may want to dedupe the effect dependencies, you can use the language service plugin to detect this at compile time: https://github.com/Effect-TS/language-service`,In,r)}}return this[t._op](t)},this),t===Hn){let r=$n.currentOp;if(r._op===ea||r._op===Qo)return Hn;return $n.currentOp=null,r._op===jt||r._op===$t?r:Te(rr(r))}}catch(r){if(t!==Hn&&!k(t,"_op")||!(t._op in this))t=Wh(`Not a valid effect: ${bn(t)}`);else if(gE(r))t=Te(At(rr(r),Ir(mr)));else t=Yu(r)}}}run=()=>{this.drainQueueOnCurrentThread()}};dq=j("effect/FiberRef/currentMinimumLogLevel",()=>_t(tO("Info"))),mq=j(Symbol.for("effect/Logger/defaultLogger"),()=>fq(HO)),hq=j(Symbol.for("effect/Logger/tracerLogger"),()=>Gp(({annotations:e,cause:t,context:r,fiberId:n,logLevel:o,message:i})=>{let a=zg(yo(Ro(r,wi),vp));if(a._tag==="None"||a.value._tag==="ExternalSpan")return;let s=$s(Ro(r,xc),hc),c={};for(let[l,u]of e)c[l]=u;if(c["effect.fiberId"]=Xw(n),c["effect.logLevel"]=o.label,t!==null&&t._tag!=="Empty")c["effect.cause"]=Mr(t,{renderErrorCause:!0});a.value.event(bn(Array.isArray(i)&&i.length===1?i[0]:i),s.unsafeCurrentTimeNanos(),c)})),gq=j(Symbol.for("effect/FiberRef/currentLoggers"),()=>sE(ai(mq,hq))),pk=d((e)=>$f(e[0]),(e,t,r)=>bt((n)=>{let o=r?.batching===!0||r?.batching==="inherit"&&n.getFiberRef(fE);if(r?.discard)return jg(r.concurrency,()=>qa(kp,r?.concurrentFinalizers)((i)=>o?Ci(e,(a,s)=>i(t(a,s)),!0,!1,1):xi(e,(a,s)=>i(t(a,s)))),()=>qa(Cp,r?.concurrentFinalizers)((i)=>Ci(e,(a,s)=>i(t(a,s)),o,!1)),(i)=>qa(Ap(i),r?.concurrentFinalizers)((a)=>Ci(e,(s,c)=>a(t(s,c)),o,!1,i)));return jg(r?.concurrency,()=>qa(kp,r?.concurrentFinalizers)((i)=>o?hy(e,1,(a,s)=>i(t(a,s)),!0):gr(e,(a,s)=>i(t(a,s)))),()=>qa(Cp,r?.concurrentFinalizers)((i)=>dk(e,(a,s)=>i(t(a,s)),o)),(i)=>qa(Ap(i),r?.concurrentFinalizers)((a)=>hy(e,i,(s,c)=>a(t(s,c)),o)))})),kc=Vt("effect/Scope"),_q={[ip]:ip,[ap]:ap,pipe(){return E(this,arguments)},fork(e){return L(()=>{let t=wq(e);if(this.state._tag==="Closed")return t.state=this.state,t;let r={},n=(o)=>t.close(o);return this.state.finalizers.set(r,n),bq(t,(o)=>L(()=>{if(this.state._tag==="Open")this.state.finalizers.delete(r)})),t})},close(e){return Ce(()=>{if(this.state._tag==="Closed")return nt;let t=Array.from(this.state.finalizers.values()).reverse();if(this.state={_tag:"Closed",exit:e},t.length===0)return nt;return bg(this.strategy)?g(gr(t,(r)=>wo(r(e))),B((r)=>g(Ei(r),vr(fc),ve(()=>yr)))):_g(this.strategy)?g(dk(t,(r)=>wo(r(e)),!1),B((r)=>g(Ei(r,{parallel:!0}),vr(fc),ve(()=>yr)))):g(hy(t,this.strategy.parallelism,(r)=>wo(r(e)),!1),B((r)=>g(Ei(r,{parallel:!0}),vr(fc),ve(()=>yr))))})},addFinalizer(e){return Ce(()=>{if(this.state._tag==="Closed")return e(this.state.exit);return this.state.finalizers.set({},e),nt})}},Sy=d(2,(e,t)=>lg(e,js(Nw(kc,t)))),uk=cE(CT),Eq=Tq(ki),mk=d(2,(e,t)=>To((r)=>hr(r(e),{onFailure:(n)=>hr(t,{onFailure:(o)=>Pt(At(n,o)),onSuccess:()=>Pt(n)}),onSuccess:(n)=>Dn(t,n)})))});var gk,yk;var xk=x(()=>{ot();gk=og,yk=Oa});class wk{context;runtimeFlags;fiberRefs;constructor(e,t,r){this.context=e,this.runtimeFlags=t,this.fiberRefs=r}pipe(){return E(this,arguments)}}var wy=(e)=>function(){if(arguments.length===1){let t=arguments[0];return(r,...n)=>e(t,r,...n)}return e.apply(this,arguments)},Sk,Cq,bk,Aq=(e)=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let r=new bk(e);return Error.stackTraceLimit=t,r},_y,id,_k,Pq=(e)=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let r=new _k(e);return Error.stackTraceLimit=t,r},Iq=(e)=>{let t=e;switch(t._op){case"Failure":case"Success":return t;case"Left":return mc(t.left);case"Right":return Ie(t.right);case"Some":return Ie(t.value);case"None":return mc(new dc)}},Mq,Nq=(e)=>new wk(e.context,e.runtimeFlags,e.fiberRefs),Fq,Tk,Ek,vk;var Ok=x(()=>{fr();le();ya();Cg();Be();Ye();_e();Vp();xk();ma();ot();Rp();by();Yg();ec();ed();Sk=wy((e,t,r)=>{let n=Au(),o=[[wi,[[n,e.context]]]];if(r?.scheduler)o.push([Bp,[[n,r.scheduler]]]);let i=vv(e.fiberRefs,{entries:o,forkAs:n});if(r?.updateRefs)i=r.updateRefs(i,n);let a=new od(n,i,e.runtimeFlags),s=t;if(r?.scope)s=B(yk(r.scope,Aa),(l)=>Eo(sp(l,nc((u)=>O(u,a.id())?nt:lc(a,u))),Ea(t,(u)=>gk(l,u))));let c=a.currentSupervisor;if(c!==ki)c.onStart(e.context,s,C(),a),a.addObserver((l)=>c.onEnd(l,a));if(_c.add(e.runtimeFlags,a),r?.immediate===!1)a.resume(s);else a.start(s);return a}),Cq=wy((e,t)=>{let r=Mq(e)(t);if(r._tag==="Failure")throw Pq(r.effect_instruction_i0);return r.effect_instruction_i0});bk=class bk extends Error{fiber;_tag="AsyncFiberException";constructor(e){super(`Fiber #${e.id().id} cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work`);this.fiber=e,this.name=this._tag,this.stack=this.message}};_y=Symbol.for("effect/Runtime/FiberFailure"),id=Symbol.for("effect/Runtime/FiberFailure/Cause");_k=class _k extends Error{[_y];[id];constructor(e){let t=Ds(e)[0];super(t?.message||"An error has occurred");if(this[_y]=_y,this[id]=e,this.name=t?`(FiberFailure) ${t.name}`:"FiberFailure",t?.stack)this.stack=t.stack}toJSON(){return{_id:"FiberFailure",cause:this[id].toJSON()}}toString(){return"(FiberFailure) "+Mr(this[id],{renderErrorCause:!0})}[re](){return this.toString()}};Mq=wy((e,t)=>{let r=Iq(t);if(r)return r;let n=new bc,o=Sk(e)(t,{scheduler:n});n.flush();let i=o.unsafePoll();if(i)return i;return ag(Gu(Aq(o),dp(o)))});Fq=Ah(Fn,Rh,Oh),Tk=Nq({context:go(),runtimeFlags:Fq,fiberRefs:Ov()}),Ek=Sk(Tk),vk=Cq(Tk)});var Rk,Cc,Ac,or,kk,ad,Ck,Ai,Fr,Ak,Pk;var Ik=x(()=>{ot();by();Ok();Rk=wa,Cc=pk,Ac=Ce,or=nt,kk=rc,ad=ze,Ck=Si,Ai=yi,Fr=B,Ak=Ek,Pk=vk});var Ty=(e,t)=>{switch(t._tag){case"StringKeyword":case"TemplateLiteral":return Object.keys(e);case"SymbolKeyword":return Object.getOwnPropertySymbols(e);case"Refinement":return Ty(e,t.from)}},Pc=(e)=>{let t=!1,r;return()=>{if(t)return r;return r=e(),t=!0,r}},Ey=(e)=>Array.isArray(e),Nk=(e)=>!Array.isArray(e),Mk=(e)=>`[${Es(e)}]`,sd=(e)=>Ey(e)?e.map(Mk).join(""):Mk(e);var Ic=x(()=>{Be()});var Po=(e,t,r,n)=>{let o=e;if(r&&we(r))o+=`
|
|
31
|
+
at path: ${sd(r)}`;if(t!==void 0)o+=`
|
|
32
|
+
details: ${t}`;if(n)o+=`
|
|
33
|
+
schema (${n._tag}): ${n}`;return o},Fk=(e)=>Po("Invalid Argument",e),Lk=(e)=>Po("Unsupported key schema",void 0,void 0,e),Dk=(e)=>Po("Unsupported literal",`literal value: ${Kr(e)}`),vy=(e)=>Po("Duplicate index signature",`${e} index signature`),qk,Uk,Oy=(e)=>Po("Duplicate property signature transformation",`Duplicate key ${Kr(e)}`),Ry=(e)=>Po("Duplicate property signature",`Duplicate key ${Kr(e)}`);var ky=x(()=>{Ve();Be();Ic();qk=Po("Unsupported index signature parameter","An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),Uk=Po("Invalid element","A required element cannot follow an optional element. ts(1257)")});var $k,jk,Bk,Vk,zk,Kk,Wk;var Jk=x(()=>{$k=Symbol.for("effect/SchemaId/DateFromSelf"),jk=Symbol.for("effect/SchemaId/GreaterThan"),Bk=Symbol.for("effect/SchemaId/GreaterThanOrEqualTo"),Vk=Symbol.for("effect/SchemaId/Int"),zk=Symbol.for("effect/SchemaId/MinLength"),Kk=Symbol.for("effect/SchemaId/MaxLength"),Wk=Symbol.for("effect/SchemaId/MinItems")});class Ua{typeParameters;decodeUnknown;encodeUnknown;annotations;_tag="Declaration";constructor(e,t,r,n={}){this.typeParameters=e,this.decodeUnknown=t,this.encodeUnknown=r,this.annotations=n}toString(){return ve(rn(this),()=>"<declaration schema>")}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map((e)=>e.toJSON()),annotations:Ue(this.annotations)}}}class Pi{literal;annotations;_tag="Literal";constructor(e,t={}){this.literal=e,this.annotations=t}toString(){return ve(rn(this),()=>Kr(this.literal))}toJSON(){return{_tag:this._tag,literal:eo(this.literal)?String(this.literal):this.literal,annotations:Ue(this.annotations)}}}class fd{symbol;annotations;_tag="UniqueSymbol";constructor(e,t={}){this.symbol=e,this.annotations=t}toString(){return ve(rn(this),()=>Kr(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:Ue(this.annotations)}}}class sC{annotations;_tag="UndefinedKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class cC{annotations;_tag="VoidKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class lC{annotations;_tag="NeverKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class uC{annotations;_tag="UnknownKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class pC{annotations;_tag="AnyKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class fC{annotations;_tag="StringKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class hC{annotations;_tag="NumberKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class yC{annotations;_tag="BooleanKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class SC{annotations;_tag="BigIntKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class bC{annotations;_tag="SymbolKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class wC{annotations;_tag="ObjectKeyword";constructor(e={}){this.annotations=e}toString(){return Lr(this)}toJSON(){return{_tag:this._tag,annotations:Ue(this.annotations)}}}class Ha{type;annotations;constructor(e,t={}){this.type=e,this.annotations=t}toJSON(){return{type:this.type.toJSON(),annotations:Ue(this.annotations)}}toString(){return String(this.type)}}class Fc{elements;rest;isReadonly;annotations;_tag="TupleType";constructor(e,t,r,n={}){this.elements=e,this.rest=t,this.isReadonly=r,this.annotations=n;let o=!1,i=!1;for(let a of e)if(a.isOptional)o=!0;else if(o){i=!0;break}if(i||o&&t.length>1)throw Error(Uk)}toString(){return ve(rn(this),()=>Kq(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map((e)=>e.toJSON()),rest:this.rest.map((e)=>e.toJSON()),isReadonly:this.isReadonly,annotations:Ue(this.annotations)}}}class $a{type;isReadonly;parameter;constructor(e,t,r){if(this.type=t,this.isReadonly=r,EC(e))this.parameter=e;else throw Error(qk)}toString(){return(this.isReadonly?"readonly ":"")+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}}class nn{annotations;_tag="TypeLiteral";propertySignatures;indexSignatures;constructor(e,t,r={}){this.annotations=r;let n={};for(let i=0;i<e.length;i++){let a=e[i].name;if(Object.prototype.hasOwnProperty.call(n,a))throw Error(Ry(a));n[a]=null}let o={string:!1,symbol:!1};for(let i=0;i<t.length;i++){let a=ax(t[i].parameter);if(gd(a)){if(o.string)throw Error(vy("string"));o.string=!0}else if(_C(a)){if(o.symbol)throw Error(vy("symbol"));o.symbol=!0}}this.propertySignatures=e,this.indexSignatures=t}toString(){return ve(rn(this),()=>Wq(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map((e)=>e.toJSON()),indexSignatures:this.indexSignatures.map((e)=>e.toJSON()),annotations:Ue(this.annotations)}}}class qt{types;annotations;static make=(e,t)=>yd(e)?new qt(e,t):e.length===1?e[0]:hd;static unify=(e,t)=>qt.make(Yq(vC(e)),t);_tag="Union";constructor(e,t={}){this.types=e,this.annotations=t}toString(){return ve(rn(this),()=>this.types.map(String).join(" | "))}toJSON(){return{_tag:this._tag,types:this.types.map((e)=>e.toJSON()),annotations:Ue(this.annotations)}}}class xd{f;annotations;_tag="Suspend";constructor(e,t={}){this.f=e,this.annotations=t,this.f=Pc(e)}toString(){return rn(this).pipe(Er(()=>Or(h_(this.f)(),(e)=>rn(e))),ve(()=>"<suspended schema>"))}toJSON(){let e=this.f(),t=Cy.get(e);if(t)return t;return Cy.set(e,{_tag:this._tag}),t={_tag:this._tag,ast:e.toJSON(),annotations:Ue(this.annotations)},Cy.set(e,t),t}}class Lc{from;filter;annotations;_tag="Refinement";constructor(e,t,r={}){this.from=e,this.filter=t,this.annotations=r}toString(){return Mc(this).pipe(ve(()=>Ge(AC(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:(e)=>Dc(this.from)?String(this.from)+" & "+e:e})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:Ue(this.annotations)}}}class tx{from;to;transformation;annotations;_tag="Transformation";constructor(e,t,r,n={}){this.from=e,this.to=t,this.transformation=r,this.annotations=n}toString(){return ve(rn(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:Ue(this.annotations)}}}class rx{from;to;decode;encode;constructor(e,t,r,n){this.from=e,this.to=t,this.decode=r,this.encode=n}}class nx{propertySignatureTransformations;_tag="TypeLiteralTransformation";constructor(e){this.propertySignatureTransformations=e;let t={},r={};for(let n of e){let o=n.from;if(t[o])throw Error(Oy(o));t[o]=!0;let i=n.to;if(r[i])throw Error(Oy(i));r[i]=!0}}}function xr(e,t){let r=!1,n=ri(e.length);for(let o=0;o<e.length;o++){let i=e[o],a=t(i);if(a!==i)r=!0;n[o]=a}return r?n:e}function t2(e){return Ge(Ky(e),{onNone:()=>"",onSome:(t)=>t.map((r)=>` & Brand<${Kr(r)}>`).join("")})}var Yk,Py,Zk,Iy,ld,ud,zt,pd,jn,My,Ny,Fy,Ly,Dy,qy,Xk,Uy,Hy,$y,jy,By,Vy,zy,It,Ky,Qk,eC,Wy,Jy,Mc,Gy,tC,rC,nC,oC,iC,Yy,Uq,Zy=(e)=>x_(Uq(e),(t)=>t===!0),Xy,Hq,$q=(e)=>Er(Hq(e),()=>Mc(e)),Nc=(e)=>(t)=>t._tag===e,dd,aC,md,jq,hd,Qy,dC,mC,gd,gC,xC,Bq,Vq,_C,zq,Io,TC=(e)=>e.map((t)=>t.type),Kq=(e)=>{let t=e.elements.map(String).join(", ");return __(e.rest,{onEmpty:()=>`readonly [${t}]`,onNonEmpty:(r,n)=>{let o=String(r),i=o.includes(" | ")?`(${o})`:o;if(n.length>0){let a=n.map(String).join(", ");if(e.elements.length>0)return`readonly [${t}, ...${i}[], ${a}]`;else return`readonly [...${i}[], ${a}]`}else if(e.elements.length>0)return`readonly [${t}, ...${i}[]]`;else return`ReadonlyArray<${o}>`}})},ct,EC=(e)=>{switch(e._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return!0;case"Refinement":return EC(e.from)}return!1},Gk=(e)=>e.map(String).join("; "),Wq=(e)=>{if(e.propertySignatures.length>0){let t=e.propertySignatures.map(String).join("; ");if(e.indexSignatures.length>0)return`{ ${t}; ${Gk(e.indexSignatures)} }`;else return`{ ${t} }`}else if(e.indexSignatures.length>0)return`{ ${Gk(e.indexSignatures)} }`;else return"{}"},Jq,Gq,vC=(e)=>Ps(e,(t)=>ex(t)?vC(t.types):[t]),Yq=(e)=>{let t=Jq(e),r=[],n={},o=[];for(let i of t)switch(i._tag){case"NeverKeyword":break;case"AnyKeyword":return[dC];case"UnknownKeyword":return[Qy];case"ObjectKeyword":case"UndefinedKeyword":case"VoidKeyword":case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":{if(!n[i._tag])n[i._tag]=i,r.push(i);break}case"Literal":{let a=typeof i.literal;switch(a){case"string":case"number":case"bigint":case"boolean":{let s=Gq[a];if(!n[s]&&!o.includes(i.literal))o.push(i.literal),r.push(i);break}case"object":{if(!o.includes(i.literal))o.push(i.literal),r.push(i);break}}break}case"UniqueSymbol":{if(!n.SymbolKeyword&&!o.includes(i.symbol))o.push(i.symbol),r.push(i);break}case"TupleType":{if(!n.ObjectKeyword)r.push(i);break}case"TypeLiteral":{if(i.propertySignatures.length===0&&i.indexSignatures.length===0){if(!n["{}"])n["{}"]=i,r.push(i)}else if(!n.ObjectKeyword)r.push(i);break}default:r.push(i)}return r},OC=(e,t)=>e.map(t),yd=(e)=>e.length>1,ex,Cy,Dc,Sd,qc=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={...e.annotations};delete n[ud];let o={...n,...t},i=Yy(e);if(Re(i))o[Vy]=qc(i.value,t);return r.annotations.value=o,Object.create(Object.getPrototypeOf(e),r)},Zq="[\\s\\S]*?",Xq="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?",RC=(e,t)=>{switch(e._tag){case"Literal":return Ca(String(e.literal));case"StringKeyword":return Zq;case"NumberKeyword":return Xq;case"TemplateLiteral":return kC(e,t,!1);case"Union":return e.types.map((r)=>RC(r,t)).join("|")}},Qq=(e,t,r,n)=>{if(ex(e)){if(r&&!n)return`(?:${t})`}else if(!r||!n)return t;return`(${t})`},kC=(e,t,r)=>{let n="";if(e.head!==""){let o=Ca(e.head);n+=t&&r?`(${o})`:o}for(let o of e.spans){let i=RC(o.type,t);if(n+=Qq(o.type,i,t,r),o.literal!==""){let a=Ca(o.literal);n+=t&&r?`(${a})`:a}}return n},CC=(e)=>new RegExp(`^${kC(e,!1,!0)}$`),ox=(e,t)=>{let r=[],n=[],o=(i)=>{switch(i._tag){case"NeverKeyword":break;case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":case"Refinement":n.push(new $a(i,t,!0));break;case"Literal":if(xt(i.literal)||Xt(i.literal))r.push(new ct(i.literal,t,!1,!0));else throw Error(Dk(i.literal));break;case"Enums":{for(let[a,s]of i.enums)r.push(new ct(s,t,!1,!0));break}case"UniqueSymbol":r.push(new ct(i.symbol,t,!1,!0));break;case"Union":i.types.forEach(o);break;default:throw Error(Lk(i))}};return o(e),{propertySignatures:r,indexSignatures:n}},ix=(e)=>(t)=>{let r=void 0;for(let n of e)if(Object.prototype.hasOwnProperty.call(t.annotations,n)){if(r===void 0)r={};r[n]=t.annotations[n]}return r},e2,st=(e)=>{switch(e._tag){case"Declaration":{let t=xr(e.typeParameters,st);return t===e.typeParameters?e:new Ua(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case"TupleType":{let t=xr(e.elements,(o)=>{let i=st(o.type);return i===o.type?o:new Io(i,o.isOptional)}),r=TC(e.rest),n=xr(r,st);return t===e.elements&&n===r?e:new Fc(t,n.map((o)=>new Ha(o)),e.isReadonly,e.annotations)}case"TypeLiteral":{let t=xr(e.propertySignatures,(n)=>{let o=st(n.type);return o===n.type?n:new ct(n.name,o,n.isOptional,n.isReadonly)}),r=xr(e.indexSignatures,(n)=>{let o=st(n.type);return o===n.type?n:new $a(n.parameter,o,n.isReadonly)});return t===e.propertySignatures&&r===e.indexSignatures?e:new nn(t,r,e.annotations)}case"Union":{let t=xr(e.types,st);return t===e.types?e:qt.make(t,e.annotations)}case"Suspend":return new xd(()=>st(e.f()),e.annotations);case"Refinement":{let t=st(e.from);return t===e.from?e:new Lc(t,e.filter,e.annotations)}case"Transformation":{let t=e2(e);return st(t!==void 0?qc(e.to,t):e.to)}}return e},Ay=(e)=>{switch(e._tag){case"Transformation":return e.from;case"Refinement":return Ay(e.from);case"Suspend":return Ay(e.f())}},tn=(e,t)=>{switch(e._tag){case"Declaration":{let r=xr(e.typeParameters,(n)=>tn(n,t));return r===e.typeParameters?e:new Ua(r,e.decodeUnknown,e.encodeUnknown)}case"TupleType":{let r=xr(e.elements,(i)=>{let a=tn(i.type,t);return a===i.type?i:new Io(a,i.isOptional)}),n=TC(e.rest),o=xr(n,(i)=>tn(i,t));return r===e.elements&&o===n?e:new Fc(r,o.map((i)=>new Ha(i)),e.isReadonly)}case"TypeLiteral":{let r=xr(e.propertySignatures,(o)=>{let i=tn(o.type,t);return i===o.type?o:new ct(o.name,i,o.isOptional,o.isReadonly)}),n=xr(e.indexSignatures,(o)=>{let i=tn(o.type,t);return i===o.type?o:new $a(o.parameter,i,o.isReadonly)});return r===e.propertySignatures&&n===e.indexSignatures?e:new nn(r,n)}case"Union":{let r=xr(e.types,(n)=>tn(n,t));return r===e.types?e:qt.make(r)}case"Suspend":{let r=void 0,n=$q(e);if(Re(n)){let o=t?"Bound":"";r={[Xy]:`${n.value}Encoded${o}`}}return new xd(()=>tn(e.f(),t),r)}case"Refinement":{let r=tn(e.from,t);if(t){if(r===e.from)return e;if(Ay(e.from)===void 0&&Zy(e))return new Lc(r,e.filter,e.annotations);return r}else return r}case"Transformation":return tn(e.from,t)}return e},bd=(e)=>tn(e,!1),Ue=(e)=>{let t={};for(let r of Object.getOwnPropertySymbols(e))t[String(r)]=e[r];return t},ax=(e)=>{switch(e._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return e;case"Refinement":return ax(e.from)}},Lr=(e)=>ve(rn(e),()=>e._tag),AC=(e)=>Wy(e).pipe(Er(()=>Gy(e)),Er(()=>Jy(e)),vr((t)=>t+t2(e))),rn=(e)=>Er(Mc(e),()=>AC(e));var sx=x(()=>{Ve();H();Be();ky();Ic();gc();Ye();Zl();ge();hg();Yk=Symbol.for("effect/annotation/TypeConstructor"),Py=Symbol.for("effect/annotation/Brand"),Zk=Symbol.for("effect/annotation/SchemaId"),Iy=Symbol.for("effect/annotation/Message"),ld=Symbol.for("effect/annotation/MissingMessage"),ud=Symbol.for("effect/annotation/Identifier"),zt=Symbol.for("effect/annotation/Title"),pd=Symbol.for("effect/annotation/AutoTitle"),jn=Symbol.for("effect/annotation/Description"),My=Symbol.for("effect/annotation/Examples"),Ny=Symbol.for("effect/annotation/Default"),Fy=Symbol.for("effect/annotation/JSONSchema"),Ly=Symbol.for("effect/annotation/Arbitrary"),Dy=Symbol.for("effect/annotation/Pretty"),qy=Symbol.for("effect/annotation/Equivalence"),Xk=Symbol.for("effect/annotation/Documentation"),Uy=Symbol.for("effect/annotation/Concurrency"),Hy=Symbol.for("effect/annotation/Batching"),$y=Symbol.for("effect/annotation/ParseIssueTitle"),jy=Symbol.for("effect/annotation/ParseOptions"),By=Symbol.for("effect/annotation/DecodingFallback"),Vy=Symbol.for("effect/annotation/Surrogate"),zy=Symbol.for("effect/annotation/StableFilter"),It=d(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?N(e.annotations[t]):C()),Ky=It(Py),Qk=It(Iy),eC=It(ld),Wy=It(zt),Jy=It(pd),Mc=It(ud),Gy=It(jn),tC=It(Uy),rC=It(Hy),nC=It($y),oC=It(jy),iC=It(By),Yy=It(Vy),Uq=It(zy),Xy=Symbol.for("effect/annotation/JSONIdentifier"),Hq=It(Xy);dd=Nc("Literal"),aC=new Pi(null);md=new sC({[zt]:"undefined"});jq=new cC({[zt]:"void"});hd=new lC({[zt]:"never"});Qy=new uC({[zt]:"unknown"});dC=new pC({[zt]:"any"});mC=new fC({[zt]:"string",[jn]:"a string"}),gd=Nc("StringKeyword");gC=new hC({[zt]:"number",[jn]:"a number"});xC=new yC({[zt]:"boolean",[jn]:"a boolean"});Bq=new SC({[zt]:"bigint",[jn]:"a bigint"});Vq=new bC({[zt]:"symbol",[jn]:"a symbol"}),_C=Nc("SymbolKeyword");zq=new wC({[zt]:"object",[jn]:"an object in the TypeScript meaning, i.e. the `object` type"});Io=class Io extends Ha{isOptional;constructor(e,t,r={}){super(e,r);this.isOptional=t}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:Ue(this.annotations)}}toString(){return String(this.type)+(this.isOptional?"?":"")}};ct=class ct extends Io{name;isReadonly;constructor(e,t,r,n,o){super(t,r,o);this.name=e,this.isReadonly=n}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:Ue(this.annotations)}}};Jq=vn(Yl(en,(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})),Gq={string:"StringKeyword",number:"NumberKeyword",boolean:"BooleanKeyword",bigint:"BigIntKeyword"};ex=Nc("Union"),Cy=j(Symbol.for("effect/Schema/AST/toJSONMemoMap"),()=>new WeakMap);Dc=Nc("Refinement"),Sd={};e2=ix([My,Ny,Fy,Ly,Dy,qy])});class lt{path;actual;issue;_tag="Pointer";constructor(e,t,r){this.path=e,this.actual=t,this.issue=r}}class ux{actual;message;_tag="Unexpected";constructor(e,t){this.actual=e,this.message=t}}class ja{ast;message;_tag="Missing";actual=void 0;constructor(e,t){this.ast=e,this.message=t}}class He{ast;actual;issues;output;_tag="Composite";constructor(e,t,r,n){this.ast=e,this.actual=t,this.issues=r,this.output=n}}class wd{ast;actual;kind;issue;_tag="Refinement";constructor(e,t,r,n){this.ast=e,this.actual=t,this.kind=r,this.issue=n}}class Td{ast;actual;kind;issue;_tag="Transformation";constructor(e,t,r,n){this.ast=e,this.actual=t,this.kind=r,this.issue=n}}class Sr{ast;actual;message;_tag="Type";constructor(e,t,r){this.ast=e,this.actual=t,this.message=r}}class px{ast;actual;message;_tag="Forbidden";constructor(e,t,r){this.ast=e,this.actual=t,this.message=r}}function Dr(e){return e.sort(a2).map((t)=>t[1])}function d2(e){return Gy(e).pipe(Er(()=>Wy(e)),Er(()=>Jy(e)),Er(()=>Mc(e)),ve(()=>`{ ${e.from} | filter }`))}function f2(e){if(e.message!==void 0)return e.message;return`Expected ${Dc(e.ast)?d2(e.ast):String(e.ast)}, actual ${Kr(e.actual)}`}var IC,FC,fx=(e)=>new FC({issue:e}),LC,DC,Wt,Bn,qr,Ed,qC,UC=(e,t)=>{if(t===void 0||Xt(t))return e;if(e===void 0)return t;return{...e,...t}},HC=(e,t,r)=>{let n=Mt(e,t);return(o,i)=>n(o,UC(r,i))},r2=(e,t,r)=>{let n=HC(e,t,r);return(o,i)=>im(n(o,i),fx)},$C=(e,t)=>HC(e.ast,!0,t),vd=(e,t)=>r2(st(e.ast),!0,t),n2,o2,Mt=(e,t)=>{let r=t?n2:o2,n=r.get(e);if(n)return n;let o=i2(e,t),i=oC(e),a=Re(i)?(l,u)=>o(l,UC(u,i.value)):o,s=iC(e),c=t&&Re(s)?(l,u)=>Hc(qC(a(l,u),s.value),e,l,u):a;return r.set(e,c),c},cx=(e)=>Bt(tC(e)),lx=(e)=>Bt(rC(e)),i2=(e,t)=>{switch(e._tag){case"Refinement":if(t){let r=Mt(e.from,!0);return(n,o)=>{o=o??Sd;let i=o?.errors==="all",a=Bn(qC(r(n,o),(s)=>{let c=new wd(e,n,"From",s);if(i&&Zy(e)&&KC(s))return Ge(e.filter(n,o,e),{onNone:()=>K(c),onSome:(l)=>K(new He(e,n,[c,new wd(e,n,"Predicate",l)]))});return K(c)}),(s)=>Ge(e.filter(s,o,e),{onNone:()=>Z(s),onSome:(c)=>K(new wd(e,n,"Predicate",c))}));return Hc(a,e,n,o)}}else{let r=Mt(st(e),!0),n=Mt(BC(e.from),!1);return(o,i)=>Hc(Bn(r(o,i),(a)=>n(a,i)),e,o,i)}case"Transformation":{let r=s2(e.transformation,t),n=t?Mt(e.from,!0):Mt(e.to,!1),o=t?Mt(e.to,!0):Mt(e.from,!1);return(i,a)=>Hc(Bn(Ed(n(i,a),(s)=>new Td(e,i,t?"Encoded":"Type",s)),(s)=>Bn(Ed(r(s,a??Sd,e,i),(c)=>new Td(e,i,"Transformation",c)),(c)=>Ed(o(c,a),(l)=>new Td(e,i,t?"Type":"Encoded",l)))),e,i,a)}case"Declaration":{let r=t?e.decodeUnknown(...e.typeParameters):e.encodeUnknown(...e.typeParameters);return(n,o)=>Hc(r(n,o??Sd,e),e,n,o)}case"Literal":return Kt(e,(r)=>r===e.literal);case"UniqueSymbol":return Kt(e,(r)=>r===e.symbol);case"UndefinedKeyword":return Kt(e,Ub);case"NeverKeyword":return Kt(e,Hb);case"UnknownKeyword":case"AnyKeyword":case"VoidKeyword":return Z;case"StringKeyword":return Kt(e,xt);case"NumberKeyword":return Kt(e,Xt);case"BooleanKeyword":return Kt(e,Wo);case"BigIntKeyword":return Kt(e,eo);case"SymbolKeyword":return Kt(e,Jo);case"ObjectKeyword":return Kt(e,Dt);case"Enums":return Kt(e,(r)=>e.enums.some(([n,o])=>o===r));case"TemplateLiteral":{if(e.spans.every((n)=>gd(n.type)))return Kt(e,(n)=>{if(!xt(n)||!n.startsWith(e.head))return!1;let o=e.head.length;for(let a=0;a<e.spans.length-1;a++){let s=e.spans[a].literal,c=n.indexOf(s,o);if(c===-1)return!1;o=c+s.length}let i=e.spans[e.spans.length-1].literal;return n.endsWith(i)&&n.length-i.length>=o});let r=CC(e);return Kt(e,(n)=>xt(n)&&r.test(n))}case"TupleType":{let r=e.elements.map((l)=>Mt(l.type,t)),n=e.rest.map((l)=>Mt(l.type,t)),o=e.elements.filter((l)=>!l.isOptional);if(e.rest.length>0)o=o.concat(e.rest.slice(1));let i=o.length,a=e.elements.length>0?e.elements.map((l,u)=>u).join(" | "):"never",s=cx(e),c=lx(e);return(l,u)=>{if(!dm(l))return K(new Sr(e,l));let p=u?.errors==="all",f=[],h=0,m=[],w=l.length;for(let P=w;P<=i-1;P++){let z=new lt(P,l,new ja(o[P-w]));if(p){f.push([h++,z]);continue}else return K(new He(e,l,z,m))}if(e.rest.length===0)for(let P=e.elements.length;P<=w-1;P++){let z=new lt(P,l,new ux(l[P],`is unexpected, expected: ${a}`));if(p){f.push([h++,z]);continue}else return K(new He(e,l,z,m))}let S=0,y=void 0;for(;S<r.length;S++)if(w<S+1){if(e.elements[S].isOptional)continue}else{let P=r[S],z=P(l[S],u);if(Wt(z)){if(Ee(z)){let Y=new lt(S,l,z.left);if(p){f.push([h++,Y]);continue}else return K(new He(e,l,Y,Dr(m)))}m.push([h++,z.right])}else{let Y=h++,D=S;if(!y)y=[];y.push(({es:te,output:F})=>Fr(Ai(z),(ie)=>{if(Ee(ie)){let ae=new lt(D,l,ie.left);if(p)return te.push([Y,ae]),or;else return K(new He(e,l,ae,Dr(F)))}return F.push([Y,ie.right]),or}))}}if(we(n)){let[P,...z]=n;for(;S<w-z.length;S++){let Y=P(l[S],u);if(Wt(Y))if(Ee(Y)){let D=new lt(S,l,Y.left);if(p){f.push([h++,D]);continue}else return K(new He(e,l,D,Dr(m)))}else m.push([h++,Y.right]);else{let D=h++,te=S;if(!y)y=[];y.push(({es:F,output:ie})=>Fr(Ai(Y),(ae)=>{if(Ee(ae)){let ee=new lt(te,l,ae.left);if(p)return F.push([D,ee]),or;else return K(new He(e,l,ee,Dr(ie)))}else return ie.push([D,ae.right]),or}))}}for(let Y=0;Y<z.length;Y++){let D=S+Y;if(w<D+1)continue;else{let te=z[Y](l[D],u);if(Wt(te)){if(Ee(te)){let F=new lt(D,l,te.left);if(p){f.push([h++,F]);continue}else return K(new He(e,l,F,Dr(m)))}m.push([h++,te.right])}else{let F=h++;if(!y)y=[];y.push(({es:ie,output:ae})=>Fr(Ai(te),(ee)=>{if(Ee(ee)){let Oe=new lt(D,l,ee.left);if(p)return ie.push([F,Oe]),or;else return K(new He(e,l,Oe,Dr(ae)))}return ae.push([F,ee.right]),or}))}}}}let R=({es:P,output:z})=>io(P)?K(new He(e,l,Dr(P),Dr(z))):Z(Dr(z));if(y&&y.length>0){let P=y;return Ac(()=>{let z={es:ra(f),output:ra(m)};return Fr(Cc(P,(Y)=>Y(z),{concurrency:s,batching:c,discard:!0}),()=>R(z))})}return R({output:m,es:f})}}case"TypeLiteral":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return Kt(e,$b);let r=[],n={},o=[];for(let u of e.propertySignatures)r.push([Mt(u.type,t),u]),n[u.name]=null,o.push(u.name);let i=e.indexSignatures.map((u)=>[Mt(u.parameter,t),Mt(u.type,t),u.parameter]),a=qt.make(e.indexSignatures.map((u)=>u.parameter).concat(o.map((u)=>Jo(u)?new fd(u):new Pi(u)))),s=Mt(a,t),c=cx(e),l=lx(e);return(u,p)=>{if(!jf(u))return K(new Sr(e,u));let f=p?.errors==="all",h=[],m=0,w=p?.onExcessProperty==="error",S=p?.onExcessProperty==="preserve",y={},R;if(w||S){R=Reflect.ownKeys(u);for(let D of R){let te=s(D,p);if(Wt(te)&&Ee(te))if(w){let F=new lt(D,u,new ux(u[D],`is unexpected, expected: ${String(a)}`));if(f){h.push([m++,F]);continue}else return K(new He(e,u,F,y))}else y[D]=u[D]}}let P=void 0,z=p?.exact===!0;for(let D=0;D<r.length;D++){let te=r[D][1],F=te.name,ie=Object.prototype.hasOwnProperty.call(u,F);if(!ie){if(te.isOptional)continue;else if(z){let Oe=new lt(F,u,new ja(te));if(f){h.push([m++,Oe]);continue}else return K(new He(e,u,Oe,y))}}let ae=r[D][0],ee=ae(u[F],p);if(Wt(ee)){if(Ee(ee)){let Oe=new lt(F,u,ie?ee.left:new ja(te));if(f){h.push([m++,Oe]);continue}else return K(new He(e,u,Oe,y))}y[F]=ee.right}else{let Oe=m++,yt=F;if(!P)P=[];P.push(({es:vt,output:Ot})=>Fr(Ai(ee),($e)=>{if(Ee($e)){let We=new lt(yt,u,ie?$e.left:new ja(te));if(f)return vt.push([Oe,We]),or;else return K(new He(e,u,We,Ot))}return Ot[yt]=$e.right,or}))}}for(let D=0;D<i.length;D++){let te=i[D],F=te[0],ie=te[1],ae=Ty(u,te[2]);for(let ee of ae){let Oe=F(ee,p);if(Wt(Oe)&&Rt(Oe)){let yt=ie(u[ee],p);if(Wt(yt)){if(Ee(yt)){let vt=new lt(ee,u,yt.left);if(f){h.push([m++,vt]);continue}else return K(new He(e,u,vt,y))}else if(!Object.prototype.hasOwnProperty.call(n,ee))y[ee]=yt.right}else{let vt=m++,Ot=ee;if(!P)P=[];P.push(({es:$e,output:We})=>Fr(Ai(yt),(je)=>{if(Ee(je)){let yn=new lt(Ot,u,je.left);if(f)return $e.push([vt,yn]),or;else return K(new He(e,u,yn,We))}else{if(!Object.prototype.hasOwnProperty.call(n,ee))We[ee]=je.right;return or}}))}}}}let Y=({es:D,output:te})=>{if(io(D))return K(new He(e,u,Dr(D),te));if(p?.propertyOrder==="original"){let F=R||Reflect.ownKeys(u);for(let ae of o)if(F.indexOf(ae)===-1)F.push(ae);let ie={};for(let ae of F)if(Object.prototype.hasOwnProperty.call(te,ae))ie[ae]=te[ae];return Z(ie)}return Z(te)};if(P&&P.length>0){let D=P;return Ac(()=>{let te={es:ra(h),output:Object.assign({},y)};return Fr(Cc(D,(F)=>F(te),{concurrency:c,batching:l,discard:!0}),()=>Y(te))})}return Y({es:h,output:y})}}case"Union":{let r=jC(e.types,t),n=Reflect.ownKeys(r.keys),o=n.length,i=e.types.length,a=new Map;for(let l=0;l<i;l++)a.set(e.types[l],Mt(e.types[l],t));let s=cx(e)??1,c=lx(e);return(l,u)=>{let p=[],f=0,h=[];if(o>0)if(Ss(l))for(let S=0;S<o;S++){let y=n[S],R=r.keys[y].buckets;if(Object.prototype.hasOwnProperty.call(l,y)){let P=String(l[y]);if(Object.prototype.hasOwnProperty.call(R,P))h=h.concat(R[P]);else{let{candidates:z,literals:Y}=r.keys[y],D=qt.make(Y),te=z.length===i?new nn([new ct(y,D,!1,!0)],[]):qt.make(z);p.push([f++,new He(te,l,new lt(y,l,new Sr(D,l[y])))])}}else{let{candidates:P,literals:z}=r.keys[y],Y=new ct(y,qt.make(z),!1,!0),D=P.length===i?new nn([Y],[]):qt.make(P);p.push([f++,new He(D,l,new lt(y,l,new ja(Y)))])}}else{let S=r.candidates.length===i?e:qt.make(r.candidates);p.push([f++,new Sr(S,l)])}if(r.otherwise.length>0)h=h.concat(r.otherwise);let m=void 0;for(let S=0;S<h.length;S++){let y=h[S],R=a.get(y)(l,u);if(Wt(R)&&(!m||m.length===0))if(Rt(R))return R;else p.push([f++,R.left]);else{let P=f++;if(!m)m=[];m.push((z)=>Ac(()=>{if("finalResult"in z)return or;else return Fr(Ai(R),(Y)=>{if(Rt(Y))z.finalResult=Y;else z.es.push([P,Y.left]);return or})}))}}let w=(S)=>io(S)?S.length===1&&S[0][1]._tag==="Type"?K(S[0][1]):K(new He(e,l,Dr(S))):K(new Sr(e,l));if(m&&m.length>0){let S=m;return Ac(()=>{let y={es:ra(p)};return Fr(Cc(S,(R)=>R(y),{concurrency:s,batching:c,discard:!0}),()=>{if("finalResult"in y)return y.finalResult;return w(y.es)})})}return w(p)}}case"Suspend":{let r=Pc(()=>Mt(e.f(),t));return(n,o)=>r()(n,o)}}},Kt=(e,t)=>(r)=>t(r)?Z(r):K(new Sr(e,r)),Uc=(e,t)=>{switch(e._tag){case"Declaration":{let r=Yy(e);if(Re(r))return Uc(r.value,t);break}case"TypeLiteral":{let r=[];for(let n=0;n<e.propertySignatures.length;n++){let o=e.propertySignatures[n],i=t?bd(o.type):st(o.type);if(dd(i)&&!o.isOptional)r.push([o.name,i])}return r}case"TupleType":{let r=[];for(let n=0;n<e.elements.length;n++){let o=e.elements[n],i=t?bd(o.type):st(o.type);if(dd(i)&&!o.isOptional)r.push([n,i])}return r}case"Refinement":return Uc(e.from,t);case"Suspend":return Uc(e.f(),t);case"Transformation":return Uc(t?e.from:e.to,t)}return[]},jC=(e,t)=>{let r={},n=[],o=[];for(let i=0;i<e.length;i++){let a=e[i],s=Uc(a,t);if(s.length>0){o.push(a);for(let c=0;c<s.length;c++){let[l,u]=s[c],p=String(u.literal);r[l]=r[l]||{buckets:{},literals:[],candidates:[]};let f=r[l].buckets;if(Object.prototype.hasOwnProperty.call(f,p)){if(c<s.length-1)continue;f[p].push(a),r[l].literals.push(u),r[l].candidates.push(a)}else{f[p]=[a],r[l].literals.push(u),r[l].candidates.push(a);break}}}else n.push(a)}return{keys:r,otherwise:n,candidates:o}},BC=(e)=>Dc(e)?BC(e.from):e,Hc=(e,t,r,n)=>{if(n?.isEffectAllowed===!0)return e;if(Wt(e))return e;let o=new bc,i=Ak(e,{scheduler:o});o.flush();let a=i.unsafePoll();if(a){if(kO(a))return Z(a.value);let s=a.cause;if(bE(s))return K(s.error);return K(new px(t,r,_E(s)))}return K(new px(t,r,"cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work"))},a2=([e],[t])=>e>t?1:e<t?-1:0,s2=(e,t)=>{switch(e._tag){case"FinalTransformation":return t?e.decode:e.encode;case"ComposeTransformation":return Z;case"TypeLiteralTransformation":return(r)=>{let n=Z(r);for(let o of e.propertySignatureTransformations){let[i,a]=t?[o.from,o.to]:[o.to,o.from],s=t?o.decode:o.encode;n=qr(n,(l)=>{let u=s(Object.prototype.hasOwnProperty.call(l,i)?N(l[i]):C());if(delete l[i],Re(u))l[a]=u.value;return l})}return n}}},Ut=(e,t=[])=>({value:e,forest:t}),$c,c2=(e)=>e.value+VC(`
|
|
34
|
+
`,e.forest),VC=(e,t)=>{let r="",n=t.length,o;for(let i=0;i<n;i++){o=t[i];let a=i===n-1;r+=e+(a?"\u2514":"\u251C")+"\u2500 "+o.value,r+=VC(e+(n>1&&!a?"\u2502 ":" "),o.forest)}return r},l2=(e)=>{switch(e){case"Encoded":return"Encoded side transformation failure";case"Transformation":return"Transformation process failure";case"Type":return"Type side transformation failure"}},u2=(e)=>{switch(e){case"From":return"From side refinement failure";case"Predicate":return"Predicate refinement failure"}},zC=(e)=>("ast"in e)?N(e.ast):C(),dx,p2=(e)=>zC(e).pipe(Or(Qk),Ge({onNone:()=>dx,onSome:(t)=>{let r=t(e);if(xt(r))return Z({message:r,override:!1});if(Rk(r))return ad(r,(n)=>({message:n,override:!1}));if(xt(r.message))return Z({message:r.message,override:r.override});return ad(r.message,(n)=>({message:n,override:r.override}))}})),mx=(e)=>(t)=>t._tag===e,KC,MC,NC,jc=(e)=>Bn(p2(e),(t)=>{if(t!==void 0)return!t.override&&(KC(e)||MC(e)&&e.kind==="From"||NC(e)&&e.kind!=="Transformation")?NC(e)||MC(e)?jc(e.issue):dx:Z(t.message);return dx}),WC=(e)=>zC(e).pipe(Or(nC),g_((t)=>t(e)),Bt),m2=(e)=>qr(jc(e),(t)=>t??WC(e)??f2(e)),_d=(e)=>WC(e)??String(e.ast),h2=(e)=>e.message??"is forbidden",g2=(e)=>e.message??"is unexpected",y2=(e)=>{let t=eC(e.ast);if(Re(t)){let r=t.value();return xt(r)?Z(r):r}return Z(e.message??"is missing")},Ba=(e)=>{switch(e._tag){case"Type":return qr(m2(e),Ut);case"Forbidden":return Z(Ut(_d(e),[Ut(h2(e))]));case"Unexpected":return Z(Ut(g2(e)));case"Missing":return qr(y2(e),Ut);case"Transformation":return Bn(jc(e),(t)=>{if(t!==void 0)return Z(Ut(t));return qr(Ba(e.issue),(r)=>Ut(_d(e),[Ut(l2(e.kind),[r])]))});case"Refinement":return Bn(jc(e),(t)=>{if(t!==void 0)return Z(Ut(t));return qr(Ba(e.issue),(r)=>Ut(_d(e),[Ut(u2(e.kind),[r])]))});case"Pointer":return qr(Ba(e.issue),(t)=>Ut(sd(e.path),[t]));case"Composite":return Bn(jc(e),(t)=>{if(t!==void 0)return Z(Ut(t));let r=_d(e);return Ey(e.issues)?qr(Cc(e.issues,Ba),(n)=>Ut(r,n)):qr(Ba(e.issues),(n)=>Ut(r,[n]))})}};var JC=x(()=>{Ve();wE();dv();Ik();er();CO();H();Be();Ic();Ye();ge();Vp();sx();IC=Symbol.for("effect/Schema/ParseErrorTypeId");FC=class FC extends pv("ParseError"){[IC]=IC;get message(){return this.toString()}toString(){return $c.formatIssueSync(this.issue)}toJSON(){return{_id:"ParseError",message:this.toString()}}[re](){return this.toJSON()}};LC=Z,DC=K,Wt=om,Bn=d(2,(e,t)=>Wt(e)?As(e,{onLeft:K,onRight:t}):Fr(e,t)),qr=d(2,(e,t)=>Wt(e)?l_(e,t):ad(e,t)),Ed=d(2,(e,t)=>Wt(e)?Gl(e,t):Ck(e,t)),qC=d(2,(e,t)=>Wt(e)?As(e,{onLeft:t,onRight:Z}):kk(e,t)),n2=j(Symbol.for("effect/ParseResult/decodeMemoMap"),()=>new WeakMap),o2=j(Symbol.for("effect/ParseResult/encodeMemoMap"),()=>new WeakMap);$c={formatIssue:(e)=>qr(Ba(e),c2),formatIssueSync:(e)=>{let t=$c.formatIssue(e);return Wt(t)?p_(t):Pk(t)},formatError:(e)=>$c.formatIssue(e.issue),formatErrorSync:(e)=>$c.formatIssueSync(e.issue)},dx=Z(void 0),KC=mx("Composite"),MC=mx("Refinement"),NC=mx("Transformation")});var GC,YC;var ZC=x(()=>{H();ge();GC=d((e)=>Dt(e[0]),(e,...t)=>{let r={};for(let n of t)if(n in e)r[n]=e[n];return r}),YC=d((e)=>Dt(e[0]),(e,...t)=>{let r={...e};for(let n of t)delete r[n];return r})});function wt(e){return class{[Bc]=XC;static ast=e;static annotations(r){return wt(on(this.ast,r))}static pipe(){return E(this,arguments)}static toString(){return String(e)}static Type;static Encoded;static Context;static[Bc]=XC}}function b2(e){return yd(e)?qt.make(OC(e,(t)=>new Pi(t))):new Pi(e[0])}function aA(e,t=b2(e)){return class extends wt(t){static annotations(n){return aA(this.literals,on(this.ast,n))}static literals=[...e]}}function T(...e){return we(e)?aA(e):yx}function gx(e,t){return class extends wt(t){static annotations(n){return gx(this.typeParameters,on(this.ast,n))}static typeParameters=[...e]}}function cA(e,t=T2(e)){return class extends wt(t){static annotations(n){return cA(this.members,on(this.ast,n))}static members=[...e]}}function ye(...e){return yd(e)?cA(e):we(e)?e[0]:yx}function Od(e,t,r=v2(e,t)){return class extends wt(r){static annotations(o){return Od(this.elements,this.rest,on(this.ast,o))}static elements=[...e];static rest=[...t]}}function lA(...e){return Array.isArray(e[0])?Od(e[0],e.slice(1)):Od(e,[])}function uA(e,t){return class extends Od([],[e],t){static annotations(n){return uA(this.value,on(this.ast,n))}static value=e}}class dA{from;to;decode;encode;_tag="PropertySignatureTransformation";constructor(e,t,r,n){this.from=e,this.to=t,this.decode=r,this.encode=n}toString(){return`PropertySignature<${hx(this.to.isOptional)}, ${this.to.type}, ${O2(this.from.fromKey)}, ${hx(this.from.isOptional)}, ${this.from.type}>`}}function wx(e,t,r=k2(e,t)){return class extends wt(r){static annotations(o){return wx(this.fields,this.records,on(this.ast,o))}static fields={...e};static records=[...t];static make=(o,i)=>{let a=C2(e,{...o});return Ox(i)?a:vd(this)(a)};static pick(...o){return b(GC(e,...o))}static omit(...o){return b(YC(e,...o))}}}function b(e,...t){return wx(e,t)}function gA(e,t,r){return class extends wx({},[{key:e,value:t}],r){static annotations(o){return gA(e,t,on(this.ast,o))}static key=e;static value=t}}function yA(e,t){return class extends wt(t){static annotations(n){return yA(this.from,on(this.ast,n))}static make=(n,o)=>Ox(o)?n:vd(this)(n);static from=e}}function xA(e,t,r){return class extends wt(r){static annotations(o){return xA(this.from,this.filter,on(this.ast,o))}static[A2]=e;static from=e;static filter=t;static make=(o,i)=>Ox(i)?o:vd(this)(o)}}function Xe(e,t){return(r)=>{function n(i,a,s){return P2(e(i,a,s),s,i)}let o=new Lc(r.ast,n,Ii(t));return xA(r,n,o)}}function Ox(e){return Wo(e)?e:e?.disableValidation??!1}var Bc,XC,QC,Ii=(e)=>{if(!e)return{};let t={...e};for(let r in QC)if(r in e){let n=QC[r];t[n]=e[r],delete t[r]}return t},on=(e,t)=>qc(e,Ii(t)),iA=(e,t)=>{let r=$C(e,t);return(n,o)=>Gl(r(n,o),fx)},eA=(e)=>k(e,Bc)&&Dt(e[Bc]),_2=(e,t,r)=>gx(e,new Ua(e.map((n)=>n.ast),(...n)=>t.decode(...n.map(wt)),(...n)=>t.encode(...n.map(wt)),Ii(r))),w2=(e,t)=>{let r=()=>(o,i,a)=>e(o)?LC(o):DC(new Sr(a,o));return gx([],new Ua([],r,r,Ii(t)))},q=function(){if(Array.isArray(arguments[0])){let r=arguments[0],n=arguments[1],o=arguments[2];return _2(r,n,o)}let e=arguments[0],t=arguments[1];return w2(e,t)},sA,ut,yx,xx,A,Jt,W,T2=(e)=>qt.make(e.map((t)=>t.ast)),E2=(e)=>ye(e,sA),v2=(e,t)=>new Fc(e.map((r)=>eA(r)?new Io(r.ast,!1):r.ast),t.map((r)=>eA(r)?new Ha(r.ast):r.ast),!0),U=(e)=>uA(e),hx=(e)=>e?'"?:"':'":"',Sx,pA,O2=(e)=>{if(e===void 0)return"never";if(xt(e))return JSON.stringify(e);return String(e)},fA=(e,t)=>{switch(e._tag){case"PropertySignatureDeclaration":return new Sx(e.type,e.isOptional,e.isReadonly,{...e.annotations,...t},e.defaultValue);case"PropertySignatureTransformation":return new dA(e.from,new pA(e.to.type,e.to.isOptional,e.to.isReadonly,{...e.to.annotations,...t},e.to.defaultValue),e.decode,e.encode)}},mA,hA=(e)=>k(e,mA),bx,_x,_=(e)=>{let t=e.ast===md||e.ast===hd?md:E2(e).ast;return new _x(new Sx(t,!0,!0,{},void 0),e)},R2,k2=(e,t)=>{let r=Reflect.ownKeys(e),n=[];if(r.length>0){let i=[],a=[],s=[];for(let c=0;c<r.length;c++){let l=r[c],u=e[l];if(hA(u)){let p=u.ast;switch(p._tag){case"PropertySignatureDeclaration":{let{type:f,isOptional:h,annotations:m}=p;i.push(new ct(l,f,h,!0,R2(p))),a.push(new ct(l,st(f),h,!0,m)),n.push(new ct(l,f,h,!0,m));break}case"PropertySignatureTransformation":{let f=p.from.fromKey??l;i.push(new ct(f,p.from.type,p.from.isOptional,!0,p.from.annotations)),a.push(new ct(l,p.to.type,p.to.isOptional,!0,p.to.annotations)),s.push(new rx(f,l,p.decode,p.encode));break}}}else i.push(new ct(l,u.ast,!1,!0)),a.push(new ct(l,st(u.ast),!1,!0)),n.push(new ct(l,u.ast,!1,!0))}if(we(s)){let c=[],l=[];for(let u of t){let{indexSignatures:p,propertySignatures:f}=ox(u.key.ast,u.value.ast);f.forEach((h)=>{i.push(h),a.push(new ct(h.name,st(h.type),h.isOptional,h.isReadonly,h.annotations))}),p.forEach((h)=>{c.push(h),l.push(new $a(h.parameter,st(h.type),h.isReadonly))})}return new tx(new nn(i,c,{[pd]:"Struct (Encoded side)"}),new nn(a,l,{[pd]:"Struct (Type side)"}),new nx(s))}}let o=[];for(let i of t){let{indexSignatures:a,propertySignatures:s}=ox(i.key.ast,i.value.ast);s.forEach((c)=>n.push(c)),a.forEach((c)=>o.push(c))}return new nn(n,o)},C2=(e,t)=>{let r=Reflect.ownKeys(e);for(let n of r){let o=e[n];if(t[n]===void 0&&hA(o)){let i=o.ast,a=i._tag==="PropertySignatureDeclaration"?i.defaultValue:i.to.defaultValue;if(a!==void 0)t[n]=a()}}return t},Rd=(e)=>gA(e.key,e.value),Vc=(e,t)=>(r)=>{let n=Ge(Ky(r.ast),{onNone:()=>[e],onSome:(i)=>[...i,e]}),o=qc(r.ast,Ii({[Py]:n,...t}));return yA(r,o)},A2,tA=(e,t,r)=>{if(Wo(e))return e?C():N(new Sr(t,r));if(xt(e))return N(new Sr(t,r,e));if(e!==void 0){if("_tag"in e)return N(e);let n=new Sr(t,r,e.message);return N(we(e.path)?new lt(e.path,r,n):n)}return C()},P2=(e,t,r)=>{if(Nk(e))return tA(e,t,r);if(we(e)){let n=Ql(e,(o)=>tA(o,t,r));if(we(n))return N(n.length===1?n[0]:new He(t,r,n))}return C()},I2,Tx=(e,t)=>(r)=>r.pipe(Xe((n)=>n.length<=e,{schemaId:I2,title:`maxLength(${e})`,description:`a string at most ${e} character(s) long`,jsonSchema:{maxLength:e},...t})),M2,Va=(e,t)=>(r)=>r.pipe(Xe((n)=>n.length>=e,{schemaId:M2,title:`minLength(${e})`,description:`a string at least ${e} character(s) long`,jsonSchema:{minLength:e},...t})),rA,de=(e,t)=>(r)=>{let n=e.source;return r.pipe(Xe((o)=>(e.lastIndex=0,e.test(o)),{schemaId:rA,[rA]:{regex:e},description:`a string matching the pattern ${n}`,jsonSchema:{pattern:n},...t}))},N2,nA,F2,L2,Ex=(e,t)=>(r)=>r.pipe(Xe((n)=>n>e,{schemaId:L2,title:`greaterThan(${e})`,description:e===0?"a positive number":`a number greater than ${e}`,jsonSchema:{exclusiveMinimum:e},...t})),D2,SA=(e,t)=>(r)=>r.pipe(Xe((n)=>n>=e,{schemaId:D2,title:`greaterThanOrEqualTo(${e})`,description:e===0?"a non-negative number":`a number greater than or equal to ${e}`,jsonSchema:{minimum:e},...t})),q2,kd=(e)=>(t)=>t.pipe(Xe((r)=>Number.isSafeInteger(r),{schemaId:q2,title:"int",description:"an integer",jsonSchema:{type:"integer"},...e})),vx=(e)=>Ex(0,{title:"positive",...e}),Cd,U2,Ad=(e,t)=>(r)=>{let n=Math.floor(e);if(n<1)throw Error(Fk(`Expected an integer greater than or equal to 1, actual ${e}`));return r.pipe(Xe((o)=>o.length>=n,{schemaId:U2,title:`minItems(${n})`,description:`an array of at least ${n} item(s)`,jsonSchema:{minItems:n},[zy]:!0,...t}))},oA,H2;var Tt=x(()=>{Ve();er();ys();ky();Jk();Ic();Ye();JC();_e();ge();sx();ZC();Bc=Symbol.for("effect/Schema");XC={_A:(e)=>e,_I:(e)=>e,_R:(e)=>e},QC={typeConstructor:Yk,schemaId:Zk,message:Iy,missingMessage:ld,identifier:ud,title:zt,description:jn,examples:My,default:Ny,documentation:Xk,jsonSchema:Fy,arbitrary:Ly,pretty:Dy,equivalence:qy,concurrency:Uy,batching:Hy,parseIssueTitle:$y,parseOptions:jy,decodingFallback:By};sA=class sA extends wt(md){};ut=class ut extends wt(aC){};yx=class yx extends wt(hd){};xx=class xx extends wt(Qy){};A=class A extends wt(mC){};Jt=class Jt extends wt(gC){};W=class W extends wt(xC){};Sx=class Sx extends Io{isReadonly;defaultValue;_tag="PropertySignatureDeclaration";constructor(e,t,r,n,o){super(e,t,n);this.isReadonly=r,this.defaultValue=o}toString(){let e=hx(this.isOptional),t=String(this.type);return`PropertySignature<${e}, ${t}, never, ${e}, ${t}>`}};pA=class pA extends Io{isReadonly;defaultValue;constructor(e,t,r,n,o){super(e,t,n);this.isReadonly=r,this.defaultValue=o}};mA=Symbol.for("effect/PropertySignature");bx=class bx{ast;[Bc];[mA]=null;_TypeToken;_Key;_EncodedToken;_HasDefault;constructor(e){this.ast=e}pipe(){return E(this,arguments)}annotations(e){return new bx(fA(this.ast,Ii(e)))}toString(){return String(this.ast)}};_x=class _x extends bx{from;constructor(e,t){super(e);this.from=t}annotations(e){return new _x(fA(this.ast,Ii(e)),this.from)}};R2=ix([ld]);A2=Symbol.for("effect/SchemaId/Refine");I2=Kk,M2=zk,rA=Symbol.for("effect/SchemaId/Pattern"),N2=Symbol.for("effect/SchemaId/UUID"),nA=/^[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;F2=class F2 extends A.pipe(de(nA,{schemaId:N2,identifier:"UUID",jsonSchema:{format:"uuid",pattern:nA.source},description:"a Universally Unique Identifier",arbitrary:()=>(e)=>e.uuid()})){};L2=jk,D2=Bk,q2=Vk;Cd=class Cd extends Jt.pipe(kd({identifier:"Int"})){};U2=Wk,oA=$k;H2=class H2 extends q(Ul,{typeConstructor:{_tag:"Date"},identifier:"DateFromSelf",schemaId:oA,[oA]:{noInvalidDate:!1},description:"a potentially invalid Date instance",pretty:()=>(e)=>`new Date(${JSON.stringify(e)})`,arbitrary:()=>(e)=>e.date({noInvalidDate:!1}),equivalence:()=>Db}){}});function br(e,t){return iA(e,$2)(t)}var $2;var za=x(()=>{Tt();$2={onExcessProperty:"error"}});function kx(e,t){if(typeof t!=="string")return;let r=e.lastIndexOf("@");if(r<=0)return;let n=e.slice(0,r),o=e.slice(r+1);if(!wA(n)||!_A(o)||t!==o)return;return{pluginName:n,marketplaceName:o,canonicalPluginId:`${n}@openai-curated`}}function Ur(e){let t=e.lastIndexOf("@");if(t<=0)return;let r=e.slice(0,t),n=e.slice(t+1);return wA(r)&&_A(n)?`${r}@openai-curated`:void 0}function _A(e){return bA.includes(e)}function wA(e){return Pd.includes(e)}function Cx(e,t){let r=t??an;return{computer_use:e?.computer_use??r.computer_use,work:e?.work??r.work,frontend:e?.frontend??r.frontend,security:e?.security??r.security}}function Kc(e,t=[]){let r=[],n=new Set;for(let o of TA){if(!e[o])continue;for(let i of zc[o].pluginIds)if(!n.has(i))n.add(i),r.push(i)}for(let o of t)if(!n.has(o))n.add(o),r.push(o);return r}var Rx,j2,B2,V2,bA,Pd,Vn,z2,zc,TA,an;var Ax=x(()=>{Tt();Rx=T("computer_use","work","frontend","security"),j2=T("computer_use","work","frontend","security"),B2=T("installed","disabled","missing","uncertain"),V2=T("healthy","missing","disabled","uncertain"),bA=Object.freeze(["openai-curated","openai-curated-remote"]),Pd=Object.freeze(["build-web-apps","codex-security"]);Vn=Object.freeze({coding:!0,computer_use:!1,work:!1,frontend:!0,security:!0}),z2={work:{name:"work",pluginIds:["documents@openai-primary-runtime","pdf@openai-primary-runtime","presentations@openai-primary-runtime","spreadsheets@openai-primary-runtime","template-creator@openai-primary-runtime"],defaultSelected:Vn.work,migrationKey:"work",semanticSkillIds:["documents:documents","pdf:pdf","presentations:Presentations","spreadsheets:Spreadsheets","template-creator:template-creator"],ownership:"shared-preserve"},frontend:{name:"frontend",pluginIds:["build-web-apps@openai-curated"],defaultSelected:Vn.frontend,migrationKey:"frontend",semanticSkillIds:["build-web-apps:frontend-app-builder","build-web-apps:frontend-testing-debugging","build-web-apps:react-best-practices"],ownership:"shared-preserve"},security:{name:"security",pluginIds:["codex-security@openai-curated"],defaultSelected:Vn.security,migrationKey:"security",semanticSkillIds:["codex-security:security-scan","codex-security:security-diff-scan","codex-security:threat-model"],ownership:"shared-preserve"},computer_use:{name:"computer_use",pluginIds:["computer-use@openai-bundled"],defaultSelected:Vn.computer_use,migrationKey:"computer_use",semanticSkillIds:["computer-use:computer-use"],ownership:"shared-preserve"}},zc=Object.freeze(z2),TA=Object.freeze(["computer_use","work","frontend","security"]),an=Object.freeze({computer_use:Vn.computer_use,work:Vn.work,frontend:Vn.frontend,security:Vn.security})});function sn(e){return b({identifier:T(e),label:A,requiresRootApproval:W})}function EA(e){let t=e.map((n)=>n.label),r=t.at(-1);if(r===void 0)return"";if(t.length===1)return r;return`${t.slice(0,-1).join(", ")}, and ${r}`}function vA(e){return e.length===0?e:`${e[0]?.toUpperCase()??""}${e.slice(1)}`}var OA,K2,W2,Px,J2,RA,G2,Y2,Z2;var kA=x(()=>{Tt();OA=T("local.repository.edit","local.repository.check","local.repository.lint","local.repository.format","local.repository.commit","external.read","specialist.dispatch","vcs.server.mutation","vcs.server.ci-trigger","unknown.effect"),K2=b({identifier:OA,label:A,requiresRootApproval:W});W2=b({localRepositoryEdit:sn("local.repository.edit"),localRepositoryCheck:sn("local.repository.check"),localRepositoryLint:sn("local.repository.lint"),localRepositoryFormat:sn("local.repository.format"),localRepositoryCommit:sn("local.repository.commit"),externalRead:sn("external.read"),specialistDispatch:sn("specialist.dispatch"),versionControlServerMutation:sn("vcs.server.mutation"),versionControlServerCiTrigger:sn("vcs.server.ci-trigger"),unknownEffect:sn("unknown.effect")}),Px={localRepositoryEdit:{identifier:"local.repository.edit",label:"local repository edit",requiresRootApproval:!1},localRepositoryCheck:{identifier:"local.repository.check",label:"local repository check",requiresRootApproval:!1},localRepositoryLint:{identifier:"local.repository.lint",label:"local repository lint",requiresRootApproval:!1},localRepositoryFormat:{identifier:"local.repository.format",label:"local repository format",requiresRootApproval:!1},localRepositoryCommit:{identifier:"local.repository.commit",label:"local repository commit",requiresRootApproval:!1},externalRead:{identifier:"external.read",label:"external read",requiresRootApproval:!1},specialistDispatch:{identifier:"specialist.dispatch",label:"specialist dispatch",requiresRootApproval:!1},versionControlServerMutation:{identifier:"vcs.server.mutation",label:"version-control-server mutation",requiresRootApproval:!0},versionControlServerCiTrigger:{identifier:"vcs.server.ci-trigger",label:"version-control-server CI triggering",requiresRootApproval:!0},unknownEffect:{identifier:"unknown.effect",label:"unclassified effect",requiresRootApproval:!0}};zr(Px);J2=T("never","root"),RA=Object.values(Px);G2=RA.filter((e)=>!e.requiresRootApproval),Y2=RA.filter((e)=>e.requiresRootApproval),Z2=Object.freeze({noRootApproval:`${vA(EA(G2))} actions do not require Root approval.`,rootApproval:`${vA(EA(Y2))} require Root approval.`})});function Id(e){let t=br(X2,e);if(Ee(t))return Ko(ps("sha256 digest",t.left));return Ki(t.right)}var Hr,Ix,M6,N6,F6,X2,Q2,eU,tU,rU;var Md=x(()=>{er();Tt();Wi();za();Hr=A.pipe(de(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u)),Ix=A.pipe(de(/^[0-9a-f]{64}$/u)),M6=Hr.pipe(Vc("RunId")),N6=Hr.pipe(Vc("ProjectId")),F6=Hr.pipe(Vc("TrustId")),X2=Ix.pipe(Vc("Sha256Digest"));Q2=b({run_id:Hr,objective_lineage:Hr,parent_run_id:_(ye(Hr,ut))}),eU=b({project_id:Hr,trust_id:Hr,trust_digest:Ix}),tU=b({project_id:Hr,project_digest:Ix}),rU=A.pipe(de(/^state-[0-9]+\.[0-9]+$/u))});function Mx(e){switch(e){case"go":case"Go":throw Error(`Legacy profile ${e} was removed and requires an explicit replacement.`);case"plus-low":return"low";case"plus":return"default";case"plus-high":return"high";case"pro-5x":case"pro-20x":throw Error(`Legacy profile ${e} was removed and requires an explicit replacement.`);default:return e}}function IA(e){return typeof e==="string"&&oU.has(e)}function aU(e){if(typeof e!=="object"||e===null||!("role"in e)||!("task"in e))return!1;let{role:t,task:r}=e;if(!IA(t)||typeof r!=="string")return!1;return Wc.get(t)?.tasks.some((n)=>n.name===r)===!0}function Fd(e,t){return typeof t==="string"&&Wc.get(e)?.tasks.some((r)=>r.name===t)===!0}function MA(e){return typeof e==="string"&&iU.has(e)}function Dx(e){let t=`${e.role}.${e.task}`;if(!Fx.has(t))throw Error("Unknown native specialist agent type.");return t}function qx(e){let t=Wc.get(e.role)?.tasks.find((r)=>r.name===e.task);if(t===void 0)throw Error("Unknown specialist task policy.");return t.instruction}function Ux(e){let t=Wc.get(e.role)?.tasks.find((r)=>r.name===e.task);if(t===void 0)throw Error("Unknown specialist task policy.");return t.description}function FA(e){let t=Wc.get(e);if(t===void 0)throw Error("Unknown specialist role.");return t}function Hx(e){let t=FA(e.role),r=e.role==="Worker"&&e.task==="operations"?"exact_ref_or_sha":t.permissions.network?"current_sources":"disabled";return Object.freeze({network:r!=="disabled",write:t.permissions.write,networkScope:r})}var Mo,CA,Nd,Mi,nU,AA="Make the smallest complete edit set within the authorized boundary, touch no unrelated paths, avoid speculative refactors or formatting churn, and perform no redundant writes or operations; preserve unrelated work and stop for Root input before expanding scope.",$r,Wc,oU,Nx,iU,PA,Fx,Lx,sU,cU,lU,uU,Jc,Ni,NA,Ka,pU,LA,dU,No;var Gc=x(()=>{Tt();Mo=T("low","default","high"),CA=T("go","Go","plus-low","plus","plus-high","pro-5x","pro-20x"),Nd=ye(Mo,CA);Mi=T("standard","fast","fast-all"),nU=T("low","medium","high","xhigh","max"),$r=[{role:"Explorer",tasks:[{name:"lookup",description:"Use when Root needs one exact repository fact; locate it and return the exact path, symbol, or value.",instruction:"Locate the exact requested repository fact."},{name:"trace",description:"Use when Root needs a complete in-scope execution or reference path; trace every relevant caller and constraint, then return the path and evidence.",instruction:"Trace the complete in-scope execution or reference path."}],capability:"repository-read",authority:"Read only the delegated Assignment repository scope; Git/VCS, lifecycle, and decisions remain Root-only.",evidence:"Return exact paths, symbols, callers, tests, and constraints.",completion:"Account for every in-scope caller and constraint.",permissions:{network:!1,write:!1}},{role:"Librarian",tasks:[{name:"lookup",description:"Use when Root needs one exact current external fact; locate it in the assigned authoritative source and return the citation.",instruction:"Locate the exact requested authoritative external fact."},{name:"research",description:"Use when Root needs a sourced current synthesis; combine the assigned authoritative sources with citations and return the evidence and uncertainty.",instruction:"Synthesize the assigned current sources with citations."}],capability:"current-research",authority:"Research only the delegated Assignment current sources without repository mutation; Git/VCS, lifecycle, and decisions remain Root-only.",evidence:"Return sourced facts, dates, and explicit uncertainty.",completion:"Resolve the assigned external fact or report the exact evidence gap.",permissions:{network:!0,write:!1}},{role:"Worker",tasks:[{name:"mechanical",description:"Use when Root has decided deterministic edits; apply only those edits, verify the result, and return changed paths and evidence.",instruction:"Apply only deterministic, already-decided edits."},{name:"implementation",description:"Use when Root has decided a bounded behavior seam; implement and verify that seam, then return changed paths and evidence.",instruction:"Implement and verify the bounded behavior seam."},{name:"integration",description:"Use when Root has decided seams that must be combined; integrate and verify them together, then return the result and residual risk.",instruction:"Integrate the decided seams and verify them together."},{name:"operations",description:"Use after Root approves an exact ref or SHA; observe required CI and release state to terminal evidence and return it, never treating pending as success.",instruction:"After Root approves an exact ref or SHA, observe required CI and release state through terminal evidence; pending or running state is never success."}],capability:"bounded-write",authority:"Change only the delegated Assignment seam; Intent lifecycle, Git/VCS, and material choices remain Root-only.",evidence:"Return changed files, verification results, and remaining risk.",completion:"Finish the delegated Assignment with proportional proof or an exact blocker and return a compact structured outcome.",permissions:{network:!1,write:!0}},{role:"Reviewer",tasks:[{name:"plan",description:"Use when Root needs a complete plan adversarially checked; review it to a fixed point and return findings, proof, and residual risk.",instruction:"Review the complete plan to a fixed point."},{name:"code",description:"Use when Root needs implemented code adversarially checked; review and repair it to a fixed point, returning findings, proof, and residual risk.",instruction:"Review and repair the implemented code to a fixed point."},{name:"artifact",description:"Use when Root needs a produced artifact inspected; review and repair it to a fixed point, returning findings, proof, and residual risk.",instruction:"Review and repair the produced artifact to a fixed point."}],capability:"bounded-review",authority:"Inspect and repair only reviewer-owned defects within the delegated Assignment; Intent lifecycle, Git/VCS, and material choices remain Root-only.",evidence:"Return findings, repaired paths, verification, and residual risk.",completion:"Reach a fixed point or report each reproducible blocker as a compact structured outcome.",permissions:{network:!1,write:!0}}];zr($r);Wc=new Map($r.map((e)=>[e.role,e])),oU=new Set($r.map((e)=>e.role)),Nx=$r.flatMap((e)=>e.tasks.map((t)=>`${e.role}:${t.name}`)),iU=new Set(Nx),PA=Nx.map((e)=>e.replace(":",".")),Fx=new Set(PA);Lx=q(IA),sU=q((e)=>Fd("Explorer",e)),cU=q((e)=>Fd("Librarian",e)),lU=q((e)=>Fd("Worker",e)),uU=q((e)=>Fd("Reviewer",e)),Jc=q(aU),Ni=Object.freeze(Nx.filter((e)=>MA(e))),NA=q(MA),Ka=Object.freeze(PA.filter((e)=>Fx.has(e))),pU=q((e)=>typeof e==="string"&&Fx.has(e));LA=b({profile:Mo,service_tier:_(Mi)}),dU=T("git_vcs","computer_use"),No=Object.freeze({requiresDelegation:!0,trivialWorkRequiresDelegation:!0,directExecutionExceptions:Object.freeze(["git_vcs","computer_use"]),requestUserInputGates:Object.freeze(["plan_approval","installation_profile_approval","remote_origin_server_vcs_mutation","public_publication_or_release","ambiguity_or_missing_material_input"]),surgicalMutationRule:AA,specialistOutcomes:Object.freeze(["completed","blocked","needs_root_input","failed"]),materialDecisionsRemainRootOwned:!0,lifecycleRemainsRootOwned:!0,integrationAndCompletionRemainRootOwned:!0,codeReviewRequiredForImplementation:!0,codeReviewRequiredBeforeVcs:!0,externalVerificationMustBeTerminal:!0,postVcsFlow:"discover_topology_observe_repair_repeat"})});function Ft(e,t){return new Je("invalid_canonical_value",`Cannot canonicalize ${e}: ${t}.`,{path:e,reason:t})}function $x(e,t,r){if(e===null)return"null";switch(typeof e){case"string":{let n=JSON.stringify(e);if(n===void 0)throw Ft(t,"invalid string");return n}case"boolean":return e?"true":"false";case"number":{if(!Number.isFinite(e))throw Ft(t,"non-finite number");let n=JSON.stringify(e);if(n===void 0)throw Ft(t,"invalid number");return n}case"undefined":throw Ft(t,"undefined is not JSON");case"bigint":throw Ft(t,"bigint is not JSON");case"function":throw Ft(t,"function is not JSON");case"symbol":throw Ft(t,"symbol is not JSON");case"object":break}if(r.has(e))throw Ft(t,"cyclic value");r.add(e);try{if(Array.isArray(e)){for(let s of Object.getOwnPropertySymbols(e))throw Ft(t,`symbol property ${String(s)}`);let i=e,a=[];for(let s=0;s<i.length;s+=1){let c=Object.getOwnPropertyDescriptor(i,String(s));if(!c||!c.enumerable||!("value"in c))throw Ft(`${t}[${s}]`,"sparse or accessor array item");a.push($x(c.value,`${t}[${s}]`,r))}for(let s of Object.getOwnPropertyNames(i)){if(s==="length")continue;let c=Number(s);if(!Number.isInteger(c)||c<0||c>=i.length||String(c)!==s)throw Ft(t,`non-index array property ${s}`);let l=Object.getOwnPropertyDescriptor(i,s);if(!l||!l.enumerable||!("value"in l))throw Ft(`${t}[${c}]`,"non-enumerable or accessor array item")}return`[${a.join(",")}]`}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw Ft(t,"only plain objects are supported");for(let i of Object.getOwnPropertySymbols(e))throw Ft(t,`symbol property ${String(i)}`);for(let i of Object.getOwnPropertyNames(e)){let a=Object.getOwnPropertyDescriptor(e,i);if(!a||!a.enumerable||!("value"in a))throw Ft(`${t}.${i}`,"non-enumerable or accessor property")}let o=[];for(let i of Object.keys(e).sort()){let a=Object.getOwnPropertyDescriptor(e,i);if(!a||!("value"in a))throw Ft(`${t}.${i}`,"accessor property");o.push(`${JSON.stringify(i)}:${$x(a.value,`${t}.${i}`,r)}`)}return`{${o.join(",")}}`}finally{r.delete(e)}}function cn(e){return $x(e,"$",new Set)}function zn(e){return new TextEncoder().encode(cn(e))}function DA(e,t){if(e.length===0||e.includes("\x00"))throw new Je("invalid_digest_domain","Digest domains must be non-empty and NUL-free.",{field:"domain"});let r=new TextEncoder().encode("holycodex-sha256\x00"),n=new TextEncoder().encode(e),o=r.byteLength+8+n.byteLength;for(let c of t){if(c.byteLength>4294967295||o>4294967291-c.byteLength)throw new Je("invalid_digest_domain","Digest input is too large.");o+=4+c.byteLength}let i=new Uint8Array(o),a=new DataView(i.buffer);i.set(r,0);let s=r.byteLength;a.setUint32(s,n.byteLength,!1),s+=4,i.set(n,s),s+=n.byteLength,a.setUint32(s,t.length,!1),s+=4;for(let c of t)a.setUint32(s,c.byteLength,!1),s+=4,i.set(c,s),s+=c.byteLength;return i}function mU(e){let t="";for(let r of e)t+=r.toString(16).padStart(2,"0");return t}async function Kn(e,t){let r=globalThis.crypto?.subtle;if(!r)throw new Je("crypto_unavailable","The standards-based crypto API is unavailable.");let n=await r.digest("SHA-256",hU(DA(e,t)));return mU(new Uint8Array(n))}function hU(e){let t=new Uint8Array(e.byteLength);return t.set(e),t}var jx=x(()=>{Wi();Md()});function HA(e){try{return cn(e)!==void 0}catch{return!1}}function Dd(e){let t=br(WA,e);if(Ee(t))return Ko(ps("CLI envelope",t.left));return Ki(t.right)}var qA,UA,$A,gU,yU,Bx="holycodex-specialist-outcome-2",Gt,Yc,xU,SU,bU,_U,wU,TU,Ld,EU,vU,OU,RU,kU,jA,BA,VA,CU,zA,KA,WA;var JA=x(()=>{er();Tt();jx();Ax();Wi();Md();Gc();za();qA=T("blocked","completed","failed","partial"),UA=ye(T("high","max","xhigh"),ut);$A=q((e)=>HA(e)),gU=q((e)=>qf(e)&&!Array.isArray(e)&&HA(e)),yU=b({blocked:W,changed_files:U(A),confidence:Jt,context_owner:ye(A,ut),material_findings:U(A),needs_more_context:W,needs_root_decision:W,needs_verification:W,relevant_files:U(A),remaining_risk:U(A),reuse_recommended:W,status:qA,suggested_followup:ye(A,ut),suggested_luna_effort:UA,suggested_specialist:ye(Lx,ut),verification:U(A),verification_passed:W}),Gt=A.pipe(Va(1)),Yc={protocol_version:T(Bx),route:Jc,evidence:U(Gt)},xU=b(Yc),SU=b({...Yc,status:T("completed"),summary:Gt}),bU=b({...Yc,status:T("blocked"),reason:Gt,needs_root_decision:W}),_U=b({...Yc,status:T("partial"),summary:Gt,completed:U(Gt),remaining:U(Gt),needs_root_decision:W}),wU=b({...Yc,status:T("failed"),error:Gt}),TU=ye(SU,bU,_U,wU),Ld={protocol_version:T(Bx),capability:Rx,route:ye(Jc,ut),evidence:U(Gt),data:$A},EU=b({...Ld,status:T("completed"),summary:Gt}),vU=b({...Ld,status:T("blocked"),reason:Gt,needs_root_decision:W}),OU=b({...Ld,status:T("partial"),summary:Gt,completed:U(Gt),remaining:U(Gt),needs_root_decision:W}),RU=b({...Ld,status:T("failed"),error:Gt}),kU=ye(EU,vU,OU,RU),jA=U(A),BA=A.pipe(de(/^[a-z][a-z0-9-]*(?: [a-z][a-z0-9-]*)*$/u)),VA=T(xn),CU=b({code:Hr,message:A,details:gU}),zA=b({schema_version:VA,ok:T(!0),command:BA,data:$A,warnings:jA}),KA=b({schema_version:VA,ok:T(!1),command:BA,error:CU,warnings:jA}),WA=ye(zA,KA)});function AU(e,t,r){return{key:`${e}:${t}`,role:e,task:t,model:YA,effort:r}}function MU(e){let t=IU.get(e);if(t===void 0)throw new Je("catalog_invalid","A profile has no route effort policy.",{profile:e});return $r.flatMap((r)=>r.tasks.map((n)=>{let o=`${r.role}:${n.name}`,i=t.efforts[o];if(i===void 0)throw new Je("catalog_invalid","A route effort policy is incomplete.",{profile:e,route:o});return AU(r.role,n.name,i)}))}function Vx(e){return{name:e.name,root:{model:"gpt-6-astra",effort:e.effort},specialistModel:"gpt-5.6-luna",defaultServiceTier:"standard",routes:MU(e.name)}}function NU(e){let t=["low","default","high"];if(e.length!==t.length)throw new Je("catalog_invalid","The profile catalog has an invalid size.");for(let r=0;r<t.length;r+=1){let n=e[r],o=t[r];if(!n||n.name!==o)throw new Je("catalog_invalid","The profile catalog order is invalid.",{index:r});let i=o==="low"?"low":o==="default"?"medium":"high";if(n.root.model!=="gpt-6-astra"||n.root.effort!==i||n.specialistModel!=="gpt-5.6-luna")throw new Je("catalog_invalid","A profile has an invalid model route.",{profile:n.name});if(n.routes.length!==Ni.length)throw new Je("catalog_invalid","A profile is incomplete.",{profile:n.name});let a=new Set;for(let s of n.routes){if(a.has(s.key)||!PU.has(s.key)||s.model!=="gpt-5.6-luna"||`${s.role}:${s.task}`!==s.key)throw new Je("catalog_invalid","A profile contains an invalid route.",{profile:n.name});a.add(s.key)}if(a.size!==Ni.length)throw new Je("catalog_invalid","A profile is missing a specialist route.",{profile:n.name})}for(let r=0;r<Ni.length;r+=1){let n=-1;for(let o of e){let i=o.routes[r];if(!i||GA[i.effort]<n)throw new Je("catalog_invalid","Profile route effort is not monotonic.",{route:Ni[r]??"unknown"});n=GA[i.effort]}}}function ln(e){let t=br(Mo,e);if(Ee(t))return Ko(new Je("invalid_profile","Unknown profile selection.",{field:"profile"},{cause:t.left}));let r=XA.get(t.right);if(!r)return Ko(new Je("invalid_profile","Unknown profile selection.",{profile:t.right}));return Ki(r)}var YA="gpt-5.6-luna",PU,GA,zx,IU,Kx,ZA,XA,FU;var QA=x(()=>{er();Wi();Gc();za();PU=new Set(Ni),GA={low:0,medium:1,high:2,xhigh:3,max:4},zx=[{profile:"low",rationale:"The low profile keeps bounded specialist work economical.",efforts:{"Explorer:lookup":"medium","Explorer:trace":"high","Librarian:lookup":"medium","Librarian:research":"high","Worker:mechanical":"high","Worker:implementation":"high","Worker:integration":"max","Worker:operations":"high","Reviewer:plan":"high","Reviewer:code":"max","Reviewer:artifact":"high"}},{profile:"default",rationale:"The default profile is the recommended balanced route.",efforts:{"Explorer:lookup":"medium","Explorer:trace":"xhigh","Librarian:lookup":"medium","Librarian:research":"xhigh","Worker:mechanical":"high","Worker:implementation":"xhigh","Worker:integration":"max","Worker:operations":"high","Reviewer:plan":"xhigh","Reviewer:code":"max","Reviewer:artifact":"xhigh"}},{profile:"high",rationale:"The high profile maximizes specialist reasoning where specified.",efforts:{"Explorer:lookup":"medium","Explorer:trace":"max","Librarian:lookup":"medium","Librarian:research":"max","Worker:mechanical":"xhigh","Worker:implementation":"max","Worker:integration":"max","Worker:operations":"xhigh","Reviewer:plan":"max","Reviewer:code":"max","Reviewer:artifact":"max"}}];zr(zx);IU=new Map(zx.map((e)=>[e.profile,e]));Kx=[Vx({name:"low",effort:"low"}),Vx({name:"default",effort:"medium"}),Vx({name:"high",effort:"high"})];NU(Kx);zr(Kx);ZA=Kx,XA=new Map,FU=new Map;for(let e of ZA){XA.set(e.name,e);let t=new Map;for(let r of e.routes)t.set(r.key,r);FU.set(e.name,t)}});import{execFile as LU}from"child_process";import{promisify as DU}from"util";var tP="holycodex-intent-1",rP="holycodex-plan-1",nP="holycodex-assignment-1",qd="toon-4",Q,Fo,Wx,Zc,un,Qe,iY,Jx,Fi,Gx,Yx,qU,eP,UU,HU,Zx,oP,iP,$U,aY,jU,BU,VU,zU,KU,sY;var aP=x(()=>{Tt();Gc();za();Q=A.pipe(Xe((e)=>e.trim().length>0)),Fo=A.pipe(de(/^[a-z0-9][a-z0-9-]{0,95}$/u)),Wx=A.pipe(de(/^[a-f0-9]{64}$/u)),Zc=Cd.pipe(SA(1)),un=A.pipe(Xe((e)=>!Number.isNaN(Date.parse(e)))),Qe=U(Q),iY=b({pid:Cd.pipe(Ex(0)),token:Q}),Jx=b({role:T("Explorer","Librarian","Worker","Reviewer"),task:Q}).pipe(Xe((e)=>$r.some((t)=>t.role===e.role&&t.tasks.some((r)=>r.name===e.task)))),Fi=b({kind:T("changed_path","check","repository_fact","ci","behavior","uncertainty"),value:Q,result:_(T("passed","failed","observed","unknown"))}),Gx=b({root:Q,git_common_dir:Q,initial_head:Q,expected_head:Q,expected_changes:Qe,expected_status_digest:Wx,updated_at:un}),Yx=T("scoping","ready","executing","verifying","reviewing","blocked","needs_root_input","complete","abandoned"),qU=T("scoping","ready","executing","verifying","reviewing"),eP=b({required:W,status:T("not_required","missing","passed","failed","accepted","rejected"),evidence:U(Fi)}),UU=b({schema_version:T(tP),toon_compatibility:T(qd),id:Fo,slug:Fo,title:Q,goal:Q,acceptance_criteria:Qe,state:Yx,revision:Zc,plan_required:W,active_plan_revision:_(Zc),active_plan_digest:_(Wx),blockers:Qe,resume_state:_(qU),verification:eP,review:eP,acceptance_met:W,root_readiness:W,evidence:U(Fi),baseline:Gx,created_at:un,updated_at:un}),HU=b({schema_version:T(rP),toon_compatibility:T(qd),intent_id:Fo,revision:Zc,predecessor_digest:_(Wx),approach:Q,scope:Qe,exclusions:Qe,assignments:Qe,dependencies:Qe,architecture:Qe,risks:Qe,assumptions:Qe,open_questions:Qe,verification:Qe,recovery:Qe,updated_at:un}),Zx=T("completed","blocked","needs_root_input","failed"),oP=T("pending","executing","completed","blocked","needs_root_input","failed"),iP=b({id:Fo,outcome:Zx,started_at:un,finished_at:un,summary:Q,evidence:U(Fi),blocker:_(Q),remaining_risk:Qe}),$U=b({schema_version:T(nP),toon_compatibility:T(qd),intent_id:Fo,id:Fo,objective:Q,owner:Jx,scope:Qe,constraints:Qe,exclusions:Qe,dependencies:Qe,acceptance_criteria:Qe,status:oP,revision:Zc,invocations:U(iP),evidence:U(Fi),blocker:_(Q),remaining_risk:Qe,created_at:un,updated_at:un}),aY=b({schema_version:T("holycodex-intent-0"),id:Fo,slug:Fo,title:Q,goal:Q,acceptance_criteria:Qe,state:Yx,revision:Zc,baseline:Gx,created_at:un,updated_at:un}),jU=b({title:Q,goal:Q,acceptanceCriteria:U(Q).pipe(Ad(1)),planRequired:_(W),verificationRequired:_(W),reviewRequired:_(W)}),BU=b({approach:Q,scope:_(U(Q)),exclusions:_(U(Q)),assignments:_(U(Q)),dependencies:_(U(Q)),architecture:_(U(Q)),risks:_(U(Q)),assumptions:_(U(Q)),openQuestions:_(U(Q)),verification:_(U(Q)),recovery:_(U(Q))}),VU=b({id:_(Q),objective:Q,owner:Jx,scope:U(Q).pipe(Ad(1)),constraints:_(U(Q)),exclusions:_(U(Q)),dependencies:_(U(Q)),acceptanceCriteria:U(Q).pipe(Ad(1))}),zU=b({invocationId:_(Q),outcome:Zx,startedAt:_(Q),summary:Q,evidence:_(U(Fi)),blocker:_(Q),remainingRisk:_(U(Q))}),KU=b({evidence:_(U(Fi)),verification:_(T("passed","failed")),review:_(T("accepted","rejected")),acceptanceMet:_(W),rootReadiness:_(W),clearBlockers:_(W)}),sY=DU(LU)});var pt=x(()=>{Lb();Wi();za();Ax();kA();Md();Gc();JA();QA();jx();aP()});function ne(e){if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Fe(e){try{return cn(e),!0}catch{return!1}}function oH(e){switch(e){case"invalid_external_data":case"manifest_invalid":case"empty_output_directory":return"validation";case"discovery_failed":return"identity";case"protocol_mismatch":case"method_unsupported":case"server_request_unsupported":case"unexpected_response":return"protocol";case"invalid_transport_line":case"transport_closed":case"transport_failure":return"transport";case"approval_required":case"permission_denied":return"approval";case"cancellation":return"interruption";case"timeout":return"timeout";case"turn_failed":return"turn";case"closed":return"closed";case"server_error":return"server"}}function lP(e){return{ok:!1,error:e}}function uP(e){return{ok:!0,value:e}}function ir(e,t=512){let r="";for(let n of e){let o=n.codePointAt(0)??0;r+=o<=8||o===11||o===12||o>=14&&o<=31||o===127?" ":n}return r.replace(/\s+/gu," ").trim().slice(0,t)}function Li(e,t=0){if(t>3)return"[truncated]";if(e===null||typeof e==="boolean")return e;if(typeof e==="string")return ir(e,256);if(typeof e==="number")return Number.isFinite(e)?e:null;if(Array.isArray(e))return e.slice(0,32).map((r)=>Li(r,t+1));if(ne(e)){let r={};for(let[n,o]of Object.entries(e).slice(0,32)){let i=ir(n,96);if(i.length>0)r[i]=Li(o,t+1)}return r}return"[redacted]"}function pP(e){let t=Li(e);return ne(t)?t:{value:t}}function Le(e,t,r){return new V("invalid_external_data",`Invalid ${e}.`,{field:e,received:Li(t)},r===void 0?void 0:{cause:r})}function Ae(e,t,r){let n=br(e,t);if(Ee(n))throw Le(r,t,String(n.left));return n.right}function dP(e,t){try{return Ae(e,t,"value"),!0}catch{return!1}}var eS,tl=1048576,tS=65536,ar,Lo,n5,Wn,nH,V;var pn=x(()=>{pt();er();Tt();eS=xn;ar=q((e)=>Fe(e)),Lo=q((e)=>ne(e)&&Fe(e)),n5=A.pipe(de(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u)),Wn=A.pipe(Xe((e)=>e.length>0&&e.length<=4096)),nH=Jt.pipe(Xe((e)=>Number.isFinite(e)&&e>=0));V=class V extends Error{code;kind;details;retryable;constructor(e,t,r={},n){super(t,n?.cause===void 0?void 0:{cause:n.cause});this.name="CodexError",this.code=e,this.kind=oH(e),this.details=r,this.retryable=n?.retryable??!1,Object.freeze(this.details),Object.freeze(this)}}});var rS,rl,nl,nS,oS,iS,aS="turn/completed";var jd=x(()=>{rS=["initialize","thread/start","thread/resume","thread/read","thread/list","thread/fork","thread/unsubscribe","turn/start","turn/steer","turn/interrupt","model/list","modelProvider/capabilities/read","config/read","permissionProfile/list"],rl=["item/commandExecution/requestApproval","item/fileChange/requestApproval","applyPatchApproval","execCommandApproval"],nl=["item/permissions/requestApproval"],nS=["mcpServer/elicitation/request"],oS=["item/tool/call"],iS={method:"initialized"}});function Ja(e,t=new Set){if(e===null||typeof e==="string"||typeof e==="boolean")return!0;if(typeof e==="number")return Number.isFinite(e);if(typeof e!=="object")return!1;if(t.has(e))return!1;t.add(e);try{if(Array.isArray(e))return e.every((r)=>Ja(r,t));return ne(e)&&Object.values(e).every((r)=>Ja(r,t))}finally{t.delete(e)}}function dn(e){return ne(e)&&Ja(e)}function sS(e){let t=[],r=0,n=!1,o=!1;for(let i=0;i<=e.length;i+=1){let a=e[i];if(i===e.length||a==="."&&!n){let s=e.slice(r,i),c=s.startsWith('"')?aH(s):s;if(!/^[A-Za-z][A-Za-z0-9_-]*$/u.test(c)&&!Ka.includes(c))throw Le("TOML key path",e);t.push(c),r=i+1;continue}if(n){if(o)o=!1;else if(a==="\\")o=!0;else if(a==='"')n=!1}else if(a==='"')n=!0}if(n||o||t.length===0)throw Le("TOML key path",e);if(t.some((i)=>i==="__proto__"||i==="constructor"||i==="prototype"))throw Le("TOML key path",e);return t}function aH(e){try{let t=JSON.parse(e);if(typeof t==="string")return t}catch{}throw Le("TOML quoted key",e)}function Pe(e,t){if(!dn(e))throw Le("TOML document",e);let r=e;for(let n of sS(t)){if(!dn(r)||!Object.prototype.hasOwnProperty.call(r,n))return;r=r[n]}return r}function Bd(e){if(Array.isArray(e))return e.map(Bd);if(ne(e))return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Bd(r)]));return e}function Vd(e){return Bd(e)}function cS(e,t,r){if(!dn(e)||!Ja(r))throw Le("TOML write",{keyPath:t});let n=sS(t),o={...Vd(e)},i=o;for(let a of n.slice(0,-1)){let s=i[a];if(s!==void 0&&!dn(s))throw Le("TOML table path",t);let c=s===void 0?{}:{...s};i[a]=c,i=c}return i[n.at(-1)]=Bd(r),o}function zd(e,t){if(!dn(e))throw Le("TOML document",e);let r=sS(t),n={...Vd(e)},o=[],i=n;for(let s of r.slice(0,-1)){let c=i[s];if(!dn(c))return n;let l={...c};o.push({table:i,key:s}),i[s]=l,i=l}let a=r.at(-1);if(!Object.prototype.hasOwnProperty.call(i,a))return n;delete i[a];for(let s=o.length-1;s>=0;s-=1){let c=o[s],l=c.table[c.key];if(dn(l)&&Object.keys(l).length===0)delete c.table[c.key];else break}return n}function il(e){if(typeof e!=="string")return!1;if(mP.includes(e))return!0;if(/^agents\.(?:explorer|librarian|worker|reviewer)\.config_file$/u.test(e))return!0;return Ka.some((t)=>e===`agents."${t}".config_file`)}function Kd(e){return il(e)}function Do(e){return typeof e==="string"&&cH.test(e)}function lS(e){return e==="gpt-6-astra"||e==="gpt-5.6-terra"||e==="gpt-5.6-sol"||e==="gpt-5.6-luna"||e==="low"||e==="medium"||e==="high"||e==="xhigh"||e==="max"||e==="default"||e==="fast"}function lH(e){return typeof e==="string"&&/^[a-f0-9]{64}$/u.test(e)}function uS(e,t){let r=new Set(t);return Object.keys(e).every((n)=>r.has(n))}function pS(e){if(!ne(e)||!uS(e,["kind","value"])||typeof e.kind!=="string")return!1;switch(e.kind){case"enum":return lS(e.value);case"boolean":return typeof e.value==="boolean";case"relative_path":return typeof e.value==="string"&&Gd(e.value);case"digest":return lH(e.value);default:return!1}}function fP(e,t){switch(fS(e)){case"boolean":return t.kind==="boolean";case"relative_path":return t.kind==="relative_path";case"digest":return t.kind==="digest";case"enum":if(t.kind!=="enum")return!1;if(e==="model")return t.value==="gpt-6-astra"||t.value==="gpt-5.6-terra"||t.value==="gpt-5.6-sol"||t.value==="gpt-5.6-luna";if(e==="model_reasoning_effort")return t.value==="low"||t.value==="medium"||t.value==="high"||t.value==="xhigh"||t.value==="max";if(e==="service_tier")return t.value==="default"||t.value==="fast";return t.value==="low"||t.value==="medium"||t.value==="high"}}function xP(e){return ne(e)&&e.kind==="absent"?Object.keys(e).length===1:pS(e)}function SP(e){return ne(e)&&uS(e,["owner","schema","installId","keyPath","originalValue","lastManagedValue"])&&e.owner==="holycodex"&&typeof e.schema==="string"&&Do(e.schema)&&Do(e.installId)&&Kd(e.keyPath)&&xP(e.originalValue)&&pS(e.lastManagedValue)&&fP(e.keyPath,e.lastManagedValue)&&(e.originalValue.kind==="absent"||fP(e.keyPath,e.originalValue))}function Ga(e){if(!ne(e)||!uS(e,["owner","schema","installId","managed"])||e.owner!=="holycodex"||!Do(e.schema)||!Do(e.installId)||!ne(e.managed))return!1;return Object.entries(e.managed).every(([t,r])=>Kd(t)&&SP(r)&&r.keyPath===t)}function Jd(e){if(!Do(e.schema)||!Do(e.installId))throw Le("managed runtime config metadata",{schema:e.schema});return{owner:"holycodex",schema:e.schema,installId:e.installId,managed:{}}}function Gd(e){if(e.length===0||e.includes("\x00")||/^[\\/]|^[A-Za-z]:[\\/]/u.test(e))return!1;let t=e.replaceAll("\\","/").split("/");return t.some((r)=>r!==".")&&t.every((r)=>r.length>0&&r!=="..")}function dS(e){if(!Gd(e))throw Le("relative config path","[redacted]");return e.replaceAll("\\","/").split("/").filter((t)=>t!==".").join("/")}function al(e,t){let r=dS(t),n=e.replaceAll("\\","/").split("/");n.pop();let o=[...n,...r.split("/")].join("/"),i=[];for(let c of o.split("/")){if(c.length===0||c===".")continue;if(c==="..")i.pop();else i.push(c)}let a=e.replaceAll("\\","/");return`${a.startsWith("//")?"//":a.startsWith("/")?"/":""}${i.join("/")}`}function fS(e){if(e==="developer_instructions")return"digest";if(e.endsWith(".config_file"))return"relative_path";if(e==="suppress_unstable_features_warning"||e==="features.default_mode_request_user_input"||e==="features.multi_agent_v2"||e==="features.context_management.experimental_mode")return"boolean";return"enum"}function uH(e,t){let r=fS(e);if(r==="boolean")return typeof t==="boolean";if(r==="relative_path")return typeof t==="string"&&Gd(t);if(r==="digest")return typeof t==="string";return typeof t==="string"&&lS(t)}async function Wa(e,t){if(!Kd(e)||!Ja(t))throw Le("managed config value",{keyPath:e});let r=fS(e);if(r==="boolean"&&typeof t==="boolean")return{kind:r,value:t};if(r==="relative_path"&&typeof t==="string"&&Gd(t))return{kind:r,value:dS(t)};if(r==="enum"&&typeof t==="string"&&lS(t))return{kind:r,value:t};return{kind:"digest",value:await Kn("holycodex-managed-config-value",[zn({keyPath:e,value:t})])}}function pH(e){if(e.kind==="enum"||e.kind==="boolean"||e.kind==="relative_path")return e.value;return}async function sl(e,t,r,n){if(!dn(e)||!Ga(t)||!Do(n.schema)||!Do(n.installId))throw Le("managed runtime config",{});let o={...t.managed},i=Vd(e),a=[];for(let[c,l]of Object.entries(r)){if(!il(c)||typeof l!=="string"&&typeof l!=="boolean")throw Le("managed config key",c);let u=c,p=t.managed[u],f=Pe(i,u);if(p&&(p.schema!==n.schema||p.installId!==n.installId)){a.push(u);continue}if(p&&p.owner==="holycodex"){let m=f===void 0?void 0:await Wa(u,f);if(m===void 0||JSON.stringify(m)!==JSON.stringify(p.lastManagedValue)){a.push(u);continue}}let h=p?.originalValue??(f===void 0?{kind:"absent"}:await Wa(u,f));if(!uH(u,l))throw Le("managed config value",{keyPath:u});i=cS(i,u,l),o[u]={owner:"holycodex",schema:n.schema,installId:n.installId,keyPath:u,originalValue:h,lastManagedValue:await Wa(u,l)}}let s={owner:"holycodex",schema:n.schema,installId:n.installId,managed:o};if(!Ga(s))throw Le("managed runtime config state",{});return{document:i,state:s,driftedKeys:a}}async function Di(e,t,r){if(!dn(e)||!Ga(t))throw Le("managed runtime config",{});let n=Vd(e),o={...t.managed},i=[],a=[],s=[];for(let[c,l]of Object.entries(t.managed)){if(!Kd(c))throw Le("managed config key",c);let u=c;if(l.owner!=="holycodex"||l.schema!==r.schema||l.installId!==r.installId){if(l.schema!==r.schema||l.installId!==r.installId)s.push(u);continue}let p=Pe(n,u);if(!(p!==void 0&&JSON.stringify(await Wa(u,p))===JSON.stringify(l.lastManagedValue))){a.push(u);continue}if(l.originalValue.kind==="absent")n=zd(n,u),i.push(u),delete o[u];else{let h=pH(l.originalValue);if(h===void 0){s.push(u),a.push(u);continue}n=cS(n,u,h),i.push(u),delete o[u]}}return{document:n,state:{...t,managed:o},restoredKeys:i,preservedKeys:a,unresolvedKeys:s}}async function Ya(e,t,r){if(!il(r)||!Ga(t))throw Le("managed config key",r);let n=t.managed[r],o=Pe(e,r),i=o===void 0?void 0:await Wa(r,o);if(!n)return i===void 0?{keyPath:r,status:"unmanaged"}:{keyPath:r,status:"unmanaged",current:i};return{keyPath:r,status:i!==void 0&&JSON.stringify(i)===JSON.stringify(n.lastManagedValue)?"unchanged":"drifted",expected:n.lastManagedValue,...i===void 0?{}:{current:i}}}var iH,ol,mP,sH,hP,gP,yP,Wd,cH;var Yd=x(()=>{pt();pt();Tt();pn();iH=q((e)=>Ja(e)),ol=q((e)=>dn(e));mP=["model","model_reasoning_effort","service_tier","model_verbosity","developer_instructions","suppress_unstable_features_warning","features.default_mode_request_user_input","features.multi_agent_v2","features.context_management.experimental_mode"],sH=q((e)=>il(e));hP=q((e)=>pS(e)),gP=q((e)=>xP(e)),yP=q((e)=>SP(e)),Wd=q((e)=>Ga(e)),cH=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u});function fH(e){return typeof e==="number"&&Number.isFinite(e)&&e>=0}function bP(e,t,r){let n=new Set([...t,r]),o=Object.keys(e);if(Object.keys(e).some((i)=>!n.has(i)))return!1;return o.length>0&&o.every((i)=>fH(e[i]))}function TP(e){if(!ne(e)||!Fe(e))return!1;return bP(e,["inputTokens","cachedInputTokens","outputTokens","reasoningOutputTokens"],"totalTokens")||bP(e,["input_tokens","cached_input_tokens","output_tokens","reasoning_output_tokens"],"total_tokens")}function Zd(e){return ne(e)&&Fe(e)&&typeof e.id==="string"&&/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u.test(e.id)}function EP(e){return ne(e)&&Fe(e)&&Zd(e.thread)}function gH(e){return ne(e)&&Fe(e)&&typeof e.id==="string"}function qo(e){return ne(e)&&Fe(e)&&typeof e.threadId==="string"&&e.threadId.length>0}function vP(e){return ne(e)&&Fe(e)&&typeof e.id==="string"&&e.id.length>0&&(e.usage===void 0||TP(e.usage))}function yH(e){return ne(e)&&Fe(e)&&typeof e.id==="string"&&typeof e.model==="string"&&(e.supportedReasoningEfforts===void 0||Array.isArray(e.supportedReasoningEfforts)&&e.supportedReasoningEfforts.every((t)=>ne(t)&&typeof t.reasoningEffort==="string"))&&(e.serviceTiers===void 0||Array.isArray(e.serviceTiers)&&e.serviceTiers.every((t)=>ne(t)&&typeof t.id==="string"))&&(e.defaultServiceTier===void 0||e.defaultServiceTier===null||typeof e.defaultServiceTier==="string")&&(e.multiAgentVersion===void 0||e.multiAgentVersion===null||e.multiAgentVersion==="disabled"||e.multiAgentVersion==="v1"||e.multiAgentVersion==="v2")}function OP(e){if(nl.some((t)=>t===e))return"permissions";if(rl.some((t)=>t===e))return"approval";if(nS.some((t)=>t===e))return"elicitation";if(oS.some((t)=>t===e))return"dynamic_tool";return"other"}var _P,cl,wP,ll,dH,mS,ul,mH,Xd,hS,gS,hH,pl,yS,xS,SS,bS,_S,wS,TS,ES,vS,OS,RS,kS,CS,AS,PS,IS,MS,NS,FS,LS,DS,qS,US,HS,$S,jS,BS,VS,f5,xH,m5;var zS=x(()=>{Tt();pn();jd();Yd();_P=A.pipe(de(/^[A-Za-z][A-Za-z0-9_./:-]{0,127}$/u)),cl=ye(A.pipe(Va(1)),Jt.pipe(Xe((e)=>Number.isSafeInteger(e)))),wP=b({code:Jt.pipe(Xe((e)=>Number.isSafeInteger(e))),message:A,data:_(ar)}),ll=ye(b({id:cl,result:ar}),b({id:cl,error:wP})),dH=b({id:cl,error:wP}),mS=b({method:_P,params:_(ar)}),ul=b({id:cl,method:_P,params:_(ar),trace:_(ar)});mH=q(TP),Xd=b({clientInfo:b({name:Wn,version:Wn,title:ye(Wn,ut)}),capabilities:ye(b({experimentalApi:W,requestAttestation:W,mcpServerOpenaiFormElicitation:_(W),optOutNotificationMethods:_(ye(U(A),ut)),extensions:_(Lo)}),ut)}),hS=q((e)=>ne(e)&&Fe(e)&&typeof e.userAgent==="string"&&typeof e.codexHome==="string"&&typeof e.platformFamily==="string"&&typeof e.platformOs==="string"),gS=b({method:T("initialized")});hH=q(Zd);pl=q((e)=>EP(e)||gH(e)),yS=pl,xS=pl,SS=q(qo),bS=q((e)=>ne(e)&&Fe(e)&&(e.status==="notLoaded"||e.status==="notSubscribed"||e.status==="unsubscribed")),_S=q((e)=>EP(e)),wS=q((e)=>{if(!ne(e)||!Fe(e))return!1;let t=Array.isArray(e.data)&&e.data.every((n)=>Zd(n)),r=Array.isArray(e.threads)&&e.threads.every((n)=>Zd(n));return t&&e.threads===void 0||r&&e.data===void 0}),TS=q((e)=>ne(e)&&Fe(e));ES=q(qo),vS=q(qo),OS=q(qo),RS=q((e)=>ne(e)&&Fe(e));kS=q((e)=>qo(e)&&(Array.isArray(e.input)&&e.input.every((t)=>Fe(t))||typeof e.prompt==="string"&&e.prompt.length>0)),CS=q((e)=>qo(e)&&typeof e.expectedTurnId==="string"&&Array.isArray(e.input)&&e.input.every((t)=>Fe(t))),AS=q((e)=>ne(e)&&Fe(e)&&(e.turn!==void 0&&vP(e.turn)||typeof e.turnId==="string"&&e.turnId.length>0||typeof e.id==="string"&&e.id.length>0)),PS=q((e)=>ne(e)&&Fe(e)&&typeof e.turnId==="string"&&e.turnId.length>0),IS=q((e)=>qo(e)&&typeof e.turnId==="string"&&e.turnId.length>0),MS=q((e)=>ne(e)&&Fe(e)),NS=q((e)=>qo(e)&&(e.turn!==void 0&&vP(e.turn)||typeof e.turnId==="string"&&e.turnId.length>0)),FS=q((e)=>ne(e)&&Fe(e));LS=q((e)=>ne(e)&&Fe(e)&&Array.isArray(e.data)&&e.data.every((t)=>yH(t))),DS=Lo,qS=Lo,US=b({includeLayers:_(W),cwd:_(ye(A,ut))}),HS=b({config:ol,origins:Lo,layers:ye(U(Lo),ut)}),$S=Lo,jS=Lo,BS=q((e)=>ne(e)&&Fe(e)&&(typeof e.id==="string"||typeof e.id==="number"&&Number.isSafeInteger(e.id))&&typeof e.method==="string"&&ne(e.params)&&(e.category==="approval"||e.category==="dynamic_tool"||e.category==="elicitation"||e.category==="other"||e.category==="permissions")),VS=ar,f5=q((e)=>ne(e)&&Fe(e)&&typeof e.kind==="string"&&typeof e.method==="string");xH=ye(T("stable","experimental","disabled"),W),m5=Rd({key:A,value:xH})});class Qd{transport;maxLineBytes;requestTimeoutMs;signal;notificationListeners=new Set;serverRequestHandlers=new Set;pending=new Map;serverRequestWork=new Set;serverRequestTasks=new Set;nextRequestId=1;readerPromise;initializePromise;transportClosePromise;initializeAttempted=!1;initialized=!1;closed=!1;constructor(e,t={}){if(this.transport=e,this.maxLineBytes=t.maxLineBytes??tl,this.requestTimeoutMs=t.requestTimeoutMs,this.signal=t.signal,!Number.isSafeInteger(this.maxLineBytes)||this.maxLineBytes<1)throw new V("invalid_external_data","The maximum line size is invalid.");if(this.requestTimeoutMs!==void 0&&(!Number.isSafeInteger(this.requestTimeoutMs)||this.requestTimeoutMs<1))throw new V("invalid_external_data","The request timeout is invalid.");if(t.onNotification)this.notificationListeners.add(t.onNotification);if(t.onServerRequest)this.serverRequestHandlers.add(t.onServerRequest);if(this.signal?.aborted)this.close();else if(this.signal)this.signal.addEventListener("abort",()=>void this.close(),{once:!0})}get isInitialized(){return this.initialized}onNotification(e){return this.notificationListeners.add(e),()=>this.notificationListeners.delete(e)}onServerRequest(e){return this.serverRequestHandlers.add(e),()=>this.serverRequestHandlers.delete(e)}async initialize(e=SH){if(this.initializePromise)return this.initializePromise;if(this.initializeAttempted)throw new V("invalid_external_data","The App Server initialize handshake was already attempted.");this.ensureOpen();let t=Ae(Xd,e,"initialize parameters");return this.initializeAttempted=!0,this.initializePromise=this.performInitialize(t),this.initializePromise}async startThread(e={}){return this.action("thread/start",TS,e,pl)}async resumeThread(e){let t=typeof e==="string"?{threadId:e}:e;return this.action("thread/resume",ES,t,yS)}async readThread(e){let t=typeof e==="string"?{threadId:e}:e;return this.action("thread/read",vS,t,_S)}async listThreads(e={}){return this.action("thread/list",RS,e,wS)}async forkThread(e){let t=typeof e==="string"?{threadId:e}:e;return this.action("thread/fork",OS,t,xS)}async unsubscribeThread(e){let t=typeof e==="string"?{threadId:e}:e;return this.action("thread/unsubscribe",SS,t,bS)}async startTurn(e){return this.action("turn/start",kS,e,AS)}async steerTurn(e){return this.action("turn/steer",CS,e,PS)}async interruptTurn(e,t){let r=typeof e==="string"?{threadId:e,turnId:t??""}:e;return this.action("turn/interrupt",IS,r,MS)}async listModels(e={}){return this.action("model/list",FS,e,LS)}async readModelProviderCapabilities(e={}){return this.action("modelProvider/capabilities/read",DS,e,qS)}async readConfig(e={}){return this.action("config/read",US,e,HS)}async listPermissionProfiles(e={}){return this.action("permissionProfile/list",$S,e,jS)}async call(e,t={}){if(e==="initialize"){let n=await this.initialize(Ae(Xd,t,"initialize parameters"));return Ae(ar,n,"initialize result")}let r=Ae(ul,{id:1,method:e,params:t},"App Server method");if(!bH.has(r.method))throw new V("method_unsupported",`Unsupported App Server method: ${e}.`,{method:e});return this.request(r.method,r.params===void 0?{}:r.params)}async close(){await this.closeWithError(new V("closed","The App Server client is closed."))}async performInitialize(e){try{let t=await this.request("initialize",Ae(ar,e,"initialize parameters")),r=Ae(hS,t,"initialize result"),n=Ae(gS,iS,"initialized notification");return await this.transport.writeLine(JSON.stringify(n)),this.initialized=!0,r}catch(t){let r=t instanceof V?t:new V("transport_failure","The initialize handshake failed.",{},{cause:t});throw await this.closeWithError(r),r}}async action(e,t,r,n){let o=Ae(t,r,`${e} parameters`),i=Ae(ar,o,`${e} parameters`),a=await this.request(e,i);return Ae(n,a,`${e} result`)}async request(e,t){if(this.ensureOpen(),e!=="initialize"&&!this.initialized)throw new V("invalid_external_data",`The ${e} action requires an initialized App Server client.`);this.startReader();let r=this.nextRequestId;this.nextRequestId+=1;let n=Ae(ul,{id:r,method:e,params:t},`${e} request`);return new Promise((o,i)=>{let a=!1,s,c,l=(p)=>{if(a)return;if(a=!0,this.pending.delete(r),s!==void 0)clearTimeout(s);c?.(),i(p)};if(this.requestTimeoutMs!==void 0)s=setTimeout(()=>l(new V("timeout",`The ${e} request timed out.`,{method:e})),this.requestTimeoutMs);if(this.signal){let p=()=>l(new V("cancellation",`The ${e} request was cancelled.`,{method:e}));this.signal.addEventListener("abort",p,{once:!0}),c=()=>this.signal?.removeEventListener("abort",p)}let u={method:e,resolve:(p)=>{if(a)return;if(a=!0,s!==void 0)clearTimeout(s);c?.(),o(p)},reject:l,...s===void 0?{}:{timer:s},...c===void 0?{}:{removeAbortListener:c}};this.pending.set(r,u),this.transport.writeLine(JSON.stringify(n)).catch((p)=>{l(p instanceof V?p:new V("transport_failure","The App Server request could not be written.",{},{cause:p}))})})}startReader(){if(!this.readerPromise)this.readerPromise=this.readLoop().catch((e)=>this.handleReaderFailure(e)).catch(()=>{return})}async readLoop(){while(!this.closed){let e=await this.transport.readLine();if(e===null){if(!this.closed)throw new V("transport_closed","The App Server transport closed.");return}if(new TextEncoder().encode(e).byteLength>this.maxLineBytes)throw new V("invalid_transport_line","An App Server line exceeded the limit.");this.handleLine(e)}}async handleReaderFailure(e){let t=e instanceof V?e:new V("transport_failure","The App Server transport failed.",{},{cause:e});await this.closeWithError(t)}handleLine(e){let t;try{t=JSON.parse(e)}catch(i){throw new V("invalid_transport_line","The App Server emitted invalid JSON.",{},{cause:i})}let r=this.tryDecode(ll,t);if(r!==void 0){this.handleResponse(r);return}let n=this.tryDecode(ul,t);if(n!==void 0){this.handleServerRequest(n);return}let o=this.tryDecode(mS,t);if(o!==void 0){this.handleNotification(o);return}throw Le("JSON-RPC message",t)}tryDecode(e,t){try{return Ae(e,t,"JSON-RPC message")}catch{return}}handleResponse(e){let t=this.pending.get(e.id);if(!t)throw new V("unexpected_response","The App Server returned an unknown request id.",{id:e.id});if(this.pending.delete(e.id),"error"in e){let r=e.error.code===-32001,n=wH(t.method);t.reject(new V(n,`The App Server rejected ${t.method}: ${ir(e.error.message)}.`,{method:t.method,serverCode:e.error.code,retryable:r,...e.error.data===void 0?{}:{data:Li(e.error.data)}},{retryable:r}));return}t.resolve(e.result)}handleServerRequest(e){let t=e.params??{},r=Ae(BS,{...e,params:t,category:OP(e.method)},"server request");this.emitNotification({kind:"server_request",method:e.method,params:t});let n=[...this.serverRequestHandlers];if(n.length===0){this.trackServerRequestTask(this.writeServerError(e.id,-32601,`No handler for ${e.method}.`));return}let o=n[0];if(o===void 0){this.trackServerRequestTask(this.writeServerError(e.id,-32601,`No handler for ${e.method}.`));return}let i={active:!0};this.serverRequestWork.add(i);let a;try{a=o(r)}catch(s){this.completeServerRequest(i,()=>this.writeServerError(e.id,-32000,ir(String(s))));return}if(a instanceof Promise){this.trackServerRequestTask(a.then((s)=>this.completeServerRequest(i,()=>this.writeValidatedServerResult(e.id,s)),(s)=>this.completeServerRequest(i,()=>this.writeServerError(e.id,-32000,ir(String(s))))));return}this.completeServerRequest(i,()=>this.writeValidatedServerResult(e.id,a))}writeValidatedServerResult(e,t){try{let r=Ae(VS,t,"server response");return this.writeServerResult(e,r)}catch(r){return this.writeServerError(e,-32000,ir(String(r)))}}completeServerRequest(e,t){if(!e.active)return;e.active=!1,this.serverRequestWork.delete(e);try{this.trackServerRequestTask(t())}catch{}}trackServerRequestTask(e){let t=e.catch(()=>{return});this.serverRequestTasks.add(t),t.then(()=>this.serverRequestTasks.delete(t),()=>this.serverRequestTasks.delete(t))}async writeServerResult(e,t){let r=Ae(ll,{id:e,result:t},"server response");await this.transport.writeLine(JSON.stringify(r))}async writeServerError(e,t,r){let n=Ae(ll,{id:e,error:{code:t,message:_H(r)}},"server error response");await this.transport.writeLine(JSON.stringify(n))}handleNotification(e){let t=e.params;if(e.method===aS){let r=Ae(NS,t,"turn/completed notification");this.emitNotification({kind:"turn_completed",method:e.method,params:r});return}if(e.method.includes("agent")||e.method.includes("subagent")){this.emitNotification({kind:"multi_agent",method:e.method,...t===void 0?{}:{params:t}});return}this.emitNotification({kind:"unknown",method:e.method,metadata:pP({params:Li(t)})})}emitNotification(e){for(let t of this.notificationListeners)try{t(e)}catch{}}rejectPending(e){for(let t of this.pending.values())t.reject(e);this.pending.clear()}async closeWithError(e){if(this.transportClosePromise!==void 0){await this.transportClosePromise;return}this.closed=!0,this.rejectPending(e);for(let t of this.serverRequestWork)t.active=!1;this.serverRequestWork.clear(),this.serverRequestTasks.clear(),this.transportClosePromise=Promise.resolve().then(()=>this.transport.close()).catch(()=>{return}),await this.transportClosePromise}ensureOpen(){if(this.closed)throw new V("closed","The App Server client is closed.")}}function _H(e){let t=ir(e);return t.length>0?t:"server request failed"}function wH(e){if(nl.some((t)=>t===e))return"permission_denied";if(rl.some((t)=>t===e))return"approval_required";if(e==="turn/interrupt")return"cancellation";if(e.startsWith("turn/"))return"turn_failed";return"server_error"}var SH,bH;var KS=x(()=>{pn();jd();zS();SH={clientInfo:{name:"holycodex",title:null,version:eS},capabilities:null},bH=new Set(rS)});import{isAbsolute as TH}from"path";function Uo(e=process.env){let t=["PATH","HOME","USER","CODEX_HOME","TMPDIR","TEMP","TMP","LANG","LC_ALL"],r={};for(let n of t){let o=e[n];if(o!==void 0&&o.length>0)r[n]=o}return r}function WS(e=process.env){return Object.freeze(Uo(e))}async function ef(e,t){let r=e.getReader(),n=[],o=0;try{while(!0){let s=await r.read();if(s.done)break;if(o+=s.value.byteLength,o>t)throw new V("invalid_transport_line","A subprocess stream exceeded its limit.");n.push(s.value)}}finally{r.releaseLock()}let i=new Uint8Array(o),a=0;for(let s of n)i.set(s,a),a+=s.byteLength;return i}function tf(e,t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch(r){throw new V("invalid_transport_line",`Invalid UTF-8 in ${t}.`,{},{cause:r})}}function Za(e){return ir(e.replace(/Bearer\s+[^\s]+/giu,"Bearer [redacted]").replace(/((?:api[_-]?key|authorization|cookie|password|secret|token)\s*[:=]\s*)[^\s,;]+/giu,"$1[redacted]"),512)}class rf{process;stdin;stdoutReader;stderrStream;maxLineBytes;maxDiagnosticBytes;lineDecoder=new TextDecoder("utf-8",{fatal:!0});stderrDiagnostics=[];stdoutBuffer=new Uint8Array(0);stderrPromise;closed=!1;constructor(e){if(!TH(e.executablePath))throw new V("discovery_failed","The Codex executable path must be absolute.");if(this.maxLineBytes=e.maxLineBytes??tl,this.maxDiagnosticBytes=e.maxDiagnosticBytes??tS,this.maxLineBytes<1||this.maxDiagnosticBytes<1)throw new V("invalid_external_data","The transport bounds are invalid.");if(this.process=Bun.spawn([e.executablePath,"app-server"],{...e.cwd===void 0?{}:{cwd:e.cwd},env:Uo(e.environment),stdin:"pipe",stdout:"pipe",stderr:"pipe"}),!(this.process.stdout instanceof ReadableStream)||!(this.process.stderr instanceof ReadableStream))throw new V("transport_failure","The Codex App Server did not expose stdio pipes.");if(typeof this.process.stdin==="number"||this.process.stdin===void 0)throw new V("transport_failure","The Codex App Server did not expose stdin.");if(this.stdin=this.process.stdin,this.stdoutReader=this.process.stdout,this.stderrStream=this.process.stderr,this.stderrPromise=this.collectStderr(),e.signal)if(e.signal.aborted)this.close();else e.signal.addEventListener("abort",()=>void this.close(),{once:!0})}get diagnostics(){return[...this.stderrDiagnostics]}async readLine(){if(this.closed&&this.stdoutBuffer.byteLength===0)return null;let e=this.stdoutReader.getReader();try{while(!0){let t=this.stdoutBuffer.indexOf(10);if(t>=0){if(t>this.maxLineBytes)throw await this.close(),new V("invalid_transport_line","The App Server emitted an overlong line.");let o=this.stdoutBuffer.slice(0,t);this.stdoutBuffer=this.stdoutBuffer.slice(t+1);let i=o.at(-1)===13?o.slice(0,-1):o;return this.lineDecoder.decode(i)}if(this.stdoutBuffer.byteLength>this.maxLineBytes)throw await this.close(),new V("invalid_transport_line","The App Server emitted an overlong line.");let r=await e.read();if(r.done){if(this.stdoutBuffer.byteLength===0)return null;if(this.stdoutBuffer.byteLength>this.maxLineBytes)throw await this.close(),new V("invalid_transport_line","The App Server emitted an overlong line.");let o=this.stdoutBuffer;return this.stdoutBuffer=new Uint8Array(0),this.lineDecoder.decode(o)}let n=new Uint8Array(this.stdoutBuffer.byteLength+r.value.byteLength);n.set(this.stdoutBuffer,0),n.set(r.value,this.stdoutBuffer.byteLength),this.stdoutBuffer=n}}catch(t){if(t instanceof V)throw t;throw new V("transport_failure","The App Server stdout could not be read.",{},{cause:t})}finally{e.releaseLock()}}async writeLine(e){if(this.closed)throw new V("closed","The App Server transport is closed.");if(new TextEncoder().encode(e).byteLength>this.maxLineBytes)throw new V("invalid_transport_line","The App Server request exceeded the line limit.");try{await this.stdin.write(`${e}
|
|
35
|
+
`),await this.stdin.flush()}catch(t){throw new V("transport_failure","The App Server stdin could not be written.",{},{cause:t})}}async close(){if(this.closed)return;this.closed=!0;try{await Promise.resolve(this.stdin.end())}catch{}try{this.process.kill()}catch{}await Promise.race([this.process.exited,new Promise((e)=>setTimeout(()=>e(-1),1000))]),await this.stderrPromise.catch(()=>{return})}async collectStderr(){try{let e=await ef(this.stderrStream,this.maxDiagnosticBytes),t=tf(e,"Codex stderr");for(let r of t.split(/\r?\n/u).slice(0,128)){let n=Za(r);if(n.length>0)this.stderrDiagnostics.push(n)}}catch{this.stderrDiagnostics.push("[stderr unavailable]")}}}var nf=x(()=>{pn()});import{lstat as E5,mkdir as v5,readFile as EH,readdir as O5,realpath as vH,stat as OH}from"fs/promises";import{delimiter as RH,isAbsolute as k5,join as C5,relative as A5,resolve as RP}from"path";async function CH(e){let t=[];if(e.executablePath!==void 0)t.push(RP(e.cwd??process.cwd(),e.executablePath));else{let r=e.pathValue??e.environment?.PATH??process.env.PATH??"",n=process.platform==="win32"?["codex.exe","codex.cmd","codex"]:["codex"];for(let o of r.split(RH).filter((i)=>i.length>0))for(let i of n)t.push(RP(o,i))}for(let r of t)try{let n=await OH(r);if(!n.isFile())continue;if(process.platform!=="win32"&&(n.mode&73)===0)continue;return await vH(r)}catch{if(e.executablePath!==void 0)throw new V("discovery_failed","The explicit Codex executable was not found.",{path:r})}throw new V("discovery_failed","No Codex executable was found on the allowlisted PATH.")}async function AH(e,t){let r=Bun.spawn([e,"--version"],{env:t,stdin:"ignore",stdout:"pipe",stderr:"pipe"});if(!(r.stdout instanceof ReadableStream)||!(r.stderr instanceof ReadableStream))throw new V("discovery_failed","The Codex version command did not expose output pipes.");try{let[n,o,i]=await IH(Promise.all([ef(r.stdout,16384),ef(r.stderr,16384),r.exited]),()=>r.kill(),"The Codex version command timed out."),a=ir(tf(n,"Codex version output"));if(i!==0||a.length===0){let s=Za(tf(o,"Codex version diagnostics"));throw new V("discovery_failed","The Codex executable did not provide a version.",{exitCode:i,diagnostics:s})}return a}catch(n){try{r.kill()}catch{}if(n instanceof V)throw n;throw new V("discovery_failed","The Codex version command failed.",{},{cause:n})}}async function PH(e){let t=await EH(e),r=await crypto.subtle.digest("SHA-256",t),n=[...new Uint8Array(r)].map((i)=>i.toString(16).padStart(2,"0")).join(""),o=Id(n);if(!o.ok)throw new V("discovery_failed","The Codex executable digest was invalid.");return o.value}async function JS(e={}){let t=await CH(e),r=Uo(e.environment),n=e.versionRunner?ir(await e.versionRunner(t,r)):await AH(t,r);if(n.length===0)throw new V("discovery_failed","The Codex version output was empty.");return{path:t,version:n,sha256:await PH(t)}}async function IH(e,t,r){let n;try{return await Promise.race([e,new Promise((o,i)=>{n=setTimeout(()=>{try{t()}catch{}i(new V("timeout",r))},kH)})])}finally{if(n!==void 0)clearTimeout(n)}}var kH=30000,N5;var kP=x(()=>{pt();Tt();pn();nf();N5=b({exitCode:Jt.pipe(Xe((e)=>Number.isSafeInteger(e))),stdout:A.pipe(Tx(1048576)),stderr:A.pipe(Tx(1048576))})});var MH="packages/codex/generated",NH,FH,GS,q5,U5;var CP=x(()=>{pt();Tt();pn();NH=/^codex-cli \d+\.\d+\.\d+$/u,FH=/^codex-app-server-\d+\.\d+\.\d+$/u,GS=A.pipe(de(/^[a-f0-9]{64}$/u)),q5=b({schema_version:T("holycodex-generated-v2"),artifact_root:T(MH),codex_cli_version:A.pipe(de(NH)),codex_cli_digest:GS,protocol_epoch:A.pipe(de(FH)),generator:b({command:lA(T("app-server"),T("generate-ts")),supported_surface:T("codex app-server generators")}),typescript_root:T("typescript"),files:b({count:Jt.pipe(kd(),vx()),digest:GS})}),U5=b({path:A.pipe(Va(1)),size:Jt.pipe(kd(),vx()),sha256:GS})});var LH;var AP=x(()=>{Tt();Yd();LH=b({owner:T("holycodex"),schema:A.pipe(de(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u)),installId:A.pipe(de(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u))})});import{spawn as DH}from"child_process";import{lstat as $o,mkdir as qH,mkdtemp as UH,readFile as HH,readdir as $H,realpath as YS,rename as jH,rm as BH,stat as z5}from"fs/promises";import{dirname as IP,isAbsolute as tb,join as Ho,relative as MP,resolve as af,sep as NP}from"path";async function LP(e){let t=ib(e.selectedPluginIds);if(t.length===0)return;if(HP(e.timeoutMs,e.pollIntervalMs),e.signal?.aborted)throw new xe("cancelled","Official Codex marketplace bootstrap was cancelled.");let r=e.readSnapshot??((s)=>ob(s,e.selectedPluginIds)),n=await r(e.codexHome);if(n!==void 0&&cf(n,t))return n;let o=e.initializeRuntime??(()=>e$(e)),i,a;try{i=await o()}catch(s){a=G("marketplace_unavailable","Codex runtime initialization could not start the official marketplace sync. Check that Codex is available and its network/policy settings permit the official marketplace.",s)}if(a===void 0)try{let s=e.timeoutMs??nb,c=e.pollIntervalMs??VH,l=Date.now();while(Date.now()-l<=s){if(e.signal?.aborted)throw new xe("cancelled","Official Codex marketplace bootstrap was cancelled.");let u=await r(e.codexHome);if(u!==void 0&&cf(u,t))return u;let p=s-(Date.now()-l);if(p<=0)break;await(e.sleep??r$)(Math.min(c,p))}a=G("marketplace_timeout","The official Codex marketplace did not become ready before the bounded wait expired. Check network access and Codex marketplace policy, then retry.")}catch(s){if(s instanceof xe&&s.code==="cancelled")throw s;a=s instanceof xe?s:G("marketplace_unavailable","The official Codex marketplace sync failed before its bounded wait completed.",s)}finally{await i?.()}if(e.gitFallback!==!1)try{return await DP({codexHome:e.codexHome,selectedPluginIds:e.selectedPluginIds,...e.environment===void 0?{}:{environment:e.environment},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.signal===void 0?{}:{signal:e.signal},...e.gitFallback===void 0?{}:e.gitFallback})}catch(s){if(s instanceof xe)throw s;throw G("marketplace_unavailable",`The official marketplace could not be populated after runtime startup (${a?.code??"unavailable"}). Check network access and retry.`,s)}throw a??G("marketplace_timeout","The official Codex marketplace did not become ready before the bounded wait expired.")}async function DP(e){let t=ib(e.selectedPluginIds);if(t.length===0)throw G("marketplace_invalid","The official marketplace fallback requires at least one selected provider plugin.");if(HP(e.timeoutMs,void 0),!tb(e.codexHome))throw G("marketplace_invalid","The Codex home for official marketplace fallback must be absolute.");if(e.signal?.aborted)throw new xe("cancelled","Official Codex marketplace fallback was cancelled.");let r=Uo(e.environment),n=e.gitRunner??BP("git",{environment:r,...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}}),o=e.timeoutMs??nb,i;try{i=await WH(n,o,e.signal)}catch(u){if(u instanceof xe)throw u;throw G("marketplace_unavailable","The official Codex marketplace remote HEAD could not be resolved. Check network access and retry.",u)}let a=Ho(e.codexHome,"plugins"),s=Ho(a,rb[1]);if(await GH(a,e.codexHome),await $o(s).catch((u)=>{if(hl(u))return;throw G("marketplace_invalid","The reserved official marketplace path could not be inspected safely.",u)})!==void 0)throw G("marketplace_invalid","The reserved official marketplace path appeared during bootstrap; refusing to overwrite it.");let l=await UH(Ho(a,".openai-plugins-stage-"));try{if(await XS(e.codexHome,l),e.cloneSnapshot!==void 0)try{await e.cloneSnapshot(qi,l)}catch(m){if(t$(m))throw G("marketplace_invalid","The staged official marketplace could not be created as a safe file tree.",m);throw m}else{let m=await n.run(["clone","--depth=1","--no-tags",qi,l],{...e.signal===void 0?{}:{signal:e.signal},timeoutMs:o});if(m.exitCode!==0)throw G("marketplace_unavailable","The official Codex marketplace could not be downloaded. Check network access and retry.",m.stderr)}await sf(l);let u=await qP(l,e.codexHome,t);if(u===void 0||!cf(u,t))throw G("marketplace_invalid","The downloaded official marketplace is missing the selected plugin entries or manifest.");if(await JH(n,l,o,e.signal)!==i)throw G("marketplace_invalid","The downloaded official marketplace did not match the verified remote HEAD.");if(await $o(s).catch((m)=>{if(hl(m))return;throw G("marketplace_invalid","The reserved official marketplace path could not be checked before publication.",m)})!==void 0)throw G("marketplace_invalid","The reserved official marketplace path appeared during staging; refusing to overwrite it.");await jH(l,s);let h=await ob(e.codexHome,e.selectedPluginIds);if(h===void 0||!cf(h,t))throw G("marketplace_invalid","The published official marketplace failed validation.");return h}catch(u){if(u instanceof xe)throw u;throw G("marketplace_unavailable","The official Codex marketplace fallback failed safely. Check network access and retry.",u)}finally{await BH(l,{recursive:!0,force:!0}).catch(()=>{return})}}async function WH(e,t,r){let n=await e.run(["ls-remote",qi,"HEAD"],{...r===void 0?{}:{signal:r},timeoutMs:t});if(n.exitCode!==0)throw G("marketplace_unavailable","The official Codex marketplace remote HEAD could not be resolved. Check network access and retry.",n.stderr);let o=n.stdout.trim().split(/\r?\n/u).map((a)=>a.trim()).filter((a)=>a.length>0),i=o.length===1?/^([0-9a-f]{40}|[0-9a-f]{64})\s+HEAD$/iu.exec(o[0]??""):null;if(i?.[1]===void 0)throw G("marketplace_invalid","The official Codex marketplace remote HEAD response was malformed.");return i[1].toLowerCase()}async function JH(e,t,r,n){let o=await e.run(["rev-parse","HEAD"],{timeoutMs:r,cwd:t,...n===void 0?{}:{signal:n}}),i=o.stdout.trim().toLowerCase();if(o.exitCode!==0||!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(i))throw G("marketplace_invalid","The downloaded official marketplace checkout did not expose a valid HEAD.",o.stderr);return i}async function GH(e,t){await ZS(t,e),await qH(e,{recursive:!0}),await ZS(t,e)}async function ZS(e,t){let r=af(e),n=af(t);while(!0){if((await $o(n).catch((a)=>{if(hl(a))return;throw a}))?.isSymbolicLink())throw G("marketplace_invalid","The official marketplace path cannot contain symlinks.");if(n===r)return;let i=IP(n);if(i===n||i!==r&&!YH(r,i))throw G("marketplace_invalid","The official marketplace path escaped CODEX_HOME.");n=i}}function YH(e,t){let r=MP(e,t);return r.length>0&&r!==".."&&!r.startsWith(`..${NP}`)&&!tb(r)}async function sf(e){let t=await $o(e);if(t.isSymbolicLink())throw G("marketplace_invalid","The official marketplace snapshot cannot contain symlinks.");if(!t.isDirectory())throw G("marketplace_invalid","The official marketplace snapshot is not a directory.");let r=await $H(e,{withFileTypes:!0});for(let n of r){let o=Ho(e,n.name),i=await $o(o);if(i.isSymbolicLink())throw G("marketplace_invalid","The official marketplace snapshot cannot contain symlinks.");if(i.isDirectory())await sf(o)}}async function ob(e,t=[]){return await qP(Ho(e,...rb),e,ib(t))}async function qP(e,t,r=[]){if(t!==void 0)await ZS(t,e);let n=await $o(e).catch((l)=>{if(hl(l))return;throw G("marketplace_invalid","The reserved openai-curated marketplace path could not be read safely.",l)});if(n===void 0)return;if(n.isSymbolicLink()||!n.isDirectory())throw G("marketplace_invalid","The reserved openai-curated marketplace path is not a real directory.");if(t!==void 0)await XS(t,e);else await sf(e);if(t!==void 0)await sf(e);let o=await YS(e),i=[Ho(o,".agents","plugins","marketplace.json"),Ho(o,".codex-plugin","marketplace.json"),Ho(o,"marketplace.json")],a,s;for(let l of i){let u=await $o(l).catch((p)=>{if(hl(p))return;throw G("marketplace_invalid","The official marketplace manifest could not be read safely.",p)});if(u===void 0)continue;if(u.isSymbolicLink()||!u.isFile())throw G("marketplace_invalid","The official marketplace manifest is not a regular file.");if(await XS(o,l),a!==void 0)throw G("marketplace_invalid","The reserved official marketplace contains more than one manifest.");a=l;try{s=new TextDecoder("utf-8",{fatal:!0}).decode(await HH(l))}catch(p){throw G("marketplace_invalid","The official marketplace manifest is not valid UTF-8.",p)}}if(a===void 0||s===void 0)return;let c;try{c=JSON.parse(s)}catch(l){throw G("marketplace_invalid","The official marketplace manifest is not valid JSON.",l)}return UP(c,o,a,r)}function UP(e,t=`${rb.join("/")}`,r=`${t}/marketplace.json`,n=[]){if(!ne(e)||e.name!==ml)throw G("marketplace_invalid","The reserved official marketplace manifest has an unexpected name.");ZH(e);let o=e.plugins;if(!Array.isArray(o)||o.length===0)throw G("marketplace_invalid","The official marketplace manifest has no plugin entries.");let i=[],a=new Set;for(let s of o){if(!ne(s)||typeof s.name!=="string"){if(n.length>0)continue;throw G("marketplace_invalid","The official marketplace contains a malformed plugin entry.")}let c=s.name;if(!/^[a-z][a-z0-9._-]{1,63}$/u.test(c)){if(n.length>0)continue;throw G("marketplace_invalid","The official marketplace contains an invalid plugin name.")}if(a.has(c)){if(n.length>0&&!n.includes(c))continue;throw G("marketplace_invalid","The official marketplace contains a duplicate plugin name.")}if(a.add(c),n.length>0&&!n.includes(c))continue;let l=XH(s);if(!QH(l))throw G("marketplace_invalid",`The official marketplace source for ${c} is unsafe.`);i.push({name:c,source:l})}if(n.some((s)=>!i.some((c)=>c.name===s)))throw G("marketplace_invalid","The official marketplace is missing a selected plugin entry.");return{name:ml,source:qi,rootPath:t,manifestPath:r,plugins:i}}function ZH(e){for(let t of["source","repository","repo","url"]){let r=e[t];if(r===void 0)continue;if((typeof r==="string"?r:ne(r)&&typeof r.url==="string"?r.url:void 0)!==qi)throw G("marketplace_invalid","The reserved official marketplace source is not the approved OpenAI repository.")}}function XH(e){let t=e.source;if(typeof t==="string")return t;if(ne(t)&&typeof t.path==="string")return t.path;if(typeof e.path==="string")return e.path;return}function QH(e){if(e===void 0||e.length===0||tb(e))return!1;if(/^[A-Za-z]:[\\/]/u.test(e))return!1;let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z][A-Za-z0-9+.-]*:/u.test(t))return!1;return t.split("/").every((r)=>r.length===0||r==="."||r!=="..")}function ib(e){let t=[],r=new Set;for(let n of e){let o=n.lastIndexOf("@");if(o<1)continue;let i=n.slice(o+1);if(i!==ml&&i!=="openai-curated-remote")continue;let a=n.slice(0,o);if(!/^[a-z][a-z0-9._-]{1,63}$/u.test(a))throw G("marketplace_invalid","A selected official marketplace plugin id is invalid.");if(!$P(a))continue;if(!r.has(a))r.add(a),t.push(a)}return t}function cf(e,t){return t.every((r)=>{let n=e.plugins.find((i)=>i.name===r);if(n===void 0)return!1;return n.source.replaceAll("\\","/").replace(/\/+$/u,"").split("/").at(-1)===r})}async function e$(e){let t=Uo(e.environment),r;try{r=new rf({executablePath:e.executablePath,environment:t,...e.signal===void 0?{}:{signal:e.signal}});let n=new Qd(r,{requestTimeoutMs:Math.min(e.timeoutMs??nb,1e4),...e.signal===void 0?{}:{signal:e.signal}});return await n.initialize(),async()=>{await n.close()}}catch(n){throw await r?.close().catch(()=>{return}),n}}function HP(e,t){if(e!==void 0&&(!Number.isSafeInteger(e)||e<1||e>300000))throw G("marketplace_invalid","The official marketplace timeout is invalid.");if(t!==void 0&&(!Number.isSafeInteger(t)||t<0||t>60000))throw G("marketplace_invalid","The official marketplace poll interval is invalid.")}async function XS(e,t){let r=await YS(e),n=await YS(t),o=MP(r,n);if(o===""||o===".."||o.startsWith(`..${NP}`))throw G("marketplace_invalid","The reserved official marketplace is outside CODEX_HOME.");let i=af(e),a=af(t);while(!0){if((await $o(a)).isSymbolicLink())throw G("marketplace_invalid","The reserved official marketplace path cannot contain symlinks.");if(a===i)break;let c=IP(a);if(c===a)throw G("marketplace_invalid","The reserved official marketplace path is outside CODEX_HOME.");a=c}}function hl(e){return typeof e==="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function t$(e){return typeof e==="object"&&e!==null&&"code"in e&&(e.code==="EPERM"||e.code==="EACCES")}async function r$(e){await new Promise((t)=>setTimeout(t,e))}function G(e,t,r){return new xe(e,t,r instanceof Error?{cause:Za(r.message)}:{})}function fn(e,t){let r=Ur(t);if(r===void 0||r!==t)return;let o=[...e.installed,...e.available].flatMap((i)=>{let a=kx(i.pluginId,i.marketplaceName);return a?.canonicalPluginId===r?[{identity:a,entry:i}]:[]});return o.find((i)=>i.entry.pluginId===r&&i.entry.installed)??o.find((i)=>i.entry.installed)??o.find((i)=>i.entry.pluginId===r)??o[0]}function $P(e){return Pd.includes(e)}function jP(e){if(!dP(eb,e))return lP(Le("live official plugin list",e));return uP(Ae(eb,e,"live official plugin list"))}function lf(e){let t=e.runner??BP(e.executable,{environment:e.environment??Uo(),...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.stdoutLimit===void 0?{}:{stdoutLimit:e.stdoutLimit},...e.stderrLimit===void 0?{}:{stderrLimit:e.stderrLimit}}),r=async()=>{let n=await t.run(["plugin","list","--json"]);if(n.exitCode!==0)throw of("list",n);let o;try{o=JSON.parse(n.stdout)}catch{throw new xe("command_failed","Codex returned invalid plugin data.")}let i=jP(o);if(!i.ok)throw new xe("command_failed","Codex returned an invalid official plugin list.");return i.value};return{list:r,ensureOfficialMarketplace:async(n)=>{if(e.codexHome===void 0)throw new xe("marketplace_unavailable","Codex home is unavailable; the official marketplace cannot be bootstrapped safely.");await LP({codexHome:e.codexHome,executablePath:e.executable,selectedPluginIds:n,...e.environment===void 0?{}:{environment:e.environment},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.officialMarketplaceFallback===void 0?{}:{gitFallback:e.officialMarketplaceFallback}})},addMarketplace:async(n,o)=>{let i=Ae(fl,n,"plugin marketplace source");if(i===ml||i===qi)throw new xe("marketplace_invalid","The reserved openai-curated marketplace must be populated by Codex runtime startup; it cannot be added manually.");let a=await t.run(["plugin","marketplace","add",i],o===void 0?void 0:{signal:o});if(a.exitCode!==0&&!/already (?:exists|added)/iu.test(a.stderr))throw of("marketplace add",a,i)},add:async(n,o)=>{let i=Ae(fl,n,"official plugin id"),a=await t.run(["plugin","add",i,"--json"],o===void 0?void 0:{signal:o});if(a.exitCode!==0)throw of("add",a,i);let s=await r(),c=fn(s,i),l=Ur(i),u=[...s.installed,...s.available].filter((f)=>f.pluginId===i&&(l===void 0||f.marketplaceName==null)),p=c?.entry??u.find((f)=>f.installed)??u[0];if(!p)throw new xe("readback_mismatch",`Codex did not report ${i} after installation.`,{plugin_id:i});if(!p.installed)throw new xe("plugin_missing",`Codex reported ${i} as unavailable after installation.`,{plugin_id:i});if(!p.enabled)throw new xe("plugin_disabled",`Codex installed ${i} but it is disabled; enable it in Codex and retry.`,{plugin_id:i})},remove:async(n,o)=>{let i=Ae(fl,n,"official plugin id"),a=i;if(Ur(i)===i){let u=await r(),p=fn(u,i);if(p?.entry.installed)a=p.entry.pluginId}let s=await t.run(["plugin","remove",a,"--json"],o===void 0?void 0:{signal:o});if(s.exitCode!==0&&!/not (?:installed|found)|missing/iu.test(s.stderr))throw of("remove",s,a);let c=await r(),l=[...c.installed,...c.available].find((u)=>u.pluginId===a);if(l?.installed)throw new xe("readback_mismatch",`Codex still reports ${i} after removal.`,{plugin_id:i,observed_plugin_id:l.pluginId})}}}function of(e,t,r){let n=Za(t.stderr).trim().slice(0,512),o=n.length>0?`: ${n}`:"";return new xe("command_failed",`Codex plugin ${e} failed${r===void 0?"":` for ${r}`}${o}`,{exit_code:t.exitCode})}function BP(e,t){let r=t.timeoutMs??30000,n=t.stdoutLimit??131072,o=t.stderrLimit??16384;return{run:(i,a)=>o$(e,i,{...t.environment===void 0?{}:{environment:t.environment},timeoutMs:a?.timeoutMs??r,stdoutLimit:n,stderrLimit:o,...a?.cwd===void 0?{}:{cwd:a.cwd},...a?.signal===void 0?{}:{signal:a.signal}})}}async function o$(e,t,r){if(r.signal?.aborted)throw new xe("cancelled","The Codex plugin command was cancelled.");let n=DH(e,[...t],{env:r.environment===void 0?void 0:{...r.environment},...r.cwd===void 0?{}:{cwd:r.cwd},stdio:["ignore","pipe","pipe"],windowsHide:!0}),o=PP(n.stdout,r.stdoutLimit),i=PP(n.stderr,r.stderrLimit),a=new Promise((p,f)=>{n.once("error",f),n.once("close",(h)=>p(h??-1))}),s,c,l=new Promise((p,f)=>{c=()=>{try{n.kill()}catch{}f(new xe("cancelled","The Codex plugin command was cancelled."))},r.signal?.addEventListener("abort",c,{once:!0})}),u=new Promise((p,f)=>{s=setTimeout(()=>{try{n.kill()}catch{}f(new xe("timeout","The Codex plugin command timed out."))},r.timeoutMs)});try{let[p,f,h]=await Promise.race([Promise.all([o,i,a]),l,u]);return{stdout:p,stderr:f,exitCode:h}}catch(p){try{n.kill()}catch{}if(p instanceof xe)throw p;throw new xe("command_failed","The Codex plugin command failed.")}finally{if(s!==void 0)clearTimeout(s);if(c!==void 0)r.signal?.removeEventListener("abort",c)}}function PP(e,t){if(e===null)return Promise.reject(new xe("command_failed","Codex plugin command output is unavailable."));return new Promise((r,n)=>{let o=[],i=0;e.on("data",(a)=>{let s=typeof a==="string"?new TextEncoder().encode(a):a instanceof Uint8Array?a:void 0;if(s===void 0){n(new xe("command_failed","Codex plugin output was invalid."));return}if(i+=s.byteLength,i>t){n(new xe("output_limit","Codex plugin output exceeded its limit."));return}o.push(s)}),e.once("end",()=>{let a=new Uint8Array(i),s=0;for(let c of o)a.set(c,s),s+=c.byteLength;try{r(new TextDecoder("utf-8",{fatal:!0}).decode(a))}catch(c){n(c)}}),e.once("error",(a)=>n(a))})}var ml="openai-curated",qi="https://github.com/openai/plugins.git",rb,nb=30000,VH=100,FP,zH,dl,fl,KH,n$,QS,eb,xe;var ab=x(()=>{pt();Tt();KS();pn();nf();rb=["plugins","openai-plugins"],FP=A.pipe(de(/^[a-z][a-z0-9._-]{1,63}$/u)),zH=A.pipe(de(/^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][A-Za-z0-9.-]+)?$/u)),dl=U(A),fl=A.pipe(de(/^[A-Za-z0-9][A-Za-z0-9._:@/-]{0,255}$/u)),KH=b({name:FP,version:zH,description:Wn,author:_(ar),license:_(Wn),homepage:_(Wn),repository:_(Wn),keywords:_(dl),skills:_(dl),commands:_(dl),hooks:_(dl),assets:_(dl),official:_(W)});n$=b({id:FP,selected:T(!0)}),QS=b({pluginId:fl,installed:W,enabled:W,name:_(ye(A,ut)),marketplaceName:_(ye(A,ut)),version:_(ye(A,ut))},Rd({key:A,value:xx})),eb=b({installed:U(QS),available:U(QS)});xe=class xe extends Error{code;details;constructor(e,t,r={}){super(t);this.name="OfficialPluginAdapterError",this.code=e,this.details=r}}});var gl=x(()=>{pn();pn();jd();zS();KS();nf();kP();CP();AP();Yd();ab();ab()});function sr(e){if(!Xa(e))throw Error("The value is not JSON serializable.");return cn(e),e}function Xa(e,t=new Set){if(e===null||typeof e==="string"||typeof e==="boolean")return!0;if(typeof e==="number")return Number.isFinite(e);if(typeof e!=="object"||t.has(e))return!1;t.add(e);try{if(Array.isArray(e))return e.every((r)=>Xa(r,t));return Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every((r)=>Xa(r,t))}finally{t.delete(e)}}var yl=x(()=>{pt()});function ht(e,t){let r=br(e,t);return Rt(r)?r.right:void 0}function WP(e){return ht(pf,e)!==void 0}var pf,L4,sb,df,i$,es,a$,s$,c$,zP,xl,ff,Qa,cb,uf,l$,VP,u$,lb,ts,p$,KP,d$,f$,jr;var rs=x(()=>{gl();pt();er();Tt();yl();pf=q((e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Xa(e)),L4=q(Xa),sb=A.pipe(de(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u)),df=A.pipe(de(/^[0-9a-f]{64}$/u)),i$=A.pipe(de(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u)),es=A.pipe(de(/^[A-Za-z0-9][A-Za-z0-9._:@/-]{0,255}$/u)),a$=A.pipe(Xe((e)=>!Number.isNaN(Date.parse(e)))),s$=b({path:A.pipe(de(/^[A-Za-z0-9][A-Za-z0-9._/-]{0,255}$/u)),digest:df}),c$=b({computer_use:W,work:W,frontend:W,security:W,coding:T(!0)}),zP=b({computer_use:_(W),work:_(W),frontend:_(W),security:_(W)}),xl=b({profile:_(Mo),tier:_(Mi),optional:_(zP),officialPlugins:_(U(es))}),ff=xl,Qa=b({selected:W,status:T("disabled","pending","healthy","missing","provider_disabled","uncertain","unavailable"),plugin_ids:U(es),reason:_(A)}),cb=b({computer_use:Qa,work:Qa,frontend:Qa,security:Qa}),uf=b({presence:T("absent","present"),digest:df,safe_value:_(ye(b({kind:T("boolean"),value:W}),b({kind:T("marketplace"),source_type:T("git"),source:T("https://github.com/davidbasilefilho/holycodex.git")})))}),l$=b({plugin_id:T("holycodex@holycodex"),before:b({preference:uf,marketplace:uf}),after:b({preference:uf,marketplace:uf})}),VP=b({presence:T("absent","present"),digest:df,safe_value:_(b({kind:T("boolean"),value:W}))}),u$=b({plugin_id:es,before:VP,after:VP}),lb={owner:T("holycodex"),schema_epoch:T(Tr),install_id:i$,version:sb,digest:df,profile:Mo,tier:Mi,optional_selections:c$,explicit_optional_selections:zP,official_plugins:_(U(es)),capability_state:_(cb),managed_artifacts:U(s$),installed_at:a$,status:_(T("active")),step:_(T("active")),managed_config:_(Wd),plugin_snapshot:_(U(b({plugin_id:es,status:T("installed","available","missing","disabled","uncertain","unknown")}))),plugin_config:_(l$),provider_config:_(U(u$)),owned_plugins:_(U(es))},ts=b(lb),p$=(({profile:e,...t})=>t)(lb),KP=ye(b({...lb,profile:Nd}),b({...p$,plan:Nd})),d$=T("preparing","conflicted"),f$=T("validated","plugins_snapshotted","roles_prepared","plugins_installed","config_published","verified","conflicted"),jr=b({...ts.fields,status:d$,step:f$})});import{lstat as m$,mkdir as h$}from"fs/promises";import{homedir as g$}from"os";import{dirname as y$,join as Ui,posix as JP,resolve as x$,sep as GP,win32 as YP}from"path";function ns(e={},t=process.env){let r=g$(),n=e.paths?.codexHome??t.CODEX_HOME??Ui(r,".codex"),o=pb(n,"CODEX_HOME"),i=Ui(o,S$);return{codexHome:o,stateRoot:i,activeRecord:Ui(i,b$),preparingRecord:Ui(i,_$),conflictedRecord:Ui(i,w$),roleRoot:Ui(i,"agents"),configFile:Ui(o,"config.toml")}}function pb(e,t,r=process.platform==="win32"?"win32":"posix"){if(typeof e!=="string"||E$(e))throw new _r("invalid_path",`${t} contains invalid characters.`);let n=r==="win32"?YP:JP,o=ub(e,r);if(typeof o!=="string"||o.length===0||!n.isAbsolute(o))throw new _r("invalid_path",`${t} must be an absolute path.`);let i=n.normalize(o);if(i.split(r==="win32"?"\\":GP).filter((s)=>s.length>0).length===0||i===n.dirname(i))throw new _r("broad_path",`${t} is too broad.`);if(o.split(/[\\/]/u).some((s)=>s===".."))throw new _r("invalid_path",`${t} cannot contain traversal.`);return n.resolve(i)}function E$(e){for(let t of e){let r=t.codePointAt(0)??0;if(r<=31||r===127)return!0}return!1}async function Sl(e){pb(e,"owned path"),await mn(e),await h$(e,{recursive:!0}),await mn(e)}async function mn(e){let r=x$(e);while(!0){try{if((await m$(r)).isSymbolicLink())throw new _r("path_symlink","A managed path cannot contain a symlink.")}catch(o){if(o instanceof _r)throw o;if(!gt(o,"ENOENT"))throw o}let n=y$(r);if(n===r)break;r=n}}async function bl(e){await mn(e)}function os(e,t,r=process.platform==="win32"?"win32":"posix"){let n=r==="win32"?YP:JP,o=n.resolve(ub(e,r)),i=n.resolve(ub(t,r)),a=n.relative(o,i);return a.length>0&&!a.startsWith(`..${r==="win32"?"\\":GP}`)&&a!==".."&&!n.isAbsolute(a)}function ub(e,t){if(t==="win32"&&/^\/[A-Za-z](?:\/|$)/u.test(e))return`${e[1]?.toUpperCase()??""}:${e.slice(2).replaceAll("/","\\")}`;return e}function gt(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}var S$="holycodex",b$="active.json",_$="preparing.json",w$="conflicted.json",T$,_r;var Hi=x(()=>{pt();T$=Tr;_r=class _r extends Error{code;constructor(e,t){super(t);this.name="PathBoundaryError",this.code=e}}});import{lstat as ZP,open as v$,readFile as XP,rename as O$,unlink as R$,writeFile as k$}from"fs/promises";import{dirname as C$}from"path";async function QP(e){let t;try{t=await v$(e,"r"),await t.sync()}catch(r){if(!eI(r))throw r}finally{await t?.close().catch(()=>{return})}}async function P$(e){await QP(e).catch((t)=>{if(!eI(t))throw t})}async function jo(e,t){await Jn(e,`${cn(t)}
|
|
36
|
+
`)}async function Jn(e,t){let r=C$(e);await Sl(r),await mn(e);let n=`${e}.tmp-${process.pid}-${crypto.randomUUID()}`;try{await k$(n,t,{encoding:"utf8",mode:384}),await QP(n),await O$(n,e),await P$(r)}catch(o){throw await R$(n).catch(()=>{return}),o}}async function I$(e,t){let r=await ZP(e);if(!r.isFile()||r.isSymbolicLink())throw new $i("state_corrupt","A persisted file is not a regular file.");let n;try{n=JSON.parse(await XP(e,"utf8"))}catch(i){throw new $i("state_corrupt","A persisted file is not valid JSON.",i)}let o=ht(t,n);if(o===void 0)throw new $i("state_corrupt","A persisted file failed schema validation.");return o}async function Yt(e){try{let t=await ZP(e);if(!t.isFile()||t.isSymbolicLink())throw new $i("state_corrupt","A persisted file is not a regular file.");return await XP(e,"utf8")}catch(t){if(gt(t,"ENOENT"))return;throw t}}async function Gn(e,t){try{return await I$(e,t)}catch(r){if(gt(r,"ENOENT"))return;throw r}}function eI(e){if(typeof e==="object"&&e!==null&&"code"in e&&typeof e.code==="string")return A$.has(e.code)||process.platform==="win32"&&e.code==="EPERM";return!1}var A$,$i;var is=x(()=>{pt();Hi();rs();A$=new Set(["EBADF","EINVAL","ENOSYS","ENOTSUP","EISDIR"]);$i=class $i extends Error{code;causeValue;constructor(e,t,r){super(t);this.name="StorageError",this.code=e,this.causeValue=r}}});import{readFile as M$}from"fs/promises";import{dirname as N$,resolve as F$}from"path";import{fileURLToPath as L$}from"url";async function tI(e=_l){let t=JSON.parse(await M$(e,"utf8")),r=ht(q$,t);if(r===void 0)throw new wl("manifest_invalid","The public package manifest is invalid.");return r}async function mf(e=_l){return(await tI(e)).version}async function hf(e=_l){return(await mf(e)).split("-",1)[0]??""}async function db(e,t,r=_l){let n=await tI(r),o=await hf(r),i=U$(e,o);if(!t)await jo(r,{...n,version:i});return{previous:o,next:i}}function U$(e,t){if(e!=="patch"&&e!=="minor"){if(ht(sb,e)===void 0)throw new wl("version_invalid","The version target is invalid.");return e}let r=t.split("."),n=Number(r[1]),o=Number(r[2]);return e==="minor"?`0.${n+1}.0`:`0.${n}.${o+1}`}var D$,q$,_l,wl;var gf=x(()=>{Tt();rs();is();D$=A.pipe(de(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-dev\.[1-9]\d*\.[1-9]\d*)?$/u)),q$=q((e)=>WP(e)&&e.name==="holycodex"&&ht(D$,e.version)!==void 0),_l=F$(N$(L$(import.meta.url)),"../package.json");wl=class wl extends Error{code;constructor(e,t){super(t);this.name="ManifestError",this.code=e}}});import{lstat as yf,readFile as xf,rm as Sf}from"fs/promises";import{join as cr,relative as rI}from"path";function nI(){return`Surgical mutation rule: ${No.surgicalMutationRule} ${$$}`}function ji(e,t="standard"){let r=ln(e);if(!r.ok)return[];return r.value.routes.map((n)=>{let o={role:n.role,task:n.task};return{name:Dx(o),rolePolicy:$r.find((i)=>i.role===n.role),description:Ux(o),taskInstruction:qx(o),permissions:Hx(o),model:"gpt-5.6-luna",effort:n.effort,serviceTier:t==="standard"?"default":"fast"}})}function mb(e,t="standard"){let r=ln(e);if(!r.ok)throw Error("Unknown profile.");return{name:"root",description:"Root-directed HolyCodex control agent.",model:r.value.root.model,effort:r.value.root.effort,serviceTier:t==="fast-all"?"fast":"default"}}function hb(e=!1){if(!No.requiresDelegation||!No.trivialWorkRequiresDelegation||!No.codeReviewRequiredForImplementation||!No.codeReviewRequiredBeforeVcs||!No.externalVerificationMustBeTerminal)throw Error("The Root orchestration policy is incomplete.");let t=["You are the HolyCodex Root orchestrator and final integration owner. Treat these generated Root instructions as the authoritative global behavior contract, AGENTS.md as repository rules, and installed skills as branch procedures.","MUST orchestrate and delegate every task, including trivial work, through a bounded Assignment to the native Explorer, Librarian, Worker, or Reviewer agents; do not implement, debug, research, test, review, or operate CI for the underlying work directly. Git/VCS is always Root-only and may be performed directly; Computer Use is a direct exception only when this installation selected --computer-use.",nI(),"Own the persistent Intent, user goal and acceptance criteria, architecture and material product or policy choices, lifecycle transitions, assignment integration, contradictory-evidence resolution, external effects, and final readiness. Use holycodex-agent semantic operations for Intent, Plan, and Assignment state; never manually edit TOON or create handoff, Decision, or standalone blocker files. Keep model_verbosity = low.","Bias toward action. Before request_user_input, finish all authorized read-only, reversible, preparatory, and independent work that can reduce uncertainty. Request input only for a material choice or explicit approval boundary: before plan approval, before installation profile approval, before remote/origin/server VCS mutation, before public publication or release, or when ambiguity/missing material input blocks safe progress. Persist the resulting needs_root_input state.","Load writing-for-agents fully before the first dispatch and apply it before every dispatch. Reuse that contract while the current context contains a complete usable load; reload only when it no longer does. Dispatch independent, non-overlapping Assignments concurrently when that improves latency or evidence coverage, preserve dependency order, and never run parallel writes against the same mutable seam. Leaves return compact structured outcomes and evidence; they cannot delegate, message peers, mutate global Intent lifecycle, perform Git/VCS, or decide material product or architecture choices.","Run proportional proof: start with the smallest relevant check, then broaden only for a new change, failure, or unresolved evidence gap. A review fixed point means no actionable finding remains within scope; do not repeat broader testing without a reason. Inspect every specialist outcome and evidence before integration. Reviewer.code fixed-point review is mandatory after implementation or any major codebase change and must pass before completion or any VCS operation.","After integration, follow the repository's discovered workflow: commit the finished change as Root, push when its topology requires a remote, and delegate Worker.operations to observe CI for the exact ref/SHA to terminal evidence; pending or running is never success. If the development gate is terminal green and release is requested and approved, perform that release action as Root and delegate terminal release observation. If any gate fails, delegate a bounded fix and repeat implementation, fixed-point review, VCS, and exact-ref observation until green. Discover the repository's actual gate and provider topology; never assume a branch or server separation."];if(e)t.push("Interactive GUI, browser, and Computer Use execution is Root-only and must not be delegated.");else t.push("Computer Use is not selected for this installation; delegate GUI, browser, and Computer Use execution to an appropriate bounded specialist.");return t.join(`
|
|
37
|
+
`)}async function gb(e,t,r=[],n="standard"){let o=cr(e,"holycodex","agents"),i=[],a=[],s=ji(t,n).map((p)=>({path:cr(o,`${p.name}.toml`),contents:wf(p)})),c=new Map(r.map((p)=>[cr(e,p.path),p])),l=new Map;for(let p of s){let f=await fb(p.path);l.set(p.path,f);let h=c.get(p.path);if(f!==void 0&&h===void 0&&f!==p.contents)throw Error(`A pre-existing HolyCodex role file is not owned by this installation: ${p.path}`)}let u=[];try{for(let m of s){let w=l.get(m.path),S=c.get(m.path);if(w!==void 0&&S!==void 0){if(await as(w)!==S.digest&&w!==m.contents){i.push(m.path),u.push({path:rI(e,m.path).replaceAll("\\","/"),digest:S.digest});continue}}if(w===void 0||w!==m.contents)await Jn(m.path,m.contents),a.push({path:m.path,previous:w,installedDigest:await as(m.contents)});u.push({path:rI(e,m.path).replaceAll("\\","/"),digest:await as(m.contents)})}let p=cr(e,"agents","root.toml"),f=await fb(p),h=await oI(p);if(h==="preserved")i.push(p);if(h==="removed"&&f!==void 0)a.push({path:p,previous:f,installedDigest:void 0});for(let m of r){let w=cr(e,m.path);if(!s.some((S)=>S.path===w)){if(!V$(e,w,m.path)){i.push(w);continue}let S=await z$(w,m.digest);if(S.status==="preserved")i.push(w);else if(S.previous!==void 0)a.push({path:w,previous:S.previous,installedDigest:void 0})}}for(let m of r){let w=cr(e,m.path);if(i.includes(w)&&!u.some((S)=>cr(e,S.path)===w))u.push(m)}return{managed_artifacts:u,preserved:i,rollback:a}}catch(p){throw await bf(a).catch(()=>{return}),p}}async function bf(e){let t=[],r=[];for(let n of[...e].reverse()){let o=await fb(n.path);if(!(n.installedDigest===void 0?o===void 0:o!==void 0&&await as(o)===n.installedDigest)){r.push(n.path);continue}if(n.previous===void 0)await Sf(n.path,{force:!1}).catch((a)=>{if(!gt(a,"ENOENT"))throw a}),t.push(n.path);else await Jn(n.path,n.previous)}return{removed:t,preserved:r}}async function _f(e,t){let r=[],n=[],o=cr(e,"agents"),i=cr(e,"holycodex","agents");for(let c of t){let l=cr(e,c.path);if(!os(e,l)||!os(o,l)&&!os(i,l)&&l!==cr(e,"config.toml")){n.push(l);continue}try{await mn(l);let u=await yf(l);if(u.isSymbolicLink()||!u.isFile()){n.push(l);continue}let p=await xf(l);if(await as(p)!==c.digest){n.push(l);continue}await Sf(l,{force:!1}),r.push(l)}catch(u){if(gt(u,"ENOENT"))r.push(l);else n.push(l)}}let a=cr(e,"agents","root.toml"),s=await oI(a);if(s==="removed")r.push(a);if(s==="preserved")n.push(a);return{removed:r,preserved:n}}function wf(e){let t=e.rolePolicy,r=[nI(),H$,`${t.role} shared policy: ${t.authority}`,t.evidence,t.completion,e.taskInstruction].join(`
|
|
38
|
+
`);return[`name = ${JSON.stringify(e.name)}`,`description = ${JSON.stringify(e.description)}`,`model = ${JSON.stringify(e.model)}`,`model_reasoning_effort = ${JSON.stringify(e.effort)}`,`service_tier = ${JSON.stringify(e.serviceTier)}`,'model_reasoning_summary = "none"','model_verbosity = "low"',`sandbox_mode = ${JSON.stringify(e.permissions.write?"workspace-write":"read-only")}`,'approval_policy = "never"',`web_search = ${JSON.stringify(e.permissions.network?"live":"disabled")}`,`developer_instructions = ${JSON.stringify(r)}`,"","[agents]","enabled = false","interrupt_message = false","","[features]","multi_agent_v2 = false","multi_agent = false","computer_use = false","browser_use = false","in_app_browser = false",""].join(`
|
|
39
|
+
`)}function j$(e,t,r){return['name = "root"','description = "Root-directed HolyCodex control agent."',`model = ${JSON.stringify(e)}`,`model_reasoning_effort = ${JSON.stringify(t)}`,`service_tier = ${JSON.stringify(r)}`,'model_verbosity = "low"',""].join(`
|
|
40
|
+
`)}function ss(e){return B$.has(e)}function V$(e,t,r){if(r==="agents/root.toml")return!0;if(/^holycodex\/agents\/(?:explorer|librarian|worker|reviewer)\.toml$/u.test(r))return!0;return os(cr(e,"agents"),t)&&/^(?:Explorer|Librarian|Worker|Reviewer)\.(?:lookup|trace|research|mechanical|implementation|integration|operations|plan|code|artifact)\.toml$/u.test(r.slice(7))}async function oI(e){try{await mn(e);let t=await yf(e);if(!t.isFile()||t.isSymbolicLink())return"preserved";let r=await xf(e,"utf8");if(!ss(r))return"preserved";return await Sf(e,{force:!1}),"removed"}catch(t){if(gt(t,"ENOENT"))return"absent";throw t}}async function fb(e){try{await mn(e);let t=await yf(e);if(t.isSymbolicLink()||!t.isFile())throw Error(`Invalid managed path: ${e}`);return new TextDecoder("utf-8",{fatal:!0}).decode(await xf(e))}catch(t){if(gt(t,"ENOENT"))return;throw t}}async function z$(e,t){try{await mn(e);let r=await yf(e);if(r.isSymbolicLink()||!r.isFile())return{status:"preserved"};let n=new TextDecoder("utf-8",{fatal:!0}).decode(await xf(e));if(await as(n)===t)return await Sf(e,{force:!1}),{status:"removed",previous:n};return{status:"preserved"}}catch(r){if(gt(r,"ENOENT"))return{status:"removed"};throw r}}async function as(e){let t=typeof e==="string"?new TextEncoder().encode(e):e,r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r),(n)=>n.toString(16).padStart(2,"0")).join("")}var H$="Do not delegate, message peers, mutate global Intent lifecycle, make material decisions, or perform Git/VCS. Return exactly one compact structured outcome (`completed`, `blocked`, `needs_root_input`, or `failed`) with observable evidence, changed paths and checks, local blockers, and remaining risk.",$$="Every Assignment must state its exact boundary, exclusions, acceptance criteria, and evidence.",B$;var Tf=x(()=>{pt();Hi();is();B$=new Set([{model:"gpt-5.6-terra",effort:"high"},{model:"gpt-5.6-sol",effort:"low"},{model:"gpt-5.6-sol",effort:"medium"},{model:"gpt-5.6-sol",effort:"high"}].flatMap(({model:e,effort:t})=>["default","fast"].map((r)=>j$(e,t,r))))});class Bo{adapter;observedIdentities={};constructor(e){if("run"in e){let t=lf({executable:"codex",runner:e});this.adapter=t}else this.adapter=e}static async discover(e=process.env){let t=await JS({environment:e}),r=lf({executable:t.path,environment:WS(e),...e.CODEX_HOME===void 0?{}:{codexHome:e.CODEX_HOME}});return new Bo(r)}async list(){try{return await this.adapter.list()}catch(e){throw Tl("list",e)}}async add(e){try{await this.adapter.add(e)}catch(t){throw Tl("add",t,e)}}async ensureOfficialMarketplace(e){if(this.adapter.ensureOfficialMarketplace===void 0)return;try{await this.adapter.ensureOfficialMarketplace(e)}catch(t){throw Tl("bootstrap",t)}}async remove(e){try{await this.adapter.remove(e)}catch(t){throw Tl("remove",t,e)}}async addMarketplace(e){try{await this.adapter.addMarketplace(e)}catch(t){throw Tl("add",t,e)}}async status(e){let t=await this.list(),r={},n=new Map;for(let i of[...t.installed,...t.available])if(!n.has(i.pluginId)||i.installed)n.set(i.pluginId,i);let o=Object.fromEntries(e.map((i)=>{let a=fn(t,i),s=Ur(i),c=n.get(i),l=a?.entry??(s===void 0||c?.marketplaceName==null?c:void 0),u=a;if(l!==void 0)r[i]=u?.entry.pluginId??l.pluginId;let p=l===void 0?"missing":l.installed&&l.enabled?"installed":l.installed?"disabled":"missing";return[i,p]}));return this.observedIdentities=Object.freeze(r),o}getObservedIdentities(){return this.observedIdentities}}function Tl(e,t,r){if(t instanceof hn)return t;let o=(t instanceof xe?t:void 0)?.code,i=o==="timeout"||o==="output_limit"||o==="cancelled"||o==="readback_mismatch"||o==="plugin_disabled"||o==="plugin_missing"||o==="marketplace_invalid"||o==="marketplace_timeout"||o==="marketplace_unavailable"?o:o==="command_failed"?e==="list"?"list_failed":e==="remove"?"remove_failed":e==="bootstrap"?"marketplace_unavailable":"add_failed":e==="list"?"list_failed":e==="bootstrap"?"marketplace_unavailable":"add_failed",a=t instanceof Error?t.message:e==="list"?"Codex could not list official plugins.":e==="remove"?`Codex could not remove ${r??"the selected official plugin"}.`:e==="bootstrap"?"Codex could not initialize the official marketplace.":`Codex could not add ${r??"the selected official plugin"}.`;return new hn(i,a,t,r===void 0?{}:{plugin_id:r})}var hn;var El=x(()=>{gl();pt();hn=class hn extends Error{code;causeValue;details;constructor(e,t,r,n={}){super(t);this.name="OfficialPluginManagerError",this.code=e,this.causeValue=r,this.details=n}}});function aI(e){let t={},r=[];for(let n of e.split(/\r?\n/u)){let o=W$(n).trim();if(o.length===0)continue;if(o.startsWith("[[")||o.endsWith("]]"))throw Error("Array-of-tables are not supported by the validated fallback.");if(o.startsWith("[")&&o.endsWith("]")){r=yb(o.slice(1,-1).trim()),K$(t,r);continue}let i=uI(o);if(i<1)throw Error("TOML assignment is invalid.");let a=yb(o.slice(0,i).trim()),s=Ef(o.slice(i+1).trim());lI(t,[...r,...a],s)}return t}function sI(e){let t=[];return cI(e,[],t),t.join(`
|
|
41
|
+
`)}function cI(e,t,r){let n=[],o=[];for(let[i,a]of Object.entries(e))if(Sb(a))o.push([i,a]);else n.push([i,a]);if(t.length>0){if(r.length>0)r.push("");r.push(`[${t.map(iI).join(".")}]`)}for(let[i,a]of n)r.push(`${iI(i)} = ${pI(a)}`);for(let[i,a]of o)cI(a,[...t,i],r)}function Ef(e){if(e.length===0)throw Error("TOML value is missing.");if(e.startsWith('"')){let t=JSON.parse(e);if(typeof t!=="string")throw Error("TOML string is invalid.");return t}if(e.startsWith("'")){if(!e.endsWith("'")||e.length<2)throw Error("TOML string is invalid.");return e.slice(1,-1)}if(e==="true")return!0;if(e==="false")return!1;if(e.startsWith("[")){if(!e.endsWith("]"))throw Error("TOML array is invalid.");let t=e.slice(1,-1).trim();return t.length===0?[]:xb(t,",").map(Ef)}if(e.startsWith("{")){if(!e.endsWith("}"))throw Error("TOML inline table is invalid.");let t=e.slice(1,-1).trim(),r={};if(t.length===0)return r;for(let n of xb(t,",")){let o=uI(n);if(o<1)throw Error("TOML inline table entry is invalid.");lI(r,yb(n.slice(0,o).trim()),Ef(n.slice(o+1).trim()))}return r}if(/^[+-]?(?:0|[1-9]\d*)(?:\.\d+)?$/u.test(e)){let t=Number(e);if(Number.isFinite(t))return t}throw Error("TOML value is unsupported.")}function yb(e){let t=xb(e,".").map((r)=>r.trim());if(t.length===0||t.some((r)=>!/^(?:[A-Za-z0-9_-]+|"(?:[^"\\]|\\.)*"|'[^']*')$/u.test(r)||r==="__proto__"||r==="constructor"||r==="prototype"))throw Error("TOML key is invalid.");return t.map((r)=>r.startsWith('"')||r.startsWith("'")?Ef(r):r)}function lI(e,t,r){if(t.length===0)throw Error("TOML key is missing.");let n=e;for(let i of t.slice(0,-1)){let a=n[i];if(a===void 0){let s={};n[i]=s,n=s}else if(Sb(a))n=a;else throw Error("TOML key conflicts with a scalar.")}let o=t.at(-1);if(Object.prototype.hasOwnProperty.call(n,o))throw Error("TOML key is duplicated.");n[o]=r}function K$(e,t){let r=e;for(let n of t){let o=r[n];if(o===void 0){let i={};r[n]=i,r=i}else if(Sb(o))r=o;else throw Error("TOML table conflicts with a scalar.")}}function xb(e,t){let r=[],n=0,o=0,i,a=!1;for(let s=0;s<e.length;s+=1){let c=e[s];if(i!==void 0){if(i==='"'&&a)a=!1;else if(i==='"'&&c==="\\")a=!0;else if(c===i)i=void 0;continue}if(c==='"'||c==="'")i=c;else if(c==="["||c==="{")o+=1;else if(c==="]"||c==="}")o-=1;else if(c===t&&o===0)r.push(e.slice(n,s)),n=s+1}if(i!==void 0||o!==0)throw Error("TOML value is unbalanced.");return r.push(e.slice(n)),r}function uI(e){let t,r=!1,n=0;for(let o=0;o<e.length;o+=1){let i=e[o];if(t!==void 0){if(t==='"'&&r)r=!1;else if(t==='"'&&i==="\\")r=!0;else if(i===t)t=void 0}else if(i==='"'||i==="'")t=i;else if(i==="["||i==="{")n+=1;else if(i==="]"||i==="}")n-=1;else if(i==="="&&n===0)return o}return-1}function W$(e){let t,r=!1;for(let n=0;n<e.length;n+=1){let o=e[n];if(t!==void 0){if(t==='"'&&r)r=!1;else if(t==='"'&&o==="\\")r=!0;else if(o===t)t=void 0}else if(o==='"'||o==="'")t=o;else if(o==="#")return e.slice(0,n)}return e}function Sb(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function iI(e){return/^[A-Za-z0-9_-]+$/u.test(e)?e:JSON.stringify(e)}function pI(e){if(typeof e==="string")return JSON.stringify(e);if(typeof e==="boolean"||typeof e==="number"){if(typeof e==="number"&&!Number.isFinite(e))throw Error("TOML number is invalid.");return String(e)}if(Array.isArray(e))return`[${e.map(pI).join(", ")}]`;if(e===null)throw Error("TOML null is not serializable.");throw Error("TOML nested values must be tables.")}import{rm as bb,rmdir as dI}from"fs/promises";async function Tb(e={},t=process.env){let r=ns(e,t),n={};try{await bl(r.codexHome),await bl(r.stateRoot),n.paths=vl({state_root:r.stateRoot})}catch(l){n.paths=Et(["path_symlink"],{error:Yn(l)})}let[o,i,a]=await Promise.all([Rl(r).catch((l)=>{n.configuration=Et(["state_corrupt"],{error:Yn(l)});return}),Gn(r.preparingRecord,jr).catch((l)=>{n.transaction=Et(["state_corrupt"],{path:r.preparingRecord,error:Yn(l)});return}),Gn(r.conflictedRecord,jr).catch((l)=>{n.transaction=Et(["state_corrupt"],{path:r.conflictedRecord,error:Yn(l)});return})]);if(i!==void 0&&n.transaction?.status!=="failed")n.transaction=Et(["incomplete_install_state"]);if(a!==void 0&&n.transaction?.status!=="failed")n.transaction=Et(["conflicted_state"]);if(!n.configuration)if(!o)n.configuration=Et(["configuration_missing"]);else if(await Rf(o))n.configuration=vl({profile:o.profile,tier:o.tier,install_id:o.install_id});else n.configuration=Et(["configuration_changed"],{path:r.activeRecord});if(o){n.runtime_config=await J$(r,o),n.native_roles=await G$(r,o.profile,o.tier);let l=Object.entries(o.capability_state??{}).find(([,u])=>u.selected&&u.status!=="healthy");if(l)n.capabilities=Et(["selected_capability_not_healthy"],{capability:l[0],status:l[1].status})}try{let l=await Yt(`${r.codexHome}/agents/root.toml`);if(l!==void 0&&ss(l)){let u=n.native_roles;n.native_roles={status:"failed",reasons:[...u?.reasons??[],"stale_legacy_root"],details:{...u?.details,path:`${r.codexHome}/agents/root.toml`}}}}catch(l){n.native_roles=Et(["native_role_invalid"],{error:Yn(l)})}let s=e.officialPluginManager??await Bo.discover({...t,CODEX_HOME:r.codexHome}).catch(()=>{return});if(o&&s?.status){let l=[...new Set([Vr,...Kc({computer_use:o.optional_selections.computer_use,work:o.optional_selections.work,frontend:o.optional_selections.frontend,security:o.optional_selections.security},o.official_plugins),...o.owned_plugins??[]])];try{let u=await s.status(l),p=Object.entries(u).filter(([,h])=>h!=="installed").map(([h])=>h),f=s.getObservedIdentities?.()??{};n.native_plugins=p.length===0?vl({status:u,observed_identities:f}):Et(["native_plugin_disagreement"],{missing:p,status:u,observed_identities:f})}catch(u){n.native_plugins=Et(["native_plugin_status_failed"],{error:Yn(u)})}}else n.native_plugins={status:"unsupported",reasons:["native_plugin_manager_unavailable"],details:{}};let c=Object.values(n).flatMap((l)=>l.reasons);return{healthy:Object.values(n).every((l)=>l.status!=="failed"),checks:n,reasons:[...new Set(c)]}}async function Ol(e={},t=process.env){let r=ns(e,t);await bl(r.codexHome),await bl(r.stateRoot);let n=await Rl(r),[o,i]=await Promise.all([Gn(r.preparingRecord,jr),Gn(r.conflictedRecord,jr)]),a=i??o??n,s=new Set(Y$(a)),c=[],l=[],u=[];if(n&&!await Rf(n))return l.push(r.activeRecord),u.push("configuration_changed"),{removed:c,preserved:l,reasons:u};let p=await Yt(r.configFile),f=Zn(p),h=a?.managed_config;if(h){let y=await Di(f,h,{schema:h.schema,installId:h.installId});if(y.preservedKeys.length>0||y.unresolvedKeys.length>0)return l.push(r.configFile),u.push("managed_config_changed"),await Br(r,a??cs()),{removed:c,preserved:l,reasons:u}}if(a?.plugin_config){if((await _b(f,a.plugin_config)).preserved.length>0)return l.push(r.configFile),u.push("plugin_config_changed"),await Br(r,a),{removed:c,preserved:l,reasons:u}}if(a?.provider_config){if((await wb(f,a.provider_config,s)).preserved.length>0)return l.push(r.configFile),u.push("provider_config_changed"),await Br(r,a),{removed:c,preserved:l,reasons:u}}let m;try{m=e.officialPluginManager??await Bo.discover({...t,CODEX_HOME:r.codexHome})}catch(y){throw new X("capability_denied","Native Codex plugin removal is unavailable.",y,{recovery:"Install or expose Codex, then retry."})}if(m===void 0||!m.remove||!m.list)throw new X("capability_denied","Native Codex plugin removal and readback are unavailable.");let w=await _f(r.codexHome,a?.managed_artifacts??[]);if(c.push(...w.removed),l.push(...w.preserved),w.preserved.length>0)u.push("managed_artifact_changed");for(let y of s)try{let R=await m.list(),P=fn(R,y),z=P?.entry.installed?P.entry.pluginId:y;await m.remove(z);let Y=await m.list();if(fn(Y,y)?.entry?.installed===!0||[...Y.installed,...Y.available].some((F)=>F.pluginId===y&&F.installed))throw new X("capability_denied",`Codex still reports ${y} after removal.`);c.push(y)}catch(R){throw u.push("native_plugin_remove_failed"),await Br(r,a??cs()),new X("capability_denied",`Codex native plugin removal did not converge for ${y}: ${Yn(R)}`,R)}if(w.preserved.length>0)return await Br(r,a??cs()),{removed:c,preserved:l,reasons:u};let S;try{let y=f,R=h;if(R){let P=await Di(y,R,{schema:R.schema,installId:R.installId});if(P.preservedKeys.length>0||P.unresolvedKeys.length>0)return l.push(r.configFile),u.push("managed_config_changed"),await Br(r,a??cs()),{removed:c,preserved:l,reasons:u};y=P.document,R=P.state}if(a?.plugin_config){let P=await _b(y,a.plugin_config,{allowBeforeState:!0});if(P.preserved.length>0)return l.push(r.configFile),u.push("plugin_config_changed"),await Br(r,a),{removed:c,preserved:l,reasons:u};y=P.document}if(a?.provider_config){let P=await wb(y,a.provider_config,s,{allowBeforeState:!0});if(P.preserved.length>0)return l.push(r.configFile),u.push("provider_config_changed"),await Br(r,a),{removed:c,preserved:l,reasons:u};y=P.document}if(a?.managed_config||a?.plugin_config||a?.provider_config)S=R===void 0?{document:y}:{document:y,state:R};if(S!==void 0)if(Object.keys(S.document).length===0&&p===void 0)await bb(r.configFile,{force:!1});else await Jn(r.configFile,Eb(S.document))}catch(y){if(y instanceof X)throw await Br(r,a??cs()),y;return l.push(r.configFile),u.push("managed_config_write_failed"),await Br(r,a??cs()),{removed:c,preserved:l,reasons:u}}if(n)try{await bb(r.activeRecord,{force:!1}),c.push(r.activeRecord)}catch(y){if(gt(y,"ENOENT"))c.push(r.activeRecord);else return l.push(r.activeRecord),u.push("state_remove_failed"),await Br(r,a??n),{removed:c,preserved:l,reasons:u}}if(l.length===0)for(let[y,R]of[[r.preparingRecord,o!==void 0],[r.conflictedRecord,i!==void 0]]){if(!R)continue;try{await Z$(y),c.push(y)}catch{l.push(y),u.push("state_remove_failed")}}if(l.length===0)try{await dI(r.roleRoot),c.push(r.roleRoot)}catch(y){if(!gt(y,"ENOENT"))l.push(r.roleRoot),u.push("role_directory_not_empty")}if(l.length===0)try{await dI(r.stateRoot),c.push(r.stateRoot)}catch(y){if(gt(y,"ENOENT"))c.push(r.stateRoot);else l.push(r.stateRoot),u.push("state_directory_not_empty")}return{removed:c,preserved:l,reasons:u}}async function J$(e,t){if(!t.managed_config)return Et(["incomplete_install_state"]);try{let r=Zn(await Yt(e.configFile)),n=Of(t.profile,t.tier,t.optional_selections.computer_use),o=[];for(let[i,a]of Object.entries(n))if((await Ya(r,t.managed_config,i)).status!=="unchanged"||i!=="developer_instructions"&&Pe(r,i)!==a)o.push(i);return o.length===0?vl({managed_keys:Object.keys(n).length}):Et(["changed_holycodex_config"],{keys:o})}catch(r){return Et(["config_unreadable"],{error:Yn(r)})}}async function G$(e,t,r){try{let n=Zn(await Yt(e.configFile)),o=[];for(let a of ji(t,r)){let s=Pe(n,`agents."${a.name}".config_file`),c=`${e.roleRoot}/${a.name}.toml`.replaceAll("\\","/");if(typeof s!=="string"||al(e.configFile,s).replaceAll("\\","/")!==c){o.push(`${a.name}:registration`);continue}let l=await Yt(`${e.roleRoot}/${a.name}.toml`);if(l===void 0){o.push(`${a.name}:missing`);continue}if(l!==wf(a)){o.push(`${a.name}:changed`);continue}let u=Zn(l);if(u.name!==a.name||typeof u.description!=="string"||typeof u.developer_instructions!=="string"||u.model!=="gpt-5.6-luna"||u.model_reasoning_summary!=="none"||u.model_verbosity!=="low"||u.tool_output_token_limit!==void 0||u.service_tier!==(r==="standard"?"default":"fast")||u.sandbox_mode!==(a.permissions.write?"workspace-write":"read-only")||u.approval_policy!=="never"||u.web_search!==(a.permissions.network?"live":"disabled")||Pe(u,"agents.enabled")!==!1||Pe(u,"features.multi_agent_v2")!==!1||Pe(u,"features.multi_agent")!==!1||Pe(u,"features.computer_use")!==!1||Pe(u,"features.browser_use")!==!1||Pe(u,"features.in_app_browser")!==!1)o.push(`${a.name}:malformed`)}let i=await Yt(`${e.codexHome}/agents/root.toml`);if(i!==void 0&&ss(i))o.push("root:stale");return o.length===0?vl({role_root:e.roleRoot,agent_types:ji(t,r).map((a)=>a.name)}):Et(["native_role_disagreement"],{roles:o})}catch(n){return Et(["native_role_invalid"],{error:Yn(n)})}}async function Br(e,t){let r={...t,status:"conflicted",step:"conflicted",managed_config:t.managed_config??{owner:"holycodex",schema:t.schema_epoch,installId:t.install_id,managed:{}},plugin_snapshot:t.plugin_snapshot??[],owned_plugins:t.owned_plugins??[]};if(ht(jr,r)!==void 0)await jo(e.conflictedRecord,sr(r))}function cs(){return{owner:"holycodex",schema_epoch:"state-0.16",install_id:"remove-conflict",version:"0.0.0",digest:"0".repeat(64),profile:"default",tier:"standard",optional_selections:{computer_use:!1,work:!1,frontend:!1,security:!1,coding:!0},explicit_optional_selections:{},managed_artifacts:[],installed_at:new Date(0).toISOString()}}function Y$(e){if(e?.owned_plugins!==void 0)return[...new Set(e.owned_plugins)];let t=(e?.plugin_snapshot??[]).filter((r)=>r.plugin_id!==Vr&&r.status!=="installed").map((r)=>r.plugin_id);return[...new Set([Vr,...t])]}function vl(e){return{status:"healthy",reasons:[],details:e}}function Et(e,t={}){return{status:"failed",reasons:e,details:t}}async function Z$(e){await bb(e,{force:!1}).catch((t)=>{if(!gt(t,"ENOENT"))throw t})}function Yn(e){return e instanceof Error?e.message.slice(0,256):"operation failed"}var vf=x(()=>{gl();pt();kl();yl();Tf();El();Hi();rs();is()});import{rm as bI}from"fs/promises";import{join as X$}from"path";function Xn(e){let t=ht(ff,e);if(t===void 0)throw new X("install_failed","The installation options are invalid.");return t}async function kf(e={},t={},r=process.env){if(ht(xl,e)===void 0)throw new X("install_failed","The installation options are invalid.");let n=ns(t,r);await Sl(n.stateRoot);let o=await Gn(n.preparingRecord,jr),a=await Gn(n.conflictedRecord,jr)??o;if(a!==void 0){await Promise.resolve().then(() => vf());let De=await Ol(t,r);if(De.preserved.length>0||De.reasons.length>0)throw new X("state_corrupt","The interrupted HolyCodex installation could not be reconciled safely.",void 0,{preserved:De.preserved.join(","),reasons:De.reasons.join(",")});return await kf({profile:e.profile??a.profile,tier:e.tier??a.tier,optional:{computer_use:e.optional?.computer_use??a.optional_selections.computer_use,work:e.optional?.work??a.optional_selections.work,frontend:e.optional?.frontend??a.optional_selections.frontend,security:e.optional?.security??a.optional_selections.security},officialPlugins:e.officialPlugins??gI(a)},t,r)}let s=await Rl(n);if(s!==void 0&&!await Rf(s))throw new X("state_corrupt","The existing HolyCodex configuration has changed and cannot be replaced.",void 0,{path:n.activeRecord});let c=fj(e.profile,s?.profile),l=mj(e.tier,s?.tier),u=hj(e.optional,s?.optional_selections),p=uj(s?.explicit_optional_selections,e.optional),f=e.officialPlugins??gI(s),h=[...new Set(Kc(TI(u),f).map((se)=>Ur(se)??se))],m;try{m=t.officialPluginManager??await Bo.discover({...r,CODEX_HOME:n.codexHome})}catch(se){throw new X("capability_denied","Native Codex plugin installation is unavailable.",se,{recovery:"Install or expose Codex, then retry."})}if(!m.addMarketplace||!m.add||!m.list)throw new X("install_failed","Native Codex plugin installation and verification are unavailable.");let w;try{w=await m.list()}catch(se){throw new X("capability_denied","Native Codex plugin state could not be read safely.",se)}let S=h.filter((se)=>{if(Ur(se)!==se)return!1;let De=Pl(w,se);return!(De?.installed&&De.enabled)});if(m.ensureOfficialMarketplace!==void 0&&S.length>0)try{await m.ensureOfficialMarketplace(S)}catch(se){throw new X("capability_denied",`The selected official Codex provider marketplace is unavailable: ${SI(se)}`,se,{recovery:"Check Codex network and marketplace policy, then retry."})}let y=s?.install_id??crypto.randomUUID().replaceAll("-",""),R=await hf(),P=(t.now?.()??new Date).toISOString(),z=await Yt(n.configFile),Y=Zn(z),D=s?.plugin_config?.before??await mI(Y),te=[...new Set([...h,...(s?.provider_config??[]).map((se)=>se.plugin_id),...s?.owned_plugins??[]])].filter((se)=>se!==Vr),ie=(await hI(Y,te)).map((se)=>{let De=s?.provider_config?.find((Zt)=>Zt.plugin_id===se.plugin_id);return De===void 0?se:{plugin_id:se.plugin_id,before:De.before,after:De.before}}),ae=s?.managed_config??Jd({schema:Tr,installId:y}),ee=await oj(Y,ae,s),{document:Oe,state:yt}=ee;ij(Oe,yt);let vt=Of(c,l,u.computer_use),Ot=await sl(Oe,yt,vt,{schema:Tr,installId:y});if(Ot.driftedKeys.length>0)throw new X("state_corrupt","HolyCodex-owned Codex settings changed and cannot be replaced safely.",void 0,{keys:Ot.driftedKeys.join(",")});let $e;try{$e=await aj({list:()=>m.list()},[...new Set([Vr,...h,...s?.owned_plugins??[]])])}catch(se){throw new X("capability_denied","Native Codex plugin state could not be read safely.",se)}let We={owner:"holycodex",schema_epoch:Tr,install_id:y,version:R,digest:s?.digest??"0".repeat(64),profile:c,tier:l,optional_selections:u,explicit_optional_selections:p,official_plugins:h,capability_state:xI(u),managed_artifacts:s?.managed_artifacts??[],installed_at:P,status:"preparing",step:"validated",managed_config:Ot.state,plugin_snapshot:$e,plugin_config:{plugin_id:Vr,before:D,after:D},provider_config:ie,owned_plugins:[...new Set(s?.owned_plugins??[])]};await Cl(n.preparingRecord,We);let je,yn=!1,zi=new Set,lr=new Set(s?.owned_plugins??[]),If=new Set,Lt=We,Mb=!1,Nb=!1,Mf=z,us=Ot.state;try{await Sl(n.roleRoot),je=await gb(n.codexHome,c,s?.managed_artifacts,l),Lt={...We,step:"roles_prepared",managed_artifacts:je.managed_artifacts},await Cl(n.preparingRecord,Lt),Mb=!0,await m.addMarketplace(Q$),await dj({list:()=>m.list(),add:(wr)=>m.add(wr)},[Vr,...h],(wr,Df)=>{if(Df==="new")zi.add(wr),lr.add(wr),Lt={...Lt,owned_plugins:[...lr]};else If.add(wr),lr.add(wr),Lt={...Lt,owned_plugins:[...lr]}}),Lt={...Lt,step:"plugins_installed"},await Cl(n.preparingRecord,Lt);let De=await Yt(n.configFile);Mf=De;let Zt=Zn(De),Nf=await mI(Zt),Ff=(await hI(Zt,te)).map((wr)=>({plugin_id:wr.plugin_id,before:ie.find((Df)=>Df.plugin_id===wr.plugin_id)?.before??wr.before,after:wr.before}));await nj(Zt,Oe,yt,vt);let Ll=await sl(Zt,yt,vt,{schema:Tr,installId:y});if(Ll.driftedKeys.length>0)throw new X("state_corrupt","HolyCodex-owned Codex settings changed during native plugin setup.",void 0,{keys:Ll.driftedKeys.join(",")});Nb=!0,us=Ll.state,Lt={...Lt,managed_config:us,plugin_config:{plugin_id:Vr,before:D,after:Nf},provider_config:Ff},await Jn(n.configFile,Eb(Ll.document)),yn=!0,Lt={...Lt,step:"config_published"},await Cl(n.preparingRecord,Lt),await cj(n,c,l,u.computer_use,us,je.preserved);let Fb=xI(u),UI=await Af({owner:"holycodex",install_id:y,version:R,profile:c,tier:l,optional_selections:u,explicit_optional_selections:p,official_plugins:h,capability_state:Fb,managed_artifacts:je.managed_artifacts,managed_config:us,plugin_config:{plugin_id:Vr,before:D,after:Nf},provider_config:Ff,plugin_snapshot:$e,owned_plugins:[...lr]}),Lf={owner:"holycodex",schema_epoch:Tr,install_id:y,version:R,digest:UI,profile:c,tier:l,optional_selections:u,explicit_optional_selections:p,official_plugins:h,capability_state:Fb,managed_artifacts:je.managed_artifacts,installed_at:P,status:"active",step:"active",managed_config:us,plugin_snapshot:$e,plugin_config:{plugin_id:Vr,before:D,after:Nf},provider_config:Ff,owned_plugins:[...lr]};if(ht(ts,Lf)===void 0)throw new X("state_corrupt","The HolyCodex configuration is invalid.");return await jo(n.activeRecord,sr(Lf)),await vb(n.preparingRecord),await vb(n.conflictedRecord),{record:Lf,optional_plugins:h,preserved:je.preserved,warnings:je.preserved.length===0?[]:["modified managed files were preserved"]}}catch(se){let De=[];if(yn)try{await sj(n.configFile,Mf)}catch{De.push("config")}if(Mb&&!Nb){if(await Yt(n.configFile).catch(()=>{return})!==Mf)De.push("config")}if(je!==void 0)try{if((await bf(je.rollback)).preserved.length>0)De.push("roles")}catch{De.push("roles")}if(If.size>0)De.push(...[...If].map((Zt)=>`plugin:${Zt}`));for(let Zt of zi)try{await m.remove?.(Zt)}catch{De.push(`plugin:${Zt}`)}if(De.length>0)await Cl(n.conflictedRecord,{...Lt,step:"conflicted",status:"conflicted"}).catch(()=>{return});else await vb(n.preparingRecord).catch(()=>{return});if(se instanceof _r)throw se;if(se instanceof X)throw se;throw new X(se instanceof hn||se instanceof Al?"capability_denied":"install_failed",SI(se),se,De.length>0?{recovery:"Resolve conflicted state before retrying."}:{})}}async function Rl(e){let t=await Gn(e.activeRecord,pf);if(t===void 0)return;let r=ht(ts,t);if(r!==void 0)return r;let n=ht(KP,t);if(n===void 0)throw new X("state_corrupt","The HolyCodex configuration is invalid.");if(!await OI(n))throw new X("state_corrupt","The existing HolyCodex configuration has an invalid digest.",void 0,{path:e.activeRecord});let o="profile"in n&&n.profile!==void 0?n.profile:("plan"in n)?n.plan:void 0;if(o===void 0)throw new X("state_corrupt","The persisted installation has neither profile nor legacy plan state.",void 0,{path:e.activeRecord});let i;try{i=Mx(o)}catch(c){throw new X("state_corrupt",`The persisted profile ${o} was removed and requires an explicit replacement.`,c,{path:e.activeRecord,profile:o})}let s={..."plan"in n?Object.fromEntries(Object.entries(n).filter(([c])=>c!=="plan")):n,profile:i,digest:await Af({owner:n.owner,install_id:n.install_id,version:n.version,profile:i,tier:n.tier,optional_selections:n.optional_selections,explicit_optional_selections:n.explicit_optional_selections,official_plugins:n.official_plugins??[],capability_state:n.capability_state??null,managed_artifacts:n.managed_artifacts,...n.managed_config===void 0?{}:{managed_config:n.managed_config},...n.plugin_config===void 0?{}:{plugin_config:n.plugin_config},...n.provider_config===void 0?{}:{provider_config:n.provider_config},...n.plugin_snapshot===void 0?{}:{plugin_snapshot:n.plugin_snapshot},...n.owned_plugins===void 0?{}:{owned_plugins:n.owned_plugins}})};return await jo(e.activeRecord,sr(s)),s}function TI(e){return{computer_use:e.computer_use,work:e.work,frontend:e.frontend,security:e.security}}function Zn(e){if(e===void 0||e.trim().length===0)return{};try{let t=globalThis.Bun,r=t?.TOML?.parse?t.TOML.parse(e):aI(e),n=ht(ol,r);if(n===void 0)throw Error("TOML document contains unsupported values.");return n}catch(t){throw new X("state_corrupt","The Codex config.toml is not valid TOML.",t)}}function Eb(e){try{let t=globalThis.Bun;return`${((t?.TOML?.stringify)?t.TOML.stringify(e):sI(e)).trimEnd()}
|
|
42
|
+
`}catch(t){throw new X("install_failed","The merged Codex configuration is not writable.",t)}}async function mI(e){return{preference:await Il(e,"plugins",_I),marketplace:await Il(e,"marketplaces",wI)}}async function hI(e,t){return await Promise.all(t.map(async(r)=>{let n=await Il(e,"plugins",r),o={presence:n.presence,digest:n.digest,...n.safe_value?.kind==="boolean"?{safe_value:n.safe_value}:{}};return{plugin_id:r,before:o,after:o}}))}async function _b(e,t,r={}){let n=e,o=[],i=[],a=[];for(let[s,c,l]of[["preference","plugins",_I],["marketplace","marketplaces",wI]]){let u=t.before[s],p=t.after[s],f=await Il(e,c,l);if(r.allowBeforeState===!0&&f.digest===u.digest)continue;if(f.digest!==p.digest){a.push(s);continue}if(u.presence==="absent"){if(f.presence==="present")n=vI(n,c,l),i.push(s);continue}if(u.safe_value===void 0){a.push(s);continue}n=EI(n,c,l,rj(u.safe_value)),o.push(s)}return{document:n,restored:o,removed:i,preserved:a}}async function wb(e,t,r,n={}){let o=e,i=[],a=[],s=[];for(let c of t){if(!r.has(c.plugin_id))continue;let{before:l,after:u}=c,p=await Il(e,"plugins",c.plugin_id);if(n.allowBeforeState===!0&&p.digest===l.digest)continue;if(p.digest!==u.digest){s.push(c.plugin_id);continue}if(l.presence==="absent"){if(p.presence==="present")o=vI(o,"plugins",c.plugin_id),a.push(c.plugin_id);continue}if(l.safe_value===void 0){s.push(c.plugin_id);continue}o=EI(o,"plugins",c.plugin_id,{enabled:l.safe_value.value}),i.push(c.plugin_id)}return{document:o,restored:i,removed:a,preserved:s}}async function Il(e,t,r){let n=ej(e,t,r),o=await Kn("holycodex-plugin-config",[zn(sr({key:`${t}.${r}`,value:n===void 0?{presence:"absent"}:n}))]),i=tj(t,n);return{presence:n===void 0?"absent":"present",digest:o,...i===void 0?{}:{safe_value:i}}}function ej(e,t,r){let n=e[t];if(!Cf(n))return;return n[r]}function tj(e,t){if(!Cf(t))return;let r=Object.keys(t);if(e==="plugins"){if(r.length!==1||r[0]!=="enabled"||typeof t.enabled!=="boolean")return;return{kind:"boolean",value:t.enabled}}if(r.length!==2||!r.includes("source_type")||!r.includes("source")||t.source_type!=="git"||t.source!==fI)return;return{kind:"marketplace",source_type:"git",source:fI}}function rj(e){if(e.kind==="boolean")return{enabled:e.value};return{source_type:e.source_type,source:e.source}}function EI(e,t,r,n){let o={...e},i=o[t];if(i!==void 0&&!Cf(i))throw new X("state_corrupt",`The ${t} Codex config table is invalid.`);return o[t]={...i,[r]:n},o}function vI(e,t,r){let n=e[t];if(!Cf(n)||!Object.prototype.hasOwnProperty.call(n,r))return e;let o={...e},i={...n};if(delete i[r],Object.keys(i).length===0)delete o[t];else o[t]=i;return o}function Cf(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Of(e,t,r=!1){let n=mb(e,t),o={model:n.model,model_reasoning_effort:n.effort,service_tier:n.serviceTier,model_verbosity:"low",developer_instructions:hb(r),suppress_unstable_features_warning:!0,"features.default_mode_request_user_input":!0,"features.multi_agent_v2":!0,"features.context_management.experimental_mode":!0};for(let i of Ka)o[`agents."${i}".config_file`]=`holycodex/agents/${i}.toml`;return o}async function nj(e,t,r,n){let o=[];for(let i of Object.keys(n)){let a=i;if(r.managed[a]!==void 0){if((await Ya(e,r,a)).status==="drifted")o.push(a);continue}let c=Pe(t,a),l=Pe(e,a);if(c!==l)o.push(a)}if(o.length>0)throw new X("state_corrupt","Codex settings changed during native plugin setup.",void 0,{keys:o.join(",")})}async function oj(e,t,r){let n=["agents.explorer.config_file","agents.librarian.config_file","agents.worker.config_file","agents.reviewer.config_file"],o=Object.fromEntries(n.flatMap((c)=>{let l=t.managed[c];return l===void 0?[]:[[c,l]]})),i=e,a=t;if(Object.keys(o).length>0){let c=await Di(e,{...t,managed:o},{schema:t.schema,installId:t.installId});if(c.preservedKeys.length>0||c.unresolvedKeys.length>0)throw new X("state_corrupt","Legacy HolyCodex agent registrations changed and cannot be migrated safely.",void 0,{keys:[...new Set([...c.preservedKeys,...c.unresolvedKeys])].join(",")});i=c.document,a={...t,managed:Object.fromEntries(Object.entries(t.managed).filter(([l])=>!n.includes(l)))}}if(!r)return{document:i,state:a};let s=r.managed_artifacts.map((c)=>c.path);for(let c of["explorer","librarian","worker","reviewer"]){if(!s.some((h)=>h.startsWith(`agents/${c[0]?.toUpperCase()}${c.slice(1)}.`)||h===`holycodex/agents/${c}.toml`))continue;let u=`agents.${c}.config_file`,p=Pe(i,u);if(typeof p!=="string")continue;let f=p.replaceAll("\\","/").replace(/^\.\//u,"");if(f===`agents/${c}.toml`||f===`holycodex/agents/${c}.toml`)i=zd(i,u)}return{document:i,state:a}}function ij(e,t){if(Pe(e,"developer_instructions")!==void 0&&t.managed.developer_instructions===void 0)throw new X("state_corrupt","Existing developer_instructions cannot be displaced safely; remove it or converge managed state first.")}async function aj(e,t){let r=await e.list();return t.map((n)=>{let o=Pl(r,n),i=o===void 0?"missing":o.installed&&o.enabled?"installed":o.installed?"disabled":"available";return{plugin_id:n,status:i}})}async function Cl(e,t){if(ht(jr,t)===void 0)throw new X("state_corrupt","The HolyCodex transaction state is invalid.");await jo(e,sr(t))}async function vb(e){await bI(e,{force:!1}).catch((t)=>{if(!gt(t,"ENOENT"))throw t})}async function sj(e,t){if(t===void 0){await bI(e,{force:!1}).catch((r)=>{if(!gt(r,"ENOENT"))throw r});return}await Jn(e,t)}async function cj(e,t,r,n,o,i=[]){let a=await Yt(e.configFile),s=Zn(a),c=Of(t,r,n);for(let[p,f]of Object.entries(c)){let h=Pe(s,p);if(p==="developer_instructions"){if(typeof h!=="string"||await lj(p,h)!==o.managed[p]?.lastManagedValue.value)throw new X("install_failed","The effective Root instructions did not converge.")}else if(h!==f)throw new X("install_failed",`The effective Codex setting ${p} did not converge.`)}let l=ji(t,r);for(let p of l){let f=`agents."${p.name}".config_file`,h=Pe(s,f);if(typeof h!=="string")throw new X("install_failed",`The ${p.name} registration is missing.`);let m=X$(e.roleRoot,`${p.name}.toml`),w=m.replaceAll("\\","/");if(al(e.configFile,h).replaceAll("\\","/")!==w)throw new X("install_failed",`The ${p.name} registration is stale.`);let y=await Yt(m);if(y===void 0)throw new X("install_failed",`The ${p.name} role file is missing.`);if(i.includes(m))continue;let R=Zn(y);if(R.name!==p.name||typeof R.description!=="string"||typeof R.model!=="string"||typeof R.model_reasoning_effort!=="string"||typeof R.service_tier!=="string"||typeof R.developer_instructions!=="string"||R.sandbox_mode!==(p.permissions.write?"workspace-write":"read-only")||R.approval_policy!=="never"||R.web_search!==(p.permissions.network?"live":"disabled")||R.tool_output_token_limit!==void 0||Pe(R,"agents.enabled")!==!1||Pe(R,"features.multi_agent_v2")!==!1||Pe(R,"features.multi_agent")!==!1||Pe(R,"features.computer_use")!==!1||Pe(R,"features.browser_use")!==!1||Pe(R,"features.in_app_browser")!==!1)throw new X("install_failed",`The ${p.name} role file is malformed.`)}let u=await Yt(`${e.codexHome}/agents/root.toml`);if(u!==void 0&&ss(u))throw new X("install_failed","A stale HolyCodex Root role remains installed.")}async function lj(e,t){return await Kn("holycodex-managed-config-value",[zn({keyPath:e,value:t})])}function uj(e,t){let r={};for(let n of["computer_use","work","frontend","security"]){let o=t?.[n]??e?.[n];if(o!==void 0)r[n]=o}return r}function pj(e){return["computer_use","work","frontend","security"].find((t)=>zc[t].pluginIds.includes(e))}function gI(e){return(e?.official_plugins??[]).filter((t)=>{let r=pj(t);return r===void 0||e?.optional_selections[r]!==!0})}async function dj(e,t,r){for(let n of t){let o;try{o=Pl(await e.list(),n)}catch(s){throw Ob("list",s,n)}if(o?.installed&&!o.enabled)throw new Al("uncertain",`${n} is disabled`);let i=!(o?.installed&&o.enabled);if(!(o?.installed&&o.enabled))try{await e.add(n)}catch(s){try{let c=Pl(await e.list(),n);if(!yI(o,c))r?.(n,"uncertain")}catch{r?.(n,"uncertain")}throw Ob("add",s,n)}let a;try{a=Pl(await e.list(),n)}catch(s){if(i)r?.(n,"uncertain");throw Ob("list",s,n)}if(!a?.installed){if(i&&!yI(o,a))r?.(n,"uncertain");throw new Al("missing",`${n} is not installed after add`)}if(i&&a.enabled)r?.(n,"new");if(!a.enabled){if(i)r?.(n,"new");throw new Al("uncertain",`${n} is disabled after add`)}}}function yI(e,t){return e?.pluginId===t?.pluginId&&e?.installed===t?.installed&&e?.enabled===t?.enabled&&e?.marketplaceName===t?.marketplaceName}function Ob(e,t,r){if(t instanceof hn)return t;return new hn(e==="list"?"list_failed":"add_failed",e==="list"?`Codex could not read the status of ${r}.`:`Codex could not add ${r}.`,t,{plugin_id:r})}function Pl(e,t){let r=fn(e,t);if(r!==void 0)return r.entry;let n=Ur(t);return[...e.installed,...e.available].find((o)=>o.pluginId===t&&(n===void 0||o.marketplaceName==null))}function fj(e,t){let r=e??t??"default";if(!ln(r).ok)throw new X("install_failed","Unknown profile.");return r}function mj(e,t){let r=e??t??"standard";if(ht(Mi,r)===void 0)throw new X("install_failed","The tier is not supported.");return r}function hj(e,t){let r=t?TI(t):an,n=Cx(e,r);return{computer_use:n.computer_use,work:n.work,frontend:n.frontend,security:n.security,coding:!0}}function xI(e,t=new Map){return Object.fromEntries(["computer_use","work","frontend","security"].map((n)=>{let o=e[n],i={selected:o,status:o?t.get(n)??"healthy":"disabled",plugin_ids:[...zc[n].pluginIds]};return[n,i]}))}async function Af(e){let{profile:t,plan:r,...n}=e,o=r===void 0?{...n,profile:t}:{...n,plan:r};return await Kn("install-record",[zn(sr(o))])}async function Rf(e){return await OI(e)}async function OI(e){return await Af({owner:e.owner,install_id:e.install_id,version:e.version,...e.profile===void 0?{}:{profile:e.profile},...e.plan===void 0?{}:{plan:e.plan},tier:e.tier,optional_selections:e.optional_selections,explicit_optional_selections:e.explicit_optional_selections,official_plugins:e.official_plugins??[],capability_state:e.capability_state??null,managed_artifacts:e.managed_artifacts,...e.managed_config===void 0?{}:{managed_config:e.managed_config},...e.plugin_config===void 0?{}:{plugin_config:e.plugin_config},...e.provider_config===void 0?{}:{provider_config:e.provider_config},...e.plugin_snapshot===void 0?{}:{plugin_snapshot:e.plugin_snapshot},...e.owned_plugins===void 0?{}:{owned_plugins:e.owned_plugins}})===e.digest}function SI(e){return e instanceof Error?e.message.slice(0,256):"operation failed"}var Q$="davidbasilefilho/holycodex",Vr="holycodex@holycodex",fI="https://github.com/davidbasilefilho/holycodex.git",_I="holycodex@holycodex",wI="holycodex",Al,X;var kl=x(()=>{gl();pt();yl();gf();Tf();El();Hi();rs();is();rs();Al=class Al extends Error{status;constructor(e,t){super(t);this.name="PluginVerificationError",this.status=e}};X=class X extends Error{code;causeValue;details;constructor(e,t,r,n={}){super(t);this.name="InstallerError",this.code=e,this.causeValue=r,this.details=n}}});import{createInterface as Vj}from"readline/promises";pt();pt();pt();var Xx=Object.freeze([{name:"yes",kind:"boolean",usage:"--yes",description:"Confirm installation."},{name:"profile",kind:"value",usage:"--profile <low|default|high>",description:"Select routing (default: default)."},{name:"tier",kind:"value",usage:"--tier <standard|fast|fast-all>",description:"Select service handling (default: standard)."},{name:"work",kind:"boolean",usage:"--work / --no-work",description:"Work plugins (default: false)."},{name:"frontend",kind:"boolean",usage:"--frontend / --no-frontend",description:"Frontend plugins via build-web-apps (default: true)."},{name:"security",kind:"boolean",usage:"--security / --no-security",description:"Security plugins (default: true)."},{name:"computer-use",kind:"boolean",usage:"--computer-use / --no-computer-use",description:"Computer Use plugins (default: false)."},{name:"add-plugin",kind:"value",usage:"--add-plugin <id>",description:"Add a Codex plugin; repeatable."},{name:"json",kind:"boolean",usage:"--json",description:"Emit one JSON envelope."}]),sP=new Set(["codex-home","profile","tier","add-plugin"]),WU=new Set(["yes","json","verbose","dry-run","computer-use","no-computer-use","work","no-work","frontend","no-frontend","security","no-security"]);class Ke extends Error{code;details;constructor(e,t,r={}){super(t);this.name="ArgumentError",this.code=e,this.details=r}}function Ud(e){if(e.length===0)throw new Ke("unknown_command","A command is required.");if(e.includes("-h")||e.includes("--help")||e.includes("--help=true"))return{command:"help",positionals:[],options:{}};if(e[0]==="help")return{command:"help",positionals:e.slice(1),options:{}};if(e[0]==="-v"||e[0]==="--version"||e[0]==="--version=true")return Ud(["version",...e.slice(1)]);let t=e[0];if(t!=="install"&&t!=="doctor"&&t!=="remove"&&t!=="version")throw new Ke("unknown_command","Unknown command.",{command:t??""});let r=[],n={};for(let o=1;o<e.length;o+=1){let i=e[o];if(i===void 0)continue;if(i==="-"||!i.startsWith("-")){r.push(i);continue}if(!i.startsWith("--")||i==="--")throw new Ke("invalid_argument","Short options are not supported.",{option:i});let a=i.slice(2),s=a.indexOf("="),c=s>=0?a.slice(0,s):a,l=s>=0?a.slice(s+1):void 0,u=c.replaceAll("_","-");if(u==="plan")throw new Ke("invalid_argument","The --plan option was removed; use --profile <low|default|high>.",{option:"--plan",replacement:"--profile"});if(!sP.has(u)&&!WU.has(u))throw new Ke("invalid_argument","Unknown option.",{option:`--${c}`});if(sP.has(u)){let p=l??e[o+1];if(p===void 0||p.length===0||p.startsWith("-"))throw new Ke("invalid_argument",`Option --${c} requires a value.`,{option:`--${c}`});if(l===void 0)o+=1;if(u==="add-plugin"){let f=n[u];n[u]=Array.isArray(f)?[...f,p]:[p]}else{if(n[u]!==void 0)throw new Ke("invalid_argument",`Option --${c} may only be supplied once.`,{option:`--${c}`});n[u]=p}continue}if(l!==void 0&&l!=="true"&&l!=="false")throw new Ke("invalid_argument",`Option --${c} is boolean.`,{option:`--${c}`});if(n[u]!==void 0)throw new Ke("invalid_argument",`Option --${c} may only be supplied once.`,{option:`--${c}`});n[u]=l==="false"?!1:!0}return JU(t,r,n),{command:t,positionals:r,options:n}}function JU(e,t,r){let n=YU(e);for(let s of Object.keys(r))if(!n.has(s))throw new Ke("invalid_argument",`Option --${s} is not valid for ${e}.`,{option:`--${s}`});let o=e==="version"?{min:0,max:1}:{min:0,max:0};if(t.length<o.min||t.length>o.max)throw new Ke("invalid_argument",`Invalid positional arguments for ${e}.`);let i=r.profile;if(typeof i==="string"&&!ln(i).ok){let s=GU[i];if(s!==void 0)throw new Ke("invalid_argument",`Legacy profile ${i} was removed; use --profile ${s}.`,{profile:i,replacement:s});if(i==="go"||i==="Go"||i==="pro-5x"||i==="pro-20x")throw new Ke("invalid_argument",`Legacy profile ${i} was removed and requires an explicit replacement using --profile <low|default|high>.`,{profile:i});throw new Ke("invalid_argument","The profile is not supported.",{profile:i})}let a=r.tier;if(typeof a==="string"&&a!=="standard"&&a!=="fast"&&a!=="fast-all")throw new Ke("invalid_argument","The tier is not supported.",{tier:a});for(let[s,c]of[["computer-use","no-computer-use"],["work","no-work"],["frontend","no-frontend"],["security","no-security"]])if(r[s]!==void 0&&r[c]!==void 0)throw new Ke("invalid_argument",`Conflicting --${s} and --${c} options.`);if(e==="install"&&r.yes===!1)throw new Ke("invalid_argument","--yes cannot be false.");if(e!=="install"&&Object.keys(r).some((s)=>["profile","tier","work","no-work","frontend","no-frontend","security","no-security","computer-use","no-computer-use","add-plugin"].includes(s)))throw new Ke("invalid_argument",`Installation options are not valid for ${e}.`)}var GU={"plus-low":"low",plus:"default","plus-high":"high"};function YU(e){switch(e){case"install":return new Set([...Xx.map((t)=>t.name),"no-work","no-frontend","no-security","no-computer-use","codex-home","verbose"]);case"doctor":return new Set(["json","verbose","codex-home"]);case"remove":return new Set(["yes","json","verbose","codex-home"]);case"version":return new Set(["json","verbose","dry-run"]);default:return new Set}}var ZU=`HolyCodex
|
|
22
43
|
|
|
23
44
|
Usage:
|
|
24
45
|
holycodex install [options]
|
|
46
|
+
holycodex remove [options]
|
|
47
|
+
holycodex doctor [options]
|
|
48
|
+
holycodex version [<0.x.y|patch|minor>] [options]
|
|
25
49
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
Options:
|
|
51
|
+
--help, -h Show this help.
|
|
52
|
+
--version, -v Print the canonical version.
|
|
53
|
+
--json Emit one validated JSON envelope.
|
|
54
|
+
|
|
55
|
+
Use --json for scripts. Install and remove use native Codex plugin management.
|
|
56
|
+
`,XU=`Install HolyCodex through Codex native plugin management.
|
|
57
|
+
|
|
58
|
+
Usage:
|
|
59
|
+
holycodex install [options]
|
|
60
|
+
|
|
61
|
+
Profiles control routing only:
|
|
62
|
+
low Root gpt-6-astra/low; specialists use the low Luna matrix.
|
|
63
|
+
default Root gpt-6-astra/medium; recommended default routing.
|
|
64
|
+
high Root gpt-6-astra/high; specialists use the high Luna matrix.
|
|
65
|
+
Default profile: default.
|
|
33
66
|
|
|
34
67
|
Tier is independent service handling (CLI values are lowercase only):
|
|
35
68
|
standard Standard service handling (default).
|
|
@@ -37,7 +70,7 @@ Tier is independent service handling (CLI values are lowercase only):
|
|
|
37
70
|
fast-all Fast service handling for Root and leaves.
|
|
38
71
|
|
|
39
72
|
Options:
|
|
40
|
-
${
|
|
73
|
+
${Xx.map((e)=>` ${e.usage.padEnd(48)} ${e.description}`).join(`
|
|
41
74
|
`)}
|
|
42
75
|
--no-work / --no-frontend / --no-security /
|
|
43
76
|
--no-computer-use Disable the corresponding plugin.
|
|
@@ -45,48 +78,45 @@ ${dI.map(e=>` ${e.usage.padEnd(48)} ${e.description}`).join(`
|
|
|
45
78
|
|
|
46
79
|
Capability defaults: Work false, Frontend true (mapped to build-web-apps),
|
|
47
80
|
Security true, and Computer Use false. --add-plugin may be repeated.
|
|
48
|
-
|
|
81
|
+
On an interactive TTY, install opens one wizard and final review with Install,
|
|
82
|
+
Change options / Redo, and Cancel. The wizard never asks for CODEX_HOME.
|
|
83
|
+
`,QU=`Remove HolyCodex-owned state through Codex native plugin management.
|
|
49
84
|
|
|
50
85
|
Usage:
|
|
51
86
|
holycodex remove [--yes] [--json] [--codex-home <absolute-path>]
|
|
52
87
|
|
|
53
88
|
Only HolyCodex-owned state is removed. Shared and unrelated Codex plugins and
|
|
54
89
|
configuration are preserved; changed owned files are preserved for review.
|
|
55
|
-
|
|
90
|
+
`,eH=`Inspect HolyCodex-owned configuration and native plugin state without mutating it.
|
|
56
91
|
|
|
57
92
|
Usage:
|
|
58
93
|
holycodex doctor [--json] [--codex-home <absolute-path>]
|
|
59
|
-
|
|
94
|
+
`,tH=`Read or update the canonical public package version.
|
|
60
95
|
|
|
61
96
|
Usage:
|
|
62
97
|
holycodex version [<0.x.y|patch|minor>] [--dry-run] [--json]
|
|
63
98
|
holycodex --version
|
|
64
99
|
holycodex -v
|
|
65
|
-
`;default:return`
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
`}
|
|
80
|
-
`)
|
|
81
|
-
`)}function xI(e){return e.some(e=>e===`-h`||e===`--help`||e===`--help=true`)}function SI(e){let t=e.filter(e=>!e.startsWith(`-`));return t[0]===`help`?t[1]:t[0]===`--version`||t[0]===`version`||t[0]===`-v`?`version`:t[0]}function CI(e){let t=e.env??{};return t.NO_COLOR!==void 0||t.TERM===`dumb`?!1:t.FORCE_COLOR!==void 0&&t.FORCE_COLOR!==`0`?!0:t.CI!==void 0&&t.CI!==`false`?!1:(e.stream===`stderr`?e.stderrIsTTY:e.stdoutIsTTY)===!0}function wI(e,t,n){return n?`\u001b[${{heading:`1`,option:`36`,argument:`2`}[t]}m${e}\u001b[0m`:e}function Y(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function TI(e){try{return _F(e),!0}catch{return!1}}function EI(e){switch(e){case`invalid_external_data`:case`manifest_invalid`:case`empty_output_directory`:return`validation`;case`discovery_failed`:return`identity`;case`protocol_mismatch`:case`method_unsupported`:case`server_request_unsupported`:case`unexpected_response`:return`protocol`;case`invalid_transport_line`:case`transport_closed`:case`transport_failure`:return`transport`;case`approval_required`:case`permission_denied`:return`approval`;case`cancellation`:return`interruption`;case`timeout`:return`timeout`;case`turn_failed`:return`turn`;case`closed`:return`closed`;case`server_error`:return`server`}}function DI(e){return{ok:!1,error:e}}function OI(e){return{ok:!0,value:e}}function kI(e,t=512){let n=``;for(let t of e){let e=t.codePointAt(0)??0;n+=e<=8||e===11||e===12||e>=14&&e<=31||e===127?` `:t}return n.replace(/\s+/gu,` `).trim().slice(0,t)}function AI(e,t=0){if(t>3)return`[truncated]`;if(e===null||typeof e==`boolean`)return e;if(typeof e==`string`)return kI(e,256);if(typeof e==`number`)return Number.isFinite(e)?e:null;if(Array.isArray(e))return e.slice(0,32).map(e=>AI(e,t+1));if(Y(e)){let n={};for(let[r,i]of Object.entries(e).slice(0,32)){let e=kI(r,96);e.length>0&&(n[e]=AI(i,t+1))}return n}return`[redacted]`}function jI(e){let t=AI(e);return Y(t)?t:{value:t}}function MI(e,t,n){return new X(`invalid_external_data`,`Invalid ${e}.`,{field:e,received:AI(t)},n===void 0?void 0:{cause:n})}function NI(e,t,n){let r=mP(e,t);if(er(r))throw MI(n,t,String(r.left));return r.right}function PI(e,t){try{return NI(e,t,`value`),!0}catch{return!1}}var FI,II,LI,RI,X,zI=v((()=>{uI(),lr(),pP(),FI=fe,II=G(e=>TI(e)),LI=G(e=>Y(e)&&TI(e)),K.pipe(CM(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u)),RI=K.pipe(pj(e=>e.length>0&&e.length<=4096)),Fj.pipe(pj(e=>Number.isFinite(e)&&e>=0)),X=class extends Error{code;kind;details;retryable;constructor(e,t,n={},r){super(t,r?.cause===void 0?void 0:{cause:r.cause}),this.name=`CodexError`,this.code=e,this.kind=EI(e),this.details=n,this.retryable=r?.retryable??!1,Object.freeze(this.details),Object.freeze(this)}}})),BI,VI,HI,UI,WI,GI,KI=v((()=>{BI=[`initialize`,`thread/start`,`thread/resume`,`thread/read`,`thread/list`,`thread/fork`,`thread/unsubscribe`,`turn/start`,`turn/steer`,`turn/interrupt`,`model/list`,`modelProvider/capabilities/read`,`config/read`,`permissionProfile/list`],VI=[`item/commandExecution/requestApproval`,`item/fileChange/requestApproval`,`applyPatchApproval`,`execCommandApproval`],HI=[`item/permissions/requestApproval`],UI=[`mcpServer/elicitation/request`],WI=[`item/tool/call`],GI={method:`initialized`}}));function qI(e,t=new Set){if(e===null||typeof e==`string`||typeof e==`boolean`)return!0;if(typeof e==`number`)return Number.isFinite(e);if(typeof e!=`object`||t.has(e))return!1;t.add(e);try{return Array.isArray(e)?e.every(e=>qI(e,t)):Y(e)&&Object.values(e).every(e=>qI(e,t))}finally{t.delete(e)}}function JI(e){return Y(e)&&qI(e)}function YI(e){let t=[],n=0,r=!1,i=!1;for(let a=0;a<=e.length;a+=1){let o=e[a];if(a===e.length||o===`.`&&!r){let r=e.slice(n,a),i=r.startsWith(`"`)?XI(r):r;if(!/^[A-Za-z][A-Za-z0-9_-]*$/u.test(i)&&!pF.includes(i))throw MI(`TOML key path`,e);t.push(i),n=a+1;continue}r?i?i=!1:o===`\\`?i=!0:o===`"`&&(r=!1):o===`"`&&(r=!0)}if(r||i||t.length===0||t.some(e=>e===`__proto__`||e===`constructor`||e===`prototype`))throw MI(`TOML key path`,e);return t}function XI(e){try{let t=JSON.parse(e);if(typeof t==`string`)return t}catch{}throw MI(`TOML quoted key`,e)}function ZI(e,t){if(!JI(e))throw MI(`TOML document`,e);let n=e;for(let e of YI(t)){if(!JI(n)||!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function QI(e){return Array.isArray(e)?e.map(QI):Y(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,QI(t)])):e}function $I(e){return QI(e)}function eL(e,t,n){if(!JI(e)||!qI(n))throw MI(`TOML write`,{keyPath:t});let r=YI(t),i={...$I(e)},a=i;for(let e of r.slice(0,-1)){let n=a[e];if(n!==void 0&&!JI(n))throw MI(`TOML table path`,t);let r=n===void 0?{}:{...n};a[e]=r,a=r}return a[r.at(-1)]=QI(n),i}function tL(e,t){if(!JI(e))throw MI(`TOML document`,e);let n=YI(t),r={...$I(e)},i=[],a=r;for(let e of n.slice(0,-1)){let t=a[e];if(!JI(t))return r;let n={...t};i.push({table:a,key:e}),a[e]=n,a=n}let o=n.at(-1);if(!Object.prototype.hasOwnProperty.call(a,o))return r;delete a[o];for(let e=i.length-1;e>=0;--e){let t=i[e],n=t.table[t.key];if(JI(n)&&Object.keys(n).length===0)delete t.table[t.key];else break}return r}function nL(e){return typeof e==`string`?wL.includes(e)||/^agents\.(?:explorer|librarian|worker|reviewer)\.config_file$/u.test(e)?!0:pF.some(t=>e===`agents."${t}".config_file`):!1}function rL(e){return typeof e==`string`&&EL.test(e)}function iL(e){return e===`gpt-5.6-terra`||e===`gpt-5.6-sol`||e===`gpt-5.6-luna`||e===`low`||e===`medium`||e===`high`||e===`xhigh`||e===`max`||e==="default"||e===`fast`}function aL(e){return typeof e==`string`&&/^[a-f0-9]{64}$/u.test(e)}function oL(e,t){let n=new Set(t);return Object.keys(e).every(e=>n.has(e))}function sL(e){if(!Y(e)||!oL(e,[`kind`,`value`])||typeof e.kind!=`string`)return!1;switch(e.kind){case`enum`:return iL(e.value);case`boolean`:return typeof e.value==`boolean`;case`relative_path`:return typeof e.value==`string`&&pL(e.value);case`digest`:return aL(e.value);default:return!1}}function cL(e,t){switch(gL(e)){case`boolean`:return t.kind===`boolean`;case`relative_path`:return t.kind===`relative_path`;case`digest`:return t.kind===`digest`;case`enum`:return t.kind===`enum`?e===`model`?t.value===`gpt-5.6-terra`||t.value===`gpt-5.6-sol`||t.value===`gpt-5.6-luna`:e===`model_reasoning_effort`?t.value===`low`||t.value===`medium`||t.value===`high`||t.value===`xhigh`||t.value===`max`:e===`service_tier`?t.value==="default"||t.value===`fast`:t.value===`low`||t.value===`medium`||t.value===`high`:!1}}function lL(e){return Y(e)&&e.kind===`absent`?Object.keys(e).length===1:sL(e)}function uL(e){return Y(e)&&oL(e,[`owner`,`schema`,`installId`,`keyPath`,`originalValue`,`lastManagedValue`])&&e.owner===`holycodex`&&typeof e.schema==`string`&&rL(e.schema)&&rL(e.installId)&&nL(e.keyPath)&&lL(e.originalValue)&&sL(e.lastManagedValue)&&cL(e.keyPath,e.lastManagedValue)&&(e.originalValue.kind===`absent`||cL(e.keyPath,e.originalValue))}function dL(e){return!Y(e)||!oL(e,[`owner`,`schema`,`installId`,`managed`])||e.owner!==`holycodex`||!rL(e.schema)||!rL(e.installId)||!Y(e.managed)?!1:Object.entries(e.managed).every(([e,t])=>nL(e)&&uL(t)&&t.keyPath===e)}function fL(e){if(!rL(e.schema)||!rL(e.installId))throw MI(`managed runtime config metadata`,{schema:e.schema});return{owner:`holycodex`,schema:e.schema,installId:e.installId,managed:{}}}function pL(e){if(e.length===0||e.includes(`\0`)||/^[\\/]|^[A-Za-z]:[\\/]/u.test(e))return!1;let t=e.replaceAll(`\\`,`/`).split(`/`);return t.some(e=>e!==`.`)&&t.every(e=>e.length>0&&e!==`..`)}function mL(e){if(!pL(e))throw MI(`relative config path`,`[redacted]`);return e.replaceAll(`\\`,`/`).split(`/`).filter(e=>e!==`.`).join(`/`)}function hL(e,t){let n=mL(t),r=e.replaceAll(`\\`,`/`).split(`/`);r.pop();let i=[...r,...n.split(`/`)].join(`/`),a=[];for(let e of i.split(`/`))e.length!==0&&e!==`.`&&(e===`..`?a.pop():a.push(e));let o=e.replaceAll(`\\`,`/`);return`${o.startsWith(`//`)?`//`:o.startsWith(`/`)?`/`:``}${a.join(`/`)}`}function gL(e){return e===`developer_instructions`?`digest`:e.endsWith(`.config_file`)?`relative_path`:e===`suppress_unstable_features_warning`||e===`features.default_mode_request_user_input`||e===`features.multi_agent_v2`||e===`features.context_management.experimental_mode`?`boolean`:`enum`}function _L(e,t){let n=gL(e);return n===`boolean`?typeof t==`boolean`:n===`relative_path`?typeof t==`string`&&pL(t):n===`digest`?typeof t==`string`:typeof t==`string`&&iL(t)}async function vL(e,t){if(!nL(e)||!qI(t))throw MI(`managed config value`,{keyPath:e});let n=gL(e);return n===`boolean`&&typeof t==`boolean`?{kind:n,value:t}:n===`relative_path`&&typeof t==`string`&&pL(t)?{kind:n,value:mL(t)}:n===`enum`&&typeof t==`string`&&iL(t)?{kind:n,value:t}:{kind:`digest`,value:await xF(`holycodex-managed-config-value`,[vF({keyPath:e,value:t})])}}function yL(e){if(e.kind===`enum`||e.kind===`boolean`||e.kind===`relative_path`)return e.value}async function bL(e,t,n,r){if(!JI(e)||!dL(t)||!rL(r.schema)||!rL(r.installId))throw MI(`managed runtime config`,{});let i={...t.managed},a=$I(e),o=[];for(let[e,s]of Object.entries(n)){if(!nL(e)||typeof s!=`string`&&typeof s!=`boolean`)throw MI(`managed config key`,e);let n=e,c=t.managed[n],l=ZI(a,n);if(c&&(c.schema!==r.schema||c.installId!==r.installId)){o.push(n);continue}if(c&&c.owner===`holycodex`){let e=l===void 0?void 0:await vL(n,l);if(e===void 0||JSON.stringify(e)!==JSON.stringify(c.lastManagedValue)){o.push(n);continue}}let u=c?.originalValue??(l===void 0?{kind:`absent`}:await vL(n,l));if(!_L(n,s))throw MI(`managed config value`,{keyPath:n});a=eL(a,n,s),i[n]={owner:`holycodex`,schema:r.schema,installId:r.installId,keyPath:n,originalValue:u,lastManagedValue:await vL(n,s)}}let s={owner:`holycodex`,schema:r.schema,installId:r.installId,managed:i};if(!dL(s))throw MI(`managed runtime config state`,{});return{document:a,state:s,driftedKeys:o}}async function xL(e,t,n){if(!JI(e)||!dL(t))throw MI(`managed runtime config`,{});let r=$I(e),i={...t.managed},a=[],o=[],s=[];for(let[e,c]of Object.entries(t.managed)){if(!nL(e))throw MI(`managed config key`,e);let t=e;if(c.owner!==`holycodex`||c.schema!==n.schema||c.installId!==n.installId)continue;let l=ZI(r,t);if(l===void 0||JSON.stringify(await vL(t,l))!==JSON.stringify(c.lastManagedValue)){o.push(t);continue}if(c.originalValue.kind===`absent`)r=tL(r,t),a.push(t),delete i[t];else{let e=yL(c.originalValue);if(e===void 0){s.push(t),o.push(t);continue}r=eL(r,t,e),a.push(t),delete i[t]}}return{document:r,state:{...t,managed:i},restoredKeys:a,preservedKeys:o,unresolvedKeys:s}}async function SL(e,t,n){if(!nL(n)||!dL(t))throw MI(`managed config key`,n);let r=t.managed[n],i=ZI(e,n),a=i===void 0?void 0:await vL(n,i);return r?{keyPath:n,status:a!==void 0&&JSON.stringify(a)===JSON.stringify(r.lastManagedValue)?`unchanged`:`drifted`,expected:r.lastManagedValue,...a===void 0?{}:{current:a}}:a===void 0?{keyPath:n,status:`unmanaged`}:{keyPath:n,status:`unmanaged`,current:a}}var CL,wL,TL,EL,DL=v((()=>{uI(),pP(),zI(),G(e=>qI(e)),CL=G(e=>JI(e)),wL=[`model`,`model_reasoning_effort`,`service_tier`,`model_verbosity`,`developer_instructions`,`suppress_unstable_features_warning`,`features.default_mode_request_user_input`,`features.multi_agent_v2`,`features.context_management.experimental_mode`],G(e=>nL(e)),G(e=>sL(e)),G(e=>lL(e)),G(e=>uL(e)),TL=G(e=>dL(e)),EL=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u}));function OL(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function kL(e,t,n){let r=new Set([...t,n]),i=Object.keys(e);return!Object.keys(e).some(e=>!r.has(e))&&i.length>0&&i.every(t=>OL(e[t]))}function AL(e){return!Y(e)||!TI(e)?!1:kL(e,[`inputTokens`,`cachedInputTokens`,`outputTokens`,`reasoningOutputTokens`],`totalTokens`)||kL(e,[`input_tokens`,`cached_input_tokens`,`output_tokens`,`reasoning_output_tokens`],`total_tokens`)}function jL(e){return Y(e)&&TI(e)&&typeof e.id==`string`&&/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u.test(e.id)}function ML(e){return Y(e)&&TI(e)&&jL(e.thread)}function NL(e){return Y(e)&&TI(e)&&typeof e.id==`string`}function PL(e){return Y(e)&&TI(e)&&typeof e.threadId==`string`&&e.threadId.length>0}function FL(e){return Y(e)&&TI(e)&&typeof e.id==`string`&&e.id.length>0&&(e.usage===void 0||AL(e.usage))}function IL(e){return Y(e)&&TI(e)&&typeof e.id==`string`&&typeof e.model==`string`&&(e.supportedReasoningEfforts===void 0||Array.isArray(e.supportedReasoningEfforts)&&e.supportedReasoningEfforts.every(e=>Y(e)&&typeof e.reasoningEffort==`string`))&&(e.serviceTiers===void 0||Array.isArray(e.serviceTiers)&&e.serviceTiers.every(e=>Y(e)&&typeof e.id==`string`))&&(e.defaultServiceTier===void 0||e.defaultServiceTier===null||typeof e.defaultServiceTier==`string`)&&(e.multiAgentVersion===void 0||e.multiAgentVersion===null||e.multiAgentVersion===`disabled`||e.multiAgentVersion===`v1`||e.multiAgentVersion===`v2`)}function LL(e){return HI.some(t=>t===e)?`permissions`:VI.some(t=>t===e)?`approval`:UI.some(t=>t===e)?`elicitation`:WI.some(t=>t===e)?`dynamic_tool`:`other`}var RL,zL,BL,VL,HL,UL,WL,GL,KL,qL,JL,YL,XL,ZL,QL,$L,eR,tR,nR,rR,iR,aR,oR,sR,cR,lR,uR,dR,fR,pR,mR,hR,gR,_R,vR,yR,bR,xR,SR,CR=v((()=>{pP(),zI(),KI(),DL(),RL=K.pipe(CM(/^[A-Za-z][A-Za-z0-9_./:-]{0,127}$/u)),zL=U(K.pipe(yM(1)),Fj.pipe(pj(e=>Number.isSafeInteger(e)))),BL=W({code:Fj.pipe(pj(e=>Number.isSafeInteger(e))),message:K,data:J(II)}),VL=U(W({id:zL,result:II}),W({id:zL,error:BL})),W({id:zL,error:BL}),HL=W({method:RL,params:J(II)}),UL=W({id:zL,method:RL,params:J(II),trace:J(II)}),G(AL),WL=W({clientInfo:W({name:RI,version:RI,title:U(RI,Aj)}),capabilities:U(W({experimentalApi:q,requestAttestation:q,mcpServerOpenaiFormElicitation:J(q),optOutNotificationMethods:J(U(Vj(K),Aj)),extensions:J(LI)}),Aj)}),GL=G(e=>Y(e)&&TI(e)&&typeof e.userAgent==`string`&&typeof e.codexHome==`string`&&typeof e.platformFamily==`string`&&typeof e.platformOs==`string`),KL=W({method:H(`initialized`)}),G(jL),qL=G(e=>ML(e)||NL(e)),JL=qL,YL=qL,XL=G(PL),ZL=G(e=>Y(e)&&TI(e)&&(e.status===`notLoaded`||e.status===`notSubscribed`||e.status===`unsubscribed`)),QL=G(e=>ML(e)),$L=G(e=>{if(!Y(e)||!TI(e))return!1;let t=Array.isArray(e.data)&&e.data.every(e=>jL(e)),n=Array.isArray(e.threads)&&e.threads.every(e=>jL(e));return t&&e.threads===void 0||n&&e.data===void 0}),eR=G(e=>Y(e)&&TI(e)),tR=G(PL),nR=G(PL),rR=G(PL),iR=G(e=>Y(e)&&TI(e)),aR=G(e=>PL(e)&&(Array.isArray(e.input)&&e.input.every(e=>TI(e))||typeof e.prompt==`string`&&e.prompt.length>0)),oR=G(e=>PL(e)&&typeof e.expectedTurnId==`string`&&Array.isArray(e.input)&&e.input.every(e=>TI(e))),sR=G(e=>Y(e)&&TI(e)&&(e.turn!==void 0&&FL(e.turn)||typeof e.turnId==`string`&&e.turnId.length>0||typeof e.id==`string`&&e.id.length>0)),cR=G(e=>Y(e)&&TI(e)&&typeof e.turnId==`string`&&e.turnId.length>0),lR=G(e=>PL(e)&&typeof e.turnId==`string`&&e.turnId.length>0),uR=G(e=>Y(e)&&TI(e)),dR=G(e=>PL(e)&&(e.turn!==void 0&&FL(e.turn)||typeof e.turnId==`string`&&e.turnId.length>0)),fR=G(e=>Y(e)&&TI(e)),pR=G(e=>Y(e)&&TI(e)&&Array.isArray(e.data)&&e.data.every(e=>IL(e))),mR=LI,hR=LI,gR=W({includeLayers:J(q),cwd:J(U(K,Aj))}),_R=W({config:CL,origins:LI,layers:U(Vj(LI),Aj)}),vR=LI,yR=LI,bR=G(e=>Y(e)&&TI(e)&&(typeof e.id==`string`||typeof e.id==`number`&&Number.isSafeInteger(e.id))&&typeof e.method==`string`&&Y(e.params)&&(e.category===`approval`||e.category===`dynamic_tool`||e.category===`elicitation`||e.category===`other`||e.category===`permissions`)),xR=II,G(e=>Y(e)&&TI(e)&&typeof e.kind==`string`&&typeof e.method==`string`),SR=U(H(`stable`,`experimental`,`disabled`),q),oM({key:K,value:SR})}));function wR(e){let t=kI(e);return t.length>0?t:`server request failed`}function TR(e){return HI.some(t=>t===e)?`permission_denied`:VI.some(t=>t===e)?`approval_required`:e===`turn/interrupt`?`cancellation`:e.startsWith(`turn/`)?`turn_failed`:`server_error`}var ER,DR,OR,kR=v((()=>{zI(),KI(),CR(),ER={clientInfo:{name:`holycodex`,title:null,version:FI},capabilities:null},DR=new Set(BI),OR=class{transport;maxLineBytes;requestTimeoutMs;signal;notificationListeners=new Set;serverRequestHandlers=new Set;pending=new Map;serverRequestWork=new Set;serverRequestTasks=new Set;nextRequestId=1;readerPromise;initializePromise;transportClosePromise;initializeAttempted=!1;initialized=!1;closed=!1;constructor(e,t={}){if(this.transport=e,this.maxLineBytes=t.maxLineBytes??1048576,this.requestTimeoutMs=t.requestTimeoutMs,this.signal=t.signal,!Number.isSafeInteger(this.maxLineBytes)||this.maxLineBytes<1)throw new X(`invalid_external_data`,`The maximum line size is invalid.`);if(this.requestTimeoutMs!==void 0&&(!Number.isSafeInteger(this.requestTimeoutMs)||this.requestTimeoutMs<1))throw new X(`invalid_external_data`,`The request timeout is invalid.`);t.onNotification&&this.notificationListeners.add(t.onNotification),t.onServerRequest&&this.serverRequestHandlers.add(t.onServerRequest),this.signal?.aborted?this.close():this.signal&&this.signal.addEventListener(`abort`,()=>void this.close(),{once:!0})}get isInitialized(){return this.initialized}onNotification(e){return this.notificationListeners.add(e),()=>this.notificationListeners.delete(e)}onServerRequest(e){return this.serverRequestHandlers.add(e),()=>this.serverRequestHandlers.delete(e)}async initialize(e=ER){if(this.initializePromise)return this.initializePromise;if(this.initializeAttempted)throw new X(`invalid_external_data`,`The App Server initialize handshake was already attempted.`);this.ensureOpen();let t=NI(WL,e,`initialize parameters`);return this.initializeAttempted=!0,this.initializePromise=this.performInitialize(t),this.initializePromise}async startThread(e={}){return this.action(`thread/start`,eR,e,qL)}async resumeThread(e){let t=typeof e==`string`?{threadId:e}:e;return this.action(`thread/resume`,tR,t,JL)}async readThread(e){let t=typeof e==`string`?{threadId:e}:e;return this.action(`thread/read`,nR,t,QL)}async listThreads(e={}){return this.action(`thread/list`,iR,e,$L)}async forkThread(e){let t=typeof e==`string`?{threadId:e}:e;return this.action(`thread/fork`,rR,t,YL)}async unsubscribeThread(e){let t=typeof e==`string`?{threadId:e}:e;return this.action(`thread/unsubscribe`,XL,t,ZL)}async startTurn(e){return this.action(`turn/start`,aR,e,sR)}async steerTurn(e){return this.action(`turn/steer`,oR,e,cR)}async interruptTurn(e,t){let n=typeof e==`string`?{threadId:e,turnId:t??``}:e;return this.action(`turn/interrupt`,lR,n,uR)}async listModels(e={}){return this.action(`model/list`,fR,e,pR)}async readModelProviderCapabilities(e={}){return this.action(`modelProvider/capabilities/read`,mR,e,hR)}async readConfig(e={}){return this.action(`config/read`,gR,e,_R)}async listPermissionProfiles(e={}){return this.action(`permissionProfile/list`,vR,e,yR)}async call(e,t={}){if(e===`initialize`){let e=await this.initialize(NI(WL,t,`initialize parameters`));return NI(II,e,`initialize result`)}let n=NI(UL,{id:1,method:e,params:t},`App Server method`);if(!DR.has(n.method))throw new X(`method_unsupported`,`Unsupported App Server method: ${e}.`,{method:e});return this.request(n.method,n.params===void 0?{}:n.params)}async close(){await this.closeWithError(new X(`closed`,`The App Server client is closed.`))}async performInitialize(e){try{let t=await this.request(`initialize`,NI(II,e,`initialize parameters`)),n=NI(GL,t,`initialize result`),r=NI(KL,GI,`initialized notification`);return await this.transport.writeLine(JSON.stringify(r)),this.initialized=!0,n}catch(e){let t=e instanceof X?e:new X(`transport_failure`,`The initialize handshake failed.`,{},{cause:e});throw await this.closeWithError(t),t}}async action(e,t,n,r){let i=NI(t,n,`${e} parameters`),a=NI(II,i,`${e} parameters`);return NI(r,await this.request(e,a),`${e} result`)}async request(e,t){if(this.ensureOpen(),e!==`initialize`&&!this.initialized)throw new X(`invalid_external_data`,`The ${e} action requires an initialized App Server client.`);this.startReader();let n=this.nextRequestId;this.nextRequestId+=1;let r=NI(UL,{id:n,method:e,params:t},`${e} request`);return new Promise((t,i)=>{let a=!1,o,s,c=e=>{a||(a=!0,this.pending.delete(n),o!==void 0&&clearTimeout(o),s?.(),i(e))};if(this.requestTimeoutMs!==void 0&&(o=setTimeout(()=>c(new X(`timeout`,`The ${e} request timed out.`,{method:e})),this.requestTimeoutMs)),this.signal){let t=()=>c(new X(`cancellation`,`The ${e} request was cancelled.`,{method:e}));this.signal.addEventListener(`abort`,t,{once:!0}),s=()=>this.signal?.removeEventListener(`abort`,t)}let l={method:e,resolve:e=>{a||(a=!0,o!==void 0&&clearTimeout(o),s?.(),t(e))},reject:c,...o===void 0?{}:{timer:o},...s===void 0?{}:{removeAbortListener:s}};this.pending.set(n,l),this.transport.writeLine(JSON.stringify(r)).catch(e=>{c(e instanceof X?e:new X(`transport_failure`,`The App Server request could not be written.`,{},{cause:e}))})})}startReader(){this.readerPromise||=this.readLoop().catch(e=>this.handleReaderFailure(e)).catch(()=>void 0)}async readLoop(){for(;!this.closed;){let e=await this.transport.readLine();if(e===null){if(!this.closed)throw new X(`transport_closed`,`The App Server transport closed.`);return}if(new TextEncoder().encode(e).byteLength>this.maxLineBytes)throw new X(`invalid_transport_line`,`An App Server line exceeded the limit.`);this.handleLine(e)}}async handleReaderFailure(e){let t=e instanceof X?e:new X(`transport_failure`,`The App Server transport failed.`,{},{cause:e});await this.closeWithError(t)}handleLine(e){let t;try{t=JSON.parse(e)}catch(e){throw new X(`invalid_transport_line`,`The App Server emitted invalid JSON.`,{},{cause:e})}let n=this.tryDecode(VL,t);if(n!==void 0){this.handleResponse(n);return}let r=this.tryDecode(UL,t);if(r!==void 0){this.handleServerRequest(r);return}let i=this.tryDecode(HL,t);if(i!==void 0){this.handleNotification(i);return}throw MI(`JSON-RPC message`,t)}tryDecode(e,t){try{return NI(e,t,`JSON-RPC message`)}catch{return}}handleResponse(e){let t=this.pending.get(e.id);if(!t)throw new X(`unexpected_response`,`The App Server returned an unknown request id.`,{id:e.id});if(this.pending.delete(e.id),`error`in e){let n=e.error.code===-32001,r=TR(t.method);t.reject(new X(r,`The App Server rejected ${t.method}: ${kI(e.error.message)}.`,{method:t.method,serverCode:e.error.code,retryable:n,...e.error.data===void 0?{}:{data:AI(e.error.data)}},{retryable:n}));return}t.resolve(e.result)}handleServerRequest(e){let t=e.params??{},n=NI(bR,{...e,params:t,category:LL(e.method)},`server request`);this.emitNotification({kind:`server_request`,method:e.method,params:t});let r=[...this.serverRequestHandlers];if(r.length===0){this.trackServerRequestTask(this.writeServerError(e.id,-32601,`No handler for ${e.method}.`));return}let i=r[0];if(i===void 0){this.trackServerRequestTask(this.writeServerError(e.id,-32601,`No handler for ${e.method}.`));return}let a={active:!0};this.serverRequestWork.add(a);let o;try{o=i(n)}catch(t){this.completeServerRequest(a,()=>this.writeServerError(e.id,-32e3,kI(String(t))));return}if(o instanceof Promise){this.trackServerRequestTask(o.then(t=>this.completeServerRequest(a,()=>this.writeValidatedServerResult(e.id,t)),t=>this.completeServerRequest(a,()=>this.writeServerError(e.id,-32e3,kI(String(t))))));return}this.completeServerRequest(a,()=>this.writeValidatedServerResult(e.id,o))}writeValidatedServerResult(e,t){try{let n=NI(xR,t,`server response`);return this.writeServerResult(e,n)}catch(t){return this.writeServerError(e,-32e3,kI(String(t)))}}completeServerRequest(e,t){if(e.active){e.active=!1,this.serverRequestWork.delete(e);try{this.trackServerRequestTask(t())}catch{}}}trackServerRequestTask(e){let t=e.catch(()=>void 0);this.serverRequestTasks.add(t),t.then(()=>this.serverRequestTasks.delete(t),()=>this.serverRequestTasks.delete(t))}async writeServerResult(e,t){let n=NI(VL,{id:e,result:t},`server response`);await this.transport.writeLine(JSON.stringify(n))}async writeServerError(e,t,n){let r=NI(VL,{id:e,error:{code:t,message:wR(n)}},`server error response`);await this.transport.writeLine(JSON.stringify(r))}handleNotification(e){let t=e.params;if(e.method===`turn/completed`){let n=NI(dR,t,`turn/completed notification`);this.emitNotification({kind:`turn_completed`,method:e.method,params:n});return}if(e.method.includes(`agent`)||e.method.includes(`subagent`)){this.emitNotification({kind:`multi_agent`,method:e.method,...t===void 0?{}:{params:t}});return}this.emitNotification({kind:`unknown`,method:e.method,metadata:jI({params:AI(t)})})}emitNotification(e){for(let t of this.notificationListeners)try{t(e)}catch{}}rejectPending(e){for(let t of this.pending.values())t.reject(e);this.pending.clear()}async closeWithError(e){if(this.transportClosePromise!==void 0){await this.transportClosePromise;return}this.closed=!0,this.rejectPending(e);for(let e of this.serverRequestWork)e.active=!1;this.serverRequestWork.clear(),this.serverRequestTasks.clear(),this.transportClosePromise=Promise.resolve().then(()=>this.transport.close()).catch(()=>void 0),await this.transportClosePromise}ensureOpen(){if(this.closed)throw new X(`closed`,`The App Server client is closed.`)}}}));function AR(e=process.env){let t=[`PATH`,`HOME`,`USER`,`CODEX_HOME`,`TMPDIR`,`TEMP`,`TMP`,`LANG`,`LC_ALL`],n={};for(let r of t){let t=e[r];t!==void 0&&t.length>0&&(n[r]=t)}return n}function jR(e=process.env){return Object.freeze(AR(e))}async function MR(e,t){let n=e.getReader(),r=[],i=0;try{for(;;){let e=await n.read();if(e.done)break;if(i+=e.value.byteLength,i>t)throw new X(`invalid_transport_line`,`A subprocess stream exceeded its limit.`);r.push(e.value)}}finally{n.releaseLock()}let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.byteLength;return a}function NR(e,t){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch(e){throw new X(`invalid_transport_line`,`Invalid UTF-8 in ${t}.`,{},{cause:e})}}function PR(e){return kI(e.replace(/Bearer\s+[^\s]+/giu,`Bearer [redacted]`).replace(/((?:api[_-]?key|authorization|cookie|password|secret|token)\s*[:=]\s*)[^\s,;]+/giu,`$1[redacted]`),512)}var FR,IR=v((()=>{zI(),FR=class{process;stdin;stdoutReader;stderrStream;maxLineBytes;maxDiagnosticBytes;lineDecoder=new TextDecoder(`utf-8`,{fatal:!0});stderrDiagnostics=[];stdoutBuffer=new Uint8Array;stderrPromise;closed=!1;constructor(e){if(!g(e.executablePath))throw new X(`discovery_failed`,`The Codex executable path must be absolute.`);if(this.maxLineBytes=e.maxLineBytes??1048576,this.maxDiagnosticBytes=e.maxDiagnosticBytes??65536,this.maxLineBytes<1||this.maxDiagnosticBytes<1)throw new X(`invalid_external_data`,`The transport bounds are invalid.`);if(this.process=Bun.spawn([e.executablePath,`app-server`],{...e.cwd===void 0?{}:{cwd:e.cwd},env:AR(e.environment),stdin:`pipe`,stdout:`pipe`,stderr:`pipe`}),!(this.process.stdout instanceof ReadableStream)||!(this.process.stderr instanceof ReadableStream))throw new X(`transport_failure`,`The Codex App Server did not expose stdio pipes.`);if(typeof this.process.stdin==`number`||this.process.stdin===void 0)throw new X(`transport_failure`,`The Codex App Server did not expose stdin.`);this.stdin=this.process.stdin,this.stdoutReader=this.process.stdout,this.stderrStream=this.process.stderr,this.stderrPromise=this.collectStderr(),e.signal&&(e.signal.aborted?this.close():e.signal.addEventListener(`abort`,()=>void this.close(),{once:!0}))}get diagnostics(){return[...this.stderrDiagnostics]}async readLine(){if(this.closed&&this.stdoutBuffer.byteLength===0)return null;let e=this.stdoutReader.getReader();try{for(;;){let t=this.stdoutBuffer.indexOf(10);if(t>=0){if(t>this.maxLineBytes)throw await this.close(),new X(`invalid_transport_line`,`The App Server emitted an overlong line.`);let e=this.stdoutBuffer.slice(0,t);this.stdoutBuffer=this.stdoutBuffer.slice(t+1);let n=e.at(-1)===13?e.slice(0,-1):e;return this.lineDecoder.decode(n)}if(this.stdoutBuffer.byteLength>this.maxLineBytes)throw await this.close(),new X(`invalid_transport_line`,`The App Server emitted an overlong line.`);let n=await e.read();if(n.done){if(this.stdoutBuffer.byteLength===0)return null;if(this.stdoutBuffer.byteLength>this.maxLineBytes)throw await this.close(),new X(`invalid_transport_line`,`The App Server emitted an overlong line.`);let e=this.stdoutBuffer;return this.stdoutBuffer=new Uint8Array,this.lineDecoder.decode(e)}let r=new Uint8Array(this.stdoutBuffer.byteLength+n.value.byteLength);r.set(this.stdoutBuffer,0),r.set(n.value,this.stdoutBuffer.byteLength),this.stdoutBuffer=r}}catch(e){throw e instanceof X?e:new X(`transport_failure`,`The App Server stdout could not be read.`,{},{cause:e})}finally{e.releaseLock()}}async writeLine(e){if(this.closed)throw new X(`closed`,`The App Server transport is closed.`);if(new TextEncoder().encode(e).byteLength>this.maxLineBytes)throw new X(`invalid_transport_line`,`The App Server request exceeded the line limit.`);try{await this.stdin.write(`${e}\n`),await this.stdin.flush()}catch(e){throw new X(`transport_failure`,`The App Server stdin could not be written.`,{},{cause:e})}}async close(){if(!this.closed){this.closed=!0;try{await Promise.resolve(this.stdin.end())}catch{}try{this.process.kill()}catch{}await Promise.race([this.process.exited,new Promise(e=>setTimeout(()=>e(-1),1e3))]),await this.stderrPromise.catch(()=>void 0)}}async collectStderr(){try{let e=NR(await MR(this.stderrStream,this.maxDiagnosticBytes),`Codex stderr`);for(let t of e.split(/\r?\n/u).slice(0,128)){let e=PR(t);e.length>0&&this.stderrDiagnostics.push(e)}}catch{this.stderrDiagnostics.push(`[stderr unavailable]`)}}}}));async function LR(e){let t=[];if(e.executablePath!==void 0)t.push(ne(e.cwd??process.cwd(),e.executablePath));else{let n=e.pathValue??process.env.PATH??``,r=process.platform===`win32`?[`codex.exe`,`codex.cmd`,`codex`]:[`codex`];for(let e of n.split(m).filter(e=>e.length>0))for(let n of r)t.push(ne(e,n))}for(let n of t)try{let e=await d(n);if(!e.isFile()||process.platform!==`win32`&&!(e.mode&73))continue;return await s(n)}catch{if(e.executablePath!==void 0)throw new X(`discovery_failed`,`The explicit Codex executable was not found.`,{path:n})}throw new X(`discovery_failed`,`No Codex executable was found on the allowlisted PATH.`)}async function RR(e,t){let n=Bun.spawn([e,`--version`],{env:t,stdin:`ignore`,stdout:`pipe`,stderr:`pipe`});if(!(n.stdout instanceof ReadableStream)||!(n.stderr instanceof ReadableStream))throw new X(`discovery_failed`,`The Codex version command did not expose output pipes.`);try{let[e,t,r]=await VR(Promise.all([MR(n.stdout,16384),MR(n.stderr,16384),n.exited]),()=>n.kill(),`The Codex version command timed out.`),i=kI(NR(e,`Codex version output`));if(r!==0||i.length===0){let e=PR(NR(t,`Codex version diagnostics`));throw new X(`discovery_failed`,`The Codex executable did not provide a version.`,{exitCode:r,diagnostics:e})}return i}catch(e){try{n.kill()}catch{}throw e instanceof X?e:new X(`discovery_failed`,`The Codex version command failed.`,{},{cause:e})}}async function zR(e){let t=await a(e),n=await crypto.subtle.digest(`SHA-256`,t),r=VP([...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``));if(!r.ok)throw new X(`discovery_failed`,`The Codex executable digest was invalid.`);return r.value}async function BR(e={}){let t=await LR(e),n=AR(e.environment),r=e.versionRunner?kI(await e.versionRunner(t,n)):await RR(t,n);if(r.length===0)throw new X(`discovery_failed`,`The Codex version output was empty.`);return{path:t,version:r,sha256:await zR(t)}}async function VR(e,t,n){let r;try{return await Promise.race([e,new Promise((e,i)=>{r=setTimeout(()=>{try{t()}catch{}i(new X(`timeout`,n))},HR)})])}finally{r!==void 0&&clearTimeout(r)}}var HR,UR=v((()=>{uI(),pP(),zI(),IR(),HR=3e4,W({exitCode:Fj.pipe(pj(e=>Number.isSafeInteger(e))),stdout:K.pipe(_M(1048576)),stderr:K.pipe(_M(1048576))})})),WR,GR,KR,qR,JR=v((()=>{uI(),pP(),zI(),WR=`packages/codex/generated`,GR=/^codex-cli \d+\.\d+\.\d+$/u,KR=/^codex-app-server-\d+\.\d+\.\d+$/u,qR=K.pipe(CM(/^[a-f0-9]{64}$/u)),W({schema_version:H(`holycodex-generated-v2`),artifact_root:H(WR),codex_cli_version:K.pipe(CM(GR)),codex_cli_digest:qR,protocol_epoch:K.pipe(CM(KR)),generator:W({command:sj(H(`app-server`),H(`generate-ts`)),supported_surface:H(`codex app-server generators`)}),typescript_root:H(`typescript`),files:W({count:Fj.pipe(QM(),sN()),digest:qR})}),W({path:K.pipe(yM(1)),size:Fj.pipe(QM(),sN()),sha256:qR})})),YR=v((()=>{pP(),DL(),W({owner:H(`holycodex`),schema:K.pipe(CM(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u)),installId:K.pipe(CM(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u))})}));async function XR(e){let t=uz(e.selectedPluginIds);if(t.length===0)return;if(pz(e.timeoutMs,e.pollIntervalMs),e.signal?.aborted)throw new Lz(`cancelled`,`Official Codex marketplace bootstrap was cancelled.`);let n=e.readSnapshot??(t=>iz(t,e.selectedPluginIds)),r=await n(e.codexHome);if(r!==void 0&&dz(r,t))return r;let i=e.initializeRuntime??(()=>fz(e)),a,o;try{a=await i()}catch(e){o=Z(`marketplace_unavailable`,`Codex runtime initialization could not start the official marketplace sync. Check that Codex is available and its network/policy settings permit the official marketplace.`,e)}if(o===void 0)try{let r=e.timeoutMs??kz,i=e.pollIntervalMs??Az,a=Date.now();for(;Date.now()-a<=r;){if(e.signal?.aborted)throw new Lz(`cancelled`,`Official Codex marketplace bootstrap was cancelled.`);let o=await n(e.codexHome);if(o!==void 0&&dz(o,t))return o;let s=r-(Date.now()-a);if(s<=0)break;await(e.sleep??_z)(Math.min(i,s))}o=Z(`marketplace_timeout`,`The official Codex marketplace did not become ready before the bounded wait expired. Check network access and Codex marketplace policy, then retry.`)}catch(e){if(e instanceof Lz&&e.code===`cancelled`)throw e;o=e instanceof Lz?e:Z(`marketplace_unavailable`,`The official Codex marketplace sync failed before its bounded wait completed.`,e)}finally{await a?.()}if(e.gitFallback!==!1)try{return await ZR({codexHome:e.codexHome,selectedPluginIds:e.selectedPluginIds,...e.environment===void 0?{}:{environment:e.environment},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.signal===void 0?{}:{signal:e.signal},...e.gitFallback===void 0?{}:e.gitFallback})}catch(e){throw e instanceof Lz?e:Z(`marketplace_unavailable`,`The official marketplace could not be populated after runtime startup (${o?.code??`unavailable`}). Check network access and retry.`,e)}throw o??Z(`marketplace_timeout`,`The official Codex marketplace did not become ready before the bounded wait expired.`)}async function ZR(e){let n=uz(e.selectedPluginIds);if(n.length===0)throw Z(`marketplace_invalid`,`The official marketplace fallback requires at least one selected provider plugin.`);if(pz(e.timeoutMs,void 0),!g(e.codexHome))throw Z(`marketplace_invalid`,`The Codex home for official marketplace fallback must be absolute.`);if(e.signal?.aborted)throw new Lz(`cancelled`,`Official Codex marketplace fallback was cancelled.`);let i=AR(e.environment),a=e.gitRunner??Cz(`git`,{environment:i,...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}}),o=e.timeoutMs??kz,s;try{s=await QR(a,o,e.signal)}catch(e){throw e instanceof Lz?e:Z(`marketplace_unavailable`,`The official Codex marketplace remote HEAD could not be resolved. Check network access and retry.`,e)}let u=_(e.codexHome,`plugins`),d=_(u,Oz[1]);if(await ez(u,e.codexHome),await t(d).catch(e=>{if(!hz(e))throw Z(`marketplace_invalid`,`The reserved official marketplace path could not be inspected safely.`,e)})!==void 0)throw Z(`marketplace_invalid`,`The reserved official marketplace path appeared during bootstrap; refusing to overwrite it.`);let f=await r(_(u,`.openai-plugins-stage-`));try{if(await mz(e.codexHome,f),e.cloneSnapshot!==void 0)try{await e.cloneSnapshot(Dz,f)}catch(e){throw gz(e)?Z(`marketplace_invalid`,`The staged official marketplace could not be created as a safe file tree.`,e):e}else{let t=await a.run([`clone`,`--depth=1`,`--no-tags`,Dz,f],{...e.signal===void 0?{}:{signal:e.signal},timeoutMs:o});if(t.exitCode!==0)throw Z(`marketplace_unavailable`,`The official Codex marketplace could not be downloaded. Check network access and retry.`,t.stderr)}await rz(f);let r=await az(f,e.codexHome,n);if(r===void 0||!dz(r,n))throw Z(`marketplace_invalid`,`The downloaded official marketplace is missing the selected plugin entries or manifest.`);if(await $R(a,f,o,e.signal)!==s)throw Z(`marketplace_invalid`,`The downloaded official marketplace did not match the verified remote HEAD.`);if(await t(d).catch(e=>{if(!hz(e))throw Z(`marketplace_invalid`,`The reserved official marketplace path could not be checked before publication.`,e)})!==void 0)throw Z(`marketplace_invalid`,`The reserved official marketplace path appeared during staging; refusing to overwrite it.`);await c(f,d);let i=await iz(e.codexHome,e.selectedPluginIds);if(i===void 0||!dz(i,n))throw Z(`marketplace_invalid`,`The published official marketplace failed validation.`);return i}catch(e){throw e instanceof Lz?e:Z(`marketplace_unavailable`,`The official Codex marketplace fallback failed safely. Check network access and retry.`,e)}finally{await l(f,{recursive:!0,force:!0}).catch(()=>void 0)}}async function QR(e,t,n){let r=await e.run([`ls-remote`,Dz,`HEAD`],{...n===void 0?{}:{signal:n},timeoutMs:t});if(r.exitCode!==0)throw Z(`marketplace_unavailable`,`The official Codex marketplace remote HEAD could not be resolved. Check network access and retry.`,r.stderr);let i=r.stdout.trim().split(/\r?\n/u).map(e=>e.trim()).filter(e=>e.length>0),a=i.length===1?/^([0-9a-f]{40}|[0-9a-f]{64})\s+HEAD$/iu.exec(i[0]??``):null;if(a?.[1]===void 0)throw Z(`marketplace_invalid`,`The official Codex marketplace remote HEAD response was malformed.`);return a[1].toLowerCase()}async function $R(e,t,n,r){let i=await e.run([`rev-parse`,`HEAD`],{timeoutMs:n,cwd:t,...r===void 0?{}:{signal:r}}),a=i.stdout.trim().toLowerCase();if(i.exitCode!==0||!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(a))throw Z(`marketplace_invalid`,`The downloaded official marketplace checkout did not expose a valid HEAD.`,i.stderr);return a}async function ez(e,t){await tz(t,e),await n(e,{recursive:!0}),await tz(t,e)}async function tz(e,n){let r=ne(e),i=ne(n);for(;;){if((await t(i).catch(e=>{if(!hz(e))throw e}))?.isSymbolicLink())throw Z(`marketplace_invalid`,`The official marketplace path cannot contain symlinks.`);if(i===r)return;let e=h(i);if(e===i||e!==r&&!nz(r,e))throw Z(`marketplace_invalid`,`The official marketplace path escaped CODEX_HOME.`);i=e}}function nz(e,t){let n=te(e,t);return n.length>0&&n!==`..`&&!n.startsWith(`..${re}`)&&!g(n)}async function rz(e){let n=await t(e);if(n.isSymbolicLink())throw Z(`marketplace_invalid`,`The official marketplace snapshot cannot contain symlinks.`);if(!n.isDirectory())throw Z(`marketplace_invalid`,`The official marketplace snapshot is not a directory.`);let r=await o(e,{withFileTypes:!0});for(let n of r){let r=_(e,n.name),i=await t(r);if(i.isSymbolicLink())throw Z(`marketplace_invalid`,`The official marketplace snapshot cannot contain symlinks.`);i.isDirectory()&&await rz(r)}}async function iz(e,t=[]){return await az(_(e,...Oz),e,uz(t))}async function az(e,n,r=[]){n!==void 0&&await tz(n,e);let i=await t(e).catch(e=>{if(!hz(e))throw Z(`marketplace_invalid`,`The reserved openai-curated marketplace path could not be read safely.`,e)});if(i===void 0)return;if(i.isSymbolicLink()||!i.isDirectory())throw Z(`marketplace_invalid`,`The reserved openai-curated marketplace path is not a real directory.`);n===void 0?await rz(e):await mz(n,e),n!==void 0&&await rz(e);let o=await s(e),c=[_(o,`.agents`,`plugins`,`marketplace.json`),_(o,`.codex-plugin`,`marketplace.json`),_(o,`marketplace.json`)],l,u;for(let e of c){let n=await t(e).catch(e=>{if(!hz(e))throw Z(`marketplace_invalid`,`The official marketplace manifest could not be read safely.`,e)});if(n!==void 0){if(n.isSymbolicLink()||!n.isFile())throw Z(`marketplace_invalid`,`The official marketplace manifest is not a regular file.`);if(await mz(o,e),l!==void 0)throw Z(`marketplace_invalid`,`The reserved official marketplace contains more than one manifest.`);l=e;try{u=new TextDecoder(`utf-8`,{fatal:!0}).decode(await a(e))}catch(e){throw Z(`marketplace_invalid`,`The official marketplace manifest is not valid UTF-8.`,e)}}}if(l===void 0||u===void 0)return;let d;try{d=JSON.parse(u)}catch(e){throw Z(`marketplace_invalid`,`The official marketplace manifest is not valid JSON.`,e)}return oz(d,o,l,r)}function oz(e,t=`${Oz.join(`/`)}`,n=`${t}/marketplace.json`,r=[]){if(!Y(e)||e.name!==`openai-curated`)throw Z(`marketplace_invalid`,`The reserved official marketplace manifest has an unexpected name.`);sz(e);let i=e.plugins;if(!Array.isArray(i)||i.length===0)throw Z(`marketplace_invalid`,`The official marketplace manifest has no plugin entries.`);let a=[],o=new Set;for(let e of i){if(!Y(e)||typeof e.name!=`string`){if(r.length>0)continue;throw Z(`marketplace_invalid`,`The official marketplace contains a malformed plugin entry.`)}let t=e.name;if(!/^[a-z][a-z0-9._-]{1,63}$/u.test(t)){if(r.length>0)continue;throw Z(`marketplace_invalid`,`The official marketplace contains an invalid plugin name.`)}if(o.has(t)){if(r.length>0&&!r.includes(t))continue;throw Z(`marketplace_invalid`,`The official marketplace contains a duplicate plugin name.`)}if(o.add(t),r.length>0&&!r.includes(t))continue;let n=cz(e);if(!lz(n))throw Z(`marketplace_invalid`,`The official marketplace source for ${t} is unsafe.`);a.push({name:t,source:n})}if(r.some(e=>!a.some(t=>t.name===e)))throw Z(`marketplace_invalid`,`The official marketplace is missing a selected plugin entry.`);return{name:Ez,source:Dz,rootPath:t,manifestPath:n,plugins:a}}function sz(e){for(let t of[`source`,`repository`,`repo`,`url`]){let n=e[t];if(n!==void 0&&(typeof n==`string`?n:Y(n)&&typeof n.url==`string`?n.url:void 0)!==`https://github.com/openai/plugins.git`)throw Z(`marketplace_invalid`,`The reserved official marketplace source is not the approved OpenAI repository.`)}}function cz(e){let t=e.source;if(typeof t==`string`)return t;if(Y(t)&&typeof t.path==`string`)return t.path;if(typeof e.path==`string`)return e.path}function lz(e){if(e===void 0||e.length===0||g(e)||/^[A-Za-z]:[\\/]/u.test(e))return!1;let t=e.replaceAll(`\\`,`/`);return t.startsWith(`/`)||/^[A-Za-z][A-Za-z0-9+.-]*:/u.test(t)?!1:t.split(`/`).every(e=>e.length===0||e===`.`||e!==`..`)}function uz(e){let t=[],n=new Set;for(let r of e){let e=r.lastIndexOf(`@`);if(e<1)continue;let i=r.slice(e+1);if(i!==`openai-curated`&&i!==`openai-curated-remote`)continue;let a=r.slice(0,e);if(!/^[a-z][a-z0-9._-]{1,63}$/u.test(a))throw Z(`marketplace_invalid`,`A selected official marketplace plugin id is invalid.`);yz(a)&&(n.has(a)||(n.add(a),t.push(a)))}return t}function dz(e,t){return t.every(t=>{let n=e.plugins.find(e=>e.name===t);return n!==void 0&&n.source.replaceAll(`\\`,`/`).replace(/\/+$/u,``).split(`/`).at(-1)===t})}async function fz(e){let t=AR(e.environment),n;try{n=new FR({executablePath:e.executablePath,environment:t,...e.signal===void 0?{}:{signal:e.signal}});let r=new OR(n,{requestTimeoutMs:Math.min(e.timeoutMs??kz,1e4),...e.signal===void 0?{}:{signal:e.signal}});return await r.initialize(),async()=>{await r.close()}}catch(e){throw await n?.close().catch(()=>void 0),e}}function pz(e,t){if(e!==void 0&&(!Number.isSafeInteger(e)||e<1||e>3e5))throw Z(`marketplace_invalid`,`The official marketplace timeout is invalid.`);if(t!==void 0&&(!Number.isSafeInteger(t)||t<0||t>6e4))throw Z(`marketplace_invalid`,`The official marketplace poll interval is invalid.`)}async function mz(e,n){let r=await s(e),i=await s(n),a=te(r,i);if(a===``||a===`..`||a.startsWith(`..${re}`))throw Z(`marketplace_invalid`,`The reserved official marketplace is outside CODEX_HOME.`);let o=ne(e),c=ne(n);for(;;){if((await t(c)).isSymbolicLink())throw Z(`marketplace_invalid`,`The reserved official marketplace path cannot contain symlinks.`);if(c===o)break;let e=h(c);if(e===c)throw Z(`marketplace_invalid`,`The reserved official marketplace path is outside CODEX_HOME.`);c=e}}function hz(e){return typeof e==`object`&&!!e&&`code`in e&&e.code===`ENOENT`}function gz(e){return typeof e==`object`&&!!e&&`code`in e&&(e.code===`EPERM`||e.code===`EACCES`)}async function _z(e){await new Promise(t=>setTimeout(t,e))}function Z(e,t,n){return new Lz(e,t,n instanceof Error?{cause:PR(n.message)}:{})}function vz(e,t){let n=vP(t);if(n===void 0||n!==t)return;let r=[...e.installed,...e.available].flatMap(e=>{let t=_P(e.pluginId,e.marketplaceName);return t?.canonicalPluginId===n?[{identity:t,entry:e}]:[]});return r.find(e=>e.entry.pluginId===n&&e.entry.installed)??r.find(e=>e.entry.installed)??r.find(e=>e.entry.pluginId===n)??r[0]}function yz(e){return TP.includes(e)}function bz(e){return PI(Iz,e)?OI(NI(Iz,e,`live official plugin list`)):DI(MI(`live official plugin list`,e))}function xz(e){let t=e.runner??Cz(e.executable,{environment:e.environment??AR(),...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.stdoutLimit===void 0?{}:{stdoutLimit:e.stdoutLimit},...e.stderrLimit===void 0?{}:{stderrLimit:e.stderrLimit}}),n=async()=>{let e=await t.run([`plugin`,`list`,`--json`]);if(e.exitCode!==0)throw Sz(`list`,e);let n;try{n=JSON.parse(e.stdout)}catch{throw new Lz(`command_failed`,`Codex returned invalid plugin data.`)}let r=bz(n);if(!r.ok)throw new Lz(`command_failed`,`Codex returned an invalid official plugin list.`);return r.value};return{list:n,ensureOfficialMarketplace:async t=>{if(e.codexHome===void 0)throw new Lz(`marketplace_unavailable`,`Codex home is unavailable; the official marketplace cannot be bootstrapped safely.`);await XR({codexHome:e.codexHome,executablePath:e.executable,selectedPluginIds:t,...e.environment===void 0?{}:{environment:e.environment},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.officialMarketplaceFallback===void 0?{}:{gitFallback:e.officialMarketplaceFallback}})},addMarketplace:async(e,n)=>{let r=NI(Pz,e,`plugin marketplace source`);if(r===`openai-curated`||r===`https://github.com/openai/plugins.git`)throw new Lz(`marketplace_invalid`,`The reserved openai-curated marketplace must be populated by Codex runtime startup; it cannot be added manually.`);let i=await t.run([`plugin`,`marketplace`,`add`,r],n===void 0?void 0:{signal:n});if(i.exitCode!==0&&!/already (?:exists|added)/iu.test(i.stderr))throw Sz(`marketplace add`,i,r)},add:async(e,r)=>{let i=NI(Pz,e,`official plugin id`),a=await t.run([`plugin`,`add`,i,`--json`],r===void 0?void 0:{signal:r});if(a.exitCode!==0)throw Sz(`add`,a,i);let o=await n(),s=vz(o,i),c=vP(i),l=[...o.installed,...o.available].filter(e=>e.pluginId===i&&(c===void 0||e.marketplaceName==null)),u=s?.entry??l.find(e=>e.installed)??l[0];if(!u)throw new Lz(`readback_mismatch`,`Codex did not report ${i} after installation.`,{plugin_id:i});if(!u.installed)throw new Lz(`plugin_missing`,`Codex reported ${i} as unavailable after installation.`,{plugin_id:i});if(!u.enabled)throw new Lz(`plugin_disabled`,`Codex installed ${i} but it is disabled; enable it in Codex and retry.`,{plugin_id:i})},remove:async(e,r)=>{let i=NI(Pz,e,`official plugin id`),a=i;if(vP(i)===i){let e=vz(await n(),i);e?.entry.installed&&(a=e.entry.pluginId)}let o=await t.run([`plugin`,`remove`,a,`--json`],r===void 0?void 0:{signal:r});if(o.exitCode!==0&&!/not (?:installed|found)|missing/iu.test(o.stderr))throw Sz(`remove`,o,a);let s=await n(),c=[...s.installed,...s.available].find(e=>e.pluginId===a);if(c?.installed)throw new Lz(`readback_mismatch`,`Codex still reports ${i} after removal.`,{plugin_id:i,observed_plugin_id:c.pluginId})}}}function Sz(e,t,n){let r=PR(t.stderr).trim().slice(0,512),i=r.length>0?`: ${r}`:``;return new Lz(`command_failed`,`Codex plugin ${e} failed${n===void 0?``:` for ${n}`}${i}`,{exit_code:t.exitCode})}function Cz(e,t){let n=t.timeoutMs??3e4,r=t.stdoutLimit??131072,i=t.stderrLimit??16384;return{run:(a,o)=>wz(e,a,{...t.environment===void 0?{}:{environment:t.environment},timeoutMs:o?.timeoutMs??n,stdoutLimit:r,stderrLimit:i,...o?.cwd===void 0?{}:{cwd:o.cwd},...o?.signal===void 0?{}:{signal:o.signal}})}}async function wz(e,t,n){if(n.signal?.aborted)throw new Lz(`cancelled`,`The Codex plugin command was cancelled.`);let r=ae(e,[...t],{env:n.environment===void 0?void 0:{...n.environment},...n.cwd===void 0?{}:{cwd:n.cwd},stdio:[`ignore`,`pipe`,`pipe`],windowsHide:!0}),i=Tz(r.stdout,n.stdoutLimit),a=Tz(r.stderr,n.stderrLimit),o=new Promise((e,t)=>{r.once(`error`,t),r.once(`close`,t=>e(t??-1))}),s,c,l=new Promise((e,t)=>{c=()=>{try{r.kill()}catch{}t(new Lz(`cancelled`,`The Codex plugin command was cancelled.`))},n.signal?.addEventListener(`abort`,c,{once:!0})}),u=new Promise((e,t)=>{s=setTimeout(()=>{try{r.kill()}catch{}t(new Lz(`timeout`,`The Codex plugin command timed out.`))},n.timeoutMs)});try{let[e,t,n]=await Promise.race([Promise.all([i,a,o]),l,u]);return{stdout:e,stderr:t,exitCode:n}}catch(e){try{r.kill()}catch{}throw e instanceof Lz?e:new Lz(`command_failed`,`The Codex plugin command failed.`)}finally{s!==void 0&&clearTimeout(s),c!==void 0&&n.signal?.removeEventListener(`abort`,c)}}function Tz(e,t){return e===null?Promise.reject(new Lz(`command_failed`,`Codex plugin command output is unavailable.`)):new Promise((n,r)=>{let i=[],a=0;e.on(`data`,e=>{let n=typeof e==`string`?new TextEncoder().encode(e):e instanceof Uint8Array?e:void 0;if(n===void 0){r(new Lz(`command_failed`,`Codex plugin output was invalid.`));return}if(a+=n.byteLength,a>t){r(new Lz(`output_limit`,`Codex plugin output exceeded its limit.`));return}i.push(n)}),e.once(`end`,()=>{let e=new Uint8Array(a),t=0;for(let n of i)e.set(n,t),t+=n.byteLength;try{n(new TextDecoder(`utf-8`,{fatal:!0}).decode(e))}catch(e){r(e)}}),e.once(`error`,e=>r(e))})}var Ez,Dz,Oz,kz,Az,jz,Mz,Nz,Pz,Fz,Iz,Lz,Rz=v((()=>{uI(),pP(),kR(),zI(),IR(),Ez=`openai-curated`,Dz=`https://github.com/openai/plugins.git`,Oz=[`plugins`,`openai-plugins`],kz=3e4,Az=100,jz=K.pipe(CM(/^[a-z][a-z0-9._-]{1,63}$/u)),Mz=K.pipe(CM(/^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][A-Za-z0-9.-]+)?$/u)),Nz=Vj(K),Pz=K.pipe(CM(/^[A-Za-z0-9][A-Za-z0-9._:@/-]{0,255}$/u)),W({name:jz,version:Mz,description:RI,author:J(II),license:J(RI),homepage:J(RI),repository:J(RI),keywords:J(Nz),skills:J(Nz),commands:J(Nz),hooks:J(Nz),assets:J(Nz),official:J(q)}),W({id:jz,selected:H(!0)}),Fz=W({pluginId:Pz,installed:q,enabled:q,name:J(U(K,Aj)),marketplaceName:J(U(K,Aj)),version:J(U(K,Aj))},oM({key:K,value:Mj})),Iz=W({installed:Vj(Fz),available:Vj(Fz)}),Lz=class extends Error{code;details;constructor(e,t,n={}){super(t),this.name=`OfficialPluginAdapterError`,this.code=e,this.details=n}}})),zz=v((()=>{zI(),KI(),CR(),kR(),IR(),UR(),JR(),YR(),DL(),Rz()}));function Bz(e){if(!Vz(e))throw Error(`The value is not JSON serializable.`);return _F(e),e}function Vz(e,t=new Set){if(e===null||typeof e==`string`||typeof e==`boolean`)return!0;if(typeof e==`number`)return Number.isFinite(e);if(typeof e!=`object`||t.has(e))return!1;t.add(e);try{return Array.isArray(e)?e.every(e=>Vz(e,t)):Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(e=>Vz(e,t))}finally{t.delete(e)}}var Hz=v((()=>{uI()}));function Uz(e,t){let n=mP(e,t);return tr(n)?n.right:void 0}function Wz(e){return Uz(Gz,e)!==void 0}var Gz,Kz,qz,Jz,Yz,Xz,Zz,Qz,$z,eB,tB,nB,rB,iB,aB,oB,sB,cB,lB,uB,dB,fB,pB=v((()=>{zz(),uI(),lr(),pP(),Hz(),Gz=G(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Vz(e)),G(Vz),Kz=K.pipe(CM(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u)),qz=K.pipe(CM(/^[0-9a-f]{64}$/u)),Jz=K.pipe(CM(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u)),Yz=K.pipe(CM(/^[A-Za-z0-9][A-Za-z0-9._:@/-]{0,255}$/u)),Xz=K.pipe(pj(e=>!Number.isNaN(Date.parse(e)))),Zz=W({path:K.pipe(CM(/^[A-Za-z0-9][A-Za-z0-9._/-]{0,255}$/u)),digest:qz}),Qz=W({computer_use:q,work:q,frontend:q,security:q,coding:H(!0)}),$z=W({computer_use:J(q),work:J(q),frontend:J(q),security:J(q)}),eB=W({plan:J(eF),tier:J(nF),optional:J($z),officialPlugins:J(Vj(Yz))}),tB=W({selected:q,status:H(`disabled`,`pending`,`healthy`,`missing`,`provider_disabled`,`uncertain`,`unavailable`),plugin_ids:Vj(Yz),reason:J(K)}),nB=W({computer_use:tB,work:tB,frontend:tB,security:tB}),rB=W({presence:H(`absent`,`present`),digest:qz,safe_value:J(U(W({kind:H(`boolean`),value:q}),W({kind:H(`marketplace`),source_type:H(`git`),source:H(`https://github.com/davidbasilefilho/holycodex.git`)})))}),iB=W({plugin_id:H(`holycodex@holycodex`),before:W({preference:rB,marketplace:rB}),after:W({preference:rB,marketplace:rB})}),aB=W({presence:H(`absent`,`present`),digest:qz,safe_value:J(W({kind:H(`boolean`),value:q}))}),oB=W({plugin_id:Yz,before:aB,after:aB}),sB={owner:H(`holycodex`),schema_epoch:H(pe),install_id:Jz,version:Kz,digest:qz,plan:eF,tier:nF,optional_selections:Qz,explicit_optional_selections:$z,official_plugins:J(Vj(Yz)),capability_state:J(nB),managed_artifacts:Vj(Zz),installed_at:Xz,status:J(H(`active`)),step:J(H(`active`)),managed_config:J(TL),plugin_snapshot:J(Vj(W({plugin_id:Yz,status:H(`installed`,`available`,`missing`,`disabled`,`uncertain`,`unknown`)}))),plugin_config:J(iB),provider_config:J(Vj(oB)),owned_plugins:J(Vj(Yz))},cB=W(sB),lB=W({...sB,plan:U(eF,H(`Go`))}),uB=H(`preparing`,`conflicted`),dB=H(`validated`,`plugins_snapshotted`,`roles_prepared`,`plugins_installed`,`config_published`,`verified`,`conflicted`),fB=W({...cB.fields,status:uB,step:dB})}));function mB(e={},t=process.env){let n=se(),r=hB(e.paths?.codexHome??t.CODEX_HOME??_(n,`.codex`),`CODEX_HOME`),i=_(r,CB);return{codexHome:r,stateRoot:i,activeRecord:_(i,wB),preparingRecord:_(i,TB),conflictedRecord:_(i,EB),roleRoot:_(i,`agents`),configFile:_(r,`config.toml`)}}function hB(e,t,n=process.platform===`win32`?`win32`:`posix`){if(typeof e!=`string`||gB(e))throw new OB(`invalid_path`,`${t} contains invalid characters.`);let r=n===`win32`?ie:ee,i=xB(e,n);if(typeof i!=`string`||i.length===0||!r.isAbsolute(i))throw new OB(`invalid_path`,`${t} must be an absolute path.`);let a=r.normalize(i);if(a.split(n===`win32`?`\\`:re).filter(e=>e.length>0).length===0||a===r.dirname(a))throw new OB(`broad_path`,`${t} is too broad.`);if(i.split(/[\\/]/u).some(e=>e===`..`))throw new OB(`invalid_path`,`${t} cannot contain traversal.`);return r.resolve(a)}function gB(e){for(let t of e){let e=t.codePointAt(0)??0;if(e<=31||e===127)return!0}return!1}async function _B(e){hB(e,`owned path`),await vB(e),await n(e,{recursive:!0}),await vB(e)}async function vB(e){let n=ne(e);for(;;){try{if((await t(n)).isSymbolicLink())throw new OB(`path_symlink`,`A managed path cannot contain a symlink.`)}catch(e){if(e instanceof OB||!SB(e,`ENOENT`))throw e}let e=h(n);if(e===n)break;n=e}}async function yB(e){await vB(e)}function bB(e,t,n=process.platform===`win32`?`win32`:`posix`){let r=n===`win32`?ie:ee,i=r.resolve(xB(e,n)),a=r.resolve(xB(t,n)),o=r.relative(i,a);return o.length>0&&!o.startsWith(`..${n===`win32`?`\\`:re}`)&&o!==`..`&&!r.isAbsolute(o)}function xB(e,t){return t===`win32`&&/^\/[A-Za-z](?:\/|$)/u.test(e)?`${e[1]?.toUpperCase()??``}:${e.slice(2).replaceAll(`/`,`\\`)}`:e}function SB(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}var CB,wB,TB,EB,DB,OB,kB=v((()=>{uI(),CB=`holycodex`,wB=`active.json`,TB=`preparing.json`,EB=`conflicted.json`,DB=pe,OB=class extends Error{code;constructor(e,t){super(t),this.name=`PathBoundaryError`,this.code=e}}}));async function AB(e){let t;try{t=await i(e,`r`),await t.sync()}catch(e){if(!LB(e))throw e}finally{await t?.close().catch(()=>void 0)}}async function jB(e){await AB(e).catch(e=>{if(!LB(e))throw e})}async function MB(e,t){await NB(e,`${_F(t)}\n`)}async function NB(e,t){let n=h(e);await _B(n),await vB(e);let r=`${e}.tmp-${process.pid}-${crypto.randomUUID()}`;try{await p(r,t,{encoding:`utf8`,mode:384}),await AB(r),await c(r,e),await jB(n)}catch(e){throw await f(r).catch(()=>void 0),e}}async function PB(e,n){let r=await t(e);if(!r.isFile()||r.isSymbolicLink())throw new zB(`state_corrupt`,`A persisted file is not a regular file.`);let i;try{i=JSON.parse(await a(e,`utf8`))}catch(e){throw new zB(`state_corrupt`,`A persisted file is not valid JSON.`,e)}let o=Uz(n,i);if(o===void 0)throw new zB(`state_corrupt`,`A persisted file failed schema validation.`);return o}async function FB(e){try{let n=await t(e);if(!n.isFile()||n.isSymbolicLink())throw new zB(`state_corrupt`,`A persisted file is not a regular file.`);return await a(e,`utf8`)}catch(e){if(SB(e,`ENOENT`))return;throw e}}async function IB(e,t){try{return await PB(e,t)}catch(e){if(SB(e,`ENOENT`))return;throw e}}function LB(e){return typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?RB.has(e.code)||process.platform===`win32`&&e.code===`EPERM`:!1}var RB,zB,BB=v((()=>{uI(),kB(),pB(),RB=new Set([`EBADF`,`EINVAL`,`ENOSYS`,`ENOTSUP`,`EISDIR`]),zB=class extends Error{code;causeValue;constructor(e,t,n){super(t),this.name=`StorageError`,this.code=e,this.causeValue=n}}}));async function VB(e=JB){let t=JSON.parse(await a(e,`utf8`)),n=Uz(qB,t);if(n===void 0)throw new YB(`manifest_invalid`,`The public package manifest is invalid.`);return n}async function HB(e=JB){return(await VB(e)).version}async function UB(e=JB){return(await HB(e)).split(`-`,1)[0]??``}async function WB(e,t,n=JB){let r=await VB(n),i=await UB(n),a=GB(e,i);return t||await MB(n,{...r,version:a}),{previous:i,next:a}}function GB(e,t){if(e!==`patch`&&e!==`minor`){if(Uz(Kz,e)===void 0)throw new YB(`version_invalid`,`The version target is invalid.`);return e}let n=t.split(`.`),r=Number(n[1]),i=Number(n[2]);return e===`minor`?`0.${r+1}.0`:`0.${r}.${i+1}`}var KB,qB,JB,YB,XB=v((()=>{pP(),pB(),BB(),KB=K.pipe(CM(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-dev\.[1-9]\d*\.[1-9]\d*)?$/u)),qB=G(e=>Wz(e)&&e.name===`holycodex`&&Uz(KB,e.version)!==void 0),JB=ne(h(oe(import.meta.url)),`../package.json`),YB=class extends Error{code;constructor(e,t){super(t),this.name=`ManifestError`,this.code=e}}}));function ZB(e,t=`standard`){let n=eI(e);return n.ok?n.value.routes.map(e=>{let n={role:e.role,task:e.task};return{name:ZP(n),rolePolicy:rF.find(t=>t.role===e.role),description:$P(n),taskInstruction:QP(n),model:`gpt-5.6-luna`,effort:e.effort,serviceTier:t===`standard`?`default`:`fast`}}):[]}function QB(e,t=`standard`){let n=eI(e);if(!n.ok)throw Error(`Unknown plan.`);return{name:`root`,description:`Root-directed HolyCodex control agent.`,model:n.value.root.model===`Terra`?`gpt-5.6-terra`:`gpt-5.6-sol`,effort:n.value.root.effort,serviceTier:t===`fast-all`?`fast`:`default`}}function $B(e=!1){let t=[`You are the HolyCodex Root orchestrator.`,`Own user intent and scope; architecture, product, policy, and material choices; integration; external state and effects; Git/VCS; contradictory-evidence resolution; and final readiness.`,`Proceed autonomously with safe local inspection, implementation, and proportional verification inside approved scope. Use request_user_input for genuinely required information or approval, including material scope or product choices and destructive, remote, or externally consequential effects.`,`Delegate substantive specialist work when it has a bounded scope and observable completion. Apply writing-for-agents before dispatch; keep routine Root-owned inspection, synthesis, and coordination local.`,`Inspect returned evidence before integration. Use planning and review gates when architecture, scope, coordination, risk, or material choices justify them, including an adversarial Reviewer.code fixed-point gate for substantive implementation where appropriate.`];return e&&t.push(`Interactive GUI, browser, and Computer Use execution is Root-only and must not be delegated.`),t.join(`
|
|
82
|
-
`)}
|
|
83
|
-
`)
|
|
84
|
-
|
|
85
|
-
`)}
|
|
86
|
-
`)}function yV(e,t,n){let r=[],i=[];for(let[t,n]of Object.entries(e))DV(n)?i.push([t,n]):r.push([t,n]);t.length>0&&(n.length>0&&n.push(``),n.push(`[${t.map(OV).join(`.`)}]`));for(let[e,t]of r)n.push(`${OV(e)} = ${kV(t)}`);for(let[e,r]of i)yV(r,[...t,e],n)}function bV(e){if(e.length===0)throw Error(`TOML value is missing.`);if(e.startsWith(`"`)){let t=JSON.parse(e);if(typeof t!=`string`)throw Error(`TOML string is invalid.`);return t}if(e.startsWith(`'`)){if(!e.endsWith(`'`)||e.length<2)throw Error(`TOML string is invalid.`);return e.slice(1,-1)}if(e===`true`)return!0;if(e===`false`)return!1;if(e.startsWith(`[`)){if(!e.endsWith(`]`))throw Error(`TOML array is invalid.`);let t=e.slice(1,-1).trim();return t.length===0?[]:wV(t,`,`).map(bV)}if(e.startsWith(`{`)){if(!e.endsWith(`}`))throw Error(`TOML inline table is invalid.`);let t=e.slice(1,-1).trim(),n={};if(t.length===0)return n;for(let e of wV(t,`,`)){let t=TV(e);if(t<1)throw Error(`TOML inline table entry is invalid.`);SV(n,xV(e.slice(0,t).trim()),bV(e.slice(t+1).trim()))}return n}if(/^[+-]?(?:0|[1-9]\d*)(?:\.\d+)?$/u.test(e)){let t=Number(e);if(Number.isFinite(t))return t}throw Error(`TOML value is unsupported.`)}function xV(e){let t=wV(e,`.`).map(e=>e.trim());if(t.length===0||t.some(e=>!/^(?:[A-Za-z0-9_-]+|"(?:[^"\\]|\\.)*"|'[^']*')$/u.test(e)||e===`__proto__`||e===`constructor`||e===`prototype`))throw Error(`TOML key is invalid.`);return t.map(e=>e.startsWith(`"`)||e.startsWith(`'`)?bV(e):e)}function SV(e,t,n){if(t.length===0)throw Error(`TOML key is missing.`);let r=e;for(let e of t.slice(0,-1)){let t=r[e];if(t===void 0){let t={};r[e]=t,r=t}else if(DV(t))r=t;else throw Error(`TOML key conflicts with a scalar.`)}let i=t.at(-1);if(Object.prototype.hasOwnProperty.call(r,i))throw Error(`TOML key is duplicated.`);r[i]=n}function CV(e,t){let n=e;for(let e of t){let t=n[e];if(t===void 0){let t={};n[e]=t,n=t}else if(DV(t))n=t;else throw Error(`TOML table conflicts with a scalar.`)}}function wV(e,t){let n=[],r=0,i=0,a,o=!1;for(let s=0;s<e.length;s+=1){let c=e[s];if(a!==void 0){a===`"`&&o?o=!1:a===`"`&&c===`\\`?o=!0:c===a&&(a=void 0);continue}c===`"`||c===`'`?a=c:c===`[`||c===`{`?i+=1:c===`]`||c===`}`?--i:c===t&&i===0&&(n.push(e.slice(r,s)),r=s+1)}if(a!==void 0||i!==0)throw Error(`TOML value is unbalanced.`);return n.push(e.slice(r)),n}function TV(e){let t,n=!1,r=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(t!==void 0)t===`"`&&n?n=!1:t===`"`&&a===`\\`?n=!0:a===t&&(t=void 0);else if(a===`"`||a===`'`)t=a;else if(a===`[`||a===`{`)r+=1;else if(a===`]`||a===`}`)--r;else if(a===`=`&&r===0)return i}return-1}function EV(e){let t,n=!1;for(let r=0;r<e.length;r+=1){let i=e[r];if(t!==void 0)t===`"`&&n?n=!1:t===`"`&&i===`\\`?n=!0:i===t&&(t=void 0);else if(i===`"`||i===`'`)t=i;else if(i===`#`)return e.slice(0,r)}return e}function DV(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function OV(e){return/^[A-Za-z0-9_-]+$/u.test(e)?e:JSON.stringify(e)}function kV(e){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`boolean`||typeof e==`number`){if(typeof e==`number`&&!Number.isFinite(e))throw Error(`TOML number is invalid.`);return String(e)}if(Array.isArray(e))return`[${e.map(kV).join(`, `)}]`;throw Error(e===null?`TOML null is not serializable.`:`TOML nested values must be tables.`)}var AV=v((()=>{})),jV=le({doctorHolyCodex:()=>MV,removeHolyCodex:()=>NV});async function MV(e={},t=process.env){let n=mB(e,t),r={};try{await yB(n.codexHome),await yB(n.stateRoot),r.paths=zV({state_root:n.stateRoot})}catch(e){r.paths=BV([`path_symlink`],{error:HV(e)})}let[i,a,o]=await Promise.all([GV(n).catch(e=>{r.configuration=BV([`state_corrupt`],{error:HV(e)})}),IB(n.preparingRecord,fB).catch(e=>{r.transaction=BV([`state_corrupt`],{path:n.preparingRecord,error:HV(e)})}),IB(n.conflictedRecord,fB).catch(e=>{r.transaction=BV([`state_corrupt`],{path:n.conflictedRecord,error:HV(e)})})]);if(a!==void 0&&r.transaction?.status!==`failed`&&(r.transaction=BV([`incomplete_install_state`])),o!==void 0&&r.transaction?.status!==`failed`&&(r.transaction=BV([`conflicted_state`])),r.configuration||=i?await OH(i)?zV({plan:i.plan,tier:i.tier,install_id:i.install_id}):BV([`configuration_changed`],{path:n.activeRecord}):BV([`configuration_missing`]),i){r.runtime_config=await PV(n,i),r.native_roles=await FV(n,i.plan,i.tier);let e=Object.entries(i.capability_state??{}).find(([,e])=>e.selected&&e.status!==`healthy`);e&&(r.capabilities=BV([`selected_capability_not_healthy`],{capability:e[0],status:e[1].status}))}try{let e=await FB(`${n.codexHome}/agents/root.toml`);if(e!==void 0&&aV(e)){let e=r.native_roles;r.native_roles={status:`failed`,reasons:[...e?.reasons??[],`stale_legacy_root`],details:{...e?.details,path:`${n.codexHome}/agents/root.toml`}}}}catch(e){r.native_roles=BV([`native_role_invalid`],{error:HV(e)})}let s=e.officialPluginManager??await mV.discover({...t,CODEX_HOME:n.codexHome}).catch(()=>void 0);if(i&&s?.status){let e=[...new Set([MH,...SP({computer_use:i.optional_selections.computer_use,work:i.optional_selections.work,frontend:i.optional_selections.frontend,security:i.optional_selections.security},i.official_plugins),...i.owned_plugins??[]])];try{let t=await s.status(e),n=Object.entries(t).filter(([,e])=>e!==`installed`).map(([e])=>e),i=s.getObservedIdentities?.()??{};r.native_plugins=n.length===0?zV({status:t,observed_identities:i}):BV([`native_plugin_disagreement`],{missing:n,status:t,observed_identities:i})}catch(e){r.native_plugins=BV([`native_plugin_status_failed`],{error:HV(e)})}}else r.native_plugins={status:`unsupported`,reasons:[`native_plugin_manager_unavailable`],details:{}};let c=Object.values(r).flatMap(e=>e.reasons);return{healthy:Object.values(r).every(e=>e.status!==`failed`),checks:r,reasons:[...new Set(c)]}}async function NV(e={},t=process.env){let n=mB(e,t);await yB(n.codexHome),await yB(n.stateRoot);let r=await GV(n),[i,a]=await Promise.all([IB(n.preparingRecord,fB),IB(n.conflictedRecord,fB)]),o=a??i??r,s=new Set(RV(o)),c=[],d=[],f=[];if(r&&!await OH(r))return d.push(n.activeRecord),f.push(`configuration_changed`),{removed:c,preserved:d,reasons:f};let p=await FB(n.configFile),m=qV(p);if(o?.managed_config){let e=await xL(m,o.managed_config,{schema:o.managed_config.schema,installId:o.managed_config.installId});if(e.preservedKeys.length>0||e.unresolvedKeys.length>0)return d.push(n.configFile),f.push(`managed_config_changed`),await IV(n,o),{removed:c,preserved:d,reasons:f}}if(o?.plugin_config&&(await ZV(m,o.plugin_config)).preserved.length>0)return d.push(n.configFile),f.push(`plugin_config_changed`),await IV(n,o),{removed:c,preserved:d,reasons:f};if(o?.provider_config&&(await QV(m,o.provider_config,s)).preserved.length>0)return d.push(n.configFile),f.push(`provider_config_changed`),await IV(n,o),{removed:c,preserved:d,reasons:f};let h;try{h=e.officialPluginManager??await mV.discover({...t,CODEX_HOME:n.codexHome})}catch(e){throw new Q(`capability_denied`,`Native Codex plugin removal is unavailable.`,e,{recovery:`Install or expose Codex, then retry.`})}if(h===void 0||!h.remove||!h.list)throw new Q(`capability_denied`,`Native Codex plugin removal and readback are unavailable.`);let g=await nV(n.codexHome,o?.managed_artifacts??[]);c.push(...g.removed),d.push(...g.preserved),g.preserved.length>0&&f.push(`managed_artifact_changed`);for(let e of s)try{let t=vz(await h.list(),e),n=t?.entry.installed?t.entry.pluginId:e;await h.remove(n);let r=await h.list();if(vz(r,e)?.entry?.installed===!0||[...r.installed,...r.available].some(t=>t.pluginId===e&&t.installed))throw new Q(`capability_denied`,`Codex still reports ${e} after removal.`);c.push(e)}catch(t){throw f.push(`native_plugin_remove_failed`),await IV(n,o??LV()),new Q(`capability_denied`,`Codex native plugin removal did not converge for ${e}: ${HV(t)}`,t)}if(g.preserved.length>0)return await IV(n,o??LV()),{removed:c,preserved:d,reasons:f};let _;try{let e=qV(await FB(n.configFile)),t=o?.managed_config;if(t){let r=await xL(e,t,{schema:t.schema,installId:t.installId});if(r.preservedKeys.length>0||r.unresolvedKeys.length>0)return d.push(n.configFile),f.push(`managed_config_changed`),await IV(n,o??LV()),{removed:c,preserved:d,reasons:f};e=r.document,t=r.state}if(o?.plugin_config){let t=await ZV(e,o.plugin_config,{allowBeforeState:!0});if(t.preserved.length>0)return d.push(n.configFile),f.push(`plugin_config_changed`),await IV(n,o),{removed:c,preserved:d,reasons:f};e=t.document}if(o?.provider_config){let t=await QV(e,o.provider_config,s,{allowBeforeState:!0});if(t.preserved.length>0)return d.push(n.configFile),f.push(`provider_config_changed`),await IV(n,o),{removed:c,preserved:d,reasons:f};e=t.document}(o?.managed_config||o?.plugin_config||o?.provider_config)&&(_=t===void 0?{document:e}:{document:e,state:t}),_!==void 0&&(Object.keys(_.document).length===0&&p===void 0?await l(n.configFile,{force:!1}):await NB(n.configFile,JV(_.document)))}catch(e){if(e instanceof Q)throw await IV(n,o??LV()),e;return d.push(n.configFile),f.push(`managed_config_write_failed`),await IV(n,o??LV()),{removed:c,preserved:d,reasons:f}}if(r)try{await l(n.activeRecord,{force:!1}),c.push(n.activeRecord)}catch(e){if(SB(e,`ENOENT`))c.push(n.activeRecord);else return d.push(n.activeRecord),f.push(`state_remove_failed`),await IV(n,o??r),{removed:c,preserved:d,reasons:f}}if(d.length===0){for(let[e,t]of[[n.preparingRecord,i!==void 0],[n.conflictedRecord,a!==void 0]])if(t)try{await VV(e),c.push(e)}catch{d.push(e),f.push(`state_remove_failed`)}}if(d.length===0)try{await u(n.roleRoot),c.push(n.roleRoot)}catch(e){SB(e,`ENOENT`)||(d.push(n.roleRoot),f.push(`role_directory_not_empty`))}if(d.length===0)try{await u(n.stateRoot),c.push(n.stateRoot)}catch(e){SB(e,`ENOENT`)?c.push(n.stateRoot):(d.push(n.stateRoot),f.push(`state_directory_not_empty`))}return{removed:c,preserved:d,reasons:f}}async function PV(e,t){if(!t.managed_config)return BV([`incomplete_install_state`]);try{let n=qV(await FB(e.configFile)),r=oH(t.plan,t.tier,t.optional_selections.computer_use),i=[];for(let[e,a]of Object.entries(r))((await SL(n,t.managed_config,e)).status!==`unchanged`||e!==`developer_instructions`&&ZI(n,e)!==a)&&i.push(e);return i.length===0?zV({managed_keys:Object.keys(r).length}):BV([`changed_holycodex_config`],{keys:i})}catch(e){return BV([`config_unreadable`],{error:HV(e)})}}async function FV(e,t,n){try{let r=qV(await FB(e.configFile)),i=[];for(let a of ZB(t,n)){let t=ZI(r,`agents."${a.name}".config_file`),o=`${e.roleRoot}/${a.name}.toml`.replaceAll(`\\`,`/`);if(typeof t!=`string`||hL(e.configFile,t).replaceAll(`\\`,`/`)!==o){i.push(`${a.name}:registration`);continue}let s=await FB(`${e.roleRoot}/${a.name}.toml`);if(s===void 0){i.push(`${a.name}:missing`);continue}if(s!==rV(a)){i.push(`${a.name}:changed`);continue}let c=qV(s);(c.name!==a.name||typeof c.description!=`string`||typeof c.developer_instructions!=`string`||c.model!==`gpt-5.6-luna`||c.model_reasoning_summary!==`none`||c.model_verbosity!==`low`||c.tool_output_token_limit!==void 0||c.service_tier!==(n===`standard`?`default`:`fast`)||c.sandbox_mode!==(a.rolePolicy.permissions.write?`workspace-write`:`read-only`)||c.approval_policy!==`never`||c.web_search!==(a.rolePolicy.permissions.network?`live`:`disabled`)||ZI(c,`agents.enabled`)!==!1||ZI(c,`features.multi_agent_v2`)!==!1||ZI(c,`features.multi_agent`)!==!1||ZI(c,`features.computer_use`)!==!1||ZI(c,`features.browser_use`)!==!1||ZI(c,`features.in_app_browser`)!==!1)&&i.push(`${a.name}:malformed`)}let a=await FB(`${e.codexHome}/agents/root.toml`);return a!==void 0&&aV(a)&&i.push(`root:stale`),i.length===0?zV({role_root:e.roleRoot,agent_types:ZB(t,n).map(e=>e.name)}):BV([`native_role_disagreement`],{roles:i})}catch(e){return BV([`native_role_invalid`],{error:HV(e)})}}async function IV(e,t){let n={...t,status:`conflicted`,step:`conflicted`,managed_config:t.managed_config??{owner:`holycodex`,schema:t.schema_epoch,installId:t.install_id,managed:{}},plugin_snapshot:t.plugin_snapshot??[],owned_plugins:t.owned_plugins??[]};Uz(fB,n)!==void 0&&await MB(e.conflictedRecord,Bz(n))}function LV(){return{owner:`holycodex`,schema_epoch:`state-0.16`,install_id:`remove-conflict`,version:`0.0.0`,digest:`0`.repeat(64),plan:`plus`,tier:`standard`,optional_selections:{computer_use:!1,work:!1,frontend:!1,security:!1,coding:!0},explicit_optional_selections:{},managed_artifacts:[],installed_at:new Date(0).toISOString()}}function RV(e){if(e?.owned_plugins!==void 0)return[...new Set(e.owned_plugins)];let t=(e?.plugin_snapshot??[]).filter(e=>e.plugin_id!==`holycodex@holycodex`&&e.status!==`installed`).map(e=>e.plugin_id);return[...new Set([MH,...t])]}function zV(e){return{status:`healthy`,reasons:[],details:e}}function BV(e,t={}){return{status:`failed`,reasons:e,details:t}}async function VV(e){await l(e,{force:!1}).catch(e=>{if(!SB(e,`ENOENT`))throw e})}function HV(e){return e instanceof Error?e.message.slice(0,256):`operation failed`}var UV=v((()=>{zz(),uI(),LH(),Hz(),fV(),gV(),kB(),pB(),BB()}));async function WV(e={},t={},n=process.env){if(Uz(eB,e)===void 0)throw new Q(`install_failed`,`The installation options are invalid.`);let r=mB(t,n);await _B(r.stateRoot);let i=await IB(r.preparingRecord,fB),a=await IB(r.conflictedRecord,fB)??i;if(a!==void 0){let{removeHolyCodex:r}=await Promise.resolve().then(()=>(UV(),jV)),i=await r(t,n);if(i.preserved.length>0||i.reasons.length>0)throw new Q(`state_corrupt`,`The interrupted HolyCodex installation could not be reconciled safely.`,void 0,{preserved:i.preserved.join(`,`),reasons:i.reasons.join(`,`)});return await WV({plan:e.plan??a.plan,tier:e.tier??a.tier,optional:{computer_use:e.optional?.computer_use??a.optional_selections.computer_use,work:e.optional?.work??a.optional_selections.work,frontend:e.optional?.frontend??a.optional_selections.frontend,security:e.optional?.security??a.optional_selections.security},officialPlugins:e.officialPlugins??vH(a)},t,n)}let o=await GV(r);if(o!==void 0&&!await OH(o))throw new Q(`state_corrupt`,`The existing HolyCodex configuration has changed and cannot be replaced.`,void 0,{path:r.activeRecord});let s=CH(e.plan,o?.plan),c=wH(e.tier,o?.tier),l=TH(e.optional,o?.optional_selections),u=gH(o?.explicit_optional_selections,e.optional),d=e.officialPlugins??vH(o),f=[...new Set(SP(KV(l),d).map(e=>vP(e)??e))],p;try{p=t.officialPluginManager??await mV.discover({...n,CODEX_HOME:r.codexHome})}catch(e){throw new Q(`capability_denied`,`Native Codex plugin installation is unavailable.`,e,{recovery:`Install or expose Codex, then retry.`})}if(!p.addMarketplace||!p.add||!p.list)throw new Q(`install_failed`,`Native Codex plugin installation and verification are unavailable.`);let m;try{m=await p.list()}catch(e){throw new Q(`capability_denied`,`Native Codex plugin state could not be read safely.`,e)}let h=f.filter(e=>{if(vP(e)!==e)return!1;let t=SH(m,e);return!(t?.installed&&t.enabled)});if(p.ensureOfficialMarketplace!==void 0&&h.length>0)try{await p.ensureOfficialMarketplace(h)}catch(e){throw new Q(`capability_denied`,`The selected official Codex provider marketplace is unavailable: ${AH(e)}`,e,{recovery:`Check Codex network and marketplace policy, then retry.`})}let g=o?.install_id??crypto.randomUUID().replaceAll(`-`,``),_=await UB(),ee=(t.now?.()??new Date).toISOString(),te=await FB(r.configFile),ne=qV(te),re=o?.plugin_config?.before??await YV(ne),ie=[...new Set([...f,...(o?.provider_config??[]).map(e=>e.plugin_id),...o?.owned_plugins??[]])].filter(e=>e!==MH),ae=(await XV(ne,ie)).map(e=>{let t=o?.provider_config?.find(t=>t.plugin_id===e.plugin_id);return t===void 0?e:{plugin_id:e.plugin_id,before:t.before,after:t.before}}),oe=await cH(ne,o?.managed_config??fL({schema:`state-0.16`,installId:g}),o),se=oe.document,ce=oe.state;lH(se,ce);let v=oH(s,c,l.computer_use),le=await bL(se,ce,v,{schema:pe,installId:g});if(le.driftedKeys.length>0)throw new Q(`state_corrupt`,`HolyCodex-owned Codex settings changed and cannot be replaced safely.`,void 0,{keys:le.driftedKeys.join(`,`)});let ue;try{ue=await uH({list:()=>p.list()},[...new Set([MH,...f,...o?.owned_plugins??[]])])}catch(e){throw new Q(`capability_denied`,`Native Codex plugin state could not be read safely.`,e)}let de={owner:`holycodex`,schema_epoch:pe,install_id:g,version:_,digest:o?.digest??`0`.repeat(64),plan:s,tier:c,optional_selections:l,explicit_optional_selections:u,official_plugins:f,capability_state:EH(l),managed_artifacts:o?.managed_artifacts??[],installed_at:ee,status:`preparing`,step:`validated`,managed_config:le.state,plugin_snapshot:ue,plugin_config:{plugin_id:MH,before:re,after:re},provider_config:ae,owned_plugins:[...new Set(o?.owned_plugins??[])]};await dH(r.preparingRecord,de);let fe,me=!1,he=new Set,ge=new Set(o?.owned_plugins??[]),_e=new Set,y=de,ve=!1,b=!1,ye=te,x=le.state;try{await _B(r.roleRoot),fe=await eV(r.codexHome,s,o?.managed_artifacts,c),y={...de,step:`roles_prepared`,managed_artifacts:fe.managed_artifacts},await dH(r.preparingRecord,y),ve=!0,await p.addMarketplace(jH),await yH({list:()=>p.list(),add:e=>p.add(e)},[MH,...f],(e,t)=>{t===`new`?(he.add(e),ge.add(e),y={...y,owned_plugins:[...ge]}):(_e.add(e),ge.add(e),y={...y,owned_plugins:[...ge]})}),y={...y,step:`plugins_installed`},await dH(r.preparingRecord,y);let e=await FB(r.configFile);ye=e;let t=qV(e),n=await YV(t),i=(await XV(t,ie)).map(e=>({plugin_id:e.plugin_id,before:ae.find(t=>t.plugin_id===e.plugin_id)?.before??e.before,after:e.before}));await sH(t,se,ce,v);let a=await bL(t,ce,v,{schema:pe,installId:g});if(a.driftedKeys.length>0)throw new Q(`state_corrupt`,`HolyCodex-owned Codex settings changed during native plugin setup.`,void 0,{keys:a.driftedKeys.join(`,`)});b=!0,x=a.state,y={...y,managed_config:x,plugin_config:{plugin_id:MH,before:re,after:n},provider_config:i},await NB(r.configFile,JV(a.document)),me=!0,y={...y,step:`config_published`},await dH(r.preparingRecord,y),await mH(r,s,c,l.computer_use,x,fe.preserved);let d=EH(l),m=await DH({owner:`holycodex`,install_id:g,version:_,plan:s,tier:c,optional_selections:l,explicit_optional_selections:u,official_plugins:f,capability_state:d,managed_artifacts:fe.managed_artifacts,managed_config:x,plugin_config:{plugin_id:MH,before:re,after:n},provider_config:i,plugin_snapshot:ue,owned_plugins:[...ge]}),h={owner:`holycodex`,schema_epoch:pe,install_id:g,version:_,digest:m,plan:s,tier:c,optional_selections:l,explicit_optional_selections:u,official_plugins:f,capability_state:d,managed_artifacts:fe.managed_artifacts,installed_at:ee,status:`active`,step:`active`,managed_config:x,plugin_snapshot:ue,plugin_config:{plugin_id:MH,before:re,after:n},provider_config:i,owned_plugins:[...ge]};if(Uz(cB,h)===void 0)throw new Q(`state_corrupt`,`The HolyCodex configuration is invalid.`);return await MB(r.activeRecord,Bz(h)),await fH(r.preparingRecord),await fH(r.conflictedRecord),{record:h,optional_plugins:f,preserved:fe.preserved,warnings:fe.preserved.length===0?[]:[`modified managed files were preserved`]}}catch(e){let t=[];if(me)try{await pH(r.configFile,ye)}catch{t.push(`config`)}if(ve&&!b&&await FB(r.configFile).catch(()=>void 0)!==ye&&t.push(`config`),fe!==void 0)try{(await tV(fe.rollback)).preserved.length>0&&t.push(`roles`)}catch{t.push(`roles`)}_e.size>0&&t.push(...[..._e].map(e=>`plugin:${e}`));for(let e of he)try{await p.remove?.(e)}catch{t.push(`plugin:${e}`)}throw t.length>0?await dH(r.conflictedRecord,{...y,step:`conflicted`,status:`conflicted`}).catch(()=>void 0):await fH(r.preparingRecord).catch(()=>void 0),e instanceof OB||e instanceof Q?e:new Q(e instanceof hV||e instanceof IH?`capability_denied`:`install_failed`,AH(e),e,t.length>0?{recovery:`Resolve conflicted state before retrying.`}:{})}}async function GV(e){let t=await IB(e.activeRecord,Gz);if(t===void 0)return;let n=Uz(cB,t);if(n!==void 0)return n;let r=Uz(lB,t);if(r===void 0)throw new Q(`state_corrupt`,`The HolyCodex configuration is invalid.`);if(!await kH(r))throw new Q(`state_corrupt`,`The existing HolyCodex configuration has an invalid digest.`,void 0,{path:e.activeRecord});let i=KP(r.plan);return{...r,plan:i,digest:await DH({owner:r.owner,install_id:r.install_id,version:r.version,plan:i,tier:r.tier,optional_selections:r.optional_selections,explicit_optional_selections:r.explicit_optional_selections,official_plugins:r.official_plugins??[],capability_state:r.capability_state??null,managed_artifacts:r.managed_artifacts,...r.managed_config===void 0?{}:{managed_config:r.managed_config},...r.plugin_config===void 0?{}:{plugin_config:r.plugin_config},...r.provider_config===void 0?{}:{provider_config:r.provider_config},...r.plugin_snapshot===void 0?{}:{plugin_snapshot:r.plugin_snapshot},...r.owned_plugins===void 0?{}:{owned_plugins:r.owned_plugins}})}}function KV(e){return{computer_use:e.computer_use,work:e.work,frontend:e.frontend,security:e.security}}function qV(e){if(e===void 0||e.trim().length===0)return{};try{let t=globalThis.Bun,n=t?.TOML?.parse?t.TOML.parse(e):_V(e),r=Uz(CL,n);if(r===void 0)throw Error(`TOML document contains unsupported values.`);return r}catch(e){throw new Q(`state_corrupt`,`The Codex config.toml is not valid TOML.`,e)}}function JV(e){try{let t=globalThis.Bun;return`${(t?.TOML?.stringify?t.TOML.stringify(e):vV(e)).trimEnd()}\n`}catch(e){throw new Q(`install_failed`,`The merged Codex configuration is not writable.`,e)}}async function YV(e){return{preference:await $V(e,`plugins`,PH),marketplace:await $V(e,`marketplaces`,FH)}}async function XV(e,t){return await Promise.all(t.map(async t=>{let n=await $V(e,`plugins`,t),r={presence:n.presence,digest:n.digest,...n.safe_value?.kind===`boolean`?{safe_value:n.safe_value}:{}};return{plugin_id:t,before:r,after:r}}))}async function ZV(e,t,n={}){let r=e,i=[],a=[],o=[];for(let[s,c,l]of[[`preference`,`plugins`,PH],[`marketplace`,`marketplaces`,FH]]){let u=t.before[s],d=t.after[s],f=await $V(e,c,l);if(n.allowBeforeState!==!0||f.digest!==u.digest){if(f.digest!==d.digest){o.push(s);continue}if(u.presence===`absent`){f.presence===`present`&&(r=iH(r,c,l),a.push(s));continue}if(u.safe_value===void 0){o.push(s);continue}r=rH(r,c,l,nH(u.safe_value)),i.push(s)}}return{document:r,restored:i,removed:a,preserved:o}}async function QV(e,t,n,r={}){let i=e,a=[],o=[],s=[];for(let c of t){if(!n.has(c.plugin_id))continue;let t=c.before,l=c.after,u=await $V(e,`plugins`,c.plugin_id);if(r.allowBeforeState!==!0||u.digest!==t.digest){if(u.digest!==l.digest){s.push(c.plugin_id);continue}if(t.presence===`absent`){u.presence===`present`&&(i=iH(i,`plugins`,c.plugin_id),o.push(c.plugin_id));continue}if(t.safe_value===void 0){s.push(c.plugin_id);continue}i=rH(i,`plugins`,c.plugin_id,{enabled:t.safe_value.value}),a.push(c.plugin_id)}}return{document:i,restored:a,removed:o,preserved:s}}async function $V(e,t,n){let r=eH(e,t,n),i=await xF(`holycodex-plugin-config`,[vF(Bz({key:`${t}.${n}`,value:r===void 0?{presence:`absent`}:r}))]),a=tH(t,r);return{presence:r===void 0?`absent`:`present`,digest:i,...a===void 0?{}:{safe_value:a}}}function eH(e,t,n){let r=e[t];if(aH(r))return r[n]}function tH(e,t){if(!aH(t))return;let n=Object.keys(t);if(e===`plugins`)return n.length!==1||n[0]!==`enabled`||typeof t.enabled!=`boolean`?void 0:{kind:`boolean`,value:t.enabled};if(!(n.length!==2||!n.includes(`source_type`)||!n.includes(`source`)||t.source_type!==`git`||t.source!==NH))return{kind:`marketplace`,source_type:`git`,source:NH}}function nH(e){return e.kind===`boolean`?{enabled:e.value}:{source_type:e.source_type,source:e.source}}function rH(e,t,n,r){let i={...e},a=i[t];if(a!==void 0&&!aH(a))throw new Q(`state_corrupt`,`The ${t} Codex config table is invalid.`);return i[t]={...a,[n]:r},i}function iH(e,t,n){let r=e[t];if(!aH(r)||!Object.prototype.hasOwnProperty.call(r,n))return e;let i={...e},a={...r};return delete a[n],Object.keys(a).length===0?delete i[t]:i[t]=a,i}function aH(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function oH(e,t,n=!1){let r=QB(e,t),i={model:r.model,model_reasoning_effort:r.effort,service_tier:r.serviceTier,model_verbosity:`low`,developer_instructions:$B(n),suppress_unstable_features_warning:!0,"features.default_mode_request_user_input":!0,"features.multi_agent_v2":!0,"features.context_management.experimental_mode":!0};for(let e of pF)i[`agents."${e}".config_file`]=`holycodex/agents/${e}.toml`;return i}async function sH(e,t,n,r){let i=[];for(let a of Object.keys(r)){let r=a;if(n.managed[r]!==void 0){(await SL(e,n,r)).status===`drifted`&&i.push(r);continue}ZI(t,r)!==ZI(e,r)&&i.push(r)}if(i.length>0)throw new Q(`state_corrupt`,`Codex settings changed during native plugin setup.`,void 0,{keys:i.join(`,`)})}async function cH(e,t,n){let r=[`agents.explorer.config_file`,`agents.librarian.config_file`,`agents.worker.config_file`,`agents.reviewer.config_file`],i=Object.fromEntries(r.flatMap(e=>{let n=t.managed[e];return n===void 0?[]:[[e,n]]})),a=e,o=t;if(Object.keys(i).length>0){let n=await xL(e,{...t,managed:i},{schema:t.schema,installId:t.installId});if(n.preservedKeys.length>0||n.unresolvedKeys.length>0)throw new Q(`state_corrupt`,`Legacy HolyCodex agent registrations changed and cannot be migrated safely.`,void 0,{keys:[...new Set([...n.preservedKeys,...n.unresolvedKeys])].join(`,`)});a=n.document,o={...t,managed:Object.fromEntries(Object.entries(t.managed).filter(([e])=>!r.includes(e)))}}if(!n)return{document:a,state:o};let s=n.managed_artifacts.map(e=>e.path);for(let e of[`explorer`,`librarian`,`worker`,`reviewer`]){if(!s.some(t=>t.startsWith(`agents/${e[0]?.toUpperCase()}${e.slice(1)}.`)||t===`holycodex/agents/${e}.toml`))continue;let t=`agents.${e}.config_file`,n=ZI(a,t);if(typeof n!=`string`)continue;let r=n.replaceAll(`\\`,`/`).replace(/^\.\//u,``);(r===`agents/${e}.toml`||r===`holycodex/agents/${e}.toml`)&&(a=tL(a,t))}return{document:a,state:o}}function lH(e,t){if(ZI(e,`developer_instructions`)!==void 0&&t.managed.developer_instructions===void 0)throw new Q(`state_corrupt`,`Existing developer_instructions cannot be displaced safely; remove it or converge managed state first.`)}async function uH(e,t){let n=await e.list();return t.map(e=>{let t=SH(n,e);return{plugin_id:e,status:t===void 0?`missing`:t.installed&&t.enabled?`installed`:t.installed?`disabled`:`available`}})}async function dH(e,t){if(Uz(fB,t)===void 0)throw new Q(`state_corrupt`,`The HolyCodex transaction state is invalid.`);await MB(e,Bz(t))}async function fH(e){await l(e,{force:!1}).catch(e=>{if(!SB(e,`ENOENT`))throw e})}async function pH(e,t){if(t===void 0){await l(e,{force:!1}).catch(e=>{if(!SB(e,`ENOENT`))throw e});return}await NB(e,t)}async function mH(e,t,n,r,i,a=[]){let o=qV(await FB(e.configFile)),s=oH(t,n,r);for(let[e,t]of Object.entries(s)){let n=ZI(o,e);if(e===`developer_instructions`){if(typeof n!=`string`||await hH(e,n)!==i.managed[e]?.lastManagedValue.value)throw new Q(`install_failed`,`The effective Root instructions did not converge.`)}else if(n!==t)throw new Q(`install_failed`,`The effective Codex setting ${e} did not converge.`)}let c=ZB(t,n);for(let t of c){let n=ZI(o,`agents."${t.name}".config_file`);if(typeof n!=`string`)throw new Q(`install_failed`,`The ${t.name} registration is missing.`);let r=_(e.roleRoot,`${t.name}.toml`),i=r.replaceAll(`\\`,`/`);if(hL(e.configFile,n).replaceAll(`\\`,`/`)!==i)throw new Q(`install_failed`,`The ${t.name} registration is stale.`);let s=await FB(r);if(s===void 0)throw new Q(`install_failed`,`The ${t.name} role file is missing.`);if(a.includes(r))continue;let c=qV(s);if(c.name!==t.name||typeof c.description!=`string`||typeof c.model!=`string`||typeof c.model_reasoning_effort!=`string`||typeof c.service_tier!=`string`||typeof c.developer_instructions!=`string`||c.sandbox_mode!==(t.rolePolicy.permissions.write?`workspace-write`:`read-only`)||c.approval_policy!==`never`||c.web_search!==(t.rolePolicy.permissions.network?`live`:`disabled`)||c.tool_output_token_limit!==void 0||ZI(c,`agents.enabled`)!==!1||ZI(c,`features.multi_agent_v2`)!==!1||ZI(c,`features.multi_agent`)!==!1||ZI(c,`features.computer_use`)!==!1||ZI(c,`features.browser_use`)!==!1||ZI(c,`features.in_app_browser`)!==!1)throw new Q(`install_failed`,`The ${t.name} role file is malformed.`)}let l=await FB(`${e.codexHome}/agents/root.toml`);if(l!==void 0&&aV(l))throw new Q(`install_failed`,`A stale HolyCodex Root role remains installed.`)}async function hH(e,t){return await xF(`holycodex-managed-config-value`,[vF({keyPath:e,value:t})])}function gH(e,t){let n={};for(let r of[`computer_use`,`work`,`frontend`,`security`]){let i=t?.[r]??e?.[r];i!==void 0&&(n[r]=i)}return n}function _H(e){return[`computer_use`,`work`,`frontend`,`security`].find(t=>OP[t].pluginIds.includes(e))}function vH(e){return(e?.official_plugins??[]).filter(t=>{let n=_H(t);return n===void 0||e?.optional_selections[n]!==!0})}async function yH(e,t,n){for(let r of t){let t;try{t=SH(await e.list(),r)}catch(e){throw xH(`list`,e,r)}if(t?.installed&&!t.enabled)throw new IH(`uncertain`,`${r} is disabled`);let i=!(t?.installed&&t.enabled);if(!(t?.installed&&t.enabled))try{await e.add(r)}catch(i){try{let i=SH(await e.list(),r);bH(t,i)||n?.(r,`uncertain`)}catch{n?.(r,`uncertain`)}throw xH(`add`,i,r)}let a;try{a=SH(await e.list(),r)}catch(e){throw i&&n?.(r,`uncertain`),xH(`list`,e,r)}if(!a?.installed)throw i&&!bH(t,a)&&n?.(r,`uncertain`),new IH(`missing`,`${r} is not installed after add`);if(i&&a.enabled&&n?.(r,`new`),!a.enabled)throw i&&n?.(r,`new`),new IH(`uncertain`,`${r} is disabled after add`)}}function bH(e,t){return e?.pluginId===t?.pluginId&&e?.installed===t?.installed&&e?.enabled===t?.enabled&&e?.marketplaceName===t?.marketplaceName}function xH(e,t,n){return t instanceof hV?t:new hV(e===`list`?`list_failed`:`add_failed`,e===`list`?`Codex could not read the status of ${n}.`:`Codex could not add ${n}.`,t,{plugin_id:n})}function SH(e,t){let n=vz(e,t);if(n!==void 0)return n.entry;let r=vP(t);return[...e.installed,...e.available].find(e=>e.pluginId===t&&(r===void 0||e.marketplaceName==null))}function CH(e,t){let n=e??t??`plus`;if(!eI(n).ok)throw new Q(`install_failed`,`Unknown plan.`);return n}function wH(e,t){let n=e??t??`standard`;if(Uz(nF,n)===void 0)throw new Q(`install_failed`,`The tier is not supported.`);return n}function TH(e,t){let n=xP(e,t?KV(t):AP);return{computer_use:n.computer_use,work:n.work,frontend:n.frontend,security:n.security,coding:!0}}function EH(e,t=new Map){return Object.fromEntries([`computer_use`,`work`,`frontend`,`security`].map(n=>{let r=e[n];return[n,{selected:r,status:r?t.get(n)??`healthy`:`disabled`,plugin_ids:[...OP[n].pluginIds]}]}))}async function DH(e){return await xF(`install-record`,[vF(Bz(e))])}async function OH(e){return await kH(e)}async function kH(e){return await DH({owner:e.owner,install_id:e.install_id,version:e.version,plan:e.plan,tier:e.tier,optional_selections:e.optional_selections,explicit_optional_selections:e.explicit_optional_selections,official_plugins:e.official_plugins??[],capability_state:e.capability_state??null,managed_artifacts:e.managed_artifacts,...e.managed_config===void 0?{}:{managed_config:e.managed_config},...e.plugin_config===void 0?{}:{plugin_config:e.plugin_config},...e.provider_config===void 0?{}:{provider_config:e.provider_config},...e.plugin_snapshot===void 0?{}:{plugin_snapshot:e.plugin_snapshot},...e.owned_plugins===void 0?{}:{owned_plugins:e.owned_plugins}})===e.digest}function AH(e){return e instanceof Error?e.message.slice(0,256):`operation failed`}var jH,MH,NH,PH,FH,IH,Q,LH=v((()=>{zz(),uI(),Hz(),XB(),fV(),gV(),kB(),pB(),BB(),AV(),jH=`davidbasilefilho/holycodex`,MH=`holycodex@holycodex`,NH=`https://github.com/davidbasilefilho/holycodex.git`,PH=`holycodex@holycodex`,FH=`holycodex`,IH=class extends Error{status;constructor(e,t){super(t),this.name=`PluginVerificationError`,this.status=e}},Q=class extends Error{code;causeValue;details;constructor(e,t,n,r={}){super(t),this.name=`InstallerError`,this.code=e,this.causeValue=n,this.details=r}}}));uI(),LH(),Hz(),UV(),XB(),gV(),kB(),BB();async function RH(e,t={}){if(xI(e)||e[0]===`help`){let t=e[0]===`help`?e.slice(1).filter(e=>!e.startsWith(`-`))[0]:SI(e);return{envelope:XH(t===void 0?`help`:`${t} help`,{help:yI(t)}),exitCode:0}}let n;try{n=hI(e);let r=await zH(n,t);return{envelope:XH(n.command,r),exitCode:QH(n.command,r)}}catch(t){return ZH(n?.command??eU(e),t)}}async function zH(e,t){switch(e.command){case`install`:return Bz(await BH(e,t));case`doctor`:return Bz(await MV(YH(e,t),t.env));case`remove`:return Bz(await VH(e,t));case`version`:return Bz(await HH(e,t));case`help`:return{help:yI(e.positionals[0])};default:throw new yU(`invalid_argument`,`Unknown command.`)}}async function BH(e,t){let n=e.options.json===!0;if(!await UH(e,t,`Install HolyCodex into the selected Codex home?`))throw new yU(`non_tty_confirmation_required`,`Install requires --yes in non-interactive mode.`);rU(t,n,`Validating Codex target`),rU(t,n,`Installing HolyCodex`),rU(t,n,`Installing selected capabilities`),rU(t,n,`Configuring Root`),rU(t,n,`Installing subagent roles`);let r=await WV({...KH(e)===void 0?{}:{plan:KH(e)},...qH(e)===void 0?{}:{tier:qH(e)},...GH(e)===void 0?{}:{optional:GH(e)},...JH(e,`add-plugin`).length===0?{}:{officialPlugins:JH(e,`add-plugin`)}},YH(e,t),t.env);return rU(t,n,`Verifying installation`),rU(t,n,`HolyCodex installation complete`),r}async function VH(e,t){let n=e.options.json===!0;if(!await UH(e,t,`Remove HolyCodex-owned Codex state?`))throw new yU(`non_tty_confirmation_required`,`Remove requires --yes in non-interactive mode.`);rU(t,n,`Validating HolyCodex ownership`);let r=await NV(YH(e,t),t.env);return rU(t,n,`Removing HolyCodex-owned state`),rU(t,n,`HolyCodex removal complete`),r}async function HH(e,t){let n=e.positionals[0];return n?await WB(n,e.options[`dry-run`]===!0):{version:await HB()}}async function UH(e,t,n){return e.options.yes===!0?!0:e.options.json===!0||t.io?.stdoutIsTTY!==!0?!1:await WH(t,n)}async function WH(e,t){return e.io?.confirm?await e.io.confirm(t):!1}function GH(e){let t={};for(let n of[`computer_use`,`work`,`frontend`,`security`]){let r=n.replaceAll(`_`,`-`);e.options[r]===!0?t[n]=!0:(e.options[r]===!1||e.options[`no-${r}`]===!0)&&(t[n]=!1)}return Object.keys(t).length===0?void 0:t}function KH(e){let t=e.options.plan;if(typeof t!=`string`)return;let n=eI(t);return n.ok?n.value.name:void 0}function qH(e){let t=e.options.tier;return t===`standard`||t===`fast`||t===`fast-all`?t:void 0}function JH(e,t){let n=e.options[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`):[]}function YH(e,t){let n=t.installer??{},r=e.options[`codex-home`];return typeof r==`string`?{...n,paths:{...n.paths,codexHome:r},...t.now?{now:t.now}:{}}:{...n,...t.now?{now:t.now}:{}}}function XH(e,t){let n=TF({schema_version:fe,ok:!0,command:e,data:t,warnings:[]});if(!n.ok)throw new yU(`internal_error`,`The success envelope failed validation.`);return n.value}function ZH(e,t){let n=$H(t),r=TF({schema_version:fe,ok:!1,command:e,error:{code:n.code,message:n.message,details:n.details},warnings:[]});return r.ok?{envelope:r.value,exitCode:n.exitCode}:{envelope:{schema_version:fe,ok:!1,command:`internal-error`,error:{code:`internal_error`,message:`The CLI failure envelope was invalid.`,details:{}},warnings:[]},exitCode:5}}function QH(e,t){return e===`doctor`&&nU(t)&&t.healthy===!1?4:0}function $H(e){if(e instanceof mI)return{code:e.code,message:tU(e.message),details:e.details,exitCode:1};if(e instanceof yU)return{code:e.code,message:tU(e.message),details:{},exitCode:e.code===`internal_error`?5:1};if(e instanceof OB)return{code:`trust_boundary_failed`,message:tU(e.message),details:{},exitCode:4};if(e instanceof Q){let t=e.code===`capability_denied`?2:e.code===`state_corrupt`?4:3;return{code:e.code,message:tU(e.message),details:e.details,exitCode:t}}if(e instanceof hV){let t=[`timeout`,`output_limit`,`cancelled`,`readback_mismatch`].includes(e.code),n=e.code===`plugin_disabled`||e.code===`plugin_missing`||e.code===`command_failed`;return{code:t?`effect_uncertain`:n?`capability_denied`:`install_failed`,message:tU(e.message),details:e.details,exitCode:t?4:n?2:3}}return e instanceof zB?{code:e.code,message:tU(e.message),details:{},exitCode:4}:e instanceof YB?{code:e.code,message:tU(e.message),details:{},exitCode:1}:(e instanceof Error,{code:`internal_error`,message:`The command failed unexpectedly.`,details:{},exitCode:5})}function eU(e){return e.find(e=>!e.startsWith(`-`))??`unknown`}function tU(e){return Array.from(e).map(e=>{let t=e.codePointAt(0)??0;return t<=31||t===127?` `:e}).join(``).replace(/\s+/gu,` `).trim().slice(0,512)}function nU(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rU(e,t,n){t||e.io?.stderrIsTTY===!1||e.io?.writeStderr?.(`${aU(n,{stderrIsTTY:e.io?.stderrIsTTY,env:e.env})}\n`)}function iU(e,t={}){let n=CI(t);if(e.envelope.ok)return e.envelope.command===`version`?oU(e.envelope.data):e.envelope.command===`install`?sU(e.envelope.data,n):e.envelope.command===`remove`?cU(e.envelope.data,n):e.envelope.command===`doctor`?lU(e.envelope.data,n):`${$(`✔`,`green`,n)} ${$(e.envelope.command,`heading`,n)}\n${hU(e.envelope.data,n)}`;let r=e.envelope.error,i=vU(r.code,e.envelope.command);return[`${$(`✖`,`red`,n)} ${$(e.envelope.command,`heading`,n)}`,` ${$(r.code,`red`,n)}: ${r.message}`,...gU(r.details,n),...i===void 0?[]:[` hint: ${i}`],``].join(`
|
|
87
|
-
`)}
|
|
88
|
-
`}function sU(e,t){let n=uU(e,`record`),r=fU(n,`version`)??`unknown`,i=fU(n,`plan`)??`unknown`,a=fU(n,`tier`)??`unknown`,o=uU(n,`optional_selections`),s=uU(n,`capability_state`),c=[`frontend`,`security`,`work`,`computer_use`].filter(e=>o?.[e]===!0).map(e=>{let t=fU(uU(s,e),`status`);return t===void 0||t===`healthy`?e:`${e} (${t})`}),l=pU(e,`preserved`),u=pU(e,`warnings`),d=c.length===0?`none`:c.join(`, `),f=l.length===0?`none`:`${l.length} managed item${l.length===1?``:`s`} (review before retrying)`;return`${[`${$(`✔`,`green`,t)} ${$(`install`,`heading`,t)}`,` ${$(`version`,`option`,t)}: ${r}`,` ${$(`plan`,`option`,t)}: ${i}`,` ${$(`tier`,`option`,t)}: ${a}`,` ${$(`capabilities`,`option`,t)}: ${d}`,` ${$(`preserved`,`option`,t)}: ${f}`,...u.map(e=>` ${$(`warning`,`red`,t)}: ${mU(e)}`)].join(`
|
|
89
|
-
`)}\n`}function cU(e,t){let n=pU(e,`removed`),r=pU(e,`preserved`),i=pU(e,`reasons`),a=r.length===0?`none`:`${r.length} item${r.length===1?``:`s`} (review before retrying)`;return`${[`${$(`✔`,`green`,t)} ${$(`remove`,`heading`,t)}`,` ${$(`removed`,`option`,t)}: ${n.length} owned item${n.length===1?``:`s`}`,` ${$(`preserved`,`option`,t)}: ${a}`,...i.map(e=>` ${$(`reason`,`option`,t)}: ${mU(e)}`)].join(`
|
|
90
|
-
`)}\n`}function lU(e,t){let n=dU(e,`healthy`)===!0,r=uU(e,`checks`),i=r===void 0?[]:Object.entries(r),a=i.flatMap(([e,n])=>{let r=nU(n)?n:void 0,i=fU(r,`status`);if(i===void 0||i===`healthy`)return[];let a=pU(r,`reasons`);return[` ${$(e,`option`,t)}: ${a.length===0?i:a.map(mU).join(`, `)}`]});return`${[`${n?$(`✔`,`green`,t):$(`✖`,`red`,t)} ${$(`doctor`,`heading`,t)}`,` ${$(`status`,`option`,t)}: ${n?`healthy`:`needs attention`}`,` ${$(`checks`,`option`,t)}: ${i.length}`,...a.length===0?[]:[` ${$(`issues`,`option`,t)}:`,...a]].join(`
|
|
91
|
-
`)}\n`}function uU(e,t){if(nU(e))return nU(e[t])?e[t]:void 0}function dU(e,t){return nU(e)?e[t]:void 0}function fU(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function pU(e,t){return!nU(e)||!Array.isArray(e[t])?[]:e[t]}function mU(e){return typeof e==`string`?e.replaceAll(`_`,` `):`operation requires review`}function hU(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return` ${$(_U(e),`dim`,t)}\n`;let n=Object.entries(e);if(n.length===0)return``;let r=Math.max(...n.map(([e])=>e.length));return`${n.map(([e,n])=>` ${$(e.padEnd(r),`option`,t)}: ${_U(n)}`).join(`
|
|
92
|
-
`)}\n`}function gU(e,t){return Object.entries(e).map(([e,n])=>` ${$(e,`option`,t)}: ${$(_U(n),`dim`,t)}`)}function _U(e){return typeof e==`string`?e:e===null||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function vU(e,t){if(e===`invalid_argument`||e===`unknown_command`)return`holycodex ${t} --help`;if(e===`non_tty_confirmation_required`)return`rerun with --yes or use an interactive terminal`;if(e===`capability_denied`)return"run `holycodex doctor` to inspect capability availability"}function $(e,t,n){return n?`\u001b[${{red:`31`,green:`32`,cyan:`36`,dim:`2`,heading:`1`,option:`36`}[t]}m${e}\u001b[0m`:e}var yU=class extends Error{code;constructor(e,t){super(t),this.name=`CliCommandError`,this.code=e}};async function bU(e=Bun.argv.slice(2),t=xU()){let n={env:process.env,cwd:process.cwd(),io:{stdin:t.stdin??CU(),stdoutIsTTY:t.stdoutIsTTY??process.stdout.isTTY===!0,stderrIsTTY:t.stderrIsTTY??process.stderr.isTTY===!0,...t.confirm===void 0?{}:{confirm:t.confirm},writeStdout:t.writeStdout,writeStderr:t.writeStderr}},r=await RH(e,n);return(xI(e)||e[0]===`help`)&&!SU(e)?n.io?.writeStdout?.(bI(SI(e),{stdoutIsTTY:n.io?.stdoutIsTTY,stderrIsTTY:n.io?.stderrIsTTY,env:n.env,stream:`stdout`})):SU(e)?n.io?.writeStdout?.(`${JSON.stringify(r.envelope)}\n`):r.envelope.ok?n.io?.writeStdout?.(iU(r,{stdoutIsTTY:n.io?.stdoutIsTTY,stderrIsTTY:n.io?.stderrIsTTY,env:n.env,stream:`stdout`})):n.io?.writeStderr?.(iU(r,{stdoutIsTTY:n.io?.stderrIsTTY,stderrIsTTY:n.io?.stderrIsTTY,env:n.env,stream:`stderr`})),r.exitCode}function xU(){return{stdoutIsTTY:process.stdout.isTTY===!0,stderrIsTTY:process.stderr.isTTY===!0,writeStdout:e=>process.stdout.write(e),writeStderr:e=>process.stderr.write(e),confirm:async t=>{let n=e({input:process.stdin,output:process.stderr});try{let e=await n.question(`${t} [y/N] `);return/^(?:y|yes)$/iu.test(e.trim())}finally{n.close()}}}}function SU(e){let t=!1;for(let n of e)n===`--json`||n===`--json=true`?t=!0:n===`--json=false`&&(t=!1);return t}async function*CU(){let e=new TextDecoder;for await(let t of process.stdin)typeof t==`string`?yield t:yield e.decode(t,{stream:!0});let t=e.decode();t.length>0&&(yield t)}LH(),UV(),XB(),kB(),gV(),fV(),pB();const wU=`holycodex`;import.meta.main&&(process.exitCode=await bU());export{mI as ArgumentError,tB as CapabilityInstallStateSchema,nB as CapabilityStateRecordSchema,mV as CodexOfficialPluginManager,cB as InstallRecordSchema,eB as InstallRequestSchema,Q as InstallerError,hV as OfficialPluginManagerError,OB as PathBoundaryError,DB as STATE_SCHEMA,hB as assertRootText,MV as doctorHolyCodex,zH as executeCommand,xI as helpRequested,yI as helpText,SI as helpTopic,WV as installHolyCodex,eV as installNativeAgents,DH as installRecordDigest,wU as packageName,hI as parseArgv,bB as pathWithin,ZB as projectNativeAgents,QB as projectRootAgent,JB as publicManifestPath,GV as readActiveInstallRecord,UB as readCanonicalBaseVersion,HB as readCanonicalVersion,NV as removeHolyCodex,nV as removeManagedNativeAgents,bI as renderHelp,iU as renderHuman,rV as renderNativeAgent,aU as renderProgress,mB as resolveInstallerPaths,tV as rollbackNativeAgentInstall,bU as runBinary,RH as runCli,WB as updateCanonicalVersion};
|
|
100
|
+
`;function Xc(e){switch(e){case"install":return XU;case"remove":return QU;case"doctor":return eH;case"version":return tH;default:return ZU}}function Qx(e,t={}){let r=$d({...t,stream:"stdout"});return Xc(e).split(`
|
|
101
|
+
`).map((n)=>{if(n==="HolyCodex")return Hd(n,"heading",r);if(/^(?:Usage|Options|Profiles control routing only|Tier is independent service handling|Capability defaults).*:$/u.test(n))return Hd(n,"heading",r);return n.replace(/--[a-z][a-z0-9-]*/gu,(o)=>Hd(o,"option",r)).replace(/<[^>]+>/gu,(o)=>Hd(o,"argument",r))}).join(`
|
|
102
|
+
`)}function Qc(e){return e.some((t)=>t==="-h"||t==="--help"||t==="--help=true")}function el(e){let t=e.filter((r)=>!r.startsWith("-"));if(t[0]==="help")return t[1];if(t[0]==="--version"||t[0]==="version"||t[0]==="-v")return"version";return t[0]}function $d(e){let t=e.env??{};if(t.NO_COLOR!==void 0||t.TERM==="dumb")return!1;if(t.FORCE_COLOR!==void 0&&t.FORCE_COLOR!=="0")return!0;if(t.CI!==void 0&&t.CI!=="false")return!1;return(e.stream==="stderr"?e.stderrIsTTY:e.stdoutIsTTY)===!0}function Hd(e,t,r){if(!r)return e;return`\x1B[${{heading:"1",option:"36",argument:"2"}[t]}m${e}\x1B[0m`}pt();kl();var gj=["low","default","high"],yj=["standard","fast","fast-all"],Vo=["work","frontend","security","computer_use"];async function Rb(e={}){let t=Xn(e),r=await import("@opentui/core"),n=PI(t),o=await r.createCliRenderer({exitOnCtrlC:!0,clearOnShutdown:!0}),i=new r.TextRenderable(o,{content:CI(n,0)});return o.root.add(i),await new Promise((a,s)=>{let c=0,l=!1,u=0,p=!1,f=(S)=>{if(p)return;p=!0,o.keyInput.off("keypress",w),o.destroy(),a(S)},h=(S)=>{if(p)return;p=!0,o.keyInput.off("keypress",w),o.destroy(),s(S)},m=()=>{i.content=l?MI(n,u):CI(n,c),o.requestRender()},w=(S)=>{try{let y=S.name.toLowerCase();if(y==="escape"||S.ctrl===!0&&y==="c"){f({action:"cancel"});return}if(l){if(y==="up"||y==="k")u=(u+2)%3;else if(y==="down"||y==="j")u=(u+1)%3;else if(y==="return"||y==="enter"||y==="linefeed"){if(u===0)f({action:"install",request:AI(n)});else if(u===1)l=!1,c=0;else f({action:"cancel"});return}m();return}if(c===Vo.length+2){if(y==="backspace")n.pluginInput=n.pluginInput.slice(0,-1);else if(y==="return"||y==="enter"||y==="linefeed")n.plugins=Sj(n.pluginInput),l=!0,u=0;else if(!S.ctrl&&!S.meta&&S.name.length===1&&!_j(S.name))n.pluginInput+=S.name;m();return}if(y==="up"||y==="k")c=Math.max(0,c-1);else if(y==="down"||y==="j")c=Math.min(Vo.length+2,c+1);else if(y==="space"&&c>=2)II(n,c-2);else if(y==="left"||y==="h")RI(n,c,-1);else if(y==="right"||y==="l")RI(n,c,1);else if(y==="return"||y==="enter"||y==="linefeed"){if(c<Vo.length+2)c+=1}if(c===Vo.length+2)n.pluginInput=n.plugins.join(", ");m()}catch(y){h(y)}};o.keyInput.on("keypress",w);try{o.start()}catch(S){h(S)}})}function AI(e){let t=e.plugins.length>0?{profile:e.profile,tier:e.tier,optional:{...e.optional},officialPlugins:[...e.plugins]}:{profile:e.profile,tier:e.tier,optional:{...e.optional}};return Xn(t)}function xj(e,t="install"){let r=PI(Xn(e));return MI(r,t==="install"?0:t==="change"?1:2)}function PI(e){let t={...an,...e.optional};return{profile:e.profile??"default",tier:e.tier??"standard",optional:{computer_use:t.computer_use??an.computer_use,work:t.work??an.work,frontend:t.frontend??an.frontend,security:t.security??an.security},plugins:[...e.officialPlugins??[]],pluginInput:(e.officialPlugins??[]).join(", ")}}function RI(e,t,r){if(t===0)e.profile=kI(gj,e.profile,r);else if(t===1)e.tier=kI(yj,e.tier,r);else if(t>=2&&t<Vo.length+2)II(e,t-2)}function II(e,t){let r=Vo[t];if(r!==void 0)e.optional[r]=!e.optional[r]}function kI(e,t,r){let n=e.indexOf(t);return e[(n+r+e.length)%e.length]??e[0]}function Sj(e){return[...new Set(e.split(",").map((t)=>t.trim()).filter(Boolean))]}function CI(e,t){return`${["HolyCodex install wizard","Use \u2191/\u2193 (or j/k) to move, \u2190/\u2192 to change, Enter to continue, Esc to cancel.","",...[["Profile",e.profile],["Service tier",e.tier],...Vo.map((n)=>[bj(n),Ml(e.optional[n])])].map(([n,o],i)=>`${i===t?"\u203A":" "} ${n}: ${o}`),`${t===Vo.length+2?"\u203A":" "} Additional plugins (comma-separated, optional): ${e.pluginInput||"none"}`].join(`
|
|
103
|
+
`)}
|
|
104
|
+
`}function MI(e,t){let r=["Install","Change options / Redo","Cancel"];return`${["Review configuration","",`Profile: ${e.profile}`,`Service tier: ${e.tier}`,`Work: ${Ml(e.optional.work)}`,`Frontend: ${Ml(e.optional.frontend)}`,`Security: ${Ml(e.optional.security)}`,`Computer Use: ${Ml(e.optional.computer_use)}`,`Additional plugins: ${e.plugins.length===0?"none":e.plugins.join(", ")}`,"",...r.map((o,i)=>`${i===t?"\u203A":" "} ${o}`),"","Enter selects the highlighted action. Esc cancels."].join(`
|
|
105
|
+
`)}
|
|
106
|
+
`}function bj(e){return e==="computer_use"?"Computer Use":`${e[0].toUpperCase()}${e.slice(1)}`}function Ml(e){return e?"enabled":"disabled"}function _j(e){let t=e.codePointAt(0)??0;return t<=31||t===127}kl();yl();vf();gf();El();Hi();is();async function Cb(e,t={}){if(Qc(e)||e[0]==="help"){let n=e[0]==="help"?e.slice(1).filter((o)=>!o.startsWith("-"))[0]:el(e);return{envelope:NI(n===void 0?"help":`${n} help`,{help:Xc(n)}),exitCode:0}}let r;try{r=Ud(e);let n=await FI(r,t);return{envelope:NI(r.command,n),exitCode:Mj(r.command,n)}}catch(n){return Ij(r?.command??Fj(e),n)}}async function FI(e,t){switch(e.command){case"install":return sr(await wj(e,t));case"doctor":return sr(await Tb(Ab(e,t),t.env));case"remove":return sr(await vj(e,t));case"version":return sr(await Oj(e,t));case"help":return{help:Xc(e.positionals[0])};default:throw new Vi("invalid_argument","Unknown command.")}}async function wj(e,t){let r=e.options.json===!0,n=Ej(e),o=await Tj(e,t,n);gn(t,r,"Validating Codex target"),gn(t,r,"Installing HolyCodex"),gn(t,r,"Installing selected capabilities"),gn(t,r,"Configuring Root"),gn(t,r,"Installing subagent roles");let i=await kf(o,Ab(e,t),t.env);return gn(t,r,"Verifying installation"),gn(t,r,"HolyCodex installation complete"),i}async function Tj(e,t,r){if(e.options.json!==!0&&e.options.yes!==!0&&t.io?.stdoutIsTTY===!0&&t.io?.stderrIsTTY===!0){let o=await(t.io?.installWizard??Rb)(r);if(o.action==="cancel")throw new Vi("install_cancelled","Installation cancelled.");return Xn(o.request)}if(!await LI(e,t,"Install HolyCodex into the selected Codex home?"))throw new Vi("non_tty_confirmation_required","Install requires --yes in non-interactive mode.");return Xn(r)}function Ej(e){let t=Cj(e),r=Aj(e),n=kj(e),o=Pj(e,"add-plugin");return Xn({...t===void 0?{}:{profile:t},...r===void 0?{}:{tier:r},...n===void 0?{}:{optional:n},...o.length===0?{}:{officialPlugins:o}})}async function vj(e,t){let r=e.options.json===!0;if(!await LI(e,t,"Remove HolyCodex-owned Codex state?"))throw new Vi("non_tty_confirmation_required","Remove requires --yes in non-interactive mode.");gn(t,r,"Validating HolyCodex ownership");let n=await Ol(Ab(e,t),t.env);return gn(t,r,"Removing HolyCodex-owned state"),gn(t,r,"HolyCodex removal complete"),n}async function Oj(e,t){let r=e.positionals[0];if(!r)return{version:await mf()};return await db(r,e.options["dry-run"]===!0)}async function LI(e,t,r){if(e.options.yes===!0)return!0;if(e.options.json===!0||t.io?.stdoutIsTTY!==!0)return!1;return await Rj(t,r)}async function Rj(e,t){return e.io?.confirm?await e.io.confirm(t):!1}function kj(e){let t={};for(let r of["computer_use","work","frontend","security"]){let n=r.replaceAll("_","-");if(e.options[n]===!0)t[r]=!0;else if(e.options[n]===!1)t[r]=!1;else if(e.options[`no-${n}`]===!0)t[r]=!1}return Object.keys(t).length===0?void 0:t}function Cj(e){let t=e.options.profile;if(typeof t!=="string")return;let r=ln(t);return r.ok?r.value.name:void 0}function Aj(e){let t=e.options.tier;return t==="standard"||t==="fast"||t==="fast-all"?t:void 0}function Pj(e,t){let r=e.options[t];return Array.isArray(r)?r.filter((n)=>typeof n==="string"):[]}function Ab(e,t){let r=t.installer??{},n=e.options["codex-home"];if(typeof n!=="string")return{...r,...t.now?{now:t.now}:{}};return{...r,paths:{...r.paths,codexHome:n},...t.now?{now:t.now}:{}}}function NI(e,t){let r=Dd({schema_version:xn,ok:!0,command:e,data:t,warnings:[]});if(!r.ok)throw new Vi("internal_error","The success envelope failed validation.");return r.value}function Ij(e,t){let r=Nj(t),n=Dd({schema_version:xn,ok:!1,command:e,error:{code:r.code,message:r.message,details:r.details},warnings:[]});if(!n.ok)return{envelope:{schema_version:xn,ok:!1,command:"internal-error",error:{code:"internal_error",message:"The CLI failure envelope was invalid.",details:{}},warnings:[]},exitCode:5};return{envelope:n.value,exitCode:r.exitCode}}function Mj(e,t){return e==="doctor"&&zo(t)&&t.healthy===!1?4:0}function Nj(e){if(e instanceof Ke)return{code:e.code,message:Bi(e.message),details:e.details,exitCode:1};if(e instanceof Vi)return{code:e.code,message:Bi(e.message),details:{},exitCode:e.code==="internal_error"?5:1};if(e instanceof _r)return{code:"trust_boundary_failed",message:Bi(e.message),details:{},exitCode:4};if(e instanceof X){let t=e.code==="capability_denied"?2:e.code==="state_corrupt"?4:3;return{code:e.code,message:Bi(e.message),details:e.details,exitCode:t}}if(e instanceof hn){let t=["timeout","output_limit","cancelled","readback_mismatch"].includes(e.code),r=e.code==="plugin_disabled"||e.code==="plugin_missing"||e.code==="command_failed";return{code:t?"effect_uncertain":r?"capability_denied":"install_failed",message:Bi(e.message),details:e.details,exitCode:t?4:r?2:3}}if(e instanceof $i)return{code:e.code,message:Bi(e.message),details:{},exitCode:4};if(e instanceof wl)return{code:e.code,message:Bi(e.message),details:{},exitCode:1};if(e instanceof Error)return{code:"internal_error",message:"The command failed unexpectedly.",details:{},exitCode:5};return{code:"internal_error",message:"The command failed unexpectedly.",details:{},exitCode:5}}function Fj(e){return e.find((t)=>!t.startsWith("-"))??"unknown"}function Bi(e){return Array.from(e).map((t)=>{let r=t.codePointAt(0)??0;return r<=31||r===127?" ":t}).join("").replace(/\s+/gu," ").trim().slice(0,512)}function zo(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function gn(e,t,r){if(t||e.io?.stderrIsTTY===!1)return;e.io?.writeStderr?.(`${DI(r,{stderrIsTTY:e.io?.stderrIsTTY,env:e.env})}
|
|
107
|
+
`)}function Pf(e,t={}){let r=$d(t);if(e.envelope.ok){if(e.envelope.command==="version")return Lj(e.envelope.data);if(e.envelope.command==="install")return Dj(e.envelope.data,r);if(e.envelope.command==="remove")return qj(e.envelope.data,r);if(e.envelope.command==="doctor")return Uj(e.envelope.data,r);return`${Se("\u2714","green",r)} ${Se(e.envelope.command,"heading",r)}
|
|
108
|
+
${$j(e.envelope.data,r)}`}let n=e.envelope.error,o=Bj(n.code,e.envelope.command);return[`${Se("\u2716","red",r)} ${Se(e.envelope.command,"heading",r)}`,` ${Se(n.code,"red",r)}: ${n.message}`,...jj(n.details,r),...o===void 0?[]:[` hint: ${o}`],""].join(`
|
|
109
|
+
`)}function DI(e,t={}){return`${Se("\u2022","cyan",$d({...t,stream:"stderr"}))} ${e}`}function Lj(e){if(zo(e)&&typeof e.version==="string")return`holycodex ${e.version}
|
|
110
|
+
`;if(zo(e)&&typeof e.next==="string"){let t=typeof e.previous==="string"?` (from ${e.previous})`:"";return`holycodex version updated to ${e.next}${t}
|
|
111
|
+
`}return`holycodex version completed
|
|
112
|
+
`}function Dj(e,t){let r=Nl(e,"record"),n=Fl(r,"version")??"unknown",o=Fl(r,"profile")??"unknown",i=Fl(r,"tier")??"unknown",a=Nl(r,"optional_selections"),s=Nl(r,"capability_state"),c=["frontend","security","work","computer_use"].filter((m)=>a?.[m]===!0).map((m)=>{let w=Fl(Nl(s,m),"status");return w===void 0||w==="healthy"?m:`${m} (${w})`}),l=ls(e,"preserved"),u=ls(e,"warnings"),p=c.length===0?"none":c.join(", "),f=l.length===0?"none":`${l.length} managed item${l.length===1?"":"s"} (review before retrying)`;return`${[`${Se("\u2714","green",t)} ${Se("install","heading",t)}`,` ${Se("version","option",t)}: ${n}`,` ${Se("profile","option",t)}: ${o}`,` ${Se("tier","option",t)}: ${i}`,` ${Se("capabilities","option",t)}: ${p}`,` ${Se("preserved","option",t)}: ${f}`,...u.map((m)=>` ${Se("warning","red",t)}: ${Pb(m)}`)].join(`
|
|
113
|
+
`)}
|
|
114
|
+
`}function qj(e,t){let r=ls(e,"removed"),n=ls(e,"preserved"),o=ls(e,"reasons"),i=n.length===0?"none":`${n.length} item${n.length===1?"":"s"} (review before retrying)`;return`${[`${Se("\u2714","green",t)} ${Se("remove","heading",t)}`,` ${Se("removed","option",t)}: ${r.length} owned item${r.length===1?"":"s"}`,` ${Se("preserved","option",t)}: ${i}`,...o.map((s)=>` ${Se("reason","option",t)}: ${Pb(s)}`)].join(`
|
|
115
|
+
`)}
|
|
116
|
+
`}function Uj(e,t){let r=Hj(e,"healthy")===!0,n=Nl(e,"checks"),o=n===void 0?[]:Object.entries(n),i=o.flatMap(([c,l])=>{let u=zo(l)?l:void 0,p=Fl(u,"status");if(p===void 0||p==="healthy")return[];let f=ls(u,"reasons");return[` ${Se(c,"option",t)}: ${f.length===0?p:f.map(Pb).join(", ")}`]});return`${[`${r?Se("\u2714","green",t):Se("\u2716","red",t)} ${Se("doctor","heading",t)}`,` ${Se("status","option",t)}: ${r?"healthy":"needs attention"}`,` ${Se("checks","option",t)}: ${o.length}`,...i.length===0?[]:[` ${Se("issues","option",t)}:`,...i]].join(`
|
|
117
|
+
`)}
|
|
118
|
+
`}function Nl(e,t){if(!zo(e))return;return zo(e[t])?e[t]:void 0}function Hj(e,t){return zo(e)?e[t]:void 0}function Fl(e,t){let r=e?.[t];return typeof r==="string"?r:void 0}function ls(e,t){if(!zo(e)||!Array.isArray(e[t]))return[];return e[t]}function Pb(e){if(typeof e!=="string")return"operation requires review";return e.replaceAll("_"," ")}function $j(e,t){if(typeof e!=="object"||e===null||Array.isArray(e))return` ${Se(kb(e),"dim",t)}
|
|
119
|
+
`;let r=Object.entries(e);if(r.length===0)return"";let n=Math.max(...r.map(([o])=>o.length));return`${r.map(([o,i])=>` ${Se(o.padEnd(n),"option",t)}: ${kb(i)}`).join(`
|
|
120
|
+
`)}
|
|
121
|
+
`}function jj(e,t){return Object.entries(e).map(([r,n])=>` ${Se(r,"option",t)}: ${Se(kb(n),"dim",t)}`)}function kb(e){if(typeof e==="string")return e;if(e===null||typeof e==="number"||typeof e==="boolean")return String(e);return JSON.stringify(e)}function Bj(e,t){if(e==="invalid_argument"||e==="unknown_command")return`holycodex ${t} --help`;if(e==="non_tty_confirmation_required")return"rerun with --yes or use an interactive terminal";if(e==="capability_denied")return"run `holycodex doctor` to inspect capability availability";return}function Se(e,t,r){if(!r)return e;return`\x1B[${{red:"31",green:"32",cyan:"36",dim:"2",heading:"1",option:"36"}[t]}m${e}\x1B[0m`}class Vi extends Error{code;constructor(e,t){super(t);this.name="CliCommandError",this.code=e}}async function Ib(e=Bun.argv.slice(2),t=zj()){let r={env:process.env,cwd:process.cwd(),io:{stdin:t.stdin??Kj(),stdoutIsTTY:t.stdoutIsTTY??process.stdout.isTTY===!0,stderrIsTTY:t.stderrIsTTY??process.stderr.isTTY===!0,...t.confirm===void 0?{}:{confirm:t.confirm},...t.installWizard===void 0?{}:{installWizard:t.installWizard},writeStdout:t.writeStdout,writeStderr:t.writeStderr}},n=await Cb(e,r);if((Qc(e)||e[0]==="help")&&!qI(e))r.io?.writeStdout?.(Qx(el(e),{stdoutIsTTY:r.io?.stdoutIsTTY,stderrIsTTY:r.io?.stderrIsTTY,env:r.env,stream:"stdout"}));else if(qI(e))r.io?.writeStdout?.(`${JSON.stringify(n.envelope)}
|
|
122
|
+
`);else if(n.envelope.ok)r.io?.writeStdout?.(Pf(n,{stdoutIsTTY:r.io?.stdoutIsTTY,stderrIsTTY:r.io?.stderrIsTTY,env:r.env,stream:"stdout"}));else r.io?.writeStderr?.(Pf(n,{stdoutIsTTY:r.io?.stderrIsTTY,stderrIsTTY:r.io?.stderrIsTTY,env:r.env,stream:"stderr"}));return n.exitCode}function zj(){return{stdoutIsTTY:process.stdout.isTTY===!0,stderrIsTTY:process.stderr.isTTY===!0,writeStdout:(e)=>process.stdout.write(e),writeStderr:(e)=>process.stderr.write(e),confirm:async(e)=>{let t=Vj({input:process.stdin,output:process.stderr});try{let r=await t.question(`${e} [y/N] `);return/^(?:y|yes)$/iu.test(r.trim())}finally{t.close()}}}}function qI(e){let t=!1;for(let r of e)if(r==="--json"||r==="--json=true")t=!0;else if(r==="--json=false")t=!1;return t}async function*Kj(){let e=new TextDecoder;for await(let r of process.stdin)if(typeof r==="string")yield r;else yield e.decode(r,{stream:!0});let t=e.decode();if(t.length>0)yield t}kl();vf();gf();Hi();El();Tf();var nZ="holycodex";if(import.meta.main)process.exitCode=await Ib();export{Ke as ArgumentError,Qa as CapabilityInstallStateSchema,cb as CapabilityStateRecordSchema,Bo as CodexOfficialPluginManager,ff as InstallOptionsSchema,ts as InstallRecordSchema,xl as InstallRequestSchema,X as InstallerError,hn as OfficialPluginManagerError,_r as PathBoundaryError,T$ as STATE_SCHEMA,pb as assertRootText,Tb as doctorHolyCodex,FI as executeCommand,Qc as helpRequested,Xc as helpText,el as helpTopic,kf as installHolyCodex,gb as installNativeAgents,Af as installRecordDigest,nZ as packageName,Ud as parseArgv,os as pathWithin,ji as projectNativeAgents,mb as projectRootAgent,_l as publicManifestPath,Rl as readActiveInstallRecord,hf as readCanonicalBaseVersion,mf as readCanonicalVersion,Ol as removeHolyCodex,_f as removeManagedNativeAgents,Qx as renderHelp,Pf as renderHuman,xj as renderInstallWizardReview,wf as renderNativeAgent,DI as renderProgress,ns as resolveInstallerPaths,bf as rollbackNativeAgentInstall,hb as rootDeveloperInstructions,Ib as runBinary,Cb as runCli,Rb as runOpenTuiInstallWizard,AI as toInstallOptions,db as updateCanonicalVersion,Xn as validateInstallOptions};
|