@inkeep/impulse-compute 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/impulse-compute.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// openteammate bundle: {"schema":"openteammate.bundle/provenance@1","source":{"repository":"inkeep/openteammate","commit":"
|
|
3
|
-
import{isBuiltin as e}from"node:module";import*as t from"node:os";import n,{constants as r,tmpdir as i}from"node:os";import*as a from"node:path";import o,{basename as s,delimiter as c,dirname as l,isAbsolute as u,join as d,relative as f,resolve as p}from"node:path";import*as m from"node:url";import h,{fileURLToPath as g}from"node:url";import*as _ from"node:crypto";import v,{createHash as y,randomUUID as b}from"node:crypto";import*as ee from"node:child_process";import{execFile as x,spawn as te}from"node:child_process";import*as ne from"node:stream";import re,{PassThrough as ie,finished as ae}from"node:stream";import"node:string_decoder";import*as S from"node:fs";import oe,{accessSync as C,chmodSync as se,closeSync as ce,constants as le,existsSync as ue,mkdirSync as w,mkdtempSync as de,openSync as fe,readFileSync as T,renameSync as pe,rmSync as me,writeFileSync as E}from"node:fs";import*as he from"node:readline";import{link as ge,lstat as _e,mkdir as ve,readFile as ye,rename as be,stat as xe,unlink as Se,writeFile as Ce}from"node:fs/promises";import*as eee from"node:zlib";import{crc32 as tee,inflateSync as nee}from"node:zlib";import*as ree from"node:util";import*as iee from"node:assert";import*as aee from"node:buffer";import we from"node:process";import Te from"node:tty";var oee=Object.create,Ee=Object.defineProperty,see=Object.getOwnPropertyDescriptor,cee=Object.getOwnPropertyNames,lee=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty,Oe=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),uee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=cee(t),a=0,o=i.length,s;a<o;a++)s=i[a],!De.call(e,s)&&s!==n&&Ee(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=see(t,s))||r.enumerable});return e},dee=(e,t,n)=>(n=e==null?{}:oee(lee(e)),uee(t||!e||!e.__esModule||!De.call(e,`default`)?Ee(n,`default`,{value:e,enumerable:!0}):n,e)),ke=`0.2.0`;const Ae=(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}}},fee={pipe(){return Ae(this,arguments)}},je=function(){function e(){}return e.prototype=fee,e}(),D=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)}}}},Me=e=>e,Ne=e=>()=>e,Pe=Ne(!0),pee=Ne(!1),mee=Ne(null),Fe=Ne(void 0),Ie=Fe;function Le(e,...t){return Ae(e,t)}function Re(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 ze(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!==n&&t.set(i,i),i}}const hee=[`line`,`column`,`sourceURL`,`originalLine`,`originalColumn`],Be=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;if(e instanceof Error){t.delete(`stack`);for(let n of hee)Object.prototype.propertyIsEnumerable.call(e,n)||t.delete(n)}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},Ve=new WeakSet,He=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Ue=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,We=e=>{try{return new Uint8Array(e)}catch{return}};let Ge=0;const gee=()=>{Ge++};function Ke(e){return typeof e==`string`}function qe(e){return typeof e==`number`}function Je(e){return typeof e==`boolean`}function _ee(e){return typeof e==`bigint`}function vee(e){return typeof e==`symbol`}function yee(e){return Ke(e)||qe(e)||vee(e)}function Ye(e){return typeof e==`function`}function Xe(e){return e===void 0}function Ze(e){return e!==void 0}function Qe(e){return e!==null}function bee(e){return e==null}function xee(e){return e!=null}function See(e){return!0}function Cee(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $e(e){return typeof e==`object`&&!!e||Ye(e)}const et=D(2,(e,t)=>$e(e)&&t in e),tt=D(2,(e,t)=>et(e,`_tag`)&&e._tag===t);function wee(e){return e instanceof Error}function Tee(e){return et(e,Symbol.iterator)||Ke(e)}const nt=`~effect/Hash`,rt=e=>{switch(typeof e){case`number`:return lt(e);case`bigint`:return ut(e.toString(10));case`string`:return ut(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?ut(`Invalid Date`):ut(e.toISOString());if(e instanceof RegExp)return ut(e.toString());{if(Ve.has(e))return it(e);let t=ht.get(e);if(t!==void 0)return t;if(gt.has(e))return gee(),ut(`[Circular]`);gt.add(e);let n=Ge,r;try{if(Eee(e))r=e[nt]();else if(typeof e==`function`)r=it(e);else if(Ue(e)){let t=We(e);r=t===void 0?it(e):ft(t)}else r=e instanceof DataView?ft(He(e)):Array.isArray(e)||ArrayBuffer.isView(e)?ft(e):e instanceof Map?kee(e):e instanceof Set?Aee(e):Oee(e)}finally{gt.delete(e)}return n===Ge&&ht.set(e,r),r}}return st(at(ut(String(e))))},it=e=>(mt.has(e)||mt.set(e,st(Math.random()*4294967296|0)),mt.get(e)),at=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),ot=D(2,(e,t)=>at(Math.imul(e,2654435761)+Math.imul(t,2246822507))),st=e=>e&3221225471|e>>>1&1073741824,Eee=e=>et(e,`~effect/Hash`)&&typeof e[`~effect/Hash`]==`function`,ct=new DataView(new ArrayBuffer(8)),lt=e=>{let t=e|0;return t===e?st(t):(ct.setFloat64(0,e===e?e:NaN),st(ot(ct.getInt32(0),ct.getInt32(4))))},ut=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return st(t)},Dee=(e,t)=>{let n=12289;for(let r of t)n^=ot(rt(r),rt(e[r]));return st(n)},Oee=e=>Dee(e,Be(e)),dt=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return st(r)},ft=e=>{let t=6151;for(let n of e)t=ot(t,rt(n));return st(t)},kee=dt(ut(`Map`),([e,t])=>ot(rt(e),rt(t))),pt=ut(`Set`),Aee=dt(pt,e=>ot(pt,rt(e))),mt=new WeakMap,ht=new WeakMap,gt=new WeakSet,_t=`~effect/Equal`;function vt(){return arguments.length===1?e=>yt(e,arguments[0]):yt(arguments[0],arguments[1])}function yt(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`||Ve.has(e)||Ve.has(t)?!1:jee(e,t):!1}function jee(e,t){let n=xt.length;for(let r=n;r-->0;)if(xt[r]===e&&St[r]===t)return!0;if(n)return bt(e,t);let r=Ct.get(e);r||Ct.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=bt(e,t)),i}function bt(e,t){xt.push(e),St.push(t);try{return Mee(e,t)}finally{xt.pop(),St.pop()}}const xt=[],St=[],Ct=new WeakMap;function Mee(e,t){if(rt(e)!==rt(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=Et(e);if(n!==Et(t)||typeof e==`function`&&!n)return!1;if(n)return e[_t](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:Nee(e,t);if(Ue(e)){if(!Ue(t)||e instanceof ArrayBuffer!=t instanceof ArrayBuffer)return!1;let n=We(e),r=We(t);return n!==void 0&&r!==void 0&&wt(n,r)}if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?wt(He(e),He(t)):wt(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:Tt(e,t,Fee,Iee):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:Tt(e,t,rt,yt):Pee(e,t)}function Nee(e,t){for(let n=0;n<e.length;n++)if(!yt(e[n],t[n]))return!1;return!0}function wt(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 Pee(e,t){let n=Be(e),r=Be(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!yt(e[i],t[i]))return!1;return!0}function Tt(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop(),a--;continue outer}}return!1}return a===0}const Fee=e=>rt(e[0]),Iee=(e,t)=>yt(e[0],t[0])&&yt(e[1],t[1]),Et=e=>et(e,`~effect/Equal`)&&typeof e[`~effect/Equal`]==`function`,Dt=Symbol.for(`~effect/Redactable`),Lee=e=>et(e,Dt);function Ot(e){return Lee(e)?Ree(e):e}function Ree(e){return e[Dt](globalThis[`~effect/Fiber/currentFiber`]?.context??zee)}const kt=`~effect/Fiber/currentFiber`,At=new Map,zee={"~effect/Context":{},base:At,depth:0,mapUnsafe:At,pipe(){return Ae(this,arguments)}};function jt(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,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(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 Bee;r.add(e);let l;if(Dt in e)l=c(Ree(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
|
+
// openteammate bundle: {"schema":"openteammate.bundle/provenance@1","source":{"repository":"inkeep/openteammate","commit":"ffb8ce2e8087fe79344ef888bc23acc2bde39fc3","path":"scripts/offload","tree":"beb50530b533754a4a23a1bb087390b19a67f3bc","entry":"../../packages/compute/src/main.ts"},"lockfile":{"path":"scripts/offload/pnpm-lock.yaml","sha256":"7af5bf26be1f3ddf53b9b03e8a5d3e3b63c009256f80a72764106322bed7263d"},"sources":[{"path":"packages/compute","tree":"2f279b7543170e176bbc1aa6021a50c867aa9b69","lockfile":{"path":"pnpm-lock.yaml","sha256":"7b82bd3b6f37902ad8e6c59385b2cb438750ef640319bf3a3f8ef591a2cbf518"}},{"path":"scripts/offload","tree":"beb50530b533754a4a23a1bb087390b19a67f3bc","lockfile":{"path":"scripts/offload/pnpm-lock.yaml","sha256":"7af5bf26be1f3ddf53b9b03e8a5d3e3b63c009256f80a72764106322bed7263d"}},{"path":"scripts/linux-desktop","tree":"a248d198d708d7c2703957e21d57596edc82d50d","lockfile":{"path":"scripts/linux-desktop/pnpm-lock.yaml","sha256":"33de8bef2e511ca1dc5a86038349955ac25ffeb880de0285ace6f3b048d2174b"}},{"path":"scripts/ec2-instance","tree":"94bfbbed80a2b9b634423d1a037235bacff3fd64","lockfile":{"path":"scripts/ec2-instance/pnpm-lock.yaml","sha256":"5b49d1967c45f686c0a4497fdc3555d6a57946e28dd2cd6bb476996da72ceaee"}}],"bundler":{"name":"rolldown","version":"1.2.11"},"format":"esm","platform":"node"}
|
|
3
|
+
import{isBuiltin as e}from"node:module";import*as t from"node:os";import n,{constants as r,tmpdir as i}from"node:os";import*as a from"node:path";import o,{basename as s,delimiter as c,dirname as l,isAbsolute as u,join as d,relative as f,resolve as p}from"node:path";import*as m from"node:url";import h,{fileURLToPath as g}from"node:url";import*as _ from"node:crypto";import v,{createHash as y,randomUUID as b}from"node:crypto";import*as ee from"node:child_process";import{execFile as x,spawn as te}from"node:child_process";import*as ne from"node:stream";import re,{PassThrough as ie,finished as ae}from"node:stream";import"node:string_decoder";import*as S from"node:fs";import oe,{accessSync as C,chmodSync as se,closeSync as ce,constants as le,existsSync as ue,mkdirSync as w,mkdtempSync as de,openSync as fe,readFileSync as T,renameSync as pe,rmSync as me,writeFileSync as E}from"node:fs";import*as he from"node:readline";import{link as ge,lstat as _e,mkdir as ve,readFile as ye,rename as be,stat as xe,unlink as Se,writeFile as Ce}from"node:fs/promises";import*as eee from"node:zlib";import{crc32 as tee,inflateSync as nee}from"node:zlib";import*as ree from"node:util";import*as iee from"node:assert";import*as aee from"node:buffer";import we from"node:process";import Te from"node:tty";var oee=Object.create,Ee=Object.defineProperty,see=Object.getOwnPropertyDescriptor,cee=Object.getOwnPropertyNames,lee=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty,Oe=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),uee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=cee(t),a=0,o=i.length,s;a<o;a++)s=i[a],!De.call(e,s)&&s!==n&&Ee(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=see(t,s))||r.enumerable});return e},dee=(e,t,n)=>(n=e==null?{}:oee(lee(e)),uee(t||!e||!e.__esModule||!De.call(e,`default`)?Ee(n,`default`,{value:e,enumerable:!0}):n,e)),ke=`0.2.1`;const Ae=(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}}},fee={pipe(){return Ae(this,arguments)}},je=function(){function e(){}return e.prototype=fee,e}(),D=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)}}}},Me=e=>e,Ne=e=>()=>e,Pe=Ne(!0),pee=Ne(!1),mee=Ne(null),Fe=Ne(void 0),Ie=Fe;function Le(e,...t){return Ae(e,t)}function Re(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 ze(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!==n&&t.set(i,i),i}}const hee=[`line`,`column`,`sourceURL`,`originalLine`,`originalColumn`],Be=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;if(e instanceof Error){t.delete(`stack`);for(let n of hee)Object.prototype.propertyIsEnumerable.call(e,n)||t.delete(n)}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},Ve=new WeakSet,He=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Ue=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,We=e=>{try{return new Uint8Array(e)}catch{return}};let Ge=0;const gee=()=>{Ge++};function Ke(e){return typeof e==`string`}function qe(e){return typeof e==`number`}function Je(e){return typeof e==`boolean`}function _ee(e){return typeof e==`bigint`}function vee(e){return typeof e==`symbol`}function yee(e){return Ke(e)||qe(e)||vee(e)}function Ye(e){return typeof e==`function`}function Xe(e){return e===void 0}function Ze(e){return e!==void 0}function Qe(e){return e!==null}function bee(e){return e==null}function xee(e){return e!=null}function See(e){return!0}function Cee(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $e(e){return typeof e==`object`&&!!e||Ye(e)}const et=D(2,(e,t)=>$e(e)&&t in e),tt=D(2,(e,t)=>et(e,`_tag`)&&e._tag===t);function wee(e){return e instanceof Error}function Tee(e){return et(e,Symbol.iterator)||Ke(e)}const nt=`~effect/Hash`,rt=e=>{switch(typeof e){case`number`:return lt(e);case`bigint`:return ut(e.toString(10));case`string`:return ut(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?ut(`Invalid Date`):ut(e.toISOString());if(e instanceof RegExp)return ut(e.toString());{if(Ve.has(e))return it(e);let t=ht.get(e);if(t!==void 0)return t;if(gt.has(e))return gee(),ut(`[Circular]`);gt.add(e);let n=Ge,r;try{if(Eee(e))r=e[nt]();else if(typeof e==`function`)r=it(e);else if(Ue(e)){let t=We(e);r=t===void 0?it(e):ft(t)}else r=e instanceof DataView?ft(He(e)):Array.isArray(e)||ArrayBuffer.isView(e)?ft(e):e instanceof Map?kee(e):e instanceof Set?Aee(e):Oee(e)}finally{gt.delete(e)}return n===Ge&&ht.set(e,r),r}}return st(at(ut(String(e))))},it=e=>(mt.has(e)||mt.set(e,st(Math.random()*4294967296|0)),mt.get(e)),at=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),ot=D(2,(e,t)=>at(Math.imul(e,2654435761)+Math.imul(t,2246822507))),st=e=>e&3221225471|e>>>1&1073741824,Eee=e=>et(e,`~effect/Hash`)&&typeof e[`~effect/Hash`]==`function`,ct=new DataView(new ArrayBuffer(8)),lt=e=>{let t=e|0;return t===e?st(t):(ct.setFloat64(0,e===e?e:NaN),st(ot(ct.getInt32(0),ct.getInt32(4))))},ut=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return st(t)},Dee=(e,t)=>{let n=12289;for(let r of t)n^=ot(rt(r),rt(e[r]));return st(n)},Oee=e=>Dee(e,Be(e)),dt=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return st(r)},ft=e=>{let t=6151;for(let n of e)t=ot(t,rt(n));return st(t)},kee=dt(ut(`Map`),([e,t])=>ot(rt(e),rt(t))),pt=ut(`Set`),Aee=dt(pt,e=>ot(pt,rt(e))),mt=new WeakMap,ht=new WeakMap,gt=new WeakSet,_t=`~effect/Equal`;function vt(){return arguments.length===1?e=>yt(e,arguments[0]):yt(arguments[0],arguments[1])}function yt(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`||Ve.has(e)||Ve.has(t)?!1:jee(e,t):!1}function jee(e,t){let n=xt.length;for(let r=n;r-->0;)if(xt[r]===e&&St[r]===t)return!0;if(n)return bt(e,t);let r=Ct.get(e);r||Ct.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=bt(e,t)),i}function bt(e,t){xt.push(e),St.push(t);try{return Mee(e,t)}finally{xt.pop(),St.pop()}}const xt=[],St=[],Ct=new WeakMap;function Mee(e,t){if(rt(e)!==rt(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=Et(e);if(n!==Et(t)||typeof e==`function`&&!n)return!1;if(n)return e[_t](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:Nee(e,t);if(Ue(e)){if(!Ue(t)||e instanceof ArrayBuffer!=t instanceof ArrayBuffer)return!1;let n=We(e),r=We(t);return n!==void 0&&r!==void 0&&wt(n,r)}if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?wt(He(e),He(t)):wt(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:Tt(e,t,Fee,Iee):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:Tt(e,t,rt,yt):Pee(e,t)}function Nee(e,t){for(let n=0;n<e.length;n++)if(!yt(e[n],t[n]))return!1;return!0}function wt(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 Pee(e,t){let n=Be(e),r=Be(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!yt(e[i],t[i]))return!1;return!0}function Tt(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop(),a--;continue outer}}return!1}return a===0}const Fee=e=>rt(e[0]),Iee=(e,t)=>yt(e[0],t[0])&&yt(e[1],t[1]),Et=e=>et(e,`~effect/Equal`)&&typeof e[`~effect/Equal`]==`function`,Dt=Symbol.for(`~effect/Redactable`),Lee=e=>et(e,Dt);function Ot(e){return Lee(e)?Ree(e):e}function Ree(e){return e[Dt](globalThis[`~effect/Fiber/currentFiber`]?.context??zee)}const kt=`~effect/Fiber/currentFiber`,At=new Map,zee={"~effect/Context":{},base:At,depth:0,mapUnsafe:At,pipe(){return Ae(this,arguments)}};function jt(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,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(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 Bee;r.add(e);let l;if(Dt in e)l=c(Ree(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(`,
|
|
4
4
|
`+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=Hee(e);else if(!t?.ignoreToString&&et(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=Uee(e);l=e instanceof Error&&e.cause!==void 0?`${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=>`${Mt(t)}:${c(Nt(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${Mt(t)}: ${c(Nt(e,t),n+1)}`).join(`,
|
|
5
5
|
`)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}const Bee=`[Circular]`;function Mt(e){return typeof e==`string`?JSON.stringify(e):String(e)}function Vee(e){return e.map(e=>`[${Mt(e)}]`).join(``)}function Hee(e){try{return e.toISOString()}catch{return`Invalid Date`}}function Uee(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function Nt(e,t){try{return e[t]}catch{return`[property access threw]`}}function Pt(e,t){let n=[],r=new WeakMap;return JSON.stringify(e,function(e,t){let i=Object.getOwnPropertyDescriptor(r.get(this)??this,e)?.value,a=et(i,Dt)?Ot(i):Ot(t);if(typeof a==`bigint`)return jt(a);if(typeof a!=`object`||!a)return a;let o=a instanceof Error&&!et(a,`toJSON`)?{...a,name:a.name,message:a.message}:a;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(a))return;if(n.push(a),o!==a&&n.push(o),!Wee(o)||Kee(o))return o;let s=Gee(o);return r.set(s,o),n.push(s),s},t?.space)??`null`}function Wee(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function Gee(e){let t=Array.isArray(e)?[]:{},n=Array.isArray(e)?Array.from({length:e.length},(e,t)=>String(t)):Object.keys(e);for(let r of n)Object.defineProperty(t,r,{enumerable:!0,get:()=>{let t=Reflect.get(e,r);return Object.getOwnPropertyDescriptor(e,r)?.get===void 0?t:Ot(t)}});return t}function Kee(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}const Ft=Symbol.for(`nodejs.util.inspect.custom`),It=e=>{try{return e=Ot(e),et(e,`toJSON`)&&Ye(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(It):e}catch{return`[toJSON threw]`}},qee=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?Pt(e,{space:t}):jt(e,{space:t})}catch{return String(e)}},Lt={toJSON(){return It(this)},[Ft](){return this.toJSON()},toString(){return jt(this.toJSON())}},Jee=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),Rt=()=>Error.stackTraceLimit,zt=e=>{Jee&&(Error.stackTraceLimit=e)};var Bt=class{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}};const Vt=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}},r=Rt();if(r===0)return n[e];zt(2);let i=t[e](()=>Error());return zt(r),i.stack?.includes(e)===!0?t[e]:n[e]})();function Ht(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function Yee(e,t){if(!Object.hasOwn(t,`__proto__`)){Object.assign(e,t);return}for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&Ht(e,n,t[n])}const Ut=`~effect/Effect`,Wt=`~effect/Exit`,Xee={_A:Me,_E:Me,_R:Me},Gt=`${Ut}/identifier`,Kt=`${Ut}/args`,qt=`${Ut}/evaluate`,Jt=`${Ut}/successCont`,Yt=`${Ut}/failureCont`,Xt=`${Ut}/ensureCont`,Zt=Symbol.for(`effect/Effect/Yield`),Qt={pipe(){return Ae(this,arguments)},toJSON(){return{...this}},toString(){return jt(this.toJSON(),{ignoreToString:!0,space:2})},[Ft](){return this.toJSON()}},Zee={[Ut]:Xee,...Qt,[Symbol.iterator](){return new Bt(this)},toJSON(){return{_id:`Effect`,op:this[Gt],...Kt in this?{args:this[Kt]}:void 0}}},$t=e=>et(e,Ut),en=e=>et(e,Wt),tn=`~effect/Cause`,nn=`~effect/Cause/Reason`,rn=e=>et(e,tn);var an=class{constructor(e){this[tn]=tn,this.reasons=e}pipe(){return Ae(this,arguments)}toJSON(){return{_id:`Cause`,reasons:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${jt(this.reasons)})`}[Ft](){return this.toJSON()}[_t](e){return rn(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>vt(t,e.reasons[n]))}[nt](){return ft(this.reasons)}};const on=new WeakMap;var sn=class{[nn];annotations;_tag;constructor(e,t,n){if(this[nn]=nn,this._tag=e,t!==cn&&typeof n==`object`&&n&&t.size>0){let e=on.get(n);e&&(t=new Map([...e,...t])),on.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);if(e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)}),t?.overwrite!==!0&&n.size===this.annotations.size)return this;let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return Ae(this,arguments)}toString(){return jt(this)}[Ft](){return this.toString()}};const cn=new Map;var ln=class extends sn{constructor(e,t=cn){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${jt(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[_t](e){return _n(e)&&vt(this.error,e.error)&&vt(this.annotations,e.annotations)}[nt](){return ot(ut(this._tag))(ot(rt(this.error))(rt(this.annotations)))}};const un=e=>new an(e),Qee=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=rt(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>vt(e,i)))continue;else t.push(i);r.push(i)}return r},dn=D(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new an(Qee(e.reasons,t.reasons));return vt(e,n)?e:n}),fn=(e,t)=>{let n=e.reasons.slice();for(let e of t.reasons)yn(e)&&!n.some(t=>yn(t)&&t.fiberId===e.fiberId&&t.annotations===e.annotations)&&n.push(e);return n.length===e.reasons.length?e:new an(n)},$ee=new an([]),pn=e=>new an([new ln(e)]);var mn=class extends sn{constructor(e,t=cn){super(`Die`,t,e),this.defect=e}toString(){return`Die(${jt(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[_t](e){return vn(e)&&vt(this.defect,e.defect)&&vt(this.annotations,e.annotations)}[nt](){return ot(ut(this._tag))(ot(rt(this.defect))(rt(this.annotations)))}};const hn=e=>new an([new mn(e)]),gn=D(e=>rn(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new an(e.reasons.map(e=>e.annotate(t,n)))),_n=e=>e._tag===`Fail`,vn=e=>e._tag===`Die`,yn=e=>e._tag===`Interrupt`;function ete(e){return Dn(`Effect.evaluate: Not implemented`)}const bn=e=>({...Zee,[Gt]:e.op,[qt]:e[qt]??ete,[Jt]:e[Jt],[Yt]:e[Yt],[Xt]:e[Xt]}),xn=e=>{let t=bn(e),n=function(e){this[Kt]=e};return n.prototype=t,function(e){return new n(e)}},Sn=e=>{let t={[Wt]:Wt,_tag:e.op,get[e.prop](){return this[Kt]},...bn(e),toString(){return`${e.op}(${jt(this[Kt])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[Kt]}},[_t](e){return en(e)&&e._tag===this._tag&&vt(this[Kt],e[Kt])},[nt](){return ot(ut(e.op),rt(this[Kt]))}},n=function(e){this[Kt]=e};return n.prototype=t,function(e){return new n(e)}},Cn=Sn({op:`Success`,prop:`value`,[qt](e){let t=e.getCont(Jt);return t?t[Jt](this[Kt],e,this):e.yieldWith(this)}}),wn={key:`effect/Cause/StackTrace`},tte={key:`effect/Cause/InterruptorStackTrace`},Tn=Sn({op:`Failure`,prop:`cause`,[qt](e){let t=this[Kt],n=!1;e.cache.stackFrame&&(t=gn(t,{mapUnsafe:new Map([[wn.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(Yt),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;r&&e.interruptible;)a||=Gt in r,r=e.getCont(Yt);a&&(t=un(t.reasons.filter(e=>e._tag!==`Fail`))),t=fn(t,i),n=!0}return r?r[Yt](t,e,n?void 0:this):e.yieldWith(n?Tn(t):this)}}),En=e=>Tn(pn(e)),Dn=e=>Tn(hn(e)),On=xn({op:`WithFiber`,[qt](e){return this[Kt](e)}}),nte=function(){class e extends globalThis.Error{}let t=bn({op:`YieldableError`,[qt](){return En(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),kn=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends nte{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(Yee(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),An=e=>{class t extends kn{_tag=e}return t.prototype.name=e,t},jn=`~effect/Cause/Done`,Mn=e=>et(e,jn),Nn={[jn]:jn,_tag:`Done`,value:void 0},Pn=e=>e===void 0?Nn:{[jn]:jn,_tag:`Done`,value:e},rte=En(Nn),ite=e=>e===void 0?rte:En(Pn(e)),Fn=e=>bn({op:e.label,[qt]:e.evaluate}),In=e=>(t,n)=>t===n||e(t,n),ate=(e,t)=>e===t,ote=()=>ate;function ste(e){return In((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})}const Ln=`~effect/Option`,Rn={[Ln]:{_A:e=>e},...Qt,[Symbol.iterator](){return new Bt(this)}},cte=Object.defineProperty(Object.assign(Object.create(Rn),{_tag:`Some`,_op:`Some`,[_t](e){return zn(e)&&Vn(e)&&vt(this.value,e.value)},[nt](){return ot(rt(this._tag))(rt(this.value))},toString(){return`some(${jt(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:It(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),lte=rt(`None`),ute=Object.assign(Object.create(Rn),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[_t](e){return zn(e)&&Bn(e)},[nt](){return lte},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),zn=e=>et(e,Ln),Bn=e=>e._tag===`None`,Vn=e=>e._tag===`Some`,dte=Object.create(ute),Hn=function(e){this.value=e};Hn.prototype=cte;const fte=e=>new Hn(e),Un=`~effect/Result`,Wn={[Un]:{_A:e=>e,_E:e=>e},...Qt,[Symbol.iterator](){return new Bt(this)}},pte=Object.assign(Object.create(Wn),{_tag:`Success`,_op:`Success`,[_t](e){return Gn(e)&&qn(e)&&vt(this.success,e.success)},[nt](){return ot(rt(this._tag))(rt(this.success))},toString(){return`success(${jt(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:It(this.success)}}}),mte=Object.assign(Object.create(Wn),{_tag:`Failure`,_op:`Failure`,[_t](e){return Gn(e)&&Kn(e)&&vt(this.failure,e.failure)},[nt](){return ot(rt(this._tag))(rt(this.failure))},toString(){return`failure(${jt(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:It(this.failure)}}}),Gn=e=>et(e,Un),Kn=e=>e._tag===`Failure`,qn=e=>e._tag===`Success`,Jn=function(e){this.failure=e};Jn.prototype=mte;const hte=e=>new Jn(e),Yn=function(e){this.success=e};Yn.prototype=pte;const gte=e=>new Yn(e);function Xn(e){return(t,n)=>t===n?0:e(t,n)}const Zn=Xn((e,t)=>e<t?-1:1),Qn=Xn((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),$n=D(2,(e,t)=>Xn((n,r)=>e(t(n),t(r)))),er=e=>D(2,(t,n)=>e(t,n)===-1),tr=e=>D(2,(t,n)=>e(t,n)===1),_te=e=>D(2,(t,n)=>e(t,n)!==1),vte=e=>D(2,(t,n)=>e(t,n)!==-1),yte=e=>D(2,(t,n)=>t===n||e(t,n)<1?t:n),O=()=>dte,nr=fte,rr=Bn,ir=Vn,ar=D(2,(e,{onNone:t,onSome:n})=>rr(e)?t():n(e.value)),or=D(2,(e,t)=>rr(e)?t():e.value),bte=D(2,(e,t)=>rr(e)?t():e),sr=e=>e==null?O():nr(e),cr=e=>e===void 0?O():nr(e),xte=or(mee),lr=or(Fe),ur=e=>(...t)=>{try{return nr(e(...t))}catch{return O()}},Ste=D(2,(e,t)=>{if(ir(e))return e.value;throw t()})(()=>Error(`getOrThrow called on a None`)),Cte=D(2,(e,t)=>rr(e)?O():nr(t(e.value))),dr=D(2,(e,t)=>rr(e)?O():t(e.value)),fr=D(2,(e,t)=>!rr(e)&&t(e.value)),pr=`~effect/Context/Service`,mr=function(){function e(){}let t=e;Object.setPrototypeOf(t,wte);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[gr]=gr,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&hr.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},wte={[pr]:pr,...Fn({label:`Service`,evaluate(e){return Cn(Mr(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return Dr(this,e)},use(e){return On(t=>e(Mr(t.context,this)))},useSync(e){return On(t=>Cn(e(Mr(t.context,this))))}},hr=new Set,gr=`~effect/Context/Reference`,_r=`~effect/Context`,vr=(e,t,n,r,i)=>{let a=Object.create(Ete);return a.cacheRoot=e??a,a.base=t,a.overlay=n,a.depth=r,a._flat=void 0,a.baseHits=0,a.maxDepth=i,a},yr=(e,t)=>{t&&(yr(e,t.parent),e.set(t.key,t.value))},br=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return yr(t,e.overlay),e._flat=t},Tte=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),vr(void 0,n,void 0,0,e.maxDepth)},xr=Symbol(),Sr=(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)?xr:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=8&&(n.base=br(n),n.overlay=void 0,n.depth=0),r)},Cr=(e,t)=>{let n=t?.maxDepth;return vr(void 0,e,void 0,0,Number.isInteger(n)&&n>=0?n:8)},Ete={get mapUnsafe(){return br(this)},...Qt,[_r]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[_t](e){if(!wr(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)||!vt(r,n.get(e)))return!1;return!0},[nt](){return lt(this.mapUnsafe.size)}},Dte=(e,t)=>e.cacheRoot===t.cacheRoot,wr=e=>et(e,_r),Tr=e=>!!e[gr],Er=()=>Ote,Ote=Cr(new Map),Dr=(e,t)=>Cr(new Map([[e.key,t]])),Or=D(3,(e,t,n)=>kte(e,t.key,n)),kte=(e,t,n)=>{let r=e,i=hr.has(t)?void 0:r.cacheRoot;if(r.depth>=r.maxDepth){let e=new Map(r._flat??r.base);return r._flat||yr(e,r.overlay),e.set(t,n),vr(i,e,void 0,0,r.maxDepth)}return vr(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1,r.maxDepth)},kr=D(2,(e,t)=>Ar(e,t.key)),Ar=(e,t)=>{let n=Sr(e,t);return n===xr?void 0:n},jr=D(2,(e,t)=>{let n=Sr(e,t.key);if(n===xr){if(Tr(t))return Pr(t);throw Ate(t)}return n}),Mr=jr,Nr=`~effect/Context/defaultValue`,Pr=e=>Nr in e?e[Nr]:e[Nr]=e.defaultValue(),Ate=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
|
|
6
6
|
`);e.splice(1,3),t.stack=e.join(`
|
|
@@ -256,7 +256,7 @@ PasswordAuthentication no
|
|
|
256
256
|
`),tS=e=>`"${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`).replaceAll(`%`,`%%`)}"`,nS=e=>`'${e.replaceAll(`'`,`'\\''`).replaceAll(`%`,`%%`)}'`,T_e=e=>`Host ${e.instanceId}\n User Administrator\n IdentityFile ${tS(d(e.directory,`id_ed25519`))}\n IdentitiesOnly yes\n UserKnownHostsFile ${tS(d(e.directory,`known_hosts`))}\n StrictHostKeyChecking yes\n BatchMode yes\n ProxyCommand aws --profile ${nS(e.profile)} --region ${nS(e.region)} ssm start-session --target %h --document-name OT-HostSSH --parameters portNumber=22\n ServerAliveInterval 15\n ServerAliveCountMax 3\n`,rS=P.check(zm(/^ssh-ed25519 [A-Za-z0-9+/]+={0,2}(?: [^\r\n]*)?$/)),E_e=F({hostKey:rS}),D_e=F({config:P,firewallRemoved:I(F({name:P,enabled:P,profiles:P,owner:L(P)}))}),O_e=F({hostKey:rS,valid:Dm,serviceState:P,native:I(F({exit:Hm,out:P,err:P}))}),iS=e=>e.split(` `).slice(0,2).join(` `),aS=N(function*(e,t,n,r){if(t.instance===void 0||t.checks.sshdValid===void 0)return yield*new ub({message:`The record has no pinned SSH host key.`});let i=yield*vm(rS)(t.checks.sshdValid.detail).pipe(hl(()=>new ub({message:`The record's SSH host key is invalid.`})));yield*Kx(t,r),yield*mb(`SSH known hosts`,d(e,`known_hosts`),`${t.instance.id} ${i}\n`),yield*mb(`SSH configuration`,d(e,`ssh_config`),T_e({directory:e,instanceId:t.instance.id,profile:n.profile,region:t.region})),yield*Hx(e,t);let a=yield*eS(e,`ssh`,[`-F`,d(e,`ssh_config`),t.instance.id,`ver`],n.environment,r);return yield*Hx(e,{...t,phase:`reachable`,checks:{...t.checks,sshReached:{ok:!0,at:od(yield*id),detail:`ver succeeded over SSH through OT-HostSSH.`}},steps:[...t.steps,a.step]})}),oS=N(function*(e,t,n,r){let i=yield*Yx(e,t,yield*Wx(`prepare-ssh`,{}),r),a=yield*Xx(D_e,i.value.out),o=yield*gg,s=d(e,`id_ed25519`);if(!(yield*o.exists(s))){yield*Hx(e,t);let i=yield*eS(e,`ssh-keygen`,[`-q`,`-t`,`ed25519`,`-N`,``,`-C`,t.run,`-f`,s],n.environment,r);t=yield*Hx(e,{...t,steps:[...t.steps,i.step]})}let c=yield*eS(e,`ssh-keygen`,[`-y`,`-f`,s],n.environment,r),l=c.stdout.trim();yield*mb(`SSH public key`,d(e,`id_ed25519.pub`),l+`
|
|
257
257
|
`);let u=yield*Wx(`ssh-bootstrap`,{PublicKey:l,Configuration:Ku(w_e(a.config))}),f=yield*Yx(e,t,u,r),p=yield*Xx(O_e,f.value.out);if(!p.valid||p.serviceState!==`Running`)return yield*new db({operation:`SshBootstrap`,exitCode:1,message:`The guest did not confirm a validated, running SSH service.`});let m=yield*Hx(e,{...t,checks:{...t.checks,sshdValid:{ok:!0,at:f.readAt,detail:iS(p.hostKey)}},steps:[...t.steps,c.step]});return yield*aS(e,m,n,r)}),k_e=N(function*(e,t,n){let r=yield*Yx(e,t,yield*Wx(`read-host-key`,{}),n),i=yield*Xx(E_e,r.value.out);t.checks.sshdValid?.detail!==iS(i.hostKey)&&(yield*new db({operation:`HostKey`,exitCode:1,message:`The observed SSH host key differs from the record; access was refused.`}))}),A_e=N(function*(e,t){let n=yield*cb,r=yield*gg;yield*Rx(e.directory);let i=yield*Bx(e.directory);if(i!==void 0&&(i.run!==e.run||i.os!==`windows`||i.phase===`retiring`||i.phase===`retired`))return yield*new ub({message:`Create requires this run's Windows record before retirement has begun.`});if(i?.phase===`reachable`)return yield*wx(i.intent.securityGroupId,yield*lx(t)),i;if(yield*Vx(e.directory),!vt(i,yield*Bx(e.directory)))return yield*new db({operation:`Create`,exitCode:1,message:`The run changed during create preflight. Retry with its current record.`});if(i?.phase===`created`)return yield*wx(i.intent.securityGroupId,yield*lx(t)),yield*oS(e.directory,yield*$x(e.directory,i,t),{profile:e.profile,environment:e.environment},t);if(i?.phase===`armed`)return yield*wx(i.intent.securityGroupId,yield*lx(t)),yield*oS(e.directory,i,{profile:e.profile,environment:e.environment},t);let a=i?.phase===`intended`;if(i?.phase===`intended`){let t=yield*vm(qm(tx),{onExcessProperty:`error`})(yield*r.readFileString(d(e.directory,i.intent.requestFile)));if(a=t.ClientToken===i.intent.clientToken,!a&&!i.refusals.some(e=>e.clientToken===t.ClientToken))return yield*new ub({message:`The stored request's token does not belong to the record.`})}if(i!==void 0&&(i.phase===`requested`||a)){yield*wx(i.intent.securityGroupId,yield*lx(t));let a=yield*Dx(i,t);if(a!==void 0&&a.id!==null){let n=yield*kx(i,t),r=yield*Hx(e.directory,{...i,phase:`created`,instance:n});return yield*oS(e.directory,yield*$x(e.directory,r,t),{profile:e.profile,environment:e.environment},t)}let o=i.phase===`requested`?i:yield*Hx(e.directory,{...i,phase:`requested`});yield*n.runInstances({parameters:yield*r.readFileString(d(e.directory,i.intent.requestFile)),userData:yield*r.readFileString(d(e.directory,i.intent.userData.file))},yield*lx(t)).pipe(dl(`AwsServiceError`,t=>Zc(function*(){return t.code!==`InsufficientInstanceCapacity`&&t.code!==`VcpuLimitExceeded`&&t.code!==`IdempotentParameterMismatch`?yield*t:(yield*Hx(e.directory,{...o,phase:`refused`,refusals:[...o.refusals,{code:t.code,at:t.readAt,clientToken:o.intent.clientToken}]}),yield*new db({operation:`RunInstances`,exitCode:3,message:t.reply.answer.message}))})));let s=yield*kx(o,t),c=yield*Hx(e.directory,{...o,phase:`created`,instance:s});return yield*oS(e.directory,yield*$x(e.directory,c,t),{profile:e.profile,environment:e.environment},t)}let o=i?.intent.attempt??1;if(i?.phase===`refused`){if(o===9)return yield*new ub({message:`Nine create attempts were refused; start a new run.`});o+=1,i=yield*Hx(e.directory,{...i,phase:`intended`,intent:{...i.intent,attempt:o,clientToken:`${e.run}-instance-${o}`}})}let s=yield*n.describeSecurityGroups({by:`name`,name:`ot-no-ingress`},yield*lx(t)),c=s.value.SecurityGroups.length===1?s.value.SecurityGroups[0]:void 0;if(c===void 0)return yield*new db({operation:`DescribeSecurityGroups`,exitCode:3,message:`Exactly one ot-no-ingress group is required; nothing was requested.`});yield*wx(c.GroupId,yield*lx(t));let l=yield*n.describeInstances({by:`run`,run:e.run},yield*lx(t));if(i===void 0?l.value.length!==0:l.value.some(e=>e.state!==`terminated`))return yield*new db({operation:`DescribeInstances`,exitCode:3,message:`Run name is still listed on ${l.value.map(e=>e.id).join(`, `)}; choose another run name.`});let u=yield*n.describeImages(S_e(e.imageId),yield*lx(t)),f=yield*id,p=e.imageId===void 0?b_e(u.value.Images,f):u.value.Images.find(t=>t.ImageId===e.imageId);if(p===void 0)return yield*new db({operation:`DescribeImages`,exitCode:3,message:`No eligible Windows image was found; nothing was requested.`});let m=od(f),h=od(nd(Math.floor((ad(f)+Ai(e.need))/1e3)*1e3)).replace(`.000Z`,`Z`),g=yield*x_e(e.run,h),_=[{Key:`ot-pool`,Value:`teammates`},{Key:`ot-kind`,Value:`windows-instance`},{Key:`ot-owner`,Value:e.owner},{Key:`ot-run`,Value:e.run},{Key:`Name`,Value:`ot-${e.run}`}],v=[..._,{Key:`ot-retire-at`,Value:h}],y=o===1?`${e.run}-instance`:`${e.run}-instance-${o}`,b=JSON.stringify({ImageId:p.ImageId,InstanceType:e.instanceType,MinCount:1,MaxCount:1,ClientToken:y,InstanceInitiatedShutdownBehavior:`terminate`,IamInstanceProfile:{Name:`openteammate-host-ssm`},SecurityGroupIds:[c.GroupId],MetadataOptions:{HttpTokens:`required`,HttpPutResponseHopLimit:1,HttpEndpoint:`enabled`},BlockDeviceMappings:[{DeviceName:`/dev/sda1`,Ebs:{VolumeSize:e.rootGiB,VolumeType:`gp3`,Encrypted:!0,DeleteOnTermination:!0}}],TagSpecifications:[{ResourceType:`instance`,Tags:v},{ResourceType:`volume`,Tags:v},{ResourceType:`network-interface`,Tags:_}]}),ee=o===1?`userdata.ps1`:`userdata-${o}.ps1`,x=o===1?`requests/run-instances.json`:`requests/run-instances-${o}.json`;yield*r.makeDirectory(d(e.directory,`requests`),{recursive:!0,mode:448}),yield*mb(`user data`,d(e.directory,ee),g),yield*mb(`RunInstances parameters`,d(e.directory,x),b);let te={schema:`openteammate.ec2-instance/record@1`,run:e.run,owner:e.owner,os:`windows`,profile:e.profile,region:e.region,helper:{...e.helper,awsCliVersion:`${s.reply.client.name}/${s.reply.client.version}`},phase:`intended`,intent:{attempt:o,image:{id:p.ImageId,name:p.Name,released:od(p.CreationDate)},instanceType:e.instanceType,rootGiB:e.rootGiB,retireAt:h,clientToken:y,securityGroupId:c.GroupId,instanceProfile:`openteammate-host-ssm`,userData:{file:ee,bytes:new TextEncoder().encode(g).byteLength,sha256:yield*Ux(g)},requestFile:x},refusals:i?.refusals??[],checks:{},ends:[...i?.ends??[],{value:h,at:m,by:`create`}],steps:i?.steps??[]};yield*Hx(e.directory,te);let ne=yield*Hx(e.directory,{...te,phase:`requested`});yield*n.runInstances({parameters:b,userData:g},yield*lx(t)).pipe(dl(`AwsServiceError`,t=>Zc(function*(){return t.code!==`InsufficientInstanceCapacity`&&t.code!==`VcpuLimitExceeded`&&t.code!==`IdempotentParameterMismatch`?yield*t:(yield*Hx(e.directory,{...ne,phase:`refused`,refusals:[...ne.refusals,{code:t.code,at:t.readAt,clientToken:y}]}),yield*new db({operation:`RunInstances`,exitCode:3,message:t.reply.answer.message}))})));let re=yield*kx(ne,t),ie=yield*Hx(e.directory,{...ne,phase:`created`,instance:re});return yield*oS(e.directory,yield*$x(e.directory,ie,t),{profile:e.profile,environment:e.environment},t)},jl),j_e=(e,t)=>(t===void 0?cx(e.within):k(t)).pipe(j(t=>ux(t).pipe(j(n=>A_e(e,t).pipe(bl({duration:n,orElse:()=>A(new db({operation:`Create`,exitCode:1,message:`The create deadline expired; read the recorded phase before resuming.`}))})))))),M_e=(e,t,n)=>Zc(function*(){let r=yield*gg,i=yield*r.realPath(g(new URL(`../`,import.meta.url))),a=r=>eS(e,`git`,[`--no-optional-locks`,`-C`,i,...r],t,n,`capture`),o=yield*r.realPath((yield*a([`rev-parse`,`--show-toplevel`])).stdout.trim());return f(o,i)!==d(`scripts`,`ec2-instance`)||(yield*a([`cat-file`,`-e`,`HEAD:scripts/ec2-instance/main.ts`]),(yield*a([`status`,`--porcelain`,`--untracked-files=all`,`--`,`.`])).stdout.trim()!==``)?`unknown`:(yield*a([`rev-parse`,`HEAD`])).stdout.trim()}).pipe(ol,M(e=>Hr(e)?e.success:`unknown`)),sS=3e5,cS=e=>ad(nd(e)),lS=()=>`w`+b().replaceAll(`-`,``),uS=(e,t=1)=>new db({operation:`Extend`,exitCode:t,message:e}),dS=(e,t)=>Xx(Zx,e).pipe(j(e=>{let n=Qx(e,t);return n===null?A(uS(`The retirement task is not Ready with this run's SYSTEM shutdown action.`)):k(od(n).replace(`.000Z`,`Z`))})),N_e=N(function*(e){let{directory:t,to:n,deadline:r}=e,i=e.record,a=i.instance;if(i.os!==`windows`||a===void 0||![`created`,`armed`,`reachable`].includes(i.phase))return yield*uS(`Cannot extend the ${i.os} record at phase ${i.phase}.`,3);if(yield*Vx(t),!vt(yield*zx(t),i))return yield*uS(`The run record changed before extension acquired custody. Retry with the current record.`);yield*wx(i.intent.securityGroupId,yield*lx(r));let o=yield*cb,s=[...new Set([a.rootVolumeId,...a.volumeIds])],c=[a.id,...s],l=yield*mx(t,i.steps);i={...i,steps:l.steps};let u=i.pendingEnd!==void 0,d=e=>uS(e,u?1:3),f=N(function*(e,t){let n=ad(yield*id);(cS(e)-n<sS||cS(t)-n<sS)&&(yield*d(`Both the current and requested ends need at least five minutes remaining.`))}),p=Zc(function*(){let e=yield*Gx(i,r,u?1:3),t=yield*o.describeVolumeEnds(s,yield*lx(r)),n=[];for(let e of s){let r=t.value.find(t=>t.id===e);if(r?.tags?.find(e=>e.Key===`ot-run`)?.Value!==i.run)return yield*d(`The exact volume `+e+` does not have this run's ownership tag.`);let a=yield*vm(yx)(r.tags.find(e=>e.Key===`ot-retire-at`)?.Value).pipe(hl(()=>d(`Volume `+e+` has no valid end tag.`)));n.push(a)}return{instance:e.end,volumes:n}}),m=yield*Wx(`read-task`,{Run:i.run}),h=Zc(function*(){let e=yield*Yx(t,i,m,r);return yield*dS(e.value.out,i.run)}),g=N(function*(e){return i=yield*Hx(t,{...i,pendingEnd:e}),e}),_=N(function*(e,n){let s=e;if(s.task.state===`unknown`){let e=l.commands.get(s.task.writeId);e?.instance===a.id&&(s=yield*g({...s,task:{...s.task,state:`accepted`,commandId:e.commandId}}))}if(s.tags===`unknown`){let e=l.tagWrites.get(s.id);e?.to===s.to&&e.ids.length===c.length&&c.every(t=>e.ids.includes(t))&&(s=yield*g({...s,tags:`acknowledged`}))}if(s.task.state===`accepted`){let e=yield*Jx(a.id,s.task.commandId,r).pipe(ol);if(Vr(e)){if(e.failure._tag!==`LifecycleError`||e.failure.operation!==`GetCommandInvocation`)return yield*e.failure;s=yield*g({...s,task:{state:`planned`}})}}let _=n??(yield*h);if(_!==s.to){if(_!==s.from||s.tags===`acknowledged`)return yield*uS(`Guest task disagrees with the unfinished end move. Check the saved record and task.`);let e=yield*Kx(i,r);if(e.end!==(s.mode===`restore`?s.to:s.from))return yield*d(`The EC2 end changed before the guest move.`);yield*f(_,s.to);let t=yield*Wx(`extend`,{Run:i.run,OldEnd:s.from,NewEnd:s.to,Restore:s.mode===`restore`?`yes`:`no`}),n=lS();s=yield*g({...s,task:{state:`unknown`,writeId:n}}),u=!0;let o=yield*qx(e,t+`
|
|
258
258
|
`+m,r,n).pipe(ol);if(Vr(o))return yield*g(s),yield*o.failure;let c=o.success.value.Command.CommandId;s=yield*g({...s,task:{state:`accepted`,writeId:n,commandId:c}});let l=yield*Jx(a.id,c,r);if((yield*dS(l.value.out,i.run))!==s.to)return yield*uS(`The guest read-back does not show the requested shutdown instant. Run extend again to reconcile it.`)}if(s=yield*g({...s,task:{state:`completed`}}),s.mode===`restore`){if((yield*Gx(i,r)).end!==s.to)return yield*uS(`The instance end changed while the guest task was being reconciled.`);let{pendingEnd:e,...n}=i;return yield*Hx(t,n)}let v=Zc(function*(){let e=yield*p,t=[e.instance,...e.volumes];return e.instance!==s.from&&e.instance!==s.to?yield*uS(`The instance carries an end outside the unfinished move.`):e.volumes.some(e=>cS(e)>cS(s.to))?yield*uS(`A recorded volume carries a later end. Its tag cannot be shortened.`):{all:t.every(e=>e===s.to),current:e.instance}}),y=yield*v;if(!y.all){if(s.tags!==`acknowledged`){yield*f(y.current,s.to),s=yield*g({...s,tags:`unknown`}),u=!0;let e=yield*o.setEndTags({ids:c,to:s.to},{...yield*lx(r),writeId:s.id}).pipe(ol);if(Vr(e))return yield*g(s),yield*e.failure;s=yield*g({...s,tags:`acknowledged`})}yield*v.pipe(Bl({until:e=>e.all,schedule:dx}))}let{pendingEnd:b,...ee}=i,x=ee.ends.at(-1)?.value===s.to?ee.ends:[...ee.ends,{value:s.to,at:od(yield*id),by:`extend`}];return yield*Hx(t,{...ee,ends:x})});return yield*Zc(function*(){if(i.pendingEnd!==void 0){let e=i.pendingEnd;if(e.mode===`extend`&&cS(e.to)<cS(e.from))return yield*uS(`The pending extension would shorten the recorded end.`);if(yield*p,i=yield*_(e),e.to===n)return i}let e=yield*p;if([e.instance,...e.volumes].some(e=>cS(n)<cS(e)))return yield*d(`The requested end is earlier than a current instance or volume end tag.`);yield*f(e.instance,n);let t=yield*h;if(t!==e.instance){yield*f(t,e.instance);let n=yield*g({id:lS(),mode:`restore`,from:t,to:e.instance,task:{state:`planned`},tags:`planned`});i=yield*_(n,t)}if(n===e.instance&&e.volumes.every(e=>e===n)&&i.ends.at(-1)?.value===n)return i;let r=yield*g({id:lS(),mode:`extend`,from:e.instance,to:n,task:{state:`planned`},tags:`planned`});return yield*_(r,e.instance)}).pipe(bl({duration:yield*ux(r),orElse:()=>A(uS(`The extension deadline expired. Run extend again to reconcile the saved move.`))}))},jl),P_e=N(function*(e,t,n,r){let i=yield*ux(r);return yield*Zc(function*(){return t.os!==`windows`||t.phase!==`armed`&&t.phase!==`reachable`||t.checks.sshdValid?.ok!==!0?yield*new ub({message:`Run create to arm the instance and pin its SSH key before reach.`}):(yield*Vx(e),vt(t,yield*zx(e))?(yield*wx(t.intent.securityGroupId,yield*lx(r)),yield*k_e(e,t,r),yield*aS(e,t,n,r)):yield*new db({operation:`Reach`,exitCode:1,message:`The run changed during reach preflight. Retry with its current record.`}))}).pipe(bl({duration:i,orElse:()=>A(new db({operation:`Reach`,exitCode:1,message:`The reach deadline expired; the record remains available for another attempt.`}))}))},jl),fS=F({instances:I(F({id:Xb,state:L(P),token:L(Xb)})),notStarted:Cm(Tm(`deadline`)),reply:L(tb),ok:Dm,readAt:P}),pS=F({ids:I(Xb),reply:L(tb),readAt:P,ok:Dm}),F_e=F({volumes:L(pS),interfaces:L(pS)}),I_e=F({kind:jm([`ec2-instance`,`ebs-volume`,`network-interface`]).annotate({description:`Kind of the recorded resource.`}),id:Xb.annotate({description:`Exact provider resource ID.`}),attachmentInventory:Cm(Am([Tm(`observed`),F_e])).annotate({description:`For an instance, the observed inventory or the two tag searches used to recover it.`}),launchedAt:Cm(P).annotate({description:`Launch time EC2 returned for a recovered instance whose attachments could no longer be read from the instance.`}),proof:jm([`terminated`,`not-listed-after-earlier-read`,`not-found-after-earlier-read`,`InvalidVolume.NotFound`,`deleted`,`InvalidNetworkInterfaceID.NotFound`,`unproven`]).annotate({description:`Provider observation supporting absence, or unproven.`}),reply:L(tb).annotate({description:`The provider's actual reply; null when the read obtained no reply.`}),readAt:P.annotate({description:`UTC time of this provider read.`})}),L_e=F({tokens:I(Xb).check(Um(1)),byRunTag:fS,byClientToken:fS,ok:Dm}),R_e={"ec2-instance":[`terminated`,`not-listed-after-earlier-read`,`not-found-after-earlier-read`],"ebs-volume":[`InvalidVolume.NotFound`,`deleted`],"network-interface":[`InvalidNetworkInterfaceID.NotFound`]},mS=({recordPhase:e,recordedInstanceId:t,resources:n,filteredReads:r})=>{if(t!==null&&!n.some(e=>e.kind===`ec2-instance`&&e.id===t))return`unproven`;let i=[r.byRunTag,r.byClientToken];if(!r.ok||i.some(e=>!e.ok||e.notStarted!==void 0||e.reply?.answer.kind!==`answered`)||n.some(e=>e.reply===null||!R_e[e.kind].includes(e.proof)))return`unproven`;for(let e of n){if(e.kind!==`ec2-instance`)continue;let r=e.attachmentInventory;if(r===void 0)return`unproven`;if(r===`observed`){if(e.launchedAt!==void 0||t===null&&!n.some(e=>e.kind===`network-interface`))return`unproven`;continue}for(let[e,t]of[[r.volumes,`DescribeVolumes`],[r.interfaces,`DescribeNetworkInterfaces`]])if(e===null||!e.ok||e.ids.length!==0||e.reply?.operation!==t||e.reply.answer.kind!==`answered`)return`unproven`}for(let e of i)for(let t of e.instances){let e=n.find(e=>e.kind===`ec2-instance`&&e.id===t.id);if(e===void 0){if(t.state!==`terminated`||t.token===null||r.tokens.includes(t.token))return`unproven`}else if(e.proof!==`terminated`&&t.state!==`terminated`)return`unproven`}return n.length===0?(e===`intended`||e===`refused`)&&r.byClientToken.instances.length===0?`nothing-created`:`unproven`:`released`},hS=`openteammate.ec2-instance/receipt@3`,gS=F({schema:Tm(hS).annotate({description:`Version of the release receipt.`}),run:vx.annotate({description:`Run whose resources this receipt describes.`}),region:P.annotate({description:`Region in which the provider was read.`}),os:d_e.annotate({description:`Recorded guest operating system.`}),recordedInstanceId:L(Xb).annotate({description:`The record’s instance ID at verification, if observed.`}),terminationAttemptedFor:Cm(Xb).annotate({description:`Instance for which this run reached dispatch without an acknowledgement proving it caused the end.`}),recordPhase:f_e.annotate({description:`Record phase used to evaluate this release.`}),status:jm([`released`,`nothing-created`,`unproven`]).annotate({description:`Whether release or non-creation was proved, or remains unproven.`}),ended:jm([`retire`,`guest-shutdown`,`other-terminate`,`not-created`,`unknown`]).annotate({description:`Observed source of the instance's end.`}),resources:I(I_e).annotate({description:`Provider-neutral resource list with the evidence for each resource.`}),filteredReads:L_e.annotate({description:`Tokens searched and the observed identities, states and tokens from both searches.`}),accountCheck:F({securityGroupId:Xb.annotate({description:`The positive control group ID.`}),reply:tb,ok:Dm.annotate({description:`Whether that exact resource was readable.`}),readAt:P.annotate({description:`UTC time of the account check.`})}).annotate({description:`Evidence that absence reads used the intended account and region.`}),localFiles:F({removed:I(P).annotate({description:`Local key files removed.`}),absent:Dm.annotate({description:`Whether local key files were confirmed absent.`})}).annotate({description:`Local cleanup observations.`}),unproven:I(F({item:P.annotate({description:`Resource or obligation still unproven.`}),reason:P.annotate({description:`What prevented proof.`}),next:P.annotate({description:`Next action that could establish proof.`})})).annotate({description:`Outstanding release obligations and their next steps.`}),startedAt:P.annotate({description:`UTC time release verification began.`}),endedAt:P.annotate({description:`UTC time release verification ended.`})}).annotate({description:`Release evidence for the resources this run recorded or recovered.`}).check(Rm(e=>e.status===`unproven`||e.accountCheck.ok&&e.localFiles.absent&&e.unproven.length===0&&e.accountCheck.reply.answer.kind===`answered`&&e.status===mS(e),{message:`A successful release requires every resource, account, filtered-read and local-file proof.`})),z_e=vm(gS,{onExcessProperty:`error`}),_S=xm(gS,{onExcessProperty:`error`}),B_e=N(function*(e){let t=yield*gg;return yield*vm(qm(gS),{onExcessProperty:`error`})(yield*t.readFileString(d(e,`receipt.json`)))}),vS=N(function*(e,t){let n=yield*(yield*gg).readFileString(d(e,`receipt.json`)).pipe(dl(`PlatformError`,e=>e.reason._tag===`NotFound`?k(void 0):A(e)));if(n===void 0)return;let r=()=>new ub({message:`The existing receipt.json is invalid.`}),i=yield*vm(qm(Em))(n).pipe(hl(r)),a=yield*vm(F({schema:P}))(i).pipe(hl(r));if(a.schema===`openteammate.ec2-instance/receipt@1`||a.schema===`openteammate.ec2-instance/receipt@2`)return yield*new ub({message:`Unknown earlier release receipt schema version. Move the old receipt.json aside and run retire again to re-prove every resource from the record. Check any inventory: item in the old receipt by hand because the record cannot carry it forward.`});if(a.schema!==`openteammate.ec2-instance/receipt@3`)return yield*new ub({message:`Unknown release receipt schema version.`});let o=yield*z_e(i).pipe(hl(r));return o.run!==t.run||o.region!==t.region||o.os!==t.os?yield*new ub({message:`The existing receipt belongs to another run, region or operating system.`}):o}),yS=N(function*(e,t){let n=yield*gg;yield*Rx(e);let r=yield*n.makeTempDirectoryScoped({directory:e,prefix:`.receipt-`}),i=d(r,`receipt.json`);return yield*px(i,fx(yield*_S(t))+`
|
|
259
|
-
`,{mode:384}),yield*(yield*n.open(i,{flag:`r`})).sync,yield*n.rename(i,d(e,`receipt.json`)),yield*(yield*n.open(e,{flag:`r`})).sync,yield*B_e(e)},jl),bS=(e,t)=>Hr(e)?{reply:e.success.reply,readAt:e.success.readAt}:e.failure._tag===`AwsReadError`?e.failure.observation??{reply:null,readAt:t}:e.failure._tag===`UsageError`?{reply:null,readAt:t}:{reply:e.failure.reply,readAt:e.failure.readAt},V_e=(e,t,n,r,i)=>{let a={instances:[],ok:!1,reply:null,readAt:r},o=e=>e!==void 0&&(e.ok||e.notStarted===`deadline`)?e:a,s=i!==void 0&&i.tokens.length===t.length&&t.every(e=>i.tokens.includes(e)),c={byRunTag:o(i?.byRunTag),byClientToken:s?o(i.byClientToken):a},l={tokens:t,byRunTag:a,byClientToken:a,ok:!1},u=new Map,d=new Map;return{search:N(function*(r){let i=yield*cb,o=[],s=!1;l={...l,byRunTag:{...l.byRunTag,ok:!1},byClientToken:{...l.byClientToken,ok:!1},ok:!1};for(let f of[`byRunTag`,`byClientToken`]){let p=f===`byRunTag`?`run-tag search`:`client-token search`;d.has(p)||d.set(p,{item:p,reason:`This filtered search has not completed.`,next:`Run retire again to complete this search.`});let m=yield*lx(n);l={...l,[f]:{...a,readAt:od(yield*id)}};let h=yield*(f===`byRunTag`?i.describeInstanceResources({by:`run`,run:e},m):i.describeInstanceResourcesByTokens(t,m)).pipe(ol),g=bS(h,od(yield*id)),_;if(Vr(h)){let e=h.failure,t=e._tag===`AwsReadError`&&e.reason===`budget`;_=t?{...c[f],notStarted:`deadline`,ok:!1}:{...g,instances:[],ok:!1};let n=ob(e);d.set(p,{item:p,reason:t?u.has(p)?sb(u.get(p)??e):`No read was started for lack of time.`:`${n.operation} ${n.code}: ${n.message}`,next:`Run retire again to complete this search.`}),t&&d.set(`deadline`,{item:`deadline`,reason:`No read was started for lack of time in the retirement deadline.`,next:`Run retire again to obtain fresh proofs.`}),ib(e)?u.set(p,e):s=!0}else{u.delete(p),o.push(...h.success.value);let e=h.success.value.flatMap(({id:e,state:t,token:n})=>e===null?[]:[{id:e,state:t,token:n}]),t=e.length===h.success.value.length;_={...g,instances:e,ok:t},t?(c[f]=_,d.delete(p)):(d.set(p,{item:p,reason:`The provider listed an instance without an ID.`,next:`Repeat the search to identify every listed instance.`}),s=!0)}l={...l,[f]:_},Hr(h)&&(yield*r(h.success.value))}return l={...l,ok:l.byRunTag.ok&&l.byClientToken.ok},{listed:o,ok:l.ok,stop:s}}),reads:()=>l,issues:d,expire:()=>{for(let[e,t]of u){let n=d.get(e);n&&d.set(e,{...n,reason:sb(t)})}}}},H_e=(e,t,n,r)=>{if(Hr(t)&&t.success.value.some(t=>t.id===e&&t.state===`terminated`))return`terminated`;if(r)return`unproven`;if(Hr(t))return t.success.value.length===0?`not-listed-after-earlier-read`:`unproven`;if(t.failure._tag!==`InvalidInstanceID.NotFound`||n===void 0)return`unproven`;let i=rd(n),a=rd(t.failure.readAt);return ir(i)&&ir(a)&&ad(a.value)-ad(i.value)>=3e5?`not-found-after-earlier-read`:`unproven`},U_e=N(function*(e,t){let n=yield*cb,r=od(yield*id);if(e.kind===`ebs-volume`){let i=yield*n.describeVolume(e.id,t).pipe(ol),a=Vr(i)&&i.failure._tag===`InvalidVolume.NotFound`?`InvalidVolume.NotFound`:Hr(i)&&i.success.value.some(t=>t.id===e.id&&t.state===`deleted`)?`deleted`:`unproven`;return{resource:{...e,...bS(i,r),proof:a},error:Vr(i)&&a===`unproven`?i.failure:void 0}}let i=yield*n.describeNetworkInterface(e.id,t).pipe(ol),a=Vr(i)&&i.failure._tag===`InvalidNetworkInterfaceID.NotFound`?`InvalidNetworkInterfaceID.NotFound`:`unproven`;return{resource:{...e,...bS(i,r),proof:a},error:Vr(i)&&a===`unproven`?i.failure:void 0}}),xS=id.pipe(M(od)),SS=e=>[{kind:`ec2-instance`,id:e.id},...Array.from(new Set([e.rootVolumeId,...e.volumeIds]),e=>({kind:`ebs-volume`,id:e})),...e.networkInterfaceIds.map(e=>({kind:`network-interface`,id:e}))],W_e=e=>vS(e.directory,e.record).pipe(M(t=>K_e(e,t))),G_e=e=>rl(W_e(e)),K_e=N(function*(e,t){let{directory:n}=e,r=e.record,i=yield*gg,a=yield*cb,o=yield*xS,s=yield*cx(e.within),c,l=()=>new Cx({securityGroupId:r.intent.securityGroupId,operation:`DescribeSecurityGroups`,kind:`process`,message:`The retirement deadline expired during the account check; no termination was sent.`+(c===void 0?``:` Deadline reached while ${c.code} persisted: ${c.message}`)}),u=yield*lx(s).pipe(hl(l),j(e=>wx(r.intent.securityGroupId,e)),hl(e=>{if(e._tag===`AccountCheckFailed`){if(e.budget&&c!==void 0)return l();e.retryable&&(c=e)}return e}),vl({schedule:dx,while:e=>e._tag===`AccountCheckFailed`&&e.retryable===!0}),bl({duration:yield*ux(s).pipe(hl(l)),orElse:()=>A(l())})),f=yield*mx(n,r.steps);r={...r,steps:f.steps},r.instance!==void 0&&(r.phase===`retiring`||t?.terminationAttemptedFor===r.instance.id||t?.ended===`retire`&&t.recordedInstanceId===r.instance.id)&&f.attempted.add(r.instance.id);let p=Array.from(new Set([r.intent.clientToken,...r.refusals.map(e=>e.clientToken)])),m=V_e(r.run,p,s,o,t?.filteredReads),h=new Map;for(let e of t?.resources??[])h.set(e.id,{...e,proof:`unproven`});let g=(e,t)=>{h.has(t)||h.set(t,{kind:e,id:t,reply:null,proof:`unproven`,readAt:o,...e===`ec2-instance`?{attachmentInventory:`observed`}:{}})};if(r.instance!==void 0)for(let e of SS(r.instance))g(e.kind,e.id);let _=new Map((t?.unproven??[]).filter(e=>e.item.startsWith(`inventory:`)).map(e=>[e.item,e]));for(let e of h.values())if(typeof e.attachmentInventory==`object`){let t=`inventory:${e.id}`;_.set(t,{item:t,reason:`Attachment inventory requires fresh run-tag searches.`,next:`Run retire again to read both attachment types.`})}let v=new Set(Array.from(h.values()).filter(e=>e.kind===`ec2-instance`&&!_.has(`inventory:${e.id}`)).map(e=>e.id));r.instance?.networkInterfaceIds.length===0&&(v.delete(r.instance.id),_.set(`inventory:${r.instance.id}`,{item:`inventory:${r.instance.id}`,reason:`No interface ID was recorded.`,next:`Recover the original interface ID before claiming release.`}));let y=new Set,b=new Map,ee=new Set,x=new Map,te=new Map,ne=new Map,re=e=>{let n=ne.get(e),r=t?.resources.some(t=>t.kind===`ec2-instance`&&t.id===e)?t.ended:void 0;return f.acknowledged.has(e)?`retire`:n===`Client.InstanceInitiatedShutdown`||n===void 0&&r===`guest-shutdown`?`guest-shutdown`:!f.attempted.has(e)&&(n===`Client.UserInitiatedShutdown`||n===void 0&&r===`other-terminate`)?`other-terminate`:`unknown`},ie=()=>{let e=Array.from(h.values()).filter(e=>e.kind===`ec2-instance`).map(e=>re(e.id));return e.length>0&&e.every(t=>t===e[0])?e[0]??`unknown`:`unknown`},ae=()=>({recordPhase:r.phase,recordedInstanceId:r.instance?.id??null,resources:Array.from(h.values()),filteredReads:m.reads()}),S=()=>{let e=new Map([...te,..._,...x,...m.issues]);for(let t of h.values())t.proof===`unproven`&&!e.has(t.id)&&e.set(t.id,{item:t.id,reason:`The exact read has not established absence.`,next:`Run retire again to read this resource.`});return{schema:hS,...ae(),...r.instance!==void 0&&f.attempted.has(r.instance.id)&&!f.acknowledged.has(r.instance.id)?{terminationAttemptedFor:r.instance.id}:{},run:r.run,region:r.region,os:r.os,status:`unproven`,ended:ie(),accountCheck:{securityGroupId:r.intent.securityGroupId,ok:!0,reply:u.reply,readAt:u.readAt},localFiles:{removed:[],absent:!1},unproven:Array.from(e.values()),startedAt:o,endedAt:o}},oe=(e,t,n)=>{x.set(e,{item:e,reason:ob(t).message,next:n}),t._tag===`AwsReadError`&&t.reason===`budget`&&x.set(`deadline`,{item:`deadline`,reason:`No read was started for lack of time in the retirement deadline.`,next:`Run retire again to finish the outstanding proofs.`})},C=new Map,se=(e,t,n)=>{if(ib(t))C.set(e,t),te.set(e,{item:e,reason:ob(t).message,next:n});else{oe(e,t,n);let r=C.get(e);r!==void 0&&t._tag===`AwsReadError`&&t.reason===`budget`&&x.set(e,{item:e,reason:sb(r),next:n}),C.delete(e)}},ce=e=>lx(s).pipe(j(t=>a.describeInstances({by:`id`,id:e},t).pipe(ol))),le=N(function*(e,t,i){let o=e.id,c=i??(yield*ce(o)),l=Hr(c)?c.success.value.find(e=>e.id===o):void 0,u=r.instance?.id===o?r.instance.launchedAt:b.get(o)?.launch??e.launchedAt,d=Hr(c)?c.success.value.length===0:c.failure._tag===`InvalidInstanceID.NotFound`,p=l?.state===`terminated`?void 0:l??(d?t:void 0);if(p!==void 0&&v.has(o)){if(r.instance?.id!==o&&!b.has(o)||p.tags?.find(e=>e.Key===`ot-run`)?.Value!==r.run)x.set(o,{item:o,reason:`Termination requires this record's ID or token and its matching ot-run tag.`,next:`Verify custody before attempting retirement again.`});else if(!ee.has(o)&&!f.acknowledged.has(o)){h.set(o,{...e,...bS(c,yield*xS),proof:`unproven`}),r=yield*Hx(n,{...r,phase:`retiring`}),yield*yS(n,{...S(),endedAt:yield*xS});let t=yield*lx(s);ee.add(o),f.attempted.add(o);let i=yield*a.terminateInstance(o,t).pipe(ol);r=yield*Hx(n,r),Vr(i)?oe(o,i.failure,`Run retire again to reconcile the request; it may have reached AWS.`):sx(o,i.success.value)&&f.acknowledged.add(o),c=yield*ce(o),l=Hr(c)?c.success.value.find(e=>e.id===o):void 0}}let m=H_e(o,c,u,t!==void 0);return h.set(o,{...e,...bS(c,yield*xS),proof:m}),l?.state===`terminated`&&l.reason!==null&&ne.set(o,l.reason.Code),te.delete(o),(Hr(c)||c.failure._tag===`InvalidInstanceID.NotFound`)&&C.delete(o),Vr(c)&&(c.failure._tag===`InvalidInstanceID.NotFound`?m===`unproven`&&t===void 0&&te.set(o,{item:o,reason:`not-found-too-soon: the NotFound reply does not establish absence.`,next:`Read again after the recorded launch is at least five minutes old.`}):se(o,c.failure,`Run retire again to complete the instance proof.`)),c}),ue=N(function*(e){for(let t of h.values()){if(t.kind===`ec2-instance`||t.proof!==`unproven`||e.has(t.id))continue;e.add(t.id);let n=yield*U_e(t,yield*lx(s));h.set(t.id,n.resource),te.delete(t.id),n.error===void 0&&C.delete(t.id),n.error!==void 0&&se(t.id,n.error,`Run retire again to complete the attachment proof.`)}}),w=N(function*(e){for(let t of e){if(t.id===null)continue;let e=t.id;if(t.token!==null&&p.includes(t.token)){b.set(e,t),g(`ec2-instance`,e);let i=Ox(t);if(i!==void 0){for(let e of SS(i))g(e.kind,e.id);let t=h.get(e);if(t!==void 0){let{launchedAt:n,...r}=t;h.set(e,{...r,attachmentInventory:`observed`})}v.add(e),_.delete(`inventory:${e}`),r.instance===void 0&&(r=yield*Hx(n,{...r,instance:i,phase:`created`}))}else if(!v.has(e)&&!y.has(e)){let n=h.get(e);n!==void 0&&h.set(e,{...n,...t.launch===null?{}:{launchedAt:t.launch},attachmentInventory:typeof n.attachmentInventory==`object`?n.attachmentInventory:{volumes:null,interfaces:null}}),_.set(`inventory:${e}`,{item:`inventory:${e}`,reason:`The token lookup did not recover complete volume and interface custody.`,next:`Run retire again to recover the attachment IDs from the instance or its run tags after it ends.`})}}}}),de=N(function*(e,t){let i=e===`ebs-volume`?`volume tag search`:`interface tag search`,o=yield*lx(s),c={by:`run`,run:r.run},l=e===`ebs-volume`?yield*a.describeVolume(c,o).pipe(ol):yield*a.describeNetworkInterface(c,o).pipe(ol),u=Hr(l)?l.success.value.flatMap(e=>e.id===null?[]:[e.id]):[],d=e===`ebs-volume`?`volumes`:`interfaces`,f={...bS(l,yield*xS),ids:u,ok:Hr(l)&&u.length===l.success.value.length};for(let e of t){let t=h.get(e.id)??e,n=typeof t.attachmentInventory==`object`?t.attachmentInventory:{volumes:null,interfaces:null};h.set(t.id,{...t,attachmentInventory:{...n,[d]:f}})}if(te.delete(i),Vr(l))return se(i,l.failure,`Run retire again to complete the attachment inventory.`),!1;C.delete(i);let p=h.size;for(let t of l.success.value)t.id===null?x.set(i,{item:i,reason:`The run-tag search returned an attachment without an ID.`,next:`Read the attachment inventory again before release.`}):g(e,t.id);return h.size!==p&&(yield*yS(n,{...S(),endedAt:yield*xS})),l.success.value.length===0}),fe=yield*Zc(function*(){yield*ux(s),x.clear();let e=new Map;for(let t of h.values())t.kind===`ec2-instance`&&t.proof===`unproven`&&(t.id===r.instance?.id||b.has(t.id))&&v.has(t.id)&&e.set(t.id,yield*le(t,void 0));let t=new Set;yield*ue(t);let n=r.instance===void 0?void 0:h.get(r.instance.id),i=n===void 0?void 0:e.get(n.id),a=n?.proof===`terminated`||i!==void 0&&Hr(i)&&i.success.value.some(e=>e.id===n?.id),o=i!==void 0&&Vr(i)&&ib(i.failure);if((a||o)&&x.size===0&&_.size===0&&Array.from(h.values()).some(e=>e.proof===`unproven`&&(e.kind!==`ec2-instance`||e.id===n?.id)))return!1;let c=Zc(function*(){let n=yield*m.search(w),i=new Map;for(let e of n.listed)e.id!==null&&e.state!==`terminated`&&i.set(e.id,e);for(let e of n.listed)e.id!==null&&!h.has(e.id)&&!Ex(r,e)&&x.set(e.id,{item:e.id,reason:`other-instance-listed: this ID has neither recorded custody nor proof of foreign terminated history.`,next:`Resolve the other instance's custody without terminating it by tag.`});for(let t of h.values()){if(t.kind!==`ec2-instance`||t.proof===`terminated`)continue;let n=i.get(t.id);(n!==void 0||!e.has(t.id)&&t.proof===`unproven`)&&e.set(t.id,yield*le(t,n,e.get(t.id)))}let a=Array.from(h.values()).filter(e=>e.kind===`ec2-instance`&&e.proof!==`unproven`&&_.has(`inventory:${e.id}`)&&(b.has(e.id)||e.id!==r.instance?.id)),o=!1;if(a.length!==0){let e=yield*de(`ebs-volume`,a),t=yield*de(`network-interface`,a);o=e&&t}if(yield*ue(t),o&&Array.from(h.values()).every(e=>e.kind===`ec2-instance`||e.proof!==`unproven`))for(let e of a)y.add(e.id),_.delete(`inventory:${e.id}`);let s=Array.from(_.keys()).some(e=>!a.some(t=>`inventory:${t.id}`===e)&&!te.has(e.slice(10))&&!n.listed.some(t=>`inventory:${t.id}`===e&&t.state!==`terminated`));return{ok:n.ok,stop:n.stop||x.size!==0||n.ok&&s,needsInventory:_.size!==0}}),l=yield*c;if(l.stop)return!0;if(!l.ok||l.needsInventory)return!1;if(h.size===0)return mS(ae())===`nothing-created`||(x.set(`instance`,{item:`instance`,reason:`The requested attempt has not been found; creation remains unproven.`,next:`Run retire again to repeat every recorded token and run-tag lookup.`}),!1);if(Array.from(h.values()).some(e=>e.proof===`unproven`))return!1;let u=yield*c;return u.stop||u.ok&&!u.needsInventory&&mS(ae())===`released`}).pipe(Bl({until:e=>e,schedule:dx}),bl({duration:yield*ux(s),orElse:()=>k(!1)}),ol);if(Vr(fe)?x.set(`retirement`,{item:`retirement`,reason:fe.failure.message,next:`Resolve this failure and run retire again; preserve the record.`}):fe.success||x.set(`deadline`,{item:`deadline`,reason:`The retirement deadline of ${Ai(e.within)} ms expired before all proofs completed.`,next:`Run retire again; keep the keys until every proof succeeds.`}),(Vr(fe)||!fe.success)&&m.expire(),Vr(fe)||!fe.success)for(let[e,t]of C){let n=te.get(e);n&&te.set(e,{...n,reason:sb(t)})}let T=S(),pe=T.unproven.length===0?mS(T):`unproven`,me=[],E=pe!==`unproven`;if(E)for(let e of[`id_ed25519`,`id_ed25519.pub`]){let t=d(n,e),r=yield*i.remove(t).pipe(ol);Hr(r)?me.push(e):r.failure.reason._tag!==`NotFound`&&(E=!1,x.set(e,{item:e,reason:r.failure.message,next:`Resolve local file access and run retire again.`}));let a=yield*i.lstat(t).pipe(ol);(Hr(a)||a.failure.reason._tag!==`NotFound`)&&(E=!1,x.set(e,{item:e,reason:Hr(a)?`The key file is still present.`:a.failure.message,next:`Resolve local file access and run retire again.`}))}let he=E?pe:`unproven`;return he===`released`&&(yield*Hx(n,{...r,phase:`retired`})),yield*yS(n,{...S(),status:he,ended:he===`nothing-created`?`not-created`:ie(),localFiles:{removed:me,absent:E},endedAt:yield*xS})}),CS={version:`0.2.0`,commit:`3e82f8538f896372e1d4d6f005ed8c9b60fa0b77`},wS=Ule.check(Rm(e=>Si(e)&&Ai(e)>0,{message:`Use a positive finite duration, such as '20 minutes'.`})),q_e=wS.check(Rm(e=>Ai(e)<=Ai(tne(24)),{message:`--need must be at most 24 hours.`})),TS=Gm.check(zm(/^[^\r\n\0]+$/)),J_e=qpe({present:e=>Zc(function*(){let t=yield*uv;e._tag===`InvalidInvocation`?(yield*Sg(t.formatHelpDoc(e.helpDoc)),yield*Sg(t.formatErrors(e.errors))):e._tag===`Help`&&e.reason===`Implicit`?yield*Sg(t.formatHelpDoc(e.helpDoc)):yield*dv.present(e)})}),Y_e=N(function*(e,t){let n=yield*wg(0),r=Xy(`create`,{directory:ty(`dir`).pipe(ly(TS),ay(`Private directory for this run's durable record and access files.`)),profile:ty(`profile`).pipe(ly(TS),ay(`AWS profile alias; required.`)),region:ty(`region`).pipe(ly(TS),sy,ay(`Region for a new run; defaults to us-west-2. Resumed runs use their record.`)),run:ty(`run`).pipe(ly(vx),ay(`Unique run name, at most 48 lowercase letters, digits and hyphens.`)),owner:ty(`owner`).pipe(ly(Xb),ay(`Handle responsible for this run.`)),os:Mme(`os`,[`windows`]).pipe(ay(`Guest operating system; Windows is implemented.`)),instanceType:ty(`type`).pipe(ly(TS),ay(`EC2 instance type; for example m7i.large.`)),need:ty(`need`).pipe(ly(q_e),ay(`Lifetime, such as '4 hours'; at most 24 hours.`)),rootGiB:jme(`root-gib`).pipe(cy(100),ly(Hm.check(Rm(e=>e>0))),ay(`Encrypted gp3 root volume size; defaults to 100 GiB.`)),imageId:ty(`image`).pipe(ly(Xb),sy,ay(`Explicit Amazon AMI; otherwise select Server 2025 Full Base aged at least three days.`)),within:ty(`within`).pipe(cy(`20 minutes`),ly(wS),ay(`One deadline for all create work; defaults to '20 minutes'.`))},N(function*(e){if(fb(e.profile)!==e.profile)return yield*new ub({message:`Use a profile whose name has no account ID (an alias in ~/.aws/config).`});yield*Wc([[`directory`,e.directory],[`owner`,e.owner],[`instance type`,e.instanceType],[`root size`,String(e.rootGiB)]],([e,t])=>pb(e,t));let r=p(e.directory);yield*pb(`directory`,r);let a=yield*Bx(r).pipe(hl(()=>new ub({message:`Cannot read a valid record.json from --dir.`}))),o=or(e.region,()=>a?.region??`us-west-2`);if(yield*pb(`region`,o),a!==void 0&&(a.run!==e.run||a.region!==o))return yield*new ub({message:`The record belongs to another run or region.`});let s=yield*cx(e.within),c=yield*Zc(function*(){yield*Rx(r);let n=a?.helper??CS??{version:`0.0.0`,commit:yield*M_e(r,t,s)};return yield*j_e({directory:r,profile:e.profile,region:o,run:e.run,owner:e.owner,instanceType:e.instanceType,rootGiB:e.rootGiB,need:e.need,within:e.within,helper:n,environment:t,...ir(e.imageId)?{imageId:e.imageId.value}:{}},s).pipe(El(_x({profile:e.profile,region:o,environment:t,temporaryDirectory:t.TMPDIR??i(),within:(yield*lx(s)).within,...a?.phase===`reachable`?{}:{evidenceDirectory:r}})))}).pipe(ol);if(Hr(c))return yield*Cg(fx(yield*Sx(c.success)));{let e=c.failure;if(e._tag===`UsageError`)return yield*e;yield*Sg(e.message);let t=yield*Bx(r);return t===void 0?yield*Sg(`Nothing was requested; no record was written.`):yield*Cg(fx(yield*Sx(t))),yield*Eg(n,e._tag===`AccountCheckFailed`?3:e._tag===`LifecycleError`?e.exitCode:1)}})).pipe(Zy(`Create or resume one Windows EC2 instance, arm its end and verify SSH access. Prints the record.`)),a=Xy(`reach`,{directory:ty(`dir`).pipe(ly(TS),ay(`Private run directory containing the record and SSH key.`)),profile:ty(`profile`).pipe(ly(TS),ay(`AWS profile alias; the exact recorded group verifies the account.`))},N(function*({directory:e,profile:r}){if(fb(r)!==r)return yield*new ub({message:`Use a profile whose name has no account ID (an alias in ~/.aws/config).`});let a=p(e);yield*pb(`directory`,a);let o=yield*Bx(a).pipe(hl(()=>new ub({message:`Cannot read a valid record.json from --dir.`})));if(o===void 0)return yield*new ub({message:`reach requires record.json from create.`});yield*vm(TS)(o.region).pipe(hl(()=>new ub({message:`The recorded region is invalid.`}))),yield*pb(`region`,o.region);let s=yield*cx(ki(20)),c=yield*P_e(a,o,{profile:r,environment:t},s).pipe(El(_x({profile:r,region:o.region,environment:t,temporaryDirectory:t.TMPDIR??i(),within:(yield*lx(s)).within,evidenceDirectory:a})),ol);if(Hr(c))return yield*Cg(fx(yield*Sx(c.success)));{let e=c.failure;return e._tag===`UsageError`?yield*e:(yield*Sg(e.message),yield*Cg(fx(yield*Sx(o))),yield*Eg(n,e._tag===`AccountCheckFailed`?3:1))}})).pipe(Zy(`Recheck the end and pinned host key, rebuild access files, and verify one SSH command. Uses the record's region.`)),o=Xy(`extend`,{directory:ty(`dir`).pipe(ly(TS),ay(`Private run directory containing record.json.`)),profile:ty(`profile`).pipe(ly(TS),ay(`AWS profile for the recorded account and region.`)),to:ty(`to`).pipe(ly(yx),ay(`New UTC end, YYYY-MM-DDTHH:mm:ssZ.`))},N(function*({directory:e,profile:r,to:a}){if(fb(r)!==r)return yield*new ub({message:`Use a profile whose name has no account ID (an alias in ~/.aws/config).`});let o=p(e);yield*pb(`directory`,o);let s=yield*zx(o).pipe(hl(()=>new ub({message:`Extend requires a valid record.json from create.`})));yield*pb(`region`,s.region),yield*Rx(o);let c=yield*cx(ki(15)),l=yield*N_e({directory:o,record:s,to:a,deadline:c}).pipe(El(_x({profile:r,region:s.region,environment:t,evidenceDirectory:o,temporaryDirectory:t.TMPDIR??i(),within:(yield*lx(c)).within,retryDeadline:c})),ol);if(Vr(l)){let e=l.failure;yield*Sg(e.message),yield*Eg(n,e._tag===`LifecycleError`?e.exitCode:e._tag===`AccountCheckFailed`?3:1)}return yield*Cg(fx(yield*Sx(yield*zx(o))))})).pipe(Zy(`Move and verify the guest shutdown task, then update and verify the recorded instance and volume end tags.`)),s=Xy(`retire`,{directory:ty(`dir`).pipe(ly(Gm),ay(`Private run directory containing record.json; the receipt is written here.`)),profile:ty(`profile`).pipe(ly(Gm),ay(`AWS profile for the recorded account and region.`)),within:ty(`within`).pipe(cy(`15 minutes`),ly(wS),ay(`Bound all retirement reads and waits with one deadline.`))},N(function*({directory:e,profile:r,within:a}){fb(r)!==r&&(yield*new ub({message:`Use a profile whose name has no account ID (an alias in ~/.aws/config).`}));let o=p(e);yield*pb(`directory`,o);let s=yield*zx(o).pipe(hl(()=>new ub({message:`Retire requires a valid record.json. Read-only recovery: aws ec2 describe-instances --profile <profile> --region <region> --filters Name=tag:ot-run,Values=<run>; repeat with Name=client-token,Values=<run>-instance.`})));yield*pb(`region`,s.region),yield*Rx(o),yield*vS(o,s);let c=yield*jl(Zc(function*(){yield*Vx(o);let e=yield*zx(o);return e.run!==s.run||e.region!==s.region?yield*new ub({message:`The run identity changed during retirement preflight.`}):yield*G_e({directory:o,record:e,within:a})})).pipe(El(_x({readRetryOwner:`verb`,profile:r,region:s.region,environment:t,evidenceDirectory:o,temporaryDirectory:t.TMPDIR??i()})),ol);if(Vr(c)){let e=c.failure;yield*Sg(e.message),yield*Eg(n,e._tag===`AccountCheckFailed`?3:1)}else yield*Cg(fx(yield*_S(c.success))),yield*Eg(n,+(c.success.status===`unproven`))})).pipe(Zy(`End this run and prove every recorded resource gone before removing local keys. Prints the persisted release receipt; incomplete proof exits 1.`)),c=Xy(`status`,{directory:ty(`dir`).pipe(ly(Gm),ay(`Private run directory containing record.json. It is read without modification.`)),profile:ty(`profile`).pipe(ly(Gm),ay(`AWS CLI profile to use. Required; the recorded group ID verifies the account.`))},N(function*({directory:e,profile:r}){fb(r)!==r&&(yield*new ub({message:`Use a profile whose name has no account ID (an alias in ~/.aws/config).`}));let a=yield*(yield*gg).readFileString(d(p(e),`record.json`)).pipe(hl(()=>new ub({message:`Cannot read record.json from --dir.`}))),o=yield*vm(qm(xx),{onExcessProperty:`error`})(a).pipe(hl(()=>new ub({message:`record.json must match openteammate.ec2-instance/record@1; unknown fields are refused; identity fields must not contain an account-shaped twelve-digit number.`}))),s=yield*cx(Ax),c=yield*__e(o,s).pipe(El(_x({within:Ax,profile:r,region:o.region,environment:t,temporaryDirectory:t.TMPDIR??i()})),ol);if(Vr(c)){let e=c.failure;e._tag===`UsageError`&&(yield*e);let t=e._tag===`AccountCheckFailed`?{operation:e.operation,kind:e.kind,code:e._tag,message:e.message}:e._tag===`StatusReadFailed`?{operation:e.operation,kind:`selection`,code:e._tag,message:e.message}:ob(e),r=t.message,i=yield*Nx({...o,now:{...t,outcome:`failed`,at:od(yield*id),message:r}});yield*Cg(fx(i)),yield*Sg(r),yield*Eg(n,e._tag===`AccountCheckFailed`?3:1)}else yield*Cg(fx(yield*Nx(c.success))),yield*Eg(n,c.success.now.problems.length===0?0:1)})).pipe(Zy(`Read the instance state, end, time left, Session Manager ping and last recorded end move. Prints one JSON line. No AWS resources are changed.`),vhe([{command:`ec2 status --dir ./run --profile team`,description:`Inspect a run in the region stored in its record.`}])),l=Xy(`ec2`).pipe(Zy(`EC2 instance helper. Exits: 0 promise verified; 1 incomplete or unproven; 2 invalid usage or record; 3 blocked before a cloud change; 130 interrupted.`),_he([r,a,c,o,s]));return yield*Qy(l,{version:CS?.version??`0.0.0`})(e).pipe(El(J_e),dl(`ShowHelp`,()=>Eg(n,2)),dl(`UsageError`,e=>Sg(e.message).pipe(il(Eg(n,2))))),yield*Tg(n)}),X_e=N(function*(e,t){yield*qc(n_e);let n=Lx(`ec2`);return n===void 0?yield*Y_e(e,t):yield*Sg(n).pipe(cl(1))}),Z_e=Nde(({fiber:e,teardown:t})=>{let n=!1;e.addObserver(e=>{process.removeListener(`SIGINT`,r),process.removeListener(`SIGTERM`,r),t(e,e=>{(n||e!==0)&&process.exit(e)})});function r(){n=!0,e.interruptUnsafe(e.id)}process.on(`SIGINT`,r),process.on(`SIGTERM`,r)}),Q_e=(e,t,n)=>{let r=e.detached??n!==`win32`;return{...t,detached:r,shell:e.shell,windowsHide:e.windowsHide??!r}},ES=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:case`EPERM`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`}return Uh({_tag:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,cause:n})},DS=(e,t,n)=>{if(!(`closed`in e)){t(),n?.();return}let r=()=>{clearImmediate(a),e.off(`error`,r),e.off(`close`,r),n?.()},i=()=>{e.closed?r():(a=setImmediate(i),n||a.unref())},a=setImmediate(i);n||a.unref(),e.once(`error`,r),e.once(`close`,r),t(),e.closed||e.destroy()},OS=e=>Yh(lue($_e(e),e=>[e])),$_e=e=>ch(t=>{let n=e.evaluate(),r=tve({...e,writable:n,pull:t});return k(e.endOnDone===!1?r:Fl(r,e=>Tc(e)?Jc:eve(n)))}),eve=e=>Yc(t=>{let n=()=>t(Jc);if(e.closed){let t=ae(e,{readable:!1},()=>{t(),n()})}else DS(e,Ie,n)}),tve=e=>nl(t=>{let n=t.currentDispatcher,r=Os(),i=Os(),a=t=>Is(i,Tae(()=>e.onError(t))),o=!1,s=e=>{o=!0,a(e)};e.writable.on(`error`,s);let c=ae(e.writable,{readable:!1},e=>{e?a(e):Is(r,Jc)});return e.pull.pipe(j(t=>{let r=0;return Yc(i=>{let o=!1,s=()=>n.scheduleTask(c,0),c=()=>{for(e.writable.off(`drain`,c),e.writable.off(`finish`,s);r<t.length;){if(o)return;if(!e.writable.write(t[r++],e.encoding,t=>{t&&(e.writable.closed?a(t):n.scheduleTask(()=>a(t),0))})){o||(e.writable.once(`drain`,c),e.writable.once(`finish`,s));return}}o||i(Jc)};return c(),qc(()=>{o=!0,e.writable.off(`drain`,c),e.writable.off(`finish`,s)})})}),zl({disableYield:!0}),e.endOnDone===!1?Me:wc(t=>(e.writable.end(),il(As(r),xs(t)))),Sl(As(i)),Pl(qc(()=>{c();let t=()=>{e.writable.off(`error`,s),e.writable.off(`error`,t),e.writable.off(`close`,t)};e.writable.errored&&!e.writable.closed&&!o?(e.writable.once(`error`,t),e.writable.once(`close`,t)):t()})))}),kS=e=>ig(nve(e)),nve=e=>ch((t,n)=>rve({scope:n,readable:e.evaluate(),onError:e.onError??ive,chunkSize:e.chunkSize,readSize:e.readSize,closeOnDone:e.closeOnDone})),rve=e=>{let t=e.readable,n=e.chunkSize??4096,r=e.closeOnDone??!0,i=e.exit??ah(void 0),a=e.latch??Yle(!1);function o(){a.openUnsafe()}t.on(`readable`,o);let s=ae(t,{readable:!0,writable:!1},t=>{i.current??=ws(t?e.onError(t):bs()),a.openUnsafe()}),c=Kc(function r(){let o=e.readable.read(e.readSize);if(o===null)return i.current?i.current:t.readableEnded?A(bs()):(a.closeUnsafe(),j(a.await,r));let s=Xr(o);for(;s.length<n&&(o=e.readable.read(e.readSize),o!==null);)s.push(o);return k(s)});return cl(Vs(e.scope,qc(()=>{t.off(`readable`,o),r?DS(t,s):s()})),c)},ive=e=>new Iie(e),AS=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),jS=(e,t,n)=>{let{commands:r}=BS(n),i=globalThis.process.platform===`win32`?`windows`:`posix`,a=r.map(e=>Yhe([e.command,...e.args],{format:i})).join(` | `);return ES(`ChildProcess`,e)(t,[a])},MS=e=>ld(e)?dd(e):e,ave=e=>{if(e.command.includes(`\0`))return`The command contains a NUL character`;let t=e.args.findIndex(e=>MS(e).includes(`\0`));if(t!==-1)return`Argument ${t+1} contains a NUL character`;for(let[t,n]of Object.entries(e.options.env??{}))if(n!==void 0&&MS(n).includes(`\0`))return`The environment variable ${t} contains a NUL character`},NS=1e3,PS=e=>{let t=()=>{};e.on(`error`,t),e.once(`close`,()=>e.off(`error`,t))},FS=e=>e.exitCode!==null||e.signalCode!==null,IS=(e,t)=>e.options.detached!==!1||!FS(t),LS=e=>e?.code===`EPERM`,RS=(e,t)=>{if(!FS(t))return!0;if(globalThis.process.platform===`win32`||!IS(e,t))return!1;try{return globalThis.process.kill(-t.pid,0),!0}catch(e){return LS(e)}},zS=(e,t=()=>{})=>{if(FS(e)){t(null);return}ee.execFile(`taskkill`,[`/pid`,String(e.pid),`/T`,`/F`],{windowsHide:!0},t)},ove=tc(Eb,Zc(function*(){let e=yield*gg,t=yield*bg,n=N(function*(n){if(!Xe(n.cwd))return yield*e.access(n.cwd),t.resolve(n.cwd)}),r=e=>{if(e.env===void 0)return;let t=e.extendEnv===!0?{...globalThis.process.env}:{};for(let[n,r]of Object.entries(e.env))r===void 0?delete t[n]:t[n]=MS(r);return t},i=e=>rg(e)?`pipe`:e,a=e=>Jh(e)?`pipe`:e,o=e=>{let t={stream:`pipe`,encoding:`utf-8`,endOnDone:!0};return Xe(e.stdin)?t:typeof e.stdin==`string`||rg(e.stdin)?{...t,stream:e.stdin}:{stream:e.stdin.stream,encoding:e.stdin.encoding??t.encoding,endOnDone:e.stdin.endOnDone??t.endOnDone}},s=(e,t)=>{let n=e[t];return Xe(n)?{stream:`pipe`}:typeof n==`string`||Jh(n)?{stream:n}:{stream:n.stream}},c=e=>{if(Xe(e.additionalFds))return[];let t=[];for(let[n,r]of Object.entries(e.additionalFds)){let e=Pb(n);Ze(e)&&t.push({fd:e,config:r})}return t.sort((e,t)=>e.fd-t.fd)},l=(e,t,n,r)=>{let o=[i(e.stream),a(t.stream),a(n.stream)];if(r.length===0)return o;let s=r.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=s;e++)o[e]=`ignore`;for(let{fd:e}of r)o[e]=`pipe`;return o},u=(e,t,n)=>Hl(fg(xde(e,e=>Ms(n,e)),t)),d=N(function*(e,t,n,r){if(n.length===0)return{getInputFd:()=>Zh,getOutputFd:()=>sg};let i=new Map,a=new Map,o=(t,n,a)=>Kc(()=>{let o=Zh;return n&&`write`in n&&(PS(n),o=OS({evaluate:()=>n,onError:n=>jS(`fromWritable(fd${t})`,AS(n),e)})),a?M(u(a,o,r),()=>{i.set(t,o)}):(i.set(t,o),Jc)}),s=(t,n,r)=>{let i=sg;if(n&&`read`in n){let r=new ie,a;r.on(`error`,e=>{a??=e}),n.on(`error`,e=>r.destroy(e)),n.pipe(r);let o=n=>jS(`fromReadable(fd${t})`,AS(n),e);i=ude(()=>a===void 0?kS({evaluate:()=>r,onError:o}):fde(o(a)))}r&&(i=ug(i,r)),a.set(t,i)};for(let{config:e,fd:r}of n){let n=t.stdio[r];switch(e.type){case`input`:yield*o(r,n,e.stream);break;case`output`:s(r,n,e.sink);break;case`duplex`:n&&`allowHalfOpen`in n&&(n.allowHalfOpen=!0),s(r,n,e.sink),yield*o(r,n,e.stream)}}return{getInputFd:e=>i.get(e)??Zh,getOutputFd:e=>a.get(e)??sg}}),f=(e,t,n,r)=>Kc(()=>{let i=Zh;return Qe(t.stdin)&&(PS(t.stdin),i=OS({evaluate:()=>t.stdin,onError:t=>jS(`fromWritable(stdin)`,AS(t),e),endOnDone:n.endOnDone,encoding:n.encoding})),rg(n.stream)?cl(u(n.stream,i,r),i):k(i)}),p=(e,t,n,r)=>{let i=t.stdout?(()=>{let n=new ie;return t.stdout.on(`error`,e=>n.destroy(e)),t.stdout.pipe(n),kS({evaluate:()=>n,onError:t=>jS(`fromReadable(stdout)`,AS(t),e)})})():sg,a=t.stderr?(()=>{let n=new ie;return t.stderr.on(`error`,e=>n.destroy(e)),t.stderr.pipe(n),kS({evaluate:()=>n,onError:t=>jS(`fromReadable(stderr)`,AS(t),e)})})():sg;Jh(n.stream)&&(i=ug(i,n.stream)),Jh(r.stream)&&(a=ug(a,r.stream));let o=vde(i,a);return{stdout:i,stderr:a,all:o}},m=(e,t)=>Yc(n=>{let r=Os(),i=ee.spawn(e.command,e.args.map(MS),t);return i.on(`error`,t=>{e.args.some(ld)&&Object.assign(t,{spawnargs:[e.command,...e.args.map(e=>ld(e)?`<redacted>`:e)]}),n(A(jS(`spawn`,t,e)))}),i.on(`exit`,(...e)=>{Is(r,Ss(e))}),i.on(`spawn`,()=>{n(k([i,r]))}),qc(()=>{i.kill(`SIGTERM`)})}),h=(e,t,n)=>globalThis.process.platform===`win32`?Yc(n=>{zS(t,t=>{n(t?A(jS(`kill`,AS(t),e)):Jc)})}):tl({try:()=>{globalThis.process.kill(-t.pid,n)},catch:t=>jS(`kill`,AS(t),e)}),g=(e,t)=>{if(globalThis.process.platform===`win32`){zS(e);return}try{globalThis.process.kill(-e.pid,t)}catch{}},_=(e,t,n)=>Kc(()=>{if(!t.kill(n)){let t=new globalThis.Error(`Failed to kill child process`);return A(jS(`kill`,t,e))}return Jc}),v=(e,t,n)=>Yc(r=>{let i=Date.now()+n,a,o=()=>{clearTimeout(a),t.removeListener(`exit`,s)},s=()=>{if(clearTimeout(a),Date.now()>=i||!RS(e,t)){o(),r(Jc);return}a=setTimeout(s,10)};return t.on(`exit`,s),s(),qc(o)}),y=N(function*(e,t,n,r){let i=n=>IS(e,t)?h(e,t,n).pipe(ul(r=>FS(t)&&LS(r.cause)?Jc:_(e,t,n))):_(e,t,n);yield*i(r?.killSignal??`SIGTERM`),Xe(r?.forceKillAfter)?(yield*As(n),yield*v(e,t,NS)):(yield*v(e,t,Ai(r.forceKillAfter)),RS(e,t)&&(yield*i(`SIGKILL`),yield*v(e,t,NS))),yield*As(n)}),b=(e,t)=>{let n=t??`stdout`;switch(n){case`stdout`:return e.stdout;case`stderr`:return e.stderr;case`all`:return e.all;default:{let t=Pb(n);return Ze(t)?e.getOutputFd(t):e.stdout}}},x=N(function*(e){switch(e._tag){case`StandardCommand`:{if(e.options.shell!==void 0&&e.options.shell!==!1&&e.args.length>0)return yield*A(Wh({module:`ChildProcess`,method:`spawn`,description:`The shell option cannot be combined with arguments; pass the whole script as the command`}));let t=ave(e);if(t!==void 0)return yield*A(Wh({module:`ChildProcess`,method:`spawn`,description:t}));let i=o(e.options),a=s(e.options,`stdout`),u=s(e.options,`stderr`),h=c(e.options),_=!0,v=yield*n(e.options),b=r(e.options),ee=l(i,a,u,h),x=N(function*(t,n){if(yield*Ns(n)){let[r]=yield*As(n);(r!==0&&Qe(r)||_&&process.platform!==`win32`&&e.options.detached!==!1)&&(yield*yl(y(e,t,n,e.options)));return}_&&(yield*yl(y(e,t,n,e.options)))}),te=Rs(),[ne,re]=yield*Ml(m(e,Q_e(e.options,{cwd:v,env:b,stdio:ee},process.platform)),([e,t],n)=>Uc([Ws(te,n),x(e,t)],{concurrency:`unbounded`,discard:!0})),ie=Khe(ne.pid);e.options.detached!==!1&&ne.on(`exit`,t=>{t!==0&&Qe(t)&&g(ne,e.options.killSignal??`SIGTERM`)});let ae=qc(()=>{_||=(ne.ref(),!0)}),S=qc(()=>(_&&=(ne.unref(),!1),ae)),oe=Os(),C=yield*zs(te)(f(e,ne,i,oe)),{all:se,stderr:ce,stdout:le}=p(e,ne,a,u),{getInputFd:ue,getOutputFd:w}=yield*zs(te)(d(e,ne,h,oe)),de=M(Ns(re),e=>!e),fe=j(Sl(As(re),As(oe)),([t,n])=>{if(Ps(oe))return As(oe);if(Qe(t))return k(Ghe(t));let r=new globalThis.Error(`Process interrupted due to receipt of signal: '${n}'`);return A(jS(`exitCode`,r,e))});return Tb({pid:ie,exitCode:fe,isRunning:de,kill:t=>y(e,ne,re,t),stdin:C,stdout:le,stderr:ce,all:se,getInputFd:ue,getOutputFd:w,unref:S})}case`PipedCommand`:{let{commands:t,pipeOptions:n}=BS(e),[r,...i]=t,a=[yield*x(r)];for(let e=0;e<i.length;e++){let t=i[e],r=n[e]??{},s=o(t.options),c=lg(k(b(a[a.length-1],r.from))),l=r.to??`stdin`;if(l===`stdin`)a.push(yield*x(Mb(t.command,t.args,{...t.options,stdin:{...s,stream:c}})));else{let e=Pb(l);if(Ze(e)){let n=gge(e),r=t.options.additionalFds??{},i=r[n],o=i?.type===`duplex`?{...i,stream:c}:{type:`input`,stream:c};a.push(yield*x(Mb(t.command,t.args,{...t.options,additionalFds:{...r,[n]:o}})))}else a.push(yield*x(Mb(t.command,t.args,{...t.options,stdin:{...s,stream:c}})))}}let s=a[a.length-1],c=e=>Wc([...a].reverse(),t=>yl(t.kill(e)),{discard:!0}),l=Zc(function*(){let e=[];for(let t of a)e.push(yield*t.unref);return Wc([...e].reverse(),e=>e,{discard:!0})});return Tb({pid:s.pid,exitCode:s.exitCode,isRunning:s.isRunning,kill:c,stdin:a[0].stdin,stdout:s.stdout,stderr:s.stderr,all:s.all,getInputFd:s.getInputFd,getOutputFd:s.getOutputFd,unref:l})}}});return Jhe(x)})),BS=e=>{let t=[],n=[],r=e=>{switch(e._tag){case`StandardCommand`:t.push(e);break;case`PipedCommand`:r(e.left),n.push(e.options),r(e.right)}};if(r(e),t.length===0)throw Error(`flattenCommand produced empty commands array`);let[i,...a]=t;return{commands:[i,...a],pipeOptions:n}},VS=e=>t=>Wh({module:`FileSystem`,method:e,description:t.message??String(t)}),HS=(e,t)=>{let n=Number(e);if(!Number.isSafeInteger(n))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return n},US=e=>dr(sr(e),boe),WS=e=>BigInt.asUintN(64,e),GS=e=>Cte(sr(e),WS),KS=(e,t)=>tl({try:()=>HS(e,`position`),catch:VS(t)}),sve=(()=>{let e=Kl(S.access,ES(`FileSystem`,`access`),VS(`access`));return(t,n)=>{let r=S.constants.F_OK;return n?.readable&&(r|=S.constants.R_OK),n?.writable&&(r|=S.constants.W_OK),e(t,r)}})(),cve=(()=>{let e=Kl(S.cp,ES(`FileSystem`,`copy`),VS(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),lve=(()=>{let e=Kl(S.copyFile,ES(`FileSystem`,`copyFile`),VS(`copyFile`));return(t,n)=>e(t,n)})(),uve=(()=>{let e=Kl(S.chmod,ES(`FileSystem`,`chmod`),VS(`chmod`));return(t,n)=>e(t,n)})(),dve=(()=>{let e=Kl(S.chown,ES(`FileSystem`,`chown`),VS(`chown`));return(t,n,r)=>e(t,n,r)})(),fve=(()=>{let e=Kl(S.link,ES(`FileSystem`,`link`),VS(`link`));return(t,n)=>e(t,n)})(),pve=(()=>{let e=Kl(S.mkdir,ES(`FileSystem`,`makeDirectory`),VS(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),qS=e=>{let n=Kl(S.mkdtemp,ES(`FileSystem`,e),VS(e));return e=>Kc(()=>{let r=e?.prefix??``,i=typeof e?.directory==`string`?a.join(e.directory,`.`):t.tmpdir();return n(r?a.join(i,r):i+`/`)})},mve=qS(`makeTempDirectory`),JS=e=>{let t=Kl(S.rm,ES(`FileSystem`,e),VS(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},hve=JS(`remove`),gve=(()=>{let e=qS(`makeTempDirectoryScoped`),t=JS(`makeTempDirectoryScoped`);return n=>Ml(e(n),e=>gl(t(e,{recursive:!0,force:!0})))})(),_ve=e=>{let{O_APPEND:t,O_CREAT:n,O_EXCL:r,O_RDONLY:i,O_RDWR:a,O_TRUNC:o,O_WRONLY:s}=S.constants;switch(e){case`r`:return i;case`r+`:return a;case`w`:return o|n|s;case`wx`:return o|n|s|r;case`w+`:return o|n|a;case`wx+`:return o|n|a|r;case`a`:return t|n|s;case`ax`:return t|n|s|r;case`a+`:return t|n|a;case`ax+`:return t|n|a|r}},vve=(e,t)=>Kc(()=>{let{O_NOFOLLOW:n}=S.constants;return process.platform===`win32`||typeof n!=`number`||n===0?A(Wh({module:`FileSystem`,method:e,description:`noFollow is not supported on this platform`})):k(_ve(t)|n)}),yve=(e=>{let t=Kl(S.open,ES(`FileSystem`,e),VS(e)),n=Kl(S.close,ES(`FileSystem`,e),VS(e));return(r,i)=>Le(Ml(i?.noFollow===!0?j(vve(e,i.flag??`r`),e=>t(r,e,i.mode)):t(r,i?.flag??`r`,i?.mode),e=>gl(n(e))),M(e=>bve(e,i?.flag?.startsWith(`a`)??!1)))})(`open`),YS=e=>Wh({module:`FileSystem`,method:e,description:`Cannot read before the start of the file`}),bve=(()=>{let e=e=>Kl(S.read,ES(`FileSystem`,e),VS(e)),t=e(`read`),n=e(`readAlloc`),r=Kl(S.fstat,ES(`FileSystem`,`stat`),VS(`stat`)),i=Kl(S.ftruncate,ES(`FileSystem`,`truncate`),VS(`truncate`)),a=Kl(S.fsync,ES(`FileSystem`,`sync`),VS(`sync`)),o=e=>{let t=Kl(S.write,ES(`FileSystem`,e),VS(e));return(e,n,r)=>t(e,n,0,n.length,r)},s=o(`write`),c=o(`writeAll`);class l{[_g];fd;append;position=BigInt(0);constructor(e,t){this[_g]=_g,this.fd=e,this.append=t}get stat(){return j(r(this.fd,{bigint:!0}),QS)}get sync(){return a(this.fd)}seek(e,t){return Kc(()=>{let n=t===`start`?e:this.position+e;return n<BigInt(0)?A(Wh({module:`FileSystem`,method:`seek`,description:`Cannot seek before the start of the file`})):(this.position=n,k(n))})}read(e,n){return Kc(()=>{let r=n?.position;if(r!==void 0)return r<BigInt(0)?A(YS(`read`)):t(this.fd,{buffer:e,position:r});let i=this.position;return M(t(this.fd,{buffer:e,position:i}),e=>(this.position=i+BigInt(e),e))})}readAlloc(e,t){return Kc(()=>{try{if(!Number.isInteger(e)||e<0)throw RangeError(`size must be a non-negative integer`);let r=t?.position;if(r!==void 0&&r<BigInt(0))return A(YS(`readAlloc`));let i=Buffer.allocUnsafeSlow(e),a=r??this.position;return M(n(this.fd,{buffer:i,position:a}),t=>{if(t===0)return O();if(r===void 0&&(this.position=a+BigInt(t)),t===e)return nr(i);let n=Buffer.allocUnsafeSlow(t);return i.copy(n,0,0,t),nr(n)})}catch(e){return A(VS(`readAlloc`)(e))}})}truncate(e){return M(i(this.fd,e||void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return Kc(()=>{let t=this.position;return j(this.append?k(void 0):KS(t,`write`),n=>M(s(this.fd,e,n),e=>(this.append||(this.position=t+BigInt(e)),e)))})}writeAllChunk(e){return Kc(()=>{let t=this.position;return j(this.append?k(void 0):KS(t,`writeAll`),n=>j(c(this.fd,e,n),n=>n===0?A(Uh({module:`FileSystem`,method:`writeAll`,_tag:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position=t+BigInt(n)),n<e.length?this.writeAllChunk(e.subarray(n)):Jc)))})}writeAll(e){return e.length===0?Jc:this.writeAllChunk(e)}}return(e,t)=>new l(e,t)})(),XS=e=>{let t=qS(e);return N(function*(e){let n=yield*t(e),r=_.randomBytes(6).toString(`hex`),i=a.join(n,e?.suffix?`${r}${e.suffix}`:r);return yield*tC(i,new Uint8Array),i})},xve=XS(`makeTempFile`),Sve=(()=>{let e=XS(`makeTempFileScoped`),t=JS(`makeTempFileScoped`);return n=>Ml(e(n),e=>gl(t(a.dirname(e),{recursive:!0,force:!0})))})(),Cve=(e,t)=>Gc({try:()=>S.promises.readdir(e,t),catch:t=>ES(`FileSystem`,`readDirectory`)(t,[e])}),wve=e=>Gc({try:()=>S.promises.readdir(e,{withFileTypes:!0}),catch:t=>ES(`FileSystem`,`readDirectoryEntries`)(t,[e])}).pipe(M(e=>e.map(e=>({name:e.name,type:ZS(e)})))),Tve=e=>Yc((t,n)=>{try{S.readFile(e,{signal:n},(n,r)=>{t(n?A(ES(`FileSystem`,`readFile`)(n,[e])):k(r))})}catch(e){t(A(VS(`readFile`)(e)))}}),Eve=(()=>{let e=Kl(S.readlink,ES(`FileSystem`,`readLink`),VS(`readLink`));return t=>e(t)})(),Dve=(()=>{let e=Kl(process.platform===`win32`?S.realpath.native:S.realpath,ES(`FileSystem`,`realPath`),VS(`realPath`));return t=>e(t)})(),Ove=(()=>{let e=Kl(S.rename,ES(`FileSystem`,`rename`),VS(`rename`));return(t,n)=>e(t,n)})(),ZS=e=>e.isFile()?`File`:e.isDirectory()?`Directory`:e.isSymbolicLink()?`SymbolicLink`:e.isBlockDevice()?`BlockDevice`:e.isCharacterDevice()?`CharacterDevice`:e.isFIFO()?`FIFO`:e.isSocket()?`Socket`:`Unknown`,QS=(e,t=`stat`)=>tl({try:()=>({type:ZS(e),mtime:sr(e.mtime),atime:sr(e.atime),birthtime:sr(e.birthtime),dev:WS(e.dev),rdev:GS(e.rdev),ino:GS(e.ino),mode:HS(e.mode,`mode`),nlink:GS(e.nlink),uid:US(e.uid),gid:US(e.gid),size:Gu(e.size),blksize:e.blksize===void 0?O():nr(Gu(e.blksize)),blocks:sr(e.blocks)}),catch:VS(t)}),$S=(e,t)=>{let n=Kl(t,ES(`FileSystem`,e),VS(e));return t=>j(n(t,{bigint:!0}),t=>QS(t,e))},eC=$S(`stat`,S.stat),kve=$S(`lstat`,S.lstat),Ave=(()=>{let e=Kl(S.symlink,ES(`FileSystem`,`symlink`),VS(`symlink`));return(t,n)=>e(t,n)})(),jve=(()=>{let e=Kl(S.truncate,ES(`FileSystem`,`truncate`),VS(`truncate`));return(t,n)=>e(t,n)})(),Mve=(()=>{let e=Kl(S.utimes,ES(`FileSystem`,`utime`),VS(`utime`));return(t,n,r)=>e(t,n,r)})(),Nve=(e,t,n)=>lde(r=>Ml(qc(()=>{let i=t.type===`Directory`?e:a.dirname(e),o=S.watch(e,{recursive:n?.recursive??!1},(e,t)=>{if(t)switch(e){case`rename`:Ul(Nae(eC(a.resolve(i,t)),{onSuccess:e=>ou(r,{_tag:`Create`,path:t}),onFailure:e=>ou(r,{_tag:`Remove`,path:t})}));return;case`change`:su(r,{_tag:`Update`,path:t});return}});return o.on(`error`,t=>{lu(r,jie(Uh({module:`FileSystem`,_tag:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t})))}),o.on(`close`,()=>{uu(r)}),o}),e=>qc(()=>e.close())).pipe(al(()=>qc(()=>n?.onReady?.())))),Pve=(e,t,n)=>Uc([eC(t),Ol(vg)]).pipe(M(([r,i])=>bte(i,()=>e).pipe(dr(e=>e.register(t,r,n)),or(()=>Nve(t,r,n)))),lg),tC=(e,t,n)=>Yc((r,i)=>{try{S.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?A(ES(`FileSystem`,`writeFile`)(t,[e])):Jc)})}catch(e){r(A(VS(`writeFile`)(e)))}}),Fve=M(Ol(vg),e=>Ede({access:sve,chmod:uve,chown:dve,copy:cve,copyFile:lve,link:fve,lstat:kve,makeDirectory:pve,makeTempDirectory:mve,makeTempDirectoryScoped:gve,makeTempFile:xve,makeTempFileScoped:Sve,open:yve,readDirectory:Cve,readDirectoryEntries:wve,readFile:Tve,readLink:Eve,realPath:Dve,remove:hve,rename:Ove,stat:eC,symlink:Ave,truncate:jve,utimes:Mve,watch(t,n){return Pve(e,t,n)},writeFile:tC})),Ive=tc(gg)(Fve),nC=e=>({fromFileUrl:t=>tl({try:()=>m.fileURLToPath(t,{windows:e}),catch:e=>new Vh({module:`Path`,method:`fromFileUrl`,cause:e})}),toFileUrl:t=>tl({try:()=>m.pathToFileURL(t,{windows:e}),catch:e=>new Vh({module:`Path`,method:`toFileUrl`,cause:e})})});({...a.posix,...nC(!1)}),{...a.win32,...nC(!0)};const Lve=$s(bg)(Dde({...a,...nC(void 0)})),Rve=$s(Ide,Lde({args:qc(()=>process.argv.slice(2)),stdinIsTerminal:qc(()=>process.stdin.isTTY===!0),stdoutIsTerminal:qc(()=>process.stdout.isTTY===!0),stderrIsTerminal:qc(()=>process.stderr.isTTY===!0),stdout:e=>OS({evaluate:()=>process.stdout,onError:e=>Uh({module:`Stdio`,method:`stdout`,_tag:`Unknown`,cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>OS({evaluate:()=>process.stderr,onError:e=>Uh({module:`Stdio`,method:`stderr`,_tag:`Unknown`,cause:e}),endOnDone:e?.endOnDone??!1}),stdin:kS({evaluate:()=>process.stdin,onError:e=>Uh({module:`Stdio`,method:`stdin`,_tag:`Unknown`,cause:e}),closeOnDone:!1})})),zve=tc(Ng,N(function*(e=rC){let t=yield*iu(),n=!1,r=!1,i=()=>{n=!0,r||uu(t)},a,o=()=>(a===void 0&&(a=process.stdin,a.readableEnded?i():a.once(`end`,i)),a);yield*Nl(()=>qc(()=>a?.off(`end`,i)));let s=yield*tg({acquire:Ml(qc(()=>{let e=o(),n=he.createInterface({input:e,escapeCodeTimeout:50}),i=e=>su(t,e),a=()=>{r=!1,uu(t)};return r=!0,he.emitKeypressEvents(e,n),n.on(`line`,i),n.once(`close`,a),{rl:n,onClose:a,onLine:i}}),({rl:e,onClose:i,onLine:a})=>qc(()=>{r=!1,e.off(`line`,a),e.off(`close`,i),e.close(),n&&uu(t)})),idleTimeToLive:`10 millis`}),c=e=>qc(()=>{let t=o();t.isTTY&&t.setRawMode(e)}),l=yield*tg({acquire:Ml(c(!0),()=>c(!1)),idleTimeToLive:`10 millis`}),u=qc(()=>process.stdout.columns??0),d=qc(()=>process.stdout.rows??0),f=Zc(function*(){let e=process.stdout,t=yield*Xae(1),n=()=>su(t,{columns:e.columns??0,rows:e.rows??0});return yield*Nl(()=>qc(()=>{e.off(`resize`,n),uu(t)})),e.on(`resize`,n),n(),t}),p=Zc(function*(){let t=o(),r=yield*iu(),i=(t,n)=>{let i={input:cr(t),key:{name:n.name??``,ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};su(r,i),e(i)&&uu(r)},a=setInterval(()=>{},2147483647),c=()=>{clearInterval(a),uu(r)};return yield*Nl(()=>qc(()=>{clearInterval(a),t.off(`keypress`,i),t.off(`end`,c)})),t.on(`keypress`,i),n?c():(yield*ng(s),yield*ng(l),t.once(`end`,c)),r}),m=Kc(()=>$ae(t).pipe(j(ar({onNone:()=>jl(il(ng(s),pu(t))),onSome:k})),hl(()=>new Mg({}))));return zde({columns:u,rows:d,size:f,readInput:p,readLine:m,display:e=>Rae(Yc(t=>{process.stdout.write(e,e=>bee(e)?t(Jc):t(A(Wh({module:`Terminal`,method:`display`,description:`Failed to write prompt to stdout`,cause:e}))))}))})})(rC));function rC(e){let t=e.key;return t.name===`escape`||t.ctrl&&(t.name===`c`||t.name===`d`)}const Bve=Yie(ove,ac(Ive,Lve,Rve,zve)),Vve=e=>Z_e(e.pipe(El(Bve),fl(e=>Sg(Pie(e)).pipe(cl(1))),al(e=>qc(()=>{process.exitCode=e}))),{disableErrorReporting:!0}),iC=(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}}},aC={pipe(){return iC(this,arguments)}},oC=function(){function e(){}return e.prototype=aC,e}(),sC=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)}}}},cC=e=>e,lC=e=>()=>e,Hve=lC(!0),Uve=lC(!1),uC=lC(void 0),dC=uC;function fC(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 pC(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!==n&&t.set(i,i),i}}const Wve=[`line`,`column`,`sourceURL`,`originalLine`,`originalColumn`],mC=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;if(e instanceof Error){t.delete(`stack`);for(let n of Wve)Object.prototype.propertyIsEnumerable.call(e,n)||t.delete(n)}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},hC=new WeakSet,gC=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),_C=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,vC=e=>{try{return new Uint8Array(e)}catch{return}};let yC=0;const Gve=()=>{yC++};function bC(e){return typeof e==`string`}function xC(e){return typeof e==`number`}function Kve(e){return typeof e==`boolean`}function qve(e){return typeof e==`symbol`}function Jve(e){return bC(e)||xC(e)||qve(e)}function SC(e){return typeof e==`function`}function Yve(e){return e!=null}function Xve(e){return!0}function CC(e){return typeof e==`object`&&!!e||SC(e)}const wC=sC(2,(e,t)=>CC(e)&&t in e),Zve=sC(2,(e,t)=>wC(e,`_tag`)&&e._tag===t),TC=`~effect/Hash`,EC=e=>{switch(typeof e){case`number`:return MC(e);case`bigint`:return NC(e.toString(10));case`string`:return NC(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?NC(`Invalid Date`):NC(e.toISOString());if(e instanceof RegExp)return NC(e.toString());{if(hC.has(e))return DC(e);let t=zC.get(e);if(t!==void 0)return t;if(BC.has(e))return Gve(),NC(`[Circular]`);BC.add(e);let n=yC,r;try{if(Qve(e))r=e[TC]();else if(typeof e==`function`)r=DC(e);else if(_C(e)){let t=vC(e);r=t===void 0?DC(e):IC(t)}else r=e instanceof DataView?IC(gC(e)):Array.isArray(e)||ArrayBuffer.isView(e)?IC(e):e instanceof Map?eye(e):e instanceof Set?tye(e):PC(e)}finally{BC.delete(e)}return n===yC&&zC.set(e,r),r}}return AC(OC(NC(String(e))))},DC=e=>(RC.has(e)||RC.set(e,AC(Math.random()*4294967296|0)),RC.get(e)),OC=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),kC=sC(2,(e,t)=>OC(Math.imul(e,2654435761)+Math.imul(t,2246822507))),AC=e=>e&3221225471|e>>>1&1073741824,Qve=e=>wC(e,`~effect/Hash`)&&typeof e[`~effect/Hash`]==`function`,jC=new DataView(new ArrayBuffer(8)),MC=e=>{let t=e|0;return t===e?AC(t):(jC.setFloat64(0,e===e?e:NaN),AC(kC(jC.getInt32(0),jC.getInt32(4))))},NC=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return AC(t)},$ve=(e,t)=>{let n=12289;for(let r of t)n^=kC(EC(r),EC(e[r]));return AC(n)},PC=e=>$ve(e,mC(e)),FC=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return AC(r)},IC=e=>{let t=6151;for(let n of e)t=kC(t,EC(n));return AC(t)},eye=FC(NC(`Map`),([e,t])=>kC(EC(e),EC(t))),LC=NC(`Set`),tye=FC(LC,e=>kC(LC,EC(e))),RC=new WeakMap,zC=new WeakMap,BC=new WeakSet,VC=`~effect/Equal`;function HC(){return arguments.length===1?e=>UC(e,arguments[0]):UC(arguments[0],arguments[1])}function UC(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`||hC.has(e)||hC.has(t)?!1:nye(e,t):!1}function nye(e,t){let n=GC.length;for(let r=n;r-->0;)if(GC[r]===e&&KC[r]===t)return!0;if(n)return WC(e,t);let r=qC.get(e);r||qC.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=WC(e,t)),i}function WC(e,t){GC.push(e),KC.push(t);try{return rye(e,t)}finally{GC.pop(),KC.pop()}}const GC=[],KC=[],qC=new WeakMap;function rye(e,t){if(EC(e)!==EC(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=XC(e);if(n!==XC(t)||typeof e==`function`&&!n)return!1;if(n)return e[VC](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:iye(e,t);if(_C(e)){if(!_C(t)||e instanceof ArrayBuffer!=t instanceof ArrayBuffer)return!1;let n=vC(e),r=vC(t);return n!==void 0&&r!==void 0&&JC(n,r)}if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?JC(gC(e),gC(t)):JC(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:YC(e,t,oye,sye):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:YC(e,t,EC,UC):aye(e,t)}function iye(e,t){for(let n=0;n<e.length;n++)if(!UC(e[n],t[n]))return!1;return!0}function JC(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 aye(e,t){let n=mC(e),r=mC(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!UC(e[i],t[i]))return!1;return!0}function YC(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop(),a--;continue outer}}return!1}return a===0}const oye=e=>EC(e[0]),sye=(e,t)=>UC(e[0],t[0])&&UC(e[1],t[1]),XC=e=>wC(e,`~effect/Equal`)&&typeof e[`~effect/Equal`]==`function`,ZC=Symbol.for(`~effect/Redactable`),cye=e=>wC(e,ZC);function QC(e){return cye(e)?$C(e):e}function $C(e){return e[ZC](globalThis[`~effect/Fiber/currentFiber`]?.context??lye)}const ew=`~effect/Fiber/currentFiber`,tw=new Map,lye={"~effect/Context":{},base:tw,depth:0,mapUnsafe:tw,pipe(){return iC(this,arguments)}};function nw(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,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(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 uye;r.add(e);let l;if(ZC in e)l=c($C(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(`,
|
|
259
|
+
`,{mode:384}),yield*(yield*n.open(i,{flag:`r`})).sync,yield*n.rename(i,d(e,`receipt.json`)),yield*(yield*n.open(e,{flag:`r`})).sync,yield*B_e(e)},jl),bS=(e,t)=>Hr(e)?{reply:e.success.reply,readAt:e.success.readAt}:e.failure._tag===`AwsReadError`?e.failure.observation??{reply:null,readAt:t}:e.failure._tag===`UsageError`?{reply:null,readAt:t}:{reply:e.failure.reply,readAt:e.failure.readAt},V_e=(e,t,n,r,i)=>{let a={instances:[],ok:!1,reply:null,readAt:r},o=e=>e!==void 0&&(e.ok||e.notStarted===`deadline`)?e:a,s=i!==void 0&&i.tokens.length===t.length&&t.every(e=>i.tokens.includes(e)),c={byRunTag:o(i?.byRunTag),byClientToken:s?o(i.byClientToken):a},l={tokens:t,byRunTag:a,byClientToken:a,ok:!1},u=new Map,d=new Map;return{search:N(function*(r){let i=yield*cb,o=[],s=!1;l={...l,byRunTag:{...l.byRunTag,ok:!1},byClientToken:{...l.byClientToken,ok:!1},ok:!1};for(let f of[`byRunTag`,`byClientToken`]){let p=f===`byRunTag`?`run-tag search`:`client-token search`;d.has(p)||d.set(p,{item:p,reason:`This filtered search has not completed.`,next:`Run retire again to complete this search.`});let m=yield*lx(n);l={...l,[f]:{...a,readAt:od(yield*id)}};let h=yield*(f===`byRunTag`?i.describeInstanceResources({by:`run`,run:e},m):i.describeInstanceResourcesByTokens(t,m)).pipe(ol),g=bS(h,od(yield*id)),_;if(Vr(h)){let e=h.failure,t=e._tag===`AwsReadError`&&e.reason===`budget`;_=t?{...c[f],notStarted:`deadline`,ok:!1}:{...g,instances:[],ok:!1};let n=ob(e);d.set(p,{item:p,reason:t?u.has(p)?sb(u.get(p)??e):`No read was started for lack of time.`:`${n.operation} ${n.code}: ${n.message}`,next:`Run retire again to complete this search.`}),t&&d.set(`deadline`,{item:`deadline`,reason:`No read was started for lack of time in the retirement deadline.`,next:`Run retire again to obtain fresh proofs.`}),ib(e)?u.set(p,e):s=!0}else{u.delete(p),o.push(...h.success.value);let e=h.success.value.flatMap(({id:e,state:t,token:n})=>e===null?[]:[{id:e,state:t,token:n}]),t=e.length===h.success.value.length;_={...g,instances:e,ok:t},t?(c[f]=_,d.delete(p)):(d.set(p,{item:p,reason:`The provider listed an instance without an ID.`,next:`Repeat the search to identify every listed instance.`}),s=!0)}l={...l,[f]:_},Hr(h)&&(yield*r(h.success.value))}return l={...l,ok:l.byRunTag.ok&&l.byClientToken.ok},{listed:o,ok:l.ok,stop:s}}),reads:()=>l,issues:d,expire:()=>{for(let[e,t]of u){let n=d.get(e);n&&d.set(e,{...n,reason:sb(t)})}}}},H_e=(e,t,n,r)=>{if(Hr(t)&&t.success.value.some(t=>t.id===e&&t.state===`terminated`))return`terminated`;if(r)return`unproven`;if(Hr(t))return t.success.value.length===0?`not-listed-after-earlier-read`:`unproven`;if(t.failure._tag!==`InvalidInstanceID.NotFound`||n===void 0)return`unproven`;let i=rd(n),a=rd(t.failure.readAt);return ir(i)&&ir(a)&&ad(a.value)-ad(i.value)>=3e5?`not-found-after-earlier-read`:`unproven`},U_e=N(function*(e,t){let n=yield*cb,r=od(yield*id);if(e.kind===`ebs-volume`){let i=yield*n.describeVolume(e.id,t).pipe(ol),a=Vr(i)&&i.failure._tag===`InvalidVolume.NotFound`?`InvalidVolume.NotFound`:Hr(i)&&i.success.value.some(t=>t.id===e.id&&t.state===`deleted`)?`deleted`:`unproven`;return{resource:{...e,...bS(i,r),proof:a},error:Vr(i)&&a===`unproven`?i.failure:void 0}}let i=yield*n.describeNetworkInterface(e.id,t).pipe(ol),a=Vr(i)&&i.failure._tag===`InvalidNetworkInterfaceID.NotFound`?`InvalidNetworkInterfaceID.NotFound`:`unproven`;return{resource:{...e,...bS(i,r),proof:a},error:Vr(i)&&a===`unproven`?i.failure:void 0}}),xS=id.pipe(M(od)),SS=e=>[{kind:`ec2-instance`,id:e.id},...Array.from(new Set([e.rootVolumeId,...e.volumeIds]),e=>({kind:`ebs-volume`,id:e})),...e.networkInterfaceIds.map(e=>({kind:`network-interface`,id:e}))],W_e=e=>vS(e.directory,e.record).pipe(M(t=>K_e(e,t))),G_e=e=>rl(W_e(e)),K_e=N(function*(e,t){let{directory:n}=e,r=e.record,i=yield*gg,a=yield*cb,o=yield*xS,s=yield*cx(e.within),c,l=()=>new Cx({securityGroupId:r.intent.securityGroupId,operation:`DescribeSecurityGroups`,kind:`process`,message:`The retirement deadline expired during the account check; no termination was sent.`+(c===void 0?``:` Deadline reached while ${c.code} persisted: ${c.message}`)}),u=yield*lx(s).pipe(hl(l),j(e=>wx(r.intent.securityGroupId,e)),hl(e=>{if(e._tag===`AccountCheckFailed`){if(e.budget&&c!==void 0)return l();e.retryable&&(c=e)}return e}),vl({schedule:dx,while:e=>e._tag===`AccountCheckFailed`&&e.retryable===!0}),bl({duration:yield*ux(s).pipe(hl(l)),orElse:()=>A(l())})),f=yield*mx(n,r.steps);r={...r,steps:f.steps},r.instance!==void 0&&(r.phase===`retiring`||t?.terminationAttemptedFor===r.instance.id||t?.ended===`retire`&&t.recordedInstanceId===r.instance.id)&&f.attempted.add(r.instance.id);let p=Array.from(new Set([r.intent.clientToken,...r.refusals.map(e=>e.clientToken)])),m=V_e(r.run,p,s,o,t?.filteredReads),h=new Map;for(let e of t?.resources??[])h.set(e.id,{...e,proof:`unproven`});let g=(e,t)=>{h.has(t)||h.set(t,{kind:e,id:t,reply:null,proof:`unproven`,readAt:o,...e===`ec2-instance`?{attachmentInventory:`observed`}:{}})};if(r.instance!==void 0)for(let e of SS(r.instance))g(e.kind,e.id);let _=new Map((t?.unproven??[]).filter(e=>e.item.startsWith(`inventory:`)).map(e=>[e.item,e]));for(let e of h.values())if(typeof e.attachmentInventory==`object`){let t=`inventory:${e.id}`;_.set(t,{item:t,reason:`Attachment inventory requires fresh run-tag searches.`,next:`Run retire again to read both attachment types.`})}let v=new Set(Array.from(h.values()).filter(e=>e.kind===`ec2-instance`&&!_.has(`inventory:${e.id}`)).map(e=>e.id));r.instance?.networkInterfaceIds.length===0&&(v.delete(r.instance.id),_.set(`inventory:${r.instance.id}`,{item:`inventory:${r.instance.id}`,reason:`No interface ID was recorded.`,next:`Recover the original interface ID before claiming release.`}));let y=new Set,b=new Map,ee=new Set,x=new Map,te=new Map,ne=new Map,re=e=>{let n=ne.get(e),r=t?.resources.some(t=>t.kind===`ec2-instance`&&t.id===e)?t.ended:void 0;return f.acknowledged.has(e)?`retire`:n===`Client.InstanceInitiatedShutdown`||n===void 0&&r===`guest-shutdown`?`guest-shutdown`:!f.attempted.has(e)&&(n===`Client.UserInitiatedShutdown`||n===void 0&&r===`other-terminate`)?`other-terminate`:`unknown`},ie=()=>{let e=Array.from(h.values()).filter(e=>e.kind===`ec2-instance`).map(e=>re(e.id));return e.length>0&&e.every(t=>t===e[0])?e[0]??`unknown`:`unknown`},ae=()=>({recordPhase:r.phase,recordedInstanceId:r.instance?.id??null,resources:Array.from(h.values()),filteredReads:m.reads()}),S=()=>{let e=new Map([...te,..._,...x,...m.issues]);for(let t of h.values())t.proof===`unproven`&&!e.has(t.id)&&e.set(t.id,{item:t.id,reason:`The exact read has not established absence.`,next:`Run retire again to read this resource.`});return{schema:hS,...ae(),...r.instance!==void 0&&f.attempted.has(r.instance.id)&&!f.acknowledged.has(r.instance.id)?{terminationAttemptedFor:r.instance.id}:{},run:r.run,region:r.region,os:r.os,status:`unproven`,ended:ie(),accountCheck:{securityGroupId:r.intent.securityGroupId,ok:!0,reply:u.reply,readAt:u.readAt},localFiles:{removed:[],absent:!1},unproven:Array.from(e.values()),startedAt:o,endedAt:o}},oe=(e,t,n)=>{x.set(e,{item:e,reason:ob(t).message,next:n}),t._tag===`AwsReadError`&&t.reason===`budget`&&x.set(`deadline`,{item:`deadline`,reason:`No read was started for lack of time in the retirement deadline.`,next:`Run retire again to finish the outstanding proofs.`})},C=new Map,se=(e,t,n)=>{if(ib(t))C.set(e,t),te.set(e,{item:e,reason:ob(t).message,next:n});else{oe(e,t,n);let r=C.get(e);r!==void 0&&t._tag===`AwsReadError`&&t.reason===`budget`&&x.set(e,{item:e,reason:sb(r),next:n}),C.delete(e)}},ce=e=>lx(s).pipe(j(t=>a.describeInstances({by:`id`,id:e},t).pipe(ol))),le=N(function*(e,t,i){let o=e.id,c=i??(yield*ce(o)),l=Hr(c)?c.success.value.find(e=>e.id===o):void 0,u=r.instance?.id===o?r.instance.launchedAt:b.get(o)?.launch??e.launchedAt,d=Hr(c)?c.success.value.length===0:c.failure._tag===`InvalidInstanceID.NotFound`,p=l?.state===`terminated`?void 0:l??(d?t:void 0);if(p!==void 0&&v.has(o)){if(r.instance?.id!==o&&!b.has(o)||p.tags?.find(e=>e.Key===`ot-run`)?.Value!==r.run)x.set(o,{item:o,reason:`Termination requires this record's ID or token and its matching ot-run tag.`,next:`Verify custody before attempting retirement again.`});else if(!ee.has(o)&&!f.acknowledged.has(o)){h.set(o,{...e,...bS(c,yield*xS),proof:`unproven`}),r=yield*Hx(n,{...r,phase:`retiring`}),yield*yS(n,{...S(),endedAt:yield*xS});let t=yield*lx(s);ee.add(o),f.attempted.add(o);let i=yield*a.terminateInstance(o,t).pipe(ol);r=yield*Hx(n,r),Vr(i)?oe(o,i.failure,`Run retire again to reconcile the request; it may have reached AWS.`):sx(o,i.success.value)&&f.acknowledged.add(o),c=yield*ce(o),l=Hr(c)?c.success.value.find(e=>e.id===o):void 0}}let m=H_e(o,c,u,t!==void 0);return h.set(o,{...e,...bS(c,yield*xS),proof:m}),l?.state===`terminated`&&l.reason!==null&&ne.set(o,l.reason.Code),te.delete(o),(Hr(c)||c.failure._tag===`InvalidInstanceID.NotFound`)&&C.delete(o),Vr(c)&&(c.failure._tag===`InvalidInstanceID.NotFound`?m===`unproven`&&t===void 0&&te.set(o,{item:o,reason:`not-found-too-soon: the NotFound reply does not establish absence.`,next:`Read again after the recorded launch is at least five minutes old.`}):se(o,c.failure,`Run retire again to complete the instance proof.`)),c}),ue=N(function*(e){for(let t of h.values()){if(t.kind===`ec2-instance`||t.proof!==`unproven`||e.has(t.id))continue;e.add(t.id);let n=yield*U_e(t,yield*lx(s));h.set(t.id,n.resource),te.delete(t.id),n.error===void 0&&C.delete(t.id),n.error!==void 0&&se(t.id,n.error,`Run retire again to complete the attachment proof.`)}}),w=N(function*(e){for(let t of e){if(t.id===null)continue;let e=t.id;if(t.token!==null&&p.includes(t.token)){b.set(e,t),g(`ec2-instance`,e);let i=Ox(t);if(i!==void 0){for(let e of SS(i))g(e.kind,e.id);let t=h.get(e);if(t!==void 0){let{launchedAt:n,...r}=t;h.set(e,{...r,attachmentInventory:`observed`})}v.add(e),_.delete(`inventory:${e}`),r.instance===void 0&&(r=yield*Hx(n,{...r,instance:i,phase:`created`}))}else if(!v.has(e)&&!y.has(e)){let n=h.get(e);n!==void 0&&h.set(e,{...n,...t.launch===null?{}:{launchedAt:t.launch},attachmentInventory:typeof n.attachmentInventory==`object`?n.attachmentInventory:{volumes:null,interfaces:null}}),_.set(`inventory:${e}`,{item:`inventory:${e}`,reason:`The token lookup did not recover complete volume and interface custody.`,next:`Run retire again to recover the attachment IDs from the instance or its run tags after it ends.`})}}}}),de=N(function*(e,t){let i=e===`ebs-volume`?`volume tag search`:`interface tag search`,o=yield*lx(s),c={by:`run`,run:r.run},l=e===`ebs-volume`?yield*a.describeVolume(c,o).pipe(ol):yield*a.describeNetworkInterface(c,o).pipe(ol),u=Hr(l)?l.success.value.flatMap(e=>e.id===null?[]:[e.id]):[],d=e===`ebs-volume`?`volumes`:`interfaces`,f={...bS(l,yield*xS),ids:u,ok:Hr(l)&&u.length===l.success.value.length};for(let e of t){let t=h.get(e.id)??e,n=typeof t.attachmentInventory==`object`?t.attachmentInventory:{volumes:null,interfaces:null};h.set(t.id,{...t,attachmentInventory:{...n,[d]:f}})}if(te.delete(i),Vr(l))return se(i,l.failure,`Run retire again to complete the attachment inventory.`),!1;C.delete(i);let p=h.size;for(let t of l.success.value)t.id===null?x.set(i,{item:i,reason:`The run-tag search returned an attachment without an ID.`,next:`Read the attachment inventory again before release.`}):g(e,t.id);return h.size!==p&&(yield*yS(n,{...S(),endedAt:yield*xS})),l.success.value.length===0}),fe=yield*Zc(function*(){yield*ux(s),x.clear();let e=new Map;for(let t of h.values())t.kind===`ec2-instance`&&t.proof===`unproven`&&(t.id===r.instance?.id||b.has(t.id))&&v.has(t.id)&&e.set(t.id,yield*le(t,void 0));let t=new Set;yield*ue(t);let n=r.instance===void 0?void 0:h.get(r.instance.id),i=n===void 0?void 0:e.get(n.id),a=n?.proof===`terminated`||i!==void 0&&Hr(i)&&i.success.value.some(e=>e.id===n?.id),o=i!==void 0&&Vr(i)&&ib(i.failure);if((a||o)&&x.size===0&&_.size===0&&Array.from(h.values()).some(e=>e.proof===`unproven`&&(e.kind!==`ec2-instance`||e.id===n?.id)))return!1;let c=Zc(function*(){let n=yield*m.search(w),i=new Map;for(let e of n.listed)e.id!==null&&e.state!==`terminated`&&i.set(e.id,e);for(let e of n.listed)e.id!==null&&!h.has(e.id)&&!Ex(r,e)&&x.set(e.id,{item:e.id,reason:`other-instance-listed: this ID has neither recorded custody nor proof of foreign terminated history.`,next:`Resolve the other instance's custody without terminating it by tag.`});for(let t of h.values()){if(t.kind!==`ec2-instance`||t.proof===`terminated`)continue;let n=i.get(t.id);(n!==void 0||!e.has(t.id)&&t.proof===`unproven`)&&e.set(t.id,yield*le(t,n,e.get(t.id)))}let a=Array.from(h.values()).filter(e=>e.kind===`ec2-instance`&&e.proof!==`unproven`&&_.has(`inventory:${e.id}`)&&(b.has(e.id)||e.id!==r.instance?.id)),o=!1;if(a.length!==0){let e=yield*de(`ebs-volume`,a),t=yield*de(`network-interface`,a);o=e&&t}if(yield*ue(t),o&&Array.from(h.values()).every(e=>e.kind===`ec2-instance`||e.proof!==`unproven`))for(let e of a)y.add(e.id),_.delete(`inventory:${e.id}`);let s=Array.from(_.keys()).some(e=>!a.some(t=>`inventory:${t.id}`===e)&&!te.has(e.slice(10))&&!n.listed.some(t=>`inventory:${t.id}`===e&&t.state!==`terminated`));return{ok:n.ok,stop:n.stop||x.size!==0||n.ok&&s,needsInventory:_.size!==0}}),l=yield*c;if(l.stop)return!0;if(!l.ok||l.needsInventory)return!1;if(h.size===0)return mS(ae())===`nothing-created`||(x.set(`instance`,{item:`instance`,reason:`The requested attempt has not been found; creation remains unproven.`,next:`Run retire again to repeat every recorded token and run-tag lookup.`}),!1);if(Array.from(h.values()).some(e=>e.proof===`unproven`))return!1;let u=yield*c;return u.stop||u.ok&&!u.needsInventory&&mS(ae())===`released`}).pipe(Bl({until:e=>e,schedule:dx}),bl({duration:yield*ux(s),orElse:()=>k(!1)}),ol);if(Vr(fe)?x.set(`retirement`,{item:`retirement`,reason:fe.failure.message,next:`Resolve this failure and run retire again; preserve the record.`}):fe.success||x.set(`deadline`,{item:`deadline`,reason:`The retirement deadline of ${Ai(e.within)} ms expired before all proofs completed.`,next:`Run retire again; keep the keys until every proof succeeds.`}),(Vr(fe)||!fe.success)&&m.expire(),Vr(fe)||!fe.success)for(let[e,t]of C){let n=te.get(e);n&&te.set(e,{...n,reason:sb(t)})}let T=S(),pe=T.unproven.length===0?mS(T):`unproven`,me=[],E=pe!==`unproven`;if(E)for(let e of[`id_ed25519`,`id_ed25519.pub`]){let t=d(n,e),r=yield*i.remove(t).pipe(ol);Hr(r)?me.push(e):r.failure.reason._tag!==`NotFound`&&(E=!1,x.set(e,{item:e,reason:r.failure.message,next:`Resolve local file access and run retire again.`}));let a=yield*i.lstat(t).pipe(ol);(Hr(a)||a.failure.reason._tag!==`NotFound`)&&(E=!1,x.set(e,{item:e,reason:Hr(a)?`The key file is still present.`:a.failure.message,next:`Resolve local file access and run retire again.`}))}let he=E?pe:`unproven`;return he===`released`&&(yield*Hx(n,{...r,phase:`retired`})),yield*yS(n,{...S(),status:he,ended:he===`nothing-created`?`not-created`:ie(),localFiles:{removed:me,absent:E},endedAt:yield*xS})}),CS={version:`0.2.1`,commit:`ffb8ce2e8087fe79344ef888bc23acc2bde39fc3`},wS=Ule.check(Rm(e=>Si(e)&&Ai(e)>0,{message:`Use a positive finite duration, such as '20 minutes'.`})),q_e=wS.check(Rm(e=>Ai(e)<=Ai(tne(24)),{message:`--need must be at most 24 hours.`})),TS=Gm.check(zm(/^[^\r\n\0]+$/)),J_e=qpe({present:e=>Zc(function*(){let t=yield*uv;e._tag===`InvalidInvocation`?(yield*Sg(t.formatHelpDoc(e.helpDoc)),yield*Sg(t.formatErrors(e.errors))):e._tag===`Help`&&e.reason===`Implicit`?yield*Sg(t.formatHelpDoc(e.helpDoc)):yield*dv.present(e)})}),Y_e=N(function*(e,t){let n=yield*wg(0),r=Xy(`create`,{directory:ty(`dir`).pipe(ly(TS),ay(`Private directory for this run's durable record and access files.`)),profile:ty(`profile`).pipe(ly(TS),ay(`AWS profile alias; required.`)),region:ty(`region`).pipe(ly(TS),sy,ay(`Region for a new run; defaults to us-west-2. Resumed runs use their record.`)),run:ty(`run`).pipe(ly(vx),ay(`Unique run name, at most 48 lowercase letters, digits and hyphens.`)),owner:ty(`owner`).pipe(ly(Xb),ay(`Handle responsible for this run.`)),os:Mme(`os`,[`windows`]).pipe(ay(`Guest operating system; Windows is implemented.`)),instanceType:ty(`type`).pipe(ly(TS),ay(`EC2 instance type; for example m7i.large.`)),need:ty(`need`).pipe(ly(q_e),ay(`Lifetime, such as '4 hours'; at most 24 hours.`)),rootGiB:jme(`root-gib`).pipe(cy(100),ly(Hm.check(Rm(e=>e>0))),ay(`Encrypted gp3 root volume size; defaults to 100 GiB.`)),imageId:ty(`image`).pipe(ly(Xb),sy,ay(`Explicit Amazon AMI; otherwise select Server 2025 Full Base aged at least three days.`)),within:ty(`within`).pipe(cy(`20 minutes`),ly(wS),ay(`One deadline for all create work; defaults to '20 minutes'.`))},N(function*(e){if(fb(e.profile)!==e.profile)return yield*new ub({message:`Use a profile whose name has no account ID (an alias in ~/.aws/config).`});yield*Wc([[`directory`,e.directory],[`owner`,e.owner],[`instance type`,e.instanceType],[`root size`,String(e.rootGiB)]],([e,t])=>pb(e,t));let r=p(e.directory);yield*pb(`directory`,r);let a=yield*Bx(r).pipe(hl(()=>new ub({message:`Cannot read a valid record.json from --dir.`}))),o=or(e.region,()=>a?.region??`us-west-2`);if(yield*pb(`region`,o),a!==void 0&&(a.run!==e.run||a.region!==o))return yield*new ub({message:`The record belongs to another run or region.`});let s=yield*cx(e.within),c=yield*Zc(function*(){yield*Rx(r);let n=a?.helper??CS??{version:`0.0.0`,commit:yield*M_e(r,t,s)};return yield*j_e({directory:r,profile:e.profile,region:o,run:e.run,owner:e.owner,instanceType:e.instanceType,rootGiB:e.rootGiB,need:e.need,within:e.within,helper:n,environment:t,...ir(e.imageId)?{imageId:e.imageId.value}:{}},s).pipe(El(_x({profile:e.profile,region:o,environment:t,temporaryDirectory:t.TMPDIR??i(),within:(yield*lx(s)).within,...a?.phase===`reachable`?{}:{evidenceDirectory:r}})))}).pipe(ol);if(Hr(c))return yield*Cg(fx(yield*Sx(c.success)));{let e=c.failure;if(e._tag===`UsageError`)return yield*e;yield*Sg(e.message);let t=yield*Bx(r);return t===void 0?yield*Sg(`Nothing was requested; no record was written.`):yield*Cg(fx(yield*Sx(t))),yield*Eg(n,e._tag===`AccountCheckFailed`?3:e._tag===`LifecycleError`?e.exitCode:1)}})).pipe(Zy(`Create or resume one Windows EC2 instance, arm its end and verify SSH access. Prints the record.`)),a=Xy(`reach`,{directory:ty(`dir`).pipe(ly(TS),ay(`Private run directory containing the record and SSH key.`)),profile:ty(`profile`).pipe(ly(TS),ay(`AWS profile alias; the exact recorded group verifies the account.`))},N(function*({directory:e,profile:r}){if(fb(r)!==r)return yield*new ub({message:`Use a profile whose name has no account ID (an alias in ~/.aws/config).`});let a=p(e);yield*pb(`directory`,a);let o=yield*Bx(a).pipe(hl(()=>new ub({message:`Cannot read a valid record.json from --dir.`})));if(o===void 0)return yield*new ub({message:`reach requires record.json from create.`});yield*vm(TS)(o.region).pipe(hl(()=>new ub({message:`The recorded region is invalid.`}))),yield*pb(`region`,o.region);let s=yield*cx(ki(20)),c=yield*P_e(a,o,{profile:r,environment:t},s).pipe(El(_x({profile:r,region:o.region,environment:t,temporaryDirectory:t.TMPDIR??i(),within:(yield*lx(s)).within,evidenceDirectory:a})),ol);if(Hr(c))return yield*Cg(fx(yield*Sx(c.success)));{let e=c.failure;return e._tag===`UsageError`?yield*e:(yield*Sg(e.message),yield*Cg(fx(yield*Sx(o))),yield*Eg(n,e._tag===`AccountCheckFailed`?3:1))}})).pipe(Zy(`Recheck the end and pinned host key, rebuild access files, and verify one SSH command. Uses the record's region.`)),o=Xy(`extend`,{directory:ty(`dir`).pipe(ly(TS),ay(`Private run directory containing record.json.`)),profile:ty(`profile`).pipe(ly(TS),ay(`AWS profile for the recorded account and region.`)),to:ty(`to`).pipe(ly(yx),ay(`New UTC end, YYYY-MM-DDTHH:mm:ssZ.`))},N(function*({directory:e,profile:r,to:a}){if(fb(r)!==r)return yield*new ub({message:`Use a profile whose name has no account ID (an alias in ~/.aws/config).`});let o=p(e);yield*pb(`directory`,o);let s=yield*zx(o).pipe(hl(()=>new ub({message:`Extend requires a valid record.json from create.`})));yield*pb(`region`,s.region),yield*Rx(o);let c=yield*cx(ki(15)),l=yield*N_e({directory:o,record:s,to:a,deadline:c}).pipe(El(_x({profile:r,region:s.region,environment:t,evidenceDirectory:o,temporaryDirectory:t.TMPDIR??i(),within:(yield*lx(c)).within,retryDeadline:c})),ol);if(Vr(l)){let e=l.failure;yield*Sg(e.message),yield*Eg(n,e._tag===`LifecycleError`?e.exitCode:e._tag===`AccountCheckFailed`?3:1)}return yield*Cg(fx(yield*Sx(yield*zx(o))))})).pipe(Zy(`Move and verify the guest shutdown task, then update and verify the recorded instance and volume end tags.`)),s=Xy(`retire`,{directory:ty(`dir`).pipe(ly(Gm),ay(`Private run directory containing record.json; the receipt is written here.`)),profile:ty(`profile`).pipe(ly(Gm),ay(`AWS profile for the recorded account and region.`)),within:ty(`within`).pipe(cy(`15 minutes`),ly(wS),ay(`Bound all retirement reads and waits with one deadline.`))},N(function*({directory:e,profile:r,within:a}){fb(r)!==r&&(yield*new ub({message:`Use a profile whose name has no account ID (an alias in ~/.aws/config).`}));let o=p(e);yield*pb(`directory`,o);let s=yield*zx(o).pipe(hl(()=>new ub({message:`Retire requires a valid record.json. Read-only recovery: aws ec2 describe-instances --profile <profile> --region <region> --filters Name=tag:ot-run,Values=<run>; repeat with Name=client-token,Values=<run>-instance.`})));yield*pb(`region`,s.region),yield*Rx(o),yield*vS(o,s);let c=yield*jl(Zc(function*(){yield*Vx(o);let e=yield*zx(o);return e.run!==s.run||e.region!==s.region?yield*new ub({message:`The run identity changed during retirement preflight.`}):yield*G_e({directory:o,record:e,within:a})})).pipe(El(_x({readRetryOwner:`verb`,profile:r,region:s.region,environment:t,evidenceDirectory:o,temporaryDirectory:t.TMPDIR??i()})),ol);if(Vr(c)){let e=c.failure;yield*Sg(e.message),yield*Eg(n,e._tag===`AccountCheckFailed`?3:1)}else yield*Cg(fx(yield*_S(c.success))),yield*Eg(n,+(c.success.status===`unproven`))})).pipe(Zy(`End this run and prove every recorded resource gone before removing local keys. Prints the persisted release receipt; incomplete proof exits 1.`)),c=Xy(`status`,{directory:ty(`dir`).pipe(ly(Gm),ay(`Private run directory containing record.json. It is read without modification.`)),profile:ty(`profile`).pipe(ly(Gm),ay(`AWS CLI profile to use. Required; the recorded group ID verifies the account.`))},N(function*({directory:e,profile:r}){fb(r)!==r&&(yield*new ub({message:`Use a profile whose name has no account ID (an alias in ~/.aws/config).`}));let a=yield*(yield*gg).readFileString(d(p(e),`record.json`)).pipe(hl(()=>new ub({message:`Cannot read record.json from --dir.`}))),o=yield*vm(qm(xx),{onExcessProperty:`error`})(a).pipe(hl(()=>new ub({message:`record.json must match openteammate.ec2-instance/record@1; unknown fields are refused; identity fields must not contain an account-shaped twelve-digit number.`}))),s=yield*cx(Ax),c=yield*__e(o,s).pipe(El(_x({within:Ax,profile:r,region:o.region,environment:t,temporaryDirectory:t.TMPDIR??i()})),ol);if(Vr(c)){let e=c.failure;e._tag===`UsageError`&&(yield*e);let t=e._tag===`AccountCheckFailed`?{operation:e.operation,kind:e.kind,code:e._tag,message:e.message}:e._tag===`StatusReadFailed`?{operation:e.operation,kind:`selection`,code:e._tag,message:e.message}:ob(e),r=t.message,i=yield*Nx({...o,now:{...t,outcome:`failed`,at:od(yield*id),message:r}});yield*Cg(fx(i)),yield*Sg(r),yield*Eg(n,e._tag===`AccountCheckFailed`?3:1)}else yield*Cg(fx(yield*Nx(c.success))),yield*Eg(n,c.success.now.problems.length===0?0:1)})).pipe(Zy(`Read the instance state, end, time left, Session Manager ping and last recorded end move. Prints one JSON line. No AWS resources are changed.`),vhe([{command:`ec2 status --dir ./run --profile team`,description:`Inspect a run in the region stored in its record.`}])),l=Xy(`ec2`).pipe(Zy(`EC2 instance helper. Exits: 0 promise verified; 1 incomplete or unproven; 2 invalid usage or record; 3 blocked before a cloud change; 130 interrupted.`),_he([r,a,c,o,s]));return yield*Qy(l,{version:CS?.version??`0.0.0`})(e).pipe(El(J_e),dl(`ShowHelp`,()=>Eg(n,2)),dl(`UsageError`,e=>Sg(e.message).pipe(il(Eg(n,2))))),yield*Tg(n)}),X_e=N(function*(e,t){yield*qc(n_e);let n=Lx(`ec2`);return n===void 0?yield*Y_e(e,t):yield*Sg(n).pipe(cl(1))}),Z_e=Nde(({fiber:e,teardown:t})=>{let n=!1;e.addObserver(e=>{process.removeListener(`SIGINT`,r),process.removeListener(`SIGTERM`,r),t(e,e=>{(n||e!==0)&&process.exit(e)})});function r(){n=!0,e.interruptUnsafe(e.id)}process.on(`SIGINT`,r),process.on(`SIGTERM`,r)}),Q_e=(e,t,n)=>{let r=e.detached??n!==`win32`;return{...t,detached:r,shell:e.shell,windowsHide:e.windowsHide??!r}},ES=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:case`EPERM`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`}return Uh({_tag:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,cause:n})},DS=(e,t,n)=>{if(!(`closed`in e)){t(),n?.();return}let r=()=>{clearImmediate(a),e.off(`error`,r),e.off(`close`,r),n?.()},i=()=>{e.closed?r():(a=setImmediate(i),n||a.unref())},a=setImmediate(i);n||a.unref(),e.once(`error`,r),e.once(`close`,r),t(),e.closed||e.destroy()},OS=e=>Yh(lue($_e(e),e=>[e])),$_e=e=>ch(t=>{let n=e.evaluate(),r=tve({...e,writable:n,pull:t});return k(e.endOnDone===!1?r:Fl(r,e=>Tc(e)?Jc:eve(n)))}),eve=e=>Yc(t=>{let n=()=>t(Jc);if(e.closed){let t=ae(e,{readable:!1},()=>{t(),n()})}else DS(e,Ie,n)}),tve=e=>nl(t=>{let n=t.currentDispatcher,r=Os(),i=Os(),a=t=>Is(i,Tae(()=>e.onError(t))),o=!1,s=e=>{o=!0,a(e)};e.writable.on(`error`,s);let c=ae(e.writable,{readable:!1},e=>{e?a(e):Is(r,Jc)});return e.pull.pipe(j(t=>{let r=0;return Yc(i=>{let o=!1,s=()=>n.scheduleTask(c,0),c=()=>{for(e.writable.off(`drain`,c),e.writable.off(`finish`,s);r<t.length;){if(o)return;if(!e.writable.write(t[r++],e.encoding,t=>{t&&(e.writable.closed?a(t):n.scheduleTask(()=>a(t),0))})){o||(e.writable.once(`drain`,c),e.writable.once(`finish`,s));return}}o||i(Jc)};return c(),qc(()=>{o=!0,e.writable.off(`drain`,c),e.writable.off(`finish`,s)})})}),zl({disableYield:!0}),e.endOnDone===!1?Me:wc(t=>(e.writable.end(),il(As(r),xs(t)))),Sl(As(i)),Pl(qc(()=>{c();let t=()=>{e.writable.off(`error`,s),e.writable.off(`error`,t),e.writable.off(`close`,t)};e.writable.errored&&!e.writable.closed&&!o?(e.writable.once(`error`,t),e.writable.once(`close`,t)):t()})))}),kS=e=>ig(nve(e)),nve=e=>ch((t,n)=>rve({scope:n,readable:e.evaluate(),onError:e.onError??ive,chunkSize:e.chunkSize,readSize:e.readSize,closeOnDone:e.closeOnDone})),rve=e=>{let t=e.readable,n=e.chunkSize??4096,r=e.closeOnDone??!0,i=e.exit??ah(void 0),a=e.latch??Yle(!1);function o(){a.openUnsafe()}t.on(`readable`,o);let s=ae(t,{readable:!0,writable:!1},t=>{i.current??=ws(t?e.onError(t):bs()),a.openUnsafe()}),c=Kc(function r(){let o=e.readable.read(e.readSize);if(o===null)return i.current?i.current:t.readableEnded?A(bs()):(a.closeUnsafe(),j(a.await,r));let s=Xr(o);for(;s.length<n&&(o=e.readable.read(e.readSize),o!==null);)s.push(o);return k(s)});return cl(Vs(e.scope,qc(()=>{t.off(`readable`,o),r?DS(t,s):s()})),c)},ive=e=>new Iie(e),AS=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),jS=(e,t,n)=>{let{commands:r}=BS(n),i=globalThis.process.platform===`win32`?`windows`:`posix`,a=r.map(e=>Yhe([e.command,...e.args],{format:i})).join(` | `);return ES(`ChildProcess`,e)(t,[a])},MS=e=>ld(e)?dd(e):e,ave=e=>{if(e.command.includes(`\0`))return`The command contains a NUL character`;let t=e.args.findIndex(e=>MS(e).includes(`\0`));if(t!==-1)return`Argument ${t+1} contains a NUL character`;for(let[t,n]of Object.entries(e.options.env??{}))if(n!==void 0&&MS(n).includes(`\0`))return`The environment variable ${t} contains a NUL character`},NS=1e3,PS=e=>{let t=()=>{};e.on(`error`,t),e.once(`close`,()=>e.off(`error`,t))},FS=e=>e.exitCode!==null||e.signalCode!==null,IS=(e,t)=>e.options.detached!==!1||!FS(t),LS=e=>e?.code===`EPERM`,RS=(e,t)=>{if(!FS(t))return!0;if(globalThis.process.platform===`win32`||!IS(e,t))return!1;try{return globalThis.process.kill(-t.pid,0),!0}catch(e){return LS(e)}},zS=(e,t=()=>{})=>{if(FS(e)){t(null);return}ee.execFile(`taskkill`,[`/pid`,String(e.pid),`/T`,`/F`],{windowsHide:!0},t)},ove=tc(Eb,Zc(function*(){let e=yield*gg,t=yield*bg,n=N(function*(n){if(!Xe(n.cwd))return yield*e.access(n.cwd),t.resolve(n.cwd)}),r=e=>{if(e.env===void 0)return;let t=e.extendEnv===!0?{...globalThis.process.env}:{};for(let[n,r]of Object.entries(e.env))r===void 0?delete t[n]:t[n]=MS(r);return t},i=e=>rg(e)?`pipe`:e,a=e=>Jh(e)?`pipe`:e,o=e=>{let t={stream:`pipe`,encoding:`utf-8`,endOnDone:!0};return Xe(e.stdin)?t:typeof e.stdin==`string`||rg(e.stdin)?{...t,stream:e.stdin}:{stream:e.stdin.stream,encoding:e.stdin.encoding??t.encoding,endOnDone:e.stdin.endOnDone??t.endOnDone}},s=(e,t)=>{let n=e[t];return Xe(n)?{stream:`pipe`}:typeof n==`string`||Jh(n)?{stream:n}:{stream:n.stream}},c=e=>{if(Xe(e.additionalFds))return[];let t=[];for(let[n,r]of Object.entries(e.additionalFds)){let e=Pb(n);Ze(e)&&t.push({fd:e,config:r})}return t.sort((e,t)=>e.fd-t.fd)},l=(e,t,n,r)=>{let o=[i(e.stream),a(t.stream),a(n.stream)];if(r.length===0)return o;let s=r.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=s;e++)o[e]=`ignore`;for(let{fd:e}of r)o[e]=`pipe`;return o},u=(e,t,n)=>Hl(fg(xde(e,e=>Ms(n,e)),t)),d=N(function*(e,t,n,r){if(n.length===0)return{getInputFd:()=>Zh,getOutputFd:()=>sg};let i=new Map,a=new Map,o=(t,n,a)=>Kc(()=>{let o=Zh;return n&&`write`in n&&(PS(n),o=OS({evaluate:()=>n,onError:n=>jS(`fromWritable(fd${t})`,AS(n),e)})),a?M(u(a,o,r),()=>{i.set(t,o)}):(i.set(t,o),Jc)}),s=(t,n,r)=>{let i=sg;if(n&&`read`in n){let r=new ie,a;r.on(`error`,e=>{a??=e}),n.on(`error`,e=>r.destroy(e)),n.pipe(r);let o=n=>jS(`fromReadable(fd${t})`,AS(n),e);i=ude(()=>a===void 0?kS({evaluate:()=>r,onError:o}):fde(o(a)))}r&&(i=ug(i,r)),a.set(t,i)};for(let{config:e,fd:r}of n){let n=t.stdio[r];switch(e.type){case`input`:yield*o(r,n,e.stream);break;case`output`:s(r,n,e.sink);break;case`duplex`:n&&`allowHalfOpen`in n&&(n.allowHalfOpen=!0),s(r,n,e.sink),yield*o(r,n,e.stream)}}return{getInputFd:e=>i.get(e)??Zh,getOutputFd:e=>a.get(e)??sg}}),f=(e,t,n,r)=>Kc(()=>{let i=Zh;return Qe(t.stdin)&&(PS(t.stdin),i=OS({evaluate:()=>t.stdin,onError:t=>jS(`fromWritable(stdin)`,AS(t),e),endOnDone:n.endOnDone,encoding:n.encoding})),rg(n.stream)?cl(u(n.stream,i,r),i):k(i)}),p=(e,t,n,r)=>{let i=t.stdout?(()=>{let n=new ie;return t.stdout.on(`error`,e=>n.destroy(e)),t.stdout.pipe(n),kS({evaluate:()=>n,onError:t=>jS(`fromReadable(stdout)`,AS(t),e)})})():sg,a=t.stderr?(()=>{let n=new ie;return t.stderr.on(`error`,e=>n.destroy(e)),t.stderr.pipe(n),kS({evaluate:()=>n,onError:t=>jS(`fromReadable(stderr)`,AS(t),e)})})():sg;Jh(n.stream)&&(i=ug(i,n.stream)),Jh(r.stream)&&(a=ug(a,r.stream));let o=vde(i,a);return{stdout:i,stderr:a,all:o}},m=(e,t)=>Yc(n=>{let r=Os(),i=ee.spawn(e.command,e.args.map(MS),t);return i.on(`error`,t=>{e.args.some(ld)&&Object.assign(t,{spawnargs:[e.command,...e.args.map(e=>ld(e)?`<redacted>`:e)]}),n(A(jS(`spawn`,t,e)))}),i.on(`exit`,(...e)=>{Is(r,Ss(e))}),i.on(`spawn`,()=>{n(k([i,r]))}),qc(()=>{i.kill(`SIGTERM`)})}),h=(e,t,n)=>globalThis.process.platform===`win32`?Yc(n=>{zS(t,t=>{n(t?A(jS(`kill`,AS(t),e)):Jc)})}):tl({try:()=>{globalThis.process.kill(-t.pid,n)},catch:t=>jS(`kill`,AS(t),e)}),g=(e,t)=>{if(globalThis.process.platform===`win32`){zS(e);return}try{globalThis.process.kill(-e.pid,t)}catch{}},_=(e,t,n)=>Kc(()=>{if(!t.kill(n)){let t=new globalThis.Error(`Failed to kill child process`);return A(jS(`kill`,t,e))}return Jc}),v=(e,t,n)=>Yc(r=>{let i=Date.now()+n,a,o=()=>{clearTimeout(a),t.removeListener(`exit`,s)},s=()=>{if(clearTimeout(a),Date.now()>=i||!RS(e,t)){o(),r(Jc);return}a=setTimeout(s,10)};return t.on(`exit`,s),s(),qc(o)}),y=N(function*(e,t,n,r){let i=n=>IS(e,t)?h(e,t,n).pipe(ul(r=>FS(t)&&LS(r.cause)?Jc:_(e,t,n))):_(e,t,n);yield*i(r?.killSignal??`SIGTERM`),Xe(r?.forceKillAfter)?(yield*As(n),yield*v(e,t,NS)):(yield*v(e,t,Ai(r.forceKillAfter)),RS(e,t)&&(yield*i(`SIGKILL`),yield*v(e,t,NS))),yield*As(n)}),b=(e,t)=>{let n=t??`stdout`;switch(n){case`stdout`:return e.stdout;case`stderr`:return e.stderr;case`all`:return e.all;default:{let t=Pb(n);return Ze(t)?e.getOutputFd(t):e.stdout}}},x=N(function*(e){switch(e._tag){case`StandardCommand`:{if(e.options.shell!==void 0&&e.options.shell!==!1&&e.args.length>0)return yield*A(Wh({module:`ChildProcess`,method:`spawn`,description:`The shell option cannot be combined with arguments; pass the whole script as the command`}));let t=ave(e);if(t!==void 0)return yield*A(Wh({module:`ChildProcess`,method:`spawn`,description:t}));let i=o(e.options),a=s(e.options,`stdout`),u=s(e.options,`stderr`),h=c(e.options),_=!0,v=yield*n(e.options),b=r(e.options),ee=l(i,a,u,h),x=N(function*(t,n){if(yield*Ns(n)){let[r]=yield*As(n);(r!==0&&Qe(r)||_&&process.platform!==`win32`&&e.options.detached!==!1)&&(yield*yl(y(e,t,n,e.options)));return}_&&(yield*yl(y(e,t,n,e.options)))}),te=Rs(),[ne,re]=yield*Ml(m(e,Q_e(e.options,{cwd:v,env:b,stdio:ee},process.platform)),([e,t],n)=>Uc([Ws(te,n),x(e,t)],{concurrency:`unbounded`,discard:!0})),ie=Khe(ne.pid);e.options.detached!==!1&&ne.on(`exit`,t=>{t!==0&&Qe(t)&&g(ne,e.options.killSignal??`SIGTERM`)});let ae=qc(()=>{_||=(ne.ref(),!0)}),S=qc(()=>(_&&=(ne.unref(),!1),ae)),oe=Os(),C=yield*zs(te)(f(e,ne,i,oe)),{all:se,stderr:ce,stdout:le}=p(e,ne,a,u),{getInputFd:ue,getOutputFd:w}=yield*zs(te)(d(e,ne,h,oe)),de=M(Ns(re),e=>!e),fe=j(Sl(As(re),As(oe)),([t,n])=>{if(Ps(oe))return As(oe);if(Qe(t))return k(Ghe(t));let r=new globalThis.Error(`Process interrupted due to receipt of signal: '${n}'`);return A(jS(`exitCode`,r,e))});return Tb({pid:ie,exitCode:fe,isRunning:de,kill:t=>y(e,ne,re,t),stdin:C,stdout:le,stderr:ce,all:se,getInputFd:ue,getOutputFd:w,unref:S})}case`PipedCommand`:{let{commands:t,pipeOptions:n}=BS(e),[r,...i]=t,a=[yield*x(r)];for(let e=0;e<i.length;e++){let t=i[e],r=n[e]??{},s=o(t.options),c=lg(k(b(a[a.length-1],r.from))),l=r.to??`stdin`;if(l===`stdin`)a.push(yield*x(Mb(t.command,t.args,{...t.options,stdin:{...s,stream:c}})));else{let e=Pb(l);if(Ze(e)){let n=gge(e),r=t.options.additionalFds??{},i=r[n],o=i?.type===`duplex`?{...i,stream:c}:{type:`input`,stream:c};a.push(yield*x(Mb(t.command,t.args,{...t.options,additionalFds:{...r,[n]:o}})))}else a.push(yield*x(Mb(t.command,t.args,{...t.options,stdin:{...s,stream:c}})))}}let s=a[a.length-1],c=e=>Wc([...a].reverse(),t=>yl(t.kill(e)),{discard:!0}),l=Zc(function*(){let e=[];for(let t of a)e.push(yield*t.unref);return Wc([...e].reverse(),e=>e,{discard:!0})});return Tb({pid:s.pid,exitCode:s.exitCode,isRunning:s.isRunning,kill:c,stdin:a[0].stdin,stdout:s.stdout,stderr:s.stderr,all:s.all,getInputFd:s.getInputFd,getOutputFd:s.getOutputFd,unref:l})}}});return Jhe(x)})),BS=e=>{let t=[],n=[],r=e=>{switch(e._tag){case`StandardCommand`:t.push(e);break;case`PipedCommand`:r(e.left),n.push(e.options),r(e.right)}};if(r(e),t.length===0)throw Error(`flattenCommand produced empty commands array`);let[i,...a]=t;return{commands:[i,...a],pipeOptions:n}},VS=e=>t=>Wh({module:`FileSystem`,method:e,description:t.message??String(t)}),HS=(e,t)=>{let n=Number(e);if(!Number.isSafeInteger(n))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return n},US=e=>dr(sr(e),boe),WS=e=>BigInt.asUintN(64,e),GS=e=>Cte(sr(e),WS),KS=(e,t)=>tl({try:()=>HS(e,`position`),catch:VS(t)}),sve=(()=>{let e=Kl(S.access,ES(`FileSystem`,`access`),VS(`access`));return(t,n)=>{let r=S.constants.F_OK;return n?.readable&&(r|=S.constants.R_OK),n?.writable&&(r|=S.constants.W_OK),e(t,r)}})(),cve=(()=>{let e=Kl(S.cp,ES(`FileSystem`,`copy`),VS(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),lve=(()=>{let e=Kl(S.copyFile,ES(`FileSystem`,`copyFile`),VS(`copyFile`));return(t,n)=>e(t,n)})(),uve=(()=>{let e=Kl(S.chmod,ES(`FileSystem`,`chmod`),VS(`chmod`));return(t,n)=>e(t,n)})(),dve=(()=>{let e=Kl(S.chown,ES(`FileSystem`,`chown`),VS(`chown`));return(t,n,r)=>e(t,n,r)})(),fve=(()=>{let e=Kl(S.link,ES(`FileSystem`,`link`),VS(`link`));return(t,n)=>e(t,n)})(),pve=(()=>{let e=Kl(S.mkdir,ES(`FileSystem`,`makeDirectory`),VS(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),qS=e=>{let n=Kl(S.mkdtemp,ES(`FileSystem`,e),VS(e));return e=>Kc(()=>{let r=e?.prefix??``,i=typeof e?.directory==`string`?a.join(e.directory,`.`):t.tmpdir();return n(r?a.join(i,r):i+`/`)})},mve=qS(`makeTempDirectory`),JS=e=>{let t=Kl(S.rm,ES(`FileSystem`,e),VS(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},hve=JS(`remove`),gve=(()=>{let e=qS(`makeTempDirectoryScoped`),t=JS(`makeTempDirectoryScoped`);return n=>Ml(e(n),e=>gl(t(e,{recursive:!0,force:!0})))})(),_ve=e=>{let{O_APPEND:t,O_CREAT:n,O_EXCL:r,O_RDONLY:i,O_RDWR:a,O_TRUNC:o,O_WRONLY:s}=S.constants;switch(e){case`r`:return i;case`r+`:return a;case`w`:return o|n|s;case`wx`:return o|n|s|r;case`w+`:return o|n|a;case`wx+`:return o|n|a|r;case`a`:return t|n|s;case`ax`:return t|n|s|r;case`a+`:return t|n|a;case`ax+`:return t|n|a|r}},vve=(e,t)=>Kc(()=>{let{O_NOFOLLOW:n}=S.constants;return process.platform===`win32`||typeof n!=`number`||n===0?A(Wh({module:`FileSystem`,method:e,description:`noFollow is not supported on this platform`})):k(_ve(t)|n)}),yve=(e=>{let t=Kl(S.open,ES(`FileSystem`,e),VS(e)),n=Kl(S.close,ES(`FileSystem`,e),VS(e));return(r,i)=>Le(Ml(i?.noFollow===!0?j(vve(e,i.flag??`r`),e=>t(r,e,i.mode)):t(r,i?.flag??`r`,i?.mode),e=>gl(n(e))),M(e=>bve(e,i?.flag?.startsWith(`a`)??!1)))})(`open`),YS=e=>Wh({module:`FileSystem`,method:e,description:`Cannot read before the start of the file`}),bve=(()=>{let e=e=>Kl(S.read,ES(`FileSystem`,e),VS(e)),t=e(`read`),n=e(`readAlloc`),r=Kl(S.fstat,ES(`FileSystem`,`stat`),VS(`stat`)),i=Kl(S.ftruncate,ES(`FileSystem`,`truncate`),VS(`truncate`)),a=Kl(S.fsync,ES(`FileSystem`,`sync`),VS(`sync`)),o=e=>{let t=Kl(S.write,ES(`FileSystem`,e),VS(e));return(e,n,r)=>t(e,n,0,n.length,r)},s=o(`write`),c=o(`writeAll`);class l{[_g];fd;append;position=BigInt(0);constructor(e,t){this[_g]=_g,this.fd=e,this.append=t}get stat(){return j(r(this.fd,{bigint:!0}),QS)}get sync(){return a(this.fd)}seek(e,t){return Kc(()=>{let n=t===`start`?e:this.position+e;return n<BigInt(0)?A(Wh({module:`FileSystem`,method:`seek`,description:`Cannot seek before the start of the file`})):(this.position=n,k(n))})}read(e,n){return Kc(()=>{let r=n?.position;if(r!==void 0)return r<BigInt(0)?A(YS(`read`)):t(this.fd,{buffer:e,position:r});let i=this.position;return M(t(this.fd,{buffer:e,position:i}),e=>(this.position=i+BigInt(e),e))})}readAlloc(e,t){return Kc(()=>{try{if(!Number.isInteger(e)||e<0)throw RangeError(`size must be a non-negative integer`);let r=t?.position;if(r!==void 0&&r<BigInt(0))return A(YS(`readAlloc`));let i=Buffer.allocUnsafeSlow(e),a=r??this.position;return M(n(this.fd,{buffer:i,position:a}),t=>{if(t===0)return O();if(r===void 0&&(this.position=a+BigInt(t)),t===e)return nr(i);let n=Buffer.allocUnsafeSlow(t);return i.copy(n,0,0,t),nr(n)})}catch(e){return A(VS(`readAlloc`)(e))}})}truncate(e){return M(i(this.fd,e||void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return Kc(()=>{let t=this.position;return j(this.append?k(void 0):KS(t,`write`),n=>M(s(this.fd,e,n),e=>(this.append||(this.position=t+BigInt(e)),e)))})}writeAllChunk(e){return Kc(()=>{let t=this.position;return j(this.append?k(void 0):KS(t,`writeAll`),n=>j(c(this.fd,e,n),n=>n===0?A(Uh({module:`FileSystem`,method:`writeAll`,_tag:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position=t+BigInt(n)),n<e.length?this.writeAllChunk(e.subarray(n)):Jc)))})}writeAll(e){return e.length===0?Jc:this.writeAllChunk(e)}}return(e,t)=>new l(e,t)})(),XS=e=>{let t=qS(e);return N(function*(e){let n=yield*t(e),r=_.randomBytes(6).toString(`hex`),i=a.join(n,e?.suffix?`${r}${e.suffix}`:r);return yield*tC(i,new Uint8Array),i})},xve=XS(`makeTempFile`),Sve=(()=>{let e=XS(`makeTempFileScoped`),t=JS(`makeTempFileScoped`);return n=>Ml(e(n),e=>gl(t(a.dirname(e),{recursive:!0,force:!0})))})(),Cve=(e,t)=>Gc({try:()=>S.promises.readdir(e,t),catch:t=>ES(`FileSystem`,`readDirectory`)(t,[e])}),wve=e=>Gc({try:()=>S.promises.readdir(e,{withFileTypes:!0}),catch:t=>ES(`FileSystem`,`readDirectoryEntries`)(t,[e])}).pipe(M(e=>e.map(e=>({name:e.name,type:ZS(e)})))),Tve=e=>Yc((t,n)=>{try{S.readFile(e,{signal:n},(n,r)=>{t(n?A(ES(`FileSystem`,`readFile`)(n,[e])):k(r))})}catch(e){t(A(VS(`readFile`)(e)))}}),Eve=(()=>{let e=Kl(S.readlink,ES(`FileSystem`,`readLink`),VS(`readLink`));return t=>e(t)})(),Dve=(()=>{let e=Kl(process.platform===`win32`?S.realpath.native:S.realpath,ES(`FileSystem`,`realPath`),VS(`realPath`));return t=>e(t)})(),Ove=(()=>{let e=Kl(S.rename,ES(`FileSystem`,`rename`),VS(`rename`));return(t,n)=>e(t,n)})(),ZS=e=>e.isFile()?`File`:e.isDirectory()?`Directory`:e.isSymbolicLink()?`SymbolicLink`:e.isBlockDevice()?`BlockDevice`:e.isCharacterDevice()?`CharacterDevice`:e.isFIFO()?`FIFO`:e.isSocket()?`Socket`:`Unknown`,QS=(e,t=`stat`)=>tl({try:()=>({type:ZS(e),mtime:sr(e.mtime),atime:sr(e.atime),birthtime:sr(e.birthtime),dev:WS(e.dev),rdev:GS(e.rdev),ino:GS(e.ino),mode:HS(e.mode,`mode`),nlink:GS(e.nlink),uid:US(e.uid),gid:US(e.gid),size:Gu(e.size),blksize:e.blksize===void 0?O():nr(Gu(e.blksize)),blocks:sr(e.blocks)}),catch:VS(t)}),$S=(e,t)=>{let n=Kl(t,ES(`FileSystem`,e),VS(e));return t=>j(n(t,{bigint:!0}),t=>QS(t,e))},eC=$S(`stat`,S.stat),kve=$S(`lstat`,S.lstat),Ave=(()=>{let e=Kl(S.symlink,ES(`FileSystem`,`symlink`),VS(`symlink`));return(t,n)=>e(t,n)})(),jve=(()=>{let e=Kl(S.truncate,ES(`FileSystem`,`truncate`),VS(`truncate`));return(t,n)=>e(t,n)})(),Mve=(()=>{let e=Kl(S.utimes,ES(`FileSystem`,`utime`),VS(`utime`));return(t,n,r)=>e(t,n,r)})(),Nve=(e,t,n)=>lde(r=>Ml(qc(()=>{let i=t.type===`Directory`?e:a.dirname(e),o=S.watch(e,{recursive:n?.recursive??!1},(e,t)=>{if(t)switch(e){case`rename`:Ul(Nae(eC(a.resolve(i,t)),{onSuccess:e=>ou(r,{_tag:`Create`,path:t}),onFailure:e=>ou(r,{_tag:`Remove`,path:t})}));return;case`change`:su(r,{_tag:`Update`,path:t});return}});return o.on(`error`,t=>{lu(r,jie(Uh({module:`FileSystem`,_tag:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t})))}),o.on(`close`,()=>{uu(r)}),o}),e=>qc(()=>e.close())).pipe(al(()=>qc(()=>n?.onReady?.())))),Pve=(e,t,n)=>Uc([eC(t),Ol(vg)]).pipe(M(([r,i])=>bte(i,()=>e).pipe(dr(e=>e.register(t,r,n)),or(()=>Nve(t,r,n)))),lg),tC=(e,t,n)=>Yc((r,i)=>{try{S.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?A(ES(`FileSystem`,`writeFile`)(t,[e])):Jc)})}catch(e){r(A(VS(`writeFile`)(e)))}}),Fve=M(Ol(vg),e=>Ede({access:sve,chmod:uve,chown:dve,copy:cve,copyFile:lve,link:fve,lstat:kve,makeDirectory:pve,makeTempDirectory:mve,makeTempDirectoryScoped:gve,makeTempFile:xve,makeTempFileScoped:Sve,open:yve,readDirectory:Cve,readDirectoryEntries:wve,readFile:Tve,readLink:Eve,realPath:Dve,remove:hve,rename:Ove,stat:eC,symlink:Ave,truncate:jve,utimes:Mve,watch(t,n){return Pve(e,t,n)},writeFile:tC})),Ive=tc(gg)(Fve),nC=e=>({fromFileUrl:t=>tl({try:()=>m.fileURLToPath(t,{windows:e}),catch:e=>new Vh({module:`Path`,method:`fromFileUrl`,cause:e})}),toFileUrl:t=>tl({try:()=>m.pathToFileURL(t,{windows:e}),catch:e=>new Vh({module:`Path`,method:`toFileUrl`,cause:e})})});({...a.posix,...nC(!1)}),{...a.win32,...nC(!0)};const Lve=$s(bg)(Dde({...a,...nC(void 0)})),Rve=$s(Ide,Lde({args:qc(()=>process.argv.slice(2)),stdinIsTerminal:qc(()=>process.stdin.isTTY===!0),stdoutIsTerminal:qc(()=>process.stdout.isTTY===!0),stderrIsTerminal:qc(()=>process.stderr.isTTY===!0),stdout:e=>OS({evaluate:()=>process.stdout,onError:e=>Uh({module:`Stdio`,method:`stdout`,_tag:`Unknown`,cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>OS({evaluate:()=>process.stderr,onError:e=>Uh({module:`Stdio`,method:`stderr`,_tag:`Unknown`,cause:e}),endOnDone:e?.endOnDone??!1}),stdin:kS({evaluate:()=>process.stdin,onError:e=>Uh({module:`Stdio`,method:`stdin`,_tag:`Unknown`,cause:e}),closeOnDone:!1})})),zve=tc(Ng,N(function*(e=rC){let t=yield*iu(),n=!1,r=!1,i=()=>{n=!0,r||uu(t)},a,o=()=>(a===void 0&&(a=process.stdin,a.readableEnded?i():a.once(`end`,i)),a);yield*Nl(()=>qc(()=>a?.off(`end`,i)));let s=yield*tg({acquire:Ml(qc(()=>{let e=o(),n=he.createInterface({input:e,escapeCodeTimeout:50}),i=e=>su(t,e),a=()=>{r=!1,uu(t)};return r=!0,he.emitKeypressEvents(e,n),n.on(`line`,i),n.once(`close`,a),{rl:n,onClose:a,onLine:i}}),({rl:e,onClose:i,onLine:a})=>qc(()=>{r=!1,e.off(`line`,a),e.off(`close`,i),e.close(),n&&uu(t)})),idleTimeToLive:`10 millis`}),c=e=>qc(()=>{let t=o();t.isTTY&&t.setRawMode(e)}),l=yield*tg({acquire:Ml(c(!0),()=>c(!1)),idleTimeToLive:`10 millis`}),u=qc(()=>process.stdout.columns??0),d=qc(()=>process.stdout.rows??0),f=Zc(function*(){let e=process.stdout,t=yield*Xae(1),n=()=>su(t,{columns:e.columns??0,rows:e.rows??0});return yield*Nl(()=>qc(()=>{e.off(`resize`,n),uu(t)})),e.on(`resize`,n),n(),t}),p=Zc(function*(){let t=o(),r=yield*iu(),i=(t,n)=>{let i={input:cr(t),key:{name:n.name??``,ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};su(r,i),e(i)&&uu(r)},a=setInterval(()=>{},2147483647),c=()=>{clearInterval(a),uu(r)};return yield*Nl(()=>qc(()=>{clearInterval(a),t.off(`keypress`,i),t.off(`end`,c)})),t.on(`keypress`,i),n?c():(yield*ng(s),yield*ng(l),t.once(`end`,c)),r}),m=Kc(()=>$ae(t).pipe(j(ar({onNone:()=>jl(il(ng(s),pu(t))),onSome:k})),hl(()=>new Mg({}))));return zde({columns:u,rows:d,size:f,readInput:p,readLine:m,display:e=>Rae(Yc(t=>{process.stdout.write(e,e=>bee(e)?t(Jc):t(A(Wh({module:`Terminal`,method:`display`,description:`Failed to write prompt to stdout`,cause:e}))))}))})})(rC));function rC(e){let t=e.key;return t.name===`escape`||t.ctrl&&(t.name===`c`||t.name===`d`)}const Bve=Yie(ove,ac(Ive,Lve,Rve,zve)),Vve=e=>Z_e(e.pipe(El(Bve),fl(e=>Sg(Pie(e)).pipe(cl(1))),al(e=>qc(()=>{process.exitCode=e}))),{disableErrorReporting:!0}),iC=(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}}},aC={pipe(){return iC(this,arguments)}},oC=function(){function e(){}return e.prototype=aC,e}(),sC=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)}}}},cC=e=>e,lC=e=>()=>e,Hve=lC(!0),Uve=lC(!1),uC=lC(void 0),dC=uC;function fC(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 pC(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!==n&&t.set(i,i),i}}const Wve=[`line`,`column`,`sourceURL`,`originalLine`,`originalColumn`],mC=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;if(e instanceof Error){t.delete(`stack`);for(let n of Wve)Object.prototype.propertyIsEnumerable.call(e,n)||t.delete(n)}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},hC=new WeakSet,gC=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),_C=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,vC=e=>{try{return new Uint8Array(e)}catch{return}};let yC=0;const Gve=()=>{yC++};function bC(e){return typeof e==`string`}function xC(e){return typeof e==`number`}function Kve(e){return typeof e==`boolean`}function qve(e){return typeof e==`symbol`}function Jve(e){return bC(e)||xC(e)||qve(e)}function SC(e){return typeof e==`function`}function Yve(e){return e!=null}function Xve(e){return!0}function CC(e){return typeof e==`object`&&!!e||SC(e)}const wC=sC(2,(e,t)=>CC(e)&&t in e),Zve=sC(2,(e,t)=>wC(e,`_tag`)&&e._tag===t),TC=`~effect/Hash`,EC=e=>{switch(typeof e){case`number`:return MC(e);case`bigint`:return NC(e.toString(10));case`string`:return NC(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?NC(`Invalid Date`):NC(e.toISOString());if(e instanceof RegExp)return NC(e.toString());{if(hC.has(e))return DC(e);let t=zC.get(e);if(t!==void 0)return t;if(BC.has(e))return Gve(),NC(`[Circular]`);BC.add(e);let n=yC,r;try{if(Qve(e))r=e[TC]();else if(typeof e==`function`)r=DC(e);else if(_C(e)){let t=vC(e);r=t===void 0?DC(e):IC(t)}else r=e instanceof DataView?IC(gC(e)):Array.isArray(e)||ArrayBuffer.isView(e)?IC(e):e instanceof Map?eye(e):e instanceof Set?tye(e):PC(e)}finally{BC.delete(e)}return n===yC&&zC.set(e,r),r}}return AC(OC(NC(String(e))))},DC=e=>(RC.has(e)||RC.set(e,AC(Math.random()*4294967296|0)),RC.get(e)),OC=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),kC=sC(2,(e,t)=>OC(Math.imul(e,2654435761)+Math.imul(t,2246822507))),AC=e=>e&3221225471|e>>>1&1073741824,Qve=e=>wC(e,`~effect/Hash`)&&typeof e[`~effect/Hash`]==`function`,jC=new DataView(new ArrayBuffer(8)),MC=e=>{let t=e|0;return t===e?AC(t):(jC.setFloat64(0,e===e?e:NaN),AC(kC(jC.getInt32(0),jC.getInt32(4))))},NC=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return AC(t)},$ve=(e,t)=>{let n=12289;for(let r of t)n^=kC(EC(r),EC(e[r]));return AC(n)},PC=e=>$ve(e,mC(e)),FC=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return AC(r)},IC=e=>{let t=6151;for(let n of e)t=kC(t,EC(n));return AC(t)},eye=FC(NC(`Map`),([e,t])=>kC(EC(e),EC(t))),LC=NC(`Set`),tye=FC(LC,e=>kC(LC,EC(e))),RC=new WeakMap,zC=new WeakMap,BC=new WeakSet,VC=`~effect/Equal`;function HC(){return arguments.length===1?e=>UC(e,arguments[0]):UC(arguments[0],arguments[1])}function UC(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`||hC.has(e)||hC.has(t)?!1:nye(e,t):!1}function nye(e,t){let n=GC.length;for(let r=n;r-->0;)if(GC[r]===e&&KC[r]===t)return!0;if(n)return WC(e,t);let r=qC.get(e);r||qC.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=WC(e,t)),i}function WC(e,t){GC.push(e),KC.push(t);try{return rye(e,t)}finally{GC.pop(),KC.pop()}}const GC=[],KC=[],qC=new WeakMap;function rye(e,t){if(EC(e)!==EC(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=XC(e);if(n!==XC(t)||typeof e==`function`&&!n)return!1;if(n)return e[VC](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:iye(e,t);if(_C(e)){if(!_C(t)||e instanceof ArrayBuffer!=t instanceof ArrayBuffer)return!1;let n=vC(e),r=vC(t);return n!==void 0&&r!==void 0&&JC(n,r)}if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?JC(gC(e),gC(t)):JC(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:YC(e,t,oye,sye):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:YC(e,t,EC,UC):aye(e,t)}function iye(e,t){for(let n=0;n<e.length;n++)if(!UC(e[n],t[n]))return!1;return!0}function JC(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 aye(e,t){let n=mC(e),r=mC(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!UC(e[i],t[i]))return!1;return!0}function YC(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop(),a--;continue outer}}return!1}return a===0}const oye=e=>EC(e[0]),sye=(e,t)=>UC(e[0],t[0])&&UC(e[1],t[1]),XC=e=>wC(e,`~effect/Equal`)&&typeof e[`~effect/Equal`]==`function`,ZC=Symbol.for(`~effect/Redactable`),cye=e=>wC(e,ZC);function QC(e){return cye(e)?$C(e):e}function $C(e){return e[ZC](globalThis[`~effect/Fiber/currentFiber`]?.context??lye)}const ew=`~effect/Fiber/currentFiber`,tw=new Map,lye={"~effect/Context":{},base:tw,depth:0,mapUnsafe:tw,pipe(){return iC(this,arguments)}};function nw(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,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(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 uye;r.add(e);let l;if(ZC in e)l=c($C(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(`,
|
|
260
260
|
`+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=fye(e);else if(!t?.ignoreToString&&wC(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=pye(e);l=e instanceof Error&&e.cause!==void 0?`${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=>`${rw(t)}:${c(iw(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${rw(t)}: ${c(iw(e,t),n+1)}`).join(`,
|
|
261
261
|
`)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}const uye=`[Circular]`;function rw(e){return typeof e==`string`?JSON.stringify(e):String(e)}function dye(e){return e.map(e=>`[${rw(e)}]`).join(``)}function fye(e){try{return e.toISOString()}catch{return`Invalid Date`}}function pye(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function iw(e,t){try{return e[t]}catch{return`[property access threw]`}}function aw(e,t){let n=[],r=new WeakMap;return JSON.stringify(e,function(e,t){let i=Object.getOwnPropertyDescriptor(r.get(this)??this,e)?.value,a=wC(i,ZC)?QC(i):QC(t);if(typeof a==`bigint`)return nw(a);if(typeof a!=`object`||!a)return a;let o=a instanceof Error&&!wC(a,`toJSON`)?{...a,name:a.name,message:a.message}:a;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(a))return;if(n.push(a),o!==a&&n.push(o),!mye(o)||gye(o))return o;let s=hye(o);return r.set(s,o),n.push(s),s},t?.space)??`null`}function mye(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function hye(e){let t=Array.isArray(e)?[]:{},n=Array.isArray(e)?Array.from({length:e.length},(e,t)=>String(t)):Object.keys(e);for(let r of n)Object.defineProperty(t,r,{enumerable:!0,get:()=>{let t=Reflect.get(e,r);return Object.getOwnPropertyDescriptor(e,r)?.get===void 0?t:QC(t)}});return t}function gye(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}const ow=Symbol.for(`nodejs.util.inspect.custom`),sw=e=>{try{return e=QC(e),wC(e,`toJSON`)&&SC(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(sw):e}catch{return`[toJSON threw]`}},_ye=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?aw(e,{space:t}):nw(e,{space:t})}catch{return String(e)}},cw={toJSON(){return sw(this)},[ow](){return this.toJSON()},toString(){return nw(this.toJSON())}},vye=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),lw=()=>Error.stackTraceLimit,uw=e=>{vye&&(Error.stackTraceLimit=e)};var dw=class{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}};const fw=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}},r=lw();if(r===0)return n[e];uw(2);let i=t[e](()=>Error());return uw(r),i.stack?.includes(e)===!0?t[e]:n[e]})();function pw(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function yye(e,t){if(!Object.hasOwn(t,`__proto__`)){Object.assign(e,t);return}for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&pw(e,n,t[n])}const mw=`~effect/Effect`,hw=`~effect/Exit`,bye={_A:cC,_E:cC,_R:cC},gw=`${mw}/identifier`,_w=`${mw}/args`,vw=`${mw}/evaluate`,yw=`${mw}/successCont`,bw=`${mw}/failureCont`,xw=`${mw}/ensureCont`,Sw=Symbol.for(`effect/Effect/Yield`),Cw={pipe(){return iC(this,arguments)},toJSON(){return{...this}},toString(){return nw(this.toJSON(),{ignoreToString:!0,space:2})},[ow](){return this.toJSON()}},xye={[mw]:bye,...Cw,[Symbol.iterator](){return new dw(this)},toJSON(){return{_id:`Effect`,op:this[gw],..._w in this?{args:this[_w]}:void 0}}},ww=e=>wC(e,mw),Sye=e=>wC(e,hw),Tw=`~effect/Cause`,Ew=`~effect/Cause/Reason`,Dw=e=>wC(e,Tw);var Ow=class{constructor(e){this[Tw]=Tw,this.reasons=e}pipe(){return iC(this,arguments)}toJSON(){return{_id:`Cause`,reasons:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${nw(this.reasons)})`}[ow](){return this.toJSON()}[VC](e){return Dw(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>HC(t,e.reasons[n]))}[TC](){return IC(this.reasons)}};const kw=new WeakMap;var Aw=class{[Ew];annotations;_tag;constructor(e,t,n){if(this[Ew]=Ew,this._tag=e,t!==jw&&typeof n==`object`&&n&&t.size>0){let e=kw.get(n);e&&(t=new Map([...e,...t])),kw.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);if(e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)}),t?.overwrite!==!0&&n.size===this.annotations.size)return this;let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return iC(this,arguments)}toString(){return nw(this)}[ow](){return this.toString()}};const jw=new Map;var Mw=class extends Aw{constructor(e,t=jw){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${nw(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[VC](e){return zw(e)&&HC(this.error,e.error)&&HC(this.annotations,e.annotations)}[TC](){return kC(NC(this._tag))(kC(EC(this.error))(EC(this.annotations)))}};const Nw=e=>new Ow(e),Cye=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=EC(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>HC(e,i)))continue;else t.push(i);r.push(i)}return r},Pw=sC(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new Ow(Cye(e.reasons,t.reasons));return HC(e,n)?e:n}),Fw=(e,t)=>{let n=e.reasons.slice();for(let e of t.reasons)Vw(e)&&!n.some(t=>Vw(t)&&t.fiberId===e.fiberId&&t.annotations===e.annotations)&&n.push(e);return n.length===e.reasons.length?e:new Ow(n)},wye=new Ow([]),Tye=e=>new Ow([new Mw(e)]);var Iw=class extends Aw{constructor(e,t=jw){super(`Die`,t,e),this.defect=e}toString(){return`Die(${nw(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[VC](e){return Bw(e)&&HC(this.defect,e.defect)&&HC(this.annotations,e.annotations)}[TC](){return kC(NC(this._tag))(kC(EC(this.defect))(EC(this.annotations)))}};const Lw=e=>new Ow([new Iw(e)]),Rw=sC(e=>Dw(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new Ow(e.reasons.map(e=>e.annotate(t,n)))),zw=e=>e._tag===`Fail`,Bw=e=>e._tag===`Die`,Vw=e=>e._tag===`Interrupt`;function Eye(e){return Xw(`Effect.evaluate: Not implemented`)}const Hw=e=>({...xye,[gw]:e.op,[vw]:e[vw]??Eye,[yw]:e[yw],[bw]:e[bw],[xw]:e[xw]}),Uw=e=>{let t=Hw(e),n=function(e){this[_w]=e};return n.prototype=t,function(e){return new n(e)}},Ww=e=>{let t={[hw]:hw,_tag:e.op,get[e.prop](){return this[_w]},...Hw(e),toString(){return`${e.op}(${nw(this[_w])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[_w]}},[VC](e){return Sye(e)&&e._tag===this._tag&&HC(this[_w],e[_w])},[TC](){return kC(NC(e.op),EC(this[_w]))}},n=function(e){this[_w]=e};return n.prototype=t,function(e){return new n(e)}},Gw=Ww({op:`Success`,prop:`value`,[vw](e){let t=e.getCont(yw);return t?t[yw](this[_w],e,this):e.yieldWith(this)}}),Kw={key:`effect/Cause/StackTrace`},qw={key:`effect/Cause/InterruptorStackTrace`},Jw=Ww({op:`Failure`,prop:`cause`,[vw](e){let t=this[_w],n=!1;e.cache.stackFrame&&(t=Rw(t,{mapUnsafe:new Map([[Kw.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(bw),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;r&&e.interruptible;)a||=gw in r,r=e.getCont(bw);a&&(t=Nw(t.reasons.filter(e=>e._tag!==`Fail`))),t=Fw(t,i),n=!0}return r?r[bw](t,e,n?void 0:this):e.yieldWith(n?Jw(t):this)}}),Yw=e=>Jw(Tye(e)),Xw=e=>Jw(Lw(e)),Zw=Uw({op:`WithFiber`,[vw](e){return this[_w](e)}}),Dye=function(){class e extends globalThis.Error{}let t=Hw({op:`YieldableError`,[vw](){return Yw(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Qw=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends Dye{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(yye(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),$w=e=>{class t extends Qw{_tag=e}return t.prototype.name=e,t},Oye=e=>wC(e,`~effect/Cause/Done`),kye=e=>Hw({op:e.label,[vw]:e.evaluate}),eT=`~effect/Option`,tT={[eT]:{_A:e=>e},...Cw,[Symbol.iterator](){return new dw(this)}},Aye=Object.defineProperty(Object.assign(Object.create(tT),{_tag:`Some`,_op:`Some`,[VC](e){return nT(e)&&Nye(e)&&HC(this.value,e.value)},[TC](){return kC(EC(this._tag))(EC(this.value))},toString(){return`some(${nw(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:sw(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),jye=EC(`None`),Mye=Object.assign(Object.create(tT),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[VC](e){return nT(e)&&rT(e)},[TC](){return jye},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),nT=e=>wC(e,eT),rT=e=>e._tag===`None`,Nye=e=>e._tag===`Some`,Pye=Object.create(Mye),iT=function(e){this.value=e};iT.prototype=Aye;const Fye=e=>new iT(e),aT=`~effect/Result`,oT={[aT]:{_A:e=>e,_E:e=>e},...Cw,[Symbol.iterator](){return new dw(this)}},Iye=Object.assign(Object.create(oT),{_tag:`Success`,_op:`Success`,[VC](e){return sT(e)&&Rye(e)&&HC(this.success,e.success)},[TC](){return kC(EC(this._tag))(EC(this.success))},toString(){return`success(${nw(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:sw(this.success)}}}),Lye=Object.assign(Object.create(oT),{_tag:`Failure`,_op:`Failure`,[VC](e){return sT(e)&&cT(e)&&HC(this.failure,e.failure)},[TC](){return kC(EC(this._tag))(EC(this.failure))},toString(){return`failure(${nw(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:sw(this.failure)}}}),sT=e=>wC(e,aT),cT=e=>e._tag===`Failure`,Rye=e=>e._tag===`Success`,lT=function(e){this.failure=e};lT.prototype=Lye;const zye=e=>new lT(e),uT=function(e){this.success=e};uT.prototype=Iye;const Bye=e=>new uT(e);function dT(e){return(t,n)=>t===n?0:e(t,n)}const Vye=dT((e,t)=>e<t?-1:1),Hye=dT((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),Uye=sC(2,(e,t)=>dT((n,r)=>e(t(n),t(r)))),Wye=e=>sC(2,(t,n)=>e(t,n)===1),fT=()=>Pye,pT=Fye,Gye=rT,mT=`~effect/Context/Service`,hT=function(){function e(){}let t=e;Object.setPrototypeOf(t,Kye);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[_T]=_T,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&gT.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},Kye={[mT]:mT,...kye({label:`Service`,evaluate(e){return Gw(jT(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return DT(this,e)},use(e){return Zw(t=>e(jT(t.context,this)))},useSync(e){return Zw(t=>Gw(e(jT(t.context,this))))}},gT=new Set,_T=`~effect/Context/Reference`,vT=`~effect/Context`,yT=(e,t,n,r,i)=>{let a=Object.create(Jye);return a.cacheRoot=e??a,a.base=t,a.overlay=n,a.depth=r,a._flat=void 0,a.baseHits=0,a.maxDepth=i,a},bT=(e,t)=>{t&&(bT(e,t.parent),e.set(t.key,t.value))},xT=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return bT(t,e.overlay),e._flat=t},qye=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),yT(void 0,n,void 0,0,e.maxDepth)},ST=Symbol(),CT=(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)?ST:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=8&&(n.base=xT(n),n.overlay=void 0,n.depth=0),r)},wT=(e,t)=>{let n=t?.maxDepth;return yT(void 0,e,void 0,0,Number.isInteger(n)&&n>=0?n:8)},Jye={get mapUnsafe(){return xT(this)},...Cw,[vT]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[VC](e){if(!TT(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)||!HC(r,n.get(e)))return!1;return!0},[TC](){return MC(this.mapUnsafe.size)}},Yye=(e,t)=>e.cacheRoot===t.cacheRoot,TT=e=>wC(e,vT),Xye=e=>!!e[_T],ET=()=>Zye,Zye=wT(new Map),DT=(e,t)=>wT(new Map([[e.key,t]])),OT=sC(3,(e,t,n)=>Qye(e,t.key,n)),Qye=(e,t,n)=>{let r=e,i=gT.has(t)?void 0:r.cacheRoot;if(r.depth>=r.maxDepth){let e=new Map(r._flat??r.base);return r._flat||bT(e,r.overlay),e.set(t,n),yT(i,e,void 0,0,r.maxDepth)}return yT(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1,r.maxDepth)},kT=sC(2,(e,t)=>AT(e,t.key)),AT=(e,t)=>{let n=CT(e,t);return n===ST?void 0:n},jT=sC(2,(e,t)=>{let n=CT(e,t.key);if(n===ST){if(Xye(t))return $ye(t);throw ebe(t)}return n}),MT=`~effect/Context/defaultValue`,$ye=e=>MT in e?e[MT]:e[MT]=e.defaultValue(),ebe=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
|
|
262
262
|
`);e.splice(1,3),t.stack=e.join(`
|
|
@@ -449,7 +449,7 @@ tmp="$dir/.connection.$$"
|
|
|
449
449
|
exec "$xfce"
|
|
450
450
|
`,nN=(e,t)=>{let n=t.slice(1);return{lock:d(e,`.X${n}-lock`),socket:d(e,`.X11-unix`,`X${n}`)}},rN=e=>({home:d(e,`home`),runtime:d(e,`runtime`),logs:d(e,`logs`),captures:d(e,`captures`),connection:d(e,`connection`)}),iN=e=>{if(e.kind===`adopted`)return{...e.connection};let t=rN(e.guest_dir);return{DISPLAY:e.display,HOME:t.home,XDG_CONFIG_HOME:d(t.home,`.config`),XDG_CACHE_HOME:d(t.home,`.cache`),XDG_DATA_HOME:d(t.home,`.local/share`),XDG_RUNTIME_DIR:t.runtime,XDG_CURRENT_DESKTOP:`XFCE`,XDG_SESSION_TYPE:`x11`,DESKTOP_SESSION:`xfce`}},eEe=e=>e.kind===`owned`?rN(e.guest_dir).home:e.guest_dir,aN=(e,t,n,r,i,a,o=t.probe_timeout_s)=>MO(function*(){let s=yield*lM,c=yield*FM(i,o),l=c<o*1e3,u=t.tools[n];if(u===void 0)return yield*z(`no resolved tool named ${n}`);let f=yield*s.run([u,...r],{timeoutMs:c,env:{...a,LC_ALL:`C`},unsetEnv:tN,cwd:eEe(t)}).pipe(WO(e=>new _M({reason:`${n} read could not run: ${e.message}`}))),p=d(e,`probes`,`${n}.json`),m=yield*MM;return f.timedOut?(yield*DM(p,{timed_out:!0,timeout_seconds:c/1e3,observed_at:m}),yield*NO(new _M({reason:`${n} read timed out; see private probes/${n}.json`,...l?{deadline:!0}:{}}))):(yield*DM(p,{native_exit:f.exitCode,stdout:f.stdout,stderr:f.stderr,observed_at:m}),f.exitCode===0?f.stdout:yield*z(`${n} read failed; see private probes/${n}.json`,f.exitCode))}),oN=e=>t=>new _M({reason:`${e}: ${t.message}`}),sN=(e,t,n=!1)=>pM(e,t).pipe(WO(e=>new _M({reason:`process identity read failed: ${e.message}`,...n&&e.timedOut===!0?{deadline:!0}:{}}))),cN=(e,t,n)=>LO(FM(t,n),t=>sN(e,t,t<n*1e3)),lN=(e,t)=>e?.kind===`running`&&fM(e.identity)===fM(t),uN=(e,t)=>MO(function*(){let n=Object.entries(e.children),r=[];e.xfce!==void 0&&r.push([`xfce`,e.xfce]),e.x_server!==void 0&&r.push([`X server`,e.x_server]);let i=[...n,...r];if(i.length===0)return;for(let[e,t]of i)if(!Number.isInteger(t.pid)||t.pid<=1)return yield*z(`${e} has a reserved or malformed recorded process identity`);let a=yield*cN(i.map(([,e])=>e.pid),t,e.probe_timeout_s);for(let[e,[t,n]]of i.entries())if(!lN(a[e],n))return yield*z(`${t} launch identity changed`)}),dN=(e,t,n)=>MO(function*(){let{lock:r}=nN(e.x11_dir,e.display),i=yield*hM(r,yield*FM(t,e.probe_timeout_s)).pipe(WO(oN(`display lock read failed`)));if(!/^\s*\d+\s*$/u.test(i.content)||Number(i.content.trim())!==n)return yield*z(`display lock does not identify the held X server`);if(i.ownerUid!==e.lock_owner_uid)return yield*z(`display lock belongs to another user`)}),tEe=e=>{let t={};for(let n of e.split(`
|
|
451
451
|
`)){let e=n.indexOf(`=`);e>0&&(t[n.slice(0,e)]=n.slice(e+1))}return t},nEe=(e,t)=>MO(function*(){let n=yield*(yield*lM).readFile(rN(e.guest_dir).connection,yield*FM(t,e.probe_timeout_s)).pipe(WO(oN(`session connection data is not readable yet`))),r=tEe(new TextDecoder().decode(n));if(r.RUN_ID!==e.run_id)return yield*z(`connection belongs to another launch`);let i=Number(r.PID);if(!Number.isInteger(i)||i<=1)return yield*z(`connection names no XFCE process`);let a=iN(e);for(let e of eN){if(r[e]===void 0)return yield*z(`session connection data is incomplete`);if(e!==`DBUS_SESSION_BUS_ADDRESS`&&r[e]!==a[e])return yield*z(`session connection data changed`)}return(r.DBUS_SESSION_BUS_ADDRESS??``).startsWith(`unix:`)?{pid:i,bus:r.DBUS_SESSION_BUS_ADDRESS??``}:yield*z(`dbus-run-session did not provide a local bus`)}),fN=e=>({...iN(e),...e.kind===`owned`&&e.connection.DBUS_SESSION_BUS_ADDRESS!==void 0?{DBUS_SESSION_BUS_ADDRESS:e.connection.DBUS_SESSION_BUS_ADDRESS}:{}}),rEe=e=>{let t=/dimensions:\s+(\d+)x(\d+)\s+pixels/u.exec(e);return t?[Number(t[1]),Number(t[2])]:void 0},pN=(e,t,n)=>MO(function*(){let r=t,i=()=>FM(n,r.probe_timeout_s);yield*uN(r,n);let a=r.kind===`owned`?r.children.xvfb?.pid:r.x_server?.pid;if(a===void 0)return yield*z(`session records no X server`);yield*dN(r,n,a);let o=r.kind===`adopted`||r.children.session!==void 0;if(r.kind===`owned`&&o){let e=yield*nEe(r,n);if(r.xfce===void 0){let[t]=yield*cN([e.pid],n,r.probe_timeout_s);if(t?.kind!==`running`)return yield*z(`XFCE launch identity changed`);r={...r,xfce:t.identity,connection:{...r.connection,DBUS_SESSION_BUS_ADDRESS:e.bus}}}else if(e.pid!==r.xfce.pid)return yield*z(`XFCE launch identity changed`)}let s=fN(r),c=yield*aN(e,r,`xdpyinfo`,[],n,s),l=rEe(c);if(l===void 0||l[0]!==r.dimensions[0]||l[1]!==r.dimensions[1])return yield*z(`X display dimensions do not match the requested geometry`);if(!o)return{observation:{dimensions:r.dimensions},session:r};let u=yield*aN(e,r,`xprop`,[`-root`,`_NET_SUPPORTING_WM_CHECK`],n,s),d=/window id # (0x[0-9a-fA-F]+)\s*$/u.exec(u);if(d?.[1]===void 0||Number.parseInt(d[1],16)===0)return yield*z(`X root has no supporting window manager`);let f=d[1],p=yield*aN(e,r,`xprop`,[`-id`,f,`_NET_SUPPORTING_WM_CHECK`,`_NET_WM_PID`],n,s),m=/_NET_SUPPORTING_WM_CHECK\(WINDOW\): window id # (0x[0-9a-fA-F]+)/u.exec(p),h=/_NET_WM_PID\(CARDINAL\)\s*=\s*(\d+)/u.exec(p);if(m?.[1]===void 0||Number.parseInt(m[1],16)!==Number.parseInt(f,16)||h?.[1]===void 0||Number(h[1])<=1)return yield*z(`window manager support window is stale or incomplete`);let g=yield*aN(e,r,`wmctrl`,[`-m`],n,s),_=/^Name:\s*(.+)$/mu.exec(g),v=/^PID:\s*(\d+)\s*$/mu.exec(g);if(_?.[1]?.trim()!==`Xfwm4`||v?.[1]===void 0||Number(v[1])!==Number(h[1]))return yield*z(`wmctrl does not identify the same Xfwm4 window manager`);let[y]=yield*cN([Number(h[1])],n,r.probe_timeout_s);if(y?.kind!==`running`)return yield*z(`window manager process is not running`);if(r.kind===`owned`){let e=r.children.session?.pid,t=yield*FTe(y.identity.pid,yield*i()).pipe(WO(oN(`window manager ancestry read failed`)));if(e===void 0||!t.includes(e))return yield*z(`window manager does not descend from the held XFCE launch`)}else if(r.window_manager!==void 0&&fM(r.window_manager)!==fM(y.identity))return yield*z(`window manager identity changed`);return yield*uN(r,n),yield*dN(r,n,a),r.keyring?.phase===`ready`&&(yield*ZTe(r,r.keyring,n,tN)),{observation:{dimensions:r.dimensions,window_manager:{name:`Xfwm4`,window:f,identity:y.identity}},session:r}}),mN=(e,t,n,r)=>MO(function*(){let i=`no completed readiness observation`;for(;;){let a=Object.entries(t.children);if(a.length>0){let e=yield*cN(a.map(([,e])=>e.pid),n,t.probe_timeout_s);for(let[t,[n,r]]of a.entries())if(!lN(e[t],r))return yield*z(`${n} exited before or during readiness`)}let o=yield*RO(pN(e,t,n));if(o._tag===`Success`)return o.success;i=o.failure.reason;let s=yield*NM,c=n.endMs-s;if(c<=0)return yield*z(`readiness expired after ${r}s: ${i}`);yield*JO(Math.min(100,c))}}),iEe=(e,t)=>e===void 0||e.kind===`absent`||e.kind===`zombie`||e.kind===`running`&&fM(e.identity)!==fM(t),hN=(e,t,n)=>XO(MO(function*(){let r=yield*lM,i={},a=yield*PM(t),o={endMs:a.endMs-t*1e3/2},s=new Map;for(let[n,i]of e){let e=yield*RO(r.watchExit(i.pid,t*1e3));e._tag===`Success`&&s.set(n,e.success)}let c=new Map(e),l=new Map,u=new Set,d=e=>MO(function*(){for(let[t,r]of c){let o=yield*PTe(r,e,Math.min(n*1e3,Math.max(1,a.endMs-(yield*NM)))).pipe(KO(()=>`error`));o===`sent`?l.set(t,e):o===`gone`?(c.delete(t),i[t]={outcome:`ended`,by:l.get(t)??`already`}):o===`changed`?(c.delete(t),u.add(t),i[t]={outcome:`ended`,by:l.get(t)??`already`,reason:`its process id now names another process, which was sent no signal`}):(c.delete(t),i[t]={outcome:`unresolved`,reason:o===`invalid`?`reserved or malformed process identity; no signal sent`:`the identity-checked signal could not be sent`})}}),f=e=>MO(function*(){for(;;){if(c.size===0)return;let t=[...c],r=yield*sN(t.map(([,e])=>e.pid),Math.min(n*1e3,Math.max(1,a.endMs-(yield*NM)))).pipe(KO(()=>[]));for(let[e,[n,a]]of t.entries())r.length===t.length&&iEe(r[e],a)&&(c.delete(n),i[n]={outcome:`ended`,by:l.get(n)??`already`});if(c.size===0||(yield*NM)>=e.endMs)return;yield*JO(100)}});yield*d(`TERM`),yield*f(o),c.size>0&&(yield*d(`KILL`),yield*f(a));for(let[e]of c)i[e]={outcome:`unresolved`,reason:`still running after the shutdown budget`};for(let[e,t]of Object.entries(i)){let n=s.get(e);if(t.outcome===`ended`&&n!==void 0&&!u.has(e)){let r=yield*RO(qO(n,{duration:2e3,orElse:()=>DO(void 0)}));i[e]={...t,exit_code:r._tag===`Success`?r.success??null:null}}else t.outcome===`ended`&&(i[e]={...t,exit_code:null})}return i})),gN=(e,t)=>MO(function*(){if(yield*TM(e.stateDir))return yield*z(`fresh-only launch refuses existing path: ${e.stateDir}`);let n=yield*mM(e.guestPaths,t).pipe(WO(oN(`path check failed`))),r=e.guestPaths.find((e,t)=>n[t]===!0);if(r!==void 0)return yield*z(`fresh-only launch refuses existing path: ${r}`)}),_N=(e,t,n)=>MO(function*(){let r=yield*ITe(e,t,n).pipe(WO(oN(`tool check failed`)));return r.kind===`missing`?yield*z(`tool directory contains a missing or non-executable prerequisite: ${r.name}`):r.tools}),vN=(e,t,n,r,i,a)=>MO(function*(){let o=yield*(yield*lM).start(t,{env:n,unsetEnv:tN,cwd:r,logPath:i}).pipe(WO(oN(`${e} could not start`))),[s]=yield*sN([o],a);return s?.kind===`running`?s.identity:yield*z(`${e} exited before or during readiness`)}),aEe=e=>MO(function*(){let t=yield*lM,n=e.probeTimeout*1e3,r=rN(e.guestDir),i=nN(e.x11Dir,e.display);yield*gN({stateDir:e.stateDir,guestPaths:[e.guestDir,i.lock,i.socket]},n);let a=yield*_N(e.toolDir,e.keyring?[...QM,...IM]:QM,n),[o,s]=e.geometry.split(`x`).map(Number);yield*EM(e.stateDir);for(let[t,i]of[[e.guestDir,!0],[r.home,!1],[r.runtime,!1],[r.logs,!1],[r.captures,!1]])yield*gM(t,i,n).pipe(WO(oN(`guest directory setup failed`)));let c=yield*RTe(n).pipe(WO(oN(`uid read failed`))),l={schema:`use-cloud-vms/linux-desktop/session@1`,run_id:b().replaceAll(`-`,``),guest:t.name,kind:`owned`,phase:`starting`,display:e.display,dimensions:[o??0,s??0],geometry:e.geometry,x11_dir:e.x11Dir,guest_dir:e.guestDir,tools:a,probe_timeout_s:e.probeTimeout,ready_timeout_s:e.readyTimeout,shutdown_timeout_s:e.shutdownTimeout,lock_owner_uid:c,children:{},connection:{},apps:{},guest_retirement_required:!0};yield*jM(e.stateDir,l);let u=yield*PM(e.readyTimeout),f=iN(l),p=MO(function*(){let t=yield*vN(`xvfb`,[a.Xvfb??``,e.display,`-screen`,`0`,e.geometry,`-nolisten`,`tcp`,`-ac`,`+extension`,`RANDR`],f,r.home,d(r.logs,`xvfb.log`),n);l={...l,children:{xvfb:t}},yield*jM(e.stateDir,l),yield*mN(e.stateDir,l,u,e.readyTimeout);let i=yield*vN(`session`,[a[`dbus-run-session`]??``,`--`,`/bin/sh`,`-c`,$Te,`sh`,e.guestDir,l.run_id,a.startxfce4??``],f,r.home,d(r.logs,`xfce.log`),n);l={...l,children:{...l.children,session:i}},yield*jM(e.stateDir,l);let o=yield*mN(e.stateDir,l,u,e.readyTimeout);return l=o.session,e.keyring&&(l=yield*GM({stateDir:e.stateDir,session:l,deadline:u,env:VM(fN(l),BM(l.guest_dir).dir),unsetEnv:tN})),l={...l,phase:`ready`,observed:o.observation,ready_at:yield*MM},yield*jM(e.stateDir,l),o.observation}),m=yield*RO(p);if(m._tag===`Success`)return{status:`ready`,state_dir:e.stateDir,run_id:l.run_id,guest:l.guest,observed:m.success,...l.keyring?.phase===`ready`?{keyring:ZM(l.keyring)}:{}};let h=e.keyring?yield*RO(AM(e.stateDir)):void 0,g=h?._tag===`Success`&&h.success.run_id===l.run_id?h.success.keyring:l.keyring,_=Object.entries(l.children),v={...yield*hN([...qM(g),..._.toReversed()],e.shutdownTimeout,e.probeTimeout),...JM(g)};return l={...l,...g===void 0?{}:{keyring:XM(g,v,m.failure.reason)},phase:`failed`,reason:m.failure.reason,ended:{direct_children:v,at:yield*MM}},yield*jM(e.stateDir,l).pipe(GO),yield*NO(m.failure)}),oEe=(e,t,n,r)=>MO(function*(){let i=yield*RO(GM({stateDir:e,session:t,deadline:n,env:VM(fN(t),BM(t.guest_dir).dir),unsetEnv:tN}).pipe(LO(e=>r(e).pipe(WO(vM)))));if(i._tag===`Success`)return i.success;let a=yield*RO(AM(e)),o=a._tag===`Success`?a.success.keyring:void 0,s={...yield*hN(qM(o),t.shutdown_timeout_s,t.probe_timeout_s),...JM(o)};return o!==void 0&&a._tag===`Success`&&(yield*jM(e,{...a.success,phase:`failed`,reason:i.failure.reason,keyring:XM(o,s,i.failure.reason)}).pipe(GO)),yield*NO(i.failure)}),sEe=e=>MO(function*(){let t=yield*lM,n=e.probeTimeout*1e3,r=rN(e.guestDir);yield*gN({stateDir:e.stateDir,guestPaths:[e.guestDir]},n);let i=yield*_N(e.toolDir,e.keyring?[...$M,...IM]:$M,n),[a,o]=e.geometry.split(`x`).map(Number),s=yield*PM(Math.max(e.probeTimeout*8,1)),{lock:c}=nN(e.x11Dir,e.display),l=yield*hM(c,yield*FM(s,e.probeTimeout)).pipe(WO(oN(`display lock read failed`)));if(!/^\s*\d+\s*$/u.test(l.content))return yield*z(`display lock does not name an X server`);let[u]=yield*sN([Number(l.content.trim())],yield*FM(s,e.probeTimeout));if(u?.kind!==`running`)return yield*z(`display lock names no running X server`);yield*EM(e.stateDir);for(let[t,i]of[[e.guestDir,!0],[r.logs,!1],[r.captures,!1]])yield*gM(t,i,n).pipe(WO(oN(`guest directory setup failed`)));let d={schema:`use-cloud-vms/linux-desktop/session@1`,run_id:b().replaceAll(`-`,``),guest:t.name,kind:`adopted`,phase:`starting`,display:e.display,dimensions:[a??0,o??0],geometry:e.geometry,x11_dir:e.x11Dir,guest_dir:e.guestDir,tools:i,probe_timeout_s:e.probeTimeout,ready_timeout_s:e.probeTimeout,shutdown_timeout_s:e.probeTimeout*2,lock_owner_uid:l.ownerUid,children:{},x_server:u.identity,connection:{DISPLAY:e.display},apps:{},guest_retirement_required:e.keyring};yield*jM(e.stateDir,d);let f=yield*pN(e.stateDir,d,s),p=f.observation.window_manager;if(p===void 0)return yield*z(`adopted display has no window manager`);let m=yield*LTe(p.identity.pid,QTe,yield*FM(s,e.probeTimeout)).pipe(WO(oN(`window manager environment read failed`)));d={...d,window_manager:p.identity,connection:{...m,DISPLAY:e.display},observed:f.observation};let h=t=>MO(function*(){let n={...t,phase:`ready`,ready_at:yield*MM};return yield*jM(e.stateDir,n),n});return d=e.keyring?yield*oEe(e.stateDir,d,s,h):yield*h(d),{status:`ready`,state_dir:e.stateDir,run_id:d.run_id,guest:d.guest,observed:f.observation,connection_keys:Object.keys(d.connection).toSorted(),...d.keyring?.phase===`ready`?{keyring:ZM(d.keyring)}:{}}}),yN=(e,t)=>MO(function*(){let n=yield*PM(t),r=yield*AM(e);if(r.phase!==`ready`)return yield*z(`session is not in its ready phase`);let i={...r,probe_timeout_s:Math.min(r.probe_timeout_s,t)},a=yield*pN(e,i,n),o=yield*AM(e);return o.phase!==`ready`||o.run_id!==r.run_id?yield*z(`session changed while readiness was inspected`):{session:r,observation:a.observation,deadline:n}}),cEe=(e,t)=>MO(function*(){let n=yield*AM(e);if(n.phase===`stopped`||n.phase===`released`)return{status:n.phase,already:!0,run_id:n.run_id};let r=[],i=t=>jM(e,t).pipe(HO(`Unavailable`,e=>kO(()=>void r.push(e.reason))));n={...n,phase:`stopping`},yield*i(n);let a=Object.entries(n.apps).flatMap(([e,t])=>t.phase===`running`||t.phase===`unresolved`?[[`app:${e}`,t.identity]]:[]),o=n.kind===`owned`?Object.entries(n.children).toReversed():[],s={...yield*hN([...a,...qM(n.keyring),...o],t,n.probe_timeout_s),...JM(n.keyring)},c={...n.apps};for(let[e,t]of Object.entries(n.apps)){let n=s[`app:${e}`];t.phase===`unidentified`?s[`app:${e}`]={outcome:`unresolved`,reason:t.pid===null?`${t.reason}; no signal sent`:`process ${t.pid} was never identified; no signal sent`}:n!==void 0&&(c[e]={...t,phase:n.outcome===`ended`?`terminated`:`unresolved`,ended:n})}let l=Object.values(s).some(e=>e.outcome===`unresolved`),u=n.kind===`owned`?`stopped`:`released`;return n={...n,apps:c,...n.keyring===void 0?{}:{keyring:YM(n.keyring,s)},phase:l?`stopping`:u,ended:{direct_children:s,at:yield*MM}},yield*i(n),{status:n.phase,run_id:n.run_id,direct_children:s,guest_retirement_required:n.guest_retirement_required||l,state_write_errors:r,failed:l||r.length>0}}),lEe=e=>e.split(`
|
|
452
|
-
`).map(e=>/^(0x[0-9a-fA-F]+)\s+(-?\d+)\s+(\d+)\s+(\S+)\s?(.*)$/u.exec(e)).filter(e=>e!==null).map(e=>({id:e[1]??``,pid:Number(e[3]),title:e[5]??``})),bN=(e,t)=>{let n=RegExp(`^\\s*${t}:\\s*(-?\\d+)\\s*$`,`mu`).exec(e);return n?.[1]===void 0?void 0:Number(n[1])},xN=(e,t)=>{let n=RegExp(`^${t}\\(CARDINAL\\) = (\\d+), (\\d+), (\\d+), (\\d+)$`,`mu`).exec(e);return n===null?RegExp(`^${t}:\\s+not found\\.$`,`mu`).test(e)?[0,0,0,0]:void 0:[Number(n[1]),Number(n[2]),Number(n[3]),Number(n[4])]},SN=(e,t,n,r)=>MO(function*(){if(!/^0x[0-9a-fA-F]+$/u.test(n))return yield*z(`window id ${n} is not an X window id`);let i=yield*aN(e,t,`xwininfo`,[`-id`,n],r,fN(t)),a=bN(i,`Absolute upper-left X`),o=bN(i,`Absolute upper-left Y`),s=bN(i,`Width`),c=bN(i,`Height`);if(a===void 0||o===void 0||s===void 0||c===void 0)return yield*z(`xwininfo did not report the window's geometry`);let l=yield*aN(e,t,`xprop`,[`-id`,n,`_GTK_FRAME_EXTENTS`,`_NET_FRAME_EXTENTS`],r,fN(t)),u=xN(l,`_GTK_FRAME_EXTENTS`);if(u===void 0)return yield*z(`xprop reported an unreadable _GTK_FRAME_EXTENTS`);let d=xN(l,`_NET_FRAME_EXTENTS`);if(d===void 0)return yield*z(`xprop reported an unreadable _NET_FRAME_EXTENTS`);let[f,p,m,h]=u,[g,_,v,y]=d;return{x:a+f-g,y:o+m-v,width:s-f-p+g+_,height:c-m-h+v+y,viewable:/Map State:\s*IsViewable/u.test(i),gtk_frame_extents:u,net_frame_extents:d}}),uEe=/^_NET_CLIENT_LIST_STACKING\(WINDOW\): window id # (.*)$/mu,dEe=(e,t,n)=>MO(function*(){let r=yield*aN(e,t,`xprop`,[`-root`,`_NET_CLIENT_LIST_STACKING`],n,fN(t)),i=uEe.exec(r)?.[1]?.split(`,`).map(e=>e.trim());return i===void 0||!i.every(e=>/^0x[0-9a-fA-F]+$/u.test(e))?yield*z(`xprop reported an unreadable _NET_CLIENT_LIST_STACKING`):i}),fEe=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,pEe=(e,t,n,r,i)=>MO(function*(){let a=yield*dEe(e,t,i),o=a.findIndex(e=>Number.parseInt(e,16)===Number.parseInt(n,16));if(o<0)return yield*z(`window ${n} is not in the window manager's stacking order`);let s=[];for(let n of a.slice(o+1)){let a=yield*SN(e,t,n,i);a.viewable&&fEe(a,r)&&s.push(n)}return s}),CN=(e,t,n,r)=>MO(function*(){let i=yield*aN(e,t,`wmctrl`,[`-lp`],r,fN(t)),a=lEe(i).filter(e=>n===void 0||e.pid===n),o=[];for(let n of a){let i=yield*SN(e,t,n.id,r);o.push({...n,x:i.x,y:i.y,width:i.width,height:i.height,gtk_frame_extents:i.gtk_frame_extents,net_frame_extents:i.net_frame_extents})}return o}),mEe=/^[a-z0-9][a-z0-9-]{0,62}$/u,hEe=(e,t)=>{let n=e.connection.XDG_RUNTIME_DIR??fN(e).XDG_RUNTIME_DIR;return{...fN(e),...e.keyring?.phase===`ready`?{DBUS_SESSION_BUS_ADDRESS:e.keyring.address}:{},HOME:t,XDG_CONFIG_HOME:d(t,`.config`),XDG_CACHE_HOME:d(t,`.cache`),XDG_DATA_HOME:d(t,`.local/share`),XDG_RUNTIME_DIR:n??d(t,`.runtime`)}},wN=(e,t,n,r)=>MO(function*(){let i=n=>d(e.guest_dir,`logs`,n<=1?`app-${t}.log`:`app-${t}-${n}.log`);for(let t=n;;t+=1){let[n]=yield*mM([i(t)],yield*FM(r,e.probe_timeout_s)).pipe(WO(e=>new _M({reason:`log path check failed: ${e.message}`})));if(n===!1)return i(t)}}),TN=(e,t,n)=>MO(function*(){let r=yield*AM(e),i=Object.fromEntries(Object.entries(r.apps).filter(([e])=>e!==t));yield*jM(e,{...r,apps:n===void 0?i:{...i,[t]:n}})}),EN=(e,t,n)=>MO(function*(){let r=yield*AM(e),i=r.apps[t];if(i===void 0)return yield*z(`no app named ${t}`);if(i.phase===`unidentified`)return yield*z(`app ${t} was never identified`);yield*jM(e,{...r,apps:{...r.apps,[t]:n(i)}})}),DN=(e,t,n,r,i,a=`app ${n} is no longer running`)=>MO(function*(){let[o]=yield*cN([r.identity.pid],i,t.probe_timeout_s);if(o?.kind!==`running`||fM(o.identity)!==fM(r.identity))return yield*EN(e,n,e=>({...e,phase:`ended`})),yield*z(a)}),ON=(e,t,n)=>new _M({reason:`app ${e} started as process ${t}, but ${n}; it cannot be signalled, so the guest must be retired`,retire:!0}),gEe=(e,t,n,r,i,a)=>MO(function*(){let o=yield*RO(TN(e,n,{...i,pid:r,phase:`unidentified`,reason:`its identity was not read yet`})),s=yield*RO(sN([r],t.probe_timeout_s*1e3));if(s._tag===`Failure`)return o._tag===`Failure`?yield*NO(ON(n,r,`it could not be recorded (${o.failure.reason}) and its identity could not be read (${s.failure.reason})`)):(yield*TN(e,n,{...i,pid:r,phase:`unidentified`,reason:s.failure.reason}).pipe(GO),yield*NO(ON(n,r,`its identity could not be read (${s.failure.reason})`)));let[c]=s.success;if(c?.kind!==`running`)return yield*TN(e,n,a).pipe(GO),yield*z(`app exited at once; see its log ${i.log}`);let l=yield*RO(TN(e,n,{...i,identity:c.identity,phase:`running`}));return l._tag===`Success`?c.identity:(yield*hN([[`app:${n}`,c.identity]],t.shutdown_timeout_s,t.probe_timeout_s))[`app:${n}`]?.outcome===`ended`?(yield*TN(e,n,a).pipe(GO),yield*z(`app ${n} started as process ${r} was ended because its record could not be written: ${l.failure.reason}`)):yield*NO(ON(n,r,`its record could not be written (${l.failure.reason}) and it could not be ended`))}),_Ee=(e,t,n,r,i)=>MO(function*(){if(r.notStarted===!0)return yield*TN(e,t,i).pipe(GO),yield*z(`app could not start: ${r.message}`);let a=`its start may have run, but returned no process id: ${r.message}`;return yield*TN(e,t,{...n,pid:null,phase:`unidentified`,reason:a}).pipe(GO),yield*NO(new _M({reason:`app ${t}: ${a}; it cannot be signalled, so the guest must be retired`,retire:!0}))}),vEe=e=>MO(function*(){if(!mEe.test(e.name))return yield*z(`app name must be lowercase letters, digits and hyphens`);if(!u(e.home))return yield*z(`app home must be an absolute guest path`);if(e.argv.length===0)return yield*z(`app launch needs a command after --`);let t=yield*AM(e.stateDir),{session:n,deadline:r}=yield*yN(e.stateDir,t.ready_timeout_s);if(n.apps[e.name]!==void 0)return yield*z(`an app named ${e.name} was already launched`);let i=yield*FM(r,n.probe_timeout_s),[a]=yield*mM([e.home],i).pipe(WO(e=>new _M({reason:`path check failed: ${e.message}`})));if(a===!0)return yield*z(`fresh-only launch refuses existing path: ${e.home}`);for(let t of[e.home,d(e.home,`.config`),d(e.home,`.cache`),d(e.home,`.local`),d(e.home,`.local/share`)])yield*gM(t,t===e.home,i).pipe(WO(e=>new _M({reason:`app home setup failed: ${e.message}`})));n.connection.XDG_RUNTIME_DIR===void 0&&n.kind===`adopted`&&(yield*gM(d(e.home,`.runtime`),!1,i).pipe(WO(e=>new _M({reason:`app home setup failed: ${e.message}`}))));let o={argv:[...e.argv],home:e.home,log:yield*wN(n,e.name,1,r),launched_at:yield*MM};return yield*kN(e.stateDir,n,e.name,o,e.timeout,void 0)}),kN=(e,t,n,r,i,a)=>MO(function*(){let o=yield*lM;yield*TN(e,n,{...r,pid:null,phase:`unidentified`,reason:`its start was requested, but no process id was recorded`}).pipe(WO(e=>new _M({reason:`app ${n} was not started, because it could not be recorded first: ${e.reason}`})));let s=yield*NM,c=yield*RO(o.start(r.argv,{env:hEe(t,r.home),unsetEnv:tN,cwd:r.home,logPath:r.log}));if(c._tag===`Failure`)return yield*_Ee(e,n,r,c.failure,a);let l=yield*gEe(e,t,n,c.success,r,a),u={...r,identity:l,phase:`running`},d=yield*PM(i);return yield*MO(function*(){for(;;){let a=yield*CN(e,t,l.pid,d);if(yield*DN(e,t,n,u,d,`app exited before it showed a window; see its log ${r.log}`),a.length>0)return{status:`launched`,app:n,identity:l,home:r.home,log:r.log,windows:a,launch_to_window_ms:(yield*NM)-s};let o=d.endMs-(yield*NM);if(o<=0)return yield*z(`app showed no window within ${i}s`);yield*JO(Math.min(250,o))}}).pipe(KTe(`app showed no window within ${i}s`))}),yEe=e=>MO(function*(){let t=yield*AM(e.stateDir),{session:n,deadline:r}=yield*yN(e.stateDir,t.ready_timeout_s),i=n.apps[e.name];if(i===void 0)return yield*z(`no app named ${e.name}`);if(i.phase===`running`)return yield*z(`app ${e.name} is running`);if(i.phase===`unidentified`||i.phase===`unresolved`)return yield*z(`app ${e.name} is ${i.phase}, so it may still be running; it cannot be relaunched`);let{previous:a=[],...o}=i,s={argv:i.argv,home:i.home,log:yield*wN(n,e.name,a.length+2,r),launched_at:yield*MM,previous:[...a,o]};return yield*kN(e.stateDir,n,e.name,s,e.timeout,i)}),AN=(e,t)=>MO(function*(){let n=e.apps[t];return n===void 0?yield*z(`no app named ${t}`):n.phase===`running`?n:yield*z(`app ${t} is ${n.phase}`)}),bEe=(e,t,n)=>MO(function*(){let{session:r,deadline:i}=yield*yN(e,n),a=yield*AN(r,t),o=yield*CN(e,r,a.identity.pid,i);return yield*DN(e,r,t,a,i),{status:`windows`,app:t,identity:a.identity,windows:o}}),xEe=(e,t,n)=>XO(MO(function*(){let r=yield*lM,i=yield*AM(e),{session:a,deadline:o}=yield*yN(e,i.ready_timeout_s),s=yield*AN(a,t),c=yield*CN(e,a,s.identity.pid,o);if(yield*DN(e,a,t,s,o),c.length===0)return yield*z(`app ${t} has no window to close`);let l=yield*RO(r.watchExit(s.identity.pid,n*1e3)),u=yield*NM,d=yield*MM;for(let t of c)yield*aN(e,a,`wmctrl`,[`-i`,`-c`,t.id],o,fN(a));let f=yield*PM(n);for(;;){let e=f.endMs-(yield*NM);if(e<=0)return yield*z(`app ${t} was asked to close and is still running after ${n}s`);let r=yield*RO(sN([s.identity.pid],Math.min(a.probe_timeout_s*1e3,e)));if(r._tag===`Failure`)return yield*z(`app ${t} was asked to close, but whether it ended could not be read: ${r.failure.reason}`);let[i]=r.success;if(i===void 0||i.kind===`absent`||i.kind===`zombie`||i.kind===`running`&&fM(i.identity)!==fM(s.identity))break;yield*JO(Math.max(0,Math.min(100,f.endMs-(yield*NM))))}let p=yield*NM,m=l._tag===`Success`?yield*l.success.pipe(qO({duration:2e3,orElse:()=>DO(void 0)}),KO(()=>void 0)):void 0,h=yield*CN(e,a,s.identity.pid,yield*PM(a.ready_timeout_s)),g={outcome:`closed`,windows_closed:c.map(e=>e.id),windows_left:h.map(e=>e.id),exit_code:m??null,close_requested_at:d,close_to_exit_ms:p-u};return yield*EN(e,t,e=>({...e,phase:`closed`,ended:g})),h.length>0?yield*z(`app ${t} ended but windows with its process id remain`):{status:`closed`,app:t,identity:s.identity,...g}})),jN=(e,t,n={})=>{let r={},i=0;for(;i<e.length;){let a=e[i]??``;if(a===`--`)return n.allowRest===!0?MN(r,t,e.slice(i+1)):{ok:!1,reason:`unexpected --`};let o=t[a];if(!a.startsWith(`--`)||o===void 0)return{ok:!1,reason:`unrecognized argument ${JSON.stringify(a)}`};if(r[a]!==void 0)return{ok:!1,reason:`${a} given more than once`};let s=e.slice(i+1,i+1+o.arity);if(s.length<o.arity||s.some(e=>e===`--`))return{ok:!1,reason:`${a} needs ${o.arity} value${o.arity===1?``:`s`}`};r[a]=s,i+=1+o.arity}return n.allowRest===!0?{ok:!1,reason:`missing -- before the command`}:MN(r,t,[])},MN=(e,t,n)=>{for(let[n,r]of Object.entries(t))if(r.required===!0&&e[n]===void 0)return{ok:!1,reason:`${n} is required`};return{ok:!0,values:e,rest:n}},SEe=e=>/^[+-]?\d+$/u.test(e)&&Number.isSafeInteger(Number(e))?Number(e):void 0;var NN=Oe(((e,t)=>{t.exports=ree.default})),PN=Oe(((e,t)=>{t.exports=ne.default})),FN=Oe(((e,t)=>{t.exports=eee.default})),IN=Oe(((e,t)=>{let n=NN(),r=PN(),i=t.exports=function(){r.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding=`utf8`,this.writable=!0};n.inherits(i,r),i.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit(`drain`))}.bind(this))},i.prototype.write=function(e,t){if(!this.writable)return this.emit(`error`,Error(`Stream not writable`)),!1;let n;return n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused},i.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))},i.prototype.destroySoon=i.prototype.end,i.prototype._end=function(){this._reads.length>0&&this.emit(`error`,Error(`Unexpected end of input`)),this.destroy()},i.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit(`close`))},i.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},i.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let i=this._buffers[n++],a=Math.min(i.length,e.length-t);i.copy(r,t,0,a),t+=a,a!==i.length&&(this._buffers[--n]=i.slice(a))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},i.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit(`error`,e)}}})),LN=Oe((e=>{let t=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];e.getImagePasses=function(e,n){let r=[],i=e%8,a=n%8,o=(e-i)/8,s=(n-a)/8;for(let e=0;e<t.length;e++){let n=t[e],c=o*n.x.length,l=s*n.y.length;for(let e=0;e<n.x.length&&n.x[e]<i;e++)c++;for(let e=0;e<n.y.length&&n.y[e]<a;e++)l++;c>0&&l>0&&r.push({width:c,height:l,index:e})}return r},e.getInterlaceIterator=function(e){return function(n,r,i){let a=n%t[i].x.length,o=(n-a)/t[i].x.length*8+t[i].x[a],s=r%t[i].y.length,c=(r-s)/t[i].y.length*8+t[i].y[s];return o*4+c*e*4}}})),RN=Oe(((e,t)=>{t.exports=function(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}})),zN=Oe(((e,t)=>{let n=LN(),r=RN();function i(e,t,n){let r=e*t;return n!==8&&(r=Math.ceil(r/(8/n))),r}let a=t.exports=function(e,t){let r=e.width,a=e.height,o=e.interlace,s=e.bpp,c=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],o){let e=n.getImagePasses(r,a);for(let t=0;t<e.length;t++)this._images.push({byteWidth:i(e[t].width,s,c),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:i(r,s,c),height:a,lineIndex:0});this._xComparison=c===8?s:c===16?s*2:1};a.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},a.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,i=r-1;for(let a=0;a<n;a++){let n=e[1+a],o=a>i?t[a-r]:0;t[a]=n+o}},a.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let i=0;i<n;i++){let n=e[1+i],a=r?r[i]:0;t[i]=n+a}},a.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,i=r-1,a=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],s=a?a[o]:0,c=o>i?t[o-r]:0,l=Math.floor((c+s)/2);t[o]=n+l}},a.prototype._unFilterType4=function(e,t,n){let i=this._xComparison,a=i-1,o=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],c=o?o[s]:0,l=s>a?t[s-i]:0,u=s>a&&o?o[s-i]:0,d=r(l,c,u);t[s]=n+d}},a.prototype._reverseFilterLine=function(e){let t=e[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(t===0)n=e.slice(1,i+1);else switch(n=Buffer.alloc(i),t){case 1:this._unFilterType1(e,n,i);break;case 2:this._unFilterType2(e,n,i);break;case 3:this._unFilterType3(e,n,i);break;case 4:this._unFilterType4(e,n,i);break;default:throw Error(`Unrecognised filter type - `+t)}this.write(n),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=n,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}})),CEe=Oe(((e,t)=>{let n=NN(),r=IN(),i=zN(),a=t.exports=function(e){r.call(this);let t=[],n=this;this._filter=new i(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit(`complete`,Buffer.concat(t))}}),this._filter.start()};n.inherits(a,r)})),BN=Oe(((e,t)=>{t.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}})),VN=Oe(((e,t)=>{let n=[];(function(){for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;n[e]=t}})();let r=t.exports=function(){this._crc=-1};r.prototype.write=function(e){for(let t=0;t<e.length;t++)this._crc=n[(this._crc^e[t])&255]^this._crc>>>8;return!0},r.prototype.crc32=function(){return this._crc^-1},r.crc32=function(e){let t=-1;for(let r=0;r<e.length;r++)t=n[(t^e[r])&255]^t>>>8;return t^-1}})),HN=Oe(((e,t)=>{let n=BN(),r=VN(),i=t.exports=function(e,t){this._options=e,e.checkCRC=e.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[n.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[n.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[n.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[n.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[n.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[n.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(n.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=n.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n]){this.error(Error(`Invalid file signature`));return}this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),i=e.readUInt32BE(4),a=``;for(let t=4;t<8;t++)a+=String.fromCharCode(e[t]);let o=!!(e[4]&32);if(!this._hasIHDR&&i!==n.TYPE_IHDR){this.error(Error(`Expected IHDR on beggining`));return}if(this._crc=new r,this._crc.write(Buffer.from(a)),this._chunks[i])return this._chunks[i](t);if(!o){this.error(Error(`Unsupported critical chunk type `+a));return}this.read(t+4,this._skipChunk.bind(this))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==t){this.error(Error(`Crc error - `+t+` - `+n));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),r=e.readUInt32BE(4),i=e[8],a=e[9],o=e[10],s=e[11],c=e[12];if(i!==8&&i!==4&&i!==2&&i!==1&&i!==16){this.error(Error(`Unsupported bit depth `+i));return}if(!(a in n.COLORTYPE_TO_BPP_MAP)){this.error(Error(`Unsupported color type`));return}if(o!==0){this.error(Error(`Unsupported compression method`));return}if(s!==0){this.error(Error(`Unsupported filter method`));return}if(c!==0&&c!==1){this.error(Error(`Unsupported interlace method`));return}this._colorType=a;let l=n.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:r,depth:i,interlace:!!c,palette:!!(a&n.COLORTYPE_PALETTE),color:!!(a&n.COLORTYPE_COLOR),alpha:!!(a&n.COLORTYPE_ALPHA),bpp:l,colorType:a}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[n*3],e[n*3+1],e[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===n.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error(`Transparency chunk must be after palette`));return}if(e.length>this._palette.length){this.error(Error(`More transparent colors than palette size`));return}for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===n.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===n.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/n.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===n.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error(`Expected palette not found`);this.inflateData(t);let r=e-t.length;r>0?this._handleIDAT(r):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}})),UN=Oe((e=>{let t=LN(),n=[function(){},function(e,t,n,r){if(r===t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],r=[function(){},function(e,t,n,r){let i=t[0];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];function i(e,t){let n=[],r=0;function i(){if(r===e.length)throw Error(`Ran out of data`);let i=e[r];r++;let a,o,s,c,l,u,d,f;switch(t){default:throw Error(`unrecognised depth`);case 16:d=e[r],r++,n.push((i<<8)+d);break;case 4:d=i&15,f=i>>4,n.push(f,d);break;case 2:l=i&3,u=i>>2&3,d=i>>4&3,f=i>>6&3,n.push(f,d,u,l);break;case 1:a=i&1,o=i>>1&1,s=i>>2&1,c=i>>3&1,l=i>>4&1,u=i>>5&1,d=i>>6&1,f=i>>7&1,n.push(f,d,u,l,c,s,o,a)}}return{get:function(e){for(;n.length<e;)i();let t=n.slice(0,e);return n=n.slice(e),t},resetAfterLine:function(){n.length=0},end:function(){if(r!==e.length)throw Error(`extra data found`)}}}function a(e,t,r,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++)for(let c=0;c<s;c++){let s=r(c,e,l);n[i](t,a,s,o),o+=i}return o}function o(e,t,n,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++){for(let c=0;c<s;c++){let s=a.get(i),u=n(c,e,l);r[i](t,s,u,o)}a.resetAfterLine()}}e.dataToBitMap=function(e,n){let r=n.width,s=n.height,c=n.depth,l=n.bpp,u=n.interlace,d;c!==8&&(d=i(e,c));let f;f=c<=8?Buffer.alloc(r*s*4):new Uint16Array(r*s*4);let p=2**c-1,m=0,h,g;if(u)h=t.getImagePasses(r,s),g=t.getInterlaceIterator(r,s);else{let e=0;g=function(){let t=e;return e+=4,t},h=[{width:r,height:s}]}for(let t=0;t<h.length;t++)c===8?m=a(h[t],f,g,l,e,m):o(h[t],f,g,l,d,p);if(c===8){if(m!==e.length)throw Error(`extra data found`)}else d.end();return f}})),WN=Oe(((e,t)=>{function n(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=i[e[a]];if(!n)throw Error(`index `+e[a]+` not in palette`);for(let e=0;e<4;e++)t[a+e]=n[e];a+=4}}function r(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=!1;if(i.length===1?i[0]===e[a]&&(n=!0):i[0]===e[a]&&i[1]===e[a+1]&&i[2]===e[a+2]&&(n=!0),n)for(let e=0;e<4;e++)t[a+e]=0;a+=4}}function i(e,t,n,r,i){let a=2**i-1,o=0;for(let i=0;i<r;i++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[o+n]=Math.floor(e[o+n]*255/a+.5);o+=4}}t.exports=function(e,t,a=!1){let o=t.depth,s=t.width,c=t.height,l=t.colorType,u=t.transColor,d=t.palette,f=e;return l===3?n(e,f,s,c,d):(u&&r(e,f,s,c,u),o!==8&&!a&&(o===16&&(f=Buffer.alloc(s*c*4)),i(e,f,s,c,o))),f}})),wEe=Oe(((e,t)=>{let n=NN(),r=FN(),i=IN(),a=CEe(),o=HN(),s=UN(),c=WN(),l=t.exports=function(e){i.call(this),this._parser=new o(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,`gamma`),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};n.inherits(l,i),l.prototype._handleError=function(e){this.emit(`error`,e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on(`error`,function(){})),this.errord=!0},l.prototype._inflateData=function(e){if(!this._inflate){if(this._bitmapInfo.interlace)this._inflate=r.createInflate(),this._inflate.on(`error`,this.emit.bind(this,`error`)),this._filter.on(`complete`,this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,r.Z_MIN_CHUNK);this._inflate=r.createInflate({chunkSize:t});let n=e,i=this.emit.bind(this,`error`);this._inflate.on(`error`,function(e){n&&i(e)}),this._filter.on(`complete`,this._complete.bind(this));let a=this._filter.write.bind(this._filter);this._inflate.on(`data`,function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,a(e))}),this._inflate.on(`end`,this._filter.end.bind(this._filter))}}this._inflate.write(e)},l.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new a(this._bitmapInfo)},l.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},l.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},l.prototype._simpleTransparency=function(){this._metaData.alpha=!0},l.prototype._headersFinished=function(){this.emit(`metadata`,this._metaData)},l.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit(`error`,`No Inflate block`))},l.prototype._complete=function(e){if(this.errord)return;let t;try{let n=s.dataToBitMap(e,this._bitmapInfo);t=c(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(e){this._handleError(e);return}this.emit(`parsed`,t)}})),TEe=Oe(((e,t)=>{let n=BN();t.exports=function(e,t,r,i){let a=[n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(i.colorType)!==-1;if(i.colorType===i.inputColorType){let t=(function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]!==256})();if(i.bitDepth===8||i.bitDepth===16&&t)return e}let o=i.bitDepth===16?new Uint16Array(e.buffer):e,s=255,c=n.COLORTYPE_TO_BPP_MAP[i.inputColorType];c===4&&!i.inputHasAlpha&&(c=3);let l=n.COLORTYPE_TO_BPP_MAP[i.colorType];i.bitDepth===16&&(s=65535,l*=2);let u=Buffer.alloc(t*r*l),d=0,f=0,p=i.bgColor||{};p.red===void 0&&(p.red=s),p.green===void 0&&(p.green=s),p.blue===void 0&&(p.blue=s);function m(){let e,t,r,c=s;switch(i.inputColorType){case n.COLORTYPE_COLOR_ALPHA:c=o[d+3],e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_COLOR:e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_ALPHA:c=o[d+1],e=o[d],t=e,r=e;break;case n.COLORTYPE_GRAYSCALE:e=o[d],t=e,r=e;break;default:throw Error(`input color type:`+i.inputColorType+` is not supported at present`)}return i.inputHasAlpha&&(a||(c/=s,e=Math.min(Math.max(Math.round((1-c)*p.red+c*e),0),s),t=Math.min(Math.max(Math.round((1-c)*p.green+c*t),0),s),r=Math.min(Math.max(Math.round((1-c)*p.blue+c*r),0),s))),{red:e,green:t,blue:r,alpha:c}}for(let e=0;e<r;e++)for(let e=0;e<t;e++){let e=m(o,d);switch(i.colorType){case n.COLORTYPE_COLOR_ALPHA:case n.COLORTYPE_COLOR:i.bitDepth===8?(u[f]=e.red,u[f+1]=e.green,u[f+2]=e.blue,a&&(u[f+3]=e.alpha)):(u.writeUInt16BE(e.red,f),u.writeUInt16BE(e.green,f+2),u.writeUInt16BE(e.blue,f+4),a&&u.writeUInt16BE(e.alpha,f+6));break;case n.COLORTYPE_ALPHA:case n.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;i.bitDepth===8?(u[f]=t,a&&(u[f+1]=e.alpha)):(u.writeUInt16BE(t,f),a&&u.writeUInt16BE(e.alpha,f+2));break}default:throw Error(`unrecognised color Type `+i.colorType)}d+=c,f+=l}return u}})),EEe=Oe(((e,t)=>{let n=RN();function r(e,t,n,r,i){for(let a=0;a<n;a++)r[i+a]=e[t+a]}function i(e,t,n){let r=0,i=t+n;for(let n=t;n<i;n++)r+=Math.abs(e[n]);return r}function a(e,t,n,r,i,a){for(let o=0;o<n;o++){let n=o>=a?e[t+o-a]:0,s=e[t+o]-n;r[i+o]=s}}function o(e,t,n,r){let i=0;for(let a=0;a<n;a++){let n=a>=r?e[t+a-r]:0,o=e[t+a]-n;i+=Math.abs(o)}return i}function s(e,t,n,r,i){for(let a=0;a<n;a++){let o=t>0?e[t+a-n]:0,s=e[t+a]-o;r[i+a]=s}}function c(e,t,n){let r=0,i=t+n;for(let a=t;a<i;a++){let i=t>0?e[a-n]:0,o=e[a]-i;r+=Math.abs(o)}return r}function l(e,t,n,r,i,a){for(let o=0;o<n;o++){let s=o>=a?e[t+o-a]:0,c=t>0?e[t+o-n]:0,l=e[t+o]-(s+c>>1);r[i+o]=l}}function u(e,t,n,r){let i=0;for(let a=0;a<n;a++){let o=a>=r?e[t+a-r]:0,s=t>0?e[t+a-n]:0,c=e[t+a]-(o+s>>1);i+=Math.abs(c)}return i}function d(e,t,r,i,a,o){for(let s=0;s<r;s++){let c=s>=o?e[t+s-o]:0,l=t>0?e[t+s-r]:0,u=t>0&&s>=o?e[t+s-(r+o)]:0,d=e[t+s]-n(c,l,u);i[a+s]=d}}function f(e,t,r,i){let a=0;for(let o=0;o<r;o++){let s=o>=i?e[t+o-i]:0,c=t>0?e[t+o-r]:0,l=t>0&&o>=i?e[t+o-(r+i)]:0,u=e[t+o]-n(s,c,l);a+=Math.abs(u)}return a}let p={0:r,1:a,2:s,3:l,4:d},m={0:i,1:o,2:c,3:u,4:f};t.exports=function(e,t,n,r,i){let a;if(!(`filterType`in r)||r.filterType===-1)a=[0,1,2,3,4];else if(typeof r.filterType==`number`)a=[r.filterType];else throw Error(`unrecognised filter types`);r.bitDepth===16&&(i*=2);let o=t*i,s=0,c=0,l=Buffer.alloc((o+1)*n),u=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=m[a[n]](e,c,o,i);r<t&&(u=a[n],t=r)}}l[s]=u,s++,p[u](e,c,o,l,s,i),s+=o,c+=o}return l}})),GN=Oe(((e,t)=>{let n=BN(),r=VN(),i=TEe(),a=EEe(),o=FN(),s=t.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=e.deflateLevel==null?9:e.deflateLevel,e.deflateStrategy=e.deflateStrategy==null?3:e.deflateStrategy,e.inputHasAlpha=e.inputHasAlpha==null||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||o.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType=typeof e.colorType==`number`?e.colorType:n.COLORTYPE_COLOR_ALPHA,e.inputColorType=typeof e.inputColorType==`number`?e.inputColorType:n.COLORTYPE_COLOR_ALPHA,[n.COLORTYPE_GRAYSCALE,n.COLORTYPE_COLOR,n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(e.colorType)===-1)throw Error(`option color type:`+e.colorType+` is not supported at present`);if([n.COLORTYPE_GRAYSCALE,n.COLORTYPE_COLOR,n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(e.inputColorType)===-1)throw Error(`option input color type:`+e.inputColorType+` is not supported at present`);if(e.bitDepth!==8&&e.bitDepth!==16)throw Error(`option bit depth:`+e.bitDepth+` is not supported at present`)};s.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},s.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},s.prototype.filterData=function(e,t,r){let o=i(e,t,r,this._options),s=n.COLORTYPE_TO_BPP_MAP[this._options.colorType];return a(o,t,r,this._options,s)},s.prototype._packChunk=function(e,t){let n=t?t.length:0,i=Buffer.alloc(n+12);return i.writeUInt32BE(n,0),i.writeUInt32BE(e,4),t&&t.copy(i,8),i.writeInt32BE(r.crc32(i.slice(4,i.length-4)),i.length-4),i},s.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*n.GAMMA_DIVISION),0),this._packChunk(n.TYPE_gAMA,t)},s.prototype.packIHDR=function(e,t){let r=Buffer.alloc(13);return r.writeUInt32BE(e,0),r.writeUInt32BE(t,4),r[8]=this._options.bitDepth,r[9]=this._options.colorType,r[10]=0,r[11]=0,r[12]=0,this._packChunk(n.TYPE_IHDR,r)},s.prototype.packIDAT=function(e){return this._packChunk(n.TYPE_IDAT,e)},s.prototype.packIEND=function(){return this._packChunk(n.TYPE_IEND,null)}})),DEe=Oe(((e,t)=>{let n=NN(),r=PN(),i=BN(),a=GN(),o=t.exports=function(e){r.call(this);let t=e||{};this._packer=new a(t),this._deflate=this._packer.createDeflate(),this.readable=!0};n.inherits(o,r),o.prototype.pack=function(e,t,n,r){this.emit(`data`,Buffer.from(i.PNG_SIGNATURE)),this.emit(`data`,this._packer.packIHDR(t,n)),r&&this.emit(`data`,this._packer.packGAMA(r));let a=this._packer.filterData(e,t,n);this._deflate.on(`error`,this.emit.bind(this,`error`)),this._deflate.on(`data`,function(e){this.emit(`data`,this._packer.packIDAT(e))}.bind(this)),this._deflate.on(`end`,function(){this.emit(`data`,this._packer.packIEND()),this.emit(`end`)}.bind(this)),this._deflate.end(a)}})),OEe=Oe(((e,t)=>{t.exports=iee.default})),kEe=Oe(((e,t)=>{t.exports=aee.default})),AEe=Oe(((e,t)=>{let n=OEe().ok,r=FN(),i=NN(),a=kEe().kMaxLength;function o(e){if(!(this instanceof o))return new o(e);e&&e.chunkSize<r.Z_MIN_CHUNK&&(e.chunkSize=r.Z_MIN_CHUNK),r.Inflate.call(this,e),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&e.maxLength!=null&&(this._maxLength=e.maxLength)}function s(e){return new o(e)}function c(e,t){t&&process.nextTick(t),e._handle&&=(e._handle.close(),null)}o.prototype._processChunk=function(e,t,i){if(typeof i==`function`)return r.Inflate._processChunk.call(this,e,t,i);let o=this,s=e&&e.length,l=this._chunkSize-this._offset,u=this._maxLength,d=0,f=[],p=0,m;this.on(`error`,function(e){m=e});function h(e,t){if(o._hadError)return;let r=l-t;if(n(r>=0,`have should not go down`),r>0){let e=o._buffer.slice(o._offset,o._offset+r);if(o._offset+=r,e.length>u&&(e=e.slice(0,u)),f.push(e),p+=e.length,u-=e.length,u===0)return!1}return(t===0||o._offset>=o._chunkSize)&&(l=o._chunkSize,o._offset=0,o._buffer=Buffer.allocUnsafe(o._chunkSize)),t===0&&(d+=s-e,s=e,!0)}n(this._handle,`zlib binding closed`);let g;do g=this._handle.writeSync(t,e,d,s,this._buffer,this._offset,l),g||=this._writeState;while(!this._hadError&&h(g[0],g[1]));if(this._hadError)throw m;if(p>=a)throw c(this),RangeError(`Cannot create final Buffer. It would be larger than 0x`+a.toString(16)+` bytes`);let _=Buffer.concat(f,p);return c(this),_},i.inherits(o,r.Inflate);function l(e,t){if(typeof t==`string`&&(t=Buffer.from(t)),!(t instanceof Buffer))throw TypeError(`Not a string or buffer`);let n=e._finishFlushFlag;return n??=r.Z_FINISH,e._processChunk(t,n)}function u(e,t){return l(new o(t),e)}t.exports=e=u,e.Inflate=o,e.createInflate=s,e.inflateSync=u})),KN=Oe(((e,t)=>{let n=t.exports=function(e){this._buffer=e,this._reads=[]};n.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},n.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}if(this._reads.length>0)throw Error(`There are some read requests waitng on finished stream`);if(this._buffer.length>0)throw Error(`unrecognised content at end of stream`)}})),jEe=Oe((e=>{let t=KN(),n=zN();e.process=function(e,r){let i=[],a=new t(e);return new n(r,{read:a.read.bind(a),write:function(e){i.push(e)},complete:function(){}}).start(),a.process(),Buffer.concat(i)}})),MEe=Oe(((e,t)=>{let n=!0,r=FN(),i=AEe();r.deflateSync||(n=!1);let a=KN(),o=jEe(),s=HN(),c=UN(),l=WN();t.exports=function(e,t){if(!n)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let u;function d(e){u=e}let f;function p(e){f=e}function m(e){f.transColor=e}function h(e){f.palette=e}function g(){f.alpha=!0}let _;function v(e){_=e}let y=[];function b(e){y.push(e)}let ee=new a(e);if(new s(t,{read:ee.read.bind(ee),error:d,metadata:p,gamma:v,palette:h,transColor:m,inflateData:b,simpleTransparency:g}).start(),ee.process(),u)throw u;let x=Buffer.concat(y);y.length=0;let te;if(f.interlace)te=r.inflateSync(x);else{let e=((f.width*f.bpp*f.depth+7>>3)+1)*f.height;te=i(x,{chunkSize:e,maxLength:e})}if(x=null,!te||!te.length)throw Error(`bad png - invalid inflate data response`);let ne=o.process(te,f);x=null;let re=c.dataToBitMap(ne,f);ne=null;let ie=l(re,f,t.skipRescale);return f.data=ie,f.gamma=_||0,f}})),NEe=Oe(((e,t)=>{let n=!0,r=FN();r.deflateSync||(n=!1);let i=BN(),a=GN();t.exports=function(e,t){if(!n)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let o=new a(t||{}),s=[];s.push(Buffer.from(i.PNG_SIGNATURE)),s.push(o.packIHDR(e.width,e.height)),e.gamma&&s.push(o.packGAMA(e.gamma));let c=o.filterData(e.data,e.width,e.height),l=r.deflateSync(c,o.getDeflateOptions());if(c=null,!l||!l.length)throw Error(`bad png - invalid compressed data response`);return s.push(o.packIDAT(l)),s.push(o.packIEND()),Buffer.concat(s)}})),PEe=Oe((e=>{let t=MEe(),n=NEe();e.read=function(e,n){return t(e,n||{})},e.write=function(e,t){return n(e,t)}})),qN=Oe((e=>{let t=NN(),n=PN(),r=wEe(),i=DEe(),a=PEe(),o=e.PNG=function(e){n.call(this),e||={},this.width=e.width|0,this.height=e.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new r(e),this._parser.on(`error`,this.emit.bind(this,`error`)),this._parser.on(`close`,this._handleClose.bind(this)),this._parser.on(`metadata`,this._metadata.bind(this)),this._parser.on(`gamma`,this._gamma.bind(this)),this._parser.on(`parsed`,function(e){this.data=e,this.emit(`parsed`,e)}.bind(this)),this._packer=new i(e),this._packer.on(`data`,this.emit.bind(this,`data`)),this._packer.on(`end`,this.emit.bind(this,`end`)),this._parser.on(`close`,this._handleClose.bind(this)),this._packer.on(`error`,this.emit.bind(this,`error`))};t.inherits(o,n),o.sync=a,o.prototype.pack=function(){return!this.data||!this.data.length?(this.emit(`error`,`No data provided`),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)},o.prototype.parse=function(e,t){if(t){let e,n;e=function(e){this.removeListener(`error`,n),this.data=e,t(null,this)}.bind(this),n=function(n){this.removeListener(`parsed`,e),t(n,null)}.bind(this),this.once(`parsed`,e),this.once(`error`,n)}return this.end(e),this},o.prototype.write=function(e){return this._parser.write(e),!0},o.prototype.end=function(e){this._parser.end(e)},o.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit(`metadata`,e)},o.prototype._gamma=function(e){this.gamma=e},o.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit(`close`)},o.bitblt=function(e,t,n,r,i,a,o,s){if(n|=0,r|=0,i|=0,a|=0,o|=0,s|=0,n>e.width||r>e.height||n+i>e.width||r+a>e.height)throw Error(`bitblt reading outside image`);if(o>t.width||s>t.height||o+i>t.width||s+a>t.height)throw Error(`bitblt writing outside image`);for(let c=0;c<a;c++)e.data.copy(t.data,(s+c)*t.width+o<<2,(r+c)*e.width+n<<2,(r+c)*e.width+n+i<<2)},o.prototype.bitblt=function(e,t,n,r,i,a,s){return o.bitblt(this,e,t,n,r,i,a,s),this},o.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n**=1/2.2/e.gamma,e.data[r+t]=Math.round(n*255)}}e.gamma=0}},o.prototype.adjustGamma=function(){o.adjustGamma(this)}}))();const JN=Uint8Array.of(137,80,78,71,13,10,26,10),FEe=(e,t)=>{switch(e){case 0:return t===16?`I;16`:`L`;case 2:return`RGB`;case 3:return`P`;case 4:return`LA`;case 6:return`RGBA`;default:return`color-type-${e}`}},YN=(e,t)=>(e[t]??0)*16777216+((e[t+1]??0)<<16)+((e[t+2]??0)<<8)+(e[t+3]??0)>>>0,IEe=(e,t)=>String.fromCharCode(...e.subarray(t,t+4)),LEe=e=>e>=65&&e<=90||e>=97&&e<=122,REe=[[0,0,8,8],[4,0,8,8],[0,4,4,8],[2,0,4,4],[0,2,2,4],[1,0,2,2],[0,1,1,2]],zEe=(e,t)=>{let n=(e,n)=>n>0?e*(1+n*t):0;return e.interlace===0?n(e.height,e.width):REe.reduce((t,[r,i,a,o])=>t+n(Math.ceil(Math.max(0,e.height-i)/o),Math.ceil(Math.max(0,e.width-r)/a)),0)},BEe=(e,t)=>{try{return nee(Buffer.concat(e),{maxOutputLength:t+1}).length===t}catch{return!1}},XN=e=>{if(e.length<JN.length||JN.some((t,n)=>e[n]!==t))return{ok:!1,reason:`invalid_png`};let t=JN.length,n,r=!1,i=!1,a=!1,o=!1,s=!1,c=[];for(;t<e.length;){if(s||e.length-t<12)return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let l=YN(e,t),u=t+4,d=IEe(e,u),f=e.subarray(u,u+4);if(l>2147483647||!f.every(LEe))return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let p=u+4+l;if(p+4>e.length)return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let m=YN(e,p);if(tee(e.subarray(u,p))>>>0!==m)return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let h=e.subarray(u+4,p);if(n===void 0){if(d!==`IHDR`||l!==13)return{ok:!1,reason:`invalid_png`};if(n={width:YN(h,0),height:YN(h,4),bitDepth:h[8]??0,colorType:h[9]??0,interlace:h[12]??0,mode:FEe(h[9]??0,h[8]??0)},n.width===0||n.height===0||h[10]!==0||h[11]!==0||n.interlace!==0&&n.interlace!==1)return{ok:!1,reason:`invalid_png`,header:n}}else if(d===`IHDR`)return{ok:!1,reason:`invalid_png`,header:n};else if(d===`IDAT`){if(a)return{ok:!1,reason:`invalid_png`,header:n};r=!0,c.push(h)}else if(d===`PLTE`){if(r||i||l===0||l%3!=0||l>768)return{ok:!1,reason:`invalid_png`,header:n};i=!0}else if(r&&(a=!0),d===`acTL`)o=!0;else if(d===`IEND`){if(l!==0||!r)return{ok:!1,reason:`invalid_png`,header:n};s=!0}else if((f[0]??0)<=90)return{ok:!1,reason:`invalid_png`,header:n};t=p+4}return!s||n===void 0?{ok:!1,reason:`invalid_png`,...n?{header:n}:{}}:o?{ok:!1,reason:`multiple_frames`,header:n}:n.bitDepth!==8||n.colorType!==2&&n.colorType!==6?{ok:!1,reason:`unsupported_sample_format`,header:n}:BEe(c,zEe(n,n.colorType===6?4:3))?{ok:!0,header:n}:{ok:!1,reason:`invalid_png`,header:n}},ZN=e=>{let t=qN.PNG.sync.read(Buffer.from(e.buffer,e.byteOffset,e.byteLength),{checkCRC:!0});return{width:t.width,height:t.height,data:new Uint8Array(t.data)}},VEe=e=>{let t=new qN.PNG({width:e.width,height:e.height});return t.data=Buffer.from(e.data),new Uint8Array(qN.PNG.sync.write(t,{colorType:6,inputHasAlpha:!0}))},QN=(e,t)=>{let n=t.right-t.left,r=t.bottom-t.top,i=new Uint8Array(n*r*4);for(let a=0;a<r;a++){let r=((t.top+a)*e.width+t.left)*4;i.set(e.data.subarray(r,r+n*4),a*n*4)}return{width:n,height:r,data:i}},HEe=(e,t)=>{let n=new Set;for(let r=0;r<e.data.length&&(n.add(((e.data[r]??0)<<24)+((e.data[r+1]??0)<<16)+((e.data[r+2]??0)<<8)+(e.data[r+3]??0)),!(n.size>=t));r+=4);return n.size},$N=e=>{if(!(e instanceof Error))return{name:void 0,code:void 0,errno:void 0};let t=`code`in e&&typeof e.code==`string`?e.code:void 0,n=`errno`in e&&typeof e.errno==`number`?e.errno:void 0;return{name:e.name,code:t,errno:n}};var eP=class extends Error{reason;subject;errorType;errno;constructor(e,t,n){super(e),this.reason=e,this.subject=t;let r=$N(n);this.errorType=n===void 0?void 0:r.code??r.name,this.errno=r.errno}};const tP=e=>y(`sha256`).update(e).digest(`hex`),nP=async(e,t,n)=>{n.path=e;let r;try{if(!(await xe(e)).isFile())throw new eP(`missing_or_non_file`,t);r=await ye(e)}catch(e){if(e instanceof eP)throw e;let{code:n}=$N(e);throw n===`ENOENT`||n===`ENOTDIR`?new eP(`missing_or_non_file`,t,e):new eP(`unreadable_file`,t,e)}n.file_bytes=r.length,n.file_sha256=tP(r);let i=XN(r);if(i.header!==void 0||i.ok){let e=(i.ok,i.header);e!==void 0&&(n.width=e.width,n.height=e.height,n.mode=e.mode,n.bit_depth=e.bitDepth)}if(!i.ok)throw new eP(i.reason,t);let a;try{a=ZN(r)}catch{throw new eP(`invalid_png`,t)}return n.rgba_sha256=tP(a.data),a},UEe=(e,t,n,r,i)=>{let[a=0,o=0,s=0,c=0]=t;if(!(a>=0&&a<s&&o>=0&&o<c))throw new eP(`invalid_content_box`);if(s>r||c>i)throw new eP(`content_box_out_of_bounds`);if(n.some(e=>e<0))throw new eP(`invalid_min_margins`);let[l=0,u=0,d=0,f=0]=e,p={top:n[0]??0,right:n[1]??0,bottom:n[2]??0,left:n[3]??0},m={top:o-u,right:d-s,bottom:f-c,left:a-l};return{source:`caller_supplied`,box:[...t],minimum_margins:p,observed_margins:m,content_contained:Object.values(m).every(e=>e>=0),margins_satisfied:m.top>=p.top&&m.right>=p.right&&m.bottom>=p.bottom&&m.left>=p.left}},WEe={"--raw":{arity:1,required:!0},"--crop":{arity:1,required:!0},"--box":{arity:4,required:!0},"--content-box":{arity:4},"--min-margins":{arity:4}},rP=e=>{if(e===void 0)return;let t=e.map(SEe);if(t.some(e=>e===void 0))throw new eP(`invalid_arguments`);return t.filter(e=>e!==void 0)},iP=e=>TO(async()=>{let t={status:`uncheckable`,reason:null,box:null,comparison_mode:`RGBA8`,decoder:`pngjs@7.0.0`,raw:{},crop:{},expected:{},dimensions_equal:null,pixels_equal:null},n={},r={};t.raw=n,t.crop=r;try{let i=jN(e,WEe);if(!i.ok)throw new eP(`invalid_arguments`);let a=rP(i.values[`--box`])??[],o=rP(i.values[`--content-box`]),s=rP(i.values[`--min-margins`]);if(t.box=[...a],o===void 0!=(s===void 0))throw new eP(`incomplete_content_bounds_arguments`);let[c=0,l=0,u=0,d=0]=a;if(!(c>=0&&c<u&&l>=0&&l<d))throw new eP(`invalid_box`);let f=await nP(i.values[`--raw`]?.[0]??``,`raw`,n);if(u>f.width||d>f.height)throw new eP(`box_out_of_bounds`);let p;o!==void 0&&s!==void 0&&(p=UEe(a,o,s,f.width,f.height),t.content_bounds=p);let m=await nP(i.values[`--crop`]?.[0]??``,`crop`,r),h=QN(f,{left:c,top:l,right:u,bottom:d});t.expected={width:h.width,height:h.height,rgba_sha256:tP(h.data)};let g=m.width===h.width&&m.height===h.height;if(t.dimensions_equal=g,!g)return{report:{...t,status:`mismatch`,reason:`dimensions_differ`},exitCode:1};let _=Buffer.compare(Buffer.from(m.data),Buffer.from(h.data))===0;return t.pixels_equal=_,_?p!==void 0&&p.content_contained!==!0?{report:{...t,status:`mismatch`,reason:`content_cut`},exitCode:1}:p!==void 0&&p.margins_satisfied!==!0?{report:{...t,status:`mismatch`,reason:`content_margins_insufficient`},exitCode:1}:{report:{...t,status:`exact`,reason:`pixels_equal`},exitCode:0}:{report:{...t,status:`mismatch`,reason:`pixels_differ`},exitCode:1}}catch(e){if(!(e instanceof eP))throw e;let n={...t,reason:e.reason};return e.subject!==void 0&&(n.subject=e.subject),e.errorType!==void 0&&(n.error_type=e.errorType),e.errno!==void 0&&(n.errno=e.errno),{report:n,exitCode:2}}}),GEe=e=>JSON.stringify(aP(e)),aP=e=>{if(Array.isArray(e))return e.map(aP);if(typeof e==`object`&&e){let t=Object.entries(e).toSorted(([e],[t])=>e<t?-1:1);return Object.fromEntries(t.map(([e,t])=>[e,aP(t)]))}return e},oP=e=>y(`sha256`).update(e).digest(`hex`),sP=e=>MO(function*(){let t=yield*TO(async()=>{try{return(await _e(l(e))).isDirectory()}catch{return!1}});if(!u(e)||!e.toLowerCase().endsWith(`.png`)||!t||(yield*TM(e))||(yield*TM(`${e}.json`)))return yield*z(`capture requires a fresh absolute .png path with an existing parent`)}),KEe=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.viewable===t.viewable,qEe=e=>MO(function*(){if(yield*sP(e.output),e.window!==void 0&&(yield*sP(e.window.output),e.window.output===e.output))return yield*z(`window output must differ from the raw output`);let t=yield*lM,{session:n,observation:r,deadline:i}=yield*yN(e.stateDir,e.timeout),a=(t,r)=>MO(function*(){let a=yield*pEe(e.stateDir,n,t,r,i);if(a.length>0)return yield*z(`window is covered by ${a.join(`, `)}`)}),o=e.window===void 0?void 0:yield*SN(e.stateDir,n,e.window.id,i);e.window!==void 0&&o!==void 0&&(yield*a(e.window.id,o));let s=d(n.guest_dir,`captures`,`${b()}.png`),c=yield*MM,l=yield*NM,u=yield*gCe(MO(function*(){return yield*aN(e.stateDir,n,`scrot`,[s],i,fN(n),e.timeout).pipe(HO(`Unavailable`,e=>NO(new _M({reason:e.reason.replace(/^scrot read/u,`scrot`),...e.nativeExit===void 0?{}:{nativeExit:e.nativeExit}})))),yield*t.readFile(s,yield*FM(i,e.timeout)).pipe(WO(e=>new _M({reason:`capture could not be read back: ${e.message}`})))}),zTe(s,n.probe_timeout_s*1e3).pipe(GO)),f=XN(u);if(!f.ok&&f.reason===`invalid_png`)return yield*z(`scrot did not produce a PNG screen capture`);let p=(f.ok,f.header);if(p===void 0||p.width!==r.dimensions[0]||p.height!==r.dimensions[1])return yield*z(`raw capture dimensions differ from the inspected display`);let m=yield*yN(e.stateDir,Math.max(.001,(i.endMs-(yield*NM))/1e3));if(m.session.run_id!==n.run_id||JSON.stringify(m.observation)!==JSON.stringify(r))return yield*z(`session or window manager changed during capture`);let h;if(e.window!==void 0&&o!==void 0){if(h=yield*SN(e.stateDir,n,e.window.id,i),!KEe(o,h))return yield*z(`window moved or changed during capture`);yield*a(e.window.id,h)}let g={run_id:n.run_id,output:e.output,bytes:u.length,sha256:oP(u),dimensions:[p.width,p.height],capture_started_at:c,capture_completed_at:yield*MM,capture_ms:(yield*NM)-l,window_manager:m.observation.window_manager??null,transformations:[]},_=h===void 0?void 0:{left:h.x,top:h.y,right:h.x+h.width,bottom:h.y+h.height};if(h!==void 0&&_!==void 0){if(!h.viewable)return yield*z(`window is not viewable`);if(_.left<0||_.top<0||_.right>p.width||_.bottom>p.height||_.left>=_.right||_.top>=_.bottom)return yield*z(`window is not entirely on the screen`);if(!f.ok)return yield*z(`raw capture is not an 8-bit RGB or RGBA PNG: ${f.reason}`)}if(yield*OM(e.output,u),yield*kM(`${e.output}.json`,g),e.window===void 0||_===void 0||!f.ok)return g;let v=QN(ZN(u),_),y=VEe(v);yield*OM(e.window.output,y);let ee=yield*iP([`--raw`,e.output,`--crop`,e.window.output,`--box`,String(_.left),String(_.top),String(_.right),String(_.bottom)]),x={run_id:n.run_id,window:e.window.id,raw:e.output,output:e.window.output,box:[_.left,_.top,_.right,_.bottom],bytes:y.length,sha256:oP(y),distinct_colors:HEe(v,4096),exact_crop:ee.report};return yield*kM(`${e.window.output}.json`,x),ee.exitCode===0?{...g,window:x}:yield*z(`window crop did not verify as an exact crop of the raw capture`)}),JEe=/\{[^{}]+\}/g,YEe=()=>typeof process==`object`&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function XEe(){return Math.random().toString(36).slice(2,11)}function cP(e){let{baseUrl:t=``,Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:i,bodySerializer:a,pathSerializer:o,headers:s,requestInitExt:c=void 0,...l}={...e};c=YEe()?c:void 0,t=mP(t);let u=[];async function d(e,d){let{baseUrl:f,fetch:p=r,Request:m=n,headers:h,params:g={},parseAs:_=`json`,querySerializer:v,bodySerializer:y=a??QEe,pathSerializer:b,body:ee,middleware:x=[],...te}=d||{},ne=t;f&&(ne=mP(f)??t);let re=typeof i==`function`?i:fP(i);v&&(re=typeof v==`function`?v:fP({...typeof i==`object`?i:{},...v}));let ie=b||o||ZEe,ae=ee===void 0?void 0:y(ee,pP(s,h,g.header)),S=pP(ae===void 0||ae instanceof FormData?{}:{"Content-Type":`application/json`},s,h,g.header),oe=[...u,...x],C={redirect:`follow`,...l,...te,body:ae,headers:S},se,ce,le=new m($Ee(e,{baseUrl:ne,params:g,querySerializer:re,pathSerializer:ie}),C),ue;for(let e in te)e in le||(le[e]=te[e]);if(oe.length){se=XEe(),ce=Object.freeze({baseUrl:ne,fetch:p,parseAs:_,querySerializer:re,bodySerializer:y,pathSerializer:ie});for(let t of oe)if(t&&typeof t==`object`&&typeof t.onRequest==`function`){let n=await t.onRequest({request:le,schemaPath:e,params:g,options:ce,id:se});if(n){if(n instanceof m)le=n;else if(n instanceof Response){ue=n;break}else throw Error(`onRequest: must return new Request() or Response() when modifying the request`)}}}if(!ue){try{ue=await p(le,c)}catch(t){let n=t;if(oe.length)for(let t=oe.length-1;t>=0;t--){let r=oe[t];if(r&&typeof r==`object`&&typeof r.onError==`function`){let t=await r.onError({request:le,error:n,schemaPath:e,params:g,options:ce,id:se});if(t){if(t instanceof Response){n=void 0,ue=t;break}if(t instanceof Error){n=t;continue}throw Error(`onError: must return new Response() or instance of Error`)}}}if(n)throw n}if(oe.length)for(let t=oe.length-1;t>=0;t--){let n=oe[t];if(n&&typeof n==`object`&&typeof n.onResponse==`function`){let t=await n.onResponse({request:le,response:ue,schemaPath:e,params:g,options:ce,id:se});if(t){if(!(t instanceof Response))throw Error(`onResponse: must return new Response() when modifying the response`);ue=t}}}}let w=ue.headers.get(`Content-Length`);if(ue.status===204||le.method===`HEAD`||w===`0`&&!ue.headers.get(`Transfer-Encoding`)?.includes(`chunked`))return ue.ok?{data:void 0,response:ue}:{error:void 0,response:ue};if(ue.ok)return{data:await(async()=>{if(_===`stream`)return ue.body;if(_===`json`&&!w){let e=await ue.text();return e?JSON.parse(e):void 0}return await ue[_]()})(),response:ue};let de=await ue.text();try{de=JSON.parse(de)}catch{}return{error:de,response:ue}}return{request(e,t,n){return d(t,{...n,method:e.toUpperCase()})},GET(e,t){return d(e,{...t,method:`GET`})},PUT(e,t){return d(e,{...t,method:`PUT`})},POST(e,t){return d(e,{...t,method:`POST`})},DELETE(e,t){return d(e,{...t,method:`DELETE`})},OPTIONS(e,t){return d(e,{...t,method:`OPTIONS`})},HEAD(e,t){return d(e,{...t,method:`HEAD`})},PATCH(e,t){return d(e,{...t,method:`PATCH`})},TRACE(e,t){return d(e,{...t,method:`TRACE`})},use(...e){for(let t of e)if(t){if(typeof t!=`object`||!(`onRequest`in t||`onResponse`in t||`onError`in t))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");u.push(t)}},eject(...e){for(let t of e){let e=u.indexOf(t);e!==-1&&u.splice(e,1)}}}}function lP(e,t,n){if(t==null)return``;if(typeof t==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?.allowReserved===!0?t:encodeURIComponent(t)}`}function uP(e,t,n){if(!t||typeof t!=`object`)return``;let r=[],i={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`;if(n.style!==`deepObject`&&n.explode===!1){for(let e in t)r.push(e,n.allowReserved===!0?t[e]:encodeURIComponent(t[e]));let i=r.join(`,`);switch(n.style){case`form`:return`${e}=${i}`;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return i}}for(let i in t){let a=n.style===`deepObject`?`${e}[${i}]`:i;r.push(lP(a,t[i],n))}let a=r.join(i);return n.style===`label`||n.style===`matrix`?`${i}${a}`:a}function dP(e,t,n){if(!Array.isArray(t))return``;if(n.explode===!1){let r={form:`,`,spaceDelimited:`%20`,pipeDelimited:`|`}[n.style]||`,`,i=(n.allowReserved===!0?t:t.map(e=>encodeURIComponent(e))).join(r);switch(n.style){case`simple`:return i;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return`${e}=${i}`}}let r={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`,i=[];for(let r of t)n.style===`simple`||n.style===`label`?i.push(n.allowReserved===!0?r:encodeURIComponent(r)):i.push(lP(e,r,n));return n.style===`label`||n.style===`matrix`?`${r}${i.join(r)}`:i.join(r)}function fP(e){return function(t){let n=[];if(t&&typeof t==`object`)for(let r in t){let i=t[r];if(i!=null){if(Array.isArray(i)){if(i.length===0)continue;n.push(dP(r,i,{style:`form`,explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}));continue}if(typeof i==`object`){n.push(uP(r,i,{style:`deepObject`,explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}));continue}n.push(lP(r,i,e))}}return n.join(`&`)}}function ZEe(e,t){let n=e;for(let r of e.match(JEe)??[]){let e=r.substring(1,r.length-1),i=!1,a=`simple`;if(e.endsWith(`*`)&&(i=!0,e=e.substring(0,e.length-1)),e.startsWith(`.`)?(a=`label`,e=e.substring(1)):e.startsWith(`;`)&&(a=`matrix`,e=e.substring(1)),!t||t[e]===void 0||t[e]===null)continue;let o=t[e];if(Array.isArray(o)){n=n.replace(r,dP(e,o,{style:a,explode:i}));continue}if(typeof o==`object`){n=n.replace(r,uP(e,o,{style:a,explode:i}));continue}if(a===`matrix`){n=n.replace(r,`;${lP(e,o)}`);continue}n=n.replace(r,a===`label`?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return n}function QEe(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get(`Content-Type`)??t.get(`content-type`):t[`Content-Type`]??t[`content-type`])===`application/x-www-form-urlencoded`?new URLSearchParams(e).toString():JSON.stringify(e)}function $Ee(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=t.pathSerializer(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith(`?`)&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function pP(...e){let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,r)}return t}function mP(e){return e.endsWith(`/`)?e.substring(0,e.length-1):e}var eDe=Oe(((e,t)=>{(function(){var n={function:!0,object:!0},r=n[typeof window]&&window||this,i=n[typeof e]&&e,a=n[typeof t]&&t&&!t.nodeType&&t,o=i&&a&&typeof global==`object`&&global;o&&(o.global===o||o.window===o||o.self===o)&&(r=o);var s=2**53-1,c=/\bOpera/,l=Object.prototype,u=l.hasOwnProperty,d=l.toString;function f(e){return e=String(e),e.charAt(0).toUpperCase()+e.slice(1)}function p(e,t,n){var r={"10.0":`10`,"6.4":`10 Technical Preview`,"6.3":`8.1`,"6.2":`8`,"6.1":`Server 2008 R2 / 7`,"6.0":`Server 2008 / Vista`,"5.2":`Server 2003 / XP 64-bit`,"5.1":`XP`,"5.01":`2000 SP1`,"5.0":`2000`,"4.0":`NT`,"4.90":`ME`};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e=`Windows `+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,`i`),n)),e=h(e.replace(/ ce$/i,` CE`).replace(/\bhpw/i,`web`).replace(/\bMacintosh\b/,`Mac OS`).replace(/_PowerPC\b/i,` OS`).replace(/\b(OS X) [^ \d]+/i,`$1`).replace(/\bMac (OS X)\b/,`$1`).replace(/\/(\d)/,` $1`).replace(/_/g,`.`).replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,``).replace(/\bx86\.64\b/gi,`x86_64`).replace(/\b(Windows Phone) OS\b/,`$1`).replace(/\b(Chrome OS \w+) [\d.]+\b/,`$1`).split(` on `)[0]),e}function m(e,t){var n=-1,r=e?e.length:0;if(typeof r==`number`&&r>-1&&r<=s)for(;++n<r;)t(e[n],n,e);else g(e,t)}function h(e){return e=ee(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:f(e)}function g(e,t){for(var n in e)u.call(e,n)&&t(e[n],n,e)}function _(e){return e==null?f(e):d.call(e).slice(8,-1)}function v(e,t){var n=e==null?`number`:typeof e[t];return!/^(?:boolean|number|string|undefined)$/.test(n)&&(n!=`object`||!!e[t])}function y(e){return String(e).replace(/([ -])(?!$)/g,`$1?`)}function b(e,t){var n=null;return m(e,function(r,i){n=t(n,r,i,e)}),n}function ee(e){return String(e).replace(/^ +| +$/g,``)}function x(e){var t=r,n=e&&typeof e==`object`&&_(e)!=`String`;n&&(t=e,e=null);var i=t.navigator||{},a=i.userAgent||``;e||=a;var o=n?!!i.likeChrome:/\bChrome\b/.test(e)&&!/internal|\n/i.test(d.toString()),s=`Object`,l=n?s:`ScriptBridgingProxyObject`,u=n?s:`Environment`,f=n&&t.java?`JavaPackage`:_(t.java),m=n?s:`RuntimeObject`,te=/\bJava/.test(f)&&t.java,ne=te&&_(t.environment)==u,re=te?`a`:`α`,ie=te?`b`:`β`,ae=t.document||{},S=t.operamini||t.opera,oe=c.test(oe=n&&S?S[`[[Class]]`]:_(S))?oe:S=null,C,se=e,ce=[],le=null,ue=e==a,w=ue&&S&&typeof S.version==`function`&&S.version(),de,fe=he([{label:`EdgeHTML`,pattern:`Edge`},`Trident`,{label:`WebKit`,pattern:`AppleWebKit`},`iCab`,`Presto`,`NetFront`,`Tasman`,`KHTML`,`Gecko`]),T=_e([`Adobe AIR`,`Arora`,`Avant Browser`,`Breach`,`Camino`,`Electron`,`Epiphany`,`Fennec`,`Flock`,`Galeon`,`GreenBrowser`,`iCab`,`Iceweasel`,`K-Meleon`,`Konqueror`,`Lunascape`,`Maxthon`,{label:`Microsoft Edge`,pattern:`(?:Edge|Edg|EdgA|EdgiOS)`},`Midori`,`Nook Browser`,`PaleMoon`,`PhantomJS`,`Raven`,`Rekonq`,`RockMelt`,{label:`Samsung Internet`,pattern:`SamsungBrowser`},`SeaMonkey`,{label:`Silk`,pattern:`(?:Cloud9|Silk-Accelerated)`},`Sleipnir`,`SlimBrowser`,{label:`SRWare Iron`,pattern:`Iron`},`Sunrise`,`Swiftfox`,`Vivaldi`,`Waterfox`,`WebPositive`,{label:`Yandex Browser`,pattern:`YaBrowser`},{label:`UC Browser`,pattern:`UCBrowser`},`Opera Mini`,{label:`Opera Mini`,pattern:`OPiOS`},`Opera`,{label:`Opera`,pattern:`OPR`},`Chromium`,`Chrome`,{label:`Chrome`,pattern:`(?:HeadlessChrome)`},{label:`Chrome Mobile`,pattern:`(?:CriOS|CrMo)`},{label:`Firefox`,pattern:`(?:Firefox|Minefield)`},{label:`Firefox for iOS`,pattern:`FxiOS`},{label:`IE`,pattern:`IEMobile`},{label:`IE`,pattern:`MSIE`},`Safari`]),pe=ye([{label:`BlackBerry`,pattern:`BB10`},`BlackBerry`,{label:`Galaxy S`,pattern:`GT-I9000`},{label:`Galaxy S2`,pattern:`GT-I9100`},{label:`Galaxy S3`,pattern:`GT-I9300`},{label:`Galaxy S4`,pattern:`GT-I9500`},{label:`Galaxy S5`,pattern:`SM-G900`},{label:`Galaxy S6`,pattern:`SM-G920`},{label:`Galaxy S6 Edge`,pattern:`SM-G925`},{label:`Galaxy S7`,pattern:`SM-G930`},{label:`Galaxy S7 Edge`,pattern:`SM-G935`},`Google TV`,`Lumia`,`iPad`,`iPod`,`iPhone`,`Kindle`,{label:`Kindle Fire`,pattern:`(?:Cloud9|Silk-Accelerated)`},`Nexus`,`Nook`,`PlayBook`,`PlayStation Vita`,`PlayStation`,`TouchPad`,`Transformer`,{label:`Wii U`,pattern:`WiiU`},`Wii`,`Xbox One`,{label:`Xbox 360`,pattern:`Xbox`},`Xoom`]),me=ge({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),E=ve([`Windows Phone`,`KaiOS`,`Android`,`CentOS`,{label:`Chrome OS`,pattern:`CrOS`},`Debian`,{label:`DragonFly BSD`,pattern:`DragonFly`},`Fedora`,`FreeBSD`,`Gentoo`,`Haiku`,`Kubuntu`,`Linux Mint`,`OpenBSD`,`Red Hat`,`SuSE`,`Ubuntu`,`Xubuntu`,`Cygwin`,`Symbian OS`,`hpwOS`,`webOS `,`webOS`,`Tablet OS`,`Tizen`,`Linux`,`Mac OS X`,`Macintosh`,`Mac`,`Windows 98;`,`Windows `]);function he(t){return b(t,function(t,n){return t||RegExp(`\\b`+(n.pattern||y(n))+`\\b`,`i`).exec(e)&&(n.label||n)})}function ge(t){return b(t,function(t,n,r){return t||(n[pe]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(pe)]||RegExp(`\\b`+y(r)+`(?:\\b|\\w*\\d)`,`i`).exec(e))&&r})}function _e(t){return b(t,function(t,n){return t||RegExp(`\\b`+(n.pattern||y(n))+`\\b`,`i`).exec(e)&&(n.label||n)})}function ve(t){return b(t,function(t,n){var r=n.pattern||y(n);return!t&&(t=RegExp(`\\b`+r+`(?:/[\\d.]+|[ \\w.]*)`,`i`).exec(e))&&(t=p(t,r,n.label||n)),t})}function ye(t){return b(t,function(t,n){var r=n.pattern||y(n);return!t&&(t=RegExp(`\\b`+r+` *\\d+[.\\w_]*`,`i`).exec(e)||RegExp(`\\b`+r+` *\\w+-[\\w]*`,`i`).exec(e)||RegExp(`\\b`+r+`(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)`,`i`).exec(e))&&((t=String(n.label&&!RegExp(r,`i`).test(n.label)?n.label:t).split(`/`))[1]&&!/[\d.]+/.test(t[0])&&(t[0]+=` `+t[1]),n=n.label||n,t=h(t[0].replace(RegExp(r,`i`),n).replace(RegExp(`; *(?:`+n+`[_-])?`,`i`),` `).replace(RegExp(`(`+n+`)[-_.]?(\\w)`,`i`),`$1 $2`))),t})}function be(t){return b(t,function(t,n){return t||(RegExp(n+`(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)`,`i`).exec(e)||0)[1]||null})}function xe(){return this.description||``}if(fe&&=[fe],/\bAndroid\b/.test(E)&&!pe&&(C=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(e))&&(pe=ee(C[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,``)||null),me&&!pe?pe=ye([me]):me&&pe&&(pe=pe.replace(RegExp(`^(`+y(me)+`)[-_.\\s]`,`i`),me+` `).replace(RegExp(`^(`+y(me)+`)[-_.]?(\\w)`,`i`),me+` $2`)),(C=/\bGoogle TV\b/.exec(pe))&&(pe=C[0]),/\bSimulator\b/i.test(e)&&(pe=(pe?pe+` `:``)+`Simulator`),T==`Opera Mini`&&/\bOPiOS\b/.test(e)&&ce.push(`running in Turbo/Uncompressed mode`),T==`IE`&&/\blike iPhone OS\b/.test(e)?(C=x(e.replace(/like iPhone OS/,``)),me=C.manufacturer,pe=C.product):/^iP/.test(pe)?(T||=`Safari`,E=`iOS`+((C=/ OS ([\d_]+)/i.exec(e))?` `+C[1].replace(/_/g,`.`):``)):T==`Konqueror`&&/^Linux\b/i.test(E)?E=`Kubuntu`:me&&me!=`Google`&&(/Chrome/.test(T)&&!/\bMobile Safari\b/i.test(e)||/\bVita\b/.test(pe))||/\bAndroid\b/.test(E)&&/^Chrome/.test(T)&&/\bVersion\//i.test(e)?(T=`Android Browser`,E=/\bAndroid\b/.test(E)?E:`Android`):T==`Silk`?(/\bMobi/i.test(e)||(E=`Android`,ce.unshift(`desktop mode`)),/Accelerated *= *true/i.test(e)&&ce.unshift(`accelerated`)):T==`UC Browser`&&/\bUCWEB\b/.test(e)?ce.push(`speed mode`):T==`PaleMoon`&&(C=/\bFirefox\/([\d.]+)\b/.exec(e))?ce.push(`identifying as Firefox `+C[1]):T==`Firefox`&&(C=/\b(Mobile|Tablet|TV)\b/i.exec(e))?(E||=`Firefox OS`,pe||=C[1]):!T||(C=!/\bMinefield\b/i.test(e)&&/\b(?:Firefox|Safari)\b/.exec(T))?(T&&!pe&&/[\/,]|^[^(]+?\)/.test(e.slice(e.indexOf(C+`/`)+8))&&(T=null),(C=pe||me||E)&&(pe||me||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(E))&&(T=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(E)?E:C)+` Browser`)):T==`Electron`&&(C=(/\bChrome\/([\d.]+)\b/.exec(e)||0)[1])&&ce.push(`Chromium `+C),w||=be([`(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)`,`Version`,y(T),`(?:Firefox|Minefield|NetFront)`]),(C=fe==`iCab`&&parseFloat(w)>3&&`WebKit`||/\bOpera\b/.test(T)&&(/\bOPR\b/.test(e)?`Blink`:`Presto`)||/\b(?:Midori|Nook|Safari)\b/i.test(e)&&!/^(?:Trident|EdgeHTML)$/.test(fe)&&`WebKit`||!fe&&/\bMSIE\b/i.test(e)&&(E==`Mac OS`?`Tasman`:`Trident`)||fe==`WebKit`&&/\bPlayStation\b(?! Vita\b)/i.test(T)&&`NetFront`)&&(fe=[C]),T==`IE`&&(C=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(e)||0)[1])?(T+=` Mobile`,E=`Windows Phone `+(/\+$/.test(C)?C:C+`.x`),ce.unshift(`desktop mode`)):/\bWPDesktop\b/i.test(e)?(T=`IE Mobile`,E=`Windows Phone 8.x`,ce.unshift(`desktop mode`),w||=(/\brv:([\d.]+)/.exec(e)||0)[1]):T!=`IE`&&fe==`Trident`&&(C=/\brv:([\d.]+)/.exec(e))&&(T&&ce.push(`identifying as `+T+(w?` `+w:``)),T=`IE`,w=C[1]),ue){if(v(t,`global`)){if(te&&(C=te.lang.System,se=C.getProperty(`os.arch`),E||=C.getProperty(`os.name`)+` `+C.getProperty(`os.version`)),ne){try{w=(()=>{throw Error(`impulse-compute loads no package at run time`)})().version.join(`.`),T=`RingoJS`}catch{(C=t.system)&&C.global.system==t.system&&(T=`Narwhal`,E||=C[0].os||null)}T||=`Rhino`}else typeof t.process==`object`&&!t.process.browser&&(C=t.process)&&(typeof C.versions==`object`&&(typeof C.versions.electron==`string`?(ce.push(`Node `+C.versions.node),T=`Electron`,w=C.versions.electron):typeof C.versions.nw==`string`&&(ce.push(`Chromium `+w,`Node `+C.versions.node),T=`NW.js`,w=C.versions.nw)),T||(T=`Node.js`,se=C.arch,E=C.platform,w=/[\d.]+/.exec(C.version),w=w?w[0]:null))}else _(C=t.runtime)==l?(T=`Adobe AIR`,E=C.flash.system.Capabilities.os):_(C=t.phantom)==m?(T=`PhantomJS`,w=(C=C.version||null)&&C.major+`.`+C.minor+`.`+C.patch):typeof ae.documentMode==`number`&&(C=/\bTrident\/(\d+)/i.exec(e))?(w=[w,ae.documentMode],(C=+C[1]+4)!=w[1]&&(ce.push(`IE `+w[1]+` mode`),fe&&(fe[1]=``),w[1]=C),w=T==`IE`?String(w[1].toFixed(1)):w[0]):typeof ae.documentMode==`number`&&/^(?:Chrome|Firefox)\b/.test(T)&&(ce.push(`masking as `+T+` `+w),T=`IE`,w=`11.0`,fe=[`Trident`],E=`Windows`);E&&=h(E)}if(w&&(C=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(w)||/(?:alpha|beta)(?: ?\d)?/i.exec(e+`;`+(ue&&i.appMinorVersion))||/\bMinefield\b/i.test(e)&&`a`)&&(le=/b/i.test(C)?`beta`:`alpha`,w=w.replace(RegExp(C+`\\+?$`),``)+(le==`beta`?ie:re)+(/\d+\+?/.exec(C)||``)),T==`Fennec`||T==`Firefox`&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(E))T=`Firefox Mobile`;else if(T==`Maxthon`&&w)w=w.replace(/\.[\d.]+/,`.x`);else if(/\bXbox\b/i.test(pe))pe==`Xbox 360`&&(E=null),pe==`Xbox 360`&&/\bIEMobile\b/.test(e)&&ce.unshift(`mobile mode`);else if((/^(?:Chrome|IE|Opera)$/.test(T)||T&&!pe&&!/Browser|Mobi/.test(T))&&(E==`Windows CE`||/Mobi/i.test(e)))T+=` Mobile`;else if(T==`IE`&&ue)try{t.external===null&&ce.unshift(`platform preview`)}catch{ce.unshift(`embedded`)}else(/\bBlackBerry\b/.test(pe)||/\bBB10\b/.test(e))&&(C=(RegExp(pe.replace(/ +/g,` *`)+`/([.\\d]+)`,`i`).exec(e)||0)[1]||w)?(C=[C,/BB10/.test(e)],E=(C[1]?(pe=null,me=`BlackBerry`):`Device Software`)+` `+C[0],w=null):this!=g&&pe!=`Wii`&&(ue&&S||/Opera/.test(T)&&/\b(?:MSIE|Firefox)\b/i.test(e)||T==`Firefox`&&/\bOS X (?:\d+\.){2,}/.test(E)||T==`IE`&&(E&&!/^Win/.test(E)&&w>5.5||/\bWindows XP\b/.test(E)&&w>8||w==8&&!/\bTrident\b/.test(e)))&&!c.test(C=x.call(g,e.replace(c,``)+`;`))&&C.name&&(C=`ing as `+C.name+((C=C.version)?` `+C:``),c.test(T)?(/\bIE\b/.test(C)&&E==`Mac OS`&&(E=null),C=`identify`+C):(C=`mask`+C,T=oe?h(oe.replace(/([a-z])([A-Z])/g,`$1 $2`)):`Opera`,/\bIE\b/.test(C)&&(E=null),ue||(w=null)),fe=[`Presto`],ce.push(C));(C=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(e)||0)[1])&&(C=[parseFloat(C.replace(/\.(\d)$/,`.0$1`)),C],T==`Safari`&&C[1].slice(-1)==`+`?(T=`WebKit Nightly`,le=`alpha`,w=C[1].slice(0,-1)):(w==C[1]||w==(C[2]=(/\bSafari\/([\d.]+\+?)/i.exec(e)||0)[1]))&&(w=null),C[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(e)||0)[1],C[0]==537.36&&C[2]==537.36&&parseFloat(C[1])>=28&&fe==`WebKit`&&(fe=[`Blink`]),!ue||!o&&!C[1]?(fe&&(fe[1]=`like Safari`),C=(C=C[0],C<400?1:C<500?2:C<526?3:C<533?4:C<534?`4+`:C<535?5:C<537?6:C<538?7:C<601?8:C<602?9:C<604?10:C<606?11:C<608?12:`12`)):(fe&&(fe[1]=`like Chrome`),C=C[1]||(C=C[0],C<530?1:C<532?2:C<532.05?3:C<533?4:C<534.03?5:C<534.07?6:C<534.1?7:C<534.13?8:C<534.16?9:C<534.24?10:C<534.3?11:C<535.01?12:C<535.02?`13+`:C<535.07?15:C<535.11?16:C<535.19?17:C<536.05?18:C<536.1?19:C<537.01?20:C<537.11?`21+`:C<537.13?23:C<537.18?24:C<537.24?25:C<537.36?26:fe==`Blink`?`28`:`27`)),fe&&(fe[1]+=` `+(C+=typeof C==`number`?`.x`:/[.+]/.test(C)?``:`+`)),T==`Safari`&&(!w||parseInt(w)>45)?w=C:T==`Chrome`&&/\bHeadlessChrome/i.test(e)&&ce.unshift(`headless`)),T==`Opera`&&(C=/\bzbov|zvav$/.exec(E))?(T+=` `,ce.unshift(`desktop mode`),C==`zvav`?(T+=`Mini`,w=null):T+=`Mobile`,E=E.replace(RegExp(` *`+C+`$`),``)):T==`Safari`&&/\bChrome\b/.exec(fe&&fe[1])?(ce.unshift(`desktop mode`),T=`Chrome Mobile`,w=null,/\bOS X\b/.test(E)?(me=`Apple`,E=`iOS 4.3+`):E=null):/\bSRWare Iron\b/.test(T)&&!w&&(w=be(`Chrome`)),w&&w.indexOf(C=/[\d.]+$/.exec(E))==0&&e.indexOf(`/`+C+`-`)>-1&&(E=ee(E.replace(C,``))),E&&E.indexOf(T)!=-1&&!RegExp(T+` OS`).test(E)&&(E=E.replace(RegExp(` *`+y(T)+` *`),``)),fe&&!/\b(?:Avant|Nook)\b/.test(T)&&(/Browser|Lunascape|Maxthon/.test(T)||T!=`Safari`&&/^iOS/.test(E)&&/\bSafari\b/.test(fe[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(T)&&fe[1])&&(C=fe[fe.length-1])&&ce.push(C),ce.length&&(ce=[`(`+ce.join(`; `)+`)`]),me&&pe&&pe.indexOf(me)<0&&ce.push(`on `+me),pe&&ce.push((/^on /.test(ce[ce.length-1])?``:`on `)+pe),E&&=(C=/ ([\d.+]+)$/.exec(E),de=C&&E.charAt(E.length-C[0].length-1)==`/`,{architecture:32,family:C&&!de?E.replace(C[0],``):E,version:C?C[1]:null,toString:function(){var e=this.version;return this.family+(e&&!de?` `+e:``)+(this.architecture==64?` 64-bit`:``)}}),(C=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(se))&&!/\bi686\b/i.test(se)?(E&&(E.architecture=64,E.family=E.family.replace(RegExp(` *`+C),``)),T&&(/\bWOW64\b/i.test(e)||ue&&/\w(?:86|32)$/.test(i.cpuClass||i.platform)&&!/\bWin64; x64\b/i.test(e))&&ce.unshift(`32-bit`)):E&&/^OS X/.test(E.family)&&T==`Chrome`&&parseFloat(w)>=39&&(E.architecture=64),e||=null;var Se={};return Se.description=e,Se.layout=fe&&fe[0],Se.manufacturer=me,Se.name=T,Se.prerelease=le,Se.product=pe,Se.ua=e,Se.version=T&&w,Se.os=E||{architecture:null,family:null,version:null,toString:function(){return`null`}},Se.parse=x,Se.toString=xe,Se.version&&ce.unshift(w),Se.name&&ce.unshift(T),E&&T&&(E!=String(E).split(` `)[0]||E!=T.split(` `)[0]&&!pe)&&ce.push(pe?`(`+E+`)`:`on `+E),ce.length&&(Se.description=ce.join(` `)),Se}var te=x();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(r.platform=te,define(function(){return te})):i&&a?g(te,function(e,t){i[t]=e}):r.platform=te}).call(e)}));const tDe=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,hP=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let t=e.match(tDe);if(!t)throw Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},gP=e=>e===`*`||e===`x`||e===`X`,_P=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},nDe=(e,t)=>typeof e==typeof t?[e,t]:[String(e),String(t)],rDe=(e,t)=>{if(gP(e)||gP(t))return 0;let[n,r]=nDe(_P(e),_P(t));return n>r?1:n<r?-1:0},vP=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=rDe(e[n]||`0`,t[n]||`0`);if(r!==0)return r}return 0},yP=(e,t)=>{let n=hP(e),r=hP(t),i=n.pop(),a=r.pop(),o=vP(n,r);return o===0?i&&a?vP(i.split(`.`),a.split(`.`)):i||a?i?-1:1:0:o};var B;(function(e){e[e.Canceled=1]=`Canceled`,e[e.Unknown=2]=`Unknown`,e[e.InvalidArgument=3]=`InvalidArgument`,e[e.DeadlineExceeded=4]=`DeadlineExceeded`,e[e.NotFound=5]=`NotFound`,e[e.AlreadyExists=6]=`AlreadyExists`,e[e.PermissionDenied=7]=`PermissionDenied`,e[e.ResourceExhausted=8]=`ResourceExhausted`,e[e.FailedPrecondition=9]=`FailedPrecondition`,e[e.Aborted=10]=`Aborted`,e[e.OutOfRange=11]=`OutOfRange`,e[e.Unimplemented=12]=`Unimplemented`,e[e.Internal=13]=`Internal`,e[e.Unavailable=14]=`Unavailable`,e[e.DataLoss=15]=`DataLoss`,e[e.Unauthenticated=16]=`Unauthenticated`})(B||={});function bP(e,t){return typeof e==`object`&&e&&`$typeName`in e&&typeof e.$typeName==`string`?t===void 0||t.typeName===e.$typeName:!1}var V;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`})(V||={});function iDe(){let e=this.buf,t=this.pos,n=0,r=0;for(let i=0;i<28;i+=7){let a=e[t++];if(n|=(a&127)<<i,!(a&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}}let i=e[t++];if(n|=(i&15)<<28,r=(i&112)>>4,!(i&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}for(let i=3;i<=31;i+=7){let a=e[t++];if(r|=(a&127)<<i,!(a&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}}throw Error(`invalid varint`)}const xP=4294967296;function SP(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=xP&&(i+=r/xP|0,r%=xP)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?TP(r,i):wP(r,i)}function aDe(e,t){let n=wP(e,t),r=n.hi&2147483648;r&&(n=TP(n.lo,n.hi));let i=CP(n.lo,n.hi);return r?`-`+i:i}function CP(e,t){if({lo:e,hi:t}=oDe(e,t),t<=2097151)return String(xP*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+EP(o)+EP(a)}function oDe(e,t){return{lo:e>>>0,hi:t>>>0}}function wP(e,t){return{lo:e|0,hi:t|0}}function TP(e,t){return t=~t,e?e=~e+1:t+=1,wP(e,t)}const EP=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function sDe(e,t){if(e>>>0<128){t.push(e);return}if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function cDe(){let e=this.buf[this.pos++];if(!(e&128))return this.assertBounds(),e;let t=e&127;if(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}const DP=lDe();function lDe(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(globalThis.Deno||globalThis.Bun||typeof process!=`object`||typeof process.env!=`object`||process.env.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`invalid int64: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),OP(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),kP(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),OP(e),SP(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),kP(e),SP(e)},dec(e,t){return aDe(e,t)},uDec(e,t){return CP(e,t)}}}function OP(e){if(!/^-?[0-9]+$/.test(e))throw Error(`invalid int64: `+e)}function kP(e){if(!/^[0-9]+$/.test(e))throw Error(`invalid uint64: `+e)}function AP(e,t){switch(e){case V.STRING:return``;case V.BOOL:return!1;case V.DOUBLE:case V.FLOAT:return 0;case V.INT64:case V.UINT64:case V.SFIXED64:case V.FIXED64:case V.SINT64:return t?`0`:DP.zero;case V.BYTES:return new Uint8Array;default:return 0}}function uDe(e,t){switch(e){case V.BOOL:return t===!1;case V.STRING:return t===``;case V.BYTES:return t instanceof Uint8Array&&!t.byteLength;case V.DOUBLE:case V.FLOAT:return Object.is(t,0);default:return t==0}}const jP=Symbol.for(`reflect unsafe local`);function dDe(e,t){let n=e[t.localName].case;return n===void 0?n:t.fields.find(e=>e.localName===n)}function fDe(e,t){let n=t.localName;if(t.oneof)return e[t.oneof.localName].case===n;if(t.presence!=2)return e[n]!==void 0&&Object.prototype.hasOwnProperty.call(e,n);switch(t.fieldKind){case`list`:return e[n].length>0;case`map`:return Object.keys(e[n]).length>0;case`scalar`:return!uDe(t.scalar,e[n]);case`enum`:return e[n]!==t.enum.values[0].number}throw Error(`message field with implicit presence`)}function MP(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==void 0}function pDe(e,t){if(t.oneof){let n=e[t.oneof.localName];return n.case===t.localName?n.value:void 0}return e[t.localName]}function mDe(e,t,n){t.oneof?e[t.oneof.localName]={case:t.localName,value:n}:e[t.localName]=n}function NP(e,t,n){t===`__proto__`?Object.defineProperty(e,"__proto__",{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function hDe(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function gDe(e,t){let n=t.localName;if(t.oneof){let r=t.oneof.localName;e[r].case===n&&(e[r]={case:void 0})}else if(t.presence!=2)delete e[n];else switch(t.fieldKind){case`map`:e[n]={};break;case`list`:e[n]=[];break;case`enum`:e[n]=t.enum.values[0].number;break;case`scalar`:e[n]=AP(t.scalar,t.longAsString)}}function PP(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function FP(e,t){if(PP(e)&&jP in e&&`add`in e&&`field`in e&&typeof e.field==`function`){if(t!==void 0){let n=t,r=e.field();return n.listKind==r.listKind&&n.scalar===r.scalar&&n.message?.typeName===r.message?.typeName&&n.enum?.typeName===r.enum?.typeName}return!0}return!1}function IP(e,t){if(PP(e)&&jP in e&&`has`in e&&`field`in e&&typeof e.field==`function`){if(t!==void 0){let n=t,r=e.field();return n.mapKey===r.mapKey&&n.mapKind==r.mapKind&&n.scalar===r.scalar&&n.message?.typeName===r.message?.typeName&&n.enum?.typeName===r.enum?.typeName}return!0}return!1}function LP(e,t){return PP(e)&&jP in e&&`desc`in e&&PP(e.desc)&&e.desc.kind===`message`&&(t===void 0||e.desc.typeName==t.typeName)}function _De(e){return BP(e.$typeName)}function RP(e){let t=e.fields[0];return BP(e.typeName)&&t!==void 0&&t.fieldKind==`scalar`&&t.name==`value`&&t.number==1}function zP(e){switch(e.typeName){case`google.protobuf.Any`:case`google.protobuf.Timestamp`:case`google.protobuf.Duration`:case`google.protobuf.FieldMask`:case`google.protobuf.Struct`:case`google.protobuf.Value`:case`google.protobuf.ListValue`:return!0;default:return RP(e)}}const vDe=new Set([`google.protobuf.DoubleValue`,`google.protobuf.FloatValue`,`google.protobuf.Int64Value`,`google.protobuf.UInt64Value`,`google.protobuf.Int32Value`,`google.protobuf.UInt32Value`,`google.protobuf.BoolValue`,`google.protobuf.StringValue`,`google.protobuf.BytesValue`]);function BP(e){return vDe.has(e)}function VP(e,t){return bP(t,e)?t:UP(e)(t)}const HP=new WeakMap;function UP(e){let t=HP.get(e);return t===void 0&&(t=yDe(e),HP.set(e,t)),t}function yDe(e){let t=e.typeName,{properties:n,prototype:r}=bDe(e);return e=>{let i;r===void 0?i={$typeName:t}:(i=Object.create(r),i.$typeName=t);for(let t=0;t<n.length;t++){let r=n[t],a=r.name,o=e?.[a];switch(r.kind){case 0:o==null?r.constant!==void 0&&(i[a]=r.constant):i[a]=r.convert===void 0?o:r.convert(o);break;case 1:i[a]=r.convert!==void 0&&Array.isArray(o)?o.map(r.convert):o??[];break;case 2:if(r.convert===void 0||!PP(o))i[a]=o??{};else{let e={},t=Object.keys(o);for(let n=0;n<t.length;n++)NP(e,t[n],r.convert(o[t[n]]));i[a]=e}break;case 3:{let e=o;if(e?.case!=null){let t=r.convert.get(e.case);if(t!==void 0){i[a]={case:e.case,value:t(e.value)};break}}i[a]={case:void 0};break}}}return i}}function bDe(e){let t=[],n={},r=SDe(e);for(let i of e.members){let e=i.localName;if(i.kind==`oneof`){t.push({name:e,kind:3,constant:void 0,convert:xDe(i)});continue}switch(i.fieldKind){case`message`:t.push({name:e,kind:0,constant:void 0,convert:WP(i)});break;case`list`:t.push({name:e,kind:1,constant:void 0,convert:i.listKind==`message`?WP(i)??(e=>e):i.scalar==V.BYTES?GP:void 0});break;case`map`:t.push({name:e,kind:2,constant:void 0,convert:i.mapKind==`message`?WP(i)??(e=>e):i.scalar==V.BYTES?GP:void 0});break;default:{let a=CDe(i);t.push({name:e,kind:0,constant:i.presence==2?a:void 0,convert:i.fieldKind==`scalar`&&i.scalar==V.BYTES?GP:void 0}),r&&(n[e]=a);break}}}return{properties:t,prototype:r?n:void 0}}function xDe(e){let t=new Map;for(let n of e.fields){let e;n.fieldKind==`message`?e=WP(n):n.fieldKind==`scalar`&&n.scalar==V.BYTES&&(e=GP),t.set(n.localName,e??(e=>e))}return t}function WP(e){if(e.fieldKind==`message`&&!e.oneof&&RP(e.message))return e.message.fields[0].scalar==V.BYTES?GP:void 0;if(e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!==`google.protobuf.Value`)return;let t=e.message,n;return e=>!PP(e)||bP(e,t)?e:(n??=UP(t),n(e))}function GP(e){return Array.isArray(e)?new Uint8Array(e):e}function SDe(e){switch(e.file.edition){case 999:return!1;case 998:return!0;default:return e.fields.some(e=>e.presence!=2&&e.fieldKind!=`message`&&!e.oneof)}}function CDe(e){let t=e.getDefaultValue();return t===void 0?e.fieldKind==`scalar`?AP(e.scalar,e.longAsString):e.enum.values[0].number:e.fieldKind==`scalar`&&e.longAsString?t.toString():t}const wDe=[`FieldValueInvalidError`,`FieldListRangeError`,`ForeignFieldError`];var KP=class extends Error{constructor(e,t,n=`FieldValueInvalidError`){super(t),this.name=n,this.field=()=>e}};function TDe(e){return e instanceof Error&&wDe.includes(e.name)&&`field`in e&&typeof e.field==`function`}let qP;function EDe(e){qP=Object.assign(Object.assign({},e),{encodeUtf8Into:e.encodeUtf8Into??YP(e.encodeUtf8.bind(e))})}function JP(){if(!qP){let e=globalThis;if(!e.TextEncoder||!e.TextDecoder)throw Error(`encoding API missing: install TextEncoder and TextDecoder on globalThis`);let t=new e.TextEncoder,n=new e.TextDecoder(`utf-8`,{ignoreBOM:!0}),r,i={encodeUtf8(e){return t.encode(e)},decodeUtf8(t,i){return i?(r||=new e.TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),r.decode(t)):n.decode(t)},checkUtf8(e){try{return!0}catch{return!1}}};t.encodeInto&&(i.encodeUtf8Into=t.encodeInto.bind(t));let a=String.prototype.isWellFormed;a&&(i.checkUtf8=e=>a.call(e)),EDe(i)}return qP}function YP(e){return(t,n)=>{let r=e(t);return n.set(r),{written:r.byteLength}}}var XP;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(XP||={});var ZP=class{constructor(e){this.stackPos=[],this.encodeUtf8Into=e?YP(e):JP().encodeUtf8Into,this.buffer=$P,this.viewCache=ODe,this.pos=0}ensureCapacity(e){let t=this.pos+e;if(t>this.buffer.length){let e=this.buffer.length||DDe;for(;e<t;)e*=2;let n=new Uint8Array(e);this.pos>0&&n.set(this.buffer),this.buffer=n}}view(){let e=this.buffer,t=this.viewCache;if(t.byteLength===e.byteLength)return t;let n=new DataView(e.buffer);return this.viewCache=n,n}finish(){let e=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],e}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(QP),this.buffer[this.pos++]=0,this}join(){let e=this.stackPos.pop();if(e===void 0)throw Error(`invalid state, fork stack empty`);let t=this.pos-e-QP,n=eF(t);return n>QP&&(this.ensureCapacity(n-QP),this.buffer.copyWithin(e+n,e+QP,this.pos)),this.pos=e,this.uint32(t),this.pos+=t,this}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.ensureCapacity(e.length),this.buffer.set(e,this.pos),this.pos+=e.length,this}uint32(e){if(rF(e),this.ensureCapacity(5),e<128)return this.buffer[this.pos++]=e,this;for(;e>127;)this.buffer[this.pos++]=e&127|128,e>>>=7;return this.buffer[this.pos++]=e,this}int32(e){if(nF(e),e>=0)return this.uint32(e);this.ensureCapacity(10);for(let t=0;t<9;t++)this.buffer[this.pos++]=e&127|128,e>>=7;return this.buffer[this.pos++]=1,this}bool(e){return this.ensureCapacity(1),this.buffer[this.pos++]=+!!e,this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){typeof e!=`string`&&(e=String(e));let t=e.length;if(t<=kDe){this.ensureCapacity(t+1);let n=this.buffer,r=this.pos;n[r++]=t;let i=0;for(;i<t;i++){let t=e.charCodeAt(i);if(t>127)break;n[r++]=t}if(i==t)return this.pos=r,this}this.ensureCapacity(t*3+5);let n=eF(t),r=this.buffer,i=this.pos,{written:a}=this.encodeUtf8Into(e,r.subarray(i+n)),o=eF(a);return o!=n&&r.copyWithin(i+o,i+n,i+n+a),this.uint32(a),this.pos+=a,this}float(e){return ADe(e),this.ensureCapacity(4),this.view().setFloat32(this.pos,e,!0),this.pos+=4,this}double(e){return this.ensureCapacity(8),this.view().setFloat64(this.pos,e,!0),this.pos+=8,this}fixed32(e){return rF(e),this.ensureCapacity(4),this.view().setUint32(this.pos,e,!0),this.pos+=4,this}sfixed32(e){return nF(e),this.ensureCapacity(4),this.view().setInt32(this.pos,e,!0),this.pos+=4,this}sint32(e){return nF(e),this.uint32((e<<1^e>>31)>>>0)}sfixed64(e){let t=DP.enc(e);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,t.lo,!0),n.setInt32(this.pos+4,t.hi,!0),this.pos+=8,this}fixed64(e){let t=DP.uEnc(e);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,t.lo,!0),n.setInt32(this.pos+4,t.hi,!0),this.pos+=8,this}int64(e){let t=DP.enc(e);return this.writeVarint64(t.lo,t.hi)}sint64(e){let t=DP.enc(e),n=t.hi>>31,r=t.lo<<1^n,i=(t.hi<<1|t.lo>>>31)^n;return this.writeVarint64(r,i)}uint64(e){let t=DP.uEnc(e);return this.writeVarint64(t.lo,t.hi)}writeVarint64(e,t){this.ensureCapacity(10);let n=this.buffer,r=this.pos;for(let i=0;i<28;i+=7){let a=e>>>i,o=!(!(a>>>7)&&t==0);if(n[r++]=(o?a|128:a)&255,!o)return this.pos=r,this}let i=e>>>28&15|(t&7)<<4,a=!!(t>>3);if(n[r++]=(a?i|128:i)&255,!a)return this.pos=r,this;for(let e=3;e<31;e+=7){let i=t>>>e,a=!!(i>>>7);if(n[r++]=(a?i|128:i)&255,!a)return this.pos=r,this}return n[r++]=t>>>31&1,this.pos=r,this}};const DDe=128,QP=1,$P=new Uint8Array,ODe=new DataView($P.buffer),kDe=32;function eF(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}var tF=class{constructor(e,t=JP().decodeUtf8){this.decodeUtf8=t,this.varint64Lo=0,this.varint64Hi=0,this.varint64=iDe,this.uint32=cDe,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.pos,t=this.uint32(),n=this.pos-e;if(n>5||n==5&&this.buf[this.pos-1]>15)throw Error(`illegal tag: varint overflows uint32`);let r=t>>>3,i=t&7;if(r<=0||i>5)throw Error(`illegal tag: field no `+r+` wire type `+i);return[r,i]}skip(e,t,n=100){let r=this.pos;switch(e){case XP.Varint:for(;this.buf[this.pos++]&128;);break;case XP.Bit64:this.pos+=4;case XP.Bit32:this.pos+=4;break;case XP.LengthDelimited:let r=this.uint32();this.pos+=r;break;case XP.StartGroup:if(n<=0)throw Error(`maximum recursion depth reached`);for(;;){let[e,r]=this.tag();if(r===XP.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(r,e,n-1)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return this.varint64(),DP.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),DP.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let e=this.varint64Lo,t=this.varint64Hi,n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,DP.dec(e,t)}bool(){let e=this.buf[this.pos];return e<128?(this.pos++,e!==0):(this.varint64(),this.varint64Lo!==0||this.varint64Hi!==0)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return DP.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return DP.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e){let t=this.uint32(),n=this.pos;this.pos+=t,this.assertBounds();let r=this.buf;if(t<=32){let i=Array(t);for(let a=0;a<t;a++){let t=r[n+a];if(t>127)return this.decodeUtf8(r.subarray(n,this.pos),e);i[a]=t}return String.fromCharCode.apply(String,i)}return this.decodeUtf8(r.subarray(n,this.pos),e)}};function nF(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid int32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int32: `+e)}function rF(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid uint32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint32: `+e)}function ADe(e){if(typeof e==`string`){let t=e;if(e=Number(e),Number.isNaN(e)&&t!==`NaN`)throw Error(`invalid float32: `+t)}else if(typeof e!=`number`)throw Error(`invalid float32: `+typeof e);if(!Number.isFinite(Math.fround(e))&&Number.isFinite(e))throw Error(`invalid float32: `+e)}function iF(e,t){let n=e.fieldKind==`list`?FP(t,e):e.fieldKind==`map`?IP(t,e):oF(e,t);if(n===!0)return;let r;switch(e.fieldKind){case`list`:r=`expected ${dF(e)}, got ${lF(t)}`;break;case`map`:r=`expected ${fF(e)}, got ${lF(t)}`;break;default:r=cF(e,t,n)}return new KP(e,r)}function aF(e,t,n){let r=oF(e,n);if(r!==!0)return new KP(e,`list item #${t+1}: ${cF(e,n,r)}`)}function jDe(e,t,n){let r=sF(e.mapKey)(t);if(r!==!0)return new KP(e,`invalid map key: ${cF({scalar:e.mapKey},t,r)}`);let i=oF(e,n);if(i!==!0)return new KP(e,`map entry ${lF(t)}: ${cF(e,n,i)}`)}function oF(e,t){return e.scalar===void 0?e.enum===void 0?LP(t,e.message):e.enum.open?sF(V.INT32)(t):e.enum.values.some(e=>e.number===t):sF(e.scalar)(t)}function sF(e){switch(e){case V.DOUBLE:return e=>typeof e==`number`;case V.FLOAT:return e=>typeof e==`number`?!Number.isFinite(Math.fround(e))&&Number.isFinite(e)?`${e.toFixed()} out of range`:!0:!1;case V.INT32:case V.SFIXED32:case V.SINT32:return e=>typeof e!=`number`||!Number.isInteger(e)?!1:e>2147483647||e<-2147483648?`${e.toFixed()} out of range`:!0;case V.FIXED32:case V.UINT32:return e=>typeof e!=`number`||!Number.isInteger(e)?!1:e>4294967295||e<0?`${e.toFixed()} out of range`:!0;case V.BOOL:return e=>typeof e==`boolean`;case V.STRING:return e=>typeof e==`string`?JP().checkUtf8(e)||`invalid UTF8`:!1;case V.BYTES:return e=>e instanceof Uint8Array;case V.INT64:case V.SFIXED64:case V.SINT64:return e=>{if(typeof e==`bigint`||typeof e==`number`||typeof e==`string`&&e.length>0)try{return DP.parse(e),!0}catch{return`${e} out of range`}return!1};case V.FIXED64:case V.UINT64:return e=>{if(typeof e==`bigint`||typeof e==`number`||typeof e==`string`&&e.length>0)try{return DP.uParse(e),!0}catch{return`${e} out of range`}return!1}}}function cF(e,t,n){return n=typeof n==`string`?`: ${n}`:`, got ${lF(t)}`,e.scalar===void 0?e.enum===void 0?`expected ${uF(e.message)}`+n:`expected ${e.enum.toString()}`+n:`expected ${MDe(e.scalar)}`+n}function lF(e){switch(typeof e){case`object`:return e===null?`null`:e instanceof Uint8Array?`Uint8Array(${e.length})`:Array.isArray(e)?`Array(${e.length})`:FP(e)?dF(e.field()):IP(e)?fF(e.field()):LP(e)?uF(e.desc):bP(e)?`message ${e.$typeName}`:`object`;case`string`:return e.length>30?`string`:`"${e.split(`"`).join(`\\"`)}"`;case`boolean`:return String(e);case`number`:return String(e);case`bigint`:return String(e)+`n`;default:return typeof e}}function uF(e){return`ReflectMessage (${e.typeName})`}function dF(e){switch(e.listKind){case`message`:return`ReflectList (${e.message.toString()})`;case`enum`:return`ReflectList (${e.enum.toString()})`;case`scalar`:return`ReflectList (${V[e.scalar]})`}}function fF(e){switch(e.mapKind){case`message`:return`ReflectMap (${V[e.mapKey]}, ${e.message.toString()})`;case`enum`:return`ReflectMap (${V[e.mapKey]}, ${e.enum.toString()})`;case`scalar`:return`ReflectMap (${V[e.mapKey]}, ${V[e.scalar]})`}}function MDe(e){switch(e){case V.STRING:return`string`;case V.BOOL:return`boolean`;case V.INT64:case V.SINT64:case V.SFIXED64:return`bigint (int64)`;case V.UINT64:case V.FIXED64:return`bigint (uint64)`;case V.BYTES:return`Uint8Array`;case V.DOUBLE:return`number (float64)`;case V.FLOAT:return`number (float32)`;case V.FIXED32:case V.UINT32:return`number (uint32)`;case V.INT32:case V.SFIXED32:case V.SINT32:return`number (int32)`}}function pF(e){if(NDe(e))return{toMessage:e=>mF(e),toLocal:e=>hF(e)};if(e.fieldKind==`message`&&!e.oneof&&RP(e.message)){let t=e.message,n=t.fields[0].localName;return{toMessage:e=>{let r=VP(t);return e!==void 0&&(r[n]=e),r},toLocal:e=>e[n]}}let t=e.message;return{toMessage:e=>e===void 0?VP(t):e,toLocal:e=>e}}function NDe(e){return e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`}function mF(e){let t={$typeName:`google.protobuf.Struct`,fields:{}};if(PP(e))for(let n of Object.keys(e))NP(t.fields,n,_F(e[n]));return t}function hF(e){let t={};for(let n of Object.keys(e.fields))NP(t,n,gF(e.fields[n]));return t}function gF(e){switch(e.kind.case){case`structValue`:return hF(e.kind.value);case`listValue`:return e.kind.value.values.map(gF);case`nullValue`:case void 0:return null;default:return e.kind.value}}function _F(e){let t={$typeName:`google.protobuf.Value`,kind:{case:void 0}};switch(typeof e){case`number`:t.kind={case:`numberValue`,value:e};break;case`string`:t.kind={case:`stringValue`,value:e};break;case`boolean`:t.kind={case:`boolValue`,value:e};break;case`object`:if(e===null)t.kind={case:`nullValue`,value:0};else if(Array.isArray(e)){let n={$typeName:`google.protobuf.ListValue`,values:[]};if(Array.isArray(e))for(let t of e)n.values.push(_F(t));t.kind={case:`listValue`,value:n}}else t.kind={case:`structValue`,value:mF(e)}}return t}function PDe(e,t,n=!0){return new yF(e,t,n)}const vF=new WeakMap;var yF=class{get sortedFields(){let e=vF.get(this.desc);if(e)return e;let t=this.desc.fields.concat().sort((e,t)=>e.number-t.number);return vF.set(this.desc,t),t}constructor(e,t,n=!0){this.lists=new Map,this.maps=new Map,this.check=n,this.desc=e,this.message=this[jP]=t??VP(e),this.fields=e.fields,this.oneofs=e.oneofs,this.members=e.members}findNumber(e){return this._fieldsByNumber||=new Map(this.desc.fields.map(e=>[e.number,e])),this._fieldsByNumber.get(e)}oneofCase(e){return bF(this.message,e),dDe(this.message,e)}isSet(e){return bF(this.message,e),fDe(this.message,e)}clear(e){bF(this.message,e),gDe(this.message,e)}get(e){bF(this.message,e);let t=pDe(this.message,e);switch(e.fieldKind){case`list`:let n=this.lists.get(e);return(!n||n[jP]!==t)&&this.lists.set(e,n=new FDe(e,t,this.check)),n;case`map`:let r=this.maps.get(e);return(!r||r[jP]!==t)&&this.maps.set(e,r=new IDe(e,t,this.check)),r;case`message`:return SF(e,t,this.check);case`scalar`:return t===void 0?AP(e.scalar,!1):OF(e,t);case`enum`:return t??e.enum.values[0].number}}set(e,t){if(bF(this.message,e),this.check){let n=iF(e,t);if(n)throw n}let n;n=e.fieldKind==`message`?xF(e,t):IP(t)||FP(t)?t[jP]:kF(e,t),mDe(this.message,e,n)}getUnknown(){return this.message.$unknown}setUnknown(e){this.message.$unknown=e}};function bF(e,t){if(t.parent.typeName!==e.$typeName)throw new KP(t,`cannot use ${t.toString()} with message ${e.$typeName}`,`ForeignFieldError`)}var FDe=class{field(){return this._field}get size(){return this._arr.length}constructor(e,t,n){this._field=e,this._arr=this[jP]=t,this.check=n}get(e){let t=this._arr[e];return t===void 0?void 0:wF(this._field,t,this.check)}set(e,t){if(e<0||e>=this._arr.length)throw new KP(this._field,`list item #${e+1}: out of range`);if(this.check){let n=aF(this._field,e,t);if(n)throw n}this._arr[e]=CF(this._field,t)}add(e){if(this.check){let t=aF(this._field,this._arr.length,e);if(t)throw t}this._arr.push(CF(this._field,e))}clear(){this._arr.splice(0,this._arr.length)}[Symbol.iterator](){return this.values()}keys(){return this._arr.keys()}*values(){for(let e of this._arr)yield wF(this._field,e,this.check)}*entries(){for(let e=0;e<this._arr.length;e++)yield[e,wF(this._field,this._arr[e],this.check)]}},IDe=class{constructor(e,t,n=!0){this.obj=this[jP]=t??{},this.check=n,this._field=e}field(){return this._field}set(e,t){if(this.check){let n=jDe(this._field,e,t);if(n)throw n}return NP(this.obj,EF(e),LDe(this._field,t)),this}delete(e){let t=EF(e),n=Object.prototype.hasOwnProperty.call(this.obj,t);return n&&delete this.obj[t],n}clear(){for(let e of Object.keys(this.obj))delete this.obj[e]}get(e){let t=hDe(this.obj,EF(e));return t!==void 0&&(t=TF(this._field,t,this.check)),t}has(e){return Object.prototype.hasOwnProperty.call(this.obj,EF(e))}*keys(){for(let e of Object.keys(this.obj))yield DF(e,this._field.mapKey)}*entries(){for(let e of Object.entries(this.obj))yield[DF(e[0],this._field.mapKey),TF(this._field,e[1],this.check)]}[Symbol.iterator](){return this.entries()}get size(){return Object.keys(this.obj).length}*values(){for(let e of Object.values(this.obj))yield TF(this._field,e,this.check)}forEach(e,t){for(let n of this.entries())e.call(t,n[1],n[0],this)}};function xF(e,t){return LP(t)?_De(t.message)&&!e.oneof&&e.fieldKind==`message`?t.message.value:t.desc.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`?hF(t.message):t.message:t}function SF(e,t,n){return t!==void 0&&(RP(e.message)&&!e.oneof&&e.fieldKind==`message`?t={$typeName:e.message.typeName,value:OF(e.message.fields[0],t)}:e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`&&PP(t)&&(t=mF(t))),new yF(e.message,t,n)}function CF(e,t){return e.listKind==`message`?xF(e,t):kF(e,t)}function wF(e,t,n){return e.listKind==`message`?SF(e,t,n):OF(e,t)}function LDe(e,t){return e.mapKind==`message`?xF(e,t):kF(e,t)}function TF(e,t,n){return e.mapKind==`message`?SF(e,t,n):t}function EF(e){return typeof e==`string`||typeof e==`number`?e:String(e)}function DF(e,t){switch(t){case V.STRING:return e;case V.INT32:case V.FIXED32:case V.UINT32:case V.SFIXED32:case V.SINT32:{let t=Number.parseInt(e);if(Number.isFinite(t))return t;break}case V.BOOL:switch(e){case`true`:return!0;case`false`:return!1}break;case V.UINT64:case V.FIXED64:try{return DP.uParse(e)}catch{}break;default:try{return DP.parse(e)}catch{}}return e}function OF(e,t){switch(e.scalar){case V.INT64:case V.SFIXED64:case V.SINT64:`longAsString`in e&&e.longAsString&&typeof t==`string`&&(t=DP.parse(t));break;case V.FIXED64:case V.UINT64:`longAsString`in e&&e.longAsString&&typeof t==`string`&&(t=DP.uParse(t))}return t}function kF(e,t){switch(e.scalar){case V.INT64:case V.SFIXED64:case V.SINT64:`longAsString`in e&&e.longAsString?t=String(t):(typeof t==`string`||typeof t==`number`)&&(t=DP.parse(t));break;case V.FIXED64:case V.UINT64:`longAsString`in e&&e.longAsString?t=String(t):(typeof t==`string`||typeof t==`number`)&&(t=DP.uParse(t))}return t}const AF=Uint8Array.prototype.setFromBase64;function jF(e){let t=e.length,n=t-(t+3>>2);!(t&3)&&e[t-1]==`=`&&(n-=e[t-2]==`=`?2:1);let r=new Uint8Array(n),i=-1;if(AF)try{let n=AF.call(r,e);n.read==t&&(i=n.written)}catch{}return i<0&&(i=RDe(r,e)),i==n?r:r.subarray(0,i)}function RDe(e,t){let n=BDe(),r=0,i=0,a,o=0;for(let s=0;s<t.length;s++){if(a=n[t.charCodeAt(s)],a===void 0)switch(t[s]){case`=`:i=0;case`
|
|
452
|
+
`).map(e=>/^(0x[0-9a-fA-F]+)\s+(-?\d+)\s+(\d+)\s+(\S+)\s?(.*)$/u.exec(e)).filter(e=>e!==null).map(e=>({id:e[1]??``,pid:Number(e[3]),title:e[5]??``})),bN=(e,t)=>{let n=RegExp(`^\\s*${t}:\\s*(-?\\d+)\\s*$`,`mu`).exec(e);return n?.[1]===void 0?void 0:Number(n[1])},xN=(e,t)=>{let n=RegExp(`^${t}\\(CARDINAL\\) = (\\d+), (\\d+), (\\d+), (\\d+)$`,`mu`).exec(e);return n===null?RegExp(`^${t}:\\s+not found\\.$`,`mu`).test(e)?[0,0,0,0]:void 0:[Number(n[1]),Number(n[2]),Number(n[3]),Number(n[4])]},SN=(e,t,n,r)=>MO(function*(){if(!/^0x[0-9a-fA-F]+$/u.test(n))return yield*z(`window id ${n} is not an X window id`);let i=yield*aN(e,t,`xwininfo`,[`-id`,n],r,fN(t)),a=bN(i,`Absolute upper-left X`),o=bN(i,`Absolute upper-left Y`),s=bN(i,`Width`),c=bN(i,`Height`);if(a===void 0||o===void 0||s===void 0||c===void 0)return yield*z(`xwininfo did not report the window's geometry`);let l=yield*aN(e,t,`xprop`,[`-id`,n,`_GTK_FRAME_EXTENTS`,`_NET_FRAME_EXTENTS`],r,fN(t)),u=xN(l,`_GTK_FRAME_EXTENTS`);if(u===void 0)return yield*z(`xprop reported an unreadable _GTK_FRAME_EXTENTS`);let d=xN(l,`_NET_FRAME_EXTENTS`);if(d===void 0)return yield*z(`xprop reported an unreadable _NET_FRAME_EXTENTS`);let[f,p,m,h]=u,[g,_,v,y]=d;return{x:a+f-g,y:o+m-v,width:s-f-p+g+_,height:c-m-h+v+y,viewable:/Map State:\s*IsViewable/u.test(i),gtk_frame_extents:u,net_frame_extents:d}}),uEe=/^_NET_CLIENT_LIST_STACKING\(WINDOW\): window id # (.*)$/mu,dEe=(e,t,n)=>MO(function*(){let r=yield*aN(e,t,`xprop`,[`-root`,`_NET_CLIENT_LIST_STACKING`],n,fN(t)),i=uEe.exec(r)?.[1]?.split(`,`).map(e=>e.trim());return i===void 0||!i.every(e=>/^0x[0-9a-fA-F]+$/u.test(e))?yield*z(`xprop reported an unreadable _NET_CLIENT_LIST_STACKING`):i}),fEe=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,pEe=(e,t,n,r,i)=>MO(function*(){let a=yield*dEe(e,t,i),o=a.findIndex(e=>Number.parseInt(e,16)===Number.parseInt(n,16));if(o<0)return yield*z(`window ${n} is not in the window manager's stacking order`);let s=[];for(let n of a.slice(o+1)){let a=yield*SN(e,t,n,i);a.viewable&&fEe(a,r)&&s.push(n)}return s}),CN=(e,t,n,r)=>MO(function*(){let i=yield*aN(e,t,`wmctrl`,[`-lp`],r,fN(t)),a=lEe(i).filter(e=>n===void 0||e.pid===n),o=[];for(let n of a){let i=yield*SN(e,t,n.id,r);o.push({...n,x:i.x,y:i.y,width:i.width,height:i.height,gtk_frame_extents:i.gtk_frame_extents,net_frame_extents:i.net_frame_extents})}return o}),mEe=/^[a-z0-9][a-z0-9-]{0,62}$/u,hEe=(e,t)=>{let n=e.connection.XDG_RUNTIME_DIR??fN(e).XDG_RUNTIME_DIR;return{...fN(e),...e.keyring?.phase===`ready`?{DBUS_SESSION_BUS_ADDRESS:e.keyring.address}:{},HOME:t,XDG_CONFIG_HOME:d(t,`.config`),XDG_CACHE_HOME:d(t,`.cache`),XDG_DATA_HOME:d(t,`.local/share`),XDG_RUNTIME_DIR:n??d(t,`.runtime`)}},wN=(e,t,n,r)=>MO(function*(){let i=n=>d(e.guest_dir,`logs`,n<=1?`app-${t}.log`:`app-${t}-${n}.log`);for(let t=n;;t+=1){let[n]=yield*mM([i(t)],yield*FM(r,e.probe_timeout_s)).pipe(WO(e=>new _M({reason:`log path check failed: ${e.message}`})));if(n===!1)return i(t)}}),TN=(e,t,n)=>MO(function*(){let r=yield*AM(e),i=Object.fromEntries(Object.entries(r.apps).filter(([e])=>e!==t));yield*jM(e,{...r,apps:n===void 0?i:{...i,[t]:n}})}),EN=(e,t,n)=>MO(function*(){let r=yield*AM(e),i=r.apps[t];if(i===void 0)return yield*z(`no app named ${t}`);if(i.phase===`unidentified`)return yield*z(`app ${t} was never identified`);yield*jM(e,{...r,apps:{...r.apps,[t]:n(i)}})}),DN=(e,t,n,r,i,a=`app ${n} is no longer running`)=>MO(function*(){let[o]=yield*cN([r.identity.pid],i,t.probe_timeout_s);if(o?.kind!==`running`||fM(o.identity)!==fM(r.identity))return yield*EN(e,n,e=>({...e,phase:`ended`})),yield*z(a)}),ON=(e,t,n)=>new _M({reason:`app ${e} started as process ${t}, but ${n}; it cannot be signalled, so the guest must be retired`,retire:!0}),gEe=(e,t,n,r,i,a)=>MO(function*(){let o=yield*RO(TN(e,n,{...i,pid:r,phase:`unidentified`,reason:`its identity was not read yet`})),s=yield*RO(sN([r],t.probe_timeout_s*1e3));if(s._tag===`Failure`)return o._tag===`Failure`?yield*NO(ON(n,r,`it could not be recorded (${o.failure.reason}) and its identity could not be read (${s.failure.reason})`)):(yield*TN(e,n,{...i,pid:r,phase:`unidentified`,reason:s.failure.reason}).pipe(GO),yield*NO(ON(n,r,`its identity could not be read (${s.failure.reason})`)));let[c]=s.success;if(c?.kind!==`running`)return yield*TN(e,n,a).pipe(GO),yield*z(`app exited at once; see its log ${i.log}`);let l=yield*RO(TN(e,n,{...i,identity:c.identity,phase:`running`}));return l._tag===`Success`?c.identity:(yield*hN([[`app:${n}`,c.identity]],t.shutdown_timeout_s,t.probe_timeout_s))[`app:${n}`]?.outcome===`ended`?(yield*TN(e,n,a).pipe(GO),yield*z(`app ${n} started as process ${r} was ended because its record could not be written: ${l.failure.reason}`)):yield*NO(ON(n,r,`its record could not be written (${l.failure.reason}) and it could not be ended`))}),_Ee=(e,t,n,r,i)=>MO(function*(){if(r.notStarted===!0)return yield*TN(e,t,i).pipe(GO),yield*z(`app could not start: ${r.message}`);let a=`its start may have run, but returned no process id: ${r.message}`;return yield*TN(e,t,{...n,pid:null,phase:`unidentified`,reason:a}).pipe(GO),yield*NO(new _M({reason:`app ${t}: ${a}; it cannot be signalled, so the guest must be retired`,retire:!0}))}),vEe=e=>MO(function*(){if(!mEe.test(e.name))return yield*z(`app name must be lowercase letters, digits and hyphens`);if(!u(e.home))return yield*z(`app home must be an absolute guest path`);if(e.argv.length===0)return yield*z(`app launch needs a command after --`);let t=yield*AM(e.stateDir),{session:n,deadline:r}=yield*yN(e.stateDir,t.ready_timeout_s);if(n.apps[e.name]!==void 0)return yield*z(`an app named ${e.name} was already launched`);let i=yield*FM(r,n.probe_timeout_s),[a]=yield*mM([e.home],i).pipe(WO(e=>new _M({reason:`path check failed: ${e.message}`})));if(a===!0)return yield*z(`fresh-only launch refuses existing path: ${e.home}`);for(let t of[e.home,d(e.home,`.config`),d(e.home,`.cache`),d(e.home,`.local`),d(e.home,`.local/share`)])yield*gM(t,t===e.home,i).pipe(WO(e=>new _M({reason:`app home setup failed: ${e.message}`})));n.connection.XDG_RUNTIME_DIR===void 0&&n.kind===`adopted`&&(yield*gM(d(e.home,`.runtime`),!1,i).pipe(WO(e=>new _M({reason:`app home setup failed: ${e.message}`}))));let o={argv:[...e.argv],home:e.home,log:yield*wN(n,e.name,1,r),launched_at:yield*MM};return yield*kN(e.stateDir,n,e.name,o,e.timeout,void 0)}),kN=(e,t,n,r,i,a)=>MO(function*(){let o=yield*lM;yield*TN(e,n,{...r,pid:null,phase:`unidentified`,reason:`its start was requested, but no process id was recorded`}).pipe(WO(e=>new _M({reason:`app ${n} was not started, because it could not be recorded first: ${e.reason}`})));let s=yield*NM,c=yield*RO(o.start(r.argv,{env:hEe(t,r.home),unsetEnv:tN,cwd:r.home,logPath:r.log}));if(c._tag===`Failure`)return yield*_Ee(e,n,r,c.failure,a);let l=yield*gEe(e,t,n,c.success,r,a),u={...r,identity:l,phase:`running`},d=yield*PM(i);return yield*MO(function*(){for(;;){let a=yield*CN(e,t,l.pid,d);if(yield*DN(e,t,n,u,d,`app exited before it showed a window; see its log ${r.log}`),a.length>0)return{status:`launched`,app:n,identity:l,home:r.home,log:r.log,windows:a,launch_to_window_ms:(yield*NM)-s};let o=d.endMs-(yield*NM);if(o<=0)return yield*z(`app showed no window within ${i}s`);yield*JO(Math.min(250,o))}}).pipe(KTe(`app showed no window within ${i}s`))}),yEe=e=>MO(function*(){let t=yield*AM(e.stateDir),{session:n,deadline:r}=yield*yN(e.stateDir,t.ready_timeout_s),i=n.apps[e.name];if(i===void 0)return yield*z(`no app named ${e.name}`);if(i.phase===`running`)return yield*z(`app ${e.name} is running`);if(i.phase===`unidentified`||i.phase===`unresolved`)return yield*z(`app ${e.name} is ${i.phase}, so it may still be running; it cannot be relaunched`);let{previous:a=[],...o}=i,s={argv:i.argv,home:i.home,log:yield*wN(n,e.name,a.length+2,r),launched_at:yield*MM,previous:[...a,o]};return yield*kN(e.stateDir,n,e.name,s,e.timeout,i)}),AN=(e,t)=>MO(function*(){let n=e.apps[t];return n===void 0?yield*z(`no app named ${t}`):n.phase===`running`?n:yield*z(`app ${t} is ${n.phase}`)}),bEe=(e,t,n)=>MO(function*(){let{session:r,deadline:i}=yield*yN(e,n),a=yield*AN(r,t),o=yield*CN(e,r,a.identity.pid,i);return yield*DN(e,r,t,a,i),{status:`windows`,app:t,identity:a.identity,windows:o}}),xEe=(e,t,n)=>XO(MO(function*(){let r=yield*lM,i=yield*AM(e),{session:a,deadline:o}=yield*yN(e,i.ready_timeout_s),s=yield*AN(a,t),c=yield*CN(e,a,s.identity.pid,o);if(yield*DN(e,a,t,s,o),c.length===0)return yield*z(`app ${t} has no window to close`);let l=yield*RO(r.watchExit(s.identity.pid,n*1e3)),u=yield*NM,d=yield*MM;for(let t of c)yield*aN(e,a,`wmctrl`,[`-i`,`-c`,t.id],o,fN(a));let f=yield*PM(n),p=a.probe_timeout_s*1e3;for(;;){let e=yield*RO(sN([s.identity.pid],p).pipe(qO({duration:p,orElse:()=>z(`process identity read timed out after ${a.probe_timeout_s}s`)})));if(e._tag===`Failure`)return yield*z(`app ${t} was asked to close, but whether it ended could not be read: ${e.failure.reason}`);let[r]=e.success;if(r===void 0||r.kind===`absent`||r.kind===`zombie`||r.kind===`running`&&fM(r.identity)!==fM(s.identity))break;let i=f.endMs-(yield*NM);if(i<=0)return yield*z(`app ${t} was asked to close and is still running after ${n}s`);yield*JO(Math.min(100,i))}let m=yield*NM,h=l._tag===`Success`?yield*l.success.pipe(qO({duration:2e3,orElse:()=>DO(void 0)}),KO(()=>void 0)):void 0,g=yield*CN(e,a,s.identity.pid,yield*PM(a.ready_timeout_s)),_={outcome:`closed`,windows_closed:c.map(e=>e.id),windows_left:g.map(e=>e.id),exit_code:h??null,close_requested_at:d,close_to_exit_ms:m-u};return yield*EN(e,t,e=>({...e,phase:`closed`,ended:_})),g.length>0?yield*z(`app ${t} ended but windows with its process id remain`):{status:`closed`,app:t,identity:s.identity,..._}})),jN=(e,t,n={})=>{let r={},i=0;for(;i<e.length;){let a=e[i]??``;if(a===`--`)return n.allowRest===!0?MN(r,t,e.slice(i+1)):{ok:!1,reason:`unexpected --`};let o=t[a];if(!a.startsWith(`--`)||o===void 0)return{ok:!1,reason:`unrecognized argument ${JSON.stringify(a)}`};if(r[a]!==void 0)return{ok:!1,reason:`${a} given more than once`};let s=e.slice(i+1,i+1+o.arity);if(s.length<o.arity||s.some(e=>e===`--`))return{ok:!1,reason:`${a} needs ${o.arity} value${o.arity===1?``:`s`}`};r[a]=s,i+=1+o.arity}return n.allowRest===!0?{ok:!1,reason:`missing -- before the command`}:MN(r,t,[])},MN=(e,t,n)=>{for(let[n,r]of Object.entries(t))if(r.required===!0&&e[n]===void 0)return{ok:!1,reason:`${n} is required`};return{ok:!0,values:e,rest:n}},SEe=e=>/^[+-]?\d+$/u.test(e)&&Number.isSafeInteger(Number(e))?Number(e):void 0;var NN=Oe(((e,t)=>{t.exports=ree.default})),PN=Oe(((e,t)=>{t.exports=ne.default})),FN=Oe(((e,t)=>{t.exports=eee.default})),IN=Oe(((e,t)=>{let n=NN(),r=PN(),i=t.exports=function(){r.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding=`utf8`,this.writable=!0};n.inherits(i,r),i.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit(`drain`))}.bind(this))},i.prototype.write=function(e,t){if(!this.writable)return this.emit(`error`,Error(`Stream not writable`)),!1;let n;return n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused},i.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))},i.prototype.destroySoon=i.prototype.end,i.prototype._end=function(){this._reads.length>0&&this.emit(`error`,Error(`Unexpected end of input`)),this.destroy()},i.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit(`close`))},i.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},i.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let i=this._buffers[n++],a=Math.min(i.length,e.length-t);i.copy(r,t,0,a),t+=a,a!==i.length&&(this._buffers[--n]=i.slice(a))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},i.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit(`error`,e)}}})),LN=Oe((e=>{let t=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];e.getImagePasses=function(e,n){let r=[],i=e%8,a=n%8,o=(e-i)/8,s=(n-a)/8;for(let e=0;e<t.length;e++){let n=t[e],c=o*n.x.length,l=s*n.y.length;for(let e=0;e<n.x.length&&n.x[e]<i;e++)c++;for(let e=0;e<n.y.length&&n.y[e]<a;e++)l++;c>0&&l>0&&r.push({width:c,height:l,index:e})}return r},e.getInterlaceIterator=function(e){return function(n,r,i){let a=n%t[i].x.length,o=(n-a)/t[i].x.length*8+t[i].x[a],s=r%t[i].y.length,c=(r-s)/t[i].y.length*8+t[i].y[s];return o*4+c*e*4}}})),RN=Oe(((e,t)=>{t.exports=function(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}})),zN=Oe(((e,t)=>{let n=LN(),r=RN();function i(e,t,n){let r=e*t;return n!==8&&(r=Math.ceil(r/(8/n))),r}let a=t.exports=function(e,t){let r=e.width,a=e.height,o=e.interlace,s=e.bpp,c=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],o){let e=n.getImagePasses(r,a);for(let t=0;t<e.length;t++)this._images.push({byteWidth:i(e[t].width,s,c),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:i(r,s,c),height:a,lineIndex:0});this._xComparison=c===8?s:c===16?s*2:1};a.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},a.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,i=r-1;for(let a=0;a<n;a++){let n=e[1+a],o=a>i?t[a-r]:0;t[a]=n+o}},a.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let i=0;i<n;i++){let n=e[1+i],a=r?r[i]:0;t[i]=n+a}},a.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,i=r-1,a=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],s=a?a[o]:0,c=o>i?t[o-r]:0,l=Math.floor((c+s)/2);t[o]=n+l}},a.prototype._unFilterType4=function(e,t,n){let i=this._xComparison,a=i-1,o=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],c=o?o[s]:0,l=s>a?t[s-i]:0,u=s>a&&o?o[s-i]:0,d=r(l,c,u);t[s]=n+d}},a.prototype._reverseFilterLine=function(e){let t=e[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(t===0)n=e.slice(1,i+1);else switch(n=Buffer.alloc(i),t){case 1:this._unFilterType1(e,n,i);break;case 2:this._unFilterType2(e,n,i);break;case 3:this._unFilterType3(e,n,i);break;case 4:this._unFilterType4(e,n,i);break;default:throw Error(`Unrecognised filter type - `+t)}this.write(n),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=n,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}})),CEe=Oe(((e,t)=>{let n=NN(),r=IN(),i=zN(),a=t.exports=function(e){r.call(this);let t=[],n=this;this._filter=new i(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit(`complete`,Buffer.concat(t))}}),this._filter.start()};n.inherits(a,r)})),BN=Oe(((e,t)=>{t.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}})),VN=Oe(((e,t)=>{let n=[];(function(){for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;n[e]=t}})();let r=t.exports=function(){this._crc=-1};r.prototype.write=function(e){for(let t=0;t<e.length;t++)this._crc=n[(this._crc^e[t])&255]^this._crc>>>8;return!0},r.prototype.crc32=function(){return this._crc^-1},r.crc32=function(e){let t=-1;for(let r=0;r<e.length;r++)t=n[(t^e[r])&255]^t>>>8;return t^-1}})),HN=Oe(((e,t)=>{let n=BN(),r=VN(),i=t.exports=function(e,t){this._options=e,e.checkCRC=e.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[n.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[n.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[n.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[n.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[n.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[n.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(n.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=n.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n]){this.error(Error(`Invalid file signature`));return}this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),i=e.readUInt32BE(4),a=``;for(let t=4;t<8;t++)a+=String.fromCharCode(e[t]);let o=!!(e[4]&32);if(!this._hasIHDR&&i!==n.TYPE_IHDR){this.error(Error(`Expected IHDR on beggining`));return}if(this._crc=new r,this._crc.write(Buffer.from(a)),this._chunks[i])return this._chunks[i](t);if(!o){this.error(Error(`Unsupported critical chunk type `+a));return}this.read(t+4,this._skipChunk.bind(this))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==t){this.error(Error(`Crc error - `+t+` - `+n));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),r=e.readUInt32BE(4),i=e[8],a=e[9],o=e[10],s=e[11],c=e[12];if(i!==8&&i!==4&&i!==2&&i!==1&&i!==16){this.error(Error(`Unsupported bit depth `+i));return}if(!(a in n.COLORTYPE_TO_BPP_MAP)){this.error(Error(`Unsupported color type`));return}if(o!==0){this.error(Error(`Unsupported compression method`));return}if(s!==0){this.error(Error(`Unsupported filter method`));return}if(c!==0&&c!==1){this.error(Error(`Unsupported interlace method`));return}this._colorType=a;let l=n.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:r,depth:i,interlace:!!c,palette:!!(a&n.COLORTYPE_PALETTE),color:!!(a&n.COLORTYPE_COLOR),alpha:!!(a&n.COLORTYPE_ALPHA),bpp:l,colorType:a}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[n*3],e[n*3+1],e[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===n.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error(`Transparency chunk must be after palette`));return}if(e.length>this._palette.length){this.error(Error(`More transparent colors than palette size`));return}for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===n.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===n.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/n.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===n.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error(`Expected palette not found`);this.inflateData(t);let r=e-t.length;r>0?this._handleIDAT(r):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}})),UN=Oe((e=>{let t=LN(),n=[function(){},function(e,t,n,r){if(r===t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],r=[function(){},function(e,t,n,r){let i=t[0];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];function i(e,t){let n=[],r=0;function i(){if(r===e.length)throw Error(`Ran out of data`);let i=e[r];r++;let a,o,s,c,l,u,d,f;switch(t){default:throw Error(`unrecognised depth`);case 16:d=e[r],r++,n.push((i<<8)+d);break;case 4:d=i&15,f=i>>4,n.push(f,d);break;case 2:l=i&3,u=i>>2&3,d=i>>4&3,f=i>>6&3,n.push(f,d,u,l);break;case 1:a=i&1,o=i>>1&1,s=i>>2&1,c=i>>3&1,l=i>>4&1,u=i>>5&1,d=i>>6&1,f=i>>7&1,n.push(f,d,u,l,c,s,o,a)}}return{get:function(e){for(;n.length<e;)i();let t=n.slice(0,e);return n=n.slice(e),t},resetAfterLine:function(){n.length=0},end:function(){if(r!==e.length)throw Error(`extra data found`)}}}function a(e,t,r,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++)for(let c=0;c<s;c++){let s=r(c,e,l);n[i](t,a,s,o),o+=i}return o}function o(e,t,n,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++){for(let c=0;c<s;c++){let s=a.get(i),u=n(c,e,l);r[i](t,s,u,o)}a.resetAfterLine()}}e.dataToBitMap=function(e,n){let r=n.width,s=n.height,c=n.depth,l=n.bpp,u=n.interlace,d;c!==8&&(d=i(e,c));let f;f=c<=8?Buffer.alloc(r*s*4):new Uint16Array(r*s*4);let p=2**c-1,m=0,h,g;if(u)h=t.getImagePasses(r,s),g=t.getInterlaceIterator(r,s);else{let e=0;g=function(){let t=e;return e+=4,t},h=[{width:r,height:s}]}for(let t=0;t<h.length;t++)c===8?m=a(h[t],f,g,l,e,m):o(h[t],f,g,l,d,p);if(c===8){if(m!==e.length)throw Error(`extra data found`)}else d.end();return f}})),WN=Oe(((e,t)=>{function n(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=i[e[a]];if(!n)throw Error(`index `+e[a]+` not in palette`);for(let e=0;e<4;e++)t[a+e]=n[e];a+=4}}function r(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=!1;if(i.length===1?i[0]===e[a]&&(n=!0):i[0]===e[a]&&i[1]===e[a+1]&&i[2]===e[a+2]&&(n=!0),n)for(let e=0;e<4;e++)t[a+e]=0;a+=4}}function i(e,t,n,r,i){let a=2**i-1,o=0;for(let i=0;i<r;i++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[o+n]=Math.floor(e[o+n]*255/a+.5);o+=4}}t.exports=function(e,t,a=!1){let o=t.depth,s=t.width,c=t.height,l=t.colorType,u=t.transColor,d=t.palette,f=e;return l===3?n(e,f,s,c,d):(u&&r(e,f,s,c,u),o!==8&&!a&&(o===16&&(f=Buffer.alloc(s*c*4)),i(e,f,s,c,o))),f}})),wEe=Oe(((e,t)=>{let n=NN(),r=FN(),i=IN(),a=CEe(),o=HN(),s=UN(),c=WN(),l=t.exports=function(e){i.call(this),this._parser=new o(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,`gamma`),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};n.inherits(l,i),l.prototype._handleError=function(e){this.emit(`error`,e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on(`error`,function(){})),this.errord=!0},l.prototype._inflateData=function(e){if(!this._inflate){if(this._bitmapInfo.interlace)this._inflate=r.createInflate(),this._inflate.on(`error`,this.emit.bind(this,`error`)),this._filter.on(`complete`,this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,r.Z_MIN_CHUNK);this._inflate=r.createInflate({chunkSize:t});let n=e,i=this.emit.bind(this,`error`);this._inflate.on(`error`,function(e){n&&i(e)}),this._filter.on(`complete`,this._complete.bind(this));let a=this._filter.write.bind(this._filter);this._inflate.on(`data`,function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,a(e))}),this._inflate.on(`end`,this._filter.end.bind(this._filter))}}this._inflate.write(e)},l.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new a(this._bitmapInfo)},l.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},l.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},l.prototype._simpleTransparency=function(){this._metaData.alpha=!0},l.prototype._headersFinished=function(){this.emit(`metadata`,this._metaData)},l.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit(`error`,`No Inflate block`))},l.prototype._complete=function(e){if(this.errord)return;let t;try{let n=s.dataToBitMap(e,this._bitmapInfo);t=c(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(e){this._handleError(e);return}this.emit(`parsed`,t)}})),TEe=Oe(((e,t)=>{let n=BN();t.exports=function(e,t,r,i){let a=[n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(i.colorType)!==-1;if(i.colorType===i.inputColorType){let t=(function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]!==256})();if(i.bitDepth===8||i.bitDepth===16&&t)return e}let o=i.bitDepth===16?new Uint16Array(e.buffer):e,s=255,c=n.COLORTYPE_TO_BPP_MAP[i.inputColorType];c===4&&!i.inputHasAlpha&&(c=3);let l=n.COLORTYPE_TO_BPP_MAP[i.colorType];i.bitDepth===16&&(s=65535,l*=2);let u=Buffer.alloc(t*r*l),d=0,f=0,p=i.bgColor||{};p.red===void 0&&(p.red=s),p.green===void 0&&(p.green=s),p.blue===void 0&&(p.blue=s);function m(){let e,t,r,c=s;switch(i.inputColorType){case n.COLORTYPE_COLOR_ALPHA:c=o[d+3],e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_COLOR:e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_ALPHA:c=o[d+1],e=o[d],t=e,r=e;break;case n.COLORTYPE_GRAYSCALE:e=o[d],t=e,r=e;break;default:throw Error(`input color type:`+i.inputColorType+` is not supported at present`)}return i.inputHasAlpha&&(a||(c/=s,e=Math.min(Math.max(Math.round((1-c)*p.red+c*e),0),s),t=Math.min(Math.max(Math.round((1-c)*p.green+c*t),0),s),r=Math.min(Math.max(Math.round((1-c)*p.blue+c*r),0),s))),{red:e,green:t,blue:r,alpha:c}}for(let e=0;e<r;e++)for(let e=0;e<t;e++){let e=m(o,d);switch(i.colorType){case n.COLORTYPE_COLOR_ALPHA:case n.COLORTYPE_COLOR:i.bitDepth===8?(u[f]=e.red,u[f+1]=e.green,u[f+2]=e.blue,a&&(u[f+3]=e.alpha)):(u.writeUInt16BE(e.red,f),u.writeUInt16BE(e.green,f+2),u.writeUInt16BE(e.blue,f+4),a&&u.writeUInt16BE(e.alpha,f+6));break;case n.COLORTYPE_ALPHA:case n.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;i.bitDepth===8?(u[f]=t,a&&(u[f+1]=e.alpha)):(u.writeUInt16BE(t,f),a&&u.writeUInt16BE(e.alpha,f+2));break}default:throw Error(`unrecognised color Type `+i.colorType)}d+=c,f+=l}return u}})),EEe=Oe(((e,t)=>{let n=RN();function r(e,t,n,r,i){for(let a=0;a<n;a++)r[i+a]=e[t+a]}function i(e,t,n){let r=0,i=t+n;for(let n=t;n<i;n++)r+=Math.abs(e[n]);return r}function a(e,t,n,r,i,a){for(let o=0;o<n;o++){let n=o>=a?e[t+o-a]:0,s=e[t+o]-n;r[i+o]=s}}function o(e,t,n,r){let i=0;for(let a=0;a<n;a++){let n=a>=r?e[t+a-r]:0,o=e[t+a]-n;i+=Math.abs(o)}return i}function s(e,t,n,r,i){for(let a=0;a<n;a++){let o=t>0?e[t+a-n]:0,s=e[t+a]-o;r[i+a]=s}}function c(e,t,n){let r=0,i=t+n;for(let a=t;a<i;a++){let i=t>0?e[a-n]:0,o=e[a]-i;r+=Math.abs(o)}return r}function l(e,t,n,r,i,a){for(let o=0;o<n;o++){let s=o>=a?e[t+o-a]:0,c=t>0?e[t+o-n]:0,l=e[t+o]-(s+c>>1);r[i+o]=l}}function u(e,t,n,r){let i=0;for(let a=0;a<n;a++){let o=a>=r?e[t+a-r]:0,s=t>0?e[t+a-n]:0,c=e[t+a]-(o+s>>1);i+=Math.abs(c)}return i}function d(e,t,r,i,a,o){for(let s=0;s<r;s++){let c=s>=o?e[t+s-o]:0,l=t>0?e[t+s-r]:0,u=t>0&&s>=o?e[t+s-(r+o)]:0,d=e[t+s]-n(c,l,u);i[a+s]=d}}function f(e,t,r,i){let a=0;for(let o=0;o<r;o++){let s=o>=i?e[t+o-i]:0,c=t>0?e[t+o-r]:0,l=t>0&&o>=i?e[t+o-(r+i)]:0,u=e[t+o]-n(s,c,l);a+=Math.abs(u)}return a}let p={0:r,1:a,2:s,3:l,4:d},m={0:i,1:o,2:c,3:u,4:f};t.exports=function(e,t,n,r,i){let a;if(!(`filterType`in r)||r.filterType===-1)a=[0,1,2,3,4];else if(typeof r.filterType==`number`)a=[r.filterType];else throw Error(`unrecognised filter types`);r.bitDepth===16&&(i*=2);let o=t*i,s=0,c=0,l=Buffer.alloc((o+1)*n),u=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=m[a[n]](e,c,o,i);r<t&&(u=a[n],t=r)}}l[s]=u,s++,p[u](e,c,o,l,s,i),s+=o,c+=o}return l}})),GN=Oe(((e,t)=>{let n=BN(),r=VN(),i=TEe(),a=EEe(),o=FN(),s=t.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=e.deflateLevel==null?9:e.deflateLevel,e.deflateStrategy=e.deflateStrategy==null?3:e.deflateStrategy,e.inputHasAlpha=e.inputHasAlpha==null||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||o.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType=typeof e.colorType==`number`?e.colorType:n.COLORTYPE_COLOR_ALPHA,e.inputColorType=typeof e.inputColorType==`number`?e.inputColorType:n.COLORTYPE_COLOR_ALPHA,[n.COLORTYPE_GRAYSCALE,n.COLORTYPE_COLOR,n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(e.colorType)===-1)throw Error(`option color type:`+e.colorType+` is not supported at present`);if([n.COLORTYPE_GRAYSCALE,n.COLORTYPE_COLOR,n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(e.inputColorType)===-1)throw Error(`option input color type:`+e.inputColorType+` is not supported at present`);if(e.bitDepth!==8&&e.bitDepth!==16)throw Error(`option bit depth:`+e.bitDepth+` is not supported at present`)};s.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},s.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},s.prototype.filterData=function(e,t,r){let o=i(e,t,r,this._options),s=n.COLORTYPE_TO_BPP_MAP[this._options.colorType];return a(o,t,r,this._options,s)},s.prototype._packChunk=function(e,t){let n=t?t.length:0,i=Buffer.alloc(n+12);return i.writeUInt32BE(n,0),i.writeUInt32BE(e,4),t&&t.copy(i,8),i.writeInt32BE(r.crc32(i.slice(4,i.length-4)),i.length-4),i},s.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*n.GAMMA_DIVISION),0),this._packChunk(n.TYPE_gAMA,t)},s.prototype.packIHDR=function(e,t){let r=Buffer.alloc(13);return r.writeUInt32BE(e,0),r.writeUInt32BE(t,4),r[8]=this._options.bitDepth,r[9]=this._options.colorType,r[10]=0,r[11]=0,r[12]=0,this._packChunk(n.TYPE_IHDR,r)},s.prototype.packIDAT=function(e){return this._packChunk(n.TYPE_IDAT,e)},s.prototype.packIEND=function(){return this._packChunk(n.TYPE_IEND,null)}})),DEe=Oe(((e,t)=>{let n=NN(),r=PN(),i=BN(),a=GN(),o=t.exports=function(e){r.call(this);let t=e||{};this._packer=new a(t),this._deflate=this._packer.createDeflate(),this.readable=!0};n.inherits(o,r),o.prototype.pack=function(e,t,n,r){this.emit(`data`,Buffer.from(i.PNG_SIGNATURE)),this.emit(`data`,this._packer.packIHDR(t,n)),r&&this.emit(`data`,this._packer.packGAMA(r));let a=this._packer.filterData(e,t,n);this._deflate.on(`error`,this.emit.bind(this,`error`)),this._deflate.on(`data`,function(e){this.emit(`data`,this._packer.packIDAT(e))}.bind(this)),this._deflate.on(`end`,function(){this.emit(`data`,this._packer.packIEND()),this.emit(`end`)}.bind(this)),this._deflate.end(a)}})),OEe=Oe(((e,t)=>{t.exports=iee.default})),kEe=Oe(((e,t)=>{t.exports=aee.default})),AEe=Oe(((e,t)=>{let n=OEe().ok,r=FN(),i=NN(),a=kEe().kMaxLength;function o(e){if(!(this instanceof o))return new o(e);e&&e.chunkSize<r.Z_MIN_CHUNK&&(e.chunkSize=r.Z_MIN_CHUNK),r.Inflate.call(this,e),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&e.maxLength!=null&&(this._maxLength=e.maxLength)}function s(e){return new o(e)}function c(e,t){t&&process.nextTick(t),e._handle&&=(e._handle.close(),null)}o.prototype._processChunk=function(e,t,i){if(typeof i==`function`)return r.Inflate._processChunk.call(this,e,t,i);let o=this,s=e&&e.length,l=this._chunkSize-this._offset,u=this._maxLength,d=0,f=[],p=0,m;this.on(`error`,function(e){m=e});function h(e,t){if(o._hadError)return;let r=l-t;if(n(r>=0,`have should not go down`),r>0){let e=o._buffer.slice(o._offset,o._offset+r);if(o._offset+=r,e.length>u&&(e=e.slice(0,u)),f.push(e),p+=e.length,u-=e.length,u===0)return!1}return(t===0||o._offset>=o._chunkSize)&&(l=o._chunkSize,o._offset=0,o._buffer=Buffer.allocUnsafe(o._chunkSize)),t===0&&(d+=s-e,s=e,!0)}n(this._handle,`zlib binding closed`);let g;do g=this._handle.writeSync(t,e,d,s,this._buffer,this._offset,l),g||=this._writeState;while(!this._hadError&&h(g[0],g[1]));if(this._hadError)throw m;if(p>=a)throw c(this),RangeError(`Cannot create final Buffer. It would be larger than 0x`+a.toString(16)+` bytes`);let _=Buffer.concat(f,p);return c(this),_},i.inherits(o,r.Inflate);function l(e,t){if(typeof t==`string`&&(t=Buffer.from(t)),!(t instanceof Buffer))throw TypeError(`Not a string or buffer`);let n=e._finishFlushFlag;return n??=r.Z_FINISH,e._processChunk(t,n)}function u(e,t){return l(new o(t),e)}t.exports=e=u,e.Inflate=o,e.createInflate=s,e.inflateSync=u})),KN=Oe(((e,t)=>{let n=t.exports=function(e){this._buffer=e,this._reads=[]};n.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},n.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}if(this._reads.length>0)throw Error(`There are some read requests waitng on finished stream`);if(this._buffer.length>0)throw Error(`unrecognised content at end of stream`)}})),jEe=Oe((e=>{let t=KN(),n=zN();e.process=function(e,r){let i=[],a=new t(e);return new n(r,{read:a.read.bind(a),write:function(e){i.push(e)},complete:function(){}}).start(),a.process(),Buffer.concat(i)}})),MEe=Oe(((e,t)=>{let n=!0,r=FN(),i=AEe();r.deflateSync||(n=!1);let a=KN(),o=jEe(),s=HN(),c=UN(),l=WN();t.exports=function(e,t){if(!n)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let u;function d(e){u=e}let f;function p(e){f=e}function m(e){f.transColor=e}function h(e){f.palette=e}function g(){f.alpha=!0}let _;function v(e){_=e}let y=[];function b(e){y.push(e)}let ee=new a(e);if(new s(t,{read:ee.read.bind(ee),error:d,metadata:p,gamma:v,palette:h,transColor:m,inflateData:b,simpleTransparency:g}).start(),ee.process(),u)throw u;let x=Buffer.concat(y);y.length=0;let te;if(f.interlace)te=r.inflateSync(x);else{let e=((f.width*f.bpp*f.depth+7>>3)+1)*f.height;te=i(x,{chunkSize:e,maxLength:e})}if(x=null,!te||!te.length)throw Error(`bad png - invalid inflate data response`);let ne=o.process(te,f);x=null;let re=c.dataToBitMap(ne,f);ne=null;let ie=l(re,f,t.skipRescale);return f.data=ie,f.gamma=_||0,f}})),NEe=Oe(((e,t)=>{let n=!0,r=FN();r.deflateSync||(n=!1);let i=BN(),a=GN();t.exports=function(e,t){if(!n)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let o=new a(t||{}),s=[];s.push(Buffer.from(i.PNG_SIGNATURE)),s.push(o.packIHDR(e.width,e.height)),e.gamma&&s.push(o.packGAMA(e.gamma));let c=o.filterData(e.data,e.width,e.height),l=r.deflateSync(c,o.getDeflateOptions());if(c=null,!l||!l.length)throw Error(`bad png - invalid compressed data response`);return s.push(o.packIDAT(l)),s.push(o.packIEND()),Buffer.concat(s)}})),PEe=Oe((e=>{let t=MEe(),n=NEe();e.read=function(e,n){return t(e,n||{})},e.write=function(e,t){return n(e,t)}})),qN=Oe((e=>{let t=NN(),n=PN(),r=wEe(),i=DEe(),a=PEe(),o=e.PNG=function(e){n.call(this),e||={},this.width=e.width|0,this.height=e.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new r(e),this._parser.on(`error`,this.emit.bind(this,`error`)),this._parser.on(`close`,this._handleClose.bind(this)),this._parser.on(`metadata`,this._metadata.bind(this)),this._parser.on(`gamma`,this._gamma.bind(this)),this._parser.on(`parsed`,function(e){this.data=e,this.emit(`parsed`,e)}.bind(this)),this._packer=new i(e),this._packer.on(`data`,this.emit.bind(this,`data`)),this._packer.on(`end`,this.emit.bind(this,`end`)),this._parser.on(`close`,this._handleClose.bind(this)),this._packer.on(`error`,this.emit.bind(this,`error`))};t.inherits(o,n),o.sync=a,o.prototype.pack=function(){return!this.data||!this.data.length?(this.emit(`error`,`No data provided`),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)},o.prototype.parse=function(e,t){if(t){let e,n;e=function(e){this.removeListener(`error`,n),this.data=e,t(null,this)}.bind(this),n=function(n){this.removeListener(`parsed`,e),t(n,null)}.bind(this),this.once(`parsed`,e),this.once(`error`,n)}return this.end(e),this},o.prototype.write=function(e){return this._parser.write(e),!0},o.prototype.end=function(e){this._parser.end(e)},o.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit(`metadata`,e)},o.prototype._gamma=function(e){this.gamma=e},o.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit(`close`)},o.bitblt=function(e,t,n,r,i,a,o,s){if(n|=0,r|=0,i|=0,a|=0,o|=0,s|=0,n>e.width||r>e.height||n+i>e.width||r+a>e.height)throw Error(`bitblt reading outside image`);if(o>t.width||s>t.height||o+i>t.width||s+a>t.height)throw Error(`bitblt writing outside image`);for(let c=0;c<a;c++)e.data.copy(t.data,(s+c)*t.width+o<<2,(r+c)*e.width+n<<2,(r+c)*e.width+n+i<<2)},o.prototype.bitblt=function(e,t,n,r,i,a,s){return o.bitblt(this,e,t,n,r,i,a,s),this},o.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n**=1/2.2/e.gamma,e.data[r+t]=Math.round(n*255)}}e.gamma=0}},o.prototype.adjustGamma=function(){o.adjustGamma(this)}}))();const JN=Uint8Array.of(137,80,78,71,13,10,26,10),FEe=(e,t)=>{switch(e){case 0:return t===16?`I;16`:`L`;case 2:return`RGB`;case 3:return`P`;case 4:return`LA`;case 6:return`RGBA`;default:return`color-type-${e}`}},YN=(e,t)=>(e[t]??0)*16777216+((e[t+1]??0)<<16)+((e[t+2]??0)<<8)+(e[t+3]??0)>>>0,IEe=(e,t)=>String.fromCharCode(...e.subarray(t,t+4)),LEe=e=>e>=65&&e<=90||e>=97&&e<=122,REe=[[0,0,8,8],[4,0,8,8],[0,4,4,8],[2,0,4,4],[0,2,2,4],[1,0,2,2],[0,1,1,2]],zEe=(e,t)=>{let n=(e,n)=>n>0?e*(1+n*t):0;return e.interlace===0?n(e.height,e.width):REe.reduce((t,[r,i,a,o])=>t+n(Math.ceil(Math.max(0,e.height-i)/o),Math.ceil(Math.max(0,e.width-r)/a)),0)},BEe=(e,t)=>{try{return nee(Buffer.concat(e),{maxOutputLength:t+1}).length===t}catch{return!1}},XN=e=>{if(e.length<JN.length||JN.some((t,n)=>e[n]!==t))return{ok:!1,reason:`invalid_png`};let t=JN.length,n,r=!1,i=!1,a=!1,o=!1,s=!1,c=[];for(;t<e.length;){if(s||e.length-t<12)return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let l=YN(e,t),u=t+4,d=IEe(e,u),f=e.subarray(u,u+4);if(l>2147483647||!f.every(LEe))return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let p=u+4+l;if(p+4>e.length)return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let m=YN(e,p);if(tee(e.subarray(u,p))>>>0!==m)return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let h=e.subarray(u+4,p);if(n===void 0){if(d!==`IHDR`||l!==13)return{ok:!1,reason:`invalid_png`};if(n={width:YN(h,0),height:YN(h,4),bitDepth:h[8]??0,colorType:h[9]??0,interlace:h[12]??0,mode:FEe(h[9]??0,h[8]??0)},n.width===0||n.height===0||h[10]!==0||h[11]!==0||n.interlace!==0&&n.interlace!==1)return{ok:!1,reason:`invalid_png`,header:n}}else if(d===`IHDR`)return{ok:!1,reason:`invalid_png`,header:n};else if(d===`IDAT`){if(a)return{ok:!1,reason:`invalid_png`,header:n};r=!0,c.push(h)}else if(d===`PLTE`){if(r||i||l===0||l%3!=0||l>768)return{ok:!1,reason:`invalid_png`,header:n};i=!0}else if(r&&(a=!0),d===`acTL`)o=!0;else if(d===`IEND`){if(l!==0||!r)return{ok:!1,reason:`invalid_png`,header:n};s=!0}else if((f[0]??0)<=90)return{ok:!1,reason:`invalid_png`,header:n};t=p+4}return!s||n===void 0?{ok:!1,reason:`invalid_png`,...n?{header:n}:{}}:o?{ok:!1,reason:`multiple_frames`,header:n}:n.bitDepth!==8||n.colorType!==2&&n.colorType!==6?{ok:!1,reason:`unsupported_sample_format`,header:n}:BEe(c,zEe(n,n.colorType===6?4:3))?{ok:!0,header:n}:{ok:!1,reason:`invalid_png`,header:n}},ZN=e=>{let t=qN.PNG.sync.read(Buffer.from(e.buffer,e.byteOffset,e.byteLength),{checkCRC:!0});return{width:t.width,height:t.height,data:new Uint8Array(t.data)}},VEe=e=>{let t=new qN.PNG({width:e.width,height:e.height});return t.data=Buffer.from(e.data),new Uint8Array(qN.PNG.sync.write(t,{colorType:6,inputHasAlpha:!0}))},QN=(e,t)=>{let n=t.right-t.left,r=t.bottom-t.top,i=new Uint8Array(n*r*4);for(let a=0;a<r;a++){let r=((t.top+a)*e.width+t.left)*4;i.set(e.data.subarray(r,r+n*4),a*n*4)}return{width:n,height:r,data:i}},HEe=(e,t)=>{let n=new Set;for(let r=0;r<e.data.length&&(n.add(((e.data[r]??0)<<24)+((e.data[r+1]??0)<<16)+((e.data[r+2]??0)<<8)+(e.data[r+3]??0)),!(n.size>=t));r+=4);return n.size},$N=e=>{if(!(e instanceof Error))return{name:void 0,code:void 0,errno:void 0};let t=`code`in e&&typeof e.code==`string`?e.code:void 0,n=`errno`in e&&typeof e.errno==`number`?e.errno:void 0;return{name:e.name,code:t,errno:n}};var eP=class extends Error{reason;subject;errorType;errno;constructor(e,t,n){super(e),this.reason=e,this.subject=t;let r=$N(n);this.errorType=n===void 0?void 0:r.code??r.name,this.errno=r.errno}};const tP=e=>y(`sha256`).update(e).digest(`hex`),nP=async(e,t,n)=>{n.path=e;let r;try{if(!(await xe(e)).isFile())throw new eP(`missing_or_non_file`,t);r=await ye(e)}catch(e){if(e instanceof eP)throw e;let{code:n}=$N(e);throw n===`ENOENT`||n===`ENOTDIR`?new eP(`missing_or_non_file`,t,e):new eP(`unreadable_file`,t,e)}n.file_bytes=r.length,n.file_sha256=tP(r);let i=XN(r);if(i.header!==void 0||i.ok){let e=(i.ok,i.header);e!==void 0&&(n.width=e.width,n.height=e.height,n.mode=e.mode,n.bit_depth=e.bitDepth)}if(!i.ok)throw new eP(i.reason,t);let a;try{a=ZN(r)}catch{throw new eP(`invalid_png`,t)}return n.rgba_sha256=tP(a.data),a},UEe=(e,t,n,r,i)=>{let[a=0,o=0,s=0,c=0]=t;if(!(a>=0&&a<s&&o>=0&&o<c))throw new eP(`invalid_content_box`);if(s>r||c>i)throw new eP(`content_box_out_of_bounds`);if(n.some(e=>e<0))throw new eP(`invalid_min_margins`);let[l=0,u=0,d=0,f=0]=e,p={top:n[0]??0,right:n[1]??0,bottom:n[2]??0,left:n[3]??0},m={top:o-u,right:d-s,bottom:f-c,left:a-l};return{source:`caller_supplied`,box:[...t],minimum_margins:p,observed_margins:m,content_contained:Object.values(m).every(e=>e>=0),margins_satisfied:m.top>=p.top&&m.right>=p.right&&m.bottom>=p.bottom&&m.left>=p.left}},WEe={"--raw":{arity:1,required:!0},"--crop":{arity:1,required:!0},"--box":{arity:4,required:!0},"--content-box":{arity:4},"--min-margins":{arity:4}},rP=e=>{if(e===void 0)return;let t=e.map(SEe);if(t.some(e=>e===void 0))throw new eP(`invalid_arguments`);return t.filter(e=>e!==void 0)},iP=e=>TO(async()=>{let t={status:`uncheckable`,reason:null,box:null,comparison_mode:`RGBA8`,decoder:`pngjs@7.0.0`,raw:{},crop:{},expected:{},dimensions_equal:null,pixels_equal:null},n={},r={};t.raw=n,t.crop=r;try{let i=jN(e,WEe);if(!i.ok)throw new eP(`invalid_arguments`);let a=rP(i.values[`--box`])??[],o=rP(i.values[`--content-box`]),s=rP(i.values[`--min-margins`]);if(t.box=[...a],o===void 0!=(s===void 0))throw new eP(`incomplete_content_bounds_arguments`);let[c=0,l=0,u=0,d=0]=a;if(!(c>=0&&c<u&&l>=0&&l<d))throw new eP(`invalid_box`);let f=await nP(i.values[`--raw`]?.[0]??``,`raw`,n);if(u>f.width||d>f.height)throw new eP(`box_out_of_bounds`);let p;o!==void 0&&s!==void 0&&(p=UEe(a,o,s,f.width,f.height),t.content_bounds=p);let m=await nP(i.values[`--crop`]?.[0]??``,`crop`,r),h=QN(f,{left:c,top:l,right:u,bottom:d});t.expected={width:h.width,height:h.height,rgba_sha256:tP(h.data)};let g=m.width===h.width&&m.height===h.height;if(t.dimensions_equal=g,!g)return{report:{...t,status:`mismatch`,reason:`dimensions_differ`},exitCode:1};let _=Buffer.compare(Buffer.from(m.data),Buffer.from(h.data))===0;return t.pixels_equal=_,_?p!==void 0&&p.content_contained!==!0?{report:{...t,status:`mismatch`,reason:`content_cut`},exitCode:1}:p!==void 0&&p.margins_satisfied!==!0?{report:{...t,status:`mismatch`,reason:`content_margins_insufficient`},exitCode:1}:{report:{...t,status:`exact`,reason:`pixels_equal`},exitCode:0}:{report:{...t,status:`mismatch`,reason:`pixels_differ`},exitCode:1}}catch(e){if(!(e instanceof eP))throw e;let n={...t,reason:e.reason};return e.subject!==void 0&&(n.subject=e.subject),e.errorType!==void 0&&(n.error_type=e.errorType),e.errno!==void 0&&(n.errno=e.errno),{report:n,exitCode:2}}}),GEe=e=>JSON.stringify(aP(e)),aP=e=>{if(Array.isArray(e))return e.map(aP);if(typeof e==`object`&&e){let t=Object.entries(e).toSorted(([e],[t])=>e<t?-1:1);return Object.fromEntries(t.map(([e,t])=>[e,aP(t)]))}return e},oP=e=>y(`sha256`).update(e).digest(`hex`),sP=e=>MO(function*(){let t=yield*TO(async()=>{try{return(await _e(l(e))).isDirectory()}catch{return!1}});if(!u(e)||!e.toLowerCase().endsWith(`.png`)||!t||(yield*TM(e))||(yield*TM(`${e}.json`)))return yield*z(`capture requires a fresh absolute .png path with an existing parent`)}),KEe=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.viewable===t.viewable,qEe=e=>MO(function*(){if(yield*sP(e.output),e.window!==void 0&&(yield*sP(e.window.output),e.window.output===e.output))return yield*z(`window output must differ from the raw output`);let t=yield*lM,{session:n,observation:r,deadline:i}=yield*yN(e.stateDir,e.timeout),a=(t,r)=>MO(function*(){let a=yield*pEe(e.stateDir,n,t,r,i);if(a.length>0)return yield*z(`window is covered by ${a.join(`, `)}`)}),o=e.window===void 0?void 0:yield*SN(e.stateDir,n,e.window.id,i);e.window!==void 0&&o!==void 0&&(yield*a(e.window.id,o));let s=d(n.guest_dir,`captures`,`${b()}.png`),c=yield*MM,l=yield*NM,u=yield*gCe(MO(function*(){return yield*aN(e.stateDir,n,`scrot`,[s],i,fN(n),e.timeout).pipe(HO(`Unavailable`,e=>NO(new _M({reason:e.reason.replace(/^scrot read/u,`scrot`),...e.nativeExit===void 0?{}:{nativeExit:e.nativeExit}})))),yield*t.readFile(s,yield*FM(i,e.timeout)).pipe(WO(e=>new _M({reason:`capture could not be read back: ${e.message}`})))}),zTe(s,n.probe_timeout_s*1e3).pipe(GO)),f=XN(u);if(!f.ok&&f.reason===`invalid_png`)return yield*z(`scrot did not produce a PNG screen capture`);let p=(f.ok,f.header);if(p===void 0||p.width!==r.dimensions[0]||p.height!==r.dimensions[1])return yield*z(`raw capture dimensions differ from the inspected display`);let m=yield*yN(e.stateDir,Math.max(.001,(i.endMs-(yield*NM))/1e3));if(m.session.run_id!==n.run_id||JSON.stringify(m.observation)!==JSON.stringify(r))return yield*z(`session or window manager changed during capture`);let h;if(e.window!==void 0&&o!==void 0){if(h=yield*SN(e.stateDir,n,e.window.id,i),!KEe(o,h))return yield*z(`window moved or changed during capture`);yield*a(e.window.id,h)}let g={run_id:n.run_id,output:e.output,bytes:u.length,sha256:oP(u),dimensions:[p.width,p.height],capture_started_at:c,capture_completed_at:yield*MM,capture_ms:(yield*NM)-l,window_manager:m.observation.window_manager??null,transformations:[]},_=h===void 0?void 0:{left:h.x,top:h.y,right:h.x+h.width,bottom:h.y+h.height};if(h!==void 0&&_!==void 0){if(!h.viewable)return yield*z(`window is not viewable`);if(_.left<0||_.top<0||_.right>p.width||_.bottom>p.height||_.left>=_.right||_.top>=_.bottom)return yield*z(`window is not entirely on the screen`);if(!f.ok)return yield*z(`raw capture is not an 8-bit RGB or RGBA PNG: ${f.reason}`)}if(yield*OM(e.output,u),yield*kM(`${e.output}.json`,g),e.window===void 0||_===void 0||!f.ok)return g;let v=QN(ZN(u),_),y=VEe(v);yield*OM(e.window.output,y);let ee=yield*iP([`--raw`,e.output,`--crop`,e.window.output,`--box`,String(_.left),String(_.top),String(_.right),String(_.bottom)]),x={run_id:n.run_id,window:e.window.id,raw:e.output,output:e.window.output,box:[_.left,_.top,_.right,_.bottom],bytes:y.length,sha256:oP(y),distinct_colors:HEe(v,4096),exact_crop:ee.report};return yield*kM(`${e.window.output}.json`,x),ee.exitCode===0?{...g,window:x}:yield*z(`window crop did not verify as an exact crop of the raw capture`)}),JEe=/\{[^{}]+\}/g,YEe=()=>typeof process==`object`&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function XEe(){return Math.random().toString(36).slice(2,11)}function cP(e){let{baseUrl:t=``,Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:i,bodySerializer:a,pathSerializer:o,headers:s,requestInitExt:c=void 0,...l}={...e};c=YEe()?c:void 0,t=mP(t);let u=[];async function d(e,d){let{baseUrl:f,fetch:p=r,Request:m=n,headers:h,params:g={},parseAs:_=`json`,querySerializer:v,bodySerializer:y=a??QEe,pathSerializer:b,body:ee,middleware:x=[],...te}=d||{},ne=t;f&&(ne=mP(f)??t);let re=typeof i==`function`?i:fP(i);v&&(re=typeof v==`function`?v:fP({...typeof i==`object`?i:{},...v}));let ie=b||o||ZEe,ae=ee===void 0?void 0:y(ee,pP(s,h,g.header)),S=pP(ae===void 0||ae instanceof FormData?{}:{"Content-Type":`application/json`},s,h,g.header),oe=[...u,...x],C={redirect:`follow`,...l,...te,body:ae,headers:S},se,ce,le=new m($Ee(e,{baseUrl:ne,params:g,querySerializer:re,pathSerializer:ie}),C),ue;for(let e in te)e in le||(le[e]=te[e]);if(oe.length){se=XEe(),ce=Object.freeze({baseUrl:ne,fetch:p,parseAs:_,querySerializer:re,bodySerializer:y,pathSerializer:ie});for(let t of oe)if(t&&typeof t==`object`&&typeof t.onRequest==`function`){let n=await t.onRequest({request:le,schemaPath:e,params:g,options:ce,id:se});if(n){if(n instanceof m)le=n;else if(n instanceof Response){ue=n;break}else throw Error(`onRequest: must return new Request() or Response() when modifying the request`)}}}if(!ue){try{ue=await p(le,c)}catch(t){let n=t;if(oe.length)for(let t=oe.length-1;t>=0;t--){let r=oe[t];if(r&&typeof r==`object`&&typeof r.onError==`function`){let t=await r.onError({request:le,error:n,schemaPath:e,params:g,options:ce,id:se});if(t){if(t instanceof Response){n=void 0,ue=t;break}if(t instanceof Error){n=t;continue}throw Error(`onError: must return new Response() or instance of Error`)}}}if(n)throw n}if(oe.length)for(let t=oe.length-1;t>=0;t--){let n=oe[t];if(n&&typeof n==`object`&&typeof n.onResponse==`function`){let t=await n.onResponse({request:le,response:ue,schemaPath:e,params:g,options:ce,id:se});if(t){if(!(t instanceof Response))throw Error(`onResponse: must return new Response() when modifying the response`);ue=t}}}}let w=ue.headers.get(`Content-Length`);if(ue.status===204||le.method===`HEAD`||w===`0`&&!ue.headers.get(`Transfer-Encoding`)?.includes(`chunked`))return ue.ok?{data:void 0,response:ue}:{error:void 0,response:ue};if(ue.ok)return{data:await(async()=>{if(_===`stream`)return ue.body;if(_===`json`&&!w){let e=await ue.text();return e?JSON.parse(e):void 0}return await ue[_]()})(),response:ue};let de=await ue.text();try{de=JSON.parse(de)}catch{}return{error:de,response:ue}}return{request(e,t,n){return d(t,{...n,method:e.toUpperCase()})},GET(e,t){return d(e,{...t,method:`GET`})},PUT(e,t){return d(e,{...t,method:`PUT`})},POST(e,t){return d(e,{...t,method:`POST`})},DELETE(e,t){return d(e,{...t,method:`DELETE`})},OPTIONS(e,t){return d(e,{...t,method:`OPTIONS`})},HEAD(e,t){return d(e,{...t,method:`HEAD`})},PATCH(e,t){return d(e,{...t,method:`PATCH`})},TRACE(e,t){return d(e,{...t,method:`TRACE`})},use(...e){for(let t of e)if(t){if(typeof t!=`object`||!(`onRequest`in t||`onResponse`in t||`onError`in t))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");u.push(t)}},eject(...e){for(let t of e){let e=u.indexOf(t);e!==-1&&u.splice(e,1)}}}}function lP(e,t,n){if(t==null)return``;if(typeof t==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?.allowReserved===!0?t:encodeURIComponent(t)}`}function uP(e,t,n){if(!t||typeof t!=`object`)return``;let r=[],i={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`;if(n.style!==`deepObject`&&n.explode===!1){for(let e in t)r.push(e,n.allowReserved===!0?t[e]:encodeURIComponent(t[e]));let i=r.join(`,`);switch(n.style){case`form`:return`${e}=${i}`;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return i}}for(let i in t){let a=n.style===`deepObject`?`${e}[${i}]`:i;r.push(lP(a,t[i],n))}let a=r.join(i);return n.style===`label`||n.style===`matrix`?`${i}${a}`:a}function dP(e,t,n){if(!Array.isArray(t))return``;if(n.explode===!1){let r={form:`,`,spaceDelimited:`%20`,pipeDelimited:`|`}[n.style]||`,`,i=(n.allowReserved===!0?t:t.map(e=>encodeURIComponent(e))).join(r);switch(n.style){case`simple`:return i;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return`${e}=${i}`}}let r={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`,i=[];for(let r of t)n.style===`simple`||n.style===`label`?i.push(n.allowReserved===!0?r:encodeURIComponent(r)):i.push(lP(e,r,n));return n.style===`label`||n.style===`matrix`?`${r}${i.join(r)}`:i.join(r)}function fP(e){return function(t){let n=[];if(t&&typeof t==`object`)for(let r in t){let i=t[r];if(i!=null){if(Array.isArray(i)){if(i.length===0)continue;n.push(dP(r,i,{style:`form`,explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}));continue}if(typeof i==`object`){n.push(uP(r,i,{style:`deepObject`,explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}));continue}n.push(lP(r,i,e))}}return n.join(`&`)}}function ZEe(e,t){let n=e;for(let r of e.match(JEe)??[]){let e=r.substring(1,r.length-1),i=!1,a=`simple`;if(e.endsWith(`*`)&&(i=!0,e=e.substring(0,e.length-1)),e.startsWith(`.`)?(a=`label`,e=e.substring(1)):e.startsWith(`;`)&&(a=`matrix`,e=e.substring(1)),!t||t[e]===void 0||t[e]===null)continue;let o=t[e];if(Array.isArray(o)){n=n.replace(r,dP(e,o,{style:a,explode:i}));continue}if(typeof o==`object`){n=n.replace(r,uP(e,o,{style:a,explode:i}));continue}if(a===`matrix`){n=n.replace(r,`;${lP(e,o)}`);continue}n=n.replace(r,a===`label`?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return n}function QEe(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get(`Content-Type`)??t.get(`content-type`):t[`Content-Type`]??t[`content-type`])===`application/x-www-form-urlencoded`?new URLSearchParams(e).toString():JSON.stringify(e)}function $Ee(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=t.pathSerializer(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith(`?`)&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function pP(...e){let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,r)}return t}function mP(e){return e.endsWith(`/`)?e.substring(0,e.length-1):e}var eDe=Oe(((e,t)=>{(function(){var n={function:!0,object:!0},r=n[typeof window]&&window||this,i=n[typeof e]&&e,a=n[typeof t]&&t&&!t.nodeType&&t,o=i&&a&&typeof global==`object`&&global;o&&(o.global===o||o.window===o||o.self===o)&&(r=o);var s=2**53-1,c=/\bOpera/,l=Object.prototype,u=l.hasOwnProperty,d=l.toString;function f(e){return e=String(e),e.charAt(0).toUpperCase()+e.slice(1)}function p(e,t,n){var r={"10.0":`10`,"6.4":`10 Technical Preview`,"6.3":`8.1`,"6.2":`8`,"6.1":`Server 2008 R2 / 7`,"6.0":`Server 2008 / Vista`,"5.2":`Server 2003 / XP 64-bit`,"5.1":`XP`,"5.01":`2000 SP1`,"5.0":`2000`,"4.0":`NT`,"4.90":`ME`};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e=`Windows `+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,`i`),n)),e=h(e.replace(/ ce$/i,` CE`).replace(/\bhpw/i,`web`).replace(/\bMacintosh\b/,`Mac OS`).replace(/_PowerPC\b/i,` OS`).replace(/\b(OS X) [^ \d]+/i,`$1`).replace(/\bMac (OS X)\b/,`$1`).replace(/\/(\d)/,` $1`).replace(/_/g,`.`).replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,``).replace(/\bx86\.64\b/gi,`x86_64`).replace(/\b(Windows Phone) OS\b/,`$1`).replace(/\b(Chrome OS \w+) [\d.]+\b/,`$1`).split(` on `)[0]),e}function m(e,t){var n=-1,r=e?e.length:0;if(typeof r==`number`&&r>-1&&r<=s)for(;++n<r;)t(e[n],n,e);else g(e,t)}function h(e){return e=ee(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:f(e)}function g(e,t){for(var n in e)u.call(e,n)&&t(e[n],n,e)}function _(e){return e==null?f(e):d.call(e).slice(8,-1)}function v(e,t){var n=e==null?`number`:typeof e[t];return!/^(?:boolean|number|string|undefined)$/.test(n)&&(n!=`object`||!!e[t])}function y(e){return String(e).replace(/([ -])(?!$)/g,`$1?`)}function b(e,t){var n=null;return m(e,function(r,i){n=t(n,r,i,e)}),n}function ee(e){return String(e).replace(/^ +| +$/g,``)}function x(e){var t=r,n=e&&typeof e==`object`&&_(e)!=`String`;n&&(t=e,e=null);var i=t.navigator||{},a=i.userAgent||``;e||=a;var o=n?!!i.likeChrome:/\bChrome\b/.test(e)&&!/internal|\n/i.test(d.toString()),s=`Object`,l=n?s:`ScriptBridgingProxyObject`,u=n?s:`Environment`,f=n&&t.java?`JavaPackage`:_(t.java),m=n?s:`RuntimeObject`,te=/\bJava/.test(f)&&t.java,ne=te&&_(t.environment)==u,re=te?`a`:`α`,ie=te?`b`:`β`,ae=t.document||{},S=t.operamini||t.opera,oe=c.test(oe=n&&S?S[`[[Class]]`]:_(S))?oe:S=null,C,se=e,ce=[],le=null,ue=e==a,w=ue&&S&&typeof S.version==`function`&&S.version(),de,fe=he([{label:`EdgeHTML`,pattern:`Edge`},`Trident`,{label:`WebKit`,pattern:`AppleWebKit`},`iCab`,`Presto`,`NetFront`,`Tasman`,`KHTML`,`Gecko`]),T=_e([`Adobe AIR`,`Arora`,`Avant Browser`,`Breach`,`Camino`,`Electron`,`Epiphany`,`Fennec`,`Flock`,`Galeon`,`GreenBrowser`,`iCab`,`Iceweasel`,`K-Meleon`,`Konqueror`,`Lunascape`,`Maxthon`,{label:`Microsoft Edge`,pattern:`(?:Edge|Edg|EdgA|EdgiOS)`},`Midori`,`Nook Browser`,`PaleMoon`,`PhantomJS`,`Raven`,`Rekonq`,`RockMelt`,{label:`Samsung Internet`,pattern:`SamsungBrowser`},`SeaMonkey`,{label:`Silk`,pattern:`(?:Cloud9|Silk-Accelerated)`},`Sleipnir`,`SlimBrowser`,{label:`SRWare Iron`,pattern:`Iron`},`Sunrise`,`Swiftfox`,`Vivaldi`,`Waterfox`,`WebPositive`,{label:`Yandex Browser`,pattern:`YaBrowser`},{label:`UC Browser`,pattern:`UCBrowser`},`Opera Mini`,{label:`Opera Mini`,pattern:`OPiOS`},`Opera`,{label:`Opera`,pattern:`OPR`},`Chromium`,`Chrome`,{label:`Chrome`,pattern:`(?:HeadlessChrome)`},{label:`Chrome Mobile`,pattern:`(?:CriOS|CrMo)`},{label:`Firefox`,pattern:`(?:Firefox|Minefield)`},{label:`Firefox for iOS`,pattern:`FxiOS`},{label:`IE`,pattern:`IEMobile`},{label:`IE`,pattern:`MSIE`},`Safari`]),pe=ye([{label:`BlackBerry`,pattern:`BB10`},`BlackBerry`,{label:`Galaxy S`,pattern:`GT-I9000`},{label:`Galaxy S2`,pattern:`GT-I9100`},{label:`Galaxy S3`,pattern:`GT-I9300`},{label:`Galaxy S4`,pattern:`GT-I9500`},{label:`Galaxy S5`,pattern:`SM-G900`},{label:`Galaxy S6`,pattern:`SM-G920`},{label:`Galaxy S6 Edge`,pattern:`SM-G925`},{label:`Galaxy S7`,pattern:`SM-G930`},{label:`Galaxy S7 Edge`,pattern:`SM-G935`},`Google TV`,`Lumia`,`iPad`,`iPod`,`iPhone`,`Kindle`,{label:`Kindle Fire`,pattern:`(?:Cloud9|Silk-Accelerated)`},`Nexus`,`Nook`,`PlayBook`,`PlayStation Vita`,`PlayStation`,`TouchPad`,`Transformer`,{label:`Wii U`,pattern:`WiiU`},`Wii`,`Xbox One`,{label:`Xbox 360`,pattern:`Xbox`},`Xoom`]),me=ge({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),E=ve([`Windows Phone`,`KaiOS`,`Android`,`CentOS`,{label:`Chrome OS`,pattern:`CrOS`},`Debian`,{label:`DragonFly BSD`,pattern:`DragonFly`},`Fedora`,`FreeBSD`,`Gentoo`,`Haiku`,`Kubuntu`,`Linux Mint`,`OpenBSD`,`Red Hat`,`SuSE`,`Ubuntu`,`Xubuntu`,`Cygwin`,`Symbian OS`,`hpwOS`,`webOS `,`webOS`,`Tablet OS`,`Tizen`,`Linux`,`Mac OS X`,`Macintosh`,`Mac`,`Windows 98;`,`Windows `]);function he(t){return b(t,function(t,n){return t||RegExp(`\\b`+(n.pattern||y(n))+`\\b`,`i`).exec(e)&&(n.label||n)})}function ge(t){return b(t,function(t,n,r){return t||(n[pe]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(pe)]||RegExp(`\\b`+y(r)+`(?:\\b|\\w*\\d)`,`i`).exec(e))&&r})}function _e(t){return b(t,function(t,n){return t||RegExp(`\\b`+(n.pattern||y(n))+`\\b`,`i`).exec(e)&&(n.label||n)})}function ve(t){return b(t,function(t,n){var r=n.pattern||y(n);return!t&&(t=RegExp(`\\b`+r+`(?:/[\\d.]+|[ \\w.]*)`,`i`).exec(e))&&(t=p(t,r,n.label||n)),t})}function ye(t){return b(t,function(t,n){var r=n.pattern||y(n);return!t&&(t=RegExp(`\\b`+r+` *\\d+[.\\w_]*`,`i`).exec(e)||RegExp(`\\b`+r+` *\\w+-[\\w]*`,`i`).exec(e)||RegExp(`\\b`+r+`(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)`,`i`).exec(e))&&((t=String(n.label&&!RegExp(r,`i`).test(n.label)?n.label:t).split(`/`))[1]&&!/[\d.]+/.test(t[0])&&(t[0]+=` `+t[1]),n=n.label||n,t=h(t[0].replace(RegExp(r,`i`),n).replace(RegExp(`; *(?:`+n+`[_-])?`,`i`),` `).replace(RegExp(`(`+n+`)[-_.]?(\\w)`,`i`),`$1 $2`))),t})}function be(t){return b(t,function(t,n){return t||(RegExp(n+`(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)`,`i`).exec(e)||0)[1]||null})}function xe(){return this.description||``}if(fe&&=[fe],/\bAndroid\b/.test(E)&&!pe&&(C=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(e))&&(pe=ee(C[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,``)||null),me&&!pe?pe=ye([me]):me&&pe&&(pe=pe.replace(RegExp(`^(`+y(me)+`)[-_.\\s]`,`i`),me+` `).replace(RegExp(`^(`+y(me)+`)[-_.]?(\\w)`,`i`),me+` $2`)),(C=/\bGoogle TV\b/.exec(pe))&&(pe=C[0]),/\bSimulator\b/i.test(e)&&(pe=(pe?pe+` `:``)+`Simulator`),T==`Opera Mini`&&/\bOPiOS\b/.test(e)&&ce.push(`running in Turbo/Uncompressed mode`),T==`IE`&&/\blike iPhone OS\b/.test(e)?(C=x(e.replace(/like iPhone OS/,``)),me=C.manufacturer,pe=C.product):/^iP/.test(pe)?(T||=`Safari`,E=`iOS`+((C=/ OS ([\d_]+)/i.exec(e))?` `+C[1].replace(/_/g,`.`):``)):T==`Konqueror`&&/^Linux\b/i.test(E)?E=`Kubuntu`:me&&me!=`Google`&&(/Chrome/.test(T)&&!/\bMobile Safari\b/i.test(e)||/\bVita\b/.test(pe))||/\bAndroid\b/.test(E)&&/^Chrome/.test(T)&&/\bVersion\//i.test(e)?(T=`Android Browser`,E=/\bAndroid\b/.test(E)?E:`Android`):T==`Silk`?(/\bMobi/i.test(e)||(E=`Android`,ce.unshift(`desktop mode`)),/Accelerated *= *true/i.test(e)&&ce.unshift(`accelerated`)):T==`UC Browser`&&/\bUCWEB\b/.test(e)?ce.push(`speed mode`):T==`PaleMoon`&&(C=/\bFirefox\/([\d.]+)\b/.exec(e))?ce.push(`identifying as Firefox `+C[1]):T==`Firefox`&&(C=/\b(Mobile|Tablet|TV)\b/i.exec(e))?(E||=`Firefox OS`,pe||=C[1]):!T||(C=!/\bMinefield\b/i.test(e)&&/\b(?:Firefox|Safari)\b/.exec(T))?(T&&!pe&&/[\/,]|^[^(]+?\)/.test(e.slice(e.indexOf(C+`/`)+8))&&(T=null),(C=pe||me||E)&&(pe||me||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(E))&&(T=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(E)?E:C)+` Browser`)):T==`Electron`&&(C=(/\bChrome\/([\d.]+)\b/.exec(e)||0)[1])&&ce.push(`Chromium `+C),w||=be([`(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)`,`Version`,y(T),`(?:Firefox|Minefield|NetFront)`]),(C=fe==`iCab`&&parseFloat(w)>3&&`WebKit`||/\bOpera\b/.test(T)&&(/\bOPR\b/.test(e)?`Blink`:`Presto`)||/\b(?:Midori|Nook|Safari)\b/i.test(e)&&!/^(?:Trident|EdgeHTML)$/.test(fe)&&`WebKit`||!fe&&/\bMSIE\b/i.test(e)&&(E==`Mac OS`?`Tasman`:`Trident`)||fe==`WebKit`&&/\bPlayStation\b(?! Vita\b)/i.test(T)&&`NetFront`)&&(fe=[C]),T==`IE`&&(C=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(e)||0)[1])?(T+=` Mobile`,E=`Windows Phone `+(/\+$/.test(C)?C:C+`.x`),ce.unshift(`desktop mode`)):/\bWPDesktop\b/i.test(e)?(T=`IE Mobile`,E=`Windows Phone 8.x`,ce.unshift(`desktop mode`),w||=(/\brv:([\d.]+)/.exec(e)||0)[1]):T!=`IE`&&fe==`Trident`&&(C=/\brv:([\d.]+)/.exec(e))&&(T&&ce.push(`identifying as `+T+(w?` `+w:``)),T=`IE`,w=C[1]),ue){if(v(t,`global`)){if(te&&(C=te.lang.System,se=C.getProperty(`os.arch`),E||=C.getProperty(`os.name`)+` `+C.getProperty(`os.version`)),ne){try{w=(()=>{throw Error(`impulse-compute loads no package at run time`)})().version.join(`.`),T=`RingoJS`}catch{(C=t.system)&&C.global.system==t.system&&(T=`Narwhal`,E||=C[0].os||null)}T||=`Rhino`}else typeof t.process==`object`&&!t.process.browser&&(C=t.process)&&(typeof C.versions==`object`&&(typeof C.versions.electron==`string`?(ce.push(`Node `+C.versions.node),T=`Electron`,w=C.versions.electron):typeof C.versions.nw==`string`&&(ce.push(`Chromium `+w,`Node `+C.versions.node),T=`NW.js`,w=C.versions.nw)),T||(T=`Node.js`,se=C.arch,E=C.platform,w=/[\d.]+/.exec(C.version),w=w?w[0]:null))}else _(C=t.runtime)==l?(T=`Adobe AIR`,E=C.flash.system.Capabilities.os):_(C=t.phantom)==m?(T=`PhantomJS`,w=(C=C.version||null)&&C.major+`.`+C.minor+`.`+C.patch):typeof ae.documentMode==`number`&&(C=/\bTrident\/(\d+)/i.exec(e))?(w=[w,ae.documentMode],(C=+C[1]+4)!=w[1]&&(ce.push(`IE `+w[1]+` mode`),fe&&(fe[1]=``),w[1]=C),w=T==`IE`?String(w[1].toFixed(1)):w[0]):typeof ae.documentMode==`number`&&/^(?:Chrome|Firefox)\b/.test(T)&&(ce.push(`masking as `+T+` `+w),T=`IE`,w=`11.0`,fe=[`Trident`],E=`Windows`);E&&=h(E)}if(w&&(C=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(w)||/(?:alpha|beta)(?: ?\d)?/i.exec(e+`;`+(ue&&i.appMinorVersion))||/\bMinefield\b/i.test(e)&&`a`)&&(le=/b/i.test(C)?`beta`:`alpha`,w=w.replace(RegExp(C+`\\+?$`),``)+(le==`beta`?ie:re)+(/\d+\+?/.exec(C)||``)),T==`Fennec`||T==`Firefox`&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(E))T=`Firefox Mobile`;else if(T==`Maxthon`&&w)w=w.replace(/\.[\d.]+/,`.x`);else if(/\bXbox\b/i.test(pe))pe==`Xbox 360`&&(E=null),pe==`Xbox 360`&&/\bIEMobile\b/.test(e)&&ce.unshift(`mobile mode`);else if((/^(?:Chrome|IE|Opera)$/.test(T)||T&&!pe&&!/Browser|Mobi/.test(T))&&(E==`Windows CE`||/Mobi/i.test(e)))T+=` Mobile`;else if(T==`IE`&&ue)try{t.external===null&&ce.unshift(`platform preview`)}catch{ce.unshift(`embedded`)}else(/\bBlackBerry\b/.test(pe)||/\bBB10\b/.test(e))&&(C=(RegExp(pe.replace(/ +/g,` *`)+`/([.\\d]+)`,`i`).exec(e)||0)[1]||w)?(C=[C,/BB10/.test(e)],E=(C[1]?(pe=null,me=`BlackBerry`):`Device Software`)+` `+C[0],w=null):this!=g&&pe!=`Wii`&&(ue&&S||/Opera/.test(T)&&/\b(?:MSIE|Firefox)\b/i.test(e)||T==`Firefox`&&/\bOS X (?:\d+\.){2,}/.test(E)||T==`IE`&&(E&&!/^Win/.test(E)&&w>5.5||/\bWindows XP\b/.test(E)&&w>8||w==8&&!/\bTrident\b/.test(e)))&&!c.test(C=x.call(g,e.replace(c,``)+`;`))&&C.name&&(C=`ing as `+C.name+((C=C.version)?` `+C:``),c.test(T)?(/\bIE\b/.test(C)&&E==`Mac OS`&&(E=null),C=`identify`+C):(C=`mask`+C,T=oe?h(oe.replace(/([a-z])([A-Z])/g,`$1 $2`)):`Opera`,/\bIE\b/.test(C)&&(E=null),ue||(w=null)),fe=[`Presto`],ce.push(C));(C=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(e)||0)[1])&&(C=[parseFloat(C.replace(/\.(\d)$/,`.0$1`)),C],T==`Safari`&&C[1].slice(-1)==`+`?(T=`WebKit Nightly`,le=`alpha`,w=C[1].slice(0,-1)):(w==C[1]||w==(C[2]=(/\bSafari\/([\d.]+\+?)/i.exec(e)||0)[1]))&&(w=null),C[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(e)||0)[1],C[0]==537.36&&C[2]==537.36&&parseFloat(C[1])>=28&&fe==`WebKit`&&(fe=[`Blink`]),!ue||!o&&!C[1]?(fe&&(fe[1]=`like Safari`),C=(C=C[0],C<400?1:C<500?2:C<526?3:C<533?4:C<534?`4+`:C<535?5:C<537?6:C<538?7:C<601?8:C<602?9:C<604?10:C<606?11:C<608?12:`12`)):(fe&&(fe[1]=`like Chrome`),C=C[1]||(C=C[0],C<530?1:C<532?2:C<532.05?3:C<533?4:C<534.03?5:C<534.07?6:C<534.1?7:C<534.13?8:C<534.16?9:C<534.24?10:C<534.3?11:C<535.01?12:C<535.02?`13+`:C<535.07?15:C<535.11?16:C<535.19?17:C<536.05?18:C<536.1?19:C<537.01?20:C<537.11?`21+`:C<537.13?23:C<537.18?24:C<537.24?25:C<537.36?26:fe==`Blink`?`28`:`27`)),fe&&(fe[1]+=` `+(C+=typeof C==`number`?`.x`:/[.+]/.test(C)?``:`+`)),T==`Safari`&&(!w||parseInt(w)>45)?w=C:T==`Chrome`&&/\bHeadlessChrome/i.test(e)&&ce.unshift(`headless`)),T==`Opera`&&(C=/\bzbov|zvav$/.exec(E))?(T+=` `,ce.unshift(`desktop mode`),C==`zvav`?(T+=`Mini`,w=null):T+=`Mobile`,E=E.replace(RegExp(` *`+C+`$`),``)):T==`Safari`&&/\bChrome\b/.exec(fe&&fe[1])?(ce.unshift(`desktop mode`),T=`Chrome Mobile`,w=null,/\bOS X\b/.test(E)?(me=`Apple`,E=`iOS 4.3+`):E=null):/\bSRWare Iron\b/.test(T)&&!w&&(w=be(`Chrome`)),w&&w.indexOf(C=/[\d.]+$/.exec(E))==0&&e.indexOf(`/`+C+`-`)>-1&&(E=ee(E.replace(C,``))),E&&E.indexOf(T)!=-1&&!RegExp(T+` OS`).test(E)&&(E=E.replace(RegExp(` *`+y(T)+` *`),``)),fe&&!/\b(?:Avant|Nook)\b/.test(T)&&(/Browser|Lunascape|Maxthon/.test(T)||T!=`Safari`&&/^iOS/.test(E)&&/\bSafari\b/.test(fe[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(T)&&fe[1])&&(C=fe[fe.length-1])&&ce.push(C),ce.length&&(ce=[`(`+ce.join(`; `)+`)`]),me&&pe&&pe.indexOf(me)<0&&ce.push(`on `+me),pe&&ce.push((/^on /.test(ce[ce.length-1])?``:`on `)+pe),E&&=(C=/ ([\d.+]+)$/.exec(E),de=C&&E.charAt(E.length-C[0].length-1)==`/`,{architecture:32,family:C&&!de?E.replace(C[0],``):E,version:C?C[1]:null,toString:function(){var e=this.version;return this.family+(e&&!de?` `+e:``)+(this.architecture==64?` 64-bit`:``)}}),(C=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(se))&&!/\bi686\b/i.test(se)?(E&&(E.architecture=64,E.family=E.family.replace(RegExp(` *`+C),``)),T&&(/\bWOW64\b/i.test(e)||ue&&/\w(?:86|32)$/.test(i.cpuClass||i.platform)&&!/\bWin64; x64\b/i.test(e))&&ce.unshift(`32-bit`)):E&&/^OS X/.test(E.family)&&T==`Chrome`&&parseFloat(w)>=39&&(E.architecture=64),e||=null;var Se={};return Se.description=e,Se.layout=fe&&fe[0],Se.manufacturer=me,Se.name=T,Se.prerelease=le,Se.product=pe,Se.ua=e,Se.version=T&&w,Se.os=E||{architecture:null,family:null,version:null,toString:function(){return`null`}},Se.parse=x,Se.toString=xe,Se.version&&ce.unshift(w),Se.name&&ce.unshift(T),E&&T&&(E!=String(E).split(` `)[0]||E!=T.split(` `)[0]&&!pe)&&ce.push(pe?`(`+E+`)`:`on `+E),ce.length&&(Se.description=ce.join(` `)),Se}var te=x();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(r.platform=te,define(function(){return te})):i&&a?g(te,function(e,t){i[t]=e}):r.platform=te}).call(e)}));const tDe=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,hP=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let t=e.match(tDe);if(!t)throw Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},gP=e=>e===`*`||e===`x`||e===`X`,_P=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},nDe=(e,t)=>typeof e==typeof t?[e,t]:[String(e),String(t)],rDe=(e,t)=>{if(gP(e)||gP(t))return 0;let[n,r]=nDe(_P(e),_P(t));return n>r?1:n<r?-1:0},vP=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=rDe(e[n]||`0`,t[n]||`0`);if(r!==0)return r}return 0},yP=(e,t)=>{let n=hP(e),r=hP(t),i=n.pop(),a=r.pop(),o=vP(n,r);return o===0?i&&a?vP(i.split(`.`),a.split(`.`)):i||a?i?-1:1:0:o};var B;(function(e){e[e.Canceled=1]=`Canceled`,e[e.Unknown=2]=`Unknown`,e[e.InvalidArgument=3]=`InvalidArgument`,e[e.DeadlineExceeded=4]=`DeadlineExceeded`,e[e.NotFound=5]=`NotFound`,e[e.AlreadyExists=6]=`AlreadyExists`,e[e.PermissionDenied=7]=`PermissionDenied`,e[e.ResourceExhausted=8]=`ResourceExhausted`,e[e.FailedPrecondition=9]=`FailedPrecondition`,e[e.Aborted=10]=`Aborted`,e[e.OutOfRange=11]=`OutOfRange`,e[e.Unimplemented=12]=`Unimplemented`,e[e.Internal=13]=`Internal`,e[e.Unavailable=14]=`Unavailable`,e[e.DataLoss=15]=`DataLoss`,e[e.Unauthenticated=16]=`Unauthenticated`})(B||={});function bP(e,t){return typeof e==`object`&&e&&`$typeName`in e&&typeof e.$typeName==`string`?t===void 0||t.typeName===e.$typeName:!1}var V;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`})(V||={});function iDe(){let e=this.buf,t=this.pos,n=0,r=0;for(let i=0;i<28;i+=7){let a=e[t++];if(n|=(a&127)<<i,!(a&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}}let i=e[t++];if(n|=(i&15)<<28,r=(i&112)>>4,!(i&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}for(let i=3;i<=31;i+=7){let a=e[t++];if(r|=(a&127)<<i,!(a&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}}throw Error(`invalid varint`)}const xP=4294967296;function SP(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=xP&&(i+=r/xP|0,r%=xP)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?TP(r,i):wP(r,i)}function aDe(e,t){let n=wP(e,t),r=n.hi&2147483648;r&&(n=TP(n.lo,n.hi));let i=CP(n.lo,n.hi);return r?`-`+i:i}function CP(e,t){if({lo:e,hi:t}=oDe(e,t),t<=2097151)return String(xP*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+EP(o)+EP(a)}function oDe(e,t){return{lo:e>>>0,hi:t>>>0}}function wP(e,t){return{lo:e|0,hi:t|0}}function TP(e,t){return t=~t,e?e=~e+1:t+=1,wP(e,t)}const EP=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function sDe(e,t){if(e>>>0<128){t.push(e);return}if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function cDe(){let e=this.buf[this.pos++];if(!(e&128))return this.assertBounds(),e;let t=e&127;if(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}const DP=lDe();function lDe(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(globalThis.Deno||globalThis.Bun||typeof process!=`object`||typeof process.env!=`object`||process.env.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`invalid int64: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),OP(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),kP(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),OP(e),SP(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),kP(e),SP(e)},dec(e,t){return aDe(e,t)},uDec(e,t){return CP(e,t)}}}function OP(e){if(!/^-?[0-9]+$/.test(e))throw Error(`invalid int64: `+e)}function kP(e){if(!/^[0-9]+$/.test(e))throw Error(`invalid uint64: `+e)}function AP(e,t){switch(e){case V.STRING:return``;case V.BOOL:return!1;case V.DOUBLE:case V.FLOAT:return 0;case V.INT64:case V.UINT64:case V.SFIXED64:case V.FIXED64:case V.SINT64:return t?`0`:DP.zero;case V.BYTES:return new Uint8Array;default:return 0}}function uDe(e,t){switch(e){case V.BOOL:return t===!1;case V.STRING:return t===``;case V.BYTES:return t instanceof Uint8Array&&!t.byteLength;case V.DOUBLE:case V.FLOAT:return Object.is(t,0);default:return t==0}}const jP=Symbol.for(`reflect unsafe local`);function dDe(e,t){let n=e[t.localName].case;return n===void 0?n:t.fields.find(e=>e.localName===n)}function fDe(e,t){let n=t.localName;if(t.oneof)return e[t.oneof.localName].case===n;if(t.presence!=2)return e[n]!==void 0&&Object.prototype.hasOwnProperty.call(e,n);switch(t.fieldKind){case`list`:return e[n].length>0;case`map`:return Object.keys(e[n]).length>0;case`scalar`:return!uDe(t.scalar,e[n]);case`enum`:return e[n]!==t.enum.values[0].number}throw Error(`message field with implicit presence`)}function MP(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==void 0}function pDe(e,t){if(t.oneof){let n=e[t.oneof.localName];return n.case===t.localName?n.value:void 0}return e[t.localName]}function mDe(e,t,n){t.oneof?e[t.oneof.localName]={case:t.localName,value:n}:e[t.localName]=n}function NP(e,t,n){t===`__proto__`?Object.defineProperty(e,"__proto__",{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function hDe(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function gDe(e,t){let n=t.localName;if(t.oneof){let r=t.oneof.localName;e[r].case===n&&(e[r]={case:void 0})}else if(t.presence!=2)delete e[n];else switch(t.fieldKind){case`map`:e[n]={};break;case`list`:e[n]=[];break;case`enum`:e[n]=t.enum.values[0].number;break;case`scalar`:e[n]=AP(t.scalar,t.longAsString)}}function PP(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function FP(e,t){if(PP(e)&&jP in e&&`add`in e&&`field`in e&&typeof e.field==`function`){if(t!==void 0){let n=t,r=e.field();return n.listKind==r.listKind&&n.scalar===r.scalar&&n.message?.typeName===r.message?.typeName&&n.enum?.typeName===r.enum?.typeName}return!0}return!1}function IP(e,t){if(PP(e)&&jP in e&&`has`in e&&`field`in e&&typeof e.field==`function`){if(t!==void 0){let n=t,r=e.field();return n.mapKey===r.mapKey&&n.mapKind==r.mapKind&&n.scalar===r.scalar&&n.message?.typeName===r.message?.typeName&&n.enum?.typeName===r.enum?.typeName}return!0}return!1}function LP(e,t){return PP(e)&&jP in e&&`desc`in e&&PP(e.desc)&&e.desc.kind===`message`&&(t===void 0||e.desc.typeName==t.typeName)}function _De(e){return BP(e.$typeName)}function RP(e){let t=e.fields[0];return BP(e.typeName)&&t!==void 0&&t.fieldKind==`scalar`&&t.name==`value`&&t.number==1}function zP(e){switch(e.typeName){case`google.protobuf.Any`:case`google.protobuf.Timestamp`:case`google.protobuf.Duration`:case`google.protobuf.FieldMask`:case`google.protobuf.Struct`:case`google.protobuf.Value`:case`google.protobuf.ListValue`:return!0;default:return RP(e)}}const vDe=new Set([`google.protobuf.DoubleValue`,`google.protobuf.FloatValue`,`google.protobuf.Int64Value`,`google.protobuf.UInt64Value`,`google.protobuf.Int32Value`,`google.protobuf.UInt32Value`,`google.protobuf.BoolValue`,`google.protobuf.StringValue`,`google.protobuf.BytesValue`]);function BP(e){return vDe.has(e)}function VP(e,t){return bP(t,e)?t:UP(e)(t)}const HP=new WeakMap;function UP(e){let t=HP.get(e);return t===void 0&&(t=yDe(e),HP.set(e,t)),t}function yDe(e){let t=e.typeName,{properties:n,prototype:r}=bDe(e);return e=>{let i;r===void 0?i={$typeName:t}:(i=Object.create(r),i.$typeName=t);for(let t=0;t<n.length;t++){let r=n[t],a=r.name,o=e?.[a];switch(r.kind){case 0:o==null?r.constant!==void 0&&(i[a]=r.constant):i[a]=r.convert===void 0?o:r.convert(o);break;case 1:i[a]=r.convert!==void 0&&Array.isArray(o)?o.map(r.convert):o??[];break;case 2:if(r.convert===void 0||!PP(o))i[a]=o??{};else{let e={},t=Object.keys(o);for(let n=0;n<t.length;n++)NP(e,t[n],r.convert(o[t[n]]));i[a]=e}break;case 3:{let e=o;if(e?.case!=null){let t=r.convert.get(e.case);if(t!==void 0){i[a]={case:e.case,value:t(e.value)};break}}i[a]={case:void 0};break}}}return i}}function bDe(e){let t=[],n={},r=SDe(e);for(let i of e.members){let e=i.localName;if(i.kind==`oneof`){t.push({name:e,kind:3,constant:void 0,convert:xDe(i)});continue}switch(i.fieldKind){case`message`:t.push({name:e,kind:0,constant:void 0,convert:WP(i)});break;case`list`:t.push({name:e,kind:1,constant:void 0,convert:i.listKind==`message`?WP(i)??(e=>e):i.scalar==V.BYTES?GP:void 0});break;case`map`:t.push({name:e,kind:2,constant:void 0,convert:i.mapKind==`message`?WP(i)??(e=>e):i.scalar==V.BYTES?GP:void 0});break;default:{let a=CDe(i);t.push({name:e,kind:0,constant:i.presence==2?a:void 0,convert:i.fieldKind==`scalar`&&i.scalar==V.BYTES?GP:void 0}),r&&(n[e]=a);break}}}return{properties:t,prototype:r?n:void 0}}function xDe(e){let t=new Map;for(let n of e.fields){let e;n.fieldKind==`message`?e=WP(n):n.fieldKind==`scalar`&&n.scalar==V.BYTES&&(e=GP),t.set(n.localName,e??(e=>e))}return t}function WP(e){if(e.fieldKind==`message`&&!e.oneof&&RP(e.message))return e.message.fields[0].scalar==V.BYTES?GP:void 0;if(e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!==`google.protobuf.Value`)return;let t=e.message,n;return e=>!PP(e)||bP(e,t)?e:(n??=UP(t),n(e))}function GP(e){return Array.isArray(e)?new Uint8Array(e):e}function SDe(e){switch(e.file.edition){case 999:return!1;case 998:return!0;default:return e.fields.some(e=>e.presence!=2&&e.fieldKind!=`message`&&!e.oneof)}}function CDe(e){let t=e.getDefaultValue();return t===void 0?e.fieldKind==`scalar`?AP(e.scalar,e.longAsString):e.enum.values[0].number:e.fieldKind==`scalar`&&e.longAsString?t.toString():t}const wDe=[`FieldValueInvalidError`,`FieldListRangeError`,`ForeignFieldError`];var KP=class extends Error{constructor(e,t,n=`FieldValueInvalidError`){super(t),this.name=n,this.field=()=>e}};function TDe(e){return e instanceof Error&&wDe.includes(e.name)&&`field`in e&&typeof e.field==`function`}let qP;function EDe(e){qP=Object.assign(Object.assign({},e),{encodeUtf8Into:e.encodeUtf8Into??YP(e.encodeUtf8.bind(e))})}function JP(){if(!qP){let e=globalThis;if(!e.TextEncoder||!e.TextDecoder)throw Error(`encoding API missing: install TextEncoder and TextDecoder on globalThis`);let t=new e.TextEncoder,n=new e.TextDecoder(`utf-8`,{ignoreBOM:!0}),r,i={encodeUtf8(e){return t.encode(e)},decodeUtf8(t,i){return i?(r||=new e.TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),r.decode(t)):n.decode(t)},checkUtf8(e){try{return!0}catch{return!1}}};t.encodeInto&&(i.encodeUtf8Into=t.encodeInto.bind(t));let a=String.prototype.isWellFormed;a&&(i.checkUtf8=e=>a.call(e)),EDe(i)}return qP}function YP(e){return(t,n)=>{let r=e(t);return n.set(r),{written:r.byteLength}}}var XP;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(XP||={});var ZP=class{constructor(e){this.stackPos=[],this.encodeUtf8Into=e?YP(e):JP().encodeUtf8Into,this.buffer=$P,this.viewCache=ODe,this.pos=0}ensureCapacity(e){let t=this.pos+e;if(t>this.buffer.length){let e=this.buffer.length||DDe;for(;e<t;)e*=2;let n=new Uint8Array(e);this.pos>0&&n.set(this.buffer),this.buffer=n}}view(){let e=this.buffer,t=this.viewCache;if(t.byteLength===e.byteLength)return t;let n=new DataView(e.buffer);return this.viewCache=n,n}finish(){let e=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],e}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(QP),this.buffer[this.pos++]=0,this}join(){let e=this.stackPos.pop();if(e===void 0)throw Error(`invalid state, fork stack empty`);let t=this.pos-e-QP,n=eF(t);return n>QP&&(this.ensureCapacity(n-QP),this.buffer.copyWithin(e+n,e+QP,this.pos)),this.pos=e,this.uint32(t),this.pos+=t,this}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.ensureCapacity(e.length),this.buffer.set(e,this.pos),this.pos+=e.length,this}uint32(e){if(rF(e),this.ensureCapacity(5),e<128)return this.buffer[this.pos++]=e,this;for(;e>127;)this.buffer[this.pos++]=e&127|128,e>>>=7;return this.buffer[this.pos++]=e,this}int32(e){if(nF(e),e>=0)return this.uint32(e);this.ensureCapacity(10);for(let t=0;t<9;t++)this.buffer[this.pos++]=e&127|128,e>>=7;return this.buffer[this.pos++]=1,this}bool(e){return this.ensureCapacity(1),this.buffer[this.pos++]=+!!e,this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){typeof e!=`string`&&(e=String(e));let t=e.length;if(t<=kDe){this.ensureCapacity(t+1);let n=this.buffer,r=this.pos;n[r++]=t;let i=0;for(;i<t;i++){let t=e.charCodeAt(i);if(t>127)break;n[r++]=t}if(i==t)return this.pos=r,this}this.ensureCapacity(t*3+5);let n=eF(t),r=this.buffer,i=this.pos,{written:a}=this.encodeUtf8Into(e,r.subarray(i+n)),o=eF(a);return o!=n&&r.copyWithin(i+o,i+n,i+n+a),this.uint32(a),this.pos+=a,this}float(e){return ADe(e),this.ensureCapacity(4),this.view().setFloat32(this.pos,e,!0),this.pos+=4,this}double(e){return this.ensureCapacity(8),this.view().setFloat64(this.pos,e,!0),this.pos+=8,this}fixed32(e){return rF(e),this.ensureCapacity(4),this.view().setUint32(this.pos,e,!0),this.pos+=4,this}sfixed32(e){return nF(e),this.ensureCapacity(4),this.view().setInt32(this.pos,e,!0),this.pos+=4,this}sint32(e){return nF(e),this.uint32((e<<1^e>>31)>>>0)}sfixed64(e){let t=DP.enc(e);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,t.lo,!0),n.setInt32(this.pos+4,t.hi,!0),this.pos+=8,this}fixed64(e){let t=DP.uEnc(e);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,t.lo,!0),n.setInt32(this.pos+4,t.hi,!0),this.pos+=8,this}int64(e){let t=DP.enc(e);return this.writeVarint64(t.lo,t.hi)}sint64(e){let t=DP.enc(e),n=t.hi>>31,r=t.lo<<1^n,i=(t.hi<<1|t.lo>>>31)^n;return this.writeVarint64(r,i)}uint64(e){let t=DP.uEnc(e);return this.writeVarint64(t.lo,t.hi)}writeVarint64(e,t){this.ensureCapacity(10);let n=this.buffer,r=this.pos;for(let i=0;i<28;i+=7){let a=e>>>i,o=!(!(a>>>7)&&t==0);if(n[r++]=(o?a|128:a)&255,!o)return this.pos=r,this}let i=e>>>28&15|(t&7)<<4,a=!!(t>>3);if(n[r++]=(a?i|128:i)&255,!a)return this.pos=r,this;for(let e=3;e<31;e+=7){let i=t>>>e,a=!!(i>>>7);if(n[r++]=(a?i|128:i)&255,!a)return this.pos=r,this}return n[r++]=t>>>31&1,this.pos=r,this}};const DDe=128,QP=1,$P=new Uint8Array,ODe=new DataView($P.buffer),kDe=32;function eF(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}var tF=class{constructor(e,t=JP().decodeUtf8){this.decodeUtf8=t,this.varint64Lo=0,this.varint64Hi=0,this.varint64=iDe,this.uint32=cDe,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.pos,t=this.uint32(),n=this.pos-e;if(n>5||n==5&&this.buf[this.pos-1]>15)throw Error(`illegal tag: varint overflows uint32`);let r=t>>>3,i=t&7;if(r<=0||i>5)throw Error(`illegal tag: field no `+r+` wire type `+i);return[r,i]}skip(e,t,n=100){let r=this.pos;switch(e){case XP.Varint:for(;this.buf[this.pos++]&128;);break;case XP.Bit64:this.pos+=4;case XP.Bit32:this.pos+=4;break;case XP.LengthDelimited:let r=this.uint32();this.pos+=r;break;case XP.StartGroup:if(n<=0)throw Error(`maximum recursion depth reached`);for(;;){let[e,r]=this.tag();if(r===XP.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(r,e,n-1)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return this.varint64(),DP.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),DP.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let e=this.varint64Lo,t=this.varint64Hi,n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,DP.dec(e,t)}bool(){let e=this.buf[this.pos];return e<128?(this.pos++,e!==0):(this.varint64(),this.varint64Lo!==0||this.varint64Hi!==0)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return DP.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return DP.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e){let t=this.uint32(),n=this.pos;this.pos+=t,this.assertBounds();let r=this.buf;if(t<=32){let i=Array(t);for(let a=0;a<t;a++){let t=r[n+a];if(t>127)return this.decodeUtf8(r.subarray(n,this.pos),e);i[a]=t}return String.fromCharCode.apply(String,i)}return this.decodeUtf8(r.subarray(n,this.pos),e)}};function nF(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid int32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int32: `+e)}function rF(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid uint32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint32: `+e)}function ADe(e){if(typeof e==`string`){let t=e;if(e=Number(e),Number.isNaN(e)&&t!==`NaN`)throw Error(`invalid float32: `+t)}else if(typeof e!=`number`)throw Error(`invalid float32: `+typeof e);if(!Number.isFinite(Math.fround(e))&&Number.isFinite(e))throw Error(`invalid float32: `+e)}function iF(e,t){let n=e.fieldKind==`list`?FP(t,e):e.fieldKind==`map`?IP(t,e):oF(e,t);if(n===!0)return;let r;switch(e.fieldKind){case`list`:r=`expected ${dF(e)}, got ${lF(t)}`;break;case`map`:r=`expected ${fF(e)}, got ${lF(t)}`;break;default:r=cF(e,t,n)}return new KP(e,r)}function aF(e,t,n){let r=oF(e,n);if(r!==!0)return new KP(e,`list item #${t+1}: ${cF(e,n,r)}`)}function jDe(e,t,n){let r=sF(e.mapKey)(t);if(r!==!0)return new KP(e,`invalid map key: ${cF({scalar:e.mapKey},t,r)}`);let i=oF(e,n);if(i!==!0)return new KP(e,`map entry ${lF(t)}: ${cF(e,n,i)}`)}function oF(e,t){return e.scalar===void 0?e.enum===void 0?LP(t,e.message):e.enum.open?sF(V.INT32)(t):e.enum.values.some(e=>e.number===t):sF(e.scalar)(t)}function sF(e){switch(e){case V.DOUBLE:return e=>typeof e==`number`;case V.FLOAT:return e=>typeof e==`number`?!Number.isFinite(Math.fround(e))&&Number.isFinite(e)?`${e.toFixed()} out of range`:!0:!1;case V.INT32:case V.SFIXED32:case V.SINT32:return e=>typeof e!=`number`||!Number.isInteger(e)?!1:e>2147483647||e<-2147483648?`${e.toFixed()} out of range`:!0;case V.FIXED32:case V.UINT32:return e=>typeof e!=`number`||!Number.isInteger(e)?!1:e>4294967295||e<0?`${e.toFixed()} out of range`:!0;case V.BOOL:return e=>typeof e==`boolean`;case V.STRING:return e=>typeof e==`string`?JP().checkUtf8(e)||`invalid UTF8`:!1;case V.BYTES:return e=>e instanceof Uint8Array;case V.INT64:case V.SFIXED64:case V.SINT64:return e=>{if(typeof e==`bigint`||typeof e==`number`||typeof e==`string`&&e.length>0)try{return DP.parse(e),!0}catch{return`${e} out of range`}return!1};case V.FIXED64:case V.UINT64:return e=>{if(typeof e==`bigint`||typeof e==`number`||typeof e==`string`&&e.length>0)try{return DP.uParse(e),!0}catch{return`${e} out of range`}return!1}}}function cF(e,t,n){return n=typeof n==`string`?`: ${n}`:`, got ${lF(t)}`,e.scalar===void 0?e.enum===void 0?`expected ${uF(e.message)}`+n:`expected ${e.enum.toString()}`+n:`expected ${MDe(e.scalar)}`+n}function lF(e){switch(typeof e){case`object`:return e===null?`null`:e instanceof Uint8Array?`Uint8Array(${e.length})`:Array.isArray(e)?`Array(${e.length})`:FP(e)?dF(e.field()):IP(e)?fF(e.field()):LP(e)?uF(e.desc):bP(e)?`message ${e.$typeName}`:`object`;case`string`:return e.length>30?`string`:`"${e.split(`"`).join(`\\"`)}"`;case`boolean`:return String(e);case`number`:return String(e);case`bigint`:return String(e)+`n`;default:return typeof e}}function uF(e){return`ReflectMessage (${e.typeName})`}function dF(e){switch(e.listKind){case`message`:return`ReflectList (${e.message.toString()})`;case`enum`:return`ReflectList (${e.enum.toString()})`;case`scalar`:return`ReflectList (${V[e.scalar]})`}}function fF(e){switch(e.mapKind){case`message`:return`ReflectMap (${V[e.mapKey]}, ${e.message.toString()})`;case`enum`:return`ReflectMap (${V[e.mapKey]}, ${e.enum.toString()})`;case`scalar`:return`ReflectMap (${V[e.mapKey]}, ${V[e.scalar]})`}}function MDe(e){switch(e){case V.STRING:return`string`;case V.BOOL:return`boolean`;case V.INT64:case V.SINT64:case V.SFIXED64:return`bigint (int64)`;case V.UINT64:case V.FIXED64:return`bigint (uint64)`;case V.BYTES:return`Uint8Array`;case V.DOUBLE:return`number (float64)`;case V.FLOAT:return`number (float32)`;case V.FIXED32:case V.UINT32:return`number (uint32)`;case V.INT32:case V.SFIXED32:case V.SINT32:return`number (int32)`}}function pF(e){if(NDe(e))return{toMessage:e=>mF(e),toLocal:e=>hF(e)};if(e.fieldKind==`message`&&!e.oneof&&RP(e.message)){let t=e.message,n=t.fields[0].localName;return{toMessage:e=>{let r=VP(t);return e!==void 0&&(r[n]=e),r},toLocal:e=>e[n]}}let t=e.message;return{toMessage:e=>e===void 0?VP(t):e,toLocal:e=>e}}function NDe(e){return e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`}function mF(e){let t={$typeName:`google.protobuf.Struct`,fields:{}};if(PP(e))for(let n of Object.keys(e))NP(t.fields,n,_F(e[n]));return t}function hF(e){let t={};for(let n of Object.keys(e.fields))NP(t,n,gF(e.fields[n]));return t}function gF(e){switch(e.kind.case){case`structValue`:return hF(e.kind.value);case`listValue`:return e.kind.value.values.map(gF);case`nullValue`:case void 0:return null;default:return e.kind.value}}function _F(e){let t={$typeName:`google.protobuf.Value`,kind:{case:void 0}};switch(typeof e){case`number`:t.kind={case:`numberValue`,value:e};break;case`string`:t.kind={case:`stringValue`,value:e};break;case`boolean`:t.kind={case:`boolValue`,value:e};break;case`object`:if(e===null)t.kind={case:`nullValue`,value:0};else if(Array.isArray(e)){let n={$typeName:`google.protobuf.ListValue`,values:[]};if(Array.isArray(e))for(let t of e)n.values.push(_F(t));t.kind={case:`listValue`,value:n}}else t.kind={case:`structValue`,value:mF(e)}}return t}function PDe(e,t,n=!0){return new yF(e,t,n)}const vF=new WeakMap;var yF=class{get sortedFields(){let e=vF.get(this.desc);if(e)return e;let t=this.desc.fields.concat().sort((e,t)=>e.number-t.number);return vF.set(this.desc,t),t}constructor(e,t,n=!0){this.lists=new Map,this.maps=new Map,this.check=n,this.desc=e,this.message=this[jP]=t??VP(e),this.fields=e.fields,this.oneofs=e.oneofs,this.members=e.members}findNumber(e){return this._fieldsByNumber||=new Map(this.desc.fields.map(e=>[e.number,e])),this._fieldsByNumber.get(e)}oneofCase(e){return bF(this.message,e),dDe(this.message,e)}isSet(e){return bF(this.message,e),fDe(this.message,e)}clear(e){bF(this.message,e),gDe(this.message,e)}get(e){bF(this.message,e);let t=pDe(this.message,e);switch(e.fieldKind){case`list`:let n=this.lists.get(e);return(!n||n[jP]!==t)&&this.lists.set(e,n=new FDe(e,t,this.check)),n;case`map`:let r=this.maps.get(e);return(!r||r[jP]!==t)&&this.maps.set(e,r=new IDe(e,t,this.check)),r;case`message`:return SF(e,t,this.check);case`scalar`:return t===void 0?AP(e.scalar,!1):OF(e,t);case`enum`:return t??e.enum.values[0].number}}set(e,t){if(bF(this.message,e),this.check){let n=iF(e,t);if(n)throw n}let n;n=e.fieldKind==`message`?xF(e,t):IP(t)||FP(t)?t[jP]:kF(e,t),mDe(this.message,e,n)}getUnknown(){return this.message.$unknown}setUnknown(e){this.message.$unknown=e}};function bF(e,t){if(t.parent.typeName!==e.$typeName)throw new KP(t,`cannot use ${t.toString()} with message ${e.$typeName}`,`ForeignFieldError`)}var FDe=class{field(){return this._field}get size(){return this._arr.length}constructor(e,t,n){this._field=e,this._arr=this[jP]=t,this.check=n}get(e){let t=this._arr[e];return t===void 0?void 0:wF(this._field,t,this.check)}set(e,t){if(e<0||e>=this._arr.length)throw new KP(this._field,`list item #${e+1}: out of range`);if(this.check){let n=aF(this._field,e,t);if(n)throw n}this._arr[e]=CF(this._field,t)}add(e){if(this.check){let t=aF(this._field,this._arr.length,e);if(t)throw t}this._arr.push(CF(this._field,e))}clear(){this._arr.splice(0,this._arr.length)}[Symbol.iterator](){return this.values()}keys(){return this._arr.keys()}*values(){for(let e of this._arr)yield wF(this._field,e,this.check)}*entries(){for(let e=0;e<this._arr.length;e++)yield[e,wF(this._field,this._arr[e],this.check)]}},IDe=class{constructor(e,t,n=!0){this.obj=this[jP]=t??{},this.check=n,this._field=e}field(){return this._field}set(e,t){if(this.check){let n=jDe(this._field,e,t);if(n)throw n}return NP(this.obj,EF(e),LDe(this._field,t)),this}delete(e){let t=EF(e),n=Object.prototype.hasOwnProperty.call(this.obj,t);return n&&delete this.obj[t],n}clear(){for(let e of Object.keys(this.obj))delete this.obj[e]}get(e){let t=hDe(this.obj,EF(e));return t!==void 0&&(t=TF(this._field,t,this.check)),t}has(e){return Object.prototype.hasOwnProperty.call(this.obj,EF(e))}*keys(){for(let e of Object.keys(this.obj))yield DF(e,this._field.mapKey)}*entries(){for(let e of Object.entries(this.obj))yield[DF(e[0],this._field.mapKey),TF(this._field,e[1],this.check)]}[Symbol.iterator](){return this.entries()}get size(){return Object.keys(this.obj).length}*values(){for(let e of Object.values(this.obj))yield TF(this._field,e,this.check)}forEach(e,t){for(let n of this.entries())e.call(t,n[1],n[0],this)}};function xF(e,t){return LP(t)?_De(t.message)&&!e.oneof&&e.fieldKind==`message`?t.message.value:t.desc.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`?hF(t.message):t.message:t}function SF(e,t,n){return t!==void 0&&(RP(e.message)&&!e.oneof&&e.fieldKind==`message`?t={$typeName:e.message.typeName,value:OF(e.message.fields[0],t)}:e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`&&PP(t)&&(t=mF(t))),new yF(e.message,t,n)}function CF(e,t){return e.listKind==`message`?xF(e,t):kF(e,t)}function wF(e,t,n){return e.listKind==`message`?SF(e,t,n):OF(e,t)}function LDe(e,t){return e.mapKind==`message`?xF(e,t):kF(e,t)}function TF(e,t,n){return e.mapKind==`message`?SF(e,t,n):t}function EF(e){return typeof e==`string`||typeof e==`number`?e:String(e)}function DF(e,t){switch(t){case V.STRING:return e;case V.INT32:case V.FIXED32:case V.UINT32:case V.SFIXED32:case V.SINT32:{let t=Number.parseInt(e);if(Number.isFinite(t))return t;break}case V.BOOL:switch(e){case`true`:return!0;case`false`:return!1}break;case V.UINT64:case V.FIXED64:try{return DP.uParse(e)}catch{}break;default:try{return DP.parse(e)}catch{}}return e}function OF(e,t){switch(e.scalar){case V.INT64:case V.SFIXED64:case V.SINT64:`longAsString`in e&&e.longAsString&&typeof t==`string`&&(t=DP.parse(t));break;case V.FIXED64:case V.UINT64:`longAsString`in e&&e.longAsString&&typeof t==`string`&&(t=DP.uParse(t))}return t}function kF(e,t){switch(e.scalar){case V.INT64:case V.SFIXED64:case V.SINT64:`longAsString`in e&&e.longAsString?t=String(t):(typeof t==`string`||typeof t==`number`)&&(t=DP.parse(t));break;case V.FIXED64:case V.UINT64:`longAsString`in e&&e.longAsString?t=String(t):(typeof t==`string`||typeof t==`number`)&&(t=DP.uParse(t))}return t}const AF=Uint8Array.prototype.setFromBase64;function jF(e){let t=e.length,n=t-(t+3>>2);!(t&3)&&e[t-1]==`=`&&(n-=e[t-2]==`=`?2:1);let r=new Uint8Array(n),i=-1;if(AF)try{let n=AF.call(r,e);n.read==t&&(i=n.written)}catch{}return i<0&&(i=RDe(r,e)),i==n?r:r.subarray(0,i)}function RDe(e,t){let n=BDe(),r=0,i=0,a,o=0;for(let s=0;s<t.length;s++){if(a=n[t.charCodeAt(s)],a===void 0)switch(t[s]){case`=`:i=0;case`
|
|
453
453
|
`:case`\r`:case` `:case` `:continue;default:throw Error(`invalid base64 string`)}switch(i){case 0:o=a,i=1;break;case 1:e[r++]=o<<2|(a&48)>>4,o=a,i=2;break;case 2:e[r++]=(o&15)<<4|(a&60)>>2,o=a,i=3;break;case 3:e[r++]=(o&3)<<6|a,i=0}}if(i==1)throw Error(`invalid base64 string`);return r}const MF=Uint8Array.prototype.toBase64,zDe={std:{alphabet:`base64`,omitPadding:!1},std_raw:{alphabet:`base64`,omitPadding:!0},url:{alphabet:`base64url`,omitPadding:!0}};function NF(e,t=`std`){if(MF)return MF.call(e,zDe[t]);let n=LF(t),r=t==`std`,i=``,a=0,o,s=0;for(let t=0;t<e.length;t++)switch(o=e[t],a){case 0:i+=n[o>>2],s=(o&3)<<4,a=1;break;case 1:i+=n[s|o>>4],s=(o&15)<<2,a=2;break;case 2:i+=n[s|o>>6],i+=n[o&63],a=0}return a&&(i+=n[s],r&&(i+=`=`,a==1&&(i+=`=`))),i}let PF,FF,IF;function LF(e){return PF||(PF=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),FF=PF.slice(0,-2).concat(`-`,`_`)),e==`url`?FF:PF}function BDe(){if(!IF){IF=[];let e=LF(`std`);for(let t=0;t<e.length;t++)IF[e[t].charCodeAt(0)]=t;IF[45]=e.indexOf(`+`),IF[95]=e.indexOf(`/`)}return IF}function RF(e){let t=!1,n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);switch(i){case`_`:t=!0;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n.push(i),t=!1;break;default:t&&(t=!1,i=i.toUpperCase()),n.push(i)}}return n.join(``)}function zF(e){return e.replace(/[A-Z]/g,e=>`_`+e.toLowerCase())}const VDe=new Set([`constructor`,`toString`,`toJSON`,`valueOf`]);function BF(e){return VDe.has(e)?e+`$`:e}function VF(e){for(let t of e.field)MP(t,`jsonName`)||(t.jsonName=RF(t.name));e.nestedType.forEach(VF)}function HDe(e,t){let n=e.values.find(e=>e.name===t);if(!n)throw Error(`cannot parse ${e} default value: ${t}`);return n.number}function UDe(e,t){switch(e){case V.STRING:return t;case V.BYTES:{let n=WDe(t);if(n===!1)throw Error(`cannot parse ${V[e]} default value: ${t}`);return n}case V.INT64:case V.SFIXED64:case V.SINT64:return DP.parse(t);case V.UINT64:case V.FIXED64:return DP.uParse(t);case V.DOUBLE:case V.FLOAT:switch(t){case`inf`:return 1/0;case`-inf`:return-1/0;case`nan`:return NaN;default:return parseFloat(t)}case V.BOOL:return t===`true`;case V.INT32:case V.UINT32:case V.SINT32:case V.FIXED32:case V.SFIXED32:return parseInt(t,10)}}function WDe(e){let t=[],n={tail:e,c:``,next(){return this.tail.length!=0&&(this.c=this.tail[0],this.tail=this.tail.substring(1),!0)},take(e){if(this.tail.length>=e){let t=this.tail.substring(0,e);return this.tail=this.tail.substring(e),t}return!1}};for(;n.next();)switch(n.c){case`\\`:if(n.next())switch(n.c){case`\\`:t.push(n.c.charCodeAt(0));break;case`b`:t.push(8);break;case`f`:t.push(12);break;case`n`:t.push(10);break;case`r`:t.push(13);break;case`t`:t.push(9);break;case`v`:t.push(11);break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:{let e=n.c,r=n.take(2);if(r===!1)return!1;let i=parseInt(e+r,8);if(Number.isNaN(i))return!1;t.push(i);break}case`x`:{let e=n.c,r=n.take(2);if(r===!1)return!1;let i=parseInt(e+r,16);if(Number.isNaN(i))return!1;t.push(i);break}case`u`:{let e=n.c,r=n.take(4);if(r===!1)return!1;let i=parseInt(e+r,16);if(Number.isNaN(i))return!1;let a=new Uint8Array(4);new DataView(a.buffer).setInt32(0,i,!0),t.push(a[0],a[1],a[2],a[3]);break}case`U`:{let e=n.c,r=n.take(8);if(r===!1)return!1;let i=DP.uEnc(e+r),a=new Uint8Array(8),o=new DataView(a.buffer);o.setInt32(0,i.lo,!0),o.setInt32(4,i.hi,!0),t.push(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]);break}}break;default:t.push(n.c.charCodeAt(0))}return new Uint8Array(t)}function*HF(e){switch(e.kind){case`file`:for(let t of e.messages)yield t,yield*HF(t);yield*e.enums,yield*e.services,yield*e.extensions;break;case`message`:for(let t of e.nestedMessages)yield t,yield*HF(t);yield*e.nestedEnums,yield*e.nestedExtensions}}function UF(e,t){return GDe([e,t])}function GDe(e,t){let n=KDe();if(!e.length)return n;if(`$typeName`in e[0]&&e[0].$typeName==`google.protobuf.FileDescriptorSet`){for(let r of e[0].file)t?.(r),GF(r,n);return n}if(`$typeName`in e[0]){let r=e[0],i=e[1],a=new Set;function o(e){let t=[];for(let r of e.dependency){if(n.getFile(r)!=null||a.has(r))continue;let o=i(r);if(!o)throw Error(`Unable to resolve ${r}, imported by ${e.name}`);`kind`in o?n.addFile(o,!1,!0):(a.add(o.name),t.push(o))}return t.concat(...t.map(o))}for(let e of[r,...o(r)].reverse())t?.(e),GF(e,n)}else for(let t of e)for(let e of t.files)n.addFile(e);return n}function KDe(){let e=new Map,t=new Map,n=new Map;return{kind:`registry`,types:e,extendees:t,[Symbol.iterator](){return e.values()},get files(){return n.values()},addFile(e,t,r){if(n.set(e.proto.name,e),!t)for(let t of HF(e))this.add(t);if(r)for(let n of e.dependencies)this.addFile(n,t,r)},add(n){if(n.kind==`extension`){let e=t.get(n.extendee.typeName);e||t.set(n.extendee.typeName,e=new Map),e.set(n.number,n)}e.set(n.typeName,n)},get(t){return e.get(t)},getFile(e){return n.get(e)},getMessage(t){let n=e.get(t);return n?.kind==`message`?n:void 0},getEnum(t){let n=e.get(t);return n?.kind==`enum`?n:void 0},getExtension(t){let n=e.get(t);return n?.kind==`extension`?n:void 0},getExtensionFor(e,n){return t.get(e.typeName)?.get(n)},getService(t){let n=e.get(t);return n?.kind==`service`?n:void 0}}}const WF={998:{fieldPresence:1,enumType:2,repeatedFieldEncoding:2,utf8Validation:3,messageEncoding:1,jsonFormat:2,enforceNamingStyle:2,defaultSymbolVisibility:1,enforceProtoLimits:1},999:{fieldPresence:2,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:2,defaultSymbolVisibility:1,enforceProtoLimits:1},1e3:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:2,defaultSymbolVisibility:1,enforceProtoLimits:1},1001:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:1,defaultSymbolVisibility:2,enforceProtoLimits:1},1002:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:3,defaultSymbolVisibility:4,enforceProtoLimits:2}};function GF(e,t){let n={kind:`file`,proto:e,deprecated:e.options?.deprecated??!1,edition:XDe(e),name:e.name.replace(/\.proto$/,``),dependencies:ZDe(e,t),enums:[],messages:[],extensions:[],services:[],toString(){return`file ${e.name}`}},r=new Map,i={get(e){return r.get(e)},add(e){tI(e.proto.options?.mapEntry===!0),r.set(e.typeName,e)}};for(let r of e.enumType)JF(r,n,void 0,t);for(let r of e.messageType)YF(r,n,void 0,t,i);for(let r of e.service)qDe(r,n,t);KF(n,t);for(let e of r.values())qF(e,t,i);for(let e of n.messages)qF(e,t,i),KF(e,t);t.addFile(n,!0)}function KF(e,t){switch(e.kind){case`file`:for(let n of e.proto.extension){let r=XF(n,e,t);e.extensions.push(r),t.add(r)}break;case`message`:for(let n of e.proto.extension){let r=XF(n,e,t);e.nestedExtensions.push(r),t.add(r)}for(let n of e.nestedMessages)KF(n,t)}}function qF(e,t,n){let r=e.proto.oneofDecl.map(t=>YDe(t,e)),i=new Set;for(let a of e.proto.field){let o=tOe(a,r),s=XF(a,e,t,o,n);e.fields.push(s),e.field[s.localName]=s,o===void 0?e.members.push(s):(o.fields.push(s),i.has(o)||(i.add(o),e.members.push(o)))}for(let t of r.filter(e=>i.has(e)))e.oneofs.push(t);for(let r of e.nestedMessages)qF(r,t,n)}function JF(e,t,n,r){var i,a;let o=QDe(e.name,e.value),s={kind:`enum`,proto:e,deprecated:e.options?.deprecated??!1,file:t,parent:n,open:!0,name:e.name,typeName:ZF(e,n,t),value:{},values:[],sharedPrefix:o,toString(){return`enum ${this.typeName}`}};s.open=aOe(s),r.add(s);for(let t of e.value){let e=t.name,n={kind:`enum_value`,proto:t,deprecated:t.options?.deprecated??!1,parent:s,name:e,localName:BF(o==null?e:e.substring(o.length)),number:t.number,jsonName:$De(t)??e,toString(){return`enum value ${s.typeName}.${e}`}};s.values.push(n),(i=s.value)[a=t.number]??(i[a]=n)}(n?.nestedEnums??t.enums).push(s)}function YF(e,t,n,r,i){let a={kind:`message`,proto:e,deprecated:e.options?.deprecated??!1,file:t,parent:n,name:e.name,typeName:ZF(e,n,t),fields:[],field:{},oneofs:[],members:[],nestedEnums:[],nestedMessages:[],nestedExtensions:[],toString(){return`message ${this.typeName}`}};e.options?.mapEntry===!0?i.add(a):((n?.nestedMessages??t.messages).push(a),r.add(a));for(let n of e.enumType)JF(n,t,a,r);for(let n of e.nestedType)YF(n,t,a,r,i)}function qDe(e,t,n){let r={kind:`service`,proto:e,deprecated:e.options?.deprecated??!1,file:t,name:e.name,typeName:ZF(e,void 0,t),methods:[],method:{},toString(){return`service ${this.typeName}`}};t.services.push(r),n.add(r);for(let t of e.method){let e=JDe(t,r,n);r.methods.push(e),r.method[e.localName]=e}}function JDe(e,t,n){let r;r=e.clientStreaming&&e.serverStreaming?`bidi_streaming`:e.clientStreaming?`client_streaming`:e.serverStreaming?`server_streaming`:`unary`;let i=n.getMessage(QF(e.inputType)),a=n.getMessage(QF(e.outputType));tI(i,`invalid MethodDescriptorProto: input_type ${e.inputType} not found`),tI(a,`invalid MethodDescriptorProto: output_type ${e.inputType} not found`);let o=e.name;return{kind:`rpc`,proto:e,deprecated:e.options?.deprecated??!1,parent:t,name:o,localName:BF(o.length?BF(o[0].toLowerCase()+o.substring(1)):o),methodKind:r,input:i,output:a,idempotency:e.options?.idempotencyLevel??0,toString(){return`rpc ${t.typeName}.${o}`}}}function YDe(e,t){return{kind:`oneof`,proto:e,deprecated:!1,parent:t,fields:[],name:e.name,localName:BF(RF(e.name)),toString(){return`oneof ${t.typeName}.${this.name}`}}}function XF(e,t,n,r,i){let a=i===void 0,o={kind:`field`,proto:e,deprecated:e.options?.deprecated??!1,name:e.name,number:e.number,scalar:void 0,message:void 0,enum:void 0,presence:nOe(e,r,a,t),utf8Validation:oOe(e,t),listKind:void 0,mapKind:void 0,mapKey:void 0,delimitedEncoding:void 0,packed:void 0,longAsString:!1,getDefaultValue:void 0},s;if(a){let r=t.kind==`file`?t:t.file,i=t.kind==`file`?void 0:t,a=ZF(e,i,r);o.kind=`extension`,o.file=r,o.parent=i,o.oneof=void 0,o.typeName=a,o.jsonName=`[${a}]`,s=()=>`extension ${a}`;let c=n.getMessage(QF(e.extendee));tI(c,`invalid FieldDescriptorProto: extendee ${e.extendee} not found`),o.extendee=c}else{let n=t;tI(n.kind==`message`),o.parent=n,o.oneof=r,o.localName=r?RF(e.name):BF(RF(e.name)),o.jsonName=e.jsonName,s=()=>`field ${n.typeName}.${e.name}`}Object.defineProperty(o,"toString",{value:s,writable:!0,enumerable:!0,configurable:!0});let c=e.label,l=e.type,u=e.options?.jstype;if(c===3){let r=l==11?i?.get(QF(e.typeName)):void 0;if(r){o.fieldKind=`map`;let{key:e,value:t}=iOe(r);return o.mapKey=e.scalar,o.mapKind=t.fieldKind,o.message=t.message,o.delimitedEncoding=!1,o.enum=t.enum,o.scalar=t.scalar,o}switch(o.fieldKind=`list`,l){case 11:case 10:o.listKind=`message`,o.message=n.getMessage(QF(e.typeName)),tI(o.message),o.delimitedEncoding=$F(e,t);break;case 14:o.listKind=`enum`,o.enum=n.getEnum(QF(e.typeName)),tI(o.enum);break;default:o.listKind=`scalar`,o.scalar=l,o.longAsString=u==1}return o.packed=rOe(e,t),o}switch(l){case 11:case 10:o.fieldKind=`message`,o.message=n.getMessage(QF(e.typeName)),tI(o.message,`invalid FieldDescriptorProto: type_name ${e.typeName} not found`),o.delimitedEncoding=$F(e,t),o.getDefaultValue=()=>void 0;break;case 14:{let t=n.getEnum(QF(e.typeName));tI(t!==void 0,`invalid FieldDescriptorProto: type_name ${e.typeName} not found`),o.fieldKind=`enum`,o.enum=n.getEnum(QF(e.typeName)),o.getDefaultValue=()=>MP(e,`defaultValue`)?HDe(t,e.defaultValue):void 0;break}default:o.fieldKind=`scalar`,o.scalar=l,o.longAsString=u==1,o.getDefaultValue=()=>MP(e,`defaultValue`)?UDe(l,e.defaultValue):void 0}return o}function XDe(e){switch(e.syntax){case``:case`proto2`:return 998;case`proto3`:return 999;case`editions`:if(e.edition===9999)return 1002;if(e.edition in WF)return e.edition;throw Error(`${e.name}: unsupported edition`);default:throw Error(`${e.name}: unsupported syntax "${e.syntax}"`)}}function ZDe(e,t){return e.dependency.map(n=>{let r=t.getFile(n);if(!r)throw Error(`Cannot find ${n}, imported by ${e.name}`);return r})}function QDe(e,t){let n=eOe(e)+`_`;for(let e of t){if(!e.name.toLowerCase().startsWith(n))return;let t=e.name.substring(n.length);if(t.length==0||/^\d/.test(t))return}return n}function $De(e){let t;for(let n of e.options?.$unknown??[]){if(n.no!==998||n.wireType!==XP.LengthDelimited)continue;let e=new tF(new tF(n.data).bytes());for(;e.pos<e.len;){let[n,r]=e.tag();n===1&&r===XP.LengthDelimited?t=e.string():e.skip(r,n)}}return t}function eOe(e){return(e.substring(0,1)+e.substring(1).replace(/[A-Z]/g,e=>`_`+e)).toLowerCase()}function ZF(e,t,n){let r;return r=t?`${t.typeName}.${e.name}`:n.proto.package.length>0?`${n.proto.package}.${e.name}`:`${e.name}`,r}function QF(e){return e.startsWith(`.`)?e.substring(1):e}function tOe(e,t){if(!MP(e,`oneofIndex`)||e.proto3Optional)return;let n=t[e.oneofIndex];return tI(n,`invalid FieldDescriptorProto: oneof #${e.oneofIndex} for field #${e.number} not found`),n}function nOe(e,t,n,r){if(e.label==2)return 3;if(e.label==3)return 2;if(t||e.proto3Optional||n)return 1;let i=eI(`fieldPresence`,{proto:e,parent:r});return i==2&&(e.type==11||e.type==10)?1:i}function rOe(e,t){if(e.label!=3)return!1;switch(e.type){case 9:case 12:case 10:case 11:return!1}let n=e.options;return n&&MP(n,`packed`)?n.packed:eI(`repeatedFieldEncoding`,{proto:e,parent:t})==1}function iOe(e){let t=e.fields.find(e=>e.number===1),n=e.fields.find(e=>e.number===2);return tI(t&&t.fieldKind==`scalar`&&t.scalar!=V.BYTES&&t.scalar!=V.FLOAT&&t.scalar!=V.DOUBLE&&n&&n.fieldKind!=`list`&&n.fieldKind!=`map`),{key:t,value:n}}function aOe(e){return eI(`enumType`,{proto:e.proto,parent:e.parent??e.file})==1}function $F(e,t){return e.type==10||eI(`messageEncoding`,{proto:e,parent:t})==2}function oOe(e,t){return eI(`utf8Validation`,{proto:e,parent:t})==2}function eI(e,t){let n=t.proto.options?.features;if(n){let t=n[e];if(t!=0)return t}if(`kind`in t){if(t.kind==`message`)return eI(e,t.parent??t.file);let n=WF[t.edition];if(!n)throw Error(`feature default for edition ${t.edition} not found`);return n[e]}return eI(e,t.parent)}function tI(e,t){if(!e)throw Error(t)}function sOe(e){let t=cOe(e);return t.messageType.forEach(VF),UF(t,()=>void 0).getFile(t.name)}function cOe(e){return Object.assign(Object.create({syntax:``,edition:0}),Object.assign(Object.assign({$typeName:`google.protobuf.FileDescriptorProto`,dependency:[],publicDependency:[],weakDependency:[],optionDependency:[],service:[],extension:[]},e),{messageType:e.messageType.map(nI),enumType:e.enumType.map(rI)}))}function nI(e){return Object.assign(Object.create({visibility:0}),{$typeName:`google.protobuf.DescriptorProto`,name:e.name,field:e.field?.map(lOe)??[],extension:[],nestedType:e.nestedType?.map(nI)??[],enumType:e.enumType?.map(rI)??[],extensionRange:e.extensionRange?.map(e=>Object.assign({$typeName:`google.protobuf.DescriptorProto.ExtensionRange`},e))??[],oneofDecl:[],reservedRange:[],reservedName:[]})}function lOe(e){return Object.assign(Object.create({label:1,typeName:``,extendee:``,defaultValue:``,oneofIndex:0,jsonName:``,proto3Optional:!1}),Object.assign(Object.assign({$typeName:`google.protobuf.FieldDescriptorProto`},e),{options:e.options?uOe(e.options):void 0}))}function uOe(e){return Object.assign(Object.create({ctype:0,packed:!1,jstype:0,lazy:!1,unverifiedLazy:!1,deprecated:!1,weak:!1,debugRedact:!1,retention:0}),Object.assign(Object.assign({$typeName:`google.protobuf.FieldOptions`},e),{targets:e.targets??[],editionDefaults:e.editionDefaults?.map(e=>Object.assign({$typeName:`google.protobuf.FieldOptions.EditionDefault`},e))??[],uninterpretedOption:[]}))}function rI(e){return Object.assign(Object.create({visibility:0}),{$typeName:`google.protobuf.EnumDescriptorProto`,name:e.name,reservedName:[],reservedRange:[],value:e.value.map(e=>Object.assign({$typeName:`google.protobuf.EnumValueDescriptorProto`},e))})}function iI(e,t,...n){return n.reduce((e,t)=>e.nestedMessages[t],e.messages[t])}const dOe=iI(sOe({name:`google/protobuf/descriptor.proto`,package:`google.protobuf`,messageType:[{name:`FileDescriptorSet`,field:[{name:`file`,number:1,type:11,label:3,typeName:`.google.protobuf.FileDescriptorProto`}],extensionRange:[{start:536e6,end:536000001}]},{name:`FileDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`package`,number:2,type:9,label:1},{name:`dependency`,number:3,type:9,label:3},{name:`public_dependency`,number:10,type:5,label:3},{name:`weak_dependency`,number:11,type:5,label:3},{name:`option_dependency`,number:15,type:9,label:3},{name:`message_type`,number:4,type:11,label:3,typeName:`.google.protobuf.DescriptorProto`},{name:`enum_type`,number:5,type:11,label:3,typeName:`.google.protobuf.EnumDescriptorProto`},{name:`service`,number:6,type:11,label:3,typeName:`.google.protobuf.ServiceDescriptorProto`},{name:`extension`,number:7,type:11,label:3,typeName:`.google.protobuf.FieldDescriptorProto`},{name:`options`,number:8,type:11,label:1,typeName:`.google.protobuf.FileOptions`},{name:`source_code_info`,number:9,type:11,label:1,typeName:`.google.protobuf.SourceCodeInfo`},{name:`syntax`,number:12,type:9,label:1},{name:`edition`,number:14,type:14,label:1,typeName:`.google.protobuf.Edition`}]},{name:`DescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`field`,number:2,type:11,label:3,typeName:`.google.protobuf.FieldDescriptorProto`},{name:`extension`,number:6,type:11,label:3,typeName:`.google.protobuf.FieldDescriptorProto`},{name:`nested_type`,number:3,type:11,label:3,typeName:`.google.protobuf.DescriptorProto`},{name:`enum_type`,number:4,type:11,label:3,typeName:`.google.protobuf.EnumDescriptorProto`},{name:`extension_range`,number:5,type:11,label:3,typeName:`.google.protobuf.DescriptorProto.ExtensionRange`},{name:`oneof_decl`,number:8,type:11,label:3,typeName:`.google.protobuf.OneofDescriptorProto`},{name:`options`,number:7,type:11,label:1,typeName:`.google.protobuf.MessageOptions`},{name:`reserved_range`,number:9,type:11,label:3,typeName:`.google.protobuf.DescriptorProto.ReservedRange`},{name:`reserved_name`,number:10,type:9,label:3},{name:`visibility`,number:11,type:14,label:1,typeName:`.google.protobuf.SymbolVisibility`}],nestedType:[{name:`ExtensionRange`,field:[{name:`start`,number:1,type:5,label:1},{name:`end`,number:2,type:5,label:1},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.ExtensionRangeOptions`}]},{name:`ReservedRange`,field:[{name:`start`,number:1,type:5,label:1},{name:`end`,number:2,type:5,label:1}]}]},{name:`ExtensionRangeOptions`,field:[{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`},{name:`declaration`,number:2,type:11,label:3,typeName:`.google.protobuf.ExtensionRangeOptions.Declaration`,options:{retention:2}},{name:`features`,number:50,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`verification`,number:3,type:14,label:1,typeName:`.google.protobuf.ExtensionRangeOptions.VerificationState`,defaultValue:`UNVERIFIED`,options:{retention:2}}],nestedType:[{name:`Declaration`,field:[{name:`number`,number:1,type:5,label:1},{name:`full_name`,number:2,type:9,label:1},{name:`type`,number:3,type:9,label:1},{name:`reserved`,number:5,type:8,label:1},{name:`repeated`,number:6,type:8,label:1}]}],enumType:[{name:`VerificationState`,value:[{name:`DECLARATION`,number:0},{name:`UNVERIFIED`,number:1}]}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`FieldDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`number`,number:3,type:5,label:1},{name:`label`,number:4,type:14,label:1,typeName:`.google.protobuf.FieldDescriptorProto.Label`},{name:`type`,number:5,type:14,label:1,typeName:`.google.protobuf.FieldDescriptorProto.Type`},{name:`type_name`,number:6,type:9,label:1},{name:`extendee`,number:2,type:9,label:1},{name:`default_value`,number:7,type:9,label:1},{name:`oneof_index`,number:9,type:5,label:1},{name:`json_name`,number:10,type:9,label:1},{name:`options`,number:8,type:11,label:1,typeName:`.google.protobuf.FieldOptions`},{name:`proto3_optional`,number:17,type:8,label:1}],enumType:[{name:`Type`,value:[{name:`TYPE_DOUBLE`,number:1},{name:`TYPE_FLOAT`,number:2},{name:`TYPE_INT64`,number:3},{name:`TYPE_UINT64`,number:4},{name:`TYPE_INT32`,number:5},{name:`TYPE_FIXED64`,number:6},{name:`TYPE_FIXED32`,number:7},{name:`TYPE_BOOL`,number:8},{name:`TYPE_STRING`,number:9},{name:`TYPE_GROUP`,number:10},{name:`TYPE_MESSAGE`,number:11},{name:`TYPE_BYTES`,number:12},{name:`TYPE_UINT32`,number:13},{name:`TYPE_ENUM`,number:14},{name:`TYPE_SFIXED32`,number:15},{name:`TYPE_SFIXED64`,number:16},{name:`TYPE_SINT32`,number:17},{name:`TYPE_SINT64`,number:18}]},{name:`Label`,value:[{name:`LABEL_OPTIONAL`,number:1},{name:`LABEL_REPEATED`,number:3},{name:`LABEL_REQUIRED`,number:2}]}]},{name:`OneofDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`options`,number:2,type:11,label:1,typeName:`.google.protobuf.OneofOptions`}]},{name:`EnumDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`value`,number:2,type:11,label:3,typeName:`.google.protobuf.EnumValueDescriptorProto`},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.EnumOptions`},{name:`reserved_range`,number:4,type:11,label:3,typeName:`.google.protobuf.EnumDescriptorProto.EnumReservedRange`},{name:`reserved_name`,number:5,type:9,label:3},{name:`visibility`,number:6,type:14,label:1,typeName:`.google.protobuf.SymbolVisibility`}],nestedType:[{name:`EnumReservedRange`,field:[{name:`start`,number:1,type:5,label:1},{name:`end`,number:2,type:5,label:1}]}]},{name:`EnumValueDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`number`,number:2,type:5,label:1},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.EnumValueOptions`}]},{name:`ServiceDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`method`,number:2,type:11,label:3,typeName:`.google.protobuf.MethodDescriptorProto`},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.ServiceOptions`}]},{name:`MethodDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`input_type`,number:2,type:9,label:1},{name:`output_type`,number:3,type:9,label:1},{name:`options`,number:4,type:11,label:1,typeName:`.google.protobuf.MethodOptions`},{name:`client_streaming`,number:5,type:8,label:1,defaultValue:`false`},{name:`server_streaming`,number:6,type:8,label:1,defaultValue:`false`}]},{name:`FileOptions`,field:[{name:`java_package`,number:1,type:9,label:1},{name:`java_outer_classname`,number:8,type:9,label:1},{name:`java_multiple_files`,number:10,type:8,label:1,defaultValue:`false`,options:{}},{name:`java_generate_equals_and_hash`,number:20,type:8,label:1,options:{deprecated:!0}},{name:`java_string_check_utf8`,number:27,type:8,label:1,defaultValue:`false`},{name:`optimize_for`,number:9,type:14,label:1,typeName:`.google.protobuf.FileOptions.OptimizeMode`,defaultValue:`SPEED`},{name:`go_package`,number:11,type:9,label:1},{name:`cc_generic_services`,number:16,type:8,label:1,defaultValue:`false`},{name:`java_generic_services`,number:17,type:8,label:1,defaultValue:`false`},{name:`py_generic_services`,number:18,type:8,label:1,defaultValue:`false`},{name:`deprecated`,number:23,type:8,label:1,defaultValue:`false`},{name:`cc_enable_arenas`,number:31,type:8,label:1,defaultValue:`true`,options:{}},{name:`objc_class_prefix`,number:36,type:9,label:1},{name:`csharp_namespace`,number:37,type:9,label:1},{name:`swift_prefix`,number:39,type:9,label:1},{name:`php_class_prefix`,number:40,type:9,label:1},{name:`php_namespace`,number:41,type:9,label:1},{name:`php_metadata_namespace`,number:44,type:9,label:1},{name:`ruby_package`,number:45,type:9,label:1},{name:`features`,number:50,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],enumType:[{name:`OptimizeMode`,value:[{name:`SPEED`,number:1},{name:`CODE_SIZE`,number:2},{name:`LITE_RUNTIME`,number:3}]}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`MessageOptions`,field:[{name:`message_set_wire_format`,number:1,type:8,label:1,defaultValue:`false`},{name:`no_standard_descriptor_accessor`,number:2,type:8,label:1,defaultValue:`false`},{name:`deprecated`,number:3,type:8,label:1,defaultValue:`false`},{name:`map_entry`,number:7,type:8,label:1},{name:`deprecated_legacy_json_field_conflicts`,number:11,type:8,label:1,options:{deprecated:!0}},{name:`features`,number:12,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`FieldOptions`,field:[{name:`ctype`,number:1,type:14,label:1,typeName:`.google.protobuf.FieldOptions.CType`,defaultValue:`STRING`},{name:`packed`,number:2,type:8,label:1},{name:`jstype`,number:6,type:14,label:1,typeName:`.google.protobuf.FieldOptions.JSType`,defaultValue:`JS_NORMAL`},{name:`lazy`,number:5,type:8,label:1,defaultValue:`false`},{name:`unverified_lazy`,number:15,type:8,label:1,defaultValue:`false`},{name:`deprecated`,number:3,type:8,label:1,defaultValue:`false`},{name:`weak`,number:10,type:8,label:1,defaultValue:`false`,options:{deprecated:!0}},{name:`debug_redact`,number:16,type:8,label:1,defaultValue:`false`},{name:`retention`,number:17,type:14,label:1,typeName:`.google.protobuf.FieldOptions.OptionRetention`},{name:`targets`,number:19,type:14,label:3,typeName:`.google.protobuf.FieldOptions.OptionTargetType`},{name:`edition_defaults`,number:20,type:11,label:3,typeName:`.google.protobuf.FieldOptions.EditionDefault`},{name:`features`,number:21,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`feature_support`,number:22,type:11,label:1,typeName:`.google.protobuf.FieldOptions.FeatureSupport`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],nestedType:[{name:`EditionDefault`,field:[{name:`edition`,number:3,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`value`,number:2,type:9,label:1}]},{name:`FeatureSupport`,field:[{name:`edition_introduced`,number:1,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`edition_deprecated`,number:2,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`deprecation_warning`,number:3,type:9,label:1},{name:`edition_removed`,number:4,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`removal_error`,number:5,type:9,label:1}]}],enumType:[{name:`CType`,value:[{name:`STRING`,number:0},{name:`CORD`,number:1},{name:`STRING_PIECE`,number:2}]},{name:`JSType`,value:[{name:`JS_NORMAL`,number:0},{name:`JS_STRING`,number:1},{name:`JS_NUMBER`,number:2}]},{name:`OptionRetention`,value:[{name:`RETENTION_UNKNOWN`,number:0},{name:`RETENTION_RUNTIME`,number:1},{name:`RETENTION_SOURCE`,number:2}]},{name:`OptionTargetType`,value:[{name:`TARGET_TYPE_UNKNOWN`,number:0},{name:`TARGET_TYPE_FILE`,number:1},{name:`TARGET_TYPE_EXTENSION_RANGE`,number:2},{name:`TARGET_TYPE_MESSAGE`,number:3},{name:`TARGET_TYPE_FIELD`,number:4},{name:`TARGET_TYPE_ONEOF`,number:5},{name:`TARGET_TYPE_ENUM`,number:6},{name:`TARGET_TYPE_ENUM_ENTRY`,number:7},{name:`TARGET_TYPE_SERVICE`,number:8},{name:`TARGET_TYPE_METHOD`,number:9}]}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`OneofOptions`,field:[{name:`features`,number:1,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`EnumOptions`,field:[{name:`allow_alias`,number:2,type:8,label:1},{name:`deprecated`,number:3,type:8,label:1,defaultValue:`false`},{name:`deprecated_legacy_json_field_conflicts`,number:6,type:8,label:1,options:{deprecated:!0}},{name:`features`,number:7,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`EnumValueOptions`,field:[{name:`deprecated`,number:1,type:8,label:1,defaultValue:`false`},{name:`features`,number:2,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`debug_redact`,number:3,type:8,label:1,defaultValue:`false`},{name:`feature_support`,number:4,type:11,label:1,typeName:`.google.protobuf.FieldOptions.FeatureSupport`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`ServiceOptions`,field:[{name:`features`,number:34,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`deprecated`,number:33,type:8,label:1,defaultValue:`false`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`MethodOptions`,field:[{name:`deprecated`,number:33,type:8,label:1,defaultValue:`false`},{name:`idempotency_level`,number:34,type:14,label:1,typeName:`.google.protobuf.MethodOptions.IdempotencyLevel`,defaultValue:`IDEMPOTENCY_UNKNOWN`},{name:`features`,number:35,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],enumType:[{name:`IdempotencyLevel`,value:[{name:`IDEMPOTENCY_UNKNOWN`,number:0},{name:`NO_SIDE_EFFECTS`,number:1},{name:`IDEMPOTENT`,number:2}]}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`UninterpretedOption`,field:[{name:`name`,number:2,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption.NamePart`},{name:`identifier_value`,number:3,type:9,label:1},{name:`positive_int_value`,number:4,type:4,label:1},{name:`negative_int_value`,number:5,type:3,label:1},{name:`double_value`,number:6,type:1,label:1},{name:`string_value`,number:7,type:12,label:1},{name:`aggregate_value`,number:8,type:9,label:1}],nestedType:[{name:`NamePart`,field:[{name:`name_part`,number:1,type:9,label:2},{name:`is_extension`,number:2,type:8,label:2}]}]},{name:`FeatureSet`,field:[{name:`field_presence`,number:1,type:14,label:1,typeName:`.google.protobuf.FeatureSet.FieldPresence`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`EXPLICIT`,edition:900},{value:`IMPLICIT`,edition:999},{value:`EXPLICIT`,edition:1e3}]}},{name:`enum_type`,number:2,type:14,label:1,typeName:`.google.protobuf.FeatureSet.EnumType`,options:{retention:1,targets:[6,1],editionDefaults:[{value:`CLOSED`,edition:900},{value:`OPEN`,edition:999}]}},{name:`repeated_field_encoding`,number:3,type:14,label:1,typeName:`.google.protobuf.FeatureSet.RepeatedFieldEncoding`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`EXPANDED`,edition:900},{value:`PACKED`,edition:999}]}},{name:`utf8_validation`,number:4,type:14,label:1,typeName:`.google.protobuf.FeatureSet.Utf8Validation`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`NONE`,edition:900},{value:`VERIFY`,edition:999}]}},{name:`message_encoding`,number:5,type:14,label:1,typeName:`.google.protobuf.FeatureSet.MessageEncoding`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`LENGTH_PREFIXED`,edition:900}]}},{name:`json_format`,number:6,type:14,label:1,typeName:`.google.protobuf.FeatureSet.JsonFormat`,options:{retention:1,targets:[3,6,1],editionDefaults:[{value:`LEGACY_BEST_EFFORT`,edition:900},{value:`ALLOW`,edition:999}]}},{name:`enforce_naming_style`,number:7,type:14,label:1,typeName:`.google.protobuf.FeatureSet.EnforceNamingStyle`,options:{retention:2,targets:[1,2,3,4,5,6,7,8,9],editionDefaults:[{value:`STYLE_LEGACY`,edition:900},{value:`STYLE2024`,edition:1001},{value:`STYLE2026`,edition:1002}]}},{name:`default_symbol_visibility`,number:8,type:14,label:1,typeName:`.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility`,options:{retention:2,targets:[1],editionDefaults:[{value:`EXPORT_ALL`,edition:900},{value:`EXPORT_TOP_LEVEL`,edition:1001},{value:`STRICT`,edition:1002}]}},{name:`enforce_proto_limits`,number:9,type:14,label:1,typeName:`.google.protobuf.FeatureSet.ProtoLimitsFeature.EnforceProtoLimits`,options:{retention:2,targets:[6,3,4,5],editionDefaults:[{value:`LEGACY_NO_EXPLICIT_LIMITS`,edition:900},{value:`PROTO_LIMITS2026`,edition:1002}]}}],nestedType:[{name:`VisibilityFeature`,enumType:[{name:`DefaultSymbolVisibility`,value:[{name:`DEFAULT_SYMBOL_VISIBILITY_UNKNOWN`,number:0},{name:`EXPORT_ALL`,number:1},{name:`EXPORT_TOP_LEVEL`,number:2},{name:`LOCAL_ALL`,number:3},{name:`STRICT`,number:4}]}]},{name:`ProtoLimitsFeature`,enumType:[{name:`EnforceProtoLimits`,value:[{name:`PROTO_LIMITS_UNKNOWN`,number:0},{name:`LEGACY_NO_EXPLICIT_LIMITS`,number:1},{name:`PROTO_LIMITS2026`,number:2}]}]}],enumType:[{name:`FieldPresence`,value:[{name:`FIELD_PRESENCE_UNKNOWN`,number:0},{name:`EXPLICIT`,number:1},{name:`IMPLICIT`,number:2},{name:`LEGACY_REQUIRED`,number:3}]},{name:`EnumType`,value:[{name:`ENUM_TYPE_UNKNOWN`,number:0},{name:`OPEN`,number:1},{name:`CLOSED`,number:2}]},{name:`RepeatedFieldEncoding`,value:[{name:`REPEATED_FIELD_ENCODING_UNKNOWN`,number:0},{name:`PACKED`,number:1},{name:`EXPANDED`,number:2}]},{name:`Utf8Validation`,value:[{name:`UTF8_VALIDATION_UNKNOWN`,number:0},{name:`VERIFY`,number:2},{name:`NONE`,number:3}]},{name:`MessageEncoding`,value:[{name:`MESSAGE_ENCODING_UNKNOWN`,number:0},{name:`LENGTH_PREFIXED`,number:1},{name:`DELIMITED`,number:2}]},{name:`JsonFormat`,value:[{name:`JSON_FORMAT_UNKNOWN`,number:0},{name:`ALLOW`,number:1},{name:`LEGACY_BEST_EFFORT`,number:2}]},{name:`EnforceNamingStyle`,value:[{name:`ENFORCE_NAMING_STYLE_UNKNOWN`,number:0},{name:`STYLE2024`,number:1},{name:`STYLE_LEGACY`,number:2},{name:`STYLE2026`,number:3}]}],extensionRange:[{start:1e3,end:9995},{start:9995,end:1e4},{start:1e4,end:10001}]},{name:`FeatureSetDefaults`,field:[{name:`defaults`,number:1,type:11,label:3,typeName:`.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault`},{name:`minimum_edition`,number:4,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`maximum_edition`,number:5,type:14,label:1,typeName:`.google.protobuf.Edition`}],nestedType:[{name:`FeatureSetEditionDefault`,field:[{name:`edition`,number:3,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`overridable_features`,number:4,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`fixed_features`,number:5,type:11,label:1,typeName:`.google.protobuf.FeatureSet`}]}]},{name:`SourceCodeInfo`,field:[{name:`location`,number:1,type:11,label:3,typeName:`.google.protobuf.SourceCodeInfo.Location`}],nestedType:[{name:`Location`,field:[{name:`path`,number:1,type:5,label:3,options:{packed:!0}},{name:`span`,number:2,type:5,label:3,options:{packed:!0}},{name:`leading_comments`,number:3,type:9,label:1},{name:`trailing_comments`,number:4,type:9,label:1},{name:`leading_detached_comments`,number:6,type:9,label:3}]}],extensionRange:[{start:536e6,end:536000001}]},{name:`GeneratedCodeInfo`,field:[{name:`annotation`,number:1,type:11,label:3,typeName:`.google.protobuf.GeneratedCodeInfo.Annotation`}],nestedType:[{name:`Annotation`,field:[{name:`path`,number:1,type:5,label:3,options:{packed:!0}},{name:`source_file`,number:2,type:9,label:1},{name:`begin`,number:3,type:5,label:1},{name:`end`,number:4,type:5,label:1},{name:`semantic`,number:5,type:14,label:1,typeName:`.google.protobuf.GeneratedCodeInfo.Annotation.Semantic`}],enumType:[{name:`Semantic`,value:[{name:`NONE`,number:0},{name:`SET`,number:1},{name:`ALIAS`,number:2}]}]}]}],enumType:[{name:`Edition`,value:[{name:`EDITION_UNKNOWN`,number:0},{name:`EDITION_LEGACY`,number:900},{name:`EDITION_PROTO2`,number:998},{name:`EDITION_PROTO3`,number:999},{name:`EDITION_2023`,number:1e3},{name:`EDITION_2024`,number:1001},{name:`EDITION_2026`,number:1002},{name:`EDITION_UNSTABLE`,number:9999},{name:`EDITION_1_TEST_ONLY`,number:1},{name:`EDITION_2_TEST_ONLY`,number:2},{name:`EDITION_99997_TEST_ONLY`,number:99997},{name:`EDITION_99998_TEST_ONLY`,number:99998},{name:`EDITION_99999_TEST_ONLY`,number:99999},{name:`EDITION_MAX`,number:2147483647}]},{name:`SymbolVisibility`,value:[{name:`VISIBILITY_UNSET`,number:0},{name:`VISIBILITY_LOCAL`,number:1},{name:`VISIBILITY_EXPORT`,number:2}]}]}),1);var fOe;(function(e){e[e.DECLARATION=0]=`DECLARATION`,e[e.UNVERIFIED=1]=`UNVERIFIED`})(fOe||={});var pOe;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.GROUP=10]=`GROUP`,e[e.MESSAGE=11]=`MESSAGE`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.ENUM=14]=`ENUM`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`})(pOe||={});var mOe;(function(e){e[e.OPTIONAL=1]=`OPTIONAL`,e[e.REPEATED=3]=`REPEATED`,e[e.REQUIRED=2]=`REQUIRED`})(mOe||={});var hOe;(function(e){e[e.SPEED=1]=`SPEED`,e[e.CODE_SIZE=2]=`CODE_SIZE`,e[e.LITE_RUNTIME=3]=`LITE_RUNTIME`})(hOe||={});var gOe;(function(e){e[e.STRING=0]=`STRING`,e[e.CORD=1]=`CORD`,e[e.STRING_PIECE=2]=`STRING_PIECE`})(gOe||={});var _Oe;(function(e){e[e.JS_NORMAL=0]=`JS_NORMAL`,e[e.JS_STRING=1]=`JS_STRING`,e[e.JS_NUMBER=2]=`JS_NUMBER`})(_Oe||={});var vOe;(function(e){e[e.RETENTION_UNKNOWN=0]=`RETENTION_UNKNOWN`,e[e.RETENTION_RUNTIME=1]=`RETENTION_RUNTIME`,e[e.RETENTION_SOURCE=2]=`RETENTION_SOURCE`})(vOe||={});var yOe;(function(e){e[e.TARGET_TYPE_UNKNOWN=0]=`TARGET_TYPE_UNKNOWN`,e[e.TARGET_TYPE_FILE=1]=`TARGET_TYPE_FILE`,e[e.TARGET_TYPE_EXTENSION_RANGE=2]=`TARGET_TYPE_EXTENSION_RANGE`,e[e.TARGET_TYPE_MESSAGE=3]=`TARGET_TYPE_MESSAGE`,e[e.TARGET_TYPE_FIELD=4]=`TARGET_TYPE_FIELD`,e[e.TARGET_TYPE_ONEOF=5]=`TARGET_TYPE_ONEOF`,e[e.TARGET_TYPE_ENUM=6]=`TARGET_TYPE_ENUM`,e[e.TARGET_TYPE_ENUM_ENTRY=7]=`TARGET_TYPE_ENUM_ENTRY`,e[e.TARGET_TYPE_SERVICE=8]=`TARGET_TYPE_SERVICE`,e[e.TARGET_TYPE_METHOD=9]=`TARGET_TYPE_METHOD`})(yOe||={});var aI;(function(e){e[e.IDEMPOTENCY_UNKNOWN=0]=`IDEMPOTENCY_UNKNOWN`,e[e.NO_SIDE_EFFECTS=1]=`NO_SIDE_EFFECTS`,e[e.IDEMPOTENT=2]=`IDEMPOTENT`})(aI||={});var bOe;(function(e){e[e.DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0]=`DEFAULT_SYMBOL_VISIBILITY_UNKNOWN`,e[e.EXPORT_ALL=1]=`EXPORT_ALL`,e[e.EXPORT_TOP_LEVEL=2]=`EXPORT_TOP_LEVEL`,e[e.LOCAL_ALL=3]=`LOCAL_ALL`,e[e.STRICT=4]=`STRICT`})(bOe||={});var xOe;(function(e){e[e.PROTO_LIMITS_UNKNOWN=0]=`PROTO_LIMITS_UNKNOWN`,e[e.LEGACY_NO_EXPLICIT_LIMITS=1]=`LEGACY_NO_EXPLICIT_LIMITS`,e[e.PROTO_LIMITS2026=2]=`PROTO_LIMITS2026`})(xOe||={});var SOe;(function(e){e[e.FIELD_PRESENCE_UNKNOWN=0]=`FIELD_PRESENCE_UNKNOWN`,e[e.EXPLICIT=1]=`EXPLICIT`,e[e.IMPLICIT=2]=`IMPLICIT`,e[e.LEGACY_REQUIRED=3]=`LEGACY_REQUIRED`})(SOe||={});var COe;(function(e){e[e.ENUM_TYPE_UNKNOWN=0]=`ENUM_TYPE_UNKNOWN`,e[e.OPEN=1]=`OPEN`,e[e.CLOSED=2]=`CLOSED`})(COe||={});var wOe;(function(e){e[e.REPEATED_FIELD_ENCODING_UNKNOWN=0]=`REPEATED_FIELD_ENCODING_UNKNOWN`,e[e.PACKED=1]=`PACKED`,e[e.EXPANDED=2]=`EXPANDED`})(wOe||={});var TOe;(function(e){e[e.UTF8_VALIDATION_UNKNOWN=0]=`UTF8_VALIDATION_UNKNOWN`,e[e.VERIFY=2]=`VERIFY`,e[e.NONE=3]=`NONE`})(TOe||={});var EOe;(function(e){e[e.MESSAGE_ENCODING_UNKNOWN=0]=`MESSAGE_ENCODING_UNKNOWN`,e[e.LENGTH_PREFIXED=1]=`LENGTH_PREFIXED`,e[e.DELIMITED=2]=`DELIMITED`})(EOe||={});var DOe;(function(e){e[e.JSON_FORMAT_UNKNOWN=0]=`JSON_FORMAT_UNKNOWN`,e[e.ALLOW=1]=`ALLOW`,e[e.LEGACY_BEST_EFFORT=2]=`LEGACY_BEST_EFFORT`})(DOe||={});var OOe;(function(e){e[e.ENFORCE_NAMING_STYLE_UNKNOWN=0]=`ENFORCE_NAMING_STYLE_UNKNOWN`,e[e.STYLE2024=1]=`STYLE2024`,e[e.STYLE_LEGACY=2]=`STYLE_LEGACY`,e[e.STYLE2026=3]=`STYLE2026`})(OOe||={});var kOe;(function(e){e[e.NONE=0]=`NONE`,e[e.SET=1]=`SET`,e[e.ALIAS=2]=`ALIAS`})(kOe||={});var AOe;(function(e){e[e.EDITION_UNKNOWN=0]=`EDITION_UNKNOWN`,e[e.EDITION_LEGACY=900]=`EDITION_LEGACY`,e[e.EDITION_PROTO2=998]=`EDITION_PROTO2`,e[e.EDITION_PROTO3=999]=`EDITION_PROTO3`,e[e.EDITION_2023=1e3]=`EDITION_2023`,e[e.EDITION_2024=1001]=`EDITION_2024`,e[e.EDITION_2026=1002]=`EDITION_2026`,e[e.EDITION_UNSTABLE=9999]=`EDITION_UNSTABLE`,e[e.EDITION_1_TEST_ONLY=1]=`EDITION_1_TEST_ONLY`,e[e.EDITION_2_TEST_ONLY=2]=`EDITION_2_TEST_ONLY`,e[e.EDITION_99997_TEST_ONLY=99997]=`EDITION_99997_TEST_ONLY`,e[e.EDITION_99998_TEST_ONLY=99998]=`EDITION_99998_TEST_ONLY`,e[e.EDITION_99999_TEST_ONLY=99999]=`EDITION_99999_TEST_ONLY`,e[e.EDITION_MAX=2147483647]=`EDITION_MAX`})(AOe||={});var jOe;(function(e){e[e.VISIBILITY_UNSET=0]=`VISIBILITY_UNSET`,e[e.VISIBILITY_LOCAL=1]=`VISIBILITY_LOCAL`,e[e.VISIBILITY_EXPORT=2]=`VISIBILITY_EXPORT`})(jOe||={});function oI(e){return Object.assign(Object.assign({readUnknownFields:!0,recursionLimit:100},e),{depth:0})}function sI(e,t,n){let r=VP(e);return lI(e).read(r,new tF(t),oI(n),t.byteLength),r}const cI=new WeakMap;function lI(e){let t=cI.get(e);return t===void 0&&(t=MOe(e)),t}function MOe(e){let t=String(e),n=new Map,r={read:NOe(t,n),readGroup:POe(t,n)};cI.set(e,r);for(let t of e.fields)n.set(t.number,uI(t));return r}function NOe(e,t){return(n,r,i,a)=>{if(++i.depth>i.recursionLimit)throw Error(`cannot decode ${e} from binary: maximum recursion depth of ${i.recursionLimit} reached`);let o=r.pos+a,s=n.$unknown??[];for(;r.pos<o;){let[e,a]=r.tag(),o=t.get(e);if(o===void 0){let t=r.skip(a,e,i.recursionLimit-i.depth);i.readUnknownFields&&s.push({no:e,wireType:a,data:t});continue}o(n,r,i,a)}s.length>0&&(n.$unknown=s),i.depth--}}function POe(e,t){return(n,r,i,a)=>{if(++i.depth>i.recursionLimit)throw Error(`cannot decode ${e} from binary: maximum recursion depth of ${i.recursionLimit} reached`);let o,s,c=n.$unknown??[];for(;r.pos<r.len&&([o,s]=r.tag(),s!=XP.EndGroup);){let e=t.get(o);if(e===void 0){let e=r.skip(s,o,i.recursionLimit-i.depth);i.readUnknownFields&&c.push({no:o,wireType:s,data:e});continue}e(n,r,i,s)}if(s!=XP.EndGroup||o!==a)throw Error(`invalid end group tag`);c.length>0&&(n.$unknown=c),i.depth--}}function FOe(e,t,n,r,i){uI(n)(e[jP],t,i,r)}function uI(e){switch(e.fieldKind){case`scalar`:return IOe(e);case`enum`:return LOe(e);case`message`:return ROe(e);case`list`:return zOe(e);case`map`:return BOe(e)}}function IOe(e){let t=fI(e.scalar,e.utf8Validation,e.longAsString),n=e.localName;if(e.oneof){let r=e.oneof.localName;return(e,i)=>{e[r]={case:n,value:t(i)}}}return(e,r)=>{e[n]=t(r)}}function LOe(e){let t=e.localName,n=e.oneof?.localName;if(e.enum.open)return n===void 0?(e,n)=>{e[t]=n.int32()}:(e,r)=>{e[n]={case:t,value:r.int32()}};let r=e.enum.values,i=e.number;return(e,a,o,s)=>{let c=a.int32();if(r.some(e=>e.number===c))n===void 0?e[t]=c:e[n]={case:t,value:c};else if(o.readUnknownFields){let t=[];sDe(c,t);let n=e.$unknown??[];n.push({no:i,wireType:s,data:new Uint8Array(t)}),e.$unknown=n}}}function ROe(e){let t=e.localName,{toMessage:n,toLocal:r}=pF(e),i=dI(e);if(e.oneof){let a=e.oneof.localName;return(e,o,s)=>{let c=e[a],l=n(c.case===t?c.value:void 0);i(l,o,s),e[a]={case:t,value:r(l)}}}return(e,a,o)=>{let s=n(e[t]);i(s,a,o),e[t]=r(s)}}function dI(e){let t=lI(e.message);if(e.delimitedEncoding){let n=e.number;return(e,r,i)=>t.readGroup(e,r,i,n)}return(e,n,r)=>t.read(e,n,r,n.uint32())}function zOe(e){let t=e.localName;if(e.listKind==`message`){let{toMessage:n,toLocal:r}=pF(e),i=dI(e);return(e,a,o)=>{let s=n(void 0);i(s,a,o),e[t].push(r(s))}}let n=e.listKind==`enum`?V.INT32:e.scalar,r=e.listKind==`scalar`&&e.longAsString,i=fI(n,e.utf8Validation,r),a=n!=V.STRING&&n!=V.BYTES;return(e,n,r,o)=>{let s=e[t];if(o==XP.LengthDelimited&&a){let e=n.uint32()+n.pos;for(;n.pos<e;)s.push(i(n))}else s.push(i(n))}}function BOe(e){let t=e.localName,n=fI(e.mapKey,e.utf8Validation,!1),r=AP(e.mapKey,!1),i,a;switch(e.mapKind){case`scalar`:{let t=e.scalar,n=fI(t,e.utf8Validation,!1);if(i=e=>n(e),t==V.BYTES)a=()=>new Uint8Array;else{let e=AP(t,!1);a=()=>e}break}case`enum`:{let t=e.enum.values[0].number;i=e=>e.int32(),a=()=>t;break}case`message`:{let{toMessage:t,toLocal:n}=pF(e),r=lI(e.message).read;i=(e,i,a)=>{let o=t(a);return r(o,e,i,e.uint32()),n(o)},a=()=>n(t(void 0));break}}return(e,o,s)=>{let c=e[t],l,u,d=o.uint32(),f=o.pos+d;for(;o.pos<f;){let[e,t]=o.tag();switch(e){case 1:l=n(o);break;case 2:u=i(o,s,u);break;default:o.skip(t,e,s.recursionLimit-s.depth)}}l===void 0&&(l=r),u===void 0&&(u=a()),NP(c,l,u)}}function fI(e,t,n){switch(e){case V.STRING:return e=>e.string(t);case V.BOOL:return e=>e.bool();case V.DOUBLE:return e=>e.double();case V.FLOAT:return e=>e.float();case V.INT32:return e=>e.int32();case V.INT64:return n?e=>String(e.int64()):e=>e.int64();case V.UINT64:return n?e=>String(e.uint64()):e=>e.uint64();case V.FIXED64:return n?e=>String(e.fixed64()):e=>e.fixed64();case V.BYTES:return e=>e.bytes();case V.FIXED32:return e=>e.fixed32();case V.SFIXED32:return e=>e.sfixed32();case V.SFIXED64:return n?e=>String(e.sfixed64()):e=>e.sfixed64();case V.SINT64:return n?e=>String(e.sint64()):e=>e.sint64();case V.UINT32:return e=>e.uint32();case V.SINT32:return e=>e.sint32()}}function pI(e,t){let n=sI(dOe,jF(e));return n.messageType.forEach(VF),n.dependency=t?.map(e=>e.proto.name)??[],UF(n,e=>t?.find(t=>t.proto.name===e)).getFile(n.name)}const VOe=pI(`Ch9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnByb3RvEg9nb29nbGUucHJvdG9idWYiKwoJVGltZXN0YW1wEg8KB3NlY29uZHMYASABKAMSDQoFbmFub3MYAiABKAVChQEKE2NvbS5nb29nbGUucHJvdG9idWZCDlRpbWVzdGFtcFByb3RvUAFaMmdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3RpbWVzdGFtcHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM`),HOe=iI(pI(`Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYiJgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQnYKE2NvbS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaLGdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL2FueXBiogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM`),0),mI={writeUnknownFields:!0};function UOe(e){return e?Object.assign(Object.assign({},mI),e):mI}function hI(e,t,n){let r=new ZP;return _I(e)(r,UOe(n),t),r.finish()}const gI=new WeakMap;function _I(e){let t=gI.get(e);return t===void 0&&(t=WOe(e)),t}function WOe(e){let t=e.typeName,n=e.fields.concat().sort((e,t)=>e.number-t.number),r=n[0],i=[],a=(e,n,a)=>{if(a.$typeName!==t&&r!==void 0)throw new KP(r,`cannot use ${r} with message ${a.$typeName}`,`ForeignFieldError`);for(let t=0;t<i.length;t++)i[t](e,n,a);let o=a.$unknown;if(o!==void 0&&n.writeUnknownFields)for(let t=0;t<o.length;t++){let{no:n,wireType:r,data:i}=o[t];e.tag(n,r).raw(i)}};gI.set(e,a);for(let e of n)i.push(vI(e));return a}function vI(e){switch(e.fieldKind){case`message`:case`scalar`:case`enum`:return GOe(e);case`list`:return qOe(e);case`map`:return JOe(e)}}function GOe(e){let t=KOe(e),n=e.localName;if(e.oneof){let r=e.oneof.localName;return(e,i,a)=>{let o=a[r];o.case===n&&t(e,i,o.value)}}if(e.presence!=2){let r=e.presence==3?`cannot encode ${e} to binary: required field not set`:void 0;return(e,i,a)=>{let o=a[n];if(o!==void 0&&Object.prototype.hasOwnProperty.call(a,n))t(e,i,o);else if(r!==void 0)throw Error(r)}}if(e.fieldKind==`enum`){let r=e.enum.values[0].number;return(e,i,a)=>{let o=a[n];o!==r&&t(e,i,o)}}switch(e.scalar){case V.BOOL:return(e,r,i)=>{let a=i[n];a!==!1&&t(e,r,a)};case V.STRING:return(e,r,i)=>{let a=i[n];a!==``&&t(e,r,a)};case V.BYTES:return(e,r,i)=>{let a=i[n];(!(a instanceof Uint8Array)||a.byteLength>0)&&t(e,r,a)};case V.DOUBLE:case V.FLOAT:return(e,r,i)=>{let a=i[n];Object.is(a,0)||t(e,r,a)};default:return(e,r,i)=>{let a=i[n];a!=0&&t(e,r,a)}}}function KOe(e){switch(e.fieldKind){case`message`:{let{toMessage:t}=pF(e),n=bI(e);return(e,r,i)=>{n(e,r,t(i))}}case`scalar`:case`enum`:{let t=e.fieldKind==`enum`?V.INT32:e.scalar,n=e.number,r=xI(t),i=yI(t,e.parent.typeName,e.name);return(e,t,a)=>{e.tag(n,r),i(e,a)}}}}function qOe(e){let t=e.localName,n=e.number;switch(e.listKind){case`message`:{let{toMessage:n}=pF(e),r=bI(e);return(e,i,a)=>{let o=a[t];for(let t=0;t<o.length;t++)r(e,i,n(o[t]))}}case`scalar`:case`enum`:{let r=e.listKind==`enum`?V.INT32:e.scalar,i=yI(r,e.parent.typeName,e.name);if(e.packed)return(e,r,a)=>{let o=a[t];if(o.length!=0){e.tag(n,XP.LengthDelimited).fork();for(let t=0;t<o.length;t++)i(e,o[t]);e.join()}};let a=xI(r);return(e,r,o)=>{let s=o[t];for(let t=0;t<s.length;t++)e.tag(n,a),i(e,s[t])}}}}function JOe(e){let t=e.localName,n=e.number,r=YOe(e);if(e.mapKind==`message`){let{toMessage:i}=pF(e),a=_I(e.message);return(e,o,s)=>{let c=s[t],l=Object.keys(c);for(let t=0;t<l.length;t++){let s=l[t];e.tag(n,XP.LengthDelimited).fork(),r(e,s),e.tag(2,XP.LengthDelimited).fork(),a(e,o,i(c[s])),e.join(),e.join()}}}let i=e.mapKind==`enum`?V.INT32:e.scalar,a=xI(i),o=yI(i,e.parent.typeName,e.name);return(e,i,s)=>{let c=s[t],l=Object.keys(c);for(let t=0;t<l.length;t++){let i=l[t];e.tag(n,XP.LengthDelimited).fork(),r(e,i),e.tag(2,a),o(e,c[i]),e.join()}}}function YOe(e){let t=xI(e.mapKey),n=yI(e.mapKey,e.parent.typeName,e.name),r=XOe(e.mapKey);return(e,i)=>{e.tag(1,t),n(e,r(i))}}function XOe(e){switch(e){case V.STRING:return e=>e;case V.BOOL:return e=>e===`true`||e!==`false`&&e;case V.UINT64:case V.FIXED64:return e=>{try{return DP.uParse(e)}catch{return e}};case V.INT64:case V.SFIXED64:case V.SINT64:return e=>{try{return DP.parse(e)}catch{return e}};default:return e=>{let t=Number.parseInt(e);return Number.isFinite(t)?t:e}}}function yI(e,t,n){let r=ZOe(e);return(e,i)=>{try{r(e,i)}catch(e){throw e instanceof Error?Error(`cannot encode field ${t}.${n} to binary: ${e.message}`):e}}}function ZOe(e){switch(e){case V.STRING:return(e,t)=>e.string(t);case V.BOOL:return(e,t)=>e.bool(t);case V.DOUBLE:return(e,t)=>e.double(t);case V.FLOAT:return(e,t)=>e.float(t);case V.INT32:return(e,t)=>e.int32(t);case V.INT64:return(e,t)=>e.int64(t);case V.UINT64:return(e,t)=>e.uint64(t);case V.FIXED64:return(e,t)=>e.fixed64(t);case V.BYTES:return(e,t)=>e.bytes(t);case V.FIXED32:return(e,t)=>e.fixed32(t);case V.SFIXED32:return(e,t)=>e.sfixed32(t);case V.SFIXED64:return(e,t)=>e.sfixed64(t);case V.SINT64:return(e,t)=>e.sint64(t);case V.UINT32:return(e,t)=>e.uint32(t);case V.SINT32:return(e,t)=>e.sint32(t)}}function QOe(e,t,n,r){vI(r)(e,t,n[jP])}function bI(e){let t=e.number,n=_I(e.message);return e.delimitedEncoding?(e,r,i)=>{e.tag(t,XP.StartGroup),n(e,r,i),e.tag(t,XP.EndGroup)}:(e,r,i)=>{e.tag(t,XP.LengthDelimited).fork(),n(e,r,i),e.join()}}function xI(e){switch(e){case V.BYTES:case V.STRING:return XP.LengthDelimited;case V.DOUBLE:case V.FIXED64:case V.SFIXED64:return XP.Bit64;case V.FIXED32:case V.SFIXED32:case V.FLOAT:return XP.Bit32;default:return XP.Varint}}function $Oe(e,t,n){let r=!1;return n||(n=VP(HOe),r=!0),n.value=hI(e,t),n.typeUrl=nke(t.$typeName),r?n:void 0}function eke(e,t){return e.typeUrl!==``&&(typeof t==`string`?t:t.typeName)===SI(e.typeUrl)}function tke(e,t){if(e.typeUrl===``)return;let n=t.kind==`message`?t:t.getMessage(SI(e.typeUrl));if(n&&eke(e,n))return sI(n,e.value)}function nke(e){return`type.googleapis.com/${e}`}function SI(e){let t=e.lastIndexOf(`/`),n=t>=0?e.substring(t+1):e;if(!n.length)throw Error(`invalid type url: ${e}`);return n}const CI=pI(`Chxnb29nbGUvcHJvdG9idWYvc3RydWN0LnByb3RvEg9nb29nbGUucHJvdG9idWYihAEKBlN0cnVjdBIzCgZmaWVsZHMYASADKAsyIy5nb29nbGUucHJvdG9idWYuU3RydWN0LkZpZWxkc0VudHJ5GkUKC0ZpZWxkc0VudHJ5EgsKA2tleRgBIAEoCRIlCgV2YWx1ZRgCIAEoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZToCOAEi6gEKBVZhbHVlEjAKCm51bGxfdmFsdWUYASABKA4yGi5nb29nbGUucHJvdG9idWYuTnVsbFZhbHVlSAASFgoMbnVtYmVyX3ZhbHVlGAIgASgBSAASFgoMc3RyaW5nX3ZhbHVlGAMgASgJSAASFAoKYm9vbF92YWx1ZRgEIAEoCEgAEi8KDHN0cnVjdF92YWx1ZRgFIAEoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3RIABIwCgpsaXN0X3ZhbHVlGAYgASgLMhouZ29vZ2xlLnByb3RvYnVmLkxpc3RWYWx1ZUgAQgYKBGtpbmQiMwoJTGlzdFZhbHVlEiYKBnZhbHVlcxgBIAMoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSobCglOdWxsVmFsdWUSDgoKTlVMTF9WQUxVRRAAQn8KE2NvbS5nb29nbGUucHJvdG9idWZCC1N0cnVjdFByb3RvUAFaL2dvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3N0cnVjdHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM`),rke=iI(CI,0),wI=iI(CI,1),ike=iI(CI,2);var TI;(function(e){e[e.NULL_VALUE=0]=`NULL_VALUE`})(TI||={});function ake(e,t,n){DI(t,e);let r=ske(e.$unknown,t),[i,a,o]=EI(t),s=oI(n);for(let e of r)FOe(i,new tF(e.data),a,e.wireType,s);return o()}function oke(e,t,n){DI(t,e);let r=(e.$unknown??[]).filter(e=>e.no!==t.number),[i,a]=EI(t,n),o=new ZP;QOe(o,{writeUnknownFields:!0},i,a);let s=new tF(o.finish());for(;s.pos<s.len;){let[e,t]=s.tag(),n=s.skip(t,e);r.push({no:e,wireType:t,data:n})}e.$unknown=r}function ske(e,t){if(e===void 0)return[];if(t.fieldKind===`enum`||t.fieldKind===`scalar`){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.number)return[e[n]];return[]}return e.filter(e=>e.no===t.number)}function EI(e,t){let n=e.typeName,r=Object.assign(Object.assign({},e),{kind:`field`,parent:e.extendee,localName:n}),i=Object.assign(Object.assign({},e.extendee),{fields:[r],members:[r],oneofs:[]}),a=VP(i,t===void 0?void 0:{[n]:t});return[PDe(i,a),r,()=>{let t=a[n];if(t===void 0){let t=e.message;return RP(t)?AP(t.fields[0].scalar,t.fields[0].longAsString):VP(t)}return t}]}function DI(e,t){if(e.extendee.typeName!=t.$typeName)throw Error(`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}const OI=Date.parse(`0001-01-01T00:00:00Z`),kI=Date.parse(`9999-12-31T23:59:59Z`),AI={alwaysEmitImplicit:!1,enumAsInteger:!1,useProtoFieldName:!1};function cke(e){return e?Object.assign(Object.assign({},AI),e):AI}function jI(e,t,n){return NI(e)(cke(n),t)}function lke(e,t,n){let r=jI(e,t,n);return JSON.stringify(r,null,n?.prettySpaces??0)}const MI=new WeakMap;function NI(e){let t=MI.get(e);return t===void 0&&(t=uke(e)),t}function uke(e){let t=e.typeName,n=fke(e);if(n!==void 0){let r=e.fields[0],i=(e,i)=>{if(i.$typeName!==t&&r!==void 0)throw new KP(r,`cannot use ${r} with message ${i.$typeName}`,`ForeignFieldError`);return n(e,i)};return MI.set(e,i),i}let r=e.fields.concat().sort((e,t)=>e.number-t.number),i=r[0],a=[],o=(n,r)=>{if(r.$typeName!==t&&i!==void 0)throw new KP(i,`cannot use ${i} with message ${r.$typeName}`,`ForeignFieldError`);let o={};for(let e=0;e<a.length;e++)a[e](n,r,o);return n.registry&&vke(o,n,n.registry,r,e),o};MI.set(e,o);for(let e of r){let t=pke(e);a.push(e.jsonName===`__proto__`||e.name===`__proto__`?dke(t):t)}return o}function dke(e){return(t,n,r)=>{let i=Object.create(null);e(t,n,i);for(let e of Object.keys(i))NP(r,e,i[e])}}function fke(e){if(e.typeName.startsWith(`google.protobuf.`))switch(e.typeName){case`google.protobuf.Any`:return(e,t)=>yke(t,e);case`google.protobuf.Timestamp`:return(e,t)=>Cke(t);case`google.protobuf.Duration`:return(e,t)=>bke(t);case`google.protobuf.FieldMask`:return(e,t)=>xke(t);case`google.protobuf.Struct`:return(e,t)=>HI(t);case`google.protobuf.Value`:return(e,t)=>UI(t);case`google.protobuf.ListValue`:return(e,t)=>Ske(t);default:if(RP(e)){let t=e.fields[0],n=t.localName,r=AP(t.scalar,!1),i=BI(t);return(e,t)=>{let a=t[n];return i(e,a===void 0?r:a)}}return}}function pke(e){switch(e.fieldKind){case`scalar`:case`enum`:case`message`:return mke(e);case`list`:case`map`:{let t=e.fieldKind==`list`?II(e):LI(e),n=e.name,r=e.jsonName,i=e.localName;return(e,a,o)=>{let s=t(e,a[i]);s!==void 0&&(o[e.useProtoFieldName?n:r]=s)}}}}function mke(e){let t=PI(e),n=e.name,r=e.jsonName,i=e.localName;if(e.oneof){let a=e.oneof.localName;return(e,o,s)=>{let c=o[a];c.case===i&&(s[e.useProtoFieldName?n:r]=t(e,c.value))}}if(e.presence!=2){let a=e.presence==3?`cannot encode ${e} to JSON: required field not set`:void 0;return(e,o,s)=>{let c=o[i];if(c!==void 0&&Object.prototype.hasOwnProperty.call(o,i))s[e.useProtoFieldName?n:r]=t(e,c);else if(a!==void 0)throw Error(a)}}if(e.fieldKind==`enum`){let a=e.enum.values[0].number;return(e,o,s)=>{let c=o[i];(c!==a||e.alwaysEmitImplicit)&&(s[e.useProtoFieldName?n:r]=t(e,c))}}switch(e.scalar){case V.BOOL:return(e,a,o)=>{let s=a[i];(s!==!1||e.alwaysEmitImplicit)&&(o[e.useProtoFieldName?n:r]=t(e,s))};case V.STRING:return(e,a,o)=>{let s=a[i];(s!==``||e.alwaysEmitImplicit)&&(o[e.useProtoFieldName?n:r]=t(e,s))};case V.BYTES:return(e,a,o)=>{let s=a[i];(!(s instanceof Uint8Array)||s.byteLength>0||e.alwaysEmitImplicit)&&(o[e.useProtoFieldName?n:r]=t(e,s))};case V.DOUBLE:case V.FLOAT:return(e,a,o)=>{let s=a[i];(!Object.is(s,0)||e.alwaysEmitImplicit)&&(o[e.useProtoFieldName?n:r]=t(e,s))};default:return(e,a,o)=>{let s=a[i];(s!=0||e.alwaysEmitImplicit)&&(o[e.useProtoFieldName?n:r]=t(e,s))}}}function hke(e){switch(e.fieldKind){case`scalar`:case`enum`:case`message`:return PI(e);case`list`:return II(e);case`map`:return LI(e)}}function PI(e){switch(e.fieldKind){case`scalar`:return BI(e);case`enum`:return RI(e);case`message`:return FI(e)}}function FI(e){let{toMessage:t}=pF(e),n=NI(e.message);return(e,r)=>n(e,t(r))}function II(e){let t=gke(e);return(e,n)=>{let r=n;if(r.length==0&&!e.alwaysEmitImplicit)return;let i=[];for(let n=0;n<r.length;n++)i.push(t(e,r[n]));return i}}function gke(e){switch(e.listKind){case`scalar`:return BI(e);case`enum`:return RI(e);case`message`:return FI(e)}}function LI(e){let t=_ke(e);return(e,n)=>{let r=n,i=Object.keys(r);if(i.length==0&&!e.alwaysEmitImplicit)return;let a={};for(let n=0;n<i.length;n++){let o=i[n];NP(a,o,t(e,r[o]))}return a}}function _ke(e){switch(e.mapKind){case`scalar`:return BI(e);case`enum`:return RI(e);case`message`:return FI(e)}}function RI(e){let t=e.enum;return t.typeName==`google.protobuf.NullValue`?(e,n)=>{if(typeof n!=`number`)throw zI(t,n);return null}:(e,n)=>{if(typeof n!=`number`)throw zI(t,n);return e.enumAsInteger?n:t.value[n]?.jsonName??n}}function zI(e,t){return Error(`cannot encode ${e} to JSON: expected number, got ${lF(t)}`)}function BI(e){switch(e.scalar){case V.INT32:case V.SFIXED32:case V.SINT32:case V.FIXED32:case V.UINT32:return(t,n)=>{if(typeof n!=`number`)throw VI(e,n);return n};case V.FLOAT:case V.DOUBLE:return(t,n)=>{if(typeof n!=`number`)throw VI(e,n);return Number.isNaN(n)?`NaN`:n===1/0?`Infinity`:n===-1/0?`-Infinity`:n};case V.STRING:return(t,n)=>{if(typeof n!=`string`)throw VI(e,n);return n};case V.BOOL:return(t,n)=>{if(typeof n!=`boolean`)throw VI(e,n);return n};case V.UINT64:case V.FIXED64:case V.INT64:case V.SFIXED64:case V.SINT64:return(t,n)=>{if(typeof n==`bigint`||typeof n==`string`||typeof n==`number`&&Number.isInteger(n))return n.toString();throw VI(e,n)};case V.BYTES:return(t,n)=>{if(n instanceof Uint8Array)return NF(n);throw VI(e,n)}}}function VI(e,t){return Error(`cannot encode ${e} to JSON: ${iF(e,t)?.message}`)}function vke(e,t,n,r,i){let a=r.$unknown;if(a===void 0)return;let o=new Set;for(let s=0;s<a.length;s++){let{no:c}=a[s];if(!o.has(c)){o.add(c);let a=n.getExtensionFor(i,c);if(!a)continue;let[s,l]=EI(a,ake(r,a)),u=s[jP],d=hke(l)(t,u[l.localName]);d!==void 0&&(e[a.jsonName]=d)}}}function yke(e,t){if(e.typeUrl===``)return{};let{registry:n}=t,r,i;if(n&&(r=tke(e,n),r&&(i=n.getMessage(r.$typeName))),!i||!r)throw Error(`cannot encode message ${e.$typeName} to JSON: "${e.typeUrl}" is not in the type registry`);let a=zP(i)?{value:NI(i)(t,r)}:NI(i)(t,r);return a[`@type`]=e.typeUrl,a}function bke(e){let t=Number(e.seconds),n=e.nanos;if(t>315576e6||t<-315576e6)throw Error(`cannot encode message ${e.$typeName} to JSON: value out of range`);if(t>0&&n<0||t<0&&n>0)throw Error(`cannot encode message ${e.$typeName} to JSON: nanos sign must match seconds sign`);let r=e.seconds.toString();if(n!==0){let e=Math.abs(n).toString();e=`0`.repeat(9-e.length)+e,e.substring(3)===`000000`?e=e.substring(0,3):e.substring(6)===`000`&&(e=e.substring(0,6)),r+=`.`+e,n<0&&t==0&&(r=`-`+r)}return r+`s`}function xke(e){return e.paths.map(t=>{if(zF(RF(t))!==t)throw Error(`cannot encode message ${e.$typeName} to JSON: lowerCamelCase of path name "${t}" is irreversible`);return RF(t)}).join(`,`)}function HI(e){let t={},n=Object.keys(e.fields);for(let r=0;r<n.length;r++){let i=n[r];NP(t,i,UI(e.fields[i]))}return t}function UI(e){switch(e.kind.case){case`nullValue`:return null;case`numberValue`:if(!Number.isFinite(e.kind.value))throw Error(`${e.$typeName} cannot be NaN or Infinity`);return e.kind.value;case`boolValue`:return e.kind.value;case`stringValue`:return e.kind.value;case`structValue`:return HI(e.kind.value);case`listValue`:return Ske(e.kind.value);default:throw Error(`${e.$typeName} must have a value`)}}function Ske(e){return e.values.map(UI)}function Cke(e){let t=Number(e.seconds)*1e3;if(t<OI||t>kI)throw Error(`cannot encode message ${e.$typeName} to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);if(e.nanos<0)throw Error(`cannot encode message ${e.$typeName} to JSON: nanos must not be negative`);if(e.nanos>999999999)throw Error(`cannot encode message ${e.$typeName} to JSON: nanos must not be greater than 999999999`);let n=`Z`;if(e.nanos>0){let t=(e.nanos+1e9).toString().substring(1);n=t.substring(3)===`000000`?`.`+t.substring(0,3)+`Z`:t.substring(6)===`000`?`.`+t.substring(0,6)+`Z`:`.`+t+`Z`}return new Date(t).toISOString().replace(`.000Z`,n)}function wke(e){return Object.assign(Object.assign({ignoreUnknownFields:!1,recursionLimit:100},e),{depth:0})}function Tke(e,t,n){return Eke(e,Vke(t,e.typeName),n)}function Eke(e,t,n){let r=VP(e);return Dke(e,r,t,n),r}function Dke(e,t,n,r){try{GI(e)(t,n,wke(r))}catch(e){throw TDe(e)?Error(`cannot decode ${e.field()} from JSON: ${e.message}`,{cause:e}):e}}const WI=new WeakMap;function GI(e){let t=WI.get(e);return t===void 0&&(t=Oke(e)),t}function Oke(e){let t=String(e),n=kke(e);if(n!==void 0){let r=(e,r,i)=>{if(++i.depth>i.recursionLimit)throw Error(`cannot decode ${t} from JSON: maximum recursion depth of ${i.recursionLimit} reached`);n(e,r,i),i.depth--};return WI.set(e,r),r}let r=e.typeName,i=new Map,a=(e,n,a)=>{if(++a.depth>a.recursionLimit)throw Error(`cannot decode ${t} from JSON: maximum recursion depth of ${a.recursionLimit} reached`);if(n==null||Array.isArray(n)||typeof n!=`object`)throw Error(`cannot decode ${t} from JSON: ${lF(n)}`);let o=new Map,s=new Set,c=Object.keys(n);for(let l=0;l<c.length;l++){let u=c[l],d=n[u],f=i.get(u);if(f!==void 0){let t=f.field;if(s.has(t))throw new KP(t,`set multiple times`);if(s.add(t),f.oneofScalarNullSkip&&d===null)continue;if(f.oneof){let e=o.get(f.oneof);if(e!==void 0)throw new KP(f.oneof,`oneof set multiple times by ${e.name} and ${t.name}`);o.set(f.oneof,t)}f.read(e,d,a)}else{let n=u.startsWith(`[`)&&u.endsWith(`]`)?a.registry?.getExtension(u.substring(1,u.length-1)):void 0;if(n?.extendee.typeName==r){let[t,r,i]=EI(n);Ake(r)(t[jP],d,a),oke(e,n,i())}if(n===void 0&&!a.ignoreUnknownFields)throw Error(`cannot decode ${t} from JSON: key "${u}" is unknown`)}}a.depth--};WI.set(e,a);for(let t of e.fields){let e={read:Ake(t),field:t,oneof:t.oneof,oneofScalarNullSkip:t.oneof!==void 0&&t.fieldKind==`scalar`};i.set(t.name,e).set(t.jsonName,e)}return a}function kke(e){if(e.typeName.startsWith(`google.protobuf.`))switch(e.typeName){case`google.protobuf.Any`:return(e,t,n)=>Uke(e,t,n);case`google.protobuf.Timestamp`:return(e,t)=>Wke(e,t);case`google.protobuf.Duration`:return(e,t)=>Gke(e,t);case`google.protobuf.FieldMask`:return(e,t)=>Kke(e,t);case`google.protobuf.Struct`:return(e,t,n)=>qke(e,t,n);case`google.protobuf.Value`:return(e,t,n)=>ZI(e,t,n);case`google.protobuf.ListValue`:return(e,t,n)=>Jke(e,t,n);default:if(RP(e)){let t=e.fields[0],n=t.localName,r=t.scalar,i=t.longAsString,a=Rke(t);return(e,t)=>{t===null?e[n]=AP(r,i):e[n]=a(t)}}return}}function Ake(e){switch(e.fieldKind){case`scalar`:return jke(e);case`enum`:return Nke(e);case`message`:return Pke(e);case`list`:return Fke(e);case`map`:return Lke(e)}}function jke(e){let t=Rke(e),n=e.localName;if(e.oneof){let r=e.oneof.localName;return(e,i)=>{e[r]={case:n,value:t(i)}}}let r=Mke(e);return(e,i)=>{i===null?r(e):e[n]=t(i)}}function Mke(e){let t=e.localName;if(e.presence!=2)return e=>{delete e[t]};if(e.fieldKind==`enum`){let n=e.enum.values[0].number;return e=>{e[t]=n}}let n=e.scalar,r=e.longAsString;return e=>{e[t]=AP(n,r)}}function Nke(e){let t=qI(e.enum),n=JI(e.enum),r=e.localName,i=e.enum.typeName!=`google.protobuf.NullValue`;if(e.oneof){let a=e.oneof.localName;return(o,s,c)=>{if(s===null&&i){o[a].case===r&&(o[a]={case:void 0});return}let l=t(s,c.ignoreUnknownFields);if(l===KI)return;let u=n(l);if(u!==!0)throw new KP(e,cF(e,l,u));o[a]={case:r,value:l}}}let a=Mke(e);return(o,s,c)=>{if(s===null&&i){a(o);return}let l=t(s,c.ignoreUnknownFields);if(l===KI)return;let u=n(l);if(u!==!0)throw new KP(e,cF(e,l,u));o[r]=l}}function Pke(e){let t=e.localName,{toMessage:n,toLocal:r}=pF(e),i=GI(e.message),a=e.message.typeName!=`google.protobuf.Value`;if(e.oneof){let o=e.oneof.localName;return(e,s,c)=>{let l=e[o];if(s===null&&a){l.case===t&&(e[o]={case:void 0});return}let u=n(l.case===t?l.value:void 0);i(u,s,c),e[o]={case:t,value:r(u)}}}return(e,o,s)=>{if(o===null&&a){delete e[t];return}let c=n(e[t]);i(c,o,s),e[t]=r(c)}}function Fke(e){let t=e.localName,n=Ike(e);return(r,i,a)=>{if(i===null)return;if(!Array.isArray(i))throw new KP(e,`expected Array, got `+lF(i));let o=r[t];for(let e=0;e<i.length;e++){let t=n(i[e],a,o.length);t!==KI&&o.push(t)}}}function Ike(e){switch(e.listKind){case`scalar`:{let t=YI(e),n=sF(e.scalar),r=XI(e);return(i,a,o)=>{if(i===null)throw new KP(e,`list item must not be null`);let s=t(i),c=n(s);if(c!==!0)throw new KP(e,`list item #${o+1}: ${cF(e,s,c)}`);return r(s)}}case`enum`:{let t=qI(e.enum),n=JI(e.enum),r=e.enum.typeName!=`google.protobuf.NullValue`;return(i,a,o)=>{if(i===null&&r)throw new KP(e,`list item must not be null`);let s=t(i,a.ignoreUnknownFields);if(s===KI)return s;let c=n(s);if(c!==!0)throw new KP(e,`list item #${o+1}: ${cF(e,s,c)}`);return s}}case`message`:{let{toMessage:t,toLocal:n}=pF(e),r=GI(e.message),i=e.message.typeName!=`google.protobuf.Value`;return(a,o)=>{if(a===null&&i)throw new KP(e,`list item must not be null`);let s=t(void 0);return r(s,a,o),n(s)}}}}function Lke(e){let t=e.localName,n=e.mapKey,r=zke(n),i=sF(n),a,o,s=e=>e,c=!0;switch(e.mapKind){case`scalar`:a=YI(e),o=sF(e.scalar),s=XI(e);break;case`enum`:{let t=qI(e.enum);a=(e,n)=>t(e,n.ignoreUnknownFields),o=JI(e.enum),c=e.enum.typeName!=`google.protobuf.NullValue`;break}case`message`:{let{toMessage:t,toLocal:n}=pF(e),r=GI(e.message);c=e.message.typeName!=`google.protobuf.Value`,a=(e,i)=>{let a=t(void 0);return r(a,e,i),n(a)};break}}return(l,u,d)=>{if(u===null)return;if(typeof u!=`object`||Array.isArray(u))throw new KP(e,`expected object, got `+lF(u));let f=l[t],p=new Set,m=Object.keys(u);for(let t=0;t<m.length;t++){let l=m[t],h=u[l],g=r(l);if(p.has(g))throw new KP(e,`duplicate map key "${l}"`);if(p.add(g),h===null&&c)throw new KP(e,`map value must not be null`);let _=a(h,d);if(_===KI)continue;let v=i(g);if(v!==!0)throw new KP(e,`invalid map key: ${cF({scalar:n},g,v)}`);if(o!==void 0){let t=o(_);if(t!==!0)throw new KP(e,`map entry ${lF(g)}: ${cF(e,_,t)}`)}NP(f,g,s(_))}}}const KI=Symbol();function qI(e){let t=e.values[0].number,n=new Map;for(let t of e.values)n.set(t.jsonName,t.number);for(let t of e.values)n.set(t.name,t.number);return(r,i)=>{if(r===null)return t;switch(typeof r){case`number`:if(Number.isInteger(r))return r;break;case`string`:{let e=n.get(r);if(e!==void 0)return e;if(i)return KI;break}}throw Error(`cannot decode ${e} from JSON: ${lF(r)}`)}}function JI(e){if(e.open)return sF(V.INT32);let t=e.values;return e=>t.some(t=>t.number===e)}function Rke(e){let t=YI(e),n=sF(e.scalar),r=XI(e);return i=>{let a=t(i),o=n(a);if(o!==!0)throw new KP(e,cF(e,a,o));return r(a)}}function YI(e){switch(e.scalar){case V.DOUBLE:case V.FLOAT:return t=>{if(t===`NaN`)return NaN;if(t===`Infinity`)return 1/0;if(t===`-Infinity`)return-1/0;if(typeof t==`number`){if(Number.isNaN(t))throw new KP(e,`unexpected NaN number`);if(!Number.isFinite(t))throw new KP(e,`unexpected infinite number`);return t}if(typeof t==`string`){if(t===``||t.trim().length!==t.length)return t;let e=Number(t);return Number.isFinite(e)?e:t}return t};case V.INT32:case V.FIXED32:case V.SFIXED32:case V.SINT32:case V.UINT32:return Bke;case V.BYTES:return t=>{if(typeof t==`string`){if(t===``)return new Uint8Array;try{return jF(t)}catch(t){throw new KP(e,t instanceof Error?t.message:String(t))}}return t};default:return e=>e}}function XI(e){let t=e.fieldKind!==`map`&&e.longAsString;switch(e.scalar){case V.INT64:case V.SFIXED64:case V.SINT64:return t?e=>String(e):e=>typeof e==`string`||typeof e==`number`?DP.parse(e):e;case V.FIXED64:case V.UINT64:return t?e=>String(e):e=>typeof e==`string`||typeof e==`number`?DP.uParse(e):e;default:return e=>e}}function zke(e){switch(e){case V.BOOL:return e=>{switch(e){case`true`:return!0;case`false`:return!1}return e};case V.INT32:case V.FIXED32:case V.UINT32:case V.SFIXED32:case V.SINT32:return Bke;case V.INT64:case V.SINT64:case V.SFIXED64:case V.UINT64:case V.FIXED64:return e=>/^-?0+$/.test(e)?`0`:e.replace(/^(-?)0+(?=\d)/,`$1`);default:return e=>e}}function Bke(e){if(typeof e==`string`){if(e===``||e.trim().length!==e.length)return e;let t=Number(e);return Number.isNaN(t)?e:t}return e}function Vke(e,t){let n;try{n=JSON.parse(e)}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`cannot decode message ${t} from JSON: ${n}`,{cause:e})}return Hke(e,t),n}function Hke(e,t){let n=[],r=!1,i=0;for(;i<e.length;)switch(e[i]){case`{`:n.push(new Set),r=!0,i++;break;case`[`:n.push(null),r=!1,i++;break;case`}`:case`]`:n.pop(),r=!1,i++;break;case`,`:r=n[n.length-1]!=null,i++;break;case`:`:r=!1,i++;break;case`"`:{let a=i++,o=!1;for(;i<e.length;){if(e[i]==`\\`){o=!0,i+=2;continue}if(e[i]==`"`)break;i++}let s=i++,c=n[n.length-1];if(r&&c){let n=o?JSON.parse(e.substring(a,s+1)):e.substring(a+1,s);if(c.has(n))throw Error(`cannot decode message ${t} from JSON: duplicate object key "${n}"`);c.add(n)}r=!1;break}default:i++}}function Uke(e,t,n){if(t===null||Array.isArray(t)||typeof t!=`object`)throw Error(`cannot decode message ${e.$typeName} from JSON: expected object but got ${lF(t)}`);if(Object.keys(t).length==0)return;let r=t[`@type`];if(typeof r!=`string`||r==``)throw Error(`cannot decode message ${e.$typeName} from JSON: "@type" is empty`);let i=r.includes(`/`)?r.substring(r.lastIndexOf(`/`)+1):r;if(!i.length)throw Error(`cannot decode message ${e.$typeName} from JSON: "@type" is invalid`);let a=n.registry?.getMessage(i);if(!a)throw Error(`cannot decode message ${e.$typeName} from JSON: ${r} is not in the type registry`);let o=VP(a);if(zP(a)&&Object.prototype.hasOwnProperty.call(t,`value`))GI(a)(o,t.value,n);else{let e={};for(let n of Object.keys(t))n!==`@type`&&NP(e,n,t[n]);GI(a)(o,e,n)}$Oe(a,o,e)}function Wke(e,t){if(typeof t!=`string`)throw Error(`cannot decode message ${e.$typeName} from JSON: ${lF(t)}`);let n=t.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.([0-9]{1,9}))?(?:Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw Error(`cannot decode message ${e.$typeName} from JSON: invalid RFC 3339 string`);let r=Date.parse(n[1]+`-`+n[2]+`-`+n[3]+`T`+n[4]+`:`+n[5]+`:`+n[6]+(n[8]?n[8]:`Z`));if(Number.isNaN(r))throw Error(`cannot decode message ${e.$typeName} from JSON: invalid RFC 3339 string`);if(r<OI||r>kI)throw Error(`cannot decode message ${e.$typeName} from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);e.seconds=DP.parse(r/1e3),e.nanos=0,n[7]&&(e.nanos=parseInt(`1`+n[7]+`0`.repeat(9-n[7].length))-1e9)}function Gke(e,t){if(typeof t!=`string`)throw Error(`cannot decode message ${e.$typeName} from JSON: ${lF(t)}`);let n=t.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(n===null)throw Error(`cannot decode message ${e.$typeName} from JSON: ${lF(t)}`);let r=Number(n[1]);if(r>315576e6||r<-315576e6)throw Error(`cannot decode message ${e.$typeName} from JSON: ${lF(t)}`);if(e.seconds=DP.parse(r),typeof n[2]!=`string`)return;let i=n[2]+`0`.repeat(9-n[2].length);e.nanos=parseInt(i),(r<0||Object.is(r,-0))&&(e.nanos=-e.nanos)}function Kke(e,t){if(typeof t!=`string`)throw Error(`cannot decode message ${e.$typeName} from JSON: ${lF(t)}`);t!==``&&(e.paths=t.split(`,`).map(t=>{if(t.includes(`_`))throw Error(`cannot decode message ${e.$typeName} from JSON: path names must be lowerCamelCase`);return zF(t)}))}function qke(e,t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`cannot decode message ${e.$typeName} from JSON ${lF(t)}`);let r=Object.keys(t);for(let i=0;i<r.length;i++){let a=r[i],o=VP(wI);ZI(o,t[a],n),NP(e.fields,a,o)}}function ZI(e,t,n){if(++n.depth>n.recursionLimit)throw Error(`cannot decode ${e.$typeName} from JSON: maximum recursion depth of ${n.recursionLimit} reached`);switch(typeof t){case`number`:e.kind={case:`numberValue`,value:t};break;case`string`:e.kind={case:`stringValue`,value:t};break;case`boolean`:e.kind={case:`boolValue`,value:t};break;case`object`:if(t===null)e.kind={case:`nullValue`,value:TI.NULL_VALUE};else if(Array.isArray(t)){let r=VP(ike);Jke(r,t,n),e.kind={case:`listValue`,value:r}}else{let r=VP(rke);qke(r,t,n),e.kind={case:`structValue`,value:r}}break;default:throw Error(`cannot decode message ${e.$typeName} from JSON ${lF(t)}`)}return n.depth--,e}function Jke(e,t,n){if(!Array.isArray(t))throw Error(`cannot decode message ${e.$typeName} from JSON ${lF(t)}`);for(let r=0;r<t.length;r++){let i=VP(wI);ZI(i,t[r],n),e.values.push(i)}}function QI(e){let t=B[e];return typeof t==`string`?t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,e=>`_`+e.toLowerCase()):e.toString()}let $I;function Yke(e){if(!$I){$I={};for(let e of Object.values(B))typeof e!=`string`&&($I[QI(e)]=e)}return $I[e]}var eL=class e extends Error{constructor(e,t=B.Unknown,n,r,i){super(Xke(e,t)),this.name=`ConnectError`,this.isWireError=!1,Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(n??{}),this.details=r??[],this.cause=i}static from(t,n=B.Unknown){return t instanceof e?t:t instanceof Error?t.name==`AbortError`||t.name==`TimeoutError`?new e(t.message,B.Canceled):new e(t.message,n,void 0,void 0,t):new e(String(t),n,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===e.prototype||t.name===`ConnectError`&&`code`in t&&typeof t.code==`number`&&`metadata`in t&&`details`in t&&Array.isArray(t.details)&&`rawMessage`in t&&typeof t.rawMessage==`string`&&`cause`in t:!1}findDetails(e){let t=e.kind===`message`?{getMessage:t=>t===e.typeName?e:void 0}:e,n=[];for(let e of this.details){if(`desc`in e){t.getMessage(e.desc.typeName)&&n.push(VP(e.desc,e.value));continue}let r=t.getMessage(e.type);if(r)try{n.push(sI(r,e.value))}catch{}}return n}};function Xke(e,t){return e.length?`[${QI(t)}] ${e}`:`[${QI(t)}]`}function Zke(...e){let t=new Headers;for(let n of e)n.forEach((e,n)=>{t.append(n,e)});return t}function Qke(e,t){let n={};for(let r of e.methods){let e=t(r);e!=null&&(n[r.localName]=e)}return n}function $ke(e,t){if(t>e)throw new eL(`message size ${t} is larger than configured writeMaxBytes ${e}`,B.ResourceExhausted)}function tL(e,t,n=!1){if(t>e){let r=`message size is larger than configured readMaxBytes ${e}`;throw n&&(r=`message size ${t} is larger than configured readMaxBytes ${e}`),new eL(r,B.ResourceExhausted)}}function eAe(e){return new tAe(e)}var tAe=class{constructor(e){this.readMaxBytes=e,this.header=new Uint8Array(5),this.headerView=new DataView(this.header.buffer),this.buf=[]}get byteLength(){return this.buf.reduce((e,t)=>e+t.byteLength,0)}decode(e){this.buf.push(e);let t=[];for(;;){let e=this.pop();if(!e)break;t.push(e)}return t}pop(){if(!(!this.env&&(this.env=this.head(),!this.env))&&this.cons(this.env.data)){let e=this.env;return this.env=void 0,e}}head(){if(!this.cons(this.header))return;let e=this.headerView.getUint8(0),t=this.headerView.getUint32(1);return tL(this.readMaxBytes,t,!0),{flags:e,data:new Uint8Array(t)}}cons(e){let t=e.byteLength;if(this.byteLength<t)return!1;let n=0;for(;n<t;){let r=this.buf.shift();r.byteLength>t-n?(e.set(r.subarray(0,t-n),n),this.buf.unshift(r.subarray(t-n)),n+=t-n):(e.set(r,n),n+=r.byteLength)}return!0}};function nAe(e){let t,n=eAe(4294967295);return new ReadableStream({start(){t=e.getReader()},async pull(e){let r=!1;for(;!r;){let i=await t.read();if(i.done)n.byteLength>0&&e.error(new eL(`protocol error: incomplete envelope`,B.InvalidArgument)),e.close();else for(let t of n.decode(i.value))e.enqueue(t),r=!0}}})}async function rAe(e,t,n){let{flags:r,data:i}=e;if((r&1)==1)throw new eL(`invalid envelope, already compressed`,B.Internal);return t&&i.byteLength>=n&&(i=await t.compress(i),r|=1),{data:i,flags:r}}async function iAe(e,t,n){let{flags:r,data:i}=e;if((r&1)==1){if(!t)throw new eL(`received compressed envelope, but do not know how to decompress`,B.Internal);i=await t.decompress(i,n),r^=1}return{data:i,flags:r}}function aAe(e,t){let n=new Uint8Array(t.length+5);n.set(t,5);let r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.setUint8(0,e),r.setUint32(1,t.length),n}var nL=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},rL=function(e){return this instanceof rL?(this.v=e,this):new rL(e)},iL=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof rL?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}},oAe=function(e){var t={},n;return r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:rL(e[r](t)),done:!1}:i?i(t):t}:i}};function sAe(e,...t){let[n,r,i]=cAe(t),a=e,o;return i?.propagateDownStreamError===!0&&(a=o=yAe(a)),a=aL(a,...n,{propagateDownStreamError:!1}),r(a).catch(e=>o?o.abort(e).then(()=>Promise.reject(e)):Promise.reject(e))}function cAe(e){let t;return typeof e[e.length-1]!=`function`&&(t=e.pop()),[e,e.pop(),t]}function lAe(e,t){return async n=>await _Ae(n,e,t)}function aL(e,...t){return iL(this,arguments,function*(){var n;let[r,i]=uAe(t),a,o=e[Symbol.asyncIterator](),s={[Symbol.asyncIterator](){return o}};i?.propagateDownStreamError===!0&&(s=a=yAe(s));for(let e of r)s=e(s);let c=s[Symbol.asyncIterator]();try{for(;;){let e=yield rL(c.next());if(e.done===!0)break;if(!a){yield yield rL(e.value);continue}try{yield yield rL(e.value)}catch(e){throw yield rL(a.abort(e)),e}}}finally{i?.propagateDownStreamError===!0&&((n=o.return)==null||n.call(o).catch(()=>{}))}})}function uAe(e){let t;return typeof e[e.length-1]!=`function`&&(t=e.pop()),[e,t]}function dAe(e,t,n){return t===void 0||n===void 0?function(t){return iL(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=nL(t),c;c=yield rL(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a;yield yield rL({flags:0,data:e.serialize(t)})}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield rL(i.call(s)))}finally{if(r)throw r.error}}})}:function(r){return iL(this,arguments,function*(){var i,a,o,s;try{for(var c=!0,l=nL(r),u;u=yield rL(l.next()),i=u.done,!i;c=!0){s=u.value,c=!1;let r=s,i,a=0;r.end?(a|=t,i=n.serialize(r.value)):i=e.serialize(r.value),yield yield rL({flags:a,data:i})}}catch(e){a={error:e}}finally{try{!c&&!i&&(o=l.return)&&(yield rL(o.call(l)))}finally{if(a)throw a.error}}})}}function fAe(e,t,n){return n&&t!==void 0?function(r){return iL(this,arguments,function*(){var i,a,o,s;try{for(var c=!0,l=nL(r),u;u=yield rL(l.next()),i=u.done,!i;c=!0){s=u.value,c=!1;let{flags:r,data:i}=s;(r&t)===t?yield yield rL({value:n.parse(i),end:!0}):yield yield rL({value:e.parse(i),end:!1})}}catch(e){a={error:e}}finally{try{!c&&!i&&(o=l.return)&&(yield rL(o.call(l)))}finally{if(a)throw a.error}}})}:function(r){return iL(this,arguments,function*(){var i,a,o,s;try{for(var c=!0,l=nL(r),u;u=yield rL(l.next()),i=u.done,!i;c=!0){s=u.value,c=!1;let{flags:r,data:i}=s;if(t!==void 0&&(r&t)===t){if(n===null)throw new eL(`unexpected end flag`,B.InvalidArgument);continue}yield yield rL(e.parse(i))}}catch(e){a={error:e}}finally{try{!c&&!i&&(o=l.return)&&(yield rL(o.call(l)))}finally{if(a)throw a.error}}})}}function pAe(e,t){return function(n){return iL(this,arguments,function*(){var r,i,a,o;try{for(var s=!0,c=nL(n),l;l=yield rL(c.next()),r=l.done,!r;s=!0)o=l.value,s=!1,yield yield rL(yield rL(rAe(o,e,t)))}catch(e){i={error:e}}finally{try{!s&&!r&&(a=c.return)&&(yield rL(a.call(c)))}finally{if(i)throw i.error}}})}}function mAe(e,t){return function(n){return iL(this,arguments,function*(){var r,i,a,o;try{for(var s=!0,c=nL(n),l;l=yield rL(c.next()),r=l.done,!r;s=!0)o=l.value,s=!1,yield yield rL(yield rL(iAe(o,e,t)))}catch(e){i={error:e}}finally{try{!s&&!r&&(a=c.return)&&(yield rL(a.call(c)))}finally{if(i)throw i.error}}})}}function hAe(){return function(e){return iL(this,arguments,function*(){var t,n,r,i;try{for(var a=!0,o=nL(e),s;s=yield rL(o.next()),t=s.done,!t;a=!0){i=s.value,a=!1;let{flags:e,data:t}=i;yield yield rL(aAe(e,t))}}catch(e){n={error:e}}finally{try{!a&&!t&&(r=o.return)&&(yield rL(r.call(o)))}finally{if(n)throw n.error}}})}}function gAe(e){return function(t){return iL(this,arguments,function*(){var n,r,i,a;let o=eAe(e);try{for(var s=!0,c=nL(t),l;l=yield rL(c.next()),n=l.done,!n;s=!0){a=l.value,s=!1;let e=a;for(let t of o.decode(e))yield yield rL(t)}}catch(e){r={error:e}}finally{try{!s&&!n&&(i=c.return)&&(yield rL(i.call(c)))}finally{if(r)throw r.error}}if(o.byteLength>0)throw new eL(`protocol error: incomplete envelope`,B.InvalidArgument)})}}async function _Ae(e,t,n){var r,i,a,o,s,c,l,u;let[d,f]=vAe(n);if(d){f>t&&tL(t,f,!0);let n=new Uint8Array(f),s=0;try{for(var p=!0,m=nL(e),h;h=await m.next(),r=h.done,!r;p=!0){o=h.value,p=!1;let e=o;if(s+e.byteLength>f)throw new eL(`protocol error: promised ${f} bytes, received ${s+e.byteLength}`,B.InvalidArgument);n.set(e,s),s+=e.byteLength}}catch(e){i={error:e}}finally{try{!p&&!r&&(a=m.return)&&await a.call(m)}finally{if(i)throw i.error}}if(s<f)throw new eL(`protocol error: promised ${f} bytes, received ${s}`,B.InvalidArgument);return n}let g=[],_=0;try{for(var v=!0,y=nL(e),b;b=await y.next(),s=b.done,!s;v=!0){u=b.value,v=!1;let e=u;_+=e.byteLength,tL(t,_),g.push(e)}}catch(e){c={error:e}}finally{try{!v&&!s&&(l=y.return)&&await l.call(y)}finally{if(c)throw c.error}}let ee=new Uint8Array(_),x=0;for(let e=g.shift();e;e=g.shift())ee.set(e,x),x+=e.byteLength;return ee}function vAe(e){if(e==null)return[!1,0];let t=typeof e==`string`?parseInt(e,10):e;return!Number.isSafeInteger(t)||t<0?[!1,t]:[!0,t]}function yAe(e){let t=e[Symbol.asyncIterator]();if(t.throw===void 0)throw Error(`AsyncIterable does not implement throw`);let n=t,r,i,a={next(){return i=n.next().finally(()=>{i=void 0}),i},throw(e){return n.throw(e)}};t.return!==void 0&&(a=Object.assign(Object.assign({},a),{return(e){return n.return(e)}}));let o=!1;return{abort(e){if(r)return r.state;let t=()=>n.throw(e).then(e=>e.done===!0?`completed`:`caught`,()=>`rethrown`);return i?(r={reason:e,state:i.then(t,t)},r.state):(r={reason:e,state:t()},r.state)},[Symbol.asyncIterator](){if(o)throw Error(`AsyncIterable cannot be re-used`);return o=!0,a}}}function bAe(e){return iL(this,arguments,function*(){yield rL(yield*oAe(nL(e)))})}var xAe=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},oL=function(e){return this instanceof oL?(this.v=e,this):new oL(e)},SAe=function(e){var t={},n;return r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:oL(e[r](t)),done:!1}:i?i(t):t}:i}},CAe=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof oL?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function sL(e,t){return Qke(e,e=>{switch(e.methodKind){case`unary`:return wAe(t,e);case`server_streaming`:return TAe(t,e);case`client_streaming`:return EAe(t,e);case`bidi_streaming`:return DAe(t,e);default:return null}})}function wAe(e,t){return async(n,r)=>{var i,a;let o=await e.unary(t,r?.signal,r?.timeoutMs,r?.headers,n,r?.contextValues);return(i=r?.onHeader)==null||i.call(r,o.header),(a=r?.onTrailer)==null||a.call(r,o.trailer),o.message}}function TAe(e,t){return(n,r)=>cL(e.stream(t,r?.signal,r?.timeoutMs,r?.headers,bAe([n]),r?.contextValues),r)}function EAe(e,t){return async(n,r)=>{var i,a,o,s,c,l;let u=await e.stream(t,r?.signal,r?.timeoutMs,r?.headers,n,r?.contextValues);(c=r?.onHeader)==null||c.call(r,u.header);let d,f=0;try{for(var p=!0,m=xAe(u.message),h;h=await m.next(),i=h.done,!i;p=!0)s=h.value,p=!1,d=s,f++}catch(e){a={error:e}}finally{try{!p&&!i&&(o=m.return)&&await o.call(m)}finally{if(a)throw a.error}}if(!d)throw new eL(`protocol error: missing response message`,B.Unimplemented);if(f>1)throw new eL(`protocol error: received extra messages for client streaming method`,B.Unimplemented);return(l=r?.onTrailer)==null||l.call(r,u.trailer),d}}function DAe(e,t){return(n,r)=>cL(e.stream(t,r?.signal,r?.timeoutMs,r?.headers,n,r?.contextValues),r)}function cL(e,t){return(function(){return CAe(this,arguments,function*(){var n,r;let i=yield oL(e);(n=t?.onHeader)==null||n.call(t,i.header),yield oL(yield*SAe(xAe(i.message))),(r=t?.onTrailer)==null||r.call(t,i.trailer)})})()}function OAe(...e){let t=new AbortController,n=e.filter(e=>e!==void 0).concat(t.signal);for(let e of n){if(e.aborted){r.apply(e);break}e.addEventListener(`abort`,r)}function r(){t.signal.aborted||t.abort(lL(this));for(let e of n)e.removeEventListener(`abort`,r)}return t}function kAe(e){let t=new AbortController,n=()=>{t.abort(new eL(`the operation timed out`,B.DeadlineExceeded))},r;return e!==void 0&&(e<=0?n():r=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(r)}}function lL(e){if(!e.aborted)return;if(e.reason!==void 0)return e.reason;let t=Error(`This operation was aborted`);return t.name=`AbortError`,t}function uL(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}function dL(e,t,...n){if(n.length>0)throw Error();return e.services[t]}const fL=`Content-Type`,pL=`Content-Length`,mL=`Content-Encoding`,hL=`Connect-Content-Encoding`,gL=`Accept-Encoding`,_L=`Connect-Accept-Encoding`,vL=`Connect-Timeout-Ms`,yL=`Connect-Protocol-Version`,bL=`User-Agent`,AAe=new Set([fL,pL,mL,`Host`,bL,`Trailer`,`Date`,gL,`Trailer-`,hL,_L,vL,yL,`Grpc-Encoding`,`Grpc-Accept-Encoding`,`Grpc-Timeout`,`Grpc-Status`,`Grpc-Message`,`Grpc-Status-Details-Bin`].map(e=>e.toLowerCase()));function jAe(e,t){t.forEach((t,n)=>{AAe.has(n.toLowerCase())||e.append(n,t)})}function xL(e,t){return e.toString().replace(/\/?$/,`/${t.parent.typeName}/${t.name}`)}function SL(e,t){return VP(e,t)}function MAe(e,t){function n(t){return t.done===!0?t:{done:t.done,value:SL(e,t.value)}}return{[Symbol.asyncIterator](){let e=t[Symbol.asyncIterator](),r={next:()=>e.next().then(n)};return e.throw!==void 0&&(r.throw=t=>e.throw(t).then(n)),e.return!==void 0&&(r.return=t=>e.return(t).then(n)),r}}}function CL(e,t){if(!t)return e;for(let n of t.concat().reverse())e=n(e);return e}function wL(e){let t=Object.assign({},e);return t.ignoreUnknownFields??=!0,t}function TL(e,t,n,r){let i=DL(OL(e.input,t),r),a=DL(kL(e.input,n),r),o=DL(OL(e.output,t),r),s=DL(kL(e.output,n),r);return{getI(e){return e?i:a},getO(e){return e?o:s}}}function EL(e,t,n,r){let i=t?OL(e.input,r):kL(e.input,n);return{parse:(t?OL(e.output,r):kL(e.output,n)).parse,serialize:i.serialize}}function DL(e,t){return{serialize(n){let r=e.serialize(n);return $ke(t.writeMaxBytes,r.byteLength),r},parse(n){return tL(t.readMaxBytes,n.byteLength,!0),e.parse(n)}}}function OL(e,t){return{parse(n){try{return sI(e,n,t)}catch(e){throw new eL(`parse binary: ${e instanceof Error?e.message:String(e)}`,B.Internal)}},serialize(n){try{return hI(e,n,t)}catch(e){throw new eL(`serialize binary: ${e instanceof Error?e.message:String(e)}`,B.Internal)}}}}function kL(e,t){let n=t?.textEncoder??new TextEncoder,r=t?.textDecoder??new TextDecoder,i=wL(t);return{parse(t){try{return Tke(e,r.decode(t),i)}catch(e){throw eL.from(e,B.InvalidArgument)}},serialize(t){try{let r=lke(e,t,i);return n.encode(r)}catch(e){throw eL.from(e,B.Internal)}}}}const NAe=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function PAe(e){let t=e?.match(NAe);if(t)return{stream:!!t[1],binary:!!t[3]}}var FAe=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function AL(e,t,n){if(t&&new Headers(t).forEach((e,t)=>n.metadata.append(t,e)),typeof e!=`object`||!e||Array.isArray(e))throw n;let r=n.code;`code`in e&&typeof e.code==`string`&&(r=Yke(e.code)??r);let i=e.message;if(i!=null&&typeof i!=`string`)throw n;let a=new eL(i??``,r,t);if(a.isWireError=!0,`details`in e&&Array.isArray(e.details))for(let t of e.details){if(typeof t!=`object`||!t||Array.isArray(t)||typeof t.type!=`string`||typeof t.value!=`string`)throw n;try{a.details.push({type:t.type,value:jF(t.value),debug:t.debug})}catch{throw n}}return a}function IAe(e,t,n){let r;try{r=JSON.parse(new TextDecoder().decode(e))}catch{throw n}return AL(r,t,n)}function LAe(e,t){let n={code:QI(e.code)};return e.rawMessage.length>0&&(n.message=e.rawMessage),e.details.length>0&&(n.details=e.details.map(e=>{if(`desc`in e){let n=VP(e.desc,e.value),r={type:e.desc.typeName,value:hI(e.desc,n)};try{r.debug=jI(e.desc,n,t)}catch{}return r}return e}).map(e=>{var{value:t}=e,n=FAe(e,[`value`]);return Object.assign(Object.assign({},n),{value:NF(t,`std_raw`)})})),n}function jL(e){let t=new eL(`invalid end stream`,B.Unknown),n;try{n=JSON.parse(typeof e==`string`?e:new TextDecoder().decode(e))}catch{throw t}if(typeof n!=`object`||!n||Array.isArray(n))throw t;let r=new Headers;if(`metadata`in n){if(typeof n.metadata!=`object`||n.metadata==null||Array.isArray(n.metadata))throw t;for(let[e,i]of Object.entries(n.metadata)){if(!Array.isArray(i)||i.some(e=>typeof e!=`string`))throw t;for(let t of i)r.append(e,t)}}return{metadata:r,error:`error`in n&&n.error!=null?AL(n.error,r,t):void 0}}function RAe(e,t,n){let r={};t!==void 0&&(r.error=LAe(t,n),t.isWireError||jAe(e,t.metadata));let i=!1,a={};return e.forEach((e,t)=>{i=!0,a[t]=[e]}),i&&(r.metadata=a),r}function zAe(e){let t=new TextEncoder;return{serialize(n){try{let r=RAe(n.metadata,n.error,e),i=JSON.stringify(r);return t.encode(i)}catch(e){throw new eL(`failed to serialize EndStreamResponse: ${e instanceof Error?e.message:String(e)}`,B.Internal)}},parse(e){try{return jL(e)}catch(e){throw new eL(`failed to parse EndStreamResponse: ${e instanceof Error?e.message:String(e)}`,B.InvalidArgument)}}}}function BAe(e){switch(e){case 400:return B.Internal;case 401:return B.Unauthenticated;case 403:return B.PermissionDenied;case 404:return B.Unimplemented;case 429:return B.Unavailable;case 502:return B.Unavailable;case 503:return B.Unavailable;case 504:return B.Unavailable;default:return B.Unknown}}function ML(e){let t=new Headers,n=new Headers;return e.forEach((e,r)=>{r.toLowerCase().startsWith(`trailer-`)?n.append(r.substring(8),e):t.append(r,e)}),[t,n]}function NL(e,t,n,r,i){let a=new Headers(r??{});return n!==void 0&&a.set(vL,`${n}`),a.set(fL,e==`unary`?t?`application/proto`:`application/json`:t?`application/connect+proto`:`application/connect+json`),a.set(yL,`1`),!a.has(`User-Agent`)&&i&&a.set(bL,`connect-es/2.3.0`),a}function PL(e,t,n,r,i,a,o){let s=NL(e,t,n,r,o);if(a!=null){let t=e==`unary`?mL:hL;s.set(t,a.name)}if(i.length>0){let t=e==`unary`?gL:_L;s.set(t,i.map(e=>e.name).join(`,`))}return s}function FL(e,t,n,r){let i=r.get(fL),a=PAe(i);if(n!==200){let t=new eL(`HTTP ${n}`,BAe(n),r);if(e==`unary`&&a&&!a.binary)return{isUnaryError:!0,unaryError:t};throw t}let o={binary:t,stream:e!==`unary`};if(a?.binary!==o.binary||a.stream!==o.stream)throw new eL(`unsupported content type ${i}`,a===void 0?B.Unknown:B.Internal,r);return{isUnaryError:!1}}function IL(e,t,n,r,i){let a,o=i.get(e==`unary`?mL:hL);if(o!=null&&o.toLowerCase()!==`identity`&&(a=t.find(e=>e.name===o),!a))throw new eL(`unsupported response encoding "${o}"`,B.Internal,i);return Object.assign({compression:a},FL(e,n,r,i))}function VAe(e,t){return t?NF(e,`url`):encodeURIComponent(new TextDecoder().decode(e))}function LL(e,t,n){let r=`?connect=v1`,i=``,a=e.header.get(mL);a!==null&&a!==`identity`&&(i=`&compression=`+encodeURIComponent(a),n=!0),n&&(r+=`&base64=1`),r+=i;let o=e.header.get(fL);o?.indexOf(`application/`)===0&&(r+=`&encoding=`+encodeURIComponent(o.slice(12))),r+=`&message=`+VAe(t,n);let s=e.url+r,c=new Headers(e.header);for(let e of[yL,fL,pL,mL,gL])c.delete(e);return Object.assign(Object.assign({},e),{requestMethod:`GET`,url:s,header:c})}function RL(e){let t=CL(e.next,e.interceptors),[n,r,i]=BL(e);return t(Object.assign(Object.assign({},e.req),{message:SL(e.req.method.input,e.req.message),signal:n})).then(e=>(i(),e),r)}function zL(e){let[t,n,r]=BL(e),i=!1,a=new Promise(e=>{t.aborted?e():t.addEventListener(`abort`,()=>e())});return a.then(()=>{var n,r;let a=e.req.message[Symbol.asyncIterator]();if(!i){let e=eL.from(lL(t),B.Canceled);(n=a.throw)==null||n.call(a,e).catch(()=>{})}(r=a.return)==null||r.call(a).catch(()=>{})}),CL(async r=>{let o=await e.next(r),s=o.message[Symbol.asyncIterator]();return a.then(()=>s.return?.call(s).catch(()=>{})),Object.assign(Object.assign({},o),{message:{[Symbol.asyncIterator]:()=>({next:async()=>{let e=t.aborted?void 0:await Promise.race([s.next(),a]);return e===void 0?i?{done:!0,value:void 0}:n(lL(t)):e}})}})},e.interceptors)(Object.assign(Object.assign({},e.req),{message:MAe(e.req.method.input,e.req.message),signal:t})).then(e=>{let o=e.message[Symbol.asyncIterator](),s=a.then(async()=>{try{for(;(await o.next()).done!==!0;);}catch{}});return Object.assign(Object.assign({},e),{message:{[Symbol.asyncIterator]:()=>({async next(){if(t.aborted)return await s,i?{done:!0,value:void 0}:n(lL(t));try{let e=await o.next();return e.done===!0&&(i=!0,r()),e}catch(e){return n(e)}},async return(e){return t.aborted||(i=!0,r()),await s,{done:!0,value:e}},async throw(e){if(i)throw eL.from(e);try{return await n(e)}finally{await s}}})}})},n)}function BL(e){let{signal:t,cleanup:n}=kAe(e.timeoutMs),r=OAe(e.signal,t);return[r.signal,function(e){let t=r.signal.aborted?eL.from(lL(r.signal),B.Canceled):eL.from(e);return r.abort(t),n(),Promise.reject(t)},function(){n(),r.abort()}]}var HAe=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},VL=function(e){return this instanceof VL?(this.v=e,this):new VL(e)},UAe=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof VL?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function WAe(e){return{async unary(t,n,r,i,a,o){let s=TL(t,e.binaryOptions,e.jsonOptions,e);return r=r===void 0?e.defaultTimeoutMs:r<=0?void 0:r,await RL({interceptors:e.interceptors,signal:n,timeoutMs:r,req:{stream:!1,service:t.parent,method:t,requestMethod:`POST`,url:xL(e.baseUrl,t),header:PL(t.methodKind,e.useBinaryFormat,r,i,e.acceptCompression,e.sendCompression,!0),contextValues:o??uL(),message:a},next:async n=>{let r=s.getI(e.useBinaryFormat).serialize(n.message);e.sendCompression&&r.byteLength>e.compressMinBytes?(r=await e.sendCompression.compress(r),n.header.set(mL,e.sendCompression.name)):n.header.delete(mL);let i=e.useHttpGet===!0&&t.idempotency===aI.NO_SIDE_EFFECTS,a;i?n=LL(n,r,e.useBinaryFormat):a=bAe([r]);let o=await e.httpClient({url:n.url,method:n.requestMethod,header:n.header,signal:n.signal,body:a}),{compression:c,isUnaryError:l,unaryError:u}=IL(t.methodKind,e.acceptCompression,e.useBinaryFormat,o.status,o.header),[d,f]=ML(o.header),p=await sAe(o.body,lAe(e.readMaxBytes,o.header.get(pL)),{propagateDownStreamError:!1});if(c&&(p=await c.decompress(p,e.readMaxBytes)),l)throw IAe(p,Zke(d,f),u);return{stream:!1,service:t.parent,method:t,header:d,message:s.getO(e.useBinaryFormat).parse(p),trailer:f}}})},async stream(t,n,r,i,a,o){let s=TL(t,e.binaryOptions,e.jsonOptions,e),c=zAe(e.jsonOptions);return r=r===void 0?e.defaultTimeoutMs:r<=0?void 0:r,zL({interceptors:e.interceptors,signal:n,timeoutMs:r,req:{stream:!0,service:t.parent,method:t,requestMethod:`POST`,url:xL(e.baseUrl,t),header:PL(t.methodKind,e.useBinaryFormat,r,i,e.acceptCompression,e.sendCompression,!0),contextValues:o??uL(),message:a},next:async n=>{let r=await e.httpClient({url:n.url,method:`POST`,header:n.header,signal:n.signal,body:aL(n.message,dAe(s.getI(e.useBinaryFormat)),pAe(e.sendCompression,e.compressMinBytes),hAe(),{propagateDownStreamError:!0})}),{compression:i}=IL(t.methodKind,e.acceptCompression,e.useBinaryFormat,r.status,r.header),a=Object.assign(Object.assign({},n),{header:r.header,trailer:new Headers,message:aL(r.body,gAe(e.readMaxBytes),mAe(i??null,e.readMaxBytes),fAe(s.getO(e.useBinaryFormat),2,c),function(e){return UAe(this,arguments,function*(){var t,n,i,o;let s=!1;try{for(var c=!0,l=HAe(e),u;u=yield VL(l.next()),t=u.done,!t;c=!0){o=u.value,c=!1;let e=o;if(e.end){if(s)throw new eL(`protocol error: received extra EndStreamResponse`,B.InvalidArgument);if(s=!0,e.value.error){let t=e.value.error;throw r.header.forEach((e,n)=>{t.metadata.append(n,e)}),t}e.value.metadata.forEach((e,t)=>a.trailer.set(t,e));continue}if(s)throw new eL(`protocol error: received extra message after EndStreamResponse`,B.InvalidArgument);yield yield VL(e.value)}}catch(e){n={error:e}}finally{try{!c&&!t&&(i=l.return)&&(yield VL(i.call(l)))}finally{if(n)throw n.error}}if(!s)throw new eL(`protocol error: missing EndStreamResponse`,B.InvalidArgument)})},{propagateDownStreamError:!0})});return a}})}}}function GAe(){try{new Headers}catch{throw Error(`connect-web requires the fetch API. Are you running on an old version of Node.js?`)}}var HL=function(e){return this instanceof HL?(this.v=e,this):new HL(e)},KAe=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof HL?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};const UL={redirect:`error`};function qAe(e){GAe();let t=e.useBinaryFormat??!1;return{async unary(n,r,i,a,o,s){let{serialize:c,parse:l}=EL(n,t,e.jsonOptions,e.binaryOptions);return i=i===void 0?e.defaultTimeoutMs:i<=0?void 0:i,await RL({interceptors:e.interceptors,signal:r,timeoutMs:i,req:{stream:!1,service:n.parent,method:n,requestMethod:`POST`,url:xL(e.baseUrl,n),header:NL(n.methodKind,t,i,a,!1),contextValues:s??uL(),message:o},next:async r=>{let i=e.useHttpGet===!0&&n.idempotency===aI.NO_SIDE_EFFECTS,a=null;i?r=LL(r,c(r.message),t):a=c(r.message);let o=await(e.fetch??globalThis.fetch)(r.url,Object.assign(Object.assign({},UL),{method:r.requestMethod,headers:r.header,signal:r.signal,body:a})),{isUnaryError:s,unaryError:u}=FL(n.methodKind,t,o.status,o.headers);if(s)throw AL(await o.json(),Zke(...ML(o.headers)),u);let[d,f]=ML(o.headers);return{stream:!1,service:n.parent,method:n,header:d,message:t?l(new Uint8Array(await o.arrayBuffer())):Eke(n.output,await o.json(),wL(e.jsonOptions)),trailer:f}}})},async stream(n,r,i,a,o,s){let{serialize:c,parse:l}=EL(n,t,e.jsonOptions,e.binaryOptions);function u(e,t,n,r){return KAe(this,arguments,function*(){let r=nAe(e).getReader(),i=!1;for(;;){let e=yield HL(r.read());if(e.done)break;let{flags:a,data:o}=e.value;if((a&1)==1)throw new eL(`protocol error: received unsupported compressed output`,B.Internal);if((a&2)==2){i=!0;let e=jL(o);if(e.error){let t=e.error;throw n.forEach((e,n)=>{t.metadata.append(n,e)}),t}e.metadata.forEach((e,n)=>t.set(n,e));continue}yield yield HL(l(o))}if(!i)throw`missing EndStreamResponse`})}async function d(e){if(n.methodKind!=`server_streaming`)throw`The fetch API does not support streaming request bodies`;let t=await e[Symbol.asyncIterator]().next();if(t.done==1)throw`missing request message`;return aAe(0,c(t.value))}return i=i===void 0?e.defaultTimeoutMs:i<=0?void 0:i,await zL({interceptors:e.interceptors,timeoutMs:i,signal:r,req:{stream:!0,service:n.parent,method:n,requestMethod:`POST`,url:xL(e.baseUrl,n),header:NL(n.methodKind,t,i,a,!1),contextValues:s??uL(),message:o},next:async r=>{let i=await(e.fetch??globalThis.fetch)(r.url,Object.assign(Object.assign({},UL),{method:r.requestMethod,headers:r.header,signal:r.signal,body:await d(r.message)}));if(FL(n.methodKind,t,i.status,i.headers),i.body===null)throw`missing response body`;let a=new Headers;return Object.assign(Object.assign({},r),{header:i.headers,trailer:a,message:u(i.body,a,i.headers,r.signal)})}})}}}var WL=dee(eDe(),1);const GL=(e=0)=>t=>`\u001B[${t+e}m`,KL=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,qL=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,JL={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(JL.modifier);const JAe=Object.keys(JL.color),YAe=Object.keys(JL.bgColor);[...JAe,...YAe];function XAe(){let e=new Map;for(let[t,n]of Object.entries(JL)){for(let[t,r]of Object.entries(n))JL[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=JL[t],e.set(r[0],r[1]);Object.defineProperty(JL,t,{value:n,enumerable:!1})}return Object.defineProperty(JL,"codes",{value:e,enumerable:!1}),JL.color.close=`\x1B[39m`,JL.bgColor.close=`\x1B[49m`,JL.color.ansi=GL(),JL.color.ansi256=KL(),JL.color.ansi16m=qL(),JL.bgColor.ansi=GL(10),JL.bgColor.ansi256=KL(10),JL.bgColor.ansi16m=qL(10),Object.defineProperties(JL,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>JL.rgbToAnsi256(...JL.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>JL.ansi256ToAnsi(JL.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>JL.ansi256ToAnsi(JL.hexToAnsi256(e)),enumerable:!1}}),JL}const YL=XAe();function XL(e,t=globalThis.Deno?globalThis.Deno.args:we.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:ZL}=we;let QL;XL(`no-color`)||XL(`no-colors`)||XL(`color=false`)||XL(`color=never`)?QL=0:(XL(`color`)||XL(`colors`)||XL(`color=true`)||XL(`color=always`))&&(QL=1);function ZAe(){if(`FORCE_COLOR`in ZL)return ZL.FORCE_COLOR===`true`?1:ZL.FORCE_COLOR===`false`?0:ZL.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(ZL.FORCE_COLOR,10),3)}function QAe(e){return e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function $Ae(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let i=ZAe();i!==void 0&&(QL=i);let a=r?QL:i;if(a===0)return 0;if(r){if(XL(`color=16m`)||XL(`color=full`)||XL(`color=truecolor`))return 3;if(XL(`color=256`))return 2}if(`TF_BUILD`in ZL&&`AGENT_NAME`in ZL)return 1;if(e&&!t&&a===void 0)return 0;let o=a||0;if(ZL.TERM===`dumb`)return o;if(we.platform===`win32`){let e=n.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in ZL)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in ZL)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in ZL)||ZL.CI_NAME===`codeship`?1:o;if(`TEAMCITY_VERSION`in ZL)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(ZL.TEAMCITY_VERSION);if(ZL.COLORTERM===`truecolor`||ZL.TERM===`xterm-kitty`||ZL.TERM===`xterm-ghostty`||ZL.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in ZL){let e=Number.parseInt((ZL.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(ZL.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(ZL.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(ZL.TERM)||`COLORTERM`in ZL?1:o}function $L(e,t={}){return QAe($Ae(e,{streamIsTTY:e&&e.isTTY,...t}))}const eje={stdout:$L({isTTY:Te.isatty(1)}),stderr:$L({isTTY:Te.isatty(2)})};function tje(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function nje(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
454
454
|
`:`
|
|
455
455
|
`)+n,i=r+1,r=e.indexOf(`
|