@usine/server 0.2.1 → 0.4.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/LICENSE +661 -21
- package/README.md +54 -20
- package/dist/backend.d.ts +26 -5
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +41 -16
- package/dist/backend.js.map +1 -1
- package/dist/backup.d.ts +6 -3
- package/dist/backup.d.ts.map +1 -1
- package/dist/backup.js +26 -8
- package/dist/backup.js.map +1 -1
- package/dist/cli.d.ts +77 -11
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +280 -31
- package/dist/cli.js.map +1 -1
- package/dist/command.d.ts +22 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +51 -0
- package/dist/command.js.map +1 -0
- package/dist/detach.d.ts +83 -0
- package/dist/detach.d.ts.map +1 -0
- package/dist/detach.js +320 -0
- package/dist/detach.js.map +1 -0
- package/dist/export-run.d.ts +1 -1
- package/dist/export-run.d.ts.map +1 -1
- package/dist/export-run.js +3 -3
- package/dist/export-run.js.map +1 -1
- package/dist/failure-message.d.ts +19 -0
- package/dist/failure-message.d.ts.map +1 -0
- package/dist/failure-message.js +127 -0
- package/dist/failure-message.js.map +1 -0
- package/dist/http.d.ts +14 -5
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +86 -33
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/instance/environment.d.ts +17 -0
- package/dist/instance/environment.d.ts.map +1 -0
- package/dist/instance/environment.js +51 -0
- package/dist/instance/environment.js.map +1 -0
- package/dist/instance/id.d.ts +17 -0
- package/dist/instance/id.d.ts.map +1 -0
- package/dist/instance/id.js +35 -0
- package/dist/instance/id.js.map +1 -0
- package/dist/instance/lock.d.ts +27 -0
- package/dist/instance/lock.d.ts.map +1 -0
- package/dist/instance/lock.js +127 -0
- package/dist/instance/lock.js.map +1 -0
- package/dist/instance/manifest.d.ts +52 -0
- package/dist/instance/manifest.d.ts.map +1 -0
- package/dist/instance/manifest.js +131 -0
- package/dist/instance/manifest.js.map +1 -0
- package/dist/instance/operator-api.d.ts +30 -0
- package/dist/instance/operator-api.d.ts.map +1 -0
- package/dist/instance/operator-api.js +47 -0
- package/dist/instance/operator-api.js.map +1 -0
- package/dist/instance/ports.d.ts +23 -0
- package/dist/instance/ports.d.ts.map +1 -0
- package/dist/instance/ports.js +81 -0
- package/dist/instance/ports.js.map +1 -0
- package/dist/instance/record.d.ts +82 -0
- package/dist/instance/record.d.ts.map +1 -0
- package/dist/instance/record.js +116 -0
- package/dist/instance/record.js.map +1 -0
- package/dist/instance/state.d.ts +45 -0
- package/dist/instance/state.d.ts.map +1 -0
- package/dist/instance/state.js +79 -0
- package/dist/instance/state.js.map +1 -0
- package/dist/instance/systemd.d.ts +36 -0
- package/dist/instance/systemd.d.ts.map +1 -0
- package/dist/instance/systemd.js +61 -0
- package/dist/instance/systemd.js.map +1 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +27 -0
- package/dist/logger.js.map +1 -0
- package/dist/main.js +38 -18
- package/dist/main.js.map +1 -1
- package/dist/registry.d.ts +20 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +37 -0
- package/dist/registry.js.map +1 -0
- package/dist/reload-signal.d.ts +8 -0
- package/dist/reload-signal.d.ts.map +1 -0
- package/dist/reload-signal.js +21 -0
- package/dist/reload-signal.js.map +1 -0
- package/dist/restart.d.ts +19 -0
- package/dist/restart.d.ts.map +1 -0
- package/dist/restart.js +105 -0
- package/dist/restart.js.map +1 -0
- package/dist/shutdown.d.ts +5 -2
- package/dist/shutdown.d.ts.map +1 -1
- package/dist/shutdown.js +11 -5
- package/dist/shutdown.js.map +1 -1
- package/dist/status.d.ts +12 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +99 -0
- package/dist/status.js.map +1 -0
- package/dist/stop.d.ts +81 -0
- package/dist/stop.d.ts.map +1 -0
- package/dist/stop.js +195 -0
- package/dist/stop.js.map +1 -0
- package/dist/system-sleep.d.ts +9 -0
- package/dist/system-sleep.d.ts.map +1 -0
- package/dist/system-sleep.js +42 -0
- package/dist/system-sleep.js.map +1 -0
- package/dist/tracing.d.ts +22 -0
- package/dist/tracing.d.ts.map +1 -0
- package/dist/tracing.js +61 -0
- package/dist/tracing.js.map +1 -0
- package/dist/up.d.ts +2 -2
- package/dist/up.d.ts.map +1 -1
- package/dist/up.js +62 -24
- package/dist/up.js.map +1 -1
- package/dist/upgrade.d.ts +58 -0
- package/dist/upgrade.d.ts.map +1 -0
- package/dist/upgrade.js +237 -0
- package/dist/upgrade.js.map +1 -0
- package/dist/web/assets/CompositeItem-DU6IyNMY.js +1 -0
- package/dist/web/assets/ToolbarRootContext-Cytu6o2e.js +1 -0
- package/dist/web/assets/X.es-B7iqdxa_.js +1 -0
- package/dist/web/assets/_agent-BVKD5odk.js +1 -0
- package/dist/web/assets/_loop-BFLzamuo.js +1 -0
- package/dist/web/assets/_name-Bh4AQ9sR.js +6 -0
- package/dist/web/assets/_name-CMVsmWzq.js +1 -0
- package/dist/web/assets/_name-DCkgEma_.js +1 -0
- package/dist/web/assets/_name-Ds_pWi15.js +1 -0
- package/dist/web/assets/_number-B9aYwvcQ.js +1 -0
- package/dist/web/assets/_run-BZWt47QS.js +8 -0
- package/dist/web/assets/_worker-Dgfufm5p.js +1 -0
- package/dist/web/assets/action-rCd1FeAz.js +1 -0
- package/dist/web/assets/agents-Drbg6qpH.js +1 -0
- package/dist/web/assets/agents-_6-dEjrY.js +1 -0
- package/dist/web/assets/button-DVWXde__.js +1 -0
- package/dist/web/assets/collapsible-IOhZV1qg.js +1 -0
- package/dist/web/assets/core-wi-Hu_JV.js +12 -0
- package/dist/web/assets/drawer-BiqnR_8i.js +1 -0
- package/dist/web/assets/dropdown-menu-C9D1kRkO.js +1 -0
- package/dist/web/assets/edit-and-retry-BgOR6mvP.js +1 -0
- package/dist/web/assets/engine-javascript-D-6se_EF.js +141 -0
- package/dist/web/assets/error-alert-9tKpTE3v.js +1 -0
- package/dist/web/assets/file-error-SjG2jLJ9.js +1 -0
- package/dist/web/assets/fill-cell-ClM88KFD.js +1 -0
- package/dist/web/assets/heading-lX1a1LNN.js +1 -0
- package/dist/web/assets/index-BymNZU1Q.js +10 -0
- package/dist/web/assets/index-Dyjfp3ET.css +2 -0
- package/dist/web/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/web/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/web/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/web/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/web/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/web/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/web/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/web/assets/label-badge-aIGT1Bry.js +1 -0
- package/dist/web/assets/list-v8WJp2Eq.js +1 -0
- package/dist/web/assets/loops-BFoFf_og.js +1 -0
- package/dist/web/assets/mark-CC3RwMy_.js +1 -0
- package/dist/web/assets/markdown-BnyfnuCL.js +29 -0
- package/dist/web/assets/matchContext-BquevSJS.js +2 -0
- package/dist/web/assets/model-BerBT6R0.js +1 -0
- package/dist/web/assets/moves-Dg9sshX5.js +1 -0
- package/dist/web/assets/overview-C_tFKGZ8.js +1 -0
- package/dist/web/assets/page-DWnGi6wA.js +301 -0
- package/dist/web/assets/project-not-found-CodaBVdu.js +1 -0
- package/dist/web/assets/pull-request-marks-DE00nqGW.js +1 -0
- package/dist/web/assets/queries-B1SHA_r4.js +1 -0
- package/dist/web/assets/reload-Dsl0zjJ7.js +1 -0
- package/dist/web/assets/repositories-BdxmD192.js +1 -0
- package/dist/web/assets/repositories-D4wYJfa_.js +1 -0
- package/dist/web/assets/route-B_gphTYG.js +1 -0
- package/dist/web/assets/route-Cc7dKnn5.js +1 -0
- package/dist/web/assets/routes-BLy5TGH_.js +65 -0
- package/dist/web/assets/run-again-BTKagSXR.js +1 -0
- package/dist/web/assets/section-B3pWIIBa.js +1 -0
- package/dist/web/assets/section-CD-MB5r3.js +1 -0
- package/dist/web/assets/section-Id99HktI.js +1 -0
- package/dist/web/assets/settings-YrDysQXW.js +1 -0
- package/dist/web/assets/slots-BraHmbNr.js +1 -0
- package/dist/web/assets/status-badge-DnvNo1tG.js +1 -0
- package/dist/web/assets/strings-CW2XaR5f.js +1 -0
- package/dist/web/assets/table-BjyI4fVI.js +1 -0
- package/dist/web/assets/tasks-DCL8kLmD.js +1 -0
- package/dist/web/assets/transcript-sxRJzx6t.js +5 -0
- package/dist/web/assets/usage-CLQJdX9-.js +1 -0
- package/dist/web/assets/use-now-0P8TUXeg.js +1 -0
- package/dist/web/assets/useAnchoredPopupScrollLock-CQ83Wy-r.js +1 -0
- package/dist/web/assets/useNavigate-BW1WdocJ.js +1 -0
- package/dist/web/assets/usePositioner-rNCxnHO-.js +1 -0
- package/dist/web/assets/useTimeout-_TcdZXP6.js +1 -0
- package/dist/web/assets/with-selector-DoElmmtd.js +1 -0
- package/dist/web/assets/workers-BH5CBOR3.js +1 -0
- package/dist/web/index.html +16 -10
- package/package.json +17 -12
- package/dist/web/assets/_name-DdyMEUN6.js +0 -6
- package/dist/web/assets/_name-eoobiMh0.js +0 -1
- package/dist/web/assets/_name-pUxlKZt5.js +0 -1
- package/dist/web/assets/badge-t7m0Vk1K.js +0 -146
- package/dist/web/assets/button-BoOukj77.js +0 -1
- package/dist/web/assets/core-CLXRiB63.js +0 -12
- package/dist/web/assets/empty-DbVYU7bi.js +0 -1
- package/dist/web/assets/engine-javascript-h-x4hGa4.js +0 -141
- package/dist/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/web/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/dist/web/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/dist/web/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/dist/web/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/dist/web/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/dist/web/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/dist/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/web/assets/index-CVBBoW6r.css +0 -2
- package/dist/web/assets/index-CsW8KcJW.js +0 -10
- package/dist/web/assets/loops-DghpuoiG.js +0 -1
- package/dist/web/assets/operator-copy-DIsVXn17.js +0 -1
- package/dist/web/assets/overview-DmCIVPwN.js +0 -1
- package/dist/web/assets/rolldown-runtime-hePW80VL.js +0 -1
- package/dist/web/assets/routes-BDyP7vCr.js +0 -1
- package/dist/web/assets/run-drawer-B-xhTXe4.js +0 -157
- package/dist/web/assets/status-badge-yblcElE0.js +0 -1
- package/dist/web/assets/table-B8cLYNvq.js +0 -1
- package/dist/web/assets/useCompositeItem-HmBmWxUW.js +0 -1
- package/dist/web/assets/with-selector-N6m4X0X_.js +0 -1
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,H as n,O as r,V as i,k as a,z as o}from"./button-BoOukj77.js";var s=e(n(),1),c=i(),l=s.createContext(void 0),u=e=>{let t=s.useContext(l);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},d=({client:e,children:t})=>(s.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,c.jsx)(l.Provider,{value:e,children:t})),f={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},p=new class{#e=f;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function m(e){setTimeout(e,0)}var h=typeof window>`u`||`Deno`in globalThis;function g(){}function _(e,t){return typeof e==`function`?e(t):e}function v(e){return typeof e==`number`&&e>=0&&e!==1/0}function y(e,t){return Math.max(e+(t||0)-Date.now(),0)}function b(e,t){return typeof e==`function`?e(t):e}function x(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==te(o,t.options))return!1}else if(!re(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function ee(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ne(t.options.mutationKey)!==ne(a))return!1}else if(!re(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function te(e,t){return(t?.queryKeyHashFn||ne)(e)}function ne(e){return JSON.stringify(e,(e,t)=>ce(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function re(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!re(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!re(e[r],t[r]))return!1;return!0}return!1}var ie=Object.prototype.hasOwnProperty;function ae(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=se(e)&&se(t);if(!r&&!(ce(e)&&ce(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ie.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=ae(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function oe(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function se(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ce(e){if(!le(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!le(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function le(e){return Object.prototype.toString.call(e)===`[object Object]`}function ue(e){return new Promise(t=>{p.setTimeout(t,e)})}function de(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:ae(e,t)}function fe(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function pe(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var me=Symbol();function he(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===me?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ge(e,t){return typeof e==`function`?e(...t):!!e}function _e(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var ve=()=>h,ye=()=>ve(),be=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},xe=new class extends be{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Se=m;function Ce(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Se,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var we=Ce(),Te=new class extends be{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Ee(e){return Math.min(1e3*2**e,3e4)}function De(e){return(e??`online`)!==`online`||Te.isOnline()}var Oe=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ke(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(g);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new Oe(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>xe.isFocused()&&(e.networkMode===`always`||Te.isOnline())&&e.canRun(),p=()=>De(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},_=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),v=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(ye()?0:3),a=e.retryDelay??Ee,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),ue(o).then(()=>f()?void 0:_()).then(()=>{t?h(r):v()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?v():_().then(v),s)}}var Ae=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),v(this.gcTime)&&(this.#e=p.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ye()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(p.clearTimeout(this.#e),this.#e=void 0)}};function je(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{_e(e,()=>t.signal,()=>n=!0)},u=he(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?pe:fe;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Ne:Me,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Me(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Me(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ne(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Pe=class extends Ae{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Le(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Le(this.options);e.data!==void 0&&(this.setState(Ie(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=de(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(g).catch(g):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>b(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===me||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>b(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!y(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=he(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?je(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=ke({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Oe&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Oe){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Fe(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Ie(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),we.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Fe(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:De(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Ie(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Le(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Re=class extends be{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Be(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ve(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ve(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof b(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!oe(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&He(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||b(this.options.staleTime,this.#t)!==b(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return oe(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(g)),t}#h(e){return!ye()&&b(this.options.enabled,this.#t)!==!1&&v(e)}#g(){this.#b();let e=b(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=y(this.#r.dataUpdatedAt,e)+1;this.#u=p.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#f=e,!(this.#f===0||!this.#h(this.#f))&&(this.#d=p.setInterval(()=>{(this.options.refetchIntervalInBackground||xe.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(p.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(p.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Be(e,t),o=i&&He(e,n,t,r);(a||o)&&(l={...l,...Fe(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=de(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=de(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,x=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&x,isStale:Ue(e,t),refetch:this.refetch,isEnabled:b(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),oe(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();we.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function ze(e,t){return b(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||b(t.retryOnMount,e)!==!1)}function Be(e,t){return ze(e,t)||e.state.data!==void 0&&Ve(e,t,t.refetchOnMount)}function Ve(e,t,n){if(b(t.enabled,e)!==!1&&b(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Ue(e,t)}return!1}function He(e,t,n,r){return(e!==t||b(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Ue(e,n)}function Ue(e,t){return b(t.enabled,e)!==!1&&e.isStaleByTime(b(t.staleTime,e))}var We=s.createContext(!1),Ge=()=>s.useContext(We);We.Provider;function Ke(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var qe=s.createContext(Ke()),Je=()=>s.useContext(qe),Ye=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?ge(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},Xe=e=>{s.useEffect(()=>{e.clearReset()},[e])},Ze=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ge(n,[e.error,r])),Qe=(e,t)=>t.state.data===void 0,$e=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},et=(e,t)=>e?.suspense&&t.isPending,tt=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function nt(e,t,n){let r=Ge(),i=Je(),a=u(n),o=a.defaultQueryOptions(e),c=a.getQueryCache().get(o.queryHash),l=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:l?`optimistic`:void 0,$e(o),Ye(o,i,c),Xe(i);let[d]=s.useState(()=>new t(a,o)),f=d.getOptimisticResult(o),p=!r&&l;if(s.useSyncExternalStore(s.useCallback(e=>{let t=p?d.subscribe(we.batchCalls(e)):g;return d.updateResult(),t},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),s.useEffect(()=>{d.setOptions(o)},[o,d]),et(o,f))throw tt(o,d,i);if(Ze({result:f,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw f.error;return o.notifyOnChangeProps?f:d.trackResult(f)}var rt=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},it={pipe(){return rt(this,arguments)}},at=function(){function e(){}return e.prototype=it,e}(),S=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},C=e=>e,ot=e=>()=>e,st=ot(!0),ct=ot(!1),lt=ot(null),ut=ot(void 0),dt=ut;function ft(e,...t){return rt(e,t)}function pt(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i}}function mt(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),t.set(i,i),i}}var ht=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},gt=new WeakSet;function _t(e){return typeof e==`string`}function vt(e){return typeof e==`number`}function yt(e){return typeof e==`boolean`}function bt(e){return typeof e==`bigint`}function xt(e){return typeof e==`symbol`}function St(e){return _t(e)||vt(e)||xt(e)}function Ct(e){return typeof e==`function`}function wt(e){return e!==void 0}function Tt(e){return e!=null}function Et(e){return!1}function Dt(e){return!0}function Ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kt(e){return typeof e==`object`&&!!e||Ct(e)}var At=S(2,(e,t)=>kt(e)&&t in e);function jt(e){return e instanceof Error}function Mt(e){return At(e,Symbol.iterator)||_t(e)}var Nt=`~effect/interfaces/Hash`,Pt=e=>{switch(typeof e){case`number`:return zt(e);case`bigint`:return Bt(e.toString(10));case`boolean`:return Bt(String(e));case`symbol`:return Bt(String(e));case`string`:return Bt(e);case`undefined`:return Bt(`undefined`);case`function`:case`object`:if(e===null)return Bt(`null`);if(e instanceof Date)return Number.isNaN(e.getTime())?Bt(`Invalid Date`):Bt(e.toISOString());if(e instanceof RegExp)return Bt(e.toString());{if(gt.has(e))return Ft(e);if(Jt.has(e))return Jt.get(e);let t=Xt(e,()=>Rt(e)?e[Nt]():typeof e==`function`?Ft(e):e instanceof DataView?Wt(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):Array.isArray(e)||ArrayBuffer.isView(e)?Wt(e):e instanceof Map?Gt(e):e instanceof Set?Kt(e):Ht(e));return Jt.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Ft=e=>(qt.has(e)||qt.set(e,zt(Math.floor(Math.random()*(2**53-1)))),qt.get(e)),It=S(2,(e,t)=>e*53^t),Lt=e=>e&3221225471|e>>>1&1073741824,Rt=e=>At(e,Nt),zt=e=>{if(e!==e)return Bt(`NaN`);if(e===1/0)return Bt(`Infinity`);if(e===-1/0)return Bt(`-Infinity`);let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Lt(t)},Bt=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Lt(t)},Vt=(e,t)=>{let n=12289;for(let r of t)n^=It(Pt(r),Pt(e[r]));return Lt(n)},Ht=e=>Vt(e,ht(e)),Ut=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return Lt(r)},Wt=Ut(6151,Pt),Gt=Ut(Bt(`Map`),([e,t])=>It(Pt(e),Pt(t))),Kt=Ut(Bt(`Set`),Pt),qt=new WeakMap,Jt=new WeakMap,Yt=new WeakSet;function Xt(e,t){if(Yt.has(e))return Bt(`[Circular]`);Yt.add(e);let n=t();return Yt.delete(e),n}var Zt=`~effect/interfaces/Equal`;function Qt(){return arguments.length===1?e=>$t(e,arguments[0]):$t(arguments[0],arguments[1])}function $t(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||gt.has(e)||gt.has(t)?!1:an(e,t,rn):!1}function en(e,t,n){let r=tn.has(e),i=nn.has(t);if(r&&i)return!0;if(r||i)return!1;tn.add(e),nn.add(t);let a=n();return tn.delete(e),nn.delete(t),a}var tn=new WeakSet,nn=new WeakSet;function rn(e,t){if(Pt(e)!==Pt(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),r=t.getTime();return n===r||Number.isNaN(n)&&Number.isNaN(r)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let n=mn(e),r=mn(t);if(n!==r)return!1;let i=n&&r;return typeof e==`function`&&!i?!1:en(e,t,()=>{if(i)return e[Zt](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:sn(e,t);if(ArrayBuffer.isView(e)){let n=e instanceof DataView;if(!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView)return!1;if(n){let n=t;return cn(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(n.buffer,n.byteOffset,n.byteLength))}return cn(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:dn(e,t):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:pn(e,t):ln(e,t)})}function an(e,t,n){let r=on.get(e);if(!r)r=new WeakMap,on.set(e,r);else if(r.has(t))return r.get(t);let i=n(e,t);r.set(t,i);let a=on.get(t);return a||(a=new WeakMap,on.set(t,a)),a.set(e,i),i}var on=new WeakMap;function sn(e,t){for(let n=0;n<e.length;n++)if(!$t(e[n],t[n]))return!1;return!0}function cn(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 ln(e,t){let n=ht(e),r=ht(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!$t(e[i],t[i]))return!1;return!0}function un(e,t){return function(n,r){let i=Array.from(r);for(let[r,a]of n){let n=!1;for(let o=0;o<i.length;o++){let[s,c]=i[o];if(e(r,s)&&t(a,c)){i[o]=i[i.length-1],i.pop(),n=!0;break}}if(!n)return!1}return!0}}var dn=un($t,$t);function fn(e){return function(t,n){let r=Array.from(n);for(let n of t){let t=!1;for(let i=0;i<r.length;i++){let a=r[i];if(e(n,a)){r[i]=r[r.length-1],r.pop(),t=!0;break}}if(!t)return!1}return!0}}var pn=fn($t),mn=e=>At(e,Zt),hn=e=>(t,n)=>t===n||e(t,n),gn=(e,t)=>e===t,_n=()=>gn;function vn(e){return hn((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e[r](t[r],n[r]))return!1;return!0})}function yn(e){return hn((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 bn=e=>e.length>0;function xn(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function Sn(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&xn(e,n,t[n])}var Cn=Symbol.for(`~effect/Redactable`),wn=e=>At(e,Cn);function Tn(e){return wn(e)?En(e):e}function En(e){return e[Cn](globalThis[`~effect/Fiber/currentFiber`]?.context??kn)}var Dn=`~effect/Fiber/currentFiber`,On=new Map,kn={"~effect/Context":{},base:On,depth:0,mapUnsafe:On,pipe(){return rt(this,arguments)}};function An(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,n=0){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return jn;r.add(e);let l;if(Cn in e)l=c(En(e),n);else if(Array.isArray(e))l=!i||e.length<=1?`[${e.map(e=>c(e,n)).join(`,`)}]`:`[\n${a(n+1)}${e.map(e=>c(e,n+1)).join(`,
|
|
2
|
-
`+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=Pn(e);else if(!t?.ignoreToString&&At(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=Fn(e);l=e instanceof Error&&e.cause?`${t} (cause: ${c(e.cause,n)})`:t}else if(Symbol.iterator in e)l=`${e.constructor.name}(${c(Array.from(e),n)})`;else{let t=s(e);if(!i||t.length<=1){let r=`{${t.map(t=>`${Mn(t)}:${c(e[t],n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${Mn(t)}: ${c(e[t],n+1)}`).join(`,
|
|
3
|
-
`)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}var jn=`[Circular]`;function Mn(e){return typeof e==`string`?JSON.stringify(e):String(e)}function Nn(e){return e.map(e=>`[${Mn(e)}]`).join(``)}function Pn(e){try{return e.toISOString()}catch{return`Invalid Date`}}function Fn(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function In(e,t){let n=[];return JSON.stringify(e,function(e,t){let r=Object.getOwnPropertyDescriptor(this,e)?.value,i=At(r,Cn)?Tn(r):Tn(t);if(typeof i==`bigint`)return An(i);if(typeof i!=`object`||!i)return i;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(!n.includes(i))return n.push(i),i},t?.space)??`null`}var Ln=Symbol.for(`nodejs.util.inspect.custom`),Rn=e=>{try{return e=Tn(e),At(e,`toJSON`)&&Ct(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(Rn):e}catch{return`[toJSON threw]`}},zn=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?In(e,{space:t}):An(e,{space:t})}catch{return String(e)}},Bn={toJSON(){return Rn(this)},[Ln](){return this.toJSON()},toString(){return An(this.toJSON())}},Vn=class{[Ln](){return this.toJSON()}toString(){return An(this.toJSON())}},Hn=class e{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 e(this.self)}},Un=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}};return t[e](()=>Error().stack)?.includes(e)===!0?t[e]:n[e]})(),Wn=`~effect/Effect`,Gn=`~effect/Exit`,Kn={_A:C,_E:C,_R:C},qn=`${Wn}/identifier`,w=`${Wn}/args`,Jn=`${Wn}/evaluate`,Yn=`${Wn}/successCont`,Xn=`${Wn}/failureCont`,Zn=`${Wn}/ensureCont`,Qn=Symbol.for(`effect/Effect/Yield`),$n={pipe(){return rt(this,arguments)},toJSON(){return{...this}},toString(){return An(this.toJSON(),{ignoreToString:!0,space:2})},[Ln](){return this.toJSON()}},er={[Wn]:Kn,...$n,[Symbol.iterator](){return new Hn(this)},toJSON(){return{_id:`Effect`,op:this[qn],...w in this?{args:this[w]}:void 0}}},tr=e=>At(e,Wn),nr=e=>At(e,Gn),rr=`~effect/Cause`,ir=`~effect/Cause/Reason`,ar=e=>At(e,rr),or=e=>At(e,ir),sr=class{[rr];reasons;constructor(e){this[rr]=rr,this.reasons=e}pipe(){return rt(this,arguments)}toJSON(){return{_id:`Cause`,failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${An(this.reasons)})`}[Ln](){return this.toJSON()}[Zt](e){return ar(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>Qt(t,e.reasons[n]))}[Nt](){return Wt(this.reasons)}},cr=new WeakMap,lr=class{[ir];annotations;_tag;constructor(e,t,n){if(this[ir]=ir,this._tag=e,t!==ur&&typeof n==`object`&&n&&t.size>0){let e=cr.get(n);e&&(t=new Map([...e,...t])),cr.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((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)});let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return rt(this,arguments)}toString(){return An(this)}[Ln](){return this.toString()}},ur=new Map,dr=class extends lr{error;constructor(e,t=ur){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${An(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[Zt](e){return vr(e)&&Qt(this.error,e.error)&&Qt(this.annotations,e.annotations)}[Nt](){return It(Bt(this._tag))(It(Pt(this.error))(Pt(this.annotations)))}},fr=e=>new sr(e),pr=new sr([]),mr=e=>new sr([new dr(e)]),hr=class extends lr{defect;constructor(e,t=ur){super(`Die`,t,e),this.defect=e}toString(){return`Die(${An(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[Zt](e){return yr(e)&&Qt(this.defect,e.defect)&&Qt(this.annotations,e.annotations)}[Nt](){return It(Bt(this._tag))(It(Pt(this.defect))(Pt(this.annotations)))}},gr=e=>new sr([new hr(e)]),_r=S(e=>ar(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new sr(e.reasons.map(e=>e.annotate(t,n)))),vr=e=>e._tag===`Fail`,yr=e=>e._tag===`Die`,br=e=>e._tag===`Interrupt`;function xr(e){return Ar(`Effect.evaluate: Not implemented`)}var Sr=e=>({...er,[qn]:e.op,[Jn]:e[Jn]??xr,[Yn]:e[Yn],[Xn]:e[Xn],[Zn]:e[Zn]}),Cr=e=>{let t=Sr(e);return function(){let n=Object.create(t);return n[w]=e.single===!1?arguments:arguments[0],n}},wr=e=>{let t={[Gn]:Gn,_tag:e.op,get[e.prop](){return this[w]},...Sr(e),toString(){return`${e.op}(${An(this[w])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[w]}},[Zt](e){return nr(e)&&e._tag===this._tag&&Qt(this[w],e[w])},[Nt](){return It(Bt(e.op),Pt(this[w]))}};return function(e){let n=Object.create(t);return n[w]=e,n}},Tr=wr({op:`Success`,prop:`value`,[Jn](e){let t=e.getCont(Yn);return t?t[Yn](this[w],e,this):e.yieldWith(this)}}),Er={key:`effect/Cause/StackTrace`},Dr={key:`effect/Cause/InterruptorStackTrace`},Or=wr({op:`Failure`,prop:`cause`,[Jn](e){let t=this[w],n=!1;e.currentStackFrame&&(t=_r(t,{mapUnsafe:new Map([[Er.key,e.currentStackFrame]])}),n=!0);let r=e.getCont(Xn);for(;e.interruptible&&e._interruptedCause&&r;)r=e.getCont(Xn);return r?r[Xn](t,e,n?void 0:this):e.yieldWith(n?Or(t):this)}}),kr=e=>Or(mr(e)),Ar=e=>Or(gr(e)),jr=Cr({op:`WithFiber`,[Jn](e){return this[w](e)}}),Mr=function(){class e extends globalThis.Error{}let t=Sr({op:`YieldableError`,[Jn](){return kr(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Nr=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends Mr{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(Sn(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),Pr=e=>{class t extends Nr{_tag=e}return t.prototype.name=e,t};Pr(`NoSuchElementError`);var Fr=`~effect/Cause/Done`,Ir=e=>At(e,Fr),Lr={[Fr]:Fr,_tag:`Done`,value:void 0},Rr=e=>e===void 0?Lr:{[Fr]:Fr,_tag:`Done`,value:e},zr=kr(Lr),Br=e=>e===void 0?zr:kr(Rr(e)),Vr=`~effect/data/Option`,Hr={[Vr]:{_A:e=>e},...$n,[Symbol.iterator](){return new Hn(this)}},Ur=Object.defineProperty(Object.assign(Object.create(Hr),{_tag:`Some`,_op:`Some`,[Zt](e){return Kr(e)&&Jr(e)&&Qt(this.value,e.value)},[Nt](){return It(Pt(this._tag))(Pt(this.value))},toString(){return`some(${An(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:Rn(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),Wr=Pt(`None`),Gr=Object.assign(Object.create(Hr),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[Zt](e){return Kr(e)&&qr(e)},[Nt](){return Wr},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),Kr=e=>At(e,Vr),qr=e=>e._tag===`None`,Jr=e=>e._tag===`Some`,Yr=Object.create(Gr),Xr=e=>{let t=Object.create(Ur);return t.value=e,t},Zr=`~effect/data/Result`,Qr={[Zr]:{_A:e=>e,_E:e=>e},...$n,[Symbol.iterator](){return new Hn(this)}},$r=Object.assign(Object.create(Qr),{_tag:`Success`,_op:`Success`,[Zt](e){return ti(e)&&ri(e)&&Qt(this.success,e.success)},[Nt](){return It(Pt(this._tag))(Pt(this.success))},toString(){return`success(${An(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:Rn(this.success)}}}),ei=Object.assign(Object.create(Qr),{_tag:`Failure`,_op:`Failure`,[Zt](e){return ti(e)&&ni(e)&&Qt(this.failure,e.failure)},[Nt](){return It(Pt(this._tag))(Pt(this.failure))},toString(){return`failure(${An(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:Rn(this.failure)}}}),ti=e=>At(e,Zr),ni=e=>e._tag===`Failure`,ri=e=>e._tag===`Success`,ii=e=>{let t=Object.create(ei);return t.failure=e,t},ai=e=>{let t=Object.create($r);return t.success=e,t},oi=S(2,(e,t)=>qr(e)?ii(t()):ai(e.value));function si(e){return(t,n)=>t===n?0:e(t,n)}var ci=si((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),li=S(2,(e,t)=>si((n,r)=>e(t(n),t(r)))),ui=e=>S(2,(t,n)=>e(t,n)===-1),di=e=>S(2,(t,n)=>e(t,n)===1),fi=e=>S(2,(t,n)=>e(t,n)!==1),pi=e=>S(2,(t,n)=>e(t,n)!==-1),T=()=>Yr,E=Xr,mi=Kr,hi=qr,D=Jr,gi=S(2,(e,{onNone:t,onSome:n})=>hi(e)?t():n(e.value)),_i=S(2,(e,t)=>hi(e)?t():e.value),vi=e=>{let t=T();for(t of e)if(D(t))return t;return t},yi=e=>e==null?T():E(e),bi=e=>e===void 0?T():E(e),xi=e=>e===null?T():E(e),Si=_i(lt),Ci=_i(ut),wi=e=>(...t)=>{try{return E(e(...t))}catch{return T()}},Ti=S(2,(e,t)=>hi(e)?T():E(t(e.value))),Ei=S(2,(e,t)=>hi(e)?T():t(e.value)),Di=Ei(C),Oi=e=>{if(Symbol.iterator in e){let t=[];for(let n of e){if(hi(n))return T();t.push(n.value)}return E(t)}let t={};for(let n of Object.keys(e)){let r=e[n];if(hi(r))return T();xn(t,n,r.value)}return E(t)},ki=e=>hi(e)?[]:[e.value],Ai=S(2,(e,t)=>hi(e)?T():t(e.value)?E(e.value):T()),ji=e=>hn((t,n)=>hi(t)?hi(n):!hi(n)&&e(t.value,n.value)),Mi=ai,Ni=ii,Pi=oi,Fi=e=>{if(Ct(e))try{return Mi(e())}catch(e){return Ni(e)}try{return Mi(e.try())}catch(t){return Ni(e.catch(t))}},Ii=ti,Li=ni,Ri=ri,zi=S(2,(e,t)=>Ri(e)?Mi(t(e.success)):e),Bi=S(2,(e,{onFailure:t,onSuccess:n})=>Li(e)?t(e.failure):n(e.success)),Vi=S(2,(e,t)=>{if(Ri(e))return e.success;throw t(e.failure)})(C),Hi=e=>{if(Symbol.iterator in e){let t=[];for(let n of e){if(Li(n))return n;t.push(n.success)}return Mi(t)}let t={};for(let n of Object.keys(e)){let r=e[n];if(Li(r))return r;xn(t,n,r.success)}return Mi(t)},Ui=vn,Wi=S(2,(e,t)=>Object.hasOwn(e,t)),Gi=S(2,(e,t)=>{let n={...e};for(let r of Ki(e))xn(n,r,t(e[r],r));return n}),Ki=e=>Object.keys(e),qi=e=>S(2,(t,n)=>{for(let r of Ki(t))if(!Wi(n,r)||!e(t[r],n[r]))return!1;return!0}),Ji=e=>{let t=qi(e);return(e,n)=>t(e,n)&&t(n,e)},Yi=globalThis.Array,Xi=e=>Yi.isArray(e)?e:Yi.from(e),Zi=e=>Yi.isArray(e)?e:[e],Qi=S(2,(e,t)=>[t,...e]),$i=S(2,(e,t)=>[...e,t]),ea=S(2,(e,t)=>Xi(e).concat(Xi(t)));Yi.isArray;var ta=bn,na=bn;function ra(e,t){return!Number.isFinite(e)||e<0||e>=t.length}var ia=S(2,(e,t)=>{let n=Math.floor(t);if(ra(n,e))throw Error(`Index out of bounds: ${n}`);return e[n]})(0),aa=S(2,(e,t)=>{let n=Yi.from(e);return n.sort(t),n}),oa=S(2,(e,t)=>{let n=Xi(e);if(na(n)){let[e,r]=t(n),i=[e],a=r;for(;bn(a);){let[e,n]=t(a);i.push(e),a=n}return i}return[]}),sa=S(2,(e,t)=>{let n=Math.max(1,Math.floor(t));return n>=e.length?[ca(e),[]]:[Qi(e.slice(1,n),ia(e)),e.slice(n)]}),ca=e=>e.slice(),la=S(2,(e,t)=>{let n=Xi(e);return na(n)?oa(n,sa(t)):[]}),ua=S(2,(e,t)=>{let n={};for(let r of e){let e=t(r);Object.hasOwn(n,e)?n[e].push(r):xn(n,e,[r])}return n}),da=(e,t)=>{let n=Pt(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let e of r)if(Qt(e,t))return!1;return r.push(t),!0},fa=S(2,(e,t)=>{let n=Xi(e),r=Xi(t);return na(n)?na(r)?_a(ea(n,r)):n:r}),pa=()=>[],ma=e=>[e],ha=S(2,(e,t)=>e.map(t)),ga=yn,_a=e=>{let t=Xi(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let e of t)da(n,e)&&r.push(e);return r},va=`~effect/BigDecimal`,ya={[va]:va,[Nt](){let e=Ea(this);return It(Pt(e.value),zt(e.scale))},[Zt](e){return ba(e)&&Aa(this,e)},toString(){return`BigDecimal(${ja(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[Ln](){return this.toJSON()},pipe(){return rt(this,arguments)}},ba=e=>At(e,va),xa=(e,t)=>{let n=Object.create(ya);return n.value=e,n.scale=t,n},Sa=(e,t)=>{if(e!==Ca&&e%wa===Ca)throw RangeError(`Value must be normalized`);let n=xa(e,t);return n.normalized=n,n},Ca=BigInt(0),wa=BigInt(10),Ta=Sa(Ca,0),Ea=e=>{if(e.normalized===void 0){if(e.value===Ca)e.normalized=Ta;else{let t=`${e.value}`,n=0;for(let e=t.length-1;e>=0&&t[e]===`0`;e--)n++;n===0&&(e.normalized=e),e.normalized=Sa(BigInt(t.substring(0,t.length-n)),e.scale-n)}}return e.normalized},Da=S(2,(e,t)=>t>e.scale?xa(e.value*wa**BigInt(t-e.scale),t):t<e.scale?xa(e.value/wa**BigInt(e.scale-t),t):e),Oa=e=>e.value<Ca?xa(-e.value,e.scale):e,ka=hn((e,t)=>e.scale>t.scale?Da(t,e.scale).value===e.value:e.scale<t.scale?Da(e,t.scale).value===t.value:e.value===t.value),Aa=S(2,(e,t)=>ka(e,t)),ja=e=>{let t=Ea(e);if(Math.abs(t.scale)>=16)return Ma(t);let n=t.value<Ca,r=n?`${t.value}`.substring(1):`${t.value}`,i,a;if(t.scale>=r.length)i=`0`,a=`0`.repeat(t.scale-r.length)+r;else{let e=r.length-t.scale;if(e>r.length){let t=e-r.length;i=`${r}${`0`.repeat(t)}`,a=``}else a=r.slice(e),i=r.slice(0,e)}let o=a===``?i:`${i}.${a}`;return n?`-${o}`:o},Ma=e=>{if(Na(e))return`0e+0`;let t=Ea(e),n=`${Oa(t).value}`,r=n.slice(0,1),i=n.slice(1),a=`${Pa(t)?`-`:``}${r}`;i!==``&&(a+=`.${i}`);let o=i.length-t.scale;return`${a}e${o>=0?`+`:``}${o}`},Na=e=>e.value===Ca,Pa=e=>e.value<Ca,Fa=e=>Sr({op:e.label,[Jn]:e.evaluate}),Ia=`~effect/Context/Service`,O=function(){function e(){}let t=e;Object.setPrototypeOf(t,La);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[za]=za,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&Ra.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},La={[Ia]:Ia,...Fa({label:`Service`,evaluate(e){return Tr(co(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return no(this,e)},use(e){return jr(t=>e(co(t.context,this)))},useSync(e){return jr(t=>Tr(e(co(t.context,this))))}},Ra=new Set,za=`~effect/Context/Reference`,Ba=`~effect/Context`,Va=8,Ha=8,Ua=(e,t,n,r)=>{let i=Object.create(Xa);return i.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void 0,i.baseHits=0,i},Wa=(e,t)=>{t&&(Wa(e,t.parent),e.set(t.key,t.value))},Ga=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return Wa(t,e.overlay),e._flat=t},Ka=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),Ya(n)},qa=Symbol(),Ja=(e,t)=>{let n=e;for(let e=n.overlay;e;e=e.parent)if(e.key===t)return e.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?qa:(n.overlay&&++n.baseHits>=Ha&&(n.base=Ga(n),n.overlay=void 0,n.depth=0),r)},Ya=e=>Ua(void 0,e,void 0,0),Xa={get mapUnsafe(){return Ga(this)},...$n,[Ba]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[Zt](e){if(!Qa(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[e,r]of t)if(!n.has(e)||!Qt(r,n.get(e)))return!1;return!0},[Nt](){return zt(this.mapUnsafe.size)}},Za=(e,t)=>e.cacheRoot===t.cacheRoot,Qa=e=>At(e,Ba),$a=e=>!!e[za],eo=()=>to,to=Ya(new Map),no=(e,t)=>Ya(new Map([[e.key,t]])),ro=S(3,(e,t,n)=>io(e,t.key,n)),io=(e,t,n)=>{let r=e,i=Ra.has(t)?void 0:r.cacheRoot;if(r.depth>=Va){let e=new Map(r.mapUnsafe);return e.set(t,n),Ua(i,e,void 0,0)}return Ua(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},ao=S(2,(e,t)=>oo(e,t.key)),oo=(e,t)=>{let n=Ja(e,t);return n===qa?void 0:n},so=S(2,(e,t)=>{let n=Ja(e,t.key);if(n===qa){if($a(t))return uo(t);throw fo(t)}return n}),co=so,lo=`~effect/Context/defaultValue`,uo=e=>lo in e?e[lo]:e[lo]=e.defaultValue(),fo=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
|
|
4
|
-
`);e.splice(1,3),t.stack=e.join(`
|
|
5
|
-
`)}return t},po=S(2,(e,t)=>{let n=Ja(e,t.key);return n===qa?$a(t)?E(uo(t)):T():E(n)}),mo=S(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:Ka(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),ho=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return Ya(t)},go=O,_o=`~effect/time/Duration`,vo=BigInt(0),yo=BigInt(1),bo=BigInt(2),xo=BigInt(10),So=BigInt(1e3),Co=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),wo=e=>Co(e*1e6),To=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=xo**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t,s=o/a+(o%a*bo>=a?yo:vo);return r?-s:s},Eo=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,Do=e=>{switch(typeof e){case`number`:return zo(e);case`bigint`:return Ro(e);case`string`:{if(e===`Infinity`)return Io;if(e===`-Infinity`)return Lo;let t=Eo.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return Ro(To(r,yo));if(i===`micro`||i===`micros`)return Ro(To(r,So));let a=Number(r);switch(i){case`milli`:case`millis`:return zo(a);case`second`:case`seconds`:return Bo(a);case`minute`:case`minutes`:return Vo(a);case`hour`:case`hours`:return Ho(a);case`day`:case`days`:return Uo(a);case`week`:case`weeks`:return Wo(a)}break}case`object`:{if(e===null)break;if(_o in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(vt)?Oo(e):Number.isNaN(e[0])||Number.isNaN(e[1])?Fo:e[0]===-1/0||e[1]===-1/0?Lo:e[0]===1/0||e[1]===1/0?Io:No(Co(e[0]*1e9+e[1]));let t=e,n=0;return t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds?No(n):No(Co(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return Oo(e)},Oo=e=>{throw Error(`Invalid Input: ${e}`)},ko={_tag:`Millis`,millis:0},Ao={_tag:`Infinity`},jo={_tag:`NegativeInfinity`},Mo={[_o]:_o,[Nt](){switch(this.value._tag){case`Millis`:{let e=this.value.millis*1e6;return Number.isFinite(e)?Pt(Co(e)):zt(this.value.millis)}case`Nanos`:return Pt(this.value.nanos);default:return Ht(this.value)}},[Zt](e){return Po(e)&&Xo(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`}}},[Ln](){return this.toJSON()},pipe(){return rt(this,arguments)}},No=e=>{let t=Object.create(Mo);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?ko:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:wo(e)}:e>0?Ao:jo:e===vo?ko:{_tag:`Nanos`,nanos:e},t},Po=e=>At(e,_o),Fo=No(0),Io=No(1/0),Lo=No(-1/0),Ro=e=>No(e),zo=e=>No(e),Bo=e=>No(e*1e3),Vo=e=>No(e*6e4),Ho=e=>No(e*36e5),Uo=e=>No(e*864e5),Wo=e=>No(e*6048e5),Go=e=>qo(Do(e),{onMillis:C,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Ko=e=>{let t=Do(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 wo(t.value.millis)}},qo=S(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)()}}),Jo=S(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(Ko(e),t.value.nanos):n.onNanos(e.value.nanos,Ko(t))),Yo=(e,t)=>Jo(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),Xo=S(2,(e,t)=>Yo(e,t)),Zo=e=>t=>{let n=e(t);return Li(n)?T():E(n.success)},Qo=go(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new ns}),$o=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},es=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},ts=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},ns=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?es:$o)}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new rs(this.setImmediate)}},rs=class{tasks=new ts;running=void 0;setImmediate;constructor(e=$o){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},is=go(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),as=go(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),os=class extends at{constructor(e){super(),e&&Sn(this,e)}},ss=e=>class extends os{_tag=e},cs=Pr,ls=`~effect/encoding/EncodingError`,us=class extends cs(`EncodingError`){[ls]=ls},ds=e=>bs(typeof e==`string`?_s.encode(e):e),fs=e=>{let t=ys(e),n=t.length;if(n%4!=0)return Ni(new us({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 Ni(new us({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));try{let e=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(n/4*3-e);for(let e=0,i=0;e<n;e+=4,i+=3){let n=xs(t.charCodeAt(e))<<18|xs(t.charCodeAt(e+1))<<12|xs(t.charCodeAt(e+2))<<6|xs(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return Mi(r)}catch(e){return Ni(new us({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},ps=e=>ws(typeof e==`string`?_s.encode(e):e),ms=e=>{let t=ys(e),n=t.length;if(n%4==1)return Ni(new us({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 Ni(new us({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,`/`),fs(r)},hs=e=>zi(ms(e),e=>vs.decode(e)),gs=e=>{let t=``;for(let n=e>>>3;n>0;n--){let e=Math.random()*4294967296>>>0;t+=Ts[e>>>24]+Ts[e>>>16&255]+Ts[e>>>8&255]+Ts[e&255]}return t},_s=new TextEncoder,vs=new TextDecoder,ys=e=>e.replace(/[\n\r]/g,``),bs=e=>{let t=e.length,n=``,r;for(r=2;r<t;r+=3)n+=Ss[e[r-2]>>2],n+=Ss[(e[r-2]&3)<<4|e[r-1]>>4],n+=Ss[(e[r-1]&15)<<2|e[r]>>6],n+=Ss[e[r]&63];return r===t+1&&(n+=Ss[e[r-2]>>2],n+=Ss[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=Ss[e[r-2]>>2],n+=Ss[(e[r-2]&3)<<4|e[r-1]>>4],n+=Ss[(e[r-1]&15)<<2],n+=`=`),n};function xs(e){if(e>=Cs.length)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=Cs[e];if(t===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}var Ss=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),Cs=[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],ws=e=>bs(e).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`),Ts=[];for(let e=0;e<256;e++)Ts.push(e.toString(16).padStart(2,`0`));var Es=`effect/Tracer/ParentSpan`,Ds=class extends O()(Es,{fiberCached:!0}){},Os=e=>e,ks=go(`effect/Tracer/DisablePropagation`,{defaultValue:ct}),As=go(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),js=go(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),Ms=`effect/Tracer`,Ns=go(Ms,{fiberCached:!0,defaultValue:()=>Os({span:e=>new Ps(e)})}),Ps=class{_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=Ci(e.parent)?.traceId??gs(32),this.spanId=gs(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)}},Fs=`effect/observability/Metric/FiberRuntimeMetricsKey`,Is=go(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:ut}),Ls=go(`effect/References/TracerEnabled`,{defaultValue:st}),Rs=go(`effect/References/TracerTimingEnabled`,{defaultValue:st}),zs=go(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),Bs=go(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),Vs=go(`effect/References/CurrentLogAnnotations`,{defaultValue:()=>({})}),Hs=go(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),Us=go(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),Ws=go(`effect/References/CurrentLogSpans`,{defaultValue:()=>[]}),Gs=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),Ks=()=>Error.stackTraceLimit,qs=e=>{Gs&&(Error.stackTraceLimit=e)},Js=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=Ks();qs(3);let n=Error();return qs(t),{...e,captureStackTrace:Xs(()=>n.stack)}},Ys=e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
|
|
6
|
-
`);if(i[e]!==void 0)return n=i[e].trim(),n}},Xs=Ys(3),Zs=class extends lr{fiberId;constructor(e,t=ur){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[Zt](e){return br(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[Nt](){return It(Bt(`${this._tag}:${this.fiberId}`))(Ft(this.annotations))}},Qs=e=>new Zs(e),$s=e=>new sr([new Zs(e)]),ec=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return Mi(n.error)}return Ni(e)},tc=Zo(ec),nc=e=>{let t=e.reasons.find(yr);return t?Mi(t.defect):Ni(e)},rc=e=>e.reasons.some(br),ic=e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag===`Interrupt`&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?Mi(t):Ni(e)},ac=S(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new sr(fa(e.reasons,t.reasons));return Qt(e,n)?e:n}),oc=S(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>vr(e)?(n=!0,new dr(t(e.error),e.annotations)):e);return n?fr(r):e}),sc=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},cc=e=>{let t=sc(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`)},lc=(e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let i=Ks();qs(1);for(let i of e.reasons){if(i._tag===`Interrupt`){r.push(i);continue}n.push(uc(i._tag===`Die`?i.defect:i.error,i.annotations,t))}if(n.length===0){let e=Error(`The fiber was interrupted by:`);e.name=`InterruptCause`,e.stack=hc(e,r);let i=new globalThis.Error(`All fibers interrupted without error`,{cause:e});i.name=`InterruptError`,i.stack=`${i.name}: ${i.message}`,n.push(uc(i,r[0].annotations,t))}return qs(i),n},uc=(e,t,n)=>{let r=typeof e,i;if(e&&r===`object`){if(i=new globalThis.Error(dc(e),{cause:e.cause?uc(e.cause):void 0}),typeof e.name==`string`&&(i.name=e.name),typeof e.stack==`string`)i.stack=pc(e.stack,i,t);else{let e=`${i.name}: ${i.message}`;i.stack=t?mc(e,t):e}n?.includeCauseInStack&&(i.stack=vc(i));for(let t of Object.keys(e))t in i||(i[t]=e[t])}else i=new globalThis.Error(e?r===`string`?e:In(e):`Unknown error: ${e}`);return i},dc=e=>{if(typeof e.message==`string`)return e.message;if(typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return In(e)},fc=/\((.*)\)/g,pc=(e,t,n)=>{let r=`${t.name}: ${t.message}`,i=(e.startsWith(r)?e.slice(r.length):e).split(`
|
|
7
|
-
`),a=[r];for(let e=1;e<i.length&&!/(?:Generator\.next|~effect\/Effect)/.test(i[e]);e++)a.push(i[e]);return n?mc(a.join(`
|
|
8
|
-
`),n):a.join(`
|
|
9
|
-
`)},mc=(e,t)=>{let n=t?.get(Er.key);return n&&(e=`${e}\n${gc(n)}`),e},hc=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let e of t){let t=e.fiberId===void 0?`unknown`:`#${e.fiberId}`,r=e.annotations.get(Dr.key);n.push(` at fiber (${t})`),r&&n.push(gc(r))}return n.join(`
|
|
10
|
-
`)},gc=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(fc),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
|
|
11
|
-
`)},_c=e=>lc(e).map(vc).join(`
|
|
12
|
-
`),vc=e=>e.cause?`${e.stack} {\n${yc(e.cause,` `)}\n}`:e.stack,yc=(e,t)=>{let n=e.stack.split(`
|
|
13
|
-
`),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${yc(e.cause,`${t} `)}\n${t}}`),r},bc=`~effect/Fiber`,xc={_A:C,_E:C},Sc={id:0},Cc=()=>globalThis[Dn],wc=class{constructor(e,t=!0){this[bc]=xc,this.setContext(e),this.id=++Sc.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)}[bc];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 co(this.context,e)}addObserver(e){return this._exit?(e(this._exit),dt):(this._observers.push(e),()=>{if(this._exit)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}interruptUnsafe(e,t){if(this._exit)return;let n=$s(e);this.currentStackFrame&&(n=_r(n,no(Er,this.currentStackFrame))),t&&(n=_r(n,t)),this._interruptedCause=this._interruptedCause?ac(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Pc(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Qn)return;let n=Ec.interruptChildren&&Ec.interruptChildren(this);if(n!==void 0)return this.evaluate(fl(n,()=>t));this._exit=t,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let e=0;e<this._observers.length;e++)this._observers[e](t);this._observers.length=0,this._stack.length=0,this._children=void 0,this.context=eo()}runLoop(e){let t=globalThis[Dn];globalThis[Dn]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;){if(this._deferredInterrupt&&(this._deferredInterrupt=!1,i=Pc(this._interruptedCause)),this.currentOpCount++,!r&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){r=!0;let e=i;i=fl(zc,()=>e)}if(i=this.currentTracerContext?this.currentTracerContext(i,this):i[Jn](this),i===Qn){let e=this._yielded;if(Gn in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return Qn}}}catch(e){return At(i,Jn)?this.runLoop(Ar(e)):Ar(`Fiber.runLoop: Not a valid effect: ${String(i)}`)}finally{this._running=n,globalThis[Dn]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,Tc;for(;;){let t=this._stack.pop();if(!t)return;let n=t[Zn]&&t[Zn](this);if(n)return n[e]=n,n;if(t[e])return t}}yieldWith(e){return this._yielded=e,Qn}children(){return this._children??=new Set}pipe(){return rt(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&Za(t,e))return;let n=this.getRef(Qo);n!==this.currentScheduler&&(this.currentScheduler=n,this._dispatcher=void 0),this.currentSpan=oo(e,Es),this.currentLogLevel=this.getRef(Hs),this.minimumLogLevel=this.getRef(Us),this.currentStackFrame=this.getRef(Is),this.maxOpsBeforeYield=this.getRef(is),this.currentPreventYield=this.getRef(as),this.runtimeMetrics=oo(e,Fs);let r=oo(e,Ms);this.currentTracerContext=r?r.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag===`Span`?this.currentSpan:void 0}},Tc={[Yn](e,t){return Pc(t._interruptedCause)},[Xn](e,t){return Pc(t._interruptedCause)}},Ec={interruptChildren:void 0},Dc=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(Dr.key,e.currentStackFrame),Ya(t)},Oc=e=>{let t=e;return t._exit?Nc(t._exit):Xc(n=>t._exit?n(Nc(t._exit)):Ic(e.addObserver(e=>n(Nc(e)))))},kc=e=>Xc(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(Nc(r))}return a(),Ic(()=>i?.())}),Ac=e=>jr(t=>jc(e,t.id)),jc=S(e=>At(e[0],bc),(e,t,n)=>jr(r=>{let i=Dc(r);return i=i&&n?mo(i,n):i??n,e.interruptUnsafe(t,i),dl(Oc(e))})),Mc=e=>jr(t=>{let n=Dc(t),r=pa();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return dl(kc(r))}),Nc=Tr,Pc=Or,Fc=kr,Ic=Cr({op:`Sync`,[Jn](e){let t=this[w](),n=e.getCont(Yn);return n?n[Yn](t,e):e.yieldWith(Tr(t))}}),Lc=Cr({op:`Suspend`,[Jn](e){return this[w]()}}),Rc=Bi({onFailure:Fc,onSuccess:Nc}),zc=Cr({op:`Yield`,[Jn](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Sl)},this[w]??0),e.yieldWith(()=>{t=!0})}})(0),Bc=Nc(T()),Vc=e=>Lc(()=>Pc(Un(e))),Hc=e=>Ar(e),Uc=e=>Lc(()=>Fc(Un(e))),Wc=Nc(void 0),Gc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Od(e,`An error occurred in Effect.try`):e.catch;return Lc(()=>{try{return Nc(Un(t))}catch(e){return Fc(Un(()=>n(e)))}})},Kc=e=>Jc(function(t,n){Un(()=>e(n)).then(e=>t(Nc(e)),e=>t(Hc(e)))},e.length!==0),qc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Od(e,`An error occurred in Effect.tryPromise`):e.catch;return Jc(function(e,r){let i=t=>{try{e(Fc(Un(()=>n(t))))}catch(t){e(Hc(t))}};try{Un(()=>t(r)).then(t=>e(Nc(t)),i)}catch(e){i(e)}},t.length!==0)},Jc=Cr({op:`Async`,single:!1,[Jn](e){let t=Un(()=>this[w][0].bind(e.currentScheduler)),n=!1,r=!1,i=this[w][1]?new AbortController:void 0,a=t(t=>{n||(n=!0,r?e.evaluate(t):r=t)},i?.signal);return r===!1?(r=!0,e._yielded=()=>{n=!0},i===void 0&&a===void 0||e._stack.push(Yc(()=>(n=!0,i?.abort(),a??Sl))),Qn):r}}),Yc=Cr({op:`AsyncFinalizer`,[Zn](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Mu))},[Xn](e,t){return rc(e)?fl(this[w](),()=>Pc(e)):Pc(e)}}),Xc=e=>Jc(e,e.length>=2),Zc=Xc(dt),Qc=(...e)=>Lc(()=>ol(e.length===1?e[0]():e[1].call(e[0].self))),$c=(e,...t)=>{let n=t.length===0?function(){return Lc(()=>ol(e.apply(this,arguments)))}:function(){let n=Lc(()=>ol(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return el(e.length,n)},el=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),tl=Ys(2),nl=function(){let e=typeof arguments[0]==`string`,t=e?arguments[0]:`Effect.fn`,n=e?arguments[1]:void 0,r=Ks();qs(2);let i=new globalThis.Error;return qs(r),e?(r,...a)=>rl(t,r,i,a,e,n):rl(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,n)},rl=(e,t,n,r,i,a)=>{let o=typeof t==`function`?t:r.shift().bind(t.self);return el(o.length,function(...t){let s=Lc(()=>{let e=o.apply(this,arguments);return tr(e)?e:ol(e)});for(let e=0;e<r.length;e++)s=r[e](s,...t);if(!tr(s))return s;let c=Ks();qs(2);let l=new globalThis.Error;return qs(c),kl(i?ld(e,a,e=>ud(s,e)):s,Is,t=>({name:e,stack:tl(()=>l.stack),parent:{name:`${e} (definition)`,stack:tl(()=>n.stack),parent:t}}))})},il=(e,...t)=>el(e.length,t.length===0?function(){return al(()=>e.apply(this,arguments))}:function(){let n=al(()=>e.apply(this,arguments));for(let e of t)n=e(n);return n}),al=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return Nc(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}if(i&&i._tag===`Failure`)return r.value;{let n=!0;return Lc(()=>n?(n=!1,fl(r.value,e=>ol(t,e))):Lc(()=>ol(e())))}}}catch(e){return Hc(e)}},ol=Cr({op:`Iterator`,single:!1,[Yn](e,t){let n=this[w][0];for(;;){let r=n.next(e);if(r.done)return Nc(r.value);if(!ml(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[Jn](e){return this[Yn](this[w][1],e)}}),sl=S(2,(e,t)=>{let n=Nc(t);return fl(e,e=>n)}),cl=e=>gl(e,E),ll=S(2,(e,t)=>fl(e,e=>tr(t)?t:Un(()=>t(e)))),ul=S(2,(e,t)=>fl(e,e=>sl(tr(t)?t:Un(()=>t(e)),e))),dl=e=>fl(e,e=>Sl),fl=S(2,(e,t)=>{let n=Object.create(pl);return n[w]=e,n[Yn]=t.length===1?t:e=>t(e),n}),pl=Sr({op:`OnSuccess`,[Jn](e){return e._stack.push(this),this[w]}}),ml=e=>Gn in e,hl=S(2,(e,t)=>ml(e)?e._tag===`Success`?t(e.value):e:fl(e,t)),gl=S(2,(e,t)=>fl(e,e=>Nc(Un(()=>t(e))))),_l=S(2,(e,t)=>ml(e)?Cl(e,t):gl(e,t)),vl=S(2,(e,t)=>ml(e)?wl(e,t):Kl(e,t)),yl=S(2,(e,t)=>ml(e)?Tl(e,t):ql(e,t)),bl=e=>e._tag===`Success`,xl=e=>e._tag===`Failure`?Mi(e.cause):Ni(e),Sl=Tr(void 0),Cl=S(2,(e,t)=>e._tag===`Success`?Tr(t(e.value)):e),wl=S(2,(e,t)=>{if(e._tag===`Success`)return e;let n=ec(e.cause);return Li(n)?e:kr(t(n.success))}),Tl=S(2,(e,t)=>{if(e._tag===`Success`)return Tr(t.onSuccess(e.value));let n=ec(e.cause);return Li(n)?e:kr(t.onFailure(n.success))}),El=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?Sl:Or(fr(t))},Dl=e=>jr(t=>Nc(po(t.context,e))),Ol=S(2,(e,t)=>jr(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),yu(e,()=>{n.setContext(r)}))})),kl=S(3,(e,t,n)=>Ol(e,e=>{let r=so(e,t),i=n(r);return r===i?e:ro(e,t,i)})),Al=()=>jl,jl=jr(e=>Nc(e.context)),Ml=e=>jr(t=>e(t.context)),Nl=S(2,(e,t)=>ml(e)?e:Ol(e,mo(t))),Pl=function(){return arguments.length===1?S(2,(e,t)=>Fl(e,arguments[0],t)):S(3,(e,t,n)=>Fl(e,t,n)).apply(this,arguments)},Fl=(e,t,n)=>Ol(e,ro(t,n)),Il=S(e=>tr(e[0]),(e,t)=>Ru({while:st,body:ot(t?.disableYield?e:fl(e,e=>zc)),step:dt})),Ll=S(2,(e,t)=>{let n=Object.create(Rl);return n[w]=e,n[Xn]=t.length===1?t:e=>t(e),n}),Rl=Sr({op:`OnFailure`,[Jn](e){return e._stack.push(this),this[w]}}),zl=S(3,(e,t,n)=>Ll(e,e=>{let r=t(e);return Li(r)?Pc(r.failure):Un(()=>n(r.success,e))})),Bl=S(2,(e,t)=>zl(e,ec,e=>t(e))),Vl=S(2,(e,t)=>zl(e,nc,t)),Hl=S(3,(e,t,n)=>Ll(e,e=>{let r=t(e);return Li(r)?Pc(e):ll(Un(()=>n(r.success,e)),Pc(e))})),Ul=S(2,(e,t)=>Hl(e,ec,e=>t(e))),Wl=S(e=>tr(e[0]),(e,t,n,r)=>Ll(e,e=>{let i=ec(e);if(Li(i))return Pc(i.failure);let a=t(i.success);return Li(a)?r?Un(()=>r(a.failure)):Pc(e):Un(()=>n(a.success))})),Gl=S(e=>tr(e[0]),(e,t,n)=>{let r;return Wl(e,e=>(r??=Object.keys(t),At(e,`_tag`)&&_t(e._tag)&&r.includes(e._tag)?Mi(e):Ni(e)),e=>Un(()=>t[e._tag](e)),n)}),Kl=S(2,(e,t)=>Bl(e,e=>Uc(()=>t(e)))),ql=S(2,(e,t)=>Ql(e,{onFailure:e=>Uc(()=>t.onFailure(e)),onSuccess:e=>Ic(()=>t.onSuccess(e))})),Jl=e=>Bl(e,Hc),Yl=e=>eu(e,{onFailure:Ni,onSuccess:Mi}),Xl=S(2,(e,t)=>{let n=Object.create(Zl);return n[w]=e,n[Yn]=t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),n[Xn]=t.onFailure.length===1?t.onFailure:e=>t.onFailure(e),n}),Zl=Sr({op:`OnSuccessAndFailure`,[Jn](e){return e._stack.push(this),this[w]}}),Ql=S(2,(e,t)=>Xl(e,{onFailure:e=>{let n=e.reasons.find(vr);return n?Un(()=>t.onFailure(n.error)):Pc(e)},onSuccess:t.onSuccess})),$l=S(2,(e,t)=>Ql(e,{onFailure:e=>Ic(()=>t.onFailure(e)),onSuccess:e=>Ic(()=>t.onSuccess(e))})),eu=S(2,(e,t)=>{if(ml(e)){if(e._tag===`Success`)return Tr(t.onSuccess(e.value));let n=ec(e.cause);return Li(n)?e:Tr(t.onFailure(n.success))}return $l(e,t)}),tu=e=>ml(e)?Tr(e):nu(e),nu=Cr({op:`Exit`,[Jn](e){return e._stack.push(this),this[w]},[Yn](e,t,n){return Nc(n??Tr(e))},[Xn](e,t,n){return Nc(n??Or(e))}}),ru=`~effect/Scope`,iu=`~effect/Scope/Closeable`,au=O(`effect/Scope`),ou=(e,t)=>Lc(()=>su(e,t)??Wc),su=(e,t)=>{if(e.state._tag===`Closed`)return;let n={_tag:`Closed`,exit:t};if(e.state._tag===`Empty`){e.state=n;return}let{finalizers:r}=e.state;if(e.state=n,r.size!==0)return r.size===1?r.values().next().value(t):lu(e,r,t)},cu=(e,t)=>bl(e)?t:Ll(t,t=>Pc(ac(e.cause,t))),lu=$c(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=Cc();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*tu(s(n))):i.push(Wu(o,s(n),!0,!0,`inherit`))}return i.length>0&&(r=yield*kc(i)),yield*El(r)}),uu=(e,t)=>{let n=hu(t);if(e.state._tag===`Closed`)return n.state=e.state,n;let r={};return pu(e,r,e=>ou(n,e)),pu(n,r,t=>Ic(()=>mu(e,r))),n},du=(e,t)=>Lc(()=>e.state._tag===`Closed`?t(e.state.exit):(pu(e,{},t),Wc)),fu=(e,t)=>du(e,ot(t)),pu=(e,t,n)=>{e.state._tag===`Empty`?e.state={_tag:`Open`,finalizers:new Map([[t,n]])}:e.state._tag===`Open`&&e.state.finalizers.set(t,n)},mu=(e,t)=>{e.state._tag===`Open`&&e.state.finalizers.delete(t)},hu=(e=`sequential`)=>({[iu]:iu,[ru]:ru,strategy:e,state:gu}),gu={_tag:`Empty`},_u=Pl(au),vu=e=>Lc(()=>{let t=hu();return bu(e(t),e=>Lc(()=>su(t,e)??Wc))}),yu=Cr({op:`OnExit`,single:!1,[Jn](e){return e._stack.push(this),this[w][0]},[Zn](e){e.interruptible&&this[w][2]!==!0&&(e._stack.push(Mu),e.interruptible=!1)},[Yn](e,t,n){n??=Tr(e);let r=this[w][1](n);return r?fl(r,e=>n):n},[Xn](e,t,n){n??=Or(e);let r=this[w][1](n);return r?fl(cu(n,r),e=>n):n}}),bu=S(2,yu),xu=S(2,(e,t)=>bu(e,e=>t)),Su=S(3,(e,t,n)=>bu(e,e=>{let r=t(e);return Li(r)?Wc:n(r.success,e)})),Cu=S(2,(e,t)=>Su(e,xl,t)),wu=S(3,(e,t,n)=>bu(e,e=>{if(e._tag!==`Failure`)return Wc;let r=t(e.cause);return Li(r)?Wc:n(r.success,e.cause)})),Tu=S(2,(e,t)=>wu(ic,t)(e)),Eu=(e,t,n)=>Iu(r=>fl(e,e=>yu(r(t(e)),t=>n(e,t),!0))),Du=S(2,(e,t)=>Ic(()=>{let n=Go(Do(t)),r=Number.isFinite(n),i=td(!1),a=0,o=!1,s,c=fl(i.await,()=>s);return[jr(t=>{let l=t.getRef(md),u=r?l.currentTimeMillisUnsafe():0;return o||u<a?s??c:(o=!0,i.closeUnsafe(),s=void 0,bu(e,e=>Ic(()=>{o=!1,a=l.currentTimeMillisUnsafe()+n,s=e,i.openUnsafe()})))}),Ic(()=>{a=0,i.closeUnsafe(),s=void 0})]})),Ou=S(2,(e,t)=>gl(Du(e,t),e=>e[0])),ku=e=>Ou(e,Io),Au=e=>jr(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Mu),e):e),ju=Cr({op:`SetInterruptible`,[Zn](e){if(e.interruptible=this[w],e._interruptedCause&&e.interruptible)return()=>Pc(e._interruptedCause)}}),Mu=ju(!0),Nu=ju(!1),Pu=e=>{if(e.interruptible=!0,e._stack.push(Nu),e._interruptedCause)return Pc(e._interruptedCause)},Fu=e=>jr(t=>t.interruptible?e:Pu(t)??e),Iu=e=>jr(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Mu),e(Fu)):e(C)),Lu=(e,t)=>Mt(e)?t?.mode===`result`?zu(e,Yl,t):zu(e,C,t):t?.discard?t.mode===`result`?zu(Object.values(e),Yl,t):zu(Object.values(e),C,t):Lc(()=>{let n={};return sl(zu(Object.entries(e),([e,r])=>gl(t?.mode===`result`?Yl(r):r,t=>{xn(n,e,t)}),{discard:!0,concurrency:t?.concurrency}),n)}),Ru=Cr({op:`While`,[Yn](e,t){return this[w].step(e),this[w].while()?(t._stack.push(this),this[w].body()):Sl},[Jn](e){return this[w].while()?(e._stack.push(this),this[w].body()):Sl}}),zu=S(e=>typeof e[1]==`function`,(e,t,n)=>Lc(()=>{let r=n?.concurrency??1,i=r===`unbounded`?1/0:Math.max(1,r);if(i===1)return Bu(e,t,n);let a=Xi(e),o=a.length;if(o===0)return n?.discard?Wc:Nc([]);let s=n?.discard?void 0:Array(o),c=Uu({f:t,out:s},a,{concurrency:i});return c?sl(c,s):Nc(s)})),Bu=(e,t,n)=>Lc(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return sl(Ru({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Vu=e=>{let t=e.onItem,n=e.step,r=(e,i,a,o)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!ml(c))return fl(tu(c),t=>n(e,s,t,a)??r(e,i,a+1,o)??Wc);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return(e,i,a)=>{let o=0,s=a?.end??i.length,c=a?.concurrency??1;if(c===1)return r(e,i,0,s);let l=a?.orderedStep===!0&&c>1,u=!1,d,f,p,m=!1,h,g,_=o,v=l?Array(s):void 0,y=e=>{let t=Ar(e);return h=t,u=!0,m=!0,f&&f.size>0?fl(Au(Mc(Array.from(f))),()=>t):t},b=(t,r,a)=>{if(!l)return n(e,t,r,a);if(h)return h;for(v[a]=r;_<s;){let t=v[_];if(t===void 0)return;v[_]=void 0;let r=_++,a=n(e,i[r],t,r);if(a)return a}},x=()=>{let n=!1;for(;!h&&o<s;o++){let r=i[o],a=g??t(e,r,o);if(ml(a)){if(h=b(r,a,o),h)break}else if(d){g=void 0;let e=Wu(d,a,!0,!0,`inherit`);if(e._exit){if(h=b(r,e._exit,o),h)break;continue}f.add(e);let t=o;if(e.addObserver(i=>{f.delete(e);try{if(h){if(!m&&i._tag===`Failure`)for(let e of i.cause.reasons)if(e._tag===`Interrupt`)continue;else h._tag===`Failure`?h.cause.reasons.push(e):h=Or(fr([e]))}else{let e=b(r,i,t);e&&(h=e._tag===`Failure`?Or(fr(e.cause.reasons.slice())):e,x())}if(n){let e=x();e&&p(e)}else u&&f.size===0&&p(h??Wc)}catch(e){p(y(e))}}),f.size<c)continue;n=!0,o++;return}else return Xc(e=>{d=Cc(),f=new Set,g=a,p=e;let t;try{t=x()}catch(t){return e(y(t))}return t?e(t):Lc(()=>(h=Sl,m=!0,f?Mc(f):Wc))})}if(u=!0,h){if(f&&f.size>0){let e=Dc(d);f.forEach(t=>t.interruptUnsafe(d.id,e));return}if(p||h._tag===`Failure`)return h}else if(p){if(f)f.size===0&&p(Wc);else return Sl}};return x()}},Hu=()=>Vu,Uu=Vu({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),Wu=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new wc(a.context,o);return n?s.evaluate(t):a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),!r&&!s._exit&&(a.children().add(s),s.addObserver(()=>a._children.delete(s))),s},Gu=e=>(t,n)=>{let r=new wc(n?.scheduler?ro(e,Qo,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Ku=Gu(eo()),qu=e=>{let t=Gu(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},Ju=(e=>{let t=qu(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw cc(e.cause);return e.value})})(eo()),Yu=e=>{let t=Gu(e);return e=>{if(ml(e))return e;let n=new ns(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??Ar(new Ed(r))}},Xu=Yu(eo()),Zu=(e=>{let t=Yu(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw cc(n.cause);return n.value}})(eo()),Qu=Nc(!0),$u=Nc(!1),ed=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return Qu;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],Qu}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](Sl)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](Sl)}open=jr(e=>this._isOpen?$u:(this._isOpen=!0,this.scheduleUnsafe(e)));release=jr(e=>this._isOpen?$u:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=Xc(e=>this._isOpen?e(Wc):(this.waiters.push(e),Ic(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=Ic(()=>this.closeUnsafe());whenOpen=e=>fl(this.await,()=>e);isOpen(){return this._isOpen}},td=e=>new ed(e??!1),nd=BigInt(0),rd={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:nd,endTime:nd,exit:Sl},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},id=e=>Object.assign(Object.create(rd),e),ad=e=>e?co(e.annotations,ks)?e._tag===`Span`?ad(Ci(e.parent)):T():E(e):T(),od=(e,t,n)=>{let r=!e.getRef(Ls)||n?.annotations&&co(n.annotations,ks),i=n?.parent===void 0?n?.root?T():ad(e.currentSpan):E(n.parent),a;if(r)a=id({name:t,parent:i,annotations:ro(n?.annotations??eo(),ks,!0)});else{let r=e.getRef(Ns),o=e.getRef(md),s=e.getRef(Rs),c=e.getRef(zs),l=e.getRef(Bs),u=n?.level??e.getRef(As),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??eo(),links:d,startTime:s?o.currentTimeNanosUnsafe():BigInt(0),kind:n?.kind??`internal`,root:n?.root??hi(i),sampled:n?.sampled??(D(i)&&i.value.sampled===!1?!1:!Ad(e.getRef(js),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},sd=(e,t)=>(t=typeof t==`function`?t:ut,kl(Is,n=>({name:e,stack:t,parent:n}))),cd=(e,t,n,r)=>Ic(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():nd,t)}),ld=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return jr(t=>{let i=od(t,e,n),a=t.getRef(md),o=t.getRef(Rs);return bu(Un(()=>r(i)),e=>cd(i,e,a,o))})},ud=Pl(Ds),dd=function(){let e=tr(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=C;return t._tag===`Span`&&(n=Js(n),r=sd(t.name,n?.captureStackTrace)),e?ud(r(arguments[0]),t):e=>ud(r(e),t)},fd=function(){let e=typeof arguments[0]!=`string`,t=e?arguments[1]:arguments[0],n=Js(arguments[2]);if(e){let e=arguments[0];return ld(t,arguments[2],t=>dd(e,t,n))}let r=typeof arguments[1]==`function`?arguments[1]:void 0,i=r?void 0:arguments[1];return(e,...a)=>ld(t,r?r(...a):i,t=>dd(e,t,n))},pd=(...e)=>jr(t=>{let n=t.currentSpanLocal;if(n){if(e.length===1)for(let[t,r]of Object.entries(e[0]))n.attribute(t,r);else n.attribute(e[0],e[1])}return Wc}),md=go(`effect/Clock`,{defaultValue:()=>new gd}),hd=2**31-1,gd=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=Ic(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return yd()}currentTimeNanos=Ic(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return vd()}monotonicTimeNanos=Ic(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(Go(e))}sleepMillis(e){return e<=0?zc:Number.isFinite(e)?Xc(t=>{let n=e>hd?this.sleepMillis(e-hd):Wc,r=setTimeout(()=>t(n),Math.min(e,hd));return Ic(()=>clearTimeout(r))}):Zc}},_d=BigInt(1e6),vd=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*_d;return e>t&&(t=e),t}}(),yd=function(){let e=BigInt(1e9),t;return()=>{let n=vd(),r=BigInt(Date.now())*_d;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),bd=e=>jr(t=>e(t.getRef(md))),xd=e=>bd(t=>t.sleep(Do(e))),Sd=bd(e=>e.currentTimeMillis);Pr(`TimeoutError`);var Cd=`~effect/Cause/IllegalArgumentError`,wd=class extends Pr(`IllegalArgumentError`){[Cd]=Cd;constructor(e){super({message:e})}};Pr(`ExceededCapacityError`);var Td=`~effect/Cause/AsyncFiberError`,Ed=class extends Pr(`AsyncFiberError`){[Td]=Td;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Dd=`~effect/Cause/UnknownError`,Od=class extends Pr(`UnknownError`){[Dd]=Dd;constructor(e,t){super({message:t,cause:e})}},kd=go(`effect/Console/CurrentConsole`,{defaultValue:()=>globalThis.console}),Ad=di(li(ci,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),jd=go(`effect/Loggers/CurrentLoggers`,{defaultValue:()=>new Set([Bd,Vd])}),Md=go(`effect/Logger/LogToStderr`,{defaultValue:ct}),Nd={"~effect/Logger":{_Message:C,_Output:C},pipe(){return rt(this,arguments)}},Pd=e=>{let t=Object.create(Nd);return t.log=e,t},Fd=e=>e.replace(/[\s="]/g,`_`),Id=(e,t)=>`${Fd(e[0])}=${t-e[1]}ms`,Ld=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];ar(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?fr(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=pr),jr(r=>{let i=e??r.currentLogLevel;if(Ad(r.minimumLogLevel,i))return Wc;let a=r.getRef(md),o=r.getRef(jd);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return Wc})},Rd={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Rd.gray,Rd.blue,Rd.green,Rd.yellow,Rd.red,Rd.bgBrightRed,Rd.black;var zd=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`)}`,Bd=Pd(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(_c(e));let o=t.getTime(),s=n.getRef(Ws),c=``;for(let e of s)c+=` ${Id(e,o)}`;let l=n.getRef(Vs);Object.keys(l).length>0&&a.push(l);let u=n.getRef(kd);(n.getRef(Md)?u.error:u.log)(`[${zd(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),Vd=Pd(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(md),a=t.getRef(Vs),o=t.currentSpan;if(o===void 0||o._tag===`ExternalSpan`)return;let s={};for(let[e,t]of Object.entries(a))xn(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=_c(e)),o.event(zn(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)}),Hd=ar,Ud=or,Wd=vr,Gd=fr,Kd=pr,qd=mr,Jd=e=>new dr(e),Yd=e=>new hr(e),Xd=Qs,Zd=oc,Qd=ac,$d=cc,ef=tc,tf=rc,nf=_c,rf=Ir,af=Br,of=wd;O()(`effect/Cause/StackTrace`),O()(`effect/Cause/InterruptorStackTrace`);var sf=nr,cf=Tr,lf=Or,uf=kr,df=Sl,ff=bl,pf={"~effect/Deferred":{_A:C,_E:C},pipe(){return rt(this,arguments)}},mf=()=>{let e=Object.create(pf);return e.resumes=void 0,e.effect=void 0,e},hf=()=>Ic(()=>mf()),gf=e=>Xc(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),Ic(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),_f=S(2,(e,t)=>Ic(()=>xf(e,t))),vf=e=>Ic(()=>yf(e)),yf=e=>e.effect!==void 0,bf=S(2,(e,t)=>_f(e,Tr(t))),xf=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},Sf=au,Cf=hu,wf=_u,Tf=du,Ef=fu,Df=uu,Of=ou,kf=`~effect/Layer`,Af=`~effect/Layer/MemoMap`,jf=(e,t)=>(e.observers++,ll(du(t,t=>e.finalizer(t)),e.effect)),Mf={[kf]:{_ROut:C,_E:C,_RIn:C},pipe(){return rt(this,arguments)}},Nf=e=>{let t=Object.create(Mf);return t.build=e,t},Pf=e=>Nf((t,n)=>{let r=Df(n);return bu(e(t,r),e=>e._tag===`Failure`?Of(r,e):Wc)}),Ff=e=>{let t=Pf((n,r)=>n.getOrElseMemoize(t,r,e));return t},If=(e,t,n,r)=>{let i=Cf(),a=mf(),o={observers:1,effect:gf(a),finalizer:n=>Lc(()=>(o.observers--,o.observers===0?(e.map.delete(t),Of(i,n)):Wc))};return e.map.set(t,o),du(n,o.finalizer).pipe(fl(()=>r(e,i)),bu(e=>(o.effect=e,_f(a,e))))},Lf=class{get[Af](){return Af}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?jf(n,t):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return Lc(()=>this.get(e,t)||If(this,e,t,n))}},Rf=()=>new Lf,zf=e=>new Lf(e),Bf=class e extends O()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=ao(t,e);return n?zf(n):Rf()}},Vf=S(3,(e,t,n)=>Pl(gl(e.build(t,n),ro(Bf,t)),Bf,t)),Hf=S(2,(e,t)=>jr(n=>Vf(e,Bf.forkOrCreate(n.context),t))),Uf=function(){return arguments.length===1?e=>Wf(no(arguments[0],e)):Wf(no(arguments[0],arguments[1]))},Wf=e=>Nf(ot(Nc(e))),Gf=function(){return arguments.length===1?e=>Kf(arguments[0],e):Kf(arguments[0],arguments[1])},Kf=(e,t)=>qf(gl(t,t=>no(e,t))),qf=e=>Ff((t,n)=>wf(e,n)),Jf=e=>qf(sl(e,eo())),Yf=(e,t,n)=>{let r=Df(n,`parallel`);return zu(e,e=>e.build(t,Df(r,`sequential`)),{concurrency:e.length}).pipe(gl(e=>ho(...e)))},Xf=(...e)=>Pf((t,n)=>Yf(e,t,n)),Zf=(e,t,n)=>Pf((r,i)=>fl(Array.isArray(t)?Yf(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(Nl(t),gl(e=>n(e,t))))),Qf=S(2,(e,t)=>Zf(e,t,C)),$f=S(2,(e,t)=>Zf(e,t,(e,t)=>mo(t,e))),ep=Sd,tp=`~effect/time/DateTime`,np=`~effect/time/DateTime/TimeZone`,rp={[tp]:tp,pipe(){return rt(this,arguments)},[Ln](){return this.toString()},toJSON(){return Rp(this).toJSON()}},ip={...rp,_tag:`Utc`,[Nt](){return zt(this.epochMilliseconds)},[Zt](e){return up(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Rp(this).toJSON()})`}},ap={...rp,_tag:`Zoned`,[Nt](){return It(zt(this.epochMilliseconds))(Pt(this.zone))},[Zt](e){return up(e)&&e._tag===`Zoned`&&this.epochMilliseconds===e.epochMilliseconds&&Qt(this.zone,e.zone)},toString(){return`DateTime.Zoned(${im(this)})`}},op={[np]:np,[Ln](){return this.toString()}},sp={...op,_tag:`Named`,[Nt](){return Bt(`Named:${this.id}`)},[Zt](e){return fp(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},cp={...op,_tag:`Offset`,[Nt](){return Bt(`Offset:${this.offset}`)},[Zt](e){return fp(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${Vp(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},lp=(e,t,n)=>{let r=Object.create(ap);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},up=e=>At(e,tp),dp=e=>up(e[0]),fp=e=>At(e,np),pp=e=>fp(e)&&e._tag===`Named`,mp=e=>e._tag===`Utc`,hp=e=>e._tag===`Zoned`,gp=hn((e,t)=>e.epochMilliseconds===t.epochMilliseconds),_p=si((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:+(e.epochMilliseconds>t.epochMilliseconds)),vp=e=>{let t=Object.create(ip);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},yp=e=>{let t=e.getTime();if(Number.isNaN(t))throw new of(`Invalid date`);return vp(t)},bp=e=>{if(up(e))return e;if(e instanceof Date)return yp(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return yp(new Date(e.epochMilliseconds));let t=new Date(0);return qp(t,e),yp(t)}return typeof e==`string`&&!xp(e)?yp(new Date(e+`Z`)):yp(new Date(e))},xp=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),Sp=-864e13+432e5,Cp=864e13-504e5,wp=(e,t)=>{let n=t?.timeZone;if(n===void 0&&up(e)&&hp(e))return e;let r=bp(e);if(r.epochMilliseconds<Sp||r.epochMilliseconds>Cp)throw RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);n===void 0&&typeof e==`object`&&`timeZoneId`in e&&(n=e.timeZoneId);let i;if(n===void 0)i=Np(new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1e3);else if(fp(n))i=n;else if(typeof n==`number`)i=Np(n);else{let e=Ip(n);if(hi(e))throw new of(`Invalid time zone: ${n}`);i=e.value}return t?.adjustForTimeZone===!0?Yp(r.epochMilliseconds,i,t?.disambiguation??`compatible`):lp(r.epochMilliseconds,i,r.partsUtc)},Tp=wi(bp),Ep=gl(ep,vp),Dp=e=>vp(e.epochMilliseconds),Op=S(dp,(e,t,n)=>n?.adjustForTimeZone===!0?Yp(e.epochMilliseconds,t,n?.disambiguation??`compatible`):lp(e.epochMilliseconds,t,e.partsUtc)),kp=new Map,Ap={day:`numeric`,month:`numeric`,year:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},jp=e=>{let t=e.resolvedOptions().timeZone;if(kp.has(t))return kp.get(t);let n=Object.create(sp);return n.id=t,n.format=e,kp.set(t,n),n},Mp=e=>{if(kp.has(e))return kp.get(e);try{return jp(new Intl.DateTimeFormat(`en-US`,{...Ap,timeZone:e}))}catch{throw new of(`Invalid time zone: ${e}`)}},Np=e=>{let t=Object.create(cp);return t.offset=e,t},Pp=wi(Mp),Fp=/^(?:GMT|[+-])/,Ip=e=>{if(Fp.test(e)){let t=Zp(e);return t===null?T():E(Np(t))}return Pp(e)},Lp=S(dp,(e,t,n)=>Ti(Pp(t),t=>Op(e,t,n))),Rp=e=>new Date(e.epochMilliseconds),zp=e=>{if(e._tag===`Utc`)return new Date(e.epochMilliseconds);if(e.zone._tag===`Offset`)return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>e.type!==`literal`),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMilliseconds=n.getTime(),n},Bp=e=>zp(e).getTime()-Up(e),Vp=e=>{let t=Math.abs(e),n=Math.floor(t/36e5),r=Math.round(t%36e5/6e4);return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},Hp=e=>Vp(Bp(e)),Up=e=>e.epochMilliseconds,Wp=e=>({millisecond:e.getUTCMilliseconds(),second:e.getUTCSeconds(),minute:e.getUTCMinutes(),hour:e.getUTCHours(),day:e.getUTCDate(),weekDay:e.getUTCDay(),month:e.getUTCMonth()+1,year:e.getUTCFullYear()}),Gp=e=>e._tag===`Utc`?Kp(e):(e.partsAdjusted===void 0&&(e.partsAdjusted=em(e,Wp)),e.partsAdjusted),Kp=e=>(e.partsUtc===void 0&&(e.partsUtc=tm(e,Wp)),e.partsUtc),qp=(e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)},Jp=864e5,Yp=(e,t,n)=>{if(t._tag===`Offset`)return lp(e-t.offset,t);let r=Qp(e-Jp,e,t),i=Qp(e+Jp,e,t);if(r===i)return lp(e-r,t);let a=r<i,o=r-i;if(a){if(Qp(e-i,e,t)===i)return lp(e-i,t);let a=lp(e-r,t);if(e!==zp(a).getTime())switch(n){case`reject`:{let n=new Date(e).toISOString();throw RangeError(`Gap time: ${n} does not exist in time zone ${t.id}`)}case`earlier`:return lp(e-i,t);case`compatible`:case`later`:return a}return a}if(Qp(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||Qp(e-r+o,e+o,t)===r)return lp(e-r,t);if(n===`reject`){let n=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${n} occurs twice in time zone ${t.id}`)}}return lp(e-i,t)},Xp=/([+-])(\d{2}):(\d{2})$/,Zp=e=>{let t=Xp.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},Qp=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=Zp(r);return i===null?Bp(lp(t,n)):i},$p=S(dp,(e,t,n)=>{if(e._tag===`Utc`){let n=Rp(e);return t(n),vp(n.getTime())}let r=zp(e),i=new Date(r.getTime());return t(i),Yp(i.getTime(),e.zone,n?.disambiguation??`compatible`)}),em=S(2,(e,t)=>t(zp(e))),tm=S(2,(e,t)=>t(Rp(e))),nm=e=>Rp(e).toISOString(),rm=e=>{let t=zp(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${Hp(e)}`},im=e=>e.zone._tag===`Offset`?rm(e):`${rm(e)}[${e.zone.id}]`;globalThis.Number;var am=ci;globalThis.String;var om=e=>e.toLowerCase(),sm=e=>e.length>0,cm=`~effect/time/Cron`;function lm(e){return{tz:e.tz,and:e.and,seconds:Xi(e.seconds),minutes:Xi(e.minutes),hours:Xi(e.hours),days:Xi(e.days),months:Xi(e.months),weekdays:Xi(e.weekdays)}}var um={[cm]:cm,[Zt](e){return dm(e)&&km(this,e)},[Nt](){return ft(Pt(this.tz),It(Pt(this.and)),It(Wt(Xi(this.seconds))),It(Wt(Xi(this.minutes))),It(Wt(Xi(this.hours))),It(Wt(Xi(this.days))),It(Wt(Xi(this.months))),It(Wt(Xi(this.weekdays))))},toObject(){return lm(this)},toString(){return`Cron(${An(lm(this))})`},toJSON(){let e=lm(this);return e._id=`Cron`,e},[Ln](){return this.toJSON()},pipe(){return rt(this,arguments)}},dm=e=>At(e,cm),fm=e=>{let t=Object.create(um);t.seconds=mm.seconds(e.seconds??[0]),t.minutes=mm.minutes(e.minutes),t.hours=mm.hours(e.hours),t.days=mm.days(e.days),t.months=mm.months(e.months),t.weekdays=mm.weekdays(e.weekdays),t.and=e.and===!0,t.tz=bi(e.tz);let n=Array.from(t.seconds),r=Array.from(t.minutes),i=Array.from(t.hours),a=Array.from(t.days),o=Array.from(t.months),s=Array.from(t.weekdays);return t.first={second:n[0]??0,minute:r[0]??0,hour:i[0]??0,day:a[0]??1,month:(o[0]??1)-1,weekday:s[0]??0},t.last={second:n[n.length-1]??59,minute:r[r.length-1]??59,hour:i[i.length-1]??23,day:a[a.length-1]??31,month:(o[o.length-1]??12)-1,weekday:s[s.length-1]??6},t.next={second:gm.next.second(n),minute:gm.next.minute(r),hour:gm.next.hour(i),day:gm.next.day(a),month:gm.next.month(o),weekday:gm.next.weekday(s)},t.prev={second:gm.prev.second(n),minute:gm.prev.minute(r),hour:gm.prev.hour(i),day:gm.prev.day(a),month:gm.prev.month(o),weekday:gm.prev.weekday(s)},t},pm=(e,t,n,r=e=>e)=>i=>{let a=[];for(let o of i){if(!Number.isInteger(o)||o<t||o>n)throw RangeError(`${e} must contain only integers between ${t} and ${n}`);a.push(r(o))}return new Set(aa(a,am))},mm={seconds:pm(`seconds`,0,59),minutes:pm(`minutes`,0,59),hours:pm(`hours`,0,23),days:pm(`days`,1,31),months:pm(`months`,1,12),weekdays:pm(`weekdays`,0,7,e=>e===7?0:e)},hm=(e,t)=>n=>{let r=Array(e).fill(void 0);if(n.length===0)return r;let i;if(t===`next`){let t=n.length-1;for(let a=e-1;a>=0;a--){for(;t>=0&&n[t]>=a;)i=n[t--];r[a]=i}}else{let t=0;for(let a=0;a<e;a++){for(;t<n.length&&n[t]<=a;)i=n[t++];r[a]=i}}return r},gm={prev:{second:hm(60,`prev`),minute:hm(60,`prev`),hour:hm(24,`prev`),day:hm(32,`prev`),month:hm(13,`prev`),weekday:hm(7,`prev`)},next:{second:hm(60,`next`),minute:hm(60,`next`),hour:hm(24,`next`),day:hm(32,`next`),month:hm(13,`next`),weekday:hm(7,`next`)}},_m=`~effect/time/Cron/CronParseError`,vm=class extends cs(`CronParseError`){[_m]=_m},ym=(e,t)=>{let n=e.trim().split(/\s+/).filter(sm);if(n.length!==5&&n.length!==6)return Ni(new vm({message:`Invalid number of segments in cron expression`,input:e}));n.length===5&&n.unshift(`0`);let[r,i,a,o,s,c]=n;return Hi({tz:t===void 0||fp(t)?Mi(t):Pi(Ip(t),()=>new vm({message:`Invalid time zone in cron expression`,input:t})),seconds:Im(r,Am),minutes:Im(i,jm),hours:Im(a,Mm),days:Im(o,Nm),months:Im(s,Pm),weekdays:Im(c,Fm)}).pipe(zi(({tz:e,seconds:t,minutes:n,hours:r,days:i,months:a,weekdays:o})=>fm({tz:e,seconds:t.values,minutes:n.values,hours:r.values,days:i.values,months:a.values,weekdays:o.values,and:(i.wildcard||o.wildcard)&&i.values.size!==0&&o.values.size!==0})))},bm=(e,t)=>Vi(ym(e,t)),xm=(e,t)=>{let n=wp(t,{timeZone:Ci(e.tz)}).pipe(Gp);return e.seconds.size!==0&&!e.seconds.has(n.second)||e.minutes.size!==0&&!e.minutes.has(n.minute)||e.hours.size!==0&&!e.hours.has(n.hour)||e.months.size!==0&&!e.months.has(n.month)?!1:e.days.size===0&&e.weekdays.size===0?!0:e.and?(e.days.size===0||e.days.has(n.day))&&(e.weekdays.size===0||e.weekdays.has(n.weekDay)):e.weekdays.size===0?e.days.has(n.day):e.days.size===0?e.weekdays.has(n.weekDay):e.days.has(n.day)||e.weekdays.has(n.weekDay)},Sm=e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+1,0)).getUTCDate(),Cm=(e,t)=>Tm(e,t,`next`),wm=(e,t)=>Tm(e,t,`prev`),Tm=(e,t,n)=>{let r=Ci(e.tz),i=wp(t??new Date,{timeZone:r}),a=n===`prev`,o=a?-1:1,s=e[n],c=a?e.last:e.first,l=a?(e,t)=>e<t:(e,t)=>e>t,u=r!==void 0&&pp(r)&&r.id===`UTC`?dt:e=>{let t=wp(e,{timeZone:i.zone,adjustForTimeZone:!0,disambiguation:a?`later`:void 0}).pipe(zp),n=e.getTime()-t.getTime();(a?n!==0:n>0)&&e.setTime(a?t.getTime():e.getTime()+n)};return Rp($p(i,t=>{t.setUTCSeconds(t.getUTCSeconds()+o,0);for(let n=0;n<1e4;n++){if(e.seconds.size!==0){let e=t.getUTCSeconds(),n=s.second[e];if(n===void 0){t.setUTCMinutes(t.getUTCMinutes()+o,c.second),u(t);continue}if(l(n,e)){t.setUTCSeconds(n),u(t);continue}}if(e.minutes.size!==0){let e=t.getUTCMinutes(),n=s.minute[e];if(n===void 0){t.setUTCHours(t.getUTCHours()+o,c.minute,c.second),u(t);continue}if(l(n,e)){t.setUTCMinutes(n,c.second),u(t);continue}}if(e.hours.size!==0){let e=t.getUTCHours(),n=s.hour[e];if(n===void 0){t.setUTCDate(t.getUTCDate()+o),t.setUTCHours(c.hour,c.minute,c.second),u(t);continue}if(l(n,e)){t.setUTCHours(n,c.minute,c.second),u(t);continue}}if(e.weekdays.size!==0||e.days.size!==0){if(e.and){let n=e.days.size===0||e.days.has(t.getUTCDate()),r=e.weekdays.size===0||e.weekdays.has(t.getUTCDay());if(!n||!r){t.setUTCDate(t.getUTCDate()+o),t.setUTCHours(c.hour,c.minute,c.second),u(t);continue}}else{let n=a?-1/0:1/0,r=a?-1/0:1/0;if(e.weekdays.size!==0){let e=t.getUTCDay(),r=s.weekday[e];n=r===void 0?a?c.weekday-7-e:7-e+c.weekday:r-e}if(e.days.size!==0&&n!==0){let e=t.getUTCDate(),n=s.day[e];if(n===void 0){if(a){let e=new Date(t);e.setUTCDate(0);let n=s.day[e.getUTCDate()];if(n===void 0&&(e.setUTCDate(0),n=s.day[e.getUTCDate()]),n===void 0)throw Error(`Unable to find cron date`);e.setUTCDate(n),r=(e.getTime()-t.getTime())/864e5}else r=Sm(t)-e+c.day}else r=!a&&n>Sm(t)?Sm(t)-e+c.day:n-e}let i=a?Math.max(n,r):Math.min(n,r);if(i!==0){t.setUTCDate(t.getUTCDate()+i),t.setUTCHours(c.hour,c.minute,c.second),u(t);continue}}}if(e.months.size!==0){let n=t.getUTCMonth()+1,r=s.month[n],i=n=>{let r=Sm(new Date(Date.UTC(t.getUTCFullYear(),n+1,0)));return e.days.size!==0&&e.weekdays.size===0?a?s.day[r]??r:c.day:a?r:1};if(r===void 0){t.setUTCFullYear(t.getUTCFullYear()+o),t.setUTCMonth(c.month,i(c.month)),t.setUTCHours(c.hour,c.minute,c.second),u(t);continue}if(l(r,n)){let e=r-1;t.setUTCMonth(e,i(e)),t.setUTCHours(c.hour,c.minute,c.second),u(t);continue}}return}throw Error(`Unable to find cron date`)}))},Em=hn((e,t)=>Qt(e.tz,t.tz)&&e.and===t.and&&Om(e.seconds,t.seconds)&&Om(e.minutes,t.minutes)&&Om(e.hours,t.hours)&&Om(e.days,t.days)&&Om(e.months,t.months)&&Om(e.weekdays,t.weekdays)),Dm=yn(_n()),Om=(e,t)=>Dm(Xi(e),Xi(t)),km=S(2,(e,t)=>Em(e,t)),Am={min:0,max:59},jm={min:0,max:59},Mm={min:0,max:23},Nm={min:1,max:31},Pm={min:1,max:12,aliases:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12}},Fm={min:0,max:7,normalize:e=>e===7?0:e,aliases:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}},Im=(e,t)=>{let n=new Set,r=e.split(`,`),i=Lm(r[0]),a=i[0]===`*`,o=t.normalize??(e=>e),s=a&&(i[1]===void 0||i[1]===1)?dt:e=>{n.add(o(e))};for(let n=0;n<r.length;n++){let a=r[n],[o,c]=n===0?i:Lm(a);if(c!==void 0){if(!Number.isInteger(c))return Ni(new vm({message:`Expected step value to be a positive integer`,input:e}));if(c<1)return Ni(new vm({message:`Expected step value to be greater than 0`,input:e}));if(c>t.max)return Ni(new vm({message:`Expected step value to be less than or equal to ${t.max}`,input:e}))}if(o===`*`){if(n===0&&(c===void 0||c===1))continue;for(let e=t.min;e<=t.max;e+=c??1)s(e)}else{let[n,r]=Rm(o,t.aliases);if(!Number.isInteger(n))return Ni(new vm({message:`Expected a positive integer`,input:e}));if(n<t.min||n>t.max)return Ni(new vm({message:`Expected a value between ${t.min} and ${t.max}`,input:e}));if(r===void 0)for(let e=n;e<=(c===void 0?n:t.max);e+=c??1)s(e);else{if(!Number.isInteger(r))return Ni(new vm({message:`Expected a positive integer`,input:e}));if(r<t.min||r>t.max)return Ni(new vm({message:`Expected a value between ${t.min} and ${t.max}`,input:e}));if(n>r)return Ni(new vm({message:`Invalid value range`,input:e}));for(let e=n;e<=r;e+=c??1)s(e)}}}return Mi({values:n,wildcard:a})},Lm=e=>{let t=e.indexOf(`/`);if(t!==-1){let n=e.slice(t+1);return[e.slice(0,t),Bm.test(n)?Number(n):NaN]}return[e,void 0]},Rm=(e,t)=>{let n=e.indexOf(`-`);return n===-1?[zm(e,t),void 0]:[zm(e.slice(0,n),t),zm(e.slice(n+1),t)]};function zm(e,t){return t?.[om(e)]??(Bm.test(e)?Number(e):NaN)}var Bm=/^\d+$/,Vm=S(2,(e,t)=>zl(e,Wm,e=>t(e))),Hm=e=>e._tag===`Fail`&&rf(e.error),Um=e=>{let t,n=!1;for(let r of e.reasons)Hm(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Ni(e):n?Ni(Gd(e.reasons.filter(e=>!Hm(e)))):Mi(t)},Wm=e=>{let t=Um(e);return Li(t)?t:Mi(t.success.value)},Gm=e=>{let t=Um(e);return Li(t)?lf(t.failure):cf(t.success.value)},Km=(e,t,n)=>vu(r=>fl(n?.local?Vf(t,Rf(),r):Hf(t,r),t=>Nl(e,t))),qm=S(e=>tr(e[0]),(e,t,n)=>Qa(t)?Nl(e,t):Km(e,Array.isArray(t)?Xf(...t):t,n)),Jm=tr,Ym=Lu,Xm=zu,Zm=Kc,Qm=qc,k=Nc,$m=Bc,eh=Lc,th=Ic,nh=Wc,rh=Xc,ih=Zc,A=Qc,j=Fc,ah=Pc,oh=Vc,sh=Hc,ch=Gc,lh=zc,uh=jr,dh=Rc,M=fl,fh=ll,ph=ul,mh=Yl,hh=tu,gh=gl,_h=sl,vh=dl,yh=Bl,bh=Gl,xh=Ll,Sh=Vl,Ch=Kl,wh=Jl,Th=Ul,Eh=xd,Dh=$l,Oh=Xl,kh=Al,Ah=Ml,jh=qm,Mh=Nl,Nh=Dl,Ph=Ol,Fh=Pl,Ih=Eu,Lh=xu,Rh=Cu,zh=bu,Bh=ku,Vh=Fu,Hh=Tu,Uh=Iu,Wh=Il,Gh=pd,Kh=ld,qh=fd,Jh=dd,Yh=Ku,Xh=Ju,Zh=Zu,Qh=Xu,$h=$c,N=nl,eg=Ld(`Warn`),tg=Ld(`Error`),ng=Ld(`Info`),rg=Ld(`Debug`);O()(`effect/Effect/Transaction`);var ig=_l,ag=vl,og=yl,sg=hl,cg=il;function lg(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function ug(e){return t=>lg(t)?.[e]}var dg=`~structural`,fg=`~sentinels`,pg=`~constructor`,mg=ug(`brands`),hg=pt(e=>{let t=lg(e)?.identifier;return typeof t==`string`?t:e.getExpected(hg)}),gg=Symbol(),_g=cf,vg=_g(gg),yg=_g(gg),bg=e=>e===gg?T():E(e),xg=e=>e._tag===`None`?vg:_g(e.value),Sg=`~effect/SchemaIssue/Issue`;function Cg(e){return At(e,Sg)&&e[Sg]===Sg}function wg(e){return Object.hasOwn(e,`input`)}var Tg=class{[Sg]=Sg;constructor(e,t){t?.reportInput===!0&&e!==gg&&(this.input=e)}},Eg=class extends Tg{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},Dg=class extends Tg{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},Og=class extends Tg{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},kg=class extends Tg{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},Ag=class extends Tg{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},jg=class extends Tg{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Mg=class extends Tg{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Ng=class extends Tg{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function Pg(e,t,n,r,i){return new jg(e,[new Og([t],n)],r,i)}var Fg=class extends Tg{_tag=`Forbidden`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},Ig=class extends Tg{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Lg=class extends Tg{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function Rg(e,t,n){if(Cg(e))return e;if(typeof e==`string`)return new Ng({message:e},t,n);let r=typeof e.issue==`string`?new Ng({message:e.issue},t,n):e.issue;return new Og(e.path,r)}function zg(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new Ng(void 0,t,n):Rg(e,t,n)}function Bg(e,t,n,r){return Array.isArray(t)?na(t)?t.length===1?Rg(t[0],n,r):new jg(e,ha(t,e=>Rg(e,n,r)),n,r):void 0:zg(t,n,r)}var Vg=e=>{let t=Qg(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return Kg(hg(e.ast),e);case`InvalidValue`:{let t=Gg(e);if(t!==void 0)return Kg(t,e);let n=Wg(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=Wg(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=Wg(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},Hg=e=>Qg(e.issue)??Qg(e);function Ug(e){return t=>({issues:qg(t,[],e?.leafHook??Vg,e?.checkHook??Hg)})}function Wg(e){return wg(e)?An(e.input):void 0}function Gg(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function Kg(e,t){let n=Wg(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function qg(e,t,n,r){switch(e._tag){case`Filter`:{let i=r(e);if(i!==void 0)return[{path:t,message:i}];if(e.issue._tag!==`InvalidValue`)return qg(e.issue,t,n,r);let a=Gg(e.issue);return[{path:t,message:a===void 0?Kg(Jg(e.filter),e):Kg(a,e.issue)}]}case`Encoding`:return qg(e.issue,t,n,r);case`Pointer`:return qg(e.issue,[...t,...e.path],n,r);case`Composite`:return e.issues.flatMap(e=>qg(e,t,n,r));case`AnyOf`:return e.issues.length===0?[{path:t,message:Qg(e)??Kg(hg(e.ast),e)}]:e.issues.flatMap(e=>qg(e,t,n,r));default:return[{path:t,message:n(e)}]}}function Jg(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>Jg(e)).join(` & `)}}function Yg(){return e=>Zg(e,``)}var Xg=Yg();function Zg(e,t){let n;switch(e._tag){case`Filter`:{let r=Hg(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return Zg(e.issue,t);let r=Gg(e.issue);n=r===void 0?Kg(Jg(e.filter),e):Kg(r,e.issue)}break}case`Encoding`:return Zg(e.issue,t);case`Pointer`:return Zg(e.issue,t+Nn(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>Zg(e,t)).join(`
|
|
14
|
-
`);n=Qg(e)??Kg(hg(e.ast),e);break;default:n=Vg(e)}return t?`${n}\n at ${t}`:n}function Qg(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return Qg(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function $g(e){let t;for(let n of e.reasons){if(!Wd(n)||!Cg(n.error))return;t??=n.error}return t}function e_(e,t){let n=$g(e);if(n===void 0)throw Error(t,{cause:e});return n}var t_=up,n_=mp,r_=gp,i_=_p,a_=yp,o_=bp,s_=Tp,c_=Ep,l_=Dp,u_=Pp,d_=Lp,f_=Rp,p_=Up;O()(`effect/DateTime/CurrentTimeZone`);var m_=nm,h_=im,g_=class e extends at{run;constructor(e){super(),this.run=e}map(t){return new e((e,n)=>this.run(e,n).pipe(ig(Ti(t))))}compose(t){return b_(this)?t:b_(t)?this:new e((e,n)=>this.run(e,n).pipe(sg(e=>t.run(e,n))))}};function __(e){return new g_((t,n)=>j(e(t,n)))}function v_(e){return __((t,n)=>{let r={message:e(t)};return D(t)?new Fg(r,t.value,n):new Fg(r)})}var y_=new g_(k);function b_(e){return e.run===y_.run}function x_(){return y_}function S_(e){return new g_((t,n)=>hi(t)?$m:e(t.value,n))}function C_(e){return T_(Ti(e))}function w_(e){return S_((t,n)=>e(t,n).pipe(ig(E)))}function T_(e){return new g_(t=>k(e(t)))}function E_(){return new g_(()=>$m)}function D_(e){return new g_(t=>{let n=Ai(t,wt);return D(n)?k(n):ig(e,E)})}function O_(){return C_(globalThis.String)}function k_(){return C_(globalThis.Number)}function A_(){return C_(globalThis.BigInt)}function j_(e){return S_((t,n)=>ch({try:()=>E(JSON.parse(t,e?.reviver)),catch:()=>new Ng({expected:`a valid JSON string`},t,n)}))}function M_(e){return S_((t,n)=>ch({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return E(n)},catch:()=>new Ng({expected:`a JSON-serializable value`},t,n)}))}function N_(){return C_(ds)}function P_(){return C_(ps)}function F_(){return w_((e,t)=>ag(dh(fs(e)),()=>new Ng({expected:`a valid Base64 string`},e,t)))}function I_(){return w_((e,t)=>Bi(hs(e),{onFailure:()=>j(new Ng({expected:`a valid Base64Url string`},e,t)),onSuccess:k}))}var L_=`~effect/SchemaTransformation/Transformation`,R_=class e{[L_]=L_;_tag=`Transformation`;decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new e(this.encode,this.decode)}compose(t){return new e(this.decode.compose(t.decode),t.encode.compose(this.encode))}};function z_(e){return At(e,L_)&&e[L_]===L_}var B_=e=>z_(e)?e:new R_(e.decode,e.encode);function V_(e){return new R_(w_(e.decode),w_(e.encode))}function H_(e){return new R_(C_(e.decode),C_(e.encode))}function U_(e){return new R_(T_(e.decode),T_(e.encode))}var W_=new R_(x_(),x_());function G_(){return W_}var K_=new R_(k_(),O_()),q_=new R_(A_(),O_()),J_=e=>Ot(e)&&typeof e.message==`string`,Y_=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:$_(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},X_=e=>{try{let t=In(e);return t===void 0?An(e):JSON.parse(t)}catch{return An(e)}},Z_=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},Q_=e=>{let t=new WeakSet,n=r=>{if(jt(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=Z_(r,e,n);return t.delete(r),i}return X_(r)};return n},$_=e=>J_(e)?Y_(e):e,ev=e=>H_({decode:$_,encode:Q_(e)});function tv(){return H_({decode:xi,encode:Si})}function nv(){return U_({decode:E,encode:Di})}var rv=V_({decode:(e,t)=>URL.canParse(e)?k(new URL(e)):j(new Ng({expected:`a valid URL string`},e,t)),encode:e=>k(e.href)}),iv=new R_(F_(),N_());function av(e){return new R_(j_(e??{}),M_(e))}var ov=V_({decode:(e,t)=>gi(s_(e),{onNone:()=>j(new Ng({expected:`a valid UTC DateTime string`},e,t)),onSome:e=>k(l_(e))}),encode:e=>k(m_(e))});function sv(e){return t=>t._tag===e}var cv=sv(`Declaration`),lv=sv(`Null`),uv=sv(`Void`),dv=sv(`Never`),fv=sv(`Literal`),pv=sv(`UniqueSymbol`),mv=sv(`Arrays`),hv=sv(`Objects`),gv=sv(`Union`),_v=sv(`Suspend`),vv=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},yv={},bv=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},xv=`~effect/Schema`,Sv=class{[xv]=xv;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}>`}},Cv=class e extends Sv{_tag=`Declaration`;typeParameters;run;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o}getParser(){let e;return(t,n)=>t===gg?vg:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(t,n,r){let i=Ry(this.typeParameters,t);return i===this.typeParameters&&n===this.checks&&r===this.encodingChecks?this:new e(i,this.run,this.annotations,n,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},wv=new class extends Sv{_tag=`Null`;getParser(){return tb(this,null)}getExpected(){return`null`}},Tv=class extends Sv{_tag=`Undefined`;getParser(){return tb(this,void 0)}toCodecJson(){return Ey(this,[Ev])}getExpected(){return`undefined`}},Ev=new vv(wv,new R_(C_(()=>void 0),C_(()=>null))),Dv=new Tv,Ov=new class extends Sv{_tag=`Void`;getParser(){let e=_g(void 0);return t=>t===gg?vg:e}toCodecJson(){return Ey(this,[Ev])}getExpected(){return`void`}},kv=new class extends Sv{_tag=`Never`;getParser(){return nb(this,Et)}getExpected(){return`never`}},Av=new class extends Sv{_tag=`Unknown`;getParser(){return nb(this,Dt)}getExpected(){return`unknown`}},jv=class extends Sv{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${An(e)}`);this.literal=e}getParser(){return tb(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Mv(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Mv(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Mv(e){let t=globalThis.String(e.literal);return Ey(e,[new vv(new jv(t),new R_(C_(()=>e.literal),C_(()=>t)))])}var Nv=new class extends Sv{_tag=`String`;getParser(){return nb(this,_t)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&mb(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},Pv=class extends Sv{_tag=`Number`;getParser(){return nb(this,vt)}matchKey(e,t){return this._match(ob,e,t)}matchPart(e,t){return this._match(ab,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:mb(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(Fv(this.checks,`effect/schema/isFinite`)||Fv(this.checks,`effect/schema/isInt`))?this:Ey(this,[xy])}toCodecStringTree(){return this.toCodecJson()===this?Ey(this,[lb]):Ey(this,[ub])}getExpected(){return`number`}};function Fv(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&Fv(e.checks,t))}var Iv=new Pv,Lv=new class extends Sv{_tag=`Boolean`;getParser(){return nb(this,yt)}getExpected(){return`boolean`}},Rv=new class extends Sv{_tag=`BigInt`;getParser(){return nb(this,bt)}matchPart(e,t){if(!db.test(e))return;let n=globalThis.BigInt(e);return t.disableChecks||!this.checks?n:mb(this.checks,n,void 0,this,t)?void 0:n}toCodecStringTree(){return Ey(this,[pb])}getExpected(){return`bigint`}},zv=class e extends Sv{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(qy(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(qy(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}return cg(function*(e,c){if(e===gg)return gg;if(!Array.isArray(e))return yield*j(new Mg(n,e,c));r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)})));let l=e.length,u={ast:n,getParser:s,input:e,len:l,tailThreshold:Math.max(a,l-o),output:new globalThis.Array(l),issues:void 0,options:c},d=Bv(u,e,{concurrency:Vv(c?.concurrency)?.concurrency,end:n.rest.length===0?a:Math.max(l,a+o)});if(d&&(yield*d),n.rest.length===0&&l>a)for(let t=a;t<=l-1;t++){let r=new Ag(n,e[t],c),i=new Og([t],r);if(c.errors===`all`)u.issues?u.issues.push(i):u.issues=[i];else return yield*j(new jg(n,[i],e,c))}return u.issues?yield*j(new jg(n,u.issues,e,c)):u.output})}_rebuild(t,n,r){let i=Ry(this.elements,t),a=Ry(this.rest,t);return i===this.elements&&a===this.rest&&n===this.checks&&r===this.encodingChecks?this:new e(this.isMutable,i,a,this.annotations,n,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}},Bv=Hu()({onItem(e,t,n){let r=n<e.len?t:gg;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step(e,t,n,r){if(n._tag===`Failure`)return Hv(e,e.ast,r,n);let i=n===yg?t:n[w];if(i!==gg)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(qy(t.ast))return;let n=new Og([r],new kg(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return uf(new jg(e.ast,[n],e.input,e.options))}}}),Vv=e=>(e=e===`unbounded`?1/0:e??1,e>1?{concurrency:e}:void 0),Hv=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=$g(r.cause);if(i===void 0)return lf(Zd(r.cause,r=>new jg(t,[new Og([n],r)],e.input,e.options)));let a=new Og([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return uf(new jg(t,[a],e.input,e.options))},Uv=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function Wv(e,t,n=yv){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(rb(Zy(t)))}var Gv=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Kv(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Kv);default:return!1}}function qv(e){return Kv(e)&&Kv(Zy(e))}var Jv=class{parameter;type;constructor(e,t){if(!qv(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,qy(t)&&!eb(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Yv=class e extends Sv{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o;let s=e.map(e=>e.name).filter((e,t,n)=>n.indexOf(e)!==t);if(s.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(s)}. ts(2300)`)}getParser(e,t=e){let n=this,r=[];for(let e of n.propertySignatures)r.push(e.name);let i=r.length,a=n.indexSignatures.length,o=i&&a?new Set(r):void 0;if(!i&&!a)return nb(n,Tt);let s,c,l=(e,t,r,a,s)=>{if(s._tag===`Failure`)return Hv(e,n,t,s)??df;let c=s===yg?a:s[w];if(r!==gg&&c!==gg){if(i&&(o.has(t)||o.has(r)))return df;xn(e.out,r,c)}return df},u=(e,t,r,i)=>{if(!i){let n=r.parserKey(t,e.options);if(!ml(n))return M(hh(n),n=>u(e,t,r,n));i=n}if(i._tag===`Failure`)return Hv(e,n,t,i)??df;let a=i===yg?t:i[w],o=e.input[t],s=r.parserValue(o,e.options);return ml(s)?l(e,t,a,o,s):M(hh(s),n=>l(e,t,a,o,n))},d=(e,t,n)=>{let r=e.input[t],i=n.parserValue(r,e.options);return ml(i)?l(e,t,t,r,i):M(hh(i),n=>l(e,t,t,r,n))},f=a?Hu()({onItem:(e,[t,n])=>u(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return cg(function*(l,p){if(l===gg)return gg;if(!(typeof l==`object`&&l&&!Array.isArray(l)))return yield*j(new Mg(n,l,p));s||(s=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),c=a?n.indexSignatures.map(n=>({is:n,parserKey:e(rb(n.parameter)),parserValue:t(n.type)})):void 0);let m=l,h={},g={ast:n,input:m,out:h,issues:void 0,options:p},_=p.errors===`all`,v=p.onExcessProperty===`error`,y=p.onExcessProperty===`preserve`,b;if(!a&&(v||y)){o??=new Set(r),b=Reflect.ownKeys(m);for(let e=0;e<b.length;e++){let t=b[e];if(!o.has(t)){if(v){let e=new Ag(n,m[t],p),r=new Og([t],e);if(_){g.issues?g.issues.push(r):g.issues=[r];continue}return yield*j(new jg(n,[r],l,p))}xn(h,t,m[t])}}}let x=Vv(p?.concurrency);if(i){let e=Xv(g,s,x);e&&(yield*e)}if(a&&!x)for(let e=0;e<a;e++){let t=c[e],n=t.is.parameter===Nv?d:u,r=t.is.parameter===Nv?Object.keys(m):Wv(m,t.is.parameter,p);for(let e=0;e<r.length;e++){let i=n(g,r[e],t);if(!ml(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(f){let e=pa();for(let t=0;t<a;t++){let n=c[t],r=Wv(m,n.is.parameter,p);for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=f(g,e,x);t&&(yield*t)}if(g.issues)return yield*j(new jg(n,g.issues,l,p));if(p.propertyOrder===`original`){let e=(b??Reflect.ownKeys(m)).concat(r),t={};for(let n of e)Object.hasOwn(h,n)&&xn(t,n,h[n]);return t}return h})}_rebuild(t,n,r,i){let a=Ry(this.propertySignatures,e=>{let n=t(e.type);return n===e.type?e:new Gv(e.name,n)}),o=Ry(this.indexSignatures,e=>{let r=n(e.parameter),i=t(e.type);return r===e.parameter&&i===e.type?e:new Jv(r,i)});return a===this.propertySignatures&&o===this.indexSignatures&&r===this.checks&&i===this.encodingChecks?this:new e(a,o,this.annotations,r,void 0,this.context,i)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}},Xv=Hu()({onItem(e,t){if(!Object.hasOwn(e.input,t.name))return t.parser(gg,e.options);let n=e.input[t.name];return xn(e.out,t.name,n),t.parser(n,e.options)},step(e,t,n){if(n._tag===`Failure`)return Hv(e,e.ast,t.name,n);if(n===yg)return;let r=n[w];if(r!==gg){xn(e.out,t.name,r);return}if(delete e.out[t.name],!qy(t.type)){let n=new Og([t.name],new kg(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return uf(new jg(e.ast,[n],e.input,e.options))}}});function Zv(e,t){return e?t?[...e,...t]:e:t}function Qv(e,t,n){return new Yv(Reflect.ownKeys(e).map(t=>new Gv(t,e[t].ast)),[],n,t)}function $v(e){return e.ast}function ey(e,t=void 0){return new zv(!1,e.map(e=>e.ast),[],void 0,t)}function ty(e,t,n){return new uy(e.map($v),t,void 0,n)}var ny=mt(e=>{for(;;){if(_v(e))return Av;let t=e.encoding;if(!t)return e.recur?.(ny,C)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==C))return Av;e=t[t.length-1].to}});function ry(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(ry)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function iy(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[fg];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!qy(t)){if(fv(t))return[{key:e.name,literal:t.literal}];if(pv(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!qy(e)){if(fv(e))return[{key:t,literal:e.literal}];if(pv(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>iy(ny(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return iy(e.thunk())}}var ay=new WeakMap,oy=Object.freeze([]);function sy(e){let t=ay.get(e);if(t)return t;let n,r=0,i,a,o=!0;for(let t=0;t<e.length;t++){let s=e[t],c=ny(s);if(dv(c))continue;if(o){if(fv(c)||pv(c)){a??=new Map;let e=fv(c)?c.literal:c.symbol,t=a.get(e);t||a.set(e,t=[]),t.push(s)}else o=!1}let l=iy(c);if(l.length){n??=new Map,r++;for(let{key:e,literal:r}of l){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=ry(c);for(let n of e)(i[n]??=[]).push(t)}}if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??oy;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=i;for(let[t,n]of i)a.set(t,Object.freeze(Array.from(n,t=>e[t])));t=(t,n)=>{if(kt(t)){let i=Object.hasOwn(t,r)?t[r]:void 0;if(i!==void 0)return a.get(i)??oy;if(n)return e}return oy}}else if(n){let a;for(let e of n)(!a||e[1][0].size>a[1][0].size)&&e[1][1].size===r&&(a=e);t=(t,r)=>{let o=i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??oy;if(!kt(t))return o.map(t=>e[t]);let s=new Set(o),c;if(a){let[n,[i]]=a,l=Object.hasOwn(t,n),u=l?t[n]:void 0;if(l&&(!r||u!==void 0)){let t=i.get(u);if(!t)return o.map(t=>e[t]);for(let e of t)s.add(e);c=n}}if(c===void 0)for(let[e,[i,a]]of n){let n=Object.hasOwn(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);if(e)for(let t of e)s.add(t)}else if(r)for(let e of a)s.add(e)}for(let[e,[i,a]]of n){if(e===c)continue;let n=Object.hasOwn(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);for(let t of s)a.has(t)&&!e?.has(t)&&s.delete(t)}}return Array.from(s).sort((e,t)=>e-t).map(t=>e[t])}}else t=t=>(i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??oy).map(t=>e[t]).filter(cy(t));return ay.set(e,t),t}function cy(e){return t=>{let n=ny(t);return n._tag===`Literal`?n.literal===e:n._tag!==`UniqueSymbol`||n.symbol===e}}function ly(e,t,n=!1){return sy(t)(e,n)}var uy=class e extends Sv{_tag=`Union`;types;mode;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.mode=t,this.encodingChecks=o}getParser(e,t){let n=this;return(r,i)=>{if(r===gg)return vg;let a=ly(r,n.types,t!==void 0);if(a.length===1){let t=e(a[0])(r,i);return t._tag===`Success`?t:ml(t)?dy(n,t.cause,r,i):xh(t,e=>dy(n,e,r,i))}let o={ast:n,compile:e,input:r,out:void 0,successes:n.mode===`oneOf`?[]:void 0,issues:void 0,options:i},s=Vv(i?.concurrency),c=fy(o,a,s?{...s,orderedStep:!0}:void 0);return c?sg(c,e=>o.out===yg?k(r):o.out?o.out:j(new Ig(n,o.issues??[],r,i))):o.out?o.out:j(new Ig(n,o.issues??[],r,i))}}_rebuild(t,n,r){let i=Ry(this.types,t);return i===this.types&&n===this.checks&&r===this.encodingChecks?this:new e(i,this.mode,this.annotations,n,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=Zy(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(fv);if(t.length>0)return`${my(n.isMutable)}[ ${t.map(t=>e(t)+hy(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>fv(e.type));if(t.length>0)return`{ ${t.map(t=>`${my(t.type.context?.isMutable)}${Mn(t.name)}${hy(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function dy(e,t,n,r){let i=$g(t);return i?uf(new Ig(e,[i],n,r)):lf(t)}var fy=Hu()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=$g(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(t),uf(new Lg(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return df}}}),py=new uy([new jv(`Infinity`),new jv(`-Infinity`),new jv(`NaN`)],`anyOf`);function my(e){return e?``:`readonly `}function hy(e){return e?`?`:``}var gy=class e extends at{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(t){return new e(this.run,{...this.annotations,...t},this.aborted)}abort(){return new e(this.run,this.annotations,!0)}and(e,t){return new _y([this,e],t)}},_y=class e extends at{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(t){return new e(this.checks,{...this.annotations,...t})}and(t,n){return new e([this,t],n)}};function vy(e,t,n=!1){return new gy((t,n,r)=>Bg(n,e(t,n,r),t,r),t,n)}function yy(e){return vy(e=>globalThis.Number.isFinite(e),{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})}var by=Ay(Iv,[yy()]),xy=new vv(new uy([by,py],`anyOf`),new R_(k_(),C_(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Sy(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return vy(e=>(r.lastIndex=0,r.test(e)),{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 Cy(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}var wy=new WeakMap;function Ty(e){return wy.get(e)??e}function Ey(e,t){return e.encoding===t?e:Cy(e,e=>{e.encoding.value=t})}function Dy(e,t){if(e.context===t)return e;let n=Ty(e);if(n.context===t)return n;let r=Cy(e,e=>{e.context.value=t});return wy.set(r,n),r}function Oy(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return ky(e,$i(e.checks.slice(0,-1),n.annotate(t)))}return Cy(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function ky(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:Cy(e,e=>{e.checks.value=t})}function Ay(e,t){return ky(e,Zv(e.checks,t))}function jy(e,t){let n=t(e.to);return n===e.to?e:new vv(n,e.transformation)}function My(e,t){let n=e,r=n[n.length-1],i=jy(r,t);return i===r?e:$i(e.slice(0,e.length-1),i)}function Ny(e){return t=>t.encoding?Ey(t,My(t.encoding,e)):t}function Py(e,t){return Ny(e=>Dy(e,t))(e)}function Fy(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:Ey(r,My(r.encoding,n))}return e(r)}return mt(n)}function Iy(e,t,n){let r=new vv(e,t);return Ey(n,n.encoding?[...n.encoding,r]:[r])}function Ly(e,t){let n=mg(e);return Oy(e,{brands:n?[...n,t]:[t]})}function Ry(e,t){let n=!1,r=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}function zy(e,t){return Dy(e,e.context?new bv(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new bv(!1,!1,void 0,t))}var By=mt(e=>Vy(Dy(e,e.context?e.context.isOptional===!1?new bv(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new bv(!0,!1)))),Vy=Ny(By),Hy=pt(e=>By(new uy([e,Dv],`anyOf`)));function Uy(e,t){let n=new vv(Av,new R_(D_(t),x_()));return Dy(e,e.context?new bv(e.context.isOptional,e.context.isMutable,n,e.context.annotations):new bv(!1,!1,n))}function Wy(e,t,n){return Iy(e,n,t)}function Gy(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:St(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function Ky(e,t){let{literals:n,parameters:r}=Gy(e);return new Yv(n.map(e=>new Gv(e,t)),r.map(e=>new Jv(e,t)))}function qy(e){return e.context?.isOptional??!1}function Jy(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(Jy)}function Yy(e){function t(e){return Jy(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return ta(n)?n:void 0}var Xy=mt(e=>{if(e.encoding)return Xy(Ey(e,void 0));let t=e,n=t.recur?.(Xy)??t,r=n.encodingChecks;if(r){let t=n===e?r:mv(n)||hv(n)||cv(n)&&n.typeParameters.length>0?Yy(r):void 0;return Cy(n,e=>{e.encodingChecks.value=void 0,e.checks.value=Zv(n.checks,t)})}return n}),Zy=mt(e=>Xy($y(e)));function Qy(e,t){let n=t,r=n.length,i=n[r-1],a=[new vv($y(Ey(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new vv($y(n[e-1].to),n[e].transformation.flip()));let o=$y(i.to);return o.encoding?Ey(o,[...o.encoding,...a]):Ey(o,a)}var $y=pt(e=>{if(e.encoding)return Qy(e,e.encoding);let t=e;return t.flip?.($y)??t.recur?.($y)??t});function eb(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(eb);default:return!1}}function tb(e,t){let n=_g(t);return(r,i)=>r===gg?vg:r===t?n:j(new Mg(e,r,i))}function nb(e,t){return(n,r)=>n===gg?vg:t(n)?yg:j(new Mg(e,n,r))}var rb=Fy(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(rb)}}),ib=Fy(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(ib)}}),ab=new globalThis.RegExp(`^${Uv}$`),ob=new globalThis.RegExp(`^(?:${Uv}|Infinity|-Infinity|NaN)$`);function sb(e){return Sy(ab,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:ab.source}),...e})}var cb=Ay(Nv,[sb()]),lb=new vv(cb,K_),ub=new vv(new uy([cb,py],`anyOf`),K_),db=new globalThis.RegExp(`^-?\\d+$`);function fb(e){return Sy(db,{expected:`a string representing a bigint`,representation:{id:`effect/schema/isStringBigInt`,payload:null},toJsonSchema:()=>({pattern:db.source}),...e})}var pb=new vv(Ay(Nv,[fb({expected:`a string representing a bigint`})]),q_);function mb(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=mb(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new Eg(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function hb(e){if(!cv(e))return;let t=e.annotations?.[pg];return Ct(t)?t(e.typeParameters):void 0}var gb=ug;function _b(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function vb(e){return e===void 0||typeof e==`string`}function yb(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function bb(e){return yb(e,_b)}var xb=new Cv([],()=>(e,t,n)=>bb(e)?yg:j(new Mg(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>Tb,toArbitrary:()=>e=>e.jsonValue()}),Sb=new vv(xb,G_()),Cb=new vv(new uy([new zv(!1,[],[xb]),new Yv([],[new Jv(Nv,xb)])],`anyOf`),G_());function wb(e){return yb(e,vb)}var Tb=new vv(new Cv([],()=>(e,t,n)=>wb(e)?yg:j(new Mg(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),G_()),Eb=Ac,Db=Cc,Ob=td,kb=`~effect/MutableRef`,Ab={[kb]:kb,...$n,toJSON(){return{_id:`MutableRef`,current:Rn(this.current)}}},jb=e=>{let t=Object.create(Ab);return t.current=e,t},Mb=S(2,(e,t)=>(e.current=t,e)),Nb=e=>new Fb(e),Pb=(e,t,n)=>Xc(r=>{if(e.free>=t)return r(n);let i=()=>{e.free<t||(e.waiters.delete(i),r(n))};return e.waiters.add(i),Ic(()=>{e.waiters.delete(i)})}),Fb=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=Lc(()=>this.free<e?Pb(this,e,t):(this.taken+=e,Nc(e)));return t}takeIfAvailable(e){return Lc(()=>this.free<e?Nc(!1):(this.taken+=e,Nc(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{for(let e of this.waiters){if(this.free<=0)break;e()}},0),this.free}resize(e){return jr(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),Wc))}release(e){return jr(t=>Nc(this.releaseUnsafe(t,e)))}get releaseAll(){return jr(e=>Nc(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>Iu(n=>{let r=Lc(()=>this.free<e?fl(n(Pb(this,e,Wc)),()=>r):(this.taken+=e,yu(n(t),()=>{this.releaseUnsafe(Cc(),e)},!0)));return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>Iu(n=>this.free<e?Bc:(this.taken+=e,yu(n(cl(t)),()=>{this.releaseUnsafe(Cc(),e)},!0)))}},Ib={"~effect/Channel":{_Env:C,_InErr:C,_InElem:C,_OutErr:C,_OutElem:C},pipe(){return rt(this,arguments)}},Lb=e=>{let t=Object.create(Ib);return t.transform=(t,n)=>xh(e(t,n),e=>k(ah(e))),t},Rb=(e,t)=>Lb((n,r)=>M(Vb(e)(n,r),e=>t(e,r))),zb=e=>Lb((t,n)=>e),Bb=e=>Lb($h(function*(t,n){let r=Df(n),i=e=>Of(r,Gm(e));return Rh(yield*Rh(e(t,n,r),i),i)})),Vb=e=>e.transform,Hb=e=>Lb((t,n)=>eh(()=>Vb(e())(t,n))),Ub=e=>zb(k(j(e))),Wb=e=>Lb((t,n)=>Gb({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Gb=e=>{let t=e.readable.getReader(),n=e.exit??jb(void 0),r=eh(()=>n.current?n.current:Oh(Qm({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??ah(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?af():k(ma(t))}));return _h(Ef(e.scope,e.releaseLockOnEnd?th(()=>t.releaseLock()):Zm(()=>t.cancel().catch(dt))),r)},Kb=S(2,(e,t)=>Rb(e,e=>th(()=>{let n=0;return gh(e,e=>t(e,n++))}))),qb=S(2,(e,t)=>Lb((n,r)=>M(Vb(e)(n,r),e=>Vb(t)(e,r)))),Jb=S(2,(e,t)=>Bb((n,r,i)=>Tf(i,t).pipe(fh(Vb(e)(n,r))))),Yb=S(2,(e,t)=>Jb(e,e=>t)),Xb=(e,t,n)=>eh(()=>{let r=Cf();return Vm(M(Vb(e)(af(),r),t),n||k).pipe(zh(e=>Of(r,e)))}),Zb=S(2,(e,t)=>Lb((n,r)=>gh(Mh(Vb(e)(n,r),t),Mh(t)))),Qb=S(2,(e,t)=>Xb(e,e=>Wh(M(e,t),{disableYield:!0}))),$b=(e,t)=>Vb(e)(af(),t);function ex(e){let t=fx(gx,Xy(e.ast));return(e,n)=>t(e,n?.disableChecks?n?.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions)}function tx(e){let t=ex(e);return(e,n)=>{let r=Qh(t(e,n));return ff(r)?E(r.value):(e_(r.cause,`Option adapter can only return none for schema issues`),T())}}function nx(e){let t=ex(e);return(e,n)=>{let r=Qh(t(e,n));if(ff(r))return r.value;let i=e_(r.cause,`Constructor adapter can only throw schema issues`);throw Error(`Schema validation failed`,{cause:i})}}function rx(e){return ix(e.ast)}function ix(e){let t=px(dx(Xy(e)));return e=>{let n=t(e,yv);return ff(n)?!0:(e_(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}function ax(e,t){let n=dx(e.ast);return t===void 0?n:(e,r)=>n(e,lx(t,r))}function ox(e,t){return mx(ax(e,t))}var sx=ox;function cx(e,t){let n=dx($y(e.ast));return t===void 0?n:(e,r)=>n(e,lx(t,r))}var lx=(e,t)=>t?{...e,...t}:e,ux=e=>e===gg?j(new Ng):k(e);function dx(e){return fx(hx,e)}function fx(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??yv);return a===yg?k(r):ml(a)?a[w]===gg?ux(gg):a:sg(a,ux)}}function px(e){return(t,n)=>Qh(e(t,n))}function mx(e){let t=px(e);return(e,n)=>{let r=t(e,n);return ff(r)?E(r.value):(e_(r.cause,`Option adapter can only return none for schema issues`),T())}}var hx=pt(e=>xx(e,hx)),gx=pt(e=>xx(e,gx,vx)),_x=pt(e=>xx(e,gx,vx,e.context?.constructorDefault));function vx(e){return e.context?.constructorDefault?_x(e):gx(e)}function yx(e,t,n,r){let i;if(ml(e)&&e._tag===`Success`){let a=bg(e===yg?t:e[w]);i=n._tag===`Transformation`?n.decode.run(a,r):n.decode(_g(a),r)}else i=n._tag===`Transformation`?sg(e,e=>n.decode.run(bg(e),r)):n.decode(ig(e,bg),r);return ml(i)&&i._tag===`Success`?xg(i[w]):sg(i,xg)}function bx(e,t){let n;return(r,i)=>r===gg?vg:e.isConstructed(r)?yg:yx((n??=t(e.link.to))(r,i),r,e.link.transformation,i)}function xx(e,t,n,r){let i=n?hb(e):void 0,a=i?bx(i,t):e.getParser(t,n),o=e.checks,s=r?e.encoding?[...e.encoding,r]:[r]:e.encoding,c=e.encodingChecks,l=(o?o[o.length-1].annotations:e.annotations)?.parseOptions;if(!s&&!o&&!c)return l?(e,t)=>a(e,lx(t,l)):a;let u,d=(t,n)=>{let r=a(t,n);if(c&&!n.disableChecks){if(ml(r)){if(r._tag===`Success`){let i=r===yg?t:r[w];if(t!==gg&&i!==gg){let i=mb(c,t,void 0,e,n);i&&(r=j(new jg(e,i,t,n)))}}}else r=M(r,r=>{if(t!==gg&&r!==gg){let r=mb(c,t,void 0,e,n);if(r)return j(new jg(e,r,t,n))}return k(r)})}if(o&&!n.disableChecks){if(ml(r)){if(r._tag===`Success`){let i=r===yg?t:r[w];if(i===gg)return r;let a=mb(o,i,void 0,e,n);a&&(r=j(new jg(e,a,i,n)))}}else r=M(r,t=>{if(t!==gg){let r=mb(o,t,void 0,e,n);if(r)return j(new jg(e,r,t,n))}return k(t)})}return r};return s?(n,r)=>{l&&(r=lx(r,l));let i=u??=s.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=s.length-1;e>=0;e--)if(o=yx(o,a,s[e].transformation,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[w],o=t(a,r)):o=sg(o,e=>{let n=t(e,r);return n===yg?_g(e):n})}if(o._tag===`Success`){let e=o[w],t=d(e,r);return t===yg?o:t}return o=xh(o,t=>oh(()=>Zd(t,t=>new Dg(e,t,n,r)))),sg(o,e=>{let t=d(e,r);return t===yg?_g(e):t})}:l?(e,t)=>d(e,lx(t,l)):d}var Sx=`~effect/Schema/Schema`,Cx={[Sx]:Sx,pipe(){return rt(this,arguments)},annotate(e){return this.rebuild(Oy(this.ast,e))},annotateKey(e){return this.rebuild(zy(this.ast,e))},check(...e){return this.rebuild(Ay(this.ast,e))}};function wx(e,t){function n(){}let r=Object.defineProperties(Object.setPrototypeOf(n,Cx),Object.getOwnPropertyDescriptors({...t}));return r.ast=e,r.rebuild=e=>wx(e,t),r.makeEffect=ex(r),r.make=nx(r),r.makeOption=tx(r),r}var Tx=S(2,(e,t)=>Dx(e,(e,n)=>[Object.hasOwn(t,e)?t[e]:e,n])),Ex=e=>e;function Dx(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let i=t(r,e[r]);if(i){let[e,t]=i;xn(n,e,t)}}return n}var Ox=S(2,(e,t)=>e===void 0?void 0:t(e)),kx=new WeakMap,Ax=e=>{if(kx.has(e))return kx.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},jx=`~effect/data/Redacted`,Mx=e=>At(e,jx),Nx=(e,t)=>{let n=Object.create(Px);return t?.label&&(n.label=t.label),kx.set(n,e),n},Px={[jx]:{_A:e=>e},label:void 0,...$n,toJSON(){return this.toString()},toString(){return`<redacted${_t(this.label)?`:`+this.label:``}>`},[Nt](){return Pt(kx.get(this))},[Zt](e){return Mx(e)&&Qt(kx.get(this),kx.get(e))}},Fx=Ax,Ix=e=>hn((t,n)=>e(Fx(t),Fx(n))),Lx=Sx;function Rx(){return(e,t,n)=>P(new Cv(e.map($v),e=>t(e.map(e=>P(e))),n))}function zx(e,t){return Rx()([],()=>(t,n,r)=>e(t)?k(t):j(new Mg(n,t,r)),t)}var Bx=`~effect/SchemaError/SchemaError`,Vx=class extends cs(`SchemaError`){[Bx]=Bx;constructor(e){super({issue:e})}get message(){return Xg(this.issue)}toString(){return`SchemaError(${this.message})`}};function Hx(e){return At(e,Bx)&&e[Bx]===Bx}function Ux(e){return ff(e)?e.value:{issues:[{message:nf(e.cause)}]}}function Wx(e,t){let n=ax(e),r={errors:`all`,...t?.parseOptions},i=Ug(t),a=e=>{let t=new ns(`sync`),a=Yh(Dh(n(e,r),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});a.currentDispatcher?.flush();let o=a.pollUnsafe();return o?Ux(o):new Promise(e=>{a.addObserver(t=>{e(Ux(t))})})};if(`~standard`in e){let t=e;return`validate`in t[`~standard`]||Object.assign(t[`~standard`],{validate:a}),t}return Object.assign(e,{"~standard":{version:1,vendor:`effect`,validate:a}})}var Gx=rx;function Kx(e,t){let n=ax(e,t);return(e,t)=>qx(n(e,t))}function qx(e){return xh(e,e=>oh(()=>Zd(e,e=>new Vx(e))))}var Jx=Kx;function Yx(e,t){let n;for(let r of e.reasons){if(!Wd(r)||!Hx(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 Xx(e){let t=Qh(e);if(ff(t))return t.value;throw Yx(t.cause,`Sync adapter can only throw schema errors`)}var Zx=ox,Qx=sx;function $x(e,t){let n=Kx(e,t);return(e,t)=>Xx(n(e,t))}var eS=$x;function tS(e,t){let n=cx(e,t);return(e,t)=>qx(n(e,t))}function nS(e,t){let n=tS(e,t);return(e,t)=>Xx(n(e,t))}var rS=nS,P=wx;function iS(e){return At(e,Lx)&&e[Lx]===Lx}var aS=Ex(e=>P(By(e.ast),{schema:e})),oS=Ex(e=>{let t=OS(e);return P(Hy(e.ast),{schema:t})}),sS=Ex(e=>P(Xy(e.ast),{schema:e})),cS=Ex(e=>P(Zy(e.ast),{schema:e}));function lS(e){let t=P(new jv(e),{literal:e,transform(n){return t.pipe(B(lS(n),{decode:C_(()=>n),encode:C_(()=>e)}))}});return t}var uS=P(kv),dS=P(Av),fS=P(wv),pS=P(Dv),F=P(Nv),mS=P(Iv),hS=P(Lv),gS=P(Rv),_S=P(Ov);function vS(e,t){return P(e,{fields:t,mapFields(e,t){let n=e(this.fields);return vS(Qv(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function I(e){return vS(Qv(e,void 0),e)}var yS=e=>typeof e==`symbol`?e:globalThis.String(e);function bS(e){return function(t){let n={},r=Object.create(null),i=Object.create(null),a=new Set;for(let o of Reflect.ownKeys(t.fields)){let s=cS(t.fields[o]),c=Object.hasOwn(e,o),l=c?e[o]:o,u=yS(l);if(a.has(u))throw new globalThis.Error(`Duplicate encoded keys: ${Mn(l)}`);a.add(u),xn(n,l,s),c&&(r[o]=l,i[l]=o)}return I(n).pipe(B(t,H_({decode:Tx(i),encode:Tx(r)})))}}function xS(e,t){return P(Ky(e.ast,t.ast),{key:e,value:t})}function SS(e,t){return P(e,{elements:t,mapElements(e,t){let n=e(this.elements);return SS(ey(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function CS(e){return SS(ey(e),e)}var L=Ex(e=>P(new zv(!1,[],[e.ast]),{value:e})),wS=Ex(e=>P(new zv(!1,[e.ast],[e.ast]),{value:e}));function TS(e,t){return P(e,{members:t,mapMembers(e,t){let n=e(this.members);return TS(ty(n,this.ast.mode,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function R(e,t){return TS(ty(e,t?.mode??`anyOf`,void 0),e)}function ES(e){let t=e.map(lS);return P(ty(t,`anyOf`,void 0),{literals:e,members:t,mapMembers(e){return R(e(this.members))},pick(e){return ES(e)},transform(e){return R(t.map((t,n)=>t.transform(e[n])))}})}var DS=Ex(e=>R([e,fS])),OS=Ex(e=>R([e,pS]));function z(e){return t=>P(Ly(t.ast,e),{schema:t,identifier:e})}function B(e,t){return n=>P(Wy(n.ast,e.ast,t?B_(t):G_()),{from:n,to:e})}function kS(e,t){return n=>t?B(n,t)(e):B(n)(e)}function AS(e){return t=>P(Uy(t.ast,e),{schema:t})}function jS(e){return xh(e,e=>oh(()=>Zd(e,e=>e.issue)))}function MS(e,t){let n=t?.encodingStrategy===`omit`?E_():x_();return t=>aS(cS(t)).pipe(B(t,{decode:D_(jS(e)),encode:n}))}function NS(e,t){return n=>sS(n).pipe(MS(e,t),kS(aS(n)))}function PS(e){return lS(e).pipe(AS(k(e)))}function FS(e,t){return I({_tag:PS(e),...t})}function IS(e,t){return zx(t=>t instanceof e,t)}function LS(){return(e,t)=>new vv(e.ast,B_(t))}var RS=vy;function zS(e,t){let n=e.source,r=e.flags,i=r===``?`new RegExp(${An(n)})`:`new RegExp(${An(n)}, ${An(r)})`;return Sy(e,{toCode:()=>({runtime:`Schema.isPattern(${i})`}),...t})}var BS=P(by),VS=yy;function HS(e){let t=pi(e.order),n=e.formatter??An;return(r,i)=>RS(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r}}},...e.annotate?.(r),...i})}function US(e){let t=pi(e.order),n=di(e.order),r=fi(e.order),i=ui(e.order),a=e.formatter??An;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return RS(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}}}},...e.annotate?.(o),...s})}}function WS(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${An(e)}`);return e}var GS=HS({order:ci,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:WS(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${An(e)})`})})}),KS=US({order:ci,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:WS(e.minimum),maximum:WS(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${An(e.minimum)}, maximum: ${An(e.maximum)}, exclusiveMinimum: ${An(t)}, exclusiveMaximum: ${An(n)} })`})}}});function qS(e){return RS(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`}),toCode:()=>({runtime:`Schema.isInt()`}),arbitrary:{constraint:{integer:!0}},...e})}var JS=mS.check(qS());function YS(e,t){return e=Math.max(0,Math.floor(e)),RS(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:t})=>t===`array`?{minItems:e}:{minLength:e},toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[dg]:!0,arbitrary:{constraint:{minLength:e}},...t})}function XS(e){return YS(1,e)}function ZS(e,t){return e=Math.max(0,Math.floor(e)),RS(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`array`?{maxItems:e}:{maxLength:e},toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[dg]:!0,arbitrary:{constraint:{maxLength:e}},...t})}function QS(e){return RS(e=>_a(e).length===e.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})}var V=F.check(XS());function $S(e){return P(Rx()([e],([e])=>(t,n,r)=>mi(t)?hi(t)?$m:og(ax(e)(t.value,r),{onSuccess:E,onFailure:e=>Pg(n,`value`,e,t,r)}):j(new Mg(n,t,r)),{representation:{id:`effect/schema/Option`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Option(${e[0].runtime})`,Type:`Option.Option<${e[0].Type}>`,importDeclarations:[`import * as Option from "effect/Option"`]}),expected:`Option`,toCodec:([e])=>LS()(R([I({_tag:lS(`Some`),value:e}),I({_tag:lS(`None`)})]),H_({decode:e=>e._tag===`None`?T():E(e.value),encode:e=>D(e)?{_tag:`Some`,value:e.value}:{_tag:`None`}})),toArbitrary:([e])=>(t,n)=>{let r=t.constant(T());return vC(t,n,r,t.oneof(r,e.arbitrary.map(E)))},toEquivalence:([e])=>ji(e),toFormatter:([e])=>gi({onNone:()=>`none()`,onSome:t=>`some(${e(t)})`})}).ast,{value:e})}function eC(e){return DS(e).pipe(B($S(sS(e)),tv()))}function tC(e){return aS(e).pipe(B($S(sS(e)),nv()))}function nC(e,t){let n=typeof t?.label==`string`?t.label:void 0,r=t?.disallowJsonEncode===!0,i=n===void 0?r?{disallowJsonEncode:!0}:void 0:r?{label:n,disallowJsonEncode:!0}:{label:n},a=n===void 0?void 0:ax(lS(n));return P(Rx()([e],([e])=>(t,n,r)=>Mx(t)?sg(a===void 0?nh:ag(a(t.label,r),e=>new Og([`label`],e)),()=>og(ax(e)(Fx(t),r),{onSuccess:()=>t,onFailure:()=>new jg(n,[new Og([`value`],new Ng(void 0,t,r))],t,r)})):j(new Mg(n,t,r)),{representation:{id:`effect/schema/Redacted`,payload:i??null},toCode:({typeParameters:e})=>({runtime:i===void 0?`Schema.Redacted(${e[0].runtime})`:`Schema.Redacted(${e[0].runtime}, ${An(i)})`,Type:`Redacted.Redacted<${e[0].Type}>`,importDeclarations:[`import * as Redacted from "effect/Redacted"`]}),expected:`Redacted`,toCodecJson:([e])=>LS()(e,{decode:C_(e=>Nx(e,{label:n})),encode:r?v_(e=>`Cannot serialize Redacted`+(D(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):C_(Fx)}),toArbitrary:([e])=>()=>({arbitrary:e.arbitrary.map(e=>Nx(e,{label:n})),terminal:e.terminal?.map(e=>Nx(e,{label:n}))}),toFormatter:()=>globalThis.String,toEquivalence:([e])=>Ix(e)}).ast,{value:e})}function rC(e,t){return B(nC(sS(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:C_(e=>Nx(e,{label:t?.label})),encode:t?.disallowEncode?v_(e=>`Cannot encode Redacted`+(D(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):C_(Fx)})(e)}function iC(e,t){return P(Rx()([e,t],([e,t])=>(n,r,i)=>{if(!Ud(n))return j(new Mg(r,n,i));switch(n._tag){case`Fail`:return og(ax(e)(n.error,i),{onSuccess:Jd,onFailure:e=>Pg(r,`error`,e,n,i)});case`Die`:return og(ax(t)(n.defect,i),{onSuccess:Yd,onFailure:e=>Pg(r,`defect`,e,n,i)});case`Interrupt`:return k(n)}},{representation:{id:`effect/schema/CauseReason`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.CauseReason(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Failure<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause.Failure`,toCodec:([e,t])=>LS()(R([I({_tag:lS(`Fail`),error:e}),I({_tag:lS(`Die`),defect:t}),I({_tag:lS(`Interrupt`),fiberId:OS(BS)})]),H_({decode:e=>{switch(e._tag){case`Fail`:return Jd(e.error);case`Die`:return Yd(e.defect);case`Interrupt`:return Xd(e.fiberId)}},encode:C})),toArbitrary:([e,t])=>aC(e,t),toEquivalence:([e,t])=>oC(e,t),toFormatter:([e,t])=>sC(e,t)}).ast,{error:e,defect:t})}function aC(e,t){return(n,r)=>{let i=n.constant(Xd());return vC(n,r,i,n.oneof(i,n.integer({min:1}).map(Xd),e.arbitrary.map(e=>Jd(e)),t.arbitrary.map(e=>Yd(e))))}}function oC(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 sC(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 cC(e,t){return P(Rx()([e,t],([e,t])=>{let n=L(iC(e,t));return(e,t,r)=>Hd(e)?og(ax(n)(e.reasons,r),{onSuccess:Gd,onFailure:n=>Pg(t,`failures`,n,e,r)}):j(new Mg(t,e,r))},{representation:{id:`effect/schema/Cause`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Cause(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Cause<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause`,toCodec:([e,t])=>LS()(L(iC(e,t)),H_({decode:Gd,encode:({reasons:e})=>e})),toArbitrary:([e,t])=>lC(e,t),toEquivalence:([e,t])=>uC(e,t),toFormatter:([e,t])=>dC(e,t)}).ast,{error:e,defect:t})}function lC(e,t){return(n,r)=>{let i=aC(e,t)(n,r);return vC(n,r,n.constant(Kd),n.array(i.arbitrary).map(Gd))}}function uC(e,t){let n=yn(oC(e,t));return(e,t)=>n(e.reasons,t.reasons)}function dC(e,t){let n=sC(e,t);return e=>`Cause([${e.reasons.map(n).join(`, `)}])`}var fC=e=>e?.includeStack===!0|(e?.excludeCause===!0?2:0),pC=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},mC=[];function hC(e){let t=fC(e),n=mC[t];if(n!==void 0)return n;let r=ew.pipe(B(dS,ev(pC(t))));return mC[t]=r,r}function gC(e,t,n){return P(Rx()([e,t,n],([e,t,n])=>{let r=cC(t,n);return(t,n,i)=>{if(!sf(t))return j(new Mg(n,t,i));switch(t._tag){case`Success`:return og(ax(e)(t.value,i),{onSuccess:cf,onFailure:e=>Pg(n,`value`,e,t,i)});case`Failure`:return og(ax(r)(t.cause,i),{onSuccess:lf,onFailure:e=>Pg(n,`cause`,e,t,i)})}}},{representation:{id:`effect/schema/Exit`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Exit(${e[0].runtime}, ${e[1].runtime}, ${e[2].runtime})`,Type:`Exit.Exit<${e[0].Type}, ${e[1].Type}, ${e[2].Type}>`,importDeclarations:[`import * as Exit from "effect/Exit"`]}),expected:`Exit`,toCodec:([e,t,n])=>LS()(R([I({_tag:lS(`Success`),value:e}),I({_tag:lS(`Failure`),cause:cC(t,n)})]),H_({decode:e=>e._tag===`Success`?cf(e.value):lf(e.cause),encode:e=>ff(e)?{_tag:`Success`,value:e.value}:{_tag:`Failure`,cause:e.cause}})),toArbitrary:([e,t,n])=>(r,i)=>{let a=lC(t,n)(r,i);return vC(r,i,_C(r,e.terminal?.map(e=>cf(e)),a.terminal?.map(e=>lf(e))),r.oneof(e.arbitrary.map(e=>cf(e)),a.arbitrary.map(e=>lf(e))))},toEquivalence:([e,t,n])=>{let r=uC(t,n);return(t,n)=>{if(t._tag!==n._tag)return!1;switch(t._tag){case`Success`:return e(t.value,n.value);case`Failure`:return r(t.cause,n.cause)}}},toFormatter:([e,t,n])=>{let r=dC(t,n);return t=>{switch(t._tag){case`Success`:return`Exit.Success(${e(t.value)})`;case`Failure`:return`Exit.Failure(${r(t.cause)})`}}}}).ast,{value:e,error:t,defect:n})}function _C(e,t,n){return t===void 0?n:n===void 0?t:e.oneof(t,n)}function vC(e,t,n,r){return{arbitrary:n===void 0||t.recursion===void 0?r:e.oneof(t.recursion,n,r),terminal:n}}globalThis.RegExp;var yC=F.annotate({expected:`a string that will be decoded as a URL`}),bC=IS(globalThis.URL,{representation:{id:`effect/schema/URL`,payload:null},toCode:()=>({runtime:`Schema.URL`,Type:`globalThis.URL`}),expected:`URL`,toCodecJson:()=>LS()(yC,rv),toArbitrary:()=>e=>e.webUrl().map(e=>new globalThis.URL(e)),toEquivalence:()=>(e,t)=>e.toString()===t.toString()}),xC=yC.pipe(B(bC,rv));function SC(e,t,n){let r={...t};if(e?.minimum!==void 0){let t=n===void 0?e.minimum:n(e.minimum),i=e.exclusiveMinimum?new globalThis.Date(t.getTime()+1):t;(r.min===void 0||i.getTime()>r.min.getTime())&&(r.min=i)}if(e?.maximum!==void 0){let t=n===void 0?e.maximum:n(e.maximum),i=e.exclusiveMaximum?new globalThis.Date(t.getTime()-1):t;(r.max===void 0||i.getTime()<r.max.getTime())&&(r.max=i)}return r}var CC=F.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function wC(e,t){return CC.pipe(B(e,av(t)))}var TC=wC(dS);globalThis.File,globalThis.FormData,globalThis.URLSearchParams;var EC=F.annotate({expected:`a string that will be decoded as a finite number`}).pipe(B(BS,K_)),DC=F.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),OC=IS(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>LS()(DC,iv),toArbitrary:()=>e=>e.uint8Array()}),kC=zx(e=>t_(e)&&n_(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:()=>LS()(F,ov),toArbitrary:()=>(e,t)=>e.date(SC(t?.constraint?.ordered?.order===i_?t.constraint.ordered:void 0,{noInvalidDate:!0},f_)).map(e=>a_(e)),toFormatter:()=>e=>e.toString(),toEquivalence:()=>r_}),AC=F.annotate({expected:`a string that will be decoded as a DateTime.Utc`}).pipe(B(kC,ov)),jC=globalThis.Symbol.for(`immer-draftable`),MC={};function NC(e,t,n,r,i){let a=IC(n,t,r),o=FC(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===MC?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:MC,value:i}})}static[Lx]=Lx;get[o](){return o}static[jC]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return rt(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return new this(e,t)}static makeOption(e,t){return tx(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Oy(this.ast,e))}static annotateKey(e){return this.rebuild(zy(this.ast,e))}static check(...e){return this.rebuild(Ay(this.ast,e))}static extend(e){return(t,r)=>{let a=LC(t)?t:I(t),o={...n.fields,...a.fields},s=Qv(o,n.ast.checks,{identifier:e});return NC(this,e,vS(Ay(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function PC(e){return new R_(C_(t=>new e(t,{"~payload":{token:MC,value:t}})),x_())}function FC(e){return`~effect/Schema/Class/${e}`}function IC(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=FC(t),o=e=>e instanceof i||At(e,a),s=PC(i);return r=B(P(new Cv([e.ast],()=>(e,t,n)=>o(e)?k(e):j(new Mg(t,e,n)),{identifier:t,[pg]:([e])=>({isConstructed:o,link:new vv(e,s)}),toCodec:([e])=>new vv(e.ast,s),toArbitrary:([e])=>()=>({arbitrary:e.arbitrary.map(e=>new i(e)),terminal:e.terminal?.map(e=>new i(e))}),toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[fg]:iy(e.ast),...n})),s)(e)}}function LC(e){return iS(e)}var H=e=>(t,n)=>NC(os,e,LC(t)?t:I(t),n,e=>({toString(){return`${e}(${An({...this})})`}})),U=e=>(t,n,r)=>{let i=LC(n)?n.mapFields(e=>({_tag:PS(t),...e}),{unsafePreserveChecks:!0}):FS(t,n);return H(e??t)(i,r)},RC=e=>(t,n)=>NC(Nr,e,LC(t)?t:I(t),n,e=>({name:e})),zC=e=>(t,n,r)=>{let i=LC(n)?n.mapFields(e=>({_tag:PS(t),...e}),{unsafePreserveChecks:!0}):FS(t,n);return RC(e??t)(i,r)};function BC(e){return P(VC(e.ast),{schema:e})}var VC=Fy(e=>{let t=KC(e,VC),n=e.context;return t===e||n===void 0?t:Py(t,HC(n))});function HC(e){return e.constructorDefault===void 0?e:new bv(e.isOptional,e.isMutable,void 0,e.annotations)}function UC(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function WC(e){return t=>{let n=new Map;for(let e=0;e<t.length;e++)n.set(Zy(t[e]),e);let r=[...t].sort((t,r)=>{t=Zy(t),r=Zy(r);let i=e(t),a=e(r);return i===a?n.get(t)-n.get(r):i-a});return r.some((e,n)=>e!==t[n])?r:t}}var GC=WC(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function KC(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Ct(n))return Ey(e,[Sb]);let r=n(e.typeParameters.map(e=>wx(Zy(e))));return r===void 0?e:Ey(e,[jy(r,t)])}case`Unknown`:return Ey(e,[Sb]);case`ObjectKeyword`:return Ey(e,[Cb]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return UC(e),e.recur(t,ib);case`Union`:{let n=GC(e.types);return n===e.types?e.recur(t):new uy(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}function qC(e){return P($C(e.ast),{schema:e})}var JC=WC(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function YC(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>P(t(Zy(e)))),i=e.annotations?.toCodecStringTree;if(Ct(i)){let n=i(r);return n===void 0?e:Ey(e,[jy(n,t)])}let a=e.annotations?.toCodecJson,o=Ct(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(Ct(s)?s(r):void 0);return c===void 0?n(e):Ey(e,[jy(c,t)])}case`Null`:return Ey(e,[XC]);case`Boolean`:return Ey(e,[ZC]);case`Unknown`:case`ObjectKeyword`:return Ey(e,[Tb]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return UC(e),e.recur(t,ib);case`Union`:{let n=JC(e.types);return n===e.types?e.recur(t):new uy(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var XC=new vv(new jv(`null`),new R_(C_(()=>null),C_(()=>`null`))),ZC=new vv(new uy([new jv(`true`),new jv(`false`)],`anyOf`),new R_(C_(e=>e===`true`),O_())),QC=new R_(C_(e=>typeof e==`string`?[e]:e),x_()),$C=Fy(e=>{let t=YC(e,$C,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})});return t!==e&&e.context!==void 0?Py(t,HC(e.context)):t},{stopAt:e=>e.transformation===QC}),ew=P(Oy(xb,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),tw=xS(F,ew),nw=e=>()=>{let t=Jx(wS(e));return Lb((e,n)=>k(M(e,e=>t(e))))},rw=`~effect/Stream`,iw={_R:C,_E:C,_A:C},aw={[rw]:iw,pipe(){return rt(this,arguments)}},ow=e=>{let t=Object.create(aw);return t.channel=e,t},sw=`~effect/Stream`,cw=e=>At(e,sw),lw=ow,uw=(e,t)=>lw(Lb((n,r)=>M($b(e.channel,r),e=>t(e,r)))),dw=e=>lw(Hb(()=>e().channel)),fw=e=>lw(Ub(e)),pw=e=>lw(Wb(e)),mw=S(2,(e,t)=>dw(()=>{let n=0;return lw(Kb(e.channel,ha(e=>t(e,n++))))})),hw=S(2,(e,t)=>lw(qb(e.channel,t))),gw=S(e=>cw(e[0]),(e,t)=>dw(()=>{let n=new TextDecoder(t?.encoding);return mw(e,e=>n.decode(e,{stream:!0}))})),_w=S(2,(e,t)=>lw(Yb(e.channel,t))),vw=S(2,(e,t)=>lw(Zb(e.channel,t))),yw=S(2,(e,t)=>Qb(e.channel,t)),bw=S(e=>cw(e[0]),(e,t,n)=>{let r,i,a=Ob(!1);return new ReadableStream({start(n){i=Yh(Mh(yw(e,e=>a.whenOpen(th(()=>{a.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0}))),t)),i.addObserver(e=>{e._tag===`Failure`?n.error($d(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return Xh(vh(Eb(i)))}},n?.strategy)}),xw=S(e=>cw(e[0]),(e,t)=>gh(kh(),n=>bw(e,n,t))),Sw=BigInt(1024);Sw*Sw*Sw*Sw*Sw,O()(`effect/platform/FileSystem/WatchBackend`);var Cw={"~effect/match/Match/Matcher":{_input:C,_filters:C,_remaining:C,_result:C,_return:C,_args:C},_tag:`TypeMatcher`,add(e){return ww(this.select,[...this.cases,e])},pipe(){return rt(this,arguments)}};function ww(e,t){let n=Object.create(Cw);return n.select=e,n.cases=t,n}var Tw=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),Ew=S(2,(e,t)=>Ow(t)(ww(C,[]))(e)),Dw=e=>t=>{let n=Tw(n=>n!=null&&Object.hasOwn(t,n[e]),n=>t[n[e]](n));return e=>e.add(n)},Ow=(e=>t=>{let n=Dw(e)(t);return e=>jw(n(e))})(`_tag`),kw=e=>{if(e._tag===`ValueMatcher`)return e.value;let t=e.cases.length;if(t===1){let t=e.cases[0];return(...n)=>{let r=e.select(...n);return t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1?Mi(t.evaluate(r,...n)):Ni(r)}}return(...n)=>{let r=e.select(...n);for(let i=0;i<t;i++){let t=e.cases[i];if(t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1)return Mi(t.evaluate(r,...n))}return Ni(r)}},Aw=`effect/match/Match/exhaustive: absurd`,jw=e=>{let t=kw(e);if(Ii(t)){if(Ri(t))return t.success;throw Error(Aw)}return(...e)=>{let n=t(...e);if(Ri(n))return n.success;throw Error(Aw)}},Mw=Ew,Nw={"~effect/Ref":{_A:C},...$n,toJSON(){return{_id:`Ref`,ref:this.ref}}},Pw=e=>{let t=Object.create(Nw);return t.ref=jb(e),t},Fw=e=>th(()=>Pw(e)),Iw=e=>th(()=>e.ref.current),Lw=S(2,(e,t)=>th(()=>Mb(e.ref,t))),Rw=S(2,(e,t)=>th(()=>{let[n,r]=t(e.ref.current);return e.ref.current=r,n})),zw=S(2,(e,t)=>th(()=>{e.ref.current=t(e.ref.current)})),Bw=S(2,(e,t)=>th(()=>e.ref.current=t(e.ref.current))),Vw=`~effect/SynchronizedRef`,Hw={...$n,[Vw]:Vw,toJSON(){return{_id:`SynchronizedRef`,value:this.backing.ref.current}}},Uw=e=>{let t=Object.create(Hw);return t.semaphore=Nb(1),t.backing=Pw(e),t},Ww=e=>th(()=>Uw(e)),Gw=e=>e.backing.ref.current,Kw=S(2,(e,t)=>e.semaphore.withPermit(eh(()=>gh(t(Gw(e)),([t,n])=>(e.backing.ref.current=n,t))))),qw=F.check(zS(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u,{message:`Expected a full GitHub repo name (owner/name)`})).pipe(z(`RepositoryName`)),Jw=F.check(zS(/^[^\s-]\S*$/u,{message:`Expected a git revision without whitespace or a leading dash`})).pipe(z(`RepositoryRevision`)),Yw=F.check(zS(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/u,{message:`Expected a 40- or 64-character lowercase git object id`})).pipe(z(`CommitSha`)),Xw=e=>{let t=e.indexOf(`/`);return{owner:e.slice(0,t),name:e.slice(t+1)}},Zw=e=>e.toLowerCase(),Qw=V.pipe(z(`EventId`)),$w=V.pipe(z(`DedupKey`)),eT=class extends H(`Event`)({id:Qw,dedupKey:$w,payload:ew,receivedAt:kC}){},tT=V.pipe(z(`LoopName`)),nT=[`none`,`required`],rT=ES(nT),iT=class extends U(`CancelReason/OperatorCanceled`)(`OperatorCanceled`,{}){},aT=class extends U(`CancelReason/Superseded`)(`Superseded`,{by:Qw}){},oT=class extends U(`CancelReason/Revoked`)(`Revoked`,{}){},sT=R([iT,aT,oT]),cT=class extends U(`RunState/Pending`)(`Pending`,{}){},lT=class extends U(`RunState/Waiting`)(`Waiting`,{}){},uT=class extends U(`RunState/Queued`)(`Queued`,{}){},dT=class extends U(`RunState/Running`)(`Running`,{}){},fT=class extends U(`RunState/Succeeded`)(`Succeeded`,{}){},pT=class extends U(`RunState/Failed`)(`Failed`,{}){},mT=class extends U(`RunState/Canceled`)(`Canceled`,{reason:sT}){},hT=R([cT,lT,uT,dT]),gT=R([...hT.members,fT,pT,mT]),_T=R([cT,lT,uT]),vT=R([cT,uT]),yT=Gx(hT),bT=Gx(_T),xT=Gx(vT),ST=()=>(...e)=>e,CT=ST()(`Pending`,`Waiting`,`Queued`,`Running`),wT=ST()(`Pending`,`Waiting`,`Queued`,`Running`,`Succeeded`,`Failed`,`Canceled`),TT=ST()(`Pending`,`Waiting`,`Queued`),ET=e=>new lT,DT=e=>new uT,OT=e=>new dT,kT=e=>new fT,AT=e=>new pT,jT=e=>new dT,MT=e=>new mT({reason:new iT}),NT=(e,t)=>new mT({reason:new aT({by:t})}),PT=e=>new mT({reason:new oT}),FT=V.pipe(z(`RunId`)),IT=class extends H(`Run`)({id:FT,eventId:Qw,loop:tT,state:gT,openedAt:kC}){};function LT(e){return t(e.defaultTagName??`div`,e,e)}var RT=F.check(zS(/\S/u,{message:`Expected a non-blank model id`})).pipe(z(`ModelId`)),zT=ES([`claude`,`codex`,`pi`]),BT=ES([`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),VT=class extends H(`Agent/BrainSpec`)({harness:zT,model:RT,effort:BT}){},HT=F.check(zS(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,{message:`Expected a kebab-case Agent name`})).pipe(z(`AgentName`)),UT=F.check(zS(/\S/u,{message:`Expected a non-blank Agent persona`})).pipe(z(`AgentPersona`)),WT=class extends H(`Agent`)({name:HT,brain:VT,parentModel:eC(RT),parentEffort:tC(BT),persona:UT}){},GT=(e,t)=>vi([e.parentModel,t]),KT=R([class extends U(`StepResult/Commit`)(`Commit`,{sha:Yw,summary:V}){},class extends U(`StepResult/PullRequest`)(`PullRequest`,{number:JS.check(GS(1)),url:xC}){},class extends U(`StepResult/Comment`)(`Comment`,{url:xC}){}]),qT=class extends H(`StepResult`)({message:V,facts:L(KT)}){},JT=V.pipe(z(`StepName`)),YT=class extends H(`Step`)({runId:FT,name:JT,result:$S(qT)}){},XT=F.check(zS(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,{message:`Expected a kebab-case Worker name`})).pipe(z(`WorkerName`)),ZT=ES([`local`,`exe.dev`]),QT=V.pipe(z(`AgentSessionId`)),$T=JS.check(GS(0)).pipe(z(`TokenCount`)),eE=JS.check(GS(1)),tE=eE.pipe(z(`ChildSessionBudget`)),nE=eE.pipe(z(`ChildSessionCount`)),rE=R([class extends U(`Agent/ParentSession`)(`ParentSession`,{id:QT,agent:HT,brain:VT}){},class extends U(`Agent/ChildSession`)(`ChildSession`,{id:QT,parentId:QT,agent:HT,brain:VT}){}]),iE=V.pipe(z(`HarnessSessionId`)),aE=class extends H(`Agent/HarnessSession`)({id:iE,cwd:V}){},oE=class extends U(`Agent/SessionStarted`)(`SessionStarted`,{session:rE,harnessSession:tC(aE).pipe(AS(k(T())))}){},sE=class extends U(`Agent/TextOutput`)(`TextOutput`,{session:rE,text:V}){},cE=class extends U(`Agent/ToolStarted`)(`ToolStarted`,{session:rE,callId:V,tool:V,input:ew}){},lE=class extends U(`Agent/ToolFinished`)(`ToolFinished`,{session:rE,callId:V,tool:V,output:ew,isError:hS}){},uE=class extends U(`Agent/SessionFinished`)(`SessionFinished`,{session:rE}){},dE=class extends U(`Agent/SessionIdle`)(`SessionIdle`,{session:rE}){},fE=class extends U(`Agent/SessionResumed`)(`SessionResumed`,{session:rE}){},pE=class extends U(`Agent/SessionTokensUpdated`)(`SessionTokensUpdated`,{session:rE,totalTokens:$T}){},mE=ES([`apiKeys`,`claudePlan`,`chatgptPlan`]),hE=class extends H(`Agent/RateLimitWindow`)({usedPercent:mS,windowDurationMinutes:eC(mS),resetsAt:eC(AC)}){},gE=class extends H(`Agent/RateLimitsSnapshot`)({limitId:eC(F),limitName:eC(F),primary:eC(hE),secondary:eC(hE)}){},_E=R([oE,sE,cE,lE,class extends U(`Agent/PoolRateLimitsUpdated`)(`PoolRateLimitsUpdated`,{session:rE,pool:mE,rateLimits:gE}){},uE,dE,fE,pE]),vE=class extends zC(`AttemptFailure/InfraFailure`)(`InfraFailure`,{message:F,cause:hC()}){},yE=class extends zC(`AttemptFailure/DefectFailure`)(`DefectFailure`,{message:F,cause:hC()}){},bE=class extends zC(`AttemptFailure/AgentFailure`)(`AgentFailure`,{message:F}){},xE=ES([`wall-clock`,`tokens`]),SE=R([vE,yE,bE,class extends zC(`AttemptFailure/RunawayFailure`)(`RunawayFailure`,{ceiling:xE}){},class extends zC(`AttemptFailure/ChildSessionBudgetFailure`)(`ChildSessionBudgetFailure`,{maxChildren:tE,attemptedChildren:nE}){}]),CE=Gx(vE),wE=class extends U(`AttemptOutcome/Succeeded`)(`Succeeded`,{}){},TE=class extends U(`AttemptOutcome/Failed`)(`Failed`,{failure:SE}){},EE=class extends U(`AttemptOutcome/Canceled`)(`Canceled`,{}){},DE=R([wE,TE,EE]),OE=V.pipe(z(`AttemptId`)),kE=JS.check(GS(1)).pipe(z(`AttemptNumber`)),AE=F.check(zS(/\S/u,{message:`Expected non-blank task text`})).pipe(z(`AttemptTask`));H(`AttemptContext`)({task:AE,agent:WT,parentModel:eC(RT)});var jE=class extends H(`Attempt`)({id:OE,runId:FT,stepName:JT,worker:XT,number:kE,brain:VT,task:AE,agent:HT,operatorIntervened:hS,parentModel:eC(RT),startedAt:kC,outcome:$S(DE)}){},ME=e=>CE(e.failure)&&e.number<e.maxAutoAttempts,NE=V.pipe(z(`ItemKey`)),PE=JS.check(GS(1)).pipe(z(`ItemNumber`)),FE=JS.check(GS(1)).pipe(z(`CycleLimit`)),IE=JS.check(GS(0)).pipe(z(`CycleGeneration`)),LE=FE.make(3),RE=JS.check(GS(0)).pipe(z(`CycleCount`)),zE=class extends H(`LoopCycleCount`)(I({loop:tT,admitted:RE,completed:RE}).check(RS(({admitted:e,completed:t})=>t<=e,{message:`Completed Runs cannot exceed admitted Runs`})).annotate({parseOptions:{onExcessProperty:`error`}})){},BE=Qw.pipe(z(`CycleBudgetAskId`)),VE=class extends H(`CycleBudgetAsk`)(I({id:BE,itemKey:NE,repository:qw,loop:tT,limit:FE,counts:wS(zE)}).check(RS(({loop:e,limit:t,counts:n})=>new Set(n.map(e=>e.loop)).size===n.length&&n.some(n=>n.loop===e&&n.admitted>=t),{message:`Expected unique participating Loops including the exhausted Loop at its limit`})).annotate({parseOptions:{onExcessProperty:`error`}})){get completedCycles(){return RE.make(Math.max(...this.counts.map(({completed:e})=>e)))}},HE=JS.check(GS(1)).pipe(z(`AttemptChannelSequence`)),UE=[`inbound`,`outbound`],WE=ES(UE),GE=class extends H(`AttemptChannel/RunSpec`)({attemptId:OE,repository:qw,revision:Jw,baseCommit:Yw,payload:ew,task:AE,agent:WT,parentModel:eC(RT),maxChildren:tE,parentEffort:BT}){},KE=class extends U(`AttemptChannel/Started`)(`Started`,{parentModel:RT}){},qE=class extends U(`AttemptChannel/SessionEvent`)(`SessionEvent`,{event:_E}){},JE=class extends U(`AttemptChannel/Final`)(`Final`,{result:qT}){},YE=class extends U(`AttemptChannel/Failed`)(`Failed`,{failure:SE}){},XE=class extends U(`AttemptChannel/Interrupted`)(`Interrupted`,{}){},ZE=class extends U(`AttemptChannel/Steer`)(`Steer`,{message:V}){},QE=class extends U(`AttemptChannel/Interrupt`)(`Interrupt`,{}){},$E=class extends U(`AttemptChannel/Cancel`)(`Cancel`,{}){},eD=class extends U(`AttemptChannel/OperatorMessage`)(`OperatorMessage`,{message:V}){},tD=class extends U(`AttemptChannel/Release`)(`Release`,{}){},nD=R([ZE,QE,eD,tD]),rD=R([nD,$E]),iD=class extends U(`AttemptChannel/ParentTarget`)(`Parent`,{}){},aD=class extends U(`AttemptChannel/ChildTarget`)(`Child`,{sessionId:QT}){},oD=R([iD,aD]),sD=class extends H(`AttemptChannel/Intervention`)({operator:V,target:oD,action:nD}){},cD=class extends H(`AttemptChannel/InterventionState`)({held:hS,paused:hS}){},lD=class extends U(`AttemptChannel/InterventionApplied`)(`InterventionApplied`,{inputSequence:HE,intervention:sD,state:cD}){},uD=class extends U(`AttemptChannel/InterventionRejected`)(`InterventionRejected`,{inputSequence:HE,intervention:sD,message:V}){},dD=R([KE,qE,JE,YE,XE,lD,uD]),fD={version:lS(6),attemptId:OE,sequence:HE,sentAt:AC},pD=class extends U(`AttemptChannel/OutboundEnvelope`)(`OutboundEnvelope`,{...fD,payload:dD}){},mD=class extends U(`AttemptChannel/InboundEnvelope`)(`InboundEnvelope`,{...fD,target:oD.pipe(MS(k({_tag:`Parent`}))),operator:V,payload:rD}){},hD=R([pD,mD]),gD=R([class extends U(`AttemptChannel/Start`)(`Start`,{version:lS(6),spec:GE}){},mD]);wC(hD),wC(gD),wC(pD);var _D=JS.check(GS(1)).pipe(z(`TranscriptSequence`)),vD=ES([3,4]),yD=I({...pD.fields,version:vD}),bD=I({_tag:lS(`InboundEnvelope`),version:vD,attemptId:OE,sequence:HE,sentAt:AC,payload:R([ZE,QE])}),xD=R([hD,I({...pD.fields,version:lS(5)}),I({...mD.fields,version:lS(5)}),yD,bD]),SD=class extends H(`@usine/engine/TranscriptEntry`)({sequence:_D,attemptId:OE,direction:WE,envelope:xD,receivedAt:kC}){};R([class extends U(`@usine/engine/TranscriptAllQuery`)(`TranscriptAllQuery`,{attemptId:OE}){},class extends U(`@usine/engine/TranscriptSessionsQuery`)(`TranscriptSessionsQuery`,{attemptId:OE}){},class extends U(`@usine/engine/TranscriptTailQuery`)(`TranscriptTailQuery`,{attemptId:OE,after:_D,limit:JS.check(GS(1))}){},class extends U(`@usine/engine/TranscriptPageQuery`)(`TranscriptPageQuery`,{attemptId:OE,before:$S(_D),limit:JS.check(GS(1))}){}]);var CD=`~effect/http/UrlParams`,wD=e=>At(e,CD),TD={...$n,[CD]:CD,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[Zt](e){return kD(this,e)},[Nt](){return Wt(this.params.flat())}},ED=e=>{let t=Object.create(TD);return t.params=e,t},DD=e=>{if(wD(e))return e;let t=OD(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return ED(n)},OD=e=>{let t=typeof e[Symbol.iterator]==`function`?Xi(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,String(r[t])]);else if(typeof r==`object`){let t=OD(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,String(r)]);return n},kD=hn((e,t)=>AD(e.params,t.params)),AD=ga(Ui([_n(),_n()])),jD=zx(wD,{representation:{id:`effect/http/UrlParams`,payload:null},toCode:()=>({runtime:`UrlParams.UrlParamsSchema`,Type:`UrlParams.UrlParams`,importDeclarations:[`import * as UrlParams from "effect/unstable/http/UrlParams"`]}),expected:`UrlParams`,toEquivalence:()=>kD,toCodec:()=>LS()(L(CS([F,F])),H_({decode:ED,encode:e=>e.params}))}),MD=ED([]),ND=S(2,(e,t)=>ED(t(e.params))),PD=S(2,(e,t)=>{let n=DD(t),r=n.params,i=new Set;for(let e=0;e<r.length;e++)i.add(r[e][0]);for(let t=0;t<e.params.length;t++)i.has(e.params[t][0])||r.push(e.params[t]);return n}),FD=S(2,(e,t)=>ND(e,ea(DD(t).params))),ID=e=>new URLSearchParams(DD(e).params).toString(),LD=jD.pipe(B(xS(F,R([F,wS(F)])),H_({decode:e=>{let t={};for(let[n,r]of e.params)if(!Object.hasOwn(t,n))xn(t,n,r);else{let e=t[n];typeof e==`string`?xn(t,n,[e,r]):e.push(r)}return t},encode:DD}))),RD=`~effect/http/HttpBody`,zD=e=>At(e,RD);cs(`HttpBodyError`);var BD=class{[RD];constructor(){this[RD]=RD}[Ln](){return this.toJSON()}toString(){return An(this,{ignoreToString:!0})}},VD=new class extends BD{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},HD=class extends BD{_tag=`Uint8Array`;body;contentType;contentLength;constructor(e,t,n){super(),this.body=e,this.contentType=t,this.contentLength=n}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},UD=(e,t)=>new HD(e,t??`application/octet-stream`,e.length),WD=new TextEncoder,GD=(e,t)=>UD(WD.encode(e),t??`text/plain`),KD=(e,t)=>GD(JSON.stringify(e),t??`application/json`),qD=(e,t)=>GD(ID(DD(e)),t??`application/x-www-form-urlencoded`),JD=class extends BD{_tag=`FormData`;contentType=void 0;contentLength=void 0;formData;constructor(e){super(),this.formData=e}toJSON(){return{_id:`effect/HttpBody`,_tag:`FormData`,formData:this.formData}}},YD=e=>new JD(e),XD=Symbol.for(`~effect/http/Headers`),ZD=Object.defineProperties(Object.create(null),{[XD]:{value:XD},[Cn]:{value(e){return sO(this,co(e,lO))}},toJSON:{value(){return Tn(this)}},[Zt]:{value(e){return $D(this,e)}},[Nt]:{value(){return Ht(this)}},toString:{value:Bn.toString},[Ln]:{value:Bn[Ln]}}),QD=e=>Object.assign(Object.create(ZD),e),$D=Ji(_n()),eO=Object.create(ZD),tO=e=>{if(e===void 0)return eO;if(Symbol.iterator in e){let t=Object.create(ZD);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(ZD);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},nO=e=>Object.setPrototypeOf(e,ZD),rO=S(3,(e,t,n)=>{let r=QD(e);return r[t.toLowerCase()]=n,r}),iO=S(2,(e,t)=>QD({...e,...tO(t)})),aO=S(2,(e,t)=>{let n=QD(e);return Object.assign(n,t),n}),oO=S(2,(e,t)=>{let n=QD(e);return delete n[t.toLowerCase()],n}),sO=S(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=Nx(e[r]))}else for(let r in e)t.test(r)&&(n[r]=Nx(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),cO=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r==`string`){if(r.toLowerCase()===e)return!0}else if(r.test(e))return!0}return!1},lO=go(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),uO=`~effect/http/Cookies`,dO=`~effect/http/Cookies/Cookie`;cs(`CookieError`);var fO={[uO]:uO,...Bn,toJSON(){return{_id:`effect/Cookies`,cookies:Gi(this.cookies,e=>e.toJSON())}},pipe(){return rt(this,arguments)}},pO=e=>{let t=Object.create(fO);return t.cookies=e,t},mO=e=>{let t={};for(let n of e)xn(t,n.name,n);return pO(t)},hO=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=gO(e.trim());t&&n.push(t)}return mO(n)};function gO(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n);if(!_O.test(r))return;let i=t[0].slice(n+1),a=yO(i);if(t.length===1)return Object.assign(Object.create(vO),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:{if(a===void 0)break;let e=parseInt(a,10);isNaN(e)||(o.maxAge=Bo(e));break}case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`}}}return Object.assign(Object.create(vO),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var _O=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,vO={[dO]:dO,...Bn,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},yO=e=>{try{return decodeURIComponent(e)}catch{return e}},bO=`~effect/http/HttpClientError`,xO=class extends cs(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[bO]=bO;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},SO=e=>e.endsWith(`Error`)?e.slice(0,-5):e,CO=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,wO=class extends cs(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return CO(SO(this._tag),this.description,this.methodAndUrl)}};cs(`EncodeError`);var TO=class extends cs(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return CO(SO(this._tag),this.description,this.methodAndUrl)}},EO=class extends cs(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return CO(SO(this._tag),this.description,e)}},DO=class extends cs(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return CO(SO(this._tag),this.description,e)}},OO=class extends cs(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return CO(SO(this._tag),this.description,e)}};RC(bO)({_tag:PS(`HttpError`),kind:ES([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:oS(hC())});var kO=e=>e!==`GET`&&e!==`HEAD`&&e!==`OPTIONS`&&e!==`TRACE`,AO=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],jO=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?oO(oO(e,`content-type`),`content-length`):(e=t.contentType===void 0?oO(e,`content-type`):rO(e,`content-type`,t.contentType),t.contentLength===void 0?oO(e,`content-length`):rO(e,`content-length`,t.contentLength.toString())),MO=class extends cs(`UrlError`){},NO=(e,t,n)=>Fi({try:()=>{let r=new URL(e,PO());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),r},catch:e=>new MO({cause:e})}),PO=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},FO=`~effect/http/HttpClientRequest`,IO={[FO]:FO,...Bn,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Tn(this.headers),body:this.body.toJSON()}},pipe(){return rt(this,arguments)}};function LO(e,t,n,r,i,a){let o=Object.create(IO);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var RO=LO(`GET`,``,MD,T(),eO,VD),zO=e=>(t,n)=>HO(RO,{method:e,url:t,...n??void 0}),BO=zO(`GET`),VO=zO(`POST`),HO=S(2,(e,t)=>{let n=e;return t.method&&(n=UO(n,t.method)),t.url&&(n=JO(n,t.url)),t.headers&&(n=GO(n,t.headers)),t.urlParams&&(n=ZO(n,t.urlParams)),t.hash&&(n=$O(n,t.hash)),t.body&&(n=ek(n,t.body)),t.accept&&(n=KO(n,t.accept)),t.acceptJson&&(n=qO(n)),n}),UO=S(2,(e,t)=>LO(t,e.url,e.urlParams,e.hash,e.headers,e.body)),WO=S(3,(e,t,n)=>LO(e.method,e.url,e.urlParams,e.hash,rO(e.headers,t,n),e.body)),GO=S(2,(e,t)=>LO(e.method,e.url,e.urlParams,e.hash,iO(e.headers,t),e.body)),KO=S(2,(e,t)=>WO(e,`Accept`,t)),qO=KO(`application/json`),JO=S(2,(e,t)=>{if(typeof t==`string`)return LO(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=DD(n.searchParams),i=yi(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,LO(e.method,n.toString(),r,i,e.headers,e.body)}),YO=S(2,(e,t)=>t===``?e:LO(e.method,XO(t,e.url),e.urlParams,e.hash,e.headers,e.body)),XO=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},ZO=S(2,(e,t)=>LO(e.method,e.url,PD(e.urlParams,t),e.hash,e.headers,e.body)),QO=S(2,(e,t)=>LO(e.method,e.url,FD(e.urlParams,t),e.hash,e.headers,e.body)),$O=S(2,(e,t)=>LO(e.method,e.url,e.urlParams,E(t),e.headers,e.body)),ek=S(2,(e,t)=>LO(e.method,e.url,e.urlParams,e.hash,jO(e.headers,t),t)),tk=S(2,(e,t)=>ek(e,KD(t))),nk=S(2,(e,t)=>ek(e,YD(t))),rk=`~effect/http/HttpIncomingMessage`,ik=(e,t)=>{let n=Jx(BC(e)),r=t?.reviver===void 0?void 0:Jx(wC(BC(e),t));return e=>r===void 0?M(e.json,e=>n(e,t)):M(e.text,i=>i===``?M(e.json,e=>n(e,t)):r(i,t))},ak=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=Zh(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=Zh(e.text)}catch{}let i={...t,headers:Tn(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},ok=`~effect/http/HttpClientResponse`,sk=(e,t)=>new lk(e,t),ck=S(2,(e,t)=>{let n=e.status;return t[n]?t[n](e):n>=200&&n<300&&t[`2xx`]?t[`2xx`](e):n>=300&&n<400&&t[`3xx`]?t[`3xx`](e):n>=400&&n<500&&t[`4xx`]?t[`4xx`](e):n>=500&&n<600&&t[`5xx`]?t[`5xx`](e):t.orElse(e)}),lk=class extends Vn{[rk];[ok];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[rk]=rk,this[ok]=ok}toJSON(){return ak(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return tO(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=hO(this.source.headers.getSetCookie())}get remoteAddress(){return T()}get stream(){return this.source.body?pw({evaluate:()=>this.source.body,onError:e=>new xO({reason:new DO({request:this.request,response:this,cause:e})})}):fw(new xO({reason:new OO({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return M(this.text,e=>ch({try:()=>e===``?null:JSON.parse(e),catch:e=>new xO({reason:new DO({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=gh(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return M(this.text,e=>ch({try:()=>DD(new URLSearchParams(e)),catch:e=>new xO({reason:new DO({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=Qm({try:()=>this.source.formData(),catch:e=>new xO({reason:new DO({request:this.request,response:this,cause:e})})}).pipe(Bh,Zh)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=Qm({try:()=>this.source.arrayBuffer(),catch:e=>new xO({reason:new DO({request:this.request,response:this,cause:e})})}).pipe(Bh,Zh),this.arrayBufferBody}pipe(){return rt(this,arguments)}};({...$n}),cs(`HttpServerError`),cs(`RequestParseError`),cs(`RouteNotFound`),cs(`InternalError`),cs(`ResponseError`),cs(`ServeError`),O()(`effect/http/HttpServerError/ClientAbort`);var uk=new Uint8Array(256);for(let e of"!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")uk[e.charCodeAt(0)]=1;var dk=new Uint8Array(256);dk[9]=1;for(let e=32;e<=126;e++)dk[e]=1;for(let e=128;e<=255;e++)dk[e]=1;cs(`MultipartError`);var fk=O(`effect/http/HttpServerRequest`);O()(`effect/http/ParsedSearchParams`);var pk=e=>nO({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${gi(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),mk=new WeakSet,hk=e=>uh(t=>{let n=so(t.context,fk);return mk.add(n.source),e}),gk=`~effect/http/HttpClient`,_k=O(`effect/HttpClient`),vk=S(2,(e,t)=>yk(n=>t(e.postprocess(n)),e.preprocess)),yk=(e,t)=>{let n=Object.create(bk);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},bk={[gk]:gk,pipe(){return rt(this,arguments)},...Bn,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(AO.map(([e,t])=>[t,function(t,n){return this.execute(zO(e)(t,n))}]))},xk=e=>yk(t=>M(t,t=>uh(n=>{let r=kk.get(t),i=r??new AbortController,a=NO(t.url,t.urlParams,Ci(t.hash));if(Li(a))return j(new xO({reason:new TO({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(ks)||n.getRef(Ck)(t)){let a=e(t,o,i.signal,n);return r?a:Uh(e=>Oh(e(a),{onSuccess(e){return Ok.register(e,i),k(new Ak(e,i))},onFailure(e){return tf(e)&&i.abort(),ah(e)}}))}return Kh(n.getRef(Ek)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(lO),l=n.getRef(wk);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,cO(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(Tk)?GO(t,pk(a)):t,Uh(s=>s(e(t,o,i.signal,n)).pipe(Jh(a,{captureStackTrace:!1}),Oh({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,cO(t,c)?`<redacted>`:e.headers[t]);return r?k(e):(Ok.register(e,i),k(new Ak(e,i)))},onFailure(e){return!r&&tf(e)&&i.abort(),ah(e)}})))})})),k),Sk=S(2,(e,t)=>yk(e.postprocess,n=>gh(e.preprocess(n),t))),Ck=go(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>ct}),wk=go(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>st}),Tk=go(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:st}),Ek=go(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),Dk=e=>Gf(_k)(Ah(t=>gh(e,e=>vk(e,Ph(e=>mo(t,e)))))),Ok=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),kk=new WeakMap,Ak=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[ok]=ok;[rk]=rk;applyInterrupt(e){return eh(()=>(Ok.unregister(this.original),Hh(e,()=>th(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return dw(()=>(Ok.unregister(this.original),_w(this.original.stream,th(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Ln](){return this.original[Ln]()}pipe(){return rt(this,arguments)}},jk=O(`effect/http/HttpRouter`);O()(`effect/http/HttpRouter/RouteContext`);var Mk=e=>e.endsWith(`/`)?e.slice(0,-1):e,Nk=S(2,(e,t)=>(t=Mk(t),e===`*`?`${t}/*`:e===`/`?t:t+e)),Pk=`~effect/http/HttpRouter/Middleware`,Fk=function(){return arguments.length===0?Ik:Ik(arguments[0],arguments[1])},Ik=(e,t)=>t?.global?Jf(A(function*(){let t=yield*jk,n=Jm(e)?yield*e:e;yield*t.addGlobalMiddleware(n)})):new zk(Jm(e)?qf(gh(e,e=>Ya(new Map([[Rk,e]])))):Wf(Ya(new Map([[Rk,e]])))),Lk=0,Rk=`effect/http/HttpRouter/MiddlewareFn`,zk=class e{[Pk]={};layerFn;dependencies;constructor(e,t){this.layerFn=e,this.dependencies=t;let n=`effect/http/HttpRouter/Middleware-${++Lk}`;this.layer=qf(A({self:this},function*(){let e=yield*kh(),t=[oo(e,Rk)];if(this.dependencies){let n=yield*Bf,r=co(e,Sf),i=yield*Vf(this.dependencies,n,r);t.push(...Vk(i))}return Ya(new Map([[n,t]]))})).pipe(Qf(this.layerFn))}layer;combine(t){return new e(this.layerFn,this.dependencies?$f(this.dependencies,t.layer):t.layer)}},Bk=new WeakMap,Vk=e=>{let t=Bk.get(e);if(t)return t;let n=pa(),r=0;for(let[t,i]of e.mapUnsafe)t.startsWith(`effect/http/HttpRouter/Middleware-`)&&(n.push(i),i.length>r&&(r=i.length));if(n.length===0)t=[];else{let e=new Set;for(let t=r-1;t>=0;t--)for(let r of n)t<r.length&&e.add(r[t]);t=Xi(e).reverse()}return Bk.set(e,t),t};Fk(hk).layer;var Hk={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,OK:200,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511},Uk=e=>Hk[e],Wk=`~effect/httpapi/HttpApiSchema/Stream`;function Gk(e){let t=typeof e==`string`?Uk(e):e;return e=>e.annotate({httpApiStatus:t})}var Kk=(e=>_S.pipe(Gk(e)))(204),qk=e=>iS(e)&&At(e,Wk),Jk=e=>qk(e)&&e._tag===`StreamSse`,Yk=e=>qk(e)&&e._tag===`StreamUint8Array`,Xk=`~effect/httpapi/HttpApiSchema/WithHeaders`,Zk=`~effect/httpapi/HttpApiSchema/WithHeadersValue`,Qk=e=>({[Zk]:Zk,body:e.body,headers:e.headers}),$k=e=>iS(e)&&At(e,`~effect/httpapi/HttpApiSchema/WithHeaders`);function eA(e,t,n){return P(e.ast,{[Xk]:Xk,schema:t,headers:n})}function tA(e,t){return e.annotate({"~httpApiEncoding":{_tag:t._tag,contentType:t.contentType??nA(t._tag)}})}function nA(e){switch(e){case`Multipart`:return`multipart/form-data`;case`Json`:return`application/json`;case`FormUrlEncoded`:return`application/x-www-form-urlencoded`;case`Uint8Array`:return`application/octet-stream`;case`Text`:return`text/plain`}}function rA(e){return t=>tA(t,{_tag:`FormUrlEncoded`,...e})}var iA=e=>{if(uv(e)||uv(Zy(e)))return!0;let t=e.encoding?.[0].to;return t!==void 0&&uv(t)},aA=gb(`~httpApiEncoding`),oA=gb(`~httpApiWithHeaders`),sA=gb(`httpApiStatus`),cA={_tag:`Json`,contentType:`application/json`},lA={_tag:`FormUrlEncoded`,contentType:`application/x-www-form-urlencoded`};function uA(e){return aA(e)??cA}function dA(e,t){return aA(e)||(kO(t)?cA:lA)}function fA(e){let t=uA(e);if(t._tag===`Multipart`)throw Error(`Multipart is not supported in response`);return t}function pA(e){return sA(e)??200}function mA(e){return $k(e)?sA(e.ast)??pA(e.schema.ast):pA(e.ast)}function hA(e){return $k(e)&&aA(e.ast)===void 0?fA(e.schema.ast):fA(e.ast)}function gA(e){return sA(e)??500}function _A(e){return $k(e)?sA(e.ast)??gA(e.schema.ast):gA(e.ast)}function vA(e){let t=e.toLowerCase().trim(),n=t.indexOf(`;`);return n===-1?t:t.slice(0,n).trim()}var yA=`~effect/httpapi/HttpApiEndpoint`;function bA(e){let t=[];for(let{schemas:n}of e.payload.values())t.push(...n);return t}function xA(e){let t=Array.from(e.success);return ta(t)?t:[Kk]}function SA(e){let t=new Set(e.error);for(let n of e.middlewares){let e=n;for(let n of e.error)t.add(n)}return Array.from(t)}var CA={[yA]:yA,pipe(){return rt(this,arguments)},prefix(e){return TA({...wA(this),path:Nk(this.path,e)})},middleware(e){return TA({...wA(this),middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return TA({...wA(this),annotations:ro(this.annotations,e,t)})},annotateMerge(e){return TA({...wA(this),annotations:mo(this.annotations,e)})}},wA=e=>({identifier:e.identifier,path:e.path,method:e.method,params:e.params,query:e.query,headers:e.headers,payload:e.payload,success:e.success,error:e.error,annotations:e.annotations,middlewares:e.middlewares});function TA(e){function t(){}return Object.setPrototypeOf(t,CA),Object.assign(t,e)}var EA=e=>(t,n,r)=>{let i=r?.disableCodecs??!1,a=i?C:qC;return TA({identifier:t,path:n,method:e,params:DA(r?.params,a),query:DA(r?.query,a),headers:DA(r?.headers,a),payload:OA(r?.payload,e,i),success:AA(r?.success,e,i),error:MA(r?.error,i),annotations:eo(),middlewares:new Set})};function DA(e,t){if(e!==void 0)return iS(e)?t(e):t(I(e))}function OA(e,t,n){let r=new Map;if(e===void 0)return r;let i=Array.isArray(e)?e:iS(e)?[e]:[I(e).pipe(rA())],a=n?C:HA;for(let e of i){let n=dA(e.ast,t),i=vA(n.contentType),o=r.get(i);if(o){if(o.encoding._tag!==n._tag)throw Error(`Multiple payload encodings for content-type: ${n.contentType}`);if(o.encoding._tag===`Multipart`)throw Error(`Multiple multipart payloads for content-type: ${n.contentType}`);o.schemas.push(a(e,t))}else r.set(i,{encoding:n,schemas:[a(e,t)]})}return r}var kA=`effect/httpapi/stream/failure`;function AA(e,t,n){if(e===void 0)return new Set;let r=Zi(e);return NA(r,t),new Set(n?r:r.map(jA))}function jA(e){return qk(e)?e:$k(e)?eA(e,qk(e.schema)?e.schema:VA(e.schema,hA(e)),qC(e.headers)):BA(e)}function MA(e,t){if(e===void 0)return new Set;let n=Zi(e);for(let e of n)if(qk($k(e)?e.schema:e))throw Error(`Streaming schemas are not supported in error responses`);return FA(n,_A),new Set(t?n:n.map(jA))}function NA(e,t){let n=!1,r=new Map;for(let i of e){let e=$k(i)?i.schema:i,a=mA(i);if(qk(e)){if(IA(e,t),n)throw Error(`Multiple streaming success responses are not supported`);n=!0;let i=PA(r,a);if(i.noContent)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);if(i.bufferedContentTypes.has(vA(e.contentType)))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`);r.set(a,{...i,stream:e})}else{let t=PA(r,a),n=iA(e.ast);if(t.stream!==void 0){if(n)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);let e=hA(i);if(vA(e.contentType)===vA(t.stream.contentType))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`)}n||t.bufferedContentTypes.add(vA(hA(i).contentType)),t.noContent=t.noContent||n}}FA(e,mA)}function PA(e,t){let n=e.get(t);return n===void 0&&(n={bufferedContentTypes:new Set,noContent:!1},e.set(t,n)),n}function FA(e,t){let n=new Map;for(let r of e){let e=t(r),i=oA(r.ast),a=$k(r)?r.schema:i?.body??r,o=iA(a.ast)?``:vA(qk(a)?a.contentType:hA(r).contentType),s=n.get(e);s===void 0&&(s={headerContentType:void 0,plainContentTypes:new Set},n.set(e,s));let c=()=>Error(`Cannot combine a response with headers with another response for status ${e} and content-type: ${o||`<no content>`}`);if($k(r)||i!==void 0){if(s.headerContentType!==void 0)throw Error(`Cannot declare multiple responses with headers for status ${e}`);if(s.plainContentTypes.has(o))throw c();s.headerContentType=o}else{if(s.headerContentType===o)throw c();s.plainContentTypes.add(o)}}}function IA(e,t){if(t===`HEAD`)throw Error(`HEAD endpoints cannot declare streaming success responses`);if(Jk(e)&&LA(e.events.ast))throw Error(`SSE event name is reserved: ${kA}`)}function LA(e){return RA(Zy(e),new Set)}function RA(e,t){if(t.has(e))return!1;if(t.add(e),gv(e))return e.types.some(e=>RA(e,t));if(_v(e))return RA(e.thunk(),t);if(!hv(e))return!1;let n=e.propertySignatures.find(e=>e.name===`event`);return n!==void 0&&zA(n.type,t)}function zA(e,t){if(t.has(e))return!1;t.add(e);let n=Zy(e);return n===e?fv(e)?e.literal===kA:gv(e)?e.types.some(e=>zA(e,t)):_v(e)?zA(e.thunk(),t):!1:zA(n,t)}function BA(e){let t=fA(e.ast),n=oA(e.ast);if(n===void 0)return VA(e,t);let r=cS(n.headers);return I({body:VA(cS(n.body),t),headers:r}).pipe(B(e)).annotate({"~httpApiWithHeaders":{...n,headersCodec:qC(r)}})}function VA(e,t){switch(t._tag){case`Json`:return BC(e);case`FormUrlEncoded`:return qC(e);case`Text`:case`Uint8Array`:return e}}function HA(e,t){switch(dA(e.ast,t)._tag){case`Json`:return BC(e);case`FormUrlEncoded`:return qC(e);case`Text`:case`Uint8Array`:case`Multipart`:return e}}var UA=EA(`GET`),WA=EA(`POST`),GA=`~effect/httpapi/HttpApi`,KA={[GA]:GA,pipe(){return rt(this,arguments)},add(...e){let t={...this.groups};for(let n of e)xn(t,n.identifier,n);return JA({...qA(this),groups:t})},addHttpApi(e){let t={...this.groups};for(let n of Object.keys(e.groups)){let r=e.groups[n];xn(t,n,r.annotateMerge(mo(e.annotations,r.annotations)))}return JA({...qA(this),groups:t})},prefix(e){return JA({...qA(this),groups:Gi(this.groups,t=>t.prefix(e))})},middleware(e){return JA({...qA(this),groups:Gi(this.groups,t=>t.middleware(e))})},annotate(e,t){return JA({...qA(this),annotations:ro(this.annotations,e,t)})},annotateMerge(e){return JA({...qA(this),annotations:mo(this.annotations,e)})}},qA=e=>({identifier:e.identifier,groups:e.groups,annotations:e.annotations}),JA=e=>{function t(){}return Object.setPrototypeOf(t,KA),Object.assign(t,e)},YA=e=>JA({identifier:e,groups:{},annotations:eo()}),XA=(e,t)=>{let n=Object.values(e.groups);for(let r of n){let n=mo(e.annotations,r.annotations);t.onGroup({group:r,mergedAnnotations:n});let i=Object.values(r.endpoints);for(let e of i)t.predicate&&!t.predicate({endpoint:e,group:r})||t.onEndpoint({group:r,endpoint:e,middleware:e.middlewares,mergedAnnotations:mo(n,e.annotations),successes:ZA(xA(e),mA),errors:ZA(SA(e),_A)})}},ZA=(e,t)=>{let n=new Map;return e.forEach(r),n;function r(e){if(qk($k(e)?e.schema:e))return;let r=t(e),i=n.get(r);i===void 0?n.set(r,[e]):i.push(e)}};O()(`effect/httpapi/HttpApi/AdditionalSchemas`);var QA=`~effect/encoding/Sse/SseError`,$A=class extends cs(`EventTooLarge`){get message(){return`Pending SSE event exceeded the maximum size of ${this.maxEventSize}`}},ej=class extends cs(`SseError`){[QA]=QA;get message(){return this.reason.message}},tj=10485760,nj=e=>Lb((t,n)=>th(()=>{let n=[],r,i=ij(e=>{e._tag===`Retry`?r=e:n.push(e)},e),a=M(t,e=>{for(let t=0;t<e.length;t++){let n=i.feed(e[t]);if(n!==void 0)return j(n)}return nh});return eh(function e(){if(ta(n)){let e=n;return n=[],k(e)}return r?j(r):M(a,e)})})),rj=(e,t)=>qb(nj(t),nw(oj.pipe(B(e)))());function ij(e,t){let n=t?.maxEventSize??tj,r,i,a,o,s,c,l,u;return d(),{feed:f,reset:d};function d(){r=!0,i=``,a=0,o=-1,s=!1,c=void 0,l=void 0,u=``}function f(e){i=i?i+e:e,r&&i.startsWith(aj)&&(i=i.slice(aj.length)),r=!1;let t=i.length,c=0;for(;c<t;){s&&=(i[c]===`
|
|
15
|
-
`&&++c,!1);let e=-1,n=o,r;for(let o=a;e<0&&o<t;++o)r=i[o],r===`:`&&n<0?n=o-c:r===`\r`?(s=!0,e=o-c):r===`
|
|
16
|
-
`&&(e=o-c);if(e<0){a=t-c,o=n;break}a=0,o=-1,p(i,c,n,e),c+=e+1}if(c===t?i=``:c>0&&(i=i.slice(c)),i.length+u.length>n){let e=new ej({reason:new $A({maxEventSize:n})});return d(),e}}function p(t,n,r,i){if(i===0){u.length>0&&(e({_tag:`Event`,id:c,event:l||`message`,data:u.slice(0,-1)}),u=``),l=void 0;return}let a=r<0,o=t.slice(n,n+(a?i:r)),s=0;s=a?i:t[n+r+1]===` `?r+2:r+1;let d=n+s,f=i-s,p=t.slice(d,d+f).toString();o===`data`?u+=p?`${p}\n`:`
|
|
17
|
-
`:o===`event`?l=p:o===`id`&&!p.includes(`\0`)?c=p:o===`retry`&&/^\d+$/.test(p)&&e(new cj({duration:zo(parseInt(p,10)),lastEventId:c}))}}var aj=``,oj=I({id:oS(F),event:F,data:F}),sj=`~effect/encoding/Sse/Retry`,cj=class e extends ss(`Retry`){[sj]=sj;static is(e){return At(e,sj)}static filter(t){return e.is(t)?Mi(t):Ni(t)}},lj=`~effect/httpapi/HttpApiMiddleware`,uj=`~effect/httpapi/HttpApiMiddleware/Security`,dj=()=>(e,t)=>{let n=globalThis.Error,r=Ks();qs(2);let i=new n;qs(r);class a extends O()(e){}let o=a;if(Object.defineProperty(a,"stack",{get(){return i.stack}}),o[lj]=lj,o.error=fj(t?.error),o.requiredForClient=t?.requiredForClient??!1,t?.security!==void 0){if(Object.keys(t.security).length===0)throw Error(`HttpApiMiddleware.Service: security object must not be empty`);o[uj]=uj,o.security=t.security}return o};function fj(e){return e===void 0?new Set:new Set(Array.isArray(e)?e:[e])}var pj=(e,t)=>A(function*(){let n=yield*kh(),r=t.httpClient.pipe(t?.baseUrl===void 0?C:Sk(YO(t.baseUrl.toString())));function i(e,t,a,o,s){if(s===-1)return r.execute(a);let c=n.mapUnsafe.get(o[s]);return c===void 0?i(e,t,a,o,s-1):c({endpoint:t,group:e,request:a,next(n){return i(e,t,n,o,s-1)}})}XA(e,{predicate:t?.predicate,onGroup(e){t.onGroup?.(e)},onEndpoint(e){let{group:n,endpoint:r,errors:a,successes:o}=e,s=_j(r.path),c={orElse:Ij},l=ck(c),u=new Map;for(let[e,t]of a.entries()){let n=Sj(t);for(let[t,r]of n.entries())bj(u,e,t,vj(r))}for(let[e,t]of u.entries()){let n=xj(t);c[e]=e=>M(xh(n(e),t=>ah(Qd(qd(new xO({reason:new EO({request:e.request,response:e})})),t))),j)}let d=new Map;for(let[e,t]of o.entries()){let n=Sj(t);for(let[t,r]of n.entries())bj(d,e,t,vj(r))}for(let e of Ej(r)){let t=Tj(e)?e.schema:e;bj(d,mA(e),t.contentType,Dj(e))}for(let[e,t]of d.entries())c[e]=xj(t);let f=Ox(r.params,tS),p=bA(r),m=ta(p)?kO(r.method)?tS(Rj(p,r.method)):tS(R(p)):void 0,h=Ox(r.headers,tS),g=Ox(r.query,tS),_=Array.from(e.middleware,e=>`${e.key}/Client`),v=$h(function*(e){let a=zO(r.method)(r.path);if(e!==void 0){if(f!==void 0){let t=yield*f(e.params);a=JO(a,s(t))}if(m!==void 0){if(kO(r.method)){if(e.payload instanceof FormData)a=nk(a,e.payload);else{let t=yield*m(e.payload);a=ek(a,t)}}else{let t=yield*m(e.payload);a=QO(a,t)}}if(h!==void 0){let t=yield*h(e.headers);a=GO(a,t)}if(g!==void 0){let t=yield*g(e.query);a=QO(a,t)}}let o=yield*i(n,r,a,_,_.length-1);if(e?.responseMode===`response-only`)return o;let c=yield*t.transformResponse===void 0?l(o):t.transformResponse(l(o));return e?.responseMode===`decoded-and-response`?[c,o]:c});t.onEndpoint({...e,endpointFn:v})}})}),mj=(e,t)=>M(_k,n=>hj(e,{...t,httpClient:t?.transformClient?t.transformClient(n):n})),hj=(e,t)=>{let n={};return pj(e,{...t,onGroup({group:e}){e.topLevel||xn(n,e.identifier,{})},onEndpoint({endpoint:e,endpointFn:t,group:r}){xn(r.topLevel?n:n[r.identifier],e.identifier,t)}}).pipe(_h(n))},gj=/(\/?):(\w+)(\?)?/g,_j=e=>gj.test(e)?(gj.lastIndex=0,t=>(gj.lastIndex=0,e.replace(gj,(e,n,r,i)=>{let a=t[r];if(a===void 0){if(i!==void 0)return``;throw Error(`Missing path parameter: ${r}`)}return`${n}${encodeURIComponent(a)}`}))):t=>e;function vj(e){let t=e.some(e=>$k(e)||oA(e.ast)!==void 0),n=Jx(t?R(e.map(yj)):Pj(e));return e=>M(e.arrayBuffer,t?t=>n({body:t,headers:e.headers}):n)}function yj(e){let t=$k(e),n=oA(e.ast);if(n!==void 0)return I({body:Fj(n.body),headers:n.headersCodec}).pipe(B(e));let r=t?e.schema:e;return I({body:Fj(r).pipe(B(r)),headers:t?e.headers:dS}).pipe(B(t?e:sS(e),H_({decode:e=>t?Qk(e):e.body,encode:e=>t?e:{body:e,headers:void 0}})))}function bj(e,t,n,r){let i=vA(n),a=e.get(t);a===void 0?e.set(t,[{contentType:i,decode:r}]):a.push({contentType:i,decode:r})}function xj(e){let t=e[0];return e.length===1&&t!==void 0?t.decode:t=>{let n=vA(t.headers[`content-type`]??``),r=e.find(e=>e.contentType===n);return r===void 0?Cj(t,n,e):r.decode(t)}}function Sj(e){let t=new Map;for(let n of e){let e=iA(($k(n)?n.schema:n).ast)?``:vA(hA(n).contentType),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return t}function Cj(e,t,n){let r=Array.from(new Set(n.map(e=>e.contentType))).join(`, `);return j(new xO({reason:new DO({request:e.request,response:e,description:`Unsupported response content-type for status ${e.status}: ${t||`<missing>`}. Expected one of: ${r}`})}))}var wj=`effect/httpapi/stream/failure`,Tj=e=>$k(e);function Ej(e){let t=[];for(let n of e.success)qk($k(n)?n.schema:n)&&t.push(n);return t}function Dj(e){let t=Tj(e),n=t?e.schema:e,r=Yk(n)?void 0:{declaration:n,decoder:Oj(n)},i=e=>gh(kh(),t=>vw(r===void 0?e.stream:kj(e.stream,r.declaration,r.decoder),t));if(!t)return i;let a=Kx(e.headers);return e=>M(a(e.headers),t=>gh(i(e),e=>Qk({body:e,headers:t})))}function Oj(e){return rj(R([I({event:lS(wj),data:wC(BC(cC(e.error,hC())))}),e.events]))}function kj(e,t,n){let r=uw(e.pipe(gw,hw(n)),e=>th(()=>{let t;return eh(()=>t===void 0?M(e,e=>{for(let n=0;n<e.length;n++){let r=e[n];if(r.event===wj&&Hd(r.data)){if(n===0)return ah(r.data);t=r.data,e=e.slice(0,n);break}}return k(e)}):ah(t))}));return t.sseMode===`data`?mw(r,e=>e.data):r}var Aj=IS(globalThis.ArrayBuffer,{expected:`ArrayBuffer`}),jj=Aj.pipe(B(OC,H_({decode(e){return new Uint8Array(e)},encode(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}}))),Mj=Aj.pipe(B(F,H_({decode(e){return new TextDecoder().decode(e)},encode(e){let t=new TextEncoder().encode(e);return t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}}))),Nj=Mj.pipe(B(R([lS(``).pipe(B(pS,H_({decode:()=>void 0,encode:()=>``}))),TC])));function Pj(e){return R(e.map(t));function t(e){return Fj(e).pipe(B(e))}}function Fj(e){switch(fA(e.ast)._tag){case`Json`:return lv(Zy(e.ast))?Nj.pipe(B(dS,H_({decode:e=>e===void 0?null:e,encode:e=>e===null?void 0:e}))):Nj;case`FormUrlEncoded`:return Mj.pipe(B(LD));case`Uint8Array`:return jj;case`Text`:return Mj}}var Ij=e=>j(new xO({reason:new DO({request:e.request,response:e})})),Lj=zx(zD);function Rj(e,t){return R(e.map(e=>Bj(e,t)))}var zj=new WeakMap;function Bj(e,t){let n=e.ast,r=zj.get(n);if(r!==void 0)return r;let i=dA(n,t),a=Lj.pipe(B(e,V_({decode(e,t){return j(new Fg({message:`Encode only schema`},e,t))},encode(e,t){switch(i._tag){case`Multipart`:return j(new Fg({message:`Payload must be a FormData`},e,t));case`Json`:try{return k(GD(JSON.stringify(e),i.contentType))}catch{return j(new Ng({expected:`a JSON-serializable request body`},e,t))}case`Text`:return typeof e==`string`?k(GD(e,i.contentType)):j(new Ng({message:`Expected a string`},e,t));case`FormUrlEncoded`:return Ot(e)?k(qD(DD(e),i.contentType)):j(new Ng({message:`Expected a record`},e,t));case`Uint8Array`:return e instanceof Uint8Array?k(UD(e,i.contentType)):j(new Ng({message:`Expected a Uint8Array`},e,t))}}})));return zj.set(n,a),a}var Vj=`~effect/httpapi/HttpApiGroup`,Hj={[Vj]:Vj,add(...e){let t={...this.endpoints};for(let n of e)xn(t,n.identifier,n);return Wj({...Uj(this),endpoints:t})},prefix(e){return Wj({...Uj(this),endpoints:Gi(this.endpoints,t=>t.prefix(e))})},middleware(e){return Wj({...Uj(this),endpoints:Gi(this.endpoints,t=>t.middleware(e))})},annotateMerge(e){return Wj({...Uj(this),annotations:mo(this.annotations,e)})},annotate(e,t){return Wj({...Uj(this),annotations:ro(this.annotations,e,t)})},annotateEndpointsMerge(e){return Wj({...Uj(this),endpoints:Gi(this.endpoints,t=>t.annotateMerge(e))})},annotateEndpoints(e,t){return Wj({...Uj(this),endpoints:Gi(this.endpoints,n=>n.annotate(e,t))})},pipe(){return rt(this,arguments)}},Uj=e=>({identifier:e.identifier,topLevel:e.topLevel,endpoints:e.endpoints,annotations:e.annotations}),Wj=e=>{function t(){}return Object.setPrototypeOf(t,Hj),t.key=`effect/httpapi/HttpApiGroup/${e.identifier}`,Object.assign(t,e)},Gj=(e,t)=>Wj({identifier:e,topLevel:t?.topLevel??!1,endpoints:{},annotations:eo()}),Kj=F.check(zS(/^\S(?:.*\S)?$/u,{message:`Expected a GitHub label name without surrounding whitespace`}),ZS(50,{message:`Expected a GitHub label name of at most 50 characters`})).pipe(z(`GitHubLabelName`)),qj=e=>e.toLowerCase(),Jj=F.check(zS(/^[0-9a-fA-F]{6}$/u,{message:`Expected a six-digit hex GitHub label color without #`})).pipe(z(`GitHubLabelColor`)),Yj=F.check(ZS(100,{message:`Expected a GitHub label description of at most 100 characters`})),Xj=class extends H(`@usine/config/DeclaredLabel`)({name:Kj,color:tC(Jj),description:tC(Yj)}){},Zj=e=>F.check(zS(/\S/u,{message:e})),Qj=Zj(`Expected a non-blank lane name`).pipe(z(`LaneName`)),$j=ES([`issue-open`,`issue-closed`,`pr-open`,`pr-closed`,`pr-merged`]),eM=R([class extends H(`@usine/config/LabelLaneSource`)({label:Kj}){},class extends H(`@usine/config/StateLaneSource`)({state:$j}){}]),tM=class extends H(`@usine/config/Lane`)({name:Qj,sources:L(eM).check(XS())}){},nM=R([class extends U(`@usine/orchestrator/InfraFailureView`)(`InfraFailure`,{message:F}){},class extends U(`@usine/orchestrator/DefectFailureView`)(`DefectFailure`,{message:F}){},class extends U(`@usine/orchestrator/AgentFailureView`)(`AgentFailure`,{message:F}){},class extends U(`@usine/orchestrator/RunawayFailureView`)(`RunawayFailure`,{ceiling:xE}){},class extends U(`@usine/orchestrator/ChildSessionBudgetFailureView`)(`ChildSessionBudgetFailure`,{maxChildren:tE,attemptedChildren:nE}){}]),rM=R([class extends U(`@usine/orchestrator/SucceededAttemptView`)(`Succeeded`,{}){},class extends U(`@usine/orchestrator/FailedAttemptView`)(`Failed`,{failure:nM}){},class extends U(`@usine/orchestrator/CanceledAttemptView`)(`Canceled`,{}){}]),iM=class extends H(`@usine/orchestrator/AttemptView`)({id:OE,number:kE,worker:XT,brain:VT,task:AE,agent:HT,operatorIntervened:hS,startedAt:F,outcome:DS(rM)}){},aM=R([KE,qE,JE,class extends U(`@usine/orchestrator/FailedTranscriptView`)(`Failed`,{failure:nM}){},XE,ZE,QE,eD,tD,$E,lD,uD]),oM=class extends H(`@usine/orchestrator/TranscriptEventView`)({sequence:_D,attemptId:OE,receivedAt:F,direction:WE,target:aS(oD),operator:aS(V),payload:aM}){},sM=class extends H(`@usine/orchestrator/TranscriptPageCursor`)({attemptId:OE,before:_D}){},cM=class extends U(`@usine/orchestrator/ColdTranscriptRequest`)(`ColdTranscriptRequest`,{}){},lM=class extends U(`@usine/orchestrator/TailTranscriptRequest`)(`TailTranscriptRequest`,{after:_D}){},uM=class extends U(`@usine/orchestrator/EarlierTranscriptRequest`)(`EarlierTranscriptRequest`,{attemptId:OE,before:_D}){};R([cM,lM,uM]),zC(`@usine/orchestrator/TranscriptAttemptNotFoundError`)(`TranscriptAttemptNotFoundError`,{runId:FT,attemptId:OE});var dM=ES(wT),fM=DS(F),pM=class extends H(`@usine/orchestrator/EditAndRetry`)({task:AE,agent:HT}){},mM=class extends H(`@usine/orchestrator/SessionIntervention`)({attemptId:OE,target:oD.pipe(MS(k({_tag:`Parent`}))),action:nD}){};zC(`@usine/orchestrator/RosterAgentNotFoundError`)(`RosterAgentNotFoundError`,{agent:HT,message:F});var hM=class extends H(`@usine/orchestrator/RunView`)({id:FT,itemKey:NE,loop:tT,repository:qw,agent:HT,state:dM,loopPaused:hS,openedAt:F,task:F,attempts:L(iM),resultMessage:fM,pullRequestUrl:fM,canApprove:hS,canRetry:hS,canCancel:hS}){},gM=class extends H(`@usine/orchestrator/RunDetailView`)({run:hM,eventDedupKey:F,eventPayload:ew,transcript:L(oM),sessionState:L(oM),earlierTranscript:L(sM)}){},_M=V.pipe(z(`BoardLaneId`)),vM=ES([`authored`,`proposed`,`fallback`]),yM=class extends H(`@usine/orchestrator/BoardItemLink`)({itemKey:NE,kind:ES([`issue`,`pr`]),number:PE,title:F,url:V}){},bM=class extends H(`@usine/orchestrator/BoardTaskView`)({...yM.fields,state:$j,labels:L(Kj),items:L(yM).check(XS()),runs:L(hM),run:DS(hM),needsYou:hS}){},xM={id:_M,name:Qj,sources:L(eM),origin:vM,items:L(bM)},SM=R([class extends U(`@usine/orchestrator/WritableBoardLaneView`)(`WritableBoardLane`,{...xM,origin:lS(`authored`),labels:L(Kj).check(XS())}){},class extends U(`@usine/orchestrator/ReadOnlyBoardLaneView`)(`ReadOnlyBoardLane`,xM){}]),CM=class extends zC(`@usine/orchestrator/BoardProjectionError`)(`BoardProjectionError`,{repository:qw,itemKey:NE,message:V}){},wM=class extends H(`@usine/orchestrator/BoardView`)({lanes:L(SM),failures:L(CM)}){},TM=class extends H(`@usine/orchestrator/LabelView`)({name:Kj,color:DS(F),description:DS(F)}){};H(`@usine/orchestrator/BoardMove`)({repository:qw,item:PE,toLane:_M}),zC(`@usine/orchestrator/BoardProjectNotFoundError`)(`BoardProjectNotFoundError`,{repository:qw}),zC(`@usine/orchestrator/BoardItemNotFoundError`)(`BoardItemNotFoundError`,{repository:qw,item:PE}),zC(`@usine/orchestrator/BoardLaneNotFoundError`)(`BoardLaneNotFoundError`,{repository:qw,lane:_M}),zC(`@usine/orchestrator/BoardLaneReadOnlyError`)(`BoardLaneReadOnlyError`,{repository:qw,lane:_M});var W=Symbol.for(`drizzle:entityKind`);function G(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,W))throw Error(`Class "${t.name??`<unknown>`}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e)?.constructor;if(n)for(;n;){if(W in n&&n[W]===t[W])return!0;n=Object.getPrototypeOf(n)}return!1}var EM=Symbol.for(`drizzle:OriginalColumn`),DM=e=>e;DM.isNoop=!0;var OM=class{static[W]=`Column`;codec;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;length;isLengthExact;isAlias;config;table;onInit(){}constructor(e,t){this.config=t,this.onInit(),this.table=e,this.name=t.name,this.isAlias=!1,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity,this.length=t.length,this.isLengthExact=t.isLengthExact}mapFromDriverValue=DM;mapToDriverValue=DM;postBuild(){return this}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}[EM](){return this}},kM=Symbol.for(`drizzle:Name`),AM=Symbol.for(`drizzle:Schema`),jM=Symbol.for(`drizzle:Columns`),MM=Symbol.for(`drizzle:ExtraConfigColumns`),NM=Symbol.for(`drizzle:OriginalName`),PM=Symbol.for(`drizzle:BaseName`),FM=Symbol.for(`drizzle:IsAlias`),IM=Symbol.for(`drizzle:ExtraConfigBuilder`),LM=Symbol.for(`drizzle:IsDrizzleTable`),K=class{static[W]=`Table`;static Symbol={Name:kM,Schema:AM,OriginalName:NM,Columns:jM,ExtraConfigColumns:MM,BaseName:PM,IsAlias:FM,ExtraConfigBuilder:IM};[kM];[NM];[AM];[jM];[MM];[PM];[FM]=!1;[LM]=!0;[IM]=void 0;constructor(e,t,n){this[kM]=this[NM]=e,this[AM]=t,this[PM]=n}};function RM(e){return e[kM]}var zM=class{static[W]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},BM=class extends zM{static[W]=`WithSubquery`},VM={startActiveSpan(e,t){return t()}},HM=Symbol.for(`drizzle:ViewBaseConfig`);function UM(e){return e!=null&&typeof e.getSQL==`function`}function WM(e){let t={sql:``,params:[]};for(let n of e)t.sql+=n.sql,t.params.push(...n.params);return t}function GM(e){let t={sql:``,params:[]},n=[];for(let r of e)n.push(r.sql),t.params.push(...r.params);return t._sql=Object.assign(n,{raw:n}),t}var KM=class{static[W]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new q([this])}},q=class e{static[W]=`SQL`;decoder=YM;shouldInlineParams=!1;usedTables=[];constructor(e){this.queryChunks=e;for(let t of e)if(G(t,K)){let e=t[K.Symbol.Schema];this.usedTables.push(e===void 0?t[K.Symbol.Name]:e+`.`+t[K.Symbol.Name])}}append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return VM.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{escapeName:i,escapeParam:a,codecs:o,inlineParams:s,paramStartIndex:c,invokeSource:l}=r,u=t.map(t=>{if(G(t,KM))return{sql:t.value.join(``),params:[]};if(G(t,qM))return{sql:i(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new KM(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new KM(`, `));return e.push(new KM(`)`)),this.buildQueryFromSourceParams(e,r)}if(G(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:s||t.shouldInlineParams});if(G(t,K)){let e=t[K.Symbol.Schema],n=t[K.Symbol.Name];return l===`mssql-view-with-schemabinding`?{sql:i(e===void 0?`dbo`:e)+`.`+i(n),params:[]}:{sql:e===void 0||t[FM]?i(n):i(e)+`.`+i(n),params:[]}}if(G(t,OM)){let e=t.name;if(n.invokeSource===`indexes`)return{sql:i(e),params:[]};let r=l===`mssql-check`?void 0:t.table[K.Symbol.Schema];return{sql:t.isAlias?i(t.name):t.table[FM]||r===void 0?i(t.table[K.Symbol.Name])+`.`+i(e):i(r)+`.`+i(t.table[K.Symbol.Name])+`.`+i(e),params:[]}}if(G(t,tN)){let e=t[HM].schema,n=t[HM].name;return{sql:e===void 0||t[HM].isAlias?i(n):i(e)+`.`+i(n),params:[]}}if(G(t,ZM)){if(G(t.value,e))return this.buildQueryFromSourceParams([t.value],r);let n=o&&G(t.encoder,OM);if(G(t.value,$M)){let e=a(c.value++,t);return t.codec=n?e=>o.apply(t.encoder,`normalizeParam`,e):void 0,{sql:n?o.apply(t.encoder,`castParam`,e):e,params:[t]}}let i;if(t.value===null)i=t.value;else{if(i=t.encoder.mapToDriverValue.isNoop?t.value:t.encoder.mapToDriverValue(t.value),G(i,e))return this.buildQueryFromSourceParams([i],r);n&&(i=o.apply(t.encoder,`normalizeParam`,i))}if(s)return{sql:this.mapInlineParam(i,r),params:[]};let l=a(c.value++,i);return{sql:n?o.apply(t.encoder,`castParam`,l):l,params:[i]}}return G(t,$M)?{sql:a(c.value++,t),params:[t]}:G(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:(t.origin===void 0?``:i(t.origin)+`.`)+i(t.fieldAlias),params:[]}:G(t,zM)?t._.isWith?{sql:i(t._.alias),params:[]}:this.buildQueryFromSourceParams([new KM(`(`),t._.sql,new KM(`) `),new qM(t._.alias)],r):typeof t==`function`&&`enumName`in t?`schema`in t&&t.schema?{sql:i(t.schema)+`.`+i(t.enumName),params:[]}:{sql:i(t.enumName),params:[]}:UM(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new KM(`(`),t.getSQL(),new KM(`)`)],r):s?{sql:this.mapInlineParam(t,r),params:[]}:{sql:a(c.value++,t),params:[t]}});return n.tagged?GM(u):WM(u)}mapInlineParam(e,{escapeString:t}){if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(typeof e==`string`)return t(e);if(typeof e==`object`){let n=e.toString();return t(n===`[object Object]`?JSON.stringify(e):n)}throw Error(`Unexpected param value: `+e)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(e){return this.decoder=typeof e==`function`?{mapFromDriverValue:e}:e,this}nullable(){return this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}},qM=class{static[W]=`Name`;brand;constructor(e){this.value=e}getSQL(){return new q([this])}};function JM(e){return typeof e==`object`&&!!e&&`mapToDriverValue`in e&&typeof e.mapToDriverValue==`function`}var YM={mapFromDriverValue:e=>e};YM.mapFromDriverValue.isNoop=!0;var XM={mapToDriverValue:e=>e};XM.mapToDriverValue.isNoop=!0,{...YM,...XM};var ZM=class{static[W]=`Param`;brand;constructor(e,t=XM,n){this.value=e,this.encoder=t,this.codec=n}getSQL(){return new q([this])}};function J(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new KM(e[0]));for(let[r,i]of t.entries())n.push(i,new KM(e[r+1]));return new q(n)}(function(e){function t(){return new q([])}e.empty=t;function n(e){return new q(e)}e.fromList=n;function r(e){return new q([new KM(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new q(n)}e.join=i;function a(e){return new qM(e)}e.identifier=a;function o(e){return new $M(e)}e.placeholder=o;function s(e,t){return new ZM(e,t)}e.param=s;function c(e){let t=QM(e);if(t.length)return J.raw(t)}e.comment=c})(J||={});function QM(e){let t=QM.encodeInput(e);return t.length?`/*${t}*/`:``}(function(e){function t(e,t){let r;if(typeof e==`object`&&typeof t==`object`)r=n({...e,...t});else if(e&&t)r=[n(e),n(t)].filter(e=>e.length).join(`,`);else if(t)r=n(t);else if(e)r=n(e);else return``;return r.length?`/*${r}*/`:``}e.merge=t;function n(e){if(typeof e==`string`)return e.length?i(e):e;let t=[];for(let[n,i]of Object.entries(e)){if(i==null||i===``)continue;let e=r(n),a=r(String(i));t.push(`${e}='${a}'`)}return t.length?t.sort().join(`,`):``}e.encodeInput=n;function r(e){return encodeURIComponent(e).replace(/'/g,`\\'`)}e.sanitizeObjectElement=r;function i(e){return e.replace(/\/\*/g,`/ *`).replace(/\*\//g,`* /`)}e.sanitizeStringInput=i})(QM||={}),(function(e){class t{static[W]=`SQL.Aliased`;isSelectionField=!1;origin;constructor(e,t){this.sql=e,this.fieldAlias=t}getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(q||={});var $M=class{static[W]=`Placeholder`;constructor(e){this.name=e}getSQL(){return new q([this])}},eN=Symbol.for(`drizzle:IsDrizzleView`),tN=class{static[W]=`View`;[HM];[eN]=!0;get[kM](){return this[HM].name}get[AM](){return this[HM].schema}get[FM](){return this[HM].isAlias}get[NM](){return this[HM].originalName}get[jM](){return this[HM].selectedFields}constructor({name:e,schema:t,selectedFields:n,query:r}){this[HM]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}};OM.prototype.getSQL=function(){return new q([this])},zM.prototype.getSQL=function(){return new q([this])};var nN=class extends Error{static[W]=`DrizzleError`;constructor({message:e,cause:t}){super(e),this.name=`DrizzleError`,this.cause=t}};function rN(e,t){return JM(t)&&!UM(e)&&!G(e,ZM)&&!G(e,$M)&&!G(e,OM)&&!G(e,K)&&!G(e,tN)?new ZM(e,t):e}var Y=(e,t)=>J`${e} = ${rN(t,e)}`,iN=(e,t)=>J`${e} <> ${rN(t,e)}`;function aN(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new q(t):new q([new KM(`(`),J.join(t.map(e=>J`(${e})`),new KM(` and `)),new KM(`)`)])}function oN(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new q(t):new q([new KM(`(`),J.join(t.map(e=>J`(${e})`),new KM(` or `)),new KM(`)`)])}function sN(e){return G(e,q)?J`not (${e})`:J`not ${e}`}var cN=(e,t)=>J`${e} > ${rN(t,e)}`,lN=(e,t)=>J`${e} >= ${rN(t,e)}`,uN=(e,t)=>J`${e} < ${rN(t,e)}`,dN=(e,t)=>J`${e} <= ${rN(t,e)}`;function fN(e,t){return Array.isArray(t)?t.length===0?J`false`:J`${e} in ${t.map(t=>rN(t,e))}`:J`${e} in ${rN(t,e)}`}function pN(e,t){return Array.isArray(t)?t.length===0?J`true`:J`${e} not in ${t.map(t=>rN(t,e))}`:J`${e} not in ${rN(t,e)}`}function mN(e){return J`(${e} is null)`}function hN(e){return J`(${e} is not null)`}function gN(e){return J`exists ${e}`}function _N(e){return J`not exists ${e}`}function vN(e,t,n){return J`${e} between ${rN(t,e)} and ${rN(n,e)}`}function yN(e,t,n){return J`${e} not between ${rN(t,e)} and ${rN(n,e)}`}function bN(e,t){return J`${e} like ${t}`}function xN(e,t){return J`${e} not like ${t}`}function SN(e,t){return J`${e} ilike ${t}`}function CN(e,t){return J`${e} not ilike ${t}`}function wN(e,t){if(Array.isArray(t)){if(t.length===0)throw Error(`arrayContains requires at least one value`);let n=rN(t,e);return J`${e} @> ${J`${Array.isArray(n)?new ZM(n):n}`}`}return J`${e} @> ${rN(t,e)}`}function TN(e,t){if(Array.isArray(t)){if(t.length===0)throw Error(`arrayContained requires at least one value`);let n=rN(t,e);return J`${e} <@ ${J`${Array.isArray(n)?new ZM(n):n}`}`}return J`${e} <@ ${rN(t,e)}`}function EN(e,t){if(Array.isArray(t)){if(t.length===0)throw Error(`arrayOverlaps requires at least one value`);let n=rN(t,e);return J`${e} && ${J`${Array.isArray(n)?new ZM(n):n}`}`}return J`${e} && ${rN(t,e)}`}function DN(e){return J`${e} asc`}function ON(e){return J`${e} desc`}var kN=class{static[W]=`ColumnTableAliasProxyHandler`;constructor(e,t){this.table=e,this.ignoreColumnAlias=t}get(e,t){return t===`table`?this.table:t===`isAlias`&&this.ignoreColumnAlias?!1:e[t]}},AN=class{static[W]=`ViewSelectionAliasProxyHandler`;constructor(e,t,n){this.view=e,this.selection=t,this.ignoreColumnAlias=n}get(e,t){let n=e[t];return G(n,OM)?new Proxy(n,new kN(this.view,this.ignoreColumnAlias)):G(n,zM)||G(n,q)||G(n,q.Aliased)||UM(n)||typeof n!=`object`||!n?n:new Proxy(n,this)}},jN=class{static[W]=`TableAliasProxyHandler`;constructor(e,t,n){this.alias=e,this.replaceOriginalName=t,this.ignoreColumnAlias=n}get(e,t){if(t===K.Symbol.IsAlias)return!0;if(t===K.Symbol.Name||this.replaceOriginalName&&t===K.Symbol.OriginalName)return this.alias;if(t===HM)return{...e[HM],name:this.alias,isAlias:!0,selectedFields:new Proxy(e[HM].selectedFields,new AN(new Proxy(e,this),e[HM].selectedFields,this.ignoreColumnAlias))};if(t===K.Symbol.Columns){let t=e[K.Symbol.Columns];if(!t)return t;if(G(e,tN))return new Proxy(e[K.Symbol.Columns],new AN(new Proxy(e,this),e[K.Symbol.Columns],this.ignoreColumnAlias));let n={};return Object.keys(t).map(r=>{n[r]=new Proxy(t[r],new kN(new Proxy(e,this),this.ignoreColumnAlias))}),n}let n=e[t];return G(n,OM)?new Proxy(n,new kN(new Proxy(e,this),this.ignoreColumnAlias)):n}},MN=class{static[W]=`ColumnAliasProxyHandler`;constructor(e){this.alias=e}get(e,t){return t===`isAlias`?!0:t===`name`?this.alias:t===`keyAsName`?!1:t===EM?()=>e:e[t]}};function NN(e,t){return new Proxy(e,new jN(t,!1,!1))}function PN(e,t){return new Proxy(e,new MN(t))}OM.prototype.as=function(e){return PN(this,e)};function FN(e){return e[EM]()}var IN=Object.getPrototypeOf(()=>null).constructor;function LN(e,t={}){let n=[],r=[];r.push(`const [ ${e.map((e,t)=>`c${t}`).join(`, `)} ] = rows[i];`);let i={},a={},o=Array.from({length:e.length});for(let r=0;r<e.length;++r){let{field:s,path:c,codec:l,arrayDimensions:u}=e[r],d,f,p,m=!1;G(s,OM)?(m=!0,d=s,p=`field: decoder${r}`):G(s,q)?(d=s.decoder,p=`field: { decoder: decoder${r} }`):G(s,zM)?(d=s._.sql.decoder,p=`field: { _: { sql: { decoder: decoder${r} } } }`):(d=s.sql.decoder,p=`field: { sql: { decoder: decoder${r} } }`),f=`decoder${r}.mapFromDriverValue`,d.mapFromDriverValue.isNoop&&(f=``),f?n.push(`const { ${p}${l?`, codec: codec${r}`:``} } = columns[${r}];`):l&&n.push(`const { codec: codec${r} } = columns[${r}];`);let h=`c${r}`,g=h;if(l&&(g=`codec${r}(${g}, ${u})`),f&&(g=`${f}(${g})`),o[r]=h===g?`${h}`:`${h} === null ? ${h} : ${g}`,c.length!==2||!m)continue;a[c[0]]===void 0?a[c[0]]=[`c${r}`]:a[c[0]]?.push(`c${r}`);let[_]=c,v=RM(s.table);i[_]=t[v]?!1:typeof i[_]==`string`?i[_]===v&&v:v}r.push(`mapped[i] = {`);let s=[];for(let t=0;t<e.length;++t){let{path:n}=e[t],c=n.map(e=>JSON.stringify(e)),l=o[t],u=n.slice(0,-1),d=0;for(;d<s.length&&d<u.length&&s[d]===u[d];)d++;for(let e=s.length-1;e>=d;--e)r.push(`${` `.repeat(e+1)}},`);for(let e=d;e<u.length;++e)r.push(`${` `.repeat(e+1)}${c[e]}: ${e===0&&u.length===1&&typeof i[n[0]]==`string`?`${a[n[0]]?.map(e=>`${e} === null`).join(` && `)} ? null : {`:`{`}`);s=u,r.push(`${` `.repeat(n.length)}${c[n.length-1]}: ${l},`)}for(let e=s.length-1;e>=0;--e)r.push(`${` `.repeat(e+1)}},`);return r.push(`};`),`${n.length?`${n.join(`
|
|
18
|
-
`)}\n\t`:``}for (let i = 0; i < length; ++i) {
|
|
19
|
-
${r.join(`
|
|
20
|
-
`)}
|
|
21
|
-
}`}function RN(e,t){let n=`\t"use strict";
|
|
22
|
-
const { columns } = this;
|
|
23
|
-
const { length } = rows;
|
|
24
|
-
const mapped = Array.from({ length });
|
|
25
|
-
${LN(e,t)}
|
|
26
|
-
return mapped;
|
|
27
|
-
//# sourceURL=drizzle:jit-query-mapper`;return Object.assign(new IN(`rows`,n).bind({columns:e}),{body:`function jitQueryMapper (rows) {\n${n}\n}`})}function zN(e,t){let n=e.map(({field:e,codec:n,arrayDimensions:r,path:i})=>{let a,o;if(G(e,OM)){if(o=e,t&&i.length===2){let t=i[0];a=(n,r)=>{t in n?typeof n[t]==`string`&&n[t]!==RM(e.table)&&(n[t]=!1):n[t]=r===null&&RM(e.table)}}}else o=G(e,q)?e.decoder:G(e,zM)?e._.sql.decoder:e.sql.decoder;let s;return s=o.mapFromDriverValue.isNoop?n?e=>n(e,r):void 0:n?e=>o.mapFromDriverValue(n(e,r)):e=>o.mapFromDriverValue(e),[s,a]});return(r=>r.map(r=>{let i={},a=e.reduce((e,{path:t},a)=>{let o=e;for(let[e,s]of t.entries())if(e<t.length-1)s in o||(o[s]={}),o=o[s];else{let[e,t]=n[a],c=r[a],l=o[s]=c===null?null:e?e(c):c;t?.(i,l)}return e},{});if(t&&Object.keys(i).length>0)for(let[e,n]of Object.entries(i))typeof n==`string`&&!t[n]&&(a[e]=null);return a}))}function BN(e,t,n){return Object.entries(e).reduce((e,[r,i])=>{if(typeof r!=`string`)return e;let a=t?[...t,r]:[r];if(G(i,OM))e.push({path:a,field:i,codec:n?.get(i,`normalize`),arrayDimensions:i.dimensions,column:i});else if(G(i,q)||G(i,q.Aliased)){let t=VN(i);e.push(t?{path:a,field:i,codec:n?.get(t,`normalize`),arrayDimensions:t.dimensions,column:t}:{path:a,field:i})}else if(G(i,zM)){let t,r=Object.values(i._.selectedFields)[0],o;G(r,OM)?(t=r,o=r):G(r,q)?(t=VN(r),o=r.decoder):(t=VN(r),o=r.sql.decoder),o&&(i._.sql.decoder=o),e.push(t?{path:a,field:i,codec:n?.get(t,`normalize`),arrayDimensions:t.dimensions,column:t}:{path:a,field:i})}else G(i,K)?e.push(...BN(i[K.Symbol.Columns],a,n)):e.push(...BN(i,a,n));return e},[])}function VN(e){let t=e.getSQL();if(G(t.decoder,OM))return t.decoder}function HN(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let[e,t]of n.entries())if(t!==r[e])return!1;return!0}function UN(e){return e[K.Symbol.Columns]}function WN(e){return G(e,zM)?e._.alias:G(e,tN)?e[HM].name:G(e,q)?void 0:e[K.Symbol.IsAlias]?e[K.Symbol.Name]:e[K.Symbol.BaseName]}function GN(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var KN=typeof TextDecoder>`u`?null:new TextDecoder,qN=class{static[W]=`RelationV2`;fieldName;sourceColumns;targetColumns;alias;where;sourceTable;targetTable;through;throughTable;isReversed;sourceColumnTableNames=[];targetColumnTableNames=[];constructor(e,t){this.targetTableName=t,this.targetTable=e}},JN=class extends qN{static[W]=`OneV2`;relationType=`one`;optional;constructor(e,t,n,r){super(t,n),this.alias=r?.alias,this.where=r?.where,r?.from&&(this.sourceColumns=(Array.isArray(r.from)?r.from:[r.from]).map(t=>(this.throughTable??=t._.through?e[t._.through._.tableName]:void 0,this.sourceColumnTableNames.push(t._.tableName),t._.column))),r?.to&&(this.targetColumns=(Array.isArray(r.to)?r.to:[r.to]).map(t=>(this.throughTable??=t._.through?e[t._.through._.tableName]:void 0,this.targetColumnTableNames.push(t._.tableName),t._.column))),this.throughTable&&(this.through={source:(Array.isArray(r?.from)?r.from:r?.from?[r.from]:[]).map(e=>e._.through),target:(Array.isArray(r?.to)?r.to:r?.to?[r.to]:[]).map(e=>e._.through)}),this.optional=r?.optional??!0}},YN={and:aN,between:vN,eq:Y,exists:gN,gt:cN,gte:lN,ilike:SN,inArray:fN,arrayContains:wN,arrayContained:TN,arrayOverlaps:EN,isNull:mN,isNotNull:hN,like:bN,lt:uN,lte:dN,ne:iN,not:sN,notBetween:yN,notExists:_N,notLike:xN,notIlike:CN,notInArray:pN,or:oN,sql:J},XN={sql:J,asc:DN,desc:ON};function ZN(e,t,n,r=!1,i=!1,a=!0){let o=t?1:e.length,s=n.map(({field:e,codec:t,arrayDimensions:n})=>{let r;return r=G(e,OM)?e:G(e,q)?e.decoder:G(e,q.Aliased)?e.sql.decoder:G(e,K)||G(e,tN)?YM:e.getSQL().decoder,a&&e.mapFromJsonValue?t=>e.mapFromJsonValue(t):r.mapFromDriverValue.isNoop?t?e=>t(e,n):void 0:t?e=>r.mapFromDriverValue(t(e,n)):e=>r.mapFromDriverValue(e)});for(let a=0;a<o;++a){let o=t?e:e[a];for(let e=0;e<n.length;++e){let t=n[e];if(t.selection){if(o[t.key]===null)continue;if(r){if(o[t.key]=JSON.parse(o[t.key]),o[t.key]===null)continue}else i&&typeof o[t.key]==`string`&&(o[t.key]=JSON.parse(o[t.key]));if(t.isArray){ZN(o[t.key],!1,t.selection,!1,i);continue}ZN(o[t.key],!0,t.selection,!1,i);continue}if(o[t.key]===null)continue;let a=s[e];a&&(o[t.key]=a(o[t.key]))}}return e}function QN(e,t,n,r=!1,i=!1){let a=t?1:e.length,o=n.map(({field:e,codec:t,arrayDimensions:n})=>{let r;return r=G(e,OM)?e:G(e,q)?e.decoder:G(e,q.Aliased)?e.sql.decoder:G(e,K)||G(e,tN)?YM:e.getSQL().decoder,r.mapFromDriverValue.isNoop?t?e=>t(e,n):void 0:t?e=>r.mapFromDriverValue(t(e,n)):e=>r.mapFromDriverValue(e)}),s=Array.from({length:a});for(let c=0;c<a;++c){let a=t?e:e[c],l={};for(let e=0;e<n.length;++e){let t=n[e],s=a[e];if(t.selection){if(s===null){l[t.key]=null;continue}if(r){if(s=JSON.parse(s),s===null){l[t.key]=null;continue}}else i&&typeof s==`string`&&(s=JSON.parse(s));t.isArray?ZN(s,!1,t.selection,!1,i):ZN(s,!0,t.selection,!1,i),l[t.key]=s;continue}if(s===null){l[t.key]=null;continue}let c=o[e];l[t.key]=c?c(s):s}s[c]=l}return t?s[0]:s}function $N({selection:e,isFirst:t,parseJson:n,parseJsonIfString:r,rootJsonMappers:i,arrayModeRoot:a}){return(o=>t&&!o[0]?o[0]:a?QN(t?o[0]:o,t,e,n,r):ZN(t?o[0]:o,t,e,n,r,i))}function eP(e,t,n,r,i,a,o,s,c){let l=[],u=[],d=!1,f=e.map(()=>`c${s.n++}`),p=e.map((e,t)=>c?f[t]:`${JSON.stringify(e.key)}: ${f[t]}`);l.push(c?`let [ ${p.join(`, `)} ] = ${t};`:`let { ${p.join(`, `)} } = ${t};`);for(let[t,{field:c,key:p,codec:m,isArray:h,selection:g,arrayDimensions:_}]of e.entries()){let e=`${n}[${t}]`,v=JSON.stringify(p),y=f[t];if(g){r?(l.push(`if (${y} !== null) ${y} = JSON.parse(${y});`),d=!0):i&&(l.push(`if (typeof ${y} === 'string') ${y} = JSON.parse(${y});`),d=!0);let t=`s${s.n++}`,n=o.length;if(o.push(`const { selection: ${t} } = ${e};`),h){let e=`j${s.n++}`,r=eP(g,`${y}[${e}]`,t,!1,i,!0,o,s,!1);if(r.hasWork){d=!0,l.push(`if (${y} !== null) {`),l.push(`\tfor (let ${e} = 0; ${e} < ${y}.length; ++${e}) {`);for(let e of r.bodyStmts)l.push(`\t\t${e}`);l.push(`\t\t${y}[${e}] = ${r.literal};`),l.push(` }`),l.push(`}`)}else o.splice(n,1)}else{let e=eP(g,y,t,!1,i,!0,o,s,!1);if(e.hasWork){d=!0,l.push(`if (${y} !== null) {`);for(let t of e.bodyStmts)l.push(`\t${t}`);l.push(`\t${y} = ${e.literal};`),l.push(`}`)}else o.splice(n,1)}u.push(`${v}: ${y}`);continue}let b=``,x=``,ee=!1;if(G(c,OM)){if(a&&c.mapFromJsonValue){ee=!0;let e=s.n++;x=`field: dec${e}`,b=`dec${e}.mapFromJsonValue`}else if(!c.mapFromDriverValue.isNoop){let e=s.n++;x=`field: dec${e}`,b=`dec${e}.mapFromDriverValue`}}else if(G(c,q)){if(a&&c.decoder.mapFromJsonValue){ee=!0;let e=s.n++;x=`field: { decoder: dec${e} }`,b=`dec${e}.mapFromJsonValue`}else if(!c.decoder.mapFromDriverValue.isNoop){let e=s.n++;x=`field: { decoder: dec${e} }`,b=`dec${e}.mapFromDriverValue`}}else if(G(c,q.Aliased)){if(a&&c.sql.decoder.mapFromJsonValue){ee=!0;let e=s.n++;x=`field: { sql: { decoder: dec${e} } }`,b=`dec${e}.mapFromJsonValue`}else if(!c.sql.decoder.mapFromDriverValue.isNoop){let e=s.n++;x=`field: { sql: { decoder: dec${e} } }`,b=`dec${e}.mapFromDriverValue`}}else if(!(G(c,K)||G(c,tN))){let t=c.getSQL();if(a&&t.decoder.mapFromJsonValue){ee=!0;let t=s.n++;o.push(`const dec${t} = ${e}.field.getSQL().decoder;`),b=`dec${t}.mapFromJsonValue`}else if(!t.decoder.mapFromDriverValue.isNoop){let t=s.n++;o.push(`const dec${t} = ${e}.field.getSQL().decoder;`),b=`dec${t}.mapFromDriverValue`}}let te=``;if(!ee&&m&&(te=`codec${s.n++}`),x||te){let t=[];x&&t.push(x),te&&t.push(`codec: ${te}`),o.push(`const { ${t.join(`, `)} } = ${e};`)}if(b||te){d=!0;let e=y;te&&(e=`${te}(${e}, ${_})`),b&&(e=`${b}(${e})`),u.push(`${v}: ${y} === null ? null : ${e}`)}else u.push(`${v}: ${y}`)}return{bodyStmts:l,literal:`{ ${u.join(`, `)} }`,hasWork:d}}function tP({selection:e,isFirst:t,parseJson:n,parseJsonIfString:r,rootJsonMappers:i,arrayModeRoot:a}){let o=[],s=eP(e,`row`,`selection`,n,r,!a&&i,o,{n:0},!!a),c=[];c.push(` "use strict";
|
|
28
|
-
const { selection } = this;`);for(let e of o)c.push(`\t${e}`);if(a){if(t){c.push(` const row = rows[0];`),c.push(` if (!row) return undefined;`);for(let e of s.bodyStmts)c.push(`\t${e}`);c.push(`\treturn ${s.literal};`)}else{c.push(` const { length } = rows;`),c.push(` const mapped = Array.from({ length });`),c.push(` for (let i = 0; i < length; ++i) {`),c.push(` const row = rows[i];`);for(let e of s.bodyStmts)c.push(`\t\t${e}`);c.push(`\t\tmapped[i] = ${s.literal};`),c.push(` }`),c.push(` return mapped;`)}}else if(!s.hasWork)c.push(t?` return rows[0];`:` return rows;`);else if(t){c.push(` const row = rows[0];`),c.push(` if (!row) return undefined;`);for(let e of s.bodyStmts)c.push(`\t${e}`);c.push(`\trows[0] = ${s.literal};`),c.push(` return rows[0];`)}else{c.push(` for (let i = 0; i < rows.length; ++i) {`),c.push(` const row = rows[i];`);for(let e of s.bodyStmts)c.push(`\t\t${e}`);c.push(`\t\trows[i] = ${s.literal};`),c.push(` }`),c.push(` return rows;`)}c.push(` //# sourceURL=drizzle:jit-relational-query-mapper`);let l=c.join(`
|
|
29
|
-
`);return Object.assign(new IN(`rows`,l).bind({selection:e}),{body:`function jitRqbMapper (rows) {\n${l}\n}`})}function nP(e,t){let n=e[jM][t];return n?G(n,OM)?n:G(n,q.Aliased)?J`${e}.${J.identifier(n.fieldAlias)}`:J`${e}.${J.identifier(t)}`:J`${e}.${J.identifier(t)}`}function rP(e,t){if(typeof t!=`object`||G(t,$M))return Y(e,t);let n=Object.entries(t);if(!n.length)return;let r=[];for(let[t,i]of n)if(i!==void 0)switch(t){case`NOT`:{let t=rP(e,i);if(!t)continue;r.push(sN(t));continue}case`OR`:if(!i.length)continue;r.push(oN(...i.map(t=>rP(e,t))));continue;case`AND`:if(!i.length)continue;r.push(aN(...i.map(t=>rP(e,t))));continue;case`isNotNull`:case`isNull`:if(!i)continue;r.push(YN[t](e));continue;case`in`:r.push(YN.inArray(e,i));continue;case`notIn`:r.push(YN.notInArray(e,i));continue;default:r.push(YN[t](e,i));continue}if(r.length)return aN(...r)}function iP(e,t,n={},r={},i=0){let a=Object.entries(t);if(!a.length)return;let o=[];for(let[t,s]of a)if(s!==void 0)switch(t){case`RAW`:{let t=typeof s==`function`?s(e,YN):s.getSQL();o.push(t);continue}case`OR`:if(!s?.length)continue;o.push(oN(...s.map(t=>iP(e,t,n,r,i))));continue;case`AND`:if(!s?.length)continue;o.push(aN(...s.map(t=>iP(e,t,n,r,i))));continue;case`NOT`:{if(s===void 0)continue;let t=iP(e,s,n,r,i);if(!t)continue;o.push(sN(t));continue}default:{if(e[jM][t]){let n=rP(nP(e,t),s);n&&o.push(n);continue}let a=n[t];if(!a)throw new nN({message:`Unknown relational filter field: "${t}"`});let c=NN(a.targetTable,`f${i}`),l=a.throughTable?NN(a.throughTable,`ft${i}`):void 0,u=r[a.targetTableName],{filter:d,joinCondition:f}=sP(a,e,c,l),p=aN(d,typeof s==`boolean`?void 0:iP(c,s,u.relations,r,i+1)),m=l?J`(select * from ${cP(c)} inner join ${cP(l)} on ${f}${J` where ${p}`.if(p)} limit 1)`:J`(select * from ${cP(c)}${J` where ${p}`.if(p)} limit 1)`;p&&o.push((s?gN:_N)(m))}}return aN(...o)}function aP(e,t){if(typeof t==`function`){let n=t(e,XN);return G(n,q)?n:Array.isArray(n)?n.length?J.join(n.map(e=>G(e,q)?e:DN(e)),J`, `):void 0:G(n,OM)?DN(n):void 0}let n=Object.entries(t).filter(([e,t])=>t);if(n.length)return J.join(n.map(([t,n])=>(n===`asc`?DN:ON)(nP(e,t))),J`, `)}function oP(e,t,n,r){let i=[],a=[];for(let[o,s]of Object.entries(t)){if(!s)continue;let t=(typeof s==`function`?s(e,{sql:YN.sql}):s).getSQL(),c=n?VN(t):void 0,l=c&&(!r||!c.jsonSelectIdentifier)?J`${n.apply(c,r?`castInJson`:`cast`,J`(${t})`)} as ${J.identifier(o)}`:J`(${t}) as ${J.identifier(o)}`;l.decoder=t.decoder,i.push(l),a.push(c&&(!r||!c.mapFromJsonValue)?{key:o,field:l,codec:n.get(c,r?`normalizeInJson`:`normalize`),arrayDimensions:c.dimensions}:{key:o,field:l})}return{sql:i.length?J.join(i,J`, `):void 0,selection:a}}function sP(e,t,n,r){if(e.through){let i=e.sourceColumns.map((n,i)=>{let a=e.through.source[i];return Y(J`${t}.${J.identifier(n.name)}`,J`${r}.${J.identifier(G(a._.column,OM)?a._.column.name:a._.key)}`)}),a=e.targetColumns.map((t,i)=>{let a=e.through.target[i];return Y(J`${r}.${J.identifier(G(a._.column,OM)?a._.column.name:a._.key)}`,J`${n}.${J.identifier(t.name)}`)});return{filter:aN(e.where?iP(e.isReversed?t:n,e.where):void 0,...i),joinCondition:aN(...a)}}return{filter:aN(...e.sourceColumns.map((r,i)=>{let a=e.targetColumns[i];return Y(J`${t}.${J.identifier(r.name)}`,J`${n}.${J.identifier(a.name)}`)}),e.where?iP(e.isReversed?t:n,e.where):void 0)}}function cP(e){return J`${e[FM]?J`${J`${J.identifier(e[AM]??``)}.`.if(e[AM])}${J.identifier(e[NM])} as ${e}`:e}`}var lP=class{static[W]=`ColumnBuilder`;config;constructor(e,t,n){this.config={name:e,keyAsName:e===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e,t){this.config.name===``&&(this.config.name=t(e))}},uP=class e extends O()(`@usine/engine/internal/RunDatabase`){static layer=t=>Uf(e)(t)},dP=class{static[W]=`SQLiteForeignKeyBuilder`;reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new fP(e,this)}},fP=class{static[W]=`SQLiteForeignKey`;reference;onUpdate;onDelete;constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[kM],...r,n[0].table[kM],...i];return e??`${a.join(`_`)}_fk`}isNameExplicit(){return!!this.reference().name}};function pP(e){function t(){if(typeof e==`function`){let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignColumns:r}}return e}return new dP(t)}var mP=class extends lP{static[W]=`SQLiteColumnBuilder`;foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:`always`,mode:t?.mode??`virtual`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((n,r)=>{let i=new dP(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)})(n,r))}},hP=class extends OM{static[W]=`SQLiteColumn`;table;constructor(e,t){super(e,t),this.table=e}};function gP(e){let t=``;for(let n=0;n<e.length;n+=2){let r=e.slice(n,n+2),i=Number.parseInt(r,16);t+=String.fromCodePoint(i)}return t}var _P=class extends mP{static[W]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint int64`,`SQLiteBigInt`)}build(e){return new vP(e,this.config)}},vP=class extends hP{static[W]=`SQLiteBigInt`;getSQLType(){return`blob`}mapFromDriverValue=e=>{if(typeof e==`string`)return BigInt(gP(e));if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString(`utf8`))}return BigInt(KN.decode(e))};mapToDriverValue=e=>Buffer.from(e.toString())},yP=class extends mP{static[W]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`object json`,`SQLiteBlobJson`)}build(e){return new bP(e,this.config)}},bP=class extends hP{static[W]=`SQLiteBlobJson`;getSQLType(){return`blob`}mapFromDriverValue=e=>{if(typeof e==`string`)return JSON.parse(gP(e));if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString(`utf8`))}return JSON.parse(KN.decode(e))};mapToDriverValue=e=>Buffer.from(JSON.stringify(e))},xP=class extends mP{static[W]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`object buffer`,`SQLiteBlobBuffer`)}build(e){return new SP(e,this.config)}},SP=class extends hP{static[W]=`SQLiteBlobBuffer`;mapFromDriverValue=e=>Buffer.isBuffer(e)?e:typeof e==`string`?Buffer.from(e,`hex`):Buffer.from(e);getSQLType(){return`blob`}};function CP(e,t){let{name:n,config:r}=GN(e,t);return r?.mode===`bigint`?new _P(n):r?.mode===`buffer`?new xP(n):new yP(n)}var wP=class extends mP{static[W]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new TP(e,this.config)}},TP=class extends hP{static[W]=`SQLiteCustomColumn`;sqlName;mapTo;mapFrom;mapJson;forJsonSelect;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver,this.mapJson=t.customTypeParams.fromJson,this.forJsonSelect=t.customTypeParams.forJsonSelect}getSQLType(){return this.sqlName}mapFromDriverValue=e=>typeof this.mapFrom==`function`?this.mapFrom(e):e;mapFromJsonValue(e){return typeof this.mapJson==`function`?this.mapJson(e):this.mapFromDriverValue(e)}jsonSelectIdentifier(e,t){if(typeof this.forJsonSelect==`function`)return this.forJsonSelect(e,t);let n=this.getSQLType().toLowerCase(),r=n.indexOf(`(`);switch(r+1?n.slice(0,r):n){case`numeric`:case`decimal`:case`bigint`:return t`cast(${e} as text)`;case`blob`:return t`hex(${e})`;default:return e}}mapToDriverValue=e=>typeof this.mapTo==`function`?this.mapTo(e):e};function EP(e){return(t,n)=>{let{name:r,config:i}=GN(t,n);return new wP(r,i,e)}}var DP=class extends mP{static[W]=`SQLiteBaseIntegerBuilder`;constructor(e,t,n){super(e,t,n),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}},OP=class extends hP{static[W]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},kP=class extends DP{static[W]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number int53`,`SQLiteInteger`)}build(e){return new AP(e,this.config)}},AP=class extends OP{static[W]=`SQLiteInteger`},jP=class extends DP{static[W]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`object date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(J`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new MP(e,this.config)}},MP=class extends OP{static[W]=`SQLiteTimestamp`;mode=this.config.mode;mapFromDriverValue=e=>typeof e==`string`?new Date(e.replaceAll(`"`,``)):this.config.mode===`timestamp`?new Date(e*1e3):new Date(e);mapToDriverValue=e=>{if(typeof e==`number`)return e;let t=e.getTime();return this.config.mode===`timestamp`?Math.floor(t/1e3):t}},NP=class extends DP{static[W]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new PP(e,this.config)}},PP=class extends OP{static[W]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue=e=>Number(e)===1;mapToDriverValue=e=>+!!e};function FP(e,t){let{name:n,config:r}=GN(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new jP(n,r.mode):r?.mode===`boolean`?new NP(n,r.mode):new kP(n)}var IP=class extends mP{static[W]=`SQLiteNumericBuilder`;constructor(e){super(e,`string numeric`,`SQLiteNumeric`)}build(e){return new LP(e,this.config)}},LP=class extends hP{static[W]=`SQLiteNumeric`;mapFromDriverValue=e=>typeof e==`string`?e:String(e);getSQLType(){return`numeric`}},RP=class extends mP{static[W]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new zP(e,this.config)}},zP=class extends hP{static[W]=`SQLiteNumericNumber`;mapFromDriverValue=e=>typeof e==`number`?e:Number(e);mapToDriverValue=String;getSQLType(){return`numeric`}},BP=class extends mP{static[W]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint int64`,`SQLiteNumericBigInt`)}build(e){return new VP(e,this.config)}},VP=class extends hP{static[W]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function HP(e,t){let{name:n,config:r}=GN(e,t),i=r?.mode;return i===`number`?new RP(n):i===`bigint`?new BP(n):new IP(n)}var UP=class extends mP{static[W]=`SQLiteRealBuilder`;constructor(e){super(e,`number double`,`SQLiteReal`)}build(e){return new WP(e,this.config)}},WP=class extends hP{static[W]=`SQLiteReal`;getSQLType(){return`real`}};function GP(e){return new UP(e??``)}var KP=class extends mP{static[W]=`SQLiteTextBuilder`;constructor(e,t){super(e,t.enum?.length?`string enum`:`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new qP(e,this.config)}},qP=class extends hP{static[W]=`SQLiteText`;enumValues=this.config.enumValues;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},JP=class extends mP{static[W]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`object json`,`SQLiteTextJson`)}build(e){return new YP(e,this.config)}},YP=class extends hP{static[W]=`SQLiteTextJson`;getSQLType(){return`text`}mapFromDriverValue=e=>JSON.parse(e);mapToDriverValue=e=>JSON.stringify(e)};function X(e,t={}){let{name:n,config:r}=GN(e,t);return r.mode===`json`?new JP(n):new KP(n,r)}function XP(){return{blob:CP,customType:EP,integer:FP,numeric:HP,real:GP,text:X}}function ZP(e){return(e.replace(/['\u2019]/g,``).match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join(`_`)}function QP(e){return(e.replace(/['\u2019]/g,``).match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,n)=>e+(n===0?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`),``)}function $P(e){return e===`snake_case`?ZP:e===`camelCase`?QP:e=>e}var eF=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),tF=class extends K{static[W]=`SQLiteTable`;static Symbol=Object.assign({},K.Symbol,{InlineForeignKeys:eF});[K.Symbol.Columns];[eF]=[];[K.Symbol.ExtraConfigBuilder]=void 0};function nF(e,t,n,r,i,a=e){let o=$P(i),s=new tF(e,r,a),c=typeof t==`function`?t(XP()):t,l=Object.fromEntries(Object.entries(c).map(([e,t])=>{let n=t;n.setName(e,o);let r=n.build(s).postBuild();return s[eF].push(...n.buildForeignKeys(r,s)),[e,r]})),u=Object.assign(s,l);return u[K.Symbol.Columns]=l,u[K.Symbol.ExtraConfigColumns]=l,n&&(u[tF.Symbol.ExtraConfigBuilder]=n),u}function rF(e){return(t,n,r)=>nF(t,n,r,void 0,e)}var iF=class{static[W]=`SQLiteCheckBuilder`;brand;constructor(e,t){this.name=e,this.value=t}build(e){return new aF(e,this)}},aF=class{static[W]=`SQLiteCheck`;name;value;constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}};function oF(e,t){return new iF(e,t)}var sF=class{static[W]=`SQLiteIndexBuilderOn`;constructor(e,t){this.name=e,this.unique=t}on(...e){return new cF(this.name,e,this.unique)}},cF=class{static[W]=`SQLiteIndexBuilder`;config;constructor(e,t,n){this.config={name:e,columns:t,unique:n,where:void 0}}where(e){return this.config.where=e,this}build(e){return new lF(this.config,e)}},lF=class{static[W]=`SQLiteIndex`;config;isNameExplicit;constructor(e,t){this.config={...e,table:t},this.isNameExplicit=!!e.name}};function uF(e){return new sF(e,!1)}function dF(e){return new sF(e,!0)}function fF(...e){return e[0].columns?new pF(e[0].columns,e[0].name):new pF(e)}var pF=class{static[W]=`SQLitePrimaryKeyBuilder`;columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new mF(e,this.columns,this.name)}},mF=class{static[W]=`SQLitePrimaryKey`;columns;name;isNameExplicit;constructor(e,t,n){this.table=e,this.columns=t,this.name=n,this.isNameExplicit=!!n}getName(){return this.name??`${this.table[tF.Symbol.Name]}_${this.columns.map(e=>e.name).join(`_`)}_pk`}};function hF(e){return G(e,tF)?[`${e[K.Symbol.BaseName]}`]:G(e,zM)?e._.usedTables??[]:G(e,q)?e.usedTables??[]:[]}var gF=class extends tN{static[W]=`SQLiteViewBase`},_F=class e{static[W]=`SelectionProxyHandler`;config;constructor(e){this.config={...e}}get(t,n){if(n===`_`)return{...t._,selectedFields:new Proxy(t._.selectedFields,this)};if(n===HM)return{...t[HM],selectedFields:new Proxy(t[HM].selectedFields,this)};if(typeof n==`symbol`)return t[n];let r=(G(t,zM)?t._.selectedFields:G(t,tN)?t[HM].selectedFields:t)[n];if(G(r,q.Aliased)){if(this.config.sqlAliasedBehavior===`sql`&&!r.isSelectionField)return r.sql;let e=r.clone();return e.isSelectionField=!0,e.origin=this.config.alias,e}if(G(r,q)){if(this.config.sqlBehavior===`sql`)return r;throw Error(`You tried to reference "${n}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return G(r,OM)?this.config.alias?new Proxy(r,new kN(new Proxy(r.table,new jN(this.config.alias,this.config.replaceOriginalName??!1,!0)),!0)):r:typeof r!=`object`||!r?r:new Proxy(r,new e(this.config))}},vF=class{static[W]=`TypedQueryBuilder`;getSelectedFields(){return this._.selectedFields}withoutSelectionCastCodecs(){return this}},yF=class{static[W]=`SQLiteSelectBuilder`;fields;session;dialect;withList;distinct;constructor(e,t=bF){this.builder=t,this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let t=!!this.fields,n;return n=this.fields?this.fields:G(e,zM)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):G(e,gF)?e[HM].selectedFields:G(e,q)?{}:UN(e),new this.builder({table:e,fields:n,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList??[],distinct:this.distinct})}},bF=class extends vF{static[W]=`SQLiteSelectQueryBuilder`;_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:n,session:r,dialect:i,withList:a,distinct:o}){super(),this.config={withList:a,table:e,fields:{...t},distinct:o,setOperators:[]},this.isPartialSelect=n,this.session=r,this.dialect=i,this._={selectedFields:t,config:this.config},this.tableName=WN(e),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{};for(let t of hF(e))this.usedTables.add(t)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,n)=>{let r=this.tableName,i=WN(t);for(let e of hF(t))this.usedTables.add(e);if(typeof i==`string`&&this.config.joins?.some(e=>e.alias===i))throw Error(`Alias "${i}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof r==`string`&&(this.config.fields={[r]:this.config.fields}),typeof i==`string`&&!G(t,q))){let e=G(t,zM)?t._.selectedFields:G(t,tN)?t[HM].selectedFields:t[K.Symbol.Columns];this.config.fields[i]=e}if(typeof n==`function`&&(n=n(new Proxy(this.config.fields,new _F({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:n,table:t,joinType:e,alias:i}),typeof i==`string`)switch(e){case`left`:this.joinsNotNullableMap[i]=!1;break;case`right`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[i]=!0;break;case`cross`:case`inner`:this.joinsNotNullableMap[i]=!0;break;case`full`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[i]=!1;break}return this}}leftJoin=this.createJoin(`left`);rightJoin=this.createJoin(`right`);innerJoin=this.createJoin(`inner`);fullJoin=this.createJoin(`full`);crossJoin=this.createJoin(`cross`);createSetOperator(e,t){return n=>{let r=typeof n==`function`?n(SF()):n;if(!HN(this.getSelectedFields(),r.getSelectedFields()))throw Error(`Set operator error (union / intersect / except): selected fields are not the same or are in a different order`);return this.config.setOperators.push({type:e,isAll:t,rightSelect:r}),this}}union=this.createSetOperator(`union`,!1);unionAll=this.createSetOperator(`union`,!0);intersect=this.createSetOperator(`intersect`,!1);except=this.createSetOperator(`except`,!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return typeof e==`function`&&(e=e(new Proxy(this.config.fields,new _F({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.where=e,this}having(e){return typeof e==`function`&&(e=e(new Proxy(this.config.fields,new _F({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.having=e,this}groupBy(...e){if(typeof e[0]==`function`){let t=e[0](new Proxy(this.config.fields,new _F({sqlAliasedBehavior:`alias`,sqlBehavior:`sql`})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]==`function`){let t=e[0](new Proxy(this.config.fields,new _F({sqlAliasedBehavior:`alias`,sqlBehavior:`sql`}))),n=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=n:this.config.orderBy=n}else{let t=e;this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=t:this.config.orderBy=t}return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}$withCache(e){return this.cacheConfig=e===void 0?{config:{},enabled:!0,autoInvalidate:!0}:e===!1?{enabled:!1}:{enabled:!0,autoInvalidate:!0,...e},this}getSQL(){return this.config.fieldsFlat=BN(this.config.fields),this.dialect.buildSelectQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}as(e){let t=[];if(t.push(...hF(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...hF(e.table));return new Proxy(new zM(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new _F({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`}))}getSelectedFields(){return new Proxy(this.config.fields,new _F({alias:this.tableName,sqlAliasedBehavior:`alias`,sqlBehavior:`error`}))}withoutSelectionCastCodecs(){return this}$dynamic(){return this}};function xF(e,t){return(n,r,...i)=>{let a=[r,...i].map(n=>({type:e,isAll:t,rightSelect:n}));for(let e of a)if(!HN(n.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error(`Set operator error (union / intersect / except): selected fields are not the same or are in a different order`);return n.addSetOperators(a)}}var SF=()=>({union:CF,unionAll:wF,intersect:TF,except:EF}),CF=xF(`union`,!1),wF=xF(`union`,!0),TF=xF(`intersect`,!1),EF=xF(`except`,!1),DF=class{static[W]=`SQLiteDialect`;mapperGenerators;constructor(e){this.mapperGenerators=e?.useJitMappers?{rows:RN,relationalRows:tP}:{rows:zN,relationalRows:$N}}escapeName(e){return`"${e.replace(/"/g,`""`)}"`}escapeParam(e){return`?`}escapeString(e){return`'${e.replace(/'/g,`''`)}'`}buildWithCTE(e){if(!e?.length)return;let t=[J`with `];for(let[n,r]of e.entries())t.push(J`${J.identifier(r._.alias)} as (${r._.sql})`),n<e.length-1&&t.push(J`, `);return t.push(J` `),J.join(t)}buildDeleteQuery({table:e,where:t,returning:n,withList:r,limit:i,orderBy:a}){let o=this.buildWithCTE(r),s=n?J` returning ${this.buildSelection(n,{isSingleTable:!0})}`:void 0;return J`${o}delete from ${e}${t?J` where ${t}`:void 0}${s}${this.buildOrderBy(a)}${this.buildLimit(i)}`}buildUpdateSet(e,t){let n=e[K.Symbol.Columns],r=Object.keys(n).filter(e=>t[e]!==void 0||n[e]?.onUpdateFn!==void 0),i=r.length;return J.join(r.flatMap((e,r)=>{let a=n[e],o=a.onUpdateFn?.(),s=t[e]??(G(o,q)?o:J.param(o,a)),c=J`${J.identifier(a.name)} = ${s}`;return r<i-1?[c,J.raw(`, `)]:[c]}))}buildUpdateQuery({table:e,set:t,where:n,returning:r,withList:i,joins:a,from:o,limit:s,orderBy:c}){let l=this.buildWithCTE(i),u=this.buildUpdateSet(e,t),d=o&&J.join([J.raw(` from `),this.buildFromTable(o)]),f=this.buildJoins(a),p=r?J` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0;return J`${l}update ${e} set ${u}${d}${f}${n?J` where ${n}`:void 0}${p}${this.buildOrderBy(c)}${this.buildLimit(s)}`}buildSelection(e,{isSingleTable:t=!1}={}){let n=e.length,r=e.flatMap(({field:e},r)=>{let i=[];if(G(e,q.Aliased)){if(e.isSelectionField)!t&&e.origin!==void 0&&i.push(J.identifier(e.origin),J.raw(`.`)),i.push(J.identifier(e.fieldAlias));else{let n=e.sql;if(t){let e=new q(n.queryChunks.map(e=>G(e,OM)?J.identifier(e.name):e));i.push(n.shouldInlineParams?e.inlineParams():e)}else i.push(n);i.push(J` as ${J.identifier(e.fieldAlias)}`)}}else if(G(e,q)){let n=e;if(t){let e=new q(n.queryChunks.map(e=>G(e,OM)?J.identifier(e.name):e));i.push(n.shouldInlineParams?e.inlineParams():e)}else i.push(n)}else G(e,OM)?e.columnType===`SQLiteNumericBigInt`||e.columnType===`SQLiteNumeric`?t?i.push(e.isAlias?J`cast(${J.identifier(FN(e).name)} as text) as ${e}`:J`cast(${J.identifier(e.name)} as text)`):i.push(e.isAlias?J`cast(${FN(e)} as text) as ${e}`:J`cast(${e} as text)`):t?i.push(e.isAlias?J`${J.identifier(FN(e).name)} as ${e}`:J.identifier(e.name)):i.push(e.isAlias?J`${FN(e)} as ${e}`:e):G(e,zM)&&(e._.isWith?i.push(e):i.push(J`(${e._.sql}) ${J.identifier(e._.alias)}`));return r<n-1&&i.push(J`, `),i});return J.join(r)}buildJoins(e){if(!e||e.length===0)return;let t=[];if(e)for(let[n,r]of e.entries()){n===0&&t.push(J` `);let i=r.table,a=r.on?J` on ${r.on}`:void 0;if(G(i,tF)){let e=i[tF.Symbol.Name],n=i[tF.Symbol.Schema],o=i[tF.Symbol.OriginalName],s=e===o?void 0:r.alias;t.push(J`${J.raw(r.joinType)} join ${n?J`${J.identifier(n)}.`:void 0}${J.identifier(o)}${s&&J` ${J.identifier(s)}`}${a}`)}else t.push(J`${J.raw(r.joinType)} join ${i}${a}`);n<e.length-1&&t.push(J` `)}return J.join(t)}buildLimit(e){return typeof e==`object`||typeof e==`number`&&e>=0?J` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[n,r]of e.entries())t.push(r),n<e.length-1&&t.push(J`, `);return t.length>0?J` order by ${J.join(t)}`:void 0}buildFromTable(e){if(G(e,K)&&e[K.Symbol.IsAlias])return J`${J`${J.identifier(e[K.Symbol.Schema]??``)}.`.if(e[K.Symbol.Schema])}${J.identifier(e[K.Symbol.OriginalName])} ${J.identifier(e[K.Symbol.Name])}`;if(G(e,tN)&&e[HM].isAlias){let t=J`${J.identifier(e[HM].originalName)}`;return e[HM].schema&&(t=J`${J.identifier(e[HM].schema)}.${t}`),J`${t} ${J.identifier(e[HM].name)}`}return e}buildSelectQuery({withList:e,fields:t,fieldsFlat:n,where:r,having:i,table:a,joins:o,orderBy:s,groupBy:c,limit:l,offset:u,distinct:d,setOperators:f}){let p=n??BN(t);for(let e of p)if(G(e.field,OM)&&RM(e.field.table)!==(G(a,zM)?a._.alias:G(a,gF)?a[HM].name:G(a,q)?void 0:RM(a))&&!(e=>o?.some(({alias:t})=>t===(e[K.Symbol.IsAlias]?RM(e):e[K.Symbol.BaseName])))(e.field.table)){let t=RM(e.field.table);throw Error(`Your "${e.path.join(`->`)}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}let m=!o||o.length===0,h=this.buildWithCTE(e),g=d?J` distinct`:void 0,_=this.buildSelection(p,{isSingleTable:m}),v=this.buildFromTable(a),y=this.buildJoins(o),b=r?J` where ${r}`:void 0,x=i?J` having ${i}`:void 0,ee=[];if(c)for(let[e,t]of c.entries())ee.push(t),e<c.length-1&&ee.push(J`, `);let te=J`${h}select${g} ${_} from ${v}${y}${b}${ee.length>0?J` group by ${J.join(ee)}`:void 0}${x}${this.buildOrderBy(s)}${this.buildLimit(l)}${u?J` offset ${u}`:void 0}`;return f.length>0?this.buildSetOperations(te,f):te}buildSetOperations(e,t){let[n,...r]=t;if(!n)throw Error(`Cannot pass undefined values to any set operator`);return r.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:n}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:n}),r)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:n,rightSelect:r,limit:i,orderBy:a,offset:o}}){let s=J`${e.getSQL()} `,c=J`${r.getSQL()}`,l;if(a&&a.length>0){let e=[];for(let t of a)if(G(t,hP))e.push(J.identifier(t.name));else if(G(t,q)){for(let e=0;e<t.queryChunks.length;e++){let n=t.queryChunks[e];G(n,hP)&&(t.queryChunks[e]=J.identifier(n.name))}e.push(J`${t}`)}else e.push(J`${t}`);l=J` order by ${J.join(e,J`, `)}`}let u=typeof i==`object`||typeof i==`number`&&i>=0?J` limit ${i}`:void 0,d=J.raw(`${t} ${n?`all `:``}`),f=o?J` offset ${o}`:void 0;return J`${s}${d}${c}${l}${u}${f}`}buildInsertQuery({table:e,values:t,onConflict:n,returning:r,withList:i,select:a}){let o=[],s=e[K.Symbol.Columns],c=Object.entries(s),l=a&&!G(t,q)?Object.keys(t.getSelectedFields()).map(e=>[e,s[e]]):c.filter(([e,t])=>!t.shouldDisableInsert()),u=l.map(([,e])=>J.identifier(e.name));if(a){let e=t;G(e,q)?o.push(e):o.push(e.getSQL())}else{let e=t;o.push(J.raw(`values `));for(let[t,n]of e.entries()){let r=[];for(let[e,t]of l){let i=n[e];if(i===void 0||G(i,ZM)&&i.value===void 0){let e;if(t.default!==null&&t.default!==void 0)e=G(t.default,q)?t.default:J.param(t.default,t);else if(t.defaultFn!==void 0){let n=t.defaultFn();e=G(n,q)?n:J.param(n,t)}else if(!t.default&&t.onUpdateFn!==void 0){let n=t.onUpdateFn();e=G(n,q)?n:J.param(n,t)}else e=J`null`;r.push(e)}else r.push(i)}o.push(r),t<e.length-1&&o.push(J`, `)}}let d=this.buildWithCTE(i),f=J.join(o),p=r?J` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0;return J`${d}insert into ${e} ${u} ${f}${n?.length?J.join(n):void 0}${p}`}sqlToQuery(e,t){return e.toQuery({escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}nestedSelectionerror(){throw new nN({message:`Views with nested selections are not supported by the relational query builder`})}buildRqbColumn(e,t,n,r){if(G(t,OM)){let i=J`${e}.${J.identifier(t.name)}`;switch(t.columnType){case`SQLiteBigInt`:case`SQLiteBlobJson`:case`SQLiteBlobBuffer`:return r?J`hex(${i}) as ${J.identifier(n)}`:J`${i} as ${J.identifier(n)}`;case`SQLiteNumeric`:case`SQLiteNumericNumber`:case`SQLiteNumericBigInt`:return J`cast(${i} as text) as ${J.identifier(n)}`;case`SQLiteCustomColumn`:return r?J`${t.jsonSelectIdentifier(i,J)} as ${J.identifier(n)}`:J`${i} as ${J.identifier(n)}`;default:return J`${i} as ${J.identifier(n)}`}}return J`${e}.${G(t,q.Aliased)?J.identifier(t.fieldAlias):UM(t)?J.identifier(n):this.nestedSelectionerror()} as ${J.identifier(n)}`}unwrapAllColumns=(e,t,n)=>J.join(Object.entries(e[jM]).map(([r,i])=>(t.push({key:r,field:i}),this.buildRqbColumn(e,i,r,n))),J`, `);getSelectedTableColumns=(e,t)=>{let n=[],r=e[jM],i=Object.entries(t),a;for(let[e,t]of i)if(t!==void 0&&(a||=t,t)){let t=r[e];n.push({column:t,tsName:e})}if(a===!1)for(let[e,i]of Object.entries(r))t[e]!==!1&&n.push({column:i,tsName:e});return n};buildColumns=(e,t,n,r)=>r?.columns?(()=>{let i=[],a=this.getSelectedTableColumns(e,r?.columns);for(let{column:r,tsName:o}of a)i.push(this.buildRqbColumn(e,r,o,n)),t.push({key:o,field:r});return i.length?J.join(i,J`, `):void 0})():this.unwrapAllColumns(e,t,n);buildRelationalQuery({schema:e,table:t,tableConfig:n,queryConfig:r,relationWhere:i,mode:a,isNested:o,errorPath:s,depth:c,throughJoin:l,jsonb:u}){let d=[],f=a===`first`,p=r===!0?void 0:r,m=s??``,h=c??0;h||(t=NN(t,`d${h}`));let g=f?1:p?.limit,_=p?.offset,v=this.buildColumns(t,d,!!o,p),y=p?.where&&i?aN(iP(t,p.where,n.relations,e),i):p?.where?iP(t,p.where,n.relations,e):i,b=p?.orderBy?aP(t,p.orderBy):void 0,x=p?.extras?oP(t,p.extras):void 0;x&&d.push(...x.selection);let ee=p?(()=>{let{with:r}=p;if(!r)return;let i=Object.entries(r).filter(([e,t])=>t);if(i.length)return J.join(i.map(([r,i])=>{let a=n.relations[r],s=G(a,JN),c=NN(a.targetTable,`d${h+1}`),l=a.throughTable?NN(a.throughTable,`tr${h}`):void 0,{filter:f,joinCondition:p}=sP(a,t,c,l),g=l?J` inner join ${cP(l)} on ${p}`:void 0,_=this.buildRelationalQuery({table:c,mode:s?`first`:`many`,schema:e,queryConfig:i,tableConfig:e[a.targetTableName],relationWhere:f,isNested:!0,errorPath:`${m.length?`${m}.`:``}${r}`,depth:h+1,throughJoin:g,jsonb:u});d.push({field:c,key:r,selection:_.selection,isArray:!s,isOptional:(a.optional??!1)||i!==!0&&!!i.where});let v=J.join(_.selection.map(e=>J`${J.raw(this.escapeString(e.key))}, ${e.selection?J`${u}(${J.identifier(e.key)})`:J.identifier(e.key)}`),J`, `),y=o?u:J`json`;return s?J`(select ${y}_object(${v}) as ${J.identifier(`r`)} from (${_.sql}) as ${J.identifier(`t`)}) as ${J.identifier(r)}`:J`coalesce((select ${y}_group_array(json_object(${v})) as ${J.identifier(`r`)} from (${_.sql}) as ${J.identifier(`t`)}), ${u}_array()) as ${J.identifier(r)}`}),J`, `)})():void 0,te=[v,x?.sql,ee].filter(e=>e!==void 0);if(!te.length)throw new nN({message:`No fields selected for table "${n.name}"${m?` ("${m}")`:``}`});return{sql:J`select ${J.join(te,J`, `)} from ${cP(t)}${l}${J` where ${y}`.if(y)}${J` order by ${b}`.if(b)}${J` limit ${g}`.if(g!==void 0)}${J` offset ${_}`.if(_!==void 0)}`,selection:d}}},OF=class{static[W]=`SQLiteQueryBuilder`;dialect;dialectConfig;constructor(e){this.dialect=G(e,DF)?e:void 0,this.dialectConfig=G(e,DF)?void 0:e}$with=(e,t)=>{let n=this;return{as:r=>(typeof r==`function`&&(r=r(n)),new Proxy(new BM(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new _F({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})))}};with(...e){let t=this;function n(n){return new yF({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function r(n){return new yF({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}return{select:n,selectDistinct:r}}select(e){return new yF({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new yF({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){return this.dialect||=new DF(this.dialectConfig),this.dialect}},kF=class{static[W]=`SQLiteViewBuilderCore`;constructor(e){this.name=e}config={}},AF=class extends kF{static[W]=`SQLiteViewBuilder`;as(e){typeof e==`function`&&(e=e(new OF));let t=new _F({alias:this.name,sqlBehavior:`error`,sqlAliasedBehavior:`alias`,replaceOriginalName:!0}),n=e.getSelectedFields();return new Proxy(new MF({config:{name:this.name,schema:void 0,selectedFields:n,query:e.getSQL().inlineParams()}}),t)}},jF=class extends kF{static[W]=`SQLiteManualViewBuilder`;columns;constructor(e,t,n){super(e),this.columns=UN(nF(e,t,void 0,void 0,n))}existing(){return new Proxy(new MF({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:void 0}}),new _F({alias:this.name,sqlBehavior:`error`,sqlAliasedBehavior:`alias`,replaceOriginalName:!0}))}as(e){return new Proxy(new MF({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:e.inlineParams()}}),new _F({alias:this.name,sqlBehavior:`error`,sqlAliasedBehavior:`alias`,replaceOriginalName:!0}))}},MF=class extends gF{static[W]=`SQLiteView`;constructor({config:e}){super(e)}};function NF(e){return((t,n)=>n?new jF(t,n,e):new AF(t))}var PF={table:rF(`snake_case`),view:NF(`snake_case`)};function FF(e,t){return new Proxy(e,new jN(t,!1))}var IF=class extends H(`@usine/engine/Submission`)({event:eT,itemKey:NE,loop:tT,step:JT,approval:rT,cycleLimit:$S(FE).pipe(NS(k(E(LE))),AS(k(E(LE)))),cycleGeneration:IE.pipe(MS(k(IE.make(0))),AS(k(IE.make(0)))),repository:qw,revision:Jw,task:AE,agent:WT,parentModel:$S(RT)}){},LF=class extends U(`@usine/engine/Claimed`)(`Claimed`,{eventId:Qw,runId:FT}){},RF=class extends U(`@usine/engine/Queued`)(`Queued`,{eventId:Qw}){},zF=[`superseded`,`revoked`],BF=ES(zF),VF=class extends U(`@usine/engine/Ignored`)(`Ignored`,{eventId:Qw,reason:BF}){},HF=class extends U(`@usine/engine/CycleBlocked`)(`CycleBlocked`,{eventId:Qw,ask:VE}){},UF=R([LF,RF,VF,HF]),WF=[`Approve`,`Continue`,`Interrupt`,`Resume`],GF=ES(WF),KF=[`Resume`,`Interrupt`,`Continue`,`Approve`],qF=PF.table(`usine_events`,{eventId:X().$type().primaryKey(),dedupKey:X().$type().notNull().unique(),payloadJson:X({mode:`json`}).$type().notNull(),receivedAt:X().notNull()},e=>[oF(`usine_events_payload_json_valid`,J`json_valid(${e.payloadJson})`)]),Z=PF.table(`usine_trigger_events`,{eventId:X().$type().primaryKey().references(()=>qF.eventId),itemKey:X().$type().notNull(),loopName:X().$type().notNull(),stepName:X().$type().notNull(),approval:X({enum:nT}).$type().notNull(),cycleLimit:FP().$type(),cycleGeneration:FP().notNull().default(0),repository:X().$type().notNull(),revision:X().$type().notNull(),task:X().$type().notNull(),agentJson:X({mode:`json`}).$type().notNull(),parentModel:X().$type()},e=>[oF(`usine_trigger_events_approval`,J`${e.approval} in ('none', 'required')`),oF(`usine_trigger_events_cycle_limit`,J`${e.cycleLimit} is null or ${e.cycleLimit} >= 1`),oF(`usine_trigger_events_agent_json_valid`,J`json_valid(${e.agentJson})`),uF(`usine_trigger_events_item`).on(e.loopName,e.itemKey),uF(`usine_trigger_events_item_history`).on(e.itemKey)]),JF=PF.table(`usine_item_cycle_budgets`,{itemKey:X().$type().primaryKey(),repository:X().$type().notNull(),generation:FP().notNull().default(0),askJson:X({mode:`json`}).$type(),resetPending:FP({mode:`boolean`}).notNull().default(!1)},e=>[oF(`usine_item_cycle_generation`,J`${e.generation} >= 0`),oF(`usine_item_cycle_ask_json`,J`${e.askJson} is null or json_valid(${e.askJson})`)]),YF=PF.table(`usine_cycle_reservations`,{runId:X().$type().primaryKey().references(()=>Q.runId),itemKey:X().$type().notNull().references(()=>JF.itemKey),generation:FP().notNull(),loop:X().$type().notNull()},e=>[uF(`usine_cycle_reservations_item`).on(e.itemKey,e.generation,e.loop),oF(`usine_cycle_reservations_generation`,J`${e.generation} >= 0`)]),XF=PF.table(`usine_cycle_resets`,{askId:X().$type().primaryKey(),eventId:X().$type().notNull().unique().references(()=>qF.eventId),itemKey:X().$type().notNull().references(()=>JF.itemKey)}),Q=PF.table(`usine_runs`,{runId:X().$type().primaryKey(),eventId:X().$type().notNull().unique().references(()=>Z.eventId),loopName:X().$type().notNull(),stateJson:X({mode:`json`}).$type().notNull(),openedAt:X().notNull(),repository:X().$type().notNull(),revision:X().$type().notNull(),task:X().$type().notNull(),agentJson:X({mode:`json`}).$type().notNull(),parentModel:X().$type()},e=>[oF(`usine_runs_state_json_valid`,J`json_valid(${e.stateJson})`),oF(`usine_runs_agent_json_valid`,J`json_valid(${e.agentJson})`)]),ZF=PF.table(`usine_steps`,{runId:X().$type().notNull().references(()=>Q.runId),stepName:X().$type().notNull(),result:X({mode:`json`}).$type()},e=>[fF({columns:[e.runId,e.stepName]}),oF(`usine_steps_result_json_valid`,J`${e.result} is null or json_valid(${e.result})`)]),QF=PF.table(`usine_attempts`,{attemptId:X().$type().primaryKey(),runId:X().$type().notNull(),stepName:X().$type().notNull(),workerName:X().$type().notNull(),attemptNumber:FP({mode:`number`}).$type().notNull(),brainJson:X({mode:`json`}).$type().notNull(),task:X().$type().notNull(),agent:X().$type().notNull(),operatorIntervened:FP({mode:`boolean`}).notNull().default(!1),parentModel:X().$type(),startedAt:X().notNull(),outcomeJson:X({mode:`json`}).$type()},e=>[oF(`usine_attempts_number`,J`${e.attemptNumber} >= 1`),oF(`usine_attempts_brain_json_valid`,J`json_valid(${e.brainJson})`),oF(`usine_attempts_outcome_json_valid`,J`${e.outcomeJson} is null or json_valid(${e.outcomeJson})`),dF(`usine_attempt_number`).on(e.runId,e.stepName,e.attemptNumber),dF(`usine_one_in_flight_attempt`).on(e.runId).where(J`${e.outcomeJson} is null`),pP({columns:[e.runId,e.stepName],foreignColumns:[ZF.runId,ZF.stepName]})]),$F=PF.table(`usine_attempt_transcripts`,{sequence:FP({mode:`number`}).primaryKey({autoIncrement:!0}),attemptId:X().$type().notNull().references(()=>QF.attemptId),direction:X({enum:UE}).notNull(),channelSequence:FP({mode:`number`}).$type().notNull(),envelope:X({mode:`json`}).$type().notNull(),receivedAt:X().notNull()},e=>[oF(`usine_attempt_transcripts_direction`,J`${e.direction} in ('inbound', 'outbound')`),oF(`usine_attempt_transcripts_sequence`,J`${e.channelSequence} >= 1`),oF(`usine_attempt_transcripts_envelope_json_valid`,J`json_valid(${e.envelope})`),dF(`usine_attempt_transcript_envelope`).on(e.attemptId,e.direction,e.channelSequence),uF(`usine_attempt_transcript_tail`).on(e.attemptId,e.sequence)]),eI=PF.table(`usine_approvals`,{runId:X().$type().primaryKey().references(()=>Q.runId),eventId:X().$type().notNull().unique().references(()=>qF.eventId)}),tI=PF.table(`usine_ignored_events`,{eventId:X().$type().primaryKey().references(()=>Z.eventId),reason:X({enum:zF}).$type().notNull()},e=>[oF(`usine_ignored_events_reason`,J`${e.reason} in ('superseded', 'revoked')`)]),nI=PF.table(`usine_workflow_commands`,{runId:X().$type().notNull().references(()=>Q.runId),command:X({enum:WF}).$type().notNull()},e=>[oF(`usine_workflow_commands_command`,J`${e.command} in ('Approve', 'Continue', 'Interrupt', 'Resume')`),fF({columns:[e.runId,e.command]})]);PF.table(`usine_cursors`,{cursorKey:X().primaryKey(),valueJson:X({mode:`json`}).$type().notNull()},e=>[oF(`usine_cursors_value_json_valid`,J`json_valid(${e.valueJson})`)]);var rI=PF.table(`usine_item_projections`,{itemKey:X().$type().primaryKey(),repository:X().$type().notNull(),source:X().notNull(),itemNumber:FP({mode:`number`}).notNull(),contentHash:X().notNull(),payloadJson:X({mode:`json`}).$type().notNull()},e=>[oF(`usine_item_projections_number`,J`${e.itemNumber} >= 1`),oF(`usine_item_projections_payload_json_valid`,J`json_valid(${e.payloadJson})`),dF(`usine_item_projection_number`).on(e.repository,e.itemNumber),uF(`usine_item_projection_repository`).on(e.repository,e.itemNumber)]),iI=PF.table(`usine_repository_label_projections`,{repository:X().$type().primaryKey(),labelsJson:X({mode:`json`}).$type().notNull()},e=>[oF(`usine_repository_label_projections_labels_json_valid`,J`json_valid(${e.labelsJson})`)]),aI=PF.table(`usine_loop_runtime`,{loopName:X().$type().primaryKey(),paused:FP({mode:`boolean`}).notNull()}),oI=PF.table(`usine_projection_revision`,{singleton:FP({mode:`number`}).primaryKey().default(1),revision:FP({mode:`number`}).notNull().default(0)},e=>[oF(`usine_projection_revision_singleton`,J`${e.singleton} = 1`)]),sI=class extends zC(`@usine/engine/RunNotFoundError`)(`RunNotFoundError`,{runId:FT}){},cI=class extends zC(`@usine/engine/RunOperationRejectedError`)(`RunOperationRejectedError`,{runId:FT,operation:ES([`approve`,`retry`]),state:F}){},lI=class extends zC(`@usine/engine/EnginePersistenceError`)(`EnginePersistenceError`,{operation:F,cause:hC()}){},uI=class extends zC(`@usine/engine/AttemptCancellationError`)(`AttemptCancellationError`,{attemptId:OE,cause:hC()}){},dI=R([sI,cI,lI]),fI=class extends zC(`@usine/engine/RunInterventionRejectedError`)(`RunInterventionRejectedError`,{runId:FT,attemptId:OE,message:V}){};R([sI,cI,lI,uI,fI]);var pI=F.check(zS(/\S/u,{message:`Expected a non-blank repository label`})),mI=F.check(zS(/^[0-9a-fA-F]{6}$/u,{message:`Expected a six-digit hex label color`})),hI=class extends H(`@usine/engine/RepositoryLabel`)({name:pI,color:eC(mI),description:eC(F)}){},gI=RS(e=>new Set(e.map(({name:e})=>e)).size===e.length,{message:`Expected unique label names`}),_I=L(hI).check(gI),vI=class extends H(`@usine/engine/RepositoryLabelProjection`)({repository:qw,labels:_I}){},yI=go(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),bI=class extends O()(`effect/http/FetchHttpClient/RequestInit`){},xI=Dk(k(xk((e,t,n,r)=>{let i=r.getRef(yI),a=ao(r.context,bI)??{},o=a.headers?aO(tO(a.headers),e.headers):e.headers;o[`content-length`]&&(o=oO(o,`content-length`));let s=r=>gh(Qm({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:e.body._tag===`Stream`?`half`:void 0,signal:n}),catch:t=>new xO({reason:new wO({request:e,cause:t})})}),t=>sk(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return M(xw(e.body.stream),s)}return s(void 0)}))),SI=JS.check(GS(1)).pipe(z(`GitHubAppId`)),CI=rC(V.check(zS(/^-----BEGIN (?:RSA )?PRIVATE KEY-----[\s\S]+-----END (?:RSA )?PRIVATE KEY-----\s*$/u,{message:`Expected a PEM-encoded RSA private key`})).pipe(z(`GitHubAppPrivateKey`)),{disallowEncode:!0});H(`@usine/github/AppCredentials`)({appId:SI,privateKey:CI});var wI=class extends O()(`@usine/github/GitHubCredentials`){},TI=class extends zC(`@usine/github/AppAuthenticationError`)(`AppAuthenticationError`,{message:V}){},EI=new TextEncoder,DI=new Uint8Array([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]),OI=(...e)=>{let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t},kI=e=>{if(e<128)return new Uint8Array([e]);let t=[];for(let n=e;n>0;n>>>=8)t.unshift(n&255);return new Uint8Array([128|t.length,...t])},AI=(e,t)=>OI(new Uint8Array([e]),kI(t.length),t),jI=e=>AI(48,OI(new Uint8Array([2,1,0]),DI,AI(4,e))),MI=e=>{let t=e.includes(`-----BEGIN RSA PRIVATE KEY-----`),n=e.replace(/-----BEGIN (?:RSA )?PRIVATE KEY-----/gu,``).replace(/-----END (?:RSA )?PRIVATE KEY-----/gu,``).replace(/\s/gu,``),r=atob(n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return t?jI(i):i},NI=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/=/gu,``).replace(/\+/gu,`-`).replace(/\//gu,`_`)},PI=e=>NI(EI.encode(JSON.stringify(e))),FI=e=>{let t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(e),t},II=N(`AppJwt.import`)(function*(e){let t=yield*Qm({try:async()=>crypto.subtle.importKey(`pkcs8`,FI(MI(Fx(e.privateKey))),{name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`},!1,[`sign`]),catch:()=>new TI({message:`The GitHub App private key is not an RSA private key WebCrypto can import`})});return N(`AppJwt.sign`)(function*(){let n=Math.floor((yield*ep)/1e3),r=`${PI({alg:`RS256`,typ:`JWT`})}.${PI({iat:n-60,exp:n+540,iss:e.appId})}`,i=yield*Zm(()=>crypto.subtle.sign(`RSASSA-PKCS1-v1_5`,t,FI(EI.encode(r))));return Nx(`${r}.${NI(new Uint8Array(i))}`)})}),LI=JS.check(GS(1)),RI=LI.pipe(z(`GitHubInstallationId`)),zI=LI.pipe(z(`GitHubRepositoryId`)),BI=class extends H(`@usine/github/Installation`)({id:RI,accountLogin:V}){},VI=class extends U(`@usine/github/TokenScope/InstallationWide`)(`InstallationWide`,{}){},HI=class extends U(`@usine/github/TokenScope/SingleRepository`)(`SingleRepository`,{repository:qw,repositoryId:zI}){},UI=R([VI,HI]),WI=class extends H(`@usine/github/InstallationToken`)({value:nC(V,{disallowJsonEncode:!0}),expiresAt:kC,scope:UI}){},GI=ES([`missing`,`multiple`,`suspended`]),KI=class extends zC(`@usine/github/InstallationDiscoveryError`)(`InstallationDiscoveryError`,{reason:GI,message:V}){},qI={checks:`read`,contents:`write`,issues:`write`,metadata:`read`,pull_requests:`write`},JI=(e,t)=>e===t||t===`read`&&e===`write`,YI=e=>Object.entries(qI).flatMap(([t,n])=>JI(e[t],n)?[]:[`${t}:${n}`]),XI=class extends U(`@usine/github/ProjectAccess/CoveredProject`)(`CoveredProject`,{installationId:RI,repository:qw,repositoryId:zI}){},ZI=class extends zC(`@usine/github/ProjectNotInstalledError`)(`ProjectNotInstalledError`,{repository:qw,message:V}){};R([XI,ZI]);var QI=(e,t,n)=>{let r=new Map(n.map(e=>[e.name.toLowerCase(),e]));return t.map(t=>{let n=r.get(t.toLowerCase());return n===void 0?new ZI({repository:t,message:`The GitHub App installation does not cover ${t}`}):new XI({installationId:e.id,repository:t,repositoryId:n.id})})},$I=class extends zC(`@usine/github/AppPermissionError`)(`AppPermissionError`,{missing:L(V).check(XS()),message:V}){},eL=ES([`create-repository-label`,`discover-installation`,`fetch-item-labels`,`fetch-issue-snapshot`,`fetch-pull-request-snapshot`,`list-installation-repositories`,`list-repository-labels`,`mint-installation-token`,`mint-worker-token`,`poll-repository-changes`,`update-item-labels`]),tL=class extends zC(`@usine/github/GitHubApiError`)(`GitHubApiError`,{operation:eL,status:$S(JS),message:V}){},nL=class extends zC(`@usine/github/GitHubRateLimitError`)(`GitHubRateLimitError`,{operation:eL,retryAt:kC,message:V}){},rL=class extends zC(`@usine/github/InvalidGitHubResponseError`)(`InvalidGitHubResponseError`,{operation:eL,message:V,detail:V}){};R([KI,$I,tL,nL,rL]);var iL=`https://api.github.com`,aL=`2026-03-10`,oL=e=>GO({accept:`application/vnd.github+json`,authorization:`Bearer ${Fx(e)}`,"user-agent":`usine`,"x-github-api-version":aL}),sL=(e,t)=>new tL({operation:e,status:t.response===void 0?T():E(t.response.status),message:t.response===void 0?`The request to GitHub could not be sent`:`GitHub rejected the request with status ${t.response.status}`}),cL=(e,t)=>new rL({operation:e,message:`GitHub returned a response that does not match its API contract`,detail:t}),lL=e=>{if(e===void 0||!/^\d+$/u.test(e))return T();let t=Number(e);return Number.isSafeInteger(t)?E(t):T()},uL=(e,t)=>{let n=lL(e);if(D(n))return E(t+n.value*1e3);if(e===void 0)return T();let r=Date.parse(e);return Number.isFinite(r)?E(r):T()},dL=(e,t)=>{let n=lL(e[`x-ratelimit-remaining`]),r=lL(e[`x-ratelimit-reset`]);return D(n)&&n.value<=t&&D(r)?E(r.value*1e3):T()},fL=(e,t)=>Ti(lL(e[`x-poll-interval`]),e=>t+e*1e3),pL=e=>{let t=e.flatMap(e=>gi(e,{onNone:()=>[],onSome:e=>[e]}));return t.length===0?T():E(Math.max(...t))},mL=(e,t)=>pL([uL(e[`retry-after`],t),dL(e,0)]),hL=(e,t,n)=>{let r=Ei(mL(t.headers,n),s_);return(t.status===403||t.status===429)&&D(r)?new nL({operation:e,retryAt:r.value,message:`GitHub asked the poller to wait before retrying`}):new tL({operation:e,status:E(t.status),message:`GitHub rejected the request with status ${t.status}`})},gL=36e5,_L=3e5,vL=L(I({id:RI,account:I({login:V}),permissions:xS(F,F),suspendedAt:DS(F)}).pipe(bS({suspendedAt:`suspended_at`}))),yL=I({id:zI,name:qw}).pipe(bS({name:`full_name`})),bL=I({totalCount:JS.check(GS(0)),repositories:L(yL)}).pipe(bS({totalCount:`total_count`})),xL=I({token:V,expiresAt:AC,repositories:tC(L(yL))}).pipe(bS({expiresAt:`expires_at`})),SL=e=>e._tag===`InstallationWide`?{operation:`mint-installation-token`,body:{permissions:qI}}:{operation:`mint-worker-token`,body:{permissions:qI,repository_ids:[e.repositoryId]}},CL=class e extends O()(`@usine/github/GitHubApp`){static layer=Gf(e,A(function*(){let e=yield*II(yield*wI),t=yield*_k,n=(e,n,r)=>A(function*(){let i=yield*t.execute(n).pipe(Ch(t=>sL(e,t)));return i.status<200||i.status>=300?yield*hL(e,i,yield*ep):yield*ik(r)(i).pipe(Ch(t=>cL(e,t.message)))}),r=N(`GitHubApp.discoverInstallation`)(function*(){let t=yield*e(),[r,...i]=yield*n(`discover-installation`,BO(`${iL}/app/installations?per_page=2`).pipe(oL(t)),vL);if(r===void 0)return yield*new KI({reason:`missing`,message:`The GitHub App is not installed on an account`});if(i.length>0)return yield*new KI({reason:`multiple`,message:`The GitHub App must have exactly one installation for this factory`});if(r.suspendedAt!==null)return yield*new KI({reason:`suspended`,message:`The GitHub App installation is suspended`});let a=YI(r.permissions);return a.length>0?yield*new $I({missing:a,message:`The GitHub App installation is missing permissions: ${a.join(`, `)}`}):new BI({id:r.id,accountLogin:r.account.login})}),i=N(`GitHubApp.mintToken`)(function*(t,r){let{operation:i,body:a}=SL(r);yield*Gh({installationId:t,operation:i,scope:r._tag});let o=yield*e(),s=yield*n(i,VO(`${iL}/app/installations/${t}/access_tokens`).pipe(tk(a),oL(o)),xL),c=yield*ep,l=p_(s.expiresAt)-c;if(l<=0||l>378e4)return yield*new rL({operation:i,message:`GitHub returned an installation token outside the one-hour lifetime bound`,detail:`expires_at ${m_(s.expiresAt)} leaves ${l}ms to live`});l>gL&&(yield*ng(`Accepted GitHub token clock skew; capped the local lease`,{installationId:t,operation:i,skewMillis:l-gL}));let u=_i(s.repositories,()=>[]);return r._tag===`SingleRepository`&&!(u.length===1&&u.every(e=>e.id===r.repositoryId))?yield*new rL({operation:i,message:`GitHub did not confirm that the worker token is scoped to exactly one repo`,detail:`expected repository id ${r.repositoryId}, confirmed [${u.map(e=>e.id).join(`, `)}]`}):new WI({value:Nx(s.token),expiresAt:o_(c+Math.min(l,gL)),scope:r})}),a=N(`GitHubApp.installedRepositories`)(function*(e){let t=[];for(let r=1;;r+=1){let i=yield*n(`list-installation-repositories`,BO(`${iL}/installation/repositories?per_page=100&page=${r}`).pipe(oL(e.value)),bL);if(t.push(...i.repositories),t.length>=i.totalCount)return t;if(i.repositories.length===0)return yield*new rL({operation:`list-installation-repositories`,message:`GitHub pagination ended before total_count repositories were returned`,detail:`page ${r} was empty after ${t.length} of ${i.totalCount} repositories`})}}),o=yield*Ww(T()),s=N(`GitHubApp.lease`)(()=>Kw(o,e=>A(function*(){let t=yield*ep;if(D(e)&&p_(e.value.token.expiresAt)-t>_L)return[e.value,e];let n=yield*r(),a={installation:n,token:yield*i(n.id,new VI)};return[a,E(a)]})));return{installation:N(`GitHubApp.installation`)(()=>gh(s(),e=>e.installation)),installationToken:N(`GitHubApp.installationToken`)(()=>gh(s(),e=>e.token)),projectAccess:N(`GitHubApp.projectAccess`)(function*(e){let{installation:t,token:n}=yield*s();return QI(t,e,yield*a(n))}),workerToken:N(`GitHubApp.workerToken`)(e=>i(e.installationId,new HI({repository:e.repository,repositoryId:e.repositoryId})))}}))},wL=V.pipe(z(`GitHubEntityTag`)),TL=class e extends H(`@usine/github/PollCursor`)({entityTag:eC(wL),watermark:eC(AC)}){static empty=new e({entityTag:T(),watermark:T()})},EL=class extends U(`@usine/github/ChangedIssue`)(`ChangedIssue`,{number:JS.check(GS(1)),updatedAt:kC}){},DL=class extends U(`@usine/github/ChangedPullRequest`)(`ChangedPullRequest`,{number:JS.check(GS(1)),updatedAt:kC}){},OL=R([EL,DL]),kL=class extends U(`@usine/github/RepositoryNotModified`)(`RepositoryNotModified`,{cursor:TL,nextPollAt:$S(kC),backoffUntil:$S(kC).pipe(AS(k(T())))}){},AL=class extends U(`@usine/github/RepositoryChanges`)(`RepositoryChanges`,{cursor:TL,items:L(OL),backlog:hS,nextPollAt:$S(kC),backoffUntil:$S(kC).pipe(AS(k(T())))}){};R([kL,AL]);var jL=V.pipe(z(`GitHubRepositoryLabelName`)),ML=F.check(zS(/^[0-9a-fA-F]{6}$/u,{message:`Expected a six-digit hex label color`})).pipe(z(`GitHubRepositoryLabelColor`)),NL=class extends H(`@usine/github/RepositoryLabel`)({name:jL,color:ML,description:eC(F)}){},PL=RS(e=>new Set(e.map(({name:e})=>e)).size===e.length,{message:`Expected unique label names`}),FL=class extends H(`@usine/github/RepositoryLabelCatalog`)({entityTag:eC(wL),labels:L(NL).check(PL)}){},IL=class extends U(`@usine/github/RepositoryLabelsNotModified`)(`RepositoryLabelsNotModified`,{}){};R([FL,IL]);var LL=class extends H(`@usine/github/NewRepositoryLabel`)({name:jL,color:$S(ML),description:$S(F)}){},RL=I({name:jL,color:ML,description:DS(F)}),zL=e=>{let{name:t,owner:n}=Xw(e);return`${iL}/repos/${encodeURIComponent(n)}/${encodeURIComponent(t)}/labels`},BL=class e extends O()(`@usine/github/GitHubLabelWriter`){static layer=Gf(e,A(function*(){let e=yield*CL,t=yield*_k;return{create:N(`GitHubLabelWriter.create`)(function*(n,r){yield*Gh({repository:n,label:r.name});let i=yield*e.installationToken(),a={name:r.name};D(r.color)&&(a.color=r.color.value),D(r.description)&&(a.description=r.description.value);let o=VO(zL(n)).pipe(tk(a),oL(i.value)),s=yield*t.execute(o).pipe(Ch(e=>sL(`create-repository-label`,e)));if(s.status<200||s.status>=300)return yield*hL(`create-repository-label`,s,yield*ep);let c=yield*ik(RL)(s).pipe(Ch(e=>cL(`create-repository-label`,e.message)));return new NL({name:c.name,color:c.color,description:yi(c.description)})})}}))},VL=class extends H(`@usine/orchestrator/LabelPreflightFinding`)({repository:qw,label:Kj,errorTag:V,message:V}){},HL=(e,t)=>{let n=[];if(D(e.color)){let r=e.color.value.toLowerCase();gi(t.color,{onNone:()=>!0,onSome:e=>e.toLowerCase()!==r})&&n.push(`color`)}if(D(e.description)){let r=e.description.value;gi(t.description,{onNone:()=>!0,onSome:e=>e!==r})&&n.push(`description`)}return n},UL=e=>new LL({name:jL.make(e.name),color:Ti(e.color,ML.make),description:e.description}),WL=class e extends O()(`@usine/orchestrator/LabelReconciler`){static layer=Gf(e,A(function*(){let e=yield*BL;return{reconcile:N(`LabelReconciler.reconcile`)(function*(t,n,r){yield*Gh({repository:t});let i=[...r],a=new Map(r.map(e=>[qj(e.name),e])),o=[],s=!1,c=T();for(let r of n){let n=a.get(qj(r.name));if(n!==void 0){let e=HL(r,n);e.length>0?yield*eg(`Declared GitHub label differs from the existing repository label; left unchanged`,{repository:t,label:r.name,drift:e.join(`, `)}):yield*rg(`Declared GitHub label already exists`,{repository:t,label:r.name});continue}let l=yield*mh(e.create(t,UL(r)));if(Li(l)){let e=l.failure;if(o.push(new VL({repository:t,label:r.name,errorTag:e._tag,message:e.message})),e._tag===`GitHubRateLimitError`){c=E(e.retryAt),yield*eg(`Label creation rate-limited; remaining declarations deferred and trigger evaluation continues`,{repository:t,label:r.name,errorTag:e._tag,message:e.message,retryAt:m_(e.retryAt)});break}yield*tg(`Declared GitHub label could not be created; trigger evaluation continues`,{repository:t,label:r.name,errorTag:e._tag,message:e.message});continue}let u=new hI({name:l.success.name,color:E(l.success.color),description:l.success.description});i.push(u),a.set(qj(u.name),u),s=!0,yield*ng(`Created declared GitHub label`,{repository:t,label:u.name})}return i.sort((e,t)=>e.name.localeCompare(t.name)),{labels:i,findings:o,catalogChanged:s,nextPollAt:c}})}}))},GL=F.check(zS(/^(?:[A-Za-z_][A-Za-z0-9_.]*|list<[A-Za-z_][A-Za-z0-9_.]*>|map<[A-Za-z_][A-Za-z0-9_.]*,[A-Za-z_][A-Za-z0-9_.]*>)$/u,{message:`Expected a CEL type reference`})).pipe(z(`CelTypeReference`)),KL=F.check(zS(/^[A-Za-z_][A-Za-z0-9_]*$/u,{message:`Expected a CEL identifier`})),qL=F.check(zS(/^[A-Za-z_][A-Za-z0-9_.]*$/u,{message:`Expected a CEL object-type name`})),JL=e=>RS(e=>new Set(e.map(({name:e})=>e)).size===e.length,{message:e}),YL=class extends H(`@usine/expression/ObjectField`)({name:KL,type:GL}){},XL=class extends H(`@usine/expression/ObjectType`)({name:qL,fields:L(YL).check(JL(`Expected unique CEL object-field names`))}){},ZL=class extends H(`@usine/expression/Variable`)({name:KL,type:GL}){},QL=class extends H(`@usine/expression/Environment`)({types:L(XL).check(JL(`Expected unique CEL object-type names`)),variables:L(ZL).check(JL(`Expected unique CEL variable names`))}){},$L=F.check(zS(/\S/u,{message:`Expected a non-blank CEL expression`})).pipe(z(`ExpressionSource`)),eR=JS.check(GS(0)),tR=ES([`check_failed`,`parse_error`,`type_error`,`unexpected_result_type`]);R([class extends zC(`@usine/expression/ExpressionCheckError`)(`ExpressionCheckError`,{source:$L,code:tR,message:V,position:$S(eR)}){},class extends zC(`@usine/expression/ExpressionEvaluationError`)(`ExpressionEvaluationError`,{source:$L,message:V}){}]),R([F,mS,gS,hS,fS]);var nR=class extends O()(`@usine/expression/ExpressionEngine`){},rR=V.pipe(z(`InstancePath`)),iR=ES([`expression`,`frontmatter`,`read`,`reference`,`schema`,`yaml`]),aR=class extends zC(`@usine/config/ConfigFileError`)(`ConfigFileError`,{file:rR,stage:iR,expression:tC($L),message:V}){};R([aR,class extends zC(`@usine/config/FactoryConfigError`)(`FactoryConfigError`,{file:rR,stage:iR,message:V}){}]);var oR=(e,t,n)=>{let r=`${t}---`,i=e.indexOf(r,n);for(;i>=0;){let n=i+r.length;if(n===e.length||e.startsWith(t,n))return i;i=e.indexOf(r,n)}return-1},sR=(e,t)=>{let n=t.startsWith(`---\r
|
|
30
|
-
`)?`\r
|
|
31
|
-
`:t.startsWith(`---
|
|
32
|
-
`)?`
|
|
33
|
-
`:void 0;if(n===void 0)return new aR({file:e,stage:`frontmatter`,expression:T(),message:`Expected the file to start with a YAML frontmatter delimiter (---)`});let r=3+n.length,i=`${n}---`,a=oR(t,n,r);if(a<0)return new aR({file:e,stage:`frontmatter`,expression:T(),message:`Expected a closing YAML frontmatter delimiter (---)`});let o=a+i.length,s=t.startsWith(n,o)?o+n.length:o;return k({yaml:t.slice(r,a),body:t.slice(s),newline:n})},cR=class extends H(`@usine/config/AgentFile`)({name:HT,harness:zT,model:RT,effort:BT,parentModel:$S(RT),parentEffort:$S(BT),persona:UT}){get agent(){return new WT({name:this.name,persona:this.persona,brain:new VT({harness:this.harness,model:this.model,effort:this.effort}),parentModel:this.parentModel,parentEffort:this.parentEffort})}};H(`@usine/config/InvalidAgent`)({file:rR,error:aR});var lR=Zj(`Expected a non-blank registry tag`).pipe(z(`RegistryTag`)),uR=F.check(zS(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u,{message:`Expected a GitHub login`})).pipe(z(`OperatorLogin`)),dR=JS.check(GS(1)),fR=RS(e=>new Set(e.map(({name:e})=>e)).size===e.length,{message:`Expected unique names`}),pR=e=>`label`in e?`label:${e.label}`:`state:${e.state}`,mR=RS(e=>{let t=e.flatMap(({sources:e})=>e.map(pR));return new Set(t).size===t.length},{message:`Expected every lane source to be mapped once`}),hR=L(tM).check(fR,mR),gR=RS(e=>new Set(e.map(({name:e})=>qj(e))).size===e.length,{message:`Expected unique GitHub label names`}),_R=L(Xj).check(gR),vR=class extends H(`@usine/config/ManagedRepo`)({name:qw,tags:L(lR).check(QS()).pipe(MS(k([]))),lanes:hR.pipe(MS(k([])))}){},yR=class extends H(`@usine/config/Worker`)({name:XT,kind:ZT,maxConcurrentAttempts:dR.pipe(MS(k(1)))}){},bR=class extends H(`@usine/config/Settings`)({pollInterval:dR.pipe(MS(k(60))),maxChildren:tE.pipe(MS(k(4))),maxAttemptMinutes:dR.pipe(MS(k(60))),maxAttemptTokens:dR.pipe(MS(k(1e7))),parentModel:tC(RT),parentEffort:tC(BT)}){},xR=R([I({mode:lS(`off`)}),I({mode:lS(`deliveries`)}),I({mode:lS(`endpoint`),publicUrl:xC}).pipe(bS({publicUrl:`public_url`}))]),SR=bR.pipe(bS({pollInterval:`poll_interval`,maxChildren:`max_children`,maxAttemptMinutes:`max_attempt_minutes`,maxAttemptTokens:`max_attempt_tokens`,parentModel:`parent_model`,parentEffort:`parent_effort`})),CR=yR.pipe(bS({maxConcurrentAttempts:`max_concurrent_attempts`})),wR=L(vR).check(fR),TR=L(CR).check(XS(),fR),ER=class extends H(`@usine/config/UsineConfig`)({version:lS(1),labels:_R.pipe(MS(k([]))),repos:wR,settings:SR.pipe(MS(k({}))),workers:TR.pipe(MS(k([{name:`local`,kind:`local`}]))),webhooks:xR.pipe(MS(k({mode:`off`}))),operator:tC(uR)}){},DR=class extends H(`@usine/config/Selector`)({repos:tC(L(qw).check(XS(),QS())),tags:tC(L(lR).check(XS(),QS()))}){}.check(RS(e=>D(e.repos)||D(e.tags),{message:`Expected selector.repos, selector.tags, or both`})),OR=(e,t)=>gi(e,{onNone:()=>!0,onSome:e=>{let n=gi(e.repos,{onNone:()=>!0,onSome:e=>e.includes(t.name)}),r=gi(e.tags,{onNone:()=>!0,onSome:e=>e.some(e=>t.tags.includes(e))});return n&&r}}),kR=F.check(RS(e=>e.trim().split(/\s+/u).length===5&&Ri(ym(e)),{message:`Expected a valid five-field cron expression`})).pipe(z(`Cron`)),AR=F.check(RS(e=>D(u_(e)),{message:`Expected an IANA time-zone name`})).pipe(z(`TimeZone`)),jR=R([class extends H(`@usine/config/IssueTrigger`)({on:lS(`issue`),if:$L}){},class extends H(`@usine/config/PullRequestTrigger`)({on:lS(`pr`),if:$L}){},class extends H(`@usine/config/ScheduleTrigger`)({on:lS(`schedule`),if:$L,cron:kR,tz:AR.pipe(MS(k(`UTC`)))}){}]),MR=zS(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,{message:`Expected a kebab-case filename identity`}),NR=tT.check(MR),PR=Zj(`Expected a non-blank Markdown prompt`).pipe(z(`PromptTemplate`)),FR=class extends H(`@usine/config/LoopFile`)({name:NR,trigger:jR,selector:$S(DR),approval:rT,maxCycles:FE.pipe(MS(k(LE)),AS(k(LE))),step:JT,agent:HT,body:PR}){};H(`@usine/config/QuarantinedLoop`)({file:rR,error:aR});var IR=e=>rR.make(`loops/${e}.md`),LR=class extends U(`@usine/config/UndeclaredLaneLabelWarning`)(`UndeclaredLaneLabelWarning`,{repository:qw,lane:Qj,label:Kj}){},RR=class extends U(`@usine/config/UndeclaredTriggerLabelWarning`)(`UndeclaredTriggerLabelWarning`,{loop:FR.fields.name,label:Kj}){};R([LR,RR]);var zR=$x(GL),BR=(e,t)=>new XL({name:e,fields:t.map(([e,t])=>new YL({name:e,type:zR(t)}))}),VR=BR(`Actor`,[[`login`,`string`]]),HR=BR(`Label`,[[`name`,`string`]]),UR=BR(`Milestone`,[[`title`,`string`]]),WR=BR(`IssueType`,[[`name`,`string`]]),GR=BR(`Commit`,[[`oid`,`string`]]),KR=BR(`RepoContext`,[[`name`,`string`],[`owner`,`string`],[`url`,`string`]]),qR=BR(`Labels`,[[`totalCount`,`int`],[`nodes`,`list<Label>`]]),JR=BR(`Assignees`,[[`totalCount`,`int`],[`nodes`,`list<Actor>`]]),YR=BR(`IssueComment`,[[`author`,`Actor`],[`body`,`string`],[`createdAt`,`string`]]),XR=BR(`IssueComments`,[[`totalCount`,`int`],[`nodes`,`list<IssueComment>`]]),ZR=BR(`PullRequestReference`,[[`number`,`int`],[`state`,`string`],[`isDraft`,`bool`],[`url`,`string`]]),QR=BR(`PullRequestReferences`,[[`totalCount`,`int`],[`nodes`,`list<PullRequestReference>`]]),$R=BR(`IssuePayload`,[[`number`,`int`],[`title`,`string`],[`body`,`string`],[`url`,`string`],[`state`,`string`],[`stateReason`,`string`],[`createdAt`,`string`],[`updatedAt`,`string`],[`closedAt`,`string`],[`author`,`Actor`],[`issueType`,`IssueType`],[`milestone`,`Milestone`],[`labels`,`Labels`],[`assignees`,`Assignees`],[`comments`,`IssueComments`],[`closedByPullRequestsReferences`,`PullRequestReferences`]]),ez=BR(`RequestedReviewer`,[[`login`,`string`]]),tz=BR(`ReviewRequest`,[[`requestedReviewer`,`RequestedReviewer`]]),nz=BR(`ReviewRequests`,[[`totalCount`,`int`],[`nodes`,`list<ReviewRequest>`]]),rz=BR(`Review`,[[`author`,`Actor`],[`state`,`string`],[`body`,`string`],[`submittedAt`,`string`],[`commit`,`Commit`]]),iz=BR(`Reviews`,[[`totalCount`,`int`],[`nodes`,`list<Review>`]]),az=BR(`ReviewThreadComment`,[[`author`,`Actor`],[`body`,`string`]]),oz=BR(`ReviewThreadComments`,[[`totalCount`,`int`],[`nodes`,`list<ReviewThreadComment>`]]),sz=BR(`ReviewThread`,[[`isResolved`,`bool`],[`isOutdated`,`bool`],[`path`,`string`],[`comments`,`ReviewThreadComments`]]),cz=BR(`ReviewThreads`,[[`totalCount`,`int`],[`nodes`,`list<ReviewThread>`]]),lz=BR(`PullRequestComment`,[[`author`,`Actor`],[`body`,`string`],[`createdAt`,`string`]]),uz=BR(`PullRequestComments`,[[`totalCount`,`int`],[`nodes`,`list<PullRequestComment>`]]),dz=BR(`ClosingIssueReference`,[[`number`,`int`],[`state`,`string`]]),fz=BR(`ClosingIssueReferences`,[[`totalCount`,`int`],[`nodes`,`list<ClosingIssueReference>`]]),pz=BR(`StatusCheckRollup`,[[`state`,`string`]]),mz=BR(`PullRequestPayload`,[[`number`,`int`],[`title`,`string`],[`body`,`string`],[`url`,`string`],[`state`,`string`],[`isDraft`,`bool`],[`merged`,`bool`],[`createdAt`,`string`],[`updatedAt`,`string`],[`mergedAt`,`string`],[`author`,`Actor`],[`baseRefName`,`string`],[`headRefName`,`string`],[`headRefOid`,`string`],[`additions`,`int`],[`deletions`,`int`],[`changedFiles`,`int`],[`reviewDecision`,`string`],[`statusCheckRollup`,`StatusCheckRollup`],[`labels`,`Labels`],[`reviewRequests`,`ReviewRequests`],[`reviews`,`Reviews`],[`reviewThreads`,`ReviewThreads`],[`comments`,`PullRequestComments`],[`closingIssuesReferences`,`ClosingIssueReferences`]]),hz=BR(`Tick`,[[`scheduledAt`,`string`],[`scheduledAtLocal`,`string`],[`cron`,`string`],[`tz`,`string`]]),gz=BR(`SchedulePayload`,[[`tick`,`Tick`]]),_z=(e,t)=>new QL({types:[KR,...e],variables:[new ZL({name:`repo`,type:zR(`RepoContext`)}),new ZL({name:`item`,type:zR(t)})]}),vz=_z([VR,HR,UR,WR,qR,JR,YR,XR,ZR,QR,$R],`IssuePayload`),yz=_z([VR,HR,GR,qR,ez,tz,nz,rz,iz,az,oz,sz,cz,lz,uz,dz,fz,pz,mz],`PullRequestPayload`),bz=_z([hz,gz],`SchedulePayload`),xz=e=>{switch(e){case`issue`:return vz;case`pr`:return yz;case`schedule`:return bz}},Sz=e=>{let{owner:t}=Xw(e.name);return{name:e.name,owner:t,url:`https://github.com/${e.name}`}},Cz=Symbol.for(`yaml.alias`),wz=Symbol.for(`yaml.document`),Tz=Symbol.for(`yaml.map`),Ez=Symbol.for(`yaml.pair`),Dz=Symbol.for(`yaml.scalar`),Oz=Symbol.for(`yaml.seq`),kz=Symbol.for(`yaml.node.type`),Az=e=>!!e&&typeof e==`object`&&e[kz]===Cz,jz=e=>!!e&&typeof e==`object`&&e[kz]===wz,Mz=e=>!!e&&typeof e==`object`&&e[kz]===Tz,Nz=e=>!!e&&typeof e==`object`&&e[kz]===Ez,Pz=e=>!!e&&typeof e==`object`&&e[kz]===Dz,Fz=e=>!!e&&typeof e==`object`&&e[kz]===Oz;function Iz(e){if(e&&typeof e==`object`)switch(e[kz]){case Tz:case Oz:return!0}return!1}function Lz(e){if(e&&typeof e==`object`)switch(e[kz]){case Cz:case Tz:case Dz:case Oz:return!0}return!1}var Rz=e=>(Pz(e)||Iz(e))&&!!e.anchor,zz=Symbol(`break visit`),Bz=Symbol(`skip children`),Vz=Symbol(`remove node`);function Hz(e,t){let n=Wz(t);jz(e)?Uz(null,e.contents,n,Object.freeze([e]))===Vz&&(e.contents=null):Uz(null,e,n,Object.freeze([]))}Hz.BREAK=zz,Hz.SKIP=Bz,Hz.REMOVE=Vz;function Uz(e,t,n,r){let i=Gz(e,t,n,r);if(Lz(i)||Nz(i))return Kz(e,r,i),Uz(e,i,n,r);if(typeof i!=`symbol`){if(Iz(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=Uz(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===zz)return zz;else i===Vz&&(t.items.splice(e,1),--e)}}else if(Nz(t)){r=Object.freeze(r.concat(t));let e=Uz(`key`,t.key,n,r);if(e===zz)return zz;e===Vz&&(t.key=null);let i=Uz(`value`,t.value,n,r);if(i===zz)return zz;i===Vz&&(t.value=null)}}return i}function Wz(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Gz(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(Mz(t))return n.Map?.(e,t,r);if(Fz(t))return n.Seq?.(e,t,r);if(Nz(t))return n.Pair?.(e,t,r);if(Pz(t))return n.Scalar?.(e,t,r);if(Az(t))return n.Alias?.(e,t,r)}function Kz(e,t,n){let r=t[t.length-1];if(Iz(r))r.items[e]=n;else if(Nz(r))e===`key`?r.key=n:r.value=n;else if(jz(r))r.contents=n;else{let e=Az(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var qz={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},Jz=e=>e.replace(/[!,[\]{}]/g,e=>qz[e]),Yz=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+Jz(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Lz(e.contents)){let t={};Hz(e.contents,(e,n)=>{Lz(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)(i!==`!!`||a!==`tag:yaml.org,2002:`)&&(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
34
|
-
`)}};Yz.defaultYaml={explicit:!1,version:`1.2`},Yz.defaultTags={"!!":`tag:yaml.org,2002:`};function Xz(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Zz(e){let t=new Set;return Hz(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function Qz(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function $z(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=Zz(e);let a=Qz(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(Pz(t.node)||Iz(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function eB(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=eB(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=eB(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=eB(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=eB(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function tB(e,t,n){if(Array.isArray(e))return e.map((e,t)=>tB(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!Rz(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var nB=class{constructor(e){Object.defineProperty(this,kz,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!jz(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=tB(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?eB(i,{"":o},``,o):o}},rB=class extends nB{constructor(e){super(Cz),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],Hz(e,{Node:(e,t)=>{(Az(t)||Rz(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(tB(a,null,t),n.get(a)),!o||o.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=iB(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(Xz(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function iB(e,t,n){if(Az(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(Iz(t)){let r=0;for(let i of t.items){let t=iB(e,i,n);t>r&&(r=t)}return r}if(Nz(t)){let r=iB(e,t.key,n),i=iB(e,t.value,n);return Math.max(r,i)}return 1}var aB=e=>!e||typeof e!=`function`&&typeof e!=`object`,$=class extends nB{constructor(e){super(Dz),this.value=e}toJSON(e,t){return t?.keep?this.value:tB(this.value,e,t)}toString(){return String(this.value)}};$.BLOCK_FOLDED=`BLOCK_FOLDED`,$.BLOCK_LITERAL=`BLOCK_LITERAL`,$.PLAIN=`PLAIN`,$.QUOTE_DOUBLE=`QUOTE_DOUBLE`,$.QUOTE_SINGLE=`QUOTE_SINGLE`;var oB=`tag:yaml.org,2002:`;function sB(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function cB(e,t,n){if(jz(e)&&(e=e.contents),Lz(e))return e;if(Nz(e)){let t=n.schema[Tz].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new rB(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=oB+t.slice(2));let l=sB(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new $(e);return c&&(c.node=t),t}l=e instanceof Map?o[Tz]:Symbol.iterator in Object(e)?o[Oz]:o[Tz]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new $(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function lB(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return cB(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var uB=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,dB=class extends nB{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>Lz(t)||Nz(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(uB(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(Iz(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,lB(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(Iz(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&Pz(i)?i.value:i:Iz(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!Nz(t))return!1;let n=t.value;return n==null||e&&Pz(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return Iz(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(Iz(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,lB(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},fB=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function pB(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var mB=(e,t,n)=>e.endsWith(`
|
|
35
|
-
`)?pB(n,t):n.includes(`
|
|
36
|
-
`)?`
|
|
37
|
-
`+pB(n,t):(e.endsWith(` `)?``:` `)+n,hB=`flow`,gB=`block`,_B=`quoted`;function vB(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=yB(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
|
|
38
|
-
`)n===`block`&&(h=yB(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
|
|
39
|
-
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
|
|
40
|
-
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function yB(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
41
|
-
`);r=t,i=t+1,a=e[i]}return r}var bB=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),xB=e=>/^(%|---|\.\.\.)/m.test(e);function SB(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
42
|
-
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function CB(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(xB(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
|
|
43
|
-
|
|
44
|
-
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
|
|
45
|
-
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:vB(o,a,_B,bB(t,!1))}function wB(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
46
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return CB(e,t);let n=t.indent||(xB(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:vB(r,n,hB,bB(t,!1))}function TB(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=CB;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?wB:i&&!t?CB:n?wB:CB}return r(e,t)}var EB;try{EB=RegExp(`(^|(?<!
|
|
47
|
-
))
|
|
48
|
-
+(?!
|
|
49
|
-
|$)`,`g`)}catch{EB=/\n+(?!\n|$)/g}function DB({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return TB(n,r);let l=r.indent||(r.forceBlockIndent||xB(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===$.BLOCK_FOLDED?!1:t===$.BLOCK_LITERAL||!SB(n,c,l.length);if(!n)return u?`|
|
|
50
|
-
`:`>
|
|
51
|
-
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
|
|
52
|
-
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
|
|
53
|
-
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
54
|
-
`&&(p=p.slice(0,-1)),p.replace(EB,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
|
|
55
|
-
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
|
|
56
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=bB(r,!0);o!==`folded`&&t!==$.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=vB(`${v}${e}${p}`,l,gB,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function OB(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
|
|
57
|
-
`)||u&&/[[\]{},]/.test(a))return TB(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
|
|
58
|
-
`)?TB(a,t):DB(e,t,n,r);if(!s&&!u&&i!==$.PLAIN&&a.includes(`
|
|
59
|
-
`))return DB(e,t,n,r);if(xB(a)){if(c===``)return t.forceBlockIndent=!0,DB(e,t,n,r);if(s&&c===l)return TB(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return TB(a,t)}return s?d:vB(d,c,hB,bB(t,!1))}function kB(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==$.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=$.QUOTE_DOUBLE);let c=e=>{switch(e){case $.BLOCK_FOLDED:case $.BLOCK_LITERAL:return i||a?TB(o.value,t):DB(o,t,n,r);case $.QUOTE_DOUBLE:return CB(o.value,t);case $.QUOTE_SINGLE:return wB(o.value,t);case $.PLAIN:return OB(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function AB(e,t){let n=Object.assign({blockQuote:!0,commentString:fB,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function jB(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(Pz(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function MB(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(Pz(e)||Iz(e))&&e.anchor;a&&Xz(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function NB(e,t,n,r){if(Nz(e))return e.toString(t,n,r);if(Az(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=Lz(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=jB(t.doc.schema.tags,a);let o=MB(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):Pz(a)?kB(a,t,n,r):a.toString(t,n,r);return o?Pz(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function PB({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=Lz(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(Iz(e)||!Lz(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||Iz(e)||(Pz(e)?e.type===$.BLOCK_FOLDED||e.type===$.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=NB(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=mB(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=mB(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=mB(g,n.indent,l(f))));let _,v,y;Lz(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&Pz(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Fz(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=NB(t,n,()=>b=!0,()=>h=!0),ee=` `;if(f||_||v){if(ee=_?`
|
|
60
|
-
`:``,v){let e=l(v);ee+=`\n${pB(e,n.indent)}`}x===``&&!n.inFlow?ee===`
|
|
61
|
-
`&&(ee=`
|
|
62
|
-
|
|
63
|
-
`):ee+=`\n${n.indent}`}else if(!p&&Iz(t)){let e=x[0],r=x.indexOf(`
|
|
64
|
-
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(ee=`\n${n.indent}`)}}else(x===``||x[0]===`
|
|
65
|
-
`)&&(ee=``);return g+=ee+x,n.inFlow?b&&r&&r():y&&!b?g+=mB(g,n.indent,l(y)):h&&i&&i(),g}function FB(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var IB=`<<`,LB={identify:e=>e===IB||typeof e==`symbol`&&e.description===IB,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new $(Symbol(IB)),{addToJSMap:zB}),stringify:()=>IB},RB=(e,t)=>(LB.identify(t)||Pz(t)&&(!t.type||t.type===$.PLAIN)&&LB.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===LB.tag&&e.default);function zB(e,t,n){if(n=e&&Az(n)?n.resolve(e.doc):n,Fz(n))for(let r of n.items)BB(e,t,r);else if(Array.isArray(n))for(let r of n)BB(e,t,r);else BB(e,t,n)}function BB(e,t,n){let r=e&&Az(n)?n.resolve(e.doc):n;if(!Mz(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function VB(e,t,{key:n,value:r}){if(Lz(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(RB(e,n))zB(e,t,r);else{let i=tB(n,``,e);if(t instanceof Map)t.set(i,tB(r,i,e));else if(t instanceof Set)t.add(i);else{let a=HB(n,i,e),o=tB(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function HB(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(Lz(e)&&n?.doc){let t=AB(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),FB(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function UB(e,t,n){return new WB(cB(e,void 0,n),cB(t,void 0,n))}var WB=class e{constructor(e,t=null){Object.defineProperty(this,kz,{value:Ez}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return Lz(n)&&(n=n.clone(t)),Lz(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return VB(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?PB(this,e,t,n):JSON.stringify(this)}};function GB(e,t,n){return(t.inFlow??e.flow?qB:KB)(e,t,n)}function KB({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(Lz(i))!d&&i.spaceBefore&&f.push(``),JB(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(Nz(i)){let e=Lz(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),JB(n,f,e.commentBefore,d))}d=!1;let s=NB(i,u,()=>o=null,()=>d=!0);o&&(s+=mB(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
|
|
66
|
-
`}}return e?(p+=`
|
|
67
|
-
`+pB(l(e),c),s&&s()):d&&o&&o(),p}function qB({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(Lz(i))i.spaceBefore&&d.push(``),JB(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(Nz(i)){let e=Lz(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),JB(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=Lz(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=NB(i,c,()=>a=null);n<e.length-1&&(o+=`,`),a&&(o+=mB(o,r,s(a))),!l&&(d.length>u||o.includes(`
|
|
68
|
-
`))&&(l=!0),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
|
|
69
|
-
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function JB({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=pB(t(r),e);n.push(i.trimStart())}}function YB(e,t){let n=Pz(t)?t.value:t;for(let r of e)if(Nz(r)&&(r.key===t||r.key===n||Pz(r.key)&&r.key.value===n))return r}var XB=class extends dB{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Tz,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(UB(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=Nz(e)?e:!e||typeof e!=`object`||!(`key`in e)?new WB(e,e?.value):new WB(e.key,e.value);let r=YB(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);Pz(r.value)&&aB(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=YB(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=YB(this.items,e)?.value;return(!t&&Pz(n)?n.value:n)??void 0}has(e){return!!YB(this.items,e)}set(e,t){this.add(new WB(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)VB(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!Nz(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),GB(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},ZB={collection:`map`,default:!0,nodeClass:XB,tag:`tag:yaml.org,2002:map`,resolve(e,t){return Mz(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>XB.from(e,t,n)},QB=class extends dB{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Oz,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=$B(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=$B(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&Pz(r)?r.value:r}has(e){let t=$B(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=$B(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];Pz(r)&&aB(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(tB(e,String(r++),t));return n}toString(e,t,n){return e?GB(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(cB(a,void 0,n))}}return i}};function $B(e){let t=Pz(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var eV={collection:`seq`,default:!0,nodeClass:QB,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Fz(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>QB.from(e,t,n)},tV={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),kB(e,t,n,r)}},nV={identify:e=>e==null,createNode:()=>new $(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new $(null),stringify:({source:e},t)=>typeof e==`string`&&nV.test.test(e)?e:t.options.nullStr},rV={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new $(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&rV.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function iV({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var aV={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:iV},oV={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():iV(e)}},sV={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new $(parseFloat(e)),n=e.indexOf(`.`);return n!==-1&&e[e.length-1]===`0`&&(t.minFractionDigits=e.length-n-1),t},stringify:iV},cV=e=>typeof e==`bigint`||Number.isInteger(e),lV=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function uV(e,t,n){let{value:r}=e;return cV(r)&&r>=0?n+r.toString(t):iV(e)}var dV={identify:e=>cV(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>lV(e,2,8,n),stringify:e=>uV(e,8,`0o`)},fV={identify:cV,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>lV(e,0,10,n),stringify:iV},pV={identify:e=>cV(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>lV(e,2,16,n),stringify:e=>uV(e,16,`0x`)},mV=[ZB,eV,tV,nV,rV,dV,fV,pV,aV,oV,sV];function hV(e){return typeof e==`bigint`||Number.isInteger(e)}var gV=({value:e})=>JSON.stringify(e),_V=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:gV},{identify:e=>e==null,createNode:()=>new $(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:gV},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:gV},{identify:hV,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>hV(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:gV}],vV=[ZB,eV].concat(_V,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),yV={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,t){if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return t(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:t,value:n},r,i,a){if(!n)return``;let o=n,s;if(typeof btoa==`function`){let e=``;for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);s=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(t??=$.BLOCK_LITERAL,t!==$.QUOTE_DOUBLE){let e=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),n=Math.ceil(s.length/e),i=Array(n);for(let t=0,r=0;t<n;++t,r+=e)i[t]=s.substr(r,e);s=i.join(t===$.BLOCK_LITERAL?`
|
|
70
|
-
`:` `)}return kB({comment:e,type:t,value:s},r,i,a)}};function bV(e,t){if(Fz(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!Nz(r)){if(Mz(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new WB(new $(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=Nz(r)?r:new WB(r)}}else t(`Expected a sequence for this tag`);return e}function xV(e,t,n){let{replacer:r}=n,i=new QB(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(UB(o,s,n))}return i}var SV={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:bV,createNode:xV},CV=class e extends QB{constructor(){super(),this.add=XB.prototype.add.bind(this),this.delete=XB.prototype.delete.bind(this),this.get=XB.prototype.get.bind(this),this.has=XB.prototype.has.bind(this),this.set=XB.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(Nz(e)?(r=tB(e.key,``,t),i=tB(e.value,r,t)):r=tB(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=xV(e,t,n),i=new this;return i.items=r.items,i}};CV.tag=`tag:yaml.org,2002:omap`;var wV={collection:`seq`,identify:e=>e instanceof Map,nodeClass:CV,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=bV(e,t),r=[];for(let{key:e}of n.items)Pz(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new CV,n)},createNode:(e,t,n)=>CV.from(e,t,n)};function TV({value:e,source:t},n){return t&&(e?EV:DV).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var EV={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new $(!0),stringify:TV},DV={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new $(!1),stringify:TV},OV={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:iV},kV={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():iV(e)}},AV={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new $(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:iV},jV=e=>typeof e==`bigint`||Number.isInteger(e);function MV(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function NV(e,t,n){let{value:r}=e;if(jV(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return iV(e)}var PV={identify:jV,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>MV(e,2,2,n),stringify:e=>NV(e,2,`0b`)},FV={identify:jV,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>MV(e,1,8,n),stringify:e=>NV(e,8,`0`)},IV={identify:jV,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>MV(e,0,10,n),stringify:iV},LV={identify:jV,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>MV(e,2,16,n),stringify:e=>NV(e,16,`0x`)},RV=class e extends XB{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=Nz(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new WB(e.key,null):new WB(e,null),YB(this.items,t.key)||this.items.push(t)}get(e,t){let n=YB(this.items,e);return!t&&Nz(n)?Pz(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=YB(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new WB(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(UB(e,null,n));return i}};RV.tag=`tag:yaml.org,2002:set`;var zV={collection:`map`,identify:e=>e instanceof Set,nodeClass:RV,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>RV.from(e,t,n),resolve(e,t){if(Mz(e)){if(e.hasAllNullValues(!0))return Object.assign(new RV,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function BV(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function VV(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return iV(e);let r=``;t<0&&(r=`-`,t*=n(-1));let i=n(60),a=[t%i];return t<60?a.unshift(0):(t=(t-a[0])/i,a.unshift(t%i),t>=60&&(t=(t-a[0])/i,a.unshift(t))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}var HV={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>BV(e,n),stringify:VV},UV={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>BV(e,!1),stringify:VV},WV={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(WV.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,i,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+`00`).substr(1,3)):0,l=Date.UTC(n,r-1,i,a||0,o||0,s||0,c),u=t[8];if(u&&u!==`Z`){let e=BV(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``},GV=[ZB,eV,tV,nV,EV,DV,PV,FV,IV,LV,OV,kV,AV,yV,LB,wV,SV,zV,HV,UV,WV],KV=new Map([[`core`,mV],[`failsafe`,[ZB,eV,tV]],[`json`,vV],[`yaml11`,GV],[`yaml-1.1`,GV]]),qV={binary:yV,bool:rV,float:sV,floatExp:oV,floatNaN:aV,floatTime:UV,int:fV,intHex:pV,intOct:dV,intTime:HV,map:ZB,merge:LB,null:nV,omap:wV,pairs:SV,seq:eV,set:zV,timestamp:WV},JV={"tag:yaml.org,2002:binary":yV,"tag:yaml.org,2002:merge":LB,"tag:yaml.org,2002:omap":wV,"tag:yaml.org,2002:pairs":SV,"tag:yaml.org,2002:set":zV,"tag:yaml.org,2002:timestamp":WV};function YV(e,t,n){let r=KV.get(t);if(r&&!e)return n&&!r.includes(LB)?r.concat(LB):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(KV.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(LB)),i.reduce((e,t)=>{let n=typeof t==`string`?qV[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(qV).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}var XV=(e,t)=>e.key<t.key?-1:+(e.key>t.key),ZV=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?YV(e,`compat`):e?YV(null,e):null,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?JV:{},this.tags=YV(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,Tz,{value:ZB}),Object.defineProperty(this,Dz,{value:tV}),Object.defineProperty(this,Oz,{value:eV}),this.sortMapEntries=typeof a==`function`?a:a===!0?XV:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function QV(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(n.push(t),r=!0):e.directives.docStart&&(r=!0)}r&&n.push(`---`);let i=AB(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(pB(t,``))}let o=!1,s=null;if(e.contents){if(Lz(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(pB(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=NB(e.contents,i,()=>s=null,t);s&&(c+=mB(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(NB(e.contents,i));if(e.directives?.docEnd){if(e.comment){let t=a(e.comment);t.includes(`
|
|
71
|
-
`)?(n.push(`...`),n.push(pB(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(pB(a(t),``)))}return n.join(`
|
|
72
|
-
`)+`
|
|
73
|
-
`}var $V=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,kz,{value:wz});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new Yz({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[kz]:{value:wz}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Lz(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){eH(this.contents)&&this.contents.add(e)}addIn(e,t){eH(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=Zz(this);e.anchor=!t||n.has(t)?Qz(t||`a`,n):t}return new rB(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=$z(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=cB(e,l,p);return o&&Iz(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new WB(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return eH(this.contents)?this.contents.delete(e):!1}deleteIn(e){return uB(e)?this.contents!=null&&(this.contents=null,!0):eH(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Iz(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return uB(e)?!t&&Pz(this.contents)?this.contents.value:this.contents:Iz(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Iz(this.contents)?this.contents.has(e):!1}hasIn(e){return uB(e)?this.contents!==void 0:Iz(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=lB(this.schema,[e],t):eH(this.contents)&&this.contents.set(e,t)}setIn(e,t){uB(e)?this.contents=t:this.contents==null?this.contents=lB(this.schema,Array.from(e),t):eH(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new Yz({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new Yz({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new ZV(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=tB(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?eB(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return QV(this,e)}};function eH(e){if(Iz(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var tH=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},nH=class extends tH{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},rH=class extends tH{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},iH=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
|
|
74
|
-
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t&&t.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function aH(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let ee=e[e.length-1],te=ee?ee.offset+ee.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:te,start:x??te}}function oH(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
|
|
75
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(oH(t.key)||oH(t.value))return!0}return!1;default:return!0}}function sH(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&oH(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function cH(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||Pz(e)&&Pz(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var lH=`All mapping items must start at the same column`;function uH({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??XB)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=aH(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,lH)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
|
|
76
|
-
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||oH(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,lH);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&sH(r.indent,u,i),n.atKey=!1,cH(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=aH(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&sH(r.indent,f,i),s=c.range[2];let l=new WB(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
|
|
77
|
-
`+_.comment:g.comment=_.comment);let e=new WB(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function dH({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??QB)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=aH(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l&&l.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&sH(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function fH(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var pH=`Block collections are not allowed within flow collections`,mH=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function hH({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?XB:QB))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=aH(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
|
|
78
|
-
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&oH(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];Nz(t)&&(t=t.value??t.key),t.comment?t.comment+=`
|
|
79
|
-
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],mH(m)&&i(r.range,`BLOCK_IN_FLOW`,pH)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);mH(f)&&i(g.range,`BLOCK_IN_FLOW`,pH),n.atKey=!1;let _=aH(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source&&m.source[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?mH(m)&&i(v.range,`BLOCK_IN_FLOW`,pH):_.comment&&(g.comment?g.comment+=`
|
|
80
|
-
`+_.comment:g.comment=_.comment);let y=new WB(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;cH(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new XB(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f&&f.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=fH(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
|
|
81
|
-
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function gH(e,t,n,r,i,a){let o=n.type===`block-map`?uH(e,t,n,r,a):n.type===`block-seq`?dH(e,t,n,r,a):hH(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function _H(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===XB.tagName&&s===`map`||o===QB.tagName&&s===`seq`)return gH(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r&&r.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),gH(e,t,n,i,o)}let l=gH(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=Lz(u)?u:new $(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function vH(e,t,n){let r=t.offset,i=yH(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?$.BLOCK_FOLDED:$.BLOCK_LITERAL,o=t.source?bH(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
|
|
82
|
-
`.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
|
|
83
|
-
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===$.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
|
|
84
|
-
`):t.length>c||r[0]===` `?(f===` `?f=`
|
|
85
|
-
`:!p&&f===`
|
|
86
|
-
`&&(f=`
|
|
87
|
-
|
|
88
|
-
`),d+=f+t.slice(c)+r,f=`
|
|
89
|
-
`,p=!0):r===``?f===`
|
|
90
|
-
`?d+=`
|
|
91
|
-
`:f=`
|
|
92
|
-
`:(d+=f+r,f=` `,p=!1)}switch(i.chomp){case`-`:break;case`+`:for(let e=s;e<o.length;++e)d+=`
|
|
93
|
-
`+o[e][0].slice(c);d[d.length-1]!==`
|
|
94
|
-
`&&(d+=`
|
|
95
|
-
`);break;default:d+=`
|
|
96
|
-
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function yH({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function bH(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function xH(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=$.PLAIN,c=SH(a,l);break;case`single-quoted-scalar`:s=$.QUOTE_SINGLE,c=CH(a,l);break;case`double-quoted-scalar`:s=$.QUOTE_DOUBLE,c=TH(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=fH(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function SH(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),wH(e)}function CH(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),wH(e.slice(1,-1)).replace(/''/g,`'`)}function wH(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
97
|
-
`,`sy`),n=RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
98
|
-
`,`sy`)}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let i=r[1],a=` `,o=t.lastIndex;for(n.lastIndex=o;r=n.exec(e);)r[1]===``?a===`
|
|
99
|
-
`?i+=a:a=`
|
|
100
|
-
`:(i+=a+r[1],a=` `),o=n.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),i+a+(r?.[1]??``)}function TH(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
|
|
101
|
-
`){if(i===`
|
|
102
|
-
`){let{fold:t,offset:i}=EH(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=DH[i];if(a)n+=a;else if(i===`
|
|
103
|
-
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
|
|
104
|
-
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a={x:2,u:4,U:8}[i];n+=OH(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
|
|
105
|
-
`&&(a!==`\r`||e[r+2]!==`
|
|
106
|
-
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function EH(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
|
|
107
|
-
`||r===`\r`)&&(r!==`\r`||e[t+2]===`
|
|
108
|
-
`);)r===`
|
|
109
|
-
`&&(n+=`
|
|
110
|
-
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var DH={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
|
|
111
|
-
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function OH(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}function kH(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?vH(e,t,r):xH(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[Dz]:c?AH(e.schema,i,c,n,r):t.type===`scalar`?jH(e,i,t,r):e.schema[Dz];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=Pz(a)?a:new $(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new $(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function AH(e,t,n,r,i){if(n===`!`)return e[Dz];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[Dz])}function jH({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[Dz];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[Dz];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function MH(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var NH={composeNode:PH,composeEmptyNode:FH};function PH(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=IH(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=kH(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:l=_H(NH,e,t,n,r),s&&(l.anchor=s.source.substring(1));break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),l=FH(e,t.offset,void 0,null,n,r),u=!1}return s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!Pz(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function FH(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=kH(e,{type:`scalar`,offset:MH(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function IH({options:e},{offset:t,source:n,end:r},i){let a=new rB(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=fH(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function LH(e,t,{offset:n,start:r,value:i,end:a},o){let s=new $V(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=aH(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?PH(c,i,l,o):FH(c,l.end,r,null,l,o);let u=s.contents.range[2],d=fH(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function RH(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function zH(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
|
|
112
|
-
|
|
113
|
-
`:`
|
|
114
|
-
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var BH=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=RH(e);r?this.warnings.push(new rH(i,t,n)):this.errors.push(new nH(i,t,n))},this.directives=new Yz({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=zH(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(Iz(i)&&!i.flow&&i.items.length>0){let e=i.items[0];Nz(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:zH(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=RH(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=LH(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new nH(RH(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new nH(RH(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=fH(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new nH(RH(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new $V(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},VH=Symbol(`break visit`),HH=Symbol(`skip children`),UH=Symbol(`remove item`);function WH(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),GH(Object.freeze([]),e,t)}WH.BREAK=VH,WH.SKIP=HH,WH.REMOVE=UH,WH.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},WH.parentCollection=(e,t)=>{let n=WH.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function GH(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=GH(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===VH)return VH;else r===UH&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function KH(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
|
|
115
|
-
`:case`\r
|
|
116
|
-
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function qH(e){switch(e){case void 0:case` `:case`
|
|
117
|
-
`:case`\r`:case` `:return!0;default:return!1}}var JH=new Set(`0123456789ABCDEFabcdef`),YH=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),XH=new Set(`,[]{}`),ZH=new Set(` ,[]{}
|
|
118
|
-
\r `),QH=e=>!e||ZH.has(e),$H=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
|
|
119
|
-
`||t===`\r`&&this.buffer[e+1]===`
|
|
120
|
-
`}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
|
|
121
|
-
`||!t&&!this.atEnd)return e+n+1}return t===`
|
|
122
|
-
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&qH(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
123
|
-
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&qH(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!qH(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&qH(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,yield*this.parseBlockStart()}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(QH),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&qH(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(QH),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||qH(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
|
|
124
|
-
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
|
|
125
|
-
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>qH(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
|
|
126
|
-
`:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
|
|
127
|
-
`)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?t:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
|
|
128
|
-
`,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
|
|
129
|
-
`;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
|
|
130
|
-
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(!0);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(qH(r)||e&&XH.has(r))break;t=n}else if(qH(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
|
|
131
|
-
`?(n+=1,r=`
|
|
132
|
-
`,i=this.buffer[n+1]):t=n),i===`#`||e&&XH.has(i))break;if(r===`
|
|
133
|
-
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&XH.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){switch(this.charAt(0)){case`!`:return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`&`:return(yield*this.pushUntil(QH))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`-`:case`?`:case`:`:{let e=this.flowLevel>0,t=this.charAt(1);if(qH(t)||e&&XH.has(t))return e?this.flowKey&&=!1:this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!qH(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(YH.has(t))t=this.buffer[++e];else if(t===`%`&&JH.has(this.buffer[e+1])&&JH.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
134
|
-
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
135
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},eU=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function tU(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function nU(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function rU(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function iU(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function aU(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function oU(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!tU(t.start,`explicit-key-ind`)&&!tU(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,rU(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}var sU=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new $H,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=KH(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&(!e||e.type!==`doc-end`)){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&oU(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&nU(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:nU(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=aU(iU(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
|
|
136
|
-
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
137
|
-
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(tU(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=aU(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(tU(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(rU(t.key)&&!tU(t.sep,`newline`)){let e=aU(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):tU(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!tU(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||tU(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e&&e.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=aU(iU(t));oU(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
|
|
138
|
-
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
139
|
-
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=aU(iU(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=aU(iU(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function cU(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new eU||null,prettyErrors:t}}function lU(e,t={}){let{lineCounter:n,prettyErrors:r}=cU(t),i=new sU(n?.addNewLine),a=new BH(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new nH(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(iH(e,n)),o.warnings.forEach(iH(e,n))),o}var uU=e=>gi(Zx(I({message:V}))(e),{onNone:()=>`Unknown YAML parsing failure`,onSome:({message:e})=>e}),dU=(e,t)=>A(function*(){let n=yield*ch({try:()=>lU(t,{keepSourceTokens:!0,prettyErrors:!0,strict:!0,uniqueKeys:!0}),catch:t=>new aR({file:e,stage:`yaml`,expression:T(),message:uU(t)})}),r=n.errors[0]??n.warnings[0];return r===void 0?n:yield*new aR({file:e,stage:`yaml`,expression:T(),message:r.message})}),fU=Yg(),pU=class extends H(`@usine/config/LoopFrontmatter`)({trigger:jR,selector:tC(DR),approval:rT.pipe(MS(k(`none`))),step:JT.pipe(MS(k(`run`))),agent:HT,maxCycles:FR.fields.maxCycles}){}.pipe(bS({maxCycles:`max_cycles`})),mU=class extends H(`@usine/config/AgentFrontmatter`)({harness:zT,model:RT,effort:BT,parent_model:tC(RT),parent_effort:tC(BT)}){},hU=(e,t)=>new aR({file:e,stage:`schema`,expression:T(),message:fU(t.issue)}),gU=Kx(ew),_U=(e,t)=>A(function*(){return yield*gU((yield*dU(e,t)).toJS()).pipe(Ch(t=>new aR({file:e,stage:`yaml`,expression:T(),message:fU(t.issue)})))}),vU=(e,t)=>new aR({file:e,stage:`expression`,expression:E(t.source),message:t.message}),yU=e=>{let t=e.slice(e.lastIndexOf(`/`)+1);return t.endsWith(`.md`)?k(t.slice(0,-3)):new aR({file:e,stage:`schema`,expression:T(),message:`Expected a .md filename`})},bU=e=>yU(e).pipe(M(t=>Kx(FR.fields.name)(t).pipe(Ch(t=>hU(e,t))))),xU=e=>yU(e).pipe(M(t=>Kx(HT)(t).pipe(Ch(t=>hU(e,t))))),SU=(e,t)=>A(function*(){let n=[],r=0;for(;r<t.length;){let i=t.indexOf(`{{`,r);if(i<0)break;let a=t.indexOf(`}}`,i+2);if(a<0)return yield*new aR({file:e,stage:`expression`,expression:T(),message:`Unclosed prompt interpolation at character ${i}`});let o=t.slice(i+2,a).trim(),s=yield*Kx($L)(o).pipe(Ch(t=>hU(e,t)));n.push({source:s,start:i,end:a+2}),r=a+2}return n}),CU=(e,t,n)=>{let r=IR(t.name),i=xz(t.trigger.on);return A(function*(){let a=yield*Xm(yield*SU(r,t.body),t=>e.evaluateScalar(t.source,i,n).pipe(Ch(e=>vU(r,e)),gh(e=>({expression:t,value:e})))),o=``,s=0;for(let{expression:e,value:n}of a)o+=t.body.slice(s,e.start),o+=String(n),s=e.end;return o+t.body.slice(s)})},wU=N(`ConfigParser.parseUsineYaml`)((e,t)=>A(function*(){let n=yield*_U(e,t);return yield*Kx(ER)(n,{onExcessProperty:`error`}).pipe(Ch(t=>hU(e,t)))})),TU=N(`ConfigParser.parseAgentFile`)((e,t)=>A(function*(){let n=yield*xU(e),r=yield*sR(e,t),i=yield*_U(e,r.yaml),a=yield*Kx(mU)(i,{onExcessProperty:`error`}).pipe(Ch(t=>hU(e,t))),o=yield*Kx(UT)(r.body).pipe(Ch(t=>hU(e,t)));return new cR({name:n,harness:a.harness,model:a.model,effort:a.effort,parentModel:a.parent_model,parentEffort:a.parent_effort,persona:o})})),EU=e=>N(`ConfigParser.parseLoopFile`)((t,n)=>A(function*(){let r=yield*bU(t),i=yield*sR(t,n),a=yield*_U(t,i.yaml),o=yield*Kx(pU)(a,{onExcessProperty:`error`}).pipe(Ch(e=>hU(t,e))),s=yield*Kx(PR)(i.body).pipe(Ch(e=>hU(t,e))),c=xz(o.trigger.on);return yield*e.checkBoolean(o.trigger.if,c).pipe(Ch(e=>vU(t,e))),yield*Xm(yield*SU(t,s),({source:n})=>e.checkScalar(n,c).pipe(Ch(e=>vU(t,e))),{discard:!0}),new FR({name:r,trigger:o.trigger,selector:o.selector,approval:o.approval,maxCycles:o.maxCycles,step:o.step,agent:o.agent,body:s})})),DU=Zx(Kj),OU=e=>N(`ConfigParser.configWarnings`)(function*(t,n){let r=new Set(t.labels.map(({name:e})=>qj(e))),i=[];for(let e of t.repos)for(let t of e.lanes)for(let n of t.sources)`label`in n&&!r.has(qj(n.label))&&i.push(new LR({repository:e.name,lane:t.name,label:n.label}));for(let t of n){let n=yield*e.relatedStringLiterals(t.trigger.if,[`item`,`labels`]);for(let e of n){let n=DU(e);D(n)&&!r.has(qj(n.value))&&i.push(new RR({loop:t.name,label:n.value}))}}return i}),kU=class e extends O()(`@usine/config/ConfigParser`){static layer=Gf(e,A(function*(){let e=yield*nR;return{configWarnings:OU(e),parseUsineYaml:wU,parseAgentFile:TU,parseLoopFile:EU(e),renderPrompt:N(`ConfigParser.renderPrompt`)((t,n)=>CU(e,t,n))}}))},AU=class extends H(`@usine/engine/RunSnapshot`)({event:eT,itemKey:NE,run:IT,step:YT,attempts:L(jE),repository:qw,revision:Jw,task:AE,agent:WT,parentModel:$S(RT)}){};H(`@usine/engine/RunEvidence`)({snapshot:AU,transcript:L(SD)});var jU=class extends H(`@usine/engine/RunSummary`)({itemKey:NE,run:IT,step:YT,attempts:L(jE),repository:qw,task:AE,agent:WT}){},MU=JS.check(GS(0)).pipe(z(`ProjectionRevision`)),NU=I({eventId:Qw,dedupKey:$w,payload:ew,receivedAt:AC,itemKey:NE,loop:tT,step:JT,approval:rT,cycleLimit:DS(FE),cycleGeneration:IE,repository:qw,revision:Jw,task:AE,agent:WT,parentModel:DS(RT)}),PU=I({itemKey:NE,repository:qw,revision:Jw,task:AE,agent:WT,parentModel:DS(RT),runId:FT,eventId:Qw,loop:tT,state:gT,openedAt:AC,stepName:JT,result:DS(qT)}),FU=I({attemptId:OE,runId:FT,stepName:JT,worker:XT,number:kE,brain:VT,task:AE,agent:HT,operatorIntervened:hS,parentModel:DS(RT),startedAt:AC,outcome:DS(DE)}),IU=I({sequence:_D,attemptId:OE,direction:WE,envelope:SD.fields.envelope,receivedAt:AC}),LU=I({...NU.fields,runId:FT,state:gT}),RU=I({runId:FT}),zU=I({reason:BF}),BU=I({runId:FT,command:GF}),VU=I({revision:MU}),HU=Kx(L(NU)),UU=Kx(L(PU)),WU=Kx(L(FU)),GU=Kx(L(LU)),KU=Kx(L(RU)),qU=Kx(L(zU)),JU=Kx(L(BU)),YU=Kx(L(VU)),XU=Kx(L(IU)),ZU=rS(ew),QU=rS(AC),$U=rS(gT),eW=rS(DE),tW=rS(qT),nW=rS(hD),rW=rS(WT),iW=rS(VT),aW=Gx(dI),oW=e=>t=>Ch(t,t=>aW(t)?t:new lI({operation:e,cause:t})),sW=e=>new eT({id:e.eventId,dedupKey:e.dedupKey,payload:e.payload,receivedAt:e.receivedAt}),cW=e=>new IF({event:sW(e),itemKey:e.itemKey,loop:e.loop,step:e.step,approval:e.approval,cycleLimit:yi(e.cycleLimit),cycleGeneration:e.cycleGeneration,repository:e.repository,revision:e.revision,task:e.task,agent:e.agent,parentModel:yi(e.parentModel)}),lW=e=>new IT({id:e.runId,eventId:e.eventId,loop:e.loop,state:e.state,openedAt:e.openedAt}),uW=e=>new YT({runId:e.runId,name:e.stepName,result:yi(e.result)}),dW=e=>new jE({id:e.attemptId,runId:e.runId,stepName:e.stepName,worker:e.worker,number:e.number,brain:e.brain,task:e.task,agent:e.agent,operatorIntervened:e.operatorIntervened,parentModel:yi(e.parentModel),startedAt:e.startedAt,outcome:yi(e.outcome)}),fW=(e,t)=>new jU({itemKey:e.itemKey,run:lW(e),step:uW(e),attempts:t.map(dW),repository:e.repository,task:e.task,agent:e.agent}),pW=e=>new SD({sequence:e.sequence,attemptId:e.attemptId,direction:e.direction,envelope:e.envelope,receivedAt:e.receivedAt}),mW=class extends H(`CycleBudgetReset`)({itemKey:NE,repository:qw,generation:IE}){},hW=class extends zC(`CycleBudgetResetRejectedError`)(`CycleBudgetResetRejectedError`,{askId:BE}){},gW=I({...mW.fields,ask:eC(VE),resetPending:hS}),_W={itemKey:JF.itemKey,repository:JF.repository,generation:JF.generation,ask:JF.askJson,resetPending:JF.resetPending},vW=Kx(L(gW),{onExcessProperty:`error`}),yW=e=>{let t=Y(Z.cycleGeneration,J`coalesce((
|
|
140
|
-
select ${JF.generation} from ${JF}
|
|
141
|
-
where ${JF.itemKey} = ${Z.itemKey}
|
|
142
|
-
), 0)`),n=N(`CycleBudget.get`)(function*(t){return yield*Gh({itemKey:t}),yi((yield*e.select(_W).from(JF).where(Y(JF.itemKey,t)).execute().pipe(M(vW)))[0])}),r=N(`CycleBudget.counts`)(function*(t){yield*Gh({itemKey:t.itemKey,generation:t.generation});let n=gN(e.select({id:QF.attemptId}).from(QF).where(Y(QF.runId,Q.runId))),r=J`json_extract(${Q.stateJson}, '$._tag')`,i=yield*e.select({loop:YF.loop,admitted:J`count(*)`,completed:J`sum(case when ${pN(r,[...CT])} and ${n} then 1 else 0 end)`}).from(YF).innerJoin(Q,Y(Q.runId,YF.runId)).where(aN(Y(YF.itemKey,t.itemKey),Y(YF.generation,t.generation),oN(iN(r,`Canceled`),n))).groupBy(YF.loop).orderBy(DN(YF.loop)).execute();return yield*Kx(L(zE))(i,{onExcessProperty:`error`})});return{admit:N(`CycleBudget.admit`)(function*(t){yield*Gh({itemKey:t.itemKey,loop:t.loop});let i=yield*n(t.itemKey);if(D(i)&&D(i.value.ask))return yield*ng(`Item cycle budget remains exhausted`,{itemKey:t.itemKey,askId:i.value.ask.value.id,loop:t.loop}),i.value.ask;if(hi(t.cycleLimit))return T();yield*e.insert(JF).values({itemKey:t.itemKey,repository:t.repository}).onConflictDoNothing().execute();let a=yield*n(t.itemKey);if(hi(a))return yield*sh(Error(`Cycle budget missing after insertion`));let o=yield*r(a.value),s=o.find(({loop:e})=>e===t.loop);if(s===void 0||s.admitted<t.cycleLimit.value)return T();let c=new VE({id:BE.make(Qw.make(JSON.stringify([t.event.id,a.value.generation]))),itemKey:t.itemKey,repository:t.repository,loop:t.loop,limit:t.cycleLimit.value,counts:[s,...o.filter(({loop:e})=>e!==t.loop)]});return yield*e.update(JF).set({askJson:rS(VE)(c)}).where(Y(JF.itemKey,t.itemKey)).execute(),yield*eg(`Item cycle budget exhausted; operator reset required`,{itemKey:t.itemKey,repository:t.repository,askId:c.id,loop:c.loop,limit:c.limit,completedCycles:c.completedCycles,counts:c.counts}),E(c)}),reserve:N(`CycleBudget.reserve`)(function*(t,i){if(hi(t.cycleLimit))return;yield*Gh({runId:i,itemKey:t.itemKey,loop:t.loop});let a=yield*n(t.itemKey);if(hi(a))return yield*sh(Error(`Run admitted without its cycle budget`));yield*e.insert(YF).values({runId:i,itemKey:t.itemKey,loop:t.loop,generation:a.value.generation}).onConflictDoNothing().execute(),yield*ng(`Item cycle reserved`,{runId:i,itemKey:t.itemKey,loop:t.loop,generation:a.value.generation,counts:yield*r(a.value)})}),get:n,asks:N(`CycleBudget.asks`)(function*(){return(yield*e.select(_W).from(JF).where(hN(JF.askJson)).execute().pipe(M(vW))).flatMap(({ask:e})=>ki(e))}),pendingResets:N(`CycleBudget.pendingResets`)(function*(){return yield*e.select(_W).from(JF).where(Y(JF.resetPending,!0)).execute().pipe(M(vW))}),isCurrentEvent:N(`CycleBudget.isCurrentEvent`)(function*(e){yield*Gh({eventId:e.event.id,itemKey:e.itemKey});let t=gi(yield*n(e.itemKey),{onNone:()=>0,onSome:e=>e.generation}),r=e.cycleGeneration===t;return r||(yield*ng(`Event observation was superseded by a cycle reset`,{eventId:e.event.id,itemKey:e.itemKey,observedGeneration:e.cycleGeneration,generation:t})),r}),currentEvent:t}},bW=e=>gh(Zm(()=>crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e))),e=>{let t=new Uint8Array(e),n=``;for(let e=0;e<16;e++)n+=t[e].toString(16).padStart(2,`0`);return n}),xW=`~effect/workflow/Workflow`,SW=O(`effect/workflow/WorkflowEngine`),CW=O(`effect/workflow/WorkflowEngine/WorkflowInstance`),wW=(e,t)=>bW(`${e._tag}-${e.idempotencyKey(t)}`),TW={[xW]:xW,annotate(e,t){return EW({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,annotations:ro(this.annotations,e,t),idempotencyKey:this.idempotencyKey,suspendedRetrySchedule:this.suspendedRetrySchedule})},annotateMerge(e){return EW({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,annotations:mo(this.annotations,e),idempotencyKey:this.idempotencyKey,suspendedRetrySchedule:this.suspendedRetrySchedule})},execute(e,t){return eh(()=>{let n=this.payloadSchema.make(e);return M(SW,e=>M(wW(this,n),r=>fh(Gh({executionId:r}),e.execute(this,{executionId:r,payload:n,discard:t?.discard,suspendedRetrySchedule:this.suspendedRetrySchedule}))))}).pipe(qh(`${this._tag}.execute`,{},{captureStackTrace:!1}))},poll(e){return M(SW,t=>t.poll(this,e)).pipe(qh(`${this._tag}.poll`,{attributes:{executionId:e}},{captureStackTrace:!1}))},interrupt(e){return M(SW,t=>t.interrupt(this,e)).pipe(qh(`${this._tag}.interrupt`,{attributes:{executionId:e}},{captureStackTrace:!1}))},resume(e){return M(SW,t=>t.resume(this,e)).pipe(qh(`${this._tag}.resume`,{attributes:{executionId:e}},{captureStackTrace:!1}))},toLayer(e){return Jf(M(SW,t=>t.register(this,e)))},executionId(e){return M(wh(this.payloadSchema.makeEffect(e)),e=>wW(this,e))},withCompensation:(...e)=>NW(...e)},EW=e=>{function t(){}return Object.setPrototypeOf(t,TW),Object.assign(t,e),t},DW=(e,t)=>EW({_tag:e,payloadSchema:iS(t.payload)?t.payload:I(t.payload),successSchema:t.success??_S,errorSchema:t.error??uS,annotations:t.annotations??eo(),idempotencyKey:t.idempotencyKey,suspendedRetrySchedule:t.suspendedRetrySchedule}),OW=`~effect/workflow/Workflow/Result`,kW=e=>At(e,OW);H(`effect/workflow/Workflow/Suspended`)({_tag:PS(`Suspended`),cause:oS(cC(uS,hC()))});var AW=(e,t)=>Ah(n=>{let r=co(n,CW),i=r.activityState;return i.count===0&&i.latch.closeUnsafe(),i.count++,zh(e,e=>{i.count--;let n=ff(e)&&t(e.value);return ff(e)&&kW(e.value)&&e.value._tag===`Suspended`&&e.value.cause&&(r.cause=r.cause?Qd(r.cause,e.value.cause):e.value.cause),i.count===0?i.latch.open:n?jW(r):nh})}),jW=$h(function*(e){let t=e.activityState;for(;;){if(t.count>0){yield*t.latch.await,yield*lh;continue}if(yield*lh,t.count===0)return}}),MW=$h(function*(e){let t=(yield*CW).scope,n=yield*kh();yield*Tf(t,t=>Mh(e(t),n))}),NW=S(2,(e,t)=>Uh(n=>ph(n(e),e=>MW(n=>ff(n)?nh:t(e,n.cause))))),PW=e=>Vh(rh(()=>{e.suspended=!0;let t=Db();t.interruptUnsafe(t.id)})),FW=go(`effect/workflow/Workflow/SuspendOnFailure`,{defaultValue:ct}),IW=`~effect/workflow/DurableDeferred`,LW=(e,t)=>{let n=t?.success??_S,r=t?.error??uS;return{[IW]:IW,name:e,successSchema:n,errorSchema:r,exitSchema:gC(BC(n),BC(r),BC(hC())),withActivityAttempt:A(function*(){return LW(`${e}/${yield*BW}`,{success:n,error:r})})}},RW=O(`effect/workflow/WorkflowEngine`),zW=O(`effect/workflow/WorkflowEngine/WorkflowInstance`),BW=go(`effect/workflow/Activity/CurrentAttempt`,{defaultValue:()=>1}),VW=$h(function*(e){let t=yield*RW,n=yield*zW;n.awaitedDeferreds.add(e.name);let r=yield*AW(t.deferredResult(e),hi);return hi(r)?yield*PW(n):yield*r.value}),HW=class e extends H(`effect/workflow/DurableDeferred/TokenParsed`)({workflowName:F,executionId:F,deferredName:F}){get asToken(){return ps(JSON.stringify([this.workflowName,this.executionId,this.deferredName]))}static FromString=F.pipe(B(wC(CS([F,F,F])),{decode:I_(),encode:P_()}),B(e,{decode:C_(([t,n,r])=>new e({workflowName:t,executionId:n,deferredName:r})),encode:C_(e=>[e.workflowName,e.executionId,e.deferredName])}));static fromString=eS(e.FromString);static encode=rS(e.FromString)},UW=S(2,(e,t)=>new HW({workflowName:t.workflow._tag,executionId:t.executionId,deferredName:e.name}).asToken),WW=S(2,$h(function*(e,t){let n=yield*RW,r=HW.fromString(t.token);yield*n.deferredDone(e,{workflowName:r.workflowName,executionId:r.executionId,deferredName:r.deferredName,exit:t.exit})})),GW=S(2,(e,t)=>WW(e,{token:t.token,exit:cf(t.value)})),KW=class extends O()(`effect/workflow/WorkflowEngine`){};O()(`effect/workflow/WorkflowEngine/WorkflowInstance`);var qW=class extends H(`@usine/engine/StepExecution`)({attempt:jE,event:eT,run:IT,step:YT,repository:qw,revision:Jw,task:AE,agent:WT,parentModel:$S(RT)}){},JW=class extends O()(`@usine/engine/StepExecutor`){},YW=e=>({appendTranscript:N(`RunStoreQueries.appendTranscript`)(function*(t,n,r){yield*e.insert($F).values({attemptId:n.attemptId,direction:t,channelSequence:n.sequence,envelope:nW(n),receivedAt:QU(r)}).onConflictDoNothing().execute()}),transcript:N(`RunStoreQueries.transcript`)(function*(t){yield*Gh({attemptId:t.attemptId,query:t._tag});let n=Mw(t,{TranscriptSessionsQuery:({attemptId:t})=>fN($F.sequence,e.select({sequence:J`max(${$F.sequence})`}).from($F).where(aN(Y($F.attemptId,t),J`(
|
|
143
|
-
json_extract(${$F.envelope}, '$.payload._tag') = 'InterventionApplied'
|
|
144
|
-
OR (json_extract(${$F.envelope}, '$.payload._tag') = 'SessionEvent'
|
|
145
|
-
AND json_extract(${$F.envelope}, '$.payload.event._tag') IN ('SessionStarted', 'SessionIdle', 'SessionResumed', 'SessionFinished'))
|
|
146
|
-
)`)).groupBy(J`coalesce(json_extract(${$F.envelope}, '$.payload.event.session.id'), json_extract(${$F.envelope}, '$.payload.intervention.target.sessionId'), '@parent')`,J`json_extract(${$F.envelope}, '$.payload._tag')`,J`json_extract(${$F.envelope}, '$.payload.event._tag') = 'SessionStarted'`)),TranscriptAllQuery:({attemptId:e})=>Y($F.attemptId,e),TranscriptTailQuery:({attemptId:e,after:t})=>aN(Y($F.attemptId,e),cN($F.sequence,t)),TranscriptPageQuery:({attemptId:e,before:t})=>gi(t,{onNone:()=>Y($F.attemptId,e),onSome:t=>aN(Y($F.attemptId,e),uN($F.sequence,t))})}),r=e.select({sequence:$F.sequence,attemptId:$F.attemptId,direction:$F.direction,envelope:$F.envelope,receivedAt:$F.receivedAt}).from($F).where(n);return(yield*XU(yield*Mw(t,{TranscriptSessionsQuery:()=>r.orderBy(DN($F.sequence)).execute(),TranscriptAllQuery:()=>r.orderBy(DN($F.sequence)).execute(),TranscriptTailQuery:({limit:e})=>r.orderBy(DN($F.sequence)).limit(e).execute(),TranscriptPageQuery:({limit:e})=>r.orderBy(ON($F.sequence)).limit(e).execute()}),{onExcessProperty:`error`})).map(pW).sort((e,t)=>e.sequence-t.sequence)})}),XW=(e,t)=>p_(t.openedAt)-p_(e.openedAt)||t.runId.localeCompare(e.runId),ZW={eventId:qF.eventId,dedupKey:qF.dedupKey,payload:qF.payloadJson,receivedAt:qF.receivedAt,itemKey:Z.itemKey,loop:Z.loopName,step:Z.stepName,approval:Z.approval,cycleLimit:Z.cycleLimit,cycleGeneration:Z.cycleGeneration,repository:Z.repository,revision:Z.revision,task:Z.task,agent:Z.agentJson,parentModel:Z.parentModel},QW={itemKey:Z.itemKey,runId:Q.runId,eventId:Q.eventId,loop:Q.loopName,state:Q.stateJson,openedAt:Q.openedAt,repository:Q.repository,revision:Q.revision,task:Q.task,agent:Q.agentJson,parentModel:Q.parentModel,stepName:ZF.stepName,result:ZF.result},$W={attemptId:QF.attemptId,runId:QF.runId,stepName:QF.stepName,worker:QF.workerName,number:QF.attemptNumber,brain:QF.brainJson,task:QF.task,agent:QF.agent,operatorIntervened:QF.operatorIntervened,parentModel:QF.parentModel,startedAt:QF.startedAt,outcome:QF.outcomeJson},eG=J`json_extract(${Q.stateJson}, '$._tag')`,tG=fN(eG,[...CT]),nG=fN(eG,[...TT]),rG=e=>$x(ew)(rW(e)),iG=e=>{let t=N(`RunStoreQueries.eventRouteByDedup`)(function*(t){return yield*HU(yield*e.select(ZW).from(qF).innerJoin(Z,Y(Z.eventId,qF.eventId)).where(Y(qF.dedupKey,t)).execute())}),n=N(`RunStoreQueries.eventRouteByRun`)(function*(t){return yield*HU(yield*e.select(ZW).from(Q).innerJoin(qF,Y(qF.eventId,Q.eventId)).innerJoin(Z,Y(Z.eventId,qF.eventId)).where(Y(Q.runId,t)).execute())}),r=N(`RunStoreQueries.runRows`)(function*(t){return yield*UU(yield*e.select(QW).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).innerJoin(ZF,Y(ZF.runId,Q.runId)).where(Y(Q.runId,t)).execute())}),i=N(`RunStoreQueries.attemptRows`)(function*(t){return yield*WU(yield*e.select($W).from(QF).where(Y(QF.runId,t)).orderBy(QF.attemptNumber).execute())}),a=N(`RunStoreQueries.snapshot`)(function*(e){let[t,a,o]=yield*Ym([r(e),i(e),n(e)]),s=t[0],c=o[0];return s===void 0||c===void 0?yield*new sI({runId:e}):new AU({event:sW(c),itemKey:c.itemKey,run:lW(s),step:uW(s),attempts:a.map(dW),repository:s.repository,revision:s.revision,task:s.task,agent:s.agent,parentModel:yi(s.parentModel)})}),o=N(`RunStoreQueries.summariesWithAttempts`)(function*(t){let n=ua((yield*Xm(la(t.map(({runId:e})=>e),100),t=>e.select($W).from(QF).where(fN(QF.runId,t)).orderBy(DN(QF.runId),DN(QF.attemptNumber)).execute().pipe(M(WU)))).flat(),({runId:e})=>e);return t.map(e=>fW(e,n[e.runId]??[]))}),s=N(`RunStoreQueries.itemRunSummaries`)(function*(t){if(t.length===0)return[];let n=(yield*Xm(la([...new Set(t)],100),t=>e.select(QW).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).innerJoin(ZF,Y(ZF.runId,Q.runId)).where(fN(Z.itemKey,t)).execute().pipe(M(UU)))).flat().sort(XW);return yield*o(n)}),c=N(`RunStoreQueries.runSummaries`)(function*(t){let[n,r]=yield*Ym([e.select(QW).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).innerJoin(ZF,Y(ZF.runId,Q.runId)).where(tG).orderBy(ON(Q.openedAt),ON(Q.runId)).execute().pipe(M(UU)),e.select(QW).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).innerJoin(ZF,Y(ZF.runId,Q.runId)).where(pN(eG,[...CT])).orderBy(ON(Q.openedAt),ON(Q.runId)).limit(t).execute().pipe(M(UU))]),i=[...n,...r].sort(XW);return yield*o(i)}),l=N(`RunStoreQueries.projectionRevision`)(function*(){return yi((yield*YU(yield*e.select({revision:oI.revision}).from(oI).where(Y(oI.singleton,1)).limit(1).execute()))[0]?.revision)}),u=N(`RunStoreQueries.updateState`)(function*(t,n){if((yield*e.update(Q).set({stateJson:$U(n)}).where(Y(Q.runId,t)).returning({runId:Q.runId}).execute()).length===0)return yield*new sI({runId:t})}),d=N(`RunStoreQueries.addAttempt`)(function*(t){yield*e.insert(QF).values({attemptId:t.id,runId:t.runId,stepName:t.stepName,workerName:t.worker,attemptNumber:t.number,brainJson:iW(t.brain),task:t.task,agent:t.agent,operatorIntervened:t.operatorIntervened,parentModel:Si(t.parentModel),startedAt:QU(t.startedAt),outcomeJson:null}).execute()}),f=N(`RunStoreQueries.closeAttempt`)(function*(t,n){yield*e.update(QF).set({outcomeJson:eW(n)}).where(aN(Y(QF.attemptId,t),mN(QF.outcomeJson))).execute()}),p=N(`RunStoreQueries.amend`)(function*(t,n){yield*Gh({runId:t,agent:n.agent.name}),yield*e.update(Q).set({task:n.task,agentJson:rG(n.agent),parentModel:Si(n.parentModel)}).where(Y(Q.runId,t)).execute()}),m=N(`RunStoreQueries.markIntervened`)(function*(t){yield*Gh({attemptId:t}),yield*e.update(QF).set({operatorIntervened:!0}).where(Y(QF.attemptId,t)).execute()}),h=N(`RunStoreQueries.updateAttemptParentModel`)(function*(t,n){yield*e.update(QF).set({parentModel:n}).where(Y(QF.attemptId,t)).execute()}),g=N(`RunStoreQueries.updateStepResult`)(function*(t,n,r){yield*e.update(ZF).set({result:tW(r)}).where(aN(Y(ZF.runId,t),Y(ZF.stepName,n))).execute()}),_=N(`RunStoreQueries.approvalExists`)(function*(t){return(yield*e.$count(eI,Y(eI.runId,t)).execute())>0}),v=N(`RunStoreQueries.recordApproval`)(function*(t,n){yield*e.insert(qF).values({eventId:n.id,dedupKey:n.dedupKey,payloadJson:ZU(n.payload),receivedAt:QU(n.receivedAt)}).onConflictDoNothing().execute(),yield*e.insert(eI).values({runId:t,eventId:n.id}).execute()}),y=N(`RunStoreQueries.requestWorkflowCommand`)(function*(t,n){yield*e.insert(nI).values({runId:t,command:n}).onConflictDoNothing().execute()}),b=N(`RunStoreQueries.requestInterrupt`)(function*(t){yield*e.delete(nI).where(aN(Y(nI.runId,t),fN(nI.command,[`Approve`,`Resume`]))).execute(),yield*y(t,`Interrupt`)}),x=N(`RunStoreQueries.workflowCommandsFor`)(function*(t){return yield*Gh({runId:t}),(yield*JU(yield*e.select({runId:nI.runId,command:nI.command}).from(nI).where(Y(nI.runId,t)).execute())).map(({command:e})=>e)}),ee=N(`RunStoreQueries.createRun`)(function*(t,n,r){let i=FF(Z,`candidate`),a=FF(Q,`candidate_run`),o=FF(tI,`ignored`);yield*e.insert(tI).select(e.select({eventId:i.eventId,reason:J`'superseded'`.as(`reason`)}).from(i).leftJoin(a,Y(a.eventId,i.eventId)).leftJoin(o,Y(o.eventId,i.eventId)).where(aN(Y(i.loopName,t.loop),Y(i.itemKey,t.itemKey),iN(i.eventId,n),mN(a.runId),mN(o.eventId)))).onConflictDoNothing().execute(),yield*e.insert(Q).values({runId:r,eventId:n,loopName:t.loop,stateJson:$U(new cT),openedAt:QU(t.event.receivedAt),repository:t.repository,revision:t.revision,task:t.task,agentJson:rG(t.agent),parentModel:Si(t.parentModel)}).onConflictDoNothing().execute(),yield*e.insert(ZF).values({runId:r,stepName:t.step,result:null}).onConflictDoNothing().execute()}),te=N(`RunStoreQueries.runForEvent`)(function*(t){return yield*KU(yield*e.select({runId:Q.runId}).from(Q).where(Y(Q.eventId,t)).execute())}),ne=N(`RunStoreQueries.ignoredEvent`)(function*(t){return yield*qU(yield*e.select({reason:tI.reason}).from(tI).where(Y(tI.eventId,t)).execute())}),re=N(`RunStoreQueries.blockingRun`)(function*(t,n){return yield*KU(yield*e.select({runId:Q.runId}).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).where(aN(Y(Z.loopName,t),Y(Z.itemKey,n),tG)).orderBy(ON(Q.openedAt)).limit(1).execute())}),ie=N(`RunStoreQueries.recordTriggerEvent`)(function*(n){yield*e.insert(qF).values({eventId:n.event.id,dedupKey:n.event.dedupKey,payloadJson:ZU(n.event.payload),receivedAt:QU(n.event.receivedAt)}).onConflictDoNothing().execute();let r=(yield*t(n.event.dedupKey))[0];return r===void 0?(yield*e.insert(Z).values({eventId:n.event.id,itemKey:n.itemKey,loopName:n.loop,stepName:n.step,approval:n.approval,cycleLimit:Si(n.cycleLimit),cycleGeneration:n.cycleGeneration,repository:n.repository,revision:n.revision,task:n.task,agentJson:rG(n.agent),parentModel:Si(n.parentModel)}).execute(),n):cW(r)}),ae=N(`RunStoreQueries.nextQueued`)(function*(t){let r=(yield*n(t))[0];return r===void 0?T():yi((yield*HU(yield*e.select(ZW).from(qF).innerJoin(Z,Y(Z.eventId,qF.eventId)).leftJoin(Q,Y(Q.eventId,qF.eventId)).leftJoin(tI,Y(tI.eventId,qF.eventId)).where(aN(Y(Z.loopName,r.loop),Y(Z.itemKey,r.itemKey),yW(e).currentEvent,mN(Q.runId),mN(tI.eventId))).orderBy(ON(qF.receivedAt)).limit(1).execute()))[0]).pipe(Ti(cW))}),oe=N(`RunStoreQueries.recoverable`)(function*(){return yield*GU(yield*e.select({...ZW,runId:Q.runId,state:Q.stateJson}).from(Q).innerJoin(qF,Y(qF.eventId,Q.eventId)).innerJoin(Z,Y(Z.eventId,qF.eventId)).where(tG).execute())}),se=N(`RunStoreQueries.pendingWorkflowCommands`)(function*(){let t=yield*JU(yield*e.select({runId:nI.runId,command:nI.command}).from(nI).execute()),n=e=>KF.indexOf(e);return[...t].sort((e,t)=>e.runId===t.runId?n(e.command)-n(t.command):e.runId<t.runId?-1:1)}),ce=N(`RunStoreQueries.completeWorkflowCommand`)(function*(t,n){yield*e.delete(nI).where(aN(Y(nI.runId,t),Y(nI.command,n))).execute()}),le=N(`RunStoreQueries.revokeUnstarted`)(function*(t,n){let r=yield*KU(yield*e.select({runId:Q.runId}).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).where(aN(Y(Z.loopName,t),Y(Z.itemKey,n),nG)).execute()),i=FF(Z,`candidate`),a=FF(Q,`candidate_run`);return yield*e.insert(tI).select(e.select({eventId:i.eventId,reason:J`'revoked'`.as(`reason`)}).from(i).leftJoin(a,Y(a.eventId,i.eventId)).where(aN(Y(i.loopName,t),Y(i.itemKey,n),mN(a.runId)))).onConflictDoNothing().execute(),r});return{cycles:yW(e),...YW(e),addAttempt:d,amend:p,markIntervened:m,approvalExists:_,blockingRun:re,closeAttempt:f,completeWorkflowCommand:ce,createRun:ee,eventRouteByRun:n,workflowCommandsFor:x,ignoredEvent:ne,nextQueued:ae,pendingWorkflowCommands:se,recordTriggerEvent:ie,recoverable:oe,recordApproval:v,requestInterrupt:b,requestWorkflowCommand:y,revision:l,revokeUnstarted:le,runSummaries:c,itemRunSummaries:s,runForEvent:te,snapshot:a,updateStepResult:g,updateAttemptParentModel:h,updateState:u}},aG=kE.make(3),oG=e=>yi(e.attempts.at(-1)).pipe(Ai(e=>hi(e.outcome))),sG=(e,t,n,r)=>{let i=new TE({failure:n});return r===`Execution`&&ME({failure:n,number:t.number,maxAutoAttempts:aG})?{_tag:`RetryAttempt`,attempt:t,outcome:i}:{_tag:`RunFailed`,attempt:t,outcome:i,state:AT(e)}},cG=(e,t,n,r)=>{if(e.run.state._tag!==`Running`)return{_tag:`Unchanged`,reason:`RunNotRunning`};let i=oG(e);return hi(i)?{_tag:`Unchanged`,reason:`NoOpenAttempt`}:i.value.id===t?Li(n)?sG(e.run.state,i.value,n.failure,r):{_tag:`RunSucceeded`,attempt:i.value,outcome:new wE,state:kT(e.run.state),result:n.success}:{_tag:`Unchanged`,reason:`AttemptReplaced`}},lG=(e,t,n)=>cG(e,t,n,`Execution`),uG=(e,t)=>{let n=oG(e);return hi(n)?{_tag:`Unchanged`,reason:`NoOpenAttempt`}:cG(e,n.value.id,t,`FinalReconciliation`)},dG=(e,t)=>{let n=e.run.state;if(!xT(n)&&n._tag!==`Running`)return{_tag:`RunClosed`,state:n};let r=T(),i=oG(e);if(n._tag===`Running`&&D(i)){let e=sG(n,i.value,t,`Execution`);if(e._tag===`RunFailed`)return e;r=E(e)}return{_tag:`StartAttempt`,state:n._tag===`Running`?n:OT(n),number:kE.make((e.attempts.at(-1)?.number??0)+1),interrupted:r}},fG=e=>yT(e.run.state)?{_tag:`Canceled`,state:MT(e.run.state),attempt:e.run.state._tag===`Running`?Ti(oG(e),e=>({id:e.id,outcome:new EE})):T()}:{_tag:`AlreadyClosed`},pG=(e,t)=>e._tag===`Failed`?{_tag:`Resume`,state:jT(e)}:e._tag===`Running`&&t.includes(`Resume`)?{_tag:`ResumePending`}:{_tag:`RetryRejected`},mG=(e,t)=>{if(hi(e))return{_tag:`OpenRun`};let n=e.value;return n.state._tag===`Running`?{_tag:`QueueEvent`}:bT(n.state)?{_tag:`SupersedeRun`,runId:n.id,state:NT(n.state,t)}:{_tag:`OpenRun`}},hG=class extends H(`@usine/engine/internal/StoredSubmission`)({submission:IF,runId:FT}){},gG=class extends H(`@usine/engine/internal/RecoverableRun`)({submission:IF,runId:FT,state:gT}){},_G=class extends H(`@usine/engine/internal/Claim`)({submission:IF,result:UF,supersededRun:$S(FT)}){},vG=class extends U(`@usine/engine/internal/AttemptStarted`)(`AttemptStarted`,{execution:qW}){},yG=class extends U(`@usine/engine/internal/AttemptRecoveryFailed`)(`AttemptRecoveryFailed`,{failure:vE}){},bG=class extends U(`@usine/engine/internal/RunClosed`)(`RunClosed`,{state:F}){},xG=A(function*(){let e=yield*uP,t=iG(e),n=(e,t,n=T())=>new _G({submission:e,result:new LF({eventId:e.event.id,runId:t}),supersededRun:n}),r=N(`RunStore.openRun`)(function*(e,t,r,i=T()){let a=yield*e.cycles.admit(t);return D(a)?new _G({submission:t,supersededRun:i,result:new HF({eventId:t.event.id,ask:a.value})}):(yield*e.createRun(t,t.event.id,r),yield*e.cycles.reserve(t,r),n(t,r,i))}),i=N(`RunStore.recordAndClaim`)(function*(t,i){return yield*Gh({eventId:t.event.id,runId:i,loop:t.loop,itemKey:t.itemKey}),yield*e.transaction(e=>A(function*(){let a=iG(e),o=yield*a.recordTriggerEvent(t),s=yield*a.runForEvent(o.event.id);if(s[0]!==void 0)return yield*ng(`Event joined its existing Run`,{eventId:o.event.id,runId:s[0].runId}),n(o,s[0].runId);let c=yield*a.ignoredEvent(o.event.id);if(c[0]!==void 0)return yield*ng(`Event remains ignored`,{eventId:o.event.id,reason:c[0].reason}),new _G({submission:o,result:new VF({eventId:o.event.id,reason:c[0].reason}),supersededRun:T()});if(!(yield*a.cycles.isCurrentEvent(o)))return new _G({submission:o,supersededRun:T(),result:new VF({eventId:o.event.id,reason:`superseded`})});let l=(yield*a.blockingRun(o.loop,o.itemKey))[0],u=mG(l===void 0?T():E((yield*a.snapshot(l.runId)).run),o.event.id);switch(yield*ng(`Event claim decided`,{eventId:o.event.id,decision:u._tag}),u._tag){case`QueueEvent`:return new _G({submission:o,result:new RF({eventId:o.event.id}),supersededRun:T()});case`SupersedeRun`:return yield*a.updateState(u.runId,u.state),yield*a.requestInterrupt(u.runId),yield*r(a,o,i,E(u.runId));case`OpenRun`:return yield*r(a,o,i)}}))},oW(`submit Event`)),a=N(`RunStore.parkForApproval`)(function*(t){yield*e.transaction(e=>A(function*(){let n=iG(e),r=yield*n.snapshot(t);r.run.state._tag===`Pending`&&(yield*n.updateState(t,ET(r.run.state)))}))},oW(`park run for approval`)),o=N(`RunStore.applyFinish`)(function*(e,t,n){if(yield*Gh({runId:t}),n._tag===`Unchanged`){yield*ng(`Attempt completion ignored`,{runId:t,reason:n.reason});return}let{attempt:r,outcome:i}=n;yield*Gh({attemptId:r.id});let a={runId:t,attemptId:r.id,number:r.number,decision:n._tag};yield*ng(`Attempt completion decided`,Mw(i,{Failed:({failure:e})=>({...a,failure:e._tag}),Succeeded:()=>a})),yield*e.closeAttempt(r.id,i),n._tag!==`RetryAttempt`&&(n._tag===`RunSucceeded`&&(yield*e.updateStepResult(t,r.stepName,n.result)),yield*e.updateState(t,n.state),yield*e.requestWorkflowCommand(t,`Continue`))}),s=N(`RunStore.beginAttempt`)(function*(t,n){return yield*Gh({runId:t}),yield*e.transaction(e=>A(function*(){let r=iG(e),i=yield*r.snapshot(t),a=new vE({message:`The orchestrator stopped during the attempt`,cause:Error(`attempt interrupted by orchestrator restart`)}),s=dG(i,a);if(s._tag===`RunClosed`)return yield*ng(`Attempt start skipped`,{runId:t,state:s.state._tag}),new bG({state:s.state._tag});if(s._tag===`RunFailed`)return yield*o(r,t,s),new yG({failure:a});D(s.interrupted)&&(yield*o(r,t,s.interrupted.value)),i.run.state._tag!==s.state._tag&&(yield*r.updateState(t,s.state));let c=OE.make(`${t}/${i.step.name}/${s.number}`),l=yield*c_,u=new jE({id:c,runId:t,stepName:i.step.name,worker:n,number:s.number,brain:i.agent.brain,task:i.task,agent:i.agent.name,operatorIntervened:!1,parentModel:i.parentModel,startedAt:l,outcome:T()});return yield*r.addAttempt(u),yield*ng(`Attempt started`,{runId:t,attemptId:c,number:s.number,worker:n}),new vG({execution:new qW({attempt:u,event:i.event,run:new IT({id:i.run.id,eventId:i.run.eventId,loop:i.run.loop,state:s.state,openedAt:i.run.openedAt}),step:i.step,repository:i.repository,revision:i.revision,task:i.task,agent:i.agent,parentModel:i.parentModel})})}))},oW(`begin attempt`)),c=N(`RunStore.finishAttempt`)(function*(t,n){return yield*Gh({runId:t.runId,attemptId:t.id}),yield*e.transaction(e=>A(function*(){let r=iG(e),i=lG(yield*r.snapshot(t.runId),t.id,n);return yield*o(r,t.runId,i),i}))},oW(`finish attempt`)),l=N(`RunStore.approve`)(function*(t,n){yield*e.transaction(e=>A(function*(){let r=iG(e);if(yield*r.approvalExists(t))return;let i=yield*r.snapshot(t);if(i.run.state._tag!==`Waiting`)return yield*new cI({runId:t,operation:`approve`,state:i.run.state._tag});yield*r.recordApproval(t,n),yield*r.updateState(t,DT(i.run.state)),yield*r.requestWorkflowCommand(t,`Approve`)}))},oW(`approve run`)),u=N(`RunStore.retry`)(function*(t,n=T()){yield*Gh({runId:t}),yield*e.transaction(e=>A(function*(){let r=iG(e),i=yield*r.snapshot(t),a=pG(i.run.state,yield*r.workflowCommandsFor(t));if(yield*ng(`Operator retry decided`,{runId:t,state:i.run.state._tag,decision:a._tag}),a._tag===`Resume`){D(n)&&(yield*r.amend(t,n.value),yield*ng(`Run effective task and Agent amended`,{runId:t,agent:n.value.agent.name})),yield*r.updateState(t,a.state),yield*r.requestWorkflowCommand(t,`Resume`);return}if(!(a._tag===`ResumePending`&&hi(n)))return yield*new cI({runId:t,operation:`retry`,state:i.run.state._tag})}))},oW(`retry run`)),d=N(`RunStore.cancel`)(function*(t){return yield*Gh({runId:t}),yield*e.transaction(e=>A(function*(){let n=iG(e),r=yield*n.snapshot(t),i=fG(r);return yield*ng(`Operator cancellation decided`,{runId:t,state:r.run.state._tag,decision:i._tag}),i._tag===`AlreadyClosed`?i:(D(i.attempt)&&(yield*n.closeAttempt(i.attempt.value.id,i.attempt.value.outcome)),yield*n.updateState(t,i.state),yield*n.requestInterrupt(t),yield*n.requestWorkflowCommand(t,`Continue`),{_tag:`Canceled`,openAttempt:Ti(i.attempt,({id:e})=>e)})}))},oW(`cancel run`)),f=N(`RunStore.revoke`)(function*(t,n){return yield*e.transaction(e=>A(function*(){let r=iG(e),i=yield*r.revokeUnstarted(t,n);for(let e of i){let t=yield*r.snapshot(e.runId);bT(t.run.state)&&(yield*r.updateState(e.runId,PT(t.run.state)),yield*r.requestInterrupt(e.runId))}return i.map(e=>e.runId)}))},oW(`revoke run`)),p=N(`RunStore.claimQueued`)(function*(t,n){return yield*e.transaction(e=>A(function*(){let i=iG(e),a=yield*i.runForEvent(t.event.id);return a[0]===void 0?(yield*i.ignoredEvent(t.event.id)).length>0||(yield*i.blockingRun(t.loop,t.itemKey)).length>0||!(yield*i.cycles.isCurrentEvent(t))?T():(yield*r(i,t,n)).result._tag===`Claimed`?E(new hG({submission:t,runId:n})):T():E(new hG({submission:t,runId:a[0].runId}))}))},oW(`claim queued Event`)),m=N(`RunStore.recoverable`)(function*(){return(yield*t.recoverable()).map(e=>new gG({submission:cW(e),runId:e.runId,state:e.state}))},oW(`list recoverable runs`)),h=N(`RunStore.appendTranscript`)(function*(t,n){let r=yield*c_;yield*e.transaction(e=>A(function*(){let i=iG(e);t===`outbound`&&n.payload._tag===`Started`&&(yield*i.updateAttemptParentModel(n.attemptId,n.payload.parentModel)),t===`outbound`&&n.payload._tag===`InterventionApplied`&&(yield*i.markIntervened(n.attemptId)),yield*i.appendTranscript(t,n,r)}))},oW(`append Attempt transcript`)),g=N(`RunStore.transcript`)(function*(e){return yield*t.transcript(e)},oW(`read Attempt transcript`)),_=N(`RunStore.reconcileCompletion`)(function*(t,n){if(yield*Gh({runId:t}),n._tag!==`Complete`){yield*rg(`Workflow reconciliation skipped`,{runId:t,reason:`Suspended`});return}yield*e.transaction(e=>A(function*(){let r=iG(e),i=yield*r.snapshot(t),a=ff(n.exit)?E(Mi(n.exit.value)):Ti(ef(n.exit.cause),Ni);if(hi(a)){yield*ng(`Workflow reconciliation skipped`,{runId:t,reason:`NoTypedOutcome`});return}yield*o(r,t,uG(i,a.value))}))},oW(`reconcile workflow completion`));return{approve:l,appendTranscript:h,beginAttempt:s,cancel:d,claimQueued:p,completeWorkflowCommand:(e,n)=>t.completeWorkflowCommand(e,n).pipe(oW(`complete workflow command`)),finishAttempt:c,nextQueued:e=>t.nextQueued(e).pipe(oW(`find queued Event`)),parkForApproval:a,pendingWorkflowCommands:t.pendingWorkflowCommands().pipe(oW(`list pending workflow commands`)),recordAndClaim:i,reconcileCompletion:_,recoverable:m(),retry:u,revoke:f,snapshot:e=>t.snapshot(e).pipe(oW(`read run`)),transcript:g}}),SG=class e extends O()(`@usine/engine/internal/RunStore`){static layer=Gf(e,xG)},CG=class extends O()(`@usine/engine/RunEngineShutdown`){},wG=class e extends O()(`@usine/engine/AttemptAdmission`){static layer=Gf(e,A(function*(){let e=yield*Nh(CG),t=D(e)?e.value:yield*hf(),n=yield*Fw(new Set),r=yield*hf(),i=N(`AttemptAdmission.enter`)(function*(e){yield*Gh({runId:e});let r=yield*Rw(n,n=>yf(t)?[!1,n]:[!0,new Set([...n,e])]);return r||(yield*ng(`Attempt deferred until restart; the engine is draining`,{runId:e})),r}),a=N(`AttemptAdmission.leave`)(function*(e){yield*Gh({runId:e});let i=yield*Bw(n,t=>new Set([...t].filter(t=>t!==e)));(yield*vf(t))&&(yield*ng(`Attempt settled during drain`,{runId:e,remainingRunIds:[...i]}),i.size===0&&(yield*bf(r,void 0)))});return{withAttempt:N(`AttemptAdmission.withAttempt`)(function*(e,t){return yield*Gh({runId:e}),yield*Ih(i(e),e=>e?t:ih,t=>t?a(e):nh)}),drain:N(`AttemptAdmission.drain`)(function*(){yield*bf(t,void 0);let e=yield*Iw(n);yield*ng(`Engine drain started; no further Attempts will be admitted`,{activeRunIds:[...e]}),e.size===0&&(yield*bf(r,void 0)),yield*gf(r),yield*ng(`Engine drain completed; all admitted Attempts settled`)})}}))},TG=DW(`@usine/engine/DurableRun`,{payload:I({submission:IF}),success:qT,error:SE,idempotencyKey:({submission:e})=>e.event.dedupKey}).annotate(FW,!0),EG=LW(`@usine/engine/ApprovalGate`),DG=e=>bh(e,{EnginePersistenceError:e=>new vE({message:`Engine persistence failed during ${e.operation}`,cause:e}),RunNotFoundError:e=>sh(e),RunOperationRejectedError:e=>sh(e)}),OG=e=>TG.executionId({submission:e}),kG=N(`DurableRun.continueWithNewest`)(function*(e,t){let n=yield*e.nextQueued(t);if(D(n)){let t=yield*OG(n.value),r=FT.make(t),i=yield*e.claimQueued(n.value,r);D(i)&&(yield*TG.execute({submission:i.value.submission},{discard:!0}))}yield*e.completeWorkflowCommand(t,`Continue`)}),AG=N(`DurableRun.attempt`)(function*(e,t){yield*Gh({runId:e,worker:t});let n=yield*SG,r=yield*JW,i=yield*n.beginAttempt(e,t).pipe(DG);if(i instanceof yG||i._tag===`RunClosed`)return i;let a=yield*r.execute(i.execution,{append:(e,t)=>n.appendTranscript(e,t).pipe(DG)}).pipe(Sh(t=>tg(`Step executor defect; operator intervention required`,{runId:e}).pipe(fh(new yE({message:`The step executor crashed outside its typed failure channel`,cause:t})))),mh);return{_tag:`AttemptExecuted`,result:a,decision:yield*n.finishAttempt(i.execution.attempt,a).pipe(DG)}}),jG=N(`DurableRun.execute`)(function*({submission:e},t){let n=FT.make(t),r=yield*SG,i=yield*JW,a=yield*wG;for(e.approval===`required`&&(yield*r.parkForApproval(n).pipe(DG),yield*VW(EG));;){let t=yield*Uh(t=>t(i.reserve(e)).pipe(M(e=>t(a.withAttempt(n,AG(n,e.worker))).pipe(Lh(e.release)))));if(t._tag===`RunClosed`)return yield*ng(`Run closed while it waited for a worker`,{runId:n,state:t.state}),yield*kG(r,n).pipe(DG),yield*new bE({message:`The run closed (${t.state}) before an attempt started`});if(t instanceof yG)return yield*kG(r,n).pipe(DG),yield*t.failure;let{result:o,decision:s}=t;if(s._tag!==`RetryAttempt`)return yield*kG(r,n).pipe(DG),Ri(o)?o.success:yield*o.failure}});TG.toLayer(jG);var MG=N(`DurableRun.runIdFor`)(function*(e){return FT.make(yield*OG(e))}),NG=class extends H(`@usine/engine/LoopRuntimeState`)({loop:tT,paused:hS}){},PG=e=>t=>t.pipe(Ch(t=>new lI({operation:e,cause:t}))),FG=A(function*(){let e=yield*uP,t=N(`LoopControl.stateFor`)(function*(t){yield*Gh({loop:t});let n=(yield*e.select({loop:aI.loopName,paused:aI.paused}).from(aI).where(Y(aI.loopName,t)).limit(1).execute())[0];return n===void 0?new NG({loop:t,paused:!1}):new NG(n)},PG(`read Loop runtime state`)),n=N(`LoopControl.states`)(function*(){return(yield*e.select({loop:aI.loopName,paused:aI.paused}).from(aI).orderBy(DN(aI.loopName)).execute()).map(e=>new NG(e))},PG(`list Loop runtime states`)),r=N(`LoopControl.write`)(function*(n){yield*Gh({loop:n.loop});let r=yield*t(n.loop);return r.paused===n.paused?(yield*rg(`Loop runtime state was already set`,{loop:n.loop,paused:n.paused}),r):(yield*e.insert(aI).values({loopName:n.loop,paused:n.paused}).onConflictDoUpdate({target:aI.loopName,set:{paused:n.paused}}).execute().pipe(PG(`write Loop runtime state`)),yield*ng(n.paused?`Loop paused`:`Loop unpaused`,{loop:n.loop,paused:n.paused}),n)});return{isPaused:N(`LoopControl.isPaused`)(function*(e){return(yield*t(e)).paused}),pause:N(`LoopControl.pause`)(e=>r(new NG({loop:e,paused:!0}))),states:n(),unpause:N(`LoopControl.unpause`)(e=>r(new NG({loop:e,paused:!1})))}}),IG=class e extends O()(`@usine/engine/LoopControl`){static layer=Gf(e,FG)},LG=500;A(function*(){let e=yield*SG,t=yield*wG,n=yield*JW,r=yield*KW,i=e=>Fh(e,KW,r),a=N(`RunEngine.launch`)(function*(e){yield*TG.execute({submission:e},{discard:!0}).pipe(i)}),o=N(`RunEngine.deliverInterrupt`)(function*(t){yield*TG.interrupt(t).pipe(i),yield*e.completeWorkflowCommand(t,`Interrupt`)}),s=N(`RunEngine.deliverApproval`)(function*(t){yield*GW(EG,{token:UW(EG,{workflow:TG,executionId:t}),value:void 0}).pipe(i),yield*e.completeWorkflowCommand(t,`Approve`)}),c=N(`RunEngine.deliverContinuation`)(function*(t){yield*kG(e,t).pipe(i)}),l=N(`RunEngine.awaitWorkflowSettlement`)(function*(e){for(let t=0;t<LG;t+=1){let t=yield*TG.poll(e).pipe(i);if(D(t))return t.value;yield*Eh(`10 millis`)}return yield*sh(Error(`Run ${e} has no durable workflow execution to settle`))}),u=N(`RunEngine.deliverResume`)(function*(t){let n=yield*l(t);if(n._tag===`Complete`){yield*e.reconcileCompletion(t,n),yield*e.completeWorkflowCommand(t,`Resume`),yield*c(t);return}yield*TG.resume(t).pipe(i),yield*e.completeWorkflowCommand(t,`Resume`)}),d={Approve:s,Continue:c,Interrupt:o,Resume:u},f=N(`RunEngine.submit`)(function*(t){let n=yield*MG(t),r=yield*e.recordAndClaim(t,n);return D(r.supersededRun)&&(yield*o(r.supersededRun.value)),r.result._tag===`Claimed`&&(yield*a(r.submission)),r.result}),p=N(`RunEngine.approve`)(function*(t,n){yield*e.approve(t,n),yield*s(t)}),m=N(`RunEngine.retry`)(function*(t,n=T()){yield*e.retry(t,n),yield*u(t)}),h=N(`RunEngine.cancel`)(function*(t){let r=yield*e.cancel(t);if(r._tag===`AlreadyClosed`){yield*rg(`Cancel was a no-op; the run was already closed`,{runId:t});return}yield*ng(`Run canceled`,{runId:t,openAttempt:_i(r.openAttempt,()=>`none`)});let i=D(r.openAttempt)?yield*n.interrupt(r.openAttempt.value).pipe(mh):Mi(void 0);if(yield*o(t),yield*c(t),D(r.openAttempt)&&Li(i))return yield*new uI({attemptId:r.openAttempt.value,cause:i.failure})}),g=N(`RunEngine.intervene`)(function*(t,r,i){yield*Gh({runId:t,attemptId:r,action:i.action._tag});let a=yield*e.snapshot(t),o=a.attempts.at(-1);if(a.run.state._tag!==`Running`||o?.id!==r||D(o.outcome))return yield*ng(`Operator input rejected for an inactive Attempt`,{runId:t,attemptId:r}),yield*new fI({runId:t,attemptId:r,message:`This Attempt is no longer running`});yield*n.intervene(r,i).pipe(Ch(e=>new fI({runId:t,attemptId:r,message:e._tag===`RunawayFailure`?`The Attempt reached its runaway limit`:e._tag===`ChildSessionBudgetFailure`?`The Attempt reached its child-session budget`:e.message})),Th(e=>eg(`Operator input delivery failed`,{runId:t,attemptId:r,message:e.message})))}),_=N(`RunEngine.revoke`)(function*(t,n){let r=yield*e.revoke(t,n);return yield*Xm(r,o,{concurrency:`unbounded`,discard:!0}),r}),v=N(`RunEngine.inspect`)(function*(t){return yield*e.snapshot(t)}),y=N(`RunEngine.transcript`)(function*(t){return yield*e.transcript(t)}),b=N(`RunEngine.reconcile`)(function*(){yield*Xm(yield*e.pendingWorkflowCommands,({command:e,runId:t})=>d[e](t),{discard:!0}),yield*Xm(yield*e.recoverable,({runId:t,state:n,submission:r})=>A(function*(){let o=yield*TG.poll(t).pipe(i);if(D(o)&&o.value._tag===`Complete`){yield*e.reconcileCompletion(t,o.value),yield*c(t);return}if(D(o)&&o.value._tag===`Suspended`){n._tag===`Running`&&(yield*u(t));return}yield*a(r)}),{concurrency:`unbounded`,discard:!0})});return yield*b(),{approve:p,cancel:h,drain:t.drain,inspect:v,intervene:g,reconcile:b,retry:m,revoke:_,submit:f,transcript:y}});var RG=class extends O()(`@usine/engine/RunEngine`){},zG=Jw.make(`HEAD`),BG=class extends zC(`@usine/orchestrator/LoopAgentResolutionError`)(`LoopAgentResolutionError`,{loop:tT,agent:HT,message:V}){},VG=N(`TriggerRouting.resolveLoop`)(function*(e,t){yield*Gh({loop:t.name,agent:t.agent});let n=new Map(e.agents.map(e=>[e.name,e])).get(t.agent);if(n===void 0)return yield*new BG({loop:t.name,agent:t.agent,message:`Loop ${t.name} references missing Agent ${t.agent}`});let r=n.agent;return{agent:r,loop:t,parentModel:GT(r,e.config.settings.parentModel)}});N(`TriggerRouting.resolveLoops`)(function*(e){let t=[];for(let n of e.loops){let r=yield*mh(VG(e,n));if(Ri(r)){t.push(r.success);continue}yield*tg(`Loaded loop lost its rostered Agent; skipping the loop`,{loop:r.failure.loop,agent:r.failure.agent,errorTag:r.failure._tag,message:r.failure.message})}return t});var HG=e=>new IF({event:new eT({id:Qw.make(e.dedupKey),dedupKey:e.dedupKey,payload:e.payload,receivedAt:e.receivedAt}),itemKey:e.itemKey,cycleGeneration:e.cycleGeneration,loop:e.loop.name,step:e.loop.step,approval:e.loop.approval,cycleLimit:e.loop.trigger.on===`schedule`?T():E(e.loop.maxCycles),repository:e.repository.name,revision:e.revision,task:e.task,agent:e.agent,parentModel:e.parentModel}),UG=e=>Mw(e,{Claimed:({runId:e})=>({runId:e}),Queued:()=>({}),Ignored:({reason:e})=>({reason:e}),CycleBlocked:({ask:e})=>({askId:e.id,reason:`cycle-budget-exhausted`})}),WG=e=>gi(e.expression,{onNone:()=>({configFile:e.file,configStage:e.stage}),onSome:t=>({configFile:e.file,configStage:e.stage,expression:t})}),GG=class extends H(`@usine/orchestrator/RepositoryPollFailure`)({repository:qw,errorTag:V,message:F}){};H(`@usine/orchestrator/PollCycle`)({repositories:JS.check(GS(0)),changedItems:JS.check(GS(0)),submissions:L(UF),revokedRuns:JS.check(GS(0)),failures:L(GG),preflightFindings:L(VL),nextPollAt:$S(kC)});var KG=e=>{let t={errorTag:e._tag,message:e.message};return e._tag===`ConfigFileError`?{...t,...WG(e)}:e._tag===`ExpressionCheckError`||e._tag===`ExpressionEvaluationError`?{...t,expression:e.source}:t},qG=e=>{let t=e.flatMap(e=>gi(e,{onNone:()=>[],onSome:e=>[p_(e)]}));return t.length===0?T():s_(Math.max(...t))},JG=4,YG=6e4,XG=e=>{let t={errorTag:e._tag,message:e.message};return e._tag===`ConfigFileError`?{...t,...WG(e)}:e._tag===`ExpressionCheckError`||e._tag===`ExpressionEvaluationError`?{...t,expression:e.source}:t},ZG=class extends U(`@usine/orchestrator/ScheduleAgentFailure`)(`ScheduleAgentFailure`,{loop:tT,agent:HT,message:F}){},QG=class extends U(`@usine/orchestrator/ScheduleTickFailure`)(`ScheduleTickFailure`,{loop:tT,repository:qw,scheduledAt:kC,errorTag:V,message:F}){},$G=class extends U(`@usine/orchestrator/ScheduleCronFailure`)(`ScheduleCronFailure`,{loop:tT,cron:F,tz:F,message:F}){},eK=R([ZG,$G,QG]),tK=class extends H(`@usine/orchestrator/ScheduleCycle`)({loops:JS.check(GS(0)),fanout:JS.check(GS(0)),submissions:L(UF),skipped:JS.check(GS(0)),alreadyFired:JS.check(GS(0)),failures:L(eK),nextTickAt:$S(kC)}){},nK=e=>e.loops.flatMap(t=>{let n=t.trigger;return n.on===`schedule`?[{loop:t,repositories:e.config.repos.filter(e=>OR(t.selector,e)),trigger:n}]:[]}),rK=(e,t)=>{let n=f_(t);return n.setUTCSeconds(0,0),a_(xm(e,n)?n:wm(e,n))},iK=(e,t)=>a_(Cm(e,f_(t))),aK=(e,t)=>gi(d_(e,t),{onNone:()=>m_(e),onSome:h_}),oK=e=>e.length===0?T():s_(Math.min(...e.map(p_))),sK=e=>NE.make(JSON.stringify([`github`,Zw(e.name)])),cK=(e,t,n)=>$w.make(JSON.stringify([e.name,Zw(t.name),m_(n)])),lK=e=>({tick:{scheduledAt:m_(e.scheduledAt),scheduledAtLocal:e.scheduledAtLocal,cron:e.trigger.cron,tz:e.trigger.tz}});(class e extends O()(`@usine/orchestrator/ScheduleTriggers`){static layer=Gf(e,A(function*(){let e=yield*kU,t=yield*nR,n=yield*RG,r=yield*IG,i=yield*Fw(T()),a=yield*Fw(new Map),o=new WeakMap,s=e=>{let t=o.get(e);if(t!==void 0)return t;let n=bm(e.cron,e.tz);return o.set(e,n),n},c=N(`ScheduleTriggers.submitTick`)(function*(r,i){yield*Gh({loop:r.loop.name,repository:r.repository.name,agent:r.agent.name,scheduledAt:m_(r.scheduledAt)});let a=lK(r),o={repo:Sz(r.repository),item:a};if(!(yield*t.evaluateBoolean(r.trigger.if,xz(`schedule`),o)))return yield*rg(`Scheduled Tick did not match its expression`,{loop:r.loop.name,repository:r.repository.name,agent:r.agent.name,scheduledAt:m_(r.scheduledAt)}),T();let s=cK(r.loop,r.repository,r.scheduledAt),c=yield*e.renderPrompt(r.loop,o),l=yield*n.submit(HG({cycleGeneration:IE.make(0),agent:r.agent,dedupKey:s,itemKey:sK(r.repository),loop:r.loop,payload:a,receivedAt:i,repository:r.repository,revision:zG,task:AE.make(c),parentModel:r.parentModel}));return yield*ng(`Submitted scheduled Tick`,{loop:r.loop.name,repository:r.repository.name,agent:r.agent.name,scheduledAt:m_(r.scheduledAt),scheduledAtLocal:r.scheduledAtLocal,result:l._tag,...UG(l)}),E(l)}),l=N(`ScheduleTriggers.tick`)(function*(e){let t=yield*c_,n=new Set((yield*r.states).filter(e=>e.paused).map(e=>e.loop));for(let t of e.loops)t.trigger.on===`schedule`&&n.has(t.name)&&(yield*rg(`Paused Loop skipped during schedule evaluation`,{loop:t.name}));let o=nK(e).filter(({loop:e})=>!n.has(e.name)),l=yield*Iw(a),u=[],d=[],f=[],p=new Map,m=[],h=0;for(let n of o){n.repositories.length===0&&(yield*eg(`Schedule loop selected no repositories`,{loop:n.loop.name}));let r=yield*ch({try:()=>{let e=s(n.trigger),r=rK(e,t);return{latest:r,latestLocal:aK(r,n.trigger.tz),next:iK(e,t)}},catch:e=>e}).pipe(mh);if(Li(r)){yield*tg(`Schedule cron boundaries could not be computed`,{loop:n.loop.name,cron:n.trigger.cron,tz:n.trigger.tz,message:String(r.failure)}),f.push(new $G({loop:n.loop.name,cron:n.trigger.cron,tz:n.trigger.tz,message:String(r.failure)}));continue}let i=r.success;m.push(i.next);let a=p_(i.latest),o=l.get(n.loop.name);if(o!==void 0&&o>=a){h+=1,yield*rg(`Tick already fired`,{loop:n.loop.name,scheduledAt:m_(i.latest)});continue}let c=yield*mh(VG(e,n.loop));if(Li(c)){let e=c.failure;yield*tg(`Schedule loop could not resolve its Agent`,{loop:e.loop,agent:e.agent,errorTag:e._tag,message:e.message}),d.push(new ZG({loop:e.loop,agent:e.agent,message:e.message}));continue}if(n.repositories.length!==0){p.set(n.loop.name,a),yield*ng(`Schedule tick due`,{loop:n.loop.name,agent:c.success.agent.name,cron:n.trigger.cron,tz:n.trigger.tz,scheduledAt:m_(i.latest),scheduledAtLocal:i.latestLocal,repositories:n.repositories.length,nextTickAt:m_(i.next)});for(let e of n.repositories)u.push({agent:c.success.agent,loop:n.loop,parentModel:c.success.parentModel,repository:e,scheduledAt:i.latest,scheduledAtLocal:i.latestLocal,trigger:n.trigger})}}yield*Gh({schedules:o.length,fanout:u.length});let g=yield*Xm(u,e=>mh(c(e,t)).pipe(gh(t=>({candidate:e,result:t}))),{concurrency:JG}),_=[],v=[],y=new Set,b=new Set,x=0;for(let{candidate:e,result:t}of g){if(Ri(t)){D(t.success)?(_.push(t.success.value),y.add(e.loop.name)):x+=1;continue}let n=t.failure;b.add(e.loop.name),yield*tg(`Scheduled Tick failed; sibling fanout was unaffected`,{loop:e.loop.name,repository:e.repository.name,agent:e.agent.name,scheduledAt:m_(e.scheduledAt),...XG(n)}),v.push(new QG({loop:e.loop.name,repository:e.repository.name,scheduledAt:e.scheduledAt,errorTag:n._tag,message:n.message}))}yield*zw(a,e=>{let t=new Map(e);for(let[e,n]of p)y.has(e)&&!b.has(e)&&t.set(e,n);return t});let ee=new tK({loops:o.length,fanout:u.length,submissions:_,skipped:x,alreadyFired:h,failures:[...d,...f,...v],nextTickAt:oK(m)});return yield*Lw(i,E(ee)),ee});return{latest:Iw(i),run:e=>A(function*(){let t=yield*mh(l(e));if(Li(t)){yield*tg(`Schedule cycle could not read Loop runtime state; retrying`,{errorTag:t.failure._tag,message:t.failure.message,operation:t.failure.operation,sleepMs:YG}),yield*Eh(zo(YG));return}let n=t.success,r=yield*ep,i=gi(n.nextTickAt,{onNone:()=>r+YG,onSome:p_}),a=Math.min(YG,Math.max(0,i-r)),o={loops:n.loops,fanout:n.fanout,submissions:n.submissions.length,skipped:n.skipped,alreadyFired:n.alreadyFired,failures:n.failures.length,nextTickAt:gi(n.nextTickAt,{onNone:()=>`none`,onSome:m_}),sleepMs:a};n.fanout===0&&n.failures.length===0?yield*rg(`Schedule cycle complete`,o):yield*ng(`Schedule cycle complete`,o),yield*Eh(zo(a))}).pipe(Wh),tick:l}}))});var uK=class extends U(`@usine/orchestrator/ApprovalNeed`)(`ApprovalNeed`,{id:F,repository:qw,runId:FT,loop:tT}){},dK=class extends U(`@usine/orchestrator/RunFailureNeed`)(`RunFailureNeed`,{id:F,repository:qw,runId:FT,loop:tT,failure:nM}){},fK=class extends U(`@usine/orchestrator/PollFailureNeed`)(`PollFailureNeed`,{id:F,failure:GG}){},pK=class extends U(`@usine/orchestrator/PreflightFindingNeed`)(`PreflightFindingNeed`,{id:F,finding:VL}){},mK=class extends U(`@usine/orchestrator/BoardProjectionNeed`)(`BoardProjectionNeed`,{id:F,failure:CM}){},hK=class extends U(`@usine/orchestrator/ScheduleFailureNeed`)(`ScheduleFailureNeed`,{id:F,failure:eK}){},gK=R([class extends U(`CycleBudgetNeed`)(`CycleBudgetNeed`,{id:F,ask:VE,itemLabel:F,itemUrl:DS(F)}){},uK,mK,dK,fK,pK,hK]),_K=ES([`clear`,`active`,`needs-you`]),vK=class extends H(`@usine/orchestrator/ProjectView`)({repository:qw,status:_K,runs:L(hM),board:wM,labels:L(TM),preflightFindings:L(VL)}){},yK=class extends H(`@usine/orchestrator/LoopView`)({name:tT,trigger:F,agent:HT,paused:hS}){},bK=R([class extends U(`@usine/orchestrator/ReadyOverview`)(`Ready`,{projects:L(vK),loops:L(yK),needsYou:L(gK)}){},class extends U(`@usine/orchestrator/NeedsSetupOverview`)(`NeedsSetup`,{errorTag:V,projects:L(vK),loops:L(yK),needsYou:L(gK)}){}]),xK={SchemaError:400,InvalidRequestError:400,CrossSiteRequestError:403,RunNotFoundError:404,TranscriptAttemptNotFoundError:404,BoardProjectNotFoundError:404,BoardItemNotFoundError:404,BoardLaneNotFoundError:404,RunOperationRejectedError:409,RunInterventionRejectedError:409,RosterAgentNotFoundError:404,CycleBudgetResetRejectedError:409,BoardLaneReadOnlyError:409,EnginePersistenceError:500,AttemptCancellationError:500,HttpBodyError:500,GitHubApiError:502,InvalidGitHubResponseError:502,BackendUnavailableError:503,InstallationDiscoveryError:503,AppPermissionError:503,GitHubRateLimitError:503},SK=class extends RC(`@usine/orchestrator/OperatorHttpError`)({error:ES(Ki(xK)),message:F}){get status(){return xK[this.error]}},CK=[...new Set(Object.values(xK))].map(e=>SK.check(RS(t=>t.status===e)).annotate({httpApiStatus:e})),wK=class extends dj()(`@usine/orchestrator/OperatorHttpPolicy`,{error:CK}){},TK=aS(uS),EK=R([F,wS(F).pipe(B(F,H_({decode:e=>e[0],encode:e=>[e]})))]),DK=EK.pipe(B(EC),B(_D)),OK=R([I({after:TK,before:TK,attempt:TK}).pipe(B(sS(cM),H_({decode:()=>new cM,encode:()=>({})}))),I({after:DK,before:TK,attempt:TK}).pipe(B(sS(lM),H_({decode:({after:e})=>new lM({after:e}),encode:({after:e})=>({after:e})}))),I({after:TK,before:DK,attempt:EK.pipe(B(OE))}).pipe(B(sS(uM),H_({decode:({before:e,attempt:t})=>new uM({before:e,attemptId:t}),encode:({before:e,attemptId:t})=>({before:e,attempt:t})})))]),kK=F.check(zS(/^[A-Za-z0-9_.-]+$/u,{message:`Expected a repository path segment`})),AK=I({ok:lS(!0)}),jK={runId:FT},MK={loop:tT},NK=YA(`OperatorApi`).add(Gj(`operator`).add(UA(`overview`,`/api/overview`,{success:bK}),UA(`agents`,`/api/agents`,{success:L(HT)}),WA(`editAndRetry`,`/api/runs/:runId/edit-and-retry`,{params:jK,payload:pM.annotate({parseOptions:{onExcessProperty:`error`}}),success:AK}),WA(`intervene`,`/api/runs/:runId/intervene`,{params:jK,payload:mM.annotate({parseOptions:{onExcessProperty:`error`}}),success:AK}),WA(`resetCycleBudget`,`/api/cycle-budgets/reset`,{payload:I({askId:BE}).annotate({parseOptions:{onExcessProperty:`error`}}),success:AK}),UA(`detail`,`/api/runs/:runId`,{params:jK,query:OK,success:gM}),WA(`approve`,`/api/runs/:runId/approve`,{params:jK,success:AK}),WA(`retry`,`/api/runs/:runId/retry`,{params:jK,success:AK}),WA(`cancel`,`/api/runs/:runId/cancel`,{params:jK,success:AK}),WA(`moveBoardItem`,`/api/projects/:owner/:repository/items/:item/lane`,{params:{owner:kK,repository:kK,item:EC.pipe(B(PE))},payload:I({toLane:_M}).annotate({parseOptions:{onExcessProperty:`error`}}),success:AK}),WA(`pause`,`/api/loops/:loop/pause`,{params:MK,success:AK}),WA(`unpause`,`/api/loops/:loop/unpause`,{params:MK,success:AK})).middleware(wK)),PK=()=>mj(NK,{baseUrl:globalThis.location.origin}),FK=e=>Xh(M(PK(),t=>e(t.operator)).pipe(jh(xI))),IK=a(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-2.5!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border bg-input/20 text-foreground dark:bg-input/30 [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function LK({className:e,variant:t=`default`,render:n,...i}){return LT({defaultTagName:`span`,props:o({className:r(IK({variant:t}),e)},i),render:n,state:{slot:`badge`,variant:t}})}export{mM as $,Ae as $n,rS as $t,uL as A,mh as An,AC as At,JF as B,Ei as Bn,xS as Bt,CL as C,rg as Cn,qw as Ct,fL as D,gh as Dn,L as Dt,cL as E,eg as En,Mw as Et,vI as F,ep as Fn,ES as Ft,ON as G,Ti as Gn,R as Gt,iI as H,_i as Hn,I as Ht,lI as I,Gf as In,V as It,fN as J,E as Jn,Qx as Jt,aN as K,gi as Kn,dS as Kt,YF as L,O as Ln,DS as Lt,sL as M,k as Mn,ew as Mt,nL as N,ch as Nn,tw as Nt,dL as O,Ch as On,hS as Ot,hI as P,qh as Pn,lS as Pt,gM as Q,Pe as Qn,bS as Qt,XF as R,Li as Rn,mS as Rt,kL as S,A as Sn,TT as St,oL as T,ng as Tn,Xw as Tt,Q as U,hi as Un,U as Ut,rI as V,yi as Vn,F as Vt,uP as W,D as Wn,CS as Wt,J as X,Qe as Xn,Kx as Xt,iN as Y,nt as Yn,B as Yt,pM as Z,Re as Zn,Zx as Zt,EL as _,Gh as _n,u as _r,PE as _t,KG as a,ZS as an,_ as ar,tk as at,TL as b,sh as bn,LT as bt,hW as c,oS as cn,ee as cr,WO as ct,WL as d,sS as dn,re as dr,QE as dt,wC as en,ke as er,cM as et,NL as f,C_ as fn,b as fr,eD as ft,IL as g,p_ as gn,d as gr,NE as gt,jL as h,o_ as hn,me as hr,IE as ht,qG as i,GS as in,be as ir,ik as it,hL as j,Zh as jn,JS as jt,mL as k,wh as kn,H as kt,QU as l,aS as ln,x as lr,_D as lt,ML as m,s_ as mn,ge as mr,tD as mt,FK as n,KS as nn,we as nr,lM as nt,yW as o,YS as on,ne as or,BO as ot,FL as p,m_ as pn,oe as pr,iD as pt,Y as q,T as qn,z as qt,GG as r,VS as rn,xe as rr,_k as rt,mW as s,zS as sn,te as sr,VO as st,LK as t,Gx as tn,Te as tr,uM as tt,ZU as u,Wx as un,g as ur,aD as ut,DL as v,_h as vn,AE as vt,iL as w,tg as wn,Zw as wt,AL as x,N as xn,FT as xt,wL as y,yh as yn,HT as yt,qF as z,Oi as zn,eC as zt};
|