@seanmozeik/tripwire 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -2
- package/dist/index.js +21 -27
- package/dist/tripwire-cli.js +1 -1
- package/dist/tripwire-hook.js +1 -1
- package/dist/tripwire-pi.js +31 -6
- package/dist/tripwire.js +107 -102
- package/dist/types/dispatch.d.ts +4 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/bash/analyze.d.ts +3 -0
- package/dist/types/lib/bash/carriers.d.ts +11 -0
- package/dist/types/lib/bash/config.d.ts +17 -0
- package/dist/types/lib/bash/execution-types.d.ts +13 -0
- package/dist/types/lib/bash/execution.d.ts +13 -0
- package/dist/types/lib/bash/index.d.ts +8 -0
- package/dist/types/lib/bash/pipeline-inputs.d.ts +10 -0
- package/dist/types/lib/bash/static-command.d.ts +9 -0
- package/dist/types/lib/bash/types.d.ts +58 -0
- package/dist/types/lib/bash/values.d.ts +25 -0
- package/dist/types/lib/bash/wrappers.d.ts +21 -0
- package/dist/types/lib/config.d.ts +32 -0
- package/dist/types/lib/rule-actions.d.ts +27 -0
- package/dist/types/rules/bash-bypass.d.ts +5 -0
- package/dist/types/rules/bash-deny.d.ts +4 -4
- package/dist/types/rules/bash-git.d.ts +2 -2
- package/dist/types/rules/bash-network-install.d.ts +2 -2
- package/dist/types/rules/bash-redirect.d.ts +2 -2
- package/dist/types/rules/bash-scoped-rm.d.ts +2 -2
- package/dist/types/rules/bash-tar-explosion.d.ts +2 -2
- package/dist/types/rules/config-custom.d.ts +3 -3
- package/dist/types/rules/tool-policy.d.ts +2 -2
- package/package.json +4 -4
- package/dist/types/lib/bash.d.ts +0 -27
package/dist/tripwire.js
CHANGED
|
@@ -1,141 +1,146 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var Pq=Object.defineProperty;var U0=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Fq=(e)=>e;function Mq(e,t){this[e]=Fq.bind(null,t)}var Un=(e,t)=>{for(var n in t)Pq(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Mq.bind(t,n)})};var w=(e,t)=>()=>(e&&(t=e(e=0)),t);var Cp;var ky=w(()=>{Cp={name:"@seanmozeik/tripwire",version:"0.7.2",description:"Configurable safety hooks for Claude Code, Codex, Cursor, Pi, and Oh My Pi",keywords:["ai-agents","bun","claude-code","codex","cursor","hooks","safety"],homepage:"https://github.com/seanmozeik/tripwire#readme",bugs:{url:"https://github.com/seanmozeik/tripwire/issues"},license:"MIT",author:"Sean Mozeik",repository:{type:"git",url:"git+https://github.com/seanmozeik/tripwire.git"},bin:{tripwire:"./dist/tripwire-cli.js","tripwire-hook":"./dist/tripwire-hook.js"},workspaces:["packages/*"],files:["dist","LICENSE","package.json","README.md"],type:"module",types:"./dist/types/index.d.ts",exports:{".":{types:"./dist/types/index.d.ts",import:"./dist/index.js",default:"./dist/index.js"}},publishConfig:{access:"public"},scripts:{build:"bun scripts/build.ts",prepublishOnly:"bun run verify",check:"bun run format && bun run lint:fix && bun run typecheck",format:"oxfmt --write .","format:check":"oxfmt --check .",lint:"oxlint .","lint:fix":"oxlint --format agent --fix .",prepare:"bunx effect-tsgo patch",test:"bun test",typecheck:"tsc --noEmit",verify:"bun run format:check && bun run lint && bun run typecheck && bun test && bun run build"},dependencies:{"shell-quote":"1.10.0"},devDependencies:{"@effect/platform-bun":"4.0.0-rc.112","@effect/tsgo":"0.38.0","@seanmozeik/de-clank":"0.1.7","bun-types":"1.4.0",effect:"4.0.0-rc.112",oxfmt:"0.65.0",oxlint:"1.80.0","oxlint-tsgolint":"7.0.2001",typescript:"7.0.2"},peerDependencies:{"@effect/platform-bun":"4.0.0-rc.112",effect:"4.0.0-rc.112"},optionalDependencies:{"@seanmozeik/tripwire-darwin-arm64":"0.7.2"},engines:{bun:">=1.4"}}});var le=(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 r=0,o=t.length;r<o;r++)n=t[r](n);return n}}},Dq,Gi;var Qe=w(()=>{Dq={pipe(){return le(this,arguments)}},Gi=function(){function e(){}return e.prototype=Dq,e}()});function zr(e,...t){return le(e,t)}function L0(e,t,n,r,o,s,i,a,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return o(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(o(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return i(s(o(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return a(i(s(o(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(a(i(s(o(r(n(t(e.apply(this,arguments)))))))))}}return}function Qt(e){let t=new WeakMap;return(n)=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),o}}function Ji(e){let t=new WeakMap;return(n)=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),t.set(o,o),o}}var p=function(e,t){if(typeof e==="function")return function(){return e(arguments)?t.apply(this,arguments):(n)=>t(n,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(n,r){if(arguments.length>=2)return t(n,r);return function(o){return t(o,n)}};case 3:return function(n,r,o){if(arguments.length>=3)return t(n,r,o);return function(s){return t(s,n,r)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(r){return t(r,...n)}}}},D=(e)=>e,gt=(e)=>()=>e,nr,Sl,Tp,qr,Vo;var X=w(()=>{Qe();nr=gt(!0),Sl=gt(!1),Tp=gt(null),qr=gt(void 0),Vo=qr});var El=(e)=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;if(e instanceof Error)t.delete("stack");let n=Object.getPrototypeOf(e),r=n;while(r!==null&&r!==Object.prototype){let o=Reflect.ownKeys(r);for(let s=0;s<o.length;s++)t.add(o[s]);r=Object.getPrototypeOf(r)}if(t.has("constructor")&&typeof e.constructor==="function"&&n===e.constructor.prototype)t.delete("constructor");return t},wc;var Iy=w(()=>{wc=new WeakSet});function Wr(e){return typeof e==="string"}function bl(e){return typeof e==="number"}function Op(e){return typeof e==="boolean"}function j0(e){return typeof e==="bigint"}function Cy(e){return typeof e==="symbol"}function Ap(e){return Wr(e)||bl(e)||Cy(e)}function ln(e){return typeof e==="function"}function Gs(e){return e===void 0}function Le(e){return e!==void 0}function wl(e){return e!==null}function B0(e){return e===null||e===void 0}function _p(e){return e!=null}function H0(e){return!1}function Ty(e){return!0}function fn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function vl(e){return typeof e==="object"&&e!==null||ln(e)}function q0(e){return e instanceof Error}function go(e){return M(e,Symbol.iterator)||Wr(e)}var M,br;var he=w(()=>{X();M=p(2,(e,t)=>vl(e)&&(t in e)),br=p(2,(e,t)=>M(e,"_tag")&&e._tag===t)});function jq(e,t){if(_y.has(e))return qe("[Circular]");_y.add(e);let n=t();return _y.delete(e),n}var Ie="~effect/interfaces/Hash",re=(e)=>{switch(typeof e){case"number":return Ln(e);case"bigint":return qe(e.toString(10));case"boolean":return qe(String(e));case"symbol":return qe(String(e));case"string":return qe(e);case"undefined":return qe("undefined");case"function":case"object":if(e===null)return qe("null");else if(e instanceof Date){if(Number.isNaN(e.getTime()))return qe("Invalid Date");return qe(e.toISOString())}else if(e instanceof RegExp)return qe(e.toString());else{if(wc.has(e))return Rp(e);if(Ay.has(e))return Ay.get(e);let t=jq(e,()=>{if($q(e))return e[Ie]();else if(typeof e==="function")return Rp(e);else if(e instanceof DataView)return vc(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e)||ArrayBuffer.isView(e))return vc(e);else if(e instanceof Map)return Uq(e);else if(e instanceof Set)return Lq(e);return Py(e)});return Ay.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Rp=(e)=>{if(!Oy.has(e))Oy.set(e,Ln(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)));return Oy.get(e)},xt,Js=(e)=>e&3221225471|e>>>1&1073741824,$q=(e)=>M(e,Ie),Ln=(e)=>{if(e!==e)return qe("NaN");if(e===1/0)return qe("Infinity");if(e===-1/0)return qe("-Infinity");let t=e|0;if(t!==e)t^=e*4294967295;while(e>4294967295)t^=e/=4294967295;return Js(t)},qe=(e)=>{let t=5381,n=e.length;while(n)t=t*33^e.charCodeAt(--n);return Js(t)},Ry=(e,t)=>{let n=12289;for(let r of t)n^=xt(re(r),re(e[r]));return Js(n)},Py=(e)=>Ry(e,El(e)),Fy=(e,t)=>(n)=>{let r=e;for(let o of n)r^=t(o);return Js(r)},vc,Uq,Lq,Oy,Ay,_y;var Xt=w(()=>{X();Iy();he();xt=p(2,(e,t)=>e*53^t),vc=Fy(6151,re),Uq=Fy(qe("Map"),([e,t])=>xt(re(e),re(t))),Lq=Fy(qe("Set"),re),Oy=new WeakMap,Ay=new WeakMap,_y=new WeakSet});function Y(){if(arguments.length===1)return(e)=>Zi(e,arguments[0]);return Zi(arguments[0],arguments[1])}function Zi(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;if(n!==typeof t)return!1;if(n==="number"&&e!==e&&t!==t)return!0;if(n!=="object"&&n!=="function")return!1;if(wc.has(e)||wc.has(t))return!1;return qq(e,t,Hq)}function Bq(e,t,n){let r=My.has(e),o=Ny.has(t);if(r&&o)return!0;if(r||o)return!1;My.add(e),Ny.add(t);let s=n();return My.delete(e),Ny.delete(t),s}function Hq(e,t){if(re(e)!==re(t))return!1;else if(e instanceof Date){if(!(t instanceof Date))return!1;let s=e.getTime(),i=t.getTime();return s===i||Number.isNaN(s)&&Number.isNaN(i)}else if(e instanceof RegExp){if(!(t instanceof RegExp))return!1;return e.toString()===t.toString()}let n=W0(e),r=W0(t);if(n!==r)return!1;let o=n&&r;if(typeof e==="function"&&!o)return!1;return Bq(e,t,()=>{if(o)return e[Ce](t);else if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;return zq(e,t)}else if(ArrayBuffer.isView(e)){let s=e instanceof DataView;if(!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||s!==t instanceof DataView)return!1;if(s){let i=t;return z0(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(i.buffer,i.byteOffset,i.byteLength))}return z0(e,t)}else if(e instanceof Map){if(!(t instanceof Map)||e.size!==t.size)return!1;return Kq(e,t)}else if(e instanceof Set){if(!(t instanceof Set)||e.size!==t.size)return!1;return Vq(e,t)}return Wq(e,t)})}function qq(e,t,n){let r=Pp.get(e);if(!r)r=new WeakMap,Pp.set(e,r);else if(r.has(t))return r.get(t);let o=n(e,t);r.set(t,o);let s=Pp.get(t);if(!s)s=new WeakMap,Pp.set(t,s);return s.set(e,o),o}function zq(e,t){for(let n=0;n<e.length;n++)if(!Zi(e[n],t[n]))return!1;return!0}function z0(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Wq(e,t){let n=El(e),r=El(t);if(n.size!==r.size)return!1;for(let o of n)if(!r.has(o)||!Zi(e[o],t[o]))return!1;return!0}function Fp(e,t){return function(r,o){let s=Array.from(o);for(let[i,a]of r){let c=!1;for(let u=0;u<s.length;u++){let[l,f]=s[u];if(e(i,l)&&t(a,f)){s[u]=s[s.length-1],s.pop(),c=!0;break}}if(!c)return!1}return!0}}function Mp(e){return function(n,r){let o=Array.from(r);for(let s of n){let i=!1;for(let a=0;a<o.length;a++){let c=o[a];if(e(s,c)){o[a]=o[o.length-1],o.pop(),i=!0;break}}if(!i)return!1}return!0}}var Ce="~effect/interfaces/Equal",My,Ny,Pp,Kq,Vq,W0=(e)=>M(e,Ce),Dy=()=>Y,$y=(e)=>(wc.add(e),e);var yt=w(()=>{Xt();Iy();he();My=new WeakSet,Ny=new WeakSet;Pp=new WeakMap;Kq=Fp(Zi,Zi);Vq=Mp(Zi)});function kc(e){if(Gq(e))return Uy(e);return e}function Uy(e){return e[kl](globalThis[Ic]?.context??Jq)}var kl,Gq=(e)=>M(e,kl),Ic="~effect/Fiber/currentFiber",K0,Jq;var Np=w(()=>{Qe();he();kl=Symbol.for("~effect/Redactable");K0=new Map,Jq={"~effect/Context":{},base:K0,depth:0,mapUnsafe:K0,pipe(){return le(this,arguments)}}});function B(e,t){let n=t?.space??0,r=new WeakSet,o=!n?"":typeof n==="number"?" ".repeat(n):n,s=(u)=>o.repeat(u),i=(u,l)=>{let f=u?.constructor;return f&&f!==Object.prototype.constructor&&f.name?`${f.name}(${l})`:l},a=(u)=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}};function c(u,l=0){if(typeof u==="string")return JSON.stringify(u);if(typeof u==="number"||u==null||typeof u==="boolean"||typeof u==="symbol")return String(u);if(typeof u==="bigint")return String(u)+"n";if(typeof u==="object"||typeof u==="function"){if(r.has(u))return Zq;r.add(u);let f;if(kl in u)f=c(Uy(u),l);else if(Array.isArray(u))f=!o||u.length<=1?`[${u.map((d)=>c(d,l)).join(",")}]`:`[
|
|
3
|
+
var zz=Object.defineProperty;var Vz=(e)=>e;function Kz(e,t){this[e]=Vz.bind(null,t)}var Qn=(e,t)=>{for(var n in t)zz(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Kz.bind(t,n)})};var v=(e,t)=>()=>(e&&(t=e(e=0)),t);var Bm;var GS=v(()=>{Bm={name:"@seanmozeik/tripwire",version:"0.8.0",description:"Configurable safety hooks for Claude Code, Codex, Cursor, Pi, and Oh My Pi",keywords:["ai-agents","bun","claude-code","codex","cursor","hooks","safety"],homepage:"https://github.com/seanmozeik/tripwire#readme",bugs:{url:"https://github.com/seanmozeik/tripwire/issues"},license:"MIT",author:"Sean Mozeik",repository:{type:"git",url:"git+https://github.com/seanmozeik/tripwire.git"},bin:{tripwire:"./dist/tripwire-cli.js","tripwire-hook":"./dist/tripwire-hook.js"},workspaces:["packages/*"],files:["dist","LICENSE","package.json","README.md"],type:"module",types:"./dist/types/index.d.ts",exports:{".":{types:"./dist/types/index.d.ts",import:"./dist/index.js",default:"./dist/index.js"}},publishConfig:{access:"public"},scripts:{build:"bun scripts/build.ts",prepublishOnly:"bun run verify",check:"bun run format && bun run lint:fix && bun run typecheck",format:"oxfmt --write .","format:check":"oxfmt --check .",lint:"oxlint .","lint:fix":"oxlint --format agent --fix .",prepare:"bunx effect-tsgo patch",test:"bun test",typecheck:"tsc --noEmit",verify:"bun run format:check && bun run lint && bun run typecheck && bun test && bun run build"},dependencies:{unbash:"4.0.10"},devDependencies:{"@effect/platform-bun":"4.0.0-rc.112","@effect/tsgo":"0.38.0","@seanmozeik/de-clank":"0.1.8","bun-types":"1.4.0",effect:"4.0.0-rc.112",oxfmt:"0.65.0",oxlint:"1.80.0","oxlint-tsgolint":"7.0.2001",typescript:"7.0.2"},peerDependencies:{"@effect/platform-bun":"4.0.0-rc.112",effect:"4.0.0-rc.112"},optionalDependencies:{"@seanmozeik/tripwire-darwin-arm64":"0.8.0"},engines:{bun:">=1.4"}}});var fe=(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 r=0,o=t.length;r<o;r++)n=t[r](n);return n}}},Jz,za;var ct=v(()=>{Jz={pipe(){return fe(this,arguments)}},za=function(){function e(){}return e.prototype=Jz,e}()});function To(e,...t){return fe(e,t)}function RA(e,t,n,r,o,s,i,a,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return o(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(o(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return i(s(o(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return a(i(s(o(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(a(i(s(o(r(n(t(e.apply(this,arguments)))))))))}}return}function bn(e){let t=new WeakMap;return(n)=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),o}}function Va(e){let t=new WeakMap;return(n)=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),t.set(o,o),o}}var p=function(e,t){if(typeof e==="function")return function(){return e(arguments)?t.apply(this,arguments):(n)=>t(n,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(n,r){if(arguments.length>=2)return t(n,r);return function(o){return t(o,n)}};case 3:return function(n,r,o){if(arguments.length>=3)return t(n,r,o);return function(s){return t(s,n,r)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(r){return t(r,...n)}}}},L=(e)=>e,_t=(e)=>()=>e,Fr,Of,Hm,Ao,Ns;var ne=v(()=>{ct();Fr=_t(!0),Of=_t(!1),Hm=_t(null),Ao=_t(void 0),Ns=Ao});var Pf=(e)=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;if(e instanceof Error)t.delete("stack");let n=Object.getPrototypeOf(e),r=n;while(r!==null&&r!==Object.prototype){let o=Reflect.ownKeys(r);for(let s=0;s<o.length;s++)t.add(o[s]);r=Object.getPrototypeOf(r)}if(t.has("constructor")&&typeof e.constructor==="function"&&n===e.constructor.prototype)t.delete("constructor");return t},ku;var JS=v(()=>{ku=new WeakSet});function _o(e){return typeof e==="string"}function Rf(e){return typeof e==="number"}function Wm(e){return typeof e==="boolean"}function FA(e){return typeof e==="bigint"}function QS(e){return typeof e==="symbol"}function jm(e){return _o(e)||Rf(e)||QS(e)}function Mn(e){return typeof e==="function"}function Li(e){return e===void 0}function Ve(e){return e!==void 0}function Ff(e){return e!==null}function MA(e){return e===null||e===void 0}function qm(e){return e!=null}function DA(e){return!1}function ZS(e){return!0}function Dn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Mf(e){return typeof e==="object"&&e!==null||Mn(e)}function NA(e){return e instanceof Error}function ns(e){return D(e,Symbol.iterator)||_o(e)}var D,eo;var ge=v(()=>{ne();D=p(2,(e,t)=>Mf(e)&&(t in e)),eo=p(2,(e,t)=>D(e,"_tag")&&e._tag===t)});function Xz(e,t){if(eE.has(e))return Ze("[Circular]");eE.add(e);let n=t();return eE.delete(e),n}var _e="~effect/interfaces/Hash",ie=(e)=>{switch(typeof e){case"number":return dr(e);case"bigint":return Ze(e.toString(10));case"boolean":return Ze(String(e));case"symbol":return Ze(String(e));case"string":return Ze(e);case"undefined":return Ze("undefined");case"function":case"object":if(e===null)return Ze("null");else if(e instanceof Date){if(Number.isNaN(e.getTime()))return Ze("Invalid Date");return Ze(e.toISOString())}else if(e instanceof RegExp)return Ze(e.toString());else{if(ku.has(e))return zm(e);if(XS.has(e))return XS.get(e);let t=Xz(e,()=>{if(Qz(e))return e[_e]();else if(typeof e==="function")return zm(e);else if(e instanceof DataView)return Cu(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e)||ArrayBuffer.isView(e))return Cu(e);else if(e instanceof Map)return Zz(e);else if(e instanceof Set)return Yz(e);return nE(e)});return XS.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},zm=(e)=>{if(!YS.has(e))YS.set(e,dr(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)));return YS.get(e)},Ot,Bi=(e)=>e&3221225471|e>>>1&1073741824,Qz=(e)=>D(e,_e),dr=(e)=>{if(e!==e)return Ze("NaN");if(e===1/0)return Ze("Infinity");if(e===-1/0)return Ze("-Infinity");let t=e|0;if(t!==e)t^=e*4294967295;while(e>4294967295)t^=e/=4294967295;return Bi(t)},Ze=(e)=>{let t=5381,n=e.length;while(n)t=t*33^e.charCodeAt(--n);return Bi(t)},tE=(e,t)=>{let n=12289;for(let r of t)n^=Ot(ie(r),ie(e[r]));return Bi(n)},nE=(e)=>tE(e,Pf(e)),rE=(e,t)=>(n)=>{let r=e;for(let o of n)r^=t(o);return Bi(r)},Cu,Zz,Yz,YS,XS,eE;var wn=v(()=>{ne();JS();ge();Ot=p(2,(e,t)=>e*53^t),Cu=rE(6151,ie),Zz=rE(Ze("Map"),([e,t])=>Ot(ie(e),ie(t))),Yz=rE(Ze("Set"),ie),YS=new WeakMap,XS=new WeakMap,eE=new WeakSet});function ee(){if(arguments.length===1)return(e)=>Ka(e,arguments[0]);return Ka(arguments[0],arguments[1])}function Ka(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;if(n!==typeof t)return!1;if(n==="number"&&e!==e&&t!==t)return!0;if(n!=="object"&&n!=="function")return!1;if(ku.has(e)||ku.has(t))return!1;return nV(e,t,tV)}function eV(e,t,n){let r=oE.has(e),o=sE.has(t);if(r&&o)return!0;if(r||o)return!1;oE.add(e),sE.add(t);let s=n();return oE.delete(e),sE.delete(t),s}function tV(e,t){if(ie(e)!==ie(t))return!1;else if(e instanceof Date){if(!(t instanceof Date))return!1;let s=e.getTime(),i=t.getTime();return s===i||Number.isNaN(s)&&Number.isNaN(i)}else if(e instanceof RegExp){if(!(t instanceof RegExp))return!1;return e.toString()===t.toString()}let n=UA(e),r=UA(t);if(n!==r)return!1;let o=n&&r;if(typeof e==="function"&&!o)return!1;return eV(e,t,()=>{if(o)return e[Oe](t);else if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;return rV(e,t)}else if(ArrayBuffer.isView(e)){let s=e instanceof DataView;if(!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||s!==t instanceof DataView)return!1;if(s){let i=t;return $A(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(i.buffer,i.byteOffset,i.byteLength))}return $A(e,t)}else if(e instanceof Map){if(!(t instanceof Map)||e.size!==t.size)return!1;return sV(e,t)}else if(e instanceof Set){if(!(t instanceof Set)||e.size!==t.size)return!1;return iV(e,t)}return oV(e,t)})}function nV(e,t,n){let r=Vm.get(e);if(!r)r=new WeakMap,Vm.set(e,r);else if(r.has(t))return r.get(t);let o=n(e,t);r.set(t,o);let s=Vm.get(t);if(!s)s=new WeakMap,Vm.set(t,s);return s.set(e,o),o}function rV(e,t){for(let n=0;n<e.length;n++)if(!Ka(e[n],t[n]))return!1;return!0}function $A(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function oV(e,t){let n=Pf(e),r=Pf(t);if(n.size!==r.size)return!1;for(let o of n)if(!r.has(o)||!Ka(e[o],t[o]))return!1;return!0}function Km(e,t){return function(r,o){let s=Array.from(o);for(let[i,a]of r){let c=!1;for(let u=0;u<s.length;u++){let[l,f]=s[u];if(e(i,l)&&t(a,f)){s[u]=s[s.length-1],s.pop(),c=!0;break}}if(!c)return!1}return!0}}function Gm(e){return function(n,r){let o=Array.from(r);for(let s of n){let i=!1;for(let a=0;a<o.length;a++){let c=o[a];if(e(s,c)){o[a]=o[o.length-1],o.pop(),i=!0;break}}if(!i)return!1}return!0}}var Oe="~effect/interfaces/Equal",oE,sE,Vm,sV,iV,UA=(e)=>D(e,Oe),iE=()=>ee,aE=(e)=>(ku.add(e),e);var Pt=v(()=>{wn();JS();ge();oE=new WeakSet,sE=new WeakSet;Vm=new WeakMap;sV=Km(Ka,Ka);iV=Gm(Ka)});function vu(e){if(aV(e))return cE(e);return e}function cE(e){return e[Df](globalThis[Iu]?.context??cV)}var Df,aV=(e)=>D(e,Df),Iu="~effect/Fiber/currentFiber",LA,cV;var Jm=v(()=>{ct();ge();Df=Symbol.for("~effect/Redactable");LA=new Map,cV={"~effect/Context":{},base:LA,depth:0,mapUnsafe:LA,pipe(){return fe(this,arguments)}}});function j(e,t){let n=t?.space??0,r=new WeakSet,o=!n?"":typeof n==="number"?" ".repeat(n):n,s=(u)=>o.repeat(u),i=(u,l)=>{let f=u?.constructor;return f&&f!==Object.prototype.constructor&&f.name?`${f.name}(${l})`:l},a=(u)=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}};function c(u,l=0){if(typeof u==="string")return JSON.stringify(u);if(typeof u==="number"||u==null||typeof u==="boolean"||typeof u==="symbol")return String(u);if(typeof u==="bigint")return String(u)+"n";if(typeof u==="object"||typeof u==="function"){if(r.has(u))return uV;r.add(u);let f;if(Df in u)f=c(cE(u),l);else if(Array.isArray(u))f=!o||u.length<=1?`[${u.map((d)=>c(d,l)).join(",")}]`:`[
|
|
4
4
|
${s(l+1)}${u.map((d)=>c(d,l+1)).join(`,
|
|
5
5
|
`+s(l+1))}
|
|
6
|
-
${s(l)}]`;else if(u instanceof Date)f=
|
|
7
|
-
${d.map((
|
|
6
|
+
${s(l)}]`;else if(u instanceof Date)f=uE(u);else if(!t?.ignoreToString&&D(u,"toString")&&typeof u.toString==="function"&&u.toString!==Object.prototype.toString&&u.toString!==Array.prototype.toString){let d=lV(u);f=u instanceof Error&&u.cause?`${d} (cause: ${c(u.cause,l)})`:d}else if(Symbol.iterator in u)f=`${u.constructor.name}(${c(Array.from(u),l)})`;else{let d=a(u);if(!o||d.length<=1){let m=`{${d.map((y)=>`${$s(y)}:${c(u[y],l)}`).join(",")}}`;f=i(u,m)}else{let m=`{
|
|
7
|
+
${d.map((y)=>`${s(l+1)}${$s(y)}: ${c(u[y],l+1)}`).join(`,
|
|
8
8
|
`)}
|
|
9
|
-
${s(l)}}`;f=i(u,m)}}return r.delete(u),f}return String(u)}return c(e,0)}function Go(e){return typeof e==="string"?JSON.stringify(e):String(e)}function Dp(e){return e.map((t)=>`[${Go(t)}]`).join("")}function Ly(e){try{return e.toISOString()}catch{return"Invalid Date"}}function Yq(e){try{let t=e.toString();return typeof t==="string"?t:String(t)}catch{return"[toString threw]"}}function Yi(e,t){let n=[];return JSON.stringify(e,function(r,o){let s=Object.getOwnPropertyDescriptor(this,r)?.value,i=M(s,kl)?kc(s):kc(o);if(typeof i==="bigint")return B(i);if(typeof i!=="object"||i===null)return i;while(n.length>0&&n[n.length-1]!==this)n.pop();if(n.includes(i))return;return n.push(i),i},t?.space)??"null"}var Zq="[Circular]";var kn=w(()=>{he();Np()});var At,Wt=(e)=>{try{if(e=kc(e),M(e,"toJSON")&&ln(e.toJSON)&&e.toJSON.length===0)return e.toJSON();else if(Array.isArray(e))return e.map(Wt);return e}catch{return"[toJSON threw]"}},V0=(e,t=2)=>{if(typeof e==="string")return e;try{return typeof e==="object"?Yi(e,{space:t}):B(e,{space:t})}catch{return String(e)}},G0,Qq;var jn=w(()=>{kn();he();Np();At=Symbol.for("nodejs.util.inspect.custom"),G0={toJSON(){return Wt(this)},[At](){return this.toJSON()},toString(){return B(this.toJSON())}};Qq=class Qq{[At](){return this.toJSON()}toString(){return B(this.toJSON())}}});var Zs,Xq=()=>{let t={["~effect/Utils/internal"]:(o)=>o()},n={["~effect/Utils/internal"]:(o)=>{try{return o()}finally{}}};return t["~effect/Utils/internal"](()=>Error().stack)?.includes("~effect/Utils/internal")===!0?t["~effect/Utils/internal"]:n["~effect/Utils/internal"]},Ae;var Qi=w(()=>{Zs=class Zs{called=!1;self;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new Zs(this.self)}};Ae=Xq()});function U(e,t,n){if(t==="__proto__")Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0});else e[t]=n}function $p(e,t){for(let n of Reflect.ownKeys(t))if(Object.prototype.propertyIsEnumerable.call(t,n))U(e,n,t[n])}function nz(e){return Kr("Effect.evaluate: Not implemented")}var xo="~effect/Effect",Xi="~effect/Exit",ez,Y0,ie,St,In,wr,Ys,ta,Cn,Q0,tz,fe=(e)=>M(e,xo),jy=(e)=>M(e,Xi),Cc="~effect/Cause",Tc="~effect/Cause/Reason",Oc=(e)=>M(e,Cc),X0=(e)=>M(e,Tc),Jo,Z0,Cl,Tl,Ac,Zo=(e)=>new Jo(e),Up,Ol=(e)=>new Jo([new Ac(e)]),Lp,By=(e)=>new Jo([new Lp(e)]),_c,Qs=(e)=>e._tag==="Fail",na=(e)=>e._tag==="Die",ra=(e)=>e._tag==="Interrupt",Yo=(e)=>({...tz,[Y0]:e.op,[St]:e[St]??nz,[In]:e[In],[wr]:e[wr],[Ys]:e[Ys]}),vr=(e)=>{let t=Yo(e);return function(){let n=Object.create(t);return n[ie]=e.single===!1?arguments:arguments[0],n}},eC=(e)=>{let t={[Xi]:Xi,_tag:e.op,get[e.prop](){return this[ie]},...Yo(e),toString(){return`${e.op}(${B(this[ie])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[ie]}},[Ce](n){return jy(n)&&n._tag===this._tag&&Y(this[ie],n[ie])},[Ie](){return xt(qe(e.op),re(this[ie]))}};return function(n){let r=Object.create(t);return r[ie]=n,r}},je,jp,Hy,pn,kr=(e)=>pn(Ol(e)),Kr=(e)=>pn(By(e)),ce,rz,Al,Qo=(e)=>{class t extends Al{_tag=e}return t.prototype.name=e,t},Il="~effect/Cause/NoSuchElementError",Bp=(e)=>M(e,Il),yo,ea="~effect/Cause/Done",_l=(e)=>M(e,ea),tC,Rc=(e)=>{if(e===void 0)return tC;return{[ea]:ea,_tag:"Done",value:e}},oz,nC=(e)=>{if(e===void 0)return oz;return kr(Rc(e))};var rt=w(()=>{yt();kn();X();Xt();jn();Qe();he();Qi();ez={_A:D,_E:D,_R:D},Y0=`${xo}/identifier`,ie=`${xo}/args`,St=`${xo}/evaluate`,In=`${xo}/successCont`,wr=`${xo}/failureCont`,Ys=`${xo}/ensureCont`,ta=Symbol.for("effect/Effect/Yield"),Cn={pipe(){return le(this,arguments)},toJSON(){return{...this}},toString(){return B(this.toJSON(),{ignoreToString:!0,space:2})},[At](){return this.toJSON()}},Q0={[Ie](){return Ry(this,Object.keys(this))},[Ce](e){let t=Object.keys(this),n=Object.keys(e);if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==n[r]||!Y(this[t[r]],e[t[r]]))return!1;return!0}},tz={[xo]:ez,...Cn,[Symbol.iterator](){return new Zs(this)},toJSON(){return{_id:"Effect",op:this[Y0],...ie in this?{args:this[ie]}:void 0}}};Jo=class Jo{[Cc];reasons;constructor(e){this[Cc]=Cc,this.reasons=e}pipe(){return le(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map((e)=>e.toJSON())}}toString(){return`Cause(${B(this.reasons)})`}[At](){return this.toJSON()}[Ce](e){return Oc(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>Y(t,e.reasons[n]))}[Ie](){return vc(this.reasons)}};Z0=new WeakMap;Cl=class Cl{[Tc];annotations;_tag;constructor(e,t,n){if(this[Tc]=Tc,this._tag=e,t!==Tl&&typeof n==="object"&&n!==null&&t.size>0){let r=Z0.get(n);if(r)t=new Map([...r,...t]);Z0.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);e.mapUnsafe.forEach((o,s)=>{if(t?.overwrite!==!0&&n.has(s))return;n.set(s,o)});let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return le(this,arguments)}toString(){return B(this)}[At](){return this.toString()}};Tl=new Map;Ac=class Ac extends Cl{error;constructor(e,t=Tl){super("Fail",t,e);this.error=e}toString(){return`Fail(${B(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[Ce](e){return Qs(e)&&Y(this.error,e.error)&&Y(this.annotations,e.annotations)}[Ie](){return xt(qe(this._tag))(xt(re(this.error))(re(this.annotations)))}};Up=new Jo([]);Lp=class Lp extends Cl{defect;constructor(e,t=Tl){super("Die",t,e);this.defect=e}toString(){return`Die(${B(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[Ce](e){return na(e)&&Y(this.defect,e.defect)&&Y(this.annotations,e.annotations)}[Ie](){return xt(qe(this._tag))(xt(re(this.defect))(re(this.annotations)))}};_c=p((e)=>Oc(e[0]),(e,t,n)=>{if(t.mapUnsafe.size===0)return e;return new Jo(e.reasons.map((r)=>r.annotate(t,n)))});je=eC({op:"Success",prop:"value",[St](e){let t=e.getCont(In);return t?t[In](this[ie],e,this):e.yieldWith(this)}}),jp={key:"effect/Cause/StackTrace"},Hy={key:"effect/Cause/InterruptorStackTrace"},pn=eC({op:"Failure",prop:"cause",[St](e){let t=this[ie],n=!1;if(e.currentStackFrame)t=_c(t,{mapUnsafe:new Map([[jp.key,e.currentStackFrame]])}),n=!0;let r=e.getCont(wr);while(e.interruptible&&e._interruptedCause&&r)r=e.getCont(wr);return r?r[wr](t,e,n?void 0:this):e.yieldWith(n?pn(t):this)}}),ce=vr({op:"WithFiber",[St](e){return this[ie](e)}}),rz=function(){class e extends globalThis.Error{}let t=Yo({op:"YieldableError",[St](){return kr(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Al=function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends rz{constructor(n){super(n?.message,n?.cause?{cause:n.cause}:void 0);if(n)$p(this,n),Object.defineProperty(this,e,{value:n,enumerable:!1})}toJSON(){return{...this[e],...this}}}}();yo=class yo extends Qo("NoSuchElementError"){[Il]=Il;constructor(e){super({message:e})}};tC={[ea]:ea,_tag:"Done",value:void 0},oz=kr(tC)});var So=(e)=>Yo({op:e.label,[St]:e.evaluate});var Pc=w(()=>{rt()});function Hp(e){return{combine:e}}function Ir(e,t,n){return{combine:e,initialValue:t,combineAll:n??((r)=>{let o=t;for(let s of r)o=e(o,s);return o})}}function sC(e){return Kt((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var Kt=(e)=>(t,n)=>t===n||e(t,n),sz=(e,t)=>e===t,oC=()=>sz;var Xo=()=>{};var Fc=(e)=>p(3,(t,n,r)=>e(t,(o)=>({...o,[n]:r(o)}))),Mc=(e)=>p(2,(t,n)=>e(t,(r)=>({[n]:r}))),Nc=(e,t)=>p(3,(n,r,o)=>t(n,(s)=>e(o(s),(i)=>({...s,[r]:i}))));var qp=w(()=>{X()});var iC="~effect/data/Option",aC,iz,az,cz,zp=(e)=>M(e,iC),ei=(e)=>e._tag==="None",zy=(e)=>e._tag==="Some",oa,es=(e)=>{let t=Object.create(iz);return t.value=e,t};var Wp=w(()=>{yt();kn();Xt();jn();he();Qi();rt();aC={[iC]:{_A:(e)=>e},...Cn,[Symbol.iterator](){return new Zs(this)}},iz=Object.defineProperty(Object.assign(Object.create(aC),{_tag:"Some",_op:"Some",[Ce](e){return zp(e)&&zy(e)&&Y(this.value,e.value)},[Ie](){return xt(re(this._tag))(re(this.value))},toString(){return`some(${B(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:Wt(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),az=re("None"),cz=Object.assign(Object.create(aC),{_tag:"None",_op:"None",valueOrUndefined:void 0,[Ce](e){return zp(e)&&ei(e)},[Ie](){return az},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),oa=Object.create(cz)});var cC="~effect/data/Result",uC,uz,lz,Kp=(e)=>M(e,cC),Dc=(e)=>e._tag==="Failure",$c=(e)=>e._tag==="Success",Fl=(e)=>{let t=Object.create(lz);return t.failure=e,t},Ml=(e)=>{let t=Object.create(uz);return t.success=e,t},Vp=(e)=>$c(e)?oa:es(e.failure),Gp=(e)=>Dc(e)?oa:es(e.success),lC;var Ky=w(()=>{yt();kn();X();Xt();jn();he();Qi();rt();Wp();uC={[cC]:{_A:(e)=>e,_E:(e)=>e},...Cn,[Symbol.iterator](){return new Zs(this)}},uz=Object.assign(Object.create(uC),{_tag:"Success",_op:"Success",[Ce](e){return Kp(e)&&$c(e)&&Y(this.success,e.success)},[Ie](){return xt(re(this._tag))(re(this.success))},toString(){return`success(${B(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:Wt(this.success)}}}),lz=Object.assign(Object.create(uC),{_tag:"Failure",_op:"Failure",[Ce](e){return Kp(e)&&Dc(e)&&Y(this.failure,e.failure)},[Ie](){return xt(re(this._tag))(re(this.failure))},toString(){return`failure(${B(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:Wt(this.failure)}}}),lC=p(2,(e,t)=>ei(e)?Fl(t()):Ml(e.value))});function ts(e){return(t,n)=>t===n?0:e(t,n)}var rr,Cr,Vy,sa,Uc=(e)=>p(2,(t,n)=>e(t,n)===-1),ti=(e)=>p(2,(t,n)=>e(t,n)===1),Nl=(e)=>p(2,(t,n)=>e(t,n)!==1),Dl=(e)=>p(2,(t,n)=>e(t,n)!==-1);var ia=w(()=>{X();rr=ts((e,t)=>{if(globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t))return 0;if(globalThis.Number.isNaN(e))return-1;if(globalThis.Number.isNaN(t))return 1;return e<t?-1:1}),Cr=ts((e,t)=>e<t?-1:1),Vy=p(2,(e,t)=>ts((n,r)=>e(t(n),t(r)))),sa=Vy(rr,(e)=>e.getTime())});var be={};Un(be,{Do:()=>Uz,all:()=>Oz,andThen:()=>wz,as:()=>pC,asVoid:()=>Ez,bind:()=>$z,bindTo:()=>Nz,composeK:()=>Cz,contains:()=>Mz,containsWith:()=>yC,exists:()=>Qy,filter:()=>ca,filterMap:()=>Rz,firstSomeOf:()=>xz,flatMap:()=>rs,flatMapNullishOr:()=>vz,flatten:()=>aa,fromIterable:()=>dz,fromNullOr:()=>Gy,fromNullishOr:()=>Tn,fromUndefinedOr:()=>ns,gen:()=>Lz,getFailure:()=>pz,getOrElse:()=>mt,getOrNull:()=>Jp,getOrThrow:()=>Sz,getOrThrowWith:()=>Jy,getOrUndefined:()=>mn,getSuccess:()=>dC,isNone:()=>me,isOption:()=>jc,isSome:()=>Ee,let:()=>Dz,lift2:()=>Fz,liftNullishOr:()=>yz,liftPredicate:()=>Yy,liftThrowable:()=>ni,makeCombinerFailFast:()=>SC,makeEquivalence:()=>Zy,makeOrder:()=>Pz,makeReducer:()=>jz,makeReducerFailFast:()=>Bz,map:()=>en,match:()=>et,none:()=>O,orElse:()=>mz,orElseResult:()=>gz,orElseSome:()=>hz,partitionMap:()=>_z,product:()=>hC,productMany:()=>Tz,reduceCompact:()=>Az,some:()=>_,tap:()=>mC,toArray:()=>xC,toRefinement:()=>fz,void:()=>bz,zipLeft:()=>Iz,zipRight:()=>kz,zipWith:()=>gC});function jz(e){return Ir((t,n)=>{if(me(t))return n;if(me(n))return t;return _(e.combine(t.value,n.value))},O())}function SC(e){return Hp((t,n)=>{if(me(t)||me(n))return O();return _(e.combine(t.value,n.value))})}function Bz(e){let t=SC(e).combine,n=_(e.initialValue);return Ir(t,n,(r)=>{let o=n;for(let s of r)if(o=t(o,s),me(o))return o;return o})}var O=()=>oa,_,jc,me,Ee,et,fz=(e)=>(t)=>Ee(e(t)),dz=(e)=>{for(let t of e)return _(t);return O()},dC,pz,mt,mz,hz,gz,xz=(e)=>{let t=O();for(t of e)if(Ee(t))return t;return t},Tn=(e)=>e==null?O():_(e),ns=(e)=>e===void 0?O():_(e),Gy=(e)=>e===null?O():_(e),yz=(e)=>(...t)=>Tn(e(...t)),Jp,mn,ni=(e)=>(...t)=>{try{return _(e(...t))}catch{return O()}},Jy,Sz,en,pC,Ez,bz,rs,wz,vz,aa,kz,Iz,Cz,mC,hC=(e,t)=>Ee(e)&&Ee(t)?_([e.value,t.value]):O(),Tz=(e,t)=>{if(me(e))return O();let n=[e.value];for(let r of t){if(me(r))return O();n.push(r.value)}return _(n)},Oz=(e)=>{if(Symbol.iterator in e){let n=[];for(let r of e){if(me(r))return O();n.push(r.value)}return _(n)}let t={};for(let n of Object.keys(e)){let r=e[n];if(me(r))return O();U(t,n,r.value)}return _(t)},gC,Az,xC=(e)=>me(e)?[]:[e.value],_z,Rz,ca,Zy=(e)=>Kt((t,n)=>me(t)?me(n):me(n)?!1:e(t.value,n.value)),Pz=(e)=>ts((t,n)=>Ee(t)?Ee(n)?e(t.value,n.value):1:-1),Fz=(e)=>p(2,(t,n)=>gC(t,n,e)),Yy,yC=(e)=>p(2,(t,n)=>me(t)?!1:e(t.value,n)),Mz,Qy,Nz,Dz,$z,Uz,Lz=(...e)=>{let n=(e.length===1?e[0]:e[1].bind(e[0]))(),r=n.next();while(!r.done){let o=r.value;if(me(o))return o;r=n.next(o.value)}return _(r.value)};var _e=w(()=>{yt();Xo();X();qp();Wp();Ky();ia();he();_=es,jc=zp,me=ei,Ee=zy,et=p(2,(e,{onNone:t,onSome:n})=>me(e)?t():n(e.value)),dC=Gp,pz=Vp,mt=p(2,(e,t)=>me(e)?t():e.value),mz=p(2,(e,t)=>me(e)?t():e),hz=p(2,(e,t)=>me(e)?_(t()):e),gz=p(2,(e,t)=>me(e)?en(t(),Ml):en(e,Fl)),Jp=mt(Tp),mn=mt(qr),Jy=p(2,(e,t)=>{if(Ee(e))return e.value;throw t()}),Sz=Jy(()=>Error("getOrThrow called on a None")),en=p(2,(e,t)=>me(e)?O():_(t(e.value))),pC=p(2,(e,t)=>en(e,()=>t)),Ez=pC(void 0),bz=_(void 0),rs=p(2,(e,t)=>me(e)?O():t(e.value)),wz=p(2,(e,t)=>rs(e,(n)=>{let r=ln(t)?t(n):t;return jc(r)?r:_(r)})),vz=p(2,(e,t)=>me(e)?O():Tn(t(e.value))),aa=rs(D),kz=p(2,(e,t)=>rs(e,()=>t)),Iz=p(2,(e,t)=>mC(e,()=>t)),Cz=p(2,(e,t)=>(n)=>rs(e(n),t)),mC=p(2,(e,t)=>rs(e,(n)=>en(t(n),()=>n))),gC=p(3,(e,t,n)=>en(hC(e,t),([r,o])=>n(r,o))),Az=p(3,(e,t,n)=>{let r=t;for(let o of e)if(Ee(o))r=n(r,o.value);return r}),_z=p(2,(e,t)=>{if(me(e))return[O(),O()];let n=t(e.value);return Dc(n)?[_(n.failure),O()]:[O(),_(n.success)]}),Rz=p(2,(e,t)=>{if(me(e))return O();let n=t(e.value);return $c(n)?_(n.success):O()}),ca=p(2,(e,t)=>me(e)?O():t(e.value)?_(e.value):O()),Yy=p(2,(e,t)=>t(e)?_(e):O()),Mz=yC(Dy()),Qy=p(2,(e,t)=>me(e)?!1:t(e.value)),Nz=Mc(en),Dz=Fc(en),$z=Nc(en,rs),Uz=_({})});var EC="~effect/Context/Service",ze=function(){function e(){}let t=e;Object.setPrototypeOf(t,Hz);let n=(r,o)=>{if(t.key=r,o?.defaultValue)t[eS]=eS,t.defaultValue=o.defaultValue;if(o?.make)t.make=o.make;if(o?.fiberCached)bC.add(r);return t};return arguments.length>0?n(arguments[0],arguments[1]):n},Hz,bC,eS="~effect/Context/Reference",wC="~effect/Context",qz=8,zz=8,tS=(e,t,n,r)=>{let o=Object.create(Kz);return o.cacheRoot=e??o,o.base=t,o.overlay=n,o.depth=r,o._flat=void 0,o.baseHits=0,o},vC=(e,t)=>{if(!t)return;vC(e,t.parent),e.set(t.key,t.value)},kC=(e)=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return vC(t,e.overlay),e._flat=t},Wz=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),ri(n)},Zp,nS=(e,t)=>{let n=e;for(let o=n.overlay;o;o=o.parent)if(o.key===t)return o.value;let r=n.base.get(t);if(r===void 0&&!n.base.has(t))return Zp;if(n.overlay&&++n.baseHits>=zz)n.base=kC(n),n.overlay=void 0,n.depth=0;return r},ri=(e)=>tS(void 0,e,void 0,0),Kz,IC=(e,t)=>e.cacheRoot===t.cacheRoot,rS=(e)=>M(e,wC),CC=(e)=>!!e[eS],hn=()=>Vz,Vz,os=(e,t)=>ri(new Map([[e.key,t]])),tn,Gz=(e,t,n)=>{let r=e,o=bC.has(t)?void 0:r.cacheRoot;if(r.depth>=qz){let s=new Map(r.mapUnsafe);return s.set(t,n),tS(o,s,void 0,0)}return tS(o,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},Yp,$l=(e,t)=>{let n=nS(e,t);return n===Zp?void 0:n},Gr,On,Xy="~effect/Context/defaultValue",TC=(e)=>{if(Xy in e)return e[Xy];return e[Xy]=e.defaultValue()},Jz=(e)=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let n=t.stack.split(`
|
|
9
|
+
${s(l)}}`;f=i(u,m)}}return r.delete(u),f}return String(u)}return c(e,0)}function $s(e){return typeof e==="string"?JSON.stringify(e):String(e)}function Qm(e){return e.map((t)=>`[${$s(t)}]`).join("")}function uE(e){try{return e.toISOString()}catch{return"Invalid Date"}}function lV(e){try{let t=e.toString();return typeof t==="string"?t:String(t)}catch{return"[toString threw]"}}function Ga(e,t){let n=[];return JSON.stringify(e,function(r,o){let s=Object.getOwnPropertyDescriptor(this,r)?.value,i=D(s,Df)?vu(s):vu(o);if(typeof i==="bigint")return j(i);if(typeof i!=="object"||i===null)return i;while(n.length>0&&n[n.length-1]!==this)n.pop();if(n.includes(i))return;return n.push(i),i},t?.space)??"null"}var uV="[Circular]";var Zn=v(()=>{ge();Jm()});var zt,fn=(e)=>{try{if(e=vu(e),D(e,"toJSON")&&Mn(e.toJSON)&&e.toJSON.length===0)return e.toJSON();else if(Array.isArray(e))return e.map(fn);return e}catch{return"[toJSON threw]"}},BA=(e,t=2)=>{if(typeof e==="string")return e;try{return typeof e==="object"?Ga(e,{space:t}):j(e,{space:t})}catch{return String(e)}},HA,fV;var pr=v(()=>{Zn();ge();Jm();zt=Symbol.for("nodejs.util.inspect.custom"),HA={toJSON(){return fn(this)},[zt](){return this.toJSON()},toString(){return j(this.toJSON())}};fV=class fV{[zt](){return this.toJSON()}toString(){return j(this.toJSON())}}});var Hi,dV=()=>{let t={["~effect/Utils/internal"]:(o)=>o()},n={["~effect/Utils/internal"]:(o)=>{try{return o()}finally{}}};return t["~effect/Utils/internal"](()=>Error().stack)?.includes("~effect/Utils/internal")===!0?t["~effect/Utils/internal"]:n["~effect/Utils/internal"]},Fe;var Ja=v(()=>{Hi=class Hi{called=!1;self;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new Hi(this.self)}};Fe=dV()});function H(e,t,n){if(t==="__proto__")Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0});else e[t]=n}function Zm(e,t){for(let n of Reflect.ownKeys(t))if(Object.prototype.propertyIsEnumerable.call(t,n))H(e,n,t[n])}function hV(e){return Oo("Effect.evaluate: Not implemented")}var rs="~effect/Effect",Qa="~effect/Exit",pV,qA,ce,Rt,Yn,to,Wi,Ya,Xn,zA,mV,de=(e)=>D(e,rs),lE=(e)=>D(e,Qa),Au="~effect/Cause",Tu="~effect/Cause/Reason",_u=(e)=>D(e,Au),VA=(e)=>D(e,Tu),Us,jA,$f,Uf,Ou,Ls=(e)=>new Us(e),Ym,Lf=(e)=>new Us([new Ou(e)]),Xm,fE=(e)=>new Us([new Xm(e)]),Pu,ji=(e)=>e._tag==="Fail",Xa=(e)=>e._tag==="Die",ec=(e)=>e._tag==="Interrupt",Bs=(e)=>({...mV,[qA]:e.op,[Rt]:e[Rt]??hV,[Yn]:e[Yn],[to]:e[to],[Wi]:e[Wi]}),no=(e)=>{let t=Bs(e);return function(){let n=Object.create(t);return n[ce]=e.single===!1?arguments:arguments[0],n}},KA=(e)=>{let t={[Qa]:Qa,_tag:e.op,get[e.prop](){return this[ce]},...Bs(e),toString(){return`${e.op}(${j(this[ce])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[ce]}},[Oe](n){return lE(n)&&n._tag===this._tag&&ee(this[ce],n[ce])},[_e](){return Ot(Ze(e.op),ie(this[ce]))}};return function(n){let r=Object.create(t);return r[ce]=n,r}},Ke,eh,dE,$n,ro=(e)=>$n(Lf(e)),Oo=(e)=>$n(fE(e)),le,gV,Bf,Hs=(e)=>{class t extends Bf{_tag=e}return t.prototype.name=e,t},Nf="~effect/Cause/NoSuchElementError",th=(e)=>D(e,Nf),os,Za="~effect/Cause/Done",Hf=(e)=>D(e,Za),GA,Ru=(e)=>{if(e===void 0)return GA;return{[Za]:Za,_tag:"Done",value:e}},xV,JA=(e)=>{if(e===void 0)return xV;return ro(Ru(e))};var pt=v(()=>{Pt();Zn();ne();wn();pr();ct();ge();Ja();pV={_A:L,_E:L,_R:L},qA=`${rs}/identifier`,ce=`${rs}/args`,Rt=`${rs}/evaluate`,Yn=`${rs}/successCont`,to=`${rs}/failureCont`,Wi=`${rs}/ensureCont`,Ya=Symbol.for("effect/Effect/Yield"),Xn={pipe(){return fe(this,arguments)},toJSON(){return{...this}},toString(){return j(this.toJSON(),{ignoreToString:!0,space:2})},[zt](){return this.toJSON()}},zA={[_e](){return tE(this,Object.keys(this))},[Oe](e){let t=Object.keys(this),n=Object.keys(e);if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==n[r]||!ee(this[t[r]],e[t[r]]))return!1;return!0}},mV={[rs]:pV,...Xn,[Symbol.iterator](){return new Hi(this)},toJSON(){return{_id:"Effect",op:this[qA],...ce in this?{args:this[ce]}:void 0}}};Us=class Us{[Au];reasons;constructor(e){this[Au]=Au,this.reasons=e}pipe(){return fe(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map((e)=>e.toJSON())}}toString(){return`Cause(${j(this.reasons)})`}[zt](){return this.toJSON()}[Oe](e){return _u(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>ee(t,e.reasons[n]))}[_e](){return Cu(this.reasons)}};jA=new WeakMap;$f=class $f{[Tu];annotations;_tag;constructor(e,t,n){if(this[Tu]=Tu,this._tag=e,t!==Uf&&typeof n==="object"&&n!==null&&t.size>0){let r=jA.get(n);if(r)t=new Map([...r,...t]);jA.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);e.mapUnsafe.forEach((o,s)=>{if(t?.overwrite!==!0&&n.has(s))return;n.set(s,o)});let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return fe(this,arguments)}toString(){return j(this)}[zt](){return this.toString()}};Uf=new Map;Ou=class Ou extends $f{error;constructor(e,t=Uf){super("Fail",t,e);this.error=e}toString(){return`Fail(${j(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[Oe](e){return ji(e)&&ee(this.error,e.error)&&ee(this.annotations,e.annotations)}[_e](){return Ot(Ze(this._tag))(Ot(ie(this.error))(ie(this.annotations)))}};Ym=new Us([]);Xm=class Xm extends $f{defect;constructor(e,t=Uf){super("Die",t,e);this.defect=e}toString(){return`Die(${j(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[Oe](e){return Xa(e)&&ee(this.defect,e.defect)&&ee(this.annotations,e.annotations)}[_e](){return Ot(Ze(this._tag))(Ot(ie(this.defect))(ie(this.annotations)))}};Pu=p((e)=>_u(e[0]),(e,t,n)=>{if(t.mapUnsafe.size===0)return e;return new Us(e.reasons.map((r)=>r.annotate(t,n)))});Ke=KA({op:"Success",prop:"value",[Rt](e){let t=e.getCont(Yn);return t?t[Yn](this[ce],e,this):e.yieldWith(this)}}),eh={key:"effect/Cause/StackTrace"},dE={key:"effect/Cause/InterruptorStackTrace"},$n=KA({op:"Failure",prop:"cause",[Rt](e){let t=this[ce],n=!1;if(e.currentStackFrame)t=Pu(t,{mapUnsafe:new Map([[eh.key,e.currentStackFrame]])}),n=!0;let r=e.getCont(to);while(e.interruptible&&e._interruptedCause&&r)r=e.getCont(to);return r?r[to](t,e,n?void 0:this):e.yieldWith(n?$n(t):this)}}),le=no({op:"WithFiber",[Rt](e){return this[ce](e)}}),gV=function(){class e extends globalThis.Error{}let t=Bs({op:"YieldableError",[Rt](){return ro(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Bf=function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends gV{constructor(n){super(n?.message,n?.cause?{cause:n.cause}:void 0);if(n)Zm(this,n),Object.defineProperty(this,e,{value:n,enumerable:!1})}toJSON(){return{...this[e],...this}}}}();os=class os extends Hs("NoSuchElementError"){[Nf]=Nf;constructor(e){super({message:e})}};GA={[Za]:Za,_tag:"Done",value:void 0},xV=ro(GA)});var ss=(e)=>Bs({op:e.label,[Rt]:e.evaluate});var Fu=v(()=>{pt()});function nh(e){return{combine:e}}function oo(e,t,n){return{combine:e,initialValue:t,combineAll:n??((r)=>{let o=t;for(let s of r)o=e(o,s);return o})}}function YA(e){return dn((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var dn=(e)=>(t,n)=>t===n||e(t,n),yV=(e,t)=>e===t,ZA=()=>yV;var Ws=()=>{};var Mu=(e)=>p(3,(t,n,r)=>e(t,(o)=>({...o,[n]:r(o)}))),Du=(e)=>p(2,(t,n)=>e(t,(r)=>({[n]:r}))),Nu=(e,t)=>p(3,(n,r,o)=>t(n,(s)=>e(o(s),(i)=>({...s,[r]:i}))));var rh=v(()=>{ne()});var XA="~effect/data/Option",eT,SV,EV,bV,oh=(e)=>D(e,XA),zi=(e)=>e._tag==="None",mE=(e)=>e._tag==="Some",tc,js=(e)=>{let t=Object.create(SV);return t.value=e,t};var sh=v(()=>{Pt();Zn();wn();pr();ge();Ja();pt();eT={[XA]:{_A:(e)=>e},...Xn,[Symbol.iterator](){return new Hi(this)}},SV=Object.defineProperty(Object.assign(Object.create(eT),{_tag:"Some",_op:"Some",[Oe](e){return oh(e)&&mE(e)&&ee(this.value,e.value)},[_e](){return Ot(ie(this._tag))(ie(this.value))},toString(){return`some(${j(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:fn(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),EV=ie("None"),bV=Object.assign(Object.create(eT),{_tag:"None",_op:"None",valueOrUndefined:void 0,[Oe](e){return oh(e)&&zi(e)},[_e](){return EV},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),tc=Object.create(bV)});var tT="~effect/data/Result",nT,wV,kV,ih=(e)=>D(e,tT),$u=(e)=>e._tag==="Failure",Uu=(e)=>e._tag==="Success",qf=(e)=>{let t=Object.create(kV);return t.failure=e,t},zf=(e)=>{let t=Object.create(wV);return t.success=e,t},ah=(e)=>Uu(e)?tc:js(e.failure),ch=(e)=>$u(e)?tc:js(e.success),rT;var gE=v(()=>{Pt();Zn();ne();wn();pr();ge();Ja();pt();sh();nT={[tT]:{_A:(e)=>e,_E:(e)=>e},...Xn,[Symbol.iterator](){return new Hi(this)}},wV=Object.assign(Object.create(nT),{_tag:"Success",_op:"Success",[Oe](e){return ih(e)&&Uu(e)&&ee(this.success,e.success)},[_e](){return Ot(ie(this._tag))(ie(this.success))},toString(){return`success(${j(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:fn(this.success)}}}),kV=Object.assign(Object.create(nT),{_tag:"Failure",_op:"Failure",[Oe](e){return ih(e)&&$u(e)&&ee(this.failure,e.failure)},[_e](){return Ot(ie(this._tag))(ie(this.failure))},toString(){return`failure(${j(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:fn(this.failure)}}}),rT=p(2,(e,t)=>zi(e)?qf(t()):zf(e.value))});function qs(e){return(t,n)=>t===n?0:e(t,n)}var Mr,so,xE,nc,Lu=(e)=>p(2,(t,n)=>e(t,n)===-1),Vi=(e)=>p(2,(t,n)=>e(t,n)===1),Vf=(e)=>p(2,(t,n)=>e(t,n)!==1),Kf=(e)=>p(2,(t,n)=>e(t,n)!==-1);var rc=v(()=>{ne();Mr=qs((e,t)=>{if(globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t))return 0;if(globalThis.Number.isNaN(e))return-1;if(globalThis.Number.isNaN(t))return 1;return e<t?-1:1}),so=qs((e,t)=>e<t?-1:1),xE=p(2,(e,t)=>qs((n,r)=>e(t(n),t(r)))),nc=xE(Mr,(e)=>e.getTime())});var ve={};Qn(ve,{Do:()=>ZV,all:()=>HV,andThen:()=>DV,as:()=>iT,asVoid:()=>FV,bind:()=>QV,bindTo:()=>GV,composeK:()=>LV,contains:()=>KV,containsWith:()=>fT,exists:()=>wE,filter:()=>sc,filterMap:()=>qV,firstSomeOf:()=>OV,flatMap:()=>Vs,flatMapNullishOr:()=>NV,flatten:()=>oc,fromIterable:()=>vV,fromNullOr:()=>yE,fromNullishOr:()=>er,fromUndefinedOr:()=>zs,gen:()=>YV,getFailure:()=>IV,getOrElse:()=>It,getOrNull:()=>uh,getOrThrow:()=>RV,getOrThrowWith:()=>SE,getOrUndefined:()=>Un,getSuccess:()=>sT,isNone:()=>he,isOption:()=>Hu,isSome:()=>Ce,let:()=>JV,lift2:()=>VV,liftNullishOr:()=>PV,liftPredicate:()=>bE,liftThrowable:()=>Ki,makeCombinerFailFast:()=>dT,makeEquivalence:()=>EE,makeOrder:()=>zV,makeReducer:()=>XV,makeReducerFailFast:()=>e3,map:()=>kn,match:()=>ut,none:()=>P,orElse:()=>AV,orElseResult:()=>_V,orElseSome:()=>TV,partitionMap:()=>jV,product:()=>cT,productMany:()=>BV,reduceCompact:()=>WV,some:()=>F,tap:()=>aT,toArray:()=>lT,toRefinement:()=>CV,void:()=>MV,zipLeft:()=>UV,zipRight:()=>$V,zipWith:()=>uT});function XV(e){return oo((t,n)=>{if(he(t))return n;if(he(n))return t;return F(e.combine(t.value,n.value))},P())}function dT(e){return nh((t,n)=>{if(he(t)||he(n))return P();return F(e.combine(t.value,n.value))})}function e3(e){let t=dT(e).combine,n=F(e.initialValue);return oo(t,n,(r)=>{let o=n;for(let s of r)if(o=t(o,s),he(o))return o;return o})}var P=()=>tc,F,Hu,he,Ce,ut,CV=(e)=>(t)=>Ce(e(t)),vV=(e)=>{for(let t of e)return F(t);return P()},sT,IV,It,AV,TV,_V,OV=(e)=>{let t=P();for(t of e)if(Ce(t))return t;return t},er=(e)=>e==null?P():F(e),zs=(e)=>e===void 0?P():F(e),yE=(e)=>e===null?P():F(e),PV=(e)=>(...t)=>er(e(...t)),uh,Un,Ki=(e)=>(...t)=>{try{return F(e(...t))}catch{return P()}},SE,RV,kn,iT,FV,MV,Vs,DV,NV,oc,$V,UV,LV,aT,cT=(e,t)=>Ce(e)&&Ce(t)?F([e.value,t.value]):P(),BV=(e,t)=>{if(he(e))return P();let n=[e.value];for(let r of t){if(he(r))return P();n.push(r.value)}return F(n)},HV=(e)=>{if(Symbol.iterator in e){let n=[];for(let r of e){if(he(r))return P();n.push(r.value)}return F(n)}let t={};for(let n of Object.keys(e)){let r=e[n];if(he(r))return P();H(t,n,r.value)}return F(t)},uT,WV,lT=(e)=>he(e)?[]:[e.value],jV,qV,sc,EE=(e)=>dn((t,n)=>he(t)?he(n):he(n)?!1:e(t.value,n.value)),zV=(e)=>qs((t,n)=>Ce(t)?Ce(n)?e(t.value,n.value):1:-1),VV=(e)=>p(2,(t,n)=>uT(t,n,e)),bE,fT=(e)=>p(2,(t,n)=>he(t)?!1:e(t.value,n)),KV,wE,GV,JV,QV,ZV,YV=(...e)=>{let n=(e.length===1?e[0]:e[1].bind(e[0]))(),r=n.next();while(!r.done){let o=r.value;if(he(o))return o;r=n.next(o.value)}return F(r.value)};var Me=v(()=>{Pt();Ws();ne();rh();sh();gE();rc();ge();F=js,Hu=oh,he=zi,Ce=mE,ut=p(2,(e,{onNone:t,onSome:n})=>he(e)?t():n(e.value)),sT=ch,IV=ah,It=p(2,(e,t)=>he(e)?t():e.value),AV=p(2,(e,t)=>he(e)?t():e),TV=p(2,(e,t)=>he(e)?F(t()):e),_V=p(2,(e,t)=>he(e)?kn(t(),zf):kn(e,qf)),uh=It(Hm),Un=It(Ao),SE=p(2,(e,t)=>{if(Ce(e))return e.value;throw t()}),RV=SE(()=>Error("getOrThrow called on a None")),kn=p(2,(e,t)=>he(e)?P():F(t(e.value))),iT=p(2,(e,t)=>kn(e,()=>t)),FV=iT(void 0),MV=F(void 0),Vs=p(2,(e,t)=>he(e)?P():t(e.value)),DV=p(2,(e,t)=>Vs(e,(n)=>{let r=Mn(t)?t(n):t;return Hu(r)?r:F(r)})),NV=p(2,(e,t)=>he(e)?P():er(t(e.value))),oc=Vs(L),$V=p(2,(e,t)=>Vs(e,()=>t)),UV=p(2,(e,t)=>aT(e,()=>t)),LV=p(2,(e,t)=>(n)=>Vs(e(n),t)),aT=p(2,(e,t)=>Vs(e,(n)=>kn(t(n),()=>n))),uT=p(3,(e,t,n)=>kn(cT(e,t),([r,o])=>n(r,o))),WV=p(3,(e,t,n)=>{let r=t;for(let o of e)if(Ce(o))r=n(r,o.value);return r}),jV=p(2,(e,t)=>{if(he(e))return[P(),P()];let n=t(e.value);return $u(n)?[F(n.failure),P()]:[P(),F(n.success)]}),qV=p(2,(e,t)=>{if(he(e))return P();let n=t(e.value);return Uu(n)?F(n.success):P()}),sc=p(2,(e,t)=>he(e)?P():t(e.value)?F(e.value):P()),bE=p(2,(e,t)=>t(e)?F(e):P()),KV=fT(iE()),wE=p(2,(e,t)=>he(e)?!1:t(e.value)),GV=Du(kn),JV=Mu(kn),QV=Nu(kn,Vs),ZV=F({})});var pT="~effect/Context/Service",Ye=function(){function e(){}let t=e;Object.setPrototypeOf(t,t3);let n=(r,o)=>{if(t.key=r,o?.defaultValue)t[CE]=CE,t.defaultValue=o.defaultValue;if(o?.make)t.make=o.make;if(o?.fiberCached)mT.add(r);return t};return arguments.length>0?n(arguments[0],arguments[1]):n},t3,mT,CE="~effect/Context/Reference",hT="~effect/Context",n3=8,r3=8,vE=(e,t,n,r)=>{let o=Object.create(s3);return o.cacheRoot=e??o,o.base=t,o.overlay=n,o.depth=r,o._flat=void 0,o.baseHits=0,o},gT=(e,t)=>{if(!t)return;gT(e,t.parent),e.set(t.key,t.value)},xT=(e)=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return gT(t,e.overlay),e._flat=t},o3=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),Gi(n)},lh,IE=(e,t)=>{let n=e;for(let o=n.overlay;o;o=o.parent)if(o.key===t)return o.value;let r=n.base.get(t);if(r===void 0&&!n.base.has(t))return lh;if(n.overlay&&++n.baseHits>=r3)n.base=xT(n),n.overlay=void 0,n.depth=0;return r},Gi=(e)=>vE(void 0,e,void 0,0),s3,yT=(e,t)=>e.cacheRoot===t.cacheRoot,AE=(e)=>D(e,hT),ST=(e)=>!!e[CE],Ln=()=>i3,i3,Ks=(e,t)=>Gi(new Map([[e.key,t]])),Cn,a3=(e,t,n)=>{let r=e,o=mT.has(t)?void 0:r.cacheRoot;if(r.depth>=n3){let s=new Map(r.mapUnsafe);return s.set(t,n),vE(o,s,void 0,0)}return vE(o,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},fh,Gf=(e,t)=>{let n=IE(e,t);return n===lh?void 0:n},Ro,tr,kE="~effect/Context/defaultValue",ET=(e)=>{if(kE in e)return e[kE];return e[kE]=e.defaultValue()},c3=(e)=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let n=t.stack.split(`
|
|
10
10
|
`);n.splice(1,3),t.stack=n.join(`
|
|
11
|
-
`)}return t},oS,ua,OC=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((r,o)=>{t.set(o,r)});return ri(t)},ke;var Ve=w(()=>{Pc();yt();X();Xt();rt();_e();he();Hz={[EC]:EC,...So({label:"Service",evaluate(e){return je(On(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return os(this,e)},use(e){return ce((t)=>e(On(t.context,this)))},useSync(e){return ce((t)=>je(e(On(t.context,this))))}},bC=new Set,Zp=Symbol(),Kz={get mapUnsafe(){return kC(this)},...Cn,[wC]:{_Services:(e)=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[Ce](e){if(!rS(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[r,o]of t)if(!n.has(r)||!Y(o,n.get(r)))return!1;return!0},[Ie](){return Ln(this.mapUnsafe.size)}},Vz=ri(new Map),tn=p(3,(e,t,n)=>Gz(e,t.key,n)),Yp=p(2,(e,t)=>$l(e,t.key)),Gr=p(2,(e,t)=>{let n=nS(e,t.key);if(n===Zp){if(CC(t))return TC(t);throw Jz(t)}return n}),On=Gr,oS=p(2,(e,t)=>{let n=nS(e,t.key);if(n!==Zp)return _(n);return CC(t)?_(TC(t)):O()}),ua=p(2,(e,t)=>{if(e.mapUnsafe.size===0)return t;if(t.mapUnsafe.size===0)return e;return Wz(e,(n)=>t.mapUnsafe.forEach((r,o)=>n.set(o,r)))}),ke=ze});var sS=(e)=>e.length>0;var Vt={};Un(Vt,{Do:()=>mW,all:()=>fW,andThen:()=>lW,bind:()=>hW,bindTo:()=>gW,fail:()=>te,failVoid:()=>Qz,filterOrFail:()=>sW,flatMap:()=>si,flip:()=>dW,fromNullishOr:()=>Xz,fromOption:()=>eW,gen:()=>pW,getFailure:()=>nW,getOrElse:()=>oi,getOrNull:()=>aW,getOrThrow:()=>_C,getOrThrowWith:()=>AC,getOrUndefined:()=>cW,getSuccess:()=>tW,isFailure:()=>xe,isResult:()=>Qp,isSuccess:()=>Ut,let:()=>xW,liftPredicate:()=>oW,makeEquivalence:()=>aS,map:()=>or,mapBoth:()=>rW,mapError:()=>Bc,match:()=>Bn,merge:()=>iW,orElse:()=>uW,succeed:()=>G,succeedNone:()=>cS,succeedSome:()=>EW,tap:()=>bW,transposeMapOption:()=>SW,transposeOption:()=>yW,try:()=>iS,void:()=>Yz});var G,te,Yz,Qz,Xz,eW,iS=(e)=>{if(ln(e))try{return G(e())}catch(t){return te(t)}else try{return G(e.try())}catch(t){return te(e.catch(t))}},Qp,xe,Ut,tW,nW,aS=(e,t)=>Kt((n,r)=>xe(n)?xe(r)&&t(n.failure,r.failure):Ut(r)&&e(n.success,r.success)),rW,Bc,or,Bn,oW,sW,iW,oi,aW,cW,AC,_C,uW,si,lW,fW=(e)=>{if(Symbol.iterator in e){let n=[];for(let r of e){if(xe(r))return r;n.push(r.success)}return G(n)}let t={};for(let n of Object.keys(e)){let r=e[n];if(xe(r))return r;U(t,n,r.success)}return G(t)},dW=(e)=>xe(e)?G(e.failure):te(e.success),pW=(...e)=>{let n=(e.length===1?e[0]:e[1].bind(e[0]))(),r=n.next();while(!r.done){let o=r.value;if(xe(o))return o;r=n.next(o.success)}return G(r.value)},mW,hW,gW,xW,yW=(e)=>ei(e)?cS:or(e.value,es),SW,cS,EW=(e)=>G(es(e)),bW;var gn=w(()=>{Xo();X();qp();Wp();Ky();he();G=Ml,te=Fl,Yz=G(void 0),Qz=te(void 0),Xz=p(2,(e,t)=>e==null?te(t(e)):G(e)),eW=lC,Qp=Kp,xe=Dc,Ut=$c,tW=Gp,nW=Vp,rW=p(2,(e,{onFailure:t,onSuccess:n})=>xe(e)?te(t(e.failure)):G(n(e.success))),Bc=p(2,(e,t)=>xe(e)?te(t(e.failure)):e),or=p(2,(e,t)=>Ut(e)?G(t(e.success)):e),Bn=p(2,(e,{onFailure:t,onSuccess:n})=>xe(e)?t(e.failure):n(e.success)),oW=p(3,(e,t,n)=>t(e)?G(e):te(n(e))),sW=p(3,(e,t,n)=>si(e,(r)=>t(r)?G(r):te(n(r)))),iW=Bn({onFailure:D,onSuccess:D}),oi=p(2,(e,t)=>xe(e)?t(e.failure):e.success),aW=oi(Tp),cW=oi(qr),AC=p(2,(e,t)=>{if(Ut(e))return e.success;throw t(e.failure)}),_C=AC(D),uW=p(2,(e,t)=>xe(e)?t(e.failure):G(e.success)),si=p(2,(e,t)=>xe(e)?te(e.failure):t(e.success)),lW=p(2,(e,t)=>si(e,(n)=>{let r=ln(t)?t(n):t;return Qp(r)?r:G(r)})),mW=G({}),hW=Nc(or,si),gW=Mc(or),xW=Fc(or),SW=p(2,(e,t)=>ei(e)?cS:or(t(e.value),es)),cS=G(oa),bW=p(2,(e,t)=>{if(Ut(e))t(e.success);return e})});var RC,nce,wW,PC;var uS=w(()=>{X();_e();he();RC=p(2,(e,t)=>{let n=0;for(let r of e){let o=t(r,n);if(Op(o)){if(o)return _(r)}else if(Ee(o))return o;n++}return O()}),nce={[Symbol.iterator](){return wW}},wW={next(){return{done:!0,value:void 0}}},PC=p(2,(e,t)=>({[Symbol.iterator](){let n=e[Symbol.iterator](),r=0;return{next(){let o=n.next();while(!o.done){if(t(o.value,r++))return{done:!1,value:o.value};o=n.next()}return{done:!0,value:void 0}}}}}))});var MC,vW=(e)=>Object.keys(e);var NC=w(()=>{X();MC=p(2,(e,t)=>{let n={...e};for(let r of vW(e))U(n,r,t(e[r],r));return n})});function LC(){return TW}var Xp,Lt=(e)=>Xp.isArray(e)?e:Xp.from(e),DC=(e)=>Xp.isArray(e)?e:[e],Ul,lS,$C,IW,la,Hn,UC,em,fS,dS,CW=(e,t)=>{let n=re(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let o of r)if(Y(o,t))return!1;return r.push(t),!0},pS,fa=()=>[],da=(e)=>[e],jt,mS=(e)=>{let t=[];for(let n of e)if(Ee(n))t.push(n.value);return t},hS,Ll,tm=(e)=>{let t=Lt(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let o of t)if(CW(n,o))r.push(o);return r},TW;var An=w(()=>{yt();X();Xt();uS();_e();gn();Xp=globalThis.Array,Ul=p(2,(e,{onEmpty:t,onNonEmpty:n})=>Hn(e)?n(e):t()),lS=p(2,(e,t)=>[...e,t]),$C=p(2,(e,t)=>Lt(e).concat(Lt(t))),IW=Xp.isArray,la=sS,Hn=sS,UC=p(2,(e,t)=>{let n=0,r=[];for(let o of e){if(!t(o,n))break;r.push(o),n++}return r}),em=p(2,(e,t)=>{let n=0;for(let r of e){if(t(r,n))return _(n);n++}return O()}),fS=RC,dS=p(2,(e,t)=>{let n=Lt(e);for(let r=n.length-1;r>=0;r--){let o=n[r],s=t(o,r);if(typeof s==="boolean"){if(s)return _(o)}else if(Ee(s))return s}return O()}),pS=p(2,(e,t)=>{let n=Lt(e),r=Lt(t);if(Hn(n))return Hn(r)?tm($C(n,r)):n;return r}),jt=p(2,(e,t)=>e.map(t)),hS=p(2,(e,t)=>{let n=[],r=[],o=0;for(let s of e){let i=t(s,o++);if(Ut(i))r.push(i.success);else n.push(i.failure)}return[n,r]}),Ll=p(3,(e,t,n)=>Lt(e).reduce((r,o,s)=>n(r,o,s),t)),TW=Ir((e,t)=>e.concat(t),[])});var nm="~effect/time/Duration",qC,zC,OW,AW,_W,rm=(e)=>BigInt(e<0?Math.ceil(e-0.5):Math.floor(e+0.5)),WC=(e)=>rm(e*1e6),jC=(e,t)=>{let n=e.indexOf(".");if(n===-1)return BigInt(e)*t;let r=e[0]==="-",o=e.slice(n+1),s=AW**BigInt(o.length),i=(BigInt(e.slice(r?1:0,n))*s+BigInt(o))*t,a=i/s+(i%s*OW>=s?zC:qC);return r?-a:a},RW,sr=(e)=>{switch(typeof e){case"number":return ii(e);case"bigint":return Tr(e);case"string":{if(e==="Infinity")return ss;if(e==="-Infinity")return pa;let t=RW.exec(e);if(!t)break;let[n,r,o]=t;if(o==="nano"||o==="nanos")return Tr(jC(r,zC));if(o==="micro"||o==="micros")return Tr(jC(r,_W));let s=Number(r);switch(o){case"milli":case"millis":return ii(s);case"second":case"seconds":return NW(s);case"minute":case"minutes":return DW(s);case"hour":case"hours":return $W(s);case"day":case"days":return UW(s);case"week":case"weeks":return LW(s)}break}case"object":{if(e===null)break;if(nm in e)return e;if(Array.isArray(e)){if(e.length!==2||!e.every(bl))return BC(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return Hc;if(e[0]===-1/0||e[1]===-1/0)return pa;if(e[0]===1/0||e[1]===1/0)return ss;return _n(rm(e[0]*1e9+e[1]))}let t=e,n=0;if(t.weeks)n+=t.weeks*604800000;if(t.days)n+=t.days*86400000;if(t.hours)n+=t.hours*3600000;if(t.minutes)n+=t.minutes*60000;if(t.seconds)n+=t.seconds*1000;if(t.milliseconds)n+=t.milliseconds;if(!t.microseconds&&!t.nanoseconds)return _n(n);return _n(rm(n*1e6+(t.microseconds??0)*1000+(t.nanoseconds??0)))}}return BC(e)},BC=(e)=>{throw Error(`Invalid Input: ${e}`)},KC,HC,PW,FW,MW,_n=(e)=>{let t=Object.create(MW);if(typeof e==="number")if(isNaN(e)||e===0||Object.is(e,-0))t.value=HC;else if(!Number.isFinite(e))t.value=e>0?PW:FW;else if(!Number.isInteger(e))t.value={_tag:"Nanos",nanos:WC(e)};else t.value={_tag:"Millis",millis:e};else if(e===qC)t.value=HC;else t.value={_tag:"Nanos",nanos:e};return t},xS=(e)=>M(e,nm),VC=(e)=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity",Hc,ss,pa,Tr=(e)=>_n(e),ii=(e)=>_n(e),NW=(e)=>_n(e*1000),DW=(e)=>_n(e*60000),$W=(e)=>_n(e*3600000),UW=(e)=>_n(e*86400000),LW=(e)=>_n(e*604800000),qc=(e)=>jW(sr(e),{onMillis:D,onNanos:(t)=>Number(t)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),gS=(e)=>{let t=sr(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return WC(t.value.millis)}},GC,jW,JC,yS=(e,t)=>JC(e,t,{onMillis:(n,r)=>n===r,onNanos:(n,r)=>n===r,onInfinity:(n,r)=>n.value._tag===r.value._tag}),ZC,BW;var ai=w(()=>{yt();X();Xt();jn();_e();Qe();he();qC=BigInt(0),zC=BigInt(1),OW=BigInt(2),AW=BigInt(10),_W=BigInt(1000),RW=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,KC=ni(sr),HC={_tag:"Millis",millis:0},PW={_tag:"Infinity"},FW={_tag:"NegativeInfinity"},MW={[nm]:nm,[Ie](){switch(this.value._tag){case"Millis":{let e=this.value.millis*1e6;return Number.isFinite(e)?re(rm(e)):Ln(this.value.millis)}case"Nanos":return re(this.value.nanos);default:return Py(this.value)}},[Ce](e){return xS(e)&&BW(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[At](){return this.toJSON()},pipe(){return le(this,arguments)}},Hc=_n(0),ss=_n(1/0),pa=_n(-1/0),GC=ni(gS),jW=p(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),JC=p(3,(e,t,n)=>{if(e.value._tag==="Infinity"||e.value._tag==="NegativeInfinity"||t.value._tag==="Infinity"||t.value._tag==="NegativeInfinity")return n.onInfinity(e,t);if(e.value._tag==="Millis")return t.value._tag==="Millis"?n.onMillis(e.value.millis,t.value.millis):n.onNanos(gS(e),t.value.nanos);else return n.onNanos(e.value.nanos,gS(t))}),ZC=p(2,(e,t)=>JC(e,t,{onMillis:(n,r)=>_n(n-r),onNanos:(n,r)=>_n(n-r),onInfinity:(n,r)=>{let o=n.value._tag,s=r.value._tag;if(o==="Infinity")return s==="Infinity"?Hc:ss;if(o==="NegativeInfinity")return s==="NegativeInfinity"?Hc:pa;return s==="Infinity"?pa:ss}})),BW=p(2,(e,t)=>yS(e,t))});var SS,YC=(e)=>(t)=>{let n=e(t);return xe(n)?O():_(n.success)};var QC=w(()=>{X();_e();gn();SS=p(2,(e,t)=>(n)=>{let r=e(n);if(xe(r))return te(n);let o=t(r.success);if(xe(o))return te(n);return o})});class eT{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,o,s=0;for(;s<r;s++){if(n[s][0]>t)break;o=n[s]}if(o&&o[0]===t)o[1].push(e);else if(s===r)n.push([t,[e]]);else n.splice(s,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class zc{executionMode;setImmediate;constructor(e="async",t){this.executionMode=e,this.setImmediate=t??(e==="sync"?qW:XC)}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new tT(this.setImmediate)}}class tT{tasks=new eT;running=void 0;setImmediate;constructor(e=XC){this.setImmediate=e}scheduleTask(e,t){if(this.tasks.scheduleTask(e,t),this.running===void 0)this.running=this.setImmediate(this.afterScheduled)}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let r=0;r<n.length;r++)n[r]()}}flush(){while(this.tasks.buckets.length>0){if(this.running!==void 0)this.running(),this.running=void 0;this.runTasks()}}}var jl,XC,qW=(e)=>{let t=!1;return Promise.resolve().then(()=>{if(!t)e()}),()=>{t=!0}},nT,rT;var om=w(()=>{Ve();jl=ke("effect/Scheduler",{fiberCached:!0,defaultValue:()=>new zc}),XC="setImmediate"in globalThis?(e)=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:(e)=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};nT=ke("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:()=>2048}),rT=ke("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:()=>!1})});var Or={};Un(Or,{Class:()=>sm,Error:()=>bS,TaggedClass:()=>zW,TaggedError:()=>ci,taggedEnum:()=>ES});function WW(){if(arguments.length===1){let n=arguments[0];return function(r){return n[r._tag](r)}}let e=arguments[0];return arguments[1][e._tag](e)}var sm,zW=(e)=>class extends sm{_tag=e},ES=()=>new Proxy({},{get(e,t,n){if(t==="$is")return br;else if(t==="$match")return WW;return(r)=>({...r,_tag:t})}}),bS,ci;var Wc=w(()=>{rt();Qe();he();sm=class extends Gi{constructor(e){super();if(e)$p(this,e)}};bS=Al,ci=Qo});function im(e){if(e>=iT.length)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=iT[e];if(t===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}var sT="~effect/encoding/EncodingError",ui,am=(e)=>typeof e==="string"?wS(CS.encode(e)):wS(e),Vc=(e)=>{let t=hT(e),n=t.length;if(n%4!==0)return te(new ui({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf("=");if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!=="="))return te(new ui({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let o=t.endsWith("==")?2:t.endsWith("=")?1:0,s=new Uint8Array(3*(n/4)-o);for(let i=0,a=0;i<n;i+=4,a+=3){let c=im(t.charCodeAt(i))<<18|im(t.charCodeAt(i+1))<<12|im(t.charCodeAt(i+2))<<6|im(t.charCodeAt(i+3));s[a]=c>>16,s[a+1]=c>>8&255,s[a+2]=c&255}return G(s)}catch(o){return te(new ui({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},lT=(e)=>or(Vc(e),(t)=>TS.decode(t)),fT=(e)=>typeof e==="string"?aT(CS.encode(e)):aT(e),vS=(e)=>{let t=hT(e),n=t.length;if(n%4===1)return te(new ui({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${n}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return te(new ui({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let r=n%4===2?`${t}==`:n%4===3?`${t}=`:t;return r=r.replace(/-/g,"+").replace(/_/g,"/"),Vc(r)},dT=(e)=>or(vS(e),(t)=>TS.decode(t)),pT=(e)=>typeof e==="string"?cT(CS.encode(e)):cT(e),kS=(e)=>{let t="";for(let n=e>>>3;n>0;n--){let r=Math.random()*4294967296>>>0;t+=Kc[r>>>24]+Kc[r>>>16&255]+Kc[r>>>8&255]+Kc[r&255]}return t},IS=(e)=>{let t=new TextEncoder().encode(e);if(t.length%2!==0)return te(new ui({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let n=t.length/2,r=new Uint8Array(n);for(let o=0;o<n;o++){let s=uT(t[o*2]),i=uT(t[o*2+1]);r[o]=s<<4|i}return G(r)}catch(n){return te(new ui({module:"Hex",kind:"Decode",input:e,message:n instanceof Error?n.message:"Invalid input"}))}},mT=(e)=>or(IS(e),(t)=>TS.decode(t)),CS,TS,hT=(e)=>e.replace(/[\n\r]/g,""),wS=(e)=>{let t=e.length,n="",r;for(r=2;r<t;r+=3)n+=is[e[r-2]>>2],n+=is[(e[r-2]&3)<<4|e[r-1]>>4],n+=is[(e[r-1]&15)<<2|e[r]>>6],n+=is[e[r]&63];if(r===t+1)n+=is[e[r-2]>>2],n+=is[(e[r-2]&3)<<4],n+="==";if(r===t)n+=is[e[r-2]>>2],n+=is[(e[r-2]&3)<<4|e[r-1]>>4],n+=is[(e[r-1]&15)<<2],n+="=";return n},is,iT,aT=(e)=>wS(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),Kc,cT=(e)=>{let t="";for(let n=0;n<e.length;n++)t+=Kc[e[n]];return t},uT=(e)=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw TypeError("Invalid input")};var cm=w(()=>{Wc();gn();ui=class ui extends ci("EncodingError"){[sT]=sT};CS=new TextEncoder,TS=new TextDecoder;is=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],iT=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],Kc=[];for(let e=0;e<256;e++)Kc.push(e.toString(16).padStart(2,"0"))});class yT{_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:"Started",startTime:e.startTime},this.attributes=new Map,this.traceId=mn(e.parent)?.traceId??kS(32),this.spanId=kS(16)}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)}}var AS="effect/Tracer/ParentSpan",um,KW=(e)=>e,lm,gT,xT,_S="effect/Tracer",fm;var ST=w(()=>{Ve();cm();X();_e();um=class um extends ze()(AS,{fiberCached:!0}){};lm=ke("effect/Tracer/DisablePropagation",{defaultValue:Sl}),gT=ke("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),xT=ke("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),fm=ke(_S,{fiberCached:!0,defaultValue:()=>KW({span:(e)=>new yT(e)})})});var ET="effect/observability/Metric/FiberRuntimeMetricsKey";var bT,Bl,dm,Gc,Hl,ql,as,RS,pm,mm;var PS=w(()=>{Ve();X();bT=ke("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),Bl=ke("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:qr}),dm=ke("effect/References/TracerEnabled",{defaultValue:nr}),Gc=ke("effect/References/TracerTimingEnabled",{defaultValue:nr}),Hl=ke("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),ql=ke("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),as=ke("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),RS=ke("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),pm=ke("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),mm=ke("effect/References/CurrentLogSpans",{defaultValue:()=>[]})});var ZW=()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");if(e===void 0)return Object.isExtensible(Error);return Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},YW,li=()=>Error.stackTraceLimit,ir=(e)=>{if(YW)Error.stackTraceLimit=e};var hm=w(()=>{YW=ZW()});var gm=(e)=>{if(e?.captureStackTrace===!1)return e;else if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=="boolean")return e;let t=li();ir(3);let n=Error();return ir(t),{...e,captureStackTrace:QW(()=>n.stack)}},FS=(e)=>(t)=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let o=r.split(`
|
|
12
|
-
`);if(o[e]!==void 0)return n=o[e].trim(),n}},
|
|
13
|
-
`),s=[r];for(let i=1;i<o.length;i++){if(/(?:Generator\.next|~effect\/Effect)/.test(o[i]))break;s.push(o[i])}return n?
|
|
11
|
+
`)}return t},TE,ic,bT=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((r,o)=>{t.set(o,r)});return Gi(t)},Te;var rt=v(()=>{Fu();Pt();ne();wn();pt();Me();ge();t3={[pT]:pT,...ss({label:"Service",evaluate(e){return Ke(tr(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return Ks(this,e)},use(e){return le((t)=>e(tr(t.context,this)))},useSync(e){return le((t)=>Ke(e(tr(t.context,this))))}},mT=new Set,lh=Symbol(),s3={get mapUnsafe(){return xT(this)},...Xn,[hT]:{_Services:(e)=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[Oe](e){if(!AE(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[r,o]of t)if(!n.has(r)||!ee(o,n.get(r)))return!1;return!0},[_e](){return dr(this.mapUnsafe.size)}},i3=Gi(new Map),Cn=p(3,(e,t,n)=>a3(e,t.key,n)),fh=p(2,(e,t)=>Gf(e,t.key)),Ro=p(2,(e,t)=>{let n=IE(e,t.key);if(n===lh){if(ST(t))return ET(t);throw c3(t)}return n}),tr=Ro,TE=p(2,(e,t)=>{let n=IE(e,t.key);if(n!==lh)return F(n);return ST(t)?F(ET(t)):P()}),ic=p(2,(e,t)=>{if(e.mapUnsafe.size===0)return t;if(t.mapUnsafe.size===0)return e;return o3(e,(n)=>t.mapUnsafe.forEach((r,o)=>n.set(o,r)))}),Te=Ye});var _E=(e)=>e.length>0;var Yt={};Qn(Yt,{Do:()=>A3,all:()=>C3,andThen:()=>k3,bind:()=>T3,bindTo:()=>_3,fail:()=>oe,failVoid:()=>f3,filterOrFail:()=>y3,flatMap:()=>Qi,flip:()=>v3,fromNullishOr:()=>d3,fromOption:()=>p3,gen:()=>I3,getFailure:()=>h3,getOrElse:()=>Ji,getOrNull:()=>E3,getOrThrow:()=>kT,getOrThrowWith:()=>wT,getOrUndefined:()=>b3,getSuccess:()=>m3,isFailure:()=>Se,isResult:()=>dh,isSuccess:()=>rn,let:()=>O3,liftPredicate:()=>x3,makeEquivalence:()=>PE,map:()=>Dr,mapBoth:()=>g3,mapError:()=>Wu,match:()=>mr,merge:()=>S3,orElse:()=>w3,succeed:()=>J,succeedNone:()=>RE,succeedSome:()=>F3,tap:()=>M3,transposeMapOption:()=>R3,transposeOption:()=>P3,try:()=>OE,void:()=>l3});var J,oe,l3,f3,d3,p3,OE=(e)=>{if(Mn(e))try{return J(e())}catch(t){return oe(t)}else try{return J(e.try())}catch(t){return oe(e.catch(t))}},dh,Se,rn,m3,h3,PE=(e,t)=>dn((n,r)=>Se(n)?Se(r)&&t(n.failure,r.failure):rn(r)&&e(n.success,r.success)),g3,Wu,Dr,mr,x3,y3,S3,Ji,E3,b3,wT,kT,w3,Qi,k3,C3=(e)=>{if(Symbol.iterator in e){let n=[];for(let r of e){if(Se(r))return r;n.push(r.success)}return J(n)}let t={};for(let n of Object.keys(e)){let r=e[n];if(Se(r))return r;H(t,n,r.success)}return J(t)},v3=(e)=>Se(e)?J(e.failure):oe(e.success),I3=(...e)=>{let n=(e.length===1?e[0]:e[1].bind(e[0]))(),r=n.next();while(!r.done){let o=r.value;if(Se(o))return o;r=n.next(o.success)}return J(r.value)},A3,T3,_3,O3,P3=(e)=>zi(e)?RE:Dr(e.value,js),R3,RE,F3=(e)=>J(js(e)),M3;var Bn=v(()=>{Ws();ne();rh();sh();gE();ge();J=zf,oe=qf,l3=J(void 0),f3=oe(void 0),d3=p(2,(e,t)=>e==null?oe(t(e)):J(e)),p3=rT,dh=ih,Se=$u,rn=Uu,m3=ch,h3=ah,g3=p(2,(e,{onFailure:t,onSuccess:n})=>Se(e)?oe(t(e.failure)):J(n(e.success))),Wu=p(2,(e,t)=>Se(e)?oe(t(e.failure)):e),Dr=p(2,(e,t)=>rn(e)?J(t(e.success)):e),mr=p(2,(e,{onFailure:t,onSuccess:n})=>Se(e)?t(e.failure):n(e.success)),x3=p(3,(e,t,n)=>t(e)?J(e):oe(n(e))),y3=p(3,(e,t,n)=>Qi(e,(r)=>t(r)?J(r):oe(n(r)))),S3=mr({onFailure:L,onSuccess:L}),Ji=p(2,(e,t)=>Se(e)?t(e.failure):e.success),E3=Ji(Hm),b3=Ji(Ao),wT=p(2,(e,t)=>{if(rn(e))return e.success;throw t(e.failure)}),kT=wT(L),w3=p(2,(e,t)=>Se(e)?t(e.failure):J(e.success)),Qi=p(2,(e,t)=>Se(e)?oe(e.failure):t(e.success)),k3=p(2,(e,t)=>Qi(e,(n)=>{let r=Mn(t)?t(n):t;return dh(r)?r:J(r)})),A3=J({}),T3=Nu(Dr,Qi),_3=Du(Dr),O3=Mu(Dr),R3=p(2,(e,t)=>zi(e)?RE:Dr(t(e.value),js)),RE=J(tc),M3=p(2,(e,t)=>{if(rn(e))t(e.success);return e})});var CT,Ele,D3,vT;var FE=v(()=>{ne();Me();ge();CT=p(2,(e,t)=>{let n=0;for(let r of e){let o=t(r,n);if(Wm(o)){if(o)return F(r)}else if(Ce(o))return o;n++}return P()}),Ele={[Symbol.iterator](){return D3}},D3={next(){return{done:!0,value:void 0}}},vT=p(2,(e,t)=>({[Symbol.iterator](){let n=e[Symbol.iterator](),r=0;return{next(){let o=n.next();while(!o.done){if(t(o.value,r++))return{done:!1,value:o.value};o=n.next()}return{done:!0,value:void 0}}}}}))});var AT,N3=(e)=>Object.keys(e);var TT=v(()=>{ne();AT=p(2,(e,t)=>{let n={...e};for(let r of N3(e))H(n,r,t(e[r],r));return n})});function RT(){return B3}var ph,on=(e)=>ph.isArray(e)?e:ph.from(e),_T=(e)=>ph.isArray(e)?e:[e],Jf,ME,OT,U3,ac,hr,PT,mh,DE,NE,L3=(e,t)=>{let n=ie(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let o of r)if(ee(o,t))return!1;return r.push(t),!0},$E,cc=()=>[],uc=(e)=>[e],sn,UE=(e)=>{let t=[];for(let n of e)if(Ce(n))t.push(n.value);return t},LE,Qf,hh=(e)=>{let t=on(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let o of t)if(L3(n,o))r.push(o);return r},B3;var nr=v(()=>{Pt();ne();wn();FE();Me();Bn();ph=globalThis.Array,Jf=p(2,(e,{onEmpty:t,onNonEmpty:n})=>hr(e)?n(e):t()),ME=p(2,(e,t)=>[...e,t]),OT=p(2,(e,t)=>on(e).concat(on(t))),U3=ph.isArray,ac=_E,hr=_E,PT=p(2,(e,t)=>{let n=0,r=[];for(let o of e){if(!t(o,n))break;r.push(o),n++}return r}),mh=p(2,(e,t)=>{let n=0;for(let r of e){if(t(r,n))return F(n);n++}return P()}),DE=CT,NE=p(2,(e,t)=>{let n=on(e);for(let r=n.length-1;r>=0;r--){let o=n[r],s=t(o,r);if(typeof s==="boolean"){if(s)return F(o)}else if(Ce(s))return s}return P()}),$E=p(2,(e,t)=>{let n=on(e),r=on(t);if(hr(n))return hr(r)?hh(OT(n,r)):n;return r}),sn=p(2,(e,t)=>e.map(t)),LE=p(2,(e,t)=>{let n=[],r=[],o=0;for(let s of e){let i=t(s,o++);if(rn(i))r.push(i.success);else n.push(i.failure)}return[n,r]}),Qf=p(3,(e,t,n)=>on(e).reduce((r,o,s)=>n(r,o,s),t)),B3=oo((e,t)=>e.concat(t),[])});var gh="~effect/time/Duration",NT,$T,H3,W3,j3,xh=(e)=>BigInt(e<0?Math.ceil(e-0.5):Math.floor(e+0.5)),UT=(e)=>xh(e*1e6),FT=(e,t)=>{let n=e.indexOf(".");if(n===-1)return BigInt(e)*t;let r=e[0]==="-",o=e.slice(n+1),s=W3**BigInt(o.length),i=(BigInt(e.slice(r?1:0,n))*s+BigInt(o))*t,a=i/s+(i%s*H3>=s?$T:NT);return r?-a:a},q3,Nr=(e)=>{switch(typeof e){case"number":return Zi(e);case"bigint":return io(e);case"string":{if(e==="Infinity")return Gs;if(e==="-Infinity")return lc;let t=q3.exec(e);if(!t)break;let[n,r,o]=t;if(o==="nano"||o==="nanos")return io(FT(r,$T));if(o==="micro"||o==="micros")return io(FT(r,j3));let s=Number(r);switch(o){case"milli":case"millis":return Zi(s);case"second":case"seconds":return G3(s);case"minute":case"minutes":return J3(s);case"hour":case"hours":return Q3(s);case"day":case"days":return Z3(s);case"week":case"weeks":return Y3(s)}break}case"object":{if(e===null)break;if(gh in e)return e;if(Array.isArray(e)){if(e.length!==2||!e.every(Rf))return MT(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return ju;if(e[0]===-1/0||e[1]===-1/0)return lc;if(e[0]===1/0||e[1]===1/0)return Gs;return rr(xh(e[0]*1e9+e[1]))}let t=e,n=0;if(t.weeks)n+=t.weeks*604800000;if(t.days)n+=t.days*86400000;if(t.hours)n+=t.hours*3600000;if(t.minutes)n+=t.minutes*60000;if(t.seconds)n+=t.seconds*1000;if(t.milliseconds)n+=t.milliseconds;if(!t.microseconds&&!t.nanoseconds)return rr(n);return rr(xh(n*1e6+(t.microseconds??0)*1000+(t.nanoseconds??0)))}}return MT(e)},MT=(e)=>{throw Error(`Invalid Input: ${e}`)},LT,DT,z3,V3,K3,rr=(e)=>{let t=Object.create(K3);if(typeof e==="number")if(isNaN(e)||e===0||Object.is(e,-0))t.value=DT;else if(!Number.isFinite(e))t.value=e>0?z3:V3;else if(!Number.isInteger(e))t.value={_tag:"Nanos",nanos:UT(e)};else t.value={_tag:"Millis",millis:e};else if(e===NT)t.value=DT;else t.value={_tag:"Nanos",nanos:e};return t},HE=(e)=>D(e,gh),BT=(e)=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity",ju,Gs,lc,io=(e)=>rr(e),Zi=(e)=>rr(e),G3=(e)=>rr(e*1000),J3=(e)=>rr(e*60000),Q3=(e)=>rr(e*3600000),Z3=(e)=>rr(e*86400000),Y3=(e)=>rr(e*604800000),qu=(e)=>X3(Nr(e),{onMillis:L,onNanos:(t)=>Number(t)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),BE=(e)=>{let t=Nr(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return UT(t.value.millis)}},HT,X3,WT,WE=(e,t)=>WT(e,t,{onMillis:(n,r)=>n===r,onNanos:(n,r)=>n===r,onInfinity:(n,r)=>n.value._tag===r.value._tag}),jT,eK;var Yi=v(()=>{Pt();ne();wn();pr();Me();ct();ge();NT=BigInt(0),$T=BigInt(1),H3=BigInt(2),W3=BigInt(10),j3=BigInt(1000),q3=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,LT=Ki(Nr),DT={_tag:"Millis",millis:0},z3={_tag:"Infinity"},V3={_tag:"NegativeInfinity"},K3={[gh]:gh,[_e](){switch(this.value._tag){case"Millis":{let e=this.value.millis*1e6;return Number.isFinite(e)?ie(xh(e)):dr(this.value.millis)}case"Nanos":return ie(this.value.nanos);default:return nE(this.value)}},[Oe](e){return HE(e)&&eK(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[zt](){return this.toJSON()},pipe(){return fe(this,arguments)}},ju=rr(0),Gs=rr(1/0),lc=rr(-1/0),HT=Ki(BE),X3=p(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),WT=p(3,(e,t,n)=>{if(e.value._tag==="Infinity"||e.value._tag==="NegativeInfinity"||t.value._tag==="Infinity"||t.value._tag==="NegativeInfinity")return n.onInfinity(e,t);if(e.value._tag==="Millis")return t.value._tag==="Millis"?n.onMillis(e.value.millis,t.value.millis):n.onNanos(BE(e),t.value.nanos);else return n.onNanos(e.value.nanos,BE(t))}),jT=p(2,(e,t)=>WT(e,t,{onMillis:(n,r)=>rr(n-r),onNanos:(n,r)=>rr(n-r),onInfinity:(n,r)=>{let o=n.value._tag,s=r.value._tag;if(o==="Infinity")return s==="Infinity"?ju:Gs;if(o==="NegativeInfinity")return s==="NegativeInfinity"?ju:lc;return s==="Infinity"?lc:Gs}})),eK=p(2,(e,t)=>WE(e,t))});var jE,qT=(e)=>(t)=>{let n=e(t);return Se(n)?P():F(n.success)};var zT=v(()=>{ne();Me();Bn();jE=p(2,(e,t)=>(n)=>{let r=e(n);if(Se(r))return oe(n);let o=t(r.success);if(Se(o))return oe(n);return o})});class KT{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,o,s=0;for(;s<r;s++){if(n[s][0]>t)break;o=n[s]}if(o&&o[0]===t)o[1].push(e);else if(s===r)n.push([t,[e]]);else n.splice(s,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class zu{executionMode;setImmediate;constructor(e="async",t){this.executionMode=e,this.setImmediate=t??(e==="sync"?nK:VT)}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new GT(this.setImmediate)}}class GT{tasks=new KT;running=void 0;setImmediate;constructor(e=VT){this.setImmediate=e}scheduleTask(e,t){if(this.tasks.scheduleTask(e,t),this.running===void 0)this.running=this.setImmediate(this.afterScheduled)}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let r=0;r<n.length;r++)n[r]()}}flush(){while(this.tasks.buckets.length>0){if(this.running!==void 0)this.running(),this.running=void 0;this.runTasks()}}}var Zf,VT,nK=(e)=>{let t=!1;return Promise.resolve().then(()=>{if(!t)e()}),()=>{t=!0}},JT,QT;var yh=v(()=>{rt();Zf=Te("effect/Scheduler",{fiberCached:!0,defaultValue:()=>new zu}),VT="setImmediate"in globalThis?(e)=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:(e)=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};JT=Te("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:()=>2048}),QT=Te("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:()=>!1})});var xr={};Qn(xr,{Class:()=>Sh,Error:()=>zE,TaggedClass:()=>rK,TaggedError:()=>Xi,taggedEnum:()=>qE});function oK(){if(arguments.length===1){let n=arguments[0];return function(r){return n[r._tag](r)}}let e=arguments[0];return arguments[1][e._tag](e)}var Sh,rK=(e)=>class extends Sh{_tag=e},qE=()=>new Proxy({},{get(e,t,n){if(t==="$is")return eo;else if(t==="$match")return oK;return(r)=>({...r,_tag:t})}}),zE,Xi;var Vu=v(()=>{pt();ct();ge();Sh=class extends za{constructor(e){super();if(e)Zm(this,e)}};zE=Bf,Xi=Hs});function Eh(e){if(e>=XT.length)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=XT[e];if(t===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}var YT="~effect/encoding/EncodingError",ea,bh=(e)=>typeof e==="string"?VE(QE.encode(e)):VE(e),Gu=(e)=>{let t=c_(e),n=t.length;if(n%4!==0)return oe(new ea({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf("=");if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!=="="))return oe(new ea({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let o=t.endsWith("==")?2:t.endsWith("=")?1:0,s=new Uint8Array(3*(n/4)-o);for(let i=0,a=0;i<n;i+=4,a+=3){let c=Eh(t.charCodeAt(i))<<18|Eh(t.charCodeAt(i+1))<<12|Eh(t.charCodeAt(i+2))<<6|Eh(t.charCodeAt(i+3));s[a]=c>>16,s[a+1]=c>>8&255,s[a+2]=c&255}return J(s)}catch(o){return oe(new ea({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},r_=(e)=>Dr(Gu(e),(t)=>ZE.decode(t)),o_=(e)=>typeof e==="string"?e_(QE.encode(e)):e_(e),KE=(e)=>{let t=c_(e),n=t.length;if(n%4===1)return oe(new ea({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${n}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return oe(new ea({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let r=n%4===2?`${t}==`:n%4===3?`${t}=`:t;return r=r.replace(/-/g,"+").replace(/_/g,"/"),Gu(r)},s_=(e)=>Dr(KE(e),(t)=>ZE.decode(t)),i_=(e)=>typeof e==="string"?t_(QE.encode(e)):t_(e),GE=(e)=>{let t="";for(let n=e>>>3;n>0;n--){let r=Math.random()*4294967296>>>0;t+=Ku[r>>>24]+Ku[r>>>16&255]+Ku[r>>>8&255]+Ku[r&255]}return t},JE=(e)=>{let t=new TextEncoder().encode(e);if(t.length%2!==0)return oe(new ea({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let n=t.length/2,r=new Uint8Array(n);for(let o=0;o<n;o++){let s=n_(t[o*2]),i=n_(t[o*2+1]);r[o]=s<<4|i}return J(r)}catch(n){return oe(new ea({module:"Hex",kind:"Decode",input:e,message:n instanceof Error?n.message:"Invalid input"}))}},a_=(e)=>Dr(JE(e),(t)=>ZE.decode(t)),QE,ZE,c_=(e)=>e.replace(/[\n\r]/g,""),VE=(e)=>{let t=e.length,n="",r;for(r=2;r<t;r+=3)n+=Js[e[r-2]>>2],n+=Js[(e[r-2]&3)<<4|e[r-1]>>4],n+=Js[(e[r-1]&15)<<2|e[r]>>6],n+=Js[e[r]&63];if(r===t+1)n+=Js[e[r-2]>>2],n+=Js[(e[r-2]&3)<<4],n+="==";if(r===t)n+=Js[e[r-2]>>2],n+=Js[(e[r-2]&3)<<4|e[r-1]>>4],n+=Js[(e[r-1]&15)<<2],n+="=";return n},Js,XT,e_=(e)=>VE(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),Ku,t_=(e)=>{let t="";for(let n=0;n<e.length;n++)t+=Ku[e[n]];return t},n_=(e)=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw TypeError("Invalid input")};var wh=v(()=>{Vu();Bn();ea=class ea extends Xi("EncodingError"){[YT]=YT};QE=new TextEncoder,ZE=new TextDecoder;Js=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],XT=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],Ku=[];for(let e=0;e<256;e++)Ku.push(e.toString(16).padStart(2,"0"))});class f_{_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:"Started",startTime:e.startTime},this.attributes=new Map,this.traceId=Un(e.parent)?.traceId??GE(32),this.spanId=GE(16)}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)}}var XE="effect/Tracer/ParentSpan",kh,sK=(e)=>e,Ch,u_,l_,eb="effect/Tracer",vh;var d_=v(()=>{rt();wh();ne();Me();kh=class kh extends Ye()(XE,{fiberCached:!0}){};Ch=Te("effect/Tracer/DisablePropagation",{defaultValue:Of}),u_=Te("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),l_=Te("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),vh=Te(eb,{fiberCached:!0,defaultValue:()=>sK({span:(e)=>new f_(e)})})});var p_="effect/observability/Metric/FiberRuntimeMetricsKey";var m_,Yf,Ih,Ju,Xf,ed,Qs,tb,Ah,Th;var nb=v(()=>{rt();ne();m_=Te("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),Yf=Te("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:Ao}),Ih=Te("effect/References/TracerEnabled",{defaultValue:Fr}),Ju=Te("effect/References/TracerTimingEnabled",{defaultValue:Fr}),Xf=Te("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),ed=Te("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),Qs=Te("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),tb=Te("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),Ah=Te("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),Th=Te("effect/References/CurrentLogSpans",{defaultValue:()=>[]})});var uK=()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");if(e===void 0)return Object.isExtensible(Error);return Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},lK,ta=()=>Error.stackTraceLimit,$r=(e)=>{if(lK)Error.stackTraceLimit=e};var _h=v(()=>{lK=uK()});var Oh=(e)=>{if(e?.captureStackTrace===!1)return e;else if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=="boolean")return e;let t=ta();$r(3);let n=Error();return $r(t),{...e,captureStackTrace:fK(()=>n.stack)}},rb=(e)=>(t)=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let o=r.split(`
|
|
12
|
+
`);if(o[e]!==void 0)return n=o[e].trim(),n}},fK;var h_=v(()=>{_h();fK=rb(3)});class RP{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return E_;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let t=0;t<this.waiters.length;t++)this.scheduled.push(this.waiters[t]);return this.waiters=[],E_}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](or)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](or)}open=le((e)=>{if(this._isOpen)return b_;return this._isOpen=!0,this.scheduleUnsafe(e)});release=le((e)=>this._isOpen?b_:this.scheduleUnsafe(e));openUnsafe(){if(this._isOpen)return!1;return this._isOpen=!0,this.flushWaiters(),!0}await=an((e)=>{if(this._isOpen)return e(Ee);return this.waiters.push(e),me(()=>{let t=this.waiters.indexOf(e);if(t!==-1)this.waiters.splice(t,1);else if(this.scheduled!==void 0){if(t=this.scheduled.indexOf(e),t!==-1)this.scheduled.splice(t,1)}})});closeUnsafe(){if(!this._isOpen)return!1;return this._isOpen=!1,!0}close=me(()=>this.closeUnsafe());whenOpen=(e)=>V(this.await,()=>e);isOpen(){return this._isOpen}}class JP{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=me(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return LK()}currentTimeNanos=me(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return ZP()}monotonicTimeNanos=me(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(qu(e))}sleepMillis(e){if(e<=0)return Xu;else if(!Number.isFinite(e))return Wh;return an((t)=>{let n=e>ob?this.sleepMillis(e-ob):Ee,r=setTimeout(()=>t(n),Math.min(e,ob));return me(()=>clearTimeout(r))})}}function QK(){ib.interruptChildren??=bK}var fb,w_=(e)=>new fb(e),pc=(e)=>new Us([new fb(e)]),db=(e)=>e.reasons.some(ji),pb=(e)=>{let t=e.reasons.find(ji);return t?J(t):oe(e)},ao=(e)=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag==="Fail")return J(n.error)}return oe(e)},k_,Rh=(e)=>e.reasons.some(Xa),C_=(e)=>{let t=e.reasons.find(Xa);return t?J(t):oe(e)},ud=(e)=>{let t=e.reasons.find(Xa);return t?J(t.defect):oe(e)},Fh=(e)=>e.reasons.some(ec),v_=(e)=>{let t=e.reasons.find(ec);return t?J(t):oe(e)},Mh=(e)=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];if(r._tag!=="Interrupt")continue;if(t??=new Set,r.fiberId!==void 0)t.add(r.fiberId)}return t?J(t):oe(e)},I_=(e)=>{let t=Mh(e);return Se(t)?dK:t.success},dK,A_=(e)=>e.reasons.length>0&&e.reasons.every(ec),T_=(e)=>Gi(e.annotations),__=(e)=>{let t=new Map;for(let n of e.reasons)if(n.annotations.size>0)for(let[r,o]of n.annotations)t.set(r,o);return Gi(t)},Dh,O_,pK=(e)=>{let t={Fail:[],Die:[],Interrupt:[]};for(let n=0;n<e.reasons.length;n++)t[e.reasons[n]._tag].push(e.reasons[n]);return t},Nh=(e)=>{let t=pK(e);if(t.Fail.length>0)return t.Fail[0].error;else if(t.Die.length>0)return t.Die[0].defect;else if(t.Interrupt.length>0)return new globalThis.Error("All fibers interrupted without error");return new globalThis.Error("Empty cause")},mb=(e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let o=ta();$r(1);for(let s of e.reasons){if(s._tag==="Interrupt"){r.push(s);continue}n.push(sb(s._tag==="Die"?s.defect:s.error,s.annotations,t))}if(n.length===0){let s=Error("The fiber was interrupted by:");s.name="InterruptCause",s.stack=xK(s,r);let i=new globalThis.Error("All fibers interrupted without error",{cause:s});i.name="InterruptError",i.stack=`${i.name}: ${i.message}`,n.push(sb(i,r[0].annotations,t))}return $r(o),n},sb=(e,t,n)=>{let r=typeof e,o;if(e&&r==="object"){if(o=new globalThis.Error(mK(e),{cause:e.cause?sb(e.cause):void 0}),typeof e.name==="string")o.name=e.name;if(typeof e.stack==="string")o.stack=gK(e.stack,o,t);else{let s=`${o.name}: ${o.message}`;o.stack=t?P_(s,t):s}if(n?.includeCauseInStack)o.stack=F_(o);for(let s of Object.keys(e))if(!(s in o))o[s]=e[s]}else o=new globalThis.Error(!e?`Unknown error: ${e}`:r==="string"?e:Ga(e));return o},mK=(e)=>{if(typeof e.message==="string")return e.message;else if(typeof e.toString==="function"&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return Ga(e)},hK,gK=(e,t,n)=>{let r=`${t.name}: ${t.message}`,o=(e.startsWith(r)?e.slice(r.length):e).split(`
|
|
13
|
+
`),s=[r];for(let i=1;i<o.length;i++){if(/(?:Generator\.next|~effect\/Effect)/.test(o[i]))break;s.push(o[i])}return n?P_(s.join(`
|
|
14
14
|
`),n):s.join(`
|
|
15
|
-
`)},
|
|
16
|
-
${
|
|
17
|
-
`)},
|
|
18
|
-
`)}
|
|
19
|
-
`),
|
|
20
|
-
${
|
|
21
|
-
}`:e.stack,
|
|
15
|
+
`)},P_=(e,t)=>{let n=t?.get(eh.key);if(n)e=`${e}
|
|
16
|
+
${R_(n)}`;return e},xK=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let r of t){let o=r.fiberId!==void 0?`#${r.fiberId}`:"unknown",s=r.annotations.get(dE.key);if(n.push(` at fiber (${o})`),s)n.push(R_(s))}return n.join(`
|
|
17
|
+
`)},R_=(e)=>{let t=[],n=e,r=0;while(n&&r<10){let o=n.stack();if(o){let s=o.matchAll(hK),i=!1;for(let[,a]of s)i=!0,t.push(` at ${n.name} (${a})`);if(!i)t.push(` at ${n.name} (${o.replace(/^at /,"")})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
|
|
18
|
+
`)},$h=(e)=>mb(e).map(F_).join(`
|
|
19
|
+
`),F_=(e)=>e.cause?`${e.stack} {
|
|
20
|
+
${M_(e.cause," ")}
|
|
21
|
+
}`:e.stack,M_=(e,t)=>{let n=e.stack.split(`
|
|
22
22
|
`),r=`${t}[cause]: ${n[0]}`;for(let o=1,s=n.length;o<s;o++)r+=`
|
|
23
23
|
${t}${n[o]}`;if(e.cause)r+=` {
|
|
24
|
-
${
|
|
25
|
-
${t}}`;return r},xm="~effect/Fiber",sK,iK,pi=()=>globalThis[Ic],WS,aK,DS,km=(e)=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(Hy.key,e.currentStackFrame),ri(t)},cK=(e)=>{if(e._children===void 0||e._children.size===0)return;return di(e._children)},HT=(e)=>{let t=e;if(t._exit)return L(t._exit);return Bt((n)=>{if(t._exit)return n(L(t._exit));return pe(e.addObserver((r)=>n(L(r))))})},Im=(e)=>Bt((t)=>{let n=e[Symbol.iterator](),r=[],o=void 0;function s(){let i=n.next();while(!i.done){if(i.value._exit){r.push(i.value._exit),i=n.next();continue}o=i.value.addObserver((a)=>{r.push(a),s()});return}t(L(r))}return s(),pe(()=>o?.())}),Cm=(e)=>ce((t)=>qT(e,t.id)),qT,di=(e)=>ce((t)=>{let n=km(t),r=fa();for(let o of e)o.interruptUnsafe(t.id,n),r.push(o);return Xl(Im(r))}),L,Be,nt,pe,ae,KS,Yc,zT=(e)=>e==null?nt(new yo):L(e),VS,Qc,GS=(e)=>L(_(e)),xa,WT=(e)=>me(e)?xa:De(e.value,_),KT=(e)=>ae(()=>Be(Ae(e))),mi=(e)=>Kr(e),Tm=(e)=>ae(()=>nt(Ae(e))),ye,VT=(e)=>{let t=typeof e==="function"?e:e.try,n=typeof e==="function"?(r)=>new lf(r,"An error occurred in Effect.try"):e.catch;return ae(()=>{try{return L(Ae(t))}catch(r){return nt(Ae(()=>n(r)))}})},JS=(e)=>ZS(function(t,n){Ae(()=>e(n)).then((r)=>t(L(r)),(r)=>t(mi(r)))},e.length!==0),GT=(e)=>{let t=typeof e==="function"?e:e.try,n=typeof e==="function"?(r)=>new lf(r,"An error occurred in Effect.tryPromise"):e.catch;return ZS(function(r,o){let s=(i)=>{try{r(nt(Ae(()=>n(i))))}catch(a){r(mi(a))}};try{Ae(()=>t(o)).then((i)=>r(L(i)),s)}catch(i){s(i)}},t.length!==0)},JT=(e)=>ce((t)=>e(t.id)),ZT,YT,ZS,uK,Bt=(e)=>ZS(e,e.length>=2),Om,QT=(...e)=>ae(()=>Jc(e.length===1?e[0]():e[1].call(e[0].self))),YS=(e,...t)=>{let n=t.length===0?function(){return ae(()=>Jc(e.apply(this,arguments)))}:function(){let r=ae(()=>Jc(e.apply(this,arguments)));for(let o=0;o<t.length;o++)r=t[o](r,...arguments);return r};return QS(e.length,n)},QS=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),vT,XT=function(){let e=typeof arguments[0]==="string",t=e?arguments[0]:"Effect.fn",n=e?arguments[1]:void 0,r=li();ir(2);let o=new globalThis.Error;if(ir(r),e)return(s,...i)=>kT(t,s,o,i,e,n);return kT(t,arguments[0],o,Array.prototype.slice.call(arguments,1),e,n)},kT=(e,t,n,r,o,s)=>{let i=typeof t==="function"?t:r.shift().bind(t.self);return QS(i.length,function(...a){let c=ae(()=>{let f=i.apply(this,arguments);return fe(f)?f:Jc(f)});for(let f=0;f<r.length;f++)c=r[f](c,...a);if(!fe(c))return c;let u=li();ir(2);let l=new globalThis.Error;return ir(u),cs(o?Kl(e,s,(f)=>jS(c,f)):c,Bl,(f)=>({name:e,stack:vT(()=>l.stack),parent:{name:`${e} (definition)`,stack:vT(()=>n.stack),parent:f}}))})},eO=(e,...t)=>QS(e.length,t.length===0?function(){return IT(()=>e.apply(this,arguments))}:function(){let n=IT(()=>e.apply(this,arguments));for(let r of t)n=r(n);return n}),IT=(e)=>{try{let t=e(),n=void 0;while(!0){let r=t.next(n);if(r.done)return L(r.value);let o=r.value;if(o&&o._tag==="Success"){n=o.value;continue}else if(o&&o._tag==="Failure")return r.value;else{let s=!0;return ae(()=>{if(s)return s=!1,K(r.value,(i)=>Jc(t,i));else return ae(()=>Jc(e()))})}}}catch(t){return mi(t)}},Jc,xn,Xc=(e)=>De(e,_),tO=(e)=>Sa(e,{onFailure:L,onSuccess:nt}),Zr,ya,Xl=(e)=>K(e,(t)=>Rn),nO=(e)=>cr(e,nt),XS=(e,t)=>ce((n)=>Bt((r)=>{let o=Lt(e),s=o.length,i=0,a=!1,c=new Set,u=[],l=(f,d,m)=>{if(i++,f._tag==="Failure"){if(u.push(...f.cause.reasons),i>=s)r(Be(Zo(u)));return}let g=!a;if(a=!0,r(c.size===0?f:K(fs(di(c)),()=>f)),g&&t?.onWinner)t.onWinner({fiber:d,index:m,parentFiber:n})};for(let f=0;f<s;f++){let d=Ea(n,o[f],!0,!0,!1);if(c.add(d),d.addObserver((m)=>{c.delete(d),l(m,d,f)}),a)break}return di(c)})),eE=(e,t)=>ce((n)=>Bt((r)=>{let o=!1,s=new Set,i=(c)=>{o=!0,r(s.size===0?c:K(fs(di(s)),()=>c))},a=0;for(let c of e){if(o)break;let u=a++,l=Ea(n,c,!0,!0,!1);s.add(l),l.addObserver((f)=>{s.delete(l);let d=!o;if(i(f),d&&t?.onWinner)t.onWinner({fiber:l,index:u,parentFiber:n})})}return di(s)})),rO,Am,K,lK,oO,We=(e)=>(Xi in e),sO,iO=(e)=>K(e,D),De,aO,cO,uO,lO,_m=(e)=>pn(ga(e)),hi=(e)=>e._tag==="Success",fO=(e)=>e._tag==="Success"?G(e):te(e),dO=(e)=>e._tag==="Success"?G(e.value):te(e),tE=(e)=>e._tag==="Failure",pO=(e)=>e._tag==="Failure"?G(e):te(e),ef=(e)=>e._tag==="Failure"?G(e.cause):te(e),nE,mO,hO=(e)=>e._tag==="Failure"&&Sm(e.cause),gO=(e)=>e._tag==="Failure"&&ym(e.cause),xO=(e)=>e._tag==="Failure"&&HS(e.cause),Rn,rE,oE,sE,fK,yO,SO,EO,iE=(e)=>{let t=[];for(let n of e)if(n._tag==="Failure")t.push(...n.cause.reasons);return t.length===0?Rn:pn(Zo(t))},bO=(e)=>hi(e)?_(e.value):O(),wO=(e)=>tE(e)?_(e.cause):O(),vO=(e)=>{let t=nE(e);return xe(t)?O():_(t.success)},kO=(e)=>e,IO=(e)=>ce((t)=>L(oS(t.context,e))),dK=(e)=>ce((t)=>KS(oS(t.context,e))),eu,cs,CO=(e,t,n)=>fs(ce((r)=>{let o=Gr(r.context,e),s=t(o);return r.setContext(tn(r.context,e,s)),Yr(Gr(r.context,xi),(i)=>{let a=Gr(r.context,e),c;if(n?.reset===void 0){if(a!==s)return ye;c=o}else c=n.reset(o,s,a);return r.setContext(tn(r.context,e,c)),ye})})),aE=()=>pK,pK,gi=(e)=>ce((t)=>e(t.context)),TO,us,Pn=function(){if(arguments.length===1)return p(2,(e,t)=>CT(e,arguments[0],t));return p(3,(e,t,n)=>CT(e,t,n)).apply(this,arguments)},CT=(e,t,n)=>eu(e,tn(t,n)),Rm,OO,cE,AO,_O,uE,RO,Pm,cr,mK,lE,tu,ur,PO=(e)=>Sa(e,{onFailure:(t)=>Bp(t)?xa:nt(t),onSuccess:GS}),FO,MO,NO,Fm,fE,DO,$O,tf,Mm,dE,UO,LO,jO,BO,pE,mE,hE=(e)=>ur(e,mi),HO,qO=(e)=>ae(()=>{let t=e[Symbol.iterator](),n=t.next();if(n.done)return mi(Error("Received an empty collection of effects"));function r(o){let s=t.next();if(s.done)return o.value;return ur(o.value,(i)=>r(s))}return r(n)}),gE=(e)=>ur(e,(t)=>K(Qc,()=>gE(e))),zO,Nm,WO=(e)=>Dm(e,{onFailure:O,onSuccess:_}),fi=(e)=>nf(e,{onFailure:te,onSuccess:G}),Jr,hK,xE,Sa,Dm,nf,KO,rf=(e)=>We(e)?je(e):gK(e),gK,VO,GO,JO,yE,ZO,YO,QO=(e)=>bo((t)=>{let n=t.monotonicTimeNanosUnsafe();return De(e,(r)=>[Tr(t.monotonicTimeNanosUnsafe()-n),r])}),$S="~effect/Scope",US="~effect/Scope/Closeable",xi,SE=(e,t)=>ae(()=>$m(e,t)??ye),$m=(e,t)=>{if(e.state._tag==="Closed")return;let n={_tag:"Closed",exit:t};if(e.state._tag==="Empty"){e.state=n;return}let r=e.state;if(e.state=n,r.finalizer!==void 0)return r.finalizer(t);let o=r.finalizers;if(o===void 0||o.size===0)return;else if(o.size===1)return o.values().next().value(t);return yK(e,o,t)},xK=(e,t)=>hi(e)?t:cr(t,(n)=>Be(bm(e.cause,n))),yK,XO=(e,t)=>{let n=of(t);if(e.state._tag==="Closed")return n.state=e.state,n;let r={};return zl(e,r,(o)=>SE(n,o)),zl(n,r,(o)=>pe(()=>EE(e,r))),n},Yr=(e,t)=>ae(()=>{if(e.state._tag==="Closed")return t(e.state.exit);return zl(e,{},t),ye}),eA=(e,t)=>Yr(e,gt(t)),zl=(e,t,n)=>{if(e.state._tag==="Empty")e.state={_tag:"Open",finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag==="Open"){let r=e.state;if(r.finalizer!==void 0)r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n);else if(r.finalizers===void 0)r.finalizerKey=t,r.finalizer=n;else r.finalizers.set(t,n)}},EE=(e,t)=>{if(e.state._tag==="Open"){let n=e.state;if(n.finalizerKey===t)n.finalizerKey=void 0,n.finalizer=void 0;else if(n.finalizers!==void 0)n.finalizers.delete(t)}},of=(e="sequential")=>({[US]:US,[$S]:$S,strategy:e,state:SK}),SK,sf,tA,bE=(e)=>ce((t)=>{let n=t.context,r=of();return t.setContext(tn(t.context,xi,r)),ls(e,(o)=>(t.setContext(n),$m(r,o)))}),Um=(e)=>ae(()=>{let t=of();return nn(e(t),(n)=>ae(()=>$m(t,n)??ye))}),af=(e,t,n)=>gi((r)=>Qr((o)=>K(sf,(s)=>ya(n?.interruptible?o(e):e,(i)=>Yr(s,(a)=>us(t(i,a),r)))))),wE=(e)=>K(sf,(t)=>gi((n)=>Yr(t,(r)=>us(e(r),n)))),ls,nn,nA,vE,kE,IE,rA,CE,oA,TE=(e,t,n)=>Qr((r)=>K(e,(o)=>ls(r(t(o)),(s)=>n(o,s),!0))),sA=(e)=>af(e,(t)=>M(t,Symbol.asyncDispose)?JS(()=>t[Symbol.asyncDispose]()):pe(()=>t[Symbol.dispose]())),OE,AE,iA=(e)=>AE(e,ss),aA,fs=(e)=>ce((t)=>{if(!t.interruptible)return e;return t.interruptible=!1,t._stack.push(Lm),e}),cA,Lm,EK,uA=(e)=>{if(e.interruptible=!0,e._stack.push(EK),e._interruptedCause)return Be(e._interruptedCause)},_E=(e)=>ce((t)=>{if(t.interruptible)return e;return uA(t)??e}),Qr=(e)=>ce((t)=>{if(!t.interruptible)return e(D);return t.interruptible=!1,t._stack.push(Lm),e(_E)}),lA=(e)=>ce((t)=>{if(t.interruptible)return e(D);let n=uA(t),r=e(fs);return n??r}),fA,cf=(e,t)=>{if(go(e))return t?.mode==="result"?ar(e,fi,t):ar(e,D,t);else if(t?.discard)return t.mode==="result"?ar(Object.values(e),fi,t):ar(Object.values(e),D,t);return ae(()=>{let n={};return xn(ar(Object.entries(e),([r,o])=>De(t?.mode==="result"?fi(o):o,(s)=>{U(n,r,s)}),{discard:!0,concurrency:t?.concurrency}),n)})},RE,dA,pA,mA,hA=(e,t,n,r)=>K(n(r,t),(o)=>{if(o)return L(_(r));let s=e.next();if(!s.done)return hA(e,t+1,n,s.value);return L(O())}),gA,xA=(e,t,n,r)=>K(n(r,t),(o)=>{if(Ut(o))return L(_(o.success));let s=e.next();if(!s.done)return xA(e,t+1,n,s.value);return L(O())}),Eo,ar,yA=(e)=>K(e,(t)=>{let n=t[Symbol.iterator]().next();return n.done?nt(new yo):L(n.value)}),bK=(e,t,n)=>ae(()=>{let r=n?.discard?void 0:[],o=e[Symbol.iterator](),s=o.next(),i=0;return xn(Eo({while:()=>!s.done,body:()=>t(s.value,i++),step:(a)=>{if(r)r.push(a);s=o.next()}}),r)}),SA=(e)=>{let{onItem:t,step:n}=e,r=(o,s,i,a)=>{for(;i<a;i++){let c=s[i],u=t(o,c,i);if(!We(u))return K(rf(u),(f)=>n(o,c,f,i)??r(o,s,i+1,a)??ye);let l=n(o,c,u,i);if(l)return l._tag==="Failure"?l:void 0}};return(o,s,i)=>{let a=0,c=i?.end??s.length,u=i?.concurrency??1;if(u===1)return r(o,s,0,c);let l=i?.orderedStep===!0,f=!1,d,m,g,b=!1,x,I,C=a,S=l?Array(c):void 0,y=(k)=>{let T=Kr(k);return x=T,f=!0,b=!0,m&&m.size>0?K(fs(di(Array.from(m))),()=>T):T},h=(k,T,F)=>{if(!l)return n(o,k,T,F);if(x)return x;S[F]=T;while(C<c){let N=S[C];if(N===void 0)return;S[C]=void 0;let R=C++,z=n(o,s[R],N,R);if(z)return z}},E=()=>{let k=!1;for(;!x&&a<c;a++){let T=s[a],F=I??t(o,T,a);if(We(F)){if(x=h(T,F,a),x)break}else if(!d)return Bt((N)=>{d=pi(),m=new Set,I=F,g=N;let R;try{R=E()}catch(z){return N(y(z))}if(R)return N(R);return ae(()=>(x=Rn,b=!0,m?di(m):ye))});else{I=void 0;let N=Ea(d,F,!0,!0,"inherit");if(N._exit){if(x=h(T,N._exit,a),x)break;continue}m.add(N);let R=a;if(N.addObserver((z)=>{m.delete(N);try{if(x){if(!b&&z._tag==="Failure")for(let q of z.cause.reasons)if(q._tag==="Interrupt")continue;else if(x._tag==="Failure")x.cause.reasons.push(q);else x=pn(Zo([q]))}else{let q=h(T,z,R);if(q)x=q._tag==="Failure"?pn(Zo(q.cause.reasons.slice())):q,E()}if(k){let q=E();if(q)g(q)}else if(f&&m.size===0)g(x??ye)}catch(q){g(y(q))}}),m.size<u)continue;k=!0,a++;return}}if(f=!0,x){if(m&&m.size>0){let T=km(d);m.forEach((F)=>F.interruptUnsafe(d.id,T));return}if(g||x._tag==="Failure")return x}else if(g){if(!m)return Rn;else if(m.size===0)g(ye)}};return E()}},uf=()=>SA,wK,PE,FE,EA,bA,wA,vA,kA,IA,CA,TA,OA,Ea=(e,t,n=!1,r=!1,o=!1)=>{let s=e,i=o==="inherit"?s.interruptible:!o,a=new WS(s.context,i);if(n)a.evaluate(t);else s.currentDispatcher.scheduleTask(()=>a.evaluate(t),0);if(!r&&!a._exit)s.children().add(a),a.addObserver(()=>s._children.delete(a));return a},AA,_A=(e)=>ce((t)=>{let n=t._children&&new Set(t._children);return nn(e,(r)=>{let o=t._children;if(o===void 0||o.size===0)return ye;else if(n)o=PC(o,(s)=>!n.has(s));return Xl(Im(o))})}),ME,RA,ds=(e)=>(t,n)=>{let r=new WS(n?.scheduler?tn(e,jl,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal)if(n.signal.aborted)r.interruptUnsafe();else{let o=()=>r.interruptUnsafe();n.signal.addEventListener("abort",o,{once:!0}),r.addObserver(()=>n.signal.removeEventListener("abort",o))}if(n?.onFiberStart)n.onFiberStart(r);return r},PA,FA,NE=(e)=>{let t=ds(e);return(n,r)=>{let o=t(n,r);if(r?.onExit)o.addObserver(r.onExit);return(s)=>o.interruptUnsafe(s)}},MA,jm=(e)=>{let t=ds(e);return(n,r)=>{let o=t(n,r);return new Promise((s)=>{o.addObserver((i)=>s(i))})}},NA,DE=(e)=>{let t=jm(e);return(n,r)=>t(n,r).then((o)=>{if(o._tag==="Failure")throw wm(o.cause);return o.value})},DA,Bm=(e)=>{let t=ds(e);return(n)=>{if(We(n))return n;let r=new zc("sync"),o=t(n,{scheduler:r});return o._dispatcher?.flush(),o._exit??Kr(new qm(o))}},$A,$E=(e)=>{let t=Bm(e);return(n)=>{let r=t(n);if(r._tag==="Failure")throw wm(r.cause);return r.value}},UA,TT,OT,UE=(e)=>new LA(e??!1),jA,BA,HA,qA,LS,vK,kK=(e)=>Object.assign(Object.create(vK),e),zA=(e)=>{if(!e)return O();return On(e.annotations,lm)?e._tag==="Span"?zA(mn(e.parent)):O():_(e)},LE=(e,t,n)=>{let r=!e.getRef(dm)||n?.annotations&&On(n.annotations,lm),o=n?.parent!==void 0?_(n.parent):n?.root?O():zA(e.currentSpan),s;if(r)s=kK({name:t,parent:o,annotations:tn(n?.annotations??hn(),lm,!0)});else{let i=e.getRef(fm),a=e.getRef(ps),c=e.getRef(Gc),u=e.getRef(Hl),l=e.getRef(ql),f=n?.level??e.getRef(gT),d=n?.links!==void 0?[...l,...n.links]:l.length===0?[]:l.slice();s=i.span({name:t,parent:o,annotations:n?.annotations??hn(),links:d,startTime:c?a.currentTimeNanosUnsafe():BigInt(0),kind:n?.kind??"internal",root:n?.root??me(o),sampled:n?.sampled??(Ee(o)&&o.value.sampled===!1?!1:!f_(e.getRef(xT),f))});for(let m in u)s.attribute(m,u[m]);if(n?.attributes!==void 0)for(let m in n.attributes)s.attribute(m,n.attributes[m])}return s},WA=(e,t)=>ce((n)=>L(LE(n,e,t))),Wl=(e,t)=>fs(ce((n)=>{let r=Gr(n.context,xi),o=LE(n,e,t??{}),s=n.getRef(ps),i=n.getRef(Gc);return xn(Yr(r,(a)=>ZA(o,a,s,i)),o)})),KA=function(){let e=typeof arguments[0]!=="string",t=e?arguments[1]:arguments[0],n=gm(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return K(Wl(t,n),(o)=>Zc(r,o,n))}return(r)=>K(Wl(t,n),(o)=>Zc(r,o,n))},IK=(e,t)=>(t=typeof t==="function"?t:qr,cs(Bl,(n)=>({name:e,stack:t,parent:n}))),VA,GA,JA,ZA=(e,t,n,r)=>pe(()=>{if(e.status._tag==="Ended")return;e.end(r?n.currentTimeNanosUnsafe():LS,t)}),Kl=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return ce((o)=>{let s=LE(o,e,n),i=o.getRef(ps),a=o.getRef(Gc);return nn(Ae(()=>r(s)),(c)=>ZA(s,c,i,a))})},jS,Zc=function(){let e=fe(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=D;if(t._tag==="Span")n=gm(n),r=IK(t.name,n?.captureStackTrace);if(e)return jS(r(arguments[0]),t);return(o)=>jS(r(o),t)},YA=function(){let e=typeof arguments[0]!=="string",t=e?arguments[1]:arguments[0],n=gm(arguments[2]);if(e){let s=arguments[0];return Kl(t,arguments[2],(i)=>Zc(s,i,n))}let r=typeof arguments[1]==="function"?arguments[1]:void 0,o=r?void 0:arguments[1];return(s,...i)=>Kl(t,r?r(...i):o,(a)=>Zc(s,a,n))},QA,XA=(...e)=>ce((t)=>{let n=t.currentSpanLocal;if(n)if(e.length===1)for(let[r,o]of Object.entries(e[0]))n.attribute(r,o);else n.attribute(e[0],e[1]);return ye}),e_,t_,ps,MS=2147483647,r_,o_,CK,bo=(e)=>ce((t)=>e(t.getRef(ps))),ba=(e)=>bo((t)=>t.sleep(sr(e))),s_,Vl="~effect/Cause/TimeoutError",i_=(e)=>M(e,Vl),Hm,Gl="~effect/Cause/IllegalArgumentError",a_=(e)=>M(e,Gl),jE,Jl="~effect/Cause/ExceededCapacityError",c_=(e)=>M(e,Jl),BE,Zl="~effect/Cause/AsyncFiberError",u_=(e)=>M(e,Zl),qm,Yl="~effect/Cause/UnknownError",l_=(e)=>M(e,Yl),lf,HE,TK=(e)=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 50000;case"Error":return 40000;case"Warn":return 30000;case"Info":return 20000;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}},OK,f_,qE,AK,d_=function(){let e=typeof arguments[0]==="string"?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return fs(ce((t)=>{let n=t.getRef(as),r={...n};for(let o=0;o<e.length;o++){let[s,i]=e[o];U(r,s,i)}return t.setContext(tn(t.context,as,r)),Yr(Gr(t.context,xi),(o)=>{let s=t.getRef(as),i={...s};for(let a=0;a<e.length;a++){let[c,u]=e[a];if(s[c]!==u)continue;if(Object.hasOwn(n,c))U(i,c,n[c]);else delete i[c]}return t.setContext(tn(t.context,as,i)),ye})}))},_K="~effect/Logger",RK,p_=(e)=>{let t=Object.create(RK);return t.log=e,t},PK=(e)=>e.replace(/[\s="]/g,"_"),FK=(e,t)=>`${PK(e[0])}=${t-e[1]}ms`,Xr=(e)=>(...t)=>{let n=void 0;for(let r=0,o=t.length;r<o;r++){let s=t[r];if(Oc(s)){if(n)t.splice(r,1);else t=t.slice(0,r).concat(t.slice(r+1));n=n?Zo(n.reasons.concat(s.reasons)):s,r--}}if(n===void 0)n=Up;return ce((r)=>{let o=e??r.currentLogLevel;if(f_(r.minimumLogLevel,o))return ye;let s=r.getRef(ps),i=r.getRef(qE);if(i.size>0){let a=new Date(s.currentTimeMillisUnsafe());for(let c of i)c.log({cause:n,fiber:r,date:a,logLevel:o,message:t})}return ye})},ha,Oce,MK=(e)=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`,NK,DK,zE,m_,UK=(e,t,n)=>{let r=e.getRef(bT);if(r.size===0)return;if(n&&!ym(t))return;let o={cause:t,fiber:e,timestamp:e.getRef(ps).currentTimeNanosUnsafe()};r.forEach((s)=>s.report(o))};var ht=w(()=>{An();Ve();ai();yt();QC();kn();X();Xt();jn();uS();_e();ia();Qe();he();Np();gn();om();ST();Qi();rt();qp();PS();hm();wT();BS=class BS extends Cl{fiberId;constructor(e,t=Tl){super("Interrupt",t,"Interrupted");this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[Ce](e){return ra(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[Ie](){return xt(qe(`${this._tag}:${this.fiberId}`))(Rp(this.annotations))}};_T=YC(Ar),XW=new Set,bm=p(2,(e,t)=>{if(e.reasons.length===0)return t;else if(t.reasons.length===0)return e;let n=new Jo(pS(e.reasons,t.reasons));return Y(e,n)?e:n}),$T=p(2,(e,t)=>{let n=!1,r=e.reasons.map((o)=>{if(Qs(o))return n=!0,new Ac(t(o.error),o.annotations);return o});return n?Zo(r):e}),nK=/\((.*)\)/g,sK={_A:D,_E:D},iK={id:0};WS=class WS{constructor(e,t=!0){this[xm]=sK,this.setContext(e),this.id=++iK.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this.runtimeMetrics?.recordFiberStart(this.context)}[xm];id;interruptible;currentOpCount;_stack;_observers;_exit;_children;_interruptedCause;_yielded;_running;_deferredInterrupt;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(e){return On(this.context,e)}addObserver(e){if(this._exit)return e(this._exit),Vo;return this._observers.push(e),()=>{if(this._exit)return;let t=this._observers.indexOf(e);if(t>=0)this._observers.splice(t,1)}}interruptUnsafe(e,t){if(this._exit)return;let n=ga(e);if(this.currentStackFrame)n=_c(n,os(jp,this.currentStackFrame));if(t)n=_c(n,t);if(this._interruptedCause=this._interruptedCause?bm(this._interruptedCause,n):n,this.interruptible)if(this._running)this._deferredInterrupt=!0;else this.evaluate(Be(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;else if(this._yielded!==void 0){let r=this._yielded;this._yielded=void 0,r()}let t=this.runLoop(e);if(t===ta)return;let n=DS.interruptChildren&&DS.interruptChildren(this);if(n!==void 0)return this.evaluate(K(n,()=>t));this._exit=t,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let r=0;r<this._observers.length;r++)this._observers[r](t);this._observers.length=0,this._stack.length=0,this._children=void 0,this.context=hn()}runLoop(e){let t=globalThis[Ic];globalThis[Ic]=this;let n=this._running;this._running=!0;let r=!1,o=e;this.currentOpCount=0;try{while(!0){if(this._deferredInterrupt)this._deferredInterrupt=!1,o=Be(this._interruptedCause);if(this.currentOpCount++,!r&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){r=!0;let s=o;o=K(Qc,()=>s)}if(o=this.currentTracerContext?this.currentTracerContext(o,this):o[St](this),o===ta){let s=this._yielded;if(Xi in s)return this._deferredInterrupt=!1,this._yielded=void 0,s;else if(this._deferredInterrupt){this._yielded=void 0,s();continue}return ta}}}catch(s){if(!M(o,St))return Kr(`Fiber.runLoop: Not a valid effect: ${String(o)}`);return this.runLoop(Kr(s))}finally{this._running=n,globalThis[Ic]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,aK;while(!0){let t=this._stack.pop();if(!t)return;let n=t[Ys]&&t[Ys](this);if(n)return n[e]=n,n;if(t[e])return t}}yieldWith(e){return this._yielded=e,ta}children(){return this._children??=new Set}pipe(){return le(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&IC(t,e))return;let n=this.getRef(jl);if(n!==this.currentScheduler)this.currentScheduler=n,this._dispatcher=void 0;this.currentSpan=$l(e,AS),this.currentLogLevel=this.getRef(RS),this.minimumLogLevel=this.getRef(pm),this.currentStackFrame=this.getRef(Bl),this.maxOpsBeforeYield=this.getRef(nT),this.currentPreventYield=this.getRef(rT),this.runtimeMetrics=$l(e,ET);let r=$l(e,_S);this.currentTracerContext=r?r.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}};aK={[In](e,t){return Be(t._interruptedCause)},[wr](e,t){return Be(t._interruptedCause)}},DS={interruptChildren:void 0},qT=p((e)=>M(e[0],xm),(e,t,n)=>ce((r)=>{let o=km(r);return o=o&&n?ua(o,n):o??n,e.interruptUnsafe(t,o),Xl(HT(e))})),L=je,Be=pn,nt=kr,pe=vr({op:"Sync",[St](e){let t=this[ie](),n=e.getCont(In);return n?n[In](t,e):e.yieldWith(je(t))}}),ae=vr({op:"Suspend",[St](e){return this[ie]()}}),KS=p((e)=>e.length>=2||jc(e[0]),(e,t)=>me(e)?nt(t?t():new yo("Effect.fromOption: Option.none")):L(e.value)),Yc=Bn({onFailure:nt,onSuccess:L}),VS=vr({op:"Yield",[St](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{if(t)return;e.evaluate(Rn)},this[ie]??0),e.yieldWith(()=>{t=!0})}}),Qc=VS(0),xa=L(O()),ye=L(void 0),ZT=ce(L),YT=JT(L),ZS=vr({op:"Async",single:!1,[St](e){let t=Ae(()=>this[ie][0].bind(e.currentScheduler)),n=!1,r=!1,o=this[ie][1]?new AbortController:void 0,s=t((i)=>{if(n)return;if(n=!0,r)e.evaluate(i);else r=i},o?.signal);if(r!==!1)return r;if(r=!0,e._yielded=()=>{n=!0},o===void 0&&s===void 0)return ta;return e._stack.push(uK(()=>(n=!0,o?.abort(),s??Rn))),ta}}),uK=vr({op:"AsyncFinalizer",[Ys](e){if(e.interruptible)e.interruptible=!1,e._stack.push(Lm)},[wr](e,t){return Sm(e)?K(this[ie](),()=>Be(e)):Be(e)}}),Om=Bt(Vo),vT=FS(2),Jc=vr({op:"Iterator",single:!1,[In](e,t){let n=this[ie][0];while(!0){let r=n.next(e);if(r.done)return L(r.value);if(!We(r.value))return t._stack.push(this),r.value;else if(r.value._tag==="Failure")return r.value;e=r.value.value}},[St](e){return this[In](this[ie][1],e)}}),xn=p(2,(e,t)=>{let n=L(t);return K(e,(r)=>n)}),Zr=p(2,(e,t)=>K(e,(n)=>fe(t)?t:Ae(()=>t(n)))),ya=p(2,(e,t)=>K(e,(n)=>xn(fe(t)?t:Ae(()=>t(n)),n))),rO=p((e)=>fe(e[1]),(e,t,n)=>XS([e,t],n)),Am=p((e)=>fe(e[1]),(e,t,n)=>eE([e,t],n)),K=p(2,(e,t)=>{let n=Object.create(lK);return n[ie]=e,n[In]=t.length!==1?(r)=>t(r):t,n}),lK=Yo({op:"OnSuccess",[St](e){return e._stack.push(this),this[ie]}}),oO=p(2,(e,t)=>{if(We(e))return e._tag==="Success"?t.onSuccess(e.value):t.onFailure(e.cause);return Jr(e,t)}),sO=p(2,(e,t)=>{if(We(e))return e._tag==="Success"?t(e.value):e;return K(e,t)}),De=p(2,(e,t)=>K(e,(n)=>L(Ae(()=>t(n))))),aO=p(2,(e,t)=>We(e)?rE(e,t):De(e,t)),cO=p(2,(e,t)=>We(e)?oE(e,t):pE(e,t)),uO=p(2,(e,t)=>We(e)?sE(e,t):mE(e,t)),lO=p(2,(e,t)=>{if(We(e)){if(e._tag==="Success")return e;let n=Ar(e.cause);if(xe(n))return e;return t(n.success)}return ur(e,t)}),nE=SS(ef,Ar),mO=SS(ef,Ql),Rn=je(void 0),rE=p(2,(e,t)=>e._tag==="Success"?je(t(e.value)):e),oE=p(2,(e,t)=>{if(e._tag==="Success")return e;let n=Ar(e.cause);if(xe(n))return e;return kr(t(n.success))}),sE=p(2,(e,t)=>{if(e._tag==="Success")return je(t.onSuccess(e.value));let n=Ar(e.cause);if(xe(n))return e;return kr(t.onFailure(n.success))}),fK=p(2,(e,t)=>hi(e)?je(t):e),yO=p(2,(e,t)=>hi(e)?t:e),SO=p(2,(e,t)=>hi(e)?t.onSuccess(e.value):t.onFailure(e.cause)),EO=fK(void 0),eu=p(2,(e,t)=>ce((n)=>{let r=n.context,o=t(r);if(r===o)return e;return n.setContext(o),ls(e,()=>{n.setContext(r);return})})),cs=p(3,(e,t,n)=>eu(e,(r)=>{let o=Gr(r,t),s=n(o);if(o===s)return r;return tn(r,t,s)})),pK=ce((e)=>L(e.context)),TO=p(2,(e,t)=>eu(e,gt(t))),us=p(2,(e,t)=>{if(We(e))return e;return eu(e,ua(t))}),Rm=p(3,(e,t,n)=>K(n,(r)=>Pn(e,t,r))),OO=p((e)=>fe(e[1]),(e,t,n)=>cE(e,t,(r,o)=>[r,o],n)),cE=p((e)=>fe(e[1]),(e,t,n,r)=>r?.concurrent?De(cf([e,t],{concurrency:2}),([o,s])=>Ae(()=>n(o,s))):K(e,(o)=>De(t,(s)=>Ae(()=>n(o,s))))),AO=p((e)=>fe(e[0]),(e,t,n)=>PE(e,t,n?(r)=>nt(n(r)):()=>nt(new yo))),_O=p(2,(e,t)=>K(t,(n)=>n?Xc(e):xa)),uE=p(2,(e,t)=>Array.from({length:t},()=>e)),RO=p((e)=>fe(e[0]),(e,t,n)=>cf(uE(e,t),n)),Pm=p((e)=>fe(e[0]),(e,t)=>Eo({while:nr,body:gt(t?.disableYield?e:K(e,(n)=>Qc)),step:Vo})),cr=p(2,(e,t)=>{let n=Object.create(mK);return n[ie]=e,n[wr]=t.length!==1?(r)=>t(r):t,n}),mK=Yo({op:"OnFailure",[St](e){return e._stack.push(this),this[ie]}}),lE=p(3,(e,t,n)=>cr(e,(r)=>{if(!t(r))return Be(r);return Ae(()=>n(r))})),tu=p(3,(e,t,n)=>cr(e,(r)=>{let o=t(r);return xe(o)?Be(o.failure):Ae(()=>n(o.success,r))})),ur=p(2,(e,t)=>tu(e,Ar,(n)=>t(n))),FO=p(2,(e,t)=>tu(e,Ql,t)),MO=p(2,(e,t)=>cr(e,(n)=>Zr(Ae(()=>t(n)),Be(n)))),NO=p(3,(e,t,n)=>lE(e,t,(r)=>Zr(Ae(()=>n(r)),Be(r)))),Fm=p(3,(e,t,n)=>cr(e,(r)=>{let o=t(r);if(xe(o))return Be(r);return Zr(Ae(()=>n(o.success,r)),Be(r))})),fE=p(2,(e,t)=>Fm(e,Ar,(n)=>t(n))),DO=p(3,(e,t,n)=>{let r=Array.isArray(t)?(o)=>M(o,"_tag")&&t.includes(o._tag):br(t);return fE(e,(o)=>r(o)?n(o):ye)}),$O=p(2,(e,t)=>Fm(e,Ql,(n)=>t(n))),tf=p((e)=>fe(e[0]),(e,t,n,r)=>cr(e,(o)=>{let s=Ar(o);if(xe(s))return Be(s.failure);if(!t(s.success))return r?Ae(()=>r(s.success)):Be(o);return Ae(()=>n(s.success))})),Mm=p((e)=>fe(e[0]),(e,t,n,r)=>cr(e,(o)=>{let s=Ar(o);if(xe(s))return Be(s.failure);let i=t(s.success);if(xe(i))return r?Ae(()=>r(i.failure)):Be(o);return Ae(()=>n(i.success))})),dE=p((e)=>fe(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?(s)=>M(s,"_tag")&&t.includes(s._tag):br(t);return tf(e,o,n,r)}),UO=p((e)=>fe(e[0]),(e,t,n)=>{let r;return Mm(e,(o)=>(r??=Object.keys(t),M(o,"_tag")&&Wr(o._tag)&&r.includes(o._tag)?G(o):te(o)),(o)=>Ae(()=>t[o._tag](o)),n)}),LO=p((e)=>fe(e[0]),(e,t,n,r,o)=>tf(e,(s)=>br(s,t)&&M(s,"reason"),(s)=>{let i=s.reason;if(br(i,n))return r(i,s);return o?Ae(()=>o(i,s)):nt(s)})),jO=p((e)=>fe(e[0]),(e,t,n,r)=>{let o;return tf(e,(s)=>br(s,t)&&M(s,"reason")&&M(s.reason,"_tag")&&Wr(s.reason._tag),(s)=>{let i=s.reason;if(o??=Object.keys(n),o.includes(i._tag))return Ae(()=>n[i._tag](i,s));return r?Ae(()=>r(i,s)):nt(s)})}),BO=p(2,(e,t)=>Mm(e,(n)=>{if(br(n,t)&&M(n,"reason"))return G(n.reason);return te(n)},nt)),pE=p(2,(e,t)=>ur(e,(n)=>Tm(()=>t(n)))),mE=p(2,(e,t)=>Sa(e,{onFailure:(n)=>Tm(()=>t.onFailure(n)),onSuccess:(n)=>pe(()=>t.onSuccess(n))})),HO=p(2,(e,t)=>ur(e,(n)=>pe(t))),zO=p((e)=>fe(e[0]),(e,t)=>{if(!t?.log)return Sa(e,{onFailure:(r)=>ye,onSuccess:(r)=>ye});let n=Xr(t.log===!0?void 0:t.log);return Jr(e,{onFailure(r){let o=qS(r);return xe(o)?Be(o.failure):t.message===void 0?n(r):n(t.message,r)},onSuccess:(r)=>ye})}),Nm=p((e)=>fe(e[0]),(e,t)=>{if(!t?.log)return Jr(e,{onFailure:(r)=>ye,onSuccess:(r)=>ye});let n=Xr(t.log===!0?void 0:t.log);return Jr(e,{onFailure:(r)=>t.message===void 0?n(r):n(t.message,r),onSuccess:(r)=>ye})}),Jr=p(2,(e,t)=>{let n=Object.create(hK);return n[ie]=e,n[In]=t.onSuccess.length!==1?(r)=>t.onSuccess(r):t.onSuccess,n[wr]=t.onFailure.length!==1?(r)=>t.onFailure(r):t.onFailure,n}),hK=Yo({op:"OnSuccessAndFailure",[St](e){return e._stack.push(this),this[ie]}}),xE=p(2,(e,t)=>Jr(e,{onFailure:(n)=>pe(()=>t.onFailure(n)),onSuccess:(n)=>pe(()=>t.onSuccess(n))})),Sa=p(2,(e,t)=>Jr(e,{onFailure:(n)=>{let r=n.reasons.find(Qs);return r?Ae(()=>t.onFailure(r.error)):Be(n)},onSuccess:t.onSuccess})),Dm=p(2,(e,t)=>Sa(e,{onFailure:(n)=>pe(()=>t.onFailure(n)),onSuccess:(n)=>pe(()=>t.onSuccess(n))})),nf=p(2,(e,t)=>{if(We(e)){if(e._tag==="Success")return je(t.onSuccess(e.value));let n=Ar(e.cause);if(xe(n))return e;return je(t.onFailure(n.success))}return Dm(e,t)}),KO=p(2,(e,t)=>{if(We(e)){if(e._tag==="Success")return je(t.onSuccess(e.value));return je(t.onFailure(e.cause))}return xE(e,t)}),gK=vr({op:"Exit",[St](e){return e._stack.push(this),this[ie]},[In](e,t,n){return L(n??je(e))},[wr](e,t,n){return L(n??pn(e))}}),VO=nf({onFailure:()=>!0,onSuccess:()=>!1}),GO=nf({onFailure:()=>!1,onSuccess:()=>!0}),JO=p(2,(e,t)=>Zr(ba(t),e)),yE=p(2,(e,t)=>Am(e,K(ba(t.duration),t.orElse))),ZO=p(2,(e,t)=>yE(e,{duration:t,orElse:()=>nt(new Hm)})),YO=p(2,(e,t)=>Am(Xc(e),xn(ba(t),O()))),xi=ze("effect/Scope"),yK=YS(function*(e,t,n){let r=[],o=[],s=Array.from(t.values()),i=pi();for(let a=s.length-1;a>=0;a--){let c=s[a];if(e.strategy==="sequential")r.push(yield*rf(c(n)));else o.push(Ea(i,c(n),!0,!0,"inherit"))}if(o.length>0)r=yield*Im(o);return yield*iE(r)}),SK={_tag:"Empty"},sf=xi,tA=Pn(xi),ls=vr({op:"OnExit",single:!1,[St](e){return e._stack.push(this),this[ie][0]},[Ys](e){if(e.interruptible&&this[ie][2]!==!0)e._stack.push(Lm),e.interruptible=!1},[In](e,t,n){n??=je(e);let r=this[ie][1](n);return r?K(r,(o)=>n):n},[wr](e,t,n){n??=pn(e);let r=this[ie][1](n);return r?K(xK(n,r),(o)=>n):n}}),nn=p(2,ls),nA=p(2,(e,t)=>nn(e,(n)=>t)),vE=p(3,(e,t,n)=>nn(e,(r)=>{if(!t(r))return ye;return n(r)})),kE=p(3,(e,t,n)=>nn(e,(r)=>{let o=t(r);return xe(o)?ye:n(o.success,r)})),IE=p(2,(e,t)=>kE(e,ef,t)),rA=p(3,(e,t,n)=>vE(e,(r)=>{if(r._tag!=="Failure")return!1;return t(r.cause)},(r)=>n(r.cause))),CE=p(3,(e,t,n)=>nn(e,(r)=>{if(r._tag!=="Failure")return ye;let o=t(r.cause);return xe(o)?ye:n(o.success,r.cause)})),oA=p(2,(e,t)=>CE(Em,t)(e)),OE=p(2,(e,t)=>pe(()=>{let n=qc(sr(t)),r=Number.isFinite(n),o=UE(!1),s=0,i=!1,a,c=K(o.await,()=>a);return[ce((u)=>{let l=u.getRef(ps),f=r?l.currentTimeMillisUnsafe():0;if(i||f<s)return a??c;return i=!0,o.closeUnsafe(),a=void 0,nn(e,(d)=>pe(()=>{i=!1,s=l.currentTimeMillisUnsafe()+n,a=d,o.openUnsafe()}))}),pe(()=>{s=0,o.closeUnsafe(),a=void 0})]})),AE=p(2,(e,t)=>De(OE(e,t),(n)=>n[0])),aA=ce((e)=>Be(ga(e.id))),cA=vr({op:"SetInterruptible",[Ys](e){if(e.interruptible=this[ie],e._interruptedCause&&e.interruptible)return()=>Be(e._interruptedCause)}}),Lm=cA(!0),EK=cA(!1),fA=De(af(pe(()=>new AbortController),(e)=>pe(()=>e.abort())),(e)=>e.signal),RE=p((e)=>go(e[0])&&!fe(e[0]),(e,t,n)=>De(ar(e,(r,o)=>fi(t(r,o)),n),(r)=>hS(r,D))),dA=p(3,(e,t,n)=>{let r=Lt(e);if(r.length===0)return pe(t);return ae(()=>{let o=0,s=t();return De(Eo({while:()=>o<r.length,body:()=>n(s,r[o],o),step(i){s=i,o++}}),()=>s)})}),pA=p((e)=>go(e[0])&&!fe(e[0]),(e,t,n)=>K(RE(e,t,{concurrency:n?.concurrency}),([r,o])=>{if(la(r))return nt(r);return n?.discard?ye:L(o)})),mA=p((e)=>go(e[0])&&!fe(e[0]),(e,t)=>ae(()=>{let n=e[Symbol.iterator](),r=n.next();if(!r.done)return hA(n,0,t,r.value);return L(O())})),gA=p((e)=>go(e[0])&&!fe(e[0]),(e,t)=>ae(()=>{let n=e[Symbol.iterator](),r=n.next();if(!r.done)return xA(n,0,t,r.value);return L(O())})),Eo=vr({op:"While",[In](e,t){if(this[ie].step(e),this[ie].while())return t._stack.push(this),this[ie].body();return Rn},[St](e){if(this[ie].while())return e._stack.push(this),this[ie].body();return Rn}}),ar=p((e)=>typeof e[1]==="function",(e,t,n)=>ae(()=>{let r=n?.concurrency??1,o=r==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,r);if(o===1)return bK(e,t,n);let s=Lt(e),i=s.length;if(i===0)return n?.discard?ye:L([]);let a=n?.discard?void 0:Array(i),c=wK({f:t,out:a},s,{concurrency:o});return c?xn(c,a):L(a)})),wK=SA({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag==="Failure")return n;else if(e.out)e.out[r]=n.value}}),PE=p(3,(e,t,n)=>K(e,(r)=>t(r)?L(r):n(r))),FE=p(3,(e,t,n)=>K(e,(r)=>{let o=t(r);return xe(o)?n(o.failure):L(o.success)})),EA=p((e)=>fe(e[0]),(e,t,n)=>FE(e,t,n?(r)=>nt(n(r)):()=>nt(new yo))),bA=p((e)=>go(e[0])&&!fe(e[0]),(e,t,n)=>ae(()=>{let r=[];return xn(ar(e,(o,s)=>{let i=t(o,s);if(typeof i==="boolean"){if(i)r.push(o);return ye}return De(i,(a)=>{if(a)r.push(o)})},{discard:!0,concurrency:n?.concurrency}),r)})),wA=p((e)=>go(e[0])&&!fe(e[0]),(e,t)=>ae(()=>{let n=[];for(let r of e){let o=t(r);if(Ut(o))n.push(o.success)}return L(n)})),vA=p((e)=>go(e[0])&&!fe(e[0]),(e,t,n)=>ae(()=>{let r=[];return xn(ar(e,(o)=>De(t(o),(s)=>{if(Ut(s))r.push(s.success)}),{discard:!0,concurrency:n?.concurrency}),r)})),kA=L({}),IA=Mc(De),CA=Nc(De,K),TA=Fc(De),OA=p((e)=>fe(e[0]),(e,t)=>ce((n)=>($K(),L(Ea(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),AA=p((e)=>fe(e[0]),(e,t)=>ce((n)=>L(Ea(n,e,t?.startImmediately,!0,t?.uninterruptible)))),ME=p((e)=>fe(e[0]),(e,t,n)=>ce((r)=>{let o=Ea(r,e,n?.startImmediately,!0,n?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed"){let s={};zl(t,s,()=>JT((a)=>a===o.id?ye:Cm(o))),o.addObserver(()=>EE(t,s))}else o.interruptUnsafe(r.id,km(r));return L(o)})),RA=p((e)=>fe(e[0]),(e,t)=>K(sf,(n)=>ME(e,n,t))),PA=p(2,(e,t)=>{if(e._exit)return e;else if(t.state._tag==="Closed")return e.interruptUnsafe(e.id),e;let n={};return zl(t,n,()=>Cm(e)),e.addObserver(()=>EE(t,n)),e}),FA=ds(hn()),MA=NE(hn()),NA=jm(hn()),DA=DE(hn()),$A=Bm(hn()),UA=$E(hn()),TT=L(!0),OT=L(!1);jA=ce((e)=>L(e.getRef(fm))),BA=p(2,(e,t)=>Pn(e,fm,t)),HA=Pn(dm),qA=Pn(Gc),LS=BigInt(0),vK={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:LS,endTime:LS,exit:Rn},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},VA=Hl,GA=ql,JA=p((e)=>fe(e[0]),(e,t,n={})=>{let o=(Array.isArray(t)?t:[t]).map((s)=>({span:s,attributes:n}));return cs(e,ql,(s)=>[...s,...o])}),jS=Pn(um),QA=p((e)=>fe(e[0]),(e,...t)=>cs(e,Hl,(n)=>{let r=t.length===1?{...n,...t[0]}:{...n};if(t.length===1)return r;else U(r,t[0],t[1]);return r})),e_=ce((e)=>{let t=e.currentSpanLocal;return t?L(t):nt(new yo)}),t_=dK(um),ps=ke("effect/Clock",{defaultValue:()=>new n_});r_=BigInt(1e6),o_=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==="function")return()=>e.bigint();if(typeof performance<"u"&&typeof performance.now==="function")return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let n=BigInt(Date.now())*r_;if(n>t)t=n;return t}}(),CK=function(){let e=BigInt(1e9),t;return()=>{let n=o_(),r=BigInt(Date.now())*r_;if(t===void 0)t=r-n;else{let o=t+n;if((r>o?r-o:o-r)>e)t=r-n}return t+n}}(),s_=bo((e)=>e.currentTimeMillis);Hm=class Hm extends Qo("TimeoutError"){[Vl]=Vl;constructor(e){super({message:e})}};jE=class jE extends Qo("IllegalArgumentError"){[Gl]=Gl;constructor(e){super({message:e})}};BE=class BE extends Qo("ExceededCapacityError"){[Jl]=Jl;constructor(e){super({message:e})}};qm=class qm extends Qo("AsyncFiberError"){[Zl]=Zl;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}};lf=class lf extends Qo("UnknownError"){[Yl]=Yl;constructor(e,t){super({message:t,cause:e})}};HE=ke("effect/Console/CurrentConsole",{defaultValue:()=>globalThis.console}),OK=Vy(rr,TK),f_=ti(OK),qE=ke("effect/Loggers/CurrentLoggers",{defaultValue:()=>new Set([NK,DK])}),AK=ke("effect/Logger/LogToStderr",{defaultValue:Sl}),RK={[_K]:{_Message:D,_Output:D},pipe(){return le(this,arguments)}},ha={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},Oce={None:[],All:[],Trace:[ha.gray],Debug:[ha.blue],Info:[ha.green],Warn:[ha.yellow],Error:[ha.red],Fatal:[ha.bgBrightRed,ha.black]},NK=p_(({cause:e,date:t,fiber:n,logLevel:r,message:o})=>{let s=Array.isArray(o)?o.slice():[o];if(e.reasons.length>0)s.push(vm(e));let i=t.getTime(),a=n.getRef(mm),c="";for(let d of a)c+=` ${FK(d,i)}`;let u=n.getRef(as);if(Object.keys(u).length>0)s.push(u);let l=n.getRef(HE);(n.getRef(AK)?l.error:l.log)(`[${MK(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...s)}),DK=p_(({cause:e,fiber:t,logLevel:n,message:r})=>{let o=t.getRef(ps),s=t.getRef(as),i=t.currentSpan;if(i===void 0||i._tag==="ExternalSpan")return;let a={};for(let[c,u]of Object.entries(s))U(a,c,u);if(a["effect.fiberId"]=t.id,a["effect.logLevel"]=n.toUpperCase(),e.reasons.length>0)a["effect.cause"]=vm(e);i.event(V0(Array.isArray(r)&&r.length===1?r[0]:r),o.currentTimeNanosUnsafe(),a)});zE=L(void 0),m_=p((e)=>fe(e[0]),(e,t)=>IE(e,(n)=>ce((r)=>(UK(r,n,t?.defectsOnly),ye))))});var lt={};Un(lt,{AsyncFiberError:()=>hV,AsyncFiberErrorTypeId:()=>pV,Done:()=>gf,DoneTypeId:()=>oV,ExceededCapacityError:()=>dV,ExceededCapacityErrorTypeId:()=>fV,IllegalArgumentError:()=>xf,IllegalArgumentErrorTypeId:()=>cV,InterruptorStackTrace:()=>S_,NoSuchElementError:()=>rV,NoSuchElementErrorTypeId:()=>nV,ReasonTypeId:()=>jK,StackTrace:()=>y_,TimeoutError:()=>aV,TimeoutErrorTypeId:()=>sV,TypeId:()=>LK,UnknownError:()=>ZE,UnknownErrorTypeId:()=>gV,annotate:()=>yV,annotations:()=>EV,combine:()=>zK,die:()=>h_,done:()=>_t,empty:()=>VE,fail:()=>GE,filterInterruptors:()=>XK,findDefect:()=>JK,findDie:()=>GK,findError:()=>x_,findErrorOption:()=>KK,findFail:()=>WK,findInterrupt:()=>YK,fromReasons:()=>wa,hasDies:()=>VK,hasFails:()=>g_,hasInterrupts:()=>ZK,hasInterruptsOnly:()=>hf,interrupt:()=>qK,interruptors:()=>QK,isAsyncFiberError:()=>mV,isCause:()=>WE,isDieReason:()=>BK,isDone:()=>zm,isExceededCapacityError:()=>lV,isFailReason:()=>ff,isIllegalArgumentError:()=>uV,isInterruptReason:()=>HK,isNoSuchElementError:()=>tV,isReason:()=>KE,isTimeoutError:()=>iV,isUnknownError:()=>xV,makeDieReason:()=>pf,makeFailReason:()=>df,makeInterruptReason:()=>mf,map:()=>ms,pretty:()=>JE,prettyErrors:()=>eV,reasonAnnotations:()=>SV,squash:()=>nu});var LK,jK,WE,KE,ff,BK,HK,wa,VE,GE,h_,qK,df=(e)=>new Ac(e),pf=(e)=>new Lp(e),mf,hf,ms,zK,nu,g_,WK,x_,KK,VK,GK,JK,ZK,YK,QK,XK,eV,JE,tV,nV,rV,zm,oV,gf,_t,sV,iV,aV,cV,uV,xf,lV,fV,dV,pV,mV,hV,gV,xV,ZE,yV,SV,EV,y_,S_;var rn=w(()=>{Ve();rt();ht();LK=Cc,jK=Tc,WE=Oc,KE=X0,ff=Qs,BK=na,HK=ra,wa=Zo,VE=Up,GE=Ol,h_=By,qK=ga,mf=AT,hf=MT,ms=$T,zK=bm,nu=wm,g_=HS,WK=qS,x_=Ar,KK=_T,VK=ym,GK=RT,JK=Ql,ZK=Sm,YK=PT,QK=FT,XK=Em,eV=zS,JE=vm,tV=Bp,nV=Il,rV=yo,zm=_l,oV=ea,gf=Rc,_t=nC,sV=Vl,iV=i_,aV=Hm,cV=Gl,uV=a_,xf=jE,lV=c_,fV=Jl,dV=BE,pV=Zl,mV=u_,hV=qm,gV=Yl,xV=l_,ZE=lf,yV=_c,SV=NT,EV=DT;y_=class y_ extends ze()("effect/Cause/StackTrace"){};S_=class S_ extends ze()("effect/Cause/InterruptorStackTrace"){}});var Gt={};Un(Gt,{asVoid:()=>NV,asVoidAll:()=>DV,die:()=>E_,fail:()=>Rr,failCause:()=>lr,filterCause:()=>OV,filterFailure:()=>TV,filterSuccess:()=>IV,filterValue:()=>CV,findDefect:()=>_V,findError:()=>AV,findErrorOption:()=>LV,getCause:()=>UV,getSuccess:()=>$V,hasDies:()=>vV,hasFails:()=>wV,hasInterrupts:()=>kV,interrupt:()=>bV,isExit:()=>YE,isFailure:()=>ru,isSuccess:()=>Rt,map:()=>PV,mapBoth:()=>MV,mapError:()=>FV,match:()=>RV,succeed:()=>_r,void:()=>fr});var YE,_r,lr,Rr,E_,bV,fr,Rt,ru,wV,vV,kV,IV,CV,TV,OV,AV,_V,RV,PV,FV,MV,NV,DV,$V,UV,LV;var dr=w(()=>{rt();ht();YE=jy,_r=je,lr=pn,Rr=kr,E_=Kr,bV=_m,fr=Rn,Rt=hi,ru=tE,wV=xO,vV=gO,kV=hO,IV=fO,CV=dO,TV=pO,OV=ef,AV=nE,_V=mO,RV=SO,PV=rE,FV=oE,MV=sE,NV=EO,DV=iE,$V=bO,UV=wO,LV=vO});var jV="~effect/Deferred",BV,Wm=()=>{let e=Object.create(BV);return e.resumes=void 0,e.effect=void 0,e},va=(e)=>Bt((t)=>{if(e.effect)return t(e.effect);return e.resumes??=[],e.resumes.push(t),pe(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);if(r>=0)n.splice(r,1)})}),HV,b_,QE=(e)=>pe(()=>qV(e)),qV=(e)=>e.effect!==void 0,XE=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let r=0;r<n.length;r++)n[r](t)}return!0};var eb=w(()=>{X();ht();Qe();BV={[jV]:{_A:D,_E:D},pipe(){return le(this,arguments)}},HV=p(2,(e,t)=>pe(()=>XE(e,t))),b_=HV});var v_,k_,I_;var tb=w(()=>{PS();v_=as,k_=mm,I_=pm});var yf,ou,Sf,Km,Ef,yi,pr;var bf=w(()=>{ht();yf=xi,ou=of,Sf=tA,Km=Yr,Ef=eA,yi=XO,pr=SE});var O_="~effect/Layer",C_="~effect/Layer/MemoMap",WV=(e,t)=>(e.observers++,Zr(Yr(t,(n)=>e.finalizer(n)),e.effect)),A_=(e)=>M(e,O_),KV,__=(e)=>{let t=Object.create(KV);return t.build=e,t},nb=(e)=>__((t,n)=>{let r=yi(n);return nn(e(t,r),(o)=>o._tag==="Failure"?pr(r,o):ye)}),VV=(e)=>{let t=nb((n,r)=>n.getOrElseMemoize(t,r,e));return t},GV=(e,t,n,r)=>{let o=ou(),s=Wm(),i={observers:1,effect:va(s),finalizer:(a)=>ae(()=>{if(i.observers--,i.observers===0)return e.map.delete(t),pr(o,a);return ye})};return e.map.set(t,i),Yr(n,i.finalizer).pipe(K(()=>r(e,o)),nn((a)=>(i.effect=a,b_(s,a))))},rb,ob=()=>new rb,JV=(e)=>new rb(e),wf,sb,R_,Si=function(){if(arguments.length===1)return(e)=>Gm(os(arguments[0],e));return Gm(os(arguments[0],arguments[1]))},Gm=(e)=>__(gt(L(e))),su=function(){if(arguments.length===1)return(e)=>T_(arguments[0],e);return T_(arguments[0],arguments[1])},T_=(e,t)=>ZV(De(t,(n)=>os(e,n))),ZV=(e)=>VV((t,n)=>Sf(e,n)),P_=(e,t,n)=>{let r=yi(n,"parallel");return ar(e,(o)=>o.build(t,yi(r,"sequential")),{concurrency:e.length}).pipe(De((o)=>OC(...o)))},Jm=(...e)=>nb((t,n)=>P_(e,t,n)),F_=(e,t,n)=>nb((r,o)=>K(Array.isArray(t)?P_(t,r,o):t.build(r,o),(s)=>e.build(r,o).pipe(us(s),De((i)=>n(i,s))))),M_,N_;var wo=w(()=>{Ve();eb();X();rt();ht();Qe();he();bf();KV={[O_]:{_ROut:D,_E:D,_RIn:D},pipe(){return le(this,arguments)}};rb=class rb{get[C_](){return C_}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);if(n)return WV(n,t);return this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return ae(()=>{let r=this.get(e,t);if(r)return r;return GV(this,e,t,n)})}};wf=class wf extends ze()("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=Yp(e,wf);return t?JV(t):ob()}};sb=p(3,(e,t,n)=>Pn(De(e.build(t,n),tn(wf,t)),wf,t)),R_=p(2,(e,t)=>ce((n)=>sb(e,wf.forkOrCreate(n.context),t))),M_=p(2,(e,t)=>F_(e,t,D)),N_=p(2,(e,t)=>F_(e,t,(n,r)=>ua(r,n)))});var D_="~effect/ExecutionPlan",YV,QV=(e)=>{let t=Object.create(YV);return t.steps=e,t},$_;var U_=w(()=>{Ve();X();ht();wo();Qe();YV={[D_]:D_,get captureRequirements(){let e=this;return gi((t)=>L(QV(e.steps.map((n)=>({...n,provide:A_(n.provide)?M_(n.provide,Gm(t)):n.provide})))))},pipe(){return le(this,arguments)}},$_=ke("effect/ExecutionPlan/CurrentMetadata",{defaultValue:gt({attempt:0,stepIndex:0})})});var Zm="~effect/time/DateTime",Ym="~effect/time/DateTime/TimeZone",j_,o3,s3,B_,i3,a3,vo=(e,t,n)=>{let r=Object.create(s3);return r.epochMilliseconds=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},iu=(e)=>M(e,Zm),Ia=(e)=>M(e,Ym),H_=(e)=>Ia(e)&&e._tag==="Offset",q_=(e)=>Ia(e)&&e._tag==="Named",z_=(e)=>e._tag==="Utc",cb=(e)=>e._tag==="Zoned",W_,K_,V_=(e)=>{let t=Object.create(o3);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},ka=(e)=>{let t=e.getTime();if(Number.isNaN(t))throw new xf("Invalid date");return V_(t)},ub=(e)=>{if(iu(e))return e;else if(e instanceof Date)return ka(e);else if(typeof e==="object"){if("epochMilliseconds"in e)return ka(new Date(e.epochMilliseconds));let t=new Date(0);return h3(t,e),ka(t)}else if(typeof e==="string"&&!c3(e))return ka(new Date(e+"Z"));return ka(new Date(e))},c3=(e)=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),u3=-8639999956800000,l3=8639999949600000,lb=(e,t)=>{let n=t?.timeZone;if(n===void 0&&iu(e)&&cb(e))return e;let r=ub(e);if(r.epochMilliseconds<u3||r.epochMilliseconds>l3)throw RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);if(n===void 0&&typeof e==="object"&&"timeZoneId"in e)n=e.timeZoneId;let o;if(n===void 0){let s=new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1000;o=If(s)}else if(Ia(n))o=n;else if(typeof n==="number")o=If(n);else{let s=pb(n);if(me(s))throw new xf(`Invalid time zone: ${n}`);o=s.value}if(t?.adjustForTimeZone!==!0)return vo(r.epochMilliseconds,o,r.partsUtc);return g3(r.epochMilliseconds,o,t?.disambiguation??"compatible")},ib,G_,f3,J_=(e)=>{let t=f3.exec(e);if(t===null){let o=xb(e);return o!==null?ib(e,{timeZone:o}):O()}let[,n,r]=t;return ib(n,{timeZone:r})},Z_=(e)=>V_(e.epochMilliseconds),kf,d3,p3=(e)=>{let t=e.resolvedOptions().timeZone;if(kf.has(t))return kf.get(t);let n=Object.create(i3);return n.id=t,n.format=e,kf.set(t,n),n},fb=(e)=>{if(kf.has(e))return kf.get(e);try{return p3(new Intl.DateTimeFormat("en-US",{...d3,timeZone:e}))}catch{throw new xf(`Invalid time zone: ${e}`)}},If=(e)=>{let t=Object.create(a3);return t.offset=e,t},db,m3,pb=(e)=>{if(m3.test(e)){let t=xb(e);return t===null?O():_(If(t))}return db(e)},Y_=(e)=>{if(e._tag==="Offset")return hb(e.offset);return e.id},Cf=(e)=>new Date(e.epochMilliseconds),Qm=(e)=>{if(e._tag==="Utc")return new Date(e.epochMilliseconds);else if(e.zone._tag==="Offset")return new Date(e.epochMilliseconds+e.zone.offset);else if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter((r)=>r.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.adjustedEpochMilliseconds=n.getTime(),n},mb=(e)=>Qm(e).getTime()-gb(e),hb=(e)=>{let t=Math.abs(e),n=Math.floor(t/3600000),r=Math.round(t%3600000/60000);if(r===60)n+=1,r=0;return`${e<0?"-":"+"}${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`},Q_=(e)=>hb(mb(e)),gb=(e)=>e.epochMilliseconds,h3=(e,t)=>{if(t.year!==void 0)e.setUTCFullYear(t.year);if(t.month!==void 0)e.setUTCMonth(t.month-1);if(t.day!==void 0)e.setUTCDate(t.day);if(t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}if(t.hour!==void 0)e.setUTCHours(t.hour);if(t.minute!==void 0)e.setUTCMinutes(t.minute);if(t.second!==void 0)e.setUTCSeconds(t.second);if(t.millisecond!==void 0)e.setUTCMilliseconds(t.millisecond)},L_=86400000,g3=(e,t,n)=>{if(t._tag==="Offset")return vo(e-t.offset,t);let r=vf(e-L_,e,t),o=vf(e+L_,e,t);if(r===o)return vo(e-r,t);let s=r<o,i=r-o;if(s){if(vf(e-o,e,t)===o)return vo(e-o,t);let u=vo(e-r,t),l=Qm(u).getTime();if(e!==l)switch(n){case"reject":{let f=new Date(e).toISOString();throw RangeError(`Gap time: ${f} does not exist in time zone ${t.id}`)}case"earlier":return vo(e-o,t);case"compatible":case"later":return u}return u}if(vf(e-r,e,t)===r){if(n==="earlier"||n==="compatible")return vo(e-r,t);if(vf(e-r+i,e+i,t)===r)return vo(e-r,t);if(n==="reject"){let u=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return vo(e-o,t)},x3,xb=(e)=>{let t=x3.exec(e);if(t===null)return null;let[,n,r,o]=t;return(n==="+"?1:-1)*(Number(r)*60+Number(o))*60*1000},vf=(e,t,n)=>{let r=n.format.formatToParts(e).find((s)=>s.type==="timeZoneName")?.value??"";if(r==="GMT")return 0;let o=xb(r);if(o===null)return mb(vo(t,n));return o},X_=(e)=>Cf(e).toISOString(),ab=(e)=>{let t=Qm(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${Q_(e)}`},yb=(e)=>e.zone._tag==="Offset"?ab(e):`${ab(e)}[${e.zone.id}]`;var eR=w(()=>{rn();yt();Xo();Xt();jn();_e();ia();Qe();he();j_={[Zm]:Zm,pipe(){return le(this,arguments)},[At](){return this.toString()},toJSON(){return Cf(this).toJSON()}},o3={...j_,_tag:"Utc",[Ie](){return Ln(this.epochMilliseconds)},[Ce](e){return iu(e)&&e._tag==="Utc"&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Cf(this).toJSON()})`}},s3={...j_,_tag:"Zoned",[Ie](){return xt(Ln(this.epochMilliseconds))(re(this.zone))},[Ce](e){return iu(e)&&e._tag==="Zoned"&&this.epochMilliseconds===e.epochMilliseconds&&Y(this.zone,e.zone)},toString(){return`DateTime.Zoned(${yb(this)})`}},B_={[Ym]:Ym,[At](){return this.toString()}},i3={...B_,_tag:"Named",[Ie](){return qe(`Named:${this.id}`)},[Ce](e){return Ia(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},a3={...B_,_tag:"Offset",[Ie](){return qe(`Offset:${this.offset}`)},[Ce](e){return Ia(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${hb(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},W_=Kt((e,t)=>e.epochMilliseconds===t.epochMilliseconds),K_=ts((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:e.epochMilliseconds>t.epochMilliseconds?1:0),ib=ni(lb),G_=ni(ub),f3=/^(.{17,35})\[(.+)\]$/,kf=new Map,d3={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},db=ni(fb),m3=/^(?:GMT|[+-])/,x3=/([+-])(\d{2}):(\d{2})$/});function S3(e,t){let[n,r]=tR(e),[o,s]=tR(t),i=Math.min(r,s),a=n*BigInt(10)**BigInt(r-i),c=o*BigInt(10)**BigInt(s-i),u=a%c;if(u===BigInt(0))return e<0||Object.is(e,-0)?-0:0;let l=globalThis.Number(`${u}e${i}`);return l===0?Math.sign(e)*globalThis.Number.MIN_VALUE:l}function tR(e){let t=Math.abs(e).toExponential(),n=t.indexOf("e"),r=t.slice(0,n).replace(".","");return[BigInt(r)*(e<0?-BigInt(1):BigInt(1)),globalThis.Number(t.slice(n+1))-r.length+1]}var qce,nR,rR,oR,sR;var Xm=w(()=>{X();qce=globalThis.Number,nR=p(2,(e,t)=>{let n=e.toString(),r=t.toString();if(n.includes("e")||r.includes("e")){if(!globalThis.Number.isFinite(e)||!globalThis.Number.isFinite(t)||t===0)return NaN;return S3(e,t)}let o=(n.split(".")[1]||"").length,s=(r.split(".")[1]||"").length,i=o>s?o:s,a=parseInt(e.toFixed(i).replace(".","")),c=parseInt(t.toFixed(i).replace(".",""));return a%c/Math.pow(10,i)});rR=p(2,(e,t)=>{let n=Math.pow(10,t);return Math.round(e*n)/n}),oR=Ir((e,t)=>Math.max(e,t),-1/0),sR=Ir((e,t)=>Math.min(e,t),1/0)});var zce,aR=(e)=>e.trim(),cR=13,uR=10,lR,E3=(e)=>{let t=e.charCodeAt(0);return t===cR||t===uR},b3=(e,t)=>e.charCodeAt(0)===cR&&t.charCodeAt(0)===uR;var fR=w(()=>{zce=globalThis.String;lR=class lR{index;length;s;stripped;constructor(e,t=!1){this.s=e,this.stripped=t,this.index=0,this.length=e.length}next(){if(this.done)return{done:!0,value:void 0};let e=this.index;while(!this.done&&!E3(this.s[this.index]))this.index=this.index+1;let t=this.index;if(!this.done){let n=this.s[this.index];if(this.index=this.index+1,!this.done&&b3(n,this.s[this.index]))this.index=this.index+1;if(!this.stripped)t=this.index}return{done:!1,value:this.s.substring(e,t)}}[Symbol.iterator](){return new lR(this.s,this.stripped)}get done(){return this.index>=this.length}}});var mr,Tf=(e)=>e.reasons.some(Sb),Sb=(e)=>e._tag==="Fail"&&zm(e.error),eh=(e)=>{let t,n=!1;for(let r of e.reasons)if(Sb(r))t??=r.error;else if(r._tag!=="Interrupt")n=!0;if(t===void 0)return te(e);return n?te(wa(e.reasons.filter((r)=>!Sb(r)))):G(t)},v3=(e)=>{let t=eh(e);return xe(t)?t:G(t.success.value)},Eb=(e)=>{let t=eh(e);return!xe(t)?_r(t.success.value):lr(t.failure)},th;var Ca=w(()=>{rn();dr();X();ht();gn();mr=p(2,(e,t)=>tu(e,v3,(n)=>t(n))),th=p(2,(e,t)=>Jr(e,{onSuccess:t.onSuccess,onFailure:(n)=>{let r=eh(n);return!xe(r)?t.onDone(r.success.value):t.onFailure(r.failure)}}))});var dR="~effect/Schedule",Ta,k3,bb=(e)=>M(e,dR),wb=(e)=>{let t=Object.create(k3);return t.step=e,t},vb=()=>{let e=0,t,n;return(r,o)=>{if(n===void 0)n=r;let s=r-n,i=t===void 0?0:r-t;return t=r,{input:o,attempt:++e,start:n,now:r,elapsed:s,elapsedSincePrevious:i}}},I3=(e)=>wb(De(e,(t)=>{let n=vb();return(r,o)=>t(n(r,o))})),kb=(e)=>cr(e.step,(t)=>L(()=>Be(t))),nh=(e)=>bo((t)=>De(kb(e),(n)=>{let r=vb();return(o)=>ae(()=>{let s=t.currentTimeMillisUnsafe();return K(n(s,o),([i,a])=>{let c=r(s,o);return c.output=i,c.duration=a,xn(ba(a),c)})})})),Ib=(e)=>wb(De(kb(e),(t)=>(n,r)=>th(t(n,r),{onSuccess:(o)=>L([r,o[1]]),onFailure:Be,onDone:()=>_t(r)}))),pR=(e)=>Of(Cb,({attempt:t})=>L(t<=e)),C3=(e)=>{let t=sr(e);return I3(L((n)=>L([n.attempt-1,t])))},Of,Cb;var Tb=w(()=>{rn();Ve();ai();X();rt();ht();Qe();he();Ca();Ta=ke("effect/Schedule/CurrentMetadata",{defaultValue:gt({input:void 0,output:void 0,duration:Hc,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),k3={[dR]:{_Out:D,_In:D,_Env:D},pipe(){return le(this,arguments)}},Of=p(2,(e,t)=>wb(De(kb(e),(n)=>{let r=vb();return(o,s)=>K(n(o,s),(i)=>{let[a,c]=i,u=t({...r(o,s),output:a,duration:c});return K(fe(u)?u:L(u),(l)=>l?L(i):_t(a))})}))),Cb=C3(Hc)});var T3=(e,t,n)=>Um((r)=>K(n?.local?sb(t,ob(),r):R_(t,r),(o)=>us(e,o))),rh;var Ob=w(()=>{Ve();X();wo();rt();ht();rh=p((e)=>fe(e[0]),(e,t,n)=>rS(t)?us(e,t):T3(e,Array.isArray(t)?Jm(...t):t,n))});var Ab,_b,gR,Af,xR,O3,_f=(e)=>{let t=e.schedule?Ib(e.schedule):O3;if(e.while)t=Of(t,({input:n})=>{let r=e.while(n);return fe(r)?r:L(r)});if(e.until)t=Of(t,({input:n})=>{let r=e.until(n);return fe(r)?De(r,(o)=>!o):L(!r)});if(e.times!==void 0)t=Of(t,({attempt:n})=>L(n<=e.times));return t};var Rb=w(()=>{X();_e();Ca();Tb();Qi();rt();ht();Ab=p(3,(e,t,n)=>K(nh(t),(r)=>{let o=Ta.defaultValue();return ur(Pm(ya(K(ae(()=>Pn(e,Ta,o)),r),(s)=>pe(()=>{o=s})),{disableYield:!0}),(s)=>_l(s)?L(s.value):n(s,o.attempt===0?O():_(o)))})),_b=p(3,(e,t,n)=>K(nh(t),(r)=>{let o=Ta.defaultValue(),s,i=ur(ae(()=>Pn(e,Ta,o)),(a)=>(s=a,K(r(a),(c)=>(o=c,i))));return mr(i,(a)=>Ae(()=>n(s,a)))})),gR=p(2,(e,t)=>{let n=typeof t==="function"?t(D):bb(t)?t:_f(t);return Ab(e,n,nt)}),Af=p(2,(e,t)=>{let n=typeof t==="function"?t(D):bb(t)?t:_f(t);return _b(e,n,nt)}),xR=p(3,(e,t,n)=>K(nh(n),(r)=>{let o=Ta.defaultValue(),s=ae(()=>Pn(e,Ta,o));return ur(K(r(t),(i)=>{o=i;let a=gt(K(s,r));return Eo({while:nr,body:a,step(c){o=c}})}),(i)=>_l(i)?L(i.value):nt(i))})),O3=Ib(Cb)});var A3=(e,t)=>{let n=-1,r=0,o=(s)=>Nm(e(s));return{begin:bo((s)=>ae(()=>{let i=t();if(i.stepIndex!==n)n=i.stepIndex,r=0;r++;let a={attempt:i.attempt,stepAttempt:r,stepIndex:i.stepIndex,startNanos:s.monotonicTimeNanosUnsafe()};return xn(o({_tag:"AttemptStart",attempt:a.attempt,stepAttempt:a.stepAttempt,stepIndex:a.stepIndex}),a)})),end:(s,i)=>bo((a)=>{let c=Tr(a.monotonicTimeNanosUnsafe()-s.startNanos);return o(i._tag==="Success"?{_tag:"AttemptSuccess",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c}:{_tag:"AttemptFailure",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c,cause:i.cause})})}},ER,SR=(e,t)=>{if(!t)return _f({schedule:e.schedule?e.schedule:e.attempts?void 0:_3,times:e.attempts,while:e.while});else if(e.attempts===1||!(e.schedule||e.attempts))return;return _f({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})},_3;var bR=w(()=>{ai();U_();X();gn();Tb();rt();ht();Ob();Rb();ER=p((e)=>fe(e[0]),(e,t,n)=>ae(()=>{let r=0,o={attempt:0,stepIndex:0},s=Rm($_,pe(()=>(o={attempt:o.attempt+1,stepIndex:r},o))),i=n?.onEvent===void 0?void 0:A3(n.onEvent,()=>o),a=i===void 0?D:(u)=>Qr((l)=>K(i.begin,(f)=>nn(l(u),(d)=>i.end(f,d)))),c;return K(Eo({while:()=>r<t.steps.length&&(c===void 0||xe(c)),body(){let u=t.steps[r],l=s(a(rh(e,u.provide)));if(c){let f=!1,d=l;l=ae(()=>{if(f)return d;return f=!0,Yc(c)}),l=Af(l,SR(u,!1))}else{let f=SR(u,!0);l=f?Af(l,f):l}return fi(l)},step(u){c=u,r++}}),()=>Yc(c))})),_3=pR(1)});var P3="~effect/Request",F3,iue,wR=(e)=>e;var vR=w(()=>{yt();rt();F3=$y({_E:(e)=>e,_A:(e)=>e,_R:(e)=>e}),iue={...Q0,[P3]:F3}});function kR(e){if(!e.map.has(e.key))return ye;return e.map.delete(e.key),e.run}var IR,CR=(e,t)=>{let n=TR(t.resolver,e,t.onExit,{context:t.context,currentScheduler:On(t.context,jl)});return()=>OR(t.resolver,n)},oh,Pb,TR=(e,t,n,r)=>{let o=Pb.get(e);if(!o)o=new Map,Pb.set(e,o);let s,i=!1,a=wR({request:t,context:r.context,uninterruptible:!1,completeUnsafe(u){if(i)return;i=!0,n(u),s?.entrySet.delete(a)}});if(e.preCheck!==void 0&&!e.preCheck(a))return a;let c=e.batchKey(a);if(s=o.get(c),!s){if(oh.length>0)s=oh.pop(),s.key=c,s.resolver=e,s.map=o;else{let u={key:c,resolver:e,map:o,entrySet:new Set,entries:new Set,delayEffect:K(ae(()=>u.resolver.delay),(l)=>kR(u)),run:nn(ae(()=>u.resolver.runAll(Array.from(u.entries),u.key)),(l)=>{for(let f of u.entrySet)f.completeUnsafe(l._tag==="Success"?Kr(Error("Effect.request: RequestResolver did not complete request",{cause:f.request})):l);if(u.entries.clear(),oh.length<128)u.entrySet.clear(),u.key=void 0,u.fiber=void 0,u.resolver=void 0,u.map=void 0,oh.push(u);return ye})};s=u}o.set(c,s),s.fiber=ds(r.context)(s.delayEffect,{scheduler:r.currentScheduler})}if(s.entrySet.add(a),s.entries.add(a),s.resolver.collectWhile(s.entries))return a;return s.fiber.interruptUnsafe(r.id),s.fiber=ds(r.context)(kR(s),{scheduler:r.currentScheduler}),a},OR=(e,t)=>{if(t.uninterruptible)return;let n=Pb.get(e);if(!n)return;let r=e.batchKey(t),o=n.get(r);if(!o)return;if(o.entries.delete(t),o.entrySet.delete(t),o.entries.size===0)n.delete(r),o.fiber?.interruptUnsafe()},M3=(e,t)=>pe(()=>OR(e,t));var AR=w(()=>{Ve();X();vR();om();rt();ht();IR=p(2,(e,t)=>{let n=(r)=>Bt((o)=>{let s=TR(r,e,o,pi());return M3(r,s)});return fe(t)?K(t,n):n(t)}),oh=[],Pb=new WeakMap});function B3(e,t){let n=`${e.type}:${e.id}`;if(Le(e.description))n+=`:${e.description}`;if(Le(t))n+=`:${H3(t)}`;return n}function H3(e){return JSON.stringify(Array.isArray(e)?e:Object.entries(e))}function q3(e,t){return{...Fb(e),...Fb(t)}}function Fb(e){if(Le(e)&&Array.isArray(e))return e.reduce((t,[n,r])=>(U(t,n,r),t),{});return e}var D3="effect/Metric/CurrentMetricAttributes",$3,U3="~effect/observability/Metric/MetricRegistryKey",L3,_R="~effect/observability/Metric",j3,cu;var RR=w(()=>{Ve();X();ht();Qe();he();$3=ke(D3,{defaultValue:()=>({})}),L3=ke(U3,{defaultValue:()=>new Map});j3=class j3{[_R]=_R;#t=new WeakMap;#e;id;description;attributes;constructor(e,t,n){this.id=e,this.description=t,this.attributes=n}valueUnsafe(e){return this.hook(e).get(e)}modifyUnsafe(e,t){return this.hook(t).modify(e,t)}updateUnsafe(e,t){return this.hook(t).update(e,t)}hook(e){let t=On(e,$3);if(Object.keys(t).length===0){if(Le(this.#e))return this.#e.hooks;return this.#e=this.getOrCreate(e,this.attributes),this.#e.hooks}let n=q3(this.attributes,t),r=this.#t.get(n);if(Le(r))return r.hooks;return r=this.getOrCreate(e,n),this.#t.set(n,r),r.hooks}getOrCreate(e,t){let n=B3(this,t),r=On(e,L3);if(r.has(n))return r.get(n);let o=this.createHooks(),s={id:this.id,type:this.type,description:this.description,attributes:Fb(t),hooks:o};return r.set(n,s),s}pipe(){return le(this,arguments)}};cu=p(2,(e,t)=>gi((n)=>pe(()=>e.updateUnsafe(t,n))))});var j={};Un(j,{Do:()=>X3,Transaction:()=>Rf,TypeId:()=>W3,abortSignal:()=>iJ,acquireDisposable:()=>ZG,acquireRelease:()=>Mr,acquireUseRelease:()=>WR,addFinalizer:()=>dh,all:()=>FR,andThen:()=>hr,annotateCurrentSpan:()=>xJ,annotateLogs:()=>GJ,annotateLogsScoped:()=>JJ,annotateSpans:()=>gJ,as:()=>gr,asSome:()=>DR,asVoid:()=>Ff,awaitAllChildren:()=>RJ,bind:()=>nG,bindTo:()=>eG,cached:()=>tJ,cachedInvalidateWithTTL:()=>rJ,cachedWithTTL:()=>nJ,callback:()=>yn,catch:()=>Pr,catchCause:()=>xr,catchCauseFilter:()=>hG,catchCauseIf:()=>mG,catchDefect:()=>Lb,catchEager:()=>Bf,catchFilter:()=>Mf,catchIf:()=>dG,catchNoSuchElement:()=>pG,catchReason:()=>uG,catchReasons:()=>lG,catchTag:()=>gs,catchTags:()=>Ub,clockWith:()=>jf,context:()=>lh,contextWith:()=>qR,currentParentSpan:()=>SJ,currentSpan:()=>yJ,delay:()=>jR,die:()=>ko,effectify:()=>ot,ensuring:()=>pu,eventually:()=>EG,exit:()=>bi,fail:()=>A,failCause:()=>fu,failCauseSync:()=>Ei,failSync:()=>Nb,fiber:()=>PJ,fiberId:()=>FJ,filter:()=>Hb,filterMap:()=>MG,filterMapEffect:()=>HR,filterMapOrElse:()=>DG,filterMapOrFail:()=>UG,filterOrElse:()=>NG,filterOrFail:()=>$G,findFirst:()=>J3,findFirstFilter:()=>Z3,firstSuccessOf:()=>OG,flatMap:()=>ne,flatMapEager:()=>on,flatten:()=>NR,flip:()=>cG,fn:()=>jJ,fnUntraced:()=>H,fnUntracedEager:()=>hh,forEach:()=>Oa,forever:()=>Co,forkChild:()=>Vb,forkDetach:()=>_J,forkIn:()=>gu,forkScoped:()=>xu,fromNullishOr:()=>iG,fromOption:()=>oG,fromResult:()=>$b,gen:()=>qt,head:()=>Y3,ignore:()=>Nf,ignoreCause:()=>kG,interrupt:()=>hu,interruptible:()=>oJ,interruptibleMask:()=>sJ,isEffect:()=>zn,isFailure:()=>zG,isSuccess:()=>WG,let:()=>tG,linkSpans:()=>wJ,log:()=>BJ,logDebug:()=>WJ,logError:()=>mh,logFatal:()=>HJ,logInfo:()=>zJ,logTrace:()=>KJ,logWarning:()=>qJ,logWithLevel:()=>QR,makeSpan:()=>JR,makeSpanScoped:()=>vJ,map:()=>oe,mapBoth:()=>gG,mapBothEager:()=>Jt,mapEager:()=>Ss,mapError:()=>Pt,mapErrorEager:()=>Ra,match:()=>wi,matchCause:()=>BG,matchCauseEager:()=>HG,matchCauseEffect:()=>qb,matchCauseEffectEager:()=>qG,matchEager:()=>jG,matchEffect:()=>uh,never:()=>sh,onError:()=>mu,onErrorFilter:()=>QG,onErrorIf:()=>YG,onExit:()=>ys,onExitFilter:()=>eJ,onExitIf:()=>XG,onExitPrimitive:()=>KR,onInterrupt:()=>VR,option:()=>aG,orDie:()=>Fr,orElseSucceed:()=>TG,partition:()=>K3,promise:()=>MR,provide:()=>zb,provideContext:()=>xs,provideService:()=>Io,provideServiceEffect:()=>Wb,race:()=>FG,raceAll:()=>BR,raceAllFirst:()=>PG,raceFirst:()=>_a,reduce:()=>V3,repeat:()=>aJ,repeatOrElse:()=>cJ,replicate:()=>uJ,replicateEffect:()=>lJ,request:()=>OJ,requestUnsafe:()=>AJ,result:()=>ih,retry:()=>bG,retryOrElse:()=>wG,runCallback:()=>NJ,runCallbackWith:()=>MJ,runFork:()=>To,runForkWith:()=>Lf,runPromise:()=>ZR,runPromiseExit:()=>ph,runPromiseExitWith:()=>DJ,runPromiseWith:()=>YR,runSync:()=>$J,runSyncExit:()=>ki,runSyncExitWith:()=>LJ,runSyncWith:()=>UJ,sandbox:()=>vG,satisfiesErrorType:()=>c4,satisfiesServicesType:()=>u4,satisfiesSuccessType:()=>a4,schedule:()=>fJ,scheduleFrom:()=>GR,scope:()=>Df,scoped:()=>vi,scopedWith:()=>Kb,service:()=>zR,serviceOption:()=>fh,setContext:()=>KG,sleep:()=>ch,spanAnnotations:()=>EJ,spanLinks:()=>bJ,succeed:()=>v,succeedNone:()=>Aa,succeedSome:()=>Mb,suspend:()=>Ne,sync:()=>Se,tap:()=>du,tapCause:()=>ah,tapCauseFilter:()=>SG,tapCauseIf:()=>yG,tapDefect:()=>LR,tapError:()=>jb,tapErrorTag:()=>xG,timed:()=>RG,timeout:()=>AG,timeoutOption:()=>_G,timeoutOrElse:()=>Bb,tracer:()=>dJ,track:()=>YJ,trackDefects:()=>e4,trackDuration:()=>t4,trackErrors:()=>XJ,trackSuccesses:()=>QJ,transposeOption:()=>sG,try:()=>Nt,tryPromise:()=>lu,tx:()=>n4,txRetry:()=>i4,undefined:()=>Q3,uninterruptible:()=>$f,uninterruptibleMask:()=>Uf,unwrapReason:()=>fG,updateContext:()=>VG,updateService:()=>GG,updateServiceScoped:()=>JG,useSpan:()=>kJ,validate:()=>G3,void:()=>Te,when:()=>LG,whileLoop:()=>uu,withErrorReporting:()=>CG,withExecutionPlan:()=>IG,withFiber:()=>Pf,withLogSpan:()=>ZJ,withLogger:()=>VJ,withParentSpan:()=>TJ,withSpan:()=>IJ,withSpanScoped:()=>CJ,withTracer:()=>pJ,withTracerEnabled:()=>mJ,withTracerTiming:()=>hJ,yieldNow:()=>Db,yieldNowWith:()=>rG,zip:()=>$R,zipWith:()=>UR});function s4(e,t){for(let[n,{value:r}]of t.journal){if(r!==n.value)n.version=n.version+1,n.value=r;for(let o of n.pending.values())e.currentDispatcher.scheduleTask(o,0);n.pending.clear()}}function PR(e){e.retry=!1,e.journal.clear()}var W3,zn,FR,K3,V3,G3,J3,Z3,Oa,Y3,uu,MR,lu,v,Aa,Mb,Ne,Se,Te,Q3,yn,sh,X3,eG,tG,nG,qt,A,Nb,fu,Ei,ko,Nt,Db,rG,Pf,$b,oG,sG,iG,ne,NR,hr,du,ih,aG,bi,oe,gr,DR,Ff,cG,$R,UR,Pr,gs,Ub,uG,lG,fG,xr,Lb,dG,Mf,pG,mG,hG,Pt,gG,Fr,jb,xG,ah,yG,SG,LR,EG,bG,wG,vG,Nf,kG,IG,CG,TG,OG,AG,_G,Bb,jR,ch,RG,BR,PG,FG,_a,Hb,MG,HR,NG,DG,$G,UG,LG,wi,jG,BG,HG,qG,qb,uh,zG,WG,lh,qR,zb,xs,KG,zR,fh,VG,GG,JG,Io,Wb,Df,vi,Kb,Mr,ZG,WR,dh,pu,mu,YG,QG,KR,ys,XG,eJ,tJ,nJ,rJ,hu,oJ,VR,$f,Uf,sJ,iJ,Co,aJ,cJ,uJ,lJ,fJ,GR,dJ,pJ,mJ,hJ,gJ,xJ,yJ,SJ,EJ,bJ,wJ,JR,vJ,kJ,IJ,CJ,TJ,OJ,AJ,Vb,gu,xu,_J,RJ,PJ,FJ,To,Lf,MJ,NJ,ZR,YR,ph,DJ,$J,UJ,ki,LJ,H,jJ,jf,QR,BJ,HJ,qJ,mh,zJ,WJ,KJ,VJ,GJ,JJ,ZJ,YJ,QJ,XJ,e4,t4,Rf,n4=(e)=>Pf((t)=>{let n=Yp(t.context,Rf);if(n)return e;n={journal:new Map,retry:!1};let r;return Uf((o)=>ne(uu({while:()=>!r,body:gt(o(e).pipe(Io(Rf,n),ah(()=>{if(!n.retry)return Te;return o(o4(n))}),bi)),step(s){if(n.retry||!r4(n))return PR(n);if(Rt(s))s4(t,n);else PR(n);r=s}}),()=>r))}),r4=(e)=>{for(let[t,{version:n}]of e.journal)if(t.version!==n)return!1;return!0},o4=(e)=>Ne(()=>{let t={},n=Array.from(e.journal.keys()),r=()=>{for(let o of n)o.pending.delete(t)};return yn((o)=>{let s=()=>{r(),o(Te)};for(let i of n)i.pending.set(t,s);return Se(r)})}),i4,ot=(e,t,n)=>(...r)=>yn((o)=>{try{e(...r,(s,i)=>{if(s)o(A(t?t(s,r):s));else o(v(i))})}catch(s){o(n?A(n(s,r)):ko(s))}}),a4=()=>(e)=>e,c4=()=>(e)=>e,u4=()=>(e)=>e,Ss,Ra,Jt,on,Bf,hh;var Oe=w(()=>{Ve();ai();dr();X();rt();ht();bR();Ob();AR();Rb();RR();tb();Qi();W3=xo,zn=fe,FR=cf,K3=RE,V3=dA,G3=pA,J3=mA,Z3=gA,Oa=ar,Y3=yA,uu=Eo,MR=JS,lu=GT,v=L,Aa=xa,Mb=GS,Ne=ae,Se=pe,Te=ye,Q3=zE,yn=Bt,sh=Om,X3=kA,eG=IA,tG=TA,nG=CA,qt=QT,A=nt,Nb=Tm,fu=Be,Ei=KT,ko=mi,Nt=VT,Db=Qc,rG=VS,Pf=ce,$b=Yc,oG=KS,sG=WT,iG=zT,ne=K,NR=iO,hr=Zr,du=ya,ih=fi,aG=WO,bi=rf,oe=De,gr=xn,DR=Xc,Ff=Xl,cG=tO,$R=OO,UR=cE,Pr=ur,gs=dE,Ub=UO,uG=LO,lG=jO,fG=BO,xr=cr,Lb=FO,dG=tf,Mf=Mm,pG=PO,mG=lE,hG=tu,Pt=pE,gG=mE,Fr=hE,jb=fE,xG=DO,ah=MO,yG=NO,SG=Fm,LR=$O,EG=gE,bG=Af,wG=_b,vG=nO,Nf=zO,kG=Nm,IG=ER,CG=m_,TG=HO,OG=qO,AG=ZO,_G=YO,Bb=yE,jR=JO,ch=ba,RG=QO,BR=XS,PG=eE,FG=rO,_a=Am,Hb=bA,MG=wA,HR=vA,NG=PE,DG=FE,$G=AO,UG=EA,LG=_O,wi=Dm,jG=nf,BG=xE,HG=KO,qG=oO,qb=Jr,uh=Sa,zG=VO,WG=GO,lh=aE,qR=gi,zb=rh,xs=us,KG=TO,zR=kO,fh=IO,VG=eu,GG=cs,JG=CO,Io=Pn,Wb=Rm,Df=sf,vi=bE,Kb=Um,Mr=af,ZG=sA,WR=TE,dh=wE,pu=nA,mu=IE,YG=rA,QG=CE,KR=ls,ys=nn,XG=vE,eJ=kE,tJ=iA,nJ=AE,rJ=OE,hu=aA,oJ=_E,VR=oA,$f=fs,Uf=Qr,sJ=lA,iJ=fA,Co=Pm,aJ=gR,cJ=Ab,uJ=uE,lJ=RO,fJ=p(2,(e,t)=>GR(e,void 0,t)),GR=xR,dJ=jA,pJ=BA,mJ=HA,hJ=qA,gJ=QA,xJ=XA,yJ=e_,SJ=t_,EJ=VA,bJ=GA,wJ=JA,JR=WA,vJ=Wl,kJ=Kl,IJ=YA,CJ=KA,TJ=Zc,OJ=IR,AJ=CR,Vb=OA,gu=ME,xu=RA,_J=AA,RJ=_A,PJ=ZT,FJ=YT,To=FA,Lf=ds,MJ=NE,NJ=MA,ZR=DA,YR=DE,ph=NA,DJ=jm,$J=UA,UJ=$E,ki=$A,LJ=Bm,H=YS,jJ=XT,jf=bo,QR=Xr,BJ=Xr(),HJ=Xr("Fatal"),qJ=Xr("Warn"),mh=Xr("Error"),zJ=Xr("Info"),WJ=Xr("Debug"),KJ=Xr("Trace"),VJ=p(2,(e,t)=>cs(e,qE,(n)=>new Set([...n,t]))),GJ=p((e)=>zn(e[0]),(e,...t)=>cs(e,v_,(n)=>{let r=t.length===1?{...n,...t[0]}:{...n};if(t.length===1)return r;else U(r,t[0],t[1]);return r})),JJ=d_,ZJ=p(2,(e,t)=>K(s_,(n)=>cs(e,k_,(r)=>[[t,n],...r]))),YJ=p((e)=>zn(e[0]),(e,t,n)=>ys(e,(r)=>{let o=n===void 0?r:Ae(()=>n(r));return cu(t,o)})),QJ=p((e)=>zn(e[0]),(e,t,n)=>du(e,(r)=>{let o=n===void 0?r:n(r);return cu(t,o)})),XJ=p((e)=>zn(e[0]),(e,t,n)=>jb(e,(r)=>{let o=n===void 0?r:Ae(()=>n(r));return cu(t,o)})),e4=p((e)=>zn(e[0]),(e,t,n)=>LR(e,(r)=>{let o=n===void 0?r:Ae(()=>n(r));return cu(t,o)})),t4=p((e)=>zn(e[0]),(e,t,n)=>jf((r)=>{let o=r.monotonicTimeNanosUnsafe();return ys(e,()=>{let s=r.monotonicTimeNanosUnsafe(),i=ZC(sr(s),sr(o)),a=n===void 0?i:Ae(()=>n(i));return cu(t,a)})}));Rf=class Rf extends ze()("effect/Effect/Transaction"){};i4=ne(Rf,(e)=>(e.retry=!0,hu)),Ss=aO,Ra=cO,Jt=uO,on=sO,Bf=lO,hh=eO});var l4=(e,t)=>{if(Rt(e))return t(0);if(hf(e.cause))return t(130);return t(f4(nu(e.cause)))},XR=(e)=>p((t)=>zn(t[0]),(t,n)=>{let r=n?.disableErrorReporting===!0?To(t):To(ah(t,(s)=>{if(hf(s))return Te;return d4(nu(s))?mh(s):Te}));try{let s=globalThis.setInterval(Vo,2147483647);r.addObserver(()=>{clearInterval(s)})}catch{}let o=n?.teardown??l4;return e({fiber:r,teardown:o})}),gh="~effect/Runtime/errorExitCode",f4=(e)=>{if(typeof e==="object"&&e!==null&&gh in e){let t=e[gh];if(typeof t==="number")return t}return 1},Pa="~effect/Runtime/errorReported",d4=(e)=>{if(typeof e==="object"&&e!==null&&Pa in e){let t=e[Pa];if(typeof t==="boolean")return t}return!0};var xh=w(()=>{rn();Oe();dr();X()});var eP;var tP=w(()=>{xh();eP=XR(({fiber:e,teardown:t})=>{let n=!1;e.addObserver((o)=>{process.removeListener("SIGINT",r),process.removeListener("SIGTERM",r),t(o,(s)=>{if(n||s!==0)process.exit(s)})});function r(){n=!0,e.interruptUnsafe(e.id)}process.on("SIGINT",r),process.on("SIGTERM",r)})});var yh={};Un(yh,{runMain:()=>m4});var m4;var nP=w(()=>{tP();m4=eP});var rP="~effect/platform/PlatformError",Es,oP,Jb,Nr=(e)=>new Jb(new oP(e)),bs=(e)=>new Jb(new Es(e));var Oo=w(()=>{Wc();Es=class Es extends ci("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}};oP=class oP extends bS{get message(){return`${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor!==void 0?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}};Jb=class Jb extends ci("PlatformError"){constructor(e){if("cause"in e)super({reason:e,cause:e.cause});else super({reason:e})}[rP]=rP;get message(){return this.reason.message}}});function g4(e,t,n,r,o){for(let s=t;s<Math.min(e.length,t+o);s++)n[r+s-t]=e[s];return n}var sP="~effect/collections/Chunk",iP,Yb=(e)=>Kt((t,n)=>t.length===n.length&&Hf(t).every((r,o)=>e(r,qf(n,o)))),x4,y4,Qb=(e)=>{let t=Object.create(y4);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=ws,t.right=ws;break}case"ISingleton":{t.length=1,t.depth=0,t.left=ws,t.right=ws;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=ws,t.right=ws;break}}return t},Eh=(e)=>M(e,sP),ws,S4=()=>ws,E4=(e)=>Qb({_tag:"ISingleton",a:e}),bh=(e)=>Eh(e)?e:w4(Lt(e)),Zb=(e,t,n)=>{switch(e.backing._tag){case"IArray":{g4(e.backing.array,0,t,n,e.length);break}case"IConcat":{Zb(e.left,t,n),Zb(e.right,t,n+e.left.length);break}case"ISingleton":{t[n]=e.backing.a;break}case"ISlice":{let r=0,o=n;while(r<e.length)t[o]=qf(e,r),r+=1,o+=1;break}}},b4=(e)=>{switch(e.backing._tag){case"IEmpty":return iP;case"IArray":return e.backing.array;default:{let t=Array(e.length);return Zb(e,t,0),e.backing={_tag:"IArray",array:t},e.left=ws,e.right=ws,e.depth=0,t}}},Hf,w4=(e)=>e.length===0?S4():e.length===1?E4(e[0]):Qb({_tag:"IArray",array:e}),qf,aP=(e)=>e.length;var cP=w(()=>{An();yt();Xo();kn();X();Xt();jn();Qe();he();iP=[],x4=Yb(Y),y4={[sP]:{_A:(e)=>e},toString(){return`Chunk(${B(Hf(this))})`},toJSON(){return{_id:"Chunk",values:Wt(Hf(this))}},[At](){return this.toJSON()},[Ce](e){return Eh(e)&&x4(this,e)},[Ie](){return vc(Hf(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return iP[Symbol.iterator]();default:return Hf(this)[Symbol.iterator]()}},pipe(){return le(this,arguments)}},ws=Qb({_tag:"IEmpty"}),Hf=b4,qf=p(2,(e,t)=>{let n=Math.floor(t);switch(e.backing._tag){case"IEmpty":throw Error(`Index out of bounds: ${n}`);case"ISingleton":{if(t!==0)throw Error(`Index out of bounds: ${n}`);return e.backing.a}case"IArray":{if(n>=e.length||n<0)throw Error(`Index out of bounds: ${n}`);return e.backing.array[n]}case"IConcat":return n<e.left.length?qf(e.left,n):qf(e.right,n-e.left.length);case"ISlice":return qf(e.backing.chunk,n+e.backing.offset)}})});var uP,lP;var fP=w(()=>{ht();uP=Cm,lP=PA});var dP;var pP=w(()=>{ht();dP=UE});var mP="~effect/MutableRef",C4,hP=(e)=>{let t=Object.create(C4);return t.current=e,t};var gP=w(()=>{jn();rt();C4={[mP]:mP,...Cn,toJSON(){return{_id:"MutableRef",current:Wt(this.current)}}}});var O4,yP=()=>({head:void 0,tail:void 0,length:0}),xP=()=>({array:[],mutable:!0,offset:0,next:void 0}),vs=(e,t)=>{if(!e.tail)e.head=e.tail=xP();else if(!e.tail.mutable)e.tail.next=xP(),e.tail=e.tail.next;e.tail.array.push(t),e.length++},yu=(e)=>{e.head=e.tail=void 0,e.length=0},SP=(e,t)=>{if(t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let s=e.head.array;return yu(e),s}let n=Array(t),r=0,o=e.head;while(o){while(o.offset<o.array.length){if(n[r++]=o.array[o.offset],o.mutable)o.array[o.offset]=void 0;if(o.offset++,r===t){if(e.head=o,e.length-=t,e.length===0)yu(e);return n}}o=o.next}return yu(e),n},Su=(e)=>{if(!e.head)return O4;let t=e.head.array[e.head.offset];if(e.head.mutable)e.head.array[e.head.offset]=void 0;if(e.head.offset++,e.length--,e.head.offset===e.head.array.length)if(e.head.next)e.head=e.head.next;else yu(e);return t};var EP=w(()=>{O4=Symbol.for("effect/MutableList/Empty")});var _4="~effect/Queue",R4="~effect/Queue/Enqueue",P4="~effect/Queue/Dequeue",Xb,F4,bu=(e)=>ce((t)=>{let n=Object.create(F4);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??Number.POSITIVE_INFINITY,n.strategy=e?.strategy??"suspend",n.messages=yP(),n.scheduleRunning=!1,n.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},L(n)}),bP=(e)=>bu({capacity:e}),zf=(e,t)=>ae(()=>{if(e.state._tag!=="Open")return vh;else if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return vh;case"suspend":if(e.capacity<=0&&e.state.takers.size>0)return vs(e.messages,t),tw(e),wh;return U4(e,t);case"sliding":return Su(e.messages),vs(e.messages,t),wh}return vs(e.messages,t),CP(e),wh}),Wf=(e,t)=>{if(e.state._tag!=="Open")return!1;else if(e.messages.length>=e.capacity){if(e.strategy==="sliding")return Su(e.messages),vs(e.messages,t),!0;else if(e.capacity<=0&&e.state.takers.size>0)return vs(e.messages,t),tw(e),!0;return!1}return vs(e.messages,t),CP(e),!0},Kf,Vf=(e,t)=>{if(e.state._tag!=="Open")return!1;let n=pn(t),r=yO(n,N4);if(e.state.offers.size===0&&e.messages.length===0)return nw(e,r),!0;return e.state={...e.state,_tag:"Closing",exit:r},!0},ks=(e)=>Vf(e,Ol(Rc())),ew=(e)=>pe(()=>{if(e.state._tag==="Done")return!0;yu(e.messages);let t=e.state.offers;if(nw(e,e.state._tag==="Open"?D4:e.state.exit),t.size>0){for(let n of t)if(n._tag==="Single")n.resume(vh);else n.resume(je(n.remaining.slice(n.offset)));t.clear()}return!0}),wP=(e)=>vP(e,1,Number.POSITIVE_INFINITY),vP=(e,t,n)=>ae(()=>$4(e,t,n)??Zr(TP(e),vP(e,1,n))),Is=(e)=>ae(()=>IP(e)??Zr(TP(e),Is(e))),kP=(e)=>ae(()=>{let t=IP(e);if(t===void 0)return L(O());if(t._tag==="Success")return L(_(t.value));return L(O())}),IP=(e)=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=Su(e.messages);return Eu(e),je(t)}else if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,Eu(e),e.capacity=0;let t=Su(e.messages);return Eu(e),je(t)}return},M4=(e)=>e.state._tag==="Done"?0:e.messages.length,vh,wh,N4,D4,tw=(e)=>{if(e.scheduleRunning=!1,e.state._tag==="Done"||e.state.takers.size===0)return;for(let t of e.state.takers)if(e.state.takers.delete(t),t(Rn),e.messages.length===0)break},CP=(e)=>{if(e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0)return;e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>tw(e),0)},$4=(e,t,n)=>{if(e.state._tag==="Done")return e.state.exit;else if(n<=0||t<=0)return je([]);else if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,Eu(e),e.capacity=0;let r=[Su(e.messages)];return Eu(e),je(r)}if(t=Math.min(t,e.capacity||1),t<=e.messages.length){let r=SP(e.messages,n);return Eu(e),je(r)}},U4=(e,t)=>Bt((n)=>{if(e.state._tag!=="Open")return n(vh);let r={_tag:"Single",message:t,resume:n};return e.state.offers.add(r),pe(()=>{if(e.state._tag==="Open")e.state.offers.delete(r)})}),Eu=(e)=>{if(e.state._tag==="Done")return Tf(e.state.exit.cause);else if(e.state.offers.size===0){if(e.state._tag==="Closing"&&e.messages.length===0)return nw(e,e.state.exit),Tf(e.state.exit.cause);return!1}let t=e.capacity-e.messages.length;for(let n of e.state.offers)if(t===0)break;else if(n._tag==="Single")vs(e.messages,n.message),t--,n.resume(wh),e.state.offers.delete(n);else{for(;n.offset<n.remaining.length;n.offset++){if(t===0)return!1;vs(e.messages,n.remaining[n.offset]),t--}n.resume(je([])),e.state.offers.delete(n)}return!1},TP=(e)=>Bt((t)=>{if(e.state._tag==="Done")return t(e.state.exit);return e.state.takers.add(t),pe(()=>{if(e.state._tag!=="Done")e.state.takers.delete(t)})}),nw=(e,t)=>{if(e.state._tag==="Done")return;let n=e.state;e.state={_tag:"Done",exit:t};for(let r of n.takers)r(t);n.takers.clear();for(let r of n.awaiters)r(t);n.awaiters.clear()};var Gf=w(()=>{X();rt();rt();ht();EP();_e();Ca();Xb={_A:D,_E:D},F4={[_4]:Xb,[R4]:Xb,[P4]:Xb,...Cn,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:M4(this)}}},Kf=p(2,(e,t)=>pe(()=>Vf(e,t))),vh=je(!1),wh=je(!0),N4=kr(Rc()),D4=_m()});class _P{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=ae(()=>{if(this.free<e)return OP(this,e,t);return this.taken+=e,L(e)});return t}takeIfAvailable(e){return ae(()=>{if(this.free<e)return L(!1);return this.taken+=e,L(!0)})}releaseUnsafe(e,t){if(this.taken-=t,this.waiters.size>0)e.currentDispatcher.scheduleTask(()=>{for(let n of this.waiters){if(this.free<=0)break;n()}},0);return this.free}resize(e){return ce((t)=>{if(this.permits=e,this.free<0)return ye;return this.releaseUnsafe(t,0),ye})}release(e){return ce((t)=>L(this.releaseUnsafe(t,e)))}get releaseAll(){return ce((e)=>L(this.releaseUnsafe(e,this.taken)))}withPermits(e){return(t)=>Qr((n)=>{let r=ae(()=>{if(this.free<e){let o=OP(this,e,ye);return K(n(o),()=>r)}return this.taken+=e,ls(n(t),()=>{this.releaseUnsafe(pi(),e);return},!0)});return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return(t)=>Qr((n)=>{if(this.free<e)return xa;return this.taken+=e,ls(n(Xc(t)),()=>{this.releaseUnsafe(pi(),e);return},!0)})}}var AP=(e)=>new _P(e),OP=(e,t,n)=>Bt((r)=>{if(e.free>=t)return r(n);let o=()=>{if(e.free<t)return;e.waiters.delete(o),r(n)};return e.waiters.add(o),pe(()=>{e.waiters.delete(o)})});var RP=w(()=>{rt();ht()});var FP="~effect/Channel",PP=(e)=>M(e,FP),j4,Sn=(e)=>{let t=Object.create(j4);return t.transform=(n,r)=>xr(e(n,r),(o)=>v(fu(o))),t},MP=(e,t)=>Sn((n,r)=>ne(eo(e)(n,r),(o)=>t(o,r))),Ih=(e)=>Sn((t,n)=>e),NP=(e)=>Sn(H(function*(t,n){let r=yi(n),o=(i)=>pr(r,Eb(i)),s=yield*mu(e(t,n,r),o);return mu(s,o)})),eo=(e)=>e.transform,B4=(e,t,n)=>bu({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(du((r)=>Ef(e,ew(r))),du((r)=>gu(Sf(t(r),e),e))),DP=(e,t)=>Sn((n,r)=>oe(B4(r,e,t),wP)),$P=(e)=>Sn((t,n)=>Ne(()=>eo(e())(t,n))),UP,LP,rw,H4,jP,BP=()=>Sn((e,t)=>Se(()=>{let n="",r=!1,o=O();function s(c){let u=[];function l(f){if(n.length===0)u.push(f);else u.push(n+f),n=""}for(let f=0;f<c.length;f++){let d=c[f];if(d.length!==0){let m=0,g=d.indexOf("\r"),b=d.indexOf(`
|
|
24
|
+
${M_(e.cause,`${t} `)}
|
|
25
|
+
${t}}`;return r},Ph="~effect/Fiber",yK,SK,oa=()=>globalThis[Iu],hb,EK,ib,Uh=(e)=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(dE.key,e.currentStackFrame),Gi(t)},bK=(e)=>{if(e._children===void 0||e._children.size===0)return;return ra(e._children)},D_=(e)=>{let t=e;if(t._exit)return W(t._exit);return an((n)=>{if(t._exit)return n(W(t._exit));return me(e.addObserver((r)=>n(W(r))))})},Lh=(e)=>an((t)=>{let n=e[Symbol.iterator](),r=[],o=void 0;function s(){let i=n.next();while(!i.done){if(i.value._exit){r.push(i.value._exit),i=n.next();continue}o=i.value.addObserver((a)=>{r.push(a),s()});return}t(W(r))}return s(),me(()=>o?.())}),Bh=(e)=>le((t)=>N_(e,t.id)),N_,ra=(e)=>le((t)=>{let n=Uh(t),r=cc();for(let o of e)o.interruptUnsafe(t.id,n),r.push(o);return ld(Lh(r))}),W,Ge,ft,me,ue,gb,Yu,$_=(e)=>e==null?ft(new os):W(e),xb,Xu,yb=(e)=>W(F(e)),mc,U_=(e)=>he(e)?mc:We(e.value,F),L_=(e)=>ue(()=>Ge(Fe(e))),sa=(e)=>Oo(e),Hh=(e)=>ue(()=>ft(Fe(e))),Ee,B_=(e)=>{let t=typeof e==="function"?e:e.try,n=typeof e==="function"?(r)=>new Ed(r,"An error occurred in Effect.try"):e.catch;return ue(()=>{try{return W(Fe(t))}catch(r){return ft(Fe(()=>n(r)))}})},Sb=(e)=>Eb(function(t,n){Fe(()=>e(n)).then((r)=>t(W(r)),(r)=>t(sa(r)))},e.length!==0),H_=(e)=>{let t=typeof e==="function"?e:e.try,n=typeof e==="function"?(r)=>new Ed(r,"An error occurred in Effect.tryPromise"):e.catch;return Eb(function(r,o){let s=(i)=>{try{r(ft(Fe(()=>n(i))))}catch(a){r(sa(a))}};try{Fe(()=>t(o)).then((i)=>r(W(i)),s)}catch(i){s(i)}},t.length!==0)},W_=(e)=>le((t)=>e(t.id)),j_,q_,Eb,wK,an=(e)=>Eb(e,e.length>=2),Wh,z_=(...e)=>ue(()=>Qu(e.length===1?e[0]():e[1].call(e[0].self))),bb=(e,...t)=>{let n=t.length===0?function(){return ue(()=>Qu(e.apply(this,arguments)))}:function(){let r=ue(()=>Qu(e.apply(this,arguments)));for(let o=0;o<t.length;o++)r=t[o](r,...arguments);return r};return wb(e.length,n)},wb=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),g_,V_=function(){let e=typeof arguments[0]==="string",t=e?arguments[0]:"Effect.fn",n=e?arguments[1]:void 0,r=ta();$r(2);let o=new globalThis.Error;if($r(r),e)return(s,...i)=>x_(t,s,o,i,e,n);return x_(t,arguments[0],o,Array.prototype.slice.call(arguments,1),e,n)},x_=(e,t,n,r,o,s)=>{let i=typeof t==="function"?t:r.shift().bind(t.self);return wb(i.length,function(...a){let c=ue(()=>{let f=i.apply(this,arguments);return de(f)?f:Qu(f)});for(let f=0;f<r.length;f++)c=r[f](c,...a);if(!de(c))return c;let u=ta();$r(2);let l=new globalThis.Error;return $r(u),Zs(o?rd(e,s,(f)=>lb(c,f)):c,Yf,(f)=>({name:e,stack:g_(()=>l.stack),parent:{name:`${e} (definition)`,stack:g_(()=>n.stack),parent:f}}))})},K_=(e,...t)=>wb(e.length,t.length===0?function(){return y_(()=>e.apply(this,arguments))}:function(){let n=y_(()=>e.apply(this,arguments));for(let r of t)n=r(n);return n}),y_=(e)=>{try{let t=e(),n=void 0;while(!0){let r=t.next(n);if(r.done)return W(r.value);let o=r.value;if(o&&o._tag==="Success"){n=o.value;continue}else if(o&&o._tag==="Failure")return r.value;else{let s=!0;return ue(()=>{if(s)return s=!1,V(r.value,(i)=>Qu(t,i));else return ue(()=>Qu(e()))})}}}catch(t){return sa(t)}},Qu,Hn,el=(e)=>We(e,F),G_=(e)=>gc(e,{onFailure:W,onSuccess:ft}),Mo,hc,ld=(e)=>V(e,(t)=>or),J_=(e)=>Lr(e,ft),kb=(e,t)=>le((n)=>an((r)=>{let o=on(e),s=o.length,i=0,a=!1,c=new Set,u=[],l=(f,d,m)=>{if(i++,f._tag==="Failure"){if(u.push(...f.cause.reasons),i>=s)r(Ge(Ls(u)));return}let y=!a;if(a=!0,r(c.size===0?f:V(ei(ra(c)),()=>f)),y&&t?.onWinner)t.onWinner({fiber:d,index:m,parentFiber:n})};for(let f=0;f<s;f++){let d=xc(n,o[f],!0,!0,!1);if(c.add(d),d.addObserver((m)=>{c.delete(d),l(m,d,f)}),a)break}return ra(c)})),Cb=(e,t)=>le((n)=>an((r)=>{let o=!1,s=new Set,i=(c)=>{o=!0,r(s.size===0?c:V(ei(ra(s)),()=>c))},a=0;for(let c of e){if(o)break;let u=a++,l=xc(n,c,!0,!0,!1);s.add(l),l.addObserver((f)=>{s.delete(l);let d=!o;if(i(f),d&&t?.onWinner)t.onWinner({fiber:l,index:u,parentFiber:n})})}return ra(s)})),Q_,jh,V,kK,Z_,Xe=(e)=>(Qa in e),Y_,X_=(e)=>V(e,L),We,eO,tO,nO,rO,qh=(e)=>$n(pc(e)),ia=(e)=>e._tag==="Success",oO=(e)=>e._tag==="Success"?J(e):oe(e),sO=(e)=>e._tag==="Success"?J(e.value):oe(e),vb=(e)=>e._tag==="Failure",iO=(e)=>e._tag==="Failure"?J(e):oe(e),fd=(e)=>e._tag==="Failure"?J(e.cause):oe(e),Ib,aO,cO=(e)=>e._tag==="Failure"&&Fh(e.cause),uO=(e)=>e._tag==="Failure"&&Rh(e.cause),lO=(e)=>e._tag==="Failure"&&db(e.cause),or,Ab,Tb,_b,CK,fO,dO,pO,Ob=(e)=>{let t=[];for(let n of e)if(n._tag==="Failure")t.push(...n.cause.reasons);return t.length===0?or:$n(Ls(t))},mO=(e)=>ia(e)?F(e.value):P(),hO=(e)=>vb(e)?F(e.cause):P(),gO=(e)=>{let t=Ib(e);return Se(t)?P():F(t.success)},xO=(e)=>e,yO=(e)=>le((t)=>W(TE(t.context,e))),vK=(e)=>le((t)=>gb(TE(t.context,e))),tl,Zs,SO=(e,t,n)=>ei(le((r)=>{let o=Ro(r.context,e),s=t(o);return r.setContext(Cn(r.context,e,s)),Do(Ro(r.context,ca),(i)=>{let a=Ro(r.context,e),c;if(n?.reset===void 0){if(a!==s)return Ee;c=o}else c=n.reset(o,s,a);return r.setContext(Cn(r.context,e,c)),Ee})})),Pb=()=>IK,IK,aa=(e)=>le((t)=>e(t.context)),EO,Ys,sr=function(){if(arguments.length===1)return p(2,(e,t)=>S_(e,arguments[0],t));return p(3,(e,t,n)=>S_(e,t,n)).apply(this,arguments)},S_=(e,t,n)=>tl(e,Cn(t,n)),zh,bO,Rb,wO,kO,Fb,CO,Vh,Lr,AK,Mb,nl,Br,vO=(e)=>gc(e,{onFailure:(t)=>th(t)?mc:ft(t),onSuccess:yb}),IO,AO,TO,Kh,Db,_O,OO,dd,Gh,Nb,PO,RO,FO,MO,$b,Ub,Lb=(e)=>Br(e,sa),DO,NO=(e)=>ue(()=>{let t=e[Symbol.iterator](),n=t.next();if(n.done)return sa(Error("Received an empty collection of effects"));function r(o){let s=t.next();if(s.done)return o.value;return Br(o.value,(i)=>r(s))}return r(n)}),Bb=(e)=>Br(e,(t)=>V(Xu,()=>Bb(e))),$O,Jh,UO=(e)=>Qh(e,{onFailure:P,onSuccess:F}),na=(e)=>pd(e,{onFailure:oe,onSuccess:J}),Fo,TK,Hb,gc,Qh,pd,LO,md=(e)=>Xe(e)?Ke(e):_K(e),_K,BO,HO,WO,Wb,jO,qO,zO=(e)=>as((t)=>{let n=t.monotonicTimeNanosUnsafe();return We(e,(r)=>[io(t.monotonicTimeNanosUnsafe()-n),r])}),ab="~effect/Scope",cb="~effect/Scope/Closeable",ca,jb=(e,t)=>ue(()=>Zh(e,t)??Ee),Zh=(e,t)=>{if(e.state._tag==="Closed")return;let n={_tag:"Closed",exit:t};if(e.state._tag==="Empty"){e.state=n;return}let r=e.state;if(e.state=n,r.finalizer!==void 0)return r.finalizer(t);let o=r.finalizers;if(o===void 0||o.size===0)return;else if(o.size===1)return o.values().next().value(t);return PK(e,o,t)},OK=(e,t)=>ia(e)?t:Lr(t,(n)=>Ge(Dh(e.cause,n))),PK,VO=(e,t)=>{let n=hd(t);if(e.state._tag==="Closed")return n.state=e.state,n;let r={};return td(e,r,(o)=>jb(n,o)),td(n,r,(o)=>me(()=>qb(e,r))),n},Do=(e,t)=>ue(()=>{if(e.state._tag==="Closed")return t(e.state.exit);return td(e,{},t),Ee}),KO=(e,t)=>Do(e,_t(t)),td=(e,t,n)=>{if(e.state._tag==="Empty")e.state={_tag:"Open",finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag==="Open"){let r=e.state;if(r.finalizer!==void 0)r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n);else if(r.finalizers===void 0)r.finalizerKey=t,r.finalizer=n;else r.finalizers.set(t,n)}},qb=(e,t)=>{if(e.state._tag==="Open"){let n=e.state;if(n.finalizerKey===t)n.finalizerKey=void 0,n.finalizer=void 0;else if(n.finalizers!==void 0)n.finalizers.delete(t)}},hd=(e="sequential")=>({[cb]:cb,[ab]:ab,strategy:e,state:RK}),RK,gd,GO,zb=(e)=>le((t)=>{let n=t.context,r=hd();return t.setContext(Cn(t.context,ca,r)),Xs(e,(o)=>(t.setContext(n),Zh(r,o)))}),Yh=(e)=>ue(()=>{let t=hd();return vn(e(t),(n)=>ue(()=>Zh(t,n)??Ee))}),xd=(e,t,n)=>aa((r)=>No((o)=>V(gd,(s)=>hc(n?.interruptible?o(e):e,(i)=>Do(s,(a)=>Ys(t(i,a),r)))))),Vb=(e)=>V(gd,(t)=>aa((n)=>Do(t,(r)=>Ys(e(r),n)))),Xs,vn,JO,Kb,Gb,Jb,QO,Qb,ZO,Zb=(e,t,n)=>No((r)=>V(e,(o)=>Xs(r(t(o)),(s)=>n(o,s),!0))),YO=(e)=>xd(e,(t)=>D(t,Symbol.asyncDispose)?Sb(()=>t[Symbol.asyncDispose]()):me(()=>t[Symbol.dispose]())),Yb,Xb,XO=(e)=>Xb(e,Gs),eP,ei=(e)=>le((t)=>{if(!t.interruptible)return e;return t.interruptible=!1,t._stack.push(Xh),e}),tP,Xh,FK,nP=(e)=>{if(e.interruptible=!0,e._stack.push(FK),e._interruptedCause)return Ge(e._interruptedCause)},ew=(e)=>le((t)=>{if(t.interruptible)return e;return nP(t)??e}),No=(e)=>le((t)=>{if(!t.interruptible)return e(L);return t.interruptible=!1,t._stack.push(Xh),e(ew)}),rP=(e)=>le((t)=>{if(t.interruptible)return e(L);let n=nP(t),r=e(ei);return n??r}),oP,yd=(e,t)=>{if(ns(e))return t?.mode==="result"?Ur(e,na,t):Ur(e,L,t);else if(t?.discard)return t.mode==="result"?Ur(Object.values(e),na,t):Ur(Object.values(e),L,t);return ue(()=>{let n={};return Hn(Ur(Object.entries(e),([r,o])=>We(t?.mode==="result"?na(o):o,(s)=>{H(n,r,s)}),{discard:!0,concurrency:t?.concurrency}),n)})},tw,sP,iP,aP,cP=(e,t,n,r)=>V(n(r,t),(o)=>{if(o)return W(F(r));let s=e.next();if(!s.done)return cP(e,t+1,n,s.value);return W(P())}),uP,lP=(e,t,n,r)=>V(n(r,t),(o)=>{if(rn(o))return W(F(o.success));let s=e.next();if(!s.done)return lP(e,t+1,n,s.value);return W(P())}),is,Ur,fP=(e)=>V(e,(t)=>{let n=t[Symbol.iterator]().next();return n.done?ft(new os):W(n.value)}),MK=(e,t,n)=>ue(()=>{let r=n?.discard?void 0:[],o=e[Symbol.iterator](),s=o.next(),i=0;return Hn(is({while:()=>!s.done,body:()=>t(s.value,i++),step:(a)=>{if(r)r.push(a);s=o.next()}}),r)}),dP=(e)=>{let{onItem:t,step:n}=e,r=(o,s,i,a)=>{for(;i<a;i++){let c=s[i],u=t(o,c,i);if(!Xe(u))return V(md(u),(f)=>n(o,c,f,i)??r(o,s,i+1,a)??Ee);let l=n(o,c,u,i);if(l)return l._tag==="Failure"?l:void 0}};return(o,s,i)=>{let a=0,c=i?.end??s.length,u=i?.concurrency??1;if(u===1)return r(o,s,0,c);let l=i?.orderedStep===!0,f=!1,d,m,y,b=!1,E,w,k=a,g=l?Array(c):void 0,x=(I)=>{let _=Oo(I);return E=_,f=!0,b=!0,m&&m.size>0?V(ei(ra(Array.from(m))),()=>_):_},S=(I,_,M)=>{if(!l)return n(o,I,_,M);if(E)return E;g[M]=_;while(k<c){let U=g[k];if(U===void 0)return;g[k]=void 0;let N=k++,Z=n(o,s[N],U,N);if(Z)return Z}},C=()=>{let I=!1;for(;!E&&a<c;a++){let _=s[a],M=w??t(o,_,a);if(Xe(M)){if(E=S(_,M,a),E)break}else if(!d)return an((U)=>{d=oa(),m=new Set,w=M,y=U;let N;try{N=C()}catch(Z){return U(x(Z))}if(N)return U(N);return ue(()=>(E=or,b=!0,m?ra(m):Ee))});else{w=void 0;let U=xc(d,M,!0,!0,"inherit");if(U._exit){if(E=S(_,U._exit,a),E)break;continue}m.add(U);let N=a;if(U.addObserver((Z)=>{m.delete(U);try{if(E){if(!b&&Z._tag==="Failure")for(let G of Z.cause.reasons)if(G._tag==="Interrupt")continue;else if(E._tag==="Failure")E.cause.reasons.push(G);else E=$n(Ls([G]))}else{let G=S(_,Z,N);if(G)E=G._tag==="Failure"?$n(Ls(G.cause.reasons.slice())):G,C()}if(I){let G=C();if(G)y(G)}else if(f&&m.size===0)y(E??Ee)}catch(G){y(x(G))}}),m.size<u)continue;I=!0,a++;return}}if(f=!0,E){if(m&&m.size>0){let _=Uh(d);m.forEach((M)=>M.interruptUnsafe(d.id,_));return}if(y||E._tag==="Failure")return E}else if(y){if(!m)return or;else if(m.size===0)y(Ee)}};return C()}},Sd=()=>dP,DK,nw,rw,pP,mP,hP,gP,xP,yP,SP,EP,bP,xc=(e,t,n=!1,r=!1,o=!1)=>{let s=e,i=o==="inherit"?s.interruptible:!o,a=new hb(s.context,i);if(n)a.evaluate(t);else s.currentDispatcher.scheduleTask(()=>a.evaluate(t),0);if(!r&&!a._exit)s.children().add(a),a.addObserver(()=>s._children.delete(a));return a},wP,kP=(e)=>le((t)=>{let n=t._children&&new Set(t._children);return vn(e,(r)=>{let o=t._children;if(o===void 0||o.size===0)return Ee;else if(n)o=vT(o,(s)=>!n.has(s));return ld(Lh(o))})}),ow,CP,ti=(e)=>(t,n)=>{let r=new hb(n?.scheduler?Cn(e,Zf,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal)if(n.signal.aborted)r.interruptUnsafe();else{let o=()=>r.interruptUnsafe();n.signal.addEventListener("abort",o,{once:!0}),r.addObserver(()=>n.signal.removeEventListener("abort",o))}if(n?.onFiberStart)n.onFiberStart(r);return r},vP,IP,sw=(e)=>{let t=ti(e);return(n,r)=>{let o=t(n,r);if(r?.onExit)o.addObserver(r.onExit);return(s)=>o.interruptUnsafe(s)}},AP,eg=(e)=>{let t=ti(e);return(n,r)=>{let o=t(n,r);return new Promise((s)=>{o.addObserver((i)=>s(i))})}},TP,iw=(e)=>{let t=eg(e);return(n,r)=>t(n,r).then((o)=>{if(o._tag==="Failure")throw Nh(o.cause);return o.value})},_P,tg=(e)=>{let t=ti(e);return(n)=>{if(Xe(n))return n;let r=new zu("sync"),o=t(n,{scheduler:r});return o._dispatcher?.flush(),o._exit??Oo(new rg(o))}},OP,aw=(e)=>{let t=tg(e);return(n)=>{let r=t(n);if(r._tag==="Failure")throw Nh(r.cause);return r.value}},PP,E_,b_,cw=(e)=>new RP(e??!1),FP,MP,DP,NP,ub,NK,$K=(e)=>Object.assign(Object.create(NK),e),$P=(e)=>{if(!e)return P();return tr(e.annotations,Ch)?e._tag==="Span"?$P(Un(e.parent)):P():F(e)},uw=(e,t,n)=>{let r=!e.getRef(Ih)||n?.annotations&&tr(n.annotations,Ch),o=n?.parent!==void 0?F(n.parent):n?.root?P():$P(e.currentSpan),s;if(r)s=$K({name:t,parent:o,annotations:Cn(n?.annotations??Ln(),Ch,!0)});else{let i=e.getRef(vh),a=e.getRef(ni),c=e.getRef(Ju),u=e.getRef(Xf),l=e.getRef(ed),f=n?.level??e.getRef(u_),d=n?.links!==void 0?[...l,...n.links]:l.length===0?[]:l.slice();s=i.span({name:t,parent:o,annotations:n?.annotations??Ln(),links:d,startTime:c?a.currentTimeNanosUnsafe():BigInt(0),kind:n?.kind??"internal",root:n?.root??he(o),sampled:n?.sampled??(Ce(o)&&o.value.sampled===!1?!1:!oR(e.getRef(l_),f))});for(let m in u)s.attribute(m,u[m]);if(n?.attributes!==void 0)for(let m in n.attributes)s.attribute(m,n.attributes[m])}return s},UP=(e,t)=>le((n)=>W(uw(n,e,t))),nd=(e,t)=>ei(le((n)=>{let r=Ro(n.context,ca),o=uw(n,e,t??{}),s=n.getRef(ni),i=n.getRef(Ju);return Hn(Do(r,(a)=>jP(o,a,s,i)),o)})),LP=function(){let e=typeof arguments[0]!=="string",t=e?arguments[1]:arguments[0],n=Oh(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return V(nd(t,n),(o)=>Zu(r,o,n))}return(r)=>V(nd(t,n),(o)=>Zu(r,o,n))},UK=(e,t)=>(t=typeof t==="function"?t:Ao,Zs(Yf,(n)=>({name:e,stack:t,parent:n}))),BP,HP,WP,jP=(e,t,n,r)=>me(()=>{if(e.status._tag==="Ended")return;e.end(r?n.currentTimeNanosUnsafe():ub,t)}),rd=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return le((o)=>{let s=uw(o,e,n),i=o.getRef(ni),a=o.getRef(Ju);return vn(Fe(()=>r(s)),(c)=>jP(s,c,i,a))})},lb,Zu=function(){let e=de(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=L;if(t._tag==="Span")n=Oh(n),r=UK(t.name,n?.captureStackTrace);if(e)return lb(r(arguments[0]),t);return(o)=>lb(r(o),t)},qP=function(){let e=typeof arguments[0]!=="string",t=e?arguments[1]:arguments[0],n=Oh(arguments[2]);if(e){let s=arguments[0];return rd(t,arguments[2],(i)=>Zu(s,i,n))}let r=typeof arguments[1]==="function"?arguments[1]:void 0,o=r?void 0:arguments[1];return(s,...i)=>rd(t,r?r(...i):o,(a)=>Zu(s,a,n))},zP,VP=(...e)=>le((t)=>{let n=t.currentSpanLocal;if(n)if(e.length===1)for(let[r,o]of Object.entries(e[0]))n.attribute(r,o);else n.attribute(e[0],e[1]);return Ee}),KP,GP,ni,ob=2147483647,QP,ZP,LK,as=(e)=>le((t)=>e(t.getRef(ni))),yc=(e)=>as((t)=>t.sleep(Nr(e))),YP,od="~effect/Cause/TimeoutError",XP=(e)=>D(e,od),ng,sd="~effect/Cause/IllegalArgumentError",eR=(e)=>D(e,sd),lw,id="~effect/Cause/ExceededCapacityError",tR=(e)=>D(e,id),fw,ad="~effect/Cause/AsyncFiberError",nR=(e)=>D(e,ad),rg,cd="~effect/Cause/UnknownError",rR=(e)=>D(e,cd),Ed,dw,BK=(e)=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 50000;case"Error":return 40000;case"Warn":return 30000;case"Info":return 20000;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}},HK,oR,pw,WK,sR=function(){let e=typeof arguments[0]==="string"?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return ei(le((t)=>{let n=t.getRef(Qs),r={...n};for(let o=0;o<e.length;o++){let[s,i]=e[o];H(r,s,i)}return t.setContext(Cn(t.context,Qs,r)),Do(Ro(t.context,ca),(o)=>{let s=t.getRef(Qs),i={...s};for(let a=0;a<e.length;a++){let[c,u]=e[a];if(s[c]!==u)continue;if(Object.hasOwn(n,c))H(i,c,n[c]);else delete i[c]}return t.setContext(Cn(t.context,Qs,i)),Ee})}))},jK="~effect/Logger",qK,iR=(e)=>{let t=Object.create(qK);return t.log=e,t},zK=(e)=>e.replace(/[\s="]/g,"_"),VK=(e,t)=>`${zK(e[0])}=${t-e[1]}ms`,$o=(e)=>(...t)=>{let n=void 0;for(let r=0,o=t.length;r<o;r++){let s=t[r];if(_u(s)){if(n)t.splice(r,1);else t=t.slice(0,r).concat(t.slice(r+1));n=n?Ls(n.reasons.concat(s.reasons)):s,r--}}if(n===void 0)n=Ym;return le((r)=>{let o=e??r.currentLogLevel;if(oR(r.minimumLogLevel,o))return Ee;let s=r.getRef(ni),i=r.getRef(pw);if(i.size>0){let a=new Date(s.currentTimeMillisUnsafe());for(let c of i)c.log({cause:n,fiber:r,date:a,logLevel:o,message:t})}return Ee})},dc,Vle,KK=(e)=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`,GK,JK,mw,aR,ZK=(e,t,n)=>{let r=e.getRef(m_);if(r.size===0)return;if(n&&!Rh(t))return;let o={cause:t,fiber:e,timestamp:e.getRef(ni).currentTimeNanosUnsafe()};r.forEach((s)=>s.report(o))};var At=v(()=>{nr();rt();Yi();Pt();zT();Zn();ne();wn();pr();FE();Me();rc();ct();ge();Jm();Bn();yh();d_();Ja();pt();rh();nb();_h();h_();fb=class fb extends $f{fiberId;constructor(e,t=Uf){super("Interrupt",t,"Interrupted");this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[Oe](e){return ec(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[_e](){return Ot(Ze(`${this._tag}:${this.fiberId}`))(zm(this.annotations))}};k_=qT(ao),dK=new Set,Dh=p(2,(e,t)=>{if(e.reasons.length===0)return t;else if(t.reasons.length===0)return e;let n=new Us($E(e.reasons,t.reasons));return ee(e,n)?e:n}),O_=p(2,(e,t)=>{let n=!1,r=e.reasons.map((o)=>{if(ji(o))return n=!0,new Ou(t(o.error),o.annotations);return o});return n?Ls(r):e}),hK=/\((.*)\)/g,yK={_A:L,_E:L},SK={id:0};hb=class hb{constructor(e,t=!0){this[Ph]=yK,this.setContext(e),this.id=++SK.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this.runtimeMetrics?.recordFiberStart(this.context)}[Ph];id;interruptible;currentOpCount;_stack;_observers;_exit;_children;_interruptedCause;_yielded;_running;_deferredInterrupt;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(e){return tr(this.context,e)}addObserver(e){if(this._exit)return e(this._exit),Ns;return this._observers.push(e),()=>{if(this._exit)return;let t=this._observers.indexOf(e);if(t>=0)this._observers.splice(t,1)}}interruptUnsafe(e,t){if(this._exit)return;let n=pc(e);if(this.currentStackFrame)n=Pu(n,Ks(eh,this.currentStackFrame));if(t)n=Pu(n,t);if(this._interruptedCause=this._interruptedCause?Dh(this._interruptedCause,n):n,this.interruptible)if(this._running)this._deferredInterrupt=!0;else this.evaluate(Ge(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;else if(this._yielded!==void 0){let r=this._yielded;this._yielded=void 0,r()}let t=this.runLoop(e);if(t===Ya)return;let n=ib.interruptChildren&&ib.interruptChildren(this);if(n!==void 0)return this.evaluate(V(n,()=>t));this._exit=t,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let r=0;r<this._observers.length;r++)this._observers[r](t);this._observers.length=0,this._stack.length=0,this._children=void 0,this.context=Ln()}runLoop(e){let t=globalThis[Iu];globalThis[Iu]=this;let n=this._running;this._running=!0;let r=!1,o=e;this.currentOpCount=0;try{while(!0){if(this._deferredInterrupt)this._deferredInterrupt=!1,o=Ge(this._interruptedCause);if(this.currentOpCount++,!r&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){r=!0;let s=o;o=V(Xu,()=>s)}if(o=this.currentTracerContext?this.currentTracerContext(o,this):o[Rt](this),o===Ya){let s=this._yielded;if(Qa in s)return this._deferredInterrupt=!1,this._yielded=void 0,s;else if(this._deferredInterrupt){this._yielded=void 0,s();continue}return Ya}}}catch(s){if(!D(o,Rt))return Oo(`Fiber.runLoop: Not a valid effect: ${String(o)}`);return this.runLoop(Oo(s))}finally{this._running=n,globalThis[Iu]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,EK;while(!0){let t=this._stack.pop();if(!t)return;let n=t[Wi]&&t[Wi](this);if(n)return n[e]=n,n;if(t[e])return t}}yieldWith(e){return this._yielded=e,Ya}children(){return this._children??=new Set}pipe(){return fe(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&yT(t,e))return;let n=this.getRef(Zf);if(n!==this.currentScheduler)this.currentScheduler=n,this._dispatcher=void 0;this.currentSpan=Gf(e,XE),this.currentLogLevel=this.getRef(tb),this.minimumLogLevel=this.getRef(Ah),this.currentStackFrame=this.getRef(Yf),this.maxOpsBeforeYield=this.getRef(JT),this.currentPreventYield=this.getRef(QT),this.runtimeMetrics=Gf(e,p_);let r=Gf(e,eb);this.currentTracerContext=r?r.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}};EK={[Yn](e,t){return Ge(t._interruptedCause)},[to](e,t){return Ge(t._interruptedCause)}},ib={interruptChildren:void 0},N_=p((e)=>D(e[0],Ph),(e,t,n)=>le((r)=>{let o=Uh(r);return o=o&&n?ic(o,n):o??n,e.interruptUnsafe(t,o),ld(D_(e))})),W=Ke,Ge=$n,ft=ro,me=no({op:"Sync",[Rt](e){let t=this[ce](),n=e.getCont(Yn);return n?n[Yn](t,e):e.yieldWith(Ke(t))}}),ue=no({op:"Suspend",[Rt](e){return this[ce]()}}),gb=p((e)=>e.length>=2||Hu(e[0]),(e,t)=>he(e)?ft(t?t():new os("Effect.fromOption: Option.none")):W(e.value)),Yu=mr({onFailure:ft,onSuccess:W}),xb=no({op:"Yield",[Rt](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{if(t)return;e.evaluate(or)},this[ce]??0),e.yieldWith(()=>{t=!0})}}),Xu=xb(0),mc=W(P()),Ee=W(void 0),j_=le(W),q_=W_(W),Eb=no({op:"Async",single:!1,[Rt](e){let t=Fe(()=>this[ce][0].bind(e.currentScheduler)),n=!1,r=!1,o=this[ce][1]?new AbortController:void 0,s=t((i)=>{if(n)return;if(n=!0,r)e.evaluate(i);else r=i},o?.signal);if(r!==!1)return r;if(r=!0,e._yielded=()=>{n=!0},o===void 0&&s===void 0)return Ya;return e._stack.push(wK(()=>(n=!0,o?.abort(),s??or))),Ya}}),wK=no({op:"AsyncFinalizer",[Wi](e){if(e.interruptible)e.interruptible=!1,e._stack.push(Xh)},[to](e,t){return Fh(e)?V(this[ce](),()=>Ge(e)):Ge(e)}}),Wh=an(Ns),g_=rb(2),Qu=no({op:"Iterator",single:!1,[Yn](e,t){let n=this[ce][0];while(!0){let r=n.next(e);if(r.done)return W(r.value);if(!Xe(r.value))return t._stack.push(this),r.value;else if(r.value._tag==="Failure")return r.value;e=r.value.value}},[Rt](e){return this[Yn](this[ce][1],e)}}),Hn=p(2,(e,t)=>{let n=W(t);return V(e,(r)=>n)}),Mo=p(2,(e,t)=>V(e,(n)=>de(t)?t:Fe(()=>t(n)))),hc=p(2,(e,t)=>V(e,(n)=>Hn(de(t)?t:Fe(()=>t(n)),n))),Q_=p((e)=>de(e[1]),(e,t,n)=>kb([e,t],n)),jh=p((e)=>de(e[1]),(e,t,n)=>Cb([e,t],n)),V=p(2,(e,t)=>{let n=Object.create(kK);return n[ce]=e,n[Yn]=t.length!==1?(r)=>t(r):t,n}),kK=Bs({op:"OnSuccess",[Rt](e){return e._stack.push(this),this[ce]}}),Z_=p(2,(e,t)=>{if(Xe(e))return e._tag==="Success"?t.onSuccess(e.value):t.onFailure(e.cause);return Fo(e,t)}),Y_=p(2,(e,t)=>{if(Xe(e))return e._tag==="Success"?t(e.value):e;return V(e,t)}),We=p(2,(e,t)=>V(e,(n)=>W(Fe(()=>t(n))))),eO=p(2,(e,t)=>Xe(e)?Ab(e,t):We(e,t)),tO=p(2,(e,t)=>Xe(e)?Tb(e,t):$b(e,t)),nO=p(2,(e,t)=>Xe(e)?_b(e,t):Ub(e,t)),rO=p(2,(e,t)=>{if(Xe(e)){if(e._tag==="Success")return e;let n=ao(e.cause);if(Se(n))return e;return t(n.success)}return Br(e,t)}),Ib=jE(fd,ao),aO=jE(fd,ud),or=Ke(void 0),Ab=p(2,(e,t)=>e._tag==="Success"?Ke(t(e.value)):e),Tb=p(2,(e,t)=>{if(e._tag==="Success")return e;let n=ao(e.cause);if(Se(n))return e;return ro(t(n.success))}),_b=p(2,(e,t)=>{if(e._tag==="Success")return Ke(t.onSuccess(e.value));let n=ao(e.cause);if(Se(n))return e;return ro(t.onFailure(n.success))}),CK=p(2,(e,t)=>ia(e)?Ke(t):e),fO=p(2,(e,t)=>ia(e)?t:e),dO=p(2,(e,t)=>ia(e)?t.onSuccess(e.value):t.onFailure(e.cause)),pO=CK(void 0),tl=p(2,(e,t)=>le((n)=>{let r=n.context,o=t(r);if(r===o)return e;return n.setContext(o),Xs(e,()=>{n.setContext(r);return})})),Zs=p(3,(e,t,n)=>tl(e,(r)=>{let o=Ro(r,t),s=n(o);if(o===s)return r;return Cn(r,t,s)})),IK=le((e)=>W(e.context)),EO=p(2,(e,t)=>tl(e,_t(t))),Ys=p(2,(e,t)=>{if(Xe(e))return e;return tl(e,ic(t))}),zh=p(3,(e,t,n)=>V(n,(r)=>sr(e,t,r))),bO=p((e)=>de(e[1]),(e,t,n)=>Rb(e,t,(r,o)=>[r,o],n)),Rb=p((e)=>de(e[1]),(e,t,n,r)=>r?.concurrent?We(yd([e,t],{concurrency:2}),([o,s])=>Fe(()=>n(o,s))):V(e,(o)=>We(t,(s)=>Fe(()=>n(o,s))))),wO=p((e)=>de(e[0]),(e,t,n)=>nw(e,t,n?(r)=>ft(n(r)):()=>ft(new os))),kO=p(2,(e,t)=>V(t,(n)=>n?el(e):mc)),Fb=p(2,(e,t)=>Array.from({length:t},()=>e)),CO=p((e)=>de(e[0]),(e,t,n)=>yd(Fb(e,t),n)),Vh=p((e)=>de(e[0]),(e,t)=>is({while:Fr,body:_t(t?.disableYield?e:V(e,(n)=>Xu)),step:Ns})),Lr=p(2,(e,t)=>{let n=Object.create(AK);return n[ce]=e,n[to]=t.length!==1?(r)=>t(r):t,n}),AK=Bs({op:"OnFailure",[Rt](e){return e._stack.push(this),this[ce]}}),Mb=p(3,(e,t,n)=>Lr(e,(r)=>{if(!t(r))return Ge(r);return Fe(()=>n(r))})),nl=p(3,(e,t,n)=>Lr(e,(r)=>{let o=t(r);return Se(o)?Ge(o.failure):Fe(()=>n(o.success,r))})),Br=p(2,(e,t)=>nl(e,ao,(n)=>t(n))),IO=p(2,(e,t)=>nl(e,ud,t)),AO=p(2,(e,t)=>Lr(e,(n)=>Mo(Fe(()=>t(n)),Ge(n)))),TO=p(3,(e,t,n)=>Mb(e,t,(r)=>Mo(Fe(()=>n(r)),Ge(r)))),Kh=p(3,(e,t,n)=>Lr(e,(r)=>{let o=t(r);if(Se(o))return Ge(r);return Mo(Fe(()=>n(o.success,r)),Ge(r))})),Db=p(2,(e,t)=>Kh(e,ao,(n)=>t(n))),_O=p(3,(e,t,n)=>{let r=Array.isArray(t)?(o)=>D(o,"_tag")&&t.includes(o._tag):eo(t);return Db(e,(o)=>r(o)?n(o):Ee)}),OO=p(2,(e,t)=>Kh(e,ud,(n)=>t(n))),dd=p((e)=>de(e[0]),(e,t,n,r)=>Lr(e,(o)=>{let s=ao(o);if(Se(s))return Ge(s.failure);if(!t(s.success))return r?Fe(()=>r(s.success)):Ge(o);return Fe(()=>n(s.success))})),Gh=p((e)=>de(e[0]),(e,t,n,r)=>Lr(e,(o)=>{let s=ao(o);if(Se(s))return Ge(s.failure);let i=t(s.success);if(Se(i))return r?Fe(()=>r(i.failure)):Ge(o);return Fe(()=>n(i.success))})),Nb=p((e)=>de(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?(s)=>D(s,"_tag")&&t.includes(s._tag):eo(t);return dd(e,o,n,r)}),PO=p((e)=>de(e[0]),(e,t,n)=>{let r;return Gh(e,(o)=>(r??=Object.keys(t),D(o,"_tag")&&_o(o._tag)&&r.includes(o._tag)?J(o):oe(o)),(o)=>Fe(()=>t[o._tag](o)),n)}),RO=p((e)=>de(e[0]),(e,t,n,r,o)=>dd(e,(s)=>eo(s,t)&&D(s,"reason"),(s)=>{let i=s.reason;if(eo(i,n))return r(i,s);return o?Fe(()=>o(i,s)):ft(s)})),FO=p((e)=>de(e[0]),(e,t,n,r)=>{let o;return dd(e,(s)=>eo(s,t)&&D(s,"reason")&&D(s.reason,"_tag")&&_o(s.reason._tag),(s)=>{let i=s.reason;if(o??=Object.keys(n),o.includes(i._tag))return Fe(()=>n[i._tag](i,s));return r?Fe(()=>r(i,s)):ft(s)})}),MO=p(2,(e,t)=>Gh(e,(n)=>{if(eo(n,t)&&D(n,"reason"))return J(n.reason);return oe(n)},ft)),$b=p(2,(e,t)=>Br(e,(n)=>Hh(()=>t(n)))),Ub=p(2,(e,t)=>gc(e,{onFailure:(n)=>Hh(()=>t.onFailure(n)),onSuccess:(n)=>me(()=>t.onSuccess(n))})),DO=p(2,(e,t)=>Br(e,(n)=>me(t))),$O=p((e)=>de(e[0]),(e,t)=>{if(!t?.log)return gc(e,{onFailure:(r)=>Ee,onSuccess:(r)=>Ee});let n=$o(t.log===!0?void 0:t.log);return Fo(e,{onFailure(r){let o=pb(r);return Se(o)?Ge(o.failure):t.message===void 0?n(r):n(t.message,r)},onSuccess:(r)=>Ee})}),Jh=p((e)=>de(e[0]),(e,t)=>{if(!t?.log)return Fo(e,{onFailure:(r)=>Ee,onSuccess:(r)=>Ee});let n=$o(t.log===!0?void 0:t.log);return Fo(e,{onFailure:(r)=>t.message===void 0?n(r):n(t.message,r),onSuccess:(r)=>Ee})}),Fo=p(2,(e,t)=>{let n=Object.create(TK);return n[ce]=e,n[Yn]=t.onSuccess.length!==1?(r)=>t.onSuccess(r):t.onSuccess,n[to]=t.onFailure.length!==1?(r)=>t.onFailure(r):t.onFailure,n}),TK=Bs({op:"OnSuccessAndFailure",[Rt](e){return e._stack.push(this),this[ce]}}),Hb=p(2,(e,t)=>Fo(e,{onFailure:(n)=>me(()=>t.onFailure(n)),onSuccess:(n)=>me(()=>t.onSuccess(n))})),gc=p(2,(e,t)=>Fo(e,{onFailure:(n)=>{let r=n.reasons.find(ji);return r?Fe(()=>t.onFailure(r.error)):Ge(n)},onSuccess:t.onSuccess})),Qh=p(2,(e,t)=>gc(e,{onFailure:(n)=>me(()=>t.onFailure(n)),onSuccess:(n)=>me(()=>t.onSuccess(n))})),pd=p(2,(e,t)=>{if(Xe(e)){if(e._tag==="Success")return Ke(t.onSuccess(e.value));let n=ao(e.cause);if(Se(n))return e;return Ke(t.onFailure(n.success))}return Qh(e,t)}),LO=p(2,(e,t)=>{if(Xe(e)){if(e._tag==="Success")return Ke(t.onSuccess(e.value));return Ke(t.onFailure(e.cause))}return Hb(e,t)}),_K=no({op:"Exit",[Rt](e){return e._stack.push(this),this[ce]},[Yn](e,t,n){return W(n??Ke(e))},[to](e,t,n){return W(n??$n(e))}}),BO=pd({onFailure:()=>!0,onSuccess:()=>!1}),HO=pd({onFailure:()=>!1,onSuccess:()=>!0}),WO=p(2,(e,t)=>Mo(yc(t),e)),Wb=p(2,(e,t)=>jh(e,V(yc(t.duration),t.orElse))),jO=p(2,(e,t)=>Wb(e,{duration:t,orElse:()=>ft(new ng)})),qO=p(2,(e,t)=>jh(el(e),Hn(yc(t),P()))),ca=Ye("effect/Scope"),PK=bb(function*(e,t,n){let r=[],o=[],s=Array.from(t.values()),i=oa();for(let a=s.length-1;a>=0;a--){let c=s[a];if(e.strategy==="sequential")r.push(yield*md(c(n)));else o.push(xc(i,c(n),!0,!0,"inherit"))}if(o.length>0)r=yield*Lh(o);return yield*Ob(r)}),RK={_tag:"Empty"},gd=ca,GO=sr(ca),Xs=no({op:"OnExit",single:!1,[Rt](e){return e._stack.push(this),this[ce][0]},[Wi](e){if(e.interruptible&&this[ce][2]!==!0)e._stack.push(Xh),e.interruptible=!1},[Yn](e,t,n){n??=Ke(e);let r=this[ce][1](n);return r?V(r,(o)=>n):n},[to](e,t,n){n??=$n(e);let r=this[ce][1](n);return r?V(OK(n,r),(o)=>n):n}}),vn=p(2,Xs),JO=p(2,(e,t)=>vn(e,(n)=>t)),Kb=p(3,(e,t,n)=>vn(e,(r)=>{if(!t(r))return Ee;return n(r)})),Gb=p(3,(e,t,n)=>vn(e,(r)=>{let o=t(r);return Se(o)?Ee:n(o.success,r)})),Jb=p(2,(e,t)=>Gb(e,fd,t)),QO=p(3,(e,t,n)=>Kb(e,(r)=>{if(r._tag!=="Failure")return!1;return t(r.cause)},(r)=>n(r.cause))),Qb=p(3,(e,t,n)=>vn(e,(r)=>{if(r._tag!=="Failure")return Ee;let o=t(r.cause);return Se(o)?Ee:n(o.success,r.cause)})),ZO=p(2,(e,t)=>Qb(Mh,t)(e)),Yb=p(2,(e,t)=>me(()=>{let n=qu(Nr(t)),r=Number.isFinite(n),o=cw(!1),s=0,i=!1,a,c=V(o.await,()=>a);return[le((u)=>{let l=u.getRef(ni),f=r?l.currentTimeMillisUnsafe():0;if(i||f<s)return a??c;return i=!0,o.closeUnsafe(),a=void 0,vn(e,(d)=>me(()=>{i=!1,s=l.currentTimeMillisUnsafe()+n,a=d,o.openUnsafe()}))}),me(()=>{s=0,o.closeUnsafe(),a=void 0})]})),Xb=p(2,(e,t)=>We(Yb(e,t),(n)=>n[0])),eP=le((e)=>Ge(pc(e.id))),tP=no({op:"SetInterruptible",[Wi](e){if(e.interruptible=this[ce],e._interruptedCause&&e.interruptible)return()=>Ge(e._interruptedCause)}}),Xh=tP(!0),FK=tP(!1),oP=We(xd(me(()=>new AbortController),(e)=>me(()=>e.abort())),(e)=>e.signal),tw=p((e)=>ns(e[0])&&!de(e[0]),(e,t,n)=>We(Ur(e,(r,o)=>na(t(r,o)),n),(r)=>LE(r,L))),sP=p(3,(e,t,n)=>{let r=on(e);if(r.length===0)return me(t);return ue(()=>{let o=0,s=t();return We(is({while:()=>o<r.length,body:()=>n(s,r[o],o),step(i){s=i,o++}}),()=>s)})}),iP=p((e)=>ns(e[0])&&!de(e[0]),(e,t,n)=>V(tw(e,t,{concurrency:n?.concurrency}),([r,o])=>{if(ac(r))return ft(r);return n?.discard?Ee:W(o)})),aP=p((e)=>ns(e[0])&&!de(e[0]),(e,t)=>ue(()=>{let n=e[Symbol.iterator](),r=n.next();if(!r.done)return cP(n,0,t,r.value);return W(P())})),uP=p((e)=>ns(e[0])&&!de(e[0]),(e,t)=>ue(()=>{let n=e[Symbol.iterator](),r=n.next();if(!r.done)return lP(n,0,t,r.value);return W(P())})),is=no({op:"While",[Yn](e,t){if(this[ce].step(e),this[ce].while())return t._stack.push(this),this[ce].body();return or},[Rt](e){if(this[ce].while())return e._stack.push(this),this[ce].body();return or}}),Ur=p((e)=>typeof e[1]==="function",(e,t,n)=>ue(()=>{let r=n?.concurrency??1,o=r==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,r);if(o===1)return MK(e,t,n);let s=on(e),i=s.length;if(i===0)return n?.discard?Ee:W([]);let a=n?.discard?void 0:Array(i),c=DK({f:t,out:a},s,{concurrency:o});return c?Hn(c,a):W(a)})),DK=dP({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag==="Failure")return n;else if(e.out)e.out[r]=n.value}}),nw=p(3,(e,t,n)=>V(e,(r)=>t(r)?W(r):n(r))),rw=p(3,(e,t,n)=>V(e,(r)=>{let o=t(r);return Se(o)?n(o.failure):W(o.success)})),pP=p((e)=>de(e[0]),(e,t,n)=>rw(e,t,n?(r)=>ft(n(r)):()=>ft(new os))),mP=p((e)=>ns(e[0])&&!de(e[0]),(e,t,n)=>ue(()=>{let r=[];return Hn(Ur(e,(o,s)=>{let i=t(o,s);if(typeof i==="boolean"){if(i)r.push(o);return Ee}return We(i,(a)=>{if(a)r.push(o)})},{discard:!0,concurrency:n?.concurrency}),r)})),hP=p((e)=>ns(e[0])&&!de(e[0]),(e,t)=>ue(()=>{let n=[];for(let r of e){let o=t(r);if(rn(o))n.push(o.success)}return W(n)})),gP=p((e)=>ns(e[0])&&!de(e[0]),(e,t,n)=>ue(()=>{let r=[];return Hn(Ur(e,(o)=>We(t(o),(s)=>{if(rn(s))r.push(s.success)}),{discard:!0,concurrency:n?.concurrency}),r)})),xP=W({}),yP=Du(We),SP=Nu(We,V),EP=Mu(We),bP=p((e)=>de(e[0]),(e,t)=>le((n)=>(QK(),W(xc(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),wP=p((e)=>de(e[0]),(e,t)=>le((n)=>W(xc(n,e,t?.startImmediately,!0,t?.uninterruptible)))),ow=p((e)=>de(e[0]),(e,t,n)=>le((r)=>{let o=xc(r,e,n?.startImmediately,!0,n?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed"){let s={};td(t,s,()=>W_((a)=>a===o.id?Ee:Bh(o))),o.addObserver(()=>qb(t,s))}else o.interruptUnsafe(r.id,Uh(r));return W(o)})),CP=p((e)=>de(e[0]),(e,t)=>V(gd,(n)=>ow(e,n,t))),vP=p(2,(e,t)=>{if(e._exit)return e;else if(t.state._tag==="Closed")return e.interruptUnsafe(e.id),e;let n={};return td(t,n,()=>Bh(e)),e.addObserver(()=>qb(t,n)),e}),IP=ti(Ln()),AP=sw(Ln()),TP=eg(Ln()),_P=iw(Ln()),OP=tg(Ln()),PP=aw(Ln()),E_=W(!0),b_=W(!1);FP=le((e)=>W(e.getRef(vh))),MP=p(2,(e,t)=>sr(e,vh,t)),DP=sr(Ih),NP=sr(Ju),ub=BigInt(0),NK={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:ub,endTime:ub,exit:or},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},BP=Xf,HP=ed,WP=p((e)=>de(e[0]),(e,t,n={})=>{let o=(Array.isArray(t)?t:[t]).map((s)=>({span:s,attributes:n}));return Zs(e,ed,(s)=>[...s,...o])}),lb=sr(kh),zP=p((e)=>de(e[0]),(e,...t)=>Zs(e,Xf,(n)=>{let r=t.length===1?{...n,...t[0]}:{...n};if(t.length===1)return r;else H(r,t[0],t[1]);return r})),KP=le((e)=>{let t=e.currentSpanLocal;return t?W(t):ft(new os)}),GP=vK(kh),ni=Te("effect/Clock",{defaultValue:()=>new JP});QP=BigInt(1e6),ZP=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==="function")return()=>e.bigint();if(typeof performance<"u"&&typeof performance.now==="function")return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let n=BigInt(Date.now())*QP;if(n>t)t=n;return t}}(),LK=function(){let e=BigInt(1e9),t;return()=>{let n=ZP(),r=BigInt(Date.now())*QP;if(t===void 0)t=r-n;else{let o=t+n;if((r>o?r-o:o-r)>e)t=r-n}return t+n}}(),YP=as((e)=>e.currentTimeMillis);ng=class ng extends Hs("TimeoutError"){[od]=od;constructor(e){super({message:e})}};lw=class lw extends Hs("IllegalArgumentError"){[sd]=sd;constructor(e){super({message:e})}};fw=class fw extends Hs("ExceededCapacityError"){[id]=id;constructor(e){super({message:e})}};rg=class rg extends Hs("AsyncFiberError"){[ad]=ad;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}};Ed=class Ed extends Hs("UnknownError"){[cd]=cd;constructor(e,t){super({message:t,cause:e})}};dw=Te("effect/Console/CurrentConsole",{defaultValue:()=>globalThis.console}),HK=xE(Mr,BK),oR=Vi(HK),pw=Te("effect/Loggers/CurrentLoggers",{defaultValue:()=>new Set([GK,JK])}),WK=Te("effect/Logger/LogToStderr",{defaultValue:Of}),qK={[jK]:{_Message:L,_Output:L},pipe(){return fe(this,arguments)}},dc={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},Vle={None:[],All:[],Trace:[dc.gray],Debug:[dc.blue],Info:[dc.green],Warn:[dc.yellow],Error:[dc.red],Fatal:[dc.bgBrightRed,dc.black]},GK=iR(({cause:e,date:t,fiber:n,logLevel:r,message:o})=>{let s=Array.isArray(o)?o.slice():[o];if(e.reasons.length>0)s.push($h(e));let i=t.getTime(),a=n.getRef(Th),c="";for(let d of a)c+=` ${VK(d,i)}`;let u=n.getRef(Qs);if(Object.keys(u).length>0)s.push(u);let l=n.getRef(dw);(n.getRef(WK)?l.error:l.log)(`[${KK(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...s)}),JK=iR(({cause:e,fiber:t,logLevel:n,message:r})=>{let o=t.getRef(ni),s=t.getRef(Qs),i=t.currentSpan;if(i===void 0||i._tag==="ExternalSpan")return;let a={};for(let[c,u]of Object.entries(s))H(a,c,u);if(a["effect.fiberId"]=t.id,a["effect.logLevel"]=n.toUpperCase(),e.reasons.length>0)a["effect.cause"]=$h(e);i.event(BA(Array.isArray(r)&&r.length===1?r[0]:r),o.currentTimeNanosUnsafe(),a)});mw=W(void 0),aR=p((e)=>de(e[0]),(e,t)=>Jb(e,(n)=>le((r)=>(ZK(r,n,t?.defectsOnly),Ee))))});var Et={};Qn(Et,{AsyncFiberError:()=>TG,AsyncFiberErrorTypeId:()=>IG,Done:()=>Id,DoneTypeId:()=>xG,ExceededCapacityError:()=>vG,ExceededCapacityErrorTypeId:()=>CG,IllegalArgumentError:()=>Ad,IllegalArgumentErrorTypeId:()=>bG,InterruptorStackTrace:()=>dR,NoSuchElementError:()=>gG,NoSuchElementErrorTypeId:()=>hG,ReasonTypeId:()=>XK,StackTrace:()=>fR,TimeoutError:()=>EG,TimeoutErrorTypeId:()=>yG,TypeId:()=>YK,UnknownError:()=>Ew,UnknownErrorTypeId:()=>_G,annotate:()=>PG,annotations:()=>FG,combine:()=>rG,die:()=>cR,done:()=>Vt,empty:()=>xw,fail:()=>yw,filterInterruptors:()=>dG,findDefect:()=>cG,findDie:()=>aG,findError:()=>lR,findErrorOption:()=>sG,findFail:()=>oG,findInterrupt:()=>lG,fromReasons:()=>Sc,hasDies:()=>iG,hasFails:()=>uR,hasInterrupts:()=>uG,hasInterruptsOnly:()=>vd,interrupt:()=>nG,interruptors:()=>fG,isAsyncFiberError:()=>AG,isCause:()=>hw,isDieReason:()=>eG,isDone:()=>og,isExceededCapacityError:()=>kG,isFailReason:()=>bd,isIllegalArgumentError:()=>wG,isInterruptReason:()=>tG,isNoSuchElementError:()=>mG,isReason:()=>gw,isTimeoutError:()=>SG,isUnknownError:()=>OG,makeDieReason:()=>kd,makeFailReason:()=>wd,makeInterruptReason:()=>Cd,map:()=>ri,pretty:()=>Sw,prettyErrors:()=>pG,reasonAnnotations:()=>RG,squash:()=>rl});var YK,XK,hw,gw,bd,eG,tG,Sc,xw,yw,cR,nG,wd=(e)=>new Ou(e),kd=(e)=>new Xm(e),Cd,vd,ri,rG,rl,uR,oG,lR,sG,iG,aG,cG,uG,lG,fG,dG,pG,Sw,mG,hG,gG,og,xG,Id,Vt,yG,SG,EG,bG,wG,Ad,kG,CG,vG,IG,AG,TG,_G,OG,Ew,PG,RG,FG,fR,dR;var In=v(()=>{rt();pt();At();YK=Au,XK=Tu,hw=_u,gw=VA,bd=ji,eG=Xa,tG=ec,Sc=Ls,xw=Ym,yw=Lf,cR=fE,nG=pc,Cd=w_,vd=A_,ri=O_,rG=Dh,rl=Nh,uR=db,oG=pb,lR=ao,sG=k_,iG=Rh,aG=C_,cG=ud,uG=Fh,lG=v_,fG=I_,dG=Mh,pG=mb,Sw=$h,mG=th,hG=Nf,gG=os,og=Hf,xG=Za,Id=Ru,Vt=JA,yG=od,SG=XP,EG=ng,bG=sd,wG=eR,Ad=lw,kG=tR,CG=id,vG=fw,IG=ad,AG=nR,TG=rg,_G=cd,OG=rR,Ew=Ed,PG=Pu,RG=T_,FG=__;fR=class fR extends Ye()("effect/Cause/StackTrace"){};dR=class dR extends Ye()("effect/Cause/InterruptorStackTrace"){}});var pn={};Qn(pn,{asVoid:()=>GG,asVoidAll:()=>JG,die:()=>pR,fail:()=>uo,failCause:()=>Hr,filterCause:()=>HG,filterFailure:()=>BG,filterSuccess:()=>UG,filterValue:()=>LG,findDefect:()=>jG,findError:()=>WG,findErrorOption:()=>YG,getCause:()=>ZG,getSuccess:()=>QG,hasDies:()=>NG,hasFails:()=>DG,hasInterrupts:()=>$G,interrupt:()=>MG,isExit:()=>bw,isFailure:()=>ol,isSuccess:()=>Kt,map:()=>zG,mapBoth:()=>KG,mapError:()=>VG,match:()=>qG,succeed:()=>co,void:()=>Wr});var bw,co,Hr,uo,pR,MG,Wr,Kt,ol,DG,NG,$G,UG,LG,BG,HG,WG,jG,qG,zG,VG,KG,GG,JG,QG,ZG,YG;var jr=v(()=>{pt();At();bw=lE,co=Ke,Hr=$n,uo=ro,pR=Oo,MG=qh,Wr=or,Kt=ia,ol=vb,DG=lO,NG=uO,$G=cO,UG=oO,LG=sO,BG=iO,HG=fd,WG=Ib,jG=aO,qG=dO,zG=Ab,VG=Tb,KG=_b,GG=pO,JG=Ob,QG=mO,ZG=hO,YG=gO});var XG="~effect/Deferred",e4,sg=()=>{let e=Object.create(e4);return e.resumes=void 0,e.effect=void 0,e},Ec=(e)=>an((t)=>{if(e.effect)return t(e.effect);return e.resumes??=[],e.resumes.push(t),me(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);if(r>=0)n.splice(r,1)})}),t4,mR,ww=(e)=>me(()=>n4(e)),n4=(e)=>e.effect!==void 0,kw=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let r=0;r<n.length;r++)n[r](t)}return!0};var Cw=v(()=>{ne();At();ct();e4={[XG]:{_A:L,_E:L},pipe(){return fe(this,arguments)}},t4=p(2,(e,t)=>me(()=>kw(e,t))),mR=t4});var gR,xR,yR;var vw=v(()=>{nb();gR=Qs,xR=Th,yR=Ah});var Td,sl,_d,ig,Od,ua,qr;var Pd=v(()=>{At();Td=ca,sl=hd,_d=GO,ig=Do,Od=KO,ua=VO,qr=jb});var bR="~effect/Layer",SR="~effect/Layer/MemoMap",o4=(e,t)=>(e.observers++,Mo(Do(t,(n)=>e.finalizer(n)),e.effect)),wR=(e)=>D(e,bR),s4,kR=(e)=>{let t=Object.create(s4);return t.build=e,t},Iw=(e)=>kR((t,n)=>{let r=ua(n);return vn(e(t,r),(o)=>o._tag==="Failure"?qr(r,o):Ee)}),i4=(e)=>{let t=Iw((n,r)=>n.getOrElseMemoize(t,r,e));return t},a4=(e,t,n,r)=>{let o=sl(),s=sg(),i={observers:1,effect:Ec(s),finalizer:(a)=>ue(()=>{if(i.observers--,i.observers===0)return e.map.delete(t),qr(o,a);return Ee})};return e.map.set(t,i),Do(n,i.finalizer).pipe(V(()=>r(e,o)),vn((a)=>(i.effect=a,mR(s,a))))},Aw,Tw=()=>new Aw,c4=(e)=>new Aw(e),Rd,_w,CR,la=function(){if(arguments.length===1)return(e)=>cg(Ks(arguments[0],e));return cg(Ks(arguments[0],arguments[1]))},cg=(e)=>kR(_t(W(e))),il=function(){if(arguments.length===1)return(e)=>ER(arguments[0],e);return ER(arguments[0],arguments[1])},ER=(e,t)=>u4(We(t,(n)=>Ks(e,n))),u4=(e)=>i4((t,n)=>_d(e,n)),vR=(e,t,n)=>{let r=ua(n,"parallel");return Ur(e,(o)=>o.build(t,ua(r,"sequential")),{concurrency:e.length}).pipe(We((o)=>bT(...o)))},ug=(...e)=>Iw((t,n)=>vR(e,t,n)),IR=(e,t,n)=>Iw((r,o)=>V(Array.isArray(t)?vR(t,r,o):t.build(r,o),(s)=>e.build(r,o).pipe(Ys(s),We((i)=>n(i,s))))),AR,TR;var cs=v(()=>{rt();Cw();ne();pt();At();ct();ge();Pd();s4={[bR]:{_ROut:L,_E:L,_RIn:L},pipe(){return fe(this,arguments)}};Aw=class Aw{get[SR](){return SR}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);if(n)return o4(n,t);return this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return ue(()=>{let r=this.get(e,t);if(r)return r;return a4(this,e,t,n)})}};Rd=class Rd extends Ye()("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=fh(e,Rd);return t?c4(t):Tw()}};_w=p(3,(e,t,n)=>sr(We(e.build(t,n),Cn(Rd,t)),Rd,t)),CR=p(2,(e,t)=>le((n)=>_w(e,Rd.forkOrCreate(n.context),t))),AR=p(2,(e,t)=>IR(e,t,L)),TR=p(2,(e,t)=>IR(e,t,(n,r)=>ic(r,n)))});var _R="~effect/ExecutionPlan",l4,f4=(e)=>{let t=Object.create(l4);return t.steps=e,t},OR;var PR=v(()=>{rt();ne();At();cs();ct();l4={[_R]:_R,get captureRequirements(){let e=this;return aa((t)=>W(f4(e.steps.map((n)=>({...n,provide:wR(n.provide)?AR(n.provide,cg(t)):n.provide})))))},pipe(){return fe(this,arguments)}},OR=Te("effect/ExecutionPlan/CurrentMetadata",{defaultValue:_t({attempt:0,stepIndex:0})})});var lg="~effect/time/DateTime",fg="~effect/time/DateTime/TimeZone",FR,x4,y4,MR,S4,E4,us=(e,t,n)=>{let r=Object.create(y4);return r.epochMilliseconds=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},al=(e)=>D(e,lg),wc=(e)=>D(e,fg),DR=(e)=>wc(e)&&e._tag==="Offset",NR=(e)=>wc(e)&&e._tag==="Named",$R=(e)=>e._tag==="Utc",Rw=(e)=>e._tag==="Zoned",UR,LR,BR=(e)=>{let t=Object.create(x4);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},bc=(e)=>{let t=e.getTime();if(Number.isNaN(t))throw new Ad("Invalid date");return BR(t)},Fw=(e)=>{if(al(e))return e;else if(e instanceof Date)return bc(e);else if(typeof e==="object"){if("epochMilliseconds"in e)return bc(new Date(e.epochMilliseconds));let t=new Date(0);return T4(t,e),bc(t)}else if(typeof e==="string"&&!b4(e))return bc(new Date(e+"Z"));return bc(new Date(e))},b4=(e)=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),w4=-8639999956800000,k4=8639999949600000,Mw=(e,t)=>{let n=t?.timeZone;if(n===void 0&&al(e)&&Rw(e))return e;let r=Fw(e);if(r.epochMilliseconds<w4||r.epochMilliseconds>k4)throw RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);if(n===void 0&&typeof e==="object"&&"timeZoneId"in e)n=e.timeZoneId;let o;if(n===void 0){let s=new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1000;o=Dd(s)}else if(wc(n))o=n;else if(typeof n==="number")o=Dd(n);else{let s=$w(n);if(he(s))throw new Ad(`Invalid time zone: ${n}`);o=s.value}if(t?.adjustForTimeZone!==!0)return us(r.epochMilliseconds,o,r.partsUtc);return _4(r.epochMilliseconds,o,t?.disambiguation??"compatible")},Ow,HR,C4,WR=(e)=>{let t=C4.exec(e);if(t===null){let o=Hw(e);return o!==null?Ow(e,{timeZone:o}):P()}let[,n,r]=t;return Ow(n,{timeZone:r})},jR=(e)=>BR(e.epochMilliseconds),Md,v4,I4=(e)=>{let t=e.resolvedOptions().timeZone;if(Md.has(t))return Md.get(t);let n=Object.create(S4);return n.id=t,n.format=e,Md.set(t,n),n},Dw=(e)=>{if(Md.has(e))return Md.get(e);try{return I4(new Intl.DateTimeFormat("en-US",{...v4,timeZone:e}))}catch{throw new Ad(`Invalid time zone: ${e}`)}},Dd=(e)=>{let t=Object.create(E4);return t.offset=e,t},Nw,A4,$w=(e)=>{if(A4.test(e)){let t=Hw(e);return t===null?P():F(Dd(t))}return Nw(e)},qR=(e)=>{if(e._tag==="Offset")return Lw(e.offset);return e.id},Nd=(e)=>new Date(e.epochMilliseconds),dg=(e)=>{if(e._tag==="Utc")return new Date(e.epochMilliseconds);else if(e.zone._tag==="Offset")return new Date(e.epochMilliseconds+e.zone.offset);else if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter((r)=>r.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.adjustedEpochMilliseconds=n.getTime(),n},Uw=(e)=>dg(e).getTime()-Bw(e),Lw=(e)=>{let t=Math.abs(e),n=Math.floor(t/3600000),r=Math.round(t%3600000/60000);if(r===60)n+=1,r=0;return`${e<0?"-":"+"}${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`},zR=(e)=>Lw(Uw(e)),Bw=(e)=>e.epochMilliseconds,T4=(e,t)=>{if(t.year!==void 0)e.setUTCFullYear(t.year);if(t.month!==void 0)e.setUTCMonth(t.month-1);if(t.day!==void 0)e.setUTCDate(t.day);if(t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}if(t.hour!==void 0)e.setUTCHours(t.hour);if(t.minute!==void 0)e.setUTCMinutes(t.minute);if(t.second!==void 0)e.setUTCSeconds(t.second);if(t.millisecond!==void 0)e.setUTCMilliseconds(t.millisecond)},RR=86400000,_4=(e,t,n)=>{if(t._tag==="Offset")return us(e-t.offset,t);let r=Fd(e-RR,e,t),o=Fd(e+RR,e,t);if(r===o)return us(e-r,t);let s=r<o,i=r-o;if(s){if(Fd(e-o,e,t)===o)return us(e-o,t);let u=us(e-r,t),l=dg(u).getTime();if(e!==l)switch(n){case"reject":{let f=new Date(e).toISOString();throw RangeError(`Gap time: ${f} does not exist in time zone ${t.id}`)}case"earlier":return us(e-o,t);case"compatible":case"later":return u}return u}if(Fd(e-r,e,t)===r){if(n==="earlier"||n==="compatible")return us(e-r,t);if(Fd(e-r+i,e+i,t)===r)return us(e-r,t);if(n==="reject"){let u=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return us(e-o,t)},O4,Hw=(e)=>{let t=O4.exec(e);if(t===null)return null;let[,n,r,o]=t;return(n==="+"?1:-1)*(Number(r)*60+Number(o))*60*1000},Fd=(e,t,n)=>{let r=n.format.formatToParts(e).find((s)=>s.type==="timeZoneName")?.value??"";if(r==="GMT")return 0;let o=Hw(r);if(o===null)return Uw(us(t,n));return o},VR=(e)=>Nd(e).toISOString(),Pw=(e)=>{let t=dg(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${zR(e)}`},Ww=(e)=>e.zone._tag==="Offset"?Pw(e):`${Pw(e)}[${e.zone.id}]`;var KR=v(()=>{In();Pt();Ws();wn();pr();Me();rc();ct();ge();FR={[lg]:lg,pipe(){return fe(this,arguments)},[zt](){return this.toString()},toJSON(){return Nd(this).toJSON()}},x4={...FR,_tag:"Utc",[_e](){return dr(this.epochMilliseconds)},[Oe](e){return al(e)&&e._tag==="Utc"&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Nd(this).toJSON()})`}},y4={...FR,_tag:"Zoned",[_e](){return Ot(dr(this.epochMilliseconds))(ie(this.zone))},[Oe](e){return al(e)&&e._tag==="Zoned"&&this.epochMilliseconds===e.epochMilliseconds&&ee(this.zone,e.zone)},toString(){return`DateTime.Zoned(${Ww(this)})`}},MR={[fg]:fg,[zt](){return this.toString()}},S4={...MR,_tag:"Named",[_e](){return Ze(`Named:${this.id}`)},[Oe](e){return wc(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},E4={...MR,_tag:"Offset",[_e](){return Ze(`Offset:${this.offset}`)},[Oe](e){return wc(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${Lw(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},UR=dn((e,t)=>e.epochMilliseconds===t.epochMilliseconds),LR=qs((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:e.epochMilliseconds>t.epochMilliseconds?1:0),Ow=Ki(Mw),HR=Ki(Fw),C4=/^(.{17,35})\[(.+)\]$/,Md=new Map,v4={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},Nw=Ki(Dw),A4=/^(?:GMT|[+-])/,O4=/([+-])(\d{2}):(\d{2})$/});function R4(e,t){let[n,r]=GR(e),[o,s]=GR(t),i=Math.min(r,s),a=n*BigInt(10)**BigInt(r-i),c=o*BigInt(10)**BigInt(s-i),u=a%c;if(u===BigInt(0))return e<0||Object.is(e,-0)?-0:0;let l=globalThis.Number(`${u}e${i}`);return l===0?Math.sign(e)*globalThis.Number.MIN_VALUE:l}function GR(e){let t=Math.abs(e).toExponential(),n=t.indexOf("e"),r=t.slice(0,n).replace(".","");return[BigInt(r)*(e<0?-BigInt(1):BigInt(1)),globalThis.Number(t.slice(n+1))-r.length+1]}var afe,JR,QR,ZR,YR;var pg=v(()=>{ne();afe=globalThis.Number,JR=p(2,(e,t)=>{let n=e.toString(),r=t.toString();if(n.includes("e")||r.includes("e")){if(!globalThis.Number.isFinite(e)||!globalThis.Number.isFinite(t)||t===0)return NaN;return R4(e,t)}let o=(n.split(".")[1]||"").length,s=(r.split(".")[1]||"").length,i=o>s?o:s,a=parseInt(e.toFixed(i).replace(".","")),c=parseInt(t.toFixed(i).replace(".",""));return a%c/Math.pow(10,i)});QR=p(2,(e,t)=>{let n=Math.pow(10,t);return Math.round(e*n)/n}),ZR=oo((e,t)=>Math.max(e,t),-1/0),YR=oo((e,t)=>Math.min(e,t),1/0)});var cfe,e1=(e)=>e.trim(),t1=13,n1=10,r1,F4=(e)=>{let t=e.charCodeAt(0);return t===t1||t===n1},M4=(e,t)=>e.charCodeAt(0)===t1&&t.charCodeAt(0)===n1;var o1=v(()=>{cfe=globalThis.String;r1=class r1{index;length;s;stripped;constructor(e,t=!1){this.s=e,this.stripped=t,this.index=0,this.length=e.length}next(){if(this.done)return{done:!0,value:void 0};let e=this.index;while(!this.done&&!F4(this.s[this.index]))this.index=this.index+1;let t=this.index;if(!this.done){let n=this.s[this.index];if(this.index=this.index+1,!this.done&&M4(n,this.s[this.index]))this.index=this.index+1;if(!this.stripped)t=this.index}return{done:!1,value:this.s.substring(e,t)}}[Symbol.iterator](){return new r1(this.s,this.stripped)}get done(){return this.index>=this.length}}});var zr,$d=(e)=>e.reasons.some(jw),jw=(e)=>e._tag==="Fail"&&og(e.error),mg=(e)=>{let t,n=!1;for(let r of e.reasons)if(jw(r))t??=r.error;else if(r._tag!=="Interrupt")n=!0;if(t===void 0)return oe(e);return n?oe(Sc(e.reasons.filter((r)=>!jw(r)))):J(t)},N4=(e)=>{let t=mg(e);return Se(t)?t:J(t.success.value)},qw=(e)=>{let t=mg(e);return!Se(t)?co(t.success.value):Hr(t.failure)},hg;var kc=v(()=>{In();jr();ne();At();Bn();zr=p(2,(e,t)=>nl(e,N4,(n)=>t(n))),hg=p(2,(e,t)=>Fo(e,{onSuccess:t.onSuccess,onFailure:(n)=>{let r=mg(n);return!Se(r)?t.onDone(r.success.value):t.onFailure(r.failure)}}))});var s1="~effect/Schedule",Cc,$4,zw=(e)=>D(e,s1),Vw=(e)=>{let t=Object.create($4);return t.step=e,t},Kw=()=>{let e=0,t,n;return(r,o)=>{if(n===void 0)n=r;let s=r-n,i=t===void 0?0:r-t;return t=r,{input:o,attempt:++e,start:n,now:r,elapsed:s,elapsedSincePrevious:i}}},U4=(e)=>Vw(We(e,(t)=>{let n=Kw();return(r,o)=>t(n(r,o))})),Gw=(e)=>Lr(e.step,(t)=>W(()=>Ge(t))),gg=(e)=>as((t)=>We(Gw(e),(n)=>{let r=Kw();return(o)=>ue(()=>{let s=t.currentTimeMillisUnsafe();return V(n(s,o),([i,a])=>{let c=r(s,o);return c.output=i,c.duration=a,Hn(yc(a),c)})})})),Jw=(e)=>Vw(We(Gw(e),(t)=>(n,r)=>hg(t(n,r),{onSuccess:(o)=>W([r,o[1]]),onFailure:Ge,onDone:()=>Vt(r)}))),i1=(e)=>Ud(Qw,({attempt:t})=>W(t<=e)),L4=(e)=>{let t=Nr(e);return U4(W((n)=>W([n.attempt-1,t])))},Ud,Qw;var Zw=v(()=>{In();rt();Yi();ne();pt();At();ct();ge();kc();Cc=Te("effect/Schedule/CurrentMetadata",{defaultValue:_t({input:void 0,output:void 0,duration:ju,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),$4={[s1]:{_Out:L,_In:L,_Env:L},pipe(){return fe(this,arguments)}},Ud=p(2,(e,t)=>Vw(We(Gw(e),(n)=>{let r=Kw();return(o,s)=>V(n(o,s),(i)=>{let[a,c]=i,u=t({...r(o,s),output:a,duration:c});return V(de(u)?u:W(u),(l)=>l?W(i):Vt(a))})}))),Qw=L4(ju)});var B4=(e,t,n)=>Yh((r)=>V(n?.local?_w(t,Tw(),r):CR(t,r),(o)=>Ys(e,o))),xg;var Yw=v(()=>{rt();ne();cs();pt();At();xg=p((e)=>de(e[0]),(e,t,n)=>AE(t)?Ys(e,t):B4(e,Array.isArray(t)?ug(...t):t,n))});var Xw,ek,u1,Ld,l1,H4,Bd=(e)=>{let t=e.schedule?Jw(e.schedule):H4;if(e.while)t=Ud(t,({input:n})=>{let r=e.while(n);return de(r)?r:W(r)});if(e.until)t=Ud(t,({input:n})=>{let r=e.until(n);return de(r)?We(r,(o)=>!o):W(!r)});if(e.times!==void 0)t=Ud(t,({attempt:n})=>W(n<=e.times));return t};var tk=v(()=>{ne();Me();kc();Zw();Ja();pt();At();Xw=p(3,(e,t,n)=>V(gg(t),(r)=>{let o=Cc.defaultValue();return Br(Vh(hc(V(ue(()=>sr(e,Cc,o)),r),(s)=>me(()=>{o=s})),{disableYield:!0}),(s)=>Hf(s)?W(s.value):n(s,o.attempt===0?P():F(o)))})),ek=p(3,(e,t,n)=>V(gg(t),(r)=>{let o=Cc.defaultValue(),s,i=Br(ue(()=>sr(e,Cc,o)),(a)=>(s=a,V(r(a),(c)=>(o=c,i))));return zr(i,(a)=>Fe(()=>n(s,a)))})),u1=p(2,(e,t)=>{let n=typeof t==="function"?t(L):zw(t)?t:Bd(t);return Xw(e,n,ft)}),Ld=p(2,(e,t)=>{let n=typeof t==="function"?t(L):zw(t)?t:Bd(t);return ek(e,n,ft)}),l1=p(3,(e,t,n)=>V(gg(n),(r)=>{let o=Cc.defaultValue(),s=ue(()=>sr(e,Cc,o));return Br(V(r(t),(i)=>{o=i;let a=_t(V(s,r));return is({while:Fr,body:a,step(c){o=c}})}),(i)=>Hf(i)?W(i.value):ft(i))})),H4=Jw(Qw)});var W4=(e,t)=>{let n=-1,r=0,o=(s)=>Jh(e(s));return{begin:as((s)=>ue(()=>{let i=t();if(i.stepIndex!==n)n=i.stepIndex,r=0;r++;let a={attempt:i.attempt,stepAttempt:r,stepIndex:i.stepIndex,startNanos:s.monotonicTimeNanosUnsafe()};return Hn(o({_tag:"AttemptStart",attempt:a.attempt,stepAttempt:a.stepAttempt,stepIndex:a.stepIndex}),a)})),end:(s,i)=>as((a)=>{let c=io(a.monotonicTimeNanosUnsafe()-s.startNanos);return o(i._tag==="Success"?{_tag:"AttemptSuccess",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c}:{_tag:"AttemptFailure",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c,cause:i.cause})})}},p1,d1=(e,t)=>{if(!t)return Bd({schedule:e.schedule?e.schedule:e.attempts?void 0:j4,times:e.attempts,while:e.while});else if(e.attempts===1||!(e.schedule||e.attempts))return;return Bd({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})},j4;var m1=v(()=>{Yi();PR();ne();Bn();Zw();pt();At();Yw();tk();p1=p((e)=>de(e[0]),(e,t,n)=>ue(()=>{let r=0,o={attempt:0,stepIndex:0},s=zh(OR,me(()=>(o={attempt:o.attempt+1,stepIndex:r},o))),i=n?.onEvent===void 0?void 0:W4(n.onEvent,()=>o),a=i===void 0?L:(u)=>No((l)=>V(i.begin,(f)=>vn(l(u),(d)=>i.end(f,d)))),c;return V(is({while:()=>r<t.steps.length&&(c===void 0||Se(c)),body(){let u=t.steps[r],l=s(a(xg(e,u.provide)));if(c){let f=!1,d=l;l=ue(()=>{if(f)return d;return f=!0,Yu(c)}),l=Ld(l,d1(u,!1))}else{let f=d1(u,!0);l=f?Ld(l,f):l}return na(l)},step(u){c=u,r++}}),()=>Yu(c))})),j4=i1(1)});var z4="~effect/Request",V4,Cfe,h1=(e)=>e;var g1=v(()=>{Pt();pt();V4=aE({_E:(e)=>e,_A:(e)=>e,_R:(e)=>e}),Cfe={...zA,[z4]:V4}});function x1(e){if(!e.map.has(e.key))return Ee;return e.map.delete(e.key),e.run}var y1,S1=(e,t)=>{let n=E1(t.resolver,e,t.onExit,{context:t.context,currentScheduler:tr(t.context,Zf)});return()=>b1(t.resolver,n)},yg,nk,E1=(e,t,n,r)=>{let o=nk.get(e);if(!o)o=new Map,nk.set(e,o);let s,i=!1,a=h1({request:t,context:r.context,uninterruptible:!1,completeUnsafe(u){if(i)return;i=!0,n(u),s?.entrySet.delete(a)}});if(e.preCheck!==void 0&&!e.preCheck(a))return a;let c=e.batchKey(a);if(s=o.get(c),!s){if(yg.length>0)s=yg.pop(),s.key=c,s.resolver=e,s.map=o;else{let u={key:c,resolver:e,map:o,entrySet:new Set,entries:new Set,delayEffect:V(ue(()=>u.resolver.delay),(l)=>x1(u)),run:vn(ue(()=>u.resolver.runAll(Array.from(u.entries),u.key)),(l)=>{for(let f of u.entrySet)f.completeUnsafe(l._tag==="Success"?Oo(Error("Effect.request: RequestResolver did not complete request",{cause:f.request})):l);if(u.entries.clear(),yg.length<128)u.entrySet.clear(),u.key=void 0,u.fiber=void 0,u.resolver=void 0,u.map=void 0,yg.push(u);return Ee})};s=u}o.set(c,s),s.fiber=ti(r.context)(s.delayEffect,{scheduler:r.currentScheduler})}if(s.entrySet.add(a),s.entries.add(a),s.resolver.collectWhile(s.entries))return a;return s.fiber.interruptUnsafe(r.id),s.fiber=ti(r.context)(x1(s),{scheduler:r.currentScheduler}),a},b1=(e,t)=>{if(t.uninterruptible)return;let n=nk.get(e);if(!n)return;let r=e.batchKey(t),o=n.get(r);if(!o)return;if(o.entries.delete(t),o.entrySet.delete(t),o.entries.size===0)n.delete(r),o.fiber?.interruptUnsafe()},K4=(e,t)=>me(()=>b1(e,t));var w1=v(()=>{rt();ne();g1();yh();pt();At();y1=p(2,(e,t)=>{let n=(r)=>an((o)=>{let s=E1(r,e,o,oa());return K4(r,s)});return de(t)?V(t,n):n(t)}),yg=[],nk=new WeakMap});function eJ(e,t){let n=`${e.type}:${e.id}`;if(Ve(e.description))n+=`:${e.description}`;if(Ve(t))n+=`:${tJ(t)}`;return n}function tJ(e){return JSON.stringify(Array.isArray(e)?e:Object.entries(e))}function nJ(e,t){return{...rk(e),...rk(t)}}function rk(e){if(Ve(e)&&Array.isArray(e))return e.reduce((t,[n,r])=>(H(t,n,r),t),{});return e}var J4="effect/Metric/CurrentMetricAttributes",Q4,Z4="~effect/observability/Metric/MetricRegistryKey",Y4,k1="~effect/observability/Metric",X4,ul;var C1=v(()=>{rt();ne();At();ct();ge();Q4=Te(J4,{defaultValue:()=>({})}),Y4=Te(Z4,{defaultValue:()=>new Map});X4=class X4{[k1]=k1;#t=new WeakMap;#e;id;description;attributes;constructor(e,t,n){this.id=e,this.description=t,this.attributes=n}valueUnsafe(e){return this.hook(e).get(e)}modifyUnsafe(e,t){return this.hook(t).modify(e,t)}updateUnsafe(e,t){return this.hook(t).update(e,t)}hook(e){let t=tr(e,Q4);if(Object.keys(t).length===0){if(Ve(this.#e))return this.#e.hooks;return this.#e=this.getOrCreate(e,this.attributes),this.#e.hooks}let n=nJ(this.attributes,t),r=this.#t.get(n);if(Ve(r))return r.hooks;return r=this.getOrCreate(e,n),this.#t.set(n,r),r.hooks}getOrCreate(e,t){let n=eJ(this,t),r=tr(e,Y4);if(r.has(n))return r.get(n);let o=this.createHooks(),s={id:this.id,type:this.type,description:this.description,attributes:rk(t),hooks:o};return r.set(n,s),s}pipe(){return fe(this,arguments)}};ul=p(2,(e,t)=>aa((n)=>me(()=>e.updateUnsafe(t,n))))});var B={};Qn(B,{Do:()=>dJ,Transaction:()=>Hd,TypeId:()=>oJ,abortSignal:()=>S6,acquireDisposable:()=>u6,acquireRelease:()=>po,acquireUseRelease:()=>U1,addFinalizer:()=>Ig,all:()=>I1,andThen:()=>Vr,annotateCurrentSpan:()=>O6,annotateLogs:()=>a5,annotateLogsScoped:()=>c5,annotateSpans:()=>_6,as:()=>Kr,asSome:()=>_1,asVoid:()=>jd,awaitAllChildren:()=>q6,bind:()=>hJ,bindTo:()=>pJ,cached:()=>m6,cachedInvalidateWithTTL:()=>g6,cachedWithTTL:()=>h6,callback:()=>Wn,catch:()=>lo,catchCause:()=>Gr,catchCauseFilter:()=>TJ,catchCauseIf:()=>AJ,catchDefect:()=>uk,catchEager:()=>Zd,catchFilter:()=>qd,catchIf:()=>vJ,catchNoSuchElement:()=>IJ,catchReason:()=>wJ,catchReasons:()=>kJ,catchTag:()=>si,catchTags:()=>ck,clockWith:()=>Qd,context:()=>Cg,contextWith:()=>N1,currentParentSpan:()=>R6,currentSpan:()=>P6,delay:()=>F1,die:()=>ls,effectify:()=>mt,ensuring:()=>ml,eventually:()=>FJ,exit:()=>da,fail:()=>R,failCause:()=>dl,failCauseSync:()=>fa,failSync:()=>sk,fiber:()=>z6,fiberId:()=>V6,filter:()=>dk,filterMap:()=>KJ,filterMapEffect:()=>D1,filterMapOrElse:()=>JJ,filterMapOrFail:()=>ZJ,filterOrElse:()=>GJ,filterOrFail:()=>QJ,findFirst:()=>cJ,findFirstFilter:()=>uJ,firstSuccessOf:()=>HJ,flatMap:()=>se,flatMapEager:()=>An,flatten:()=>T1,flip:()=>bJ,fn:()=>X6,fnUntraced:()=>q,fnUntracedEager:()=>_g,forEach:()=>vc,forever:()=>ds,forkChild:()=>xk,forkDetach:()=>j6,forkIn:()=>xl,forkScoped:()=>yl,fromNullishOr:()=>SJ,fromOption:()=>xJ,fromResult:()=>ak,gen:()=>un,head:()=>lJ,ignore:()=>zd,ignoreCause:()=>$J,interrupt:()=>gl,interruptible:()=>x6,interruptibleMask:()=>y6,isEffect:()=>yr,isFailure:()=>r6,isSuccess:()=>o6,let:()=>mJ,linkSpans:()=>D6,log:()=>e5,logDebug:()=>o5,logError:()=>Tg,logFatal:()=>t5,logInfo:()=>r5,logTrace:()=>s5,logWarning:()=>n5,logWithLevel:()=>z1,makeSpan:()=>W1,makeSpanScoped:()=>N6,map:()=>ae,mapBoth:()=>_J,mapBothEager:()=>mn,mapEager:()=>ci,mapError:()=>Gt,mapErrorEager:()=>Tc,match:()=>pa,matchCause:()=>e6,matchCauseEager:()=>t6,matchCauseEffect:()=>pk,matchCauseEffectEager:()=>n6,matchEager:()=>XJ,matchEffect:()=>kg,never:()=>Sg,onError:()=>hl,onErrorFilter:()=>f6,onErrorIf:()=>l6,onExit:()=>ai,onExitFilter:()=>p6,onExitIf:()=>d6,onExitPrimitive:()=>L1,onInterrupt:()=>B1,option:()=>EJ,orDie:()=>fo,orElseSucceed:()=>BJ,partition:()=>sJ,promise:()=>A1,provide:()=>mk,provideContext:()=>ii,provideService:()=>fs,provideServiceEffect:()=>hk,race:()=>VJ,raceAll:()=>M1,raceAllFirst:()=>zJ,raceFirst:()=>Ac,reduce:()=>iJ,repeat:()=>E6,repeatOrElse:()=>b6,replicate:()=>w6,replicateEffect:()=>k6,request:()=>H6,requestUnsafe:()=>W6,result:()=>Eg,retry:()=>MJ,retryOrElse:()=>DJ,runCallback:()=>G6,runCallbackWith:()=>K6,runFork:()=>ps,runForkWith:()=>Jd,runPromise:()=>j1,runPromiseExit:()=>Ag,runPromiseExitWith:()=>J6,runPromiseWith:()=>q1,runSync:()=>Q6,runSyncExit:()=>ha,runSyncExitWith:()=>Y6,runSyncWith:()=>Z6,sandbox:()=>NJ,satisfiesErrorType:()=>b5,satisfiesServicesType:()=>w5,satisfiesSuccessType:()=>E5,schedule:()=>C6,scheduleFrom:()=>H1,scope:()=>Vd,scoped:()=>ma,scopedWith:()=>gk,service:()=>$1,serviceOption:()=>vg,setContext:()=>s6,sleep:()=>wg,spanAnnotations:()=>F6,spanLinks:()=>M6,succeed:()=>A,succeedNone:()=>Ic,succeedSome:()=>ok,suspend:()=>He,sync:()=>we,tap:()=>pl,tapCause:()=>bg,tapCauseFilter:()=>RJ,tapCauseIf:()=>PJ,tapDefect:()=>R1,tapError:()=>lk,tapErrorTag:()=>OJ,timed:()=>qJ,timeout:()=>WJ,timeoutOption:()=>jJ,timeoutOrElse:()=>fk,tracer:()=>v6,track:()=>l5,trackDefects:()=>p5,trackDuration:()=>m5,trackErrors:()=>d5,trackSuccesses:()=>f5,transposeOption:()=>yJ,try:()=>Xt,tryPromise:()=>fl,tx:()=>h5,txRetry:()=>S5,undefined:()=>fJ,uninterruptible:()=>Kd,uninterruptibleMask:()=>Gd,unwrapReason:()=>CJ,updateContext:()=>i6,updateService:()=>a6,updateServiceScoped:()=>c6,useSpan:()=>$6,validate:()=>aJ,void:()=>Pe,when:()=>YJ,whileLoop:()=>ll,withErrorReporting:()=>LJ,withExecutionPlan:()=>UJ,withFiber:()=>Wd,withLogSpan:()=>u5,withLogger:()=>i5,withParentSpan:()=>B6,withSpan:()=>U6,withSpanScoped:()=>L6,withTracer:()=>I6,withTracerEnabled:()=>A6,withTracerTiming:()=>T6,yieldNow:()=>ik,yieldNowWith:()=>gJ,zip:()=>O1,zipWith:()=>P1});function y5(e,t){for(let[n,{value:r}]of t.journal){if(r!==n.value)n.version=n.version+1,n.value=r;for(let o of n.pending.values())e.currentDispatcher.scheduleTask(o,0);n.pending.clear()}}function v1(e){e.retry=!1,e.journal.clear()}var oJ,yr,I1,sJ,iJ,aJ,cJ,uJ,vc,lJ,ll,A1,fl,A,Ic,ok,He,we,Pe,fJ,Wn,Sg,dJ,pJ,mJ,hJ,un,R,sk,dl,fa,ls,Xt,ik,gJ,Wd,ak,xJ,yJ,SJ,se,T1,Vr,pl,Eg,EJ,da,ae,Kr,_1,jd,bJ,O1,P1,lo,si,ck,wJ,kJ,CJ,Gr,uk,vJ,qd,IJ,AJ,TJ,Gt,_J,fo,lk,OJ,bg,PJ,RJ,R1,FJ,MJ,DJ,NJ,zd,$J,UJ,LJ,BJ,HJ,WJ,jJ,fk,F1,wg,qJ,M1,zJ,VJ,Ac,dk,KJ,D1,GJ,JJ,QJ,ZJ,YJ,pa,XJ,e6,t6,n6,pk,kg,r6,o6,Cg,N1,mk,ii,s6,$1,vg,i6,a6,c6,fs,hk,Vd,ma,gk,po,u6,U1,Ig,ml,hl,l6,f6,L1,ai,d6,p6,m6,h6,g6,gl,x6,B1,Kd,Gd,y6,S6,ds,E6,b6,w6,k6,C6,H1,v6,I6,A6,T6,_6,O6,P6,R6,F6,M6,D6,W1,N6,$6,U6,L6,B6,H6,W6,xk,xl,yl,j6,q6,z6,V6,ps,Jd,K6,G6,j1,q1,Ag,J6,Q6,Z6,ha,Y6,q,X6,Qd,z1,e5,t5,n5,Tg,r5,o5,s5,i5,a5,c5,u5,l5,f5,d5,p5,m5,Hd,h5=(e)=>Wd((t)=>{let n=fh(t.context,Hd);if(n)return e;n={journal:new Map,retry:!1};let r;return Gd((o)=>se(ll({while:()=>!r,body:_t(o(e).pipe(fs(Hd,n),bg(()=>{if(!n.retry)return Pe;return o(x5(n))}),da)),step(s){if(n.retry||!g5(n))return v1(n);if(Kt(s))y5(t,n);else v1(n);r=s}}),()=>r))}),g5=(e)=>{for(let[t,{version:n}]of e.journal)if(t.version!==n)return!1;return!0},x5=(e)=>He(()=>{let t={},n=Array.from(e.journal.keys()),r=()=>{for(let o of n)o.pending.delete(t)};return Wn((o)=>{let s=()=>{r(),o(Pe)};for(let i of n)i.pending.set(t,s);return we(r)})}),S5,mt=(e,t,n)=>(...r)=>Wn((o)=>{try{e(...r,(s,i)=>{if(s)o(R(t?t(s,r):s));else o(A(i))})}catch(s){o(n?R(n(s,r)):ls(s))}}),E5=()=>(e)=>e,b5=()=>(e)=>e,w5=()=>(e)=>e,ci,Tc,mn,An,Zd,_g;var Re=v(()=>{rt();Yi();jr();ne();pt();At();m1();Yw();w1();tk();C1();vw();Ja();oJ=rs,yr=de,I1=yd,sJ=tw,iJ=sP,aJ=iP,cJ=aP,uJ=uP,vc=Ur,lJ=fP,ll=is,A1=Sb,fl=H_,A=W,Ic=mc,ok=yb,He=ue,we=me,Pe=Ee,fJ=mw,Wn=an,Sg=Wh,dJ=xP,pJ=yP,mJ=EP,hJ=SP,un=z_,R=ft,sk=Hh,dl=Ge,fa=L_,ls=sa,Xt=B_,ik=Xu,gJ=xb,Wd=le,ak=Yu,xJ=gb,yJ=U_,SJ=$_,se=V,T1=X_,Vr=Mo,pl=hc,Eg=na,EJ=UO,da=md,ae=We,Kr=Hn,_1=el,jd=ld,bJ=G_,O1=bO,P1=Rb,lo=Br,si=Nb,ck=PO,wJ=RO,kJ=FO,CJ=MO,Gr=Lr,uk=IO,vJ=dd,qd=Gh,IJ=vO,AJ=Mb,TJ=nl,Gt=$b,_J=Ub,fo=Lb,lk=Db,OJ=_O,bg=AO,PJ=TO,RJ=Kh,R1=OO,FJ=Bb,MJ=Ld,DJ=ek,NJ=J_,zd=$O,$J=Jh,UJ=p1,LJ=aR,BJ=DO,HJ=NO,WJ=jO,jJ=qO,fk=Wb,F1=WO,wg=yc,qJ=zO,M1=kb,zJ=Cb,VJ=Q_,Ac=jh,dk=mP,KJ=hP,D1=gP,GJ=nw,JJ=rw,QJ=wO,ZJ=pP,YJ=kO,pa=Qh,XJ=pd,e6=Hb,t6=LO,n6=Z_,pk=Fo,kg=gc,r6=BO,o6=HO,Cg=Pb,N1=aa,mk=xg,ii=Ys,s6=EO,$1=xO,vg=yO,i6=tl,a6=Zs,c6=SO,fs=sr,hk=zh,Vd=gd,ma=zb,gk=Yh,po=xd,u6=YO,U1=Zb,Ig=Vb,ml=JO,hl=Jb,l6=QO,f6=Qb,L1=Xs,ai=vn,d6=Kb,p6=Gb,m6=XO,h6=Xb,g6=Yb,gl=eP,x6=ew,B1=ZO,Kd=ei,Gd=No,y6=rP,S6=oP,ds=Vh,E6=u1,b6=Xw,w6=Fb,k6=CO,C6=p(2,(e,t)=>H1(e,void 0,t)),H1=l1,v6=FP,I6=MP,A6=DP,T6=NP,_6=zP,O6=VP,P6=KP,R6=GP,F6=BP,M6=HP,D6=WP,W1=UP,N6=nd,$6=rd,U6=qP,L6=LP,B6=Zu,H6=y1,W6=S1,xk=bP,xl=ow,yl=CP,j6=wP,q6=kP,z6=j_,V6=q_,ps=IP,Jd=ti,K6=sw,G6=AP,j1=_P,q1=iw,Ag=TP,J6=eg,Q6=PP,Z6=aw,ha=OP,Y6=tg,q=bb,X6=V_,Qd=as,z1=$o,e5=$o(),t5=$o("Fatal"),n5=$o("Warn"),Tg=$o("Error"),r5=$o("Info"),o5=$o("Debug"),s5=$o("Trace"),i5=p(2,(e,t)=>Zs(e,pw,(n)=>new Set([...n,t]))),a5=p((e)=>yr(e[0]),(e,...t)=>Zs(e,gR,(n)=>{let r=t.length===1?{...n,...t[0]}:{...n};if(t.length===1)return r;else H(r,t[0],t[1]);return r})),c5=sR,u5=p(2,(e,t)=>V(YP,(n)=>Zs(e,xR,(r)=>[[t,n],...r]))),l5=p((e)=>yr(e[0]),(e,t,n)=>ai(e,(r)=>{let o=n===void 0?r:Fe(()=>n(r));return ul(t,o)})),f5=p((e)=>yr(e[0]),(e,t,n)=>pl(e,(r)=>{let o=n===void 0?r:n(r);return ul(t,o)})),d5=p((e)=>yr(e[0]),(e,t,n)=>lk(e,(r)=>{let o=n===void 0?r:Fe(()=>n(r));return ul(t,o)})),p5=p((e)=>yr(e[0]),(e,t,n)=>R1(e,(r)=>{let o=n===void 0?r:Fe(()=>n(r));return ul(t,o)})),m5=p((e)=>yr(e[0]),(e,t,n)=>Qd((r)=>{let o=r.monotonicTimeNanosUnsafe();return ai(e,()=>{let s=r.monotonicTimeNanosUnsafe(),i=jT(Nr(s),Nr(o)),a=n===void 0?i:Fe(()=>n(i));return ul(t,a)})}));Hd=class Hd extends Ye()("effect/Effect/Transaction"){};S5=se(Hd,(e)=>(e.retry=!0,gl)),ci=eO,Tc=tO,mn=nO,An=Y_,Zd=rO,_g=K_});var k5=(e,t)=>{if(Kt(e))return t(0);if(vd(e.cause))return t(130);return t(C5(rl(e.cause)))},V1=(e)=>p((t)=>yr(t[0]),(t,n)=>{let r=n?.disableErrorReporting===!0?ps(t):ps(bg(t,(s)=>{if(vd(s))return Pe;return v5(rl(s))?Tg(s):Pe}));try{let s=globalThis.setInterval(Ns,2147483647);r.addObserver(()=>{clearInterval(s)})}catch{}let o=n?.teardown??k5;return e({fiber:r,teardown:o})}),Og="~effect/Runtime/errorExitCode",C5=(e)=>{if(typeof e==="object"&&e!==null&&Og in e){let t=e[Og];if(typeof t==="number")return t}return 1},_c="~effect/Runtime/errorReported",v5=(e)=>{if(typeof e==="object"&&e!==null&&_c in e){let t=e[_c];if(typeof t==="boolean")return t}return!0};var Pg=v(()=>{In();Re();jr();ne()});var K1;var G1=v(()=>{Pg();K1=V1(({fiber:e,teardown:t})=>{let n=!1;e.addObserver((o)=>{process.removeListener("SIGINT",r),process.removeListener("SIGTERM",r),t(o,(s)=>{if(n||s!==0)process.exit(s)})});function r(){n=!0,e.interruptUnsafe(e.id)}process.on("SIGINT",r),process.on("SIGTERM",r)})});var Rg={};Qn(Rg,{runMain:()=>A5});var A5;var J1=v(()=>{G1();A5=K1});var Q1="~effect/platform/PlatformError",ui,Z1,Sk,mo=(e)=>new Sk(new Z1(e)),li=(e)=>new Sk(new ui(e));var ms=v(()=>{Vu();ui=class ui extends Xi("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}};Z1=class Z1 extends zE{get message(){return`${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor!==void 0?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}};Sk=class Sk extends Xi("PlatformError"){constructor(e){if("cause"in e)super({reason:e,cause:e.cause});else super({reason:e})}[Q1]=Q1;get message(){return this.reason.message}}});function _5(e,t,n,r,o){for(let s=t;s<Math.min(e.length,t+o);s++)n[r+s-t]=e[s];return n}var Y1="~effect/collections/Chunk",X1,bk=(e)=>dn((t,n)=>t.length===n.length&&Yd(t).every((r,o)=>e(r,Xd(n,o)))),O5,P5,wk=(e)=>{let t=Object.create(P5);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=fi,t.right=fi;break}case"ISingleton":{t.length=1,t.depth=0,t.left=fi,t.right=fi;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=fi,t.right=fi;break}}return t},Mg=(e)=>D(e,Y1),fi,R5=()=>fi,F5=(e)=>wk({_tag:"ISingleton",a:e}),Dg=(e)=>Mg(e)?e:D5(on(e)),Ek=(e,t,n)=>{switch(e.backing._tag){case"IArray":{_5(e.backing.array,0,t,n,e.length);break}case"IConcat":{Ek(e.left,t,n),Ek(e.right,t,n+e.left.length);break}case"ISingleton":{t[n]=e.backing.a;break}case"ISlice":{let r=0,o=n;while(r<e.length)t[o]=Xd(e,r),r+=1,o+=1;break}}},M5=(e)=>{switch(e.backing._tag){case"IEmpty":return X1;case"IArray":return e.backing.array;default:{let t=Array(e.length);return Ek(e,t,0),e.backing={_tag:"IArray",array:t},e.left=fi,e.right=fi,e.depth=0,t}}},Yd,D5=(e)=>e.length===0?R5():e.length===1?F5(e[0]):wk({_tag:"IArray",array:e}),Xd,eF=(e)=>e.length;var tF=v(()=>{nr();Pt();Ws();Zn();ne();wn();pr();ct();ge();X1=[],O5=bk(ee),P5={[Y1]:{_A:(e)=>e},toString(){return`Chunk(${j(Yd(this))})`},toJSON(){return{_id:"Chunk",values:fn(Yd(this))}},[zt](){return this.toJSON()},[Oe](e){return Mg(e)&&O5(this,e)},[_e](){return Cu(Yd(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return X1[Symbol.iterator]();default:return Yd(this)[Symbol.iterator]()}},pipe(){return fe(this,arguments)}},fi=wk({_tag:"IEmpty"}),Yd=M5,Xd=p(2,(e,t)=>{let n=Math.floor(t);switch(e.backing._tag){case"IEmpty":throw Error(`Index out of bounds: ${n}`);case"ISingleton":{if(t!==0)throw Error(`Index out of bounds: ${n}`);return e.backing.a}case"IArray":{if(n>=e.length||n<0)throw Error(`Index out of bounds: ${n}`);return e.backing.array[n]}case"IConcat":return n<e.left.length?Xd(e.left,n):Xd(e.right,n-e.left.length);case"ISlice":return Xd(e.backing.chunk,n+e.backing.offset)}})});var nF,rF;var oF=v(()=>{At();nF=Bh,rF=vP});var sF;var iF=v(()=>{At();sF=cw});var aF="~effect/MutableRef",L5,cF=(e)=>{let t=Object.create(L5);return t.current=e,t};var uF=v(()=>{pr();pt();L5={[aF]:aF,...Xn,toJSON(){return{_id:"MutableRef",current:fn(this.current)}}}});var H5,fF=()=>({head:void 0,tail:void 0,length:0}),lF=()=>({array:[],mutable:!0,offset:0,next:void 0}),di=(e,t)=>{if(!e.tail)e.head=e.tail=lF();else if(!e.tail.mutable)e.tail.next=lF(),e.tail=e.tail.next;e.tail.array.push(t),e.length++},Sl=(e)=>{e.head=e.tail=void 0,e.length=0},dF=(e,t)=>{if(t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let s=e.head.array;return Sl(e),s}let n=Array(t),r=0,o=e.head;while(o){while(o.offset<o.array.length){if(n[r++]=o.array[o.offset],o.mutable)o.array[o.offset]=void 0;if(o.offset++,r===t){if(e.head=o,e.length-=t,e.length===0)Sl(e);return n}}o=o.next}return Sl(e),n},El=(e)=>{if(!e.head)return H5;let t=e.head.array[e.head.offset];if(e.head.mutable)e.head.array[e.head.offset]=void 0;if(e.head.offset++,e.length--,e.head.offset===e.head.array.length)if(e.head.next)e.head=e.head.next;else Sl(e);return t};var pF=v(()=>{H5=Symbol.for("effect/MutableList/Empty")});var j5="~effect/Queue",q5="~effect/Queue/Enqueue",z5="~effect/Queue/Dequeue",kk,V5,wl=(e)=>le((t)=>{let n=Object.create(V5);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??Number.POSITIVE_INFINITY,n.strategy=e?.strategy??"suspend",n.messages=fF(),n.scheduleRunning=!1,n.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},W(n)}),mF=(e)=>wl({capacity:e}),ep=(e,t)=>ue(()=>{if(e.state._tag!=="Open")return $g;else if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return $g;case"suspend":if(e.capacity<=0&&e.state.takers.size>0)return di(e.messages,t),vk(e),Ng;return Z5(e,t);case"sliding":return El(e.messages),di(e.messages,t),Ng}return di(e.messages,t),SF(e),Ng}),tp=(e,t)=>{if(e.state._tag!=="Open")return!1;else if(e.messages.length>=e.capacity){if(e.strategy==="sliding")return El(e.messages),di(e.messages,t),!0;else if(e.capacity<=0&&e.state.takers.size>0)return di(e.messages,t),vk(e),!0;return!1}return di(e.messages,t),SF(e),!0},np,rp=(e,t)=>{if(e.state._tag!=="Open")return!1;let n=$n(t),r=fO(n,G5);if(e.state.offers.size===0&&e.messages.length===0)return Ik(e,r),!0;return e.state={...e.state,_tag:"Closing",exit:r},!0},pi=(e)=>rp(e,Lf(Ru())),Ck=(e)=>me(()=>{if(e.state._tag==="Done")return!0;Sl(e.messages);let t=e.state.offers;if(Ik(e,e.state._tag==="Open"?J5:e.state.exit),t.size>0){for(let n of t)if(n._tag==="Single")n.resume($g);else n.resume(Ke(n.remaining.slice(n.offset)));t.clear()}return!0}),hF=(e)=>gF(e,1,Number.POSITIVE_INFINITY),gF=(e,t,n)=>ue(()=>Q5(e,t,n)??Mo(EF(e),gF(e,1,n))),mi=(e)=>ue(()=>yF(e)??Mo(EF(e),mi(e))),xF=(e)=>ue(()=>{let t=yF(e);if(t===void 0)return W(P());if(t._tag==="Success")return W(F(t.value));return W(P())}),yF=(e)=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=El(e.messages);return bl(e),Ke(t)}else if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,bl(e),e.capacity=0;let t=El(e.messages);return bl(e),Ke(t)}return},K5=(e)=>e.state._tag==="Done"?0:e.messages.length,$g,Ng,G5,J5,vk=(e)=>{if(e.scheduleRunning=!1,e.state._tag==="Done"||e.state.takers.size===0)return;for(let t of e.state.takers)if(e.state.takers.delete(t),t(or),e.messages.length===0)break},SF=(e)=>{if(e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0)return;e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>vk(e),0)},Q5=(e,t,n)=>{if(e.state._tag==="Done")return e.state.exit;else if(n<=0||t<=0)return Ke([]);else if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,bl(e),e.capacity=0;let r=[El(e.messages)];return bl(e),Ke(r)}if(t=Math.min(t,e.capacity||1),t<=e.messages.length){let r=dF(e.messages,n);return bl(e),Ke(r)}},Z5=(e,t)=>an((n)=>{if(e.state._tag!=="Open")return n($g);let r={_tag:"Single",message:t,resume:n};return e.state.offers.add(r),me(()=>{if(e.state._tag==="Open")e.state.offers.delete(r)})}),bl=(e)=>{if(e.state._tag==="Done")return $d(e.state.exit.cause);else if(e.state.offers.size===0){if(e.state._tag==="Closing"&&e.messages.length===0)return Ik(e,e.state.exit),$d(e.state.exit.cause);return!1}let t=e.capacity-e.messages.length;for(let n of e.state.offers)if(t===0)break;else if(n._tag==="Single")di(e.messages,n.message),t--,n.resume(Ng),e.state.offers.delete(n);else{for(;n.offset<n.remaining.length;n.offset++){if(t===0)return!1;di(e.messages,n.remaining[n.offset]),t--}n.resume(Ke([])),e.state.offers.delete(n)}return!1},EF=(e)=>an((t)=>{if(e.state._tag==="Done")return t(e.state.exit);return e.state.takers.add(t),me(()=>{if(e.state._tag!=="Done")e.state.takers.delete(t)})}),Ik=(e,t)=>{if(e.state._tag==="Done")return;let n=e.state;e.state={_tag:"Done",exit:t};for(let r of n.takers)r(t);n.takers.clear();for(let r of n.awaiters)r(t);n.awaiters.clear()};var op=v(()=>{ne();pt();pt();At();pF();Me();kc();kk={_A:L,_E:L},V5={[j5]:kk,[q5]:kk,[z5]:kk,...Xn,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:K5(this)}}},np=p(2,(e,t)=>me(()=>rp(e,t))),$g=Ke(!1),Ng=Ke(!0),G5=ro(Ru()),J5=qh()});class kF{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=ue(()=>{if(this.free<e)return bF(this,e,t);return this.taken+=e,W(e)});return t}takeIfAvailable(e){return ue(()=>{if(this.free<e)return W(!1);return this.taken+=e,W(!0)})}releaseUnsafe(e,t){if(this.taken-=t,this.waiters.size>0)e.currentDispatcher.scheduleTask(()=>{for(let n of this.waiters){if(this.free<=0)break;n()}},0);return this.free}resize(e){return le((t)=>{if(this.permits=e,this.free<0)return Ee;return this.releaseUnsafe(t,0),Ee})}release(e){return le((t)=>W(this.releaseUnsafe(t,e)))}get releaseAll(){return le((e)=>W(this.releaseUnsafe(e,this.taken)))}withPermits(e){return(t)=>No((n)=>{let r=ue(()=>{if(this.free<e){let o=bF(this,e,Ee);return V(n(o),()=>r)}return this.taken+=e,Xs(n(t),()=>{this.releaseUnsafe(oa(),e);return},!0)});return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return(t)=>No((n)=>{if(this.free<e)return mc;return this.taken+=e,Xs(n(el(t)),()=>{this.releaseUnsafe(oa(),e);return},!0)})}}var wF=(e)=>new kF(e),bF=(e,t,n)=>an((r)=>{if(e.free>=t)return r(n);let o=()=>{if(e.free<t)return;e.waiters.delete(o),r(n)};return e.waiters.add(o),me(()=>{e.waiters.delete(o)})});var CF=v(()=>{pt();At()});var IF="~effect/Channel",vF=(e)=>D(e,IF),X5,jn=(e)=>{let t=Object.create(X5);return t.transform=(n,r)=>Gr(e(n,r),(o)=>A(dl(o))),t},AF=(e,t)=>jn((n,r)=>se(Uo(e)(n,r),(o)=>t(o,r))),Lg=(e)=>jn((t,n)=>e),TF=(e)=>jn(q(function*(t,n){let r=ua(n),o=(i)=>qr(r,qw(i)),s=yield*hl(e(t,n,r),o);return hl(s,o)})),Uo=(e)=>e.transform,eQ=(e,t,n)=>wl({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(pl((r)=>Od(e,Ck(r))),pl((r)=>xl(_d(t(r),e),e))),_F=(e,t)=>jn((n,r)=>ae(eQ(r,e,t),hF)),OF=(e)=>jn((t,n)=>He(()=>Uo(e())(t,n))),PF,RF,Ak,tQ,FF,MF=()=>jn((e,t)=>we(()=>{let n="",r=!1,o=P();function s(c){let u=[];function l(f){if(n.length===0)u.push(f);else u.push(n+f),n=""}for(let f=0;f<c.length;f++){let d=c[f];if(d.length!==0){let m=0,y=d.indexOf("\r"),b=d.indexOf(`
|
|
26
26
|
`);if(r){if(b===0)l(""),m=1,b=d.indexOf(`
|
|
27
|
-
`,m);else l("");r=!1}while(
|
|
28
|
-
`,m);else if(d.length===
|
|
29
|
-
`,m);n=n+d.substring(m,d.length-(r?1:0))}}return
|
|
30
|
-
`))e=e.replace(
|
|
31
|
-
`);n=
|
|
32
|
-
at ${t}`:n}function Cu(e){if(e._tag==="Pointer")return;if(e._tag==="Encoding")return Cu(e.issue);let n=(e._tag==="Filter"?e.filter.annotations:("annotations"in e)?e.annotations:e.ast.annotations)?.[e._tag==="MissingKey"?"messageMissingKey":e._tag==="UnexpectedKey"?"messageUnexpectedKey":"message"];if(typeof n==="string")return n}var od="~effect/SchemaIssue/Issue",$r,ww,vw,Ft,Da,$h,Et,ft,we,Tu,sd,kw,SF=(e)=>{let t=Cu(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return Oi(nd(e.ast),e);case"InvalidValue":{let n=Iw(e);if(n!==void 0)return Oi(n,e);let r=Dh(e);return r===void 0?"Expected a valid value":`Invalid data ${r}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let n=Dh(e);return n===void 0?"Expected no excess property":`Unexpected key with value ${n}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let n=Dh(e);return n===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${n}`}}},EF=(e)=>Cu(e.issue)??Cu(e),wF;var Ai=w(()=>{An();kn();Ti();Nh();he();$r=class $r{[od]=od;constructor(e,t){if(t?.reportInput===!0&&e!==Re)this.input=e}};ww=class ww extends $r{_tag="Filter";filter;issue;constructor(e,t,n,r){super(n,r);this.filter=e,this.issue=t}};vw=class vw extends $r{_tag="Encoding";ast;issue;constructor(e,t,n,r){super(n,r);this.ast=e,this.issue=t}};Ft=class Ft extends $r{_tag="Pointer";path;issue;constructor(e,t){super();this.path=e,this.issue=t}};Da=class Da extends $r{_tag="MissingKey";annotations;constructor(e){super();this.annotations=e}};$h=class $h extends $r{_tag="UnexpectedKey";ast;constructor(e,t,n){super(t,n);this.ast=e}};Et=class Et extends $r{_tag="Composite";ast;issues;constructor(e,t,n,r){super(n,r);this.ast=e,this.issues=t}};ft=class ft extends $r{_tag="InvalidType";ast;constructor(e,t,n){super(t,n);this.ast=e}};we=class we extends $r{_tag="InvalidValue";annotations;constructor(e,t,n){super(t,n);this.annotations=e}};Tu=class Tu extends $r{_tag="Forbidden";annotations;constructor(e,t,n){super(t,n);this.annotations=e}};sd=class sd extends $r{_tag="AnyOf";ast;issues;constructor(e,t,n,r){super(n,r);this.ast=e,this.issues=t}};kw=class kw extends $r{_tag="OneOf";ast;successes;constructor(e,t,n,r){super(n,r);this.ast=e,this.successes=t}};wF=y6()});function id(e){let t;for(let n of e.reasons){if(!ff(n)||!bw(n.error))return;t??=n.error}return t}function Os(e,t){let n=id(e);if(n===void 0)throw Error(t,{cause:e});return n}var Tw=w(()=>{rn();Ai()});var Ow,kF,IF,CF,TF,OF,Aw,_w,AF,_F,Uh,RF,Lh,Rw,ad,PF,FF,_i,jh,MF,NF,Bh;var Hh=w(()=>{eR();Ow=iu,kF=Ia,IF=H_,CF=q_,TF=z_,OF=cb,Aw=W_,_w=K_,AF=ka,_F=lb,Uh=G_,RF=J_,Lh=Z_,Rw=fb,ad=If,PF=db,FF=pb,_i=Y_,jh=Cf,MF=gb,NF=X_,Bh=yb});function S6(e){return new As((t,n)=>A(e(t,n)))}function Fw(e){return S6((t,n)=>{let r={message:e(t)};return Ee(t)?new Tu(r,t.value,n):new Tu(r)})}function DF(e){return e.run===$F.run}function ro(){return $F}function Mw(e){return new As((t,n)=>me(t)?Aa:e(t.value,n))}function ve(e){return qh(en(e))}function Vn(e){return Mw((t,n)=>e(t,n).pipe(Ss(_)))}function qh(e){return new As((t)=>v(e(t)))}function Nw(){return new As(()=>Aa)}function cd(e){return new As((t)=>{let n=ca(t,Le);return Ee(n)?v(n):Ss(e,_)})}function Ua(){return ve(globalThis.String)}function zh(){return ve(globalThis.Number)}function UF(){return ve(globalThis.BigInt)}function Dw(){return ve((e)=>new globalThis.Date(e))}function LF(){return ve(aR)}function jF(e){return Mw((t,n)=>Nt({try:()=>_(JSON.parse(t,e?.reviver)),catch:()=>new we({expected:"a valid JSON string"},t,n)}))}function BF(e){return Mw((t,n)=>Nt({try:()=>{let r=JSON.stringify(t,e?.replacer,e?.space);if(r===void 0)throw TypeError("Value cannot be represented as JSON");return _(r)},catch:()=>new we({expected:"a JSON-serializable value"},t,n)}))}function $w(){return ve(am)}function Wh(){return ve(fT)}function Kh(){return ve(pT)}function HF(){return Vn((e,t)=>Ra($b(Vc(e)),()=>new we({expected:"a valid Base64 string"},e,t)))}function qF(){return Vn((e,t)=>Bn(lT(e),{onFailure:()=>A(new we({expected:"a valid Base64 string"},e,t)),onSuccess:v}))}function zF(){return Vn((e,t)=>Bn(vS(e),{onFailure:()=>A(new we({expected:"a valid Base64Url string"},e,t)),onSuccess:v}))}function WF(){return Vn((e,t)=>Bn(dT(e),{onFailure:()=>A(new we({expected:"a valid Base64Url string"},e,t)),onSuccess:v}))}function KF(){return Vn((e,t)=>Bn(IS(e),{onFailure:()=>A(new we({expected:"a valid hexadecimal string"},e,t)),onSuccess:v}))}function VF(){return Vn((e,t)=>Bn(mT(e),{onFailure:()=>A(new we({expected:"a valid hexadecimal string"},e,t)),onSuccess:v}))}function GF(){return ve(encodeURIComponent)}function JF(){return Vn((e,t)=>{try{return v(globalThis.decodeURIComponent(e))}catch{return A(new we({expected:"a valid URI component"},e,t))}})}function Uw(){return Vn((e,t)=>et(Uh(e),{onNone:()=>A(new we({message:"Invalid DateTime input"},e,t)),onSome:(n)=>v(Lh(n))}))}function ZF(){return ve((e)=>eM(Array.from(e.entries())))}function YF(){return ve((e)=>{let t=new FormData;if(typeof e==="object"&&e!==null)E6(e).forEach(([r,o])=>{t.append(r,o)});return t})}function QF(){return ve((e)=>eM(Array.from(e.entries())))}function XF(){return ve((e)=>{if(typeof e==="object"&&e!==null)return new URLSearchParams(b6(e));return new URLSearchParams})}function v6(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),n=t.split("."),r=t.startsWith(".")?1:0;return n.slice(r).map((o)=>w6.test(o)?globalThis.Number(o):o)}function eM(e){let t={},n=new WeakSet;function r(o,s,i){let a=Object.hasOwn(o,s)?o[s]:void 0;if(n.has(a)&&Array.isArray(a)===i)return a;let c=i?[]:{};return n.add(c),U(o,s,c),c}return e.forEach(([o,s])=>{let i=v6(o),a=t;i.forEach((c,u)=>{let l=u===i.length-1;if(Array.isArray(a)&&c==="")if(l)a.push(s);else{let f=i[u+1],d=typeof f==="number"||f==="",m=a.length;a=r(a,m,d)}else if(l){let f=Object.hasOwn(a,c);if(f&&Array.isArray(a[c]))a[c].push(s);else if(f)U(a,c,[a[c],s]);else U(a,c,s)}else{let f=i[u+1];a=r(a,c,typeof f==="number"||f==="")}})}),t}function tM(e){return(t)=>{let n=[];function r(o,s){if(e(s))n.push([o,s]);else if(Array.isArray(s))if(s.every(e))s.forEach((a)=>{n.push([o,a])});else s.forEach((a,c)=>{r(`${o}[${c}]`,a)});else if(typeof s==="object"&&s!==null)for(let[i,a]of Object.entries(s))r(`${o}[${i}]`,a)}for(let[o,s]of Object.entries(t))r(o,s);return n}}var As,$F,E6,b6,w6;var Vh=w(()=>{Hh();Oe();cm();_e();Qe();he();gn();Ai();fR();As=class As extends Gi{run;constructor(e){super();this.run=e}map(e){return new As((t,n)=>this.run(t,n).pipe(Ss(en(e))))}compose(e){if(DF(this))return e;if(DF(e))return this;return new As((t,n)=>this.run(t,n).pipe(on((r)=>e.run(r,n))))}};$F=new As(v);E6=tM((e)=>typeof e==="string"||typeof Blob<"u"&&e instanceof Blob);b6=tM(Wr);w6=/^\d+$/});var nM,jw="~effect/BigDecimal",k6,Jh=(e)=>M(e,jw),Gn=(e,t)=>{let n=Object.create(k6);return n.value=e,n.scale=t,n},oM=(e,t)=>{if(e!==yr&&e%Gh===yr)throw RangeError("Value must be normalized");let n=Gn(e,t);return n.normalized=n,n},yr,I6,C6,Gh,sM,Bw=(e)=>{if(e.normalized===void 0)if(e.value===yr)e.normalized=sM;else{let t=`${e.value}`,n=0;for(let s=t.length-1;s>=0;s--)if(t[s]==="0")n++;else break;if(n===0)e.normalized=e;let r=BigInt(t.substring(0,t.length-n)),o=e.scale-n;e.normalized=oM(r,o)}return e.normalized},Ri,iM,_s,T6,O6,rM=(e)=>e.value===yr?0:e.value<yr?-1:1,A6=(e)=>e.value<yr?Gn(-e.value,e.scale):e,Hw,_6,aM=(e)=>{if(e==="")return _(sM);let t,n,r=e.search(/[eE]/);if(r!==-1){let c=e.slice(r+1);if(t=e.slice(0,r),n=Number(c),t===""||!Number.isSafeInteger(n)||!nM.test(c))return O()}else t=e,n=0;let o,s,i=t.search(/\./);if(i!==-1){let c=t.slice(0,i),u=t.slice(i+1);o=`${c}${u}`,s=u.length}else o=t,s=0;if(!nM.test(o))return O();let a=s-n;if(!Number.isSafeInteger(a))return O();return _(Gn(BigInt(o),a))},Ro=(e)=>{let t=Bw(e);if(Math.abs(t.scale)>=16)return R6(t);let n=t.value<yr,r=n?`${t.value}`.substring(1):`${t.value}`,o,s;if(t.scale>=r.length)o="0",s="0".repeat(t.scale-r.length)+r;else{let a=r.length-t.scale;if(a>r.length){let c=a-r.length;o=`${r}${"0".repeat(c)}`,s=""}else s=r.slice(a),o=r.slice(0,a)}let i=s===""?o:`${o}.${s}`;return n?`-${i}`:i},R6=(e)=>{if(P6(e))return"0e+0";let t=Bw(e),n=`${A6(t).value}`,r=n.slice(0,1),o=n.slice(1),s=`${cM(t)?"-":""}${r}`;if(o!=="")s+=`.${o}`;let i=o.length-t.scale;return`${s}e${i>=0?"+":""}${i}`},P6=(e)=>e.value===yr,cM=(e)=>e.value<yr,F6=(e)=>e.value>yr,qw=(e)=>Jh(e[0]),uM,zw,Ww;var Kw=w(()=>{yt();Xo();X();Xt();jn();_e();ia();Qe();he();nM=/^[+-]?\d+$/,k6={[jw]:jw,[Ie](){let e=Bw(this);return xt(re(e.value),Ln(e.scale))},[Ce](e){return Jh(e)&&_6(this,e)},toString(){return`BigDecimal(${Ro(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[At](){return this.toJSON()},pipe(){return le(this,arguments)}},yr=BigInt(0),I6=BigInt(1),C6=BigInt(-1),Gh=BigInt(10),sM=oM(yr,0),Ri=p(2,(e,t)=>{if(t>e.scale)return Gn(e.value*Gh**BigInt(t-e.scale),t);if(t<e.scale)return Gn(e.value/Gh**BigInt(e.scale-t),t);return e}),iM=p(2,(e,t)=>{if(t.value===yr)return e;if(e.value===yr)return t;if(e.scale>t.scale)return Gn(Ri(t,e.scale).value+e.value,e.scale);if(e.scale<t.scale)return Gn(Ri(e,t.scale).value+t.value,t.scale);return Gn(e.value+t.value,e.scale)}),_s=ts((e,t)=>{let n=rr(rM(e),rM(t));if(n!==0)return n;if(e.scale>t.scale)return Cr(e.value,Ri(t,e.scale).value);if(e.scale<t.scale)return Cr(Ri(e,t.scale).value,t.value);return Cr(e.value,t.value)}),T6=Uc(_s),O6=ti(_s),Hw=Kt((e,t)=>{if(e.scale>t.scale)return Ri(t,e.scale).value===e.value;if(e.scale<t.scale)return Ri(e,t.scale).value===t.value;return e.value===t.value}),_6=p(2,(e,t)=>Hw(e,t)),uM=p(qw,(e,t=0)=>{if(e.scale<=t)return e;return Gn(e.value/Gh**BigInt(e.scale-t),t)}),zw=p(qw,(e,t=0)=>{let n=uM(e,t);if(F6(e)&&T6(n,e))return iM(n,Gn(I6,t));return n}),Ww=p(qw,(e,t=0)=>{let n=uM(e,t);if(cM(e)&&O6(n,e))return iM(n,Gn(C6,t));return n})});class ld{_tag="Middleware";decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new ld(this.encode,this.decode)}}function M6(e){return M(e,ud)&&e[ud]===ud}function Sr(e){return new Pe(Vn(e.decode),Vn(e.encode))}function st(e){return new Pe(ve(e.decode),ve(e.encode))}function Yh(e){return new Pe(qh(e.decode),qh(e.encode))}function fM(){return new Pe(LF(),ro())}function Ou(){return N6}function bM(){return st({decode:Gy,encode:Jp})}function wM(){return st({decode:ns,encode:mn})}function vM(e){return st({decode:Tn,encode:e?.onNoneEncoding===null?Jp:mn})}function kM(){return Yh({decode:_,encode:aa})}function IM(){return Yh({decode:(e)=>e.pipe(ca(Le),_),encode:aa})}function _M(e){return new Pe(jF(e??{}),BF(e))}var ud="~effect/SchemaTransformation/Transformation",Pe,Zh=(e)=>{if(M6(e))return e;return new Pe(e.decode,e.encode)},N6,Au,Qh,Vw,dM,pM,mM,hM,D6=(e)=>fn(e)&&typeof e.message==="string",gM=(e)=>{let n=Object.hasOwn(e,"cause")?Error(e.message,{cause:yM(e.cause)}):Error(e.message);if(typeof e.name==="string"&&e.name!=="Error")n.name=e.name;if(typeof e.stack==="string")n.stack=e.stack;return n},$6=(e)=>{try{let t=Yi(e);return t===void 0?B(e):JSON.parse(t)}catch{return B(e)}},U6=(e,t,n)=>{let r={name:e.name,message:typeof e.message==="string"?e.message:""};if(t?.includeStack&&typeof e.stack==="string")r.stack=e.stack;if(!t?.excludeCause&&e.cause!==void 0)r.cause=n(e.cause);return r},xM=(e)=>{let t=new WeakSet,n=(r)=>{if(q0(r)){if(t.has(r))return"[Circular]";t.add(r);let o=U6(r,e,n);return t.delete(r),o}return $6(r)};return n},yM=(e)=>D6(e)?gM(e):e,SM=(e)=>st({decode:gM,encode:(t)=>xM(e)(t)}),EM=(e)=>st({decode:yM,encode:xM(e)}),Gw,Jw,Zw,CM,TM,OM,AM,RM,PM,FM,Yw,Qw,Xw,ev;var Xh=w(()=>{Kw();Hh();ai();Oe();kn();_e();he();Vh();Ai();Pe=class Pe{[ud]=ud;_tag="Transformation";decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new Pe(this.encode,this.decode)}compose(e){return new Pe(this.decode.compose(e.decode),e.encode.compose(this.encode))}};N6=new Pe(ro(),ro());Au=new Pe(zh(),Ua()),Qh=new Pe(UF(),Ua()),Vw=new Pe(Dw(),ve(Ly)),dM=new Pe(Dw(),ve((e)=>e.getTime())),pM=Sr({decode:(e,t)=>et(KC(e),{onNone:()=>A(new we({expected:"a valid Duration string"},e,t)),onSome:v}),encode:(e)=>v(globalThis.String(e))}),mM=Sr({decode:(e)=>v(Tr(e)),encode:(e,t)=>et(GC(e),{onNone:()=>A(new we({expected:"a Duration representable as a bigint"},e,t)),onSome:(n)=>v(n)})}),hM=st({decode:(e)=>ii(e),encode:(e)=>qc(e)});Gw=Sr({decode:(e,t)=>URL.canParse(e)?v(new URL(e)):A(new we({expected:"a valid URL string"},e,t)),encode:(e)=>v(e.href)}),Jw=Sr({decode:(e,t)=>{let n=aM(e);return me(n)?A(new we({expected:"a valid BigDecimal string"},e,t)):v(n.value)},encode:(e)=>v(Ro(e))}),Zw=new Pe(HF(),$w()),CM=new Pe(qF(),$w()),TM=new Pe(WF(),Wh()),OM=new Pe(VF(),Kh()),AM=new Pe(JF(),GF());RM=new Pe(ZF(),YF()),PM=new Pe(QF(),XF()),FM=st({decode:(e)=>ad(e),encode:(e)=>e.offset}),Yw=Sr({decode:(e,t)=>et(PF(e),{onNone:()=>A(new we({expected:"a valid IANA time zone"},e,t)),onSome:v}),encode:(e)=>v(e.id)}),Qw=Sr({decode:(e,t)=>et(FF(e),{onNone:()=>A(new we({expected:"a valid time zone"},e,t)),onSome:v}),encode:(e)=>v(_i(e))}),Xw=Sr({decode:(e,t)=>et(Uh(e),{onNone:()=>A(new we({expected:"a valid UTC DateTime string"},e,t)),onSome:(n)=>v(Lh(n))}),encode:(e)=>v(NF(e))}),ev=Sr({decode:(e,t)=>et(RF(e),{onNone:()=>A(new we({expected:"a valid Zoned DateTime string"},e,t)),onSome:v}),encode:(e)=>v(Bh(e))})});function Fi(e){return(t)=>t._tag===e}class dt{to;transformation;constructor(e,t){this.to=e,this.transformation=t}}class so{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}}function t1(e){switch(e._tag){case"String":case"Number":case"BigInt":return!0;case"Literal":case"TemplateLiteral":return!e.checks;case"Union":return!e.checks&&e.types.every(t1);default:return!1}}function NM(e){let t=globalThis.String(e.literal);return Ge(e,[new dt(new Er(t),new Pe(ve(()=>e.literal),ve(()=>t)))])}function rv(e,t){return e.some((n)=>n.annotations?.representation?.id===t||n._tag==="FilterGroup"&&rv(n.checks,t))}function La(e,t,n=ja){let r,o;function s(i){switch(i._tag){case"String":case"TemplateLiteral":return(r??=Object.keys(e)).filter((a)=>i.matchPart(a,n)!==void 0);case"Number":return(r??=Object.keys(e)).filter((a)=>i.matchKey(a,n)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter((a)=>i.matchKey(a,n)!==void 0);case"Union":return[...new Set(i.types.flatMap(s))];default:return[]}}return s(Iv(Jn(t)))}class ng{name;type;constructor(e,t){this.name=e,this.type=t}}function ov(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(ov);default:return!1}}function q6(e){return ov(e)&&ov(Jn(e))}class rg{parameter;type;constructor(e,t){if(!q6(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,bt(t)&&!k1(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}}function sv(e,t,n){if(n._tag==="Failure")return eg(e,e.ast,t.name,n);if(n===Dt)return;let r=n[ie];if(r!==Re){U(e.out,t.name,r);return}if(delete e.out[t.name],!bt(t.type)){let o=new Ft([t.name],new Da(t.type.context?.annotations));if(e.options.errors==="all"){if(e.issues)e.issues.push(o);else e.issues=[o];return}else return Rr(new Et(e.ast,[o],e.input,e.options))}}function xv(e,t){if(!e)return t;if(!t)return e;return[...e,...t]}function og(e,t,n){return new Mu(Reflect.ownKeys(e).map((r)=>new ng(r,e[r].ast)),[],n,t)}function pd(e){return e.ast}function yv(e,t=void 0){return new io(!1,e.map((n)=>n.ast),[],void 0,t)}function sg(e,t,n){return new Fn(e.map(pd),t,void 0,n)}function l1(e,t){if(e.encoding||t.some((s)=>s.encoding))throw Error("StructWithRest does not support encodings");let{propertySignatures:n,indexSignatures:r,checks:o}=e;for(let s of t)n=n.concat(s.propertySignatures),r=r.concat(s.indexSignatures),o=xv(o,s.checks);return new Mu(n,r,void 0,o)}function f1(e,t){if(e.encoding)throw Error("TupleWithRest does not support encodings");return new io(e.isMutable,e.elements,t,void 0,e.checks)}function d1(e){switch(e._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return e.propertySignatures.length||e.indexSignatures.length?["object"]:["string","number","boolean","symbol","bigint","object","array","function"];case"Enum":return Array.from(new Set(e.enums.map(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(d1)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function Ru(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[td];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap((t)=>{let n=t.type;if(!bt(n)){if(_u(n))return[{key:t.name,literal:n.literal}];if(nv(n))return[{key:t.name,literal:n.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,n)=>{if(!bt(t)){if(_u(t))return[{key:n,literal:t.literal}];if(nv(t))return[{key:n,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map((n)=>Ru(ig(n)));return t[0].filter((n)=>t.every((r)=>r.some((o)=>o.key===n.key&&o.literal===n.literal)))}case"Suspend":return Ru(e.thunk())}}function z6(e){let t=$M.get(e);if(t)return t;let n,r=0,o,s,i=!0;for(let a=0;a<e.length;a++){let c=e[a],u=ig(c);if(L6(u))continue;if(i)if(_u(u)||nv(u)){s??=new Map;let f=_u(u)?u.literal:u.symbol,d=s.get(f);if(!d)s.set(f,d=[]);d.push(c)}else i=!1;let l=Ru(u);if(l.length){n??=new Map,r++;for(let{key:f,literal:d}of l){let m=n.get(f);if(!m)n.set(f,m=[new Map,new Set]);m[1].add(a);let g=m[0].get(d);if(!g)m[0].set(d,g=new Set);g.add(a)}}else{o??={};let f=d1(u);for(let d of f)(o[d]??=[]).push(a)}}if(i&&s)s.forEach(Object.freeze),t=(a)=>s.get(a)??fd;else if(n?.size===1&&!o){let[a,[c]]=n.entries().next().value,u=c;for(let[l,f]of c)u.set(l,Object.freeze(Array.from(f,(d)=>e[d])));t=(l,f)=>{if(vl(l)){let d=Object.hasOwn(l,a)?l[a]:void 0;if(d!==void 0)return u.get(d)??fd;if(f)return e}return fd}}else if(n){let a;for(let c of n)if((!a||c[1][0].size>a[1][0].size)&&c[1][1].size===r)a=c;t=(c,u)=>{let l=c===null?"null":Array.isArray(c)?"array":typeof c,f=o?.[l]??fd;if(!vl(c))return f.map((g)=>e[g]);let d=new Set(f),m;if(a){let[g,[b]]=a,x=Object.hasOwn(c,g),I=x?c[g]:void 0;if(x&&(!u||I!==void 0)){let C=b.get(I);if(!C)return f.map((S)=>e[S]);for(let S of C)d.add(S);m=g}}if(m===void 0)for(let[g,[b,x]]of n){let I=Object.hasOwn(c,g),C=I?c[g]:void 0;if(I&&(!u||C!==void 0)){let S=b.get(C);if(S)for(let y of S)d.add(y)}else if(u)for(let S of x)d.add(S)}for(let[g,[b,x]]of n){if(g===m)continue;let I=Object.hasOwn(c,g),C=I?c[g]:void 0;if(I&&(!u||C!==void 0)){let S=b.get(C);for(let y of d)if(x.has(y)&&!S?.has(y))d.delete(y)}}return Array.from(d).sort((g,b)=>g-b).map((g)=>e[g])}}else t=(a)=>{let c=a===null?"null":Array.isArray(a)?"array":typeof a;return(o?.[c]??fd).map((u)=>e[u]).filter(W6(a))};return $M.set(e,t),t}function W6(e){return(t)=>{let n=ig(t);return n._tag==="Literal"?n.literal===e:n._tag==="UniqueSymbol"?n.symbol===e:!0}}function md(e,t,n=!1){return z6(t)(e,n)}function UM(e,t,n,r){let o=id(t);if(!o)return lr(t);return Rr(new sd(e,[o],n,r))}function LM(e){return e?"":"readonly "}function jM(e){return e?"?":""}function Ha(e){let t=!1,n;return()=>{if(t)return n;return n=e(),t=!0,n}}function cg(e,t,n=!1){return new dd((r,o,s)=>yF(o,e(r,o,s),r,s),t,n)}function ug(e,t){return new dd((n,r,o)=>e(n)?void 0:new we(void 0,n,o),t,!0)}function Sv(e){return cg((t)=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}function hd(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return cg((o)=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n}`,representation:{id:"effect/schema/isPattern",payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitrary:{constraint:{patterns:[e.source]}},...t})}function gd(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}function bv(e){return m1.get(e)??e}function Ge(e,t){if(e.encoding===t)return e;return gd(e,(n)=>{n.encoding.value=t})}function xd(e,t){if(e.context===t)return e;let n=bv(e);if(n.context===t)return n;let r=gd(e,(o)=>{o.context.value=t});return m1.set(r,n),r}function yd(e){return e.encoding?yd(e.encoding[e.encoding.length-1].to):e}function Ur(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return lg(e,lS(e.checks.slice(0,-1),n.annotate(t)))}return gd(e,(n)=>{n.annotations.value={...n.annotations.value,...t}})}function lg(e,t){if(e._tag==="Suspend"&&t)throw Error("Cannot add checks to Suspend");if(e.checks===t)return e;return gd(e,(n)=>{n.checks.value=t})}function Fo(e,t){return lg(e,xv(e.checks,t))}function Nu(e,t){let n=t(e.to);return n===e.to?e:new dt(n,e.transformation)}function h1(e,t){let n=e,r=n[n.length-1],o=Nu(r,t);return o===r?e:lS(e.slice(0,e.length-1),o)}function wv(e){return(t)=>t.encoding?Ge(t,h1(t.encoding,e)):t}function fg(e,t){return wv((n)=>xd(n,t))(e)}function qa(e,t){function n(r){if(r.encoding){let o=r.encoding[r.encoding.length-1];return t?.stopAt?.(o)?r:Ge(r,h1(r.encoding,n))}return e(r)}return Ji(n)}function g1(e,t){return vv(e,t,sn(e))}function x1(e,t){return vv(Jn(e),t,e)}function vv(e,t,n){let r=new dt(e,t);return Ge(n,n.encoding?[...n.encoding,r]:[r])}function y1(e,t){let n=hF(e),r=n?[...n,t]:[t];return Ur(e,{brands:r})}function Pu(e,t){let n=!1,r=Array(e.length);for(let o=0;o<e.length;o++){let s=e[o],i=t(s);if(i!==s)n=!0;r[o]=i}return n?r:e}function Sd(e,t){let n=e.context?new so(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new so(!1,!1,void 0,t);return xd(e,n)}function E1(e,t){let n=new Pe(cd(t),ro()),r=new dt(Rs,n),o=e.context?new so(e.context.isOptional,e.context.isMutable,r,e.context.annotations):new so(!1,!1,r);return xd(e,o)}function dg(e,t,n){return vv(e,n,t)}function Z6(e){let t=[],n=[];function r(o){switch(o._tag){case"Literal":if(Ap(o.literal))t.push(o.literal);return;case"UniqueSymbol":t.push(o.symbol);return;case"Never":return;case"Union":for(let s=0;s<o.types.length;s++)r(o.types[s]);return;default:n.push(o)}}return r(e),{literals:t,parameters:n}}function b1(e,t){let{literals:n,parameters:r}=Z6(e);return new Mu(n.map((o)=>new ng(o,t)),r.map((o)=>new rg(o,t)))}function bt(e){return e.context?.isOptional??!1}function w1(e){return e.context?.isMutable??!1}function v1(e){return e.annotations?.[Wn]===!0||e._tag==="FilterGroup"&&e.checks.every(v1)}function Y6(e){function t(r){if(v1(r))return[r];return r._tag==="FilterGroup"?r.checks.flatMap(t):[]}let n=e.flatMap(t);return la(n)?n:void 0}function Q6(e,t){let n=t,r=n.length,o=n[r-1],s=[new dt(oo(Ge(e,void 0)),n[0].transformation.flip())];for(let a=1;a<r;a++)s.unshift(new dt(oo(n[a-1].to),n[a].transformation.flip()));let i=oo(o.to);if(i.encoding)return Ge(i,[...i.encoding,...s]);else return Ge(i,s)}function k1(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(k1);default:return!1}}function pg(e,t){let n=Dr(t);return(r,o)=>{if(r===Re)return no;if(r===t)return n;return A(new ft(e,r,o))}}function ao(e,t){return(n,r)=>{if(n===Re)return no;if(t(n))return Dt;return A(new ft(e,n,r))}}function BM(e,t,n){let{encodedParts:r,literals:o}=e,s=t.length;for(let u=0;u<o.length;u++){let l=o[u];if(l&&!t.includes(l))return}if(e.suffixLengths[0]>s)return;let i=Array(r.length),a;function c(u,l){if(u===r.length)return l===s;if(a?.has(u*(s+1)+l))return!1;let f=r[u];if(u===r.length-1){let d=t.slice(l);if(f.matchPart(d,n)!==void 0)return i[u]=d,!0}else if(f._tag==="Literal"){let d=o[u];if(t.startsWith(d,l)&&c(u+1,l+d.length))return i[u]=d,!0}else{let d=s-e.suffixLengths[u+1],m=o[u+1],g=m===void 0?d:t.lastIndexOf(m,d);while(g>=l){let b=t.slice(l,g);if(f.matchPart(b,n)!==void 0&&c(u+1,g))return i[u]=b,!0;if(g===0)break;g=m===void 0?g-1:t.lastIndexOf(m,g-1)}}return a??=new Set,a.add(u*(s+1)+l),!1}return c(0,0)?i:void 0}function Cv(e){return hd(iv,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:iv.source}),...e})}function Tv(e){return hd(av,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:av.source}),...e})}function Av(e){return hd(cv,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:cv.source}),...e})}function co(e,t,n,r,o){for(let s=0;s<e.length;s++){let i=e[s];if(i._tag==="FilterGroup"){if(n=co(i.checks,t,n,r,o),n&&(o.errors!=="all"||n[n.length-1].filter.aborted))return n}else{let a=i.run(t,r,o);if(a){let c=new ww(i,a,t,o);if(n)n.push(c);else n=[c];if(o.errors!=="all"||i.aborted)return n}}}return n}function _1(e,t){let n=co(e,t,void 0,Rs,{errors:"all"});if(n){let r=new Et(Rs,n);return te(r)}return G(t)}function R1(e){if(!Mi(e))return;let t=e.annotations?.[Fh];return ln(t)?t(e.typeParameters):void 0}function i5(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&globalThis.Number.isFinite(e)}function a5(e){return e===void 0||typeof e==="string"}function P1(e,t){let n=new WeakMap,r=[];e:while(!0){if(typeof e!=="object"||e===null){if(!t(e))return!1}else{let o=e,s=n.get(o);if(s===!1)return!1;if(s===void 0){let i=Array.isArray(o);if(!i){let a=Object.getPrototypeOf(o);if(a!==null&&a!==Object.prototype&&Object.getPrototypeOf(a)!==null)return!1}n.set(o,!1),r.push({value:o,keys:i?o.length:Object.keys(o),index:0})}}while(r.length>0){let o=r[r.length-1],s=o.keys;if(typeof s==="number"){if(o.index<s){e=o.value[o.index++];continue e}}else if(o.index<s.length){e=o.value[s[o.index++]];continue e}n.set(o.value,!0),r.pop()}return!0}}function $u(e){return P1(e,i5)}function c5(e){return P1(e,a5)}var Mi,L6,_u,nv,uv,j6,HM,B6,ja,MM="~effect/Schema",wt,Ba,qM,lv,zM,WM,fv,KM,VM,GM,JM,ZM,YM,QM,Rs,XM,e1,dv,pv,mv,Er,n1,Po,r1,hv,o1,s1,i1,a1,c1,u1,io,H6,gv=(e)=>(e=e==="unbounded"?1/0:e??1,e>1?{concurrency:e}:void 0),eg=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let o=id(r.cause);if(o===void 0)return lr(ms(r.cause,(i)=>new Et(t,[new Ft([n],i)],e.input,e.options)));let s=new Ft([n],o);if(e.options.errors==="all")if(e.issues)e.issues.push(s);else e.issues=[s];else return Rr(new Et(t,[s],e.input,e.options))},tg="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?",Mu,DM,ig,$M,fd,Fn,K6,p1,ag,dd,Pi,Ev,V6,m1,Du,G6,S1,kv,J6,sn,Jn,oo,I1,Iv,mg,C1,T1="[\\s\\S]*?",iv,X6,O1,e5,t5,n5="-?\\d+",av,Ov,r5,o5="Symbol\\((.*)\\)",cv,s5,A1,Fu,F1,_v,M1,u5,Rv;var Ps=w(()=>{An();rn();Oe();dr();kn();X();ht();Ti();Tw();Nh();Qe();he();gn();Vh();Ai();Xh();Mi=Fi("Declaration"),L6=Fi("Never"),_u=Fi("Literal"),nv=Fi("UniqueSymbol"),uv=Fi("Arrays"),j6=Fi("Objects"),HM=Fi("Union"),B6=Fi("Suspend");ja={};wt=class wt{[MM]=MM;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}};Ba=class Ba extends wt{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,o,s,i,a){super(n,r,o,s);this.typeParameters=e,this.run=t,this.encodingChecks=i,this.encodingRun=a}getParser(){let e;return(t,n)=>{if(t===Re)return no;return(e??=this.run(this.typeParameters))(t,this,n)}}_rebuild(e,t,n,r,o){let s=Pu(this.typeParameters,e);return s===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&o===this.encodingRun?this:new Ba(s,r,this.annotations,t,void 0,this.context,n,o)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;if(typeof e==="string")return e;return"<Declaration>"}};qM=class qM extends wt{_tag="Null";getParser(){return pg(this,null)}getExpected(){return"null"}};lv=new qM;zM=class zM extends wt{_tag="Undefined";getParser(){return pg(this,void 0)}toCodecJson(){return Ge(this,[WM])}getExpected(){return"undefined"}};WM=new dt(lv,new Pe(ve(()=>{return}),ve(()=>null))),fv=new zM;KM=class KM extends wt{_tag="Void";getParser(){let e=Dr(void 0);return(t)=>t===Re?no:e}toCodecJson(){return Ge(this,[WM])}getExpected(){return"void"}};VM=new KM;GM=class GM extends wt{_tag="Never";getParser(){return ao(this,H0)}getExpected(){return"never"}};JM=new GM;ZM=class ZM extends wt{_tag="Any";getParser(){return ao(this,Ty)}getExpected(){return"any"}};YM=new ZM;QM=class QM extends wt{_tag="Unknown";getParser(){return ao(this,Ty)}getExpected(){return"unknown"}};Rs=new QM;XM=class XM extends wt{_tag="ObjectKeyword";getParser(){return ao(this,vl)}getExpected(){return"object | array | function"}};e1=new XM;dv=class dv extends wt{_tag="Enum";enums;constructor(e,t,n,r,o){super(t,n,r,o);this.enums=e}getParser(){let e=new Set(this.enums.map(([,t])=>t));return ao(this,(t)=>e.has(t))}toCodecStringTree(){if(this.enums.some(([e,t])=>typeof t==="number")){let e=Object.fromEntries(this.enums.map(([t,n])=>[globalThis.String(n),n]));return Ge(this,[new dt(new Fn(Object.keys(e).map((t)=>new Er(t)),"anyOf"),new Pe(ve((t)=>e[t]),Ua()))])}return this}getExpected(){return this.enums.map(([e,t])=>JSON.stringify(t)).join(" | ")}};pv=class pv extends wt{_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(e,t,n,r,o){super(t,n,r,o);let s=[],i=[];for(let c of e){let u=Jn(c);if(t1(u))s.push(u),i.push(u._tag==="Literal"?globalThis.String(u.literal):void 0);else throw Error(`Invalid TemplateLiteral part ${u._tag}`)}let a=Array(s.length+1);a[s.length]=0;for(let c=s.length-1;c>=0;c--)a[c]=a[c+1]+(i[c]?.length??0);this.parts=e,this.encodedParts=s,this.literals=i,this.suffixLengths=a}getParser(e){let t=e(this.asTemplateLiteralParser());return(n,r)=>{if(n===Re)return no;let o=t(n,r);if(o._tag==="Success")return Dt;return Jt(o,{onSuccess:()=>n,onFailure:(s)=>new Et(this,[s],n,r)})}}getExpected(){return"string"}matchPart(e,t){return BM(this,e,t)===void 0?void 0:e}asTemplateLiteralParser(){let e=new io(!1,this.parts.map(C1),[]);return dg(Po,e,new Pe(Vn((t,n)=>{let r=BM(this,t,n);if(r)return v(r);return A(new we({expected:"a string matching template literal parts"},t,n))}),ve((t)=>t.join(""))))}};mv=class mv extends wt{_tag="UniqueSymbol";symbol;constructor(e,t,n,r,o){super(t,n,r,o);this.symbol=e}getParser(){return pg(this,this.symbol)}toCodecStringTree(){return Ge(this,[A1])}getExpected(){return globalThis.String(this.symbol)}};Er=class Er extends wt{_tag="Literal";literal;constructor(e,t,n,r,o){super(t,n,r,o);if(typeof e==="number"&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${B(e)}`);this.literal=e}getParser(){return pg(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==="bigint"?NM(this):this}toCodecStringTree(){return typeof this.literal==="string"?this:NM(this)}getExpected(){return typeof this.literal==="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};n1=class n1 extends wt{_tag="String";getParser(){return ao(this,Wr)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&co(n,e,void 0,this,t)?void 0:e}getExpected(){return"string"}};Po=new n1;r1=class r1 extends wt{_tag="Number";getParser(){return ao(this,bl)}matchKey(e,t){return this._match(X6,e,t)}matchPart(e,t){return this._match(iv,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);if(n.disableChecks||!this.checks)return r;return co(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){if(this.checks&&(rv(this.checks,"effect/schema/isFinite")||rv(this.checks,"effect/schema/isInt")))return this;return Ge(this,[V6])}toCodecStringTree(){if(this.toCodecJson()===this)return Ge(this,[e5]);return Ge(this,[t5])}getExpected(){return"number"}};hv=new r1;o1=class o1 extends wt{_tag="Boolean";getParser(){return ao(this,Op)}getExpected(){return"boolean"}};s1=new o1;i1=class i1 extends wt{_tag="Symbol";getParser(){return ao(this,Cy)}matchKey(e,t){if(t.disableChecks||!this.checks)return e;return co(this.checks,e,void 0,this,t)?void 0:e}toCodecStringTree(){return Ge(this,[A1])}getExpected(){return"symbol"}};a1=new i1;c1=class c1 extends wt{_tag="BigInt";getParser(){return ao(this,j0)}matchPart(e,t){if(!av.test(e))return;let n=globalThis.BigInt(e);if(t.disableChecks||!this.checks)return n;return co(this.checks,n,void 0,this,t)?void 0:n}toCodecStringTree(){return Ge(this,[r5])}getExpected(){return"bigint"}};u1=new c1;io=class io extends wt{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,o,s,i,a){super(r,o,s,i);this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=a;let c=!1;for(let u=0;u<t.length;u++)if(bt(t[u]))c=!0;else if(c)throw Error("A required element cannot follow an optional element. ts(1257)");if(c&&n.length>1)throw Error("A required element cannot follow an optional element. ts(1257)");for(let u=1;u<n.length;u++)if(bt(n[u]))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let n=this,r,o,s=n.elements.length,i=Math.max(0,n.rest.length-1);function a(c,u){if(u<s)return r[u];else if(u>=c)return o[u-c+1];return o[0]}return hh(function*(c,u){if(c===Re)return Re;if(!Array.isArray(c))return yield*A(new ft(n,c,u));if(!r)r=n.elements.map((g)=>({ast:g,parser:t(g)})),o=n.rest.map((g)=>({ast:g,parser:t(g)}));let l=c.length,f={ast:n,getParser:a,input:c,len:l,tailThreshold:Math.max(s,l-i),output:new globalThis.Array(l),issues:void 0,options:u},d=gv(u?.concurrency),m=H6(f,c,{concurrency:d?.concurrency,end:n.rest.length===0?s:Math.max(l,s+i)});if(m)yield*m;if(n.rest.length===0&&l>s)for(let g=s;g<=l-1;g++){let b=new $h(n,c[g],u),x=new Ft([g],b);if(u.errors==="all")if(f.issues)f.issues.push(x);else f.issues=[x];else return yield*A(new Et(n,[x],c,u))}if(f.issues)return yield*A(new Et(n,f.issues,c,u));return f.output})}_rebuild(e,t,n){let r=Pu(this.elements,e),o=Pu(this.rest,e);return r===this.elements&&o===this.rest&&t===this.checks&&n===this.encodingChecks?this:new io(this.isMutable,r,o,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return"array"}};H6=uf()({onItem(e,t,n){let r=n<e.len?t:Re;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step(e,t,n,r){if(n._tag==="Failure")return eg(e,e.ast,r,n);let o=n===Dt?t:n[ie];if(o!==Re)e.output[r]=o;else{let s=e.getParser(e.tailThreshold,r);if(bt(s.ast))return;let i=new Ft([r],new Da(s.ast.context?.annotations));if(e.options.errors==="all")if(e.issues)e.issues.push(i);else e.issues=[i];else return Rr(new Et(e.ast,[i],e.input,e.options))}}});Mu=class Mu extends wt{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,o,s,i){super(n,r,o,s);this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=i;let a=e.map((c)=>c.name).filter((c,u,l)=>l.indexOf(c)!==u);if(a.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(a)}. ts(2300)`)}getParser(e,t=e){let n=this,r=[];for(let x of n.propertySignatures)r.push(x.name);let o=r.length,s=n.indexSignatures.length,i=o&&s?new Set(r):void 0;if(!o&&!s)return ao(n,_p);let a,c,u=(x,I,C,S,y)=>{if(y._tag==="Failure")return eg(x,n,I,y)??fr;let h=y===Dt?S:y[ie];if(C!==Re&&h!==Re){if(o&&(i.has(I)||i.has(C)))return fr;U(x.out,C,h)}return fr},l=(x,I,C,S)=>{if(!S){let k=C.parserKey(I,x.options);if(!We(k))return ne(bi(k),(T)=>l(x,I,C,T));S=k}if(S._tag==="Failure")return eg(x,n,I,S)??fr;let y=S===Dt?I:S[ie],h=x.input[I],E=C.parserValue(h,x.options);return We(E)?u(x,I,y,h,E):ne(bi(E),(k)=>u(x,I,y,h,k))},f=(x,I,C)=>{let S=x.input[I],y=C.parserValue(S,x.options);return We(y)?u(x,I,I,S,y):ne(bi(y),(h)=>u(x,I,I,S,h))},d=s?uf()({onItem:(x,[I,C])=>l(x,I,C),step:(x,I,C)=>C._tag==="Failure"?C:void 0}):void 0,m=()=>{if(!a)a=n.propertySignatures.map((x)=>({parser:t(x.type),name:x.name,type:x.type})),c=s?n.indexSignatures.map((x)=>({is:x,parserKey:e(Iv(x.parameter)),parserValue:t(x.type)})):void 0;return a},g=hh(function*(x,I){if(x===Re)return Re;if(!(typeof x==="object"&&x!==null&&!Array.isArray(x)))return yield*A(new ft(n,x,I));m();let C=x,S={},y={ast:n,input:C,out:S,issues:void 0,options:I},h=I.errors==="all",E=I.onExcessProperty==="error",k=I.onExcessProperty==="preserve",T;if(!s&&(E||k)){i??=new Set(r),T=Reflect.ownKeys(C);for(let N=0;N<T.length;N++){let R=T[N];if(!i.has(R))if(E){let z=new $h(n,C[R],I),q=new Ft([R],z);if(h){if(y.issues)y.issues.push(q);else y.issues=[q];continue}else return yield*A(new Et(n,[q],x,I))}else U(S,R,C[R])}}let F=gv(I?.concurrency);if(o){let N=DM(y,a,F);if(N)yield*N}if(s&&!F)for(let N=0;N<s;N++){let R=c[N],z=R.is.parameter===Po?f:l,q=R.is.parameter===Po?Object.keys(C):La(C,R.is.parameter,I);for(let ue=0;ue<q.length;ue++){let ut=z(y,q[ue],R);if(!We(ut))yield*ut;else if(ut._tag==="Failure")return yield*ut}}else if(d){let N=fa();for(let z=0;z<s;z++){let q=c[z],ue=La(C,q.is.parameter,I);for(let ut=0;ut<ue.length;ut++)N.push([ue[ut],q])}let R=d(y,N,F);if(R)yield*R}if(y.issues)return yield*A(new Et(n,y.issues,x,I));if(I.propertyOrder==="original"){let N=(T??Reflect.ownKeys(C)).concat(r),R={};for(let z of N)if(Object.hasOwn(S,z))U(R,z,S[z]);return R}return S});if(s)return g;let b=(x,I,C)=>{let S=a[I];return ne(bi(C),(y)=>{let h=sv(x,S,y);if(h)return h;let E=()=>Dr(x.out),k=DM(x,a.slice(I+1));return k?on(k,E):E()})};return(x,I)=>{if(x===Re)return no;if(I.errors==="all"||I.onExcessProperty!==void 0||I.propertyOrder==="original"||I.concurrency!==void 0)return g(x,I);if(!(typeof x==="object"&&x!==null&&!Array.isArray(x)))return A(new ft(n,x,I));let C=m(),S=x,y={},h={ast:n,input:S,out:y,issues:void 0,options:I};try{for(let E=0;E<C.length;E++){let k=C[E],T=k.name,F=Object.hasOwn(S,T),N=F?S[T]:Re,R=k.parser(N,I);if(!We(R))return b(h,E,R);if(R===Dt){if(F)U(y,T,N);continue}let z=sv(h,k,R);if(z)return z}}catch(E){return ko(E)}return Dr(y)}}_rebuild(e,t,n,r){let o=Pu(this.propertySignatures,(i)=>{let a=e(i.type);return a===i.type?i:new ng(i.name,a)}),s=Pu(this.indexSignatures,(i)=>{let a=t(i.parameter),c=e(i.type);return a===i.parameter&&c===i.type?i:new rg(a,c)});return o===this.propertySignatures&&s===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Mu(o,s,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){if(this.propertySignatures.length===0&&this.indexSignatures.length===0)return"object | array";return"object"}};DM=uf()({onItem(e,t){if(!Object.hasOwn(e.input,t.name))return t.parser(Re,e.options);let n=e.input[t.name];return U(e.out,t.name,n),t.parser(n,e.options)},step:sv});ig=Ji((e)=>{while(!0){if(B6(e))return Rs;let t=e.encoding;if(!t)return e.recur?.(ig,D)??e;if(t.some((n)=>n.transformation._tag==="Middleware"&&n.transformation.decode!==D))return Rs;e=t[t.length-1].to}});$M=new WeakMap,fd=Object.freeze([]);Fn=class Fn extends wt{_tag="Union";types;mode;encodingChecks;constructor(e,t,n,r,o,s,i){super(n,r,o,s);this.types=e,this.mode=t,this.encodingChecks=i}getParser(e,t){let n=this;return(r,o)=>{if(r===Re)return no;let s=md(r,n.types,t!==void 0);if(s.length===1){let u=e(s[0])(r,o);if(u._tag==="Success")return u;return We(u)?UM(n,u.cause,r,o):xr(u,(l)=>UM(n,l,r,o))}let i={ast:n,compile:e,input:r,out:void 0,successes:n.mode==="oneOf"?[]:void 0,issues:void 0,options:o},a=gv(o?.concurrency),c=K6(i,s,a?{...a,orderedStep:!0}:void 0);if(!c){if(i.out)return i.out;return A(new sd(n,i.issues??[],r,o))}return on(c,(u)=>{if(i.out===Dt)return v(r);if(i.out)return i.out;return A(new sd(n,i.issues??[],r,o))})}}_rebuild(e,t,n){let r=Pu(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new Fn(r,this.mode,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}return}getExpected(e){let t=this.annotations?.expected;if(typeof t==="string")return t;if(this.types.length===0)return"never";let n=this.types.map((r)=>{let o=Jn(r);switch(o._tag){case"Arrays":{let s=o.elements.filter(_u);if(s.length>0)return`${LM(o.isMutable)}[ ${s.map((i)=>e(i)+jM(i.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let s=o.propertySignatures.filter((i)=>_u(i.type));if(s.length>0)return`{ ${s.map((i)=>`${LM(i.type.context?.isMutable)}${Go(i.name)}${jM(i.type.context?.isOptional)}: ${e(i.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(n)).join(" | ")}};K6=uf()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag==="Failure"){let r=id(n.cause);if(r===void 0)return n;if(e.issues)e.issues.push(r);else e.issues=[r]}else{if(e.out&&e.successes)return e.successes.push(t),Rr(new kw(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return fr}}}),p1=new Fn([new Er("Infinity"),new Er("-Infinity"),new Er("NaN")],"anyOf");ag=class ag extends wt{_tag="Suspend";thunk;constructor(e,t,n,r,o){if(n)throw Error("Cannot add checks to Suspend");super(t,void 0,r,o);this.thunk=Ha(e)}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new ag(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}};dd=class dd extends Gi{_tag="Filter";run;annotations;aborted;constructor(e,t=void 0,n=!1){super();this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new dd(this.run,{...this.annotations,...e},this.aborted)}abort(){return new dd(this.run,this.annotations,!0)}and(e,t){return new Pi([this,e],t)}};Pi=class Pi extends Gi{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super();this.checks=e,this.annotations=t}annotate(e){return new Pi(this.checks,{...this.annotations,...e})}and(e,t){return new Pi([this,e],t)}};Ev=Fo(hv,[Sv()]),V6=new dt(new Fn([Ev,p1],"anyOf"),new Pe(zh(),ve((e)=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));m1=new WeakMap;Du=Ji((e)=>{let t=e.context?e.context.isOptional===!1?new so(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new so(!0,!1);return G6(xd(e,t))}),G6=wv(Du),S1=Qt((e)=>Du(new Fn([e,fv],"anyOf"))),kv=Ji((e)=>{let t=e.context?e.context.isMutable===!1?new so(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new so(!1,!0);return J6(xd(e,t))}),J6=wv(kv);sn=Ji((e)=>{if(e.encoding)return sn(Ge(e,void 0));let t=e,n=t.recur?.(sn)??t,r=n.encodingChecks;if(r){let o=n===e?r:uv(n)||j6(n)||Mi(n)&&n.typeParameters.length>0?Y6(r):void 0;return gd(n,(s)=>{s.encodingChecks.value=void 0,s.checks.value=xv(n.checks,o)})}return n}),Jn=Ji((e)=>sn(oo(e)));oo=Qt((e)=>{if(e.encoding)return Q6(e,e.encoding);let t=e;return t.flip?.(oo)??t.recur?.(oo)??t});I1=Qt((e)=>new Fn(e.enums.map((t)=>new Er(t[1],{title:t[0]})),"anyOf")),Iv=qa((e)=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(Iv)}}),mg=qa((e)=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(mg)}}),C1=qa((e)=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(C1)}}),iv=new globalThis.RegExp(`^${tg}$`),X6=new globalThis.RegExp(`^(?:${tg}|Infinity|-Infinity|NaN)$`);O1=Fo(Po,[Cv()]),e5=new dt(O1,Au),t5=new dt(new Fn([O1,p1],"anyOf"),Au),av=new globalThis.RegExp(`^${n5}$`);Ov=Fo(Po,[Tv({expected:"a string representing a bigint"})]),r5=new dt(Ov,Qh),cv=new globalThis.RegExp(`^${o5}$`),s5=Fo(Po,[Av()]),A1=new dt(s5,new Pe(ve((e)=>globalThis.Symbol.for(cv.exec(e)[1])),Vn((e,t)=>{if(globalThis.Symbol.keyFor(e)!==void 0)return v(globalThis.String(e));return A(new Tu({message:"cannot serialize to string, Symbol is not registered"},e,t))})));Fu=new Ba([],()=>(e,t,n)=>$u(e)?Dt:A(new ft(t,e,n)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{return},toCodecStringTree:()=>Rv,toArbitrary:()=>(e)=>e.jsonValue()}),F1=Ur(Fu,{representation:{id:"effect/schema/MutableJson",payload:null}}),_v=new dt(Fu,Ou()),M1=new dt(new Fn([new io(!1,[],[Fu]),new Mu([],[new rg(Po,Fu)])],"anyOf"),Ou());u5=new Ba([],()=>(e,t,n)=>c5(e)?Dt:A(new ft(t,e,n)),{expected:"StringTree",toCodecStringTree:()=>{return}}),Rv=new dt(u5,Ou())});function Pv(){return Object.assign((e)=>e,{option:(e)=>_(e),result:(e)=>G(e),is:(e)=>!0})}var N1=w(()=>{_e();gn()});var $1,U1,D1="~effect/ChildProcessSpawner/ChildProcessHandle",f5,Fv=(e)=>Object.setPrototypeOf({...e},f5),L1=(e)=>{let t=(r,o)=>e(r).pipe(oe((s)=>sF(o?.includeStderr===!0?s.all:s.stdout)),Ii),n=(r,o)=>iF(t(r,o));return Uu.of({spawn:e,exitCode:(r)=>vi(ne(e(r),(o)=>o.exitCode)),streamString:t,streamLines:n,lines:(r,o)=>aF(n(r,o)),string:(r,o)=>cF(t(r,o))})},Uu;var Mv=w(()=>{N1();Ve();Oe();jn();vu();$1=Pv(),U1=Pv(),f5={[D1]:D1,...G0,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}};Uu=class Uu extends ze()("effect/process/ChildProcessSpawner"){}});var j1="~effect/unstable/process/ChildProcess",d5,hg=(e,t,n)=>Object.assign(Object.create(d5),{_tag:"StandardCommand",command:e,args:t,options:n}),gg=function(...t){if(B1(t[0])){let[s,...i]=t,a=H1(s,i);return hg(a[0]??"",a.slice(1),{})}if(typeof t[0]==="object"&&!Array.isArray(t[0])&&!B1(t[0])){let s=t[0];return function(i,...a){let c=H1(i,a);return hg(c[0]??"",c.slice(1),s)}}if(typeof t[0]==="string"&&!Array.isArray(t[1])){let[s,i={}]=t;return hg(s,[],i)}let[n,r=[],o={}]=t;return hg(n,r,o)},B1=(e)=>Array.isArray(e)&&("raw"in e)&&Array.isArray(e.raw),xg=(e)=>{let t=/^fd(\d+)$/.exec(e);if(t===null)return;let n=parseInt(t[1],10);return n>=3?n:void 0},K1=(e)=>`fd${e}`,H1=(e,t)=>{let n=[];for(let[r,o]of e.entries())n=p5(e,t,n,o,r);return n},p5=(e,t,n,r,o)=>{let s=e.raw[o];if(s===void 0)throw Error(`Invalid backslash sequence: ${e.raw[o]}`);let{hasLeadingWhitespace:i,hasTrailingWhitespace:a,tokens:c}=h5(r,s),u=W1(n,c,i);if(o===t.length)return u;let l=t[o],f=Array.isArray(l)?l.map((d)=>q1(d)):[q1(l)];return W1(u,f,a)},q1=(e)=>{if(typeof e==="string")return e;return String(e)},z1,m5,h5=(e,t)=>{if(t.length===0)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let n=z1.has(t[0]),r=[],o=0;for(let i=0,a=0;i<e.length;i+=1,a+=1){let c=t[a];if(z1.has(c)){if(o!==i)r.push(e.slice(o,i));o=i+1}else if(c==="\\"){let u=t[a+1];if(u===`
|
|
33
|
-
`)i-=1,a+=1;else if(u==="u"&&t[a+2]==="{")a=t.indexOf("}",a+3);else a+=
|
|
34
|
-
`]),m5={x:3,u:5}});var G1=(e,t,n)=>{let r=e.detached??n!=="win32";return{...t,detached:r,shell:e.shell,windowsHide:e.windowsHide??!r}};var He=(e,t)=>(n,[r])=>{let o="Unknown";switch(n.code){case"ENOENT":o="NotFound";break;case"EACCES":o="PermissionDenied";break;case"EEXIST":o="AlreadyExists";break;case"EISDIR":o="BadResource";break;case"ENOTDIR":o="BadResource";break;case"EBUSY":o="Busy";break;case"ELOOP":o="BadResource";break}return Nr({_tag:o,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,cause:n})};var Nv=w(()=>{Oo()});var Lu=(e)=>iw(rw(x5(e),(t)=>[t])),x5=(e)=>Sn((t)=>{let n=e.evaluate();return v(y5({...e,writable:n,pull:t}))}),y5=(e)=>e.pull.pipe(ne((t)=>{let n=0;return yn(function r(o){for(;n<t.length;)if(!e.writable.write(t[n++],e.encoding)){e.writable.once("drain",()=>r(o));return}o(Te)})}),Co({disableYield:!0}),_a(yn((t)=>{let n=(r)=>t(A(e.onError(r)));return e.writable.once("error",n),Se(()=>{e.writable.off("error",n)})})),e.endOnDone!==!1?mr((t)=>{if("closed"in e.writable&&e.writable.closed)return _t(t);return yn((n)=>{e.writable.once("finish",()=>n(_t(t))),e.writable.end()})}):D);var Dv=w(()=>{rn();Jf();Oe();X();Ca();Oh()});var ju=(e)=>to(E5(e)),E5=(e)=>Sn((t,n)=>b5({scope:n,readable:e.evaluate(),onError:e.onError??w5,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),b5=(e)=>{let t=e.readable,n=e.closeOnDone??!0,r=e.exit??hP(void 0),o=dP(!1);function s(){o.openUnsafe()}function i(u){r.current=Rr(e.onError(u)),o.openUnsafe()}function a(){r.current=Rr(gf()),o.openUnsafe()}t.on("readable",s),t.once("error",i),t.once("end",a);let c=Ne(function u(){let l=e.readable.read(e.chunkSize);if(l===null){if(r.current)return r.current;if(t.readableEnded)return A(gf());return o.closeUnsafe(),ne(o.await,u)}let f=da(l);while(!0){if(l=e.readable.read(e.chunkSize),l===null)break;f.push(l)}return v(f)});return gr(Ef(e.scope,Se(()=>{if(t.off("readable",s),t.off("error",i),t.off("end",a),n&&"closed"in e.readable&&!e.readable.closed)e.readable.destroy()})),c)},w5=(e)=>new ZE(e);var $v=w(()=>{An();rn();Jf();Oe();dr();pP();gP();bf();vu()});import*as yg from"child_process";import{PassThrough as Uv}from"stream";var za=(e)=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),Mo=(e,t,n)=>{let{commands:r}=Y1(n),o=r.reduce((s,i)=>{let a=`${i.command} ${i.args.join(" ")}`;return s.length===0?a:`${s} | ${a}`},"");return He("ChildProcess",e)(t,[o])},J1=(e,t=()=>{})=>yg.execFile("taskkill",["/pid",String(e.pid),"/T","/F"],{windowsHide:!0},t),k5,Z1,Y1=(e)=>{let t=[],n=[],r=(a)=>{switch(a._tag){case"StandardCommand":{t.push(a);break}case"PipedCommand":{r(a.left),n.push(a.options),r(a.right);break}}};if(r(e),t.length===0)throw Error("flattenCommand produced empty commands array");let[o,...s]=t;return{commands:[o,...s],pipeOptions:n}};var Q1=w(()=>{eb();Oe();dr();Rh();wo();Ph();he();Oh();vu();V1();Mv();Nv();Dv();$v();k5=qt(function*(){let e=yield*Ci,t=yield*Ao,n=H(function*(y){if(Gs(y.cwd))return;return yield*e.access(y.cwd),t.resolve(y.cwd)}),r=(y)=>y.extendEnv?{...globalThis.process.env,...y.env}:y.env,o=(y)=>Fa(y)?"pipe":y,s=(y)=>Zf(y)?"pipe":y,i=(y)=>{let h={stream:"pipe",encoding:"utf-8",endOnDone:!0};if(Gs(y.stdin))return h;if(typeof y.stdin==="string")return{...h,stream:y.stdin};if(Fa(y.stdin))return{...h,stream:y.stdin};return{stream:y.stdin.stream,encoding:y.stdin.encoding??h.encoding,endOnDone:y.stdin.endOnDone??h.endOnDone}},a=(y,h)=>{let E=y[h];if(Gs(E))return{stream:"pipe"};if(typeof E==="string")return{stream:E};if(Zf(E))return{stream:E};return{stream:E.stream}},c=(y)=>{if(Gs(y.additionalFds))return[];let h=[];for(let[E,k]of Object.entries(y.additionalFds)){let T=xg(E);if(Le(T))h.push({fd:T,config:k})}return h.sort((E,k)=>E.fd-k.fd)},u=(y,h,E,k)=>{let T=[o(y.stream),s(h.stream),s(E.stream)];if(k.length===0)return T;let F=k.reduce((N,{fd:R})=>Math.max(N,R),2);for(let N=3;N<=F;N++)T[N]="ignore";for(let{fd:N}of k)T[N]="pipe";return T},l=H(function*(y,h,E){if(E.length===0)return{getInputFd:()=>Yf,getOutputFd:()=>wu};let k=new Map,T=new Map;for(let{config:F,fd:N}of E){let R=h.stdio[N];switch(F.type){case"input":{let z=Yf;if(R&&"write"in R)z=Lu({evaluate:()=>R,onError:(q)=>Mo(`fromWritable(fd${N})`,za(q),y)});if(F.stream)yield*xu(dw(F.stream,z));k.set(N,z);break}case"output":{let z=wu;if(R&&"read"in R){let q=new Uv;R.on("error",(ue)=>q.destroy(ue)),R.pipe(q),z=ju({evaluate:()=>q,onError:(ue)=>Mo(`fromReadable(fd${N})`,za(ue),y)})}if(F.sink)z=Ah(z,F.sink);T.set(N,z);break}}}return{getInputFd:(F)=>k.get(F)??Yf,getOutputFd:(F)=>T.get(F)??wu}}),f=(y,h,E)=>Ne(()=>{let k=Yf;if(wl(h.stdin))k=Lu({evaluate:()=>h.stdin,onError:(T)=>Mo("fromWritable(stdin)",za(T),y),endOnDone:E.endOnDone,encoding:E.encoding});if(Fa(E.stream))return gr(xu(dw(E.stream,k)),k);return v(k)}),d=(y,h,E,k)=>{let T=h.stdout?(()=>{let R=new Uv;return h.stdout.on("error",(z)=>R.destroy(z)),h.stdout.pipe(R),ju({evaluate:()=>R,onError:(z)=>Mo("fromReadable(stdout)",za(z),y)})})():wu,F=h.stderr?(()=>{let R=new Uv;return h.stderr.on("error",(z)=>R.destroy(z)),h.stderr.pipe(R),ju({evaluate:()=>R,onError:(z)=>Mo("fromReadable(stderr)",za(z),y)})})():wu;if(Zf(E.stream))T=Ah(T,E.stream);if(Zf(k.stream))F=Ah(F,k.stream);let N=oF(T,F);return{stdout:T,stderr:F,all:N}},m=(y,h)=>yn((E)=>{let k=Wm(),T=yg.spawn(y.command,y.args,h);return T.on("error",(F)=>{E(A(Mo("spawn",F,y)))}),T.on("exit",(...F)=>{XE(k,_r(F))}),T.on("spawn",()=>{E(v([T,k]))}),Se(()=>{T.kill("SIGTERM")})}),g=(y,h,E)=>{if(globalThis.process.platform==="win32")return yn((k)=>{J1(h,(T)=>{if(T)k(A(Mo("kill",za(T),y)));else k(Te)})});return Nt({try:()=>{globalThis.process.kill(-h.pid,E)},catch:(k)=>Mo("kill",za(k),y)})},b=(y,h)=>{if(globalThis.process.platform==="win32"){J1(y);return}try{globalThis.process.kill(-y.pid,h)}catch{}},x=(y,h,E)=>Ne(()=>{if(!h.kill(E)){let T=new globalThis.Error("Failed to kill child process");return A(Mo("kill",T,y))}return Te}),I=(y,h,E)=>(k)=>{let T=E?.killSignal??"SIGTERM";return Gs(E?.forceKillAfter)?k(h,y,T):Bb(k(h,y,T),{duration:E.forceKillAfter,orElse:()=>k(h,y,"SIGKILL")})},C=(y,h)=>{let E=h??"stdout";switch(E){case"stdout":return y.stdout;case"stderr":return y.stderr;case"all":return y.all;default:{let k=xg(E);if(Le(k))return y.getOutputFd(k);return y.stdout}}},S=H(function*(y){switch(y._tag){case"StandardCommand":{let h=i(y.options),E=a(y.options,"stdout"),k=a(y.options,"stderr"),T=c(y.options),F=!0,N=yield*n(y.options),R=r(y.options),z=u(h,E,k,T),[q,ue]=yield*Mr(m(y,G1(y.options,{cwd:N,env:R,stdio:z},process.platform)),H(function*([Hr,Ec]){let bc=yield*QE(Ec),xl=I(Hr,y,y.options);if(bc){let[Vs]=yield*va(Ec);if(Vs!==0&&wl(Vs))return yield*Nf(xl(g));return yield*Te}if(!F)return yield*Te;return yield*xl((Vs,D0,$0)=>g(Vs,D0,$0).pipe(Pr(()=>x(Vs,D0,$0)),hr(va(Ec)))).pipe(Nf)})),ut=U1(q.pid);q.on("exit",(Hr)=>{if(Hr!==0&&wl(Hr))b(q,y.options.killSignal??"SIGTERM")});let Ks=Se(()=>{if(!F)q.ref(),F=!0}),gl=Se(()=>{if(F)q.unref(),F=!1;return Ks}),kp=yield*f(y,q,h),{all:Ip,stderr:wy,stdout:vy}=d(y,q,E,k),{getInputFd:Oq,getOutputFd:Aq}=yield*l(y,q,T),_q=oe(QE(ue),(Hr)=>!Hr),Rq=ne(va(ue),([Hr,Ec])=>{if(wl(Hr))return v($1(Hr));let bc=new globalThis.Error(`Process interrupted due to receipt of signal: '${Ec}'`);return A(Mo("exitCode",bc,y))});return Fv({pid:ut,exitCode:Rq,isRunning:_q,kill:(Hr)=>I(q,y,Hr)((bc,xl,Vs)=>g(bc,xl,Vs).pipe(Pr(()=>x(bc,xl,Vs)),hr(va(ue)))).pipe(Ff),stdin:kp,stdout:vy,stderr:wy,all:Ip,getInputFd:Oq,getOutputFd:Aq,unref:gl})}case"PipedCommand":{let{commands:h,pipeOptions:E}=Y1(y),[k,...T]=h,F=[yield*S(k)];for(let q=0;q<T.length;q++){let ue=T[q],ut=E[q]??{},Ks=i(ue.options),gl=Ii(v(C(F[F.length-1],ut.from))),kp=ut.to??"stdin";if(kp==="stdin")F.push(yield*S(gg(ue.command,ue.args,{...ue.options,stdin:{...Ks,stream:gl}})));else{let Ip=xg(kp);if(Le(Ip)){let wy=K1(Ip),vy=ue.options.additionalFds??{};F.push(yield*S(gg(ue.command,ue.args,{...ue.options,additionalFds:{...vy,[wy]:{type:"input",stream:gl}}})))}else F.push(yield*S(gg(ue.command,ue.args,{...ue.options,stdin:{...Ks,stream:gl}})))}}let N=F[F.length-1],R=(q)=>Oa([...F].reverse(),(ue)=>Nf(ue.kill(q)),{discard:!0}),z=qt(function*(){let q=[];for(let ue of F)q.push(yield*ue.unref);return Oa([...q].reverse(),(ue)=>ue,{discard:!0})});return Fv({pid:N.pid,exitCode:N.exitCode,isRunning:N.isRunning,kill:R,stdin:N.stdin,stdout:N.stdout,stderr:N.stderr,all:N.all,getInputFd:N.getInputFd,getOutputFd:N.getOutputFd,unref:z})}}});return L1(S)}),Z1=su(Uu,k5)});var X1=w(()=>{Q1()});function eN(e=rN()){return e[6]=e[6]&15|64,e[8]=e[8]&63|128,e}function tN(e,t=rN()){let n=Math.min(Math.max(0,Math.trunc(e)),T5);return t[0]=Math.floor(n/1099511627776),t[1]=Math.floor(n/4294967296)&255,t[2]=Math.floor(n/16777216)&255,t[3]=Math.floor(n/65536)&255,t[4]=Math.floor(n/256)&255,t[5]=n&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128,t}var C5=(e)=>e.toString(16).padStart(2,"0"),nN=(e)=>[e.subarray(0,4),e.subarray(4,6),e.subarray(6,8),e.subarray(8,10),e.subarray(10,16)].map((n)=>Array.from(n,C5).join("")).join("-"),rN=()=>globalThis.crypto.getRandomValues(new Uint8Array(16)),oN=(e)=>nN(e===void 0?eN():eN(e)),T5=281474976710655,sN=(e,t)=>nN(t===void 0?tN(e):tN(e,t));var iN="~effect/platform/Crypto",Lv,aN=(e)=>{let t=e.randomBytes,n=(i)=>oe(A5("randomBytes",i),t),r=(i)=>(i[0]&31)*281474976710656+i[1]*1099511627776+i[2]*4294967296+i[3]*16777216+i[4]*65536+i[5]*256+i[6],o=()=>r(t(7))/9007199254740992,s=()=>{while(!0){let i=t(7),a=r(i);if((i[0]&32)===0)return a+Number.MIN_SAFE_INTEGER;if(a<Number.MAX_SAFE_INTEGER)return a+1}};return Lv.of({[iN]:iN,randomBytes:n,nextDoubleUnsafe:o,nextIntUnsafe:s,digest:e.digest,random:Se(()=>o()),randomBoolean:Se(()=>o()>0.5),randomInt:Se(()=>s()),randomBetween:(i,a)=>Se(()=>o()*(a-i)+i),randomIntBetween(i,a,c){let u=c?.halfOpen===!0?0:1;return Se(()=>{let l=Math.ceil(i),f=Math.floor(a);return Math.floor(o()*(f-l+u))+l})},randomShuffle:(i)=>Se(()=>{let a=Array.from(i);for(let c=a.length-1;c>=1;c=c-1){let u=Math.min(c,Math.floor(o()*(c+1))),l=a[c];a[c]=a[u],a[u]=l}return a}),randomUUIDv4:Se(()=>oN(t(16))),randomUUIDv7:jf((i)=>v(sN(i.currentTimeMillisUnsafe(),t(16))))})},A5=(e,t)=>Number.isSafeInteger(t)&&t>=0?v(t):A(bs({module:"Crypto",method:e,description:"size must be a non-negative safe integer"}));var cN=w(()=>{Ve();Oe();Oo();Lv=ze("effect/Crypto")});import*as Sg from"crypto";var R5=(e)=>{switch(e){case"SHA-1":return"sha1";case"SHA-256":return"sha256";case"SHA-384":return"sha384";case"SHA-512":return"sha512"}},P5=(e,t)=>Nt({try:()=>Uint8Array.from(Sg.createHash(R5(e)).update(t).digest()),catch:(n)=>Nr({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:n})}),F5,uN;var lN=w(()=>{cN();Oe();wo();Oo();F5=aN({randomBytes:Sg.randomBytes,digest:P5}),uN=Si(Lv,F5)});var fN;var dN=w(()=>{lN();fN=uN});import*as pN from"crypto";import*as ee from"fs";import*as mN from"os";import*as Bu from"path";var it=(e)=>(t)=>bs({module:"FileSystem",method:e,description:t.message??String(t)}),D5,$5,U5,L5,j5,B5,H5,q5,jv=(e)=>{let t=ot(ee.mkdtemp,He("FileSystem",e),it(e));return(n)=>Ne(()=>{let r=n?.prefix??"",o=typeof n?.directory==="string"?Bu.join(n.directory,"."):mN.tmpdir();return t(r?Bu.join(o,r):o+"/")})},z5,Bv=(e)=>{let t=ot(ee.rm,He("FileSystem",e),it(e));return(n,r)=>t(n,{recursive:r?.recursive??!1,force:r?.force??!1})},W5,K5,V5=(e)=>{let t=ot(ee.open,He("FileSystem",e),it(e)),n=ot(ee.close,He("FileSystem",e),it(e));return(r,o)=>zr(Mr(t(r,o?.flag??"r",o?.mode),(s)=>Fr(n(s))),oe((s)=>J5(s,o?.flag?.startsWith("a")??!1)))},G5,J5,hN=(e)=>{let t=jv(e);return H(function*(n){let r=yield*t(n),o=pN.randomBytes(6).toString("hex"),s=Bu.join(r,n?.suffix?`${o}${n.suffix}`:o);return yield*xN(s,new Uint8Array(0)),s})},Z5,Y5,Q5=(e,t)=>lu({try:()=>ee.promises.readdir(e,t),catch:(n)=>He("FileSystem","readDirectory")(n,[e])}),X5=(e)=>yn((t,n)=>{try{ee.readFile(e,{signal:n},(r,o)=>{if(r)t(A(He("FileSystem","readFile")(r,[e])));else t(v(o))})}catch(r){t(A(it("readFile")(r)))}}),eZ,tZ,nZ,gN=(e)=>({type:e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",mtime:Tn(e.mtime),atime:Tn(e.atime),birthtime:Tn(e.birthtime),dev:e.dev,rdev:Tn(e.rdev),ino:Tn(e.ino),mode:e.mode,nlink:Tn(e.nlink),uid:Tn(e.uid),gid:Tn(e.gid),size:Cs(e.size),blksize:e.blksize!==void 0?_(Cs(e.blksize)):O(),blocks:Tn(e.blocks)}),Hv,rZ,oZ,sZ,iZ=(e,t)=>nF((n)=>Mr(Se(()=>{let r=ee.watch(e,{recursive:t?.recursive??!1},(o,s)=>{if(!s)return;switch(o){case"rename":{To(uh(Hv(s),{onSuccess:(i)=>zf(n,{_tag:"Create",path:s}),onFailure:(i)=>zf(n,{_tag:"Remove",path:s})}));return}case"change":{Wf(n,{_tag:"Update",path:s});return}}});return r.on("error",(o)=>{Vf(n,GE(Nr({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:e,cause:o})))}),r.on("close",()=>{ks(n)}),r}),(r)=>Se(()=>r.close()))),aZ=(e,t,n)=>Hv(t).pipe(oe((r)=>e.pipe(rs((o)=>o.register(t,r,n)),mt(()=>iZ(t,n)))),Ii),xN=(e,t,n)=>yn((r,o)=>{try{ee.writeFile(e,t,{signal:o,flag:n?.flag,mode:n?.mode},(s)=>{if(s)r(A(He("FileSystem","writeFile")(s,[e])));else r(Te)})}catch(s){r(A(it("writeFile")(s)))}}),cZ,yN;var SN=w(()=>{rn();Oe();Oe();Rh();X();wo();_e();Oo();Gf();vu();Nv();D5=(()=>{let e=ot(ee.access,He("FileSystem","access"),it("access"));return(t,n)=>{let r=ee.constants.F_OK;if(n?.readable)r|=ee.constants.R_OK;if(n?.writable)r|=ee.constants.W_OK;return e(t,r)}})(),$5=(()=>{let e=ot(ee.cp,He("FileSystem","copy"),it("copy"));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),U5=(()=>{let e=ot(ee.copyFile,He("FileSystem","copyFile"),it("copyFile"));return(t,n)=>e(t,n)})(),L5=(()=>{let e=ot(ee.chmod,He("FileSystem","chmod"),it("chmod"));return(t,n)=>e(t,n)})(),j5=(()=>{let e=ot(ee.chown,He("FileSystem","chown"),it("chown"));return(t,n,r)=>e(t,n,r)})(),B5=(()=>{let e=ot(ee.glob,He("FileSystem","glob"),it("glob"));return(t,n)=>e(t,{cwd:n?.root,exclude:n?.exclude})})(),H5=(()=>{let e=ot(ee.link,He("FileSystem","link"),it("link"));return(t,n)=>e(t,n)})(),q5=(()=>{let e=ot(ee.mkdir,He("FileSystem","makeDirectory"),it("makeDirectory"));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),z5=jv("makeTempDirectory"),W5=Bv("remove"),K5=(()=>{let e=jv("makeTempDirectoryScoped"),t=Bv("makeTempDirectoryScoped");return(n)=>Mr(e(n),(r)=>Fr(t(r,{recursive:!0})))})(),G5=V5("open"),J5=(()=>{let e=(l)=>ot(ee.read,He("FileSystem",l),it(l)),t=e("read"),n=e("readAlloc"),r=ot(ee.fstat,He("FileSystem","stat"),it("stat")),o=ot(ee.ftruncate,He("FileSystem","truncate"),it("truncate")),s=ot(ee.fsync,He("FileSystem","sync"),it("sync")),i=(l)=>ot(ee.write,He("FileSystem",l),it(l)),a=i("write"),c=i("writeAll");class u{[_h];fd;append;position=BigInt(0);constructor(l,f){this[_h]=_h,this.fd=l,this.append=f}get stat(){return oe(r(this.fd),gN)}get sync(){return s(this.fd)}seek(l,f){let d=Cs(l);return Se(()=>{if(f==="start")this.position=d;else if(f==="current")this.position=this.position+d;return Cs(this.position)})}read(l){return Ne(()=>{let f=this.position;return oe(t(this.fd,{buffer:l,position:f}),(d)=>{let m=Cs(d);return this.position=f+m,m})})}readAlloc(l){let f=Number(l);return Ne(()=>{let d=Buffer.allocUnsafeSlow(f),m=this.position;return oe(n(this.fd,{buffer:d,position:m}),(g)=>{if(g===0)return O();if(this.position=m+BigInt(g),g===f)return _(d);let b=Buffer.allocUnsafeSlow(g);return d.copy(b,0,0,g),_(b)})})}truncate(l){return oe(o(this.fd,l?Number(l):void 0),()=>{if(!this.append){let f=BigInt(l??0);if(this.position>f)this.position=f}})}write(l){return Ne(()=>{let f=this.position;return oe(a(this.fd,l,void 0,void 0,this.append?void 0:Number(f)),(d)=>{let m=Cs(d);if(!this.append)this.position=f+m;return m})})}writeAllChunk(l){return Ne(()=>{let f=this.position;return ne(c(this.fd,l,void 0,void 0,this.append?void 0:Number(f)),(d)=>{if(d===0)return A(Nr({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"}));if(!this.append)this.position=f+BigInt(d);return d<l.length?this.writeAllChunk(l.subarray(d)):Te})})}writeAll(l){return this.writeAllChunk(l)}}return(l,f)=>new u(l,f)})(),Z5=hN("makeTempFile"),Y5=(()=>{let e=hN("makeTempFileScoped"),t=Bv("makeTempFileScoped");return(n)=>Mr(e(n),(r)=>Fr(t(Bu.dirname(r),{recursive:!0})))})(),eZ=(()=>{let e=ot(ee.readlink,He("FileSystem","readLink"),it("readLink"));return(t)=>e(t)})(),tZ=(()=>{let e=ot(ee.realpath,He("FileSystem","realPath"),it("realPath"));return(t)=>e(t)})(),nZ=(()=>{let e=ot(ee.rename,He("FileSystem","rename"),it("rename"));return(t,n)=>e(t,n)})(),Hv=(()=>{let e=ot(ee.stat,He("FileSystem","stat"),it("stat"));return(t)=>oe(e(t),gN)})(),rZ=(()=>{let e=ot(ee.symlink,He("FileSystem","symlink"),it("symlink"));return(t,n)=>e(t,n)})(),oZ=(()=>{let e=ot(ee.truncate,He("FileSystem","truncate"),it("truncate"));return(t,n)=>e(t,n!==void 0?Number(n):void 0)})(),sZ=(()=>{let e=ot(ee.utimes,He("FileSystem","utime"),it("utime"));return(t,n,r)=>e(t,n,r)})(),cZ=oe(fh(pw),(e)=>lF({access:D5,chmod:L5,chown:j5,copy:$5,copyFile:U5,glob:B5,link:H5,makeDirectory:q5,makeTempDirectory:z5,makeTempDirectoryScoped:K5,makeTempFile:Z5,makeTempFileScoped:Y5,open:G5,readDirectory:Q5,readFile:X5,readLink:eZ,realPath:tZ,remove:W5,rename:nZ,stat:Hv,symlink:rZ,truncate:oZ,utimes:sZ,watch(t,n){return aZ(e,t,n)},writeFile:xN})),yN=su(Ci)(cZ)});var EN;var bN=w(()=>{SN();EN=yN});import*as Ed from"path";import*as Eg from"url";var qv=(e)=>({fromFileUrl:(t)=>Nt({try:()=>Eg.fileURLToPath(t,{windows:e}),catch:(n)=>new Es({module:"Path",method:"fromFileUrl",cause:n})}),toFileUrl:(t)=>Nt({try:()=>Eg.pathToFileURL(t,{windows:e}),catch:(n)=>new Es({module:"Path",method:"toFileUrl",cause:n})})}),fZ,dZ,wN;var vN=w(()=>{Oe();wo();Ph();Oo();fZ=Si(Ao)({[Ts]:Ts,...Ed.posix,...qv(!1)}),dZ=Si(Ao)({[Ts]:Ts,...Ed.win32,...qv(!0)}),wN=Si(Ao)({[Ts]:Ts,...Ed,...qv(void 0)})});var kN;var IN=w(()=>{vN();kN=wN});var zv="~effect/Stdio",bg,CN=(e)=>({[zv]:zv,stdinIsTerminal:v(!1),stdoutIsTerminal:v(!1),...e});var Wv=w(()=>{Ve();Oe();bg=ze(zv)});var ON;var AN=w(()=>{Oe();wo();Oo();Wv();Dv();$v();ON=Si(bg,CN({args:Se(()=>process.argv.slice(2)),stdinIsTerminal:Se(()=>process.stdin.isTTY===!0),stdoutIsTerminal:Se(()=>process.stdout.isTTY===!0),stdout:(e)=>Lu({evaluate:()=>process.stdout,onError:(t)=>Nr({module:"Stdio",method:"stdout",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stderr:(e)=>Lu({evaluate:()=>process.stderr,onError:(t)=>Nr({module:"Stdio",method:"stderr",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stdin:ju({evaluate:()=>process.stdin,onError:(e)=>Nr({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})}))});var _N;var RN=w(()=>{AN();_N=ON});var wg="~effect/collections/Graph",Kv=(e)=>e,xZ=(e,t,n)=>(e==="directed"?t.source===n.source&&t.target===n.target:t.source===n.source&&t.target===n.target||t.source===n.target&&t.target===n.source)&&Y(t.data,n.data),yZ=(e,t)=>e==="directed"?re(t):Js(re(t.data)^re(t.source)+re(t.target)),SZ,PN=(e,t)=>{let n=Object.create(SZ);return n.type=e,n.mutable=t,n.transforming=!1,n.nodes=new Map,n.edges=new Map,n.adjacency=new Map,n.reverseAdjacency=new Map,n.nextNodeIndex=0,n.nextEdgeIndex=0,n.acyclic=_(!0),n},bd=(e)=>{let t=Kv(e);return{type:e.type,nodes:Array.from(t.nodes,([n,r])=>({index:n,data:r})).sort((n,r)=>n.index-r.index),edges:Array.from(t.edges,([n,r])=>({index:n,source:r.source,target:r.target,data:r.data})).sort((n,r)=>n.index-r.index)}},wd=(e)=>{let t=PN(e.type,!1);for(let n of e.nodes)t.nodes.set(n.index,n.data),t.adjacency.set(n.index,[]),t.reverseAdjacency.set(n.index,[]);for(let n of e.edges)if(t.edges.set(n.index,{source:n.source,target:n.target,data:n.data}),t.adjacency.get(n.source).push(n.index),t.reverseAdjacency.get(n.target).push(n.index),e.type==="undirected")t.adjacency.get(n.target).push(n.index),t.reverseAdjacency.get(n.source).push(n.index);return t.nextNodeIndex=e.nodes.length===0?0:e.nodes[e.nodes.length-1].index+1,t.nextEdgeIndex=e.edges.length===0?0:e.edges[e.edges.length-1].index+1,t.acyclic=O(),t};var Vv=w(()=>{yt();Xt();jn();_e();Qe();he();SZ={[wg]:{_N:(e)=>e,_E:(e)=>e},[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[At](){return this.toJSON()},[Ce](e){if(M(e,wg)){let t=Kv(e);if(this.nodes.size!==t.nodes.size||this.edges.size!==t.edges.size||this.type!==t.type)return!1;for(let[n,r]of this.nodes)if(!t.nodes.has(n)||!Y(r,t.nodes.get(n)))return!1;for(let[n,r]of this.edges){let o=t.edges.get(n);if(o===void 0||!xZ(this.type,r,o))return!1}return!0}return!1},[Ie](){let e=qe("Graph");e=e^qe(this.type),e=e^Ln(this.nodes.size),e=e^Ln(this.edges.size);for(let[t,n]of this.nodes)e=e^re(t)+re(n);for(let[t,n]of this.edges)e=e^re(t)+yZ(this.type,n);return e},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return`Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`},pipe(){return le(this,arguments)}}});var EZ,Gv=(e)=>M(e,EZ),MN,bZ;var NN=w(()=>{yt();Xt();Vv();he();EZ=wg;MN=class MN{type;source;target;identity;constructor(e,t,n,r){this.type=e,this.source=t,this.target=n,this.identity=r}[Ce](e){if(!(e instanceof MN)||this.type!==e.type||!Y(this.identity,e.identity))return!1;if(this.type==="directed")return Y(this.source,e.source)&&Y(this.target,e.target);return Y(this.source,e.source)&&Y(this.target,e.target)||Y(this.source,e.target)&&Y(this.target,e.source)}[Ie](){let e=re(this.identity);return this.type==="directed"?xt(re(this.target))(xt(re(this.source))(e)):Js(e^re(this.source)+re(this.target))}};bZ=class bZ{[Symbol.iterator];visit;constructor(e){this.visit=e,this[Symbol.iterator]=()=>e((t,n)=>[t,n])[Symbol.iterator]()}}});function $N(e,t,n,r,o,s){if(t>32)throw Error("HashMap: max depth exceeded");let i=Di(n,t),a=Di(o,t);if(i===a){let l=$N(e,t+uo,n,r,o,s);return new No(e,i,[l])}let c=i|a,u=i>>>0<a>>>0?[r,s]:[s,r];return new No(e,c,u)}class Hu{canEdit(e){return this.edit===e}}var kg="~effect/collections/HashMap",uo=5,Cd,vZ,DN,kZ,IZ=(e)=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),vd=(e,t)=>e>>>t&kZ,Di=(e,t)=>1<<vd(e,t),vg=(e,t)=>IZ(e&t-1),UN,Fs,kd,No,Id,Ig,LN,Jv=(e)=>M(e,kg),Zv=()=>new Ig(!1,0,LN,0),jN=(e)=>{let t=LN,n=0,r={value:!1};for(let[o,s]of e){let i=re(o);if(r.value=!1,t=t.set(NaN,0,i,o,s,r),r.value)n++}return new Ig(!1,0,t,n)},BN,Yv,CZ=(e,t,n,r)=>{let o=e,s={value:!1},i=o._editable?o._edit:NaN,a=o._root.set(i,0,n,t,r,s);if(o._editable){if(o._root=a,s.value)o._size++;return e}if(o._root===a)return e;return new Ig(!1,o._edit,a,o._size+(s.value?1:0))},Qv,Xv=(e)=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){let n=t.next();if(n.done)return{done:!0,value:void 0};return{done:!1,value:n.value[0]}}}},HN=(e)=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){return t.next()}}},Cg=(e)=>e.size;var ek=w(()=>{yt();kn();X();Xt();jn();_e();Qe();he();Cd=1<<uo,vZ=Cd/4,DN=Cd/2,kZ=Cd-1;UN=class UN extends Hu{_tag="EmptyNode";edit=0;get size(){return 0}get(e,t,n){return O()}has(e,t,n){return!1}set(e,t,n,r,o,s){return s.value=!0,new Fs(e,n,r,o)}remove(e,t,n,r,o){return this}iterator(){return[][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}canEdit(e){return!1}};Fs=class Fs extends Hu{_tag="LeafNode";edit;hash;key;value;constructor(e,t,n,r){super();this.edit=e,this.hash=t,this.key=n,this.value=r}get size(){return 1}get(e,t,n){if(this.hash===t&&Y(this.key,n))return _(this.value);return O()}has(e,t,n){return this.hash===t&&Y(this.key,n)}set(e,t,n,r,o,s){if(this.hash===n&&Y(this.key,r)){if(Y(this.value,o))return this;if(this.canEdit(e))return this.value=o,this;return new Fs(e,n,r,o)}if(s.value=!0,this.hash===n)return new kd(e,n,[[this.key,this.value],[r,o]]);let i=Di(n,t),a=Di(this.hash,t);if(i===a)return new No(e,i,[this.set(e,t+uo,n,r,o,s)]);let c=i|a,u=i>>>0<a>>>0?[new Fs(e,n,r,o),this]:[this,new Fs(e,n,r,o)];return new No(e,c,u)}remove(e,t,n,r,o){if(this.hash===n&&Y(this.key,r)){o.value=!0;return}return this}iterator(){return[[this.key,this.value]][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}};kd=class kd extends Hu{_tag="CollisionNode";edit;hash;entries;constructor(e,t,n){super();this.edit=e,this.hash=t,this.entries=n}get size(){return this.entries.length}get(e,t,n){if(this.hash!==t)return O();for(let[r,o]of this.entries)if(Y(r,n))return _(o);return O()}has(e,t,n){if(this.hash!==t)return!1;for(let[r]of this.entries)if(Y(r,n))return!0;return!1}set(e,t,n,r,o,s){if(this.hash!==n)return s.value=!0,$N(e,t,this.hash,this,n,new Fs(e,n,r,o));for(let i=0;i<this.entries.length;i++)if(Y(this.entries[i][0],r)){if(Y(this.entries[i][1],o))return this;if(this.canEdit(e))return this.entries[i]=[r,o],this;let a=[...this.entries];return a[i]=[r,o],new kd(e,this.hash,a)}if(s.value=!0,this.canEdit(e))return this.entries.push([r,o]),this;return new kd(e,this.hash,[...this.entries,[r,o]])}remove(e,t,n,r,o){if(this.hash!==n)return this;let s=this.entries.findIndex(([a])=>Y(a,r));if(s===-1)return this;if(o.value=!0,this.entries.length===1)return;if(this.entries.length===2){let a=this.entries[s===0?1:0];return new Fs(e,this.hash,a[0],a[1])}if(this.canEdit(e))return this.entries.splice(s,1),this;let i=[...this.entries];return i.splice(s,1),new kd(e,this.hash,i)}iterator(){return this.entries[Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}};No=class No extends Hu{_tag="IndexedNode";edit;_size;bitmap;children;constructor(e,t,n){super();this.edit=e,this.bitmap=t,this.children=n}get size(){if(this._size===void 0)this._size=this.children.reduce((e,t)=>e+t.size,0);return this._size}get(e,t,n){let r=Di(t,e);if((this.bitmap&r)===0)return O();let o=vg(this.bitmap,r);return this.children[o].get(e+uo,t,n)}has(e,t,n){let r=Di(t,e);if((this.bitmap&r)===0)return!1;let o=vg(this.bitmap,r);return this.children[o].has(e+uo,t,n)}set(e,t,n,r,o,s){let i=Di(n,t),a=vg(this.bitmap,i);if((this.bitmap&i)!==0){let c=this.children[a],u=c.set(e,t+uo,n,r,o,s);if(c===u)return this;if(this.canEdit(e))return this.children[a]=u,this;let l=[...this.children];return l[a]=u,new No(e,this.bitmap,l)}else{s.value=!0;let c=new Fs(e,n,r,o),u=this.bitmap|i;if(this.canEdit(e)){if(this.children.splice(a,0,c),this.bitmap=u,this._size=void 0,this.children.length>DN)return this.expand(e,u,this.children);return this}let l=[...this.children];if(l.splice(a,0,c),l.length>DN)return this.expand(e,u,l);return new No(e,u,l)}}remove(e,t,n,r,o){let s=Di(n,t);if((this.bitmap&s)===0)return this;let i=vg(this.bitmap,s),a=this.children[i],c=a.remove(e,t+uo,n,r,o);if(!o.value)return this;if(c===void 0){let l=this.bitmap^s;if(l===0)return;if(this.children.length===2){let d=this.children[i===0?1:0];if(d._tag==="LeafNode")return d}if(this.canEdit(e))return this.children.splice(i,1),this.bitmap=l,this._size=void 0,this;let f=[...this.children];return f.splice(i,1),new No(e,l,f)}if(a===c)return this;if(this.canEdit(e))return this.children[i]=c,this;let u=[...this.children];return u[i]=c,new No(e,this.bitmap,u)}expand(e,t,n){let r=new globalThis.Array(Cd),o=0;for(let s=0;s<Cd;s++)if((t&1<<s)!==0)r[s]=n[o++];return new Id(e,n.length,r)}iterator(){let e=0,t;return{next:()=>{while(e<this.children.length){if(!t)t=this.children[e].iterator();let n=t.next();if(!n.done)return n;t=void 0,e++}return{done:!0,value:void 0}}}}[Symbol.iterator](){return this.iterator()}};Id=class Id extends Hu{_tag="ArrayNode";edit;_size;count;children;constructor(e,t,n){super();this.edit=e,this.count=t,this.children=n}get size(){if(this._size===void 0)this._size=this.children.reduce((e,t)=>e+(t?.size??0),0);return this._size}get(e,t,n){let r=vd(t,e),o=this.children[r];return o?o.get(e+uo,t,n):O()}has(e,t,n){let r=vd(t,e),o=this.children[r];return o?o.has(e+uo,t,n):!1}set(e,t,n,r,o,s){let i=vd(n,t),a=this.children[i];if(a){let c=a.set(e,t+uo,n,r,o,s);if(a===c)return this;if(this.canEdit(e))return this.children[i]=c,this;let u=[...this.children];return u[i]=c,new Id(e,this.count,u)}else{s.value=!0;let c=new Fs(e,n,r,o);if(this.canEdit(e))return this.children[i]=c,this.count++,this._size=void 0,this;let u=[...this.children];return u[i]=c,new Id(e,this.count+1,u)}}remove(e,t,n,r,o){let s=vd(n,t),i=this.children[s];if(!i)return this;let a=i.remove(e,t+uo,n,r,o);if(!o.value)return this;let c=this.count-(a?0:1);if(c<vZ)return this.pack(e,s,a);if(i===a)return this;if(this.canEdit(e)){if(this.children[s]=a,!a)this.count=c;return this._size=void 0,this}let u=[...this.children];return u[s]=a,new Id(e,c,u)}pack(e,t,n){let r=[],o=0,s=1;for(let i=0;i<this.children.length;i++){let a=i===t?n:this.children[i];if(a)r.push(a),o|=s;s<<=1}return new No(e,o,r)}iterator(){let e=0,t;return{next:()=>{while(e<this.children.length){let n=this.children[e];if(!n){e++;continue}if(!t)t=n.iterator();let r=t.next();if(!r.done)return r;t=void 0,e++}return{done:!0,value:void 0}}}}[Symbol.iterator](){return this.iterator()}};Ig=class Ig{[kg]=kg;_editable;_edit;_root;_size;constructor(e,t,n,r){this._editable=e,this._edit=t,this._root=n,this._size=r}get size(){return this._size}[Symbol.iterator](){return this._root.iterator()}[Ce](e){if(Jv(e)){let t=e;if(this.size!==t.size)return!1;for(let[n,r]of this){let o=zr(e,BN(n));if(me(o)||!Y(r,o.value))return!1}return!0}return!1}[Ie](){let e=qe("HashMap");for(let[t,n]of this)e=e^re(t)+re(n);return e}[At](){return Wt(this)}toString(){return`HashMap(${B(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([e,t])=>[Wt(e),Wt(t)])}}pipe(){return le(this,arguments)}};LN=new UN,BN=p(2,(e,t)=>e._root.get(0,re(t),t)),Yv=p(2,(e,t)=>e._root.has(0,re(t),t)),Qv=p(3,(e,t,n)=>CZ(e,t,re(t),n))});var zN,Tg,AZ,Og=(e)=>Array.from(AZ(e)),WN;var KN=w(()=>{ek();zN=Jv,Tg=jN,AZ=HN,WN=Cg});var Td="~effect/collections/HashSet",RZ,PZ=(e)=>{let t=Object.create(RZ);return t[Td]=Td,t.keyMap=e,t},tk=(e)=>M(e,Td),nk=(e)=>e.keyMap,VN=(e)=>{let t=Zv();for(let n of e)t=Qv(t,n,!0);return PZ(t)},GN=(e,t)=>Yv(nk(e),t),Ag=(e)=>Cg(nk(e)),JN=(e,t)=>{for(let n of e)if(!t(n))return!1;return!0};var ZN=w(()=>{yt();kn();Xt();jn();Qe();he();ek();RZ={[Ie](){return re(Td)},[Ce](e){return tk(e)&&Ag(this)===Ag(e)&&JN(this,(t)=>GN(e,t))},[Symbol.iterator](){return Xv(nk(this))},toString(){return`HashSet(${B(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:Wt(Array.from(this))}},[At](){return this.toJSON()},pipe(){return le(this,arguments)}}});var _g,YN,QN;var XN=w(()=>{ZN();_g=VN,YN=tk,QN=Ag});function Rg(e){let t=fD(Fg,sn(e.ast));return(n,r)=>t(n,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Pg(e){let t=Rg(e);return(n,r)=>{let o=ki(t(n,r));if(Rt(o))return _(o.value);return Os(o.cause,"Option adapter can only return none for schema issues"),O()}}function tD(e){let t=Rg(e);return(n,r)=>{let o=ki(t(n,r));if(Rt(o))return o.value;let s=Os(o.cause,"Constructor adapter can only throw schema issues");throw Error("Schema validation failed",{cause:s})}}function nD(e){return Ad(e.ast)}function Ad(e){let t=Wa(_d(sn(e)));return(n)=>{let r=t(n,ja);if(Rt(r))return!0;return Os(r.cause,"Type guard adapter can only return false for schema issues"),!1}}function rD(e){let t=_d(e);return(n,r)=>{let o=ki(t(n,r));if(Rt(o))return;return Os(o.cause,"Issue adapter can only return schema issues")}}function oD(e,t){let r=Wa(_d(sn(e.ast)))(t,ja);if(ru(r)){let o=Os(r.cause,"Assertion adapter can only throw schema issues");throw Error("Schema validation failed",{cause:o})}}function vt(e,t){let n=_d(e.ast);return t===void 0?n:(r,o)=>n(r,Od(t,o))}function sD(e,t){return Wa(vt(e,t))}function ok(e,t){return dD(vt(e,t))}function aD(e,t){return pD(vt(e,t))}function NZ(e,t){return mD(vt(e,t))}function qu(e,t){let n=_d(oo(e.ast));return t===void 0?n:(r,o)=>n(r,Od(t,o))}function cD(e,t){return Wa(qu(e,t))}function ik(e,t){return dD(qu(e,t))}function lD(e,t){return pD(qu(e,t))}function DZ(e,t){return mD(qu(e,t))}function _d(e){return fD(hD,e)}function fD(e,t){let n;return(r,o)=>{let s=(n??=e(t))(r,o??ja);if(s===Dt)return v(r);if(!We(s))return on(s,eD);return s[ie]===Re?eD(Re):s}}function Wa(e){return(t,n)=>ki(e(t,n))}function dD(e){let t=Wa(e);return(n,r)=>{let o=t(n,r);if(Rt(o))return _(o.value);return Os(o.cause,"Option adapter can only return none for schema issues"),O()}}function pD(e){let t=Wa(e);return(n,r)=>{let o=t(n,r);if(Rt(o))return G(o.value);return te(Os(o.cause,"Result adapter can only return schema issues"))}}function mD(e){let t=Wa(e);return(n,r)=>{let o=t(n,r);if(Rt(o))return o.value;let s=Os(o.cause,"Sync adapter can only throw schema issues");throw Error("Schema validation failed",{cause:s})}}function gD(e){return e.context?.constructorDefault?$Z(e):Fg(e)}function xD(e,t,n,r){let o;if(We(e)&&e._tag==="Success"){let s=Mh(e===Dt?t:e[ie]);o=n._tag==="Transformation"?n.decode.run(s,r):n.decode(Dr(s),r)}else if(n._tag==="Transformation")o=on(e,(s)=>n.decode.run(Mh(s),r));else o=n.decode(Ss(e,Mh),r);return We(o)&&o._tag==="Success"?yw(o[ie]):on(o,yw)}function UZ(e,t){let n;return(r,o)=>{if(r===Re)return no;if(e.isConstructed(r))return Dt;let s=(n??=t(e.link.to))(r,o);return xD(s,r,e.link.transformation,o)}}function ck(e,t,n,r){let o=n?R1(e):void 0,s=o?UZ(o,t):e.getParser(t,n),i=e.checks,a=r?e.encoding?[...e.encoding,r]:[r]:e.encoding,c=e.encodingChecks,u=(i?i[i.length-1].annotations:e.annotations)?.parseOptions;if(!a&&!i&&!c){if(!u)return s;return(d,m)=>s(d,Od(m,u))}let l,f=(d,m)=>{let g=s(d,m);if(c&&!m.disableChecks)if(We(g)){if(g._tag==="Success"){let b=g===Dt?d:g[ie];if(d!==Re&&b!==Re){let x=co(c,d,void 0,e,m);if(x)g=A(new Et(e,x,d,m))}}}else g=ne(g,(b)=>{if(d!==Re&&b!==Re){let x=co(c,d,void 0,e,m);if(x)return A(new Et(e,x,d,m))}return v(b)});if(i&&!m.disableChecks)if(We(g)){if(g._tag==="Success"){let b=g===Dt?d:g[ie];if(b===Re)return g;let x=co(i,b,void 0,e,m);if(x)g=A(new Et(e,x,b,m))}}else g=ne(g,(b)=>{if(b!==Re){let x=co(i,b,void 0,e,m);if(x)return A(new Et(e,x,b,m))}return v(b)});return g};if(!a)return u?(d,m)=>f(d,Od(m,u)):f;return(d,m)=>{if(u)m=Od(m,u);let g=l??=a.map((I)=>t(I.to)),b=d,x=g[g.length-1](d,m);for(let I=a.length-1;I>=0;I--)if(x=xD(x,b,a[I].transformation,m),I!==0){let C=g[I-1];if(x._tag==="Success")b=x[ie],x=C(b,m);else x=on(x,(S)=>{let y=C(S,m);return y===Dt?Dr(S):y})}if(x._tag==="Success"){let I=x[ie],C=f(I,m);return C===Dt?x:C}return x=xr(x,(I)=>Ei(()=>ms(I,(C)=>new vw(e,C,d,m)))),on(x,(I)=>{let C=f(I,m);return C===Dt?Dr(I):C})}}var rk,iD,sk,uD,ak,Od=(e,t)=>t?{...e,...t}:e,eD=(e)=>{if(e===Re)return A(new we);return v(e)},hD,Fg,$Z;var Mg=w(()=>{rn();Oe();dr();X();ht();Tw();Nh();_e();gn();Ps();Ai();rk=vt;iD=ok;sk=NZ;uD=ik;ak=DZ;hD=Qt((e)=>ck(e,hD)),Fg=Qt((e)=>ck(e,Fg,gD)),$Z=Qt((e)=>ck(e,Fg,gD,e.context?.constructorDefault))});function Mn(e,t,n){return{id:e,payloadSchema:t,revive:n}}function ge(e,t,n){return{id:e,payloadSchema:t,revive:n}}function Rd(e,t){function n(){}let r=Object.defineProperties(Object.setPrototypeOf(n,LZ),Object.getOwnPropertyDescriptors({...t}));return r.ast=e,r.rebuild=(o)=>Rd(o,t),r.makeEffect=Rg(r),r.make=tD(r),r.makeOption=Pg(r),r}var Ng="~effect/Schema/Schema",LZ;var yD=w(()=>{Qe();Ps();Mg();LZ={[Ng]:Ng,pipe(){return le(this,arguments)},annotate(e){return this.rebuild(Ur(this.ast,e))},annotateKey(e){return this.rebuild(Sd(this.ast,e))},check(...e){return this.rebuild(Fo(this.ast,e))}}});var Gme,SD;var ED=w(()=>{Gme=globalThis.Boolean,SD=Ir((e,t)=>e||t,!1)});function fk(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let o=t(r,e[r]);if(o){let[s,i]=o;U(n,s,i)}}return n}function kD(e,t){let n=t?.omitKeyWhen??(()=>!1);return Hp((r,o)=>{let s=Reflect.ownKeys(e),i={};for(let a of s){let c=e[a].combine(r[a],o[a]);if(n(c))continue;U(i,a,c)}return i})}var bD,wD,vD,lk,En=(e)=>e;var Dg=w(()=>{X();bD=p(2,(e,t)=>fk(e,(n,r)=>t.includes(n)?[n,r]:void 0)),wD=p(2,(e,t)=>fk(e,(n,r)=>!t.includes(n)?[n,r]:void 0)),vD=p(2,(e,t)=>({...e,...t})),lk=p(2,(e,t)=>fk(e,(n,r)=>[Object.hasOwn(t,n)?t[n]:n,r]))});function Pd(e){return Ir((t,n)=>{if(t===void 0)return n;if(n===void 0)return t;return e.combine(t,n)},void 0)}var ID=()=>{};function Do(e,t){if(t.length>0)e+=`
|
|
35
|
-
at ${Dp(t)}`;return Error(e)}var pk=w(()=>{kn()});function Ms(e){return Error(`Unable to derive an arbitrary for ${e}`)}function qZ(e,t,n){return t.reduce((r,o)=>r.filter((s)=>o.run(s,e,ja)===void 0),n)}function LD(e,t){if(e?.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength)throw Ms(`${t} constraints`)}function jD(e){return e===void 0||e.minLength===void 0&&e.maxLength===void 0?void 0:{...e.minLength!==void 0?{minLength:e.minLength}:{},...e.maxLength!==void 0?{maxLength:e.maxLength}:{}}}function mk(e,t,n,r){return r?e.uniqueArray(t,{...n,comparator:r}):e.array(t,n)}function _D(e,t,n,r=!1){let o=t.constraint,s=jD(o);return LD(s,"array"),mk(e,n,r?{...s,maxLength:s?.minLength??0}:s,o?.unique?Y:void 0)}function $g(e,t,n,r){return t.chain((o)=>o.length<n?e.constant(o):r.map((s)=>[...o,...s]))}function RD(e,t){return e.chain((n)=>t.map((r)=>({...Object.fromEntries(r),...n})))}function PD(e,t,n,r,o,s){if(r===void 0||t===void 0)return r===void 0?[t,n]:[r,o];let i=e(t,r);return i===s?[r,o]:i===0?[t,n||o]:[t,n]}function GZ(e,t){if(e===void 0)return t;if(e.order!==t.order)throw Error("Cannot merge ordered arbitrary constraints with different Order instances");let[n,r]=PD(e.order,e.minimum,e.exclusiveMinimum,t.minimum,t.exclusiveMinimum,-1),[o,s]=PD(e.order,e.maximum,e.exclusiveMaximum,t.maximum,t.exclusiveMaximum,1);return{order:e.order,...n!==void 0?{minimum:n}:{},...r!==void 0?{exclusiveMinimum:r}:{},...o!==void 0?{maximum:o}:{},...s!==void 0?{exclusiveMaximum:s}:{}}}function JZ(e,t){let{ordered:n,...r}=e??{},{ordered:o,...s}=t,i=o===void 0?n:GZ(n,o);return{...VZ.combine(r,s),...i===void 0?{}:{ordered:i}}}function FD(e){let t=[],n=[];function r(o){if(o.annotations?.arbitrary)n.push(o.annotations.arbitrary);if(o._tag!=="Filter")for(let s of o.checks)r(s);else t.push(o)}return e?.forEach(r),{filters:t,arbitraries:n}}function ZZ(e){let t=e.map(({constraint:n})=>n).filter(Le);return(n)=>{let r=t.reduce((o,s)=>JZ(o,s),n.constraint);return{...n,constraint:r}}}function Fd(e){return{...e,constraint:void 0}}function MD(e,t,n){if(t===void 0||t.minLength===void 0&&t.maxLength===void 0)return;if(t.minLength!==void 0&&e.indexSignatures.length===0&&t.minLength>e.propertySignatures.length)throw Ms("object property constraints");let r={};if(t.minLength!==void 0)r.minLength=Math.max(0,t.minLength-n);if(t.maxLength!==void 0){if(r.maxLength=t.maxLength-n,r.maxLength<0)throw Ms("object property constraints")}return LD(r,"object property"),r}function YZ(e,t,n,r,o,s){let i=r.length;if(s.maxLength!==void 0&&s.maxLength<i)throw Ms("object property constraints");let a=s.minLength===void 0?0:Math.max(0,s.minLength-i),c=s.maxLength===void 0?o.length:Math.min(o.length,s.maxLength-i);if(a>c)throw Ms("object property constraints");let u=e.record(t,{requiredKeys:[...r,...o]}),l=e.shuffledSubarray([...o],{minLength:a,maxLength:c});return e.tuple(u,l).map(([f,d])=>{let m=new Set([...r,...d]),g={};for(let b of n)if(m.has(b))U(g,b,f[b]);return g})}function BD(e,t,n,r){let o={};if(e?.minimum!==void 0)o.min=t(e.minimum,e.exclusiveMinimum===!0);if(e?.maximum!==void 0)o.max=n(e.maximum,e.exclusiveMaximum===!0);if(o.min!==void 0&&o.max!==void 0&&o.min>o.max)throw Ms(r);return o}function QZ(e){return BD(e,(t,n)=>n?Math.floor(t)+1:Math.ceil(t),(t,n)=>n?Math.ceil(t)-1:Math.floor(t),"integer constraints")}function XZ(e,t){let n={...e?.noInfinity?{noDefaultInfinity:!0}:{},...e?.noNaN?{noNaN:!0}:{},...t?.minimum!==void 0?{min:t.minimum}:{},...t?.exclusiveMinimum!==void 0?{minExcluded:t.exclusiveMinimum}:{},...t?.maximum!==void 0?{max:t.maximum}:{},...t?.exclusiveMaximum!==void 0?{maxExcluded:t.exclusiveMaximum}:{}};if(n.min!==void 0&&n.max!==void 0&&(n.min>n.max||n.min===n.max&&(n.minExcluded||n.maxExcluded)))throw Ms("number constraints");return n}function eY(e){return BD(e,(t,n)=>n?t+BigInt(1):t,(t,n)=>n?t-BigInt(1):t,"the ordered bigint constraints")}function zu(e,t){let n=(r,o,s=OD)=>e(r,o,s);return n.terminal=(r,o,s=OD)=>t(r,o,s),n}function Lr(e){return zu(e,e)}function ND(e,t){let n=TD.get(t)??e.createDepthIdentifier();return TD.set(t,n),{maxDepth:2,depthIdentifier:n}}function DD(e,t){return t.length===0?void 0:t.length===1?t[0]:e.oneof(...t)}function nY(e){return{...e,constraint:tY}}function rY(e,t,n,r){let o=r===void 0?[]:[{arbitrary:r,weight:1}];for(let{candidate:s}of n){if(!s)continue;let i=s.make(e,t);if(i===void 0)continue;let a=s.weight??1;if(!globalThis.Number.isInteger(a)||a<=0)throw Ms("a candidate with an invalid weight");o.push({arbitrary:i,weight:a})}return o.length===0?void 0:o.length===1?o[0].arbitrary:e.oneof(...o)}function $D(e,t,n,r,o){let s=rY(n,r,t.arbitraries,o);return s===void 0?void 0:qZ(e,t.filters,s)}function oY(e,t){if(!(typeof e==="object"&&e!==null&&("arbitrary"in e)))return{arbitrary:e,terminal:t?void 0:e};let n="terminal"in e?e.terminal:t?void 0:e.arbitrary;return{arbitrary:e.arbitrary,terminal:n}}function sY(e,t,n,r,o){return e.map((s)=>({arbitrary:o?t.constant(null).chain(()=>s(t,n,r)):s(t,n,r),terminal:s.terminal(t,n,r)}))}function UD(e,t,n,r){let o=ZZ(t.arbitraries);return zu((s,i,a)=>{let c=o(i);return $D(e,t,s,c,n(s,i,c,a))},(s,i,a)=>{let c=o(i);return $D(e,t,s,c,r(s,i,c,a))})}function jr(e,t){let n=_o(e)?.toArbitrary;if(n){let r=Mi(e)?e.typeParameters.map((i)=>jr(i,t)):[],o=FD(e.checks),s=(i)=>(a,c,u,l)=>oY(n(sY(r,a,Fd(c),l,i))(a,u),r.length>0)[i?"terminal":"arbitrary"];return UD(e,o,s(!1),s(!0))}if(e.checks){let r=FD(e.checks),o=jr(lg(e,void 0),t);return UD(e,r,(s,i,a,c)=>o(s,a,c),(s,i,a,c)=>o.terminal(s,a,c))}return iY(e,t)}function iY(e,t){switch(e._tag){case"Never":case"Declaration":throw Do(`Unsupported AST ${e._tag}`,t);case"Null":return Lr((n)=>n.constant(null));case"Void":case"Undefined":return Lr((n)=>n.constant(void 0));case"Unknown":case"Any":return Lr((n)=>n.anything());case"String":return Lr((n,r)=>{let o=r.constraint,s=o?.patterns;return s?n.oneof(...s.map((i)=>n.stringMatching(new RegExp(i)))):n.string(jD(o))});case"Number":return Lr((n,r)=>{let o=r.constraint,s=o?.ordered?.order===rr?o.ordered:void 0;return o?.integer?n.integer(QZ(s)):n.float(XZ(o,s))});case"Boolean":return Lr((n)=>n.boolean());case"BigInt":return Lr((n,r)=>{let o=r.constraint?.ordered?.order===Cr?r.constraint.ordered:void 0;return n.bigInt(eY(o))});case"Symbol":return Lr((n)=>n.string().map(Symbol.for));case"Literal":return Lr((n)=>n.constant(e.literal));case"UniqueSymbol":return Lr((n)=>n.constant(e.symbol));case"ObjectKeyword":return Lr((n)=>n.oneof(n.object(),n.array(n.anything())));case"Enum":return jr(I1(e),t);case"TemplateLiteral":{let n=e.parts.map((r,o)=>jr(Jn(r),[...t,o]));return Lr((r,o,s)=>r.tuple(...n.map((i)=>i(r,nY(o),s))).map((i)=>i.map((a)=>globalThis.String(a)).join("")))}case"Arrays":{let n=e.elements.map((i,a)=>({ast:i,arbitrary:jr(i,[...t,a])})),r=e.elements.length,o=e.rest.map((i,a)=>({ast:i,arbitrary:jr(i,[...t,r+a])})),s=(i,a,c)=>{let u=Fd(a),l=[],f=[],d=0;for(let C of n){let S=C.arbitrary.terminal(i,u,c);if(bt(C.ast)){f.push(S);continue}if(S===void 0)return;d++,l.push(S.map(_))}let m=a.constraint?.minLength??0,b=Hn(o)&&m>d+f.length?f.length:Math.max(0,m-d),x=0;for(let C of f){if(x>=b||C===void 0){l.push(i.constant(O()));continue}x++,d++,l.push(C.map(_))}if(x<b)return;let I=i.tuple(...l).map(mS);if(Hn(o)){let[C,...S]=o,y=e.elements.length===0?a:u,h=Math.max(0,m-d-S.length),E=h===0?void 0:C.arbitrary.terminal(i,u,c);if(h>0&&E===void 0)return;let k=h===0?i.constant([]):_D(i,{...y,constraint:{...y.constraint,minLength:h}},E,!0);if(I=$g(i,I,r,k),S.length>0){let T=[];for(let N of S){let R=N.arbitrary.terminal(i,u,c);if(R===void 0)return;T.push(R)}let F=i.tuple(...T);I=$g(i,I,r,F)}}return I};return zu((i,a,c)=>{let u=Fd(a),l=n.map(({ast:d,arbitrary:m})=>{let g=m(i,u,c);return bt(d)?g.chain((b)=>i.boolean().map((x)=>x?_(b):O())):g.map(_)}),f=i.tuple(...l).map((d)=>mS(UC(d,Ee)));if(Hn(o)){let[d,...m]=o.map(({arbitrary:b})=>b(i,u,c)),g=_D(i,e.elements.length===0?a:u,d);if(f=$g(i,f,r,g),m.length>0){let b=i.tuple(...m);f=$g(i,f,r,b)}}if(a.recursion){let d=s(i,a,c);if(d!==void 0)return i.oneof(a.recursion,d,f)}return f},s)}case"Objects":{let n=e.propertySignatures.map((s)=>({ps:s,arbitrary:jr(s.type,[...t,s.name])})),r=e.indexSignatures.map((s)=>({is:s,parameter:jr(s.parameter,t),type:jr(s.type,t)}));return zu((s,i,a)=>{let c=Fd(i),u={},l=[],f=[],d=[];for(let{ps:x,arbitrary:I}of n){let C=x.name;if(l.push(C),bt(x.type))d.push(C);else f.push(C);U(u,C,I(s,c,a))}let m=i.constraint;if(d.length>0&&r.length===0&&m!==void 0&&(m.minLength!==void 0||m.maxLength!==void 0))return YZ(s,u,l,f,d,m);let g=s.record(u,{requiredKeys:f}),b=MD(e,i.constraint,f.length);for(let{parameter:x,type:I}of r){let C=s.tuple(x(s,c,a),I(s,c,a)),S=mk(s,C,b,AD);g=RD(g,S)}return g},(s,i,a)=>{let c=Fd(i),u={},l=[],f=[];for(let{ps:x,arbitrary:I}of n){let C=x.name,S=I.terminal(s,c,a);if(bt(x.type)){if(S!==void 0)f.push([C,S]);continue}if(S===void 0)return;l.push(C),U(u,C,S)}let d=Math.max(0,(i.constraint?.minLength??0)-l.length);for(let[x,I]of f){if(d===0)break;d--,l.push(x),U(u,x,I)}if(d>0&&e.indexSignatures.length===0)return;let m=s.record(u,{requiredKeys:l}),g=MD(e,i.constraint,l.length),b=g?.minLength??0;for(let{parameter:x,type:I}of r){let C;if(b===0)C=s.constant([]);else{let S=x.terminal(s,c,a),y=I.terminal(s,c,a);if(S===void 0||y===void 0)return;C=mk(s,s.tuple(S,y),{...g,maxLength:b},AD)}m=RD(m,C)}return m})}case"Union":{let n=e.types.map((o)=>jr(o,t)),r=(o,s,i)=>DD(o,n.map((a)=>a.terminal(o,s,i)).filter(Le));return zu((o,s,i)=>{let a=n.map((u)=>u(o,s,i));if(s.recursion){let u=r(o,s,i);if(u!==void 0)return o.oneof(s.recursion,u,...a)}let c=DD(o,a);if(c===void 0)throw Ms("a union with no members");return c},r)}case"Suspend":{let n=CD.get(e);if(n)return n;let r=Ha(()=>jr(e.thunk(),t)),o=zu((s,i,a)=>{let c=ND(s,e),u={...i,recursion:c},l=a.includes(e)?a:[...a,e],f=r().terminal(s,u,l);if(f===void 0)throw Do("Unable to derive an arbitrary for a recursive schema without a finite generation path",t);return s.oneof(c,f,s.constant(null).chain(()=>r()(s,u,l)))},(s,i,a)=>{if(a.includes(e))return;let c=ND(s,e);return r().terminal(s,{...i,recursion:c},[...a,e])});return CD.set(e,o),o}}}var CD,TD,OD,AD=([e],[t])=>Y(e,t),zZ,WZ,Ug,KZ,VZ,tY,HD;var qD=w(()=>{An();ED();yt();X();Xm();_e();ia();he();Ps();Dg();ID();pk();Ti();CD=new WeakMap,TD=new WeakMap,OD=[];zZ=Pd(oR),WZ=Pd(sR),Ug=Pd(SD),KZ=Pd(LC()),VZ=kD({integer:Ug,maxLength:WZ,minLength:zZ,noInfinity:Ug,noNaN:Ug,patterns:KZ,unique:Ug},{omitKeyWhen:Gs});tY={noInfinity:!0,noNaN:!0};HD=Qt((e)=>jr(e,[]))});function $i(e,t){let n=_o(e)?.toEquivalence;if(n)return n(Mi(e)?e.typeParameters.map((r)=>$i(r,t)):[]);switch(e._tag){case"Never":return oC();case"Declaration":case"Null":case"Undefined":case"Void":case"Unknown":case"Any":case"String":case"Number":case"Boolean":case"BigInt":case"Symbol":case"Literal":case"UniqueSymbol":case"ObjectKeyword":case"Enum":case"TemplateLiteral":return Y;case"Arrays":{let r=e.elements.map((i,a)=>$i(i,[...t,a])),o=e.elements.length,s=e.rest.map((i,a)=>$i(i,[...t,o+a]));return Kt((i,a)=>{if(!Array.isArray(i)||!Array.isArray(a))return!1;let c=i.length;if(c!==a.length)return!1;let u=0;for(;u<Math.min(c,e.elements.length);u++)if(!r[u](i[u],a[u]))return!1;if(s.length>0){let[l,...f]=s;for(;u<c-f.length;u++)if(!l(i[u],a[u]))return!1;for(let d=0;d<f.length;d++)if(!f[d](i[u+d],a[u+d]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return Y;let r=e.propertySignatures.map((s)=>$i(s.type,[...t,s.name])),o=e.indexSignatures.map((s)=>$i(s.type,t));return Kt((s,i)=>{if(!fn(s)||!fn(i))return!1;for(let a=0;a<r.length;a++){let c=e.propertySignatures[a],u=c.name,l=Object.hasOwn(s,u),f=Object.hasOwn(i,u);if(bt(c.type)){if(l!==f)return!1}if(l&&f&&!r[a](s[u],i[u]))return!1}for(let a=0;a<o.length;a++){let c=e.indexSignatures[a],u=La(s,c.parameter),l=La(i,c.parameter);if(u.length!==l.length)return!1;for(let f=0;f<u.length;f++){let d=u[f];if(!Object.hasOwn(i,d)||!o[a](s[d],i[d]))return!1}}return!0})}case"Union":{let r=sn(e).types,o=new Map(r.map((s,i)=>[s,[Ad(s),$i(e.types[i],t)]]));return Kt((s,i)=>{let a=md(s,r);for(let c=0;c<a.length;c++){let[u,l]=o.get(a[c]);if(u(s)&&u(i))return l(s,i)}return!1})}case"Suspend":{let r=Ha(()=>$i(e.thunk(),t));return Kt((o,s)=>r()(o,s))}}}var zD;var WD=w(()=>{yt();Xo();X();he();Ps();Mg();Ti();zD=Qt((e)=>$i(e,[]))});function Ka(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Wu(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function VD(e,t){return e===t||e===(t.endsWith("#")?t.slice(0,-1):`${t}#`)}function ZD(e){return{dialect:"draft-07",...gY(e,CY)}}function lY(e,t){return n(e,!1,!0);function n(r,o,s=!1){if(!fn(r))return r;let i=o||!s&&XD(r.$id),a={};for(let c of Object.keys(r)){let u=r[c],l=u;switch(c){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":l=gk(u,(f)=>n(f,i))??u;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":l=Array.isArray(u)?u.map((f)=>n(f,i)):u;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":l=n(u,i)}U(a,c,l)}return t(a,i),a}}function YD(e,t){return lY(e,(n)=>{fY(n,t)})}function fY(e,t){if(typeof e.$ref==="string")U(e,"$ref",t(e.$ref,"$ref"));if(typeof e.$dynamicRef==="string")U(e,"$dynamicRef",t(e.$dynamicRef,"$dynamicRef"))}function gk(e,t){if(!fn(e))return;let n={};for(let r of Object.keys(e))U(n,r,t(e[r],r));return n}function dY(e,t,n){let r=new Map,o=[],s=hk;function i(d,m=[],g=[]){if(m.length===0&&t?.trackIds){let b=fn(d)?l(d):void 0;s=GD(b,hk)??hk}return u(d,m,g,{sourceRoot:[],targetRoot:[],uri:s})}function a(){for(let[d,m,g]of o){let b=m,x=QD(m,g);if(x!==void 0){let I=pY(x.hash);if(x.hash="",I!==void 0){let C=r.get(JD(x.href,I));if(C!==void 0)b=mY(m,C)}}U(d,"$ref",b)}}let c=n(i);return a(),c;function u(d,m,g,b){if(typeof d==="boolean")return f(m,g,b),t?.booleanAdapter?.(d)??d;if(!fn(d))return d;let x=b,I=l(d);if(m.length>0&&t?.trackIds&&XD(I)){let y=GD(I,b.uri);if(y!==void 0)x={parent:b,sourceRoot:m,targetRoot:g,uri:y}}f(m,g,x);let C=x.uri,S={isDocumentRoot:m.length===0,schema(y,h,E=h){return u(y,[...m,h],[...g,E],x)},schemaAt(y,h,E){return u(y,[...m,...h],[...g,...E],x)},schemaArray(y,h,E=h){return Array.isArray(y)?y.map((k,T)=>u(k,[...m,h,String(T)],[...g,E,String(T)],x)):y},schemaMap(y,h,E=h){if(!fn(y))return y;return gk(y,(k,T)=>u(k,[...m,h,T],[...g,E,T],x))},reference(y,h){if(typeof h==="string")o.push([y,h,C]);else U(y,"$ref",h)}};return e(d,S)}function l(d){return t?.ignoreRefSiblings===!0&&typeof d.$ref==="string"?void 0:d.$id}function f(d,m,g){if(g.parent!==void 0)f(d,m,g.parent);r.set(JD(g.uri,d.slice(g.sourceRoot.length)),m.slice(g.targetRoot.length))}}function QD(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function GD(e,t){if(typeof e!=="string")return;let n=QD(e,t);if(n===void 0)return;return n.hash="",n.href}function pY(e){if(e.length===0)return[];let t;try{t=decodeURIComponent(e.slice(1))}catch{return}if(!t.startsWith("/"))return;return/~(?:[^01]|$)/.test(t)?void 0:t.slice(1).split("/").map(Wu)}function mY(e,t){let n=e.indexOf("#");if(n===-1&&t.length===0)return e;return`${n===-1?e:e.slice(0,n)}${hY(t)}`}function hY(e){return e.length===0?"#":`#/${e.map((t)=>encodeURI(Ka(t)).replace(/#/g,"%23")).join("/")}`}function JD(e,t){return`${e}\x00${JSON.stringify(t)}`}function XD(e){return typeof e==="string"&&e.length>0&&e[0]!=="#"}function gY(e,t,n){return dY(t,{...n,trackIds:!0},(r)=>({schema:r(e.schema),definitions:gk(e.definitions,(o,s)=>r(o,["$defs",s],["definitions",s]))}))}function EY(e,t,n,r,o,s=xY){let i;if(s.has(t))i=r.schemaMap(n,t);else if(yY.has(t))i=r.schemaArray(n,t);else if(o.has(t))i=r.schema(n,t);else return!1;return U(e,t,i),!0}function Va(e,t,n){throw Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${n}`)}function vY(e,t,n,r){for(let o of t)if(Object.hasOwn(e,o))Va(o,n,`it is not active in ${r} but would become active in the target`)}function IY(e,t,n,r,o){if(n.isDocumentRoot)U(e,"$schema",VD(t,KD)?r:t);else if(!VD(t,KD))Va("$schema",o,"an embedded resource cannot declare a different dialect")}function CY(e,t){vY(e,kY,"Draft-07","Draft 2020-12");let n={},r=void 0,o=void 0,s=void 0;for(let i of Object.keys(e)){let a=e[i];if(EY(n,i,a,t,SY))continue;switch(i){case"$ref":r=a;break;case"$schema":IY(n,a,t,uY,"Draft-07");break;case"$id":case"$anchor":break;case"$defs":U(n,"definitions",t.schemaMap(a,i,"definitions"));break;case"prefixItems":o=a;break;case"items":s=a;break;case"dependentRequired":case"dependentSchemas":case"minContains":case"maxContains":break;case"$dynamicRef":case"$dynamicAnchor":case"$vocabulary":case"unevaluatedProperties":case"unevaluatedItems":Va(i,"Draft-07","the target dialect has no equivalent");case"required":if(Array.isArray(a)&&a.length===0)break;U(n,i,a);break;default:U(n,i,a)}}if(TY(n,o,s,t),Object.hasOwn(e,"contains")){let{minContains:i,maxContains:a}=e;if(i!==void 0&&i!==1||a!==void 0)Va("minContains/maxContains","Draft-07","contains cardinality cannot be represented");if(Object.hasOwn(e,"minContains"))U(n,"minContains",i)}else{if(Object.hasOwn(e,"minContains"))U(n,"minContains",e.minContains);if(Object.hasOwn(e,"maxContains"))U(n,"maxContains",e.maxContains)}return AY(e,n,t,"draft-07"),RY(e,n,"$id","Draft-07"),OY(n,r,t),n}function TY(e,t,n,r){if(t===void 0){if(n!==void 0)U(e,"items",r.schema(n,"items"));return}if(U(e,"items",r.schemaArray(t,"prefixItems","items")),n!==void 0)U(e,"additionalItems",r.schema(n,"items","additionalItems"))}function OY(e,t,n){if(t===void 0)return;if(typeof t==="string"&&Object.keys(e).length>0){let r={};n.reference(r,t),_Y(e,r)}else n.reference(e,t)}function AY(e,t,n,r){let o=fn(e.dependentRequired)?e.dependentRequired:void 0,s=fn(e.dependentSchemas)?e.dependentSchemas:void 0;if(o===void 0&&s===void 0)return;let i={},a=new Set([...Object.keys(o??{}),...Object.keys(s??{})]);for(let c of a){let u=o?.[c],l=s?.[c],f=r==="draft-04"&&Array.isArray(u)&&u.length===0;if(l===void 0){if(!f)U(i,c,u)}else if(u===void 0||f)U(i,c,n.schemaAt(l,["dependentSchemas",c],["dependencies",c]));else U(i,c,{allOf:[n.schemaAt(l,["dependentSchemas",c],["dependencies",c,"allOf","0"]),{required:u}]})}if(Object.keys(i).length>0)U(t,"dependencies",i)}function _Y(e,t){if(Array.isArray(e.allOf))e.allOf.push(t);else U(e,"allOf",[t])}function RY(e,t,n,r){let{$id:o,$anchor:s}=e;if(s===void 0){if(o!==void 0)U(t,n,o);return}if(typeof s!=="string"||!bY.test(s))Va("$anchor",r,"the anchor is not valid");if(!wY.test(s))Va("$anchor",r,"the anchor cannot be represented as a plain-name fragment identifier");if(o===void 0)U(t,n,`#${s}`);else Va("$anchor",r,"it cannot be combined with the schema $id")}var uY="http://json-schema.org/draft-07/schema#",KD="https://json-schema.org/draft/2020-12/schema",hk="https://effect.invalid/.json-schema/",xY,yY,SY,e$,rhe,ohe,bY,wY,kY;var xk=w(()=>{he();xY=new Set(["properties","patternProperties"]),yY=new Set(["allOf","anyOf","oneOf"]),SY=new Set(["not","additionalProperties","propertyNames","contains","if","then","else","contentSchema"]);e$=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"],rhe=[...e$,"deprecated"],ohe=[...e$,"$comment","$id","$schema","const","contains","contentEncoding","contentMediaType","else","examples","if","patternProperties","propertyNames","then"],bY=/^[A-Za-z_][-A-Za-z0-9._]*$/,wY=/^[A-Za-z][-A-Za-z0-9._:]*$/;kY=["additionalItems","definitions","dependencies"]});var she,Ku=(e)=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");var yk=w(()=>{she=globalThis.RegExp});function Md(e,t){if(e===void 0)return;let n={},r=e.title;if(typeof r==="string")n.title=r;let{description:o,expected:s}=e;if(typeof o==="string")n.description=o;else if(t?.generateDescriptions===!0&&typeof s==="string")n.description=s;let i=e.default;if($u(i))n.default=i;let a=e.examples;if(Array.isArray(a)&&$u(a))n.examples=a;let c=e.readOnly;if(typeof c==="boolean")n.readOnly=c;let u=e.writeOnly;if(typeof u==="boolean")n.writeOnly=u;let l=e.format;if(typeof l==="string")n.format=l;let f=e.contentEncoding;if(typeof f==="string")n.contentEncoding=f;let d=e.contentMediaType;if(typeof d==="string")n.contentMediaType=d;let m=e.contentSchema;if($u(m))n.contentSchema=m;if(t?.includeAnnotationKey!==void 0)for(let[g,b]of Object.entries(e)){if(FY.has(g)||!t.includeAnnotationKey(g))continue;if($u(b))U(n,g,b)}return Object.keys(n).length===0?void 0:n}function r$(e){let t=e.type==="number"||e.type==="integer"?e.type:void 0,n=e;if(t!==void 0)n={...e},delete n.type;if(Array.isArray(n.allOf)){let r=[],o=!1;for(let s of n.allOf){let i=r$(s);if(i.type!==void 0){if(o=!0,t===void 0||i.type==="integer")t=i.type}if(Object.keys(i.schema).length>0)r.push(i.schema)}if(o){let{allOf:s,...i}=n;n=r.length===0?i:{...i,allOf:r}}}return{type:t,schema:n}}function MY(e){return Array.isArray(e.anyOf)&&e.anyOf.length===4&&e.anyOf[0]?.type==="number"&&e.anyOf.slice(1).every((t)=>t.type==="string")}function Sk(e,t){return Object.keys(e).every((n)=>t.includes(`|${n}|`))}function n$(e,t){return typeof e.$ref!=="string"&&t.every((n)=>!Object.hasOwn(e,n))}function Nd(e,t,n){if(Object.keys(e).length===0)return t;let r=Object.keys(t);if(r.length===0)return e;let o=e.type==="number"||e.type==="integer"?e.type:void 0,s=MY(e);if(o!==void 0||s){let a=r$(t);if(a.type!==void 0){let c=o==="integer"||a.type==="integer"?"integer":"number",u={...e,type:c};if(s)delete u.anyOf;let l=Object.keys(a.schema);if(l.length===0)return u;return Sk(a.schema,Ek)&&n$(u,l)?{...u,...a.schema}:Nd(u,a.schema,n)}}if(n&&n$(e,r))return{...e,...t};let i=Array.isArray(t.allOf)&&r.length===1?t.allOf:[t];if(Array.isArray(e.allOf))return{...e,allOf:[...e.allOf,...i]};if(typeof e.$ref==="string")return{allOf:[e,...i]};return{...e,allOf:i}}function DY(e,t,n,r){let o=new Map,s=new WeakMap,i=new Map,a=!1,c=Object.keys(n);for(let S of c)f(S,["references",S]);let u=jt(e,(S,y)=>d(x(S,t[y]))),l={};for(let S of c){let y=o.get(S);if(typeof y!=="string")U(l,S,d(y))}return{dialect:"draft-2020-12",schemas:u,definitions:l};function f(S,y){let h=o.get(S);if(h!==void 0)return typeof h==="string"?h:S;if(!Object.hasOwn(n,S))throw Do(`Invalid reference ${S}`,[...y,"$ref"]);o.set(S,null);let E=n[S],k=x(E,["references",S]),T=m(E);if(T!==void 0){let F=i.get(T),N=F?.find((R)=>Y(o.get(R),k));if(N===void 0)if(F===void 0)i.set(T,[S]);else F.push(S);else return a=!0,o.set(S,N),N}return o.set(S,k),S}function d(S){if(!a)return S;return YD(S,(y)=>y.replace(/^#\/\$defs\/([^/]*)/,(h,E)=>{let k=o.get(Wu(E));return typeof k==="string"?`#/$defs/${Ka(k)}`:h}))}function m(S){if(S._tag==="Reference")return;let y=S.checks.length===0?S.annotations:S.checks[S.checks.length-1].annotations;return typeof y?.identifier!=="string"&&typeof y?.[Ma]==="string"?y[Ma]:void 0}function g(S,y){return S?.schemas?.map((h,E)=>x(h,[...y,"schemas",E]))??[]}function b(S,y,h){let E=S.annotations,k=E?.toJsonSchema;if(k!==void 0){let R=g(S.representation,[...h,"representation"]),z=k({type:y,schemas:R}),q=Md(E,r),ue=q===void 0?z:{...z,...q},ut=q===void 0?o$:NY;return S._tag==="Filter"&&Sk(ue,ut)&&(q===void 0||Sk(q,Ek))?[ue,!0]:[ue]}if(S._tag==="Filter")return;let T=S.checks.map((R,z)=>b(R,y,[...h,"checks",z])).filter((R)=>R!==void 0);if(T.length===0)return;let F=Md(E,r),N=T.map(([R])=>R);return[F===void 0?{allOf:N}:{allOf:N,...F}]}function x(S,y){if(S._tag==="Reference"){let T=f(S.$ref,y);return{$ref:`#/$defs/${Ka(T)}`}}let h=s.get(S);if(h!==void 0)return h;let E=I(S,y),k=Md(S.annotations,r);if(k!==void 0)E={...E,...k};for(let T=0;T<S.checks.length;T++){let F=typeof E.type==="string"&&$Y(E.type)?E.type:void 0,N=b(S.checks[T],F,[...y,"checks",T]);if(N!==void 0)E=Nd(E,...N)}return s.set(S,E),E}function I(S,y){switch(S._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":case"UniqueSymbol":return{type:"string",allOf:[{pattern:"^Symbol\\((.*)\\)$"}]};case"Declaration":return{};case"Suspend":return x(S.thunk,[...y,"thunk"]);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN"]},{type:"string",enum:["Infinity"]},{type:"string",enum:["-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let h=S.literal;return typeof h==="bigint"?{type:"string",enum:[globalThis.String(h)]}:{type:typeof h,enum:[h]}}case"Enum":{let h=S.enums.map(([E,k])=>typeof k==="number"&&!globalThis.Number.isFinite(k)?{type:"string",enum:[globalThis.String(k)],title:E}:{type:typeof k,enum:[k],title:E});return h.length===0?{not:{}}:{anyOf:h}}case"TemplateLiteral":return{type:"string",pattern:`^${S.parts.map(Lg).join("")}$`};case"Arrays":{if(S.rest.length>1)throw Do("Invalid schema representation document",[...y,"rest"]);let h={type:"array"},E=S.elements.length,k=S.elements.map((T,F)=>{if(T.isOptional)E--;let N=x(T.type,[...y,"elements",F,"type"]),R=Md(T.annotations,r);return R===void 0?N:Nd(N,R)});if(k.length>0){if(h.prefixItems=k,h.maxItems=S.elements.length,E>0)h.minItems=E}else h.items=!1;if(S.rest.length===1){delete h.maxItems;let T=x(S.rest[0],[...y,"rest",0]);if(Object.keys(T).length>0)h.items=T;else delete h.items}return h}case"Objects":{if(S.propertySignatures.length===0&&S.indexSignatures.length===0)return{anyOf:[{type:"object"},{type:"array"}]};let h={type:"object"},E={},k=[];for(let R=0;R<S.propertySignatures.length;R++){let z=S.propertySignatures[R];if(typeof z.name!=="string")throw Do("Invalid schema representation document",[...y,"propertySignatures",R,"name"]);let q=z.name,ue=x(z.type,[...y,"propertySignatures",R,"type"]),ut=Md(z.annotations,r);if(U(E,q,ut===void 0?ue:Nd(ue,ut)),!z.isOptional)k.push(q)}if(S.propertySignatures.length>0)h.properties=E;if(k.length>0)h.required=k;let T={},F=[];for(let R=0;R<S.indexSignatures.length;R++){let z=S.indexSignatures[R],q=x(z.type,[...y,"indexSignatures",R,"type"]);if(Object.keys(q).length===1&&"not"in q)q=!1;let ue=C(z.parameter,[...y,"indexSignatures",R,"parameter"],new Set);if(ue.length===0)F.push(q);else for(let ut of ue){let Ks=T[ut];U(T,ut,Ks===void 0?q:Ks===!1||q===!1?!1:Nd(Ks,q))}}let N=Object.keys(T).length>0;if(N)h.patternProperties=T;if(S.indexSignatures.length===0)h.additionalProperties=r?.additionalProperties??!1;else if(F.length===1&&S.propertySignatures.length===0&&!N)h.additionalProperties=F[0];else if(F.length>0)h.allOf=F.map((R)=>({type:"object",additionalProperties:R}));if(typeof h.additionalProperties==="object"&&h.additionalProperties!==null&&Object.keys(h.additionalProperties).length===0)delete h.additionalProperties;return h}case"Union":{let h=S.types.map((E,k)=>x(E,[...y,"types",k]));if(h.length===0)return{not:{}};if(S.mode==="anyOf"&&h.length>1){let E=UY(h);if(E!==void 0)return E}return S.mode==="anyOf"?{anyOf:h}:{oneOf:h}}}}function C(S,y,h){switch(S._tag){case"Reference":{if(!Object.hasOwn(n,S.$ref))throw Do(`Invalid reference ${S.$ref}`,[...y,"$ref"]);if(f(S.$ref,y),h.has(S.$ref))return[];let E=new Set(h).add(S.$ref);return C(n[S.$ref],["references",S.$ref],E)}case"String":return s$(x(S,y));case"TemplateLiteral":return[`^${S.parts.map(Lg).join("")}$`];case"Union":return S.types.flatMap((E,k)=>C(E,[...y,"types",k],h));default:throw Do("Invalid schema representation document",y)}}}function $Y(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}function UY(e){let t=void 0,n=[];for(let r of e){if(Object.keys(r).length!==2||r.type===void 0||!Array.isArray(r.enum)||r.enum.length===0)return;if(t===void 0)t=r.type;else if(r.type!==t)return;n.push(...r.enum)}return{type:t,enum:n}}function s$(e){let t=[];if(typeof e.pattern==="string")t.push(e.pattern);for(let n of["allOf","anyOf","oneOf"]){let r=e[n];if(Array.isArray(r)){for(let o of r)if(typeof o==="object"&&o!==null&&!Array.isArray(o))t.push(...s$(o))}}return t}function Lg(e){switch(e._tag){case"Literal":return Ku(globalThis.String(e.literal));case"String":return T1;case"Number":return tg;case"TemplateLiteral":return e.parts.map(Lg).join("");case"Union":return e.types.map(Lg).join("|");default:throw Do("Invalid schema representation document",[])}}function i$(e,t){let n=DY([e.representation],[["representation"]],e.references,t);return{dialect:n.dialect,schema:n.schemas[0],definitions:n.definitions}}var FY,o$="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|",Ek="|title|description|default|examples|readOnly|writeOnly|",NY;var a$=w(()=>{An();yt();xk();yk();Ps();pk();Ti();FY=new Set([...gF,Ma,...mF]);NY=o$+Ek});function lo(e){return e===void 0?void 0:{annotations:e}}function bk(e,t){let{references:n,representations:r}=BY([e],t);return{representation:r[0],references:n}}function BY(e,t){let n={},r=new Map,o=new Set,s=new Map,i=new Set;for(let h of e)m(h);let a=t?.referencePolicy??jY;for(let h of s.values())for(let E of h.values()){let k=a({ast:E.ast,occurrences:E.occurrences,identifier:E.identifier});if(k!==void 0){let T=k===E.identifier||!k.endsWith("_")?"_":"";E.reference=u(k,E,T)}else if(E.isRecursive)E.reference=u(`${E.ast._tag}_`,E,"")}return{representations:jt(e,(h)=>b(h)),references:n};function u(h,E,k="_"){let T=h,F=0;while(r.has(T)){if(r.get(T)===E)return T;T=`${h}${k}${++F}`}return r.set(T,E),T}function l(h,E,k){let T=E.fallback;if(T!==void 0)return gw(h)===T?h:Ur(h,{[Ma]:T});return k===E.identifier?h:Ur(h,{identifier:k})}function f(h,E){if(!Object.hasOwn(n,h)&&!o.has(h)){o.add(h);let k=x(E);o.delete(h),U(n,h,k)}return{_tag:"Reference",$ref:h}}function d(h){let E=yd(h),k=bv(E),T=ku(E),F=T===void 0?(E!==h?ku(h):void 0)??gw(E):void 0;if(F!==void 0)T=`${F}Encoded`;let N=s.get(k);if(N===void 0)N=new Map,s.set(k,N);let R=N.get(T);if(R===void 0)R={ast:k,identifier:T,fallback:F,occurrences:0,isRecursive:!1,reference:void 0},N.set(T,R);return R}function m(h){let E=d(h),k=E.ast;if(E.occurrences++,i.has(E)){E.isRecursive=!0;return}if(E.occurrences>1)return;switch(i.add(E),g(k.checks),k._tag){case"Declaration":case"Arrays":case"Objects":case"Union":k.recur((T)=>(m(T),T));break;case"TemplateLiteral":k.parts.forEach(m);break;case"Suspend":m(k.thunk());break}i.delete(E)}function g(h){h?.forEach((E)=>{if(E.annotations?.representation?.schemas?.forEach((k)=>m(sn(k))),E._tag==="FilterGroup")g(E.checks)})}function b(h){let E=d(h),k=E.ast,T=E.reference;if(T!==void 0){let F=E.identifier===void 0?k:l(k,E,T);return f(T,F)}return x(k)}function x(h){let E=I(h.checks);switch(h._tag){case"Declaration":return{_tag:"Declaration",typeParameters:h.typeParameters.map((k)=>b(k)),checks:E,...S(h.annotations)};case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"String":case"Boolean":case"Number":case"BigInt":case"Symbol":case"ObjectKeyword":return{_tag:h._tag,checks:E,...lo(h.annotations)};case"Literal":return{_tag:"Literal",literal:h.literal,checks:E,...lo(h.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:h.symbol,checks:E,...lo(h.annotations)};case"Enum":return{_tag:"Enum",enums:h.enums,checks:E,...lo(h.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:h.parts.map((k)=>b(k)),checks:E,...lo(h.annotations)};case"Arrays":return{_tag:"Arrays",elements:h.elements.map((k)=>{let T=yd(k),F=T.context?.annotations;return{isOptional:bt(T),type:b(k),...lo(F)}}),rest:h.rest.map((k)=>b(k)),checks:E,...lo(h.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:h.propertySignatures.map((k)=>{let T=yd(k.type),F=T.context?.annotations;return{name:k.name,type:b(k.type),isOptional:bt(T),isMutable:w1(T),...lo(F)}}),indexSignatures:h.indexSignatures.map((k)=>({parameter:b(k.parameter),type:b(k.type)})),checks:E,...lo(h.annotations)};case"Union":return{_tag:"Union",types:h.types.map((k)=>b(k)),mode:h.mode,checks:E,...lo(h.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:b(h.thunk()),...lo(h.annotations)}}}function I(h){return h?.map(C)??[]}function C(h){switch(h._tag){case"Filter":return{_tag:"Filter",aborted:h.aborted,...y(h.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:jt(h.checks,C),...y(h.annotations)}}}function S(h){if(h===void 0)return;let{representation:E,...k}=h;return{...E===void 0?void 0:{representation:E},...Object.keys(k).length===0?void 0:{annotations:k}}}function y(h){if(h===void 0)return;let{representation:E,...k}=h,T=E===void 0?void 0:E.schemas===void 0?E:{...E,schemas:E.schemas.map((F)=>b(sn(F)))};return{...T===void 0?void 0:{representation:T},...Object.keys(k).length===0?void 0:{annotations:k}}}}var jY=({identifier:e})=>e;var c$=w(()=>{An();Ps();Ti()});function l$(e,t){let n=[];return wk(e,t,"",n),n}function wk(e,t,n,r){if(Object.is(e,t))return;if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,s=t.length,i=Math.min(o,s);for(let a=0;a<i;a++)wk(e[a],t[a],`${n}/${a}`,r);for(let a=o-1;a>=s;a--)r.push({op:"remove",path:`${n}/${a}`});for(let a=o;a<s;a++)r.push({op:"add",path:`${n}/${a}`,value:t[a]});return}if(jg(e)&&jg(t)){let o=Object.keys(e),s=Object.keys(t),i=Array.from(new Set([...o,...s])).sort();for(let a of i){let c=`${n}/${Ka(a)}`,u=Object.hasOwn(e,a),l=Object.hasOwn(t,a);if(u&&l)wk(e[a],t[a],c,r);else if(!u&&l)r.push({op:"add",path:c,value:t[a]});else r.push({op:"remove",path:c})}return}r.push({op:"replace",path:n,value:t})}function f$(e,t){let n=t;for(let r of e)n=zY(n,r);return n}function jg(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function qY(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(Wu)}function d$(e){if(!/^(0|[1-9]\d*)$/.test(e))throw Error(`Invalid array index: "${e}"`);return Number(e)}function zY(e,t){if(t.path===""){if(t.op==="remove")throw Error("Unsupported operation at the root");return t.value}let n=WY(e,t.path);if(n===null)throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:r,parent:o,stack:s}=n;if(Array.isArray(o)){if(r==="-"&&t.op!=="add")throw Error(`"-" is not valid for ${t.op} at "${t.path}".`);let i=r==="-"?o.length:d$(r),a=t.op==="add"?o.length:o.length-1;if(i>a)throw Error(`Array index out of bounds at "${t.path}".`);let c=o.slice();if(t.op==="add")c.splice(i,0,t.value);else if(t.op==="remove")c.splice(i,1);else c[i]=t.value;return u$(s,c)}if(jg(o)){if(t.op!=="add"&&!Object.hasOwn(o,r))throw Error(`Property "${r}" does not exist at "${t.path}".`);let i={...o};if(t.op==="remove")delete i[r];else U(i,r,t.value);return u$(s,i)}throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function WY(e,t){let n=qY(t);if(n.length===0)return null;let r=n[n.length-1],o=[],s=e;for(let i=0;i<n.length-1;i++){let a=n[i];if(Array.isArray(s)){let c=d$(a);if(c>=s.length)return null;o.push({container:s,token:c}),s=s[c];continue}if(jg(s)){if(!Object.hasOwn(s,a))return null;o.push({container:s,token:a}),s=s[a];continue}return null}return{stack:o,parent:s,lastToken:r}}function u$(e,t){let n=t;for(let r=e.length-1;r>=0;r--){let{container:o,token:s}=e[r];if(Array.isArray(o)){let i=o.slice();i[s]=n,n=i}else{let i={...o};U(i,s,n),n=i}}return n}var p$=()=>{};function g$(e,t){return fo(Vu("Iso",e,t))}function m$(e,t){return fo(Vu("Lens",e,t))}function Vu(e,t,n){return[{_tag:"PrimitiveNode",kind:e,get:t,set:n}]}class kk{_tag="PathNode";kind="Lens";path;get;set;constructor(e){this.path=e,this.get=(t)=>{let n=t;for(let r=0;r<e.length;r++)n=n[e[r]];return n},this.set=(t,n)=>{let r=Hg(n),o=r,s=0;for(;s<e.length-1;s++){let i=e[s];U(o,i,Hg(o[i])),o=o[i]}return U(o,e[s],t),r}}}class Bg{_tag="CheckNode";kind="Prism";checks;get;set=D;constructor(e){this.checks=e,this.get=(t)=>_1(e,t)}}function Ga(e,t){if(e.length===0)return t;if(t.length===0)return e;let n=e.slice();for(let r=0;r<t.length;r++){let o=t[r],s=n[n.length-1];if(s._tag==="PathNode"&&o._tag==="PathNode")n[n.length-1]=new kk([...s.path,...o.path]);else if(s._tag==="CheckNode"&&o._tag==="CheckNode")n[n.length-1]=new Bg([...s.checks,...o.checks]);else n.push(o)}return n}function GY(e,t){return fo(Vu("Optional",e,t))}class Dd{node;getResult;replaceResult;constructor(e,t,n){this.node=e,this.getResult=t,this.replaceResult=n}replace(e,t){return oi(this.replaceResult(e,t),()=>t)}modify(e){return(t)=>oi(si(this.getResult(t),(n)=>this.replaceResult(e(n),t)),()=>t)}compose(e){return fo(Ga(this.node,e.node))}key(e){return fo(Ga(this.node,[new kk([e])]))}optionalKey(e){return fo(Ga(this.node,Vu("Lens",(t)=>t[e],(t,n)=>{let r=Hg(n);if(t===void 0)if(Array.isArray(r)&&typeof e==="number")r.splice(e,1);else delete r[e];else U(r,e,t);return r})))}check(...e){return fo(Ga(this.node,[new Bg(e)]))}refine(e,t){return fo(Ga(this.node,[new Bg([ug(e,t)])]))}tag(e){let t=te(new we({expected:`${JSON.stringify(e)} tag`}));return fo(Ga(this.node,Vu("Prism",(n)=>n._tag===e?G(n):t,D)))}at(e,...t){let n=te(new Ft([e],new Da(void 0)));return fo(Ga(this.node,Vu("Optional",(r)=>Object.hasOwn(r,e)?G(r[e]):n,(r,o)=>{if(Object.hasOwn(o,e)){let s=Hg(o);return U(s,e,r),G(s)}else return n})))}pick(e){return this.compose(m$(bD(e),(t,n)=>({...n,...t})))}omit(e){return this.compose(m$(wD(e),(t,n)=>({...n,...t})))}notUndefined(){return this.refine(Le,{expected:"a value other than `undefined`"})}forEach(e){let t=e(qg());return GY((n)=>or(this.getResult(n),(r)=>{let o=[];for(let s=0;s<r.length;s++){let i=t.getResult(r[s]);if(Ut(i))o.push(i.success)}return o}),(n,r)=>si(this.getResult(r),(o)=>{let s=[];for(let a=0;a<o.length;a++)if(Ut(t.getResult(o[a])))s.push(a);if(n.length!==s.length)return te(new we({message:`each: replacement length mismatch: ${n.length} !== ${s.length}`}));let i=o.slice();for(let a=0;a<s.length;a++){let c=s[a],u=t.replaceResult(n[a],o[c]);if(xe(u))return te(new Ft([c],u.failure));i[c]=u.success}return this.replaceResult(i,r)}))}modifyAll(e){return(t)=>oi(si(this.getResult(t),(n)=>this.replaceResult(n.map(e),t)),()=>t)}}function fo(e){let t=e[0]??VY;if(e.length>1){let n=e.reduce((r,o)=>YY(r,o.kind),"Iso");t={kind:n,get:JY(e,n),set:ZY(e,n)}}switch(t.kind){case"Iso":return new x$(e,t.get,t.set);case"Lens":return new y$(e,t.get,t.set);case"Prism":return new S$(e,t.get,t.set);case"Optional":return new Dd(e,t.get,t.set)}}function Hg(e){if(Array.isArray(e))return e.slice();if(typeof e==="object"&&e!==null){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}function JY(e,t){return(n)=>{for(let r=0;r<e.length;r++){let o=e[r],s=o.get(n);if(vk(o.kind)){if(xe(s))return s;n=s.success}else n=s}return vk(t)?G(n):n}}function ZY(e,t){if(h$(t))return(n)=>{for(let r=e.length-1;r>=0;r--)n=e[r].set(n);return n};return(n,r)=>{let o=e.length,s=Array(o);for(let i=0;i<o;i++){s[i]=r;let a=e[i];if(vk(a.kind)){let c=a.get(r);if(xe(c))return c;r=c.success}else r=a.get(r)}for(let i=o-1;i>=0;i--){let a=e[i];if(h$(a.kind))n=a.set(n);else if(a.kind==="Lens")n=a.set(n,s[i]);else{let c=a.set(n,s[i]);if(xe(c))return c;n=c.success}}return t==="Optional"?G(n):n}}function vk(e){return e==="Prism"||e==="Optional"}function h$(e){return e==="Iso"||e==="Prism"}function YY(e,t){if(e==="Iso")return t;if(t==="Iso"||e===t)return e;return"Optional"}function qg(){return QY}var VY,x$,y$,S$,QY;var E$=w(()=>{X();he();gn();Ps();Ai();Dg();VY={kind:"Iso",get:D,set:D};x$=class x$ extends Dd{get;set;constructor(e,t,n){super(e,(r)=>G(t(r)),(r)=>G(n(r)));this.get=t,this.set=n}replace(e,t){return this.set(e)}modify(e){return(t)=>this.set(e(this.get(t)))}};y$=class y$ extends Dd{get;constructor(e,t,n){super(e,(r)=>G(t(r)),(r,o)=>G(n(r,o)));this.get=t,this.replace=n}modify(e){return(t)=>this.replace(e(this.get(t)),t)}};S$=class S$ extends Dd{set;constructor(e,t,n){super(e,t,(r,o)=>G(n(r)));this.set=n}replace(e,t){return this.set(e)}modify(e){return(t)=>oi(or(this.getResult(t),(n)=>this.set(e(n))),()=>t)}};QY=fo([])});var Ja,b$=(e)=>{if(Ja.has(e))return Ja.get(e);else throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var w$=w(()=>{Ja=new WeakMap});var v$="~effect/data/Redacted",Ik=(e)=>M(e,v$),Ns=(e,t)=>{let n=Object.create(tQ);if(t?.label)n.label=t.label;return Ja.set(n,e),n},tQ,Ui,k$=(e)=>Kt((t,n)=>e(Ui(t),Ui(n)));var $d=w(()=>{yt();Xo();Xt();rt();w$();he();tQ={[v$]:{_A:(e)=>e},label:void 0,...Cn,toJSON(){return this.toString()},toString(){return`<redacted${Wr(this.label)?":"+this.label:""}>`},[Ie](){return re(Ja.get(this))},[Ce](e){return Ik(e)&&Y(Ja.get(this),Ja.get(e))}},Ui=b$});var P={};Un(P,{Any:()=>PQ,Array:()=>$e,ArrayEnsure:()=>qQ,BigDecimal:()=>Wk,BigDecimalFromString:()=>L9,BigDecimalReviver:()=>U9,BigInt:()=>$o,BigIntFromString:()=>J9,Boolean:()=>Zg,BooleanFromBit:()=>n7,Cause:()=>Kg,CauseReason:()=>Wg,CauseReasonReviver:()=>u9,CauseReviver:()=>l9,Char:()=>Z8,Chunk:()=>y2,ChunkReviver:()=>v9,Class:()=>M2,Date:()=>Yn,DateFromMillis:()=>A9,DateFromString:()=>O9,DateReviver:()=>T9,DateTimeUtc:()=>Qd,DateTimeUtcFromDate:()=>c7,DateTimeUtcFromMillis:()=>l7,DateTimeUtcFromString:()=>u7,DateTimeUtcReviver:()=>a7,DateTimeZoned:()=>Yk,DateTimeZonedFromString:()=>x7,DateTimeZonedReviver:()=>g7,Defect:()=>qk,Duration:()=>Zd,DurationFromMillis:()=>F9,DurationFromNanos:()=>P9,DurationFromString:()=>w2,DurationReviver:()=>_9,Enum:()=>_Q,Error:()=>rx,ErrorInstance:()=>u2,ErrorInstanceReviver:()=>p9,Exit:()=>l2,ExitReviver:()=>m9,File:()=>Kk,FileReviver:()=>H9,Finite:()=>Zn,FiniteFromString:()=>G9,FormData:()=>Vk,FormDataReviver:()=>q9,Graph:()=>m2,GraphReviver:()=>S9,HashMap:()=>h2,HashMapReviver:()=>E9,HashSet:()=>x2,HashSetReviver:()=>w9,Int:()=>Uo,Json:()=>tp,JsonObject:()=>tX,JsonReviver:()=>nX,Literal:()=>Ke,Literals:()=>Ls,MutableJson:()=>W2,MutableJsonReviver:()=>oX,Natural:()=>an,Never:()=>RQ,NonEmptyArray:()=>HQ,NonEmptyString:()=>XU,Null:()=>Fe,NullOr:()=>Mk,NullishOr:()=>rU,Number:()=>Hd,NumberFromString:()=>V9,ObjectKeyword:()=>MQ,Opaque:()=>r8,Option:()=>ji,OptionFromNullOr:()=>Q8,OptionFromNullishOr:()=>e9,OptionFromOptional:()=>n9,OptionFromOptionalKey:()=>t9,OptionFromOptionalNullOr:()=>r9,OptionFromUndefinedOr:()=>X8,OptionReviver:()=>Y8,PropertyKey:()=>Ok,ReadonlyMap:()=>p2,ReadonlyMapReviver:()=>h9,ReadonlySet:()=>g2,ReadonlySetReviver:()=>b9,Record:()=>Yg,Redacted:()=>ex,RedactedFromValue:()=>c9,RedactedReviver:()=>a9,RegExp:()=>S2,RegExpReviver:()=>k9,Result:()=>e2,ResultReviver:()=>o9,SchemaError:()=>Za,StandardSchemaV1FailureResult:()=>t7,String:()=>J,StringFromBase64:()=>Y9,StringFromBase64Url:()=>Q9,StringFromHex:()=>X9,StringFromUriComponent:()=>e7,Struct:()=>Q,StructWithRest:()=>jQ,Symbol:()=>eU,TaggedClass:()=>b7,TaggedError:()=>po,TaggedStruct:()=>Xg,TaggedUnion:()=>n8,TemplateLiteral:()=>OQ,TemplateLiteralParser:()=>AQ,TimeZone:()=>Zk,TimeZoneFromString:()=>h7,TimeZoneNamed:()=>Jk,TimeZoneNamedFromString:()=>p7,TimeZoneNamedReviver:()=>d7,TimeZoneOffset:()=>A2,TimeZoneOffsetReviver:()=>f7,TimeZoneReviver:()=>m7,Tree:()=>eX,Trim:()=>Z9,Trimmed:()=>T2,Tuple:()=>Ju,TupleWithRest:()=>BQ,URL:()=>nx,URLFromString:()=>C9,URLReviver:()=>I9,URLSearchParams:()=>Gk,URLSearchParamsReviver:()=>W9,Uint8Array:()=>Yd,Uint8ArrayFromBase64:()=>o7,Uint8ArrayFromBase64Url:()=>s7,Uint8ArrayFromHex:()=>i7,Uint8ArrayReviver:()=>r7,Undefined:()=>Pk,UndefinedOr:()=>Qg,Union:()=>pt,UniqueArray:()=>zQ,UniqueSymbol:()=>NQ,Unknown:()=>Rk,UnknownFromJsonString:()=>B9,Void:()=>FQ,annotate:()=>rQ,annotateEncoded:()=>oQ,annotateKey:()=>sQ,asserts:()=>uQ,brand:()=>sU,catchDecoding:()=>JQ,catchDecodingWithContext:()=>cU,catchEncoding:()=>ZQ,catchEncodingWithContext:()=>uU,check:()=>KQ,declare:()=>Br,declareConstructor:()=>Qn,decode:()=>YQ,decodeEffect:()=>lQ,decodeExit:()=>fQ,decodeOption:()=>pQ,decodePromise:()=>hQ,decodeResult:()=>mQ,decodeSync:()=>gQ,decodeTo:()=>de,decodeUnknownEffect:()=>Us,decodeUnknownExit:()=>z$,decodeUnknownOption:()=>dQ,decodeUnknownPromise:()=>K$,decodeUnknownResult:()=>W$,decodeUnknownSync:()=>V$,encode:()=>QQ,encodeEffect:()=>G$,encodeExit:()=>xQ,encodeKeys:()=>UQ,encodeOption:()=>SQ,encodePromise:()=>bQ,encodeResult:()=>EQ,encodeSync:()=>wQ,encodeTo:()=>Nk,encodeUnknownEffect:()=>Gg,encodeUnknownExit:()=>J$,encodeUnknownOption:()=>yQ,encodeUnknownPromise:()=>Y$,encodeUnknownResult:()=>Z$,encodeUnknownSync:()=>Q$,extendTo:()=>LQ,fieldsAssign:()=>DQ,flip:()=>Ck,fromBrand:()=>GQ,fromFormData:()=>z9,fromJsonString:()=>C2,fromURLSearchParams:()=>K9,instanceOf:()=>Li,is:()=>Bd,isBase64:()=>Uk,isBase64Reviver:()=>h8,isBase64Url:()=>EU,isBase64UrlReviver:()=>g8,isBetween:()=>Gd,isBetweenBigDecimal:()=>U8,isBetweenBigInt:()=>qU,isBetweenBigIntReviver:()=>G7,isBetweenDate:()=>UU,isBetweenDateReviver:()=>q7,isBetweenReviver:()=>A8,isCapitalized:()=>CU,isCapitalizedReviver:()=>w8,isEndsWith:()=>wU,isEndsWithReviver:()=>y8,isFinite:()=>OU,isFiniteReviver:()=>k8,isGUID:()=>yU,isGUIDReviver:()=>p8,isGreaterThan:()=>_U,isGreaterThanBigDecimal:()=>M8,isGreaterThanBigInt:()=>LU,isGreaterThanBigIntReviver:()=>z7,isGreaterThanDate:()=>MU,isGreaterThanDateReviver:()=>L7,isGreaterThanOrEqualTo:()=>Lk,isGreaterThanOrEqualToBigDecimal:()=>N8,isGreaterThanOrEqualToBigInt:()=>jU,isGreaterThanOrEqualToBigIntReviver:()=>W7,isGreaterThanOrEqualToDate:()=>NU,isGreaterThanOrEqualToDateReviver:()=>j7,isGreaterThanOrEqualToReviver:()=>C8,isGreaterThanReviver:()=>I8,isIncludes:()=>vU,isIncludesReviver:()=>S8,isInt:()=>Jd,isInt32:()=>P8,isIntReviver:()=>R8,isLengthBetween:()=>Bk,isLengthBetweenReviver:()=>B8,isLessThan:()=>RU,isLessThanBigDecimal:()=>D8,isLessThanBigInt:()=>BU,isLessThanBigIntReviver:()=>K7,isLessThanDate:()=>DU,isLessThanDateReviver:()=>B7,isLessThanOrEqualTo:()=>PU,isLessThanOrEqualToBigDecimal:()=>$8,isLessThanOrEqualToBigInt:()=>HU,isLessThanOrEqualToBigIntReviver:()=>V7,isLessThanOrEqualToDate:()=>$U,isLessThanOrEqualToDateReviver:()=>H7,isLessThanOrEqualToReviver:()=>O8,isLessThanReviver:()=>T8,isLowercased:()=>IU,isLowercasedReviver:()=>b8,isMaxLength:()=>WU,isMaxLengthReviver:()=>j8,isMaxProperties:()=>ZU,isMaxPropertiesReviver:()=>K8,isMaxSize:()=>VU,isMaxSizeReviver:()=>q8,isMinLength:()=>jk,isMinLengthReviver:()=>L8,isMinProperties:()=>JU,isMinPropertiesReviver:()=>W8,isMinSize:()=>KU,isMinSizeReviver:()=>H8,isMultipleOf:()=>FU,isMultipleOfReviver:()=>_8,isNonEmpty:()=>zU,isPattern:()=>Ya,isPatternReviver:()=>a8,isPropertiesLengthBetween:()=>YU,isPropertiesLengthBetweenReviver:()=>V8,isPropertyNames:()=>QU,isPropertyNamesReviver:()=>G8,isSchema:()=>Jg,isSchemaError:()=>L$,isSizeBetween:()=>GU,isSizeBetweenReviver:()=>z8,isStartsWith:()=>bU,isStartsWithReviver:()=>x8,isStringBigInt:()=>hU,isStringBigIntReviver:()=>u8,isStringFinite:()=>mU,isStringFiniteReviver:()=>c8,isStringSymbol:()=>gU,isStringSymbolReviver:()=>l8,isTrimmed:()=>$k,isTrimmedReviver:()=>s8,isULID:()=>SU,isULIDReviver:()=>m8,isUUID:()=>xU,isUUIDReviver:()=>d8,isUint32:()=>F8,isUncapitalized:()=>TU,isUncapitalizedReviver:()=>v8,isUnique:()=>Hk,isUniqueReviver:()=>J8,isUppercased:()=>kU,isUppercasedReviver:()=>E8,link:()=>Je,make:()=>V,makeFilter:()=>Ze,makeFilterGroup:()=>o8,makeIsBetween:()=>Vd,makeIsGreaterThan:()=>qd,makeIsGreaterThanOrEqualTo:()=>zd,makeIsLessThan:()=>Wd,makeIsLessThanOrEqualTo:()=>Kd,makeIsMultipleOf:()=>AU,middlewareDecoding:()=>iU,middlewareEncoding:()=>aU,mutable:()=>WQ,mutableKey:()=>IQ,optional:()=>Nn,optionalKey:()=>Ds,overrideToCodecIso:()=>Q7,overrideToEquivalence:()=>I7,overrideToFormatter:()=>v7,readonlyKey:()=>CQ,refine:()=>VQ,required:()=>kQ,requiredKey:()=>vQ,resolveAnnotations:()=>sX,resolveAnnotationsKey:()=>iX,revealBottom:()=>nQ,revealCodec:()=>iQ,suspend:()=>oU,tag:()=>$s,tagDefaultOmit:()=>t8,toArbitrary:()=>w7,toCodecArrayFromSingle:()=>R7,toCodecIso:()=>L2,toCodecJson:()=>D2,toCodecJsonAST:()=>ox,toCodecStringTree:()=>ep,toDifferJsonPatch:()=>X7,toEncoded:()=>Xu,toEncoderXml:()=>P7,toEquivalence:()=>C7,toFormatter:()=>k7,toIso:()=>J7,toIsoFocus:()=>Y7,toIsoSource:()=>Z7,toJsonSchemaDocument:()=>N2,toRepresentation:()=>T7,toStandardJSONSchemaV1:()=>cQ,toStandardSchemaV1:()=>aQ,toTaggedUnion:()=>pU,toType:()=>Dn,withConstructorDefault:()=>lU,withDecodingDefault:()=>dU,withDecodingDefaultKey:()=>Dk,withDecodingDefaultType:()=>e8,withDecodingDefaultTypeKey:()=>XQ});function Qn(){return(e,t,n)=>V(new Ba(e.map(pd),(r)=>t(r.map((o)=>V(o))),n))}function Br(e,t){return Qn()([],()=>(n,r,o)=>e(n)?v(n):A(new ft(r,n,o)),t)}function nQ(e){return e}function rQ(e){return(t)=>t.annotate(e)}function oQ(e){return(t)=>Ck(Ck(t).annotate(e))}function sQ(e){return(t)=>t.rebuild(Sd(t.ast,e))}function iQ(e){return e}function L$(e){return M(e,Ld)&&e[Ld]===Ld}function I$(e){return Rt(e)?e.value:{issues:[{message:JE(e.cause)}]}}function aQ(e,t){let n=vt(e),r={errors:"all",...t?.parseOptions},o=bF(t),s=(i)=>{let a=new zc("sync"),c=To(wi(n(i,r),{onFailure:o,onSuccess:(l)=>({value:l})}),{scheduler:a});c.currentDispatcher?.flush();let u=c.pollUnsafe();if(u)return I$(u);return new Promise((l)=>{c.addObserver((f)=>{l(I$(f))})})};if("~standard"in e){let i=e;if("validate"in i["~standard"])return i;return Object.assign(i["~standard"],{validate:s}),i}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}function C$(e,t){let n=N2(e);if(t==="draft-2020-12"){let r=n.schema;if(Object.keys(n.definitions).length>0)r.$defs=n.definitions;return r}else if(t==="draft-07"){let r=ZD(n),o=r.schema;if(Object.keys(r.definitions).length>0)o.definitions=r.definitions;return o}throw new globalThis.Error(`Unsupported target: ${t}`)}function cQ(e){let t={input(n){return C$(e,n.target)},output(n){return C$(Dn(e),n.target)}};if("~standard"in e){let n=e;if("jsonSchema"in n["~standard"])return n;return Object.assign(n["~standard"],{jsonSchema:t}),n}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}function Us(e,t){let n=vt(e,t);return(r,o)=>j$(n(r,o))}function j$(e){if(We(e))return _k(e);return xr(e,(t)=>Ei(()=>ms(t,(n)=>new Za(n))))}function B$(e,t){let n;for(let r of e.reasons){if(!ff(r)||!L$(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function H$(e){return ph(e).then((t)=>{if(Rt(t))return t.value;throw B$(t.cause,"Promise adapter can only reject schema errors")})}function q$(e){let t=ki(e);if(Rt(t))return t.value;throw B$(t.cause,"Sync adapter can only throw schema errors")}function z$(e,t){let n=sD(e,t);return(r,o)=>_k(n(r,o))}function _k(e){return Rt(e)?e:lr(ms(e.cause,(t)=>new Za(t)))}function W$(e,t){let n=aD(e,t);return(r,o)=>Bc(n(r,o),(s)=>new Za(s))}function K$(e,t){let n=Us(e,t);return(r,o)=>H$(n(r,o))}function V$(e,t){let n=Us(e,t);return(r,o)=>q$(n(r,o))}function Gg(e,t){let n=qu(e,t);return(r,o)=>j$(n(r,o))}function J$(e,t){let n=cD(e,t);return(r,o)=>_k(n(r,o))}function Z$(e,t){let n=lD(e,t);return(r,o)=>Bc(n(r,o),(s)=>new Za(s))}function Y$(e,t){let n=Gg(e,t);return(r,o)=>H$(n(r,o))}function Q$(e,t){let n=Gg(e,t);return(r,o)=>q$(n(r,o))}function Jg(e){return M(e,Ud)&&e[Ud]===Ud}function TQ(e){return M(e,jd)&&e[jd]===jd}function Ck(e){if(TQ(e))return e.schema.rebuild(oo(e.ast));return V(oo(e.ast),{[jd]:jd,schema:e})}function Ke(e){let t=V(new Er(e),{literal:e,transform(n){return t.pipe(de(Ke(n),{decode:ve(()=>n),encode:ve(()=>e)}))}});return t}function X$(e){return new pv(e.map((t)=>Jg(t)?t.ast:new Er(t)))}function OQ(e){return V(X$(e),{parts:e})}function AQ(e){return V(X$(e).asTemplateLiteralParser(),{parts:e})}function _Q(e){return V(new dv(Object.keys(e).filter((t)=>typeof e[e[t]]!=="number").map((t)=>[t,e[t]])),{enums:e})}function NQ(e){return V(new mv(e))}function Fk(e,t){return V(e,{fields:t,mapFields(n,r){let o=n(this.fields);return Fk(og(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Q(e){return Fk(og(e,void 0),e)}function DQ(e){return En((t)=>t.mapFields(vD(e)))}function UQ(e){return function(t){let n={},r=Object.create(null),o=Object.create(null),s=new Set;for(let i of Reflect.ownKeys(t.fields)){let a=Xu(t.fields[i]),c=Object.hasOwn(e,i),u=c?e[i]:i,l=$Q(u);if(s.has(l))throw new globalThis.Error(`Duplicate encoded keys: ${Go(u)}`);if(s.add(l),U(n,u,a),c)r[i]=u,o[u]=i}return Q(n).pipe(de(t,st({decode:lk(o),encode:lk(r)})))}}function LQ(e,t){return(n)=>{let r=MC(n.fields,Dn),o=Q({...r,...e});return n.pipe(de(o,st({decode:(s)=>{let i={...s};for(let a in e){let c=t[a],u=c(s);if(Ee(u))U(i,a,u.value)}return i},encode:(s)=>{let i={...s};for(let a in e)delete i[a];return i}})))}}function Yg(e,t){return V(b1(e.ast,t.ast),{key:e,value:t})}function jQ(e,t){return V(l1(e.ast,t.map(pd)),{schema:e,records:t})}function tU(e,t){return V(e,{elements:t,mapElements(n,r){let o=n(this.elements);return tU(yv(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Ju(e){return tU(yv(e),e)}function BQ(e,t){return V(f1(e.ast,t.map(pd)),{schema:e,rest:t})}function qQ(e){return pt([e,$e(e)]).pipe(de($e(Dn(e)),st({decode:DC,encode:(t)=>t.length===1?t[0]:t})))}function zQ(e){return $e(e).check(Hk())}function nU(e,t){return V(e,{members:t,mapMembers(n,r){let o=n(this.members);return nU(sg(o,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function pt(e,t){return nU(sg(e,t?.mode??"anyOf",void 0),e)}function Ls(e){let t=e.map(Ke);return V(sg(t,"anyOf",void 0),{literals:e,members:t,mapMembers(n){return pt(n(this.members))},pick(n){return Ls(n)},transform(n){return pt(t.map((r,o)=>r.transform(n[o])))}})}function oU(e){return V(new ag(()=>e().ast))}function KQ(...e){return(t)=>t.check(...e)}function VQ(e,t){return(n)=>V(Fo(n.ast,[ug(e,t)]),{schema:n})}function sU(e){return(t)=>V(y1(t.ast,e),{schema:t,identifier:e})}function GQ(e,t){return(n)=>(t.checks?n.check(...t.checks):n).pipe(sU(e))}function iU(e){return(t)=>V(g1(t.ast,new ld(e,D)),{schema:t})}function aU(e){return(t)=>V(x1(t.ast,new ld(D,e)),{schema:t})}function JQ(e){return cU(e)}function cU(e){return(t)=>iU(Bf(e))(t)}function ZQ(e){return uU(e)}function uU(e){return(t)=>aU(Bf(e))(t)}function de(e,t){return(n)=>V(dg(n.ast,e.ast,t?Zh(t):Ou()),{from:n,to:e})}function YQ(e){return(t)=>de(Dn(t),e)(t)}function Nk(e,t){return(n)=>t?de(n,t)(e):de(n)(e)}function QQ(e){return(t)=>de(t,e)(Xu(t))}function lU(e){return(t)=>V(E1(t.ast,e),{schema:t})}function fU(e){return xr(e,(t)=>Ei(()=>ms(t,(n)=>n.issue)))}function Dk(e,t){let n=t?.encodingStrategy==="omit"?Nw():ro();return(r)=>Ds(Xu(r)).pipe(de(r,{decode:cd(fU(e)),encode:n}))}function XQ(e,t){return(n)=>Dn(n).pipe(Dk(e,t),Nk(Ds(n)))}function dU(e,t){let n=t?.encodingStrategy==="omit"?Nw():ro();return(r)=>Nn(Xu(r)).pipe(de(r,{decode:cd(fU(e)),encode:n}))}function e8(e,t){return(n)=>Dn(n).pipe(dU(e,t),Nk(Nn(n)))}function $s(e){return Ke(e).pipe(lU(v(e)))}function t8(e){return $s(e).pipe(Dk(v(e),{encodingStrategy:"omit"}))}function Xg(e,t){return Q({_tag:$s(e),...t})}function pU(e){return(t)=>{let n={},r=[],o=new Set,s={},i=(l)=>(f)=>l.includes(f[e]);return a(t),Object.assign(t,{cases:n,discriminants:r,isAnyOf:i,guards:s,match:c,matchOrElse:u});function a(l){let f=l.ast;if(HM(f)&&"members"in l&&globalThis.Array.isArray(l.members)&&l.members.every(Jg))return l.members.forEach(a);let d=Ru(f);if(d.length>0){let m=d.find((g)=>g.key===e)?.literal;if(Ap(m)){let g=typeof m==="number"?globalThis.String(m):m;if(o.has(g))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(m)}`);o.add(g),r.push(m),U(n,m,l),U(s,m,Bd(Dn(l)));return}}throw new globalThis.Error("No literal or unique symbol found")}function c(){if(arguments.length===1){let g=arguments[0];return function(b){let x=b[e];return(Object.hasOwn(g,x)?g[x]:void 0)(b)}}let l=arguments[0],f=arguments[1],d=l[e];return(Object.hasOwn(f,d)?f[d]:void 0)(l)}function u(){if(arguments.length===2){let b=arguments[0],x=arguments[1];return function(I){let C=I[e];return(Object.hasOwn(b,C)?b[C]??x:x)(I)}}let l=arguments[0],f=arguments[1],d=arguments[2],m=l[e];return(Object.hasOwn(f,m)?f[m]??d:d)(l)}}}function n8(e){let t={},n=[];for(let c of Object.keys(e)){let u=Xg(c,e[c]);U(t,c,u),n.push(u)}let r=pt(n),{guards:o,isAnyOf:s,match:i,matchOrElse:a}=pU("_tag")(r);return V(r.ast,{cases:t,isAnyOf:s,guards:o,match:i,matchOrElse:a})}function r8(){return(e)=>e}function Li(e,t){return Br((n)=>n instanceof e,t)}function Je(){return(e,t)=>new dt(e.ast,Zh(t))}function o8(e,t=void 0){return new Pi(e,t)}function bn(e,t){return Mn(e,Fe,({annotations:n})=>n===void 0?t:t.annotate(n))}function $k(e){let t=new globalThis.RegExp(T$);return Ze((n)=>n.trim()===n,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isTrimmed()"}),arbitrary:{constraint:{patterns:[T$]}},...e})}function Ya(e,t){let{source:n,flags:r}=e,o=r===""?`new RegExp(${B(n)})`:`new RegExp(${B(n)}, ${B(r)})`;return hd(e,{toCode:()=>({runtime:`Schema.isPattern(${o})`}),...t})}function mU(e){return Cv({toCode:()=>({runtime:"Schema.isStringFinite()"}),...e})}function hU(e){return Tv({toCode:()=>({runtime:"Schema.isStringBigInt()"}),...e})}function gU(e){return Av({toCode:()=>({runtime:"Schema.isStringSymbol()"}),...e})}function xU(e,t){let n=f8(e);return Ya(n,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:n.source,format:"uuid"}),toCode:()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),...t})}function yU(e){return Ya(O$,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:()=>({pattern:O$.source}),toCode:()=>({runtime:"Schema.isGUID()"}),...e})}function SU(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return Ya(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isULID()"}),...e})}function Uk(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return Ya(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64()"}),...e})}function EU(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return Ya(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64Url()"}),...e})}function bU(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`^${Ku(e)}`);return Ze((o)=>o.startsWith(e),{expected:`a string starting with ${n}`,representation:{id:"effect/schema/isStartsWith",payload:{startsWith:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isStartsWith(${B(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}function wU(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`${Ku(e)}$`);return Ze((o)=>o.endsWith(e),{expected:`a string ending with ${n}`,representation:{id:"effect/schema/isEndsWith",payload:{endsWith:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isEndsWith(${B(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}function vU(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(Ku(e));return Ze((o)=>o.includes(e),{expected:`a string including ${n}`,representation:{id:"effect/schema/isIncludes",payload:{includes:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isIncludes(${B(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}function kU(e){let t=new globalThis.RegExp(A$);return Ze((n)=>n.toUpperCase()===n,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isUppercased()"}),arbitrary:{constraint:{patterns:[A$]}},...e})}function IU(e){let t=new globalThis.RegExp(_$);return Ze((n)=>n.toLowerCase()===n,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isLowercased()"}),arbitrary:{constraint:{patterns:[_$]}},...e})}function CU(e){let t=new globalThis.RegExp(R$);return Ze((n)=>n.charAt(0).toUpperCase()===n.charAt(0),{expected:"a string with the first character in uppercase",representation:{id:"effect/schema/isCapitalized",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isCapitalized()"}),arbitrary:{constraint:{patterns:[R$]}},...e})}function TU(e){let t=new globalThis.RegExp(P$);return Ze((n)=>n.charAt(0).toLowerCase()===n.charAt(0),{expected:"a string with the first character in lowercase",representation:{id:"effect/schema/isUncapitalized",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isUncapitalized()"}),arbitrary:{constraint:{patterns:[P$]}},...e})}function qd(e){let t=ti(e.order),n=e.formatter??B;return(r,o)=>Ze((s)=>t(s,r),{expected:`a value greater than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r,exclusiveMinimum:!0}}},...e.annotate?.(r),...o})}function zd(e){let t=Dl(e.order),n=e.formatter??B;return(r,o)=>Ze((s)=>t(s,r),{expected:`a value greater than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r}}},...e.annotate?.(r),...o})}function Wd(e){let t=Uc(e.order),n=e.formatter??B;return(r,o)=>Ze((s)=>t(s,r),{expected:`a value less than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r,exclusiveMaximum:!0}}},...e.annotate?.(r),...o})}function Kd(e){let t=Nl(e.order),n=e.formatter??B;return(r,o)=>Ze((s)=>t(s,r),{expected:`a value less than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r}}},...e.annotate?.(r),...o})}function Vd(e){let t=Dl(e.order),n=ti(e.order),r=Nl(e.order),o=Uc(e.order),s=e.formatter??B;return(i,a)=>{let c=i.exclusiveMinimum?n:t,u=i.exclusiveMaximum?o:r;return Ze((l)=>c(l,i.minimum)&&u(l,i.maximum),{expected:`a value between ${s(i.minimum)}${i.exclusiveMinimum?" (excluded)":""} and ${s(i.maximum)}${i.exclusiveMaximum?" (excluded)":""}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:i.minimum,maximum:i.maximum,...i.exclusiveMinimum&&{exclusiveMinimum:!0},...i.exclusiveMaximum&&{exclusiveMaximum:!0}}}},...e.annotate?.(i),...a})}}function AU(e){return(t,n)=>{let r=e.formatter??B;return Ze((o)=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${r(t)}`,...e.annotate?.(t),...n})}}function Zu(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${B(e)}`);return e}function Jd(e){return Ze((t)=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer"}),toCode:()=>({runtime:"Schema.isInt()"}),arbitrary:{constraint:{integer:!0}},...e})}function P8(e){return new Pi([Jd(),Gd({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}function F8(e){return new Pi([Jd(),Gd({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}function Yu(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${B(e)}`);return e.toISOString()}function Qu(e){return`new Date(${B(e.getTime())})`}function jk(e,t){return e=Math.max(0,Math.floor(e)),Ze((n)=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="array"?{minItems:e}:{minLength:e},toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[Wn]:!0,arbitrary:{constraint:{minLength:e}},...t})}function zU(e){return jk(1,e)}function WU(e,t){return e=Math.max(0,Math.floor(e)),Ze((n)=>n.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:n})=>n==="array"?{maxItems:e}:{maxLength:e},toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[Wn]:!0,arbitrary:{constraint:{maxLength:e}},...t})}function Bk(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Ze((r)=>r.length>=e&&r.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:"effect/schema/isLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:({type:r})=>r==="array"?{allOf:[{minItems:e},{maxItems:t}]}:{allOf:[{minLength:e},{maxLength:t}]},toCode:()=>({runtime:`Schema.isLengthBetween(${e}, ${t})`}),[Wn]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}function KU(e,t){return e=Math.max(0,Math.floor(e)),Ze((n)=>n.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[Wn]:!0,arbitrary:{constraint:{minLength:e}},...t})}function VU(e,t){return e=Math.max(0,Math.floor(e)),Ze((n)=>n.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[Wn]:!0,arbitrary:{constraint:{maxLength:e}},...t})}function GU(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Ze((r)=>r.size>=e&&r.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:"effect/schema/isSizeBetween",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isSizeBetween(${e}, ${t})`}),[Wn]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}function JU(e,t){return e=Math.max(0,Math.floor(e)),Ze((n)=>Reflect.ownKeys(n).length>=e,{expected:`a value with at least ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMinProperties",payload:{minProperties:e}},toJsonSchema:()=>({minProperties:e}),toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[Wn]:!0,arbitrary:{constraint:{minLength:e}},...t})}function ZU(e,t){return e=Math.max(0,Math.floor(e)),Ze((n)=>Reflect.ownKeys(n).length<=e,{expected:`a value with at most ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMaxProperties",payload:{maxProperties:e}},toJsonSchema:()=>({maxProperties:e}),toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[Wn]:!0,arbitrary:{constraint:{maxLength:e}},...t})}function YU(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Ze((r)=>Reflect.ownKeys(r).length>=e&&Reflect.ownKeys(r).length<=t,{expected:e===t?`a value with exactly ${e===1?"1 entry":`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:"effect/schema/isPropertiesLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({minProperties:e,maxProperties:t}),toCode:()=>({runtime:`Schema.isPropertiesLengthBetween(${e}, ${t})`}),[Wn]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}function QU(e,t){let n=Xu(e),r=rD(n.ast);return Ze((o,s,i)=>{let a=Reflect.ownKeys(o),c=[];for(let u of a){let l=r(u,i);if(l!==void 0){if(c.push(new Ft([u],l)),i.errors==="first")break}}if(la(c))return new Et(s,c,o,i);return!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[n.ast]},toJsonSchema:({schemas:o})=>({propertyNames:o[0]}),toCode:({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),[Wn]:!0,...t})}function Hk(e){return Ze((t)=>tm(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:"Schema.isUnique()"}),arbitrary:{constraint:{unique:!0}},...e})}function ji(e){let t=Qn()([e],([n])=>(r,o,s)=>{if(jc(r)){if(me(r))return Aa;return Jt(vt(n)(r.value,s),{onSuccess:_,onFailure:(i)=>Kn(o,"value",i,r,s)})}return A(new ft(o,r,s))},{representation:{id:"effect/schema/Option",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Option(${n[0].runtime})`,Type:`Option.Option<${n[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),expected:"Option",toCodec:([n])=>Je()(pt([Q({_tag:Ke("Some"),value:n}),Q({_tag:Ke("None")})]),st({decode:(r)=>r._tag==="None"?O():_(r.value),encode:(r)=>Ee(r)?{_tag:"Some",value:r.value}:{_tag:"None"}})),toArbitrary:([n])=>(r,o)=>{let s=r.constant(O()),i=r.oneof(s,n.arbitrary.map(_));return Qa(r,o,s,i)},toEquivalence:([n])=>Zy(n),toFormatter:([n])=>et({onNone:()=>"none()",onSome:(r)=>`some(${n(r)})`})});return V(t.ast,{value:e})}function Q8(e){return Mk(e).pipe(de(ji(Dn(e)),bM()))}function X8(e){return Qg(e).pipe(de(ji(Dn(e)),wM()))}function e9(e,t){return rU(e).pipe(de(ji(Dn(e)),vM(t)))}function t9(e){return Ds(e).pipe(de(ji(Dn(e)),kM()))}function n9(e){return Nn(e).pipe(de(ji(Dn(e)),IM()))}function r9(e,t){let n=t===void 0?"omit":t.onNoneEncoding,r=n===null?null:void 0;return Nn(Mk(e)).pipe(de(ji(Dn(e)),Yh({decode:(o)=>o.pipe(ca(_p),_),encode:n==="omit"?aa:(o)=>_(mt(aa(o),()=>r))})))}function e2(e,t){let n=Qn()([e,t],([r,o])=>(s,i,a)=>{if(!Qp(s))return A(new ft(i,s,a));switch(s._tag){case"Success":return Jt(rk(r)(s.success,a),{onSuccess:G,onFailure:(c)=>Kn(i,"success",c,s,a)});case"Failure":return Jt(rk(o)(s.failure,a),{onSuccess:te,onFailure:(c)=>Kn(i,"failure",c,s,a)})}},{representation:{id:"effect/schema/Result",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Result(${r[0].runtime}, ${r[1].runtime})`,Type:`Result.Result<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Result from "effect/Result"']}),expected:"Result",toCodec:([r,o])=>Je()(pt([Q({_tag:Ke("Success"),success:r}),Q({_tag:Ke("Failure"),failure:o})]),st({decode:(s)=>s._tag==="Success"?G(s.success):te(s.failure),encode:(s)=>Ut(s)?{_tag:"Success",success:s.success}:{_tag:"Failure",failure:s.failure}})),toArbitrary:([r,o])=>(s,i)=>{let a=f2(s,r.terminal?.map((u)=>G(u)),o.terminal?.map((u)=>te(u))),c=s.oneof(r.arbitrary.map((u)=>G(u)),o.arbitrary.map((u)=>te(u)));return Qa(s,i,a,c)},toEquivalence:([r,o])=>aS(r,o),toFormatter:([r,o])=>Bn({onSuccess:(s)=>`success(${r(s)})`,onFailure:(s)=>`failure(${o(s)})`})});return V(n.ast,{success:e,failure:t})}function ex(e,t){let n=typeof t?.label==="string"?t.label:void 0,r=t?.disallowJsonEncode===!0,o=n!==void 0?r?{label:n,disallowJsonEncode:!0}:{label:n}:r?{disallowJsonEncode:!0}:void 0,s=n!==void 0?vt(Ke(n)):void 0,i=Qn()([e],([a])=>(c,u,l)=>{if(Ik(c)){let f=s!==void 0?Ra(s(c.label,l),(d)=>new Ft(["label"],d)):Te;return on(f,()=>Jt(vt(a)(Ui(c),l),{onSuccess:()=>c,onFailure:()=>new Et(u,[new Ft(["value"],new we(void 0,c,l))],c,l)}))}return A(new ft(u,c,l))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:({typeParameters:a})=>({runtime:o!==void 0?`Schema.Redacted(${a[0].runtime}, ${B(o)})`:`Schema.Redacted(${a[0].runtime})`,Type:`Redacted.Redacted<${a[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),expected:"Redacted",toCodecJson:([a])=>Je()(a,{decode:ve((c)=>Ns(c,{label:n})),encode:r?Fw((c)=>"Cannot serialize Redacted"+(Ee(c)&&typeof c.value.label==="string"?` with label: "${c.value.label}"`:"")):ve(Ui)}),toArbitrary:([a])=>()=>({arbitrary:a.arbitrary.map((c)=>Ns(c,{label:n})),terminal:a.terminal?.map((c)=>Ns(c,{label:n}))}),toFormatter:()=>globalThis.String,toEquivalence:([a])=>k$(a)});return V(i.ast,{value:e})}function c9(e,t){return de(ex(Dn(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:ve((n)=>Ns(n,{label:t?.label})),encode:t?.disallowEncode?Fw((n)=>"Cannot encode Redacted"+(Ee(n)&&typeof n.value.label==="string"?` with label: "${n.value.label}"`:"")):ve(Ui)})(e)}function Wg(e,t){let n=Qn()([e,t],([r,o])=>(s,i,a)=>{if(!KE(s))return A(new ft(i,s,a));switch(s._tag){case"Fail":return Jt(vt(r)(s.error,a),{onSuccess:df,onFailure:(c)=>Kn(i,"error",c,s,a)});case"Die":return Jt(vt(o)(s.defect,a),{onSuccess:pf,onFailure:(c)=>Kn(i,"defect",c,s,a)});case"Interrupt":return v(s)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.CauseReason(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Failure<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause.Failure",toCodec:([r,o])=>Je()(pt([Q({_tag:Ke("Fail"),error:r}),Q({_tag:Ke("Die"),defect:o}),Q({_tag:Ke("Interrupt"),fiberId:Qg(Zn)})]),st({decode:(s)=>{switch(s._tag){case"Fail":return df(s.error);case"Die":return pf(s.defect);case"Interrupt":return mf(s.fiberId)}},encode:D})),toArbitrary:([r,o])=>t2(r,o),toEquivalence:([r,o])=>n2(r,o),toFormatter:([r,o])=>r2(r,o)});return V(n.ast,{error:e,defect:t})}function t2(e,t){return(n,r)=>{let o=n.constant(mf()),s=n.oneof(o,n.integer({min:1}).map(mf),e.arbitrary.map((i)=>df(i)),t.arbitrary.map((i)=>pf(i)));return Qa(n,r,o,s)}}function n2(e,t){return(n,r)=>{if(n._tag!==r._tag)return!1;switch(n._tag){case"Fail":return e(n.error,r.error);case"Die":return t(n.defect,r.defect);case"Interrupt":return n.fiberId===r.fiberId}}}function r2(e,t){return(n)=>{switch(n._tag){case"Fail":return`Fail(${e(n.error)})`;case"Die":return`Die(${t(n.defect)})`;case"Interrupt":return"Interrupt"}}}function Kg(e,t){let n=Qn()([e,t],([r,o])=>{let s=$e(Wg(r,o));return(i,a,c)=>{if(!WE(i))return A(new ft(a,i,c));return Jt(vt(s)(i.reasons,c),{onSuccess:wa,onFailure:(u)=>Kn(a,"failures",u,i,c)})}},{representation:{id:"effect/schema/Cause",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Cause(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Cause<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause",toCodec:([r,o])=>Je()($e(Wg(r,o)),st({decode:wa,encode:({reasons:s})=>s})),toArbitrary:([r,o])=>o2(r,o),toEquivalence:([r,o])=>s2(r,o),toFormatter:([r,o])=>i2(r,o)});return V(n.ast,{error:e,defect:t})}function o2(e,t){return(n,r)=>{let o=t2(e,t)(n,r),s=n.constant(VE),i=n.array(o.arbitrary).map(wa);return Qa(n,r,s,i)}}function s2(e,t){let n=sC(n2(e,t));return(r,o)=>n(r.reasons,o.reasons)}function i2(e,t){let n=r2(e,t);return(r)=>`Cause([${r.reasons.map(n).join(", ")}])`}function u2(e){let t=a2(e),n=F$[t];if(n!==void 0)return n;let r=c2(t),o=Li(globalThis.Error,{representation:{id:"effect/schema/Error",payload:r??null},toCode:()=>({runtime:r!==void 0?`Schema.ErrorInstance(${B(r)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),expected:"Error",toCodecJson:()=>Je()(rX,SM(r)),toArbitrary:()=>(s)=>s.string().map((i)=>new globalThis.Error(i))});return F$[t]=o,o}function qk(e){let t=a2(e),n=M$[t];if(n!==void 0)return n;let r=tp.pipe(de(Rk,EM(c2(t))));return M$[t]=r,r}function l2(e,t,n){let r=Qn()([e,t,n],([o,s,i])=>{let a=Kg(s,i);return(c,u,l)=>{if(!YE(c))return A(new ft(u,c,l));switch(c._tag){case"Success":return Jt(vt(o)(c.value,l),{onSuccess:_r,onFailure:(f)=>Kn(u,"value",f,c,l)});case"Failure":return Jt(vt(a)(c.cause,l),{onSuccess:lr,onFailure:(f)=>Kn(u,"cause",f,c,l)})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:({typeParameters:o})=>({runtime:`Schema.Exit(${o[0].runtime}, ${o[1].runtime}, ${o[2].runtime})`,Type:`Exit.Exit<${o[0].Type}, ${o[1].Type}, ${o[2].Type}>`,importDeclarations:['import * as Exit from "effect/Exit"']}),expected:"Exit",toCodec:([o,s,i])=>Je()(pt([Q({_tag:Ke("Success"),value:o}),Q({_tag:Ke("Failure"),cause:Kg(s,i)})]),st({decode:(a)=>a._tag==="Success"?_r(a.value):lr(a.cause),encode:(a)=>Rt(a)?{_tag:"Success",value:a.value}:{_tag:"Failure",cause:a.cause}})),toArbitrary:([o,s,i])=>(a,c)=>{let u=o2(s,i)(a,c),l=f2(a,o.terminal?.map((d)=>_r(d)),u.terminal?.map((d)=>lr(d))),f=a.oneof(o.arbitrary.map((d)=>_r(d)),u.arbitrary.map((d)=>lr(d)));return Qa(a,c,l,f)},toEquivalence:([o,s,i])=>{let a=s2(s,i);return(c,u)=>{if(c._tag!==u._tag)return!1;switch(c._tag){case"Success":return o(c.value,u.value);case"Failure":return a(c.cause,u.cause)}}},toFormatter:([o,s,i])=>{let a=i2(s,i);return(c)=>{switch(c._tag){case"Success":return`Exit.Success(${o(c.value)})`;case"Failure":return`Exit.Failure(${a(c.cause)})`}}}});return V(r.ast,{value:e,error:t,defect:n})}function f2(e,t,n){return t===void 0?n:n===void 0?t:e.oneof(t,n)}function Qa(e,t,n,r){return{arbitrary:n===void 0||t.recursion===void 0?r:e.oneof(t.recursion,n,r),terminal:n}}function N$(e,t,n,r){return r===void 0?e.array(t,n):e.uniqueArray(t,{...n,comparator:r})}function tx(e,t,n,r,o,s){let i=t.constraint,a=i===void 0||i.minLength===void 0&&i.maxLength===void 0?void 0:{...i.minLength!==void 0?{minLength:i.minLength}:{},...i.maxLength!==void 0?{maxLength:i.maxLength}:{}};if(a?.minLength!==void 0&&a.maxLength!==void 0&&a.minLength>a.maxLength)throw new globalThis.Error("Unable to derive an arbitrary for size constraints");let c=a?.minLength??0,u=c===0?e.constant([]):r===void 0?void 0:N$(e,r,{...a,maxLength:c},s),l=Qa(e,t,u,N$(e,n,a,s));return{arbitrary:l.arbitrary.map(o),terminal:l.terminal?.map(o)}}function d2(e,t,n,r,o){return tx(e,t,e.tuple(n.arbitrary,r.arbitrary),n.terminal===void 0||r.terminal===void 0?void 0:e.tuple(n.terminal,r.terminal),o,([s],[i])=>Y(s,i))}function p2(e,t){let n=Qn()([e,t],([r,o])=>{let s=$e(Ju([r,o]));return(i,a,c)=>{if(i instanceof globalThis.Map)return Jt(vt(s)([...i],c),{onSuccess:(u)=>new globalThis.Map(u),onFailure:(u)=>Kn(a,"entries",u,i,c)});return A(new ft(a,i,c))}},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.ReadonlyMap(${r[0].runtime}, ${r[1].runtime})`,Type:`globalThis.ReadonlyMap<${r[0].Type}, ${r[1].Type}>`}),expected:"ReadonlyMap",toCodec:([r,o])=>Je()($e(Ju([r,o])),st({decode:(s)=>new globalThis.Map(s),encode:(s)=>[...s.entries()]})),toArbitrary:([r,o])=>(s,i)=>d2(s,i,r,o,(a)=>new globalThis.Map(a)),toEquivalence:([r,o])=>Fp(r,o),toFormatter:([r,o])=>(s)=>{let i=s.size;if(i===0)return"ReadonlyMap(0) {}";let a=globalThis.Array.from(s.entries()).sort().map(([c,u])=>`${r(c)} => ${o(u)}`);return`ReadonlyMap(${i}) { ${a.join(", ")} }`}});return V(n.ast,{key:e,value:t})}function D$(e,t,n){return Q({type:Ke(e),nodes:$e(Q({index:an,data:t})),edges:$e(Q({index:an,source:an,target:an,data:n}))})}function $$(e,t){let n=-1,r=new Set;for(let o=0;o<e.nodes.length;o++){let s=e.nodes[o].index;if(s<=n)return A(new Ft(["nodes",o,"index"],new we({expected:"a strictly increasing node index"},s,t)));n=s,r.add(s)}n=-1;for(let o=0;o<e.edges.length;o++){let s=e.edges[o];if(s.index<=n)return A(new Ft(["edges",o,"index"],new we({expected:"a strictly increasing edge index"},s.index,t)));if(n=s.index,!r.has(s.source))return A(new Ft(["edges",o,"source"],new we({expected:"an encoded node index"},s.source,t)));if(!r.has(s.target))return A(new Ft(["edges",o,"target"],new we({expected:"an encoded node index"},s.target,t)))}return v(wd(e))}function g9(e,t,n){if(!Gv(e)||e.mutable||e.type!==t)return A(new we({expected:`an immutable ${t} Graph`},e,n));return v(bd(e))}function x9(e,t){return(n,r)=>{let o=bd(n),s=bd(r);if(o.type!==s.type||o.nodes.length!==s.nodes.length||o.edges.length!==s.edges.length)return!1;for(let i=0;i<o.nodes.length;i++)if(o.nodes[i].index!==s.nodes[i].index||!e(o.nodes[i].data,s.nodes[i].data))return!1;for(let i=0;i<o.edges.length;i++){let a=o.edges[i],c=s.edges[i],u=o.type==="directed"?a.source===c.source&&a.target===c.target:a.source===c.source&&a.target===c.target||a.source===c.target&&a.target===c.source;if(a.index!==c.index||!u||!t(a.data,c.data))return!1}return!0}}function y9(e,t,n){return(r,o)=>{let s=wd({type:e,nodes:[],edges:[]}),i=r.constant(s),a=r.array(t.arbitrary).chain((c)=>{let u=c.map((f,d)=>({index:d,data:f}));if(u.length===0)return i;let l=r.integer({min:0,max:u.length-1});return r.array(r.tuple(l,l,n.arbitrary)).map((f)=>wd({type:e,nodes:u,edges:f.map(([d,m,g],b)=>({index:b,source:d,target:m,data:g}))}))});return Qa(r,o,i,a)}}function m2(e,t,n){let r=Qn()([t,n],([o,s])=>{let i=D$(e,o,s);return(a,c,u)=>{if(!Gv(a)||a.mutable||a.type!==e)return A(new ft(c,a,u));return ne(vt(i)(bd(a),u),(l)=>$$(l,u))}},{representation:{id:"effect/schema/Graph",payload:e},toCode:({typeParameters:o})=>({runtime:`Schema.Graph(${B(e)}, ${o[0].runtime}, ${o[1].runtime})`,Type:`Graph.Graph<${o[0].Type}, ${o[1].Type}, ${B(e)}>`,importDeclarations:['import * as Graph from "effect/Graph"']}),expected:`an immutable ${e} Graph`,toCodec:([o,s])=>Je()(D$(e,o,s),Sr({decode:$$,encode:(i,a)=>g9(i,e,a)})),toArbitrary:([o,s])=>y9(e,o,s),toEquivalence:([o,s])=>x9(o,s),toFormatter:()=>globalThis.String});return V(r.ast,{type:e,node:t,edge:n})}function h2(e,t){let n=Qn()([e,t],([r,o])=>{let s=$e(Ju([r,o]));return(i,a,c)=>{if(zN(i))return Jt(vt(s)(Og(i),c),{onSuccess:Tg,onFailure:(u)=>Kn(a,"entries",u,i,c)});return A(new ft(a,i,c))}},{representation:{id:"effect/schema/HashMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.HashMap(${r[0].runtime}, ${r[1].runtime})`,Type:`HashMap.HashMap<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as HashMap from "effect/HashMap"']}),expected:"HashMap",toCodec:([r,o])=>Je()($e(Ju([r,o])),st({decode:Tg,encode:Og})),toArbitrary:([r,o])=>(s,i)=>d2(s,i,r,o,Tg),toEquivalence:([r,o])=>Fp(r,o),toFormatter:([r,o])=>(s)=>{let i=WN(s);if(i===0)return"HashMap(0) {}";let a=Og(s).sort().map(([c,u])=>`${r(c)} => ${o(u)}`);return`HashMap(${i}) { ${a.join(", ")} }`}});return V(n.ast,{key:e,value:t})}function g2(e){let t=Qn()([e],([n])=>{let r=$e(n);return(o,s,i)=>{if(o instanceof globalThis.Set)return Jt(vt(r)([...o],i),{onSuccess:(a)=>new globalThis.Set(a),onFailure:(a)=>Kn(s,"values",a,o,i)});return A(new ft(s,o,i))}},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.ReadonlySet(${n[0].runtime})`,Type:`globalThis.ReadonlySet<${n[0].Type}>`}),expected:"ReadonlySet",toCodec:([n])=>Je()($e(n),st({decode:(r)=>new globalThis.Set(r),encode:(r)=>[...r.values()]})),toArbitrary:([n])=>(r,o)=>tx(r,o,n.arbitrary,n.terminal,(s)=>new globalThis.Set(s),Y),toEquivalence:([n])=>Mp(n),toFormatter:([n])=>(r)=>{let o=r.size;if(o===0)return"ReadonlySet(0) {}";let s=globalThis.Array.from(r.values()).sort().map((i)=>`${n(i)}`);return`ReadonlySet(${o}) { ${s.join(", ")} }`}});return V(t.ast,{value:e})}function x2(e){let t=Qn()([e],([n])=>{let r=$e(n);return(o,s,i)=>{if(YN(o))return Jt(vt(r)(Lt(o),i),{onSuccess:_g,onFailure:(a)=>Kn(s,"values",a,o,i)});return A(new ft(s,o,i))}},{representation:{id:"effect/schema/HashSet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.HashSet(${n[0].runtime})`,Type:`HashSet.HashSet<${n[0].Type}>`}),expected:"HashSet",toCodec:([n])=>Je()($e(n),st({decode:_g,encode:Lt})),toArbitrary:([n])=>(r,o)=>tx(r,o,n.arbitrary,n.terminal,_g,Y),toEquivalence:([n])=>Mp(n),toFormatter:([n])=>(r)=>{let o=QN(r);if(o===0)return"HashSet(0) {}";let s=globalThis.Array.from(r).sort().map((i)=>`${n(i)}`);return`HashSet(${o}) { ${s.join(", ")} }`}});return V(t.ast,{value:e})}function y2(e){let t=Qn()([e],([n])=>{let r=$e(n);return(o,s,i)=>{if(Eh(o))return Jt(vt(r)(Lt(o),i),{onSuccess:bh,onFailure:(a)=>Kn(s,"values",a,o,i)});return A(new ft(s,o,i))}},{representation:{id:"effect/schema/Chunk",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Chunk(${n[0].runtime})`,Type:`Chunk.Chunk<${n[0].Type}>`}),expected:"Chunk",toCodec:([n])=>Je()($e(n),st({decode:bh,encode:Lt})),toArbitrary:([n])=>(r,o)=>tx(r,o,n.arbitrary,n.terminal,bh),toEquivalence:([n])=>Yb(n),toFormatter:([n])=>(r)=>{let o=aP(r);if(o===0)return"Chunk(0) {}";let s=globalThis.Array.from(r).sort().map((i)=>`${n(i)}`);return`Chunk(${o}) { ${s.join(", ")} }`}});return V(t.ast,{value:e})}function zk(e,t,n){let r={...t};if(e?.minimum!==void 0){let o=n===void 0?e.minimum:n(e.minimum),s=e.exclusiveMinimum?new globalThis.Date(o.getTime()+1):o;if(r.min===void 0||s.getTime()>r.min.getTime())r.min=s}if(e?.maximum!==void 0){let o=n===void 0?e.maximum:n(e.maximum),s=e.exclusiveMaximum?new globalThis.Date(o.getTime()-1):o;if(r.max===void 0||s.getTime()<r.max.getTime())r.max=s}return r}function Vg(e,t){return Ri(e,t).value}function M9(e,t,n){return n?Vg(Ww(e,t),t)+globalThis.BigInt(1):Vg(zw(e,t),t)}function N9(e,t,n){return n?Vg(zw(e,t),t)-globalThis.BigInt(1):Vg(Ww(e,t),t)}function D9(e){return Math.max(k2,e.minimum?.scale??0,e.maximum?.scale??0,e.exclusiveMinimum&&e.minimum!==void 0?e.minimum.scale+1:0,e.exclusiveMaximum&&e.maximum!==void 0?e.maximum.scale+1:0)}function Tk(e,t){let n={};if(e.minimum!==void 0)n.min=M9(e.minimum,t,e.exclusiveMinimum===!0);if(e.maximum!==void 0)n.max=N9(e.maximum,t,e.exclusiveMaximum===!0);if(n.min!==void 0&&n.max!==void 0&&n.min>n.max)return;return n}function $9(e){let t=D9(e);if(Tk(e,t)===void 0)throw new globalThis.Error(I2);let n=0,r=t;while(n<r){let o=n+Math.floor((r-n)/2);if(Tk(e,o)===void 0)n=o+1;else r=o}return{min:n,max:t}}function C2(e,t){return j9.pipe(de(e,_M(t)))}function z9(e){return Vk.pipe(de(e,RM))}function K9(e){return Gk.pipe(de(e,PM))}function Qk(e,t,n,r,o){let s=E7(n,t,r),i=F2(t),a=class extends e{constructor(...[c,u]){let f=u?.["~payload"],d=f?.token===Ak?f.value:n.make(c??{},u);super(d,{...u,disableChecks:!0,"~payload":{token:Ak,value:d}})}static[Ud]=Ud;get[i](){return i}static[y7]=!0;static identifier=t;static fields=n.fields;static get ast(){return s(this).ast}static pipe(){return le(this,arguments)}static rebuild(c){return s(this).rebuild(c)}static make(c,u){return new this(c,u)}static makeOption(c,u){return Pg(s(this))(c??{},u)}static makeEffect(c,u){return s(this).makeEffect(c??{},u)}static annotate(c){return this.rebuild(Ur(this.ast,c))}static annotateKey(c){return this.rebuild(Sd(this.ast,c))}static check(...c){return this.rebuild(Fo(this.ast,c))}static extend(c){return(u,l)=>{let f=Xd(u)?u:Q(u),d={...n.fields,...f.fields},m=og(d,n.ast.checks,{identifier:c});return Qk(this,c,Fk(Fo(m,f.ast.checks),d),l,o)}}static mapFields(c,u){return n.mapFields(c,u)}};if(o!==void 0)Object.assign(a.prototype,o(t));return a}function S7(e){return new Pe(ve((t)=>new e(t,{"~payload":{token:Ak,value:t}})),ro())}function F2(e){return`~effect/Schema/Class/${e}`}function E7(e,t,n){let r;return(o)=>{if(r!==void 0)return r;let s=F2(t),i=(u)=>u instanceof o||M(u,s),a=S7(o),c=V(new Ba([e.ast],()=>(u,l,f)=>i(u)?v(u):A(new ft(l,u,f)),{identifier:t,[Fh]:([u])=>({isConstructed:i,link:new dt(u,a)}),toCodec:([u])=>new dt(u.ast,a),toArbitrary:([u])=>()=>({arbitrary:u.arbitrary.map((l)=>new o(l)),terminal:u.terminal?.map((l)=>new o(l))}),toFormatter:([u])=>(l)=>`${o.identifier}(${u(l)})`,[td]:Ru(e.ast),...n}));return r=de(c,a)(e)}}function Xd(e){return Jg(e)}function w7(e){let t=HD(e.ast);return(n)=>t(n,{})}function v7(e){return(t)=>t.annotate({toFormatter:e})}function k7(e,t){return n(e.ast);function n(o){let s=_o(o)?.toFormatter;if(typeof s==="function")return s(Mi(o)?o.typeParameters.map(n):[]);if(t?.onBefore){let i=t.onBefore(o,n);if(i!==void 0)return i}return r(o)}function r(o){switch(o._tag){default:return B;case"Never":return()=>"never";case"Void":return()=>"void";case"Arrays":{let s=o.elements.map(n),i=o.rest.map(n);return(a)=>{let c=[],u=0;for(;u<s.length;u++)if(a.length<u+1){if(bt(o.elements[u]))continue}else c.push(s[u](a[u]));if(i.length>0){let[l,...f]=i;for(;u<a.length-f.length;u++)c.push(l(a[u]));for(let d=0;d<f.length;d++)c.push(f[d](a[u+d]))}return"["+c.join(", ")+"]"}}case"Objects":{let s=o.propertySignatures.map((a)=>n(a.type)),i=o.indexSignatures.map((a)=>n(a.type));if(o.propertySignatures.length===0&&o.indexSignatures.length===0)return B;return(a)=>{let c=[],u=new Set;for(let l=0;l<s.length;l++){let f=o.propertySignatures[l],d=f.name;if(u.add(d),bt(f.type)&&!Object.hasOwn(a,d))continue;c.push(`${Go(d)}: ${s[l](a[d])}`)}for(let l=0;l<i.length;l++){let f=La(a,o.indexSignatures[l].parameter);for(let d of f){if(u.has(d))continue;u.add(d),c.push(`${Go(d)}: ${i[l](a[d])}`)}}return c.length>0?"{ "+c.join(", ")+" }":"{}"}}case"Union":{let s=sn(o).types,i=(c)=>md(c,s),a=new Map(s.map((c,u)=>[c,[Ad(c),n(o.types[u])]]));return(c)=>{let u=i(c);for(let l=0;l<u.length;l++){let[f,d]=a.get(u[l]);if(f(c))return d(c)}return B(c)}}case"Suspend":{let s=Ha(()=>n(o.thunk()));return(i)=>s()(i)}}}}function I7(e){return(t)=>t.annotate({toEquivalence:e})}function C7(e){return zD(e.ast)}function T7(e,t){return bk(e.ast,t)}function N2(e,t){let n=bk(ox(e.ast),t);return i$(n,t)}function D2(e){return V(ox(e.ast),{schema:e})}function Xk(e){return e.constructorDefault===void 0?e:new so(e.isOptional,e.isMutable,void 0,e.annotations)}function $2(e){if(e.propertySignatures.some((t)=>typeof t.name!=="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function U2(e){return(t)=>{let n=new Map;for(let s=0;s<t.length;s++)n.set(Jn(t[s]),s);let r=[...t].sort((s,i)=>{s=Jn(s),i=Jn(i);let a=e(s),c=e(i);if(a!==c)return a-c;return n.get(s)-n.get(i)});if(!r.some((s,i)=>s!==t[i]))return t;return r}}function A7(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!ln(n))return Ge(e,[_v]);let r=e.typeParameters.map((s)=>Rd(Jn(s))),o=n(r);return o===void 0?e:Ge(e,[Nu(o,t)])}case"Unknown":return Ge(e,[_v]);case"ObjectKeyword":return Ge(e,[M1]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return $2(e),e.recur(t,mg);case"Union":{let n=O7(e.types);if(n!==e.types)return new Fn(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function L2(e){return V(j2(sn(e.ast)))}function _7(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecIso??e.annotations?.toCodec;if(ln(n)){let r=n(e.typeParameters.map((o)=>Rd(o)));return Ge(e,[Nu(r,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}function ep(e){return V(q2(e.ast),{schema:e})}function R7(e){return V(z2(e.ast))}function P7(e,t){let n=ku(e.ast)??xw(e.ast),r=G$(ep(e));return(o)=>r(o).pipe(oe((s)=>F7(s,{rootName:n,...t})))}function F7(e,t){let n=t.rootName??"root",r=t.arrayItemName??"item",o=t.pretty??!0,s=t.indent??" ",i=t.sortKeys??!0,a=new Set,c=[];return l(n,e,0),c.join(o?`
|
|
36
|
-
`:"");function u(f,d){c.push(o?s.repeat(f)+d:d)}function l(f,d,m,g){let{attrs:b,safe:x}=Gu.tagInfo(f,g);if(d===void 0)u(m,`<${x}${b}/>`);else if(typeof d==="string")u(m,`<${x}${b}>${Gu.escapeText(d)}</${x}>`);else if(typeof d!=="object"||d===null)u(m,`<${x}${b}>${Gu.escapeText(B(d))}</${x}>`);else{if(a.has(d))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:d});a.add(d);try{if(globalThis.globalThis.Array.isArray(d)){if(d.length===0){u(m,`<${x}${b}/>`);return}u(m,`<${x}${b}>`);for(let S of d)l(r,S,m+1);u(m,`</${x}>`);return}let I=d,C=Object.keys(I);if(i)C.sort();if(C.length===0){u(m,`<${x}${b}/>`);return}u(m,`<${x}${b}>`);for(let S of C)l(Gu.parseTagName(S).safe,I[S],m+1,S);u(m,`</${x}>`)}finally{a.delete(d)}}}}function N7(e,t,n){switch(e._tag){case"Declaration":{let r=e.typeParameters.map((u)=>V(t(Jn(u)))),o=e.annotations?.toCodecStringTree;if(ln(o)){let u=o(r);if(u===void 0)return e;return Ge(e,[Nu(u,t)])}let s=e.annotations?.toCodecJson,i=ln(s)?s(r):void 0,a=i===void 0?e.annotations?.toCodec:void 0,c=i??(ln(a)?a(r):void 0);return c===void 0?n(e):Ge(e,[Nu(c,t)])}case"Null":return Ge(e,[D7]);case"Boolean":return Ge(e,[$7]);case"Unknown":case"ObjectKeyword":return Ge(e,[Rv]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return $2(e),e.recur(t,mg);case"Union":{let r=M7(e.types);if(r!==e.types)return new Fn(r,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function U7(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur(z2):e}function J7(e){let t=L2(e);return g$(ak(t),sk(t))}function Z7(e){return qg()}function Y7(e){return qg()}function Q7(e,t){return(n)=>V(Ur(n.ast,{toCodecIso:()=>new dt(e.ast,Zh(t))}),{schema:n})}function X7(e){let t=D2(e),n=ak(t),r=sk(t);return{empty:[],diff:(o,s)=>l$(n(o),n(s)),combine:(o,s)=>[...o,...s],patch:(o,s)=>{let i=n(o),a=f$(s,i);return Object.is(a,i)?o:r(a)}}}function eX(e){let t=oU(()=>n),n=pt([e,$e(t),Yg(J,t)]);return n}function sX(e){return _o(e.ast)}function iX(e){return e.ast.context?.annotations}var Ud,Ld="~effect/SchemaError/SchemaError",Za,Bd,uQ,lQ,fQ,dQ,pQ,mQ,hQ,gQ,G$,xQ,yQ,SQ,EQ,bQ,wQ,V,Ds,vQ,Nn,kQ,IQ,CQ,Dn,Xu,jd="~effect/Schema/flip",RQ,PQ,Rk,Fe,Pk,J,Hd,Zg,eU,$o,FQ,MQ,$Q=(e)=>typeof e==="symbol"?e:globalThis.String(e),$e,HQ,WQ,Mk,Qg,rU,Ze,T$="^\\S[\\s\\S]*\\S$|^\\S$|^$",s8,i8,a8,c8,u8,l8,f8=(e)=>{if(e)return new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/},d8,O$,p8,m8,h8,g8,x8,y8,S8,A$="^[^a-z]*$",E8,_$="^[^A-Z]*$",b8,R$="^[^a-z]?.*$",w8,P$="^[^A-Z]?.*$",v8,Zn,OU,k8,_U,I8,Lk,C8,RU,T8,PU,O8,Gd,A8,FU,_8,R8,Uo,an,MU,NU,DU,$U,UU,LU,jU,BU,HU,qU,M8,N8,D8,$8,U8,L8,j8,B8,H8,q8,z8,W8,K8,V8,G8,J8,XU,Z8,Y8,o9,s9,i9,a9,u9,l9,f9,d9,a2=(e)=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),c2=(e)=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},F$,p9,M$,m9,h9,S9,E9,b9,w9,v9,S2,k9,E2,nx,I9,C9,b2,Yn,T9,O9,A9,Zd,_9,R9,w2,P9,F9,v2,k2=20,I2="Unable to derive an arbitrary for the ordered BigDecimal constraints",Wk,U9,L9,j9,B9,Kk,H9,Vk,q9,Gk,W9,V9,G9,J9,T2,Z9,Y9,Q9,X9,e7,Ok,t7,n7,O2,Yd,r7,o7,s7,i7,Qd,a7,c7,u7,l7,A2,f7,_2,Jk,d7,p7,R2,Zk,m7,h7,P2,Yk,g7,x7,y7,Ak,M2=(e)=>(t,n)=>{let r=Xd(t)?t:Q(t);return Qk(sm,e,r,n,(o)=>({toString(){return`${o}(${B({...this})})`}}))},b7=(e)=>(t,n,r)=>{let o=Xd(n)?n.mapFields((s)=>({_tag:$s(t),...s}),{unsafePreserveChecks:!0}):Xg(t,n);return M2(e??t)(o,r)},rx=(e)=>(t,n)=>{let r=Xd(t)?t:Q(t);return Qk(Al,e,r,n,(s)=>({name:s}))},po=(e)=>(t,n,r)=>{let o=Xd(n)?n.mapFields((s)=>({_tag:$s(t),...s}),{unsafePreserveChecks:!0}):Xg(t,n);return rx(e??t)(o,r)},ox,O7,j2,Gu,M7,D7,$7,B2,H2=(e)=>e.transformation===B2,q2,U$=(e)=>bt(e)?Du(Rs):Rs,z2,L7,j7,B7,H7,q7,z7,W7,K7,V7,G7,tp,tX,nX,rX,W2,oX;var Xa=w(()=>{An();Kw();rn();cP();Wc();Hh();ai();Oe();cm();yt();Xo();dr();kn();X();NN();KN();XN();rt();ht();Vv();Ti();yD();qD();WD();a$();c$();hm();p$();xk();Xm();E$();_e();ia();Qe();he();NC();$d();yk();gn();om();Ps();Vh();Ai();Mg();Xh();Dg();Ud=Ng;Za=class Za extends ci("SchemaError"){[Ld]=Ld;constructor(e){let t=li();ir(0);try{super({issue:e})}finally{ir(t)}}get message(){return wF(this.issue)}toString(){return`SchemaError(${this.message})`}};Bd=nD,uQ=oD;lQ=Us;fQ=z$,dQ=ok,pQ=iD;mQ=W$;hQ=K$;gQ=V$;G$=Gg;xQ=J$,yQ=ik,SQ=uD;EQ=Z$;bQ=Y$;wQ=Q$,V=Rd;Ds=En((e)=>V(Du(e.ast),{schema:e})),vQ=En((e)=>e.schema),Nn=En((e)=>{let t=Qg(e);return V(S1(e.ast),{schema:t})}),kQ=En((e)=>e.schema.members[0]),IQ=En((e)=>V(kv(e.ast),{schema:e})),CQ=En((e)=>e.schema),Dn=En((e)=>V(sn(e.ast),{schema:e})),Xu=En((e)=>V(Jn(e.ast),{schema:e}));RQ=V(JM),PQ=V(YM),Rk=V(Rs),Fe=V(lv),Pk=V(fv),J=V(Po),Hd=V(hv),Zg=V(s1),eU=V(a1),$o=V(u1),FQ=V(VM),MQ=V(e1);$e=En((e)=>V(new io(!1,[],[e.ast]),{value:e})),HQ=En((e)=>V(new io(!1,[e.ast],[e.ast]),{value:e}));WQ=En((e)=>V(new io(!0,e.ast.elements,e.ast.rest),{schema:e}));Mk=En((e)=>pt([e,Fe])),Qg=En((e)=>pt([e,Pk])),rU=En((e)=>pt([e,Fe,Pk]));Ze=cg;s8=ge("effect/schema/isTrimmed",Fe,({annotations:e})=>$k(e));i8=Q({source:J,flags:J}).check(Ze((e)=>{let t=iS(()=>new globalThis.RegExp(e.source,e.flags));return Ut(t)&&t.success.source===e.source&&t.success.flags===e.flags})),a8={id:"effect/schema/isPattern",payloadSchema:i8,revive:({annotations:e,payload:t})=>Ya(new globalThis.RegExp(t.source,t.flags),e)};c8=ge("effect/schema/isStringFinite",Fe,({annotations:e})=>mU(e));u8=ge("effect/schema/isStringBigInt",Fe,({annotations:e})=>hU(e));l8=ge("effect/schema/isStringSymbol",Fe,({annotations:e})=>gU(e));d8=ge("effect/schema/isUUID",Q({version:pt([Ls([1,2,3,4,5,6,7,8]),Fe])}),({annotations:e,payload:t})=>xU(t.version??void 0,e)),O$=/^([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})$/;p8=ge("effect/schema/isGUID",Fe,({annotations:e})=>yU(e));m8=ge("effect/schema/isULID",Fe,({annotations:e})=>SU(e));h8=ge("effect/schema/isBase64",Fe,({annotations:e})=>Uk(e));g8=ge("effect/schema/isBase64Url",Fe,({annotations:e})=>EU(e));x8=ge("effect/schema/isStartsWith",Q({startsWith:J}),({annotations:e,payload:t})=>bU(t.startsWith,e));y8=ge("effect/schema/isEndsWith",Q({endsWith:J}),({annotations:e,payload:t})=>wU(t.endsWith,e));S8=ge("effect/schema/isIncludes",Q({includes:J}),({annotations:e,payload:t})=>vU(t.includes,e));E8=ge("effect/schema/isUppercased",Fe,({annotations:e})=>kU(e));b8=ge("effect/schema/isLowercased",Fe,({annotations:e})=>IU(e));w8=ge("effect/schema/isCapitalized",Fe,({annotations:e})=>CU(e));v8=ge("effect/schema/isUncapitalized",Fe,({annotations:e})=>TU(e)),Zn=V(Ev),OU=Sv,k8=ge("effect/schema/isFinite",Fe,({annotations:e})=>OU(e));_U=qd({order:rr,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:Zu(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${B(e)})`})})}),I8=ge("effect/schema/isGreaterThan",Q({exclusiveMinimum:Zn}),({annotations:e,payload:t})=>_U(t.exclusiveMinimum,e)),Lk=zd({order:rr,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:Zu(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${B(e)})`})})}),C8=ge("effect/schema/isGreaterThanOrEqualTo",Q({minimum:Zn}),({annotations:e,payload:t})=>Lk(t.minimum,e)),RU=Wd({order:rr,annotate:(e)=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:Zu(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${B(e)})`})})}),T8=ge("effect/schema/isLessThan",Q({exclusiveMaximum:Zn}),({annotations:e,payload:t})=>RU(t.exclusiveMaximum,e)),PU=Kd({order:rr,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:Zu(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${B(e)})`})})}),O8=ge("effect/schema/isLessThanOrEqualTo",Q({maximum:Zn}),({annotations:e,payload:t})=>PU(t.maximum,e)),Gd=Vd({order:rr,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:Zu(e.minimum),maximum:Zu(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[n?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${B(e.minimum)}, maximum: ${B(e.maximum)}, exclusiveMinimum: ${B(t)}, exclusiveMaximum: ${B(n)} })`})}}}),A8=ge("effect/schema/isBetween",Q({minimum:Zn,maximum:Zn,exclusiveMinimum:Nn(Ke(!0)),exclusiveMaximum:Nn(Ke(!0))}),({annotations:e,payload:t})=>Gd(t,e)),FU=AU({remainder:nR,zero:0,annotate:(e)=>({expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${B(e)})`})})}),_8=ge("effect/schema/isMultipleOf",Q({divisor:Zn}),({annotations:e,payload:t})=>FU(t.divisor,e));R8=ge("effect/schema/isInt",Fe,({annotations:e})=>Jd(e)),Uo=Hd.check(Jd()),an=Uo.check(Lk(0));MU=qd({order:sa,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:Yu(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanDate(${Qu(e)})`})})}),NU=zd({order:sa,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:Yu(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${Qu(e)})`})})}),DU=Wd({order:sa,annotate:(e)=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:Yu(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanDate(${Qu(e)})`})})}),$U=Kd({order:sa,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:Yu(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${Qu(e)})`})})}),UU=Vd({order:sa,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:Yu(e.minimum),maximum:Yu(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${Qu(e.minimum)}, maximum: ${Qu(e.maximum)}, exclusiveMinimum: ${B(t)}, exclusiveMaximum: ${B(n)} })`})}}}),LU=qd({order:Cr,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${B(e)})`})})}),jU=zd({order:Cr,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${B(e)})`})})}),BU=Wd({order:Cr,annotate:(e)=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanBigInt(${B(e)})`})})}),HU=Kd({order:Cr,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${B(e)})`})})}),qU=Vd({order:Cr,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenBigInt",payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${B(e.minimum)}, maximum: ${B(e.maximum)}, exclusiveMinimum: ${B(t)}, exclusiveMaximum: ${B(n)} })`})}}}),M8=qd({order:_s,formatter:(e)=>Ro(e)}),N8=zd({order:_s,formatter:(e)=>Ro(e)}),D8=Wd({order:_s,formatter:(e)=>Ro(e)}),$8=Kd({order:_s,formatter:(e)=>Ro(e)}),U8=Vd({order:_s,formatter:(e)=>Ro(e)});L8=ge("effect/schema/isMinLength",Q({minLength:an}),({annotations:e,payload:t})=>jk(t.minLength,e));j8=ge("effect/schema/isMaxLength",Q({maxLength:an}),({annotations:e,payload:t})=>WU(t.maxLength,e));B8=ge("effect/schema/isLengthBetween",Q({minimum:an,maximum:an}),({annotations:e,payload:t})=>Bk(t.minimum,t.maximum,e));H8=ge("effect/schema/isMinSize",Q({minSize:an}),({annotations:e,payload:t})=>KU(t.minSize,e));q8=ge("effect/schema/isMaxSize",Q({maxSize:an}),({annotations:e,payload:t})=>VU(t.maxSize,e));z8=ge("effect/schema/isSizeBetween",Q({minimum:an,maximum:an}),({annotations:e,payload:t})=>GU(t.minimum,t.maximum,e));W8=ge("effect/schema/isMinProperties",Q({minProperties:an}),({annotations:e,payload:t})=>JU(t.minProperties,e));K8=ge("effect/schema/isMaxProperties",Q({maxProperties:an}),({annotations:e,payload:t})=>ZU(t.maxProperties,e));V8=ge("effect/schema/isPropertiesLengthBetween",Q({minimum:an,maximum:an}),({annotations:e,payload:t})=>YU(t.minimum,t.maximum,e));G8=ge("effect/schema/isPropertyNames",Fe,({annotations:e,schemas:t})=>QU(t[0],e));J8=ge("effect/schema/isUnique",Fe,({annotations:e})=>Hk(e)),XU=J.check(zU()),Z8=J.check(Bk(1,1));Y8=Mn("effect/schema/Option",Fe,({annotations:e,typeParameters:t})=>{let n=ji(t[0]);return e===void 0?n:n.annotate(e)});o9=Mn("effect/schema/Result",Fe,({annotations:e,typeParameters:t})=>{let n=e2(t[0],t[1]);return e===void 0?n:n.annotate(e)}),s9=Br((e)=>{if(!fn(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every((n)=>{switch(n){case"label":return typeof e[n]==="string";case"disallowJsonEncode":return e[n]===!0;default:return!1}})}),i9=pt([Fe,s9]);a9=Mn("effect/schema/Redacted",i9,({annotations:e,payload:t,typeParameters:n})=>{let r=ex(n[0],t??void 0);return e===void 0?r:r.annotate(e)});u9=Mn("effect/schema/CauseReason",Fe,({annotations:e,typeParameters:t})=>{let n=Wg(t[0],t[1]);return e===void 0?n:n.annotate(e)});l9=Mn("effect/schema/Cause",Fe,({annotations:e,typeParameters:t})=>{let n=Kg(t[0],t[1]);return e===void 0?n:n.annotate(e)});f9=Br((e)=>{if(!fn(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every((n)=>(n==="includeStack"||n==="excludeCause")&&e[n]===!0)}),d9=pt([Fe,f9]),F$=[];p9=Mn("effect/schema/Error",d9,({annotations:e,payload:t})=>{let n=u2(t??void 0);return e===void 0?n:n.annotate(e)}),M$=[];m9=Mn("effect/schema/Exit",Fe,({annotations:e,typeParameters:t})=>{let n=l2(t[0],t[1],t[2]);return e===void 0?n:n.annotate(e)});h9=Mn("effect/schema/ReadonlyMap",Fe,({annotations:e,typeParameters:t})=>{let n=p2(t[0],t[1]);return e===void 0?n:n.annotate(e)});S9=Mn("effect/schema/Graph",Ls(["directed","undirected"]),({annotations:e,payload:t,typeParameters:n})=>{let r=m2(t,n[0],n[1]);return e===void 0?r:r.annotate(e)});E9=Mn("effect/schema/HashMap",Fe,({annotations:e,typeParameters:t})=>{let n=h2(t[0],t[1]);return e===void 0?n:n.annotate(e)});b9=Mn("effect/schema/ReadonlySet",Fe,({annotations:e,typeParameters:t})=>{let n=g2(t[0]);return e===void 0?n:n.annotate(e)});w9=Mn("effect/schema/HashSet",Fe,({annotations:e,typeParameters:t})=>{let n=x2(t[0]);return e===void 0?n:n.annotate(e)});v9=Mn("effect/schema/Chunk",Fe,({annotations:e,typeParameters:t})=>{let n=y2(t[0]);return e===void 0?n:n.annotate(e)}),S2=Li(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),expected:"RegExp",toCodecJson:()=>Je()(Q({source:J,flags:J}),Sr({decode:(e,t)=>Nt({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new we({expected:"valid RegExp source and flags"},e,t)}),encode:(e)=>v({source:e.source,flags:e.flags})})),toArbitrary:()=>(e)=>e.tuple(e.constantFrom(".",".*","\\d+","\\w+","[a-z]+","[A-Z]+","[0-9]+","^[a-zA-Z0-9]+$","^\\d{4}-\\d{2}-\\d{2}$"),e.uniqueArray(e.constantFrom("g","i","m","s","u","y"),{minLength:0,maxLength:6}).map((t)=>t.join(""))).map(([t,n])=>new globalThis.RegExp(t,n)),toEquivalence:()=>(e,t)=>e.source===t.source&&e.flags===t.flags}),k9=bn("effect/schema/RegExp",S2),E2=J.annotate({expected:"a string that will be decoded as a URL"}),nx=Li(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),expected:"URL",toCodecJson:()=>Je()(E2,Gw),toArbitrary:()=>(e)=>e.webUrl().map((t)=>new globalThis.URL(t)),toEquivalence:()=>(e,t)=>e.toString()===t.toString()}),I9=bn("effect/schema/URL",nx),C9=E2.pipe(de(nx,Gw));b2=J.annotate({expected:"a string that will be decoded as a Date"}),Yn=Br((e)=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),expected:"a valid Date",toCodecJson:()=>Je()(b2,Vw),toArbitrary:()=>(e,t)=>e.date(zk(t?.constraint?.ordered?.order===sa?t.constraint.ordered:void 0,{noInvalidDate:!0}))}),T9=bn("effect/schema/Date",Yn),O9=b2.pipe(de(Yn,Vw)),A9=Uo.pipe(de(Yn,dM)),Zd=Br(xS,{representation:{id:"effect/schema/Duration",payload:null},toCode:()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),expected:"Duration",toCodecJson:()=>Je()(pt([Q({_tag:Ke("Infinity")}),Q({_tag:Ke("NegativeInfinity")}),Q({_tag:Ke("Nanos"),value:$o}),Q({_tag:Ke("Millis"),value:Uo})]),st({decode:(e)=>{switch(e._tag){case"Infinity":return ss;case"NegativeInfinity":return pa;case"Nanos":return Tr(e.value);case"Millis":return ii(e.value)}},encode:(e)=>{switch(e.value._tag){case"Infinity":return{_tag:"Infinity"};case"NegativeInfinity":return{_tag:"NegativeInfinity"};case"Nanos":return{_tag:"Nanos",value:e.value.nanos};case"Millis":return{_tag:"Millis",value:e.value.millis}}}})),toArbitrary:()=>(e)=>e.oneof(e.constant(ss),e.constant(pa),e.bigInt().map(Tr),e.maxSafeInteger().map(ii)),toFormatter:()=>globalThis.String,toEquivalence:()=>yS}),_9=bn("effect/schema/Duration",Zd),R9=J.annotate({expected:"a string that will be decoded as a Duration"}),w2=R9.pipe(de(Zd,pM)),P9=$o.pipe(de(Zd,mM)),F9=Hd.pipe(de(Zd,hM)),v2=J.annotate({expected:"a string that will be decoded as a BigDecimal"});Wk=Br(Jh,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),expected:"BigDecimal",toCodecJson:()=>Je()(v2,Jw),toArbitrary:()=>(e,t)=>{let n=t.constraint?.ordered?.order===_s?t.constraint.ordered:void 0;if(n===void 0)return e.tuple(e.bigInt(),e.integer({min:0,max:k2})).map(([r,o])=>Gn(r,o));return e.integer($9(n)).chain((r)=>{let o=Tk(n,r);if(o===void 0)throw new globalThis.Error(I2);return e.bigInt(o).map((s)=>Gn(s,r))})},toFormatter:()=>(e)=>Ro(e),toEquivalence:()=>Hw}),U9=bn("effect/schema/BigDecimal",Wk),L9=v2.pipe(de(Wk,Jw)),j9=J.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});B9=C2(Rk),Kk=Li(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:()=>({runtime:"Schema.File",Type:"globalThis.File"}),expected:"File",toCodecJson:()=>Je()(Q({data:J.check(Uk()),type:J,name:J,lastModified:Uo}),Sr({decode:(e,t)=>Bn(Vc(e.data),{onFailure:()=>A(new we({expected:"a valid Base64 string"},e.data,t)),onSuccess:(n)=>{let r=new globalThis.Uint8Array(n);return v(new globalThis.File([r],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>lu({try:async()=>{let n=new globalThis.Uint8Array(await e.arrayBuffer());return{data:am(n),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new we({expected:"a readable File"},e,t)})}))}),H9=bn("effect/schema/File",Kk),Vk=Li(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),expected:"FormData",toCodecJson:()=>Je()($e(Ju([J,pt([Q({_tag:$s("String"),value:J}),Q({_tag:$s("File"),value:Kk})])])),Sr({decode:(e)=>{let t=new globalThis.FormData;for(let[n,r]of e)t.append(n,r.value);return v(t)},encode:(e)=>v(globalThis.Array.from(e.entries()).map(([t,n])=>{if(typeof n==="string")return[t,{_tag:"String",value:n}];else return[t,{_tag:"File",value:n}]}))}))}),q9=bn("effect/schema/FormData",Vk);Gk=Li(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),expected:"URLSearchParams",toCodecJson:()=>Je()(J.annotate({expected:"a query string that will be decoded as URLSearchParams"}),st({decode:(e)=>new globalThis.URLSearchParams(e),encode:(e)=>e.toString()}))}),W9=bn("effect/schema/URLSearchParams",Gk);V9=J.annotate({expected:"a string that will be decoded as a number"}).pipe(de(Hd,Au)),G9=J.annotate({expected:"a string that will be decoded as a finite number"}).pipe(de(Zn,Au)),J9=V(Ov).pipe(de($o,Qh)),T2=J.check($k()),Z9=J.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(de(T2,fM())),Y9=J.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(de(J,CM)),Q9=J.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(de(J,TM)),X9=J.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(de(J,OM)),e7=J.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(de(J,AM)),Ok=pt([Zn,eU,J]),t7=Q({issues:$e(Q({message:J,path:Nn($e(pt([Ok,Q({key:Ok})])))}))}),n7=Ls([0,1]).pipe(de(Zg,st({decode:(e)=>e===1,encode:(e)=>e?1:0}))),O2=J.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),Yd=Li(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>Je()(O2,Zw),toArbitrary:()=>(e)=>e.uint8Array()}),r7=bn("effect/schema/Uint8Array",Yd),o7=O2.pipe(de(Yd,Zw)),s7=J.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(de(Yd,{decode:zF(),encode:Wh()})),i7=J.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(de(Yd,{decode:KF(),encode:Kh()})),Qd=Br((e)=>Ow(e)&&TF(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Utc",toCodecJson:()=>Je()(J,Xw),toArbitrary:()=>(e,t)=>e.date(zk(t?.constraint?.ordered?.order===_w?t.constraint.ordered:void 0,{noInvalidDate:!0},jh)).map((n)=>AF(n)),toFormatter:()=>(e)=>e.toString(),toEquivalence:()=>Aw}),a7=bn("effect/schema/DateTimeUtc",Qd),c7=Yn.pipe(de(Qd,{decode:Uw(),encode:ve(jh)})),u7=J.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(de(Qd,Xw)),l7=Uo.pipe(de(Qd,{decode:Uw(),encode:ve(MF)})),A2=Br(IF,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Offset",toCodecJson:()=>Je()(Uo,FM),toArbitrary:()=>(e)=>e.integer({min:-43200000,max:50400000}).map((t)=>ad(t)),toFormatter:()=>(e)=>_i(e),toEquivalence:()=>(e,t)=>e.offset===t.offset}),f7=bn("effect/schema/TimeZoneOffset",A2),_2=J.annotate({expected:"an IANA time zone identifier"}),Jk=Br(CF,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Named",toCodecJson:()=>Je()(_2,Yw),toArbitrary:()=>(e)=>e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(Rw)),toFormatter:()=>(e)=>_i(e),toEquivalence:()=>(e,t)=>e.id===t.id}),d7=bn("effect/schema/TimeZoneNamed",Jk),p7=_2.pipe(de(Jk,Yw)),R2=J.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),Zk=Br(kF,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone",toCodecJson:()=>Je()(R2,Qw),toArbitrary:()=>(e)=>e.oneof(e.integer({min:-43200000,max:50400000}).map((t)=>ad(t)),e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(Rw))),toFormatter:()=>(e)=>_i(e),toEquivalence:()=>(e,t)=>_i(e)===_i(t)}),m7=bn("effect/schema/TimeZone",Zk),h7=R2.pipe(de(Zk,Qw)),P2=J.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),Yk=Br((e)=>Ow(e)&&OF(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Zoned",toCodecJson:()=>Je()(P2,ev),toArbitrary:()=>(e,t)=>e.tuple(e.date(zk(t?.constraint?.ordered?.order===_w?t.constraint.ordered:void 0,{max:new globalThis.Date(8639999949600000),min:new globalThis.Date(-8639999949600000),noInvalidDate:!0},jh)),e.constantFrom("UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney")).map(([n,r])=>_F(n,{timeZone:r})),toFormatter:()=>(e)=>Bh(e),toEquivalence:()=>Aw}),g7=bn("effect/schema/DateTimeZoned",Yk),x7=P2.pipe(de(Yk,ev)),y7=globalThis.Symbol.for("immer-draftable"),Ak={};ox=qa((e)=>{let t=A7(e,ox),n=e.context;if(t===e||n===void 0)return t;return fg(t,Xk(n))});O7=U2((e)=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});j2=Qt((e)=>{let t=_7(e,j2);return t!==e&&e.context!==void 0?fg(t,Xk(e.context)):t});Gu={escapeText(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},escapeAttribute(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},parseTagName(e){let t=e,n=e;if(!/^[A-Za-z_]/.test(n))n="_"+n;if(n=n.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(n))n="_"+n;return{safe:n,changed:n!==t}},tagInfo(e,t){let{changed:n,safe:r}=Gu.parseTagName(e),s=n||t&&t!==e?` data-name="${Gu.escapeAttribute(t??e)}"`:"";return{safe:r,attrs:s}}},M7=U2((e)=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});D7=new dt(new Er("null"),new Pe(ve(()=>null),ve(()=>"null"))),$7=new dt(new Fn([new Er("true"),new Er("false")],"anyOf"),new Pe(ve((e)=>e==="true"),Ua())),B2=new Pe(ve((e)=>typeof e==="string"?[e]:e),ro()),q2=qa((e)=>{let t=N7(e,q2,(n)=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:n})});if(t!==e&&e.context!==void 0)return fg(t,Xk(e.context));return t},{stopAt:H2}),z2=qa((e)=>{let t=U7(e);if(uv(t)){let n=dg(new Fn([new io(t.isMutable,t.elements.map(U$),t.rest.map(U$)),Po],"anyOf"),t,B2);return bt(e)?Du(n):n}return t},{stopAt:H2});L7=ge("effect/schema/isGreaterThanDate",Q({exclusiveMinimum:Yn}),({annotations:e,payload:t})=>MU(t.exclusiveMinimum,e)),j7=ge("effect/schema/isGreaterThanOrEqualToDate",Q({minimum:Yn}),({annotations:e,payload:t})=>NU(t.minimum,e)),B7=ge("effect/schema/isLessThanDate",Q({exclusiveMaximum:Yn}),({annotations:e,payload:t})=>DU(t.exclusiveMaximum,e)),H7=ge("effect/schema/isLessThanOrEqualToDate",Q({maximum:Yn}),({annotations:e,payload:t})=>$U(t.maximum,e)),q7=ge("effect/schema/isBetweenDate",Q({minimum:Yn,maximum:Yn,exclusiveMinimum:Nn(Ke(!0)),exclusiveMaximum:Nn(Ke(!0))}),({annotations:e,payload:t})=>UU(t,e)),z7=ge("effect/schema/isGreaterThanBigInt",Q({exclusiveMinimum:$o}),({annotations:e,payload:t})=>LU(t.exclusiveMinimum,e)),W7=ge("effect/schema/isGreaterThanOrEqualToBigInt",Q({minimum:$o}),({annotations:e,payload:t})=>jU(t.minimum,e)),K7=ge("effect/schema/isLessThanBigInt",Q({exclusiveMaximum:$o}),({annotations:e,payload:t})=>BU(t.exclusiveMaximum,e)),V7=ge("effect/schema/isLessThanOrEqualToBigInt",Q({maximum:$o}),({annotations:e,payload:t})=>HU(t.maximum,e)),G7=ge("effect/schema/isBetweenBigInt",Q({minimum:$o,maximum:$o,exclusiveMinimum:Nn(Ke(!0)),exclusiveMaximum:Nn(Ke(!0))}),({annotations:e,payload:t})=>qU(t,e));tp=V(Ur(Fu,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})})),tX=Yg(J,tp),nX=bn("effect/schema/Json",tp),rX=Q({message:J,name:Ds(J),stack:Ds(J),cause:Ds(tp)}),W2=V(Ur(F1,{toCode:()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"})})),oX=bn("effect/schema/MutableJson",W2)});var K2="~effect/platform/Terminal",eI="effect/platform/Terminal/QuitError",np,V2=(e)=>M(e,eI),mo,G2=(e)=>mo.of({...e,[K2]:K2});var sx=w(()=>{Ve();he();Xa();np=class np extends rx("QuitError")({_tag:$s("QuitError")}){[eI]=eI};mo=ze("effect/platform/Terminal")});import*as ix from"readline";function Y2(e){return e.key.ctrl&&(e.key.name==="c"||e.key.name==="d")}var J2,Z2;var Q2=w(()=>{Oe();wo();_e();Oo();he();Gf();eF();sx();J2=H(function*(e=Y2){let{stdin:t,stdout:n}=process,r=yield*bu(),o=t.readableEnded,s=!1,i=()=>{if(o=!0,!s)ks(r)};t.once("end",i),yield*dh(()=>Se(()=>t.off("end",i)));let a=yield*XP({acquire:Mr(Se(()=>{let m=ix.createInterface({input:t,escapeCodeTimeout:50}),g=(x)=>Wf(r,x),b=()=>{s=!1,ks(r)};if(s=!0,ix.emitKeypressEvents(t,m),m.on("line",g),m.once("close",b),t.isTTY)t.setRawMode(!0);return{rl:m,onClose:b,onLine:g}}),({rl:m,onClose:g,onLine:b})=>Se(()=>{if(s=!1,m.off("line",b),m.off("close",g),t.isTTY)t.setRawMode(!1);if(m.close(),o)ks(r)})),idleTimeToLive:"10 millis"}),c=Se(()=>n.columns??0),u=Se(()=>n.rows??0),l=qt(function*(){let m=yield*bu(),g=(I,C)=>{let S={input:ns(I),key:{name:C.name??"",ctrl:!!C.ctrl,meta:!!C.meta,shift:!!C.shift}};if(Wf(m,S),e(S))ks(m)},b=setInterval(()=>{},2147483647),x=()=>{clearInterval(b),ks(m)};if(yield*dh(()=>Se(()=>{clearInterval(b),t.off("keypress",g),t.off("end",x)})),t.on("keypress",g),o)x();else yield*lw(a),t.once("end",x);return m}),f=Ne(()=>kP(r).pipe(ne(et({onNone:()=>vi(hr(lw(a),Is(r))),onSome:v})),Pt(()=>new np({}))));return G2({columns:c,rows:u,readInput:l,readLine:f,display:(m)=>$f(yn((g)=>{n.write(m,(b)=>B0(b)?g(Te):g(A(bs({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:b}))))}))})}),Z2=su(mo,J2(Y2))});var X2;var eL=w(()=>{Q2();X2=Z2});var ax={};Un(ax,{layer:()=>uX});var uX;var tL=w(()=>{wo();X1();dN();bN();IN();RN();eL();uX=Z1.pipe(N_(Jm(EN,fN,kN,_N,X2)))});var nI=w(()=>{nP();tL()});var el=w(()=>{rn();Wc();Oe();dr();_e();gn();Xa()});var oL=U0(function(xye,rL){var lX=["||","&&",";;","|&","<(","<<<",">>",">&","<&","&",";","(",")","|","<",">"],nL=/[\n\r\u2028\u2029]/,fX=/[\s#!"$&'():;<=>@\\^`|]/g;rL.exports=function(t){return t.map(function(n){if(n==="")return"''";if(n&&typeof n==="object"){if("op"in n&&n.op==="glob"){if(typeof n.pattern!=="string")throw TypeError("glob token requires a string `pattern`");if(nL.test(n.pattern))throw TypeError("glob `pattern` must not contain line terminators");return n.pattern.replace(fX,"\\$&")}if("op"in n&&typeof n.op==="string"){if(lX.indexOf(n.op)<0)throw TypeError("invalid `op` value: "+JSON.stringify(n.op));return n.op.replace(/[\s\S]/g,"\\$&")}if("comment"in n&&typeof n.comment==="string"){if(nL.test(n.comment))throw TypeError("`comment` must not contain line terminators");return"#"+n.comment}throw TypeError("unrecognized object token shape")}if(/["\s\\]/.test(n)&&!/'/.test(n))return"'"+n.replace(/(['])/g,"\\$1")+"'";if(/["'\s]/.test(n))return'"'+n.replace(/(["\\$`!])/g,"\\$1")+'"';return String(n).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}~])/g,"$1\\$2")}).join(" ")}});var fL=U0(function(yye,lL){var uL="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",sL=new RegExp("^"+uL+"$"),iL="|&;()<> \\t",dX="'([^']*?)'",pX='"((\\\\"|[^"])*?)"',mX=/^#$/,aL="'",cL='"',cx="$",ec="",hX=4294967296;for(ux=0;ux<4;ux++)ec+=(hX*Math.random()).toString(16);var ux,gX=new RegExp("^"+ec);function xX(e,t){var n=t.lastIndex,r=[],o;while(o=t.exec(e))if(r[r.length]=o,t.lastIndex===o.index)t.lastIndex+=1;return t.lastIndex=n,r}function yX(e,t,n){var r=typeof e==="function"?e(n):e[n];if(typeof r>"u"&&n!="")r="";else if(typeof r>"u")r="$";if(typeof r==="object")return t+ec+JSON.stringify(r)+ec;return t+r}function SX(e,t,n){if(!n)n={};var r=n.escape||"\\",o=n.splitUnquoted===!0?`
|
|
37
|
-
|
|
38
|
-
`?0:1;else if(F!==" "&&F!=="\t"&&F!==`
|
|
39
|
-
`)x+=1}}else m+=h}if(I)return{op:"glob",pattern:m};if(o){if(x!==null&&x>0){g[g.length]=m,m="";for(var N=1;N<x;N+=1)g[g.length]=""}if(m!==""||b&&g.length===0)g[g.length]=m;return g}return m}).reduce(function(u,l){if(typeof l>"u")return u;return[].concat(l).forEach(function(f){u[u.length]=f}),u},[])}lL.exports=function(t,n,r){var o=SX(t,n,r);if(typeof n!=="function")return o;return o.reduce(function(s,i){if(typeof i==="object")return s[s.length]=i,s;var a=i.split(RegExp("("+ec+".*?"+ec+")","g"));if(a.length===1)return s[s.length]=a[0],s;return a.filter(Boolean).forEach(function(c){s[s.length]=gX.test(c)?JSON.parse(c.split(ec)[1]):c}),s},[])}});var js,rI;var dL=w(()=>{js=oL(),rI=fL()});var EX,xL,yL,SL,EL=(e)=>typeof e==="string",Bs=(e)=>{if(typeof e==="object"&&"op"in e&&typeof e.op==="string")return e.op;return null},bX=(e)=>typeof e==="object"&&("comment"in e),wX=(e)=>{try{let t=[...new Bun.Glob(e).scanSync({onlyFiles:!1,dot:!0})];if(t.length>0)return t}catch{}return[e]},vX=(e)=>{if(EL(e))return[e];if(typeof e==="object"&&"op"in e&&e.op==="glob"&&"pattern"in e)return wX(String(e.pattern));let t=Bs(e);if(t!==null){if(yL.has(t)||SL.has(t))return[];return[`__op_${t}__`]}if(bX(e))return[];return["__tripwire_cmd_sub__"]},pL=(e,t)=>{let n=[],r=[],o=[],s=[],i=0;while(i<e.length){let l=e[i],f=Bs(l);if(f!==null&&yL.has(f)){let d=n.at(-1);if(d!==void 0&&/^[0-9]+$/.test(d)&&t.remaining>0)n.pop(),t.remaining-=1;let m=e[i+1];if(m!==void 0&&EL(m)){s.push({op:f,target:m}),i+=2;continue}i+=1;continue}for(let d of vX(l))n.push(d);i+=1}if(n.length===0)return null;for(let l=1;l<n.length;l+=1){let f=n[l];if(f.startsWith("-")&&f!=="-")o.push(f);else r.push(f)}let a=n[0],c=a.lastIndexOf("/");return{head:c===-1?a:a.slice(c+1),tokens:n,args:r,flags:o,redirects:s,raw:n.join(" ")}},kX=(e)=>`$${e}`,IX=(e)=>{let t=[];for(let n=0;n<e.length;n+=1){let r=e[n],o=e[n+1];if(Bs(r)==="&"&&o!==void 0&&(Bs(o)===">"||Bs(o)===">>")){let s={op:Bs(o)===">"?"&>":"&>>"};t.push(s),n+=1;continue}if(Bs(r)===">"&&o!==void 0&&Bs(o)==="|"){t.push({op:">"}),n+=1;continue}t.push(r)}return t},CX=(e)=>e.match(/(?<![\w$])\d+(?=[<>])/g)?.length??0,oI=(e)=>{let t=/<<-?\s*(?:"(?<quoted>[^"]+)"|'(?<single>[^']+)'|(?<unquoted>[A-Za-z_][A-Za-z0-9_]*))/u.exec(e);return t?.groups?.quoted??t?.groups?.single??t?.groups?.unquoted??null},TX,sI=(e)=>TX.test(e),bL=(e)=>{let t=e.split(`
|
|
40
|
-
|
|
41
|
-
`)},wL=(e)=>{let t=new Map,n=e.split(`
|
|
42
|
-
`);for(let r=0;r<n.length;r+=1){let o=n[r],s=oI(o);if(s===null||sI(o))continue;let i=[];r+=1;while(r<n.length&&n[r].trim()!==s)i.push(n[r]),r+=1;if(!t.has(s))t.set(s,i.join(`
|
|
43
|
-
|
|
44
|
-
`),n=[];for(let r=0;r<t.length;r+=1){let o=t[r],s=oI(o);if(s===null||!sI(o))continue;let i=[];r+=1;while(r<t.length&&t[r].trim()!==s)i.push(t[r]),r+=1;if(i.length>0)n.push(i.join(`
|
|
45
|
-
`)
|
|
46
|
-
`&&!n&&!r?" ; ":s}return t},tl=(e)=>{let t,n=oee(bL(e));try{t=rI(n,kX)}catch{return[gL(n)]}t=IX(t);let r={remaining:CX(n)},o=[],s=[];for(let c of t){let u=Bs(c);if(u!==null&&SL.has(u)){let l=pL(s,r);if(l!==null)o.push(l);s=[];continue}s.push(c)}let i=pL(s,r);if(i!==null)o.push(i);if(ree(o))o.push(gL(n));for(let c of[...RX(e),...OX(e)])for(let u of tl(c))o.push(u);let a=o.length;for(let c=0;c<a;c+=1){let u=o[c];for(let l of nee)for(let f of l(u))for(let d of tl(f))o.push(d)}return o},see=(e)=>e.startsWith("./")?e.slice(2):e,iI=(e,t=[],n=[])=>{if(e==="")return!1;let r=see(e);if(r===".."||r.startsWith("../")||r.includes("/../"))return!1;for(let o of[...xL,...n])if(r===o||r.startsWith(`${o}/`))return!0;for(let o of[...EX,...t])if(r===o||r.startsWith(`${o}/`))return!0;return!1},TL=(e=[],t=[])=>{let n={"build outputs":["dist","build","_build","out","target"],"js framework outputs":[".next",".nuxt",".svelte-kit",".output",".astro",".angular",".vite",".parcel-cache",".turbo",".vercel",".netlify",".fly",".wrangler",".serverless"],"tests / coverage":["coverage",".nyc_output"],caches:[".cache",".ruff_cache",".mypy_cache",".pytest_cache",".ty_cache",".tox"],"language / package":["__pycache__",".venv","venv","node_modules",".gradle","DerivedData",".bundle",".cargo-target"],"tmp / state":["tmp",".tmp",".state",...xL],iac:[".terraform"],"bundler dev":[".yarn/cache",".yarn/install-state.gz",".pnpm-store",".bun"]};if(e.length>0)n["custom relative"]=e;if(t.length>0)n["custom absolute"]=t;return Object.entries(n).map(([r,o])=>` ${r}: ${o.join(", ")}`).join(`
|
|
47
|
-
`)},wn=(e)=>/(?<prefix>^|\s)#\s*tripwire-allow:[ \t]*\S[^\r\n]*/.test(bL(e));var Lo=w(()=>{dL();EX=["dist","build","_build","out","target",".next",".nuxt",".svelte-kit",".output",".astro",".angular",".vite",".parcel-cache",".turbo",".vercel",".netlify",".fly",".wrangler",".serverless","coverage",".nyc_output",".cache",".ruff_cache",".mypy_cache",".pytest_cache",".ty_cache",".tox","__pycache__",".venv","venv","node_modules",".gradle","DerivedData",".bundle",".cargo-target","tmp",".tmp",".state",".terraform",".yarn/cache",".yarn/install-state.gz",".pnpm-store",".bun"],xL=["/tmp","/var/tmp","/var/folders","/private/tmp","/private/var/tmp","/private/var/folders"],yL=new Set([">",">>","<","<<","<<<","<>",">&","<&","&>","&>>"]),SL=new Set([";","&&","||","|","|&","&"]),TX=/(?:^|[|;&]\s*)(?:\/(?:usr\/bin|bin|usr\/local\/bin|opt\/homebrew\/bin)\/)?(?:sh|bash|zsh|dash|ksh|ash)(?:\s|$)/u,vL=/^\$\{?HOME\}?(?:\/|$)/,PX=new Set(["-e","--extension","-t","--type","-E","--exclude","-d","--max-depth","--min-depth","--exact-depth","-c","--color","--changed-within","--changed-before","-S","--size","-o","--owner","-j","--threads","-g","--glob","--format","--max-results","--ignore-file","--search-path","--base-directory","--path-separator","--and"]),mL={execFlags:new Set(["-x","-X","--exec","--exec-batch"]),placeholders:new Set(["{}","{/}","{//}","{.}","{/.}"]),pickRoot:FX},hL={execFlags:new Set(["-exec","-execdir","-ok","-okdir"]),placeholders:new Set(["{}"]),pickRoot:MX},NX=Object.assign(Object.create(null),{fd:mL,fdfind:mL,find:hL,gfind:hL}),UX=/\$\(\s*cat\s+<<-?\s*['"]?(?<delimiter>\w+)['"]?\s*\n(?<body>[\s\S]*?)\n\s*\k<delimiter>\s*\)/u,LX=/\$\(\s*(?:printf|echo)\s+(?:-[a-zA-Z]+\s+)*'(?<content>[^']*)'/u,jX=new Set(["sh","bash","zsh","dash","ksh","ash"]),HX=new Set(["command","exec","env","time","nohup","setsid","nice","ionice","chronic","stdbuf","unbuffer","script","taskset","sudo","doas","xargs","watch"]),qX={command:new Set,env:new Set(["-u","--unset","-C","--chdir","-S","--split-string","--block-signal"]),time:new Set(["-f","--format","-o","--output"]),nice:new Set(["-n","--adjustment"]),ionice:new Set(["-c","--class","-n","--classdata","-p","--pid"]),stdbuf:new Set(["-i","--input","-o","--output","-e","--error"]),script:new Set(["-c","--command"]),taskset:new Set,sudo:new Set(["-u","--user","-g","--group","-C","--close-from","-D","--chdir","-h","--host","-p","--prompt","-r","--role","-t","--type","-U","--other-user","-R","--chroot","-T","--command-timeout"]),doas:new Set(["-a","-C","-u"]),xargs:new Set(["-I","-i","-J","-n","--max-args","-P","--max-procs","-s","--max-chars","-L","--max-lines","-E","--eof","-d","--delimiter","-a","--arg-file","--replace"]),watch:new Set(["-n","--interval"])},VX=new Set(["eval"]),JX=new Set(["run","proxy","err","test","summary"]),XX={timeout:{valueFlags:new Set(["-s","--signal","-k","--kill-after"]),skipPositionals:1,dashCommand:!1},gtimeout:{valueFlags:new Set(["-s","--signal","-k","--kill-after"]),skipPositionals:1,dashCommand:!1},chroot:{valueFlags:new Set(["--userspec","--groups"]),skipPositionals:1,dashCommand:!1},flock:{valueFlags:new Set(["-w","--wait","--timeout","-E","--conflict-exit-code"]),skipPositionals:1,dashCommand:!0},su:{valueFlags:new Set,skipPositionals:0,dashCommand:!0}},CL=new Set(["!","if","elif","then","else","while","until","do"]),nee=[$X,BX,KX,GX,QX,eee,tee]});import{readFileSync as iee}from"fs";import{homedir as aee}from"os";var OL,cee,uee,lee,fee,dee,pee,aI,AL,_L,mee=(e)=>e instanceof Error&&("code"in e)&&e.code==="ENOENT",hee=(e)=>j.try({try:()=>iee(e,"utf8"),catch:(t)=>new AL({cause:t})}).pipe(j.catchTag("ConfigReadError",(t)=>mee(t.cause)?j.succeed(null):j.fail(t))),gee=(e)=>j.try({try:()=>JSON.parse(e),catch:(t)=>new _L({cause:t})}),xee=(e)=>P.decodeUnknownEffect(pee)(e,{onExcessProperty:"error"}),px=()=>({git:{protectedBranches:[],enforceConventionalCommits:!1},safePaths:{},toolPolicies:[],blockedCommands:[],allowedCommands:[],secretScanner:{executable:"betterleaks",timeoutMs:5000}}),cI=(e)=>{let t=px();return{git:{protectedBranches:e.git?.protectedBranches??t.git.protectedBranches,enforceConventionalCommits:e.git?.enforceConventionalCommits??t.git.enforceConventionalCommits},safePaths:{...t.safePaths,...e.safePaths},toolPolicies:e.toolPolicies??t.toolPolicies,blockedCommands:e.blockedCommands??t.blockedCommands,allowedCommands:e.allowedCommands??t.allowedCommands,secretScanner:e.secretScanner??t.secretScanner}},RL=(e=aI)=>j.gen(function*(){let n=yield*hee(e);if(n===null)return{ok:!0,config:px()};let r=yield*gee(n),o=yield*xee(r);return{ok:!0,config:cI(o)}}).pipe(j.timeout(1000),j.catchCause((t)=>{let n={ok:!1,error:lt.pretty(t)};return j.succeed(n)}));var PL=w(()=>{el();OL=P.Struct({pattern:P.String,message:P.String,action:P.optional(P.Union([P.Literal("deny"),P.Literal("ask")])),requiresFlags:P.optional(P.Array(P.String)),forbidsFlagValues:P.optional(P.Array(P.Struct({flag:P.String,values:P.Array(P.String)})))}),cee=P.Struct({protectedBranches:P.optional(P.Array(P.String)),enforceConventionalCommits:P.optional(P.Boolean)}),uee=P.Struct({relative:P.optional(P.Array(P.String)),absolute:P.optional(P.Array(P.String))}),lee=P.Struct({argumentsIncludeAll:P.optional(P.Array(P.String)),argumentsStartWith:P.optional(P.Array(P.String)),shortFlagsIncludeAll:P.optional(P.Array(P.String))}),fee=P.Struct({rule:P.String,executables:P.Array(P.String),action:P.Union([P.Literal("deny"),P.Literal("warn")]),message:P.String,match:P.optional(lee)}),dee=P.Struct({executable:P.String,timeoutMs:P.Finite.check(P.isGreaterThan(0))}),pee=P.Struct({git:P.optional(cee),safePaths:P.optional(uee),toolPolicies:P.optional(P.Array(fee)),blockedCommands:P.optional(P.Array(OL)),allowedCommands:P.optional(P.Array(OL)),secretScanner:P.optional(dee)}),aI=`${aee()}/.config/tripwire/config.json`;AL=class AL extends Or.TaggedError("ConfigReadError"){};_L=class _L extends Or.TaggedError("ConfigParseError"){}});var DL,fI,dI=(e)=>({kind:"cursor",eventName:e,post:fI.has(e)}),yee=(e)=>DL.has(e)||fI.has(e),tc=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),Mt=(e,...t)=>{for(let n of t){let r=e[n];if(typeof r==="string")return r}return},pI=(e,...t)=>{for(let n of t)if(n in e)return e[n];return},lI=(e,t,...n)=>{let r=Mt(e,...n);if(r!==void 0)return r;if(typeof t==="string"&&n.includes("command"))return t;return tc(t)?Mt(t,...n):void 0},FL=(e,t)=>{if(e===void 0)throw Error(`Cursor hook payload missing ${t}`);return e},See=(e)=>{let t=e.toLowerCase();if(t==="bash"||t==="exec"||t==="shell"||t==="run_command")return"Bash";if(t==="read"||t==="read_file")return"Read";if(t==="write"||t==="write_file")return"Write";if(t==="edit"||t==="edit_file"||t==="multiedit"||t==="apply_patch")return"Edit";return e},Eee=(e)=>e==="Read"||e==="Write"||e==="Edit",bee=(e,t)=>{let n;if(typeof e==="string")n=e;else if(tc(e))n=Mt(e,"command","cmd");if(t&&n===void 0)throw Error("Cursor hook payload missing command");if(typeof e==="string")return{command:e};if(!tc(e)||n===void 0)return e;return{...e,command:n}},wee=(e,t,n)=>{let r=Mt(t,"file_path","filePath","path");if(n&&r===void 0)throw Error(`Cursor ${e} hook payload missing file path`);if(e==="Read")return{...t,file_path:r??""};if(e==="Write"){let o=Mt(t,"content","fileText","text");if(n&&o===void 0)throw Error("Cursor Write hook payload missing content");return{...t,file_path:r??"",content:o??""}}if(e==="Edit"){let o=Mt(t,"old_string","oldString"),s=Mt(t,"new_string","newString");if(n&&(o===void 0||s===void 0))throw Error("Cursor Edit hook payload missing oldString or newString");return{...t,file_path:r??"",old_string:o??"",new_string:s??""}}return t},uI=(e,t,n=!0)=>{if(e==="Bash")return bee(t,n);if(!Eee(e))return t;if(!tc(t)){if(n)throw Error(`Cursor ${e} hook payload is missing tool input`);return t}return wee(e,t,n)},ML=(e,t)=>{if(typeof t!=="string")return t;if(e==="Bash")return{stdout:t,stderr:""};if(e==="Read")return{content:t};return{content:t}},vee=(e,t)=>{if(e==="beforeShellExecution"||e==="afterShellExecution")return"Bash";if(e==="beforeReadFile"||e==="beforeTabFileRead"||e==="afterFileEdit"||e==="afterTabFileEdit")return e.startsWith("before")?"Read":"Edit";let n=Mt(t,"tool_name","toolName");if(n!==void 0)return See(n);let r=pI(t,"tool_input","toolInput");if(Mt(t,"command","cmd")!==void 0||typeof r==="string"||tc(r)&&Mt(r,"command","cmd")!==void 0)return"Bash";if(Mt(t,"file_path","filePath","path")!==void 0||tc(r)&&Mt(r,"file_path","filePath","path")!==void 0)return"Read";return""},kee=(e,t)=>{if(e==="Bash")return{command:lI(t,void 0,"command","cmd")};let n={file_path:Mt(t,"file_path","filePath","path")};if(e==="Write")n.content=Mt(t,"content","fileText","text");if(e==="Edit")n.old_string=Mt(t,"old_string","oldString"),n.new_string=Mt(t,"new_string","newString");return n},Iee=(e,t,n,r)=>{let o=pI(n,"tool_input","toolInput"),s=!r;if(e==="beforeShellExecution"||e==="afterShellExecution"){let i=lI(n,o,"command","cmd");return{command:s?FL(i,"command"):i??""}}if(e==="beforeReadFile"||e==="beforeTabFileRead"||e==="afterFileEdit"||e==="afterTabFileEdit"){let i=lI(n,o,"file_path","filePath","path");return uI(t,{file_path:s?FL(i,"file path"):i??"",...Array.isArray(n.edits)&&{edits:n.edits}},s)}if(o===void 0&&["Bash","Read","Write","Edit"].includes(t))return uI(t,kee(t,n),s);return uI(t,o,s)},Cee=(e,t,n)=>{if(e==="afterShellExecution")return ML(t,Mt(n,"output")??"");let r=pI(n,"tool_response","toolResponse","tool_output","toolOutput","result","result_json");return ML(t,r)},NL=(e,t,n)=>{let r=vee(t,e),o=Iee(t,r,e,n),s=n?Cee(t,r,e):void 0,i=Mt(e,"cwd"),a=Mt(e,"conversation_id","session_id"),c=Mt(e,"tool_use_id");return{event:{hook_event_name:n?"PostToolUse":"PreToolUse",...r.length>0&&{tool_name:r},...o!==void 0&&{tool_input:o},...s!==void 0&&{tool_response:s},...i!==void 0&&{cwd:i},...a!==void 0&&{session_id:a},...c!==void 0&&{tool_use_id:c}},host:dI(t)}},$L=(e,t)=>{if(t!==void 0&&!yee(t))throw Error(`Unknown Cursor hook event "${t}"`);if(!tc(e)){if(t!==void 0)throw Error(`Cursor ${t} hook payload must be a JSON object`);return{event:e,host:{kind:"native"}}}let n=t??Mt(e,"hook_event_name");if(n!==void 0&&DL.has(n))return NL(e,n,!1);if(n!==void 0&&fI.has(n))return NL(e,n,!0);return{event:e,host:{kind:"native"}}};var UL=w(()=>{DL=new Set(["preToolUse","beforeShellExecution","beforeMCPExecution","beforeReadFile","beforeTabFileRead"]),fI=new Set(["postToolUse","postToolUseFailure","afterShellExecution","afterMCPExecution","afterFileEdit","afterTabFileEdit"])});var LL,Z=(e)=>({kind:"allow",rule:e,message:""}),Bi=(e,t)=>({kind:"warn",rule:e,message:t}),zt=(e,t)=>({kind:"ask",rule:e,message:t}),se=(e,t)=>({kind:"deny",rule:e,message:t}),nl=(e)=>{let t=Z("none");for(let n of e)if(LL[n.kind]>LL[t.kind])t=n;return t};var Xn=w(()=>{LL={allow:0,warn:1,ask:2,deny:3}});var mI,rl=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),jL=(e)=>rl(e)&&typeof e.command==="string",BL=(e)=>rl(e)&&typeof e.file_path==="string"&&typeof e.old_string==="string"&&typeof e.new_string==="string",HL=(e)=>rl(e)&&typeof e.file_path==="string"&&typeof e.content==="string",qL=(e)=>rl(e)&&typeof e.file_path==="string",zL=(e,t)=>{if(!rl(t))return"";if(e==="Bash"){let n=typeof t.stdout==="string"?t.stdout:"",r=typeof t.stderr==="string"?t.stderr:"";return[n,r].filter((o)=>o.length>0).join(`
|
|
48
|
-
`)
|
|
49
|
-
`)}catch{}};var KL=w(()=>{WL=`${Aee()}/.claude/tripwire.log`;try{Oee(_ee.dirname(WL),{recursive:!0})}catch{}});var Ree=(e)=>e.tokens.slice(1).join(" "),VL=(e,...t)=>{let n=new Set(e.flags);return t.some((r)=>n.has(r))},Pee,Fee,GL=(e,t)=>{let n=wn(t),r=[];for(let o of e)for(let s of Pee){if(!s.match(o,t))continue;if(n&&!Fee.has(s.rule))continue;r.push(s.action==="deny"?se(s.rule,s.message):zt(s.rule,s.message));break}return r.length===0?Z("bash-deny"):nl(r)};var JL=w(()=>{Lo();Xn();Pee=[{rule:"unsupported-shell-structure",action:"deny",message:"Tripwire cannot inspect every executable branch in this shell structure. Rewrite it as simple commands joined with `;`, `&&`, or `||` so each command can be checked.",match:(e)=>e.head===fx},{rule:"rm-rf-root",action:"deny",message:"rm -rf / is catastrophic. If the goal is cleaning a subdirectory, scope the path inside the project (e.g. ./dist).",match:(e)=>e.head==="rm"&&VL(e,"-rf","-fr","-Rf","-fR")&&e.tokens.includes("/")},{rule:"rm-rf-home",action:"deny",message:"rm -rf on $HOME / ~ would erase the home directory. Refuse.",match:(e)=>e.head==="rm"&&VL(e,"-rf","-fr","-Rf","-fR")&&e.tokens.some((t)=>/^(?<home>~|\$HOME|\$\{HOME\})$/.test(t))},{rule:"fork-bomb",action:"deny",message:"Fork bomb pattern detected. Refuse.",match:(e,t)=>/:\(\)\s*\{\s*:\s*\|\s*:\s*&\s*\}\s*;/.test(t)},{rule:"source-script",action:"deny",message:"`source` / `.` executes a file in the current shell. Refuse arbitrary sourced scripts.",match:(e)=>(e.head==="source"||e.head===".")&&e.tokens.length>1},{rule:"dd-raw-device",action:"deny",message:"dd writing to a raw block device wipes the disk. Refuse.",match:(e)=>e.head==="dd"&&/\bof=\/dev\/(?<type>disk|sd|nvme|rdisk)/i.test(Ree(e))},{rule:"mkfs",action:"deny",message:"mkfs formats a filesystem. Refuse.",match:(e)=>/^mkfs(?<ext>\.[a-z0-9]+)?$/i.test(e.head)},{rule:"kill-all",action:"deny",message:"kill -9 -1 kills every process you own. Refuse.",match:(e)=>e.head==="kill"&&e.tokens.includes("-9")&&e.tokens.includes("-1")},{rule:"chmod-777-recursive",action:"deny",message:"Recursive chmod 777 makes everything world-writable. Use 755 for directories, 644 for files, scoped narrowly.",match:(e)=>e.head==="chmod"&&e.flags.some((t)=>t.includes("R"))&&e.tokens.includes("777")},{rule:"no-verify",action:"deny",message:"--no-verify skips git hooks. Per policy: never skip hooks. Fix the underlying issue.",match:(e)=>e.tokens.includes("--no-verify")},{rule:"no-gpg-sign",action:"deny",message:"Bypassing GPG signing is off-limits unless explicitly requested.",match:(e,t)=>/--no-gpg-sign\b|-c\s+commit\.gpgsign=false/.test(t)},{rule:"sudo",action:"ask",message:"sudo escalates privileges and is almost never needed in a coding session. If genuinely required, explain why; otherwise find a non-sudo path.",match:(e)=>e.head==="sudo"},{rule:"shutdown",action:"deny",message:"shutdown / reboot / halt control the machine. Refuse \u2014 system control should be done manually.",match:(e)=>["shutdown","reboot","halt","poweroff"].includes(e.head)},{rule:"launchctl-mutation",action:"deny",message:"launchctl load/unload/bootstrap/bootout/kickstart mutates system services. Refuse \u2014 surface the intent instead.",match:(e)=>e.head==="launchctl"&&typeof e.tokens[1]==="string"&&["load","unload","bootstrap","bootout","kickstart","enable","disable"].includes(e.tokens[1])},{rule:"defaults-write",action:"deny",message:"`defaults write` mutates macOS preferences. Refuse \u2014 surface the intent.",match:(e)=>e.head==="defaults"&&e.tokens[1]==="write"},{rule:"csrutil",action:"deny",message:"csrutil controls System Integrity Protection. Refuse.",match:(e)=>e.head==="csrutil"},{rule:"nvram",action:"deny",message:"nvram modifies firmware variables. Refuse.",match:(e)=>e.head==="nvram"},{rule:"diskutil-destructive",action:"deny",message:"diskutil eraseDisk / reformat / partitionDisk wipes disks. Refuse.",match:(e)=>e.head==="diskutil"&&typeof e.tokens[1]==="string"&&["eraseDisk","reformat","partitionDisk","eraseVolume","secureErase"].includes(e.tokens[1])},{rule:"tmutil-destructive",action:"deny",message:"tmutil delete / disablelocal touches Time Machine. Refuse.",match:(e)=>e.head==="tmutil"&&typeof e.tokens[1]==="string"&&["delete","disablelocal"].includes(e.tokens[1])},{rule:"osascript",action:"ask",message:"osascript runs arbitrary AppleScript and can do almost anything (move files, send emails, drive apps). Confirm with the user what you want done before running it.",match:(e)=>e.head==="osascript"},{rule:"topgrade",action:"deny",message:"topgrade upgrades everything (brew, mas, npm globals, rust, mise). System upgrades should be done manually.",match:(e)=>e.head==="topgrade"},{rule:"rsync-delete",action:"deny",message:"rsync --delete removes files at the destination. High blast radius \u2014 surface the intent instead.",match:(e)=>e.head==="rsync"&&e.flags.includes("--delete")},{rule:"softwareupdate-install",action:"deny",message:"`softwareupdate --install / -i / -d` triggers macOS system updates. Refuse \u2014 system updates should be done manually.",match:(e)=>e.head==="softwareupdate"&&e.flags.some((t)=>t==="--install"||t==="-i"||t==="-d"||t.startsWith("--download"))},{rule:"pmset-write",action:"deny",message:"`pmset` (with arguments) writes power-management settings. Read-only `pmset -g` is fine; mutations need the user.",match:(e)=>e.head==="pmset"&&e.tokens.length>1&&!e.tokens.includes("-g")&&!e.tokens.includes("-G")},{rule:"dscl-mutate",action:"deny",message:"`dscl . -create / -delete / -append / -change / -merge` modifies the local directory service (your user account, groups, etc.). Refuse.",match:(e)=>e.head==="dscl"&&e.tokens.some((t)=>["-create","-delete","-append","-change","-merge","-passwd"].includes(t))},{rule:"xattr-quarantine-bypass",action:"deny",message:"`xattr -d com.apple.quarantine` removes Gatekeeper's quarantine bit \u2014 the macOS protection against running untrusted binaries. Refuse.",match:(e)=>e.head==="xattr"&&e.tokens.includes("-d")&&e.tokens.some((t)=>t.includes("com.apple.quarantine"))},{rule:"spctl-disable",action:"deny",message:"`spctl --master-disable` / `--global-disable` disables Gatekeeper system-wide. Refuse.",match:(e)=>e.head==="spctl"&&e.flags.some((t)=>t==="--master-disable"||t==="--global-disable"||t==="--disable")},{rule:"kextload",action:"deny",message:"Loading a kernel extension (`kextload`, `kmutil load`) is a system-level mutation. Refuse \u2014 the user handles this manually.",match:(e)=>e.head==="kextload"||e.head==="kextunload"||e.head==="kmutil"&&(e.tokens[1]==="load"||e.tokens[1]==="unload")},{rule:"security-keychain-destructive",action:"deny",message:"`security delete-keychain / delete-generic-password / delete-internet-password / set-keychain-settings` mutates your Keychain (where CLIs store their secrets). Refuse \u2014 Keychain should be managed manually.",match:(e)=>e.head==="security"&&typeof e.tokens[1]==="string"&&["delete-keychain","delete-generic-password","delete-internet-password","delete-certificate","delete-identity","set-keychain-settings","unlock-keychain","lock-keychain","create-keychain"].includes(e.tokens[1])},{rule:"security-keychain-add-write",action:"ask",message:"`security add-generic-password / add-internet-password / add-certificate` writes to your Keychain. Other tools manage their own entries \u2014 confirm this is the right path before adding anything else manually.",match:(e)=>e.head==="security"&&typeof e.tokens[1]==="string"&&["add-generic-password","add-internet-password","add-certificate"].includes(e.tokens[1])},{rule:"systemsetup",action:"deny",message:"`systemsetup -set...` writes machine-wide settings (timezone, sleep, network time, restart-on-power-failure). Refuse.",match:(e)=>e.head==="systemsetup"&&e.tokens.some((t)=>t.startsWith("-set"))},{rule:"scutil-set",action:"deny",message:"`scutil --set` writes system configuration (computer name, hostname, LocalHostName). Refuse \u2014 read-only `scutil --get` is fine.",match:(e)=>e.head==="scutil"&&e.tokens.includes("--set")},{rule:"brew-mutation",action:"ask",message:"`brew install/uninstall/upgrade/untap` modifies the machine globally. Confirm before running.",match:(e)=>e.head==="brew"&&typeof e.tokens[1]==="string"&&["install","uninstall","upgrade","reinstall","untap","tap"].includes(e.tokens[1])},{rule:"mas-mutation",action:"ask",message:"`mas install/uninstall` changes installed Mac App Store apps. Confirm.",match:(e)=>e.head==="mas"&&typeof e.tokens[1]==="string"&&["install","uninstall","purchase"].includes(e.tokens[1])},{rule:"gh-destructive",action:"deny",message:"gh repo/release/issue delete is destructive on shared state. Refuse.",match:(e)=>e.head==="gh"&&typeof e.tokens[1]==="string"&&typeof e.tokens[2]==="string"&&["repo","release","issue","pr"].includes(e.tokens[1])&&["delete","destroy","remove"].includes(e.tokens[2])},{rule:"flyctl-destroy",action:"deny",message:"flyctl apps destroy / volumes destroy nukes deployed infra. Refuse.",match:(e)=>e.head==="flyctl"&&e.tokens.some((t)=>t==="destroy"||t==="delete")},{rule:"gcloud-delete",action:"deny",message:"`gcloud ... delete` affects cloud resources. Refuse.",match:(e)=>e.head==="gcloud"&&e.tokens.includes("delete")}],Fee=new Set(["unsupported-shell-structure","rm-rf-root","rm-rf-home","fork-bomb","dd-raw-device","mkfs","kill-all","diskutil-destructive","tmutil-destructive","shutdown","csrutil","nvram","kextload","spctl-disable","xattr-quarantine-bypass","topgrade","softwareupdate-install","systemsetup","scutil-set","security-keychain-destructive","no-verify","no-gpg-sign"])});var gI=(e)=>e.protectedBranches??[],Mee,Nee,Dee,$ee=(e)=>{if(e.head!=="git")return null;let t=e.tokens.slice(1),n=0;while(n<t.length){let r=t[n];if(r===void 0)break;if(Nee.has(r)){n+=2;continue}if(Dee.has(r)){n+=1;continue}if(r.startsWith("--git-dir=")||r.startsWith("--work-tree=")||r.startsWith("--namespace=")||r.startsWith("--super-prefix=")||r.startsWith("--exec-path=")){n+=1;continue}if(r.startsWith("-")){n+=1;continue}return{subcommand:r,subArgs:t.slice(n+1)}}return null},Uee=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=e[n];if(r===void 0)break;if(r==="-m"||r==="--message"){let o=e[n+1];return o===void 0?null:dx(o,t)}if(r.startsWith("--message="))return dx(r.slice(10),t);if(/^-[a-zA-Z]*m[a-zA-Z]*$/.test(r)){let o=e[n+1];return o===void 0?null:dx(o,t)}}return null},Lee=(e,t)=>{let n=gI(t);for(let r of e)for(let o of n)if(r===o||r.endsWith(`:${o}`)||r.endsWith(`/${o}`))return o;return null},jee=(e)=>e.filter((t)=>!t.startsWith("-")),Bee=(e)=>e.filter((t)=>t.startsWith("-")),kt=(e,...t)=>{let n=new Set(e);return t.some((r)=>n.has(r))},Hee=({subArgs:e,positional:t})=>{if(kt(e,"--global","--system"))return se("git-config-global","Modifying global / system git config is off-limits \u2014 that is your personal identity. Read-only `git config --get` is fine.");if(!kt(e,"--get","-l","--list","--get-all","--get-regexp")&&t.length>=2)return se("git-config-write","Local git config writes should be done explicitly. To read a value, use `git config --get <key>`.");return Z("bash-git")},qee=({subArgs:e})=>{if(kt(e,"--cached"))return Z("bash-git");return zt("git-rm","`git rm <path>` removes from the index AND the working tree. To untrack-only, use `git rm --cached <path>`. To delete the file separately, use `trash` / `rip`. Confirm intent.")},zee=({subArgs:e,positional:t})=>{if(kt(e,"--staged","-S")&&!kt(e,"--worktree","-W"))return Z("bash-git");if(t.length>0)return se("git-restore-discard","`git restore <path>` discards uncommitted changes in the working tree. Refuse \u2014 `git diff <path>` to inspect first, or `git stash push <path>` to preserve.");return Z("bash-git")},Wee=({subArgs:e,positional:t})=>{if(kt(e,"-b","-B"))return Z("bash-git");if(kt(e,"-f","--force"))return se("git-checkout-force","`git checkout -f` overwrites the working tree without preserving uncommitted changes. Refuse.");if(e.includes("--"))return se("git-checkout-discard","`git checkout -- <path>` discards uncommitted working-tree changes. Refuse \u2014 use `git stash push <path>` to preserve, or `git diff <path>` to inspect first.");let[n]=t;if(n!==void 0&&t.length===1&&(n==="."||n.startsWith("./")))return se("git-checkout-discard-all","`git checkout .` discards ALL uncommitted working-tree changes. Refuse \u2014 `git stash` to preserve, or `git diff` to inspect first.");return Z("bash-git")},Kee=({subArgs:e})=>{if(kt(e,"-f","--force","--discard-changes"))return se("git-switch-force","`git switch -f / --discard-changes` throws away uncommitted working-tree changes. Refuse.");return Z("bash-git")},Vee=({subArgs:e,flags:t,positional:n})=>{if(kt(e,"--hard"))return se("git-reset-hard","`git reset --hard` discards all uncommitted changes AND moves HEAD. Refuse \u2014 describe the intent in chat. If undoing a published commit, `git revert <sha>` is safer.");if(kt(e,"--keep"))return zt("git-reset-keep","`git reset --keep` resets HEAD but preserves uncommitted local changes. Confirm intent.");if(n.length===0&&t.length===0)return Z("bash-git");return zt("git-reset-mixed","`git reset` moves HEAD. Confirm intent \u2014 if undoing a commit, `git revert` is usually safer.")},Gee=({flags:e})=>{if(e.some((t)=>/^-[a-zA-Z]*[df]/.test(t)||t==="--force"))return se("git-clean-fd","`git clean -fd` deletes untracked files (often your in-progress work). Refuse \u2014 inspect with `git clean -dn` (dry run) first. If genuinely needed, append ` # tripwire-allow: <reason>`.");return Z("bash-git")},Jee=({subArgs:e,positional:t,config:n})=>{if(kt(e,"--abort","--quit","--continue","--skip","--edit-todo"))return Z("bash-git");if(kt(e,"-i","--interactive"))return se("git-rebase-interactive","`git rebase -i` rewrites history interactively. Refuse \u2014 too easy to lose commits in the agent loop. If this is genuinely required, do it manually outside the agent.");let[r]=t,o=gI(n);if(r!==void 0&&o.includes(r))return zt("git-rebase-onto-protected",`Rebasing onto \`${r}\` rewrites history of the current branch. \`git merge ${r}\` is usually safer. Confirm intent.`);return zt("git-rebase","`git rebase` rewrites commit history. `git merge` is usually safer. Confirm intent.")},Zee=({subArgs:e})=>{if(kt(e,"--abort","--quit","--continue","--skip"))return Z("bash-git");return zt("git-cherry-pick","`git cherry-pick` applies commits onto the current branch and can create conflicts. Confirm intent.")},Yee=({subArgs:e})=>{if(kt(e,"--abort","--continue","--quit"))return Z("bash-git");return zt("git-merge","`git merge <branch>` may create merge conflicts. Confirm intent.")},Qee=({subArgs:e,config:t,heredocBodies:n})=>{if(kt(e,"--amend"))return se("git-commit-amend","`git commit --amend` rewrites the last commit. If it has been pushed, this causes upstream divergence. Refuse \u2014 surface the intent.");let r=Uee(e,n),o=kt(e,"-F","--file","-c","-C","--reuse-message","--reedit-message"),s=kt(e,"--no-edit");if(r===null&&!o&&!s)return se("git-commit-no-message",'`git commit` without `-m "..."` opens an editor and hangs the agent. Use `git commit -m "<conventional message>"`.');if(r!==null&&t.enforceConventionalCommits===!0&&!Mee.test(r))return se("git-commit-non-conventional",["Commit message must follow Conventional Commits format:"," `<type>(<scope>)?(!)?: <description>`","Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert.","Examples:"," `fix(auth): handle expired token refresh`"," `feat: add bash-git rule`"," `chore: bump deps`",`Got: ${JSON.stringify(r)}`].join(`
|
|
50
|
-
`));if(kt(e,"-a","--all")||e.some((i)=>/^-[a-zA-Z]*a[a-zA-Z]*$/.test(i)))return zt("git-commit-auto-stage","`git commit -a / --all` auto-stages every tracked change. Explicit `git add <files>` first is usually clearer about what is being committed. Confirm.");return Z("bash-git")},Xee=({subArgs:e,flags:t,positional:n,config:r})=>{if(t.some((s)=>s==="--force"||s==="-f"||s.startsWith("--force-with-lease")))return se("git-force-push","Force push is forbidden. If a branch needs to be reset upstream, surface the intent \u2014 there is almost always a non-force path.");if(kt(e,"--delete","--mirror")||e.some((s)=>s.startsWith(":")))return se("git-push-delete","Refusing to delete a remote branch via push. If genuinely needed, surface the intent.");let o=Lee(n,r);if(o!==null)return se("git-push-protected",`Refusing to push directly to protected branch \`${o}\`. Open a PR instead: \`gh pr create\`.`);return Z("bash-git")},ete=({subArgs:e,flags:t,positional:n,config:r})=>{let o=t.find((s)=>s==="-D"||s==="-d"||s==="--delete"||/^-[a-zA-Z]*D/.test(s)||/^-[a-zA-Z]*d/.test(s));if(o!==void 0){let s=n,i=new Set(gI(r)),a=s.find((c)=>i.has(c));if(a!==void 0)return se("git-branch-delete-protected",`Refusing to delete protected branch \`${a}\`.`);if(o==="-D"||o.includes("D"))return se("git-branch-force-delete",`\`git branch -D ${s.join(" ")}\` force-deletes branches even if unmerged (potential data loss). To delete a merged branch, use \`-d\`. To force, append \` # tripwire-allow: <reason>\`.`);return zt("git-branch-delete",`\`git branch -d ${s.join(" ")}\` deletes a branch (merged-only check). Confirm intent.`)}if(kt(e,"-m","-M","--move"))return zt("git-branch-move","Renaming a branch can confuse pushed remotes. Confirm intent.");return Z("bash-git")},tte=({subArgs:e})=>{if(kt(e,"-d","--delete"))return se("git-tag-delete","`git tag -d` deletes a tag. Refuse \u2014 surface intent.");return Z("bash-git")},nte=({subArgs:e})=>{let t=e[0]??"push";if(t==="drop"||t==="clear")return se("git-stash-drop",`\`git stash ${t}\` discards stashed work. Refuse \u2014 \`git stash list\` and \`git stash show\` to inspect first.`);return Z("bash-git")},rte=({flags:e})=>{if(e.some((t)=>t.startsWith("--prune=")||t==="--aggressive"))return se("git-gc-prune","`git gc --prune=now` / `--aggressive` destroys reflog recovery options. Refuse.");return Z("bash-git")},ote=({subArgs:e})=>{let[t]=e;if(t==="add"||t==="remove"||t==="rm"||t==="set-url"||t==="rename")return zt("git-remote-mutate",`\`git remote ${t}\` changes which remote you're pushing to. Confirm \u2014 accidentally pointing at the wrong remote is high blast-radius.`);return Z("bash-git")},ZL=({subcommand:e,subArgs:t})=>{let n=t[0]??"";if(["add","remove","rm","deinit","sync","set-url"].includes(n))return zt("git-submodule-worktree-mutate",`\`git ${e} ${n}\` modifies repo structure. Confirm intent.`);return Z("bash-git")},ste,ite=(e,t,n)=>{let{subcommand:r,subArgs:o}=e,s=Bee(o),i=jee(o);if(new Set(["status","diff","log","show","blame","rev-parse","rev-list","ls-files","ls-tree","cat-file","reflog","describe","shortlog","whatchanged","archive","bundle","fsck","fetch","ls-remote","help","version","grep","name-rev","merge-base","symbolic-ref","check-ignore","count-objects","verify-commit","verify-tag"]).has(r)){if(r==="reflog"&&(o[0]==="expire"||kt(o,"--expire")))return se("git-reflog-expire","`git reflog expire` destroys git's recovery history. Refuse \u2014 surface the intent.");if(r==="symbolic-ref"&&i.length>=2)return se("git-symbolic-ref-write","`git symbolic-ref <name> <ref>` rewrites a symbolic ref. Refuse.");return Z("bash-git")}let c=ste.get(r);if(c!==void 0)return c({subcommand:r,subArgs:o,flags:s,positional:i,config:t,heredocBodies:n});return Bi("git-unknown-subcommand",`\`git ${r}\` is not classified by tripwire. Allowing \u2014 flag if this looks like history-rewriting or data-loss territory.`)},YL=(e,t,n)=>{if(wn(t))return Z("bash-git");let r=wL(t);for(let o of e){let s=$ee(o);if(s===null)continue;let i=ite(s,n,r);if(i!==null&&i.kind!=="allow")return i}return Z("bash-git")};var QL=w(()=>{Lo();Xn();Mee=/^(?<type>feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(?<scope>\([\w./\- ]+\))?!?:\s+\S/,Nee=new Set(["-C","-c","--git-dir","--work-tree","--namespace","--super-prefix"]),Dee=new Set(["--bare","--paginate","-p","--no-pager","--no-replace-objects","--literal-pathspecs","--glob-pathspecs","--noglob-pathspecs","--icase-pathspecs","--no-optional-locks","--exec-path","--html-path","--man-path","--info-path"]),ste=new Map([["config",Hee],["add",()=>Z("bash-git")],["mv",()=>Z("bash-git")],["rm",qee],["restore",zee],["checkout",Wee],["switch",Kee],["reset",Vee],["clean",Gee],["rebase",Jee],["cherry-pick",Zee],["merge",Yee],["commit",Qee],["push",Xee],["branch",ete],["tag",tte],["stash",nte],["filter-branch",({subcommand:e})=>se("git-filter",`\`git ${e}\` rewrites entire repo history. Refuse.`)],["filter-repo",({subcommand:e})=>se("git-filter",`\`git ${e}\` rewrites entire repo history. Refuse.`)],["gc",rte],["update-ref",()=>se("git-update-ref","`git update-ref` directly mutates refs and bypasses normal git operations. Refuse.")],["remote",ote],["submodule",ZL],["worktree",ZL],["init",({subcommand:e})=>Bi(`git-${e}`,`\`git ${e}\` is allowed but unusual mid-session. Make sure this is what the user asked for.`)],["clone",({subcommand:e})=>Bi(`git-${e}`,`\`git ${e}\` is allowed but unusual mid-session. Make sure this is what the user asked for.`)]])});var ate,cte,ute=(e)=>{for(let t=0;t<e.length-1;t+=1){let n=e[t],r=e[t+1];if(n===void 0||r===void 0)continue;if(ate.has(n.head)&&cte.has(r.head))return!0}return!1},lte,XL=(e,t)=>{if(wn(t))return Z("bash-network-install");if(ute(e))return se("curl-pipe-shell","Piping `curl` / `wget` directly into a shell runs whatever the remote URL serves. Refuse \u2014 download to a file, inspect, then run if appropriate. If you genuinely need this, append ` # tripwire-allow: <reason>` (and explain to the user what you're running).");for(let n of e)for(let r of lte)if(n.head===r.head&&n.tokens[1]===r.subcommand)return zt(r.rule,r.message);return Z("bash-network-install")};var ej=w(()=>{Lo();Xn();ate=new Set(["curl","wget","wget2","aria2c","xh"]),cte=new Set(["bash","sh","zsh","fish"]),lte=[{head:"cargo",subcommand:"install",rule:"cargo-install",message:"Confirm before `cargo install <crate>`: this builds and installs arbitrary code from crates.io into ~/.cargo/bin globally."},{head:"go",subcommand:"install",rule:"go-install",message:"Confirm before `go install`: this fetches and installs arbitrary Go code globally."},{head:"gem",subcommand:"install",rule:"gem-install",message:"Confirm before `gem install`: pulls arbitrary code from rubygems.org."}]});import{lstatSync as fte,readlinkSync as dte,realpathSync as pte}from"fs";import ol from"path";var mte,tj=(e)=>{try{return pte(e)}catch{return null}},xI=(e,t=new Set)=>{if(t.has(e))return e;t.add(e);let n=tj(e);if(n!==null)return n;try{if(fte(e).isSymbolicLink()){let o=dte(e);return xI(ol.resolve(ol.dirname(e),o),t)}}catch{}let r=ol.dirname(e);if(r===e)return e;return ol.join(xI(r,t),ol.basename(e))},rp=(e,t,n)=>{let r=ol.resolve(e),o=t==="write"?xI(r):tj(r),s=[e,r];if(o!==null&&!s.includes(o))s.push(o);for(let i of s)for(let a of n)if(a.pattern.test(i))return a;return null},yI=(e)=>{let t=rp(e.file_path,"write",mte);if(t!==null)return se(t.rule,t.message);return Z("path-protect")};var mx=w(()=>{Xn();mte=[{pattern:/(?<prefix>^|\/)\.env(?<ext>\.[^/]+)?$/,rule:"env-file",message:".env files hold secrets that should never be sent to the model. Refuse to write or edit. If an example is needed, create .env.example with redacted placeholders."},{pattern:/(?<prefix>^|\/)\.dev\.vars(?<ext>\.[^/]+)?$/,rule:"dev-vars",message:".dev.vars holds Cloudflare/Wrangler secrets. Do not modify."},{pattern:/(?<prefix>^|\/)\.ssh\//,rule:"ssh-dir",message:"Never write into ~/.ssh/. Refuse."},{pattern:/(?<prefix>^|\/)(?<key>id_rsa|id_ed25519|id_ecdsa|id_dsa)(?<pub>\.pub)?$/,rule:"ssh-key",message:"SSH key file. Refuse."},{pattern:/\.(?<ext>pem|key|p12|pfx)$/i,rule:"private-key",message:"Private key file. Refuse to overwrite. If generating a new key, use a different filename and let the user review."},{pattern:/(?<prefix>^|\/)secrets?\.(?<ext>json|ya?ml|toml|env)$/i,rule:"secrets-file",message:"Secrets file. Refuse."},{pattern:/(?<prefix>^|\/)\.aws\/credentials$/,rule:"aws-credentials",message:"AWS credentials file. Refuse."},{pattern:/(?<prefix>^|\/)\.netrc$/,rule:"netrc",message:".netrc holds host credentials. Refuse."}]});var hte,SI=(e)=>{let t=rp(e,"write",hte);if(t!==null)return se(t.rule,t.message);return null},nj=(e,t)=>{if(wn(t))return Z("bash-redirect");for(let n of e){for(let r of n.redirects)if(r.op===">"||r.op===">>"){let o=SI(r.target);if(o!==null)return o}if(n.head==="tee")for(let r of n.args){let o=SI(r);if(o!==null)return o}if(n.head==="cp"||n.head==="mv"){let r=n.args.at(-1);if(r!==void 0){let o=SI(r);if(o!==null)return o}}}return Z("bash-redirect")};var rj=w(()=>{Lo();Xn();mx();hte=[{rule:"redirect-env",pattern:/(?<prefix>^|\/)\.env(?<ext>\.[^/]+)?$/,message:"Refusing to write into a .env file via shell redirect / tee / cp / mv. .env files hold secrets \u2014 never overwrite from a tool call."},{rule:"redirect-dev-vars",pattern:/(?<prefix>^|\/)\.dev\.vars(?<ext>\.[^/]+)?$/,message:"Refusing to write into .dev.vars (Cloudflare/Wrangler secrets)."},{rule:"redirect-ssh",pattern:/(?<prefix>^|\/)\.ssh\//,message:"Refusing to write into ~/.ssh/ via shell."},{rule:"redirect-key",pattern:/\.(?<ext>pem|key|p12|pfx)$/i,message:"Refusing to overwrite a private-key-shaped file via shell."},{rule:"redirect-aws-credentials",pattern:/(?<prefix>^|\/)\.aws\/credentials$/,message:"Refusing to write into ~/.aws/credentials via shell."},{rule:"redirect-netrc",pattern:/(?<prefix>^|\/)\.netrc$/,message:"Refusing to write into ~/.netrc via shell."},{rule:"redirect-block-device",pattern:/^\/dev\/(?<type>sd|disk|nvme|rdisk)/i,message:"Redirecting into a raw block device wipes the disk. Refuse."}]});var gte=(e,t)=>{let n=!1,r=[];for(let i of e.tokens.slice(1)){if(!n&&i==="--"){n=!0;continue}if(!n&&i.startsWith("-")&&i!=="-")continue;r.push(i)}let o=t.relative??[],s=t.absolute??[];return r.filter((i)=>!iI(i,o,s))},xte=(e,t)=>{if(!e.tokens.includes("-delete"))return null;let n=[];for(let i of e.tokens.slice(1)){if(i.startsWith("-"))break;n.push(i)}let r=n.length===0?["."]:n,o=t.relative??[],s=t.absolute??[];return r.filter((i)=>!iI(i,o,s))},oj=(e,t,n)=>{if(wn(t))return Z("bash-scoped-rm");let r=[];for(let a of e){if(a.head==="rm"){let c=gte(a,n);if(c.length>0)r.push({kind:"rm",targets:c});continue}if(a.head==="find"){let c=xte(a,n);if(c!==null&&c.length>0)r.push({kind:"find -delete",targets:c})}}if(r.length===0)return Z("bash-scoped-rm");let o=n.relative??[],s=n.absolute??[],i=r.map((a)=>` \u2022 ${a.kind} on: ${a.targets.map((c)=>JSON.stringify(c)).join(", ")}`).join(`
|
|
51
|
-
`);return se("destructive-outside-safe-paths",`Destructive deletion outside known-safe scopes is blocked. Use a recoverable deletion tool or limit the target to an ephemeral build, cache, state, or temporary directory:
|
|
52
|
-
${TL(o,s)}
|
|
27
|
+
`,m);else l("");r=!1}while(y!==-1||b!==-1)if(y===-1||b!==-1&&b<y)l(d.substring(m,b)),m=b+1,b=d.indexOf(`
|
|
28
|
+
`,m);else if(d.length===y+1)r=!0,y=-1;else l(d.substring(m,y)),m=y+(b===y+1?2:1),y=d.indexOf("\r",m),b=d.indexOf(`
|
|
29
|
+
`,m);n=n+d.substring(m,d.length-(r?1:0))}}return hr(u)?u:null}let i=He(()=>{if(o._tag==="Some")return Vt(o.value);return hg(e,{onSuccess:a,onFailure:dl,onDone:(c)=>{if(o=F(c),n.length>0||r){let u=n;return n="",r=!1,A([u])}return Vt(c)}})});function a(c){let u=s(c);return u!==null?A(u):i}return i})),DF,Bg=(e)=>jn((t,n)=>{let r;return A(He(()=>{if(r)return r;return e.pipe(_d(n),se((o)=>Uo(o)(t,n)),se((o)=>r=o))}))}),nQ=(e,t,n)=>He(()=>{let r=sl(),o=Uo(e)(Vt(),r);return zr(se(o,t),n?n:A).pipe(ai((s)=>qr(r,s)))}),Tk,_k=(e,t)=>Uo(e)(Vt(),t);var sp=v(()=>{nr();In();Re();ne();Me();ct();ge();kc();op();Pd();X5={[IF]:{_Env:L,_InErr:L,_InElem:L,_OutErr:L,_OutElem:L},pipe(){return fe(this,arguments)}},PF=Lg(A(Vt())),RF=p(2,(e,t)=>AF(e,(n)=>we(()=>{let r=0;return ae(n,(o)=>t(o,r++))}))),Ak=p(2,(e,t)=>tQ(e,(n)=>A(t(n)))),tQ=p(2,(e,t)=>AF(e,(n)=>A(zr(n,(r)=>se(t(r),Vt))))),FF=p((e)=>vF(e[0])&&vF(e[1]),(e,t,n)=>TF(q(function*(r,o,s){let i=n?.haltStrategy??"both",a=yield*mF(0);yield*Od(s,Ck(a));let c=0;function u(f,d){if(c++,!$d(d))return np(a,d);switch(i){case"both":return c===2?np(a,d):Pe;case"left":case"right":return f===i?np(a,d):Pe;case"either":return np(a,d)}}let l=(f,d,m)=>Uo(d)(r,m).pipe(se((y)=>y.pipe(se((b)=>ep(a,b)),ds)),hl((y)=>Vr(qr(m,qw(y)),u(f,y))),xl(s));return yield*l("left",e,ua(s)),yield*l("right",t,ua(s)),mi(a)}))),DF=p(2,(e,t)=>jn((n,r)=>se(Uo(e)(n,r),(o)=>Uo(t)(o,r)))),Tk=p(3,(e,t,n)=>He(()=>{let r=t();return nQ(e,(o)=>ll({while:Fr,body:()=>o,step:(s)=>{r=n(r,s)}}),()=>A(r))}))});var rQ="~effect/Stream",oQ,sQ,NF=(e)=>{let t=Object.create(sQ);return t.channel=e,t};var $F=v(()=>{ne();ct();oQ={_R:L,_E:L,_A:L},sQ={[rQ]:oQ,pipe(){return fe(this,arguments)}}});var UF="~effect/Sink",LF,aQ,cQ,ip=(e)=>D(e,UF),Ok=(e)=>Pk((t,n)=>Uo(e)(t,n).pipe(se(ds({disableYield:!0})),zr(A))),Pk=(e)=>{let t=Object.create(cQ);return t.transform=e,t},uQ=(e)=>jn((t,n)=>A(se(e.transform(t,n),Vt))),ap,BF=(e)=>lQ(vc((t)=>e(t),{discard:!0})),lQ=(e)=>Pk((t)=>t.pipe(se(e),ds({disableYield:!0}),zr(()=>LF))),HF=(e)=>Ok(Bg(ae(e,uQ)));var Wg=v(()=>{In();sp();Re();ne();ct();ge();kc();LF=A([void 0]),aQ={_A:L,_In:L,_L:L,_E:L,_R:L},cQ={[UF]:aQ,pipe(){return fe(this,arguments)}},ap=Pk((e)=>zr(ds(e,{disableYield:!0}),()=>LF))});var fQ="~effect/RcRef",Fk,dQ,pQ,WF,jF=(e)=>Wd((t)=>{let n=t.context,r=tr(n,Td),o=new WF(e.acquire,n,r,e.idleTimeToLive?Nr(e.idleTimeToLive):void 0);return Kr(ig(r,()=>{let s=o.state._tag==="Acquired"?qr(o.state.scope,Wr):Pe;return o.state=dQ,s}),o)}),mQ=(e)=>Gd(function t(n){switch(e.state._tag){case"Closed":return gl;case"Acquired":return e.state.refCount++,e.state.fiber?Kr(nF(e.state.fiber),e.state):A(e.state);case"Empty":{let r=sl();return e.semaphore.withPermit(He(()=>{if(e.state._tag!=="Empty")return t(n);return n(ii(e.acquire,Cn(e.context,Td,r))).pipe(ae((o)=>{let s={_tag:"Acquired",value:o,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=s,s}),ai((o)=>ol(o)?qr(r,o):Pe))}))}}}),qF;var zF=v(()=>{rt();Yi();Re();jr();oF();ne();ct();Pd();CF();Fk={_tag:"Empty"},dQ={_tag:"Closed"},pQ={_A:L,_E:L};WF=class WF{[fQ]=pQ;pipe(){return fe(this,arguments)}state=Fk;semaphore=wF(1);acquire;context;scope;idleTimeToLive;constructor(e,t,n,r){this.acquire=e,this.context=t,this.scope=n,this.idleTimeToLive=r}};qF=q(function*(e){let t=e,n=yield*mQ(t),r=yield*Vd,o=t.idleTimeToLive!==void 0&&BT(t.idleTimeToLive);return yield*ig(r,()=>{if(n.refCount--,n.refCount>0)return Pe;if(t.idleTimeToLive===void 0)return t.state=Fk,qr(n.scope,Wr);else if(n.invalidated)return qr(n.scope,Wr);else if(!o)return Pe;return n.fiber=wg(t.idleTimeToLive).pipe(se(()=>{if(t.state._tag==="Acquired"&&t.state.refCount===0)return t.state=Fk,qr(n.scope,Wr);return Pe}),ml(we(()=>{n.fiber=void 0})),Jd(t.context),rF(t.scope)),Pe}),n.value})});var VF,Mk;var KF=v(()=>{zF();VF=jF,Mk=qF});var xQ="~effect/Stream",Oc=(e)=>D(e,xQ),Lo,GF=(e)=>Lo(Lg(e)),yQ=(e,t)=>Lo(jn((n,r)=>se(_k(e.channel,r),(o)=>t(o,r)))),Dk=(e)=>e.channel,JF=(e,t)=>Lo(_F(e,t)),kl,QF=(e)=>Lo(OF(()=>e().channel)),ga=(e)=>Lo(Bg(ae(e,Dk))),SQ,ZF,jg,YF,XF=(e)=>e.channel.pipe(DF(MF()),Lo),Nk,eM=(e)=>Tk(e.channel,()=>[],(t,n)=>{for(let r=0;r<n.length;r++)t.push(n[r]);return t}),tM=(e)=>Tk(e.channel,()=>"",(t,n)=>t+n.join(""));var Cl=v(()=>{nr();In();sp();Re();jr();ne();$F();ge();Lo=NF,kl=Lo(PF),SQ=p(2,(e,t)=>QF(()=>{let n=0;return Lo(RF(e.channel,sn((r)=>t(r,n++))))})),ZF=p((e)=>Oc(e[0])&&Oc(e[1]),(e,t,n)=>Lo(FF(Dk(e),Dk(t),n))),jg=p(2,(e,t)=>yQ(e,(n,r)=>we(()=>{let o,s,i=He(()=>{if(s!==void 0){let c=s;return s=void 0,A(c)}return n}).pipe(lo((c)=>(o=uo(c),Vt()))),a=ae(He(()=>t.transform(i,r)),([c,u])=>(s=u,uc(c)));return He(()=>o?o:a)}))),YF=p((e)=>Oc(e[0]),(e,t)=>QF(()=>{let n=new TextDecoder(t?.encoding);return SQ(e,(r)=>n.decode(r,{stream:!0}))})),Nk=p(2,(e,t)=>gk((n)=>_k(e.channel,n).pipe(se((r)=>t.transform(r,n)),ae(([r])=>r))))});var nM="~effect/platform/FileSystem",hi=(e)=>typeof e==="bigint"?e:BigInt(e),up,gme,xa,rM=(e)=>xa.of({...e,[nM]:nM,exists:(t)=>To(e.access(t),Kr(!0),si("PlatformError",(n)=>n.reason._tag==="NotFound"?A(!1):R(n))),readFileString:(t,n)=>se(e.readFile(t),(r)=>Xt({try:()=>new TextDecoder(n).decode(r),catch:(o)=>li({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:o})})),stream:q(function*(t,n){let r=yield*e.open(t,{flag:"r"});if(n?.offset)yield*r.seek(n.offset,"start");let o=n?.bytesToRead!==void 0?hi(n.bytesToRead):void 0,s=BigInt(0),i=hi(n?.chunkSize??65536),a=r.readAlloc(i);return GF(A(se(He(()=>{if(o!==void 0&&o<=s)return Vt();return o!==void 0&&o-s<i?r.readAlloc(o-s):a}),ut({onNone:()=>Vt(),onSome:(c)=>(s+=BigInt(c.length),A(uc(c)))}))))},ga),sink:(t,n)=>To(e.open(t,{flag:"w",...n}),ae((r)=>BF((o)=>r.writeAll(o))),HF),writeFileString:(t,n,r)=>se(Xt({try:()=>new TextEncoder().encode(n),catch:(o)=>li({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:o})}),(o)=>e.writeFile(t,o,r))}),qg="~effect/platform/FileSystem/File",$k;var zg=v(()=>{nr();In();rt();Re();ne();Me();ms();Wg();Cl();up=BigInt(1024),gme=up*up*up*up*up,xa=Ye("effect/platform/FileSystem");$k=class $k extends Ye()("effect/platform/FileSystem/WatchBackend"){}});function oM(e,t){let n="",r=0,o=-1,s=0,i;for(let a=0;a<=e.length;++a){if(a<e.length)i=e.charCodeAt(a);else if(i===47)break;else i=47;if(i===47){if(o===a-1||s===1);else if(o!==a-1&&s===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let c=n.lastIndexOf("/");if(c!==n.length-1){if(c===-1)n="",r=0;else n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/");o=a,s=0;continue}}else if(n.length===2||n.length===1){n="",r=0,o=a,s=0;continue}}if(t){if(n.length>0)n+="/..";else n="..";r=2}}else{if(n.length>0)n+="/"+e.slice(o+1,a);else n=e.slice(o+1,a);r=a-o-1}o=a,s=0}else if(i===46&&s!==-1)++s;else s=-1}return n}function EQ(e,t){let n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");if(!n)return r;if(n===t.root)return n+r;return n+e+r}function bQ(e){if(e.protocol!=="file:")return R(new ui({module:"Path",method:"fromFileUrl",description:"URL must be of scheme file"}));else if(e.hostname!=="")return R(new ui({module:"Path",method:"fromFileUrl",description:"Invalid file URL host"}));let t=e.pathname;for(let n=0;n<t.length;n++)if(t[n]==="%"){let r=t.codePointAt(n+2)|32;if(t[n+1]==="2"&&r===102)return R(new ui({module:"Path",method:"fromFileUrl",description:"must not include encoded / characters"}))}return A(decodeURIComponent(t))}function kQ(e){let t=new URL("file://"),n=sM(e);if(e.charCodeAt(e.length-1)===wQ&&n[n.length-1]!=="/")n+="/";return t.pathname=_Q(n),A(t)}function _Q(e){if(e.includes("%"))e=e.replace(CQ,"%25");if(e.includes("\\"))e=e.replace(vQ,"%5C");if(e.includes(`
|
|
30
|
+
`))e=e.replace(IQ,"%0A");if(e.includes("\r"))e=e.replace(AQ,"%0D");if(e.includes("\t"))e=e.replace(TQ,"%09");return e}var gi="~effect/platform/Path",hs,sM=function(){let t="",n=!1,r=void 0;for(let o=arguments.length-1;o>=-1&&!n;o--){let s;if(o>=0)s=arguments[o];else{let i=globalThis.process;if(r===void 0&&"process"in globalThis&&typeof i==="object"&&i!==null&&typeof i.cwd==="function")r=i.cwd();s=r}if(s.length===0)continue;t=s+"/"+t,n=s.charCodeAt(0)===47}if(t=oM(t,!n),n)if(t.length>0)return"/"+t;else return"/";else if(t.length>0)return t;else return"."},wQ=47,CQ,vQ,IQ,AQ,TQ,Lk;var Vg=v(()=>{rt();Re();ne();ms();hs=Ye("effect/Path");CQ=/%/g,vQ=/\\/g,IQ=/\n/g,AQ=/\r/g,TQ=/\t/g;Lk=hs.of({[gi]:gi,resolve:sM,normalize(e){if(e.length===0)return".";let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;if(e=oM(e,!t),e.length===0&&!t)e=".";if(e.length>0&&n)e+="/";if(t)return"/"+e;return e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return".";let e;for(let t=0;t<arguments.length;++t){let n=arguments[t];if(n.length>0)if(e===void 0)e=n;else e+="/"+n}if(e===void 0)return".";return Lk.normalize(e)},relative(e,t){if(e===t)return"";if(e=Lk.resolve(e),t=Lk.resolve(t),e===t)return"";let n=1;for(;n<e.length;++n)if(e.charCodeAt(n)!==47)break;let r=e.length,o=r-n,s=1;for(;s<t.length;++s)if(t.charCodeAt(s)!==47)break;let a=t.length-s,c=o<a?o:a,u=-1,l=0;for(;l<=c;++l){if(l===c){if(a>c){if(t.charCodeAt(s+l)===47)return t.slice(s+l+1);else if(l===0)return t.slice(s+l)}else if(o>c){if(e.charCodeAt(n+l)===47)u=l;else if(l===0)u=0}break}let d=e.charCodeAt(n+l),m=t.charCodeAt(s+l);if(d!==m)break;else if(d===47)u=l}let f="";for(l=n+u+1;l<=r;++l)if(l===r||e.charCodeAt(l)===47)if(f.length===0)f+="..";else f+="/..";if(f.length>0)return f+t.slice(s+u);else{if(s+=u,t.charCodeAt(s)===47)++s;return t.slice(s)}},dirname(e){if(e.length===0)return".";let t=e.charCodeAt(0),n=t===47,r=-1,o=!0;for(let s=e.length-1;s>=1;--s)if(t=e.charCodeAt(s),t===47){if(!o){r=s;break}}else o=!1;if(r===-1)return n?"/":".";if(n&&r===1)return"//";return e.slice(0,r)},basename(e,t){let n=0,r=-1,o=!0,s;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";let i=t.length-1,a=-1;for(s=e.length-1;s>=0;--s){let c=e.charCodeAt(s);if(c===47){if(!o){n=s+1;break}}else{if(a===-1)o=!1,a=s+1;if(i>=0)if(c===t.charCodeAt(i)){if(--i===-1)r=s}else i=-1,r=a}}if(n===r)r=a;else if(r===-1)r=e.length;return e.slice(n,r)}else{for(s=e.length-1;s>=0;--s)if(e.charCodeAt(s)===47){if(!o){n=s+1;break}}else if(r===-1)o=!1,r=s+1;if(r===-1)return"";return e.slice(n,r)}},extname(e){let t=-1,n=0,r=-1,o=!0,s=0;for(let i=e.length-1;i>=0;--i){let a=e.charCodeAt(i);if(a===47){if(!o){n=i+1;break}continue}if(r===-1)o=!1,r=i+1;if(a===46){if(t===-1)t=i;else if(s!==1)s=1}else if(t!==-1)s=-1}if(t===-1||r===-1||s===0||s===1&&t===r-1&&t===n+1)return"";return e.slice(t,r)},format:function(t){if(t===null||typeof t!=="object")throw TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return EQ("/",t)},parse(e){let t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;let n=e.charCodeAt(0),r=n===47,o;if(r)t.root="/",o=1;else o=0;let s=-1,i=0,a=-1,c=!0,u=e.length-1,l=0;for(;u>=o;--u){if(n=e.charCodeAt(u),n===47){if(!c){i=u+1;break}continue}if(a===-1)c=!1,a=u+1;if(n===46){if(s===-1)s=u;else if(l!==1)l=1}else if(s!==-1)l=-1}if(s===-1||a===-1||l===0||l===1&&s===a-1&&s===i+1){if(a!==-1)if(i===0&&r)t.base=t.name=e.slice(1,a);else t.base=t.name=e.slice(i,a)}else{if(i===0&&r)t.name=e.slice(1,s),t.base=e.slice(1,a);else t.name=e.slice(i,s),t.base=e.slice(i,a);t.ext=e.slice(s,a)}if(i>0)t.dir=e.slice(0,i-1);else if(r)t.dir="/";return t},sep:"/",fromFileUrl:bQ,toFileUrl:kQ,toNamespacedPath:L})});function gs(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function lp(e){return(t)=>gs(t)?.[e]}var Sr="~structural",Pc="~identifier",fp="~sentinels",Kg="~constructor",aM,vl,Bk,Hk,cM,dp,uM;var ya=v(()=>{ne();aM=["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],vl=lp("identifier"),Bk=lp(Pc),Hk=lp("title"),cM=lp("brands"),dp=bn((e)=>{let t=gs(e)?.identifier;if(typeof t==="string")return t;return e.getExpected(dp)}),uM=new Set([fp,Sr,"representation","arbitrary","brands","toJsonSchema","toCode","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso"])});var De,ho,Bo,en,Gg=(e)=>e===De?P():F(e),Wk=(e)=>e._tag==="None"?Bo:ho(e.value);var Jg=v(()=>{jr();Me();pt();De=Symbol(),ho=co,Bo=ho(De),en=ho(De)});function zk(e){return D(e,mp)&&e[mp]===mp}function OQ(e){return Object.hasOwn(e,"input")}function Er(e,t,n,r,o){return new Ft(e,[new Jt([t],n)],r,o)}function qk(e,t,n){if(zk(e))return e;if(typeof e==="string")return new Ie({message:e},t,n);let r=typeof e.issue==="string"?new Ie({message:e.issue},t,n):e.issue;return new Jt(e.path,r)}function lM(e,t,n){if(e===void 0)return;if(typeof e==="boolean")return e?void 0:new Ie(void 0,t,n);return qk(e,t,n)}function fM(e,t,n,r){if(Array.isArray(t)){if(!hr(t))return;return t.length===1?qk(t[0],n,r):new Ft(e,sn(t,(o)=>qk(o,n,r)),n,r)}return lM(t,n,r)}function mM(e){return(t)=>({issues:Il(t,[],e?.leafHook??dM,e?.checkHook??pM)})}function Qg(e){return OQ(e)?j(e.input):void 0}function Jk(e){let t=e.annotations?.expected;return typeof t==="string"?t:void 0}function Sa(e,t){let n=Qg(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function Il(e,t,n,r){switch(e._tag){case"Filter":{let o=r(e);if(o!==void 0)return[{path:t,message:o}];if(e.issue._tag!=="InvalidValue")return Il(e.issue,t,n,r);let s=Jk(e.issue);return[{path:t,message:s===void 0?Sa(Qk(e.filter),e):Sa(s,e.issue)}]}case"Encoding":return Il(e.issue,t,n,r);case"Pointer":return Il(e.issue,[...t,...e.path],n,r);case"Composite":return e.issues.flatMap((o)=>Il(o,t,n,r));case"AnyOf":{if(e.issues.length===0)return[{path:t,message:Al(e)??Sa(dp(e.ast),e)}];return e.issues.flatMap((o)=>Il(o,t,n,r))}default:return[{path:t,message:n(e)}]}}function Qk(e){let t=e.annotations?.expected;if(typeof t==="string")return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map((n)=>Qk(n)).join(" & ")}}function PQ(){return(e)=>pp(e,"")}function pp(e,t){let n;switch(e._tag){case"Filter":{let r=pM(e);if(r!==void 0)n=r;else{if(e.issue._tag!=="InvalidValue")return pp(e.issue,t);let o=Jk(e.issue);n=o===void 0?Sa(Qk(e.filter),e):Sa(o,e.issue)}break}case"Encoding":return pp(e.issue,t);case"Pointer":return pp(e.issue,t+Qm(e.path));case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map((r)=>pp(r,t)).join(`
|
|
31
|
+
`);n=Al(e)??Sa(dp(e.ast),e);break}default:n=dM(e);break}return t?`${n}
|
|
32
|
+
at ${t}`:n}function Al(e){if(e._tag==="Pointer")return;if(e._tag==="Encoding")return Al(e.issue);let n=(e._tag==="Filter"?e.filter.annotations:("annotations"in e)?e.annotations:e.ast.annotations)?.[e._tag==="MissingKey"?"messageMissingKey":e._tag==="UnexpectedKey"?"messageUnexpectedKey":"message"];if(typeof n==="string")return n}var mp="~effect/SchemaIssue/Issue",go,Vk,Kk,Jt,Fc,Zg,Ft,bt,Ie,Tl,hp,Gk,dM=(e)=>{let t=Al(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return Sa(dp(e.ast),e);case"InvalidValue":{let n=Jk(e);if(n!==void 0)return Sa(n,e);let r=Qg(e);return r===void 0?"Expected a valid value":`Invalid data ${r}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let n=Qg(e);return n===void 0?"Expected no excess property":`Unexpected key with value ${n}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let n=Qg(e);return n===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${n}`}}},pM=(e)=>Al(e.issue)??Al(e),hM;var Ea=v(()=>{nr();Zn();ya();Jg();ge();go=class go{[mp]=mp;constructor(e,t){if(t?.reportInput===!0&&e!==De)this.input=e}};Vk=class Vk extends go{_tag="Filter";filter;issue;constructor(e,t,n,r){super(n,r);this.filter=e,this.issue=t}};Kk=class Kk extends go{_tag="Encoding";ast;issue;constructor(e,t,n,r){super(n,r);this.ast=e,this.issue=t}};Jt=class Jt extends go{_tag="Pointer";path;issue;constructor(e,t){super();this.path=e,this.issue=t}};Fc=class Fc extends go{_tag="MissingKey";annotations;constructor(e){super();this.annotations=e}};Zg=class Zg extends go{_tag="UnexpectedKey";ast;constructor(e,t,n){super(t,n);this.ast=e}};Ft=class Ft extends go{_tag="Composite";ast;issues;constructor(e,t,n,r){super(n,r);this.ast=e,this.issues=t}};bt=class bt extends go{_tag="InvalidType";ast;constructor(e,t,n){super(t,n);this.ast=e}};Ie=class Ie extends go{_tag="InvalidValue";annotations;constructor(e,t,n){super(t,n);this.annotations=e}};Tl=class Tl extends go{_tag="Forbidden";annotations;constructor(e,t,n){super(t,n);this.annotations=e}};hp=class hp extends go{_tag="AnyOf";ast;issues;constructor(e,t,n,r){super(n,r);this.ast=e,this.issues=t}};Gk=class Gk extends go{_tag="OneOf";ast;successes;constructor(e,t,n,r){super(n,r);this.ast=e,this.successes=t}};hM=PQ()});function gp(e){let t;for(let n of e.reasons){if(!bd(n)||!zk(n.error))return;t??=n.error}return t}function xi(e,t){let n=gp(e);if(n===void 0)throw Error(t,{cause:e});return n}var Zk=v(()=>{In();Ea()});var Yk,xM,yM,SM,EM,bM,Xk,eC,wM,kM,Yg,CM,Xg,tC,xp,vM,IM,ba,ex,AM,TM,tx;var nx=v(()=>{KR();Yk=al,xM=wc,yM=DR,SM=NR,EM=$R,bM=Rw,Xk=UR,eC=LR,wM=bc,kM=Mw,Yg=HR,CM=WR,Xg=jR,tC=Dw,xp=Dd,vM=Nw,IM=$w,ba=qR,ex=Nd,AM=Bw,TM=VR,tx=Ww});function RQ(e){return new yi((t,n)=>R(e(t,n)))}function rC(e){return RQ((t,n)=>{let r={message:e(t)};return Ce(t)?new Tl(r,t.value,n):new Tl(r)})}function _M(e){return e.run===OM.run}function Ho(){return OM}function oC(e){return new yi((t,n)=>he(t)?Ic:e(t.value,n))}function Ae(e){return rx(kn(e))}function br(e){return oC((t,n)=>e(t,n).pipe(ci(F)))}function rx(e){return new yi((t)=>A(e(t)))}function sC(){return new yi(()=>Ic)}function yp(e){return new yi((t)=>{let n=sc(t,Ve);return Ce(n)?A(n):ci(e,F)})}function Dc(){return Ae(globalThis.String)}function ox(){return Ae(globalThis.Number)}function PM(){return Ae(globalThis.BigInt)}function iC(){return Ae((e)=>new globalThis.Date(e))}function RM(){return Ae(e1)}function FM(e){return oC((t,n)=>Xt({try:()=>F(JSON.parse(t,e?.reviver)),catch:()=>new Ie({expected:"a valid JSON string"},t,n)}))}function MM(e){return oC((t,n)=>Xt({try:()=>{let r=JSON.stringify(t,e?.replacer,e?.space);if(r===void 0)throw TypeError("Value cannot be represented as JSON");return F(r)},catch:()=>new Ie({expected:"a JSON-serializable value"},t,n)}))}function aC(){return Ae(bh)}function sx(){return Ae(o_)}function ix(){return Ae(i_)}function DM(){return br((e,t)=>Tc(ak(Gu(e)),()=>new Ie({expected:"a valid Base64 string"},e,t)))}function NM(){return br((e,t)=>mr(r_(e),{onFailure:()=>R(new Ie({expected:"a valid Base64 string"},e,t)),onSuccess:A}))}function $M(){return br((e,t)=>mr(KE(e),{onFailure:()=>R(new Ie({expected:"a valid Base64Url string"},e,t)),onSuccess:A}))}function UM(){return br((e,t)=>mr(s_(e),{onFailure:()=>R(new Ie({expected:"a valid Base64Url string"},e,t)),onSuccess:A}))}function LM(){return br((e,t)=>mr(JE(e),{onFailure:()=>R(new Ie({expected:"a valid hexadecimal string"},e,t)),onSuccess:A}))}function BM(){return br((e,t)=>mr(a_(e),{onFailure:()=>R(new Ie({expected:"a valid hexadecimal string"},e,t)),onSuccess:A}))}function HM(){return Ae(encodeURIComponent)}function WM(){return br((e,t)=>{try{return A(globalThis.decodeURIComponent(e))}catch{return R(new Ie({expected:"a valid URI component"},e,t))}})}function cC(){return br((e,t)=>ut(Yg(e),{onNone:()=>R(new Ie({message:"Invalid DateTime input"},e,t)),onSome:(n)=>A(Xg(n))}))}function jM(){return Ae((e)=>KM(Array.from(e.entries())))}function qM(){return Ae((e)=>{let t=new FormData;if(typeof e==="object"&&e!==null)FQ(e).forEach(([r,o])=>{t.append(r,o)});return t})}function zM(){return Ae((e)=>KM(Array.from(e.entries())))}function VM(){return Ae((e)=>{if(typeof e==="object"&&e!==null)return new URLSearchParams(MQ(e));return new URLSearchParams})}function NQ(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),n=t.split("."),r=t.startsWith(".")?1:0;return n.slice(r).map((o)=>DQ.test(o)?globalThis.Number(o):o)}function KM(e){let t={},n=new WeakSet;function r(o,s,i){let a=Object.hasOwn(o,s)?o[s]:void 0;if(n.has(a)&&Array.isArray(a)===i)return a;let c=i?[]:{};return n.add(c),H(o,s,c),c}return e.forEach(([o,s])=>{let i=NQ(o),a=t;i.forEach((c,u)=>{let l=u===i.length-1;if(Array.isArray(a)&&c==="")if(l)a.push(s);else{let f=i[u+1],d=typeof f==="number"||f==="",m=a.length;a=r(a,m,d)}else if(l){let f=Object.hasOwn(a,c);if(f&&Array.isArray(a[c]))a[c].push(s);else if(f)H(a,c,[a[c],s]);else H(a,c,s)}else{let f=i[u+1];a=r(a,c,typeof f==="number"||f==="")}})}),t}function GM(e){return(t)=>{let n=[];function r(o,s){if(e(s))n.push([o,s]);else if(Array.isArray(s))if(s.every(e))s.forEach((a)=>{n.push([o,a])});else s.forEach((a,c)=>{r(`${o}[${c}]`,a)});else if(typeof s==="object"&&s!==null)for(let[i,a]of Object.entries(s))r(`${o}[${i}]`,a)}for(let[o,s]of Object.entries(t))r(o,s);return n}}var yi,OM,FQ,MQ,DQ;var ax=v(()=>{nx();Re();wh();Me();ct();ge();Bn();Ea();o1();yi=class yi extends za{run;constructor(e){super();this.run=e}map(e){return new yi((t,n)=>this.run(t,n).pipe(ci(kn(e))))}compose(e){if(_M(this))return e;if(_M(e))return this;return new yi((t,n)=>this.run(t,n).pipe(An((r)=>e.run(r,n))))}};OM=new yi(A);FQ=GM((e)=>typeof e==="string"||typeof Blob<"u"&&e instanceof Blob);MQ=GM(_o);DQ=/^\d+$/});var JM,lC="~effect/BigDecimal",$Q,ux=(e)=>D(e,lC),wr=(e,t)=>{let n=Object.create($Q);return n.value=e,n.scale=t,n},ZM=(e,t)=>{if(e!==Jr&&e%cx===Jr)throw RangeError("Value must be normalized");let n=wr(e,t);return n.normalized=n,n},Jr,UQ,LQ,cx,YM,fC=(e)=>{if(e.normalized===void 0)if(e.value===Jr)e.normalized=YM;else{let t=`${e.value}`,n=0;for(let s=t.length-1;s>=0;s--)if(t[s]==="0")n++;else break;if(n===0)e.normalized=e;let r=BigInt(t.substring(0,t.length-n)),o=e.scale-n;e.normalized=ZM(r,o)}return e.normalized},wa,XM,Si,BQ,HQ,QM=(e)=>e.value===Jr?0:e.value<Jr?-1:1,WQ=(e)=>e.value<Jr?wr(-e.value,e.scale):e,dC,jQ,eD=(e)=>{if(e==="")return F(YM);let t,n,r=e.search(/[eE]/);if(r!==-1){let c=e.slice(r+1);if(t=e.slice(0,r),n=Number(c),t===""||!Number.isSafeInteger(n)||!JM.test(c))return P()}else t=e,n=0;let o,s,i=t.search(/\./);if(i!==-1){let c=t.slice(0,i),u=t.slice(i+1);o=`${c}${u}`,s=u.length}else o=t,s=0;if(!JM.test(o))return P();let a=s-n;if(!Number.isSafeInteger(a))return P();return F(wr(BigInt(o),a))},xs=(e)=>{let t=fC(e);if(Math.abs(t.scale)>=16)return qQ(t);let n=t.value<Jr,r=n?`${t.value}`.substring(1):`${t.value}`,o,s;if(t.scale>=r.length)o="0",s="0".repeat(t.scale-r.length)+r;else{let a=r.length-t.scale;if(a>r.length){let c=a-r.length;o=`${r}${"0".repeat(c)}`,s=""}else s=r.slice(a),o=r.slice(0,a)}let i=s===""?o:`${o}.${s}`;return n?`-${i}`:i},qQ=(e)=>{if(zQ(e))return"0e+0";let t=fC(e),n=`${WQ(t).value}`,r=n.slice(0,1),o=n.slice(1),s=`${tD(t)?"-":""}${r}`;if(o!=="")s+=`.${o}`;let i=o.length-t.scale;return`${s}e${i>=0?"+":""}${i}`},zQ=(e)=>e.value===Jr,tD=(e)=>e.value<Jr,VQ=(e)=>e.value>Jr,pC=(e)=>ux(e[0]),nD,mC,hC;var gC=v(()=>{Pt();Ws();ne();wn();pr();Me();rc();ct();ge();JM=/^[+-]?\d+$/,$Q={[lC]:lC,[_e](){let e=fC(this);return Ot(ie(e.value),dr(e.scale))},[Oe](e){return ux(e)&&jQ(this,e)},toString(){return`BigDecimal(${xs(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[zt](){return this.toJSON()},pipe(){return fe(this,arguments)}},Jr=BigInt(0),UQ=BigInt(1),LQ=BigInt(-1),cx=BigInt(10),YM=ZM(Jr,0),wa=p(2,(e,t)=>{if(t>e.scale)return wr(e.value*cx**BigInt(t-e.scale),t);if(t<e.scale)return wr(e.value/cx**BigInt(e.scale-t),t);return e}),XM=p(2,(e,t)=>{if(t.value===Jr)return e;if(e.value===Jr)return t;if(e.scale>t.scale)return wr(wa(t,e.scale).value+e.value,e.scale);if(e.scale<t.scale)return wr(wa(e,t.scale).value+t.value,t.scale);return wr(e.value+t.value,e.scale)}),Si=qs((e,t)=>{let n=Mr(QM(e),QM(t));if(n!==0)return n;if(e.scale>t.scale)return so(e.value,wa(t,e.scale).value);if(e.scale<t.scale)return so(wa(e,t.scale).value,t.value);return so(e.value,t.value)}),BQ=Lu(Si),HQ=Vi(Si),dC=dn((e,t)=>{if(e.scale>t.scale)return wa(t,e.scale).value===e.value;if(e.scale<t.scale)return wa(e,t.scale).value===t.value;return e.value===t.value}),jQ=p(2,(e,t)=>dC(e,t)),nD=p(pC,(e,t=0)=>{if(e.scale<=t)return e;return wr(e.value/cx**BigInt(e.scale-t),t)}),mC=p(pC,(e,t=0)=>{let n=nD(e,t);if(VQ(e)&&BQ(n,e))return XM(n,wr(UQ,t));return n}),hC=p(pC,(e,t=0)=>{let n=nD(e,t);if(tD(e)&&HQ(n,e))return XM(n,wr(LQ,t));return n})});class Ep{_tag="Middleware";decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new Ep(this.encode,this.decode)}}function KQ(e){return D(e,Sp)&&e[Sp]===Sp}function Qr(e){return new Ne(br(e.decode),br(e.encode))}function ht(e){return new Ne(Ae(e.decode),Ae(e.encode))}function fx(e){return new Ne(rx(e.decode),rx(e.encode))}function oD(){return new Ne(RM(),Ho())}function _l(){return GQ}function mD(){return ht({decode:yE,encode:uh})}function hD(){return ht({decode:zs,encode:Un})}function gD(e){return ht({decode:er,encode:e?.onNoneEncoding===null?uh:Un})}function xD(){return fx({decode:F,encode:oc})}function yD(){return fx({decode:(e)=>e.pipe(sc(Ve),F),encode:oc})}function kD(e){return new Ne(FM(e??{}),MM(e))}var Sp="~effect/SchemaTransformation/Transformation",Ne,lx=(e)=>{if(KQ(e))return e;return new Ne(e.decode,e.encode)},GQ,Ol,dx,xC,sD,iD,aD,cD,JQ=(e)=>Dn(e)&&typeof e.message==="string",uD=(e)=>{let n=Object.hasOwn(e,"cause")?Error(e.message,{cause:fD(e.cause)}):Error(e.message);if(typeof e.name==="string"&&e.name!=="Error")n.name=e.name;if(typeof e.stack==="string")n.stack=e.stack;return n},QQ=(e)=>{try{let t=Ga(e);return t===void 0?j(e):JSON.parse(t)}catch{return j(e)}},ZQ=(e,t,n)=>{let r={name:e.name,message:typeof e.message==="string"?e.message:""};if(t?.includeStack&&typeof e.stack==="string")r.stack=e.stack;if(!t?.excludeCause&&e.cause!==void 0)r.cause=n(e.cause);return r},lD=(e)=>{let t=new WeakSet,n=(r)=>{if(NA(r)){if(t.has(r))return"[Circular]";t.add(r);let o=ZQ(r,e,n);return t.delete(r),o}return QQ(r)};return n},fD=(e)=>JQ(e)?uD(e):e,dD=(e)=>ht({decode:uD,encode:(t)=>lD(e)(t)}),pD=(e)=>ht({decode:fD,encode:lD(e)}),yC,SC,EC,SD,ED,bD,wD,CD,vD,ID,bC,wC,kC,CC;var px=v(()=>{gC();nx();Yi();Re();Zn();Me();ge();ax();Ea();Ne=class Ne{[Sp]=Sp;_tag="Transformation";decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new Ne(this.encode,this.decode)}compose(e){return new Ne(this.decode.compose(e.decode),e.encode.compose(this.encode))}};GQ=new Ne(Ho(),Ho());Ol=new Ne(ox(),Dc()),dx=new Ne(PM(),Dc()),xC=new Ne(iC(),Ae(uE)),sD=new Ne(iC(),Ae((e)=>e.getTime())),iD=Qr({decode:(e,t)=>ut(LT(e),{onNone:()=>R(new Ie({expected:"a valid Duration string"},e,t)),onSome:A}),encode:(e)=>A(globalThis.String(e))}),aD=Qr({decode:(e)=>A(io(e)),encode:(e,t)=>ut(HT(e),{onNone:()=>R(new Ie({expected:"a Duration representable as a bigint"},e,t)),onSome:(n)=>A(n)})}),cD=ht({decode:(e)=>Zi(e),encode:(e)=>qu(e)});yC=Qr({decode:(e,t)=>URL.canParse(e)?A(new URL(e)):R(new Ie({expected:"a valid URL string"},e,t)),encode:(e)=>A(e.href)}),SC=Qr({decode:(e,t)=>{let n=eD(e);return he(n)?R(new Ie({expected:"a valid BigDecimal string"},e,t)):A(n.value)},encode:(e)=>A(xs(e))}),EC=new Ne(DM(),aC()),SD=new Ne(NM(),aC()),ED=new Ne(UM(),sx()),bD=new Ne(BM(),ix()),wD=new Ne(WM(),HM());CD=new Ne(jM(),qM()),vD=new Ne(zM(),VM()),ID=ht({decode:(e)=>xp(e),encode:(e)=>e.offset}),bC=Qr({decode:(e,t)=>ut(vM(e),{onNone:()=>R(new Ie({expected:"a valid IANA time zone"},e,t)),onSome:A}),encode:(e)=>A(e.id)}),wC=Qr({decode:(e,t)=>ut(IM(e),{onNone:()=>R(new Ie({expected:"a valid time zone"},e,t)),onSome:A}),encode:(e)=>A(ba(e))}),kC=Qr({decode:(e,t)=>ut(Yg(e),{onNone:()=>R(new Ie({expected:"a valid UTC DateTime string"},e,t)),onSome:(n)=>A(Xg(n))}),encode:(e)=>A(TM(e))}),CC=Qr({decode:(e,t)=>ut(CM(e),{onNone:()=>R(new Ie({expected:"a valid Zoned DateTime string"},e,t)),onSome:A}),encode:(e)=>A(tx(e))})});function Ca(e){return(t)=>t._tag===e}class wt{to;transformation;constructor(e,t){this.to=e,this.transformation=t}}class jo{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}}function GD(e){switch(e._tag){case"String":case"Number":case"BigInt":return!0;case"Literal":case"TemplateLiteral":return!e.checks;case"Union":return!e.checks&&e.types.every(GD);default:return!1}}function TD(e){let t=globalThis.String(e.literal);return ot(e,[new wt(new Zr(t),new Ne(Ae(()=>e.literal),Ae(()=>t)))])}function AC(e,t){return e.some((n)=>n.annotations?.representation?.id===t||n._tag==="FilterGroup"&&AC(n.checks,t))}function Nc(e,t,n=$c){let r,o;function s(i){switch(i._tag){case"String":case"TemplateLiteral":return(r??=Object.keys(e)).filter((a)=>i.matchPart(a,n)!==void 0);case"Number":return(r??=Object.keys(e)).filter((a)=>i.matchKey(a,n)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter((a)=>i.matchKey(a,n)!==void 0);case"Union":return[...new Set(i.types.flatMap(s))];default:return[]}}return s(JC(kr(t)))}class gx{name;type;constructor(e,t){this.name=e,this.type=t}}function TC(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(TC);default:return!1}}function nZ(e){return TC(e)&&TC(kr(e))}class xx{parameter;type;constructor(e,t){if(!nZ(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Mt(t)&&!xN(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}}function _C(e,t,n){if(n._tag==="Failure")return mx(e,e.ast,t.name,n);if(n===en)return;let r=n[ce];if(r!==De){H(e.out,t.name,r);return}if(delete e.out[t.name],!Mt(t.type)){let o=new Jt([t.name],new Fc(t.type.context?.annotations));if(e.options.errors==="all"){if(e.issues)e.issues.push(o);else e.issues=[o];return}else return uo(new Ft(e.ast,[o],e.input,e.options))}}function HC(e,t){if(!e)return t;if(!t)return e;return[...e,...t]}function yx(e,t,n){return new Dl(Reflect.ownKeys(e).map((r)=>new gx(r,e[r].ast)),[],n,t)}function kp(e){return e.ast}function WC(e,t=void 0){return new qo(!1,e.map((n)=>n.ast),[],void 0,t)}function Sx(e,t,n){return new ir(e.map(kp),t,void 0,n)}function rN(e,t){if(e.encoding||t.some((s)=>s.encoding))throw Error("StructWithRest does not support encodings");let{propertySignatures:n,indexSignatures:r,checks:o}=e;for(let s of t)n=n.concat(s.propertySignatures),r=r.concat(s.indexSignatures),o=HC(o,s.checks);return new Dl(n,r,void 0,o)}function oN(e,t){if(e.encoding)throw Error("TupleWithRest does not support encodings");return new qo(e.isMutable,e.elements,t,void 0,e.checks)}function sN(e){switch(e._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return e.propertySignatures.length||e.indexSignatures.length?["object"]:["string","number","boolean","symbol","bigint","object","array","function"];case"Enum":return Array.from(new Set(e.enums.map(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(sN)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function Rl(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[fp];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap((t)=>{let n=t.type;if(!Mt(n)){if(Pl(n))return[{key:t.name,literal:n.literal}];if(IC(n))return[{key:t.name,literal:n.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,n)=>{if(!Mt(t)){if(Pl(t))return[{key:n,literal:t.literal}];if(IC(t))return[{key:n,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map((n)=>Rl(Ex(n)));return t[0].filter((n)=>t.every((r)=>r.some((o)=>o.key===n.key&&o.literal===n.literal)))}case"Suspend":return Rl(e.thunk())}}function rZ(e){let t=OD.get(e);if(t)return t;let n,r=0,o,s,i=!0;for(let a=0;a<e.length;a++){let c=e[a],u=Ex(c);if(YQ(u))continue;if(i)if(Pl(u)||IC(u)){s??=new Map;let f=Pl(u)?u.literal:u.symbol,d=s.get(f);if(!d)s.set(f,d=[]);d.push(c)}else i=!1;let l=Rl(u);if(l.length){n??=new Map,r++;for(let{key:f,literal:d}of l){let m=n.get(f);if(!m)n.set(f,m=[new Map,new Set]);m[1].add(a);let y=m[0].get(d);if(!y)m[0].set(d,y=new Set);y.add(a)}}else{o??={};let f=sN(u);for(let d of f)(o[d]??=[]).push(a)}}if(i&&s)s.forEach(Object.freeze),t=(a)=>s.get(a)??bp;else if(n?.size===1&&!o){let[a,[c]]=n.entries().next().value,u=c;for(let[l,f]of c)u.set(l,Object.freeze(Array.from(f,(d)=>e[d])));t=(l,f)=>{if(Mf(l)){let d=Object.hasOwn(l,a)?l[a]:void 0;if(d!==void 0)return u.get(d)??bp;if(f)return e}return bp}}else if(n){let a;for(let c of n)if((!a||c[1][0].size>a[1][0].size)&&c[1][1].size===r)a=c;t=(c,u)=>{let l=c===null?"null":Array.isArray(c)?"array":typeof c,f=o?.[l]??bp;if(!Mf(c))return f.map((y)=>e[y]);let d=new Set(f),m;if(a){let[y,[b]]=a,E=Object.hasOwn(c,y),w=E?c[y]:void 0;if(E&&(!u||w!==void 0)){let k=b.get(w);if(!k)return f.map((g)=>e[g]);for(let g of k)d.add(g);m=y}}if(m===void 0)for(let[y,[b,E]]of n){let w=Object.hasOwn(c,y),k=w?c[y]:void 0;if(w&&(!u||k!==void 0)){let g=b.get(k);if(g)for(let x of g)d.add(x)}else if(u)for(let g of E)d.add(g)}for(let[y,[b,E]]of n){if(y===m)continue;let w=Object.hasOwn(c,y),k=w?c[y]:void 0;if(w&&(!u||k!==void 0)){let g=b.get(k);for(let x of d)if(E.has(x)&&!g?.has(x))d.delete(x)}}return Array.from(d).sort((y,b)=>y-b).map((y)=>e[y])}}else t=(a)=>{let c=a===null?"null":Array.isArray(a)?"array":typeof a;return(o?.[c]??bp).map((u)=>e[u]).filter(oZ(a))};return OD.set(e,t),t}function oZ(e){return(t)=>{let n=Ex(t);return n._tag==="Literal"?n.literal===e:n._tag==="UniqueSymbol"?n.symbol===e:!0}}function Cp(e,t,n=!1){return rZ(t)(e,n)}function PD(e,t,n,r){let o=gp(t);if(!o)return Hr(t);return uo(new hp(e,[o],n,r))}function RD(e){return e?"":"readonly "}function FD(e){return e?"?":""}function Lc(e){let t=!1,n;return()=>{if(t)return n;return n=e(),t=!0,n}}function wx(e,t,n=!1){return new wp((r,o,s)=>fM(o,e(r,o,s),r,s),t,n)}function kx(e,t){return new wp((n,r,o)=>e(n)?void 0:new Ie(void 0,n,o),t,!0)}function jC(e){return wx((t)=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}function vp(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return wx((o)=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n}`,representation:{id:"effect/schema/isPattern",payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitrary:{constraint:{patterns:[e.source]}},...t})}function Ip(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}function zC(e){return aN.get(e)??e}function ot(e,t){if(e.encoding===t)return e;return Ip(e,(n)=>{n.encoding.value=t})}function Ap(e,t){if(e.context===t)return e;let n=zC(e);if(n.context===t)return n;let r=Ip(e,(o)=>{o.context.value=t});return aN.set(r,n),r}function Tp(e){return e.encoding?Tp(e.encoding[e.encoding.length-1].to):e}function xo(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Cx(e,ME(e.checks.slice(0,-1),n.annotate(t)))}return Ip(e,(n)=>{n.annotations.value={...n.annotations.value,...t}})}function Cx(e,t){if(e._tag==="Suspend"&&t)throw Error("Cannot add checks to Suspend");if(e.checks===t)return e;return Ip(e,(n)=>{n.checks.value=t})}function Ss(e,t){return Cx(e,HC(e.checks,t))}function Nl(e,t){let n=t(e.to);return n===e.to?e:new wt(n,e.transformation)}function cN(e,t){let n=e,r=n[n.length-1],o=Nl(r,t);return o===r?e:ME(e.slice(0,e.length-1),o)}function VC(e){return(t)=>t.encoding?ot(t,cN(t.encoding,e)):t}function vx(e,t){return VC((n)=>Ap(n,t))(e)}function Bc(e,t){function n(r){if(r.encoding){let o=r.encoding[r.encoding.length-1];return t?.stopAt?.(o)?r:ot(r,cN(r.encoding,n))}return e(r)}return Va(n)}function uN(e,t){return KC(e,t,Tn(e))}function lN(e,t){return KC(kr(e),t,e)}function KC(e,t,n){let r=new wt(e,t);return ot(n,n.encoding?[...n.encoding,r]:[r])}function fN(e,t){let n=cM(e),r=n?[...n,t]:[t];return xo(e,{brands:r})}function Fl(e,t){let n=!1,r=Array(e.length);for(let o=0;o<e.length;o++){let s=e[o],i=t(s);if(i!==s)n=!0;r[o]=i}return n?r:e}function _p(e,t){let n=e.context?new jo(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new jo(!1,!1,void 0,t);return Ap(e,n)}function pN(e,t){let n=new Ne(yp(t),Ho()),r=new wt(Ei,n),o=e.context?new jo(e.context.isOptional,e.context.isMutable,r,e.context.annotations):new jo(!1,!1,r);return Ap(e,o)}function Ix(e,t,n){return KC(e,n,t)}function uZ(e){let t=[],n=[];function r(o){switch(o._tag){case"Literal":if(jm(o.literal))t.push(o.literal);return;case"UniqueSymbol":t.push(o.symbol);return;case"Never":return;case"Union":for(let s=0;s<o.types.length;s++)r(o.types[s]);return;default:n.push(o)}}return r(e),{literals:t,parameters:n}}function mN(e,t){let{literals:n,parameters:r}=uZ(e);return new Dl(n.map((o)=>new gx(o,t)),r.map((o)=>new xx(o,t)))}function Mt(e){return e.context?.isOptional??!1}function hN(e){return e.context?.isMutable??!1}function gN(e){return e.annotations?.[Sr]===!0||e._tag==="FilterGroup"&&e.checks.every(gN)}function lZ(e){function t(r){if(gN(r))return[r];return r._tag==="FilterGroup"?r.checks.flatMap(t):[]}let n=e.flatMap(t);return ac(n)?n:void 0}function fZ(e,t){let n=t,r=n.length,o=n[r-1],s=[new wt(Wo(ot(e,void 0)),n[0].transformation.flip())];for(let a=1;a<r;a++)s.unshift(new wt(Wo(n[a-1].to),n[a].transformation.flip()));let i=Wo(o.to);if(i.encoding)return ot(i,[...i.encoding,...s]);else return ot(i,s)}function xN(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(xN);default:return!1}}function Ax(e,t){let n=ho(t);return(r,o)=>{if(r===De)return Bo;if(r===t)return n;return R(new bt(e,r,o))}}function zo(e,t){return(n,r)=>{if(n===De)return Bo;if(t(n))return en;return R(new bt(e,n,r))}}function MD(e,t,n){let{encodedParts:r,literals:o}=e,s=t.length;for(let u=0;u<o.length;u++){let l=o[u];if(l&&!t.includes(l))return}if(e.suffixLengths[0]>s)return;let i=Array(r.length),a;function c(u,l){if(u===r.length)return l===s;if(a?.has(u*(s+1)+l))return!1;let f=r[u];if(u===r.length-1){let d=t.slice(l);if(f.matchPart(d,n)!==void 0)return i[u]=d,!0}else if(f._tag==="Literal"){let d=o[u];if(t.startsWith(d,l)&&c(u+1,l+d.length))return i[u]=d,!0}else{let d=s-e.suffixLengths[u+1],m=o[u+1],y=m===void 0?d:t.lastIndexOf(m,d);while(y>=l){let b=t.slice(l,y);if(f.matchPart(b,n)!==void 0&&c(u+1,y))return i[u]=b,!0;if(y===0)break;y=m===void 0?y-1:t.lastIndexOf(m,y-1)}}return a??=new Set,a.add(u*(s+1)+l),!1}return c(0,0)?i:void 0}function QC(e){return vp(OC,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:OC.source}),...e})}function ZC(e){return vp(PC,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:PC.source}),...e})}function XC(e){return vp(RC,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:RC.source}),...e})}function Vo(e,t,n,r,o){for(let s=0;s<e.length;s++){let i=e[s];if(i._tag==="FilterGroup"){if(n=Vo(i.checks,t,n,r,o),n&&(o.errors!=="all"||n[n.length-1].filter.aborted))return n}else{let a=i.run(t,r,o);if(a){let c=new Vk(i,a,t,o);if(n)n.push(c);else n=[c];if(o.errors!=="all"||i.aborted)return n}}}return n}function kN(e,t){let n=Vo(e,t,void 0,Ei,{errors:"all"});if(n){let r=new Ft(Ei,n);return oe(r)}return J(t)}function CN(e){if(!va(e))return;let t=e.annotations?.[Kg];return Mn(t)?t(e.typeParameters):void 0}function SZ(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&globalThis.Number.isFinite(e)}function EZ(e){return e===void 0||typeof e==="string"}function vN(e,t){let n=new WeakMap,r=[];e:while(!0){if(typeof e!=="object"||e===null){if(!t(e))return!1}else{let o=e,s=n.get(o);if(s===!1)return!1;if(s===void 0){let i=Array.isArray(o);if(!i){let a=Object.getPrototypeOf(o);if(a!==null&&a!==Object.prototype&&Object.getPrototypeOf(a)!==null)return!1}n.set(o,!1),r.push({value:o,keys:i?o.length:Object.keys(o),index:0})}}while(r.length>0){let o=r[r.length-1],s=o.keys;if(typeof s==="number"){if(o.index<s){e=o.value[o.index++];continue e}}else if(o.index<s.length){e=o.value[s[o.index++]];continue e}n.set(o.value,!0),r.pop()}return!0}}function Ul(e){return vN(e,SZ)}function bZ(e){return vN(e,EZ)}var va,YQ,Pl,IC,FC,XQ,DD,eZ,$c,AD="~effect/Schema",Dt,Uc,ND,MC,$D,UD,DC,LD,BD,HD,WD,jD,qD,zD,Ei,VD,KD,NC,$C,UC,Zr,JD,ys,QD,LC,ZD,YD,XD,eN,tN,nN,qo,tZ,BC=(e)=>(e=e==="unbounded"?1/0:e??1,e>1?{concurrency:e}:void 0),mx=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let o=gp(r.cause);if(o===void 0)return Hr(ri(r.cause,(i)=>new Ft(t,[new Jt([n],i)],e.input,e.options)));let s=new Jt([n],o);if(e.options.errors==="all")if(e.issues)e.issues.push(s);else e.issues=[s];else return uo(new Ft(t,[s],e.input,e.options))},hx="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?",Dl,_D,Ex,OD,bp,ir,sZ,iN,bx,wp,ka,qC,iZ,aN,$l,aZ,dN,GC,cZ,Tn,kr,Wo,yN,JC,Tx,SN,EN="[\\s\\S]*?",OC,dZ,bN,pZ,mZ,hZ="-?\\d+",PC,YC,gZ,xZ="Symbol\\((.*)\\)",RC,yZ,wN,Ml,IN,ev,AN,wZ,tv;var bi=v(()=>{nr();In();Re();jr();Zn();ne();At();ya();Zk();Jg();ct();ge();Bn();ax();Ea();px();va=Ca("Declaration"),YQ=Ca("Never"),Pl=Ca("Literal"),IC=Ca("UniqueSymbol"),FC=Ca("Arrays"),XQ=Ca("Objects"),DD=Ca("Union"),eZ=Ca("Suspend");$c={};Dt=class Dt{[AD]=AD;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}};Uc=class Uc extends Dt{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,o,s,i,a){super(n,r,o,s);this.typeParameters=e,this.run=t,this.encodingChecks=i,this.encodingRun=a}getParser(){let e;return(t,n)=>{if(t===De)return Bo;return(e??=this.run(this.typeParameters))(t,this,n)}}_rebuild(e,t,n,r,o){let s=Fl(this.typeParameters,e);return s===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&o===this.encodingRun?this:new Uc(s,r,this.annotations,t,void 0,this.context,n,o)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;if(typeof e==="string")return e;return"<Declaration>"}};ND=class ND extends Dt{_tag="Null";getParser(){return Ax(this,null)}getExpected(){return"null"}};MC=new ND;$D=class $D extends Dt{_tag="Undefined";getParser(){return Ax(this,void 0)}toCodecJson(){return ot(this,[UD])}getExpected(){return"undefined"}};UD=new wt(MC,new Ne(Ae(()=>{return}),Ae(()=>null))),DC=new $D;LD=class LD extends Dt{_tag="Void";getParser(){let e=ho(void 0);return(t)=>t===De?Bo:e}toCodecJson(){return ot(this,[UD])}getExpected(){return"void"}};BD=new LD;HD=class HD extends Dt{_tag="Never";getParser(){return zo(this,DA)}getExpected(){return"never"}};WD=new HD;jD=class jD extends Dt{_tag="Any";getParser(){return zo(this,ZS)}getExpected(){return"any"}};qD=new jD;zD=class zD extends Dt{_tag="Unknown";getParser(){return zo(this,ZS)}getExpected(){return"unknown"}};Ei=new zD;VD=class VD extends Dt{_tag="ObjectKeyword";getParser(){return zo(this,Mf)}getExpected(){return"object | array | function"}};KD=new VD;NC=class NC extends Dt{_tag="Enum";enums;constructor(e,t,n,r,o){super(t,n,r,o);this.enums=e}getParser(){let e=new Set(this.enums.map(([,t])=>t));return zo(this,(t)=>e.has(t))}toCodecStringTree(){if(this.enums.some(([e,t])=>typeof t==="number")){let e=Object.fromEntries(this.enums.map(([t,n])=>[globalThis.String(n),n]));return ot(this,[new wt(new ir(Object.keys(e).map((t)=>new Zr(t)),"anyOf"),new Ne(Ae((t)=>e[t]),Dc()))])}return this}getExpected(){return this.enums.map(([e,t])=>JSON.stringify(t)).join(" | ")}};$C=class $C extends Dt{_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(e,t,n,r,o){super(t,n,r,o);let s=[],i=[];for(let c of e){let u=kr(c);if(GD(u))s.push(u),i.push(u._tag==="Literal"?globalThis.String(u.literal):void 0);else throw Error(`Invalid TemplateLiteral part ${u._tag}`)}let a=Array(s.length+1);a[s.length]=0;for(let c=s.length-1;c>=0;c--)a[c]=a[c+1]+(i[c]?.length??0);this.parts=e,this.encodedParts=s,this.literals=i,this.suffixLengths=a}getParser(e){let t=e(this.asTemplateLiteralParser());return(n,r)=>{if(n===De)return Bo;let o=t(n,r);if(o._tag==="Success")return en;return mn(o,{onSuccess:()=>n,onFailure:(s)=>new Ft(this,[s],n,r)})}}getExpected(){return"string"}matchPart(e,t){return MD(this,e,t)===void 0?void 0:e}asTemplateLiteralParser(){let e=new qo(!1,this.parts.map(SN),[]);return Ix(ys,e,new Ne(br((t,n)=>{let r=MD(this,t,n);if(r)return A(r);return R(new Ie({expected:"a string matching template literal parts"},t,n))}),Ae((t)=>t.join(""))))}};UC=class UC extends Dt{_tag="UniqueSymbol";symbol;constructor(e,t,n,r,o){super(t,n,r,o);this.symbol=e}getParser(){return Ax(this,this.symbol)}toCodecStringTree(){return ot(this,[wN])}getExpected(){return globalThis.String(this.symbol)}};Zr=class Zr extends Dt{_tag="Literal";literal;constructor(e,t,n,r,o){super(t,n,r,o);if(typeof e==="number"&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${j(e)}`);this.literal=e}getParser(){return Ax(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==="bigint"?TD(this):this}toCodecStringTree(){return typeof this.literal==="string"?this:TD(this)}getExpected(){return typeof this.literal==="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};JD=class JD extends Dt{_tag="String";getParser(){return zo(this,_o)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&Vo(n,e,void 0,this,t)?void 0:e}getExpected(){return"string"}};ys=new JD;QD=class QD extends Dt{_tag="Number";getParser(){return zo(this,Rf)}matchKey(e,t){return this._match(dZ,e,t)}matchPart(e,t){return this._match(OC,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);if(n.disableChecks||!this.checks)return r;return Vo(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){if(this.checks&&(AC(this.checks,"effect/schema/isFinite")||AC(this.checks,"effect/schema/isInt")))return this;return ot(this,[iZ])}toCodecStringTree(){if(this.toCodecJson()===this)return ot(this,[pZ]);return ot(this,[mZ])}getExpected(){return"number"}};LC=new QD;ZD=class ZD extends Dt{_tag="Boolean";getParser(){return zo(this,Wm)}getExpected(){return"boolean"}};YD=new ZD;XD=class XD extends Dt{_tag="Symbol";getParser(){return zo(this,QS)}matchKey(e,t){if(t.disableChecks||!this.checks)return e;return Vo(this.checks,e,void 0,this,t)?void 0:e}toCodecStringTree(){return ot(this,[wN])}getExpected(){return"symbol"}};eN=new XD;tN=class tN extends Dt{_tag="BigInt";getParser(){return zo(this,FA)}matchPart(e,t){if(!PC.test(e))return;let n=globalThis.BigInt(e);if(t.disableChecks||!this.checks)return n;return Vo(this.checks,n,void 0,this,t)?void 0:n}toCodecStringTree(){return ot(this,[gZ])}getExpected(){return"bigint"}};nN=new tN;qo=class qo extends Dt{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,o,s,i,a){super(r,o,s,i);this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=a;let c=!1;for(let u=0;u<t.length;u++)if(Mt(t[u]))c=!0;else if(c)throw Error("A required element cannot follow an optional element. ts(1257)");if(c&&n.length>1)throw Error("A required element cannot follow an optional element. ts(1257)");for(let u=1;u<n.length;u++)if(Mt(n[u]))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let n=this,r,o,s=n.elements.length,i=Math.max(0,n.rest.length-1);function a(c,u){if(u<s)return r[u];else if(u>=c)return o[u-c+1];return o[0]}return _g(function*(c,u){if(c===De)return De;if(!Array.isArray(c))return yield*R(new bt(n,c,u));if(!r)r=n.elements.map((y)=>({ast:y,parser:t(y)})),o=n.rest.map((y)=>({ast:y,parser:t(y)}));let l=c.length,f={ast:n,getParser:a,input:c,len:l,tailThreshold:Math.max(s,l-i),output:new globalThis.Array(l),issues:void 0,options:u},d=BC(u?.concurrency),m=tZ(f,c,{concurrency:d?.concurrency,end:n.rest.length===0?s:Math.max(l,s+i)});if(m)yield*m;if(n.rest.length===0&&l>s)for(let y=s;y<=l-1;y++){let b=new Zg(n,c[y],u),E=new Jt([y],b);if(u.errors==="all")if(f.issues)f.issues.push(E);else f.issues=[E];else return yield*R(new Ft(n,[E],c,u))}if(f.issues)return yield*R(new Ft(n,f.issues,c,u));return f.output})}_rebuild(e,t,n){let r=Fl(this.elements,e),o=Fl(this.rest,e);return r===this.elements&&o===this.rest&&t===this.checks&&n===this.encodingChecks?this:new qo(this.isMutable,r,o,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return"array"}};tZ=Sd()({onItem(e,t,n){let r=n<e.len?t:De;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step(e,t,n,r){if(n._tag==="Failure")return mx(e,e.ast,r,n);let o=n===en?t:n[ce];if(o!==De)e.output[r]=o;else{let s=e.getParser(e.tailThreshold,r);if(Mt(s.ast))return;let i=new Jt([r],new Fc(s.ast.context?.annotations));if(e.options.errors==="all")if(e.issues)e.issues.push(i);else e.issues=[i];else return uo(new Ft(e.ast,[i],e.input,e.options))}}});Dl=class Dl extends Dt{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,o,s,i){super(n,r,o,s);this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=i;let a=e.map((c)=>c.name).filter((c,u,l)=>l.indexOf(c)!==u);if(a.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(a)}. ts(2300)`)}getParser(e,t=e){let n=this,r=[];for(let E of n.propertySignatures)r.push(E.name);let o=r.length,s=n.indexSignatures.length,i=o&&s?new Set(r):void 0;if(!o&&!s)return zo(n,qm);let a,c,u=(E,w,k,g,x)=>{if(x._tag==="Failure")return mx(E,n,w,x)??Wr;let S=x===en?g:x[ce];if(k!==De&&S!==De){if(o&&(i.has(w)||i.has(k)))return Wr;H(E.out,k,S)}return Wr},l=(E,w,k,g)=>{if(!g){let I=k.parserKey(w,E.options);if(!Xe(I))return se(da(I),(_)=>l(E,w,k,_));g=I}if(g._tag==="Failure")return mx(E,n,w,g)??Wr;let x=g===en?w:g[ce],S=E.input[w],C=k.parserValue(S,E.options);return Xe(C)?u(E,w,x,S,C):se(da(C),(I)=>u(E,w,x,S,I))},f=(E,w,k)=>{let g=E.input[w],x=k.parserValue(g,E.options);return Xe(x)?u(E,w,w,g,x):se(da(x),(S)=>u(E,w,w,g,S))},d=s?Sd()({onItem:(E,[w,k])=>l(E,w,k),step:(E,w,k)=>k._tag==="Failure"?k:void 0}):void 0,m=()=>{if(!a)a=n.propertySignatures.map((E)=>({parser:t(E.type),name:E.name,type:E.type})),c=s?n.indexSignatures.map((E)=>({is:E,parserKey:e(JC(E.parameter)),parserValue:t(E.type)})):void 0;return a},y=_g(function*(E,w){if(E===De)return De;if(!(typeof E==="object"&&E!==null&&!Array.isArray(E)))return yield*R(new bt(n,E,w));m();let k=E,g={},x={ast:n,input:k,out:g,issues:void 0,options:w},S=w.errors==="all",C=w.onExcessProperty==="error",I=w.onExcessProperty==="preserve",_;if(!s&&(C||I)){i??=new Set(r),_=Reflect.ownKeys(k);for(let U=0;U<_.length;U++){let N=_[U];if(!i.has(N))if(C){let Z=new Zg(n,k[N],w),G=new Jt([N],Z);if(S){if(x.issues)x.issues.push(G);else x.issues=[G];continue}else return yield*R(new Ft(n,[G],E,w))}else H(g,N,k[N])}}let M=BC(w?.concurrency);if(o){let U=_D(x,a,M);if(U)yield*U}if(s&&!M)for(let U=0;U<s;U++){let N=c[U],Z=N.is.parameter===ys?f:l,G=N.is.parameter===ys?Object.keys(k):Nc(k,N.is.parameter,w);for(let ye=0;ye<G.length;ye++){let Wt=Z(x,G[ye],N);if(!Xe(Wt))yield*Wt;else if(Wt._tag==="Failure")return yield*Wt}}else if(d){let U=cc();for(let Z=0;Z<s;Z++){let G=c[Z],ye=Nc(k,G.is.parameter,w);for(let Wt=0;Wt<ye.length;Wt++)U.push([ye[Wt],G])}let N=d(x,U,M);if(N)yield*N}if(x.issues)return yield*R(new Ft(n,x.issues,E,w));if(w.propertyOrder==="original"){let U=(_??Reflect.ownKeys(k)).concat(r),N={};for(let Z of U)if(Object.hasOwn(g,Z))H(N,Z,g[Z]);return N}return g});if(s)return y;let b=(E,w,k)=>{let g=a[w];return se(da(k),(x)=>{let S=_C(E,g,x);if(S)return S;let C=()=>ho(E.out),I=_D(E,a.slice(w+1));return I?An(I,C):C()})};return(E,w)=>{if(E===De)return Bo;if(w.errors==="all"||w.onExcessProperty!==void 0||w.propertyOrder==="original"||w.concurrency!==void 0)return y(E,w);if(!(typeof E==="object"&&E!==null&&!Array.isArray(E)))return R(new bt(n,E,w));let k=m(),g=E,x={},S={ast:n,input:g,out:x,issues:void 0,options:w};try{for(let C=0;C<k.length;C++){let I=k[C],_=I.name,M=Object.hasOwn(g,_),U=M?g[_]:De,N=I.parser(U,w);if(!Xe(N))return b(S,C,N);if(N===en){if(M)H(x,_,U);continue}let Z=_C(S,I,N);if(Z)return Z}}catch(C){return ls(C)}return ho(x)}}_rebuild(e,t,n,r){let o=Fl(this.propertySignatures,(i)=>{let a=e(i.type);return a===i.type?i:new gx(i.name,a)}),s=Fl(this.indexSignatures,(i)=>{let a=t(i.parameter),c=e(i.type);return a===i.parameter&&c===i.type?i:new xx(a,c)});return o===this.propertySignatures&&s===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Dl(o,s,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){if(this.propertySignatures.length===0&&this.indexSignatures.length===0)return"object | array";return"object"}};_D=Sd()({onItem(e,t){if(!Object.hasOwn(e.input,t.name))return t.parser(De,e.options);let n=e.input[t.name];return H(e.out,t.name,n),t.parser(n,e.options)},step:_C});Ex=Va((e)=>{while(!0){if(eZ(e))return Ei;let t=e.encoding;if(!t)return e.recur?.(Ex,L)??e;if(t.some((n)=>n.transformation._tag==="Middleware"&&n.transformation.decode!==L))return Ei;e=t[t.length-1].to}});OD=new WeakMap,bp=Object.freeze([]);ir=class ir extends Dt{_tag="Union";types;mode;encodingChecks;constructor(e,t,n,r,o,s,i){super(n,r,o,s);this.types=e,this.mode=t,this.encodingChecks=i}getParser(e,t){let n=this;return(r,o)=>{if(r===De)return Bo;let s=Cp(r,n.types,t!==void 0);if(s.length===1){let u=e(s[0])(r,o);if(u._tag==="Success")return u;return Xe(u)?PD(n,u.cause,r,o):Gr(u,(l)=>PD(n,l,r,o))}let i={ast:n,compile:e,input:r,out:void 0,successes:n.mode==="oneOf"?[]:void 0,issues:void 0,options:o},a=BC(o?.concurrency),c=sZ(i,s,a?{...a,orderedStep:!0}:void 0);if(!c){if(i.out)return i.out;return R(new hp(n,i.issues??[],r,o))}return An(c,(u)=>{if(i.out===en)return A(r);if(i.out)return i.out;return R(new hp(n,i.issues??[],r,o))})}}_rebuild(e,t,n){let r=Fl(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new ir(r,this.mode,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}return}getExpected(e){let t=this.annotations?.expected;if(typeof t==="string")return t;if(this.types.length===0)return"never";let n=this.types.map((r)=>{let o=kr(r);switch(o._tag){case"Arrays":{let s=o.elements.filter(Pl);if(s.length>0)return`${RD(o.isMutable)}[ ${s.map((i)=>e(i)+FD(i.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let s=o.propertySignatures.filter((i)=>Pl(i.type));if(s.length>0)return`{ ${s.map((i)=>`${RD(i.type.context?.isMutable)}${$s(i.name)}${FD(i.type.context?.isOptional)}: ${e(i.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(n)).join(" | ")}};sZ=Sd()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag==="Failure"){let r=gp(n.cause);if(r===void 0)return n;if(e.issues)e.issues.push(r);else e.issues=[r]}else{if(e.out&&e.successes)return e.successes.push(t),uo(new Gk(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return Wr}}}),iN=new ir([new Zr("Infinity"),new Zr("-Infinity"),new Zr("NaN")],"anyOf");bx=class bx extends Dt{_tag="Suspend";thunk;constructor(e,t,n,r,o){if(n)throw Error("Cannot add checks to Suspend");super(t,void 0,r,o);this.thunk=Lc(e)}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new bx(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}};wp=class wp extends za{_tag="Filter";run;annotations;aborted;constructor(e,t=void 0,n=!1){super();this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new wp(this.run,{...this.annotations,...e},this.aborted)}abort(){return new wp(this.run,this.annotations,!0)}and(e,t){return new ka([this,e],t)}};ka=class ka extends za{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super();this.checks=e,this.annotations=t}annotate(e){return new ka(this.checks,{...this.annotations,...e})}and(e,t){return new ka([this,e],t)}};qC=Ss(LC,[jC()]),iZ=new wt(new ir([qC,iN],"anyOf"),new Ne(ox(),Ae((e)=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));aN=new WeakMap;$l=Va((e)=>{let t=e.context?e.context.isOptional===!1?new jo(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new jo(!0,!1);return aZ(Ap(e,t))}),aZ=VC($l),dN=bn((e)=>$l(new ir([e,DC],"anyOf"))),GC=Va((e)=>{let t=e.context?e.context.isMutable===!1?new jo(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new jo(!1,!0);return cZ(Ap(e,t))}),cZ=VC(GC);Tn=Va((e)=>{if(e.encoding)return Tn(ot(e,void 0));let t=e,n=t.recur?.(Tn)??t,r=n.encodingChecks;if(r){let o=n===e?r:FC(n)||XQ(n)||va(n)&&n.typeParameters.length>0?lZ(r):void 0;return Ip(n,(s)=>{s.encodingChecks.value=void 0,s.checks.value=HC(n.checks,o)})}return n}),kr=Va((e)=>Tn(Wo(e)));Wo=bn((e)=>{if(e.encoding)return fZ(e,e.encoding);let t=e;return t.flip?.(Wo)??t.recur?.(Wo)??t});yN=bn((e)=>new ir(e.enums.map((t)=>new Zr(t[1],{title:t[0]})),"anyOf")),JC=Bc((e)=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(JC)}}),Tx=Bc((e)=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(Tx)}}),SN=Bc((e)=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(SN)}}),OC=new globalThis.RegExp(`^${hx}$`),dZ=new globalThis.RegExp(`^(?:${hx}|Infinity|-Infinity|NaN)$`);bN=Ss(ys,[QC()]),pZ=new wt(bN,Ol),mZ=new wt(new ir([bN,iN],"anyOf"),Ol),PC=new globalThis.RegExp(`^${hZ}$`);YC=Ss(ys,[ZC({expected:"a string representing a bigint"})]),gZ=new wt(YC,dx),RC=new globalThis.RegExp(`^${xZ}$`),yZ=Ss(ys,[XC()]),wN=new wt(yZ,new Ne(Ae((e)=>globalThis.Symbol.for(RC.exec(e)[1])),br((e,t)=>{if(globalThis.Symbol.keyFor(e)!==void 0)return A(globalThis.String(e));return R(new Tl({message:"cannot serialize to string, Symbol is not registered"},e,t))})));Ml=new Uc([],()=>(e,t,n)=>Ul(e)?en:R(new bt(t,e,n)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{return},toCodecStringTree:()=>tv,toArbitrary:()=>(e)=>e.jsonValue()}),IN=xo(Ml,{representation:{id:"effect/schema/MutableJson",payload:null}}),ev=new wt(Ml,_l()),AN=new wt(new ir([new qo(!1,[],[Ml]),new Dl([],[new xx(ys,Ml)])],"anyOf"),_l());wZ=new Uc([],()=>(e,t,n)=>bZ(e)?en:R(new bt(t,e,n)),{expected:"StringTree",toCodecStringTree:()=>{return}}),tv=new wt(wZ,_l())});function nv(){return Object.assign((e)=>e,{option:(e)=>F(e),result:(e)=>J(e),is:(e)=>!0})}var TN=v(()=>{Me();Bn()});var ON,PN,_N="~effect/ChildProcessSpawner/ChildProcessHandle",CZ,rv=(e)=>Object.setPrototypeOf({...e},CZ),RN=(e)=>{let t=(r,o)=>e(r).pipe(ae((s)=>YF(o?.includeStderr===!0?s.all:s.stdout)),ga),n=(r,o)=>XF(t(r,o));return Ll.of({spawn:e,exitCode:(r)=>ma(se(e(r),(o)=>o.exitCode)),streamString:t,streamLines:n,lines:(r,o)=>eM(n(r,o)),string:(r,o)=>tM(t(r,o))})},Ll;var ov=v(()=>{TN();rt();Re();pr();Cl();ON=nv(),PN=nv(),CZ={[_N]:_N,...HA,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}};Ll=class Ll extends Ye()("effect/process/ChildProcessSpawner"){}});var FN="~effect/unstable/process/ChildProcess",vZ,_x=(e,t,n)=>Object.assign(Object.create(vZ),{_tag:"StandardCommand",command:e,args:t,options:n}),Ox=function(...t){if(MN(t[0])){let[s,...i]=t,a=DN(s,i);return _x(a[0]??"",a.slice(1),{})}if(typeof t[0]==="object"&&!Array.isArray(t[0])&&!MN(t[0])){let s=t[0];return function(i,...a){let c=DN(i,a);return _x(c[0]??"",c.slice(1),s)}}if(typeof t[0]==="string"&&!Array.isArray(t[1])){let[s,i={}]=t;return _x(s,[],i)}let[n,r=[],o={}]=t;return _x(n,r,o)},MN=(e)=>Array.isArray(e)&&("raw"in e)&&Array.isArray(e.raw),Px=(e)=>{let t=/^fd(\d+)$/.exec(e);if(t===null)return;let n=parseInt(t[1],10);return n>=3?n:void 0},LN=(e)=>`fd${e}`,DN=(e,t)=>{let n=[];for(let[r,o]of e.entries())n=IZ(e,t,n,o,r);return n},IZ=(e,t,n,r,o)=>{let s=e.raw[o];if(s===void 0)throw Error(`Invalid backslash sequence: ${e.raw[o]}`);let{hasLeadingWhitespace:i,hasTrailingWhitespace:a,tokens:c}=TZ(r,s),u=UN(n,c,i);if(o===t.length)return u;let l=t[o],f=Array.isArray(l)?l.map((d)=>NN(d)):[NN(l)];return UN(u,f,a)},NN=(e)=>{if(typeof e==="string")return e;return String(e)},$N,AZ,TZ=(e,t)=>{if(t.length===0)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let n=$N.has(t[0]),r=[],o=0;for(let i=0,a=0;i<e.length;i+=1,a+=1){let c=t[a];if($N.has(c)){if(o!==i)r.push(e.slice(o,i));o=i+1}else if(c==="\\"){let u=t[a+1];if(u===`
|
|
33
|
+
`)i-=1,a+=1;else if(u==="u"&&t[a+2]==="{")a=t.indexOf("}",a+3);else a+=AZ[u]??1}}let s=o===e.length;if(!s)r.push(e.slice(o));return{tokens:r,hasLeadingWhitespace:n,hasTrailingWhitespace:s}},UN=(e,t,n)=>n||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t.at(0)}`,...t.slice(1)];var BN=v(()=>{rt();Fu();ov();vZ={...ss({label:"Command",evaluate(e){return Ro(e.context,Ll).spawn(this)}}),[FN]:FN},$N=new Set([" ","\t","\r",`
|
|
34
|
+
`]),AZ={x:3,u:5}});var HN=(e,t,n)=>{let r=e.detached??n!=="win32";return{...t,detached:r,shell:e.shell,windowsHide:e.windowsHide??!r}};var Je=(e,t)=>(n,[r])=>{let o="Unknown";switch(n.code){case"ENOENT":o="NotFound";break;case"EACCES":o="PermissionDenied";break;case"EEXIST":o="AlreadyExists";break;case"EISDIR":o="BadResource";break;case"ENOTDIR":o="BadResource";break;case"EBUSY":o="Busy";break;case"ELOOP":o="BadResource";break}return mo({_tag:o,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,cause:n})};var sv=v(()=>{ms()});var Bl=(e)=>Ok(Ak(OZ(e),(t)=>[t])),OZ=(e)=>jn((t)=>{let n=e.evaluate();return A(PZ({...e,writable:n,pull:t}))}),PZ=(e)=>e.pull.pipe(se((t)=>{let n=0;return Wn(function r(o){for(;n<t.length;)if(!e.writable.write(t[n++],e.encoding)){e.writable.once("drain",()=>r(o));return}o(Pe)})}),ds({disableYield:!0}),Ac(Wn((t)=>{let n=(r)=>t(R(e.onError(r)));return e.writable.once("error",n),we(()=>{e.writable.off("error",n)})})),e.endOnDone!==!1?zr((t)=>{if("closed"in e.writable&&e.writable.closed)return Vt(t);return Wn((n)=>{e.writable.once("finish",()=>n(Vt(t))),e.writable.end()})}):L);var iv=v(()=>{In();sp();Re();ne();kc();Wg()});var Hl=(e)=>Lo(FZ(e)),FZ=(e)=>jn((t,n)=>MZ({scope:n,readable:e.evaluate(),onError:e.onError??DZ,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),MZ=(e)=>{let t=e.readable,n=e.closeOnDone??!0,r=e.exit??cF(void 0),o=sF(!1);function s(){o.openUnsafe()}function i(u){r.current=uo(e.onError(u)),o.openUnsafe()}function a(){r.current=uo(Id()),o.openUnsafe()}t.on("readable",s),t.once("error",i),t.once("end",a);let c=He(function u(){let l=e.readable.read(e.chunkSize);if(l===null){if(r.current)return r.current;if(t.readableEnded)return R(Id());return o.closeUnsafe(),se(o.await,u)}let f=uc(l);while(!0){if(l=e.readable.read(e.chunkSize),l===null)break;f.push(l)}return A(f)});return Kr(Od(e.scope,we(()=>{if(t.off("readable",s),t.off("error",i),t.off("end",a),n&&"closed"in e.readable&&!e.readable.closed)e.readable.destroy()})),c)},DZ=(e)=>new Ew(e);var av=v(()=>{nr();In();sp();Re();jr();iF();uF();Pd();Cl()});import*as Rx from"child_process";import{PassThrough as cv}from"stream";var Hc=(e)=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),Es=(e,t,n)=>{let{commands:r}=qN(n),o=r.reduce((s,i)=>{let a=`${i.command} ${i.args.join(" ")}`;return s.length===0?a:`${s} | ${a}`},"");return Je("ChildProcess",e)(t,[o])},WN=(e,t=()=>{})=>Rx.execFile("taskkill",["/pid",String(e.pid),"/T","/F"],{windowsHide:!0},t),$Z,jN,qN=(e)=>{let t=[],n=[],r=(a)=>{switch(a._tag){case"StandardCommand":{t.push(a);break}case"PipedCommand":{r(a.left),n.push(a.options),r(a.right);break}}};if(r(e),t.length===0)throw Error("flattenCommand produced empty commands array");let[o,...s]=t;return{commands:[o,...s],pipeOptions:n}};var zN=v(()=>{Cw();Re();jr();zg();cs();Vg();ge();Wg();Cl();BN();ov();sv();iv();av();$Z=un(function*(){let e=yield*xa,t=yield*hs,n=q(function*(x){if(Li(x.cwd))return;return yield*e.access(x.cwd),t.resolve(x.cwd)}),r=(x)=>x.extendEnv?{...globalThis.process.env,...x.env}:x.env,o=(x)=>Oc(x)?"pipe":x,s=(x)=>ip(x)?"pipe":x,i=(x)=>{let S={stream:"pipe",encoding:"utf-8",endOnDone:!0};if(Li(x.stdin))return S;if(typeof x.stdin==="string")return{...S,stream:x.stdin};if(Oc(x.stdin))return{...S,stream:x.stdin};return{stream:x.stdin.stream,encoding:x.stdin.encoding??S.encoding,endOnDone:x.stdin.endOnDone??S.endOnDone}},a=(x,S)=>{let C=x[S];if(Li(C))return{stream:"pipe"};if(typeof C==="string")return{stream:C};if(ip(C))return{stream:C};return{stream:C.stream}},c=(x)=>{if(Li(x.additionalFds))return[];let S=[];for(let[C,I]of Object.entries(x.additionalFds)){let _=Px(C);if(Ve(_))S.push({fd:_,config:I})}return S.sort((C,I)=>C.fd-I.fd)},u=(x,S,C,I)=>{let _=[o(x.stream),s(S.stream),s(C.stream)];if(I.length===0)return _;let M=I.reduce((U,{fd:N})=>Math.max(U,N),2);for(let U=3;U<=M;U++)_[U]="ignore";for(let{fd:U}of I)_[U]="pipe";return _},l=q(function*(x,S,C){if(C.length===0)return{getInputFd:()=>ap,getOutputFd:()=>kl};let I=new Map,_=new Map;for(let{config:M,fd:U}of C){let N=S.stdio[U];switch(M.type){case"input":{let Z=ap;if(N&&"write"in N)Z=Bl({evaluate:()=>N,onError:(G)=>Es(`fromWritable(fd${U})`,Hc(G),x)});if(M.stream)yield*yl(Nk(M.stream,Z));I.set(U,Z);break}case"output":{let Z=kl;if(N&&"read"in N){let G=new cv;N.on("error",(ye)=>G.destroy(ye)),N.pipe(G),Z=Hl({evaluate:()=>G,onError:(ye)=>Es(`fromReadable(fd${U})`,Hc(ye),x)})}if(M.sink)Z=jg(Z,M.sink);_.set(U,Z);break}}}return{getInputFd:(M)=>I.get(M)??ap,getOutputFd:(M)=>_.get(M)??kl}}),f=(x,S,C)=>He(()=>{let I=ap;if(Ff(S.stdin))I=Bl({evaluate:()=>S.stdin,onError:(_)=>Es("fromWritable(stdin)",Hc(_),x),endOnDone:C.endOnDone,encoding:C.encoding});if(Oc(C.stream))return Kr(yl(Nk(C.stream,I)),I);return A(I)}),d=(x,S,C,I)=>{let _=S.stdout?(()=>{let N=new cv;return S.stdout.on("error",(Z)=>N.destroy(Z)),S.stdout.pipe(N),Hl({evaluate:()=>N,onError:(Z)=>Es("fromReadable(stdout)",Hc(Z),x)})})():kl,M=S.stderr?(()=>{let N=new cv;return S.stderr.on("error",(Z)=>N.destroy(Z)),S.stderr.pipe(N),Hl({evaluate:()=>N,onError:(Z)=>Es("fromReadable(stderr)",Hc(Z),x)})})():kl;if(ip(C.stream))_=jg(_,C.stream);if(ip(I.stream))M=jg(M,I.stream);let U=ZF(_,M);return{stdout:_,stderr:M,all:U}},m=(x,S)=>Wn((C)=>{let I=sg(),_=Rx.spawn(x.command,x.args,S);return _.on("error",(M)=>{C(R(Es("spawn",M,x)))}),_.on("exit",(...M)=>{kw(I,co(M))}),_.on("spawn",()=>{C(A([_,I]))}),we(()=>{_.kill("SIGTERM")})}),y=(x,S,C)=>{if(globalThis.process.platform==="win32")return Wn((I)=>{WN(S,(_)=>{if(_)I(R(Es("kill",Hc(_),x)));else I(Pe)})});return Xt({try:()=>{globalThis.process.kill(-S.pid,C)},catch:(I)=>Es("kill",Hc(I),x)})},b=(x,S)=>{if(globalThis.process.platform==="win32"){WN(x);return}try{globalThis.process.kill(-x.pid,S)}catch{}},E=(x,S,C)=>He(()=>{if(!S.kill(C)){let _=new globalThis.Error("Failed to kill child process");return R(Es("kill",_,x))}return Pe}),w=(x,S,C)=>(I)=>{let _=C?.killSignal??"SIGTERM";return Li(C?.forceKillAfter)?I(S,x,_):fk(I(S,x,_),{duration:C.forceKillAfter,orElse:()=>I(S,x,"SIGKILL")})},k=(x,S)=>{let C=S??"stdout";switch(C){case"stdout":return x.stdout;case"stderr":return x.stderr;case"all":return x.all;default:{let I=Px(C);if(Ve(I))return x.getOutputFd(I);return x.stdout}}},g=q(function*(x){switch(x._tag){case"StandardCommand":{let S=i(x.options),C=a(x.options,"stdout"),I=a(x.options,"stderr"),_=c(x.options),M=!0,U=yield*n(x.options),N=r(x.options),Z=u(S,C,I,_),[G,ye]=yield*po(m(x,HN(x.options,{cwd:U,env:N,stdio:Z},process.platform)),q(function*([Io,bu]){let wu=yield*ww(bu),Tf=w(Io,x,x.options);if(wu){let[Ui]=yield*Ec(bu);if(Ui!==0&&Ff(Ui))return yield*zd(Tf(y));return yield*Pe}if(!M)return yield*Pe;return yield*Tf((Ui,OA,PA)=>y(Ui,OA,PA).pipe(lo(()=>E(Ui,OA,PA)),Vr(Ec(bu)))).pipe(zd)})),Wt=PN(G.pid);G.on("exit",(Io)=>{if(Io!==0&&Ff(Io))b(G,x.options.killSignal??"SIGTERM")});let $i=we(()=>{if(!M)G.ref(),M=!0}),Af=we(()=>{if(M)G.unref(),M=!1;return $i}),Um=yield*f(x,G,S),{all:Lm,stderr:VS,stdout:KS}=d(x,G,C,I),{getInputFd:Hz,getOutputFd:Wz}=yield*l(x,G,_),jz=ae(ww(ye),(Io)=>!Io),qz=se(Ec(ye),([Io,bu])=>{if(Ff(Io))return A(ON(Io));let wu=new globalThis.Error(`Process interrupted due to receipt of signal: '${bu}'`);return R(Es("exitCode",wu,x))});return rv({pid:Wt,exitCode:qz,isRunning:jz,kill:(Io)=>w(G,x,Io)((wu,Tf,Ui)=>y(wu,Tf,Ui).pipe(lo(()=>E(wu,Tf,Ui)),Vr(Ec(ye)))).pipe(jd),stdin:Um,stdout:KS,stderr:VS,all:Lm,getInputFd:Hz,getOutputFd:Wz,unref:Af})}case"PipedCommand":{let{commands:S,pipeOptions:C}=qN(x),[I,..._]=S,M=[yield*g(I)];for(let G=0;G<_.length;G++){let ye=_[G],Wt=C[G]??{},$i=i(ye.options),Af=ga(A(k(M[M.length-1],Wt.from))),Um=Wt.to??"stdin";if(Um==="stdin")M.push(yield*g(Ox(ye.command,ye.args,{...ye.options,stdin:{...$i,stream:Af}})));else{let Lm=Px(Um);if(Ve(Lm)){let VS=LN(Lm),KS=ye.options.additionalFds??{};M.push(yield*g(Ox(ye.command,ye.args,{...ye.options,additionalFds:{...KS,[VS]:{type:"input",stream:Af}}})))}else M.push(yield*g(Ox(ye.command,ye.args,{...ye.options,stdin:{...$i,stream:Af}})))}}let U=M[M.length-1],N=(G)=>vc([...M].reverse(),(ye)=>zd(ye.kill(G)),{discard:!0}),Z=un(function*(){let G=[];for(let ye of M)G.push(yield*ye.unref);return vc([...G].reverse(),(ye)=>ye,{discard:!0})});return rv({pid:U.pid,exitCode:U.exitCode,isRunning:U.isRunning,kill:N,stdin:U.stdin,stdout:U.stdout,stderr:U.stderr,all:U.all,getInputFd:U.getInputFd,getOutputFd:U.getOutputFd,unref:Z})}}});return RN(g)}),jN=il(Ll,$Z)});var VN=v(()=>{zN()});function KN(e=QN()){return e[6]=e[6]&15|64,e[8]=e[8]&63|128,e}function GN(e,t=QN()){let n=Math.min(Math.max(0,Math.trunc(e)),BZ);return t[0]=Math.floor(n/1099511627776),t[1]=Math.floor(n/4294967296)&255,t[2]=Math.floor(n/16777216)&255,t[3]=Math.floor(n/65536)&255,t[4]=Math.floor(n/256)&255,t[5]=n&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128,t}var LZ=(e)=>e.toString(16).padStart(2,"0"),JN=(e)=>[e.subarray(0,4),e.subarray(4,6),e.subarray(6,8),e.subarray(8,10),e.subarray(10,16)].map((n)=>Array.from(n,LZ).join("")).join("-"),QN=()=>globalThis.crypto.getRandomValues(new Uint8Array(16)),ZN=(e)=>JN(e===void 0?KN():KN(e)),BZ=281474976710655,YN=(e,t)=>JN(t===void 0?GN(e):GN(e,t));var XN="~effect/platform/Crypto",uv,e$=(e)=>{let t=e.randomBytes,n=(i)=>ae(WZ("randomBytes",i),t),r=(i)=>(i[0]&31)*281474976710656+i[1]*1099511627776+i[2]*4294967296+i[3]*16777216+i[4]*65536+i[5]*256+i[6],o=()=>r(t(7))/9007199254740992,s=()=>{while(!0){let i=t(7),a=r(i);if((i[0]&32)===0)return a+Number.MIN_SAFE_INTEGER;if(a<Number.MAX_SAFE_INTEGER)return a+1}};return uv.of({[XN]:XN,randomBytes:n,nextDoubleUnsafe:o,nextIntUnsafe:s,digest:e.digest,random:we(()=>o()),randomBoolean:we(()=>o()>0.5),randomInt:we(()=>s()),randomBetween:(i,a)=>we(()=>o()*(a-i)+i),randomIntBetween(i,a,c){let u=c?.halfOpen===!0?0:1;return we(()=>{let l=Math.ceil(i),f=Math.floor(a);return Math.floor(o()*(f-l+u))+l})},randomShuffle:(i)=>we(()=>{let a=Array.from(i);for(let c=a.length-1;c>=1;c=c-1){let u=Math.min(c,Math.floor(o()*(c+1))),l=a[c];a[c]=a[u],a[u]=l}return a}),randomUUIDv4:we(()=>ZN(t(16))),randomUUIDv7:Qd((i)=>A(YN(i.currentTimeMillisUnsafe(),t(16))))})},WZ=(e,t)=>Number.isSafeInteger(t)&&t>=0?A(t):R(li({module:"Crypto",method:e,description:"size must be a non-negative safe integer"}));var t$=v(()=>{rt();Re();ms();uv=Ye("effect/Crypto")});import*as Fx from"crypto";var qZ=(e)=>{switch(e){case"SHA-1":return"sha1";case"SHA-256":return"sha256";case"SHA-384":return"sha384";case"SHA-512":return"sha512"}},zZ=(e,t)=>Xt({try:()=>Uint8Array.from(Fx.createHash(qZ(e)).update(t).digest()),catch:(n)=>mo({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:n})}),VZ,n$;var r$=v(()=>{t$();Re();cs();ms();VZ=e$({randomBytes:Fx.randomBytes,digest:zZ}),n$=la(uv,VZ)});var o$;var s$=v(()=>{r$();o$=n$});import*as i$ from"crypto";import*as re from"fs";import*as a$ from"os";import*as Wl from"path";var gt=(e)=>(t)=>li({module:"FileSystem",method:e,description:t.message??String(t)}),JZ,QZ,ZZ,YZ,XZ,e8,t8,n8,lv=(e)=>{let t=mt(re.mkdtemp,Je("FileSystem",e),gt(e));return(n)=>He(()=>{let r=n?.prefix??"",o=typeof n?.directory==="string"?Wl.join(n.directory,"."):a$.tmpdir();return t(r?Wl.join(o,r):o+"/")})},r8,fv=(e)=>{let t=mt(re.rm,Je("FileSystem",e),gt(e));return(n,r)=>t(n,{recursive:r?.recursive??!1,force:r?.force??!1})},o8,s8,i8=(e)=>{let t=mt(re.open,Je("FileSystem",e),gt(e)),n=mt(re.close,Je("FileSystem",e),gt(e));return(r,o)=>To(po(t(r,o?.flag??"r",o?.mode),(s)=>fo(n(s))),ae((s)=>c8(s,o?.flag?.startsWith("a")??!1)))},a8,c8,c$=(e)=>{let t=lv(e);return q(function*(n){let r=yield*t(n),o=i$.randomBytes(6).toString("hex"),s=Wl.join(r,n?.suffix?`${o}${n.suffix}`:o);return yield*l$(s,new Uint8Array(0)),s})},u8,l8,f8=(e,t)=>fl({try:()=>re.promises.readdir(e,t),catch:(n)=>Je("FileSystem","readDirectory")(n,[e])}),d8=(e)=>Wn((t,n)=>{try{re.readFile(e,{signal:n},(r,o)=>{if(r)t(R(Je("FileSystem","readFile")(r,[e])));else t(A(o))})}catch(r){t(R(gt("readFile")(r)))}}),p8,m8,h8,u$=(e)=>({type:e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",mtime:er(e.mtime),atime:er(e.atime),birthtime:er(e.birthtime),dev:e.dev,rdev:er(e.rdev),ino:er(e.ino),mode:e.mode,nlink:er(e.nlink),uid:er(e.uid),gid:er(e.gid),size:hi(e.size),blksize:e.blksize!==void 0?F(hi(e.blksize)):P(),blocks:er(e.blocks)}),dv,g8,x8,y8,S8=(e,t)=>JF((n)=>po(we(()=>{let r=re.watch(e,{recursive:t?.recursive??!1},(o,s)=>{if(!s)return;switch(o){case"rename":{ps(kg(dv(s),{onSuccess:(i)=>ep(n,{_tag:"Create",path:s}),onFailure:(i)=>ep(n,{_tag:"Remove",path:s})}));return}case"change":{tp(n,{_tag:"Update",path:s});return}}});return r.on("error",(o)=>{rp(n,yw(mo({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:e,cause:o})))}),r.on("close",()=>{pi(n)}),r}),(r)=>we(()=>r.close()))),E8=(e,t,n)=>dv(t).pipe(ae((r)=>e.pipe(Vs((o)=>o.register(t,r,n)),It(()=>S8(t,n)))),ga),l$=(e,t,n)=>Wn((r,o)=>{try{re.writeFile(e,t,{signal:o,flag:n?.flag,mode:n?.mode},(s)=>{if(s)r(R(Je("FileSystem","writeFile")(s,[e])));else r(Pe)})}catch(s){r(R(gt("writeFile")(s)))}}),b8,f$;var d$=v(()=>{In();Re();Re();zg();ne();cs();Me();ms();op();Cl();sv();JZ=(()=>{let e=mt(re.access,Je("FileSystem","access"),gt("access"));return(t,n)=>{let r=re.constants.F_OK;if(n?.readable)r|=re.constants.R_OK;if(n?.writable)r|=re.constants.W_OK;return e(t,r)}})(),QZ=(()=>{let e=mt(re.cp,Je("FileSystem","copy"),gt("copy"));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),ZZ=(()=>{let e=mt(re.copyFile,Je("FileSystem","copyFile"),gt("copyFile"));return(t,n)=>e(t,n)})(),YZ=(()=>{let e=mt(re.chmod,Je("FileSystem","chmod"),gt("chmod"));return(t,n)=>e(t,n)})(),XZ=(()=>{let e=mt(re.chown,Je("FileSystem","chown"),gt("chown"));return(t,n,r)=>e(t,n,r)})(),e8=(()=>{let e=mt(re.glob,Je("FileSystem","glob"),gt("glob"));return(t,n)=>e(t,{cwd:n?.root,exclude:n?.exclude})})(),t8=(()=>{let e=mt(re.link,Je("FileSystem","link"),gt("link"));return(t,n)=>e(t,n)})(),n8=(()=>{let e=mt(re.mkdir,Je("FileSystem","makeDirectory"),gt("makeDirectory"));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),r8=lv("makeTempDirectory"),o8=fv("remove"),s8=(()=>{let e=lv("makeTempDirectoryScoped"),t=fv("makeTempDirectoryScoped");return(n)=>po(e(n),(r)=>fo(t(r,{recursive:!0})))})(),a8=i8("open"),c8=(()=>{let e=(l)=>mt(re.read,Je("FileSystem",l),gt(l)),t=e("read"),n=e("readAlloc"),r=mt(re.fstat,Je("FileSystem","stat"),gt("stat")),o=mt(re.ftruncate,Je("FileSystem","truncate"),gt("truncate")),s=mt(re.fsync,Je("FileSystem","sync"),gt("sync")),i=(l)=>mt(re.write,Je("FileSystem",l),gt(l)),a=i("write"),c=i("writeAll");class u{[qg];fd;append;position=BigInt(0);constructor(l,f){this[qg]=qg,this.fd=l,this.append=f}get stat(){return ae(r(this.fd),u$)}get sync(){return s(this.fd)}seek(l,f){let d=hi(l);return we(()=>{if(f==="start")this.position=d;else if(f==="current")this.position=this.position+d;return hi(this.position)})}read(l){return He(()=>{let f=this.position;return ae(t(this.fd,{buffer:l,position:f}),(d)=>{let m=hi(d);return this.position=f+m,m})})}readAlloc(l){let f=Number(l);return He(()=>{let d=Buffer.allocUnsafeSlow(f),m=this.position;return ae(n(this.fd,{buffer:d,position:m}),(y)=>{if(y===0)return P();if(this.position=m+BigInt(y),y===f)return F(d);let b=Buffer.allocUnsafeSlow(y);return d.copy(b,0,0,y),F(b)})})}truncate(l){return ae(o(this.fd,l?Number(l):void 0),()=>{if(!this.append){let f=BigInt(l??0);if(this.position>f)this.position=f}})}write(l){return He(()=>{let f=this.position;return ae(a(this.fd,l,void 0,void 0,this.append?void 0:Number(f)),(d)=>{let m=hi(d);if(!this.append)this.position=f+m;return m})})}writeAllChunk(l){return He(()=>{let f=this.position;return se(c(this.fd,l,void 0,void 0,this.append?void 0:Number(f)),(d)=>{if(d===0)return R(mo({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"}));if(!this.append)this.position=f+BigInt(d);return d<l.length?this.writeAllChunk(l.subarray(d)):Pe})})}writeAll(l){return this.writeAllChunk(l)}}return(l,f)=>new u(l,f)})(),u8=c$("makeTempFile"),l8=(()=>{let e=c$("makeTempFileScoped"),t=fv("makeTempFileScoped");return(n)=>po(e(n),(r)=>fo(t(Wl.dirname(r),{recursive:!0})))})(),p8=(()=>{let e=mt(re.readlink,Je("FileSystem","readLink"),gt("readLink"));return(t)=>e(t)})(),m8=(()=>{let e=mt(re.realpath,Je("FileSystem","realPath"),gt("realPath"));return(t)=>e(t)})(),h8=(()=>{let e=mt(re.rename,Je("FileSystem","rename"),gt("rename"));return(t,n)=>e(t,n)})(),dv=(()=>{let e=mt(re.stat,Je("FileSystem","stat"),gt("stat"));return(t)=>ae(e(t),u$)})(),g8=(()=>{let e=mt(re.symlink,Je("FileSystem","symlink"),gt("symlink"));return(t,n)=>e(t,n)})(),x8=(()=>{let e=mt(re.truncate,Je("FileSystem","truncate"),gt("truncate"));return(t,n)=>e(t,n!==void 0?Number(n):void 0)})(),y8=(()=>{let e=mt(re.utimes,Je("FileSystem","utime"),gt("utime"));return(t,n,r)=>e(t,n,r)})(),b8=ae(vg($k),(e)=>rM({access:JZ,chmod:YZ,chown:XZ,copy:QZ,copyFile:ZZ,glob:e8,link:t8,makeDirectory:n8,makeTempDirectory:r8,makeTempDirectoryScoped:s8,makeTempFile:u8,makeTempFileScoped:l8,open:a8,readDirectory:f8,readFile:d8,readLink:p8,realPath:m8,remove:o8,rename:h8,stat:dv,symlink:g8,truncate:x8,utimes:y8,watch(t,n){return E8(e,t,n)},writeFile:l$})),f$=il(xa)(b8)});var p$;var m$=v(()=>{d$();p$=f$});import*as Op from"path";import*as Mx from"url";var pv=(e)=>({fromFileUrl:(t)=>Xt({try:()=>Mx.fileURLToPath(t,{windows:e}),catch:(n)=>new ui({module:"Path",method:"fromFileUrl",cause:n})}),toFileUrl:(t)=>Xt({try:()=>Mx.pathToFileURL(t,{windows:e}),catch:(n)=>new ui({module:"Path",method:"toFileUrl",cause:n})})}),C8,v8,h$;var g$=v(()=>{Re();cs();Vg();ms();C8=la(hs)({[gi]:gi,...Op.posix,...pv(!1)}),v8=la(hs)({[gi]:gi,...Op.win32,...pv(!0)}),h$=la(hs)({[gi]:gi,...Op,...pv(void 0)})});var x$;var y$=v(()=>{g$();x$=h$});var mv="~effect/Stdio",Dx,S$=(e)=>({[mv]:mv,stdinIsTerminal:A(!1),stdoutIsTerminal:A(!1),...e});var hv=v(()=>{rt();Re();Dx=Ye(mv)});var b$;var w$=v(()=>{Re();cs();ms();hv();iv();av();b$=la(Dx,S$({args:we(()=>process.argv.slice(2)),stdinIsTerminal:we(()=>process.stdin.isTTY===!0),stdoutIsTerminal:we(()=>process.stdout.isTTY===!0),stdout:(e)=>Bl({evaluate:()=>process.stdout,onError:(t)=>mo({module:"Stdio",method:"stdout",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stderr:(e)=>Bl({evaluate:()=>process.stderr,onError:(t)=>mo({module:"Stdio",method:"stderr",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stdin:Hl({evaluate:()=>process.stdin,onError:(e)=>mo({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})}))});var k$;var C$=v(()=>{w$();k$=b$});var Nx="~effect/collections/Graph",gv=(e)=>e,O8=(e,t,n)=>(e==="directed"?t.source===n.source&&t.target===n.target:t.source===n.source&&t.target===n.target||t.source===n.target&&t.target===n.source)&&ee(t.data,n.data),P8=(e,t)=>e==="directed"?ie(t):Bi(ie(t.data)^ie(t.source)+ie(t.target)),R8,v$=(e,t)=>{let n=Object.create(R8);return n.type=e,n.mutable=t,n.transforming=!1,n.nodes=new Map,n.edges=new Map,n.adjacency=new Map,n.reverseAdjacency=new Map,n.nextNodeIndex=0,n.nextEdgeIndex=0,n.acyclic=F(!0),n},Pp=(e)=>{let t=gv(e);return{type:e.type,nodes:Array.from(t.nodes,([n,r])=>({index:n,data:r})).sort((n,r)=>n.index-r.index),edges:Array.from(t.edges,([n,r])=>({index:n,source:r.source,target:r.target,data:r.data})).sort((n,r)=>n.index-r.index)}},Rp=(e)=>{let t=v$(e.type,!1);for(let n of e.nodes)t.nodes.set(n.index,n.data),t.adjacency.set(n.index,[]),t.reverseAdjacency.set(n.index,[]);for(let n of e.edges)if(t.edges.set(n.index,{source:n.source,target:n.target,data:n.data}),t.adjacency.get(n.source).push(n.index),t.reverseAdjacency.get(n.target).push(n.index),e.type==="undirected")t.adjacency.get(n.target).push(n.index),t.reverseAdjacency.get(n.source).push(n.index);return t.nextNodeIndex=e.nodes.length===0?0:e.nodes[e.nodes.length-1].index+1,t.nextEdgeIndex=e.edges.length===0?0:e.edges[e.edges.length-1].index+1,t.acyclic=P(),t};var xv=v(()=>{Pt();wn();pr();Me();ct();ge();R8={[Nx]:{_N:(e)=>e,_E:(e)=>e},[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[zt](){return this.toJSON()},[Oe](e){if(D(e,Nx)){let t=gv(e);if(this.nodes.size!==t.nodes.size||this.edges.size!==t.edges.size||this.type!==t.type)return!1;for(let[n,r]of this.nodes)if(!t.nodes.has(n)||!ee(r,t.nodes.get(n)))return!1;for(let[n,r]of this.edges){let o=t.edges.get(n);if(o===void 0||!O8(this.type,r,o))return!1}return!0}return!1},[_e](){let e=Ze("Graph");e=e^Ze(this.type),e=e^dr(this.nodes.size),e=e^dr(this.edges.size);for(let[t,n]of this.nodes)e=e^ie(t)+ie(n);for(let[t,n]of this.edges)e=e^ie(t)+P8(this.type,n);return e},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return`Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`},pipe(){return fe(this,arguments)}}});var F8,yv=(e)=>D(e,F8),A$,M8;var T$=v(()=>{Pt();wn();xv();ge();F8=Nx;A$=class A${type;source;target;identity;constructor(e,t,n,r){this.type=e,this.source=t,this.target=n,this.identity=r}[Oe](e){if(!(e instanceof A$)||this.type!==e.type||!ee(this.identity,e.identity))return!1;if(this.type==="directed")return ee(this.source,e.source)&&ee(this.target,e.target);return ee(this.source,e.source)&&ee(this.target,e.target)||ee(this.source,e.target)&&ee(this.target,e.source)}[_e](){let e=ie(this.identity);return this.type==="directed"?Ot(ie(this.target))(Ot(ie(this.source))(e)):Bi(e^ie(this.source)+ie(this.target))}};M8=class M8{[Symbol.iterator];visit;constructor(e){this.visit=e,this[Symbol.iterator]=()=>e((t,n)=>[t,n])[Symbol.iterator]()}}});function O$(e,t,n,r,o,s){if(t>32)throw Error("HashMap: max depth exceeded");let i=Aa(n,t),a=Aa(o,t);if(i===a){let l=O$(e,t+Ko,n,r,o,s);return new bs(e,i,[l])}let c=i|a,u=i>>>0<a>>>0?[r,s]:[s,r];return new bs(e,c,u)}class jl{canEdit(e){return this.edit===e}}var Ux="~effect/collections/HashMap",Ko=5,Np,N8,_$,$8,U8=(e)=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),Fp=(e,t)=>e>>>t&$8,Aa=(e,t)=>1<<Fp(e,t),$x=(e,t)=>U8(e&t-1),P$,wi,Mp,bs,Dp,Lx,R$,Sv=(e)=>D(e,Ux),Ev=()=>new Lx(!1,0,R$,0),F$=(e)=>{let t=R$,n=0,r={value:!1};for(let[o,s]of e){let i=ie(o);if(r.value=!1,t=t.set(NaN,0,i,o,s,r),r.value)n++}return new Lx(!1,0,t,n)},M$,bv,L8=(e,t,n,r)=>{let o=e,s={value:!1},i=o._editable?o._edit:NaN,a=o._root.set(i,0,n,t,r,s);if(o._editable){if(o._root=a,s.value)o._size++;return e}if(o._root===a)return e;return new Lx(!1,o._edit,a,o._size+(s.value?1:0))},wv,kv=(e)=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){let n=t.next();if(n.done)return{done:!0,value:void 0};return{done:!1,value:n.value[0]}}}},D$=(e)=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){return t.next()}}},Bx=(e)=>e.size;var Cv=v(()=>{Pt();Zn();ne();wn();pr();Me();ct();ge();Np=1<<Ko,N8=Np/4,_$=Np/2,$8=Np-1;P$=class P$ extends jl{_tag="EmptyNode";edit=0;get size(){return 0}get(e,t,n){return P()}has(e,t,n){return!1}set(e,t,n,r,o,s){return s.value=!0,new wi(e,n,r,o)}remove(e,t,n,r,o){return this}iterator(){return[][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}canEdit(e){return!1}};wi=class wi extends jl{_tag="LeafNode";edit;hash;key;value;constructor(e,t,n,r){super();this.edit=e,this.hash=t,this.key=n,this.value=r}get size(){return 1}get(e,t,n){if(this.hash===t&&ee(this.key,n))return F(this.value);return P()}has(e,t,n){return this.hash===t&&ee(this.key,n)}set(e,t,n,r,o,s){if(this.hash===n&&ee(this.key,r)){if(ee(this.value,o))return this;if(this.canEdit(e))return this.value=o,this;return new wi(e,n,r,o)}if(s.value=!0,this.hash===n)return new Mp(e,n,[[this.key,this.value],[r,o]]);let i=Aa(n,t),a=Aa(this.hash,t);if(i===a)return new bs(e,i,[this.set(e,t+Ko,n,r,o,s)]);let c=i|a,u=i>>>0<a>>>0?[new wi(e,n,r,o),this]:[this,new wi(e,n,r,o)];return new bs(e,c,u)}remove(e,t,n,r,o){if(this.hash===n&&ee(this.key,r)){o.value=!0;return}return this}iterator(){return[[this.key,this.value]][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}};Mp=class Mp extends jl{_tag="CollisionNode";edit;hash;entries;constructor(e,t,n){super();this.edit=e,this.hash=t,this.entries=n}get size(){return this.entries.length}get(e,t,n){if(this.hash!==t)return P();for(let[r,o]of this.entries)if(ee(r,n))return F(o);return P()}has(e,t,n){if(this.hash!==t)return!1;for(let[r]of this.entries)if(ee(r,n))return!0;return!1}set(e,t,n,r,o,s){if(this.hash!==n)return s.value=!0,O$(e,t,this.hash,this,n,new wi(e,n,r,o));for(let i=0;i<this.entries.length;i++)if(ee(this.entries[i][0],r)){if(ee(this.entries[i][1],o))return this;if(this.canEdit(e))return this.entries[i]=[r,o],this;let a=[...this.entries];return a[i]=[r,o],new Mp(e,this.hash,a)}if(s.value=!0,this.canEdit(e))return this.entries.push([r,o]),this;return new Mp(e,this.hash,[...this.entries,[r,o]])}remove(e,t,n,r,o){if(this.hash!==n)return this;let s=this.entries.findIndex(([a])=>ee(a,r));if(s===-1)return this;if(o.value=!0,this.entries.length===1)return;if(this.entries.length===2){let a=this.entries[s===0?1:0];return new wi(e,this.hash,a[0],a[1])}if(this.canEdit(e))return this.entries.splice(s,1),this;let i=[...this.entries];return i.splice(s,1),new Mp(e,this.hash,i)}iterator(){return this.entries[Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}};bs=class bs extends jl{_tag="IndexedNode";edit;_size;bitmap;children;constructor(e,t,n){super();this.edit=e,this.bitmap=t,this.children=n}get size(){if(this._size===void 0)this._size=this.children.reduce((e,t)=>e+t.size,0);return this._size}get(e,t,n){let r=Aa(t,e);if((this.bitmap&r)===0)return P();let o=$x(this.bitmap,r);return this.children[o].get(e+Ko,t,n)}has(e,t,n){let r=Aa(t,e);if((this.bitmap&r)===0)return!1;let o=$x(this.bitmap,r);return this.children[o].has(e+Ko,t,n)}set(e,t,n,r,o,s){let i=Aa(n,t),a=$x(this.bitmap,i);if((this.bitmap&i)!==0){let c=this.children[a],u=c.set(e,t+Ko,n,r,o,s);if(c===u)return this;if(this.canEdit(e))return this.children[a]=u,this;let l=[...this.children];return l[a]=u,new bs(e,this.bitmap,l)}else{s.value=!0;let c=new wi(e,n,r,o),u=this.bitmap|i;if(this.canEdit(e)){if(this.children.splice(a,0,c),this.bitmap=u,this._size=void 0,this.children.length>_$)return this.expand(e,u,this.children);return this}let l=[...this.children];if(l.splice(a,0,c),l.length>_$)return this.expand(e,u,l);return new bs(e,u,l)}}remove(e,t,n,r,o){let s=Aa(n,t);if((this.bitmap&s)===0)return this;let i=$x(this.bitmap,s),a=this.children[i],c=a.remove(e,t+Ko,n,r,o);if(!o.value)return this;if(c===void 0){let l=this.bitmap^s;if(l===0)return;if(this.children.length===2){let d=this.children[i===0?1:0];if(d._tag==="LeafNode")return d}if(this.canEdit(e))return this.children.splice(i,1),this.bitmap=l,this._size=void 0,this;let f=[...this.children];return f.splice(i,1),new bs(e,l,f)}if(a===c)return this;if(this.canEdit(e))return this.children[i]=c,this;let u=[...this.children];return u[i]=c,new bs(e,this.bitmap,u)}expand(e,t,n){let r=new globalThis.Array(Np),o=0;for(let s=0;s<Np;s++)if((t&1<<s)!==0)r[s]=n[o++];return new Dp(e,n.length,r)}iterator(){let e=0,t;return{next:()=>{while(e<this.children.length){if(!t)t=this.children[e].iterator();let n=t.next();if(!n.done)return n;t=void 0,e++}return{done:!0,value:void 0}}}}[Symbol.iterator](){return this.iterator()}};Dp=class Dp extends jl{_tag="ArrayNode";edit;_size;count;children;constructor(e,t,n){super();this.edit=e,this.count=t,this.children=n}get size(){if(this._size===void 0)this._size=this.children.reduce((e,t)=>e+(t?.size??0),0);return this._size}get(e,t,n){let r=Fp(t,e),o=this.children[r];return o?o.get(e+Ko,t,n):P()}has(e,t,n){let r=Fp(t,e),o=this.children[r];return o?o.has(e+Ko,t,n):!1}set(e,t,n,r,o,s){let i=Fp(n,t),a=this.children[i];if(a){let c=a.set(e,t+Ko,n,r,o,s);if(a===c)return this;if(this.canEdit(e))return this.children[i]=c,this;let u=[...this.children];return u[i]=c,new Dp(e,this.count,u)}else{s.value=!0;let c=new wi(e,n,r,o);if(this.canEdit(e))return this.children[i]=c,this.count++,this._size=void 0,this;let u=[...this.children];return u[i]=c,new Dp(e,this.count+1,u)}}remove(e,t,n,r,o){let s=Fp(n,t),i=this.children[s];if(!i)return this;let a=i.remove(e,t+Ko,n,r,o);if(!o.value)return this;let c=this.count-(a?0:1);if(c<N8)return this.pack(e,s,a);if(i===a)return this;if(this.canEdit(e)){if(this.children[s]=a,!a)this.count=c;return this._size=void 0,this}let u=[...this.children];return u[s]=a,new Dp(e,c,u)}pack(e,t,n){let r=[],o=0,s=1;for(let i=0;i<this.children.length;i++){let a=i===t?n:this.children[i];if(a)r.push(a),o|=s;s<<=1}return new bs(e,o,r)}iterator(){let e=0,t;return{next:()=>{while(e<this.children.length){let n=this.children[e];if(!n){e++;continue}if(!t)t=n.iterator();let r=t.next();if(!r.done)return r;t=void 0,e++}return{done:!0,value:void 0}}}}[Symbol.iterator](){return this.iterator()}};Lx=class Lx{[Ux]=Ux;_editable;_edit;_root;_size;constructor(e,t,n,r){this._editable=e,this._edit=t,this._root=n,this._size=r}get size(){return this._size}[Symbol.iterator](){return this._root.iterator()}[Oe](e){if(Sv(e)){let t=e;if(this.size!==t.size)return!1;for(let[n,r]of this){let o=To(e,M$(n));if(he(o)||!ee(r,o.value))return!1}return!0}return!1}[_e](){let e=Ze("HashMap");for(let[t,n]of this)e=e^ie(t)+ie(n);return e}[zt](){return fn(this)}toString(){return`HashMap(${j(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([e,t])=>[fn(e),fn(t)])}}pipe(){return fe(this,arguments)}};R$=new P$,M$=p(2,(e,t)=>e._root.get(0,ie(t),t)),bv=p(2,(e,t)=>e._root.has(0,ie(t),t)),wv=p(3,(e,t,n)=>L8(e,t,ie(t),n))});var $$,Hx,W8,Wx=(e)=>Array.from(W8(e)),U$;var L$=v(()=>{Cv();$$=Sv,Hx=F$,W8=D$,U$=Bx});var $p="~effect/collections/HashSet",q8,z8=(e)=>{let t=Object.create(q8);return t[$p]=$p,t.keyMap=e,t},vv=(e)=>D(e,$p),Iv=(e)=>e.keyMap,B$=(e)=>{let t=Ev();for(let n of e)t=wv(t,n,!0);return z8(t)},H$=(e,t)=>bv(Iv(e),t),jx=(e)=>Bx(Iv(e)),W$=(e,t)=>{for(let n of e)if(!t(n))return!1;return!0};var j$=v(()=>{Pt();Zn();wn();pr();ct();ge();Cv();q8={[_e](){return ie($p)},[Oe](e){return vv(e)&&jx(this)===jx(e)&&W$(this,(t)=>H$(e,t))},[Symbol.iterator](){return kv(Iv(this))},toString(){return`HashSet(${j(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:fn(Array.from(this))}},[zt](){return this.toJSON()},pipe(){return fe(this,arguments)}}});var qx,q$,z$;var V$=v(()=>{j$();qx=B$,q$=vv,z$=jx});function zx(e){let t=oU(Kx,Tn(e.ast));return(n,r)=>t(n,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Vx(e){let t=zx(e);return(n,r)=>{let o=ha(t(n,r));if(Kt(o))return F(o.value);return xi(o.cause,"Option adapter can only return none for schema issues"),P()}}function G$(e){let t=zx(e);return(n,r)=>{let o=ha(t(n,r));if(Kt(o))return o.value;let s=xi(o.cause,"Constructor adapter can only throw schema issues");throw Error("Schema validation failed",{cause:s})}}function J$(e){return Lp(e.ast)}function Lp(e){let t=Wc(Bp(Tn(e)));return(n)=>{let r=t(n,$c);if(Kt(r))return!0;return xi(r.cause,"Type guard adapter can only return false for schema issues"),!1}}function Q$(e){let t=Bp(e);return(n,r)=>{let o=ha(t(n,r));if(Kt(o))return;return xi(o.cause,"Issue adapter can only return schema issues")}}function Z$(e,t){let r=Wc(Bp(Tn(e.ast)))(t,$c);if(ol(r)){let o=xi(r.cause,"Assertion adapter can only throw schema issues");throw Error("Schema validation failed",{cause:o})}}function Nt(e,t){let n=Bp(e.ast);return t===void 0?n:(r,o)=>n(r,Up(t,o))}function Y$(e,t){return Wc(Nt(e,t))}function Tv(e,t){return sU(Nt(e,t))}function eU(e,t){return iU(Nt(e,t))}function G8(e,t){return aU(Nt(e,t))}function ql(e,t){let n=Bp(Wo(e.ast));return t===void 0?n:(r,o)=>n(r,Up(t,o))}function tU(e,t){return Wc(ql(e,t))}function Ov(e,t){return sU(ql(e,t))}function rU(e,t){return iU(ql(e,t))}function J8(e,t){return aU(ql(e,t))}function Bp(e){return oU(cU,e)}function oU(e,t){let n;return(r,o)=>{let s=(n??=e(t))(r,o??$c);if(s===en)return A(r);if(!Xe(s))return An(s,K$);return s[ce]===De?K$(De):s}}function Wc(e){return(t,n)=>ha(e(t,n))}function sU(e){let t=Wc(e);return(n,r)=>{let o=t(n,r);if(Kt(o))return F(o.value);return xi(o.cause,"Option adapter can only return none for schema issues"),P()}}function iU(e){let t=Wc(e);return(n,r)=>{let o=t(n,r);if(Kt(o))return J(o.value);return oe(xi(o.cause,"Result adapter can only return schema issues"))}}function aU(e){let t=Wc(e);return(n,r)=>{let o=t(n,r);if(Kt(o))return o.value;let s=xi(o.cause,"Sync adapter can only throw schema issues");throw Error("Schema validation failed",{cause:s})}}function uU(e){return e.context?.constructorDefault?Q8(e):Kx(e)}function lU(e,t,n,r){let o;if(Xe(e)&&e._tag==="Success"){let s=Gg(e===en?t:e[ce]);o=n._tag==="Transformation"?n.decode.run(s,r):n.decode(ho(s),r)}else if(n._tag==="Transformation")o=An(e,(s)=>n.decode.run(Gg(s),r));else o=n.decode(ci(e,Gg),r);return Xe(o)&&o._tag==="Success"?Wk(o[ce]):An(o,Wk)}function Z8(e,t){let n;return(r,o)=>{if(r===De)return Bo;if(e.isConstructed(r))return en;let s=(n??=t(e.link.to))(r,o);return lU(s,r,e.link.transformation,o)}}function Rv(e,t,n,r){let o=n?CN(e):void 0,s=o?Z8(o,t):e.getParser(t,n),i=e.checks,a=r?e.encoding?[...e.encoding,r]:[r]:e.encoding,c=e.encodingChecks,u=(i?i[i.length-1].annotations:e.annotations)?.parseOptions;if(!a&&!i&&!c){if(!u)return s;return(d,m)=>s(d,Up(m,u))}let l,f=(d,m)=>{let y=s(d,m);if(c&&!m.disableChecks)if(Xe(y)){if(y._tag==="Success"){let b=y===en?d:y[ce];if(d!==De&&b!==De){let E=Vo(c,d,void 0,e,m);if(E)y=R(new Ft(e,E,d,m))}}}else y=se(y,(b)=>{if(d!==De&&b!==De){let E=Vo(c,d,void 0,e,m);if(E)return R(new Ft(e,E,d,m))}return A(b)});if(i&&!m.disableChecks)if(Xe(y)){if(y._tag==="Success"){let b=y===en?d:y[ce];if(b===De)return y;let E=Vo(i,b,void 0,e,m);if(E)y=R(new Ft(e,E,b,m))}}else y=se(y,(b)=>{if(b!==De){let E=Vo(i,b,void 0,e,m);if(E)return R(new Ft(e,E,b,m))}return A(b)});return y};if(!a)return u?(d,m)=>f(d,Up(m,u)):f;return(d,m)=>{if(u)m=Up(m,u);let y=l??=a.map((w)=>t(w.to)),b=d,E=y[y.length-1](d,m);for(let w=a.length-1;w>=0;w--)if(E=lU(E,b,a[w].transformation,m),w!==0){let k=y[w-1];if(E._tag==="Success")b=E[ce],E=k(b,m);else E=An(E,(g)=>{let x=k(g,m);return x===en?ho(g):x})}if(E._tag==="Success"){let w=E[ce],k=f(w,m);return k===en?E:k}return E=Gr(E,(w)=>fa(()=>ri(w,(k)=>new Kk(e,k,d,m)))),An(E,(w)=>{let k=f(w,m);return k===en?ho(w):k})}}var Av,X$,_v,nU,Pv,Up=(e,t)=>t?{...e,...t}:e,K$=(e)=>{if(e===De)return R(new Ie);return A(e)},cU,Kx,Q8;var Gx=v(()=>{In();Re();jr();ne();At();Zk();Jg();Me();Bn();bi();Ea();Av=Nt;X$=Tv;_v=G8;nU=Ov;Pv=J8;cU=bn((e)=>Rv(e,cU)),Kx=bn((e)=>Rv(e,Kx,uU)),Q8=bn((e)=>Rv(e,Kx,uU,e.context?.constructorDefault))});function ar(e,t,n){return{id:e,payloadSchema:t,revive:n}}function xe(e,t,n){return{id:e,payloadSchema:t,revive:n}}function Hp(e,t){function n(){}let r=Object.defineProperties(Object.setPrototypeOf(n,Y8),Object.getOwnPropertyDescriptors({...t}));return r.ast=e,r.rebuild=(o)=>Hp(o,t),r.makeEffect=zx(r),r.make=G$(r),r.makeOption=Vx(r),r}var Jx="~effect/Schema/Schema",Y8;var fU=v(()=>{ct();bi();Gx();Y8={[Jx]:Jx,pipe(){return fe(this,arguments)},annotate(e){return this.rebuild(xo(this.ast,e))},annotateKey(e){return this.rebuild(_p(this.ast,e))},check(...e){return this.rebuild(Ss(this.ast,e))}}});var dxe,dU;var pU=v(()=>{dxe=globalThis.Boolean,dU=oo((e,t)=>e||t,!1)});function Dv(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let o=t(r,e[r]);if(o){let[s,i]=o;H(n,s,i)}}return n}function xU(e,t){let n=t?.omitKeyWhen??(()=>!1);return nh((r,o)=>{let s=Reflect.ownKeys(e),i={};for(let a of s){let c=e[a].combine(r[a],o[a]);if(n(c))continue;H(i,a,c)}return i})}var mU,hU,gU,Mv,qn=(e)=>e;var Qx=v(()=>{ne();mU=p(2,(e,t)=>Dv(e,(n,r)=>t.includes(n)?[n,r]:void 0)),hU=p(2,(e,t)=>Dv(e,(n,r)=>!t.includes(n)?[n,r]:void 0)),gU=p(2,(e,t)=>({...e,...t})),Mv=p(2,(e,t)=>Dv(e,(n,r)=>[Object.hasOwn(t,n)?t[n]:n,r]))});function Wp(e){return oo((t,n)=>{if(t===void 0)return n;if(n===void 0)return t;return e.combine(t,n)},void 0)}var yU=()=>{};function ws(e,t){if(t.length>0)e+=`
|
|
35
|
+
at ${Qm(t)}`;return Error(e)}var $v=v(()=>{Zn()});function ki(e){return Error(`Unable to derive an arbitrary for ${e}`)}function n9(e,t,n){return t.reduce((r,o)=>r.filter((s)=>o.run(s,e,$c)===void 0),n)}function RU(e,t){if(e?.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength)throw ki(`${t} constraints`)}function FU(e){return e===void 0||e.minLength===void 0&&e.maxLength===void 0?void 0:{...e.minLength!==void 0?{minLength:e.minLength}:{},...e.maxLength!==void 0?{maxLength:e.maxLength}:{}}}function Uv(e,t,n,r){return r?e.uniqueArray(t,{...n,comparator:r}):e.array(t,n)}function kU(e,t,n,r=!1){let o=t.constraint,s=FU(o);return RU(s,"array"),Uv(e,n,r?{...s,maxLength:s?.minLength??0}:s,o?.unique?ee:void 0)}function Zx(e,t,n,r){return t.chain((o)=>o.length<n?e.constant(o):r.map((s)=>[...o,...s]))}function CU(e,t){return e.chain((n)=>t.map((r)=>({...Object.fromEntries(r),...n})))}function vU(e,t,n,r,o,s){if(r===void 0||t===void 0)return r===void 0?[t,n]:[r,o];let i=e(t,r);return i===s?[r,o]:i===0?[t,n||o]:[t,n]}function a9(e,t){if(e===void 0)return t;if(e.order!==t.order)throw Error("Cannot merge ordered arbitrary constraints with different Order instances");let[n,r]=vU(e.order,e.minimum,e.exclusiveMinimum,t.minimum,t.exclusiveMinimum,-1),[o,s]=vU(e.order,e.maximum,e.exclusiveMaximum,t.maximum,t.exclusiveMaximum,1);return{order:e.order,...n!==void 0?{minimum:n}:{},...r!==void 0?{exclusiveMinimum:r}:{},...o!==void 0?{maximum:o}:{},...s!==void 0?{exclusiveMaximum:s}:{}}}function c9(e,t){let{ordered:n,...r}=e??{},{ordered:o,...s}=t,i=o===void 0?n:a9(n,o);return{...i9.combine(r,s),...i===void 0?{}:{ordered:i}}}function IU(e){let t=[],n=[];function r(o){if(o.annotations?.arbitrary)n.push(o.annotations.arbitrary);if(o._tag!=="Filter")for(let s of o.checks)r(s);else t.push(o)}return e?.forEach(r),{filters:t,arbitraries:n}}function u9(e){let t=e.map(({constraint:n})=>n).filter(Ve);return(n)=>{let r=t.reduce((o,s)=>c9(o,s),n.constraint);return{...n,constraint:r}}}function jp(e){return{...e,constraint:void 0}}function AU(e,t,n){if(t===void 0||t.minLength===void 0&&t.maxLength===void 0)return;if(t.minLength!==void 0&&e.indexSignatures.length===0&&t.minLength>e.propertySignatures.length)throw ki("object property constraints");let r={};if(t.minLength!==void 0)r.minLength=Math.max(0,t.minLength-n);if(t.maxLength!==void 0){if(r.maxLength=t.maxLength-n,r.maxLength<0)throw ki("object property constraints")}return RU(r,"object property"),r}function l9(e,t,n,r,o,s){let i=r.length;if(s.maxLength!==void 0&&s.maxLength<i)throw ki("object property constraints");let a=s.minLength===void 0?0:Math.max(0,s.minLength-i),c=s.maxLength===void 0?o.length:Math.min(o.length,s.maxLength-i);if(a>c)throw ki("object property constraints");let u=e.record(t,{requiredKeys:[...r,...o]}),l=e.shuffledSubarray([...o],{minLength:a,maxLength:c});return e.tuple(u,l).map(([f,d])=>{let m=new Set([...r,...d]),y={};for(let b of n)if(m.has(b))H(y,b,f[b]);return y})}function MU(e,t,n,r){let o={};if(e?.minimum!==void 0)o.min=t(e.minimum,e.exclusiveMinimum===!0);if(e?.maximum!==void 0)o.max=n(e.maximum,e.exclusiveMaximum===!0);if(o.min!==void 0&&o.max!==void 0&&o.min>o.max)throw ki(r);return o}function f9(e){return MU(e,(t,n)=>n?Math.floor(t)+1:Math.ceil(t),(t,n)=>n?Math.ceil(t)-1:Math.floor(t),"integer constraints")}function d9(e,t){let n={...e?.noInfinity?{noDefaultInfinity:!0}:{},...e?.noNaN?{noNaN:!0}:{},...t?.minimum!==void 0?{min:t.minimum}:{},...t?.exclusiveMinimum!==void 0?{minExcluded:t.exclusiveMinimum}:{},...t?.maximum!==void 0?{max:t.maximum}:{},...t?.exclusiveMaximum!==void 0?{maxExcluded:t.exclusiveMaximum}:{}};if(n.min!==void 0&&n.max!==void 0&&(n.min>n.max||n.min===n.max&&(n.minExcluded||n.maxExcluded)))throw ki("number constraints");return n}function p9(e){return MU(e,(t,n)=>n?t+BigInt(1):t,(t,n)=>n?t-BigInt(1):t,"the ordered bigint constraints")}function zl(e,t){let n=(r,o,s=bU)=>e(r,o,s);return n.terminal=(r,o,s=bU)=>t(r,o,s),n}function yo(e){return zl(e,e)}function TU(e,t){let n=EU.get(t)??e.createDepthIdentifier();return EU.set(t,n),{maxDepth:2,depthIdentifier:n}}function _U(e,t){return t.length===0?void 0:t.length===1?t[0]:e.oneof(...t)}function h9(e){return{...e,constraint:m9}}function g9(e,t,n,r){let o=r===void 0?[]:[{arbitrary:r,weight:1}];for(let{candidate:s}of n){if(!s)continue;let i=s.make(e,t);if(i===void 0)continue;let a=s.weight??1;if(!globalThis.Number.isInteger(a)||a<=0)throw ki("a candidate with an invalid weight");o.push({arbitrary:i,weight:a})}return o.length===0?void 0:o.length===1?o[0].arbitrary:e.oneof(...o)}function OU(e,t,n,r,o){let s=g9(n,r,t.arbitraries,o);return s===void 0?void 0:n9(e,t.filters,s)}function x9(e,t){if(!(typeof e==="object"&&e!==null&&("arbitrary"in e)))return{arbitrary:e,terminal:t?void 0:e};let n="terminal"in e?e.terminal:t?void 0:e.arbitrary;return{arbitrary:e.arbitrary,terminal:n}}function y9(e,t,n,r,o){return e.map((s)=>({arbitrary:o?t.constant(null).chain(()=>s(t,n,r)):s(t,n,r),terminal:s.terminal(t,n,r)}))}function PU(e,t,n,r){let o=u9(t.arbitraries);return zl((s,i,a)=>{let c=o(i);return OU(e,t,s,c,n(s,i,c,a))},(s,i,a)=>{let c=o(i);return OU(e,t,s,c,r(s,i,c,a))})}function So(e,t){let n=gs(e)?.toArbitrary;if(n){let r=va(e)?e.typeParameters.map((i)=>So(i,t)):[],o=IU(e.checks),s=(i)=>(a,c,u,l)=>x9(n(y9(r,a,jp(c),l,i))(a,u),r.length>0)[i?"terminal":"arbitrary"];return PU(e,o,s(!1),s(!0))}if(e.checks){let r=IU(e.checks),o=So(Cx(e,void 0),t);return PU(e,r,(s,i,a,c)=>o(s,a,c),(s,i,a,c)=>o.terminal(s,a,c))}return S9(e,t)}function S9(e,t){switch(e._tag){case"Never":case"Declaration":throw ws(`Unsupported AST ${e._tag}`,t);case"Null":return yo((n)=>n.constant(null));case"Void":case"Undefined":return yo((n)=>n.constant(void 0));case"Unknown":case"Any":return yo((n)=>n.anything());case"String":return yo((n,r)=>{let o=r.constraint,s=o?.patterns;return s?n.oneof(...s.map((i)=>n.stringMatching(new RegExp(i)))):n.string(FU(o))});case"Number":return yo((n,r)=>{let o=r.constraint,s=o?.ordered?.order===Mr?o.ordered:void 0;return o?.integer?n.integer(f9(s)):n.float(d9(o,s))});case"Boolean":return yo((n)=>n.boolean());case"BigInt":return yo((n,r)=>{let o=r.constraint?.ordered?.order===so?r.constraint.ordered:void 0;return n.bigInt(p9(o))});case"Symbol":return yo((n)=>n.string().map(Symbol.for));case"Literal":return yo((n)=>n.constant(e.literal));case"UniqueSymbol":return yo((n)=>n.constant(e.symbol));case"ObjectKeyword":return yo((n)=>n.oneof(n.object(),n.array(n.anything())));case"Enum":return So(yN(e),t);case"TemplateLiteral":{let n=e.parts.map((r,o)=>So(kr(r),[...t,o]));return yo((r,o,s)=>r.tuple(...n.map((i)=>i(r,h9(o),s))).map((i)=>i.map((a)=>globalThis.String(a)).join("")))}case"Arrays":{let n=e.elements.map((i,a)=>({ast:i,arbitrary:So(i,[...t,a])})),r=e.elements.length,o=e.rest.map((i,a)=>({ast:i,arbitrary:So(i,[...t,r+a])})),s=(i,a,c)=>{let u=jp(a),l=[],f=[],d=0;for(let k of n){let g=k.arbitrary.terminal(i,u,c);if(Mt(k.ast)){f.push(g);continue}if(g===void 0)return;d++,l.push(g.map(F))}let m=a.constraint?.minLength??0,b=hr(o)&&m>d+f.length?f.length:Math.max(0,m-d),E=0;for(let k of f){if(E>=b||k===void 0){l.push(i.constant(P()));continue}E++,d++,l.push(k.map(F))}if(E<b)return;let w=i.tuple(...l).map(UE);if(hr(o)){let[k,...g]=o,x=e.elements.length===0?a:u,S=Math.max(0,m-d-g.length),C=S===0?void 0:k.arbitrary.terminal(i,u,c);if(S>0&&C===void 0)return;let I=S===0?i.constant([]):kU(i,{...x,constraint:{...x.constraint,minLength:S}},C,!0);if(w=Zx(i,w,r,I),g.length>0){let _=[];for(let U of g){let N=U.arbitrary.terminal(i,u,c);if(N===void 0)return;_.push(N)}let M=i.tuple(..._);w=Zx(i,w,r,M)}}return w};return zl((i,a,c)=>{let u=jp(a),l=n.map(({ast:d,arbitrary:m})=>{let y=m(i,u,c);return Mt(d)?y.chain((b)=>i.boolean().map((E)=>E?F(b):P())):y.map(F)}),f=i.tuple(...l).map((d)=>UE(PT(d,Ce)));if(hr(o)){let[d,...m]=o.map(({arbitrary:b})=>b(i,u,c)),y=kU(i,e.elements.length===0?a:u,d);if(f=Zx(i,f,r,y),m.length>0){let b=i.tuple(...m);f=Zx(i,f,r,b)}}if(a.recursion){let d=s(i,a,c);if(d!==void 0)return i.oneof(a.recursion,d,f)}return f},s)}case"Objects":{let n=e.propertySignatures.map((s)=>({ps:s,arbitrary:So(s.type,[...t,s.name])})),r=e.indexSignatures.map((s)=>({is:s,parameter:So(s.parameter,t),type:So(s.type,t)}));return zl((s,i,a)=>{let c=jp(i),u={},l=[],f=[],d=[];for(let{ps:E,arbitrary:w}of n){let k=E.name;if(l.push(k),Mt(E.type))d.push(k);else f.push(k);H(u,k,w(s,c,a))}let m=i.constraint;if(d.length>0&&r.length===0&&m!==void 0&&(m.minLength!==void 0||m.maxLength!==void 0))return l9(s,u,l,f,d,m);let y=s.record(u,{requiredKeys:f}),b=AU(e,i.constraint,f.length);for(let{parameter:E,type:w}of r){let k=s.tuple(E(s,c,a),w(s,c,a)),g=Uv(s,k,b,wU);y=CU(y,g)}return y},(s,i,a)=>{let c=jp(i),u={},l=[],f=[];for(let{ps:E,arbitrary:w}of n){let k=E.name,g=w.terminal(s,c,a);if(Mt(E.type)){if(g!==void 0)f.push([k,g]);continue}if(g===void 0)return;l.push(k),H(u,k,g)}let d=Math.max(0,(i.constraint?.minLength??0)-l.length);for(let[E,w]of f){if(d===0)break;d--,l.push(E),H(u,E,w)}if(d>0&&e.indexSignatures.length===0)return;let m=s.record(u,{requiredKeys:l}),y=AU(e,i.constraint,l.length),b=y?.minLength??0;for(let{parameter:E,type:w}of r){let k;if(b===0)k=s.constant([]);else{let g=E.terminal(s,c,a),x=w.terminal(s,c,a);if(g===void 0||x===void 0)return;k=Uv(s,s.tuple(g,x),{...y,maxLength:b},wU)}m=CU(m,k)}return m})}case"Union":{let n=e.types.map((o)=>So(o,t)),r=(o,s,i)=>_U(o,n.map((a)=>a.terminal(o,s,i)).filter(Ve));return zl((o,s,i)=>{let a=n.map((u)=>u(o,s,i));if(s.recursion){let u=r(o,s,i);if(u!==void 0)return o.oneof(s.recursion,u,...a)}let c=_U(o,a);if(c===void 0)throw ki("a union with no members");return c},r)}case"Suspend":{let n=SU.get(e);if(n)return n;let r=Lc(()=>So(e.thunk(),t)),o=zl((s,i,a)=>{let c=TU(s,e),u={...i,recursion:c},l=a.includes(e)?a:[...a,e],f=r().terminal(s,u,l);if(f===void 0)throw ws("Unable to derive an arbitrary for a recursive schema without a finite generation path",t);return s.oneof(c,f,s.constant(null).chain(()=>r()(s,u,l)))},(s,i,a)=>{if(a.includes(e))return;let c=TU(s,e);return r().terminal(s,{...i,recursion:c},[...a,e])});return SU.set(e,o),o}}}var SU,EU,bU,wU=([e],[t])=>ee(e,t),r9,o9,Yx,s9,i9,m9,DU;var NU=v(()=>{nr();pU();Pt();ne();pg();Me();rc();ge();bi();Qx();yU();$v();ya();SU=new WeakMap,EU=new WeakMap,bU=[];r9=Wp(ZR),o9=Wp(YR),Yx=Wp(dU),s9=Wp(RT()),i9=xU({integer:Yx,maxLength:o9,minLength:r9,noInfinity:Yx,noNaN:Yx,patterns:s9,unique:Yx},{omitKeyWhen:Li});m9={noInfinity:!0,noNaN:!0};DU=bn((e)=>So(e,[]))});function Ta(e,t){let n=gs(e)?.toEquivalence;if(n)return n(va(e)?e.typeParameters.map((r)=>Ta(r,t)):[]);switch(e._tag){case"Never":return ZA();case"Declaration":case"Null":case"Undefined":case"Void":case"Unknown":case"Any":case"String":case"Number":case"Boolean":case"BigInt":case"Symbol":case"Literal":case"UniqueSymbol":case"ObjectKeyword":case"Enum":case"TemplateLiteral":return ee;case"Arrays":{let r=e.elements.map((i,a)=>Ta(i,[...t,a])),o=e.elements.length,s=e.rest.map((i,a)=>Ta(i,[...t,o+a]));return dn((i,a)=>{if(!Array.isArray(i)||!Array.isArray(a))return!1;let c=i.length;if(c!==a.length)return!1;let u=0;for(;u<Math.min(c,e.elements.length);u++)if(!r[u](i[u],a[u]))return!1;if(s.length>0){let[l,...f]=s;for(;u<c-f.length;u++)if(!l(i[u],a[u]))return!1;for(let d=0;d<f.length;d++)if(!f[d](i[u+d],a[u+d]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return ee;let r=e.propertySignatures.map((s)=>Ta(s.type,[...t,s.name])),o=e.indexSignatures.map((s)=>Ta(s.type,t));return dn((s,i)=>{if(!Dn(s)||!Dn(i))return!1;for(let a=0;a<r.length;a++){let c=e.propertySignatures[a],u=c.name,l=Object.hasOwn(s,u),f=Object.hasOwn(i,u);if(Mt(c.type)){if(l!==f)return!1}if(l&&f&&!r[a](s[u],i[u]))return!1}for(let a=0;a<o.length;a++){let c=e.indexSignatures[a],u=Nc(s,c.parameter),l=Nc(i,c.parameter);if(u.length!==l.length)return!1;for(let f=0;f<u.length;f++){let d=u[f];if(!Object.hasOwn(i,d)||!o[a](s[d],i[d]))return!1}}return!0})}case"Union":{let r=Tn(e).types,o=new Map(r.map((s,i)=>[s,[Lp(s),Ta(e.types[i],t)]]));return dn((s,i)=>{let a=Cp(s,r);for(let c=0;c<a.length;c++){let[u,l]=o.get(a[c]);if(u(s)&&u(i))return l(s,i)}return!1})}case"Suspend":{let r=Lc(()=>Ta(e.thunk(),t));return dn((o,s)=>r()(o,s))}}}var $U;var UU=v(()=>{Pt();Ws();ne();ge();bi();Gx();ya();$U=bn((e)=>Ta(e,[]))});function jc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Vl(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function BU(e,t){return e===t||e===(t.endsWith("#")?t.slice(0,-1):`${t}#`)}function jU(e){return{dialect:"draft-07",..._9(e,L9)}}function k9(e,t){return n(e,!1,!0);function n(r,o,s=!1){if(!Dn(r))return r;let i=o||!s&&VU(r.$id),a={};for(let c of Object.keys(r)){let u=r[c],l=u;switch(c){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":l=Bv(u,(f)=>n(f,i))??u;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":l=Array.isArray(u)?u.map((f)=>n(f,i)):u;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":l=n(u,i)}H(a,c,l)}return t(a,i),a}}function qU(e,t){return k9(e,(n)=>{C9(n,t)})}function C9(e,t){if(typeof e.$ref==="string")H(e,"$ref",t(e.$ref,"$ref"));if(typeof e.$dynamicRef==="string")H(e,"$dynamicRef",t(e.$dynamicRef,"$dynamicRef"))}function Bv(e,t){if(!Dn(e))return;let n={};for(let r of Object.keys(e))H(n,r,t(e[r],r));return n}function v9(e,t,n){let r=new Map,o=[],s=Lv;function i(d,m=[],y=[]){if(m.length===0&&t?.trackIds){let b=Dn(d)?l(d):void 0;s=HU(b,Lv)??Lv}return u(d,m,y,{sourceRoot:[],targetRoot:[],uri:s})}function a(){for(let[d,m,y]of o){let b=m,E=zU(m,y);if(E!==void 0){let w=I9(E.hash);if(E.hash="",w!==void 0){let k=r.get(WU(E.href,w));if(k!==void 0)b=A9(m,k)}}H(d,"$ref",b)}}let c=n(i);return a(),c;function u(d,m,y,b){if(typeof d==="boolean")return f(m,y,b),t?.booleanAdapter?.(d)??d;if(!Dn(d))return d;let E=b,w=l(d);if(m.length>0&&t?.trackIds&&VU(w)){let x=HU(w,b.uri);if(x!==void 0)E={parent:b,sourceRoot:m,targetRoot:y,uri:x}}f(m,y,E);let k=E.uri,g={isDocumentRoot:m.length===0,schema(x,S,C=S){return u(x,[...m,S],[...y,C],E)},schemaAt(x,S,C){return u(x,[...m,...S],[...y,...C],E)},schemaArray(x,S,C=S){return Array.isArray(x)?x.map((I,_)=>u(I,[...m,S,String(_)],[...y,C,String(_)],E)):x},schemaMap(x,S,C=S){if(!Dn(x))return x;return Bv(x,(I,_)=>u(I,[...m,S,_],[...y,C,_],E))},reference(x,S){if(typeof S==="string")o.push([x,S,k]);else H(x,"$ref",S)}};return e(d,g)}function l(d){return t?.ignoreRefSiblings===!0&&typeof d.$ref==="string"?void 0:d.$id}function f(d,m,y){if(y.parent!==void 0)f(d,m,y.parent);r.set(WU(y.uri,d.slice(y.sourceRoot.length)),m.slice(y.targetRoot.length))}}function zU(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function HU(e,t){if(typeof e!=="string")return;let n=zU(e,t);if(n===void 0)return;return n.hash="",n.href}function I9(e){if(e.length===0)return[];let t;try{t=decodeURIComponent(e.slice(1))}catch{return}if(!t.startsWith("/"))return;return/~(?:[^01]|$)/.test(t)?void 0:t.slice(1).split("/").map(Vl)}function A9(e,t){let n=e.indexOf("#");if(n===-1&&t.length===0)return e;return`${n===-1?e:e.slice(0,n)}${T9(t)}`}function T9(e){return e.length===0?"#":`#/${e.map((t)=>encodeURI(jc(t)).replace(/#/g,"%23")).join("/")}`}function WU(e,t){return`${e}\x00${JSON.stringify(t)}`}function VU(e){return typeof e==="string"&&e.length>0&&e[0]!=="#"}function _9(e,t,n){return v9(t,{...n,trackIds:!0},(r)=>({schema:r(e.schema),definitions:Bv(e.definitions,(o,s)=>r(o,["$defs",s],["definitions",s]))}))}function F9(e,t,n,r,o,s=O9){let i;if(s.has(t))i=r.schemaMap(n,t);else if(P9.has(t))i=r.schemaArray(n,t);else if(o.has(t))i=r.schema(n,t);else return!1;return H(e,t,i),!0}function qc(e,t,n){throw Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${n}`)}function N9(e,t,n,r){for(let o of t)if(Object.hasOwn(e,o))qc(o,n,`it is not active in ${r} but would become active in the target`)}function U9(e,t,n,r,o){if(n.isDocumentRoot)H(e,"$schema",BU(t,LU)?r:t);else if(!BU(t,LU))qc("$schema",o,"an embedded resource cannot declare a different dialect")}function L9(e,t){N9(e,$9,"Draft-07","Draft 2020-12");let n={},r=void 0,o=void 0,s=void 0;for(let i of Object.keys(e)){let a=e[i];if(F9(n,i,a,t,R9))continue;switch(i){case"$ref":r=a;break;case"$schema":U9(n,a,t,w9,"Draft-07");break;case"$id":case"$anchor":break;case"$defs":H(n,"definitions",t.schemaMap(a,i,"definitions"));break;case"prefixItems":o=a;break;case"items":s=a;break;case"dependentRequired":case"dependentSchemas":case"minContains":case"maxContains":break;case"$dynamicRef":case"$dynamicAnchor":case"$vocabulary":case"unevaluatedProperties":case"unevaluatedItems":qc(i,"Draft-07","the target dialect has no equivalent");case"required":if(Array.isArray(a)&&a.length===0)break;H(n,i,a);break;default:H(n,i,a)}}if(B9(n,o,s,t),Object.hasOwn(e,"contains")){let{minContains:i,maxContains:a}=e;if(i!==void 0&&i!==1||a!==void 0)qc("minContains/maxContains","Draft-07","contains cardinality cannot be represented");if(Object.hasOwn(e,"minContains"))H(n,"minContains",i)}else{if(Object.hasOwn(e,"minContains"))H(n,"minContains",e.minContains);if(Object.hasOwn(e,"maxContains"))H(n,"maxContains",e.maxContains)}return W9(e,n,t,"draft-07"),q9(e,n,"$id","Draft-07"),H9(n,r,t),n}function B9(e,t,n,r){if(t===void 0){if(n!==void 0)H(e,"items",r.schema(n,"items"));return}if(H(e,"items",r.schemaArray(t,"prefixItems","items")),n!==void 0)H(e,"additionalItems",r.schema(n,"items","additionalItems"))}function H9(e,t,n){if(t===void 0)return;if(typeof t==="string"&&Object.keys(e).length>0){let r={};n.reference(r,t),j9(e,r)}else n.reference(e,t)}function W9(e,t,n,r){let o=Dn(e.dependentRequired)?e.dependentRequired:void 0,s=Dn(e.dependentSchemas)?e.dependentSchemas:void 0;if(o===void 0&&s===void 0)return;let i={},a=new Set([...Object.keys(o??{}),...Object.keys(s??{})]);for(let c of a){let u=o?.[c],l=s?.[c],f=r==="draft-04"&&Array.isArray(u)&&u.length===0;if(l===void 0){if(!f)H(i,c,u)}else if(u===void 0||f)H(i,c,n.schemaAt(l,["dependentSchemas",c],["dependencies",c]));else H(i,c,{allOf:[n.schemaAt(l,["dependentSchemas",c],["dependencies",c,"allOf","0"]),{required:u}]})}if(Object.keys(i).length>0)H(t,"dependencies",i)}function j9(e,t){if(Array.isArray(e.allOf))e.allOf.push(t);else H(e,"allOf",[t])}function q9(e,t,n,r){let{$id:o,$anchor:s}=e;if(s===void 0){if(o!==void 0)H(t,n,o);return}if(typeof s!=="string"||!M9.test(s))qc("$anchor",r,"the anchor is not valid");if(!D9.test(s))qc("$anchor",r,"the anchor cannot be represented as a plain-name fragment identifier");if(o===void 0)H(t,n,`#${s}`);else qc("$anchor",r,"it cannot be combined with the schema $id")}var w9="http://json-schema.org/draft-07/schema#",LU="https://json-schema.org/draft/2020-12/schema",Lv="https://effect.invalid/.json-schema/",O9,P9,R9,KU,bxe,wxe,M9,D9,$9;var Hv=v(()=>{ge();O9=new Set(["properties","patternProperties"]),P9=new Set(["allOf","anyOf","oneOf"]),R9=new Set(["not","additionalProperties","propertyNames","contains","if","then","else","contentSchema"]);KU=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"],bxe=[...KU,"deprecated"],wxe=[...KU,"$comment","$id","$schema","const","contains","contentEncoding","contentMediaType","else","examples","if","patternProperties","propertyNames","then"],M9=/^[A-Za-z_][-A-Za-z0-9._]*$/,D9=/^[A-Za-z][-A-Za-z0-9._:]*$/;$9=["additionalItems","definitions","dependencies"]});var kxe,Kl=(e)=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");var Wv=v(()=>{kxe=globalThis.RegExp});function qp(e,t){if(e===void 0)return;let n={},r=e.title;if(typeof r==="string")n.title=r;let{description:o,expected:s}=e;if(typeof o==="string")n.description=o;else if(t?.generateDescriptions===!0&&typeof s==="string")n.description=s;let i=e.default;if(Ul(i))n.default=i;let a=e.examples;if(Array.isArray(a)&&Ul(a))n.examples=a;let c=e.readOnly;if(typeof c==="boolean")n.readOnly=c;let u=e.writeOnly;if(typeof u==="boolean")n.writeOnly=u;let l=e.format;if(typeof l==="string")n.format=l;let f=e.contentEncoding;if(typeof f==="string")n.contentEncoding=f;let d=e.contentMediaType;if(typeof d==="string")n.contentMediaType=d;let m=e.contentSchema;if(Ul(m))n.contentSchema=m;if(t?.includeAnnotationKey!==void 0)for(let[y,b]of Object.entries(e)){if(V9.has(y)||!t.includeAnnotationKey(y))continue;if(Ul(b))H(n,y,b)}return Object.keys(n).length===0?void 0:n}function QU(e){let t=e.type==="number"||e.type==="integer"?e.type:void 0,n=e;if(t!==void 0)n={...e},delete n.type;if(Array.isArray(n.allOf)){let r=[],o=!1;for(let s of n.allOf){let i=QU(s);if(i.type!==void 0){if(o=!0,t===void 0||i.type==="integer")t=i.type}if(Object.keys(i.schema).length>0)r.push(i.schema)}if(o){let{allOf:s,...i}=n;n=r.length===0?i:{...i,allOf:r}}}return{type:t,schema:n}}function K9(e){return Array.isArray(e.anyOf)&&e.anyOf.length===4&&e.anyOf[0]?.type==="number"&&e.anyOf.slice(1).every((t)=>t.type==="string")}function jv(e,t){return Object.keys(e).every((n)=>t.includes(`|${n}|`))}function JU(e,t){return typeof e.$ref!=="string"&&t.every((n)=>!Object.hasOwn(e,n))}function zp(e,t,n){if(Object.keys(e).length===0)return t;let r=Object.keys(t);if(r.length===0)return e;let o=e.type==="number"||e.type==="integer"?e.type:void 0,s=K9(e);if(o!==void 0||s){let a=QU(t);if(a.type!==void 0){let c=o==="integer"||a.type==="integer"?"integer":"number",u={...e,type:c};if(s)delete u.anyOf;let l=Object.keys(a.schema);if(l.length===0)return u;return jv(a.schema,qv)&&JU(u,l)?{...u,...a.schema}:zp(u,a.schema,n)}}if(n&&JU(e,r))return{...e,...t};let i=Array.isArray(t.allOf)&&r.length===1?t.allOf:[t];if(Array.isArray(e.allOf))return{...e,allOf:[...e.allOf,...i]};if(typeof e.$ref==="string")return{allOf:[e,...i]};return{...e,allOf:i}}function J9(e,t,n,r){let o=new Map,s=new WeakMap,i=new Map,a=!1,c=Object.keys(n);for(let g of c)f(g,["references",g]);let u=sn(e,(g,x)=>d(E(g,t[x]))),l={};for(let g of c){let x=o.get(g);if(typeof x!=="string")H(l,g,d(x))}return{dialect:"draft-2020-12",schemas:u,definitions:l};function f(g,x){let S=o.get(g);if(S!==void 0)return typeof S==="string"?S:g;if(!Object.hasOwn(n,g))throw ws(`Invalid reference ${g}`,[...x,"$ref"]);o.set(g,null);let C=n[g],I=E(C,["references",g]),_=m(C);if(_!==void 0){let M=i.get(_),U=M?.find((N)=>ee(o.get(N),I));if(U===void 0)if(M===void 0)i.set(_,[g]);else M.push(g);else return a=!0,o.set(g,U),U}return o.set(g,I),g}function d(g){if(!a)return g;return qU(g,(x)=>x.replace(/^#\/\$defs\/([^/]*)/,(S,C)=>{let I=o.get(Vl(C));return typeof I==="string"?`#/$defs/${jc(I)}`:S}))}function m(g){if(g._tag==="Reference")return;let x=g.checks.length===0?g.annotations:g.checks[g.checks.length-1].annotations;return typeof x?.identifier!=="string"&&typeof x?.[Pc]==="string"?x[Pc]:void 0}function y(g,x){return g?.schemas?.map((S,C)=>E(S,[...x,"schemas",C]))??[]}function b(g,x,S){let C=g.annotations,I=C?.toJsonSchema;if(I!==void 0){let N=y(g.representation,[...S,"representation"]),Z=I({type:x,schemas:N}),G=qp(C,r),ye=G===void 0?Z:{...Z,...G},Wt=G===void 0?ZU:G9;return g._tag==="Filter"&&jv(ye,Wt)&&(G===void 0||jv(G,qv))?[ye,!0]:[ye]}if(g._tag==="Filter")return;let _=g.checks.map((N,Z)=>b(N,x,[...S,"checks",Z])).filter((N)=>N!==void 0);if(_.length===0)return;let M=qp(C,r),U=_.map(([N])=>N);return[M===void 0?{allOf:U}:{allOf:U,...M}]}function E(g,x){if(g._tag==="Reference"){let _=f(g.$ref,x);return{$ref:`#/$defs/${jc(_)}`}}let S=s.get(g);if(S!==void 0)return S;let C=w(g,x),I=qp(g.annotations,r);if(I!==void 0)C={...C,...I};for(let _=0;_<g.checks.length;_++){let M=typeof C.type==="string"&&Q9(C.type)?C.type:void 0,U=b(g.checks[_],M,[...x,"checks",_]);if(U!==void 0)C=zp(C,...U)}return s.set(g,C),C}function w(g,x){switch(g._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":case"UniqueSymbol":return{type:"string",allOf:[{pattern:"^Symbol\\((.*)\\)$"}]};case"Declaration":return{};case"Suspend":return E(g.thunk,[...x,"thunk"]);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN"]},{type:"string",enum:["Infinity"]},{type:"string",enum:["-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let S=g.literal;return typeof S==="bigint"?{type:"string",enum:[globalThis.String(S)]}:{type:typeof S,enum:[S]}}case"Enum":{let S=g.enums.map(([C,I])=>typeof I==="number"&&!globalThis.Number.isFinite(I)?{type:"string",enum:[globalThis.String(I)],title:C}:{type:typeof I,enum:[I],title:C});return S.length===0?{not:{}}:{anyOf:S}}case"TemplateLiteral":return{type:"string",pattern:`^${g.parts.map(Xx).join("")}$`};case"Arrays":{if(g.rest.length>1)throw ws("Invalid schema representation document",[...x,"rest"]);let S={type:"array"},C=g.elements.length,I=g.elements.map((_,M)=>{if(_.isOptional)C--;let U=E(_.type,[...x,"elements",M,"type"]),N=qp(_.annotations,r);return N===void 0?U:zp(U,N)});if(I.length>0){if(S.prefixItems=I,S.maxItems=g.elements.length,C>0)S.minItems=C}else S.items=!1;if(g.rest.length===1){delete S.maxItems;let _=E(g.rest[0],[...x,"rest",0]);if(Object.keys(_).length>0)S.items=_;else delete S.items}return S}case"Objects":{if(g.propertySignatures.length===0&&g.indexSignatures.length===0)return{anyOf:[{type:"object"},{type:"array"}]};let S={type:"object"},C={},I=[];for(let N=0;N<g.propertySignatures.length;N++){let Z=g.propertySignatures[N];if(typeof Z.name!=="string")throw ws("Invalid schema representation document",[...x,"propertySignatures",N,"name"]);let G=Z.name,ye=E(Z.type,[...x,"propertySignatures",N,"type"]),Wt=qp(Z.annotations,r);if(H(C,G,Wt===void 0?ye:zp(ye,Wt)),!Z.isOptional)I.push(G)}if(g.propertySignatures.length>0)S.properties=C;if(I.length>0)S.required=I;let _={},M=[];for(let N=0;N<g.indexSignatures.length;N++){let Z=g.indexSignatures[N],G=E(Z.type,[...x,"indexSignatures",N,"type"]);if(Object.keys(G).length===1&&"not"in G)G=!1;let ye=k(Z.parameter,[...x,"indexSignatures",N,"parameter"],new Set);if(ye.length===0)M.push(G);else for(let Wt of ye){let $i=_[Wt];H(_,Wt,$i===void 0?G:$i===!1||G===!1?!1:zp($i,G))}}let U=Object.keys(_).length>0;if(U)S.patternProperties=_;if(g.indexSignatures.length===0)S.additionalProperties=r?.additionalProperties??!1;else if(M.length===1&&g.propertySignatures.length===0&&!U)S.additionalProperties=M[0];else if(M.length>0)S.allOf=M.map((N)=>({type:"object",additionalProperties:N}));if(typeof S.additionalProperties==="object"&&S.additionalProperties!==null&&Object.keys(S.additionalProperties).length===0)delete S.additionalProperties;return S}case"Union":{let S=g.types.map((C,I)=>E(C,[...x,"types",I]));if(S.length===0)return{not:{}};if(g.mode==="anyOf"&&S.length>1){let C=Z9(S);if(C!==void 0)return C}return g.mode==="anyOf"?{anyOf:S}:{oneOf:S}}}}function k(g,x,S){switch(g._tag){case"Reference":{if(!Object.hasOwn(n,g.$ref))throw ws(`Invalid reference ${g.$ref}`,[...x,"$ref"]);if(f(g.$ref,x),S.has(g.$ref))return[];let C=new Set(S).add(g.$ref);return k(n[g.$ref],["references",g.$ref],C)}case"String":return YU(E(g,x));case"TemplateLiteral":return[`^${g.parts.map(Xx).join("")}$`];case"Union":return g.types.flatMap((C,I)=>k(C,[...x,"types",I],S));default:throw ws("Invalid schema representation document",x)}}}function Q9(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}function Z9(e){let t=void 0,n=[];for(let r of e){if(Object.keys(r).length!==2||r.type===void 0||!Array.isArray(r.enum)||r.enum.length===0)return;if(t===void 0)t=r.type;else if(r.type!==t)return;n.push(...r.enum)}return{type:t,enum:n}}function YU(e){let t=[];if(typeof e.pattern==="string")t.push(e.pattern);for(let n of["allOf","anyOf","oneOf"]){let r=e[n];if(Array.isArray(r)){for(let o of r)if(typeof o==="object"&&o!==null&&!Array.isArray(o))t.push(...YU(o))}}return t}function Xx(e){switch(e._tag){case"Literal":return Kl(globalThis.String(e.literal));case"String":return EN;case"Number":return hx;case"TemplateLiteral":return e.parts.map(Xx).join("");case"Union":return e.types.map(Xx).join("|");default:throw ws("Invalid schema representation document",[])}}function XU(e,t){let n=J9([e.representation],[["representation"]],e.references,t);return{dialect:n.dialect,schema:n.schemas[0],definitions:n.definitions}}var V9,ZU="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|",qv="|title|description|default|examples|readOnly|writeOnly|",G9;var e2=v(()=>{nr();Pt();Hv();Wv();bi();$v();ya();V9=new Set([...uM,Pc,...aM]);G9=ZU+qv});function Go(e){return e===void 0?void 0:{annotations:e}}function zv(e,t){let{references:n,representations:r}=eY([e],t);return{representation:r[0],references:n}}function eY(e,t){let n={},r=new Map,o=new Set,s=new Map,i=new Set;for(let S of e)m(S);let a=t?.referencePolicy??X9;for(let S of s.values())for(let C of S.values()){let I=a({ast:C.ast,occurrences:C.occurrences,identifier:C.identifier});if(I!==void 0){let _=I===C.identifier||!I.endsWith("_")?"_":"";C.reference=u(I,C,_)}else if(C.isRecursive)C.reference=u(`${C.ast._tag}_`,C,"")}return{representations:sn(e,(S)=>b(S)),references:n};function u(S,C,I="_"){let _=S,M=0;while(r.has(_)){if(r.get(_)===C)return _;_=`${S}${I}${++M}`}return r.set(_,C),_}function l(S,C,I){let _=C.fallback;if(_!==void 0)return Bk(S)===_?S:xo(S,{[Pc]:_});return I===C.identifier?S:xo(S,{identifier:I})}function f(S,C){if(!Object.hasOwn(n,S)&&!o.has(S)){o.add(S);let I=E(C);o.delete(S),H(n,S,I)}return{_tag:"Reference",$ref:S}}function d(S){let C=Tp(S),I=zC(C),_=vl(C),M=_===void 0?(C!==S?vl(S):void 0)??Bk(C):void 0;if(M!==void 0)_=`${M}Encoded`;let U=s.get(I);if(U===void 0)U=new Map,s.set(I,U);let N=U.get(_);if(N===void 0)N={ast:I,identifier:_,fallback:M,occurrences:0,isRecursive:!1,reference:void 0},U.set(_,N);return N}function m(S){let C=d(S),I=C.ast;if(C.occurrences++,i.has(C)){C.isRecursive=!0;return}if(C.occurrences>1)return;switch(i.add(C),y(I.checks),I._tag){case"Declaration":case"Arrays":case"Objects":case"Union":I.recur((_)=>(m(_),_));break;case"TemplateLiteral":I.parts.forEach(m);break;case"Suspend":m(I.thunk());break}i.delete(C)}function y(S){S?.forEach((C)=>{if(C.annotations?.representation?.schemas?.forEach((I)=>m(Tn(I))),C._tag==="FilterGroup")y(C.checks)})}function b(S){let C=d(S),I=C.ast,_=C.reference;if(_!==void 0){let M=C.identifier===void 0?I:l(I,C,_);return f(_,M)}return E(I)}function E(S){let C=w(S.checks);switch(S._tag){case"Declaration":return{_tag:"Declaration",typeParameters:S.typeParameters.map((I)=>b(I)),checks:C,...g(S.annotations)};case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"String":case"Boolean":case"Number":case"BigInt":case"Symbol":case"ObjectKeyword":return{_tag:S._tag,checks:C,...Go(S.annotations)};case"Literal":return{_tag:"Literal",literal:S.literal,checks:C,...Go(S.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:S.symbol,checks:C,...Go(S.annotations)};case"Enum":return{_tag:"Enum",enums:S.enums,checks:C,...Go(S.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:S.parts.map((I)=>b(I)),checks:C,...Go(S.annotations)};case"Arrays":return{_tag:"Arrays",elements:S.elements.map((I)=>{let _=Tp(I),M=_.context?.annotations;return{isOptional:Mt(_),type:b(I),...Go(M)}}),rest:S.rest.map((I)=>b(I)),checks:C,...Go(S.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:S.propertySignatures.map((I)=>{let _=Tp(I.type),M=_.context?.annotations;return{name:I.name,type:b(I.type),isOptional:Mt(_),isMutable:hN(_),...Go(M)}}),indexSignatures:S.indexSignatures.map((I)=>({parameter:b(I.parameter),type:b(I.type)})),checks:C,...Go(S.annotations)};case"Union":return{_tag:"Union",types:S.types.map((I)=>b(I)),mode:S.mode,checks:C,...Go(S.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:b(S.thunk()),...Go(S.annotations)}}}function w(S){return S?.map(k)??[]}function k(S){switch(S._tag){case"Filter":return{_tag:"Filter",aborted:S.aborted,...x(S.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:sn(S.checks,k),...x(S.annotations)}}}function g(S){if(S===void 0)return;let{representation:C,...I}=S;return{...C===void 0?void 0:{representation:C},...Object.keys(I).length===0?void 0:{annotations:I}}}function x(S){if(S===void 0)return;let{representation:C,...I}=S,_=C===void 0?void 0:C.schemas===void 0?C:{...C,schemas:C.schemas.map((M)=>b(Tn(M)))};return{..._===void 0?void 0:{representation:_},...Object.keys(I).length===0?void 0:{annotations:I}}}}var X9=({identifier:e})=>e;var t2=v(()=>{nr();bi();ya()});function r2(e,t){let n=[];return Vv(e,t,"",n),n}function Vv(e,t,n,r){if(Object.is(e,t))return;if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,s=t.length,i=Math.min(o,s);for(let a=0;a<i;a++)Vv(e[a],t[a],`${n}/${a}`,r);for(let a=o-1;a>=s;a--)r.push({op:"remove",path:`${n}/${a}`});for(let a=o;a<s;a++)r.push({op:"add",path:`${n}/${a}`,value:t[a]});return}if(ey(e)&&ey(t)){let o=Object.keys(e),s=Object.keys(t),i=Array.from(new Set([...o,...s])).sort();for(let a of i){let c=`${n}/${jc(a)}`,u=Object.hasOwn(e,a),l=Object.hasOwn(t,a);if(u&&l)Vv(e[a],t[a],c,r);else if(!u&&l)r.push({op:"add",path:c,value:t[a]});else r.push({op:"remove",path:c})}return}r.push({op:"replace",path:n,value:t})}function o2(e,t){let n=t;for(let r of e)n=rY(n,r);return n}function ey(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function nY(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(Vl)}function s2(e){if(!/^(0|[1-9]\d*)$/.test(e))throw Error(`Invalid array index: "${e}"`);return Number(e)}function rY(e,t){if(t.path===""){if(t.op==="remove")throw Error("Unsupported operation at the root");return t.value}let n=oY(e,t.path);if(n===null)throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:r,parent:o,stack:s}=n;if(Array.isArray(o)){if(r==="-"&&t.op!=="add")throw Error(`"-" is not valid for ${t.op} at "${t.path}".`);let i=r==="-"?o.length:s2(r),a=t.op==="add"?o.length:o.length-1;if(i>a)throw Error(`Array index out of bounds at "${t.path}".`);let c=o.slice();if(t.op==="add")c.splice(i,0,t.value);else if(t.op==="remove")c.splice(i,1);else c[i]=t.value;return n2(s,c)}if(ey(o)){if(t.op!=="add"&&!Object.hasOwn(o,r))throw Error(`Property "${r}" does not exist at "${t.path}".`);let i={...o};if(t.op==="remove")delete i[r];else H(i,r,t.value);return n2(s,i)}throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function oY(e,t){let n=nY(t);if(n.length===0)return null;let r=n[n.length-1],o=[],s=e;for(let i=0;i<n.length-1;i++){let a=n[i];if(Array.isArray(s)){let c=s2(a);if(c>=s.length)return null;o.push({container:s,token:c}),s=s[c];continue}if(ey(s)){if(!Object.hasOwn(s,a))return null;o.push({container:s,token:a}),s=s[a];continue}return null}return{stack:o,parent:s,lastToken:r}}function n2(e,t){let n=t;for(let r=e.length-1;r>=0;r--){let{container:o,token:s}=e[r];if(Array.isArray(o)){let i=o.slice();i[s]=n,n=i}else{let i={...o};H(i,s,n),n=i}}return n}var i2=()=>{};function u2(e,t){return Jo(Gl("Iso",e,t))}function a2(e,t){return Jo(Gl("Lens",e,t))}function Gl(e,t,n){return[{_tag:"PrimitiveNode",kind:e,get:t,set:n}]}class Gv{_tag="PathNode";kind="Lens";path;get;set;constructor(e){this.path=e,this.get=(t)=>{let n=t;for(let r=0;r<e.length;r++)n=n[e[r]];return n},this.set=(t,n)=>{let r=ny(n),o=r,s=0;for(;s<e.length-1;s++){let i=e[s];H(o,i,ny(o[i])),o=o[i]}return H(o,e[s],t),r}}}class ty{_tag="CheckNode";kind="Prism";checks;get;set=L;constructor(e){this.checks=e,this.get=(t)=>kN(e,t)}}function zc(e,t){if(e.length===0)return t;if(t.length===0)return e;let n=e.slice();for(let r=0;r<t.length;r++){let o=t[r],s=n[n.length-1];if(s._tag==="PathNode"&&o._tag==="PathNode")n[n.length-1]=new Gv([...s.path,...o.path]);else if(s._tag==="CheckNode"&&o._tag==="CheckNode")n[n.length-1]=new ty([...s.checks,...o.checks]);else n.push(o)}return n}function aY(e,t){return Jo(Gl("Optional",e,t))}class Vp{node;getResult;replaceResult;constructor(e,t,n){this.node=e,this.getResult=t,this.replaceResult=n}replace(e,t){return Ji(this.replaceResult(e,t),()=>t)}modify(e){return(t)=>Ji(Qi(this.getResult(t),(n)=>this.replaceResult(e(n),t)),()=>t)}compose(e){return Jo(zc(this.node,e.node))}key(e){return Jo(zc(this.node,[new Gv([e])]))}optionalKey(e){return Jo(zc(this.node,Gl("Lens",(t)=>t[e],(t,n)=>{let r=ny(n);if(t===void 0)if(Array.isArray(r)&&typeof e==="number")r.splice(e,1);else delete r[e];else H(r,e,t);return r})))}check(...e){return Jo(zc(this.node,[new ty(e)]))}refine(e,t){return Jo(zc(this.node,[new ty([kx(e,t)])]))}tag(e){let t=oe(new Ie({expected:`${JSON.stringify(e)} tag`}));return Jo(zc(this.node,Gl("Prism",(n)=>n._tag===e?J(n):t,L)))}at(e,...t){let n=oe(new Jt([e],new Fc(void 0)));return Jo(zc(this.node,Gl("Optional",(r)=>Object.hasOwn(r,e)?J(r[e]):n,(r,o)=>{if(Object.hasOwn(o,e)){let s=ny(o);return H(s,e,r),J(s)}else return n})))}pick(e){return this.compose(a2(mU(e),(t,n)=>({...n,...t})))}omit(e){return this.compose(a2(hU(e),(t,n)=>({...n,...t})))}notUndefined(){return this.refine(Ve,{expected:"a value other than `undefined`"})}forEach(e){let t=e(ry());return aY((n)=>Dr(this.getResult(n),(r)=>{let o=[];for(let s=0;s<r.length;s++){let i=t.getResult(r[s]);if(rn(i))o.push(i.success)}return o}),(n,r)=>Qi(this.getResult(r),(o)=>{let s=[];for(let a=0;a<o.length;a++)if(rn(t.getResult(o[a])))s.push(a);if(n.length!==s.length)return oe(new Ie({message:`each: replacement length mismatch: ${n.length} !== ${s.length}`}));let i=o.slice();for(let a=0;a<s.length;a++){let c=s[a],u=t.replaceResult(n[a],o[c]);if(Se(u))return oe(new Jt([c],u.failure));i[c]=u.success}return this.replaceResult(i,r)}))}modifyAll(e){return(t)=>Ji(Qi(this.getResult(t),(n)=>this.replaceResult(n.map(e),t)),()=>t)}}function Jo(e){let t=e[0]??iY;if(e.length>1){let n=e.reduce((r,o)=>lY(r,o.kind),"Iso");t={kind:n,get:cY(e,n),set:uY(e,n)}}switch(t.kind){case"Iso":return new l2(e,t.get,t.set);case"Lens":return new f2(e,t.get,t.set);case"Prism":return new d2(e,t.get,t.set);case"Optional":return new Vp(e,t.get,t.set)}}function ny(e){if(Array.isArray(e))return e.slice();if(typeof e==="object"&&e!==null){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}function cY(e,t){return(n)=>{for(let r=0;r<e.length;r++){let o=e[r],s=o.get(n);if(Kv(o.kind)){if(Se(s))return s;n=s.success}else n=s}return Kv(t)?J(n):n}}function uY(e,t){if(c2(t))return(n)=>{for(let r=e.length-1;r>=0;r--)n=e[r].set(n);return n};return(n,r)=>{let o=e.length,s=Array(o);for(let i=0;i<o;i++){s[i]=r;let a=e[i];if(Kv(a.kind)){let c=a.get(r);if(Se(c))return c;r=c.success}else r=a.get(r)}for(let i=o-1;i>=0;i--){let a=e[i];if(c2(a.kind))n=a.set(n);else if(a.kind==="Lens")n=a.set(n,s[i]);else{let c=a.set(n,s[i]);if(Se(c))return c;n=c.success}}return t==="Optional"?J(n):n}}function Kv(e){return e==="Prism"||e==="Optional"}function c2(e){return e==="Iso"||e==="Prism"}function lY(e,t){if(e==="Iso")return t;if(t==="Iso"||e===t)return e;return"Optional"}function ry(){return fY}var iY,l2,f2,d2,fY;var p2=v(()=>{ne();ge();Bn();bi();Ea();Qx();iY={kind:"Iso",get:L,set:L};l2=class l2 extends Vp{get;set;constructor(e,t,n){super(e,(r)=>J(t(r)),(r)=>J(n(r)));this.get=t,this.set=n}replace(e,t){return this.set(e)}modify(e){return(t)=>this.set(e(this.get(t)))}};f2=class f2 extends Vp{get;constructor(e,t,n){super(e,(r)=>J(t(r)),(r,o)=>J(n(r,o)));this.get=t,this.replace=n}modify(e){return(t)=>this.replace(e(this.get(t)),t)}};d2=class d2 extends Vp{set;constructor(e,t,n){super(e,t,(r,o)=>J(n(r)));this.set=n}replace(e,t){return this.set(e)}modify(e){return(t)=>Ji(Dr(this.getResult(t),(n)=>this.set(e(n))),()=>t)}};fY=Jo([])});var Vc,m2=(e)=>{if(Vc.has(e))return Vc.get(e);else throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var h2=v(()=>{Vc=new WeakMap});var g2="~effect/data/Redacted",Jv=(e)=>D(e,g2),Ci=(e,t)=>{let n=Object.create(mY);if(t?.label)n.label=t.label;return Vc.set(n,e),n},mY,_a,x2=(e)=>dn((t,n)=>e(_a(t),_a(n)));var Kp=v(()=>{Pt();Ws();wn();pt();h2();ge();mY={[g2]:{_A:(e)=>e},label:void 0,...Xn,toJSON(){return this.toString()},toString(){return`<redacted${_o(this.label)?":"+this.label:""}>`},[_e](){return ie(Vc.get(this))},[Oe](e){return Jv(e)&&ee(Vc.get(this),Vc.get(e))}},_a=m2});var O={};Qn(O,{Any:()=>zY,Array:()=>je,ArrayEnsure:()=>n7,BigDecimal:()=>hI,BigDecimalFromString:()=>YX,BigDecimalReviver:()=>ZX,BigInt:()=>ks,BigIntFromString:()=>cee,Boolean:()=>ly,BooleanFromBit:()=>hee,Cause:()=>iy,CauseReason:()=>sy,CauseReasonReviver:()=>wX,CauseReviver:()=>kX,Char:()=>uX,Chunk:()=>fB,ChunkReviver:()=>NX,Class:()=>AB,Date:()=>vr,DateFromMillis:()=>WX,DateFromString:()=>HX,DateReviver:()=>BX,DateTimeUtc:()=>cm,DateTimeUtcFromDate:()=>bee,DateTimeUtcFromMillis:()=>kee,DateTimeUtcFromString:()=>wee,DateTimeUtcReviver:()=>Eee,DateTimeZoned:()=>bI,DateTimeZonedFromString:()=>Oee,DateTimeZonedReviver:()=>_ee,Defect:()=>pI,Duration:()=>im,DurationFromMillis:()=>VX,DurationFromNanos:()=>zX,DurationFromString:()=>hB,DurationReviver:()=>jX,Enum:()=>jY,Error:()=>xy,ErrorInstance:()=>nB,ErrorInstanceReviver:()=>IX,Exit:()=>rB,ExitReviver:()=>AX,File:()=>gI,FileReviver:()=>tee,Finite:()=>Cr,FiniteFromString:()=>aee,FormData:()=>xI,FormDataReviver:()=>nee,Graph:()=>aB,GraphReviver:()=>RX,HashMap:()=>cB,HashMapReviver:()=>FX,HashSet:()=>lB,HashSetReviver:()=>DX,Int:()=>Cs,Json:()=>fm,JsonObject:()=>mte,JsonReviver:()=>hte,Literal:()=>et,Literals:()=>Ti,MutableJson:()=>UB,MutableJsonReviver:()=>xte,Natural:()=>_n,Never:()=>qY,NonEmptyArray:()=>t7,NonEmptyString:()=>VL,Null:()=>Le,NullOr:()=>oI,NullishOr:()=>Q2,Number:()=>Yp,NumberFromString:()=>iee,ObjectKeyword:()=>KY,Opaque:()=>g7,Option:()=>Pa,OptionFromNullOr:()=>fX,OptionFromNullishOr:()=>pX,OptionFromOptional:()=>hX,OptionFromOptionalKey:()=>mX,OptionFromOptionalNullOr:()=>gX,OptionFromUndefinedOr:()=>dX,OptionReviver:()=>lX,PropertyKey:()=>Yv,ReadonlyMap:()=>iB,ReadonlyMapReviver:()=>TX,ReadonlySet:()=>uB,ReadonlySetReviver:()=>MX,Record:()=>fy,Redacted:()=>my,RedactedFromValue:()=>bX,RedactedReviver:()=>EX,RegExp:()=>dB,RegExpReviver:()=>$X,Result:()=>KL,ResultReviver:()=>xX,SchemaError:()=>Kc,StandardSchemaV1FailureResult:()=>mee,String:()=>Q,StringFromBase64:()=>lee,StringFromBase64Url:()=>fee,StringFromHex:()=>dee,StringFromUriComponent:()=>pee,Struct:()=>te,StructWithRest:()=>XY,Symbol:()=>K2,TaggedClass:()=>Mee,TaggedError:()=>Qo,TaggedStruct:()=>py,TaggedUnion:()=>h7,TemplateLiteral:()=>HY,TemplateLiteralParser:()=>WY,TimeZone:()=>EI,TimeZoneFromString:()=>Tee,TimeZoneNamed:()=>SI,TimeZoneNamedFromString:()=>Iee,TimeZoneNamedReviver:()=>vee,TimeZoneOffset:()=>wB,TimeZoneOffsetReviver:()=>Cee,TimeZoneReviver:()=>Aee,Tree:()=>pte,Trim:()=>uee,Trimmed:()=>EB,Tuple:()=>Ql,TupleWithRest:()=>e7,URL:()=>gy,URLFromString:()=>LX,URLReviver:()=>UX,URLSearchParams:()=>yI,URLSearchParamsReviver:()=>oee,Uint8Array:()=>am,Uint8ArrayFromBase64:()=>xee,Uint8ArrayFromBase64Url:()=>yee,Uint8ArrayFromHex:()=>See,Uint8ArrayReviver:()=>gee,Undefined:()=>nI,UndefinedOr:()=>dy,Union:()=>kt,UniqueArray:()=>r7,UniqueSymbol:()=>GY,Unknown:()=>tI,UnknownFromJsonString:()=>eee,Void:()=>VY,annotate:()=>gY,annotateEncoded:()=>xY,annotateKey:()=>yY,asserts:()=>wY,brand:()=>Y2,catchDecoding:()=>c7,catchDecodingWithContext:()=>tL,catchEncoding:()=>u7,catchEncodingWithContext:()=>nL,check:()=>s7,declare:()=>Eo,declareConstructor:()=>Ir,decode:()=>l7,decodeEffect:()=>kY,decodeExit:()=>CY,decodeOption:()=>IY,decodePromise:()=>TY,decodeResult:()=>AY,decodeSync:()=>_Y,decodeTo:()=>pe,decodeUnknownEffect:()=>Ai,decodeUnknownExit:()=>$2,decodeUnknownOption:()=>vY,decodeUnknownPromise:()=>L2,decodeUnknownResult:()=>U2,decodeUnknownSync:()=>B2,encode:()=>f7,encodeEffect:()=>H2,encodeExit:()=>OY,encodeKeys:()=>ZY,encodeOption:()=>RY,encodePromise:()=>MY,encodeResult:()=>FY,encodeSync:()=>DY,encodeTo:()=>sI,encodeUnknownEffect:()=>cy,encodeUnknownExit:()=>W2,encodeUnknownOption:()=>PY,encodeUnknownPromise:()=>q2,encodeUnknownResult:()=>j2,encodeUnknownSync:()=>z2,extendTo:()=>YY,fieldsAssign:()=>JY,flip:()=>Qv,fromBrand:()=>a7,fromFormData:()=>ree,fromJsonString:()=>SB,fromURLSearchParams:()=>see,instanceOf:()=>Oa,is:()=>Zp,isBase64:()=>cI,isBase64Reviver:()=>T7,isBase64Url:()=>pL,isBase64UrlReviver:()=>_7,isBetween:()=>om,isBetweenBigDecimal:()=>Z7,isBetweenBigInt:()=>NL,isBetweenBigIntReviver:()=>ate,isBetweenDate:()=>PL,isBetweenDateReviver:()=>nte,isBetweenReviver:()=>W7,isCapitalized:()=>SL,isCapitalizedReviver:()=>D7,isEndsWith:()=>hL,isEndsWithReviver:()=>P7,isFinite:()=>bL,isFiniteReviver:()=>$7,isGUID:()=>fL,isGUIDReviver:()=>I7,isGreaterThan:()=>kL,isGreaterThanBigDecimal:()=>K7,isGreaterThanBigInt:()=>RL,isGreaterThanBigIntReviver:()=>rte,isGreaterThanDate:()=>AL,isGreaterThanDateReviver:()=>Yee,isGreaterThanOrEqualTo:()=>uI,isGreaterThanOrEqualToBigDecimal:()=>G7,isGreaterThanOrEqualToBigInt:()=>FL,isGreaterThanOrEqualToBigIntReviver:()=>ote,isGreaterThanOrEqualToDate:()=>TL,isGreaterThanOrEqualToDateReviver:()=>Xee,isGreaterThanOrEqualToReviver:()=>L7,isGreaterThanReviver:()=>U7,isIncludes:()=>gL,isIncludesReviver:()=>R7,isInt:()=>sm,isInt32:()=>z7,isIntReviver:()=>q7,isLengthBetween:()=>fI,isLengthBetweenReviver:()=>eX,isLessThan:()=>CL,isLessThanBigDecimal:()=>J7,isLessThanBigInt:()=>ML,isLessThanBigIntReviver:()=>ste,isLessThanDate:()=>_L,isLessThanDateReviver:()=>ete,isLessThanOrEqualTo:()=>vL,isLessThanOrEqualToBigDecimal:()=>Q7,isLessThanOrEqualToBigInt:()=>DL,isLessThanOrEqualToBigIntReviver:()=>ite,isLessThanOrEqualToDate:()=>OL,isLessThanOrEqualToDateReviver:()=>tte,isLessThanOrEqualToReviver:()=>H7,isLessThanReviver:()=>B7,isLowercased:()=>yL,isLowercasedReviver:()=>M7,isMaxLength:()=>UL,isMaxLengthReviver:()=>X7,isMaxProperties:()=>jL,isMaxPropertiesReviver:()=>sX,isMaxSize:()=>BL,isMaxSizeReviver:()=>nX,isMinLength:()=>lI,isMinLengthReviver:()=>Y7,isMinProperties:()=>WL,isMinPropertiesReviver:()=>oX,isMinSize:()=>LL,isMinSizeReviver:()=>tX,isMultipleOf:()=>IL,isMultipleOfReviver:()=>j7,isNonEmpty:()=>$L,isPattern:()=>Gc,isPatternReviver:()=>E7,isPropertiesLengthBetween:()=>qL,isPropertiesLengthBetweenReviver:()=>iX,isPropertyNames:()=>zL,isPropertyNamesReviver:()=>aX,isSchema:()=>uy,isSchemaError:()=>R2,isSizeBetween:()=>HL,isSizeBetweenReviver:()=>rX,isStartsWith:()=>mL,isStartsWithReviver:()=>O7,isStringBigInt:()=>cL,isStringBigIntReviver:()=>w7,isStringFinite:()=>aL,isStringFiniteReviver:()=>b7,isStringSymbol:()=>uL,isStringSymbolReviver:()=>k7,isTrimmed:()=>aI,isTrimmedReviver:()=>y7,isULID:()=>dL,isULIDReviver:()=>A7,isUUID:()=>lL,isUUIDReviver:()=>v7,isUint32:()=>V7,isUncapitalized:()=>EL,isUncapitalizedReviver:()=>N7,isUnique:()=>dI,isUniqueReviver:()=>cX,isUppercased:()=>xL,isUppercasedReviver:()=>F7,link:()=>st,make:()=>K,makeFilter:()=>it,makeFilterGroup:()=>x7,makeIsBetween:()=>rm,makeIsGreaterThan:()=>Xp,makeIsGreaterThanOrEqualTo:()=>em,makeIsLessThan:()=>tm,makeIsLessThanOrEqualTo:()=>nm,makeIsMultipleOf:()=>wL,middlewareDecoding:()=>X2,middlewareEncoding:()=>eL,mutable:()=>o7,mutableKey:()=>UY,optional:()=>cr,optionalKey:()=>vi,overrideToCodecIso:()=>fte,overrideToEquivalence:()=>Uee,overrideToFormatter:()=>Nee,readonlyKey:()=>LY,refine:()=>i7,required:()=>$Y,requiredKey:()=>NY,resolveAnnotations:()=>yte,resolveAnnotationsKey:()=>Ste,revealBottom:()=>hY,revealCodec:()=>SY,suspend:()=>Z2,tag:()=>Ii,tagDefaultOmit:()=>m7,toArbitrary:()=>Dee,toCodecArrayFromSingle:()=>qee,toCodecIso:()=>RB,toCodecJson:()=>_B,toCodecJsonAST:()=>yy,toCodecStringTree:()=>lm,toDifferJsonPatch:()=>dte,toEncoded:()=>ef,toEncoderXml:()=>zee,toEquivalence:()=>Lee,toFormatter:()=>$ee,toIso:()=>cte,toIsoFocus:()=>lte,toIsoSource:()=>ute,toJsonSchemaDocument:()=>TB,toRepresentation:()=>Bee,toStandardJSONSchemaV1:()=>bY,toStandardSchemaV1:()=>EY,toTaggedUnion:()=>iL,toType:()=>ur,withConstructorDefault:()=>rL,withDecodingDefault:()=>sL,withDecodingDefaultKey:()=>iI,withDecodingDefaultType:()=>p7,withDecodingDefaultTypeKey:()=>d7});function Ir(){return(e,t,n)=>K(new Uc(e.map(kp),(r)=>t(r.map((o)=>K(o))),n))}function Eo(e,t){return Ir()([],()=>(n,r,o)=>e(n)?A(n):R(new bt(r,n,o)),t)}function hY(e){return e}function gY(e){return(t)=>t.annotate(e)}function xY(e){return(t)=>Qv(Qv(t).annotate(e))}function yY(e){return(t)=>t.rebuild(_p(t.ast,e))}function SY(e){return e}function R2(e){return D(e,Jp)&&e[Jp]===Jp}function y2(e){return Kt(e)?e.value:{issues:[{message:Sw(e.cause)}]}}function EY(e,t){let n=Nt(e),r={errors:"all",...t?.parseOptions},o=mM(t),s=(i)=>{let a=new zu("sync"),c=ps(pa(n(i,r),{onFailure:o,onSuccess:(l)=>({value:l})}),{scheduler:a});c.currentDispatcher?.flush();let u=c.pollUnsafe();if(u)return y2(u);return new Promise((l)=>{c.addObserver((f)=>{l(y2(f))})})};if("~standard"in e){let i=e;if("validate"in i["~standard"])return i;return Object.assign(i["~standard"],{validate:s}),i}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}function S2(e,t){let n=TB(e);if(t==="draft-2020-12"){let r=n.schema;if(Object.keys(n.definitions).length>0)r.$defs=n.definitions;return r}else if(t==="draft-07"){let r=jU(n),o=r.schema;if(Object.keys(r.definitions).length>0)o.definitions=r.definitions;return o}throw new globalThis.Error(`Unsupported target: ${t}`)}function bY(e){let t={input(n){return S2(e,n.target)},output(n){return S2(ur(e),n.target)}};if("~standard"in e){let n=e;if("jsonSchema"in n["~standard"])return n;return Object.assign(n["~standard"],{jsonSchema:t}),n}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}function Ai(e,t){let n=Nt(e,t);return(r,o)=>F2(n(r,o))}function F2(e){if(Xe(e))return eI(e);return Gr(e,(t)=>fa(()=>ri(t,(n)=>new Kc(n))))}function M2(e,t){let n;for(let r of e.reasons){if(!bd(r)||!R2(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function D2(e){return Ag(e).then((t)=>{if(Kt(t))return t.value;throw M2(t.cause,"Promise adapter can only reject schema errors")})}function N2(e){let t=ha(e);if(Kt(t))return t.value;throw M2(t.cause,"Sync adapter can only throw schema errors")}function $2(e,t){let n=Y$(e,t);return(r,o)=>eI(n(r,o))}function eI(e){return Kt(e)?e:Hr(ri(e.cause,(t)=>new Kc(t)))}function U2(e,t){let n=eU(e,t);return(r,o)=>Wu(n(r,o),(s)=>new Kc(s))}function L2(e,t){let n=Ai(e,t);return(r,o)=>D2(n(r,o))}function B2(e,t){let n=Ai(e,t);return(r,o)=>N2(n(r,o))}function cy(e,t){let n=ql(e,t);return(r,o)=>F2(n(r,o))}function W2(e,t){let n=tU(e,t);return(r,o)=>eI(n(r,o))}function j2(e,t){let n=rU(e,t);return(r,o)=>Wu(n(r,o),(s)=>new Kc(s))}function q2(e,t){let n=cy(e,t);return(r,o)=>D2(n(r,o))}function z2(e,t){let n=cy(e,t);return(r,o)=>N2(n(r,o))}function uy(e){return D(e,Gp)&&e[Gp]===Gp}function BY(e){return D(e,Qp)&&e[Qp]===Qp}function Qv(e){if(BY(e))return e.schema.rebuild(Wo(e.ast));return K(Wo(e.ast),{[Qp]:Qp,schema:e})}function et(e){let t=K(new Zr(e),{literal:e,transform(n){return t.pipe(pe(et(n),{decode:Ae(()=>n),encode:Ae(()=>e)}))}});return t}function V2(e){return new $C(e.map((t)=>uy(t)?t.ast:new Zr(t)))}function HY(e){return K(V2(e),{parts:e})}function WY(e){return K(V2(e).asTemplateLiteralParser(),{parts:e})}function jY(e){return K(new NC(Object.keys(e).filter((t)=>typeof e[e[t]]!=="number").map((t)=>[t,e[t]])),{enums:e})}function GY(e){return K(new UC(e))}function rI(e,t){return K(e,{fields:t,mapFields(n,r){let o=n(this.fields);return rI(yx(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function te(e){return rI(yx(e,void 0),e)}function JY(e){return qn((t)=>t.mapFields(gU(e)))}function ZY(e){return function(t){let n={},r=Object.create(null),o=Object.create(null),s=new Set;for(let i of Reflect.ownKeys(t.fields)){let a=ef(t.fields[i]),c=Object.hasOwn(e,i),u=c?e[i]:i,l=QY(u);if(s.has(l))throw new globalThis.Error(`Duplicate encoded keys: ${$s(u)}`);if(s.add(l),H(n,u,a),c)r[i]=u,o[u]=i}return te(n).pipe(pe(t,ht({decode:Mv(o),encode:Mv(r)})))}}function YY(e,t){return(n)=>{let r=AT(n.fields,ur),o=te({...r,...e});return n.pipe(pe(o,ht({decode:(s)=>{let i={...s};for(let a in e){let c=t[a],u=c(s);if(Ce(u))H(i,a,u.value)}return i},encode:(s)=>{let i={...s};for(let a in e)delete i[a];return i}})))}}function fy(e,t){return K(mN(e.ast,t.ast),{key:e,value:t})}function XY(e,t){return K(rN(e.ast,t.map(kp)),{schema:e,records:t})}function G2(e,t){return K(e,{elements:t,mapElements(n,r){let o=n(this.elements);return G2(WC(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Ql(e){return G2(WC(e),e)}function e7(e,t){return K(oN(e.ast,t.map(kp)),{schema:e,rest:t})}function n7(e){return kt([e,je(e)]).pipe(pe(je(ur(e)),ht({decode:_T,encode:(t)=>t.length===1?t[0]:t})))}function r7(e){return je(e).check(dI())}function J2(e,t){return K(e,{members:t,mapMembers(n,r){let o=n(this.members);return J2(Sx(o,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function kt(e,t){return J2(Sx(e,t?.mode??"anyOf",void 0),e)}function Ti(e){let t=e.map(et);return K(Sx(t,"anyOf",void 0),{literals:e,members:t,mapMembers(n){return kt(n(this.members))},pick(n){return Ti(n)},transform(n){return kt(t.map((r,o)=>r.transform(n[o])))}})}function Z2(e){return K(new bx(()=>e().ast))}function s7(...e){return(t)=>t.check(...e)}function i7(e,t){return(n)=>K(Ss(n.ast,[kx(e,t)]),{schema:n})}function Y2(e){return(t)=>K(fN(t.ast,e),{schema:t,identifier:e})}function a7(e,t){return(n)=>(t.checks?n.check(...t.checks):n).pipe(Y2(e))}function X2(e){return(t)=>K(uN(t.ast,new Ep(e,L)),{schema:t})}function eL(e){return(t)=>K(lN(t.ast,new Ep(L,e)),{schema:t})}function c7(e){return tL(e)}function tL(e){return(t)=>X2(Zd(e))(t)}function u7(e){return nL(e)}function nL(e){return(t)=>eL(Zd(e))(t)}function pe(e,t){return(n)=>K(Ix(n.ast,e.ast,t?lx(t):_l()),{from:n,to:e})}function l7(e){return(t)=>pe(ur(t),e)(t)}function sI(e,t){return(n)=>t?pe(n,t)(e):pe(n)(e)}function f7(e){return(t)=>pe(t,e)(ef(t))}function rL(e){return(t)=>K(pN(t.ast,e),{schema:t})}function oL(e){return Gr(e,(t)=>fa(()=>ri(t,(n)=>n.issue)))}function iI(e,t){let n=t?.encodingStrategy==="omit"?sC():Ho();return(r)=>vi(ef(r)).pipe(pe(r,{decode:yp(oL(e)),encode:n}))}function d7(e,t){return(n)=>ur(n).pipe(iI(e,t),sI(vi(n)))}function sL(e,t){let n=t?.encodingStrategy==="omit"?sC():Ho();return(r)=>cr(ef(r)).pipe(pe(r,{decode:yp(oL(e)),encode:n}))}function p7(e,t){return(n)=>ur(n).pipe(sL(e,t),sI(cr(n)))}function Ii(e){return et(e).pipe(rL(A(e)))}function m7(e){return Ii(e).pipe(iI(A(e),{encodingStrategy:"omit"}))}function py(e,t){return te({_tag:Ii(e),...t})}function iL(e){return(t)=>{let n={},r=[],o=new Set,s={},i=(l)=>(f)=>l.includes(f[e]);return a(t),Object.assign(t,{cases:n,discriminants:r,isAnyOf:i,guards:s,match:c,matchOrElse:u});function a(l){let f=l.ast;if(DD(f)&&"members"in l&&globalThis.Array.isArray(l.members)&&l.members.every(uy))return l.members.forEach(a);let d=Rl(f);if(d.length>0){let m=d.find((y)=>y.key===e)?.literal;if(jm(m)){let y=typeof m==="number"?globalThis.String(m):m;if(o.has(y))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(m)}`);o.add(y),r.push(m),H(n,m,l),H(s,m,Zp(ur(l)));return}}throw new globalThis.Error("No literal or unique symbol found")}function c(){if(arguments.length===1){let y=arguments[0];return function(b){let E=b[e];return(Object.hasOwn(y,E)?y[E]:void 0)(b)}}let l=arguments[0],f=arguments[1],d=l[e];return(Object.hasOwn(f,d)?f[d]:void 0)(l)}function u(){if(arguments.length===2){let b=arguments[0],E=arguments[1];return function(w){let k=w[e];return(Object.hasOwn(b,k)?b[k]??E:E)(w)}}let l=arguments[0],f=arguments[1],d=arguments[2],m=l[e];return(Object.hasOwn(f,m)?f[m]??d:d)(l)}}}function h7(e){let t={},n=[];for(let c of Object.keys(e)){let u=py(c,e[c]);H(t,c,u),n.push(u)}let r=kt(n),{guards:o,isAnyOf:s,match:i,matchOrElse:a}=iL("_tag")(r);return K(r.ast,{cases:t,isAnyOf:s,guards:o,match:i,matchOrElse:a})}function g7(){return(e)=>e}function Oa(e,t){return Eo((n)=>n instanceof e,t)}function st(){return(e,t)=>new wt(e.ast,lx(t))}function x7(e,t=void 0){return new ka(e,t)}function zn(e,t){return ar(e,Le,({annotations:n})=>n===void 0?t:t.annotate(n))}function aI(e){let t=new globalThis.RegExp(E2);return it((n)=>n.trim()===n,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isTrimmed()"}),arbitrary:{constraint:{patterns:[E2]}},...e})}function Gc(e,t){let{source:n,flags:r}=e,o=r===""?`new RegExp(${j(n)})`:`new RegExp(${j(n)}, ${j(r)})`;return vp(e,{toCode:()=>({runtime:`Schema.isPattern(${o})`}),...t})}function aL(e){return QC({toCode:()=>({runtime:"Schema.isStringFinite()"}),...e})}function cL(e){return ZC({toCode:()=>({runtime:"Schema.isStringBigInt()"}),...e})}function uL(e){return XC({toCode:()=>({runtime:"Schema.isStringSymbol()"}),...e})}function lL(e,t){let n=C7(e);return Gc(n,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:n.source,format:"uuid"}),toCode:()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),...t})}function fL(e){return Gc(b2,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:()=>({pattern:b2.source}),toCode:()=>({runtime:"Schema.isGUID()"}),...e})}function dL(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return Gc(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isULID()"}),...e})}function cI(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return Gc(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64()"}),...e})}function pL(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return Gc(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64Url()"}),...e})}function mL(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`^${Kl(e)}`);return it((o)=>o.startsWith(e),{expected:`a string starting with ${n}`,representation:{id:"effect/schema/isStartsWith",payload:{startsWith:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isStartsWith(${j(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}function hL(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`${Kl(e)}$`);return it((o)=>o.endsWith(e),{expected:`a string ending with ${n}`,representation:{id:"effect/schema/isEndsWith",payload:{endsWith:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isEndsWith(${j(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}function gL(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(Kl(e));return it((o)=>o.includes(e),{expected:`a string including ${n}`,representation:{id:"effect/schema/isIncludes",payload:{includes:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isIncludes(${j(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}function xL(e){let t=new globalThis.RegExp(w2);return it((n)=>n.toUpperCase()===n,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isUppercased()"}),arbitrary:{constraint:{patterns:[w2]}},...e})}function yL(e){let t=new globalThis.RegExp(k2);return it((n)=>n.toLowerCase()===n,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isLowercased()"}),arbitrary:{constraint:{patterns:[k2]}},...e})}function SL(e){let t=new globalThis.RegExp(C2);return it((n)=>n.charAt(0).toUpperCase()===n.charAt(0),{expected:"a string with the first character in uppercase",representation:{id:"effect/schema/isCapitalized",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isCapitalized()"}),arbitrary:{constraint:{patterns:[C2]}},...e})}function EL(e){let t=new globalThis.RegExp(v2);return it((n)=>n.charAt(0).toLowerCase()===n.charAt(0),{expected:"a string with the first character in lowercase",representation:{id:"effect/schema/isUncapitalized",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isUncapitalized()"}),arbitrary:{constraint:{patterns:[v2]}},...e})}function Xp(e){let t=Vi(e.order),n=e.formatter??j;return(r,o)=>it((s)=>t(s,r),{expected:`a value greater than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r,exclusiveMinimum:!0}}},...e.annotate?.(r),...o})}function em(e){let t=Kf(e.order),n=e.formatter??j;return(r,o)=>it((s)=>t(s,r),{expected:`a value greater than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r}}},...e.annotate?.(r),...o})}function tm(e){let t=Lu(e.order),n=e.formatter??j;return(r,o)=>it((s)=>t(s,r),{expected:`a value less than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r,exclusiveMaximum:!0}}},...e.annotate?.(r),...o})}function nm(e){let t=Vf(e.order),n=e.formatter??j;return(r,o)=>it((s)=>t(s,r),{expected:`a value less than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r}}},...e.annotate?.(r),...o})}function rm(e){let t=Kf(e.order),n=Vi(e.order),r=Vf(e.order),o=Lu(e.order),s=e.formatter??j;return(i,a)=>{let c=i.exclusiveMinimum?n:t,u=i.exclusiveMaximum?o:r;return it((l)=>c(l,i.minimum)&&u(l,i.maximum),{expected:`a value between ${s(i.minimum)}${i.exclusiveMinimum?" (excluded)":""} and ${s(i.maximum)}${i.exclusiveMaximum?" (excluded)":""}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:i.minimum,maximum:i.maximum,...i.exclusiveMinimum&&{exclusiveMinimum:!0},...i.exclusiveMaximum&&{exclusiveMaximum:!0}}}},...e.annotate?.(i),...a})}}function wL(e){return(t,n)=>{let r=e.formatter??j;return it((o)=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${r(t)}`,...e.annotate?.(t),...n})}}function Zl(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${j(e)}`);return e}function sm(e){return it((t)=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer"}),toCode:()=>({runtime:"Schema.isInt()"}),arbitrary:{constraint:{integer:!0}},...e})}function z7(e){return new ka([sm(),om({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}function V7(e){return new ka([sm(),om({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}function Yl(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${j(e)}`);return e.toISOString()}function Xl(e){return`new Date(${j(e.getTime())})`}function lI(e,t){return e=Math.max(0,Math.floor(e)),it((n)=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="array"?{minItems:e}:{minLength:e},toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[Sr]:!0,arbitrary:{constraint:{minLength:e}},...t})}function $L(e){return lI(1,e)}function UL(e,t){return e=Math.max(0,Math.floor(e)),it((n)=>n.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:n})=>n==="array"?{maxItems:e}:{maxLength:e},toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[Sr]:!0,arbitrary:{constraint:{maxLength:e}},...t})}function fI(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),it((r)=>r.length>=e&&r.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:"effect/schema/isLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:({type:r})=>r==="array"?{allOf:[{minItems:e},{maxItems:t}]}:{allOf:[{minLength:e},{maxLength:t}]},toCode:()=>({runtime:`Schema.isLengthBetween(${e}, ${t})`}),[Sr]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}function LL(e,t){return e=Math.max(0,Math.floor(e)),it((n)=>n.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[Sr]:!0,arbitrary:{constraint:{minLength:e}},...t})}function BL(e,t){return e=Math.max(0,Math.floor(e)),it((n)=>n.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[Sr]:!0,arbitrary:{constraint:{maxLength:e}},...t})}function HL(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),it((r)=>r.size>=e&&r.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:"effect/schema/isSizeBetween",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isSizeBetween(${e}, ${t})`}),[Sr]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}function WL(e,t){return e=Math.max(0,Math.floor(e)),it((n)=>Reflect.ownKeys(n).length>=e,{expected:`a value with at least ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMinProperties",payload:{minProperties:e}},toJsonSchema:()=>({minProperties:e}),toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[Sr]:!0,arbitrary:{constraint:{minLength:e}},...t})}function jL(e,t){return e=Math.max(0,Math.floor(e)),it((n)=>Reflect.ownKeys(n).length<=e,{expected:`a value with at most ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMaxProperties",payload:{maxProperties:e}},toJsonSchema:()=>({maxProperties:e}),toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[Sr]:!0,arbitrary:{constraint:{maxLength:e}},...t})}function qL(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),it((r)=>Reflect.ownKeys(r).length>=e&&Reflect.ownKeys(r).length<=t,{expected:e===t?`a value with exactly ${e===1?"1 entry":`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:"effect/schema/isPropertiesLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({minProperties:e,maxProperties:t}),toCode:()=>({runtime:`Schema.isPropertiesLengthBetween(${e}, ${t})`}),[Sr]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}function zL(e,t){let n=ef(e),r=Q$(n.ast);return it((o,s,i)=>{let a=Reflect.ownKeys(o),c=[];for(let u of a){let l=r(u,i);if(l!==void 0){if(c.push(new Jt([u],l)),i.errors==="first")break}}if(ac(c))return new Ft(s,c,o,i);return!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[n.ast]},toJsonSchema:({schemas:o})=>({propertyNames:o[0]}),toCode:({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),[Sr]:!0,...t})}function dI(e){return it((t)=>hh(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:"Schema.isUnique()"}),arbitrary:{constraint:{unique:!0}},...e})}function Pa(e){let t=Ir()([e],([n])=>(r,o,s)=>{if(Hu(r)){if(he(r))return Ic;return mn(Nt(n)(r.value,s),{onSuccess:F,onFailure:(i)=>Er(o,"value",i,r,s)})}return R(new bt(o,r,s))},{representation:{id:"effect/schema/Option",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Option(${n[0].runtime})`,Type:`Option.Option<${n[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),expected:"Option",toCodec:([n])=>st()(kt([te({_tag:et("Some"),value:n}),te({_tag:et("None")})]),ht({decode:(r)=>r._tag==="None"?P():F(r.value),encode:(r)=>Ce(r)?{_tag:"Some",value:r.value}:{_tag:"None"}})),toArbitrary:([n])=>(r,o)=>{let s=r.constant(P()),i=r.oneof(s,n.arbitrary.map(F));return Jc(r,o,s,i)},toEquivalence:([n])=>EE(n),toFormatter:([n])=>ut({onNone:()=>"none()",onSome:(r)=>`some(${n(r)})`})});return K(t.ast,{value:e})}function fX(e){return oI(e).pipe(pe(Pa(ur(e)),mD()))}function dX(e){return dy(e).pipe(pe(Pa(ur(e)),hD()))}function pX(e,t){return Q2(e).pipe(pe(Pa(ur(e)),gD(t)))}function mX(e){return vi(e).pipe(pe(Pa(ur(e)),xD()))}function hX(e){return cr(e).pipe(pe(Pa(ur(e)),yD()))}function gX(e,t){let n=t===void 0?"omit":t.onNoneEncoding,r=n===null?null:void 0;return cr(oI(e)).pipe(pe(Pa(ur(e)),fx({decode:(o)=>o.pipe(sc(qm),F),encode:n==="omit"?oc:(o)=>F(It(oc(o),()=>r))})))}function KL(e,t){let n=Ir()([e,t],([r,o])=>(s,i,a)=>{if(!dh(s))return R(new bt(i,s,a));switch(s._tag){case"Success":return mn(Av(r)(s.success,a),{onSuccess:J,onFailure:(c)=>Er(i,"success",c,s,a)});case"Failure":return mn(Av(o)(s.failure,a),{onSuccess:oe,onFailure:(c)=>Er(i,"failure",c,s,a)})}},{representation:{id:"effect/schema/Result",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Result(${r[0].runtime}, ${r[1].runtime})`,Type:`Result.Result<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Result from "effect/Result"']}),expected:"Result",toCodec:([r,o])=>st()(kt([te({_tag:et("Success"),success:r}),te({_tag:et("Failure"),failure:o})]),ht({decode:(s)=>s._tag==="Success"?J(s.success):oe(s.failure),encode:(s)=>rn(s)?{_tag:"Success",success:s.success}:{_tag:"Failure",failure:s.failure}})),toArbitrary:([r,o])=>(s,i)=>{let a=oB(s,r.terminal?.map((u)=>J(u)),o.terminal?.map((u)=>oe(u))),c=s.oneof(r.arbitrary.map((u)=>J(u)),o.arbitrary.map((u)=>oe(u)));return Jc(s,i,a,c)},toEquivalence:([r,o])=>PE(r,o),toFormatter:([r,o])=>mr({onSuccess:(s)=>`success(${r(s)})`,onFailure:(s)=>`failure(${o(s)})`})});return K(n.ast,{success:e,failure:t})}function my(e,t){let n=typeof t?.label==="string"?t.label:void 0,r=t?.disallowJsonEncode===!0,o=n!==void 0?r?{label:n,disallowJsonEncode:!0}:{label:n}:r?{disallowJsonEncode:!0}:void 0,s=n!==void 0?Nt(et(n)):void 0,i=Ir()([e],([a])=>(c,u,l)=>{if(Jv(c)){let f=s!==void 0?Tc(s(c.label,l),(d)=>new Jt(["label"],d)):Pe;return An(f,()=>mn(Nt(a)(_a(c),l),{onSuccess:()=>c,onFailure:()=>new Ft(u,[new Jt(["value"],new Ie(void 0,c,l))],c,l)}))}return R(new bt(u,c,l))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:({typeParameters:a})=>({runtime:o!==void 0?`Schema.Redacted(${a[0].runtime}, ${j(o)})`:`Schema.Redacted(${a[0].runtime})`,Type:`Redacted.Redacted<${a[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),expected:"Redacted",toCodecJson:([a])=>st()(a,{decode:Ae((c)=>Ci(c,{label:n})),encode:r?rC((c)=>"Cannot serialize Redacted"+(Ce(c)&&typeof c.value.label==="string"?` with label: "${c.value.label}"`:"")):Ae(_a)}),toArbitrary:([a])=>()=>({arbitrary:a.arbitrary.map((c)=>Ci(c,{label:n})),terminal:a.terminal?.map((c)=>Ci(c,{label:n}))}),toFormatter:()=>globalThis.String,toEquivalence:([a])=>x2(a)});return K(i.ast,{value:e})}function bX(e,t){return pe(my(ur(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:Ae((n)=>Ci(n,{label:t?.label})),encode:t?.disallowEncode?rC((n)=>"Cannot encode Redacted"+(Ce(n)&&typeof n.value.label==="string"?` with label: "${n.value.label}"`:"")):Ae(_a)})(e)}function sy(e,t){let n=Ir()([e,t],([r,o])=>(s,i,a)=>{if(!gw(s))return R(new bt(i,s,a));switch(s._tag){case"Fail":return mn(Nt(r)(s.error,a),{onSuccess:wd,onFailure:(c)=>Er(i,"error",c,s,a)});case"Die":return mn(Nt(o)(s.defect,a),{onSuccess:kd,onFailure:(c)=>Er(i,"defect",c,s,a)});case"Interrupt":return A(s)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.CauseReason(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Failure<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause.Failure",toCodec:([r,o])=>st()(kt([te({_tag:et("Fail"),error:r}),te({_tag:et("Die"),defect:o}),te({_tag:et("Interrupt"),fiberId:dy(Cr)})]),ht({decode:(s)=>{switch(s._tag){case"Fail":return wd(s.error);case"Die":return kd(s.defect);case"Interrupt":return Cd(s.fiberId)}},encode:L})),toArbitrary:([r,o])=>GL(r,o),toEquivalence:([r,o])=>JL(r,o),toFormatter:([r,o])=>QL(r,o)});return K(n.ast,{error:e,defect:t})}function GL(e,t){return(n,r)=>{let o=n.constant(Cd()),s=n.oneof(o,n.integer({min:1}).map(Cd),e.arbitrary.map((i)=>wd(i)),t.arbitrary.map((i)=>kd(i)));return Jc(n,r,o,s)}}function JL(e,t){return(n,r)=>{if(n._tag!==r._tag)return!1;switch(n._tag){case"Fail":return e(n.error,r.error);case"Die":return t(n.defect,r.defect);case"Interrupt":return n.fiberId===r.fiberId}}}function QL(e,t){return(n)=>{switch(n._tag){case"Fail":return`Fail(${e(n.error)})`;case"Die":return`Die(${t(n.defect)})`;case"Interrupt":return"Interrupt"}}}function iy(e,t){let n=Ir()([e,t],([r,o])=>{let s=je(sy(r,o));return(i,a,c)=>{if(!hw(i))return R(new bt(a,i,c));return mn(Nt(s)(i.reasons,c),{onSuccess:Sc,onFailure:(u)=>Er(a,"failures",u,i,c)})}},{representation:{id:"effect/schema/Cause",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Cause(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Cause<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause",toCodec:([r,o])=>st()(je(sy(r,o)),ht({decode:Sc,encode:({reasons:s})=>s})),toArbitrary:([r,o])=>ZL(r,o),toEquivalence:([r,o])=>YL(r,o),toFormatter:([r,o])=>XL(r,o)});return K(n.ast,{error:e,defect:t})}function ZL(e,t){return(n,r)=>{let o=GL(e,t)(n,r),s=n.constant(xw),i=n.array(o.arbitrary).map(Sc);return Jc(n,r,s,i)}}function YL(e,t){let n=YA(JL(e,t));return(r,o)=>n(r.reasons,o.reasons)}function XL(e,t){let n=QL(e,t);return(r)=>`Cause([${r.reasons.map(n).join(", ")}])`}function nB(e){let t=eB(e),n=I2[t];if(n!==void 0)return n;let r=tB(t),o=Oa(globalThis.Error,{representation:{id:"effect/schema/Error",payload:r??null},toCode:()=>({runtime:r!==void 0?`Schema.ErrorInstance(${j(r)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),expected:"Error",toCodecJson:()=>st()(gte,dD(r)),toArbitrary:()=>(s)=>s.string().map((i)=>new globalThis.Error(i))});return I2[t]=o,o}function pI(e){let t=eB(e),n=A2[t];if(n!==void 0)return n;let r=fm.pipe(pe(tI,pD(tB(t))));return A2[t]=r,r}function rB(e,t,n){let r=Ir()([e,t,n],([o,s,i])=>{let a=iy(s,i);return(c,u,l)=>{if(!bw(c))return R(new bt(u,c,l));switch(c._tag){case"Success":return mn(Nt(o)(c.value,l),{onSuccess:co,onFailure:(f)=>Er(u,"value",f,c,l)});case"Failure":return mn(Nt(a)(c.cause,l),{onSuccess:Hr,onFailure:(f)=>Er(u,"cause",f,c,l)})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:({typeParameters:o})=>({runtime:`Schema.Exit(${o[0].runtime}, ${o[1].runtime}, ${o[2].runtime})`,Type:`Exit.Exit<${o[0].Type}, ${o[1].Type}, ${o[2].Type}>`,importDeclarations:['import * as Exit from "effect/Exit"']}),expected:"Exit",toCodec:([o,s,i])=>st()(kt([te({_tag:et("Success"),value:o}),te({_tag:et("Failure"),cause:iy(s,i)})]),ht({decode:(a)=>a._tag==="Success"?co(a.value):Hr(a.cause),encode:(a)=>Kt(a)?{_tag:"Success",value:a.value}:{_tag:"Failure",cause:a.cause}})),toArbitrary:([o,s,i])=>(a,c)=>{let u=ZL(s,i)(a,c),l=oB(a,o.terminal?.map((d)=>co(d)),u.terminal?.map((d)=>Hr(d))),f=a.oneof(o.arbitrary.map((d)=>co(d)),u.arbitrary.map((d)=>Hr(d)));return Jc(a,c,l,f)},toEquivalence:([o,s,i])=>{let a=YL(s,i);return(c,u)=>{if(c._tag!==u._tag)return!1;switch(c._tag){case"Success":return o(c.value,u.value);case"Failure":return a(c.cause,u.cause)}}},toFormatter:([o,s,i])=>{let a=XL(s,i);return(c)=>{switch(c._tag){case"Success":return`Exit.Success(${o(c.value)})`;case"Failure":return`Exit.Failure(${a(c.cause)})`}}}});return K(r.ast,{value:e,error:t,defect:n})}function oB(e,t,n){return t===void 0?n:n===void 0?t:e.oneof(t,n)}function Jc(e,t,n,r){return{arbitrary:n===void 0||t.recursion===void 0?r:e.oneof(t.recursion,n,r),terminal:n}}function T2(e,t,n,r){return r===void 0?e.array(t,n):e.uniqueArray(t,{...n,comparator:r})}function hy(e,t,n,r,o,s){let i=t.constraint,a=i===void 0||i.minLength===void 0&&i.maxLength===void 0?void 0:{...i.minLength!==void 0?{minLength:i.minLength}:{},...i.maxLength!==void 0?{maxLength:i.maxLength}:{}};if(a?.minLength!==void 0&&a.maxLength!==void 0&&a.minLength>a.maxLength)throw new globalThis.Error("Unable to derive an arbitrary for size constraints");let c=a?.minLength??0,u=c===0?e.constant([]):r===void 0?void 0:T2(e,r,{...a,maxLength:c},s),l=Jc(e,t,u,T2(e,n,a,s));return{arbitrary:l.arbitrary.map(o),terminal:l.terminal?.map(o)}}function sB(e,t,n,r,o){return hy(e,t,e.tuple(n.arbitrary,r.arbitrary),n.terminal===void 0||r.terminal===void 0?void 0:e.tuple(n.terminal,r.terminal),o,([s],[i])=>ee(s,i))}function iB(e,t){let n=Ir()([e,t],([r,o])=>{let s=je(Ql([r,o]));return(i,a,c)=>{if(i instanceof globalThis.Map)return mn(Nt(s)([...i],c),{onSuccess:(u)=>new globalThis.Map(u),onFailure:(u)=>Er(a,"entries",u,i,c)});return R(new bt(a,i,c))}},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.ReadonlyMap(${r[0].runtime}, ${r[1].runtime})`,Type:`globalThis.ReadonlyMap<${r[0].Type}, ${r[1].Type}>`}),expected:"ReadonlyMap",toCodec:([r,o])=>st()(je(Ql([r,o])),ht({decode:(s)=>new globalThis.Map(s),encode:(s)=>[...s.entries()]})),toArbitrary:([r,o])=>(s,i)=>sB(s,i,r,o,(a)=>new globalThis.Map(a)),toEquivalence:([r,o])=>Km(r,o),toFormatter:([r,o])=>(s)=>{let i=s.size;if(i===0)return"ReadonlyMap(0) {}";let a=globalThis.Array.from(s.entries()).sort().map(([c,u])=>`${r(c)} => ${o(u)}`);return`ReadonlyMap(${i}) { ${a.join(", ")} }`}});return K(n.ast,{key:e,value:t})}function _2(e,t,n){return te({type:et(e),nodes:je(te({index:_n,data:t})),edges:je(te({index:_n,source:_n,target:_n,data:n}))})}function O2(e,t){let n=-1,r=new Set;for(let o=0;o<e.nodes.length;o++){let s=e.nodes[o].index;if(s<=n)return R(new Jt(["nodes",o,"index"],new Ie({expected:"a strictly increasing node index"},s,t)));n=s,r.add(s)}n=-1;for(let o=0;o<e.edges.length;o++){let s=e.edges[o];if(s.index<=n)return R(new Jt(["edges",o,"index"],new Ie({expected:"a strictly increasing edge index"},s.index,t)));if(n=s.index,!r.has(s.source))return R(new Jt(["edges",o,"source"],new Ie({expected:"an encoded node index"},s.source,t)));if(!r.has(s.target))return R(new Jt(["edges",o,"target"],new Ie({expected:"an encoded node index"},s.target,t)))}return A(Rp(e))}function _X(e,t,n){if(!yv(e)||e.mutable||e.type!==t)return R(new Ie({expected:`an immutable ${t} Graph`},e,n));return A(Pp(e))}function OX(e,t){return(n,r)=>{let o=Pp(n),s=Pp(r);if(o.type!==s.type||o.nodes.length!==s.nodes.length||o.edges.length!==s.edges.length)return!1;for(let i=0;i<o.nodes.length;i++)if(o.nodes[i].index!==s.nodes[i].index||!e(o.nodes[i].data,s.nodes[i].data))return!1;for(let i=0;i<o.edges.length;i++){let a=o.edges[i],c=s.edges[i],u=o.type==="directed"?a.source===c.source&&a.target===c.target:a.source===c.source&&a.target===c.target||a.source===c.target&&a.target===c.source;if(a.index!==c.index||!u||!t(a.data,c.data))return!1}return!0}}function PX(e,t,n){return(r,o)=>{let s=Rp({type:e,nodes:[],edges:[]}),i=r.constant(s),a=r.array(t.arbitrary).chain((c)=>{let u=c.map((f,d)=>({index:d,data:f}));if(u.length===0)return i;let l=r.integer({min:0,max:u.length-1});return r.array(r.tuple(l,l,n.arbitrary)).map((f)=>Rp({type:e,nodes:u,edges:f.map(([d,m,y],b)=>({index:b,source:d,target:m,data:y}))}))});return Jc(r,o,i,a)}}function aB(e,t,n){let r=Ir()([t,n],([o,s])=>{let i=_2(e,o,s);return(a,c,u)=>{if(!yv(a)||a.mutable||a.type!==e)return R(new bt(c,a,u));return se(Nt(i)(Pp(a),u),(l)=>O2(l,u))}},{representation:{id:"effect/schema/Graph",payload:e},toCode:({typeParameters:o})=>({runtime:`Schema.Graph(${j(e)}, ${o[0].runtime}, ${o[1].runtime})`,Type:`Graph.Graph<${o[0].Type}, ${o[1].Type}, ${j(e)}>`,importDeclarations:['import * as Graph from "effect/Graph"']}),expected:`an immutable ${e} Graph`,toCodec:([o,s])=>st()(_2(e,o,s),Qr({decode:O2,encode:(i,a)=>_X(i,e,a)})),toArbitrary:([o,s])=>PX(e,o,s),toEquivalence:([o,s])=>OX(o,s),toFormatter:()=>globalThis.String});return K(r.ast,{type:e,node:t,edge:n})}function cB(e,t){let n=Ir()([e,t],([r,o])=>{let s=je(Ql([r,o]));return(i,a,c)=>{if($$(i))return mn(Nt(s)(Wx(i),c),{onSuccess:Hx,onFailure:(u)=>Er(a,"entries",u,i,c)});return R(new bt(a,i,c))}},{representation:{id:"effect/schema/HashMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.HashMap(${r[0].runtime}, ${r[1].runtime})`,Type:`HashMap.HashMap<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as HashMap from "effect/HashMap"']}),expected:"HashMap",toCodec:([r,o])=>st()(je(Ql([r,o])),ht({decode:Hx,encode:Wx})),toArbitrary:([r,o])=>(s,i)=>sB(s,i,r,o,Hx),toEquivalence:([r,o])=>Km(r,o),toFormatter:([r,o])=>(s)=>{let i=U$(s);if(i===0)return"HashMap(0) {}";let a=Wx(s).sort().map(([c,u])=>`${r(c)} => ${o(u)}`);return`HashMap(${i}) { ${a.join(", ")} }`}});return K(n.ast,{key:e,value:t})}function uB(e){let t=Ir()([e],([n])=>{let r=je(n);return(o,s,i)=>{if(o instanceof globalThis.Set)return mn(Nt(r)([...o],i),{onSuccess:(a)=>new globalThis.Set(a),onFailure:(a)=>Er(s,"values",a,o,i)});return R(new bt(s,o,i))}},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.ReadonlySet(${n[0].runtime})`,Type:`globalThis.ReadonlySet<${n[0].Type}>`}),expected:"ReadonlySet",toCodec:([n])=>st()(je(n),ht({decode:(r)=>new globalThis.Set(r),encode:(r)=>[...r.values()]})),toArbitrary:([n])=>(r,o)=>hy(r,o,n.arbitrary,n.terminal,(s)=>new globalThis.Set(s),ee),toEquivalence:([n])=>Gm(n),toFormatter:([n])=>(r)=>{let o=r.size;if(o===0)return"ReadonlySet(0) {}";let s=globalThis.Array.from(r.values()).sort().map((i)=>`${n(i)}`);return`ReadonlySet(${o}) { ${s.join(", ")} }`}});return K(t.ast,{value:e})}function lB(e){let t=Ir()([e],([n])=>{let r=je(n);return(o,s,i)=>{if(q$(o))return mn(Nt(r)(on(o),i),{onSuccess:qx,onFailure:(a)=>Er(s,"values",a,o,i)});return R(new bt(s,o,i))}},{representation:{id:"effect/schema/HashSet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.HashSet(${n[0].runtime})`,Type:`HashSet.HashSet<${n[0].Type}>`}),expected:"HashSet",toCodec:([n])=>st()(je(n),ht({decode:qx,encode:on})),toArbitrary:([n])=>(r,o)=>hy(r,o,n.arbitrary,n.terminal,qx,ee),toEquivalence:([n])=>Gm(n),toFormatter:([n])=>(r)=>{let o=z$(r);if(o===0)return"HashSet(0) {}";let s=globalThis.Array.from(r).sort().map((i)=>`${n(i)}`);return`HashSet(${o}) { ${s.join(", ")} }`}});return K(t.ast,{value:e})}function fB(e){let t=Ir()([e],([n])=>{let r=je(n);return(o,s,i)=>{if(Mg(o))return mn(Nt(r)(on(o),i),{onSuccess:Dg,onFailure:(a)=>Er(s,"values",a,o,i)});return R(new bt(s,o,i))}},{representation:{id:"effect/schema/Chunk",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Chunk(${n[0].runtime})`,Type:`Chunk.Chunk<${n[0].Type}>`}),expected:"Chunk",toCodec:([n])=>st()(je(n),ht({decode:Dg,encode:on})),toArbitrary:([n])=>(r,o)=>hy(r,o,n.arbitrary,n.terminal,Dg),toEquivalence:([n])=>bk(n),toFormatter:([n])=>(r)=>{let o=eF(r);if(o===0)return"Chunk(0) {}";let s=globalThis.Array.from(r).sort().map((i)=>`${n(i)}`);return`Chunk(${o}) { ${s.join(", ")} }`}});return K(t.ast,{value:e})}function mI(e,t,n){let r={...t};if(e?.minimum!==void 0){let o=n===void 0?e.minimum:n(e.minimum),s=e.exclusiveMinimum?new globalThis.Date(o.getTime()+1):o;if(r.min===void 0||s.getTime()>r.min.getTime())r.min=s}if(e?.maximum!==void 0){let o=n===void 0?e.maximum:n(e.maximum),s=e.exclusiveMaximum?new globalThis.Date(o.getTime()-1):o;if(r.max===void 0||s.getTime()<r.max.getTime())r.max=s}return r}function ay(e,t){return wa(e,t).value}function KX(e,t,n){return n?ay(hC(e,t),t)+globalThis.BigInt(1):ay(mC(e,t),t)}function GX(e,t,n){return n?ay(mC(e,t),t)-globalThis.BigInt(1):ay(hC(e,t),t)}function JX(e){return Math.max(xB,e.minimum?.scale??0,e.maximum?.scale??0,e.exclusiveMinimum&&e.minimum!==void 0?e.minimum.scale+1:0,e.exclusiveMaximum&&e.maximum!==void 0?e.maximum.scale+1:0)}function Zv(e,t){let n={};if(e.minimum!==void 0)n.min=KX(e.minimum,t,e.exclusiveMinimum===!0);if(e.maximum!==void 0)n.max=GX(e.maximum,t,e.exclusiveMaximum===!0);if(n.min!==void 0&&n.max!==void 0&&n.min>n.max)return;return n}function QX(e){let t=JX(e);if(Zv(e,t)===void 0)throw new globalThis.Error(yB);let n=0,r=t;while(n<r){let o=n+Math.floor((r-n)/2);if(Zv(e,o)===void 0)n=o+1;else r=o}return{min:n,max:t}}function SB(e,t){return XX.pipe(pe(e,kD(t)))}function ree(e){return xI.pipe(pe(e,CD))}function see(e){return yI.pipe(pe(e,vD))}function wI(e,t,n,r,o){let s=Fee(n,t,r),i=IB(t),a=class extends e{constructor(...[c,u]){let f=u?.["~payload"],d=f?.token===Xv?f.value:n.make(c??{},u);super(d,{...u,disableChecks:!0,"~payload":{token:Xv,value:d}})}static[Gp]=Gp;get[i](){return i}static[Pee]=!0;static identifier=t;static fields=n.fields;static get ast(){return s(this).ast}static pipe(){return fe(this,arguments)}static rebuild(c){return s(this).rebuild(c)}static make(c,u){return new this(c,u)}static makeOption(c,u){return Vx(s(this))(c??{},u)}static makeEffect(c,u){return s(this).makeEffect(c??{},u)}static annotate(c){return this.rebuild(xo(this.ast,c))}static annotateKey(c){return this.rebuild(_p(this.ast,c))}static check(...c){return this.rebuild(Ss(this.ast,c))}static extend(c){return(u,l)=>{let f=um(u)?u:te(u),d={...n.fields,...f.fields},m=yx(d,n.ast.checks,{identifier:c});return wI(this,c,rI(Ss(m,f.ast.checks),d),l,o)}}static mapFields(c,u){return n.mapFields(c,u)}};if(o!==void 0)Object.assign(a.prototype,o(t));return a}function Ree(e){return new Ne(Ae((t)=>new e(t,{"~payload":{token:Xv,value:t}})),Ho())}function IB(e){return`~effect/Schema/Class/${e}`}function Fee(e,t,n){let r;return(o)=>{if(r!==void 0)return r;let s=IB(t),i=(u)=>u instanceof o||D(u,s),a=Ree(o),c=K(new Uc([e.ast],()=>(u,l,f)=>i(u)?A(u):R(new bt(l,u,f)),{identifier:t,[Kg]:([u])=>({isConstructed:i,link:new wt(u,a)}),toCodec:([u])=>new wt(u.ast,a),toArbitrary:([u])=>()=>({arbitrary:u.arbitrary.map((l)=>new o(l)),terminal:u.terminal?.map((l)=>new o(l))}),toFormatter:([u])=>(l)=>`${o.identifier}(${u(l)})`,[fp]:Rl(e.ast),...n}));return r=pe(c,a)(e)}}function um(e){return uy(e)}function Dee(e){let t=DU(e.ast);return(n)=>t(n,{})}function Nee(e){return(t)=>t.annotate({toFormatter:e})}function $ee(e,t){return n(e.ast);function n(o){let s=gs(o)?.toFormatter;if(typeof s==="function")return s(va(o)?o.typeParameters.map(n):[]);if(t?.onBefore){let i=t.onBefore(o,n);if(i!==void 0)return i}return r(o)}function r(o){switch(o._tag){default:return j;case"Never":return()=>"never";case"Void":return()=>"void";case"Arrays":{let s=o.elements.map(n),i=o.rest.map(n);return(a)=>{let c=[],u=0;for(;u<s.length;u++)if(a.length<u+1){if(Mt(o.elements[u]))continue}else c.push(s[u](a[u]));if(i.length>0){let[l,...f]=i;for(;u<a.length-f.length;u++)c.push(l(a[u]));for(let d=0;d<f.length;d++)c.push(f[d](a[u+d]))}return"["+c.join(", ")+"]"}}case"Objects":{let s=o.propertySignatures.map((a)=>n(a.type)),i=o.indexSignatures.map((a)=>n(a.type));if(o.propertySignatures.length===0&&o.indexSignatures.length===0)return j;return(a)=>{let c=[],u=new Set;for(let l=0;l<s.length;l++){let f=o.propertySignatures[l],d=f.name;if(u.add(d),Mt(f.type)&&!Object.hasOwn(a,d))continue;c.push(`${$s(d)}: ${s[l](a[d])}`)}for(let l=0;l<i.length;l++){let f=Nc(a,o.indexSignatures[l].parameter);for(let d of f){if(u.has(d))continue;u.add(d),c.push(`${$s(d)}: ${i[l](a[d])}`)}}return c.length>0?"{ "+c.join(", ")+" }":"{}"}}case"Union":{let s=Tn(o).types,i=(c)=>Cp(c,s),a=new Map(s.map((c,u)=>[c,[Lp(c),n(o.types[u])]]));return(c)=>{let u=i(c);for(let l=0;l<u.length;l++){let[f,d]=a.get(u[l]);if(f(c))return d(c)}return j(c)}}case"Suspend":{let s=Lc(()=>n(o.thunk()));return(i)=>s()(i)}}}}function Uee(e){return(t)=>t.annotate({toEquivalence:e})}function Lee(e){return $U(e.ast)}function Bee(e,t){return zv(e.ast,t)}function TB(e,t){let n=zv(yy(e.ast),t);return XU(n,t)}function _B(e){return K(yy(e.ast),{schema:e})}function kI(e){return e.constructorDefault===void 0?e:new jo(e.isOptional,e.isMutable,void 0,e.annotations)}function OB(e){if(e.propertySignatures.some((t)=>typeof t.name!=="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function PB(e){return(t)=>{let n=new Map;for(let s=0;s<t.length;s++)n.set(kr(t[s]),s);let r=[...t].sort((s,i)=>{s=kr(s),i=kr(i);let a=e(s),c=e(i);if(a!==c)return a-c;return n.get(s)-n.get(i)});if(!r.some((s,i)=>s!==t[i]))return t;return r}}function Wee(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Mn(n))return ot(e,[ev]);let r=e.typeParameters.map((s)=>Hp(kr(s))),o=n(r);return o===void 0?e:ot(e,[Nl(o,t)])}case"Unknown":return ot(e,[ev]);case"ObjectKeyword":return ot(e,[AN]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return OB(e),e.recur(t,Tx);case"Union":{let n=Hee(e.types);if(n!==e.types)return new ir(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function RB(e){return K(FB(Tn(e.ast)))}function jee(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecIso??e.annotations?.toCodec;if(Mn(n)){let r=n(e.typeParameters.map((o)=>Hp(o)));return ot(e,[Nl(r,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}function lm(e){return K(NB(e.ast),{schema:e})}function qee(e){return K($B(e.ast))}function zee(e,t){let n=vl(e.ast)??Hk(e.ast),r=H2(lm(e));return(o)=>r(o).pipe(ae((s)=>Vee(s,{rootName:n,...t})))}function Vee(e,t){let n=t.rootName??"root",r=t.arrayItemName??"item",o=t.pretty??!0,s=t.indent??" ",i=t.sortKeys??!0,a=new Set,c=[];return l(n,e,0),c.join(o?`
|
|
36
|
+
`:"");function u(f,d){c.push(o?s.repeat(f)+d:d)}function l(f,d,m,y){let{attrs:b,safe:E}=Jl.tagInfo(f,y);if(d===void 0)u(m,`<${E}${b}/>`);else if(typeof d==="string")u(m,`<${E}${b}>${Jl.escapeText(d)}</${E}>`);else if(typeof d!=="object"||d===null)u(m,`<${E}${b}>${Jl.escapeText(j(d))}</${E}>`);else{if(a.has(d))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:d});a.add(d);try{if(globalThis.globalThis.Array.isArray(d)){if(d.length===0){u(m,`<${E}${b}/>`);return}u(m,`<${E}${b}>`);for(let g of d)l(r,g,m+1);u(m,`</${E}>`);return}let w=d,k=Object.keys(w);if(i)k.sort();if(k.length===0){u(m,`<${E}${b}/>`);return}u(m,`<${E}${b}>`);for(let g of k)l(Jl.parseTagName(g).safe,w[g],m+1,g);u(m,`</${E}>`)}finally{a.delete(d)}}}}function Gee(e,t,n){switch(e._tag){case"Declaration":{let r=e.typeParameters.map((u)=>K(t(kr(u)))),o=e.annotations?.toCodecStringTree;if(Mn(o)){let u=o(r);if(u===void 0)return e;return ot(e,[Nl(u,t)])}let s=e.annotations?.toCodecJson,i=Mn(s)?s(r):void 0,a=i===void 0?e.annotations?.toCodec:void 0,c=i??(Mn(a)?a(r):void 0);return c===void 0?n(e):ot(e,[Nl(c,t)])}case"Null":return ot(e,[Jee]);case"Boolean":return ot(e,[Qee]);case"Unknown":case"ObjectKeyword":return ot(e,[tv]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return OB(e),e.recur(t,Tx);case"Union":{let r=Kee(e.types);if(r!==e.types)return new ir(r,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function Zee(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur($B):e}function cte(e){let t=RB(e);return u2(Pv(t),_v(t))}function ute(e){return ry()}function lte(e){return ry()}function fte(e,t){return(n)=>K(xo(n.ast,{toCodecIso:()=>new wt(e.ast,lx(t))}),{schema:n})}function dte(e){let t=_B(e),n=Pv(t),r=_v(t);return{empty:[],diff:(o,s)=>r2(n(o),n(s)),combine:(o,s)=>[...o,...s],patch:(o,s)=>{let i=n(o),a=o2(s,i);return Object.is(a,i)?o:r(a)}}}function pte(e){let t=Z2(()=>n),n=kt([e,je(t),fy(Q,t)]);return n}function yte(e){return gs(e.ast)}function Ste(e){return e.ast.context?.annotations}var Gp,Jp="~effect/SchemaError/SchemaError",Kc,Zp,wY,kY,CY,vY,IY,AY,TY,_Y,H2,OY,PY,RY,FY,MY,DY,K,vi,NY,cr,$Y,UY,LY,ur,ef,Qp="~effect/Schema/flip",qY,zY,tI,Le,nI,Q,Yp,ly,K2,ks,VY,KY,QY=(e)=>typeof e==="symbol"?e:globalThis.String(e),je,t7,o7,oI,dy,Q2,it,E2="^\\S[\\s\\S]*\\S$|^\\S$|^$",y7,S7,E7,b7,w7,k7,C7=(e)=>{if(e)return new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/},v7,b2,I7,A7,T7,_7,O7,P7,R7,w2="^[^a-z]*$",F7,k2="^[^A-Z]*$",M7,C2="^[^a-z]?.*$",D7,v2="^[^A-Z]?.*$",N7,Cr,bL,$7,kL,U7,uI,L7,CL,B7,vL,H7,om,W7,IL,j7,q7,Cs,_n,AL,TL,_L,OL,PL,RL,FL,ML,DL,NL,K7,G7,J7,Q7,Z7,Y7,X7,eX,tX,nX,rX,oX,sX,iX,aX,cX,VL,uX,lX,xX,yX,SX,EX,wX,kX,CX,vX,eB=(e)=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),tB=(e)=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},I2,IX,A2,AX,TX,RX,FX,MX,DX,NX,dB,$X,pB,gy,UX,LX,mB,vr,BX,HX,WX,im,jX,qX,hB,zX,VX,gB,xB=20,yB="Unable to derive an arbitrary for the ordered BigDecimal constraints",hI,ZX,YX,XX,eee,gI,tee,xI,nee,yI,oee,iee,aee,cee,EB,uee,lee,fee,dee,pee,Yv,mee,hee,bB,am,gee,xee,yee,See,cm,Eee,bee,wee,kee,wB,Cee,kB,SI,vee,Iee,CB,EI,Aee,Tee,vB,bI,_ee,Oee,Pee,Xv,AB=(e)=>(t,n)=>{let r=um(t)?t:te(t);return wI(Sh,e,r,n,(o)=>({toString(){return`${o}(${j({...this})})`}}))},Mee=(e)=>(t,n,r)=>{let o=um(n)?n.mapFields((s)=>({_tag:Ii(t),...s}),{unsafePreserveChecks:!0}):py(t,n);return AB(e??t)(o,r)},xy=(e)=>(t,n)=>{let r=um(t)?t:te(t);return wI(Bf,e,r,n,(s)=>({name:s}))},Qo=(e)=>(t,n,r)=>{let o=um(n)?n.mapFields((s)=>({_tag:Ii(t),...s}),{unsafePreserveChecks:!0}):py(t,n);return xy(e??t)(o,r)},yy,Hee,FB,Jl,Kee,Jee,Qee,MB,DB=(e)=>e.transformation===MB,NB,P2=(e)=>Mt(e)?$l(Ei):Ei,$B,Yee,Xee,ete,tte,nte,rte,ote,ste,ite,ate,fm,mte,hte,gte,UB,xte;var Qc=v(()=>{nr();gC();In();tF();Vu();nx();Yi();Re();wh();Pt();Ws();jr();Zn();ne();T$();L$();V$();pt();At();xv();ya();fU();NU();UU();e2();t2();_h();i2();Hv();pg();p2();Me();rc();ct();ge();TT();Kp();Wv();Bn();yh();bi();ax();Ea();Gx();px();Qx();Gp=Jx;Kc=class Kc extends Xi("SchemaError"){[Jp]=Jp;constructor(e){let t=ta();$r(0);try{super({issue:e})}finally{$r(t)}}get message(){return hM(this.issue)}toString(){return`SchemaError(${this.message})`}};Zp=J$,wY=Z$;kY=Ai;CY=$2,vY=Tv,IY=X$;AY=U2;TY=L2;_Y=B2;H2=cy;OY=W2,PY=Ov,RY=nU;FY=j2;MY=q2;DY=z2,K=Hp;vi=qn((e)=>K($l(e.ast),{schema:e})),NY=qn((e)=>e.schema),cr=qn((e)=>{let t=dy(e);return K(dN(e.ast),{schema:t})}),$Y=qn((e)=>e.schema.members[0]),UY=qn((e)=>K(GC(e.ast),{schema:e})),LY=qn((e)=>e.schema),ur=qn((e)=>K(Tn(e.ast),{schema:e})),ef=qn((e)=>K(kr(e.ast),{schema:e}));qY=K(WD),zY=K(qD),tI=K(Ei),Le=K(MC),nI=K(DC),Q=K(ys),Yp=K(LC),ly=K(YD),K2=K(eN),ks=K(nN),VY=K(BD),KY=K(KD);je=qn((e)=>K(new qo(!1,[],[e.ast]),{value:e})),t7=qn((e)=>K(new qo(!1,[e.ast],[e.ast]),{value:e}));o7=qn((e)=>K(new qo(!0,e.ast.elements,e.ast.rest),{schema:e}));oI=qn((e)=>kt([e,Le])),dy=qn((e)=>kt([e,nI])),Q2=qn((e)=>kt([e,Le,nI]));it=wx;y7=xe("effect/schema/isTrimmed",Le,({annotations:e})=>aI(e));S7=te({source:Q,flags:Q}).check(it((e)=>{let t=OE(()=>new globalThis.RegExp(e.source,e.flags));return rn(t)&&t.success.source===e.source&&t.success.flags===e.flags})),E7={id:"effect/schema/isPattern",payloadSchema:S7,revive:({annotations:e,payload:t})=>Gc(new globalThis.RegExp(t.source,t.flags),e)};b7=xe("effect/schema/isStringFinite",Le,({annotations:e})=>aL(e));w7=xe("effect/schema/isStringBigInt",Le,({annotations:e})=>cL(e));k7=xe("effect/schema/isStringSymbol",Le,({annotations:e})=>uL(e));v7=xe("effect/schema/isUUID",te({version:kt([Ti([1,2,3,4,5,6,7,8]),Le])}),({annotations:e,payload:t})=>lL(t.version??void 0,e)),b2=/^([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})$/;I7=xe("effect/schema/isGUID",Le,({annotations:e})=>fL(e));A7=xe("effect/schema/isULID",Le,({annotations:e})=>dL(e));T7=xe("effect/schema/isBase64",Le,({annotations:e})=>cI(e));_7=xe("effect/schema/isBase64Url",Le,({annotations:e})=>pL(e));O7=xe("effect/schema/isStartsWith",te({startsWith:Q}),({annotations:e,payload:t})=>mL(t.startsWith,e));P7=xe("effect/schema/isEndsWith",te({endsWith:Q}),({annotations:e,payload:t})=>hL(t.endsWith,e));R7=xe("effect/schema/isIncludes",te({includes:Q}),({annotations:e,payload:t})=>gL(t.includes,e));F7=xe("effect/schema/isUppercased",Le,({annotations:e})=>xL(e));M7=xe("effect/schema/isLowercased",Le,({annotations:e})=>yL(e));D7=xe("effect/schema/isCapitalized",Le,({annotations:e})=>SL(e));N7=xe("effect/schema/isUncapitalized",Le,({annotations:e})=>EL(e)),Cr=K(qC),bL=jC,$7=xe("effect/schema/isFinite",Le,({annotations:e})=>bL(e));kL=Xp({order:Mr,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:Zl(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${j(e)})`})})}),U7=xe("effect/schema/isGreaterThan",te({exclusiveMinimum:Cr}),({annotations:e,payload:t})=>kL(t.exclusiveMinimum,e)),uI=em({order:Mr,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:Zl(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${j(e)})`})})}),L7=xe("effect/schema/isGreaterThanOrEqualTo",te({minimum:Cr}),({annotations:e,payload:t})=>uI(t.minimum,e)),CL=tm({order:Mr,annotate:(e)=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:Zl(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${j(e)})`})})}),B7=xe("effect/schema/isLessThan",te({exclusiveMaximum:Cr}),({annotations:e,payload:t})=>CL(t.exclusiveMaximum,e)),vL=nm({order:Mr,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:Zl(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${j(e)})`})})}),H7=xe("effect/schema/isLessThanOrEqualTo",te({maximum:Cr}),({annotations:e,payload:t})=>vL(t.maximum,e)),om=rm({order:Mr,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:Zl(e.minimum),maximum:Zl(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[n?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${j(e.minimum)}, maximum: ${j(e.maximum)}, exclusiveMinimum: ${j(t)}, exclusiveMaximum: ${j(n)} })`})}}}),W7=xe("effect/schema/isBetween",te({minimum:Cr,maximum:Cr,exclusiveMinimum:cr(et(!0)),exclusiveMaximum:cr(et(!0))}),({annotations:e,payload:t})=>om(t,e)),IL=wL({remainder:JR,zero:0,annotate:(e)=>({expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${j(e)})`})})}),j7=xe("effect/schema/isMultipleOf",te({divisor:Cr}),({annotations:e,payload:t})=>IL(t.divisor,e));q7=xe("effect/schema/isInt",Le,({annotations:e})=>sm(e)),Cs=Yp.check(sm()),_n=Cs.check(uI(0));AL=Xp({order:nc,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:Yl(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanDate(${Xl(e)})`})})}),TL=em({order:nc,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:Yl(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${Xl(e)})`})})}),_L=tm({order:nc,annotate:(e)=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:Yl(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanDate(${Xl(e)})`})})}),OL=nm({order:nc,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:Yl(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${Xl(e)})`})})}),PL=rm({order:nc,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:Yl(e.minimum),maximum:Yl(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${Xl(e.minimum)}, maximum: ${Xl(e.maximum)}, exclusiveMinimum: ${j(t)}, exclusiveMaximum: ${j(n)} })`})}}}),RL=Xp({order:so,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${j(e)})`})})}),FL=em({order:so,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${j(e)})`})})}),ML=tm({order:so,annotate:(e)=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanBigInt(${j(e)})`})})}),DL=nm({order:so,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${j(e)})`})})}),NL=rm({order:so,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenBigInt",payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${j(e.minimum)}, maximum: ${j(e.maximum)}, exclusiveMinimum: ${j(t)}, exclusiveMaximum: ${j(n)} })`})}}}),K7=Xp({order:Si,formatter:(e)=>xs(e)}),G7=em({order:Si,formatter:(e)=>xs(e)}),J7=tm({order:Si,formatter:(e)=>xs(e)}),Q7=nm({order:Si,formatter:(e)=>xs(e)}),Z7=rm({order:Si,formatter:(e)=>xs(e)});Y7=xe("effect/schema/isMinLength",te({minLength:_n}),({annotations:e,payload:t})=>lI(t.minLength,e));X7=xe("effect/schema/isMaxLength",te({maxLength:_n}),({annotations:e,payload:t})=>UL(t.maxLength,e));eX=xe("effect/schema/isLengthBetween",te({minimum:_n,maximum:_n}),({annotations:e,payload:t})=>fI(t.minimum,t.maximum,e));tX=xe("effect/schema/isMinSize",te({minSize:_n}),({annotations:e,payload:t})=>LL(t.minSize,e));nX=xe("effect/schema/isMaxSize",te({maxSize:_n}),({annotations:e,payload:t})=>BL(t.maxSize,e));rX=xe("effect/schema/isSizeBetween",te({minimum:_n,maximum:_n}),({annotations:e,payload:t})=>HL(t.minimum,t.maximum,e));oX=xe("effect/schema/isMinProperties",te({minProperties:_n}),({annotations:e,payload:t})=>WL(t.minProperties,e));sX=xe("effect/schema/isMaxProperties",te({maxProperties:_n}),({annotations:e,payload:t})=>jL(t.maxProperties,e));iX=xe("effect/schema/isPropertiesLengthBetween",te({minimum:_n,maximum:_n}),({annotations:e,payload:t})=>qL(t.minimum,t.maximum,e));aX=xe("effect/schema/isPropertyNames",Le,({annotations:e,schemas:t})=>zL(t[0],e));cX=xe("effect/schema/isUnique",Le,({annotations:e})=>dI(e)),VL=Q.check($L()),uX=Q.check(fI(1,1));lX=ar("effect/schema/Option",Le,({annotations:e,typeParameters:t})=>{let n=Pa(t[0]);return e===void 0?n:n.annotate(e)});xX=ar("effect/schema/Result",Le,({annotations:e,typeParameters:t})=>{let n=KL(t[0],t[1]);return e===void 0?n:n.annotate(e)}),yX=Eo((e)=>{if(!Dn(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every((n)=>{switch(n){case"label":return typeof e[n]==="string";case"disallowJsonEncode":return e[n]===!0;default:return!1}})}),SX=kt([Le,yX]);EX=ar("effect/schema/Redacted",SX,({annotations:e,payload:t,typeParameters:n})=>{let r=my(n[0],t??void 0);return e===void 0?r:r.annotate(e)});wX=ar("effect/schema/CauseReason",Le,({annotations:e,typeParameters:t})=>{let n=sy(t[0],t[1]);return e===void 0?n:n.annotate(e)});kX=ar("effect/schema/Cause",Le,({annotations:e,typeParameters:t})=>{let n=iy(t[0],t[1]);return e===void 0?n:n.annotate(e)});CX=Eo((e)=>{if(!Dn(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every((n)=>(n==="includeStack"||n==="excludeCause")&&e[n]===!0)}),vX=kt([Le,CX]),I2=[];IX=ar("effect/schema/Error",vX,({annotations:e,payload:t})=>{let n=nB(t??void 0);return e===void 0?n:n.annotate(e)}),A2=[];AX=ar("effect/schema/Exit",Le,({annotations:e,typeParameters:t})=>{let n=rB(t[0],t[1],t[2]);return e===void 0?n:n.annotate(e)});TX=ar("effect/schema/ReadonlyMap",Le,({annotations:e,typeParameters:t})=>{let n=iB(t[0],t[1]);return e===void 0?n:n.annotate(e)});RX=ar("effect/schema/Graph",Ti(["directed","undirected"]),({annotations:e,payload:t,typeParameters:n})=>{let r=aB(t,n[0],n[1]);return e===void 0?r:r.annotate(e)});FX=ar("effect/schema/HashMap",Le,({annotations:e,typeParameters:t})=>{let n=cB(t[0],t[1]);return e===void 0?n:n.annotate(e)});MX=ar("effect/schema/ReadonlySet",Le,({annotations:e,typeParameters:t})=>{let n=uB(t[0]);return e===void 0?n:n.annotate(e)});DX=ar("effect/schema/HashSet",Le,({annotations:e,typeParameters:t})=>{let n=lB(t[0]);return e===void 0?n:n.annotate(e)});NX=ar("effect/schema/Chunk",Le,({annotations:e,typeParameters:t})=>{let n=fB(t[0]);return e===void 0?n:n.annotate(e)}),dB=Oa(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),expected:"RegExp",toCodecJson:()=>st()(te({source:Q,flags:Q}),Qr({decode:(e,t)=>Xt({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new Ie({expected:"valid RegExp source and flags"},e,t)}),encode:(e)=>A({source:e.source,flags:e.flags})})),toArbitrary:()=>(e)=>e.tuple(e.constantFrom(".",".*","\\d+","\\w+","[a-z]+","[A-Z]+","[0-9]+","^[a-zA-Z0-9]+$","^\\d{4}-\\d{2}-\\d{2}$"),e.uniqueArray(e.constantFrom("g","i","m","s","u","y"),{minLength:0,maxLength:6}).map((t)=>t.join(""))).map(([t,n])=>new globalThis.RegExp(t,n)),toEquivalence:()=>(e,t)=>e.source===t.source&&e.flags===t.flags}),$X=zn("effect/schema/RegExp",dB),pB=Q.annotate({expected:"a string that will be decoded as a URL"}),gy=Oa(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),expected:"URL",toCodecJson:()=>st()(pB,yC),toArbitrary:()=>(e)=>e.webUrl().map((t)=>new globalThis.URL(t)),toEquivalence:()=>(e,t)=>e.toString()===t.toString()}),UX=zn("effect/schema/URL",gy),LX=pB.pipe(pe(gy,yC));mB=Q.annotate({expected:"a string that will be decoded as a Date"}),vr=Eo((e)=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),expected:"a valid Date",toCodecJson:()=>st()(mB,xC),toArbitrary:()=>(e,t)=>e.date(mI(t?.constraint?.ordered?.order===nc?t.constraint.ordered:void 0,{noInvalidDate:!0}))}),BX=zn("effect/schema/Date",vr),HX=mB.pipe(pe(vr,xC)),WX=Cs.pipe(pe(vr,sD)),im=Eo(HE,{representation:{id:"effect/schema/Duration",payload:null},toCode:()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),expected:"Duration",toCodecJson:()=>st()(kt([te({_tag:et("Infinity")}),te({_tag:et("NegativeInfinity")}),te({_tag:et("Nanos"),value:ks}),te({_tag:et("Millis"),value:Cs})]),ht({decode:(e)=>{switch(e._tag){case"Infinity":return Gs;case"NegativeInfinity":return lc;case"Nanos":return io(e.value);case"Millis":return Zi(e.value)}},encode:(e)=>{switch(e.value._tag){case"Infinity":return{_tag:"Infinity"};case"NegativeInfinity":return{_tag:"NegativeInfinity"};case"Nanos":return{_tag:"Nanos",value:e.value.nanos};case"Millis":return{_tag:"Millis",value:e.value.millis}}}})),toArbitrary:()=>(e)=>e.oneof(e.constant(Gs),e.constant(lc),e.bigInt().map(io),e.maxSafeInteger().map(Zi)),toFormatter:()=>globalThis.String,toEquivalence:()=>WE}),jX=zn("effect/schema/Duration",im),qX=Q.annotate({expected:"a string that will be decoded as a Duration"}),hB=qX.pipe(pe(im,iD)),zX=ks.pipe(pe(im,aD)),VX=Yp.pipe(pe(im,cD)),gB=Q.annotate({expected:"a string that will be decoded as a BigDecimal"});hI=Eo(ux,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),expected:"BigDecimal",toCodecJson:()=>st()(gB,SC),toArbitrary:()=>(e,t)=>{let n=t.constraint?.ordered?.order===Si?t.constraint.ordered:void 0;if(n===void 0)return e.tuple(e.bigInt(),e.integer({min:0,max:xB})).map(([r,o])=>wr(r,o));return e.integer(QX(n)).chain((r)=>{let o=Zv(n,r);if(o===void 0)throw new globalThis.Error(yB);return e.bigInt(o).map((s)=>wr(s,r))})},toFormatter:()=>(e)=>xs(e),toEquivalence:()=>dC}),ZX=zn("effect/schema/BigDecimal",hI),YX=gB.pipe(pe(hI,SC)),XX=Q.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});eee=SB(tI),gI=Oa(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:()=>({runtime:"Schema.File",Type:"globalThis.File"}),expected:"File",toCodecJson:()=>st()(te({data:Q.check(cI()),type:Q,name:Q,lastModified:Cs}),Qr({decode:(e,t)=>mr(Gu(e.data),{onFailure:()=>R(new Ie({expected:"a valid Base64 string"},e.data,t)),onSuccess:(n)=>{let r=new globalThis.Uint8Array(n);return A(new globalThis.File([r],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>fl({try:async()=>{let n=new globalThis.Uint8Array(await e.arrayBuffer());return{data:bh(n),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new Ie({expected:"a readable File"},e,t)})}))}),tee=zn("effect/schema/File",gI),xI=Oa(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),expected:"FormData",toCodecJson:()=>st()(je(Ql([Q,kt([te({_tag:Ii("String"),value:Q}),te({_tag:Ii("File"),value:gI})])])),Qr({decode:(e)=>{let t=new globalThis.FormData;for(let[n,r]of e)t.append(n,r.value);return A(t)},encode:(e)=>A(globalThis.Array.from(e.entries()).map(([t,n])=>{if(typeof n==="string")return[t,{_tag:"String",value:n}];else return[t,{_tag:"File",value:n}]}))}))}),nee=zn("effect/schema/FormData",xI);yI=Oa(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),expected:"URLSearchParams",toCodecJson:()=>st()(Q.annotate({expected:"a query string that will be decoded as URLSearchParams"}),ht({decode:(e)=>new globalThis.URLSearchParams(e),encode:(e)=>e.toString()}))}),oee=zn("effect/schema/URLSearchParams",yI);iee=Q.annotate({expected:"a string that will be decoded as a number"}).pipe(pe(Yp,Ol)),aee=Q.annotate({expected:"a string that will be decoded as a finite number"}).pipe(pe(Cr,Ol)),cee=K(YC).pipe(pe(ks,dx)),EB=Q.check(aI()),uee=Q.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(pe(EB,oD())),lee=Q.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(pe(Q,SD)),fee=Q.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(pe(Q,ED)),dee=Q.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(pe(Q,bD)),pee=Q.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(pe(Q,wD)),Yv=kt([Cr,K2,Q]),mee=te({issues:je(te({message:Q,path:cr(je(kt([Yv,te({key:Yv})])))}))}),hee=Ti([0,1]).pipe(pe(ly,ht({decode:(e)=>e===1,encode:(e)=>e?1:0}))),bB=Q.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),am=Oa(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>st()(bB,EC),toArbitrary:()=>(e)=>e.uint8Array()}),gee=zn("effect/schema/Uint8Array",am),xee=bB.pipe(pe(am,EC)),yee=Q.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(pe(am,{decode:$M(),encode:sx()})),See=Q.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(pe(am,{decode:LM(),encode:ix()})),cm=Eo((e)=>Yk(e)&&EM(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Utc",toCodecJson:()=>st()(Q,kC),toArbitrary:()=>(e,t)=>e.date(mI(t?.constraint?.ordered?.order===eC?t.constraint.ordered:void 0,{noInvalidDate:!0},ex)).map((n)=>wM(n)),toFormatter:()=>(e)=>e.toString(),toEquivalence:()=>Xk}),Eee=zn("effect/schema/DateTimeUtc",cm),bee=vr.pipe(pe(cm,{decode:cC(),encode:Ae(ex)})),wee=Q.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(pe(cm,kC)),kee=Cs.pipe(pe(cm,{decode:cC(),encode:Ae(AM)})),wB=Eo(yM,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Offset",toCodecJson:()=>st()(Cs,ID),toArbitrary:()=>(e)=>e.integer({min:-43200000,max:50400000}).map((t)=>xp(t)),toFormatter:()=>(e)=>ba(e),toEquivalence:()=>(e,t)=>e.offset===t.offset}),Cee=zn("effect/schema/TimeZoneOffset",wB),kB=Q.annotate({expected:"an IANA time zone identifier"}),SI=Eo(SM,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Named",toCodecJson:()=>st()(kB,bC),toArbitrary:()=>(e)=>e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(tC)),toFormatter:()=>(e)=>ba(e),toEquivalence:()=>(e,t)=>e.id===t.id}),vee=zn("effect/schema/TimeZoneNamed",SI),Iee=kB.pipe(pe(SI,bC)),CB=Q.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),EI=Eo(xM,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone",toCodecJson:()=>st()(CB,wC),toArbitrary:()=>(e)=>e.oneof(e.integer({min:-43200000,max:50400000}).map((t)=>xp(t)),e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(tC))),toFormatter:()=>(e)=>ba(e),toEquivalence:()=>(e,t)=>ba(e)===ba(t)}),Aee=zn("effect/schema/TimeZone",EI),Tee=CB.pipe(pe(EI,wC)),vB=Q.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),bI=Eo((e)=>Yk(e)&&bM(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Zoned",toCodecJson:()=>st()(vB,CC),toArbitrary:()=>(e,t)=>e.tuple(e.date(mI(t?.constraint?.ordered?.order===eC?t.constraint.ordered:void 0,{max:new globalThis.Date(8639999949600000),min:new globalThis.Date(-8639999949600000),noInvalidDate:!0},ex)),e.constantFrom("UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney")).map(([n,r])=>kM(n,{timeZone:r})),toFormatter:()=>(e)=>tx(e),toEquivalence:()=>Xk}),_ee=zn("effect/schema/DateTimeZoned",bI),Oee=vB.pipe(pe(bI,CC)),Pee=globalThis.Symbol.for("immer-draftable"),Xv={};yy=Bc((e)=>{let t=Wee(e,yy),n=e.context;if(t===e||n===void 0)return t;return vx(t,kI(n))});Hee=PB((e)=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});FB=bn((e)=>{let t=jee(e,FB);return t!==e&&e.context!==void 0?vx(t,kI(e.context)):t});Jl={escapeText(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},escapeAttribute(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},parseTagName(e){let t=e,n=e;if(!/^[A-Za-z_]/.test(n))n="_"+n;if(n=n.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(n))n="_"+n;return{safe:n,changed:n!==t}},tagInfo(e,t){let{changed:n,safe:r}=Jl.parseTagName(e),s=n||t&&t!==e?` data-name="${Jl.escapeAttribute(t??e)}"`:"";return{safe:r,attrs:s}}},Kee=PB((e)=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});Jee=new wt(new Zr("null"),new Ne(Ae(()=>null),Ae(()=>"null"))),Qee=new wt(new ir([new Zr("true"),new Zr("false")],"anyOf"),new Ne(Ae((e)=>e==="true"),Dc())),MB=new Ne(Ae((e)=>typeof e==="string"?[e]:e),Ho()),NB=Bc((e)=>{let t=Gee(e,NB,(n)=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:n})});if(t!==e&&e.context!==void 0)return vx(t,kI(e.context));return t},{stopAt:DB}),$B=Bc((e)=>{let t=Zee(e);if(FC(t)){let n=Ix(new ir([new qo(t.isMutable,t.elements.map(P2),t.rest.map(P2)),ys],"anyOf"),t,MB);return Mt(e)?$l(n):n}return t},{stopAt:DB});Yee=xe("effect/schema/isGreaterThanDate",te({exclusiveMinimum:vr}),({annotations:e,payload:t})=>AL(t.exclusiveMinimum,e)),Xee=xe("effect/schema/isGreaterThanOrEqualToDate",te({minimum:vr}),({annotations:e,payload:t})=>TL(t.minimum,e)),ete=xe("effect/schema/isLessThanDate",te({exclusiveMaximum:vr}),({annotations:e,payload:t})=>_L(t.exclusiveMaximum,e)),tte=xe("effect/schema/isLessThanOrEqualToDate",te({maximum:vr}),({annotations:e,payload:t})=>OL(t.maximum,e)),nte=xe("effect/schema/isBetweenDate",te({minimum:vr,maximum:vr,exclusiveMinimum:cr(et(!0)),exclusiveMaximum:cr(et(!0))}),({annotations:e,payload:t})=>PL(t,e)),rte=xe("effect/schema/isGreaterThanBigInt",te({exclusiveMinimum:ks}),({annotations:e,payload:t})=>RL(t.exclusiveMinimum,e)),ote=xe("effect/schema/isGreaterThanOrEqualToBigInt",te({minimum:ks}),({annotations:e,payload:t})=>FL(t.minimum,e)),ste=xe("effect/schema/isLessThanBigInt",te({exclusiveMaximum:ks}),({annotations:e,payload:t})=>ML(t.exclusiveMaximum,e)),ite=xe("effect/schema/isLessThanOrEqualToBigInt",te({maximum:ks}),({annotations:e,payload:t})=>DL(t.maximum,e)),ate=xe("effect/schema/isBetweenBigInt",te({minimum:ks,maximum:ks,exclusiveMinimum:cr(et(!0)),exclusiveMaximum:cr(et(!0))}),({annotations:e,payload:t})=>NL(t,e));fm=K(xo(Ml,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})})),mte=fy(Q,fm),hte=zn("effect/schema/Json",fm),gte=te({message:Q,name:vi(Q),stack:vi(Q),cause:vi(fm)}),UB=K(xo(IN,{toCode:()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"})})),xte=zn("effect/schema/MutableJson",UB)});var LB="~effect/platform/Terminal",CI="effect/platform/Terminal/QuitError",dm,BB=(e)=>D(e,CI),Zo,HB=(e)=>Zo.of({...e,[LB]:LB});var Sy=v(()=>{rt();ge();Qc();dm=class dm extends xy("QuitError")({_tag:Ii("QuitError")}){[CI]=CI};Zo=Ye("effect/platform/Terminal")});import*as Ey from"readline";function qB(e){return e.key.ctrl&&(e.key.name==="c"||e.key.name==="d")}var WB,jB;var zB=v(()=>{Re();cs();Me();ms();ge();op();KF();Sy();WB=q(function*(e=qB){let{stdin:t,stdout:n}=process,r=yield*wl(),o=t.readableEnded,s=!1,i=()=>{if(o=!0,!s)pi(r)};t.once("end",i),yield*Ig(()=>we(()=>t.off("end",i)));let a=yield*VF({acquire:po(we(()=>{let m=Ey.createInterface({input:t,escapeCodeTimeout:50}),y=(E)=>tp(r,E),b=()=>{s=!1,pi(r)};if(s=!0,Ey.emitKeypressEvents(t,m),m.on("line",y),m.once("close",b),t.isTTY)t.setRawMode(!0);return{rl:m,onClose:b,onLine:y}}),({rl:m,onClose:y,onLine:b})=>we(()=>{if(s=!1,m.off("line",b),m.off("close",y),t.isTTY)t.setRawMode(!1);if(m.close(),o)pi(r)})),idleTimeToLive:"10 millis"}),c=we(()=>n.columns??0),u=we(()=>n.rows??0),l=un(function*(){let m=yield*wl(),y=(w,k)=>{let g={input:zs(w),key:{name:k.name??"",ctrl:!!k.ctrl,meta:!!k.meta,shift:!!k.shift}};if(tp(m,g),e(g))pi(m)},b=setInterval(()=>{},2147483647),E=()=>{clearInterval(b),pi(m)};if(yield*Ig(()=>we(()=>{clearInterval(b),t.off("keypress",y),t.off("end",E)})),t.on("keypress",y),o)E();else yield*Mk(a),t.once("end",E);return m}),f=He(()=>xF(r).pipe(se(ut({onNone:()=>ma(Vr(Mk(a),mi(r))),onSome:A})),Gt(()=>new dm({}))));return HB({columns:c,rows:u,readInput:l,readLine:f,display:(m)=>Kd(Wn((y)=>{n.write(m,(b)=>MA(b)?y(Pe):y(R(li({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:b}))))}))})}),jB=il(Zo,WB(qB))});var VB;var KB=v(()=>{zB();VB=jB});var by={};Qn(by,{layer:()=>wte});var wte;var GB=v(()=>{cs();VN();s$();m$();y$();C$();KB();wte=jN.pipe(TR(ug(p$,o$,x$,k$,VB)))});var II=v(()=>{J1();GB()});var vs=v(()=>{In();Vu();Re();jr();Me();Bn();Qc()});var Zc="__tripwire_dynamic_shell_value__",AI=(e)=>({start:e.pos,end:e.end}),kte=(e)=>{let t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)},TI=()=>({aliases:new Map,backgroundPidAvailable:!1,bindings:new Map,functions:new Map,temps:new Map}),ln=(e)=>({aliases:new Map(e.aliases),backgroundPidAvailable:e.backgroundPidAvailable,bindings:new Map(e.bindings),functions:new Map(e.functions),temps:new Map(e.temps)}),_I=(e)=>e.type==="SingleQuoted"||e.type==="DoubleQuoted"||e.type==="AnsiCQuoted"||e.type==="LocaleString",QB=(e)=>e.every((t)=>{switch(t.type){case"Literal":case"SingleQuoted":case"AnsiCQuoted":return!0;case"DoubleQuoted":case"LocaleString":return QB(t.parts);case"SimpleExpansion":case"ParameterExpansion":case"CommandExpansion":case"ArithmeticExpansion":case"ProcessSubstitution":case"ExtendedGlob":case"BraceExpansion":return!1;default:return!1}}),_i=(e)=>QB(e.parts??[]),ZB=(e)=>{if(e===void 0||(e.errors?.length??0)>0||e.commands.length!==1)return null;let[t]=e.commands;if(t===void 0||t.background===!0||t.redirects.length>0)return null;let{command:n}=t;if(n.type!=="Command"||n.name===void 0||!_i(n.name))return null;if(n.prefix.length>0||n.suffix.some((r)=>!_i(r)))return null;return{command:n,head:kte(n.name.value),args:n.suffix.map((r)=>r.value)}},YB=(e)=>{let t=e.parts??[];if(t.length!==1)return;let[n]=t;if(n?.type==="CommandExpansion")return n.script;if(n?.type!=="DoubleQuoted"||n.parts.length!==1)return;let[r]=n.parts;return r?.type==="CommandExpansion"?r.script:void 0},XB=(e,t)=>e.command.name?.value.includes("/")===!1&&(t.aliases.has(e.head)||t.functions.has(e.head)),OI=(e,t)=>{let n=ZB(YB(e));if(n===null||XB(n,t))return null;if(n.head==="cat"&&n.args.length===0&&n.command.redirects.length===1){let[r]=n.command.redirects;if(r?.operator!=="<<"&&r?.operator!=="<<-")return null;if(r.heredocQuoted===!0||r.body===void 0||_i(r.body))return(r.content??"").replace(/\n+$/u,"");return null}if(n.head==="printf"&&n.args.length===2){let[r,o]=n.args;if(r==="%s"||r===String.raw`%s\n`)return o??""}return null},JB=(e)=>["/tmp","/private/tmp","/var/tmp","/private/var/tmp","/var/folders","/private/var/folders"].some((t)=>e===t||e.startsWith(`${t}/`)),Cte=(e)=>{let t=!1,n=null,r=[];for(let o=0;o<e.length;o+=1){let s=e[o];if(s==="-t")t=!0,o+=1;else if(s==="-p"||s==="--tmpdir")n=e[o+1]??"",o+=1;else if(s?.startsWith("--tmpdir=")===!0)n=s.slice(9);else if(s!==void 0&&!s.startsWith("-"))r.push(s)}return{explicitDirectory:n,positionals:r,systemTempTemplate:t}},eH=(e,t)=>{let n=ZB(YB(e));if(n?.head!=="mktemp"||XB(n,t)||["TMPDIR","TMP","TEMP"].some((a)=>t.bindings.has(a)||t.temps.has(a))||!n.args.some((a)=>a==="-d"||a==="--directory"||/^-[^-]*d/u.test(a)))return!1;let{explicitDirectory:r,positionals:o,systemTempTemplate:s}=Cte(n.args);if(r!==null&&!JB(r))return!1;if(o.length===0||s||r!==null)return!0;let[i]=o;return o.length===1&&i!==void 0&&JB(i)},tH=(e)=>{if(e.type==="SimpleExpansion")return/^\$(?<name>[A-Za-z_][A-Za-z0-9_]*|[0-9]+|!)$/u.exec(e.text)?.groups?.name??null;if(e.type==="ParameterExpansion"&&e.indirect!==!0&&e.length!==!0&&e.operator===void 0&&e.index===void 0&&e.slice===void 0&&e.replace===void 0&&/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|!)$/u.test(e.parameter))return e.parameter;return null},nH=(e)=>{let t=[],n=(i,a)=>{for(let c of i)switch(c.type){case"Literal":case"SingleQuoted":case"AnsiCQuoted":{t.push({kind:"literal",value:c.value});break}case"DoubleQuoted":case"LocaleString":{if(!n(c.parts,!0))return!1;break}case"SimpleExpansion":case"ParameterExpansion":{let u=tH(c);if(u===null)return!1;t.push({kind:"variable",quoted:a,variable:u});break}case"ArithmeticExpansion":case"BraceExpansion":case"CommandExpansion":case"ExtendedGlob":case"ProcessSubstitution":return!1;default:return!1}return!0};if(!n(e.parts??[],!1))return null;let r=t.filter((i)=>i.kind==="variable");if(r.length!==1)return null;let[o]=r;if(o===void 0)return null;let s=t.indexOf(o);return{prefix:t.slice(0,s).map((i)=>i.kind==="literal"?i.value:"").join(""),quoted:o.quoted,suffix:t.slice(s+1).map((i)=>i.kind==="literal"?i.value:"").join(""),variable:o.variable}},vte=(e)=>{let t=e.parts??[];if(t.length!==1||t[0]?.type!=="DoubleQuoted")return null;let n=t[0].parts;if(n.length<1||n.length>2)return null;let[r]=n,o=r===void 0?null:tH(r);if(o===null)return null;let[,s]=n;if(s!==void 0&&s.type!=="Literal")return null;return{variable:o,suffix:s?.value??""}},rH=(e,t)=>{let n=vte(e);if(n===null||!t.temps.has(n.variable))return null;let{suffix:r,variable:o}=n;if(r!==""&&!r.startsWith("/")||r.split("/").includes("..")||r.includes("\x00"))return null;return{source:e.text,value:`/private/tmp/tripwire-provenance/${o}${r}`,kind:"trusted-temp-path",range:AI(e),quoted:!0,variable:o}},PI=(e,t)=>{let n=nH(e);if(n===null)return null;let{prefix:r,quoted:o,suffix:s,variable:i}=n,a=t.bindings.get(i);if(a===void 0||a.kind==="dynamic"||a.kind==="trusted-temp-path"||a.kind==="background-pid"&&(r!==""||s!=="")||s.split("/").includes("..")||r.split("/").includes(".."))return null;let c=`${r}${a.value}${s}`;if(!o&&(/\s/u.test(c)||c.includes("*")||c.includes("?")||c.includes("[")))return null;return{...a,source:e.text,value:c,range:AI(e),quoted:o,variable:i}},RI=(e,t)=>{let n=nH(e);if(!t.backgroundPidAvailable||n?.variable!=="!"||n.prefix!==""||n.suffix!=="")return null;return{source:e.text,value:"__tripwire_background_pid__",kind:"background-pid",range:AI(e),quoted:n.quoted,variable:"!"}};var tf=()=>{};function oH(e){return e>=48&&e<=55}function Ite(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Ate(e,t){try{return String.fromCodePoint(e)}catch{return t}}function FI(e,t,n){let r=t,o="";while(r<n&&e.charCodeAt(r)!==39){if(e.charCodeAt(r)!==92||r+1>=n){let c=r;while(r<n){let u=e.charCodeAt(r);if(u===39||u===92&&r+1<n)break;r++}o+=e.slice(c,r);continue}let i=r++,a=e[r++];switch(a){case"a":o+="\x07";break;case"b":o+="\b";break;case"e":case"E":o+="\x1B";break;case"f":o+="\f";break;case"n":o+=`
|
|
37
|
+
`;break;case"r":o+="\r";break;case"t":o+="\t";break;case"v":o+="\v";break;case"\\":o+="\\";break;case"'":o+="'";break;case'"':o+='"';break;case"?":o+="?";break;case`
|
|
38
|
+
`:break;case"c":{let c=r<n?e.charCodeAt(r):39;if(c===39){o+=e.slice(i,r);break}if(r++,c===92){let u=r<n&&e.charCodeAt(r)===92;if(u)r++;if(o+="\x1C",!u&&r<n)o+=e[r],r++;break}o+=String.fromCharCode(c===63?127:c&31);break}case"x":case"u":case"U":{let c=r,u=a==="x"?2:a==="u"?4:8;while(r<n&&r-c<u&&Ite(e.charCodeAt(r)))r++;if(r===c){o+=`\\${a}`;break}let l=e.slice(i,r);o+=Ate(Number.parseInt(e.slice(c,r),16),l);break}default:{let c=a.charCodeAt(0);if(!oH(c)){o+=`\\${a}`;break}while(r<n&&r-i-1<3&&oH(e.charCodeAt(r)))r++;o+=String.fromCharCode(Number.parseInt(e.slice(i+1,r),8)&255);break}}}let s=r<n;if(s)r++;return{value:o,end:r,closed:s}}var Yo=9,Ct=10,bo=32,Ar=33,tt=34,hn=35,$e=36,Yc=37,Tr=38,xt=39,be=40,Qt=41,Is=42,On=43,nf=44,gn=45,Xc=47,_r=48,Or=57,rf=58,of=59,dt=60,nt=61,$t=62,Xo=63,eu=64,Ra=65,Fa=90,Vn=91,ke=92,As=93,sf=94,Ma=95,qe=96,Oi=97,Pi=122,Ut=123,wo=124,lr=125,sH=126;function Tte(e){switch(e){case",":return 1;case"=":case"+=":case"-=":case"*=":case"/=":case"%=":case"<<=":case">>=":case"&=":case"|=":case"^=":return 2;case"||":return 4;case"&&":return 5;case"|":return 6;case"^":return 7;case"&":return 8;case"==":case"!=":return 9;case"<":case"<=":case">":case">=":return 10;case"<<":case">>":return 11;case"+":case"-":return 12;case"*":case"/":case"%":return 13;case"**":return 14;default:return-1}}function _te(e){switch(e){case"=":case"+=":case"-=":case"*=":case"/=":case"%=":case"<<=":case">>=":case"&=":case"|=":case"^=":case"**":return!0;default:return!1}}function af(e,t=0,n){let r=0,o=e.length,s=n?.commandExpansions.length??0,i=n?.embeddedWords.length??0;function a(w,k,g=!1){let x={type:"ArithmeticWord",pos:w+t,end:k+t,value:e.slice(w,k),parts:void 0};if(g)n?.embeddedWords.push(x);return x}function c(){while(r<o){let w=e.charCodeAt(r);if(w===bo||w===Yo||w===Ct)r++;else break}}function u(){if(r>=o)return null;let w=e.charCodeAt(r),k=r+1<o?e.charCodeAt(r+1):0,g=r+2<o?e.charCodeAt(r+2):0;switch(w){case nf:return r++,",";case nt:if(k===nt)return r+=2,"==";return r++,"=";case Ar:if(k===nt)return r+=2,"!=";return null;case dt:if(k===dt){if(g===nt)return r+=3,"<<=";return r+=2,"<<"}if(k===nt)return r+=2,"<=";return r++,"<";case $t:if(k===$t){if(g===nt)return r+=3,">>=";return r+=2,">>"}if(k===nt)return r+=2,">=";return r++,">";case On:if(k===nt)return r+=2,"+=";if(k===On)return null;return r++,"+";case gn:if(k===nt)return r+=2,"-=";if(k===gn)return null;return r++,"-";case Is:if(k===Is)return r+=2,"**";if(k===nt)return r+=2,"*=";return r++,"*";case Xc:if(k===nt)return r+=2,"/=";return r++,"/";case Yc:if(k===nt)return r+=2,"%=";return r++,"%";case wo:if(k===wo)return r+=2,"||";if(k===nt)return r+=2,"|=";return r++,"|";case Tr:if(k===Tr)return r+=2,"&&";if(k===nt)return r+=2,"&=";return r++,"&";case sf:if(k===nt)return r+=2,"^=";return r++,"^";case Xo:return r++,"?";default:return null}}function l(w){let k=f();while(!0){if(c(),r>=o)break;let g=r,x=u();if(!x)break;if(x==="?"){if(3<w){r=g;break}let _=l(1);if(c(),r<o&&e.charCodeAt(r)===rf)r++;let M=l(3);k={type:"ArithmeticTernary",pos:k.pos,end:M.end,test:k,consequent:_,alternate:M};continue}let S=Tte(x);if(S<w){r=g;break}let C=_te(x)?S:S+1,I=l(C);k={type:"ArithmeticBinary",pos:k.pos,end:I.end,operator:x,left:k,right:I}}return k}function f(){if(c(),r>=o)return a(r,r);let w=r,k=e.charCodeAt(r),g=r+1<o?e.charCodeAt(r+1):0;if(k===On&&g===On){r+=2;let x=f();return{type:"ArithmeticUnary",pos:w+t,end:x.end,operator:"++",operand:x,prefix:!0}}if(k===gn&&g===gn){r+=2;let x=f();return{type:"ArithmeticUnary",pos:w+t,end:x.end,operator:"--",operand:x,prefix:!0}}if(k===Ar){r++;let x=f();return{type:"ArithmeticUnary",pos:w+t,end:x.end,operator:"!",operand:x,prefix:!0}}if(k===sH){r++;let x=f();return{type:"ArithmeticUnary",pos:w+t,end:x.end,operator:"~",operand:x,prefix:!0}}if(k===On&&g!==On&&g!==nt){r++;let x=f();return{type:"ArithmeticUnary",pos:w+t,end:x.end,operator:"+",operand:x,prefix:!0}}if(k===gn&&g!==gn&&g!==nt){r++;let x=f();return{type:"ArithmeticUnary",pos:w+t,end:x.end,operator:"-",operand:x,prefix:!0}}return d()}function d(){let w=m();if(c(),r+1<o){let k=e.charCodeAt(r),g=e.charCodeAt(r+1);if(k===On&&g===On)return r+=2,{type:"ArithmeticUnary",pos:w.pos,end:r+t,operator:"++",operand:w,prefix:!1};if(k===gn&&g===gn)return r+=2,{type:"ArithmeticUnary",pos:w.pos,end:r+t,operator:"--",operand:w,prefix:!1}}return w}function m(){if(c(),r>=o)return a(r,r);let w=e.charCodeAt(r);if(w===be){let C=r;r++;let I=l(0);if(c(),r<o&&e.charCodeAt(r)===Qt)r++;return{type:"ArithmeticGroup",pos:C+t,end:r+t,expression:I}}if(w===$e){let C=r,I=n?.commandExpansions.length??0,_=n?.embeddedWords.length??0,M=y(),U=n?.findArithmeticWordEnd?.(C+t,t+o)??r+t;if(U>r+t){if(n)n.commandExpansions.length=I,n.embeddedWords.length=_;return r=U-t,a(C,r,!0)}return M}if(w===96||w===34||w===39){let C=r;return r=(n?.findArithmeticWordEnd?.(C+t,t+o)??C+t+1)-t,a(C,r,!0)}let k=r,g=n?.embeddedWords.length??0,x=b(),S=n?.findArithmeticWordEnd?.(k+t,t+o)??r+t;if(S>r+t){if(n)n.embeddedWords.length=g;return r=S-t,a(k,r,!0)}return x}function y(){let w=r;if(r++,r>=o)return a(w,r);let k=e.charCodeAt(r);if(k===be)if(r+1<o&&e.charCodeAt(r+1)===be){let g=n?.findArithmeticExpansionEnd(w+t,t+o)??-1;if(g!==-1)r=g-t;else{r+=2;let x=1;while(r<o&&x>0)if(e.charCodeAt(r)===be&&e.charCodeAt(r+1)===be)x++,r+=2;else if(e.charCodeAt(r)===Qt&&e.charCodeAt(r+1)===Qt)x--,r+=2;else r++}}else{r++;let g=n?.findClosingParenthesis(r+t,t+o)??-1;if(g!==-1)r=g-t+1;else{let I=1;while(r<o&&I>0){let _=e.charCodeAt(r++);if(_===be)I++;else if(_===Qt)I--}}let x=e.slice(w,r),S=x.slice(2,-1),C={type:"ArithmeticCommandExpansion",pos:w+t,end:r+t,text:x,inner:S,script:void 0};return n?.commandExpansions.push(C),C}else if(k===Ut){let g=n?.findClosingBrace(r+t+1,t+o)??-1;if(g!==-1)r=g-t+1;else{r++;let x=1;while(r<o&&x>0){let S=e.charCodeAt(r++);if(S===Ut)x++;else if(S===lr)x--}}}else while(r<o){let g=e.charCodeAt(r);if(g>=Oi&&g<=Pi||g>=Ra&&g<=Fa||g>=_r&&g<=Or||g===Ma)r++;else break}return a(w,r,k===be||k===Ut)}function b(){let w=r;while(r<o){let k=e.charCodeAt(r);if(k>=_r&&k<=Or||k>=Ra&&k<=Fa||k>=Oi&&k<=Pi||k===Ma||k===35)r++;else break}if(r>w&&r<o&&e.charCodeAt(r)===Vn){let k=n?.findClosingBracket?.(r+t+1,t+o)??-1;if(k!==-1)r=k-t+1;else{r++;let g=1;while(r<o&&g>0){let x=e.charCodeAt(r);if(x===Vn)g++;else if(x===As)g--;r++}}return a(w,r,!0)}if(r===w)return r++,a(w,r);return a(w,r)}if(c(),r>=o)return null;let E=l(0);if(c(),r<o&&n)return n.commandExpansions.length=s,n.embeddedWords.length=i,a(0,o,!0);return E}var MI=()=>{};function Ote(e){let t="";for(let n of e)t+=n.type==="Literal"?n.value:n.text;return t}function Pte(e){let t=e.indexOf("\\");if(t===-1)return e;let n="",r=0;for(let o=t;o<e.length;o++){if(e.charCodeAt(o)!==92)continue;if(n+=e.slice(r,o),o++,o>=e.length){n+="\\",r=o;break}if(e.charCodeAt(o)!==10)n+=e[o];r=o+1}return n+e.slice(r)}class tn{static _resolveWord;static _resolveHeredocBody;text;pos;end;#t;#e;#n;#o;#i=null;constructor(e,t,n,r,o,s=0){this.text=e,this.pos=t,this.end=n,this.#t=r,this.#e=o??tn._resolveWord,this.#n=s,this.#o=r!==void 0?null:void 0}get value(){if(this.#i===null){let e=this.parts;if(!e)this.#i=Pte(this.text);else{let t="";for(let n of e)switch(n.type){case"Literal":case"SingleQuoted":case"AnsiCQuoted":t+=n.value;break;case"DoubleQuoted":case"LocaleString":t+=Ote(n.parts);break;default:t+=n.text;break}this.#i=t}}return this.#i}get parts(){if(this.#o===null)this.#o=this.#e(this.#t??"",this,this.#n)??void 0;return this.#o}set parts(e){this.#o=e??void 0}sourceText(){return this.#t?.slice(this.pos,this.end)}toJSON(){return{text:this.text,pos:this.pos,end:this.end,parts:this.parts,value:this.value}}}class ky{token=h.EOF;_value="";_owner;pos=0;end=0;fileDescriptor=void 0;variableName=void 0;content=void 0;targetPos=0;targetEnd=0;assignmentOperatorPos=-1;raw=!1;keywordEligible=!1;constructor(e=null){this._owner=e}get value(){return this._value??(this._value=this._owner===null?"":this._owner._tokenValue(this.pos,this.end,this.raw))}set value(e){this._value=e}reset(){this.token=h.EOF,this._value="",this.pos=0,this.end=0,this.fileDescriptor=void 0,this.variableName=void 0,this.content=void 0,this.targetPos=0,this.targetEnd=0,this.assignmentOperatorPos=-1,this.raw=!1,this.keywordEligible=!1}copyFrom(e){this.token=e.token,this._value=e._value,this.pos=e.pos,this.end=e.end,this.fileDescriptor=e.fileDescriptor,this.variableName=e.variableName,this.content=e.content,this.targetPos=e.targetPos,this.targetEnd=e.targetEnd,this.assignmentOperatorPos=e.assignmentOperatorPos,this.raw=e.raw,this.keywordEligible=e.keywordEligible}}function iH(e,t,n){if(t===n)return!0;let r=e.charCodeAt(t-1);return r<128&&(Qe[r]&1)!==0}function Da(e,t,n){for(let r=t;r<n;r++){let o=e.charCodeAt(r);if(o===ke||o===xt||o===tt||o===$e||o===qe||(o===dt||o===$t)&&r+1<n&&e.charCodeAt(r+1)===be)return!0}return!1}function aH(e,t){let n=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o===ke){r++;continue}if(o===Ut){n++;continue}if(o===lr){if(n>0)n--;continue}if(o===xt){r++;while(r<e.length&&e.charCodeAt(r)!==xt)r++;continue}if(o===tt){r++;while(r<e.length&&e.charCodeAt(r)!==tt){if(e.charCodeAt(r)===ke)r++;r++}continue}if(o===t&&n===0)return r}return-1}function cH(e){let t=e.type;return t==="Literal"||t==="SimpleExpansion"||t==="ParameterExpansion"||t==="CommandExpansion"||t==="ArithmeticExpansion"}function Mte(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<_r||n>Or)return!1}return e.length>0}function Dte(e,t,n){for(let r=t;r<n;r++){let o=e.charCodeAt(r);if(o<_r||o>Or)return!1}return n>t}function dH(e){return e<Co}function pH(e){return-e-2}function pm(e,t,n,r){let o=r;for(let s=t;s<n&&o>=0;s++){let i=e.charCodeAt(s);if(o>=ko){if(i===Vn)o++;else if(i===As&&--o===ko)o=lH}else if(o===wy)o=i<128&&Na[i]&1?uH:Co;else if(o===uH){if(i<128&&Na[i]&2)continue;if(i===Vn)o=ko+1;else if(i===On)o=fH;else o=i===nt?-s-2:Co}else if(o===lH)if(i===On)o=fH;else o=i===nt?-s-2:Co;else o=i===nt?-s-2:Co}return o}function Tt(e,t,n,r=0,o=0){e.token=t,e._value=n,e.pos=r,e.end=o,e.fileDescriptor=void 0,e.variableName=void 0,e.content=void 0,e.assignmentOperatorPos=-1,e.raw=!1,e.keywordEligible=!1}function mm(e,t,n,r,o){e.token=t,e._value=null,e.pos=n,e.end=r,e.fileDescriptor=void 0,e.variableName=void 0,e.content=void 0,e.assignmentOperatorPos=-1,e.raw=o,e.keywordEligible=!1}function $te(e,t,n){switch(e.charCodeAt(t)){case Ar:return n===1?h.Bang:void 0;case Ut:return n===1?h.LBrace:void 0;case lr:return n===1?h.RBrace:void 0;case 105:{if(n!==2)return;let r=e.charCodeAt(t+1);return r===102?h.If:r===110?h.In:void 0}case 102:if(n===2)return e.charCodeAt(t+1)===105?h.Fi:void 0;if(n===3)return e.startsWith("for",t)?h.For:void 0;if(n===8)return e.startsWith("function",t)?h.Function:void 0;return;case 116:return n===4&&e.startsWith("then",t)?h.Then:void 0;case 101:if(n!==4)return;if(e.startsWith("else",t))return h.Else;if(e.startsWith("elif",t))return h.Elif;if(e.startsWith("esac",t))return h.Esac;return;case 100:if(n===2)return e.charCodeAt(t+1)===111?h.Do:void 0;if(n===4)return e.startsWith("done",t)?h.Done:void 0;return;case 99:if(n===4)return e.startsWith("case",t)?h.Case:void 0;if(n===6)return e.startsWith("coproc",t)?h.Coproc:void 0;return;case 119:return n===5&&e.startsWith("while",t)?h.While:void 0;case 117:return n===5&&e.startsWith("until",t)?h.Until:void 0;case 115:return n===6&&e.startsWith("select",t)?h.Select:void 0;default:return}}function Ute(e,t,n){let r=t+1<n?e.charCodeAt(t+1):0;if(r<=bo||r===lr)return-1;let o=1,s=!1,i=t+1;while(i<n&&o>0){let a=e.charCodeAt(i);if(a===Ut)o++;else if(a===lr){if(--o===0)break}else if(a<=bo||a===of||a===wo||a===Tr)return-1;else if(o===1&&(a===44||a===46&&i+1<n&&e.charCodeAt(i+1)===46))s=!0;if(a===ke)i++;i++}if(o===0&&s)return i+1;return-1}class es{src;srcEnd;pos;current;nextState;hasPeek;pendingHereDocs;collectedExpansions;_errors=null;_buildParts=!1;_buildValue=!1;_nestingDepth=0;constructor(e,t=0,n=e.length){if(this.src=e,this.srcEnd=n,this.pos=t,this.current=new ky(this),this.nextState=new ky(this),this.hasPeek=!1,this.pendingHereDocs=null,this.collectedExpansions=null,t===0&&e.charCodeAt(0)===hn&&e.charCodeAt(1)===Ar){let r=e.indexOf(`
|
|
39
|
+
`);this.pos=r===-1?this.srcEnd:r+1}}getSource(){return this.src}get errors(){return this._errors??(this._errors=[])}getCollectedExpansions(){return this.collectedExpansions??Nte}collect(e){(this.collectedExpansions??=[]).push([e,this._nestingDepth])}getPos(){return this.pos}_tokenValue(e,t,n){return n?this.src.slice(e,t):this.wordValueOf(e,t)}wordValueOf(e,t){let n=this.pos,r=this.srcEnd,o=this._buildValue,s=this._unbalanced,i=this._errors===null?0:this._errors.length;this.pos=e,this.srcEnd=t,this._buildValue=!0,this.readWordText();let a=this._wordText;if(this.pos=n,this.srcEnd=r,this._buildValue=o,this._unbalanced=s,this._errors!==null)this._errors.length=i;return a}findClosingBracket(e,t=this.srcEnd){return this.findClosingShellDelimiter(e,t,As)}findClosingArithmeticBracket(e,t=this.srcEnd){return this.findClosingShellDelimiter(e,t,As,!1,!1)}findClosingBrace(e,t=this.srcEnd){return this.findClosingShellDelimiter(e,t,lr)}findClosingParenthesis(e,t=this.srcEnd){let n=this.pos,r=this.srcEnd,o=this._unbalanced;this.pos=e,this.srcEnd=Math.min(t,this.srcEnd),this.extractBalanced();let s=this._unbalanced?-1:this.pos-1;return this.pos=n,this.srcEnd=r,this._unbalanced=o,s}findArithmeticExpansionEnd(e,t=this.srcEnd){let n=new es(this.src,e,t);return n.pos=e+1,n.scanArithmeticBody(),n.pos}findArithmeticWordEnd(e,t=this.srcEnd){let n=new es(this.src,e,t);return n.pos=e,n.scanArithmeticWordEnd()}scanArithmeticWordEnd(){while(this.pos<this.srcEnd){let e=this.src.charCodeAt(this.pos);if(e===$e){this.readDollar();continue}if(e===qe){this.readBacktickExpansion();continue}if(e===xt){this.pos++,this.skipSQ();continue}if(e===tt){this.pos++,this.skipDQ();continue}if(e===ke){this.pos+=2;continue}if(e===Vn){let t=this.findClosingBracket(this.pos+1);if(t!==-1){this.pos=t+1;continue}}if((e===dt||e===$t)&&this.src.charCodeAt(this.pos+1)===be){this.pos+=2,this.extractBalanced();continue}if(e<128&&mH[e])break;this.pos++}return this.pos}findClosingShellDelimiter(e,t,n,r=!1,o=!0){let s=this.pos,i=this.srcEnd,a=this._unbalanced;this.srcEnd=Math.min(t,this.srcEnd);let c=[n],u=e;while(u<this.srcEnd){let l=this.src.charCodeAt(u);if(l===ke){u+=2;continue}if(l===hn&&r&&iH(this.src,u,e)){while(u<this.srcEnd&&this.src.charCodeAt(u)!==Ct)u++;continue}if(l===xt){this.pos=u+1,this.skipSQ(),u=this.pos;continue}if(l===tt){this.pos=u+1,this.skipDQ(),u=this.pos;continue}if(l===qe){u++;while(u<this.srcEnd&&this.src.charCodeAt(u)!==qe){if(this.src.charCodeAt(u)===ke)u++;u++}if(u<this.srcEnd)u++;continue}if(l===$e&&u+1<this.srcEnd&&this.src.charCodeAt(u+1)===be||(l===dt||l===$t)&&u+1<this.srcEnd&&this.src.charCodeAt(u+1)===be){this.pos=u+2,this.extractBalanced(),u=this.pos;continue}let f=c[c.length-1];if(l===$e&&u+1<this.srcEnd){let d=this.src.charCodeAt(u+1);if(d===$e){u+=2;continue}if(d===Ut&&o){c.push(lr),u+=2;continue}}if(f===As&&l===Vn)c.push(As);else if(f===Qt&&l===be)c.push(Qt);else if(l===f){if(c.pop(),c.length===0)return this.pos=s,this.srcEnd=i,this._unbalanced=a,u}u++}return this.pos=s,this.srcEnd=i,this._unbalanced=a,-1}skipSubshellBody(){return this.extractBalanced(),this._unbalanced?-1:this.pos}skipCompoundBody(e){let t=[{close:e,phase:e===h.Esac?"case-pattern":"commands"}],n=!0;for(;;){let r=this.next(n?T.CommandStart:T.Normal),o=r.token;if(o===h.EOF)return-1;let s=t.length-1,i=t[s];if(i.phase==="function-name"){if(o===h.Newline)continue;i.phase="function-body",n=!0;continue}else if(i.phase==="function-body"){if(o===h.Newline)continue;if(i.phase="commands",n=!0,o===h.LParen&&this.peek(T.Normal).token===h.RParen){this.next(T.Normal),i.phase="function-body";continue}}else if(i.phase==="coproc-command"){if(o===h.Newline)continue;if(o===h.Word){i.phase="coproc-body",n=!0;continue}i.phase="commands",n=!0}else if(i.phase==="coproc-body"){if(o===h.Newline)continue;if(i.phase=o===h.Word&&r.keywordEligible&&r.value==="time"?"time-command":"commands",n=!0,i.phase==="time-command")continue}else if(i.phase==="time-command"){if(o===h.Word&&r.keywordEligible&&r.value==="-p"){i.phase="time-command-after-p";continue}if(o===h.Word&&r.keywordEligible&&r.value==="--"){i.phase="commands";continue}i.phase="commands",n=!0}else if(i.phase==="time-command-after-p"){if(o===h.Word&&r.keywordEligible&&r.value==="--"){i.phase="commands";continue}i.phase="commands",n=!0}else if(i.phase==="for-header"){if(o===h.ArithCmd||o===h.Semi||o===h.Newline){n=!0;continue}if(o===h.Do||o===h.LBrace){i.close=o===h.Do?h.Done:h.RBrace,i.phase="commands",n=!0;continue}}else if(i.phase==="case-word"){if(o===h.Newline)continue;i.phase="case-in",n=!1;continue}else if(i.phase==="case-in"){if(o===h.Newline){n=!0;continue}i.phase="case-pattern",n=!0;continue}else if(i.phase==="case-pattern"){if(o===h.Esac&&n){if(t.pop(),t.length===0)return r.end;n=!1;continue}if(o===h.RParen)i.phase="commands",n=!0;else n=o===h.Newline;continue}if(o===i.close){if(t.pop(),t.length===0)return r.end;n=!1;continue}if(n)switch(o){case h.LParen:t.push({close:h.RParen,phase:"commands"});break;case h.LBrace:t.push({close:h.RBrace,phase:"commands"});break;case h.If:t.push({close:h.Fi,phase:"commands"});break;case h.For:t.push({close:h.Done,phase:"for-header"});break;case h.While:case h.Until:case h.Select:t.push({close:h.Done,phase:"commands"});break;case h.Case:t.push({close:h.Esac,phase:"case-word"});break;case h.DblLBracket:if(!this.skipTestCommandBody())return-1;n=!1;continue;case h.Assignment:case h.Redirect:case h.Bang:case h.Then:case h.Else:case h.Elif:case h.Do:case h.In:break;case h.Semi:case h.Newline:case h.Pipe:case h.And:case h.Or:case h.Amp:case h.DoubleSemi:case h.SemiAmp:case h.DoubleSemiAmp:break;case h.Function:i.phase="function-name";break;case h.Coproc:i.phase="coproc-command";break;default:if(o===h.Word&&r.keywordEligible&&r.value==="time")i.phase="time-command",n=!0;else n=!1;continue}switch(o){case h.Semi:case h.Newline:case h.Pipe:case h.And:case h.Or:case h.Amp:n=!0;break;case h.DoubleSemi:case h.SemiAmp:case h.DoubleSemiAmp:if(i.close===h.Esac)i.phase="case-pattern";n=!0;break;case h.RParen:n=!0;break}}}skipTestGroup(){let e=1;for(;;){let t=this.next(T.TestMode);if(t.token===h.EOF)return-1;if(t.token===h.DblRBracket)return this.unshift(t),-1;if(t.token===h.LParen)e++;else if(t.token===h.RParen&&--e===0)return t.end}}skipTestCommandBody(){for(;;){let e=this.next(T.TestMode).token;if(e===h.DblRBracket)return!0;if(e===h.EOF)return!1}}buildWordParts(e){this._buildParts=!0,this.pos=e;let t=this.src.charCodeAt(e);if((t===60||t===62)&&e+1<this.srcEnd&&this.src.charCodeAt(e+1)===40){this.pos=e+2;let n=this.extractBalanced();if(this._unbalanced)this.errors.push({message:"unterminated process substitution",pos:e});let o={type:"ProcessSubstitution",text:this.src.slice(e,this.pos),operator:t===60?"<":">",script:void 0,inner:n??void 0,innerStart:e+2};if(this.collect(o),this.pos<this.srcEnd)if(this.readWordText(),this._wordParts)this._wordParts.unshift(o);else this._wordParts=[o];else this._wordParts=[o]}else this.readWordText();return this._wordParts}buildEmbeddedWordParts(e){return this._buildParts=!0,this.pos=e,this.readInnerWordText(),this._wordParts}buildHereDocParts(e,t){this._buildParts=!0;let n=this.src,r=[],o="",s=e,i=e,a=()=>{if(o)r.push({type:"Literal",value:o,text:n.slice(s,i)}),o=""};while(i<t){let c=n.charCodeAt(i);if(c===92){if(i+1<t){let u=n.charCodeAt(i+1);if(u===36||u===96||u===92){o+=String.fromCharCode(u),i+=2;continue}}o+="\\",i++;continue}if(c===36){if(a(),s=i,this.pos=i,this.readDollar(),this._resultPart)r.push(this._resultPart),s=this.pos;else o+=n.slice(i,this.pos);i=this.pos;continue}if(c===96){if(a(),s=i,this.pos=i,this.readBacktickExpansion(),this._resultPart)r.push(this._resultPart),s=this.pos;else o+=n.slice(i,this.pos);i=this.pos;continue}o+=n[i],i++}return a(),r.length>1||r.length===1&&r[0].type!=="Literal"?r:null}registerHereDocTarget(e){if(this.pendingHereDocs===null)return;for(let t of this.pendingHereDocs)if(!t.target){t.target=e;return}}readTestRegexWord(){this.hasPeek=!1,this.skipSpacesAndTabs();let e=this.src,t=this.srcEnd,n=this.pos,r=0;while(this.pos<t){let o=e.charCodeAt(this.pos);if(o===be){r++,this.pos++;continue}if(o===ke){this.pos+=this.pos+1<t?2:1;continue}if(o===xt){let s=this.pos++,i=s>n&&e.charCodeAt(s-1)===$e;while(this.pos<t&&e.charCodeAt(this.pos)!==xt){if(i&&e.charCodeAt(this.pos)===ke&&this.pos+1<t)this.pos++;this.pos++}if(this.pos<t)this.pos++;else this.errors.push({message:i?"unterminated ANSI-C quote":"unterminated single quote",pos:s});continue}if(o===tt){this.pos++,this.readDoubleQuoted();continue}if(o===qe){this.readBacktickExpansion();continue}if(r>0){if(o===Qt)r--;this.pos++;continue}if(o===$e){this.readDollar();continue}if((o===dt||o===$t)&&this.pos+1<t&&e.charCodeAt(this.pos+1)===be){let s=this.pos;if(this.pos+=2,this.extractBalanced(),this._unbalanced)this.errors.push({message:"unterminated process substitution",pos:s});continue}if(o<128&&Qe[o]&1&&o!==wo)break;this.pos++}return Tt(this.current,h.Word,e.slice(n,this.pos),n,this.pos),this.current}readCStyleForExprs(){this.hasPeek=!1;let e=this.src,t=this.srcEnd;while(this.pos<t&&(e.charCodeAt(this.pos)===bo||e.charCodeAt(this.pos)===Yo))this.pos++;if(this.pos<t&&e.charCodeAt(this.pos)===be)this.pos++;let n=[this.pos,0,0],r=["","","",0,0,0],o=0,s=1,i=this.pos;while(this.pos<t&&s>0){let a=e.charCodeAt(this.pos);if(a===be)s++,this.pos++;else if(a===Qt){if(s--,s===0){let c=e.slice(i,this.pos);r[o]=c.trim(),r[3+o]=n[o]+c.length-c.trimStart().length,this.pos++;while(this.pos<t&&(e.charCodeAt(this.pos)===bo||e.charCodeAt(this.pos)===Yo))this.pos++;if(this.pos<t&&e.charCodeAt(this.pos)===Qt)this.pos++;break}this.pos++}else if(a===of&&s===1){let c=e.slice(i,this.pos);if(r[o]=c.trim(),r[3+o]=n[o]+c.length-c.trimStart().length,o<2)o++;this.pos++,i=this.pos,n[o]=i}else if(a===xt)this.pos++,this.skipSQ();else if(a===tt)this.pos++,this.skipDQ();else this.pos++}return r}peek(e=T.Normal){if(!this.hasPeek)this.readNext(this.nextState,e),this.hasPeek=!0;return this.nextState}peekFollow(e){if(!this.hasPeek){let t=e[this.current.token]?T.CommandStart:T.Normal;this.readNext(this.nextState,t),this.hasPeek=!0}return this.nextState}next(e=T.Normal){if(this.hasPeek){this.hasPeek=!1;let t=this.current;return this.current=this.nextState,this.nextState=t,this.current}return this.readNext(this.current,e),this.current}unshift(e){this.nextState.copyFrom(e),this.hasPeek=!0}readNext(e,t){let n=this.src,r=this.srcEnd,o=this.pos;while(o<r){let a=n.charCodeAt(o);if(a===bo||a===Yo){o++;continue}if(a===ke&&o+1<r&&n.charCodeAt(o+1)===Ct){o+=2;continue}if(a===Ct&&t===T.TestMode){o++;continue}break}if(this.pos=o,o>=r){this.consumePendingHereDocs(),Tt(e,h.EOF,"",o,o);return}let s=o,i=n.charCodeAt(o);if(i===hn){while(this.pos<r&&n.charCodeAt(this.pos)!==Ct)this.pos++;this.readNext(e,t);return}if(i===Ct){this.pos++,this.consumePendingHereDocs(),Tt(e,h.Newline,`
|
|
40
|
+
`,s,this.pos);return}if(t===T.TestMode&&(i===dt||i===$t)&&!(this.pos+1<this.srcEnd&&n.charCodeAt(this.pos+1)===be)){this.pos++,Tt(e,h.Word,i===dt?"<":">",s,this.pos),e.keywordEligible=!0;return}if(i<128&&Qe[i]&1&&this.tryReadOperator(e,i,t,s))return;this.readWord(e,t,s)}tryReadOperator(e,t,n,r){let o=this.src,s=this.pos,i=s+1<this.srcEnd?o.charCodeAt(s+1):0;switch(t){case of:if(i===of){if(s+2<this.srcEnd&&o.charCodeAt(s+2)===Tr)return this.pos+=3,Tt(e,h.DoubleSemiAmp,";;&",r,this.pos),!0;return this.pos+=2,Tt(e,h.DoubleSemi,";;",r,this.pos),!0}if(i===Tr)return this.pos+=2,Tt(e,h.SemiAmp,";&",r,this.pos),!0;return this.pos++,Tt(e,h.Semi,";",r,this.pos),!0;case wo:if(i===wo)return this.pos+=2,Tt(e,h.Or,"||",r,this.pos),!0;if(i===Tr)return this.pos+=2,Tt(e,h.Pipe,"|&",r,this.pos),!0;return this.pos++,Tt(e,h.Pipe,"|",r,this.pos),!0;case Tr:if(i===Tr)return this.pos+=2,Tt(e,h.And,"&&",r,this.pos),!0;if(i===$t){this.pos+=2;let a=this.pos<this.srcEnd&&o.charCodeAt(this.pos)===$t;if(a)this.pos++;this.skipSpacesAndTabs();let c=this.pos;if(this.pos<this.srcEnd&&o.charCodeAt(this.pos)!==Ct&&o.charCodeAt(this.pos)!==hn)this.readRedirectTargetText();return this.redirectToken(e,a?"&>>":"&>",r,c),!0}return this.pos++,Tt(e,h.Amp,"&",r,this.pos),!0;case be:if(n===T.CommandStart&&i===be){let a=this.errors.length;if(this.readArithmeticCommand(e,r),!this._notArithmetic)return!0;this.errors.length=a,this.pos=r}return this.pos++,Tt(e,h.LParen,"(",r,this.pos),!0;case Qt:return this.pos++,Tt(e,h.RParen,")",r,this.pos),!0;case dt:case $t:return this.readRedirection(e,r);default:return!1}}readRedirection(e,t){let n=this.src,r=n.charCodeAt(this.pos),o="";if(r===dt){this.pos++;let s=this.pos<this.srcEnd?n.charCodeAt(this.pos):0;if(s===dt){this.pos++;let i=this.pos<this.srcEnd?n.charCodeAt(this.pos):0;if(i===dt){this.pos++,this.skipSpacesAndTabs();let l=this.pos;if(this.pos<this.srcEnd&&n.charCodeAt(this.pos)!==Ct&&n.charCodeAt(this.pos)!==hn)this.readRedirectTargetText();return this.redirectToken(e,"<<<",t,l),!0}let a=i===gn;if(a)this.pos++;this.skipSpacesAndTabs();let c=this.pos;if(this.pos>=this.srcEnd||n.charCodeAt(this.pos)!==hn)this.readHereDocDelimiter();let u=this.pos>c;if(u)(this.pendingHereDocs??=[]).push({delimiter:this._hereDelim,strip:a,quoted:this._hereQuoted});return Tt(e,h.Redirect,a?"<<-":"<<",t,this.pos),e.content=u?this._hereDelim:void 0,e.targetPos=c,e.targetEnd=u?this.pos:c,!0}if(s===be)return this.readProcessSubstitution(e,"<",t),!0;if(s===$t)o="<>",this.pos++;else if(s===Tr)o="<&",this.pos++;else o="<"}else if(r===$t){this.pos++;let s=this.pos<this.srcEnd?n.charCodeAt(this.pos):0;if(s===be)return this.readProcessSubstitution(e,">",t),!0;if(s===$t)o=">>",this.pos++;else if(s===Tr)o=">&",this.pos++;else if(s===wo)o=">|",this.pos++;else o=">"}if(this.skipSpacesAndTabs(),this.pos<this.srcEnd){let s=n.charCodeAt(this.pos);if((s===dt||s===$t)&&this.pos+1<this.srcEnd&&n.charCodeAt(this.pos+1)===be){let a=this.pos;if(this.pos+=2,this.extractBalanced(),this._unbalanced)this.errors.push({message:"unterminated process substitution",pos:a});let c=n.slice(a,this.pos);return Tt(e,h.Redirect,o,t,this.pos),e.content=c,e.targetPos=a,e.targetEnd=this.pos,!0}let i=this.pos;if(s!==Ct&&s!==hn)this.readRedirectTargetText();return this.redirectToken(e,o,t,i),!0}return this.redirectToken(e,o,t,this.pos),!0}readRedirectTargetText(){let e=this._buildValue;this._buildValue=!0,this.readWordText(),this._buildValue=e}redirectToken(e,t,n,r){let o=this.pos>r&&(this._wordText.length>0||this._wordQuoted);Tt(e,h.Redirect,t,n,this.pos),e.content=o?this._wordText:void 0,e.targetPos=r,e.targetEnd=o?this.pos:r}readProcessSubstitution(e,t,n){if(this.pos++,this.extractBalanced(),this._unbalanced)this.errors.push({message:"unterminated process substitution",pos:n});let r=this.src.slice(n,this.pos);Tt(e,h.Word,r,n,this.pos)}readHereDocDelimiter(){let e=this.src,t=this.srcEnd,n=this._buildValue;this._buildValue=!0;let r="",o=!1;while(this.pos<t){let s=e.charCodeAt(this.pos);if(s===xt){o=!0,this.pos++;while(this.pos<t&&e.charCodeAt(this.pos)!==xt)r+=e[this.pos],this.pos++;if(this.pos<t)this.pos++}else if(s===tt){o=!0,this.pos++;while(this.pos<t&&e.charCodeAt(this.pos)!==tt){if(e.charCodeAt(this.pos)===ke&&this.pos+1<t){let i=e.charCodeAt(this.pos+1);if(i===Ct){this.pos+=2;continue}if(i===$e||i===qe||i===tt||i===ke)this.pos++}r+=e[this.pos],this.pos++}if(this.pos<t)this.pos++}else if(s===ke){if(this.pos+1<t&&e.charCodeAt(this.pos+1)===Ct){this.pos+=2;continue}if(o=!0,this.pos++,this.pos<t)r+=e[this.pos],this.pos++;else r+="\\"}else if(s===qe){let i=this.pos;this.pos++;while(this.pos<t&&e.charCodeAt(this.pos)!==qe){if(e.charCodeAt(this.pos)===ke)this.pos++;this.pos++}if(this.pos<t)this.pos++;r+=e.slice(i,this.pos)}else if(s===$e){let i=this.pos+1<t?e.charCodeAt(this.pos+1):0;if(i===xt||i===tt)o=!0;this.readDollar(),r+=this._resultText}else if(s<128&&Qe[s]&1)break;else r+=e[this.pos],this.pos++}this._buildValue=n,this._hereDelim=r,this._hereQuoted=o}consumePendingHereDocs(){let e=this.pendingHereDocs;if(e===null||e.length===0)return;for(let t of e){let n=this.pos,r=this.readHereDocBody(t.delimiter,t.strip);if(t.target){if(t.target.content=r,t.quoted)t.target.heredocQuoted=!0;else if(r){let o=this.parseHereDocBody(r,n);if(o)t.target.body=o}}}e.length=0}readHereDocBody(e,t){let n=this.pos,r=this.skipHereDocBody(e,t);return this.src.slice(n,r)}matchHereDocDelimiter(e,t,n,r){let o=this.src,s=t;for(let i=0;i<e.length;){if(r&&o.charCodeAt(s)===ke&&s+1<n&&o.charCodeAt(s+1)===Ct){s+=2;continue}if(s>=n||o.charCodeAt(s)!==e.charCodeAt(i))return-1;s++,i++}return s}logicalLineEnd(e,t,n){let r=this.src,o=e;while(o<t){let s=r.charCodeAt(o);if(s===Ct)return o;o+=n&&s===ke?2:1}return t}skipHereDocBody(e,t,n=!1,r=!1){let o=this.src,s=this.srcEnd,i=e.length;while(this.pos<s){let a=this.pos,c=o.indexOf(`
|
|
41
|
+
`,this.pos);if(c===-1||c>s)c=s;if(t)while(a<c&&o.charCodeAt(a)===Yo)a++;if(c-a===i&&o.startsWith(e,a)){let u=this.pos;return this.pos=c<s?c+1:c,u}if(n){let u=this.matchHereDocDelimiter(e,a,s,!r);if(u!==-1){let l=o.indexOf(")",u);if(l!==-1&&l<this.logicalLineEnd(a,s,!r)){let f=this.pos;return this.pos=u,f}}}this.pos=c<s?c+1:c}return this.pos}parseHereDocBody(e,t){let n=!1;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o===qe){n=!0;break}if(o===$e){let s=r+1<e.length?e.charCodeAt(r+1):0;if(s===Ut||s===be||s===$e||s>=Oi&&s<=Pi||s>=Ra&&s<=Fa||s===Ma||s===Ar||s===hn||s===eu||s===Is||s===Xo||s===gn||s>=_r&&s<=Or){n=!0;break}}if(o===ke)r++}if(!n)return null;return new tn(e,t,t+e.length,this.src,tn._resolveHeredocBody,this._nestingDepth)}_wordText="";_wordRaw=!1;_wordQuoted=!1;_wordHasExpansions=!1;_wordKeywordEligible=!1;_wordIsAssignment;_wordAssignmentOperatorPos;_wordParts=null;_resultText="";_resultIsRaw=!0;_resultHasExpansion=!1;_resultPart;_unbalanced=!1;_notArithmetic=!1;_dqText="";_dqHasExpansions=!1;_dqParts=null;_dqEnd=0;_hereDelim="";_hereQuoted=!1;readWord(e,t,n=0){this.readWordText(),this.classifyWord(e,t,n)}classifyWord(e,t,n){let r=this.src,o=this._wordRaw,s=this._wordHasExpansions,i=this._wordQuoted,a=this._wordKeywordEligible,c=this._wordIsAssignment,u=this._wordAssignmentOperatorPos,l=this.pos,f=l-n,d=null;if(!o&&!s){let m=l<this.srcEnd?r.charCodeAt(l):0;if(!i&&f<=16||m===dt||m===$t)d=this.wordValueOf(n,l)}if(t===T.CommandStart&&a){if(o){if(f<=8){let m=$te(r,n,f);if(m!==void 0){mm(e,m,n,l,!0);return}}if(f===2&&r.charCodeAt(n)===Vn&&r.charCodeAt(n+1)===Vn){mm(e,h.DblLBracket,n,l,!0);return}}else if(d!==null&&d.length>0){let m=d.charCodeAt(0);if(m>=Oi&&m<=Pi&&d.length<=8||m===Ar||m===Ut||m===lr){let y=Rte.get(d);if(y!==void 0){Tt(e,y,d,n,l);return}}if(m===Vn&&d==="[["){Tt(e,h.DblLBracket,d,n,l);return}}}if(t===T.CommandStart||t===T.CommandPrefix){if(c===void 0){let m=-1,y=!1;for(let b=n+1;b<l;b++){let E=r.charCodeAt(b);if(E===nt){m=b;break}if(E===Vn)y=!0}if(m!==-1){let b=pm(r,n,l,wy);if(dH(b))u=pH(b)}else if(y&&l<this.srcEnd&&pm(r,n,l,wy)>=ko){this.pos=n,this.readWordText(!0),this.classifyWord(e,t,n);return}}if(u!==void 0){if(mm(e,h.Assignment,n,l,o),d!==null)e._value=d;e.assignmentOperatorPos=u;return}}if((t===T.CommandStart||t===T.TestMode)&&a){if(o){if(f===2&&r.charCodeAt(n)===As&&r.charCodeAt(n+1)===As){mm(e,h.DblRBracket,n,l,!0);return}}else if(d==="]]"){Tt(e,h.DblRBracket,d,n,l);return}}if(!s&&this.pos<this.srcEnd){let m=r.charCodeAt(this.pos);if(m===dt||m===$t){if(o){let y=r.charCodeAt(n);if(y>=_r&&y<=Or&&Dte(r,n,l)){let b=Number.parseInt(r.slice(n,l),10);if(this.readRedirection(e,n)){e.fileDescriptor=b;return}}if(y===Ut&&f>2&&r.charCodeAt(l-1)===lr){let b=r.slice(n+1,l-1);if(this.readRedirection(e,n)){e.variableName=b;return}}}else if(d!==null&&d.length>0){if(d.charCodeAt(0)>=_r&&d.charCodeAt(0)<=Or&&Mte(d)){let y=Number.parseInt(d,10);if(this.readRedirection(e,n)){e.fileDescriptor=y;return}}if(d.charCodeAt(0)===Ut&&d.charCodeAt(d.length-1)===lr&&d.length>2){let y=d.slice(1,-1);if(this.readRedirection(e,n)){e.variableName=y;return}}}}}if(mm(e,h.Word,n,l,o),d!==null)e._value=d;e.keywordEligible=a}readWordText(e=!1){let t=this.src,n=this.srcEnd,r=this.pos,o=r,s=0;while(r<n){let k=t.charCodeAt(r);if(k<128&&Qe[k]){s=k;break}r++}if(r>=n||Qe[s]&1&&!(s===be&&r>o&&$a[t.charCodeAt(r-1)])&&!e){if(this.pos=r,this._wordText=(this._buildParts||this._buildValue)&&r>o?t.slice(o,r):"",this._wordRaw=!0,this._wordQuoted=!1,this._wordHasExpansions=!1,this._wordKeywordEligible=!0,this._wordIsAssignment=void 0,this._wordAssignmentOperatorPos=void 0,this._buildParts)this._wordParts=null;return}let i=this._buildParts,a=i||this._buildValue,c=a&&r>o?t.slice(o,r):"",u=!1,l=!1,f=!0,d=!0,m=r>o?t.charCodeAt(r-1):0,y=pm(t,o,r,wy),b,E="",w=0;if(i)b=[],E=c,w=o;while(r<n){let k=t.charCodeAt(r);if(k>=128||!Qe[k]){let g=r;r++;while(r<n){let x=t.charCodeAt(r);if(x<128&&Qe[x])break;r++}if(m=t.charCodeAt(r-1),y=pm(t,g,r,y),a){let x=t.slice(g,r);if(c+=x,i)E+=x}continue}if(Qe[k]&1){if(k===be&&m<128&&$a[m]){f=!1;let g=m;r++;let x=r,S=this.findClosingShellDelimiter(x,n,Qt,g===nt),C=S===-1?n:S;if(r=S===-1?n:S+1,S===-1)this.errors.push({message:"unterminated extended glob",pos:x-2});if(m=t.charCodeAt(r-1),a){let I="("+t.slice(x,r);if(c+=I,i&&g!==nt){if(E.length>0){let M=E.slice(0,-1);if(M)b.push({type:"Literal",value:M,text:t.slice(w,x-2)});E=""}let _=Fte[g];b.push({type:"ExtendedGlob",text:_+I,operator:_,pattern:t.slice(x,C),parts:Da(t,x,C)?this.parseSubFieldWord(x,C).parts:void 0}),w=r}else if(i)E+=I}continue}if(e&&y>=ko){let g=this.findClosingBracket(r);if(g!==-1){let x=g+1;if(y=pm(t,r,x,y),m=t.charCodeAt(g),a){let S=t.slice(r,x);if(c+=S,i)E+=S}r=x;continue}}break}if(k===ke){if(r++,r<n)if(t.charCodeAt(r)===Ct)r++,d=!1;else{if(y>=0&&y<ko)y=Co;if(u=!0,f=!1,d=!1,m=t.charCodeAt(r),a){if(c+=t[r],i)E+=t[r]}r++}else{if(y>=0&&y<ko)y=Co;if(u=!0,f=!1,m=ke,a){if(c+="\\",i)E+="\\"}}continue}if(k===xt){let g=r;if(y>=0&&y<ko)y=Co;u=!0,f=!1,d=!1,r++;let x=r;while(r<n&&t.charCodeAt(r)!==xt)r++;if(r>x)m=t.charCodeAt(r-1);let S=a?t.slice(x,r):"";if(a)c+=S;if(r<n)r++;else this.errors.push({message:"unterminated single quote",pos:x-1});if(i){if(E)b.push({type:"Literal",value:E,text:t.slice(w,g)}),E="";b.push({type:"SingleQuoted",value:S,text:t.slice(g,r)}),w=r}continue}if(k===tt){let g=r;if(y>=0&&y<ko)y=Co;if(u=!0,f=!1,d=!1,r++,this.pos=r,this.readDoubleQuoted(),r=this.pos,this._dqEnd>g+1)m=t.charCodeAt(this._dqEnd-1);if(this._dqHasExpansions)l=!0;if(a)c+=this._dqText;if(i){if(E)b.push({type:"Literal",value:E,text:t.slice(w,g)}),E="";let x=t.slice(g,r);b.push({type:"DoubleQuoted",text:x,parts:this._dqParts??[{type:"Literal",value:this._dqText,text:t.slice(g+1,this._dqEnd)}]}),w=r}continue}if(k===$e){f=!1;let g=r;if(y>=0&&y<ko)y=Co;if(this.pos=r,this.readDollar(),r=this.pos,!this._resultIsRaw)d=!1;if(r>g)m=t.charCodeAt(r-1);if(this._resultHasExpansion)l=!0;if(a)c+=this._resultText;if(i)if(this._resultPart){if(E)b.push({type:"Literal",value:E,text:t.slice(w,g)}),E="";b.push(this._resultPart),w=r}else E+=this._resultText;continue}if(k===qe){f=!1;let g=r;if(y>=0&&y<ko)y=Co;if(this.pos=r,this.readBacktickExpansion(),r=this.pos,d=!1,m=t.charCodeAt(r-1),l=!0,a)c+=this._resultText;if(i){if(E)b.push({type:"Literal",value:E,text:t.slice(w,g)}),E="";b.push(this._resultPart),w=r}continue}if(k===Ut){if(y>=0&&y<ko)y=Co;let g=Ute(t,r,n);if(g>0){if(f=!1,m=t.charCodeAt(g-1),a){let x=t.slice(r,g);if(c+=x,i){if(E)b.push({type:"Literal",value:E,text:t.slice(w,r)}),E="";b.push({type:"BraceExpansion",text:x,parts:Da(t,r+1,g-1)?this.parseSubFieldWord(r+1,g-1).parts:void 0}),w=g}}r=g;continue}if(m=Ut,a){if(c+="{",i)E+="{"}r++;continue}r++}if(i&&E)b.push({type:"Literal",value:E,text:t.slice(w,r)});if(this.pos=r,this._wordText=c,this._wordRaw=d,this._wordQuoted=u,this._wordHasExpansions=l,this._wordKeywordEligible=f,this._wordIsAssignment=dH(y),this._wordAssignmentOperatorPos=this._wordIsAssignment?pH(y):void 0,i)this._wordParts=b.length>1||b.length===1&&b[0].type!=="Literal"?b:null}readInnerWordText(){let e=this.src,t=this.srcEnd,n=this.pos,r="",o=this._buildParts,s,i="",a=0;if(o)s=[],a=n;while(n<t){let c=e.charCodeAt(n);if(c===ke){if(n++,n<t)if(e.charCodeAt(n)===Ct)n++;else{let u=e[n++];if(r+=u,o)i+=u}continue}if(c===xt){let u=n;n++;let l=n;while(n<t&&e.charCodeAt(n)!==xt)n++;let f=e.slice(l,n);if(r+=f,n<t)n++;if(o){if(i)s.push({type:"Literal",value:i,text:e.slice(a,u)}),i="";s.push({type:"SingleQuoted",value:f,text:e.slice(u,n)}),a=n}continue}if(c===tt){let u=n;if(n++,this.pos=n,this.readDoubleQuoted(),n=this.pos,r+=this._dqText,o){if(i)s.push({type:"Literal",value:i,text:e.slice(a,u)}),i="";let l=e.slice(u,n);s.push({type:"DoubleQuoted",text:l,parts:this._dqParts??[{type:"Literal",value:this._dqText,text:e.slice(u+1,this._dqEnd)}]}),a=n}continue}if(c===$e){let u=n;if(this.pos=n,this.readDollar(),n=this.pos,r+=this._resultText,o)if(this._resultPart){if(i)s.push({type:"Literal",value:i,text:e.slice(a,u)}),i="";s.push(this._resultPart),a=n}else i+=this._resultText;continue}if(c===qe){let u=n;if(this.pos=n,this.readBacktickExpansion(),n=this.pos,r+=this._resultText,o){if(i)s.push({type:"Literal",value:i,text:e.slice(a,u)}),i="";s.push(this._resultPart),a=n}continue}if((c===dt||c===$t)&&n+1<t&&e.charCodeAt(n+1)===be){let u=n;this.pos=n+2;let l=this.extractBalanced();n=this.pos;let f=e.slice(u,n);if(r+=f,o){if(i)s.push({type:"Literal",value:i,text:e.slice(a,u)}),i="";let d={type:"ProcessSubstitution",text:f,operator:c===dt?"<":">",script:void 0,inner:l,innerStart:u+2};s.push(d),this.collect(d),a=n}continue}if(r+=e[n],o)i+=e[n];n++}if(o&&i)s.push({type:"Literal",value:i,text:e.slice(a,n)});if(this.pos=n,this._wordText=r,this._wordRaw=!1,this._wordQuoted=!1,this._wordHasExpansions=!1,this._wordKeywordEligible=!1,o)this._wordParts=s.length>1||s.length===1&&s[0].type!=="Literal"?s:null}parseSubFieldWord(e,t){if(e>=t)return new tn("",e,e);if(this._nestingDepth>=xn)return new tn(this.src.slice(e,t),e,t);this._nestingDepth++;let n=this.srcEnd,r=this.pos,o=this._wordText,s=this._wordParts,i=this._wordQuoted,a=this._wordKeywordEligible;this.srcEnd=t,this.pos=e,this.readInnerWordText();let c=new tn(this.src.slice(e,t),e,t);if(this._buildParts&&this._wordParts)c.parts=this._wordParts;return this.srcEnd=n,this.pos=r,this._wordText=o,this._wordParts=s,this._wordQuoted=i,this._wordKeywordEligible=a,this._nestingDepth--,c}skipSQ(){while(this.pos<this.srcEnd&&this.src.charCodeAt(this.pos)!==xt)this.pos++;if(this.pos<this.srcEnd)this.pos++}skipAnsiCQuoted(){let e=this.pos-1,t=FI(this.src,this.pos,this.srcEnd);if(this.pos=t.end,!t.closed)this.errors.push({message:"unterminated ANSI-C quote",pos:e})}skipDQ(){let e=this.src,t=this.srcEnd;while(this.pos<t){let n=e.charCodeAt(this.pos);if(n===tt){this.pos++;return}if(n===ke){this.pos+=2;continue}if(n===$e&&this.pos+1<t){let r=e.charCodeAt(this.pos+1);if(r===be){let o=this.pos;if(this.pos+=2,this.extractBalanced(),this._unbalanced)this.errors.push({message:"unterminated command substitution",pos:o});continue}if(r===Ut){this.pos+=2;let o=1;while(this.pos<t&&o>0){let s=e.charCodeAt(this.pos);if(s===lr){if(--o===0){this.pos++;break}}else if(s===Ut&&this.pos>0&&e.charCodeAt(this.pos-1)===$e)o++;else if(s===ke)this.pos++;else if(s===xt){this.pos++,this.skipSQ();continue}else if(s===tt){this.pos++,this.skipDQ();continue}this.pos++}continue}}if(n===qe){this.pos++;while(this.pos<t&&e.charCodeAt(this.pos)!==qe){if(e.charCodeAt(this.pos)===ke)this.pos++;this.pos++}if(this.pos<t)this.pos++;continue}this.pos++}}skipSpacesAndTabs(){let e=this.src,t=this.srcEnd;while(this.pos<t){let n=e.charCodeAt(this.pos);if(n===bo||n===Yo)this.pos++;else if(n===ke&&this.pos+1<t&&e.charCodeAt(this.pos+1)===Ct)this.pos+=2;else break}}readDoubleQuoted(){let e=this.src,t=this.srcEnd,n=this.pos,r=!1,o=this._buildParts,s=o||this._buildValue;if(!o){let l=this.pos;while(l<t){let f=e.charCodeAt(l);if(f===tt){this._dqText=s?e.slice(n,l):"",this._dqEnd=l,this.pos=l+1,this._dqHasExpansions=!1,this._dqParts=null;return}if(f===$e||f===qe||f===ke)break;l++}}let i="",a=null,c="",u=o?this.pos:0;while(this.pos<t&&e.charCodeAt(this.pos)!==tt){let l=this.pos;while(this.pos<t){let d=e.charCodeAt(this.pos);if(d===tt||d===ke||d===$e||d===qe)break;this.pos++}if(s&&this.pos>l){let d=e.slice(l,this.pos);if(i+=d,o)c+=d}if(this.pos>=t||e.charCodeAt(this.pos)===tt)break;let f=e.charCodeAt(this.pos);if(f===ke){if(this.pos++,this.pos<t){let d=e.charCodeAt(this.pos);if(d===Ct){this.pos++;continue}if(s)if(d===$e||d===qe||d===tt||d===ke){let m=e[this.pos];if(i+=m,o)c+=m}else{let m="\\"+e[this.pos];if(i+=m,o)c+=m}this.pos++}continue}if(f===$e){let d=this.pos+1<t?e.charCodeAt(this.pos+1):0;if(d===tt||d===xt){if(s){if(i+="$",o)c+="$"}this.pos++;continue}let m=this.pos;if(this.readDollar(),s)i+=this._resultText;if(this._resultHasExpansion)r=!0;if(o){let y=this._resultPart;if(y&&cH(y)){if(!a)a=[];if(c)a.push({type:"Literal",value:c,text:e.slice(u,m)}),c="";a.push(y),u=this.pos}else c+=this._resultText}continue}if(f===qe){let d=this.pos;if(this.readBacktickExpansion(),s)i+=this._resultText;if(r=!0,o&&this._resultPart&&cH(this._resultPart)){if(!a)a=[];if(c)a.push({type:"Literal",value:c,text:e.slice(u,d)}),c="";a.push(this._resultPart),u=this.pos}continue}}if(o&&a&&c)a.push({type:"Literal",value:c,text:e.slice(u,this.pos)});if(this._dqEnd=this.pos,this.pos<t)this.pos++;else this.errors.push({message:"unterminated double quote",pos:n-1});this._dqText=i,this._dqHasExpansions=r,this._dqParts=a}readDollar(){let e=this.pos;this.pos++;let t=this.src,n=this.srcEnd,r=this._buildParts||this._buildValue;if(this.pos>=n){this._resultText="$",this._resultIsRaw=!0,this._resultHasExpansion=!1,this._resultPart=void 0;return}let o=t.charCodeAt(this.pos);if(o===be){if(this.pos+1<n&&t.charCodeAt(this.pos+1)===be){let s=this.pos,i=this.errors.length;if(this.readArithmeticExpansion(),!this._notArithmetic)return;this.errors.length=i,this.pos=s}this.readCommandSubstitution();return}if(o===Ut){let s=this.pos+1<n?t.charCodeAt(this.pos+1):0;if(s===bo||s===Yo||s===Ct){this.readBraceCommandSubstitution();return}if(s===wo){this.readValueSubstitution();return}this.readParameterExpansion();return}if(o===xt){if(this.pos++,r){let s=this.readAnsiCQuoted();this._resultText=s,this._resultPart=this._buildParts?{type:"AnsiCQuoted",text:t.slice(e,this.pos),value:s}:void 0}else this.skipAnsiCQuoted(),this._resultText="",this._resultPart=void 0;this._resultIsRaw=!1,this._resultHasExpansion=!1;return}if(o===tt){if(this.pos++,this.readDoubleQuoted(),this._resultText=this._dqText,this._resultIsRaw=!1,this._resultHasExpansion=this._dqHasExpansions,this._buildParts){let s=t.slice(e,this.pos);this._resultPart={type:"LocaleString",text:s,parts:this._dqParts??[{type:"Literal",value:this._dqText,text:t.slice(e+2,this._dqEnd)}]}}else this._resultPart=void 0;return}if(o===eu||o===Is||o===hn||o===Xo||o===gn||o===$e||o===Ar||o>=_r&&o<=Or){this.pos++;let s=r?t.slice(this.pos-2,this.pos):"";this._resultText=s,this._resultIsRaw=!0,this._resultHasExpansion=!1,this._resultPart=this._buildParts?{type:"SimpleExpansion",text:s}:void 0;return}if(o<128&&Na[o]&1){let s=this.pos-1;while(this.pos<n){let a=t.charCodeAt(this.pos);if(a<128&&Na[a]&2)this.pos++;else break}let i=r?t.slice(s,this.pos):"";this._resultText=i,this._resultIsRaw=!0,this._resultHasExpansion=!1,this._resultPart=this._buildParts?{type:"SimpleExpansion",text:i}:void 0;return}if(o===Vn){let s=this.findClosingArithmeticBracket(this.pos+1);if(s!==-1){let i=this.pos+1,a=t.slice(i,s);this.pos=s+1;let c=r?t.slice(e,this.pos):"";this._resultText=c,this._resultIsRaw=!0,this._resultHasExpansion=!1,this._resultPart=this._buildParts?{type:"ArithmeticExpansion",text:c,expression:this.buildArithmeticExpression(a,i)}:void 0;return}}this._resultText="$",this._resultIsRaw=!0,this._resultHasExpansion=!1,this._resultPart=void 0}scanArithmeticBody(){this._notArithmetic=!1,this.pos+=2;let e=1,t=0,n=0,r,o=0,s=!1,i=this.src,a=this.srcEnd,c=this.pos;while(this.pos<a&&e>0){let u=i.charCodeAt(this.pos);if(u===ke)this.pos+=2;else if(u===xt)this.pos++,this.skipSQ();else if(u===tt)this.pos++,this.skipDQ();else if(u===qe){this.pos++;while(this.pos<a&&i.charCodeAt(this.pos)!==qe){if(i.charCodeAt(this.pos)===ke)this.pos++;this.pos++}if(this.pos<a)this.pos++}else if(u===$e&&this.pos+2<a&&i.charCodeAt(this.pos+1)===be&&i.charCodeAt(this.pos+2)!==be){let l=this.pos;if(this.pos+=2,this.extractBalanced(),this._unbalanced)this.errors.push({message:"unterminated command substitution",pos:l})}else if(u===$e&&this.pos+1<a&&i.charCodeAt(this.pos+1)===Ut){let l=this.findClosingBrace(this.pos+2,a);this.pos=l===-1?a:l+1}else if((u===dt||u===$t)&&this.pos+1<a&&i.charCodeAt(this.pos+1)===be)this.pos+=2,this.extractBalanced();else if(u===be)if(i.charCodeAt(this.pos-1)===$e&&i.charCodeAt(this.pos+1)===be){if(e===1)n=t;else(r??=[]).push(t);if(e++,t=0,++o+this._nestingDepth>=xn){if(!s)this.errors.push({message:"maximum arithmetic expansion nesting depth exceeded",pos:this.pos-1}),s=!0}this.pos+=2}else t++,this.pos++;else if(u===Qt&&t>0)t--,this.pos++;else if(u===Qt&&this.pos+1<a&&i.charCodeAt(this.pos+1)===Qt){if(--e===0){this.pos+=2;break}t=e===1?n:r.pop(),this.pos+=2}else if(u===Qt&&e===1)return this._notArithmetic=!0,"";else this.pos++}return this._buildParts||this._buildValue?i.slice(c,this.pos-2):""}readArithmeticExpansion(){let e=this.pos+2,t=this.scanArithmeticBody();if(this._notArithmetic)return;let n=this._buildParts||this._buildValue?"$(("+t+"))":"";this._resultText=n,this._resultIsRaw=!0,this._resultHasExpansion=!1,this._resultPart=this._buildParts?{type:"ArithmeticExpansion",text:n,expression:this.buildArithmeticExpression(t,e)}:void 0}buildArithmeticExpression(e,t){if(!Da(this.src,t,t+e.length))return af(e,t)??void 0;let n=[],r=[],o=af(e,t,{commandExpansions:n,embeddedWords:r,findClosingBracket:(s,i)=>this.findClosingBracket(s,i),findClosingBrace:(s,i)=>this.findClosingBrace(s,i),findClosingParenthesis:(s,i)=>this.findClosingParenthesis(s,i),findArithmeticExpansionEnd:(s,i)=>this.findArithmeticExpansionEnd(s,i),findArithmeticWordEnd:(s,i)=>this.findArithmeticWordEnd(s,i)})??void 0;for(let s of n)s.innerStart=s.pos+2,this.collect(s);for(let s of r)s.parts=this.parseSubFieldWord(s.pos,s.end).parts;return o}readArithmeticCommand(e,t){let n=this._buildValue;this._buildValue=!0;let r=this.scanArithmeticBody();this._buildValue=n,Tt(e,h.ArithCmd,r,t,this.pos)}readCommandSubstitution(){let e=this.pos-1;this.pos++;let t=this.extractBalanced();if(this._unbalanced)this.errors.push({message:"unterminated command substitution",pos:e});let r=this._buildParts||this._buildValue?this.src.slice(e,this.pos):"";if(this._resultText=r,this._resultIsRaw=!0,this._resultHasExpansion=!0,this._buildParts)this._resultPart={type:"CommandExpansion",text:r,script:void 0,inner:t,innerStart:e+2},this.collect(this._resultPart);else this._resultPart=void 0}readBraceCommandSubstitution(){this.readBraceSubstitution(1)}readValueSubstitution(){this.readBraceSubstitution(2)}readBraceSubstitution(e){let t=this.pos-1;this.pos+=e;let n=this.src,r=this.srcEnd,o=1,s=this.pos;while(this.pos<r){let i=n.charCodeAt(this.pos);if(i===Ut)o++;else if(i===lr){if(--o===0){this.pos++;break}}else if(i===xt){this.pos++,this.skipSQ();continue}else if(i===tt){this.pos++,this.skipDQ();continue}else if(i===ke)this.pos++;this.pos++}if(this._resultIsRaw=!0,this._resultHasExpansion=!0,this._buildParts||this._buildValue){let i=n.slice(s,this.pos-1),a=i.trim(),c=n.slice(t,this.pos);if(this._resultText=c,this._buildParts){let u=s+(i.length-i.trimStart().length);this._resultPart={type:"CommandExpansion",text:c,script:void 0,inner:a,innerStart:u},this.collect(this._resultPart)}else this._resultPart=void 0}else this._resultText="",this._resultPart=void 0}readBacktickExpansion(){this.pos++;let e=this.src,t=this.srcEnd,n=this.pos;if(!this._buildParts&&!this._buildValue){while(this.pos<t&&e.charCodeAt(this.pos)!==qe){if(e.charCodeAt(this.pos)===ke&&this.pos+1<t)this.pos++;this.pos++}if(this.pos<t)this.pos++;else this.errors.push({message:"unterminated backtick",pos:n-1});this._resultText="",this._resultIsRaw=!1,this._resultHasExpansion=!0,this._resultPart=void 0;return}let r="",o=!1;while(this.pos<t&&e.charCodeAt(this.pos)!==qe){if(e.charCodeAt(this.pos)===ke){o=!0;break}this.pos++}if(!o)r=e.slice(n,this.pos);else{r=e.slice(n,this.pos);while(this.pos<t&&e.charCodeAt(this.pos)!==qe)if(e.charCodeAt(this.pos)===ke){if(this.pos++,this.pos<t){let i=e.charCodeAt(this.pos);if(i===$e||i===qe||i===ke)r+=e[this.pos];else r+="\\"+e[this.pos];this.pos++}}else{let i=this.pos;while(this.pos<t){let a=e.charCodeAt(this.pos);if(a===qe||a===ke)break;this.pos++}r+=e.slice(i,this.pos)}}if(this.pos<t)this.pos++;else this.errors.push({message:"unterminated backtick",pos:n-1});let s=e.slice(n-1,this.pos);if(this._resultText=r,this._resultHasExpansion=!0,this._buildParts)this._resultPart={type:"CommandExpansion",text:s,script:void 0,inner:r,innerStart:o?void 0:n},this.collect(this._resultPart);else this._resultPart=void 0}readParameterExpansion(){let e=this.src,t=this.srcEnd,n=this.pos;this.pos++;let r=1,o=!1;while(this.pos<t&&r>0){let a=e.charCodeAt(this.pos);if(a===$e){let c=this.pos+1<t?e.charCodeAt(this.pos+1):0;if(c===Ut){if(r++,this._nestingDepth+r>xn&&!o)this.errors.push({message:"maximum parameter expansion nesting depth exceeded",pos:this.pos}),o=!0;this.pos+=2;continue}if(c===$e){this.pos+=2;continue}if(c===be){let u=this.pos;if(this.pos+=2,this.extractBalanced(),this._unbalanced)this.errors.push({message:"unterminated command substitution",pos:u});continue}}else if(a===qe){this.pos++;while(this.pos<t&&e.charCodeAt(this.pos)!==qe){if(e.charCodeAt(this.pos)===ke)this.pos++;this.pos++}if(this.pos<t)this.pos++;continue}else if(a===lr){if(--r===0){this.pos++;break}}else if(a===ke)this.pos++;else if(a===xt){if(this.pos++,this.pos>n+1&&e.charCodeAt(this.pos-2)===$e)this.skipAnsiCQuoted();else this.skipSQ();continue}else if(a===tt){this.pos++,this.skipDQ();continue}this.pos++}let s=r===0;if(!s)this.errors.push({message:"unterminated parameter expansion",pos:n-1});let i=this._buildParts||this._buildValue?e.slice(n-1,this.pos):"";if(this._resultText=i,this._resultIsRaw=!0,this._resultHasExpansion=!1,this._buildParts){let a=e.slice(n+1,s?this.pos-1:this.pos);this._resultPart=this.parseParamInner(i,a,n+1)}else this._resultPart=void 0}parseParamInner(e,t,n){let r={type:"ParameterExpansion",text:e,parameter:"",index:void 0,indexParts:void 0,indirect:void 0,length:void 0,operator:void 0,operand:void 0,slice:void 0,replace:void 0},o=t.length;if(o===0)return r;let s=(u,l)=>this.parseSubFieldWord(n+u,n+l),i=(u)=>{let l=this.findClosingBracket(n+u,n+o);return l===-1?-1:l-n},a=0;if(t.charCodeAt(0)===Ar)r.indirect=!0,a=1;if(!r.indirect&&t.charCodeAt(0)===hn){if(o===1)return r.parameter="#",r;if(t.charCodeAt(1)===hn)r.parameter="#",a=1;else{let u=this.scanParamName(t,1);if(u>1){let l=u;if(l<o&&t.charCodeAt(l)===Vn){let f=i(l+1);if(f!==-1)l=f+1}if(l>=o){if(r.length=!0,r.parameter=t.slice(1,u),u<o&&t.charCodeAt(u)===Vn){let f=i(u+1);if(f!==-1)r.index=t.slice(u+1,f),r.indexParts=s(u+1,f).parts}return r}}r.parameter="#",a=1}}if(!r.parameter){let u=a;a=this.scanParamName(t,a),r.parameter=t.slice(u,a)}if(a<o&&t.charCodeAt(a)===Vn){let u=i(a+1);if(u!==-1)r.index=t.slice(a+1,u),r.indexParts=s(a+1,u).parts,a=u+1}if(a>=o)return r;let c=t.charCodeAt(a);if(c===rf){if(a+1<o){let f=t.charCodeAt(a+1);if(f===gn||f===nt||f===On||f===Xo)return r.operator=t.slice(a,a+2),r.operand=s(a+2,o),r}a++;let u=t.slice(a),l=aH(u,rf);if(l===-1)r.slice={offset:s(a,o),length:void 0};else r.slice={offset:s(a,a+l),length:s(a+l+1,o)};return r}if(c===gn||c===nt||c===On||c===Xo)return r.operator=t[a],r.operand=s(a+1,o),r;if(c===hn){if(a+1<o&&t.charCodeAt(a+1)===hn)r.operator="##",r.operand=s(a+2,o);else r.operator="#",r.operand=s(a+1,o);return r}if(c===Yc){if(a+1<o&&t.charCodeAt(a+1)===Yc)r.operator="%%",r.operand=s(a+2,o);else r.operator="%",r.operand=s(a+1,o);return r}if(c===Xc){a++;let u="/";if(a<o){let d=t.charCodeAt(a);if(d===Xc)u="//",a++;else if(d===hn)u="/#",a++;else if(d===Yc)u="/%",a++}r.operator=u;let l=t.slice(a),f=aH(l,Xc);if(f===-1)r.replace={pattern:s(a,o),replacement:new tn("",n+o,n+o)};else r.replace={pattern:s(a,a+f),replacement:s(a+f+1,o)};return r}if(c===sf){if(a+1<o&&t.charCodeAt(a+1)===sf){if(r.operator="^^",a+2<o)r.operand=s(a+2,o)}else if(r.operator="^",a+1<o)r.operand=s(a+1,o);return r}if(c===nf){if(a+1<o&&t.charCodeAt(a+1)===nf){if(r.operator=",,",a+2<o)r.operand=s(a+2,o)}else if(r.operator=",",a+1<o)r.operand=s(a+1,o);return r}if(c===eu)return r.operator="@",r.operand=s(a+1,o),r;return r.operator=t.slice(a),r}scanParamName(e,t){let n=t;if(n>=e.length)return n;let r=e.charCodeAt(n);if(r===eu||r===Is||r===hn||r===Xo||r===gn||r===$e||r===Ar)return n+1;if(r>=_r&&r<=Or){while(n<e.length&&e.charCodeAt(n)>=_r&&e.charCodeAt(n)<=Or)n++;return n}if(r>=Oi&&r<=Pi||r>=Ra&&r<=Fa||r===Ma){n++;while(n<e.length){let o=e.charCodeAt(n);if(o>=Oi&&o<=Pi||o>=Ra&&o<=Fa||o>=_r&&o<=Or||o===Ma)n++;else break}}return n}readAnsiCQuoted(){let e=this.pos-1,t=FI(this.src,this.pos,this.srcEnd);if(this.pos=t.end,!t.closed)this.errors.push({message:"unterminated ANSI-C quote",pos:e});return t.value}extractBalanced(){let e=this.src,t=this.srcEnd,n=this._buildParts||this._buildValue,r=1,o=this.pos;this._unbalanced=!1;while(this.pos<t){let d=e.charCodeAt(this.pos);if(d===Qt){let m=n?e.slice(o,this.pos):"";return this.pos++,m}else if(d===be||d===ke||d===xt||d===tt||d===qe)break;else if(d===dt&&this.pos+1<t&&e.charCodeAt(this.pos+1)===dt)break;else if(d===hn&&(this.pos===o||e.charCodeAt(this.pos-1)<128&&Qe[e.charCodeAt(this.pos-1)]&1))break;else if(d===99&&(this.pos===o||e.charCodeAt(this.pos-1)<128&&Qe[e.charCodeAt(this.pos-1)]&1)&&this.pos+3<t&&e.charCodeAt(this.pos+1)===97&&e.charCodeAt(this.pos+2)===115&&e.charCodeAt(this.pos+3)===101&&(this.pos+4>=t||e.charCodeAt(this.pos+4)<128&&Qe[e.charCodeAt(this.pos+4)]&1))break;else this.pos++}let s=0,i=0,a=null,c=-1,u=o>=2&&e.charCodeAt(o)===be&&e.charCodeAt(o-1)===be&&e.charCodeAt(o-2)===$e,l=0,f=!1;while(this.pos<t&&r>0){let d=e.charCodeAt(this.pos);if(d===be){if(c<0&&this.pos+1<t&&e.charCodeAt(this.pos+1)===be)c=r;if(e.charCodeAt(this.pos-1)===$e&&++l+this._nestingDepth>=xn){if(!f)this.errors.push({message:"maximum command substitution nesting depth exceeded",pos:this.pos-1}),f=!0}if(r++,s>0)i++;this.pos++}else if(d===Qt)if(s>0&&i===0)this.pos++;else{if(s>0)i--;if(r--,r===0){let m=n?e.slice(o,this.pos):"";return this.pos++,m}if(r<=c)c=-1;this.pos++}else if(d===ke){if(this.pos++,this.pos<t)this.pos++}else if(d===xt)this.pos++,this.skipSQ();else if(d===tt)this.pos++,this.skipDQ();else if(d===qe){this.pos++;while(this.pos<t&&e.charCodeAt(this.pos)!==qe){if(e.charCodeAt(this.pos)===ke)this.pos++;if(this.pos<t)this.pos++}if(this.pos<t)this.pos++}else if(d===dt&&c<0&&this.pos+1<t&&e.charCodeAt(this.pos+1)===dt)if(this.pos+2<t&&e.charCodeAt(this.pos+2)===dt)this.pos+=3;else{this.pos+=2;let m=this.pos<t&&e.charCodeAt(this.pos)===gn;if(m)this.pos++;if(this.skipSpacesAndTabs(),this.readHereDocDelimiter(),this._hereDelim||this._hereQuoted)(a??=[]).push({delimiter:this._hereDelim,strip:m,quoted:this._hereQuoted})}else if(d===Ct&&a){this.pos++;for(let m of a)this.skipHereDocBody(m.delimiter,m.strip,!0,m.quoted);a=null}else if(d===hn&&c<0&&!u&&iH(e,this.pos,o))while(this.pos<t&&e.charCodeAt(this.pos)!==Ct)this.pos++;else{let m=this.pos;while(this.pos<t){let y=e.charCodeAt(this.pos);if(y<128&&Qe[y])break;this.pos++}if(this.pos>m){let y=this.pos-m,b=m>o?e.charCodeAt(m-1):0;if(y===4&&(m===o||b<128&&Qe[b]&1)){let E=e.charCodeAt(m);if(E===99&&e.charCodeAt(m+1)===97&&e.charCodeAt(m+2)===115&&e.charCodeAt(m+3)===101)s++;else if(E===101&&e.charCodeAt(m+1)===115&&e.charCodeAt(m+2)===97&&e.charCodeAt(m+3)===99&&s>0){if(s--,s===0)i=0}}}else this.pos++}}return this._unbalanced=!0,n?e.slice(o,this.pos):""}}var xn=256,h,Rte,Qe,mH,Na,$a,Fte,Co=-1,wy=0,uH=1,lH=2,fH=3,ko=4,Nte,T;var DI=v(()=>{MI();h={Word:0,Assignment:1,Semi:2,Newline:3,Pipe:4,And:5,Or:6,Amp:7,LParen:8,RParen:9,LBrace:10,RBrace:11,Bang:12,If:13,Then:14,Else:15,Elif:16,Fi:17,Do:18,Done:19,For:20,While:21,Until:22,In:23,Case:24,Esac:25,Function:26,DoubleSemi:27,SemiAmp:28,DoubleSemiAmp:29,Select:30,DblLBracket:31,DblRBracket:32,EOF:33,ArithCmd:34,Coproc:35,Redirect:36};Rte=new Map([["if",h.If],["then",h.Then],["else",h.Else],["elif",h.Elif],["fi",h.Fi],["do",h.Do],["done",h.Done],["for",h.For],["while",h.While],["until",h.Until],["in",h.In],["case",h.Case],["esac",h.Esac],["function",h.Function],["select",h.Select],["coproc",h.Coproc],["!",h.Bang],["{",h.LBrace],["}",h.RBrace]]),Qe=new Uint8Array(128);Qe[wo]=1;Qe[Tr]=1;Qe[of]=1;Qe[be]=1;Qe[Qt]=1;Qe[dt]=1;Qe[$t]=1;Qe[bo]=1;Qe[Yo]=1;Qe[Ct]=1;Qe[ke]=2;Qe[xt]=2;Qe[tt]=2;Qe[$e]=2;Qe[qe]=2;Qe[Ut]=2;mH=new Uint8Array(128);for(let e of[Yo,Ct,bo,Ar,Yc,Tr,be,Qt,Is,On,nf,gn,Xc,rf,dt,nt,$t,Xo,sf,wo])mH[e]=1;Na=new Uint8Array(128);for(let e=Oi;e<=Pi;e++)Na[e]=3;for(let e=Ra;e<=Fa;e++)Na[e]=3;for(let e=_r;e<=Or;e++)Na[e]=2;Na[Ma]=3;$a=new Uint8Array(128);$a[Xo]=1;$a[eu]=1;$a[Is]=1;$a[On]=1;$a[Ar]=1;$a[nt]=1;Fte={[Xo]:"?",[eu]:"@",[Is]:"*",[On]:"+",[Ar]:"!"};Nte=[];T={Normal:0,CommandStart:1,TestMode:2,CommandPrefix:3}});function hH(e,t,n=0){let r=new es(e,t.pos,t.end);r._nestingDepth=n;let o=r.buildWordParts(t.pos);if(!o)return;return NI(r),o}function Cy(e,t,n=0){if(!Da(e,t.pos,t.end))return;let r=new es(e,t.pos,t.end);r._nestingDepth=n;let o=r.buildEmbeddedWordParts(t.pos);if(!o)return;return NI(r),o}function gH(e,t,n=0){let r=new es(e,t.pos,t.end);r._nestingDepth=n;let o=r.buildHereDocParts(t.pos,t.end);if(!o)return;return NI(r),o}function NI(e){let t=e.getSource();for(let[n,r]of e.getCollectedExpansions())if(n.inner!==void 0){let o=r+1;if(o>xn+1);else if(n.innerStart!==void 0)n.script=$I(t,n.innerStart,n.innerStart+n.inner.length,o);else n.script=cf(n.inner),Object.defineProperty(n.script,"source",{value:n.inner,enumerable:!1});n.inner=void 0,n.innerStart=void 0}}var xH=v(()=>{DI();UI()});class yH{type="ArithmeticCommand";pos;end;body;#t;#e;#n=null;constructor(e,t,n,r,o){this.pos=e,this.end=t,this.body=n,this.#t=r,this.#e=o}get expression(){if(this.#n===null)this.#n=Iy(this.body,this.pos+2,this.#t,this.#e);return this.#n}set expression(e){this.#n=e??void 0}toJSON(){return{type:this.type,pos:this.pos,end:this.end,expression:this.expression,body:this.body}}}class vy{type="ArithmeticFor";pos;end;body;#t;#e;#n;#o;#i;#m;#f;#p;#d=null;#a=null;#u=null;constructor(e,t,n,r,o,s,i,a,c,u,l){this.pos=e,this.end=t,this.body=n,this.#t=r,this.#e=o,this.#n=s,this.#o=i,this.#i=a,this.#m=c,this.#f=u,this.#p=l}get initialize(){if(this.#d===null)if(this.#t)this.#d=Iy(this.#t,this.#o,this.#f,this.#p);else this.#d=void 0;return this.#d}set initialize(e){this.#d=e??void 0}get test(){if(this.#a===null)if(this.#e)this.#a=Iy(this.#e,this.#i,this.#f,this.#p);else this.#a=void 0;return this.#a}set test(e){this.#a=e??void 0}get update(){if(this.#u===null)if(this.#n)this.#u=Iy(this.#n,this.#m,this.#f,this.#p);else this.#u=void 0;return this.#u}set update(e){this.#u=e??void 0}toJSON(){return{type:this.type,pos:this.pos,end:this.end,initialize:this.initialize,test:this.test,update:this.update,body:this.body}}}function Iy(e,t,n,r=0){if(!Da(n,t,t+e.length))return af(e,t)??void 0;let o=[],s=[],i=new es(n),a=af(e,t,{commandExpansions:o,embeddedWords:s,findClosingBracket:(c,u)=>i.findClosingBracket(c,u),findClosingBrace:(c,u)=>i.findClosingBrace(c,u),findClosingParenthesis:(c,u)=>i.findClosingParenthesis(c,u),findArithmeticExpansionEnd:(c,u)=>i.findArithmeticExpansionEnd(c,u),findArithmeticWordEnd:(c,u)=>i.findArithmeticWordEnd(c,u)})??void 0;for(let c of o)if(c.inner!==void 0){if(r<=xn){let u=c.pos+2;c.script=$I(n,u,u+c.inner.length,r+1)}c.inner=void 0}for(let c of s)c.parts=Cy(n,c,r);return a}function LI(e){return e.token===h.Word&&e.keywordEligible&&e.value==="!"}function jte(e){return(t,n)=>{let r=t.slice(n.pos,n.end);return r===e?void 0:[{type:"Literal",value:e,text:r}]}}function hm(e){return e.length===0?[]:e}function cf(e){return new BI(e,0,e.length).run()}function $I(e,t,n,r=0){return new BI(e,t,n,r).run()}class BI{tok;source;start;end;depth;errors=null;_redirects=vo;syntaxDepth=0;constructor(e,t,n,r=0){this.tok=new es(e,t,n),this.tok._nestingDepth=r,this.source=e,this.start=t,this.end=n,this.depth=r}run(){let e=this.start;if(this.depth>xn)this.error("maximum substitution nesting depth exceeded",e);let t;if(e===0&&this.source.charCodeAt(0)===35&&this.source.charCodeAt(1)===33){let s=this.source.indexOf(`
|
|
42
|
+
`);t=s===-1?this.source:this.source.slice(0,s)}let n=this.list();for(;;){let s=this.tok.peek(T.CommandStart);if(s.token===h.EOF)break;if(this.error(`unexpected token '${s.value}'`,s.pos),!Kn[s.token]&&s.token!==h.In)break;this.tok.next(T.CommandStart);let i=this.tok.peek(T.CommandStart).token;if(i!==h.Semi&&i!==h.Newline&&i!==h.Amp)break;while(i===h.Semi||i===h.Newline||i===h.Amp)this.tok.next(T.CommandStart),i=this.tok.peek(T.CommandStart).token;let a=this.list();for(let c=0;c<a.length;c++)n.push(a[c])}let r=this.tok._errors;if(r!==null&&r.length>0){let s=this.errors??=[];for(let i=0;i<r.length;i++)s.push(r[i])}if(this.errors!==null&&this.errors.length>1)this.errors.sort((s,i)=>s.pos-i.pos);return{type:"Script",pos:e,end:this.end,shebang:t,commands:n,errors:this.errors??void 0}}error(e,t){(this.errors??=[]).push({message:e,pos:t})}skipSemi(){if(this.tok.peek(T.Normal).token===h.Semi)this.tok.next(T.Normal)}accept(e,t=T.Normal){if(this.tok.peek(t).token===e)return this.tok.next(t);return null}acceptEnd(e,t=T.Normal){if(this.tok.peek(t).token===e)return this.tok.next(t).end;return-1}skipNewlines(e=T.Normal){while(this.tok.peek(e).token===h.Newline)this.tok.next(e)}makeStatement(e,t){let n=t.length>0?t[t.length-1].end:e.end;return{type:"Statement",pos:e.pos,end:n,command:e,background:void 0,redirects:hm(t)}}list(){let e=[];this.skipNewlines(T.CommandStart);let t=this.tok.peek(T.CommandStart).token;if(Kn[t]||!yn[t])return e;let n=this.andOr();if(n){let r=this._redirects;this._redirects=vo,e.push(this.makeStatement(n,r))}for(;;){if(t=this.tok.peekFollow(Ri).token,t!==h.Semi&&t!==h.Newline&&t!==h.Amp)break;let r=t===h.Amp,o=this.tok.next(T.Normal).end;if(r){let i=e[e.length-1];i.background=!0,i.end=o}if(this.skipNewlines(T.CommandStart),t=this.tok.peek(T.CommandStart).token,Kn[t]||!yn[t])break;let s=this.andOr();if(s){let i=this._redirects;this._redirects=vo,e.push(this.makeStatement(s,i))}}return e}andOr(){let e=this.pipeline();if(!e)return null;let t=this.tok.peek(T.Normal).token;if(t!==h.And&&t!==h.Or)return e;let n=e;if(this._redirects.length>0)n=this.makeStatement(e,this._redirects),this._redirects=vo;let r=[n],o=[];do{let s=this.tok.next(T.Normal),i=s.token===h.And?"&&":"||";this.skipNewlines(T.CommandStart);let a=this.pipeline();if(!a){this.error(`expected command after '${i}'`,s.end);break}o.push(i),r.push(a),t=this.tok.peek(T.Normal).token}while(t===h.And||t===h.Or);return{type:"AndOr",pos:e.pos,end:r[r.length-1].end,commands:r,operators:o}}wrapCompoundRedirects(e){let t=this._redirects;if(this._redirects=vo,t.length===0)return e;return this.makeStatement(e,t)}pipeline(){let e=!1,t=0,n=0,r=this.tok.peek(T.CommandStart);if(r.token===h.Word&&r.keywordEligible&&r.value==="time"){e=!0;let f=this.tok.next(T.CommandStart);t=f.pos,n=f.end;let d=this.tok.peek(T.CommandStart);if(d.token===h.Word&&d.keywordEligible&&d.value==="-p")n=this.tok.next(T.CommandStart).end}let o=!1,s=this.tok.peek(T.CommandStart);if(s.token===h.Bang){if(!e)t=s.pos;n=this.tok.next(T.CommandStart).end,o=!0;let f=this.tok.peek(T.CommandStart);if(f.token===h.Bang){this.error("unexpected token '!'",f.pos);do n=this.tok.next(T.CommandStart).end;while(this.tok.peek(T.CommandStart).token===h.Bang)}}let i=this.command();if(!i){if(e||o)return{type:"Pipeline",pos:t,end:n,commands:[],negated:o?!0:void 0,operators:[],time:e?!0:void 0};return null}if(!e&&!o)t=i.pos;let a=[i],c=[],u=this._redirects;this._redirects=vo;while(this.tok.peek(T.Normal).token===h.Pipe){if(a.length===1&&u.length>0)a[0]=this.makeStatement(i,u),u=[];let f=this.tok.next(T.Normal),d=f.value==="|&"?"|&":"|";this.skipNewlines(T.CommandStart);let m=this.command();if(!m){this.error(`expected command after '${d}'`,f.end);break}c.push(d),a.push(this.wrapCompoundRedirects(m))}if(a.length===1&&!o&&!e)return this._redirects=u,a[0];if(u.length>0)a[0]=this.makeStatement(i,u);return{type:"Pipeline",pos:t,end:a[a.length-1].end,commands:a,negated:o?!0:void 0,operators:c,time:e?!0:void 0}}command(){switch(this.tok.peek(T.CommandStart).token){case h.LParen:return this.subshell();case h.LBrace:return this.braceGroup();case h.If:return this.ifClause();case h.For:return this.forClause();case h.While:return this.whileClause();case h.Until:return this.untilClause();case h.Case:return this.caseClause();case h.Function:return this.functionDef();case h.Select:return this.selectClause();case h.DblLBracket:return this.testCommand();case h.ArithCmd:return this.arithCommand();case h.Coproc:return this.coprocCommand();case h.Word:case h.Assignment:case h.Redirect:return this.simpleCommandOrFunction();default:return null}}collectTrailingRedirects(){let e=vo;while(this.tok.peekFollow(Ri).token===h.Redirect)e=this.collectRedirect(e,T.Normal);return e}arithCommand(){let e=this.tok.next(T.CommandStart);return this._redirects=this.collectTrailingRedirects(),new yH(e.pos,e.end,e.value,this.source,this.depth)}coprocCommand(){let e=this.tok.next(T.CommandStart),t=e.pos,n=e.end,r=this.tok.peek(T.CommandStart);if(r.token!==h.Word&&r.token!==h.Assignment&&r.token!==h.Redirect){let l=this.pipeline()??{type:"Command",pos:t,end:n,name:void 0,prefix:[],suffix:[],redirects:[]},f=this._redirects;this._redirects=vo;let d=this.collectTrailingRedirects(),m=[...f,...d],y=m.length>0?m[m.length-1].end:l.end;return{type:"Coproc",pos:t,end:y,name:void 0,body:l,redirects:m}}let o=this.toWord(this.tok.next(T.CommandStart)),s=this.pipeline();if(s===null){let l={type:"Command",pos:o.pos,end:o.end,name:o,prefix:[],suffix:[],redirects:[]},f=this.collectTrailingRedirects(),d=f.length>0?f[f.length-1].end:l.end;return{type:"Coproc",pos:t,end:d,name:void 0,body:l,redirects:hm(f)}}if(s.type==="Command"){let l=s;if(l.name)l.suffix=[l.name,...l.suffix];l.name=o,l.pos=o.pos;let f=this.collectTrailingRedirects(),d=f.length>0?f[f.length-1].end:l.end;return{type:"Coproc",pos:t,end:d,name:void 0,body:l,redirects:hm(f)}}let i=this._redirects;this._redirects=vo;let a=this.collectTrailingRedirects(),c=[...i,...a],u=c.length>0?c[c.length-1].end:s.end;return{type:"Coproc",pos:t,end:u,name:o,body:s,redirects:c}}subshell(){return this.subshellBody(this.tok.next(T.CommandStart).pos)}subshellBody(e){if(this.syntaxDepth===xn){this.error("maximum subshell nesting depth exceeded",e);let o=this.tok.skipSubshellBody();if(o<0)this.error("expected ')' to close subshell",this.tok.getPos());let s=o>=0?o:e;return this._redirects=this.collectTrailingRedirects(),{type:"Subshell",pos:e,end:s,body:this.makeCompoundList([])}}this.syntaxDepth++;let t=this.list();this.syntaxDepth--;let n=this.acceptEnd(h.RParen,T.Normal);if(n<0)this.error("expected ')' to close subshell",this.tok.getPos());let r=n>=0?n:e;return this._redirects=this.collectTrailingRedirects(),{type:"Subshell",pos:e,end:r,body:this.makeCompoundList(t)}}braceGroup(){let e=this.tok.next(T.CommandStart).pos;if(this.syntaxDepth===xn){this.error("maximum brace group nesting depth exceeded",e);let o=this.tok.skipCompoundBody(h.RBrace);if(o<0)this.error("expected '}' to close brace group",this.tok.getPos());let s=o>=0?o:e;return this._redirects=this.collectTrailingRedirects(),{type:"BraceGroup",pos:e,end:s,body:this.makeCompoundList([])}}this.syntaxDepth++;let t=this.list();this.syntaxDepth--;let n=this.acceptEnd(h.RBrace,T.Normal);if(n<0)this.error("expected '}' to close brace group",this.tok.getPos());let r=n>=0?n:e;return this._redirects=this.collectTrailingRedirects(),{type:"BraceGroup",pos:e,end:r,body:this.makeCompoundList(t)}}ifClause(){let e=this.tok.next(T.CommandStart).pos;if(this.syntaxDepth===xn){this.error("maximum if nesting depth exceeded",e);let l=this.tok.skipCompoundBody(h.Fi);if(l<0)this.error("expected 'fi' to close 'if'",this.tok.getPos());let f=l>=0?l:e;return this._redirects=this.collectTrailingRedirects(),{type:"If",pos:e,end:f,clause:this.makeCompoundList([]),then:this.makeCompoundList([]),else:void 0}}this.syntaxDepth++;let t,n,r=e,o,s;for(;;){if(o=this.makeCompoundList(this.list()),this.skipSemi(),!this.accept(h.Then,T.CommandStart))this.error("expected 'then'",this.tok.getPos());s=this.makeCompoundList(this.list()),this.skipSemi();let l=this.accept(h.Elif,T.CommandStart);if(!l)break;let f={type:"If",pos:r,end:r,clause:o,then:s,else:void 0};if(n)n.else=f;else t=f;n=f,r=l.pos}let i,a;if(this.accept(h.Else,T.CommandStart)){i=this.makeCompoundList(this.list()),this.skipSemi();let l=this.acceptEnd(h.Fi,T.CommandStart);if(l<0)this.error("expected 'fi' to close 'if'",this.tok.getPos());a=l>=0?l:r}else{let l=this.acceptEnd(h.Fi,T.CommandStart);if(l<0)this.error("expected 'fi' to close 'if'",this.tok.getPos());a=l>=0?l:r}this.syntaxDepth--,this._redirects=this.collectTrailingRedirects();let c={type:"If",pos:r,end:a,clause:o,then:s,else:i};if(!t)return c;n.else=c;let u=t;while(u!==c)u.end=a,u=u.else;return t}forClause(){let e=this.tok.next(T.CommandStart).pos;if(this.tok.peek(T.Normal).token===h.LParen)return this.cStyleFor(e);let t=this.readWord(T.Normal),n=[];if(this.skipNewlines(T.CommandStart),this.tok.peek(T.CommandStart).token===h.In){this.tok.next(T.CommandStart);while(this.tok.peek(T.Normal).token===h.Word)n.push(this.readWord(T.Normal))}if(this.skipSemi(),this.skipNewlines(T.CommandStart),this.tok.peek(T.CommandStart).token===h.LBrace){let i=this.braceGroup();return{type:"For",pos:e,end:i.end,name:t,wordlist:n,body:i.body}}if(!this.accept(h.Do,T.CommandStart))this.error("expected 'do'",this.tok.getPos());if(this.syntaxDepth===xn){this.error("maximum for nesting depth exceeded",e);let i=this.tok.skipCompoundBody(h.Done);if(i<0)this.error("expected 'done' to close 'for'",this.tok.getPos());let a=i>=0?i:e;return this._redirects=this.collectTrailingRedirects(),{type:"For",pos:e,end:a,name:t,wordlist:n,body:this.makeCompoundList([])}}this.syntaxDepth++;let r=this.list();this.syntaxDepth--,this.skipSemi();let o=this.acceptEnd(h.Done,T.CommandStart);if(o<0)this.error("expected 'done' to close 'for'",this.tok.getPos());let s=o>=0?o:e;return this._redirects=this.collectTrailingRedirects(),{type:"For",pos:e,end:s,name:t,wordlist:n,body:this.makeCompoundList(r)}}cStyleFor(e){let[t,n,r,o,s,i]=this.tok.readCStyleForExprs();if(this.tok.peek(T.CommandStart).token===h.Semi)this.tok.next(T.CommandStart);if(this.skipNewlines(T.CommandStart),this.tok.peek(T.CommandStart).token===h.LBrace){let l=this.braceGroup();return new vy(e,l.end,l.body,t,n,r,o,s,i,this.source,this.depth)}if(!this.accept(h.Do,T.CommandStart))this.error("expected 'do'",this.tok.getPos());if(this.syntaxDepth===xn){this.error("maximum for nesting depth exceeded",e);let l=this.tok.skipCompoundBody(h.Done);if(l<0)this.error("expected 'done' to close 'for'",this.tok.getPos());let f=l>=0?l:e;return this._redirects=this.collectTrailingRedirects(),new vy(e,f,this.makeCompoundList([]),t,n,r,o,s,i,this.source,this.depth)}this.syntaxDepth++;let a=this.list();this.syntaxDepth--;let c=this.acceptEnd(h.Done,T.CommandStart);if(c<0)this.error("expected 'done' to close 'for'",this.tok.getPos());let u=c>=0?c:e;return this._redirects=this.collectTrailingRedirects(),new vy(e,u,this.makeCompoundList(a),t,n,r,o,s,i,this.source,this.depth)}whileClause(){return this.whileOrUntil("while")}untilClause(){return this.whileOrUntil("until")}whileOrUntil(e){let t=this.tok.next(T.CommandStart).pos;if(this.syntaxDepth===xn){this.error(`maximum ${e} nesting depth exceeded`,t);let i=this.tok.skipCompoundBody(h.Done);if(i<0)this.error(`expected 'done' to close '${e}'`,this.tok.getPos());let a=i>=0?i:t;return this._redirects=this.collectTrailingRedirects(),{type:"While",pos:t,end:a,kind:e,clause:this.makeCompoundList([]),body:this.makeCompoundList([])}}this.syntaxDepth++;let n=this.makeCompoundList(this.list());if(this.skipSemi(),!this.accept(h.Do,T.CommandStart))this.error("expected 'do'",this.tok.getPos());let r=this.list();this.skipSemi();let o=this.acceptEnd(h.Done,T.CommandStart);if(o<0)this.error(`expected 'done' to close '${e}'`,this.tok.getPos());let s=o>=0?o:t;return this.syntaxDepth--,this._redirects=this.collectTrailingRedirects(),{type:"While",pos:t,end:s,kind:e,clause:n,body:this.makeCompoundList(r)}}caseClause(){let e=this.tok.next(T.CommandStart).pos,t=this.readWord(T.Normal);if(this.skipNewlines(T.CommandStart),!this.accept(h.In,T.CommandStart))this.error("expected 'in' after 'case' word",this.tok.getPos());if(this.skipNewlines(T.CommandStart),this.syntaxDepth===xn){this.error("maximum case nesting depth exceeded",e);let i=this.tok.skipCompoundBody(h.Esac);if(i<0)this.error("expected 'esac' to close 'case'",this.tok.getPos());let a=i>=0?i:e;return this._redirects=this.collectTrailingRedirects(),{type:"Case",pos:e,end:a,word:t,items:[]}}this.syntaxDepth++;let n=[],r=this.tok.peek(T.CommandStart).token;while(r!==h.Esac&&r!==h.EOF){let i=this.tok.peek(T.Normal).pos;this.accept(h.LParen,T.Normal);let a=[];r=this.tok.peek(T.Normal).token;while(r!==h.RParen&&r!==h.EOF){if(r!==h.Pipe)a.push(this.toWord(this.tok.next(T.Normal)));else this.tok.next(T.Normal);r=this.tok.peek(T.Normal).token}let c=this.acceptEnd(h.RParen,T.Normal),u=this.list(),l=c>=0?c:i;if(u.length>0)l=u[u.length-1].end;let f={type:"CaseItem",pos:i,end:l,pattern:a,body:this.makeCompoundList(u),terminator:void 0};if(r=this.tok.peek(T.CommandStart).token,r===h.DoubleSemi||r===h.SemiAmp||r===h.DoubleSemiAmp){let d=this.tok.next(T.CommandStart);f.terminator=Lte[d.token],f.end=d.end}n.push(f),this.skipNewlines(T.CommandStart),r=this.tok.peek(T.CommandStart).token}let o=this.acceptEnd(h.Esac,T.CommandStart);if(o<0)this.error("expected 'esac' to close 'case'",this.tok.getPos());let s=o>=0?o:e;return this.syntaxDepth--,this._redirects=this.collectTrailingRedirects(),{type:"Case",pos:e,end:s,word:t,items:n}}selectClause(){let e=this.tok.next(T.CommandStart).pos,t=this.readWord(T.Normal),n=[];if(this.skipNewlines(T.CommandStart),this.tok.peek(T.CommandStart).token===h.In){this.tok.next(T.CommandStart);while(this.tok.peek(T.Normal).token===h.Word)n.push(this.readWord(T.Normal))}if(this.skipSemi(),this.skipNewlines(T.CommandStart),this.tok.peek(T.CommandStart).token===h.LBrace){let i=this.braceGroup();return{type:"Select",pos:e,end:i.end,name:t,wordlist:n,body:i.body}}if(!this.accept(h.Do,T.CommandStart))this.error("expected 'do'",this.tok.getPos());if(this.syntaxDepth===xn){this.error("maximum select nesting depth exceeded",e);let i=this.tok.skipCompoundBody(h.Done);if(i<0)this.error("expected 'done' to close 'select'",this.tok.getPos());let a=i>=0?i:e;return this._redirects=this.collectTrailingRedirects(),{type:"Select",pos:e,end:a,name:t,wordlist:n,body:this.makeCompoundList([])}}this.syntaxDepth++;let r=this.list();this.syntaxDepth--,this.skipSemi();let o=this.acceptEnd(h.Done,T.CommandStart);if(o<0)this.error("expected 'done' to close 'select'",this.tok.getPos());let s=o>=0?o:e;return this._redirects=this.collectTrailingRedirects(),{type:"Select",pos:e,end:s,name:t,wordlist:n,body:this.makeCompoundList(r)}}testCommand(){let e=this.tok.next(T.CommandStart).pos,t=this.parseTestOr(),n=this.acceptEnd(h.DblRBracket,T.TestMode);if(n<0)this.error("expected ']]' to close '[['",this.tok.getPos());let r=n>=0?n:e;return this._redirects=this.collectTrailingRedirects(),{type:"TestCommand",pos:e,end:r,expression:t}}parseTestOr(){let e=this.parseTestAnd();while(this.tok.peek(T.TestMode).token===h.Or){this.tok.next(T.TestMode);let t=this.parseTestAnd();e={type:"TestLogical",pos:e.pos,end:t.end,operator:"||",left:e,right:t}}return e}parseTestAnd(){let e=this.parseTestNot();while(this.tok.peek(T.TestMode).token===h.And){this.tok.next(T.TestMode);let t=this.parseTestNot();e={type:"TestLogical",pos:e.pos,end:t.end,operator:"&&",left:e,right:t}}return e}parseTestNot(){let e=this.tok.peek(T.TestMode);if(!LI(e))return this.parseTestPrimary();let t=this.tok.next(T.TestMode).pos;if(e=this.tok.peek(T.TestMode),!LI(e)){let o=this.parseTestPrimary();return{type:"TestNot",pos:t,end:o.end,operand:o}}let n=[t];while(LI(e))n.push(this.tok.next(T.TestMode).pos),e=this.tok.peek(T.TestMode);let r=this.parseTestPrimary();for(let o=n.length-1;o>=0;o--)r={type:"TestNot",pos:n[o],end:r.end,operand:r};return r}parseTestPrimary(){if(this.tok.peek(T.TestMode).token===h.LParen){let i=this.tok.next(T.TestMode).pos;if(this.syntaxDepth===xn){this.error("maximum test group nesting depth exceeded",i);let l=this.tok.skipTestGroup();if(l<0)this.error("expected ')' to close test group",this.tok.getPos());let f=l>=0?l:i,d=new tn("",i,i,this.source,void 0,this.depth);return{type:"TestGroup",pos:i,end:f,expression:{type:"TestUnary",pos:i,end:i,operator:"-n",operand:d}}}this.syntaxDepth++;let a=this.parseTestOr();this.syntaxDepth--;let c=this.acceptEnd(h.RParen,T.TestMode);if(c<0)this.error("expected ')' to close test group",this.tok.getPos());let u=c>=0?c:i;return{type:"TestGroup",pos:i,end:u,expression:a}}let e=this.tok.next(T.TestMode),t=e.value,n=e.pos,r=e.end;if(e.keywordEligible&&Hte[t]===1){if(this.tok.peek(T.TestMode).token===h.Word){let a=this.readWord(T.TestMode);return{type:"TestUnary",pos:n,end:a.end,operator:t,operand:a}}}let o=this.tok.peek(T.TestMode);if(o.token===h.Word&&o.keywordEligible&&Wte[o.value]===1){let i=this.tok.next(T.TestMode).value,a;if(i==="=~"){let u=this.tok.readTestRegexWord();a=new tn(this.source.slice(u.pos,u.end),u.pos,u.end,this.source,Cy,this.depth)}else a=this.readWord(T.TestMode);let c=this.toWordFromPosEnd(e,n,r);return{type:"TestBinary",pos:n,end:a.end,operator:i,left:c,right:a}}let s=this.toWordFromPosEnd(e,n,r);return{type:"TestUnary",pos:n,end:s.end,operator:"-n",operand:s}}functionDef(){let e=this.tok.next(T.CommandStart).pos,t=this.readWord(T.Normal),n;if(this.tok.peek(T.CommandStart).token===h.LParen){let s=this.tok.next(T.CommandStart).pos;if(this.tok.peek(T.CommandStart).token===h.RParen)this.tok.next(T.CommandStart),this.skipNewlines(T.CommandStart),n=this.commandAsBody();else n=this.subshellBody(s)}else this.skipNewlines(T.CommandStart),n=this.commandAsBody();let r=this._redirects;this._redirects=vo;let o=r.length>0?r[r.length-1].end:n.end;return{type:"Function",pos:e,end:o,name:t,body:n,redirects:hm(r)}}simpleCommandOrFunction(){let e=[],t=[],n=this.tok.peek(T.CommandStart).pos,r=n,o=T.CommandStart;for(;;){let a=this.tok.peek(o).token;if(a===h.Assignment){let c=this.tok.next(o);r=c.end,e.push(this.parseAssignment(c))}else if(a===h.Redirect)t=this.collectRedirect(t,o),r=t[t.length-1].end;else break;o=T.CommandPrefix}if(this.tok.peek(T.Normal).token!==h.Word)return{type:"Command",pos:n,end:r,name:void 0,prefix:e,suffix:[],redirects:t};let s=this.readWord(T.Normal);if(r=s.end,this.tok.peek(T.Normal).token===h.LParen){if(this.tok.next(T.Normal),this.tok.peek(T.Normal).token===h.RParen){this.tok.next(T.Normal),this.skipNewlines(T.CommandStart);let a=this.commandAsBody(),c=this._redirects;this._redirects=vo;let u=c.length>0?c[c.length-1].end:a.end;return{type:"Function",pos:s.pos,end:u,name:s,body:a,redirects:hm(c)}}}let i=[];for(;;){let a=this.tok.peek(T.Normal).token;if(a===h.Word||a===h.Assignment){let c=this.readWord(T.Normal);i.push(c),r=c.end}else if(a===h.Redirect)t=this.collectRedirect(t,T.Normal),r=t[t.length-1].end;else break}return{type:"Command",pos:n,end:r,name:s,prefix:e,suffix:i,redirects:t}}collectRedirect(e,t){if(e===vo)e=[];let n=this.tok.next(t),r=n.pos,o=n.end,s={pos:r,end:o,operator:Bte[n.value]??">",target:void 0,fileDescriptor:n.fileDescriptor,variableName:n.variableName,content:n.content,heredocQuoted:void 0,body:void 0};if(n.targetEnd>n.targetPos){let a=n.value==="<<"||n.value==="<<-"?jte(n.content??""):void 0,c=this.source.slice(n.targetPos,n.targetEnd);s.target=new tn(c,n.targetPos,n.targetEnd,this.source,a,this.depth)}else this.error("expected redirect target",n.targetPos);if(s.target&&(n.value==="<<"||n.value==="<<-"))this.tok.registerHereDocTarget(s);return e.push(s),e}commandAsBody(){let e=this.tok.peek(T.CommandStart).token;if(e===h.LBrace)return this.braceGroup();if(e===h.LParen)return this.subshell();let t=this.command(),n=this.tok.getPos();return t??{type:"CompoundList",pos:n,end:n,commands:[]}}readWord(e){return this.toWord(this.tok.next(e))}toWord(e){let t=e.raw?e.value:this.source.slice(e.pos,e.end);return new tn(t,e.pos,e.end,this.source,void 0,this.depth)}toWordFromPosEnd(e,t,n){let r=e.raw&&e.pos===t&&e.end===n?e.value:this.source.slice(t,n);return new tn(r,t,n,this.source,void 0,this.depth)}parseAssignment(e){let t=e.raw?e.value:this.source.slice(e.pos,e.end),n=e.pos,r=e.end,o={type:"Assignment",pos:n,end:r,text:t,name:void 0,value:void 0,append:void 0,index:void 0,indexParts:void 0,array:void 0},s=e.assignmentOperatorPos-n;if(s<=0)return o;let i=s,a=!1,c,u=s;while(u>=2&&t.charCodeAt(u-2)===92&&t.charCodeAt(u-1)===10)u-=2;if(t.charCodeAt(u-1)===43)a=!0,i=u-1;let l=t.indexOf("[");if(l>0&&l<i){let b=t.lastIndexOf("]",s);if(b>l)c=t.slice(l+1,b),i=l}let f=t.slice(0,i),d=f.includes("\\\n")?f.split("\\\n").join(""):f;if(o.name=d,a)o.append=!0;if(c!==void 0){o.index=c;let b=n+l+1,E=b+c.length;if(Da(this.source,b,E)){let w=new tn(c,b,E,this.source,Cy,this.depth);Object.defineProperty(o,"indexParts",{configurable:!0,enumerable:!0,get:()=>w.parts,set:(k)=>{w.parts=k}})}}let m=s+1,y=n+m;if(m<t.length&&t.charCodeAt(m)===40&&t.charCodeAt(t.length-1)===41){let b=this.parseArrayElements(y+1,r-1);o.array=b}else o.value=new tn(t.slice(m),y,r,this.source,void 0,this.depth);return o}parseArrayElements(e,t){let n=new es(this.source,e,t),r=[];while(n.peek(T.Normal).token!==h.EOF){if(n.peek(T.Normal).token===h.Newline){n.next(T.Normal);continue}let o=n.next(T.Normal);if(o.token===h.Word||o.token===h.Assignment){let s=o.raw?o.value:this.source.slice(o.pos,o.end);r.push(new tn(s,o.pos,o.end,this.source,void 0,this.depth))}}return r}makeCompoundList(e){let t=this.tok.getPos(),n=e.length>0?e[0].pos:t,r=e.length>0?e[e.length-1].end:t;return{type:"CompoundList",pos:n,end:r,commands:e}}}var Lte,Bte,Kn,Ri,yn,Hte,Wte,vo;var UI=v(()=>{DI();MI();xH();tn._resolveWord=hH;tn._resolveHeredocBody=gH;Lte={[h.DoubleSemi]:";;",[h.SemiAmp]:";&",[h.DoubleSemiAmp]:";;&"},Bte={">":">",">>":">>","<":"<","<<":"<<","<<-":"<<-","<<<":"<<<","<>":"<>","<&":"<&",">&":">&",">|":">|","&>":"&>","&>>":"&>>"};Kn=new Uint8Array(37);Kn[h.EOF]=1;Kn[h.RParen]=1;Kn[h.RBrace]=1;Kn[h.Then]=1;Kn[h.Else]=1;Kn[h.Elif]=1;Kn[h.Fi]=1;Kn[h.Do]=1;Kn[h.Done]=1;Kn[h.Esac]=1;Kn[h.DoubleSemi]=1;Kn[h.SemiAmp]=1;Kn[h.DoubleSemiAmp]=1;Ri=new Uint8Array(37);Ri[h.RParen]=1;Ri[h.RBrace]=1;Ri[h.DblRBracket]=1;Ri[h.Fi]=1;Ri[h.Done]=1;Ri[h.Esac]=1;Ri[h.ArithCmd]=1;yn=new Uint8Array(37);yn[h.Word]=1;yn[h.Assignment]=1;yn[h.Bang]=1;yn[h.LParen]=1;yn[h.LBrace]=1;yn[h.DblLBracket]=1;yn[h.If]=1;yn[h.For]=1;yn[h.While]=1;yn[h.Until]=1;yn[h.Case]=1;yn[h.Function]=1;yn[h.Select]=1;yn[h.ArithCmd]=1;yn[h.Coproc]=1;yn[h.Redirect]=1;Hte={"-a":1,"-b":1,"-c":1,"-d":1,"-e":1,"-f":1,"-g":1,"-h":1,"-k":1,"-p":1,"-r":1,"-s":1,"-t":1,"-u":1,"-v":1,"-w":1,"-x":1,"-z":1,"-n":1,"-o":1,"-N":1,"-S":1,"-L":1,"-G":1,"-O":1,"-R":1},Wte={"==":1,"!=":1,"=~":1,"=":1,"-eq":1,"-ne":1,"-lt":1,"-le":1,"-gt":1,"-ge":1,"-nt":1,"-ot":1,"-ef":1,"<":1,">":1};vo=[]});var tu=(e)=>({start:e.pos,end:e.end}),Ua=(e)=>{let t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)},uf=(e)=>{if(e.name===void 0||e.prefix.length>0||e.redirects.length>0||!_i(e.name)||e.suffix.some((t)=>!_i(t)))return null;return[e.name,...e.suffix].map((t)=>({source:t.text,value:t.value,kind:"literal",range:tu(t),quoted:(t.parts??[]).some((n)=>n.type==="SingleQuoted"||n.type==="DoubleQuoted"||n.type==="AnsiCQuoted"||n.type==="LocaleString")}))};var Ay=v(()=>{tf()});var La,bH,SH,HI=(e,t,n)=>{let r=t;while(r<e.length){let o=e[r]?.value;if(o===void 0)break;if(n.has(o))r+=2;else if(o.includes("=")&&n.has(o.slice(0,o.indexOf("="))))r+=1;else if(o==="--")return r+1;else if(o.startsWith("-")&&o!=="-")r+=1;else break}return r},Ty=(e)=>{let t=Object.hasOwn(SH,e.head)?SH[e.head]??new Set:new Set,n=HI(e.words,1,t);if(e.head==="env")while(/^[A-Za-z_][A-Za-z0-9_]*=/u.test(e.words[n]?.value??""))n+=1;return n},lf=(e,t)=>{for(let n=1;n<e.length-1;n+=1){let r=e[n]?.value;if(r!==void 0&&(r===`-${t}`||r.startsWith("-")&&!r.startsWith("--")&&r.slice(1).includes(t)))return n+1}return null},_y=(e,t,n=1)=>{for(let r=n;r<e.length;r+=1){let o=e[r]?.value;if(o!==void 0){if(t.has(o))return r+1<e.length?r+1:null;for(let s of t)if(o.startsWith(`${s}=`))return r}}return null},qte,zte=(e)=>e==="/"||e==="~"||e==="."||e===".."||e.startsWith("/")||e.startsWith("~/")||e.startsWith("./")||e.startsWith("../")||/^\$\{?HOME\}?(?:\/|$)/u.test(e),EH=(e)=>{if(e==="/")return 100;if(e==="~"||/^\$\{?HOME\}?(?:\/|$)/u.test(e))return 90;if(/^\/(?:etc|usr|bin|sbin|System|Library|var|boot|root|home)(?:\/|$)/u.test(e))return 80;if(e.startsWith("/Users/"))return 70;if(e.startsWith("/"))return 60;if(e.startsWith("../"))return 40;return 10},wH=(e,t,n)=>{let r=[];for(let o=1;o<t;o+=1){let s=e[o];if(s!==void 0&&n==="fd"&&qte.has(s.value))o+=1;else if(s?.value.startsWith("-")===!0){if(n==="find")break}else if(s!==void 0&&zte(s.value))r.push(s)}return r.sort((o,s)=>EH(s.value)-EH(o.value)),r[0]??{source:".",value:".",kind:"literal",range:e[0]?.range??{start:0,end:0},quoted:!1}},WI,kH,CH,vH,IH,jI;var Oy=v(()=>{La=new Set(["sh","bash","zsh","dash","ksh","ash"]),bH=new Set(["command","exec","env","time","nohup","setsid","nice","ionice","chronic","stdbuf","unbuffer","taskset","sudo","doas","xargs","watch"]),SH={env:new Set(["-u","--unset","-C","--chdir","-S","--split-string","--block-signal"]),time:new Set(["-f","--format","-o","--output"]),nice:new Set(["-n","--adjustment"]),ionice:new Set(["-c","--class","-n","--classdata","-p","--pid"]),stdbuf:new Set(["-i","--input","-o","--output","-e","--error"]),sudo:new Set(["-u","--user","-g","--group","-C","--close-from","-D","--chdir","-h","--host","-p","--prompt","-r","--role","-t","--type","-U","--other-user","-R","--chroot","-T","--command-timeout"]),doas:new Set(["-a","-C","-u"]),xargs:new Set(["-I","-i","-J","-n","--max-args","-P","--max-procs","-s","--max-chars","-L","--max-lines","-E","--eof","-d","--delimiter","-a","--arg-file","--replace"]),watch:new Set(["-n","--interval"])},qte=new Set(["-e","--extension","-t","--type","-E","--exclude","-d","--max-depth","--min-depth","--exact-depth","-c","--color","--changed-within","--changed-before","-S","--size","-o","--owner","-j","--threads","-g","--glob","--format","--max-results","--ignore-file","--search-path","--base-directory","--path-separator","--and"]),WI=new Set(["-x","-X","--exec","--exec-batch"]),kH=new Set(["{}","{/}","{//}","{.}","{/.}"]),CH=new Set(["-exec","-execdir","-ok","-okdir"]),vH=new Set(["{}"]),IH=new Set(["run","proxy","err","test","summary"]),jI={timeout:{valueFlags:new Set(["-s","--signal","-k","--kill-after"]),skipPositionals:1,shellFlag:!1},gtimeout:{valueFlags:new Set(["-s","--signal","-k","--kill-after"]),skipPositionals:1,shellFlag:!1},chroot:{valueFlags:new Set(["--userspec","--groups"]),skipPositionals:1,shellFlag:!1},flock:{valueFlags:new Set(["-w","--wait","--timeout","-E","--conflict-exit-code"]),skipPositionals:1,shellFlag:!0},su:{valueFlags:new Set,skipPositionals:0,shellFlag:!0}}});class qI{#t;#e;constructor(e,t){this.#e=e,this.#t=[...t].toSorted((n,r)=>r.command.length-n.command.length)}isCarrierCommand(e){let t=uf(e);return t!==null&&this.#n(t)!==null}inspect(e,t,n){let r=this.#n(e.words);if(r===null)return!1;this.#o(r.words,t,n);let o=Gte(r.words);if(o===null){if(r.words.some((u)=>u.value==="-Q"||u.value==="-V"))return!0;return this.#e.addDiagnostic("dynamic-shell-source","Tripwire cannot identify the SSH destination and remote command safely.",e.range),!0}let s=r.words.slice(o);if(s.length===0){let u=r.words.some((l)=>l.value==="-N"||l.value==="-G"||l.value==="-Q"||l.value==="-V"||l.value==="-W"||l.value.startsWith("-W"));if(!n.inspectedPipelineInput&&!u)this.#e.addDiagnostic("dynamic-shell-source","An interactive remote shell has no command source that Tripwire can inspect.",e.range);return!0}let i=s.find((u)=>u.kind!=="literal");if(i!==void 0)return this.#e.addDiagnostic("dynamic-shell-source","The remote shell command is computed at runtime.",i.range),!0;if(n.inspectedPipelineInput&&La.has(Ua(s[0]?.value??""))&&lf(s,"c")===null)return this.#e.emitSynthetic(s,e,t,{...n,inspectedPipelineInput:!0}),!0;let[a]=s,c=s.at(-1);if(a!==void 0&&c!==void 0){let u=s.map((l)=>l.value).join(" ");this.#e.inspectShellSource({source:u,value:u,kind:"literal",range:{start:a.range.start,end:c.range.end},quoted:!0},t,{...n,inspectedPipelineInput:!1})}return!0}#n(e){let[t]=e;if(t!==void 0&&Ua(t.value)==="ssh")return{kind:"ssh",words:e};for(let n of this.#t)if(n.command.every((r,o)=>e[o]?.value===r)&&n.command.length<=e.length){let[r]=e;if(r===void 0)return null;return{kind:n.equivalentTo,words:[{...r,source:n.equivalentTo,value:n.equivalentTo},...e.slice(n.command.length)]}}return null}#o(e,t,n){for(let r=1;r<e.length;r+=1){let o=Kte(e,r);if(r=o.nextIndex,o.opaqueConfig!==void 0)this.#e.addDiagnostic("dynamic-shell-source","An explicit SSH configuration file may contain executable commands that Tripwire has not inspected.",o.opaqueConfig.range);else if(o.source!==void 0)this.#e.inspectShellSource(o.source,t,{...n,inspectedPipelineInput:!1})}}}var Vte,Kte=(e,t)=>{let n=e[t];if(n===void 0)return{nextIndex:t,opaqueConfig:void 0,source:void 0};if(n.value==="-F"||n.value.startsWith("-F"))return{nextIndex:n.value==="-F"?t+1:t,opaqueConfig:n,source:void 0};let r=t,o;if(n.value==="-o")r+=1,o=e[r];else if(n.value.startsWith("-o"))o={...n,source:n.source.slice(2),value:n.value.slice(2)};let s=o===void 0?null:/^(?<key>[A-Za-z]+)(?:=|\s+)(?<source>[\s\S]+)$/u.exec(o.value),i=s?.groups?.key?.toLowerCase(),a=s?.groups?.source,c=o!==void 0&&a!==void 0&&a!=="none"&&i!==void 0&&["localcommand","proxycommand","remotecommand"].includes(i)?{...o,source:a,value:a}:void 0;return{nextIndex:r,opaqueConfig:void 0,source:c}},Gte=(e)=>{let t=1;while(t<e.length){let r=e[t];if(r?.kind!=="literal")return null;if(r.value==="--"){t+=1;break}if(Vte.has(r.value)){if(e[t+1]?.kind!=="literal")return null;t+=2}else if(r.value.startsWith("-")&&r.value!=="-")t+=1;else break}return e[t]?.kind==="literal"?t+1:null};var AH=v(()=>{Ay();Oy();Vte=new Set(["-B","-b","-c","-D","-E","-e","-F","-I","-i","-J","-L","-l","-m","-O","-o","-p","-Q","-R","-S","-W","-w"])});class zI{#t;#e;constructor(e,t){this.#e=e,this.#t=t}inspect(e,t,n){let r=new Set;return this.#n(e,t,n,r),this.#o(e,t,n,r),r}#n(e,t,n,r){for(let o=0;o<e.length-1;o+=1){let s=e[o],i=e[o+1];if(s?.type==="Command"&&i?.type==="Command"&&i.name!==void 0&&La.has(Ua(i.name.value))){for(let a of s.redirects)if((a.operator==="<<"||a.operator==="<<-")&&a.content!==void 0)this.#e.inspectShellSource({source:a.content,value:a.content,kind:"literal",range:tu(a),quoted:a.heredocQuoted===!0},t,n),r.add(o+1)}}}#o(e,t,n,r){for(let o=0;o<e.length-2;o+=1){let s=e[o],i=e[o+1],a=e[o+2];if(s?.type==="Command"&&i?.type==="Command"&&a?.type==="Command"&&this.#i(a)){let c=Jte(s,i),u=c===null?null:Qte(c);if(u!==null)this.#e.inspectShellSource({source:u,value:u,kind:"literal",range:tu(s),quoted:!0},t,n),r.add(o+2)}}}#i(e){let t=uf(e);if(t===null)return!1;if(La.has(Ua(t[0]?.value??"")))return lf(t,"c")===null;return this.#t.isCarrierCommand(e)}}var Jte=(e,t)=>{let n=uf(e),r=uf(t);if(n===null||r===null||Ua(r[0]?.value??"")!=="base64"||r.length!==2||!["-d","-D","--decode"].includes(r[1]?.value??""))return null;let o=Ua(n[0]?.value??""),s=n.slice(1).map((i)=>i.value);if(o==="printf"&&s.length===2){let[i,a]=s;return i==="%s"||i===String.raw`%s\n`?a??null:null}if(o==="echo"){let i=s.filter((a)=>a!=="-n");return i.length===1?i[0]??null:null}return null},Qte=(e)=>{if(e.length===0||e.length>1048576||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u.test(e))return null;let t=Buffer.from(e,"base64");if(t.toString("base64")!==e||t.includes(0))return null;try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{return null}};var TH=v(()=>{Ay();Oy()});class VI{#t;#e;#n;constructor(e,t){this.#e=e,this.#t=new qI(e,t),this.#n=new zI(e,this.#t)}inspectShellInput(e,t,n,r){if(!La.has(e.head))return!1;let o=r.inspectedPipelineInput;for(let[s,i]of t.entries())if((i.operator==="<<"||i.operator==="<<-")&&i.content!==void 0){let a={source:i.content,value:i.content,kind:"literal",range:tu(i),quoted:i.heredocQuoted===!0};this.#e.inspectShellSource(a,n,r),o=!0}else if(i.operator==="<<<")this.#e.inspectShellSource(e.redirects[s]?.target,n,r),o=!0;else if(i.operator==="<")this.#e.addDiagnostic("dynamic-shell-source","A shell wrapper reads program source from a file that Tripwire has not inspected.",tu(i));return o}inspectWrapper(e,t,n,r=!1){if(e.head==="eval"||this.#t.inspect(e,t,n)||this.#o(e,t,n,r)||this.#i(e,t,n))return;this.#f(e,t,n)}inspectPipelineInputs(e,t,n){return this.#n.inspect(e,t,n)}#o(e,t,n,r){if(!La.has(e.head))return!1;let o=lf(e.words,"c");if(o!==null)return this.#e.inspectShellSource(e.words[o],t,n),!0;if(!(r||e.tokens.includes("-n")||e.tokens.includes("--noexec")||e.tokens.includes("--help")||e.tokens.includes("--version")))this.#e.addDiagnostic("dynamic-shell-source","A shell wrapper has no inline program source that Tripwire can inspect.",e.range);return!0}#i(e,t,n){switch(e.head){case"trap":return this.#p(e,t,n),!0;case"script":{let r=_y(e.words,new Set(["-c","--command"]));if(r!==null)this.#e.inspectShellSource(e.words[r],t,n);return!0}case"watch":return this.#m(e,t,n),!0;case"xargs":return this.#d(e,t,n),!0;default:return!1}}#m(e,t,n){let r=Ty(e),o=e.words.slice(r);if(e.tokens.includes("-x")||e.tokens.includes("--exec")){this.#e.emitSynthetic(o,e,t,n);return}let[s]=o,i=o.at(-1),a=o.find((c)=>c.kind==="dynamic");if(a!==void 0){this.#e.addDiagnostic("dynamic-shell-source","watch receives command text that is computed at runtime.",a.range);return}if(s!==void 0&&i!==void 0){let c=o.map((u)=>u.value).join(" ");this.#e.inspectShellSource({source:c,value:c,kind:"literal",range:{start:s.range.start,end:i.range.end},quoted:!0},t,n)}}#f(e,t,n){if(bH.has(e.head)){let r=Ty(e);this.#e.emitSynthetic(e.words.slice(r),e,t,n)}else if(e.head==="fd"||e.head==="fdfind")this.#a(e,WI,kH,t,n);else if(e.head==="find"||e.head==="gfind")this.#a(e,CH,vH,t,n);else if(e.head==="rtk")this.#u(e,t,n);else{let r=Object.hasOwn(jI,e.head)?jI[e.head]:void 0;if(r!==void 0)this.#y(e,r,t,n)}}#p(e,t,n){let[,r,o]=e.words,s=r?.value==="--"?o:r;if(s===void 0||s.value===""||s.value==="-"||s.value==="-p"||s.value==="-l")return;this.#e.inspectShellSource(s,t,n)}#d(e,t,n){let r=Ty(e),o=e.words.slice(r),s=o[0]??{kind:"literal",quoted:!1,range:e.range,source:"echo",value:"echo"},i={kind:"dynamic",quoted:!1,range:e.range,source:"<xargs-input>",value:Zc};this.#e.emitSynthetic([s,...o.slice(1),i],e,t,n)}#a(e,t,n,r,o){for(let s=1;s<e.words.length;s+=1){let i=e.words[s];if(i!==void 0&&t.has(i.value)){let a=[],c=wH(e.words,s,t===WI?"fd":"find");for(let u=s+1;u<e.words.length;u+=1){let l=e.words[u];if(l===void 0||l.value===";"||l.value==="+")break;a.push(n.has(l.value)?c:l)}this.#e.emitSynthetic(a,e,r,o)}}}#u(e,t,n){let r=1;while(e.words[r]?.value.startsWith("-")===!0)r+=1;let o=e.words[r]?.value;if(o===void 0)return;if(IH.has(o)){let s=_y(e.words,new Set(["-c","--command"]),r+1);if(s!==null){this.#e.inspectShellSource(e.words[s],t,n);return}this.#e.emitSynthetic(e.words.slice(r+1),e,t,n);return}this.#e.emitSynthetic(e.words.slice(r),e,t,n)}#y(e,t,n,r){if(t.shellFlag){let s=_y(e.words,new Set(["-c","--command"]));if(s!==null){this.#e.inspectShellSource(e.words[s],n,r);return}}let o=HI(e.words,1,t.valueFlags);o+=t.skipPositionals,this.#e.emitSynthetic(e.words.slice(o),e,n,r)}}var _H=v(()=>{AH();TH();Ay();tf();Oy()});class PH{#t;#e=[];#n=[];#o=[];#i=[];#m=new WeakSet;#f=new Set;#p=new Set;#d=[];#a;#u;#y=1;#E=1;constructor(e,t){this.#t=e,this.#u=t,this.#a=new VI({addDiagnostic:(n,r,o)=>{this.#c(n,r,o)},emitSynthetic:(n,r,o,s)=>{this.#v(n,r,o,s)},inspectShellSource:(n,r,o)=>{this.#N(n,r,o)}},t.executionCarrierAliases??[])}analyze(e){let t=TI(),n=(r,o)=>{t.bindings.set(r,{source:o,value:o,kind:"literal",range:{start:0,end:0},quoted:!0,variable:r})};if(this.#u.cwd!==void 0)n("PWD",this.#u.cwd);for(let[r,o]of(this.#u.positionalArguments??[]).entries())n((r+1).toString(),o);return this.#g(e,t,{inspectedPipelineInput:!1,source:this.#t,pipeline:void 0}),{source:this.#t,invocations:this.#e,redirects:this.#n,diagnostics:this.#o,hasBypass:this.#U()}}#c(e,t,n){this.#o.push({kind:e,message:t,range:n})}#g(e,t,n){if(this.#m.has(e))return;this.#m.add(e);let r=e.source??n.source;for(let o of e.errors??[])this.#c("parse-error",o.message,{start:o.pos,end:o.pos});this.#b(e.commands,t,{...n,source:r})}#b(e,t,n){for(let r of e)this.#w(r,t,n)}#w(e,t,n){if(this.#S(e.redirects,t,n),this.#s(e.command,t,n),e.background===!0)t.backgroundPidAvailable=!0}#s(e,t,n){if(this.#I(e,t,n)||this.#A(e,t,n)||this.#T(e,t,n))return;this.#c("parse-error",`Unknown Bash AST node: ${e.type}`,ts(e))}#I(e,t,n){if(e.type==="Statement")return this.#w(e,t,n),!0;if(e.type==="Command")return this.#_(e,t,n),!0;if(e.type==="CompoundList")return this.#b(e.commands,t,n),!0;if(e.type==="Pipeline"){let r=this.#E;this.#E+=1;let o=this.#a.inspectPipelineInputs(e.commands,t,n);for(let[s,i]of e.commands.entries())this.#s(i,ln(t),{...n,inspectedPipelineInput:o.has(s),pipeline:{id:r,index:s}});return!0}if(e.type==="AndOr"){let r=ln(t);for(let o of e.commands)this.#s(o,r,n);return GI(t,KI([t,r])),!0}return!1}#A(e,t,n){if(e.type==="If"){let r=ln(t);this.#s(e.clause,r,n);let o=ln(r);this.#s(e.then,o,n);let s=ln(r);if(e.else!==void 0)this.#s(e.else,s,n);return GI(t,KI([o,s])),!0}if(e.type==="For"||e.type==="Select"){let r=this.#r(e.name,t,n),o=e.wordlist.map((s)=>this.#r(s,t,n));if(r.kind==="literal"&&/^[A-Za-z_][A-Za-z0-9_]*$/u.test(r.value)&&o.length>0&&o.length<=32&&o.every((s)=>s.kind==="literal"))for(let s of o){let i=ln(t);i.temps.delete(r.value),i.bindings.set(r.value,s),this.#s(e.body,i,n)}else{let s=ln(t);s.temps.delete(r.value),s.bindings.delete(r.value),this.#s(e.body,s,n)}return!0}if(e.type==="ArithmeticFor")return this.#l(e.initialize,t,n),this.#l(e.test,t,n),this.#l(e.update,t,n),this.#s(e.body,ln(t),n),!0;if(e.type==="While"){let r=ln(t);return this.#s(e.clause,r,n),this.#s(e.body,r,n),!0}if(e.type==="Function"){let r=this.#r(e.name,t,n);if(r.kind!=="literal"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(r.value))this.#c("function","The function name is not static.",ts(e));else t.functions.set(r.value,e);return!0}return!1}#T(e,t,n){if(e.type==="Subshell")return this.#s(e.body,ln(t),n),!0;if(e.type==="BraceGroup")return this.#s(e.body,t,n),!0;if(e.type==="Case"){this.#r(e.word,t,n);let r=[ln(t)];for(let o of e.items){for(let i of o.pattern)this.#r(i,t,n);let s=ln(t);this.#s(o.body,s,n),r.push(s)}return GI(t,KI(r)),!0}if(e.type==="Coproc"){if(e.name!==void 0)this.#r(e.name,t,n);return this.#S(e.redirects,t,n),this.#s(e.body,ln(t),n),!0}if(e.type==="TestCommand")return this.#x(e.expression,t,n),!0;if(e.type==="ArithmeticCommand")return this.#l(e.expression,t,n),!0;return!1}#_(e,t,n){let r=e.prefix.flatMap((u)=>{let l=this.#O(u,t,n);return l===null?[]:[l]});if(e.name===void 0)for(let u of r)OH(u,t);let o=this.#S(e.redirects,t,n);if(e.name===void 0)return;let s=this.#r(e.name,t,n),i=e.suffix.flatMap((u)=>this.#k(u,t,n));if(s.kind==="literal"&&t.functions.has(s.value)){this.#R(s.value,i,r,t,n);return}if(s.kind==="literal"&&t.aliases.has(s.value)){this.#F(s.value,i,t,n,ts(e));return}let a=this.#C([s,...i],o,ts(e),n,!1);if(a===null)return;if(a.head==="alias"){this.#M(a,t);return}if(a.head==="unalias"){this.#D(a,t);return}let c=this.#a.inspectShellInput(a,e.redirects,t,n);this.#a.inspectWrapper(a,t,n,c),this.#$(a,t)}#O(e,t,n){for(let i of e.indexParts??[])this.#h(i,t,n);for(let i of e.array??[])this.#r(i,t,n);let r=e.value===void 0?void 0:this.#r(e.value,t,n);if(e.name===void 0)return null;let o=e.append!==!0&&e.index===void 0&&e.array===void 0&&e.value!==void 0&&eH(e.value,t);return{binding:Xte(e,r,t)?r:void 0,name:e.name,trustedTemp:o}}#k(e,t,n){let r=this.#r(e,t,n);if(r.kind!=="literal"||r.quoted||!/[*?[]/u.test(r.value))return[r];try{let o=[...new Bun.Glob(r.value).scanSync({onlyFiles:!1,dot:!0})];if(o.length===0)return[r];let s=[];for(let i of o)s.push({source:r.source,value:i,kind:r.kind,range:r.range,quoted:r.quoted});return s}catch{return[r]}}#r(e,t,n){for(let a of e.parts??[])this.#h(a,t,n);let r=rH(e,t);if(r!==null)return r;let o=RI(e,t);if(o!==null)return o;let s=PI(e,t);if(s!==null)return s;if(_i(e))return{source:e.text,value:e.value,kind:"literal",range:ts(e),quoted:(e.parts??[]).some((a)=>_I(a))};let i=OI(e,t);if(i!==null)return{source:e.text,value:i,kind:"literal",range:ts(e),quoted:!0};return{source:e.text,value:e.value,kind:"dynamic",range:ts(e),quoted:(e.parts??[]).some((a)=>_I(a))}}#h(e,t,n){switch(e.type){case"Literal":case"SingleQuoted":case"AnsiCQuoted":case"SimpleExpansion":return;case"DoubleQuoted":case"LocaleString":{for(let r of e.parts)this.#h(r,t,n);return}case"ParameterExpansion":{this.#P(e,t,n);return}case"CommandExpansion":case"ProcessSubstitution":{if(e.script!==void 0)this.#g(e.script,ln(t),n);return}case"ArithmeticExpansion":{this.#l(e.expression,t,n);return}case"ExtendedGlob":case"BraceExpansion":{for(let r of e.parts??[])this.#h(r,t,n);break}default:break}}#P(e,t,n){for(let r of e.indexParts??[])this.#h(r,t,n);if(e.operand!==void 0)this.#r(e.operand,t,n);if(e.slice!==void 0){if(this.#r(e.slice.offset,t,n),e.slice.length!==void 0)this.#r(e.slice.length,t,n)}if(e.replace!==void 0)this.#r(e.replace.pattern,t,n),this.#r(e.replace.replacement,t,n)}#l(e,t,n){if(e===void 0)return;switch(e.type){case"ArithmeticBinary":{this.#l(e.left,t,n),this.#l(e.right,t,n);return}case"ArithmeticUnary":{this.#l(e.operand,t,n);return}case"ArithmeticTernary":{this.#l(e.test,t,n),this.#l(e.consequent,t,n),this.#l(e.alternate,t,n);return}case"ArithmeticGroup":{this.#l(e.expression,t,n);return}case"ArithmeticWord":{for(let r of e.parts??[])this.#h(r,t,n);return}case"ArithmeticCommandExpansion":{if(e.script!==void 0)this.#g(e.script,ln(t),n);break}default:break}}#x(e,t,n){switch(e.type){case"TestUnary":{this.#r(e.operand,t,n);return}case"TestBinary":{this.#r(e.left,t,n),this.#r(e.right,t,n);return}case"TestLogical":{this.#x(e.left,t,n),this.#x(e.right,t,n);return}case"TestNot":{this.#x(e.operand,t,n);return}case"TestGroup":{this.#x(e.expression,t,n);break}default:break}}#S(e,t,n){let r=[];for(let o of e){if(o.body!==void 0)this.#i.push(ts(o.body)),this.#r(o.body,t,n);else if(o.content!==void 0){let c=n.source.indexOf(o.content,o.end);if(c!==-1)this.#i.push({start:c,end:c+o.content.length})}let s=o.target===void 0?{source:"",value:Zc,kind:"dynamic",range:ts(o),quoted:!1}:this.#r(o.target,t,n),i;if(o.operator==="<<-")i="<<";else if(o.operator===">|")i=">";else i=o.operator;let a={op:i,target:s,range:ts(o)};r.push(a),this.#n.push(a)}return r}#C(e,t,n,r,o){let[s]=e;if(s===void 0)return null;if(s.kind!=="literal")return this.#c("dynamic-executable","The executable name is computed at runtime.",s.range),null;let i=e.map((l)=>l.value),a=i.slice(1).filter((l)=>l.startsWith("-")&&l!=="-"),c=i.slice(1).filter((l)=>!l.startsWith("-")||l==="-"),u={id:this.#y,head:Zte(s.value),words:e,tokens:i,args:c,flags:a,redirects:t,raw:o?e.map((l)=>l.source).join(" "):r.source.slice(n.start,n.end),range:n,pipeline:r.pipeline,synthetic:o};if(this.#y+=1,this.#e.push(u),u.head==="eval")this.#c("eval","`eval` can turn computed data into shell syntax.",n);return u}#R(e,t,n,r,o){let s=r.functions.get(e);if(s===void 0)return;if(this.#p.has(e)){this.#c("function",`Recursive function call: ${e}`,ts(s));return}this.#p.add(e);let i=ln(r),a=new Set(n.map((u)=>u.name));for(let u of n)OH(u,i);for(let u of i.bindings.keys())if(/^[0-9]+$/u.test(u))i.bindings.delete(u);for(let[u,l]of t.entries())i.bindings.set(String(u+1),l);let c={localNames:new Set};this.#d.push(c);try{this.#S(s.redirects,i,o),this.#s(s.body,i,o);let u=new Set([...a,...c.localNames]);for(let l of i.bindings.keys())if(/^[0-9]+$/u.test(l))u.add(l);Yte(r,i,u)}finally{this.#d.pop(),this.#p.delete(e)}}#F(e,t,n,r,o){let s=n.aliases.get(e);if(s===void 0)return;if(this.#f.has(e)){this.#c("alias",`Recursive alias expansion: ${e}`,o);return}this.#f.add(e);try{let i=cf(s),[a]=i.commands,c=a?.command;if((i.errors?.length??0)>0||i.commands.length!==1||a?.background===!0||a?.redirects.length!==0||c?.type!=="Command"||c.name===void 0||c.prefix.length>0||c.redirects.length>0){this.#g(i,ln(n),{...r,source:s,pipeline:void 0}),this.#c("alias",`Alias ${e} has compound expansion whose call arguments cannot be bound safely.`,o);return}let u={...r,source:s},l=[this.#r(c.name,n,u),...c.suffix.flatMap((d)=>this.#k(d,n,u)),...t],f={id:0,head:e,words:[],tokens:[],args:[],flags:[],redirects:[],raw:e,range:o,pipeline:r.pipeline,synthetic:!0};this.#v(l,f,n,r)}finally{this.#f.delete(e)}}#M(e,t){for(let n of e.words.slice(1))if(n.kind==="literal"){let r=n.value.indexOf("=");if(r!==-1){let o=n.value.slice(0,r);if(/^[A-Za-z_][A-Za-z0-9_]*$/u.test(o))t.aliases.set(o,n.value.slice(r+1));else this.#c("alias",`Invalid alias name: ${o}`,n.range)}}else this.#c("alias","An alias definition is computed at runtime.",n.range)}#D(e,t){if(e.tokens.includes("-a")){t.aliases.clear();return}for(let n of e.words.slice(1))if(n.kind==="literal")t.aliases.delete(n.value),this.#f.delete(n.value)}#v(e,t,n,r){let o=this.#C(e,[],t.range,{...r,pipeline:t.pipeline},!0);if(o!==null)this.#a.inspectWrapper(o,n,r,r.inspectedPipelineInput)}#N(e,t,n){if(e?.kind!=="literal"){this.#c("dynamic-shell-source","A shell wrapper receives source that is computed at runtime.",e?.range??{start:0,end:0});return}try{this.#g(cf(e.value),ln(t),{...n,inspectedPipelineInput:!1,source:e.value,pipeline:void 0})}catch(r){this.#c("parse-error",r instanceof Error?r.message:"The nested shell source could not be parsed.",e.range)}}#$(e,t){if(e.head==="export"&&e.flags.some((r)=>r==="-f"||/^-[^-]*f/u.test(r)))this.#c("function","Exported functions can execute in a nested shell outside the local call binding.",e.range);if(e.head==="unset"){for(let r of e.words.slice(1))if(/^[A-Za-z_][A-Za-z0-9_]*$/u.test(r.value))t.temps.delete(r.value),t.bindings.delete(r.value);return}if(!["export","readonly","declare","typeset","local"].includes(e.head))return;let n=this.#d.at(-1);for(let r of e.words.slice(1)){let o=/^(?<name>[A-Za-z_][A-Za-z0-9_]*)/u.exec(r.source)?.groups?.name;if(o!==void 0){if(e.head==="local")n?.localNames.add(o);t.temps.delete(o),t.bindings.delete(o)}}}#U(){let e=this.#t.split("");for(let t of this.#i)for(let n=t.start;n<t.end&&n<e.length;n+=1)if(e[n]!==`
|
|
43
|
+
`&&e[n]!=="\r")e[n]=" ";return/(?<prefix>^|\s)#\s*tripwire-allow:[ \t]*\S[^\r\n]*/u.test(e.join(""))}}var ts=(e)=>({start:e.pos,end:e.end}),Zte=(e)=>{let t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)},Py=(e)=>{let[t,...n]=e,r=new Map;if(t===void 0)return r;for(let[o,s]of t)if(n.every((i)=>i.get(o)===s))r.set(o,s);return r},KI=(e)=>{let[t,...n]=e;if(t===void 0)return TI();return{aliases:Py([t.aliases,...n.map((r)=>r.aliases)]),backgroundPidAvailable:[t,...n].every((r)=>r.backgroundPidAvailable),bindings:Py([t.bindings,...n.map((r)=>r.bindings)]),functions:Py([t.functions,...n.map((r)=>r.functions)]),temps:Py([t.temps,...n.map((r)=>r.temps)])}},GI=(e,t)=>{e.backgroundPidAvailable=t.backgroundPidAvailable,e.aliases.clear();for(let[n,r]of t.aliases)e.aliases.set(n,r);e.bindings.clear();for(let[n,r]of t.bindings)e.bindings.set(n,r);e.functions.clear();for(let[n,r]of t.functions)e.functions.set(n,r);e.temps.clear();for(let[n,r]of t.temps)e.temps.set(n,r)},Ry=(e,t,n)=>{for(let r of e.keys())if(!n.has(r)&&!t.has(r))e.delete(r);for(let[r,o]of t)if(!n.has(r))e.set(r,o)},Yte=(e,t,n)=>{Ry(e.aliases,t.aliases,new Set),Ry(e.functions,t.functions,new Set),Ry(e.bindings,t.bindings,n),Ry(e.temps,t.temps,n),e.backgroundPidAvailable=t.backgroundPidAvailable},OH=(e,t)=>{if(t.temps.delete(e.name),t.bindings.delete(e.name),e.trustedTemp)t.temps.set(e.name,{variable:e.name});else if(e.binding!==void 0)t.bindings.set(e.name,e.binding)},Xte=(e,t,n)=>{if(e.append===!0||e.index!==void 0||e.array!==void 0||e.value===void 0)return!1;if(t?.kind==="literal")return _i(e.value)||OI(e.value,n)!==null||PI(e.value,n)!==null;return t?.kind==="background-pid"&&RI(e.value,n)!==null},gm=(e,t={})=>{try{return new PH(e,t).analyze(cf(e))}catch(n){return{source:e,invocations:[],redirects:[],diagnostics:[{kind:"parse-error",message:n instanceof Error?n.message:"The Bash parser failed.",range:{start:0,end:e.length}}],hasBypass:!1}}};var RH=v(()=>{UI();_H();tf()});var ene,FH,tne=(e)=>e.startsWith("./")?e.slice(2):e,JI=(e,t=[],n=[])=>{if(e===""||e===Zc)return!1;let r=tne(e);if(r===".."||r.startsWith("../")||r.includes("/../"))return!1;for(let o of[...FH,...n])if(r===o||r.startsWith(`${o}/`))return!0;for(let o of[...ene,...t])if(r===o||r.startsWith(`${o}/`))return!0;return!1},MH=(e=[],t=[])=>{let n={"build outputs":["dist","build","_build","out","target"],"js framework outputs":[".next",".nuxt",".svelte-kit",".output",".astro",".angular",".vite",".parcel-cache",".turbo",".vercel",".netlify",".fly",".wrangler",".serverless"],"tests / coverage":["coverage",".nyc_output"],caches:[".cache",".ruff_cache",".mypy_cache",".pytest_cache",".ty_cache",".tox"],"language / package":["__pycache__",".venv","venv","node_modules",".gradle","DerivedData",".bundle",".cargo-target"],"tmp / state":["tmp",".tmp",".state",...FH],iac:[".terraform"],"bundler dev":[".yarn/cache",".yarn/install-state.gz",".pnpm-store",".bun"]};if(e.length>0)n["custom relative"]=e;if(t.length>0)n["custom absolute"]=t;return Object.entries(n).map(([r,o])=>` ${r}: ${o.join(", ")}`).join(`
|
|
44
|
+
`)};var Fy=v(()=>{tf();RH();tf();ene=["dist","build","_build","out","target",".next",".nuxt",".svelte-kit",".output",".astro",".angular",".vite",".parcel-cache",".turbo",".vercel",".netlify",".fly",".wrangler",".serverless","coverage",".nyc_output",".cache",".ruff_cache",".mypy_cache",".pytest_cache",".ty_cache",".tox","__pycache__",".venv","venv","node_modules",".gradle","DerivedData",".bundle",".cargo-target","tmp",".tmp",".state",".terraform",".yarn/cache",".yarn/install-state.gz",".pnpm-store",".bun"],FH=["/tmp","/var/tmp","/var/folders","/private/tmp","/private/var/tmp","/private/var/folders"]});var nne,rne,DH;var NH=v(()=>{vs();nne=O.Literal("ssh"),rne=O.Struct({command:O.Array(O.NonEmptyString).check(O.isMinLength(1),O.isMaxLength(16)),equivalentTo:nne}),DH=O.Struct({executionCarrierAliases:O.optional(O.Array(rne).check(O.isMaxLength(64)))})});var $H,Y=(e)=>({kind:"allow",rule:e,message:""}),Ts=(e,t)=>({kind:"warn",rule:e,message:t}),Lt=(e,t)=>({kind:"ask",rule:e,message:t}),X=(e,t)=>({kind:"deny",rule:e,message:t}),ff=(e)=>{let t=Y("none");for(let n of e)if($H[n.kind]>$H[t.kind])t=n;return t};var Gn=v(()=>{$H={allow:0,warn:1,ask:2,deny:3}});var Pn,QI,one=(e)=>Object.hasOwn(QI.fields,e),UH=(e,t)=>{let n=one(e.rule)?t[e.rule]:void 0;if(n===void 0||n===e.kind)return e;if(n==="allow")return Y(e.rule);if(n==="warn")return Ts(e.rule,e.message);if(n==="ask")return Lt(e.rule,e.message);return X(e.rule,e.message)};var ZI=v(()=>{vs();Gn();Pn=O.Literals(["allow","warn","ask","deny"]),QI=O.Struct({"brew-mutation":O.optional(Pn),"chmod-777-recursive":O.optional(Pn),"defaults-write":O.optional(Pn),"dscl-mutate":O.optional(Pn),"launchctl-mutation":O.optional(Pn),"mas-mutation":O.optional(Pn),"no-gpg-sign":O.optional(Pn),"no-verify":O.optional(Pn),osascript:O.optional(Pn),"pmset-write":O.optional(Pn),"rsync-delete":O.optional(Pn),"scutil-set":O.optional(Pn),"security-keychain-add-write":O.optional(Pn),"softwareupdate-install":O.optional(Pn),sudo:O.optional(Pn),systemsetup:O.optional(Pn),topgrade:O.optional(Pn)})});import{readFileSync as sne}from"fs";import{homedir as ine}from"os";var LH,ane,cne,une,lne,fne,dne,YI,BH,HH,pne=(e)=>e instanceof Error&&("code"in e)&&e.code==="ENOENT",mne=(e)=>B.try({try:()=>sne(e,"utf8"),catch:(t)=>new BH({cause:t})}).pipe(B.catchTag("ConfigReadError",(t)=>pne(t.cause)?B.succeed(null):B.fail(t))),hne=(e)=>B.try({try:()=>JSON.parse(e),catch:(t)=>new HH({cause:t})}),gne=(e)=>O.decodeUnknownEffect(dne)(e,{onExcessProperty:"error"}),My=()=>({git:{protectedBranches:[],enforceConventionalCommits:!1},safePaths:{},toolPolicies:[],blockedCommands:[],allowedCommands:[],ruleActions:{},secretScanner:{executable:"betterleaks",timeoutMs:5000},shell:{executionCarrierAliases:[]}}),Dy=(e)=>{let t=My();return{git:{protectedBranches:e.git?.protectedBranches??t.git.protectedBranches,enforceConventionalCommits:e.git?.enforceConventionalCommits??t.git.enforceConventionalCommits},safePaths:{...t.safePaths,...e.safePaths},toolPolicies:e.toolPolicies??t.toolPolicies,blockedCommands:e.blockedCommands??t.blockedCommands,allowedCommands:e.allowedCommands??t.allowedCommands,ruleActions:{...t.ruleActions,...e.ruleActions},secretScanner:e.secretScanner??t.secretScanner,shell:{executionCarrierAliases:e.shell?.executionCarrierAliases??t.shell.executionCarrierAliases}}},Ny=(e=YI)=>B.gen(function*(){let n=yield*mne(e);if(n===null)return{ok:!0,config:My()};let r=yield*hne(n),o=yield*gne(r);return{ok:!0,config:Dy(o)}}).pipe(B.timeout(1000),B.catchCause((t)=>{let n={ok:!1,error:Et.pretty(t)};return B.succeed(n)}));var XI=v(()=>{vs();NH();ZI();LH=O.Struct({pattern:O.String,message:O.String,action:O.optional(O.Union([O.Literal("deny"),O.Literal("ask")])),requiresFlags:O.optional(O.Array(O.String)),forbidsFlagValues:O.optional(O.Array(O.Struct({flag:O.String,values:O.Array(O.String)})))}),ane=O.Struct({protectedBranches:O.optional(O.Array(O.String)),enforceConventionalCommits:O.optional(O.Boolean)}),cne=O.Struct({relative:O.optional(O.Array(O.String)),absolute:O.optional(O.Array(O.String))}),une=O.Struct({argumentsIncludeAll:O.optional(O.Array(O.String)),argumentsStartWith:O.optional(O.Array(O.String)),shortFlagsIncludeAll:O.optional(O.Array(O.String))}),lne=O.Struct({rule:O.String,executables:O.Array(O.String),action:O.Union([O.Literal("deny"),O.Literal("warn")]),message:O.String,match:O.optional(une)}),fne=O.Struct({executable:O.String,timeoutMs:O.Finite.check(O.isGreaterThan(0))}),dne=O.Struct({git:O.optional(ane),safePaths:O.optional(cne),toolPolicies:O.optional(O.Array(lne)),blockedCommands:O.optional(O.Array(LH)),allowedCommands:O.optional(O.Array(LH)),ruleActions:O.optional(QI),secretScanner:O.optional(fne),shell:O.optional(DH)}),YI=`${ine()}/.config/tripwire/config.json`;BH=class BH extends xr.TaggedError("ConfigReadError"){};HH=class HH extends xr.TaggedError("ConfigParseError"){}});var xne,zH,n0,r0=(e)=>({kind:"cursor",eventName:e,post:n0.has(e)}),yne=(e)=>zH.has(e)||n0.has(e),nu=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),Zt=(e,...t)=>{for(let n of t){let r=e[n];if(typeof r==="string")return r}return},o0=(e,...t)=>{for(let n of t)if(n in e)return e[n];return},t0=(e,t,...n)=>{let r=Zt(e,...n);if(r!==void 0)return r;if(typeof t==="string"&&n.includes("command"))return t;return nu(t)?Zt(t,...n):void 0},WH=(e,t)=>{if(e===void 0)throw Error(`Cursor hook payload missing ${t}`);return e},Sne=(e)=>{let t=e.toLowerCase();if(t==="bash"||t==="exec"||t==="shell"||t==="run_command")return"Bash";if(t==="read"||t==="read_file")return"Read";if(t==="write"||t==="write_file")return"Write";if(t==="edit"||t==="edit_file"||t==="multiedit"||t==="apply_patch")return"Edit";return e},Ene=(e)=>e==="Read"||e==="Write"||e==="Edit",bne=(e,t)=>{let n;if(typeof e==="string")n=e;else if(nu(e))n=Zt(e,"command","cmd");if(t&&n===void 0)throw Error("Cursor hook payload missing command");if(typeof e==="string")return{command:e};if(!nu(e)||n===void 0)return e;return{...e,command:n}},wne=(e,t,n)=>{let r=Zt(t,"file_path","filePath","path");if(n&&r===void 0)throw Error(`Cursor ${e} hook payload missing file path`);if(e==="Read")return{...t,file_path:r??""};if(e==="Write"){let o=Zt(t,"content","fileText","text");if(n&&o===void 0)throw Error("Cursor Write hook payload missing content");return{...t,file_path:r??"",content:o??""}}if(e==="Edit"){let o=Zt(t,"old_string","oldString"),s=Zt(t,"new_string","newString");if(n&&(o===void 0||s===void 0))throw Error("Cursor Edit hook payload missing oldString or newString");return{...t,file_path:r??"",old_string:o??"",new_string:s??""}}return t},e0=(e,t,n=!0)=>{if(e==="Bash")return bne(t,n);if(!Ene(e))return t;if(!nu(t)){if(n)throw Error(`Cursor ${e} hook payload is missing tool input`);return t}return wne(e,t,n)},jH=(e,t)=>{if(typeof t!=="string")return t;if(e==="Bash")return{stdout:t,stderr:""};if(e==="Read")return{content:t};return{content:t}},kne=(e,t)=>{if(e==="beforeShellExecution"||e==="afterShellExecution")return"Bash";if(e==="beforeReadFile"||e==="beforeTabFileRead"||e==="afterFileEdit"||e==="afterTabFileEdit")return e.startsWith("before")?"Read":"Edit";let n=Zt(t,"tool_name","toolName");if(n!==void 0)return Sne(n);let r=o0(t,"tool_input","toolInput");if(Zt(t,"command","cmd")!==void 0||typeof r==="string"||nu(r)&&Zt(r,"command","cmd")!==void 0)return"Bash";if(Zt(t,"file_path","filePath","path")!==void 0||nu(r)&&Zt(r,"file_path","filePath","path")!==void 0)return"Read";return""},Cne=(e,t)=>{if(e==="Bash")return{command:t0(t,void 0,"command","cmd")};let n={file_path:Zt(t,"file_path","filePath","path")};if(e==="Write")return{...n,content:Zt(t,"content","fileText","text")};if(e==="Edit")return{...n,old_string:Zt(t,"old_string","oldString"),new_string:Zt(t,"new_string","newString")};return n},vne=(e,t,n,r)=>{let o=O.decodeUnknownResult(xne)(n);if(Yt.isFailure(o))throw Error("Cursor sent an invalid tool event");let s=o.success,i=o0(s,"tool_input","toolInput"),a=!r;if(e==="beforeShellExecution"||e==="afterShellExecution"){let c=t0(s,i,"command","cmd");return{command:a?WH(c,"command"):c??""}}if(e==="beforeReadFile"||e==="beforeTabFileRead"||e==="afterFileEdit"||e==="afterTabFileEdit"){let c=t0(s,i,"file_path","filePath","path");return e0(t,{file_path:a?WH(c,"file path"):c??"",...Array.isArray(s.edits)&&{edits:s.edits}},a)}if(i===void 0&&["Bash","Read","Write","Edit"].includes(t))return e0(t,Cne(t,s),a);return e0(t,i,a)},Ine=(e,t,n)=>{if(e==="afterShellExecution")return jH(t,Zt(n,"output")??"");let r=o0(n,"tool_response","toolResponse","tool_output","toolOutput","result","result_json");return jH(t,r)},qH=(e,t,n)=>{let r=kne(t,e),o=vne(t,r,e,n),s=n?Ine(t,r,e):void 0,i=Zt(e,"cwd"),a=Zt(e,"conversation_id","session_id"),c=Zt(e,"tool_use_id");return{event:{hook_event_name:n?"PostToolUse":"PreToolUse",...r.length>0&&{tool_name:r},...o!==void 0&&{tool_input:o},...s!==void 0&&{tool_response:s},...i!==void 0&&{cwd:i},...a!==void 0&&{session_id:a},...c!==void 0&&{tool_use_id:c}},host:r0(t)}},VH=(e,t)=>{if(t!==void 0&&!yne(t))throw Error(`Unknown Cursor hook event "${t}"`);if(!nu(e)){if(t!==void 0)throw Error(`Cursor ${t} hook payload must be a JSON object`);return{event:e,host:{kind:"native"}}}let n=t??Zt(e,"hook_event_name");if(n!==void 0&&zH.has(n))return qH(e,n,!1);if(n!==void 0&&n0.has(n))return qH(e,n,!0);return{event:e,host:{kind:"native"}}};var KH=v(()=>{vs();xne=O.Record(O.String,O.Unknown),zH=new Set(["preToolUse","beforeShellExecution","beforeMCPExecution","beforeReadFile","beforeTabFileRead"]),n0=new Set(["postToolUse","postToolUseFailure","afterShellExecution","afterMCPExecution","afterFileEdit","afterTabFileEdit"])});var s0,df=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),GH=(e)=>df(e)&&typeof e.command==="string",JH=(e)=>df(e)&&typeof e.file_path==="string"&&typeof e.old_string==="string"&&typeof e.new_string==="string",QH=(e)=>df(e)&&typeof e.file_path==="string"&&typeof e.content==="string",ZH=(e)=>df(e)&&typeof e.file_path==="string",YH=(e,t)=>{if(!df(t))return"";if(e==="Bash"){let n=typeof t.stdout==="string"?t.stdout:"",r=typeof t.stderr==="string"?t.stderr:"";return[n,r].filter((o)=>o.length>0).join(`
|
|
45
|
+
`)}if(e==="Read"){if(typeof t.content==="string")return t.content;let{file:n}=t;return df(n)&&typeof n.content==="string"?n.content:""}return typeof t.content==="string"?t.content:""};var i0=v(()=>{vs();s0=O.Struct({hook_event_name:O.String,tool_name:O.optional(O.String),tool_input:O.optional(O.Unknown),tool_response:O.optional(O.Unknown),cwd:O.optional(O.String),session_id:O.optional(O.String),turn_id:O.optional(O.String),tool_use_id:O.optional(O.String)})});import{appendFileSync as Ane,mkdirSync as Tne}from"fs";import{homedir as _ne}from"os";import One from"path";var XH,_s=(e,t)=>{let n=new Date().toISOString(),r=t instanceof Error?t.stack??t.message:String(t);try{Ane(XH,`[${n}] [${e}] ${r}
|
|
46
|
+
`)}catch{}};var eW=v(()=>{XH=`${_ne()}/.claude/tripwire.log`;try{Tne(One.dirname(XH),{recursive:!0})}catch{}});var Pne,pf=(e,t)=>{if(!e.hasBypass||t.kind==="allow"||Pne.has(t.rule))return t;return Y(t.rule)};var a0=v(()=>{Gn();Pne=new Set(["unsupported-shell-structure","source-script","rm-rf-root","rm-rf-home","fork-bomb","dd-raw-device","mkfs","kill-all","diskutil-destructive","tmutil-destructive","shutdown","csrutil","nvram","kextload","spctl-disable","xattr-quarantine-bypass","topgrade","softwareupdate-install","systemsetup","scutil-set","security-keychain-destructive","no-verify","no-gpg-sign","curl-pipe-shell","gh-api-mutation","gh-destructive","flyctl-destroy","gcloud-delete","git-dynamic-subcommand","git-dynamic-mutation","git-restore-discard","git-checkout-force","git-checkout-discard","git-checkout-discard-all","git-switch-force","git-reset-hard","git-force-push","git-filter","git-update-ref","git-reflog-expire","git-symbolic-ref-write"])});var Rne=(e)=>e.tokens.slice(1).join(" "),tW=(e,...t)=>{let n=new Set(e.flags);return t.some((r)=>n.has(r))},Fne,Mne,Dne=(e)=>{if(e.head==="dd")return e.words.slice(1).some((n)=>n.kind==="dynamic"&&!n.source.startsWith("if="));if(e.head==="rsync"){let n=e.words.findIndex((o)=>o.value==="--"),r=n===-1?e.words.length:n;return e.words.slice(1,r).some((o)=>o.kind==="dynamic")}if(e.head==="gh"&&e.tokens[1]==="api"){for(let n=2;n<e.words.length;n+=1){let r=e.words[n-1]?.value,o=e.words[n];if(o?.kind==="dynamic"&&(r==="--method"||r==="-X"||o.source.startsWith("-X")||o.source.startsWith("--method=")))return!0}return!1}let t=Fne.get(e.head);if(t!==void 0)return e.words.slice(1,t+1).some((n)=>n.kind==="dynamic");return Mne.has(e.head)&&e.words.slice(1).some((n)=>n.kind==="dynamic")},Nne=(e)=>{if(e.head!=="gh"||e.tokens[1]!=="api")return null;for(let t=2;t<e.tokens.length;t+=1){let n=e.tokens[t];if(n==="--method"||n==="-X")return e.tokens[t+1]?.toUpperCase()??"";if(n?.startsWith("--method=")===!0)return n.slice(9).toUpperCase();if(n?.startsWith("-X")===!0&&n.length>2)return n.slice(2).toUpperCase()}return null},$ne=(e)=>{if(e.head!=="gh"||e.tokens[1]!=="api")return!1;let t=Nne(e);if(t!==null&&["POST","PUT","PATCH","DELETE"].includes(t))return!0;return e.flags.some((n)=>n==="--input"||n.startsWith("--input=")||n==="-f"||n==="-F"||n==="--field"||n.startsWith("--field=")||n==="--raw-field"||n.startsWith("--raw-field="))},Une,nW=(e,t={})=>{let n=[];if(e.diagnostics.length>0){let r=[...new Set(e.diagnostics.map((s)=>s.message))],o=X("unsupported-shell-structure",`Tripwire cannot inspect this shell program safely: ${r.join(" ")}`);n.push(pf(e,o))}for(let r of e.invocations)if(Dne(r)){let o=X("unsupported-shell-structure",`Tripwire cannot classify computed policy arguments to \`${r.head}\` safely.`);n.push(pf(e,o))}else{let o=Une.find((s)=>s.match(r,e.source));if(o!==void 0){let s=o.action==="deny"?X(o.rule,o.message):Lt(o.rule,o.message);n.push(pf(e,UH(s,t)))}}return n.length===0?Y("bash-deny"):ff(n)};var rW=v(()=>{Gn();ZI();a0();Fne=new Map([["launchctl",1],["defaults",1],["diskutil",1],["tmutil",1],["security",1],["brew",1],["mas",1],["kmutil",1],["gh",2]]),Mne=new Set(["dd","kill","chmod","softwareupdate","pmset","dscl","xattr","spctl","systemsetup","scutil","flyctl","gcloud"]),Une=[{rule:"rm-rf-root",action:"deny",message:"rm -rf / is catastrophic. If the goal is cleaning a subdirectory, scope the path inside the project (e.g. ./dist).",match:(e)=>e.head==="rm"&&tW(e,"-rf","-fr","-Rf","-fR")&&e.tokens.includes("/")},{rule:"rm-rf-home",action:"deny",message:"rm -rf on $HOME / ~ would erase the home directory. Refuse.",match:(e)=>e.head==="rm"&&tW(e,"-rf","-fr","-Rf","-fR")&&e.tokens.some((t)=>/^(?<home>~|\$HOME|\$\{HOME\})$/u.test(t))},{rule:"fork-bomb",action:"deny",message:"Fork bomb pattern detected. Refuse.",match:(e,t)=>/:\(\)\s*\{\s*:\s*\|\s*:\s*&\s*\}\s*;/u.test(t)},{rule:"source-script",action:"deny",message:"`source` / `.` executes a file in the current shell. Refuse arbitrary sourced scripts.",match:(e)=>(e.head==="source"||e.head===".")&&e.tokens.length>1},{rule:"dd-raw-device",action:"deny",message:"dd writing to a raw block device wipes the disk. Refuse.",match:(e)=>e.head==="dd"&&/\bof=\/dev\/(?<type>disk|sd|nvme|rdisk)/iu.test(Rne(e))},{rule:"mkfs",action:"deny",message:"mkfs formats a filesystem. Refuse.",match:(e)=>/^mkfs(?<ext>\.[a-z0-9]+)?$/iu.test(e.head)},{rule:"kill-all",action:"deny",message:"kill -9 -1 kills every process you own. Refuse.",match:(e)=>e.head==="kill"&&e.tokens.includes("-9")&&e.tokens.includes("-1")},{rule:"chmod-777-recursive",action:"deny",message:"Recursive chmod 777 makes everything world-writable. Use 755 for directories, 644 for files, scoped narrowly.",match:(e)=>e.head==="chmod"&&e.flags.some((t)=>t.includes("R"))&&e.tokens.includes("777")},{rule:"no-verify",action:"deny",message:"--no-verify skips git hooks. Per policy: never skip hooks. Fix the underlying issue.",match:(e)=>e.tokens.includes("--no-verify")},{rule:"no-gpg-sign",action:"deny",message:"Bypassing GPG signing is off-limits unless explicitly requested.",match:(e,t)=>/--no-gpg-sign\b|-c\s+commit\.gpgsign=false/u.test(t)},{rule:"sudo",action:"ask",message:"sudo escalates privileges and is almost never needed in a coding session. If genuinely required, explain why; otherwise find a non-sudo path.",match:(e)=>e.head==="sudo"},{rule:"shutdown",action:"deny",message:"shutdown / reboot / halt control the machine. Refuse \u2014 system control should be done manually.",match:(e)=>["shutdown","reboot","halt","poweroff"].includes(e.head)},{rule:"launchctl-mutation",action:"deny",message:"launchctl load/unload/bootstrap/bootout/kickstart mutates system services. Refuse \u2014 surface the intent instead.",match:(e)=>e.head==="launchctl"&&typeof e.tokens[1]==="string"&&["load","unload","bootstrap","bootout","kickstart","enable","disable"].includes(e.tokens[1])},{rule:"defaults-write",action:"deny",message:"`defaults write` mutates macOS preferences. Refuse \u2014 surface the intent.",match:(e)=>e.head==="defaults"&&e.tokens[1]==="write"},{rule:"csrutil",action:"deny",message:"csrutil controls System Integrity Protection. Refuse.",match:(e)=>e.head==="csrutil"},{rule:"nvram",action:"deny",message:"nvram modifies firmware variables. Refuse.",match:(e)=>e.head==="nvram"},{rule:"diskutil-destructive",action:"deny",message:"diskutil eraseDisk / reformat / partitionDisk wipes disks. Refuse.",match:(e)=>e.head==="diskutil"&&typeof e.tokens[1]==="string"&&["eraseDisk","reformat","partitionDisk","eraseVolume","secureErase"].includes(e.tokens[1])},{rule:"tmutil-destructive",action:"deny",message:"tmutil delete / disablelocal touches Time Machine. Refuse.",match:(e)=>e.head==="tmutil"&&typeof e.tokens[1]==="string"&&["delete","disablelocal"].includes(e.tokens[1])},{rule:"osascript",action:"ask",message:"osascript runs arbitrary AppleScript and can do almost anything (move files, send emails, drive apps). Confirm with the user what you want done before running it.",match:(e)=>e.head==="osascript"},{rule:"topgrade",action:"deny",message:"topgrade upgrades everything (brew, mas, npm globals, rust, mise). System upgrades should be done manually.",match:(e)=>e.head==="topgrade"},{rule:"rsync-delete",action:"deny",message:"rsync --delete removes files at the destination. High blast radius \u2014 surface the intent instead.",match:(e)=>e.head==="rsync"&&e.flags.includes("--delete")},{rule:"softwareupdate-install",action:"deny",message:"`softwareupdate --install / -i / -d` triggers macOS system updates. Refuse \u2014 system updates should be done manually.",match:(e)=>e.head==="softwareupdate"&&e.flags.some((t)=>t==="--install"||t==="-i"||t==="-d"||t.startsWith("--download"))},{rule:"pmset-write",action:"deny",message:"`pmset` (with arguments) writes power-management settings. Read-only `pmset -g` is fine; mutations need the user.",match:(e)=>e.head==="pmset"&&e.tokens.length>1&&!e.tokens.includes("-g")&&!e.tokens.includes("-G")},{rule:"dscl-mutate",action:"deny",message:"`dscl . -create / -delete / -append / -change / -merge` modifies the local directory service (your user account, groups, etc.). Refuse.",match:(e)=>e.head==="dscl"&&e.tokens.some((t)=>["-create","-delete","-append","-change","-merge","-passwd"].includes(t))},{rule:"xattr-quarantine-bypass",action:"deny",message:"`xattr -d com.apple.quarantine` removes Gatekeeper's quarantine bit \u2014 the macOS protection against running untrusted binaries. Refuse.",match:(e)=>e.head==="xattr"&&e.tokens.includes("-d")&&e.tokens.some((t)=>t.includes("com.apple.quarantine"))},{rule:"spctl-disable",action:"deny",message:"`spctl --master-disable` / `--global-disable` disables Gatekeeper system-wide. Refuse.",match:(e)=>e.head==="spctl"&&e.flags.some((t)=>t==="--master-disable"||t==="--global-disable"||t==="--disable")},{rule:"kextload",action:"deny",message:"Loading a kernel extension (`kextload`, `kmutil load`) is a system-level mutation. Refuse \u2014 the user handles this manually.",match:(e)=>e.head==="kextload"||e.head==="kextunload"||e.head==="kmutil"&&(e.tokens[1]==="load"||e.tokens[1]==="unload")},{rule:"security-keychain-destructive",action:"deny",message:"`security delete-keychain / delete-generic-password / delete-internet-password / set-keychain-settings` mutates your Keychain (where CLIs store their secrets). Refuse \u2014 Keychain should be managed manually.",match:(e)=>e.head==="security"&&typeof e.tokens[1]==="string"&&["delete-keychain","delete-generic-password","delete-internet-password","delete-certificate","delete-identity","set-keychain-settings","unlock-keychain","lock-keychain","create-keychain"].includes(e.tokens[1])},{rule:"security-keychain-add-write",action:"ask",message:"`security add-generic-password / add-internet-password / add-certificate` writes to your Keychain. Other tools manage their own entries \u2014 confirm this is the right path before adding anything else manually.",match:(e)=>e.head==="security"&&typeof e.tokens[1]==="string"&&["add-generic-password","add-internet-password","add-certificate"].includes(e.tokens[1])},{rule:"systemsetup",action:"deny",message:"`systemsetup -set...` writes machine-wide settings (timezone, sleep, network time, restart-on-power-failure). Refuse.",match:(e)=>e.head==="systemsetup"&&e.tokens.some((t)=>t.startsWith("-set"))},{rule:"scutil-set",action:"deny",message:"`scutil --set` writes system configuration (computer name, hostname, LocalHostName). Refuse \u2014 read-only `scutil --get` is fine.",match:(e)=>e.head==="scutil"&&e.tokens.includes("--set")},{rule:"brew-mutation",action:"ask",message:"`brew install/uninstall/upgrade/untap` modifies the machine globally. Confirm before running.",match:(e)=>e.head==="brew"&&typeof e.tokens[1]==="string"&&["install","uninstall","upgrade","reinstall","untap","tap"].includes(e.tokens[1])},{rule:"mas-mutation",action:"ask",message:"`mas install/uninstall` changes installed Mac App Store apps. Confirm.",match:(e)=>e.head==="mas"&&typeof e.tokens[1]==="string"&&["install","uninstall","purchase"].includes(e.tokens[1])},{rule:"gh-destructive",action:"deny",message:"gh repo/release/issue delete is destructive on shared state. Refuse.",match:(e)=>e.head==="gh"&&typeof e.tokens[1]==="string"&&typeof e.tokens[2]==="string"&&["repo","release","issue","pr"].includes(e.tokens[1])&&["delete","destroy","remove"].includes(e.tokens[2])},{rule:"gh-api-mutation",action:"deny",message:"`gh api` with a mutating HTTP method can change shared GitHub state and bypass Git workflow protections. Refuse the inline mutation.",match:$ne},{rule:"flyctl-destroy",action:"deny",message:"flyctl apps destroy / volumes destroy nukes deployed infra. Refuse.",match:(e)=>e.head==="flyctl"&&e.tokens.some((t)=>t==="destroy"||t==="delete")},{rule:"gcloud-delete",action:"deny",message:"`gcloud ... delete` affects cloud resources. Refuse.",match:(e)=>e.head==="gcloud"&&e.tokens.includes("delete")}]});var c0=(e)=>e.protectedBranches??[],Lne,Bne,Hne,sW,Wne=(e)=>{if(e.head!=="git")return null;let t=e.tokens.slice(1),n=0;while(n<t.length){let r=t[n];if(r===void 0)break;if(Bne.has(r))n+=2;else if(Hne.has(r))n+=1;else if(r.startsWith("--git-dir=")||r.startsWith("--work-tree=")||r.startsWith("--namespace=")||r.startsWith("--super-prefix=")||r.startsWith("--exec-path="))n+=1;else if(r.startsWith("-"))n+=1;else return{subcommand:r,subcommandIndex:n+1,subArgs:t.slice(n+1)}}return null},jne=(e)=>{for(let t=0;t<e.length;t+=1){let n=e[t];if(n===void 0)break;if(n==="-m"||n==="--message")return e[t+1]??null;if(n.startsWith("--message="))return n.slice(10);if(/^-[a-zA-Z]*m[a-zA-Z]*$/u.test(n))return e[t+1]??null}return null},qne=(e,t)=>{let n=c0(t);for(let r of e)for(let o of n)if(r===o||r.endsWith(`:${o}`)||r.endsWith(`/${o}`))return o;return null},zne=(e)=>e.filter((t)=>!t.startsWith("-")),Vne=(e)=>e.filter((t)=>t.startsWith("-")),vt=(e,...t)=>{let n=new Set(e);return t.some((r)=>n.has(r))},Kne=({subArgs:e,positional:t})=>{if(vt(e,"--global","--system"))return X("git-config-global","Modifying global / system git config is off-limits \u2014 that is your personal identity. Read-only `git config --get` is fine.");if(!vt(e,"--get","-l","--list","--get-all","--get-regexp")&&t.length>=2)return X("git-config-write","Local git config writes should be done explicitly. To read a value, use `git config --get <key>`.");return Y("bash-git")},Gne=({subArgs:e})=>{if(vt(e,"--cached"))return Y("bash-git");return Lt("git-rm","`git rm <path>` removes from the index AND the working tree. To untrack-only, use `git rm --cached <path>`. To delete the file separately, use `trash` / `rip`. Confirm intent.")},Jne=({subArgs:e,positional:t})=>{if(vt(e,"--staged","-S")&&!vt(e,"--worktree","-W"))return Y("bash-git");if(t.length>0)return X("git-restore-discard","`git restore <path>` discards uncommitted changes in the working tree. Refuse \u2014 `git diff <path>` to inspect first, or `git stash push <path>` to preserve.");return Y("bash-git")},Qne=({subArgs:e,positional:t})=>{if(vt(e,"-b","-B"))return Y("bash-git");if(vt(e,"-f","--force"))return X("git-checkout-force","`git checkout -f` overwrites the working tree without preserving uncommitted changes. Refuse.");if(e.includes("--"))return X("git-checkout-discard","`git checkout -- <path>` discards uncommitted working-tree changes. Refuse \u2014 use `git stash push <path>` to preserve, or `git diff <path>` to inspect first.");let[n]=t;if(n!==void 0&&t.length===1&&(n==="."||n.startsWith("./")))return X("git-checkout-discard-all","`git checkout .` discards ALL uncommitted working-tree changes. Refuse \u2014 `git stash` to preserve, or `git diff` to inspect first.");return Y("bash-git")},Zne=({subArgs:e})=>{if(vt(e,"-f","--force","--discard-changes"))return X("git-switch-force","`git switch -f / --discard-changes` throws away uncommitted working-tree changes. Refuse.");return Y("bash-git")},Yne=({subArgs:e,flags:t,positional:n})=>{if(vt(e,"--hard"))return X("git-reset-hard","`git reset --hard` discards all uncommitted changes AND moves HEAD. Refuse \u2014 describe the intent in chat. If undoing a published commit, `git revert <sha>` is safer.");if(vt(e,"--keep"))return Lt("git-reset-keep","`git reset --keep` resets HEAD but preserves uncommitted local changes. Confirm intent.");if(n.length===0&&t.length===0)return Y("bash-git");return Lt("git-reset-mixed","`git reset` moves HEAD. Confirm intent \u2014 if undoing a commit, `git revert` is usually safer.")},Xne=({subArgs:e,flags:t})=>{if(vt(e,"-n","--dry-run")||t.some((n)=>/^-[a-zA-Z]*n/u.test(n)))return Y("bash-git");if(t.some((n)=>/^-[a-zA-Z]*[df]/u.test(n)||n==="--force"))return X("git-clean-fd","`git clean -fd` deletes untracked files (often your in-progress work). Refuse \u2014 inspect with `git clean -dn` (dry run) first. If genuinely needed, append ` # tripwire-allow: <reason>`.");return Y("bash-git")},ere=({subArgs:e,positional:t,config:n})=>{if(vt(e,"--abort","--quit","--continue","--skip","--edit-todo"))return Y("bash-git");if(vt(e,"-i","--interactive"))return X("git-rebase-interactive","`git rebase -i` rewrites history interactively. Refuse \u2014 too easy to lose commits in the agent loop. If this is genuinely required, do it manually outside the agent.");let[r]=t,o=c0(n);if(r!==void 0&&o.includes(r))return Lt("git-rebase-onto-protected",`Rebasing onto \`${r}\` rewrites history of the current branch. \`git merge ${r}\` is usually safer. Confirm intent.`);return Lt("git-rebase","`git rebase` rewrites commit history. `git merge` is usually safer. Confirm intent.")},tre=({subArgs:e})=>{if(vt(e,"--abort","--quit","--continue","--skip"))return Y("bash-git");return Lt("git-cherry-pick","`git cherry-pick` applies commits onto the current branch and can create conflicts. Confirm intent.")},nre=({subArgs:e})=>{if(vt(e,"--abort","--continue","--quit"))return Y("bash-git");return Lt("git-merge","`git merge <branch>` may create merge conflicts. Confirm intent.")},rre=({subArgs:e,config:t})=>{if(vt(e,"--amend"))return X("git-commit-amend","`git commit --amend` rewrites the last commit. If it has been pushed, this causes upstream divergence. Refuse \u2014 surface the intent.");let n=jne(e),r=vt(e,"-F","--file","-c","-C","--reuse-message","--reedit-message"),o=vt(e,"--no-edit");if(n===null&&!r&&!o)return X("git-commit-no-message",'`git commit` without `-m "..."` opens an editor and hangs the agent. Use `git commit -m "<conventional message>"`.');if(n!==null&&t.enforceConventionalCommits===!0&&!Lne.test(n))return X("git-commit-non-conventional",["Commit message must follow Conventional Commits format:"," `<type>(<scope>)?(!)?: <description>`","Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert.","Examples:"," `fix(auth): handle expired token refresh`"," `feat: add bash-git rule`"," `chore: bump deps`",`Got: ${JSON.stringify(n)}`].join(`
|
|
47
|
+
`));if(vt(e,"-a","--all")||e.some((s)=>/^-[a-zA-Z]*a[a-zA-Z]*$/u.test(s)))return Lt("git-commit-auto-stage","`git commit -a / --all` auto-stages every tracked change. Explicit `git add <files>` first is usually clearer about what is being committed. Confirm.");return Y("bash-git")},ore=({subArgs:e,flags:t,positional:n,config:r})=>{if(t.some((s)=>s==="--force"||s==="-f"||s.startsWith("--force-with-lease")))return X("git-force-push","Force push is forbidden. If a branch needs to be reset upstream, surface the intent \u2014 there is almost always a non-force path.");if(vt(e,"--delete","--mirror")||e.some((s)=>s.startsWith(":")))return X("git-push-delete","Refusing to delete a remote branch via push. If genuinely needed, surface the intent.");let o=qne(n,r);if(o!==null)return X("git-push-protected",`Refusing to push directly to protected branch \`${o}\`. Open a PR instead: \`gh pr create\`.`);return Y("bash-git")},sre=({subArgs:e,flags:t,positional:n,config:r})=>{let o=t.find((s)=>s==="-D"||s==="-d"||s==="--delete"||/^-[a-zA-Z]*D/u.test(s)||/^-[a-zA-Z]*d/u.test(s));if(o!==void 0){let s=n,i=new Set(c0(r)),a=s.find((c)=>i.has(c));if(a!==void 0)return X("git-branch-delete-protected",`Refusing to delete protected branch \`${a}\`.`);if(o==="-D"||o.includes("D"))return X("git-branch-force-delete",`\`git branch -D ${s.join(" ")}\` force-deletes branches even if unmerged (potential data loss). To delete a merged branch, use \`-d\`. To force, append \` # tripwire-allow: <reason>\`.`);return Lt("git-branch-delete",`\`git branch -d ${s.join(" ")}\` deletes a branch (merged-only check). Confirm intent.`)}if(vt(e,"-m","-M","--move"))return Lt("git-branch-move","Renaming a branch can confuse pushed remotes. Confirm intent.");return Y("bash-git")},ire=({subArgs:e})=>{if(vt(e,"-d","--delete"))return X("git-tag-delete","`git tag -d` deletes a tag. Refuse \u2014 surface intent.");return Y("bash-git")},are=({subArgs:e})=>{let t=e[0]??"push";if(t==="drop"||t==="clear")return X("git-stash-drop",`\`git stash ${t}\` discards stashed work. Refuse \u2014 \`git stash list\` and \`git stash show\` to inspect first.`);return Y("bash-git")},cre=({flags:e})=>{if(e.some((t)=>t.startsWith("--prune=")||t==="--aggressive"))return X("git-gc-prune","`git gc --prune=now` / `--aggressive` destroys reflog recovery options. Refuse.");return Y("bash-git")},ure=({subArgs:e})=>{let[t]=e;if(t!==void 0&&["add","prune","remove","rename","rm","set-branches","set-head","set-url","update"].includes(t))return Lt("git-remote-mutate",`\`git remote ${t}\` changes which remote you're pushing to. Confirm \u2014 accidentally pointing at the wrong remote is high blast-radius.`);return Y("bash-git")},lre=({subArgs:e})=>{if(vt(e,"-f","--force"))return X("git-checkout-index-force","`git checkout-index --force` can overwrite working-tree files. Refuse.");return Lt("git-checkout-index","`git checkout-index` writes files from the index into the working tree. Confirm the target and intent.")},oW=({subcommand:e,subArgs:t})=>{let n=t[0]??"";if(["add","remove","rm","deinit","sync","set-url"].includes(n))return Lt("git-submodule-worktree-mutate",`\`git ${e} ${n}\` modifies repo structure. Confirm intent.`);return Y("bash-git")},fre,dre=(e,t)=>{let{subcommand:n,subArgs:r}=e,o=Vne(r),s=zne(r);if(sW.has(n)){if(n==="reflog"&&(r[0]==="expire"||vt(r,"--expire")))return X("git-reflog-expire","`git reflog expire` destroys git's recovery history. Refuse \u2014 surface the intent.");if(n==="symbolic-ref"&&s.length>=2)return X("git-symbolic-ref-write","`git symbolic-ref <name> <ref>` rewrites a symbolic ref. Refuse.");return Y("bash-git")}let i=fre.get(n);if(i!==void 0)return i({subcommand:n,subArgs:r,flags:o,positional:s,config:t});return Ts("git-unknown-subcommand",`\`git ${n}\` is not classified by tripwire. Allowing \u2014 flag if this looks like history-rewriting or data-loss territory.`)},pre=(e)=>{if(sW.has(e.subcommand))return!0;if(e.subcommand!=="remote")return!1;let t=e.subArgs.find((n)=>!n.startsWith("-"));return t===void 0||t==="get-url"||t==="show"},iW=(e,t)=>{for(let n of e.invocations){let r=Wne(n);if(r!==null){if(n.words[r.subcommandIndex]?.kind==="dynamic")return X("git-dynamic-subcommand","Tripwire cannot classify a Git subcommand that is computed at runtime.");if((!pre(r)||r.subcommand==="reflog"||r.subcommand==="symbolic-ref")&&n.words.slice(1).some((i)=>i.kind==="dynamic"))return X("git-dynamic-mutation",`Tripwire cannot prove that computed arguments to \`git ${r.subcommand}\` preserve Git safety policy.`);let s=dre(r,t);if(s!==null&&s.kind!=="allow")return s}}return Y("bash-git")};var aW=v(()=>{Gn();Lne=/^(?<type>feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(?<scope>\([\w./\- ]+\))?!?:\s+\S/u,Bne=new Set(["-C","-c","--git-dir","--work-tree","--namespace","--super-prefix"]),Hne=new Set(["--bare","--paginate","-p","--no-pager","--no-replace-objects","--literal-pathspecs","--glob-pathspecs","--noglob-pathspecs","--icase-pathspecs","--no-optional-locks","--exec-path","--html-path","--man-path","--info-path"]),sW=new Set(["status","diff","diff-tree","log","show","blame","rev-parse","rev-list","ls-files","ls-tree","cat-file","reflog","describe","shortlog","whatchanged","archive","bundle","fsck","fetch","ls-remote","help","version","grep","name-rev","merge-base","symbolic-ref","check-ignore","count-objects","verify-commit","verify-tag"]),fre=new Map([["config",Kne],["add",()=>Y("bash-git")],["mv",()=>Y("bash-git")],["rm",Gne],["restore",Jne],["checkout",Qne],["switch",Zne],["reset",Yne],["clean",Xne],["rebase",ere],["cherry-pick",tre],["merge",nre],["commit",rre],["push",ore],["branch",sre],["tag",ire],["stash",are],["filter-branch",({subcommand:e})=>X("git-filter",`\`git ${e}\` rewrites entire repo history. Refuse.`)],["filter-repo",({subcommand:e})=>X("git-filter",`\`git ${e}\` rewrites entire repo history. Refuse.`)],["gc",cre],["update-ref",()=>X("git-update-ref","`git update-ref` directly mutates refs and bypasses normal git operations. Refuse.")],["remote",ure],["submodule",oW],["worktree",oW],["checkout-index",lre],["write-tree",()=>Y("bash-git")],["init",({subcommand:e})=>Ts(`git-${e}`,`\`git ${e}\` is allowed but unusual mid-session. Make sure this is what the user asked for.`)],["clone",({subcommand:e})=>Ts(`git-${e}`,`\`git ${e}\` is allowed but unusual mid-session. Make sure this is what the user asked for.`)]])});var mre,hre,gre=(e)=>{for(let t of e.invocations){let{pipeline:n}=t;if(mre.has(t.head)&&n!==void 0){if(e.invocations.find((o)=>o.pipeline?.id===n.id&&o.pipeline.index===n.index+1&&hre.has(o.head))!==void 0)return!0}}return!1},xre,cW=(e)=>{if(gre(e))return X("curl-pipe-shell","Piping `curl` / `wget` directly into a shell runs whatever the remote URL serves. Refuse \u2014 download to a file, inspect, then run if appropriate. If you genuinely need this, append ` # tripwire-allow: <reason>` (and explain to the user what you're running).");for(let t of e.invocations)for(let n of xre)if(t.head===n.head&&t.tokens[1]===n.subcommand)return Lt(n.rule,n.message);return Y("bash-network-install")};var uW=v(()=>{Gn();mre=new Set(["curl","wget","wget2","aria2c","xh"]),hre=new Set(["bash","sh","zsh","fish"]),xre=[{head:"cargo",subcommand:"install",rule:"cargo-install",message:"Confirm before `cargo install <crate>`: this builds and installs arbitrary code from crates.io into ~/.cargo/bin globally."},{head:"go",subcommand:"install",rule:"go-install",message:"Confirm before `go install`: this fetches and installs arbitrary Go code globally."},{head:"gem",subcommand:"install",rule:"gem-install",message:"Confirm before `gem install`: pulls arbitrary code from rubygems.org."}]});import{lstatSync as yre,readlinkSync as Sre,realpathSync as Ere}from"fs";import mf from"path";var bre,lW=(e)=>{try{return Ere(e)}catch{return null}},u0=(e,t=new Set)=>{if(t.has(e))return e;t.add(e);let n=lW(e);if(n!==null)return n;try{if(yre(e).isSymbolicLink()){let o=Sre(e);return u0(mf.resolve(mf.dirname(e),o),t)}}catch{}let r=mf.dirname(e);if(r===e)return e;return mf.join(u0(r,t),mf.basename(e))},xm=(e,t,n)=>{let r=mf.resolve(e),o=t==="write"?u0(r):lW(r),s=[e,r];if(o!==null&&!s.includes(o))s.push(o);for(let i of s)for(let a of n)if(a.pattern.test(i))return a;return null},l0=(e)=>{let t=xm(e.file_path,"write",bre);if(t!==null)return X(t.rule,t.message);return Y("path-protect")};var $y=v(()=>{Gn();bre=[{pattern:/(?<prefix>^|\/)\.env(?<ext>\.[^/]+)?$/u,rule:"env-file",message:".env files hold secrets that should never be sent to the model. Refuse to write or edit. If an example is needed, create .env.example with redacted placeholders."},{pattern:/(?<prefix>^|\/)\.dev\.vars(?<ext>\.[^/]+)?$/u,rule:"dev-vars",message:".dev.vars holds Cloudflare/Wrangler secrets. Do not modify."},{pattern:/(?<prefix>^|\/)\.ssh\//u,rule:"ssh-dir",message:"Never write into ~/.ssh/. Refuse."},{pattern:/(?<prefix>^|\/)(?<key>id_rsa|id_ed25519|id_ecdsa|id_dsa)(?<pub>\.pub)?$/u,rule:"ssh-key",message:"SSH key file. Refuse."},{pattern:/\.(?<ext>pem|key|p12|pfx)$/iu,rule:"private-key",message:"Private key file. Refuse to overwrite. If generating a new key, use a different filename and let the user review."},{pattern:/(?<prefix>^|\/)secrets?\.(?<ext>json|ya?ml|toml|env)$/iu,rule:"secrets-file",message:"Secrets file. Refuse."},{pattern:/(?<prefix>^|\/)\.aws\/credentials$/u,rule:"aws-credentials",message:"AWS credentials file. Refuse."},{pattern:/(?<prefix>^|\/)\.netrc$/u,rule:"netrc",message:".netrc holds host credentials. Refuse."}]});var wre,kre=(e)=>{let t=xm(e,"write",wre);if(t!==null)return X(t.rule,t.message);return null},f0=(e)=>e.kind==="dynamic"||e.kind==="background-pid"?X("redirect-dynamic-target","Tripwire cannot prove that this computed write target avoids protected files."):kre(e.value),fW=(e)=>{for(let t of e.redirects)if(t.op===">"||t.op===">>"||t.op==="&>"||t.op==="&>>"){let n=f0(t.target);if(n!==null)return n}for(let t of e.invocations){let n=t.words.slice(1).filter((r)=>!r.value.startsWith("-"));if(t.head==="tee")for(let r of n){let o=f0(r);if(o!==null)return o}if(t.head==="cp"||t.head==="mv"){let r=n.at(-1);if(r!==void 0){let o=f0(r);if(o!==null)return o}}}return Y("bash-redirect")};var dW=v(()=>{Gn();$y();wre=[{rule:"redirect-env",pattern:/(?<prefix>^|\/)\.env(?<ext>\.[^/]+)?$/u,message:"Refusing to write into a .env file via shell redirect / tee / cp / mv. .env files hold secrets \u2014 never overwrite from a tool call."},{rule:"redirect-dev-vars",pattern:/(?<prefix>^|\/)\.dev\.vars(?<ext>\.[^/]+)?$/u,message:"Refusing to write into .dev.vars (Cloudflare/Wrangler secrets)."},{rule:"redirect-ssh",pattern:/(?<prefix>^|\/)\.ssh\//u,message:"Refusing to write into ~/.ssh/ via shell."},{rule:"redirect-key",pattern:/\.(?<ext>pem|key|p12|pfx)$/iu,message:"Refusing to overwrite a private-key-shaped file via shell."},{rule:"redirect-aws-credentials",pattern:/(?<prefix>^|\/)\.aws\/credentials$/u,message:"Refusing to write into ~/.aws/credentials via shell."},{rule:"redirect-netrc",pattern:/(?<prefix>^|\/)\.netrc$/u,message:"Refusing to write into ~/.netrc via shell."},{rule:"redirect-block-device",pattern:/^\/dev\/(?<type>sd|disk|nvme|rdisk)/iu,message:"Redirecting into a raw block device wipes the disk. Refuse."}]});var Cre=(e,t)=>{let n=!1,r=[];for(let i of e.tokens.slice(1))if(!n&&i==="--")n=!0;else if(n||!i.startsWith("-")||i==="-")r.push(i);let o=t.relative??[],s=t.absolute??[];return r.filter((i)=>!JI(i,o,s))},vre=(e,t)=>{if(!e.tokens.includes("-delete"))return null;let n=[];for(let i of e.tokens.slice(1)){if(i.startsWith("-"))break;n.push(i)}let r=n.length===0?["."]:n,o=t.relative??[],s=t.absolute??[];return r.filter((i)=>!JI(i,o,s))},pW=(e,t)=>{let n=[];for(let i of e.invocations)if(i.head==="rm"){let a=Cre(i,t);if(a.length>0)n.push({kind:"rm",targets:a})}else if(i.head==="find"){let a=vre(i,t);if(a!==null&&a.length>0)n.push({kind:"find -delete",targets:a})}if(n.length===0)return Y("bash-scoped-rm");let r=t.relative??[],o=t.absolute??[],s=n.map((i)=>` \u2022 ${i.kind} on: ${i.targets.map((a)=>JSON.stringify(a)).join(", ")}`).join(`
|
|
48
|
+
`);return X("destructive-outside-safe-paths",`Destructive deletion outside known-safe scopes is blocked. Use a recoverable deletion tool or limit the target to an ephemeral build, cache, state, or temporary directory:
|
|
49
|
+
${MH(r,o)}
|
|
53
50
|
|
|
54
51
|
Flagged targets:
|
|
55
|
-
${
|
|
52
|
+
${s}
|
|
56
53
|
|
|
57
|
-
If raw deletion is genuinely needed, append \` # tripwire-allow: <reason>\` to the command.`)};var
|
|
54
|
+
If raw deletion is genuinely needed, append \` # tripwire-allow: <reason>\` to the command.`)};var mW=v(()=>{Fy();Gn()});var Ire=(e)=>e==="--extract"||e.startsWith("-")&&!e.startsWith("--")&&e.slice(1).includes("x"),Are=(e)=>{for(let t=0;t<e.tokens.length;t+=1){let n=e.tokens[t];if(n!==void 0){if(n==="-C"||n==="--directory")return e.tokens[t+1]??null;if(n.startsWith("--directory="))return n.slice(12)}}return null},hW=(e)=>e==="/"||/^(?<home>~|\$HOME|\$\{HOME\})$/u.test(e),Tre=(e)=>{let t=e.tokens.indexOf("-d");return t===-1?void 0:e.tokens[t+1]},gW=(e)=>{for(let t of e.invocations)if(t.head==="tar"){let[,n]=t.tokens,o=t.flags.some(Ire)||t.tokens.includes("--extract")||n!==void 0&&/^[a-zA-Z]+$/u.test(n)&&n.includes("x")?Are(t):null;if(o!==null&&hW(o))return X("tar-extract-to-root",`tar -x with -C ${o} can overwrite arbitrary system files. Refuse \u2014 extract to a contained directory (e.g. ./tmp/extract) and inspect before moving anything elsewhere.`)}for(let t of e.invocations)if(t.head==="unzip"){let n=Tre(t);if(n!==void 0&&hW(n))return X("unzip-to-root",`unzip -d ${n} can overwrite arbitrary system files. Refuse \u2014 extract to a contained directory.`)}return Y("bash-tar-explosion")};var xW=v(()=>{Gn()});var _re="If this is intentional, append ` # tripwire-allow: <reason>` to the command.",Ore,yW=(e)=>Ore.get(e)??e,SW=(e)=>{let t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)},Pre=(e,t)=>e.some((n)=>n===t||n.startsWith(`${t}=`)),Rre=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=e[n];if(r!==void 0){if(r===t)return e[n+1]??"";if(r.startsWith(`${t}=`))return r.slice(t.length+1)}}return null},Fre=(e)=>{let t=[],n=e.tokens.slice(1);for(let r=0;r<n.length;r+=1){let o=n[r];if(o?.startsWith("-")===!0){let s=n[r+1];if(!o.includes("=")&&s!==void 0&&!s.startsWith("-"))r+=1}else if(o!==void 0)t.push(o)}return t},EW=(e,t)=>{let{pattern:n}=t,r=gm(n);if(r.diagnostics.length>0||r.invocations.length===0)return!1;let[o]=r.invocations;if(o===void 0)return!1;let[s,...i]=o.tokens;if(s===void 0)return!1;return e.invocations.some((a)=>{if(SW(a.head)!==SW(s))return!1;let c=Fre(a),u=i.every((d,m)=>c[m]!==void 0&&yW(c[m])===yW(d)),l=(t.requiresFlags??[]).every((d)=>Pre(a.tokens,d)),f=(t.forbidsFlagValues??[]).every((d)=>{let m=Rre(a.tokens,d.flag);return m!==null&&d.values.includes(m)});return u&&l&&f})},bW=(e,t,n)=>{for(let r of n)if(EW(e,r))return Y("config-custom");for(let r of t)if(EW(e,r)){let o=r.message.includes("tripwire-allow")?r.message:`${r.message} ${_re}`;return r.action==="ask"?Lt("config-custom",o):X("config-custom",o)}return Y("config-custom")};var wW=v(()=>{Fy();Gn();Ore=new Map([["add","create"],["new","create"],["edit","update"],["set","update"],["rm","delete"],["del","delete"],["remove","delete"]])});import{readFileSync as Mre}from"fs";var kW=(e,t)=>{let n=new Set(e.split(`
|
|
58
55
|
`).map((r)=>r.trim()).filter((r)=>r.length>0));return t.split(`
|
|
59
|
-
`).filter((r)=>r.trim().length>0).filter((r)=>!n.has(r.trim()))},
|
|
56
|
+
`).filter((r)=>r.trim().length>0).filter((r)=>!n.has(r.trim()))},CW=(e)=>{try{return Mre(e,"utf8")}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return"";throw t}};var vW=()=>{};var Dre,Nre,$re,Ure,Lre=(e)=>{if(Ure.test(e))return!1;for(let t of Dre)if(t.test(e))return!0;return!1},d0=(e)=>{let t=e.file_path;if(!Nre.test(t)||$re.test(t))return Y("lazy-code");let n="content"in e?e.content:e.new_string,r="content"in e?CW(t):e.old_string,o=[];for(let a of kW(r,n))if(Lre(a))o.push(a.slice(0,200));if(o.length===0)return Y("lazy-code");let s=o.slice(0,3).map((a)=>` \u2022 ${a}`).join(`
|
|
60
57
|
`),i=o.length>3?`
|
|
61
|
-
\u2026and ${o.length-3} more`:"";return
|
|
62
|
-
`))};var
|
|
58
|
+
\u2026and ${o.length-3} more`:"";return Ts("lazy-code-marker",["Heads up: line(s) you just added contain words that often signal incomplete or deferred work. The write went through \u2014 this is a flag, not a block.","",'Why this exists: AI coding agents have a strong pull toward stubbing things, deferring "for now," and shipping half-built fallbacks instead of finishing the work in the same turn. The point of this warning is to push back on that pull on every iteration. If you stubbed something out for time, finish it this turn rather than leaving deferred work for later.',"",'If the marker is genuinely permanent \u2014 a real product term ("auth fallback flow", "retry fallback chain", an HTML input placeholder, a public API field literally named "placeholder"), a logging tag, or a comment intentionally left for a human reader \u2014 no action needed. To silence the flag on subsequent edits of that line, append `tripwire-allow: <one-line reason>` (any comment syntax: `//`, `#`, `--`, etc.).',"","Flagged additions:",s+i].join(`
|
|
59
|
+
`))};var IW=v(()=>{Gn();vW();Dre=[/\bTODO\s*:/iu,/\bFIXME\s*:/iu,/\bXXX\s*:/iu,/\bHACK\s*:/iu,/\bfor now\b/iu,/\bnot implemented\b/iu,/\bNotImplementedError\b/u,/\btemp fix\b/iu,/\bfallback\b/iu,/\bplaceholder\b/iu,/\bbackwards?[ -]?compat(?<ibility>ibility)?\b/iu,/\bfor later\b/iu,/\blater on\b/iu,/\bget back to\b/iu,/\bI'?ll fix\b/iu,/\bto be implemented\b/iu,/\bnot yet (?<state>implemented|done)\b/iu,/\bstubbed\b/iu],Nre=/\.(?<ext>ts|tsx|js|jsx|mjs|cjs|py|rs|go|rb|java|kt|swift|c|cc|cpp|h|hpp|cs|php|sh|zsh|bash|lua|ex|exs|clj|scala|dart)$/iu,$re=/(?<prefix>^|\/)(?<dir>__tests__|tests?|spec|fixtures?|mocks?|__mocks__|stories)(?<suffix>\/|$)|\.(?<ext>test|spec|fixture|mock|stories)\.[^/]+$/iu,Ure=/tripwire-allow:[ \t]*\S/u});import{spawnSync as Bre}from"child_process";var Hre,Wre,jre,qre=({executable:e,args:t,input:n,timeoutMs:r})=>{let o=Bre(e,t,{encoding:"utf8",input:n,maxBuffer:67108864,stdio:["pipe","pipe","ignore"],timeout:r}),s={status:o.status,stdout:typeof o.stdout==="string"?o.stdout:""};return o.error===void 0?s:{...s,error:o.error}},zre=(e)=>{if(typeof e!=="object"||e===null||!("code"in e))return;return typeof e.code==="string"?e.code:void 0},Vre=(e)=>{let t=zre(e);if(t==="ENOENT")return"missing-executable";if(t==="ETIMEDOUT")return"timeout";return"non-zero-exit"},Kre=(e)=>{let t=new Map;for(let n of e)t.set(n.RuleID,(t.get(n.RuleID)??0)+1);return[...t.entries()].map(([n,r])=>({rule:n,count:r}))},Gre=(e,t)=>{let n=e,r=[...t].toSorted((o,s)=>s.Secret.length-o.Secret.length);for(let o of r)if(o.Secret!=="")n=n.replaceAll(o.Secret,`[REDACTED:${o.RuleID}]`);return n},AW=(e,t,n=qre)=>{if(e.length===0)return{ok:!0,hits:[],redacted:e};let r;try{r=n({executable:t.executable,args:jre,input:e,timeoutMs:t.timeoutMs})}catch{return{ok:!1,category:"non-zero-exit"}}if(r.error!==void 0)return{ok:!1,category:Vre(r.error)};if(r.status!==0)return{ok:!1,category:"non-zero-exit"};let o;try{o=JSON.parse(r.stdout)}catch{return{ok:!1,category:"malformed-json"}}let s=O.decodeUnknownResult(Wre)(o);if(Yt.isFailure(s))return{ok:!1,category:"malformed-json"};let i=s.success;return{ok:!0,hits:Kre(i),redacted:Gre(e,i)}};var TW=v(()=>{vs();Hre=O.Struct({RuleID:O.String,Description:O.String,StartLine:O.Finite,EndLine:O.Finite,Secret:O.String,Match:O.String}),Wre=O.Array(Hre),jre=["stdin","--report-format","json","--report-path","-","--exit-code","0","--no-banner","--no-color","--log-level","error"]});var Jre=(e)=>`Tripwire could not verify this tool output because the configured secret scanner failed (${e}). The original output was withheld. Install Betterleaks 1.5.0 or later, check secretScanner.executable and secretScanner.timeoutMs, then run the original tool again.`,_W=(e)=>{let t=YH(e.toolName,e.response);if(t.length===0)return Y("post-secret-scrub");let n=AW(t,e.secretScanner,e.scannerRunner);if(!n.ok)return X("secret-scanner-failed",Jre(n.category));if(n.hits.length===0)return Y("post-secret-scrub");let r=n.hits.map((o)=>`${o.rule}\xD7${o.count}`).join(", ");return X("secrets-in-output",[`tripwire intercepted ${n.hits.length} secret pattern(s) in this tool's output (${r}). The original output was withheld so the secret never enters the model context. A redacted form is below \u2014 work from this, do not re-run the same command in a way that re-fetches the underlying secret.`,"","Redacted output:",n.redacted.slice(0,16000)+(n.redacted.length>16000?`
|
|
63
60
|
\u2026[truncated]`:"")].join(`
|
|
64
|
-
`))};var
|
|
61
|
+
`))};var OW=v(()=>{Gn();i0();TW()});var Qre,PW=(e)=>{let t=xm(e.file_path,"read",Qre);if(t!==null)return X(t.rule,t.message);return Y("read-protect")};var RW=v(()=>{Gn();$y();Qre=[{rule:"read-env",pattern:/(?<prefix>^|\/)\.env(?<ext>\.[^/]+)?$/u,message:".env files hold secrets that should never enter the model context. Refuse to read. If the goal is documenting required env vars, look at .env.example or describe the schema from memory."},{rule:"read-dev-vars",pattern:/(?<prefix>^|\/)\.dev\.vars(?<ext>\.[^/]+)?$/u,message:"Refuse to read .dev.vars (Cloudflare/Wrangler secrets)."},{rule:"read-ssh",pattern:/(?<prefix>^|\/)\.ssh\//u,message:"Refuse to read files inside ~/.ssh/."},{rule:"read-ssh-key",pattern:/(?<prefix>^|\/)(?<key>id_rsa|id_ed25519|id_ecdsa|id_dsa)$/u,message:"Refuse to read SSH private key files."},{rule:"read-private-key",pattern:/\.(?<ext>pem|key|p12|pfx)$/iu,message:"Refuse to read private-key-shaped files."},{rule:"read-aws-credentials",pattern:/(?<prefix>^|\/)\.aws\/credentials$/u,message:"Refuse to read ~/.aws/credentials."},{rule:"read-netrc",pattern:/(?<prefix>^|\/)\.netrc$/u,message:"Refuse to read ~/.netrc (host credentials)."},{rule:"read-secrets-file",pattern:/(?<prefix>^|\/)secrets?\.(?<ext>json|ya?ml|toml|env)$/iu,message:"Refuse to read a file named secrets.{json,yaml,toml,env}."}]});var Zre=(e,t)=>e.some((n)=>n.startsWith("-")&&!n.startsWith("--")&&n.slice(1).includes(t)),Yre=(e,t)=>{if(!t.executables.includes(e.head))return!1;let n=e.tokens.slice(1),r=new Set(n);if(!(t.match?.argumentsIncludeAll??[]).every((o)=>r.has(o)))return!1;if(!(t.match?.argumentsStartWith??[]).every((o,s)=>n[s]===o))return!1;return(t.match?.shortFlagsIncludeAll??[]).every((o)=>Zre(e.flags,o))},FW=(e,t)=>{for(let n of e.invocations)for(let r of t)if(Yre(n,r))return r.action==="deny"?X(r.rule,r.message):Ts(r.rule,r.message);return Y("tool-policy")};var MW=v(()=>{Gn()});var VW={};Qn(VW,{collectPostToolUseRules:()=>y0,collectPreToolUseRules:()=>x0,decide:()=>ooe,decideBash:()=>S0,normalizeToolName:()=>ym,runHook:()=>foe,runRules:()=>h0,runRulesSync:()=>Uy});var Xre=async()=>{let e=[];for await(let t of process.stdin){let n=t;if(n instanceof Uint8Array)e.push(Buffer.from(n));else throw TypeError("Tripwire received a non-byte stdin chunk")}return Buffer.concat(e).toString("utf8")},g0,DW=250,eoe="--tripwire-hook",toe,hf=(e=g0)=>{if(e.kind==="cursor"&&!e.post){process.stdout.write(`{"continue":true,"permission":"allow"}
|
|
65
62
|
`);return}process.stdout.write(`{"continue": true}
|
|
66
|
-
`)},
|
|
67
|
-
`)},
|
|
68
|
-
`);return}let r=e.hook_event_name,o=`[tripwire:${t.rule}] ${t.message}`;if(
|
|
63
|
+
`)},p0=(e)=>`[tripwire:${e.rule}] ${e.message}`,LW=(e)=>{let t=e.kind==="ask"?`${p0(e)} This unattended Cursor run cannot ask a human, so the action is denied.`:p0(e);process.stdout.write(`${JSON.stringify({continue:!0,permission:"deny",user_message:t,agent_message:t})}
|
|
64
|
+
`)},BW=(e)=>e.turn_id!==void 0,NW=(e,t,n)=>{if(n.kind==="cursor"){process.stdout.write(`${JSON.stringify({continue:!0,permission:"allow",agent_message:p0(t)})}
|
|
65
|
+
`);return}let r=e.hook_event_name,o=`[tripwire:${t.rule}] ${t.message}`;if(BW(e)){process.stdout.write(`${JSON.stringify({continue:!0,systemMessage:o})}
|
|
69
66
|
`);return}let s={hookEventName:r,additionalContext:o};process.stdout.write(`${JSON.stringify({continue:!0,hookSpecificOutput:s})}
|
|
70
|
-
`)},
|
|
71
|
-
`)},
|
|
72
|
-
`)},
|
|
67
|
+
`)},m0=(e,t,n=g0)=>{if(n.kind==="cursor"){LW(t);return}let r={hookSpecificOutput:{hookEventName:e,permissionDecision:t.kind==="deny"?"deny":"ask",permissionDecisionReason:`[tripwire:${t.rule}] ${t.message}`}};process.stdout.write(`${JSON.stringify(r)}
|
|
68
|
+
`)},noe=(e,t)=>{if(t.kind==="cursor"){hf(t);return}let n={continue:!0,decision:"block",reason:`[tripwire:${e.rule}] ${e.message}`};process.stdout.write(`${JSON.stringify(n)}
|
|
69
|
+
`)},ym=(e)=>{let t=e.toLowerCase();if(t==="bash"||t==="exec"||t==="shell"||t==="run_command")return"Bash";if(t==="read"||t==="read_file")return"Read";if(t==="write"||t==="write_file")return"Write";if(t==="edit"||t==="edit_file"||t==="multiedit"||t==="apply_patch")return"Edit";if(t==="webfetch"||t==="web_fetch"||t==="fetch")return"WebFetch";if(t==="powershell")return"PowerShell";return e},HW,WW,roe=(e,t,n)=>B.gen(function*(){let o=yield*B.exit(B.try({try:t,catch:(s)=>new HW({cause:s})}).pipe(B.timeout(n)));if(pn.isSuccess(o))return o.value;return _s(e,Et.pretty(o.cause)),Y(e)}),jW=(e,t,n={})=>{let r=[],o=gm(e,{...n,executionCarrierAliases:t.shell.executionCarrierAliases}),s=(i,a)=>({name:i,fn:()=>pf(o,a())});return r.push(s("bash-deny",()=>nW(o,t.ruleActions)),s("bash-git",()=>iW(o,t.git)),s("bash-scoped-rm",()=>pW(o,t.safePaths)),s("bash-redirect",()=>fW(o)),s("bash-network-install",()=>cW(o)),s("bash-tar-explosion",()=>gW(o)),s("tool-policy",()=>FW(o,t.toolPolicies)),s("config-custom",()=>bW(o,t.blockedCommands,t.allowedCommands))),r},x0=(e,t,n,r)=>{let o=[];if(e==="PowerShell")return o.push({name:"powershell-unsupported",fn:()=>X("powershell-unsupported","PowerShell commands are blocked because Tripwire cannot parse PowerShell grammar. Use the Bash tool, or add a PowerShell parser before you enable this tool.")}),o;if(e==="Bash"&&GH(t))return jW(t.command,n,r===void 0?{}:{cwd:r});if(e==="Read"&&ZH(t)){let a=t;return o.push({name:"read-protect",fn:()=>PW(a)}),o}let s=(e==="Edit"||e==="MultiEdit")&&JH(t),i=e==="Write"&&QH(t);if(s){let a=t;o.push({name:"path-protect",fn:()=>l0(a)},{name:"lazy-code",fn:()=>d0(a)})}else if(i){let a=t;o.push({name:"path-protect",fn:()=>l0(a)},{name:"lazy-code",fn:()=>d0(a)})}return o},y0=(e,t,n)=>{if(e==="Bash"||e==="PowerShell"||e==="Read"||e==="WebFetch"){let r=e==="PowerShell"?"Bash":e;return[{name:"post-secret-scrub",fn:()=>_W({toolName:r,response:t,secretScanner:n})}]}return[]},h0=(e,t)=>B.gen(function*(){if(e.length===0)return Y("no-rules");let r=[];for(let o of e)r.push(yield*roe(o.name,o.fn,t));return ff(r)}),Uy=(e)=>{if(e.length===0)return Y("no-rules");let t=[];for(let n of e)try{t.push(n.fn())}catch(r){_s(n.name,r),t.push(Y(n.name))}return ff(t)},ooe=(e,t={})=>{let n=Dy(t),r=ym(e.tool_name??"");if(e.hook_event_name==="PreToolUse")return Uy(x0(r,e.tool_input,n,e.cwd));if(e.hook_event_name==="PostToolUse")return Uy(y0(r,e.tool_response,n.secretScanner));return Y("no-rules")},S0=(e,t={},n={})=>Uy(jW(e,Dy(t),n)),soe=(e,t,n)=>{let r=e.hook_event_name,o=ym(e.tool_name??"");if(r==="PreToolUse"&&o==="Bash"){if(t.kind==="warn"){NW(e,t,n);return}hf(n);return}if(t.kind==="warn"){NW(e,t,n);return}hf(n)},ioe=(e)=>`tripwire config at ${YI} failed to load, so ALL custom safety policy is inactive. Failing closed until it is fixed. Fix the JSON, then this clears on the next hook call. Restart any long-running consumer that caches the loaded config. Error: ${e}`,qW=()=>{let e=process.argv.indexOf("--cursor-event");if(e!==-1)return process.argv[e+1]??"";return process.argv.find((n)=>n.startsWith("--cursor-event="))?.slice(15)},aoe=()=>process.argv.includes(eoe),zW=()=>{let e=qW();return e===void 0?g0:r0(e)},Ba=(e,t=!1)=>{let n=zW();if(t){m0("PreToolUse",X("tripwire-batch-error",`Tripwire batch input could not be processed (${e}). Failing closed.`),n);return}if(n.kind==="cursor"&&!n.post){LW(X("cursor-hook-error",`Cursor hook input could not be processed (${e}). Failing closed.`));return}hf(n)},$W=(e,t)=>{if(t.kind==="cursor")return`cursor:${t.eventName}`;return BW(e)?"codex":"native"},UW=(e)=>e.length===1?e[0]??Y("no-rules"):ff(e),coe=(e)=>B.gen(function*(){let n=Array.isArray(e);if(n&&!aoe())return _s("decode","Batch hook input is only available through --tripwire-hook"),Ba("unsupported batch input"),{ok:!1};let r,o;if(n){let c=yield*B.exit(O.decodeEffect(toe)(e));if(pn.isFailure(c))return _s("decode",Et.pretty(c.cause)),Ba("unsupported batch event shape",!0),{ok:!1};r=c.value,o=zW()}else{let c=VH(e,qW()),u=yield*B.exit(O.decodeUnknownEffect(s0)(c.event));if(pn.isFailure(u))return _s("decode",Et.pretty(u.cause)),Ba("unsupported event shape"),{ok:!1};r=[u.value],{host:o}=c}let[s]=r;if(s===void 0)return Ba("empty batch",!0),{ok:!1};let i=s.hook_event_name,a=$W(s,o);if(r.some((c)=>c.hook_event_name!==i))return _s("decode","Batch hook input mixes event phases"),Ba("mixed event phases",!0),{ok:!1};if(r.some((c)=>$W(c,o)!==a))return _s("decode","Batch hook input mixes hosts"),Ba("mixed hosts",!0),{ok:!1};return{ok:!0,events:r,firstEvent:s,host:o,phase:i}}),uoe,loe,foe=()=>{Rg.runMain(loe)};var E0=v(()=>{II();vs();Fy();XI();KH();Gn();i0();eW();a0();rW();aW();uW();dW();mW();xW();wW();IW();$y();OW();RW();MW();g0={kind:"native"},toe=O.Array(s0).check(O.isMinLength(1));HW=class HW extends xr.TaggedError("RuleExecutionError"){};WW=class WW extends xr.TaggedError("HookInputParseError"){};uoe=B.gen(function*(){let t=yield*Ny(),n=yield*B.promise(Xre),r=yield*B.exit(B.try({try:()=>JSON.parse(n),catch:(u)=>new WW({cause:u})}));if(pn.isFailure(r)){_s("parse",Et.pretty(r.cause)),Ba("invalid JSON");return}let o=yield*coe(r.value);if(!o.ok)return;let{events:s,firstEvent:i,host:a,phase:c}=o;if(c==="PreToolUse"){if(!t.ok){m0(c,X("config-error",ioe(t.error)),a);return}let u=[];for(let f of s){let d=ym(f.tool_name??"");u.push(yield*h0(x0(d,f.tool_input,t.config,f.cwd),DW))}let l=UW(u);if(l.kind==="deny"||l.kind==="ask"){m0(c,l,a);return}soe(i,l,a);return}if(c==="PostToolUse"){let u=t.ok?t.config.secretScanner:My().secretScanner,l=[];for(let d of s){let m=ym(d.tool_name??"");l.push(yield*h0(y0(m,d.tool_response,u),DW))}let f=UW(l);if(f.kind==="deny"){noe(f,a);return}hf(a);return}hf(a)}),loe=uoe.pipe(B.catchCause((e)=>B.sync(()=>{_s("dispatch-fatal",Et.pretty(e)),Ba("dispatcher failure")})))});function doe(e){return{_tag:"Value",value:e}}function poe(e,t){return{_tag:"Record",keys:e,value:t}}function moe(e,t){return{_tag:"Array",length:e,value:t}}function xoe(e,t){let n=Object.create(hoe);return n.load=e,n.mapInput=t,n}function GW(e,t){return xoe((n)=>e(t(n)),(n)=>GW(e,RA(t,n)))}function yoe(e){return GW(e,goe)}function Soe(e,t){return e===""&&!t?void 0:e}function Eoe(e,t){let n=t?.preserveEmptyStrings===!0,r=woe(e);return yoe((o)=>A(Coe(r,e,o,n)))}function boe(e){let t=e?.env??{...globalThis.process?.env,...import.meta?.env};return Eoe(t,{preserveEmptyStrings:e?.preserveEmptyStrings})}function woe(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let o=n.split("_"),s=t;for(let i of o){let a=s.children??=Object.create(null);s=a[i]??={}}}return t}function Coe(e,t,n,r){let o=n.map(String).join("_"),s=Soe(Object.hasOwn(t,o)?t[o]:void 0,r),i=voe(e,n),a=i?.children?Object.keys(i.children):[];if(a.length===0)return s===void 0?void 0:doe(s);if(a.every((u)=>koe.test(u))){let u=Math.max(...a.map((l)=>parseInt(l,10)))+1;return moe(u,s)}return poe(new Set(a),s)}function voe(e,t){if(t.length===0)return e;let n=e;for(let r of t)if(n=n?.children?.[String(r)],!n)return;return n}var KW,hoe,goe=(e)=>e,koe;var JW=v(()=>{rt();Re();ne();pt();KW=Te("effect/ConfigProvider",{defaultValue:()=>boe()}),hoe={...Xn,toJSON(){return{_id:"ConfigProvider"}}};koe=/^(0|[1-9][0-9]*)$/});function ZW(e){let t=Object.create(Aoe);return t.evaluator=e,t.parse=(n)=>e(n,[]).pipe(Tc((r)=>r.error),An((r)=>r._tag==="Resolved"?A(r.value):R(r.error))),t}var QW="~effect/Config",Aoe,YW=(e,t,n)=>e.evaluator(t,n),XW=(e,t)=>({_tag:"Resolved",value:e,hasInput:t}),Toe,_oe,ej=(e)=>e.pipe(Toe(F),_oe(P())),b0,w0,tj;var k0=v(()=>{JW();Re();Fu();ne();Me();Qc();px();Aoe={...ss({label:"Config",evaluate(e){return this.parse(e.getRef(KW))}}),[QW]:QW,toJSON(){return{_id:"Config"}}};Toe=p(2,(e,t)=>ZW((n,r)=>ae(YW(e,n,r),(o)=>o._tag==="Resolved"?XW(t(o.value),o.hasInput):o))),_oe=p(2,(e,t)=>ZW((n,r)=>ci(YW(e,n,r),(o)=>o._tag==="Absent"?XW(t,!1):o))),b0=Ti(["true","yes","on","1","y"]),w0=Ti(["false","no","off","0","n"]),tj=Ti([...b0.literals,...w0.literals]).pipe(pe(ly,ht({decode:(e)=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:(e)=>e?"true":"false"})))});var at="~effect/cli/CliError",C0=(e)=>D(e,at),ru,Ly,Sm,By,Hy,fr,Wy,rj,Ooe,Ha;var Em=v(()=>{ge();Pg();Qc();ru=class ru extends Qo(`${at}/UnrecognizedOption`)("UnrecognizedOption",{option:Q,command:cr(je(Q)),suggestions:je(Q)}){[at]=at;get message(){let e=this.suggestions.length>0?`
|
|
73
70
|
|
|
74
71
|
Did you mean this?
|
|
75
72
|
${this.suggestions.join(`
|
|
76
|
-
`)}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}};
|
|
73
|
+
`)}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}};Ly=class Ly extends Qo(`${at}/DuplicateOption`)("DuplicateOption",{option:Q,parentCommand:Q,childCommand:Q}){[at]=at;get message(){return`Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`}};Sm=class Sm extends Qo(`${at}/MissingOption`)("MissingOption",{option:Q}){[at]=at;get message(){return`Missing required flag: --${this.option}`}};By=class By extends Qo(`${at}/MissingArgument`)("MissingArgument",{argument:Q}){[at]=at;get message(){return`Missing required argument: ${this.argument}`}};Hy=class Hy extends Qo(`${at}/UnexpectedArgument`)("UnexpectedArgument",{arguments:je(Q)}){[at]=at;get message(){return`Unexpected positional ${this.arguments.length===1?"argument":"arguments"}: ${this.arguments.map((t)=>JSON.stringify(t)).join(", ")}`}};fr=class fr extends Qo(`${at}/InvalidValue`)("InvalidValue",{option:Q,value:Q,expected:Q,kind:kt([et("flag"),et("argument")])}){[at]=at;get message(){let e=this.expected.startsWith("Expected ")||this.expected.startsWith("Expected:")?this.expected:`Expected: ${this.expected}`;if(this.kind==="argument")return`Invalid value for argument <${this.option}>: "${this.value}". ${e}`;if(this.value.length===0)return`Missing value for flag --${this.option}. ${e}`;return`Invalid value for flag --${this.option}: "${this.value}". ${e}`}};Wy=class Wy extends Qo(`${at}/UnknownSubcommand`)("UnknownSubcommand",{subcommand:Q,parent:cr(je(Q)),suggestions:je(Q)}){[at]=at;get message(){let e=this.suggestions.length>0?`
|
|
77
74
|
|
|
78
75
|
Did you mean this?
|
|
79
76
|
${this.suggestions.join(`
|
|
80
|
-
`)}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}};
|
|
77
|
+
`)}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}};rj=class rj extends Qo(`${at}/UserError`)("UserError",{cause:pI(),userMessage:vi(Q)}){[at]=at;[_c]=!0;get message(){if(this.userMessage)return this.userMessage;if(typeof this.cause==="string"&&this.cause)return this.cause;if(this.cause instanceof Error&&this.cause.message)return this.cause.message;return"An error occurred"}};Ooe=kt([ru,Ly,Sm,By,Hy,fr,Wy,rj]);Ha=class Ha extends Qo(`${at}/ShowHelp`)("ShowHelp",{commandPath:je(Q),errors:je(Ooe)}){[at]=at;[Og]=this.errors.length?1:0;[_c]=!1;get message(){return"Help requested"}}});var oj,Poe=(e)=>{let t=[],n=0,r=0;while((r=e.indexOf(".",r))!==-1){if(r===0||e[r-1]!=="\\")t.push(e.slice(n,r)),n=r+1;r++}return t.push(e.slice(n)),t},Roe=(e)=>e.length>=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")),v0=(e)=>{let t=(e??"").trim();if(Roe(t)){if(t[0]==="'")t=t.slice(1,-1);try{return JSON.parse(t)}catch{return t}}let n=!1,r="";for(let o of t)if(n)r+=o===";"||o==="#"||o==="\\"?o:`\\${o}`,n=!1;else if(o===";"||o==="#")break;else if(o==="\\")n=!0;else r+=o;return r.trim()},sj=(e)=>{let t=Object.create(null),n=t,r=/^\[([^\]]*)\]\s*$/,o=/^([^=]+)(=(.*))?$/;for(let i of e.split(/[\r\n]+/g)){if(i.length===0||/^\s*(?:[;#]|$)/.test(i))continue;let a=r.exec(i);if(a!==null){let y=v0(a[1]);if(y==="__proto__")n=Object.create(null);else n=t[y]??=Object.create(null);continue}let c=o.exec(i);if(c===null)continue;let u=v0(c[1]),l=u.length>2&&u.endsWith("[]"),f=l?u.slice(0,-2):u;if(f==="__proto__")continue;let d=c[2]===void 0?!0:v0(c[3]),m=d==="true"||d==="false"||d==="null"?JSON.parse(d):d;if(l){if(!oj.call(n,f))n[f]=[];else if(!Array.isArray(n[f]))n[f]=[n[f]]}if(Array.isArray(n[f]))n[f].push(m);else n[f]=m}let s=[];for(let i of Object.keys(t)){if(typeof t[i]!=="object"||t[i]===null||Array.isArray(t[i]))continue;let a=Poe(i),c=a.pop(),u=c.replace(/\\\./g,".");n=t;for(let l of a){if(l==="__proto__")continue;if(!oj.call(n,l)||typeof n[l]!=="object"||n[l]===null)n[l]=Object.create(null);n=n[l]}if(n===t&&u===c)continue;n[u]=t[i],s.push(i)}for(let i of s)delete t[i];return t};var ij=v(()=>{oj=Object.prototype.hasOwnProperty});class uj{root=bm();input;current=this.root;index=0;line=1;column=1;explicitTables=new Set;constructor(e){this.input=e}parse(){while(!0){if(this.skipDocumentWhitespace(),this.done)return this.root;if(this.peek()==="[")this.parseHeader();else{let e=this.parseKeyPath("=");this.skipInlineWhitespace(),this.expect("="),this.skipInlineWhitespace(),this.assign(this.current,e,this.parseValue()),this.finishStatement()}}}parseHeader(){this.expect("[");let e=this.peek()==="[";if(e)this.advance();this.skipInlineWhitespace();let t=this.parseKeyPath("]");if(this.skipInlineWhitespace(),this.expect("]"),e)this.expect("]");this.finishStatement();let n=JSON.stringify(t);if(!e&&this.explicitTables.has(n))this.fail(`Cannot redefine table '${t.join(".")}'`);if(!e)this.explicitTables.add(n);this.current=this.resolveTable(t,e)}resolveTable(e,t){let n=this.root;for(let r=0;r<e.length;r++){let o=e[r],s=r===e.length-1,i=n[o];if(s&&t){if(i===void 0)i=[],n[o]=i;if(!Array.isArray(i))this.fail(`Cannot redefine existing key '${e.slice(0,r+1).join(".")}'`);let a=bm();return i.push(a),a}if(i===void 0)i=bm(),n[o]=i;if(Array.isArray(i))i=i[i.length-1];if(!cj(i))this.fail(`Cannot redefine existing key '${e.slice(0,r+1).join(".")}'`);n=i}return n}assign(e,t,n){let r=e;for(let s=0;s<t.length-1;s++){let i=t[s],a=r[i];if(a===void 0){let c=bm();r[i]=c,r=c}else if(cj(a))r=a;else this.fail(`Cannot redefine existing key '${t.slice(0,s+1).join(".")}'`)}let o=t[t.length-1];if(aj.call(r,o))this.fail(`Cannot redefine existing key '${t.join(".")}'`);r[o]=n}parseKeyPath(e){let t=[];while(!0){this.skipInlineWhitespace();let n=this.peek(),r;if(n==='"')r=this.parseBasicString(!1);else if(n==="'")r=this.parseLiteralString(!1);else{let o=this.index;while(/[A-Za-z0-9_-]/.test(this.peek()))this.advance();r=this.input.slice(o,this.index)}if(r.length===0)this.fail("Expected a key");if(t.push(r),this.skipInlineWhitespace(),this.peek()==="."){this.advance();continue}if(this.peek()!==e)this.fail(`Expected '${e}'`);return t}}parseValue(){let e=this.peek();if(e==='"')return this.parseBasicString(this.input.startsWith('"""',this.index));if(e==="'")return this.parseLiteralString(this.input.startsWith("'''",this.index));if(e==="[")return this.parseArray();if(e==="{")return this.parseInlineTable();let t=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)/.exec(this.input.slice(this.index));if(t!==null)return this.advance(t[0].length),this.parseDate(`${t[1]}T${t[2]}`);let n=this.index;while(!this.done&&!/[\s,#\]}]/.test(this.peek()))this.advance();let r=this.input.slice(n,this.index);if(r==="true")return!0;if(r==="false")return!1;if(r.length===0)this.fail("Expected a value");let o=this.parseDate(r);if(o!==void 0)return o;let s=this.parseNumber(r);if(s!==void 0)return s;this.fail(`Invalid value '${r}'`)}parseDate(e){if(new RegExp("^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:[Zz]|[+-]\\d{2}:\\d{2})$").test(e)){let r=new Date(e.replace("t","T").replace("z","Z"));if(Number.isNaN(r.getTime()))this.fail(`Invalid date-time '${e}'`);return r}if(new RegExp("^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?$").test(e)||new RegExp("^\\d{4}-\\d{2}-\\d{2}$").test(e)||new RegExp("^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?$").test(e))return e.replace("t","T");return}parseNumber(e){let t=e.replace(/_/g,"");if(/^[+-]?(?:inf|nan)$/.test(e)){if(t.endsWith("nan"))return Number.NaN;return t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}if(/^0x[0-9A-Fa-f](?:_?[0-9A-Fa-f])*$/.test(e))return Number.parseInt(t.slice(2),16);if(/^0o[0-7](?:_?[0-7])*$/.test(e))return Number.parseInt(t.slice(2),8);if(/^0b[01](?:_?[01])*$/.test(e))return Number.parseInt(t.slice(2),2);if(/^[+-]?(?:0|[1-9](?:_?\d)*)$/.test(e))return Number(t);if(/^[+-]?(?:(?:0|[1-9](?:_?\d)*)\.\d(?:_?\d)*(?:[eE][+-]?\d(?:_?\d)*)?|(?:0|[1-9](?:_?\d)*)[eE][+-]?\d(?:_?\d)*)$/.test(e))return Number(t);return}parseBasicString(e){if(this.expect('"'),e){if(this.expect('"'),this.expect('"'),this.peek()===`
|
|
81
78
|
`)this.advance()}let t="";while(!this.done){if(e&&this.input.startsWith('"""',this.index))return this.advance(3),t;let n=this.peek();if(!e&&n==='"')return this.advance(),t;if(!e&&(n===`
|
|
82
79
|
`||n==="\r"))this.fail("Basic strings cannot contain newlines");if(n!=="\\"){t+=n,this.advance();continue}if(this.advance(),e&&/[ \t\r\n]/.test(this.peek())){while(/[ \t]/.test(this.peek()))this.advance();if(this.peek()!==`
|
|
83
80
|
`&&this.peek()!=="\r")this.fail("Invalid multiline string continuation");while(/[ \t\r\n]/.test(this.peek()))this.advance();continue}let r=this.peek();this.advance();let o={b:"\b",t:"\t",n:`
|
|
84
|
-
`,f:"\f",r:"\r",'"':'"',"\\":"\\"};if(
|
|
81
|
+
`,f:"\f",r:"\r",'"':'"',"\\":"\\"};if(aj.call(o,r))t+=o[r];else if(r==="u"||r==="U"){let s=r==="u"?4:8,i=this.input.slice(this.index,this.index+s);if(!new RegExp(`^[0-9A-Fa-f]{${s}}$`).test(i))this.fail("Invalid unicode escape");t+=String.fromCodePoint(Number.parseInt(i,16)),this.advance(s)}else this.fail(`Invalid escape '\\${r}'`)}this.fail("Unterminated basic string")}parseLiteralString(e){if(this.expect("'"),e){if(this.expect("'"),this.expect("'"),this.peek()===`
|
|
85
82
|
`)this.advance()}let t=this.index;while(!this.done){if(e&&this.input.startsWith("'''",this.index)){let n=this.input.slice(t,this.index);return this.advance(3),n}if(!e&&this.peek()==="'"){let n=this.input.slice(t,this.index);return this.advance(),n}if(!e&&(this.peek()===`
|
|
86
|
-
`||this.peek()==="\r"))this.fail("Literal strings cannot contain newlines");this.advance()}this.fail("Unterminated literal string")}parseArray(){this.expect("[");let e=[];while(!0){if(this.skipArrayWhitespace(),this.peek()==="]")return this.advance(),e;if(e.push(this.parseValue()),this.skipArrayWhitespace(),this.peek()==="]")return this.advance(),e;this.expect(",")}}parseInlineTable(){this.expect("{");let e=
|
|
83
|
+
`||this.peek()==="\r"))this.fail("Literal strings cannot contain newlines");this.advance()}this.fail("Unterminated literal string")}parseArray(){this.expect("[");let e=[];while(!0){if(this.skipArrayWhitespace(),this.peek()==="]")return this.advance(),e;if(e.push(this.parseValue()),this.skipArrayWhitespace(),this.peek()==="]")return this.advance(),e;this.expect(",")}}parseInlineTable(){this.expect("{");let e=bm();if(this.skipInlineWhitespace(),this.peek()==="}")return this.advance(),e;while(!0){let t=this.parseKeyPath("=");if(this.skipInlineWhitespace(),this.expect("="),this.skipInlineWhitespace(),this.assign(e,t,this.parseValue()),this.skipInlineWhitespace(),this.peek()==="}")return this.advance(),e;if(this.expect(","),this.skipInlineWhitespace(),this.peek()==="}")this.fail("Inline tables cannot end with a trailing comma")}}skipDocumentWhitespace(){while(!this.done)if(/[ \t\r\n]/.test(this.peek()))this.advance();else if(this.peek()==="#")this.skipComment();else return}skipInlineWhitespace(){while(this.peek()===" "||this.peek()==="\t")this.advance()}skipArrayWhitespace(){while(!this.done)if(/[ \t\r\n]/.test(this.peek()))this.advance();else if(this.peek()==="#")this.skipComment();else return}finishStatement(){if(this.skipInlineWhitespace(),this.peek()==="#")this.skipComment();if(!this.done&&this.peek()!==`
|
|
87
84
|
`&&this.peek()!=="\r")this.fail("Expected the end of the line")}skipComment(){while(!this.done&&this.peek()!==`
|
|
88
85
|
`)this.advance()}expect(e){if(this.peek()!==e)this.fail(`Expected '${e}'`);this.advance()}advance(e=1){for(let t=0;t<e;t++){if(this.input[this.index]===`
|
|
89
|
-
`)this.line++,this.column=1;else this.column++;this.index++}}peek(){return this.input[this.index]??""}get done(){return this.index>=this.input.length}fail(e){throw SyntaxError(`${e} at line ${this.line}, column ${this.column}`)}}var
|
|
86
|
+
`)this.line++,this.column=1;else this.column++;this.index++}}peek(){return this.input[this.index]??""}get done(){return this.index>=this.input.length}fail(e){throw SyntaxError(`${e} at line ${this.line}, column ${this.column}`)}}var aj,bm=()=>Object.create(null),cj=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof Date),lj=(e)=>new uj(e.replace(/^\uFEFF/,"")).parse();var fj=v(()=>{aj=Object.prototype.hasOwnProperty});class mj{input;anchors;index=0;constructor(e,t){this.input=e,this.anchors=t}parse(){let e=this.parseValue();if(this.skipWhitespace(),this.index!==this.input.length)this.fail("Unexpected flow collection content");return e}parseValue(){this.skipWhitespace();let e=this.peek();if(e==="[")return this.parseSequence();if(e==="{")return this.parseMapping();if(e==='"'||e==="'")return zy(this.readQuoted(e));if(e==="*"){this.index++;let t=this.readUntil(/[,\]}\s]/);if(!this.anchors.has(t))this.fail(`Unknown alias '*${t}'`);return this.anchors.get(t)}return zy(this.readUntil(/[,\]}]/).trim())}parseSequence(){this.expect("[");let e=[];if(this.skipWhitespace(),this.peek()==="]")return this.index++,e;while(!0){if(e.push(this.parseValue()),this.skipWhitespace(),this.peek()==="]")return this.index++,e;if(this.expect(","),this.skipWhitespace(),this.peek()==="]")return this.index++,e}}parseMapping(){this.expect("{");let e={};if(this.skipWhitespace(),this.peek()==="}")return this.index++,e;while(!0){let t=this.parseKey();if(this.skipWhitespace(),this.expect(":"),I0.call(e,t))this.fail(`Duplicate key '${t}'`);if(dj(e,t,this.parseValue()),this.skipWhitespace(),this.peek()==="}")return this.index++,e;if(this.expect(","),this.skipWhitespace(),this.peek()==="}")return this.index++,e}}parseKey(){this.skipWhitespace();let e=this.peek();if(e==='"'||e==="'")return pj(this.readQuoted(e));return this.readUntil(/:/).trim()}readQuoted(e){let t=this.index++,n=!1;while(this.index<this.input.length){let r=this.input[this.index++];if(e==='"'&&n)n=!1;else if(e==='"'&&r==="\\")n=!0;else if(e==="'"&&r===e&&this.input[this.index]===e)this.index++;else if(r===e)return this.input.slice(t,this.index)}this.fail("Unterminated quoted scalar")}readUntil(e){let t=this.index;while(this.index<this.input.length&&!e.test(this.peek()))this.index++;return this.input.slice(t,this.index)}skipWhitespace(){while(/\s/.test(this.peek()))this.index++}expect(e){if(this.peek()!==e)this.fail(`Expected '${e}'`);this.index++}peek(){return this.input[this.index]??""}fail(e){throw SyntaxError(`${e} at flow offset ${this.index}`)}}class hj{lines;index=0;anchors=new Map;constructor(e){this.lines=e}parse(){if(this.skipIgnored(),this.index>=this.lines.length)return null;let e=this.parseNode(this.lines[this.index].indent);if(this.skipIgnored(),this.index<this.lines.length)this.fail(this.lines[this.index],"Unexpected content");return e}parseNode(e){this.skipIgnored();let t=this.lines[this.index];if(t===void 0)return null;if(t.indent!==e)this.fail(t,`Expected indentation of ${e} spaces`);if(t.text==="-"||t.text.startsWith("- "))return this.parseSequence(e);if(qy(t.text)!==-1)return this.parseMapping(e);return this.index++,this.parseInlineValue(t.text)}parseMapping(e){let t={};while(!0){this.skipIgnored();let n=this.lines[this.index];if(n===void 0||n.indent<e)return t;if(n.indent>e)this.fail(n,`Unexpected indentation of ${n.indent} spaces`);let r=qy(n.text);if(r===-1)return t;this.index++,this.parseMappingEntry(t,n.text,r,e,n)}}parseMappingEntry(e,t,n,r,o){let s=pj(t.slice(0,n).trim()),i=t.slice(n+1).trim(),a=this.parseNodeValue(i,r);if(I0.call(e,s))this.fail(o,`Duplicate key '${s}'`);dj(e,s,a)}parseSequence(e){let t=[];while(!0){this.skipIgnored();let n=this.lines[this.index];if(n===void 0||n.indent<e)return t;if(n.indent>e)this.fail(n,`Unexpected indentation of ${n.indent} spaces`);if(n.text!=="-"&&!n.text.startsWith("- "))return t;this.index++;let r=n.text.slice(1).trimStart(),o=qy(r);if(o===-1){t.push(this.parseNodeValue(r,e));continue}let s={};this.parseMappingEntry(s,r,o,e+2,n);while(!0){this.skipIgnored();let i=this.lines[this.index];if(i===void 0||i.indent<=e)break;if(i.indent!==e+2)this.fail(i,`Expected indentation of ${e+2} spaces`);let a=qy(i.text);if(a===-1)this.fail(i,"Expected a mapping entry");this.index++,this.parseMappingEntry(s,i.text,a,e+2,i)}t.push(s)}}parseNodeValue(e,t){let n=e,r,o=/^&([^\s,[\]{}]+)(?:\s+(.*))?$/.exec(n);if(o!==null)r=o[1],n=o[2]??"";let s;if(n.length===0){this.skipIgnored();let i=this.lines[this.index];s=i!==void 0&&i.indent>t?this.parseNode(i.indent):null}else if(/^[|>](?:[1-9]?[+-]?|[+-]?[1-9]?)$/.test(n))s=this.parseBlockScalar(n,t);else s=this.parseInlineValue(n);if(r!==void 0)this.anchors.set(r,s);return s}parseInlineValue(e){if(e.startsWith("*")){let t=e.slice(1).trim();if(!this.anchors.has(t))throw SyntaxError(`Unknown YAML alias '*${t}'`);return this.anchors.get(t)}if(e.startsWith("[")||e.startsWith("{"))return new mj(e,this.anchors).parse();return zy(e)}parseBlockScalar(e,t){let n=e[0],r=e.includes("-")?"strip":e.includes("+")?"keep":"clip",o=Number.parseInt(e.replace(/[^1-9]/g,""),10),s=this.index,i=s,a=Number.isNaN(o)?Number.POSITIVE_INFINITY:t+o;while(i<this.lines.length){let l=this.lines[i];if(l.raw.trim().length!==0&&l.indent<=t)break;if(l.raw.trim().length!==0)a=Math.min(a,l.indent);i++}if(a===Number.POSITIVE_INFINITY)a=t+1;let c=[];for(let l=s;l<i;l++){let f=this.lines[l];if(f.raw.trim().length===0)c.push("");else if(f.indent<a)this.fail(f,`Expected block scalar indentation of ${a} spaces`);else c.push(f.raw.slice(a))}this.index=i;let u="";if(n==="|")u=c.join(`
|
|
90
87
|
`);else for(let l=0;l<c.length;l++)if(u+=c[l],l<c.length-1)u+=c[l].length===0||c[l+1].length===0?`
|
|
91
88
|
`:" ";if(r==="keep")return`${u}
|
|
92
89
|
`;return u=u.replace(/\n+$/,""),r==="strip"?u:`${u}
|
|
93
|
-
`}skipIgnored(){while(this.index<this.lines.length){let e=this.lines[this.index];if(e.text.length===0||e.text.startsWith("%")||e.text==="---")this.index++;else if(e.text==="..."){this.index++;while(this.index<this.lines.length&&this.lines[this.index].text.length===0)this.index++;if(this.index<this.lines.length)this.fail(this.lines[this.index],"Multiple YAML documents are not supported")}else return}}fail(e,t){throw SyntaxError(`${t} at line ${e.number}`)}}var
|
|
94
|
-
`,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"};if(
|
|
90
|
+
`}skipIgnored(){while(this.index<this.lines.length){let e=this.lines[this.index];if(e.text.length===0||e.text.startsWith("%")||e.text==="---")this.index++;else if(e.text==="..."){this.index++;while(this.index<this.lines.length&&this.lines[this.index].text.length===0)this.index++;if(this.index<this.lines.length)this.fail(this.lines[this.index],"Multiple YAML documents are not supported")}else return}}fail(e,t){throw SyntaxError(`${t} at line ${e.number}`)}}var I0,dj=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n})},Doe=(e)=>{let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(t==='"'){if(n)n=!1;else if(o==="\\")n=!0;else if(o===t)t=void 0}else if(t==="'"){if(o===t&&e[r+1]===t)r++;else if(o===t)t=void 0}else if(o==="'"||o==='"')t=o;else if(o==="#"&&(r===0||/\s/.test(e[r-1])))return e.slice(0,r).trimEnd()}return e.trimEnd()},qy=(e)=>{let t,n=!1,r=0;for(let o=0;o<e.length;o++){let s=e[o];if(t==='"'){if(n)n=!1;else if(s==="\\")n=!0;else if(s===t)t=void 0}else if(t==="'"){if(s===t&&e[o+1]===t)o++;else if(s===t)t=void 0}else if(s==="'"||s==='"')t=s;else if(s==="["||s==="{")r++;else if(s==="]"||s==="}")r--;else if(s===":"&&r===0&&(e[o+1]===void 0||/\s/.test(e[o+1])))return o}return-1},Noe=(e)=>{if(!e.endsWith('"')||e.length<2)throw SyntaxError("Unterminated double-quoted YAML string");let t="";for(let n=1;n<e.length-1;n++){let r=e[n];if(r!=="\\"){t+=r;continue}let o=e[++n],s={"0":"\x00",a:"\x07",b:"\b",t:"\t",n:`
|
|
91
|
+
`,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"};if(I0.call(s,o)){t+=s[o];continue}if(o==="x"||o==="u"||o==="U"){let i=o==="x"?2:o==="u"?4:8,a=e.slice(n+1,n+1+i);if(!new RegExp(`^[0-9A-Fa-f]{${i}}$`).test(a))throw SyntaxError("Invalid unicode escape in YAML string");t+=String.fromCodePoint(Number.parseInt(a,16)),n+=i;continue}throw SyntaxError(`Invalid YAML escape '\\${o}'`)}return t},zy=(e)=>{let t=e.trim();if(t.length===0)return null;if(t.startsWith('"')&&t.endsWith('"'))return Noe(t);if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1).replace(/''/g,"'");if(/^(?:null|~)$/i.test(t))return null;if(/^true$/i.test(t))return!0;if(/^false$/i.test(t))return!1;if(/^[+-]?\.inf$/i.test(t))return t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY;if(/^\.nan$/i.test(t))return Number.NaN;let n=t.replace(/_/g,"");if(/^[+-]?0x[0-9a-f]+$/i.test(n))return(n[0]==="-"?-1:1)*Number.parseInt(n.replace(/^[+-]?0x/i,""),16);if(/^[+-]?0o[0-7]+$/i.test(n))return(n[0]==="-"?-1:1)*Number.parseInt(n.replace(/^[+-]?0o/i,""),8);if(/^[+-]?(?:0|[1-9]\d*)$/.test(n)||/^[+-]?(?:(?:0|[1-9]\d*)?\.\d+|(?:0|[1-9]\d*)\.?\d*[eE][+-]?\d+)$/.test(n))return Number(n);return t},pj=(e)=>{let t=zy(e);return t===null||t===void 0?"":String(t)},A0=(e)=>{let n=e.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
95
92
|
`).split(`
|
|
96
|
-
`).map((r,o)=>{let s=/^( *)/.exec(r)[1].length;if(r.slice(0,s+1).includes("\t"))throw SyntaxError(`Tabs cannot be used for YAML indentation at line ${o+1}`);return{raw:r,text:
|
|
97
|
-
${n}`,t)+
|
|
98
|
-
`))}):"";return
|
|
99
|
-
`+
|
|
100
|
-
`))+
|
|
101
|
-
`))}})},
|
|
102
|
-
`));let s=
|
|
103
|
-
`+
|
|
104
|
-
`))+
|
|
105
|
-
`)},
|
|
106
|
-
${c}`,o)+i})
|
|
107
|
-
`));let s=
|
|
108
|
-
`+
|
|
109
|
-
`))+
|
|
110
|
-
`}),
|
|
111
|
-
`}),
|
|
112
|
-
`}),
|
|
113
|
-
`+r}),
|
|
114
|
-
`}),
|
|
115
|
-
`}),
|
|
116
|
-
`}),
|
|
93
|
+
`).map((r,o)=>{let s=/^( *)/.exec(r)[1].length;if(r.slice(0,s+1).includes("\t"))throw SyntaxError(`Tabs cannot be used for YAML indentation at line ${o+1}`);return{raw:r,text:Doe(r.slice(s)),indent:s,number:o+1}});return new hj(n).parse()};var gj=v(()=>{I0=Object.prototype.hasOwnProperty});var Uoe="~effect/cli/Primitive",Loe,xj,yj,Vy=(e)=>e._tag==="Boolean",Os=(e,t)=>Object.assign(Object.create(Loe),{_tag:e,parse:t}),Ky=(e,t)=>{let n=lm(t),r=Ai(n);return Os(e,(o)=>Gt(r(o),(s)=>s.message))},Sj,Ej,bj,wj,kj,Cj=(e)=>{let t=new Map(e),n=e.map(([o])=>j(o)).join(" | "),r=Os("Choice",(o)=>{if(t.has(o))return A(t.get(o));return R(n)});return Object.assign(r,{choiceKeys:e.map(([o])=>o)})},vj=(e,t)=>{let n=Os("Path",q(function*(r){let o=yield*xa,s=yield*hs,i=s.isAbsolute(r)?r:s.resolve(r),a=yield*Gt(o.exists(i),(c)=>`Failed to check path existence: ${c.message}`);if(t===!0&&!a)return yield*R(`Path does not exist: ${i}`);if(a&&e!=="either"){let c=yield*Gt(o.stat(i),(u)=>`Failed to stat path: ${u.message}`);if(e==="file"&&c.type!=="File")return yield*R(`Path is not a file: ${i}`);if(e==="directory"&&c.type!=="Directory")return yield*R(`Path is not a directory: ${i}`)}return i}));return Object.assign(n,{pathType:e})},Ij,T0,Boe,_0=(e)=>Os("FileParse",q(function*(t){let n=e?.format??t.split(".").pop(),r=Boe[n];if(r===void 0)return yield*R(`Unsupported file format: ${n}`);let o=yield*T0.parse(t);return yield*Xt({try:()=>r(o),catch:(s)=>`Failed to parse '.${n}' file content: ${s}`})})),Aj=(e,t)=>{let n=Ai(e);return Os("FileSchema",q(function*(r){let o=yield*_0(t).parse(r);return yield*Gt(n(o),(s)=>t?.errorFormatter?.(s.issue)??s.toString())}))},Tj,_j,wm=(e)=>{switch(e._tag){case"Boolean":return"boolean";case"String":return"string";case"Integer":return"integer";case"Float":return"number";case"Date":return"date";case"Path":return"path";case"Choice":return"choice";case"Redacted":return"string";case"FileText":return"file";case"FileParse":return"file";case"FileSchema":return"file";case"KeyValuePair":return"key=value";case"None":return"none";default:return"value"}},Fi=(e)=>e._tag==="Choice"?e.choiceKeys:void 0,O0=(e)=>e._tag==="Path"?e.pathType:void 0;var gf=v(()=>{k0();Re();zg();Zn();ne();Vg();Kp();Qc();ij();fj();gj();Loe={[Uoe]:{_A:L}},xj=Zp(b0),yj=Zp(w0),Sj=Ky("Boolean",tj),Ej=Ky("Float",Cr),bj=Ky("Integer",Cs),wj=Ky("Date",vr),kj=Os("String",(e)=>A(e)),Ij=Os("Redacted",(e)=>A(Ci(e))),T0=Os("FileText",q(function*(e){let t=yield*xa,n=yield*hs,r=n.isAbsolute(e)?e:n.resolve(e);if(!(yield*Gt(t.exists(r),(a)=>`Failed to check file existence: ${a.message}`)))return yield*R(`File does not exist: ${r}`);if((yield*Gt(t.stat(r),(a)=>`Failed to stat file: ${a.message}`)).type!=="File")return yield*R(`Path is not a file: ${r}`);return yield*Gt(t.readFileString(r),(a)=>`Failed to read file: ${a.message}`)})),Boe={ini:(e)=>sj(e),json:(e)=>JSON.parse(e),toml:(e)=>lj(e),yml:(e)=>A0(e),yaml:(e)=>A0(e)},Tj=Os("KeyValuePair",q(function*(e){let t=e.split("=");if(t.length!==2)return yield*R(`Invalid key=value format. Expected format: key=value, got: ${e}`);let[n,r]=t;if(!n||!r)return yield*R(`Invalid key=value format. Both key and value must be non-empty. Got: ${e}`);return{[n]:r}})),_j=Os("None",()=>R("This option does not accept values"))});var Mi="\x1B[1m",Oj="\x1B[3m",ou="\x1B[4m",Pj="\x1B[9m",Rj="\x1B[?25h",Cm="\x1B[?25l",su="\x1B[G",Gy="\x1B[s",Jy="\x1B[u",Wa="\x1B[2K",Fj="\x07",Qy="\x1B[31m",Zy="\x1B[32m",Mj="\x1B[35m",iu="\x1B[37m",vm="\x1B[90m",xf="\x1B[96m",yt=(e,...t)=>`${t.flat().join("")}${e}\x1B[0m`,Ps=(...e)=>e,Dj=(e,t)=>{if(t===void 0)return`\x1B[${Math.max(e+1,0)}G`;return`\x1B[${t+1};${Math.max(e+1,0)}H`},Nj=(e=1)=>`\x1B[${e}B`,$j=(e,t=0)=>{let n="";if(t<0)n+=`\x1B[${-t}A`;if(t>0)n+=`\x1B[${t}B`;if(e>0)n+=`\x1B[${e}C`;if(e<0)n+=`\x1B[${-e}D`;return n},Uj=(e)=>{let t="";for(let n=0;n<e;n++)t+="\x1B[2K"+(n<e-1?"\x1B[1A":"");if(e>0)t+="\x1B[G";return t};class Rs{token;date;parts;locales;constructor(e){this.token=e.token,this.locales=e.locales,this.date=e.date||new Date,this.parts=e.parts||[this]}isToken(){return!1}nextPart(){let e=It(mh(this.parts,(t)=>t===this),()=>0);return DE(this.parts.slice(e+1),(t)=>!t.isToken())}previousPart(){let e=mh(this.parts,(t)=>t===this);if(Ce(e))return NE(this.parts.slice(0,e.value),(t)=>!t.isToken());return P()}toString(){return String(this.date)}}var zj="~effect/cli/Prompt",Vj=(e)=>D(e,zj),Kj,Hoe,Woe=(e)=>({...process.platform==="win32"?Hoe:Kj,...e}),joe,Sn=(e)=>ae(joe,(t)=>({...t,...e.theme})),qoe=(e)=>yt(e,Mi),R0=(e,t)=>yt(e,Ps(Oj,t)),ze=(e,...t)=>e.length===0?"":yt(e,...t),ja=(e,t)=>e.length===0?t:e+" "+t,zoe=(e,t,n)=>{let r=Math.max(e.arrowUp.length,e.arrowDown.length);if(t)return e.arrowUp.padEnd(r);if(n)return e.arrowDown.padEnd(r);return" ".repeat(r)},F0=(e)=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}},n={value:t.initial};return au(n,{render:tse(t),process:(r)=>ose(r,t.initial),clear:Yoe(t)})},au=(e,...t)=>{let[n,r]=t.length===1?[void 0,t[0]]:[t[0],t[1]],o=Object.create(N0);return o._tag="Loop",o.initialState=e,o.render=r.render,o.process=r.process,o.clear=r.clear,o.events=n,o},Gj=(e)=>{let t={initial:new Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:A,...e,locales:{...hse,...e.locales}},n=Sse(t.dateMask,t.initial,t.locales),r=n.findIndex((s)=>!s.isToken()),o={dateParts:n,typed:"",cursor:r,value:t.initial,error:P()};return au(o,{render:gse(t),process:xse(t),clear:sse(t)})},Voe,Jj=(e)=>{let t={default:0,min:Number.NEGATIVE_INFINITY,max:Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,precision:2,validate:(o)=>{if(o<t.min)return R(`${o} must be greater than or equal to ${t.min}`);if(o>t.max)return R(`${o} must be less than or equal to ${t.max}`);return A(o)},...e},n=e.default===void 0?"":`${t.default}`,r={cursor:n.length,value:n,error:P()};return au(r,{render:Ise(t),process:Ase(t),clear:cq(t)})},M0=(e)=>{let t={default:0,min:Number.NEGATIVE_INFINITY,max:Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,validate:(o)=>{if(o<t.min)return R(`${o} must be greater than or equal to ${t.min}`);if(o>t.max)return R(`${o} must be less than or equal to ${t.max}`);return A(o)},...e},n=e.default===void 0?"":`${t.default}`,r={cursor:n.length,value:n,error:P()};return au(r,{render:Cse(t),process:vse(t),clear:cq(t)})},Koe,Qj=(e)=>gq(e,"password").pipe(Koe(Ci)),Jn,Goe=(e)=>{let t=0,n=-1;for(let r=0;r<e.length;r++)if(e[r].selected===!0){if(n!==-1)throw Error("InvalidArgumentException: only a single choice can be selected by default for Prompt.select");n=r}if(n!==-1)t=n;return t},D0=(e)=>{let t={maxPerPage:10,...e},n=Goe(t.choices);return au(n,{render:Dse(t),process:$se(t),clear:Nse(t)})},Joe=(e)=>{let t=Object.create(N0);return t._tag="Succeed",t.value=e,t},Zj=(e)=>gq(e,"text"),Yj=(e)=>{let t={initial:!1,active:"on",inactive:"off",...e};return au(t.initial,{render:eie(t),process:tie,clear:()=>Zse(t)})},N0,P0=(e,t,n)=>He(()=>{let r=e;switch(r._tag){case"Loop":return Qoe(r,t,n);case"OnSuccess":return se(P0(r.prompt,t,n),(o)=>P0(r.onSuccess(o),t,n));case"Succeed":return A(r.value)}}),Qoe,z,yf=(e,t)=>{if(t===0)return Wa+Dj(0);let n=0,r=e.split(uu);for(let o of r)n+=1+Math.floor(Math.max(o.length-1,0)/t);return Uj(n)},Zoe=(e,t)=>{let n=e.split(uu);return t===0?n.length:To(sn(n,(r)=>Math.ceil(r.length/t)),Qf(0,(r,o)=>r+o))},$0=(e,t,n)=>{if(n!==void 0&&n.length>0)return Nj(Zoe(n,t))+yf(`
|
|
94
|
+
${n}`,t)+yf(e,t);return yf(e,t)},cu,uu,Yoe=(e)=>q(function*(t,n){let o=yield*(yield*Zo).columns,s=yield*Sn(e),i=t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,a=U0(i,s.prefix,s.pointerSmall,e,{plain:!0}),c=yf(a,o),u=Wa+su;return c+u}),U0=(e,t,n,r,o)=>lu(e,r.message,t,n,o),Xoe,ese,tse=(e)=>(t,n)=>z.$match(n,{Beep:()=>A(cu),NextFrame:({state:r})=>Xoe(r,e),Submit:({value:r})=>ese(r,e)}),nse,rse,ose=(e,t)=>{let n=It(e.input,()=>"");if(e.key.name==="enter"||e.key.name==="return")return A(z.Submit({value:t}));if(nse.test(n.toLowerCase()))return A(z.Submit({value:!0}));if(rse.test(n.toLowerCase()))return A(z.Submit({value:!1}));return A(z.Beep())},sse=(e)=>q(function*(t,n){let o=yield*(yield*Zo).columns,s=yield*Sn(e),i=Wa+su,a=Qf(t.dateParts,"",(f,d)=>f+d.toString()),c=L0(s.prefix,s.pointerSmall,a,e,{plain:!0}),u=Ce(t.error)?Jf(t.error.value.split(uu),{onEmpty:()=>"",onNonEmpty:(f)=>ja(s.pointerSmall,f.join(`
|
|
95
|
+
`))}):"";return $0(c,o,u)+i}),ise=(e,t,n)=>{if(Ce(e.error)){let r=e.error.value.split(uu);if(hr(r)){let o=ze(t,n.errorColor),s=sn(r,(i)=>R0(i,n.errorColor));return Gy+`
|
|
96
|
+
`+ja(o,s.join(`
|
|
97
|
+
`))+Jy}}return""},Xj=(e,t,n=!1)=>Qf(e.dateParts,"",(r,o,s)=>{let i=o.toString();if(s===e.cursor&&!n){let a=Ps(ou,t.primaryColor);return r+yt(i,a)}return r+i}),L0=(e,t,n,r,o)=>lu(n,r.message,e,t,o),ase,cse,use=(e)=>(e.dateParts[e.cursor].increment(),z.NextFrame({state:{...e,typed:""}})),lse=(e)=>(e.dateParts[e.cursor].decrement(),z.NextFrame({state:{...e,typed:""}})),fse=(e)=>{let t=e.dateParts[e.cursor].previousPart();if(Ce(t))return z.NextFrame({state:{...e,typed:"",cursor:e.dateParts.indexOf(t.value)}});return z.Beep()},dse=(e)=>{let t=e.dateParts[e.cursor].nextPart();if(Ce(t))return z.NextFrame({state:{...e,typed:"",cursor:e.dateParts.indexOf(t.value)}});return z.Beep()},pse=(e)=>{let t=e.dateParts[e.cursor].nextPart(),n=ut(t,{onNone:()=>e.dateParts.findIndex((r)=>!r.isToken()),onSome:(r)=>e.dateParts.indexOf(r)});return z.NextFrame({state:{...e,cursor:n}})},mse=(e,t)=>{if(/\d/.test(e)){let n=t.typed+e;return t.dateParts[t.cursor].setValue(n),z.NextFrame({state:{...t,typed:n}})}return z.Beep()},hse,gse=(e)=>(t,n)=>z.$match(n,{Beep:()=>A(cu),NextFrame:({state:r})=>ase(r,e),Submit:()=>cse(t,e)}),xse=(e)=>(t,n)=>{switch(t.key.name){case"left":return A(fse(n));case"right":return A(dse(n));case"k":case"up":return A(use(n));case"j":case"down":return A(lse(n));case"tab":return A(pse(n));case"enter":case"return":return pa(e.validate(n.value),{onFailure:(r)=>z.NextFrame({state:{...n,error:F(r)}}),onSuccess:(r)=>z.Submit({value:r})});default:return A(mse(It(t.input,()=>""),n))}},yse,Bj,Sse=(e,t,n)=>{let r=[],o=null;while(o=yse.exec(e)){let i=o.shift(),a=o.findIndex((c)=>c!==void 0);if(a in Bj){let c=o[a]||i;r.push(Bj[a]({token:c,date:t,parts:r,locales:n}))}else r.push(new B0({token:o[a]||i,date:t,parts:r,locales:n}))}let s=r.reduce((i,a)=>{let c=i[i.length-1];if(a.isToken()&&c!==void 0&&c.isToken())c.setValue(a.token);else i.push(a);return i},cc());return r.splice(0,r.length,...s),r},B0,eq,tq,nq,rq,oq,sq,iq,aq,lu=(e,t,n,r,o)=>{let s=n.length===0?"":n+" ",i=(c)=>{let u=s+c;if(r.length>0)u+=" "+r;if(e.length>0)u+=" "+e;else if(r.length>0)u+=" ";return u},a=o?.plain===!0?(c)=>c:qoe;return Jf(t.split(uu),{onEmpty:()=>i(""),onNonEmpty:(c)=>{let u=sn(c,(l)=>a(l));return i(u.join(`
|
|
98
|
+
`))}})},Ese=(e,t,n,r)=>{if(!e.disabled&&e.description&&t){let o=n.descriptionSeparator+e.description;return r?.plain===!0?o:yt(o,n.mutedColor)}return""},cq=(e)=>q(function*(t,n){let o=yield*(yield*Zo).columns,s=yield*Sn(e),i=Wa+su,a=uq(t,s.pointerSmall,s,{plain:!0}),c=H0(t,s.prefix,s.pointerSmall,e,s,{plain:!0});return $0(c,o,a)+i}),bse=(e,t,n,r)=>{let o=e.value===""?"":`${e.value}`;if(t||r?.plain===!0)return o;let s=Ce(e.error)?n.errorColor:Ps(ou,n.primaryColor);return yt(o,s)},uq=(e,t,n,r)=>{if(Ce(e.error))return Jf(e.error.value.split(uu),{onEmpty:()=>"",onNonEmpty:(o)=>{if(r?.plain===!0)return ja(t,o.join(`
|
|
99
|
+
`));let s=ze(t,n.errorColor),i=sn(o,(a)=>R0(a,n.errorColor));return Gy+`
|
|
100
|
+
`+ja(s,i.join(`
|
|
101
|
+
`))+Jy}});return""},H0=(e,t,n,r,o,s,i=!1)=>{let a=bse(e,i,o,s);return lu(a,r.message,t,n,s)},lq,fq,dq=(e)=>{if(e.value.length<=0)return A(z.Beep());let t=e.value.slice(0,e.value.length-1);return A(z.NextFrame({state:{...e,value:t,error:P()}}))},pq=(e)=>A(z.NextFrame({state:{...e,cursor:0,value:"",error:P()}})),wse=(e,t)=>{if(t.value.length===0&&e==="-")return A(z.NextFrame({state:{...t,value:"-",error:P()}}));let n=Number.parseInt(t.value+e);if(Number.isNaN(n))return A(z.Beep());else return A(z.NextFrame({state:{...t,value:`${n}`,error:P()}}))},kse=(e,t)=>{if(e==="."&&t.value.includes("."))return A(z.Beep());if(t.value.length===0&&e==="-")return A(z.NextFrame({state:{...t,value:"-",error:P()}}));let n=Number.parseFloat(t.value+e);if(Number.isNaN(n))return A(z.Beep());else return A(z.NextFrame({state:{...t,value:e==="."?`${n}.`:t.value.includes(".")&&/^\d$/.test(e)?t.value+e:`${n}`,error:P()}}))},Cse=(e)=>(t,n)=>z.$match(n,{Beep:()=>A(cu),NextFrame:({state:r})=>lq(r,e),Submit:()=>fq(t,e)}),vse=(e)=>(t,n)=>{if(t.key.ctrl&&t.key.name==="u")return pq(n);switch(t.key.name){case"backspace":return dq(n);case"k":case"up":return A(z.NextFrame({state:{...n,value:n.value===""||n.value==="-"?`${e.incrementBy}`:`${Number.parseInt(n.value)+e.incrementBy}`,error:P()}}));case"j":case"down":return A(z.NextFrame({state:{...n,value:n.value===""||n.value==="-"?`-${e.decrementBy}`:`${Number.parseInt(n.value)-e.decrementBy}`,error:P()}}));case"enter":case"return":{let r=Number.parseInt(n.value);if(Number.isNaN(r))return A(z.NextFrame({state:{...n,error:F("Must provide an integer value")}}));else return pa(e.validate(r),{onFailure:(o)=>z.NextFrame({state:{...n,error:F(o)}}),onSuccess:(o)=>z.Submit({value:o})})}default:return wse(It(t.input,()=>""),n)}},Ise=(e)=>(t,n)=>z.$match(n,{Beep:()=>A(cu),NextFrame:({state:r})=>lq(r,e),Submit:()=>fq(t,e)}),Ase=(e)=>(t,n)=>{if(t.key.ctrl&&t.key.name==="u")return pq(n);switch(t.key.name){case"backspace":return dq(n);case"k":case"up":return A(z.NextFrame({state:{...n,value:n.value===""||n.value==="-"?`${e.incrementBy}`:`${Number.parseFloat(n.value)+e.incrementBy}`,error:P()}}));case"j":case"down":return A(z.NextFrame({state:{...n,value:n.value===""||n.value==="-"?`-${e.decrementBy}`:`${Number.parseFloat(n.value)-e.decrementBy}`,error:P()}}));case"enter":case"return":{let r=Number.parseFloat(n.value);if(Number.isNaN(r))return A(z.NextFrame({state:{...n,error:F("Must provide a floating point value")}}));else return se(we(()=>QR(r,e.precision)),(o)=>pa(e.validate(o),{onFailure:(s)=>z.NextFrame({state:{...n,error:F(s)}}),onSuccess:(s)=>z.Submit({value:s})}))}default:return kse(It(t.input,()=>""),n)}},W0=(e,t,n,r)=>lu("",n.message,e,t,r),Tse=(e,t,n,r,o,s)=>{let i=zoe(o,r===n.startIndex&&n.startIndex>0,r===n.endIndex-1&&n.endIndex<t.length);if(s?.plain===!0)return e===r?o.pointer+i:i+" ".repeat(o.pointer.length);if(t[r].disabled){let a=Ps(Mi,o.mutedColor);return e===r?ze(o.pointer,a)+i:i+" ".repeat(o.pointer.length)}return e===r?ze(o.pointer,o.primaryColor)+i:i+" ".repeat(o.pointer.length)},_se=(e,t,n,r)=>{if(r?.plain===!0)return e.title;let o=e.title;if(t)return e.disabled?yt(o,Ps(ou,n.mutedColor)):yt(o,Ps(ou,n.primaryColor));return e.disabled?yt(o,Ps(Pj,n.mutedColor)):o},mq=(e,t,n,r)=>{let o=t.choices,s=nie(e,o.length,t.maxPerPage),i=[];for(let a=s.startIndex;a<s.endIndex;a++){let c=o[a],u=e===a,l=Tse(e,o,s,a,n,r),f=_se(c,u,n,r),d=Ese(c,u,n,r);i.push(l+f+" "+d)}return i.join(`
|
|
102
|
+
`)},Ose,Pse,Rse=(e,t)=>{if(e===0)return A(z.NextFrame({state:t.length-1}));return A(z.NextFrame({state:e-1}))},Fse=(e,t)=>{if(e===t.length-1)return A(z.NextFrame({state:0}));return A(z.NextFrame({state:e+1}))},Mse=(e,t)=>A(z.NextFrame({state:(e+1)%t.length})),Dse=(e)=>(t,n)=>z.$match(n,{Beep:()=>A(cu),NextFrame:({state:r})=>Ose(r,e),Submit:()=>Pse(t,e)}),Nse=(e)=>q(function*(t,n){let o=yield*(yield*Zo).columns,s=yield*Sn(e),i=Wa+su,a=W0(s.prefix,s.pointerSmall,e,{plain:!0}),c=mq(t,e,s,{plain:!0});return yf(`${a}
|
|
103
|
+
${c}`,o)+i}),$se=(e)=>(t,n)=>{switch(t.key.name){case"k":case"up":return Rse(n,e.choices);case"j":case"down":return Fse(n,e.choices);case"tab":return Mse(n,e.choices);case"enter":case"return":{let r=e.choices[n];if(r.disabled)return A(z.Beep());return A(z.Submit({value:r.value}))}default:return A(z.Beep())}},Use,Lse=(e,t,n,r,o)=>{let s=e.value;if(o?.plain===!0)switch(t.type){case"hidden":return"";case"password":return n.passwordMask.repeat(s.length);case"text":return s}if(s.length===0)return"";let i=Ce(e.error)?n.errorColor:r?n.submittedColor:Ps(ou,n.primaryColor);switch(t.type){case"hidden":return"";case"password":return ze(n.passwordMask.repeat(s.length),i);case"text":return yt(s,i)}},hq=(e,t,n,r)=>{if(Ce(e.error))return Jf(e.error.value.split(uu),{onEmpty:()=>"",onNonEmpty:(o)=>{if(r?.plain===!0)return ja(t,o.join(`
|
|
104
|
+
`));let s=ze(t,n.errorColor),i=sn(o,(a)=>R0(a,n.errorColor));return Gy+`
|
|
105
|
+
`+ja(s,i.join(`
|
|
106
|
+
`))+Jy}});return""},j0=(e,t,n,r,o,s,i=!1)=>{let a=Lse(e,r,o,i,s);return lu(a,r.message,t,n,s)},Bse,Hse,Wse=(e)=>{if(e.cursor<=0)return A(z.Beep());let t=e.value.slice(0,e.cursor-1),n=e.value.slice(e.cursor),r=e.cursor-1,o=`${t}${n}`;return A(z.NextFrame({state:{...e,cursor:r,value:o,error:P()}}))},jse=(e)=>A(z.NextFrame({state:{...e,cursor:0,value:"",error:P()}})),qse=(e)=>{if(e.cursor<=0)return A(z.Beep());let t=e.cursor-1;return A(z.NextFrame({state:{...e,cursor:t,error:P()}}))},zse=(e)=>{if(e.cursor>=e.value.length)return A(z.Beep());let t=Math.min(e.cursor+1,e.value.length);return A(z.NextFrame({state:{...e,cursor:t,error:P()}}))},Hj=(e)=>A(z.NextFrame({state:{...e,cursor:0,error:P()}})),Wj=(e)=>A(z.NextFrame({state:{...e,cursor:e.value.length,error:P()}})),Vse=(e,t)=>{if(e.value===t.default)return A(z.Beep());let n=e.value.length===0?t.default:e.value;return A(z.NextFrame({state:{...e,value:n,cursor:n.length,error:P()}}))},Kse=(e,t)=>{let n=t.value.slice(0,t.cursor),r=t.value.slice(t.cursor),o=`${n}${e}${r}`,s=t.cursor+e.length;return A(z.NextFrame({state:{...t,cursor:s,value:o,error:P()}}))},Gse=(e)=>(t,n)=>z.$match(n,{Beep:()=>A(cu),NextFrame:({state:r})=>Bse(r,e),Submit:()=>Hse(t,e)}),Jse=(e)=>(t,n)=>{if(t.key.ctrl)switch(t.key.name){case"u":return jse(n);case"a":return Hj(n);case"e":return Wj(n);default:return A(z.Beep())}switch(t.key.name){case"backspace":return Wse(n);case"left":return qse(n);case"right":return zse(n);case"home":return Hj(n);case"end":return Wj(n);case"enter":case"return":{let r=n.value;return pa(e.validate(r),{onFailure:(o)=>z.NextFrame({state:{...n,value:r,error:F(o)}}),onSuccess:(o)=>z.Submit({value:o})})}case"tab":return Vse(n,e);default:return Kse(It(t.input,()=>""),n)}},Qse=(e)=>(t,n)=>Use(t,e),gq=(e,t)=>{let n={default:"",type:t,validate:A,...e},r={cursor:n.default.length,value:n.default,error:P()};return au(r,{render:Gse(n),process:Jse(n),clear:Qse(n)})},Zse,xq=(e,t,n,r=!1)=>{let o=ze(n.toggleSeparator,n.mutedColor),s=Ps(ou,r?n.submittedColor:n.primaryColor),i=e?t.inactive:yt(t.inactive,s);return(e?yt(t.active,s):t.active)+" "+ja(o,i)},yq=(e,t,n,r)=>lu(e,r.message,t,n),Yse,Xse,jj,qj,eie=(e)=>(t,n)=>{switch(n._tag){case"Beep":return A(cu);case"NextFrame":return Yse(t,e);case"Submit":return Xse(t,e)}},tie=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return qj;case"1":case"k":case"left":case"up":return jj;case" ":case"tab":return t?qj:jj;case"enter":case"return":return A(z.Submit({value:t}));default:return A(z.Beep())}},nie=(e,t,n)=>{let r=n===void 0?t:n,o=Math.min(t-r,e-Math.floor(r/2));if(o<0)o=0;let s=Math.min(o+r,t);return{startIndex:o,endIndex:s}};var Yy=v(()=>{nr();rt();Vu();Re();Fu();ne();pg();Me();ge();op();Kp();Sy();Kj={prefix:"?",arrowUp:"\u2191",arrowDown:"\u2193",checkboxOn:"\u2612",checkboxOff:"\u2610",tick:"\u2714",ellipsis:"\u2026",pointerSmall:"\u203A",pointer:"\u276F",descriptionSeparator:"- ",passwordMask:"*",toggleSeparator:"/",primaryColor:xf,mutedColor:vm,successColor:Zy,errorColor:Qy,submittedColor:iu},Hoe={...Kj,checkboxOn:"[*]",checkboxOff:"[ ]",tick:"\u221A",ellipsis:"...",pointerSmall:"\xBB",pointer:">"},joe=Te("effect/unstable/cli/Prompt/Theme",{defaultValue:Woe}),Voe=p(2,(e,t)=>{let n=Object.create(N0);return n._tag="OnSuccess",n.prompt=e,n.onSuccess=t,n}),Koe=p(2,(e,t)=>Voe(e,(n)=>Joe(t(n)))),Jn=q(function*(e){let t=yield*Zo,n=yield*t.readInput;return yield*P0(e,t,n)},Gt(()=>new dm({})),ma),N0={...ss({label:"Prompt",evaluate(){return Jn(this)}}),[zj]:{_Output:(e)=>e}},Qoe=q(function*(e,t,n){let r=yr(e.initialState)?yield*e.initialState:e.initialState,o=z.NextFrame({state:r});while(!0){let s=yield*e.render(r,o);if(yield*fo(t.display(s)),e.events){let i=mi(n).pipe(ae((c)=>({_tag:"Input",input:c}))),a=yield*Ac(i,mi(e.events).pipe(ae((c)=>({_tag:"Event",value:c}))));o=yield*e.process(a,r)}else{let i=yield*mi(n);o=yield*e.process(i,r)}switch(o._tag){case"Beep":continue;case"NextFrame":{yield*fo(t.display(yield*e.clear(r,o))),r=o.state;continue}case"Submit":{yield*fo(t.display(yield*e.clear(r,o)));let i=yield*e.render(r,o);return yield*fo(t.display(i)),o.value}}}},(e,t,n)=>ml(e,fo(n.display(Rj)))),z=qE(),cu=Fj,uu=/\r?\n/,Xoe=q(function*(e,t){let n=yield*Sn(t),r=ze(n.prefix,n.primaryColor),o=ze(n.pointerSmall,n.mutedColor),s=e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,i=yt(s,n.mutedColor),a=U0(i,r,o,t);return Cm+a}),ese=q(function*(e,t){let n=yield*Sn(t),r=ze(n.tick,n.successColor),o=ze(n.ellipsis,n.mutedColor),s=e?t.label.confirm:t.label.deny;return U0(s,r,o,t)+`
|
|
107
|
+
`}),nse=/^y|t$/,rse=/^n|f$/,ase=q(function*(e,t){let n=yield*Sn(t),r=ze(n.prefix,n.primaryColor),o=ze(n.pointerSmall,n.mutedColor),s=Xj(e,n),i=L0(r,o,s,t),a=ise(e,n.pointerSmall,n);return Cm+i+a}),cse=q(function*(e,t){let n=yield*Sn(t),r=ze(n.tick,n.successColor),o=ze(n.ellipsis,n.mutedColor),s=Xj(e,n,!0);return L0(r,o,s,t)+`
|
|
108
|
+
`}),hse={months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},yse=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,Bj={1:({token:e,...t})=>new B0({token:e.replace(/\\(.)/g,"$1"),...t}),2:(e)=>new oq(e),3:(e)=>new sq(e),4:(e)=>new iq(e),5:(e)=>new aq(e),6:(e)=>new rq(e),7:(e)=>new nq(e),8:(e)=>new tq(e),9:(e)=>new eq(e)};B0=class B0 extends Rs{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}};eq=class eq extends Rs{increment(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}decrement(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setValue(e){this.date.setMilliseconds(Number.parseInt(e.slice(-this.token.length)))}toString(){return`${this.date.getMilliseconds()}`.padStart(4,"0").substring(0,this.token.length)}};tq=class tq extends Rs{increment(){this.date.setSeconds(this.date.getSeconds()+1)}decrement(){this.date.setSeconds(this.date.getSeconds()-1)}setValue(e){this.date.setSeconds(Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getSeconds()}`;return this.token.length>1?e.padStart(2,"0"):e}};nq=class nq extends Rs{increment(){this.date.setMinutes(this.date.getMinutes()+1)}decrement(){this.date.setMinutes(this.date.getMinutes()-1)}setValue(e){this.date.setMinutes(Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getMinutes()}`;return this.token.length>1?e.padStart(2,"0"):e}};rq=class rq extends Rs{increment(){this.date.setHours(this.date.getHours()+1)}decrement(){this.date.setHours(this.date.getHours()-1)}setValue(e){this.date.setHours(Number.parseInt(e.slice(-2)))}toString(){let e=/h/.test(this.token)?this.date.getHours()%12||12:this.date.getHours();return this.token.length>1?`${e}`.padStart(2,"0"):`${e}`}};oq=class oq extends Rs{increment(){this.date.setDate(this.date.getDate()+1)}decrement(){this.date.setDate(this.date.getDate()-1)}setValue(e){this.date.setDate(Number.parseInt(e.slice(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();switch(this.token){case"DD":return`${e}`.padStart(2,"0");case"Do":return`${e}${this.ordinalIndicator(e)}`;case"d":return`${t+1}`;case"ddd":return this.locales.weekdaysShort[t];case"dddd":return this.locales.weekdays[t];default:return`${e}`}}ordinalIndicator(e){if(e>=11&&e<=13)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}};sq=class sq extends Rs{increment(){this.date.setMonth(this.date.getMonth()+1)}decrement(){this.date.setMonth(this.date.getMonth()-1)}setValue(e){let t=Number.parseInt(e.slice(-2))-1;this.date.setMonth(t<0?0:t)}toString(){let e=this.date.getMonth();switch(this.token.length){case 2:return`${e+1}`.padStart(2,"0");case 3:return this.locales.monthsShort[e];case 4:return this.locales.months[e];default:return`${e+1}`}}};iq=class iq extends Rs{increment(){this.date.setFullYear(this.date.getFullYear()+1)}decrement(){this.date.setFullYear(this.date.getFullYear()-1)}setValue(e){this.date.setFullYear(Number.parseInt(e.slice(-4)))}toString(){let e=`${this.date.getFullYear()}`.padStart(4,"0");return this.token.length===2?e.slice(-2):e}};aq=class aq extends Rs{increment(){this.date.setHours((this.date.getHours()+12)%24)}decrement(){this.increment()}setValue(e){}toString(){let e=this.date.getHours()>=12?"pm":"am";return/A/.test(this.token)?e.toUpperCase():e}};lq=q(function*(e,t){let n=yield*Sn(t),r=ze(n.prefix,n.primaryColor),o=ze(n.pointerSmall,n.mutedColor),s=uq(e,n.pointerSmall,n);return H0(e,r,o,t,n)+s}),fq=q(function*(e,t){let n=yield*Sn(t),r=ze(n.tick,n.successColor),o=ze(n.ellipsis,n.mutedColor);return H0(e,r,o,t,n,void 0,!0)+`
|
|
109
|
+
`}),Ose=q(function*(e,t){let n=yield*Sn(t),r=mq(e,t,n),o=ze(n.prefix,n.primaryColor),s=ze(n.pointerSmall,n.mutedColor),i=W0(o,s,t);return Cm+i+`
|
|
110
|
+
`+r}),Pse=q(function*(e,t){let n=yield*Sn(t),r=t.choices[e].title,o=ze(n.tick,n.successColor),s=ze(n.ellipsis,n.mutedColor);return W0(o,s,t)+" "+yt(r,n.submittedColor)+`
|
|
111
|
+
`}),Use=q(function*(e,t){let r=yield*(yield*Zo).columns,o=yield*Sn(t),s=Wa+su,i=hq(e,o.pointerSmall,o,{plain:!0});return $0(j0(e,o.prefix,o.pointerSmall,t,o,{plain:!0}),r,i)+s}),Bse=q(function*(e,t){let n=yield*Sn(t),r=ze(n.prefix,n.primaryColor),o=ze(n.pointerSmall,n.mutedColor),s=j0(e,r,o,t,n),i=hq(e,n.pointerSmall,n),a=t.type==="password"?n.passwordMask.length:1,c=(e.cursor-e.value.length)*a;return s+i+$j(c)}),Hse=q(function*(e,t){let n=yield*Sn(t),r=ze(n.tick,n.successColor),o=ze(n.ellipsis,n.mutedColor);return j0(e,r,o,t,n,void 0,!0)+`
|
|
112
|
+
`}),Zse=q(function*(e){let n=yield*(yield*Zo).columns,r=yield*Sn(e),o=Wa+su,s=e.active+" "+ja(r.toggleSeparator,e.inactive),i=lu(s,e.message,r.prefix,r.pointerSmall,{plain:!0});return yf(i,n)+o}),Yse=q(function*(e,t){let n=yield*Sn(t),r=ze(n.prefix,n.primaryColor),o=ze(n.pointerSmall,n.mutedColor),s=xq(e,t,n),i=yq(s,r,o,t);return Cm+i}),Xse=q(function*(e,t){let n=yield*Sn(t),r=ze(n.tick,n.successColor),o=ze(n.ellipsis,n.mutedColor),s=xq(e,t,n,!0);return yq(s,r,o,t)+`
|
|
113
|
+
`}),jj=A(z.NextFrame({state:!0})),qj=A(z.NextFrame({state:!1}))});var Sq="~effect/cli/Param",En="argument",Bt="flag",Im,Xy=(e)=>D(e,Sq),du=(e)=>e.kind==="flag",Rn=(e)=>{let t=(n)=>e.kind===En?oie(e.name,e.primitiveType,n):sie(e.name,e.primitiveType,n);return Object.setPrototypeOf({_tag:"Single",...e,description:e.description??P(),aliases:e.aliases??[],hidden:e.hidden??!1,parse:t},Im)},eS=(e,t)=>Rn({name:t,primitiveType:kj,kind:e}),Eq=(e,t)=>Rn({name:t,primitiveType:Sj,kind:e}),tS=(e,t)=>Rn({name:t,primitiveType:bj,kind:e}),nS=(e,t)=>Rn({name:t,primitiveType:Ej,kind:e}),rS=(e,t)=>Rn({name:t,primitiveType:wj,kind:e}),Am=(e,t,n)=>Rn({name:t,primitiveType:Cj(n),kind:e}),oS=(e,t,n)=>{let r=n.map((o)=>[o,o]);return Am(e,t,r)},Sf=(e,t,n)=>Rn({name:t,kind:e,primitiveType:vj(n?.pathType??"either",n?.mustExist),typeName:n?.typeName}),sS=(e,t,n)=>Sf(e,t,{pathType:"directory",typeName:"directory",mustExist:n?.mustExist}),iS=(e,t,n)=>Sf(e,t,{pathType:"file",typeName:"file",mustExist:n?.mustExist}),aS=(e,t)=>Rn({name:t,primitiveType:Ij,kind:e}),cS=(e,t)=>Rn({name:t,primitiveType:T0,kind:e}),uS=(e,t,n)=>Rn({name:t,primitiveType:_0(n),kind:e}),lS=(e,t,n,r)=>Rn({name:t,primitiveType:Aj(n,r),kind:e}),bq=(e,t)=>pu(gu(Rn({name:t,primitiveType:Tj,kind:e}),{min:1}),(n)=>Object.fromEntries(n.flatMap(Object.entries))),fS=(e)=>Rn({name:"__none__",primitiveType:_j,kind:e}),rie,wq,dS,kq=(e)=>Di(e,(t)=>Rn({...t,hidden:!0})),pu,mu=(e,t,n=[])=>{let r=n.map((o)=>()=>o().parse);return Object.assign(Object.create(Im),{_tag:"Transform",kind:e.kind,param:e,alternatives:n,f:t,parse:t(e.parse,r)})},hu,pS,fu=(e)=>{let t=q(function*(n){return xu(e),yield*e.parse(n).pipe(ae(([r,o])=>[r,F(o)]),ck({MissingOption:()=>A([n.arguments,P()]),MissingArgument:()=>A([n.arguments,P()])}))});return Object.assign(Object.create(Im),{_tag:"Optional",kind:e.kind,param:e,parse:t})},mS,hS,gS,gu=(e,t)=>{let n=xu(e),r=(o)=>{if(n.kind==="argument")return iie(e,n,o,t);else return aie(e,n,o,t)};return Object.assign(Object.create(Im),{_tag:"Variadic",kind:e.kind,param:e,min:zs(t?.min),max:zs(t?.max),parse:r})},xS,yS,SS,Tm,ES,bS,wS,kS,CS,oie,sie,iie,aie,z0=(e,t)=>{let n=e;switch(n._tag){case"Single":return t.Single(n);case"Map":return t.Map(n);case"Transform":return t.Transform(n);case"Optional":return t.Optional(n);case"Variadic":return t.Variadic(n)}},Di=(e,t)=>z0(e,{Single:(n)=>t(n),Map:(n)=>pu(Di(n.param,t),n.f),Transform:(n)=>mu(Di(n.param,t),n.f,n.alternatives.map((r)=>()=>Di(r(),t))),Optional:(n)=>fu(Di(n.param,t)),Variadic:(n)=>gu(Di(n.param,t),{min:Un(n.min),max:Un(n.max)})}),St=(e)=>z0(e,{Single:(t)=>[t],Map:(t)=>St(t.param),Transform:(t)=>[...St(t.param),...t.alternatives.flatMap((n)=>St(n()))],Optional:(t)=>St(t.param),Variadic:(t)=>St(t.param)}),xu=(e)=>{let t=St(e);if(t.length===0)throw Error("No Single param found in param structure");if(t.length>1)throw Error(`Multiple Single params found: ${t.map((n)=>n.name).join(", ")}`);return t[0]},Pr=(e)=>z0(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:P(),variadicMax:P()}),Map:(t)=>Pr(t.param),Transform:(t)=>Pr(t.param),Optional:(t)=>({...Pr(t.param),isOptional:!0}),Variadic:(t)=>({...Pr(t.param),isVariadic:!0,variadicMin:t.min,variadicMax:t.max})});var Fs=v(()=>{k0();Re();ne();Me();ct();ge();Bn();Qc();Em();gf();Yy();Im={[Sq]:{_A:L},pipe(){return fe(this,arguments)}},rie=/^-+/,wq=p(2,(e,t)=>Di(e,(n)=>Rn({...n,aliases:[...n.aliases,t.replace(rie,"")]}))),dS=p(2,(e,t)=>Di(e,(n)=>Rn({...n,description:F(t)}))),pu=p(2,(e,t)=>{let n=(r)=>ae(e.parse(r),([o,s])=>[o,t(s)]);return Object.assign(Object.create(Im),{_tag:"Map",kind:e.kind,param:e,f:t,parse:n})}),hu=p(2,(e,t)=>mu(e,(n)=>(r)=>se(n(r),([o,s])=>t(s).pipe(ae((i)=>[o,i]))))),pS=p(3,(e,t,n)=>{let r=xu(e);return mu(e,(o)=>(s)=>se(o(s),([i,a])=>Xt({try:()=>t(a),catch:(c)=>n(c)}).pipe(Gt((c)=>new fr({option:r.name,value:String(a),expected:c,kind:r.kind})),ae((c)=>[i,c]))))}),mS=p(2,(e,t)=>{if(!yr(t))return pu(fu(e),It(()=>t));return hu(fu(e),ut({onNone:()=>t,onSome:A}))}),hS=p(2,(e,t)=>{let n=(o,s)=>new fr({option:o._tag==="MissingOption"?o.option:o.argument,value:"config",expected:s.message,kind:o._tag==="MissingOption"?"flag":"argument"}),r=(o,s)=>ej(t).pipe(Gt((i)=>n(o,i)),se(ut({onNone:()=>R(o),onSome:(i)=>A([s.arguments,i])})));return mu(e,(o)=>(s)=>o(s).pipe(si(["MissingOption","MissingArgument"],(i)=>r(i,s))))}),gS=p(2,(e,t)=>{let n=(r,o)=>se(Vj(t)?A(t):t,Jn).pipe(ae((s)=>[o.arguments,s]),si("QuitError",()=>R(r)));return mu(e,(r)=>(o)=>r(o).pipe(si(["MissingOption","MissingArgument"],(s)=>n(s,o))))}),xS=p(3,(e,t,n)=>{if(t<0)throw Error("between: min must be non-negative");if(n<t)throw Error("between: max must be greater than or equal to min");return gu(e,{min:t,max:n})}),yS=p(2,(e,t)=>{if(t<0)throw Error("atMost: max must be non-negative");return gu(e,{max:t})}),SS=p(2,(e,t)=>{if(t<0)throw Error("atLeast: min must be non-negative");return gu(e,{min:t})}),Tm=p(3,(e,t,n)=>hu(e,q(function*(r){let o=t(r);if(Ce(o))return o.value;let s=xu(e);return yield*new fr({option:s.name,value:String(r),expected:n(r),kind:s.kind})}))),ES=p(3,(e,t,n)=>Tm(e,bE(t),n)),bS=p(2,(e,t)=>Di(e,(n)=>Rn({...n,typeName:t}))),wS=p(2,(e,t)=>{let n=Ai(t);return hu(e,(r)=>Gt(n(r),(o)=>{let s=xu(e);return new fr({option:s.name,value:String(r),expected:`Schema validation failed: ${o.message}`,kind:s.kind})}))}),kS=p(2,(e,t)=>mu(e,(n,r)=>(o)=>lo(n(o),()=>r[0]()(o)),[t])),CS=p(2,(e,t)=>mu(e,(n,r)=>(o)=>lo(ae(n(o),([s,i])=>[s,J(i)]),()=>ae(r[0]()(o),([s,i])=>[s,oe(i)])),[t])),oie=q(function*(e,t,n){if(n.arguments.length===0)return yield*new By({argument:e});let r=n.arguments[0],o=yield*Gt(t.parse(r),(s)=>new fr({option:e,value:r,expected:s,kind:"argument"}));return[n.arguments.slice(1),o]}),sie=q(function*(e,t,n){let r=n.flags[e];if(r===void 0||r.length===0)return yield*new Sm({option:e});let o=r[0],s=yield*Gt(t.parse(o),(i)=>new fr({option:e,value:o,expected:i,kind:"flag"}));return[n.arguments,s]}),iie=q(function*(e,t,n,r){let o=[],s=r?.min??0,i=r?.max??Number.POSITIVE_INFINITY,a=0,c=n.arguments;while(c.length>0&&a<i){let[u,l]=yield*e.parse({flags:n.flags,arguments:c});o.push(l),c=u,a++}if(a<s)return yield*new fr({option:t.name,value:`${a} values`,expected:`at least ${s} value${s===1?"":"s"}`,kind:t.kind});return[c,o]}),aie=q(function*(e,t,n,r){let o=[],i=[t.name,...t.aliases].flatMap((c)=>n.flags[c]??[]),a=i.length;if(Ve(r?.min)&&a<r.min)return yield*a===0?new Sm({option:t.name}):new fr({option:t.name,value:`${a} occurrences`,expected:`at least ${r.min} value${r.min===1?"":"s"}`,kind:t.kind});if(Ve(r?.max)&&a>r.max)return yield*new fr({option:t.name,value:`${a} occurrences`,expected:`at most ${r.max} value${r.max===1?"":"s"}`,kind:t.kind});for(let c of i){let[,u]=yield*e.parse({flags:{[t.name]:[c]},arguments:[]});o.push(u)}return[n.arguments,o]})});var Yr={};Qn(Yr,{atLeast:()=>Oie,atMost:()=>Pie,between:()=>Rie,choice:()=>mie,choiceWithValue:()=>Mie,date:()=>pie,directory:()=>fie,file:()=>lie,fileParse:()=>yie,fileSchema:()=>Sie,fileText:()=>xie,filter:()=>Nie,filterMap:()=>$ie,float:()=>die,integer:()=>uie,map:()=>Aie,mapEffect:()=>Tie,mapTryCatch:()=>_ie,none:()=>Eie,optional:()=>bie,orElse:()=>Uie,orElseResult:()=>Lie,path:()=>hie,redacted:()=>gie,string:()=>cie,variadic:()=>Iie,withDefault:()=>kie,withDescription:()=>wie,withFallbackConfig:()=>Cie,withFallbackPrompt:()=>vie,withMetavar:()=>Die,withSchema:()=>Fie});var cie=(e)=>eS(En,e),uie=(e)=>tS(En,e),lie=(e,t)=>iS(En,e,t),fie=(e,t)=>sS(En,e,t),die=(e)=>nS(En,e),pie=(e)=>rS(En,e),mie=(e,t)=>oS(En,e,t),hie=(e,t)=>Sf(En,e,t),gie=(e)=>aS(En,e),xie=(e)=>cS(En,e),yie=(e,t)=>uS(En,e,t),Sie=(e,t,n)=>lS(En,e,t,n),Eie,bie=(e)=>fu(e),wie,kie,Cie,vie,Iie,Aie,Tie,_ie,Oie,Pie,Rie,Fie,Mie=(e,t)=>Am(En,e,t),Die,Nie,$ie,Uie,Lie;var Cq=v(()=>{ne();Fs();Eie=fS(En),wie=p(2,(e,t)=>dS(e,t)),kie=mS,Cie=p(2,(e,t)=>hS(e,t)),vie=p(2,(e,t)=>gS(e,t)),Iie=p((e)=>Xy(e[0]),(e,t)=>gu(e,t)),Aie=p(2,(e,t)=>pu(e,t)),Tie=p(2,(e,t)=>hu(e,t)),_ie=p(3,(e,t,n)=>pS(e,t,n)),Oie=p(2,(e,t)=>SS(e,t)),Pie=p(2,(e,t)=>yS(e,t)),Rie=p(3,(e,t,n)=>xS(e,t,n)),Fie=p(2,(e,t)=>wS(e,t)),Die=p(2,(e,t)=>bS(e,t)),Nie=p(3,(e,t,n)=>ES(e,t,n)),$ie=p(3,(e,t,n)=>Tm(e,t,n)),Uie=p(2,(e,t)=>kS(e,t)),Lie=p(2,(e,t)=>CS(e,t))});var Bie,vq=(e)=>le((t)=>e(t.getRef(Bie))),V0=(...e)=>vq((t)=>me(()=>{t.error(...e)})),Fn=(...e)=>vq((t)=>me(()=>{t.log(...e)}));var vS=v(()=>{pt();At();Bie=dw});var Ef,IS=(e)=>e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,(t)=>`\\x${t.charCodeAt(0).toString(16).padStart(2,"0")}`),Hie=(e)=>{let t=globalThis.process,n=typeof t==="object"&&t!==null,r=e?.colors!==void 0?e.colors:n&&typeof t.stdout==="object"&&t.stdout!==null&&t.stdout.isTTY===!0&&t.env?.NO_COLOR!=="1",o=r?{bold:(c)=>`\x1B[1m${c}\x1B[0m`,dim:(c)=>`\x1B[2m${c}\x1B[0m`,cyan:(c)=>`\x1B[36m${c}\x1B[0m`,green:(c)=>`\x1B[32m${c}\x1B[0m`,blue:(c)=>`\x1B[34m${c}\x1B[0m`,yellow:(c)=>`\x1B[33m${c}\x1B[0m`,magenta:(c)=>`\x1B[35m${c}\x1B[0m`}:{bold:(c)=>c,dim:(c)=>c,cyan:(c)=>c,green:(c)=>c,blue:(c)=>c,yellow:(c)=>c,magenta:(c)=>c},s=r?"\x1B[0m":"",i=r?"\x1B[31m":"",a=r?"\x1B[1m":"";return{formatHelpDoc:(c)=>qie(c,o),formatCliError:(c)=>IS(c.message),formatError:(c)=>`
|
|
117
114
|
${a}${i}ERROR${s}
|
|
118
|
-
${
|
|
115
|
+
${IS(c.message)}${s}`,formatErrors:(c)=>{if(c.length===0)return"";if(c.length===1)return`
|
|
119
116
|
${a}${i}ERROR${s}
|
|
120
|
-
${
|
|
121
|
-
${a}${i}ERRORS${s}`);for(let[,f]of u)for(let d of f)l.push(` ${
|
|
122
|
-
`)},formatVersion:(c,u)=>`${o.bold(c)} ${o.dim("v")}${o.bold(u)}`}},
|
|
123
|
-
`)},
|
|
124
|
-
`)};var
|
|
125
|
-
`)};var
|
|
126
|
-
`)};var
|
|
127
|
-
`)};var _H=(e,t,n)=>{switch(t){case"bash":return bH(e,n);case"zsh":return AH(e,n);case"fish":return kH(e,n)}};var RH=()=>{};var Ct={};Un(Ct,{atLeast:()=>gse,atMost:()=>xse,between:()=>yse,boolean:()=>xp,choice:()=>c0,choiceWithValue:()=>a0,date:()=>tse,directory:()=>ose,file:()=>rse,fileParse:()=>ase,fileSchema:()=>cse,fileText:()=>ise,filter:()=>Ese,filterMap:()=>Sse,float:()=>ese,integer:()=>Xoe,keyValuePair:()=>use,map:()=>u0,mapEffect:()=>mse,mapTryCatch:()=>hse,none:()=>lse,optional:()=>iy,orElse:()=>bse,orElseResult:()=>wse,path:()=>nse,redacted:()=>sse,string:()=>Qoe,withAlias:()=>oy,withDefault:()=>yp,withDescription:()=>xc,withFallbackConfig:()=>dse,withFallbackPrompt:()=>pse,withHidden:()=>fse,withMetavar:()=>sy,withSchema:()=>vse});var Qoe=(e)=>_x(It,e),xp=(e)=>fH(It,e),Xoe=(e)=>Rx(It,e),ese=(e)=>Px(It,e),tse=(e)=>Fx(It,e),a0=(e,t)=>pp(It,e,t),c0=(e,t)=>Mx(It,e,t),nse=(e,t)=>ul(It,e,t),rse=(e,t)=>Dx(It,e,t),ose=(e,t)=>Nx(It,e,t),sse=(e)=>$x(It,e),ise=(e)=>Ux(It,e),ase=(e,t)=>Lx(It,e,t),cse=(e,t,n)=>jx(It,e,t,n),use=(e)=>dH(It,e),lse,oy,xc,sy,fse=(e)=>mH(e),iy=(e)=>lc(e),yp,dse,pse,u0,mse,hse,gse,xse,yse,Sse,Ese,bse,wse,vse;var l0=w(()=>{X();zo();lse=Bx(It),oy=p(2,(e,t)=>pH(e,t)),xc=p(2,(e,t)=>Hx(e,t)),sy=p(2,(e,t)=>Yx(e,t)),yp=zx,dse=p(2,(e,t)=>Wx(e,t)),pse=p(2,(e,t)=>Kx(e,t)),u0=p(2,(e,t)=>dc(e,t)),mse=p(2,(e,t)=>mc(e,t)),hse=p(3,(e,t,n)=>qx(e,t,n)),gse=p(2,(e,t)=>Jx(e,t)),xse=p(2,(e,t)=>Gx(e,t)),yse=p(3,(e,t,n)=>Vx(e,t,n)),Sse=p(3,(e,t,n)=>mp(e,t,n)),Ese=p(3,(e,t,n)=>Zx(e,t,n)),bse=p(2,(e,t)=>Xx(e,t)),wse=p(2,(e,t)=>ey(e,t)),vse=p(2,(e,t)=>Qx(e,t))});var ay="~effect/cli/Command/Config/Internal",cy=(e)=>{let t=[],n=[],r=[];function o(i){let a=Object.create(null);for(let c of Object.keys(i))a[c]=s(i[c]);return a}function s(i){if(Array.isArray(i))return{_tag:"Array",children:i.map((a)=>s(a))};else if(Ax(i)){let a=t.length;if(t.push(i),i.kind==="argument")r.push(i);else n.push(i);return{_tag:"Param",index:a}}else return{_tag:"Nested",tree:o(i)}}return{[ay]:ay,flags:n,arguments:r,orderedParams:t,tree:o(e)}},PH,FH=(e,t)=>{switch(e._tag){case"Param":return{_tag:"Param",index:e.index+t};case"Array":return{_tag:"Array",children:e.children.map((n)=>FH(n,t))};case"Nested":return{_tag:"Nested",tree:MH(e.tree,t)}}},MH=(e,t)=>{let n=Object.create(null);for(let r of Object.keys(e))n[r]=FH(e[r],t);return n},f0=(e,t)=>{let n=e.orderedParams.length;return{[ay]:ay,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:Object.assign(Object.create(null),e.tree,MH(t.tree,n))}},d0=(e,t)=>{let n={};for(let o of Object.keys(e))U(n,o,r(e[o]));return n;function r(o){switch(o._tag){case"Param":return t[o.index];case"Array":return o.children.map((s)=>r(s));case"Nested":return d0(o.tree,t)}}};var p0=w(()=>{zo();PH=cy({})});var Sp="~effect/cli/Command",Me=(e)=>e,kse,tr=(e)=>{let t=e.config,n=e.contextConfig??PH,r=e.service??ze(`${Sp}/${e.name}`),o=e.annotations??hn(),s=e.globalFlags??[],i=e.subcommands??[],a=(f,d)=>Le(e.handle)?e.handle(f,d):A(new qi({commandPath:d,errors:[]})),c=e.parse??uy(t),u=e.parseContext??uy(n,{allowLeftovers:!0}),l=(f)=>{let d=[],m=[];for(let I of t.arguments){let C=ct(I),S=er(I);for(let y of C)d.push({name:y.name,type:y.typeName??cp(y.primitiveType),description:y.description,required:!S.isOptional&&(!S.isVariadic||Qy(S.variadicMin,(h)=>h>0)),variadic:S.isVariadic})}let g=f.length>0?f.join(" "):e.name;if(i.some((I)=>I.commands.some((C)=>!C.unlisted)))g+=" <subcommand>";g+=" [flags]";for(let I of d){let C=I.variadic?`<${I.name}...>`:`<${I.name}>`;g+=` ${I.required?C:`[${C}]`}`}for(let I of t.flags){let C=ct(I),S=er(I);for(let y of C){if(y.hidden)continue;m.push(ly(y,S))}}let b=[];for(let I of i){let C=I.commands.filter((S)=>!S.unlisted);if(C.length===0)continue;b.push({group:I.group,commands:jt(C,(S)=>({name:S.name,alias:S.alias,shortDescription:S.shortDescription,description:S.description??""}))})}let x=e.examples??[];return{description:e.description??"",usage:g,flags:m,annotations:o,...d.length>0&&{args:d},...b.length>0&&{subcommands:b},...x.length>0&&{examples:x}}};return Object.assign(Object.create(kse),{[Sp]:Sp,name:e.name,examples:e.examples??[],annotations:o,globalFlags:s,subcommands:i,unlisted:e.unlisted??!1,config:t,contextConfig:n,service:r,parse:c,parseContext:u,handle:a,buildHelpDoc:l,...Le(e.description)?{description:e.description}:{},...Le(e.shortDescription)?{shortDescription:e.shortDescription}:{},...Le(e.alias)?{alias:e.alias}:{}})},ly=(e,t)=>{let n=e.aliases.map((r)=>r.length===1?`-${r}`:`--${r}`);return{name:e.name,aliases:n,type:e.typeName??cp(e.primitiveType),description:Ise(e.description,Hs(e.primitiveType)),required:e.primitiveType._tag!=="Boolean"&&!t.isOptional}},Ise=(e,t)=>{if(t===void 0||t.length===0)return e;let n=`(choices: ${t.join(", ")})`;return et(e,{onNone:()=>_(n),onSome:(r)=>_(`${r} ${n}`)})},uy=(e,t)=>H(function*(n){let r={flags:n.flags,arguments:n.arguments},[o,s]=yield*Cse(r,e.orderedParams);if(t?.allowLeftovers!==!0&&o.length>0)return yield*new xx({arguments:o});return d0(e.tree,s)}),Cse,m0=(e,t,n)=>{let r=Me(e),o=new Set;((i)=>{for(let a of i){let c=ct(a);for(let u of c)o.add(u.name)}})((n?.contextConfig??r.contextConfig).flags);for(let i of t){let a=Me(i);for(let c of a.config.flags){let u=ct(c);for(let l of u)if(o.has(l.name))throw new hx({option:l.name,parentCommand:e.name,childCommand:i.name})}}};var fl=w(()=>{An();Ve();Oe();Pc();_e();he();ip();zo();il();p0();kse={...So({label:"Command",evaluate(){return Me(this).service}})},Cse=H(function*(e,t){let n=[],r=e.arguments;for(let o of t){let[s,i]=yield*o.parse({flags:e.flags,arguments:r});n.push(i),r=s}return[r,n]})});var Tse=(e)=>{switch(e.primitiveType._tag){case"Boolean":return{_tag:"Boolean"};case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:Hs(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:$I(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},Ose=(e)=>{switch(e.primitiveType._tag){case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:Hs(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:$I(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},h0=(e)=>{let n=Me(e).config,r=[];for(let i of n.flags){let a=ct(i);for(let c of a){if(c.kind!=="flag")continue;if(c.hidden)continue;r.push({name:c.name,aliases:c.aliases,description:mn(c.description),type:Tse(c)})}}let o=[];for(let i of n.arguments){let a=ct(i),c=er(i);for(let u of a){if(u.kind!=="argument")continue;o.push({name:u.name,description:mn(u.description),required:!c.isOptional,variadic:c.isVariadic,type:Ose(u)})}}let s=[];for(let i of e.subcommands)for(let a of i.commands){if(a.unlisted)continue;s.push(h0(a))}return{name:e.name,description:e.shortDescription??e.description,flags:r,arguments:o,subcommands:s}};var NH=w(()=>{_e();zo();il();fl()});var g0=(e)=>{let t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r),n.push(r)}return n},DH=(e,t)=>{let n=[e],r=e;for(let o=1;o<t.length;o++){let s=t[o],i=void 0;for(let a of r.subcommands)if(i=a.commands.find((c)=>c.name===s),i)break;if(!i)break;n.push(i),r=i}return n},x0=(e,t,n)=>{let o=DH(e,t).flatMap((s)=>Me(s).globalFlags);return g0([...n,...o])},_se=(e)=>{let t=[],n=(r)=>{let o=Me(r);for(let s of o.globalFlags)t.push(s);for(let s of r.subcommands)for(let i of s.commands)n(i)};return n(e),g0(t)},Rse=(e,t)=>{if(e.length<=1)return[];let n=new Set(t.map((o)=>o.name)),r=[];for(let o of e.slice(0,-1)){let s=Me(o);for(let i of s.contextConfig.flags){let a=ct(i),c=er(i);for(let u of a){if(n.has(u.name))continue;if(u.hidden)continue;n.add(u.name),r.push(ly(u,c))}}}return r},$H=(e,t)=>g0([...t,..._se(e)]),fy=(e,t,n)=>qt(function*(){let r=DH(e,t),o=r.length>0?r[r.length-1]:e,s=Me(o).buildHelpDoc(t),i=Rse(r,s.flags),a=x0(e,t,n),c=[];for(let u of a){let l=ct(u.flag),f=er(u.flag);for(let d of l){if(d.hidden)continue;c.push({...ly(d,f),required:!1})}}return{...s,flags:[...i,...s.flags],globalFlags:c}});var y0=w(()=>{Oe();zo();fl()});var dy=(e)=>({_tag:"Action",flag:e.flag,run:e.run}),Fse=(e)=>(t)=>{UH+=1;let n=ze(`effect/unstable/cli/GlobalFlag/${e}/${UH}`);return Object.assign(n,{_tag:"Setting",id:e,flag:t.flag})},UH=0,Mse,Nse,S0,Dse,dl,LH;var E0=w(()=>{ty();Ve();Oe();_e();n0();RH();l0();NH();y0();Mse=dy({flag:xp("help").pipe(oy("h"),xc("Show help information"),yp(!1)),run:H(function*(e,{builtIns:t,command:n,commandPath:r}){let o=yield*ll,s=yield*fy(n,r,t);yield*un(o.formatHelpDoc(s))})}),Nse=dy({flag:xp("version").pipe(oy("v"),xc("Show version information"),yp(!1)),run:H(function*(e,{command:t,version:n}){let r=yield*ll;yield*un(r.formatVersion(t.name,n))})}),S0=dy({flag:xp("wizard").pipe(xc("Start wizard mode for a command"),yp(!1)),run:()=>Te}),Dse=dy({flag:c0("completions",["bash","zsh","fish","sh"]).pipe(iy,u0((e)=>en(e,(t)=>t==="sh"?"bash":t)),sy("<bash|zsh|fish|sh>"),xc("Print shell completion script")),run:H(function*(e,{command:t}){if(me(e))return;let n=h0(t);yield*un(_H(t.name,e.value,n))})}),dl=Fse("log-level")({flag:a0("log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(iy,xc("Sets the minimum log level"),sy("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),LH=[Mse,Nse,S0,Dse,dl]});var py,$se;var BH=w(()=>{Ve();E0();py=class py extends ke("effect/unstable/cli/CliConfig",{defaultValue:()=>$se}){};$se={builtIns:LH}});function qH(e){let t=e.indexOf("--");if(t===-1)return{tokens:HH(e),trailingOperands:[]};return{tokens:HH(e.slice(0,t)),trailingOperands:e.slice(t+1)}}var HH=(e)=>{let t=[];for(let n of e)if(!n.startsWith("-"))t.push({_tag:"Value",value:n});else if(n.startsWith("--")){let r=n.indexOf("=");if(r!==-1){let o=n.slice(2,r),s=n.slice(r+1);t.push({_tag:"LongOption",name:o,raw:n,value:s})}else t.push({_tag:"LongOption",name:n.slice(2),raw:n})}else if(n.length>1){let r=n.slice(1),o=r.indexOf("=");if(o!==-1){let s=r.slice(0,o),i=r.slice(o+1);t.push({_tag:"ShortOption",flag:s,raw:`-${s}`,value:i})}else for(let s of r)t.push({_tag:"ShortOption",flag:s,raw:`-${s}`})}else t.push({_tag:"Value",value:n});return t};var jse=(e,t)=>{let n=e.length,r=t.length,o=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let s=0;s<=n;s++)o[s][0]=s;for(let s=0;s<=r;s++)o[0][s]=s;for(let s=1;s<=n;s++)for(let i=1;i<=r;i++){let a=e[s-1]===t[i-1]?0:1;o[s][i]=Math.min(o[s-1][i]+1,o[s][i-1]+1,o[s-1][i-1]+a)}return o[n][r]},b0=(e,t)=>{let n=t.map((o)=>[jse(e,o),o]).filter(([o])=>o<=2).sort(([o],[s])=>o-s);if(n.length===0)return[];let r=n[0][0];return n.filter(([o])=>o===r).map(([,o])=>o)};var v0=(e)=>et(e.subcommand,{onNone:()=>[],onSome:(t)=>[t.name,...v0(t.parsedInput)]}),k0=(e,t,n=[])=>qt(function*(){let{tokens:r,trailingOperands:o}=e,s=[...n,t.name],i=Me(t),c=i.config.flags.flatMap(ct).filter(fc),u=ml(c),f=i.contextConfig.flags.flatMap(ct).filter(fc),d=ml(f),m=new Set(f.map((S)=>S.name)),g={command:t,commandPath:s,flagRegistry:u,inheritedFlagRegistry:d,localFlagNames:c.filter((S)=>!m.has(S.name)).map((S)=>S.name)},b=Xse(r,g);if(b._tag==="Leaf")return{flags:b.flags,arguments:[...b.arguments,...o],subcommand:O(),...b.errors.length>0&&{errors:b.errors}};let x={tokens:b.childTokens,trailingOperands:o},I=yield*k0(x,b.sub,s),C=[...b.errors,...I.errors??[]];return{flags:b.flags,arguments:[],subcommand:_({name:b.sub.name,parsedInput:I}),...C.length>0&&{errors:C}}}),my=(e)=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},ml=(e)=>{let t=new Map;for(let n of e){if(t.has(n.name))throw Error(`Duplicate flag name "${n.name}" in command definition`);t.set(n.name,n);for(let r of n.aliases){if(t.has(r))throw Error(`Duplicate flag/alias "${r}" in command definition (conflicts with "${t.get(r).name}")`);t.set(r,n)}}return{params:e,index:t}},KH=(e)=>{let t=new Map,n=(r,o)=>{let s=t.get(r);if(s&&s!==o)throw Error(`Duplicate subcommand name/alias "${r}" in command definition (conflicts with "${s.name}")`);t.set(r,o)};for(let r of e)for(let o of r.commands)if(n(o.name,o),o.alias&&o.alias!==o.name)n(o.alias,o);return t},I0=(e)=>Object.fromEntries(e.map((t)=>[t.name,[]])),Bse=(e)=>{let t=I0(e);return{add:(n,r)=>{if(r!==void 0)t[n].push(r)},merge:(n)=>{for(let r in n){let o=n[r];if(o?.length)for(let s=0;s<o.length;s++)t[r].push(o[s])}},snapshot:()=>t}},hy=(e)=>e._tag==="LongOption"||e._tag==="ShortOption",VH=(e)=>e._tag==="LongOption"?e.name:e.flag,pl=(e,t)=>{let n=VH(e),r=t.index.get(n);if(r&&r.name===n)return{param:r,negated:!1};if(e._tag==="LongOption"&&e.name.startsWith("no-")){let o=e.name.slice(3),s=t.index.get(o);if(s&&s.name===o&&wx(s.primitiveType))return{param:s,negated:!0}}if(r)return{param:r,negated:!1};return},zH=(e,t,n)=>new $n({option:t.name,value:n,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),Hse=(e)=>{let t=Hs(e.primitiveType);return new $n({option:e.name,value:"",expected:t===void 0?e.typeName??cp(e.primitiveType):t.join(" | "),kind:"flag"})},WH=(e)=>e?._tag==="Value"&&(cB(e.value)||uB(e.value))?e.value:void 0,GH=(e,t,n,r=!1)=>{let o=Ep(e,t,n,r);switch(o._tag){case"Value":return{_tag:"Value",value:o.value};case"Error":return{_tag:"Error",error:o.error}}},Ep=(e,t,n,r=!1)=>{if(r){if(t.value!==void 0)return{_tag:"Error",error:zH(t,n,t.value),tokens:[]};let s=WH(e.peek());if(s!==void 0){let i=e.take();return{_tag:"Error",error:zH(t,n,s),tokens:i===void 0?[]:[i]}}return{_tag:"Value",value:"false",tokens:[]}}if(t.value!==void 0)return{_tag:"Value",value:t.value,tokens:[]};if(wx(n.primitiveType)){let s=WH(e.peek()),i=s!==void 0?e.take():void 0;return{_tag:"Value",value:s??"true",tokens:i===void 0?[]:[i]}}let o=e.peek();if(o?._tag==="Value"){let s=e.take();return{_tag:"Value",value:o.value,tokens:s===void 0?[]:[s]}}return{_tag:"Error",error:Hse(n),tokens:[]}},qse=(e,t)=>{let n=I0(t.params),r=[],o=[],s=my(e);for(let i=s.take();i;i=s.take()){if(!hy(i)){r.push(i);continue}let a=pl(i,t);if(!a){r.push(i);continue}let c=GH(s,i,a.param,a.negated);if(c._tag==="Error"){o.push(c.error);continue}if(c.value!==void 0)n[a.param.name].push(c.value)}return{flagMap:n,remainder:r,errors:o}},zse=(e)=>Me(e).config.flags.flatMap(ct).filter(fc),Wse=(e)=>Me(e).contextConfig.flags.flatMap(ct).filter(fc),JH=(e,t)=>{for(let n of t){let r=pl(e,n);if(r!==void 0)return r}return},w0=(e,t,n,r)=>{e.push(n);let o=Ep(t,n,r.param,r.negated);e.push(...o.tokens)},Kse=(e,t,n,r,o)=>{let s=my(t);Ep(s,e,n.param,n.negated);for(let i=s.take();i;i=s.take()){if(hy(i)){let a=JH(i,o);if(a!==void 0)Ep(s,i,a.param,a.negated);continue}if(i._tag==="Value")return r.has(i.value)}return!1},ZH=(e,t,n)=>{let r=I0(n.params),o=[],s=(i,a,c)=>{let u=ml(zse(a)),l=ml(Wse(a)),f=KH(a.subcommands),d=my(i),m=[],g=!0;for(let b=d.take();b;b=d.take()){if(hy(b)){let x=JH(b,c);if(x!==void 0){w0(m,d,b,x);continue}let I=pl(b,l);if(I!==void 0){w0(m,d,b,I);continue}let C=pl(b,u),S=pl(b,n);if(C!==void 0){if(S===void 0||!g||!Kse(b,d.rest(),C,f,[u,l,n])){w0(m,d,b,C);continue}}if(S!==void 0){let y=Ep(d,b,S.param,S.negated);if(y._tag==="Error"){o.push(y.error);continue}if(y.value!==void 0)r[S.param.name].push(y.value);continue}m.push(b);continue}if(b._tag==="Value"&&g){let x=f.get(b.value);if(x!==void 0)return m.push(b),m.push(...s(d.rest(),x,[...c,l])),m;g=!1}m.push(b)}return m};return{flagMap:r,remainder:s(e,t,[]),errors:o}},Vse=(e,t,n)=>{let r=e._tag==="LongOption"?`--${e.name}`:`-${e.flag}`,o=[];for(let i of t){if(i.hidden)continue;if(o.push(i.name),wx(i.primitiveType))o.push(`no-${i.name}`);for(let a of i.aliases)o.push(a)}let s=b0(VH(e),o).map((i)=>i.length===1?`-${i}`:`--${i}`);return new nc({option:r,suggestions:s,command:n})},Gse=(e)=>({flags:Bse(e.params),arguments:[],errors:[],mode:{_tag:"AwaitingFirstValue"}}),Jse=(e)=>({_tag:"Leaf",flags:e.flags.snapshot(),arguments:e.arguments,errors:e.errors}),Zse=(e,t,n,r)=>{let{command:o,commandPath:s,inheritedFlagRegistry:i,localFlagNames:a}=n,c=KH(o.subcommands),u=c.get(e);if(u){let f=[...s,u.name],d=r.flags.snapshot();for(let g of a){let b=d[g];if(b!==void 0&&b.length>0)r.errors.push(new nc({option:`--${g}`,suggestions:[],command:f}))}let m=qse(t.rest(),i);return r.flags.merge(m.flagMap),r.errors.push(...m.errors),{_tag:"Subcommand",result:{_tag:"Sub",flags:r.flags.snapshot(),sub:u,childTokens:m.remainder,errors:r.errors}}}if(!(Me(o).config.arguments.length>0)&&c.size>0){let f=[];for(let[m,g]of c)if(!g.unlisted)f.push(m);let d=b0(e,f);r.errors.push(new yx({subcommand:e,parent:s,suggestions:d}))}return{_tag:"Argument"}},Yse=(e,t,n,r)=>{let{commandPath:o,flagRegistry:s}=n,i=pl(e,s);if(!i){r.errors.push(Vse(e,s.params,o));return}let a=GH(t,e,i.param,i.negated);if(a._tag==="Error"){r.errors.push(a.error);return}r.flags.add(i.param.name,a.value)},Qse=(e,t,n,r)=>{if(r.mode._tag==="AwaitingFirstValue"){let o=Zse(e,t,n,r);if(o._tag==="Subcommand")return o.result;r.mode={_tag:"CollectingArguments"}}r.arguments.push(e);return},Xse=(e,t)=>{let n=my(e),r=Gse(t.flagRegistry);for(let o=n.take();o;o=n.take()){if(hy(o)){Yse(o,n,t,r);continue}if(o._tag==="Value"){let s=Qse(o.value,n,t,r);if(s)return s}}return Jse(r)};var YH=w(()=>{Oe();_e();ip();zo();il();fl()});var T0,tie=(e,t)=>{let n=e;for(let r of t.slice(1)){let o=n.subcommands.flatMap((s)=>s.commands).find((s)=>s.name===r||s.alias===r);if(o===void 0)break;n=o}return n},eq,nie=(e)=>e.subcommands.some((n)=>n.commands.some((r)=>!r.unlisted))||Me(e).config.orderedParams.length>0,QH,rie=(e)=>{let t=sie(e);switch(e.primitiveType._tag){case"Boolean":return oe(vn(jI({message:t,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),(n)=>Wo(String(n)));case"Choice":{let n=Hs(e.primitiveType)??[];return oe(vn(HI({message:t,choices:n.map((r)=>({title:r,value:r}))})),Wo)}case"Date":return oe(vn(LB({message:t})),(n)=>Wo(n.toISOString()));case"Float":return oe(vn(jB({message:t})),(n)=>Wo(String(n)));case"Integer":return oe(vn(BI({message:t})),(n)=>Wo(String(n)));case"Redacted":return oe(vn(BB({message:t})),(n)=>Wo(Ui(n),"<redacted>"));default:return oe(vn(HB({message:t})),Wo)}},Wo=(e,t=e)=>({value:e,displayValue:t}),oie=(e)=>e.kind===It?`--${e.name}`:e.name,sie=(e)=>C0(e),C0=(e)=>{let t=mn(e.description)?.trim(),n=e.kind===It&&t!==void 0&&t.length<=32?t:iie(e.name);return e.kind===It?`${n} (${oie(e)})`:n},iie=(e)=>{let t=e.split(/[-_]+/).filter((n)=>n.length>0);if(t.length===0)return e;return[t[0][0].toUpperCase()+t[0].slice(1),...t.slice(1)].join(" ")},gy=(e)=>un(oq("Current command",e.map((t)=>t.displayValue),IB)),XH=(e,t)=>`${at(e.toUpperCase(),qs,al)} ${at("\xB7",fp)} ${at(t,qs,sc)}`,tq=(e,t,n)=>[`${at(e,qs,al)} ${at(`v${t}`,sc)} ${at("\xB7 Command wizard",qs,sc)}`,...n===void 0||n.length===0?[]:[n],at("Build a command interactively. Press Ctrl+C to cancel.",fp),""].join(`
|
|
128
|
-
`),
|
|
129
|
-
${
|
|
130
|
-
`)},aie=(e)=>{let o=e.map(cie),s=[],i=" $ ";for(let a of o){let c=i===" $ "||i===" "?"":" ";if(i.length+c.length+a.length>88&&i!==" $ ")s.push(`${i} \\`),i=` ${a}`;else i+=`${c}${a}`}if(i!==" $ ")s.push(i);return s},cie=(e)=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'",`'"'"'`)}'`;var sq=w(()=>{ty();Oe();_e();$d();zo();il();Ox();fl();T0=H(function*(e,t){let n=t?.commandPath??[e.name],r=tie(e,n),o=(t?.prefix??n).map((s)=>Wo(s));return yield*gy(o),yield*eq(r,o,r===e?"ROOT":r.name),{args:o.map((s)=>s.value),displayArgs:o.map((s)=>s.displayValue)}}),eq=H(function*(e,t,n){let r=Me(e),o=e.subcommands.flatMap((a)=>a.commands.filter((c)=>!c.unlisted)),s=o.length===0?r.config:r.contextConfig;if(s.flags.length>0){yield*un(XH(n,"FLAGS"));for(let a of s.flags)t.push(...yield*QH(a));if(s.arguments.length>0||o.length>0)yield*gy(t)}if(s.arguments.length>0){yield*un(XH(n,"ARGUMENTS"));for(let a of s.arguments)t.push(...yield*QH(a));if(o.length>0)yield*gy(t)}if(o.length===0)return;let i=yield*vn(HI({message:"Command",choices:o.map((a)=>({title:a.name,value:a,...a.shortDescription!==void 0?{description:a.shortDescription}:a.description!==void 0?{description:a.description}:{}}))}));if(yield*un(),t.push(Wo(i.name)),nie(i))yield*gy(t);yield*eq(i,t,i.name)}),QH=H(function*(e){let t=gc(e),n=er(e);if(n.isOptional){if(!(yield*vn(jI({message:`Set ${C0(t)}?`,initial:!1}))))return yield*un(),[]}let r=!n.isVariadic?1:yield*vn(BI({message:`${C0(t)} count`,default:mt(n.variadicMin,()=>0),min:mt(n.variadicMin,()=>0),...Ee(n.variadicMax)?{max:n.variadicMax.value}:{}})),o=[];for(let i=0;i<r;i++)o.push(yield*rie(t));let s=t.kind===It?{flags:{[t.name]:o.map((i)=>i.value)},arguments:[]}:{flags:{},arguments:o.map((i)=>i.value)};if(yield*e.parse(s),yield*un(),t.kind===Yt)return o;return o.flatMap((i)=>[Wo(`--${t.name}`),i])})});var ho={};Un(ho,{annotate:()=>Eie,annotateMerge:()=>bie,isCommand:()=>O0,make:()=>lie,provide:()=>vie,provideEffect:()=>Iie,provideEffectDiscard:()=>Cie,provideSync:()=>kie,run:()=>Rie,runWith:()=>A0,unlisted:()=>Sie,withAlias:()=>yie,withDescription:()=>gie,withExamples:()=>wie,withGlobalFlags:()=>hie,withHandler:()=>fie,withSharedFlags:()=>mie,withShortDescription:()=>xie,withSubcommands:()=>pie,wizard:()=>Tie});var O0=(e)=>M(e,Sp),lie=(e,t,n)=>{let r=cy(t??{});return tr({name:e,config:r,...Le(n)?{handle:n}:{}})},fie,die=(e)=>{let t=[],n=new Map,r=(i,a)=>{t.push(a);let c=n.get(i);if(c)c.push(a);else n.set(i,[a])};for(let i of e){if(O0(i)){r(void 0,i);continue}for(let a of i.commands)r(i.group,a)}let o=[],s=n.get(void 0);if(s&&s.length>0)o.push({group:void 0,commands:s});for(let[i,a]of n){if(i===void 0)continue;o.push({group:i,commands:a})}return{flat:t,groups:o}},pie,mie,hie,gie,xie,yie,Sie=(e)=>tr({...Me(e),unlisted:!0}),Eie,bie,wie,xy=(e,t)=>{let n=Me(e);return tr({...n,handle:(r,o)=>t(n.handle(r,o),r)})},vie,kie,Iie,Cie,Tie=(e,t)=>oe(T0(e,t),(n)=>n.args),Oie=(e,t,n,r)=>{let o=new Set(t),s=[],i=new Set;for(let a of e){if(o.has(a))continue;let c=ct(a.flag);for(let u of c){let l=n[u.name];if(!l||l.length===0)continue;let f=`--${u.name}`;if(i.has(f))continue;i.add(f),s.push(new nc({option:f,suggestions:[],command:r}))}}return s},Aie=(e,t,n)=>qt(function*(){let{builtIns:r}=yield*py,o=yield*ll,s=yield*fy(e,t.commandPath,r);if(yield*un(o.formatHelpDoc(s)),n&&t.errors.length>0)yield*XI(o.formatErrors(t.errors))}),_ie=(e)=>qt(function*(){let t=yield*ll;yield*XI(t.formatError(e)),e[Pa]=!1}),Rie,A0=(e,t)=>{let n=Me(e);return H(function*(r){let{builtIns:o}=yield*py,{tokens:s,trailingOperands:i}=qH(r),a=$H(e,o),c=a.flatMap((k)=>ct(k.flag)),u=ml(c.filter(fc)),{flagMap:l,remainder:f,errors:d}=ZH(s,e,u),m={flags:l,arguments:[]},g=yield*k0({tokens:f,trailingOperands:i},e),b=[e.name,...v0(g)],x={builtIns:o,command:e,commandPath:b,version:t.version},I=x0(e,b,o),C=Oie(a,I,l,b);if(C.length>0||d.length>0){let k=g.errors??[];return yield*new qi({commandPath:b,errors:[...d,...C,...k]})}for(let k of I){if(k._tag!=="Action")continue;if(!ct(k.flag).some((R)=>{let z=l[R.name];return z!==void 0&&z.length>0}))continue;let[,N]=yield*k.flag.parse(m);if(k===S0)return yield*qt(function*(){yield*un(tq(e.name,t.version,e.description));let R=[e.name,...r.filter((ue)=>ue!=="--wizard"&&!ue.startsWith("--wizard="))],z=yield*T0(e,{commandPath:b,prefix:R});if(yield*un(nq(z.displayArgs)),yield*vn(qB({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))yield*un(),yield*A0(e,{...t,renderErrors:!1})(z.args.slice(1))}).pipe(gs("QuitError",()=>un(rq())));yield*k.run(N,x);return}if(g.errors&&g.errors.length>0)return yield*new qi({commandPath:b,errors:g.errors});let S=yield*ih(n.parse(g));if(S._tag==="Failure")return yield*new qi({commandPath:b,errors:[S.failure]});let y=n.handle(S.success,[e.name]),h=I.includes(dl)?(yield*dl.flag.parse(m))[1]:O();y=Io(y,dl,h);for(let k of I){if(k._tag!=="Setting"||k===dl)continue;let[,T]=yield*k.flag.parse(m);y=Io(y,k,T)}let E=et(h,{onNone:()=>hn(),onSome:(k)=>os(I_,k)});yield*xs(y,E)},Mf((r)=>RI(r)&&r._tag==="ShowHelp"?G(r):te(r),(r)=>hr(Aie(e,r,t.renderErrors!==!1),A(r))),Mf((r)=>t.renderErrors!==!1&&RI(r)&&r._tag==="UserError"?G(r):te(r),(r)=>hr(_ie(r),A(r))),Mf((r)=>V2(r)?G(r):te(r),(r)=>hu))};var iq=w(()=>{ty();Ve();Oe();X();_e();he();tb();gn();xh();Wv();sx();BH();ip();n0();E0();fl();p0();y0();YH();sq();zo();Ox();fie=p(2,(e,t)=>tr({...Me(e),handle:t})),pie=p(2,(e,t)=>{let n=die(t);m0(e,n.flat);let r=Me(e),o=new Map(n.flat.map((c)=>[c.name,Me(c)])),s=Symbol("effect/cli/SubcommandState"),i=H(function*(c){if(me(c.subcommand))return yield*r.parse(c);let u=o.get(c.subcommand.value.name);if(!u)return yield*r.parse(c);let l=yield*r.parseContext(c),f=yield*u.parse(c.subcommand.value.parsedInput);return{...l,[s]:{name:u.name,result:f}}}),a=H(function*(c,u){let f=c[s];if(f){let d=o.get(f.name);if(!d)return yield*new qi({commandPath:u,errors:[]});return yield*d.handle(f.result,[...u,d.name]).pipe(Io(r.service,c))}return yield*r.handle(c,u)});return tr({name:r.name,config:r.config,contextConfig:r.contextConfig,description:r.description,shortDescription:r.shortDescription,alias:r.alias,unlisted:r.unlisted,annotations:r.annotations,globalFlags:r.globalFlags,examples:r.examples,service:r.service,subcommands:n.groups,parse:i,parseContext:r.parseContext,handle:a})}),mie=p(2,(e,t)=>{let n=Me(e),r=cy(t),o=f0(n.config,r),s=f0(n.contextConfig,r);if(n.subcommands.length>0){let l=n.subcommands.flatMap((f)=>f.commands);m0(e,l,{contextConfig:s})}let i=uy(r,{allowLeftovers:!0}),a=H(function*(l){let f=yield*n.parse(l),d=yield*i(l);return{...f,...d}}),c=H(function*(l){let f=yield*n.parseContext(l),d=yield*i(l);return{...f,...d}}),u=(l,f)=>n.handle(l,f);return tr({name:n.name,config:o,contextConfig:s,description:n.description,shortDescription:n.shortDescription,alias:n.alias,unlisted:n.unlisted,annotations:n.annotations,globalFlags:n.globalFlags,examples:n.examples,service:n.service,subcommands:n.subcommands,parse:a,parseContext:c,handle:u})}),hie=p(2,(e,t)=>{let n=Me(e),r=Array.from(new Set([...n.globalFlags,...t]));return tr({...n,globalFlags:r})}),gie=p(2,(e,t)=>tr({...Me(e),description:t})),xie=p(2,(e,t)=>tr({...Me(e),shortDescription:t})),yie=p(2,(e,t)=>tr({...Me(e),alias:t})),Eie=p(3,(e,t,n)=>{let r=Me(e);return tr({...r,annotations:tn(r.annotations,t,n)})}),bie=p(2,(e,t)=>{let n=Me(e);return tr({...n,annotations:ua(n.annotations,t)})}),wie=p(2,(e,t)=>tr({...Me(e),examples:t})),vie=p((e)=>O0(e[0]),(e,t,n)=>xy(e,(r,o)=>zb(r,typeof t==="function"?t(o):t,n))),kie=p(3,(e,t,n)=>xy(e,(r,o)=>Io(r,t,typeof n==="function"?n(o):n))),Iie=p(3,(e,t,n)=>xy(e,(r,o)=>Wb(r,t,typeof n==="function"?n(o):n))),Cie=p(2,(e,t)=>xy(e,(n,r)=>hr(typeof t==="function"?t(r):t,n))),Rie=p(2,(e,t)=>bg.use(({args:n})=>ne(n,(r)=>A0(e,t)(r))))});var aq=w(()=>{hH();iq();l0()});var cq=(e)=>{let t=e?.trim();return t===void 0||t.length===0?void 0:t},uq=()=>({bunExecutable:cq(process.env.TRIPWIRE_BUN),forcePortable:process.env.TRIPWIRE_FORCE_PORTABLE==="1",packageDist:cq(process.env.TRIPWIRE_PACKAGE_DIST)});var lq=()=>{};import{lstat as gq,mkdir as Pie,open as Fie,readFile as bp,readlink as Mie,realpath as Nie,rename as xq,rm as yy,stat as Die,symlink as fq}from"fs/promises";import{homedir as vp}from"os";import yc from"path";import{fileURLToPath as dq}from"url";var pq,yq,Ko=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),hl=(e,t)=>e instanceof Error&&("code"in e)&&e.code===t,wp=async(e,t,n={})=>{let r=e,o=!1;try{o=(await gq(e)).isSymbolicLink()}catch(c){if(!hl(c,"ENOENT"))throw c}if(o)r=await Nie(e);let s=`${r}.${process.pid}.next`,i,a=384;try{a=(await Die(r)).mode&4095}catch(c){if(!hl(c,"ENOENT"))throw c}await yy(s,{force:!0});try{i=await Fie(s,"wx",a),await i.writeFile(t,"utf8"),await i.chmod(a),await i.sync(),await i.close(),i=void 0,await n.beforeRename?.(s,r),await xq(s,r)}finally{try{if(i!==void 0)await i.close()}finally{await yy(s,{force:!0})}}},$ie=(e)=>Ko(e)&&typeof e.type==="string"&&typeof e.command==="string"&&(e.timeout===void 0||typeof e.timeout==="number"),mq=(e)=>Array.isArray(e)&&e.every((t)=>Ko(t)&&Array.isArray(t.hooks)&&t.hooks.every($ie)),Uie=(e)=>{if(!Ko(e))return!1;let{hooks:t}=e;if(t===void 0)return!0;return Ko(t)&&(t.PreToolUse===void 0||mq(t.PreToolUse))&&(t.PostToolUse===void 0||mq(t.PostToolUse))},_0=(e,t)=>{let n=JSON.parse(e);if(!Uie(n))throw Error(`${t} hook config has an unsupported shape`);return n},Lie=(e)=>{let t=JSON.parse(e);if(!Ko(t))throw Error("Cursor hooks.json must contain a JSON object");let{hooks:n}=t;if(n===void 0)return t;if(!Ko(n))throw Error("Cursor hooks.json `hooks` must be an object");for(let[r,o]of Object.entries(n))if(!Array.isArray(o)||o.some((s)=>!Ko(s)||typeof s.command!=="string"))throw Error(`Cursor hooks.json event ${r} must contain command hooks`);return t},Sc="tripwire-hook",Sq=async(e,t)=>{await Pie(yc.dirname(t),{recursive:!0});try{if(!(await gq(t)).isSymbolicLink())return{action:"already",success:!1};let r=await Mie(t);if(r===e)return{action:"already",success:!0};let o=yc.resolve(yc.dirname(t),r);if(yc.basename(o)!=="tripwire-pi.js")return{action:"already",success:!1};let s=`${t}.${process.pid}.next`;await yy(s,{force:!0});try{await fq(e,s),await xq(s,t)}finally{await yy(s,{force:!0})}return{action:"updated",success:!0}}catch(n){if(!(n instanceof Error&&("code"in n)&&n.code==="ENOENT"))throw n;return await fq(e,t),{action:"installed",success:!0}}},jie,Bie,Sy=(e)=>e===Sc||e.startsWith(`${Sc} `)||e.includes("/tripwire-darwin-arm64/")||e.includes("/tripwire-hook")||e.includes("/tripwire.js")||e.includes("/dist/tripwire"),Hie=(e,t,n=Sc)=>{let r=Bie.has(t),o={command:`${n} --cursor-event ${t}`,...r&&{failClosed:!0}};if(e===void 0)return[[o],!0];let s=!1,i=e.some((u)=>Sy(u.command)),a=`${n} --cursor-event ${t}`,c=e.map((u)=>{if(!Sy(u.command))return u;if(u.command===a&&(!r||u.failClosed===!0))return u;return s=!0,{...u,command:a,...r&&{failClosed:!0}}});if(i)return[c,s];return[[...c,o],!0]},Ey=(e,t=Sc)=>{if(!e)return[[{hooks:[{type:"command",command:t}]}],!1];let n=!1,r=e.map((i)=>({...i,hooks:i.hooks.map((a)=>{if(Sy(a.command)){if(a.command!==t)return n=!0,{...a,command:t};return a}return a})}));if(r.some((i)=>i.hooks.some((a)=>a.command===t)))return[r,!n];return[[...r,{hooks:[{type:"command",command:t}]}],!1]},R0=async(e={})=>{let t=e.homeDirectory??vp(),n=e.hookCommand??Sc,r=`${t}/.claude/settings.json`;try{let o=await bp(r,"utf8"),s=_0(o,"Claude");s.hooks??={};let[i,a]=Ey(s.hooks.PreToolUse,n),[c,u]=Ey(s.hooks.PostToolUse,n);if(s.hooks.PreToolUse=i,s.hooks.PostToolUse=c,a&&u)return{success:!0,message:`Already configured: ${r}`};return await wp(r,`${JSON.stringify(s,null,2)}
|
|
131
|
-
`),{success:!0,message:`Updated ${r}`}}catch(o){if(
|
|
132
|
-
`,c=a!==s,u=await
|
|
117
|
+
${IS(c[0].message)}${s}`;let u=new Map;for(let f of c){let d=f._tag??"Error",m=u.get(d)??[];m.push(f),u.set(d,m)}let l=[];l.push(`
|
|
118
|
+
${a}${i}ERRORS${s}`);for(let[,f]of u)for(let d of f)l.push(` ${IS(d.message)}${s}`);return l.join(`
|
|
119
|
+
`)},formatVersion:(c,u)=>`${o.bold(c)} ${o.dim("v")}${o.bold(u)}`}},Wie=(e)=>e.replace(/\u001B\[[0-9;]*m/g,""),G0=(e)=>Wie(e).length,jie=(e,t)=>{let n=G0(e),r=Math.max(0,t-n);return e+" ".repeat(r)},_m=(e,t)=>{let n=Math.max(...e.map((o)=>G0(o.left)))+4,r=t===void 0?n:Math.min(n,t);return e.map(({left:o,right:s})=>` ${jie(o,Math.max(r,G0(o)+1))}${s}`).join(`
|
|
120
|
+
`)},Iq=(e,t)=>t?`${e}, ${t}`:e,qie=(e,t)=>{let n=[];if(e.description)n.push(t.bold("DESCRIPTION")),n.push(` ${e.description}`),n.push("");if(n.push(t.bold("USAGE")),n.push(` ${t.cyan(e.usage)}`),n.push(""),e.args&&e.args.length>0){n.push(t.bold("ARGUMENTS"));let r=e.args.map((o)=>{let s=o.name;if(o.variadic)s+="...";let i=t.green(s),a=t.dim(o.type),c=`${i} ${a}`,u=o.required?"":t.dim(" (optional)"),l=It(o.description,()=>"")+u;return{left:c,right:l}});n.push(_m(r,25)),n.push("")}if(e.flags.length>0){n.push(t.bold("FLAGS"));let r=e.flags.map((o)=>{let s=[];s.push(t.green(`--${o.name}`));for(let c of o.aliases)s.push(t.green(c));let i=s.join(", "),a=o.type!=="boolean"?` ${t.dim(o.type)}`:"";return{left:i+a,right:It(o.description,()=>"")}});n.push(_m(r)),n.push("")}if(e.globalFlags&&e.globalFlags.length>0){n.push(t.bold("GLOBAL FLAGS"));let r=e.globalFlags.map((o)=>{let s=[];s.push(t.green(`--${o.name}`));for(let c of o.aliases)s.push(t.green(c));let i=s.join(", "),a=o.type!=="boolean"?` ${t.dim(o.type)}`:"";return{left:i+a,right:It(o.description,()=>"")}});n.push(_m(r)),n.push("")}if(e.subcommands&&e.subcommands.length>0){let r=e.subcommands.find((o)=>o.group===void 0);if(r){if(n.push(t.bold("SUBCOMMANDS")),n.push(_m(r.commands.map((o)=>({left:t.cyan(Iq(o.name,o.alias)),right:o.shortDescription??o.description})),20)),e.subcommands.length>1)n.push("")}for(let o of e.subcommands){if(o.group===void 0)continue;n.push(t.bold(`${o.group}:`)),n.push(_m(o.commands.map((s)=>({left:t.cyan(Iq(s.name,s.alias)),right:s.shortDescription??s.description})),20)),n.push("")}}if(e.examples&&e.examples.length>0){n.push(t.bold("EXAMPLES"));let r=!0,o=!1;for(let s of e.examples){if(s.description){if(!r)n.push("");n.push(` ${t.dim(`# ${s.description}`)}`)}else if(o)n.push("");n.push(` ${t.cyan(s.command)}`),r=!1,o=!!s.description}n.push("")}if(n[n.length-1]==="")n.pop();return n.join(`
|
|
121
|
+
`)};var J0=v(()=>{rt();Me();Ef=Te("effect/cli/CliOutput",{defaultValue:()=>Hie()})});var Om=(e)=>e.replace(/'/g,"'\\''"),Q0=(e)=>e.replace(/[^a-zA-Z0-9_]/g,"_"),Z0=(e)=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);if(e.type._tag==="Boolean")t.push(`--no-${e.name}`);return t},zie=(e,t)=>{if(e.length===0)return;let n=e.map(Z0);t.push(` local ${n.map((r,o)=>`_used_${o}=""`).join(" ")}`),t.push(" for ((i = 1; i < cword; i++)); do"),t.push(' case "${words[i]%%=*}" in'),n.forEach((r,o)=>{t.push(` ${r.join("|")}) _used_${o}=1 ;;`)}),t.push(" esac"),t.push(" done"),t.push(' local _filtered_flags=""'),n.forEach((r,o)=>{t.push(` [[ -n "$_used_${o}" ]] || _filtered_flags+=" ${r.join(" ")}"`)}),t.push("")},Vie=(e,t)=>{t.push(`${e}()`),t.push("{"),t.push(' local _cur="$1" _word="$2"; shift 2'),t.push(""),t.push(' local _head="${_cur%"$_word"}"'),t.push(' local _open=""'),t.push(' case "$_head" in'),t.push(` *\\') _open="'" ;;`),t.push(` *\\") _open='"' ;;`),t.push(" esac"),t.push(""),t.push(' local _prefix="$_cur" _committed="$_head"'),t.push(" _prefix=${_prefix//\\\\/}; _prefix=${_prefix//\\\"/}; _prefix=${_prefix//\\'/}"),t.push(" _committed=${_committed//\\\\/}; _committed=${_committed//\\\"/}; _committed=${_committed//\\'/}"),t.push(""),t.push(" COMPREPLY=()"),t.push(" local _choice _rest _match"),t.push(' for _choice in "$@"; do'),t.push(' [[ "$_choice" == "$_prefix"* ]] || continue'),t.push(' _rest="${_choice#"$_committed"}"'),t.push(' case "$_open" in'),t.push(` "'")`),t.push(` if [[ "$_head" == "'" ]]; then`),t.push(" _match=${_rest//\\'/\\'\\\\\\'\\'}"),t.push(" else"),t.push(' [[ "$_rest" == *\\\'* ]] && continue'),t.push(' _match="$_rest"'),t.push(" fi"),t.push(" ;;"),t.push(` '"')`),t.push(' _match="${_rest//\\\\/\\\\\\\\}"'),t.push(' _match="${_match//\\$/\\\\$}"'),t.push(' _match="${_match//\\`/\\\\\\`}"'),t.push(' _match="${_match//\\"/\\\\\\"}"'),t.push(" ;;"),t.push(" *)"),t.push(` printf -v _match '%q' "$_rest"`),t.push(` [[ -z "$_head" && "$_match" == '~'* ]] && _match="\\\\$_match"`),t.push(" ;;"),t.push(" esac"),t.push(' [[ -n "$_open" && "$_match" == *"$_open" ]] && _match+="$_open"'),t.push(' COMPREPLY+=("$_match")'),t.push(" done"),t.push("}"),t.push("")},Tq=(e,t)=>`${e} "$cur" "$_comp_word" ${t.map((n)=>`'${Om(n)}'`).join(" ")}`,Kie=(e,t)=>{switch(e._tag){case"Boolean":return;case"Choice":return Tq(t,e.values);case"Path":if(e.pathType==="directory")return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )';default:return}},Gie=(e,t)=>{switch(e._tag){case"Choice":return Tq(t,e.values);case"Path":if(e.pathType==="directory")return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )';default:return}},_q=(e,t,n,r)=>{let o=[...t,e.name],s=`_${o.map(Q0).join("_")}`;if(n.push(`${s}()`),n.push("{"),n.push(" local cur prev words cword i"),n.push(t.length===0?" local _command_index=0":' local _command_index="$1"'),n.push(' _init_completion -n "$COMP_WORDBREAKS" || return'),t.length===0)n.push(' local _comp_word="$2"');n.push("");let i=e.flags.filter((c)=>c.type._tag!=="Boolean");if(i.length>0){n.push(" # Flag value completions"),n.push(' case "$prev" in');for(let c of i){let u=[`--${c.name}`];for(let f of c.aliases)u.push(f.length===1?`-${f}`:`--${f}`);let l=Kie(c.type,r);if(l)n.push(` ${u.join("|")})`),n.push(` ${l}`),n.push(" return"),n.push(" ;;")}n.push(" esac"),n.push("")}if(e.subcommands.length>0){n.push(" # Subcommand dispatch"),n.push(" local cmd _skip_next=0"),n.push(" for ((i = _command_index + 1; i < cword; i++)); do"),n.push(" if (( _skip_next )); then"),n.push(" _skip_next=0"),n.push(" continue"),n.push(" fi"),n.push(' case "${words[i]}" in');for(let c of e.flags){if(c.type._tag==="Boolean")continue;let u=Z0(c);n.push(` ${u.join("|")}) _skip_next=1 ;;`),n.push(` ${u.map((l)=>`${l}=*`).join("|")}) ;;`)}for(let c of e.subcommands){let u=`_${[...o,c.name].map(Q0).join("_")}`;n.push(` ${c.name})`),n.push(` ${u} "$i"`),n.push(" return"),n.push(" ;;")}n.push(" esac"),n.push(" done"),n.push("")}if(zie(e.flags,n),e.flags.length>0||e.subcommands.length>0){if(n.push(" # Complete flags (filtered) and subcommands"),n.push(' if [[ "$cur" == -* ]]; then'),e.flags.length>0)n.push(' COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )');n.push(" return"),n.push(" fi"),n.push("")}let a=e.arguments.flatMap((c,u)=>{let l=Gie(c.type,r);return l===void 0?[]:[{argument:c,completion:l,index:u}]});if(a.length>0){n.push(" # Positional argument completions"),n.push(" local _position=0 _skip_next=0 _end_of_options=0"),n.push(" for ((i = _command_index + 1; i < cword; i++)); do"),n.push(" if (( _skip_next )); then"),n.push(" _skip_next=0"),n.push(" continue"),n.push(" fi"),n.push(" if (( _end_of_options )); then"),n.push(" ((_position += 1))"),n.push(" continue"),n.push(" fi"),n.push(' case "${words[i]}" in'),n.push(" --) _end_of_options=1 ;;");for(let u of e.flags){let l=Z0(u);if(u.type._tag==="Boolean")n.push(` ${l.join("|")}) ;;`);else n.push(` ${l.join("|")}) _skip_next=1 ;;`),n.push(` ${l.map((f)=>`${f}=*`).join("|")}) ;;`)}n.push(" -*) ;;"),n.push(" *) ((_position += 1)) ;;"),n.push(" esac"),n.push(" done"),n.push(' case "$_position" in');for(let{argument:u,completion:l,index:f}of a){if(u.variadic)continue;n.push(` ${f})`),n.push(` ${l}`),n.push(" return"),n.push(" ;;")}n.push(" esac");let c=a.find(({argument:u})=>u.variadic);if(c!==void 0)n.push(` if (( _position >= ${c.index} )); then`),n.push(` ${c.completion}`),n.push(" return"),n.push(" fi")}else if(e.subcommands.length>0){let c=e.subcommands.map((u)=>u.name);n.push(` COMPREPLY=( $(compgen -W '${c.join(" ")}' -- "$cur") )`)}n.push("}"),n.push("");for(let c of e.subcommands)_q(c,o,n,r)},Oq=(e,t)=>{let n=[],r=Q0(e),o=`_${r}--choices`;return n.push(`###-begin-${Om(e)}-completions-###`),n.push("#"),n.push("# Static completion script for Bash"),n.push("#"),n.push("# Installation:"),n.push(`# ${Om(e)} --completions bash >> ~/.bashrc`),n.push("#"),n.push(""),n.push("if ! type _init_completion &>/dev/null; then"),n.push(" _init_completion()"),n.push(" {"),n.push(" COMPREPLY=()"),n.push(' local _i _j=0 _piece _line="$COMP_LINE"'),n.push(' words=("${COMP_WORDS[0]}")'),n.push(" cword=0"),n.push(' _line="${_line#*"${COMP_WORDS[0]}"}"'),n.push(" for ((_i = 1; _i < ${#COMP_WORDS[@]}; _i++)); do"),n.push(' _piece="${COMP_WORDS[_i]}"'),n.push(' if [[ "$_line" == [[:blank:]]* ]]; then'),n.push(" ((_j++))"),n.push(' words[_j]="$_piece"'),n.push(" else"),n.push(' words[_j]="${words[_j]}$_piece"'),n.push(" fi"),n.push(" ((_i == COMP_CWORD)) && cword=$_j"),n.push(' _line="${_line#*"$_piece"}"'),n.push(" done"),n.push(' cur="${words[cword]}"'),n.push(' prev=""'),n.push(' ((cword > 0)) && prev="${words[cword-1]}"'),n.push(" return 0"),n.push(" }"),n.push("fi"),n.push(""),Vie(o,n),_q(t,[],n,o),n.push(`complete -F _${r} ${Om(e)}`),n.push(`###-end-${Om(e)}-completions-###`),n.join(`
|
|
122
|
+
`)};var qa=(e)=>e.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),Pq=(e)=>qa(e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,"\\$&")),Qie=(e,t)=>{if(e.length===0){if(t.length>0)return"__fish_use_subcommand";return""}let n=e.map((r)=>`__fish_seen_subcommand_from ${r}`).join("; and ");if(t.length>0)return`${n}; and not __fish_seen_subcommand_from ${t.join(" ")}`;return n},Y0=(e)=>{let t=[];for(let n of e.aliases)if(n.length===1)t.push(`-s ${n}`);t.push(e.name);for(let n of e.aliases)if(n.length>1)t.push(n);if(e.type._tag==="Boolean")t.push(`no-${e.name}`);return`not __fish_contains_opt ${t.join(" ")}`},Zie=(e)=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);return`begin; ${Y0(e)}; or contains -- (commandline -poc)[-1] ${t.join(" ")}; end`},Yie=(e)=>{let t=[`-l ${e.name}`];for(let r of e.aliases)if(r.length===1)t.push(`-s ${r}`);else t.push(`-l ${r}`);if(e.description)t.push(`-d '${qa(e.description)}'`);let n=Xie(e.type);if(n)t.push(n);return t},Xie=(e)=>{switch(e._tag){case"Boolean":return;case"Choice":return`-r -f -a '${e.values.map(Pq).join(" ")}'`;case"Path":if(e.pathType==="directory")return"-r -F";return"-r -F";default:return"-r -f"}},eae=(e)=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.map(Pq).join(" ")}'`;case"Path":return"-r -F";default:return}},Rq=(e,t,n,r)=>{let o=t.subcommands.map((c)=>c.name),s=Qie(n,o),i=s?`-n '${s}'`:"";if(!t.arguments.some((c)=>c.type._tag==="Path")){let c=[`complete -c ${e}`];if(i)c.push(i);c.push("-f"),r.push(c.join(" "))}for(let c of t.subcommands){let u=[`complete -c ${e}`];if(i)u.push(i);if(u.push(`-f -a '${qa(c.name)}'`),c.description)u.push(`-d '${qa(c.description)}'`);r.push(u.join(" "))}for(let c of t.flags){let u=c.type._tag==="Boolean",l=u?Y0(c):Zie(c),f=s?`${s}; and ${l}`:l,d=f?`-n '${f}'`:"",m=[`complete -c ${e}`];if(d)m.push(d);if(m.push(...Yie(c)),r.push(m.join(" ")),u){let y=[`complete -c ${e}`];if(d)y.push(d);if(y.push(`-l no-${c.name}`),c.description)y.push(`-d '${qa(`Disable ${c.name}`)}'`);r.push(y.join(" "))}}if(t.flags.length>0){let u=s?`${s}; and not string match -q -- "-*" (commandline -ct)`:'not string match -q -- "-*" (commandline -ct)';for(let l of t.flags){let f=`${u}; and ${Y0(l)}`,d=l.type._tag==="Boolean",m=[`complete -c ${e}`];if(m.push(`-n '${f}'`),m.push(`-f -a '--${l.name}'`),l.description)m.push(`-d '${qa(l.description)}'`);if(r.push(m.join(" ")),d){let y=[`complete -c ${e}`];if(y.push(`-n '${f}'`),y.push(`-f -a '--no-${l.name}'`),l.description)y.push(`-d '${qa(`Disable ${l.name}`)}'`);r.push(y.join(" "))}}}for(let c of t.arguments){let u=eae(c.type);if(u){let l=[`complete -c ${e}`];if(i)l.push(i);if(l.push(u),c.description)l.push(`-d '${qa(c.description)}'`);r.push(l.join(" "))}}for(let c of t.subcommands)Rq(e,c,[...n,c.name],r)},Fq=(e,t)=>{let n=[];return n.push(`###-begin-${e}-completions-###`),n.push("#"),n.push("# Static completion script for Fish"),n.push("#"),n.push("# Installation:"),n.push(`# ${e} --completions fish > ~/.config/fish/completions/${e}.fish`),n.push("#"),n.push(""),Rq(e,t,[],n),n.push(""),n.push(`###-end-${e}-completions-###`),n.join(`
|
|
123
|
+
`)};var AS=(e)=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),Nq=(e)=>e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,"\\$&").replace(/'/g,"'\\''"),X0=(e)=>e.replace(/[^a-zA-Z0-9_]/g,"_"),nae=(e)=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);if(e.type._tag==="Boolean")t.push(`--no-${e.name}`);return t},rae=(e)=>{switch(e._tag){case"Boolean":return"";case"Choice":return`:value:(${e.values.map(Nq).join(" ")})`;case"Path":return e.pathType==="directory"?":directory:_directories":":file:_files";case"Integer":return":integer:";case"Float":return":float:";case"Date":return":date:";default:return":value:"}},oae=(e)=>{switch(e._tag){case"Choice":return`(${e.values.map(Nq).join(" ")})`;case"Path":return e.pathType==="directory"?"_directories":"_files";default:return""}},Mq=(e)=>{let t=[],n=e.description?`[${AS(e.description)}]`:"",r=rae(e.type),o=`(${nae(e).join(" ")})`;t.push(`'${o}--${e.name}${n}${r}'`);for(let s of e.aliases){let i=s.length===1?"-":"--";t.push(`'${o}${i}${s}${n}${r}'`)}if(e.type._tag==="Boolean"){let s=e.description?`[${AS(`Disable ${e.name}`)}]`:"";t.push(`'${o}--no-${e.name}${s}'`)}return t},Dq=(e)=>{let t=e.description?AS(e.description):e.name,n=oae(e.type);return`'${e.variadic?"*":""}:${t}:${n}'`},$q=(e,t,n)=>{let r=[...t,e.name],o=`_${r.map(X0).join("_")}`;if(n.push(`${o}() {`),e.subcommands.length>0){n.push(" local context state state_descr line"),n.push(" typeset -A opt_args"),n.push(""),n.push(" local -a commands"),n.push(" commands=(");for(let s of e.subcommands){let i=s.description?AS(s.description):"";n.push(` '${s.name}:${i}'`)}n.push(" )"),n.push(""),n.push(" local -a specs"),n.push(" specs=(");for(let s of e.flags)for(let i of Mq(s))n.push(` ${i}`);if(e.arguments.length>0){n.push(" -"),n.push(" parent-arguments");for(let s of e.arguments)n.push(` ${Dq(s)}`);n.push(" -"),n.push(" subcommands")}n.push(" '1:command:->command'"),n.push(" '*::arg:->args'"),n.push(" )"),n.push(""),n.push(' _arguments -C "${specs[@]}"'),n.push(""),n.push(' case "$state" in'),n.push(" command)"),n.push(" _describe -t commands 'commands' commands"),n.push(" ;;"),n.push(" args)"),n.push(' case "$words[1]" in');for(let s of e.subcommands){let i=`_${[...r,s.name].map(X0).join("_")}`;n.push(` ${s.name})`),n.push(` ${i}`),n.push(" ;;")}n.push(" esac"),n.push(" ;;"),n.push(" esac")}else{let s=[];for(let i of e.flags)s.push(...Mq(i));for(let i of e.arguments)s.push(Dq(i));if(s.length>0){n.push(" local -a specs"),n.push(" specs=(");for(let i of s)n.push(` ${i}`);n.push(" )"),n.push(' _arguments "${specs[@]}"')}}n.push("}"),n.push("");for(let s of e.subcommands)$q(s,r,n)},Uq=(e,t)=>{let n=[],r=X0(e);return n.push(`#compdef ${e}`),n.push(`###-begin-${e}-completions-###`),n.push("#"),n.push("# Static completion script for Zsh"),n.push("#"),n.push("# Installation:"),n.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),n.push("# then add ~/.zsh/completions to your fpath"),n.push("#"),n.push(""),$q(t,[],n),n.push("# Handle both direct invocation and autoload"),n.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),n.push(` _${r} "$@"`),n.push("else"),n.push(` compdef _${r} ${e}`),n.push("fi"),n.push(`###-end-${e}-completions-###`),n.join(`
|
|
124
|
+
`)};var Lq=(e,t,n)=>{switch(t){case"bash":return Oq(e,n);case"zsh":return Uq(e,n);case"fish":return Fq(e,n)}};var Bq=()=>{};var Ht={};Qn(Ht,{atLeast:()=>vae,atMost:()=>Iae,between:()=>Aae,boolean:()=>Pm,choice:()=>tA,choiceWithValue:()=>eA,date:()=>lae,directory:()=>pae,file:()=>dae,fileParse:()=>gae,fileSchema:()=>xae,fileText:()=>hae,filter:()=>_ae,filterMap:()=>Tae,float:()=>uae,integer:()=>cae,keyValuePair:()=>yae,map:()=>nA,mapEffect:()=>kae,mapTryCatch:()=>Cae,none:()=>Sae,optional:()=>OS,orElse:()=>Oae,orElseResult:()=>Pae,path:()=>fae,redacted:()=>mae,string:()=>aae,withAlias:()=>TS,withDefault:()=>Rm,withDescription:()=>yu,withFallbackConfig:()=>bae,withFallbackPrompt:()=>wae,withHidden:()=>Eae,withMetavar:()=>_S,withSchema:()=>Rae});var aae=(e)=>eS(Bt,e),Pm=(e)=>Eq(Bt,e),cae=(e)=>tS(Bt,e),uae=(e)=>nS(Bt,e),lae=(e)=>rS(Bt,e),eA=(e,t)=>Am(Bt,e,t),tA=(e,t)=>oS(Bt,e,t),fae=(e,t)=>Sf(Bt,e,t),dae=(e,t)=>iS(Bt,e,t),pae=(e,t)=>sS(Bt,e,t),mae=(e)=>aS(Bt,e),hae=(e)=>cS(Bt,e),gae=(e,t)=>uS(Bt,e,t),xae=(e,t,n)=>lS(Bt,e,t,n),yae=(e)=>bq(Bt,e),Sae,TS,yu,_S,Eae=(e)=>kq(e),OS=(e)=>fu(e),Rm,bae,wae,nA,kae,Cae,vae,Iae,Aae,Tae,_ae,Oae,Pae,Rae;var rA=v(()=>{ne();Fs();Sae=fS(Bt),TS=p(2,(e,t)=>wq(e,t)),yu=p(2,(e,t)=>dS(e,t)),_S=p(2,(e,t)=>bS(e,t)),Rm=mS,bae=p(2,(e,t)=>hS(e,t)),wae=p(2,(e,t)=>gS(e,t)),nA=p(2,(e,t)=>pu(e,t)),kae=p(2,(e,t)=>hu(e,t)),Cae=p(3,(e,t,n)=>pS(e,t,n)),vae=p(2,(e,t)=>SS(e,t)),Iae=p(2,(e,t)=>yS(e,t)),Aae=p(3,(e,t,n)=>xS(e,t,n)),Tae=p(3,(e,t,n)=>Tm(e,t,n)),_ae=p(3,(e,t,n)=>ES(e,t,n)),Oae=p(2,(e,t)=>kS(e,t)),Pae=p(2,(e,t)=>CS(e,t)),Rae=p(2,(e,t)=>wS(e,t))});var PS="~effect/cli/Command/Config/Internal",RS=(e)=>{let t=[],n=[],r=[];function o(i){let a=Object.create(null);for(let c of Object.keys(i))a[c]=s(i[c]);return a}function s(i){if(Array.isArray(i))return{_tag:"Array",children:i.map((a)=>s(a))};else if(Xy(i)){let a=t.length;if(t.push(i),i.kind==="argument")r.push(i);else n.push(i);return{_tag:"Param",index:a}}else return{_tag:"Nested",tree:o(i)}}return{[PS]:PS,flags:n,arguments:r,orderedParams:t,tree:o(e)}},Hq,Wq=(e,t)=>{switch(e._tag){case"Param":return{_tag:"Param",index:e.index+t};case"Array":return{_tag:"Array",children:e.children.map((n)=>Wq(n,t))};case"Nested":return{_tag:"Nested",tree:jq(e.tree,t)}}},jq=(e,t)=>{let n=Object.create(null);for(let r of Object.keys(e))n[r]=Wq(e[r],t);return n},oA=(e,t)=>{let n=e.orderedParams.length;return{[PS]:PS,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:Object.assign(Object.create(null),e.tree,jq(t.tree,n))}},sA=(e,t)=>{let n={};for(let o of Object.keys(e))H(n,o,r(e[o]));return n;function r(o){switch(o._tag){case"Param":return t[o.index];case"Array":return o.children.map((s)=>r(s));case"Nested":return sA(o.tree,t)}}};var iA=v(()=>{Fs();Hq=RS({})});var Fm="~effect/cli/Command",Be=(e)=>e,Fae,Rr=(e)=>{let t=e.config,n=e.contextConfig??Hq,r=e.service??Ye(`${Fm}/${e.name}`),o=e.annotations??Ln(),s=e.globalFlags??[],i=e.subcommands??[],a=(f,d)=>Ve(e.handle)?e.handle(f,d):R(new Ha({commandPath:d,errors:[]})),c=e.parse??FS(t),u=e.parseContext??FS(n,{allowLeftovers:!0}),l=(f)=>{let d=[],m=[];for(let w of t.arguments){let k=St(w),g=Pr(w);for(let x of k)d.push({name:x.name,type:x.typeName??wm(x.primitiveType),description:x.description,required:!g.isOptional&&(!g.isVariadic||wE(g.variadicMin,(S)=>S>0)),variadic:g.isVariadic})}let y=f.length>0?f.join(" "):e.name;if(i.some((w)=>w.commands.some((k)=>!k.unlisted)))y+=" <subcommand>";y+=" [flags]";for(let w of d){let k=w.variadic?`<${w.name}...>`:`<${w.name}>`;y+=` ${w.required?k:`[${k}]`}`}for(let w of t.flags){let k=St(w),g=Pr(w);for(let x of k){if(x.hidden)continue;m.push(MS(x,g))}}let b=[];for(let w of i){let k=w.commands.filter((g)=>!g.unlisted);if(k.length===0)continue;b.push({group:w.group,commands:sn(k,(g)=>({name:g.name,alias:g.alias,shortDescription:g.shortDescription,description:g.description??""}))})}let E=e.examples??[];return{description:e.description??"",usage:y,flags:m,annotations:o,...d.length>0&&{args:d},...b.length>0&&{subcommands:b},...E.length>0&&{examples:E}}};return Object.assign(Object.create(Fae),{[Fm]:Fm,name:e.name,examples:e.examples??[],annotations:o,globalFlags:s,subcommands:i,unlisted:e.unlisted??!1,config:t,contextConfig:n,service:r,parse:c,parseContext:u,handle:a,buildHelpDoc:l,...Ve(e.description)?{description:e.description}:{},...Ve(e.shortDescription)?{shortDescription:e.shortDescription}:{},...Ve(e.alias)?{alias:e.alias}:{}})},MS=(e,t)=>{let n=e.aliases.map((r)=>r.length===1?`-${r}`:`--${r}`);return{name:e.name,aliases:n,type:e.typeName??wm(e.primitiveType),description:Mae(e.description,Fi(e.primitiveType)),required:e.primitiveType._tag!=="Boolean"&&!t.isOptional}},Mae=(e,t)=>{if(t===void 0||t.length===0)return e;let n=`(choices: ${t.join(", ")})`;return ut(e,{onNone:()=>F(n),onSome:(r)=>F(`${r} ${n}`)})},FS=(e,t)=>q(function*(n){let r={flags:n.flags,arguments:n.arguments},[o,s]=yield*Dae(r,e.orderedParams);if(t?.allowLeftovers!==!0&&o.length>0)return yield*new Hy({arguments:o});return sA(e.tree,s)}),Dae,aA=(e,t,n)=>{let r=Be(e),o=new Set;((i)=>{for(let a of i){let c=St(a);for(let u of c)o.add(u.name)}})((n?.contextConfig??r.contextConfig).flags);for(let i of t){let a=Be(i);for(let c of a.config.flags){let u=St(c);for(let l of u)if(o.has(l.name))throw new Ly({option:l.name,parentCommand:e.name,childCommand:i.name})}}};var bf=v(()=>{nr();rt();Re();Fu();Me();ge();Em();Fs();gf();iA();Fae={...ss({label:"Command",evaluate(){return Be(this).service}})},Dae=q(function*(e,t){let n=[],r=e.arguments;for(let o of t){let[s,i]=yield*o.parse({flags:e.flags,arguments:r});n.push(i),r=s}return[r,n]})});var Nae=(e)=>{switch(e.primitiveType._tag){case"Boolean":return{_tag:"Boolean"};case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:Fi(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:O0(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},$ae=(e)=>{switch(e.primitiveType._tag){case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:Fi(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:O0(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},cA=(e)=>{let n=Be(e).config,r=[];for(let i of n.flags){let a=St(i);for(let c of a){if(c.kind!=="flag")continue;if(c.hidden)continue;r.push({name:c.name,aliases:c.aliases,description:Un(c.description),type:Nae(c)})}}let o=[];for(let i of n.arguments){let a=St(i),c=Pr(i);for(let u of a){if(u.kind!=="argument")continue;o.push({name:u.name,description:Un(u.description),required:!c.isOptional,variadic:c.isVariadic,type:$ae(u)})}}let s=[];for(let i of e.subcommands)for(let a of i.commands){if(a.unlisted)continue;s.push(cA(a))}return{name:e.name,description:e.shortDescription??e.description,flags:r,arguments:o,subcommands:s}};var qq=v(()=>{Me();Fs();gf();bf()});var uA=(e)=>{let t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r),n.push(r)}return n},zq=(e,t)=>{let n=[e],r=e;for(let o=1;o<t.length;o++){let s=t[o],i=void 0;for(let a of r.subcommands)if(i=a.commands.find((c)=>c.name===s),i)break;if(!i)break;n.push(i),r=i}return n},lA=(e,t,n)=>{let o=zq(e,t).flatMap((s)=>Be(s).globalFlags);return uA([...n,...o])},Lae=(e)=>{let t=[],n=(r)=>{let o=Be(r);for(let s of o.globalFlags)t.push(s);for(let s of r.subcommands)for(let i of s.commands)n(i)};return n(e),uA(t)},Bae=(e,t)=>{if(e.length<=1)return[];let n=new Set(t.map((o)=>o.name)),r=[];for(let o of e.slice(0,-1)){let s=Be(o);for(let i of s.contextConfig.flags){let a=St(i),c=Pr(i);for(let u of a){if(n.has(u.name))continue;if(u.hidden)continue;n.add(u.name),r.push(MS(u,c))}}}return r},Vq=(e,t)=>uA([...t,...Lae(e)]),DS=(e,t,n)=>un(function*(){let r=zq(e,t),o=r.length>0?r[r.length-1]:e,s=Be(o).buildHelpDoc(t),i=Bae(r,s.flags),a=lA(e,t,n),c=[];for(let u of a){let l=St(u.flag),f=Pr(u.flag);for(let d of l){if(d.hidden)continue;c.push({...MS(d,f),required:!1})}}return{...s,flags:[...i,...s.flags],globalFlags:c}});var fA=v(()=>{Re();Fs();bf()});var NS=(e)=>({_tag:"Action",flag:e.flag,run:e.run}),Wae=(e)=>(t)=>{Kq+=1;let n=Ye(`effect/unstable/cli/GlobalFlag/${e}/${Kq}`);return Object.assign(n,{_tag:"Setting",id:e,flag:t.flag})},Kq=0,jae,qae,dA,zae,wf,Gq;var pA=v(()=>{vS();rt();Re();Me();J0();Bq();rA();qq();fA();jae=NS({flag:Pm("help").pipe(TS("h"),yu("Show help information"),Rm(!1)),run:q(function*(e,{builtIns:t,command:n,commandPath:r}){let o=yield*Ef,s=yield*DS(n,r,t);yield*Fn(o.formatHelpDoc(s))})}),qae=NS({flag:Pm("version").pipe(TS("v"),yu("Show version information"),Rm(!1)),run:q(function*(e,{command:t,version:n}){let r=yield*Ef;yield*Fn(r.formatVersion(t.name,n))})}),dA=NS({flag:Pm("wizard").pipe(yu("Start wizard mode for a command"),Rm(!1)),run:()=>Pe}),zae=NS({flag:tA("completions",["bash","zsh","fish","sh"]).pipe(OS,nA((e)=>kn(e,(t)=>t==="sh"?"bash":t)),_S("<bash|zsh|fish|sh>"),yu("Print shell completion script")),run:q(function*(e,{command:t}){if(he(e))return;let n=cA(t);yield*Fn(Lq(t.name,e.value,n))})}),wf=Wae("log-level")({flag:eA("log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(OS,yu("Sets the minimum log level"),_S("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),Gq=[jae,qae,dA,zae,wf]});var $S,Vae;var Qq=v(()=>{rt();pA();$S=class $S extends Te("effect/unstable/cli/CliConfig",{defaultValue:()=>Vae}){};Vae={builtIns:Gq}});function Yq(e){let t=e.indexOf("--");if(t===-1)return{tokens:Zq(e),trailingOperands:[]};return{tokens:Zq(e.slice(0,t)),trailingOperands:e.slice(t+1)}}var Zq=(e)=>{let t=[];for(let n of e)if(!n.startsWith("-"))t.push({_tag:"Value",value:n});else if(n.startsWith("--")){let r=n.indexOf("=");if(r!==-1){let o=n.slice(2,r),s=n.slice(r+1);t.push({_tag:"LongOption",name:o,raw:n,value:s})}else t.push({_tag:"LongOption",name:n.slice(2),raw:n})}else if(n.length>1){let r=n.slice(1),o=r.indexOf("=");if(o!==-1){let s=r.slice(0,o),i=r.slice(o+1);t.push({_tag:"ShortOption",flag:s,raw:`-${s}`,value:i})}else for(let s of r)t.push({_tag:"ShortOption",flag:s,raw:`-${s}`})}else t.push({_tag:"Value",value:n});return t};var Jae=(e,t)=>{let n=e.length,r=t.length,o=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let s=0;s<=n;s++)o[s][0]=s;for(let s=0;s<=r;s++)o[0][s]=s;for(let s=1;s<=n;s++)for(let i=1;i<=r;i++){let a=e[s-1]===t[i-1]?0:1;o[s][i]=Math.min(o[s-1][i]+1,o[s][i-1]+1,o[s-1][i-1]+a)}return o[n][r]},mA=(e,t)=>{let n=t.map((o)=>[Jae(e,o),o]).filter(([o])=>o<=2).sort(([o],[s])=>o-s);if(n.length===0)return[];let r=n[0][0];return n.filter(([o])=>o===r).map(([,o])=>o)};var gA=(e)=>ut(e.subcommand,{onNone:()=>[],onSome:(t)=>[t.name,...gA(t.parsedInput)]}),xA=(e,t,n=[])=>un(function*(){let{tokens:r,trailingOperands:o}=e,s=[...n,t.name],i=Be(t),c=i.config.flags.flatMap(St).filter(du),u=Cf(c),f=i.contextConfig.flags.flatMap(St).filter(du),d=Cf(f),m=new Set(f.map((g)=>g.name)),y={command:t,commandPath:s,flagRegistry:u,inheritedFlagRegistry:d,localFlagNames:c.filter((g)=>!m.has(g.name)).map((g)=>g.name)},b=cce(r,y);if(b._tag==="Leaf")return{flags:b.flags,arguments:[...b.arguments,...o],subcommand:P(),...b.errors.length>0&&{errors:b.errors}};let E={tokens:b.childTokens,trailingOperands:o},w=yield*xA(E,b.sub,s),k=[...b.errors,...w.errors??[]];return{flags:b.flags,arguments:[],subcommand:F({name:b.sub.name,parsedInput:w}),...k.length>0&&{errors:k}}}),US=(e)=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},Cf=(e)=>{let t=new Map;for(let n of e){if(t.has(n.name))throw Error(`Duplicate flag name "${n.name}" in command definition`);t.set(n.name,n);for(let r of n.aliases){if(t.has(r))throw Error(`Duplicate flag/alias "${r}" in command definition (conflicts with "${t.get(r).name}")`);t.set(r,n)}}return{params:e,index:t}},tz=(e)=>{let t=new Map,n=(r,o)=>{let s=t.get(r);if(s&&s!==o)throw Error(`Duplicate subcommand name/alias "${r}" in command definition (conflicts with "${s.name}")`);t.set(r,o)};for(let r of e)for(let o of r.commands)if(n(o.name,o),o.alias&&o.alias!==o.name)n(o.alias,o);return t},yA=(e)=>Object.fromEntries(e.map((t)=>[t.name,[]])),Qae=(e)=>{let t=yA(e);return{add:(n,r)=>{if(r!==void 0)t[n].push(r)},merge:(n)=>{for(let r in n){let o=n[r];if(o?.length)for(let s=0;s<o.length;s++)t[r].push(o[s])}},snapshot:()=>t}},LS=(e)=>e._tag==="LongOption"||e._tag==="ShortOption",nz=(e)=>e._tag==="LongOption"?e.name:e.flag,kf=(e,t)=>{let n=nz(e),r=t.index.get(n);if(r&&r.name===n)return{param:r,negated:!1};if(e._tag==="LongOption"&&e.name.startsWith("no-")){let o=e.name.slice(3),s=t.index.get(o);if(s&&s.name===o&&Vy(s.primitiveType))return{param:s,negated:!0}}if(r)return{param:r,negated:!1};return},Xq=(e,t,n)=>new fr({option:t.name,value:n,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),Zae=(e)=>{let t=Fi(e.primitiveType);return new fr({option:e.name,value:"",expected:t===void 0?e.typeName??wm(e.primitiveType):t.join(" | "),kind:"flag"})},ez=(e)=>e?._tag==="Value"&&(xj(e.value)||yj(e.value))?e.value:void 0,rz=(e,t,n,r=!1)=>{let o=Mm(e,t,n,r);switch(o._tag){case"Value":return{_tag:"Value",value:o.value};case"Error":return{_tag:"Error",error:o.error}}},Mm=(e,t,n,r=!1)=>{if(r){if(t.value!==void 0)return{_tag:"Error",error:Xq(t,n,t.value),tokens:[]};let s=ez(e.peek());if(s!==void 0){let i=e.take();return{_tag:"Error",error:Xq(t,n,s),tokens:i===void 0?[]:[i]}}return{_tag:"Value",value:"false",tokens:[]}}if(t.value!==void 0)return{_tag:"Value",value:t.value,tokens:[]};if(Vy(n.primitiveType)){let s=ez(e.peek()),i=s!==void 0?e.take():void 0;return{_tag:"Value",value:s??"true",tokens:i===void 0?[]:[i]}}let o=e.peek();if(o?._tag==="Value"){let s=e.take();return{_tag:"Value",value:o.value,tokens:s===void 0?[]:[s]}}return{_tag:"Error",error:Zae(n),tokens:[]}},Yae=(e,t)=>{let n=yA(t.params),r=[],o=[],s=US(e);for(let i=s.take();i;i=s.take()){if(!LS(i)){r.push(i);continue}let a=kf(i,t);if(!a){r.push(i);continue}let c=rz(s,i,a.param,a.negated);if(c._tag==="Error"){o.push(c.error);continue}if(c.value!==void 0)n[a.param.name].push(c.value)}return{flagMap:n,remainder:r,errors:o}},Xae=(e)=>Be(e).config.flags.flatMap(St).filter(du),ece=(e)=>Be(e).contextConfig.flags.flatMap(St).filter(du),oz=(e,t)=>{for(let n of t){let r=kf(e,n);if(r!==void 0)return r}return},hA=(e,t,n,r)=>{e.push(n);let o=Mm(t,n,r.param,r.negated);e.push(...o.tokens)},tce=(e,t,n,r,o)=>{let s=US(t);Mm(s,e,n.param,n.negated);for(let i=s.take();i;i=s.take()){if(LS(i)){let a=oz(i,o);if(a!==void 0)Mm(s,i,a.param,a.negated);continue}if(i._tag==="Value")return r.has(i.value)}return!1},sz=(e,t,n)=>{let r=yA(n.params),o=[],s=(i,a,c)=>{let u=Cf(Xae(a)),l=Cf(ece(a)),f=tz(a.subcommands),d=US(i),m=[],y=!0;for(let b=d.take();b;b=d.take()){if(LS(b)){let E=oz(b,c);if(E!==void 0){hA(m,d,b,E);continue}let w=kf(b,l);if(w!==void 0){hA(m,d,b,w);continue}let k=kf(b,u),g=kf(b,n);if(k!==void 0){if(g===void 0||!y||!tce(b,d.rest(),k,f,[u,l,n])){hA(m,d,b,k);continue}}if(g!==void 0){let x=Mm(d,b,g.param,g.negated);if(x._tag==="Error"){o.push(x.error);continue}if(x.value!==void 0)r[g.param.name].push(x.value);continue}m.push(b);continue}if(b._tag==="Value"&&y){let E=f.get(b.value);if(E!==void 0)return m.push(b),m.push(...s(d.rest(),E,[...c,l])),m;y=!1}m.push(b)}return m};return{flagMap:r,remainder:s(e,t,[]),errors:o}},nce=(e,t,n)=>{let r=e._tag==="LongOption"?`--${e.name}`:`-${e.flag}`,o=[];for(let i of t){if(i.hidden)continue;if(o.push(i.name),Vy(i.primitiveType))o.push(`no-${i.name}`);for(let a of i.aliases)o.push(a)}let s=mA(nz(e),o).map((i)=>i.length===1?`-${i}`:`--${i}`);return new ru({option:r,suggestions:s,command:n})},rce=(e)=>({flags:Qae(e.params),arguments:[],errors:[],mode:{_tag:"AwaitingFirstValue"}}),oce=(e)=>({_tag:"Leaf",flags:e.flags.snapshot(),arguments:e.arguments,errors:e.errors}),sce=(e,t,n,r)=>{let{command:o,commandPath:s,inheritedFlagRegistry:i,localFlagNames:a}=n,c=tz(o.subcommands),u=c.get(e);if(u){let f=[...s,u.name],d=r.flags.snapshot();for(let y of a){let b=d[y];if(b!==void 0&&b.length>0)r.errors.push(new ru({option:`--${y}`,suggestions:[],command:f}))}let m=Yae(t.rest(),i);return r.flags.merge(m.flagMap),r.errors.push(...m.errors),{_tag:"Subcommand",result:{_tag:"Sub",flags:r.flags.snapshot(),sub:u,childTokens:m.remainder,errors:r.errors}}}if(!(Be(o).config.arguments.length>0)&&c.size>0){let f=[];for(let[m,y]of c)if(!y.unlisted)f.push(m);let d=mA(e,f);r.errors.push(new Wy({subcommand:e,parent:s,suggestions:d}))}return{_tag:"Argument"}},ice=(e,t,n,r)=>{let{commandPath:o,flagRegistry:s}=n,i=kf(e,s);if(!i){r.errors.push(nce(e,s.params,o));return}let a=rz(t,e,i.param,i.negated);if(a._tag==="Error"){r.errors.push(a.error);return}r.flags.add(i.param.name,a.value)},ace=(e,t,n,r)=>{if(r.mode._tag==="AwaitingFirstValue"){let o=sce(e,t,n,r);if(o._tag==="Subcommand")return o.result;r.mode={_tag:"CollectingArguments"}}r.arguments.push(e);return},cce=(e,t)=>{let n=US(e),r=rce(t.flagRegistry);for(let o=n.take();o;o=n.take()){if(LS(o)){ice(o,n,t,r);continue}if(o._tag==="Value"){let s=ace(o.value,n,t,r);if(s)return s}}return oce(r)};var iz=v(()=>{Re();Me();Em();Fs();gf();bf()});var EA,lce=(e,t)=>{let n=e;for(let r of t.slice(1)){let o=n.subcommands.flatMap((s)=>s.commands).find((s)=>s.name===r||s.alias===r);if(o===void 0)break;n=o}return n},uz,fce=(e)=>e.subcommands.some((n)=>n.commands.some((r)=>!r.unlisted))||Be(e).config.orderedParams.length>0,az,dce=(e)=>{let t=mce(e);switch(e.primitiveType._tag){case"Boolean":return ae(Jn(F0({message:t,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),(n)=>Ms(String(n)));case"Choice":{let n=Fi(e.primitiveType)??[];return ae(Jn(D0({message:t,choices:n.map((r)=>({title:r,value:r}))})),Ms)}case"Date":return ae(Jn(Gj({message:t})),(n)=>Ms(n.toISOString()));case"Float":return ae(Jn(Jj({message:t})),(n)=>Ms(String(n)));case"Integer":return ae(Jn(M0({message:t})),(n)=>Ms(String(n)));case"Redacted":return ae(Jn(Qj({message:t})),(n)=>Ms(_a(n),"<redacted>"));default:return ae(Jn(Zj({message:t})),Ms)}},Ms=(e,t=e)=>({value:e,displayValue:t}),pce=(e)=>e.kind===Bt?`--${e.name}`:e.name,mce=(e)=>SA(e),SA=(e)=>{let t=Un(e.description)?.trim(),n=e.kind===Bt&&t!==void 0&&t.length<=32?t:hce(e.name);return e.kind===Bt?`${n} (${pce(e)})`:n},hce=(e)=>{let t=e.split(/[-_]+/).filter((n)=>n.length>0);if(t.length===0)return e;return[t[0][0].toUpperCase()+t[0].slice(1),...t.slice(1)].join(" ")},BS=(e)=>Fn(pz("Current command",e.map((t)=>t.displayValue),Mj)),cz=(e,t)=>`${yt(e.toUpperCase(),Mi,xf)} ${yt("\xB7",vm)} ${yt(t,Mi,iu)}`,lz=(e,t,n)=>[`${yt(e,Mi,xf)} ${yt(`v${t}`,iu)} ${yt("\xB7 Command wizard",Mi,iu)}`,...n===void 0||n.length===0?[]:[n],yt("Build a command interactively. Press Ctrl+C to cancel.",vm),""].join(`
|
|
125
|
+
`),fz=(e)=>pz("Command ready",e,xf,Zy),dz=()=>`
|
|
126
|
+
${yt("Wizard cancelled.",Qy)}`,pz=(e,t,n,r=iu)=>{let o=gce(t);return[yt(e,Mi,r),...o.map((s)=>yt(s,n)),""].join(`
|
|
127
|
+
`)},gce=(e)=>{let o=e.map(xce),s=[],i=" $ ";for(let a of o){let c=i===" $ "||i===" "?"":" ";if(i.length+c.length+a.length>88&&i!==" $ ")s.push(`${i} \\`),i=` ${a}`;else i+=`${c}${a}`}if(i!==" $ ")s.push(i);return s},xce=(e)=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'",`'"'"'`)}'`;var mz=v(()=>{vS();Re();Me();Kp();Fs();gf();Yy();bf();EA=q(function*(e,t){let n=t?.commandPath??[e.name],r=lce(e,n),o=(t?.prefix??n).map((s)=>Ms(s));return yield*BS(o),yield*uz(r,o,r===e?"ROOT":r.name),{args:o.map((s)=>s.value),displayArgs:o.map((s)=>s.displayValue)}}),uz=q(function*(e,t,n){let r=Be(e),o=e.subcommands.flatMap((a)=>a.commands.filter((c)=>!c.unlisted)),s=o.length===0?r.config:r.contextConfig;if(s.flags.length>0){yield*Fn(cz(n,"FLAGS"));for(let a of s.flags)t.push(...yield*az(a));if(s.arguments.length>0||o.length>0)yield*BS(t)}if(s.arguments.length>0){yield*Fn(cz(n,"ARGUMENTS"));for(let a of s.arguments)t.push(...yield*az(a));if(o.length>0)yield*BS(t)}if(o.length===0)return;let i=yield*Jn(D0({message:"Command",choices:o.map((a)=>({title:a.name,value:a,...a.shortDescription!==void 0?{description:a.shortDescription}:a.description!==void 0?{description:a.description}:{}}))}));if(yield*Fn(),t.push(Ms(i.name)),fce(i))yield*BS(t);yield*uz(i,t,i.name)}),az=q(function*(e){let t=xu(e),n=Pr(e);if(n.isOptional){if(!(yield*Jn(F0({message:`Set ${SA(t)}?`,initial:!1}))))return yield*Fn(),[]}let r=!n.isVariadic?1:yield*Jn(M0({message:`${SA(t)} count`,default:It(n.variadicMin,()=>0),min:It(n.variadicMin,()=>0),...Ce(n.variadicMax)?{max:n.variadicMax.value}:{}})),o=[];for(let i=0;i<r;i++)o.push(yield*dce(t));let s=t.kind===Bt?{flags:{[t.name]:o.map((i)=>i.value)},arguments:[]}:{flags:{},arguments:o.map((i)=>i.value)};if(yield*e.parse(s),yield*Fn(),t.kind===En)return o;return o.flatMap((i)=>[Ms(`--${t.name}`),i])})});var Xr={};Qn(Xr,{annotate:()=>_ce,annotateMerge:()=>Oce,isCommand:()=>bA,make:()=>Sce,provide:()=>Rce,provideEffect:()=>Mce,provideEffectDiscard:()=>Dce,provideSync:()=>Fce,run:()=>Bce,runWith:()=>wA,unlisted:()=>Tce,withAlias:()=>Ace,withDescription:()=>vce,withExamples:()=>Pce,withGlobalFlags:()=>Cce,withHandler:()=>Ece,withSharedFlags:()=>kce,withShortDescription:()=>Ice,withSubcommands:()=>wce,wizard:()=>Nce});var bA=(e)=>D(e,Fm),Sce=(e,t,n)=>{let r=RS(t??{});return Rr({name:e,config:r,...Ve(n)?{handle:n}:{}})},Ece,bce=(e)=>{let t=[],n=new Map,r=(i,a)=>{t.push(a);let c=n.get(i);if(c)c.push(a);else n.set(i,[a])};for(let i of e){if(bA(i)){r(void 0,i);continue}for(let a of i.commands)r(i.group,a)}let o=[],s=n.get(void 0);if(s&&s.length>0)o.push({group:void 0,commands:s});for(let[i,a]of n){if(i===void 0)continue;o.push({group:i,commands:a})}return{flat:t,groups:o}},wce,kce,Cce,vce,Ice,Ace,Tce=(e)=>Rr({...Be(e),unlisted:!0}),_ce,Oce,Pce,HS=(e,t)=>{let n=Be(e);return Rr({...n,handle:(r,o)=>t(n.handle(r,o),r)})},Rce,Fce,Mce,Dce,Nce=(e,t)=>ae(EA(e,t),(n)=>n.args),$ce=(e,t,n,r)=>{let o=new Set(t),s=[],i=new Set;for(let a of e){if(o.has(a))continue;let c=St(a.flag);for(let u of c){let l=n[u.name];if(!l||l.length===0)continue;let f=`--${u.name}`;if(i.has(f))continue;i.add(f),s.push(new ru({option:f,suggestions:[],command:r}))}}return s},Uce=(e,t,n)=>un(function*(){let{builtIns:r}=yield*$S,o=yield*Ef,s=yield*DS(e,t.commandPath,r);if(yield*Fn(o.formatHelpDoc(s)),n&&t.errors.length>0)yield*V0(o.formatErrors(t.errors))}),Lce=(e)=>un(function*(){let t=yield*Ef;yield*V0(t.formatError(e)),e[_c]=!1}),Bce,wA=(e,t)=>{let n=Be(e);return q(function*(r){let{builtIns:o}=yield*$S,{tokens:s,trailingOperands:i}=Yq(r),a=Vq(e,o),c=a.flatMap((I)=>St(I.flag)),u=Cf(c.filter(du)),{flagMap:l,remainder:f,errors:d}=sz(s,e,u),m={flags:l,arguments:[]},y=yield*xA({tokens:f,trailingOperands:i},e),b=[e.name,...gA(y)],E={builtIns:o,command:e,commandPath:b,version:t.version},w=lA(e,b,o),k=$ce(a,w,l,b);if(k.length>0||d.length>0){let I=y.errors??[];return yield*new Ha({commandPath:b,errors:[...d,...k,...I]})}for(let I of w){if(I._tag!=="Action")continue;if(!St(I.flag).some((N)=>{let Z=l[N.name];return Z!==void 0&&Z.length>0}))continue;let[,U]=yield*I.flag.parse(m);if(I===dA)return yield*un(function*(){yield*Fn(lz(e.name,t.version,e.description));let N=[e.name,...r.filter((ye)=>ye!=="--wizard"&&!ye.startsWith("--wizard="))],Z=yield*EA(e,{commandPath:b,prefix:N});if(yield*Fn(fz(Z.displayArgs)),yield*Jn(Yj({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))yield*Fn(),yield*wA(e,{...t,renderErrors:!1})(Z.args.slice(1))}).pipe(si("QuitError",()=>Fn(dz())));yield*I.run(U,E);return}if(y.errors&&y.errors.length>0)return yield*new Ha({commandPath:b,errors:y.errors});let g=yield*Eg(n.parse(y));if(g._tag==="Failure")return yield*new Ha({commandPath:b,errors:[g.failure]});let x=n.handle(g.success,[e.name]),S=w.includes(wf)?(yield*wf.flag.parse(m))[1]:P();x=fs(x,wf,S);for(let I of w){if(I._tag!=="Setting"||I===wf)continue;let[,_]=yield*I.flag.parse(m);x=fs(x,I,_)}let C=ut(S,{onNone:()=>Ln(),onSome:(I)=>Ks(yR,I)});yield*ii(x,C)},qd((r)=>C0(r)&&r._tag==="ShowHelp"?J(r):oe(r),(r)=>Vr(Uce(e,r,t.renderErrors!==!1),R(r))),qd((r)=>t.renderErrors!==!1&&C0(r)&&r._tag==="UserError"?J(r):oe(r),(r)=>Vr(Lce(r),R(r))),qd((r)=>BB(r)?J(r):oe(r),(r)=>gl))};var hz=v(()=>{vS();rt();Re();ne();Me();ge();vw();Bn();Pg();hv();Sy();Qq();Em();J0();pA();bf();iA();fA();iz();mz();Fs();Yy();Ece=p(2,(e,t)=>Rr({...Be(e),handle:t})),wce=p(2,(e,t)=>{let n=bce(t);aA(e,n.flat);let r=Be(e),o=new Map(n.flat.map((c)=>[c.name,Be(c)])),s=Symbol("effect/cli/SubcommandState"),i=q(function*(c){if(he(c.subcommand))return yield*r.parse(c);let u=o.get(c.subcommand.value.name);if(!u)return yield*r.parse(c);let l=yield*r.parseContext(c),f=yield*u.parse(c.subcommand.value.parsedInput);return{...l,[s]:{name:u.name,result:f}}}),a=q(function*(c,u){let f=c[s];if(f){let d=o.get(f.name);if(!d)return yield*new Ha({commandPath:u,errors:[]});return yield*d.handle(f.result,[...u,d.name]).pipe(fs(r.service,c))}return yield*r.handle(c,u)});return Rr({name:r.name,config:r.config,contextConfig:r.contextConfig,description:r.description,shortDescription:r.shortDescription,alias:r.alias,unlisted:r.unlisted,annotations:r.annotations,globalFlags:r.globalFlags,examples:r.examples,service:r.service,subcommands:n.groups,parse:i,parseContext:r.parseContext,handle:a})}),kce=p(2,(e,t)=>{let n=Be(e),r=RS(t),o=oA(n.config,r),s=oA(n.contextConfig,r);if(n.subcommands.length>0){let l=n.subcommands.flatMap((f)=>f.commands);aA(e,l,{contextConfig:s})}let i=FS(r,{allowLeftovers:!0}),a=q(function*(l){let f=yield*n.parse(l),d=yield*i(l);return{...f,...d}}),c=q(function*(l){let f=yield*n.parseContext(l),d=yield*i(l);return{...f,...d}}),u=(l,f)=>n.handle(l,f);return Rr({name:n.name,config:o,contextConfig:s,description:n.description,shortDescription:n.shortDescription,alias:n.alias,unlisted:n.unlisted,annotations:n.annotations,globalFlags:n.globalFlags,examples:n.examples,service:n.service,subcommands:n.subcommands,parse:a,parseContext:c,handle:u})}),Cce=p(2,(e,t)=>{let n=Be(e),r=Array.from(new Set([...n.globalFlags,...t]));return Rr({...n,globalFlags:r})}),vce=p(2,(e,t)=>Rr({...Be(e),description:t})),Ice=p(2,(e,t)=>Rr({...Be(e),shortDescription:t})),Ace=p(2,(e,t)=>Rr({...Be(e),alias:t})),_ce=p(3,(e,t,n)=>{let r=Be(e);return Rr({...r,annotations:Cn(r.annotations,t,n)})}),Oce=p(2,(e,t)=>{let n=Be(e);return Rr({...n,annotations:ic(n.annotations,t)})}),Pce=p(2,(e,t)=>Rr({...Be(e),examples:t})),Rce=p((e)=>bA(e[0]),(e,t,n)=>HS(e,(r,o)=>mk(r,typeof t==="function"?t(o):t,n))),Fce=p(3,(e,t,n)=>HS(e,(r,o)=>fs(r,t,typeof n==="function"?n(o):n))),Mce=p(3,(e,t,n)=>HS(e,(r,o)=>hk(r,t,typeof n==="function"?n(o):n))),Dce=p(2,(e,t)=>HS(e,(n,r)=>Vr(typeof t==="function"?t(r):t,n))),Bce=p(2,(e,t)=>Dx.use(({args:n})=>se(n,(r)=>wA(e,t)(r))))});var gz=v(()=>{Cq();hz();rA()});var xz=(e)=>{let t=e?.trim();return t===void 0||t.length===0?void 0:t},yz=()=>({bunExecutable:xz(process.env.TRIPWIRE_BUN),forcePortable:process.env.TRIPWIRE_FORCE_PORTABLE==="1",packageDist:xz(process.env.TRIPWIRE_PACKAGE_DIST)}),Sz=()=>({...process.env});var kA=()=>{};import{lstat as vz,mkdir as Hce,open as Wce,readFile as Dm,readlink as jce,realpath as qce,rename as Iz,rm as WS,stat as zce,symlink as Ez}from"fs/promises";import{homedir as $m}from"os";import Su from"path";import{fileURLToPath as bz}from"url";var wz,Az,Ds=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),vf=(e,t)=>e instanceof Error&&("code"in e)&&e.code===t,Nm=async(e,t,n={})=>{let r=e,o=!1;try{o=(await vz(e)).isSymbolicLink()}catch(c){if(!vf(c,"ENOENT"))throw c}if(o)r=await qce(e);let s=`${r}.${process.pid}.next`,i,a=384;try{a=(await zce(r)).mode&4095}catch(c){if(!vf(c,"ENOENT"))throw c}await WS(s,{force:!0});try{i=await Wce(s,"wx",a),await i.writeFile(t,"utf8"),await i.chmod(a),await i.sync(),await i.close(),i=void 0,await n.beforeRename?.(s,r),await Iz(s,r)}finally{try{if(i!==void 0)await i.close()}finally{await WS(s,{force:!0})}}},Vce=(e)=>Ds(e)&&typeof e.type==="string"&&typeof e.command==="string"&&(e.timeout===void 0||typeof e.timeout==="number"),kz=(e)=>Array.isArray(e)&&e.every((t)=>Ds(t)&&Array.isArray(t.hooks)&&t.hooks.every(Vce)),Kce=(e)=>{if(!Ds(e))return!1;let{hooks:t}=e;if(t===void 0)return!0;return Ds(t)&&(t.PreToolUse===void 0||kz(t.PreToolUse))&&(t.PostToolUse===void 0||kz(t.PostToolUse))},CA=(e,t)=>{let n=JSON.parse(e);if(!Kce(n))throw Error(`${t} hook config has an unsupported shape`);return n},Gce=(e)=>{let t=JSON.parse(e);if(!Ds(t))throw Error("Cursor hooks.json must contain a JSON object");let{hooks:n}=t;if(n===void 0)return t;if(!Ds(n))throw Error("Cursor hooks.json `hooks` must be an object");for(let[r,o]of Object.entries(n))if(!Array.isArray(o)||o.some((s)=>!Ds(s)||typeof s.command!=="string"))throw Error(`Cursor hooks.json event ${r} must contain command hooks`);return t},Eu="tripwire-hook",Tz=async(e,t)=>{await Hce(Su.dirname(t),{recursive:!0});try{if(!(await vz(t)).isSymbolicLink())return{action:"already",success:!1};let r=await jce(t);if(r===e)return{action:"already",success:!0};let o=Su.resolve(Su.dirname(t),r);if(Su.basename(o)!=="tripwire-pi.js")return{action:"already",success:!1};let s=`${t}.${process.pid}.next`;await WS(s,{force:!0});try{await Ez(e,s),await Iz(s,t)}finally{await WS(s,{force:!0})}return{action:"updated",success:!0}}catch(n){if(!(n instanceof Error&&("code"in n)&&n.code==="ENOENT"))throw n;return await Ez(e,t),{action:"installed",success:!0}}},Jce,Qce,jS=(e)=>e===Eu||e.startsWith(`${Eu} `)||e.includes("/tripwire-darwin-arm64/")||e.includes("/tripwire-hook")||e.includes("/tripwire.js")||e.includes("/dist/tripwire"),Zce=(e,t,n=Eu)=>{let r=Qce.has(t),o={command:`${n} --cursor-event ${t}`,...r&&{failClosed:!0}};if(e===void 0)return[[o],!0];let s=!1,i=e.some((u)=>jS(u.command)),a=`${n} --cursor-event ${t}`,c=e.map((u)=>{if(!jS(u.command))return u;if(u.command===a&&(!r||u.failClosed===!0))return u;return s=!0,{...u,command:a,...r&&{failClosed:!0}}});if(i)return[c,s];return[[...c,o],!0]},qS=(e,t=Eu)=>{if(!e)return[[{hooks:[{type:"command",command:t}]}],!1];let n=!1,r=e.map((i)=>({...i,hooks:i.hooks.map((a)=>{if(jS(a.command)){if(a.command!==t)return n=!0,{...a,command:t};return a}return a})}));if(r.some((i)=>i.hooks.some((a)=>a.command===t)))return[r,!n];return[[...r,{hooks:[{type:"command",command:t}]}],!1]},vA=async(e={})=>{let t=e.homeDirectory??$m(),n=e.hookCommand??Eu,r=`${t}/.claude/settings.json`;try{let o=await Dm(r,"utf8"),s=CA(o,"Claude");s.hooks??={};let[i,a]=qS(s.hooks.PreToolUse,n),[c,u]=qS(s.hooks.PostToolUse,n);if(s.hooks.PreToolUse=i,s.hooks.PostToolUse=c,a&&u)return{success:!0,message:`Already configured: ${r}`};return await Nm(r,`${JSON.stringify(s,null,2)}
|
|
128
|
+
`),{success:!0,message:`Updated ${r}`}}catch(o){if(vf(o,"ENOENT"))return{success:!1,message:`Config file not found: ${r}`};return{success:!1,message:`Failed to update Claude config: ${o instanceof Error?o.message:String(o)}`}}},IA=async(e={})=>{let t=e.homeDirectory??$m(),n=`${t}/.pi/agent/settings.json`,r=`${t}/.pi/agent/extensions/tripwire.js`;try{let o=e.extensionSource??Az.find((f)=>Bun.file(f).size>0);if(o===void 0)return{success:!1,message:"Built Pi extension not found; run `bun run build` first"};let s=await Dm(n,"utf8"),i=CA(s,"Pi");if(i.hooks!==void 0){let{PreToolUse:f,PostToolUse:d,...m}=i.hooks,y=(k)=>k?.map((g)=>({...g,hooks:g.hooks.filter((x)=>!jS(x.command))})).filter((g)=>g.hooks.length>0)??[],b=y(f),E=y(d),w={...m,...b.length>0&&{PreToolUse:b},...E.length>0&&{PostToolUse:E}};if(Object.keys(w).length===0){let{hooks:k,...g}=i;i=g}else i.hooks=w}let a=`${JSON.stringify(i,null,2)}
|
|
129
|
+
`,c=a!==s,u=await Tz(o,r);if(!u.success)return{success:!1,message:`Refusing to replace existing Pi extension: ${r}`};if(c)await Nm(n,a);if(u.action==="already"&&!c)return{success:!0,message:`Already configured: ${r}`};return{success:!0,message:`${u.action==="updated"?"Updated":"Installed"} ${r}`}}catch(o){if(vf(o,"ENOENT"))return{success:!1,message:`Config file not found: ${n}`};return{success:!1,message:`Failed to update pi config: ${o instanceof Error?o.message:String(o)}`}}},AA=async(e={})=>{let n=`${e.homeDirectory??$m()}/.omp/agent/extensions/tripwire.js`;try{let r=e.extensionSource??Az.find((i)=>Bun.file(i).size>0);if(r===void 0)return{success:!1,message:"Built Pi extension not found; run `bun run build` first"};let o=await Tz(r,n);if(!o.success)return{success:!1,message:`Refusing to replace existing oh-my-pi extension: ${n}`};if(o.action==="already")return{success:!0,message:`Already configured: ${n}`};return{success:!0,message:`${o.action==="updated"?"Updated":"Installed"} ${n}`}}catch(r){return{success:!1,message:`Failed to install oh-my-pi extension: ${r instanceof Error?r.message:String(r)}`}}},Cz=(e)=>{let t=Bun.TOML.parse(e),n=Ds(t)?t.features:void 0;if(n!==void 0&&!Ds(n))throw Error("Codex config.toml `features` must be a table");return n},Yce=(e)=>{if(Cz(e)?.hooks===!0)return e;let t=e.includes(`\r
|
|
133
130
|
`)?`\r
|
|
134
131
|
`:`
|
|
135
|
-
`,n=/^[\t ]*\[features\][\t ]*(?:#.*)?(?:\r?\n|$)/
|
|
132
|
+
`,n=/^[\t ]*\[features\][\t ]*(?:#.*)?(?:\r?\n|$)/mu.exec(e),r;if(n===null){let o=e.length===0||e.endsWith(`
|
|
136
133
|
`)?"":t,s=e.length===0||e.endsWith(`
|
|
137
|
-
`)?t:"";r=`${e}${o}[features]${t}hooks = true${s}`}else{let o=n.index+n[0].length,s=/^[\t ]*\[/
|
|
138
|
-
`)?`hooks = true${t}`:`${t}hooks = true`;r=`${e.slice(0,o)}${f}${e.slice(o)}`}else{let l=u.groups?.prefix,f=u.groups?.value;if(l===void 0||f===void 0)throw Error("Could not locate Codex hooks value in config.toml");let d=o+u.index+l.length,m=d+f.length;r=`${e.slice(0,d)}true${e.slice(m)}`}}if(
|
|
139
|
-
`,d=
|
|
140
|
-
`),{success:!0,message:`Updated ${r}`}}catch(o){if(
|
|
141
|
-
`);
|
|
134
|
+
`)?t:"";r=`${e}${o}[features]${t}hooks = true${s}`}else{let o=n.index+n[0].length,s=/^[\t ]*\[/gmu;s.lastIndex=o;let a=s.exec(e)?.index??e.length,c=e.slice(o,a),u=/^(?<prefix>[\t ]*hooks[\t ]*=[\t ]*)(?<value>[^#\r\n]*?)(?<suffix>[\t ]*(?:#.*)?)$/mu.exec(c);if(u===null){let f=n[0].endsWith(`
|
|
135
|
+
`)?`hooks = true${t}`:`${t}hooks = true`;r=`${e.slice(0,o)}${f}${e.slice(o)}`}else{let l=u.groups?.prefix,f=u.groups?.value;if(l===void 0||f===void 0)throw Error("Could not locate Codex hooks value in config.toml");let d=o+u.index+l.length,m=d+f.length;r=`${e.slice(0,d)}true${e.slice(m)}`}}if(Cz(r)?.hooks!==!0)throw Error("Could not enable Codex hooks in config.toml");return r},TA=async(e={})=>{let t=e.homeDirectory??$m(),n=e.hookCommand??Eu,r=`${t}/.codex/config.toml`,o=`${t}/.codex/hooks.json`;try{let[s,i]=await Promise.all([Dm(o,"utf8"),Dm(r,"utf8")]),a=CA(s,"Codex");a.hooks??={};let[c]=qS(a.hooks.PreToolUse,n),[u]=qS(a.hooks.PostToolUse,n),l=(b)=>b.map((E)=>({...E,hooks:E.hooks.map((w)=>w.command===n&&w.timeout===void 0?{...w,timeout:10}:w)}));a.hooks.PreToolUse=l(c),a.hooks.PostToolUse=l(u);let f=`${JSON.stringify(a,null,2)}
|
|
136
|
+
`,d=Yce(i),m=f!==s,y=d!==i;if(m)await Nm(o,f);if(y)await Nm(r,d);if(!m&&!y)return{success:!0,message:`Already configured: ${r} and ${o}`};return{success:!0,message:`Updated ${r} and ${o}`}}catch(s){if(vf(s,"ENOENT"))return{success:!1,message:`Config file not found: ${Ds(s)&&typeof s.path==="string"?s.path:`${r} or ${o}`}`};return{success:!1,message:`Failed to update Codex config: ${s instanceof Error?s.message:String(s)}`}}},_A=async(e={})=>{let t=e.homeDirectory??$m(),n=e.hookCommand??Eu,r=`${t}/.cursor/hooks.json`;try{let o=await Dm(r,"utf8"),s=Gce(o);s.version??=1,s.hooks??={};let i=!1;for(let a of Jce){let[c,u]=Zce(s.hooks[a],a,n);s.hooks[a]=c,i||=u}if(!i)return{success:!0,message:`Already configured: ${r}`};return await Nm(r,`${JSON.stringify(s,null,2)}
|
|
137
|
+
`),{success:!0,message:`Updated ${r}`}}catch(o){if(vf(o,"ENOENT"))return{success:!1,message:`Config file not found: ${r}`};return{success:!1,message:`Failed to update Cursor hooks.json: ${o instanceof Error?o.message:String(o)}`}}},_z=async(e={})=>[{target:"claude",...await vA(e)},{target:"codex",...await TA(e)},{target:"cursor",...await _A(e)},{target:"pi",...await IA(e)},{target:"oh-my-pi",...await AA(e)}];var Oz=v(()=>{kA();({packageDist:wz}=yz()),Az=[...wz===void 0?[]:[Su.join(wz,"tripwire-pi.js")],Su.join(Su.dirname(process.execPath),"tripwire-pi.js"),bz(new URL("../../dist/tripwire-pi.js",import.meta.url)),bz(new URL("tripwire-pi.js",import.meta.url))],Jce=["preToolUse","postToolUse","beforeShellExecution","afterShellExecution","beforeReadFile","afterFileEdit"],Qce=new Set(["preToolUse","beforeShellExecution","beforeReadFile"])});import{readFile as Xce}from"fs/promises";var If,eue=(e)=>B.try({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(e),catch:()=>new If({message:"The checked script is not valid UTF-8, so Tripwire cannot parse it."})}),tue=(e)=>B.tryPromise({try:()=>Xce(e),catch:(t)=>new If({message:`Tripwire could not read the checked script: ${String(t)}`})}),nue=()=>Ny().pipe(B.flatMap((e)=>e.ok?B.succeed(e.config):B.fail(new If({message:`Tripwire configuration failed to load: ${e.error}`})))),rue=(e,t)=>B.tryPromise({try:async()=>{let n=Bun.spawn(["/bin/bash","-s","--",...t],{cwd:process.cwd(),env:Sz(),stderr:"inherit",stdin:"pipe",stdout:"inherit"});return await n.stdin.write(e),await n.stdin.end(),n.exited},catch:(n)=>new If({message:`Tripwire could not start the checked script: ${String(n)}`})}),Pz=(e,t)=>B.gen(function*(){let r=yield*tue(e),o=yield*eue(r),s=yield*nue(),i=S0(o,s,{cwd:process.cwd(),positionalArguments:t});if(i.kind==="deny"||i.kind==="ask")yield*new If({message:`[tripwire:${i.rule}] ${i.message}`});if(i.kind==="warn")process.stderr.write(`[tripwire:${i.rule}] ${i.message}
|
|
138
|
+
`);process.exitCode=yield*rue(r,t)});var Rz=v(()=>{vs();E0();XI();kA();If=class If extends xr.TaggedError("CheckedScriptError"){}});var Dz={};Qn(Dz,{runCliProgram:()=>yue});import Fz from"path";var Mz=()=>{if(/(?:^|[/\\])bun(?:\.exe)?$/iu.test(process.execPath)){let t=import.meta.filename;if(Fz.basename(t)==="tripwire.js")return[process.execPath,t,"--tripwire-hook"];let n=Fz.join(import.meta.dirname,"..","main.ts");return[process.execPath,n,"--tripwire-hook"]}return[process.execPath,"--tripwire-hook"]},oue=(e)=>/^[A-Za-z0-9_/:=.,+@%-]+$/u.test(e)?e:`'${e.replaceAll("'",String.raw`'\''`)}'`,sue=()=>Mz().map((e)=>oue(e)).join(" "),iue=(e,t,n,r)=>{if(e==="Bash")return{command:t??""};if(e==="Read")return{file_path:n??""};if(e==="Write")return{file_path:n??"",content:r??""};if(e==="Edit"||e==="MultiEdit")return{file_path:n??"",old_string:"",new_string:r??""};return null},aue=(e)=>{let{tool:t,post:n,command:r,path:o,stdout:s,stderr:i,content:a}=e,c=n?"PostToolUse":"PreToolUse",u=iue(t,r,o,a),l={hook_event_name:c,tool_name:t,cwd:process.cwd(),session_id:"tripwire-cli-test",...u!==null&&{tool_input:u}};if(n)l.tool_response=t==="Bash"?{stdout:s??"",stderr:i??""}:{content:a??""};return l},cue=(e)=>{try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}},uue=(e)=>B.sync(()=>{let{command:t,content:n,path:r,post:o,stderr:s,stdout:i,tool:a}=e,c=aue({tool:a,post:o,command:t,path:r,stdout:i,stderr:s,content:n}),u=Bun.spawnSync(Mz(),{stdin:new TextEncoder().encode(JSON.stringify(c)),timeout:1e4,stdout:"pipe",stderr:"pipe"});if(u.exitCode!==0){let f=new TextDecoder().decode(u.stderr);process.stderr.write(`error: ${f}
|
|
139
|
+
`),process.exit(1)}let l=new TextDecoder().decode(u.stdout);process.stdout.write(`${cue(l)}
|
|
140
|
+
`)}),lue,fue=(e)=>B.gen(function*(){if(!["claude","codex","cursor","pi","oh-my-pi","omp","all"].includes(e))process.stderr.write(`error: unknown target "${e}"
|
|
141
|
+
`),process.stderr.write(`Valid targets: claude, codex, cursor, pi, oh-my-pi, all
|
|
142
|
+
`),process.exit(1);let n,r={hookCommand:sue()};switch(e){case"claude":{n=[{target:"claude",result:yield*B.promise(()=>vA(r))}];break}case"codex":{n=[{target:"codex",result:yield*B.promise(()=>TA(r))}];break}case"pi":{n=[{target:"pi",result:yield*B.promise(()=>IA(r))}];break}case"oh-my-pi":case"omp":{n=[{target:"oh-my-pi",result:yield*B.promise(()=>AA(r))}];break}case"cursor":{n=[{target:"cursor",result:yield*B.promise(()=>_A(r))}];break}case"all":{n=(yield*B.promise(()=>_z(r))).map((i)=>({target:i.target,result:i}));break}default:{n=[];break}}let o=!1;for(let{target:s,result:i}of n)if(i.success){let a=i.message.startsWith("Already configured")?"\u2299":"\u2713";process.stdout.write(`${a} [${s}] ${i.message}
|
|
143
|
+
`)}else process.stderr.write(`\u2717 [${s}] ${i.message}
|
|
144
|
+
`),o=!0;if(o)process.exit(1)}),due,pue,mue,hue,gue,xue,yue=async()=>{try{await B.runPromise(xue.pipe(B.provide(by.layer)))}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`${t}
|
|
145
|
+
`),process.exitCode=1}};var Nz=v(async()=>{II();vs();gz();GS();Oz();Rz();lue=Xr.make("test",{command:Yr.string("command").pipe(Yr.optional,Yr.withDescription("Command to test (for Bash tool)")),content:Ht.string("content").pipe(Ht.optional,Ht.withDescription("Content for Write/Edit tools")),path:Ht.string("path").pipe(Ht.optional,Ht.withDescription("File path for Read/Write/Edit tools")),post:Ht.boolean("post").pipe(Ht.withDefault(!1),Ht.withDescription("Test PostToolUse instead of PreToolUse")),stderr:Ht.string("stderr").pipe(Ht.optional,Ht.withDescription("Stderr for PostToolUse Bash")),stdout:Ht.string("stdout").pipe(Ht.optional,Ht.withDescription("Stdout for PostToolUse Bash")),tool:Ht.string("tool").pipe(Ht.withDefault("Bash"),Ht.withDescription("Tool name (Bash, Read, Write, Edit, MultiEdit)"))},({command:e,content:t,path:n,post:r,stderr:o,stdout:s,tool:i})=>uue({command:ve.getOrUndefined(e),content:ve.getOrUndefined(t),path:ve.getOrUndefined(n),post:r,stderr:ve.getOrUndefined(o),stdout:ve.getOrUndefined(s),tool:i})).pipe(Xr.withDescription("Test a synthetic hook event")),due=Xr.make("install",{target:Yr.string("target").pipe(Yr.withDescription("Target agent (claude, codex, cursor, pi, oh-my-pi, or all)"))},({target:e})=>fue(e)).pipe(Xr.withDescription("Install tripwire hooks for AI agents")),pue=Yr.string("script").pipe(Yr.withDescription("Bash script file to inspect and execute from the checked bytes")),mue=Yr.string("argument").pipe(Yr.variadic(),Yr.withDescription("Arguments passed to the script after --")),hue=Xr.make("run-script",{script:pue,trailingArguments:mue},({script:e,trailingArguments:t})=>Pz(e,t)).pipe(Xr.withDescription("Inspect one script snapshot, then execute those exact bytes with Bash")),gue=Xr.make("tripwire").pipe(Xr.withDescription("Opinionated hooks dispatcher for AI coding agents"),Xr.withSubcommands([lue,due,hue])),xue=Xr.run(gue,{version:Bm.version})});var $z={};Qn($z,{runCli:()=>Sue});var Sue=async()=>{let{runCliProgram:e}=await Nz().then(() => Dz);await e()};var Uz=async()=>{};GS();import Eue from"path";var bue="--tripwire-hook",wue="--tripwire-force-cli",Lz=process.argv.indexOf(wue,2),Bz=Lz!==-1;if(Bz)process.argv.splice(Lz,1);var zS=process.argv.slice(2),kue=Eue.basename(process.argv0),Cue=!Bz&&(kue==="tripwire-hook"||zS.includes(bue)||zS.some((e)=>e.startsWith("--cursor-event")));if(Cue){let{runHook:e}=await Promise.resolve().then(() => (E0(),VW));e()}else if(zS.length===1&&zS[0]==="--version")process.stdout.write(`${Bm.version}
|
|
146
|
+
`);else{let{runCli:e}=await Uz().then(() => $z);await e()}
|